/* FizLink admin. Tokens follow the data-viz reference palette: series
   colors are validated for colour-blind separation in both themes; status
   colors are reserved and always paired with an icon and a label. */
:root {
  color-scheme: light;
  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-2: #f8f9fb;
  --chart-surface: #ffffff;
  --line: #e3e6eb;
  --grid: #eceef1;
  --text: #0b0b0b;
  --text-2: #52514e;
  --muted: #7a7a76;
  --accent: #2a78d6;
  --accent-soft: rgba(42, 120, 214, .1);
  --series-1: #2a78d6;
  --series-2: #eb6834;
  --series-3: #1baf7a;
  --good: #0ca30c;
  --warning: #fab219;
  --serious: #ec835a;
  --critical: #d03b3b;
  --good-text: #006300;
  --critical-text: #b42f2f;
  --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 4px 16px rgba(16, 24, 40, .05);
  --radius: 14px;
}
@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --bg: #111110;
    --surface: #1a1a19;
    --surface-2: #20201e;
    --chart-surface: #1a1a19;
    --line: #2c2c29;
    --grid: #262624;
    --text: #f0efec;
    --text-2: #c3c2b7;
    --muted: #8c8b84;
    --accent: #3987e5;
    --accent-soft: rgba(57, 135, 229, .16);
    --series-1: #3987e5;
    --series-2: #d95926;
    --series-3: #199e70;
    --good-text: #4cc94c;
    --critical-text: #f07a7a;
    --shadow: 0 1px 2px rgba(0, 0, 0, .35);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #111110;
  --surface: #1a1a19;
  --surface-2: #20201e;
  --chart-surface: #1a1a19;
  --line: #2c2c29;
  --grid: #262624;
  --text: #f0efec;
  --text-2: #c3c2b7;
  --muted: #8c8b84;
  --accent: #3987e5;
  --accent-soft: rgba(57, 135, 229, .16);
  --series-1: #3987e5;
  --series-2: #d95926;
  --series-3: #199e70;
  --good-text: #4cc94c;
  --critical-text: #f07a7a;
  --shadow: 0 1px 2px rgba(0, 0, 0, .35);
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--text);
  font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, sans-serif; -webkit-font-smoothing: antialiased; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
code, .id, .mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .92em; }
code { background: var(--surface-2); border: 1px solid var(--line); border-radius: 6px; padding: 1px 5px; overflow-wrap: anywhere; }
pre code { background: none; border: 0; padding: 0; border-radius: 0; font-size: inherit; overflow-wrap: normal; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.hidden { display: none !important; }
h1, h2, h3 { letter-spacing: -.01em; }
h2 { font-size: 15px; margin: 0 0 12px; }
h3 { font-size: 14px; margin: 18px 0 8px; }

/* ---------- shell ---------- */
body.app { display: grid; grid-template-columns: 236px 1fr; min-height: 100vh; }
.side { background: var(--surface); border-right: 1px solid var(--line); display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh; padding: 18px 12px; }
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px 18px; color: var(--text); font-weight: 700; font-size: 16px; }
.brand:hover { text-decoration: none; }
.brand small { font-weight: 500; color: var(--muted); }
.logo { width: 30px; height: 30px; stroke: none; }
.logo-bg { fill: var(--accent); }
.side nav { display: flex; flex-direction: column; gap: 2px; }
.side nav a { display: flex; align-items: center; gap: 11px; padding: 9px 12px; border-radius: 10px; color: var(--text-2); font-weight: 500; }
.side nav a:hover { background: var(--surface-2); text-decoration: none; color: var(--text); }
.side nav a.on { background: var(--accent-soft); color: var(--accent); }
.side-foot { margin-top: auto; display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 12px 10px 0; border-top: 1px solid var(--line); }
.who { display: inline-flex; align-items: center; gap: 8px; color: var(--text-2); }
.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 12px; padding: 14px 28px;
  background: color-mix(in srgb, var(--bg) 85%, transparent); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.topbar h1 { font-size: 19px; margin: 0; }
.spacer { flex: 1; }
.content { padding: 24px 28px 48px; max-width: 1400px; width: 100%; }
.menu { display: none; }
.backdrop { display: none; }
.theme-sun { display: none; }
:root[data-theme="dark"] .theme-sun { display: block; }
:root[data-theme="dark"] .theme-moon { display: none; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .theme-sun { display: block; } :root:not([data-theme="light"]) .theme-moon { display: none; } }
body.bare { min-height: 100vh; display: grid; place-items: center; }
.bare-main { width: min(400px, calc(100vw - 32px)); }

@media (max-width: 900px) {
  body.app { grid-template-columns: 1fr; }
  .side { position: fixed; inset: 0 auto 0 0; width: 260px; z-index: 20; transform: translateX(-105%); transition: transform .2s; box-shadow: var(--shadow); }
  body.side-open .side { transform: none; }
  .backdrop { display: block; position: fixed; inset: 0; z-index: 15; background: rgba(0, 0, 0, .35); opacity: 0; pointer-events: none; transition: opacity .2s; }
  body.side-open .backdrop { opacity: 1; pointer-events: auto; }
  .menu { display: inline-grid; }
  .topbar, .content { padding-left: 16px; padding-right: 16px; }
}

/* ---------- pieces ---------- */
.pill { display: inline-flex; align-items: center; gap: 7px; padding: 4px 11px; border-radius: 999px; font-size: 12.5px;
  background: var(--surface); border: 1px solid var(--line); color: var(--text-2); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.pill.ok .dot { background: var(--good); }
.pill.bad .dot { background: var(--critical); }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px 20px; }
.card + .card, .grid + .card, .card + .grid, .grid + .grid, .card + h2, .grid + h2 { margin-top: 18px; }
/* Grid items line up by the grid gap, never by sibling margins. */
.grid > * { margin-top: 0 !important; min-width: 0; }
.card-head { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 6px 12px; margin-bottom: 10px; }
.card-head h2 { margin: 0; display: flex; align-items: center; gap: 8px; }
.card-head > .muted { text-align: right; }
.page-head { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px 16px; margin-bottom: 16px; }
.page-head p { margin: 0; flex: 1 1 320px; }
.grid { display: grid; gap: 16px; }
.grid.kpis { grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); }
.grid.two { grid-template-columns: repeat(auto-fill, minmax(min(100%, 460px), 1fr)); }
.grid.three { grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr)); }

.kpi { display: flex; flex-direction: column; gap: 4px; color: var(--text); min-height: 150px; }
a.kpi:hover { text-decoration: none; border-color: var(--accent); }
.kpi .k { font-size: 12.5px; color: var(--text-2); display: flex; align-items: center; gap: 7px; }
.kpi .v { font-size: clamp(22px, 2.2vw, 28px); overflow-wrap: anywhere; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: -.02em; line-height: 1.15; }
.kpi .v small { font-size: 14px; font-weight: 500; color: var(--text-2); margin-left: 3px; }
.kpi .sub { font-size: 12.5px; color: var(--muted); }
.kpi .spark { height: 36px; margin-top: auto; padding-top: 6px; background: transparent; }

.status { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 999px; }
.status svg { width: 13px; height: 13px; stroke-width: 2.4; }
.status.good { color: var(--good-text); background: color-mix(in srgb, var(--good) 14%, transparent); }
.status.warning { color: var(--text); background: color-mix(in srgb, var(--warning) 28%, transparent); }
.status.critical { color: var(--critical-text); background: color-mix(in srgb, var(--critical) 14%, transparent); }

.health-row .card-head { margin-bottom: 0; }
.health-row .muted { margin-top: 4px; }
.meter { height: 6px; border-radius: 6px; background: var(--grid); overflow: hidden; margin-top: 6px; }
.meter span { display: block; height: 100%; border-radius: 6px; background: var(--series-1); }
.meter.warning span { background: var(--warning); }
.meter.critical span { background: var(--critical); }

.badge { display: inline-block; font-size: 11.5px; font-weight: 600; padding: 2px 8px; border-radius: 999px; background: var(--surface-2); color: var(--text-2); border: 1px solid var(--line); }
.badge.ok { color: var(--good-text); background: color-mix(in srgb, var(--good) 12%, transparent); border-color: transparent; }
.badge.bad { color: var(--critical-text); background: color-mix(in srgb, var(--critical) 12%, transparent); border-color: transparent; }

/* tables */
.scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em;
  padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 9px 10px; border-bottom: 1px solid var(--grid); vertical-align: middle; }
tbody tr:hover { background: var(--surface-2); }
tr.empty td { text-align: center; padding: 22px; }
tr.banned td { opacity: .6; }
td.actions { white-space: nowrap; text-align: right; }
td.actions form { display: inline; }
td.notes { max-width: 280px; white-space: pre-wrap; color: var(--text-2); }
/* Tighten on the wrapper: a negative margin on the table itself would
   overflow the scroll box and show a vertical scrollbar. */
.card > .scroll { margin: -4px 0; }

/* forms */
input, select, textarea { font: inherit; color: var(--text); background: var(--surface-2); border: 1px solid var(--line);
  border-radius: 9px; padding: 8px 11px; outline: none; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
button { font: inherit; cursor: pointer; border-radius: 9px; border: 1px solid var(--line); background: var(--surface); color: var(--text); padding: 8px 14px; font-weight: 500; }
button:hover { border-color: var(--accent); }
button.primary, form.upload > div > button, .login button { background: var(--accent); color: #fff; border-color: transparent; }
button.small { padding: 4px 10px; font-size: 12.5px; }
button.danger { color: var(--critical-text); }
button.link { border: 0; background: none; padding: 0; color: var(--accent); }
.icon-btn { display: inline-grid; place-items: center; padding: 7px; border: 0; background: transparent; color: var(--text-2); border-radius: 9px; }
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
form.inline { display: flex; gap: 6px; }
form.inline input { padding: 5px 9px; min-width: 120px; }
.search { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.search input { flex: 1; min-width: 200px; }
.upload { display: grid; gap: 12px; max-width: 640px; }
.upload label { display: grid; gap: 5px; font-weight: 500; font-size: 13px; }
.upload .row { display: flex; gap: 8px; }
/* release history */
.releases { display: grid; gap: 10px; }
.release { border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; background: var(--surface-2); }
.release-head { display: flex; align-items: center; gap: 8px 10px; flex-wrap: wrap; margin-bottom: 8px; }
.release-head h3 { margin: 0; font-size: 15px; font-variant-numeric: tabular-nums; }
.release-del { margin-left: auto; }
button.ghost { background: transparent; border-color: transparent; }
.release-notes { display: flex; gap: 8px; align-items: flex-end; }
.release-notes textarea { flex: 1; min-width: 0; resize: vertical; background: var(--surface); }
@media (max-width: 640px) { .release-notes { flex-direction: column; align-items: stretch; } }
.add-release { margin-top: 14px; }
.add-release summary { cursor: pointer; color: var(--accent); font-weight: 500; }
.add-release form { margin-top: 10px; }
.plats { border: 0; padding: 0; margin: 0; display: flex; gap: 6px 16px; flex-wrap: wrap; }
.plats legend { font-weight: 500; font-size: 13px; margin-bottom: 5px; padding: 0; }
.upload label.check { display: flex; align-items: center; gap: 6px; font-weight: 400; }
.login { display: grid; gap: 14px; padding: 28px; }
.login h1 { margin: 0 0 4px; font-size: 20px; display: flex; align-items: center; gap: 10px; }
.login label { display: grid; gap: 6px; font-size: 13px; font-weight: 500; }
.error { color: var(--critical-text); }
.warn { padding: 10px 14px; border-radius: 10px; background: color-mix(in srgb, var(--warning) 18%, transparent); }
.notice { padding: 10px 14px; border-radius: 10px; background: var(--accent-soft); }
.pager { display: flex; gap: 14px; align-items: center; justify-content: center; margin-top: 14px; }

/* segmented control */
.seg { display: inline-flex; background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; padding: 3px; }
.seg button { border: 0; background: transparent; padding: 5px 12px; border-radius: 7px; font-size: 13px; color: var(--text-2); }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }

/* ---------- charts ---------- */
.chart { position: relative; background: var(--chart-surface); }
.chart svg { width: 100%; height: 100%; display: block; overflow: visible; stroke: none; }
.chart .grid-line { stroke: var(--grid); stroke-width: 1; }
.chart .axis-label { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.chart .series { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .area { opacity: .1; }
.chart .cross { stroke: var(--text-2); stroke-width: 1; stroke-dasharray: 3 3; }
.chart .hover-dot { stroke: var(--chart-surface); stroke-width: 2; }
.chart .empty-msg { fill: var(--muted); font-size: 13px; }
.chart-wrap { height: 220px; }
.legend { display: flex; flex-wrap: wrap; gap: 14px; font-size: 12.5px; color: var(--text-2); margin: -2px 0 8px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 14px; height: 3px; border-radius: 2px; display: inline-block; }
.chart-wrap { touch-action: pan-y; }
.tip { position: absolute; pointer-events: none; z-index: 3; background: var(--surface); border: 1px solid var(--line);
  border-radius: 10px; box-shadow: var(--shadow); padding: 8px 10px; font-size: 12.5px; white-space: nowrap; }
.tip b { display: block; font-weight: 600; margin-bottom: 3px; color: var(--text); }
.tip .row { display: flex; align-items: center; gap: 8px; color: var(--text-2); }
.tip .row i { width: 10px; height: 3px; border-radius: 2px; }
.tip .row em { font-style: normal; margin-left: auto; padding-left: 14px; color: var(--text); font-variant-numeric: tabular-nums; font-weight: 600; }
details.data { margin-top: 8px; font-size: 12.5px; }
details.data summary { cursor: pointer; color: var(--muted); }
details.data table { margin-top: 6px; }
details.data td, details.data th { padding: 4px 8px; }

/* ---------- info lists / guide ---------- */
dl.kv { display: grid; grid-template-columns: minmax(120px, max-content) minmax(0, 1fr); gap: 7px 18px; margin: 0; }
dl.kv dt { color: var(--muted); }
dl.kv dd { margin: 0; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; min-width: 0; }
@media (max-width: 560px) { dl.kv { grid-template-columns: 1fr; gap: 2px; } dl.kv dd { margin-bottom: 8px; } }
.guide p { color: var(--text-2); max-width: 900px; }
.guide h2 { margin-top: 4px; }
.guide .steps { counter-reset: s; list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
.guide .steps li { counter-increment: s; position: relative; padding-left: 34px; }
.guide .steps li::before { content: counter(s); position: absolute; left: 0; top: 0; width: 22px; height: 22px; border-radius: 50%;
  background: var(--accent-soft); color: var(--accent); font-weight: 700; font-size: 12px; display: grid; place-items: center; }
.cmd-wrap { position: relative; margin: 8px 0 0; }
.cmd-wrap pre.cmd { margin: 0; padding-right: 84px; }
.cmd-wrap > button { position: absolute; top: 8px; right: 8px; font-size: 12px; padding: 3px 10px; }
pre.cmd { position: relative; background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px;
  overflow-x: auto; font: 12.5px/1.55 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; margin: 8px 0 0; }
.flow { display: grid; grid-template-columns: 1fr auto 1fr auto 1fr; align-items: center; gap: 10px; text-align: center; margin: 6px 0 4px; }
.flow .node { border: 1px solid var(--line); border-radius: 12px; padding: 12px; background: var(--surface-2); }
.flow .node b { display: block; }
.flow .arrow { color: var(--muted); font-size: 12px; }
.flow .arrow .down { display: none; }
@media (max-width: 700px) { .flow { grid-template-columns: 1fr; } .flow .arrow .side-a { display: none; } .flow .arrow .down { display: inline; } }
