:root {
  color-scheme: light;
  --page: #f9f9f7;
  --surface: #fcfcfb;
  --ink: #0b0b0b;
  --ink-2: #52514e;
  --muted: #6f6d68;
  --grid: #e1e0d9;
  --axis: #c3c2b7;
  --border: rgba(11, 11, 11, 0.10);
  --series: #2a78d6;
  --track: #cde2fb;
  --good: #0ca30c;
  --good-text: #006300;
  --bad-text: #b42e2e;
  --warn-bg: #fff4d6;
  --warn-ink: #6b4a00;
  --accent-bg: #eef4fc;
  --shadow: 0 1px 2px rgba(11, 11, 11, 0.04);
  --radius: 14px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --page: #0d0d0d;
    --surface: #1a1a19;
    --ink: #ffffff;
    --ink-2: #c3c2b7;
    --muted: #9a988f;
    --grid: #2c2c2a;
    --axis: #383835;
    --border: rgba(255, 255, 255, 0.10);
    --series: #3987e5;
    --track: #1c3554;
    --good: #0ca30c;
    --good-text: #3fc23f;
    --bad-text: #ef7a7a;
    --warn-bg: #3a2d0a;
    --warn-ink: #f5d38a;
    --accent-bg: #172536;
    --shadow: none;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #0d0d0d;
  --surface: #1a1a19;
  --ink: #ffffff;
  --ink-2: #c3c2b7;
  --muted: #9a988f;
  --grid: #2c2c2a;
  --axis: #383835;
  --border: rgba(255, 255, 255, 0.10);
  --series: #3987e5;
  --track: #1c3554;
  --good: #0ca30c;
  --good-text: #3fc23f;
  --bad-text: #ef7a7a;
  --warn-bg: #3a2d0a;
  --warn-ink: #f5d38a;
  --accent-bg: #172536;
  --shadow: none;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--page);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.45;
  -webkit-text-size-adjust: 100%;
  padding-bottom: env(safe-area-inset-bottom);
}
button { font: inherit; color: inherit; }

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

/* ---------- header ---------- */
.top {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: calc(14px + env(safe-area-inset-top)) 0 10px;
}
.brand { font-weight: 650; font-size: 18px; letter-spacing: -0.01em; }
.sync { font-size: 13px; color: var(--ink-2); text-align: right; }
.sync button {
  border: 0; background: none; padding: 0; margin-left: 8px; color: var(--muted);
  text-decoration: underline; cursor: pointer; font-size: 13px;
}

.tabs {
  position: sticky; top: 0; z-index: 5;
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px;
  padding: 4px; margin: 0 -4px 16px;
  background: color-mix(in srgb, var(--page) 88%, transparent);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
}
.tabs a {
  text-align: center; padding: 9px 4px; border-radius: 10px;
  color: var(--ink-2); text-decoration: none; font-size: 14px; font-weight: 550;
}
.tabs a[aria-current="page"] { background: var(--surface); color: var(--ink); box-shadow: inset 0 0 0 1px var(--border); }

.banner {
  background: var(--warn-bg); color: var(--warn-ink);
  border-radius: 12px; padding: 10px 14px; margin-bottom: 14px; font-size: 14px;
}

h2 { font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; color: var(--ink-2); margin: 22px 0 10px; }
h2:first-child { margin-top: 4px; }
.sub { color: var(--ink-2); font-size: 14px; margin: -4px 0 12px; }

.card {
  background: var(--surface); border-radius: var(--radius);
  box-shadow: inset 0 0 0 1px var(--border), var(--shadow);
  padding: 14px 16px;
}
.card + .card { margin-top: 12px; }
.tiles > .card, .stats > .card { margin-top: 0; }

/* ---------- tiles ---------- */
.tiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
@media (min-width: 620px) { .tiles { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.tile { padding: 12px 14px 14px; }
.tile .lbl { font-size: 13px; color: var(--ink-2); }
.tile .val { font-size: 26px; font-weight: 650; letter-spacing: -0.02em; margin-top: 2px; line-height: 1.15; }
.tile .val small { font-size: 14px; font-weight: 500; color: var(--ink-2); letter-spacing: 0; }
.tile .note { font-size: 12.5px; color: var(--ink-2); margin-top: 6px; }
.meter { height: 6px; border-radius: 3px; background: var(--track); margin-top: 10px; overflow: hidden; }
.meter > i { display: block; height: 100%; border-radius: 3px; background: var(--series); }
.meter.done > i { background: var(--good); }

.status { font-size: 12.5px; font-weight: 600; white-space: nowrap; }
.status.ok { color: var(--good-text); }
.status.no { color: var(--bad-text); }
.status.wip { color: var(--ink-2); font-weight: 500; }

.hero-row { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.chip {
  display: inline-block; font-size: 12.5px; font-weight: 600; color: var(--series);
  background: var(--accent-bg); border-radius: 999px; padding: 3px 10px;
}

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 0; border-radius: 10px; padding: 11px 16px; cursor: pointer;
  background: var(--series); color: #fff; font-weight: 600; font-size: 15px;
}
.btn.ghost { background: transparent; color: var(--ink); box-shadow: inset 0 0 0 1px var(--border); }
.btn[disabled] { opacity: 0.55; cursor: default; }
.row-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 12px; }

.focus { margin: 8px 0 0; padding-left: 18px; color: var(--ink-2); font-size: 14px; }
.focus li + li { margin-top: 3px; }

/* ---------- table ---------- */
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 9px 6px; text-align: left; border-bottom: 1px solid var(--grid); vertical-align: middle; }
th { font-weight: 550; color: var(--ink-2); font-size: 12.5px; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
.delta { font-size: 12px; color: var(--ink-2); }

.weeknav { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.weeknav b { font-weight: 600; }
.weeknav button {
  border: 0; background: var(--surface); box-shadow: inset 0 0 0 1px var(--border);
  width: 38px; height: 38px; border-radius: 10px; cursor: pointer; font-size: 18px; color: var(--ink);
}
.weeknav button[disabled] { opacity: 0.35; cursor: default; }

/* ---------- plan ---------- */
.week { position: relative; }
.week.current { box-shadow: inset 0 0 0 2px var(--series), var(--shadow); }
.week.future { opacity: 0.78; }
.week .head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.week .head b { font-size: 16px; }
.week .dates { font-size: 13px; color: var(--ink-2); }
.targets { margin-top: 10px; }
.targets td:first-child { width: 40%; }

/* ---------- charts ---------- */
.chart { position: relative; width: 100%; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart text { fill: var(--muted); font-size: 11px; font-family: inherit; }
.chart .tick-today { fill: var(--ink); font-weight: 650; }
.chart .grid { stroke: var(--grid); stroke-width: 1; }
.chart .base { stroke: var(--axis); stroke-width: 1; }
.chart .target { stroke: var(--ink-2); stroke-width: 1; }
.chart .target-lbl { fill: var(--ink-2); font-size: 11px; }
.chart .bar { fill: var(--series); }
.chart .bar.dim { opacity: 0.35; }
.chart .line { fill: none; stroke: var(--series); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .dot { fill: var(--series); stroke: var(--surface); stroke-width: 2; }
.chart .hit { fill: transparent; cursor: pointer; }
.chart .cross { stroke: var(--axis); stroke-width: 1; }
.chart-title { font-weight: 600; font-size: 15px; }
.chart-sub { font-size: 13px; color: var(--ink-2); margin: 2px 0 8px; }
.empty { color: var(--ink-2); font-size: 14px; padding: 18px 0; text-align: center; }

.tip {
  position: fixed; z-index: 20; pointer-events: none;
  background: var(--ink); color: var(--page);
  font-size: 13px; line-height: 1.35; padding: 7px 10px; border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.18); max-width: 220px;
}
.tip b { font-weight: 650; }

.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin-bottom: 12px; }
.stats .card { padding: 10px 12px; }
.stats .lbl { font-size: 12.5px; color: var(--ink-2); }
.stats .v { font-size: 20px; font-weight: 650; }

/* ---------- login ---------- */
.login { max-width: 360px; margin: 18vh auto 0; padding: 0 16px; }
.login h1 { font-size: 22px; margin: 0 0 6px; }
.login p { color: var(--ink-2); margin: 0 0 18px; }
.login input {
  width: 100%; font: inherit; font-size: 16px; padding: 12px 14px; border-radius: 10px;
  border: 0; box-shadow: inset 0 0 0 1px var(--border); background: var(--surface); color: var(--ink);
  margin-bottom: 10px;
}
.login .btn { width: 100%; }
.err { color: var(--bad-text); font-size: 14px; min-height: 20px; margin-top: 8px; }

.foot { margin-top: 28px; font-size: 12.5px; color: var(--muted); text-align: center; }

.legend { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--ink-2); margin: 0 0 6px; }
.legend .key-line { display: inline-block; width: 16px; height: 0; border-top: 1px solid var(--ink-2); }
.legend .key-bar { display: inline-block; width: 8px; height: 10px; border-radius: 2px 2px 0 0; background: var(--series); }
