/* DeepBell dashboard. Dark is the default theme; [data-theme="light"] switches the tokens. */

:root {
    color-scheme: dark;
    --bg: #03050c;
    --bg-side: rgba(4, 7, 16, 0.82);
    --surface: rgba(11, 17, 34, 0.66);
    --surface-solid: #0a1022;
    --surface-2: rgba(255, 255, 255, 0.025);
    --surface-3: rgba(255, 255, 255, 0.055);
    --well: rgba(1, 3, 9, 0.55);
    --border: rgba(255, 255, 255, 0.07);
    --border-strong: rgba(255, 255, 255, 0.15);
    --highlight: inset 0 1px 0 rgba(255, 255, 255, 0.04);
    --text: #eef2f7;
    --text-2: #a3b0c2;
    --text-3: #7f8da3;
    --heading: #ffffff;

    --accent: #00f2fe;
    --accent-text: #3ff2ff;
    --accent-ink: #011218;
    --accent-soft: rgba(0, 242, 254, 0.08);
    --accent-line: rgba(0, 242, 254, 0.3);
    --accent-glow: rgba(0, 242, 254, 0.28);
    --purple: #a855f7;
    --purple-text: #c99bff;
    --grad: linear-gradient(135deg, #00f2fe 0%, #4f46e5 55%, #7000ff 100%);
    --btn-grad: linear-gradient(135deg, #00f2fe 0%, #00c6ff 100%);

    --ok: #10b981;
    --ok-text: #34d399;
    --ok-soft: rgba(16, 185, 129, 0.12);
    --warn: #f59e0b;
    --warn-text: #fbbf24;
    --warn-soft: rgba(245, 158, 11, 0.12);
    --bad: #ef4444;
    --bad-text: #f87171;
    --bad-soft: rgba(239, 68, 68, 0.12);
    --info: #38bdf8;
    --info-text: #7dd3fc;
    --info-soft: rgba(56, 189, 248, 0.12);
    --orange: #fb923c;
    --orange-soft: rgba(249, 115, 22, 0.12);
    --yellow: #facc15;
    --yellow-soft: rgba(250, 204, 21, 0.1);
    --violet: #c084fc;
    --violet-soft: rgba(192, 132, 252, 0.12);

    --shadow: 0 18px 44px rgba(0, 0, 0, 0.32);
    --shadow-sm: 0 6px 18px rgba(0, 0, 0, 0.28);
    --ring: 0 0 0 3px rgba(0, 242, 254, 0.38);

    --chart-grid: rgba(255, 255, 255, 0.06);
    --chart-tick: #8391a7;
    --chart-cpu: #00f2fe;
    --chart-ram: #a855f7;
    --chart-base: rgba(163, 176, 194, 0.6);
    --chart-alert: #f59e0b;
    --chart-flag: #ef4444;
    --chart-band: rgba(239, 68, 68, 0.11);
    --chart-synthetic: #64748b;
    --chart-gap: rgba(255, 255, 255, 0.035);
    --chart-tooltip: #0b1224;

    --strip-healthy: #10b981;
    --strip-degraded: #f59e0b;
    --strip-incident: #ef4444;
    --strip-synthetic: #3a4458;
    --strip-nodata: rgba(255, 255, 255, 0.07);

    --radius-lg: 20px;
    --radius: 14px;
    --radius-sm: 10px;
    --radius-xs: 7px;
    --font-sans: 'Plus Jakarta Sans', 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
    --font-display: 'Outfit', var(--font-sans);
    --font-mono: 'Fira Code', ui-monospace, 'Cascadia Mono', Consolas, monospace;
    --ease: cubic-bezier(0.16, 1, 0.3, 1);
}

[data-theme="light"] {
    color-scheme: light;
    --bg: #eef2f8;
    --bg-side: rgba(255, 255, 255, 0.86);
    --surface: rgba(255, 255, 255, 0.92);
    --surface-solid: #ffffff;
    --surface-2: #f6f8fc;
    --surface-3: #edf1f7;
    --well: #f4f7fb;
    --border: rgba(15, 23, 42, 0.09);
    --border-strong: rgba(15, 23, 42, 0.18);
    --highlight: inset 0 1px 0 rgba(255, 255, 255, 0.9);
    --text: #0f172a;
    --text-2: #475569;
    --text-3: #5b687c;
    --heading: #0b1220;

    --accent: #00c8d7;
    --accent-text: #0e7490;
    --accent-ink: #011218;
    --accent-soft: rgba(8, 145, 178, 0.08);
    --accent-line: rgba(8, 145, 178, 0.32);
    --accent-glow: rgba(8, 145, 178, 0.2);
    --purple: #7c3aed;
    --purple-text: #6d28d9;
    --btn-grad: linear-gradient(135deg, #22e4f0 0%, #00bde6 100%);

    --ok-text: #047857;
    --ok-soft: rgba(16, 185, 129, 0.11);
    --warn-text: #9a4a08;
    --warn-soft: rgba(245, 158, 11, 0.13);
    --bad-text: #b91c1c;
    --bad-soft: rgba(239, 68, 68, 0.09);
    --info-text: #0369a1;
    --info-soft: rgba(56, 189, 248, 0.12);
    --orange: #b53a0b;
    --orange-soft: rgba(234, 88, 12, 0.09);
    --yellow: #8c5606;
    --yellow-soft: rgba(202, 138, 4, 0.1);
    --violet: #7e22ce;
    --violet-soft: rgba(147, 51, 234, 0.09);

    --shadow: 0 1px 2px rgba(15, 23, 42, 0.05), 0 10px 30px rgba(15, 23, 42, 0.06);
    --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06), 0 4px 12px rgba(15, 23, 42, 0.05);
    --ring: 0 0 0 3px rgba(8, 145, 178, 0.32);

    --chart-grid: rgba(15, 23, 42, 0.07);
    --chart-tick: #5b687c;
    --chart-cpu: #0891b2;
    --chart-ram: #7c3aed;
    --chart-base: rgba(71, 85, 105, 0.6);
    --chart-alert: #d97706;
    --chart-flag: #dc2626;
    --chart-band: rgba(220, 38, 38, 0.08);
    --chart-synthetic: #94a3b8;
    --chart-gap: rgba(15, 23, 42, 0.045);
    --chart-tooltip: #0f172a;

    --strip-synthetic: #cbd5e1;
    --strip-nodata: #e2e8f0;
}

/* ---------- Base ---------- */

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

* {
    margin: 0;
    padding: 0;
}

html {
    -webkit-text-size-adjust: 100%;
    scroll-padding-top: 24px;
}

body {
    font-family: var(--font-sans);
    font-size: 15px;
    line-height: 1.55;
    background-color: var(--bg);
    color: var(--text);
    min-height: 100vh;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    transition: background-color 0.25s ease, color 0.25s ease;
}

h1, h2, h3, h4 {
    font-family: var(--font-display);
    color: var(--heading);
    font-weight: 600;
    letter-spacing: -0.015em;
    line-height: 1.25;
}

a {
    color: var(--accent-text);
    text-decoration-thickness: 1px;
    text-underline-offset: 3px;
}

code {
    font-family: var(--font-mono);
    font-size: 0.86em;
    background: var(--surface-3);
    border: 1px solid var(--border);
    border-radius: 5px;
    padding: 0.05em 0.35em;
}

button,
input {
    font: inherit;
    color: inherit;
}

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

[hidden] {
    display: none !important;
}

::selection {
    background: rgba(0, 242, 254, 0.25);
}

.sprite {
    position: absolute;
    width: 0;
    height: 0;
    overflow: hidden;
}

.icon {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

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

.skip-link {
    position: absolute;
    left: 16px;
    top: -60px;
    z-index: 200;
    background: var(--surface-solid);
    color: var(--text);
    padding: 10px 16px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-strong);
    font-weight: 600;
    text-decoration: none;
}

.skip-link:focus {
    top: 16px;
}

/* Static ambient light behind the app (no motion). */
.ambient {
    position: fixed;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    background:
        radial-gradient(900px 560px at 88% -12%, rgba(0, 242, 254, 0.08), transparent 62%),
        radial-gradient(760px 520px at -6% 108%, rgba(112, 0, 255, 0.075), transparent 62%);
}

[data-theme="light"] .ambient {
    background:
        radial-gradient(900px 560px at 88% -12%, rgba(0, 200, 215, 0.1), transparent 62%),
        radial-gradient(760px 520px at -6% 108%, rgba(124, 58, 237, 0.06), transparent 62%);
}

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

.app {
    position: relative;
    z-index: 1;
    display: grid;
    grid-template-columns: 264px minmax(0, 1fr);
    min-height: 100vh;
}

.sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    display: flex;
    flex-direction: column;
    gap: 22px;
    padding: 26px 18px 22px;
    background: var(--bg-side);
    border-right: 1px solid var(--border);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
    z-index: 40;
}

.sidebar-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 0 6px 20px;
    border-bottom: 1px solid var(--border);
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    color: var(--heading);
    border-radius: var(--radius-xs);
}

.brand-logo {
    width: 26px;
    height: 26px;
    color: var(--accent);
    fill: none;
    stroke: currentColor;
    stroke-width: 2.4;
    stroke-linecap: round;
    stroke-linejoin: round;
    filter: drop-shadow(0 0 8px var(--accent-glow));
}

.brand-text {
    font-family: var(--font-display);
    font-size: 1.32rem;
    font-weight: 700;
    letter-spacing: -0.03em;
}

.badge-sre {
    font-size: 0.66rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    color: #fff;
    background: var(--grad);
    padding: 3px 7px;
    border-radius: 6px;
}

.nav {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex-grow: 1;
}

.nav-item {
    position: relative;
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 42px;
    padding: 9px 14px;
    border-radius: 12px;
    border: 1px solid transparent;
    color: var(--text-2);
    font-weight: 600;
    font-size: 0.93rem;
    text-decoration: none;
    transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease, transform 0.25s var(--ease);
}

.nav-item .icon {
    color: var(--text-3);
    transition: color 0.2s ease;
}

.nav-item:hover {
    background: var(--surface-3);
    color: var(--heading);
    transform: translateX(3px);
}

.nav-item[aria-current="page"] {
    background: var(--accent-soft);
    border-color: var(--accent-line);
    color: var(--heading);
    box-shadow: var(--highlight), 0 4px 14px rgba(0, 242, 254, 0.06);
}

.nav-item[aria-current="page"] .icon {
    color: var(--accent-text);
}

.nav-count {
    margin-left: auto;
    font-size: 0.7rem;
    font-weight: 700;
    color: #fff;
    background: var(--bad);
    border-radius: 999px;
    padding: 1px 8px;
    font-variant-numeric: tabular-nums;
    box-shadow: 0 0 12px rgba(239, 68, 68, 0.45);
}

.sidebar-footer {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding-top: 18px;
    border-top: 1px solid var(--border);
}

.status-box {
    display: flex;
    align-items: center;
    gap: 11px;
    min-width: 0;
    padding: 11px 14px;
    border-radius: 12px;
    background: var(--well);
    border: 1px solid var(--border);
}

.sidebar-top .status-box-top {
    display: none;
}

.status-text {
    font-size: 0.84rem;
    font-weight: 700;
    color: var(--heading);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.pulse-dot {
    position: relative;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
    background: var(--text-3);
}

[data-tone="ok"] .pulse-dot { background: var(--ok); box-shadow: 0 0 10px var(--ok); }
[data-tone="warn"] .pulse-dot { background: var(--warn); box-shadow: 0 0 10px var(--warn); }
[data-tone="bad"] .pulse-dot { background: var(--bad); box-shadow: 0 0 10px var(--bad); }
[data-tone="neutral"] .pulse-dot { background: var(--text-3); }

.pulse-dot::after {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 50%;
    background: inherit;
    animation: pulse 2s infinite ease-out;
}

@keyframes pulse {
    0% { transform: scale(1); opacity: 0.75; }
    100% { transform: scale(3); opacity: 0; }
}

.env-note {
    font-size: 0.74rem;
    color: var(--text-3);
    padding: 0 4px;
}

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

.sidebar-links a,
.link-btn {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    min-height: 34px;
    padding: 4px;
    border-radius: var(--radius-xs);
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-2);
    text-decoration: none;
    background: none;
    border: 0;
    cursor: pointer;
    text-align: left;
}

.sidebar-links a .icon,
.link-btn .icon {
    width: 16px;
    height: 16px;
}

.sidebar-links a:hover,
.link-btn:hover {
    color: var(--heading);
}

.theme-toggle .icon-moon,
[data-theme="light"] .theme-toggle .icon-sun {
    display: none;
}

[data-theme="light"] .theme-toggle .icon-moon {
    display: block;
}

/* ---------- Main column ---------- */

.main {
    min-width: 0;
    padding: 30px 40px 48px;
    display: flex;
    flex-direction: column;
    gap: 24px;
    outline: none;
}

.main > * {
    width: 100%;
    max-width: 1520px;
}

.header {
    position: relative;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 24px;
    padding-bottom: 22px;
    border-bottom: 1px solid var(--border);
}

.eyebrow {
    display: block;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--accent-text);
}

.header-title h1 {
    font-size: 1.95rem;
    font-weight: 700;
    letter-spacing: -0.03em;
    margin-top: 4px;
    outline: none;
}

.stat-cards {
    display: flex;
    gap: 14px;
}

.stat-card {
    width: 214px;
    display: flex;
    flex-direction: column;
    gap: 5px;
    padding: 12px 16px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--highlight);
    transition: border-color 0.2s ease;
}

.stat-card:hover {
    border-color: var(--border-strong);
}

.stat-label,
.kpi-label {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-3);
}

.stat-label .icon,
.kpi-label .icon {
    width: 14px;
    height: 14px;
}

.stat-row {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 10px;
}

.stat-value {
    font-family: var(--font-display);
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--heading);
    font-variant-numeric: tabular-nums;
    line-height: 1.1;
    white-space: nowrap;
}

.stat-unit {
    font-family: var(--font-sans);
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-2);
    margin-left: 3px;
}

.spark {
    width: 84px;
    height: 26px;
    overflow: visible;
}

.spark path {
    fill: none;
    stroke: var(--chart-cpu);
    stroke-width: 1.6;
    vector-effect: non-scaling-stroke;
}

.spark .spark-area {
    stroke: none;
    fill: var(--chart-cpu);
    opacity: 0.12;
}

.spark-ram path {
    stroke: var(--chart-ram);
}

.spark-ram .spark-area {
    fill: var(--chart-ram);
}

.stat-bar {
    height: 5px;
    border-radius: 3px;
    background: var(--surface-3);
    overflow: hidden;
}

.stat-progress {
    height: 100%;
    width: 0;
    border-radius: 3px;
    background: var(--accent);
    transition: width 0.5s var(--ease), background-color 0.3s ease;
}

.stat-progress[data-level="warn"] { background: var(--warn); }
.stat-progress[data-level="high"] { background: var(--bad); }

.stat-note {
    font-size: 0.7rem;
    color: var(--text-3);
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.demo-chip {
    position: absolute;
    left: 50%;
    bottom: -16px;
    transform: translateX(-50%);
    display: inline-flex;
    align-items: center;
    gap: 8px;
    max-width: min(92%, 640px);
    padding: 6px 14px;
    border-radius: 999px;
    background: var(--surface-solid);
    border: 1px solid var(--accent-line);
    box-shadow: var(--shadow-sm), 0 0 18px var(--accent-glow);
    color: var(--heading);
    font-size: 0.8rem;
    font-weight: 600;
    text-decoration: none;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    z-index: 5;
}

.demo-chip::before {
    content: '';
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--accent);
    box-shadow: 0 0 8px var(--accent);
    flex-shrink: 0;
}

/* ---------- Views and grid ---------- */

.view {
    display: flex;
    flex-direction: column;
    gap: 24px;
    animation: rise 0.3s var(--ease);
}

@keyframes rise {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: none; }
}

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

.grid > * {
    min-width: 0;
}

.col-4 { grid-column: span 4; }
.col-5 { grid-column: span 5; }
.col-6 { grid-column: span 6; }
.col-7 { grid-column: span 7; }
.col-8 { grid-column: span 8; }
.col-12 { grid-column: 1 / -1; }

.panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 24px;
    box-shadow: var(--highlight), var(--shadow);
    transition: border-color 0.25s ease;
}

.panel:hover {
    border-color: var(--border-strong);
}

.panel-flush {
    padding: 8px;
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
    margin-bottom: 18px;
}

.panel-header > div {
    min-width: 0;
}

.panel h2 {
    font-size: 1.14rem;
}

.panel-sub {
    font-size: 0.82rem;
    color: var(--text-2);
    margin-top: 3px;
    line-height: 1.5;
}

.panel-meta {
    font-size: 0.76rem;
    color: var(--text-3);
    white-space: nowrap;
}

.panel-foot {
    font-size: 0.76rem;
    color: var(--text-3);
    margin-top: 14px;
}

.panel-tools {
    display: flex;
    align-items: center;
    gap: 14px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.view-lead {
    max-width: 82ch;
    color: var(--text-2);
    font-size: 0.92rem;
}

.view-lead strong {
    color: var(--heading);
}

.view-intro {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    gap: 24px;
    flex-wrap: wrap;
}

.note {
    font-size: 0.8rem;
    color: var(--text-2);
    line-height: 1.55;
    margin-top: 12px;
}

.sub-title {
    font-size: 0.78rem;
    font-family: var(--font-sans);
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-3);
    margin: 22px 0 10px;
}

.text-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--accent-text);
    text-decoration: none;
    white-space: nowrap;
    border-radius: 4px;
}

.text-link .icon {
    width: 15px;
    height: 15px;
    transition: transform 0.2s ease;
}

.text-link:hover .icon {
    transform: translateX(3px);
}

.empty-state,
.table-empty,
.log-empty {
    color: var(--text-3);
    font-size: 0.86rem;
}

.empty-state {
    text-align: center;
    padding: 28px 12px;
}

.error-text {
    color: var(--bad-text);
    font-size: 0.86rem;
}

/* ---------- Buttons, badges, inputs ---------- */

.btn {
    --btn-bg: var(--btn-grad);
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 42px;
    padding: 0 20px;
    border-radius: 11px;
    border: 1px solid transparent;
    background: var(--btn-bg);
    color: var(--accent-ink);
    font-family: var(--font-sans);
    font-weight: 700;
    font-size: 0.86rem;
    letter-spacing: -0.01em;
    text-decoration: none;
    white-space: nowrap;
    cursor: pointer;
    transition: transform 0.18s ease, box-shadow 0.18s ease, background-color 0.18s ease, border-color 0.18s ease, opacity 0.18s ease;
}

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

.btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 8px 20px var(--accent-glow);
}

.btn:active {
    transform: translateY(0);
    box-shadow: none;
}

.btn:focus-visible {
    outline: none;
    box-shadow: var(--ring);
}

.btn:disabled,
.btn[aria-disabled="true"] {
    opacity: 0.45;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.btn-secondary {
    --btn-bg: var(--surface-2);
    color: var(--heading);
    border-color: var(--border-strong);
}

.btn-secondary:hover {
    background: var(--surface-3);
    box-shadow: none;
    border-color: var(--accent-line);
}

.btn-danger {
    --btn-bg: linear-gradient(135deg, #f87171 0%, #ef4444 100%);
    color: #fff;
}

.btn-danger:hover {
    box-shadow: 0 8px 20px rgba(239, 68, 68, 0.3);
}

.btn-small {
    min-height: 36px;
    padding: 0 14px;
    font-size: 0.8rem;
    border-radius: 9px;
}

.btn.is-loading {
    pointer-events: none;
}

.btn.is-loading::before {
    content: '';
    width: 14px;
    height: 14px;
    border-radius: 50%;
    border: 2px solid currentColor;
    border-right-color: transparent;
    animation: spin 0.8s linear infinite;
}

.btn.is-loading .icon {
    display: none;
}

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

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

.badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 10px;
    border-radius: 999px;
    border: 1px solid var(--border-strong);
    background: var(--surface-2);
    color: var(--text-2);
    font-size: 0.72rem;
    font-weight: 700;
    white-space: nowrap;
}

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

.badge[data-tone="ok"] { color: var(--ok-text); background: var(--ok-soft); border-color: rgba(16, 185, 129, 0.32); }
.badge[data-tone="warn"] { color: var(--warn-text); background: var(--warn-soft); border-color: rgba(245, 158, 11, 0.34); }
.badge[data-tone="bad"] { color: var(--bad-text); background: var(--bad-soft); border-color: rgba(239, 68, 68, 0.34); }
.badge[data-tone="info"] { color: var(--info-text); background: var(--info-soft); border-color: rgba(56, 189, 248, 0.32); }
.badge[data-tone="accent"] { color: var(--accent-text); background: var(--accent-soft); border-color: var(--accent-line); }
.badge[data-tone="violet"] { color: var(--purple-text); background: var(--violet-soft); border-color: rgba(168, 85, 247, 0.34); }

.count-pill {
    display: inline-block;
    min-width: 24px;
    margin-left: 6px;
    padding: 0 7px;
    border-radius: 999px;
    background: var(--surface-3);
    color: var(--text-2);
    font-family: var(--font-sans);
    font-size: 0.72rem;
    font-weight: 700;
    text-align: center;
    vertical-align: 2px;
    font-variant-numeric: tabular-nums;
}

.input {
    width: 100%;
    min-height: 42px;
    padding: 0 14px;
    border-radius: 10px;
    border: 1px solid var(--border-strong);
    background: var(--well);
    color: var(--heading);
    font-family: var(--font-mono);
    font-size: 0.9rem;
    transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

.input:hover {
    border-color: var(--accent-line);
}

.input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: var(--ring);
}

.input[aria-invalid="true"] {
    border-color: var(--bad);
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.2);
}

.field-error {
    min-height: 1.2em;
    margin-top: 6px;
    font-size: 0.78rem;
    color: var(--bad-text);
}

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

.seg button {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 34px;
    padding: 0 14px;
    border: 0;
    border-radius: 8px;
    background: none;
    color: var(--text-2);
    font-size: 0.8rem;
    font-weight: 700;
    cursor: pointer;
    transition: background-color 0.18s ease, color 0.18s ease;
}

.seg button:hover {
    color: var(--heading);
}

.seg button[aria-pressed="true"] {
    background: var(--accent-soft);
    color: var(--accent-text);
    box-shadow: inset 0 0 0 1px var(--accent-line);
}

.seg-count {
    font-variant-numeric: tabular-nums;
    color: var(--text-3);
    font-weight: 600;
}

.live-tag {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 3px 10px;
    border-radius: 999px;
    border: 1px solid var(--accent-line);
    background: var(--accent-soft);
    color: var(--accent-text);
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    white-space: nowrap;
}

.live-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--accent);
    box-shadow: 0 0 8px var(--accent);
    animation: blink 2s ease-in-out infinite;
}

@keyframes blink {
    50% { opacity: 0.35; }
}

/* Skeleton loaders */
.skeleton,
.skeleton-row {
    background: linear-gradient(90deg, var(--surface-3) 0%, var(--surface-2) 50%, var(--surface-3) 100%);
    background-size: 200% 100%;
    animation: shimmer 1.4s ease-in-out infinite;
}

.skeleton-row {
    list-style: none;
    height: 46px;
    border-radius: var(--radius-sm);
    margin-bottom: 8px;
}

@keyframes shimmer {
    from { background-position: 100% 0; }
    to { background-position: -100% 0; }
}

/* ---------- Status banner ---------- */

.status-banner {
    --tone: var(--text-3);
    --tone-soft: var(--surface-2);
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px 20px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    border-left: 3px solid var(--tone);
    background: linear-gradient(90deg, var(--tone-soft), transparent 70%), var(--surface);
    box-shadow: var(--highlight), var(--shadow-sm);
    transition: border-color 0.3s ease;
}

.status-banner[data-tone="ok"] { --tone: var(--ok); --tone-soft: var(--ok-soft); }
.status-banner[data-tone="warn"] { --tone: var(--warn); --tone-soft: var(--warn-soft); }
.status-banner[data-tone="bad"] { --tone: var(--bad); --tone-soft: var(--bad-soft); }

.banner-icon {
    display: grid;
    place-items: center;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: var(--tone-soft);
    border: 1px solid var(--border);
    flex-shrink: 0;
}

.banner-icon .pulse-dot {
    width: 10px;
    height: 10px;
}

.banner-copy {
    min-width: 0;
    flex: 1;
}

.banner-title {
    font-family: var(--font-display);
    font-size: 1.08rem;
    font-weight: 600;
    color: var(--heading);
}

.banner-detail {
    font-size: 0.84rem;
    color: var(--text-2);
    margin-top: 1px;
}

.banner-detail a {
    font-weight: 600;
}

.banner-facts {
    display: flex;
    gap: 22px;
    flex-shrink: 0;
}

.banner-facts div {
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.banner-facts dt {
    font-size: 0.66rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-3);
}

.banner-facts dd {
    font-family: var(--font-mono);
    font-size: 0.8rem;
    color: var(--text);
    white-space: nowrap;
}

/* ---------- Hero and pipeline ---------- */

.hero {
    position: relative;
    overflow: hidden;
    border-color: var(--accent-line);
    background:
        radial-gradient(520px 260px at 100% 0%, rgba(0, 242, 254, 0.07), transparent 70%),
        var(--surface);
}

[data-theme="light"] .hero {
    background:
        radial-gradient(520px 260px at 100% 0%, rgba(0, 200, 215, 0.09), transparent 70%),
        var(--surface);
}

.hero-lead {
    font-family: var(--font-display);
    font-size: 1.55rem;
    line-height: 1.32;
    font-weight: 600;
    letter-spacing: -0.02em;
    color: var(--heading);
    max-width: 34ch;
}

.hero-sub {
    margin-top: 10px;
    font-size: 0.9rem;
    color: var(--text-2);
    max-width: 70ch;
}

.hero-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 18px;
}

.pipeline-head {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 26px 0 14px;
    padding-top: 20px;
    border-top: 1px solid var(--border);
}

.pipeline-head h2 {
    font-size: 1.02rem;
}

.pipeline {
    list-style: none;
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 14px;
}

.pipe-step {
    --node: var(--border-strong);
    --node-bg: var(--surface-2);
    --node-ink: var(--text-3);
    --detail: var(--text-3);
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-width: 0;
}

/* Connector from this node to the next one. */
.pipe-step:not(:last-child)::after {
    content: '';
    position: absolute;
    top: 19px;
    left: 48px;
    right: -6px;
    height: 2px;
    border-radius: 2px;
    background: linear-gradient(90deg, var(--line, var(--border-strong)) var(--fill, 0%), var(--border) var(--fill, 0%));
}

.pipe-node {
    position: relative;
    display: grid;
    place-items: center;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 1.5px solid var(--node);
    background: var(--node-bg);
    color: var(--node-ink);
    transition: background-color 0.3s ease, border-color 0.3s ease, color 0.3s ease, box-shadow 0.3s ease;
}

.pipe-node .icon {
    width: 18px;
    height: 18px;
}

.pipe-copy {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.pipe-copy strong {
    display: inline-flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px 7px;
    font-family: var(--font-display);
    font-size: 0.98rem;
    font-weight: 600;
    color: var(--heading);
}

.pipe-n {
    font-family: var(--font-mono);
    font-size: 0.72rem;
    font-weight: 500;
    color: var(--text-3);
}

.pipe-what {
    font-size: 0.78rem;
    color: var(--text-2);
    line-height: 1.45;
}

.pipe-detail {
    margin-top: 4px;
    font-family: var(--font-mono);
    font-size: 0.72rem;
    line-height: 1.45;
    color: var(--detail);
    min-height: 2.9em;
    transition: color 0.3s ease;
}

.pipe-step[data-state="active"] {
    --node: var(--accent);
    --node-bg: var(--accent-soft);
    --node-ink: var(--accent-text);
    --detail: var(--accent-text);
}

.pipe-step[data-state="active"] .pipe-node {
    animation: ring 1.8s ease-out infinite;
}

.pipe-step[data-state="waiting"] {
    --node: var(--warn);
    --node-bg: var(--warn-soft);
    --node-ink: var(--warn-text);
    --detail: var(--warn-text);
}

.pipe-step[data-state="waiting"] .pipe-node {
    animation: ring-warn 1.8s ease-out infinite;
}

.pipe-step[data-state="done"] {
    --node: var(--accent);
    --node-bg: var(--accent);
    --node-ink: var(--accent-ink);
    --detail: var(--text-2);
    --line: var(--accent);
    --fill: 100%;
}

.pipe-step[data-current] .pipe-copy strong::after {
    content: 'now';
    font-family: var(--font-sans);
    font-size: 0.62rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--accent-ink);
    background: var(--accent);
    border-radius: 4px;
    padding: 1px 5px;
    white-space: nowrap;
}

.pipe-step[data-current][data-state="waiting"] .pipe-copy strong::after {
    content: 'act now';
    background: var(--warn);
    color: #1c1302;
}

@keyframes ring {
    0% { box-shadow: 0 0 0 0 rgba(0, 242, 254, 0.35); }
    100% { box-shadow: 0 0 0 10px rgba(0, 242, 254, 0); }
}

@keyframes ring-warn {
    0% { box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.4); }
    100% { box-shadow: 0 0 0 10px rgba(245, 158, 11, 0); }
}

.pipeline-note {
    margin-top: 12px;
    font-size: 0.78rem;
    color: var(--text-3);
}

.pipeline-compact {
    gap: 8px;
    margin-bottom: 4px;
}

.pipeline-compact .pipe-step {
    align-items: center;
    text-align: center;
    gap: 6px;
}

.pipeline-compact .pipe-step:not(:last-child)::after {
    top: 15px;
    left: calc(50% + 20px);
    right: calc(-50% + 16px);
}

.pipeline-compact .pipe-node {
    width: 32px;
    height: 32px;
}

.pipeline-compact .pipe-node .icon {
    width: 15px;
    height: 15px;
}

.pipeline-compact .pipe-copy strong {
    font-size: 0.8rem;
    justify-content: center;
}

.pipeline-compact .pipe-copy strong::after,
.pipeline-compact .pipe-detail {
    display: none;
}

.pipe-caption {
    min-height: 2.6em;
    margin: 8px 0 16px;
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    background: var(--well);
    border: 1px solid var(--border);
    font-family: var(--font-mono);
    font-size: 0.74rem;
    color: var(--text-2);
}

.pipe-caption b {
    color: var(--accent-text);
    font-weight: 500;
}

.pipe-caption[data-state="waiting"] b {
    color: var(--warn-text);
}

/* ---------- Guided demo ---------- */

.demo-panel {
    display: flex;
    flex-direction: column;
}

.demo-panel .panel-header {
    margin-bottom: 12px;
}

.demo-progress {
    height: 4px;
    border-radius: 2px;
    background: var(--surface-3);
    overflow: hidden;
    margin-bottom: 8px;
}

.demo-progress-fill {
    height: 100%;
    width: 0;
    background: var(--grad);
    border-radius: 2px;
    transition: width 0.5s var(--ease);
}

.steps {
    list-style: none;
    display: flex;
    flex-direction: column;
}

.step {
    display: grid;
    grid-template-columns: 26px minmax(0, 1fr) auto;
    gap: 12px;
    align-items: start;
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
}

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

.step-mark {
    position: relative;
    display: grid;
    place-items: center;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: 1.5px solid var(--border-strong);
    color: var(--text-3);
    font-family: var(--font-mono);
    font-size: 0.68rem;
    transition: background-color 0.25s ease, border-color 0.25s ease;
}

.step-mark .icon {
    display: none;
    width: 13px;
    height: 13px;
    stroke-width: 3;
}

.step-title {
    display: block;
    font-size: 0.86rem;
    font-weight: 600;
    color: var(--text-2);
    line-height: 1.5;
}

.step-detail {
    display: block;
    font-size: 0.76rem;
    color: var(--text-3);
    line-height: 1.45;
}

.step-detail:empty {
    display: none;
}

.step-time {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    color: var(--text-3);
    padding-top: 3px;
}

.step[data-state="active"] .step-mark {
    border-color: var(--accent);
    border-right-color: transparent;
    animation: spin 0.9s linear infinite;
}

.step[data-state="active"] .step-num {
    animation: spin 0.9s linear infinite reverse;
}

.step[data-state="active"] .step-title {
    color: var(--heading);
}

.step[data-state="active"] .step-detail {
    color: var(--accent-text);
}

.step[data-state="done"] .step-mark {
    background: var(--accent);
    border-color: var(--accent);
    color: var(--accent-ink);
}

.step[data-state="done"] .step-mark .icon {
    display: block;
}

.step[data-state="done"] .step-num,
.step[data-state="failed"] .step-num {
    display: none;
}

.step[data-state="done"] .step-title {
    color: var(--text);
}

.step[data-state="done"]:not(.is-latest) .step-detail {
    display: none;
}

.step[data-state="failed"] .step-mark {
    background: var(--bad);
    border-color: var(--bad);
}

.step[data-state="failed"] .step-mark::after {
    content: '!';
    color: #fff;
    font-family: var(--font-sans);
    font-weight: 800;
    font-size: 0.78rem;
}

.step[data-state="failed"] .step-detail {
    color: var(--bad-text);
}

.demo-foot {
    margin-top: auto;
    padding-top: 12px;
    font-size: 0.78rem;
    color: var(--text-3);
    line-height: 1.5;
}

.demo-foot[data-tone="ok"] { color: var(--ok-text); }
.demo-foot[data-tone="bad"] { color: var(--bad-text); }

.demo-foot a {
    font-weight: 600;
}

/* ---------- KPI tiles ---------- */

.kpis {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 24px;
}

.kpi {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas:
        "label label"
        "value bars"
        "note note";
    align-items: end;
    column-gap: 12px;
    padding: 18px 20px;
    border-radius: var(--radius);
    background: var(--surface);
    border: 1px solid var(--border);
    box-shadow: var(--highlight), var(--shadow-sm);
}

.kpi-label {
    grid-area: label;
    margin-bottom: 8px;
}

.kpi-value {
    grid-area: value;
    font-family: var(--font-display);
    font-size: 1.85rem;
    font-weight: 600;
    line-height: 1.1;
    color: var(--heading);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.kpi-value small {
    font-family: var(--font-sans);
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-2);
    margin-left: 3px;
}

.kpi-value[data-tone="bad"] { color: var(--bad-text); }
.kpi-value[data-tone="ok"] { color: var(--ok-text); }

.kpi-note {
    grid-area: note;
    margin-top: 6px;
    font-size: 0.74rem;
    color: var(--text-3);
}

.kpi-bars,
.kpi-meter {
    grid-area: bars;
    align-self: end;
}

.kpi-bars {
    width: 104px;
    height: 34px;
    overflow: visible;
}

.kpi-bars rect {
    fill: var(--accent);
    opacity: 0.75;
}

.kpi-bars rect[data-tone="bad"] { fill: var(--bad); opacity: 0.9; }
.kpi-bars rect[data-tone="muted"] { fill: var(--text-3); opacity: 0.35; }
.kpi-bars rect[data-tone="ram"] { fill: var(--purple); }

/* Each bar links to its incident; its name shows on hover. */
.kpi-bars a rect {
    transition: opacity 0.15s ease;
}

.kpi-bars:hover a rect {
    opacity: 0.4;
}

.kpi-bars a:hover rect {
    opacity: 1;
}

.kpi-meter {
    width: 104px;
    height: 6px;
    margin-bottom: 12px;
    border-radius: 3px;
    background: var(--surface-3);
    overflow: hidden;
}

.kpi-meter-fill {
    height: 100%;
    width: 0;
    border-radius: 3px;
    background: var(--ok);
    transition: width 0.6s var(--ease);
}

/* ---------- Charts ---------- */

.chart-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 12px;
}

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

.chart-now {
    font-family: var(--font-display);
    font-size: 1.4rem;
    font-weight: 600;
    color: var(--heading);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.chart-now small {
    font-family: var(--font-sans);
    font-size: 0.75rem;
    color: var(--text-2);
    margin-left: 3px;
}

.series-dot {
    width: 10px;
    height: 10px;
    border-radius: 3px;
    flex-shrink: 0;
}

.series-dot[data-series="cpu"] { background: var(--chart-cpu); box-shadow: 0 0 10px var(--chart-cpu); }
.series-dot[data-series="ram"] { background: var(--chart-ram); box-shadow: 0 0 10px var(--chart-ram); }

[data-theme="light"] .series-dot {
    box-shadow: none !important;
}

.chart-box {
    position: relative;
    height: 220px;
    border-radius: var(--radius);
    background: var(--well);
    border: 1px solid var(--border);
    padding: 12px 10px 6px 6px;
}

.chart-tall { height: 260px; }
.chart-mini { height: 128px; padding: 8px 8px 4px 4px; }
.chart-square { height: 300px; }

.chart-box canvas {
    display: block;
}

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

.chart {
    min-width: 0;
}

.chart figcaption {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
}

.chart-title {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-family: var(--font-display);
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--heading);
}

.chart-unit {
    font-family: var(--font-mono);
    font-size: 0.74rem;
    color: var(--text-3);
    white-space: nowrap;
}

.chart-fallback {
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    border: 1px dashed var(--border-strong);
    color: var(--text-2);
    font-size: 0.84rem;
}

.legend {
    list-style: none;
    display: flex;
    flex-wrap: wrap;
    gap: 8px 20px;
    font-size: 0.78rem;
    color: var(--text-2);
}

.legend li {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.legend-tight {
    gap: 6px 16px;
    font-size: 0.74rem;
}

.strip-panel .panel-header {
    align-items: flex-end;
    flex-wrap: wrap;
}

.strip-panel .legend-tight {
    justify-content: flex-end;
    padding-bottom: 2px;
}

.sw-line {
    width: 20px;
    height: 0;
    border-top: 2.5px solid var(--chart-cpu);
}

.sw-line[data-series="ram"] { border-color: var(--chart-ram); }
.sw-line[data-series="base"] { border-color: var(--chart-base); }
.sw-line[data-series="alert"] { border-color: var(--chart-alert); }
.sw-line[data-series="synthetic"] { border-color: var(--chart-synthetic); }

.sw-dash {
    border-top-style: dashed;
    border-top-width: 2px;
}

.sw-dot {
    display: inline-block;
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: var(--chart-flag);
    box-shadow: 0 0 0 2px var(--surface-solid);
}

.sw-inline {
    margin-right: 6px;
    vertical-align: 0;
}

.sw-band {
    width: 18px;
    height: 12px;
    border-radius: 3px;
    background: var(--chart-band);
    border: 1px solid rgba(239, 68, 68, 0.35);
}

.sw {
    width: 12px;
    height: 12px;
    border-radius: 3px;
}

/* ---------- Status strip ---------- */

.strip {
    display: flex;
    gap: 3px;
    height: 44px;
    padding: 4px;
    border-radius: var(--radius-sm);
    outline: none;
}

.strip:focus-visible {
    box-shadow: var(--ring);
}

.bar {
    flex: 1;
    min-width: 0;
    border-radius: 3px;
    cursor: crosshair;
    transition: transform 0.15s ease, filter 0.15s ease, opacity 0.15s ease;
}

.bar.skeleton {
    cursor: default;
}

.bar[data-state="healthy"],
.sw[data-state="healthy"] { background: var(--strip-healthy); }
.bar[data-state="degraded"],
.sw[data-state="degraded"] { background: var(--strip-degraded); }
.bar[data-state="incident"],
.sw[data-state="incident"] { background: var(--strip-incident); }
.bar[data-state="synthetic"],
.sw[data-state="synthetic"] {
    background: repeating-linear-gradient(135deg, var(--strip-synthetic) 0 3px, transparent 3px 6px);
    box-shadow: inset 0 0 0 1px var(--strip-synthetic);
}
.bar[data-state="nodata"],
.sw[data-state="nodata"] { background: var(--strip-nodata); }

.bar:hover,
.bar.is-selected {
    transform: scaleY(1.12);
    filter: brightness(1.15);
}

.bar.is-selected {
    box-shadow: 0 0 0 2px var(--heading);
}

.strip-axis {
    display: flex;
    justify-content: space-between;
    margin-top: 6px;
    padding: 0 4px;
    font-family: var(--font-mono);
    font-size: 0.7rem;
    color: var(--text-3);
}

.strip-detail {
    min-height: 2.8em;
    margin-top: 10px;
    padding: 9px 12px;
    border-radius: var(--radius-sm);
    background: var(--well);
    border: 1px solid var(--border);
    font-size: 0.8rem;
    color: var(--text-2);
}

/* ---------- Recent incidents and lists ---------- */

.recent {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.recent-item {
    display: grid;
    grid-template-columns: 34px minmax(0, 1fr) auto;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--surface-2);
    color: inherit;
    text-decoration: none;
    transition: border-color 0.2s ease, background-color 0.2s ease, transform 0.2s ease;
}

.recent-item:hover {
    border-color: var(--accent-line);
    background: var(--surface-3);
    transform: translateX(2px);
}

.recent-name {
    display: block;
    font-weight: 600;
    font-size: 0.88rem;
    color: var(--heading);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.recent-meta {
    display: block;
    font-size: 0.74rem;
    color: var(--text-3);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.kind-icon {
    display: grid;
    place-items: center;
    width: 34px;
    height: 34px;
    border-radius: 10px;
    background: var(--surface-3);
    color: var(--text-2);
    flex-shrink: 0;
}

.kind-icon .icon {
    width: 17px;
    height: 17px;
}

.kind-icon[data-kind="cpu_spike"] { color: var(--orange); background: var(--orange-soft); }
.kind-icon[data-kind="memory_leak"] { color: var(--bad-text); background: var(--bad-soft); }
.kind-icon[data-kind="db_corruption"] { color: var(--yellow); background: var(--yellow-soft); }

.empty-box {
    list-style: none;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    padding: 26px 16px;
    text-align: center;
    border-radius: var(--radius-sm);
    border: 1px dashed var(--border-strong);
    color: var(--text-2);
    font-size: 0.86rem;
}

.empty-box .icon {
    width: 26px;
    height: 26px;
    color: var(--accent-text);
}

.empty-box .btn-row {
    justify-content: center;
}

/* ---------- Markdown reports ---------- */

.md {
    font-size: 0.9rem;
    line-height: 1.7;
    color: var(--text-2);
    overflow-wrap: break-word;
}

.md > :first-child {
    margin-top: 0;
}

.md h1,
.md h2,
.md h3 {
    color: var(--heading);
    margin: 1.4em 0 0.55em;
}

.md h1 {
    font-size: 1.3rem;
    color: var(--accent-text);
}

.md h2 {
    font-size: 1.08rem;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--border);
}

.md h3 {
    font-size: 0.98rem;
}

.md p,
.md ul,
.md ol,
.md blockquote,
.md pre,
.md .table-wrap {
    margin-bottom: 0.9em;
}

.md ul,
.md ol {
    padding-left: 1.4em;
}

.md li {
    margin-bottom: 0.3em;
}

.md strong {
    color: var(--heading);
}

.md blockquote {
    padding: 10px 14px;
    border-left: 3px solid var(--accent);
    background: var(--accent-soft);
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

.md blockquote p {
    margin: 0;
}

.md pre {
    padding: 14px;
    border-radius: var(--radius-sm);
    background: var(--well);
    border: 1px solid var(--border);
    overflow-x: auto;
    font-family: var(--font-mono);
    font-size: 0.8rem;
}

.md pre code {
    border: 0;
    background: none;
    padding: 0;
}

.md code {
    color: var(--accent-text);
}

.md table {
    border-collapse: collapse;
    font-size: 0.78rem;
    width: 100%;
}

.md th,
.md td {
    padding: 6px 10px;
    border-bottom: 1px solid var(--border);
    text-align: left;
    white-space: nowrap;
}

.md th {
    color: var(--text-3);
    font-weight: 700;
}

.md td {
    font-family: var(--font-mono);
}

.md.raw {
    white-space: pre-wrap;
    font-family: var(--font-mono);
    font-size: 0.8rem;
}

/* The latest report is a preview: it fills whatever height the row gives it (set by the
   recent-incidents list beside it), fades out, and links to the full report. */
.latest-panel {
    display: flex;
    flex-direction: column;
}

.latest-panel .panel-header {
    margin-bottom: 12px;
}

.md-frame {
    position: relative;
    flex: 1;
    min-height: 300px;
}

.md-preview {
    position: absolute;
    inset: 0;
    overflow: hidden;
    padding: 4px 4px 0;
    mask-image: linear-gradient(180deg, #000 72%, transparent);
    -webkit-mask-image: linear-gradient(180deg, #000 72%, transparent);
}

.latest-more {
    align-self: flex-start;
    margin-top: 12px;
}

/* ---------- Watchdog card and terminal ---------- */

.watchdog {
    display: grid;
    grid-template-columns: minmax(0, 5fr) minmax(0, 8fr);
    gap: 24px;
    align-items: stretch;
}

.watchdog-side {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.watchdog .terminal {
    display: flex;
    flex-direction: column;
}

.watchdog .log {
    flex: 1;
    height: auto;
    min-height: 220px;
    max-height: 300px;
}

.agent-box {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px;
    border-radius: var(--radius);
    background: var(--surface-2);
    border: 1px solid var(--border);
}

.agent-avatar {
    display: grid;
    place-items: center;
    width: 44px;
    height: 44px;
    border-radius: 12px;
    background: radial-gradient(circle, var(--accent-soft) 0%, transparent 75%), var(--surface-3);
    color: var(--accent-text);
    flex-shrink: 0;
}

.agent-box[data-tone="bad"] .agent-avatar { color: var(--bad-text); background: var(--bad-soft); }
.agent-box[data-tone="warn"] .agent-avatar { color: var(--warn-text); background: var(--warn-soft); }

.agent-avatar .icon {
    width: 22px;
    height: 22px;
}

.agent-state {
    font-family: var(--font-display);
    font-weight: 600;
    color: var(--heading);
}

.agent-sub {
    font-size: 0.78rem;
    color: var(--text-2);
    line-height: 1.45;
}

.facts {
    display: grid;
    gap: 0;
}

.facts > div {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
    font-size: 0.82rem;
}

.facts > div:last-child {
    border-bottom: 0;
}

.facts dt {
    color: var(--text-3);
    font-weight: 600;
    white-space: nowrap;
}

.facts dd {
    color: var(--text);
    font-family: var(--font-mono);
    font-size: 0.78rem;
    text-align: right;
}

.facts-compact > div {
    padding: 6px 0;
}

.terminal {
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: var(--well);
    overflow: hidden;
}

[data-theme="light"] .terminal {
    background: #0d1426;
    border-color: #0d1426;
    --text: #e2e8f0;
    --text-2: #b6c2d3;
    --text-3: #8b98ad;
}

.terminal-head {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    font-family: var(--font-mono);
    font-size: 0.74rem;
    color: var(--text-3);
}

.terminal-head .icon {
    width: 14px;
    height: 14px;
    color: var(--accent);
}

.terminal-meta {
    margin-left: auto;
}

.log {
    list-style: none;
    height: 260px;
    overflow-y: auto;
    padding: 10px 12px;
    display: flex;
    flex-direction: column;
    gap: 7px;
    font-family: var(--font-mono);
    font-size: 0.74rem;
    line-height: 1.5;
}

.log-short {
    height: 190px;
}

.log li {
    display: grid;
    grid-template-columns: auto auto minmax(0, 1fr);
    gap: 8px;
    color: var(--text-2);
    animation: rise 0.25s var(--ease);
}

.log time {
    color: var(--text-3);
}

.lvl {
    font-weight: 500;
    min-width: 3.4em;
}

.lvl[data-level="info"] { color: var(--info-text); }
.lvl[data-level="warn"] { color: var(--warn-text); }
.lvl[data-level="error"] { color: var(--bad-text); }
.lvl[data-level="success"] { color: var(--ok-text); }

[data-theme="light"] .terminal .lvl[data-level="info"] { color: #7dd3fc; }
[data-theme="light"] .terminal .lvl[data-level="warn"] { color: #fbbf24; }
[data-theme="light"] .terminal .lvl[data-level="error"] { color: #f87171; }
[data-theme="light"] .terminal .lvl[data-level="success"] { color: #34d399; }

.msg {
    overflow-wrap: anywhere;
}

.log .log-empty {
    display: block;
}

/* ---------- Incidents view ---------- */

.toolbar {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.incidents-side {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.incident-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 2px;
    max-height: 560px;
    overflow-y: auto;
    padding: 2px;
}

.incident-row {
    display: grid;
    grid-template-columns: 34px minmax(0, 1fr) auto;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 12px;
    border-radius: 12px;
    border: 1px solid transparent;
    background: none;
    text-align: left;
    cursor: pointer;
    transition: background-color 0.18s ease, border-color 0.18s ease;
}

.incident-row:hover {
    background: var(--surface-3);
}

.incident-row[aria-current="true"] {
    background: var(--accent-soft);
    border-color: var(--accent-line);
}

.log:focus-visible,
.table-wrap:focus-visible,
.incident-row:focus-visible {
    outline: none;
    box-shadow: var(--ring);
}

.row-main {
    min-width: 0;
}

.row-title {
    display: block;
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--heading);
}

.row-title .incident-id {
    font-family: var(--font-mono);
    font-weight: 400;
    color: var(--text-3);
    font-size: 0.8rem;
}

.row-meta {
    display: block;
    font-size: 0.75rem;
    color: var(--text-3);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.report-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 2px;
    max-height: 320px;
    overflow-y: auto;
}

.report-list button {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 10px;
    align-items: center;
    width: 100%;
    min-height: 40px;
    padding: 8px 10px;
    border: 1px solid transparent;
    border-radius: 9px;
    background: none;
    text-align: left;
    cursor: pointer;
    font-size: 0.82rem;
    color: var(--text);
}

.report-list button:hover {
    background: var(--surface-3);
}

.report-list button[aria-current="true"] {
    background: var(--accent-soft);
    border-color: var(--accent-line);
}

.report-list .rl-title {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.report-list time {
    font-family: var(--font-mono);
    font-size: 0.72rem;
    color: var(--text-3);
}

.incident-detail {
    position: sticky;
    top: 24px;
    align-self: start;
    max-height: calc(100vh - 48px);
    overflow-y: auto;
}

.detail-head {
    display: flex;
    align-items: center;
    gap: 14px;
}

.detail-head .kind-icon {
    width: 44px;
    height: 44px;
    border-radius: 12px;
}

.detail-title-wrap {
    flex: 1;
    min-width: 0;
}

.detail-title-wrap h2 {
    font-size: 1.25rem;
}

.measures {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 10px;
    margin-top: 18px;
}

.measures > div {
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    background: var(--surface-2);
    border: 1px solid var(--border);
    min-width: 0;
}

.measures dt {
    font-size: 0.66rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-3);
}

.measures dd {
    margin-top: 2px;
    font-family: var(--font-mono);
    font-size: 0.86rem;
    color: var(--heading);
    white-space: nowrap;
}

.measures .is-measure {
    border-color: var(--accent-line);
    background: var(--accent-soft);
}

.measures .is-measure dd {
    font-family: var(--font-display);
    font-size: 1.15rem;
    font-weight: 600;
}

/* Lifecycle bar: start -> detected -> resolved, drawn to scale. */
.lifecycle {
    margin-top: 16px;
}

.lc-track {
    position: relative;
    display: flex;
    height: 10px;
    border-radius: 5px;
    overflow: hidden;
    background: var(--surface-3);
}

.lc-seg {
    height: 100%;
    min-width: 4px;
    transition: flex-grow 0.4s var(--ease);
}

.lc-seg[data-part="detect"] { background: var(--warn); }
.lc-seg[data-part="open"] { background: var(--bad); }
.lc-seg[data-part="open"][data-live] {
    background: repeating-linear-gradient(135deg, var(--bad) 0 6px, rgba(239, 68, 68, 0.55) 6px 12px);
    background-size: 17px 100%;
    animation: stripes 1s linear infinite;
}

@keyframes stripes {
    to { background-position: 17px 0; }
}

.lc-labels {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    margin-top: 6px;
    font-size: 0.72rem;
    color: var(--text-3);
}

.lc-labels b {
    color: var(--text-2);
    font-weight: 600;
}

.timeline {
    list-style: none;
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding-left: 4px;
}

.timeline li {
    position: relative;
    display: grid;
    grid-template-columns: 74px 84px minmax(0, 1fr);
    gap: 10px;
    padding: 6px 0 6px 20px;
    font-size: 0.82rem;
}

.timeline li::before {
    content: '';
    position: absolute;
    left: 3px;
    top: 0;
    bottom: 0;
    width: 2px;
    background: var(--border-strong);
}

.timeline li:first-child::before { top: 14px; }
.timeline li:last-child::before { bottom: calc(100% - 14px); }

.timeline li::after {
    content: '';
    position: absolute;
    left: -1px;
    top: 10px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--tl, var(--text-3));
    box-shadow: 0 0 0 3px var(--surface-solid);
}

.timeline li[data-type="fault"] { --tl: var(--orange); }
.timeline li[data-type="flagged"] { --tl: var(--warn); }
.timeline li[data-type="detected"] { --tl: var(--bad); }
.timeline li[data-type="report"] { --tl: var(--info); }
.timeline li[data-type="action"] { --tl: var(--purple); }
.timeline li[data-type="resolved"] { --tl: var(--ok); }
.timeline li[data-type="interrupted"] { --tl: var(--text-3); }
.timeline li[data-type="pending"] { --tl: var(--warn); }
.timeline li[data-type="firing"] { --tl: var(--bad); }

.timeline time {
    font-family: var(--font-mono);
    font-size: 0.76rem;
    color: var(--text-3);
    padding-top: 1px;
}

.tl-type {
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--tl, var(--text-3));
    padding-top: 2px;
}

[data-theme="light"] .timeline li[data-type="flagged"] .tl-type,
[data-theme="light"] .timeline li[data-type="pending"] .tl-type { color: var(--warn-text); }
[data-theme="light"] .timeline li[data-type="resolved"] .tl-type { color: var(--ok-text); }
[data-theme="light"] .timeline li[data-type="report"] .tl-type { color: var(--info-text); }

.tl-text {
    color: var(--text);
    overflow-wrap: anywhere;
}

.report-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 14px;
    flex-wrap: wrap;
    margin: 22px 0 6px;
    padding-top: 20px;
    border-top: 1px solid var(--border);
}

#detail-incident[hidden] + .report-head {
    margin-top: 0;
    padding-top: 0;
    border-top: 0;
}

.report-title {
    font-size: 1.05rem;
}

.incident-detail .md {
    margin-top: 14px;
}

/* ---------- Tables ---------- */

.table-wrap {
    width: 100%;
    overflow-x: auto;
    border-radius: var(--radius-sm);
}

.table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 0.86rem;
}

.table th,
.table td {
    padding: 11px 14px;
    text-align: left;
    white-space: nowrap;
    border-bottom: 1px solid var(--border);
}

.table thead th {
    position: sticky;
    top: 0;
    z-index: 1;
    background: var(--surface-solid);
    color: var(--text-3);
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.table tbody tr {
    transition: background-color 0.15s ease;
}

.table tbody tr:hover {
    background: var(--surface-2);
}

.table .num {
    text-align: right;
    font-family: var(--font-mono);
    font-variant-numeric: tabular-nums;
}

.table .mono {
    font-family: var(--font-mono);
    font-size: 0.78rem;
    color: var(--text-2);
}

.table .time {
    font-family: var(--font-mono);
    font-size: 0.8rem;
}

.table td.table-empty,
.table td.error-text {
    text-align: center;
    white-space: normal;
    padding: 22px 14px;
}

.table tr.is-new td {
    animation: flash 1.4s ease;
}

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

.cell-sub {
    display: block;
    font-family: var(--font-sans);
    font-size: 0.72rem;
    color: var(--text-3);
}

abbr[title] {
    text-decoration: none;
    cursor: help;
}

.cell-ago {
    font-family: var(--font-sans);
    font-size: 0.74rem;
    color: var(--text-3);
    margin-left: 6px;
}

.cell-sub.mono {
    font-family: var(--font-mono);
    font-size: 0.7rem;
}

.delta-up { color: var(--bad-text); }
.delta-flat { color: var(--text-3); }

/* ---------- Chaos Lab ---------- */

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

.chaos-card {
    --tone: var(--orange);
    --tone-soft: var(--orange-soft);
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 20px;
    border-radius: 18px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    overflow: hidden;
    transition: border-color 0.3s var(--ease), box-shadow 0.3s var(--ease), transform 0.3s var(--ease);
}

.chaos-card[data-tone="red"] { --tone: var(--bad-text); --tone-soft: var(--bad-soft); }
.chaos-card[data-tone="yellow"] { --tone: var(--yellow); --tone-soft: var(--yellow-soft); }
.chaos-card[data-tone="purple"] { --tone: var(--violet); --tone-soft: var(--violet-soft); }

.chaos-card:hover {
    border-color: color-mix(in srgb, var(--tone) 45%, transparent);
    box-shadow: 0 16px 34px color-mix(in srgb, var(--tone) 14%, transparent);
}

.chaos-card.is-disabled {
    opacity: 0.88;
}

.chaos-card.is-disabled:hover {
    border-color: var(--border);
    box-shadow: none;
}

.chaos-icon {
    display: grid;
    place-items: center;
    width: 42px;
    height: 42px;
    border-radius: 12px;
    background: var(--tone-soft);
    color: var(--tone);
}

.chaos-icon .icon {
    width: 22px;
    height: 22px;
}

.chaos-card h3 {
    font-size: 1.08rem;
}

.chaos-card p {
    font-size: 0.82rem;
    color: var(--text-2);
    line-height: 1.5;
}

/* What the visitor should watch for after injecting the fault. */
.chaos-card .chaos-expect {
    display: flex;
    gap: 8px;
    padding: 9px 11px;
    border-radius: var(--radius-sm);
    background: var(--well);
    border: 1px solid var(--border);
    font-size: 0.76rem;
    line-height: 1.5;
}

.chaos-expect .icon {
    flex-shrink: 0;
    width: 14px;
    height: 14px;
    margin-top: 2px;
    color: var(--tone);
}

/* Caps and buttons sit together at the bottom of every card, so the cards line up. */
.caps {
    list-style: none;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: auto;
}

.caps li {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 8px;
    border-radius: 6px;
    background: var(--well);
    border: 1px solid var(--border);
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--text-2);
}

.caps .icon {
    width: 12px;
    height: 12px;
    color: var(--ok-text);
}

.chaos-foot {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    padding-top: 6px;
}

/* Snapshots: the explainer sits at the bottom, under however many snapshots there are. */
.snap-panel {
    display: flex;
    flex-direction: column;
}

.snap-how {
    list-style: none;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 16px;
    margin-top: auto;
    padding-top: 18px;
    border-top: 1px solid var(--border);
}

.snap-panel .table-wrap {
    margin-bottom: 20px;
}

.snap-how li {
    display: flex;
    gap: 10px;
    font-size: 0.78rem;
    line-height: 1.5;
    color: var(--text-2);
}

.snap-how b {
    color: var(--heading);
    font-weight: 600;
}

.snap-how .icon {
    flex-shrink: 0;
    width: 16px;
    height: 16px;
    margin-top: 2px;
    color: var(--accent-text);
}

/* The fault cards share the height of the Live results panel beside them. */
.faults-panel {
    display: flex;
    flex-direction: column;
}

.faults-panel .chaos-grid {
    flex: 1;
    grid-auto-rows: 1fr;
}

.btn-chaos {
    --btn-bg: var(--tone-soft);
    color: var(--tone);
    border-color: color-mix(in srgb, var(--tone) 45%, transparent);
    min-height: 40px;
}

.btn-chaos:hover {
    --btn-bg: color-mix(in srgb, var(--tone) 22%, transparent);
    box-shadow: 0 8px 20px color-mix(in srgb, var(--tone) 22%, transparent);
}

.chaos-state {
    font-size: 0.74rem;
    color: var(--text-3);
    font-weight: 600;
}

.cooldown {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 3px;
    background: transparent;
}

.cooldown-fill {
    height: 100%;
    width: 0;
    background: var(--tone);
    opacity: 0.8;
    transition: width 1s linear;
}

.leak {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.leak-meter {
    height: 8px;
    border-radius: 4px;
    background: var(--surface-3);
    overflow: hidden;
}

.leak-fill {
    height: 100%;
    width: 0;
    border-radius: 4px;
    background: linear-gradient(90deg, var(--warn), var(--bad));
    transition: width 0.5s var(--ease);
}

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

.results .panel-header {
    margin-bottom: 14px;
}

.mini-charts {
    display: grid;
    gap: 12px;
    margin-bottom: 16px;
}

.db-alert {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    padding: 12px 14px;
    margin-bottom: 14px;
    border-radius: var(--radius-sm);
    border: 1px solid rgba(239, 68, 68, 0.38);
    background: var(--bad-soft);
    color: var(--bad-text);
    font-size: 0.84rem;
}

.db-alert > span {
    flex: 1;
    min-width: 12em;
}

.db-alert code {
    color: inherit;
}

.db-alert-lg {
    margin: 0;
    padding: 16px 18px;
    font-size: 0.9rem;
}

.report-teaser {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-top: 16px;
    padding-top: 14px;
    border-top: 1px solid var(--border);
}

.report-teaser p {
    font-size: 0.86rem;
    color: var(--heading);
    font-weight: 600;
}

/* ---------- Time Machine ---------- */

.snap-track {
    position: relative;
    height: 58px;
    margin: 4px 6px 18px;
}

.snap-axis {
    position: absolute;
    left: 0;
    right: 0;
    top: 22px;
    height: 2px;
    border-radius: 2px;
    background: var(--border-strong);
}

.snap-dot {
    position: absolute;
    top: 16px;
    width: 14px;
    height: 14px;
    margin-left: -7px;
    border-radius: 50%;
    background: var(--accent);
    border: 2px solid var(--surface-solid);
    box-shadow: 0 0 0 1px var(--accent-line);
}

.snap-dot[data-bad] {
    background: var(--bad);
}

.snap-dot[data-newest] {
    width: 18px;
    height: 18px;
    top: 14px;
    margin-left: -9px;
    box-shadow: 0 0 0 4px var(--accent-soft), 0 0 14px var(--accent-glow);
}

.snap-now {
    position: absolute;
    top: 10px;
    right: -2px;
    width: 2px;
    height: 26px;
    background: var(--text-3);
}

.snap-label {
    position: absolute;
    top: 40px;
    font-family: var(--font-mono);
    font-size: 0.68rem;
    color: var(--text-3);
    white-space: nowrap;
}

.snap-label-start { left: 0; }
.snap-label-end { right: 0; }

.tx-form label {
    display: block;
    font-size: 0.78rem;
    font-weight: 700;
    color: var(--text-2);
    margin-bottom: 6px;
}

.input-row {
    display: flex;
    gap: 8px;
}

.input-row .btn {
    min-height: 42px;
}

.tag-bad {
    font-family: var(--font-sans);
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--bad-text);
}

/* ---------- About ---------- */

.prose h2 {
    font-size: 1.15rem;
    margin: 26px 0 10px;
}

.prose h2:first-child {
    margin-top: 0;
}

.prose p,
.prose li {
    color: var(--text-2);
    font-size: 0.9rem;
}

.arch {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.arch-lane {
    padding: 14px;
    border-radius: var(--radius);
    background: var(--surface-2);
    border: 1px solid var(--border);
}

.prose .arch-label {
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--accent-text);
    margin-bottom: 10px;
}

.arch-flow {
    list-style: none;
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 22px;
}

.arch-flow-2 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.prose .arch-flow li {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    background: var(--well);
    border: 1px solid var(--border);
    font-size: 0.78rem;
}

.arch-flow li:not(:last-child)::after {
    content: '';
    position: absolute;
    right: -17px;
    top: 50%;
    width: 12px;
    height: 12px;
    transform: translateY(-50%);
    background: var(--accent-text);
    mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12h14M12 5l7 7-7 7'/%3E%3C/svg%3E") center / contain no-repeat;
    -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12h14M12 5l7 7-7 7'/%3E%3C/svg%3E") center / contain no-repeat;
}

.arch-flow b {
    color: var(--heading);
    font-weight: 600;
}

.decisions,
.limits {
    padding-left: 1.2em;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.decisions b {
    color: var(--heading);
}

.about-side {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.about-side h2 {
    margin-bottom: 12px;
}

.limits li {
    font-size: 0.84rem;
    color: var(--text-2);
}

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

.stack > div {
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
}

.stack > div:last-child {
    border-bottom: 0;
}

.stack dt {
    font-weight: 700;
    font-size: 0.86rem;
    color: var(--heading);
}

.stack dd {
    font-size: 0.8rem;
    color: var(--text-2);
}

/* ---------- Settings ---------- */

.narrow {
    max-width: 620px;
}

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

.stack-form label {
    font-weight: 700;
    font-size: 0.86rem;
    color: var(--heading);
}

.stack-form .note {
    margin-top: 0;
}

.feedback {
    min-height: 1.4em;
    font-size: 0.84rem;
    color: var(--text-2);
}

.feedback[data-tone="ok"] { color: var(--ok-text); }
.feedback[data-tone="bad"] { color: var(--bad-text); }

/* ---------- Footer, banner, dialog, toasts ---------- */

.page-footer {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 12px;
    padding-top: 18px;
    border-top: 1px solid var(--border);
    font-size: 0.78rem;
    color: var(--text-3);
}

.page-footer a {
    color: var(--text-2);
    font-weight: 600;
    text-decoration: none;
}

.page-footer a:hover {
    color: var(--heading);
}

/* On a phone the footer links wrap onto several lines, so the dot separators would sit alone. */
@media (max-width: 640px) {
    .page-footer {
        gap: 4px 20px;
    }

    .page-footer > [aria-hidden="true"] {
        display: none;
    }

    /* Make room in the top bar for the status text ("Incident: memory leak"). */
    .badge-sre {
        display: none;
    }
}

/* Let the snapshot time and its "x ago" note wrap, so the Restore button is never pushed out
   of view behind a horizontal scrollbar. */
.table td.time {
    white-space: normal;
}

/* A bar at the top of the main column: it pushes the page down rather than covering it, and
   stays in view while scrolling. */
.conn-banner {
    position: sticky;
    top: 12px;
    z-index: 60;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-radius: var(--radius);
    border: 1px solid rgba(239, 68, 68, 0.45);
    background: color-mix(in srgb, var(--surface-solid) 90%, #ef4444);
    box-shadow: var(--shadow);
    font-size: 0.86rem;
    color: var(--text);
    animation: drop 0.25s var(--ease);
}

.conn-banner[hidden] {
    display: none;
}

.conn-banner strong {
    color: var(--bad-text);
}

.conn-attempt {
    margin-left: 6px;
    color: var(--text-3);
    font-variant-numeric: tabular-nums;
}

@keyframes drop {
    from { opacity: 0; transform: translateY(-8px); }
    to { opacity: 1; transform: none; }
}

/* Offline: the data on screen is frozen, so it stops looking live. */
[data-offline] .live-tag {
    border-color: var(--border-strong);
    background: var(--surface-3);
    color: var(--text-3);
}

[data-offline] .live-dot {
    background: var(--text-3);
    box-shadow: none;
    animation: none;
}

[data-offline] .live-text {
    display: none;
}

[data-offline] .live-tag::after {
    content: 'paused';
}

[data-offline] .chart-box,
[data-offline] .pipeline,
[data-offline] .spark {
    opacity: 0.55;
    transition: opacity 0.3s ease;
}

[data-offline] .pipe-step .pipe-node {
    animation: none;
}

.spinner {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    border-radius: 50%;
    border: 2px solid var(--bad-text);
    border-right-color: transparent;
    animation: spin 0.8s linear infinite;
}

.modal {
    margin: auto;
    width: min(460px, calc(100% - 32px));
    padding: 24px;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-strong);
    background: var(--surface-solid);
    color: var(--text);
    box-shadow: 0 30px 80px rgba(0, 0, 0, 0.5);
}

.modal[open] {
    animation: pop 0.2s var(--ease);
}

@keyframes pop {
    from { opacity: 0; transform: translateY(8px) scale(0.98); }
    to { opacity: 1; transform: none; }
}

.modal::backdrop {
    background: rgba(2, 4, 10, 0.68);
    backdrop-filter: blur(4px);
}

[data-theme="light"] .modal::backdrop {
    background: rgba(15, 23, 42, 0.35);
}

.modal-icon {
    display: grid;
    place-items: center;
    width: 42px;
    height: 42px;
    border-radius: 12px;
    background: var(--accent-soft);
    color: var(--accent-text);
    margin-bottom: 14px;
}

.modal[data-danger] .modal-icon {
    background: var(--bad-soft);
    color: var(--bad-text);
}

.modal h2 {
    font-size: 1.2rem;
}

.modal p {
    margin-top: 8px;
    font-size: 0.9rem;
    color: var(--text-2);
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 22px;
}

.toast-stack {
    position: fixed;
    right: 20px;
    bottom: 20px;
    z-index: 110;
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: min(400px, calc(100% - 32px));
}

.toast {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: start;
    gap: 10px;
    padding: 12px 12px 12px 14px;
    border-radius: var(--radius);
    border: 1px solid var(--border-strong);
    border-left: 3px solid var(--tone, var(--info));
    background: var(--surface-solid);
    box-shadow: var(--shadow);
    font-size: 0.86rem;
    color: var(--text);
    animation: toast-in 0.25s var(--ease);
}

.toast[data-type="success"] { --tone: var(--ok); }
.toast[data-type="warn"] { --tone: var(--warn); }
.toast[data-type="error"] { --tone: var(--bad); }

.toast > .icon {
    width: 17px;
    height: 17px;
    margin-top: 1px;
    color: var(--tone, var(--info));
}

.toast.leaving {
    opacity: 0;
    transform: translateX(12px);
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.toast-close {
    display: grid;
    place-items: center;
    width: 28px;
    height: 28px;
    margin: -4px -4px 0 0;
    border: 0;
    border-radius: 7px;
    background: none;
    color: var(--text-3);
    cursor: pointer;
}

.toast-close:hover {
    background: var(--surface-3);
    color: var(--heading);
}

.toast-close .icon {
    width: 15px;
    height: 15px;
}

@keyframes toast-in {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: none; }
}

/* ---------- Responsive ---------- */

@media (max-width: 1360px) {
    .kpis {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .banner-facts {
        gap: 16px;
    }

    .measures {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

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

    .main {
        padding: 26px 28px 40px;
    }

    .header {
        flex-direction: column;
        align-items: stretch;
    }

    .stat-card {
        flex: 1;
        width: auto;
    }

    .col-4, .col-5, .col-6, .col-7, .col-8 {
        grid-column: 1 / -1;
    }

    .banner-facts {
        display: none;
    }

    .incident-detail {
        position: static;
        max-height: none;
    }

    .watchdog {
        grid-template-columns: minmax(0, 1fr);
    }
}

/* Tablets and phones: the sidebar becomes a sticky top bar with scrolling tabs. */
@media (max-width: 900px) {
    html {
        scroll-padding-top: 120px;
    }

    .app {
        display: block;
    }

    .sidebar {
        position: sticky;
        top: 0;
        height: auto;
        display: grid;
        grid-template-columns: minmax(0, 1fr);
        gap: 10px;
        padding: 10px 16px 8px;
        border-right: 0;
        border-bottom: 1px solid var(--border);
    }

    .sidebar-top {
        padding: 0;
        border-bottom: 0;
    }

    .brand-text {
        font-size: 1.15rem;
    }

    .sidebar-top .status-box-top {
        display: flex;
        padding: 6px 12px;
        max-width: 58vw;
    }

    .status-box-top .status-text {
        font-size: 0.74rem;
    }

    .nav {
        flex-direction: row;
        gap: 4px;
        overflow-x: auto;
        scrollbar-width: none;
        margin: 0 -16px;
        padding: 0 16px 2px;
        scroll-padding: 0 16px;
    }

    .nav::-webkit-scrollbar {
        display: none;
    }

    /* Overflow hint: fade the right edge while more items are off screen (set by initNavHint). */
    .nav[data-more] {
        -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 40px), transparent);
        mask-image: linear-gradient(to right, #000 calc(100% - 40px), transparent);
    }

    .nav-item {
        flex-shrink: 0;
        min-height: 40px;
        padding: 8px 12px;
        gap: 8px;
        font-size: 0.82rem;
        border-radius: 10px;
        white-space: nowrap;
    }

    .nav-item:hover {
        transform: none;
    }

    .nav-item .icon {
        width: 16px;
        height: 16px;
    }

    /* The footer's status box, notes and links are redundant here; keep only the theme
       toggle, as an icon button at the right end of the top bar. */
    .sidebar-footer {
        display: block;
        position: absolute;
        top: 10px;
        right: 12px;
        padding: 0;
        border-top: 0;
    }

    .sidebar-footer .status-box,
    .sidebar-footer .env-note,
    .sidebar-footer .sidebar-links a {
        display: none;
    }

    /* Keep the label for screen readers. */
    .theme-toggle span {
        position: absolute;
        width: 1px;
        height: 1px;
        overflow: hidden;
        clip: rect(0 0 0 0);
        white-space: nowrap;
    }

    .theme-toggle {
        justify-content: center;
        min-width: 40px;
        min-height: 40px;
        border: 1px solid var(--border);
        border-radius: 999px;
    }

    .sidebar-top {
        padding-right: 48px;
    }

    .main {
        padding: 18px 16px 32px;
        gap: 18px;
    }

    /* The top bar is sticky here and already says "Offline", so the banner scrolls away. */
    .conn-banner {
        position: relative;
        top: auto;
    }

    /* Comfortable tap targets for text links. */
    .brand,
    .text-link,
    .page-footer a {
        min-height: 40px;
        display: inline-flex;
        align-items: center;
    }

    .view,
    .grid {
        gap: 18px;
    }

    .kpis {
        gap: 12px;
    }

    .header {
        padding-bottom: 18px;
        gap: 14px;
    }

    .header-title h1 {
        font-size: 1.55rem;
    }

    .demo-chip {
        position: static;
        transform: none;
        max-width: 100%;
        white-space: normal;
    }

    .pipeline {
        grid-template-columns: minmax(0, 1fr);
        gap: 0;
    }

    .pipeline:not(.pipeline-compact) .pipe-step {
        flex-direction: row;
        gap: 14px;
        padding-bottom: 14px;
    }

    .pipeline:not(.pipeline-compact) .pipe-step:not(:last-child)::after {
        top: 44px;
        bottom: 2px;
        left: 19px;
        right: auto;
        width: 2px;
        height: auto;
        background: linear-gradient(180deg, var(--line, var(--border-strong)) var(--fill, 0%), var(--border) var(--fill, 0%));
    }

    .pipe-detail {
        min-height: 0;
    }

    .pipeline-compact {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }

    .charts-2 {
        grid-template-columns: minmax(0, 1fr);
    }

    .arch-flow {
        grid-template-columns: minmax(0, 1fr);
        gap: 18px;
    }

    .arch-flow li:not(:last-child)::after {
        right: auto;
        left: 50%;
        top: auto;
        bottom: -16px;
        transform: translateX(-50%) rotate(90deg);
    }
}

@media (max-width: 640px) {
    body {
        font-size: 14.5px;
    }

    .panel {
        padding: 18px 16px;
        border-radius: 16px;
    }

    .panel-flush {
        padding: 6px;
    }

    .panel-header {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }

    .panel-header .text-link,
    .panel-header > .badge {
        align-self: flex-start;
    }

    .stat-cards {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 10px;
    }

    .stat-card {
        padding: 10px 12px;
    }

    .stat-value {
        font-size: 1.28rem;
    }

    .spark {
        width: 56px;
    }

    .status-banner {
        align-items: flex-start;
        padding: 14px;
        gap: 12px;
    }

    .banner-icon {
        width: 32px;
        height: 32px;
    }

    .hero-lead {
        font-size: 1.28rem;
    }

    .hero-actions .btn {
        flex: 1 1 100%;
    }

    /* Phones: lift the main action above the long intro text, so it is on the first screen. */
    .hero {
        display: flex;
        flex-direction: column;
    }

    .hero-lead {
        order: -2;
    }

    .hero-actions {
        order: -1;
    }

    .kpi {
        padding: 14px;
        grid-template-areas:
            "label label"
            "value value"
            "note note"
            "bars bars";
    }

    .kpi-value {
        font-size: 1.5rem;
    }

    .kpi-bars {
        margin-top: 10px;
        width: 100%;
        height: 30px;
    }

    .kpi-meter {
        margin: 12px 0 2px;
        width: 100%;
    }

    .kpi-label {
        font-size: 0.62rem;
        letter-spacing: 0.05em;
    }

    .chart-box {
        height: 190px;
    }

    .chart-tall {
        height: 210px;
    }

    .chart-square {
        height: 260px;
    }

    .legend {
        gap: 6px 14px;
        font-size: 0.74rem;
    }

    .strip {
        gap: 2px;
        height: 38px;
        padding: 3px;
    }

    .chaos-grid,
    .snap-how {
        grid-template-columns: minmax(0, 1fr);
    }

    .measures {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .timeline li {
        grid-template-columns: 64px minmax(0, 1fr);
    }

    .timeline .tl-type {
        grid-column: 2;
        grid-row: 1;
    }

    .timeline .tl-text {
        grid-column: 1 / -1;
    }

    .table th,
    .table td {
        padding: 10px 10px;
    }

    .hide-sm {
        display: none;
    }

    .cell-ago {
        display: block;
        margin-left: 0;
        white-space: normal;
    }

    /* The snapshot's time cell wraps, so the Restore button stays in view. */
    .snap-panel .table td.time {
        white-space: normal;
    }

    .recent-meta,
    .row-meta {
        white-space: normal;
    }

    /* Wrap long names onto a second line so the incident id stays visible. */
    .recent-name {
        white-space: normal;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
    }

    .view-intro {
        align-items: stretch;
    }

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

    .seg button {
        padding: 0 10px;
        min-height: 40px;
    }

    .log {
        height: 220px;
    }

    .toast-stack {
        right: 16px;
        left: 16px;
        bottom: 16px;
        width: auto;
    }

    .modal-actions .btn {
        flex: 1;
    }

    .btn-small {
        min-height: 40px;
    }
}

/* ---------- Alerts ---------- */

.alert-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.alert-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 4px 16px;
    padding: 14px;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: var(--surface-2);
    border-left: 3px solid var(--text-3);
}

.alert-row[data-state="pending"] { border-left-color: var(--warn); }
.alert-row[data-state="firing"] { border-left-color: var(--bad); background: var(--bad-soft); }
.alert-row[data-state="resolved"] { border-left-color: var(--ok); }
.alert-row[data-state="ok"] { border-left-color: var(--border-strong); }

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

.alert-cond {
    font-family: var(--font-mono);
    font-size: 0.78rem;
    color: var(--text-2);
    overflow-wrap: anywhere;
}

#notify-note {
    margin-top: 16px;
}

.alert-desc {
    grid-column: 1 / -1;
    font-size: 0.78rem;
    color: var(--text-3);
}

.alert-state {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 4px;
    font-size: 0.74rem;
    color: var(--text-3);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

#alert-history .timeline {
    max-height: 440px;
    overflow-y: auto;
    padding-right: 10px;
}

#alert-history .timeline li {
    grid-template-columns: 64px minmax(0, 1fr);
    row-gap: 0;
}

#alert-history .tl-type {
    grid-column: 2;
    grid-row: 1;
}

#alert-history .tl-text {
    grid-column: 2;
    grid-row: 2;
    overflow-wrap: anywhere;
}

#alert-history time {
    grid-row: 1 / span 2;
}

/* ---------- Likely cause and merged timeline ---------- */

.cause {
    margin-top: 22px;
    padding: 16px 18px;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: var(--surface-2);
    min-height: 120px;
}

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

.cause-head .sub-title {
    margin: 0 4px 0 0;
}

.cause-summary {
    margin-top: 12px;
    font-weight: 600;
    color: var(--heading);
}

.cause-note {
    margin-top: 6px;
    font-size: 0.82rem;
    color: var(--text-2);
}

.cause-disclaimer {
    color: var(--text-3);
    font-size: 0.76rem;
}

.cause-label {
    margin-top: 14px;
    font-size: 0.72rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-3);
}

.cause-list {
    margin-top: 6px;
    padding-left: 1.2em;
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 0.84rem;
    color: var(--text-2);
}

.sub-title .panel-meta {
    display: block;
    margin-top: 2px;
    text-transform: none;
    letter-spacing: 0;
    font-weight: 400;
}

.timeline time small {
    display: block;
    font-size: 0.68rem;
    color: var(--text-3);
    opacity: 0.85;
}

.timeline li[data-type="alert"] { --tl: var(--yellow); }
.timeline li[data-type="restore"] { --tl: var(--purple); }

[data-theme="light"] .timeline li[data-type="alert"] .tl-type { color: var(--warn-text); }

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