/* ==========================================================================
   sd-dashboard.css — 控制台首页重设计（shadcn 风格令牌 + 组件）
   --------------------------------------------------------------------------
   约定（与 ui.css 一致，改动前必读）：
   1. 本文件只被 app/templates/dashboard.html 引用，不影响 admin / vendor_dashboard。
   2. tailwind.css 是冻结的预编译残缺产物，本文件不依赖任何 Tailwind 类，
      也不新增 Tailwind 类；所有新样式使用独立 .sd-* 类或直接覆盖已有 .vd-* 结构类。
      守门：python3 tests/check_tailwind_classes.py --diff
   3. 本文件必须在 vendor-dashboard.css 之后加载（同优先级后置生效）。
      修改后请 bump dashboard.html 里的 ?v= 查询串，避免浏览器缓存旧样式。
   4. 客户端可见文案不出现后端服务商名，守门：python3 tests/test_no_vendor_leak.py
   ========================================================================== */

:root {
  --sd-background: 210 40% 98%;
  --sd-foreground: 222 47% 11%;
  --sd-card: 0 0% 100%;
  --sd-card-foreground: 222 47% 11%;
  --sd-muted: 210 40% 96%;
  --sd-muted-foreground: 215 16% 47%;
  --sd-accent: 210 40% 94%;
  --sd-border: 214 32% 91%;
  --sd-ring: 221 83% 53%;
  --sd-primary: 221 83% 53%;
  --sd-primary-foreground: 0 0% 100%;
  --sd-primary-soft: 214 95% 96%;
  --sd-warm: 35 92% 50%;
  --sd-warm-soft: 45 100% 95%;
  --sd-warm-foreground: 26 60% 24%;
  --sd-success: 142 71% 38%;
  --sd-success-soft: 141 79% 95%;
  --sd-warning: 32 90% 45%;
  --sd-warning-soft: 45 100% 94%;
  --sd-danger: 0 72% 51%;
  --sd-danger-soft: 0 86% 97%;
  --sd-radius: 12px;
  --sd-radius-sm: 8px;
  --sd-radius-lg: 16px;
  --sd-shadow-sm: 0 1px 2px hsl(222 47% 11% / .05);
  --sd-shadow-md: 0 1px 2px hsl(222 47% 11% / .04), 0 8px 24px hsl(222 47% 11% / .05);
}

html[data-sd-theme="dark"] {
  --sd-background: 222 47% 8%;
  --sd-foreground: 210 40% 96%;
  --sd-card: 222 44% 12%;
  --sd-card-foreground: 210 40% 96%;
  --sd-muted: 217 33% 17%;
  --sd-muted-foreground: 215 18% 70%;
  --sd-accent: 217 33% 19%;
  --sd-border: 217 33% 21%;
  --sd-primary: 217 91% 62%;
  --sd-primary-soft: 217 50% 19%;
  --sd-warm: 38 92% 58%;
  --sd-warm-soft: 38 40% 17%;
  --sd-warm-foreground: 45 100% 88%;
  --sd-success-soft: 142 40% 16%;
  --sd-warning-soft: 38 40% 17%;
  --sd-danger-soft: 0 40% 18%;
  --sd-shadow-sm: 0 1px 2px hsl(0 0% 0% / .3);
  --sd-shadow-md: 0 8px 24px hsl(0 0% 0% / .35);
}

html[data-sd-theme="dark"] body.vd-body,
html[data-sd-theme="dark"] .vd-sidebar,
html[data-sd-theme="dark"] .vd-panel,
html[data-sd-theme="dark"] .vd-stat,
html[data-sd-theme="dark"] .vd-projects > div,
html[data-sd-theme="dark"] .vd-support__content > .space-y-6 > div,
html[data-sd-theme="dark"] .vd-support .vd-support__integration {
  color-scheme: dark;
}

body.vd-body {
  background: hsl(var(--sd-background));
  color: hsl(var(--sd-foreground));
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  -webkit-font-smoothing: antialiased;
}

.sd-sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.sd-ico { width: 16px; height: 16px; flex-shrink: 0; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.sd-ico--sm { width: 14px; height: 14px; }
.sd-ico--lg { width: 18px; height: 18px; }

/* ── 顶栏 ─────────────────────────────────────────────────────────────── */
.vd-header.sd-topbar {
  height: 60px;
  background: hsl(var(--sd-card) / .88);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid hsl(var(--sd-border));
}
.vd-header.sd-topbar .vd-header__inner { width: 100%; max-width: 1600px; margin-inline: auto; padding-inline: 24px; gap: 20px; }
.vd-header.sd-topbar .vd-brand__mark { width: 30px; height: 30px; border-radius: 9px; font-size: 14px; font-weight: 700; background: hsl(var(--sd-primary)); }
.vd-header.sd-topbar .vd-brand__name { font-size: 15px; font-weight: 650; letter-spacing: -.02em; }
.vd-header.sd-topbar .vd-header__actions { gap: 10px; }
.vd-header.sd-topbar .vd-header__account { display: none; }
.vd-header.sd-topbar .vd-header__logout {
  border: 1px solid hsl(var(--sd-border)); border-radius: var(--sd-radius-sm);
  padding: 6px 11px; font-size: 12px; font-weight: 600; color: hsl(var(--sd-muted-foreground));
}
.vd-header.sd-topbar .vd-header__logout:hover { background: hsl(var(--sd-accent)); color: hsl(var(--sd-foreground)); }

.sd-topbar__left, .sd-topbar__right { display: flex; align-items: center; gap: 10px; min-width: 0; }
.sd-topbar__left { flex-shrink: 0; }
.sd-topbar__right { margin-left: auto; }
.sd-topbar__search { display: flex; align-items: center; gap: 8px; width: min(340px, 30vw); height: 34px; padding: 0 10px; border-radius: var(--sd-radius-sm); background: hsl(var(--sd-muted)); border: 1px solid hsl(var(--sd-border)); color: hsl(var(--sd-muted-foreground)); }
.sd-topbar__search:focus-within { outline: 2px solid hsl(var(--sd-ring) / .3); outline-offset: 1px; }
.sd-topbar__search input { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; font-size: 12px; color: hsl(var(--sd-foreground)); }
.sd-topbar__search input::placeholder { color: hsl(var(--sd-muted-foreground)); }
.sd-topbar__search kbd { font: inherit; font-size: 10px; padding: 2px 6px; border-radius: 5px; border: 1px solid hsl(var(--sd-border)); background: hsl(var(--sd-card)); color: hsl(var(--sd-muted-foreground)); }
.sd-icon-btn { position: relative; width: 34px; height: 34px; display: grid; place-items: center; border: 1px solid transparent; border-radius: var(--sd-radius-sm); background: transparent; color: hsl(var(--sd-muted-foreground)); }
.sd-icon-btn:hover { background: hsl(var(--sd-accent)); color: hsl(var(--sd-foreground)); }
.sd-topbar__sep { width: 1px; height: 22px; background: hsl(var(--sd-border)); }
.sd-account { display: flex; align-items: center; gap: 9px; border: 0; background: transparent; color: hsl(var(--sd-foreground)); padding: 4px 6px; border-radius: var(--sd-radius-sm); }
.sd-account:hover { background: hsl(var(--sd-accent)); }
.sd-avatar { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; background: hsl(var(--sd-primary-soft)); color: hsl(var(--sd-primary)); font-size: 12px; font-weight: 700; }
.sd-account__txt { display: flex; flex-direction: column; align-items: flex-start; line-height: 1.25; }
.sd-account__txt b { font-size: 12px; font-weight: 600; }
.sd-account__txt small { font-size: 10px; color: hsl(var(--sd-muted-foreground)); }

/* ── 侧边栏 ───────────────────────────────────────────────────────────── */
.vd-shell.sd-shell { grid-template-columns: 216px minmax(0, 1fr); gap: 24px; padding: 24px 24px 56px; }
.vd-sidebar.sd-sidebar { top: 84px; gap: 2px; padding: 14px 10px; border-right: 1px solid hsl(var(--sd-border)); background: transparent; }
.vd-sidebar.sd-sidebar > .sd-nav {
  display: flex; align-items: center; gap: 10px; min-height: 38px; padding: 0 12px;
  border: 1px solid transparent; border-radius: var(--sd-radius-sm);
  background: transparent; color: hsl(var(--sd-muted-foreground));
  font-size: 13px; font-weight: 500; letter-spacing: 0; text-transform: none;
  white-space: nowrap; text-align: left;
}
.vd-sidebar.sd-sidebar > .sd-nav:hover { background: hsl(var(--sd-accent)); color: hsl(var(--sd-foreground)); }
.vd-sidebar.sd-sidebar > .sd-nav.active,
.vd-sidebar.sd-sidebar > .sd-nav.active.bg-blue-600,
.vd-sidebar.sd-sidebar > .sd-nav.active.text-white {
  background: hsl(var(--sd-primary-soft)) !important;
  color: hsl(var(--sd-primary)) !important;
  border-color: hsl(var(--sd-primary) / .16);
}
.vd-sidebar.sd-sidebar > .sd-nav .sd-ico { color: currentColor; }
.sd-nav-group { padding: 14px 12px 6px; font-size: 10px; font-weight: 600; letter-spacing: .12em; text-transform: uppercase; color: hsl(var(--sd-muted-foreground)); }
.vd-sidebar.sd-sidebar > hr { display: none; }
.vd-sidebar.sd-sidebar > a.sd-nav {
  display: flex; align-items: center; gap: 10px; min-height: 38px; padding: 0 12px;
  border-radius: var(--sd-radius-sm); font-size: 13px; font-weight: 500;
  color: hsl(var(--sd-muted-foreground)); text-decoration: none;
}
.vd-sidebar.sd-sidebar > a.sd-nav:hover { background: hsl(var(--sd-accent)); color: hsl(var(--sd-foreground)); }
.sd-nav__badge { margin-left: auto; font-size: 10px; padding: 1px 6px; border-radius: 999px; background: hsl(var(--sd-muted)); color: hsl(var(--sd-muted-foreground)); }
.sd-sidebar__foot { margin-top: auto; padding: 14px 12px 4px; font-size: 10px; line-height: 1.6; color: hsl(var(--sd-muted-foreground)); border-top: 1px solid hsl(var(--sd-border)); }

/* ── 主区 ─────────────────────────────────────────────────────────────── */
.vd-main.sd-main { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.vd-overview.sd-overview { gap: 16px; }
.vd-main.sd-main > .hidden, .vd-main.sd-main > [hidden] { display: none !important; }

.sd-welcome { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; flex-wrap: wrap; }
.sd-eyebrow { font-size: 11px; color: hsl(var(--sd-muted-foreground)); }
.sd-welcome h1 { margin: 5px 0 0; font-size: 25px; font-weight: 650; letter-spacing: -.03em; line-height: 1.25; color: hsl(var(--sd-foreground)); }
.sd-welcome p { margin: 5px 0 0; font-size: 13px; color: hsl(var(--sd-muted-foreground)); }
.sd-welcome__actions { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; }

.sd-segmented { display: inline-flex; gap: 2px; padding: 3px; border-radius: 10px; background: hsl(var(--sd-muted)); border: 1px solid hsl(var(--sd-border)); }
.sd-segmented button { border: 0; background: transparent; color: hsl(var(--sd-muted-foreground)); font-size: 12px; font-weight: 500; padding: 6px 12px; border-radius: 7px; white-space: nowrap; }
.sd-segmented button.is-active { background: hsl(var(--sd-card)); color: hsl(var(--sd-foreground)); box-shadow: var(--sd-shadow-sm); }
.sd-btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; height: 36px; padding: 0 13px; border-radius: 9px; font-size: 12px; font-weight: 600; border: 1px solid transparent; white-space: nowrap; }
.sd-btn--primary { background: hsl(var(--sd-primary)); color: hsl(var(--sd-primary-foreground)); }
.sd-btn--primary:hover { filter: brightness(.95); }
.sd-btn--warm { background: hsl(var(--sd-warm)); color: #2b1a02; }
.sd-btn--warm:hover { filter: brightness(.96); }
.sd-btn--ghost { background: hsl(var(--sd-card)); border-color: hsl(var(--sd-border)); color: hsl(var(--sd-foreground)); }
.sd-btn--ghost:hover { background: hsl(var(--sd-accent)); }

/* ── 卡片通用 ─────────────────────────────────────────────────────────── */
.sd-card { background: hsl(var(--sd-card)); color: hsl(var(--sd-card-foreground)); border: 1px solid hsl(var(--sd-border)); border-radius: var(--sd-radius); box-shadow: var(--sd-shadow-sm); min-width: 0; }
.sd-card--narrow { max-width: 860px; }
.sd-card__head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 16px 18px 0; }
.sd-card__head h2, .sd-card__head h3 { margin: 0; font-size: 14px; font-weight: 600; letter-spacing: -.01em; }
.sd-card__head p { margin: 3px 0 0; font-size: 11px; color: hsl(var(--sd-muted-foreground)); }
/* 卡片主标题（不放在 .sd-card__head 里时用，例如左侧标题 + 右侧按钮的布局）*/
.sd-card__title { margin: 0; font-size: 15.5px; font-weight: 650; letter-spacing: -.02em; color: hsl(var(--sd-foreground)); }
.sd-card__foot { display: flex; flex-wrap: wrap; gap: 18px; padding: 0 18px 14px; font-size: 11px; color: hsl(var(--sd-muted-foreground)); }
.sd-card__foot b { color: hsl(var(--sd-foreground)); font-weight: 600; }
.sd-more { border: 0; background: transparent; color: hsl(var(--sd-muted-foreground)); width: 26px; height: 26px; border-radius: 6px; display: grid; place-items: center; }
.sd-more:hover { background: hsl(var(--sd-accent)); }
.sd-pill { font-size: 10px; font-weight: 500; padding: 4px 9px; border-radius: 999px; background: hsl(var(--sd-muted)); color: hsl(var(--sd-muted-foreground)); border: 1px solid hsl(var(--sd-border)); white-space: nowrap; }
.sd-legend { display: flex; gap: 14px; font-size: 11px; color: hsl(var(--sd-muted-foreground)); white-space: nowrap; }
.sd-legend__item { display: inline-flex; align-items: center; gap: 6px; }
.sd-legend__swatch { width: 8px; height: 8px; border-radius: 3px; display: inline-block; }

/* ── Key 状态四联 KPI（点击即筛选 Key 表格）───────────────────────────── */
.sd-kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.sd-kpi {
  position: relative; display: flex; flex-direction: column; gap: 3px;
  min-width: 0; padding: 14px 16px 13px; text-align: left;
  background: hsl(var(--sd-card)); color: hsl(var(--sd-card-foreground));
  border: 1px solid hsl(var(--sd-border)); border-radius: var(--sd-radius);
  box-shadow: var(--sd-shadow-sm); cursor: pointer;
  transition: border-color .15s ease, box-shadow .15s ease, transform .15s ease;
}
.sd-kpi:hover { border-color: hsl(var(--sd-ring) / .45); box-shadow: var(--sd-shadow-md); transform: translateY(-1px); }
.sd-kpi:focus-visible { outline: 2px solid hsl(var(--sd-ring)); outline-offset: 2px; }
.sd-kpi.is-on { border-color: var(--sd-kpi-color); box-shadow: 0 0 0 2px var(--sd-kpi-color-soft); }
.sd-kpi__top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.sd-kpi__label { display: inline-flex; align-items: center; gap: 7px; font-size: 12px; font-weight: 500; color: hsl(var(--sd-muted-foreground)); }
.sd-kpi__dot { width: 7px; height: 7px; border-radius: 50%; background: var(--sd-kpi-color); flex-shrink: 0; }
.sd-kpi__hint { font-size: 10px; color: hsl(var(--sd-muted-foreground)); opacity: .8; }
.sd-kpi__value { font-size: 26px; font-weight: 650; letter-spacing: -.03em; line-height: 1.2; font-variant-numeric: tabular-nums; color: var(--sd-kpi-color); }
.sd-kpi__sub { font-size: 11px; color: hsl(var(--sd-muted-foreground)); }
.sd-kpi__bar { height: 5px; border-radius: 999px; background: hsl(var(--sd-muted)); overflow: hidden; margin-top: 6px; }
.sd-kpi__bar i { display: block; height: 100%; border-radius: 999px; background: var(--sd-kpi-color); }

/* ── 辅助栅格行 ───────────────────────────────────────────────────────── */
.sd-row { display: grid; grid-template-columns: minmax(0, 1.85fr) minmax(280px, 1fr); gap: 14px; align-items: stretch; }
.sd-col { display: flex; flex-direction: column; gap: 14px; min-width: 0; }

.sd-chart { padding: 12px 12px 0; height: 178px; }
.sd-chart svg { display: block; width: 100%; height: 100%; overflow: visible; }
.sd-axis { display: flex; justify-content: space-between; padding: 0 18px 4px; font-size: 10px; color: hsl(var(--sd-muted-foreground)); }

.sd-usage { padding: 16px 18px 18px; display: flex; flex-direction: column; gap: 12px; }
.sd-usage__nums { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.sd-usage__num { padding: 10px 12px; border-radius: var(--sd-radius-sm); background: hsl(var(--sd-muted)); border: 1px solid hsl(var(--sd-border)); }
.sd-usage__num span { display: block; font-size: 10px; color: hsl(var(--sd-muted-foreground)); }
.sd-usage__num b { display: block; margin-top: 3px; font-size: 17px; font-weight: 650; letter-spacing: -.02em; font-variant-numeric: tabular-nums; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sd-usage__ring { display: flex; align-items: center; gap: 14px; }
.sd-ring { position: relative; width: 92px; height: 92px; border-radius: 50%; flex-shrink: 0; display: grid; place-items: center; background: conic-gradient(hsl(var(--sd-primary)) 0 var(--sd-p1, 0%), hsl(var(--sd-warm)) var(--sd-p1, 0%) var(--sd-p2, 0%), hsl(var(--sd-border)) var(--sd-p2, 0%) 100%); }
.sd-ring::after { content: ""; position: absolute; width: 62px; height: 62px; border-radius: 50%; background: hsl(var(--sd-card)); }
.sd-ring__inner { position: absolute; z-index: 1; text-align: center; line-height: 1.15; }
.sd-ring__inner b { display: block; font-size: 17px; font-weight: 650; font-variant-numeric: tabular-nums; }
.sd-ring__inner span { font-size: 9px; color: hsl(var(--sd-muted-foreground)); }
.sd-usage__legend { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 7px; font-size: 11px; }
.sd-usage__legend div { display: flex; align-items: center; gap: 7px; }
.sd-usage__legend i { width: 8px; height: 8px; border-radius: 3px; flex-shrink: 0; }
.sd-usage__legend span { flex: 1; min-width: 0; color: hsl(var(--sd-muted-foreground)); }
.sd-usage__legend b { font-weight: 600; font-variant-numeric: tabular-nums; }

.sd-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.sd-table th { text-align: left; padding: 9px 18px; font-size: 10px; font-weight: 600; letter-spacing: .06em; color: hsl(var(--sd-muted-foreground)); text-transform: uppercase; border-bottom: 1px solid hsl(var(--sd-border)); }
.sd-table td { padding: 10px 18px; border-bottom: 1px solid hsl(var(--sd-border)); }
.sd-table tbody tr:last-child td { border-bottom: 0; }
.sd-table tbody tr:hover { background: hsl(var(--sd-muted) / .6); }
.sd-table__muted { color: hsl(var(--sd-muted-foreground)); }
.sd-table__mono { font-variant-numeric: tabular-nums; }
.sd-status { display: inline-flex; align-items: center; gap: 6px; padding: 3px 9px; border-radius: 999px; font-size: 11px; font-weight: 500; white-space: nowrap; }
.sd-status i { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.sd-status.is-online { background: hsl(var(--sd-success-soft)); color: hsl(var(--sd-success)); }
.sd-status.is-idle { background: hsl(var(--sd-warning-soft)); color: hsl(var(--sd-warning)); }
.sd-status.is-off { background: hsl(var(--sd-muted)); color: hsl(var(--sd-muted-foreground)); }
.sd-live-dot { display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: hsl(var(--sd-success)); margin-right: 7px; box-shadow: 0 0 0 3px hsl(var(--sd-success) / .14); }

.sd-quick { padding: 16px 18px 18px; }
.sd-quick__row { margin-top: 11px; }
.sd-quick__label { font-size: 11px; color: hsl(var(--sd-muted-foreground)); margin-bottom: 5px; }
.sd-code { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 10px; border-radius: var(--sd-radius-sm); background: hsl(var(--sd-muted)); border: 1px solid hsl(var(--sd-border)); font-size: 11px; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; word-break: break-all; }
.sd-code .sd-ico { color: hsl(var(--sd-muted-foreground)); }
.sd-quick__link { display: inline-flex; align-items: center; gap: 6px; margin-top: 13px; font-size: 11px; font-weight: 600; color: hsl(var(--sd-primary)); }

.sd-region-mini { padding: 16px 18px 18px; }
.sd-region-mini__row { margin-top: 10px; }
.sd-region-mini__top { display: flex; justify-content: space-between; font-size: 11px; margin-bottom: 5px; }
.sd-region-mini__top b { font-weight: 600; font-variant-numeric: tabular-nums; }
.sd-region-mini__bar { height: 6px; border-radius: 999px; background: hsl(var(--sd-muted)); overflow: hidden; }
.sd-region-mini__bar i { display: block; height: 100%; border-radius: 999px; background: hsl(var(--sd-primary)); }

/* ── 资源管理区标题 / Key 面板上提 ────────────────────────────────────── */
.sd-section-title { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; padding-top: 4px; }
.sd-section-title h2 { margin: 0; font-size: 17px; font-weight: 600; letter-spacing: -.02em; }
.sd-section-title p { margin: 4px 0 0; font-size: 12px; color: hsl(var(--sd-muted-foreground)); }

/* 左列已被 vendor-dashboard.css 设为 display:contents，子元素直接参与
   .vd-management 的 flex 排序；用 order 把「设备 Key」提到「项目与配置」之前。 */
.vd-management.sd-management { gap: 14px; }
.vd-management.sd-management > .lg\:col-span-2 > .vd-key-panel { order: -1; }
.vd-management.sd-management > .lg\:col-span-2 > #sd-projects-heading { order: 1; }
.vd-management.sd-management > .lg\:col-span-2 > #projects-config { order: 2; }
.vd-management.sd-management > .lg\:col-span-2 > #project-pager { order: 3; }
/* ⚠️ details 是 .vd-management 的直接子元素（左列 .lg\:col-span-2 在它之前就已闭合）。
   两个选择器都留着，防止将来结构再被挪进左列时 order/width 静默失效。 */
.vd-management.sd-management > .vd-support,
.vd-management.sd-management > .lg\:col-span-2 > .vd-support { order: 4; flex: 1 1 100%; width: 100%; min-width: 0; align-self: stretch; }
.sd-subheading { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-top: 6px; }
.sd-subheading h3 { margin: 0; font-size: 14px; font-weight: 600; }
.sd-subheading p { margin: 3px 0 0; font-size: 11px; color: hsl(var(--sd-muted-foreground)); }

/* ── 设备 Key 面板（核心区：可读性优先）───────────────────────────────── */
.vd-key-panel.sd-key-panel { padding: 18px; border-radius: var(--sd-radius); box-shadow: var(--sd-shadow-sm); }
.vd-key-panel.sd-key-panel .vd-section-heading { margin-bottom: 14px; }
.sd-key-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.sd-key-head__title { display: flex; align-items: center; gap: 9px; }
.sd-key-head__mark { width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; background: hsl(var(--sd-primary-soft)); color: hsl(var(--sd-primary)); }
.sd-key-head h2 { margin: 0; font-size: 15px; font-weight: 650; letter-spacing: -.01em; }
.sd-key-head p { margin: 2px 0 0; font-size: 11px; color: hsl(var(--sd-muted-foreground)); }

.vd-key-panel.sd-key-panel #key-section-header { justify-content: flex-start !important; margin-bottom: 10px !important; }
.vd-key-panel.sd-key-panel #key-filter-bar { width: 100%; gap: 8px; }
.vd-key-panel.sd-key-panel #key-filter-bar > select,
.vd-key-panel.sd-key-panel #key-filter-bar > button { height: 34px; border: 1px solid hsl(var(--sd-border)); border-radius: var(--sd-radius-sm); background: hsl(var(--sd-card)); color: hsl(var(--sd-muted-foreground)); font-size: 12px; font-weight: 500; padding: 0 10px; }
.vd-key-panel.sd-key-panel #key-search { height: 34px; border: 1px solid hsl(var(--sd-border)) !important; border-radius: var(--sd-radius-sm); font-size: 12px; padding-left: 32px; background: hsl(var(--sd-card)); color: hsl(var(--sd-foreground)); }
.vd-key-panel.sd-key-panel #key-search:focus { border-color: hsl(var(--sd-ring)) !important; outline: 2px solid hsl(var(--sd-ring) / .25); }
.vd-key-panel.sd-key-panel #key-filter-bar > .relative { flex: 1 1 240px; max-width: 380px; }
.sd-search-clear { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); border: 0; background: transparent; color: hsl(var(--sd-muted-foreground)); font-size: 15px; line-height: 1; padding: 2px 4px; cursor: pointer; display: none; }
.sd-search-clear.is-visible { display: block; }

.vd-key-panel.sd-key-panel #key-bulk-bar { flex-direction: row; align-items: center; flex-wrap: wrap; gap: 10px; padding: 9px 12px; border: 1px solid hsl(var(--sd-border)); border-radius: var(--sd-radius-sm); background: hsl(var(--sd-muted) / .6); margin-bottom: 12px; transition: background .15s ease, border-color .15s ease; }
.vd-key-panel.sd-key-panel #key-bulk-bar.has-selection { background: hsl(var(--sd-primary-soft)); border-color: hsl(var(--sd-primary) / .35); }
.vd-key-panel.sd-key-panel #selected-count { font-size: 11px; font-weight: 600; color: hsl(var(--sd-muted-foreground)); letter-spacing: 0; text-transform: none; }
.vd-key-panel.sd-key-panel #key-bulk-bar.has-selection #selected-count { color: hsl(var(--sd-primary)); }
.vd-key-panel.sd-key-panel #key-bulk-actions { gap: 7px; }
.vd-key-panel.sd-key-panel .bulk-action-btn { height: 30px; border-radius: var(--sd-radius-sm); font-size: 11px; font-weight: 600; }

.vd-key-panel.sd-key-panel table { min-width: 940px; }
.vd-key-panel.sd-key-panel table thead { background: hsl(var(--sd-muted)); }
.vd-key-panel.sd-key-panel table th { padding: 10px 12px; font-size: 10px; font-weight: 600; letter-spacing: .05em; text-transform: uppercase; color: hsl(var(--sd-muted-foreground)); border-bottom: 1px solid hsl(var(--sd-border)); }
.vd-key-panel.sd-key-panel table td { padding: 11px 12px; border-top: 1px solid hsl(var(--sd-border)); color: hsl(var(--sd-foreground)); font-size: 12px; vertical-align: middle; }
.vd-key-panel.sd-key-panel table tr:hover td { background: hsl(var(--sd-muted) / .55); }
.vd-key-panel.sd-key-panel table td:nth-child(2) .font-mono { font-size: 12px; letter-spacing: -.01em; }
.vd-key-panel.sd-key-panel table td:nth-child(2) > div:last-child { font-size: 10px !important; letter-spacing: .02em; }
.vd-key-panel.sd-key-panel table td:nth-child(4) > div { font-size: 11px !important; }
.vd-key-panel.sd-key-panel table td:nth-child(5) { font-size: 11px !important; font-weight: 500; text-transform: none; letter-spacing: 0; color: hsl(var(--sd-muted-foreground)); }
.vd-key-panel.sd-key-panel table .key-action-btn { min-width: 66px; height: 26px; font-size: 10px; border-radius: var(--sd-radius-sm); }
.vd-key-panel.sd-key-panel table td:nth-child(6) button:first-child { border-radius: var(--sd-radius-sm); padding: 5px 9px; }
.vd-key-panel.sd-key-panel .device-checkbox { width: 15px; height: 15px; accent-color: hsl(var(--sd-primary)); }
.vd-key-panel.sd-key-panel #key-pagination-info { font-size: 11px; }
.vd-key-panel.sd-key-panel #key-btn-prev,
.vd-key-panel.sd-key-panel #key-btn-next { border: 1px solid hsl(var(--sd-border)); border-radius: var(--sd-radius-sm); padding: 5px 10px; font-size: 11px; background: hsl(var(--sd-card)); color: hsl(var(--sd-foreground)); }

/* 状态徽章（五态口径沿用 JS 里的 KD_STATE，这里只统一外观） */
.sd-state-badge { display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; border-radius: 999px; font-size: 11px; font-weight: 600; white-space: nowrap; }
.sd-state-badge i { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.sd-online-dot { display: inline-flex; align-items: center; gap: 5px; margin-top: 5px; font-size: 10px; font-weight: 600; color: hsl(var(--sd-muted-foreground)); }
.sd-online-dot i { width: 6px; height: 6px; border-radius: 50%; background: hsl(var(--sd-border)); }
.sd-online-dot.is-online { color: hsl(var(--sd-success)); }
.sd-online-dot.is-online i { background: hsl(var(--sd-success)); }

/* ── 项目与配置 / 更多运营工具 ────────────────────────────────────────── */
.vd-projects.sd-projects > div { border-radius: var(--sd-radius) !important; box-shadow: var(--sd-shadow-sm) !important; }
.vd-support.sd-support > summary { padding: 13px 2px; font-size: 13px; color: hsl(var(--sd-muted-foreground)); border-top: 1px solid hsl(var(--sd-border)); }
.vd-support.sd-support[open] > summary { margin-bottom: 14px; }
/* 折叠区内只有「资源商城 + 接入代码」两张卡，单列更实用（商城内部套餐卡自己会自适应列数） */
.vd-support.sd-support .vd-support__content { grid-template-columns: minmax(0, 1fr); gap: 14px; }
.vd-support.sd-support .vd-support__content { gap: 14px; }
.vd-support.sd-support .vd-support__content > .space-y-6 > div { border-radius: var(--sd-radius) !important; box-shadow: var(--sd-shadow-sm) !important; }
.vd-section-heading.sd-hidden, .sd-hidden { display: none; }

/* ── 终端客户地域分布（首屏替代原「实时运行流」）───────────────────────── */
.sd-region-card { display: flex; flex-direction: column; min-width: 0; }
.sd-region-card .sd-card__head { align-items: center; flex-wrap: wrap; padding-bottom: 4px; }
.sd-segmented--sm button { font-size: 11px; padding: 5px 11px; }
.sd-region-body { display: flex; flex-direction: column; gap: 12px; padding: 12px 18px 16px; }
.sd-region-kpis { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.sd-region-kpi { padding: 10px 6px; text-align: center; border-radius: var(--sd-radius-sm); background: hsl(var(--sd-muted)); border: 1px solid hsl(var(--sd-border)); }
.sd-region-kpi b { display: block; font-size: 18px; font-weight: 650; line-height: 1.15; letter-spacing: -.02em; font-variant-numeric: tabular-nums; color: hsl(var(--sd-foreground)); }
.sd-region-kpi span { display: block; margin-top: 3px; font-size: 10px; color: hsl(var(--sd-muted-foreground)); }
.sd-region-list { display: grid; gap: 1px; }
.sd-region-row {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 7px 8px; border: 0; border-radius: var(--sd-radius-sm);
  background: transparent; color: inherit; text-align: left; cursor: pointer;
  font: inherit;
}
.sd-region-row:hover { background: hsl(var(--sd-accent)); }
.sd-region-row:focus-visible { outline: 2px solid hsl(var(--sd-ring)); outline-offset: 1px; }
.sd-region-row__name { width: 52px; flex-shrink: 0; font-size: 12px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sd-region-row__bar { flex: 1; min-width: 0; height: 6px; border-radius: 999px; background: hsl(var(--sd-muted)); overflow: hidden; }
.sd-region-row__bar i { display: block; height: 100%; border-radius: 999px; background: linear-gradient(90deg, hsl(var(--sd-primary) / .5), hsl(var(--sd-primary))); }
.sd-region-row__val { flex-shrink: 0; display: inline-flex; align-items: center; gap: 5px; font-size: 11px; font-weight: 600; font-variant-numeric: tabular-nums; }
.sd-region-row__delta { font-size: 9px; font-weight: 700; font-style: normal; }
.sd-region-row__delta.is-up { color: hsl(var(--sd-success)); }
.sd-region-row__delta.is-down { color: hsl(var(--sd-danger)); }
.sd-region-row.is-special { opacity: .55; }
.sd-region-foot { font-size: 10px; line-height: 1.6; color: hsl(var(--sd-muted-foreground)); }
.sd-region-empty { padding: 20px 14px; text-align: center; font-size: 11px; line-height: 1.7; border: 1px dashed hsl(var(--sd-border)); border-radius: var(--sd-radius-sm); background: hsl(var(--sd-muted) / .5); color: hsl(var(--sd-muted-foreground)); }
.sd-region-empty.is-error { color: hsl(var(--sd-danger)); }

/* ── 资源商城 / 套餐卡 ─────────────────────────────────────────────────── */
.sd-mall { overflow: hidden; grid-column: 1 / -1; }
.sd-mall__head { display: flex; flex-direction: column; gap: 12px; padding: 16px 18px 14px; border-bottom: 1px solid hsl(var(--sd-border)); background: hsl(var(--sd-muted) / .45); }
.sd-mall__title { display: flex; align-items: center; gap: 11px; min-width: 0; }
.sd-mall__mark { width: 34px; height: 34px; flex-shrink: 0; display: grid; place-items: center; border-radius: 10px; background: hsl(var(--sd-primary)); color: hsl(var(--sd-primary-foreground)); }
.sd-mall__title h3 { margin: 0; font-size: 15px; font-weight: 650; letter-spacing: -.01em; }
.sd-mall__title p { margin: 2px 0 0; font-size: 11px; line-height: 1.5; color: hsl(var(--sd-muted-foreground)); }
.sd-mall__target { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; }
.sd-mall__target > span { font-size: 10px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: hsl(var(--sd-muted-foreground)); white-space: nowrap; }
.sd-mall__target select { flex: 1; min-width: 180px; height: 34px; padding: 0 10px; border: 1px solid hsl(var(--sd-border)); border-radius: var(--sd-radius-sm); background: hsl(var(--sd-card)); color: hsl(var(--sd-foreground)); font-size: 12px; font-weight: 500; cursor: pointer; }
.sd-plans { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 12px; padding: 16px 18px 18px; }
.sd-plan { display: flex; flex-direction: column; gap: 11px; padding: 16px; border: 1px solid hsl(var(--sd-border)); border-radius: var(--sd-radius); background: hsl(var(--sd-card)); box-shadow: var(--sd-shadow-sm); transition: border-color .18s, box-shadow .18s, transform .18s; }
.sd-plan:hover { border-color: hsl(var(--sd-ring) / .5); box-shadow: var(--sd-shadow-md); transform: translateY(-2px); }
.sd-plan__tags { display: flex; gap: 6px; flex-wrap: wrap; }
.sd-plan__badge { display: inline-flex; align-items: center; padding: 2px 8px; border-radius: 999px; font-size: 9px; font-weight: 600; white-space: nowrap; }
.sd-plan__badge.is-blue { background: hsl(var(--sd-primary-soft)); color: hsl(var(--sd-primary)); }
.sd-plan__badge.is-green { background: hsl(var(--sd-success-soft)); color: hsl(var(--sd-success)); }
.sd-plan__name { margin: 0; font-size: 15px; font-weight: 650; line-height: 1.35; letter-spacing: -.01em; color: hsl(var(--sd-foreground)); }
.sd-plan__desc { margin: 0; font-size: 11px; line-height: 1.6; color: hsl(var(--sd-muted-foreground)); }
.sd-plan__tip span { cursor: help; font-size: 10px; font-weight: 600; color: hsl(var(--sd-muted-foreground)); border-bottom: 1px dashed hsl(var(--sd-border)); }
.sd-plan__price { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 11px 13px; border-radius: var(--sd-radius-sm); background: hsl(var(--sd-primary-soft)); }
.sd-plan__price-num { display: inline-flex; align-items: baseline; gap: 1px; font-size: 26px; font-weight: 700; line-height: 1; letter-spacing: -.02em; color: hsl(var(--sd-primary)); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.sd-plan__price-num i { font-size: 14px; font-style: normal; }
.sd-plan__unit { font-size: 10px; font-weight: 500; text-align: right; color: hsl(var(--sd-muted-foreground)); }
.sd-plan__rows { display: flex; flex-direction: column; }
.sd-plan__row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 7px 0; border-top: 1px dashed hsl(var(--sd-border)); }
.sd-plan__row.is-first { border-top: 0; }
.sd-plan__row > span { font-size: 11px; font-weight: 500; white-space: nowrap; color: hsl(var(--sd-muted-foreground)); }
.sd-plan__row > b { font-size: 12px; font-weight: 600; text-align: right; color: hsl(var(--sd-foreground)); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.sd-plan__row > b.is-green { color: hsl(var(--sd-success)); }
.sd-plan__foot { margin-top: auto; display: flex; flex-direction: column; gap: 10px; padding-top: 2px; }
.sd-plan__qtyline { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.sd-qty { display: inline-flex; align-items: center; border: 1px solid hsl(var(--sd-border)); border-radius: var(--sd-radius-sm); overflow: hidden; }
.sd-qty button { width: 32px; height: 32px; border: 0; background: hsl(var(--sd-muted)); color: hsl(var(--sd-muted-foreground)); font-size: 15px; font-weight: 600; cursor: pointer; }
.sd-qty button:hover { background: hsl(var(--sd-accent)); color: hsl(var(--sd-foreground)); }
.sd-qty input { width: 46px; height: 32px; box-sizing: border-box; border: 0; border-inline: 1px solid hsl(var(--sd-border)); background: hsl(var(--sd-card)); color: hsl(var(--sd-foreground)); text-align: center; font-size: 13px; font-weight: 600; outline: none; -moz-appearance: textfield; }
.sd-qty input::-webkit-outer-spin-button, .sd-qty input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.sd-plan__total { font-size: 11px; white-space: nowrap; color: hsl(var(--sd-muted-foreground)); }
.sd-plan__total b { font-size: 15px; font-weight: 700; color: hsl(var(--sd-primary)); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.sd-plan__buy { width: 100%; height: 38px; border: 0; border-radius: var(--sd-radius-sm); background: hsl(var(--sd-primary)); color: hsl(var(--sd-primary-foreground)); font-size: 13px; font-weight: 600; cursor: pointer; transition: filter .15s ease, transform .1s ease; }
.sd-plan__buy:hover { filter: brightness(.94); }
.sd-plan__buy:active { transform: translateY(1px); }
.sd-plan__buy:focus-visible { outline: 2px solid hsl(var(--sd-ring)); outline-offset: 2px; }
.sd-plan-empty { grid-column: 1 / -1; padding: 30px 20px; text-align: center; border: 1px dashed hsl(var(--sd-border)); border-radius: var(--sd-radius); }
.sd-plan-empty b { display: block; font-size: 13px; font-weight: 600; color: hsl(var(--sd-muted-foreground)); }
.sd-plan-empty span { display: block; margin-top: 6px; font-size: 11px; color: hsl(var(--sd-muted-foreground)); opacity: .8; }

/* ── 接入代码卡（替代原先依赖 nth-child 的深色代码块）─────────────────── */
.sd-integration { padding: 16px 18px 18px; grid-column: 1 / -1; }
.sd-integration__head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.sd-integration__head h3 { margin: 0; font-size: 14px; font-weight: 650; letter-spacing: -.01em; }
.sd-integration__head span { font-size: 11px; color: hsl(var(--sd-muted-foreground)); }
.sd-integration__body { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 12px; }
.sd-integration__body > div { min-width: 0; }
.sd-integration__body p { margin: 0 0 5px; font-size: 10px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: hsl(var(--sd-muted-foreground)); }
.sd-integration__body code { display: block; padding: 8px 10px; border-radius: var(--sd-radius-sm); background: hsl(var(--sd-muted)); border: 1px solid hsl(var(--sd-border)); font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 11px; color: hsl(var(--sd-foreground)); word-break: break-all; }
.sd-integration__body > a { grid-column: 1 / -1; display: inline-flex; align-items: center; justify-content: center; height: 34px; border: 1px solid hsl(var(--sd-border)); border-radius: var(--sd-radius-sm); font-size: 11px; font-weight: 600; color: hsl(var(--sd-foreground)); text-decoration: none; }
.sd-integration__body > a:hover { background: hsl(var(--sd-accent)); }
@media (max-width: 700px) { .sd-integration__body { grid-template-columns: 1fr; } }

/* ── 深色主题补丁 ─────────────────────────────────────────────────────────
   vendor-dashboard.css 用的是固定色变量（--vd-ink / --vd-surface / #fff），
   不随 data-sd-theme 变化；存量模板里也还有内联硬编码的浅色。
   这里只针对「深色下会真的看不清」的元素做定点覆盖，浅色不受影响。 */

/* 顶栏品牌名 / 账户信息用的是 --vd-ink（固定深色） */
html[data-sd-theme="dark"] .vd-brand,
html[data-sd-theme="dark"] .vd-brand__name,
html[data-sd-theme="dark"] .vd-header__account strong { color: hsl(var(--sd-foreground)); }
html[data-sd-theme="dark"] .vd-header__account,
html[data-sd-theme="dark"] .vd-header__account small { color: hsl(var(--sd-muted-foreground)); }
html[data-sd-theme="dark"] .vd-header.sd-topbar .vd-header__logout { color: hsl(var(--sd-muted-foreground)); }

/* 面板 / 项目卡 / 折叠区容器：vendor 里固定 #fff */
html[data-sd-theme="dark"] .vd-panel,
html[data-sd-theme="dark"] .vd-projects > div { background: hsl(var(--sd-card)); border-color: hsl(var(--sd-border)); }
html[data-sd-theme="dark"] .vd-key-panel.sd-key-panel table thead { background: hsl(var(--sd-muted)); }

/* Key 表格：vendor 用 --vd-ink 固定深色写死了首列的 Key 文案 */
html[data-sd-theme="dark"] .vd-key-panel table td { color: hsl(var(--sd-foreground)); border-color: hsl(var(--sd-border)); }
html[data-sd-theme="dark"] .vd-key-panel table td:nth-child(2) .font-mono { color: hsl(var(--sd-foreground)) !important; }
html[data-sd-theme="dark"] .vd-key-panel table td:nth-child(5) { color: hsl(var(--sd-muted-foreground)); }

/* 批量操作栏：Tailwind 的 bg-gray-50/80 是固定浅色，深色下会变成一条亮灰带 */
html[data-sd-theme="dark"] .vd-key-panel #key-bulk-bar { background: hsl(var(--sd-muted) / .55) !important; border-color: hsl(var(--sd-border)) !important; }
html[data-sd-theme="dark"] .vd-key-panel #key-bulk-bar .bulk-action-btn { background: hsl(var(--sd-card)) !important; border-color: hsl(var(--sd-border)) !important; }
html[data-sd-theme="dark"] .vd-key-panel #key-bulk-bar .factory-action-btn { border-color: hsl(var(--sd-danger) / .4) !important; color: hsl(var(--sd-danger)) !important; }
html[data-sd-theme="dark"] .vd-key-panel #selected-count { color: hsl(var(--sd-muted-foreground)); }

/* 行内操作按钮 / 分页 / 下拉：内联样式与 Tailwind 固定浅色 */
html[data-sd-theme="dark"] .vd-key-panel .key-action-btn { border-color: hsl(var(--sd-primary) / .35); background: hsl(var(--sd-primary-soft)); color: hsl(var(--sd-primary)); }
html[data-sd-theme="dark"] .vd-key-panel .key-action-btn:hover { background: hsl(var(--sd-primary) / .22); color: hsl(var(--sd-primary)); }
html[data-sd-theme="dark"] .vd-key-panel #key-btn-prev,
html[data-sd-theme="dark"] .vd-key-panel #key-btn-next,
html[data-sd-theme="dark"] .vd-key-panel #btn-export-project-keys { background: hsl(var(--sd-card)) !important; border-color: hsl(var(--sd-border)) !important; color: hsl(var(--sd-foreground)) !important; }
html[data-sd-theme="dark"] .vd-key-panel #key-filter-bar > select { background: hsl(var(--sd-card)); border-color: hsl(var(--sd-border)); color: hsl(var(--sd-foreground)); }
html[data-sd-theme="dark"] .sd-search-clear { color: hsl(var(--sd-muted-foreground)); }

/* 项目卡：结构在 2026-10-31 重写为 .sd-proj*（见第 23 段），下面的控件样式
   由语义类自己负责，这里不再兜底 —— 旧的 #projects-config / nth-child 补丁
   会以 !important 压掉新设计（尤其把度量块的凹槽又抬成 --sd-muted）。
   分页按钮仍沿用旧结构，单独保留在后面。 */

/* Key 表格「当前消耗 / 余额」列用的是 Tailwind 固定灰阶 */
html[data-sd-theme="dark"] .vd-key-panel table td:nth-child(4) .text-gray-700 { color: hsl(var(--sd-foreground)) !important; }
html[data-sd-theme="dark"] .vd-key-panel table td:nth-child(4) .text-gray-400,
html[data-sd-theme="dark"] .vd-key-panel table td:nth-child(4) .text-gray-300 { color: hsl(var(--sd-muted-foreground)) !important; }

/* 分页按钮：Tailwind bg-white 在深色下是白块，且 <button> 默认 color 是黑色 → 文字消失 */
html[data-sd-theme="dark"] #project-pager button { background: hsl(var(--sd-card)) !important; border-color: hsl(var(--sd-border)) !important; color: hsl(var(--sd-foreground)) !important; }
html[data-sd-theme="dark"] #project-pager button:disabled { opacity: .55 !important; }
html[data-sd-theme="dark"] #project-pager #proj-pagination-info { color: hsl(var(--sd-muted-foreground)); }

/* 批量操作按钮：未选中时是 disabled（opacity .35），深色下几乎看不见 → 提到 .5 并转中性色 */
html[data-sd-theme="dark"] .vd-key-panel #key-bulk-bar .bulk-action-btn:disabled { opacity: .7 !important; color: hsl(var(--sd-muted-foreground)) !important; }
html[data-sd-theme="dark"] .vd-key-panel #key-bulk-bar .bulk-action-btn:not(:disabled) { color: hsl(var(--sd-primary)) !important; }

/* ── 响应式：沿用现有 900 / 700 / 420 断点，避免与 vendor-dashboard.css 冲突 ── */
@media (max-width: 1180px) {
  .sd-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .sd-row { grid-template-columns: minmax(0, 1fr); }
  .sd-topbar__search { width: min(260px, 26vw); }
}
@media (max-width: 900px) {
  .vd-shell.sd-shell { grid-template-columns: 184px minmax(0, 1fr); gap: 18px; padding-inline: 16px; }
  .sd-topbar__search kbd { display: none; }
}
@media (max-width: 700px) {
  .vd-shell.sd-shell { display: block; padding: 18px 14px 40px; }
  .vd-header.sd-topbar .vd-header__inner { padding-inline: 14px; }
  .sd-topbar__search { display: none; }
  .sd-account__txt { display: none; }
  .vd-sidebar.sd-sidebar { position: fixed; z-index: 1001; inset: 0 auto 0 0; width: min(280px, 84vw); padding: 70px 12px 20px; background: hsl(var(--sd-card)); box-shadow: var(--sd-shadow-md); transform: translateX(-105%); visibility: hidden; transition: transform .2s ease-in-out, visibility .2s; }
  body.vd-menu-open .vd-sidebar.sd-sidebar { transform: translateX(0); visibility: visible; }
  .sd-welcome h1 { font-size: 22px; }
  .sd-welcome__actions { width: 100%; }
  .sd-segmented { flex: 1; }
  .sd-segmented button { flex: 1; padding: 6px 4px; }
  .sd-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; }
  .sd-kpi { padding: 12px; }
  .sd-kpi__value { font-size: 22px; }
  .sd-card__head { padding: 14px 14px 0; }
  .sd-card__foot { padding: 0 14px 12px; }
  .sd-table th, .sd-table td { padding: 9px 12px; }
  .vd-key-panel.sd-key-panel { padding: 14px; }
}
@media (max-width: 420px) {
  .sd-kpis { grid-template-columns: 1fr 1fr; gap: 8px; }
  .sd-kpi__hint { display: none; }
  .sd-usage__nums { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) {
  .sd-kpi { transition: none; }
  .sd-kpi:hover { transform: none; }
}

/* ══════════════════════════════════════════════════════════════════════════
   深色模式 · 全站兼容层（覆盖概览之外的 8 个 tab）
   --------------------------------------------------------------------------
   背景：概览 tab 用 .sd-* 组件，已经适配深色；其余 tab（账单 / 终端充值 /
   结算 / 账户 / API 集成 / 兑换码 / 文档）是存量模板，全部写死 Tailwind 浅色
   工具类（bg-white / text-gray-800 / border-gray-100 …）。
   深色主题只切换了 --sd-* 令牌与 body 前景色，这些固定值不跟着变，于是出现
   「白色卡片 + 浅色文字」，即反馈的「所有栏目颜色都不对」。

   做法：不逐个 tab 手写覆盖（8 个 tab、上百处），而是把模板里**真实出现过**的
   浅色工具类批量映射到 sd 令牌。类清单来自
   `grep class=` 的频次统计，不是凭空列的，别随手加用不到的。
   用 !important 是因为不少元素还带内联 style（内联非 important 会被样式表
   important 压过），这是唯一能同时命中两处的写法。

   注意：本段必须留在文件最后，保证级联顺序在 .sd-* 组件之后。
   ══════════════════════════════════════════════════════════════════════════ */

/* 语义化文字色令牌：浅色主题用深色调，深色主题用浅色调 */
:root {
  --sd-text-blue: 221 83% 45%;
  --sd-text-green: 142 72% 30%;
  --sd-text-amber: 28 88% 32%;
  --sd-text-red: 0 72% 45%;
  --sd-text-violet: 262 70% 45%;
  --sd-text-orange: 22 88% 36%;
}
html[data-sd-theme="dark"] {
  --sd-text-blue: 217 91% 72%;
  --sd-text-green: 142 60% 64%;
  --sd-text-amber: 38 92% 66%;
  --sd-text-red: 0 84% 72%;
  --sd-text-violet: 262 82% 74%;
  --sd-text-orange: 24 92% 66%;
}

/* 原生控件（滚动条 / select 下拉 / 日期面板 / 自动填充）跟随主题 */
html[data-sd-theme="dark"] { color-scheme: dark; }

/* 通用边框色兜底。
   用 :where() 把特异性压到 0，只压过 Tailwind preflight 的
   `*,::before,::after{border-color:#e5e7eb}`，不会误伤 .border-blue-100 这类
   显式指定颜色的类（它们特异性更高）。直接写 html[attr] * 会反过来压掉它们。 */
:where(html[data-sd-theme="dark"]) *,
:where(html[data-sd-theme="dark"]) ::before,
:where(html[data-sd-theme="dark"]) ::after { border-color: hsl(var(--sd-border)); }

/* ── 1. 表面 ─────────────────────────────────────────────────────────────── */
html[data-sd-theme="dark"] .bg-white { background-color: hsl(var(--sd-card)) !important; }
html[data-sd-theme="dark"] .bg-gray-50,
html[data-sd-theme="dark"] .bg-gray-100,
html[data-sd-theme="dark"] .bg-slate-50,
html[data-sd-theme="dark"] .bg-slate-100,
html[data-sd-theme="dark"] .bg-gray-50\/30,
html[data-sd-theme="dark"] .bg-gray-50\/50,
html[data-sd-theme="dark"] .bg-gray-50\/80,
html[data-sd-theme="dark"] .bg-gray-900\/40 { background-color: hsl(var(--sd-muted)) !important; }
/* 半透明版本保留一点透感，别和卡片糊成一块 */
html[data-sd-theme="dark"] .bg-gray-50\/30 { background-color: hsl(var(--sd-muted) / .45) !important; }
html[data-sd-theme="dark"] .bg-gray-50\/80 { background-color: hsl(var(--sd-muted) / .8) !important; }
/* body 自己也带着 bg-gray-50（模板骨架），它必须是画布色而不是 muted，
   否则页面底比卡片还亮，卡片看起来像被抠了洞。 */
html[data-sd-theme="dark"] body.bg-gray-50 { background-color: hsl(var(--sd-background)) !important; }
/* 遮罩层：深色下要更实，否则底下的暗色内容会透上来 */
html[data-sd-theme="dark"] .bg-gray-900\/40 { background-color: hsl(222 47% 4% / .68) !important; }

/* 代码块：浅色主题下是深色块，两个主题都该是深色，只把对比度提一点。
   ⚠️ 只认 pre / div —— 早先写成 .bg-gray-900.rounded-lg，把同样带这两个类的
   按钮（「刷新」等）一起命中了，而且特异性比 button.bg-gray-900 高，
   按钮被压成近黑、白字看不清。加选择器前先想清楚会不会误伤按钮。 */
html[data-sd-theme="dark"] pre.bg-gray-900,
html[data-sd-theme="dark"] div.bg-gray-900 { background-color: hsl(222 47% 6%) !important; }
/* bg-gray-900 的按钮在深色下不能是近黑（贴卡片看不见），改成 accent 面 */
html[data-sd-theme="dark"] button.bg-gray-900 { background-color: hsl(var(--sd-accent)) !important; color: hsl(var(--sd-foreground)) !important; }
html[data-sd-theme="dark"] button.bg-gray-900:hover { background-color: hsl(var(--sd-accent) / .8) !important; }

/* API 文档里的装饰渐变卡（from-blue-50 to-cyan-50 这类），深色下会变成亮白块 */
html[data-sd-theme="dark"] .bg-gradient-to-r,
html[data-sd-theme="dark"] .bg-gradient-to-br,
html[data-sd-theme="dark"] .bg-gradient-to-l { background-image: none !important; background-color: hsl(var(--sd-muted) / .55) !important; }

/* ── 2. 文字 ─────────────────────────────────────────────────────────────── */
html[data-sd-theme="dark"] .text-gray-900,
html[data-sd-theme="dark"] .text-gray-800,
html[data-sd-theme="dark"] .text-gray-700,
html[data-sd-theme="dark"] .text-slate-800,
html[data-sd-theme="dark"] .text-slate-700 { color: hsl(var(--sd-foreground)) !important; }

html[data-sd-theme="dark"] .text-gray-600,
html[data-sd-theme="dark"] .text-gray-500,
html[data-sd-theme="dark"] .text-slate-600,
html[data-sd-theme="dark"] .text-slate-500 { color: hsl(var(--sd-muted-foreground)) !important; }

html[data-sd-theme="dark"] .text-gray-400,
html[data-sd-theme="dark"] .text-gray-300,
html[data-sd-theme="dark"] .text-slate-400,
html[data-sd-theme="dark"] .text-slate-300 { color: hsl(var(--sd-muted-foreground) / .82) !important; }

/* 品牌色 / 语义色文字：浅色主题下压暗，深色主题下提亮 */
html[data-sd-theme="dark"] .text-blue-800,
html[data-sd-theme="dark"] .text-blue-700,
html[data-sd-theme="dark"] .text-blue-600,
html[data-sd-theme="dark"] .text-blue-500,
html[data-sd-theme="dark"] .text-sky-600,
html[data-sd-theme="dark"] .text-indigo-600,
html[data-sd-theme="dark"] .text-indigo-700 { color: hsl(var(--sd-text-blue)) !important; }

html[data-sd-theme="dark"] .text-green-800,
html[data-sd-theme="dark"] .text-green-700,
html[data-sd-theme="dark"] .text-green-600,
html[data-sd-theme="dark"] .text-emerald-800,
html[data-sd-theme="dark"] .text-emerald-700,
html[data-sd-theme="dark"] .text-emerald-600 { color: hsl(var(--sd-text-green)) !important; }

html[data-sd-theme="dark"] .text-amber-800,
html[data-sd-theme="dark"] .text-amber-700,
html[data-sd-theme="dark"] .text-amber-500,
html[data-sd-theme="dark"] .text-yellow-700 { color: hsl(var(--sd-text-amber)) !important; }

html[data-sd-theme="dark"] .text-orange-800,
html[data-sd-theme="dark"] .text-orange-700,
html[data-sd-theme="dark"] .text-orange-600,
html[data-sd-theme="dark"] .text-orange-500,
html[data-sd-theme="dark"] .text-orange-400 { color: hsl(var(--sd-text-orange)) !important; }

html[data-sd-theme="dark"] .text-red-700,
html[data-sd-theme="dark"] .text-red-600,
html[data-sd-theme="dark"] .text-red-500,
html[data-sd-theme="dark"] .text-red-400,
html[data-sd-theme="dark"] .text-rose-600 { color: hsl(var(--sd-text-red)) !important; }

html[data-sd-theme="dark"] .text-purple-900,
html[data-sd-theme="dark"] .text-purple-800,
html[data-sd-theme="dark"] .text-purple-700,
html[data-sd-theme="dark"] .text-indigo-800,
html[data-sd-theme="dark"] .text-indigo-900,
html[data-sd-theme="dark"] .text-violet-700 { color: hsl(var(--sd-text-violet)) !important; }

/* ── 3. 语义底色（徽章 / 提示条）─────────────────────────────────────────── */
html[data-sd-theme="dark"] .bg-blue-50,
html[data-sd-theme="dark"] .bg-blue-100,
html[data-sd-theme="dark"] .bg-sky-50,
html[data-sd-theme="dark"] .bg-indigo-50,
html[data-sd-theme="dark"] .bg-indigo-100 { background-color: hsl(var(--sd-primary-soft)) !important; }

html[data-sd-theme="dark"] .bg-green-50,
html[data-sd-theme="dark"] .bg-green-100,
html[data-sd-theme="dark"] .bg-emerald-50,
html[data-sd-theme="dark"] .bg-emerald-100 { background-color: hsl(var(--sd-success-soft)) !important; }

html[data-sd-theme="dark"] .bg-amber-50,
html[data-sd-theme="dark"] .bg-amber-100,
html[data-sd-theme="dark"] .bg-orange-50,
html[data-sd-theme="dark"] .bg-orange-100,
html[data-sd-theme="dark"] .bg-yellow-50 { background-color: hsl(var(--sd-warm-soft)) !important; }

html[data-sd-theme="dark"] .bg-red-50,
html[data-sd-theme="dark"] .bg-red-100,
html[data-sd-theme="dark"] .bg-rose-50 { background-color: hsl(var(--sd-danger-soft)) !important; }

html[data-sd-theme="dark"] .bg-purple-50,
html[data-sd-theme="dark"] .bg-purple-100,
html[data-sd-theme="dark"] .bg-violet-50 { background-color: hsl(var(--sd-text-violet) / .16) !important; }

/* ── 4. 边框 ─────────────────────────────────────────────────────────────── */
html[data-sd-theme="dark"] .border-gray-50,
html[data-sd-theme="dark"] .border-gray-100,
html[data-sd-theme="dark"] .border-gray-200,
html[data-sd-theme="dark"] .border-slate-100,
html[data-sd-theme="dark"] .border-slate-200 { border-color: hsl(var(--sd-border)) !important; }

html[data-sd-theme="dark"] .border-blue-100,
html[data-sd-theme="dark"] .border-blue-200,
html[data-sd-theme="dark"] .border-indigo-100 { border-color: hsl(var(--sd-primary) / .32) !important; }

html[data-sd-theme="dark"] .border-green-100,
html[data-sd-theme="dark"] .border-green-200,
html[data-sd-theme="dark"] .border-emerald-100,
html[data-sd-theme="dark"] .border-emerald-200 { border-color: hsl(var(--sd-success) / .35) !important; }

html[data-sd-theme="dark"] .border-amber-100,
html[data-sd-theme="dark"] .border-amber-200,
html[data-sd-theme="dark"] .border-orange-100 { border-color: hsl(var(--sd-warm) / .38) !important; }

html[data-sd-theme="dark"] .border-red-200,
html[data-sd-theme="dark"] .border-rose-100 { border-color: hsl(var(--sd-danger) / .4) !important; }

html[data-sd-theme="dark"] .border-purple-100 { border-color: hsl(var(--sd-text-violet) / .32) !important; }

/* 表格分隔线：divide-* 是作用在「后续兄弟节点」上的，选择器必须带儿子组合 */
html[data-sd-theme="dark"] .divide-gray-100 > :not([hidden]) ~ :not([hidden]),
html[data-sd-theme="dark"] .divide-gray-200 > :not([hidden]) ~ :not([hidden]),
html[data-sd-theme="dark"] .divide-slate-100 > :not([hidden]) ~ :not([hidden]) { border-color: hsl(var(--sd-border)) !important; }

/* ── 5. 表单控件 ─────────────────────────────────────────────────────────── */
/* ⚠️ 这条规则的特异性是 (0,4,1) 且带 !important —— 它会压掉任何语义化控件的
   底色（.sd-input / .sd-proj__num / .sd-proj__name 全中招，深色下全变成同一个
   card 色，输入框也就看不出是输入框）。所以这里用 :not([class*="sd-"]) 把
   sd 组件家族整体豁免出去，让组件自己的令牌说话；存量模板控件仍由这条兜底。 */
html[data-sd-theme="dark"] input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([class*="sd-"]),
html[data-sd-theme="dark"] select:not([class*="sd-"]),
html[data-sd-theme="dark"] textarea:not([class*="sd-"]) {
  background-color: hsl(var(--sd-card)) !important;
  border-color: hsl(var(--sd-border)) !important;
  color: hsl(var(--sd-foreground)) !important;
}
html[data-sd-theme="dark"] input:not([class*="sd-"])::placeholder,
html[data-sd-theme="dark"] textarea:not([class*="sd-"])::placeholder { color: hsl(var(--sd-muted-foreground) / .75) !important; }
/* 只读 / 禁用态不要跟普通输入框一样亮 */
html[data-sd-theme="dark"] input:not([class*="sd-"]):disabled,
html[data-sd-theme="dark"] textarea:not([class*="sd-"]):disabled,
html[data-sd-theme="dark"] select:not([class*="sd-"]):disabled { background-color: hsl(var(--sd-muted) / .6) !important; }

/* ── 6. hover 态（漏了会出现「悬停变白」）────────────────────────────────── */
html[data-sd-theme="dark"] .hover\:bg-gray-100:hover,
html[data-sd-theme="dark"] .hover\:bg-gray-50:hover,
html[data-sd-theme="dark"] .hover\:bg-gray-50\/50:hover,
html[data-sd-theme="dark"] .hover\:bg-gray-200:hover { background-color: hsl(var(--sd-accent)) !important; }
html[data-sd-theme="dark"] .hover\:bg-blue-50:hover { background-color: hsl(var(--sd-primary) / .16) !important; }
html[data-sd-theme="dark"] .hover\:bg-emerald-50:hover { background-color: hsl(var(--sd-success) / .16) !important; }
html[data-sd-theme="dark"] .hover\:bg-black:hover { background-color: hsl(var(--sd-accent)) !important; }
html[data-sd-theme="dark"] .hover\:text-gray-700:hover { color: hsl(var(--sd-foreground)) !important; }
html[data-sd-theme="dark"] .hover\:text-red-700:hover { color: hsl(var(--sd-text-red)) !important; }

/* ── 7. 阴影：浅色阴影在深色背景上等于没有，换成纯黑投影 ────────────────── */
html[data-sd-theme="dark"] .shadow-sm,
html[data-sd-theme="dark"] .shadow,
html[data-sd-theme="dark"] .shadow-md,
html[data-sd-theme="dark"] .shadow-lg,
html[data-sd-theme="dark"] .shadow-xl { box-shadow: 0 8px 24px hsl(0 0% 0% / .38) !important; }

/* ── 8. 开发文档 tab（.doc-* 来自共用 ui.css）───────────────────────────────
   .doc-layout / .doc-list / .doc-content 定义在 ui.css，公共文档站 /docs 也在用，
   所以不能改 ui.css（会把公共站也变深色）。这里只在控制台页面覆盖。 */
html[data-sd-theme="dark"] .doc-list,
html[data-sd-theme="dark"] .doc-content {
  background: hsl(var(--sd-card)) !important;
  border-color: hsl(var(--sd-border)) !important;
  color: hsl(var(--sd-foreground));
}
html[data-sd-theme="dark"] .doc-list__item { color: hsl(var(--sd-muted-foreground)); }
html[data-sd-theme="dark"] .doc-list__item:hover { background: hsl(var(--sd-accent)); color: hsl(var(--sd-foreground)); }
html[data-sd-theme="dark"] .doc-list__item.active { background: hsl(var(--sd-primary-soft)); color: hsl(var(--sd-primary)); }
html[data-sd-theme="dark"] .doc-content h1,
html[data-sd-theme="dark"] .doc-content h2 { border-bottom-color: hsl(var(--sd-border)); }
html[data-sd-theme="dark"] .doc-content a { color: hsl(var(--sd-primary)); }
html[data-sd-theme="dark"] .doc-content code { background: hsl(var(--sd-muted)); color: hsl(var(--sd-text-amber)); }
html[data-sd-theme="dark"] .doc-content pre { background: hsl(222 47% 6%); border-color: hsl(var(--sd-border)); }
html[data-sd-theme="dark"] .doc-content pre code { background: none; color: hsl(var(--sd-foreground)); }
html[data-sd-theme="dark"] .doc-content th,
html[data-sd-theme="dark"] .doc-content td { border-color: hsl(var(--sd-border)); }
html[data-sd-theme="dark"] .doc-content th { background: hsl(var(--sd-muted)); }
html[data-sd-theme="dark"] .doc-content blockquote {
  background: hsl(var(--sd-primary-soft)); color: hsl(var(--sd-foreground));
  border-left-color: hsl(var(--sd-primary) / .55);
}

/* ── 9. 内联硬编码色兜底 ───────────────────────────────────────────────────
   模板里还有 70+ 处 style="background:#fff" / "color:#1f2937" 这类内联色，
   零散分布在弹窗（#kd-detail / #region-modal / 充值 / 令牌）和少数提示块里。
   逐个改标记风险大且容易漏，这里用属性选择器按「值」兜底。
   注意：属性选择器匹配的是 HTML 里写的原始字符串 —— 静态模板里的
   #fff 不会被序列化成 rgb()，所以能命中；JS 现拼的样式则匹配不到，
   那部分已经在渲染函数里改成类名了（别再往里写内联色）。 */
html[data-sd-theme="dark"] [style*="background:#fff"],
html[data-sd-theme="dark"] [style*="background: #fff"],
html[data-sd-theme="dark"] [style*="background:#f8fafc"],
html[data-sd-theme="dark"] [style*="background:#fafafa"],
html[data-sd-theme="dark"] [style*="background:#f9fafb"],
html[data-sd-theme="dark"] [style*="background:#f1f5f9"],
html[data-sd-theme="dark"] [style*="background:#f3f4f6"] { background: hsl(var(--sd-card)) !important; }

/* 深色卡片里的浅灰内层（表头、行）保持 muted，别和卡片同色 */
html[data-sd-theme="dark"] [style*="background:#eef2f7"],
html[data-sd-theme="dark"] [style*="background:#eef1f6"] { background: hsl(var(--sd-muted)) !important; }

/* 暖色警示块（API 文档的「升级前必读」） */
html[data-sd-theme="dark"] [style*="background:#fffbeb"] { background: hsl(var(--sd-warm-soft)) !important; border-color: hsl(var(--sd-warm) / .45) !important; }
html[data-sd-theme="dark"] [style*="background:#fde68a"] { background: hsl(var(--sd-warm) / .26) !important; }
/* 主色浅底（Key 详情按钮、提示条） */
html[data-sd-theme="dark"] [style*="background:#eff6ff"] { background: hsl(var(--sd-primary-soft)) !important; }
html[data-sd-theme="dark"] [style*="border:1px solid #bfdbfe"] { border-color: hsl(var(--sd-primary) / .35) !important; }
html[data-sd-theme="dark"] [style*="color:#92400e"],
html[data-sd-theme="dark"] [style*="color:#78350f"],
html[data-sd-theme="dark"] [style*="color:#b45309"] { color: hsl(var(--sd-text-amber)) !important; }

/* 错误块 */
html[data-sd-theme="dark"] [style*="background:#fef2f2"] { background: hsl(var(--sd-danger-soft)) !important; border-color: hsl(var(--sd-danger) / .45) !important; }
html[data-sd-theme="dark"] [style*="color:#dc2626"],
html[data-sd-theme="dark"] [style*="color:#b91c1c"] { color: hsl(var(--sd-text-red)) !important; }

/* 正文/次要文字 */
html[data-sd-theme="dark"] [style*="color:#1f2937"],
html[data-sd-theme="dark"] [style*="color:#1e293b"],
html[data-sd-theme="dark"] [style*="color:#111827"] { color: hsl(var(--sd-foreground)) !important; }
html[data-sd-theme="dark"] [style*="color:#475569"],
html[data-sd-theme="dark"] [style*="color:#4b5563"],
html[data-sd-theme="dark"] [style*="color:#374151"] { color: hsl(var(--sd-muted-foreground)) !important; }
html[data-sd-theme="dark"] [style*="color:#94a3b8"],
html[data-sd-theme="dark"] [style*="color:#9ca3af"],
html[data-sd-theme="dark"] [style*="color:#cbd5e1"],
html[data-sd-theme="dark"] [style*="color:#8491a3"] { color: hsl(var(--sd-muted-foreground) / .82) !important; }
html[data-sd-theme="dark"] [style*="color:#2563eb"],
html[data-sd-theme="dark"] [style*="color:#1d4ed8"] { color: hsl(var(--sd-primary)) !important; }
html[data-sd-theme="dark"] [style*="color:#047857"] { color: hsl(var(--sd-text-green)) !important; }

/* 内联边框   顺序要在背景/文字之后 —— 这些规则会同时改 border-color，
   放在后面可避免被上面 shorthand 里的 background 覆盖判断干扰 */
html[data-sd-theme="dark"] [style*="border:1px solid #e5e7eb"],
html[data-sd-theme="dark"] [style*="border: 1px solid #e5e7eb"],
html[data-sd-theme="dark"] [style*="border:1px solid #eef1f6"],
html[data-sd-theme="dark"] [style*="border-left:1px solid #eef1f6"],
html[data-sd-theme="dark"] [style*="border-top:1px solid #eef1f6"],
html[data-sd-theme="dark"] [style*="border-bottom:1px solid #eef1f6"],
html[data-sd-theme="dark"] [style*="border:1px solid #eef2f7"],
html[data-sd-theme="dark"] [style*="border-top:1px solid #eef2f7"],
html[data-sd-theme="dark"] [style*="border-color:#f9fafb"] { border-color: hsl(var(--sd-border)) !important; }
html[data-sd-theme="dark"] [style*="border:1px solid #fecaca"] { border-color: hsl(var(--sd-danger) / .45) !important; }
html[data-sd-theme="dark"] [style*="border:1px solid #fcd34d"] { border-color: hsl(var(--sd-warm) / .45) !important; }

/* ── 10. 弹窗 ──────────────────────────────────────────────────────────────
   模板里的弹窗容器用内联 rgba(15,23,42,.4~.5) 当遮罩，深色页面本身就很暗，
   45% 的深蓝遮罩几乎看不出来，弹窗卡（card 12%）和背后的画布只差几个色阶，
   结果「弹窗不像弹窗」。这里把遮罩压到近黑，并给面板加一道描边。
   ⚠️ 必须按 id 命中，不能用 [style*=...] —— 打开弹窗时 JS 会写
   el.style.display，浏览器随即把整个 style 属性重新序列化
   （rgba(15,23,42,0.45) → rgba(15, 23, 42, 0.45) 逗号后补空格），
   属性选择器当场失配。这条踩过一次，别再改回属性选择器。 */
html[data-sd-theme="dark"] #kd-modal,
html[data-sd-theme="dark"] #region-modal,
html[data-sd-theme="dark"] #npModalRoot,
html[data-sd-theme="dark"] #code-redeem-modal,
html[data-sd-theme="dark"] #move-keys-modal { background: hsl(222 47% 4% / .72) !important; }
html[data-sd-theme="dark"] [style*="box-shadow:0 25px 50px"] {
  border: 1px solid hsl(var(--sd-border));
  box-shadow: 0 24px 64px hsl(0 0% 0% / .55) !important;
}

/* ══════════════════════════════════════════════════════════════════════════
   11. 二级页面统一外壳
   --------------------------------------------------------------------------
   除「概览」外的 8 个 tab 原本各写各的版式（有的 20px 标题 + 29 处
   uppercase tracking-widest，有的直接一张裸表格）。这里给它们一套共同骨架：
   页头（eyebrow / h1 / 描述 / 右侧动作）+ 内容卡片。
   所有取值只走 --sd-* 令牌，深浅两套主题自动跟随，不必再写深色补丁。
   ══════════════════════════════════════════════════════════════════════════ */
.sd-page { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
/* ⚠️ 本文件在 tailwind.css 之后加载，.sd-page 的 display:flex 与 .hidden 特异性相同，
   后者会被压掉 → 隐藏的 tab 会一直显示。switchTab 同时设 hidden 属性和 .hidden 类，
   两个都兜住。不要删这条。 */
.sd-page[hidden], .sd-page.hidden { display: none !important; }
.sd-page__head {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 16px; flex-wrap: wrap; padding-bottom: 2px;
}
.sd-page__head h1 {
  margin: 5px 0 0; font-size: 20px; font-weight: 650;
  letter-spacing: -.028em; line-height: 1.25; color: hsl(var(--sd-foreground));
}
.sd-page__desc {
  margin: 5px 0 0; max-width: 66ch;
  font-size: 12px; line-height: 1.65; color: hsl(var(--sd-muted-foreground));
}
.sd-page__actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* 卡片内的顶部工具条（标题 + 右侧动作），和 .sd-card__head 的区别是带底部分隔线 */
.sd-toolbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; flex-wrap: wrap; padding: 14px 18px;
  border-bottom: 1px solid hsl(var(--sd-border));
}
.sd-toolbar__meta { font-size: 11px; color: hsl(var(--sd-muted-foreground)); }
.sd-toolbar__meta b { color: hsl(var(--sd-foreground)); font-weight: 600; }
/* 表格紧跟在 card head 之后时留一点呼吸，否则 th 会贴住标题 */
.sd-card__body { padding-top: 6px; }
.sd-card__body--flush { padding-top: 0; }

/* ── 12. 展示型 KPI（无点击行为，区别于概览那四张可筛选卡）─────────────── */
.sd-kpis--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.sd-kpi--static { --sd-kpi-color: hsl(var(--sd-foreground)); cursor: default; }
.sd-kpi--static:hover { transform: none; border-color: hsl(var(--sd-border)); box-shadow: var(--sd-shadow-sm); }
.sd-kpi__value--primary { color: hsl(var(--sd-primary)); }
.sd-kpi__value--success { color: hsl(var(--sd-success)); }
.sd-kpi__value--warn { color: hsl(var(--sd-warning)); }
.sd-kpi__value--plain { color: hsl(var(--sd-foreground)); }
.sd-kpi__unit { font-size: 13px; font-weight: 500; margin-left: 2px; opacity: .7; }

/* ── 13. 语义状态徽章 ──────────────────────────────────────────────────── */
.sd-status.is-success { background: hsl(var(--sd-success-soft)); color: hsl(var(--sd-success)); }
.sd-status.is-warn { background: hsl(var(--sd-warning-soft)); color: hsl(var(--sd-warning)); }
.sd-status.is-info { background: hsl(var(--sd-primary-soft)); color: hsl(var(--sd-primary)); }
.sd-status.is-danger { background: hsl(var(--sd-danger-soft)); color: hsl(var(--sd-danger)); }
.sd-status.is-neutral { background: hsl(var(--sd-muted)); color: hsl(var(--sd-muted-foreground)); }
.sd-status.is-plain {
  background: transparent; padding-left: 0; padding-right: 0;
  color: hsl(var(--sd-muted-foreground)); font-weight: 500;
}
.sd-status--sm { font-size: 10px; padding: 2px 7px; }

/* ── 14. 表格增强 ──────────────────────────────────────────────────────── */
.sd-table--tight th { padding: 8px 14px; }
.sd-table--tight td { padding: 9px 14px; }
.sd-table__strong { font-weight: 600; color: hsl(var(--sd-foreground)); }
.sd-table__sec { display: block; margin-top: 2px; font-size: 10px; color: hsl(var(--sd-muted-foreground)); }
.sd-table .sd-table__num { text-align: right; font-variant-numeric: tabular-nums; }
.sd-table th.sd-table__num { text-align: right; }
.sd-table__mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 11px; }
.sd-table__nowrap { white-space: nowrap; }
.sd-table__break { word-break: break-all; }
.sd-table__struck { text-decoration: line-through; color: hsl(var(--sd-muted-foreground)); }
/* 语义文字色（表格里的金额、增减量等） */
.sd-text-success { color: hsl(var(--sd-success)) !important; }
.sd-text-warn { color: hsl(var(--sd-warning)) !important; }
.sd-text-danger { color: hsl(var(--sd-danger)) !important; }
.sd-text-primary { color: hsl(var(--sd-primary)) !important; }
.sd-text-muted { color: hsl(var(--sd-muted-foreground)) !important; }
.sd-table tr.is-muted td { opacity: .55; }
.sd-table__scroll { overflow-x: auto; }
.sd-table__scroll .sd-table { min-width: 720px; }

/* 表格里的行内文字按钮 */.sd-linkbtn {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px; border-radius: 6px; border: 1px solid hsl(var(--sd-border));
  background: hsl(var(--sd-card)); color: hsl(var(--sd-foreground));
  font-size: 11px; font-weight: 600; white-space: nowrap;
}
.sd-linkbtn:hover { background: hsl(var(--sd-accent)); }
.sd-linkbtn--primary { border-color: hsl(var(--sd-primary) / .45); color: hsl(var(--sd-primary)); }
.sd-linkbtn--primary:hover { background: hsl(var(--sd-primary-soft)); }
.sd-linkbtn--danger { border-color: hsl(var(--sd-danger) / .4); color: hsl(var(--sd-danger)); }
.sd-linkbtn--danger:hover { background: hsl(var(--sd-danger-soft)); }
.sd-linkbtn[disabled] { opacity: .45; pointer-events: none; }

/* ── 15. 空态 ──────────────────────────────────────────────────────────── */
.sd-empty { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 42px 20px; text-align: center; }
.sd-empty .sd-ico { width: 22px; height: 22px; color: hsl(var(--sd-muted-foreground) / .6); }
.sd-empty__title { font-size: 13px; font-weight: 600; color: hsl(var(--sd-foreground)); }
.sd-empty__desc { font-size: 11px; color: hsl(var(--sd-muted-foreground)); max-width: 42ch; line-height: 1.6; }
.sd-empty--danger .sd-empty__title { color: hsl(var(--sd-danger)); }

/* ── 16. 表单（账户设置）───────────────────────────────────────────────── */
.sd-form__sect {
  display: grid; grid-template-columns: 190px minmax(0, 1fr);
  gap: 12px 24px; padding: 20px 18px;
  border-top: 1px solid hsl(var(--sd-border));
}
.sd-form__sect:first-of-type { border-top: 0; }
.sd-form__label { font-size: 12.5px; font-weight: 600; color: hsl(var(--sd-foreground)); }
.sd-form__hint { margin-top: 3px; font-size: 11px; line-height: 1.55; color: hsl(var(--sd-muted-foreground)); }
.sd-form__body { display: flex; flex-direction: column; gap: 10px; min-width: 0; max-width: 460px; }
.sd-form__row { display: flex; gap: 8px; align-items: center; }
.sd-form__row > .sd-input { flex: 1; min-width: 0; }
.sd-form__foot {
  display: flex; align-items: center; justify-content: flex-end; gap: 10px;
  padding: 14px 18px; border-top: 1px solid hsl(var(--sd-border));
  background: hsl(var(--sd-muted) / .5);
  border-radius: 0 0 calc(var(--sd-radius) - 1px) calc(var(--sd-radius) - 1px);
}
.sd-field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.sd-field__label { font-size: 11px; font-weight: 500; color: hsl(var(--sd-muted-foreground)); }
.sd-input {
  height: 36px; width: 100%; padding: 0 11px;
  border: 1px solid hsl(var(--sd-border)); border-radius: var(--sd-radius-sm);
  /* 比卡片略深一档，否则深色主题下输入框和卡片同色，只剩一条细边可辨 */
  background: hsl(var(--sd-muted) / .55); color: hsl(var(--sd-foreground));
  font-size: 12.5px; line-height: 1; font-family: inherit;
  transition: border-color .15s, box-shadow .15s;
}
.sd-input::placeholder { color: hsl(var(--sd-muted-foreground) / .75); }
.sd-input:focus {
  outline: 0; border-color: hsl(var(--sd-ring));
  background: hsl(var(--sd-card));
  box-shadow: 0 0 0 3px hsl(var(--sd-ring) / .16);
}
textarea.sd-input { height: auto; padding: 9px 11px; line-height: 1.6; resize: vertical; }
select.sd-input { appearance: none; padding-right: 28px;
  background-image: linear-gradient(45deg, transparent 50%, currentColor 50%), linear-gradient(135deg, currentColor 50%, transparent 50%);
  background-position: calc(100% - 15px) 15px, calc(100% - 10px) 15px;
  background-size: 5px 5px, 5px 5px; background-repeat: no-repeat; }
.sd-input--sm { height: 32px; font-size: 12px; }

/* ── 17. 提示框（替代原来 13 处 from-blue-50 to-cyan-50 渐变块）────────── */
.sd-callout {
  padding: 13px 15px; border-radius: var(--sd-radius-sm);
  border: 1px solid hsl(var(--sd-border)); background: hsl(var(--sd-muted) / .6);
  font-size: 12px; line-height: 1.68; color: hsl(var(--sd-foreground));
}
.sd-callout__title {
  display: flex; align-items: center; gap: 7px;
  margin: 0 0 6px; font-size: 12.5px; font-weight: 650;
  letter-spacing: -.01em; color: inherit;
}
.sd-callout p { margin: 0; }
.sd-callout p + p, .sd-callout p + ul, .sd-callout ul + p { margin-top: 7px; }
.sd-callout ul { margin: 0; padding-left: 17px; }
.sd-callout li + li { margin-top: 3px; }
.sd-callout code {
  padding: 1px 5px; border-radius: 4px; font-size: 11px;
  background: hsl(var(--sd-card)); border: 1px solid hsl(var(--sd-border));
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
.sd-callout--warn {
  background: hsl(var(--sd-warm-soft)); border-color: hsl(var(--sd-warm) / .38);
  color: hsl(var(--sd-warm-foreground));
}
.sd-callout--warn code { background: hsl(var(--sd-warm) / .16); border-color: hsl(var(--sd-warm) / .3); }
.sd-callout--info {
  background: hsl(var(--sd-primary-soft)); border-color: hsl(var(--sd-primary) / .3);
  color: hsl(var(--sd-foreground));
}
.sd-callout--danger {
  background: hsl(var(--sd-danger-soft)); border-color: hsl(var(--sd-danger) / .35);
  color: hsl(var(--sd-danger));
}

/* 副卡片（卡片内再分块，如「推荐 / 经典」两栏）*/
.sd-subcard {
  padding: 14px; border-radius: var(--sd-radius-sm);
  border: 1px solid hsl(var(--sd-border)); background: hsl(var(--sd-muted) / .45);
  min-width: 0;
}
.sd-subcard__title {
  display: flex; align-items: center; gap: 6px; margin: 0 0 8px;
  font-size: 12px; font-weight: 650; color: hsl(var(--sd-foreground));
}
.sd-subcard ul { margin: 0; padding-left: 16px; font-size: 11.5px; line-height: 1.72; color: hsl(var(--sd-muted-foreground)); }
.sd-subcard li + li { margin-top: 3px; }
.sd-subcard code {
  padding: 1px 4px; border-radius: 4px; font-size: 11px;
  background: hsl(var(--sd-card)); border: 1px solid hsl(var(--sd-border));
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color: hsl(var(--sd-foreground));
}

/* ── 18. 代码块（两个主题都保持深色，只统一圆角与内边距）──────────────── */
.sd-pre {
  margin: 8px 0 0; padding: 11px 12px; border-radius: var(--sd-radius-sm);
  background: hsl(222 47% 9%); color: hsl(210 40% 92%);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 11px; line-height: 1.65; overflow-x: auto;
  border: 1px solid hsl(222 40% 18%);
  tab-size: 4;
}
.sd-pre code { font: inherit; background: none; border: 0; padding: 0; color: inherit; }

/* ── 19. 集成页分组锚点导航 ────────────────────────────────────────────── */
.sd-anchors {
  display: flex; gap: 6px; overflow-x: auto; padding: 3px;
  border-radius: var(--sd-radius-sm); background: hsl(var(--sd-muted) / .7);
  border: 1px solid hsl(var(--sd-border)); scrollbar-width: none;
}
.sd-anchors::-webkit-scrollbar { display: none; }
.sd-anchors a {
  flex-shrink: 0; padding: 6px 11px; border-radius: 7px;
  font-size: 11.5px; font-weight: 500; white-space: nowrap;
  color: hsl(var(--sd-muted-foreground)); text-decoration: none;
}
.sd-anchors a:hover { background: hsl(var(--sd-card)); color: hsl(var(--sd-foreground)); }
.sd-anchors a.is-active {
  background: hsl(var(--sd-card)); color: hsl(var(--sd-foreground));
  box-shadow: var(--sd-shadow-sm); font-weight: 600;
}

/* ── 20. 文档页（tab-docs）────────────────────────────────────────────────
   .doc-layout / .doc-list / .doc-content 定义在共用 ui.css（公共文档站 /docs
   也在用），不能改 ui.css。这里只在控制台内把它们"融进"外层 sd-card：
   去掉两面各自的边框和圆角，改成左栏分隔线 + 各自滚动。 */
.sd-docs { padding: 0; overflow: hidden; }
.sd-docs .doc-layout {
  gap: 0; min-height: 0; height: min(640px, 72vh);
  border-radius: var(--sd-radius); overflow: hidden;
}
.sd-docs .doc-list {
  flex: 0 0 232px; max-width: 232px; max-height: none; height: 100%;
  border: 0; border-right: 1px solid hsl(var(--sd-border)); border-radius: 0;
  padding: 10px; background: hsl(var(--sd-muted) / .42);
}
.sd-docs .doc-list__item { color: hsl(var(--sd-foreground) / .86); }
.sd-docs .doc-list__item:hover { background: hsl(var(--sd-accent)); }
.sd-docs .doc-list__item.active {
  background: hsl(var(--sd-primary-soft)); color: hsl(var(--sd-primary));
}
.sd-docs .doc-content {
  height: 100%; max-height: none; border: 0; border-radius: 0;
  background: hsl(var(--sd-card)); color: hsl(var(--sd-card-foreground));
  padding: 24px 28px;
}
.sd-docs .doc-content h1, .sd-docs .doc-content h2,
.sd-docs .doc-content h3, .sd-docs .doc-content h4 { color: hsl(var(--sd-foreground)); }
.sd-docs .doc-content h1, .sd-docs .doc-content h2 { border-bottom-color: hsl(var(--sd-border)); }
.sd-docs .doc-content p, .sd-docs .doc-content li { color: hsl(var(--sd-foreground) / .88); }
.sd-docs .doc-content strong { color: hsl(var(--sd-foreground)); }
.sd-docs .doc-content a { color: hsl(var(--sd-primary)); }
.sd-docs .doc-content code {
  background: hsl(var(--sd-muted)); color: hsl(var(--sd-text-violet));
  border: 1px solid hsl(var(--sd-border));
}
.sd-docs .doc-content pre {
  background: hsl(var(--sd-muted) / .6); border: 1px solid hsl(var(--sd-border));
  border-radius: var(--sd-radius-sm);
}
.sd-docs .doc-content pre code { background: none; border: 0; color: hsl(var(--sd-foreground)); }
.sd-docs .doc-content th, .sd-docs .doc-content td { border-color: hsl(var(--sd-border)); }
.sd-docs .doc-content th { background: hsl(var(--sd-muted)); color: hsl(var(--sd-foreground)); }
.sd-docs .doc-content blockquote {
  background: hsl(var(--sd-primary-soft)); border-left-color: hsl(var(--sd-primary));
  color: hsl(var(--sd-foreground)); border-radius: 0 var(--sd-radius-sm) var(--sd-radius-sm) 0;
}

/* ── 21. 集成页（tab-api）：把原来的彩色渐变块收成克制的卡片层次 ──────
   原页面每个接口分组都是 from-X-50 to-Y-50 的渐变 + 彩色边框，
   六组六种颜色，信息密度高时很吵。这里统一成「中性卡片 + 彩色方法徽章」：
   靠 HTTP 方法（GET/POST/PUT/WSS）上色，而不是靠每块的背景色。
   DOM 不改，只换类名，降低回归风险。 */
.sd-api-block { display: flex; flex-direction: column; gap: 14px; padding: 18px; }
.sd-api-hero { display: flex; flex-direction: column; gap: 10px; }
.sd-api-hero > h2 {
  margin: 0; font-size: 15.5px; font-weight: 650;
  letter-spacing: -.02em; line-height: 1.35; color: hsl(var(--sd-foreground));
}
.sd-api-hero > p {
  margin: 0; font-size: 12px; line-height: 1.7;
  color: hsl(var(--sd-muted-foreground));
}
.sd-api-body {
  display: flex; flex-direction: column; gap: 12px;
  padding: 13px 14px; border-radius: var(--sd-radius-sm);
  border: 1px solid hsl(var(--sd-border)); background: hsl(var(--sd-muted) / .45);
}

/* HTTP 方法徽章：等宽、小、只做标识 */
.sd-method {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 2px 7px; border-radius: 5px;
  font-size: 10px; font-weight: 700; letter-spacing: .04em;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  white-space: nowrap;
}
.sd-method--get { background: hsl(var(--sd-success-soft)); color: hsl(var(--sd-success)); }
.sd-method--post, .sd-method--stream { background: hsl(var(--sd-primary-soft)); color: hsl(var(--sd-primary)); }
.sd-method--put { background: hsl(var(--sd-warning-soft)); color: hsl(var(--sd-warning)); }
.sd-method--delete { background: hsl(var(--sd-danger-soft)); color: hsl(var(--sd-danger)); }

/* 单个接口条目：头部方法 + 路径，主体放参数说明与示例 */
.sd-endpoint {
  border: 1px solid hsl(var(--sd-border)); border-radius: var(--sd-radius-sm); overflow: hidden;
}
.sd-endpoint__head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; padding: 9px 12px;
  background: hsl(var(--sd-muted) / .55); border-bottom: 1px solid hsl(var(--sd-border));
}
.sd-endpoint__head > div { display: flex; align-items: center; gap: 8px; min-width: 0; }
.sd-endpoint__path {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 11.5px; color: hsl(var(--sd-foreground)); word-break: break-all;
}
.sd-endpoint__hint {
  flex-shrink: 0; font-size: 10px; color: hsl(var(--sd-muted-foreground));
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
.sd-endpoint__body { padding: 12px; display: flex; flex-direction: column; gap: 10px; }

/* 一行三条的特性说明卡（专用权限 / 可控风险 / 随时撤销…）*/
.sd-feats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.sd-feat {
  padding: 10px 12px; border-radius: var(--sd-radius-sm);
  border: 1px solid hsl(var(--sd-border)); background: hsl(var(--sd-muted) / .40);
  min-width: 0;
}
.sd-feat__title { margin: 0 0 3px; font-size: 11.5px; font-weight: 650; color: hsl(var(--sd-foreground)); }
.sd-feat__desc { margin: 0; font-size: 11px; line-height: 1.62; color: hsl(var(--sd-muted-foreground)); }

.sd-feat__list {
  margin: 0; padding-left: 16px;
  font-size: 11px; line-height: 1.75; color: hsl(var(--sd-muted-foreground));
}
.sd-feat__list li + li { margin-top: 3px; }
.sd-feat__list code { color: hsl(var(--sd-foreground)); font-size: 10.5px; }

/* 行内代码（原文是 bg-white px-1 rounded 的白色小胶囊，在中性底上要换色）*/
.sd-code-inline {
  padding: 1px 5px; border-radius: 4px;
  background: hsl(var(--sd-muted)); border: 1px solid hsl(var(--sd-border));
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: .92em; color: hsl(var(--sd-foreground));
}

/* 集成页里的正文小标题（获取单个设备统计 / 如何获取 Token…）*/
.sd-api-h3 {
  margin: 4px 0 0; font-size: 13px; font-weight: 650;
  letter-spacing: -.01em; color: hsl(var(--sd-foreground));
}
.sd-api-h4 {
  margin: 6px 0 0; font-size: 12px; font-weight: 650;
  color: hsl(var(--sd-foreground));
}
.sd-api-p { margin: 0; font-size: 11.5px; line-height: 1.72; color: hsl(var(--sd-muted-foreground)); }
.sd-pre--sm { font-size: 10px; }

@media (max-width: 900px) {
  .sd-feats { grid-template-columns: minmax(0, 1fr); }
}

/* ── 22. 新版二级页的窄屏回落 ──────────────────────────────────────────── */
@media (max-width: 1024px) {
  .sd-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .sd-form__sect { grid-template-columns: minmax(0, 1fr); gap: 10px; }
  .sd-form__body { max-width: none; }
}
@media (max-width: 640px) {
  .sd-page__head { align-items: flex-start; }
  .sd-page__head h1 { font-size: 18px; }
  .sd-kpis, .sd-kpis--3 { grid-template-columns: minmax(0, 1fr); }
  .sd-toolbar { padding: 12px 14px; }
  .sd-card__head { padding: 14px 14px 0; }
  .sd-form__foot { border-radius: 0; }
}

/* ── 23. 项目卡（概览页「项目与配置」）─────────────────────────────────────
   原来卡片里是一堆内联样式：卡片 12%、度量块 17%、虚线分隔三者在深色下
   只差几个色阶，整个区块糊成一片。这里改成「卡片浮起 + 度量块内嵌」的
   双向层次：深色下卡片比画布亮，度量块比卡片暗，中间靠实线分隔。
   浅色主题同样是「白卡 + 灰槽」，只是方向相反（卡片比画布白）。
   注意：结构由 renderProjects() 输出，改类名要同步改 JS。 */
.vd-projects.sd-projects { gap: 16px !important; }

.sd-proj {
  display: flex; flex-direction: column;
  background: hsl(var(--sd-card));
  border: 1px solid hsl(var(--sd-border));
  border-radius: var(--sd-radius);
  padding: 16px 18px 14px;
  box-shadow: var(--sd-shadow-sm);
  min-width: 0;
}

/* 头部：状态点 + 可编辑项目名 + #id + 操作 */
.sd-proj__head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.sd-proj__ident { display: flex; align-items: center; gap: 9px; min-width: 0; flex: 1; }
.sd-proj__dot {
  width: 7px; height: 7px; border-radius: 99px; flex-shrink: 0;
  background: hsl(var(--sd-primary));
  box-shadow: 0 0 0 3px hsl(var(--sd-primary) / .16);
}
/* 项目名：平时无框像标题，hover/focus 才显出「可以改」 */
.sd-proj__name {
  flex: 0 1 auto; min-width: 0; max-width: 280px;
  padding: 2px 7px; margin-left: -7px;
  border: 1px solid transparent; border-radius: var(--sd-radius-sm);
  background: transparent; color: hsl(var(--sd-foreground));
  font-size: 14px; font-weight: 650; letter-spacing: -.01em;
  font-family: inherit; outline: none;
  text-overflow: ellipsis;
}
.sd-proj__name:hover { background: hsl(var(--sd-muted) / .7); }
.sd-proj__name.is-editing {
  background: hsl(var(--sd-muted)); border-color: hsl(var(--sd-ring));
  box-shadow: 0 0 0 3px hsl(var(--sd-ring) / .16);
}
.sd-proj__id {
  flex-shrink: 0; font-size: 10px; font-weight: 600;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  color: hsl(var(--sd-muted-foreground));
}
.sd-proj__acts { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.sd-proj__act {
  padding: 5px 10px; border-radius: var(--sd-radius-sm);
  border: 1px solid hsl(var(--sd-border));
  background: hsl(var(--sd-card)); color: hsl(var(--sd-muted-foreground));
  font-family: inherit; font-size: 11px; font-weight: 600; line-height: 1.2;
  cursor: pointer; transition: background .15s ease, color .15s ease, border-color .15s ease;
}
.sd-proj__act:hover { background: hsl(var(--sd-accent)); color: hsl(var(--sd-foreground)); }
.sd-proj__act--danger:hover {
  background: hsl(var(--sd-danger-soft)); color: hsl(var(--sd-danger));
  border-color: hsl(var(--sd-danger) / .45);
}

/* 度量块：内嵌槽。浅色是灰底，深色比卡片再暗一档，配 inset 制造凹陷感 */
.sd-proj__metrics { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-top: 14px; }
.sd-proj__metric {
  padding: 8px 10px; min-width: 0;
  border-radius: var(--sd-radius-sm);
  background: hsl(var(--sd-muted) / .75);
  border: 1px solid hsl(var(--sd-border) / .9);
}
.sd-proj__metric-label {
  margin: 0; font-size: 10px; font-weight: 600; line-height: 1.3;
  color: hsl(var(--sd-muted-foreground));
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sd-proj__metric-value {
  margin: 4px 0 0; font-size: 16px; font-weight: 650; line-height: 1.1;
  letter-spacing: -.02em; font-variant-numeric: tabular-nums;
  color: hsl(var(--sd-foreground));
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sd-proj__metric-value.is-ok { color: hsl(var(--sd-success)); }
.sd-proj__metric-value.is-warn { color: hsl(var(--sd-warning)); }

/* 配置行：标签 / 控件 / 说明 三列对齐，比原来 wrap 成一条的读法清楚得多 */
.sd-proj__rows { margin-top: 4px; }
.sd-proj__row {
  display: grid;
  grid-template-columns: 68px minmax(0, 148px) minmax(0, 1fr);
  align-items: center; gap: 12px;
  padding: 9px 0;
  border-top: 1px solid hsl(var(--sd-border));
}
.sd-proj__label {
  font-size: 11px; font-weight: 600; line-height: 1.3;
  color: hsl(var(--sd-muted-foreground));
  white-space: nowrap;
}
.sd-proj__ctrl { display: flex; align-items: center; gap: 6px; min-width: 0; }
.sd-proj__ctrl > .sd-proj__select, .sd-proj__ctrl > .sd-proj__num { width: 100%; }
.sd-proj__num {
  width: 62px; flex: 0 0 62px;
  padding: 4px 8px; border-radius: var(--sd-radius-sm);
  border: 1px solid hsl(var(--sd-border));
  background: hsl(var(--sd-card)); color: hsl(var(--sd-primary));
  font-family: inherit; font-size: 12px; font-weight: 650;
  text-align: center; outline: none;
}
.sd-proj__unit { flex-shrink: 0; font-size: 11px; font-weight: 600; color: hsl(var(--sd-muted-foreground)); }
.sd-proj__select {
  padding: 5px 8px; border-radius: var(--sd-radius-sm);
  border: 1px solid hsl(var(--sd-border));
  background: hsl(var(--sd-card)); color: hsl(var(--sd-primary));
  font-family: inherit; font-size: 11px; font-weight: 600;
  outline: none; cursor: pointer; min-width: 0;
}
.sd-proj__num:focus, .sd-proj__select:focus {
  border-color: hsl(var(--sd-ring));
  box-shadow: 0 0 0 3px hsl(var(--sd-ring) / .16);
}
.sd-proj__select:disabled { opacity: .55; cursor: not-allowed; }
.sd-proj__hint {
  font-size: 11px; line-height: 1.5;
  color: hsl(var(--sd-muted-foreground));
  min-width: 0;
}

/* 高级配置区 */
.sd-proj__adv { margin-top: 12px; }
.sd-proj__adv-title {
  margin: 0 0 6px; font-size: 10px; font-weight: 600;
  color: hsl(var(--sd-muted-foreground));
}
.sd-proj__code {
  width: 100%; box-sizing: border-box; height: 120px; resize: vertical;
  padding: 9px 11px; border-radius: var(--sd-radius-sm);
  border: 1px solid hsl(var(--sd-border));
  background: hsl(var(--sd-muted) / .6); color: hsl(var(--sd-foreground));
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 10.5px; line-height: 1.6; outline: none;
}
.sd-proj__code:focus { border-color: hsl(var(--sd-ring)); background: hsl(var(--sd-card)); }

/* 空态 */
.sd-proj-empty {
  padding: 34px 20px; text-align: center;
  background: hsl(var(--sd-card));
  border: 1px dashed hsl(var(--sd-border));
  border-radius: var(--sd-radius);
}
.sd-proj-empty__title { margin: 0; font-size: 13px; font-weight: 600; color: hsl(var(--sd-muted-foreground)); }
.sd-proj-empty__desc { margin: 6px 0 0; font-size: 11px; color: hsl(var(--sd-muted-foreground)); }

/* 深色：卡片浮起一档（画布 8% → 卡片 14%），度量块沉到 9%，
   分隔线从「几乎不可见的 21%」提到 26%，控件底色再暗一档才有输入感。 */
html[data-sd-theme="dark"] .sd-proj {
  background: hsl(222 40% 14%);
  border-color: hsl(217 33% 26%);
  box-shadow: 0 1px 0 hsl(210 40% 96% / .045) inset, 0 10px 28px hsl(0 0% 0% / .3);
}
html[data-sd-theme="dark"] .sd-proj__metric {
  background: hsl(222 47% 9%);
  border-color: hsl(217 33% 22%);
  box-shadow: inset 0 1px 2px hsl(0 0% 0% / .35);
}
html[data-sd-theme="dark"] .sd-proj__row { border-top-color: hsl(217 33% 25%); }
html[data-sd-theme="dark"] .sd-proj__num,
html[data-sd-theme="dark"] .sd-proj__select,
html[data-sd-theme="dark"] .sd-proj__code {
  background: hsl(222 47% 10%);
  border-color: hsl(217 33% 27%);
}
html[data-sd-theme="dark"] .sd-proj__num:focus,
html[data-sd-theme="dark"] .sd-proj__select:focus,
html[data-sd-theme="dark"] .sd-proj__code:focus { background: hsl(222 47% 12%); }
html[data-sd-theme="dark"] .sd-proj__act { background: hsl(222 44% 17%); border-color: hsl(217 33% 30%); color: hsl(215 20% 82%); }
html[data-sd-theme="dark"] .sd-proj__act:hover { background: hsl(217 33% 24%); color: hsl(var(--sd-foreground)); }
/* 语义数值：令牌里的 success/warning 是给浅色底调的，压在 9% 的深槽上偏暗，单独提亮 */
html[data-sd-theme="dark"] .sd-proj__metric-value.is-ok { color: hsl(142 64% 56%); }
html[data-sd-theme="dark"] .sd-proj__metric-value.is-warn { color: hsl(33 94% 62%); }
html[data-sd-theme="dark"] .sd-proj__name { color: hsl(var(--sd-foreground)); }
html[data-sd-theme="dark"] .sd-proj__name:hover { background: hsl(217 33% 20%); }
html[data-sd-theme="dark"] .sd-proj-empty { background: hsl(222 44% 12%); border-color: hsl(217 33% 26%); }

@media (max-width: 560px) {
  .sd-proj__metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .sd-proj__row { grid-template-columns: 62px minmax(0, 1fr); row-gap: 4px; }
  .sd-proj__hint { grid-column: 2 / -1; }
  .sd-proj__head { flex-wrap: wrap; }
}

/* ── 24. 全局弹窗（AppConfirm / AppInput / AppResult）深色适配 ──────────────
   这三个弹窗来自 app/static/js/ui.js，卡片写在共用 ui.css 里（管理端、厂商端
   也在用，不能改源文件）。模板里的弹窗是挂到 body 下的，所以用 html 上的
   深色开关做作用域，只有控制台深色模式会命中。
   浅色下的白色卡片在深色页面上等于一块发光板，必须换面；同时保留各主题的
   色相（--conf-color 由 JS 按 red/amber/blue 下发），只用 color-mix 调深浅。 */
html[data-sd-theme="dark"] .ui-confirm__mask {
  background: hsl(222 47% 4% / .74);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
}
html[data-sd-theme="dark"] .ui-confirm__card {
  background: hsl(var(--sd-card));
  border-color: hsl(var(--sd-border));
  box-shadow: 0 32px 80px hsl(0 0% 0% / .6), 0 0 0 1px hsl(210 40% 96% / .04) inset;
}
html[data-sd-theme="dark"] .ui-confirm__title { color: hsl(var(--sd-foreground)); }
html[data-sd-theme="dark"] .ui-confirm__desc { color: hsl(var(--sd-muted-foreground)); }
html[data-sd-theme="dark"] .ui-confirm__foot {
  background: hsl(var(--sd-muted) / .45);
  border-top-color: hsl(var(--sd-border));
}
html[data-sd-theme="dark"] .ui-confirm__btn--cancel {
  background: hsl(222 44% 14%);
  border-color: hsl(217 33% 28%);
  color: hsl(215 20% 84%);
}
html[data-sd-theme="dark"] .ui-confirm__btn--cancel:hover { background: hsl(217 33% 20%); }
html[data-sd-theme="dark"] .ui-confirm__label { color: hsl(var(--sd-muted-foreground)); }
html[data-sd-theme="dark"] .ui-confirm__input {
  background: hsl(222 47% 10%);
  border-color: hsl(217 33% 27%);
  color: hsl(var(--sd-foreground));
}
html[data-sd-theme="dark"] .ui-confirm__input:focus { box-shadow: 0 0 0 3px hsl(var(--sd-ring) / .2); }
html[data-sd-theme="dark"] .ui-confirm__result-box {
  background: hsl(222 47% 10%);
  border-color: hsl(217 33% 26%);
  color: hsl(var(--sd-foreground));
}
html[data-sd-theme="dark"] .ui-confirm__copy {
  background: hsl(var(--sd-primary-soft));
  border-color: hsl(var(--sd-primary) / .4);
  color: hsl(var(--sd-primary));
}
html[data-sd-theme="dark"] .ui-confirm__copy:hover { background: hsl(var(--sd-primary) / .22); }
/* 图标圈与禁用态按钮的底色来自 JS 下发的浅色主题值，深色下要降饱和 */
html[data-sd-theme="dark"] .ui-confirm__btn--ok:disabled {
  background: var(--conf-soft);
  color: hsl(var(--sd-danger));
  filter: brightness(.45) saturate(1.6);
}
@supports (background: color-mix(in srgb, red 20%, transparent)) {
  html[data-sd-theme="dark"] .ui-confirm__icon {
    background: color-mix(in srgb, var(--conf-icon-bg) 22%, transparent);
  }
  html[data-sd-theme="dark"] .ui-confirm__btn--ok:disabled {
    background: color-mix(in srgb, var(--conf-color) 20%, transparent);
    color: color-mix(in srgb, var(--conf-color) 62%, white);
    filter: none;
  }
}

/* ── 25. Key 详情弹窗（#kd-modal）──────────────────────────────────────────
   原来整块是内联样式拼的：面板 #f8fafc、区块 #fff、行分隔 1px dashed #f3f4f6。
   深色下前两者都被第 9 节的兜底压成同一个 --sd-card，区块和面板糊成一片；
   而 dashed #f3f4f6 没有任何兜底命中，保留成浅灰虚线 —— 在 9% 的背景上
   像一排发光的点，比正文还抢眼。这里改成类驱动：
     面板 = 托盘（浅色灰 / 深色 card），区块 = 区块面（浅色白 / 深色略亮），
     行分隔用 --sd-border 实线，并且只给 label 与 value 各自一个明确的色阶。
   结构由 kdRow() / kdBlock() / renderKdDetail() 输出，改类名要同步改 JS。 */
.sd-kd {
  --kd-surface: hsl(var(--sd-background));  /* 浅色：比白卡略灰的托盘 */
  --kd-block: hsl(var(--sd-card));          /* 浅色：区块上浮成白卡 */
  width: 100%; max-width: 1020px;
  /* ⚠️ 上下留白走 margin，不走遮罩的 padding：sticky 头部是相对「滚动容器的
     padding box」吸顶的，遮罩只要带 padding-top，滚起来头部上方就会露出
     一条 24px 的缝，行内容从缝里穿上去。 */
  margin: 24px 0;
  background: var(--kd-surface);
  border: 1px solid hsl(var(--sd-border));
  border-radius: var(--sd-radius-lg);
  box-shadow: 0 24px 64px hsl(0 0% 0% / .28), 0 2px 8px hsl(0 0% 0% / .12);
}
/* 深色：托盘抬到 card（比遮罩亮），区块再亮一档形成内嵌面 ——
   方向和浅色相反，但两级关系一致：托盘永远是底色，区块永远比托盘"离眼睛近" */
html[data-sd-theme="dark"] .sd-kd {
  --kd-surface: hsl(var(--sd-card));
  --kd-block: hsl(var(--sd-muted) / .6);
  box-shadow: 0 24px 64px hsl(0 0% 0% / .55), 0 0 0 1px hsl(210 40% 96% / .03) inset;
}

.sd-kd__head {
  position: sticky; top: 0; z-index: 2;
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px 18px; flex-wrap: wrap;
  padding: 13px 18px;
  background: var(--kd-surface);
  border-bottom: 1px solid hsl(var(--sd-border));
  border-radius: var(--sd-radius-lg) var(--sd-radius-lg) 0 0;
}
.sd-kd__ident { display: flex; align-items: center; gap: 10px; min-width: 0; }
.sd-kd__code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 17px; font-weight: 700; letter-spacing: .03em;
  color: hsl(var(--sd-primary));
  white-space: nowrap;
}
.sd-kd__state {
  display: inline-flex; align-items: center;
  padding: 3px 9px; border-radius: 999px;
  font-size: 10.5px; font-weight: 650; line-height: 1.4;
  white-space: nowrap;
}

.sd-kd__acts { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.sd-kd__key {
  padding: 5px 8px; margin-right: 2px;
  border-radius: 7px; cursor: pointer;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px; font-weight: 500;
  color: hsl(var(--sd-muted-foreground));
  transition: background .15s ease, color .15s ease;
}
.sd-kd__key:hover { background: hsl(var(--sd-accent)); color: hsl(var(--sd-foreground)); }
.sd-kd__key:active { background: hsl(var(--sd-border)); }

/* 操作按钮：默认中性（描边 + 卡片底），语义态只染文字与描边，别让整条工具栏染色 */
.sd-kd__btn {
  padding: 6px 11px; border-radius: var(--sd-radius-sm);
  border: 1px solid hsl(var(--sd-border));
  background: var(--kd-block);
  color: hsl(var(--sd-muted-foreground));
  font-family: inherit; font-size: 11px; font-weight: 650; line-height: 1.2;
  cursor: pointer;
  transition: background .15s ease, color .15s ease, border-color .15s ease;
}
.sd-kd__btn:hover { background: hsl(var(--sd-accent)); color: hsl(var(--sd-foreground)); }
.sd-kd__btn--danger { color: hsl(var(--sd-text-red)); border-color: hsl(var(--sd-danger) / .42); }
.sd-kd__btn--danger:hover {
  background: hsl(var(--sd-danger-soft)); color: hsl(var(--sd-text-red));
  border-color: hsl(var(--sd-danger) / .6);
}
.sd-kd__btn--success { color: hsl(var(--sd-text-green)); border-color: hsl(var(--sd-success) / .42); }
.sd-kd__btn--success:hover {
  background: hsl(var(--sd-success-soft)); color: hsl(var(--sd-text-green));
  border-color: hsl(var(--sd-success) / .6);
}
.sd-kd__btn--warn { color: hsl(var(--sd-text-amber)); border-color: hsl(var(--sd-warm) / .38); }
.sd-kd__btn--warn:hover {
  background: hsl(var(--sd-warm-soft)); color: hsl(var(--sd-text-amber));
  border-color: hsl(var(--sd-warm) / .55);
}
/* 风险动作（重置绑定）：平时保持中性，只在悬停时说话 ——
   三个按钮各染一色会让工具栏变成红绿灯，反而没人知道该点哪个 */
.sd-kd__btn--risk:hover {
  background: hsl(var(--sd-danger-soft)); color: hsl(var(--sd-text-red));
  border-color: hsl(var(--sd-danger) / .55);
}
.sd-kd__close {
  display: grid; place-items: center;
  width: 28px; height: 28px; padding: 0;
  border: 0; border-radius: 8px;
  background: transparent; color: hsl(var(--sd-muted-foreground));
  font-size: 17px; font-weight: 600; line-height: 1; cursor: pointer;
  transition: background .15s ease, color .15s ease;
}
.sd-kd__close:hover { background: hsl(var(--sd-accent)); color: hsl(var(--sd-foreground)); }

.sd-kd__body { padding: 16px 18px 18px; }
.sd-kd-grid {
  display: grid; gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  align-items: start;  /* 两栏行数不同，别让短的那张被拉到同高留一大片空 */
}

.sd-kd-card {
  min-width: 0;
  padding: 12px 14px 6px;
  background: var(--kd-block);
  border: 1px solid hsl(var(--sd-border) / .8);
  border-radius: var(--sd-radius);
}
/* 区块标题：中文不用 uppercase / 大字距，改用一根短竖条做视觉锚点 */
.sd-kd-card__title {
  display: flex; align-items: center; gap: 7px;
  margin: 0 0 6px;
  font-size: 11px; font-weight: 650; letter-spacing: .01em;
  color: hsl(var(--sd-muted-foreground));
}
.sd-kd-card__title::before {
  content: ""; width: 3px; height: 11px; border-radius: 2px;
  background: hsl(var(--sd-primary) / .55);
}
.sd-kd-card__rows { display: flex; flex-direction: column; }

/* 行：label 恒在左、value 恒在右，中间只留一条低对比实线。
   深色下 border/…/0.7 叠在 14% 的区块面上，比虚线安静得多。 */
.sd-kd-row {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 14px; padding: 8px 0;
  border-top: 1px solid hsl(var(--sd-border) / .7);
}
.sd-kd-row:first-child { border-top: 0; padding-top: 4px; }
.sd-kd-row__label {
  flex-shrink: 0;
  font-size: 11px; font-weight: 600; line-height: 1.5;
  color: hsl(var(--sd-muted-foreground));
}
.sd-kd-row__value {
  min-width: 0; text-align: right;
  font-size: 12px; font-weight: 600; line-height: 1.5;
  font-variant-numeric: tabular-nums;
  color: hsl(var(--sd-foreground));
  word-break: break-all;
}
/* 余额是这张卡的落点，给一个字号/颜色的抬升，别和其余 7 行一个平面 */
.sd-kd-row__value--strong {
  font-size: 13px; font-weight: 700;
  color: hsl(var(--sd-primary));
}
/* 上报时长异常标记：原来是行内 "⚠ 异常" 文字，混在数字里读不出来 */
.sd-kd-flag {
  display: inline-flex; align-items: center; margin-left: 6px;
  padding: 1px 6px; border-radius: 999px;
  font-size: 10px; font-weight: 650; line-height: 1.5;
  vertical-align: 1px;
  color: hsl(var(--sd-text-amber));
  background: hsl(var(--sd-warm-soft));
  border: 1px solid hsl(var(--sd-warm) / .38);
}

.sd-kd-empty {
  padding: 40px; text-align: center;
  font-size: 12px; color: hsl(var(--sd-muted-foreground));
}
.sd-kd-empty--err { color: hsl(var(--sd-text-red)); }

@media (max-width: 620px) {
  .sd-kd__head { padding: 12px 14px; }
  .sd-kd__body { padding: 12px 12px 14px; }
  .sd-kd__acts { width: 100%; }
  .sd-kd__key { flex: 1 1 100%; margin-bottom: 2px; }
}

