/* ============================================================
   xmmbdr 运营控制台 · 样式表
   ------------------------------------------------------------
   口径：
   - 深色固定侧栏 + 浅色工作区，13px 基准，数据表格紧凑
   - 所有颜色走 CSS 变量，html[data-theme="dark"] 一键换肤
   - 金额/数量统一 tabular-nums，避免跳动
   ============================================================ */

:root {
  /* 背景与边界 */
  --bg: #f5f6fa;
  --surface: #ffffff;
  --surface-2: #fbfcfe;
  --surface-3: #f2f4f9;
  --line: #e4e8f0;
  --line-2: #eef1f6;

  /* 文本 */
  --ink: #101828;
  --ink-2: #475467;
  --ink-3: #98a2b3;
  --ink-4: #c3cbd8;

  /* 品牌 */
  --brand: #4f46e5;
  --brand-2: #6366f1;
  --brand-soft: #eef2ff;
  --brand-ink: #3730a3;

  /* 语义色 */
  --ok: #067647;
  --ok-soft: #ecfdf3;
  --warn: #b54708;
  --warn-soft: #fffaeb;
  --bad: #b42318;
  --bad-soft: #fef3f2;
  --info: #175cd3;
  --info-soft: #eff8ff;

  /* 侧栏 */
  --side: #0b1120;
  --side-2: #151f36;
  --side-3: #1d2942;
  --side-ink: #a3b0c6;
  --side-ink-2: #64708a;

  /* 尺寸 */
  --radius: 10px;
  --radius-sm: 8px;
  --radius-xs: 6px;
  --shadow-1: 0 1px 2px rgba(16, 24, 40, .06);
  --shadow-2: 0 8px 24px -12px rgba(16, 24, 40, .28);
  --shadow-3: 0 24px 60px -24px rgba(16, 24, 40, .45);

  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;

  --side-w: 236px;
  --side-w-min: 68px;
  --topbar-h: 56px;
}

html[data-theme="dark"] {
  --bg: #0a0f1c;
  --surface: #121a2b;
  --surface-2: #162033;
  --surface-3: #1b2740;
  --line: #24304a;
  --line-2: #1c2740;

  --ink: #e7ecf5;
  --ink-2: #a9b6cc;
  --ink-3: #6f7d96;
  --ink-4: #47536b;

  --brand: #7c7cf7;
  --brand-2: #8b8bfa;
  --brand-soft: #1e2350;
  --brand-ink: #c7c9ff;

  --ok: #4ade80;
  --ok-soft: #0d2b1d;
  --warn: #fbbf24;
  --warn-soft: #2f2306;
  --bad: #f87171;
  --bad-soft: #331416;
  --info: #7cb7ff;
  --info-soft: #0d2440;

  --side: #070c17;
  --side-2: #101a2e;
  --shadow-1: 0 1px 2px rgba(0, 0, 0, .4);
  --shadow-2: 0 8px 24px -12px rgba(0, 0, 0, .7);
  --shadow-3: 0 24px 60px -24px rgba(0, 0, 0, .8);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 13.5px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
h1, h2, h3, h4, p { margin: 0; }
button { font-family: inherit; }
a { color: var(--brand); text-decoration: none; }
[hidden] { display: none !important; }
::selection { background: color-mix(in srgb, var(--brand) 24%, transparent); }

/* 滚动条 */
* { scrollbar-width: thin; scrollbar-color: var(--ink-4) transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-thumb { background: color-mix(in srgb, var(--ink-3) 40%, transparent); border-radius: 8px; border: 3px solid transparent; background-clip: content-box; }
*::-webkit-scrollbar-track { background: transparent; }

/* ============================================================
   登录
   ============================================================ */
.login {
  min-height: 100%;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(1100px 520px at 12% -8%, rgba(99, 102, 241, .28), transparent 62%),
    radial-gradient(900px 480px at 108% 108%, rgba(23, 92, 211, .26), transparent 58%),
    #0a1020;
}
.login-card {
  width: 100%;
  max-width: 392px;
  background: var(--surface);
  border-radius: 16px;
  padding: 30px 28px 22px;
  box-shadow: var(--shadow-3);
  border: 1px solid rgba(255, 255, 255, .06);
}
.login-brand { display: flex; gap: 12px; align-items: center; margin-bottom: 24px; }
.login-brand h1 { font-size: 17px; font-weight: 700; letter-spacing: -.2px; }
.login-brand p { font-size: 12px; color: var(--ink-3); margin-top: 3px; }
.mark {
  width: 38px; height: 38px; flex: none;
  display: grid; place-items: center;
  border-radius: 11px;
  background: linear-gradient(145deg, var(--brand-2), var(--brand));
  color: #fff; font-weight: 800; font-size: 16px;
  box-shadow: 0 6px 16px -8px rgba(79, 70, 229, .9);
}
.login .field { margin-bottom: 14px; }
.login-tip { min-height: 18px; margin-top: 10px; font-size: 12.5px; color: var(--bad); }
.login-foot { margin-top: 6px; font-size: 12px; color: var(--ink-3); text-align: center; }
.login-extra { display: flex; align-items: center; justify-content: space-between; margin: 4px 0 16px; font-size: 12px; color: var(--ink-3); }
.login-extra label { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }

/* ============================================================
   外壳
   ============================================================ */
.shell {
  display: grid;
  grid-template-columns: var(--side-w) minmax(0, 1fr);
  min-height: 100%;
}
.shell.collapsed { grid-template-columns: var(--side-w-min) minmax(0, 1fr); }

.side {
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column;
  background: var(--side);
  color: var(--side-ink);
  border-right: 1px solid rgba(255, 255, 255, .04);
  z-index: 40;
}
.side-head {
  display: flex; align-items: center; gap: 10px;
  padding: 16px 14px 14px;
  border-bottom: 1px solid rgba(255, 255, 255, .06);
  min-height: var(--topbar-h);
}
.side-head .mark { width: 30px; height: 30px; font-size: 13px; border-radius: 9px; }
.side-brand { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.side-brand b { color: #fff; font-size: 13.5px; letter-spacing: .2px; }
.side-brand small { color: var(--side-ink-2); font-size: 11px; letter-spacing: .04em; }
.side-collapse {
  margin-left: auto;
  width: 24px; height: 24px; flex: none;
  display: grid; place-items: center;
  border: 1px solid rgba(255, 255, 255, .1);
  border-radius: 7px;
  background: transparent; color: var(--side-ink-2);
  cursor: pointer; font-size: 12px; line-height: 1;
}
.side-collapse:hover { color: #fff; border-color: rgba(255, 255, 255, .28); }

.side-nav { padding: 10px 8px 18px; flex: 1; overflow-y: auto; }
.nav-group { margin-bottom: 4px; }
.nav-group > .g-label {
  display: block;
  padding: 12px 12px 5px;
  font-size: 10.5px; font-weight: 700; letter-spacing: .1em;
  color: var(--side-ink-2); text-transform: uppercase;
}
.nav-item {
  position: relative;
  display: flex; align-items: center; gap: 10px;
  width: 100%;
  padding: 8px 10px;
  margin-bottom: 1px;
  border: 0; border-radius: 8px;
  background: transparent; color: var(--side-ink);
  font-size: 13px; text-align: left; cursor: pointer;
  transition: background .14s, color .14s;
}
.nav-item svg { width: 17px; height: 17px; flex: none; opacity: .8; }
.nav-item span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-item:hover { background: rgba(255, 255, 255, .06); color: #fff; }
.nav-item:hover svg { opacity: 1; }
.nav-item.on { background: var(--side-2); color: #fff; font-weight: 600; box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .06); }
.nav-item.on svg { opacity: 1; color: var(--brand-2); }
.nav-item.on::before {
  content: ""; position: absolute; left: -8px; top: 50%; transform: translateY(-50%);
  width: 3px; height: 16px; border-radius: 0 3px 3px 0; background: var(--brand-2);
}
.nav-item .badge {
  margin-left: auto;
  min-width: 18px; height: 18px; padding: 0 5px;
  display: grid; place-items: center;
  border-radius: 9px;
  background: var(--bad); color: #fff;
  font-size: 10.5px; font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.nav-item .badge.zero { display: none; }

.side-foot {
  padding: 10px 10px 14px;
  border-top: 1px solid rgba(255, 255, 255, .06);
  display: grid; gap: 8px;
}
.side-health {
  display: grid; gap: 5px;
  padding: 9px 10px;
  border-radius: 9px;
  background: rgba(255, 255, 255, .035);
  font-size: 11.5px; color: var(--side-ink-2);
}
.side-health .row { display: flex; align-items: center; gap: 6px; }
.side-health b { color: var(--side-ink); font-weight: 600; font-variant-numeric: tabular-nums; }
.dot { width: 6px; height: 6px; border-radius: 50%; background: var(--ok); flex: none; }
.dot.warn { background: #fbbf24; }
.dot.bad { background: #f87171; }

.side-me {
  display: flex; align-items: center; gap: 9px;
  width: 100%; padding: 8px 10px;
  border: 1px solid rgba(255, 255, 255, .1);
  border-radius: 9px;
  background: rgba(255, 255, 255, .04);
  color: var(--side-ink); cursor: pointer; text-align: left;
}
.side-me:hover { background: rgba(255, 255, 255, .09); color: #fff; }
.side-me .avatar {
  width: 26px; height: 26px; border-radius: 50%; flex: none;
  display: grid; place-items: center;
  background: linear-gradient(145deg, var(--brand-2), var(--brand));
  color: #fff; font-size: 11.5px; font-weight: 700;
}
.side-me .who { display: grid; line-height: 1.3; overflow: hidden; }
.side-me .who b { color: #fff; font-size: 12.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.side-me .who small { font-size: 11px; color: var(--side-ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* 收起态 */
.shell.collapsed .side-brand,
.shell.collapsed .side-collapse,
.shell.collapsed .side-health,
.shell.collapsed .side-me .who { display: none; }
.shell.collapsed .side-head { justify-content: center; padding: 14px 0; }
.shell.collapsed .nav-group > .g-label { text-align: center; font-size: 0; padding: 10px 0 4px; }
.shell.collapsed .nav-group > .g-label::before { content: "•••"; font-size: 9px; letter-spacing: 1px; color: var(--side-ink-2); }
.shell.collapsed .nav-item { justify-content: center; padding: 9px 0; }
.shell.collapsed .nav-item span,
.shell.collapsed .nav-item .badge { display: none; }
.shell.collapsed .side-me { justify-content: center; padding: 7px 0; }

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

.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 14px;
  padding: 0 20px; height: var(--topbar-h);
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: saturate(180%) blur(10px);
  border-bottom: 1px solid var(--line);
}
.crumb { display: flex; align-items: center; gap: 8px; min-width: 0; }
.crumb .sep { color: var(--ink-4); font-size: 11px; }
.crumb h2 { font-size: 15px; font-weight: 700; letter-spacing: -.2px; white-space: nowrap; }
.crumb .sub { font-size: 12px; color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top-right { margin-left: auto; display: flex; align-items: center; gap: 8px; }

.top-search {
  display: inline-flex; align-items: center; gap: 7px;
  height: 32px; padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--ink-3);
  font-size: 12.5px; cursor: pointer;
  transition: border-color .15s, color .15s;
}
.top-search:hover { border-color: var(--ink-4); color: var(--ink-2); }
.top-search kbd {
  font-family: var(--mono); font-size: 10.5px;
  padding: 1px 4px; border-radius: 4px;
  background: var(--surface-3); color: var(--ink-3);
  border: 1px solid var(--line);
}

.icon-btn {
  width: 32px; height: 32px;
  display: inline-grid; place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface); color: var(--ink-2);
  cursor: pointer; font-size: 14px; line-height: 1;
  transition: background .15s, border-color .15s, color .15s;
}
.icon-btn:hover { background: var(--surface-3); color: var(--ink); }

.view { padding: 18px 20px 56px; min-height: 0; }

/* ============================================================
   按钮 / 表单
   ============================================================ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 32px; padding: 0 13px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface); color: var(--ink);
  font-size: 12.5px; font-weight: 550; cursor: pointer;
  white-space: nowrap;
  transition: background .15s, border-color .15s, color .15s, box-shadow .15s;
}
.btn:hover { border-color: var(--ink-4); background: var(--surface-2); }
.btn:focus-visible { outline: 2px solid var(--brand-2); outline-offset: 1px; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; box-shadow: 0 1px 2px rgba(79, 70, 229, .3); }
.btn.primary:hover { background: var(--brand-ink); border-color: var(--brand-ink); }
.btn.danger { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 32%, var(--line)); background: var(--bad-soft); }
.btn.danger:hover { background: color-mix(in srgb, var(--bad) 14%, var(--bad-soft)); }
.btn.ok { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 32%, var(--line)); background: var(--ok-soft); }
.btn.ok:hover { background: color-mix(in srgb, var(--ok) 14%, var(--ok-soft)); }
.btn.quiet { border-color: transparent; background: transparent; color: var(--ink-2); }
.btn.quiet:hover { background: var(--surface-3); color: var(--ink); }
.btn.small { height: 28px; padding: 0 9px; font-size: 12px; }
.btn.tiny { height: 24px; padding: 0 7px; font-size: 11.5px; border-radius: 6px; }
.btn.block { width: 100%; height: 40px; font-size: 13.5px; }
.btn.link { height: auto; padding: 0; border: 0; background: none; color: var(--brand); font-size: 12.5px; }
.btn.link:hover { background: none; text-decoration: underline; }

.field { display: grid; gap: 5px; min-width: 0; }
.field > span { font-size: 12px; font-weight: 600; color: var(--ink-2); }
.field .hint { font-size: 11.5px; color: var(--ink-3); font-weight: 400; }
input[type="text"], input[type="password"], input[type="number"], input[type="search"], input[type="date"], select, textarea {
  height: 32px; width: 100%;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface); color: var(--ink);
  font-family: inherit; font-size: 13px;
  transition: border-color .15s, box-shadow .15s;
}
input::placeholder, textarea::placeholder { color: var(--ink-4); }
textarea { height: auto; min-height: 88px; padding: 8px 10px; line-height: 1.6; resize: vertical; }
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--brand-2);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand-2) 18%, transparent);
}
input[type="checkbox"] { width: 15px; height: 15px; accent-color: var(--brand); cursor: pointer; }
select {
  appearance: none; padding-right: 28px;
  background-image: linear-gradient(45deg, transparent 50%, var(--ink-3) 50%), linear-gradient(135deg, var(--ink-3) 50%, transparent 50%);
  background-position: calc(100% - 15px) 13px, calc(100% - 10px) 13px;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
}
.switch { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; user-select: none; font-size: 12.5px; color: var(--ink-2); }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch .track {
  width: 36px; height: 20px; border-radius: 10px; flex: none;
  background: var(--ink-4); position: relative; transition: background .18s;
}
.switch .track::after {
  content: ""; position: absolute; top: 2px; left: 2px;
  width: 16px; height: 16px; border-radius: 50%;
  background: #fff; transition: transform .18s;
  box-shadow: 0 1px 2px rgba(0, 0, 0, .25);
}
.switch input:checked + .track { background: var(--brand); }
.switch input:checked + .track::after { transform: translateX(16px); }

/* ============================================================
   卡片 / 页头 / 工具条
   ============================================================ */
.page-head { display: flex; align-items: flex-end; gap: 12px; margin-bottom: 14px; }
.page-head .t { display: grid; gap: 2px; min-width: 0; }
.page-head h1 { font-size: 19px; font-weight: 700; letter-spacing: -.3px; }
.page-head p { font-size: 12.5px; color: var(--ink-3); }
.page-head .actions { margin-left: auto; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-1);
  overflow: hidden;
}
.card + .card, .card + .grid, .grid + .card { margin-top: 14px; }
.card-head {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 15px;
  border-bottom: 1px solid var(--line-2);
  min-height: 46px;
}
.card-head h3 { font-size: 13.5px; font-weight: 700; }
.card-head .sub { font-size: 11.5px; color: var(--ink-3); }
.card-head .right { margin-left: auto; display: flex; gap: 8px; align-items: center; }
.card-body { padding: 15px; }
.card-body.tight { padding: 0; }
.card-body.flush { padding: 0 0 0; }

.grid { display: grid; gap: 14px; }
.grid.c2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.c3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.kpi { grid-template-columns: repeat(auto-fit, minmax(196px, 1fr)); }
.grid.dash { grid-template-columns: minmax(0, 1.62fr) minmax(0, 1fr); align-items: start; }

.toolbar {
  display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px;
  padding: 12px 15px;
  border-bottom: 1px solid var(--line-2);
  background: var(--surface-2);
}
.toolbar .field { min-width: 132px; }
.toolbar .field.grow { flex: 1 1 220px; min-width: 180px; }
.toolbar .spacer { flex: 1; }
.toolbar .seg { height: 32px; }

/* KPI */
.kpi {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 13px 15px 14px;
  box-shadow: var(--shadow-1);
  min-width: 0;
}
.kpi .k { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--ink-3); }
.kpi .k .ico { width: 15px; height: 15px; opacity: .7; }
.kpi .v {
  font-size: 23px; font-weight: 700; letter-spacing: -.5px;
  margin-top: 7px; font-variant-numeric: tabular-nums;
  display: flex; align-items: baseline; gap: 4px;
}
.kpi .v small { font-size: 12px; font-weight: 500; color: var(--ink-3); letter-spacing: 0; }
.kpi .d { margin-top: 7px; display: flex; align-items: center; gap: 7px; font-size: 11.5px; color: var(--ink-3); }
.kpi.accent { border-color: color-mix(in srgb, var(--brand) 26%, var(--line)); background: linear-gradient(180deg, var(--brand-soft), var(--surface) 72%); }
.kpi.warn { border-color: color-mix(in srgb, var(--warn) 26%, var(--line)); background: linear-gradient(180deg, var(--warn-soft), var(--surface) 72%); }
.kpi.bad { border-color: color-mix(in srgb, var(--bad) 26%, var(--line)); background: linear-gradient(180deg, var(--bad-soft), var(--surface) 72%); }

.chip {
  display: inline-flex; align-items: center; gap: 3px;
  height: 19px; padding: 0 6px; border-radius: 5px;
  font-size: 11px; font-weight: 600;
  font-variant-numeric: tabular-nums;
  background: var(--surface-3); color: var(--ink-2);
}
.chip.up { background: var(--ok-soft); color: var(--ok); }
.chip.down { background: var(--bad-soft); color: var(--bad); }
.chip.flat { background: var(--surface-3); color: var(--ink-3); }

/* 数值 */
.mn { font-variant-numeric: tabular-nums; font-weight: 600; }
.mn.pos { color: var(--ok); }
.mn.neg { color: var(--bad); }
.mut { color: var(--ink-3); }
.strong { font-weight: 600; }
.mono, .code { font-family: var(--mono); font-size: 12px; color: var(--ink-2); }
.nowrap { white-space: nowrap; }
.num { text-align: right; font-variant-numeric: tabular-nums; }

/* ============================================================
   表格
   ============================================================ */
.table-wrap { width: 100%; overflow: auto; }
table.tb { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 12.8px; }
table.tb th {
  position: sticky; top: 0; z-index: 2;
  padding: 9px 14px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--line);
  color: var(--ink-3);
  font-size: 11.5px; font-weight: 600; letter-spacing: .02em;
  text-align: left; white-space: nowrap;
}
table.tb th.sortable { cursor: pointer; user-select: none; }
table.tb th.sortable:hover { color: var(--ink); }
table.tb th .arrow { margin-left: 3px; opacity: .45; font-size: 9px; }
table.tb th.on { color: var(--brand); }
table.tb th.on .arrow { opacity: 1; }
table.tb td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--line-2);
  vertical-align: middle;
  white-space: nowrap;
}
table.tb td.wrap { white-space: normal; min-width: 220px; }
table.tb tbody tr:hover { background: var(--surface-2); }
table.tb tbody tr:last-child td { border-bottom: 0; }
table.tb tbody tr.sel { background: var(--brand-soft); }
table.tb .actions { display: flex; gap: 6px; }
table.tb td.num, table.tb th.num { text-align: right; font-variant-numeric: tabular-nums; }
table.tb .col-check { width: 38px; text-align: center; }
table.tb .col-check input { display: block; margin: 0 auto; }
.table-foot { border-top: 1px solid var(--line); }

/* 状态标签 */
.pill {
  display: inline-flex; align-items: center; gap: 4px;
  height: 21px; padding: 0 7px;
  border-radius: 6px;
  font-size: 11.5px; font-weight: 600;
  background: var(--surface-3); color: var(--ink-2);
  white-space: nowrap;
}
.pill.ok { background: var(--ok-soft); color: var(--ok); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.bad { background: var(--bad-soft); color: var(--bad); }
.pill.brand { background: var(--brand-soft); color: var(--brand-ink); }
.pill.info { background: var(--info-soft); color: var(--info); }
.pill.dot::before { content: ""; width: 5px; height: 5px; border-radius: 50%; background: currentColor; }

/* 分段 */
.seg { display: inline-flex; padding: 3px; gap: 2px; background: var(--surface-3); border-radius: 8px; }
.seg button {
  height: 26px; padding: 0 11px;
  border: 0; border-radius: 6px;
  background: transparent; color: var(--ink-2);
  font-size: 12px; font-weight: 600; cursor: pointer;
  transition: background .14s, color .14s;
  white-space: nowrap;
}
.seg button:hover { color: var(--ink); }
.seg button.on { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-1); }

/* 分页 */
.pager {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 15px;
  border-top: 1px solid var(--line);
  font-size: 12px; color: var(--ink-2);
}
.pager .right { margin-left: auto; display: flex; align-items: center; gap: 6px; }
.pager select { height: 28px; width: auto; font-size: 12px; }
.pager .btn { height: 28px; padding: 0 9px; }

/* 空态 / 骨架 */
.empty { padding: 44px 20px; text-align: center; color: var(--ink-3); }
.empty .ico { font-size: 22px; opacity: .5; margin-bottom: 8px; }
.empty b { display: block; color: var(--ink-2); font-size: 13px; margin-bottom: 3px; font-weight: 600; }
.skel { padding: 16px 15px; display: grid; gap: 10px; }
.skel i {
  display: block; height: 12px; border-radius: 6px;
  background: linear-gradient(90deg, var(--surface-3) 25%, var(--surface-2) 50%, var(--surface-3) 75%);
  background-size: 200% 100%;
  animation: sh 1.2s infinite linear;
}
@keyframes sh { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* ============================================================
   图表（纯 SVG，无依赖）
   ============================================================ */
.chart { padding: 14px 15px 8px; }
.chart .plot { position: relative; height: 172px; }
.chart .plot svg { display: block; width: 100%; height: 100%; overflow: visible; }
.chart .axis { display: flex; justify-content: space-between; gap: 4px; margin-top: 8px; }
.chart .axis span { flex: 1; text-align: center; font-size: 10.5px; color: var(--ink-3); white-space: nowrap; }
.legend { display: flex; align-items: center; gap: 14px; font-size: 11.5px; color: var(--ink-3); }
.legend i { display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: 5px; vertical-align: middle; }
.chart-tip {
  position: absolute; z-index: 5; pointer-events: none;
  padding: 6px 9px; border-radius: 7px;
  background: var(--ink); color: var(--surface);
  font-size: 11.5px; line-height: 1.5; white-space: nowrap;
  box-shadow: var(--shadow-2); transform: translate(-50%, -108%);
  opacity: 0; transition: opacity .12s;
}
.chart .plot:hover .chart-tip { opacity: 1; }

/* 进度条 */
.meter { height: 6px; border-radius: 3px; background: var(--surface-3); overflow: hidden; }
.meter > i { display: block; height: 100%; border-radius: 3px; background: var(--brand); }

/* ============================================================
   待办 / 列表
   ============================================================ */
.todo { display: grid; }
.todo-item {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 15px;
  border-bottom: 1px solid var(--line-2);
  cursor: pointer; text-align: left; background: none; border-left: 0; border-right: 0; border-top: 0;
  width: 100%;
  transition: background .14s;
}
.todo-item:last-child { border-bottom: 0; }
.todo-item:hover { background: var(--surface-2); }
.todo-item .bar { width: 3px; height: 28px; border-radius: 2px; background: var(--warn); flex: none; }
.todo-item .bar.bad { background: var(--bad); }
.todo-item .txt { display: grid; gap: 1px; min-width: 0; }
.todo-item .txt b { font-size: 12.8px; font-weight: 600; }
.todo-item .txt small { font-size: 11.5px; color: var(--ink-3); }
.todo-item .go { margin-left: auto; color: var(--ink-3); font-size: 12px; }

.rank { display: grid; }
.rank-row {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 15px;
  border-bottom: 1px solid var(--line-2);
  font-size: 12.8px;
}
.rank-row:last-child { border-bottom: 0; }
.rank-row .no {
  width: 19px; height: 19px; flex: none;
  display: grid; place-items: center;
  border-radius: 5px;
  background: var(--surface-3); color: var(--ink-3);
  font-size: 11px; font-weight: 700;
}
.rank-row:nth-child(1) .no { background: #fff4d6; color: #a15c00; }
.rank-row:nth-child(2) .no { background: #eef1f6; color: #545f71; }
.rank-row:nth-child(3) .no { background: #fdeee2; color: #a15c2f; }
.rank-row .nm { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rank-row .bar-wrap { flex: 1; min-width: 40px; }
.rank-row .val { margin-left: auto; font-variant-numeric: tabular-nums; font-weight: 600; }

/* KV */
.kv { display: grid; grid-template-columns: repeat(auto-fit, minmax(148px, 1fr)); gap: 12px 18px; }
.kv > div { display: grid; gap: 1px; min-width: 0; }
.kv span { font-size: 11.5px; color: var(--ink-3); }
.kv b { font-size: 13.5px; font-weight: 600; font-variant-numeric: tabular-nums; word-break: break-all; }

/* 描述列表（抽屉） */
.dl { display: grid; gap: 0; }
.dl .row { display: flex; gap: 12px; padding: 8px 0; border-bottom: 1px dashed var(--line-2); font-size: 12.8px; }
.dl .row:last-child { border-bottom: 0; }
.dl .row > span { color: var(--ink-3); width: 92px; flex: none; }
.dl .row > b { font-weight: 600; word-break: break-all; }

/* 头像方块 */
.avatar {
  width: 26px; height: 26px; border-radius: 50%;
  display: inline-grid; place-items: center;
  background: var(--brand-soft); color: var(--brand-ink);
  font-size: 11px; font-weight: 700; flex: none;
}
.user-cell { display: flex; align-items: center; gap: 9px; }
.user-cell .txt { display: grid; line-height: 1.35; min-width: 0; }
.user-cell .txt b { font-size: 12.8px; font-weight: 600; }
.user-cell .txt small { font-size: 11.5px; color: var(--ink-3); font-family: var(--mono); }

/* ============================================================
   遮罩 / 弹窗 / 抽屉 / 命令面板 / Toast
   ============================================================ */
.scrim { position: fixed; inset: 0; z-index: 45; background: rgba(8, 15, 30, .45); }
.overlay { position: fixed; inset: 0; background: rgba(15, 23, 42, .42); backdrop-filter: blur(2px); z-index: 60; }

.modal {
  position: fixed; z-index: 61; top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: min(540px, calc(100vw - 32px));
  max-height: calc(100vh - 64px);
  display: flex; flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow-3);
  overflow: hidden;
  animation: pop .16s ease-out;
}
.modal.wide { width: min(760px, calc(100vw - 32px)); }
.modal-head { display: flex; align-items: flex-start; gap: 10px; padding: 15px 18px 13px; border-bottom: 1px solid var(--line-2); }
.modal-head .t { display: grid; gap: 2px; min-width: 0; }
.modal-head h3 { font-size: 14.5px; font-weight: 700; }
.modal-head .sub { font-size: 12px; color: var(--ink-3); }
.modal-head .x {
  margin-left: auto; width: 26px; height: 26px;
  display: grid; place-items: center;
  border: 0; border-radius: 6px; background: none;
  font-size: 17px; line-height: 1; color: var(--ink-3); cursor: pointer;
}
.modal-head .x:hover { background: var(--surface-3); color: var(--ink); }
.modal-body { padding: 16px 18px; overflow: auto; display: grid; gap: 13px; }
.modal-body p { font-size: 13px; color: var(--ink-2); line-height: 1.65; }
.modal-foot {
  display: flex; justify-content: flex-end; gap: 8px;
  padding: 11px 18px; border-top: 1px solid var(--line-2);
  background: var(--surface-2);
}
@keyframes pop { from { opacity: 0; transform: translate(-50%, -48%) scale(.985); } to { opacity: 1; transform: translate(-50%, -50%) scale(1); } }

/* 抽屉 */
.drawer {
  position: fixed; z-index: 61; top: 0; right: 0; bottom: 0;
  width: min(520px, 100vw);
  display: flex; flex-direction: column;
  background: var(--surface);
  border-left: 1px solid var(--line);
  box-shadow: var(--shadow-3);
  animation: slide .2s ease-out;
}
.drawer.wide { width: min(760px, 100vw); }
.drawer-head { display: flex; align-items: flex-start; gap: 10px; padding: 16px 18px 14px; border-bottom: 1px solid var(--line-2); }
.drawer-head .t { display: grid; gap: 2px; min-width: 0; }
.drawer-head h3 { font-size: 14.5px; font-weight: 700; }
.drawer-head .sub { font-size: 12px; color: var(--ink-3); }
.drawer-head .x { margin-left: auto; width: 26px; height: 26px; display: grid; place-items: center; border: 0; border-radius: 6px; background: none; font-size: 17px; color: var(--ink-3); cursor: pointer; }
.drawer-head .x:hover { background: var(--surface-3); color: var(--ink); }
.drawer-body { padding: 16px 18px 24px; overflow: auto; display: grid; gap: 16px; }
.drawer-foot { margin-top: auto; display: flex; gap: 8px; padding: 12px 18px; border-top: 1px solid var(--line-2); background: var(--surface-2); }
@keyframes slide { from { transform: translateX(16px); opacity: .6; } to { transform: none; opacity: 1; } }

/* 命令面板 */
.palette {
  position: fixed; z-index: 70; top: 12vh; left: 50%;
  transform: translateX(-50%);
  width: min(560px, calc(100vw - 28px));
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow-3);
  overflow: hidden;
  animation: pop2 .14s ease-out;
}
@keyframes pop2 { from { opacity: 0; transform: translate(-50%, -6px); } to { opacity: 1; transform: translate(-50%, 0); } }
.palette input {
  height: 44px; border: 0; border-bottom: 1px solid var(--line-2);
  border-radius: 0; font-size: 14px; padding: 0 16px;
  background: var(--surface);
}
.palette input:focus { box-shadow: none; border-color: var(--line-2); }
.palette .list { max-height: min(52vh, 400px); overflow: auto; padding: 6px; }
.palette .item {
  display: flex; align-items: center; gap: 9px;
  width: 100%; padding: 8px 10px;
  border: 0; border-radius: 8px;
  background: none; color: var(--ink); cursor: pointer;
  font-size: 13px; text-align: left;
}
.palette .item svg { width: 15px; height: 15px; color: var(--ink-3); flex: none; }
.palette .item small { margin-left: auto; font-size: 11px; color: var(--ink-3); }
.palette .item.on, .palette .item:hover { background: var(--brand-soft); }
.palette .item.on svg { color: var(--brand); }
.palette .foot { padding: 7px 12px; border-top: 1px solid var(--line-2); background: var(--surface-2); font-size: 11px; color: var(--ink-3); display: flex; gap: 12px; }
.palette kbd { font-family: var(--mono); font-size: 10px; padding: 1px 4px; border-radius: 4px; background: var(--surface-3); border: 1px solid var(--line); }

/* Toast */
.toasts { position: fixed; z-index: 90; top: 14px; right: 14px; display: grid; gap: 8px; justify-items: end; }
.toast {
  display: flex; align-items: flex-start; gap: 8px;
  min-width: 200px; max-width: 380px;
  padding: 10px 13px;
  border-radius: 9px;
  background: var(--ink); color: var(--surface);
  font-size: 12.8px; line-height: 1.5;
  box-shadow: var(--shadow-2);
  animation: tin .16s ease-out;
}
.toast::before { content: ""; width: 3px; align-self: stretch; border-radius: 2px; background: var(--brand-2); flex: none; }
.toast.ok { background: #0b3b28; color: #e6f8ee; }
.toast.ok::before { background: #34d399; }
.toast.bad { background: #3d1414; color: #fdeaea; }
.toast.bad::before { background: #f87171; }
@keyframes tin { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }

/* 页脚信息 */
.foot-note { margin-top: 16px; font-size: 11.5px; color: var(--ink-3); display: flex; gap: 12px; flex-wrap: wrap; }
.foot-note b { color: var(--ink-2); font-weight: 600; }

/* ============================================================
   响应式
   ============================================================ */
@media (max-width: 1200px) {
  .grid.dash { grid-template-columns: minmax(0, 1fr); }
  .grid.c3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 1000px) {
  .shell, .shell.collapsed { grid-template-columns: minmax(0, 1fr); }
  .side {
    position: fixed; left: 0; top: 0; width: var(--side-w);
    transform: translateX(-100%);
    transition: transform .22s ease;
    box-shadow: 0 0 40px rgba(0, 0, 0, .45);
  }
  .side.open { transform: none; }
  .shell.collapsed .side-brand,
  .shell.collapsed .side-health,
  .shell.collapsed .side-me .who { display: grid; }
  .shell.collapsed .nav-item { justify-content: flex-start; padding: 8px 10px; }
  .shell.collapsed .nav-item span { display: inline; }
  .shell.collapsed .side-head { justify-content: flex-start; padding: 16px 14px 14px; }
  .view { padding: 14px 14px 44px; }
  .topbar { padding: 0 12px; }
  .top-search { display: none; }
  .only-desktop { display: none !important; }
  .grid.c2, .grid.c3 { grid-template-columns: minmax(0, 1fr); }
  .page-head .actions #settleBtn { display: none; }
}
@media (min-width: 1001px) {
  #menuToggle { display: none; }
}
@media (max-width: 620px) {
  .crumb .sub { display: none; }
  .grid.kpi { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpi .v { font-size: 19px; }
  .page-head { flex-wrap: wrap; }
  .page-head .actions { margin-left: 0; width: 100%; }
  .chart .plot { height: 140px; }
  .chart .axis span:nth-child(even) { display: none; }
  .drawer { width: 100vw; }
}

/* 打印（导出前预览） */
@media print {
  .side, .topbar, .toasts, .page-head .actions { display: none !important; }
  .shell { grid-template-columns: 1fr; }
  .view { padding: 0; }
  body { background: #fff; }
  .card { box-shadow: none; break-inside: avoid; }
}
