/* governance-server dashboard. Same visual language as the architecture
   document (docs/architecture.html): paper ground, ink text, copper for
   coinbase / blocks, teal for upstream and links. Bricolage Grotesque for
   headings, IBM Plex Sans for text, IBM Plex Mono for data. */
:root {
  --bg: #f4f5f1; --card: #ffffff; --fg: #17201c; --muted: #5a6761; --line: #d6dcd6;
  --accent: #a94f17; --accent-soft: #f3e3d6;
  --teal: #1d6a61; --teal-soft: #dcece8;
  --ok: #2f7a3e; --warn: #9a6a00; --warn-soft: #f6ecd2; --bad: #b3261e; --code: #eceee9;
  --m1: #6b3fa0; --m2: #1d6a61; --m3: #9a6a00; --m4: #7d5a12; --m7: #2f7a3e;
  --f-display: "Bricolage Grotesque", "Segoe UI", system-ui, sans-serif;
  --f-body: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --f-mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, monospace;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #121815; --card: #19211d; --fg: #e5ebe7; --muted: #9aa8a1; --line: #2e3a34;
    --accent: #e3925a; --accent-soft: #3a2619; --teal: #6cc3b6; --teal-soft: #17302c;
    --ok: #7ccf8a; --warn: #e2b64b; --warn-soft: #34290f; --bad: #f2786d; --code: #1f2823;
    --m1: #b99cf0; --m2: #6cc3b6; --m3: #e2b64b; --m4: #d9a441; --m7: #7ccf8a;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #121815; --card: #19211d; --fg: #e5ebe7; --muted: #9aa8a1; --line: #2e3a34;
  --accent: #e3925a; --accent-soft: #3a2619; --teal: #6cc3b6; --teal-soft: #17302c;
  --ok: #7ccf8a; --warn: #e2b64b; --warn-soft: #34290f; --bad: #f2786d; --code: #1f2823;
  --m1: #b99cf0; --m2: #6cc3b6; --m3: #e2b64b; --m4: #d9a441; --m7: #7ccf8a;
  color-scheme: dark;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--fg);
  font: 15px/1.55 var(--f-body); }
a { color: var(--teal); text-decoration: none; }
a:hover { text-decoration: underline; }
a:focus-visible, button:focus-visible, input:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
code, .mono, td.mono { font-family: var(--f-mono); font-size: 0.86em; }
h1, h2, h3 { font-family: var(--f-display); text-wrap: balance; line-height: 1.15; }
h1 { font-size: clamp(1.7rem, 3.5vw, 2.2rem); font-weight: 750; letter-spacing: -0.02em; margin: 8px 0 14px; }
h2 { font-size: 1.3rem; font-weight: 750; letter-spacing: -0.01em; margin: 30px 0 10px; }

/* Header */
header.top { display: flex; flex-wrap: wrap; gap: 8px 22px; align-items: center;
  padding: 12px max(16px, env(safe-area-inset-right, 0px)) 12px max(16px, env(safe-area-inset-left, 0px));
  border-bottom: 1px solid var(--line); background: var(--bg); position: sticky; top: 0; z-index: 2; }
.brand { font-family: var(--f-display); font-weight: 750; font-size: 1.15rem; letter-spacing: -0.01em; color: var(--fg); }
.brand:hover { text-decoration: none; }
.top nav { display: flex; gap: 2px; flex-wrap: wrap; }
.top nav a { padding: 4px 10px; border-radius: 6px; color: var(--muted); font-size: 0.93rem; }
.top nav a:hover { color: var(--fg); text-decoration: none; }
.top nav a.on { background: var(--accent-soft); color: var(--accent); }
.tools { margin-left: auto; display: flex; gap: 12px; align-items: center; color: var(--muted); font-size: 0.88rem; }
.tools .json { font-family: var(--f-mono); font-size: 0.8rem; padding: 2px 8px; border: 1px solid var(--line);
  border-radius: 999px; background: var(--card); }
.tools button { background: var(--card); border: 1px solid var(--line); color: var(--fg); border-radius: 6px;
  padding: 2px 8px; cursor: pointer; }
main { padding: 20px max(16px, env(safe-area-inset-right, 0px)) 40px max(16px, env(safe-area-inset-left, 0px));
  max-width: 1400px; margin: 0 auto; }
footer { padding: 18px 16px 28px; color: var(--muted); font-size: 0.8rem; text-align: center;
  border-top: 1px solid var(--line); }
footer p { margin: 4px 0; }

/* Cards and key/value */
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 14px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; min-width: 0; }
.card .k { font-family: var(--f-mono); font-size: 0.7rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--accent); }
.card .v { font-family: var(--f-display); font-size: 1.35rem; font-weight: 750; margin-top: 4px; }
.card .v .mono, .card .v.mono { font-family: var(--f-mono); font-size: 1rem; font-weight: 500; }
.card .s { color: var(--muted); font-size: 0.82rem; margin-top: 3px; overflow-wrap: anywhere; }
dl.kv { display: grid; grid-template-columns: max-content 1fr; gap: 5px 18px; margin: 0; }
dl.kv dt { color: var(--muted); }
dl.kv dd { margin: 0; overflow-wrap: anywhere; }

/* Tables */
.tablewrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 10px; background: var(--card); }
table { border-collapse: collapse; width: 100%; font-size: 0.88rem; }
th, td { text-align: left; padding: 8px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-family: var(--f-mono); font-size: 0.68rem; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--muted); font-weight: 500; background: var(--code); white-space: nowrap; }
th.sortable { cursor: pointer; user-select: none; }
th.sortable::after { content: " ↕"; opacity: .4; }
tr:last-child td { border-bottom: none; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
td.num { font-family: var(--f-mono); font-size: 0.84rem; }

/* State and coinbase message colours */
.ok { color: var(--ok); } .warn { color: var(--warn); } .bad { color: var(--bad); } .muted { color: var(--muted); }
.pill { display: inline-block; padding: 1px 8px; border-radius: 5px; font-family: var(--f-mono); font-size: 0.72rem;
  background: var(--code); white-space: nowrap; }
.k-m1 { color: var(--m1); } .k-m2 { color: var(--m2); } .k-m3 { color: var(--m3); }
.k-m4 { color: var(--m4); } .k-m7 { color: var(--m7); } .k-payout { color: var(--fg); }
.k-witness, .k-other { color: var(--muted); } .k-op_return { color: var(--bad); } .k-treasury { color: var(--warn); }
.pill.k-m1, .pill.k-m2, .pill.k-m3, .pill.k-m4, .pill.k-m7 { background: var(--accent-soft); }
.hex { font-family: var(--f-mono); font-size: 0.75rem; color: var(--muted); overflow-wrap: anywhere; word-break: break-all; }
.bar { height: 6px; background: var(--code); border-radius: 3px; overflow: hidden; min-width: 80px; }
.bar > span { display: block; height: 100%; background: var(--accent); }
.diff-add { color: var(--ok); } .diff-del { color: var(--bad); }
.banner { padding: 12px 16px; border-radius: 10px; color: var(--warn); background: var(--warn-soft);
  font-weight: 500; margin-bottom: 14px; }

/* Forms and paging */
.pager { display: flex; gap: 14px; align-items: center; margin: 12px 0; }
form.inline { display: flex; gap: 8px; align-items: center; margin: 0 0 12px; flex-wrap: wrap; }
form.inline input { background: var(--card); color: var(--fg); border: 1px solid var(--line);
  border-radius: 6px; padding: 5px 9px; width: 130px; font: inherit; }
form.inline button { background: var(--accent-soft); color: var(--accent); border: 1px solid transparent;
  border-radius: 6px; padding: 5px 12px; cursor: pointer; font: inherit; font-weight: 500; }

/* In-page section links (catalog, architecture) */
nav.toc { display: flex; flex-wrap: wrap; gap: 6px 16px; margin: 6px 0 4px; font-size: 0.9rem; }
nav.toc a { color: var(--muted); }
nav.toc a:hover { color: var(--fg); }

/* API catalog */
section.api { display: flex; flex-direction: column; gap: 12px; }
section.api > h2 { margin-bottom: 0; }
section.api > p { margin: 0; max-width: 80ch; }
.endpoint { display: flex; flex-direction: column; gap: 10px; }
.endpoint p { margin: 0; max-width: 90ch; }
.endpoint .sig { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.endpoint .verb { background: var(--teal-soft); color: var(--teal); }
.endpoint .path { font-size: 1rem; font-weight: 500; }
.endpoint .try { margin-left: auto; font-size: 0.82rem; }
pre.example { margin: 0; padding: 12px 14px; background: var(--code); border-radius: 8px;
  overflow-x: auto; font-family: var(--f-mono); font-size: 0.8rem; line-height: 1.5; }

@media (max-width: 640px) { .tools .refresh { display: none; } }
@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto !important; } }

/* ------------------------------------------------------------------
   Architecture document (/architecture), rendered inside the dashboard.
   Scoped to .doc so it cannot leak into the other pages. */
.doc { max-width: 880px; margin: 0 auto; display: flex; flex-direction: column; gap: 52px; font-size: 16px; line-height: 1.6; }
.doc p { margin: 0; max-width: 68ch; }
.doc h1 { font-size: clamp(2.1rem, 5vw, 3.1rem); margin: 0; }
.doc h2 { font-size: 1.6rem; margin: 0; }
.doc h3 { font-size: 1.05rem; font-weight: 600; margin: 0; }
.doc :not(pre) > code { background: var(--code); padding: 1px 5px; border-radius: 4px; }
.doc section { display: flex; flex-direction: column; gap: 18px; }
.doc .eyebrow { font-family: var(--f-mono); font-size: 0.75rem; letter-spacing: 0.12em; text-transform: uppercase; color: var(--accent); }
.doc .lede { font-size: 1.12rem; }
.doc .doc-head { display: flex; flex-direction: column; gap: 18px; padding-bottom: 28px; border-bottom: 1px solid var(--line); }
.doc .chips { display: flex; flex-wrap: wrap; gap: 8px; }
.doc .chip { font-family: var(--f-mono); font-size: 0.78rem; padding: 4px 10px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--card); white-space: nowrap; }
.doc .chip.ok { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 40%, var(--line)); }
.doc .chip.warn { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 40%, var(--line)); }
.doc .diagram { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 16px; overflow-x: auto; }
.doc .diagram pre.mermaid { margin: 0; background: transparent; min-width: 640px; }
.doc .caption { font-size: 0.85rem; color: var(--muted); }
.doc table { font-size: 0.92rem; }
.doc td.path { font-family: var(--f-mono); font-size: 0.84rem; white-space: nowrap; }
.doc .grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 14px; }
.doc .card { padding: 16px 18px; display: flex; flex-direction: column; gap: 8px; }
.doc .card h3 { font-size: 1rem; }
.doc .card p { font-size: 0.93rem; }
.doc ol.steps { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; counter-reset: s; }
.doc ol.steps li { counter-increment: s; display: grid; grid-template-columns: 34px 1fr; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line); }
.doc ol.steps li:first-child { border-top: 0; }
.doc ol.steps li::before { content: counter(s); font-family: var(--f-mono); font-size: 0.8rem; color: var(--accent);
  background: var(--accent-soft); border-radius: 6px; height: 26px; display: grid; place-items: center; }
.doc ol.steps li > div { min-width: 0; }
.doc ul.plain { margin: 0; padding-left: 1.1em; display: flex; flex-direction: column; gap: 6px; max-width: 70ch; }
.doc .finding { display: grid; grid-template-columns: 110px 1fr; gap: 14px; padding: 14px 0; border-top: 1px solid var(--line); }
.doc .finding:first-of-type { border-top: 0; }
.doc .finding .tag { font-family: var(--f-mono); font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.08em; padding-top: 3px; }
.doc .finding .tag.up { color: var(--teal); }
.doc .finding .tag.fix { color: var(--ok); }
.doc .finding .tag.open { color: var(--warn); }
.doc .finding > div { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.doc .bars { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 18px; display: flex; flex-direction: column; gap: 14px; }
.doc .bar-row { display: grid; grid-template-columns: 170px 1fr; gap: 12px; align-items: center; }
.doc .bar-label { font-size: 0.88rem; }
.doc .bar-track { position: relative; height: 22px; background: var(--code); border-radius: 4px; }
.doc .bar-fill { position: absolute; inset: 0 auto 0 0; border-radius: 4px; }
.doc .bar-val { position: absolute; top: 50%; transform: translateY(-50%); font-family: var(--f-mono); font-size: 0.78rem; white-space: nowrap; color: var(--fg); }
.doc .axis { display: grid; grid-template-columns: 170px 1fr; gap: 12px; }
.doc .axis-ticks { position: relative; height: 16px; font-family: var(--f-mono); font-size: 0.7rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.doc .axis-ticks span { position: absolute; transform: translateX(-50%); }
.doc .axis-ticks span:first-child { transform: none; }
.doc .axis-ticks span:last-child { transform: translateX(-100%); }
.doc pre.code { background: var(--code); border-radius: 8px; padding: 14px 16px; overflow-x: auto; font-family: var(--f-mono); font-size: 0.84rem; line-height: 1.5; margin: 0; }
.doc .callout { background: var(--warn-soft); border-radius: 10px; padding: 14px 18px; display: flex; flex-direction: column; gap: 8px; }
.doc .callout h3 { color: var(--warn); font-size: 1rem; }
.doc .pill { background: var(--teal-soft); color: var(--teal); }
.doc .pill.cb { background: var(--accent-soft); color: var(--accent); }
.doc .commits { font-family: var(--f-mono); font-size: 0.85rem; }
.doc .commits td:first-child { color: var(--accent); white-space: nowrap; }
@media (max-width: 560px) {
  .doc .finding { grid-template-columns: 1fr; gap: 4px; }
  .doc .bar-row, .doc .axis { grid-template-columns: 1fr; gap: 4px; }
  .doc .axis > :first-child { display: none; }
}

/* Mining overview (landing page) */
.small { font-size: 0.8rem; font-weight: 400; }
.eyebrow { font-family: var(--f-mono); font-size: 0.75rem; letter-spacing: 0.12em; text-transform: uppercase; color: var(--accent); }
section.hero { display: flex; flex-direction: column; gap: 14px; padding: 18px 0 26px; border-bottom: 1px solid var(--line); }
section.hero h1 { font-size: clamp(2.2rem, 5vw, 3.2rem); margin: 0; }
section.hero .lede { font-size: 1.1rem; max-width: 68ch; margin: 0; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; }
.button { display: inline-block; padding: 8px 16px; border-radius: 8px; border: 1px solid var(--line);
  background: var(--card); color: var(--fg); font-weight: 500; }
.button:hover { text-decoration: none; border-color: var(--accent); }
.button.primary { background: var(--accent); border-color: var(--accent); color: var(--bg); }
.grid.stats { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
.grid.ways { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); align-items: start; }
.way { display: flex; flex-direction: column; gap: 10px; }
.way h3 { font-size: 1.1rem; margin: 0; }
.way p { margin: 0; font-size: 0.93rem; }
.way p.warn { color: var(--warn); background: var(--warn-soft); padding: 8px 10px; border-radius: 6px; }
table.facts th { width: 150px; text-transform: none; letter-spacing: 0; font-family: var(--f-body); font-size: 0.88rem;
  color: var(--accent); background: var(--card); white-space: normal; }
.grid.links { grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); }
a.card.link { display: flex; flex-direction: column; gap: 4px; color: var(--fg); }
a.card.link:hover { text-decoration: none; border-color: var(--teal); }
a.card.link .title { font-weight: 600; color: var(--teal); }
