:root {
  --bg: #f6f7fb; --surface: #fff; --line: #e6e8f0; --text: #1d2030; --muted: #7b8194;
  --brand: #5b5bd6; --brand2: #7c6cf0; --ok: #12a37a; --warn: #d98310; --danger: #d64545; --nav: #1b1e2b;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font-size: 14px; line-height: 1.55; }
h1, h2, h3, h4 { margin: 0 0 8px; font-weight: 600; }
h2 { font-size: 19px; }
.hidden { display: none !important; }
.center { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.row { display: flex; align-items: center; gap: 10px; }
.row.wrap { flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pos { color: var(--ok); }
.neg { color: var(--danger); }
.mono { font-family: ui-monospace, "Cascadia Code", Consolas, monospace; font-size: 12px; }

.layout { display: flex; min-height: 100vh; }
.sidebar {
  width: 210px; flex: none; background: var(--nav); color: #cfd3e3;
  display: flex; flex-direction: column; padding: 18px 12px; gap: 16px;
  position: sticky; top: 0; height: 100vh;
}
.brand, .gate-brand { font-size: 19px; font-weight: 700; color: #fff; }
.brand span, .gate-brand span { display: block; font-size: 11px; font-weight: 400; color: #8b90a6; letter-spacing: 1.5px; }
.sidebar nav { display: flex; flex-direction: column; gap: 4px; overflow-y: auto; }
.navitem { text-align: left; background: transparent; border: 0; color: #b9bed3; padding: 9px 12px; border-radius: 8px; cursor: pointer; font-size: 14px; }
.navitem:hover { background: #262a3b; color: #fff; }
.navitem.active { background: var(--brand); color: #fff; }
.who { margin-top: auto; display: flex; flex-direction: column; gap: 8px; border-top: 1px solid #2c3145; padding-top: 14px; }
.main { flex: 1; min-width: 0; padding: 22px 26px 70px; }
.page { display: flex; flex-direction: column; gap: 12px; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; }
.gate { width: 360px; display: flex; flex-direction: column; gap: 12px; }
.gate-hint { border-top: 1px dashed var(--line); padding-top: 10px; line-height: 1.7; }
.section-title { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 600; color: #4b5066; margin-top: 8px; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 2px; }
.dot.blue { background: #6b6bf0; }
.dot.green { background: #2fc08c; }

.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(158px, 1fr)); gap: 12px; }
.stat { display: flex; flex-direction: column; gap: 3px; }
.statvalue { font-size: 21px; font-weight: 700; letter-spacing: -.02em; }
.stat.ok .statvalue { color: var(--ok); }
.stat.warn .statvalue { color: var(--warn); }
.stat.bad .statvalue { color: var(--danger); }

label { display: flex; flex-direction: column; gap: 6px; font-size: 12px; color: var(--muted); }
input, select, textarea {
  font: inherit; color: var(--text); background: #fff; border: 1px solid var(--line);
  border-radius: 8px; padding: 8px 10px; outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--brand); }
.tiny-select { padding: 6px 9px; font-size: 13px; }
.btn { font: inherit; border: 1px solid var(--line); background: #fff; color: var(--text); border-radius: 8px; padding: 8px 14px; cursor: pointer; white-space: nowrap; }
.btn:hover { border-color: #c9cde0; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.ok { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.ghost { background: transparent; border-color: #3a4056; color: #cfd3e3; }
.btn.small { padding: 5px 10px; font-size: 12px; }
.tab-btn { border: 1px solid var(--line); background: #fff; border-radius: 99px; padding: 5px 12px; font-size: 12px; cursor: pointer; color: var(--muted); }
.tab-btn.on { background: #eceafc; border-color: #c9c4f5; color: var(--brand); font-weight: 600; }

.tablewrap { overflow-x: auto; padding: 0; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 9px 12px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: middle; white-space: nowrap; }
th { font-size: 12px; color: var(--muted); font-weight: 500; background: #fafbff; }
tbody tr:hover { background: #fafbff; }
tbody tr.banned { background: #fff7f7; }
tr:last-child td { border-bottom: 0; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.chip { font-size: 11px; padding: 2px 8px; border-radius: 999px; background: #eef0f8; color: var(--muted); white-space: nowrap; }
.chip.ok { background: #e4f7f0; color: var(--ok); }
.chip.warn { background: #fdf1de; color: var(--warn); }
.chip.danger { background: #fde9e9; color: var(--danger); }
.chip.gold { background: #fdf5dd; color: #a97c06; }

.chartwrap { margin-top: 10px; }
.trend { width: 100%; height: auto; display: block; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; margin-top: 6px; }
.warnbox { display: flex; flex-direction: column; gap: 6px; }
.warnbox:empty { display: none; }
.warnline { background: #fff8ec; border-left: 4px solid var(--warn); border-radius: 0 8px 8px 0; padding: 9px 12px; font-size: 12.5px; color: #8a5d12; }

.param-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; }
.param-grid label.inline { flex-direction: row; align-items: center; gap: 8px; color: var(--text); }
.param-grid input[type=checkbox] { width: 16px; height: 16px; }

.modal { position: fixed; inset: 0; background: rgba(20, 22, 34, .45); display: flex; align-items: center; justify-content: center; padding: 20px; z-index: 50; }
.modalbody { background: #fff; border-radius: 14px; padding: 18px; width: 440px; max-width: 100%; max-height: 90vh; overflow: auto; display: flex; flex-direction: column; gap: 12px; }
.modalbody.wide { width: 760px; }
.kv { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 6px 16px; }
.kvrow { padding: 6px 0; border-bottom: 1px dashed var(--line); }
.kvrow b { display: block; font-size: 12px; color: var(--muted); font-weight: 500; }
.toast { position: fixed; right: 22px; bottom: 22px; background: #1d2030; color: #fff; padding: 11px 16px; border-radius: 10px; font-size: 13px; z-index: 80; box-shadow: 0 10px 30px rgba(0,0,0,.2); }
.error { color: var(--danger); font-size: 13px; }
.box { background: #fdecec; border: 1px solid #f6cfcf; border-radius: 10px; padding: 10px 12px; }
pre.code { background: #161a2c; color: #dfe6fa; padding: 14px 16px; border-radius: 10px; overflow-x: auto; font-size: 12px; line-height: 1.8; margin: 0; }

@media (max-width: 780px) {
  .layout { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: static; }
  .sidebar nav { flex-direction: row; flex-wrap: wrap; max-height: none; }
  .sidebar nav .navitem { padding: 6px 10px; font-size: 12px; }
  .who { flex-direction: row; align-items: center; flex-wrap: wrap; }
  .main { padding: 16px 14px 50px; }
}
@media print { .sidebar, .btn, .toast { display: none; } .card { break-inside: avoid; } }
