:root {
    --bg: #f4f6fa;
    --panel: #ffffff;
    --border: #e4e9f2;
    --border-strong: #d3dae6;
    --text: #16202f;
    --muted: #6b7a90;
    --accent: #2563eb;
    --accent-soft: #eaf0ff;
    --ok: #0f9d58;
    --ok-soft: #e7f6ec;
    --warn: #b45309;
    --warn-soft: #fdf1de;
    --bad: #c32626;
    --bad-soft: #fdeaea;
    --info: #1d4ed8;
    --info-soft: #e9f0ff;
    --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", "PingFang SC", system-ui, sans-serif;
    font-size: 14px;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
}

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

/* ---------------- sidebar ---------------- */
.sidebar {
    width: 252px;
    flex: 0 0 252px;
    background: var(--panel);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 18px 16px 14px;
}

.brand-logo {
    width: 34px;
    height: 34px;
    border-radius: 10px;
    background: linear-gradient(135deg, #2563eb, #22b8cf);
    color: #fff;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 17px;
}

.brand-text { display: flex; flex-direction: column; line-height: 1.2; }
.brand-text strong { font-size: 14.5px; letter-spacing: .01em; }
.brand-text span { font-size: 11px; color: var(--muted); letter-spacing: .04em; }

.nav { padding: 4px 10px 10px; flex: 1; }

.nav-group {
    font-size: 10.5px;
    letter-spacing: .1em;
    text-transform: uppercase;
    color: #9aa7ba;
    margin: 14px 8px 6px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 8px 10px;
    border-radius: 9px;
    color: #45536b;
    font-size: 13px;
    cursor: pointer;
    border: 1px solid transparent;
    user-select: none;
}

.nav-item:hover { background: #f5f8fd; }
.nav-item.active {
    background: var(--accent-soft);
    border-color: #d8e3ff;
    color: var(--accent);
    font-weight: 600;
}

.nav-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #c3cddd;
    flex: 0 0 6px;
}
.nav-item.active .nav-dot { background: var(--accent); }

.side-foot {
    border-top: 1px solid var(--border);
    padding: 12px 16px 16px;
    display: flex;
    flex-direction: column;
    gap: 7px;
    font-size: 12px;
    color: var(--muted);
}
.side-foot-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.side-foot-row .mono { color: var(--text); }

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

.topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    background: rgba(244, 246, 250, .88);
    backdrop-filter: blur(8px);
    border-bottom: 1px solid var(--border);
    padding: 12px 22px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
}

.page-title { font-size: 16px; font-weight: 650; letter-spacing: .01em; }
.page-sub { font-size: 12px; color: var(--muted); margin-top: 1px; }

.top-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.view { padding: 18px 22px 8px; max-width: 1320px; width: 100%; }

.foot {
    padding: 12px 22px 22px;
    font-size: 11.5px;
    color: #93a0b3;
}

/* ---------------- atoms ---------------- */
.chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 28px;
    padding: 0 10px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #fbfcfe;
    font-family: var(--mono);
    font-size: 11.5px;
    color: #3c4a61;
    white-space: nowrap;
    max-width: 320px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.badge {
    display: inline-flex;
    align-items: center;
    height: 21px;
    padding: 0 8px;
    border-radius: 999px;
    font-size: 11.5px;
    font-weight: 600;
    background: #eef1f6;
    color: #5b6a80;
    white-space: nowrap;
}
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.bad { background: var(--bad-soft); color: var(--bad); }
.badge.info { background: var(--info-soft); color: var(--info); }

.mono { font-family: var(--mono); font-size: 12.5px; }
.small { font-size: 12px; }
.muted { color: var(--muted); }
.strong { font-weight: 600; }
.center { text-align: center; }
.nowrap { white-space: nowrap; }
.break { word-break: break-all; }
.spacer { flex: 1; }

.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.row.top { align-items: flex-start; }
.col { display: flex; flex-direction: column; gap: 8px; }

.card {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 16px 18px;
    box-shadow: 0 1px 2px rgba(16, 24, 40, .035);
    margin-bottom: 14px;
}

.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.card-title { font-size: 14px; font-weight: 650; letter-spacing: .01em; }
.card-desc { font-size: 12px; color: var(--muted); margin-top: 2px; max-width: 860px; }
.card-body > *:first-child { margin-top: 0; }
.card.compact { padding: 12px 14px; }

.grid { display: grid; gap: 14px; }
.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }

.kpi {
    background: #fbfcfe;
    border: 1px solid var(--border);
    border-radius: 11px;
    padding: 11px 13px;
    min-width: 0;
}
.kpi-label { font-size: 11px; color: var(--muted); letter-spacing: .04em; text-transform: uppercase; }
.kpi-value { font-size: 16px; font-weight: 650; margin-top: 3px; word-break: break-all; }
.kpi-sub { font-size: 11.5px; color: var(--muted); margin-top: 2px; word-break: break-all; }
.kpi.big .kpi-value { font-size: 24px; font-family: var(--mono); letter-spacing: -.01em; }

table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
th {
    text-align: left;
    font-size: 11px;
    font-weight: 600;
    color: #8794a8;
    text-transform: uppercase;
    letter-spacing: .05em;
    padding: 7px 10px;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}
td { padding: 7px 10px; border-bottom: 1px solid #f0f3f9; vertical-align: top; }
tbody tr:hover td { background: #fafbfe; }
tbody tr:last-child td { border-bottom: none; }

.btn {
    height: 34px;
    padding: 0 12px;
    border: 1px solid var(--border-strong);
    border-radius: 9px;
    background: #fff;
    color: #33415a;
    font-size: 12.5px;
    font-family: inherit;
    cursor: pointer;
    transition: background .12s, border-color .12s;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
}
.btn:hover { background: #f5f8fd; border-color: #c2cdde; }
.btn:active { background: #eef3fb; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: #1d4fd8; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: #f0f4fb; }
.btn.danger { color: var(--bad); border-color: #f0c9c9; }
.btn.danger:hover { background: #fdf3f3; }
.btn.sm { height: 28px; padding: 0 9px; font-size: 12px; }

.input, .select, textarea {
    height: 34px;
    padding: 0 10px;
    border: 1px solid var(--border-strong);
    border-radius: 9px;
    background: #fff;
    color: var(--text);
    font-size: 12.5px;
    font-family: inherit;
    outline: none;
    min-width: 0;
}
textarea { height: auto; padding: 8px 10px; font-family: var(--mono); font-size: 12px; resize: vertical; }
.input:focus, .select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(37, 99, 235, .1); }
.input.mono { font-family: var(--mono); }

.field { display: flex; flex-direction: column; gap: 5px; }
.field > label { font-size: 11.5px; color: var(--muted); }

.hint {
    background: #f7f9fd;
    border: 1px solid #e6ecf7;
    border-left: 3px solid var(--accent);
    border-radius: 8px;
    padding: 9px 12px;
    font-size: 12.5px;
    color: #46536b;
}
.hint.warn { background: var(--warn-soft); border-color: #f3e2c6; border-left-color: var(--warn); color: #7c4a08; }
.hint.bad { background: var(--bad-soft); border-color: #f4d4d4; border-left-color: var(--bad); color: #8f1f1f; }
.hint + .hint { margin-top: 8px; }

.code {
    background: #f6f8fc;
    border: 1px solid var(--border);
    border-radius: 9px;
    padding: 10px 12px;
    font-family: var(--mono);
    font-size: 12px;
    line-height: 1.6;
    color: #253247;
    overflow: auto;
    max-height: 340px;
    white-space: pre-wrap;
    word-break: break-all;
    margin: 0;
}

.hero {
    background: linear-gradient(135deg, #f3f7ff 0%, #f8fbff 55%, #f4fbfd 100%);
    border: 1px solid #dfe8f8;
    border-radius: 16px;
    padding: 18px;
    margin-bottom: 14px;
}
.hero-ip { font-family: var(--mono); font-size: 30px; font-weight: 650; letter-spacing: -.02em; line-height: 1.15; word-break: break-all; }

.divider { height: 1px; background: var(--border); margin: 14px 0; }

.spark { display: flex; align-items: flex-end; gap: 2px; height: 44px; margin-top: 8px; }
.spark-bar { width: 4px; border-radius: 2px 2px 0 0; background: #b9cdf5; min-height: 2px; }
.spark-bar.bad { background: #e9b4b4; }

.bars { display: flex; flex-direction: column; gap: 6px; }
.bar-row { display: grid; grid-template-columns: 66px 1fr 90px; gap: 8px; align-items: center; font-size: 12px; }
.bar-track { height: 9px; background: #eef2f9; border-radius: 5px; overflow: hidden; display: flex; }
.bar-fill { height: 100%; background: var(--accent); }
.bar-fill.bad { background: #dc7c7c; }

.pill-group { display: inline-flex; background: #f2f5fb; border-radius: 9px; padding: 3px; gap: 2px; }
.pill {
    border: none;
    background: transparent;
    border-radius: 7px;
    padding: 5px 10px;
    font-size: 12px;
    color: #5a6880;
    cursor: pointer;
    font-family: inherit;
}
.pill.active { background: #fff; color: var(--accent); font-weight: 600; box-shadow: 0 1px 2px rgba(16,24,40,.08); }

.toast {
    position: fixed;
    right: 20px;
    bottom: 20px;
    background: #16202f;
    color: #fff;
    border-radius: 10px;
    padding: 10px 14px;
    font-size: 12.5px;
    opacity: 0;
    transform: translateY(8px);
    transition: opacity .18s, transform .18s;
    pointer-events: none;
    z-index: 100;
    max-width: 420px;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast.bad { background: #8f1f1f; }
.toast.ok { background: #11603f; }

.log-scroll { max-height: 520px; overflow: auto; }
.check-ok { color: var(--ok); font-weight: 600; }
.check-fail { color: var(--bad); font-weight: 600; }
.check-warn { color: var(--warn); font-weight: 600; }

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

@media (max-width: 1180px) {
    .cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .cols-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 900px) {
    .app { flex-direction: column; }
    .sidebar { width: 100%; flex: none; height: auto; position: static; border-right: none; border-bottom: 1px solid var(--border); }
    .nav { display: flex; overflow-x: auto; gap: 6px; padding: 0 12px 10px; }
    .nav-group { display: none; }
    .nav-item { white-space: nowrap; }
    .side-foot { display: none; }
    .cols-2, .cols-3, .cols-4 { grid-template-columns: 1fr; }
    .view { padding: 14px; }
    .topbar { padding: 10px 14px; }
}
