:root {
  --paper: #ffffff;
  --ground: #f4f5f7;
  --line: #d9dce1;
  --text: #16181d;
  --muted: #6b7280;
  --accent: #0b6bcb;
  --ok: #1f7a4d;
  --warn: #9a6700;
  --bad: #b42318;
  --radius: 8px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #1b1e24;
    --ground: #121418;
    --line: #2e333c;
    --text: #e8eaed;
    --muted: #9aa2ad;
    --accent: #4f9df7;
    --ok: #45b37d;
    --warn: #d9a441;
    --bad: #f2705f;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--text);
  background: var(--ground);
}

header {
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 12px 20px;
  background: var(--paper);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 2;
  flex-wrap: wrap;
}

.brand { display: flex; align-items: baseline; gap: 10px; }
.brand strong { font-size: 17px; letter-spacing: 0.2px; }
.site { color: var(--muted); font-size: 13px; }

nav { display: flex; gap: 4px; }

nav button {
  border: 1px solid transparent;
  background: none;
  color: var(--muted);
  padding: 6px 12px;
  border-radius: var(--radius);
  cursor: pointer;
  font: inherit;
}
nav button:hover { background: var(--ground); }
nav button.aktiv { color: var(--text); background: var(--ground); border-color: var(--line); }

.connection { margin-left: auto; font-size: 13px; color: var(--muted); }
.connection.bad { color: var(--bad); }

main { padding: 20px; max-width: 1400px; margin: 0 auto; }
.view.hidden { display: none; }

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

.card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
}

.card h3 { margin: 0 0 2px; font-size: 15px; }
.card .sub { color: var(--muted); font-size: 12px; margin-bottom: 12px; }

.bar {
  height: 10px;
  background: var(--ground);
  border: 1px solid var(--line);
  border-radius: 999px;
  overflow: hidden;
  margin: 10px 0 8px;
}
.bar > span { display: block; height: 100%; background: var(--accent); }
.bar.matured > span { background: var(--ok); }
.bar.young > span { background: var(--warn); }

.figure { font-size: 24px; font-weight: 600; }
.figure small { font-size: 13px; font-weight: 400; color: var(--muted); }

.rows { margin-top: 10px; border-top: 1px solid var(--line); padding-top: 8px; }
.row { display: flex; justify-content: space-between; gap: 12px; font-size: 13px; padding: 2px 0; }
.row span:first-child { color: var(--muted); }

.ok { color: var(--ok); }
.warn { color: var(--warn); }
.bad { color: var(--bad); }

.columns { display: grid; grid-template-columns: minmax(420px, 1fr) minmax(380px, 1fr); gap: 16px; }
@media (max-width: 1000px) { .columns { grid-template-columns: 1fr; } }

.list, .protocol {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}
.protocol { padding: 16px; }

table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 8px 12px; border-bottom: 1px solid var(--line); }
th { color: var(--muted); font-weight: 500; background: var(--ground); position: sticky; top: 0; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tbody tr { cursor: pointer; }
tbody tr:hover { background: var(--ground); }
tbody tr.selected { background: var(--ground); box-shadow: inset 3px 0 0 var(--accent); }

.protocol h2 { margin: 0 0 4px; font-size: 16px; }
.protocol h4 { margin: 18px 0 6px; font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.protocol .head { color: var(--muted); font-size: 13px; }
.protocol table { font-size: 12.5px; }

.hint, .empty { color: var(--muted); font-size: 13px; }
.hint { margin-top: 20px; }

.hash { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 11px; color: var(--muted); word-break: break-all; }

a.button {
  display: inline-block; margin-top: 12px; font-size: 13px;
  color: var(--accent); text-decoration: none;
  border: 1px solid var(--line); border-radius: var(--radius); padding: 5px 10px;
}
a.button:hover { background: var(--ground); }

/* --- Zustand ------------------------------------------------------------ */

.section {
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin: 28px 0 12px;
}

.card.wide { grid-column: 1 / -1; }

.state-word {
  font-size: 22px;
  font-weight: 600;
  display: flex;
  align-items: baseline;
  gap: 10px;
}
.state-word small { font-size: 13px; font-weight: 400; color: var(--muted); }

.dot {
  width: 9px; height: 9px; border-radius: 999px;
  background: var(--muted); display: inline-block; flex: none;
}
.dot.running { background: var(--ok); animation: pulse 2s ease-in-out infinite; }
.dot.idle { background: var(--muted); }
.dot.missing { background: var(--bad); }

@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }
@media (prefers-reduced-motion: reduce) { .dot.running { animation: none; } }

.phase-bar { display: flex; gap: 3px; margin: 14px 0 6px; }
.phase-bar > div {
  flex: 1; height: 6px; border-radius: 999px; background: var(--ground);
  border: 1px solid var(--line);
}
.phase-bar > div.done { background: var(--ok); border-color: var(--ok); }
.phase-bar > div.now { background: var(--accent); border-color: var(--accent); }
.phase-names { display: flex; gap: 3px; font-size: 11px; color: var(--muted); }
.phase-names > span { flex: 1; text-align: center; }
.phase-names > span.now { color: var(--text); font-weight: 500; }

.source {
  margin-top: 10px; font-size: 11.5px; color: var(--muted);
  border-top: 1px solid var(--line); padding-top: 8px;
}
.source.reported::before { content: "\25CF  "; color: var(--ok); }
.source.derived::before { content: "\25CB  "; }

.activity .headline { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.activity .rate { font-size: 20px; font-weight: 600; white-space: nowrap; }
.activity .rate small { font-size: 12px; font-weight: 400; color: var(--muted); }
.warn-line { color: var(--warn); font-size: 12.5px; margin-top: 8px; }

/* --- Batch and mix ------------------------------------------------------ */

.mix-row { cursor: pointer; }
.mix-row:hover { background: var(--ground); }

.crosscheck {
  margin-top: 12px; padding: 10px 12px; border-radius: var(--radius);
  background: var(--ground); border: 1px solid var(--line); font-size: 12.5px;
}
.crosscheck .verdict { font-weight: 600; }

.back {
  background: none; border: 1px solid var(--line); border-radius: var(--radius);
  color: var(--accent); font: inherit; font-size: 13px; padding: 4px 10px;
  cursor: pointer; margin-bottom: 12px;
}
.back:hover { background: var(--ground); }
