:root {
    --bg: #0c0c0e;
    --surface: #141417;
    --surface-2: #1b1b1f;
    --surface-3: #232328;
    --border: #25252b;
    --border-2: #303037;
    --text: #ececef;
    --muted: #8d8d96;
    --dim: #5d5d66;
    --accent: #ff6b2c;
    --accent-2: #f2541b;
    --green: #3fd08f;
    --red: #ff5f5f;
    --amber: #f5b742;
    --give: #ff7a59;
    --get: #3fd08f;
    --radius: 14px;
    --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font-family: var(--font); font-size: 14px; }
body { min-height: 100vh; -webkit-font-smoothing: antialiased; }
body.locked > :not(#lock) { visibility: hidden; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.num, .tab { font-variant-numeric: tabular-nums; }
a { color: inherit; }

/* ── Buttons, pills, inputs ─────────────────────────── */
.btn {
    border: 1px solid var(--border-2); background: var(--surface-2); border-radius: 10px;
    padding: 9px 14px; font-weight: 600; font-size: 13px; transition: background .15s, border-color .15s, opacity .15s;
    white-space: nowrap;
}
.btn:hover { background: var(--surface-3); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn--accent { background: linear-gradient(180deg, var(--accent), var(--accent-2)); border-color: transparent; color: #fff; }
.btn--accent:hover { background: linear-gradient(180deg, #ff7c43, #f2541b); }
.btn--ghost { background: transparent; }
.btn--danger { color: var(--red); border-color: rgba(255,95,95,.3); background: transparent; }
.btn--sm { padding: 6px 11px; font-size: 12px; border-radius: 8px; }
.btn--xs { padding: 3px 8px; font-size: 11px; border-radius: 6px; }
.btn--block { width: 100%; }
.icon-btn {
    width: 30px; height: 30px; display: inline-grid; place-items: center; border-radius: 8px;
    border: 1px solid transparent; background: transparent; color: var(--muted);
}
.icon-btn:hover { background: var(--surface-3); color: var(--text); }

.pills { display: inline-flex; gap: 4px; background: var(--surface); border: 1px solid var(--border); border-radius: 999px; padding: 3px; }
.pill {
    display: inline-flex; align-items: center; gap: 6px; border: 0; background: transparent; color: var(--muted);
    padding: 6px 13px; border-radius: 999px; font-weight: 600; font-size: 12.5px;
}
.pill:hover { color: var(--text); }
.pill .dot { width: 6px; height: 6px; border-radius: 50%; background: #fff; display: none; }
.pill.is-active { background: linear-gradient(180deg, var(--accent), var(--accent-2)); color: #fff; }
.pill.is-active .dot { display: inline-block; }

.seg { display: inline-flex; background: var(--surface); border: 1px solid var(--border); border-radius: 9px; padding: 2px; }
.seg button { border: 0; background: transparent; color: var(--muted); padding: 5px 11px; border-radius: 7px; font-weight: 600; font-size: 12px; }
.seg button.is-active { background: var(--surface-3); color: var(--text); }
.seg--lg button { padding: 8px 16px; font-size: 13px; }

.input {
    background: var(--surface); border: 1px solid var(--border-2); border-radius: 10px; padding: 9px 12px; outline: none;
    width: 100%; transition: border-color .15s;
}
.input:focus { border-color: var(--accent); }
.input--title { background: transparent; border-color: transparent; font-size: 20px; font-weight: 700; padding: 4px 6px; margin-left: -6px; }
.input--title:hover { border-color: var(--border-2); }
.input--title:focus { border-color: var(--accent); background: var(--surface); }
input[type=number] { -moz-appearance: textfield; }
input::-webkit-outer-spin-button, input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

.chip {
    display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; border-radius: 999px; font-size: 11.5px; font-weight: 700;
    background: var(--surface-3); color: var(--muted); letter-spacing: .02em;
}
.chip--draft { background: rgba(245,183,66,.12); color: var(--amber); }
.chip--settled { background: rgba(63,208,143,.12); color: var(--green); }
.chip--lang { background: #26262d; color: #c9c9d1; font-size: 10px; padding: 1px 6px; border-radius: 5px; }
.chip--variant { background: rgba(255,107,44,.12); color: #ffa27a; font-size: 10.5px; padding: 1px 7px; border-radius: 5px; }
.game-badge { font-size: 10px; font-weight: 800; letter-spacing: .03em; padding: 1px 6px; border-radius: 5px; }
.game-badge--pokemon { background: rgba(255,203,5,.14); color: #ffd84a; }
.game-badge--onepiece { background: rgba(229,57,53,.15); color: #ff7b73; }
.game-badge--other { background: var(--surface-3); color: var(--muted); }

/* ── Lock ───────────────────────────────────────────── */
.lock { position: fixed; inset: 0; display: grid; place-items: center; background: radial-gradient(circle at 50% 30%, #1c1410, var(--bg) 60%); z-index: 100; }
body:not(.locked) .lock { display: none; }
.lock__card { width: min(360px, 92vw); background: var(--surface); border: 1px solid var(--border); border-radius: 18px; padding: 28px; display: grid; gap: 14px; }
.lock__card input { background: var(--surface-2); border: 1px solid var(--border-2); border-radius: 10px; padding: 11px 13px; outline: none; }
.lock__card input:focus { border-color: var(--accent); }
.lock__error { color: var(--red); margin: 0; font-size: 13px; white-space: pre-wrap; }

/* ── Topbar ─────────────────────────────────────────── */
.topbar {
    position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 18px; justify-content: space-between;
    padding: 12px 24px; background: rgba(12,12,14,.86); backdrop-filter: blur(12px); border-bottom: 1px solid var(--border);
}
.brand { display: inline-flex; align-items: center; gap: 10px; font-size: 15px; letter-spacing: -.01em; }
.brand b { font-weight: 800; }
.brand__mark { width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center; font-weight: 800; color: #fff; background: linear-gradient(135deg, var(--accent), #c43d0d); }
.brand--lg { font-size: 18px; }
.topbar__right { display: flex; align-items: center; gap: 12px; }
.link-muted { color: var(--muted); text-decoration: none; font-size: 13px; }
.link-muted:hover { color: var(--text); }

.view { max-width: 1520px; margin: 0 auto; padding: 22px 24px; }

/* ── Desk bar ───────────────────────────────────────── */
.deskbar { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-end; gap: 14px; margin-bottom: 18px; }
.deskbar__title { flex: 1 1 320px; min-width: 260px; }
.deskbar__meta { display: flex; align-items: center; gap: 10px; margin-top: 4px; }
.deskbar__actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.save-state { font-size: 12px; color: var(--dim); }
.save-state--error { color: var(--red); font-weight: 600; }
.save-state button { margin-left: 6px; }
.currency { display: flex; align-items: center; gap: 8px; margin-right: 6px; }
.rate { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }
.rate input { width: 74px; background: var(--surface); border: 1px solid var(--border-2); border-radius: 7px; padding: 5px 7px; outline: none; }
.rate input:focus { border-color: var(--accent); }
.rate--missing input { border-color: var(--red); }

.banner {
    display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
    background: rgba(63,208,143,.08); border: 1px solid rgba(63,208,143,.25); color: #bdf2d8;
    border-radius: 12px; padding: 12px 16px; margin-bottom: 16px; font-weight: 500;
}

/* ── Board + panels ─────────────────────────────────── */
.board { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; align-items: start; }
@media (max-width: 1080px) { .board { grid-template-columns: 1fr; } }

.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.panel__head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; padding: 16px 18px 12px; }
.panel__title { display: flex; align-items: center; gap: 9px; font-size: 17px; font-weight: 800; letter-spacing: -.01em; }
.side-dot { width: 9px; height: 9px; border-radius: 50%; }
.panel[data-side=give] .side-dot { background: var(--give); box-shadow: 0 0 12px var(--give); }
.panel[data-side=get] .side-dot { background: var(--get); box-shadow: 0 0 12px var(--get); }
.panel__sub { color: var(--muted); font-size: 12.5px; margin-top: 3px; }
.panel__total { font-size: 22px; font-weight: 800; letter-spacing: -.02em; text-align: right; }
.panel__total small { display: block; color: var(--muted); font-size: 11.5px; font-weight: 500; letter-spacing: 0; margin-top: 2px; }

.panel__tools { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 0 18px 12px; flex-wrap: wrap; }
.mult { display: inline-flex; align-items: center; gap: 6px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 3px 4px 3px 10px; }
.mult__label { font-size: 11px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .05em; }
.mult input { width: 56px; background: transparent; border: 0; outline: none; text-align: center; font-weight: 800; font-size: 14px; }
.mult button { border: 0; background: var(--surface-3); width: 24px; height: 24px; border-radius: 6px; color: var(--text); font-weight: 700; }
.mult__presets { display: inline-flex; gap: 3px; }
.mult__presets button { width: auto; padding: 0 6px; font-size: 11px; color: var(--muted); background: transparent; }
.mult__presets button.is-active { color: var(--accent); }

.thead, .row {
    display: grid; grid-template-columns: minmax(0, 1fr) 54px 108px 116px 34px; align-items: center; gap: 10px; padding: 0 18px;
}
.thead { color: var(--dim); font-size: 11.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; padding-top: 9px; padding-bottom: 9px; border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.thead .r, .row .r { text-align: right; }
.thead .c, .row .c { text-align: center; }
.row { min-height: 84px; border-bottom: 1px solid var(--border); cursor: pointer; transition: background .12s; }
.row:hover { background: rgba(255,255,255,.018); }
.row.is-open { background: var(--surface-2); }
.item { display: flex; align-items: center; gap: 13px; min-width: 0; padding: 10px 0; }
.item__meta { min-width: 0; }
.item__name { font-weight: 700; font-size: 14.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item__name .n { color: var(--muted); font-weight: 600; }
.item__sub { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; color: var(--muted); font-size: 12.5px; margin-top: 4px; }
.item__sub .grade { color: var(--text); font-weight: 700; }
.item__warn { color: var(--amber); font-size: 11.5px; margin-top: 4px; }
.item__warn--bad { color: var(--red); }
.cell-big { font-weight: 700; font-size: 14px; }
.cell-small { color: var(--dim); font-size: 11.5px; margin-top: 2px; }
.value-cell { font-weight: 800; font-size: 14.5px; }
.chev { transition: transform .15s; color: var(--dim); }
.row.is-open .chev { transform: rotate(180deg); }

.empty { padding: 36px 18px; text-align: center; color: var(--muted); }
.empty b { color: var(--text); display: block; margin-bottom: 4px; font-size: 15px; }

.panel__foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 18px; border-top: 1px solid var(--border); flex-wrap: wrap; }
.cash { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); font-size: 12.5px; font-weight: 600; }
.cash__input { display: inline-flex; align-items: center; background: var(--surface-2); border: 1px solid var(--border-2); border-radius: 9px; padding: 0 9px; }
.cash__input input { width: 110px; background: transparent; border: 0; outline: none; padding: 7px 4px; font-weight: 700; text-align: right; }
.cash__input:focus-within { border-color: var(--accent); }

/* Row editor */
.editor { background: var(--surface-2); border-bottom: 1px solid var(--border); padding: 4px 18px 16px; display: grid; gap: 12px; }
.editor__grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; }
.field { display: grid; gap: 5px; }
.field > span { font-size: 11px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .05em; }
.field select, .field input { background: var(--surface); border: 1px solid var(--border-2); border-radius: 9px; padding: 8px 10px; outline: none; width: 100%; }
.field select:focus, .field input:focus { border-color: var(--accent); }
.chips { display: flex; flex-wrap: wrap; gap: 5px; }
.chips button { border: 1px solid var(--border-2); background: var(--surface); color: var(--muted); border-radius: 8px; padding: 5px 10px; font-weight: 700; font-size: 12px; }
.chips button.is-active { border-color: var(--accent); color: #fff; background: rgba(255,107,44,.16); }
.editor__actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.stepper { display: inline-flex; align-items: center; background: var(--surface); border: 1px solid var(--border-2); border-radius: 9px; }
.stepper button { border: 0; background: transparent; width: 30px; height: 34px; font-weight: 800; color: var(--muted); }
.stepper input { width: 44px; border: 0 !important; background: transparent !important; text-align: center; font-weight: 700; padding: 0 !important; }

/* ── Card thumbnails / slabs ────────────────────────── */
.thumb { --w: 48px; flex: none; position: relative; }
.thumb img { display: block; width: 100%; height: 100%; object-fit: contain; }
.thumb__ph { width: 100%; height: 100%; display: grid; place-items: center; color: var(--dim); font-size: calc(var(--w) * .2); text-align: center; padding: 3px; }
.rawcard { width: var(--w); aspect-ratio: 63 / 88; border-radius: calc(var(--w) * .055); overflow: hidden; background: var(--surface-3); box-shadow: 0 2px 10px rgba(0,0,0,.45); }
.sealedbox { width: var(--w); aspect-ratio: 1; border-radius: calc(var(--w) * .08); overflow: hidden; background: var(--surface-3); }
.slab {
    width: var(--w); aspect-ratio: 0.6; border-radius: calc(var(--w) * .09); padding: calc(var(--w) * .055);
    display: flex; flex-direction: column; gap: calc(var(--w) * .045);
    background: linear-gradient(160deg, rgba(255,255,255,.22), rgba(255,255,255,.06) 40%, rgba(255,255,255,.14));
    border: 1px solid rgba(255,255,255,.28); box-shadow: 0 3px 14px rgba(0,0,0,.55), inset 0 0 0 1px rgba(0,0,0,.4);
}
.slab__label {
    height: 21%; flex: none; border-radius: calc(var(--w) * .04); display: flex; align-items: center; justify-content: space-between;
    padding: 0 calc(var(--w) * .06); background: #f7f7f5; color: #111; overflow: hidden; position: relative;
    font-weight: 900; line-height: 1; letter-spacing: -.02em;
}
.slab__grader { font-size: calc(var(--w) * .17); }
.slab__grade { font-size: calc(var(--w) * .25); }
.slab__cert { display: none; position: absolute; left: calc(var(--w) * .06); bottom: calc(var(--w) * .025); font-size: calc(var(--w) * .055); font-weight: 600; opacity: .75; letter-spacing: .02em; }
.slab__window { flex: 1; border-radius: calc(var(--w) * .035); overflow: hidden; background: #0a0a0b; display: grid; place-items: center; }
.slab__window img { width: 92%; height: 96%; object-fit: contain; }
.slab--psa .slab__label { background: #fbfbf8; box-shadow: inset 0 calc(var(--w) * .03) 0 #d01f2f, inset 0 calc(var(--w) * -.03) 0 #d01f2f; }
.slab--psa .slab__grader { color: #d01f2f; }
.slab--bgs .slab__label { background: linear-gradient(180deg, #eef0f3, #b4bac3); }
.slab--bgs.is-gold .slab__label { background: linear-gradient(180deg, #f6dd8c, #c59a32); }
.slab--bgs.is-black .slab__label { background: linear-gradient(180deg, #2b2b2b, #0b0b0b); color: #e8c766; }
.slab--cgc .slab__label { background: #fff; box-shadow: inset calc(var(--w) * .05) 0 0 #1aa6a0; color: #0b2f55; }
.slab--sgc .slab__label { background: #121212; color: #fff; box-shadow: inset 0 0 0 1px #3a3a3a; }
.slab--tag .slab__label { background: #050505; color: #fff; box-shadow: inset 0 0 0 1px #444; }
.slab--ace .slab__label { background: linear-gradient(180deg, #fff, #dfe7ff); color: #1c2f7a; }
.slab--other .slab__label { background: #d9d9de; }
.thumb--lg .slab__cert { display: block; }
.thumb--lg .slab__label { align-items: flex-start; padding-top: calc(var(--w) * .035); }

/* ── Summary bar ────────────────────────────────────── */
.spacer { height: 120px; }
.sumbar {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 25; background: rgba(14,14,17,.92); backdrop-filter: blur(14px);
    border-top: 1px solid var(--border); padding: 12px 24px calc(12px + env(safe-area-inset-bottom));
}
.sumbar__inner { max-width: 1520px; margin: 0 auto; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 18px; }
.sumbar__side { display: flex; flex-direction: column; }
.sumbar__side--get { align-items: flex-end; text-align: right; }
.sumbar__label { font-size: 11px; color: var(--muted); font-weight: 700; text-transform: uppercase; letter-spacing: .06em; display: flex; align-items: center; gap: 6px; }
.sumbar__val { font-size: 24px; font-weight: 800; letter-spacing: -.02em; }
.sumbar__break { font-size: 11.5px; color: var(--dim); }
.sumbar__mid { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.balance { font-weight: 800; font-size: 15px; padding: 6px 14px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border-2); }
.balance--even { color: var(--green); border-color: rgba(63,208,143,.35); }
.balance--us { color: var(--green); }
.balance--them { color: var(--give); }
@media (max-width: 760px) {
    .sumbar__inner { grid-template-columns: 1fr 1fr; }
    .sumbar__mid { grid-column: 1 / -1; order: 3; }
    .sumbar__val { font-size: 19px; }
    .view { padding: 16px 12px; }
    .topbar { padding: 10px 12px; gap: 10px; }
    .topbar .brand > span:last-child, .topbar .link-muted { display: none; }
    .thead { display: none; }
    .row { grid-template-columns: minmax(0, 1fr) 96px 28px; }
    .row .col-qty, .row .col-unit { display: none; }
}

/* ── Drawer (add cards) ─────────────────────────────── */
.drawer { position: fixed; inset: 0; z-index: 60; display: flex; justify-content: flex-end; background: rgba(0,0,0,.55); }
.drawer__panel {
    width: min(760px, 100vw); height: 100%; background: var(--bg); border-left: 1px solid var(--border);
    display: flex; flex-direction: column; animation: slideIn .18s ease-out; position: relative;
}
@keyframes slideIn { from { transform: translateX(30px); opacity: .4; } to { transform: none; opacity: 1; } }
.drawer__head { padding: 16px 20px 12px; border-bottom: 1px solid var(--border); display: grid; gap: 12px; }
.drawer__row { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.drawer__title { font-weight: 800; font-size: 17px; }
.searchbox { display: flex; gap: 8px; }
.searchbox__field { flex: 1; display: flex; align-items: center; gap: 8px; background: var(--surface); border: 1px solid var(--border-2); border-radius: 12px; padding: 0 12px; }
.searchbox__field:focus-within { border-color: var(--accent); }
.searchbox__field input { flex: 1; background: transparent; border: 0; outline: none; padding: 12px 0; font-size: 15px; }
.searchbox__hint { font-size: 12px; color: var(--dim); }
.searchbox__hint code { background: var(--surface-2); padding: 1px 5px; border-radius: 4px; color: var(--muted); }
.drawer__body { flex: 1; overflow-y: auto; padding: 16px 20px 200px; }
.drawer__filters { display: flex; gap: 8px; flex-wrap: wrap; }
.dropzone {
    position: absolute; inset: 0; display: none; place-items: center; z-index: 5; background: rgba(255,107,44,.1);
    border: 2px dashed var(--accent); border-radius: 6px; font-size: 18px; font-weight: 800; color: #fff; pointer-events: none;
}
.drawer.is-drag .dropzone { display: grid; }
.notes-list { color: var(--dim); font-size: 12px; margin: 0 0 10px; padding-left: 18px; }
.err-box { background: rgba(255,95,95,.08); border: 1px solid rgba(255,95,95,.3); color: #ffc2c2; border-radius: 10px; padding: 10px 12px; font-size: 13px; white-space: pre-wrap; margin-bottom: 12px; }
.err-box pre { max-height: 220px; overflow: auto; font-size: 11px; color: #f3a1a1; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 10px; cursor: pointer; display: flex; flex-direction: column; gap: 8px; transition: border-color .12s, transform .12s; text-align: left; }
.tile:hover { border-color: var(--border-2); transform: translateY(-1px); }
.tile.is-picked { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.tile__img { display: grid; place-items: center; height: 170px; }
.tile__img .thumb { --w: 118px; }
.tile__name { font-weight: 700; font-size: 13px; line-height: 1.25; }
.tile__set { color: var(--muted); font-size: 11.5px; line-height: 1.3; }
.tile__prices { display: flex; justify-content: space-between; font-size: 11.5px; color: var(--muted); border-top: 1px solid var(--border); padding-top: 7px; margin-top: auto; }
.tile__prices b { color: var(--text); font-weight: 700; }
.tile__score { font-size: 10.5px; color: var(--dim); }

.detect { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 14px; margin-bottom: 16px; }
.detect__head { display: flex; gap: 12px; align-items: flex-start; margin-bottom: 12px; }
.detect__photo { width: 64px; height: 84px; border-radius: 8px; object-fit: cover; flex: none; border: 1px solid var(--border-2); }
.detect__read { font-weight: 700; font-size: 14px; }
.detect__facts { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 6px; }
.conf { height: 4px; border-radius: 4px; background: var(--surface-3); width: 120px; overflow: hidden; margin-top: 8px; }
.conf > i { display: block; height: 100%; background: var(--green); }
.scan-progress { display: flex; align-items: center; gap: 12px; padding: 18px; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; margin-bottom: 16px; }
.scan-progress img { width: 54px; height: 72px; object-fit: cover; border-radius: 6px; }
.spinner { width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--surface-3); border-top-color: var(--accent); animation: spin .8s linear infinite; flex: none; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Multi-card scan: overview photo with matched card outlines */
.mscan { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 14px; margin-bottom: 16px; }
.mscan__bar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.mscan__bar .muted { font-size: 12px; }
.mscan__stage { position: relative; border-radius: 10px; overflow: hidden; cursor: crosshair; line-height: 0; }
.mscan__stage img { width: 100%; display: block; }
.mscan__stage svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.mscan__card { fill: rgba(63,208,143,.08); stroke: var(--green); stroke-width: 3; cursor: pointer; vector-effect: non-scaling-stroke; }
.mscan__card:hover { fill: rgba(63,208,143,.22); }
.mscan__card.is-weak { stroke: var(--amber); fill: rgba(245,183,66,.08); }
.mscan__num { fill: #fff; font: 800 24px var(--font); paint-order: stroke; stroke: #000; stroke-width: 5px; pointer-events: none; }
.mscan__card.is-pending { stroke: #fff; stroke-width: 2; stroke-dasharray: 6 5; fill: rgba(255,255,255,.06); animation: pulse 1.2s ease-in-out infinite; }
.mscan__card.is-error { stroke: var(--red); fill: rgba(255,95,95,.1); }
@keyframes pulse { 50% { opacity: .35; } }
.vis { display: flex; align-items: center; gap: 10px; margin-top: 10px; padding: 8px 10px; border-radius: 10px; background: rgba(63,208,143,.07); border: 1px solid rgba(63,208,143,.25); font-size: 12.5px; }
.vis img { width: 34px; height: 47px; object-fit: cover; border-radius: 4px; }
.vis .muted { font-size: 11.5px; }
.vis--weak { background: rgba(245,183,66,.07); border-color: rgba(245,183,66,.3); color: #f5d08a; }
.vis--busy { background: var(--surface-2); border-color: var(--border-2); color: var(--muted); }
.gweb { margin-top: 6px; font-size: 12px; display: flex; flex-wrap: wrap; gap: 6px; align-items: baseline; }
.gweb a { font-size: 11.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
.gweb__ok { color: var(--green); }
.gweb__bad { color: var(--amber); }
.gweb--err { color: var(--red); }
.detect.is-flash { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(255,107,44,.35); }
.detect--missed { border-style: dashed; }

.config {
    position: absolute; left: 0; right: 0; bottom: 0; background: var(--surface); border-top: 1px solid var(--border-2);
    box-shadow: 0 -18px 40px rgba(0,0,0,.5); padding: 16px 20px calc(16px + env(safe-area-inset-bottom)); display: grid; gap: 12px;
    animation: rise .16s ease-out;
}
@keyframes rise { from { transform: translateY(20px); opacity: .5; } to { transform: none; opacity: 1; } }
.config__top { display: flex; gap: 14px; align-items: flex-start; }
.config__top .thumb { --w: 62px; }
.config__name { font-weight: 800; font-size: 15px; }
.config__value { margin-left: auto; text-align: right; }
.config__value b { font-size: 20px; font-weight: 800; display: block; }
.config__grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; align-items: end; }

/* ── History ────────────────────────────────────────── */
.hist__head { display: flex; justify-content: space-between; align-items: flex-end; gap: 14px; flex-wrap: wrap; margin-bottom: 16px; }
.hist__title { font-size: 24px; font-weight: 800; letter-spacing: -.02em; margin: 0; }
.hist__stats { color: var(--muted); margin-top: 4px; }
.hist__tools { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.hist__search { display: flex; align-items: center; gap: 8px; background: var(--surface); border: 1px solid var(--border); border-radius: 999px; padding: 0 14px; }
.hist__search input { background: transparent; border: 0; outline: none; padding: 8px 0; width: 200px; }
.htable { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.hrow { display: grid; grid-template-columns: minmax(0, 1.6fr) 120px 120px 110px 140px 90px; gap: 12px; align-items: center; padding: 12px 18px; border-bottom: 1px solid var(--border); cursor: pointer; }
.hrow:last-child { border-bottom: 0; }
.hrow:hover { background: rgba(255,255,255,.02); }
.hrow--head { cursor: default; color: var(--dim); font-size: 11.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; }
.hrow--head:hover { background: none; }
.hrow .r { text-align: right; }
.hrow__who { display: flex; align-items: center; gap: 12px; min-width: 0; }
.stack { display: flex; flex: none; }
.stack img, .stack span { width: 30px; height: 42px; object-fit: cover; border-radius: 4px; border: 2px solid var(--surface); margin-left: -10px; background: var(--surface-3); }
.stack :first-child { margin-left: 0; }
.hrow__name { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hrow__date { color: var(--muted); font-size: 12px; margin-top: 2px; }
.pos { color: var(--green); }
.neg { color: var(--give); }
@media (max-width: 900px) {
    .hrow { grid-template-columns: minmax(0, 1fr) 110px 80px; }
    .hrow .h-opt { display: none; }
}

/* ── Present mode ───────────────────────────────────── */
.present { position: fixed; inset: 0; z-index: 80; background: radial-gradient(1200px 600px at 50% -10%, #1f150f, var(--bg) 60%); overflow-y: auto; padding: 28px 34px 140px; }
.present__top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 22px; }
.present__partner { font-size: 26px; font-weight: 800; letter-spacing: -.02em; }
.present__cols { display: grid; grid-template-columns: 1fr 1fr; gap: 26px; }
@media (max-width: 900px) { .present__cols { grid-template-columns: 1fr; } }
.present__col { background: rgba(20,20,23,.7); border: 1px solid var(--border); border-radius: 18px; padding: 20px; }
.present__colhead { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 18px; }
.present__colhead h2 { margin: 0; font-size: 15px; text-transform: uppercase; letter-spacing: .1em; display: flex; align-items: center; gap: 9px; }
.present__colhead .big { font-size: 30px; font-weight: 800; letter-spacing: -.02em; }
.present__grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 20px 16px; }
.pcard { display: flex; flex-direction: column; align-items: center; gap: 8px; text-align: center; }
.pcard .thumb { --w: 140px; }
.pcard__name { font-weight: 700; font-size: 13px; line-height: 1.25; }
.pcard__sub { color: var(--muted); font-size: 11.5px; }
.pcard__val { font-weight: 800; font-size: 15px; }
.pcard__qty { position: absolute; top: -6px; right: -6px; background: var(--accent); color: #fff; font-weight: 800; font-size: 12px; border-radius: 999px; padding: 2px 7px; z-index: 2; }
.present__cash { margin-top: 18px; padding: 12px 14px; border-radius: 12px; background: var(--surface-2); display: flex; justify-content: space-between; font-weight: 700; }
.present__foot { position: fixed; left: 0; right: 0; bottom: 0; padding: 18px 34px; background: rgba(12,12,14,.92); border-top: 1px solid var(--border); display: flex; justify-content: center; gap: 40px; align-items: center; font-size: 18px; font-weight: 700; flex-wrap: wrap; }
.present__foot .balance { font-size: 18px; }

/* ── Modal + toasts ─────────────────────────────────── */
.modal { position: fixed; inset: 0; z-index: 90; display: grid; place-items: center; background: rgba(0,0,0,.6); padding: 16px; }
.modal__card { width: min(520px, 100%); background: var(--surface); border: 1px solid var(--border-2); border-radius: 16px; padding: 22px; display: grid; gap: 14px; max-height: 90vh; overflow: auto; }
.modal__card h3 { margin: 0; font-size: 18px; }
.modal__actions { display: flex; justify-content: flex-end; gap: 8px; }
.kv { display: grid; grid-template-columns: 1fr auto; gap: 6px 14px; font-size: 13.5px; }
.kv .k { color: var(--muted); }
.kv .v { font-weight: 700; text-align: right; }
.toasts { position: fixed; top: 70px; right: 18px; z-index: 95; display: grid; gap: 8px; width: min(420px, calc(100vw - 36px)); }
.toast { background: var(--surface-2); border: 1px solid var(--border-2); border-radius: 12px; padding: 11px 14px; font-size: 13px; box-shadow: 0 10px 30px rgba(0,0,0,.4); animation: rise .16s ease-out; }
.toast--ok { border-color: rgba(63,208,143,.4); }
.toast--error { border-color: rgba(255,95,95,.5); background: #241517; white-space: pre-wrap; }
.toast--error details { margin-top: 6px; }
.toast--error pre { max-height: 260px; overflow: auto; font-size: 11px; color: #f3a1a1; white-space: pre-wrap; }
.toast__close { float: right; border: 0; background: transparent; color: var(--muted); font-size: 16px; line-height: 1; margin-left: 8px; }
