/* Shared by the tenant and admin pages (the server and the build put this file in front of each page's app.css).
   No framework, no images, no external fonts (CSP: default-src 'self'). The colour tokens are the single source: the pill
   pairs are checked for WCAG AA contrast (4.5:1) in both themes by test/ui-shared.test.ts. */
:root {
  --bg: #f4f4f4;
  --panel: #ffffff;
  --line: #d4d4d4;
  --text: #1f1f1f;
  --muted: #6b6b6b;
  --bar: #6b6b6b;
  --bar-bg: #e6e6e6;
  --bad: #3a3a3a;
  --pill-ok-bg: #d9f2e0;   --pill-ok-fg: #0b5a26;
  --pill-run-bg: #dbe8fb;  --pill-run-fg: #0f3f8a;
  --pill-bad-bg: #fbe0de;  --pill-bad-fg: #8f1a12;
  --pill-off-bg: #e6e6e6;  --pill-off-fg: #3d3d3d;
  --pill-warn-bg: #fcefc7; --pill-warn-fg: #6b4700;
  --banner-bg: #b3261e;    --banner-fg: #ffffff;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #161616;
    --panel: #202020;
    --line: #3a3a3a;
    --text: #e8e8e8;
    --muted: #a3a3a3;
    --bar: #a8a8a8;
    --bar-bg: #333333;
    --bad: #d0d0d0;
    --pill-ok-bg: #123a22;   --pill-ok-fg: #8fe0ac;
    --pill-run-bg: #14305c;  --pill-run-fg: #9cc4ff;
    --pill-bad-bg: #4a1815;  --pill-bad-fg: #ffb3ad;
    --pill-off-bg: #333333;  --pill-off-fg: #cfcfcf;
    --pill-warn-bg: #4a3500; --pill-warn-fg: #f5cf6a;
    --banner-bg: #b3261e;    --banner-fg: #ffffff;
  }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.45 system-ui, "Segoe UI", sans-serif; }
.pad { padding: 16px; }
.muted { color: var(--muted); }
.mono { font-family: ui-monospace, Consolas, monospace; }
.right { text-align: right; }
header.top { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; padding: 10px 16px; background: var(--panel); border-bottom: 1px solid var(--line); }
header.top .brand { font-weight: 600; }
header.top .who { margin-left: auto; }
header.top .who .tenant { color: var(--muted); margin-left: 6px; }
nav { display: flex; flex-wrap: wrap; gap: 4px; }
nav button { background: none; border: 1px solid transparent; padding: 4px 10px; color: var(--text); cursor: pointer; font: inherit; border-radius: 4px; }
nav button[aria-current="page"] { border-color: var(--line); background: var(--bg); font-weight: 600; }
main { padding: 16px; max-width: 1400px; margin: 0 auto; }
h2 { margin: 0 0 12px; font-size: 16px; }
h3 { margin: 20px 0 8px; font-size: 14px; }
.titlebar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-bottom: 12px; }
.titlebar h2 { margin: 0; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: 12px; margin-bottom: 16px; }
.tiles { display: flex; flex-wrap: wrap; gap: 12px; margin-bottom: 16px; }
.tile { background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: 10px 14px; min-width: 130px; }
.tile .n { font-size: 20px; font-weight: 600; }
.tile .l { color: var(--muted); font-size: 12px; }
.tile .sub { color: var(--muted); font-size: 12px; margin-top: 2px; }
.cols2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; align-items: start; }
.cols2 > * { min-width: 0; }
@media (max-width: 900px) { .cols2 { grid-template-columns: minmax(0, 1fr); } }

/* Tables: a wide table scrolls inside its own box, never the page. */
.scroll { overflow-x: auto; max-width: 100%; border: 1px solid var(--line); border-radius: 6px; background: var(--panel); }
table { border-collapse: collapse; width: max-content; min-width: 100%; background: var(--panel); }
th, td { padding: 6px 8px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; white-space: nowrap; }
tbody tr:last-child td { border-bottom: 0; }
th { font-weight: 600; color: var(--muted); font-size: 12px; white-space: normal; vertical-align: bottom; }
td.wrap { white-space: normal; overflow-wrap: break-word; min-width: 12ch; max-width: 32ch; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td.empty { text-align: center; color: var(--muted); padding: 14px 8px; white-space: normal; }
tr.dim td { color: var(--muted); }
td.actions { white-space: normal; }
td.actions .btns { display: flex; flex-wrap: wrap; gap: 6px; }

.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: end; margin-bottom: 12px; }
.filters label, .form label { display: flex; flex-direction: column; font-size: 12px; color: var(--muted); gap: 2px; }
.form { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 10px; align-items: end; }
.form > button.btn { justify-self: start; }
.form.inline { display: flex; flex-wrap: wrap; gap: 10px; align-items: end; }
.form.inline label { min-width: 220px; }
input, select, button.btn { font: inherit; padding: 4px 8px; border: 1px solid var(--line); border-radius: 4px; background: var(--panel); color: var(--text); }
button.btn { cursor: pointer; }
button.btn:hover { background: var(--bg); }
button.btn.primary { background: var(--text); color: var(--panel); border-color: var(--text); }
button.btn.sm { padding: 1px 8px; font-size: 12px; }
button.link { background: none; border: none; color: var(--text); text-decoration: underline; cursor: pointer; font: inherit; padding: 0; }
label.check { flex-direction: row; align-items: center; gap: 6px; color: var(--text); }
fieldset.span { grid-column: 1 / -1; border: 1px solid var(--line); border-radius: 4px; padding: 6px 10px 8px; margin: 0; }
fieldset.span legend { font-size: 12px; color: var(--muted); padding: 0 4px; }
.checks { display: flex; flex-wrap: wrap; gap: 6px 16px; }

/* Pills: one component for statuses, the live stream, the ledger check and the row flags. */
.pill { display: inline-flex; align-items: center; gap: 5px; padding: 1px 9px; border-radius: 999px; font-size: 12px; line-height: 18px; font-weight: 600; white-space: nowrap; }
.pill .dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; flex: none; }
.pill.st-ok { background: var(--pill-ok-bg); color: var(--pill-ok-fg); }
.pill.st-run { background: var(--pill-run-bg); color: var(--pill-run-fg); }
.pill.st-bad { background: var(--pill-bad-bg); color: var(--pill-bad-fg); }
.pill.st-off { background: var(--pill-off-bg); color: var(--pill-off-fg); }
.pill.st-warn { background: var(--pill-warn-bg); color: var(--pill-warn-fg); }
.pill.flag { font-size: 11px; line-height: 16px; font-weight: 500; padding: 0 7px; border-radius: 4px; }
.pill.st-run .dot { animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: 0.3; } }
.flags { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 3px; }
.legend { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 0 0 12px; }
.api { display: inline-block; margin-left: 6px; vertical-align: baseline; font-size: 11px; color: var(--muted); border: 1px solid var(--line); border-radius: 4px; padding: 0 5px; line-height: 16px; }
.keyname .prefix { color: var(--muted); font-size: 12px; margin-left: 6px; }
.detail { color: var(--muted); font-size: 12px; }
td .detail { white-space: normal; max-width: 24ch; }
td .detail.mono { white-space: nowrap; max-width: none; }
td.num .detail { margin-left: auto; }
.spinner { display: inline-block; width: 10px; height: 10px; border: 2px solid var(--line); border-top-color: var(--text); border-radius: 50%; animation: spin 0.8s linear infinite; vertical-align: -1px; margin-right: 4px; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner, .pill.st-run .dot { animation: none; } }
.bar { display: inline-block; height: 10px; background: var(--bar); border-radius: 2px; min-width: 1px; vertical-align: middle; }
.bar-track { display: inline-block; width: 160px; background: var(--bar-bg); border-radius: 2px; height: 10px; vertical-align: middle; }
.bar-track .bar { display: block; height: 10px; }
.error { color: var(--bad); font-weight: 600; margin: 8px 0; }
.notice { border: 1px solid var(--line); background: var(--panel); border-radius: 6px; padding: 12px; margin-bottom: 16px; }
.keybox { display: flex; gap: 8px; align-items: center; margin: 8px 0; }
.keybox input { flex: 1; min-width: 0; }
.login { max-width: 360px; margin: 10vh auto; }
.login .form { grid-template-columns: 1fr; }
.banner { background: var(--banner-bg); color: var(--banner-fg); padding: 10px 16px; font-weight: 600; }
.banner.inline { border-radius: 6px; margin-bottom: 16px; }

/* Tenant page only; the shared tokens, tables and pills are in src/web/static/shared.css. */
