/* ===============================================================
   CJONE 物业管理系统 — macOS 27「Liquid Glass」设计系统
   ===============================================================
   设计原则（与 v1 平面风格的区别）：
     1) 分层材质：窗口 → 侧栏 → 卡片 → 弹层，每层有不同的透明度与模糊半径，
        靠「材质厚度」建立层级，而不是靠边框和阴影堆叠。
     2) 连续圆角：所有容器用较大圆角 + 内描边高光（specular highlight），
        模拟玻璃边缘的折射感。1px 硬边框尽量去掉。
     3) 内容优先：玻璃只用在「容器」上，数据格与文字永远不透明 ——
        矩阵里透出背景会毁掉可读性，这是风格让位于功能的地方。
     4) 紧急度六色阶**一个字节都没改**：那套色是「相邻两档在色相/明度/填充方式
        三者中至少两项不同」推导出来的，改色即破坏色盲冗余编码。风格不得侵入语义。
   =============================================================== */

:root {
  /* ---------- 紧急度：语义层，风格层不得修改 ---------- */
  --st-expired-bg: #9E1B32; --st-expired-fg: #FFFFFF; --st-expired-bd: #9E1B32;
  --st-due7-bg:    #C2410C; --st-due7-fg:    #FFFFFF; --st-due7-bd:    #C2410C;
  --st-due30-bg:   #FDF1D6; --st-due30-fg:   #6B3A0F; --st-due30-bd:   #E9B44C;
  --st-ok-bg:      #E9F5EE; --st-ok-fg:      #1B6B45; --st-ok-bd:      #CBE6D5;
  --st-exempt-bg:  #F1F2F4; --st-exempt-fg:  #5C6470; --st-exempt-bd:  #D5D9DF;
  --st-wip-bg:     #F1EAFE; --st-wip-fg:     #5B21B6; --st-wip-bd:     #C4B5FD;

  /* 「缺少处理单据」是独立维度，不参与紧急度配色 */
  --st-doc-missing: #C2410C;
  --st-critical-ring: #6B0F1F;
  --st-critical-halo: rgba(158, 27, 50, .12);

  /* ---------- 中性：取自 macOS 27 系统灰阶 ---------- */
  --bg-canvas: #E9E9EC;
  --bg-surface: #FFFFFF;
  --bg-subtle: rgba(120, 120, 128, .08);
  --bg-na: #FAFBFC;
  --tx-primary: #1D1D1F;
  --tx-secondary: #515154;
  --tx-tertiary: #8A8A8E;

  /* 玻璃材质用的极细描边（不是灰线，是白色的边缘高光） */
  --hairline: rgba(0, 0, 0, .07);
  --hairline-strong: rgba(0, 0, 0, .12);
  --specular: rgba(255, 255, 255, .72);
  --bd-default: rgba(0, 0, 0, .08);
  --bd-strong: rgba(0, 0, 0, .16);

  /* ---------- 品牌：金冠（CJone253）----------
   * ★★★ 为什么主色不是「亮金 #F5C542」而是这个偏暗的琥珀金：
   *   亮金上放白字，对比度只有 1.62 —— 按钮文字基本看不清（实测值）。
   *   徽标里的亮金只用于**图形**（不需要承载文字），
   *   而这里要用于**按钮背景**，必须选能托住白字的色阶。
   *
   *   实测（WCAG 对比度）：
   *     白字 on #F5C542 → 1.62  ✗ 不可用
   *     白字 on #B87718 → 3.69  AA-large（仅大字）
   *     白字 on #A8681A → 4.51  ✓ AA（正文字号也合规）← 采用
   *     白字 on #8F5712 → 5.93  ✓ AA（悬停/按下更暗）
   *
   *   这是「风格让位于可读性」的地方：品牌识别由徽标和标题承担，
   *   交互控件必须是可读的 —— 一个看不清字的金色按钮不叫高级，叫缺陷。
   */
  --brand-600: #A8681A;
  --brand-700: #8F5712;
  --brand-50: rgba(168, 104, 26, .10);
  --focus-ring: rgba(168, 104, 26, .38);
  /* 徽标专用亮金：只用于图形与分隔线，永不承载文字 */
  --gold-bright: #F5C542;
  --gold-light: #FFE9A8;
  --gold-deep: #B87718;

  /**
   * ★★★ 品牌色的「同一个变量不能同时当按钮底色和文字色」——
   *   --brand-600 (#A8681A) 当**按钮底色**时白字 4.51 合格，
   *   但同一个色当**文字**放在 --bg-canvas (#E9E9EC) 上只有 3.72，不达 AA。
   *   方向正好相反：底色要暗到能托住白字，文字要暗到能从浅灰底上跳出来，
   *   而画布本身不是纯白，于是「刚好合格的那一档」在两种用途下并不重合。
   *
   *   实测（对 #E9E9EC 画布）：
   *     #A8681A → 3.72  ✗
   *     #8F5712 → 4.90  ✓
   *     #96540D → 4.85  ✓  ← 文字色采用（另有 5.88 on 纯白，卡片里也够）
   *
   *   所以拆成两组：--brand-* 供背景/边框/焦点环，
   *   --brand-ink 供文字（链接、强调数字）。深色模式下两者也各自反转。
   */
  --brand-ink: #96540D;

  /**
   * ★★★ 按钮渐变的三段单独成变量，**不引用 --brand-600**。
   *   原因：深色模式下 --brand-600 会反转成亮金 #E8B33C，
   *   若渐变写成 `linear-gradient(#B26010, var(--brand-600))`，
   *   深色下就变成「暗棕 → 亮金」这种跨 60 度明度的脏渐变，
   *   而且亮金那一端配白字只有 1.92 —— 按钮右半边直接看不清。
   *   渐变是「一整套配色」，必须整组一起换。
   */
  --brand-btn-top: #B26010;   /* 白字 4.59 ✓ */
  --brand-btn-mid: #A8681A;   /* 白字 4.51 ✓ */
  --brand-btn-bot: #8F5712;   /* 白字 5.93 ✓ */
  --brand-btn-top-h: #A8681A;
  --brand-btn-mid-h: #9E5A10;
  --brand-btn-bot-h: #7C4A0E;
  --brand-on-btn: #FFFFFF;    /* 品牌底上的文字色：浅色下用白 */
  --danger: #D70015;
  --ok: #1B8A4B;

  /* ---------- 材质：三档厚度 ---------- */
  /* 薄：卡片、工具条 —— 能透过背景但内容清晰 */
  --glass-thin: rgba(255, 255, 255, .66);
  --glass-thin-blur: blur(20px) saturate(180%);
  /* 中：弹层、菜单 —— 明显玻璃感 */
  --glass-medium: rgba(252, 252, 253, .82);
  --glass-medium-blur: blur(34px) saturate(190%);
  /* 厚：侧栏 —— macOS 的 sidebar vibrancy，透出桌面但压低饱和 */
  --glass-thick: rgba(246, 246, 248, .62);
  --glass-thick-blur: blur(48px) saturate(170%);

  /* ---------- 尺度 ---------- */
  --sp-1: 4px; --sp-2: 8px; --sp-3: 12px; --sp-4: 16px; --sp-5: 20px;
  --sp-6: 24px; --sp-8: 32px; --sp-10: 40px; --sp-12: 48px; --sp-16: 64px;

  /* 连续圆角：macOS 27 的比例，越大的容器圆角越大 */
  --r-xs: 4px; --r-sm: 8px; --r-md: 13px; --r-lg: 18px; --r-xl: 24px; --r-pill: 999px;

  /* 分层阴影：macOS 的阴影很淡但离得很远，靠「距离」而不是「黑度」表达层级 */
  --sh-sm: 0 1px 2px rgba(0, 0, 0, .05), 0 1px 1px rgba(0, 0, 0, .03);
  --sh-md: 0 4px 14px rgba(0, 0, 0, .07), 0 1px 3px rgba(0, 0, 0, .04);
  --sh-lg: 0 18px 48px rgba(0, 0, 0, .16), 0 4px 12px rgba(0, 0, 0, .07);
  --sh-win: 0 32px 80px rgba(0, 0, 0, .22), 0 8px 24px rgba(0, 0, 0, .10);

  /* 内描边高光 —— 玻璃感的关键，比外部阴影更能说明「这是块玻璃」 */
  --inset-hi: inset 0 1px 0 rgba(255, 255, 255, .9);
  --inset-hi-strong: inset 0 1px 0 rgba(255, 255, 255, .95), inset 0 -1px 0 rgba(0, 0, 0, .04);

  --cell-w: 136px; --cell-h: 44px; --row-h: 48px; --col-freeze: 200px;

  --font-sans: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text",
    "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei UI",
    "Microsoft YaHei", "Source Han Sans SC", "Noto Sans CJK SC", sans-serif;
  --font-num: "SF Mono", ui-monospace, "JetBrains Mono", Menlo, Consolas, monospace;

  --dur-fast: 140ms; --dur-base: 240ms; --dur-slow: 380ms; --dur-pulse: 2000ms;
  --ease-out: cubic-bezier(.22, .78, .20, 1);
  --ease-spring: cubic-bezier(.34, 1.36, .64, 1);

  --sidebar-w: 236px;
  --winbar-h: 38px;
  --topbar-h: 56px;

  color-scheme: light dark;
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0;
  /* 画布用极淡的冷色渐变，玻璃层才有东西可以「透过」 */
  background:
    radial-gradient(1100px 620px at 12% -8%, #EDF3FE 0%, transparent 62%),
    radial-gradient(900px 560px at 92% 108%, #F3EEFB 0%, transparent 58%),
    var(--bg-canvas);
  background-attachment: fixed;
  color: var(--tx-primary);
  font-family: var(--font-sans);
  font-size: 14px; line-height: 1.57;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  letter-spacing: -.006em;
}

body { min-height: 100vh; }

button, input, select, textarea {
  font-family: inherit; font-size: inherit; color: inherit;
}

button { cursor: pointer; border: none; background: none; }
/**
 * 链接用 --brand-ink 而不是 --brand-600：见变量定义处的实测说明。
 * 画布 #E9E9EC 上 #A8681A 只有 3.72，不够 AA；#96540D 是 4.90。
 */
a { color: var(--brand-ink); text-decoration: none; }
a:hover { text-decoration: underline; }

.num { font-family: var(--font-num); font-variant-numeric: tabular-nums; }

h1, h2, h3, h4 { margin: 0; font-weight: 600; letter-spacing: -.022em; }
h1 { font-size: 28px; line-height: 34px; }
h2 { font-size: 21px; line-height: 27px; }
h3 { font-size: 16px; line-height: 23px; }
h4 { font-size: 14px; line-height: 21px; }

.muted { color: var(--tx-secondary); }
.dim { color: var(--tx-tertiary); }
.tiny { font-size: 11px; line-height: 14px; font-weight: 500; }
.small { font-size: 12px; line-height: 16px; }

/* ---------------- 状态胶囊 ----------------
   语义色不变，只换形态：连续圆角 + 内高光，像 macOS 的标签。
   ------------------------------------------------- */
.pill {
  display: inline-flex; align-items: center; gap: 4px;
  height: 21px; padding: 0 8px;
  border-radius: var(--r-pill);
  font-size: 11px; font-weight: 600; line-height: 1;
  white-space: nowrap;
  border: 1px solid transparent;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .35);
}
.pill .ico { width: 10px; height: 10px; flex: 0 0 auto; }

.pill.expired { background: var(--st-expired-bg); color: var(--st-expired-fg); border-color: var(--st-expired-bd); }
.pill.due7    { background: var(--st-due7-bg);    color: var(--st-due7-fg);    border-color: var(--st-due7-bd); }
.pill.due30   { background: var(--st-due30-bg);   color: var(--st-due30-fg);   border-style: dashed; border-color: var(--st-due30-bd); }
.pill.ok      { background: var(--st-ok-bg);      color: var(--st-ok-fg);      border-color: var(--st-ok-bd); }
.pill.wip     { background: var(--st-wip-bg);     color: var(--st-wip-fg);     border-style: dashed; border-color: var(--st-wip-bd); }
.pill.exempt  {
  background: var(--st-exempt-bg); color: var(--st-exempt-fg); border-color: var(--st-exempt-bd);
  background-image: repeating-linear-gradient(45deg, rgba(92,100,112,.10) 0 1px, transparent 1px 4px);
}
.pill.na { background: var(--bg-na); color: var(--tx-tertiary); border-color: var(--bd-default); }

.pill.expired .ico, .pill.due7 .ico { opacity: .95; }

/* ---------------- 按钮 ----------------
   玻璃按钮：半透明底 + 内高光 + 极细描边。
   主按钮用品牌色实心（它在玻璃上是唯一需要「实」的东西）。
   ------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 34px; padding: 0 14px;
  border-radius: var(--r-sm);
  font-size: 13.5px; font-weight: 500;
  letter-spacing: -.008em;
  border: 1px solid var(--hairline-strong);
  background: linear-gradient(180deg, rgba(255,255,255,.92), rgba(250,250,252,.82));
  color: var(--tx-primary);
  box-shadow: var(--inset-hi-strong), var(--sh-sm);
  transition:
    background var(--dur-fast) var(--ease-out),
    box-shadow var(--dur-fast) var(--ease-out),
    transform var(--dur-fast) var(--ease-out);
  white-space: nowrap;
  -webkit-backdrop-filter: var(--glass-thin-blur);
  backdrop-filter: var(--glass-thin-blur);
}
.btn:hover {
  background: linear-gradient(180deg, #FFFFFF, rgba(246,246,249,.92));
  box-shadow: var(--inset-hi-strong), 0 2px 8px rgba(0,0,0,.09);
}
.btn:active { transform: scale(.975); box-shadow: inset 0 1px 2px rgba(0,0,0,.10); }
.btn:focus-visible { outline: 3px solid var(--focus-ring); outline-offset: 2px; }
.btn:disabled { opacity: .42; cursor: not-allowed; transform: none; }
.btn:disabled:hover { background: linear-gradient(180deg, rgba(255,255,255,.92), rgba(250,250,252,.82)); box-shadow: var(--inset-hi-strong), var(--sh-sm); }

.btn.primary {
  /**
   * ★★★ 渐变的三段全部在白字对比度 ≥4.5 的区间内（实测）：
   *     顶 #B26010 → 4.59 · 中 #A8681A → 4.51 · 底 #8F5712 → 5.93
   *   这里有一个很容易踩的坑：为了「金色显得亮」把渐变顶部提亮到 #D9992A，
   *   白字对比度立刻掉到 2.46 —— 按钮看起来更「金」，但字看不清了。
   *   渐变里**不能有任何一段**低于 4.5，因为文字会跨过整个渐变分布。
   *   想要更亮的金，只能换深色模式（那边文字是深的），见文件末尾。
   */
  background: linear-gradient(180deg, var(--brand-btn-top), var(--brand-btn-mid) 55%, var(--brand-btn-bot));
  border-color: rgba(90, 40, 0, .34);
  color: var(--brand-on-btn);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.34), 0 1px 3px rgba(150,86,10,.35), 0 0 0 .5px rgba(140,80,8,.24);
  -webkit-backdrop-filter: none; backdrop-filter: none;
}
.btn.primary:hover {
  /* 悬停是「更暗」而不是「更亮」：亮色会让白字对比度跌破门槛 */
  background: linear-gradient(180deg, var(--brand-btn-top-h), var(--brand-btn-mid-h) 55%, var(--brand-btn-bot-h));
  box-shadow: inset 0 1px 0 rgba(255,255,255,.40), 0 3px 10px rgba(150,86,10,.42);
}
.btn.ghost {
  border-color: transparent; background: transparent; color: var(--tx-secondary);
  box-shadow: none; -webkit-backdrop-filter: none; backdrop-filter: none;
}
.btn.ghost:hover { background: var(--bg-subtle); color: var(--tx-primary); box-shadow: none; }
.btn.ghost:active { transform: scale(.97); box-shadow: none; }
.btn.danger {
  background: linear-gradient(180deg, #F0353F, var(--danger) 60%, #C1000F);
  border-color: rgba(120, 0, 12, .34); color: #fff;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.30), 0 1px 3px rgba(200,0,20,.34);
  -webkit-backdrop-filter: none; backdrop-filter: none;
}
.btn.danger:hover { filter: brightness(1.06); }
.btn.sm { height: 27px; padding: 0 10px; font-size: 12px; border-radius: 7px; gap: 5px; }
.btn.block { width: 100%; }

/* ---------------- 表单 ----------------
   输入框做成「凹陷的玻璃槽」，与凸起的按钮形成对照。
   ------------------------------------------------- */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: var(--sp-4); }
.field > label { font-size: 12.5px; font-weight: 600; color: var(--tx-secondary); letter-spacing: -.004em; }
.field .req { color: var(--danger); margin-left: 2px; }
.input, .select, .textarea {
  width: 100%; height: 36px; padding: 0 12px;
  border: 1px solid var(--hairline-strong); border-radius: var(--r-sm);
  background: rgba(255, 255, 255, .78);
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, .05);
  transition: border-color var(--dur-fast), box-shadow var(--dur-fast), background var(--dur-fast);
}
.textarea { height: auto; min-height: 78px; padding: 10px 12px; resize: vertical; line-height: 1.5; }
.input:hover, .select:hover, .textarea:hover { border-color: rgba(0,0,0,.22); }
.input:focus, .select:focus, .textarea:focus {
  outline: none; background: #fff;
  border-color: var(--brand-600);
  box-shadow: inset 0 1px 2px rgba(0,0,0,.04), 0 0 0 3.5px var(--focus-ring);
}
.input::placeholder, .textarea::placeholder { color: var(--tx-tertiary); }
.hint { font-size: 12px; color: var(--tx-tertiary); line-height: 1.5; }
.err { font-size: 12px; color: var(--danger); }

/* 开关：iOS/macOS 27 的胶囊开关，轨道有内阴影 */
.switch { position: relative; display: inline-block; width: 42px; height: 25px; flex: 0 0 auto; }
.switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.switch .track {
  position: absolute; inset: 0;
  background: rgba(120, 120, 128, .28);
  border-radius: var(--r-pill);
  box-shadow: inset 0 1px 2px rgba(0,0,0,.10);
  transition: background var(--dur-base) var(--ease-out);
}
.switch .track::after {
  content: ''; position: absolute; top: 2.5px; left: 2.5px;
  width: 20px; height: 20px; border-radius: 50%; background: #fff;
  box-shadow: 0 2px 5px rgba(0,0,0,.20), 0 0 0 .5px rgba(0,0,0,.04);
  transition: transform var(--dur-base) var(--ease-spring);
}
/* 开：金色轨道。白滑块是「图形」不是文字，按 UI 组件 ≥3 判定，此处 4.51 有余量 */
.switch input:checked + .track { background: linear-gradient(180deg, var(--brand-btn-top), var(--brand-btn-mid)); }
.switch input:checked + .track::after { transform: translateX(17px); }
.switch input:focus-visible + .track { box-shadow: 0 0 0 3.5px var(--focus-ring); }
.switch input:disabled + .track { opacity: .40; }

/* ---------------- 卡片 ----------------
   薄玻璃 + 内高光。边框几乎不可见，靠材质与阴影分层。
   ------------------------------------------------- */
.card {
  background: var(--glass-thin);
  -webkit-backdrop-filter: var(--glass-thin-blur);
  backdrop-filter: var(--glass-thin-blur);
  border: 1px solid rgba(255, 255, 255, .60);
  border-radius: var(--r-lg);
  box-shadow: var(--inset-hi), var(--sh-md);
}
.card-h {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--sp-3); padding: 14px 20px;
  border-bottom: 1px solid var(--hairline);
}
.card-b { padding: var(--sp-5); }

/* ---------------- 表格（非矩阵的普通表格） ---------------- */
.table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13px; }
.table th {
  text-align: left; font-weight: 600; font-size: 11.5px; color: var(--tx-secondary);
  padding: 9px 12px; border-bottom: 1px solid var(--hairline);
  background: rgba(120, 120, 128, .06); white-space: nowrap;
  letter-spacing: .01em;
}
.table th:first-child { border-top-left-radius: var(--r-sm); }
.table th:last-child { border-top-right-radius: var(--r-sm); }
.table td { padding: 11px 12px; border-bottom: 1px solid var(--hairline); vertical-align: middle; }
.table tbody tr:hover td { background: rgba(168, 104, 26, .055); }
.table tbody tr:last-child td { border-bottom: none; }

/* ---------------- 布局：窗口外壳 ---------------- */
.app {
  display: flex;
  min-height: 100vh;
}

/* 侧栏：macOS sidebar vibrancy —— 厚玻璃，压饱和，右侧只有一根发丝线 */
.sidebar {
  width: var(--sidebar-w); flex: 0 0 var(--sidebar-w);
  background: var(--glass-thick);
  -webkit-backdrop-filter: var(--glass-thick-blur);
  backdrop-filter: var(--glass-thick-blur);
  border-right: 1px solid var(--hairline);
  box-shadow: inset -1px 0 0 rgba(255,255,255,.5);
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
  z-index: 30;
}

/* 窗口交通灯 —— 三颗球，做成真的能用（不是装饰）：
   红 = 退出登录（二次确认）　黄 = 折叠侧栏　绿 = 全屏 */
.winbar {
  height: var(--winbar-h); flex: 0 0 var(--winbar-h);
  display: flex; align-items: center; gap: 8px;
  padding: 0 14px;
}
.winbar .tl {
  width: 12px; height: 12px; border-radius: 50%; flex: 0 0 auto;
  border: none; padding: 0; position: relative;
  box-shadow: inset 0 0 0 .5px rgba(0,0,0,.14), inset 0 1px 1px rgba(255,255,255,.36);
  transition: filter var(--dur-fast);
}
.winbar .tl.close { background: linear-gradient(180deg, #FF6D66, #EC4B41); }
.winbar .tl.min   { background: linear-gradient(180deg, #FFC93C, #F0A81E); }
.winbar .tl.max   { background: linear-gradient(180deg, #4CD964, #23B93B); }
.winbar:hover .tl { filter: brightness(1.04); }
.winbar .tl::after {
  content: ''; position: absolute; inset: 0; border-radius: 50%;
  background: center/7px 7px no-repeat;
  opacity: 0; transition: opacity var(--dur-fast);
}
.winbar:hover .tl.close::after { opacity: .62; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 10'%3E%3Cpath d='M2.6 2.6l4.8 4.8M7.4 2.6l-4.8 4.8' stroke='%23590302' stroke-width='1.3' stroke-linecap='round'/%3E%3C/svg%3E"); }
.winbar:hover .tl.min::after   { opacity: .62; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 10'%3E%3Cpath d='M2.4 5h5.2' stroke='%23593C00' stroke-width='1.3' stroke-linecap='round'/%3E%3C/svg%3E"); }
.winbar:hover .tl.max::after   { opacity: .62; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 10'%3E%3Cpath d='M3.2 6.4V3.2h3.2M6.8 3.6v3.2H3.6' stroke='%23054408' stroke-width='1.2' stroke-linecap='round' fill='none'/%3E%3C/svg%3E"); }
.winbar .tl:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 2px; }

.brand { display: flex; align-items: center; gap: 10px; padding: 4px 18px 16px; }
/**
 * 徽标容器。
 * ★ 背景改成「透明 + 内联 SVG 自带深底」，不再用 CSS 渐变。
 *   原因：徽标的深底板与金色是**一体设计**的（金只在深底上够亮），
 *   如果容器再叠一层渐变，两套色会打架，且圆角会露出双层边缘。
 */
.brand .logo {
  width: 32px; height: 32px; border-radius: 9px; flex: 0 0 auto;
  display: grid; place-items: center;
  filter: drop-shadow(0 1px 2px rgba(10,20,40,.22));
}
.brand .logo svg { display: block; width: 100%; height: 100%; }
.brand .name { font-weight: 600; font-size: 13.5px; line-height: 1.2; letter-spacing: -.01em; }
.brand .sub { font-size: 11px; color: var(--tx-tertiary); letter-spacing: .01em; }

.nav { flex: 1; overflow-y: auto; padding: 0 var(--sp-2) var(--sp-3); }
.nav-group { margin-bottom: 14px; }
.nav-group > .lbl {
  font-size: 10.5px; font-weight: 700; color: var(--tx-tertiary);
  text-transform: uppercase; letter-spacing: .06em;
  padding: 6px 10px;
}
.nav a {
  display: flex; align-items: center; gap: 9px;
  padding: 7px 10px; margin-bottom: 1px;
  border-radius: 7px; color: var(--tx-secondary);
  font-size: 13px; font-weight: 500;
  letter-spacing: -.006em;
  text-decoration: none;
  transition: background var(--dur-fast) var(--ease-out), color var(--dur-fast);
  position: relative;
}
.nav a:hover { background: rgba(120, 120, 128, .12); color: var(--tx-primary); text-decoration: none; }
/* 选中态：macOS 27 的「填充强调」，带一点内高光，不是纯色块 */
.nav a.active {
  /* 强调底色：暖金半透明，与 --brand-50 同源（原来是蓝色 rgba(10,132,255,...)） */
  background: linear-gradient(180deg, rgba(168,104,26,.18), rgba(168,104,26,.12));
  color: var(--brand-ink); font-weight: 600;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.55);
}
.nav a .ico { width: 16px; height: 16px; flex: 0 0 auto; }
.nav a .badge {
  margin-left: auto; min-width: 18px; height: 18px; padding: 0 5px;
  border-radius: var(--r-pill);
  background: linear-gradient(180deg, #E2542A, var(--st-doc-missing));
  color: #fff; font-size: 10.5px; font-weight: 700;
  display: grid; place-items: center;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.28);
}

.sidebar-foot { padding: var(--sp-3); border-top: 1px solid var(--hairline); }

/* 版本行 —— 侧栏底部，等宽字体，一行放下版本号与构建指纹。
   ★ 它是「线上跑的是哪个构建」的唯一可视证据：只看版本号字符串会被骗
     （用旧代码发新版本号，字符串一样对），要连指纹一起看。 */
.verline {
  display: flex; align-items: center; gap: 6px;
  padding: 6px 10px 0;
  font-size: 10.5px; line-height: 1.4;
  letter-spacing: -.002em;
  user-select: text; /* 报障时要能复制 */
}
.verline .v { font-weight: 600; }
.verline .fp {
  font-family: var(--font-num);
  font-size: 10px;
  padding: 0 4px;
  border-radius: 3px;
  background: rgba(120, 120, 128, .14);
  letter-spacing: .01em;
}
.login-ver {
  margin-top: 10px;
  font-size: 11px;
  text-align: center;
  letter-spacing: -.002em;
}
.me {
  display: flex; align-items: center; gap: 9px;
  padding: 7px 8px; border-radius: var(--r-sm);
  transition: background var(--dur-fast);
}
.me:hover { background: rgba(120, 120, 128, .10); }
.avatar {
  width: 29px; height: 29px; border-radius: 50%; flex: 0 0 auto;
  display: grid; place-items: center; color: #fff;
  font-size: 12px; font-weight: 600;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.34), 0 1px 2px rgba(0,0,0,.14);
}
.me .who { min-width: 0; }
.me .who .n { font-size: 12.5px; font-weight: 600; line-height: 1.25; }
.me .who .r { font-size: 11px; color: var(--tx-tertiary); }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

/* 顶栏：中玻璃，滚动时内容从它下面模糊穿过 */
.topbar {
  height: var(--topbar-h); flex: 0 0 var(--topbar-h);
  display: flex; align-items: center; gap: var(--sp-4);
  padding: 0 var(--sp-6);
  background: var(--glass-thin);
  -webkit-backdrop-filter: var(--glass-thin-blur);
  backdrop-filter: var(--glass-thin-blur);
  border-bottom: 1px solid var(--hairline);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.55);
  position: sticky; top: 0; z-index: 20;
}
.topbar .title { font-size: 16px; font-weight: 650; letter-spacing: -.018em; }
.topbar .spacer { flex: 1; }

.page { padding: var(--sp-6); max-width: 1600px; width: 100%; }

/* ---------------- 汇总条 ----------------
   浮动玻璃工具条：圆角胶囊 + 轻薄阴影，像 macOS 的工具栏。
   ------------------------------------------------- */
.summary-bar {
  display: flex; align-items: center; gap: 6px;
  flex-wrap: wrap;
  padding: 8px 10px;
  background: var(--glass-thin);
  -webkit-backdrop-filter: var(--glass-thin-blur);
  backdrop-filter: var(--glass-thin-blur);
  border: 1px solid rgba(255,255,255,.62);
  border-radius: var(--r-md);
  box-shadow: var(--inset-hi), var(--sh-sm);
  margin-bottom: var(--sp-4);
}
.summary-bar .seg {
  display: inline-flex; align-items: center; gap: 6px;
  height: 28px; padding: 0 11px;
  border-radius: var(--r-pill);
  border: 1px solid transparent;
  background: transparent;
  font-size: 12.5px; font-weight: 500;
  color: var(--tx-secondary);
  transition: all var(--dur-fast) var(--ease-out);
}
.summary-bar .seg:hover { background: rgba(120,120,128,.12); color: var(--tx-primary); }
.summary-bar .seg.on {
  border-color: rgba(90, 40, 0, .22);
  background: linear-gradient(180deg, var(--brand-btn-top), var(--brand-btn-mid));
  color: var(--brand-on-btn); font-weight: 600;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.34), 0 1px 3px rgba(150,86,10,.30);
}
.summary-bar .seg .dot { width: 8px; height: 8px; border-radius: 50%; flex: 0 0 auto; }
.summary-bar .seg .n { font-family: var(--font-num); font-weight: 700; }

/* ---------------- 证照矩阵 ★ 核心 ----------------
   ★ 这里刻意「不玻璃」：矩阵是数据区，背景透出来会毁掉可读性。
     macOS 自己的表格也是不透明的。风格让位于功能。
   ------------------------------------------------- */
.matrix-wrap {
  background: var(--bg-surface);
  border: 1px solid var(--hairline);
  border-radius: var(--r-md);
  box-shadow: var(--sh-md);
  overflow: auto;
  max-height: calc(100vh - 240px);
}
.matrix { border-collapse: separate; border-spacing: 0; font-size: 12px; }

.matrix thead th {
  position: sticky; top: 0; z-index: 3;
  background: rgba(247, 247, 249, .94);
  -webkit-backdrop-filter: blur(12px) saturate(160%);
  backdrop-filter: blur(12px) saturate(160%);
  border-bottom: 1px solid var(--hairline-strong);
  padding: 0;
  height: 46px;
  font-weight: 600; font-size: 11.5px; color: var(--tx-secondary);
  text-align: center;
  white-space: nowrap;
}
.matrix thead th.freeze {
  left: 0; z-index: 5; text-align: left; padding-left: 16px;
  width: var(--col-freeze); min-width: var(--col-freeze);
  border-right: 1px solid var(--hairline-strong);
}
.matrix thead th .th-in { display: flex; flex-direction: column; align-items: center; gap: 1px; }
.matrix thead th .th-in .s { font-size: 10px; color: var(--tx-tertiary); font-weight: 500; }

.matrix tbody td {
  padding: 0; height: var(--row-h);
  border-bottom: 1px solid var(--hairline);
  text-align: center;
  vertical-align: middle;
}
.matrix tbody td.freeze {
  position: sticky; left: 0; z-index: 2;
  background: var(--bg-surface);
  text-align: left; padding: 0 14px;
  width: var(--col-freeze); min-width: var(--col-freeze);
  border-right: 1px solid var(--hairline);
}
.matrix tbody tr:hover td { background: rgba(168, 104, 26, .048); }
.matrix tbody tr:hover td.freeze { background: #F5F8FE; }
.matrix tbody tr:last-child td { border-bottom: none; }

.vplate {
  font-weight: 650; font-size: 12.5px; line-height: 1.25;
  font-family: var(--font-num); letter-spacing: -.02em;
}
.vmeta { font-size: 11px; color: var(--tx-tertiary); line-height: 1.3; margin-top: 1px; }

/* 单元格 —— 三行压缩：剩余天数 / 到期日 / 缺单据角标 */
.cell {
  position: relative;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 0; height: var(--row-h); width: 100%;
  cursor: pointer; border: none; background: transparent;
  padding: 0 4px;
  transition: background var(--dur-fast);
}
.cell:focus-visible { outline: 2px solid var(--brand-600); outline-offset: -3px; }
.cell .d1 { font-size: 12px; font-weight: 650; line-height: 1.25; font-family: var(--font-num); font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.cell .d2 { font-size: 10.5px; line-height: 1.2; color: var(--tx-tertiary); font-family: var(--font-num); }

.cell.expired .d1 { color: var(--st-expired-bg); }
.cell.due7 .d1 { color: var(--st-due7-bg); }
.cell.due30 .d1 { color: #8A5A12; }
.cell.ok .d1 { color: var(--st-ok-fg); }
.cell.wip .d1 { color: var(--st-wip-fg); }
.cell.exempt .d1 { color: var(--st-exempt-fg); }
.cell.exempt { background-image: repeating-linear-gradient(45deg, rgba(92,100,112,.06) 0 1px, transparent 1px 5px); }

/* 实心底色：仅最紧急两档 —— 让 82% 的格子保持安静 */
.cell.expired { background: var(--st-expired-bg); }
.cell.expired .d1, .cell.expired .d2 { color: #fff; }
.cell.expired .d2 { opacity: .8; }
.cell.due7 { background: var(--st-due7-bg); }
.cell.due7 .d1, .cell.due7 .d2 { color: #fff; }
.cell.due7 .d2 { opacity: .85; }

/* 全表最紧急的一格：外描边 + 光晕（全屏只允许一处） */
.cell.worst {
  box-shadow: inset 0 0 0 2px var(--st-critical-ring), 0 0 0 3px var(--st-critical-halo);
  z-index: 1;
}
@media (prefers-reduced-motion: no-preference) {
  .cell.due7.worst { animation: breathe var(--dur-pulse) ease-in-out infinite; }
}
@keyframes breathe {
  0%, 100% { box-shadow: inset 0 0 0 2px var(--st-critical-ring), 0 0 0 3px var(--st-critical-halo); }
  50% { box-shadow: inset 0 0 0 2px var(--st-critical-ring), 0 0 0 6px rgba(158, 27, 50, .06); }
}

/* ★ 缺单据角标 —— 独立维度，绝不改底色 */
.doc-dot {
  position: absolute; top: 5px; right: 6px;
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--st-doc-missing);
  box-shadow: 0 0 0 1.5px var(--bg-surface);
}
.cell.expired .doc-dot, .cell.due7 .doc-dot {
  background: #FFD9C2; box-shadow: 0 0 0 1.5px rgba(158, 27, 50, .5);
}

/* 不适用：斜纹 + 灰点，不可点击 */
.cell.na {
  cursor: default;
  background-image: repeating-linear-gradient(45deg, rgba(152,162,179,.10) 0 1px, transparent 1px 6px);
}
.cell.na .d1 { color: var(--bd-strong); font-weight: 400; }

/* 未建档：虚框 + 破折号（与「不适用」区分开） */
.cell.unconfigured .d1 { color: var(--bd-strong); }
.cell.unconfigured::after {
  content: ''; position: absolute; inset: 8px 12px;
  border: 1px dashed var(--bd-strong); border-radius: 4px;
}

/* ---------------- 网格 / KPI ---------------- */
.grid { display: grid; gap: var(--sp-4); }
.grid.c2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.c3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.c4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 1280px) { .grid.c4 { grid-template-columns: repeat(2, minmax(0,1fr)); } }
@media (max-width: 900px) { .grid.c3, .grid.c4, .grid.c2 { grid-template-columns: 1fr; } }

.kpi {
  padding: 16px 20px;
  background: var(--glass-thin);
  -webkit-backdrop-filter: var(--glass-thin-blur);
  backdrop-filter: var(--glass-thin-blur);
  border: 1px solid rgba(255,255,255,.62);
  border-radius: var(--r-lg);
  box-shadow: var(--inset-hi), var(--sh-sm);
  transition: box-shadow var(--dur-base) var(--ease-out), transform var(--dur-base) var(--ease-out);
}
.kpi:hover { box-shadow: var(--inset-hi), var(--sh-md); transform: translateY(-1px); }
.kpi .k { font-size: 12px; color: var(--tx-secondary); font-weight: 550; letter-spacing: -.004em; }
.kpi .v {
  font-size: 30px; font-weight: 620; line-height: 1.15; margin-top: 3px;
  font-family: var(--font-num); font-variant-numeric: tabular-nums;
  letter-spacing: -.035em;
}
.kpi .v.alert { color: var(--st-expired-bg); }
.kpi .v.warn { color: var(--st-due7-bg); }
.kpi .sub { font-size: 11.5px; color: var(--tx-tertiary); margin-top: 4px; }

/* 行列表项 */
.rowitem {
  display: flex; align-items: center; gap: var(--sp-3);
  padding: 11px 16px;
  border-bottom: 1px solid var(--hairline);
  transition: background var(--dur-fast);
}
.rowitem:last-child { border-bottom: none; }
.rowitem:hover { background: rgba(168, 104, 26, .05); }
.rowitem .grow { flex: 1; min-width: 0; }
.rowitem .t { font-size: 13px; font-weight: 550; letter-spacing: -.006em; }
.rowitem .s { font-size: 11.5px; color: var(--tx-tertiary); margin-top: 1px; }

/* 空态 */
.empty { padding: var(--sp-12) var(--sp-6); text-align: center; }
.empty .t { font-size: 14px; font-weight: 600; color: var(--tx-secondary); }
.empty .s { font-size: 12.5px; color: var(--tx-tertiary); margin-top: 4px; }

/* ---------------- 弹层 ----------------
   macOS 27 的 sheet：从中心轻微放大出现，材质更厚，遮罩更淡。
   ------------------------------------------------- */
.overlay {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(20, 20, 24, .28);
  -webkit-backdrop-filter: blur(2px);
  backdrop-filter: blur(2px);
  display: flex; align-items: center; justify-content: center;
  padding: var(--sp-6);
  animation: fadeIn var(--dur-base) var(--ease-out);
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.sheet {
  background: var(--glass-medium);
  -webkit-backdrop-filter: var(--glass-medium-blur);
  backdrop-filter: var(--glass-medium-blur);
  border: 1px solid rgba(255, 255, 255, .70);
  border-radius: var(--r-xl);
  box-shadow: var(--inset-hi), var(--sh-win);
  width: 100%; max-width: 560px;
  max-height: 88vh;
  display: flex; flex-direction: column;
  animation: sheetIn var(--dur-slow) var(--ease-spring);
  overflow: hidden;
}
.sheet.wide { max-width: 780px; }
@keyframes sheetIn {
  from { transform: scale(.945) translateY(8px); opacity: 0; }
  to { transform: none; opacity: 1; }
}
.sheet-h {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: var(--sp-4); padding: 20px 24px 15px;
  border-bottom: 1px solid var(--hairline);
}
.sheet-b { padding: 20px 24px; overflow-y: auto; flex: 1; }
.sheet-f {
  padding: 14px 24px; border-top: 1px solid var(--hairline);
  display: flex; justify-content: flex-end; gap: 8px;
  background: rgba(255,255,255,.34);
}

/* Toast：macOS 通知样式 —— 厚玻璃 + 圆角 + 左侧细色条 */
.toasts {
  position: fixed; right: var(--sp-6); bottom: var(--sp-6); z-index: 200;
  display: flex; flex-direction: column; gap: 8px;
}
.toast {
  min-width: 240px; max-width: 400px;
  padding: 12px 16px;
  background: var(--glass-medium);
  -webkit-backdrop-filter: var(--glass-medium-blur);
  backdrop-filter: var(--glass-medium-blur);
  color: var(--tx-primary);
  border: 1px solid rgba(255,255,255,.66);
  border-radius: var(--r-md);
  font-size: 13px; font-weight: 500;
  box-shadow: var(--inset-hi), var(--sh-lg);
  animation: toastIn var(--dur-base) var(--ease-spring);
}
@keyframes toastIn { from { transform: translateY(10px) scale(.96); opacity: 0; } to { transform: none; opacity: 1; } }
.toast.ok { border-left: 3px solid var(--ok); }
.toast.err { border-left: 3px solid var(--danger); }

/* ---------------- 登录 ----------------
   整页就是一张「macOS 登录窗」：居中玻璃卡，背景是冷淡的渐变。
   ------------------------------------------------- */
.login-wrap {
  min-height: 100vh; display: grid; place-items: center;
  padding: var(--sp-6);
  background:
    radial-gradient(1000px 700px at 24% -6%, #DCE9FF 0%, transparent 60%),
    radial-gradient(900px 620px at 86% 104%, #EFE6FB 0%, transparent 58%),
    radial-gradient(700px 500px at 50% 50%, #F7F9FC 0%, transparent 70%);
}
.login-card {
  width: 100%; max-width: 392px;
  background: var(--glass-medium);
  -webkit-backdrop-filter: var(--glass-medium-blur);
  backdrop-filter: var(--glass-medium-blur);
  border: 1px solid rgba(255,255,255,.72);
  border-radius: var(--r-xl);
  box-shadow: var(--inset-hi), var(--sh-win);
  padding: var(--sp-8);
}
.login-card .logo-lg {
  width: 52px; height: 52px; border-radius: 14px;
  display: grid; place-items: center;
  margin-bottom: var(--sp-4);
  filter: drop-shadow(0 4px 14px rgba(10,20,40,.26));
}
.login-card .logo-lg svg { display: block; width: 100%; height: 100%; }

/**
 * 英文商标 —— CJone253
 * ★ 字距拉开 + 小字号 + 中性灰：商标是「标识」不是「标题」，
 *   如果和中文名一样黑一样粗，两行会互抢，看起来像重复说了两遍。
 *   金字前缀用金色，让商标与徽标同源。
 */
.login-card .brand-en {
  font-size: 12.5px; font-weight: 600; letter-spacing: .14em;
  text-transform: none; color: #B87718;
  margin-bottom: 10px;
}

/* 提示条 */
.banner {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 11px 14px; border-radius: var(--r-sm);
  font-size: 12.5px; line-height: 1.5;
  border: 1px solid;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.44);
}
.banner.warn { background: rgba(255, 247, 237, .90); border-color: #FED7AA; color: #7C2D12; }
.banner.info { background: rgba(238, 246, 255, .90); border-color: #C7D7FB; color: #1E3A8A; }
.banner.danger { background: rgba(253, 242, 244, .92); border-color: #F5C2CB; color: #7A1226; }

/* 小工具 */
.flex { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: var(--sp-1); } .gap-2 { gap: var(--sp-2); } .gap-3 { gap: var(--sp-3); } .gap-4 { gap: var(--sp-4); }
.mb-2 { margin-bottom: var(--sp-2); } .mb-3 { margin-bottom: var(--sp-3); } .mb-4 { margin-bottom: var(--sp-4); } .mb-6 { margin-bottom: var(--sp-6); }
.mt-2 { margin-top: var(--sp-2); } .mt-4 { margin-top: var(--sp-4); }
.w-full { width: 100%; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.scroll-x { overflow-x: auto; }

/* 骨架 */
.skel {
  background: linear-gradient(90deg, rgba(120,120,128,.10) 25%, rgba(120,120,128,.05) 50%, rgba(120,120,128,.10) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.2s infinite;
  border-radius: var(--r-sm);
}
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }

/* ===============================================================
   响应式：≤900px 转为 iOS 式布局
   ---------------------------------------------------------------
   侧栏固定 236px 在 390px 屏上会把内容推出视口。
   移动端改为底部标签栏 + 可横向滑动的矩阵，而不是缩小桌面布局。
   窗口交通灯在移动端没有意义（没有窗口），隐藏。
   =============================================================== */
@media (max-width: 900px) {
  :root { --sp-6: 16px; --sp-5: 16px; --sp-4: 13px; --col-freeze: 148px; --topbar-h: 50px; }

  .app { flex-direction: column; }

  .sidebar {
    position: fixed; left: 0; right: 0; bottom: 0; top: auto;
    width: 100%; flex: none; height: auto;
    flex-direction: row; align-items: stretch;
    border-right: none; border-top: 1px solid var(--hairline);
    box-shadow: 0 -1px 0 rgba(255,255,255,.6), 0 -8px 28px rgba(0,0,0,.06);
    z-index: 60;
    padding-bottom: env(safe-area-inset-bottom, 0);
    background: var(--glass-medium);
    -webkit-backdrop-filter: var(--glass-medium-blur);
    backdrop-filter: var(--glass-medium-blur);
  }
  .winbar, .brand, .sidebar-foot { display: none; }

  .nav {
    display: flex; flex-direction: row; padding: 5px;
    overflow-x: auto; overflow-y: hidden; gap: 3px;
    width: 100%; -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .nav::-webkit-scrollbar { display: none; }
  .nav-group { display: contents; }
  .nav-group > .lbl { display: none; }

  .nav a {
    flex: 0 0 auto; flex-direction: column; gap: 2px;
    padding: 6px 10px; margin: 0; min-width: 58px;
    font-size: 10px; border-radius: 9px;
    text-align: center; position: relative;
  }
  .nav a span:not(.badge) { font-size: 10px; line-height: 1.2; }
  .nav a .ico { width: 19px; height: 19px; }
  .nav a.active { background: rgba(168, 104, 26, .16); box-shadow: none; }
  .nav a .badge {
    position: absolute; top: 1px; right: 3px; margin: 0;
    min-width: 15px; height: 15px; font-size: 9px; padding: 0 4px;
  }

  .main { padding-bottom: 74px; }

  .topbar { padding: 0 14px; gap: 8px; }
  .topbar .title { font-size: 15px; }
  .topbar .small.dim { display: none; }

  .page { padding: 14px; }

  .matrix-wrap { max-height: none; border-radius: var(--r-md); }
  .matrix tbody td { height: 54px; }
  .matrix thead th.freeze, .matrix tbody td.freeze { width: var(--col-freeze); min-width: var(--col-freeze); }
  .matrix thead th.freeze { padding-left: 12px; }
  .matrix tbody td.freeze { padding: 0 11px; }
  .vplate { font-size: 12px; }
  .vmeta { font-size: 10px; }
  .cell .d1 { font-size: 11.5px; }
  .cell .d2 { font-size: 9.5px; }

  .grid.c4 { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .kpi { padding: 12px 14px; border-radius: var(--r-md); }
  .kpi .v { font-size: 24px; }
  .kpi:hover { transform: none; }

  .page > div[style*="grid-template-columns"] { grid-template-columns: 1fr !important; }

  .summary-bar {
    flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .summary-bar::-webkit-scrollbar { display: none; }
  .summary-bar .seg { flex: 0 0 auto; }

  /* 弹层：移动端从底部升起，占满宽，圆角只留上面两个 */
  .overlay { padding: 0; align-items: flex-end; -webkit-backdrop-filter: none; backdrop-filter: none; }
  .sheet, .sheet.wide {
    max-width: 100%; border-radius: 20px 20px 0 0; max-height: 92vh;
    animation: sheetUp var(--dur-slow) var(--ease-spring);
  }
  @keyframes sheetUp { from { transform: translateY(24px); opacity: .7; } to { transform: none; opacity: 1; } }
  .sheet-h { padding: 16px 18px 12px; }
  .sheet-b { padding: 16px 18px; }
  .sheet-f { padding: 12px 18px calc(12px + env(safe-area-inset-bottom, 0)); }
  .sheet-f .btn { flex: 1; }

  .table { min-width: 600px; }

  .rowitem { padding: 10px 12px; gap: 8px; }
  .rowitem > div:first-child { width: auto !important; min-width: 78px; }
  .rowitem .btn.sm { padding: 0 8px; }

  .toasts { left: 14px; right: 14px; bottom: 86px; }
  .toast { min-width: 0; max-width: none; }

  .login-card { padding: 26px; border-radius: var(--r-lg); }
  .login-wrap { padding: 16px; }

  .banner { font-size: 12px; padding: 10px 12px; }
}

@media (max-width: 380px) {
  .nav a { min-width: 52px; padding: 6px 7px; }
  .kpi .v { font-size: 22px; }
}

/* ---------------- 深色模式 ----------------
   macOS 27 的深色不是「把白反过来」：玻璃更厚、描边更暗、阴影几乎消失，
   靠层次差而不是阴影表达深度。
   ------------------------------------------------- */
@media (prefers-color-scheme: dark) {
  :root {
    --bg-canvas: #1A1A1C;
    --bg-surface: #242426;
    --bg-subtle: rgba(255, 255, 255, .07);
    --bg-na: #2A2A2C;
    --tx-primary: #F2F2F4;
    --tx-secondary: #B4B4B8;
    --tx-tertiary: #8A8A8E;

    --hairline: rgba(255, 255, 255, .09);
    --hairline-strong: rgba(255, 255, 255, .15);
    --specular: rgba(255, 255, 255, .10);
    --bd-default: rgba(255, 255, 255, .11);
    --bd-strong: rgba(255, 255, 255, .20);

    /**
     * ★★★ 深色模式下品牌色**反过来了**，不是把浅色的金调亮那么简单：
     *   浅色模式是「暗金底 + 白字」；深色模式是「亮金底 + 深墨字」。
     *   原因：深底上放暗金（#A8681A on #242426 = 3.44）连链接文字都读不出；
     *   而亮金（#F5C542 on #242426 = 9.55）配深墨字（#1B1206 on #F5C542 = 11.40）
     *   两边都远超 AA。同一个品牌在两种模式下都该是「金」，
     *   但**金的明度不能不变** —— 不变就意味着一边必然读不清。
     */
    --brand-600: #E8B33C;   /* 深底上的金：作描边/焦点环 → 8.07 ✓ */
    --brand-700: #F5C542;   /* 悬停提亮更深一档 → 9.55 ✓ */
    --brand-50: rgba(232, 179, 60, .16);
    --focus-ring: rgba(232, 179, 60, .46);
    /* 文字用金：深底上 #E8B33C 已 8.07，不需要像浅色模式那样再压暗一档 */
    --brand-ink: #F0C577;

    /**
     * 深色模式的按钮渐变整组换成亮金，文字跟着换成深墨。
     * ★ 这组必须成套改：只把底色改亮而忘了改字色，白字 on #E8B33C 只有 1.92。
     *   实测：#1B1206 on #FFD766 = 13.35 / on #F5C542 = 11.40 / on #D9992A = 7.52
     */
    --brand-btn-top: #FFD766;
    --brand-btn-mid: #F5C542;
    --brand-btn-bot: #D9992A;
    --brand-btn-top-h: #FFE08A;
    --brand-btn-mid-h: #FFD766;
    --brand-btn-bot-h: #E0A833;
    --brand-on-btn: #1B1206; /* 亮金底上的深墨字 */
    --glass-thin: rgba(38, 38, 41, .66);
    --glass-medium: rgba(34, 34, 37, .84);
    --glass-thick: rgba(30, 30, 33, .64);

    --inset-hi: inset 0 1px 0 rgba(255, 255, 255, .09);
    --inset-hi-strong: inset 0 1px 0 rgba(255, 255, 255, .11);

    --sh-sm: 0 1px 2px rgba(0, 0, 0, .34);
    --sh-md: 0 4px 14px rgba(0, 0, 0, .40);
    --sh-lg: 0 18px 48px rgba(0, 0, 0, .58);
    --sh-win: 0 32px 80px rgba(0, 0, 0, .70);

    /* 深色下紧急度要提亮，否则深红在深底上读不出来 */
    --st-expired-bg: #C42A45;
    --st-due7-bg: #DE5A18;
    --st-due30-bg: #3D3016;
    --st-due30-fg: #F0C577;
    --st-ok-bg: #17301F;
    --st-ok-fg: #6FD79B;
    --st-ok-bd: #2C563D;
    --st-exempt-bg: #2A2A2D;
    --st-exempt-fg: #A8A8AD;
    --st-exempt-bd: #3E3E42;
    --st-wip-bg: #2A1F3D;
    --st-wip-fg: #BFA6F5;
    --st-wip-bd: #4A3A6B;
    --st-doc-missing: #FF8B4A;
  }

  html, body {
    background:
      radial-gradient(1100px 620px at 12% -8%, #1B2436 0%, transparent 62%),
      radial-gradient(900px 560px at 92% 108%, #241E33 0%, transparent 58%),
      var(--bg-canvas);
    background-attachment: fixed;
  }

  /* 深色下按钮不该是「白玻璃」 */
  .btn {
    background: linear-gradient(180deg, rgba(70,70,75,.92), rgba(52,52,56,.88));
    border-color: rgba(255, 255, 255, .14);
    color: var(--tx-primary);
  }
  .btn:hover {
    background: linear-gradient(180deg, rgba(82,82,88,.95), rgba(60,60,65,.92));
    box-shadow: var(--inset-hi-strong), 0 2px 8px rgba(0,0,0,.36);
  }
  .btn:disabled:hover { background: linear-gradient(180deg, rgba(70,70,75,.92), rgba(52,52,56,.88)); }
  /* 深色模式主按钮：亮金底 + 深墨字（11.40 ✓），与浅色模式白字暗金底互为镜像 */
  .btn.primary {
    background: linear-gradient(180deg, var(--brand-btn-top), var(--brand-btn-mid) 58%, var(--brand-btn-bot));
    border-color: rgba(255, 220, 120, .40);
    color: var(--brand-on-btn);
    box-shadow: inset 0 1px 0 rgba(255,255,255,.42), 0 1px 3px rgba(0,0,0,.34), 0 0 0 .5px rgba(245,197,66,.30);
  }
  .btn.primary:hover {
    background: linear-gradient(180deg, var(--brand-btn-top-h), var(--brand-btn-mid-h) 58%, var(--brand-btn-bot-h));
  }
  .btn.ghost { background: transparent; }
  .btn.ghost:hover { background: rgba(255,255,255,.09); }

  .input, .select, .textarea {
    background: rgba(28, 28, 31, .80);
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, .30);
  }
  .input:focus, .select:focus, .textarea:focus { background: #1E1E21; }

  .card { border-color: rgba(255, 255, 255, .10); }
  .kpi { border-color: rgba(255, 255, 255, .10); }
  .summary-bar { border-color: rgba(255, 255, 255, .10); }
  .sheet { border-color: rgba(255, 255, 255, .12); }
  .login-card { border-color: rgba(255, 255, 255, .12); }
  .toast { border-color: rgba(255, 255, 255, .12); }

  .matrix thead th { background: rgba(36, 36, 39, .96); }
  .matrix tbody tr:hover td { background: rgba(232, 179, 60, .10); }
  .matrix tbody tr:hover td.freeze { background: #2A3040; }
  .matrix-wrap { background: #202023; }

  .nav a:hover { background: rgba(255, 255, 255, .08); }
  .nav a.active {
    background: linear-gradient(180deg, rgba(232,179,60,.26), rgba(232,179,60,.17));
    color: #F0C577;
  }
  .me:hover { background: rgba(255, 255, 255, .07); }
  .rowitem:hover { background: rgba(232, 179, 60, .10); }
  .table tbody tr:hover td { background: rgba(232, 179, 60, .10); }

  .banner.warn { background: rgba(66, 44, 20, .72); border-color: #7A5220; color: #F5C98A; }
  .banner.info { background: rgba(24, 40, 68, .72); border-color: #2C4C7E; color: #A8CBF5; }
  .banner.danger { background: rgba(66, 22, 30, .72); border-color: #7E2C3A; color: #F5A8B4; }

  .sheet-f { background: rgba(255, 255, 255, .04); }
  .winbar .tl { box-shadow: inset 0 0 0 .5px rgba(0,0,0,.42), inset 0 1px 1px rgba(255,255,255,.20); }
}

/* 尊重系统的「减弱动态效果」 */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
  .cell.due7.worst { animation: none; }
}
