/* Layout: a passport-office feel — calm teal cover colour, white data pages, gold stamp as the one accent, mono for IMEI/MRZ data. */
:root {
  --bg: #eef2f0;
  --surface: #ffffff;
  --sunk: #e3e9e6;
  --fg: #10201f;
  --muted: #566764;
  --line: #cfd9d5;
  --brand: #0f4c4a;
  --brand-fg: #ffffff;
  --sun: #b97d00;
  --sun-soft: #f6e7c2;
  --good: #1d7a4c;
  --warn: #9a6400;
  --bad: #b3261e;
  --display: "Bricolage Grotesque", "Segoe UI", system-ui, sans-serif;
  --body: "Figtree", "Segoe UI", system-ui, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;
  --r: 14px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b1615; --surface: #13211f; --sunk: #0f1c1b; --fg: #e5eeeb; --muted: #94a8a3; --line: #26403c;
    --brand: #5cc2b6; --brand-fg: #062120; --sun: #f0b52e; --sun-soft: #3a2e10;
    --good: #5fd39a; --warn: #f0b52e; --bad: #ff8a80; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0b1615; --surface: #13211f; --sunk: #0f1c1b; --fg: #e5eeeb; --muted: #94a8a3; --line: #26403c;
  --brand: #5cc2b6; --brand-fg: #062120; --sun: #f0b52e; --sun-soft: #3a2e10;
  --good: #5fd39a; --warn: #f0b52e; --bad: #ff8a80; color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; } /* .panel/.btn set display, which would otherwise override the hidden attribute */
html { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } * { transition: none !important; animation: none !important; } }
body { margin: 0; background: var(--bg); color: var(--fg); font: 16px/1.55 var(--body); }
img { max-width: 100%; display: block; }
a { color: var(--brand); }
h1, h2, h3 { font-family: var(--display); line-height: 1.12; text-wrap: balance; margin: 0; letter-spacing: -0.01em; }
h1 { font-size: clamp(2rem, 5vw, 3.4rem); font-weight: 700; }
h2 { font-size: clamp(1.5rem, 3vw, 2.1rem); font-weight: 700; }
h3 { font-size: 1.15rem; font-weight: 600; }
p { margin: 0; }
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.eyebrow { font: 600 0.75rem/1 var(--mono); letter-spacing: 0.12em; text-transform: uppercase; color: var(--sun); }
:focus-visible { outline: 3px solid var(--sun); outline-offset: 2px; border-radius: 6px; }

.wrap { max-width: 1120px; margin: 0 auto; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
section.block { padding-block: 56px; }
.stack { display: grid; gap: 16px; }

/* header */
body::before { content: ""; position: fixed; inset: 0 0 auto; height: env(safe-area-inset-top, 0px); z-index: 10; background: var(--surface); }
.top { position: sticky; top: env(safe-area-inset-top, 0px); z-index: 9; background: var(--surface); border-bottom: 1px solid var(--line); }
.top .wrap { display: flex; align-items: center; gap: 16px; min-height: 64px; flex-wrap: wrap; padding-block: 8px; }
.logo { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--fg); font: 700 1.15rem var(--display); }
.logo i { width: 30px; height: 30px; border-radius: 50%; background: radial-gradient(circle at 50% 50%, var(--sun) 0 38%, transparent 40%), conic-gradient(var(--sun) 0 10%, transparent 0 20%, var(--sun) 0 30%, transparent 0 40%, var(--sun) 0 50%, transparent 0 60%, var(--sun) 0 70%, transparent 0 80%, var(--sun) 0 90%, transparent 0); }
.nav { display: flex; gap: 4px; flex-wrap: wrap; margin-left: auto; }
.nav a { text-decoration: none; color: var(--fg); padding: 8px 12px; border-radius: 999px; font-weight: 500; font-size: 0.95rem; }
.nav a[aria-current="page"] { background: var(--sunk); color: var(--brand); }
.nav a:hover { background: var(--sunk); }
.demo-bar { background: var(--sun-soft); color: var(--fg); font-size: 0.85rem; text-align: center; padding: 6px 16px; }

/* buttons + inputs */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 0 20px; border-radius: 999px; border: 1.5px solid var(--brand); background: var(--brand); color: var(--brand-fg); font: 600 0.95rem var(--body); text-decoration: none; cursor: pointer; }
.btn.ghost { background: transparent; color: var(--brand); }
.btn.gold { background: var(--sun); border-color: var(--sun); color: #1b1300; }
.btn.small { min-height: 34px; padding: 0 14px; font-size: 0.85rem; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn:hover:not(:disabled) { filter: brightness(1.08); }
label { display: grid; gap: 6px; font-weight: 600; font-size: 0.9rem; }
input, select, textarea { font: 400 1rem var(--body); color: var(--fg); background: var(--surface); border: 1.5px solid var(--line); border-radius: 10px; padding: 10px 12px; min-height: 44px; width: 100%; }
textarea { min-height: 80px; }
input:focus, select:focus, textarea:focus { border-color: var(--brand); outline: none; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; }
.choices { display: flex; flex-wrap: wrap; gap: 8px; }
.choices input { position: absolute; opacity: 0; pointer-events: none; width: 1px; }
.choices label { font-weight: 500; border: 1.5px solid var(--line); border-radius: 999px; padding: 8px 14px; cursor: pointer; background: var(--surface); display: inline-block; }
.choices input:checked + span { color: var(--brand); }
.choices label:has(input:checked) { border-color: var(--brand); background: var(--sunk); color: var(--brand); }
.choices label:has(input:focus-visible) { outline: 3px solid var(--sun); outline-offset: 2px; }
fieldset { border: 0; padding: 0; margin: 0; display: grid; gap: 8px; }
legend { font-weight: 600; font-size: 0.9rem; margin-bottom: 8px; padding: 0; }

/* hero */
.hero { display: grid; grid-template-columns: 1.1fr 1fr; gap: 40px; align-items: center; padding-block: 48px 56px; }
.hero p.lead { font-size: 1.15rem; color: var(--muted); max-width: 34em; margin-top: 16px; }
.hero .actions { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 24px; }
@media (max-width: 820px) { .hero { grid-template-columns: 1fr; padding-block: 32px; } }

/* the passport data page */
.passport { background: var(--surface); border: 1px solid var(--line); border-radius: 18px; overflow: hidden; box-shadow: 0 18px 40px -24px rgba(15, 76, 74, 0.45); }
.passport .cover { background: var(--brand); color: var(--brand-fg); display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 18px; font: 600 0.72rem var(--mono); letter-spacing: 0.14em; text-transform: uppercase; }
.passport .page { display: grid; grid-template-columns: 150px 1fr; gap: 18px; padding: 18px; position: relative;
  background-image: repeating-radial-gradient(circle at 100% 0, transparent 0 9px, color-mix(in srgb, var(--brand) 6%, transparent) 9px 10px); }
.passport .fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 16px; min-width: 0; }
.passport .f small { display: block; font: 500 0.66rem var(--mono); letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); }
.passport .f b { font-weight: 600; font-size: 0.98rem; word-break: break-word; }
.passport .mrz { background: var(--sunk); padding: 12px 18px; font: 500 0.82rem/1.5 var(--mono); letter-spacing: 0.08em; overflow-x: auto; white-space: pre; color: var(--fg); }
.stamp { position: absolute; right: 18px; bottom: 14px; transform: rotate(-12deg); border: 2.5px solid var(--sun); color: var(--sun); border-radius: 50%; width: 82px; height: 82px; display: grid; place-items: center; text-align: center; font: 700 0.62rem/1.15 var(--mono); letter-spacing: 0.08em; text-transform: uppercase; opacity: 0.9; }
.stamp b { display: block; font: 700 1.6rem/1 var(--display); letter-spacing: 0; }
@media (max-width: 520px) { .passport .page { grid-template-columns: 1fr; } .passport .page > div:first-child { width: 96px; } .passport .fields { grid-template-columns: 1fr 1fr; } .stamp { width: 66px; height: 66px; } }

/* phone silhouette when no photo yet */
.ph { aspect-ratio: 9 / 16; max-width: 100%; border-radius: 18px; border: 2px solid var(--line); background: linear-gradient(160deg, var(--sunk), var(--surface)); position: relative; display: grid; place-items: center; color: var(--muted); font: 600 0.7rem var(--mono); }
.ph::before { content: ""; position: absolute; top: 8px; left: 50%; width: 32%; height: 6px; transform: translateX(-50%); background: var(--line); border-radius: 6px; }
.photo { aspect-ratio: 9 / 16; width: 100%; object-fit: cover; border-radius: 14px; border: 1px solid var(--line); background: var(--sunk); }

/* trust strip */
.trust { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0; border-block: 1px solid var(--line); background: var(--surface); }
.trust div { padding: 20px; border-left: 1px solid var(--line); display: grid; gap: 4px; }
.trust div:first-child { border-left: 0; }
.trust b { font: 600 1rem var(--display); }
.trust span { color: var(--muted); font-size: 0.9rem; }
@media (max-width: 820px) { .trust { grid-template-columns: 1fr 1fr; } .trust div:nth-child(3) { border-left: 0; } .trust div:nth-child(n+3) { border-top: 1px solid var(--line); } }

/* phone cards */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 16px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 14px; display: grid; grid-template-rows: auto 1fr auto; gap: 12px; text-decoration: none; color: var(--fg); transition: transform .15s, border-color .15s; }
.card:hover { transform: translateY(-2px); border-color: var(--brand); }
.card .media { display: grid; grid-template-columns: 70px 1fr; gap: 12px; align-items: start; }
.card .media .ph, .card .media .photo { width: 70px; border-radius: 10px; }
.card .meta { display: grid; gap: 4px; min-width: 0; }
.card .price { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; border-top: 1px dashed var(--line); padding-top: 10px; }
.card .price b { font: 700 1.2rem var(--display); }
.chip { display: inline-flex; align-items: center; gap: 6px; font: 600 0.72rem var(--mono); letter-spacing: 0.04em; padding: 3px 9px; border-radius: 999px; background: var(--sunk); color: var(--fg); white-space: nowrap; }
.chip.g-A { background: color-mix(in srgb, var(--good) 16%, transparent); color: var(--good); }
.chip.g-B { background: color-mix(in srgb, var(--warn) 16%, transparent); color: var(--warn); }
.chip.g-C { background: color-mix(in srgb, var(--bad) 14%, transparent); color: var(--bad); }
.chip.ok { color: var(--good); }
.chip.bad { color: var(--bad); }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }

/* filters */
.filters { display: grid; grid-template-columns: 2fr 1fr 1fr 1fr; gap: 12px; margin-block: 20px; }
@media (max-width: 720px) { .filters { grid-template-columns: 1fr 1fr; } .filters .search { grid-column: 1 / -1; } }

/* passport detail page */
.detail { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr); gap: 32px; padding-block: 32px 56px; align-items: start; }
.gallery { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.gallery .ph, .gallery .photo { width: 100%; }
.buybox { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 18px; display: grid; gap: 14px; }
.buybox .big { font: 700 2rem var(--display); }
.note { background: var(--sun-soft); border-radius: 12px; padding: 12px 14px; font-size: 0.92rem; }
@media (max-width: 860px) { .detail { grid-template-columns: 1fr; } }

/* trade-in */
.sell { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr); gap: 28px; align-items: start; padding-block: 32px 56px; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 20px; display: grid; gap: 18px; }
.quote { position: sticky; top: calc(env(safe-area-inset-top, 0px) + 84px); background: var(--brand); color: var(--brand-fg); border-radius: var(--r); padding: 22px; display: grid; gap: 10px; }
.quote .range { font: 700 2.2rem/1.1 var(--display); }
.quote .muted { color: inherit; opacity: 0.78; }
.quote hr { border: 0; border-top: 1px solid currentColor; opacity: 0.25; width: 100%; margin: 4px 0; }
@media (max-width: 860px) { .sell { grid-template-columns: 1fr; } .quote { position: static; } }

/* steps (buy-back / dealers explainer) */
.steps { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; counter-reset: s; }
.steps div { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 18px; display: grid; gap: 6px; }
.steps div::before { counter-increment: s; content: counter(s); font: 700 0.8rem var(--mono); color: var(--sun); }

/* table */
.tablewrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); }
table { border-collapse: collapse; width: 100%; font-size: 0.92rem; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; white-space: nowrap; }
th { font: 600 0.72rem var(--mono); letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); background: var(--sunk); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tr:last-child td { border-bottom: 0; }
td input { min-height: 34px; padding: 4px 8px; width: 72px; }

.band { background: var(--brand); color: var(--brand-fg); }
.band .wrap { display: grid; grid-template-columns: 1.4fr 1fr; gap: 24px; align-items: center; padding-block: 48px; }
.band p { opacity: 0.85; margin-top: 10px; }
.band .btn { background: var(--sun); border-color: var(--sun); color: #1b1300; }
@media (max-width: 760px) { .band .wrap { grid-template-columns: 1fr; } }

.toast { position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); background: var(--fg); color: var(--bg); padding: 12px 18px; border-radius: 12px; font-weight: 500; z-index: 20; max-width: calc(100% - 32px); }
.empty { padding: 32px; text-align: center; color: var(--muted); background: var(--surface); border: 1px dashed var(--line); border-radius: var(--r); }
.err { color: var(--bad); font-weight: 500; }

footer { border-top: 1px solid var(--line); background: var(--surface); }
footer .wrap { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 24px; padding-block: 32px; font-size: 0.9rem; }
footer .wrap > * { min-width: 0; }
@media (max-width: 720px) { footer .wrap { grid-template-columns: 1fr; } }

/* admin */
.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-block: 20px; }
.tabs button { border: 1.5px solid var(--line); background: var(--surface); color: var(--fg); border-radius: 999px; padding: 8px 14px; font: 600 0.9rem var(--body); cursor: pointer; min-height: 40px; }
.tabs button[aria-selected="true"] { border-color: var(--brand); color: var(--brand); background: var(--sunk); }
.thumbs { display: flex; gap: 8px; flex-wrap: wrap; }
.thumbs figure { margin: 0; position: relative; width: 70px; }
.thumbs img { width: 70px; height: 100px; object-fit: cover; border-radius: 8px; }
.thumbs button { position: absolute; top: 2px; right: 2px; border: 0; border-radius: 50%; width: 22px; height: 22px; background: var(--fg); color: var(--bg); cursor: pointer; line-height: 1; }
dialog { border: 1px solid var(--line); border-radius: var(--r); background: var(--surface); color: var(--fg); padding: 20px; width: min(640px, calc(100% - 32px)); }
dialog::backdrop { background: rgba(0, 0, 0, 0.45); }
.sticker { display: grid; grid-template-columns: 110px 1fr; gap: 12px; align-items: center; border: 1px dashed var(--line); border-radius: 10px; padding: 12px; }
@media print { body * { visibility: hidden; } .sticker, .sticker * { visibility: visible; } .sticker { position: absolute; left: 0; top: 0; } }
