:root {
  --bg: #f4f6f8;
  --surface: #ffffff;
  --text: #1f2933;
  --muted: #607080;
  --primary: #0d6e6e;
  --danger: #b42318;
  --border: #d6dde5;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Segoe UI", "Helvetica Neue", sans-serif;
  background: var(--bg);
  color: var(--text);
}

.container {
  width: min(1080px, 94vw);
  margin: 0 auto;
}

.row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.site-header,
.site-footer {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.site-footer {
  margin-top: 2rem;
  border-top: 1px solid var(--border);
  border-bottom: 0;
  padding: 1rem 0;
}

.footer-content {
  display: grid;
  gap: 0.75rem;
}

.footer-about strong {
  display: block;
  margin-bottom: 0.2rem;
}

.footer-about p {
  margin: 0.25rem 0;
  color: var(--muted);
}

.footer-meta {
  font-size: 0.92rem;
}

.footer-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.8rem;
}

.footer-links a {
  color: var(--primary);
  font-weight: 600;
  text-decoration: none;
}

.brand {
  text-decoration: none;
  color: var(--text);
  font-weight: 700;
  font-size: 1.1rem;
  padding: 1rem 0;
}

.main-nav {
  display: flex;
  gap: 0.8rem;
  flex-wrap: wrap;
}

.main-nav a {
  color: var(--primary);
  text-decoration: none;
  font-weight: 600;
}

.admin-subnav-wrap {
  margin: 1rem 0 1.2rem;
}

.admin-subnav {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  background: #e8eef2;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.45rem;
}

.admin-subnav a {
  color: #26414f;
  text-decoration: none;
  font-weight: 600;
  border-radius: 9px;
  padding: 0.45rem 0.75rem;
}

.admin-subnav a.is-active {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--primary);
}

h1,
h2,
h3 {
  margin-top: 1.2rem;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1rem;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1rem;
  margin: 1rem 0 2rem;
}

.listing-image {
  width: 100%;
  height: 190px;
  object-fit: cover;
  border-radius: 8px;
  background: #e9eff5;
}

.listing-image-link {
  display: block;
}

.listing-title-link {
  color: inherit;
  text-decoration: none;
}

.listing-title-link:hover {
  text-decoration: underline;
}

.listing-card h3 {
  margin-bottom: 0.4rem;
}

.listing-image-placeholder {
  border: 1px dashed #c3ced9;
}

.text-link {
  color: var(--primary);
  font-weight: 600;
}

.listing-card-compact .listing-image {
  height: 150px;
}

.listing-card-compact .price {
  font-size: 1.05rem;
  margin: 0.4rem 0;
}

.variant-switcher {
  margin-top: 1rem;
}

.variant-switcher h2 {
  margin: 0 0 0.7rem;
  font-size: 1rem;
}

.variant-links {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.listing-gallery {
  display: grid;
  gap: 0.7rem;
  margin-top: 0.7rem;
}

.listing-gallery-main-wrap {
  margin: 0;
}

.listing-gallery-main {
  width: 100%;
  height: clamp(360px, 56vw, 640px);
  object-fit: contain;
  border-radius: 10px;
  border: 0;
  background: #fff;
  box-shadow: none;
}

.listing-gallery-carousel .listing-gallery-main {
  cursor: pointer;
  touch-action: pan-y;
}

.listing-gallery-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(90px, 1fr));
  gap: 0.5rem;
}

.listing-gallery-counter {
  text-align: center;
  font-weight: 700;
  color: var(--muted);
  margin-top: 0.15rem;
}

.listing-gallery-thumb {
  border: 2px solid transparent;
  border-radius: 10px;
  padding: 0;
  background: transparent;
}

.listing-gallery-thumb img {
  width: 100%;
  height: 85px;
  object-fit: cover;
  border-radius: 8px;
  border: 2px solid #fff;
  display: block;
}

.listing-gallery-thumb.is-active {
  border-color: var(--primary);
  border-width: 4px;
  box-shadow: none;
}

.listing-gallery-thumbs_side {
  grid-template-columns: 1fr;
}

.listing-gallery-controls {
  display: flex;
  gap: 0.5rem;
  justify-content: center;
}

.listing-gallery-controls .button {
  min-width: 130px;
}

.listing-gallery-carousel .listing-gallery-strip {
  display: flex;
  gap: 0.45rem;
  overflow-x: auto;
  overflow-y: hidden;
  white-space: nowrap;
  padding-bottom: 0.25rem;
  scrollbar-width: thin;
}

.listing-gallery-carousel .listing-gallery-thumb {
  flex: 0 0 auto;
}

.listing-gallery-carousel .listing-gallery-thumb img {
  width: 86px;
  height: 62px;
}

.listing-gallery-carousel_v2 .listing-gallery-v2-viewport {
  overflow: hidden;
  border-radius: 10px;
  border: 0;
  background: #fff;
  cursor: grab;
  touch-action: pan-y;
  box-shadow: none;
}

.listing-gallery-carousel_v2 .listing-gallery-v2-viewport.is-dragging {
  cursor: grabbing;
}

.listing-gallery-carousel_v2 .listing-gallery-v2-track {
  display: flex;
  will-change: transform;
}

.listing-gallery-carousel_v2 .listing-gallery-v2-slide {
  flex: 0 0 100%;
  min-width: 100%;
}

.listing-gallery-carousel_v2 .listing-gallery-v2-slide .listing-gallery-main {
  border: 0;
  border-radius: 0;
  user-select: none;
  -webkit-user-drag: none;
}

.listing-gallery-carousel_v2 .listing-gallery-strip {
  display: flex;
  gap: 0.45rem;
  overflow-x: auto;
  overflow-y: hidden;
  white-space: nowrap;
  padding-bottom: 0.25rem;
  scrollbar-width: thin;
}

.listing-gallery-carousel_v2 .listing-gallery-thumb {
  flex: 0 0 auto;
}

.listing-gallery-carousel_v2 .listing-gallery-thumb img {
  width: 74px;
  height: 52px;
}

.listing-lightbox[hidden] {
  display: none;
}

.listing-lightbox {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: #000;
  display: grid;
  grid-template-rows: auto 1fr auto;
  align-items: center;
  justify-items: center;
  gap: 0.5rem;
  padding: 0.7rem;
}

.listing-lightbox-close {
  justify-self: end;
}

.listing-lightbox-stage {
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
  overflow: hidden;
}

.listing-lightbox-viewport {
  width: 100%;
  height: 100%;
  overflow: hidden;
  touch-action: none;
  cursor: grab;
}

.listing-lightbox-viewport.is-dragging {
  cursor: grabbing;
}

.listing-lightbox-track {
  display: flex;
  width: 100%;
  height: 100%;
  will-change: transform;
}

.listing-lightbox-slide {
  flex: 0 0 100%;
  min-width: 100%;
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
  overflow: hidden;
  background: #000;
}

.listing-lightbox-slide img {
  display: block;
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  transform-origin: 50% 50%;
  transition: transform 180ms ease;
  will-change: transform;
  backface-visibility: hidden;
  user-select: none;
  -webkit-user-drag: none;
}

.listing-lightbox-slide img.is-zoomed {
  transform: scale(2);
}

.listing-lightbox-controls {
  display: flex;
  gap: 0.6rem;
  width: min(460px, 100%);
}

.listing-lightbox-counter {
  color: #d9e0e6;
  font-size: 0.92rem;
  font-weight: 600;
}

.listing-lightbox-controls .button {
  flex: 1 1 0;
}

body.lightbox-open {
  overflow: hidden;
}

.badge {
  display: inline-block;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 700;
  background: #e0f2f2;
  color: var(--primary);
}

.price {
  font-size: 1.2rem;
  font-weight: 700;
  margin: 0.6rem 0;
}

a.button,
button,
input[type="submit"] {
  display: inline-block;
  border: 0;
  border-radius: 10px;
  background: var(--primary);
  color: white;
  padding: 0.65rem 0.9rem;
  text-decoration: none;
  font-weight: 600;
  cursor: pointer;
  touch-action: manipulation;
}

button.secondary,
a.button.secondary {
  background: #607080;
}

button.danger,
a.button.danger {
  background: var(--danger);
}

form.inline {
  display: inline;
}

label {
  display: block;
  font-weight: 600;
  margin-top: 0.8rem;
}

input,
textarea,
select {
  width: 100%;
  padding: 0.65rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  margin-top: 0.3rem;
  font: inherit;
}

textarea {
  min-height: 130px;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-top: 1rem;
}

.filters {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.8rem;
  align-items: end;
  margin: 1rem 0;
}

.type-filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  margin: 1rem 0;
}

.type-filter-button {
  display: inline-block;
  padding: 0.6rem 0.9rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: #f0f5f8;
  color: #26414f;
  font-weight: 700;
  text-decoration: none;
}

.type-filter-button.is-active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.listing-filter {
  margin: 1rem 0;
  padding: 0.8rem;
}

.listing-filter-topbar {
  display: grid;
  grid-template-columns: auto auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.55rem;
}

.listing-filter-chip-row {
  display: flex;
  gap: 0.45rem;
  flex-wrap: nowrap;
  overflow-x: auto;
  overflow-y: hidden;
  white-space: nowrap;
  padding-bottom: 0.15rem;
  scrollbar-width: thin;
}

.listing-filter-divider {
  width: 1px;
  height: 2rem;
  background: #cfd9e2;
}

.filter-chip {
  display: inline-block;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.35rem 0.7rem;
  font-size: 0.9rem;
  line-height: 1.1;
  text-decoration: none;
  color: #27404d;
  background: #f6f9fb;
  font-weight: 600;
}

.filter-chip.is-active {
  color: #fff;
  background: var(--primary);
  border-color: var(--primary);
}

.listing-filter-toggle {
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #eef4f8;
  color: #27404d;
  padding: 0.45rem 0.75rem;
  font-weight: 700;
}

.listing-sort-inline {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin: 0;
}

.listing-sort-inline label {
  margin: 0;
  font-size: 0.88rem;
  color: #405869;
}

.listing-sort-inline select {
  width: auto;
  min-width: 165px;
  margin: 0;
  padding: 0.45rem 0.5rem;
}

.listing-filter-form {
  display: grid;
  gap: 0.7rem;
  margin-top: 0.7rem;
}

.listing-filter-inline {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) minmax(150px, 210px);
  gap: 0.55rem;
  align-items: end;
}

.listing-filter-inline input,
.listing-filter-inline select {
  margin-top: 0;
}

.listing-filter-panel {
  display: none;
  margin-top: 0;
}

.listing-filter-panel[open] {
  display: block;
  border: 1px dashed var(--border);
  border-radius: 10px;
  padding: 0.55rem 0.65rem 0.65rem;
  background: #fbfdff;
  margin-top: 0.55rem;
}

.listing-filter-panel summary {
  display: none;
}

.price-slider-filter {
  border: 1px solid #d9e3ea;
  border-radius: 10px;
  padding: 0.55rem 0.65rem 0.7rem;
  background: #f7fbfe;
}

.price-slider-head {
  display: flex;
  justify-content: space-between;
  gap: 0.6rem;
  align-items: center;
  margin-bottom: 0.45rem;
  color: #2a4452;
}

.price-slider-filter input[type="range"] {
  margin: 0.15rem 0;
  width: 100%;
}

.listing-filter-grid {
  margin-top: 0.6rem;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.6rem;
}

.listing-filter-grid label {
  margin-top: 0;
  font-weight: 600;
  font-size: 0.92rem;
}

.listing-filter-grid input,
.listing-filter-grid select {
  margin-top: 0.2rem;
}

.company-summary {
  margin: 0 0 1.4rem;
}

.company-summary h2 {
  margin-top: 0;
}

.company-summary-link {
  margin: 1rem 0 0;
}

.gallery {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 0.7rem;
  margin-top: 1rem;
}

.gallery img {
  width: 100%;
  height: 150px;
  object-fit: cover;
  border-radius: 8px;
}

.flash {
  padding: 0.7rem 0.9rem;
  border-radius: 8px;
  margin-top: 1rem;
}

.flash.error {
  background: #fee2e2;
  color: #991b1b;
}

.flash.success {
  background: #dcfce7;
  color: #166534;
}

.kv {
  display: grid;
  grid-template-columns: 180px 1fr;
  gap: 0.4rem 0.8rem;
}

.admin-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 1rem;
}

.admin-card h2 {
  margin-top: 0;
}

.admin-help {
  color: var(--muted);
  margin: 0.35rem 0 0.8rem;
}

.code-input {
  font-family: Consolas, "Courier New", monospace;
  font-size: 0.92rem;
  line-height: 1.45;
}

.upload-log-list {
  display: grid;
  gap: 0.8rem;
}

.upload-log-item {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.8rem;
  background: #f9fbfc;
}

.upload-log-item p {
  margin: 0.25rem 0;
}

.upload-log-reasons {
  margin: 0.25rem 0 0.6rem 1.2rem;
  padding: 0;
}

.admin-view-switch {
  display: flex;
  gap: 0.6rem;
  margin: 0.8rem 0 1rem;
}

.admin-table-wrap {
  overflow-x: auto;
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 780px;
}

.admin-table th,
.admin-table td {
  border-bottom: 1px solid var(--border);
  text-align: left;
  padding: 0.7rem 0.6rem;
  vertical-align: top;
}

.admin-table th {
  background: #f3f7fa;
  font-size: 0.92rem;
}

@media (max-width: 760px) {
  .row {
    align-items: flex-start;
    flex-direction: column;
  }

  .filters {
    grid-template-columns: 1fr;
  }

  .listing-filter-inline {
    grid-template-columns: 1fr;
  }

  .listing-filter-topbar {
    grid-template-columns: auto auto 1fr;
    align-items: start;
  }

  .listing-filter-divider {
    display: none;
  }

  .listing-sort-inline {
    grid-column: 1 / -1;
    justify-content: flex-start;
  }

  .price-slider-head {
    grid-column: 1 / -1;
  }

  .listing-filter-inline button,
  .listing-filter-inline .button {
    width: 100%;
  }

  .footer-meta {
    line-height: 1.5;
  }

  .kv {
    grid-template-columns: 1fr;
  }

  .listing-gallery-main {
    height: clamp(320px, 82vw, 520px);
  }

  .listing-gallery-carousel .listing-gallery-controls {
    width: 100%;
    justify-content: space-between;
  }

  .listing-gallery-carousel .listing-gallery-controls .button {
    flex: 1 1 0;
    min-width: 0;
  }

  .listing-gallery-carousel .listing-gallery-thumb img {
    width: 78px;
    height: 56px;
  }

  .listing-gallery-carousel_v2 .listing-gallery-thumb img {
    width: 68px;
    height: 48px;
  }

  .listing-lightbox {
    padding: 0.5rem;
  }

  .listing-lightbox-stage img {
    max-height: 100%;
  }
}

@media (min-width: 761px) {
  .listing-lightbox {
    padding: 1rem 1.2rem;
  }

  .listing-lightbox-stage {
    width: min(1500px, 96vw);
    height: calc(100vh - 190px);
  }

  .listing-lightbox-slide img {
    max-width: calc(100vw - 180px);
    max-height: calc(100vh - 220px);
  }
}

@media (min-width: 900px) {
  .listing-gallery-thumbs_side {
    grid-template-columns: 1fr 140px;
    align-items: start;
  }

  .listing-gallery-thumbs_side .listing-gallery-strip {
    grid-template-columns: 1fr;
  }

  .listing-gallery-thumbs_side .listing-gallery-thumb img {
    height: 76px;
  }
}

.types-editor-layout {
    display: grid;
    gap: 1.5rem;
    grid-template-columns: minmax(220px, 280px) minmax(0, 1fr);
    align-items: start;
}

.types-sidebar,
.types-main,
.types-raw-json {
    display: grid;
    gap: 1rem;
}

.types-sidebar-head,
.types-main-head,
.attribute-section-head,
.types-raw-json-actions {
    display: flex;
    align-items: start;
    justify-content: space-between;
    gap: 1rem;
}

.types-sidebar-head h2,
.types-main-head h2,
.attribute-section-head h3 {
    margin: 0;
}

.types-sidebar-head p,
.types-main-head p,
.attribute-section-head p,
.types-list-item span,
.attribute-card-head p,
.types-empty p {
    margin: 0;
    color: var(--muted-text);
}

.types-list,
.attribute-list {
    display: grid;
    gap: 0.85rem;
}

.types-list-item {
    display: grid;
    gap: 0.2rem;
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 16px;
    background: #fff;
    padding: 0.9rem 1rem;
    text-align: left;
}

.types-list-item.is-active {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px rgba(36, 131, 120, 0.18);
}

.types-list-empty,
.types-empty {
    border: 1px dashed var(--line);
    border-radius: 16px;
    background: #fafcfd;
    padding: 1rem;
}

.types-meta-grid,
.attribute-grid {
    display: grid;
    gap: 0.9rem;
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.attribute-card {
    display: grid;
    gap: 0.9rem;
    border: 1px solid var(--line);
    border-radius: 18px;
    background: #fff;
    padding: 1rem;
}

.attribute-card-head,
.attribute-card-actions,
.types-main-actions {
    display: flex;
    align-items: start;
    justify-content: space-between;
    gap: 0.75rem;
}

.attribute-card-head h4 {
    margin: 0 0 0.2rem;
}

.types-inline-checkbox {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.types-inline-checkbox input {
    width: 1.1rem;
    height: 1.1rem;
}

@media (max-width: 980px) {
    .types-editor-layout {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 720px) {
    .types-sidebar-head,
    .types-main-head,
    .attribute-section-head,
    .types-raw-json-actions,
    .attribute-card-head,
    .attribute-card-actions,
    .types-main-actions {
        flex-direction: column;
    }

    .types-meta-grid,
    .attribute-grid {
        grid-template-columns: 1fr;
    }
}
