:root {
    --bg: #f3f5f9;
    --card: #ffffff;
    --text: #172033;
    --muted: #77809a;
    --line: #e4e8f0;
    --brand: #3b6ef6;
    --brand-dark: #2c56c9;
    --danger: #d64545;
    --warn: #d68b22;
    --ok: #1f9d63;
    --sidebar: #151c2e;
    --sidebar-muted: #93a0bd;
    --radius: 12px;
    --shadow: 0 8px 24px rgba(23, 32, 51, .06);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
    font-size: 14px;
}

button,
input,
select,
textarea {
    font: inherit;
}

.hidden {
    display: none !important;
}

/* ---------- 登录 ---------- */
.login-view {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: radial-gradient(circle at top left, #25355c 0, #101626 55%, #0b101b 100%);
    padding: 24px;
}

.login-card {
    width: 100%;
    max-width: 380px;
    background: rgba(255, 255, 255, .98);
    border-radius: 16px;
    padding: 32px;
    box-shadow: 0 24px 60px rgba(0, 0, 0, .35);
}

.login-card h1 {
    margin: 0 0 6px;
    font-size: 22px;
}

.login-card p {
    margin: 0 0 22px;
    color: var(--muted);
    font-size: 13px;
    line-height: 1.6;
}

.field {
    display: block;
    margin-bottom: 14px;
}

.field span {
    display: block;
    font-size: 12px;
    color: var(--muted);
    margin-bottom: 6px;
}

.field input,
.field select,
.field textarea {
    width: 100%;
    border: 1px solid var(--line);
    background: #fff;
    border-radius: 8px;
    padding: 10px 12px;
    outline: none;
    transition: border-color .15s, box-shadow .15s;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
    border-color: var(--brand);
    box-shadow: 0 0 0 3px rgba(59, 110, 246, .12);
}

.field textarea {
    min-height: 90px;
    resize: vertical;
    font-family: "SFMono-Regular", Consolas, monospace;
    font-size: 12px;
}

.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    border: 1px solid var(--line);
    background: #fff;
    color: var(--text);
    border-radius: 8px;
    padding: 9px 14px;
    cursor: pointer;
    transition: all .15s;
    white-space: nowrap;
}

.btn:hover {
    border-color: #c9d3e6;
    background: #f8faff;
}

.btn.primary {
    background: var(--brand);
    border-color: var(--brand);
    color: #fff;
}

.btn.primary:hover {
    background: var(--brand-dark);
}

.btn.danger {
    color: var(--danger);
    border-color: #f0c9c9;
}

.btn.danger:hover {
    background: #fff5f5;
}

.btn.small {
    padding: 5px 10px;
    font-size: 12px;
}

.btn.block {
    width: 100%;
    justify-content: center;
    padding: 11px;
}

/* ---------- 布局 ---------- */
.layout {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 224px;
    background: var(--sidebar);
    color: #fff;
    padding: 22px 14px;
    position: sticky;
    top: 0;
    height: 100vh;
    flex: 0 0 224px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 10px 22px;
    border-bottom: 1px solid rgba(255, 255, 255, .08);
    margin-bottom: 18px;
}

.brand-mark {
    width: 32px;
    height: 32px;
    border-radius: 9px;
    background: linear-gradient(135deg, #4d7dff, #7f5bff);
    display: grid;
    place-items: center;
    font-weight: 700;
    font-size: 15px;
}

.brand strong {
    display: block;
    font-size: 14px;
}

.brand small {
    color: var(--sidebar-muted);
    font-size: 11px;
}

.nav-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.nav-list button {
    width: 100%;
    text-align: left;
    border: 0;
    background: transparent;
    color: var(--sidebar-muted);
    padding: 10px 12px;
    border-radius: 8px;
    cursor: pointer;
    margin-bottom: 2px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.nav-list button:hover {
    color: #fff;
    background: rgba(255, 255, 255, .06);
}

.nav-list button.active {
    color: #fff;
    background: linear-gradient(90deg, rgba(77, 125, 255, .28), rgba(77, 125, 255, .08));
}

.sidebar-foot {
    position: absolute;
    bottom: 20px;
    left: 24px;
    right: 24px;
    color: var(--sidebar-muted);
    font-size: 11px;
    line-height: 1.7;
}

.main {
    flex: 1;
    min-width: 0;
    padding: 24px 28px 48px;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 22px;
}

.topbar h1 {
    margin: 0;
    font-size: 22px;
}

.topbar .sub {
    color: var(--muted);
    font-size: 12px;
    margin-top: 4px;
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 10px;
    border-radius: 999px;
    font-size: 12px;
    background: #eef1f7;
    color: #4b5673;
}

.pill.ok {
    background: #e7f7ef;
    color: var(--ok);
}

.pill.warn {
    background: #fdf3e2;
    color: var(--warn);
}

.pill.bad {
    background: #fdeaea;
    color: var(--danger);
}

.dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: currentColor;
}

/* ---------- 卡片/表格 ---------- */
.cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
    gap: 14px;
    margin-bottom: 18px;
}

.card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 18px;
}

.card .label {
    color: var(--muted);
    font-size: 12px;
    margin-bottom: 8px;
}

.card .value {
    font-size: 26px;
    font-weight: 700;
    letter-spacing: -.5px;
}

.card .hint {
    color: var(--muted);
    font-size: 11px;
    margin-top: 6px;
}

.panel {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 18px;
    overflow: hidden;
}

.panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 16px 18px;
    border-bottom: 1px solid var(--line);
}

.panel-head h2 {
    margin: 0;
    font-size: 15px;
}

.panel-body {
    padding: 18px;
}

.grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 18px;
}

.filters {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: flex-end;
    padding: 16px 18px;
    border-bottom: 1px solid var(--line);
}

.filters .field {
    margin: 0;
    min-width: 140px;
}

.filters .field.grow {
    flex: 1;
    min-width: 180px;
}

.table-wrap {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    min-width: 720px;
}

th,
td {
    text-align: left;
    padding: 11px 14px;
    border-bottom: 1px solid var(--line);
    vertical-align: top;
}

th {
    color: var(--muted);
    font-weight: 500;
    font-size: 12px;
    background: #fafbfe;
    white-space: nowrap;
}

tbody tr:hover {
    background: #f9fbff;
}

td.mono,
.mono {
    font-family: "SFMono-Regular", Consolas, monospace;
    font-size: 12px;
}

.muted {
    color: var(--muted);
}

.tag {
    display: inline-block;
    padding: 3px 8px;
    border-radius: 999px;
    font-size: 11px;
    background: #eef1f7;
    color: #4b5673;
    white-space: nowrap;
}

.tag.high {
    background: #fdeaea;
    color: var(--danger);
}

.tag.suspicious {
    background: #fdf3e2;
    color: var(--warn);
}

.tag.observe {
    background: #eaf0ff;
    color: var(--brand);
}

.tag.ok {
    background: #e7f7ef;
    color: var(--ok);
}

.tag.pending {
    background: #f1ecfe;
    color: #7a4de0;
}

.empty {
    padding: 36px 18px;
    color: var(--muted);
    text-align: center;
}

.pager {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 18px;
    color: var(--muted);
    font-size: 12px;
}

.pager-actions {
    display: flex;
    gap: 8px;
}

.bars {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.bar-row {
    display: grid;
    grid-template-columns: 170px 1fr 64px;
    gap: 10px;
    align-items: center;
    font-size: 12px;
}

.bar-track {
    height: 8px;
    background: #eef1f7;
    border-radius: 999px;
    overflow: hidden;
}

.bar-fill {
    height: 100%;
    background: linear-gradient(90deg, #4d7dff, #7f5bff);
    border-radius: 999px;
    min-width: 2px;
}

.bar-value {
    text-align: right;
    color: var(--muted);
}

.spark {
    display: flex;
    align-items: flex-end;
    gap: 3px;
    height: 120px;
    padding: 12px 4px 0;
    border-bottom: 1px solid var(--line);
}

.spark-bar {
    flex: 1;
    min-width: 3px;
    background: linear-gradient(180deg, #6b8cff, #c3d1ff);
    border-radius: 3px 3px 0 0;
    position: relative;
}

.spark-bar:hover {
    background: var(--brand);
}

.legend {
    display: flex;
    gap: 14px;
    color: var(--muted);
    font-size: 11px;
    padding: 8px 4px 0;
}

.legend span {
    display: inline-flex;
    gap: 5px;
    align-items: center;
}

.swatch {
    width: 9px;
    height: 9px;
    border-radius: 2px;
    background: #6b8cff;
}

/* ---------- 弹窗 ---------- */
.modal-mask {
    position: fixed;
    inset: 0;
    background: rgba(10, 15, 28, .55);
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 40px 16px;
    z-index: 50;
    overflow-y: auto;
}

.modal {
    width: 100%;
    max-width: 720px;
    background: #fff;
    border-radius: 14px;
    box-shadow: 0 30px 80px rgba(0, 0, 0, .3);
}

.modal-head {
    padding: 18px 20px;
    border-bottom: 1px solid var(--line);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modal-head h3 {
    margin: 0;
    font-size: 16px;
}

.modal-body {
    padding: 20px;
    max-height: 70vh;
    overflow-y: auto;
}

.modal-foot {
    padding: 14px 20px;
    border-top: 1px solid var(--line);
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    flex-wrap: wrap;
}

.kv {
    display: grid;
    grid-template-columns: 150px 1fr;
    gap: 8px 12px;
    margin-bottom: 14px;
    font-size: 13px;
}

.kv dt {
    color: var(--muted);
}

.kv dd {
    margin: 0;
    word-break: break-word;
}

pre {
    background: #0f172a;
    color: #d5def5;
    padding: 14px;
    border-radius: 10px;
    overflow: auto;
    font-size: 12px;
    max-height: 280px;
}

/* ---------- 提示 ---------- */
.toast {
    position: fixed;
    right: 22px;
    bottom: 22px;
    padding: 12px 16px;
    background: #172033;
    color: #fff;
    border-radius: 10px;
    box-shadow: 0 16px 40px rgba(0, 0, 0, .25);
    z-index: 100;
    max-width: 420px;
    font-size: 13px;
}

.toast.error {
    background: #b3261e;
}

.section-note {
    background: #f7f9fd;
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 12px 14px;
    color: var(--muted);
    font-size: 12px;
    line-height: 1.7;
    margin-bottom: 16px;
}

@media (max-width: 900px) {
    .layout {
        flex-direction: column;
    }

    .sidebar {
        width: 100%;
        height: auto;
        position: static;
        flex: none;
    }

    .nav-list {
        display: flex;
        flex-wrap: wrap;
        gap: 4px;
    }

    .nav-list button {
        width: auto;
    }

    .sidebar-foot {
        display: none;
    }

    .main {
        padding: 18px 14px 40px;
    }

    .grid-2 {
        grid-template-columns: 1fr;
    }

    .bar-row {
        grid-template-columns: 110px 1fr 52px;
    }
}

@media (max-width: 520px) {
    .topbar {
        align-items: flex-start;
        flex-direction: column;
    }
}
