@import url("../fonts/fonts.css");
@import url("../vendor/uPlot.min.css");

/* ═══════════════════════════════════════════════════════════════════════
   Monitorly — "Instrument"

   The look borrows from lab test equipment rather than from network
   operations centres: quiet anodised surfaces, one saturated colour per
   state, and every measured number set in mono. The signature element is
   the tape — the seismograph strip of recent checks that repeats at three
   densities across the product.
   ═══════════════════════════════════════════════════════════════════════ */

:root {
    color-scheme: light;

    --bg: #eceef0;
    --bg-grain: #e5e8eb;
    --panel: #ffffff;
    --panel-2: #f5f7f8;
    --panel-3: #eef1f3;
    --line: #d3d8dd;
    --line-soft: #e4e8eb;

    --ink: #12181d;
    --ink-2: #3c4750;
    --ink-muted: #616d78;

    --up: #17795e;
    --up-bg: rgba(23, 121, 94, 0.11);
    --warn: #b5730a;
    --warn-bg: rgba(181, 115, 10, 0.13);
    --down: #be3a2b;
    --down-bg: rgba(190, 58, 43, 0.11);
    --idle: #7d8994;
    --idle-bg: rgba(125, 137, 148, 0.13);

    --accent: #0e7c8c;
    --accent-hover: #0b6674;
    --accent-ink: #ffffff;
    --accent-bg: rgba(14, 124, 140, 0.1);

    --shadow-1: 0 1px 2px rgba(16, 24, 32, 0.06);
    --shadow-2: 0 6px 24px -12px rgba(16, 24, 32, 0.3);
    --shadow-pop: 0 12px 40px -16px rgba(16, 24, 32, 0.4);

    --font-display: "Archivo", "Helvetica Neue", system-ui, sans-serif;
    --font-body: "Public Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
    --font-mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, monospace;

    --radius-sm: 4px;
    --radius: 8px;
    --radius-lg: 12px;

    --rail-width: 236px;
    --page-max: 1440px;
}

/* Dark mode arrives two ways: an explicit choice stamped on <html> by the
   server, and the visitor's system setting when they have not chosen. Both
   paths land on the same tokens. */

:root[data-theme="dark"] {
    color-scheme: dark;

    --bg: #0e1418;
    --bg-grain: #101820;
    --panel: #161d23;
    --panel-2: #1b242b;
    --panel-3: #202a32;
    --line: #26313a;
    --line-soft: #1e272e;

    --ink: #e6ebef;
    --ink-2: #bcc7d0;
    --ink-muted: #8a98a5;

    --up: #37c08c;
    --up-bg: rgba(55, 192, 140, 0.14);
    --warn: #f2b23c;
    --warn-bg: rgba(242, 178, 60, 0.14);
    --down: #f2685c;
    --down-bg: rgba(242, 104, 92, 0.15);
    --idle: #7c8b98;
    --idle-bg: rgba(124, 139, 152, 0.16);

    --accent: #2fcbd6;
    --accent-hover: #56dbe4;
    --accent-ink: #052128;
    --accent-bg: rgba(47, 203, 214, 0.14);

    --shadow-1: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow-2: 0 8px 28px -16px rgba(0, 0, 0, 0.8);
    --shadow-pop: 0 16px 44px -18px rgba(0, 0, 0, 0.9);
}

@media (prefers-color-scheme: dark) {
    :root[data-theme="system"],
    :root:not([data-theme]) {
        color-scheme: dark;

        --bg: #0e1418;
        --bg-grain: #101820;
        --panel: #161d23;
        --panel-2: #1b242b;
        --panel-3: #202a32;
        --line: #26313a;
        --line-soft: #1e272e;

        --ink: #e6ebef;
        --ink-2: #bcc7d0;
        --ink-muted: #8a98a5;

        --up: #37c08c;
        --up-bg: rgba(55, 192, 140, 0.14);
        --warn: #f2b23c;
        --warn-bg: rgba(242, 178, 60, 0.14);
        --down: #f2685c;
        --down-bg: rgba(242, 104, 92, 0.15);
        --idle: #7c8b98;
        --idle-bg: rgba(124, 139, 152, 0.16);

        --accent: #2fcbd6;
        --accent-hover: #56dbe4;
        --accent-ink: #052128;
        --accent-bg: rgba(47, 203, 214, 0.14);

        --shadow-1: 0 1px 2px rgba(0, 0, 0, 0.4);
        --shadow-2: 0 8px 28px -16px rgba(0, 0, 0, 0.8);
        --shadow-pop: 0 16px 44px -18px rgba(0, 0, 0, 0.9);
    }
}


*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    -webkit-text-size-adjust: 100%;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font-family: var(--font-body);
    font-size: 14px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

h1, h2, h3, h4 {
    font-family: var(--font-display);
    font-weight: 600;
    letter-spacing: -0.01em;
    margin: 0;
}

h1 { font-size: 22px; }
h2 { font-size: 17px; }
h3 { font-size: 15px; }

p { margin: 0 0 12px; }
p:last-child { margin-bottom: 0; }

a {
    color: var(--accent);
    text-decoration: none;
}

a:hover { text-decoration: underline; }

:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
    border-radius: 3px;
}

::selection {
    background: var(--accent);
    color: var(--accent-ink);
}

.icon {
    width: 18px;
    height: 18px;
    flex: none;
}

/* Eyebrows carry the instrument-panel voice: wide, small, engraved. */
.eyebrow {
    font-family: var(--font-display);
    font-variation-settings: "wdth" 118;
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--ink-muted);
    margin: 0;
}

.num {
    font-family: var(--font-mono);
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.02em;
}

.muted { color: var(--ink-muted); }
.nowrap { white-space: nowrap; }
.truncate {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
}

/* ── Shell ──────────────────────────────────────────────────────────── */

.shell {
    display: grid;
    grid-template-columns: var(--rail-width) minmax(0, 1fr);
    min-height: 100vh;
}

.rail {
    position: sticky;
    top: 0;
    display: flex;
    flex-direction: column;
    height: 100vh;
    padding: 18px 14px;
    background: var(--panel);
    border-right: 1px solid var(--line);
}

.rail__brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 4px 8px 18px;
    color: var(--ink);
}

.rail__brand:hover { text-decoration: none; }

.rail__mark {
    width: 30px;
    height: 30px;
    flex: none;
    border-radius: 7px;
    background: var(--ink);
    color: var(--panel);
    display: grid;
    place-items: center;
}

.rail__mark svg { width: 20px; height: 20px; }

.rail__name {
    font-family: var(--font-display);
    font-variation-settings: "wdth" 112;
    font-weight: 600;
    font-size: 15px;
    letter-spacing: -0.01em;
    line-height: 1.1;
}

.rail__nav {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.rail__section {
    padding: 18px 8px 6px;
}

.rail__link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: var(--radius);
    color: var(--ink-2);
    font-weight: 500;
    position: relative;
}

.rail__link:hover {
    background: var(--panel-2);
    color: var(--ink);
    text-decoration: none;
}

.rail__link[aria-current="page"] {
    background: var(--panel-2);
    color: var(--ink);
}

.rail__link[aria-current="page"]::before {
    content: "";
    position: absolute;
    left: -14px;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 18px;
    border-radius: 0 2px 2px 0;
    background: var(--accent);
}

.rail__count {
    margin-left: auto;
    font-family: var(--font-mono);
    font-size: 11px;
    padding: 1px 6px;
    border-radius: 999px;
    background: var(--down-bg);
    color: var(--down);
}

.rail__foot {
    margin-top: auto;
    padding-top: 16px;
    border-top: 1px solid var(--line-soft);
}

.rail__user {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px;
    border-radius: var(--radius);
    color: var(--ink);
    width: 100%;
}

.rail__user:hover {
    background: var(--panel-2);
    text-decoration: none;
}

.avatar {
    width: 30px;
    height: 30px;
    flex: none;
    border-radius: 999px;
    display: grid;
    place-items: center;
    background: var(--accent-bg);
    color: var(--accent);
    font-family: var(--font-display);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.02em;
}

.rail__userinfo { min-width: 0; }
.rail__username {
    font-weight: 600;
    font-size: 13px;
    line-height: 1.2;
}
.rail__role {
    font-size: 11px;
    color: var(--ink-muted);
    text-transform: capitalize;
}

.main {
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px 22px;
    background: color-mix(in srgb, var(--bg) 88%, transparent);
    backdrop-filter: blur(8px);
    border-bottom: 1px solid var(--line);
}

.topbar__title { min-width: 0; }
.topbar__actions {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 8px;
}

.page {
    padding: 22px;
    max-width: var(--page-max);
    width: 100%;
}

.page > * + * { margin-top: 18px; }

/* ── Global status readout ──────────────────────────────────────────── */

.readout {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 5px 12px 5px 10px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: var(--panel);
    font-size: 12px;
    font-weight: 500;
}

.readout__dot {
    width: 8px;
    height: 8px;
    border-radius: 999px;
    background: var(--up);
    box-shadow: 0 0 0 3px var(--up-bg);
}

.readout--down .readout__dot { background: var(--down); box-shadow: 0 0 0 3px var(--down-bg); }
.readout--warn .readout__dot { background: var(--warn); box-shadow: 0 0 0 3px var(--warn-bg); }
.readout--idle .readout__dot { background: var(--idle); box-shadow: 0 0 0 3px var(--idle-bg); }

.readout__clock {
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--ink-muted);
    padding-left: 8px;
    border-left: 1px solid var(--line);
}

/* ── Buttons ────────────────────────────────────────────────────────── */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    padding: 7px 13px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--panel);
    color: var(--ink);
    font: inherit;
    font-weight: 500;
    font-size: 13px;
    cursor: pointer;
    transition: background 0.12s ease, border-color 0.12s ease, color 0.12s ease;
}

.btn:hover {
    background: var(--panel-2);
    text-decoration: none;
}

.btn .icon { width: 16px; height: 16px; }

.btn--primary {
    background: var(--accent);
    border-color: var(--accent);
    color: var(--accent-ink);
}

.btn--primary:hover {
    background: var(--accent-hover);
    border-color: var(--accent-hover);
}

.btn--danger {
    color: var(--down);
    border-color: color-mix(in srgb, var(--down) 35%, var(--line));
}

.btn--danger:hover { background: var(--down-bg); }

.btn--ghost {
    border-color: transparent;
    background: transparent;
    color: var(--ink-2);
}

.btn--ghost:hover { background: var(--panel-2); color: var(--ink); }

.btn--icon {
    padding: 7px;
    width: 32px;
    height: 32px;
}

.btn--sm { padding: 4px 9px; font-size: 12px; }

.btn[disabled] { opacity: 0.5; cursor: not-allowed; }

.btn-row {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    align-items: center;
}

/* ── Panels ─────────────────────────────────────────────────────────── */

.panel {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-1);
    overflow: hidden;
}

.panel__head {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    border-bottom: 1px solid var(--line-soft);
}

.panel__head > .btn-row,
.panel__head > .seg { margin-left: auto; }

.panel__body { padding: 16px; }
.panel__body--flush { padding: 0; }

.grid {
    display: grid;
    gap: 16px;
}

.grid--stats { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
.grid--split { grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr); }
.grid--halves { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }

/* ── Stat tiles ─────────────────────────────────────────────────────── */

.stat {
    padding: 14px 16px 16px;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-1);
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 0;
}

.stat__value {
    font-family: var(--font-display);
    font-variation-settings: "wdth" 96;
    font-size: 30px;
    font-weight: 600;
    line-height: 1.05;
    letter-spacing: -0.02em;
    font-variant-numeric: tabular-nums;
}

.stat__value--up { color: var(--up); }
.stat__value--down { color: var(--down); }
.stat__value--warn { color: var(--warn); }

.stat__unit {
    font-size: 15px;
    color: var(--ink-muted);
    font-weight: 500;
    margin-left: 2px;
}

.stat__foot {
    font-size: 12px;
    color: var(--ink-muted);
    display: flex;
    align-items: center;
    gap: 6px;
}

/* ── Status pills ───────────────────────────────────────────────────── */

.pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 9px 3px 7px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.02em;
    text-transform: uppercase;
    font-family: var(--font-display);
    font-variation-settings: "wdth" 108;
    background: var(--idle-bg);
    color: var(--idle);
    white-space: nowrap;
}

.pill::before {
    content: "";
    width: 6px;
    height: 6px;
    border-radius: 999px;
    background: currentColor;
}

.pill--up { background: var(--up-bg); color: var(--up); }
.pill--down { background: var(--down-bg); color: var(--down); }
.pill--degraded { background: var(--warn-bg); color: var(--warn); }
.pill--paused,
.pill--pending { background: var(--idle-bg); color: var(--idle); }

.pill--plain {
    text-transform: none;
    font-family: var(--font-body);
    font-variation-settings: normal;
    font-weight: 500;
    letter-spacing: 0;
    background: var(--panel-3);
    color: var(--ink-2);
    padding: 3px 9px;
}

.pill--plain::before { display: none; }

.tag {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 2px 8px;
    border-radius: 999px;
    border: 1px solid var(--line);
    font-size: 11px;
    color: var(--ink-muted);
}

.tag .icon { width: 12px; height: 12px; }

/* ── The tape ───────────────────────────────────────────────────────────
   The signature. Bar height is response time on a log scale, colour is the
   outcome, and the hairline underneath is the baseline of the instrument.
   Geometry is mirrored in assets/js/tape.js for live updates.            */

.tape-wrap {
    position: relative;
    display: block;
    min-width: 0;
}

.tape {
    display: block;
    width: 100%;
    height: 26px;
    overflow: visible;
}

.tape--hero { height: 64px; }
.tape--fleet { height: 34px; }

.tape-base {
    stroke: var(--line);
    stroke-width: 1;
    vector-effect: non-scaling-stroke;
}

.tape-bar { fill: var(--idle); }
.tape-bar--up { fill: var(--up); }
.tape-bar--degraded { fill: var(--warn); }
.tape-bar--down { fill: var(--down); }
.tape-bar--empty { fill: var(--line); opacity: 0.7; }

.tape-bar--fresh {
    animation: tape-in 0.15s ease-out;
}

@keyframes tape-in {
    from { transform: translateY(4px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.tape-legend {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 11px;
    color: var(--ink-muted);
    margin-top: 6px;
}

.tape-now {
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

.tape-now::before {
    content: "";
    width: 2px;
    height: 10px;
    background: var(--accent);
}

/* ── Monitor rows ───────────────────────────────────────────────────── */

.rows {
    display: flex;
    flex-direction: column;
}

.row {
    display: grid;
    grid-template-columns: minmax(200px, 1.6fr) 88px minmax(150px, 1.1fr) 84px 78px 40px;
    align-items: center;
    gap: 14px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--line-soft);
    transition: background 0.12s ease;
}

.row:last-child { border-bottom: 0; }
.row:hover { background: var(--panel-2); }

.row--head {
    padding-top: 9px;
    padding-bottom: 9px;
    background: var(--panel-2);
    border-bottom: 1px solid var(--line);
}

.row--head:hover { background: var(--panel-2); }

.row__id {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.row__type {
    width: 30px;
    height: 30px;
    flex: none;
    display: grid;
    place-items: center;
    border-radius: var(--radius-sm);
    background: var(--panel-3);
    color: var(--ink-muted);
}

.row__name {
    font-weight: 600;
    color: var(--ink);
    display: block;
    line-height: 1.25;
}

.row__name:hover { color: var(--accent); text-decoration: none; }

.row__target {
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--ink-muted);
    display: block;
}

.row__metric {
    font-family: var(--font-mono);
    font-size: 13px;
    font-variant-numeric: tabular-nums;
    text-align: right;
}

.row__metric small {
    display: block;
    font-family: var(--font-body);
    font-size: 11px;
    color: var(--ink-muted);
}

.row__actions {
    display: flex;
    justify-content: flex-end;
}

/* ── Tables ─────────────────────────────────────────────────────────── */

.table-wrap { overflow-x: auto; }

.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.table th {
    text-align: left;
    padding: 9px 16px;
    font-family: var(--font-display);
    font-variation-settings: "wdth" 112;
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--ink-muted);
    background: var(--panel-2);
    border-bottom: 1px solid var(--line);
    white-space: nowrap;
}

.table td {
    padding: 11px 16px;
    border-bottom: 1px solid var(--line-soft);
    vertical-align: middle;
}

.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: var(--panel-2); }

.table .num { font-size: 12px; }
.table__right { text-align: right; }

/* ── Forms ──────────────────────────────────────────────────────────── */

.form-grid {
    display: grid;
    gap: 16px;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field--wide { grid-column: 1 / -1; }

.field__label {
    font-size: 12px;
    font-weight: 600;
    color: var(--ink-2);
}

.field__hint {
    font-size: 12px;
    color: var(--ink-muted);
}

.input,
.select,
.textarea {
    width: 100%;
    padding: 8px 11px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--panel);
    color: var(--ink);
    font: inherit;
    font-size: 13px;
    transition: border-color 0.12s ease, box-shadow 0.12s ease;
}

.input:focus,
.select:focus,
.textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-bg);
}

.input--mono,
.textarea--mono { font-family: var(--font-mono); font-size: 12.5px; }

.textarea { min-height: 88px; resize: vertical; }

.select {
    appearance: none;
    background-image: linear-gradient(45deg, transparent 50%, currentColor 50%),
                      linear-gradient(135deg, currentColor 50%, transparent 50%);
    background-position: calc(100% - 16px) 52%, calc(100% - 11px) 52%;
    background-size: 5px 5px, 5px 5px;
    background-repeat: no-repeat;
    padding-right: 32px;
}

.check {
    display: flex;
    align-items: flex-start;
    gap: 9px;
    padding: 9px 11px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--panel);
    cursor: pointer;
}

.check:hover { border-color: color-mix(in srgb, var(--accent) 40%, var(--line)); }

.check input {
    margin: 2px 0 0;
    accent-color: var(--accent);
    width: 15px;
    height: 15px;
    flex: none;
}

.check__text { font-size: 13px; line-height: 1.35; }
.check__text small { display: block; color: var(--ink-muted); font-size: 11.5px; }

.fieldset {
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    padding: 16px;
    margin: 0;
}

.fieldset > legend {
    padding: 0 8px;
    font-family: var(--font-display);
    font-variation-settings: "wdth" 114;
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--ink-muted);
}

.form-actions {
    display: flex;
    gap: 10px;
    align-items: center;
    padding-top: 4px;
}

.form-actions .btn-row { margin-left: auto; }

/* ── Filters / segmented control ────────────────────────────────────── */

.seg {
    display: inline-flex;
    padding: 2px;
    gap: 2px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--panel-2);
}

.seg a,
.seg button {
    padding: 4px 10px;
    border: 0;
    border-radius: 5px;
    background: transparent;
    color: var(--ink-muted);
    font: inherit;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
}

.seg a:hover,
.seg button:hover { color: var(--ink); text-decoration: none; }

.seg [aria-current="true"] {
    background: var(--panel);
    color: var(--ink);
    box-shadow: var(--shadow-1);
}

.filters {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}

.search {
    position: relative;
    display: flex;
    align-items: center;
    min-width: 200px;
}

.search .icon {
    position: absolute;
    left: 10px;
    width: 15px;
    height: 15px;
    color: var(--ink-muted);
    pointer-events: none;
}

.search .input { padding-left: 32px; }

/* ── Flash messages ─────────────────────────────────────────────────── */

.flashes {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.flash {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 11px 14px;
    border-radius: var(--radius);
    border: 1px solid var(--line);
    background: var(--panel);
    font-size: 13px;
    box-shadow: var(--shadow-1);
}

.flash--success { border-left: 3px solid var(--up); }
.flash--error { border-left: 3px solid var(--down); }
.flash--warning { border-left: 3px solid var(--warn); }

.flash .icon { color: var(--ink-muted); margin-top: 1px; }

/* ── Empty states ───────────────────────────────────────────────────── */

.empty {
    padding: 44px 22px;
    text-align: center;
    color: var(--ink-muted);
}

.empty h3 { color: var(--ink); margin-bottom: 6px; }
.empty p { max-width: 46ch; margin: 0 auto 16px; }

/* ── Charts ─────────────────────────────────────────────────────────── */

.chart {
    width: 100%;
    min-height: 200px;
}

.chart--tall { min-height: 280px; }

.uplot,
.u-wrap { width: 100% !important; }

.u-legend {
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--ink-muted);
}

.u-legend .u-marker { border-radius: 2px; }

/* Daily uptime bars, drawn as flex boxes rather than a chart library. */
.bars {
    display: flex;
    gap: 3px;
    align-items: flex-end;
    height: 56px;
}

.bars__bar {
    flex: 1;
    min-width: 3px;
    border-radius: 2px 2px 0 0;
    background: var(--up);
    position: relative;
}

.bars__bar--none { background: var(--line); }
.bars__bar--warn { background: var(--warn); }
.bars__bar--down { background: var(--down); }

.bars__scale {
    display: flex;
    justify-content: space-between;
    font-size: 11px;
    color: var(--ink-muted);
    margin-top: 8px;
}

/* Availability donut */
.donut { display: flex; align-items: center; gap: 16px; }
.donut svg { width: 88px; height: 88px; flex: none; }
.donut__track { stroke: var(--line); }
.donut__value { stroke: var(--up); stroke-linecap: round; transition: stroke-dashoffset 0.4s ease; }
.donut__value--warn { stroke: var(--warn); }
.donut__value--down { stroke: var(--down); }
.donut__label { font-family: var(--font-mono); font-size: 12px; fill: var(--ink); }

/* Certificate meter */
.meter {
    height: 6px;
    border-radius: 999px;
    background: var(--line);
    overflow: hidden;
}

.meter__fill {
    height: 100%;
    border-radius: 999px;
    background: var(--up);
}

.meter__fill--warn { background: var(--warn); }
.meter__fill--down { background: var(--down); }

/* ── Definition lists ───────────────────────────────────────────────── */

.dl {
    display: grid;
    grid-template-columns: minmax(110px, auto) minmax(0, 1fr);
    gap: 9px 16px;
    font-size: 13px;
    margin: 0;
}

.dl dt { color: var(--ink-muted); }
.dl dd {
    margin: 0;
    min-width: 0;
    overflow-wrap: anywhere;
}

/* ── Access matrix (groups on a monitor) ────────────────────────────── */

.access {
    display: flex;
    flex-direction: column;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    overflow: hidden;
}

.access__row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 12px;
    padding: 9px 12px;
    border-bottom: 1px solid var(--line-soft);
}

.access__row:last-child { border-bottom: 0; }
.access__row .seg { background: var(--panel-2); }

.access__name { font-weight: 500; }
.access__meta { font-size: 11.5px; color: var(--ink-muted); }

/* ── Login and install ──────────────────────────────────────────────── */

.bare {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
    background:
        radial-gradient(1100px 520px at 50% -10%, var(--bg-grain), transparent 70%),
        var(--bg);
}

.card {
    width: 100%;
    max-width: 400px;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-pop);
    padding: 26px;
}

.card--wide { max-width: 720px; }

.card__brand {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 20px;
}

.card__form { display: flex; flex-direction: column; gap: 14px; }

.steps {
    display: flex;
    gap: 4px;
    margin-bottom: 22px;
}

.steps__item {
    flex: 1;
    padding-top: 8px;
    border-top: 2px solid var(--line);
    font-size: 11px;
    color: var(--ink-muted);
}

.steps__item[data-state="done"] { border-color: var(--up); color: var(--up); }
.steps__item[data-state="current"] { border-color: var(--accent); color: var(--ink); font-weight: 600; }

/* Without JavaScript every step stays visible and the form still submits. */
[data-wizard][data-js="1"] .step { display: none; }
[data-wizard][data-js="1"] .step[data-active="true"] { display: block; }
[data-wizard]:not([data-js="1"]) .steps { display: none; }
.step + .step { margin-top: 28px; }

.checklist { display: flex; flex-direction: column; gap: 2px; }

.checklist__item {
    display: flex;
    align-items: baseline;
    gap: 10px;
    padding: 7px 0;
    border-bottom: 1px solid var(--line-soft);
    font-size: 13px;
}

.checklist__item:last-child { border-bottom: 0; }

.checklist__mark {
    font-family: var(--font-mono);
    font-weight: 600;
    width: 14px;
    flex: none;
}

.checklist__item[data-ok="1"] .checklist__mark { color: var(--up); }
.checklist__item[data-ok="0"] .checklist__mark { color: var(--down); }
.checklist__item[data-ok="warn"] .checklist__mark { color: var(--warn); }

.checklist__detail { margin-left: auto; color: var(--ink-muted); font-size: 12px; text-align: right; }

.result {
    padding: 10px 12px;
    border-radius: var(--radius);
    font-size: 13px;
    display: none;
}

.result[data-state="ok"] { display: block; background: var(--up-bg); color: var(--up); }
.result[data-state="error"] { display: block; background: var(--down-bg); color: var(--down); }
.result[data-state="busy"] { display: block; background: var(--panel-2); color: var(--ink-muted); }

.code {
    display: block;
    padding: 11px 13px;
    background: var(--panel-3);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    font-family: var(--font-mono);
    font-size: 12px;
    overflow-x: auto;
    white-space: pre;
}

/* ── Utilities ──────────────────────────────────────────────────────── */

.stack { display: flex; flex-direction: column; gap: 12px; }
.stack--tight { gap: 6px; }
.inline { display: flex; align-items: center; gap: 8px; }
.inline--between { justify-content: space-between; }
.spread { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.mt-0 { margin-top: 0; }

.live-dot {
    width: 6px;
    height: 6px;
    border-radius: 999px;
    background: var(--up);
    animation: breathe 3s ease-in-out infinite;
}

@keyframes breathe {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.35; }
}

[data-live-stale="true"] .live-dot { background: var(--warn); animation: none; }

/* ── Responsive ─────────────────────────────────────────────────────── */

@media (max-width: 1080px) {
    .grid--split { grid-template-columns: minmax(0, 1fr); }
    .row { grid-template-columns: minmax(160px, 1.6fr) 80px minmax(120px, 1fr) 72px 40px; }
    .row__uptime30 { display: none; }
}

@media (max-width: 860px) {
    .shell { grid-template-columns: minmax(0, 1fr); }

    .rail {
        position: static;
        height: auto;
        flex-direction: row;
        align-items: center;
        gap: 8px;
        padding: 10px 14px;
        border-right: 0;
        border-bottom: 1px solid var(--line);
        overflow-x: auto;
    }

    .rail__brand { padding: 0 8px 0 0; }
    .rail__name { display: none; }
    .rail__nav { flex-direction: row; }
    .rail__section { display: none; }
    .rail__link span { display: none; }
    .rail__link[aria-current="page"]::before { display: none; }
    .rail__foot { margin: 0 0 0 auto; padding: 0; border: 0; }
    .rail__userinfo { display: none; }

    .topbar { padding: 10px 14px; }
    .readout__clock { display: none; }
    .page { padding: 14px; }

    .row {
        grid-template-columns: minmax(0, 1fr) auto;
        grid-template-areas:
            "id status"
            "tape tape"
            "metrics metrics";
        gap: 10px;
    }

    .row__id { grid-area: id; }
    .row__status { grid-area: status; }
    .row__tape { grid-area: tape; }
    .row__metric { grid-area: metrics; text-align: left; display: inline-flex; gap: 6px; align-items: baseline; }
    .row__metric small { display: inline; }
    .row__actions { display: none; }
    .row--head { display: none; }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.001ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.001ms !important;
    }
}

@media print {
    .rail, .topbar__actions { display: none; }
}

/* Radio groups styled as a segmented control (monitor sharing levels). */
.seg label {
    display: inline-flex;
    position: relative;
}

.seg label .btn {
    border: 0;
    background: transparent;
    color: var(--ink-muted);
    padding: 4px 10px;
    font-size: 12px;
    border-radius: 5px;
}

.seg label input:checked + .btn {
    background: var(--panel);
    color: var(--ink);
    box-shadow: var(--shadow-1);
    font-weight: 600;
}

.seg label input:focus-visible + .btn {
    outline: 2px solid var(--accent);
    outline-offset: 1px;
}

code {
    font-family: var(--font-mono);
    font-size: 0.92em;
    padding: 1px 4px;
    border-radius: 3px;
    background: var(--panel-3);
}
