/* ============================================================
   桌面端 UI 美化（登录后外壳 + 仪表盘）
   ------------------------------------------------------------
   设计取向：政务服务系统的「克制而精致」——
   不换字体、不改信息架构，只统一材质、层级、节奏与交互反馈。
   作用域：.sidebar / .topbar（外壳）+ .dash-panel（仪表盘），
   其余业务页不受影响。
   ============================================================ */

/* ---------- ① 侧边栏：磨砂玻璃 ---------- */
.sidebar {
  background: rgba(255, 255, 255, .55);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  backdrop-filter: blur(24px) saturate(180%);
  /* 亮白描边收边：右侧一条 1px 白线 + 内高光，玻璃边缘更清晰 */
  border-right: 1px solid rgba(255, 255, 255, .9);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, .9),
    inset -1px 0 0 rgba(255, 255, 255, .8),
    1px 0 18px rgba(15, 23, 42, .05);
}
.sidebar > * { position: relative; z-index: 1; }
.sidebar::after {
  content: ""; position: absolute; inset: 0; pointer-events: none; z-index: 0;
  background:
    radial-gradient(420px 220px at 110% -10%, rgba(96, 165, 250, .14), transparent 60%),
    radial-gradient(360px 200px at -20% 105%, rgba(56, 189, 248, .10), transparent 62%);
}
.sidebar-header {
  padding-bottom: 14px;
  border-bottom: 1px solid rgba(15, 23, 42, .06);
}
.sidebar-header h2 { color: var(--primary); letter-spacing: .2px; }
.sidebar-header p { color: var(--text-secondary); opacity: 1; }
.sidebar-nav { padding: 10px 0 14px; }
.sidebar-nav a {
  margin: 2px 8px;
  padding: 9px 12px;
  border-radius: 9px;
  font-size: 13.5px;
  letter-spacing: .1px;
  color: var(--text-secondary);
  transition: background .16s ease, color .16s ease, transform .16s ease;
}
.sidebar-nav a:hover {
  background: var(--primary-tint, rgba(24, 84, 204, .08));
  color: var(--primary);
  transform: translateX(1px);
}
.sidebar-nav a.active {
  background: var(--primary-tint-strong, rgba(24, 84, 204, .16));
  color: var(--primary);
  box-shadow: inset 2px 0 0 var(--primary);
}
.sidebar-nav .nav-section-title {
  padding: 14px 22px 6px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .12em;
  text-transform: none;
  color: var(--text-light);
  opacity: 1;
}
.sidebar-footer {
  border-top: 1px solid rgba(15, 23, 42, .06);
  background: rgba(255, 255, 255, .28);
}
.sidebar-footer .sf-name { color: var(--text); opacity: 1; }
.sidebar-footer .sf-dept { color: var(--text-secondary); opacity: 1; }

/* ---------- ② 顶栏 ---------- */
.topbar {
  padding: 0 22px;
  background: rgba(255, 255, 255, .88);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid rgba(15, 23, 42, .07);
}
.topbar-left h1 { font-size: 17px; font-weight: 650; letter-spacing: .1px; }
.topbar-right { gap: 12px; }

/* ---------- ③ Hero：收敛装饰环，换成柔和光晕 ---------- */
.portal-hero {
  border-radius: 18px;
  padding: 24px 28px;
  border-color: var(--hc-bd, rgba(79, 141, 247, .18));
  box-shadow: 0 1px 2px rgba(15, 23, 42, .04), 0 16px 36px var(--hc-sh, rgba(79, 141, 247, .10));
}
.portal-hero::before {
  right: -130px; top: -190px;
  width: 430px; height: 430px;
  border: 1px solid var(--hc-a3, rgba(79, 141, 247, .22));
  box-shadow: 0 0 0 38px var(--hc-a1, rgba(79, 141, 247, .06));
  opacity: .55;
}
.portal-hero::after { opacity: .75; }

.portal-hero-icon {
  border-radius: 18px;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .4),
              0 10px 22px var(--hc-sh, rgba(79, 141, 247, .18));
}
.ph-greet {
  font-size: 24px; font-weight: 750; letter-spacing: -.4px;
}
.ph-tags { margin-top: 10px; gap: 7px; }
.ph-pill {
  border: 1px solid var(--hc-bd, rgba(79, 141, 247, .18));
  background: rgba(255, 255, 255, .72);
}
.ph-pill-role {
  color: #fff;
  background: var(--hc, #4F8DF7);
  border-color: transparent;
}
.ph-state { margin-top: 10px; font-variant-numeric: tabular-nums; }
.ph-state-dot {
  box-shadow: 0 0 0 4px var(--hc-a1, rgba(79, 141, 247, .08));
}

/* KPI 小卡 */
.ph-kpis { gap: 12px; }
.ph-kpi {
  min-width: 118px;
  padding: 12px 18px;
  border-radius: 14px;
  background: rgba(255, 255, 255, .86);
  border: 1px solid var(--hc-bd, rgba(79, 141, 247, .18));
  box-shadow: 0 1px 2px rgba(15, 23, 42, .04);
  transition: transform .16s ease, box-shadow .16s ease, background .16s ease;
}
.ph-kpi:hover {
  transform: translateY(-2px);
  background: #fff;
  box-shadow: 0 8px 20px var(--hc-sh, rgba(79, 141, 247, .16));
}
.ph-kpi-n {
  font-size: 28px; font-weight: 800; letter-spacing: -.5px;
  font-variant-numeric: tabular-nums;
  color: var(--hc, #4F8DF7);
}
.ph-kpi-label { font-size: 12px; letter-spacing: .2px; }

/* ---------- ④ 仪表盘分区与卡片 ---------- */
.dash-panel { padding: 24px 28px 40px; }
.dash-section { margin-bottom: 26px; }
.dash-section-title {
  font-size: 15px; font-weight: 700; letter-spacing: .2px;
  margin-bottom: 12px;
}
.dst-dot {
  width: 6px; height: 16px; border-radius: 3px;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--dc, #4F8DF7) 14%, transparent);
}
.stats-grid > * {
  border-radius: 14px;
  transition: transform .16s ease, box-shadow .16s ease;
}
.stats-grid > *:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 24px rgba(15, 23, 42, .08);
}

/* 待办卡 */
.wb-todos > * {
  border-radius: 14px;
  transition: transform .16s ease, box-shadow .16s ease;
}
.wb-todos > *:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 24px rgba(15, 23, 42, .08);
}

/* 我要预约：降高度、加反馈 */
.quick-book-card {
  padding: 18px 20px;
  border-radius: 14px;
  transition: transform .16s ease, box-shadow .16s ease, border-color .16s ease;
}
.quick-book-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 26px rgba(15, 23, 42, .09);
}
.quick-book-card .qb-icon { margin-bottom: 8px; }
.quick-book-card .qb-title { font-size: 15.5px; font-weight: 650; }

/* 指标卡：按数量决定桌面列数，避免 5+1 / 4+1 尾卡落单 */
@media (min-width: 1500px) {
  .dash-panel .stats-grid.stats-n6 { grid-template-columns: repeat(6, minmax(0, 1fr)); }
  .dash-panel .stats-grid.stats-n5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
  .dash-panel .stats-grid.stats-n4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .dash-panel .stats-grid.stats-n3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .dash-panel .stats-grid.stats-n2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  /* 一行 6 张时收紧卡片内距，给标签留出足够宽度 */
  .dash-panel .stats-grid.stats-n6 .stat-card { padding: 12px; gap: 9px; }
  .dash-panel .stats-grid.stats-n6 .stat-icon { width: 36px; height: 36px; border-radius: 10px; font-size: 18px; }
  .dash-panel .stats-grid.stats-n6 .stat-value { font-size: 24px; }
  .dash-panel .stats-grid.stats-n6 .stat-label { font-size: 12px; }
  .dash-panel .stats-grid.stats-n6 .wb-scope { font-size: 10px; padding: 2px 5px; margin-left: 4px; }
}
@media (min-width: 900px) and (max-width: 1499px) {
  .dash-panel .stats-grid.stats-n6,
  .dash-panel .stats-grid.stats-n5 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .dash-panel .stats-grid.stats-n4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dash-panel .stats-grid.stats-n3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

/* 表格：表头更轻、数字对齐、行悬停 */
.dash-panel table thead th {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .04em;
  color: var(--muted);
  background: #f8fafc;
  border-bottom: 1px solid rgba(15, 23, 42, .07);
}
.dash-panel table tbody tr { transition: background .14s ease; }
.dash-panel table tbody tr:hover { background: #f6f9ff; }
.dash-panel table td { font-variant-numeric: tabular-nums; }

/* 面板内卡片去重影，统一描边 */
.dash-panel .card {
  border-radius: 14px;
  box-shadow: 0 1px 2px rgba(15, 23, 42, .04);
}
.dash-panel .card-title { font-size: 14.5px; font-weight: 650; }

/* ---------- ⑤ 深色模式 ---------- */
[data-theme="dark"] .topbar {
  background: rgba(15, 23, 42, .86);
  border-bottom-color: rgba(255, 255, 255, .08);
}
[data-theme="dark"] .portal-hero {
  background:
    radial-gradient(680px 280px at 92% -12%, var(--hc-a3, rgba(79, 141, 247, .18)), transparent 62%),
    linear-gradient(128deg, #101a2e 0%, #16223c 100%);
  color: #e8edf5;
}
[data-theme="dark"] .ph-greet { color: #f1f5f9; }
[data-theme="dark"] .ph-pill { background: rgba(255, 255, 255, .08); }
[data-theme="dark"] .ph-kpi { background: rgba(255, 255, 255, .06); }
[data-theme="dark"] .ph-kpi:hover { background: rgba(255, 255, 255, .1); }
[data-theme="dark"] .dash-panel table thead th { background: rgba(255, 255, 255, .04); }
[data-theme="dark"] .dash-panel table tbody tr:hover { background: rgba(96, 165, 250, .08); }

/* ---------- ⑥ 无障碍与动效偏好 ---------- */
.quick-book-card:focus-visible,
.ph-kpi:focus-visible,
.sidebar-nav a:focus-visible {
  outline: 2px solid var(--primary, #1854cc);
  outline-offset: 2px;
}
@media (prefers-reduced-motion: reduce) {
  .ph-kpi, .quick-book-card, .stats-grid > *, .wb-todos > *, .sidebar-nav a, .dash-panel table tbody tr {
    transition: none !important;
  }
  .ph-kpi:hover, .quick-book-card:hover, .stats-grid > *:hover, .wb-todos > *:hover {
    transform: none !important;
  }
}
