/* Solar Sponge. Chart tokens from the dataviz reference palette; a warm sun accent for primary actions and the start screen.
   Light by default, dark via OS setting or html[data-theme]. */
:root {
  color-scheme: light;
  --page: #f9f9f7; --surface: #fcfcfb; --border: rgba(11,11,11,0.10);
  --ink: #0b0b0b; --ink-2: #52514e; --muted: #6f6d66; --grid: #e1e0d9; --axis: #c3c2b7;
  --accent: #a85a00; --accent-ink: #ffffff; --accent-tint: #fbf1e3; --accent-line: #e8c48f;
  --import: #2a78d6; --import-soft: #86b6ef; --export: #eb6834; --export-soft: #f5b08f;
  --s3: #1baf7a; --s4: #eda100; --good: #006300; --bad: #b32b2b; --good-tint: #e6f3e6; --bad-tint: #fbe9e9;
  --cat1: #2a78d6; --cat2: #eb6834; --cat3: #1baf7a; --cat4: #eda100; --cat5: #e87ba4; --cat6: #008300; --cat7: #4a3aa7; --cat8: #e34948;
}
@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --page: #0d0d0d; --surface: #1a1a19; --border: rgba(255,255,255,0.10);
    --ink: #ffffff; --ink-2: #c3c2b7; --muted: #9c9a93; --grid: #2c2c2a; --axis: #383835;
    --accent: #f0a33a; --accent-ink: #1a1200; --accent-tint: #2a2114; --accent-line: #6b4a14;
    --import: #3987e5; --import-soft: #1c5cab; --export: #d95926; --export-soft: #8f3312;
    --s3: #199e70; --s4: #c98500; --good: #3fc43f; --bad: #f07676; --good-tint: #142614; --bad-tint: #2e1616;
    --cat1: #3987e5; --cat2: #d95926; --cat3: #199e70; --cat4: #c98500; --cat5: #d55181; --cat6: #008300; --cat7: #9085e9; --cat8: #e66767;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #0d0d0d; --surface: #1a1a19; --border: rgba(255,255,255,0.10);
  --ink: #ffffff; --ink-2: #c3c2b7; --muted: #9c9a93; --grid: #2c2c2a; --axis: #383835;
  --accent: #f0a33a; --accent-ink: #1a1200; --accent-tint: #2a2114; --accent-line: #6b4a14;
  --import: #3987e5; --import-soft: #1c5cab; --export: #d95926; --export-soft: #8f3312;
  --s3: #199e70; --s4: #c98500; --good: #3fc43f; --bad: #f07676; --good-tint: #142614; --bad-tint: #2e1616;
  --cat1: #3987e5; --cat2: #d95926; --cat3: #199e70; --cat4: #c98500; --cat5: #d55181; --cat6: #008300; --cat7: #9085e9; --cat8: #e66767;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--page); color: var(--ink); font: 14px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif; }
::selection { background: var(--accent-line); color: var(--ink); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
a { color: var(--accent); text-underline-offset: 3px; }

/* Header: brand, page name, nav. */
header { display: flex; flex-wrap: wrap; gap: 6px 14px; align-items: center; padding: 10px 16px; border-bottom: 1px solid var(--border); background: var(--surface); }
header .brand { font-weight: 700; font-size: 16px; color: var(--ink); text-decoration: none; letter-spacing: -0.01em; }
header .brand::before { content: ""; display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: var(--accent); margin-right: 8px; vertical-align: 0; }
header h1 { font-size: 20px; font-weight: 600; color: var(--ink); margin: 0; letter-spacing: -0.01em; }
header h1::before { content: "/"; color: var(--muted); margin-right: 10px; font-weight: 400; }
header nav { display: flex; flex-wrap: wrap; gap: 2px 4px; }
header nav a { color: var(--ink-2); text-decoration: none; padding: 6px 8px; border-radius: 6px; min-height: 32px; display: inline-flex; align-items: center; }
header nav a:hover { background: var(--page); color: var(--ink); }
header nav a[aria-current] { color: var(--ink); font-weight: 600; box-shadow: inset 0 -2px 0 var(--accent); border-radius: 0; }
header nav.off a { color: var(--muted); }
header .spacer { flex: 1; }
header button { font-size: 13px; }

main { padding: 16px; max-width: 1400px; margin: 0 auto; display: grid; gap: 16px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 16px 18px; }
.card h2 { font-size: 18px; margin: 0 0 8px; letter-spacing: -0.01em; }
.card .sub { color: var(--ink-2); font-size: 13px; margin: -4px 0 10px; }
p, li, .sub, summary { max-width: 72ch; }
.row { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.kpis { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; }
.kpi .label { color: var(--ink-2); font-size: 13px; }
.kpi .value { font-size: 26px; font-weight: 600; margin-top: 2px; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.kpi .unit { font-size: 13px; color: var(--ink-2); font-weight: 400; margin-left: 4px; }
.kpi .note { color: var(--muted); font-size: 12.5px; margin-top: 2px; }
.kpi.accent { background: var(--accent-tint); border-color: var(--accent-line); }
.chart { width: 100%; height: 340px; }
.chart.tall { height: 520px; }
.controls { display: flex; flex-wrap: wrap; gap: 8px 14px; align-items: center; margin-bottom: 10px; }
.controls label { color: var(--ink-2); font-size: 13px; display: inline-flex; align-items: center; gap: 6px; }
input, select, button { font: inherit; color: var(--ink); background: var(--page); border: 1px solid var(--axis); border-radius: 6px; padding: 5px 9px; min-height: 32px; }
input[type=number] { width: 90px; } input[type=time] { width: 132px; }
input[type=checkbox], input[type=radio] { min-height: 0; width: 16px; height: 16px; accent-color: var(--accent); }
button { cursor: pointer; } button:hover { border-color: var(--ink-2); } button:disabled { cursor: default; opacity: 0.6; }
.primary, button.primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; font-weight: 600; }
.primary:hover, button.primary:hover { filter: brightness(1.08); border-color: transparent; }
.big { font-size: 16px; padding: 12px 22px; border-radius: 8px; display: inline-block; cursor: pointer; }
details { border: 1px solid var(--border); border-radius: 8px; padding: 0 12px; background: var(--page); }
details + details { margin-top: 8px; }
summary { cursor: pointer; color: var(--ink-2); font-weight: 600; padding: 8px 0; list-style-position: inside; }
details[open] summary { border-bottom: 1px solid var(--border); margin-bottom: 8px; }
details .controls { margin-bottom: 4px; } details .controls:last-child { margin-bottom: 10px; }
table { border-collapse: collapse; width: 100%; font-variant-numeric: tabular-nums; }
th, td { text-align: right; padding: 5px 8px; border-bottom: 1px solid var(--grid); }
th:first-child, td:first-child { text-align: left; }
th { color: var(--ink-2); font-weight: 600; font-size: 12.5px; }
th button.sort { all: unset; cursor: pointer; color: inherit; font: inherit; } th button.sort:hover { color: var(--ink); } th button.sort:focus-visible { outline: 2px solid var(--accent); }
tr.pinned td { background: var(--accent-tint); font-weight: 600; }
td.ok { color: var(--good); } td.bad { color: var(--bad); }
.check { font-size: 12.5px; color: var(--muted); padding: 8px 16px; max-width: none; }
.check b.ok { color: var(--good); } .check b.bad { color: var(--bad); }
.placeholder { color: var(--muted); font-style: italic; }
.badge { display: inline-block; font-size: 11px; padding: 1px 6px; border-radius: 10px; border: 1px solid var(--axis); color: var(--ink-2); margin: 1px 3px 1px 0; white-space: nowrap; }

/* Splash (no data yet): a warm sunrise behind one card, banners and alerts. */
body.splash { background: radial-gradient(ellipse 80% 55% at 50% -10%, var(--accent-tint) 0%, var(--page) 70%); min-height: 100vh; }
body.splash main { min-height: calc(100vh - 56px); align-content: center; }
.sun { width: 56px; height: 56px; color: var(--accent); display: block; }
.sun .rays { transform-origin: 32px 32px; animation: sun-turn 14s linear infinite; }
@keyframes sun-turn { to { transform: rotate(360deg); } }
.start { background: var(--surface); border: 1px solid var(--accent-line); border-radius: 14px; padding: 28px 28px 24px; max-width: 760px; margin: 0 auto; width: 100%; box-shadow: 0 18px 50px -24px rgba(168, 90, 0, 0.35); animation: rise 500ms cubic-bezier(0.2, 0.8, 0.2, 1) both; }
.start .sun { margin-bottom: 14px; }
.start h1 { font-size: 30px; line-height: 1.12; letter-spacing: -0.025em; margin: 0 0 10px; text-wrap: balance; }
@keyframes rise { from { opacity: 0.6; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .start, .sun .rays { animation: none; } }
/* Frosted loader over the whole page. */
#overlay { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; background: color-mix(in srgb, var(--page) 55%, transparent); backdrop-filter: blur(6px) saturate(0.8); -webkit-backdrop-filter: blur(6px) saturate(0.8); opacity: 0; transition: opacity 200ms ease-out; }
#overlay.on { opacity: 1; }
#overlay .loader { background: var(--surface); border: 1px solid var(--accent-line); border-radius: 14px; padding: 24px 28px; min-width: 280px; text-align: center; box-shadow: 0 18px 50px -24px rgba(168, 90, 0, 0.45); }
#overlay .sun { margin: 0 auto 10px; } #overlay .sun .rays { animation-duration: 2.4s; }
#overlay .title { font-size: 16px; font-weight: 600; } #overlay .note { color: var(--ink-2); font-size: 13px; margin-top: 4px; font-variant-numeric: tabular-nums; }
.start .lead { font-size: 16px; color: var(--ink-2); margin: 0 0 20px; }
.start ol { padding-left: 0; margin: 0 0 18px; list-style: none; counter-reset: step; }
.start li { counter-increment: step; display: grid; grid-template-columns: 32px 1fr; gap: 12px; align-items: start; margin-bottom: 16px; font-size: 15px; }
.start li::before { content: counter(step); display: inline-flex; align-items: center; justify-content: center; width: 28px; height: 28px; border-radius: 50%; background: var(--accent); color: var(--accent-ink); font-weight: 700; }
.start li .big { margin-top: 8px; }
.start .portal { background: var(--page); border: 1px solid var(--accent); color: var(--accent); font-weight: 600; text-decoration: none; }
.start .portal:hover { background: var(--accent-tint); }
.start .callout { background: var(--accent-tint); border: 1px solid var(--accent-line); border-radius: 8px; padding: 10px 12px; margin: 0; color: var(--ink); font-size: 14px; }
.visually-hidden { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); border: 0; }
input.visually-hidden:focus-visible + label { outline: 2px solid var(--accent); outline-offset: 2px; }
.alert { border-radius: 8px; padding: 10px 12px; margin-top: 12px; border: 1px solid; font-size: 14px; max-width: none; }
.alert:empty { display: none; }
.alert.bad { background: var(--bad-tint); border-color: var(--bad); } .alert.good { background: var(--good-tint); border-color: var(--good); } .alert.info { background: var(--accent-tint); border-color: var(--accent-line); }
.banner { display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center; background: var(--accent-tint); border: 1px solid var(--accent-line); border-radius: 10px; padding: 10px 14px; }
.banner .spacer { flex: 1; } .banner button { min-height: 28px; padding: 3px 10px; }

@media (max-width: 700px) {
  main { padding: 12px; gap: 12px; }
  header { padding: 8px 12px; }
  header h1 { width: 100%; order: 3; } header h1::before { content: none; }
  header nav a, header button, .banner button { min-height: 40px; }
  .card { padding: 12px; }
  .start { padding: 20px 16px; } .start h1 { font-size: 24px; }
  .chart { height: 280px; } .chart.tall { height: 420px; }
  input[type=time] { width: 112px; }
}
