/* Valgard admin: dark by default, light on request; one accent, quiet surfaces, numbers in tabular figures. */
:root {
    --bg: #0b0d12;
    --bg-2: #10131a;
    --panel: #141821;
    --panel-2: #191e29;
    --line: #232a37;
    --line-2: #2d3546;
    --text: #e6e9f0;
    --muted: #8b93a7;
    --faint: #5d6579;
    --accent: #7c8cff;
    --accent-2: #a78bfa;
    --accent-soft: rgba(124, 140, 255, 0.14);
    --good: #3ecf8e;
    --good-soft: rgba(62, 207, 142, 0.14);
    --warn: #f5b84a;
    --warn-soft: rgba(245, 184, 74, 0.14);
    --bad: #ff6b7a;
    --bad-soft: rgba(255, 107, 122, 0.14);
    --info: #4cc3ff;
    --info-soft: rgba(76, 195, 255, 0.14);
    --shadow: 0 1px 0 rgba(255, 255, 255, 0.03) inset, 0 8px 30px rgba(0, 0, 0, 0.35);
    --radius: 14px;
    --radius-sm: 9px;
    --font: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    --mono: "JetBrains Mono", ui-monospace, "Cascadia Code", Consolas, monospace;
    color-scheme: dark;
}

:root[data-theme="light"] {
    --bg: #f5f6fa;
    --bg-2: #eef0f6;
    --panel: #ffffff;
    --panel-2: #f7f8fc;
    --line: #e4e7ef;
    --line-2: #d6dae5;
    --text: #151925;
    --muted: #5d6578;
    --faint: #8a91a3;
    --accent: #5865f2;
    --accent-2: #8b5cf6;
    --accent-soft: rgba(88, 101, 242, 0.1);
    --good: #12a36b;
    --good-soft: rgba(18, 163, 107, 0.1);
    --warn: #c98200;
    --warn-soft: rgba(201, 130, 0, 0.1);
    --bad: #e0384b;
    --bad-soft: rgba(224, 56, 75, 0.1);
    --info: #0b8bd1;
    --info-soft: rgba(11, 139, 209, 0.1);
    --shadow: 0 1px 2px rgba(20, 25, 40, 0.06), 0 8px 24px rgba(20, 25, 40, 0.06);
    color-scheme: light;
}

* { box-sizing: border-box; }

html, body { margin: 0; height: 100%; }

body {
    background: radial-gradient(1200px 600px at 80% -10%, rgba(124, 140, 255, 0.08), transparent 60%),
        radial-gradient(900px 500px at -10% 110%, rgba(167, 139, 250, 0.06), transparent 60%), var(--bg);
    color: var(--text);
    font: 14px/1.5 var(--font);
    -webkit-font-smoothing: antialiased;
    font-feature-settings: "tnum" 1, "cv11" 1;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
::selection { background: var(--accent-soft); }

/* ---------- layout ---------- */
.shell { display: grid; grid-template-columns: 248px 1fr; min-height: 100vh; }

.sidebar {
    position: sticky; top: 0; height: 100vh; padding: 20px 14px;
    background: linear-gradient(180deg, var(--bg-2), var(--bg));
    border-right: 1px solid var(--line);
    display: flex; flex-direction: column; gap: 4px;
}

.brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px 18px; }
.brand-mark {
    width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center;
    background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: white; font-weight: 800;
    box-shadow: 0 6px 20px rgba(124, 140, 255, 0.35);
}
.brand b { display: block; font-size: 15px; letter-spacing: 0.2px; }
.brand span { color: var(--muted); font-size: 12px; }

.nav a {
    display: flex; align-items: center; gap: 11px; padding: 9px 12px; border-radius: 10px;
    color: var(--muted); font-weight: 500; text-decoration: none; transition: background 0.15s, color 0.15s;
}
.nav a:hover { background: var(--panel); color: var(--text); }
.nav a.active { background: var(--accent-soft); color: var(--text); }
.nav a.active svg { color: var(--accent); }
.nav svg { width: 18px; height: 18px; flex: none; }
.nav .count {
    margin-left: auto; min-width: 22px; padding: 1px 7px; border-radius: 999px; text-align: center;
    background: var(--panel-2); color: var(--muted); font-size: 12px; font-weight: 600;
}
.nav .count.alert { background: var(--bad-soft); color: var(--bad); }

.sidebar-foot { margin-top: auto; padding: 12px; color: var(--faint); font-size: 12px; }

.main { min-width: 0; display: flex; flex-direction: column; }

.topbar {
    position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 14px;
    padding: 14px 28px; background: color-mix(in srgb, var(--bg) 82%, transparent);
    backdrop-filter: blur(12px); border-bottom: 1px solid var(--line);
}
.topbar h1 { margin: 0; font-size: 18px; font-weight: 650; letter-spacing: -0.2px; white-space: nowrap; }
.topbar .live { display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: 12px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--good); box-shadow: 0 0 0 3px var(--good-soft); }
.dot.off { background: var(--faint); box-shadow: none; }
.dot.bad { background: var(--bad); box-shadow: 0 0 0 3px var(--bad-soft); }
.spacer { flex: 1; }

.search { position: relative; }
.search input { width: 280px; padding-left: 34px; }
.search svg { position: absolute; left: 10px; top: 50%; translate: 0 -50%; width: 16px; color: var(--faint); }

.content { padding: 24px 28px 48px; display: flex; flex-direction: column; gap: 20px; }

/* ---------- controls ---------- */
input, select, textarea {
    background: var(--panel); border: 1px solid var(--line-2); border-radius: var(--radius-sm);
    padding: 8px 11px; outline: none; transition: border-color 0.15s, box-shadow 0.15s;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

.btn {
    display: inline-flex; align-items: center; gap: 7px; padding: 8px 14px; border-radius: var(--radius-sm);
    border: 1px solid var(--line-2); background: var(--panel); cursor: pointer; font-weight: 550;
    transition: background 0.15s, border-color 0.15s, transform 0.05s;
}
.btn:hover { background: var(--panel-2); border-color: var(--faint); }
.btn:active { transform: translateY(1px); }
.btn svg { width: 16px; height: 16px; }
.btn.primary { background: linear-gradient(135deg, var(--accent), var(--accent-2)); border-color: transparent; color: white; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 40%, var(--line-2)); }
.btn.danger:hover { background: var(--bad-soft); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.ghost:hover { background: var(--panel); color: var(--text); }
.btn.small { padding: 5px 10px; font-size: 13px; }
.icon-btn { padding: 7px; }

.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.toolbar label { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; }

label:has(> .switch) { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; cursor: pointer; }
.switch { position: relative; width: 36px; height: 20px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.switch span { position: absolute; inset: 0; border-radius: 999px; background: var(--line-2); transition: background 0.15s; cursor: pointer; }
.switch span::after {
    content: ""; position: absolute; left: 3px; top: 3px; width: 14px; height: 14px; border-radius: 50%;
    background: white; transition: translate 0.15s;
}
.switch input:checked + span { background: var(--accent); }
.switch input:checked + span::after { translate: 16px 0; }

.tabs { display: inline-flex; padding: 4px; gap: 2px; border-radius: 12px; background: var(--panel); border: 1px solid var(--line); }
.tabs button { border: 0; background: transparent; padding: 6px 14px; border-radius: 8px; color: var(--muted); cursor: pointer; font-weight: 550; }
.tabs button.active { background: var(--panel-2); color: var(--text); box-shadow: var(--shadow); }

/* ---------- cards ---------- */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-head { display: flex; align-items: center; gap: 10px; padding: 16px 18px 12px; }
.card-head h2 { margin: 0; font-size: 14px; font-weight: 650; }
.card-head .hint { color: var(--muted); font-size: 12px; }
.card-body { padding: 0 18px 18px; }
.card-body.flush { padding: 0; }

.grid { display: grid; gap: 20px; }
.grid.kpis { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
.grid.two { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
.grid.halves { grid-template-columns: repeat(2, minmax(0, 1fr)); }

.kpi { padding: 16px 18px; position: relative; overflow: hidden; }
.kpi .label { color: var(--muted); font-size: 12px; font-weight: 550; text-transform: uppercase; letter-spacing: 0.6px; }
.kpi .value { margin-top: 6px; font-size: 28px; font-weight: 700; letter-spacing: -0.5px; }
.kpi .sub { color: var(--faint); font-size: 12px; margin-top: 2px; }
.kpi::after {
    content: ""; position: absolute; right: -30px; top: -30px; width: 110px; height: 110px; border-radius: 50%;
    background: radial-gradient(circle, var(--glow, var(--accent-soft)), transparent 70%);
}
.kpi.good { --glow: var(--good-soft); }
.kpi.bad { --glow: var(--bad-soft); }
.kpi.warn { --glow: var(--warn-soft); }

/* ---------- tables ---------- */
.table-wrap { overflow: auto; max-height: calc(100vh - 230px); border-top: 1px solid var(--line); }
table { width: 100%; border-collapse: separate; border-spacing: 0; }
th {
    position: sticky; top: 0; z-index: 1; text-align: left; font-size: 12px; font-weight: 600; color: var(--muted);
    text-transform: uppercase; letter-spacing: 0.5px; padding: 10px 14px; background: var(--panel-2);
    border-bottom: 1px solid var(--line); white-space: nowrap;
}
td { padding: 9px 14px; border-bottom: 1px solid var(--line); vertical-align: top; }
tr:last-child td { border-bottom: 0; }
tbody tr { transition: background 0.1s; }
tbody tr:hover { background: color-mix(in srgb, var(--panel-2) 70%, transparent); }
tr.clickable { cursor: pointer; }
td.num, th.num { text-align: right; }
td.mono, .mono { font-family: var(--mono); font-size: 12.5px; }
td.wrap { white-space: normal; word-break: break-all; }
.empty { padding: 40px; text-align: center; color: var(--faint); }

.fields { font-family: var(--mono); font-size: 12px; color: var(--muted); max-width: 720px; white-space: pre-wrap; word-break: break-all; }
.fields b { color: var(--text); font-weight: 500; }

/* ---------- pills ---------- */
.pill {
    display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 999px; font-size: 12px;
    font-weight: 600; background: var(--panel-2); color: var(--muted); white-space: nowrap;
}
.pill.good { background: var(--good-soft); color: var(--good); }
.pill.bad { background: var(--bad-soft); color: var(--bad); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.info { background: var(--info-soft); color: var(--info); }
.pill.accent { background: var(--accent-soft); color: var(--accent); }

.who { display: flex; align-items: center; gap: 10px; }
.avatar {
    width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; font-weight: 700; font-size: 13px;
    color: #0b0d12; background: var(--c, var(--muted)); flex: none;
}
.who .name { font-weight: 600; }
.who .meta { color: var(--muted); font-size: 12px; }

/* ---------- lists ---------- */
.list { display: flex; flex-direction: column; }
.list-item { display: flex; align-items: center; gap: 12px; padding: 10px 18px; border-top: 1px solid var(--line); }
.list-item .grow { flex: 1; min-width: 0; }
.list-item .title { font-weight: 550; }
.list-item .sub { color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.time { color: var(--faint); font-size: 12px; white-space: nowrap; }

/* ---------- chart ---------- */
.chart { width: 100%; height: 220px; display: block; }
.chart .grid-line { stroke: var(--line); stroke-dasharray: 3 4; }
.chart .axis { fill: var(--faint); font-size: 11px; }
.legend { display: flex; gap: 16px; color: var(--muted); font-size: 12px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.bars { display: flex; align-items: flex-end; gap: 2px; height: 70px; }
.bars span { flex: 1; min-width: 2px; border-radius: 2px 2px 0 0; background: var(--accent); opacity: 0.75; }

.server-lines { margin: 0; font-family: var(--mono); font-size: 12px; color: var(--muted); white-space: pre-wrap; line-height: 1.7; }

/* ---------- console ---------- */
.terminal {
    background: #07090d; border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; height: 460px;
    overflow: auto; font-family: var(--mono); font-size: 13px; color: #cfd6e4;
}
:root[data-theme="light"] .terminal { background: #0f1218; }
.terminal .cmd { color: #9aa8ff; margin-top: 10px; }
.terminal .cmd::before { content: "› "; color: #6b76c9; }
.terminal .out { white-space: pre-wrap; }
.terminal .err { white-space: pre-wrap; color: #ff8a96; }
.prompt { display: flex; gap: 10px; }
.prompt input { flex: 1; font-family: var(--mono); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
    padding: 5px 11px; border-radius: 999px; border: 1px solid var(--line-2); background: var(--panel);
    font-family: var(--mono); font-size: 12px; cursor: pointer; color: var(--muted);
}
.chip:hover { color: var(--text); border-color: var(--accent); }

/* ---------- player ---------- */
.hero { padding: 22px; display: flex; gap: 20px; align-items: center; flex-wrap: wrap; }
.hero .big-avatar {
    width: 64px; height: 64px; border-radius: 18px; display: grid; place-items: center; font-size: 26px; font-weight: 800;
    color: white; background: linear-gradient(135deg, var(--accent), var(--accent-2));
}
.hero h2 { margin: 0; font-size: 22px; letter-spacing: -0.3px; }
.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px 22px; padding: 0 22px 22px; }
.fact .k { color: var(--faint); font-size: 12px; }
.fact .v { font-weight: 550; margin-top: 2px; word-break: break-all; }
.chars { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; padding: 0 18px 18px; }
.char { padding: 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--panel-2); }

/* ---------- login ---------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login .card { width: 100%; max-width: 380px; padding: 30px; }
.login h1 { margin: 16px 0 4px; font-size: 22px; }
.login p { margin: 0 0 22px; color: var(--muted); }
.login input { width: 100%; margin-bottom: 12px; padding: 11px 13px; }
.login .btn { width: 100%; justify-content: center; padding: 11px; }
.login .error { color: var(--bad); font-size: 13px; min-height: 20px; margin-top: 10px; }

/* ---------- modal & toast ---------- */
.backdrop {
    position: fixed; inset: 0; z-index: 50; background: rgba(5, 7, 12, 0.6); backdrop-filter: blur(4px);
    display: grid; place-items: center; padding: 20px; animation: fade 0.15s ease;
}
.modal { width: 100%; max-width: 440px; padding: 22px; animation: rise 0.18s ease; }
.modal h3 { margin: 0 0 6px; font-size: 17px; }
.modal p { margin: 0 0 16px; color: var(--muted); }
.modal .field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.modal .field span { color: var(--muted); font-size: 12px; font-weight: 550; }
.modal .actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }
.modal pre { margin: 0; padding: 10px 12px; border-radius: var(--radius-sm); background: var(--panel-2); font-family: var(--mono); font-size: 12px; white-space: pre-wrap; }

.toasts { position: fixed; right: 20px; bottom: 20px; z-index: 60; display: flex; flex-direction: column; gap: 10px; }
.toast {
    min-width: 260px; max-width: 420px; padding: 12px 14px; border-radius: 12px; background: var(--panel);
    border: 1px solid var(--line-2); box-shadow: var(--shadow); animation: rise 0.2s ease; white-space: pre-wrap;
}
.toast.bad { border-color: color-mix(in srgb, var(--bad) 50%, var(--line-2)); }
.toast.good { border-color: color-mix(in srgb, var(--good) 50%, var(--line-2)); }

@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } }

.skeleton { height: 14px; border-radius: 6px; background: linear-gradient(90deg, var(--panel-2), var(--line), var(--panel-2)); background-size: 200% 100%; animation: shimmer 1.2s infinite; }
@keyframes shimmer { to { background-position: -200% 0; } }

@media (max-width: 1100px) {
    .grid.two, .grid.halves { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 820px) {
    .shell { grid-template-columns: 1fr; }
    .sidebar { position: static; height: auto; flex-direction: row; flex-wrap: wrap; padding: 10px; }
    .brand { padding: 4px 8px; }
    .nav { display: flex; flex-wrap: wrap; gap: 4px; }
    .sidebar-foot { display: none; }
    .topbar { padding: 12px 16px; flex-wrap: wrap; }
    .search input { width: 100%; }
    .search { flex: 1 1 100%; order: 3; }
    .content { padding: 16px; }
}
