:root {
    color-scheme: dark;
    --bg: #0e1117;
    --surface: #161b24;
    --surface2: #1d2330;
    --border: #272e3d;
    --text: #e7eaf0;
    --muted: #8d96aa;
    --accent: #4ade80;
    --accent-ink: #062b14;
    --info: #60a5fa;
    --warn: #fbbf24;
    --bad: #f87171;
    --radius: 12px;
}

* { box-sizing: border-box; }
html { font-size: 16px; }
body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
a { color: var(--info); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.6rem; margin: 0 0 .25rem; }
h2 { font-size: 1.05rem; margin: 0 0 .75rem; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.sub { color: var(--muted); margin: 0 0 1.25rem; }
.hint { color: var(--muted); font-size: .88rem; margin: 1rem 0 0; }
.empty { color: var(--muted); padding: .5rem 0; }
.count { font-size: .8rem; color: var(--muted); background: var(--surface2); padding: .1rem .55rem; border-radius: 999px; vertical-align: middle; }

/* top bar */
.topbar {
    display: flex; align-items: center; gap: 1.25rem; flex-wrap: wrap;
    padding: .75rem 1.25rem; background: var(--surface); border-bottom: 1px solid var(--border);
    position: sticky; top: 0; z-index: 5;
}
.brand { font-weight: 700; color: var(--accent); letter-spacing: .02em; }
.topbar nav { display: flex; gap: .25rem; flex-wrap: wrap; flex: 1; }
.topbar nav a { color: var(--muted); padding: .4rem .7rem; border-radius: 8px; }
.topbar nav a:hover { color: var(--text); background: var(--surface2); text-decoration: none; }
.topbar nav a.active { color: var(--text); background: var(--surface2); }
.badge { background: var(--warn); color: #3b2a00; border-radius: 999px; font-size: .72rem; font-weight: 700; padding: .05rem .45rem; margin-left: .25rem; }
.logout { display: flex; align-items: center; gap: .75rem; margin: 0; }
.who { color: var(--muted); font-size: .85rem; }

.content { max-width: 1120px; margin: 0 auto; padding: 1.5rem 1.25rem 4rem; }
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 1.5rem; }

/* layout helpers */
.grid { display: grid; gap: 1rem; margin-bottom: 1rem; }
.grid.cards { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.grid.stats { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }

.card {
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 1.1rem 1.25rem; margin-bottom: 1rem;
}
.grid > .card { margin-bottom: 0; }
.card.auth { width: 100%; max-width: 400px; }
.card.auth.wide { max-width: 460px; }
.card.auth h1 { text-align: center; }
.card.auth .sub { text-align: center; }

.stat {
    display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 1rem 1.25rem; color: inherit;
}
.stat:hover { border-color: var(--accent); text-decoration: none; }
.stat .num { font-size: 2rem; font-weight: 700; line-height: 1.1; }
.stat .lbl { color: var(--muted); font-size: .85rem; }

/* server cards */
.server .head { display: flex; justify-content: space-between; align-items: center; margin-bottom: .75rem; }
.server .name { font-weight: 600; }
.pill { display: inline-block; padding: .1rem .6rem; border-radius: 999px; font-size: .78rem; font-weight: 600; background: var(--surface2); color: var(--muted); }
.pill.ok { background: rgba(74, 222, 128, .15); color: var(--accent); }
.pill.warn { background: rgba(251, 191, 36, .15); color: var(--warn); }
.pill.bad { background: rgba(248, 113, 113, .15); color: var(--bad); }
.metric { display: flex; justify-content: space-between; font-size: .88rem; padding: .2rem 0; }
.metric .k { color: var(--muted); }
.bar { height: 8px; background: var(--surface2); border-radius: 999px; overflow: hidden; margin: .15rem 0 .5rem; }
.bar .fill { height: 100%; background: var(--accent); width: 0; transition: width .4s; }
.bar .fill.warn { background: var(--warn); }
.bar .fill.crit { background: var(--bad); }

/* tables */
.table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.table th { text-align: left; color: var(--muted); font-weight: 600; font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; padding: .4rem .6rem; border-bottom: 1px solid var(--border); }
.table td { padding: .55rem .6rem; border-bottom: 1px solid var(--border); vertical-align: middle; word-break: break-word; }
.table tr:last-child td { border-bottom: 0; }
.actions-cell { white-space: nowrap; }
.card:has(.table) { overflow-x: auto; }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: .5rem; background: #4b5367; }
.dot.on { background: var(--accent); box-shadow: 0 0 6px var(--accent); }
.toolbar { margin-bottom: 1rem; }

/* chips / feed */
.chips { display: flex; flex-wrap: wrap; gap: .5rem; }
.chip { background: var(--surface2); border: 1px solid var(--border); border-radius: 999px; padding: .25rem .8rem; font-size: .88rem; }
.chip small { color: var(--muted); margin-left: .35rem; }
.feed { list-style: none; margin: 0; padding: 0; }
.feed li { padding: .4rem 0; border-bottom: 1px solid var(--border); font-size: .88rem; }
.feed li:last-child { border-bottom: 0; }
.feed .when { color: var(--muted); font-size: .78rem; display: block; }

/* forms & buttons */
label { display: block; font-size: .85rem; color: var(--muted); margin-bottom: .9rem; }
input[type=text], input[type=email], input[type=password], input[type=search], select {
    display: block; width: 100%; margin-top: .3rem; padding: .6rem .75rem; font: inherit; color: var(--text);
    background: var(--bg); border: 1px solid var(--border); border-radius: 8px;
}
input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: transparent; }
td select { margin-top: 0; min-width: 150px; }
.btn {
    display: inline-block; font: inherit; font-weight: 600; cursor: pointer; border: 0; border-radius: 8px;
    padding: .6rem 1rem; background: var(--accent); color: var(--accent-ink);
}
.btn:hover { filter: brightness(1.08); text-decoration: none; }
.btn:disabled { opacity: .5; cursor: default; }
.btn.small { padding: .3rem .7rem; font-size: .85rem; }
.btn.danger { background: transparent; color: var(--bad); border: 1px solid var(--bad); }
.btn.ghost { background: transparent; color: var(--muted); border: 1px solid var(--border); }
.card.auth form .btn, .card form .btn:only-child { width: 100%; }
.alert { padding: .65rem .9rem; border-radius: 8px; margin-bottom: 1rem; font-size: .9rem; }
.alert.err { background: rgba(248, 113, 113, .12); color: var(--bad); border: 1px solid rgba(248, 113, 113, .3); }
.alert.ok { background: rgba(74, 222, 128, .12); color: var(--accent); border: 1px solid rgba(74, 222, 128, .3); }
.kv { display: grid; grid-template-columns: auto 1fr; gap: .4rem 1rem; margin: 0; font-size: .92rem; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }

/* 2FA */
.qr { display: grid; place-items: center; margin: 1rem 0; }
.qr img, .qr canvas { background: #fff; padding: 10px; border-radius: 8px; }
.secret { display: inline-block; margin-top: .3rem; padding: .35rem .6rem; background: var(--bg); border: 1px solid var(--border); border-radius: 6px; letter-spacing: .08em; }
.codes { list-style: none; padding: 0; margin: 1rem 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: .5rem; }
.codes li { background: var(--bg); border: 1px solid var(--border); border-radius: 8px; padding: .5rem .75rem; text-align: center; font-size: 1.05rem; }

/* toast */
.toast {
    position: fixed; right: 1rem; bottom: 1rem; max-width: 360px; padding: .75rem 1rem; border-radius: 10px;
    background: var(--surface2); border: 1px solid var(--border); box-shadow: 0 8px 24px rgba(0, 0, 0, .4); z-index: 20;
}
.toast.ok { border-color: var(--accent); }
.toast.err { border-color: var(--bad); }

@media (max-width: 640px) {
    .topbar { gap: .6rem; }
    .who { display: none; }
    .content { padding: 1rem .75rem 3rem; }
}

/* phase 2/3 */
.muted { color: var(--muted); font-weight: 400; font-size: .85rem; }
.tabs { display: flex; gap: .5rem; }
.chart { display: block; width: 100%; height: 200px; }
.inline-form { display: flex; flex-wrap: wrap; gap: 1rem; align-items: flex-end; margin-bottom: 1rem; }
.inline-form label { margin-bottom: 0; min-width: 160px; }
h2.space { margin-top: 1.5rem; }
.danger-zone { margin-top: 1.5rem; padding: 1rem 1.25rem; border: 1px solid rgba(248, 113, 113, .4); border-radius: var(--radius); background: rgba(248, 113, 113, .05); }
.danger-zone .sub { margin-bottom: .75rem; }
.topbar nav a { font-size: .9rem; padding: .4rem .55rem; }
td small { color: var(--muted); }
