:root {
    --bg: #f3f6f8;
    --card: #ffffff;
    --ink: #16222e;
    --muted: #5c6c79;
    --border: #e0e7ec;
    --accent: #0e7490;
    --accent-ink: #ffffff;
    --accent-soft: #e2f3f5;
    --good: #16895e;
    --good-soft: #e3f6ee;
    --warn: #b4740e;
    --warn-soft: #fbf0dd;
    --crit: #c23b34;
    --crit-soft: #fbe6e4;
    --shadow: 0 1px 3px rgba(20, 30, 40, 0.08), 0 1px 2px rgba(20, 30, 40, 0.06);
}

:root[data-theme="dark"] {
    --bg: #0f1720;
    --card: #17212c;
    --ink: #e7edf2;
    --muted: #93a4b2;
    --border: #28333e;
    --accent: #2bb6c4;
    --accent-ink: #06232a;
    --accent-soft: #163338;
    --good: #35c08a;
    --good-soft: #123224;
    --warn: #e0a63a;
    --warn-soft: #3a2c10;
    --crit: #e5695f;
    --crit-soft: #3a1613;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
    background: var(--bg);
    color: var(--ink);
    font-family: -apple-system, "Segoe UI", Roboto, "Inter", Arial, sans-serif;
    font-size: 15px;
    line-height: 1.5;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

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

.sidebar {
    width: 230px;
    flex-shrink: 0;
    background: var(--card);
    border-right: 1px solid var(--border);
    padding: 20px 14px;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
}
.sidebar .brand { font-weight: 700; font-size: 17px; margin-bottom: 20px; padding: 0 8px; display: flex; align-items: center; gap: 8px; }
.sidebar .brand .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--accent); }
.sidebar nav a {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 12px; border-radius: 8px; color: var(--ink);
    font-size: 14px; margin-bottom: 2px;
}
.sidebar nav a:hover { background: var(--bg); text-decoration: none; }
.sidebar nav a.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }

.main { flex: 1; min-width: 0; }
.topbar {
    display: flex; align-items: center; justify-content: space-between;
    padding: 14px 24px; border-bottom: 1px solid var(--border); background: var(--card);
}
.topbar h1 { font-size: 18px; margin: 0; }
.content { padding: 24px; max-width: 1200px; }

.theme-toggle {
    border: 1px solid var(--border); background: var(--bg); color: var(--ink);
    border-radius: 20px; padding: 6px 12px; font-size: 13px; cursor: pointer;
}

.card {
    background: var(--card); border: 1px solid var(--border); border-radius: 12px;
    padding: 18px; box-shadow: var(--shadow); margin-bottom: 18px;
}
.card h2, .card h3 { margin-top: 0; }

.grid { display: grid; gap: 16px; }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
@media (max-width: 800px) { .grid-3, .grid-2 { grid-template-columns: 1fr; } .sidebar { position: fixed; z-index: 50; transform: translateX(-100%); transition: transform .2s; }
    .sidebar.open { transform: translateX(0); } }

.stat-tile .label { color: var(--muted); font-size: 13px; margin-bottom: 4px; }
.stat-tile .value { font-size: 26px; font-weight: 700; }

.meter { height: 10px; border-radius: 6px; background: var(--bg); border: 1px solid var(--border); overflow: hidden; }
.meter > span { display: block; height: 100%; background: var(--accent); border-radius: 6px; }
.meter.warn > span { background: var(--warn); }
.meter.crit > span { background: var(--crit); }
.meter-caption { display: flex; justify-content: space-between; font-size: 13px; color: var(--muted); margin-top: 6px; }

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); }
th { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .03em; }
tr:last-child td { border-bottom: none; }

.badge { display: inline-flex; align-items: center; padding: 3px 10px; border-radius: 20px; font-size: 12px; font-weight: 600; }
.badge-good { background: var(--good-soft); color: var(--good); }
.badge-warn { background: var(--warn-soft); color: var(--warn); }
.badge-crit { background: var(--crit-soft); color: var(--crit); }
.badge-muted { background: var(--bg); color: var(--muted); }

.btn {
    display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--border);
    background: var(--card); color: var(--ink); padding: 9px 16px; border-radius: 8px;
    font-size: 14px; cursor: pointer; text-decoration: none;
}
.btn:hover { border-color: var(--accent); text-decoration: none; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { opacity: .92; }
.btn-danger { color: var(--crit); border-color: var(--crit-soft); }
.btn-danger:hover { background: var(--crit-soft); }
.btn-sm { padding: 5px 10px; font-size: 13px; }

form .field { margin-bottom: 14px; }
label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; font-weight: 600; }
input[type=text], input[type=password], input[type=number], input[type=email], select, textarea {
    width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px;
    background: var(--bg); color: var(--ink); font-size: 14px; font-family: inherit;
}
textarea { font-family: ui-monospace, monospace; font-size: 13px; }
.help { font-size: 12px; color: var(--muted); margin-top: 4px; }
.radio-row { display: flex; gap: 16px; }
.radio-row label { display: flex; align-items: center; gap: 6px; font-weight: 400; color: var(--ink); }

.alert { padding: 12px 14px; border-radius: 8px; margin-bottom: 16px; font-size: 14px; }
.alert-good { background: var(--good-soft); color: var(--good); }
.alert-crit { background: var(--crit-soft); color: var(--crit); }
.alert-warn { background: var(--warn-soft); color: var(--warn); }

.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; }
.login-box { width: 360px; }

.empty { color: var(--muted); text-align: center; padding: 30px 10px; }
.flex-between { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.mono { font-family: ui-monospace, monospace; font-size: 13px; }
