/* =====================================================================
   Cookies Inc Dashboard · flat dark + restrained color for scanability
   (no gradients; colors are matte / flat only)
   ===================================================================== */

/* ---------- tokens ---------- */
:root {
    /* surfaces — flat charcoal */
    --bg-0: #111111;
    --bg-1: #161616;
    --bg-2: #1a1a1a;
    --bg-3: #222222;
    --bg-4: #2a2a2a;

    /* text */
    --text: #e0e0e0;
    --text-soft: #b8b8b8;
    --text-muted: #7a7a7a;
    --text-dim: #555555;

    /* border */
    --border: #2e2e2e;
    --border-strong: #3a3a3a;
    --border-focus: #4a7a6c;

    /* primary accent — muted teal (buttons, links, active nav) */
    --accent: #5a8f7f;
    --accent-hi: #6fa090;
    --accent-lo: #1a2421;
    --accent-dim: #2d4a42;
    --accent-on: #0a0f0d;

    /* KPI strip: four distinguishable matte accents (left stripe on .metric) */
    --stat-1: #5a8f7f;
    --stat-2: #6b86a8;
    --stat-3: #a68f6a;
    --stat-4: #8f7daa;

    /* semantic — readable on dark, still flat */
    --info: #7a9aab;
    --info-lo: #1a2228;
    --success: #7cb88c;
    --success-lo: #1a231c;
    --warn: #c4a66d;
    --warn-lo: #221e18;
    --danger: #c08080;
    --danger-lo: #231a1a;

    --c-teal: #5a8f7f;
    --c-sky: #6b86a8;
    --c-violet: #8f7daa;
    --c-rose: #b07a7a;
    --c-lime: #8faa7a;

    --font-display: "Space Grotesk", "IBM Plex Sans", ui-sans-serif, system-ui, sans-serif;
    --font-sans: "IBM Plex Sans", ui-sans-serif, system-ui, sans-serif;
    --font-mono: "JetBrains Mono", "IBM Plex Mono", ui-monospace, SFMono-Regular, Consolas, monospace;

    --r-xs: 3px;
    --r-sm: 4px;
    --r-md: 5px;
    --r-lg: 6px;
    --r-xl: 8px;

    --s-1: 4px;
    --s-2: 6px;
    --s-3: 8px;
    --s-4: 10px;
    --s-5: 12px;
    --s-6: 16px;
    --s-8: 20px;

    --rail-w: 48px;
    --max-w: 1600px;

    /* single flat shadow for overlays only */
    --panel: var(--bg-2);

    /* table row hover — slight teal-gray */
    --row-hover: #1a221f;
}

/* keep backward-compat: anywhere old css expects these names */
:root {
    --color-accent: var(--accent);
}

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

html, body {
    margin: 0;
    padding: 0;
    background: var(--bg-0);
    color: var(--text);
    font-family: var(--font-sans);
    font-size: 12px;
    line-height: 1.45;
    font-feature-settings: "ss01", "cv11";
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    min-height: 100vh;
}

body { background: var(--bg-0); }

h1, h2, h3, h4 {
    margin: 0;
    font-family: var(--font-display);
    font-weight: 600;
    letter-spacing: -0.015em;
    color: var(--text);
}
h1 { font-size: 1.05rem; line-height: 1.2; }
h2 { font-size: 0.92rem; line-height: 1.25; }
h3 { font-size: 0.8rem; line-height: 1.3; text-transform: none; }

p, dd, dt, li, label { margin: 0; }

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

code, pre, .mono { font-family: var(--font-mono); font-size: 0.82em; }

.autogrind-player-name-wrap {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    min-width: 0;
}

.autogrind-player-mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1rem;
    height: 1rem;
    flex: 0 0 auto;
    color: var(--accent-hi);
    background: color-mix(in srgb, var(--accent-lo) 82%, transparent);
    border: 1px solid var(--accent-dim);
    border-radius: 999px;
}

.autogrind-player-mark svg {
    width: 0.72rem;
    height: 0.72rem;
}

/* scrollbars (webkit) */
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb { background: var(--bg-3); border-radius: 999px; border: 2px solid var(--bg-0); }
*::-webkit-scrollbar-thumb:hover { background: var(--bg-4); }

/* numbers always tabular */
.metric-value, .data-table td, .detail-list dd, .ag-stat strong,
.last-backup-code, .result-import-code, .result-advanced-code {
    font-variant-numeric: tabular-nums;
}

/* ---------- app shell: sidebar + main ---------- */
.app {
    display: grid;
    grid-template-columns: var(--rail-w) 1fr;
    min-height: 100vh;
    animation: app-fade-in 0.28s ease-out;
}

.sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    background: var(--bg-1);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 8px 0 8px;
    gap: 2px;
    z-index: 20;
}

.sidebar .brand {
    flex: 0 0 32px;
    width: 32px;
    height: 32px;
    border-radius: var(--r-sm);
    background: var(--accent-lo);
    border: 1px solid var(--accent-dim);
    display: grid;
    place-items: center;
    color: var(--accent-hi);
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 0.85rem;
    letter-spacing: -0.02em;
    margin-bottom: 6px;
}

.sidebar .rail-divider {
    width: 22px;
    height: 1px;
    background: var(--border);
    margin: 4px 0;
}

.rail-link {
    position: relative;
    width: 34px;
    height: 34px;
    display: grid;
    place-items: center;
    border-radius: var(--r-sm);
    color: var(--text-muted);
    background: transparent;
    border: 1px solid transparent;
    transition: color 0.15s ease, background 0.15s ease, border-color 0.15s ease;
}
.rail-link svg { width: 16px; height: 16px; }
.rail-link:hover {
    color: var(--text);
    background: var(--bg-2);
    border-color: var(--border);
}
.rail-link.active {
    color: var(--accent-hi);
    background: var(--accent-lo);
    border-color: var(--accent-dim);
}
.rail-link.active::before {
    content: "";
    position: absolute;
    left: -10px;
    top: 6px;
    bottom: 6px;
    width: 2px;
    border-radius: 1px;
    background: var(--accent);
}
/* tooltip label on hover */
.rail-link[data-label]::after {
    content: attr(data-label);
    position: absolute;
    left: calc(100% + 10px);
    top: 50%;
    transform: translateY(-50%) translateX(-4px);
    background: var(--bg-3);
    color: var(--text);
    font-size: 10px;
    font-weight: 500;
    padding: 4px 8px;
    border: 1px solid var(--border-strong);
    border-radius: var(--r-sm);
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.15s ease, transform 0.15s ease;
    z-index: 30;
}
.rail-link:hover[data-label]::after { opacity: 1; transform: translateY(-50%) translateX(0); }

.sidebar .rail-spacer { flex: 1; }

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

/* ---------- page header (slim, inline with content) ---------- */
.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--s-3);
    padding: 8px 14px 8px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-0);
}

.topbar-block { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.topbar-block h1 { font-size: 1rem; font-weight: 600; }

.topbar-actions {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    justify-content: flex-end;
}
.topbar-actions .button { flex-shrink: 0; }

.eyebrow {
    font-size: 9px;
    font-weight: 600;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--text-muted);
    display: inline-flex;
    align-items: center;
    gap: 5px;
}
.eyebrow::before {
    content: "";
    width: 3px;
    height: 3px;
    border-radius: 0;
    background: var(--accent);
}

.muted { color: var(--text-muted); }

/* ---------- main shell ---------- */
.shell {
    padding: 8px 14px 28px;
    max-width: var(--max-w);
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* SPC generator: use full main column (no artificial narrow column) */
.create-shell {
    max-width: none;
    width: 100%;
    box-sizing: border-box;
}

/* Wider minimum columns on large screens so the form breathes edge-to-edge */
.create-page .field-grid {
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}
.create-page .field-wide {
    grid-column: 1 / -1;
}

/* ---------- buttons ---------- */
.button,
button.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    height: 26px;
    padding: 0 9px;
    font-family: var(--font-sans);
    font-size: 11px;
    font-weight: 500;
    color: var(--text-soft);
    background: var(--bg-2);
    border: 1px solid var(--border);
    border-radius: var(--r-sm);
    cursor: pointer;
    user-select: none;
    text-decoration: none;
    transition: background 0.13s ease, border-color 0.13s ease, color 0.13s ease, transform 0.08s ease;
    white-space: nowrap;
}
.button:hover,
.button:active,
.button:focus-visible {
    background: var(--bg-3);
    border-color: var(--border-strong);
    color: var(--text);
}
.button:active { transform: translateY(1px); }
.button:focus-visible { outline: 2px solid var(--border-focus); outline-offset: 1px; }
.button:disabled {
    opacity: 0.55;
    cursor: not-allowed;
    transform: none;
}

.button-sm { height: 22px; padding: 0 7px; font-size: 10px; border-radius: var(--r-xs); }
.button-lg { height: 30px; padding: 0 14px; font-size: 12px; }

.button-solid {
    background: var(--accent);
    color: var(--accent-on);
    border-color: var(--accent-dim);
    font-weight: 600;
}
.button-solid:hover {
    background: var(--accent-hi);
    color: var(--accent-on);
    border-color: var(--accent-hi);
}

.button-ghost {
    background: transparent;
    border-color: var(--border);
    color: var(--text-muted);
}
.button-ghost:hover {
    background: var(--bg-2);
    color: var(--text);
}

.action-danger-outline {
    background: transparent;
    color: var(--danger);
    border-color: #5c3d3d;
}
.action-danger-outline:hover {
    background: var(--danger-lo);
    color: #d49898;
    border-color: var(--danger);
}

/* "Max all" on create page */
.create-page .button-max {
    background: transparent;
    color: var(--text-soft);
    border-color: var(--border-strong);
}
.create-page .button-max:hover { background: var(--bg-3); color: var(--text); }
.create-page .button-max.is-active { background: var(--accent-lo); color: var(--accent-hi); border-color: var(--accent-dim); }
.create-page .small { font-size: 11px; }

/* ---------- status badges / chips ---------- */
.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    height: 22px;
    padding: 0 8px;
    border-radius: var(--r-xs);
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.04em;
    background: var(--bg-2);
    color: var(--text-muted);
    border: 1px solid var(--border);
    text-transform: uppercase;
}
.status-badge::before {
    content: "";
    width: 5px; height: 5px;
    border-radius: 50%;
    background: var(--text-dim);
}
.status-badge.ok,
.status-badge.connected,
.status-badge.is-ok {
    color: var(--success);
    border-color: #2d4a38;
    background: var(--success-lo);
}
.status-badge.ok::before { background: var(--success); }
.status-badge.err,
.status-badge.is-err {
    color: var(--danger);
    border-color: #4a3232;
    background: var(--danger-lo);
}
.status-badge.err::before { background: var(--danger); }
.status-badge.warn { color: var(--warn); border-color: #4a4030; background: var(--warn-lo); }
.status-badge.warn::before { background: var(--warn); }

.read-only-pill {
    display: inline-block;
    margin-left: 6px;
    font-size: 9px;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    padding: 1px 5px;
    border-radius: var(--r-xs);
    color: var(--info);
    background: var(--info-lo);
    border: 1px solid #2d3d48;
    vertical-align: middle;
}

/* ---------- inputs / forms ---------- */
input, textarea, select {
    font-family: inherit;
    font-size: 12px;
    color: var(--text);
    background: var(--bg-1);
    border: 1px solid var(--border);
    border-radius: var(--r-sm);
    padding: 5px 8px;
    transition: border-color 0.13s ease, background 0.13s ease;
    min-width: 0;
    width: 100%;
}
input::placeholder, textarea::placeholder { color: var(--text-dim); }
input:focus, textarea:focus, select:focus {
    outline: none;
    border-color: var(--border-focus);
    background: var(--bg-2);
}
input[type="checkbox"] { width: auto; }

.input-inline {
    background: var(--bg-1);
    border: 1px solid var(--border);
    color: var(--text);
    border-radius: var(--r-sm);
    padding: 4px 8px;
    font-size: 11px;
}
.input-inline::placeholder { color: var(--text-dim); }
.input-inline:focus { border-color: var(--border-focus); outline: none; background: var(--bg-2); }

.form-group {
    display: flex;
    flex-direction: column;
    gap: 5px;
}
.form-group label {
    font-size: 11px;
    font-weight: 500;
    color: var(--text-muted);
    letter-spacing: 0.02em;
}
.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
}
.form-group textarea { min-height: 80px; resize: vertical; }

.form-group-inline {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
}
.form-group-inline label {
    font-size: 11px;
    color: var(--text-muted);
    font-weight: 500;
    margin-right: 2px;
}
.form-group-inline .input-inline { flex: 1 1 180px; }

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

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

.form-title {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    letter-spacing: 0.06em;
    text-transform: uppercase;
    margin-bottom: 6px;
}

/* field = create-page style */
.field { display: flex; flex-direction: column; gap: 5px; }
.field label {
    font-size: 11.5px;
    font-weight: 600;
    color: var(--text-soft);
    letter-spacing: 0.01em;
}
.field label .muted { font-weight: 400; font-size: 10.5px; }
.field input, .field select, .field textarea { width: 100%; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--border-focus); }
.field-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 10px;
}

/* Align first control row across columns when labels differ in length (SPC generator, etc.) */
.field-grid.field-grid--align-controls {
    align-items: stretch;
}
.field-grid.field-grid--align-controls > .field {
    display: flex;
    flex-direction: column;
    gap: 5px;
    min-width: 0;
}
.field-grid.field-grid--align-controls > .field > label:first-child {
    min-height: 2.75em;
    line-height: 1.35;
}
.field-grid.field-grid--align-controls > .field > label:first-child + * {
    margin-top: auto;
}
.field-wide { grid-column: span 2; }
.field-hint { font-size: 10.5px; color: var(--text-dim); margin-top: 2px; }
.input-with-action { display: flex; gap: 6px; align-items: stretch; }
.input-with-action input { flex: 1; }
.input-with-action .button-ghost { flex-shrink: 0; }
.input-with-chips { flex-wrap: wrap; }
.chip-row { display: flex; flex-wrap: wrap; gap: 4px; }
.chip {
    font-size: 11px;
    padding: 3px 9px;
    border-radius: 999px;
    background: transparent;
    color: var(--text-muted);
    border: 1px solid var(--border);
    cursor: pointer;
}
.chip:hover { color: var(--text); border-color: var(--border-strong); }
.chip.active { background: var(--accent-lo); color: var(--accent-hi); border-color: var(--accent-dim); }

/* toggle (pill) */
.toggle-label {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    user-select: none;
    font-size: 12px;
    color: var(--text-soft);
}
.toggle-input { position: absolute; opacity: 0; width: 0; height: 0; pointer-events: none; }
.toggle-slider {
    position: relative;
    width: 30px;
    height: 16px;
    background: var(--bg-3);
    border: 1px solid var(--border);
    border-radius: 999px;
    transition: background 0.15s ease, border-color 0.15s ease;
    flex-shrink: 0;
}
.toggle-slider::before {
    content: "";
    position: absolute;
    top: 1px;
    left: 1px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--text-soft);
    transition: transform 0.15s ease, background 0.15s ease;
}
.toggle-input:checked + .toggle-slider { background: var(--accent-dim); border-color: var(--accent); }
.toggle-input:checked + .toggle-slider::before { transform: translateX(14px); background: var(--accent-hi); }
.toggle-input:focus-visible + .toggle-slider { outline: 1px solid var(--border-focus); outline-offset: 1px; }
.toggle-text { font-weight: 500; }

/* uid field */
.uid-field {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 2px;
    background: var(--bg-2);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    transition: border-color 0.13s ease;
}
.uid-field input {
    border: none;
    background: transparent;
    padding: 4px 8px;
    min-width: 220px;
    font-family: var(--font-mono);
    font-size: 11.5px;
}
.uid-field input:focus { background: transparent; }
.uid-field .button-sm { margin: 0; }
.uid-field.is-set { border-color: #2d4a38; background: var(--success-lo); }
.uid-field.is-set input { color: var(--success); }

/* leader override (pill toggle + input) */
.leader-override-group {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 2px 4px 2px 8px;
    background: var(--bg-2);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    transition: border-color 0.13s ease, background 0.13s ease;
}
.leader-override-toggle { display: inline-flex; }
.leader-override-toggle.active { /* no-op, style via input:checked */ }
.leader-uid-input {
    background: transparent;
    border: none;
    padding: 4px 8px;
    min-width: 180px;
    font-family: var(--font-mono);
    font-size: 11.5px;
    color: var(--text);
}
.leader-uid-input:focus { outline: none; background: transparent; }
.leader-override-group:has(.toggle-input:checked) {
    border-color: var(--accent-dim);
    background: var(--accent-lo);
}

.leader-override-warning {
    display: none;
    padding: 8px 10px;
    background: var(--warn-lo);
    border: 1px solid #4a4030;
    border-radius: var(--r-md);
    color: var(--warn);
    font-size: 12px;
    line-height: 1.5;
}
.leader-override-warning.active { display: block; }
.leader-override-warning strong { font-size: 11.5px; letter-spacing: 0.04em; }

/* ---------- panel (card) ---------- */
.panel {
    background: var(--bg-2);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    padding: 10px 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-width: 0;
}

.panel-head {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 8px;
    flex-wrap: wrap;
}
.panel-head h2 { font-size: 12.5px; font-weight: 600; margin-top: 1px; }

.panel-sub {
    font-size: 11px;
    color: var(--text-muted);
    font-weight: 500;
    letter-spacing: 0.02em;
}
.panel-message {
    font-size: 11px;
    color: var(--text-muted);
    margin: 0;
}

.panel-hero { position: relative; }
.panel-hero::before { display: none; }

/* ---------- summary row (kpi tiles) ---------- */
.summary-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 8px;
}

.metric {
    background: var(--bg-2);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    padding: 8px 10px;
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-height: 58px;
    position: relative;
    border-left: 3px solid var(--stat-1);
}
.summary-row .metric:nth-child(2) { border-left-color: var(--stat-2); }
.summary-row .metric:nth-child(3) { border-left-color: var(--stat-3); }
.summary-row .metric:nth-child(4) { border-left-color: var(--stat-4); }
.summary-row .metric:nth-child(n+5) { border-left-color: var(--border-strong); }
.metric::after { display: none; }
.metric-label {
    font-size: 9px;
    font-weight: 600;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--text-muted);
}
.metric-value {
    font-family: var(--font-display);
    font-size: 17px;
    font-weight: 600;
    color: var(--text);
    letter-spacing: -0.02em;
    line-height: 1.15;
}
.metric-accent { color: var(--stat-3); }
.metric-sub {
    display: block;
    margin-top: 0;
    font-size: 10px;
    color: var(--text-muted);
}

/* ---------- segmented control ---------- */
.segmented {
    display: inline-flex;
    padding: 2px;
    background: var(--bg-1);
    border: 1px solid var(--border);
    border-radius: var(--r-sm);
    gap: 1px;
}
.segment {
    height: 22px;
    padding: 0 8px;
    font-size: 10px;
    font-weight: 500;
    color: var(--text-muted);
    background: transparent;
    border: none;
    border-radius: var(--r-xs);
    cursor: pointer;
    transition: background 0.13s ease, color 0.13s ease;
}
.segment:hover { color: var(--text); background: var(--bg-2); }
.segment.active { color: var(--accent-hi); background: var(--accent-lo); }

.window-segments {
    display: inline-flex;
    padding: 2px;
    background: var(--bg-1);
    border: 1px solid var(--border);
    border-radius: var(--r-sm);
    gap: 1px;
    margin-top: 2px;
}
.window-segments .segment { padding: 0 6px; }

/* ---------- tables ---------- */
.table-wrap {
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    background: var(--bg-1);
    overflow: auto;
    max-width: 100%;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12.5px;
}
.data-table th,
.data-table thead th {
    text-align: left;
    font-size: 9px;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--accent-hi);
    background: var(--bg-1);
    padding: 6px 8px;
    border-bottom: 2px solid var(--accent-dim);
    position: sticky;
    top: 0;
    z-index: 1;
}
.data-table td {
    padding: 6px 8px;
    border-bottom: 1px solid var(--border);
    color: var(--text-soft);
    vertical-align: middle;
    font-size: 11px;
}
.data-table tbody tr:hover { background: var(--row-hover); }
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table.compact td,
.data-table.compact th { padding: 5px 7px; font-size: 10.5px; }

/* Leaderboard multi-select */
.data-table-lb .lb-select-col {
    width: 2rem;
    text-align: center;
    vertical-align: middle;
}
.lb-select-col .lb-select-all {
    margin: 0;
    accent-color: var(--accent-hi);
    cursor: pointer;
}
.data-table-lb td.lb-ch {
    text-align: center;
    vertical-align: middle;
}
.data-table-lb td.lb-ch input {
    margin: 0;
    accent-color: var(--accent-hi);
    cursor: pointer;
}
.multi-select-panel .multi-stats-dl { margin-top: 6px; }
.multi-select-panel .multi-stats-dl dd {
    font-variant-numeric: tabular-nums;
}

.table-action {
    height: 22px;
    padding: 0 8px;
    font-size: 11px;
    background: var(--bg-2);
    border: 1px solid var(--border);
    color: var(--text-soft);
    border-radius: var(--r-xs);
    cursor: pointer;
    transition: background 0.13s ease, color 0.13s ease;
}
.table-action:hover { background: var(--bg-3); color: var(--text); }

/* ---------- key/value list ---------- */
.detail-list {
    display: grid;
    grid-template-columns: 1fr;
    gap: 2px;
    margin: 0;
    padding: 0;
}
.detail-list div {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 12px;
    align-items: baseline;
    min-width: 0;
    padding: 6px 0;
    border-bottom: 1px dashed var(--border);
}
.detail-list div:last-child { border-bottom: none; }
.detail-list dt {
    font-size: 10px;
    color: var(--text-muted);
    font-weight: 500;
    min-width: 0;
}
.detail-list dd {
    font-size: 11px;
    color: var(--text);
    font-weight: 500;
    text-align: right;
    font-variant-numeric: tabular-nums;
    min-width: 0;
}
.detail-list-drawer div { padding: 5px 0; }

.focus-block { display: flex; flex-direction: column; gap: 6px; }
.focus-block h3 {
    font-family: var(--font-display);
    font-size: 14px;
    font-weight: 600;
    letter-spacing: -0.015em;
}

/* ---------- split grids ---------- */
.split-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 8px;
}
.split-grid-bottom { grid-template-columns: 2fr 1fr; }
@media (max-width: 1100px) { .split-grid-bottom { grid-template-columns: 1fr; } }

.two-col {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}
@media (max-width: 1080px) { .two-col { grid-template-columns: 1fr; } }

/* ---------- generic stack-list (open teams etc.) ---------- */
.stack-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
    max-height: 320px;
    overflow-y: auto;
    padding-right: 4px;
}
.list-row {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 8px;
    align-items: center;
    padding: 7px 9px;
    background: var(--bg-1);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    transition: border-color 0.13s ease, background 0.13s ease, transform 0.08s ease;
    cursor: pointer;
}
.list-row:hover { border-color: var(--accent-dim); background: var(--row-hover); }
.list-row:active { transform: translateY(1px); }
.list-row strong { font-weight: 600; color: var(--text); font-size: 12.5px; }
.list-meta {
    font-size: 11px;
    color: var(--text-muted);
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 2px;
}

.empty {
    padding: 14px;
    text-align: center;
    color: var(--text-muted);
    font-size: 11px;
}

/* ---------- online dot / member indicator ---------- */
.online-dot,
.member-dot {
    display: inline-block;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--text-dim);
    margin-right: 6px;
    vertical-align: middle;
}
.online-dot.is-online,
.member-dot.online { background: var(--success); }
.online-dot.is-offline { background: var(--text-dim); }

.member-name { display: flex; flex-direction: column; gap: 2px; }
.member-name strong { font-weight: 600; color: var(--text); font-size: 12.5px; }
.member-sub { font-size: 11px; color: var(--text-muted); }
.member-status { font-size: 11px; color: var(--text-muted); }

/* ---------- modals ---------- */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.65);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
    z-index: 50;
}
.modal-overlay.active { opacity: 1; pointer-events: auto; }

.modal {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, calc(-50% + 8px));
    width: min(560px, calc(100vw - 40px));
    max-height: calc(100vh - 40px);
    overflow-y: auto;
    background: var(--bg-2);
    border: 1px solid var(--border-strong);
    border-radius: var(--r-lg);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.18s ease, transform 0.22s cubic-bezier(.2,.9,.3,1);
    box-shadow: none;
    z-index: 60;
}
.modal.active {
    opacity: 1;
    transform: translate(-50%, -50%);
    pointer-events: auto;
}
.modal-content { padding: 14px 16px 12px; }
.modal-content h2 { font-size: 13px; margin-bottom: 8px; }
.modal-close {
    position: absolute;
    top: 10px;
    right: 12px;
    width: 28px;
    height: 28px;
    font-size: 20px;
    line-height: 1;
    background: transparent;
    color: var(--text-muted);
    border: 1px solid var(--border);
    border-radius: var(--r-sm);
    cursor: pointer;
    display: grid;
    place-items: center;
    transition: background 0.13s ease, color 0.13s ease;
}
.modal-close:hover { background: var(--bg-3); color: var(--text); }

.member-modal-content { width: min(640px, calc(100vw - 40px)); }
.member-modal-head { margin-bottom: 10px; }
.member-modal-head h2 { font-size: 14px; }
.member-modal-body { display: flex; flex-direction: column; gap: 10px; }
.member-modal-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.member-modal-content .detail-list div {
    grid-template-columns: minmax(0, 150px) minmax(0, 1fr);
    align-items: start;
}
.member-modal-content .detail-list dd {
    text-align: left;
    overflow-wrap: anywhere;
    word-break: break-word;
}
.member-modal-raw {
    display: none;
    font-size: 11px;
    padding: 10px;
    background: var(--bg-1);
    border: 1px solid var(--border);
    border-radius: var(--r-sm);
    max-height: 260px;
    overflow: auto;
    color: var(--text-soft);
}
.member-modal-raw.visible { display: block; }

/* centered confirm (stacked above other modals) */
#confirm-modal.modal {
    z-index: 70;
    width: min(440px, calc(100vw - 40px));
}
.confirm-modal-inner {
    position: relative;
    padding-right: 40px;
}
.confirm-modal-message {
    font-size: 13px;
    color: var(--text-soft);
    line-height: 1.55;
    margin: 0 0 16px;
}
.confirm-modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    flex-wrap: wrap;
}
.confirm-modal-dismiss {
    position: absolute;
    top: 10px;
    right: 12px;
    width: 28px;
    height: 28px;
    font-size: 20px;
    line-height: 1;
    background: transparent;
    color: var(--text-muted);
    border: 1px solid var(--border);
    border-radius: var(--r-sm);
    cursor: pointer;
    display: grid;
    place-items: center;
    transition: background 0.13s ease, color 0.13s ease;
}
.confirm-modal-dismiss:hover {
    background: var(--bg-3);
    color: var(--text);
}

/* ---------- drawer (team control center) ---------- */
.drawer {
    position: fixed;
    top: 50%;
    left: 50%;
    width: min(1240px, calc(100vw - 56px));
    height: min(900px, calc(100vh - 56px));
    min-width: 760px;
    background: var(--bg-1);
    border: 1px solid var(--border-strong);
    border-radius: 14px;
    transform: translate(-50%, calc(-50% + 18px)) scale(0.98);
    opacity: 0;
    pointer-events: none;
    transition: transform 0.24s cubic-bezier(.2,.85,.3,1), opacity 0.18s ease;
    box-shadow: 0 28px 80px rgba(0, 0, 0, 0.46);
    z-index: 55;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.drawer.active {
    transform: translate(-50%, -50%) scale(1);
    opacity: 1;
    pointer-events: auto;
}
.drawer-inner {
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
}
.drawer-head {
    padding: 18px 22px 14px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 20px;
}
.drawer-head h2 { font-size: 24px; }
.drawer-close {
    width: 44px;
    height: 44px;
    background: transparent;
    color: var(--text-muted);
    border: 1px solid var(--border);
    border-radius: 12px;
    font-size: 28px;
    line-height: 1;
    cursor: pointer;
}
.drawer-close:hover { color: var(--text); background: var(--bg-3); }

.drawer-tabs {
    display: flex;
    gap: 0;
    padding: 0 20px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-1);
}
.drawer-tab {
    height: 54px;
    padding: 0 18px;
    font-size: 15px;
    font-weight: 600;
    background: transparent;
    color: var(--text-muted);
    border: none;
    border-bottom: 3px solid transparent;
    cursor: pointer;
    transition: color 0.13s ease, border-color 0.13s ease;
}
.drawer-tab:hover { color: var(--text); }
.drawer-tab.active { color: var(--accent-hi); border-bottom-color: var(--accent); }

.drawer-tab-panel { display: none; padding: 18px 20px 20px; overflow-y: auto; flex: 1; }
.drawer-tab-panel.active { display: block; }

.drawer-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
}
.drawer-card {
    background: var(--bg-2);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 16px 18px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.drawer-card h3 { font-size: 15px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-muted); font-weight: 700; }
.drawer-card-wide { grid-column: 1 / -1; }
.drawer-card-table { grid-column: 1 / -1; }
.drawer-copy { font-size: 15px; color: var(--text-soft); line-height: 1.65; }

.read-only-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.read-only-raw {
    margin-top: 4px;
    padding: 6px 2px;
    border-top: 1px dashed var(--border);
}
.read-only-raw summary {
    cursor: pointer;
    font-size: 11.5px;
    color: var(--text-muted);
    padding: 4px 0;
    list-style: none;
}
.read-only-raw summary::-webkit-details-marker { display: none; }
.read-only-raw summary::before { content: "▸ "; color: var(--text-dim); }
.read-only-raw[open] summary::before { content: "▾ "; }
.read-only-raw summary:hover { color: var(--text); }
.read-only-pre {
    font-family: var(--font-mono);
    font-size: 11px;
    line-height: 1.55;
    background: var(--bg-1);
    color: var(--text-soft);
    border: 1px solid var(--border);
    border-radius: var(--r-sm);
    padding: 10px;
    max-height: 240px;
    overflow: auto;
    margin-top: 8px;
    white-space: pre-wrap;
    word-break: break-all;
}

/* chat */
.chat-window {
    height: 260px;
    max-height: 40vh;
    overflow-y: auto;
    padding: 6px;
    background: var(--bg-1);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.chat-message {
    padding: 6px 10px;
    background: var(--bg-2);
    border-radius: var(--r-sm);
    border: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 2px;
    position: relative;
}
.chat-message .chat-meta {
    font-size: 10.5px;
    color: var(--text-muted);
    display: flex;
    justify-content: space-between;
    gap: 10px;
}
.chat-message .chat-body {
    font-size: 12.5px;
    color: var(--text);
    line-height: 1.45;
    word-break: break-word;
}
.chat-input-row {
    display: flex;
    gap: 6px;
    margin-top: 10px;
}
.chat-input-row input { flex: 1; }
.chat-actions {
    margin-top: 8px;
    padding-top: 10px;
    border-top: 1px dashed var(--border);
}
.delete-chat-btn {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 20px;
    height: 20px;
    background: transparent;
    border: none;
    color: var(--text-dim);
    cursor: pointer;
    font-size: 13px;
    border-radius: var(--r-xs);
    opacity: 0;
    transition: opacity 0.13s ease, color 0.13s ease, background 0.13s ease;
}
.chat-message:hover .delete-chat-btn { opacity: 1; }
.delete-chat-btn:hover { color: var(--danger); background: var(--danger-lo); }

/* settings groups in drawer */
.settings-group {
    padding: 8px 0;
    border-bottom: 1px dashed var(--border);
}
.settings-group:last-child { border-bottom: none; }
.settings-group-label {
    font-size: 9px;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: 4px;
}
.action-row { display: flex; gap: 6px; flex-wrap: wrap; }

.action-result {
    margin-top: 8px;
    padding: 8px 10px;
    background: var(--success-lo);
    border: 1px solid #2d4a38;
    border-radius: var(--r-md);
    color: var(--success);
    font-size: 11px;
}
.action-result.error {
    background: var(--danger-lo);
    border-color: #4a3232;
    color: var(--danger);
}

/* ---------- create-account page specifics ---------- */
.panel-create {
    gap: 6px;
    padding: 6px 8px;
}

.create-callout {
    font-size: 11.5px;
    line-height: 1.45;
    margin: 0 0 16px;
    padding: 10px 12px;
    border-radius: var(--r-md);
    border: 1px solid var(--border);
    background: var(--bg-1);
}
.create-callout-lead {
    color: var(--text-soft);
    font-weight: 600;
}
.create-section {
    margin-bottom: 10px;
}
.create-section:last-of-type {
    margin-bottom: 2px;
}
.create-section-title {
    font-size: 9.5px;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-muted);
    margin: 0 0 6px;
    padding-bottom: 3px;
    border-bottom: 1px solid var(--border);
}
.create-page .field-grid.field-grid--create {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 8px 10px;
    align-items: start;
}
@media (min-width: 760px) {
    .create-page .field-grid.field-grid--create {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}
@media (min-width: 980px) {
    .create-page .field-grid.field-grid--create {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }
}
@media (min-width: 1280px) {
    .create-page .field-grid.field-grid--create {
        grid-template-columns: repeat(5, minmax(0, 1fr));
    }
}
@media (min-width: 1680px) {
    .create-page .field-grid.field-grid--create {
        grid-template-columns: repeat(6, minmax(0, 1fr));
    }
}
.create-page .field-grid.field-grid--create > .field {
    min-width: 0;
    gap: 3px;
}
.create-page .field-grid.field-grid--create > .field > .field-hint {
    font-size: 9px;
    line-height: 1.18;
}
.create-page .field-span-2 {
    grid-column: span 2;
}
@media (max-width: 640px) {
    .create-page .field-span-2 {
        grid-column: span 1;
    }
}
/* Calmer label/control rhythm than generic field-grid--align-controls. */
.create-page .field-grid.field-grid--create > .field > label:first-child {
    min-height: 0;
}
.create-page .field-grid.field-grid--create > .field > label:first-child + * {
    margin-top: 0;
}
.create-page .field-grid.field-grid--create > .field > label {
    font-size: 10.5px;
    line-height: 1.15;
}
.create-page .field-grid.field-grid--create .input-with-action {
    gap: 4px;
}
.create-page .field-grid.field-grid--create .input-with-action .button {
    padding-inline: 7px;
}
.create-page .range-field {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 132px;
    gap: 8px;
    align-items: center;
}
.create-page .range-field--with-button {
    grid-template-columns: minmax(0, 1fr) 96px auto;
}
.create-page .range-field input[type="range"] {
    width: 100%;
}
.create-page .range-field .button {
    padding-inline: 7px;
}
.create-page .range-field ~ .field-hint:not(#cookiePowerHint) {
    display: none;
}
.field-hint-tight {
    margin-bottom: 1px;
    margin-top: 1px;
}
.chip-row-events {
    gap: 4px;
    margin-top: 1px;
}
.chip-row-events .chip {
    flex: 0 1 auto;
    padding: 1px 7px;
    font-size: 10px;
}
.inline-code {
    font-family: var(--font-mono);
    font-size: 10px;
    padding: 1px 5px;
    border-radius: var(--r-xs);
    background: var(--bg-2);
    border: 1px solid var(--border);
    color: var(--text-soft);
}
.input-with-action--split {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px;
}
.input-with-action--split > input {
    flex: 1 1 200px;
    min-width: 140px;
}
.input-action-cluster {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px;
    flex: 0 1 auto;
}
.create-head {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}
.create-head h2 { font-size: 12.5px; margin-bottom: 0; }
.create-head .muted {
    max-width: 70ch;
    font-size: 11px;
    line-height: 1.25;
}
.last-backup {
    display: flex;
    flex-direction: column;
    gap: 1px;
    align-items: flex-end;
    min-width: 140px;
    max-width: min(100%, 300px);
}
.last-backup-code {
    font-family: var(--font-mono);
    font-size: 11px;
    padding: 3px 7px;
    background: var(--bg-1);
    border: 1px solid var(--border);
    border-radius: var(--r-sm);
    color: var(--text);
    word-break: break-all;
    text-align: right;
}
.create-page input,
.create-page select,
.create-page textarea {
    font-size: 11px;
    padding: 4px 7px;
}
.create-page .button,
.create-page button.button {
    height: 24px;
    padding: 0 8px;
    font-size: 10.5px;
}
.create-page .button-lg {
    height: 28px;
    padding: 0 12px;
    font-size: 11px;
}
.create-form { display: flex; flex-direction: column; gap: 8px; }
.create-status { font-size: 12px; margin-top: 4px; }
.create-status.is-error { color: var(--danger); }

.result-import {
    margin-top: 1px;
    border: 1px solid var(--border-strong);
    border-left: 3px solid var(--accent);
    background: var(--bg-1);
    border-radius: var(--r-lg);
}
.result-import-inner { padding: 6px 8px; display: flex; flex-direction: column; gap: 5px; }
.result-import-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    gap: 8px;
    flex-wrap: wrap;
}
.result-import-head .eyebrow { color: var(--accent-hi); }
.result-import-hint { font-size: 9px; }
.result-import-code {
    display: block;
    font-family: var(--font-mono);
    font-size: 11px;
    padding: 5px 7px;
    background: var(--accent-lo);
    border: 1px solid var(--accent-dim);
    border-radius: var(--r-md);
    color: var(--accent-hi);
    letter-spacing: 0.06em;
    word-break: break-all;
}
.create-page .result-import-inner.is-batch .result-import-head .result-copy-primary,
.create-page .result-import-inner.is-batch #result-spc {
    display: none;
}
.create-page .batch-codes-wrap {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 4px;
}
.create-page .batch-code-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: min(60vh, 480px);
    overflow-y: auto;
}
.create-page .batch-code-row {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    padding: 8px 10px;
    background: var(--bg-0);
    border: 1px solid var(--border-strong);
    border-radius: var(--r-md);
}
.create-page .batch-code-idx {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    flex: 0 0 auto;
    min-width: 2.25rem;
}
.create-page .batch-code-value {
    flex: 1 1 200px;
    margin: 0;
    font-family: var(--font-mono);
    font-size: 11px;
    line-height: 1.4;
    word-break: break-all;
    color: var(--accent-hi);
    letter-spacing: 0.04em;
}
.create-page .batch-copy-btn {
    flex: 0 0 auto;
}
.result-import-code:not(.has-value) { color: var(--text-dim); }
.result-copy-primary { align-self: center; }

@media (min-width: 1100px) {
    .create-page .field-grid.field-grid--create > .field {
        position: relative;
        overflow: visible;
    }

    .create-page .field-grid.field-grid--create > .field > .field-hint {
        display: block;
        position: absolute;
        top: calc(100% + 4px);
        left: 0;
        right: 0;
        padding: 6px 7px;
        background: rgba(15, 19, 18, 0.98);
        border: 1px solid var(--border-strong);
        border-radius: var(--r-sm);
        box-shadow: 0 8px 18px rgba(0, 0, 0, 0.24);
        opacity: 0;
        visibility: hidden;
        pointer-events: none;
        transform: translateY(-4px);
        transition: opacity 0.14s ease, transform 0.14s ease, visibility 0.14s ease;
        z-index: 4;
    }

    .create-page .field-grid.field-grid--create > .field > .field-hint.field-hint-tight {
        position: static;
        padding: 0;
        background: none;
        border: 0;
        border-radius: 0;
        box-shadow: none;
        opacity: 1;
        visibility: visible;
        pointer-events: auto;
        transform: none;
    }

    .create-page .field-grid.field-grid--create > .field:hover > .field-hint:not(.field-hint-tight),
    .create-page .field-grid.field-grid--create > .field:focus-within > .field-hint:not(.field-hint-tight) {
        opacity: 1;
        visibility: visible;
        transform: translateY(0);
    }
}

@media (min-width: 1280px) {
    .create-page .field-template {
        grid-column: span 4;
    }

    .create-page .field-batch,
    .create-page .field-stat-first-play,
    .create-page .field-videos {
        grid-column: span 1;
    }

    .create-page .field-vip {
        grid-column: span 2;
    }
}

@media (min-width: 1680px) {
    .create-page .field-template {
        grid-column: span 5;
    }

    .create-page .field-videos {
        grid-column: span 2;
    }
}

.result-advanced {
    padding: 8px 0 0;
    border-top: 1px dashed var(--border);
}
.result-advanced summary {
    cursor: pointer;
    font-size: 12px;
    color: var(--text-muted);
    padding: 6px 0;
    list-style: none;
    font-weight: 500;
}
.result-advanced summary::-webkit-details-marker { display: none; }
.result-advanced summary::before { content: "▸ "; color: var(--text-dim); }
.result-advanced[open] summary::before { content: "▾ "; }
.result-advanced summary:hover { color: var(--text); }
.result-advanced-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-top: 10px;
}
.result-advanced-code {
    display: block;
    font-family: var(--font-mono);
    font-size: 11.5px;
    padding: 8px 10px;
    background: var(--bg-1);
    border: 1px solid var(--border);
    border-radius: var(--r-sm);
    color: var(--text);
    word-break: break-all;
}
.result-advanced-code.has-value { color: var(--accent-hi); }

.result-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 10px; }
.result-card { padding: 10px; background: var(--bg-1); border: 1px solid var(--border); border-radius: var(--r-md); }
.result-card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.result-card-head .eyebrow { }
.result-card .eyebrow { margin-bottom: 4px; display: block; }
.result-card code {
    display: block;
    font-family: var(--font-mono);
    font-size: 12px;
    padding: 8px 10px;
    background: var(--bg-2);
    border: 1px solid var(--border);
    border-radius: var(--r-sm);
    color: var(--text);
    word-break: break-all;
    margin-top: 8px;
}
.result-card code:not(.has-value) { color: var(--text-dim); }
.result-copy-btn { margin-top: 8px; }
.result-copy-btn:disabled { opacity: 0.55; }

/* SPC / gear modal-specific layouts */
.spc-modal-content { width: min(640px, calc(100vw - 40px)); }
.spc-form { display: flex; flex-direction: column; gap: 10px; }
.spc-form .form-group { gap: 4px; }
.spc-lead { font-size: 12.5px; color: var(--text-soft); }
.spc-lead code { color: var(--accent-hi); }
.spc-code { font-family: var(--font-mono); font-size: 12px; color: var(--accent-hi); }
.spc-result {
    padding: 12px;
    background: var(--bg-1);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    margin-top: 10px;
}
.spc-result-label { font-size: 11px; color: var(--text-muted); }
.spc-result-meta { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 8px; }
.spc-result-meta > div { display: flex; flex-direction: column; gap: 2px; }
.spc-result-meta dt { font-size: 10.5px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.08em; }
.spc-result-meta dd { font-size: 12.5px; color: var(--text); font-variant-numeric: tabular-nums; }

/* ---------- responsive ---------- */
@media (max-width: 720px) {
    .app { grid-template-columns: 1fr; }
    .sidebar {
        position: fixed;
        left: 0; right: 0; bottom: 0; top: auto;
        flex-direction: row;
        height: 56px;
        width: 100%;
        padding: 0 14px;
        border-right: none;
        border-top: 1px solid var(--border);
        gap: 2px;
        justify-content: space-around;
    }
    .sidebar .brand { margin-bottom: 0; }
    .sidebar .rail-divider { display: none; }
    .sidebar .rail-spacer { display: none; }
    .rail-link[data-label]::after {
        left: 50%;
        top: auto;
        bottom: calc(100% + 8px);
        transform: translate(-50%, 4px);
    }
    .rail-link:hover[data-label]::after { transform: translate(-50%, 0); }
    .shell { padding: 8px 10px 72px; }
    .topbar { padding: 8px 10px 8px; }
    .topbar-actions { justify-content: flex-start; }
    .drawer {
        width: calc(100vw - 20px);
        height: calc(100vh - 20px);
        min-width: 0;
        border-radius: 12px;
    }
    .drawer-grid { grid-template-columns: 1fr; }
}

/* ---------- motion + loading (shared) ---------- */
@keyframes app-fade-in {
    from { opacity: 0; }
    to { opacity: 1; }
}
@keyframes panel-rise {
    from { opacity: 0; transform: translateY(4px); }
    to { opacity: 1; transform: translateY(0); }
}
@keyframes spin-ring {
    to { transform: rotate(360deg); }
}
@keyframes load-dot-fade {
    0%, 60%, 100% { opacity: 0.2; }
    30% { opacity: 1; }
}

.panel {
    transition: border-color 0.18s ease, box-shadow 0.18s ease;
}
.panel:hover {
    border-color: var(--border-strong);
}

.summary-row .metric {
    transition: border-color 0.18s ease, transform 0.14s ease;
}
.summary-row .metric:hover {
    transform: translateY(-1px);
}

.data-table tbody tr {
    transition: background 0.12s ease;
}

.load-line,
.load-line__text {
    display: inline;
    vertical-align: baseline;
}
.load-inline {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: center;
}
.load-inline .load-line__text { display: inline; }

.loading-dots {
    display: inline;
    white-space: nowrap;
    letter-spacing: 0.02em;
}
.loading-dots .loading-dot {
    display: inline;
    animation: load-dot-fade 1.05s ease-in-out infinite;
}
.loading-dots .loading-dot:nth-child(1) { animation-delay: 0ms; }
.loading-dots .loading-dot:nth-child(2) { animation-delay: 150ms; }
.loading-dots .loading-dot:nth-child(3) { animation-delay: 300ms; }

.spinner {
    display: inline-block;
    width: 14px;
    height: 14px;
    border: 2px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    flex-shrink: 0;
    animation: spin-ring 0.65s linear infinite;
    vertical-align: middle;
}
.button .spinner {
    width: 12px;
    height: 12px;
    border-width: 2px;
}

.list-row--loading {
    justify-content: center;
    pointer-events: none;
    min-height: 48px;
}

.load-cell {
    text-align: center;
    padding-top: 14px !important;
    padding-bottom: 14px !important;
}

.status-badge.is-syncing {
    color: var(--info);
    border-color: #2d3d48;
    background: var(--info-lo);
}
.status-badge.is-syncing::before {
    background: var(--info);
    animation: load-dot-fade 1.2s ease-in-out infinite;
}

/* subtle lift on first paint for primary panels (direct shell children that are .panel) */
@media (min-width: 721px) {
    .shell > .panel {
        animation: panel-rise 0.32s ease-out backwards;
    }
}

/* ---------- reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
    * { transition: none !important; }
    .app,
    .shell .panel,
    .summary-row .metric:hover {
        animation: none !important;
        transform: none !important;
    }
    .loading-dots .loading-dot,
    .spinner,
    .status-badge.is-syncing::before {
        animation: none !important;
    }
    .loading-dots .loading-dot { opacity: 0.55; }
    .spinner { border-color: var(--accent-dim); border-top-color: var(--accent); }
}

/* =====================================================================
   GitHub-style dashboard skin
   Current reference inspected from github.com repo, Issues, Actions and
   appearance surfaces on 2026-04-24. This keeps app behavior intact and
   maps the dashboard to Primer-like tokens, spacing, borders and motion.
   ===================================================================== */

:root {
    --bg-0: #ffffff;
    --bg-1: #f6f8fa;
    --bg-2: #ffffff;
    --bg-3: #f6f8fa;
    --bg-4: #eff2f5;

    --text: #1f2328;
    --text-soft: #59636e;
    --text-muted: #59636e;
    --text-dim: #818b98;

    --border: #d1d9e0;
    --border-strong: #8c959f;
    --border-focus: #0969da;

    --accent: #0969da;
    --accent-hi: #0550ae;
    --accent-lo: #ddf4ff;
    --accent-dim: #54aeff;
    --accent-on: #ffffff;

    --success: #1a7f37;
    --success-lo: #dafbe1;
    --warn: #9a6700;
    --warn-lo: #fff8c5;
    --danger: #cf222e;
    --danger-lo: #ffebe9;
    --info: #0969da;
    --info-lo: #ddf4ff;

    --stat-1: #0969da;
    --stat-2: #8250df;
    --stat-3: #1a7f37;
    --stat-4: #bc4c00;

    --font-display: "Mona Sans VF", -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji";
    --font-sans: "Mona Sans VF", -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji";
    --font-mono: ui-monospace, SFMono-Regular, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;

    --r-xs: 3px;
    --r-sm: 6px;
    --r-md: 6px;
    --r-lg: 6px;
    --r-xl: 6px;

    --rail-w: 100%;
    --max-w: 1280px;
    --panel: #ffffff;
    --row-hover: #f6f8fa;
}

html,
body {
    background: #ffffff;
    color: var(--text);
    font-family: var(--font-sans);
    font-size: 14px;
    line-height: 1.5;
    font-feature-settings: normal;
}

body {
    min-width: 320px;
}

h1,
h2,
h3,
h4 {
    font-family: var(--font-sans);
    letter-spacing: 0;
    color: var(--text);
}

h1 { font-size: 20px; line-height: 1.5; font-weight: 600; }
h2 { font-size: 16px; line-height: 1.5; font-weight: 600; }
h3 { font-size: 14px; line-height: 1.5; font-weight: 600; }

a {
    color: var(--accent);
}

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

*::-webkit-scrollbar-thumb {
    background: #d1d9e0;
    border-color: #ffffff;
}

.app {
    display: block;
    min-height: 100vh;
    animation: none;
}

.sidebar {
    position: sticky;
    top: 0;
    height: 64px;
    width: 100%;
    flex-direction: row;
    justify-content: flex-start;
    align-items: center;
    gap: 8px;
    padding: 16px 32px;
    background: #25292e;
    border-right: 0;
    border-bottom: 1px solid #30363d;
    z-index: 50;
}

.sidebar .brand {
    width: 32px;
    height: 32px;
    margin: 0 8px 0 0;
    border-radius: 50%;
    border-color: rgba(255, 255, 255, 0.2);
    background: transparent;
    color: #ffffff;
    font-size: 16px;
    font-weight: 600;
}

.sidebar .rail-divider {
    display: none;
}

.rail-link {
    flex: 0 0 auto;
    width: auto;
    height: 32px;
    grid-auto-flow: column;
    display: inline-grid;
    grid-template-columns: auto auto;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 0 8px;
    border-radius: 6px;
    color: rgba(255, 255, 255, 0.82);
    border-color: transparent;
    transition:
        color 0.08s cubic-bezier(0.65, 0, 0.35, 1),
        background-color 0.08s cubic-bezier(0.65, 0, 0.35, 1),
        border-color 0.08s cubic-bezier(0.65, 0, 0.35, 1);
}

.rail-link svg {
    width: 16px;
    height: 16px;
    stroke-width: 2;
}

.rail-link:hover {
    color: #ffffff;
    background: rgba(255, 255, 255, 0.12);
    border-color: transparent;
    text-decoration: none;
}

.rail-link.active {
    color: #ffffff;
    background: rgba(255, 255, 255, 0.16);
    border-color: rgba(255, 255, 255, 0.08);
}

.rail-link.active::before {
    content: "";
    position: absolute;
    left: 8px;
    right: 8px;
    bottom: -17px;
    top: auto;
    width: auto;
    height: 2px;
    border-radius: 2px;
    background: #fd8c73;
}

.rail-link[data-label]::after {
    content: attr(data-label);
    position: static;
    transform: none;
    opacity: 1;
    pointer-events: auto;
    background: transparent;
    color: inherit;
    border: 0;
    border-radius: 0;
    padding: 0;
    font-size: 14px;
    font-weight: 600;
    white-space: nowrap;
    transition: none;
}

.rail-link:hover[data-label]::after {
    transform: none;
}

.sidebar .rail-spacer {
    flex: 1 1 auto;
}

.app-main {
    background: #ffffff;
}

.topbar {
    min-height: 96px;
    align-items: flex-end;
    padding: 20px 32px 0;
    background: #f6f8fa;
    border-bottom: 1px solid var(--border);
}

.topbar-block {
    gap: 4px;
    padding-bottom: 16px;
}

.topbar-block h1 {
    font-size: 20px;
    font-weight: 600;
}

.topbar-actions {
    align-items: center;
    padding-bottom: 16px;
}

.eyebrow {
    color: var(--text-muted);
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0;
    text-transform: none;
}

.shell {
    width: min(100%, var(--max-w));
    margin: 0 auto;
    padding: 24px 32px 64px;
    gap: 16px;
}

.button,
button.button {
    min-height: 32px;
    height: 32px;
    padding: 5px 12px;
    border-radius: 6px;
    border: 1px solid rgba(31, 35, 40, 0.15);
    background: #f6f8fa;
    color: #24292f;
    font-size: 14px;
    font-weight: 500;
    line-height: 20px;
    box-shadow: 0 1px 0 rgba(31, 35, 40, 0.04);
    transition:
        color 0.08s cubic-bezier(0.65, 0, 0.35, 1),
        background-color 0.08s cubic-bezier(0.65, 0, 0.35, 1),
        border-color 0.08s cubic-bezier(0.65, 0, 0.35, 1),
        box-shadow 0.08s cubic-bezier(0.65, 0, 0.35, 1);
}

.button:hover,
.button:active,
.button:focus-visible {
    background: #eff2f5;
    color: #24292f;
    border-color: rgba(31, 35, 40, 0.15);
    box-shadow: 0 1px 0 rgba(31, 35, 40, 0.08);
    transform: none;
    text-decoration: none;
}

.button:active {
    background: #eaeef2;
}

.button:focus-visible,
.input-inline:focus,
select:focus,
textarea:focus {
    outline: 2px solid #0969da;
    outline-offset: -2px;
    border-color: #0969da;
    box-shadow: inset 0 0 0 1px #0969da;
}

.button:disabled {
    color: #8c959f;
    background: #f6f8fa;
    border-color: rgba(31, 35, 40, 0.15);
    box-shadow: none;
}

.button-sm {
    min-height: 28px;
    height: 28px;
    padding: 3px 8px;
    font-size: 12px;
    border-radius: 6px;
}

.button-lg {
    min-height: 40px;
    height: 40px;
    padding: 9px 16px;
    font-size: 14px;
}

.button-solid {
    color: #ffffff;
    background: #1f883d;
    border-color: rgba(31, 35, 40, 0.15);
    box-shadow: 0 1px 0 rgba(31, 35, 40, 0.1);
}

.button-solid:hover,
.button-solid:focus-visible {
    color: #ffffff;
    background: #1a7f37;
    border-color: rgba(31, 35, 40, 0.15);
}

.button-solid:active {
    background: #116329;
}

.button-ghost {
    background: transparent;
    border-color: transparent;
    box-shadow: none;
}

.button-ghost:hover {
    background: #f6f8fa;
    color: #24292f;
}

.status-badge,
.ag-status {
    min-height: 20px;
    padding: 1px 7px;
    border-radius: 2em;
    border: 1px solid rgba(31, 35, 40, 0.15);
    background: #f6f8fa;
    color: var(--text-muted);
    font-size: 12px;
    font-weight: 500;
    letter-spacing: 0;
    text-transform: none;
}

.status-badge.ok,
.status-badge.connected,
.status-badge.is-ok,
.ag-status-running {
    color: #1a7f37;
    background: #dafbe1;
    border-color: rgba(26, 127, 55, 0.28);
}

.status-badge.err,
.status-badge.is-err,
.ag-status-error {
    color: #cf222e;
    background: #ffebe9;
    border-color: rgba(207, 34, 46, 0.28);
}

.status-badge.warn,
.ag-status-paused {
    color: #9a6700;
    background: #fff8c5;
    border-color: rgba(154, 103, 0, 0.28);
}

.status-badge::before,
.ag-status::before {
    width: 6px;
    height: 6px;
}

.input-inline,
textarea,
select {
    min-height: 32px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: #ffffff;
    color: var(--text);
    font-size: 14px;
    line-height: 20px;
    box-shadow: inset 0 1px 0 rgba(31, 35, 40, 0.04);
}

.input-inline::placeholder {
    color: #6e7781;
}

.input-inline:focus {
    background: #ffffff;
}

.form-group label {
    color: var(--text);
    font-size: 14px;
    font-weight: 600;
}

.muted,
.panel-sub,
.metric-sub {
    color: var(--text-muted);
}

.toggle-label {
    gap: 8px;
    color: var(--text);
}

.toggle-slider {
    width: 42px;
    height: 22px;
    border-radius: 999px;
    border-color: #d1d9e0;
    background: #afb8c1;
}

.toggle-slider::before {
    width: 18px;
    height: 18px;
    top: 1px;
    left: 1px;
    background: #ffffff;
    box-shadow: 0 1px 2px rgba(31, 35, 40, 0.18);
}

.toggle-input:checked + .toggle-slider {
    background: #1f883d;
    border-color: #1f883d;
}

.toggle-input:checked + .toggle-slider::before {
    transform: translateX(20px);
    background: #ffffff;
}

.panel {
    background: #ffffff;
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 16px;
    box-shadow: none;
    transition:
        border-color 0.08s cubic-bezier(0.65, 0, 0.35, 1),
        background-color 0.08s cubic-bezier(0.65, 0, 0.35, 1);
}

.panel:hover {
    border-color: var(--border);
    box-shadow: none;
}

.panel-head {
    margin: -16px -16px 16px;
    padding: 12px 16px;
    background: #f6f8fa;
    border-bottom: 1px solid var(--border);
    border-radius: 6px 6px 0 0;
}

.panel-head h2 {
    font-size: 16px;
    font-weight: 600;
}

.panel-message {
    background: #f6f8fa;
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-muted);
}

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

.metric {
    gap: 4px;
    min-height: 104px;
    padding: 16px;
    background: #ffffff;
    border: 1px solid var(--border);
    border-left: 1px solid var(--border);
    border-radius: 6px;
    box-shadow: none;
}

.summary-row .metric:nth-child(2),
.summary-row .metric:nth-child(3),
.summary-row .metric:nth-child(4),
.summary-row .metric:nth-child(n+5) {
    border-left-color: var(--border);
}

.metric:hover {
    transform: none;
    border-color: var(--border);
}

.metric-label {
    color: var(--text-muted);
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0;
    text-transform: none;
}

.metric-value {
    color: var(--text);
    font-family: var(--font-sans);
    font-size: 24px;
    font-weight: 600;
    letter-spacing: 0;
}

.metric-accent {
    color: var(--accent);
}

.table-wrap {
    border: 1px solid var(--border);
    border-radius: 6px;
    background: #ffffff;
    box-shadow: none;
}

.data-table {
    background: #ffffff;
    color: var(--text);
    font-size: 14px;
}

.data-table th,
.data-table thead th {
    height: 40px;
    padding: 8px 16px;
    background: #f6f8fa;
    border-bottom: 1px solid var(--border);
    color: var(--text-muted);
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0;
    text-transform: none;
}

.data-table td {
    padding: 10px 16px;
    border-bottom: 1px solid var(--border);
    color: var(--text);
    font-size: 14px;
}

.data-table.compact td,
.data-table.compact th {
    padding: 8px 12px;
    font-size: 13px;
}

.data-table tbody tr:hover {
    background: #f6f8fa;
}

.empty {
    color: var(--text-muted);
}

.modal-overlay {
    background: rgba(31, 35, 40, 0.4);
}

.modal {
    background: #ffffff;
    border: 1px solid var(--border);
    border-radius: 6px;
    box-shadow: 0 8px 24px rgba(140, 149, 159, 0.2);
}

.modal-content {
    padding: 16px;
}

.modal-content h2 {
    font-size: 16px;
    font-weight: 600;
}

.modal-close {
    width: 32px;
    height: 32px;
    border-radius: 6px;
    color: var(--text-muted);
}

.modal-close:hover {
    background: #f6f8fa;
    color: var(--text);
}

.spinner {
    border-color: #d1d9e0;
    border-top-color: #0969da;
}

@media (max-width: 900px) {
    .sidebar {
        height: auto;
        min-height: 56px;
        padding: 12px 20px;
        overflow-x: auto;
        scrollbar-width: none;
    }

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

    .auth-rail-popover {
        left: 0;
        right: auto;
    }

    .auth-slot {
        margin: 0 8px 0 0;
    }

    .rail-link[data-label]::after {
        display: none;
    }

    .topbar {
        min-height: auto;
        align-items: flex-start;
        flex-direction: column;
        padding: 16px 16px 0;
    }

    .topbar-actions {
        width: 100%;
        justify-content: flex-start;
    }

    .shell {
        padding: 16px 16px 48px;
    }
}

.theme-toggle-group {
    display: inline-flex;
    align-items: center;
    min-height: 32px;
    padding: 4px 8px;
    background: #ffffff;
    border: 1px solid var(--border);
    border-radius: 6px;
    box-shadow: 0 1px 0 rgba(31, 35, 40, 0.04);
}

.theme-toggle-label {
    color: var(--text);
}

.auth-slot {
    width: 32px;
    min-width: 32px;
    height: 32px;
    margin: 0 0 6px;
    display: grid;
    place-items: center;
}

.auth-toast {
    position: fixed;
    right: 16px;
    bottom: 16px;
    padding: 10px 14px;
    border-radius: 10px;
    background: #fff8c5;
    color: #24292f;
    border: 1px solid rgba(154, 103, 0, 0.28);
    font-weight: 700;
    z-index: 9999;
    box-shadow: 0 8px 24px rgba(140, 149, 159, 0.2);
}

.auth-rail {
    position: relative;
    width: 32px;
    height: 32px;
}

.auth-rail-trigger {
    width: 32px;
    height: 32px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    border: 1px solid rgba(31, 35, 40, 0.15);
    background: #ffffff;
    color: #24292f;
    cursor: pointer;
    font-family: var(--font-display);
    font-size: 16px;
    font-weight: 700;
    box-shadow: 0 1px 0 rgba(31, 35, 40, 0.04);
}

.auth-rail-trigger:hover,
.auth-rail-trigger:focus-visible {
    background: #f6f8fa;
    border-color: rgba(31, 35, 40, 0.15);
    outline: none;
}

.auth-rail-popover {
    position: absolute;
    top: calc(100% + 10px);
    left: 0;
    min-width: 180px;
    padding: 10px;
    border-radius: 10px;
    background: #ffffff;
    border: 1px solid var(--border);
    box-shadow: 0 8px 24px rgba(140, 149, 159, 0.2);
    z-index: 60;
}

.auth-rail-popover-head {
    display: grid;
    gap: 2px;
    padding-bottom: 8px;
    margin-bottom: 8px;
    border-bottom: 1px solid var(--border);
}

.auth-rail-popover-head strong {
    font-size: 13px;
    line-height: 1.2;
}

.auth-rail-popover-head span {
    color: var(--text-muted);
    font-size: 12px;
}

.auth-rail-popover-note {
    margin: -2px 0 8px;
    color: var(--text-muted);
    font-size: 11px;
    line-height: 1.4;
}

.auth-rail-popover-note strong {
    color: var(--text);
}

.auth-rail-section {
    display: grid;
    gap: 6px;
    padding-bottom: 8px;
    margin-bottom: 8px;
    border-bottom: 1px solid var(--border);
}

.auth-rail-section-label {
    color: var(--text-muted);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.auth-rail-user-list {
    display: grid;
    gap: 6px;
    max-height: 220px;
    overflow-y: auto;
}

.auth-rail-user-button {
    width: 100%;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 10px;
    min-height: 32px;
    padding: 7px 10px;
    border-radius: 8px;
    border: 1px solid rgba(31, 35, 40, 0.15);
    background: #f6f8fa;
    color: #24292f;
    cursor: pointer;
    text-align: left;
}

.auth-rail-user-button:hover:not(:disabled) {
    background: #eff2f5;
}

.auth-rail-user-button.is-current {
    background: #e7f0ff;
    border-color: rgba(9, 105, 218, 0.28);
}

.auth-rail-user-button:disabled {
    cursor: default;
    opacity: 1;
}

.auth-rail-user-button.is-loading {
    opacity: 0.72;
}

.auth-rail-user-name {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 12px;
    font-weight: 600;
}

.auth-rail-user-meta {
    color: var(--text-muted);
    font-size: 11px;
    text-transform: uppercase;
}

.auth-rail-popover-actions {
    display: grid;
    gap: 6px;
}

.auth-rail-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 28px;
    padding: 5px 10px;
    border-radius: 6px;
    border: 1px solid rgba(31, 35, 40, 0.15);
    background: #f6f8fa;
    color: #24292f;
    font-size: 12px;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
}

.auth-rail-link:hover {
    background: #eff2f5;
    text-decoration: none;
}

.auth-rail-link--logout {
    font: inherit;
}

/* GitHub dark mode, mapped from current Primer dark primitives. */
html[data-theme="dark"] {
    --bg-0: #0d1117;
    --bg-1: #010409;
    --bg-2: #0d1117;
    --bg-3: #151b23;
    --bg-4: #212830;

    --text: #f0f6fc;
    --text-soft: #d1d7e0;
    --text-muted: #9198a1;
    --text-dim: #656c76;

    --border: #3d444d;
    --border-strong: #656c76;
    --border-focus: #4493f8;

    --accent: #4493f8;
    --accent-hi: #79c0ff;
    --accent-lo: #388bfd1a;
    --accent-dim: #388bfd66;
    --accent-on: #ffffff;

    --success: #3fb950;
    --success-lo: #2ea04326;
    --warn: #d29922;
    --warn-lo: #bb800926;
    --danger: #f85149;
    --danger-lo: #f851491a;
    --info: #4493f8;
    --info-lo: #388bfd1a;

    --stat-1: #4493f8;
    --stat-2: #a371f7;
    --stat-3: #3fb950;
    --stat-4: #db6d28;

    --panel: #0d1117;
    --row-hover: #151b23;
}

html[data-theme="dark"],
html[data-theme="dark"] body {
    background: #0d1117;
    color: var(--text);
}

html[data-theme="dark"] *::-webkit-scrollbar-thumb {
    background: #3d444d;
    border-color: #0d1117;
}

html[data-theme="dark"] .sidebar {
    background: #010409;
    border-bottom-color: #3d444d;
}

html[data-theme="dark"] .sidebar .brand {
    border-color: #3d444d;
    color: #f0f6fc;
}

html[data-theme="dark"] .rail-link {
    color: #d1d7e0;
}

html[data-theme="dark"] .rail-link:hover {
    color: #ffffff;
    background: #212830;
}

html[data-theme="dark"] .rail-link.active {
    background: #212830;
    border-color: #3d444d;
}

html[data-theme="dark"] .rail-link.active::before {
    background: #fd8c73;
}

html[data-theme="dark"] .app-main,
html[data-theme="dark"] .topbar {
    background: #0d1117;
}

html[data-theme="dark"] .topbar {
    border-bottom-color: #3d444d;
}

html[data-theme="dark"] .button,
html[data-theme="dark"] button.button {
    color: #f0f6fc;
    background: #212830;
    border-color: #3d444d;
    box-shadow: 0 1px 0 rgba(1, 4, 9, 0.35);
}

html[data-theme="dark"] .button:hover,
html[data-theme="dark"] .button:active,
html[data-theme="dark"] .button:focus-visible {
    color: #f0f6fc;
    background: #262c36;
    border-color: #656c76;
}

html[data-theme="dark"] .button:active {
    background: #2a313c;
}

html[data-theme="dark"] .button:disabled {
    color: #656c76;
    background: #212830;
    border-color: #3d444d;
}

html[data-theme="dark"] .button-solid {
    color: #ffffff;
    background: #238636;
    border-color: #2ea04366;
}

html[data-theme="dark"] .button-solid:hover,
html[data-theme="dark"] .button-solid:focus-visible {
    background: #2ea043;
    color: #ffffff;
}

html[data-theme="dark"] .button-solid:active {
    background: #238636;
}

html[data-theme="dark"] .button-ghost {
    background: transparent;
    border-color: transparent;
}

html[data-theme="dark"] .button-ghost:hover {
    background: #212830;
    color: #f0f6fc;
}

html[data-theme="dark"] .action-danger-outline {
    color: #ff7b72;
    border-color: #f8514966;
}

html[data-theme="dark"] .action-danger-outline:hover {
    background: #f851491a;
    color: #ffa198;
    border-color: #f85149;
}

html[data-theme="dark"] input,
html[data-theme="dark"] textarea,
html[data-theme="dark"] select,
html[data-theme="dark"] .input-inline {
    color: #f0f6fc;
    background: #0d1117;
    border-color: #3d444d;
    box-shadow: inset 0 1px 0 rgba(1, 4, 9, 0.24);
}

html[data-theme="dark"] input::placeholder,
html[data-theme="dark"] textarea::placeholder,
html[data-theme="dark"] .input-inline::placeholder {
    color: #656c76;
}

html[data-theme="dark"] input:focus,
html[data-theme="dark"] textarea:focus,
html[data-theme="dark"] select:focus,
html[data-theme="dark"] .input-inline:focus,
html[data-theme="dark"] .button:focus-visible {
    background: #0d1117;
    border-color: #4493f8;
    outline: 2px solid #4493f8;
    outline-offset: -2px;
    box-shadow: inset 0 0 0 1px #4493f8;
}

html[data-theme="dark"] .theme-toggle-group,
html[data-theme="dark"] .uid-field,
html[data-theme="dark"] .leader-override-group {
    background: #151b23;
    border-color: #3d444d;
    box-shadow: none;
}

html[data-theme="dark"] .auth-toast {
    color: #f0f6fc;
    background: #151b23;
    border-color: #3d444d;
    box-shadow: 0 8px 24px rgba(1, 4, 9, 0.6);
}

html[data-theme="dark"] .auth-rail-trigger {
    color: #f0f6fc;
    background: #0d1117;
    border-color: #3d444d;
    box-shadow: 0 1px 0 rgba(1, 4, 9, 0.35);
}

html[data-theme="dark"] .auth-rail-trigger:hover,
html[data-theme="dark"] .auth-rail-trigger:focus-visible {
    background: #151b23;
    border-color: #656c76;
}

html[data-theme="dark"] .auth-rail-popover {
    background: #0d1117;
    border-color: #3d444d;
    box-shadow: 0 8px 24px rgba(1, 4, 9, 0.6);
}

html[data-theme="dark"] .auth-rail-popover-head {
    border-bottom-color: #3d444d;
}

html[data-theme="dark"] .auth-rail-popover-head span {
    color: #9198a1;
}

html[data-theme="dark"] .auth-rail-popover-note strong {
    color: #f0f6fc;
}

html[data-theme="dark"] .auth-rail-user-button {
    border-color: #3d444d;
    background: #151b23;
    color: #f0f6fc;
}

html[data-theme="dark"] .auth-rail-user-button:hover:not(:disabled) {
    background: #212830;
}

html[data-theme="dark"] .auth-rail-user-button.is-current {
    background: rgba(47, 129, 247, 0.18);
    border-color: rgba(47, 129, 247, 0.38);
}

html[data-theme="dark"] .auth-rail-link {
    color: #f0f6fc;
    background: #151b23;
    border-color: #3d444d;
}

html[data-theme="dark"] .auth-rail-link:hover {
    background: #212830;
}

html[data-theme="dark"] .uid-field.is-set {
    background: #2ea04326;
    border-color: #2ea04366;
}

html[data-theme="dark"] .status-badge,
html[data-theme="dark"] .ag-status {
    color: #9198a1;
    background: #151b23;
    border-color: #3d444d;
}

html[data-theme="dark"] .status-badge.ok,
html[data-theme="dark"] .status-badge.connected,
html[data-theme="dark"] .status-badge.is-ok,
html[data-theme="dark"] .ag-status-running {
    color: #3fb950;
    background: #2ea04326;
    border-color: #2ea04366;
}

html[data-theme="dark"] .status-badge.err,
html[data-theme="dark"] .status-badge.is-err,
html[data-theme="dark"] .ag-status-error {
    color: #f85149;
    background: #f851491a;
    border-color: #f8514966;
}

html[data-theme="dark"] .status-badge.warn,
html[data-theme="dark"] .ag-status-paused {
    color: #d29922;
    background: #bb800926;
    border-color: #bb800966;
}

html[data-theme="dark"] .toggle-slider {
    background: #3d444d;
    border-color: #656c76;
}

html[data-theme="dark"] .toggle-slider::before {
    background: #f0f6fc;
    box-shadow: 0 1px 2px rgba(1, 4, 9, 0.45);
}

html[data-theme="dark"] .toggle-input:checked + .toggle-slider {
    background: #238636;
    border-color: #2ea043;
}

html[data-theme="dark"] .panel,
html[data-theme="dark"] .metric,
html[data-theme="dark"] .table-wrap,
html[data-theme="dark"] .data-table,
html[data-theme="dark"] .modal,
html[data-theme="dark"] .drawer,
html[data-theme="dark"] .drawer-card,
html[data-theme="dark"] .result-card,
html[data-theme="dark"] .result-advanced-code,
html[data-theme="dark"] .spc-result {
    background: #0d1117;
    border-color: #3d444d;
}

html[data-theme="dark"] .panel:hover,
html[data-theme="dark"] .metric:hover {
    border-color: #3d444d;
}

html[data-theme="dark"] .panel-head,
html[data-theme="dark"] .panel-message,
html[data-theme="dark"] .data-table th,
html[data-theme="dark"] .data-table thead th,
html[data-theme="dark"] .list-row,
html[data-theme="dark"] .segmented {
    background: #151b23;
    border-color: #3d444d;
}

html[data-theme="dark"] .data-table td {
    border-bottom-color: #3d444d;
}

html[data-theme="dark"] .data-table tbody tr:hover,
html[data-theme="dark"] .list-row:hover,
html[data-theme="dark"] .modal-close:hover,
html[data-theme="dark"] .drawer-close:hover {
    background: #151b23;
}

html[data-theme="dark"] .segment {
    color: #9198a1;
}

html[data-theme="dark"] .segment:hover,
html[data-theme="dark"] .segment.active {
    color: #f0f6fc;
    background: #212830;
}

html[data-theme="dark"] .modal-overlay {
    background: rgba(1, 4, 9, 0.72);
}

html[data-theme="dark"] .modal {
    box-shadow: 0 8px 24px rgba(1, 4, 9, 0.6);
}

html[data-theme="dark"] .drawer-head,
html[data-theme="dark"] .drawer-tabs {
    background: #010409;
    border-color: #3d444d;
}

html[data-theme="dark"] .drawer-tab {
    color: #9198a1;
}

html[data-theme="dark"] .drawer-tab:hover {
    color: #f0f6fc;
}

html[data-theme="dark"] .drawer-tab.active {
    color: #79c0ff;
    border-bottom-color: #4493f8;
}

html[data-theme="dark"] .spinner {
    border-color: #3d444d;
    border-top-color: #4493f8;
}

.login-shell {
    min-height: 100vh;
    margin: 0;
    background: var(--bg-0);
    color: var(--text);
    font-family: var(--font-sans);
}

.login-layout {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 32px 20px;
}

.login-card {
    width: min(100%, 480px);
    gap: 14px;
}

.login-card-head {
    align-items: center;
    margin-bottom: 0;
}

.login-card h1 {
    margin: 0;
    font-size: 1.2rem;
}

.login-brand {
    flex: 0 0 auto;
    width: 32px;
    height: 32px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    border: 1px solid var(--border);
    background: var(--bg-2);
    color: var(--text);
    font-family: var(--font-display);
    font-size: 16px;
    font-weight: 700;
    text-decoration: none;
}

.login-brand:hover {
    background: var(--bg-3);
    border-color: var(--border-strong);
    color: var(--text);
    text-decoration: none;
}

.login-copy,
.login-note {
    margin: 0;
    color: var(--text-muted);
    font-size: 13px;
    line-height: 1.55;
}

.login-form,
.users-form {
    display: grid;
    gap: 14px;
}

.users-form {
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    align-items: end;
}

.users-form > .button {
    justify-self: start;
}

.login-field,
.users-field {
    display: grid;
    gap: 6px;
}

.login-field span,
.users-field span {
    color: var(--text);
    font-size: 12px;
    font-weight: 600;
}

.login-field input,
.users-field input,
.users-field select {
    min-height: 32px;
    border-radius: 6px;
    border: 1px solid var(--border);
    background: var(--bg-0);
    color: var(--text);
    padding: 6px 10px;
    font: inherit;
    box-shadow: inset 0 1px 0 rgba(31, 35, 40, 0.04);
}

.login-field input:focus,
.users-field input:focus,
.users-field select:focus {
    background: var(--bg-0);
}

.login-submit {
    width: 100%;
    margin-top: 4px;
}

.login-error {
    margin: 0;
    padding: 10px 12px;
    color: var(--danger);
    background: var(--danger-lo);
    border: 1px solid color-mix(in srgb, var(--danger) 35%, var(--border) 65%);
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
}

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

html[data-theme="dark"] .login-brand {
    background: #151b23;
    border-color: #3d444d;
    color: #f0f6fc;
}

html[data-theme="dark"] .login-brand:hover {
    background: #212830;
    border-color: #656c76;
}

html[data-theme="dark"] .login-field input,
html[data-theme="dark"] .users-field input,
html[data-theme="dark"] .users-field select {
    background: #0d1117;
    border-color: #3d444d;
    box-shadow: inset 0 1px 0 rgba(1, 4, 9, 0.24);
}

@media (max-width: 640px) {
    .login-layout {
        padding: 16px;
    }

    .login-card {
        width: 100%;
    }

    .login-card-head {
        align-items: flex-start;
    }

    .users-form {
        grid-template-columns: 1fr;
    }

    .users-form > .button {
        width: 100%;
        justify-self: stretch;
    }
}
