/* ADO 專案現況 — 設計 token
   紙面：冷灰水泥底 + 近白卡片；互動色：藍染；楷體只用在「總人事時地物」導覽字。
   圖表色取自已驗證的資料視覺化色盤（對這組背景重新跑過色盲與對比檢查）。 */

:root {
  color-scheme: light;
  --page: #e9ecef;
  --surface: #fafbfc;
  --surface-2: #f1f3f5;
  --ink: #0e1318;
  --ink-2: #47515c;
  --muted: #6f7883;
  --rule: #d5dae0;
  --rule-strong: #bcc4cc;
  --grid: #e3e6ea;
  --axis: #c3c9d0;
  --accent: #26408b;
  --accent-ink: #26408b;
  --accent-wash: #e3e8f5;
  --shadow: 0 1px 0 rgba(14, 19, 24, 0.04), 0 8px 24px -16px rgba(14, 19, 24, 0.25);

  /* 類別色（依固定順序指派） */
  --s1: #2a78d6;
  --s2: #eb6834;
  --s3: #1baf7a;
  --s4: #eda100;
  --s5: #e87ba4;
  --s6: #008300;
  --de: #b8bfc7; /* 淡化 / 其他 */

  /* 工作項目狀態分類：有順序的單色階（提議 → 完成） */
  --c-proposed: #86b6ef;
  --c-progress: #3987e5;
  --c-resolved: #1c5cab;
  --c-completed: #0d366b;

  /* 進度條的底色：同色系、貼近背景，才不會被看成已填滿 */
  --meter-track: #dde7f5;

  /* 熱度圖：單色階，0 貼近背景 */
  --h0: #eceff2;
  --h1: #b7d3f6;
  --h2: #6da7ec;
  --h3: #2a78d6;
  --h4: #184f95;

  /* 狀態色：只用在「好 / 注意 / 嚴重」的意義上，並一律搭配圖示與文字 */
  --good: #0ca30c;
  --warning: #fab219;
  --serious: #ec835a;
  --critical: #d03b3b;
  --info: #8a939d;
  --good-ink: #006300;
  --critical-ink: #b1282a;

  --font-sans: "PingFang TC", "Noto Sans TC", "Microsoft JhengHei", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-kai: "LXGW WenKai TC", "Kaiti TC", "BiauKai", "DFKai-SB", "KaiTi", "STKaiti", serif;
  --font-mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --radius: 10px;
  --rail: 76px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --page: #0b0e11;
    --surface: #14191e;
    --surface-2: #1b2127;
    --ink: #eef1f4;
    --ink-2: #b3bcc6;
    --muted: #8a939d;
    --rule: #262d34;
    --rule-strong: #353e47;
    --grid: #232a31;
    --axis: #353e47;
    --accent: #93a8f2;
    --accent-ink: #b5c4f7;
    --accent-wash: #1c2440;
    --shadow: none;
    --s1: #3987e5;
    --s2: #d95926;
    --s3: #199e70;
    --s4: #c98500;
    --s5: #d55181;
    --s6: #008300;
    --de: #4a535c;
    --c-proposed: #184f95;
    --c-progress: #256abf;
    --c-resolved: #5598e7;
    --c-completed: #9ec5f4;
    --meter-track: #1f2a37;
    --h0: #1c2227;
    --h1: #184f95;
    --h2: #256abf;
    --h3: #3987e5;
    --h4: #86b6ef;
    --good-ink: #3cc13c;
    --critical-ink: #f07a7a;
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #0b0e11;
  --surface: #14191e;
  --surface-2: #1b2127;
  --ink: #eef1f4;
  --ink-2: #b3bcc6;
  --muted: #8a939d;
  --rule: #262d34;
  --rule-strong: #353e47;
  --grid: #232a31;
  --axis: #353e47;
  --accent: #93a8f2;
  --accent-ink: #b5c4f7;
  --accent-wash: #1c2440;
  --shadow: none;
  --s1: #3987e5;
  --s2: #d95926;
  --s3: #199e70;
  --s4: #c98500;
  --s5: #d55181;
  --s6: #008300;
  --de: #4a535c;
  --c-proposed: #184f95;
  --c-progress: #256abf;
  --c-resolved: #5598e7;
  --c-completed: #9ec5f4;
  --meter-track: #1f2a37;
  --h0: #1c2227;
  --h1: #184f95;
  --h2: #256abf;
  --h3: #3987e5;
  --h4: #86b6ef;
  --good-ink: #3cc13c;
  --critical-ink: #f07a7a;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font: 15px/1.6 var(--font-sans);
  font-feature-settings: "palt" 0;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent-ink); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
[hidden] { display: none !important; }
.mono { font-family: var(--font-mono); font-size: 0.92em; }
/* 數字連結：保留原本的文字顏色，用虛線底線提示可以開啟 Azure DevOps */
a.lk { color: inherit; text-decoration: underline dotted; text-decoration-color: var(--rule-strong); text-underline-offset: 0.22em; text-decoration-thickness: 1px; }
a.lk:hover { color: var(--accent-ink); text-decoration: underline solid; text-decoration-color: currentColor; }
.hbars a.name, .barlist a.name { text-decoration: underline dotted; text-decoration-color: var(--rule-strong); text-underline-offset: 0.22em; }
.hbars a.name:hover, .barlist a.name:hover { color: var(--accent-ink); text-decoration: underline solid; }
a.plain { color: inherit; }
a.plain:hover { color: var(--accent-ink); }
.open-in { display: inline-block; margin-top: 4px; font-size: 13px; }
.card-head .head-link { margin-left: auto; font-size: 12.5px; white-space: nowrap; align-self: center; }
.card-head .head-link + .tools { margin-left: 8px; }
.muted { color: var(--muted); }
.ink2 { color: var(--ink-2); }
.num { font-variant-numeric: tabular-nums; }
.nowrap { white-space: nowrap; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- 版面 ---------- */

.shell { display: grid; grid-template-columns: var(--rail) minmax(0, 1fr); min-height: 100vh; }
.rail {
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: calc(env(safe-area-inset-top, 0px) + 18px) 0 18px;
  border-right: 1px solid var(--rule);
  background: var(--surface);
}
.rail-mark {
  font-size: 11px; letter-spacing: 0.12em; color: var(--muted);
  writing-mode: vertical-rl; margin-bottom: 14px; user-select: none;
}
.rail-sep { width: 28px; height: 1px; background: var(--rule); margin: 6px 0; }
.glyph-link {
  position: relative; display: grid; place-items: center;
  width: 56px; height: 58px; border-radius: 12px;
  font-family: var(--font-kai); font-weight: 700; font-size: 32px; line-height: 1;
  color: var(--ink); text-decoration: none;
  transition: background-color 120ms ease, color 120ms ease;
}
.glyph-link:hover { background: var(--surface-2); text-decoration: none; }
.glyph-link[aria-current="true"] { background: var(--accent-wash); color: var(--accent-ink); }
.glyph-link .glyph-cap {
  position: absolute; bottom: 3px; left: 0; right: 0; text-align: center;
  font: 10px/1 var(--font-sans); color: var(--muted); letter-spacing: 0.04em;
}
.glyph-link .glyph-cap { opacity: 0; transition: opacity 120ms ease; }
.glyph-link:hover .glyph-cap, .glyph-link:focus-visible .glyph-cap, .glyph-link[aria-current="true"] .glyph-cap { opacity: 1; }
.glyph-dot {
  position: absolute; top: 7px; right: 7px;
  min-width: 16px; height: 16px; padding: 0 4px; border-radius: 8px;
  font: 600 10px/16px var(--font-sans); color: #fff; text-align: center;
  box-shadow: 0 0 0 2px var(--surface);
}
.glyph-dot.critical { background: var(--critical); }
.glyph-dot.warning { background: var(--warning); color: #3b2a00; }
.glyph-dot.info { background: var(--info); }

.main { min-width: 0; }
.topbar {
  position: sticky; top: env(safe-area-inset-top, 0px); z-index: 20;
  display: flex; align-items: center; gap: 12px;
  padding: 10px clamp(16px, 3vw, 36px);
  background: color-mix(in srgb, var(--page) 88%, transparent);
  backdrop-filter: saturate(1.2) blur(10px);
  border-bottom: 1px solid var(--rule);
}
.brand { font-weight: 600; letter-spacing: 0.02em; white-space: nowrap; }
.brand small { font-weight: 400; color: var(--muted); margin-left: 6px; }
.topbar form { flex: 1; display: flex; gap: 8px; min-width: 0; max-width: 720px; margin-left: auto; }
.topbar .url-input { flex: 1; min-width: 0; }
.content { padding: 28px clamp(16px, 3vw, 36px) 80px; max-width: 1360px; }

/* ---------- 控制項 ---------- */

.input {
  height: 38px; padding: 0 12px; border-radius: 8px;
  border: 1px solid var(--rule-strong); background: var(--surface);
  font-size: 14px;
}
.input::placeholder { color: var(--muted); }
.input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-wash); }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 38px; padding: 0 16px; border-radius: 8px; white-space: nowrap;
  border: 1px solid var(--rule-strong); background: var(--surface); cursor: pointer;
  font-size: 14px; font-weight: 500; text-decoration: none; color: var(--ink);
}
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--surface); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--surface-2); }
.btn.small { height: 30px; padding: 0 10px; font-size: 13px; }
.btn:disabled { opacity: 0.55; cursor: default; }
.btn.danger { color: var(--critical-ink); }

.pat-chip {
  display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 10px;
  border-radius: 15px; border: 1px solid var(--rule); background: var(--surface);
  font-size: 13px; cursor: pointer; white-space: nowrap;
}
.pat-chip:hover { background: var(--surface-2); }
.pat-chip .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--good); }
.pat-chip.missing .dot { background: var(--warning); }
.topbar-actions { display: flex; align-items: center; gap: 8px; min-width: 0; }
.user-chip { display: inline-flex; align-items: center; gap: 2px; min-width: 0; font-size: 13px; color: var(--ink-2); }
.user-chip .email { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 22ch; }
.signin-btn { height: 46px; padding: 0 22px; font-size: 15px; }

/* ---------- 首頁 ---------- */

.landing {
  display: grid; grid-template-columns: auto minmax(0, 620px); gap: clamp(28px, 6vw, 96px);
  align-items: start; justify-content: start; padding-top: clamp(24px, 8vh, 96px);
}
.landing-glyphs { display: flex; flex-direction: column; gap: 4px; }
.landing-glyph {
  display: grid; grid-template-columns: auto auto; justify-content: start; align-items: center; gap: 16px;
}
.landing-glyph b {
  font-family: var(--font-kai); font-weight: 700; font-size: clamp(56px, 7vw, 88px); line-height: 1.02;
  color: var(--rule-strong); transition: color 420ms ease;
}
.landing-glyph span { font-size: 13px; color: var(--muted); white-space: nowrap; transition: color 420ms ease; }
.landing-glyph.lit b { color: var(--ink); }
.landing-glyph.lit span { color: var(--ink-2); }
.landing-glyph.busy b { color: var(--accent); }
.landing h1 { font-size: clamp(26px, 3.2vw, 36px); line-height: 1.3; margin: 0 0 12px; font-weight: 700; letter-spacing: 0.01em; }
.landing .lede { color: var(--ink-2); margin: 0 0 28px; max-width: 34em; }
.big-form { display: flex; gap: 10px; flex-wrap: wrap; }
.big-form .input { flex: 1 1 320px; height: 46px; font-size: 15px; }
.big-form .btn { height: 46px; padding: 0 22px; font-size: 15px; }
.form-error { color: var(--critical-ink); margin: 10px 0 0; font-size: 14px; }
.hint { font-size: 13px; color: var(--muted); margin: 10px 0 0; }
.recent { margin-top: 36px; }
.recent h2 { font-size: 13px; font-weight: 600; color: var(--muted); margin: 0 0 8px; letter-spacing: 0.04em; }
.recent ul { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--rule); }
.recent li { display: flex; align-items: center; gap: 12px; border-bottom: 1px solid var(--rule); }
.recent li a { flex: 1; padding: 10px 2px; color: var(--ink); display: flex; gap: 8px; align-items: baseline; min-width: 0; }
.recent li a:hover { text-decoration: none; color: var(--accent-ink); }
.recent li .org { color: var(--muted); }
.recent li time { font-size: 12px; color: var(--muted); white-space: nowrap; }

/* 分析進度 */
.steps { list-style: none; margin: 24px 0 0; padding: 0; border-top: 1px solid var(--rule); }
.steps li {
  display: grid; grid-template-columns: 22px minmax(0, 1fr); gap: 10px;
  padding: 9px 0; border-bottom: 1px solid var(--rule); font-size: 14px;
}
.steps .mark { width: 16px; height: 16px; margin-top: 3px; border-radius: 50%; border: 1.5px solid var(--rule-strong); }
.steps .running .mark { border-color: var(--accent); border-right-color: transparent; animation: spin 0.8s linear infinite; }
.steps .done .mark { border: 0; background: var(--good); mask: none; position: relative; }
.steps .done .mark::after, .steps .partial .mark::after {
  content: ""; position: absolute; left: 5px; top: 2px; width: 4px; height: 8px;
  border: solid #fff; border-width: 0 2px 2px 0; transform: rotate(45deg);
}
.steps .partial .mark { border: 0; background: var(--warning); position: relative; }
.steps .failed .mark { border: 0; background: var(--critical); position: relative; }
.steps .failed .mark::after { content: "×"; position: absolute; inset: 0; color: #fff; font: 700 12px/16px var(--font-sans); text-align: center; }
.steps .label { font-weight: 500; }
.steps .detail { color: var(--muted); margin-left: 8px; }
.steps .err { display: block; color: var(--critical-ink); font-size: 13px; }
.steps .partial .err { color: var(--ink-2); }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Dashboard 頁首 ---------- */

.masthead { display: flex; flex-wrap: wrap; gap: 16px 32px; align-items: flex-end; justify-content: space-between; }
.masthead .crumb { font-size: 14px; color: var(--muted); }
.masthead h1 { margin: 2px 0 6px; font-size: clamp(28px, 3.6vw, 40px); line-height: 1.15; font-weight: 700; letter-spacing: 0.01em; word-break: break-word; }
.masthead .desc { margin: 0; color: var(--ink-2); max-width: 46em; }
.meta { display: flex; flex-wrap: wrap; gap: 6px 18px; margin: 12px 0 0; padding: 0; list-style: none; font-size: 13px; color: var(--muted); }
.meta b { color: var(--ink-2); font-weight: 500; }
.masthead .actions { display: flex; gap: 8px; flex-wrap: wrap; }

.verdict {
  display: flex; gap: 14px; align-items: flex-start; margin: 26px 0 0; padding: 16px 18px;
  border-radius: var(--radius); background: var(--surface); border: 1px solid var(--rule);
}
.verdict .level { flex: none; display: inline-flex; align-items: center; gap: 6px; font-weight: 600; white-space: nowrap; }
.verdict .level i { width: 10px; height: 10px; border-radius: 50%; background: var(--info); }
.verdict .level.active i { background: var(--good); }
.verdict .level.slowing i { background: var(--warning); }
.verdict .level.quiet i, .verdict .level.dormant i { background: var(--serious); }
.verdict p { margin: 0; color: var(--ink-2); }

/* KPI */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 1px; margin: 18px 0 0; background: var(--rule); border: 1px solid var(--rule); border-radius: var(--radius); overflow: hidden; }
.kpi { background: var(--surface); padding: 14px 16px 12px; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.kpi .label { font-size: 13px; color: var(--ink-2); }
.kpi .value { font-size: 30px; font-weight: 600; line-height: 1.2; letter-spacing: -0.01em; }
.kpi .value small { font-size: 15px; font-weight: 500; color: var(--ink-2); margin-left: 2px; }
.kpi .note { font-size: 12px; color: var(--muted); }
.kpi svg { margin-top: 6px; }

/* ---------- 區段 ---------- */

.section { margin-top: 64px; scroll-margin-top: 72px; }
.section-head { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 4px 20px; align-items: end; margin-bottom: 20px; padding-bottom: 14px; border-bottom: 1px solid var(--rule-strong); }
.section-head .big { grid-row: span 2; font-family: var(--font-kai); font-weight: 700; font-size: 72px; line-height: 0.9; }
.section-head h2 { margin: 0; font-size: 22px; line-height: 1.3; }
.section-head h2 small { font-size: 14px; font-weight: 400; color: var(--muted); margin-left: 10px; }
.section-head p { margin: 0; color: var(--ink-2); }
.subhead { font-size: 13px; font-weight: 600; letter-spacing: 0.06em; color: var(--muted); margin: 34px 0 12px; }
.subhead:first-child { margin-top: 0; }

/* 並排的卡片等高，底邊對齊；需要高矮不一時改用 .stack 把短卡片疊在同一欄 */
.grid { display: grid; gap: 16px; align-items: stretch; }
.stack { display: grid; gap: 16px; align-content: start; min-width: 0; }
/* 自動平衡的兩欄：每欄是一串卡片，最後一張延伸到底，讓左右底邊對齊 */
.balanced { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; align-items: stretch; }
.balanced.single { grid-template-columns: minmax(0, 1fr); }
.balanced.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.balanced > .col { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.balanced > .col:empty { display: none; }
.balanced > .col > :last-child { flex-grow: 1; }
.balanced.measuring { align-items: start; }
.balanced.measuring > .col > :last-child { flex-grow: 0; }
.split { display: grid; gap: 20px 28px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr)); align-items: start; }
.split > * { min-width: 0; }
.split > * > .subhead:first-child { margin-top: 0; }
.cols-2 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 420px), 1fr)); }
.cols-3 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr)); }
.span-all { grid-column: 1 / -1; }

.card { background: var(--surface); border: 1px solid var(--rule); border-radius: var(--radius); padding: 16px 18px 18px; min-width: 0; box-shadow: var(--shadow); }
.card-head { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 10px; }
.card-head h3 { margin: 0; font-size: 15px; line-height: 1.4; }
.card-head .sub { display: block; font-size: 12.5px; color: var(--muted); font-weight: 400; margin-top: 2px; }
.card-head .tools { margin-left: auto; display: flex; gap: 4px; flex: none; }
.toggle-table { height: 26px; padding: 0 8px; font-size: 12px; border-radius: 6px; border: 1px solid var(--rule); background: transparent; color: var(--ink-2); cursor: pointer; }
.toggle-table[aria-pressed="true"] { background: var(--accent-wash); color: var(--accent-ink); border-color: transparent; }
.empty { color: var(--muted); font-size: 14px; padding: 18px 0; }
.empty b { color: var(--ink-2); font-weight: 500; }
.unavailable { display: flex; gap: 10px; align-items: flex-start; color: var(--ink-2); font-size: 14px; padding: 14px; border-radius: 8px; background: var(--surface-2); }
.unavailable .scope { font-family: var(--font-mono); font-size: 12px; color: var(--muted); display: block; margin-top: 2px; }

/* 小統計 */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(128px, 1fr)); gap: 12px 20px; }
.stat .label { font-size: 12.5px; color: var(--ink-2); display: block; }
.stat .value { font-size: 22px; font-weight: 600; line-height: 1.3; }
.stat .value small { font-size: 13px; font-weight: 500; color: var(--ink-2); margin-left: 2px; }
.stat .note { font-size: 12px; color: var(--muted); display: block; }

/* 診斷清單 */
.findings { display: grid; gap: 0; margin: 0; padding: 0; list-style: none; }
.finding { display: grid; grid-template-columns: 92px 34px minmax(0, 1fr); gap: 12px; align-items: start; padding: 12px 0; border-top: 1px solid var(--rule); }
.finding:first-child { border-top: 0; }
.sev { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 600; white-space: nowrap; padding-top: 2px; }
.sev svg { flex: none; }
.sev.critical { color: var(--critical-ink); }
.sev.warning { color: var(--ink); }
.sev.info { color: var(--ink-2); }
.sev.good { color: var(--good-ink); }
.facet-chip {
  display: grid; place-items: center; width: 30px; height: 30px; border-radius: 7px;
  border: 1px solid var(--rule); font-family: var(--font-kai); font-weight: 700; font-size: 18px; color: var(--ink);
  text-decoration: none;
}
.facet-chip:hover { background: var(--accent-wash); text-decoration: none; }
.finding .title { font-weight: 600; }
.finding .detail { color: var(--ink-2); font-size: 14px; }
.findings-group + .findings-group { margin-top: 18px; }
.findings-group h3 { font-size: 13px; font-weight: 600; color: var(--muted); margin: 0 0 4px; letter-spacing: 0.04em; }

/* 表格 */
.table-wrap { overflow-x: auto; margin: 0 -2px; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.tbl th { text-align: left; font-weight: 500; color: var(--muted); font-size: 12.5px; padding: 6px 10px 6px 0; border-bottom: 1px solid var(--rule-strong); white-space: nowrap; }
.tbl td { padding: 8px 10px 8px 0; border-bottom: 1px solid var(--rule); vertical-align: top; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl .r { text-align: right; font-variant-numeric: tabular-nums; }
.tbl .c { text-align: center; }
.tbl td.title-cell { min-width: 220px; }
.tbl .sub { display: block; font-size: 12px; color: var(--muted); }
.more { font-size: 13px; color: var(--muted); margin: 8px 0 0; }
.more-btn { border: 0; padding: 0; background: none; color: var(--accent-ink); font-size: 13px; cursor: pointer; }
.more-btn:hover { text-decoration: underline; text-underline-offset: 3px; }

.badge { display: inline-flex; align-items: center; gap: 4px; height: 20px; padding: 0 7px; border-radius: 10px; font-size: 11.5px; font-weight: 500; white-space: nowrap; border: 1px solid var(--rule); color: var(--ink-2); background: var(--surface); vertical-align: 1px; }
.badge.accent { border-color: transparent; background: var(--accent-wash); color: var(--accent-ink); }
.badge.dim { color: var(--muted); }
.badge i { width: 7px; height: 7px; border-radius: 50%; background: var(--info); }
.badge.s-good i { background: var(--good); }
.badge.s-warning i { background: var(--warning); }
.badge.s-serious i { background: var(--serious); }
.badge.s-critical i { background: var(--critical); }

.stage-list { display: flex; flex-wrap: wrap; gap: 4px; }
.check { color: var(--good-ink); font-weight: 600; }
.cross { color: var(--muted); }

/* 條列式長條（分布、排行） */
.barlist { list-style: none; margin: 0; padding: 0; display: grid; gap: 7px; }
.barlist li { display: grid; grid-template-columns: minmax(80px, 38%) minmax(0, 1fr) auto; gap: 10px; align-items: center; font-size: 13.5px; }
.barlist .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.barlist .track { display: block; height: 10px; }
.barlist .fill { display: block; height: 10px; border-radius: 0 4px 4px 0; background: var(--s1); min-width: 2px; }
.barlist .val { font-variant-numeric: tabular-nums; color: var(--ink-2); min-width: 2.5em; text-align: right; }

.hbars { list-style: none; margin: 0; padding: 0; display: grid; gap: 9px; }
.hbars li { display: grid; grid-template-columns: minmax(96px, 30%) minmax(0, 1fr) 3.2em; gap: 12px; align-items: center; font-size: 13.5px; }
.hbars .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink); }
.hbars .name .sub { display: inline; margin-left: 6px; font-size: 12px; color: var(--muted); }
.hbars .track { display: flex; gap: 2px; height: 14px; min-width: 0; }
.hbars .seg { flex: 0 1 auto; min-width: 2px; height: 100%; outline-offset: 1px; }
.hbars .seg.end { border-radius: 0 4px 4px 0; }
.hbars .seg:hover { filter: brightness(1.12); }
.hbars .val { text-align: right; font-variant-numeric: tabular-nums; color: var(--ink-2); }

.meter { position: relative; height: 8px; border-radius: 4px; background: var(--meter-track); overflow: hidden; }
.meter > span { position: absolute; inset: 0 auto 0 0; background: var(--s1); border-radius: 4px; }
.meter.status-good > span { background: var(--good); }
.meter.status-warning > span { background: var(--warning); }
.meter.status-critical > span { background: var(--critical); }
.meter.neutral, .meter[class*="status-"] { background: var(--grid); }
.meter-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; align-items: center; }

/* 圖表 */
.chart { position: relative; width: 100%; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart text { font-family: var(--font-sans); fill: var(--muted); font-size: 11px; }
.chart .tick-label { font-variant-numeric: tabular-nums; }
.chart .gridline { stroke: var(--grid); stroke-width: 1; }
.chart .baseline { stroke: var(--axis); stroke-width: 1; }
.chart .hit { fill: transparent; cursor: default; }
.chart .mark { transition: opacity 120ms ease; }
.chart .dim-others .mark:not(.hover) { opacity: 0.45; }
.chart .direct-label { fill: var(--ink-2); font-size: 11.5px; }
.chart .crosshair { stroke: var(--axis); stroke-width: 1; }
.legend { display: flex; flex-wrap: wrap; gap: 4px 16px; margin: 0 0 10px; padding: 0; list-style: none; font-size: 12.5px; color: var(--ink-2); }
.legend li { display: inline-flex; align-items: center; gap: 6px; }
.legend .sw { width: 10px; height: 10px; border-radius: 2px; }
.legend .ln { width: 14px; height: 2px; border-radius: 1px; }

.tooltip {
  position: fixed; z-index: 100; pointer-events: none; max-width: 300px;
  background: var(--surface); color: var(--ink); border: 1px solid var(--rule-strong);
  border-radius: 8px; padding: 8px 10px; font-size: 12.5px; line-height: 1.5;
  box-shadow: 0 10px 30px -12px rgba(0, 0, 0, 0.35);
}
.tooltip .tt-title { color: var(--muted); font-size: 12px; margin-bottom: 2px; }
.tooltip .tt-row { display: grid; grid-template-columns: 14px auto minmax(0, 1fr); gap: 6px; align-items: center; }
.tooltip .tt-row b { font-variant-numeric: tabular-nums; font-weight: 600; }
.tooltip .tt-row span { color: var(--ink-2); }
.tooltip .tt-key { width: 12px; height: 2px; border-radius: 1px; }

/* 日曆熱度圖 */
.cal-scale { display: flex; align-items: center; gap: 4px; font-size: 11.5px; color: var(--muted); margin-top: 8px; justify-content: flex-end; }
.cal-scale i { width: 11px; height: 11px; border-radius: 2px; }

/* 時間軸 */
.timeline { list-style: none; margin: 0; padding: 0 0 0 4px; }
.timeline li { position: relative; display: grid; grid-template-columns: 92px 18px minmax(0, 1fr); gap: 8px; padding: 5px 0; font-size: 13.5px; }
.timeline li::before { content: ""; position: absolute; left: 104px; top: 0; bottom: 0; width: 1px; background: var(--rule-strong); }
.timeline li:first-child::before { top: 12px; }
.timeline li:last-child::before { bottom: calc(100% - 12px); }
.timeline time { color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.timeline .pin { position: relative; z-index: 1; width: 9px; height: 9px; margin: 6px 0 0 4.5px; border-radius: 50%; background: var(--surface); border: 2px solid var(--ink-2); }
.timeline .ago { color: var(--muted); font-size: 12px; margin-left: 6px; }

.lifespan { margin: 4px 0 18px; }
.lifespan .bar { position: relative; height: 10px; border-radius: 5px; background: var(--surface-2); }
.lifespan .bar span { position: absolute; top: 0; bottom: 0; border-radius: 5px; background: var(--s1); }
.lifespan .ends { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); margin-top: 6px; }

/* 反覆項目 */
.iter-row { display: grid; grid-template-columns: minmax(220px, 1.3fr) minmax(0, 3fr) minmax(130px, 0.8fr); gap: 16px; align-items: center; padding: 8px 0; border-top: 1px solid var(--rule); font-size: 13.5px; }
.iter-name { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 8px; min-width: 0; }
.iter-dates { flex-basis: 100%; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.iter-row:first-child { border-top: 0; }
.iters.no-dates .iter-row { grid-template-columns: minmax(0, 1fr) minmax(120px, 0.6fr); }
.iters.no-dates .gantt { display: none; }
.iter-row .gantt { position: relative; height: 14px; background: var(--surface-2); border-radius: 3px; }
.iter-row .gantt span { position: absolute; top: 2px; bottom: 2px; border-radius: 3px; background: var(--de); }
.iter-row.current .gantt span { background: var(--s1); }
.iter-row .today { position: absolute; top: -3px; bottom: -3px; width: 2px; background: var(--ink); border-radius: 1px; }

/* 物：資產清單 */
.inventory { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 1px; background: var(--rule); border: 1px solid var(--rule); border-radius: var(--radius); overflow: hidden; }
.inv { background: var(--surface); padding: 12px 14px; color: var(--ink); display: flex; flex-direction: column; gap: 2px; min-width: 0; }
a.inv:hover { background: var(--surface-2); text-decoration: none; }
.inv .n { font-size: 24px; font-weight: 600; line-height: 1.2; }
.inv .l { font-size: 13px; color: var(--ink-2); }
.inv .d { font-size: 12px; color: var(--muted); }
.inv.na .n { color: var(--muted); font-size: 16px; font-weight: 500; padding-top: 5px; }

/* 頁尾：資料來源 */
.coverage { margin-top: 72px; }
.coverage .grid-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 0 24px; }
.cov { display: flex; gap: 8px; padding: 6px 0; border-bottom: 1px solid var(--rule); font-size: 13px; align-items: baseline; }
.cov .n { margin-left: auto; color: var(--muted); font-variant-numeric: tabular-nums; }
.cov .bad { color: var(--critical-ink); }
.cov-errors { margin-top: 12px; font-size: 13px; color: var(--ink-2); }
.cov-errors li { margin: 2px 0; }

/* 設定抽屜 */
.drawer-backdrop { position: fixed; inset: 0; z-index: 50; background: rgba(8, 10, 12, 0.35); }
.drawer {
  position: fixed; z-index: 51; top: 0; right: 0; bottom: 0; width: min(520px, 100vw);
  background: var(--surface); border-left: 1px solid var(--rule); overflow-y: auto;
  padding: calc(env(safe-area-inset-top, 0px) + 20px) 24px calc(env(safe-area-inset-bottom, 0px) + 24px);
  box-shadow: -20px 0 50px -30px rgba(0, 0, 0, 0.5);
}
.drawer h2 { margin: 0 0 4px; font-size: 20px; }
.drawer .close { position: absolute; top: calc(env(safe-area-inset-top, 0px) + 14px); right: 14px; }
.drawer label { display: block; font-size: 13px; font-weight: 600; margin: 18px 0 6px; }
.drawer .input { width: 100%; }
.drawer .row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 16px; }
.status-box { margin-top: 16px; padding: 12px 14px; border-radius: 8px; background: var(--surface-2); font-size: 14px; }
.status-box.ok { border-left: 3px solid var(--good); }
.status-box.missing { border-left: 3px solid var(--warning); }
.status-box .muted { font-size: 13px; }
.scope-list { margin: 8px 0 0; padding-left: 18px; font-size: 13px; color: var(--ink-2); }
.scope-list code { font-family: var(--font-mono); font-size: 12px; }
.msg { margin-top: 12px; font-size: 14px; }
.msg.ok { color: var(--good-ink); }
.msg.err { color: var(--critical-ink); }

.loading-overlay { opacity: 0.5; pointer-events: none; transition: opacity 150ms ease; }

/* ---------- 窄螢幕 ---------- */

@media (max-width: 860px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .rail {
    position: sticky; top: 0; z-index: 30; height: auto; flex-direction: row; justify-content: center;
    padding: calc(env(safe-area-inset-top, 0px) + 4px) 8px 4px; border-right: 0; border-bottom: 1px solid var(--rule);
  }
  .rail-mark, .rail-sep { display: none; }
  .glyph-link { width: 48px; height: 44px; font-size: 24px; }
  .glyph-link .glyph-cap { display: none; }
  .glyph-dot { top: 2px; right: 2px; min-width: 14px; height: 14px; font-size: 9px; line-height: 14px; }
  .topbar { position: static; flex-wrap: wrap; }
  .topbar form { order: 3; flex-basis: 100%; max-width: none; margin: 0; }
  .landing { grid-template-columns: minmax(0, 1fr); }
  .landing-glyphs { flex-direction: row; gap: 10px; }
  .landing-glyph { grid-template-columns: 1fr; gap: 0; }
  .landing-glyph b { font-size: 44px; }
  .landing-glyph span { display: none; }
  .section-head .big { font-size: 52px; }
  .finding { grid-template-columns: 30px minmax(0, 1fr); }
  .finding .sev { grid-column: 1 / -1; }
  .iter-row { grid-template-columns: minmax(0, 1fr) minmax(80px, auto); }
  .iter-row .gantt { grid-column: 1 / -1; grid-row: 2; }
  .section { scroll-margin-top: 60px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}
