/* Opus Cloud dashboard. The page runs under a CSP without inline styles (API.md section 1): every style is a
   class here, and the few positions set from script go through element.style. Colours are tokens; the dark
   theme is the default, the light theme is its own set of steps, not an inversion. */

:root,
:root[data-theme="dark"] {
    color-scheme: dark;
    --page: #0f1012;
    --surface: #17181b;
    --surface-2: #1e1f23;
    --surface-3: #26282d;
    --chart-surface: #17181b;
    --border: rgba(255, 255, 255, 0.09);
    --border-strong: rgba(255, 255, 255, 0.16);
    --ink: #f0efec;
    --ink-2: #c3c2b7;
    --ink-3: #8f8d86;
    --accent: #3987e5;
    --accent-ink: #ffffff;
    --accent-soft: rgba(57, 135, 229, 0.16);
    --focus: #6da7ec;
    --good: #0ca30c;
    --good-ink: #3fcf55;
    --warning: #fab219;
    --serious: #ec835a;
    --critical: #d03b3b;
    --critical-ink: #f07a7a;
    --good-soft: rgba(12, 163, 12, 0.16);
    --warning-soft: rgba(250, 178, 25, 0.15);
    --critical-soft: rgba(208, 59, 59, 0.18);
    --neutral-soft: rgba(255, 255, 255, 0.07);
    --grid: #2c2c2a;
    --axis: #45453f;
    --tick: #9b998f;
    --s1: #3987e5;
    --s2: #d95926;
    --s3: #199e70;
    --s4: #c98500;
    --s5: #d55181;
    --s6: #0ca30c;
    --s7: #9085e9;
    --s8: #e66767;
    --s-other: #898781;
    --band-ok: rgba(12, 163, 12, 0.10);
    --band-watch: rgba(250, 178, 25, 0.11);
    --band-danger: rgba(208, 59, 59, 0.15);
    --band-fight: rgba(144, 133, 233, 0.13);
    --band-info: rgba(255, 255, 255, 0.06);
    --heat-neg: #2a78d6;
    --heat-neg-half: #1c3f6a;
    --heat-mid: #2b2b29;
    --heat-pos-half: #6b2a2a;
    --heat-pos: #e66767;
    --shadow: 0 12px 32px rgba(0, 0, 0, 0.45);
}

:root[data-theme="light"] {
    color-scheme: light;
    --page: #f4f4f1;
    --surface: #fcfcfb;
    --surface-2: #f3f3f0;
    --surface-3: #e9e8e3;
    --chart-surface: #fcfcfb;
    --border: rgba(11, 11, 11, 0.10);
    --border-strong: rgba(11, 11, 11, 0.18);
    --ink: #0b0b0b;
    --ink-2: #52514e;
    --ink-3: #6f6d68;
    --accent: #2a78d6;
    --accent-ink: #ffffff;
    --accent-soft: rgba(42, 120, 214, 0.12);
    --focus: #2a78d6;
    --good-ink: #006300;
    --critical-ink: #b42727;
    --good-soft: rgba(12, 163, 12, 0.12);
    --warning-soft: rgba(250, 178, 25, 0.20);
    --critical-soft: rgba(208, 59, 59, 0.12);
    --neutral-soft: rgba(11, 11, 11, 0.05);
    --grid: #e1e0d9;
    --axis: #c3c2b7;
    --tick: #6f6d68;
    --s1: #2a78d6;
    --s2: #eb6834;
    --s3: #1baf7a;
    --s4: #eda100;
    --s5: #e87ba4;
    --s6: #008300;
    --s7: #6250d6;
    --s8: #e34948;
    --band-ok: rgba(12, 163, 12, 0.08);
    --band-watch: rgba(237, 161, 0, 0.13);
    --band-danger: rgba(208, 59, 59, 0.10);
    --band-fight: rgba(98, 80, 214, 0.09);
    --band-info: rgba(11, 11, 11, 0.05);
    --heat-neg: #184f95;
    --heat-neg-half: #86b6ef;
    --heat-mid: #ecebe6;
    --heat-pos-half: #f0a3a2;
    --heat-pos: #c42e2d;
    --shadow: 0 12px 32px rgba(11, 11, 11, 0.16);
}

* {
    box-sizing: border-box;
}

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

body {
    margin: 0;
    background: var(--page);
    color: var(--ink);
    font: 14px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    min-height: 100vh;
    overflow-x: hidden;
}

h1, h2, h3, h4 {
    margin: 0;
    font-weight: 600;
    line-height: 1.3;
}

h1 { font-size: 22px; }
h2 { font-size: 16px; }
h3 { font-size: 14px; }

p { margin: 0; }

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

a:hover { text-decoration: underline; }

code, .mono {
    font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, "Liberation Mono", monospace;
    font-size: 12.5px;
}

:focus-visible {
    outline: 2px solid var(--focus);
    outline-offset: 2px;
}

[hidden] { display: none !important; }

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

.offscreen { left: -9999px; }

.muted { color: var(--ink-3); }
.secondary { color: var(--ink-2); }
.small { font-size: 12.5px; }
.nowrap { white-space: nowrap; }
.num { font-variant-numeric: tabular-nums; }
.break { overflow-wrap: anywhere; }

/* ---------------------------------------------------------------- shell */

.boot {
    display: grid;
    place-items: center;
    min-height: 100vh;
    color: var(--ink-3);
}

.shell {
    display: grid;
    grid-template-columns: 236px minmax(0, 1fr);
    min-height: 100vh;
    /* The sidebar's column is painted down the whole page, however long it is; the sidebar itself stays in view. */
    background: linear-gradient(to right, var(--surface) 235px, var(--border) 235px, var(--border) 236px, transparent 236px);
}

.sidebar {
    position: sticky;
    top: 0;
    align-self: start;
    height: 100vh;
    height: 100dvh;
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 18px 12px;
    background: var(--surface);
    border-right: 1px solid var(--border);
    overflow-y: auto;
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 4px 10px 18px;
    color: var(--ink);
    font-weight: 650;
    font-size: 15px;
}

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

.brand-mark {
    width: 26px;
    height: 26px;
    flex: none;
}

.brand-mark .ring { fill: none; stroke: var(--accent); stroke-width: 2.5; }
.brand-mark .dot { fill: var(--accent); }

.brand-sub {
    display: block;
    font-size: 11.5px;
    font-weight: 500;
    color: var(--ink-3);
}

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

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

.nav-link:hover {
    background: var(--neutral-soft);
    color: var(--ink);
    text-decoration: none;
}

.nav-link[aria-current="page"] {
    background: var(--accent-soft);
    color: var(--ink);
}

.nav-icon {
    width: 18px;
    height: 18px;
    flex: none;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.sidebar-foot {
    margin-top: auto;
    padding: 12px 10px 0;
    border-top: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 10px;
}

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

.account-name {
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.account-meta {
    font-size: 12px;
    color: var(--ink-3);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

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

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

.topbar-title {
    font-weight: 600;
    font-size: 15px;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.topbar-tools {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 8px;
}

.topbar .menu-button { display: none; }

.content {
    width: 100%;
    max-width: 1400px;
    padding: 24px 28px 48px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.demo-ribbon {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 9px;
    border-radius: 999px;
    background: var(--warning-soft);
    color: var(--ink);
    font-size: 12px;
    font-weight: 600;
}

.live-state {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--ink-3);
}

.live-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--ink-3);
}

.live-state[data-state="open"] .live-dot { background: var(--good); }
.live-state[data-state="connecting"] .live-dot,
.live-state[data-state="closed"] .live-dot { background: var(--warning); }

.scrim {
    display: none;
}

/* ---------------------------------------------------------------- page parts */

.page-head {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 12px 20px;
}

.page-head-text {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
    flex: 1 1 280px;
}

.page-head-text p { color: var(--ink-2); }

.page-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 18px;
    min-width: 0;
}

.card-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 12px;
    margin-bottom: 14px;
}

.card-head h2 { margin-right: auto; }

.card-flush { padding: 0; }
.card-flush > .card-head { padding: 16px 18px 0; }

.grid {
    display: grid;
    gap: 16px;
    min-width: 0;
}

.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-tiles { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
.grid-cards { grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); }

.stack {
    display: flex;
    flex-direction: column;
    gap: 16px;
    min-width: 0;
}

.stack-tight { gap: 8px; }

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

.spread { justify-content: space-between; }

.tile {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 16px 18px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
}

.tile-label {
    color: var(--ink-2);
    font-size: 12.5px;
    font-weight: 500;
}

.tile-value {
    font-size: 28px;
    font-weight: 650;
    line-height: 1.15;
    letter-spacing: -0.01em;
}

.tile-sub {
    color: var(--ink-3);
    font-size: 12.5px;
}

.dl {
    display: grid;
    grid-template-columns: max-content minmax(0, 1fr);
    gap: 6px 16px;
    margin: 0;
}

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

.facts {
    display: flex;
    flex-wrap: wrap;
    gap: 10px 26px;
}

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

.fact-label {
    font-size: 12px;
    color: var(--ink-3);
}

.fact-value {
    font-weight: 600;
    font-size: 15px;
}

/* ---------------------------------------------------------------- states */

.state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 32px 16px;
    text-align: center;
    color: var(--ink-3);
}

.state-error { color: var(--ink-2); }

.state-icon {
    width: 28px;
    height: 28px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
}

.state-error .state-icon { stroke: var(--critical-ink); }

.spinner {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    border: 2.5px solid var(--border-strong);
    border-top-color: var(--accent);
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

@media (prefers-reduced-motion: reduce) {
    .spinner { animation-duration: 3s; }
}

.skeleton {
    height: 14px;
    border-radius: 6px;
    background: var(--neutral-soft);
}

.banner {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 12px 14px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--surface-2);
    color: var(--ink);
}

.banner-error { background: var(--critical-soft); border-color: transparent; }
.banner-warning { background: var(--warning-soft); border-color: transparent; }
.banner-ok { background: var(--good-soft); border-color: transparent; }
.banner-info { background: var(--accent-soft); border-color: transparent; }

.banner-body {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
}

.banner-body .small { color: var(--ink-2); }

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

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: 34px;
    padding: 6px 14px;
    border-radius: 8px;
    border: 1px solid var(--border-strong);
    background: var(--surface-2);
    color: var(--ink);
    font: inherit;
    font-weight: 550;
    cursor: pointer;
    white-space: nowrap;
}

.btn:hover:not(:disabled) { background: var(--surface-3); }

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

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

.btn-primary:hover:not(:disabled) {
    background: color-mix(in srgb, var(--accent) 86%, #000);
}

.btn-danger {
    background: transparent;
    border-color: color-mix(in srgb, var(--critical) 60%, transparent);
    color: var(--critical-ink);
}

.btn-danger:hover:not(:disabled) { background: var(--critical-soft); }

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

.btn-ghost:hover:not(:disabled) {
    background: var(--neutral-soft);
    color: var(--ink);
}

.btn-small {
    min-height: 28px;
    padding: 3px 10px;
    font-size: 12.5px;
}

.btn-icon {
    width: 34px;
    padding: 0;
}

.btn-icon svg {
    width: 18px;
    height: 18px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.btn-wide { width: 100%; }

.segmented {
    display: inline-flex;
    padding: 2px;
    border-radius: 9px;
    background: var(--surface-2);
    border: 1px solid var(--border);
}

.segmented button {
    min-height: 28px;
    padding: 2px 10px;
    border: 0;
    border-radius: 7px;
    background: transparent;
    color: var(--ink-2);
    font: inherit;
    font-size: 12.5px;
    font-weight: 600;
    cursor: pointer;
}

.segmented button[aria-pressed="true"] {
    background: var(--surface-3);
    color: var(--ink);
}

input, select, textarea {
    font: inherit;
    color: var(--ink);
    background: var(--surface-2);
    border: 1px solid var(--border-strong);
    border-radius: 8px;
    padding: 7px 10px;
    min-height: 34px;
    max-width: 100%;
}

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

input[type="checkbox"], input[type="radio"] {
    min-height: 0;
    width: 16px;
    height: 16px;
    padding: 0;
    accent-color: var(--accent);
}

textarea {
    width: 100%;
    resize: vertical;
    line-height: 1.45;
}

textarea.code {
    font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
    font-size: 12.5px;
    min-height: 320px;
    tab-size: 2;
}

.input-invalid {
    border-color: var(--critical) !important;
}

.field {
    display: flex;
    flex-direction: column;
    gap: 5px;
    min-width: 0;
}

.field-label {
    font-weight: 550;
    font-size: 13px;
}

.field-hint {
    font-size: 12px;
    color: var(--ink-3);
}

.field-error {
    font-size: 12.5px;
    color: var(--critical-ink);
}

.check {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    cursor: pointer;
}

.check input { margin-top: 2px; flex: none; }

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

.check-disabled {
    cursor: not-allowed;
    opacity: 0.55;
}

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

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

.form-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: flex-end;
}

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

.filters .field { flex: 0 1 190px; }
.filters .field-grow { flex: 1 1 220px; }

/* ---------------------------------------------------------------- badges, chips, bars */

.badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 1px 8px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
    background: var(--neutral-soft);
    color: var(--ink-2);
    white-space: nowrap;
}

.badge::before {
    content: "";
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
    opacity: 0.9;
}

.badge-plain::before { display: none; }
.badge-good { background: var(--good-soft); color: var(--good-ink); }
.badge-warning { background: var(--warning-soft); color: var(--ink); }
.badge-warning::before { background: var(--warning); }
.badge-serious { background: rgba(236, 131, 90, 0.18); color: var(--ink); }
.badge-serious::before { background: var(--serious); }
.badge-critical { background: var(--critical-soft); color: var(--critical-ink); }
.badge-info { background: var(--accent-soft); color: var(--ink); }
.badge-info::before { background: var(--accent); }

.chips {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

.chip {
    display: inline-block;
    padding: 1px 8px;
    border-radius: 6px;
    background: var(--surface-3);
    color: var(--ink-2);
    font-size: 12px;
    white-space: nowrap;
}

.meter {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

.meter-track {
    width: 64px;
    height: 6px;
    border-radius: 3px;
    background: var(--surface-3);
    overflow: hidden;
    flex: none;
}

.meter-fill {
    display: block;
    height: 100%;
    border-radius: 3px;
    background: var(--s1);
}

.meter-fill.low { background: var(--critical); }
.meter-fill.mid { background: var(--warning); }
.meter-fill.high { background: var(--good); }

.barlist {
    display: flex;
    flex-direction: column;
    gap: 9px;
}

.barlist-row {
    display: grid;
    grid-template-columns: minmax(90px, 34%) minmax(0, 1fr) 44px;
    align-items: center;
    gap: 10px;
}

.barlist-label {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--ink-2);
}

.barlist-track {
    height: 10px;
    border-radius: 3px;
    background: transparent;
}

.barlist-fill {
    display: block;
    height: 100%;
    border-radius: 0 4px 4px 0;
    background: var(--s1);
}

.barlist-value {
    text-align: right;
    font-variant-numeric: tabular-nums;
    font-weight: 600;
}

.stagebar {
    display: flex;
    height: 12px;
    border-radius: 4px;
    overflow: hidden;
    gap: 2px;
}

.stagebar span { display: block; height: 100%; min-width: 3px; }

.legend-inline {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 16px;
    font-size: 12.5px;
    color: var(--ink-2);
}

.legend-inline span {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.swatch {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 3px;
}

.sw-s1 { background: var(--s1); }
.sw-s2 { background: var(--s2); }
.sw-s3 { background: var(--s3); }
.sw-s4 { background: var(--s4); }
.sw-s5 { background: var(--s5); }
.sw-good { background: var(--good); }
.sw-warning { background: var(--warning); }
.sw-serious { background: var(--serious); }
.sw-critical { background: var(--critical); }
.sw-muted { background: var(--ink-3); }

/* ---------------------------------------------------------------- tables */

.table-scroll {
    overflow-x: auto;
    max-width: 100%;
}

.table {
    width: 100%;
    border-collapse: collapse;
    font-variant-numeric: tabular-nums;
}

.table th {
    text-align: left;
    font-size: 12px;
    font-weight: 600;
    color: var(--ink-3);
    padding: 8px 12px;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

.table td {
    padding: 9px 12px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: var(--neutral-soft); }
.table .r { text-align: right; }

.table-dense th, .table-dense td { padding: 5px 10px; font-size: 12.5px; }

.table th button.sort {
    border: 0;
    background: none;
    color: inherit;
    font: inherit;
    cursor: pointer;
    padding: 0;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.table th button.sort[aria-pressed="true"] { color: var(--ink); }

.row-link {
    color: var(--ink);
    font-weight: 600;
}

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

.cell-sub {
    font-size: 12px;
    color: var(--ink-3);
}

.table-foot {
    display: flex;
    justify-content: center;
    padding: 12px;
}

/* ---------------------------------------------------------------- tabs */

.tabs {
    display: flex;
    gap: 2px;
    border-bottom: 1px solid var(--border);
    overflow-x: auto;
    scrollbar-width: none;
}

.tab {
    padding: 9px 14px;
    color: var(--ink-2);
    font-weight: 550;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    white-space: nowrap;
}

.tab:hover {
    color: var(--ink);
    text-decoration: none;
}

.tab[aria-current="page"] {
    color: var(--ink);
    border-bottom-color: var(--accent);
}

/* ---------------------------------------------------------------- dialogs and toasts */

dialog.dialog {
    width: min(560px, calc(100vw - 32px));
    max-height: calc(100vh - 48px);
    padding: 0;
    border: 1px solid var(--border-strong);
    border-radius: 14px;
    background: var(--surface);
    color: var(--ink);
    box-shadow: var(--shadow);
}

dialog.dialog-wide { width: min(760px, calc(100vw - 32px)); }

dialog.dialog::backdrop {
    background: rgba(0, 0, 0, 0.55);
}

.dialog-inner {
    display: flex;
    flex-direction: column;
    max-height: calc(100vh - 50px);
}

.dialog-head {
    padding: 18px 20px 6px;
}

.dialog-body {
    padding: 10px 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.dialog-foot {
    padding: 12px 20px 18px;
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 8px;
}

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

.secret-value {
    flex: 1 1 260px;
    min-width: 0;
    padding: 10px 12px;
    border-radius: 8px;
    background: var(--surface-2);
    border: 1px dashed var(--border-strong);
    overflow-wrap: anywhere;
    user-select: all;
}

.toasts {
    position: fixed;
    right: 16px;
    bottom: 16px;
    z-index: 100;
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-width: min(380px, calc(100vw - 32px));
}

.toast {
    padding: 10px 14px;
    border-radius: 10px;
    background: var(--surface-3);
    border: 1px solid var(--border-strong);
    box-shadow: var(--shadow);
}

.toast-error { border-color: var(--critical); }
.toast-ok { border-color: var(--good); }

/* ---------------------------------------------------------------- login */

.login {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px 16px;
}

.login-card {
    width: min(420px, 100%);
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.login-wide { width: min(560px, 100%); }

.login-brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.login-brand .brand-mark { width: 34px; height: 34px; }

.login-tools {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.switch {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-weight: 550;
}

.demo-accounts {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 8px;
}

.demo-account {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
    padding: 10px 12px;
    border-radius: 10px;
    border: 1px solid var(--border-strong);
    background: var(--surface-2);
    color: var(--ink);
    font: inherit;
    text-align: left;
    cursor: pointer;
}

.demo-account:hover { border-color: var(--accent); }
.demo-account strong { font-size: 13.5px; }
.demo-account span { font-size: 12px; color: var(--ink-3); overflow-wrap: anywhere; }

/* ---------------------------------------------------------------- alerts feed */

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

.feed-item {
    display: grid;
    grid-template-columns: 74px minmax(0, 1.3fr) minmax(0, 1fr) minmax(0, 1fr) 96px;
    gap: 12px;
    align-items: center;
    padding: 10px 18px;
    border-bottom: 1px solid var(--border);
}

.feed-item:last-child { border-bottom: 0; }

.feed-item .cell-main > * {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.feed-item.is-new { animation: arrive 1.6s ease-out; }

@keyframes arrive {
    from { background: var(--accent-soft); }
    to { background: transparent; }
}

@media (prefers-reduced-motion: reduce) {
    .feed-item.is-new { animation: none; }
}

.feed-time {
    font-variant-numeric: tabular-nums;
    color: var(--ink-2);
}

.feed-meta {
    font-size: 12px;
    color: var(--ink-3);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.pause-note {
    font-size: 12.5px;
    color: var(--ink-2);
}

/* ---------------------------------------------------------------- servers */

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

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

.server-title h2 { margin-right: auto; }

.counts {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 8px;
}

.count {
    background: var(--surface-2);
    border-radius: 8px;
    padding: 8px 10px;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.count-label {
    font-size: 11.5px;
    color: var(--ink-3);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.count-value {
    font-weight: 650;
    font-size: 17px;
    font-variant-numeric: tabular-nums;
}

.config-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 340px;
    gap: 16px;
    align-items: start;
}

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

.history-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
}

.history-item:last-child { border-bottom: 0; }

.history-head {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.pre {
    margin: 0;
    padding: 12px;
    border-radius: 8px;
    background: var(--surface-2);
    overflow: auto;
    max-height: 360px;
    font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
    font-size: 12px;
    white-space: pre;
}

.check-table td { vertical-align: top; }

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

/* ---------------------------------------------------------------- profile */

.profile-head {
    display: flex;
    flex-wrap: wrap;
    gap: 16px 24px;
    align-items: center;
}

.profile-id {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
    flex: 1 1 260px;
}

.profile-id h1 {
    overflow-wrap: anywhere;
}

.profile-tools {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    justify-content: space-between;
}

.charts {
    display: grid;
    gap: 16px;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    min-width: 0;
}

.charts > .span-2 { grid-column: 1 / -1; }

.action-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
    gap: 12px;
}

.action {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 14px;
    border-radius: 10px;
    background: var(--surface-2);
}

.action p { color: var(--ink-2); font-size: 13px; }

/* ---------------------------------------------------------------- charts */

.chart {
    margin: 0;
    background: var(--chart-surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 14px 16px 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-width: 0;
}

.chart-head {
    display: flex;
    align-items: center;
    gap: 8px;
}

.chart-title {
    margin-right: auto;
    font-size: 14px;
}

.chart-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 4px 14px;
    font-size: 12px;
    color: var(--ink-2);
}

.chart-legend:empty { display: none; }

.chart-legend-item {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.chart-ylabel {
    font-size: 11.5px;
    color: var(--ink-3);
}

.chart-ylabel:empty { display: none; }

.chart-stage {
    position: relative;
    min-width: 0;
}

.chart-plot {
    position: relative;
    width: 100%;
    min-height: 60px;
}

.chart-svg {
    display: block;
    overflow: visible;
    max-width: 100%;
}

.chart-svg:focus-visible {
    outline: 2px solid var(--focus);
    outline-offset: 4px;
    border-radius: 4px;
}

.chart-svg-over {
    position: relative;
}

.chart-canvas {
    position: absolute;
    display: block;
}

.chart-empty {
    position: absolute;
    left: 50%;
    top: 42%;
    transform: translate(-50%, -50%);
    padding: 4px 12px;
    border-radius: 6px;
    background: var(--surface-2);
    color: var(--ink-3);
    font-size: 12.5px;
    pointer-events: none;
}

.chart-message {
    padding: 28px 0;
    text-align: center;
    color: var(--ink-3);
}

.chart-note {
    font-size: 12px;
    color: var(--ink-3);
}

.chart-table {
    max-height: 320px;
    overflow: auto;
    border-top: 1px solid var(--border);
}

.chart-tip {
    position: absolute;
    z-index: 5;
    pointer-events: none;
    min-width: 140px;
    max-width: 280px;
    padding: 8px 10px;
    border-radius: 8px;
    background: var(--surface-3);
    border: 1px solid var(--border-strong);
    box-shadow: var(--shadow);
    font-size: 12px;
}

.chart-tip-title {
    font-weight: 600;
    margin-bottom: 4px;
    color: var(--ink);
}

.chart-tip-row {
    display: grid;
    grid-template-columns: 12px minmax(0, 1fr) auto;
    gap: 6px;
    align-items: center;
    color: var(--ink-2);
}

.chart-tip-label {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.chart-tip-value {
    color: var(--ink);
    font-variant-numeric: tabular-nums;
    text-align: right;
}

.chart-key {
    display: inline-block;
    width: 12px;
    height: 12px;
    flex: none;
    position: relative;
}

.chart-key-none { visibility: hidden; }

.chart-key-box { border-radius: 3px; background: currentColor; }

.chart-key-line::after,
.chart-key-dash::after {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    top: 5px;
    height: 2px;
    border-radius: 1px;
    background: currentColor;
}

.chart-key-dash::after {
    background: repeating-linear-gradient(90deg, currentColor 0 4px, transparent 4px 6px);
}

.chart-key-dot::after {
    content: "";
    position: absolute;
    left: 2px;
    top: 2px;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: currentColor;
}

.chart-key-mark::after {
    content: "";
    position: absolute;
    left: 2px;
    top: 2px;
    width: 8px;
    height: 8px;
    background: currentColor;
    transform: rotate(45deg);
}

.chart-key-mark.ch-mark-reflag::after {
    transform: none;
    clip-path: polygon(0 0, 100% 0, 50% 100%);
    width: 10px;
    left: 1px;
}

.chart-key-mark.ch-mark-info::after { transform: none; }

.chart-key.ch-s1 { color: var(--s1); }
.chart-key.ch-s2 { color: var(--s2); }
.chart-key.ch-s3 { color: var(--s3); }
.chart-key.ch-s4 { color: var(--s4); }
.chart-key.ch-s5 { color: var(--s5); }
.chart-key.ch-s6 { color: var(--s6); }
.chart-key.ch-s7 { color: var(--s7); }
.chart-key.ch-s8 { color: var(--s8); }
.chart-key.ch-other { color: var(--s-other); }
.chart-key.ch-band-ok { color: var(--good); opacity: 0.55; }
.chart-key.ch-band-watch { color: var(--warning); opacity: 0.6; }
.chart-key.ch-band-danger { color: var(--critical); opacity: 0.55; }
.chart-key.ch-band-fight { color: var(--s7); opacity: 0.5; }
.chart-key.ch-band-info { color: var(--ink-3); opacity: 0.5; }
.chart-key.ch-mark-alert { color: var(--critical); }
.chart-key.ch-mark-reflag { color: var(--serious); }
.chart-key.ch-mark-info { color: var(--ink-2); }

.chart-scale {
    display: inline-flex;
    flex-wrap: wrap;
    gap: 4px 14px;
}

.chart-scale-step {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.chart-scale-ramp { border-radius: 2px; }

.ch-grid { stroke: var(--grid); stroke-width: 1; }
.ch-axis { stroke: var(--axis); stroke-width: 1; }
.ch-tick { fill: var(--tick); font-size: 11px; font-variant-numeric: tabular-nums; }
.ch-axis-label { fill: var(--ink-3); font-size: 11.5px; }
.ch-value { fill: var(--ink-2); font-size: 11.5px; font-weight: 600; }
.ch-hit { fill: transparent; cursor: crosshair; }
.ch-hover { fill: var(--neutral-soft); }
.ch-cross { stroke: var(--ink-3); stroke-width: 1; stroke-dasharray: 3 3; }
.ch-break { fill: var(--chart-surface); }

.ch-band-ok { fill: var(--band-ok); }
.ch-band-watch { fill: var(--band-watch); }
.ch-band-danger { fill: var(--band-danger); }
.ch-band-fight { fill: var(--band-fight); }
.ch-band-info { fill: var(--band-info); }

.ch-strip.ch-band-fight { fill: var(--s7); }

.ch-ref { stroke-width: 1.5; fill: none; }
.ch-ref-typical { stroke: var(--ink-3); stroke-dasharray: 2 4; stroke-linecap: round; }
.ch-ref-flag { stroke: var(--critical); stroke-dasharray: 7 4; }
.ch-ref-limit { stroke: var(--serious); stroke-dasharray: 5 4; }
.ch-ref-info { stroke: var(--ink-2); stroke-dasharray: 3 3; }
.ch-ref-solid { stroke-dasharray: none; stroke-width: 2; }

.ch-ref-label {
    fill: var(--ink-2);
    font-size: 11px;
    font-weight: 600;
    paint-order: stroke;
    stroke: var(--chart-surface);
    stroke-width: 3px;
    stroke-linejoin: round;
}

.ch-ref-label-flag { fill: var(--critical-ink); }
.ch-ref-label-limit { fill: var(--ink); }

.ch-line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.ch-dashed { stroke-dasharray: 6 4; stroke-width: 1.75; }
.ch-area { stroke: none; fill-opacity: 0.55; }
.ch-area-edge { stroke-width: 1.25; }
.ch-bar { stroke: none; }
.ch-dot { stroke: var(--chart-surface); stroke-width: 1.5; }
.ch-dot-focus { stroke-width: 2; }

.ch-line.ch-s1, .ch-dot.ch-s1 { stroke: var(--s1); }
.ch-line.ch-s2 { stroke: var(--s2); }
.ch-line.ch-s3 { stroke: var(--s3); }
.ch-line.ch-s4 { stroke: var(--s4); }
.ch-line.ch-s5 { stroke: var(--s5); }
.ch-line.ch-s6 { stroke: var(--s6); }
.ch-line.ch-s7 { stroke: var(--s7); }
.ch-line.ch-s8 { stroke: var(--s8); }
.ch-line.ch-other { stroke: var(--s-other); }

.ch-dot.ch-s1, .ch-dot.ch-s2, .ch-dot.ch-s3, .ch-dot.ch-s4,
.ch-dot.ch-s5, .ch-dot.ch-s6, .ch-dot.ch-s7, .ch-dot.ch-s8, .ch-dot.ch-other { stroke: var(--chart-surface); }

.ch-area.ch-s1, .ch-bar.ch-s1, .ch-dot.ch-s1 { fill: var(--s1); }
.ch-area.ch-s2, .ch-bar.ch-s2, .ch-dot.ch-s2 { fill: var(--s2); }
.ch-area.ch-s3, .ch-bar.ch-s3, .ch-dot.ch-s3 { fill: var(--s3); }
.ch-area.ch-s4, .ch-bar.ch-s4, .ch-dot.ch-s4 { fill: var(--s4); }
.ch-area.ch-s5, .ch-bar.ch-s5, .ch-dot.ch-s5 { fill: var(--s5); }
.ch-area.ch-s6, .ch-bar.ch-s6, .ch-dot.ch-s6 { fill: var(--s6); }
.ch-area.ch-s7, .ch-bar.ch-s7, .ch-dot.ch-s7 { fill: var(--s7); }
.ch-area.ch-s8, .ch-bar.ch-s8, .ch-dot.ch-s8 { fill: var(--s8); }
.ch-area.ch-other, .ch-bar.ch-other, .ch-dot.ch-other { fill: var(--s-other); }

/* Colours by meaning, picked by the page through options.colors (severity bars). */
.ch-bar.ch-sev-low, .ch-area.ch-sev-low { fill: var(--s1); }
.ch-bar.ch-sev-medium, .ch-area.ch-sev-medium { fill: var(--warning); }
.ch-bar.ch-sev-high, .ch-area.ch-sev-high { fill: var(--critical); }
.chart-key.ch-sev-low { color: var(--s1); }
.chart-key.ch-sev-medium { color: var(--warning); }
.chart-key.ch-sev-high { color: var(--critical); }

.ch-mark { stroke: var(--chart-surface); stroke-width: 1.5; }
.ch-mark-alert { fill: var(--critical); }
.ch-mark-reflag { fill: var(--serious); }
.ch-mark-info { fill: var(--ink-2); }

.ch-gauge-value { fill: var(--ink); font-size: 26px; font-weight: 650; font-variant-numeric: tabular-nums; }
.ch-gauge-track { fill: var(--surface-3); }
.ch-gauge-band.ch-band-ok { fill: var(--good); fill-opacity: 0.5; }
.ch-gauge-band.ch-band-watch { fill: var(--warning); fill-opacity: 0.55; }
.ch-gauge-band.ch-band-danger { fill: var(--critical); fill-opacity: 0.6; }
.ch-gauge-band.ch-band-fight { fill: var(--s7); fill-opacity: 0.5; }
.ch-gauge-band.ch-band-info { fill: var(--ink-3); fill-opacity: 0.4; }
.ch-gauge-needle { stroke: var(--ink); stroke-width: 3; stroke-linecap: round; }
.ch-gauge-pointer { fill: var(--ink); }

.ch-lane { fill: transparent; }
.ch-lane-odd { fill: var(--neutral-soft); }
.ch-lane-label { fill: var(--ink-2); font-size: 12px; }
.ch-lane-dot { fill-opacity: 0.85; }
.ch-focus-ring { fill: none; stroke: var(--ink); stroke-width: 2; }
.ch-cell-focus { fill: none; stroke: var(--ink); stroke-width: 1.5; }

/* ---------------------------------------------------------------- responsive */

@media (max-width: 1100px) {
    .config-layout { grid-template-columns: minmax(0, 1fr); }
    .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

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

    .sidebar {
        position: fixed;
        z-index: 40;
        left: 0;
        top: 0;
        bottom: 0;
        width: min(280px, 84vw);
        transform: translateX(-102%);
        transition: transform 0.18s ease-out;
        box-shadow: var(--shadow);
    }

    .shell.nav-open .sidebar { transform: none; }

    .shell.nav-open .scrim {
        display: block;
        position: fixed;
        inset: 0;
        z-index: 30;
        background: rgba(0, 0, 0, 0.45);
    }

    .topbar .menu-button { display: inline-flex; }
    .topbar { padding: 8px 16px; }
    .content { padding: 18px 16px 40px; }
    .charts { grid-template-columns: minmax(0, 1fr); }
    .grid-2 { grid-template-columns: minmax(0, 1fr); }
    .feed-item { grid-template-columns: 64px minmax(0, 1fr) minmax(0, 1fr) 84px; }
    .feed-item .feed-col-opt { display: none; }
}

@media (max-width: 600px) {
    h1 { font-size: 19px; }
    .grid-3 { grid-template-columns: minmax(0, 1fr); }
    .grid-cards { grid-template-columns: minmax(0, 1fr); }
    .grid-tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
    .tile { padding: 12px 14px; }
    .tile-value { font-size: 22px; }
    .card { padding: 14px; }
    .counts { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .col-opt { display: none; }
    .table th, .table td { padding: 8px 8px; }
    .feed-item {
        grid-template-columns: 54px minmax(0, 1.2fr) minmax(0, 1fr) auto;
        padding: 10px 14px;
        gap: 8px;
    }
    .feed-item .feed-col-opt2 { display: none; }
    .topbar-tools .hide-narrow { display: none; }
    .filters .field { flex: 1 1 140px; }
    .barlist-row { grid-template-columns: minmax(80px, 38%) minmax(0, 1fr) 36px; }
    .dl { grid-template-columns: minmax(0, 1fr); gap: 2px; }
    .dl dd { margin-bottom: 8px; }
    .page-actions { width: 100%; }
}

/* the profile's assessment (overview tab) */
.assessment-headline { margin: 0 0 8px; font-size: 1.05rem; font-weight: 600; }
.assessment-reasons { margin: 0 0 8px; padding-left: 1.2em; }
.assessment-reasons li { margin: 2px 0; }
