/* 设计令牌：颜色的唯一来源。
 *
 * 关键约定：沿用旧变量名（--bg/--card/--border/--fg/--dim/--green/--yellow/--red/--blue），
 * 只换值。legacy.css 与 4000 行脚本里的大量内联 style 都引用这些名字，
 * 改名字等于全站失效；改值则整体换肤。
 *
 * 语义色只表达四种状态，不新增第五种：
 *   绿=正常 / 琥珀=需注意（即将过期、水位偏低） / 红=异常 / 蓝=信息与主操作。
 * 浅色取 Tailwind green-600 / amber-700 / red-600 / blue-600，
 * 白底对比度 3.9~5.2:1；三档文字（--fg / --fg-2 / --dim）为 slate-900/700/500，
 * 对比度约 14.6:1 / 8.3:1 / 4.8:1，均过 WCAG AA。
 */

:root {
  color-scheme: light;

  /* 表面：冷调浅灰蓝，比纯灰更显干净 */
  --bg: #f5f7fb;
  --bg-subtle: #f9fafd;
  --card: #ffffff;
  --card-hover: #fcfdff;

  /* 线条 */
  --border: #e5e9f2;
  --border-strong: #cdd5e4;

  /* 文字：slate 系 */
  --fg: #0f172a;
  --fg-2: #334155;
  --dim: #64748b;

  /* 语义：饱和但不刺眼，soft 底色配同族文字 */
  --green: #16a34a;
  --green-soft: #e7f6ee;
  --yellow: #b45309;
  --yellow-soft: #fcf0dd;
  --red: #dc2626;
  --red-soft: #fdecec;
  --blue: #2563eb;
  --blue-soft: #e9effd;

  /* 形状 */
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;

  /* 间距（4 基数） */
  --s1: 4px;
  --s2: 8px;
  --s3: 12px;
  --s4: 16px;
  --s5: 24px;
  --s6: 32px;

  /* 阴影：只有浮起层（抽屉/弹框/下拉）用，平面元素一律靠边框分隔 */
  --shadow-pop: 0 8px 24px rgba(15, 23, 42, 0.10);
  --shadow-drawer: 0 12px 40px rgba(15, 23, 42, 0.16);

  /* 字号 */
  --fs-label: 11px;
  --fs-aux: 12px;
  --fs-body: 13px;
  --fs-title: 15px;
  --fs-metric: 20px;

  /* 布局 */
  --sidebar-w: 208px;

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

  --t-fast: 120ms ease;
}

/* 暗色：跟随系统，但允许 [data-theme] 覆盖。令牌名不变，只换值。
 * 蓝调深板岩（比纯黑灰更有层次），语义色用 400 档保证暗底上的鲜亮度。 */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0e1420;
    --bg-subtle: #131a29;
    --card: #171f30;
    --card-hover: #1b2437;
    --border: #2a3549;
    --border-strong: #3b4863;
    --fg: #e8edf6;
    --fg-2: #b7c1d3;
    --dim: #8391a6;
    --green: #4ade80;
    --green-soft: #12291c;
    --yellow: #fbbf24;
    --yellow-soft: #2d2410;
    --red: #f87171;
    --red-soft: #331519;
    --blue: #60a5fa;
    --blue-soft: #14263f;
    --shadow-pop: 0 8px 24px rgba(0, 0, 0, 0.5);
    --shadow-drawer: 0 12px 40px rgba(0, 0, 0, 0.6);
  }
}

[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0e1420;
  --bg-subtle: #131a29;
  --card: #171f30;
  --card-hover: #1b2437;
  --border: #2a3549;
  --border-strong: #3b4863;
  --fg: #e8edf6;
  --fg-2: #b7c1d3;
  --dim: #8391a6;
  --green: #4ade80;
  --green-soft: #12291c;
  --yellow: #fbbf24;
  --yellow-soft: #2d2410;
  --red: #f87171;
  --red-soft: #331519;
  --blue: #60a5fa;
  --blue-soft: #14263f;
  --shadow-pop: 0 8px 24px rgba(0, 0, 0, 0.5);
  --shadow-drawer: 0 12px 40px rgba(0, 0, 0, 0.6);
}
