:root {
  color-scheme: light;
  --page: #f4f3ef;
  --surface-1: #fcfcfb;
  --text-primary: #0b0b0b;
  --text-secondary: #52514e;
  --text-muted: #898781;
  --gridline: #e1e0d9;
  --border: rgba(11, 11, 11, 0.10);
  --series-1: #2a78d6;
  --series-2: #eb6834;
  --accent: #2a78d6;
  --danger: #c0392b;
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --page: #111110;
    --surface-1: #1a1a19;
    --text-primary: #f0efec;
    --text-secondary: #c3c2b7;
    --text-muted: #898781;
    --gridline: #2c2c2a;
    --border: rgba(255, 255, 255, 0.10);
    --series-1: #3987e5;
    --series-2: #d95926;
    --accent: #5a9cec;
    --danger: #ef6f62;
  }
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--page); color: var(--text-primary); }
h1, h2 { margin: 0; line-height: 1.2; }
h1 { font-size: 1.15rem; }
h2 { font-size: 1.1rem; }
button { font: inherit; color: inherit; cursor: pointer; }

/* Login */
body.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { width: 100%; max-width: 360px; background: var(--surface-1); border: 1px solid var(--border); border-radius: 14px; padding: 28px 24px; }
.login-card h1 { margin-bottom: 18px; }
.login-card form { display: grid; gap: 14px; }
.login-card label { display: grid; gap: 6px; color: var(--text-secondary); font-size: 0.9rem; }
.login-card input { font: inherit; padding: 10px 12px; border-radius: 8px; border: 1px solid var(--border); background: var(--page); color: var(--text-primary); }
.login-card button { margin-top: 4px; padding: 11px; border: 0; border-radius: 999px; background: var(--accent); color: #fff; font-weight: 600; }
.login-error { margin: 0 0 14px; color: var(--danger); font-size: 0.9rem; }

/* Dashboard */
.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 16px; border-bottom: 1px solid var(--border); background: var(--surface-1); }
.top-user { display: flex; align-items: center; gap: 12px; margin: 0; color: var(--text-secondary); font-size: 0.9rem; }
.link { background: none; border: 0; padding: 0; color: var(--accent); }
main { max-width: 1040px; margin: 0 auto; padding: 20px 16px 48px; }

.panel { background: var(--surface-1); border: 1px solid var(--border); border-radius: 14px; padding: 20px; position: relative; }
.panel-head { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: 12px 20px; }
.panel-note { margin: 4px 0 0; color: var(--text-secondary); font-size: 0.88rem; max-width: 60ch; }

.range { display: inline-flex; border: 1px solid var(--border); border-radius: 999px; padding: 2px; }
.range button { border: 0; background: none; padding: 5px 12px; border-radius: 999px; color: var(--text-secondary); font-size: 0.85rem; }
.range button[aria-pressed="true"] { background: var(--text-primary); color: var(--surface-1); }

.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; margin: 18px 0; }
.tile { display: grid; gap: 2px; padding: 14px; border-radius: 10px; border: 1px solid var(--border); }
.tile-label { color: var(--text-secondary); font-size: 0.85rem; }
.tile strong { font-size: 1.6rem; font-variant-numeric: tabular-nums; }
.tile-sub { color: var(--text-muted); font-size: 0.82rem; }

.legend { display: flex; flex-wrap: wrap; gap: 6px 18px; list-style: none; margin: 0 0 8px; padding: 0; color: var(--text-secondary); font-size: 0.85rem; }
.legend li { display: flex; align-items: center; gap: 6px; }
.swatch { width: 12px; height: 12px; border-radius: 3px; }
.swatch-1 { background: var(--series-1); }
.swatch-2 { background: var(--series-2); }

.chart { position: relative; min-height: 240px; }
.chart svg { display: block; width: 100%; height: 240px; overflow: visible; }
.chart-status { position: absolute; inset: 0; display: grid; place-items: center; margin: 0; color: var(--text-muted); font-size: 0.9rem; pointer-events: none; }
.axis text { fill: var(--text-muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.grid line { stroke: var(--gridline); stroke-width: 1; }
.bar-1 { fill: var(--series-1); }
.bar-2 { fill: var(--series-2); }
.day-hit { fill: transparent; outline: none; }
.day-hit:hover, .day-hit:focus-visible { fill: var(--text-primary); fill-opacity: 0.05; }

.tooltip { position: absolute; z-index: 2; min-width: 170px; padding: 10px 12px; border-radius: 10px; background: var(--surface-1); border: 1px solid var(--border); box-shadow: 0 6px 20px rgba(0, 0, 0, 0.12); font-size: 0.85rem; pointer-events: none; }
.tooltip-day { color: var(--text-secondary); margin-bottom: 6px; }
.tooltip-row { display: grid; grid-template-columns: 14px auto 1fr; align-items: center; gap: 6px; }
.tooltip-row strong { font-variant-numeric: tabular-nums; }
.tooltip-row span:last-child { color: var(--text-secondary); }
.tooltip-key { width: 12px; height: 3px; border-radius: 2px; }

.table-view { margin-top: 14px; font-size: 0.88rem; }
.table-view summary { cursor: pointer; color: var(--accent); }
.table-view table { width: 100%; border-collapse: collapse; margin-top: 10px; font-variant-numeric: tabular-nums; }
.table-view th, .table-view td { text-align: right; padding: 6px 8px; border-bottom: 1px solid var(--gridline); }
.table-view th:first-child, .table-view td:first-child { text-align: left; }
.table-view th { color: var(--text-secondary); font-weight: 500; }
