/* ============================================================
   Panini Collection — full-viewport web app UI
   ============================================================ */

:root {
    --bg:        #0b0d17;
    --bg-2:      #12152400;
    --panel:     #151933;
    --panel-2:   #1b2044;
    --panel-3:   #232a56;
    --line:      #2b3167;
    --text:      #eef1ff;
    --muted:     #98a0d0;
    --faint:     #6b73a8;
    --accent:    #4f7cff;
    --accent-2:  #6d54ff;
    --green:     #2fbf71;
    --green-dim: #1c7a49;
    --gold:      #f4b83e;
    --gold-dim:  #7a5a12;
    --red:       #e2445c;
    --radius:    14px;
    --radius-sm: 10px;
    --shadow:    0 18px 50px rgba(0, 0, 0, .5);
    --font:      -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }

body {
    font-family: var(--font);
    color: var(--text);
    background:
        radial-gradient(1200px 800px at 100% -10%, #1b2050 0%, transparent 55%),
        radial-gradient(1000px 700px at -10% 110%, #201a4a 0%, transparent 55%),
        var(--bg);
    width: 100dvw;
    height: 100dvh;
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
}

#app { width: 100dvw; height: 100dvh; overflow: hidden; }

/* ---------- Loading ---------- */
.app-loading { display: grid; place-items: center; }
.spinner {
    width: 42px; height: 42px; border-radius: 50%;
    border: 4px solid var(--panel-3); border-top-color: var(--accent);
    animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

button { font-family: inherit; cursor: pointer; }
button:disabled { opacity: .5; cursor: not-allowed; }

/* ============================================================
   Auth screen
   ============================================================ */
.auth {
    width: 100dvw; height: 100dvh;
    display: grid; place-items: center; padding: 20px;
}
.auth-card {
    width: min(400px, 100%);
    background: linear-gradient(180deg, var(--panel-2), var(--panel));
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 30px 28px;
}
.auth-logo { font-size: 40px; text-align: center; }
.auth-card h1 { text-align: center; font-size: 22px; margin: 6px 0 2px; }
.auth-card p.sub { text-align: center; color: var(--muted); margin: 0 0 22px; font-size: 14px; }
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 12.5px; color: var(--muted); margin-bottom: 6px; }
.field input {
    width: 100%; padding: 12px 14px; font-size: 15px;
    background: var(--bg); color: var(--text);
    border: 1px solid var(--line); border-radius: var(--radius-sm);
    outline: none; transition: border-color .15s;
}
.field input:focus { border-color: var(--accent); }
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    padding: 12px 18px; font-size: 15px; font-weight: 600;
    border: 1px solid transparent; border-radius: var(--radius-sm);
    background: var(--panel-3); color: var(--text); transition: filter .15s, background .15s;
}
.btn:hover { filter: brightness(1.12); }
.btn-primary { background: linear-gradient(180deg, var(--accent), var(--accent-2)); color: #fff; width: 100%; }
.btn-ghost { background: transparent; border-color: var(--line); }
.btn-block { width: 100%; }
.auth-switch { text-align: center; margin-top: 16px; font-size: 13.5px; color: var(--muted); }
.auth-switch a { color: var(--accent); cursor: pointer; text-decoration: none; }
.form-error {
    background: rgba(226, 68, 92, .12); border: 1px solid rgba(226, 68, 92, .4);
    color: #ffb3bf; padding: 10px 12px; border-radius: var(--radius-sm);
    font-size: 13px; margin-bottom: 14px;
}

/* Sign-up: location status, fill-book option, deletion notice */
.geo-status { font-size: 12.5px; padding: 9px 12px; border-radius: var(--radius-sm); margin-bottom: 12px; border: 1px solid var(--line); }
.geo-status.checking { color: var(--muted); }
.geo-status.ok   { color: #9be9bd; border-color: var(--green-dim); background: rgba(47,191,113,.10); }
.geo-status.warn { color: #ffe4a6; border-color: var(--gold-dim); background: rgba(244,184,62,.10); }
.geo-status.bad  { color: #ffb3bf; border-color: rgba(226,68,92,.5); background: rgba(226,68,92,.12); }
.fillbook-opt {
    display: flex; gap: 10px; align-items: flex-start; cursor: pointer;
    background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius-sm);
    padding: 12px; margin-bottom: 12px;
}
.fillbook-opt input { margin-top: 3px; flex: none; }
.fillbook-opt b { display: block; font-size: 13.5px; }
.fillbook-opt small { color: var(--muted); font-size: 12px; line-height: 1.45; }
.geo-notice { font-size: 12px; color: var(--muted); line-height: 1.5; margin-bottom: 16px; }
.geo-notice b { color: var(--text); }

/* ============================================================
   App shell
   ============================================================ */
.shell {
    width: 100dvw; height: 100dvh;
    display: grid;
    grid-template-columns: 288px 1fr;
    grid-template-rows: 100dvh;
}

/* ---------- Sidebar ---------- */
.sidebar {
    background: rgba(10, 12, 26, .72);
    backdrop-filter: blur(8px);
    border-right: 1px solid var(--line);
    display: flex; flex-direction: column;
    min-height: 0;
}
.brand {
    display: flex; align-items: center; gap: 10px;
    padding: 18px 20px; border-bottom: 1px solid var(--line); flex: none;
}
.brand .logo { font-size: 24px; }
.brand h1 { font-size: 16px; margin: 0; }
.brand small { display: block; color: var(--faint); font-size: 11px; font-weight: 500; }

.overall {
    padding: 16px 20px; border-bottom: 1px solid var(--line); flex: none;
}
.overall .pct { font-size: 30px; font-weight: 800; letter-spacing: -.5px; }
.overall .pct span { font-size: 15px; color: var(--muted); font-weight: 600; }
.overall .nums { color: var(--muted); font-size: 12.5px; margin-top: 2px; }
.bar { height: 8px; background: var(--panel); border-radius: 99px; overflow: hidden; margin-top: 10px; }
.bar > i { display: block; height: 100%; background: linear-gradient(90deg, var(--green), #7be0a4); border-radius: 99px; transition: width .35s; }

.nav-search { padding: 12px 14px 4px; flex: none; }
.nav-search input {
    width: 100%; padding: 10px 12px; font-size: 13.5px;
    background: var(--bg); color: var(--text);
    border: 1px solid var(--line); border-radius: var(--radius-sm); outline: none;
}
.nav-search input:focus { border-color: var(--accent); }
.nav-empty { color: var(--faint); font-size: 13px; padding: 12px; text-align: center; }

.nav { overflow-y: auto; flex: 1; min-height: 0; padding: 8px 10px 20px; }
.nav-group-label {
    font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--faint);
    padding: 14px 12px 6px; font-weight: 700;
}
.nav-item {
    display: flex; align-items: center; gap: 10px;
    padding: 9px 12px; border-radius: var(--radius-sm);
    color: var(--muted); cursor: pointer; user-select: none;
    border: 1px solid transparent;
}
.nav-item:hover { background: var(--panel); color: var(--text); }
.nav-item.active { background: var(--panel-2); color: var(--text); border-color: var(--line); }
.nav-item .name { flex: 1; font-size: 14px; font-weight: 500; }
.nav-item .count {
    font-size: 11.5px; color: var(--faint); font-variant-numeric: tabular-nums;
    background: var(--bg); padding: 2px 7px; border-radius: 99px; border: 1px solid var(--line);
}
.nav-item.complete .count { color: var(--green); border-color: var(--green-dim); }
.nav-item .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--panel-3); flex: none; }
.nav-item.complete .dot { background: var(--green); }
.nav-item.partial .dot { background: var(--gold); }
.nav-item .flag { width: 22px; flex: none; text-align: center; font-size: 16px; line-height: 1; }
.nav-item.alert .count { background: var(--red); color: #fff; border-color: transparent; }
.nav-item.complete .name { color: var(--green); }

.sidebar-ad {
    flex: none; padding: 8px 16px 10px;
    border-top: 1px solid var(--line);
    background: rgba(255,255,255,.02);
}
.sidebar-ad-head {
    width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 8px;
    padding: 0 0 7px; border: 0; background: transparent; color: var(--faint);
    font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: .08em;
}
.sidebar-ad-head small {
    text-transform: none; letter-spacing: 0; color: var(--muted);
    font-size: 11px; font-weight: 700;
}
.sidebar-ad-head:hover, .sidebar-ad-head:hover small { color: var(--text); }
.sidebar-ad-media { overflow: hidden; }
.sidebar-ad img {
    display: block; width: 100%; height: 128px;
    object-fit: contain; border-radius: 8px;
    background: #05070d;
}
.sidebar-ad.collapsed { padding-bottom: 8px; }
.sidebar-ad.collapsed .sidebar-ad-head { padding-bottom: 0; }
.sidebar-ad.collapsed .sidebar-ad-media { display: none; }

.sidebar-foot { border-top: 1px solid var(--line); padding: 12px 16px; flex: none; display: flex; align-items: center; gap: 10px; }
.avatar {
    width: 34px; height: 34px; border-radius: 50%; flex: none;
    display: grid; place-items: center; font-weight: 700; color: #fff;
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
}
.sidebar-foot .who { flex: 1; min-width: 0; }
.sidebar-foot .who b { display: block; font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-foot .who small { color: var(--faint); font-size: 11px; }
.icon-btn {
    background: var(--panel); border: 1px solid var(--line); color: var(--muted);
    width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center; font-size: 15px;
}
.icon-btn:hover { color: var(--text); }
.icon-btn.tog.on { color: #fff; background: linear-gradient(180deg, var(--accent), var(--accent-2)); border-color: transparent; }
.sidebar-foot { gap: 8px; }

/* ---------- Main ---------- */
.main { min-width: 0; min-height: 0; display: flex; flex-direction: column; height: 100dvh; }

.topbar {
    flex: none; display: flex; align-items: center; gap: 14px;
    padding: 16px 24px; border-bottom: 1px solid var(--line);
    background: rgba(11, 13, 23, .55); backdrop-filter: blur(8px);
}
.topbar .menu-btn { display: none; }
.topbar .title { flex: 1; min-width: 0; }
.topbar .title h2 { margin: 0; font-size: 19px; }
.topbar .title .crumb { color: var(--faint); font-size: 12.5px; }
.topbar .sec-progress { color: var(--muted); font-size: 13px; text-align: right; flex: none; }
.topbar .sec-progress b { color: var(--text); }

.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 7px 12px; font-size: 12.5px; font-weight: 600;
    background: var(--panel-2); border: 1px solid var(--line); color: var(--muted); border-radius: 99px;
}
.chip:hover { color: var(--text); border-color: var(--accent); }
.chip.solid { background: var(--panel-3); color: var(--text); }
.minf { display: inline-flex; align-items: center; gap: 7px; font-size: 12px; color: var(--muted); font-weight: 600; }
.minf input {
    width: 54px; padding: 6px 8px; text-align: center; font: inherit;
    background: var(--bg); color: var(--text); border: 1px solid var(--line); border-radius: 8px;
}

.content { flex: 1; min-height: 0; overflow-y: auto; overflow-x: hidden; padding: 14px 20px 24px; }

/* Wide tables scroll inside their own box rather than widening the page. */
.tscroll { overflow-x: auto; -webkit-overflow-scrolling: touch; max-width: 100%; }

/* ---------- Card grid: 4 columns ---------- */
.grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    /* Portrait cards are tall, so a 4×5 team page is height-bound: cap the grid
       width to whatever keeps 5 rows within the viewport. */
    width: min(360px, 100%, calc((100dvh - 150px) * 0.56));
    margin: 0 auto;
}
.card {
    position: relative; aspect-ratio: 210 / 297; /* portrait sticker */
    min-width: 0; /* let grid tracks shrink below the nowrap name's intrinsic width */
    border-radius: 10px; border: 1.5px solid var(--line);
    background: linear-gradient(180deg, var(--panel-2), var(--panel));
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 3px; cursor: pointer; user-select: none;
    transition: transform .08s, border-color .15s, box-shadow .15s;
}
.card:hover { transform: translateY(-2px); box-shadow: 0 10px 24px rgba(0,0,0,.35); }
.card:active { transform: translateY(0); }

/* Clean sticker scan fills the tile. The <img> adds .has-img on load; cards
   without a scan (img 404s and removes itself) keep the plain styled tile. */
.card .cbg {
    position: absolute; inset: 0; border-radius: inherit; z-index: 0; overflow: hidden;
}
.card .cbg img {
    width: 100%; height: 100%; object-fit: cover; object-position: center 16%; display: block;
}
.card > :not(.cbg) { z-index: 1; } /* flex/abs children stack above the backdrop */
.card .cflag, .card .code, .card .qty, .card .cname { text-shadow: 0 1px 4px rgba(0,0,0,.85); }

/* Dark scrim over sticker scans so the overlaid code/name/status stay readable. */
.card.has-img .cbg::after {
    content: ''; position: absolute; inset: 0; border-radius: inherit;
    background: linear-gradient(180deg, rgba(11,13,23,.74), rgba(11,13,23,.90));
}

.card .cflag { font-size: clamp(13px, 3.4vw, 18px); line-height: 1; }
.card .code { font-size: clamp(12px, 3.2vw, 16px); font-weight: 800; letter-spacing: .3px; }
.card .cname {
    width: 92%; font-size: 9.5px; line-height: 1.15; color: var(--muted);
    display: flex; flex-direction: column; align-items: center; text-align: center;
}
.card .cname span, .card .cname b {
    display: block; max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.card .cname span { font-weight: 500; }
.card .cname b { font-weight: 800; }
.card .cname.single {
    display: block; font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.card .qty {
    position: absolute; left: 5px; right: 5px; bottom: 5px; justify-content: center;
    font-size: 9px; line-height: 1; font-weight: 700; color: var(--faint);
    display: inline-flex; align-items: center; gap: 3px;
}
.card .qty .swatch { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

.card.missing { border-style: dashed; border-color: #3a2130; }
.card.missing .code { color: var(--faint); }
.card.missing .qty { color: var(--red); }
.card.missing .cbg { filter: grayscale(1); opacity: .45; }

.card.owned { border-color: var(--green-dim); background: linear-gradient(180deg, rgba(47,191,113,.14), var(--panel)); }
.card.owned .qty { color: var(--green); }

/* Doubles look like a normal owned card; only the count text + badge are amber. */
.card.double .qty { color: var(--gold); }

.card .badge {
    position: absolute; top: 6px; right: 6px;
    min-width: 20px; height: 20px; padding: 0 6px;
    border-radius: 99px; background: var(--gold); color: #1a1400;
    font-size: 11px; font-weight: 800; display: grid; place-items: center;
}

.section-note { max-width: 480px; margin: 0 auto 10px; color: var(--muted); font-size: 12px; text-align: center; }

/* Book "page view": two 4×3 halves. Empty cells stay blank; card 13 spans 2 cols.
   Stacked top/bottom on mobile, side-by-side (open book) on desktop. */
.page-book { display: flex; flex-direction: column; align-items: center; gap: 16px; }
.page-half {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 7px;
    width: min(300px, 100%, calc((100dvh - 160px) * 0.46));
}
.page-half .card { aspect-ratio: 210 / 297; }
.page-half .card.landscape { aspect-ratio: 297 / 210; }
@media (min-width: 760px) {
    .page-book { flex-direction: row; align-items: flex-start; justify-content: center; gap: 30px; }
    .page-half { width: min(300px, 44vw); }
}

/* Grid / Page view switcher */
.switcher { display: inline-flex; background: var(--panel-2); border: 1px solid var(--line); border-radius: 9px; padding: 2px; }
.switcher .sw {
    border: none; background: transparent; color: var(--muted);
    padding: 5px 10px; font-size: 15px; border-radius: 7px; line-height: 1;
}
.switcher .sw.on { background: var(--panel-3); color: var(--text); }

/* ============================================================
   Modal
   ============================================================ */
.overlay {
    position: fixed; inset: 0; background: rgba(4, 6, 16, .7);
    backdrop-filter: blur(3px); display: grid; place-items: center; z-index: 50; padding: 20px;
    animation: fade .15s ease;
}
@keyframes fade { from { opacity: 0; } }
.modal {
    width: min(360px, 100%);
    background: linear-gradient(180deg, var(--panel-2), var(--panel));
    border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
    padding: 26px 24px; text-align: center; animation: pop .18s ease;
}
@keyframes pop { from { transform: scale(.94); opacity: 0; } }
.modal .m-img {
    display: block; height: min(34vh, 300px); aspect-ratio: 480 / 668;
    margin: 0 auto 14px; border-radius: 8px; object-fit: cover;
    box-shadow: 0 8px 28px rgba(0,0,0,.55);
}
.modal .m-code { font-size: 30px; font-weight: 900; letter-spacing: .5px; }
.modal .m-name { font-size: 15px; font-weight: 700; margin-top: 2px; }
.modal .m-sub { color: var(--muted); font-size: 13px; margin-top: 2px; }
.stepper { display: flex; align-items: center; justify-content: center; gap: 18px; margin: 24px 0 8px; }
.step-btn {
    width: 58px; height: 58px; border-radius: 50%; font-size: 26px; font-weight: 700;
    background: var(--panel-3); border: 1px solid var(--line); color: var(--text);
    display: grid; place-items: center; transition: filter .12s, transform .06s;
}
.step-btn:hover { filter: brightness(1.2); }
.step-btn:active { transform: scale(.92); }
.step-btn.plus { background: linear-gradient(180deg, var(--green), var(--green-dim)); border-color: transparent; }
.step-btn.minus { background: linear-gradient(180deg, #3a3f6e, var(--panel-3)); }
.qty-big { min-width: 84px; font-size: 52px; font-weight: 900; font-variant-numeric: tabular-nums; }
.qty-label { color: var(--muted); font-size: 12.5px; height: 16px; }
.modal-actions { display: flex; gap: 10px; margin-top: 20px; }
.modal-actions .btn { flex: 1; }

.share-url { display: flex; gap: 8px; margin: 18px 0 4px; }
.share-url input {
    flex: 1; min-width: 0; padding: 11px 12px; font-size: 13px; text-align: left;
    background: var(--bg); color: var(--text); border: 1px solid var(--line); border-radius: var(--radius-sm);
}
.share-url .btn { flex: none; width: auto; padding-left: 20px; padding-right: 20px; }

.settings-row { text-align: left; margin-top: 18px; }
.settings-row label { display: flex; justify-content: space-between; font-size: 13px; color: var(--muted); margin-bottom: 8px; }
.settings-row label b { color: var(--text); font-variant-numeric: tabular-nums; }
.settings-row input[type="range"] { width: 100%; accent-color: var(--accent); height: 22px; cursor: pointer; }

/* ============================================================
   Admin panel & list viewer (uses .content)
   ============================================================ */
.panel-wrap { max-width: 860px; margin: 0 auto; }
.filter-select { max-width: 46vw; }
.card-box {
    background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
    padding: 20px; margin-bottom: 18px;
}
.card-box h3 { margin: 0 0 14px; font-size: 15px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
.row .field { margin: 0; flex: 1; min-width: 130px; }
.checkbox { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); font-size: 14px; cursor: pointer; }

table.data { width: 100%; border-collapse: collapse; }
table.data th, table.data td { text-align: left; padding: 11px 10px; border-bottom: 1px solid var(--line); font-size: 14px; }
table.data th { color: var(--faint); font-size: 12px; text-transform: uppercase; letter-spacing: .05em; }
table.data td.actions { text-align: right; white-space: nowrap; }
.tag { font-size: 11px; padding: 2px 8px; border-radius: 99px; border: 1px solid var(--line); color: var(--muted); }
.tag.admin { color: var(--gold); border-color: var(--gold-dim); }
.tag.susp { color: var(--red); border-color: rgba(226,68,92,.4); }
.suspended-row { opacity: .55; }
.mini-btn { padding: 6px 10px; font-size: 12.5px; border-radius: 8px; background: var(--panel-3); border: 1px solid var(--line); color: var(--text); margin-left: 6px; }
.mini-btn.danger { color: #ffb3bf; border-color: rgba(226,68,92,.4); }
.mini-btn.good { color: #9be9bd; border-color: var(--green-dim); }
.mini-btn:hover { filter: brightness(1.15); }

.list-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: 8px; }
.list-cell {
    background: var(--panel-2); border: 1px solid var(--line); border-radius: 9px;
    padding: 9px 6px; text-align: center; font-size: 13px;
}
.list-cell b { display: block; font-weight: 800; }
.list-cell small { color: var(--faint); font-size: 11px; }

/* Check-cards result cells */
.list-cell.chk.have { border-color: var(--green-dim); background: rgba(47,191,113,.12); }
.list-cell.chk.have small { color: var(--green); }
.list-cell.chk.dupe { border-color: var(--gold-dim); background: rgba(244,184,62,.14); }
.list-cell.chk.dupe small { color: var(--gold); }
.list-cell.chk.need { border-color: #3a2130; }
.list-cell.chk.need small { color: var(--red); }
.list-cell.chk.unknown { opacity: .6; }
.check-summary { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.check-summary .pill { font-size: 12.5px; font-weight: 700; padding: 4px 12px; border-radius: 99px; border: 1px solid var(--line); }
.check-summary .pill.have { color: var(--green); border-color: var(--green-dim); }
.check-summary .pill.need { color: var(--red); border-color: #3a2130; }
.check-summary .pill.unknown { color: var(--muted); }

.check-actions { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.toggle-switch-field {
    display: inline-flex; align-items: center; gap: 8px;
    color: var(--muted); font-size: 13px; font-weight: 700;
    cursor: pointer; user-select: none;
}
.toggle-switch-field input {
    position: absolute; opacity: 0; width: 1px; height: 1px; pointer-events: none;
}
.toggle-switch {
    position: relative; width: 36px; height: 20px; flex: none;
    border-radius: 99px; border: 1px solid var(--line);
    background: var(--panel-2); transition: border-color .15s, background .15s;
}
.toggle-switch::after {
    content: ''; position: absolute; top: 2px; left: 2px;
    width: 14px; height: 14px; border-radius: 50%;
    background: var(--faint); transition: transform .15s, background .15s;
}
.toggle-switch-field input:checked + .toggle-switch {
    border-color: var(--gold-dim); background: rgba(244,184,62,.18);
}
.toggle-switch-field input:checked + .toggle-switch::after {
    transform: translateX(16px); background: var(--gold);
}
.toggle-switch-field input:focus-visible + .toggle-switch {
    outline: 2px solid var(--accent); outline-offset: 2px;
}

.field textarea {
    width: 100%; padding: 12px 14px; font: inherit; font-size: 14px; resize: vertical;
    background: var(--bg); color: var(--text); border: 1px solid var(--line); border-radius: var(--radius-sm);
    outline: none;
}
.field textarea:focus { border-color: var(--accent); }

/* Needed / Doubles grouped into per-team blocks */
.list-block { margin-bottom: 22px; }
.list-head {
    display: flex; align-items: center; gap: 9px; margin: 0 0 10px;
    font-size: 15px; padding-bottom: 7px; border-bottom: 1px solid var(--line);
}
.list-head .list-group {
    margin-left: auto; color: var(--muted); font-size: 12px; font-weight: 700;
}
.list-head .list-count {
    margin-left: auto; font-size: 12px; font-weight: 700; color: var(--muted);
    background: var(--panel); border: 1px solid var(--line); border-radius: 99px; padding: 2px 9px;
}
.list-head .list-group + .list-count { margin-left: 0; }

.needed-grid {
    grid-template-columns: repeat(auto-fill, minmax(118px, 1fr));
    gap: 10px;
}
.needed-cell {
    min-width: 0; padding: 8px; text-align: center;
    background: var(--panel-2); border: 1px solid var(--line); border-radius: 9px;
}
.needed-code {
    display: block; margin-bottom: 5px; font-size: 13px; line-height: 1;
    font-weight: 900; color: var(--text);
}
.needed-name {
    display: flex; flex-direction: column; align-items: center;
    min-height: 29px; color: var(--muted);
    font-size: 12px; line-height: 1.15;
}
.needed-name span, .needed-name b {
    display: block; max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.needed-name span { font-weight: 500; }
.needed-name b { color: var(--text); font-weight: 800; }
.needed-name.single { justify-content: center; }
.needed-by {
    display: block; margin-top: 5px; padding-top: 5px;
    border-top: 1px dashed var(--line);
    color: var(--faint); font-size: 11px; font-weight: 700;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* Merge lists (admin): collector tick boxes */
.merge-users { display: flex; flex-wrap: wrap; gap: 8px; }
.merge-user {
    display: inline-flex; align-items: center; gap: 7px; cursor: pointer;
    padding: 7px 12px; border-radius: 99px; font-size: 13.5px; font-weight: 600;
    background: var(--panel-2); border: 1px solid var(--line); color: var(--muted);
}
.merge-user:hover { color: var(--text); }
.merge-user.on { color: var(--text); border-color: var(--accent); background: rgba(79,124,255,.12); }
.merge-user input { accent-color: var(--accent); margin: 0; }

/* Impersonation banner */
.imp-banner {
    flex: none; display: flex; align-items: center; justify-content: space-between; gap: 12px;
    padding: 10px 22px; font-size: 13.5px;
    background: linear-gradient(90deg, rgba(244,184,62,.18), rgba(244,184,62,.06));
    border-bottom: 1px solid var(--gold-dim); color: #ffe4a6; flex-wrap: wrap;
}
.imp-banner .mini-btn { background: var(--gold); color: #241a00; border-color: transparent; font-weight: 700; }

/* Unread messages banner (thin red strip under the top) */
.unread-banner {
    flex: none; text-align: center; cursor: pointer;
    padding: 7px 14px; font-size: 13px; font-weight: 600;
    background: linear-gradient(90deg, rgba(226,68,92,.9), rgba(226,68,92,.75));
    color: #fff; border-bottom: 1px solid rgba(0,0,0,.2);
}
.unread-banner:hover { filter: brightness(1.06); }

/* Audit filter select */
.filter-select {
    font: inherit; font-size: 13px; padding: 7px 12px; border-radius: 99px;
    background: var(--panel-3); color: var(--text); border: 1px solid var(--line); cursor: pointer;
}
.data td.when { color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.data .muted, small.muted { color: var(--faint); }
.delta { font-weight: 800; font-variant-numeric: tabular-nums; }
.delta.up { color: var(--green); }
.delta.down { color: var(--red); }

/* Find suppliers — chips of users who can supply a needed card */
.supplier-list { display: flex; flex-wrap: wrap; gap: 7px; }
.supplier {
    font-size: 13px; padding: 6px 11px; border-radius: 99px;
    background: var(--panel-2); border: 1px solid var(--line); color: var(--text);
}
.supplier b { color: var(--green); font-variant-numeric: tabular-nums; }
.spare-row { margin-bottom: 10px; padding: 12px 16px; }
.spare-row > b { font-size: 15px; }
.spare-head { margin-bottom: 8px; display: flex; gap: 10px; align-items: baseline; }
.spare-head b { font-size: 15px; }

/* Transfer (Give) button inside swap-match cells */
.list-cell .xfer { display: block; width: 100%; margin: 6px 0 0; padding: 5px 6px; font-size: 11.5px; text-align: center; color: #9be9bd; border-color: var(--green-dim); }
.list-cell .req { display: block; width: 100%; margin: 5px 0 0; padding: 5px 6px; font-size: 11.5px; text-align: center; color: var(--muted); }

/* Inbox messages */
.msg { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; margin-bottom: 12px; }
.msg.unread { border-color: var(--accent); background: linear-gradient(180deg, rgba(79,124,255,.08), var(--panel)); }
.msg-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; margin-bottom: 6px; }
.msg-head b { font-size: 14.5px; }
.msg-meta { color: var(--faint); font-size: 12px; white-space: nowrap; }
.msg-body { color: var(--muted); font-size: 13.5px; line-height: 1.5; white-space: pre-wrap; }

/* Swap match — two side-by-side columns */
.match-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; align-items: start; }
.match-col { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; }
.match-title {
    margin: 0 0 14px; font-size: 15px; display: flex; align-items: center; gap: 8px;
    padding-bottom: 10px; border-bottom: 1px solid var(--line);
}
.match-title b {
    margin-left: auto; font-size: 12px; color: var(--accent);
    background: var(--panel-2); border: 1px solid var(--line); border-radius: 99px; padding: 2px 10px;
}
@media (max-width: 720px) { .match-grid { grid-template-columns: 1fr; } }

.empty-state { text-align: center; color: var(--muted); padding: 60px 20px; }
.empty-state .big { font-size: 40px; }

/* ---------- Toast ---------- */
#toast {
    position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%) translateY(20px);
    background: var(--panel-3); border: 1px solid var(--line); color: var(--text);
    padding: 11px 18px; border-radius: 99px; font-size: 13.5px; font-weight: 600;
    box-shadow: var(--shadow); opacity: 0; pointer-events: none; transition: all .25s; z-index: 80;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
#toast.err { border-color: var(--red); color: #ffb3bf; }

/* ---------- Scrollbars ---------- */
.nav::-webkit-scrollbar, .content::-webkit-scrollbar { width: 10px; }
.nav::-webkit-scrollbar-thumb, .content::-webkit-scrollbar-thumb { background: var(--panel-3); border-radius: 99px; border: 2px solid transparent; background-clip: padding-box; }

/* ============================================================
   Responsive: sidebar becomes a drawer
   ============================================================ */
.scrim { display: none; }
@media (max-width: 860px) {
    .shell { grid-template-columns: 1fr; }
    .sidebar {
        position: fixed; z-index: 60; top: 0; left: 0; width: 280px; height: 100dvh;
        transform: translateX(-100%); transition: transform .22s ease; box-shadow: var(--shadow);
    }
    .shell.drawer-open .sidebar { transform: translateX(0); }
    .shell.drawer-open .scrim { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 55; }
    .topbar .menu-btn { display: grid; }
    .topbar .sec-progress { display: none; }
    .topbar { flex-wrap: wrap; row-gap: 10px; }
    .topbar .title { min-width: 55%; }
    .topbar .title h2 { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    .chips { margin-left: auto; }
    .content { padding: 16px 14px 60px; }
    .grid { gap: 9px; }
    .match-title { flex-wrap: wrap; }
}
@media (max-width: 420px) {
    .topbar { padding: 12px 14px; }
    .topbar .title h2 { font-size: 17px; }
}
@media (max-height: 720px) {
    .sidebar-ad img { height: 96px; }
}
