/* Master Set Tracker */
:root {
  --bg: #f4f5f8;
  --surface: #ffffff;
  --surface-2: #eef0f4;
  --border: #dde1e8;
  --text: #1b1f2a;
  --muted: #697083;
  --accent: #e3350d;
  --accent-2: #ffcb05;
  --blue: #2a6fdb;
  --ok: #1f9d55;
  --gold: #c99a06;
  --bar-bg: #e3e6ec;
  --shadow: 0 1px 2px rgba(20, 25, 40, .06), 0 4px 14px rgba(20, 25, 40, .06);
  --radius: 12px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #11141b;
    --surface: #1a1e28;
    --surface-2: #232837;
    --border: #2e3446;
    --text: #e8ebf2;
    --muted: #949bb0;
    --bar-bg: #2a3040;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 6px 18px rgba(0, 0, 0, .25);
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
}
body.noscroll { overflow: hidden; }
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .4em; }
h1 { font-size: 1.8rem; }
code { background: var(--surface-2); padding: 0 .3em; border-radius: 4px; font-size: .9em; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.ok { color: var(--ok); }
[hidden] { display: none !important; }

.wrap { max-width: 1320px; margin: 0 auto; padding: 0 16px; }

/* Top bar */
.topbar { background: var(--surface); border-bottom: 3px solid var(--accent); position: sticky; top: 0; z-index: 20; }
.topbar-inner { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 56px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 8px; color: var(--text); font-weight: 700; font-size: 1.05rem; }
.brand svg { color: var(--accent); }
.brand:hover { text-decoration: none; }
.nav { display: flex; gap: 4px; flex-wrap: wrap; }
.nav a { padding: 6px 12px; border-radius: 8px; color: var(--text); font-weight: 500; }
.nav a:hover { background: var(--surface-2); text-decoration: none; }
.nav a.on { background: var(--surface-2); color: var(--accent); }
.nav a.muted { color: var(--muted); }

main.wrap { padding-top: 24px; padding-bottom: 40px; }
.footer { color: var(--muted); font-size: .8rem; padding-bottom: 32px; }

.hero { margin-bottom: 18px; }
.hero.row { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; }
.section-title { margin-top: 28px; font-size: 1.2rem; }

/* Buttons & forms */
.btn {
  display: inline-flex; align-items: center; gap: 6px; border: 1px solid transparent; cursor: pointer;
  background: var(--accent); color: #fff; font: inherit; font-weight: 600; padding: 9px 16px; border-radius: 9px;
}
.btn:hover { filter: brightness(1.07); text-decoration: none; }
.btn.sm { padding: 5px 11px; font-size: .85rem; border-radius: 7px; }
.btn.ghost { background: transparent; color: var(--text); border-color: var(--border); }
.btn.ghost:hover { background: var(--surface-2); }
.btn.on { background: var(--accent-2); color: #3b2f00; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
input, select {
  font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border);
  border-radius: 8px; padding: 8px 10px; min-width: 0;
}
input:focus, select:focus { outline: 2px solid var(--blue); outline-offset: -1px; }
.form { display: grid; gap: 14px; max-width: 760px; }
.form label { display: grid; gap: 4px; font-weight: 500; }
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; }
.checks { display: flex; flex-wrap: wrap; gap: 8px 18px; }
.form label.check, label.check { display: flex; align-items: center; gap: 8px; font-weight: 400; }
.switch { display: inline-flex; align-items: center; gap: 6px; font-size: .9rem; color: var(--muted); white-space: nowrap; }
.alert { background: #fde8e4; color: #8a1c05; padding: 10px 14px; border-radius: 8px; }
.alert.ok { background: #e3f5ea; color: #145c33; }
.badge { font-size: .75rem; vertical-align: middle; background: var(--accent-2); color: #3b2f00; padding: 3px 8px; border-radius: 99px; }

.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); margin-bottom: 18px; }
.empty { background: var(--surface); border: 1px dashed var(--border); border-radius: var(--radius); padding: 40px 20px; text-align: center; }

.auth { max-width: 380px; margin: 40px auto; }

/* Progress */
.prog { margin: 10px 0; }
.prog-head { display: flex; justify-content: space-between; gap: 10px; font-size: .9rem; margin-bottom: 4px; }
.prog-label { font-weight: 600; }
.prog-nums { color: var(--muted); white-space: nowrap; }
.prog-nums b { color: var(--text); }
.bar { height: 10px; background: var(--bar-bg); border-radius: 99px; overflow: hidden; }
.bar i { display: block; height: 100%; background: linear-gradient(90deg, var(--accent), #ff6b3d); border-radius: 99px; transition: width .35s ease; }
.bar.sm { height: 6px; }
.bar.big, .prog.big .bar { height: 16px; }
.prog.big .prog-head { font-size: 1.05rem; }
.prog.gold .bar i { background: linear-gradient(90deg, var(--gold), var(--accent-2)); }
.progress-block { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 18px; box-shadow: var(--shadow); margin-bottom: 16px; }

/* Stat tiles */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; margin: 16px 0; }
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; display: grid; gap: 2px; box-shadow: var(--shadow); }
.tile-k { color: var(--muted); font-size: .82rem; }
.tile-v { font-size: 1.6rem; font-weight: 700; }
.tile-s { color: var(--muted); font-size: .8rem; }

.breakdown { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 16px; }
.breakdown .panel { margin-bottom: 0; }
table.mini { width: 100%; border-collapse: collapse; font-size: .88rem; }
table.mini td, table.mini th { padding: 5px 4px; border-bottom: 1px solid var(--border); text-align: left; }
table.mini tr:last-child td { border-bottom: 0; }
table.mini td.n { white-space: nowrap; color: var(--muted); width: 1%; padding-right: 12px; }
table.mini td.n b { color: var(--text); }
table.mini td.w { width: 40%; }

/* Home set cards */
.set-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 16px; margin-top: 18px; }
.set-card { display: grid; grid-template-rows: 110px auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; color: var(--text); box-shadow: var(--shadow); transition: transform .15s; }
.set-card:hover { text-decoration: none; transform: translateY(-2px); }
.set-logo { display: grid; place-items: center; padding: 14px; background: linear-gradient(135deg, var(--surface-2), var(--surface)); }
.set-logo img { max-height: 82px; max-width: 80%; object-fit: contain; }
.set-info { padding: 12px 16px 16px; }
.set-title { display: flex; align-items: center; gap: 8px; }
.set-title h2 { font-size: 1.15rem; margin: 0; }
.sym { width: 22px; height: 22px; object-fit: contain; flex: none; }
.set-meta { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: .85rem; color: var(--muted); margin-top: 8px; }
.set-meta b { color: var(--text); }

.set-head { display: flex; gap: 20px; align-items: center; margin-bottom: 18px; flex-wrap: wrap; }
.set-head-logo img { max-height: 90px; max-width: 260px; object-fit: contain; }

/* Manage sets */
.set-list { display: grid; gap: 6px; }
.set-row { display: grid; grid-template-columns: 26px minmax(0, 1fr) auto auto auto auto; align-items: center; gap: 10px; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 8px 12px; }
.set-row.tracked { border-color: var(--accent-2); }
.sr-name { display: grid; min-width: 0; }
.sr-name b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
details.serie { margin: 10px 0; }
details.serie summary { cursor: pointer; font-weight: 700; padding: 6px 0; }

/* Toolbar */
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin: 22px 0 14px; position: sticky; top: 59px; z-index: 10; background: var(--bg); padding: 8px 0; }
.toolbar input[type=search] { flex: 1 1 220px; }
.toolbar .count { margin-left: auto; color: var(--muted); font-size: .85rem; }

/* Card grid */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 14px; }
.grid.compact { grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 8px; }
.grid.compact .tc-name, .grid.compact .tc-rar { display: none; }
.grid.is-admin { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }

.tc { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; overflow: hidden; display: flex; flex-direction: column; box-shadow: var(--shadow); }
.tc-img { position: relative; display: block; width: 100%; padding: 8px 8px 0; border: 0; background: none; cursor: zoom-in; aspect-ratio: 245 / 342; }
.tc-img img { width: 100%; height: 100%; object-fit: contain; border-radius: 6px; transition: filter .2s, opacity .2s; }
.tc-img .noimg { display: grid; place-items: center; height: 100%; background: var(--surface-2); border-radius: 6px; color: var(--muted); font-size: .8rem; padding: 8px; }
.tc.s-missing .tc-img img { filter: grayscale(1); opacity: .38; }
.tc.s-partial { border-color: color-mix(in srgb, var(--accent-2) 70%, var(--border)); }
.tc.s-complete { border-color: var(--ok); }
.tick { position: absolute; top: 12px; right: 12px; width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; background: var(--ok); color: #fff; font-weight: 700; font-size: .9rem; box-shadow: 0 2px 6px rgba(0,0,0,.3); }
.tc-body { padding: 8px 10px 10px; display: grid; gap: 4px; }
.tc-top { display: flex; gap: 6px; align-items: baseline; min-width: 0; }
.tc-num { font-size: .75rem; color: var(--muted); font-variant-numeric: tabular-nums; flex: none; }
.tc-name { font-weight: 600; font-size: .9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tc-rar { font-size: .74rem; color: var(--muted); }
.tc-vars { display: flex; flex-wrap: wrap; gap: 4px; }

/* Variant chips */
.vc { display: inline-flex; align-items: center; gap: 4px; font-size: .75rem; border: 1px solid var(--border); background: var(--surface-2); color: var(--muted); padding: 2px 7px; border-radius: 99px; line-height: 1.5; }
.vc em { font-style: normal; font-weight: 700; }
.vc b { background: var(--text); color: var(--surface); border-radius: 99px; padding: 0 6px; font-size: .7rem; }
.vc.have { background: color-mix(in srgb, var(--ok) 16%, var(--surface)); border-color: var(--ok); color: var(--text); }
.vc.have b { background: var(--ok); color: #fff; }
.vc.off { opacity: .5; text-decoration: line-through; }
.vc.adm { padding: 2px 3px 2px 8px; }
.vc.adm b { min-width: 22px; text-align: center; }
.vc .q { border: 0; background: var(--surface); color: var(--text); width: 22px; height: 22px; border-radius: 50%; cursor: pointer; font-weight: 700; line-height: 1; font-size: .9rem; }
.vc .q:hover { background: var(--accent); color: #fff; }
.vc .va input { margin: 0 2px; }
.vdel, .vadd { border: 1px dashed var(--border); background: none; color: var(--muted); border-radius: 99px; font-size: .72rem; cursor: pointer; padding: 1px 7px; }
.vdel:hover, .vadd:hover { color: var(--accent); border-color: var(--accent); }
.vaddform { display: flex; gap: 4px; width: 100%; }
.vaddform input { flex: 1; padding: 3px 6px; font-size: .8rem; }

/* Quick add */
.quick label { display: block; margin-bottom: 8px; }
.quick-row { display: flex; gap: 8px; max-width: 420px; }
.quick-row input { flex: 1; font-size: 1.1rem; }
.quick-log { list-style: none; padding: 0; margin: 10px 0 0; font-size: .88rem; display: grid; gap: 2px; }
.quick-log .pos { color: var(--ok); font-weight: 700; }
.quick-log .neg { color: var(--accent); font-weight: 700; }
.quick-log .err { color: var(--accent); }

/* Modal */
.modal { position: fixed; inset: 0; background: rgba(8, 10, 16, .72); z-index: 50; display: grid; place-items: center; padding: 16px; }
.modal-box { position: relative; background: var(--surface); border-radius: 16px; max-width: 860px; width: 100%; max-height: calc(100vh - 32px); overflow: auto; padding: 22px; }
.modal-box.narrow { max-width: 440px; }
.modal-x { position: absolute; top: 8px; right: 12px; border: 0; background: none; color: var(--muted); font-size: 1.8rem; cursor: pointer; line-height: 1; }
.modal-body { display: grid; grid-template-columns: minmax(0, 340px) minmax(0, 1fr); gap: 24px; }
.m-img img { width: 100%; border-radius: 12px; }
.m-vars { margin-top: 12px; }
.m-vars tr.have td:first-child { font-weight: 600; }
.m-nav { display: flex; gap: 8px; margin-top: 16px; }
.pill { display: inline-block; padding: 3px 10px; border-radius: 99px; font-size: .8rem; font-weight: 600; background: var(--surface-2); }
.pill.s-complete { background: var(--ok); color: #fff; }
.pill.s-partial { background: var(--accent-2); color: #3b2f00; }

#toast { position: fixed; bottom: 20px; left: 50%; transform: translate(-50%, 30px); background: var(--text); color: var(--surface); padding: 10px 16px; border-radius: 10px; opacity: 0; transition: .25s; z-index: 60; pointer-events: none; }
#toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 720px) {
  h1 { font-size: 1.45rem; }
  .modal-body { grid-template-columns: 1fr; }
  .m-img { max-width: 260px; margin: 0 auto; }
  .set-row { grid-template-columns: 22px minmax(0, 1fr) auto; }
  .set-row > .small { display: none; }
  .set-row .btn { grid-column: span 1; }
  .set-cards { grid-template-columns: 1fr; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
  .grid.is-admin { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
  .toolbar { top: 0; position: static; }
  .tiles { grid-template-columns: 1fr 1fr; }
  .tile-v { font-size: 1.3rem; }
}

/* Bulk variant tool & promos */
details.panel > summary { cursor: pointer; }
.bulk-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; margin-top: 12px; }
.bulk-grid > label { display: grid; gap: 4px; font-weight: 500; font-size: .9rem; }
.bulk-rar { grid-column: 1 / -1; border: 1px solid var(--border); border-radius: 8px; display: flex; flex-wrap: wrap; gap: 6px 16px; padding: 8px 12px; }
.bulk-rar legend { font-weight: 500; font-size: .9rem; padding: 0 4px; }
.bulk-actions { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.promo-tag { background: var(--accent-2); color: #3b2f00; border-radius: 4px; padding: 0 4px; font-weight: 700; font-size: .65rem; text-transform: uppercase; }
