/* Welthy – mobile first, light and dark. No inline styles (CSP). */
:root {
  --bg: #f4f6f8;
  --surface: #ffffff;
  --text: #16202a;
  --muted: #5d6b78;
  --border: #dde3e9;
  --brand: #12324a;
  --accent: #1f7a5c;
  --accent-text: #ffffff;
  --ok-bg: #e5f4ec; --ok-text: #1b5e3f;
  --bad-bg: #fbe9e9; --bad-text: #8c1d1d;
  --warn-bg: #fff4dc; --warn-text: #7a5300;
  --radius: 12px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e151c;
    --surface: #17212b;
    --text: #e6edf3;
    --muted: #93a1ae;
    --border: #283542;
    --brand: #0b1f2e;
    --accent: #2f9e78;
    --ok-bg: #143326; --ok-text: #8fd8b4;
    --bad-bg: #3a1717; --bad-text: #f2a7a7;
    --warn-bg: #3a2c0d; --warn-text: #f0cf86;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
body > header {
  background: var(--brand);
  color: #fff;
  padding-top: env(safe-area-inset-top);
}
.bar {
  max-width: 960px;
  margin: 0 auto;
  padding: 10px 16px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 16px;
}
.brand { color: #fff; font-weight: 700; font-size: 1.2rem; text-decoration: none; margin-right: auto; }
nav { display: flex; gap: 4px; order: 3; width: 100%; overflow-x: auto; }
nav a {
  color: #cfdbe6; text-decoration: none; padding: 6px 10px; border-radius: 8px; white-space: nowrap;
}
nav a.active, nav a:hover { background: rgba(255, 255, 255, 0.14); color: #fff; }
body > header button.link { color: #cfdbe6; }
@media (min-width: 720px) {
  nav { order: 0; width: auto; }
}
main {
  flex: 1;
  width: 100%;
  max-width: 960px;
  margin: 0 auto;
  padding: 16px 16px calc(16px + env(safe-area-inset-bottom));
}
footer { text-align: center; color: var(--muted); font-size: 0.8rem; padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); }
h1 { font-size: 1.5rem; margin: 0 0 12px; }
h2 { font-size: 1.15rem; margin: 0 0 8px; }
a { color: var(--accent); }
code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.95em; }
.muted { color: var(--muted); }
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 16px;
}
.card.narrow { max-width: 440px; margin: 24px auto; }
.list .card { margin-bottom: 10px; }
.row-between { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.stack { display: flex; flex-direction: column; gap: 6px; margin: 8px 0; }
.stack button { margin-top: 10px; }
form.inline { display: inline; }
label { font-weight: 600; font-size: 0.92rem; }
input, select {
  font: inherit;
  font-size: 16px; /* no zoom on iOS */
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  width: 100%;
}
button, .button {
  font: inherit;
  font-weight: 600;
  padding: 10px 16px;
  border-radius: 8px;
  border: 0;
  background: var(--accent);
  color: var(--accent-text);
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
}
button.secondary, .button.secondary { background: transparent; color: var(--accent); border: 1px solid var(--accent); }
button.danger { background: transparent; color: var(--bad-text); border: 1px solid var(--bad-text); }
button.link { background: none; border: 0; padding: 4px; color: var(--accent); font-weight: 500; }
details { margin-top: 10px; }
details summary { cursor: pointer; color: var(--accent); }
details form { margin: 8px 8px 0 0; }
.flash { padding: 10px 14px; border-radius: 8px; margin-bottom: 14px; }
.flash.ok { background: var(--ok-bg); color: var(--ok-text); }
.flash.bad { background: var(--bad-bg); color: var(--bad-text); }
.flash.warn { background: var(--warn-bg); color: var(--warn-text); }
.pill { display: inline-block; font-size: 0.78rem; padding: 2px 8px; border-radius: 999px; background: var(--bg); border: 1px solid var(--border); margin: 4px 4px 0 0; }
.pill.ok { background: var(--ok-bg); color: var(--ok-text); border-color: transparent; }
.pill.bad { background: var(--bad-bg); color: var(--bad-text); border-color: transparent; }
.pill.warn { background: var(--warn-bg); color: var(--warn-text); border-color: transparent; }
.hero { padding: 8px 0 16px; }
.hero .label { margin: 0; color: var(--muted); font-size: 0.95rem; }
.hero .total { margin: 0; font-size: 2.4rem; font-weight: 700; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.qr { display: flex; justify-content: center; margin: 12px 0; }
.qr svg { width: 220px; height: 220px; background: #fff; border-radius: 8px; }
.secret { text-align: center; word-break: break-all; user-select: all; -webkit-user-select: all; }
.steps { padding-left: 20px; }
.qr-actions { text-align: center; margin: 0 0 12px; }

/* --- phase 2: overview, lists, charts ------------------------------------------- */
:root { --chart-line: #1f7a5c; --chart-wash: rgba(31, 122, 92, 0.10); --up: #1b7a4b; --down: #b42318; }
@media (prefers-color-scheme: dark) {
  :root { --chart-line: #3ccf9b; --chart-wash: rgba(60, 207, 155, 0.12); --up: #6fd6a2; --down: #f28b82; }
}
.small { font-size: 0.85rem; }
.right { text-align: right; }
.crumbs { margin: 0 0 6px; font-size: 0.9rem; color: var(--muted); }
.total-sm { font-size: 1.7rem; font-weight: 700; margin: 0 0 8px; font-variant-numeric: tabular-nums; }
.amount { font-variant-numeric: tabular-nums; font-weight: 600; white-space: nowrap; }
.changes { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 12px; }
.change { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 8px 10px; display: flex; flex-direction: column; font-variant-numeric: tabular-nums; }
.change strong { font-size: 0.95rem; }
.change.up strong, .change.up .small { color: var(--up); }
.change.down strong, .change.down .small { color: var(--down); }
.up { color: var(--up); }
.down { color: var(--down); }
@media (max-width: 420px) { .change strong { font-size: 0.85rem; } }
.attention { border-color: var(--warn-text); }
ul.plain { list-style: none; padding: 0; margin: 0; }
ul.plain li { padding: 6px 0; border-bottom: 1px solid var(--border); }
ul.plain li:last-child { border-bottom: 0; }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 6px; vertical-align: middle; }
.dot.stale { background: #e0a100; }
.dot.missing { background: #d93025; }
.dot.ok { background: #1b7a4b; }
ul.shares { list-style: none; padding: 0; margin: 0; }
ul.shares li { margin: 0 0 10px; }
.meter { height: 6px; background: var(--bg); border-radius: 3px; overflow: hidden; margin: 4px 0 2px; }
.meter span { display: block; height: 100%; background: var(--accent); border-radius: 3px; }
.w-0 { width: 0; } .w-5 { width: 5%; } .w-10 { width: 10%; } .w-15 { width: 15%; } .w-20 { width: 20%; }
.w-25 { width: 25%; } .w-30 { width: 30%; } .w-35 { width: 35%; } .w-40 { width: 40%; } .w-45 { width: 45%; }
.w-50 { width: 50%; } .w-55 { width: 55%; } .w-60 { width: 60%; } .w-65 { width: 65%; } .w-70 { width: 70%; }
.w-75 { width: 75%; } .w-80 { width: 80%; } .w-85 { width: 85%; } .w-90 { width: 90%; } .w-95 { width: 95%; } .w-100 { width: 100%; }
.grid2 { display: grid; gap: 0 16px; }
@media (min-width: 720px) { .grid2 { grid-template-columns: 1fr 1fr; } }
nav.seg { display: flex; gap: 2px; background: var(--bg); border-radius: 8px; padding: 2px; }
nav.seg a { padding: 4px 8px; border-radius: 6px; text-decoration: none; color: var(--muted); font-size: 0.85rem; }
nav.seg a.active { background: var(--surface); color: var(--text); font-weight: 600; }
a.linkcard { display: block; color: inherit; text-decoration: none; }
a.linkcard:hover { border-color: var(--accent); }
dl.facts { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; margin: 0; }
dl.facts dt { color: var(--muted); }
dl.facts dd { margin: 0; font-variant-numeric: tabular-nums; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
th, td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--border); white-space: nowrap; }
th { color: var(--muted); font-weight: 600; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td.wrap, th.wrap { white-space: normal; }
.card.narrow-wide { max-width: 560px; margin: 0 auto 16px; }
fieldset.radio { border: 0; padding: 0; margin: 6px 0; display: flex; flex-direction: column; gap: 6px; }
fieldset.radio legend { font-weight: 600; font-size: 0.92rem; margin-bottom: 4px; }
label.check { font-weight: 400; display: flex; gap: 8px; align-items: flex-start; }
label.check input { width: auto; margin-top: 4px; }
svg.chart { display: block; width: 100%; height: auto; }
svg.chart .gridline { stroke: var(--border); stroke-width: 1; }
svg.chart .tick { fill: var(--muted); font-size: 28px; font-variant-numeric: tabular-nums; }
svg.chart .line { fill: none; stroke: var(--chart-line); stroke-width: 3; stroke-linejoin: round; stroke-linecap: round; }
svg.chart .area { fill: var(--chart-wash); stroke: none; }
svg.chart .end-dot { fill: var(--chart-line); }
svg.chart .hit { fill: transparent; }
svg.chart .hit:hover { fill: rgba(127, 127, 127, 0.08); }
@media (min-width: 720px) { svg.chart .tick { font-size: 16px; } }
.card.demo { border-style: dashed; }
.halt-all { width: 100%; font-weight: 700; }
.state-list { display: grid; grid-template-columns: auto 1fr; gap: 2px 12px; margin: 8px 0; font-size: 0.9rem; }
.state-list dt { color: var(--muted); }
.state-list dd { margin: 0; }
.state-list .ok { color: var(--ok-text); } .state-list .warn { color: var(--warn-text); } .state-list .bad { color: var(--bad-text); }
.cmd-list { list-style: none; padding: 0; margin: 6px 0 0; font-size: 0.85rem; }
.cmd-list li { padding: 4px 0; border-top: 1px solid var(--border); }
