:root {
  --bg: #f6f5f2;
  --surface: #ffffff;
  --surface-2: #efede8;
  --fg: #1b1a17;
  --muted: #6b675f;
  --border: #e2dfd8;
  --accent: #1f6f4a;
  --accent-fg: #ffffff;
  --warn: #9a5b00;
  --warn-bg: #fdf1dc;
  --bad: #8a2b2b;
  --bad-bg: #f8e3e1;
  --ok-bg: #e2f1e8;
  --radius: 14px;
  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  --font: ui-sans-serif, -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111110;
    --surface: #1b1a18;
    --surface-2: #252421;
    --fg: #f1efe9;
    --muted: #a19c92;
    --border: #2f2d29;
    --accent: #4cc28a;
    --accent-fg: #0d1f16;
    --warn: #f0b552;
    --warn-bg: #3a2c12;
    --bad: #f08a80;
    --bad-bg: #3b1d1a;
    --ok-bg: #16301f;
  }
}
* { box-sizing: border-box; }
html { text-wrap: pretty; -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--fg); font: 15px/1.45 var(--font); }
h1, h2 { margin: 0; letter-spacing: -0.01em; }
h1 { font-size: 22px; }
h2 { font-size: 13px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); font-weight: 600; margin-bottom: 10px; }
a { color: var(--accent); }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.num, .price, .kpi .value { font-variant-numeric: tabular-nums; }
.top { padding: 20px clamp(16px, 4vw, 40px) 8px; }
.top p { margin: 2px 0 0; font-size: 13px; }
main { padding: 8px clamp(16px, 4vw, 40px) 60px; max-width: 1500px; }

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 14px; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; }
.kpi .label { font-size: 12px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); font-weight: 600; }
.kpi .value { font-size: 28px; font-weight: 700; margin-top: 4px; letter-spacing: -0.02em; }
.kpi .sub { font-size: 13px; color: var(--muted); margin-top: 2px; }
.kpi.hero .value { color: var(--accent); }

.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 18px; }
.chip { min-height: 36px; padding: 6px 12px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); color: var(--fg); font: inherit; font-size: 14px; cursor: pointer; display: inline-flex; gap: 6px; align-items: center; }
.chip .n { color: var(--muted); font-variant-numeric: tabular-nums; }
.chip.on { background: var(--fg); color: var(--bg); border-color: var(--fg); }
.chip.on .n { color: inherit; opacity: 0.75; }

.spotlight { margin-bottom: 18px; }
.strip { display: flex; gap: 12px; overflow-x: auto; padding-bottom: 6px; scroll-snap-type: x proximity;
  mask-image: linear-gradient(to right, #000 calc(100% - 40px), transparent); }
.spot { flex: 0 0 150px; scroll-snap-align: start; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 8px; cursor: pointer; text-align: left; font: inherit; color: inherit; }
.spot img { width: 100%; aspect-ratio: 5 / 7; object-fit: cover; border-radius: 8px; display: block; background: var(--surface-2); }
.spot .rank { font-size: 12px; color: var(--muted); margin-top: 6px; }
.spot .nm { font-weight: 600; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.spot .price { font-weight: 700; color: var(--accent); }

.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; position: sticky; top: 0; z-index: 5; background: var(--bg); padding: 10px 0; }
.toolbar input, .toolbar select { min-height: 44px; border: 1px solid var(--border); background: var(--surface); color: var(--fg); border-radius: 10px; padding: 0 12px; font: inherit; }
.toolbar input { flex: 1 1 240px; }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.seg button { min-height: 42px; padding: 0 14px; border: 0; background: var(--surface); color: var(--fg); font: inherit; cursor: pointer; }
.seg button.on { background: var(--fg); color: var(--bg); }
.count { margin: 2px 0 12px; font-size: 13px; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 14px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 8px; display: flex; flex-direction: column; gap: 8px; }
.card .thumb { padding: 0; border: 0; background: var(--surface-2); border-radius: 8px; cursor: zoom-in; display: block; }
.card .thumb img { width: 100%; aspect-ratio: 5 / 7; object-fit: cover; display: block; border-radius: 8px; }
.card .body { padding: 0 4px 4px; display: flex; flex-direction: column; gap: 4px; flex: 1; }
.card .nm { font-weight: 650; font-size: 15px; line-height: 1.25; }
.card .sub { font-size: 13px; color: var(--muted); }
.prices { display: flex; gap: 12px; align-items: baseline; margin-top: 2px; }
.prices .raw { font-size: 20px; font-weight: 700; }
.prices .raw.none { font-size: 14px; font-weight: 500; color: var(--muted); }
.prices .psa { font-size: 13px; color: var(--muted); }
.badges { display: flex; flex-wrap: wrap; gap: 4px; }
.badge { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; border-radius: 6px; padding: 2px 6px; background: var(--surface-2); color: var(--muted); }
.badge.priced { background: var(--ok-bg); color: var(--accent); }
.badge.review { background: var(--warn-bg); color: var(--warn); }
.badge.unpriced { background: var(--surface-2); color: var(--muted); }
.badge.occluded, .badge.low { background: var(--bad-bg); color: var(--bad); }
.links { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 13px; margin-top: auto; padding-top: 4px; align-items: center; }
.links .edit { margin-left: auto; }
.note { font-size: 12px; color: var(--muted); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

button.ghost, button.primary, .links .edit { min-height: 36px; padding: 0 12px; border-radius: 10px; font: inherit; font-size: 14px; cursor: pointer; border: 1px solid var(--border); background: var(--surface); color: var(--fg); transition: transform 120ms var(--ease-out); }
button.primary { background: var(--accent); color: var(--accent-fg); border-color: var(--accent); font-weight: 600; }
button:active { transform: scale(0.97); }
button:disabled { opacity: 0.6; cursor: progress; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
table { border-collapse: collapse; width: 100%; font-size: 14px; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); vertical-align: middle; white-space: nowrap; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); position: sticky; top: 0; background: var(--surface); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td.name { white-space: normal; min-width: 180px; font-weight: 600; }
td img { width: 40px; height: 56px; object-fit: cover; border-radius: 4px; display: block; cursor: zoom-in; }

.overlay { position: fixed; inset: 0; background: rgb(0 0 0 / 0.55); display: grid; place-items: center; padding: 16px; z-index: 20; opacity: 0; transition: opacity 180ms var(--ease-out); }
.overlay.open { opacity: 1; }
.overlay[hidden] { display: none; }
.panel { background: var(--surface); color: var(--fg); border-radius: 16px; border: 1px solid var(--border); max-height: calc(100vh - 32px); display: flex; flex-direction: column; transform: scale(0.96); opacity: 0; transition: transform 180ms var(--ease-out), opacity 180ms var(--ease-out); }
.overlay.open .panel { transform: scale(1); opacity: 1; }
.panel-head, .panel-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 12px 14px; }
.panel-foot { justify-content: flex-end; border-top: 1px solid var(--border); }
.lightbox-panel { width: min(720px, 100%); }
.lightbox-panel img { max-height: calc(100vh - 110px); max-width: 100%; object-fit: contain; display: block; margin: 0 auto 14px; border-radius: 6px; }
.edit-panel { width: min(760px, 100%); overflow: auto; }
.edit-body { display: grid; grid-template-columns: 200px 1fr; gap: 16px; padding: 0 14px 14px; }
.edit-body img { width: 100%; aspect-ratio: 5 / 7; object-fit: cover; border-radius: 10px; background: var(--surface-2); }
.fields { display: flex; flex-direction: column; gap: 10px; }
.fields label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; }
.fields input, .fields select { min-height: 44px; border: 1px solid var(--border); background: var(--bg); color: var(--fg); border-radius: 10px; padding: 0 12px; font: 15px var(--font); text-transform: none; letter-spacing: 0; }
.fields label.check { flex-direction: row; align-items: center; gap: 10px; min-height: 44px; text-transform: none; letter-spacing: 0; font-size: 14px; color: var(--fg); font-weight: 500; cursor: pointer; }
.fields label.check input { min-height: 0; width: 20px; height: 20px; accent-color: var(--accent); }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.msg { min-height: 20px; margin: 0; font-size: 14px; }
.msg.ok { color: var(--accent); }
.msg.err { color: var(--bad); }
.empty { padding: 40px; text-align: center; color: var(--muted); grid-column: 1 / -1; }
@media (max-width: 640px) {
  .edit-body { grid-template-columns: 1fr; }
  .edit-body img { width: 140px; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(155px, 1fr)); gap: 10px; }
  .kpi .value { font-size: 22px; }
}
@media (prefers-reduced-motion: reduce) {
  .overlay, .panel, button { transition: none; }
}
