:root {
    --bg: #0c0e14;
    --bg-elevated: #13161f;
    --surface: #1a1e28;
    --surface-hover: #222733;
    --border: #2c3344;
    --border-subtle: #232836;
    --text: #e8eaef;
    --text-secondary: #949bab;
    --text-tertiary: #6b7280;
    --accent: #5b8def;
    --accent-hover: #4a7de0;
    --accent-muted: rgba(91, 141, 239, 0.12);
    --success: #34c759;
    --success-bg: rgba(52, 199, 89, 0.12);
    --warning: #f5a623;
    --danger: #ff5c5c;
    --danger-bg: rgba(255, 92, 92, 0.1);
    --active: #7c9cff;
    --active-bg: rgba(124, 156, 255, 0.14);
    --standby: #34c759;
    --standby-bg: rgba(52, 199, 89, 0.12);
    --radius-sm: 6px;
    --radius: 10px;
    --radius-lg: 14px;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px rgba(0, 0, 0, 0.25);
    --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    --font-mono: "JetBrains Mono", "SF Mono", "Fira Code", ui-monospace, monospace;
}

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

* {
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent;
}

*::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

*::-webkit-scrollbar-track {
    background: transparent;
}

*::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 999px;
}

*::-webkit-scrollbar-thumb:hover {
    background: var(--text-tertiary);
}

*::-webkit-scrollbar-corner {
    background: transparent;
}

body {
    margin: 0;
    min-height: 100vh;
    font-family: var(--font);
    font-size: 14px;
    line-height: 1.5;
    color: var(--text);
    background: var(--bg);
    background-image:
        radial-gradient(ellipse 80% 50% at 50% -20%, rgba(91, 141, 239, 0.08), transparent),
        radial-gradient(ellipse 60% 40% at 100% 100%, rgba(52, 199, 89, 0.04), transparent);
}

/* Header */
.app-header {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    padding: 1.25rem 2rem 0.75rem;
    max-width: 1200px;
    margin: 0 auto;
    gap: 1rem;
}

.header-left {
    justify-self: start;
}

.header-right {
    justify-self: end;
}

.header-title {
    margin: 0;
    justify-self: center;
    font-size: 1.25rem;
    font-weight: 600;
    letter-spacing: -0.02em;
    text-align: center;
}

.brand-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    border-radius: var(--radius);
    background: linear-gradient(155deg, rgba(91, 141, 239, 0.24), rgba(91, 141, 239, 0.08));
    border: 1px solid rgba(91, 141, 239, 0.38);
    color: var(--accent);
    box-shadow:
        0 2px 8px rgba(91, 141, 239, 0.22),
        inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

.brand-icon svg {
    width: 24px;
    height: 24px;
}

.live-indicator {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.375rem 0.875rem;
    background: var(--surface);
    border: 1px solid var(--border-subtle);
    border-radius: 999px;
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.status-dot.online {
    background: var(--success);
    box-shadow: 0 0 0 3px rgba(52, 199, 89, 0.25);
    animation: pulse 2s ease-in-out infinite;
}

.status-dot.offline {
    background: var(--danger);
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* Tabs */
.tabs-nav {
    display: flex;
    justify-content: center;
    padding: 0 2rem 1.5rem;
    max-width: 1200px;
    margin: 0 auto;
}

.tabs-nav-inner {
    display: inline-flex;
    gap: 0.25rem;
    padding: 0.3125rem;
    background: var(--surface);
    border: 1px solid var(--border-subtle);
    border-radius: 999px;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.03);
}

.tab-btn {
    position: relative;
    padding: 0.5625rem 1.375rem;
    background: transparent;
    border: none;
    border-radius: 999px;
    color: var(--text-secondary);
    font-family: inherit;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: color 0.15s, background 0.15s, box-shadow 0.15s;
}

.tab-btn:hover {
    color: var(--text);
    background: rgba(255, 255, 255, 0.04);
}

.tab-btn.active {
    color: var(--text);
    background: var(--bg-elevated);
    box-shadow:
        0 1px 2px rgba(0, 0, 0, 0.25),
        inset 0 0 0 1px rgba(255, 255, 255, 0.06);
}

.tab-btn.active::after {
    display: none;
}

main {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 2rem 3rem;
}

.tab-content { display: none; }
.tab-content.active { display: block; }

/* Panels */
.panel {
    background: var(--bg-elevated);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    margin-bottom: 1.25rem;
    box-shadow: var(--shadow);
}

.panel-head { margin-bottom: 1.25rem; }

.panel-head h2 {
    margin: 0 0 0.25rem;
    font-size: 1rem;
    font-weight: 600;
    letter-spacing: -0.01em;
}

.panel-desc {
    margin: 0;
    font-size: 0.8125rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

.access-info {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
}

.access-info p {
    margin: 0;
    font-size: 0.8125rem;
    line-height: 1.55;
    color: var(--text-secondary);
}

.access-info strong {
    color: var(--text-primary);
    font-weight: 600;
}

.access-state {
    flex: none;
    padding: 0.125rem 0.5rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
}

.access-state--on {
    color: var(--success);
    background: var(--success-bg);
}

.access-state--off {
    color: var(--text-tertiary);
    background: var(--surface);
}

.panel-actions { margin-top: 1.5rem; }

#settings .panel + .panel { margin-top: 1.25rem; }

#diagnostics .panel + .panel { margin-top: 1.25rem; }

.settings-actions,
.diag-settings-actions {
    margin-top: 1.25rem;
    margin-bottom: 0.5rem;
}

/* Drive grid & cards */
.drive-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 1rem;
}

.drive-grid--status {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 1rem;
}

.drive-grid--status .drive-card--monitor {
    width: 100%;
    max-width: 260px;
    /* Ohne Untergrenze schrumpfen die Karten immer weiter, statt umzubrechen –
       dann bricht der Text in der Kennzahlenzeile Wort für Wort um. */
    min-width: 224px;
}

.drive-grid--status .empty-state {
    width: 100%;
}

.drive-card {
    background: var(--surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius);
    padding: 1.25rem;
    transition: border-color 0.15s, box-shadow 0.15s;
}

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

.drive-card--monitor {
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    align-items: center;
    text-align: center;
    gap: 0.625rem;
    min-height: 156px;
    padding: 1rem 1.125rem 0.875rem;
    border-width: 1px;
    border-style: solid;
}

.drive-card__header {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.375rem;
    width: 100%;
}

.drive-card__status-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 0.5rem 0.625rem;
    width: 100%;
}

.drive-card__smart-inline {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}

.drive-card__active-via {
    margin: 0;
    max-width: 100%;
    font-size: 0.6875rem;
    line-height: 1.35;
    opacity: 0.82;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.drive-card__active-via-label {
    opacity: 0.72;
    font-weight: 500;
}

.drive-card__smart {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    margin: 0.35rem 0 0.5rem;
}

.smart-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
    box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.15);
}

.smart-dot--ok { background: var(--success); }
.smart-dot--warn { background: var(--warning); }
.smart-dot--alarm { background: var(--danger); }
.smart-dot--unknown { background: var(--text-tertiary); }

.smart-temp {
    font-size: 0.8125rem;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.smart-temp--ok { color: inherit; opacity: 0.95; }
.smart-temp--warn { color: var(--warning); }
.smart-temp--alarm { color: var(--danger); }
.smart-temp--unknown { opacity: 0.55; }
.smart-temp--stale {
    opacity: 0.42;
    color: var(--text-tertiary);
    font-weight: 500;
}

.drive-card__temp-chart {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 0.2rem;
    width: 100%;
    margin: 0;
    padding: 0.3rem 0.35rem 0.2rem;
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: var(--radius-sm);
    background: rgba(0, 0, 0, 0.18);
    color: inherit;
    font: inherit;
    text-align: left;
}

.drive-card__temp-chart--empty {
    justify-content: center;
    min-height: 2.5rem;
    font-size: 0.6875rem;
    color: var(--text-tertiary);
    text-align: center;
    cursor: default;
    border-style: dashed;
}

.drive-card__temp-chart-label {
    font-size: 0.625rem;
    color: var(--text-secondary);
    text-align: center;
    font-variant-numeric: tabular-nums;
}

.temp-chart {
    display: block;
    width: 100%;
    height: auto;
}

.temp-chart__line {
    fill: none;
    stroke: #6b9fff;
    stroke-width: 1.5;
    stroke-linejoin: miter;
    stroke-linecap: butt;
    shape-rendering: geometricPrecision;
}

.drive-card__temp-chart .temp-chart__line {
    stroke-width: 1.25;
}

.temp-chart__line--idle {
    stroke: #8eb8ff;
    stroke-dasharray: 4 3;
    opacity: 0.82;
}

.temp-chart__line--standby {
    stroke-dasharray: 5 4;
    opacity: 0.72;
}

.temp-chart__standby-band {
    fill: rgba(255, 255, 255, 0.045);
}

.temp-chart__legend {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-top: 0.35rem;
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.temp-chart__legend-item {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}

.temp-chart__legend-swatch {
    width: 1.1rem;
    height: 0;
    border-top: 2px solid #6b9fff;
}

.temp-chart__legend-swatch--standby {
    border-top-style: dashed;
    opacity: 0.72;
}

.temp-chart__legend-swatch--band {
    width: 0.85rem;
    height: 0.65rem;
    border: none;
    background: rgba(255, 255, 255, 0.06);
    border-radius: 2px;
}

.temp-chart__guide {
    stroke-width: 1;
    stroke-dasharray: 3 3;
    opacity: 0.55;
}

.temp-chart__guide--warn { stroke: var(--warning); }
.temp-chart__guide--alarm { stroke: var(--danger); }

.temp-chart__ylabel {
    fill: var(--text-tertiary);
    font-size: 9px;
    font-family: var(--font-mono, ui-monospace, monospace);
    font-variant-numeric: tabular-nums;
}

.info-badge-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.25rem;
    height: 1.25rem;
    padding: 0;
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.2);
    color: inherit;
    font-size: 0.75rem;
    line-height: 1;
    cursor: pointer;
    opacity: 0.85;
    transition: opacity 0.15s, background 0.15s;
}

.info-badge-btn:hover {
    opacity: 1;
    background: rgba(0, 0, 0, 0.35);
}

.info-badge-btn--inline {
    margin-left: 0.35rem;
    vertical-align: middle;
}

.cell-log-duration {
    white-space: nowrap;
}

.info-popover {
    position: fixed;
    z-index: 1200;
    min-width: 180px;
    max-width: min(320px, calc(100vw - 16px));
    padding: 0.65rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-elevated);
    box-shadow: var(--shadow);
    font-size: 0.8125rem;
    line-height: 1.45;
}

.info-popover__title {
    font-weight: 600;
    margin-bottom: 0.35rem;
    color: var(--text);
}

.info-popover__line {
    color: var(--text-secondary);
}

.info-badge-btn--compact {
    width: 1.1rem;
    height: 1.1rem;
    font-size: 0.6875rem;
}

/* Die Systemplatte kennt keine Zustände – deshalb bewusst neutral gehalten
   und ohne Ampel, damit sie sich optisch von den überwachten Platten abhebt. */
.drive-card--system {
    background: linear-gradient(155deg, rgba(148, 155, 171, 0.16), rgba(148, 155, 171, 0.04));
    border-color: rgba(148, 155, 171, 0.3);
    color: var(--text);
}

.drive-card__model {
    margin: 0;
    max-width: 100%;
    font-size: 0.6875rem;
    line-height: 1.35;
    opacity: 0.6;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.state-badge.system {
    background: rgba(148, 155, 171, 0.16);
    color: var(--text-secondary);
}

.state-badge.system::before { background: var(--text-secondary); }

/* Nur-Lese-Betrieb (Zugriff von außen): alles ausblenden, was etwas auslöst.
   Die eigentliche Sperre sitzt im Server, das hier ist die Entsprechung in
   der Oberfläche. */
body.read-only .drive-card__actions,
/* Der Neustart bleibt auch von außen erreichbar — die Leiste darum ebenso. */
body.read-only #btn-status-scan,
body.read-only .info-badge-btn,
/* Von außen bleibt allein die Überwachung. Eine Leiste mit einem einzigen
   Reiter wäre nur noch Zierrat — vor allem in der eingerichteten App. */
body.read-only .tabs-nav {
    display: none !important;
}

.drive-card__usage {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    width: 100%;
    margin-top: 0.35rem;
}

.drive-card__usage-track {
    height: 4px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.14);
    overflow: hidden;
}

.drive-card__usage-track span {
    display: block;
    height: 100%;
    border-radius: inherit;
    background: currentColor;
    opacity: 0.6;
}

.drive-card__usage--warn .drive-card__usage-track span {
    background: var(--warning);
    opacity: 0.95;
}

.drive-card__usage--full .drive-card__usage-track span {
    background: var(--danger);
    opacity: 0.95;
}

.drive-card__usage-text {
    display: flex;
    justify-content: space-between;
    gap: 0.5rem;
    font-size: 0.6875rem;
    line-height: 1.3;
    opacity: 0.78;
    font-variant-numeric: tabular-nums;
}

.drive-card__footer {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    width: 100%;
    padding-top: 0.5rem;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
}

/* Kennzahlenzeile der Karte: „Seit 12 Min · Spindown in 4 Min". Beide Angaben
   teilen sich eine Zeile und dürfen nur als Ganzes umbrechen, nie Wort für
   Wort. */
.drive-card__meta {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    justify-content: center;
    column-gap: 0.85rem;
    row-gap: 0.15rem;
    width: 100%;
}

.drive-card__meta-cell {
    display: inline-flex;
    align-items: baseline;
    gap: 0.3rem;
    white-space: nowrap;
}

.drive-card__meta-label {
    font-size: 0.625rem;
    color: inherit;
    opacity: 0.6;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.drive-card__meta-value {
    font-size: 0.8125rem;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    color: inherit;
    opacity: 0.92;
}

.drive-card--monitor .drive-name {
    margin: 0;
    font-size: 1rem;
}

.drive-card--monitor .state-timer {
    margin: 0;
}

.drive-card--monitor.status-active {
    background: linear-gradient(155deg, rgba(124, 156, 255, 0.28), rgba(124, 156, 255, 0.08));
    border-color: rgba(124, 156, 255, 0.45);
    color: #dbe4ff;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

.drive-card--monitor.status-idle {
    background: linear-gradient(155deg, rgba(245, 166, 35, 0.26), rgba(245, 166, 35, 0.07));
    border-color: rgba(245, 166, 35, 0.42);
    color: #ffe8c2;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

.drive-card--monitor.status-standby {
    background: linear-gradient(155deg, rgba(52, 199, 89, 0.26), rgba(52, 199, 89, 0.07));
    border-color: rgba(52, 199, 89, 0.42);
    color: #d4f5de;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

.drive-card--monitor.status-fault {
    background: linear-gradient(155deg, rgba(255, 140, 66, 0.28), rgba(255, 92, 92, 0.08));
    border-color: rgba(255, 140, 66, 0.5);
    color: #ffe0cc;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

.drive-card--monitor.status-unknown {
    background: linear-gradient(155deg, rgba(107, 114, 128, 0.22), rgba(107, 114, 128, 0.06));
    border-color: rgba(107, 114, 128, 0.35);
    color: var(--text-secondary);
}

.drive-card--monitor .state-badge {
    align-self: center;
    background: rgba(0, 0, 0, 0.22);
    backdrop-filter: blur(4px);
}

.drive-led {
    position: absolute;
    top: 0.75rem;
    right: 0.75rem;
    width: 9px;
    height: 9px;
    border-radius: 50%;
    box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.25);
}

.drive-led--idle {
    background: #34c759;
    box-shadow:
        0 0 0 2px rgba(0, 0, 0, 0.25),
        0 0 6px rgba(52, 199, 89, 0.55);
}

.drive-led--active {
    background: #ff5c5c;
    box-shadow:
        0 0 0 2px rgba(0, 0, 0, 0.25),
        0 0 8px rgba(255, 92, 92, 0.75);
    animation: led-pulse 1.2s ease-in-out infinite;
}

.drive-led--fault {
    background: #ff8c42;
    box-shadow:
        0 0 0 2px rgba(0, 0, 0, 0.25),
        0 0 8px rgba(255, 140, 66, 0.75);
    animation: led-pulse 0.8s ease-in-out infinite;
}

@keyframes led-pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.55; transform: scale(0.92); }
}

.panel-head--center {
    text-align: center;
}

.panel-head--center .panel-desc {
    max-width: 42rem;
    margin-left: auto;
    margin-right: auto;
}

.panel-head--center .btn {
    margin-top: 0.875rem;
}

.live-status-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.625rem;
    margin-top: 0.875rem;
}

.cpu-idle-line {
    margin: 0.75rem auto 0;
    max-width: 42rem;
    font-size: 0.8125rem;
    color: var(--text-secondary);
    font-variant-numeric: tabular-nums;
}

.cpu-idle-line span {
    color: var(--text);
    font-weight: 500;
}

.sys-temps-block {
    white-space: nowrap;
    color: var(--text-secondary);
    font-weight: 400;
}

.sys-temps-block span {
    font-weight: 500;
}

.drive-card__actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.5rem;
    width: 100%;
    padding-top: 0.75rem;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
}

/* Management – config cards */
.config-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 1rem;
}

.config-grid--center {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
}

.config-grid--center .config-card {
    width: 100%;
    max-width: 380px;
}

.config-grid--center .empty-state {
    width: 100%;
}

.config-grid .empty-state {
    grid-column: 1 / -1;
}

.config-card {
    background: var(--surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius);
    padding: 1.25rem;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.config-card:hover {
    border-color: var(--border);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
}

.config-card__head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 1rem;
    padding-bottom: 0.875rem;
    border-bottom: 1px solid var(--border-subtle);
}

.config-card__title-wrap {
    display: flex;
    flex-direction: column;
    gap: 0.375rem;
    min-width: 0;
}

.config-card__title {
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
    letter-spacing: -0.01em;
    word-break: break-word;
}

.config-card__fields {
    display: flex;
    flex-direction: column;
    gap: 0.875rem;
}

.config-card__fields .field {
    margin: 0;
}

.config-card__meta {
    margin: 0.875rem 0 0;
    padding-top: 0.875rem;
    border-top: 1px solid var(--border-subtle);
    font-size: 0.75rem;
    color: var(--text-tertiary);
}

.file-preview-stack {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.drive-name {
    margin: 0 0 0.75rem;
    font-size: 0.9375rem;
    font-weight: 600;
    letter-spacing: -0.01em;
}

.media-badge {
    display: inline-flex;
    align-items: center;
    margin-left: 0.35rem;
    padding: 0.1rem 0.45rem;
    border-radius: 999px;
    font-size: 0.625rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    vertical-align: middle;
    text-transform: uppercase;
}

.media-badge--hdd {
    color: var(--text-secondary);
    background: color-mix(in srgb, var(--text-secondary) 12%, transparent);
}

.media-badge--ssd {
    color: #7dd3fc;
    background: color-mix(in srgb, #38bdf8 18%, transparent);
}

.drive-card__trim-meta {
    display: inline-block;
    margin-left: 0.25rem;
    font-size: 0.6875rem;
    color: var(--text-secondary);
    max-width: 11rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    vertical-align: middle;
}

.state-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.375rem 0.75rem;
    border-radius: 999px;
    font-size: 0.8125rem;
    font-weight: 500;
}

.state-badge::before {
    content: "";
    width: 6px;
    height: 6px;
    border-radius: 50%;
}

.state-badge.active {
    background: var(--active-bg);
    color: var(--active);
}
.state-badge.active::before { background: var(--active); }

.state-badge.standby {
    background: var(--standby-bg);
    color: var(--standby);
}
.state-badge.standby::before { background: var(--standby); }

.state-badge.idle {
    background: rgba(245, 166, 35, 0.12);
    color: var(--warning);
}
.state-badge.idle::before { background: var(--warning); }

.state-badge.unknown {
    background: rgba(107, 114, 128, 0.15);
    color: var(--text-secondary);
}
.state-badge.unknown::before { background: var(--text-tertiary); }

.state-badge.fault {
    background: rgba(255, 140, 66, 0.18);
    color: #ffb380;
}
.state-badge.fault::before { background: #ff8c42; }

.state-badge--compact {
    padding: 0.2rem 0.5rem;
    font-size: 0.75rem;
}

.diag-badge {
    display: inline-flex;
    align-items: center;
    padding: 0.2rem 0.5rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 500;
    white-space: nowrap;
}

.diag-badge--ok {
    background: rgba(52, 199, 89, 0.16);
    color: #9ae6b0;
}

.diag-badge--warn {
    background: rgba(245, 166, 35, 0.18);
    color: #ffd89a;
}

.diag-badge--alarm {
    background: rgba(255, 92, 92, 0.16);
    color: #ffb3b3;
}

.diag-badge--info {
    background: rgba(90, 156, 255, 0.16);
    color: #a8caff;
}

.diag-badge--neutral {
    background: rgba(148, 163, 184, 0.14);
    color: var(--text-secondary);
}

.cell-diag-detail {
    font-size: 0.8125rem;
    max-width: 28rem;
}

.cell-diag-detail__inner {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.diag-expand-hint {
    font-size: 0.6875rem;
    color: var(--text-tertiary);
}

.diag-row {
    cursor: pointer;
}

.diag-row:hover {
    background: rgba(148, 163, 184, 0.06);
}

.diag-row--expanded {
    background: rgba(90, 156, 255, 0.06);
}

.m-card--diag-click {
    cursor: pointer;
}

.m-card--diag-expanded {
    border-color: rgba(90, 156, 255, 0.35);
}

.diag-raw {
    margin: 0;
    padding: 0.5rem 0.625rem;
    border-radius: 0.375rem;
    background: rgba(0, 0, 0, 0.28);
    border: 1px solid rgba(148, 163, 184, 0.14);
    font-family: var(--font-mono, ui-monospace, monospace);
    font-size: 0.6875rem;
    line-height: 1.45;
    white-space: pre-wrap;
    word-break: break-word;
    color: var(--text-secondary);
}

.panel-head--diag-log {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.75rem 1rem;
}

.panel-head--diag-log .panel-head__text {
    flex: 1 1 16rem;
    min-width: 0;
}

.diag-log-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
    flex-shrink: 0;
}

.cell-diag-time {
    min-width: 11rem;
    white-space: nowrap;
    vertical-align: top;
}

.cell-diag-time__line,
.diag-time-block__line {
    display: block;
    font-family: inherit;
    font-size: inherit;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    color: var(--text-primary);
    line-height: 1.35;
}

.diag-time-block {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.35rem 0.5rem;
    margin-bottom: 0.5rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid rgba(148, 163, 184, 0.12);
}

.diag-time-block__meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
}

.m-card__head--diag {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    margin-bottom: 0.35rem;
}

.data-table--diag .th-diag-time {
    min-width: 11rem;
}

.data-table--diag .th-diag-status {
    min-width: 8rem;
}

.cell-diag-time__meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
    margin-top: 0.2rem;
}

.diag-session-badge {
    display: inline-block;
    padding: 0.05rem 0.35rem;
    border-radius: 999px;
    font-size: 0.6875rem;
    font-weight: 600;
    background: rgba(148, 163, 184, 0.16);
    color: var(--text-secondary);
}

.diag-session-badge--active {
    background: rgba(90, 156, 255, 0.18);
    color: #a8caff;
}

.data-table--diag .th-filter {
    min-width: 7rem;
}

.state-timer {
    margin-top: 0.625rem;
    font-size: 0.75rem;
    color: var(--text-tertiary);
}

/* Monitor data row (history + log) */
.monitor-data-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.25rem;
    align-items: start;
}

.monitor-data-panel {
    margin-bottom: 0;
}

.monitor-data-panel .panel-head {
    margin-bottom: 0.875rem;
}

.field-input--compact {
    padding: 0.375rem 0.625rem;
    font-size: 0.8125rem;
}

.data-table--history .th-filter {
    min-width: 7.5rem;
    vertical-align: middle;
}

.th-filter-head {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    white-space: nowrap;
}

.filter-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.625rem;
    height: 1.625rem;
    padding: 0;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-tertiary);
    cursor: pointer;
    transition: color 0.15s, background-color 0.15s, border-color 0.15s;
}

.filter-toggle:hover {
    color: var(--text-secondary);
    background: var(--surface-hover);
    border-color: var(--border-subtle);
}

.filter-toggle--active {
    color: var(--accent);
    background: var(--accent-muted);
    border-color: rgba(91, 141, 239, 0.25);
}

.filter-icon {
    width: 0.875rem;
    height: 0.875rem;
}

.filter-menu {
    position: fixed;
    z-index: 200;
    min-width: 8.5rem;
    padding: 0.375rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-elevated);
    box-shadow: var(--shadow);
}

.filter-option {
    display: block;
    width: 100%;
    padding: 0.4375rem 0.625rem;
    border: none;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-secondary);
    font: inherit;
    font-size: 0.8125rem;
    text-align: left;
    cursor: pointer;
    transition: background-color 0.12s, color 0.12s;
}

.filter-option:hover {
    background: var(--surface-hover);
    color: var(--text);
}

.filter-option--active {
    background: var(--accent-muted);
    color: var(--accent);
    font-weight: 500;
}

.th-filter-label {
    display: block;
    margin-bottom: 0.375rem;
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.th-filter-select {
    width: 100%;
    min-width: 0;
    padding: 0.3rem 1.5rem 0.3rem 0.5rem;
    font-size: 0.75rem;
    background-color: var(--bg-elevated);
}

/* Table */
.table-wrap {
    overflow: auto;
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius);
    max-height: 280px;
    scrollbar-color: var(--border) var(--surface);
}

.table-wrap::-webkit-scrollbar-track {
    background: var(--surface);
    margin: 4px 0;
}

.table-wrap--compact {
    max-height: 240px;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8125rem;
}

.data-table th,
.data-table td {
    padding: 0.625rem 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border-subtle);
}

.data-table th {
    position: sticky;
    top: 0;
    background: var(--surface);
    font-weight: 500;
    color: var(--text-secondary);
    font-size: 0.8125rem;
}

.data-table tbody tr:hover { background: var(--surface-hover); }
.data-table tbody tr:last-child td { border-bottom: none; }

.cell-mono {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    white-space: nowrap;
}

.cell-muted {
    color: var(--text-tertiary);
    font-size: 0.8125rem;
}

.empty-cell {
    text-align: center;
    color: var(--text-tertiary);
    padding: 0.875rem 1rem !important;
    font-size: 0.8125rem;
}

.metric-cell {
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.metric-cell.metric-ok {
    background: rgba(52, 199, 89, 0.14);
    color: #9ae6b0;
}

.metric-cell.metric-warn {
    background: rgba(245, 166, 35, 0.16);
    color: #ffd89a;
}

.metric-cell.metric-alarm {
    background: rgba(255, 92, 92, 0.16);
    color: #ffb3b3;
}

/* Toolbar & buttons */
.toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 0.625rem;
}

.toolbar--actions {
    justify-content: center;
    margin-bottom: 0;
}

.toolbar--actions + .notice-banner {
    margin-top: 1.25rem;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem 1.125rem;
    border-radius: 999px;
    font-family: inherit;
    font-size: 0.8125rem;
    font-weight: 500;
    cursor: pointer;
    border: 1px solid transparent;
    transition: background 0.15s, border-color 0.15s, color 0.15s, box-shadow 0.15s;
}

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

.btn-secondary {
    background: var(--surface);
    color: var(--text);
    border-color: var(--border);
}
.btn-secondary:hover { background: var(--surface-hover); }

.btn-outline {
    background: transparent;
    color: var(--accent);
    border-color: var(--accent);
}
.btn-outline:hover { background: var(--accent-muted); }

.btn-danger {
    background: transparent;
    color: var(--danger);
    border-color: var(--border);
    padding: 0.375rem 0.75rem;
    font-size: 0.75rem;
    flex-shrink: 0;
}
.btn-danger:hover {
    background: var(--danger-bg);
    border-color: var(--danger);
}

.btn-sm {
    padding: 0.375rem 0.875rem;
    font-size: 0.75rem;
}

.btn-xs {
    padding: 0.3rem 0.65rem;
    font-size: 0.6875rem;
}

.btn-ghost {
    background: rgba(0, 0, 0, 0.18);
    color: inherit;
    border-color: rgba(255, 255, 255, 0.14);
    backdrop-filter: blur(4px);
}

.btn-ghost:hover {
    background: rgba(0, 0, 0, 0.28);
    border-color: rgba(255, 255, 255, 0.22);
}

.drive-card--monitor.status-active .btn-ghost {
    border-color: rgba(124, 156, 255, 0.35);
}

.drive-card--monitor.status-idle .btn-ghost {
    border-color: rgba(245, 166, 35, 0.35);
}

.drive-card--monitor.status-standby .btn-ghost {
    border-color: rgba(52, 199, 89, 0.35);
}

.drive-card--monitor.status-fault .btn-ghost {
    border-color: rgba(255, 140, 66, 0.4);
}

.drive-card--monitor.status-unknown .btn-ghost {
    border-color: var(--border);
    color: var(--text-secondary);
}

/* Forms */
.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.25rem;
}

.field { display: block; }
.field-wide { grid-column: 1 / -1; }

.field-label {
    display: block;
    margin-bottom: 0.375rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text);
}

.settings-group-title {
    grid-column: 1 / -1;
    margin: 0.75rem 0 0;
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.settings-group-title:first-child {
    margin-top: 0;
}

.field-input {
    width: 100%;
    padding: 0.5rem 0.75rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-family: inherit;
    font-size: 0.875rem;
    transition: border-color 0.15s, box-shadow 0.15s;
    appearance: none;
    -webkit-appearance: none;
}

.field-input[type="number"] {
    -moz-appearance: textfield;
}

.field-input[type="number"]::-webkit-outer-spin-button,
.field-input[type="number"]::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

select.field-input {
    padding-right: 2rem;
    background-color: var(--surface);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12' fill='none'%3E%3Cpath d='M3 4.5L6 7.5L9 4.5' stroke='%23949bab' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    background-size: 12px;
    cursor: pointer;
}

select.field-input:focus {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12' fill='none'%3E%3Cpath d='M3 4.5L6 7.5L9 4.5' stroke='%235b8def' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}

select.field-input option {
    background: var(--bg-elevated);
    color: var(--text);
}

.field-input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-muted);
}

.field-hint {
    display: block;
    margin-top: 0.375rem;
    font-size: 0.75rem;
    color: var(--text-tertiary);
    line-height: 1.45;
}

.field-hint code {
    font-family: ui-monospace, "Cascadia Code", "Source Code Pro", monospace;
    font-size: 0.6875rem;
    padding: 0.05rem 0.3rem;
    background: var(--surface);
    border: 1px solid var(--border-subtle);
    border-radius: 3px;
}

.field-check {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    padding-top: 1.5rem;
    cursor: pointer;
    color: var(--text);
    font-size: 0.875rem;
}

.field-row {
    display: flex;
    gap: 0.625rem;
}

.field-row .field-input { flex: 1; }

.field-row .field-unit {
    flex: 0 0 7.5rem;
    padding-left: 0.625rem;
    padding-right: 1.75rem;
    text-align: left;
}

.field-input-suffix {
    display: flex;
    align-items: stretch;
    max-width: 100%;
}

.field-input-suffix .field-input {
    flex: 1;
    min-width: 0;
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
    border-right: none;
}

.field-input-suffix .field-input:focus {
    z-index: 1;
}

.field-input-suffix__unit {
    display: flex;
    align-items: center;
    flex-shrink: 0;
    padding: 0 0.75rem;
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--text-tertiary);
    background: var(--bg-elevated);
    border: 1px solid var(--border-subtle);
    border-left: none;
    border-radius: 0 var(--radius) var(--radius) 0;
    user-select: none;
}

.field-input-suffix:focus-within .field-input-suffix__unit {
    border-color: var(--accent);
}

/* Config card labels (legacy alias) */
.config-field {
    display: block;
    margin-top: 0.875rem;
}

.config-field:first-of-type { margin-top: 0; }

/* Toasts */
.toast-stack {
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 0.625rem;
    max-width: min(22rem, calc(100vw - 2rem));
    pointer-events: none;
}

.toast {
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
    font-size: 0.8125rem;
    font-weight: 500;
    line-height: 1.45;
    border: 1px solid transparent;
    box-shadow: var(--shadow);
    opacity: 0;
    transform: translateY(-0.5rem) scale(0.98);
    transition: opacity 0.28s ease, transform 0.28s ease;
    pointer-events: auto;
}

.toast-visible {
    opacity: 1;
    transform: translateY(0) scale(1);
}

.toast-success {
    background: var(--bg-elevated);
    color: var(--success);
    border-color: rgba(52, 199, 89, 0.35);
}

.toast-error {
    background: var(--bg-elevated);
    color: var(--danger);
    border-color: rgba(255, 92, 92, 0.35);
}

/* Notices */
.notice-banner {
    background: var(--accent-muted);
    border: 1px solid rgba(91, 141, 239, 0.25);
    border-radius: var(--radius);
    padding: 1rem 1.25rem;
    margin-bottom: 0;
}

.notice-banner h3 {
    margin: 0 0 0.375rem;
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--accent);
}

.notice-banner p {
    margin: 0 0 0.875rem;
    font-size: 0.8125rem;
    color: var(--text-secondary);
}

.notice-list { display: flex; flex-direction: column; gap: 0.625rem; }

.notice-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    padding: 0.875rem 1rem;
    background: var(--surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
}

.notice-meta {
    font-size: 0.75rem;
    color: var(--text-tertiary);
}

.tag-suggested {
    display: inline-block;
    align-self: flex-start;
    padding: 0.2rem 0.5rem;
    background: var(--accent-muted);
    color: var(--accent);
    border-radius: 999px;
    font-size: 0.6875rem;
    font-weight: 500;
}

.tag-add { color: var(--success); font-weight: 500; }
.tag-del { color: var(--danger); font-weight: 500; }

.empty-state {
    grid-column: 1 / -1;
    margin: 0;
    padding: 2rem;
    text-align: center;
    color: var(--text-tertiary);
    font-size: 0.875rem;
}

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

/* File diff preview */
.file-box {
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius);
    overflow: hidden;
    background: var(--surface);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.02);
}

.file-header {
    display: flex;
    background: var(--bg-elevated);
    border-bottom: 1px solid var(--border-subtle);
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.file-header-col {
    flex: 1;
    padding: 0.625rem 1rem;
}

.file-header-col + .file-header-col {
    border-left: 1px solid var(--border-subtle);
}

.file-header-label {
    display: block;
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-tertiary);
    margin-bottom: 0.125rem;
}

.split-box {
    display: flex;
    max-height: 220px;
    overflow: auto;
    scrollbar-color: var(--border) var(--surface);
}

.split-box::-webkit-scrollbar-track {
    background: var(--surface);
}

.split-left,
.split-right {
    flex: 1;
    padding: 0.875rem 1rem;
    overflow-x: auto;
    white-space: pre-wrap;
    font-family: var(--font-mono);
    font-size: 0.75rem;
    line-height: 1.6;
}

.split-left {
    border-right: 1px solid var(--border-subtle);
    background: rgba(0, 0, 0, 0.2);
    color: var(--text-tertiary);
}

.file-diff-add { color: var(--success); }
.file-diff-del {
    color: var(--danger);
    text-decoration: line-through;
    opacity: 0.85;
}

@media (max-width: 900px) {
    .monitor-data-row { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
    .app-header,
    .tabs-nav,
    main { padding-left: 1rem; padding-right: 1rem; }

    .toast-stack {
        top: 0.75rem;
        right: 0.75rem;
        left: 0.75rem;
        max-width: none;
    }

    .app-header {
        grid-template-columns: auto 1fr auto;
        padding-top: 1rem;
    }

    .header-title {
        font-size: 1.0625rem;
    }

    .brand-icon {
        width: 38px;
        height: 38px;
    }

    .brand-icon svg {
        width: 21px;
        height: 21px;
    }

    .config-grid {
        grid-template-columns: 1fr;
    }

    .tabs-nav-inner {
        display: flex;
        width: 100%;
    }

    .tab-btn {
        flex: 1;
        padding-left: 0.75rem;
        padding-right: 0.75rem;
        font-size: 0.8125rem;
    }

    .drive-grid--status .drive-card--monitor {
        max-width: none;
    }

    .split-box { flex-direction: column; }
    .split-left {
        border-right: none;
        border-bottom: 1px solid var(--border-subtle);
    }

    .notice-item { flex-direction: column; align-items: flex-start; }
}
