/* kls web pages: sign-in, the admin console, the backups page.
   One stylesheet, served by lab-auth at /auth/static/site.css.

   White by default (a switch picks dark), near-black text for legibility; colour is kept
   for meaning: green/amber/red for state, one blue for charts and links.
   IBM Plex Sans, tabular figures wherever numbers line up. */

@font-face { font-family:"Plex Sans"; src:url("/auth/static/plex-sans.woff2") format("woff2");
  font-weight:100 700; font-style:normal; font-display:swap; }
@font-face { font-family:"Plex Mono"; src:url("/auth/static/plex-mono.woff2") format("woff2");
  font-weight:500; font-style:normal; font-display:swap; }

:root {
  --bg:#ffffff; --surface:#ffffff; --sunk:#f8fafc;
  --text:#0f172a; --text-2:#334155; --muted:#64748b;
  --line:#e2e8f0; --line-2:#cbd5e1;
  --primary:#0f172a; --on-primary:#ffffff;
  --link:#1d4ed8; --chart:#2a78d6; --chart-fill:rgba(42,120,214,.12);
  --ok:#15803d; --ok-bg:#dcfce7; --warn:#b45309; --warn-bg:#fef3c7; --bad:#b91c1c; --bad-bg:#fee2e2;
  --focus:#2563eb;
  --sans:"Plex Sans", ui-sans-serif, system-ui, "Segoe UI", sans-serif;
  --mono:"Plex Mono", ui-monospace, "Cascadia Mono", Consolas, monospace;
  color-scheme:light;
}
/* Dark, when chosen with the switch (cookie lab_theme=dark; the server or the
   backups page's script sets data-theme on <html>). Light is the default. */
:root[data-theme="dark"] {
  --bg:#0f172a; --surface:#162032; --sunk:#1c2940;
  --text:#f1f5f9; --text-2:#cbd5e1; --muted:#94a3b8;
  --line:#26354d; --line-2:#36486a;
  --primary:#e2e8f0; --on-primary:#0f172a;
  --link:#93c5fd; --chart:#5b9ff0; --chart-fill:rgba(91,159,240,.16);
  --ok:#4ade80; --ok-bg:#12301f; --warn:#fbbf24; --warn-bg:#3a2c0b; --bad:#f87171; --bad-bg:#3b1618;
  --focus:#60a5fa;
  color-scheme:dark;
}
.theme-switch .when-dark { display:none; }
:root[data-theme="dark"] .theme-switch .when-light { display:none; }
:root[data-theme="dark"] .theme-switch .when-dark { display:inline-flex; }
.theme-switch span { display:inline-flex; }
.door-head { display:flex; align-items:center; justify-content:space-between; gap:12px; }

* { box-sizing:border-box; }
html { -webkit-text-size-adjust:100%; }
body { margin:0; background:var(--bg); color:var(--text); font:400 15px/1.5 var(--sans);
  -webkit-font-smoothing:antialiased; }
a { color:var(--link); text-underline-offset:3px; }
h1, h2, h3 { margin:0; font-weight:600; line-height:1.25; }
p { margin:0; }
.muted { color:var(--muted); }
.small { font-size:13px; }
.num { font-variant-numeric:tabular-nums; }
:focus-visible { outline:2px solid var(--focus); outline-offset:2px; border-radius:4px; }
svg.i { width:16px; height:16px; flex:none; stroke:currentColor; fill:none; stroke-width:2;
  stroke-linecap:round; stroke-linejoin:round; }
.stack > * + * { margin-top:16px; }
.sr { position:absolute; width:1px; height:1px; overflow:hidden; clip-path:inset(50%); white-space:nowrap; }
.scroll-x { overflow-x:auto; }
fieldset.access { border:0; margin:0; padding:0; min-width:0; }
fieldset.access legend { padding:0; }

/* the lab's mark */
.mast { display:flex; align-items:center; gap:10px; color:var(--text); text-decoration:none; }
.mast .seal { width:30px; height:30px; border-radius:6px; background:var(--primary); color:var(--on-primary);
  display:grid; place-items:center; font-weight:600; font-size:12.5px; flex:none; }
.mast .lab { font-weight:600; font-size:14px; line-height:1.2; }
.mast .lab span { display:block; font-weight:400; font-size:12.5px; color:var(--muted); }

/* -- controls ----------------------------------------------------------------- */

.btn { display:inline-flex; align-items:center; justify-content:center; gap:7px; min-height:36px;
  padding:0 14px; border-radius:6px; border:1px solid var(--line-2); background:var(--surface);
  color:var(--text); font:500 14px/1 var(--sans); cursor:pointer; text-decoration:none; white-space:nowrap; }
.btn:hover { background:var(--sunk); }
.btn:disabled { opacity:.5; cursor:not-allowed; }
.btn-primary { background:var(--primary); border-color:var(--primary); color:var(--on-primary); }
.btn-primary:hover { background:var(--primary); opacity:.9; }
.btn-quiet { border-color:transparent; background:transparent; color:var(--text-2); }
.btn-quiet:hover { background:var(--sunk); }
.btn-danger { color:var(--bad); border-color:transparent; background:transparent; }
.btn-danger:hover { background:var(--bad-bg); }
.btn-wide { width:100%; min-height:44px; font-size:15px; }
.btn-icon { width:36px; padding:0; }

.field { display:block; font-weight:500; font-size:13.5px; color:var(--text-2); margin:0 0 6px; }
.field .opt { font-weight:400; color:var(--muted); }
.input { width:100%; min-height:42px; padding:0 12px; border-radius:6px; border:1px solid var(--line-2);
  background:var(--surface); color:var(--text); font:400 15px var(--sans); }
.input:focus { outline:none; border-color:var(--focus); box-shadow:0 0 0 3px color-mix(in srgb, var(--focus) 25%, transparent); }
.input:disabled { background:var(--sunk); color:var(--muted); }
.hint { font-size:13px; color:var(--muted); margin-top:6px; }
.code { min-height:58px; font:500 26px/1 var(--mono); letter-spacing:.4em; padding-left:.55em;
  font-variant-numeric:tabular-nums; }

.alert { display:flex; gap:10px; align-items:flex-start; padding:10px 12px; border-radius:6px; font-size:14px; }
.alert svg { margin-top:2px; }
.alert-bad { background:var(--bad-bg); color:var(--bad); }
.alert-ok { background:var(--ok-bg); color:var(--ok); }

/* -- sign-in ------------------------------------------------------------------- */

.door { min-height:100vh; min-height:100dvh; display:grid; grid-template-rows:auto 1fr auto;
  padding:24px clamp(16px, 5vw, 56px) 0; overflow:hidden; }
.door main { align-self:center; width:100%; max-width:400px; margin:40px auto 56px; }
.door h1 { font-size:28px; letter-spacing:-.015em; }
.door .lede { font-size:15.5px; color:var(--text-2); margin-top:8px; }
.door .lede strong { color:var(--text); font-weight:600; overflow-wrap:anywhere; }
.door form { margin-top:24px; }
.door .after { margin-top:20px; font-size:13.5px; color:var(--muted); display:flex; gap:4px 16px; flex-wrap:wrap; }
.trace { display:block; width:calc(100% + 2 * clamp(16px, 5vw, 56px)); margin:0 calc(-1 * clamp(16px, 5vw, 56px));
  height:clamp(80px, 16vh, 150px); }
.trace path { fill:none; stroke:var(--line-2); stroke-width:1.5; vector-effect:non-scaling-stroke; }
.trace path.base { stroke:var(--line); stroke-width:1; }

/* -- console and the backups page ------------------------------------------------ */

.bar { border-bottom:1px solid var(--line); background:var(--surface); position:sticky; top:0; z-index:5; }
.bar-in { max-width:1200px; margin:0 auto; padding:0 24px; min-height:56px; display:flex; align-items:center; gap:20px; }
.tabs { display:flex; gap:4px; align-self:stretch; }
.tabs a { display:flex; align-items:center; padding:0 12px; color:var(--text-2); text-decoration:none; font-weight:500;
  font-size:14px; border-bottom:2px solid transparent; margin-bottom:-1px; }
.tabs a:hover { color:var(--text); }
.tabs a[aria-current="page"] { color:var(--text); border-bottom-color:var(--text); }
.spacer { flex:1; }
.who { display:flex; align-items:center; gap:6px; font-size:13.5px; color:var(--muted); }
.who b { color:var(--text); font-weight:600; }
.sheet { max-width:1200px; margin:0 auto; padding:24px 24px 64px; }
.notice { margin-bottom:16px; max-width:640px; }

.panel { background:var(--surface); border:1px solid var(--line); border-radius:8px; }
main > .panel, main > .grid { margin-top:16px; }
main > :first-child { margin-top:0; }
.panel-head { display:flex; align-items:center; gap:12px; flex-wrap:wrap; padding:12px 16px;
  border-bottom:1px solid var(--line); min-height:52px; }
.panel-head h2 { font-size:15px; }
.panel-head .count { color:var(--muted); font-size:14px; font-variant-numeric:tabular-nums; }
.panel-head .aside { color:var(--muted); font-size:13px; }
.panel-body { padding:12px 16px; }
.grid { display:grid; gap:16px; }
.grid-2 { grid-template-columns:1fr 1fr; }
.grid-4 { grid-template-columns:repeat(4, minmax(0, 1fr)); }

/* overall state: a list of what is wrong, or one line saying nothing is */
.health { display:flex; align-items:flex-start; gap:12px; padding:14px 16px; border-radius:8px; border:1px solid; }
.health.ok { background:var(--ok-bg); border-color:color-mix(in srgb, var(--ok) 30%, transparent); color:var(--ok); }
.health.warn { background:var(--warn-bg); border-color:color-mix(in srgb, var(--warn) 35%, transparent); color:var(--warn); }
.health.bad { background:var(--bad-bg); border-color:color-mix(in srgb, var(--bad) 35%, transparent); color:var(--bad); }
.health svg { width:20px; height:20px; margin-top:1px; }
.health h2 { font-size:15px; }
.health ul { margin:6px 0 0; padding:0; list-style:none; color:var(--text); }
.health li { display:flex; gap:8px; align-items:baseline; padding:2px 0; font-size:14px; }
.health .when { color:var(--text-2); font-size:13px; margin-top:2px; }

/* metric tiles: the current value and the last 24 hours behind it */
.tile { padding:14px 16px 10px; }
.tile .k { font-size:13px; font-weight:500; color:var(--text-2); }
.tile .v { font-size:26px; font-weight:600; letter-spacing:-.01em; font-variant-numeric:tabular-nums; margin-top:2px; }
.tile .v small { font-size:14px; font-weight:400; color:var(--muted); margin-left:4px; }
.tile .s { font-size:12.5px; color:var(--muted); font-variant-numeric:tabular-nums; }
.spark { display:block; width:100%; height:52px; margin-top:8px; overflow:visible; }
.spark .area { fill:var(--chart-fill); stroke:none; }
.spark .line { fill:none; stroke:var(--chart); stroke-width:2; vector-effect:non-scaling-stroke; stroke-linejoin:round; }
.spark .grid-line { stroke:var(--line); stroke-width:1; vector-effect:non-scaling-stroke; stroke-dasharray:3 3; }
.spark .hit { fill:transparent; }
.spark .hit:hover { fill:color-mix(in srgb, var(--chart) 18%, transparent); }
.spark-axis { display:flex; justify-content:space-between; font-size:11.5px; color:var(--muted); margin-top:2px; }
.nodata { height:52px; margin-top:8px; display:grid; place-items:center; font-size:12.5px; color:var(--muted);
  border:1px dashed var(--line-2); border-radius:6px; }

/* tables */
table.rows { width:100%; border-collapse:collapse; }
.rows th { text-align:left; font-size:12.5px; font-weight:500; color:var(--muted); padding:8px 16px;
  border-bottom:1px solid var(--line); background:var(--sunk); white-space:nowrap; }
.rows td { padding:10px 16px; border-bottom:1px solid var(--line); vertical-align:middle; font-size:14px; }
.rows tr:last-child td { border-bottom:0; }
.rows tbody tr:hover td { background:var(--sunk); }
.right { text-align:right; }
.nowrap { white-space:nowrap; }

/* state: a coloured dot plus a word, never colour alone */
.state { display:inline-flex; align-items:center; gap:7px; font-size:13.5px; font-weight:500; white-space:nowrap; }
.state::before { content:""; width:8px; height:8px; border-radius:50%; background:currentColor; flex:none; }
.state-ok { color:var(--ok); } .state-warn { color:var(--warn); } .state-bad { color:var(--bad); }
.state-idle { color:var(--muted); }

/* disk meters */
.meter { height:8px; border-radius:4px; background:var(--sunk); overflow:hidden; min-width:120px; }
.meter i { display:block; height:100%; background:var(--chart); border-radius:4px; }
.meter.warn i { background:var(--warn); } .meter.bad i { background:var(--bad); }
.meter-cell { width:40%; }
.meter i.w0 { width:0%; } .meter i.w5 { width:5%; } .meter i.w10 { width:10%; } .meter i.w15 { width:15%; } .meter i.w20 { width:20%; } .meter i.w25 { width:25%; } .meter i.w30 { width:30%; } .meter i.w35 { width:35%; } .meter i.w40 { width:40%; } .meter i.w45 { width:45%; } .meter i.w50 { width:50%; } .meter i.w55 { width:55%; } .meter i.w60 { width:60%; } .meter i.w65 { width:65%; } .meter i.w70 { width:70%; } .meter i.w75 { width:75%; } .meter i.w80 { width:80%; } .meter i.w85 { width:85%; } .meter i.w90 { width:90%; } .meter i.w95 { width:95%; } .meter i.w100 { width:100%; }

/* key facts */
.facts { display:grid; grid-template-columns:repeat(auto-fill, minmax(180px, 1fr)); gap:0; margin:0; }
.facts div { padding:10px 16px; border-bottom:1px solid var(--line); }
.facts dt { font-size:12.5px; color:var(--muted); }
.facts dd { margin:2px 0 0; font-size:14px; font-weight:500; font-variant-numeric:tabular-nums; }

/* people */
.person { display:flex; align-items:center; gap:10px; min-width:0; }
.initials { width:32px; height:32px; border-radius:50%; display:grid; place-items:center; flex:none;
  font-size:12px; font-weight:600; color:var(--text-2); background:var(--sunk); border:1px solid var(--line); }
.person .n { font-weight:600; }
.person .e { font-size:13px; color:var(--muted); overflow-wrap:anywhere; }
.person .note { font-size:13px; color:var(--text-2); }
.tags { display:flex; flex-wrap:wrap; gap:6px; }
.tag { display:inline-flex; align-items:center; min-height:24px; padding:0 8px; border-radius:4px;
  font-size:12.5px; font-weight:500; background:var(--sunk); color:var(--text-2); border:1px solid var(--line); }
.tag-all { background:var(--primary); border-color:var(--primary); color:var(--on-primary); }
.search { position:relative; }
.search svg { position:absolute; left:10px; top:11px; color:var(--muted); width:15px; height:15px; }
.search .input { min-height:36px; padding-left:32px; width:240px; font-size:14px; }

/* activity */
.feed { list-style:none; margin:0; padding:0; }
.feed li { display:grid; grid-template-columns:18px 1fr auto; gap:10px; align-items:baseline;
  padding:9px 16px; border-bottom:1px solid var(--line); font-size:14px; }
.feed li:last-child { border-bottom:0; }
.feed li svg { width:15px; height:15px; color:var(--muted); position:relative; top:2px; }
.feed .d { color:var(--muted); font-size:13px; overflow-wrap:anywhere; }
.feed .when { color:var(--muted); font-size:13px; white-space:nowrap; font-variant-numeric:tabular-nums; }
.feed .none { display:block; color:var(--muted); }
.panel-foot { padding:10px 16px; border-top:1px solid var(--line); font-size:13.5px; color:var(--muted);
  display:flex; justify-content:space-between; gap:12px; flex-wrap:wrap; align-items:center; }
.empty { padding:32px 16px; max-width:52ch; }
.empty h3 { font-size:15px; margin-bottom:4px; }
.empty p { color:var(--text-2); }
.empty .btn { margin-top:14px; }
.foot { margin-top:20px; font-size:13px; color:var(--muted); max-width:80ch; }

/* dialogs */
dialog { border:1px solid var(--line-2); padding:0; border-radius:10px; background:var(--surface); color:var(--text);
  box-shadow:0 20px 50px -20px rgba(15, 23, 42, .5); width:min(560px, calc(100vw - 24px));
  max-height:calc(100dvh - 32px); }
dialog::backdrop { background:rgba(15, 23, 42, .5); }
.dlg-head { display:flex; align-items:center; gap:10px; padding:16px 20px 4px; }
.dlg-head h3 { font-size:17px; flex:1; }
.dlg-body { padding:14px 20px 20px; }
.dlg-foot { display:flex; gap:8px; justify-content:flex-end; align-items:center; flex-wrap:wrap;
  padding:12px 20px; border-top:1px solid var(--line); background:var(--sunk); border-radius:0 0 10px 10px; }
.dlg-foot .left { margin-right:auto; display:flex; gap:4px; flex-wrap:wrap; }
.pair { display:grid; grid-template-columns:1fr 1fr; gap:14px; }

.choice { display:grid; grid-template-columns:1fr 1fr; gap:8px; }
.choice input { position:absolute; opacity:0; pointer-events:none; }
.choice label { display:block; padding:10px 12px; border:1px solid var(--line-2); border-radius:6px; cursor:pointer;
  font-weight:600; font-size:14px; }
.choice label small { display:block; font-weight:400; font-size:12.5px; color:var(--muted); margin-top:2px; }
.choice input:checked + label { border-color:var(--focus); box-shadow:inset 0 0 0 1px var(--focus); }
.choice input:focus-visible + label { outline:2px solid var(--focus); outline-offset:2px; }
.picks { display:none; flex-wrap:wrap; gap:8px; margin-top:10px; }
.access:has(input[value=some]:checked) .picks { display:flex; }
.pick { position:relative; }
.pick input { position:absolute; opacity:0; }
.pick span { display:inline-flex; align-items:center; gap:8px; min-height:34px; padding:0 12px; border-radius:6px;
  border:1px solid var(--line-2); font-size:14px; font-weight:500; cursor:pointer; color:var(--text-2); }
.pick span::before { content:""; width:14px; height:14px; border-radius:3px; border:1.5px solid var(--line-2); flex:none; }
.pick input:checked + span { border-color:var(--focus); color:var(--text); }
.pick input:checked + span::before { background:var(--focus); border-color:var(--focus); }
.pick input:focus-visible + span { outline:2px solid var(--focus); outline-offset:2px; }
.switch { display:flex; align-items:center; justify-content:space-between; gap:16px; padding:12px 0 0;
  border-top:1px solid var(--line); }
.switch .t { font-weight:600; font-size:14px; }
.switch .d { font-size:13px; color:var(--muted); }
.toggle { position:relative; width:40px; height:24px; flex:none; }
.toggle input { opacity:0; width:100%; height:100%; position:absolute; margin:0; cursor:pointer; z-index:1; }
.toggle i { position:absolute; inset:0; border-radius:12px; background:var(--line-2); transition:background .15s; }
.toggle i::after { content:""; position:absolute; top:3px; left:3px; width:18px; height:18px; border-radius:50%;
  background:#fff; transition:transform .15s; }
.toggle input:checked + i { background:var(--bad); }
.toggle input:checked + i::after { transform:translateX(16px); }
.toggle input:focus-visible + i { outline:2px solid var(--focus); outline-offset:2px; }

/* backups page */
.report-kind { font-weight:600; }
.report-sum { color:var(--muted); font-size:13px; }

@media (max-width: 980px) {
  .grid-4 { grid-template-columns:repeat(2, minmax(0, 1fr)); }
  .grid-2 { grid-template-columns:1fr; }
  .hide-md { display:none; }
}
@media (max-width: 600px) {
  .bar-in, .sheet { padding-left:16px; padding-right:16px; }
  .bar-in { gap:10px; }
  .grid-4 { grid-template-columns:1fr; }
  .search, .search .input { width:100%; flex:1 1 100%; }
  .hide-sm, .who .as, .mast .lab { display:none; }
  .pair, .choice { grid-template-columns:1fr; }
  .rows th, .rows td { padding-left:12px; padding-right:12px; }
}
@media (prefers-reduced-motion: reduce) { * { transition:none !important; } }
