:root {
    color-scheme: light;
    --bg: #f4f6f8;
    --panel: #ffffff;
    --panel-soft: #eef3f7;
    --ink: #17202a;
    --muted: #687684;
    --line: #dce3ea;
    --ok: #11845b;
    --warn: #b7791f;
    --bad: #c53030;
    --accent: #0f6f9f;
    --gold: #b7791f;
    --header: #ffffff;
    --shadow: 0 10px 28px rgba(23, 32, 42, 0.08);
}

:root[data-theme="dark"] {
    color-scheme: dark;
    --bg: #08110d;
    --panel: #0d1913;
    --panel-soft: #10251a;
    --ink: #e4f7dc;
    --muted: #8fb59d;
    --line: #1e3d2d;
    --ok: #36d17f;
    --warn: #e1b84d;
    --bad: #ff6b6b;
    --accent: #36d17f;
    --gold: #e1b84d;
    --header: #07100b;
    --shadow: 0 12px 36px rgba(0, 0, 0, 0.28);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

a {
    color: inherit;
}

.app-header {
    position: sticky;
    top: 0;
    z-index: 20;
    background: color-mix(in srgb, var(--header) 94%, transparent);
    border-bottom: 1px solid var(--line);
    backdrop-filter: blur(16px);
}

.header-inner {
    width: min(1120px, calc(100% - 32px));
    min-height: 62px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: 1fr auto auto;
    align-items: center;
    gap: 16px;
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
    text-decoration: none;
    font-weight: 800;
    font-size: 18px;
}

.brand-mark {
    width: 34px;
    height: 34px;
    display: inline-grid;
    place-items: center;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel-soft);
    color: var(--accent);
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 13px;
}

.main-nav {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel-soft);
}

.main-nav a,
.theme-toggle {
    min-height: 34px;
    border: 0;
    border-radius: 6px;
    color: var(--muted);
    background: transparent;
    font: inherit;
    font-size: 14px;
    font-weight: 700;
}

.main-nav a {
    display: inline-flex;
    align-items: center;
    padding: 0 12px;
    text-decoration: none;
}

.main-nav a.active {
    color: var(--ink);
    background: var(--panel);
    box-shadow: var(--shadow);
}

.theme-toggle {
    border: 1px solid var(--line);
    padding: 0 12px;
    cursor: pointer;
}

.theme-toggle:hover,
.main-nav a:hover {
    color: var(--ink);
}

.shell {
    width: min(1120px, calc(100% - 32px));
    margin: 0 auto;
    padding: 24px 0 42px;
}

.topbar {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 20px;
}

.topbar h1 {
    margin: 0;
    font-size: 30px;
    line-height: 1.15;
    font-weight: 800;
}

.topbar p {
    margin: 4px 0 0;
    color: var(--muted);
    font-size: 14px;
}

.timestamp {
    color: var(--muted);
    font-size: 14px;
    white-space: nowrap;
}

.notice {
    border: 1px solid var(--line);
    background: var(--panel);
    border-left: 4px solid var(--warn);
    border-radius: 8px;
    padding: 14px 16px;
    margin-bottom: 18px;
}

.summary-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
    margin-bottom: 20px;
}

.summary-card {
    min-height: 96px;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 15px;
}

.summary-card span {
    display: block;
    color: var(--muted);
    font-size: 13px;
    margin-bottom: 9px;
}

.summary-card strong {
    font-size: 28px;
    line-height: 1.1;
}

.terminal-card {
    background:
        linear-gradient(135deg, color-mix(in srgb, var(--ok) 18%, transparent), transparent 55%),
        var(--panel);
    color: var(--ink);
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.terminal-card strong {
    color: var(--ok);
    text-shadow: 0 0 18px color-mix(in srgb, var(--ok) 34%, transparent);
}

.area-section {
    margin-top: 18px;
}

.area-section:first-of-type {
    margin-top: 0;
}

.area-heading {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    margin: 0 0 10px;
}

.area-heading h2 {
    margin: 0;
    font-size: 19px;
    line-height: 1.25;
}

.area-heading span {
    color: var(--muted);
    font-size: 13px;
    white-space: nowrap;
}

.overview-list {
    display: grid;
    gap: 10px;
}

.overview-row {
    display: grid;
    grid-template-columns: minmax(220px, 1fr) minmax(380px, 1.25fr);
    gap: 16px;
    align-items: center;
    background: var(--panel);
    border: 1px solid var(--line);
    border-left: 4px solid var(--muted);
    border-radius: 8px;
    padding: 15px 16px;
}

.overview-row.is-ok {
    border-left-color: var(--ok);
}

.overview-row.is-bad {
    border-left-color: var(--bad);
}

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

.overview-main h3 {
    margin: 8px 0 4px;
    font-size: 20px;
    line-height: 1.2;
}

.overview-main > span {
    color: var(--muted);
    font-size: 13px;
}

.overview-metrics {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
}

.overview-metrics div {
    border-top: 1px solid var(--line);
    padding-top: 9px;
}

.overview-metrics span,
.metric span {
    display: block;
    color: var(--muted);
    font-size: 12px;
    margin-bottom: 3px;
}

.overview-metrics strong {
    display: block;
    font-size: 15px;
    line-height: 1.25;
    overflow-wrap: anywhere;
}

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

.device-card {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 16px;
}

.device-card header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 14px;
}

.device-card h3 {
    margin: 0 0 4px;
    font-size: 18px;
    line-height: 1.25;
}

.location {
    color: var(--muted);
    font-size: 13px;
}

.status {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    font-weight: 800;
    white-space: nowrap;
}

.dot {
    width: 10px;
    height: 10px;
    border-radius: 999px;
    background: var(--muted);
}

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

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

.metrics {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.metric {
    border-top: 1px solid var(--line);
    padding-top: 10px;
}

.metric strong {
    font-size: 16px;
    font-weight: 800;
}

.empty {
    color: var(--muted);
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 22px;
}

@media (max-width: 860px) {
    .summary-grid {
        grid-template-columns: 1fr 1fr;
    }

    .overview-row {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 640px) {
    .header-inner {
        width: min(100% - 20px, 1120px);
        grid-template-columns: 1fr auto;
        gap: 10px;
        padding: 10px 0;
    }

    .brand {
        font-size: 16px;
    }

    .main-nav {
        grid-column: 1 / -1;
        width: 100%;
    }

    .main-nav a {
        flex: 1;
        justify-content: center;
    }

    .shell {
        width: min(100% - 20px, 1120px);
        padding-top: 18px;
    }

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

    .summary-grid,
    .overview-metrics,
    .metrics {
        grid-template-columns: 1fr;
    }

    .summary-card {
        min-height: 78px;
    }

    .summary-card strong {
        font-size: 24px;
    }

    .area-heading {
        align-items: flex-start;
        flex-direction: column;
        gap: 2px;
    }
}

