:root {
    color-scheme: light;
    --ink-900: #0b0d13;
    --ink-800: #12151d;
    --ink-700: #1b1f2a;
    --ink-500: #5b6273;
    --ink-400: #7c8496;
    --ink-300: #a7adbb;
    --line: #e7e9f0;
    --line-soft: #f0f2f7;
    --surface: #ffffff;
    --canvas: #f6f7fb;
    --accent: #5b6cff;
    --accent-2: #a855f7;
    --accent-soft: #eef0ff;
    --ok: #12b76a;
    --ok-soft: #e7f8ef;
    --warn: #f79009;
    --warn-soft: #fef4e6;
    --danger: #f04438;
    --danger-soft: #feeceb;
    --radius: 14px;
    --radius-sm: 9px;
    --shadow-sm: 0 1px 2px rgba(16, 20, 32, .06);
    --shadow: 0 6px 24px -12px rgba(16, 20, 32, .22);
    --sidebar: 232px;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--canvas);
    color: var(--ink-900);
    font: 14px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
h1, h2, h3 { margin: 0; font-weight: 650; letter-spacing: -.01em; }

/* ---------- shell ---------- */

.shell { display: grid; grid-template-columns: var(--sidebar) 1fr; min-height: 100vh; }

.side {
    background: linear-gradient(180deg, var(--ink-900), var(--ink-800) 58%, #0e1119);
    color: #e8eaf2;
    padding: 22px 16px;
    position: sticky;
    top: 0;
    height: 100vh;
    display: flex;
    flex-direction: column;
    gap: 22px;
}

.brand { display: flex; align-items: center; gap: 11px; padding: 0 6px; }
.brand-mark {
    width: 36px; height: 36px; border-radius: 10px; flex: none;
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
    display: grid; place-items: center; font-weight: 800; font-size: 15px; color: #fff;
    box-shadow: 0 6px 18px -8px var(--accent);
}
.brand-text strong { display: block; font-size: 14.5px; letter-spacing: -.01em; }
.brand-text span { display: block; font-size: 11.5px; color: var(--ink-300); }

.nav { display: flex; flex-direction: column; gap: 3px; overflow-y: auto; }
.nav-group { font-size: 11px; text-transform: uppercase; letter-spacing: .09em; color: #5d6478; padding: 14px 10px 6px; }
.nav a {
    display: flex; align-items: center; gap: 10px;
    padding: 9px 11px; border-radius: 9px;
    color: #b9bfd0; font-weight: 500; font-size: 13.5px;
    transition: background .16s ease, color .16s ease;
}
.nav a:hover { background: rgba(255, 255, 255, .06); color: #fff; }
.nav a.on { background: rgba(91, 108, 255, .16); color: #fff; box-shadow: inset 2px 0 0 var(--accent); }
.nav a .ic { width: 16px; text-align: center; opacity: .85; font-size: 13px; }
.nav a .badge {
    margin-left: auto; background: var(--danger); color: #fff;
    font-size: 10.5px; font-weight: 700; padding: 1px 6px; border-radius: 20px;
}

.side-foot { margin-top: auto; font-size: 11.5px; color: #5d6478; padding: 0 8px; }

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

.top {
    background: rgba(255, 255, 255, .86);
    backdrop-filter: saturate(180%) blur(12px);
    border-bottom: 1px solid var(--line);
    padding: 14px 26px;
    display: flex; align-items: center; gap: 14px;
    position: sticky; top: 0; z-index: 20;
}
.top h1 { font-size: 17px; }
.top .sub { color: var(--ink-400); font-size: 12.5px; margin-top: 1px; }
.top-actions { margin-left: auto; display: flex; align-items: center; gap: 9px; }

.live {
    display: inline-flex; align-items: center; gap: 7px;
    background: var(--ok-soft); color: #067647;
    border: 1px solid #cdeedc; border-radius: 20px;
    padding: 5px 12px; font-size: 12.5px; font-weight: 600;
}
.live .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--ok); animation: pulse 1.8s ease-out infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(18, 183, 106, .5); } 70% { box-shadow: 0 0 0 7px rgba(18, 183, 106, 0); } 100% { box-shadow: 0 0 0 0 rgba(18, 183, 106, 0); } }

.content { padding: 22px 26px 60px; }

.pane { display: none; animation: rise .22s ease both; }
.pane.on { display: block; }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ---------- primitives ---------- */

.card {
    background: var(--surface); border: 1px solid var(--line);
    border-radius: var(--radius); box-shadow: var(--shadow-sm);
    padding: 18px;
}
.card > header { display: flex; align-items: baseline; gap: 10px; margin-bottom: 15px; }
.card > header h2 { font-size: 14.5px; }
.card > header .hint { color: var(--ink-400); font-size: 12px; }
.card > header .right { margin-left: auto; }

.grid { display: grid; gap: 14px; }
.g-kpi { grid-template-columns: repeat(auto-fit, minmax(178px, 1fr)); }
.g-2 { grid-template-columns: repeat(auto-fit, minmax(330px, 1fr)); }
.g-form { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); align-items: start; }
.g-3 { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.mt { margin-top: 14px; }

.kpi { position: relative; overflow: hidden; }
.kpi .label { color: var(--ink-500); font-size: 12.5px; display: flex; align-items: center; gap: 6px; }
.kpi .value { font-size: 27px; font-weight: 700; letter-spacing: -.02em; margin: 8px 0 3px; font-variant-numeric: tabular-nums; }
.kpi .foot { color: var(--ink-400); font-size: 12px; }
.kpi .spark { position: absolute; right: 0; bottom: 0; left: 0; height: 34px; opacity: .5; }
.kpi.accent .value { background: linear-gradient(120deg, var(--accent), var(--accent-2)); -webkit-background-clip: text; background-clip: text; color: transparent; }

.chip { display: inline-flex; align-items: center; gap: 5px; border-radius: 20px; padding: 2px 9px; font-size: 11.5px; font-weight: 650; }
.chip.ok { background: var(--ok-soft); color: #067647; }
.chip.warn { background: var(--warn-soft); color: #b54708; }
.chip.danger { background: var(--danger-soft); color: #b42318; }
.chip.info { background: var(--accent-soft); color: #3538cd; }
.chip.mute { background: var(--line-soft); color: var(--ink-500); }

label.field { display: block; margin-bottom: 13px; }
label.field > span { display: block; color: var(--ink-500); font-size: 12.5px; margin-bottom: 5px; }
label.field > span b { color: var(--danger); font-weight: 600; }

input, textarea, select {
    width: 100%; padding: 9px 11px;
    border: 1px solid #dcdfe8; border-radius: var(--radius-sm);
    background: #fff; color: var(--ink-900); font: inherit;
    transition: border-color .15s ease, box-shadow .15s ease;
}
input:focus, textarea:focus, select:focus {
    outline: 0; border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(91, 108, 255, .13);
}
textarea { min-height: 104px; resize: vertical; line-height: 1.6; }
textarea.tall { min-height: 230px; }
.row { display: flex; gap: 10px; }
.row > * { flex: 1; min-width: 0; }

.check { display: flex; align-items: center; gap: 8px; margin-bottom: 13px; font-size: 13px; color: var(--ink-700); }
.check input { width: auto; }

.btn {
    display: inline-flex; align-items: center; gap: 7px;
    border: 1px solid transparent; border-radius: var(--radius-sm);
    padding: 9px 16px; font: inherit; font-weight: 600; font-size: 13.5px;
    background: linear-gradient(135deg, var(--accent), #6d5bf6);
    color: #fff; cursor: pointer; transition: transform .12s ease, box-shadow .16s ease, opacity .16s;
    box-shadow: 0 6px 16px -10px var(--accent);
}
.btn:hover { transform: translateY(-1px); box-shadow: 0 10px 22px -12px var(--accent); }
.btn:active { transform: none; }
.btn.ghost { background: #fff; color: var(--ink-700); border-color: #dcdfe8; box-shadow: none; }
.btn.ghost:hover { border-color: #c3c8d6; background: #fcfcfe; }
.btn.sm { padding: 6px 11px; font-size: 12.5px; }
.btn.danger { background: linear-gradient(135deg, #f04438, #e04a3f); box-shadow: none; }

table { width: 100%; border-collapse: collapse; font-size: 13px; }
th {
    text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em;
    color: var(--ink-400); font-weight: 650; padding: 9px 11px; border-bottom: 1px solid var(--line);
    white-space: nowrap;
}
td { padding: 11px; border-bottom: 1px solid var(--line-soft); vertical-align: top; }
tbody tr:hover td { background: #fafbfe; }
tbody tr:last-child td { border-bottom: 0; }
.scroll { overflow-x: auto; margin: 0 -18px -18px; padding: 0 18px 4px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12px; }
.wrap-text { white-space: pre-wrap; word-break: break-word; min-width: 240px; max-width: 520px; }
.nowrap { white-space: nowrap; }
.muted { color: var(--ink-400); }
.empty { text-align: center; color: var(--ink-400); padding: 34px 12px; font-size: 13px; }

.notice {
    display: flex; align-items: center; gap: 9px;
    background: var(--ok-soft); border: 1px solid #cdeedc; color: #067647;
    border-radius: var(--radius-sm); padding: 11px 14px; margin-bottom: 16px; font-size: 13.5px; font-weight: 500;
}
.notice.err { background: var(--danger-soft); border-color: #fbd5d2; color: #b42318; }

.bar-list { display: flex; flex-direction: column; gap: 11px; }
.bar-item .top-line { display: flex; justify-content: space-between; font-size: 12.5px; margin-bottom: 5px; }
.bar-item .top-line .name { color: var(--ink-700); font-weight: 550; }
.bar-item .top-line .num { color: var(--ink-500); font-variant-numeric: tabular-nums; }
.bar-track { height: 7px; border-radius: 20px; background: var(--line-soft); overflow: hidden; }
.bar-fill { height: 100%; border-radius: 20px; background: linear-gradient(90deg, var(--accent), var(--accent-2)); }

.legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: 12px; color: var(--ink-500); }
.legend i { display: inline-block; width: 9px; height: 9px; border-radius: 3px; margin-right: 6px; }

/* ---------- login ---------- */

.login-wrap { min-height: 100vh; display: grid; place-items: center; background: radial-gradient(1100px 500px at 50% -10%, #e9ebff, var(--canvas)); padding: 24px; }
.login-card { width: min(92vw, 392px); background: #fff; border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow); padding: 30px; }
.login-card .brand { padding: 0 0 20px; color: var(--ink-900); }
.login-card .brand-text span { color: var(--ink-400); }

@media (max-width: 900px) {
    .shell { grid-template-columns: 1fr; }
    .side { position: static; height: auto; flex-direction: row; align-items: center; gap: 12px; overflow-x: auto; }
    .nav { flex-direction: row; }
    .nav-group, .side-foot { display: none; }
    .content, .top { padding-left: 16px; padding-right: 16px; }
}