/* Produz — palette values from the validated reference instance.
   Condition colours are a STATUS palette: always paired with a glyph and the
   condition's name, never carrying meaning on their own. */

:root {
  color-scheme: light;
  --surface: #fcfcfb;
  --plane: #f4f4f1;
  --ink: #0b0b0b;
  --ink-2: #52514e;
  --muted: #898781;
  --grid: #e1e0d9;
  --axis: #c3c2b7;
  --border: rgba(11, 11, 11, 0.10);
  --accent: #2a78d6;
  --good: #006300;

  --cond-NonExistence: #898781;
  --cond-Danger: #d03b3b;
  --cond-Emergency: #ec835a;
  --cond-Normal: #0ca30c;
  --cond-Affluence: #2a78d6;
  --cond-PowerChange: #4a3aa7;
  --cond-Power: #184f95;

  --radius: 10px;
  --font: system-ui, -apple-system, "Segoe UI", sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --surface: #1a1a19;
    --plane: #0d0d0d;
    --ink: #ffffff;
    --ink-2: #c3c2b7;
    --muted: #898781;
    --grid: #2c2c2a;
    --axis: #383835;
    --border: rgba(255, 255, 255, 0.10);
    --accent: #3987e5;
    --good: #0ca30c;
    --cond-Danger: #e66767;
    --cond-Affluence: #3987e5;
    --cond-PowerChange: #9085e9;
    --cond-Power: #86b6ef;
  }
}

/* Explicit choice wins over the OS setting, both ways. */
:root[data-theme="dark"] {
  color-scheme: dark;
  --surface: #1a1a19;
  --plane: #0d0d0d;
  --ink: #ffffff;
  --ink-2: #c3c2b7;
  --muted: #898781;
  --grid: #2c2c2a;
  --axis: #383835;
  --border: rgba(255, 255, 255, 0.10);
  --accent: #3987e5;
  --good: #0ca30c;
  --cond-Danger: #e66767;
  --cond-Affluence: #3987e5;
  --cond-PowerChange: #9085e9;
  --cond-Power: #86b6ef;
}


* { box-sizing: border-box; }

body {
  margin: 0;
  font: 15px/1.5 var(--font);
  background: var(--plane);
  color: var(--ink);
  -webkit-text-size-adjust: 100%;
}

h1, h2, h3 { line-height: 1.25; margin: 0; font-weight: 650; }
h1 { font-size: 1.15rem; }
h2 { font-size: 1.02rem; }
h3 { font-size: 0.9rem; }
p { margin: 0 0 0.6rem; }
a { color: var(--accent); }

/* --- shell --------------------------------------------------------------- */

header.top {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 12px;
  padding: 10px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
header.top .brand { font-weight: 700; letter-spacing: -0.01em; }
header.top .brand span { color: var(--muted); font-weight: 500; }
header.top .spacer { flex: 1; }

nav.tabs {
  display: flex; gap: 2px; overflow-x: auto;
  padding: 0 10px; background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 45px; z-index: 19;
}
nav.tabs a {
  padding: 9px 12px; font-size: 0.86rem; color: var(--ink-2);
  text-decoration: none; white-space: nowrap;
  border-bottom: 2px solid transparent;
}
nav.tabs a.on { color: var(--ink); border-bottom-color: var(--accent); font-weight: 600; }

main { max-width: 1080px; margin: 0 auto; padding: 18px 16px 64px; }

/* The language toggle sits in the header, so it is reachable from the intro
   screen too — buried in Settings it is invisible to someone who has not yet
   decided to sign up. */
header.top .grain button { padding: 4px 9px; font-size: 0.76rem; }

/* A rule with the word sitting in the gap. Hidden until the Google button
   actually renders — an "or" above nothing reads as a broken page. */
.or {
  display: flex; align-items: center; gap: 10px;
  color: var(--muted); font-size: 0.78rem; margin-bottom: 14px;
}
.or::before, .or::after { content: ""; flex: 1; height: 1px; background: var(--border); }

/* --- intro --------------------------------------------------------------- */

body.welcome nav.tabs,
body.welcome #quick-entry { display: none; }

.welcome { max-width: 520px; margin: 0 auto; }
.w-title { font-size: 2rem; letter-spacing: -0.02em; text-align: center; margin: 10px 0 4px; }
.w-lead { text-align: center; color: var(--ink-2); margin-bottom: 24px; }
.w-steps { list-style: none; counter-reset: s; margin: 0 0 22px; padding: 0; }
.w-steps li {
  counter-increment: s; display: grid;
  grid-template-columns: 26px 1fr; gap: 2px 12px; margin-bottom: 15px;
}
.w-steps li::before {
  content: counter(s); grid-row: span 2;
  width: 26px; height: 26px; border-radius: 50%;
  display: grid; place-items: center;
  background: color-mix(in oklab, var(--accent) 14%, transparent);
  color: var(--accent); font-size: 0.78rem; font-weight: 700;
}
.w-steps b { font-size: 0.95rem; }
.w-steps span { color: var(--ink-2); font-size: 0.86rem; }

/* --- cards --------------------------------------------------------------- */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 14px;
}
.card > h2, .card > h3 { margin-bottom: 8px; }
.sub { color: var(--ink-2); font-size: 0.86rem; }
.muted { color: var(--muted); }
.tiny { font-size: 0.78rem; }

.row { display: flex; align-items: center; gap: 10px; }
.row.wrap { flex-wrap: wrap; }
.spread { justify-content: space-between; }

/* --- condition badge ----------------------------------------------------- */

.badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 9px 3px 7px; border-radius: 999px;
  font-size: 0.8rem; font-weight: 600; white-space: nowrap;
  border: 1px solid currentColor;
}
.badge .g { font-size: 0.72em; letter-spacing: -0.06em; }
.badge.lg { font-size: 0.92rem; padding: 5px 13px 5px 10px; }

/* --- stat list ----------------------------------------------------------- */

.stat-row {
  display: grid;
  grid-template-columns: 1fr auto 130px auto;
  align-items: center; gap: 14px;
  padding: 12px 4px;
  border-bottom: 1px solid var(--border);
  text-decoration: none; color: inherit;
}
.stat-row:last-child { border-bottom: 0; }
.stat-row:hover { background: color-mix(in oklab, var(--accent) 5%, transparent); }
.stat-name { font-weight: 600; }
.stat-figs { text-align: right; font-variant-numeric: tabular-nums; }
.stat-figs b { font-size: 1.05rem; }

@media (max-width: 620px) {
  .stat-row { grid-template-columns: 1fr auto; row-gap: 6px; }
  .stat-row .spark-cell { grid-column: 1 / -1; }
}

/* --- chart --------------------------------------------------------------- */

.chart { position: relative; }
.chart-svg { width: 100%; height: auto; display: block; touch-action: pan-y; }
.chart-empty { color: var(--muted); font-size: 0.86rem; padding: 26px 0; text-align: center; }
.grid { stroke: var(--grid); stroke-width: 1; }
.axis-label { fill: var(--muted); font-size: 11px; font-family: var(--font); font-variant-numeric: tabular-nums; }
.series { stroke: var(--ink-2); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.trendline { stroke: var(--accent); stroke-width: 2; stroke-dasharray: 6 4; opacity: 0.85; }
.quota { stroke: var(--muted); stroke-width: 1.5; stroke-dasharray: 2 5; }
.quota-label { fill: var(--muted); font-size: 10px; font-family: var(--font); }
.trendline.seg { stroke-width: 9; stroke-dasharray: none; opacity: 0.3; stroke-linecap: round; }
.trend-label { fill: var(--accent); font-size: 11px; font-family: var(--font); font-weight: 600; }
.dot { fill: var(--ink-2); }
.dot-current { fill: var(--ink); stroke: var(--surface); stroke-width: 2; }
.crosshair { stroke: var(--axis); stroke-width: 1; }
.hover-dot { fill: none; stroke: var(--ink); stroke-width: 2; }
.chart-tip {
  position: absolute; transform: translate(-50%, -100%);
  background: var(--ink); color: var(--surface);
  padding: 4px 8px; border-radius: 6px; font-size: 0.78rem;
  pointer-events: none; white-space: nowrap; font-variant-numeric: tabular-nums;
}
.chart-tip .tip-key { opacity: 0.7; margin-left: 6px; }
.spark { width: 120px; height: 30px; display: block; }
.spark-line { stroke: var(--ink-2); stroke-width: 1.75; }
.spark-dot { fill: var(--ink-2); }

.grain { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.grain button {
  border: 0; background: transparent; color: var(--ink-2);
  padding: 5px 11px; font: inherit; font-size: 0.82rem; cursor: pointer;
}
.grain button.on { background: var(--accent); color: #fff; font-weight: 600; }

/* --- forms & buttons ----------------------------------------------------- */

input, select, textarea, button { font: inherit; }
input[type="number"], input[type="text"], input[type="date"], select, textarea {
  width: 100%; padding: 8px 10px;
  background: var(--plane); color: var(--ink);
  border: 1px solid var(--border); border-radius: 8px;
}
input[type="number"] { font-variant-numeric: tabular-nums; }
label.field { display: block; margin-bottom: 10px; }
label.field > span { display: block; font-size: 0.8rem; color: var(--ink-2); margin-bottom: 3px; }

button.btn {
  padding: 8px 14px; border-radius: 8px; cursor: pointer;
  border: 1px solid var(--border); background: var(--surface); color: var(--ink);
  font-weight: 550;
}
button.btn:hover { border-color: var(--axis); }
button.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.btn.sm { padding: 5px 10px; font-size: 0.83rem; }
button.btn.link { border: 0; background: none; color: var(--accent); padding: 4px; }

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 560px) { .grid2 { grid-template-columns: 1fr; } }

/* --- entry sheet --------------------------------------------------------- */

.entry-row {
  display: grid; grid-template-columns: 1fr 120px; gap: 12px;
  align-items: center; padding: 9px 0; border-bottom: 1px solid var(--border);
}
.entry-row:last-of-type { border-bottom: 0; }
.entry-row .unit { color: var(--muted); font-size: 0.8rem; }

/* --- formula checklist --------------------------------------------------- */

ol.steps { list-style: none; margin: 0; padding: 0; counter-reset: s; }
ol.steps li {
  display: grid; grid-template-columns: 26px 1fr; gap: 10px;
  padding: 10px 0; border-bottom: 1px solid var(--border);
}
ol.steps li:last-child { border-bottom: 0; }
ol.steps li.done .step-text { color: var(--muted); text-decoration: line-through; }
ol.steps input[type="checkbox"] { width: 18px; height: 18px; margin-top: 2px; accent-color: var(--accent); }
.step-text { font-size: 0.93rem; }
.step-when { font-size: 0.74rem; color: var(--muted); }

/* --- explanation --------------------------------------------------------- */

.explain {
  background: var(--plane); border-left: 3px solid var(--axis);
  padding: 9px 12px; border-radius: 0 8px 8px 0;
  font-size: 0.88rem; color: var(--ink-2);
}
.metrics { display: flex; gap: 16px; flex-wrap: wrap; font-size: 0.78rem; color: var(--muted); margin-top: 8px; }
.metrics b { color: var(--ink-2); font-variant-numeric: tabular-nums; }

.banner {
  background: color-mix(in oklab, var(--accent) 10%, var(--surface));
  border: 1px solid color-mix(in oklab, var(--accent) 35%, transparent);
}

.empty { text-align: center; padding: 34px 16px; color: var(--muted); }

table.wow { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
table.wow th, table.wow td { text-align: right; padding: 6px 8px; border-bottom: 1px solid var(--border); font-size: 0.86rem; }
table.wow th:first-child, table.wow td:first-child { text-align: left; }
table.wow th { color: var(--muted); font-weight: 600; font-size: 0.76rem; text-transform: uppercase; letter-spacing: 0.04em; }
.delta-up { color: var(--good); }
.delta-down { color: var(--cond-Danger); }

.toast {
  position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%);
  background: var(--ink); color: var(--surface);
  padding: 9px 16px; border-radius: 999px; font-size: 0.86rem; z-index: 60;
}
