/* ── Tokens ───────────────────────────────────────────────────────────────
   Neutral slate base + indigo accent. Semantic ramp: ok / warn / bad.
   Dark theme is a token swap only — no rule duplication below.            */
:root {
    --accent: #4F46E5;
    --accent-light: #EEF2FF;
    --accent-dark: #4338CA;
    --ok: #059669;
    --ok-light: #ECFDF5;
    --ok-dark: #047857;
    --warn: #D97706;
    --warn-light: #FFFBEB;
    --bad: #DC2626;
    --bad-light: #FEF2F2;

    --surface: #FFFFFF;
    --canvas: #F1F5F9;
    --sunken: #F8FAFC;
    --border: #E2E8F0;
    --text-1: #0F172A;
    --text-2: #475569;
    --text-3: #94A3B8;
    --shadow: 0 1px 3px rgba(15, 23, 42, .06), 0 1px 2px rgba(15, 23, 42, .04);
    --radius: 10px;
    --sidebar-w: 220px;
}

@media (prefers-color-scheme: dark) {
    :root {
        --accent: #818CF8;
        --accent-light: #1E1B4B;
        --accent-dark: #A5B4FC;
        --ok: #34D399;
        --ok-light: #022C22;
        --ok-dark: #6EE7B7;
        --warn: #FBBF24;
        --warn-light: #291B04;
        --bad: #F87171;
        --bad-light: #2C0B0B;

        --surface: #0F172A;
        --canvas: #020617;
        --sunken: #1E293B;
        --border: #1E293B;
        --text-1: #F1F5F9;
        --text-2: #94A3B8;
        --text-3: #64748B;
        --shadow: 0 1px 3px rgba(0, 0, 0, .5);
    }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
    margin: 0;
    font-family: 'Inter', -apple-system, system-ui, 'Segoe UI', sans-serif;
    font-size: 13px;
    color: var(--text-1);
    background: var(--canvas);
    -webkit-font-smoothing: antialiased;
}
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-3); }
a { text-decoration: none; color: inherit; }

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

/* ── Sidebar ───────────────────────────────────────────────────────────── */
.sidebar {
    width: var(--sidebar-w);
    flex: none;
    background: var(--surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
}
.side-logo {
    height: 64px;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 18px;
    border-bottom: 1px solid var(--border);
    font-weight: 700;
    font-size: .9rem;
    letter-spacing: -.2px;
}
.side-logo svg { width: 22px; height: 22px; color: var(--accent); flex: none; }
.side-nav { display: flex; flex-direction: column; padding: 12px 10px; gap: 2px; }
.side-nav a {
    font-size: 0.82rem;
    font-weight: 500;
    color: var(--text-2);
    padding: 9px 12px;
    border-radius: 7px;
    transition: background .15s, color .15s;
}
.side-nav a:hover { background: var(--sunken); color: var(--text-1); }
.side-nav a.active { background: var(--accent-light); color: var(--accent); font-weight: 600; }
.side-foot { margin-top: auto; padding: 16px 18px; font-size: 0.68rem; color: var(--text-3); border-top: 1px solid var(--border); text-transform: uppercase; letter-spacing: .5px; }

/* ── Main ──────────────────────────────────────────────────────────────── */
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
    display: flex; justify-content: space-between; align-items: center; gap: 12px;
    flex-wrap: wrap;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 12px clamp(14px, 3vw, 26px);
    position: sticky; top: 0; z-index: 20;
}
.pagetitle { display: flex; align-items: center; gap: 12px; min-width: 0; }
.pagetitle h1 { font-size: 1.15rem; font-weight: 700; margin: 0; line-height: 1.25; letter-spacing: -.3px; }
.crumbs { font-size: 0.72rem; color: var(--text-2); margin-top: 2px; }
.top-right { display: flex; align-items: center; gap: 10px 14px; flex-wrap: wrap; font-size: 0.75rem; color: var(--text-2); }
.live { display: inline-flex; align-items: center; gap: 6px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 0 3px var(--ok-light); flex: none; }
.dot.stale { background: var(--warn); box-shadow: 0 0 0 3px var(--warn-light); }
.user { color: var(--text-1); font-weight: 600; }
.signout { color: var(--text-2); font-weight: 600; border: 1px solid var(--border); border-radius: 7px; padding: 6px 13px; transition: .15s; }
.signout:hover { background: var(--bad); color: #fff; border-color: var(--bad); }

/* ── Grid + cards ──────────────────────────────────────────────────────── */
.grid {
    display: grid; gap: 14px;
    padding: clamp(14px, 2.4vw, 22px);
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    align-content: start;
    flex: 1;
}
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 18px;
}
.card.wide { grid-column: span 2; }
@media (max-width: 680px) { .card.wide { grid-column: span 1; } }

.card h2 { font-size: 0.7rem; text-transform: uppercase; letter-spacing: .5px; color: var(--text-2); margin: 0 0 14px; font-weight: 700; display: flex; align-items: baseline; gap: 8px; }
.card h2.mt { margin-top: 18px; }
.sub { text-transform: none; letter-spacing: 0; color: var(--text-3); font-weight: 400; font-size: 0.68rem; }

.bigstat { font-size: 2.7rem; font-weight: 700; line-height: 1; letter-spacing: -1.5px; font-variant-numeric: tabular-nums; }
.bigstat small { font-size: 1.1rem; color: var(--text-3); margin-left: 3px; font-weight: 500; }

.bar { height: 8px; background: var(--sunken); border-radius: 999px; overflow: hidden; margin: 13px 0; }
.bar .fill { height: 100%; width: 0%; background: var(--accent); border-radius: 999px; transition: width .6s cubic-bezier(.4,0,.2,1), background .3s; }
.bar .fill.warn { background: var(--warn); }
.bar .fill.bad { background: var(--bad); }

.cores { display: grid; grid-template-columns: repeat(auto-fill, minmax(46px, 1fr)); gap: 6px; margin-top: 8px; }
.core { background: var(--sunken); border-radius: 6px; padding: 6px 2px; text-align: center; font-size: 0.62rem; color: var(--text-3); }
.core b { display: block; color: var(--text-1); font-size: 0.72rem; font-weight: 700; font-variant-numeric: tabular-nums; }

.foot { color: var(--text-2); font-size: 0.75rem; margin-top: 9px; line-height: 1.55; }

.badges { display: flex; flex-wrap: wrap; gap: 8px; }
.badge { padding: 5px 11px; border-radius: 999px; font-size: 0.72rem; font-weight: 600; background: var(--sunken); color: var(--text-2); white-space: nowrap; }
.badge.up { color: var(--ok-dark); background: var(--ok-light); }
.badge.down { color: var(--bad); background: var(--bad-light); }

.db-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 380px) { .db-row { grid-template-columns: 1fr; } }
.db { background: var(--sunken); border-radius: 8px; padding: 13px; }
.db-name { font-weight: 700; margin-bottom: 6px; font-size: 0.9rem; }
.db-stat { font-size: 0.75rem; color: var(--text-2); line-height: 1.6; }
.db-stat b { color: var(--text-1); font-variant-numeric: tabular-nums; }
.tag { font-size: 0.6rem; padding: 2px 8px; border-radius: 999px; margin-left: 6px; vertical-align: middle; font-weight: 700; text-transform: uppercase; letter-spacing: .3px; }
.tag.up { background: var(--ok-light); color: var(--ok-dark); }
.tag.down { background: var(--bad-light); color: var(--bad); }

.drow { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.drow:last-child { margin-bottom: 0; }
.drow .lbl { width: 92px; font-size: 0.72rem; color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: none; }
.drow .bar { flex: 1; margin: 0; }
.drow .val { min-width: 92px; text-align: right; font-size: 0.72rem; color: var(--text-2); flex: none; font-variant-numeric: tabular-nums; }
@media (max-width: 460px) { .drow .val { min-width: 0; } .drow .lbl { width: 70px; } }

.tablewrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.proc { width: 100%; border-collapse: collapse; font-size: 0.8rem; min-width: 380px; }
table.proc th { text-align: left; background: var(--sunken); color: var(--text-2); font-weight: 700; padding: 7px 8px; font-size: 0.66rem; text-transform: uppercase; letter-spacing: .5px; }
table.proc th:first-child { border-radius: 6px 0 0 6px; }
table.proc th:last-child { border-radius: 0 6px 6px 0; }
table.proc td { padding: 8px; border-bottom: 1px solid var(--border); white-space: nowrap; font-variant-numeric: tabular-nums; }
table.proc tr:last-child td { border-bottom: none; }
table.proc td.name { font-weight: 600; font-variant-numeric: normal; }
table.proc td.muted { color: var(--text-3); }

/* Site status pills */
.pill { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 0.66rem; font-weight: 700; text-transform: uppercase; letter-spacing: .3px; background: var(--sunken); color: var(--text-2); }
.pill.online { background: var(--ok-light); color: var(--ok-dark); }
.pill.stopped, .pill.errored { background: var(--bad-light); color: var(--bad); }
.pill.cluster { background: var(--warn-light); color: var(--warn); }

.ctr { display: flex; justify-content: space-between; align-items: center; gap: 10px; background: var(--sunken); border-radius: 8px; padding: 11px 13px; margin-bottom: 8px; font-size: 0.8rem; }
.ctr:last-child { margin-bottom: 0; }
.ctr .cn { font-weight: 700; }
.ctr .cs { color: var(--text-2); font-size: 0.72rem; text-align: right; font-variant-numeric: tabular-nums; }

.empty { color: var(--text-3); font-size: 0.75rem; padding: 6px 0; }

.foot-bar { text-align: center; color: var(--text-3); font-size: 0.7rem; padding: 10px 16px 24px; }

@media (max-width: 860px) {
    .sidebar { display: none; }
}

/* ── Login ─────────────────────────────────────────────────────────────── */
.login-body {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 20px;
    background:
        radial-gradient(1200px 600px at 50% -20%, var(--accent-light), transparent 70%),
        var(--canvas);
}
.login-wrap { width: 100%; max-width: 380px; }
.login-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 14px;
    box-shadow: var(--shadow);
    padding: 32px 28px;
    display: flex;
    flex-direction: column;
}
.login-mark {
    width: 44px; height: 44px;
    border-radius: 11px;
    background: var(--accent-light);
    color: var(--accent);
    display: flex; align-items: center; justify-content: center;
    margin-bottom: 16px;
}
.login-mark svg { width: 22px; height: 22px; }
.login-card h1 { font-size: 1.3rem; margin: 0; letter-spacing: -.4px; }
.login-sub { color: var(--text-2); font-size: .8rem; margin: 5px 0 22px; }
.login-card label { font-size: .72rem; font-weight: 600; color: var(--text-2); margin-bottom: 6px; }
.login-card input {
    font-family: inherit;
    font-size: .88rem;
    color: var(--text-1);
    background: var(--sunken);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 10px 12px;
    margin-bottom: 16px;
    transition: border-color .15s, box-shadow .15s;
}
.login-card input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-light);
}
.login-card button {
    font-family: inherit;
    font-size: .85rem;
    font-weight: 600;
    color: #fff;
    background: var(--accent);
    border: none;
    border-radius: 8px;
    padding: 11px;
    cursor: pointer;
    transition: background .15s;
}
.login-card button:hover:not(:disabled) { background: var(--accent-dark); }
.login-card button:disabled { opacity: .6; cursor: default; }
.login-error {
    margin-top: 14px;
    background: var(--bad-light);
    color: var(--bad);
    font-size: .76rem;
    font-weight: 500;
    border-radius: 7px;
    padding: 9px 11px;
}
.login-foot { text-align: center; color: var(--text-3); font-size: .68rem; margin-top: 18px; }
