/* ============================================================
 * 云控 V7 · 设计变量（Design Tokens）
 * 唯一色/字/间距/圆角/阴影来源；组件样式只消费变量，不写字面量。
 * 浅色为默认，深色通过 <html data-theme="dark"> 覆盖语义层。
 * 无第三方依赖，离线内网可用。
 * ============================================================ */

:root {
  color-scheme: light;

  /* ---------- 中性色 · 12 级（1 最浅 → 12 最深） ---------- */
  --n1:  #ffffff;
  --n2:  #f8fafc;
  --n3:  #f1f5f9;
  --n4:  #e9eef5;
  --n5:  #dfe6ef;
  --n6:  #cbd5e1;
  --n7:  #94a3b8;
  --n8:  #64748b;
  --n9:  #475569;
  --n10: #334155;
  --n11: #1e293b;
  --n12: #0f172a;

  /* ---------- 品牌色 ---------- */
  --brand-50:  #eff6ff;
  --brand-100: #dbeafe;
  --brand-200: #bfdbfe;
  --brand-500: #3b82f6;
  --brand:     #2563eb;
  --brand-600: #1d4ed8;
  --brand-700: #1e40af;

  /* ---------- 语义色 ---------- */
  --ok:       #16a34a;
  --ok-bg:    #ecfdf3;
  --ok-bd:    #bbf7d0;
  --warn:     #d97706;
  --warn-bg:  #fffbeb;
  --warn-bd:  #fde68a;
  --danger:   #dc2626;
  --danger-bg:#fef2f2;
  --danger-bd:#fecaca;
  --info:     #0ea5e9;
  --info-bg:  #f0f9ff;
  --info-bd:  #bae6fd;
  --purple:   #7c3aed;
  --purple-bg:#f5f3ff;
  --purple-bd:#ddd6fe;
  --teal:     #0d9488;
  --teal-bg:  #f0fdfa;
  --teal-bd:  #99f6e4;
  /* -fg：浅底上的语义文字色（-bg 底 + -fg 字达到 AA；-ok/-warn 等只用于描边、圆点、大图形） */
  --ok-fg:    #166534;
  --warn-fg:  #92400e;
  --danger-fg:#991b1b;
  --info-fg:  #075985;
  --brand-fg: #1d4ed8;
  --purple-fg:#6d28d9;
  --teal-fg:  #115e59;

  /* ---------- 语义映射（浅色） ---------- */
  --bg:          var(--n2);
  --bg-elevated: var(--n1);
  --surface:     var(--n1);
  --surface-2:   var(--n3);
  --surface-3:   var(--n4);
  --surface-hover: var(--n3);
  --border:      var(--n4);
  --border-strong: var(--n6);
  --text:        var(--n12);
  --text-2:      var(--n9);
  --text-3:      var(--n8);
  --text-4:      var(--n7);
  --text-inv:    #ffffff;
  --focus-ring:  0 0 0 3px rgba(37, 99, 235, .20);
  --selection:   var(--brand-100);

  /* ---------- 字阶（正文 13，数据密度优先） ---------- */
  --fs-11: 11px;
  --fs-12: 12px;
  --fs-13: 13px;
  --fs-14: 14px;
  --fs-16: 16px;
  --fs-20: 20px;
  --fs-24: 24px;
  --fs-30: 30px;

  --lh-tight: 1.25;
  --lh-base:  1.55;
  --fw-normal: 400;
  --fw-medium: 500;
  --fw-semi:   600;
  --fw-bold:   700;

  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei",
          "PingFang SC", "Hiragino Sans GB", "Noto Sans SC", sans-serif;
  --mono: ui-monospace, "Cascadia Code", "Cascadia Mono", Consolas,
          "SF Mono", Menlo, "Liberation Mono", monospace;

  /* ---------- 间距（4 的倍数） ---------- */
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 20px;
  --sp-6: 24px;
  --sp-7: 28px;
  --sp-8: 32px;
  --sp-10: 40px;

  /* ---------- 圆角 ---------- */
  --r-xs: 6px;
  --r-sm: 8px;    /* 控件 */
  --r-md: 12px;   /* 卡片 */
  --r-lg: 16px;   /* 抽屉 / 弹窗 */
  --r-pill: 999px;

  /* ---------- 阴影 · 3 级 ---------- */
  --sh-1: 0 1px 2px rgba(15, 23, 42, .05), 0 1px 3px rgba(15, 23, 42, .05);
  --sh-2: 0 4px 12px rgba(15, 23, 42, .08), 0 1px 3px rgba(15, 23, 42, .05);
  --sh-3: 0 16px 40px rgba(15, 23, 42, .16), 0 4px 12px rgba(15, 23, 42, .08);

  /* ---------- 布局 ---------- */
  --side-w: 216px;
  --side-w-collapsed: 64px;
  --top-h: 56px;
  --view-max: 1600px;
  --row-h: 40px;
  --ctrl-h: 32px;
  --ctrl-h-sm: 26px;

  /* ---------- 层级 ---------- */
  --z-pop: 50;
  --z-drawer: 60;
  --z-modal: 70;
  --z-toast: 80;

  /* ---------- 动效 ---------- */
  --t-fast: 120ms;
  --t-base: 180ms;
  --ease: cubic-bezier(.4, 0, .2, 1);
}

/* ============================ 深色 ============================ */
html[data-theme="dark"] {
  color-scheme: dark;

  --n1:  #0b1220;
  --n2:  #0e1626;
  --n3:  #131e30;
  --n4:  #1d2a3f;
  --n5:  #22304a;
  --n6:  #334155;
  --n7:  #5b6b83;
  --n8:  #8494ab;
  --n9:  #a8b6cc;
  --n10: #c4d0e0;
  --n11: #dde5f0;
  --n12: #eef3fa;

  --brand-50:  #10203a;
  --brand-100: #16294a;
  --brand-200: #1d3559;
  --brand-500: #60a5fa;
  --brand:     #3b82f6;
  --brand-600: #60a5fa;
  --brand-700: #93c5fd;

  --ok:       #22c55e;
  --ok-bg:    #0d2a1b;
  --ok-bd:    #14532d;
  --warn:     #f59e0b;
  --warn-bg:  #2a1f08;
  --warn-bd:  #78350f;
  --danger:   #ef4444;
  --danger-bg:#2c1315;
  --danger-bd:#7f1d1d;
  --info:     #38bdf8;
  --info-bg:  #072736;
  --info-bd:  #075985;
  --purple:   #a78bfa;
  --purple-bg:#1d1738;
  --purple-bd:#4c1d95;
  --teal:     #2dd4bf;
  --teal-bg:  #062a28;
  --teal-bd:  #115e59;
  --ok-fg:    #4ade80;
  --warn-fg:  #fbbf24;
  --danger-fg:#f87171;
  --info-fg:  #38bdf8;
  --brand-fg: #60a5fa;
  --purple-fg:#a78bfa;
  --teal-fg:  #2dd4bf;

  --bg:          #0b1220;
  --bg-elevated: #111a2b;
  --surface:     #111a2b;
  --surface-2:   #16202f;
  --surface-3:   #1d2a3f;
  --surface-hover: #1a2638;
  --border:      #22304a;
  --border-strong: #334155;
  --text:        #e6edf7;
  --text-2:      #a8b6cc;
  --text-3:      #8494ab;
  --text-4:      #6b7c94;
  --text-inv:    #0b1220;
  --focus-ring:  0 0 0 3px rgba(59, 130, 246, .32);
  --selection:   #1e3a5f;

  --sh-1: 0 1px 2px rgba(0, 0, 0, .40), 0 1px 3px rgba(0, 0, 0, .30);
  --sh-2: 0 6px 18px rgba(0, 0, 0, .50), 0 1px 3px rgba(0, 0, 0, .35);
  --sh-3: 0 20px 48px rgba(0, 0, 0, .62), 0 4px 14px rgba(0, 0, 0, .40);
}

/* ============================================================
 * 断点 · 移动密度 · 安全区（V7 移动端适配）
 * 断点三档：
 *   桌面 ≥1101 · 平板 769–1100 · 手机 ≤768
 * 媒体查询里只能写数值字面量，故下面两处 @media 的数值需与变量注释同步；
 * 变量本身供 JS/CSS 消费（抽屉宽度、行高、日志高度、安全区）。
 * ============================================================ */
:root {
  /* 断点（记录用，供脚本读取 document 上的 --bp-* ） */
  --bp-tablet: 1100px;
  --bp-mobile: 768px;

  /* 触控密度 */
  --tap-min: 40px;               /* 可点区域最小边长 */
  --row-h-touch: 44px;           /* 移动端表格行高 */
  --nav-drawer-w: min(80vw, 300px);  /* 侧栏抽屉【最大】宽度：内容宽时以内容为准 */
  --nav-drawer-min: 176px;       /* 抽屉最小宽度：图标 + 2~4 字 + 箭头刚好放下 */
  --log-h-mobile: 45vh;          /* 运行台日志高度 */

  /* 安全区（iPhone 刘海 / 底部手势条） */
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
}

/* ---------- 平板 769–1100：侧栏收窄，顶栏略降 ---------- */
@media (min-width: 769px) and (max-width: 1100px) {
  :root {
    --side-w: 188px;
    --top-h: 52px;
    --view-max: 100%;
    --row-h: 40px;
  }
}

/* ---------- 手机 ≤768：顶栏 48 / 行高 44 / 控件 40 ---------- */
@media (max-width: 768px) {
  :root {
    --top-h: 48px;
    --row-h: var(--row-h-touch);
    --ctrl-h: var(--tap-min);
    --ctrl-h-sm: 36px;
    --side-w: var(--nav-drawer-w);
    --view-max: 100%;
    --fs-20: 19px;
    --fs-24: 21px;
  }
}
