* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --bg: #0f0f0f;
    --surface: #1a1a1a;
    --surface-2: #222;
    --border: #2a2a2a;
    --text: #e0e0e0;
    --text-dim: #888;
    --accent: #3b82f6;
    --green: #22c55e;
    --yellow: #eab308;
    --red: #ef4444;
    --radius: 0.5rem;
}

body {
    font-family: system-ui, -apple-system, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
}

/* ── Layout ────────────────────────────────────── */

.layout {
    display: flex;
    min-height: 100vh;
}

/* ── Sidebar ───────────────────────────────────── */

nav#sidebar {
    width: 220px;
    background: var(--surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
}

.nav-brand {
    padding: 1.25rem 1rem 1rem;
    border-bottom: 1px solid var(--border);
}

.nav-brand h1 {
    font-size: 1.2rem;
    color: var(--accent);
    font-weight: 700;
    letter-spacing: -0.01em;
}

#nav-links {
    flex: 1;
    padding: 0.75rem 0.5rem;
    overflow-y: auto;
}

.nav-section {
    margin-bottom: 1rem;
}

.nav-section-title {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-dim);
    padding: 0.25rem 0.75rem 0.4rem;
    font-weight: 600;
}

#nav-links a, .nav-footer a {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.5rem 0.75rem;
    color: var(--text-dim);
    text-decoration: none;
    border-radius: var(--radius);
    font-size: 0.875rem;
    transition: background 0.15s, color 0.15s;
    cursor: pointer;
}

#nav-links a:hover, .nav-footer a:hover {
    background: var(--border);
    color: var(--text);
}

#nav-links a.active {
    background: var(--accent);
    color: #fff;
}

.nav-icon {
    font-size: 1.1rem;
    width: 1.5rem;
    text-align: center;
    flex-shrink: 0;
}

.nav-footer {
    padding: 0.5rem;
    border-top: 1px solid var(--border);
}

.nav-loading {
    color: var(--text-dim);
    padding: 1rem 0.75rem;
    font-size: 0.875rem;
}

/* ── Main content ──────────────────────────────── */

main {
    flex: 1;
    padding: 1.5rem 2rem;
    overflow-y: auto;
    min-width: 0;
}

/* ── Page title ────────────────────────────────── */

.page-header {
    margin-bottom: 1.5rem;
}

.page-header h2 {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 0.25rem;
}

.page-header .subtitle {
    color: var(--text-dim);
    font-size: 0.875rem;
}

/* ── Stat cards (overview grid) ────────────────── */

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
}

.stat-card .label {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-dim);
    margin-bottom: 0.5rem;
}

.stat-card .value {
    font-size: 1.75rem;
    font-weight: 700;
    line-height: 1;
}

.stat-card .detail {
    font-size: 0.8rem;
    color: var(--text-dim);
    margin-top: 0.35rem;
}

/* ── Card ──────────────────────────────────────── */

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
    margin-bottom: 1rem;
}

.card h3 {
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-dim);
    margin-bottom: 0.75rem;
}

/* ── Health table ──────────────────────────────── */

.health-table {
    width: 100%;
    border-collapse: collapse;
}

.health-table th {
    text-align: left;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-dim);
    padding: 0.5rem 0.75rem;
    border-bottom: 1px solid var(--border);
}

.health-table td {
    padding: 0.6rem 0.75rem;
    border-bottom: 1px solid var(--border);
    font-size: 0.875rem;
}

.health-table tr:last-child td {
    border-bottom: none;
}

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

/* ── Status badges ─────────────────────────────── */

.badge {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.15rem 0.6rem;
    border-radius: 1rem;
    font-size: 0.8rem;
    font-weight: 500;
}

.badge-healthy {
    background: rgba(34, 197, 94, 0.15);
    color: var(--green);
}

.badge-degraded {
    background: rgba(234, 179, 8, 0.15);
    color: var(--yellow);
}

.badge-unhealthy {
    background: rgba(239, 68, 68, 0.15);
    color: var(--red);
}

.badge-unknown {
    background: rgba(136, 136, 136, 0.15);
    color: var(--text-dim);
}

.badge-starting {
    background: rgba(59, 130, 246, 0.15);
    color: var(--accent);
}

/* ── System info ───────────────────────────────── */

.sys-info {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem 2rem;
    font-size: 0.875rem;
}

.sys-info dt {
    color: var(--text-dim);
}

.sys-info dd {
    font-family: ui-monospace, monospace;
    font-size: 0.8rem;
}

/* ── UI cards grid ─────────────────────────────── */

.ui-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 1rem;
}

.ui-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
    text-align: center;
    text-decoration: none;
    color: var(--text);
    transition: border-color 0.15s, background 0.15s;
    cursor: pointer;
    display: block;
}

.ui-card:hover {
    border-color: var(--accent);
    background: var(--surface-2);
}

.ui-card .icon {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
}

.ui-card .name {
    font-weight: 600;
    font-size: 0.95rem;
}

.ui-card .path {
    font-size: 0.75rem;
    color: var(--text-dim);
    margin-top: 0.25rem;
    font-family: ui-monospace, monospace;
}

/* ── Loading / Error ───────────────────────────── */

.loading {
    color: var(--text-dim);
    padding: 2rem 0;
    text-align: center;
}

.error {
    color: var(--red);
}

/* ── Responsive ────────────────────────────────── */

@media (max-width: 768px) {
    .layout {
        flex-direction: column;
    }

    nav#sidebar {
        width: 100%;
        height: auto;
        position: static;
        border-right: none;
        border-bottom: 1px solid var(--border);
    }

    #nav-links {
        display: flex;
        flex-wrap: wrap;
        gap: 0.25rem;
    }

    .nav-section {
        display: flex;
        flex-wrap: wrap;
        gap: 0.25rem;
        margin-bottom: 0.25rem;
    }

    .nav-section-title {
        width: 100%;
    }

    main {
        padding: 1rem;
    }

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

    .sys-info {
        grid-template-columns: 1fr;
    }
}
