/* ============================================================
   五合一挂机平台 · 管理后台样式
   纯手写 CSS：无外链字体、无框架、无 CDN
   ============================================================ */
:root {
  --bg: #0d1117;
  --bg-soft: #131a23;
  --bg-elev: #172029;
  --bg-elev-2: #1d2833;
  --line: #253241;
  --line-soft: #1e2833;
  --text: #e6edf3;
  --text-dim: #9aa8b6;
  --text-mute: #6b7a8a;
  --brand: #3b82f6;
  --brand-dim: #1d4ed8;
  --ok: #3fb950;
  --warn: #d29922;
  --danger: #f85149;
  --purple: #a371f7;
  --teal: #39c5bb;
  --radius: 8px;
  --radius-sm: 6px;
  --shadow: 0 8px 24px rgba(1, 4, 9, .55);
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", "PingFang SC", "Hiragino Sans GB", "Source Han Sans SC", sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Cascadia Mono", "DejaVu Sans Mono", monospace;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 13px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
code, pre, .mono { font-family: var(--mono); font-size: 12px; }
h1, h2, h3, h4 { margin: 0; font-weight: 600; }
::selection { background: rgba(59, 130, 246, .35); }

.boot { padding: 48px; text-align: center; color: var(--text-dim); }

/* ---------------- 登录页 ---------------- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px;
  background:
    radial-gradient(900px 500px at 12% -10%, rgba(59,130,246,.16), transparent 60%),
    radial-gradient(700px 400px at 100% 110%, rgba(163,113,247,.14), transparent 60%),
    var(--bg); }
.login-card { width: 100%; max-width: 380px; background: var(--bg-soft); border: 1px solid var(--line);
  border-radius: 12px; padding: 28px 26px; box-shadow: var(--shadow); }
.login-card .brand { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
.login-card .brand .logo { width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--brand), var(--purple)); color: #fff; font-weight: 700; font-size: 13px; }
.login-card h1 { font-size: 17px; }
.login-card .sub { color: var(--text-mute); font-size: 12px; margin: 0 0 20px; }
.login-card .tip { margin-top: 16px; padding: 10px 12px; border-radius: var(--radius-sm);
  background: rgba(59,130,246,.08); border: 1px solid rgba(59,130,246,.22); color: var(--text-dim); font-size: 11.5px; line-height: 1.7; }
.login-error { margin-top: 12px; padding: 9px 12px; border-radius: var(--radius-sm); font-size: 12px;
  background: rgba(248,81,73,.1); border: 1px solid rgba(248,81,73,.35); color: #ffb3ae; }
.login-error[hidden] { display: none; }

/* ---------------- 布局 ---------------- */
.shell { display: grid; grid-template-columns: 218px 1fr; min-height: 100vh; }
.sidebar { background: var(--bg-soft); border-right: 1px solid var(--line); display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.sidebar .brand { display: flex; gap: 10px; align-items: center; padding: 16px 16px 14px; border-bottom: 1px solid var(--line-soft); }
.sidebar .brand .logo { width: 28px; height: 28px; border-radius: 7px; display: grid; place-items: center; flex: none;
  background: linear-gradient(135deg, var(--brand), var(--purple)); color: #fff; font-weight: 700; font-size: 12px; }
.sidebar .brand b { font-size: 13px; display: block; }
.sidebar .brand span { font-size: 11px; color: var(--text-mute); }
.nav { padding: 10px 8px; display: flex; flex-direction: column; gap: 2px; flex: 1; }
.nav-group { font-size: 10.5px; letter-spacing: .08em; color: var(--text-mute); padding: 12px 10px 5px; text-transform: uppercase; }
.nav a { display: flex; align-items: center; gap: 9px; padding: 7px 10px; border-radius: var(--radius-sm);
  color: var(--text-dim); font-size: 12.5px; border: 1px solid transparent; }
.nav a:hover { background: var(--bg-elev); color: var(--text); text-decoration: none; }
.nav a.active { background: rgba(59,130,246,.14); color: #cfe0ff; border-color: rgba(59,130,246,.35); }
.nav a .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .55; flex: none; }
.nav a .ico { width: 16px; text-align: center; opacity: .85; flex: none; }
.sidebar .foot { padding: 12px; border-top: 1px solid var(--line-soft); font-size: 11px; color: var(--text-mute); }

.main { display: flex; flex-direction: column; min-width: 0; }
.topbar { position: sticky; top: 0; z-index: 30; background: rgba(13,17,23,.96); backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--line); }
.riskbar { display: flex; align-items: center; gap: 8px; padding: 7px 20px; font-size: 11.5px;
  background: rgba(210,153,34,.1); border-bottom: 1px solid rgba(210,153,34,.28); color: #e8c46a; }
.riskbar .warn-ico { flex: none; font-weight: 700; }
.riskbar .txt { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.riskbar .more { background: none; border: 1px solid rgba(210,153,34,.4); color: #e8c46a; border-radius: 4px;
  font-size: 11px; padding: 1px 8px; cursor: pointer; flex: none; }
.riskbar .more:hover { background: rgba(210,153,34,.16); }
.riskbar .risk-list { position: absolute; top: 100%; left: 0; right: 0; background: var(--bg-elev); border-bottom: 1px solid var(--line);
  padding: 12px 20px 14px; box-shadow: var(--shadow); color: var(--text-dim); font-size: 12px; white-space: normal; }
.riskbar .risk-list ul { margin: 0; padding-left: 18px; }
.riskbar .risk-list li { margin: 3px 0; }
.riskbar { position: relative; }

.headbar { display: flex; align-items: center; gap: 12px; padding: 12px 20px; }
.headbar h2 { font-size: 15px; }
.headbar .crumb { color: var(--text-mute); font-size: 11.5px; }
.headbar .spacer { flex: 1; }
.headbar .who { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--text-dim); }
.avatar { width: 24px; height: 24px; border-radius: 50%; background: var(--bg-elev-2); border: 1px solid var(--line);
  display: grid; place-items: center; font-size: 11px; color: var(--text); }

.view { padding: 6px 20px 40px; min-height: 60vh; }

/* ---------------- 通用元件 ---------------- */
.card { background: var(--bg-soft); border: 1px solid var(--line); border-radius: var(--radius); }
.card > header { display: flex; align-items: center; gap: 10px; padding: 11px 14px; border-bottom: 1px solid var(--line-soft); }
.card > header h3 { font-size: 12.5px; }
.card > header .spacer { flex: 1; }
.card > .body { padding: 14px; }
.grid { display: grid; gap: 12px; }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (max-width: 1180px) { .grid-4 { grid-template-columns: repeat(2, minmax(0,1fr)); } }
@media (max-width: 900px) { .grid-3, .grid-2 { grid-template-columns: minmax(0,1fr); } .shell { grid-template-columns: 1fr; } .sidebar { display: none; } }

.stat { background: var(--bg-soft); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; position: relative; overflow: hidden; }
.stat .k { font-size: 11.5px; color: var(--text-mute); display: flex; align-items: center; gap: 6px; }
.stat .v { font-size: 22px; font-weight: 650; letter-spacing: -.02em; margin-top: 4px; font-variant-numeric: tabular-nums; }
.stat .v small { font-size: 12px; color: var(--text-mute); font-weight: 400; margin-left: 3px; }
.stat .d { font-size: 11px; color: var(--text-mute); margin-top: 2px; }
.stat::after { content: ""; position: absolute; inset: 0 auto 0 0; width: 3px; background: var(--brand); opacity: .75; }
.stat.ok::after { background: var(--ok); }
.stat.warn::after { background: var(--warn); }
.stat.danger::after { background: var(--danger); }
.stat.purple::after { background: var(--purple); }

.btn { display: inline-flex; align-items: center; gap: 5px; padding: 5px 11px; border-radius: var(--radius-sm);
  border: 1px solid var(--line); background: var(--bg-elev); color: var(--text); font-size: 12px; font-family: inherit;
  cursor: pointer; white-space: nowrap; transition: background .12s, border-color .12s, opacity .12s; }
.btn:hover:not(:disabled) { background: var(--bg-elev-2); border-color: #33465b; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.primary { background: var(--brand-dim); border-color: var(--brand); color: #fff; }
.btn.primary:hover:not(:disabled) { background: #2563eb; }
.btn.ok { background: rgba(63,185,80,.14); border-color: rgba(63,185,80,.45); color: #7ee787; }
.btn.danger { background: rgba(248,81,73,.12); border-color: rgba(248,81,73,.4); color: #ff9c96; }
.btn.ghost { background: transparent; }
.btn.sm { padding: 3px 8px; font-size: 11.5px; }
.btn.link { background: none; border: none; color: var(--brand); padding: 2px 4px; }
.btn.link:hover:not(:disabled) { text-decoration: underline; background: none; }

.input, .select, .textarea {
  width: 100%; padding: 6px 9px; background: var(--bg); color: var(--text);
  border: 1px solid var(--line); border-radius: var(--radius-sm); font-family: inherit; font-size: 12px; outline: none;
}
.input:focus, .select:focus, .textarea:focus { border-color: var(--brand); box-shadow: 0 0 0 2px rgba(59,130,246,.18); }
.textarea { min-height: 84px; resize: vertical; line-height: 1.6; }
.select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--text-mute) 50%), linear-gradient(135deg, var(--text-mute) 50%, transparent 50%);
  background-position: calc(100% - 14px) 11px, calc(100% - 9px) 11px; background-size: 5px 5px, 5px 5px; background-repeat: no-repeat; padding-right: 26px; }
label.field { display: block; margin-bottom: 10px; }
label.field > .lb { display: block; font-size: 11.5px; color: var(--text-dim); margin-bottom: 4px; }
label.field > .lb em { color: var(--danger); font-style: normal; margin-left: 2px; }
label.field .hint { font-size: 11px; color: var(--text-mute); margin-top: 3px; }

.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 12px; }
.toolbar .spacer { flex: 1; }
.toolbar .input, .toolbar .select { width: auto; min-width: 130px; }
.field-inline { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-dim); }

.chip { display: inline-flex; align-items: center; padding: 1px 7px; border-radius: 10px; font-size: 11px;
  border: 1px solid var(--line); color: var(--text-dim); background: var(--bg-elev); white-space: nowrap; }
.chip.ok, .chip.green { color: #7ee787; border-color: rgba(63,185,80,.4); background: rgba(63,185,80,.1); }
.chip.warn, .chip.orange { color: #e8c46a; border-color: rgba(210,153,34,.4); background: rgba(210,153,34,.1); }
.chip.danger, .chip.red { color: #ff9c96; border-color: rgba(248,81,73,.4); background: rgba(248,81,73,.1); }
.chip.blue { color: #9ec5ff; border-color: rgba(59,130,246,.4); background: rgba(59,130,246,.12); }
.chip.purple { color: #d2b8ff; border-color: rgba(163,113,247,.4); background: rgba(163,113,247,.12); }
.chip.mute { color: var(--text-mute); }

/* 表格 */
.table-wrap { border: 1px solid var(--line); border-radius: var(--radius); overflow: auto; background: var(--bg-soft); }
table.dt { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 12px; }
table.dt th { position: sticky; top: 0; z-index: 1; background: var(--bg-elev); color: var(--text-dim); font-weight: 500;
  text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; font-size: 11.5px; }
table.dt td { padding: 7px 10px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
table.dt tbody tr:hover td { background: rgba(59,130,246,.05); }
table.dt tbody tr:last-child td { border-bottom: none; }
table.dt td.num, table.dt th.num { text-align: right; font-variant-numeric: tabular-nums; font-family: var(--mono); font-size: 11.5px; }
table.dt td.ops { white-space: nowrap; }
table.dt td.ops .btn { margin-right: 4px; }
table.dt td.ops .btn:last-child { margin-right: 0; }
.empty { padding: 34px 12px; text-align: center; color: var(--text-mute); font-size: 12px; }
.pre { background: var(--bg); border: 1px solid var(--line-soft); border-radius: var(--radius-sm); padding: 9px 11px;
  max-height: 260px; overflow: auto; white-space: pre-wrap; word-break: break-all; color: var(--text-dim); font-family: var(--mono); font-size: 11.5px; }

/* 分页 */
.pager { display: flex; align-items: center; gap: 6px; justify-content: flex-end; padding: 10px 2px 0; font-size: 12px; color: var(--text-mute); }
.pager .btn { min-width: 26px; justify-content: center; }

/* 选项卡 */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 12px; overflow-x: auto; }
.tabs button { background: none; border: none; border-bottom: 2px solid transparent; color: var(--text-dim);
  padding: 7px 11px; font-size: 12.5px; font-family: inherit; cursor: pointer; white-space: nowrap; }
.tabs button:hover { color: var(--text); }
.tabs button.active { color: #cfe0ff; border-bottom-color: var(--brand); }

/* 弹窗 */
.overlay { position: fixed; inset: 0; background: rgba(1,4,9,.62); display: grid; place-items: center; z-index: 100; padding: 20px; }
.modal { width: 100%; max-width: 440px; background: var(--bg-soft); border: 1px solid var(--line); border-radius: 10px;
  box-shadow: var(--shadow); max-height: 88vh; display: flex; flex-direction: column; }
.modal.wide { max-width: 720px; }
.modal > header { padding: 12px 16px; border-bottom: 1px solid var(--line-soft); display: flex; align-items: center; }
.modal > header h3 { font-size: 13px; flex: 1; }
.modal > .body { padding: 16px; overflow: auto; }
.modal > footer { padding: 12px 16px; border-top: 1px solid var(--line-soft); display: flex; gap: 8px; justify-content: flex-end; }
.modal .err { margin-bottom: 10px; padding: 8px 10px; border-radius: var(--radius-sm); font-size: 11.5px;
  background: rgba(248,81,73,.1); border: 1px solid rgba(248,81,73,.35); color: #ffb3ae; }
.modal .err[hidden] { display: none; }

/* 抽屉 */
.drawer-mask { position: fixed; inset: 0; background: rgba(1,4,9,.5); z-index: 90; }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(720px, 96vw); background: var(--bg-soft);
  border-left: 1px solid var(--line); z-index: 95; display: flex; flex-direction: column; box-shadow: var(--shadow); }
.drawer > header { padding: 12px 16px; border-bottom: 1px solid var(--line-soft); display: flex; align-items: center; gap: 10px; }
.drawer > header h3 { font-size: 13px; flex: 1; }
.drawer > .body { padding: 14px 16px 28px; overflow: auto; }

/* toast */
#toast-root { position: fixed; top: 14px; right: 14px; z-index: 300; display: flex; flex-direction: column; gap: 8px;
  max-width: min(420px, 92vw); }
.toast { padding: 9px 13px; border-radius: var(--radius-sm); font-size: 12px; border: 1px solid var(--line);
  background: var(--bg-elev); color: var(--text); box-shadow: var(--shadow); animation: tin .16s ease-out; word-break: break-word; }
.toast.ok { border-color: rgba(63,185,80,.5); background: #16241b; color: #b7f0be; }
.toast.err { border-color: rgba(248,81,73,.5); background: #2a1618; color: #ffc0bb; }
.toast.warn { border-color: rgba(210,153,34,.5); background: #2a2313; color: #f3d99a; }
@keyframes tin { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }

/* 图表 */
.chart-wrap { position: relative; height: 240px; }
.chart-wrap canvas { width: 100%; height: 100%; display: block; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 11.5px; color: var(--text-dim); margin-top: 8px; }
.legend i { display: inline-block; width: 9px; height: 9px; border-radius: 2px; margin-right: 5px; vertical-align: -1px; }

.kv { display: grid; grid-template-columns: 120px 1fr; gap: 5px 10px; font-size: 12px; }
.kv .k { color: var(--text-mute); }
.kv .v { color: var(--text); word-break: break-all; }

.section-title { font-size: 12.5px; color: var(--text-dim); margin: 18px 0 8px; padding-bottom: 6px; border-bottom: 1px solid var(--line-soft); }
.hr { height: 1px; background: var(--line-soft); margin: 14px 0; border: none; }
.muted { color: var(--text-mute); }
.small { font-size: 11px; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.col { display: flex; flex-direction: column; gap: 8px; }
.notice { padding: 9px 12px; border-radius: var(--radius-sm); font-size: 11.5px; line-height: 1.7;
  background: rgba(59,130,246,.08); border: 1px solid rgba(59,130,246,.24); color: #b9d4ff; margin-bottom: 12px; }
.notice.warn { background: rgba(210,153,34,.09); border-color: rgba(210,153,34,.3); color: #f0d492; }
.cfg-group { border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 12px; background: var(--bg-soft); }
.cfg-group > .gh { padding: 9px 13px; border-bottom: 1px solid var(--line-soft); font-size: 12.5px; display: flex; align-items: center; gap: 8px; }
.cfg-group > .gb { padding: 4px 13px 8px; }
.cfg-row { display: grid; grid-template-columns: 260px 1fr 96px; gap: 10px; align-items: center; padding: 7px 0; border-bottom: 1px dashed var(--line-soft); }
.cfg-row:last-child { border-bottom: none; }
.cfg-row .lb { font-size: 12px; }
.cfg-row .lb small { display: block; color: var(--text-mute); font-size: 10.5px; font-family: var(--mono); }
.cfg-row .val { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.cfg-row .val .input, .cfg-row .val .select { width: auto; min-width: 120px; }
.cfg-row .act { text-align: right; }
.switch { position: relative; width: 38px; height: 20px; border-radius: 12px; background: var(--bg-elev-2);
  border: 1px solid var(--line); cursor: pointer; flex: none; transition: background .15s; }
.switch::after { content: ""; position: absolute; top: 2px; left: 2px; width: 14px; height: 14px; border-radius: 50%;
  background: var(--text-mute); transition: transform .15s, background .15s; }
.switch.on { background: rgba(63,185,80,.28); border-color: rgba(63,185,80,.55); }
.switch.on::after { transform: translateX(18px); background: #7ee787; }
.subvals { display: flex; gap: 6px; flex-wrap: wrap; }
.subvals .mini { display: flex; align-items: center; gap: 4px; font-size: 11px; color: var(--text-mute); }
.subvals .input { width: 78px; }
.hidden { display: none !important; }
