:root {
  --ink: #111827;
  --muted: #667085;
  --soft: #98a2b3;
  --line: #d7dde5;
  --line-soft: #e8edf2;
  --paper: #f6f7f9;
  --panel: #ffffff;
  --panel-subtle: #f1f4f7;
  --accent: #0f5b4f;
  --accent-ink: #083c34;
  --accent-soft: #e7f2ef;
  --blue: #1d4ed8;
  --premium: #8a4b00;
  --premium-line: #e3b15f;
  --premium-soft: #fff7e8;
  --danger: #9b1c1c;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--paper);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

body.has-image-modal {
  overflow: hidden;
}

button,
input,
select {
  font: inherit;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
a:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 2px;
}

.shell {
  min-height: 100vh;
}

.shell[data-auth="checking"] .login,
.shell[data-auth="out"] .login {
  display: grid;
}

.shell[data-auth="in"] .catalog {
  display: block;
}

.login,
.catalog {
  display: none;
}

.login {
  min-height: 100vh;
  place-items: center;
  padding: 32px 18px;
}

.login > * {
  width: min(480px, 100%);
}

.login__brand,
.eyebrow,
.select-field span,
.search label {
  color: var(--accent-ink);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.login h1 {
  margin: 8px 0 10px;
  font-size: clamp(32px, 5vw, 52px);
  line-height: 1;
  font-weight: 650;
}

.login p {
  margin: 0 0 24px;
  color: var(--muted);
  line-height: 1.5;
}

.login__form {
  border-top: 1px solid var(--line);
  padding-top: 22px;
}

.login__form label {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 13px;
}

.password-row,
.search-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

input,
select {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  color: var(--ink);
  padding: 0 10px;
}

select {
  cursor: pointer;
}

button {
  min-height: 38px;
  border: 1px solid var(--ink);
  border-radius: 6px;
  background: var(--ink);
  color: #fff;
  padding: 0 13px;
  cursor: pointer;
}

.ghost,
.secondary {
  background: var(--panel);
  color: var(--ink);
  border-color: var(--line);
}

.secondary {
  width: 100%;
}

.error {
  min-height: 20px;
  margin-top: 10px;
  color: var(--danger);
  font-size: 13px;
}

.catalog {
  min-height: 100vh;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 18px;
  align-items: center;
  min-height: 64px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.96);
  padding: 10px 20px;
  backdrop-filter: blur(10px);
}

.eyebrow {
  margin: 0 0 3px;
}

.topbar h1 {
  margin: 0;
  font-size: 21px;
  line-height: 1.1;
  font-weight: 750;
}

.metrics {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px 14px;
  min-width: 0;
  color: var(--muted);
  font-size: 12px;
}

.metric {
  display: inline-flex;
  gap: 5px;
  align-items: baseline;
  white-space: nowrap;
}

.metric span {
  color: var(--soft);
  text-transform: uppercase;
}

.metric strong {
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  font-weight: 750;
}

.workspace {
  display: grid;
  grid-template-columns: 276px minmax(0, 1fr);
  gap: 16px;
  align-items: start;
  max-width: 1680px;
  margin: 0 auto;
  padding: 16px 20px 28px;
}

.controls {
  position: sticky;
  top: 80px;
  display: grid;
  gap: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 12px;
}

.search label {
  display: block;
  margin-bottom: 7px;
}

.filters {
  display: grid;
  gap: 10px;
}

.filter-toggle {
  display: none;
}

.select-field {
  display: grid;
  gap: 6px;
}

.catalog-main {
  min-width: 0;
}

.results {
  display: grid;
  gap: 12px;
}

.result-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 10px 12px;
  color: var(--muted);
  font-size: 13px;
}

.result-summary strong {
  color: var(--ink);
  font-size: 15px;
  font-variant-numeric: tabular-nums;
}

.result-summary__meta {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.status-pill {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel-subtle);
  color: var(--muted);
  padding: 3px 8px;
  white-space: nowrap;
}

.brand-section {
  display: grid;
  gap: 8px;
}

.brand-heading {
  position: sticky;
  top: 65px;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--accent);
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.96);
  padding: 9px 12px 9px 10px;
  backdrop-filter: blur(8px);
}

.brand-heading h2 {
  margin: 0;
  font-size: 17px;
  line-height: 1.2;
  font-weight: 750;
}

.brand-heading span {
  color: var(--muted);
  font-size: 12px;
}

.model-list {
  display: grid;
  gap: 8px;
}

.model-group {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.03);
}

.model-header {
  display: grid;
  grid-template-columns: 112px minmax(0, 1fr) auto;
  gap: 14px;
  align-items: start;
  min-height: 148px;
  padding: 12px;
}

.model-thumb {
  width: 112px;
  height: 136px;
  display: block;
  object-fit: cover;
  object-position: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.model-thumb--empty {
  display: grid;
  place-items: center;
  color: var(--soft);
  font-size: 10px;
  line-height: 1.2;
  text-align: center;
}

.model-image-button {
  display: block;
  width: 112px;
  height: 136px;
  min-height: 0;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: inherit;
  padding: 0;
  cursor: zoom-in;
}

.model-image-button:hover .model-thumb {
  border-color: var(--accent);
}

.model-image-button .model-thumb {
  pointer-events: none;
}

.model-main {
  min-width: 0;
}

.model-title-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: baseline;
}

.model-title {
  margin: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 15px;
  line-height: 1.25;
  font-weight: 750;
}

.model-price {
  color: var(--accent);
  font-size: 14px;
  font-variant-numeric: tabular-nums;
  font-weight: 800;
  white-space: nowrap;
}

.model-sub,
.model-counts {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-width: 0;
  margin-top: 8px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.3;
}

.model-sub span,
.model-counts span {
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--line-soft);
  border-radius: 6px;
  background: #f8fafc;
  padding: 4px 7px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.price-tiers {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 9px;
}

.price-tier {
  display: inline-flex;
  gap: 5px;
  align-items: baseline;
  max-width: 250px;
  overflow: hidden;
  border: 1px solid var(--line-soft);
  border-radius: 6px;
  background: #f8fafc;
  color: var(--muted);
  padding: 5px 8px;
  font-size: 11.5px;
  line-height: 1.15;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.price-tier strong {
  color: var(--accent);
  font-variant-numeric: tabular-nums;
  font-weight: 800;
}

.price-tier--premium {
  border-color: var(--premium-line);
  background: var(--premium-soft);
  color: var(--premium);
}

.price-tier--premium strong {
  color: var(--premium);
}

.model-toggle {
  min-height: 30px;
  border-color: var(--line);
  background: var(--panel);
  color: var(--accent-ink);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.variant-list {
  border-top: 1px solid var(--line-soft);
  background: #fbfcfd;
}

.variant-header {
  display: grid;
  grid-template-columns: 100px minmax(0, 1fr) 120px 74px;
  gap: 12px;
  align-items: center;
  border-bottom: 1px solid var(--line-soft);
  background: #f3f6f8;
  padding: 8px 12px;
  color: var(--soft);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.variant-row {
  display: grid;
  grid-template-columns: 100px minmax(0, 1fr) 120px 74px;
  gap: 12px;
  align-items: center;
  min-height: 140px;
  border-top: 1px solid var(--line-soft);
  padding: 10px 12px;
  color: var(--ink);
  font-size: 12.5px;
}

.variant-row:first-child {
  border-top: 0;
}

.variant-row:hover {
  background: #ffffff;
}

.variant-row--premium {
  background: var(--premium-soft);
  box-shadow: inset 3px 0 0 var(--premium-line);
}

.variant-row--premium:hover {
  background: #fff3d8;
}

.variant-main {
  min-width: 0;
}

.variant-thumb-cell {
  min-width: 0;
}

.variant-thumb {
  width: 100px;
  height: 126px;
  display: block;
  object-fit: cover;
  object-position: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.variant-thumb--empty {
  display: grid;
  place-items: center;
  color: var(--soft);
  font-size: 10px;
  line-height: 1.2;
  text-align: center;
}

.variant-image-button {
  display: block;
  width: 100px;
  height: 126px;
  min-height: 0;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: inherit;
  padding: 0;
  cursor: zoom-in;
}

.variant-image-button:hover .variant-thumb,
.variant-image-button:focus-visible .variant-thumb {
  border-color: var(--accent);
}

.variant-image-button .variant-thumb {
  pointer-events: none;
}

.variant-main strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13.5px;
  line-height: 1.25;
}

.variant-main .variant-mobile-title {
  display: none;
}

.variant-main > span,
.variant-cell,
.variant-dim {
  color: var(--muted);
}

.variant-main > span {
  display: block;
  margin-top: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 11.5px;
  font-variant-numeric: tabular-nums;
}

.condition-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.condition-pill {
  display: inline-flex;
  gap: 5px;
  align-items: baseline;
  max-width: 100%;
  overflow: hidden;
  border: 1px solid var(--line-soft);
  border-radius: 6px;
  background: #fff;
  color: var(--muted);
  padding: 4px 7px;
  font-size: 11.5px;
  line-height: 1.15;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.condition-pill > span {
  color: var(--soft);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.condition-pill--premium {
  border-color: var(--premium-line);
  background: var(--premium-soft);
  color: var(--premium);
  font-weight: 750;
}

.condition-pill--optional {
  display: none;
}

.variant-price {
  color: var(--accent);
  text-align: right;
  font-size: 15px;
  font-variant-numeric: tabular-nums;
  font-weight: 800;
  white-space: nowrap;
}

.variant-price--premium,
.variant-material--premium {
  color: var(--premium);
  font-weight: 800;
}

.variant-cell,
.variant-dim {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cell-label {
  display: none;
}

.source {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 32px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  color: var(--ink);
  padding: 0 10px;
  font-size: 12px;
  font-weight: 750;
  text-decoration: none;
}

.source:hover {
  border-color: var(--accent);
  color: var(--accent-ink);
}

.more-row {
  border-top: 1px solid var(--line-soft);
  padding: 7px 10px;
  background: var(--panel);
}

.more-row button {
  min-height: 28px;
  border: 0;
  background: transparent;
  color: var(--blue);
  padding: 0;
  font-size: 12px;
  font-weight: 750;
}

.empty {
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 28px;
  text-align: center;
  color: var(--muted);
}

.loading-state {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 18px 20px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 650;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
}

.image-modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 26px;
}

.image-modal[hidden] {
  display: none;
}

.image-modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(17, 24, 39, 0.74);
}

.image-modal__frame {
  position: relative;
  z-index: 1;
  width: min(920px, 100%);
  max-height: min(900px, calc(100vh - 52px));
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  gap: 10px;
  margin: 0;
  border-radius: 8px;
  background: #fff;
  padding: 14px;
  box-shadow: 0 24px 80px rgba(15, 23, 42, 0.35);
}

.image-modal__close {
  position: absolute;
  top: 10px;
  right: 10px;
  min-height: 32px;
  border-color: rgba(17, 24, 39, 0.22);
  background: rgba(255, 255, 255, 0.92);
  color: var(--ink);
  padding: 0 11px;
}

.image-modal__image {
  width: 100%;
  max-height: calc(100vh - 128px);
  min-height: 220px;
  object-fit: contain;
  border-radius: 6px;
  background: #fff;
}

.image-modal__status {
  position: absolute;
  inset: 52px 18px 54px;
  display: none;
  place-items: center;
  color: var(--muted);
  font-size: 14px;
  pointer-events: none;
}

.image-modal[data-state="loading"] .image-modal__status,
.image-modal[data-state="error"] .image-modal__status {
  display: grid;
}

.image-modal[data-state="error"] .image-modal__status {
  color: var(--danger);
}

.image-modal[data-state="error"] .image-modal__image {
  opacity: 0;
}

.image-modal__caption {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
  text-align: center;
}

@media (max-width: 1180px) {
  .workspace {
    grid-template-columns: 240px minmax(0, 1fr);
  }

  .variant-header,
  .variant-row {
    grid-template-columns: 90px minmax(0, 1fr) 106px 66px;
  }

  .variant-thumb,
  .variant-image-button {
    width: 90px;
    height: 112px;
  }
}

@media (max-width: 860px) {
  .topbar {
    position: static;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 10px;
    padding: 12px 14px;
  }

  .metrics {
    grid-column: 1 / -1;
    justify-content: flex-start;
  }

  .workspace {
    grid-template-columns: 1fr;
    gap: 12px;
    padding: 12px 14px 22px;
  }

  .controls {
    position: static;
  }

  .filters {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .secondary {
    grid-column: 1 / -1;
  }

  .brand-heading {
    position: static;
  }
}

@media (max-width: 760px) {
  .topbar h1 {
    font-size: 20px;
  }

  .metrics {
    display: none;
  }

  .ghost {
    min-height: 34px;
    padding: 0 10px;
  }

  .password-row,
  .result-summary,
  .filters {
    grid-template-columns: 1fr;
  }

  .search-row {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 7px;
  }

  .filters {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .filter-toggle {
    display: block;
    width: 100%;
    min-height: 44px;
    border-color: var(--line);
    background: var(--panel);
    color: var(--accent-ink);
    font-weight: 750;
  }

  .controls .filters {
    display: none;
  }

  .controls[data-filters-open="true"] .filters {
    display: grid;
  }

  .select-field:first-child,
  .secondary {
    grid-column: 1 / -1;
  }

  .result-summary {
    display: grid;
  }

  .model-header {
    grid-template-columns: 100px minmax(0, 1fr);
    gap: 10px;
    align-items: start;
    min-height: 0;
    padding: 10px;
  }

  .model-thumb {
    width: 100px;
    height: 122px;
  }

  .model-image-button {
    width: 100px;
    height: 122px;
  }

  .model-header > div:first-child {
    grid-column: 1;
  }

  .model-main {
    grid-column: 2;
  }

  .model-title-row {
    grid-template-columns: 1fr;
    gap: 4px;
  }

  .model-title {
    white-space: normal;
  }

  .model-toggle {
    grid-column: 1 / -1;
    width: 100%;
  }

  .price-tier {
    width: 100%;
    max-width: 100%;
    justify-content: space-between;
    white-space: normal;
  }

  .price-tier strong {
    margin-left: auto;
    white-space: nowrap;
  }

  .variant-row {
    grid-template-columns: 108px minmax(0, 1fr) auto;
    gap: 8px 10px;
    align-items: start;
    min-height: 0;
    padding: 10px;
  }

  .variant-header {
    display: none;
  }

  .variant-thumb-cell {
    grid-column: 1;
    grid-row: 1 / span 6;
  }

  .variant-thumb,
  .variant-image-button {
    width: 108px;
    height: 134px;
  }

  .variant-main {
    grid-column: 2 / 3;
  }

  .variant-main strong {
    white-space: normal;
    font-size: 13px;
    line-height: 1.3;
  }

  .condition-tags {
    gap: 5px;
    margin-top: 7px;
  }

  .condition-pill {
    width: fit-content;
    padding: 4px 6px;
    font-size: 11px;
    white-space: normal;
  }

  .condition-pill > span {
    flex: 0 0 auto;
  }

  .variant-price {
    grid-column: 3;
    grid-row: 1;
    font-size: 14px;
  }

  .variant-cell,
  .variant-dim {
    display: block;
    grid-column: 2 / -1;
    white-space: normal;
    font-size: 12px;
  }

  .source {
    grid-column: 2 / -1;
    width: fit-content;
    min-height: 34px;
  }

  .cell-label {
    display: inline;
    color: var(--soft);
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 0.04em;
    text-transform: uppercase;
  }

  .image-modal {
    padding: 12px;
  }

  .image-modal__frame {
    max-height: calc(100vh - 24px);
    padding: 10px;
  }

  .image-modal__image {
    max-height: calc(100vh - 104px);
  }
}
