/* ══════════════════════════════════════════════════════════════════════════
   XinTool · 一体化工作台 — 共享设计系统
   三端（桌面 Web / iOS / Android）共用同一套 token 与业务组件。
   Direction: tech-utility（Datadog / GitHub / Cloudflare dashboard）
   六枚 token 逐字绑定自 direction library；:root 之外不出现任何裸 hex，
   所有颜色都是 var() 或 color-mix() 派生。
   ══════════════════════════════════════════════════════════════════════════ */

:root {
  /* ─── 六枚 token（tech-utility，逐字） ─────────────────────────────────── */
  --bg:      oklch(98% 0.005 250);
  --surface: oklch(100% 0 0);
  --fg:      oklch(22% 0.02 240);
  --muted:   oklch(50% 0.018 240);
  --border:  oklch(90% 0.008 240);
  --accent:  oklch(58% 0.16 145);

  /* ─── 字族 ─────────────────────────────────────────────────────────────── */
  --font-display: -apple-system, BlinkMacSystemFont, 'Inter', 'Segoe UI', system-ui, sans-serif;
  --font-body:    -apple-system, BlinkMacSystemFont, 'Inter', 'Segoe UI', system-ui, sans-serif;
  --font-mono:    'JetBrains Mono', 'IBM Plex Mono', ui-monospace, Menlo, monospace;

  /* ─── 派生 ─────────────────────────────────────────────────────────────── */
  --accent-soft: color-mix(in oklch, var(--accent) 12%, transparent);
  --accent-line: color-mix(in oklch, var(--accent) 34%, transparent);
  --fg-soft:     color-mix(in oklch, var(--fg) 4.5%, transparent);
  --fg-softer:   color-mix(in oklch, var(--fg) 2.5%, transparent);
  --fg-line:     color-mix(in oklch, var(--fg) 20%, transparent);

  /* ─── 状态语义（业务含义，非装饰） ─────────────────────────────────────── */
  --ok:      oklch(54% 0.12 158);
  --ok-soft: color-mix(in oklch, oklch(54% 0.12 158) 12%, transparent);
  --warn:      oklch(56% 0.13 72);
  --warn-soft: color-mix(in oklch, oklch(56% 0.13 72) 15%, transparent);
  --danger:      oklch(53% 0.17 25);
  --danger-soft: color-mix(in oklch, oklch(53% 0.17 25) 11%, transparent);
  --info:      oklch(52% 0.11 250);
  --info-soft: color-mix(in oklch, oklch(52% 0.11 250) 11%, transparent);
  /* AI 语义复用 info 蓝：调色板里不留紫色 */
  --ai:      var(--info);
  --ai-soft: var(--info-soft);

  /* ─── 尺度 ─────────────────────────────────────────────────────────────── */
  --fs-h1: clamp(24px, 2.4vw, 30px);
  --fs-h2: 19px;
  --fs-h3: 15px;
  --fs-body: 13.5px;
  --fs-lead: 14.5px;
  --fs-meta: 11.5px;
  --fs-micro: 10px;

  --gap-xs: 5px;
  --gap-sm: 9px;
  --gap-md: 14px;
  --gap-lg: 22px;
  --gap-xl: 34px;

  --radius-sm: 5px;
  --radius: 7px;
  --radius-lg: 11px;

  /* ─── 应用外壳尺寸 ─────────────────────────────────────────────────────── */
  --appbar-h: 50px;
  --sidebar-w: 238px;
  --context-w: 392px;
  --row-h: 38px;

  --shadow-pop: 0 1px 2px color-mix(in oklch, var(--fg) 7%, transparent),
                0 12px 32px -10px color-mix(in oklch, var(--fg) 22%, transparent);
}

/* ─── reset ────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-body), 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
  font-size: var(--fs-body);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
img, svg { display: block; max-width: 100%; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; cursor: pointer; background: none; border: 0; padding: 0; }
input, select, textarea { font: inherit; color: inherit; }
p { margin: 0; }
h1, h2, h3, h4 { margin: 0; font-weight: 600; text-wrap: balance; }
ul, ol { margin: 0; padding: 0; list-style: none; }
table { border-collapse: collapse; width: 100%; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; border-radius: 3px; }

/* ─── 通用原语 ──────────────────────────────────────────────────────────── */
.stack { display: flex; flex-direction: column; }
.stack > * + * { margin-top: var(--gap-md); }
.row { display: flex; align-items: center; gap: var(--gap-sm); }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: var(--gap-md); }
.row-wrap { flex-wrap: wrap; }
.spacer { flex: 1 1 auto; }
.num, .mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.meta { font-family: var(--font-mono); font-size: var(--fs-meta); color: var(--muted); }
/* 眉标 —— 一屏只有一处，占用唯一 accent（三端通用） */
.eyebrow {
  font-family: var(--font-mono); font-size: var(--fs-micro); letter-spacing: 0.14em;
  text-transform: uppercase; color: var(--accent); margin: 0 0 10px;
}
/* 分区内的 tab 面板：切换时由 JS 增删 .hidden */
.tabpane { display: block; }
.label {
  font-family: var(--font-mono); font-size: var(--fs-micro); letter-spacing: 0.12em;
  text-transform: uppercase; color: var(--muted); margin: 0;
}
.dim { color: var(--muted); }
.strong { font-weight: 600; }
.nowrap { white-space: nowrap; }
.cap { max-width: 72ch; }
.hidden { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ─── 控件 ──────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 32px; padding: 6px 12px;
  border-radius: var(--radius); border: 1px solid transparent;
  font-size: 13px; font-weight: 500; white-space: nowrap;
  transition: background 0.14s ease, border-color 0.14s ease, color 0.14s ease;
}
.btn-primary { background: var(--accent); color: var(--surface); border-color: var(--accent); }
.btn-primary:hover { background: color-mix(in oklch, var(--accent) 86%, black); }
.btn-secondary { border-color: var(--fg-line); color: var(--fg); }
.btn-secondary:hover { border-color: var(--fg); background: var(--fg-soft); }
.btn-quiet { color: var(--muted); border-color: transparent; }
.btn-quiet:hover { color: var(--fg); background: var(--fg-soft); }
.btn-sm { min-height: 27px; padding: 3px 9px; font-size: 12px; }
.btn-block { width: 100%; }
.icon-btn {
  display: grid; place-items: center; width: 30px; height: 30px;
  border-radius: var(--radius); color: var(--muted); border: 1px solid transparent;
}
.icon-btn:hover { background: var(--fg-soft); color: var(--fg); }
.icon-btn[aria-pressed="true"] { background: var(--fg); color: var(--surface); }

.field { display: flex; flex-direction: column; gap: 5px; }
.field > .label { letter-spacing: 0.1em; }
.input, .select, .textarea {
  width: 100%; min-height: 32px; padding: 6px 10px;
  background: var(--surface); color: var(--fg);
  border: 1px solid var(--border); border-radius: var(--radius);
  font-size: 13px;
}
.input::placeholder, .textarea::placeholder { color: color-mix(in oklch, var(--muted) 72%, transparent); }
.input:focus, .select:focus, .textarea:focus { border-color: var(--fg-line); }
.textarea { min-height: 72px; resize: vertical; line-height: 1.6; }
.field-error { color: var(--danger); font-size: 11.5px; font-family: var(--font-mono); }
.input[aria-invalid="true"], .textarea[aria-invalid="true"] { border-color: var(--danger); }

.seg { display: inline-flex; padding: 2px; background: var(--fg-soft); border-radius: var(--radius); }
.seg-btn { padding: 4px 11px; border-radius: calc(var(--radius) - 2px); font-size: 12.5px; color: var(--muted); white-space: nowrap; }
.seg-btn[aria-selected="true"] { background: var(--surface); color: var(--fg); font-weight: 600; }

.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); }
.tab { padding: 8px 12px; font-size: 13px; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tab:hover { color: var(--fg); }
.tab[aria-selected="true"] { color: var(--fg); border-bottom-color: var(--fg); font-weight: 600; }

/* ─── 标记：tag / pill / stage / status ─────────────────────────────────── */
.pill {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 8px; border-radius: 999px;
  background: var(--accent-soft); color: var(--accent);
  font-family: var(--font-mono); font-size: var(--fs-micro);
  letter-spacing: 0.06em; text-transform: uppercase; white-space: nowrap;
}
.tag {
  display: inline-flex; align-items: center; padding: 2px 7px;
  border-radius: var(--radius-sm); border: 1px solid var(--border);
  color: var(--muted); font-family: var(--font-mono); font-size: var(--fs-micro);
  letter-spacing: 0.05em; white-space: nowrap;
}
.tag-oid { color: var(--fg); border-color: var(--fg-line); }
.stage {
  display: inline-flex; align-items: center; padding: 2px 7px; border-radius: 4px;
  border: 1px solid var(--fg-line); font-family: var(--font-mono); font-size: var(--fs-micro);
  letter-spacing: 0.07em; white-space: nowrap;
}
.status {
  display: inline-flex; align-items: center; gap: 5px; padding: 2px 8px; border-radius: 999px;
  font-family: var(--font-mono); font-size: var(--fs-micro); letter-spacing: 0.05em; white-space: nowrap;
}
.status::before { content: ''; width: 5px; height: 5px; border-radius: 50%; background: currentColor; flex: none; }
.status-ok     { background: var(--ok-soft);     color: var(--ok); }
.status-warn   { background: var(--warn-soft);   color: var(--warn); }
.status-danger { background: var(--danger-soft); color: var(--danger); }
.status-info   { background: var(--info-soft);   color: var(--info); }
.status-ai     { background: var(--ai-soft);     color: var(--ai); }
.status-plain  { background: var(--fg-soft);     color: var(--muted); }

/* ─── 提示条 ────────────────────────────────────────────────────────────── */
.banner {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 10px 12px; border-radius: var(--radius);
  border: 1px solid var(--border); background: var(--surface);
  font-size: 12.5px;
}
.banner .bn-mark { font-family: var(--font-mono); font-size: var(--fs-micro); letter-spacing: 0.08em; padding-top: 1px; flex: none; }
.banner-danger { border-color: color-mix(in oklch, var(--danger) 34%, transparent); background: var(--danger-soft); }
.banner-danger .bn-mark { color: var(--danger); }
.banner-warn { border-color: color-mix(in oklch, var(--warn) 34%, transparent); background: var(--warn-soft); }
.banner-warn .bn-mark { color: var(--warn); }
.banner-info { border-color: color-mix(in oklch, var(--info) 30%, transparent); background: var(--info-soft); }
.banner-info .bn-mark { color: var(--info); }
.banner-ai { border-color: color-mix(in oklch, var(--ai) 30%, transparent); background: var(--ai-soft); }
.banner-ai .bn-mark { color: var(--ai); }
.banner p { color: var(--fg); }

/* ─── 空 / 加载 ─────────────────────────────────────────────────────────── */
.empty { display: flex; flex-direction: column; gap: 6px; padding: 34px 18px; text-align: center; border: 1px dashed var(--border); border-radius: var(--radius-lg); }
.empty .em-t { font-size: 13px; font-weight: 600; }
.empty .em-d { font-size: 12.5px; color: var(--muted); max-width: 46ch; margin-inline: auto; }
.skel { background: linear-gradient(90deg, var(--fg-soft) 25%, var(--fg-softer) 37%, var(--fg-soft) 63%); background-size: 400% 100%; animation: skel 1.3s ease-in-out infinite; border-radius: 4px; height: 11px; }
@keyframes skel { 0% { background-position: 100% 0; } 100% { background-position: 0 0; } }
@media (prefers-reduced-motion: reduce) { .skel { animation: none; } }

/* ══════════════════════════════════════════════════════════════════════════
   桌面 Web 工作台外壳
   ══════════════════════════════════════════════════════════════════════════ */
body.app-shell { height: 100vh; overflow: hidden; }
.app { height: 100vh; display: grid; grid-template-rows: var(--appbar-h) minmax(0, 1fr); }

.appbar {
  display: flex; align-items: center; gap: var(--gap-md);
  padding-inline: 12px; background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.brand { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 600; letter-spacing: -0.01em; white-space: nowrap; }
.brand .mark {
  width: 22px; height: 22px; border: 1px solid var(--fg); border-radius: 5px;
  display: grid; place-items: center; font-family: var(--font-mono); font-size: 10px;
}
.crumbs { display: flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--muted); min-width: 0; }
.crumbs b { color: var(--fg); font-weight: 600; }
.crumbs .sep { color: var(--fg-line); }
.search-trigger {
  display: inline-flex; align-items: center; gap: 8px;
  min-height: 30px; padding: 4px 10px; min-width: 220px;
  border: 1px solid var(--border); border-radius: var(--radius);
  color: var(--muted); font-size: 12.5px; background: var(--bg);
}
.search-trigger:hover { border-color: var(--fg-line); color: var(--fg); }
.search-trigger kbd { margin-left: auto; font-family: var(--font-mono); font-size: var(--fs-micro); border: 1px solid var(--border); border-radius: 3px; padding: 1px 4px; }
.dataset-chip {
  display: inline-flex; align-items: center; gap: 5px; padding: 3px 8px; border-radius: 999px;
  border: 1px solid var(--warn-soft); background: var(--warn-soft); color: var(--warn);
  font-family: var(--font-mono); font-size: var(--fs-micro); letter-spacing: 0.06em; white-space: nowrap;
}
.avatar {
  display: grid; place-items: center; width: 28px; height: 28px; border-radius: 50%;
  background: var(--fg); color: var(--surface); font-size: 11px; font-weight: 600; flex: none;
}

.app-body { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr) var(--context-w); min-height: 0; }
.app-body.no-context { grid-template-columns: var(--sidebar-w) minmax(0, 1fr); }
.app-body.no-context .contextpanel { display: none; }

/* ─── 侧边导航 ─────────────────────────────────────────────────────────── */
.sidebar { background: var(--surface); border-right: 1px solid var(--border); display: flex; flex-direction: column; min-height: 0; overflow-y: auto; padding: 12px 10px 16px; }
.orgswitch {
  display: flex; align-items: center; gap: 9px; width: 100%; padding: 8px 9px;
  border: 1px solid var(--border); border-radius: var(--radius); text-align: left; margin-bottom: 12px;
}
.orgswitch:hover { border-color: var(--fg-line); }
.orgswitch .os-mark { width: 26px; height: 26px; border-radius: 6px; background: var(--fg-soft); display: grid; place-items: center; font-family: var(--font-mono); font-size: 10px; flex: none; }
.orgswitch .os-t { font-size: 12.5px; font-weight: 600; line-height: 1.25; }
.orgswitch .os-s { font-family: var(--font-mono); font-size: var(--fs-micro); color: var(--muted); }

.navgroup + .navgroup { margin-top: 16px; }
.navgroup > .label { padding: 0 9px 6px; }
.navitem {
  position: relative; display: flex; align-items: center; gap: 9px;
  width: 100%; padding: 7px 9px; border-radius: var(--radius);
  font-size: 13px; color: var(--muted); text-align: left;
}
.navitem:hover { background: var(--fg-soft); color: var(--fg); }
.navitem[aria-current="page"] { background: var(--fg-soft); color: var(--fg); font-weight: 600; }
.navitem[aria-current="page"]::before {
  content: ''; position: absolute; left: 0; top: 7px; bottom: 7px; width: 2px;
  background: var(--fg); border-radius: 2px;
}
.navitem .ni-ico { width: 15px; height: 15px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.5; }
.navitem .ni-count { margin-left: auto; font-family: var(--font-mono); font-size: var(--fs-micro); color: var(--muted); }
.navitem[aria-current="page"] .ni-count { color: var(--fg); }
.navitem .ni-count.is-alert { color: var(--danger); }
.sidebar-foot { margin-top: auto; padding: 14px 9px 0; border-top: 1px solid var(--border); }
.sidebar-foot .label { margin-bottom: 6px; }
.sidebar-foot li { position: relative; padding-left: 13px; font-size: 11.5px; color: var(--muted); line-height: 1.6; margin-bottom: 5px; }
.sidebar-foot li::before { content: '—'; position: absolute; left: 0; font-family: var(--font-mono); color: var(--fg-line); }

/* ─── 工作区 ───────────────────────────────────────────────────────────── */
.workarea { min-width: 0; overflow-y: auto; padding: 18px 20px 40px; background: var(--bg); }
.view { display: none; }
.view.is-active { display: block; }
.viewhead { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--gap-md); margin-bottom: 14px; flex-wrap: wrap; }
.viewhead h1 { font-family: var(--font-display); font-size: var(--fs-h1); letter-spacing: -0.02em; line-height: 1.15; }
.viewhead .vh-sub { font-size: 12.5px; color: var(--muted); margin-top: 4px; }

.bar { display: flex; align-items: center; gap: var(--gap-sm); flex-wrap: wrap; padding-bottom: 12px; border-bottom: 1px solid var(--border); margin-bottom: 16px; }
.bar .count { font-family: var(--font-mono); font-size: var(--fs-meta); color: var(--muted); }
.chips { display: flex; gap: 5px; flex-wrap: wrap; }
.chip {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px; border-radius: 999px; border: 1px solid var(--border);
  font-size: 12px; color: var(--muted); white-space: nowrap;
}
.chip:hover { border-color: var(--fg-line); color: var(--fg); }
.chip[aria-pressed="true"] { background: var(--fg); border-color: var(--fg); color: var(--surface); font-weight: 500; }
.chip .c-n { font-family: var(--font-mono); font-size: var(--fs-micro); opacity: 0.75; }

.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1px; background: var(--border); border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; margin-bottom: 20px; }
.kpi { background: var(--surface); padding: 13px 15px; display: flex; flex-direction: column; gap: 3px; }
.kpi .kp-k { font-family: var(--font-mono); font-size: var(--fs-micro); letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); }
.kpi .kp-v { font-family: var(--font-mono); font-size: 25px; font-weight: 500; font-variant-numeric: tabular-nums; line-height: 1.1; letter-spacing: -0.02em; }
.kpi .kp-d { font-size: 11.5px; color: var(--muted); }
.kpi.is-alert .kp-v { color: var(--danger); }

.section-h { display: flex; align-items: baseline; justify-content: space-between; gap: var(--gap-md); margin: 22px 0 10px; }
.section-h h2 { font-family: var(--font-display); font-size: var(--fs-h2); letter-spacing: -0.015em; }
.section-h .label { padding-bottom: 2px; }

/* ─── 待办列表 ─────────────────────────────────────────────────────────── */
.tasklist { border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface); overflow: hidden; }
.taskrow {
  display: grid; grid-template-columns: 22px minmax(0, 1fr) 92px 104px 74px;
  align-items: center; gap: 12px; padding: 9px 14px;
  border-bottom: 1px solid var(--border); width: 100%; text-align: left;
}
.taskrow:last-child { border-bottom: 0; }
.taskrow:hover { background: var(--fg-softer); }
.taskrow[aria-selected="true"] { background: var(--fg-soft); }
.taskrow.is-overdue { box-shadow: inset 2px 0 0 var(--danger); }
.tk-check { width: 16px; height: 16px; border: 1px solid var(--fg-line); border-radius: 4px; display: grid; place-items: center; color: transparent; }
.tk-check:hover { border-color: var(--fg); color: var(--muted); }
.tk-check[aria-checked="true"] { background: var(--fg); border-color: var(--fg); color: var(--surface); }
.tk-check[aria-checked="true"] svg { width: 10px; height: 10px; stroke: currentColor; stroke-width: 2.4; fill: none; }
.taskrow.is-done .tk-main { text-decoration: line-through; color: var(--muted); }
.tk-main { min-width: 0; }
.tk-title { font-size: 13px; line-height: 1.35; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tk-sub { font-family: var(--font-mono); font-size: var(--fs-micro); color: var(--muted); margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tk-due { font-family: var(--font-mono); font-size: 11.5px; color: var(--muted); white-space: nowrap; }
.tk-due.is-late { color: var(--danger); }

/* ─── 看板 ─────────────────────────────────────────────────────────────── */
.kanban { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(224px, 1fr); gap: 12px; overflow-x: auto; padding-bottom: 8px; }
.kb-col { background: var(--fg-softer); border: 1px solid var(--border); border-radius: var(--radius-lg); display: flex; flex-direction: column; min-height: 260px; }
.kb-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 11px 13px; border-bottom: 1px solid var(--border); }
.kb-head .kb-t { font-size: 12.5px; font-weight: 600; }
.kb-head .kb-n { font-family: var(--font-mono); font-size: var(--fs-micro); color: var(--muted); }
.kb-body { padding: 9px; display: flex; flex-direction: column; gap: 7px; overflow-y: auto; flex: 1; }
.kb-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 10px 11px; text-align: left; width: 100%;
}
.kb-card:hover { border-color: var(--fg-line); }
.kb-card[aria-selected="true"] { border-color: var(--fg); }
.kb-card.is-flag { box-shadow: inset 2px 0 0 var(--warn); }
.kb-card.is-danger { box-shadow: inset 2px 0 0 var(--danger); }
.kb-card .kc-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 6px; }
.kb-card .kc-name { font-size: 13px; font-weight: 600; }
.kb-card .kc-line { font-size: 11.5px; color: var(--muted); line-height: 1.5; margin-bottom: 7px; }
.kb-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding-top: 7px; border-top: 1px solid var(--border); font-family: var(--font-mono); font-size: var(--fs-micro); color: var(--muted); }

/* ─── 主从列表 ─────────────────────────────────────────────────────────── */
.masterlist { border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface); overflow: hidden; }
.masterrow {
  display: grid; grid-template-columns: minmax(0, 1.6fr) 108px 118px 84px 96px;
  align-items: center; gap: 12px; padding: 10px 14px;
  border-bottom: 1px solid var(--border); width: 100%; text-align: left;
}
.masterrow:last-child { border-bottom: 0; }
.masterrow:hover { background: var(--fg-softer); }
.masterrow[aria-selected="true"] { background: var(--fg-soft); box-shadow: inset 2px 0 0 var(--fg); }
.mr-name { font-size: 13px; font-weight: 600; display: flex; align-items: center; gap: 7px; min-width: 0; }
.mr-name .mr-id { font-family: var(--font-mono); font-weight: 400; font-size: var(--fs-micro); color: var(--muted); }
.mr-sub { font-size: 11.5px; color: var(--muted); margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mr-cell { font-family: var(--font-mono); font-size: 11.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mr-bar { display: flex; align-items: center; gap: 7px; }
.meter { flex: 1; height: 3px; border-radius: 2px; background: var(--fg-soft); overflow: hidden; min-width: 40px; }
.meter span { display: block; height: 100%; background: var(--fg); }
.meter.is-ok span { background: var(--ok); }
.meter.is-warn span { background: var(--warn); }
.meter.is-danger span { background: var(--danger); }

/* ─── 右侧上下文面板 ───────────────────────────────────────────────────── */
.contextpanel { background: var(--surface); border-left: 1px solid var(--border); display: flex; flex-direction: column; min-height: 0; }
.cp-head { padding: 14px 16px 12px; border-bottom: 1px solid var(--border); }
.cp-head .cph-id { font-family: var(--font-mono); font-size: var(--fs-micro); color: var(--muted); letter-spacing: 0.06em; }
.cp-head h2 { font-family: var(--font-display); font-size: 18px; margin: 5px 0 7px; letter-spacing: -0.015em; }
.cp-tabs { display: flex; gap: 2px; border-top: 1px solid var(--border); margin: 12px -16px -12px; padding: 0 10px; overflow-x: auto; }
.cp-tab { padding: 9px 10px; font-size: 12.5px; color: var(--muted); border-bottom: 2px solid transparent; white-space: nowrap; }
.cp-tab[aria-selected="true"] { color: var(--fg); border-bottom-color: var(--fg); font-weight: 600; }
.cp-body { flex: 1; overflow-y: auto; padding: 14px 16px 28px; }
.cp-actions { padding: 10px 16px; border-top: 1px solid var(--border); display: flex; gap: 7px; flex-wrap: wrap; }
.cp-pane { display: none; }
.cp-pane.is-active { display: block; }

.kv { display: grid; grid-template-columns: 96px minmax(0, 1fr); gap: 7px 12px; }
.kv dt { font-family: var(--font-mono); font-size: var(--fs-micro); letter-spacing: 0.07em; text-transform: uppercase; color: var(--muted); padding-top: 2px; }
.kv dd { margin: 0; font-size: 12.5px; line-height: 1.6; }
.kv dd b { font-weight: 600; }

.timeline { position: relative; padding-left: 15px; }
.timeline::before { content: ''; position: absolute; left: 3px; top: 5px; bottom: 5px; width: 1px; background: var(--border); }
.tl-item { position: relative; padding-bottom: 14px; }
.tl-item:last-child { padding-bottom: 0; }
.tl-item::before { content: ''; position: absolute; left: -15px; top: 5px; width: 7px; height: 7px; border-radius: 50%; background: var(--surface); border: 1px solid var(--fg-line); }
.tl-item.is-latest::before { background: var(--fg); border-color: var(--fg); }
.tl-item.is-alert::before { background: var(--danger); border-color: var(--danger); }
.tl-date { font-family: var(--font-mono); font-size: var(--fs-micro); color: var(--muted); }
.tl-text { font-size: 12.5px; line-height: 1.6; margin-top: 2px; }
.tl-meta { font-family: var(--font-mono); font-size: var(--fs-micro); color: var(--muted); margin-top: 3px; }

.docrow { display: flex; align-items: center; gap: 9px; padding: 8px 0; border-bottom: 1px solid var(--border); }
.docrow:last-child { border-bottom: 0; }
.docrow .dr-name { flex: 1; font-size: 12.5px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.docrow .dr-ver { font-family: var(--font-mono); font-size: var(--fs-micro); color: var(--muted); }

.cardblock { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); padding: 12px 13px; }
.cardblock + .cardblock { margin-top: 10px; }
.cardblock .cb-t { font-size: 12.5px; font-weight: 600; margin-bottom: 7px; display: flex; align-items: center; justify-content: space-between; gap: 8px; }

.progress-track { display: flex; gap: 2px; align-items: center; }
.pt-step { flex: 1; height: 4px; border-radius: 2px; background: var(--fg-soft); }
.pt-step.is-done { background: var(--fg-line); }
.pt-step.is-current { background: var(--fg); height: 6px; }
.pt-step.is-stop { background: var(--danger); }
.stage-legend { display: flex; gap: 3px; margin-top: 7px; }
.stage-legend li { flex: 1; font-family: var(--font-mono); font-size: 9.5px; color: var(--muted); text-align: center; letter-spacing: 0.02em; }
.stage-legend li.is-current { color: var(--fg); font-weight: 600; }
.stage-legend li.is-stop { color: var(--danger); }

/* ─── 方案版本 ─────────────────────────────────────────────────────────── */
.verrow { display: grid; grid-template-columns: 42px minmax(0, 1fr) 84px; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--border); align-items: start; }
.verrow:last-child { border-bottom: 0; }
.verrow .vr-v { font-family: var(--font-mono); font-size: 11.5px; font-weight: 600; }
.verrow.is-expired .vr-v { color: var(--muted); }
.verrow .vr-note { font-size: 12.5px; line-height: 1.55; }
.verrow .vr-meta { font-family: var(--font-mono); font-size: var(--fs-micro); color: var(--muted); margin-top: 3px; }
.verrow .vr-date { font-family: var(--font-mono); font-size: var(--fs-micro); color: var(--muted); text-align: right; }

.srcrow { display: grid; grid-template-columns: minmax(0, 1fr) 88px; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--border); }
.srcrow:last-child { border-bottom: 0; }
.srcrow .sresult { font-size: 12.5px; font-weight: 600; }
.srcrow .srmeta { font-family: var(--font-mono); font-size: var(--fs-micro); color: var(--muted); margin-top: 3px; }
.srcrow.is-stale { box-shadow: inset 2px 0 0 var(--warn); padding-left: 9px; }

/* ─── 覆盖层：抽屉 / 命令面板 / toast ──────────────────────────────────── */
.drawer { position: fixed; inset: 0; z-index: 60; display: none; }
.drawer.is-open { display: block; }
.drawer .scrim { position: absolute; inset: 0; background: color-mix(in oklch, var(--fg) 34%, transparent); }
.drawer-panel {
  position: absolute; top: 0; right: 0; bottom: 0; width: min(440px, 92vw);
  background: var(--surface); border-left: 1px solid var(--border);
  box-shadow: var(--shadow-pop); display: flex; flex-direction: column;
}
.drawer-head { padding: 14px 18px; border-bottom: 1px solid var(--border); display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.drawer-body { flex: 1; overflow-y: auto; padding: 16px 18px 24px; display: flex; flex-direction: column; gap: 14px; }
.drawer-foot { padding: 12px 18px; border-top: 1px solid var(--border); display: flex; gap: 8px; justify-content: flex-end; }

.cmd { position: fixed; inset: 0; z-index: 70; display: none; }
.cmd.is-open { display: block; }
.cmd .scrim { position: absolute; inset: 0; background: color-mix(in oklch, var(--fg) 30%, transparent); }
.cmd-panel {
  position: relative; margin: 11vh auto 0; width: min(620px, 92vw);
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-pop); overflow: hidden;
}
.cmd-input { width: 100%; border: 0; border-bottom: 1px solid var(--border); padding: 14px 16px; font-size: 15px; background: transparent; }
.cmd-list { max-height: 46vh; overflow-y: auto; padding: 6px; }
.cmd-row { display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px; border-radius: var(--radius); text-align: left; }
.cmd-row:hover, .cmd-row.is-cursor { background: var(--fg-soft); }
.cmd-row .cr-t { font-size: 13px; }
.cmd-row .cr-k { margin-left: auto; font-family: var(--font-mono); font-size: var(--fs-micro); color: var(--muted); }
.cmd-empty { padding: 20px 14px; text-align: center; font-size: 12.5px; color: var(--muted); }

.toasts { position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%); z-index: 90; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast {
  display: flex; align-items: center; gap: 10px;
  background: var(--fg); color: var(--surface);
  padding: 9px 14px; border-radius: var(--radius); font-size: 12.5px;
  box-shadow: var(--shadow-pop); animation: toast-in 0.18s ease;
}
.toast .tt-k { font-family: var(--font-mono); font-size: var(--fs-micro); letter-spacing: 0.08em; text-transform: uppercase; opacity: 0.7; }
.toast.is-undo { pointer-events: auto; }
.toast button { color: var(--surface); text-decoration: underline; font-size: 12.5px; }
@keyframes toast-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }
@media (prefers-reduced-motion: reduce) { .toast { animation: none; } }

/* ─── 数据表 ───────────────────────────────────────────────────────────── */
.ds-table { font-size: 12.5px; }
.ds-table th, .ds-table td { padding: 9px 12px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: top; }
.ds-table th { color: var(--muted); font-weight: 500; font-family: var(--font-mono); font-size: var(--fs-micro); letter-spacing: 0.1em; text-transform: uppercase; border-bottom-color: var(--fg-line); }
.ds-table tbody tr:hover { background: var(--fg-softer); }
.ds-table .num-col { font-family: var(--font-mono); font-variant-numeric: tabular-nums; text-align: right; }
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface); }
.table-wrap .ds-table th:first-child, .table-wrap .ds-table td:first-child { padding-left: 14px; }
.table-wrap .ds-table tbody tr:last-child td { border-bottom: 0; }

/* ─── 响应式 ───────────────────────────────────────────────────────────── */
@media (max-width: 1440px) { :root { --context-w: 356px; --sidebar-w: 218px; } }
@media (max-width: 1240px) {
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .masterrow { grid-template-columns: minmax(0, 1.6fr) 104px 96px 92px; }
  .masterrow .mr-hide-md { display: none; }
}
@media (max-width: 1080px) {
  :root { --sidebar-w: 60px; }
  .sidebar { padding-inline: 8px; }
  .sidebar .navitem span, .sidebar .navgroup > .label, .orgswitch .os-t, .orgswitch .os-s, .sidebar-foot { display: none; }
  .orgswitch { justify-content: center; }
  .navitem { justify-content: center; }
  .navitem .ni-count { display: none; }
  .app-body { grid-template-columns: var(--sidebar-w) minmax(0, 1fr); }
  .contextpanel { display: none; }
}
@media (max-width: 900px) {
  .appbar { flex-wrap: wrap; row-gap: 8px; }
  .search-trigger { min-width: 0; flex: 1; }
  .crumbs { display: none; }
  .taskrow { grid-template-columns: 22px minmax(0, 1fr) 84px; }
  .taskrow .tk-owner, .taskrow .tk-tag { display: none; }
  .masterrow { grid-template-columns: minmax(0, 1fr) 96px; }
  .masterrow .mr-hide-sm { display: none; }
  .kanban { grid-auto-columns: minmax(200px, 82%); }
}
@media (max-width: 640px) {
  .workarea { padding: 14px 12px 32px; }
  .kpis { grid-template-columns: 1fr; }
  .kv { grid-template-columns: 1fr; gap: 2px 0; }
  .kv dt { padding-top: 7px; }
}
