/* DealDigger design system — one stylesheet for every page. */
:root {
  --bg:          #0b0d12;
  --surface:     #15181f;
  --surface-2:   #1d212a;
  --border:      #2a2f3a;
  --text:        #e6e8ec;
  --muted:       #9aa1ad;
  --accent:      #00ffd7;
  --accent-dim:  #00bfa5;
  --accent-ink:  #06231f;
  --pos:         #3ddc84;
  --neg:         #ff6b6b;
  --warn:        #ffb020;
  --deal:        #ff9f00;
  --maybe:       #ffd966;
  --radius:      10px;
  --shadow:      0 6px 24px rgba(0, 0, 0, .35);
  --font:        "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-brand:  "Press Start 2P", monospace;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 var(--font);
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; }
h1, h2, h3 { line-height: 1.25; margin: 0 0 .5rem; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; }
p { margin: 0 0 .75rem; }
code { color: var(--accent); }

/* ── Top bar ─────────────────────────────────────────────────────────────── */
.topbar {
  position: sticky; top: 0; z-index: 10;
  background: rgba(11, 13, 18, .92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}
.topbar-inner {
  max-width: 1180px; margin: 0 auto; padding: .6rem 1rem;
  display: flex; align-items: center; gap: 1rem; flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: .6rem; color: var(--accent); }
.brand:hover { text-decoration: none; }
.brand img { width: 36px; height: 36px; border-radius: 8px; }
.brand span { font-family: var(--font-brand); font-size: .8rem; letter-spacing: .02em; }
.nav { display: flex; gap: .25rem; flex-wrap: wrap; margin-left: auto; }
.nav a {
  color: var(--muted); padding: .45rem .75rem; border-radius: 8px; font-weight: 500; font-size: .9rem;
}
.nav a:hover { color: var(--text); background: var(--surface-2); text-decoration: none; }
.nav a.active { color: var(--accent-ink); background: var(--accent); }
.account-nav { display: flex; align-items: center; gap: .5rem; }
.account-nav > a:not(.btn) { color: var(--muted); font-weight: 500; font-size: .9rem; padding: .45rem .5rem; border-radius: 8px; }
.account-nav > a.active { color: var(--text); background: var(--surface-2); }
.auth-box { max-width: 440px; margin: 2rem auto; }
.auth-box form { display: grid; gap: .9rem; margin: 1rem 0; }

.banner { padding: .6rem 1rem; text-align: center; font-size: .9rem; background: #fff3cd; color: #332701; }
.banner a { color: #5a3d00; text-decoration: underline; }

/* ── Layout ──────────────────────────────────────────────────────────────── */
.page { max-width: 1180px; margin: 0 auto; padding: 1.25rem 1rem 3rem; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem;
             flex-wrap: wrap; margin-bottom: 1rem; }
.page-head p { color: var(--muted); margin: 0; }
.panel {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1rem 1.1rem; margin-bottom: 1rem;
}
.panel > h2:first-child, .panel > h3:first-child { margin-top: 0; }
.grid { display: grid; gap: 1rem; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.grid-stats { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
.row { display: flex; gap: .75rem; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }
.footer { text-align: center; color: var(--muted); font-size: .85rem; padding: 2rem 1rem; }
.footer a { color: var(--muted); margin: 0 .5rem; }

/* ── Forms ───────────────────────────────────────────────────────────────── */
.search-bar { display: flex; gap: .5rem; flex-wrap: wrap; }
.search-bar input[type=text], .search-bar input[type=search] { flex: 1 1 260px; }
input[type=text], input[type=search], input[type=number], input[type=date], input[type=password],
input[type=email], select, textarea {
  background: var(--surface-2); color: var(--text); border: 1px solid var(--border);
  border-radius: 8px; padding: .6rem .7rem; font: inherit; min-height: 42px;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: transparent; }
label { display: block; font-size: .8rem; color: var(--muted); margin-bottom: .25rem; }
.field { display: flex; flex-direction: column; min-width: 120px; flex: 1; }
.form-grid { display: grid; gap: .75rem; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); align-items: end; }
.segmented { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.segmented label { margin: 0; }
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented span { display: block; padding: .5rem .8rem; color: var(--muted); cursor: pointer; font-size: .9rem; }
.segmented input:checked + span { background: var(--accent); color: var(--accent-ink); font-weight: 600; }
.segmented input:focus-visible + span { outline: 2px solid var(--accent); }

.btn, button, input[type=submit] {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  min-height: 42px; padding: .55rem 1rem; border-radius: 8px; cursor: pointer;
  font: 600 .9rem var(--font); border: 1px solid var(--border);
  background: var(--surface-2); color: var(--text);
}
.btn:hover, button:hover { border-color: var(--accent-dim); text-decoration: none; }
.btn-primary, button.primary, input[type=submit] {
  background: var(--accent); color: var(--accent-ink); border-color: var(--accent);
}
.btn-primary:hover, button.primary:hover, input[type=submit]:hover { background: var(--accent-dim); }
.btn-sm { min-height: 32px; padding: .3rem .65rem; font-size: .8rem; }
.btn-danger { color: var(--neg); }
.btn-danger:hover { border-color: var(--neg); }
.inline { display: inline; }

/* ── Feedback ────────────────────────────────────────────────────────────── */
.notice { padding: .7rem .9rem; border-radius: 8px; margin: 0 0 1rem; font-size: .9rem;
          background: rgba(0, 255, 215, .07); border: 1px solid rgba(0, 191, 165, .5); }
.notice.warn  { background: rgba(255, 176, 32, .08); border-color: rgba(255, 176, 32, .6); }
.notice.error { background: rgba(255, 107, 107, .08); border-color: rgba(255, 107, 107, .6); }
.muted { color: var(--muted); }
.small { font-size: .8rem; }
.pos { color: var(--pos); font-weight: 600; }
.neg { color: var(--neg); }
.nowrap { white-space: nowrap; }
.right { text-align: right; }

.tag { display: inline-block; padding: .15rem .5rem; border-radius: 999px; font-size: .72rem;
       font-weight: 700; color: #111; margin: .1rem .15rem .1rem 0; white-space: nowrap; }
.tag.deal   { background: var(--deal); }
.tag.maybe  { background: var(--maybe); }
.tag.check  { background: var(--neg); }
.tag.budget { background: var(--pos); }
.tag.plain  { background: var(--surface-2); color: var(--muted); border: 1px solid var(--border); }

/* ── Stats ───────────────────────────────────────────────────────────────── */
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: .9rem 1rem; }
.stat .label { color: var(--muted); font-size: .8rem; }
.stat .value { font-size: 1.5rem; font-weight: 700; margin-top: .15rem; }
.stat .sub { font-size: .8rem; color: var(--muted); }

/* ── Tables (become stacked cards on phones) ─────────────────────────────── */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th, td { padding: .6rem .7rem; text-align: left; vertical-align: middle; border-bottom: 1px solid var(--border); }
th { font-size: .72rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted);
     background: var(--surface-2); font-weight: 600; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: rgba(0, 255, 215, .04); }
td.num, th.num { text-align: right; white-space: nowrap; }
.thumb { width: 48px; max-width: none; height: auto; border-radius: 4px; border: 1px solid var(--border); display: block; }
td.img-cell { width: 64px; }
.btn-sm { white-space: nowrap; }
.title-cell { min-width: 220px; }

@media (max-width: 720px) {
  table.stack thead { display: none; }
  table.stack, table.stack tbody, table.stack tr, table.stack td { display: block; width: 100%; }
  table.stack tr { padding: .6rem .8rem; border-bottom: 1px solid var(--border); }
  table.stack td { border: 0; padding: .2rem 0 .2rem 38%; position: relative; text-align: right; min-height: 1.6rem; }
  table.stack td::before { content: attr(data-label); position: absolute; left: 0; top: .25rem; width: 36%;
                           color: var(--muted); font-size: .78rem; text-align: left; }
  table.stack td[data-label=""] { padding-left: 0; }
  table.stack td[data-label=""]::before { content: none; }
  table.stack td.title-cell, table.stack td.img-cell { padding-left: 0; text-align: left; }
  table.stack td.title-cell::before, table.stack td.img-cell::before { content: none; }
  table.stack td.num { text-align: right; }
  .nav { margin-left: 0; width: 100%; overflow-x: auto; flex-wrap: nowrap; }
  .nav a { white-space: nowrap; }
  .page { padding-left: 12px; padding-right: 12px; }
  .search-bar > * { flex: 1 1 auto; }
  .search-bar input[type=search] { flex-basis: 100%; }
  .title-cell { min-width: 0; }
}

/* ── Card detail ─────────────────────────────────────────────────────────── */
.card-hero { display: grid; grid-template-columns: minmax(180px, 280px) 1fr; gap: 1.25rem; }
.card-hero img { width: 100%; border-radius: 12px; box-shadow: var(--shadow); }
@media (max-width: 640px) { .card-hero { grid-template-columns: 1fr; } .card-hero img { max-width: 260px; } }
dl.facts { display: grid; grid-template-columns: max-content 1fr; gap: .3rem 1rem; margin: 0; }
dl.facts dt { color: var(--muted); }
dl.facts dd { margin: 0; }
.price-list { list-style: none; padding: 0; margin: 0; }
.price-list li { display: flex; justify-content: space-between; gap: 1rem; padding: .35rem 0; border-bottom: 1px dashed var(--border); }
.price-list li:last-child { border-bottom: 0; }
.big-value { font-size: 2rem; font-weight: 800; color: var(--accent); }

/* ── Hero (home) ─────────────────────────────────────────────────────────── */
.hero { background: linear-gradient(135deg, rgba(0,255,215,.10), rgba(0,255,215,0) 60%), var(--surface);
        border: 1px solid var(--border); border-radius: 14px; padding: 1.5rem 1.25rem; margin-bottom: 1rem; }
.hero h1 { font-size: 1.6rem; }
.hero p { color: var(--muted); }

label.check { display: inline-flex; align-items: center; gap: .4rem; margin: 0; color: var(--text); font-size: .9rem; }
label.check input { width: 18px; height: 18px; accent-color: var(--accent); }
input[type=url] { background: var(--surface-2); color: var(--text); border: 1px solid var(--border);
                  border-radius: 8px; padding: .6rem .7rem; font: inherit; min-height: 42px; width: 100%; }
.watch-box > summary { font-weight: 600; margin: 0; }
tr.muted td { opacity: .6; }

/* ── Printings grid (deal search) ─────────────────────────────────────────── */
.print-grid { display: grid; gap: .75rem; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.print-tile { background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: .6rem;
              display: flex; flex-direction: column; gap: .3rem; }
.print-img { display: block; aspect-ratio: 63 / 88; background: var(--bg); border-radius: 6px; overflow: hidden;
             display: flex; align-items: center; justify-content: center; }
.print-img img { width: 100%; height: 100%; object-fit: contain; }
.print-name { font-weight: 600; font-size: .9rem; line-height: 1.2; }
.print-value { font-weight: 800; color: var(--accent); display: flex; gap: .4rem; align-items: center; flex-wrap: wrap; }
.print-tile .btn { margin-top: auto; }
.finish-row { border-top: 1px solid var(--border); padding-top: .35rem; }
.finish-head { display: flex; justify-content: space-between; align-items: baseline; gap: .5rem; font-size: .85rem; font-weight: 600; }
.finish-sources { list-style: none; margin: .15rem 0 0; padding: 0; font-size: .72rem; color: var(--muted); }
.finish-sources li { display: flex; justify-content: space-between; gap: .5rem; }
@media (max-width: 720px) { .print-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

.big-inline { font-size: 1.4rem; color: var(--accent); }

.shop-links { display: grid; gap: .5rem; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); }
.shop-link { display: flex; flex-direction: column; gap: .15rem; padding: .6rem .75rem; border-radius: 8px;
             background: var(--surface-2); border: 1px solid var(--border); color: var(--text); }
.shop-link:hover { border-color: var(--accent-dim); text-decoration: none; }
.shop-link strong { color: var(--accent); }

/* ── Set lookup ──────────────────────────────────────────────────────────── */
.set-list { display: grid; gap: .5rem; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.set-link { display: flex; justify-content: space-between; gap: .5rem; padding: .65rem .8rem; border-radius: 8px;
            background: var(--surface-2); border: 1px solid var(--border); color: var(--text); }
.set-link:hover { border-color: var(--accent-dim); text-decoration: none; }
.set-rank { color: var(--muted); font-weight: 700; width: 2.2rem; }
.finish-chips { display: flex; flex-wrap: wrap; gap: .35rem; }
.finish-chip { background: var(--surface-2); border: 1px solid var(--border); border-radius: 6px; padding: .15rem .45rem;
               font-size: .78rem; white-space: nowrap; }
.finish-chip strong { color: var(--accent); }

/* ── Scanner ─────────────────────────────────────────────────────────────── */
.scan-button { position: relative; cursor: pointer; }
.scan-status { margin: .75rem 0 0; font-weight: 600; min-height: 1.4em; }
.scan-preview { max-width: 220px; max-height: 300px; border-radius: 10px; margin-top: .75rem; display: block; }
.scan-preview[hidden] { display: none; }
#scanner.dragging { outline: 2px dashed var(--accent); }
.scan-results { display: grid; gap: .75rem; }
.scan-result.best { border-color: var(--accent-dim); box-shadow: 0 0 0 1px var(--accent-dim); }
.scan-camera { position: relative; margin-top: .75rem; background: #000; border-radius: 12px; overflow: hidden;
               max-height: 75vh; aspect-ratio: 3 / 4; max-width: 100%; }
.scan-camera[hidden] { display: none; }
.scan-camera video { width: 100%; height: 100%; display: block; object-fit: fill; cursor: pointer; }
.scan-guide { position: absolute; border: 3px solid var(--accent); border-radius: 14px; pointer-events: none;
              box-shadow: 0 0 0 9999px rgba(0, 0, 0, .45); display: flex; align-items: flex-start; justify-content: center; }
.scan-guide span { margin-top: .5rem; font-size: .8rem; font-weight: 600; color: #fff; background: rgba(0,0,0,.55);
                   padding: .15rem .5rem; border-radius: 6px; }
.scan-camera-bar { position: absolute; left: 0; right: 0; bottom: .75rem; display: flex; gap: .5rem; justify-content: center; }
.scan-result { display: flex; gap: 1rem; align-items: flex-start; margin: 0; }
.scan-result .thumb { width: 84px; }
.scan-info { display: grid; gap: .35rem; flex: 1; }
.scan-name { font-weight: 700; font-size: 1.05rem; }
.scan-value { font-size: 1.2rem; font-weight: 800; color: var(--accent); }

details > summary { cursor: pointer; color: var(--accent); margin: .5rem 0; }
.chart { width: 100%; height: 140px; display: block; }
.chart .line { fill: none; stroke: var(--accent); stroke-width: 2; }
.chart .line.cost { stroke: var(--muted); stroke-dasharray: 4 4; stroke-width: 1.5; }
.chart .area { fill: rgba(0, 255, 215, .08); stroke: none; }
.legend { display: flex; gap: 1rem; font-size: .8rem; color: var(--muted); }
.legend i { display: inline-block; width: 14px; height: 2px; vertical-align: middle; margin-right: .3rem; background: var(--accent); }
.legend i.cost { background: var(--muted); }
