:root {
  color-scheme: light;
  --bg: #f4f4f1;
  --surface: #fcfcfb;
  --surface-2: #f0efec;
  --border: #e3e2dd;
  --text: #16181d;
  --text-2: #52514e;
  --muted: #7d7c77;
  --grid: #e8e7e2;
  --accent: #2a78d6;
  --accent-ink: #ffffff;
  --side: #14213a;
  --side-text: #c8d2e4;
  --side-on: #2a78d6;
  --series-1: #2a78d6;
  --series-2: #eb6834;
  --series-3: #1baf7a;
  --good: #0ca30c;
  --good-ink: #006300;
  --bad: #d03b3b;
  --bad-ink: #b42828;
  --live: #fab219;
  --pend: #a9a8a2;
  --void: #7b8aa3;
  --shadow: 0 1px 2px rgba(20, 20, 20, .05), 0 1px 12px rgba(20, 20, 20, .04);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #111110;
    --surface: #1a1a19;
    --surface-2: #232321;
    --border: #2f2f2c;
    --text: #f3f3f1;
    --text-2: #c3c2b7;
    --muted: #8f8e86;
    --grid: #2b2b29;
    --accent: #3987e5;
    --side: #0b1222;
    --side-text: #aab6cc;
    --side-on: #3987e5;
    --series-1: #3987e5;
    --series-2: #d95926;
    --series-3: #199e70;
    --good-ink: #4cc94c;
    --bad-ink: #ef7373;
    --pend: #6d6c66;
    --shadow: none;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #111110; --surface: #1a1a19; --surface-2: #232321; --border: #2f2f2c;
  --text: #f3f3f1; --text-2: #c3c2b7; --muted: #8f8e86; --grid: #2b2b29;
  --accent: #3987e5; --side: #0b1222; --side-text: #aab6cc; --side-on: #3987e5;
  --series-1: #3987e5; --series-2: #d95926; --series-3: #199e70;
  --good-ink: #4cc94c; --bad-ink: #ef7373; --pend: #6d6c66; --shadow: none;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  display: flex;
  min-height: 100vh;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- Sidebar ---------- */
.side {
  width: 230px; flex: none; background: var(--side); color: var(--side-text);
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh;
}
.brand { display: flex; gap: 10px; align-items: center; padding: 20px 18px; color: #fff; font-weight: 700; font-size: 16px; line-height: 1.1; }
.brand:hover { text-decoration: none; }
.brand small { font-weight: 400; font-size: 11px; color: var(--side-text); }
.logo { width: 36px; height: 36px; border-radius: 10px; background: var(--side-on); display: grid; place-items: center; font-size: 18px; color: #fff; }
.side nav { display: flex; flex-direction: column; padding: 6px 10px; gap: 2px; }
.side nav a { display: flex; gap: 10px; align-items: center; padding: 9px 10px; border-radius: 8px; color: var(--side-text); }
.side nav a:hover { background: rgba(255,255,255,.06); text-decoration: none; color: #fff; }
.side nav a.on { background: var(--side-on); color: #fff; }
.side nav svg { width: 18px; height: 18px; fill: currentColor; flex: none; }
.side-foot { margin-top: auto; padding: 16px 18px; font-size: 11px; opacity: .6; }

main { flex: 1; min-width: 0; padding: 0 28px 40px; }
.top { display: flex; align-items: center; justify-content: space-between; padding: 22px 0 14px; }
.top h1 { font-size: 22px; margin: 0; letter-spacing: -.01em; }

/* ---------- Cards / grid ---------- */
.grid { display: grid; gap: 16px; margin-bottom: 16px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g-2-1 { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 16px 18px; box-shadow: var(--shadow); min-width: 0; }
.card h2 { font-size: 15px; margin: 0 0 2px; }
.card .sub { color: var(--muted); font-size: 12px; margin: 0 0 12px; }
.card.empty { text-align: center; padding: 50px; }

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px; box-shadow: var(--shadow); }
.kpi .l { color: var(--text-2); font-size: 12px; }
.kpi .v { font-size: 26px; font-weight: 650; letter-spacing: -.02em; margin-top: 2px; font-variant-numeric: tabular-nums; }
.kpi .d { color: var(--muted); font-size: 12px; }

.chart-wrap { position: relative; width: 100%; }

/* ---------- Filters ---------- */
.filters { display: flex; flex-wrap: wrap; gap: 10px 14px; align-items: flex-end; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; margin-bottom: 16px; }
.filters label { display: flex; flex-direction: column; font-size: 11px; color: var(--text-2); gap: 3px; }
input, select, button { font: inherit; color: var(--text); }
input[type=text], input[type=date], input[type=number], input[type=search], select {
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 6px 8px; min-height: 34px;
}
input.short { width: 84px; }
.btn { display: inline-flex; align-items: center; gap: 6px; background: var(--accent); color: var(--accent-ink); border: 0; border-radius: 8px; padding: 8px 14px; cursor: pointer; font-weight: 600; min-height: 34px; }
.btn:hover { filter: brightness(1.07); text-decoration: none; }
.btn.ghost { background: transparent; color: var(--text-2); border: 1px solid var(--border); }
.btn.danger { background: var(--bad); }
.btn.small { padding: 4px 10px; min-height: 28px; font-size: 12px; }

.tabs { display: flex; gap: 4px; margin-bottom: 12px; flex-wrap: wrap; }
.tabs a { padding: 6px 12px; border-radius: 999px; border: 1px solid var(--border); color: var(--text-2); background: var(--surface); }
.tabs a.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.tabs a:hover { text-decoration: none; }

/* ---------- Tables ---------- */
.tbl-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; white-space: nowrap; }
th a { color: inherit; }
td.n, th.n { text-align: right; white-space: nowrap; }
tbody tr:hover { background: var(--surface-2); }
tr.sub-row td { border-bottom: 0; padding-top: 0; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.pos { color: var(--good-ink); font-weight: 600; }
.neg { color: var(--bad-ink); font-weight: 600; }
.nowrap { white-space: nowrap; }

.badge { display: inline-flex; align-items: center; gap: 4px; font-size: 11px; font-weight: 600; padding: 2px 8px 2px 6px; border-radius: 999px; white-space: nowrap; border: 1px solid transparent; }
.badge i { font-style: normal; font-size: 10px; }
.badge.won { background: color-mix(in srgb, var(--good) 14%, transparent); color: var(--good-ink); border-color: color-mix(in srgb, var(--good) 35%, transparent); }
.badge.lost { background: color-mix(in srgb, var(--bad) 12%, transparent); color: var(--bad-ink); border-color: color-mix(in srgb, var(--bad) 35%, transparent); }
.badge.live { background: color-mix(in srgb, var(--live) 18%, transparent); color: var(--text); border-color: color-mix(in srgb, var(--live) 60%, transparent); }
.badge.pend { background: var(--surface-2); color: var(--text-2); border-color: var(--border); }
.badge.void { background: var(--surface-2); color: var(--void); border-color: var(--border); }
.tag { display: inline-block; font-size: 11px; padding: 1px 7px; border-radius: 6px; background: var(--surface-2); color: var(--text-2); border: 1px solid var(--border); margin-right: 3px; }

/* status bar */
.sbar { display: flex; height: 14px; border-radius: 7px; overflow: hidden; gap: 2px; margin: 10px 0; }
.sbar span { min-width: 3px; }
.sbar .won, .dot.won { background: var(--good); }
.sbar .lost, .dot.lost { background: var(--bad); }
.sbar .live, .dot.live { background: var(--live); }
.sbar .pend, .dot.pend { background: var(--pend); }
.sbar .void, .dot.void { background: var(--void); }
.slegend { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 12px; color: var(--text-2); }
.slegend b { color: var(--text); }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 6px; }

/* hit-rate mini bar */
.hr { display: flex; align-items: center; gap: 8px; min-width: 130px; }
.hr span.small { white-space: nowrap; }
.hr .b { flex: 1; height: 6px; background: var(--surface-2); border-radius: 3px; overflow: hidden; }
.hr .b span { display: block; height: 100%; background: var(--series-1); border-radius: 3px; }

/* coupon detail */
.coupon-head { display: flex; flex-wrap: wrap; gap: 24px; align-items: center; }
.coupon-head .big { font-size: 30px; font-weight: 700; }
.ev-sel { font-size: 13px; }
.ev-sel .t { font-weight: 600; }

/* import */
.drop { border: 2px dashed var(--border); border-radius: 12px; padding: 30px; text-align: center; background: var(--surface-2); }
.drop.over { border-color: var(--accent); }
.alert { padding: 12px 14px; border-radius: 10px; margin-bottom: 16px; border: 1px solid; }
.alert.ok { background: color-mix(in srgb, var(--good) 10%, var(--surface)); border-color: color-mix(in srgb, var(--good) 40%, transparent); }
.alert.err { background: color-mix(in srgb, var(--bad) 10%, var(--surface)); border-color: color-mix(in srgb, var(--bad) 40%, transparent); }
.alert.warn { background: color-mix(in srgb, var(--live) 12%, var(--surface)); border-color: color-mix(in srgb, var(--live) 50%, transparent); }

.pager { display: flex; gap: 6px; justify-content: center; margin-top: 14px; flex-wrap: wrap; }
.pager a, .pager span { padding: 4px 10px; border: 1px solid var(--border); border-radius: 6px; background: var(--surface); }
.pager span.on { background: var(--accent); color: #fff; border-color: var(--accent); }

.note { font-size: 12px; color: var(--muted); margin-top: 8px; }
details summary { cursor: pointer; color: var(--accent); }

@media (max-width: 1100px) {
  .g3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .g-2-1 { grid-template-columns: 1fr; }
}
@media (max-width: 800px) {
  body { flex-direction: column; }
  .side { width: 100%; height: auto; position: static; }
  .side nav { flex-direction: row; overflow-x: auto; }
  .side nav a { white-space: nowrap; }
  .side-foot { display: none; }
  main { padding: 0 16px 30px; }
  .g2, .g3 { grid-template-columns: 1fr; }
}

.tag.warn-tag { background: color-mix(in srgb, var(--live) 18%, transparent); border-color: color-mix(in srgb, var(--live) 55%, transparent); color: var(--text); }
.tag.ok-tag { background: color-mix(in srgb, var(--good) 12%, transparent); border-color: color-mix(in srgb, var(--good) 35%, transparent); color: var(--good-ink); }
.alerts { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 8px; }
.alerts li { padding: 10px 12px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface-2); }
.alerts li.bad { border-color: color-mix(in srgb, var(--bad) 45%, transparent); background: color-mix(in srgb, var(--bad) 8%, var(--surface)); }
.alerts li.good { border-color: color-mix(in srgb, var(--good) 45%, transparent); background: color-mix(in srgb, var(--good) 8%, var(--surface)); }
.explain { font-size: 12px; color: var(--text-2); background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; margin: 8px 0 12px; }
.explain b { color: var(--text); }
textarea.report { width: 100%; min-height: 520px; font: 12px/1.45 ui-monospace, Consolas, monospace; background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: 10px; padding: 12px; }
.formrow { display: flex; flex-wrap: wrap; gap: 10px 14px; align-items: flex-end; }
.formrow label { display: flex; flex-direction: column; font-size: 11px; color: var(--text-2); gap: 3px; }
.checks { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 12px; }
.checks label { flex-direction: row !important; align-items: center; gap: 5px !important; font-size: 12px !important; color: var(--text) !important; }

.intro { background: color-mix(in srgb, var(--accent) 8%, var(--surface)); border: 1px solid color-mix(in srgb, var(--accent) 30%, transparent); border-left: 4px solid var(--accent); border-radius: 10px; padding: 12px 14px; margin: -4px 0 16px; font-size: 13px; color: var(--text-2); }
.intro b { color: var(--text); }
.what { font-size: 13px; color: var(--text-2); margin: 4px 0 6px; line-height: 1.45; }
.what b { color: var(--text); font-weight: 600; }
.what + .sub { margin-top: 0; }

/* ---------- Typy Claude: podział dzień-po-dniu / archiwum w kubełkach ---------- */
.day-head { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; padding: 8px 12px; border-radius: 8px; margin-bottom: 8px; display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.day-head.today { background: color-mix(in srgb, var(--accent) 12%, var(--surface)); color: var(--accent); border: 1px solid color-mix(in srgb, var(--accent) 35%, transparent); }
.day-head.future { background: var(--surface-2); color: var(--text-2); border: 1px solid var(--border); }
.day-head .count { font-weight: 400; text-transform: none; letter-spacing: 0; color: inherit; opacity: .8; }

.arch-bucket { border: 1px solid var(--border); border-radius: 12px; margin-bottom: 10px; overflow: hidden; }
.arch-bucket + .arch-bucket { margin-top: 10px; }
.arch-bucket > summary { list-style: none; cursor: pointer; display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 14px; font-weight: 700; font-size: 13px; background: var(--surface-2); }
.arch-bucket > summary::-webkit-details-marker { display: none; }
.arch-bucket > summary::before { content: '▸'; margin-right: 8px; color: var(--muted); display: inline-block; transition: transform .15s; }
.arch-bucket[open] > summary::before { transform: rotate(90deg); }
.arch-bucket > summary .count { font-weight: 400; color: var(--muted); font-size: 12px; }
.arch-bucket > summary .sumy { font-weight: 400; font-size: 12px; color: var(--text-2); display: flex; gap: 8px; align-items: center; white-space: nowrap; }
.arch-bucket .tbl-wrap { padding: 0; }
.arch-bucket .tbl-wrap table { margin: 0; }
.arch-bucket.today { border-color: color-mix(in srgb, var(--accent) 45%, transparent); }
.arch-bucket.today > summary { background: color-mix(in srgb, var(--accent) 10%, var(--surface)); color: var(--accent); }
.arch-bucket.yesterday { border-color: color-mix(in srgb, var(--series-3) 45%, transparent); }
.arch-bucket.yesterday > summary { background: color-mix(in srgb, var(--series-3) 10%, var(--surface)); color: var(--good-ink); }
.arch-bucket.week > summary, .arch-bucket.twoweeks > summary { background: var(--surface-2); color: var(--text-2); }
.arch-bucket.month > summary, .arch-bucket.older > summary { background: var(--surface-2); color: var(--muted); }
.arch-empty { padding: 10px 14px; margin: 0; }
