/* =====================================================================
 * StyleKit D「清晰指挥舱 v2」生产皮肤
 * - Corporate Clean tokens（见 tokens.css）
 * - V2 IA：ledger 统计、主版位、日期刊头、Admin 运行轨（登录页保留旧版 Hero）
 * - 挂在 cascade 最后；通过选择器与加载顺序覆盖历史层
 * ===================================================================== */

:root {
  /* 取值收敛到 tokens.css 的 --accent-today（明/暗各一处），此处只做别名 */
  --d-today-accent: var(--accent-today);
  --d-ledger-bg: var(--bg-card);
  --d-ledger-line: var(--line);
  --d-masthead-serif: "Source Han Serif SC", "Noto Serif SC", "Songti SC", "SimSun", serif;
  --d-radius: var(--radius-md);
  --d-focus: 0 0 0 2px var(--bg-card), 0 0 0 4px var(--brand-2);
}

/* ---------- 基础组件契约（Button / Input / Card / Tag；不含登录页） ---------- */
html body .app-shell .action-button,
html body .app-shell button.action-button {
  background: var(--brand);
  color: var(--brand-on);
  border: 1px solid var(--brand-strong);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-soft);
  font-weight: 600;
  min-height: 40px;
  transition: background var(--duration-fast) var(--ease-out),
    border-color var(--duration-fast) var(--ease-out),
    box-shadow var(--duration-fast) var(--ease-out);
}
html body .app-shell .action-button:hover {
  background: var(--brand-strong);
}
html body .app-shell .action-button:focus-visible,
html body .app-shell .ghost-button:focus-visible {
  outline: none;
  box-shadow: var(--d-focus);
}
html body .app-shell .ghost-button {
  background: transparent;
  color: var(--text-main);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-md);
  min-height: 40px;
}
html body .app-shell .ghost-button:hover {
  background: var(--bg-soft);
  border-color: var(--brand-2);
}
html body .app-shell input:not([type="checkbox"]):not([type="radio"]),
html body .app-shell textarea,
html body .app-shell select {
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-md);
  background: var(--bg-card);
  color: var(--text-main);
  min-height: 40px;
}
html body .app-shell .panel,
html body .app-shell .assistant-block,
html body .app-shell .card {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--bg-card);
  box-shadow: none;
}
html body .app-shell .status-pill,
html body .app-shell .info-chip,
html body .app-shell .badge {
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  font-variant-numeric: tabular-nums;
}

/* 禁止静态卡 hover 上浮（可点击的除外） */
html body .app-shell .stat-card:not([data-action]):hover,
html body .app-shell .panel:not([data-action]):hover {
  transform: none;
  box-shadow: none;
}

/* ---------- 日期刊头 ---------- */
html body .app-shell .d-masthead {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 4px 2px 12px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 12px;
}
html body .app-shell .d-masthead-date {
  font-family: var(--d-masthead-serif);
  font-size: 1.35rem;
  font-weight: 600;
  color: var(--text-main);
  letter-spacing: 0.02em;
}
html body .app-shell .d-masthead-date .d-today-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--d-today-accent);
  margin-right: 8px;
  vertical-align: middle;
}
html body .app-shell .d-masthead-role {
  font-size: 0.8125rem;
  color: var(--text-soft);
  font-variant-numeric: tabular-nums;
}
html body .app-shell .d-section-title {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 10px;
  font-size: 0.95rem;
  font-weight: 650;
  color: var(--text-main);
}
html body .app-shell .d-section-num {
  font-variant-numeric: tabular-nums;
  color: var(--brand);
  font-weight: 700;
  font-size: 0.8rem;
  letter-spacing: 0.04em;
  opacity: 0.85;
}

/* ---------- Ledger 统计条（替代等权 KPI 卡矩阵） ---------- */
html body .app-shell .d-ledger,
html body .app-shell:not(.mobile-shell) .stats-row:not(.is-quiet-empty) {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) repeat(4, minmax(0, 1fr));
  gap: 0;
  background: var(--d-ledger-bg);
  border: 1px solid var(--d-ledger-line);
  border-radius: var(--radius-lg);
  overflow: hidden;
  margin-bottom: 16px;
  box-shadow: none;
}
html body .app-shell:not(.mobile-shell) .stats-row:not(.is-quiet-empty) > .stat-card,
html body .app-shell .d-ledger > .d-ledger-cell {
  border: none;
  border-radius: 0;
  box-shadow: none;
  background: transparent;
  margin: 0;
  padding: 14px 16px;
  min-height: 0;
  position: relative;
}
html body .app-shell:not(.mobile-shell) .stats-row:not(.is-quiet-empty) > .stat-card + .stat-card,
html body .app-shell .d-ledger > .d-ledger-cell + .d-ledger-cell {
  border-left: 1px solid var(--d-ledger-line);
}
/* 主版位：今日重点/需拍板 占第一格，稍强调 */
html body .app-shell:not(.mobile-shell) .stats-row:not(.is-quiet-empty) > .stats-featured,
html body .app-shell:not(.mobile-shell) .stats-row:not(.is-quiet-empty) > .v5-hero-card {
  background: var(--brand-soft);
  padding: 16px 18px;
}
html body .app-shell:not(.mobile-shell) .stats-row:not(.is-quiet-empty) .stat-card-spark,
html body .app-shell:not(.mobile-shell) .stats-row:not(.is-quiet-empty) .stat-card-ring,
html body .app-shell:not(.mobile-shell) .stats-row:not(.is-quiet-empty) .v5-hero-art,
html body .app-shell:not(.mobile-shell) .stats-row:not(.is-quiet-empty) .v5-dynamic-timeline {
  display: none;
}
html body .app-shell:not(.mobile-shell) .stats-row:not(.is-quiet-empty) .stat-card-note,
html body .app-shell:not(.mobile-shell) .stats-row:not(.is-quiet-empty) .stat-card-subnote,
html body .app-shell:not(.mobile-shell) .stats-row:not(.is-quiet-empty) .v5-hero-note,
html body .app-shell:not(.mobile-shell) .stats-row:not(.is-quiet-empty) .v5-hero-pill,
html body .app-shell:not(.mobile-shell) .stats-row:not(.is-quiet-empty) .v5-hero-meta {
  display: none;
}
html body .app-shell:not(.mobile-shell) .stats-row:not(.is-quiet-empty) .stat-card-value,
html body .app-shell:not(.mobile-shell) .stats-row:not(.is-quiet-empty) .v5-hero-title {
  font-size: 1.35rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--text-main);
  margin: 4px 0 0;
  line-height: 1.25;
}
html body .app-shell:not(.mobile-shell) .stats-row:not(.is-quiet-empty) .v5-hero-title {
  font-size: 1.05rem;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
html body .app-shell:not(.mobile-shell) .stats-row:not(.is-quiet-empty) .stat-card-label,
html body .app-shell:not(.mobile-shell) .stats-row:not(.is-quiet-empty) .v5-hero-label {
  font-size: 0.72rem;
  letter-spacing: 0.04em;
  text-transform: none;
  color: var(--text-soft);
  font-weight: 600;
}
html body .app-shell:not(.mobile-shell) .stats-row:not(.is-quiet-empty) .stat-card-progress {
  display: block;
  height: 3px;
  margin-top: 8px;
  background: var(--bg-soft);
  border-radius: 2px;
  overflow: hidden;
}
html body .app-shell:not(.mobile-shell) .stats-row:not(.is-quiet-empty) .stat-card-progress > span {
  display: block;
  height: 100%;
  background: var(--brand);
}
html body .app-shell:not(.mobile-shell) .stats-row:not(.is-quiet-empty) .v5-hero-countdown {
  font-size: 0.7rem;
  padding: 2px 6px;
}
html body .app-shell:not(.mobile-shell) .stats-row:not(.is-quiet-empty) .v5-hero-priority {
  font-size: 0.7rem;
}

/* 显式 d-ledger 单元 */
html body .app-shell .d-ledger-cell .d-ledger-label {
  display: block;
  font-size: 0.72rem;
  color: var(--text-soft);
  font-weight: 600;
  margin-bottom: 4px;
}
html body .app-shell .d-ledger-cell .d-ledger-value {
  font-size: 1.35rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--text-main);
  line-height: 1.2;
}
html body .app-shell .d-ledger-cell.is-warn .d-ledger-value { color: var(--warning); }
html body .app-shell .d-ledger-cell.is-danger .d-ledger-value { color: var(--danger); }
html body .app-shell .d-ledger-cell.is-ok .d-ledger-value { color: var(--success); }
html body .app-shell .d-ledger-cell .d-ledger-note {
  display: block;
  margin-top: 4px;
  font-size: 0.72rem;
  color: var(--text-soft);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* 桌面 D 首页：ledger 在上，主决策卡独立 */
html body .app-shell:not(.mobile-shell) .d-home-stack {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
html body .app-shell:not(.mobile-shell) .d-decision-board {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--bg-card);
  padding: 16px 18px;
}
html body .app-shell:not(.mobile-shell) .d-decision-board .v5-hero-card,
html body .app-shell:not(.mobile-shell) .d-decision-board .stats-featured {
  border: none;
  box-shadow: none;
  background: transparent;
  padding: 0;
}
html body .app-shell:not(.mobile-shell) .d-decision-board .v5-hero-art,
html body .app-shell:not(.mobile-shell) .d-decision-board .v5-dynamic-timeline {
  display: block;
  max-width: 200px;
  margin-left: auto;
}

/* ---------- 登录页：按主人要求保留旧版左右 Hero+表单，不在此覆盖 ---------- */

/* ---------- Admin 运行轨 / 健康条 ---------- */
html body.admin-app .d-run-strip,
html body .command-topbar.d-run-strip,
.command-topbar {
  border-bottom: 1px solid var(--line);
}
html body .d-run-strip-extra,
#d-admin-run-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 8px 16px;
  background: var(--bg-soft);
  border-bottom: 1px solid var(--line);
  font-size: 0.78rem;
  font-variant-numeric: tabular-nums;
  color: var(--text-sub);
}
#d-admin-run-strip .d-run-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--bg-card);
}
#d-admin-run-strip .d-run-chip .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--success);
}
#d-admin-run-strip .d-run-chip.is-warn .dot { background: var(--warning); }
#d-admin-run-strip .d-run-chip.is-bad .dot { background: var(--danger); }

/* Admin KPI → ledger 条 */
html body .ops-kpi-grid,
#stats-cards.ops-kpi-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: var(--bg-card);
}
html body .ops-kpi-grid > .stat-card,
#stats-cards.ops-kpi-grid > .stat-card {
  border: none;
  border-radius: 0;
  box-shadow: none;
  margin: 0;
  border-left: 1px solid var(--line);
  background: transparent;
}
html body .ops-kpi-grid > .stat-card:first-child,
#stats-cards.ops-kpi-grid > .stat-card:first-child {
  border-left: none;
}
html body .ops-kpi-grid .stat-spark {
  display: none;
}

/* ---------- 侧栏 / 导航密度 ---------- */
html body .app-shell:not(.mobile-shell) .side-nav a,
html body .app-shell:not(.mobile-shell) .nav-item {
  border-radius: var(--radius-md);
}
html body .app-shell:not(.mobile-shell)[data-role="assistant"] {
  --d-density: compact;
}
html body .app-shell:not(.mobile-shell)[data-role="assistant"] .panel-body,
html body .app-shell:not(.mobile-shell)[data-role="assistant"] .assistant-block {
  font-size: 0.925rem;
}

/* ---------- 移动：单主任务 + 44px ---------- */
@media (max-width: 860px) {
  html body .app-shell.mobile-shell .bottom-nav button,
  html body .app-shell.mobile-shell .mobile-nav-item,
  html body .app-shell.mobile-shell .nav-item {
    min-height: 44px;
    min-width: 44px;
  }
  html body .app-shell.mobile-shell .d-ledger,
  html body .app-shell.mobile-shell .stats-row:not(.is-quiet-empty) {
    display: grid;
    grid-template-columns: 1fr;
  }
}

/* ---------- 暗色语义（沿 tokens，补 D 层） ---------- */
html[data-theme="dark"] body .app-shell:not(.mobile-shell) .stats-row:not(.is-quiet-empty) > .stats-featured,
html[data-theme="dark"] body .app-shell:not(.mobile-shell) .stats-row:not(.is-quiet-empty) > .v5-hero-card {
  background: var(--brand-soft);
}
/* 暗色值已随 tokens.css 的 --accent-today 自动切换，无需在此重复覆盖 */

/* ---------- 助理待安排：账簿表感 ---------- */
html body .app-shell[data-role="assistant"] .pending-list,
html body .app-shell[data-role="assistant"] .pending-card-list {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: var(--bg-card);
}
html body .app-shell[data-role="assistant"] .pending-card {
  border-radius: 0;
  border: none;
  border-bottom: 1px solid var(--line);
  box-shadow: none;
}
html body .app-shell[data-role="assistant"] .pending-card:last-child {
  border-bottom: none;
}

/* 空状态启动器与主按钮对齐（保留既有结构） */
html body .app-shell .xq-quiet-launcher {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--bg-card);
  box-shadow: none;
}

/* 减少玻璃/重阴影残留（仅工作台；登录页保留旧视觉） */
html body .app-shell .glass {
  backdrop-filter: none;
  background: var(--bg-card);
}
