/* NRTH PROXY customer web — base: fonts, Polar tokens, reset, header, footer, controls,
   tables, readouts, dialogs. Shares the NRTH "Polar Day / Polar Night instrument log" system
   (NRTHMAIL SPEC §7). Night is the default; Day is the stored choice. */

/* ---------- Fonts (self-hosted, latin + latin-ext) ---------- */
@font-face {
  font-family: "Schibsted Grotesk";
  font-style: normal;
  font-display: swap;
  font-weight: 400 900;
  src: url(../fonts/schibsted-grotesk-latin.woff2) format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Schibsted Grotesk";
  font-style: normal;
  font-display: swap;
  font-weight: 400 900;
  src: url(../fonts/schibsted-grotesk-latin-ext.woff2) format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "Schibsted Grotesk";
  font-style: italic;
  font-display: swap;
  font-weight: 400 900;
  src: url(../fonts/schibsted-grotesk-latin-italic.woff2) format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Schibsted Grotesk";
  font-style: italic;
  font-display: swap;
  font-weight: 400 900;
  src: url(../fonts/schibsted-grotesk-latin-ext-italic.woff2) format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "Martian Mono";
  font-style: normal;
  font-display: swap;
  font-weight: 100 800;
  font-stretch: 75% 112.5%;
  src: url(../fonts/martian-mono-latin.woff2) format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Martian Mono";
  font-style: normal;
  font-display: swap;
  font-weight: 100 800;
  font-stretch: 75% 112.5%;
  src: url(../fonts/martian-mono-latin-ext.woff2) format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

/* ---------- Tokens ---------- */
:root {
  --sans: "Schibsted Grotesk", "Helvetica Neue", Helvetica, sans-serif;
  --mono: "Martian Mono", ui-monospace, Menlo, Consolas, monospace;

  --fs-addr: clamp(1.375rem, 1rem + 3.4vw, 3.5rem);
  --fs-xl: clamp(1.75rem, 1.3rem + 1.6vw, 2.5rem);
  --fs-hero: clamp(2rem, 1.1rem + 2.7vw, 3.375rem);
  --fs-l: 1.375rem;
  --fs-m: 1.0625rem;
  --fs-body: 1rem;
  --fs-s: 0.875rem;
  --fs-xs: 0.8125rem;
  --fs-label: 0.6875rem;

  --radius: 0;
  --radius-s: 2px;

  --s1: 4px;
  --s2: 8px;
  --s3: 12px;
  --s4: 16px;
  --s5: 24px;
  --s6: 32px;
  --s7: 48px;
  --s8: 72px;
  --s9: 112px;

  --wrap: 1240px;
  --gutter: clamp(16px, 4vw, 40px);
  --header-h: 56px;
  --measure: 68ch;

  --t-fast: 120ms;
  --t-med: 220ms;
  --t-slow: 600ms;
  --ease: cubic-bezier(.2, .7, .1, 1);

  --z-header: 10;
  --z-menu: 20;
  --z-sheet: 40;
  --z-toast: 50;
}

:root,
:root[data-theme="night"] {
  color-scheme: dark;
  --bg: #0E1114;
  --paper: #151A1F;
  --ink: #E4E7E1;
  --ink-2: #A9B0B6;
  --ink-3: #868E96;
  --rule: #2A3138;
  --rule-2: #1F252B;
  --signal: #FF5F1A;
  --signal-ink: #0E1114;
  --signal-text: #FF8A4C;
  --ok: #7CC495;
  --warn: #E3B25A;
  --err: #FF8A80;
  --select: #5A2A10;
  --focus: 0 0 0 2px var(--bg), 0 0 0 4px var(--signal);
  --focus-inset: inset 0 0 0 2px var(--signal);
  --scrim: rgba(0, 0, 0, .6);
}
:root[data-theme="day"] {
  color-scheme: light;
  --bg: #EEF0EC;
  --paper: #F8F9F6;
  --ink: #111417;
  --ink-2: #41474D;
  --ink-3: #5E656C;
  --rule: #C5CAC4;
  --rule-2: #DADDD8;
  --signal: #FF4F00;
  --signal-ink: #111417;
  --signal-text: #B23A00;
  --ok: #2E6B45;
  --warn: #8A5A00;
  --err: #B3261E;
  --select: #FFD9C2;
  --focus: 0 0 0 2px var(--bg), 0 0 0 4px var(--signal), 0 0 0 5px var(--ink);
  --focus-inset: inset 0 0 0 2px var(--signal), inset 0 0 0 3px var(--ink);
  --scrim: rgba(17, 20, 23, .38);
}

/* ---------- Reset and base type ---------- */
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 100%;
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  font-kerning: normal;
  scroll-padding-top: calc(var(--header-h) + var(--s5));
  overflow-x: clip;
}
body {
  margin: 0;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  overflow-x: clip;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
main { flex: 1 0 auto; }
main:focus { outline: none; }
h1, h2, h3, h4, p, ul, ol, dl, dd, figure, pre, fieldset { margin: 0; }
fieldset { padding: 0; border: 0; min-width: 0; }
legend { padding: 0; }
ul, ol { padding: 0; }
img, svg { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; }
::selection { background: var(--select); color: var(--ink); }
b, strong { font-weight: 650; }
code, kbd, samp, pre { font-family: var(--mono); font-size: 0.875em; font-stretch: 100%; }
pre, .table-wrap, .lines-out { scrollbar-width: thin; scrollbar-color: var(--rule) transparent; }
a { color: var(--ink); text-decoration-line: underline; text-decoration-thickness: 1px; text-decoration-color: var(--ink-3); text-underline-offset: 3px; }
a:hover { text-decoration-color: var(--ink); text-decoration-thickness: 2px; }
:focus { outline: none; }
:focus-visible { outline: none; box-shadow: var(--focus); }
a:focus-visible { -webkit-box-decoration-break: clone; box-decoration-break: clone; }

.wrap { width: 100%; max-width: calc(var(--wrap) + 2 * var(--gutter)); margin-inline: auto; padding-inline: var(--gutter); }
.sr-only { position: absolute !important; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }

/* Engraved instrument label */
.label {
  font-family: var(--mono);
  font-size: var(--fs-label);
  font-weight: 500;
  font-stretch: 112.5%;
  line-height: 1.45;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--ink-3);
}
.label a { color: var(--ink-3); text-decoration-color: var(--rule); }
.label a:hover { color: var(--ink); }
.label .mono, .label a.mono { text-transform: none; letter-spacing: 0; }
.mono { font-family: var(--mono); font-stretch: 100%; font-variant-numeric: tabular-nums; }
.dim { color: var(--ink-3); }
.warn-text { color: var(--warn); }

.skip { position: absolute; display: inline-flex; align-items: center; min-height: 44px; left: var(--gutter); top: -100px; z-index: 100; padding: var(--s2) var(--s3); background: var(--ink); color: var(--bg); text-decoration: none; font-weight: 600; }
.skip:focus { top: var(--s2); }

/* ---------- Header ---------- */
.site-header { position: sticky; top: 0; z-index: var(--z-header); background: var(--bg); border-bottom: 1px solid var(--rule); }
.header-row { display: flex; align-items: center; height: var(--header-h); gap: var(--s6); }

.wordmark { display: inline-flex; align-items: center; min-height: 44px; color: var(--ink); text-decoration: none; flex: none; }
.wordmark:hover { text-decoration: none; }
.wm-nrth { font-family: var(--sans); font-weight: 800; font-size: 1.25rem; line-height: 1; letter-spacing: .015em; }
.wm-n { position: relative; margin-right: 5px; }
.wm-n::after { content: ""; position: absolute; top: .3em; right: -5px; width: 4px; height: 4px; background: var(--signal); }
.wm-rule { width: 1px; height: 20px; background: var(--ink); margin-inline: 11px 10px; }
.wm-product { font-family: var(--mono); font-weight: 500; font-size: .75rem; font-stretch: 112.5%; letter-spacing: .12em; line-height: 1; color: var(--ink-2); text-transform: uppercase; }

.menu { display: flex; align-items: center; flex: 1; gap: var(--s6); min-width: 0; }
.nav { display: flex; align-items: stretch; gap: var(--s5); height: var(--header-h); }
.nav a { display: inline-flex; align-items: center; gap: var(--s2); font-size: var(--fs-s); font-weight: 500; color: var(--ink-2); text-decoration: none; border-bottom: 2px solid transparent; padding-top: 2px; white-space: nowrap; }
.nav a:hover { color: var(--ink); }
.nav a[aria-current="page"] { color: var(--ink); border-bottom-color: var(--ink); }
.nav a:focus-visible { box-shadow: var(--focus-inset); }
.nav-live { display: none; width: 6px; height: 6px; border-radius: 50%; background: var(--signal); }
.nav-live.is-on { display: inline-block; animation: breathe 2.4s ease-in-out infinite; }
.panel-nav-mobile { display: none; }

.switches { margin-left: auto; display: flex; align-items: center; gap: var(--s4); }
.switch { display: flex; align-items: center; margin: 0; }
.switch-sep { color: var(--rule); font-family: var(--mono); font-size: var(--fs-label); }
.switch a, .switch button {
  display: inline-flex; align-items: center; min-height: 32px; padding: 0 6px;
  font-family: var(--mono); font-size: var(--fs-label); font-weight: 500; font-stretch: 112.5%; letter-spacing: .08em; text-transform: uppercase;
  color: var(--ink-3); background: none; border: 0; text-decoration: none;
}
.switch a:hover, .switch button:hover { color: var(--ink); }
.switch a[aria-current="true"],
:root[data-theme="day"] .switch [data-set-theme="day"],
:root[data-theme="night"] .switch [data-set-theme="night"] { color: var(--ink); text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 5px; }
.switch-session { gap: var(--s2); }
.switch-session .who { font-size: var(--fs-label); color: var(--ink-3); max-width: 18ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.switch .logout { color: var(--ink-2); }
.theme-icon { width: 16px; height: 16px; color: var(--ink-2); margin-right: 4px; flex: none; }
.theme-icon .sun-night { display: none; }
:root[data-theme="night"] .theme-icon .sun-day { display: none; }
:root[data-theme="night"] .theme-icon .sun-night { display: inline; }
.auth-links { display: flex; align-items: center; gap: var(--s4); }
.auth-login { font-size: var(--fs-s); font-weight: 500; color: var(--ink-2); text-decoration: none; white-space: nowrap; }
.auth-login:hover { color: var(--ink); text-decoration: underline; }

.menu-btn { display: none; align-items: center; min-height: 44px; margin-left: auto; padding: 0 0 0 var(--s4); background: none; border: 0; font-family: var(--mono); font-size: var(--fs-label); font-weight: 500; font-stretch: 112.5%; letter-spacing: .08em; text-transform: uppercase; color: var(--ink); }
.menu-btn-bars { display: inline-block; width: 14px; height: 7px; margin-left: 10px; border-block: 1px solid currentColor; }
[data-menu-open] .menu-btn-bars { height: 1px; border-bottom: 0; }

@media (max-width: 899.98px) {
  .header-row { gap: var(--s4); }
  .menu-btn { display: inline-flex; }
  .menu { display: none; position: fixed; top: var(--header-h); left: 0; right: 0; z-index: var(--z-menu); flex-direction: column; align-items: stretch; gap: 0; max-height: calc(100dvh - var(--header-h)); overflow-y: auto; padding: 0 var(--gutter) var(--s6); background: var(--bg); border-bottom: 1px solid var(--ink); }
  [data-menu-open] .menu { display: flex; }
  .nav { flex-direction: column; height: auto; gap: 0; }
  .nav a { min-height: 52px; font-size: var(--fs-m); font-weight: 600; color: var(--ink); border-bottom: 1px solid var(--rule); padding-top: 0; }
  .nav a[aria-current="page"] { border-bottom-color: var(--rule); }
  .nav a[aria-current="page"]::after { content: ""; width: 6px; height: 6px; margin-left: var(--s3); background: var(--ink); }
  .panel-nav-mobile { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 var(--s4); margin-top: var(--s4); border-top: 1px solid var(--ink); }
  .panel-nav-mobile a { display: flex; align-items: center; min-height: 48px; font-family: var(--mono); font-size: var(--fs-label); font-weight: 500; font-stretch: 112.5%; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-2); text-decoration: none; border-bottom: 1px solid var(--rule-2); }
  .panel-nav-mobile a[aria-current="page"] { color: var(--ink); }
  .panel-nav-mobile a[aria-current="page"]::before { content: ""; width: 6px; height: 6px; margin-right: var(--s3); background: var(--signal); }
  .switches { margin: var(--s5) 0 0; justify-content: space-between; flex-wrap: wrap; gap: var(--s3) var(--s4); }
  .switch a, .switch button { min-height: 44px; min-width: 44px; justify-content: center; padding: 0 var(--s2); }
  .switch-session { width: 100%; justify-content: space-between; }
  .auth-links { width: 100%; justify-content: space-between; }
  .auth-register { min-height: 44px; }
}
html:not(.js) .js-only { display: none !important; }
@media (max-width: 899.98px) {
  html:not(.js) .header-row { flex-wrap: wrap; height: auto; min-height: var(--header-h); column-gap: var(--s4); padding-block: var(--s2); }
  html:not(.js) .menu-btn { display: none; }
  html:not(.js) .menu { display: flex; position: static; flex-direction: row; flex-wrap: wrap; align-items: center; gap: 0 var(--s4); padding: 0; max-height: none; overflow: visible; background: none; border: 0; }
  html:not(.js) .nav { flex-direction: row; flex-wrap: wrap; height: auto; gap: var(--s4); }
  html:not(.js) .nav a { min-height: 44px; font-size: var(--fs-s); font-weight: 500; border-bottom: 0; }
  html:not(.js) .nav a[aria-current="page"]::after { display: none; }
  html:not(.js) .switches { margin: 0 0 0 auto; }
}

/* ---------- Impersonation banner ---------- */
.impersonation { background: var(--signal); color: var(--signal-ink); }
.impersonation-row { display: flex; align-items: center; justify-content: space-between; gap: var(--s4); min-height: 40px; padding-block: var(--s1); font-size: var(--fs-s); font-weight: 600; }
.impersonation .act { color: var(--signal-ink); }

/* ---------- Footer ---------- */
.site-footer { border-top: 1px solid var(--ink); margin-top: var(--s9); }
.footer-grid { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr) minmax(0, 1.2fr); gap: var(--s6) var(--s7); padding-block: var(--s6) var(--s7); }
.footer-col { min-width: 0; }
.wordmark-footer { min-height: 0; margin-bottom: var(--s3); }
.footer-line { font-size: var(--fs-s); color: var(--ink-2); max-width: 44ch; }
.footer-note { margin-top: var(--s3); font-size: var(--fs-s); color: var(--ink-3); max-width: 44ch; }
.footer-links { display: grid; gap: var(--s2); align-content: start; }
.footer-links a { font-size: var(--fs-s); color: var(--ink-2); text-decoration: none; width: fit-content; }
.footer-links a:hover { color: var(--ink); text-decoration: underline; }
.footer-meta { display: grid; gap: var(--s1); align-content: start; }
.footer-mail { font-size: var(--fs-s); }
.footer-company-label, .footer-year { margin-top: var(--s3); }
.footer-company { font-size: var(--fs-s); color: var(--ink-2); }
@media (max-width: 899.98px) { .footer-grid { grid-template-columns: minmax(0, 1fr); gap: var(--s5); } .site-footer { margin-top: var(--s8); } }

/* ---------- Controls ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: var(--s3); min-height: 44px; padding: 0 var(--s4); border: 1px solid var(--ink); border-radius: var(--radius); background: transparent; color: var(--ink); font-family: var(--sans); font-size: var(--fs-body); font-weight: 600; line-height: 1; text-decoration: none; white-space: nowrap; }
.btn:hover { background: var(--ink); color: var(--bg); text-decoration: none; }
.btn-primary { background: var(--ink); color: var(--bg); }
.btn-primary:hover { background: var(--ink-2); border-color: var(--ink-2); }
.btn-signal { background: var(--signal); border-color: var(--signal); color: var(--signal-ink); }
.btn-signal:hover { background: var(--ink); border-color: var(--ink); color: var(--bg); }
.btn-danger { border-color: var(--err); color: var(--err); }
.btn-danger:hover { background: var(--err); color: var(--bg); }
.btn-small { min-height: 36px; padding: 0 var(--s3); font-size: var(--fs-s); }
.btn:disabled { opacity: .45; pointer-events: none; }
.btn-text { display: inline-flex; align-items: center; gap: var(--s2); min-height: 44px; padding: 0 var(--s2); background: none; border: 0; color: var(--ink); font-weight: 500; text-decoration: underline; text-decoration-thickness: 1px; text-decoration-color: var(--ink-3); text-underline-offset: 4px; }
.btn-text:hover { text-decoration-color: var(--ink); text-decoration-thickness: 2px; }
.act { display: inline-flex; align-items: center; min-height: 32px; padding: 0 var(--s1); background: none; border: 0; font-family: var(--mono); font-size: var(--fs-label); font-weight: 500; font-stretch: 112.5%; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-2); text-decoration: none; white-space: nowrap; }
.act:hover { color: var(--ink); text-decoration: underline; text-underline-offset: 5px; text-decoration-thickness: 1px; }
.act-danger { color: var(--ink-3); }
.act-danger:hover { color: var(--err); }

.input { min-height: 44px; padding: 0 var(--s3); border: 1px solid var(--ink-3); border-radius: var(--radius-s); background: var(--paper); color: var(--ink); width: 100%; }
.input:focus-visible { border-color: var(--ink); }
.input[aria-invalid="true"] { border-color: var(--err); }
textarea.input { padding: var(--s2) var(--s3); min-height: 72px; resize: vertical; line-height: 1.45; }
select.input { padding-right: var(--s6); appearance: none; -webkit-appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--ink-2) 50%), linear-gradient(135deg, var(--ink-2) 50%, transparent 50%); background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%; background-size: 5px 5px; background-repeat: no-repeat; }
.input-code { font-size: var(--fs-l); letter-spacing: .18em; max-width: 14rem; }
::placeholder { color: var(--ink-3); opacity: 1; }
input[type="date"].input, input[type="number"].input { font-variant-numeric: tabular-nums; }
.input-row { display: flex; align-items: center; gap: var(--s3); }
.input-row .input { flex: 1 1 auto; min-width: 0; }

.field { display: grid; gap: var(--s2); align-content: start; }
.field > label, .fieldset > legend { font-weight: 600; font-size: var(--fs-s); }
.fieldset > legend.label { font-weight: 500; margin-bottom: var(--s2); }
.hint { font-size: var(--fs-s); color: var(--ink-3); line-height: 1.45; }
.field-error { font-size: var(--fs-s); color: var(--err); font-weight: 600; }
.readonly { min-height: 44px; display: flex; align-items: center; padding: 0 var(--s3); border: 1px solid var(--rule); color: var(--ink-2); background: transparent; }
.check { display: flex; align-items: flex-start; gap: var(--s3); min-height: 44px; font-weight: 600; font-size: var(--fs-s); cursor: pointer; }
.check input { width: 18px; height: 18px; margin: 3px 0 0; accent-color: var(--ink); flex: none; }
.radios { display: flex; flex-wrap: wrap; gap: var(--s2) var(--s5); }
.radio { display: inline-flex; align-items: center; gap: var(--s2); min-height: 40px; font-size: var(--fs-s); font-weight: 500; cursor: pointer; }
.radio input { width: 16px; height: 16px; margin: 0; accent-color: var(--ink); }
.form { display: grid; gap: var(--s5); padding-top: var(--s5); max-width: 760px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s5) var(--s6); }
.field-wide { grid-column: 1 / -1; }
.field-btn { align-self: end; }
.form-actions { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s3) var(--s4); }
.form-inline { display: inline-flex; margin: 0; }
.lines-out { width: 100%; padding: var(--s3) var(--s4); border: 1px solid var(--rule); background: var(--paper); color: var(--ink); font-size: var(--fs-xs); line-height: 1.7; resize: vertical; white-space: pre; overflow: auto; }

.copy { position: relative; }
.copy::after { content: ""; position: absolute; left: 0; right: 0; bottom: -4px; height: 2px; background: var(--signal); transform: scaleX(0); transform-origin: left center; pointer-events: none; }
.copy.is-copied::after { transform: scaleX(1); transition: transform var(--t-med) var(--ease); }
.btn-signal.copy.is-copied::after { background: var(--ink); }

/* ---------- Flash ---------- */
.flash { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s2) var(--s3); min-height: 44px; margin-top: var(--s4); padding: var(--s2) var(--s4); border: 1px solid var(--rule); border-left: 2px solid var(--ink); font-size: var(--fs-s); font-weight: 500; }
.flash a { color: var(--ink); }
.flash-ok { border-left-color: var(--ok); }
.flash-err { border-left-color: var(--err); color: var(--err); }
.flash-warn { border-left-color: var(--warn); }
form.flash .act { margin-left: auto; }

/* ---------- Page structure ---------- */
.main { padding-top: var(--s5); }
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: var(--s4) var(--s5); padding-bottom: var(--s4); border-bottom: 1px solid var(--ink); }
.page-title { display: flex; flex-wrap: wrap; align-items: baseline; gap: var(--s2) var(--s4); min-width: 0; }
.h1 { font-size: var(--fs-l); font-weight: 700; line-height: 1.15; letter-spacing: -.01em; display: inline-flex; align-items: center; gap: var(--s3); }
.h2 { font-size: var(--fs-m); font-weight: 700; line-height: 1.3; display: inline-flex; align-items: center; gap: var(--s3); }
.h1-display { margin-top: var(--s3); font-size: var(--fs-xl); font-weight: 750; line-height: 1.1; letter-spacing: -.02em; max-width: 22ch; }
.h2-display { margin-top: var(--s2); font-size: var(--fs-l); font-weight: 700; line-height: 1.2; letter-spacing: -.015em; max-width: 30ch; }
.page-count { font-size: var(--fs-xs); color: var(--ink-3); }
.section-sub { margin-top: var(--s3); font-size: var(--fs-m); color: var(--ink-2); max-width: 56ch; line-height: 1.5; }
.section-head { padding-bottom: var(--s5); }
.section-head-row { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: var(--s3) var(--s5); }
.page-head-block { padding-top: var(--s6); padding-bottom: var(--s5); border-bottom: 1px solid var(--ink); margin-bottom: var(--s5); }

.strip { display: flex; align-items: center; gap: var(--s3); min-height: 48px; border-bottom: 1px solid var(--rule); }
.strip-tight { min-height: 40px; }
.strip-meta { margin-left: auto; font-size: var(--fs-xs); color: var(--ink-3); }
.strip-link { margin-left: auto; display: inline-flex; align-items: center; min-height: 44px; font-size: var(--fs-s); color: var(--ink-2); white-space: nowrap; }
.strip-link:hover { color: var(--ink); }
.strip .act { margin-left: auto; }
.quiet { padding: var(--s4) 0; font-size: var(--fs-s); color: var(--ink-3); }
.quiet a { color: var(--ink-2); }

/* ---------- Readouts (instrument strip) ---------- */
.readouts { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); border-bottom: 1px solid var(--ink); }
.ro { display: grid; align-content: start; gap: var(--s2); min-width: 0; padding: var(--s4) var(--s3) var(--s4) 0; margin-left: var(--s4); border-left: 1px solid var(--rule); padding-left: var(--s4); }
.ro:first-child { margin-left: 0; border-left: 0; padding-left: 0; }
.ro .label { display: flex; align-items: center; gap: var(--s2); }
.ro-value { font-size: 1.375rem; font-weight: 500; line-height: 1.1; letter-spacing: -.02em; color: var(--ink); white-space: nowrap; }
.ro-value.ro-small { font-size: var(--fs-s); font-weight: 500; letter-spacing: 0; line-height: 1.5; white-space: normal; overflow-wrap: anywhere; }
.ro-text { font-family: var(--sans); font-size: var(--fs-m); font-weight: 600; letter-spacing: 0; display: flex; align-items: center; }
.ro-unit { font-size: var(--fs-xs); font-weight: 500; letter-spacing: 0; color: var(--ink-2); }
.ro-note { font-size: var(--fs-label); color: var(--ink-3); line-height: 1.45; }
.ro-note a { color: var(--ink-2); }
.ro-meter { margin-top: calc(-1 * var(--s1)); }
.ro-health.is-fail .ro-value { color: var(--err); }
.dot { display: inline-block; width: 8px; height: 8px; margin-right: var(--s2); border-radius: 50%; background: var(--ink-3); vertical-align: middle; flex: none; }
.dot.is-ok { background: var(--ok); }
.dot.is-fail { background: var(--err); }
.live { display: inline-block; flex: none; width: 8px; height: 8px; border-radius: 50%; background: var(--ink-3); vertical-align: middle; }
.live.is-on { background: var(--signal); animation: breathe 2.4s ease-in-out infinite; }
.live.is-off { background: var(--err); animation: none; }
.qbar { display: block; width: 100%; height: 2px; overflow: visible; }
.qbar-track { fill: var(--rule); }
.qbar-fill { fill: var(--ink); }
.qbar.is-hot .qbar-fill { fill: var(--signal); }

/* ---------- Facts ---------- */
.facts { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 0 var(--s5); }
.fact { display: grid; gap: 3px; padding: var(--s3) 0; border-bottom: 1px solid var(--rule-2); min-width: 0; }
.fact dd { font-size: var(--fs-s); overflow-wrap: anywhere; }
.fact-quota { grid-column: span 2; }
.fact-quota .qbar { margin-top: var(--s2); }
.fact-pct { color: var(--ink-3); }
.facts-tight { grid-template-columns: minmax(0, 1fr); gap: 0; }
.facts-tight .fact { grid-template-columns: 10rem minmax(0, 1fr); align-items: baseline; gap: var(--s3); }

/* ---------- Tables ---------- */
.table-wrap { width: 100%; overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th { padding: var(--s3) var(--s5) var(--s2) 0; border-bottom: 1px solid var(--rule); text-align: left; font-family: var(--mono); font-size: var(--fs-label); font-weight: 500; font-stretch: 112.5%; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-3); white-space: nowrap; vertical-align: bottom; }
.table td { padding: var(--s3) var(--s5) var(--s3) 0; border-bottom: 1px solid var(--rule-2); vertical-align: top; font-size: var(--fs-s); line-height: 1.4; }
.table th:last-child, .table td:last-child { padding-right: 0; }
.table .num { text-align: right; white-space: nowrap; }
.table td.mono { font-size: var(--fs-xs); }
.table tbody tr:hover { background: var(--paper); }
.row-empty td { color: var(--ink-3); padding-block: var(--s5); }
.uname { font-weight: 600; font-size: var(--fs-s); text-decoration: none; overflow-wrap: anywhere; }
.uname:hover { text-decoration: underline; }
.dname { display: block; font-size: var(--fs-xs); color: var(--ink-2); font-family: var(--sans); font-weight: 400; overflow-wrap: anywhere; }
.state { font-family: var(--mono); font-size: var(--fs-label); font-weight: 500; font-stretch: 112.5%; letter-spacing: .08em; text-transform: uppercase; white-space: nowrap; color: var(--ink-2); }
.state-disabled { color: var(--ink-3); }
.state-quota, .state-expired, .state-warn { color: var(--warn); }
.state-err { color: var(--err); }
.state-signal { color: var(--signal-text); }
.state-big { font-size: var(--fs-xs); }
.t-actions { white-space: nowrap; }
.t-actions-h { text-align: right; }
.acts { display: flex; justify-content: flex-end; align-items: center; gap: 0 var(--s3); }
.acts form { display: inline-flex; align-items: center; margin: 0; }
.quota-col { min-width: 160px; }
.quota-col .qbar { margin-bottom: var(--s2); }
.qtext { font-size: var(--fs-xs); white-space: nowrap; }
.is-credit { color: var(--ok); }

.toolbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--s3) var(--s5); padding: var(--s3) 0; border-bottom: 1px solid var(--rule); }
.tabs { display: flex; flex-wrap: wrap; gap: var(--s2) var(--s4); }
.tabs a { display: inline-flex; align-items: center; min-height: 36px; font-family: var(--mono); font-size: var(--fs-label); font-weight: 500; font-stretch: 112.5%; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-3); text-decoration: none; border-bottom: 1px solid transparent; }
.tabs a:hover { color: var(--ink); }
.tabs a[aria-current="true"] { color: var(--ink); border-bottom-color: var(--ink); }
.filters { justify-content: flex-start; align-items: flex-end; gap: var(--s4); }
.filter { display: grid; gap: var(--s1); flex: 0 1 220px; min-width: 160px; }
.filter .input { min-height: 36px; font-size: var(--fs-s); }
.filter-actions { display: flex; align-items: center; gap: var(--s4); }

/* ---------- Empty state: a line and ruled log paper ---------- */
.empty { padding: var(--s5) 0 var(--s4); }
.empty-line { font-size: var(--fs-s); color: var(--ink-2); max-width: 60ch; }
.empty-line a { color: var(--ink); }
.paper { display: grid; margin-top: var(--s4); }
.paper span { height: 44px; border-bottom: 1px solid var(--rule-2); }

/* ---------- Charts ---------- */
.charts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 var(--s7); margin-top: var(--s2); }
.chart { min-width: 0; }
.chart figcaption { width: 100%; }
.ch { height: 132px; margin-top: var(--s4); }
.ch-svg { width: 100%; height: 100%; overflow: visible; }
.ch-base { stroke: var(--rule); stroke-width: 1; }
.ch-bar { fill: var(--ink-2); }
.ch-bar:hover { fill: var(--ink); }
.ch-bar-now { fill: var(--signal); }
.ch-axis { display: flex; justify-content: space-between; gap: var(--s3); padding-top: var(--s2); font-size: var(--fs-label); color: var(--ink-3); }
.sp-svg { width: 100%; height: 100%; overflow: visible; }
.sp-line { fill: none; stroke: var(--ink); stroke-width: 1.25; stroke-linejoin: round; }
.sp-end { stroke: var(--signal); stroke-width: 6; stroke-linecap: square; }

/* ---------- Dialogs, toast ---------- */
dialog.dlg { width: min(520px, calc(100vw - 2 * var(--gutter))); max-height: calc(100dvh - 2 * var(--s6)); padding: 0; border: 1px solid var(--ink); border-radius: 0; background: var(--bg); color: var(--ink); box-shadow: none; overflow: auto; }
dialog.dlg::backdrop { background: rgba(0, 0, 0, .6); }
:root[data-theme="day"] dialog.dlg::backdrop { background: rgba(17, 20, 23, .38); }
.dlg-head { display: flex; align-items: center; justify-content: space-between; gap: var(--s4); padding: var(--s2) var(--s2) var(--s2) var(--s5); border-bottom: 1px solid var(--rule); }
.dlg-title { font-size: var(--fs-m); font-weight: 700; line-height: 1.3; }
.dlg-x { min-height: 44px; padding: 0 var(--s3); background: none; border: 0; font-family: var(--mono); font-size: var(--fs-label); font-weight: 500; font-stretch: 112.5%; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-2); }
.dlg-x:hover { color: var(--ink); }
.dlg-body { padding: var(--s5); display: grid; gap: var(--s4); }
.dlg-body p { max-width: 52ch; color: var(--ink-2); }
.dlg-actions { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: var(--s3) var(--s4); padding: 0 var(--s5) var(--s5); }
.dlg.is-danger .btn-primary { background: var(--err); border-color: var(--err); color: var(--bg); }
.toast { position: fixed; left: var(--gutter); bottom: var(--gutter); z-index: var(--z-toast); display: flex; align-items: center; gap: var(--s4); max-width: min(520px, calc(100vw - 2 * var(--gutter))); padding: var(--s3) var(--s4); background: var(--ink); color: var(--bg); font-size: var(--fs-s); line-height: 1.4; }

/* ---------- Prose (docs, legal, instructions) ---------- */
.prose { font-size: var(--fs-body); line-height: 1.6; color: var(--ink); }
.prose > * + * { margin-top: var(--s4); }
.prose p { max-width: var(--measure); }
.prose h2, .prose h3, .prose h4 { line-height: 1.25; letter-spacing: -.01em; }
.prose h2 { margin-top: var(--s7); font-size: var(--fs-l); font-weight: 700; padding-top: var(--s4); border-top: 1px solid var(--ink); }
.prose h3 { margin-top: var(--s6); font-size: var(--fs-m); font-weight: 700; }
.prose h4 { margin-top: var(--s5); font-size: var(--fs-body); font-weight: 700; }
.prose ul, .prose ol { padding-left: 1.25em; max-width: var(--measure); }
.prose li + li { margin-top: var(--s1); }
.prose code { padding: 1px 4px; background: var(--paper); border: 1px solid var(--rule-2); font-size: .85em; overflow-wrap: anywhere; }
.prose pre, .code { padding: var(--s3) var(--s4); background: var(--paper); border: 1px solid var(--rule); font-size: var(--fs-xs); line-height: 1.6; overflow-x: auto; }
.prose pre code { padding: 0; border: 0; background: none; font-size: inherit; }
.prose table { width: 100%; border-collapse: collapse; font-size: var(--fs-s); }
.prose th { padding: var(--s2) var(--s3) var(--s2) 0; border-bottom: 1px solid var(--rule); text-align: left; font-family: var(--mono); font-size: var(--fs-label); font-weight: 500; font-stretch: 112.5%; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-3); }
.prose td { padding: var(--s2) var(--s3) var(--s2) 0; border-bottom: 1px solid var(--rule-2); vertical-align: top; }
.prose a { color: var(--ink); }
.prose blockquote { margin: 0; padding-left: var(--s4); border-left: 2px solid var(--rule); color: var(--ink-2); }
.prose hr { border: 0; border-top: 1px solid var(--rule); }
.prose .method, .prose kbd { display: inline-block; padding: 1px 6px; border: 1px solid var(--ink); font-family: var(--mono); font-size: var(--fs-label); font-weight: 500; letter-spacing: .06em; text-transform: uppercase; }

/* ---------- Motion ---------- */
@keyframes breathe { 0%, 100% { opacity: 1; } 50% { opacity: .3; } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}

/* ---------- Mobile shared ---------- */
@media (max-width: 899.98px) {
  .main { padding-top: var(--s4); }
  .readouts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .ro { margin-left: 0; border-left: 0; padding-left: 0; padding-right: var(--s3); }
  .ro:nth-child(even) { margin-left: var(--s3); border-left: 1px solid var(--rule); padding-left: var(--s3); }
  .ro:nth-child(n+3) { border-top: 1px solid var(--rule); }
  .form-grid { grid-template-columns: minmax(0, 1fr); gap: var(--s4); }
  .form-actions .btn { width: 100%; }
  .form-actions .btn-text { width: 100%; justify-content: center; }
  .charts { grid-template-columns: minmax(0, 1fr); gap: var(--s4) 0; }
  .facts { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .facts-tight { grid-template-columns: minmax(0, 1fr); }
  .facts-tight .fact { grid-template-columns: minmax(0, 1fr); gap: 2px; }
  .fact-quota { grid-column: 1 / -1; }
  .page-head .btn { width: 100%; }
  .toolbar { align-items: stretch; }
  .tabs { width: 100%; flex-wrap: nowrap; gap: var(--s4); overflow-x: auto; scrollbar-width: none; }
  .tabs a { flex: none; }
  .filters .filter { flex: 1 1 100%; }
  .filter-actions { width: 100%; flex-wrap: wrap; }

  .table-wrap { overflow: visible; }
  .table thead { display: none; }
  .table, .table tbody, .table tr, .table td { display: block; }
  .table tr { padding: var(--s3) 0; border-bottom: 1px solid var(--rule); }
  .table tbody tr:hover { background: none; }
  .table td { display: grid; grid-template-columns: 6.5rem minmax(0, 1fr); gap: var(--s3); align-items: baseline; padding: var(--s1) 0; border: 0; text-align: left; }
  .table td::before { content: attr(data-l); font-family: var(--mono); font-size: var(--fs-label); font-weight: 500; font-stretch: 112.5%; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-3); line-height: 1.6; }
  .table td.num { text-align: left; }
  .table td > :not(.qbar):not(.acts) { grid-column: 2; }
  .table td[colspan] { grid-template-columns: minmax(0, 1fr); }
  .table td[colspan]::before { display: none; }
  .quota-col { min-width: 0; }
  .quota-col .qbar { grid-column: 2; order: 1; margin: var(--s2) 0 0; }
  .quota-col .qtext { grid-column: 2; }
  .table .t-actions { grid-template-columns: minmax(0, 1fr); white-space: normal; padding-top: var(--s3); }
  .table .t-actions::before { display: none; }
  .acts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s2); justify-content: stretch; }
  .acts form { display: grid; }
  .acts .act, .acts form { width: 100%; }
  .acts .act { min-height: 44px; justify-content: center; text-align: center; white-space: normal; line-height: 1.3; padding: var(--s2) var(--s3); border: 1px solid var(--rule); }
  .table-conns td, .table-live td { grid-template-columns: 5rem minmax(0, 1fr); }
}
@media (max-width: 559.98px) {
  .ro-value { font-size: 1.25rem; }
  .facts:not(.facts-tight) { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 var(--s4); }
}
