:root {
  --bg: #f6f7f9; --card: #fff; --text: #1b1f24; --muted: #667080; --line: #e3e6ea; --accent: #0b3fa8;
  --green: #1e7d4f; --red: #b3261e; --amber: #9a6700; --blue: #0b57d0; --chip: #eef1f5;
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #111418; --card: #1b2026; --text: #e6e9ed; --muted: #98a2b0; --line: #2c333b; --accent: #8fb0ff;
    --green: #6fd19c; --red: #ff8a80; --amber: #f2c14e; --blue: #8ab4f8; --chip: #262d35; }
}
* { box-sizing: border-box; }
/* Elements styled with display (the sign-in form, the tabs) must still hide. */
[hidden] { display: none !important; }
body { margin: 0; background: var(--bg); color: var(--text); }
header { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 24px; padding: 12px 20px; background: var(--card); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 1; }
h1 { font-size: 18px; margin: 0; }
h1 span { color: var(--muted); font-weight: 500; }
h2 { font-size: 17px; margin: 0 0 8px; }
nav { display: flex; gap: 4px; flex-wrap: wrap; }
nav button { background: none; border: 0; padding: 8px 12px; border-radius: 8px; color: var(--muted); font: inherit; cursor: pointer; }
nav button.active { background: var(--chip); color: var(--text); font-weight: 600; }
#who { margin-left: auto; color: var(--muted); font-size: 13px; display: flex; align-items: center; gap: 10px; }
#who[hidden] { display: none; }
.money { min-width: 40px; padding: 4px 8px; border-radius: 999px; font-weight: 700; background: var(--chip); border-color: transparent; color: var(--text); }
main { max-width: 1200px; margin: 0 auto; padding: 20px 16px 60px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 16px; margin-bottom: 12px; }
.grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.spread { justify-content: space-between; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.mono { font-family: ui-monospace, Menlo, monospace; }
.error { color: var(--red); }
.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--chip); }
.badge.green { color: var(--green); } .badge.red { color: var(--red); } .badge.amber { color: var(--amber); } .badge.blue { color: var(--blue); }
button, .button { font: inherit; padding: 7px 12px; border-radius: 8px; border: 1px solid var(--line); background: var(--card); color: var(--text); cursor: pointer; }
button.primary, form button[type=submit] { background: var(--accent); color: #fff; border-color: transparent; }
button.danger { color: var(--red); }
button.link { border: 0; background: none; color: var(--accent); padding: 0; }
button:disabled { opacity: .5; cursor: default; }
input, select { font: inherit; padding: 8px 10px; border-radius: 8px; border: 1px solid var(--line); background: var(--card); color: var(--text); }
form#signin { max-width: 360px; margin: 40px auto; display: grid; gap: 10px; background: var(--card); padding: 24px; border-radius: 12px; border: 1px solid var(--line); }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; }
.table-wrap { overflow-x: auto; }
.num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
dl { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; margin: 8px 0 0; font-size: 14px; }
dt { color: var(--muted); }
dd { margin: 0; }
.answers { margin: 6px 0 0; padding-left: 18px; font-size: 14px; }
.answers li { margin: 2px 0; }
.big { font-size: 26px; font-weight: 700; }
.toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; background: var(--muted); }
.dot.ok { background: var(--green); } .dot.bad { background: var(--red); }
audio { height: 32px; max-width: 100%; }
.nowrap { white-space: nowrap; }
.mt { margin-top: 12px; }
.mt-s { margin-top: 6px; }
@media (max-width: 640px) { header { padding: 10px 16px; } #who { margin-left: 0; } }

/* ---- charts (charts.js) and the simulator ---- */
.chart { width: 100%; height: auto; display: block; }
.chart .grid { stroke: var(--line); stroke-width: 1; }
.chart .axis { fill: var(--muted); font-size: 12px; }
.chart .bar:hover { opacity: .8; }
.c0 { fill: #3b82f6; } .c1 { fill: #14b8a6; } .c2 { fill: #f59e0b; } .c3 { fill: #a855f7; }
.c4 { fill: #ef4444; } .c5 { fill: #22c55e; } .c6 { fill: #64748b; } .c7 { fill: #ec4899; }
.cell.up { fill: var(--green); } .cell.degraded { fill: var(--amber); } .cell.down { fill: var(--red); } .cell.none { fill: var(--chip); }
.up { fill: var(--green); } .degraded { fill: var(--amber); } .down { fill: var(--red); } .none { fill: var(--chip); }
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 13px; color: var(--muted); margin-top: 8px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.chart-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; margin-bottom: 10px; }
.chart-head h2 { margin: 0 auto 0 0; }
.segmented { display: inline-flex; background: var(--chip); border-radius: 8px; padding: 2px; }
.segmented button { border: 0; background: none; padding: 5px 10px; border-radius: 6px; color: var(--muted); font-size: 13px; }
.segmented button.active { background: var(--card); color: var(--text); font-weight: 600; box-shadow: 0 1px 2px rgba(0,0,0,.12); }
.section { margin-top: 24px; }
.sim { display: grid; gap: 16px; grid-template-columns: minmax(260px, 1fr) minmax(300px, 1.3fr); }
@media (max-width: 760px) { .sim { grid-template-columns: 1fr; } }
.fields { display: grid; grid-template-columns: 1fr 110px; gap: 8px 12px; align-items: center; font-size: 14px; }
.fields input { width: 100%; text-align: right; }
.fields .hint { grid-column: 1 / -1; margin-top: -4px; }
details summary { cursor: pointer; color: var(--accent); margin: 12px 0 8px; font-size: 14px; }
tfoot td { font-weight: 700; border-bottom: 0; }

/* Confirming a critical action (super admins) */
dialog { border: 1px solid var(--line); border-radius: 12px; padding: 0; background: var(--card); color: var(--text); max-width: 420px; width: calc(100% - 32px); }
dialog::backdrop { background: rgba(0, 0, 0, .45); }
form.confirm { display: grid; gap: 10px; padding: 20px; }
form.confirm p { margin: 0; }
button.danger-solid { background: var(--red); color: #fff; border-color: transparent; }

/* Long emails (e.g. with +tags) wrap instead of overflowing cards and tables */
.email { overflow-wrap: break-word; min-width: 0; }
.card-title { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; }
td.email { min-width: 12ch; }
