/* cardscan — phone first, laptop fine. No framework. */
:root {
  --bg: #f6f7f9; --panel: #fff; --ink: #1c2330; --muted: #677084; --line: #dfe3ea;
  --accent: #1f6feb; --accent-ink: #fff; --good: #1a7f37; --warn: #9a6700; --bad: #cf222e; --chip: #eef1f5;
  --radius: 10px; --gap: 12px;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #0f1217; --panel: #171b22; --ink: #e6e9ef; --muted: #98a1b3; --line: #2a303b; --accent: #4c8dff; --chip: #222834; --good: #3fb950; --warn: #d29922; --bad: #f85149; }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.35rem; margin: .2rem 0 .6rem; }
h2 { font-size: 1.05rem; margin: 1.2rem 0 .5rem; }
main { padding: var(--gap); max-width: 1400px; margin: 0 auto; }
main.narrow { max-width: 420px; padding-top: 12vh; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.error { color: var(--bad); }
.ok { color: var(--good); }
.warn { color: var(--warn); }
.right { text-align: right; }
.nowrap { white-space: nowrap; }

nav.top { position: sticky; top: 0; z-index: 20; display: flex; gap: 2px; align-items: center; overflow-x: auto; background: var(--panel); border-bottom: 1px solid var(--line); padding: 6px 8px; }
nav.top a { padding: 7px 10px; border-radius: 8px; color: var(--ink); white-space: nowrap; }
nav.top a.on { background: var(--chip); font-weight: 600; }
nav.top .brand { font-weight: 700; margin-right: 6px; }
nav.top form { margin-left: auto; }
.badge { display: inline-block; min-width: 1.4em; padding: 0 .4em; border-radius: 999px; background: var(--bad); color: #fff; font-size: .75rem; text-align: center; }

.alert { background: #fff4e5; color: #6b3d00; border: 1px solid #f0c27a; padding: 8px 12px; border-radius: var(--radius); margin: 8px 0; }
@media (prefers-color-scheme: dark) { .alert { background: #3a2a10; color: #f5d69b; border-color: #6b4e1a; } }

.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; margin-bottom: var(--gap); }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 8px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 8px 10px; }
.stat b { display: block; font-size: 1.15rem; }
.stat span { color: var(--muted); font-size: .8rem; }

table { width: 100%; border-collapse: collapse; }
th, td { padding: 6px 8px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { font-size: .8rem; color: var(--muted); font-weight: 600; }
.table-wrap { overflow-x: auto; }

form.inline { display: inline; }
.filters { display: flex; flex-wrap: wrap; gap: 6px; align-items: end; }
.filters label { display: flex; flex-direction: column; font-size: .75rem; color: var(--muted); }
input, select, textarea, button { font: inherit; color: inherit; }
input, select, textarea { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 7px 9px; min-width: 0; }
input[type=checkbox] { width: 20px; height: 20px; }
button, .button { background: var(--accent); color: var(--accent-ink); border: 0; border-radius: 8px; padding: 8px 13px; cursor: pointer; display: inline-block; }
button.secondary, .button.secondary { background: var(--chip); color: var(--ink); }
button.danger { background: var(--bad); }
button:disabled { opacity: .5; }
.card-form { display: grid; gap: 10px; }
.card-form label { display: grid; gap: 4px; }
.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

.chip { display: inline-block; background: var(--chip); border-radius: 999px; padding: 1px 8px; font-size: .75rem; margin: 1px 2px 1px 0; }
.chip.bad { background: var(--bad); color: #fff; }
.chip.warn { background: var(--warn); color: #fff; }
.chip.good { background: var(--good); color: #fff; }

/* Card grid */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 10px; }
@media (max-width: 480px) { .grid { grid-template-columns: repeat(2, 1fr); gap: 8px; } }
.tile { position: relative; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; display: flex; flex-direction: column; }
.tile .sel { position: absolute; top: 6px; left: 6px; z-index: 2; }
.tile img { width: 100%; aspect-ratio: 63 / 88; object-fit: cover; background: var(--chip); display: block; }
.tile .body { padding: 6px 8px 8px; font-size: .82rem; display: grid; gap: 2px; }
.tile .name { font-weight: 600; font-size: .88rem; line-height: 1.2; }
.tile .price { display: flex; justify-content: space-between; }
.tile .price b { font-size: .95rem; }
.tile.review { border-color: var(--warn); }
.tile.pos::after { content: attr(data-pos); position: absolute; top: 6px; right: 6px; background: rgba(0,0,0,.65); color: #fff; font-size: .72rem; padding: 1px 6px; border-radius: 6px; }

.bulkbar { position: sticky; bottom: 0; z-index: 15; background: var(--panel); border-top: 1px solid var(--line); padding: 8px; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: 0 calc(-1 * var(--gap)); }

/* Card detail and review */
.compare { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 10px; }
.compare figure { margin: 0; }
.compare img { width: 100%; border-radius: 8px; background: var(--chip); }
.compare figcaption { font-size: .8rem; color: var(--muted); }
.candidates { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 8px; }
.candidates form { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 6px; display: grid; gap: 4px; font-size: .8rem; }
.candidates img { width: 100%; aspect-ratio: 63/88; object-fit: cover; border-radius: 6px; background: var(--chip); }
.stack { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 8px; }
.stack figure { margin: 0; font-size: .75rem; }
.stack img { width: 100%; border-radius: 6px; }

.spark { width: 100%; height: 140px; }
.spark path.market { stroke: var(--accent); fill: none; stroke-width: 2; }
.spark path.low { stroke: var(--warn); fill: none; stroke-width: 1.5; }
details > summary { cursor: pointer; }
