:root { --bg: #f6f7f9; --fg: #1d2330; --muted: #667085; --line: #d8dde6; --accent: #1f5fbf; --ok: #127a3d; --bad: #b42318; --card: #fff; }
@media (prefers-color-scheme: dark) { :root { --bg: #14171c; --fg: #e6e9ee; --muted: #98a2b3; --line: #2c323c; --accent: #6ea2f0; --ok: #47c47a; --bad: #f07a6e; --card: #1c2028; } }
* { box-sizing: border-box; }
body { margin: 0; font: 15px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif; background: var(--bg); color: var(--fg); }
a { color: var(--accent); }
header.top { display: flex; flex-wrap: wrap; gap: 16px; align-items: center; padding: 10px 20px; background: var(--card); border-bottom: 1px solid var(--line); }
header .brand { font-weight: 700; text-decoration: none; color: var(--fg); }
header nav { display: flex; gap: 14px; flex-wrap: wrap; flex: 1; }
header .who { display: flex; gap: 10px; align-items: center; color: var(--muted); font-size: 13px; }
.role { border: 1px solid var(--line); border-radius: 10px; padding: 0 6px; }
main { padding: 20px; max-width: 1200px; margin: 0 auto; }
h1 { font-size: 22px; } h2 { font-size: 17px; margin-top: 28px; }
table { border-collapse: collapse; width: 100%; background: var(--card); margin: 8px 0; }
th, td { border-bottom: 1px solid var(--line); padding: 6px 8px; text-align: left; vertical-align: top; font-size: 14px; }
table.kv th { width: 260px; color: var(--muted); font-weight: 500; }
code { font-size: 13px; overflow-wrap: anywhere; }
.ok { color: var(--ok); } .bad { color: var(--bad); } .muted { color: var(--muted); font-size: 13px; }
.badge { font-size: 12px; border: 1px solid currentColor; border-radius: 10px; padding: 1px 8px; vertical-align: middle; }
.code { font-family: ui-monospace, monospace; color: var(--muted); }
.flash { padding: 10px 12px; border: 1px solid var(--line); background: var(--card); border-radius: 6px; margin: 8px 0; }
.flash.error { border-color: var(--bad); color: var(--bad); }
.warn { padding: 10px 12px; border: 1px solid #c4a000; border-radius: 6px; margin: 8px 0; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin: 8px 0; }
.grid { display: grid; gap: 10px; max-width: 640px; }
fieldset { border: 1px solid var(--line); border-radius: 6px; display: grid; gap: 8px; }
label { display: grid; gap: 3px; }
label:has(input[type=checkbox]), label:has(input[type=radio]) { display: flex; gap: 6px; align-items: center; }
input, select, button { font: inherit; padding: 6px 8px; border: 1px solid var(--line); border-radius: 5px; background: var(--card); color: var(--fg); }
input.short { width: 6em; }
button, a.button { cursor: pointer; background: var(--accent); color: #fff; border-color: var(--accent); text-decoration: none; padding: 6px 12px; border-radius: 5px; display: inline-block; }
button.danger { background: var(--bad); border-color: var(--bad); }
button.link { background: none; border: none; color: var(--accent); padding: 0; }
form.inline { display: inline; }
.narrow { max-width: 380px; margin: 40px auto; display: grid; gap: 10px; }
.narrow form { display: grid; gap: 10px; }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 12px; }
.card .n { font-size: 28px; font-weight: 700; }
.card.bad .n { color: var(--bad); }

/* MFA enrolment QR code (inline SVG): white quiet zone so phone cameras read it in dark mode too */
.qr { margin: 16px 0; }
.qr svg { display: block; max-width: none; background: #fff; border-radius: 4px; }
details.manual { margin-top: 20px; color: var(--muted); }
details.manual summary { cursor: pointer; }

/* Billing (schema 0009) */
tr.muted td { color: var(--muted); }
.badge.ok { color: var(--ok); } .badge.bad { color: var(--bad); } .badge.muted { color: var(--muted); }
details { margin: 8px 0; } details > summary { cursor: pointer; color: var(--accent); margin: 6px 0; }
details > form { margin-top: 8px; }
legend { color: var(--muted); font-size: 13px; padding: 0 4px; }
/* company billing page: one panel per group (account, invoices and payments, charges, calls) */
section.panel { margin: 18px 0; } section.panel > h2:first-child { margin-top: 0; }
section.panel h3 { margin: 18px 0 6px; } section.panel .two h3 { margin-top: 4px; }
.two table.kv th { width: 48%; }
fieldset + fieldset { margin-top: 4px; }

/* Revenue report (schema 0010): chart colours live here because the CSP forbids inline styles */
:root { --c-rec: #2f6fd6; --c-one: #e08a1e; --c-oth: #8a63d2; --c-neg: #c2453a; --c-col: #14995a; --c-ma: #1d2330; --c-ly: #8a93a3; --grid: #e3e7ee; }
@media (prefers-color-scheme: dark) { :root { --c-rec: #5f95ec; --c-one: #f0a54a; --c-oth: #a98ae6; --c-neg: #ef7b70; --c-col: #45c983; --c-ma: #e6e9ee; --c-ly: #7f8898; --grid: #2c323c; } }
figure.chart { margin: 12px 0; background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 12px; }
.rev-chart { width: 100%; height: auto; display: block; }
.rev-chart .grid { stroke: var(--grid); stroke-width: 1; }
.rev-chart .grid.zero { stroke: var(--muted); }
.rev-chart .axis { fill: var(--muted); font-size: 12px; font-family: system-ui, sans-serif; font-variant-numeric: tabular-nums; }
.rev-chart .s-rec { fill: var(--c-rec); } .rev-chart .s-one { fill: var(--c-one); } .rev-chart .s-oth { fill: var(--c-oth); }
.rev-chart .s-neg { fill: var(--c-neg); }
.rev-chart .hit { fill: transparent; } .rev-chart g:hover .hit { fill: var(--fg); fill-opacity: 0.06; }
.rev-chart path { fill: none; stroke-linejoin: round; stroke-linecap: round; }
.rev-chart .l-col { stroke: var(--c-col); stroke-width: 2.5; }
.rev-chart .l-ma { stroke: var(--c-ma); stroke-width: 2; stroke-dasharray: 7 5; }
.rev-chart .l-ly { stroke: var(--c-ly); stroke-width: 1.8; stroke-dasharray: 2 4; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-top: 8px; font-size: 13px; align-items: center; }
.legend .k { display: inline-block; width: 14px; height: 10px; border-radius: 2px; margin-right: 6px; vertical-align: middle; }
.legend .k.s-rec { background: var(--c-rec); } .legend .k.s-one { background: var(--c-one); } .legend .k.s-oth { background: var(--c-oth); }
.legend .k.s-neg { background: var(--c-neg); }
.legend .k.l-col { height: 3px; background: var(--c-col); } .legend .k.l-ma { height: 0; border-top: 2px dashed var(--c-ma); border-radius: 0; }
.legend .k.l-ly { height: 0; border-top: 2px dotted var(--c-ly); border-radius: 0; }
.spark { display: block; margin-top: 6px; } .spark polyline { fill: none; stroke: var(--accent); stroke-width: 1.5; }
.scroll { overflow-x: auto; }
table.num td, table.num th { font-variant-numeric: tabular-nums; white-space: nowrap; }
form.filters label { display: flex; gap: 4px; align-items: center; }
pre.sample { background: var(--card); border: 1px solid var(--line); border-radius: 6px; padding: 8px; font-size: 12px; overflow-x: auto; }
.rev-chart g.partial rect:not(.hit) { fill-opacity: 0.45; }
/* DID list */
.row.spread { justify-content: space-between; }
table.dids td.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
table.dids a.sort { color: inherit; text-decoration: none; } table.dids a.sort.on { color: var(--accent); }
table.dids td.actions { white-space: nowrap; } table.dids td.actions input { padding: 3px 6px; }
button.small { padding: 3px 8px; font-size: 12px; } .small { font-size: 12px; }
/* Endpoint log */
.badge.caution { color: #a86a00; }
a.button.secondary { background: none; color: var(--accent); border: 1px solid var(--accent); }
.two-col { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 16px; }
table.eplog td { vertical-align: top; } .nowrap { white-space: nowrap; }
table.eplog tr.sev-error td:first-child { border-left: 3px solid var(--bad); }
table.eplog tr.sev-warning td:first-child { border-left: 3px solid #d39a00; }
dl.hints dt { font-weight: 600; margin-top: 8px; } dl.hints dd { margin: 2px 0 0 0; color: var(--muted); max-width: 70em; }
table.mini td { font-size: 13px; }

/* Operations dashboard (dashboard/viz.py). Categorical slots c-1..c-5 in fixed order (validated: light #fcfcfb
   surface, dark #1c2028; light slots 3-4 are under 3:1, so every chart has a legend and a table view).
   Status colours are reserved for state and always come with an icon and a word. */
:root { --c1: #2a78d6; --c2: #eb6834; --c3: #1baf7a; --c4: #eda100; --c5: #e87ba4;
        --st-ok: #0ca30c; --st-warn: #fab219; --st-serious: #ec835a; --st-crit: #d03b3b; --st-none: #98a2b3;
        --tint-ok: transparent; --tint-warn: #fff6e0; --tint-crit: #fdecec; --tint-serious: #fdf0ea;
        --q1: #cde2fb; --q2: #9ec5f4; --q3: #6da7ec; --q4: #3987e5; --q5: #256abf; --q6: #184f95; --q0: #eef1f5;
        --dial-track: #e3e7ee; --ink-on: #fff; }
@media (prefers-color-scheme: dark) {
  :root { --c1: #3987e5; --c2: #d95926; --c3: #199e70; --c4: #c98500; --c5: #d55181;
          --tint-warn: #3a3013; --tint-crit: #3d1c1c; --tint-serious: #3b2419;
          --q1: #104281; --q2: #184f95; --q3: #256abf; --q4: #3987e5; --q5: #6da7ec; --q6: #9ec5f4; --q0: #232833;
          --dial-track: #2c323c; }
}
.dash-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 8px; }
.dash-head h1 { margin: 8px 0; }
.panel { background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px; margin: 12px 0; }
.panel h3 { font-size: 15px; margin: 0 0 8px; }
.two { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 12px; }
.two > .chart, .two > .panel { margin: 0; }
figure.chart figcaption { font-weight: 600; font-size: 14px; margin-bottom: 6px; }
figure.chart.flat { border: 0; padding: 0; margin: 0 0 10px; }

/* status chip: icon + word, colour as a second signal */
.st { display: inline-flex; align-items: center; gap: 5px; white-space: nowrap; font-size: 13px; }
.st .ico { display: inline-grid; place-items: center; width: 17px; height: 17px; border-radius: 50%; font-size: 11px;
           font-weight: 700; color: var(--ink-on); background: var(--st-none); }
.st-ok .ico { background: var(--st-ok); } .st-warn .ico { background: var(--st-warn); color: #1d2330; }
.st-serious .ico { background: var(--st-serious); color: #1d2330; } .st-crit .ico { background: var(--st-crit); }
td.cell-warn { background: var(--tint-warn); } td.cell-crit { background: var(--tint-crit); }
td.cell-serious { background: var(--tint-serious); }

/* needs-attention list */
.attn { border-left: 4px solid var(--st-ok); }
.attn:has(tr.lv-warn) { border-left-color: var(--st-warn); } .attn:has(tr.lv-crit) { border-left-color: var(--st-crit); }
.attn h2 { margin-top: 0; }
.attn-list td { vertical-align: middle; } .attn-list .w-st { width: 110px; } .attn-list .w-area { width: 120px; color: var(--muted); }
.attn-list .w-go { width: 70px; text-align: right; }
.attn-list tr.lv-crit td:first-child { box-shadow: inset 3px 0 var(--st-crit); }

/* KPI tiles */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; margin: 14px 0; }
.tile { background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 12px; border-top: 3px solid var(--line); }
.tile-ok { border-top-color: var(--st-ok); } .tile-warn { border-top-color: var(--st-warn); }
.tile-crit { border-top-color: var(--st-crit); } .tile-serious { border-top-color: var(--st-serious); }
.t-label { color: var(--muted); font-size: 13px; } .t-value { font-size: 26px; font-weight: 650; font-variant-numeric: tabular-nums; margin: 2px 0 4px; }
.t-foot { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; } .delta { color: var(--muted); font-size: 12px; }
.spark2 { display: block; margin-top: 6px; } .spark2 path { fill: none; stroke: var(--muted); stroke-width: 1.5; }
.spark2 circle { fill: var(--accent); }

/* dials */
.dials { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; }
.dial-card { margin: 0; background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 8px 8px 4px; }
.viz.dial { width: 100%; height: auto; display: block; }
.dial .d-track { fill: none; stroke: var(--dial-track); stroke-width: 16; }
.dial .d-band { fill: none; stroke-width: 4; } .dial .b-ok { stroke: var(--st-ok); } .dial .b-warn { stroke: var(--st-warn); }
.dial .b-crit { stroke: var(--st-crit); }
.dial .d-val { fill: none; stroke-width: 16; } .dial .d-val.st-ok, .dial .d-val.st-none { stroke: var(--c1); }
.dial .d-val.st-warn { stroke: var(--st-warn); } .dial .d-val.st-crit { stroke: var(--st-crit); }
.dial .d-needle { stroke: var(--fg); stroke-width: 2.5; stroke-linecap: round; } .dial .d-hub { fill: var(--fg); }
.dial .d-num { fill: var(--fg); font: 600 24px system-ui, sans-serif; font-variant-numeric: tabular-nums; }
.dial .d-unit { font-size: 13px; fill: var(--muted); } .dial .d-min { fill: var(--muted); font: 11px system-ui, sans-serif; }
.dial-card::after { content: none; }

/* bar / line / heatmap / segments */
.viz.bars, .viz.heat, .viz.seg { width: 100%; height: auto; display: block; }
.viz .grid { stroke: var(--grid); stroke-width: 1; } .viz .grid.zero { stroke: var(--muted); }
.viz .axis { fill: var(--muted); font: 11px system-ui, sans-serif; font-variant-numeric: tabular-nums; }
.viz .hit { fill: transparent; } .viz g:hover .hit { fill: var(--fg); fill-opacity: 0.06; }
.viz .c-1, .legend .k.c-1 { fill: var(--c1); background: var(--c1); } .viz .c-2, .legend .k.c-2 { fill: var(--c2); background: var(--c2); }
.viz .c-3, .legend .k.c-3 { fill: var(--c3); background: var(--c3); } .viz .c-4, .legend .k.c-4 { fill: var(--c4); background: var(--c4); }
.viz .c-5, .legend .k.c-5 { fill: var(--c5); background: var(--c5); }
.viz path.l-1 { fill: none; stroke: var(--c1); stroke-width: 2; } .viz circle.l-1 { fill: var(--c1); stroke: var(--card); stroke-width: 2; }
.viz path.l-3 { fill: none; stroke: var(--c3); stroke-width: 2; } .viz circle.l-3 { fill: var(--c3); stroke: var(--card); stroke-width: 2; }
.viz .ref { stroke: var(--muted); stroke-width: 1.5; stroke-dasharray: 6 4; } .viz .ref-t { fill: var(--muted); }
.viz.heat rect.q0 { fill: var(--q0); } .viz.heat rect.q1, .legend .k.q1 { fill: var(--q1); background: var(--q1); }
.viz.heat rect.q2, .legend .k.q2 { fill: var(--q2); background: var(--q2); } .viz.heat rect.q3, .legend .k.q3 { fill: var(--q3); background: var(--q3); }
.viz.heat rect.q4, .legend .k.q4 { fill: var(--q4); background: var(--q4); } .viz.heat rect.q5, .legend .k.q5 { fill: var(--q5); background: var(--q5); }
.viz.heat rect.q6, .legend .k.q6 { fill: var(--q6); background: var(--q6); }
.viz.seg .seg-t { fill: #fff; font: 600 12px system-ui, sans-serif; }
.viz .m-track { fill: var(--dial-track); } .viz .m-fill.st-ok, .viz .m-fill.st-none { fill: var(--c1); }
.viz .m-fill.st-warn { fill: var(--st-warn); } .viz .m-fill.st-crit { fill: var(--st-crit); }
.viz.meter { vertical-align: middle; display: inline-block; }
table.meters td { vertical-align: middle; } table.meters .numc { text-align: right; font-variant-numeric: tabular-nums; }
table.cos td { vertical-align: middle; }
.viz.seg .seg-t.on-c-3, .viz.seg .seg-t.on-c-4, .viz.seg .seg-t.on-c-5 { fill: #1d2330; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin: 12px 0 0; }
.tabs a { padding: 6px 14px; border: 1px solid transparent; border-bottom: none; border-radius: 6px 6px 0 0; color: inherit; text-decoration: none; margin-bottom: -1px; }
.tabs a.on { border-color: var(--line); background: var(--card); font-weight: 600; }
.tabs a:hover:not(.on) { background: var(--card); }
