:root {
  /* 亮色拟态玻璃 精修强化 */
  --bg: #f8fafc;
  --panel: rgba(255, 255, 255, 0.70);
  --panel-strong: rgba(255, 255, 255, 0.90);
  --border: rgba(255, 255, 255, 0.8);
  --border-strong: rgba(59, 130, 246, 0.5);
  --muted: #64748b;
  --text: #0f172a;
  --accent: #2563eb;
  --accent-2: #3b82f6;
  --warn: #eab308;
  --error: #ef4444;
  --success: #10b981;
  --info: #3b82f6;
  --success-bg: rgba(16, 185, 129, 0.1);
  --success-border: rgba(16, 185, 129, 0.2);
  --error-bg: rgba(239, 68, 68, 0.1);
  --error-border: rgba(239, 68, 68, 0.2);
  --warn-bg: rgba(245, 158, 11, 0.1);
  --warn-border: rgba(245, 158, 11, 0.2);
  --info-bg: rgba(59, 130, 246, 0.1);
  --info-border: rgba(59, 130, 246, 0.2);
  --radius: 16px;
  --shadow: 0 8px 32px rgba(31, 38, 135, 0.08);
  /* 柔和的高级玻璃投影 */
  --blur: 24px;

  --map-vignette: radial-gradient(ellipse at 50% 50%, transparent 40%, rgba(248, 250, 252, 0.5) 75%, rgba(248, 250, 252, 0.9) 100%);
  --topbar-bg: linear-gradient(90deg, rgba(255, 255, 255, 0.4), rgba(255, 255, 255, 0.7), rgba(255, 255, 255, 0.4));
  --card-border: rgba(0, 0, 0, 0.06);
  --table-head-bg: #f1f5f9;
  --table-border: rgba(0, 0, 0, 0.04);
  --table-hover-bg: linear-gradient(90deg, transparent, rgba(37, 99, 235, 0.05), transparent);
  --btn-ghost-bg: #fff;
  --btn-ghost-hover: #f8fafc;
  --scrollbar-track: rgba(0, 0, 0, 0.04);
  --modal-bg: #ffffff;
  --modal-header-bg: #f8fafc;
}

:root.dark-theme {
  /* 暗夜拟态玻璃 精修强化 */
  --bg: #03060a;
  --panel: rgba(16, 23, 38, 0.60);
  --panel-strong: rgba(10, 15, 24, 0.85);
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(94, 234, 212, 0.4);
  --muted: #8292a8;
  --text: #f0f4f8;
  --accent: #5eead4;
  --accent-2: #60a5fa;
  --warn: #fbbf24;
  --error: #f87171;
  --success: #34d399;
  --info: #60a5fa;
  --success-bg: rgba(52, 211, 153, 0.15);
  --success-border: rgba(52, 211, 153, 0.3);
  --error-bg: rgba(248, 113, 113, 0.15);
  --error-border: rgba(248, 113, 113, 0.3);
  --warn-bg: rgba(251, 191, 36, 0.15);
  --warn-border: rgba(251, 191, 36, 0.3);
  --info-bg: rgba(96, 165, 250, 0.15);
  --info-border: rgba(96, 165, 250, 0.3);
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
  --blur: 24px;

  --map-vignette: radial-gradient(ellipse at 50% 50%, transparent 40%, rgba(3, 6, 10, 0.4) 75%, rgba(3, 6, 10, 0.7) 100%);
  --topbar-bg: linear-gradient(90deg, rgba(10, 15, 24, 0.4), rgba(10, 15, 24, 0.7), rgba(10, 15, 24, 0.4));
  --card-border: rgba(255, 255, 255, 0.05);
  --table-head-bg: #0b111a;
  --table-border: rgba(255, 255, 255, 0.03);
  --table-hover-bg: linear-gradient(90deg, transparent, rgba(94, 234, 212, 0.05), transparent);
  --btn-ghost-bg: transparent;
  --btn-ghost-hover: rgba(255, 255, 255, 0.05);
  --scrollbar-track: rgba(0, 0, 0, 0.2);
  --modal-bg: #060a10;
  --modal-header-bg: #0a0f18;
}

:root.cyberpunk-theme {
  /* 赛博科技霓虹 (Cyber Neon Dark) */
  --bg: #050510;
  --panel: rgba(20, 20, 35, 0.75);
  --panel-strong: rgba(15, 15, 25, 0.90);
  --border: rgba(0, 240, 255, 0.3);
  /* 青色描边基础 */
  --border-strong: #00f0ff;
  /* 高亮电光青 */
  --muted: #8b9bb4;
  --text: #ffffff;
  --accent: #00f0ff;
  --accent-2: #ff003c;
  /* 警示洋红 */
  --warn: #ffea00;
  --error: #ff003c;
  --success: #00ff9d;
  --info: #00f0ff;
  --success-bg: rgba(0, 255, 157, 0.15);
  --success-border: rgba(0, 255, 157, 0.3);
  --error-bg: rgba(255, 0, 60, 0.15);
  --error-border: rgba(255, 0, 60, 0.3);
  --warn-bg: rgba(255, 234, 0, 0.15);
  --warn-border: rgba(255, 234, 0, 0.3);
  --info-bg: rgba(0, 240, 255, 0.15);
  --info-border: rgba(0, 240, 255, 0.3);
  --radius: 4px;
  /* 硬朗小角 */
  --shadow: 0 0 15px rgba(0, 240, 255, 0.15);
  /* 外发光 */
  --blur: 10px;

  --map-vignette: radial-gradient(ellipse at 50% 50%, transparent 40%, rgba(5, 5, 16, 0.6) 75%, rgba(5, 5, 16, 0.95) 100%);
  --topbar-bg: linear-gradient(90deg, rgba(5, 5, 16, 0.8), rgba(20, 20, 35, 0.9), rgba(5, 5, 16, 0.8));
  --card-border: rgba(0, 240, 255, 0.2);
  --table-head-bg: #080814;
  --table-border: rgba(0, 240, 255, 0.1);
  --table-hover-bg: linear-gradient(90deg, transparent, rgba(0, 240, 255, 0.15), transparent);
  --btn-ghost-bg: transparent;
  --btn-ghost-hover: rgba(0, 240, 255, 0.1);
  --scrollbar-track: rgba(0, 0, 0, 0.5);
  --modal-bg: #050510;
  --modal-header-bg: #0a0a1a;
}

:root.cyberpunk-theme .card-block {
  border-left: 2px solid var(--accent);
}

:root.cyberpunk-theme .kpi-value {
  text-shadow: 0 0 10px rgba(0, 240, 255, 0.5);
  font-family: "Courier New", Courier, monospace;
}

:root.minimalist-theme {
  /* 雅致极简留白 (Modern Minimalist Light) */
  --bg: #f5f7fa;
  --panel: #ffffff;
  --panel-strong: #ffffff;
  --border: transparent;
  --border-strong: #e2e8f0;
  --muted: #64748b;
  --text: #1e293b;
  --accent: #2563eb;
  --accent-2: #10b981;
  /* 翡翠绿 */
  --warn: #f59e0b;
  --error: #ef4444;
  --success: #10b981;
  --info: #3b82f6;
  --success-bg: rgba(16, 185, 129, 0.1);
  --success-border: rgba(16, 185, 129, 0.2);
  --error-bg: rgba(239, 68, 68, 0.1);
  --error-border: rgba(239, 68, 68, 0.2);
  --warn-bg: rgba(245, 158, 11, 0.1);
  --warn-border: rgba(245, 158, 11, 0.2);
  --info-bg: rgba(59, 130, 246, 0.1);
  --info-border: rgba(59, 130, 246, 0.2);
  --radius: 24px;
  /* 超大圆角 */
  --shadow: 0 10px 40px rgba(0, 0, 0, 0.04);
  /* 柔和弥散阴影 */
  --blur: 0px;

  --map-vignette: radial-gradient(ellipse at 50% 50%, transparent 40%, rgba(245, 247, 250, 0.5) 75%, #f5f7fa 100%);
  --topbar-bg: #ffffff;
  --card-border: transparent;
  --table-head-bg: #f8fafc;
  --table-border: #f1f5f9;
  --table-hover-bg: #f8fafc;
  --btn-ghost-bg: #f1f5f9;
  --btn-ghost-hover: #e2e8f0;
  --scrollbar-track: #f1f5f9;
  --modal-bg: #ffffff;
  --modal-header-bg: #ffffff;
}

:root.aurora-theme {
  --bg: linear-gradient(135deg, #1e1b4b, #312e81, #4c1d95, #701a75);
  --panel: rgba(255, 255, 255, 0.1);
  --panel-strong: rgba(255, 255, 255, 0.15);
  --border: rgba(255, 255, 255, 0.15);
  --border-strong: rgba(232, 121, 249, 0.6);
  --muted: #d8b4fe;
  --text: #ffffff;
  --accent: #f0abfc;
  --accent-2: #a78bfa;
  --warn: #fde047;
  --error: #fca5a5;
  --success: #6ee7b7;
  --info: #93c5fd;
  --success-bg: rgba(110, 231, 183, 0.15);
  --success-border: rgba(110, 231, 183, 0.3);
  --error-bg: rgba(252, 165, 165, 0.15);
  --error-border: rgba(252, 165, 165, 0.3);
  --warn-bg: rgba(253, 224, 71, 0.15);
  --warn-border: rgba(253, 224, 71, 0.3);
  --info-bg: rgba(147, 197, 253, 0.15);
  --info-border: rgba(147, 197, 253, 0.3);
  --radius: 20px;
  --shadow: 0 20px 50px rgba(0, 0, 0, 0.2);
  --blur: 32px;

  --map-vignette: radial-gradient(ellipse at 50% 50%, transparent 40%, rgba(30, 27, 75, 0.4) 75%, rgba(30, 27, 75, 0.8) 100%);
  --topbar-bg: rgba(255, 255, 255, 0.05);
  --card-border: rgba(255, 255, 255, 0.1);
  --table-head-bg: rgba(30, 27, 75, 0.98);
  --table-border: rgba(255, 255, 255, 0.08);
  --table-hover-bg: rgba(232, 121, 249, 0.1);
  --btn-ghost-bg: transparent;
  --btn-ghost-hover: rgba(255, 255, 255, 0.1);
  --scrollbar-track: rgba(0, 0, 0, 0.1);
  --modal-bg: rgba(49, 46, 129, 0.95);
  --modal-header-bg: rgba(30, 27, 75, 0.8);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body.layout {
  margin: 0;
  height: 100vh;
  overflow: hidden;
  color: var(--text);
  font-family: "Manrope", "HarmonyOS Sans", "PingFang SC", system-ui, sans-serif;
  background: var(--bg);
}

a {
  color: inherit;
  text-decoration: none;
}

/* 1. 地图与光效 */
.map-bg-layer {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: auto;
}

.map-fullscreen-wrapper {
  position: absolute;
  inset: 0;
}

.map-frame-fullscreen {
  width: 100vw;
  height: 100vh;
  border: none;
  display: block;
}

.map-vignette {
  position: absolute;
  inset: 0;
  background: var(--map-vignette);
  pointer-events: none;
}

.map-scanlines {
  display: none;
}

/* 2. UI悬浮层 */
.app-ui-layer {
  position: relative;
  z-index: 10;
  height: 100vh;
  display: flex;
  flex-direction: column;
  pointer-events: none;
}

.topbar-wrapper {
  padding: 6px 24px;
  pointer-events: auto;
}

.hud-container {
  flex: 1;
  display: flex;
  justify-content: space-between;
  padding: 0 8px 8px 32px;
  gap: 8px;
  overflow: hidden;
  position: relative;
}

.drawer-left {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 250px;
  z-index: 50;
  pointer-events: auto;
  transform: translateX(calc(-100% + 32px));
  transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
  display: flex;
  background: var(--panel);
  backdrop-filter: blur(var(--blur));
  border-right: 1px solid var(--border);
  border-bottom-right-radius: var(--radius);
  border-top-right-radius: var(--radius);
  box-shadow: 12px 0 32px rgba(0, 0, 0, 0.06);
}

.drawer-left:hover {
  transform: translateX(0);
}

.drawer-content {
  flex: 1;
  min-height: 0;
  padding: 16px 20px;
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.drawer-handle {
  width: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.02);
  border-left: 1px solid var(--border);
  color: var(--muted);
  cursor: e-resize;
  border-radius: 0 var(--radius) var(--radius) 0;
}

.drawer-content::-webkit-scrollbar {
  width: 4px;
}

.drawer-content::-webkit-scrollbar-thumb {
  background: rgba(37, 99, 235, 0.2);
  border-radius: 4px;
}

.hud-side {
  width: 480px;
  pointer-events: auto;
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow-y: auto;
  overflow-x: hidden;
  padding-right: 6px;
  z-index: 20;
}

/* 防止 flex-direction: column 默认压缩子元素高度 */
.hud-side > * {
  flex-shrink: 0;
}

/* 底部防遮挡占位符 */
.hud-side::after {
  content: '';
  display: block;
  height: 24px;
  flex-shrink: 0;
}

.hud-side::-webkit-scrollbar {
  width: 4px;
}

.hud-side::-webkit-scrollbar-thumb {
  background: rgba(37, 99, 235, 0.2);
  border-radius: 4px;
}

.hud-center-spacer {
  flex: 1;
}

/* 3. 玻璃拟态与卡片 */
.glass,
.card-block,
.topbar {
  background: var(--panel);
  backdrop-filter: blur(var(--blur));
  -webkit-backdrop-filter: blur(var(--blur));
  border: 1px solid var(--border);
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
}

.card-block::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 24px;
  height: 1px;
  background: var(--accent);
  box-shadow: 0 0 10px var(--accent);
}

.card-block {
  padding: 18px 20px;
}

/* 4. 顶部导航 (去除Logo背景，标题居中放大) */
.topbar {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 16px;
  align-items: center;
  padding: 14px 24px;
  background: var(--topbar-bg);
  border-bottom: 1px solid var(--border);
}

.brand {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
}

.brand-logo {
  height: 40px;
  width: auto;
  max-width: 140px;
  border-radius: 0;
  background: transparent;
  padding: 0;
  object-fit: contain;
  /* Light mode might need filter to make logo dark if it assumes dark backgrounds */
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.1));
}

.brand-name {
  font-weight: 800;
  font-size: 20px;
  letter-spacing: 1px;
  color: var(--text);
  white-space: nowrap;
}

.nav-links {
  display: flex;
  gap: 8px;
}

.nav-switch-btn {
  font-size: 13px;
  padding: 6px 14px !important;
  border-radius: 8px !important;
  white-space: nowrap;
  transition: all 0.3s ease;
  position: relative;
  overflow: hidden;
}

.nav-switch-btn:hover {
  color: var(--accent) !important;
  border-color: var(--accent) !important;
  box-shadow: 0 0 12px rgba(37, 99, 235, 0.15);
  transform: translateY(-1px);
}

.nav-btn-group {
  display: flex;
  gap: 4px;
}

.mobile-theme-btn {
  display: none !important;
}

.nav-link {
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 14px;
  color: var(--muted);
  border: 1px solid transparent;
  transition: all 0.2s;
}

.nav-link:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.04);
}

.nav-link.active {
  color: var(--accent);
  border-color: rgba(94, 234, 212, 0.3);
  background: rgba(94, 234, 212, 0.05);
  font-weight: 600;
  box-shadow: inset 0 0 12px rgba(94, 234, 212, 0.05);
}

.topbar-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
}

.inline-label {
  color: var(--muted);
  font-size: 12px;
}

.scroll-wrap {
  max-height: 280px;
  overflow-y: auto !important;
  overflow-x: auto;
  min-height: 0; /* 允许在 flex column 中正确收缩，防止撑破卡片 */
}

.scroll-wrap::-webkit-scrollbar {
  width: 6px;
  display: block;
}

.scroll-wrap::-webkit-scrollbar-track {
  background: var(--scrollbar-track);
  border-radius: 0 8px 8px 0;
}

.scroll-wrap::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: 8px;
}

.scroll-wrap::-webkit-scrollbar-thumb:hover {
  background: var(--accent);
}

/* 6. KPI与表格内容 (加入防折行逻辑与表头不透明) */
.kpi-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 4px;
}

.kpi-card {
  padding: 16px;
  border-radius: 10px;
  background: var(--panel-strong);
  border: 1px solid var(--card-border);
  display: flex;
  flex-direction: column;
  position: relative;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.02);
}

.kpi-card::after {
  content: "";
  position: absolute;
  bottom: 0;
  left: 10%;
  width: 80%;
  height: 2px;
  background: var(--border-strong);
}

.kpi-card.primary {
  border-color: var(--border-strong);
  background: linear-gradient(180deg, var(--table-hover-bg) 0%, transparent 100%);
}

.kpi-card.primary::after {
  background: var(--accent);
  box-shadow: 0 0 10px var(--accent);
}

.kpi-label {
  color: var(--muted);
  font-size: 13px;
  letter-spacing: 0.5px;
}

.kpi-value {
  font-size: 38px;
  font-weight: 900;
  margin: 4px 0 0 0;
  font-variant-numeric: tabular-nums;
  color: var(--text);
  line-height: 1.1;
}

.kpi-card.primary .kpi-value {
  color: var(--accent);
}

/* 核心：防标题折行 */
.card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  padding-bottom: 12px;
  flex-wrap: nowrap;
}

.card-head>div:first-child {
  flex-shrink: 0;
  white-space: nowrap;
  margin-right: 12px;
}

.card-label {
  color: var(--accent-2);
  font-size: 11px;
  letter-spacing: 1px;
  margin: 0;
  opacity: 0.8;
}

.card-title {
  font-size: 18px;
  font-weight: 700;
  margin-top: 4px;
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}

.table-wrap {
  border-radius: 8px;
  border: 1px solid var(--card-border);
  background: var(--panel);
  overflow: hidden;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-variant-numeric: tabular-nums;
}

/* 核心：为表头加不透明背景色，防止滚动内容穿透重叠 */
th {
  text-align: left;
  padding: 10px 14px;
  font-size: 12px;
  color: var(--muted);
  border-bottom: 1px solid var(--table-border);
  background: var(--table-head-bg);
  position: sticky;
  top: 0;
  z-index: 10;
  white-space: nowrap;
}

td {
  padding: 12px 14px;
  font-size: 13px;
  border-bottom: 1px solid var(--table-border);
  color: var(--text);
  white-space: nowrap;
}

tr:hover td {
  background: var(--table-hover-bg);
  color: var(--accent);
}

/* 7. 右侧 UI 优化组件 (Badge, Filter Group) */
.badge-status {
  display: inline-flex;
  align-items: center;
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  border: 1px solid rgba(0, 0, 0, 0.08);
  background: rgba(255, 255, 255, 0.6);
  color: var(--muted);
}

/* --- 最新打卡记录表格专属紧凑排版 --- */
#recent_scroll_wrap table {
  table-layout: fixed;
}

#recent_scroll_wrap th,
#recent_scroll_wrap td {
  padding: 10px 6px;
  /* 压缩左右 Padding 为地点让位 */
}

#recent_scroll_wrap th:nth-child(1),
#recent_scroll_wrap td:nth-child(1) {
  width: 14%;
}

/* 工号 */
#recent_scroll_wrap th:nth-child(2),
#recent_scroll_wrap td:nth-child(2) {
  width: 16%;
}

/* 姓名 */
#recent_scroll_wrap th:nth-child(3),
#recent_scroll_wrap td:nth-child(3) {
  width: 18%;
}

/* 部门 */
#recent_scroll_wrap th:nth-child(4),
#recent_scroll_wrap td:nth-child(4) {
  width: 10%;
}

/* 类型 */
#recent_scroll_wrap th:nth-child(5),
#recent_scroll_wrap td:nth-child(5) {
  width: 25%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* 打卡地点 */
#recent_scroll_wrap th:nth-child(6),
#recent_scroll_wrap td:nth-child(6) {
  width: 17%;
}

/* 时间 */

.badge-status.success {
  background: var(--success-bg);
  border-color: var(--success-border);
  color: var(--success);
}

.badge-status.error {
  background: var(--error-bg);
  border-color: var(--error-border);
  color: var(--error);
}

.badge-status.warning {
  background: var(--warn-bg);
  border-color: var(--warn-border);
  color: var(--warn);
}

.badge-status.info {
  background: var(--info-bg);
  border-color: var(--info-border);
  color: var(--info);
}

.filter-group {
  display: flex;
  flex-wrap: nowrap;
  background: rgba(255, 255, 255, 0.4);
  padding: 4px;
  border-radius: 20px;
  border: 1px solid rgba(0, 0, 0, 0.05);
}

.filter-group .chip {
  border: none;
  background: transparent;
  padding: 6px 14px;
  margin: 0;
  white-space: nowrap;
}

.filter-group .chip.active {
  background: rgba(37, 99, 235, 0.1);
  box-shadow: none;
  border: none;
  color: var(--accent);
  border-radius: 16px;
}

.control {
  background: rgba(255, 255, 255, 0.6);
  color: var(--text);
  border: 1px solid rgba(0, 0, 0, 0.1);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 13px;
  outline: none;
  transition: all 0.2s;
}

.control:focus {
  background: #fff;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.1);
}

.control-compact {
  min-width: 128px;
}

.btn {
  padding: 8px 16px;
  border-radius: 8px;
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.2s;
}

.btn.primary {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 4px 14px var(--border-strong);
}

.btn.primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px var(--border-strong);
}

.btn.ghost {
  background: var(--btn-ghost-bg);
  border: 1px solid var(--border);
  color: var(--text);
}

.btn.ghost:hover {
  background: var(--btn-ghost-hover);
}

.chip {
  padding: 6px 12px;
  border-radius: 20px;
  border: 1px solid var(--border);
  font-size: 12px;
  background: var(--panel);
  color: var(--muted);
  cursor: pointer;
}

.chip.active {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(37, 99, 235, 0.05);
}

.card-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.card-actions.gap {
  gap: 10px;
}

.card-actions.wrap {
  justify-content: flex-start;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 99px;
  border: 1px solid rgba(0, 0, 0, 0.08);
  background: rgba(255, 255, 255, 0.6);
  font-size: 12px;
}

.pill.accent {
  color: var(--accent);
  border-color: rgba(37, 99, 235, 0.2);
  background: rgba(37, 99, 235, 0.05);
}

/* 8. HUD与响应式 */
.map-hud-status {
  position: absolute;
  top: auto;
  bottom: 40px;
  left: 50%;
  transform: translateX(-50%);
  pointer-events: none;
  z-index: 5;
}

.hud-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 20px;
  border-radius: 30px;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(37, 99, 235, 0.2);
  box-shadow: 0 8px 24px rgba(37, 99, 235, 0.1);
}

.hud-text {
  font-size: 13px;
  font-weight: 600;
  color: var(--accent);
  letter-spacing: 1px;
}

.live-pulse-dot {
  width: 8px;
  height: 8px;
  background: #ef4444;
  border-radius: 50%;
  box-shadow: 0 0 8px #ef4444;
  animation: pulse 2s infinite cubic-bezier(0.4, 0, 0.6, 1);
}

@keyframes pulse {

  0%,
  100% {
    opacity: 1;
    transform: scale(1);
  }

  50% {
    opacity: 0.4;
    transform: scale(1.4);
  }
}

@media (max-width: 1080px) {
  .hud-container {
    flex-direction: column;
    overflow-y: auto;
    pointer-events: auto;
    padding: 0 16px 16px 16px;
    /* Decrease side padding for mobile */
    gap: 16px;
  }

  .hud-side {
    width: 100%;
    height: auto;
    overflow: visible;
    padding-right: 0;
  }

  .app-ui-layer {
    overflow-y: auto;
    pointer-events: auto;
  }

  /* --- Mobile Table Optimizations --- */
  .card-block {
    padding: 14px 16px;
    /* slightly tighter cards */
  }

  /* Make the scrollbar much more obvious and easier to grab on mobile */
  .scroll-wrap::-webkit-scrollbar {
    height: 6px;
    /* Make horizontal scrollbar thicker */
  }

  .scroll-wrap::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.08);
    /* Darker track */
    border-radius: 4px;
  }

  .scroll-wrap::-webkit-scrollbar-thumb {
    background: var(--accent);
    /* highly visible thumb */
    border-radius: 4px;
  }

  /* Compact table cells */
  th {
    padding: 8px 10px;
    font-size: 11px;
  }

  td {
    padding: 10px 10px;
    font-size: 12px;
  }

  /* Text truncation for table cells to prevent expanding too wide */
  td.truncate-mobile {
    max-width: 90px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  /* Optional: Force ellipsis on department/name columns inherently if they are too long */
  #working_tbody td:nth-child(2),
  #working_tbody td:nth-child(3),
  #recent_tbody td:nth-child(2),
  #recent_tbody td:nth-child(3),
  #work-orders-table td:nth-child(3),
  #report_tbody_merged td:nth-child(2) {
    max-width: 100px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .btn {
    min-height: 44px;
    /* Touch target size optimization */
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  .control,
  select.control {
    min-height: 44px;
    /* Touch target size optimization */
  }
}

/* Compatibility styles for shared UI utilities */
.hidden {
  display: none !important;
}

.muted {
  color: var(--muted);
}

.table-empty {
  color: var(--muted);
  text-align: center;
}

.sort-chips {
  display: inline-flex;
  gap: 6px;
}

.error-detail {
  border: 1px solid rgba(239, 68, 68, 0.3);
  background: rgba(239, 68, 68, 0.05);
  border-radius: 8px;
  padding: 10px 12px;
  color: #b91c1c;
}

.error-detail pre {
  margin: 8px 0 0;
  white-space: pre-wrap;
  word-break: break-all;
}

.loading {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 10px;
  background: rgba(255, 255, 255, 0.7);
  z-index: 999;
  pointer-events: auto;
  backdrop-filter: blur(8px);
}

.loading.hidden {
  display: none;
}

.spinner {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 4px solid rgba(0, 0, 0, 0.1);
  border-top-color: var(--accent);
  animation: spin 1s linear infinite;
}

.loading-text {
  color: var(--text);
  font-weight: 500;
  font-size: 14px;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.toast-container {
  position: fixed;
  right: 24px;
  bottom: 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 1000;
}

.toast {
  min-width: 220px;
  padding: 14px 18px;
  border-radius: 12px;
  border: 1px solid rgba(0, 0, 0, 0.06);
  background: rgba(255, 255, 255, 0.95);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
  color: var(--text);
  font-weight: 500;
}

.toast.ok {
  border-left: 4px solid #10b981;
}

.toast.err {
  border-left: 4px solid #ef4444;
}

.toast.info {
  border-left: 4px solid #3b82f6;
}

/* Modal styles for changelog */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: var(--modal-overlay);
  backdrop-filter: blur(4px);
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.modal-body {
  background: var(--modal-bg);
  border-radius: 16px;
  width: 800px;
  max-width: 90vw;
  max-height: 85vh;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.15);
  display: flex;
  flex-direction: column;
  transform: translateY(20px);
  transition: transform 0.3s ease;
  overflow: hidden;
}

.modal-overlay.active .modal-body {
  transform: translateY(0);
}

.modal-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--card-border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--modal-header-bg);
}

.modal-header h2 {
  margin: 0;
  font-size: 18px;
  color: var(--text);
}

.modal-close {
  background: transparent;
  border: none;
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
  color: var(--muted);
}

.modal-content {
  padding: 24px;
  overflow-y: auto;
}

.changelog-item {
  border-left: 2px solid var(--accent);
  padding-left: 16px;
  margin-bottom: 24px;
  position: relative;
}

.changelog-item::before {
  content: "";
  position: absolute;
  left: -6px;
  top: 0;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid #fff;
}

.cl-meta {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 8px;
}

.cl-ver {
  font-weight: 700;
  font-size: 16px;
  color: var(--text);
}

.cl-date {
  font-size: 12px;
  color: var(--muted);
}

.cl-desc {
  font-size: 14px;
  line-height: 1.6;
  color: var(--text);
  margin-bottom: 4px;
}

/* ===== 抽屉地图筛选折叠面板 ===== */
.drawer-map-section {
  border-radius: 10px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.02);
}

.drawer-map-toggle {
  border-radius: 0 !important;
  border: none !important;
  display: flex;
  align-items: center;
  font-size: 13px;
  position: relative;
}

.drawer-map-toggle.active {
  color: var(--accent);
  background: rgba(37, 99, 235, 0.05) !important;
}

.drawer-map-count {
  margin-left: 4px;
  font-size: 11px;
  color: var(--muted);
}

.drawer-chevron {
  margin-left: auto;
  font-size: 12px;
  transition: transform 0.25s;
  color: var(--muted);
}

.drawer-map-toggle.active .drawer-chevron {
  transform: rotate(90deg);
}

.drawer-map-panel {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s cubic-bezier(0.4, 0, 0.2, 1),
    padding 0.3s ease;
  padding: 0 14px;
  background: rgba(0, 0, 0, 0.02);
  border-top: 0 solid var(--border);
}

.drawer-map-panel.open {
  max-height: 400px;
  padding: 14px 14px 10px;
  border-top-width: 1px;
}

/* ===== 日报摘要预览 ===== */
.report-preview-wrap {
  max-height: 140px;
  overflow-y: auto;
}

.report-preview-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.report-preview-item {
  padding: 9px 12px;
  border-radius: 8px;
  background: var(--panel-strong);
  border: 1px solid var(--card-border);
  cursor: default;
  transition: border-color 0.2s;
}

.report-preview-item:hover {
  border-color: var(--border-strong);
}

.report-preview-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}

.report-preview-name {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  flex-shrink: 0;
}

.report-preview-badge {
  font-size: 10px;
  color: var(--accent);
  background: rgba(37, 99, 235, 0.08);
  border: 1px solid rgba(37, 99, 235, 0.2);
  border-radius: 4px;
  padding: 1px 6px;
  white-space: nowrap;
}

.report-preview-time {
  font-size: 11px;
  color: var(--muted);
  margin-left: auto;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.report-preview-content {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.5;
  /* 单行截断 */
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ===== 值守人员卡片 ===== */
.duty-card {
  padding: 16px 20px 20px;
  background: var(--panel);
  backdrop-filter: blur(var(--blur));
  -webkit-backdrop-filter: blur(var(--blur));
  border-radius: var(--radius);
  border: 1px solid rgba(251, 191, 36, 0.25);
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: var(--shadow), 0 0 0 1px rgba(251, 191, 36, 0.1) inset;
  position: relative;
  overflow: hidden;
}

/* 顶部警戒色光边 */
.duty-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--warn), transparent);
  box-shadow: 0 0 12px var(--warn);
}

/* 右上角光晕背景 */
.duty-card::after {
  content: "";
  position: absolute;
  top: -40px;
  right: -40px;
  width: 120px;
  height: 120px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(251, 191, 36, 0.12) 0%, transparent 70%);
  pointer-events: none;
}

.duty-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
  border-bottom: 1px solid rgba(251, 191, 36, 0.15);
  padding-bottom: 12px;
}

.duty-card-title-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.duty-pulse-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--warn);
  box-shadow: 0 0 0 0 rgba(251, 191, 36, 0.7);
  animation: duty-pulse 2s ease-in-out infinite;
  flex-shrink: 0;
}

@keyframes duty-pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(251, 191, 36, 0.7);
  }

  70% {
    box-shadow: 0 0 0 8px rgba(251, 191, 36, 0);
  }

  100% {
    box-shadow: 0 0 0 0 rgba(251, 191, 36, 0);
  }
}

.duty-card-label {
  font-size: 11px;
  letter-spacing: 1px;
  color: var(--warn);
  opacity: 0.9;
  font-weight: 600;
  text-transform: uppercase;
}

.duty-card-count-badge {
  font-size: 11px;
  font-weight: 700;
  color: var(--warn);
  background: rgba(251, 191, 36, 0.12);
  border: 1px solid rgba(251, 191, 36, 0.3);
  border-radius: 99px;
  padding: 2px 10px;
  letter-spacing: 0.5px;
}

/* 值守人员网格布局 */
.duty-people-grid {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 200px;
  overflow-y: auto;
  padding-right: 2px;
}

.duty-people-grid::-webkit-scrollbar {
  width: 4px;
}

.duty-people-grid::-webkit-scrollbar-thumb {
  background: rgba(251, 191, 36, 0.3);
  border-radius: 4px;
}

.duty-person-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 10px;
  background: rgba(251, 191, 36, 0.04);
  border: 1px solid rgba(251, 191, 36, 0.1);
  transition: background 0.2s, border-color 0.2s;
  cursor: default;
}

.duty-person-row:hover {
  background: rgba(251, 191, 36, 0.1);
  border-color: rgba(251, 191, 36, 0.25);
}

.work-order-row {
  cursor: pointer;
  transition: background 0.2s;
}

.work-order-row:hover {
  background: var(--btn-ghost-hover);
}

.report-row {
  cursor: pointer;
  transition: background 0.2s;
}

.report-row:hover {
  background: var(--btn-ghost-hover);
}

/* 拖拽排序专用动画类 */
.sortable-ghost {
  opacity: 0.3 !important;
  background-color: var(--panel) !important;
  border: 1px dashed var(--accent) !important;
  transform: scale(0.98);
}

.sortable-drag {
  opacity: 1 !important;
  cursor: grabbing !important;
  background: var(--panel-strong) !important;
  box-shadow: 0 15px 35px rgba(0, 0, 0, 0.3), 0 5px 15px rgba(0, 0, 0, 0.2) !important;
  transform: scale(1.02) !important;
  border-radius: 12px;
  z-index: 1000 !important;
}

[data-active-tab] .dept-card-v2 {
  /* 当可以拖拽时，给予提示并禁用选中文本 */
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
}

.duty-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: linear-gradient(135deg, rgba(251, 191, 36, 0.3), rgba(245, 158, 11, 0.5));
  border: 1.5px solid rgba(251, 191, 36, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 800;
  color: var(--warn);
  flex-shrink: 0;
  letter-spacing: 0;
}

.duty-person-info {
  flex: 1;
  min-width: 0;
}

.duty-person-name {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.2;
}

.duty-person-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 2px;
}

.duty-person-dept {
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.duty-person-type {
  font-size: 10px;
  font-weight: 600;
  color: var(--warn);
  background: rgba(251, 191, 36, 0.12);
  border: 1px solid rgba(251, 191, 36, 0.25);
  border-radius: 4px;
  padding: 1px 5px;
  white-space: nowrap;
  flex-shrink: 0;
}

.duty-person-time {
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
  flex-shrink: 0;
  font-variant-numeric: tabular-nums;
}

/* 空状态 */
.duty-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 18px 0 6px;
  color: var(--muted);
}

.duty-empty-icon {
  font-size: 28px;
  opacity: 0.4;
}

.duty-empty-text {
  font-size: 12px;
  opacity: 0.6;
}

/* dark theme 适配 */
:root.dark-theme .duty-card {
  border-color: rgba(251, 191, 36, 0.2);
  box-shadow: var(--shadow), 0 0 0 1px rgba(251, 191, 36, 0.08) inset;
}

:root.dark-theme .duty-avatar {
  background: linear-gradient(135deg, rgba(251, 191, 36, 0.2), rgba(245, 158, 11, 0.35));
}

/* =========================================================
   V2 Dashboard Merged Components
   ========================================================= */

/* HR 异常监控小方块 */
.hr-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 16px;
}

.hr-stat-box {
  background: rgba(255, 255, 255, 0.03);
  padding: 12px;
  border-radius: 8px;
  text-align: center;
  border: 1px solid var(--card-border);
}

.hr-stat-box .v {
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
}

.hr-stat-box .l {
  font-size: 11px;
  color: var(--muted);
  margin-top: 4px;
}

/* 图标小卡片 (用于合并的业务概览) */
.glass-stat-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: var(--panel-strong);
  border: 1px solid var(--card-border);
  border-radius: 12px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.02);
  transition: transform 0.2s;
  position: relative;
  overflow: hidden;
}

.glass-stat-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 3px;
  height: 100%;
  background: var(--accent, var(--accent-2));
}

.glass-stat-card:hover {
  transform: translateY(-2px);
}

.glass-stat-card .icon {
  font-size: 24px;
  padding: 8px;
  background: rgba(0, 0, 0, 0.03);
  border-radius: 8px;
  line-height: 1;
}

.glass-stat-info {
  flex: 1;
}

.glass-stat-info h4 {
  margin: 0 0 2px 0;
  font-size: 12px;
  color: var(--muted);
  font-weight: 500;
}

.glass-stat-info .val {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
}

/* V2 走势与明细结构容器 */
.chart-container-merged {
  width: 100%;
}

/* V2 汇报流渲染项 */
.report-summary-item {
  display: flex;
  flex-direction: column;
  padding: 10px 12px;
  border-bottom: 1px solid var(--table-border);
}

.report-summary-item:last-child {
  border-bottom: none;
}

.report-summary-item .meta {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--muted);
  margin-bottom: 4px;
}

.report-summary-item .content {
  font-size: 13px;
  color: var(--text);
  line-height: 1.4;
  white-space: normal;
}

/* ==========================================================
   Tolltips for abnormal stats panel
   ========================================================== */
.has-tooltip {
  position: relative;
  cursor: pointer;
  overflow: visible !important;
}

.kpi-tooltip {
  display: none;
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%) translateY(4px);
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.3);
  padding: 4px;
  z-index: 1000;
  width: max-content;
  min-width: 200px;
  max-width: 300px;
  font-size: 13px;
  color: var(--text-color);
  max-height: 250px;
  overflow-y: auto;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateX(-50%) translateY(0);
  }

  to {
    opacity: 1;
    transform: translateX(-50%) translateY(4px);
  }
}

.has-tooltip:hover .kpi-tooltip,
.has-tooltip:active .kpi-tooltip {
  display: block;
  animation: fadeIn 0.2s ease-out forwards;
}

/* Fix viewport clipping for the left-most tooltip */
.kpi-row .kpi-card:first-child .kpi-tooltip {
  left: 0;
  transform: translateY(4px);
}

@keyframes fadeInLeftBound {
  from {
    opacity: 0;
    transform: translateY(0);
  }

  to {
    opacity: 1;
    transform: translateY(4px);
  }
}

.kpi-row .kpi-card:first-child:hover .kpi-tooltip,
.kpi-row .kpi-card:first-child:active .kpi-tooltip {
  animation: fadeInLeftBound 0.2s ease-out forwards;
}

/* Fix viewport clipping for the right-most tooltip */
.kpi-row .kpi-card:last-child .kpi-tooltip {
  left: auto;
  right: 0;
  transform: translateY(4px);
}

@keyframes fadeInRightBound {
  from {
    opacity: 0;
    transform: translateY(0);
  }

  to {
    opacity: 1;
    transform: translateY(4px);
  }
}

.kpi-row .kpi-card:last-child:hover .kpi-tooltip,
.kpi-row .kpi-card:last-child:active .kpi-tooltip {
  animation: fadeInRightBound 0.2s ease-out forwards;
}


.kpi-tooltip-empty {
  padding: 8px;
  text-align: center;
  color: var(--muted);
  font-size: 12px;
}

.kpi-tooltip-item {
  padding: 6px 8px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  line-height: 1.4;
  text-align: left;
}

.kpi-tooltip-item:last-child {
  border-bottom: none;
}

.kpi-tooltip-item .tt-name {
  font-weight: 600;
  color: var(--accent-1);
  margin-right: 6px;
  white-space: nowrap;
}

.kpi-tooltip-item .tt-time {
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
}

.kpi-tooltip-item .tt-reason {
  margin-top: 3px;
  font-size: 12px;
  color: var(--text-color);
  opacity: 0.9;
  white-space: nowrap;
}

/* =========================================
   12. Admin Management Drawer 
========================================= */
.admin-drawer {
  position: fixed;
  top: 24px;
  right: 24px;
  bottom: 24px;
  width: 600px;
  background: var(--panel);
  backdrop-filter: blur(var(--blur));
  -webkit-backdrop-filter: blur(var(--blur));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.2);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.3s ease;
  transform: translateX(0);
}

.admin-drawer.hidden {
  transform: translateX(calc(100% + 40px));
  opacity: 0;
  pointer-events: none;
}

.admin-drawer-header {
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.05);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.admin-drawer-content {
  flex: 1;
  padding: 20px;
  overflow-y: auto;
}

.admin-drawer-content.scroll-wrap {
  max-height: none;
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
}

.admin-table th {
  text-align: left;
  padding: 12px;
  font-size: 13px;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
  font-weight: 600;
}

.admin-table td {
  padding: 14px 12px;
  font-size: 14px;
  border-bottom: 1px solid var(--table-border);
  color: var(--text);
}

.admin-table tr:hover td {
  background: var(--table-hover-bg);
}

/* Switch for is_active */
.switch {
  position: relative;
  display: inline-block;
  width: 36px;
  height: 20px;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: var(--muted);
  transition: .4s;
  border-radius: 34px;
}

.slider:before {
  position: absolute;
  content: "";
  height: 14px;
  width: 14px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: .4s;
  border-radius: 50%;
}

input:checked+.slider {
  background-color: var(--success);
}

input:checked+.slider:before {
  transform: translateX(16px);
}

/* =========================================
   13. Dept Attendance V2 
========================================= */

.dept-card-container {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.dept-card-v2 {
  background: var(--btn-ghost-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  padding: 14px 16px;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.02);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.dept-card-v2:hover {
  transform: translateY(-1px);
  background: var(--table-hover-bg);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.04);
  border-color: var(--border-strong);
}

.dcv-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.dcv-name {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.dcv-stats {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
}

.dcv-stats strong {
  font-size: 16px;
  font-weight: 800;
  color: var(--text);
.dcv-progress {
  height: 4px;
  background: rgba(0, 0, 0, 0.05);
  border-radius: 2px;
  overflow: hidden;
}

.dcv-progress-bar {
  height: 100%;
  background: var(--primary);
  border-radius: 2px;
  transition: width 0.3s ease;
}
  border-radius: 4px;
  overflow: hidden;
}

:root.dark-theme .dcv-progress,
:root.cyberpunk-theme .dcv-progress,
:root.aurora-theme .dcv-progress {
  background: rgba(255, 255, 255, 0.1);
}

.dcv-progress-bar {
  height: 100%;
  background: #2563eb;
  border-radius: 4px;
  transition: width 0.6s cubic-bezier(0.16, 1, 0.3, 1);
  position: relative;
  overflow: hidden;
}

.dcv-progress-bar::after {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: -50px;
  width: 50px;
  background: linear-gradient(
    90deg,
    rgba(255, 255, 255, 0) 0%,
    rgba(255, 255, 255, 0.4) 50%,
    rgba(255, 255, 255, 0) 100%
  );
  animation: dcv-progress-flow 2s infinite ease-in-out;
}

@keyframes dcv-progress-flow {
  0% {
    left: -50px;
  }
  100% {
    left: 100%;
  }
}


:root.dark-theme .dcv-progress-bar {
  background: #3b82f6;
}

:root.aurora-theme .dcv-progress-bar {
  background: #8b5cf6;
}

/* Department Person Chips in Modal */
.person-badge {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  border-radius: 12px;
  background: var(--table-head-bg);
  border: 1px solid transparent;
  /* reserved for status color */
}

.pb-avatar {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

.pb-name {
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
}

/* Status variants */
.person-badge.status-on_duty {
  background: var(--success-bg);
  border-color: var(--success-border);
}

.person-badge.status-on_duty .pb-avatar {
  background: var(--success-bg);
  color: var(--success);
}

.person-badge.status-leave {
  background: var(--error-bg);
  border-color: var(--error-border);
}

.person-badge.status-leave .pb-avatar {
  background: var(--error-bg);
  color: var(--error);
}

.person-badge.status-off_duty {
  background: var(--info-bg);
  border-color: var(--info-border);
}

.person-badge.status-off_duty .pb-avatar {
  background: var(--info-bg);
  color: var(--info);
}

/* ═══════════════════════════════════════════════════════════════════════
   STANDARD CARD SYSTEM
   ═══════════════════════════════════════════════════════════════════════ */

/* ── Base Card ─────────────────────────────────────────────────────── */
.dashboard-card {
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--panel);
  backdrop-filter: blur(12px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: box-shadow 0.2s, opacity 0.2s, transform 0.2s;
  margin-bottom: 0;
  position: relative;
}

.dashboard-card:hover {
  box-shadow: 0 4px 20px rgba(0,0,0,0.08);
  z-index: 50;
}

/* ── Prevent Iframe Flashing on Map Hover ── */
.dashboard-card[data-card-id="center-map"]:hover {
  box-shadow: none !important;
  z-index: auto !important;
  transform: none !important;
}

/* ── Card Header ───────────────────────────────────────────────────── */
.dashboard-card__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  min-height: 38px;
  border-bottom: 1px solid rgba(128,128,128,0.1);
  flex-shrink: 0;
}

.dashboard-card__title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 8px;
}

.dashboard-card__actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

/* ── Drag Handle ───────────────────────────────────────────────────── */
.dashboard-card__drag-handle {
  cursor: grab;
  padding: 2px 4px;
  opacity: 0;
  transition: opacity 0.2s;
  font-size: 14px;
  color: var(--muted);
  user-select: none;
  flex-shrink: 0;
}

.dashboard-card:hover .dashboard-card__drag-handle {
  opacity: 0.5;
}

.dashboard-card__drag-handle:hover {
  opacity: 1 !important;
}

.dashboard-card[data-card-fixed="true"] .dashboard-card__drag-handle {
  display: none;
}

/* ── Card Body ─────────────────────────────────────────────────────── */
.dashboard-card__body {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  min-height: 0;
  padding: 0 14px 10px;
}

/* ── Size Tiers ────────────────────────────────────────────────────── */
.dashboard-card.card-size-strip {
  /* KPI strips — no fixed height, auto-sized content */
  margin-bottom: 0;
}

.dashboard-card.card-size-strip .dashboard-card__header {
  display: none;
}
.dashboard-card.card-size-strip,
.dashboard-card.card-size-strip .dashboard-card__body {
  overflow: visible !important;
  padding: 0;
}

.dashboard-card.card-size-standard .dashboard-card__body {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 12px;
    display: flex;
    flex-direction: column;
}

/* Ensure chart container has a definite size constraints to guide ECharts canvas */
.dashboard-card.card-size-standard .chart-container-merged {
    flex: 1;
    min-height: 0;
}

.dashboard-card.card-size-standard {
  height: 220px;
}

.dashboard-card.card-size-hero {
  /* Hero card (map) — no margin, occupies full center */
  border-radius: 0;
  border: none;
  background: transparent;
  backdrop-filter: none;
  height: 100%;
}

.dashboard-card.card-size-hero .dashboard-card__header {
  display: none;
}

.dashboard-card.card-size-hero .dashboard-card__body {
  padding: 0;
}

/* ── Hidden Cards ──────────────────────────────────────────────────── */
.dashboard-card.card-hidden {
  display: none !important;
}

/* ── Drag & Drop Feedback ──────────────────────────────────────────── */
.card-ghost {
  opacity: 0.4;
  border: 2px dashed var(--accent) !important;
  background: rgba(99,102,241,0.05) !important;
}

.card-chosen {
  box-shadow: 0 8px 32px rgba(99,102,241,0.2);
  transform: scale(1.01);
  z-index: 1000;
}

.card-dragging {
  opacity: 0.9;
}

/* ── Card Manager Panel ────────────────────────────────────────────── */

#card-manager-panel {
  z-index: 850;
}

.card-manager-modal-body {
  width: 420px;
  max-width: 92vw;
  max-height: min(78vh, 760px);
}

.card-manager-modal-content {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.card-manager-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 6px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s;
  font-size: 13px;
  color: var(--text);
}

.card-manager-item:hover {
  background: rgba(128,128,128,0.06);
}

.card-manager-item input[type="checkbox"] {
  accent-color: var(--accent);
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

.card-manager-label {
  flex: 1;
}

.card-manager-region {
  font-size: 11px;
  color: var(--muted);
  background: rgba(128,128,128,0.08);
  padding: 2px 6px;
  border-radius: 4px;
}

.card-manager-reset {
  width: 100%;
  margin-top: 6px;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  font-size: 12px;
  cursor: pointer;
  transition: background 0.15s;
}

.card-manager-reset:hover {
  background: rgba(239,68,68,0.08);
  border-color: var(--error);
  color: var(--error);
}

/* ── Make left/right panels use natural flow for card system ──────── */
.panel-left .dashboard-card:last-child,
.panel-right .dashboard-card:last-child {
  margin-bottom: 0;
}

/* ── Override old card-block styles inside dashboard-card ─────────── */
.dashboard-card .card-block {
  margin-bottom: 0;
  border-radius: 0;
  border: none;
  background: transparent;
  backdrop-filter: none;
  box-shadow: none;
}

.dashboard-card .glass {
  background: transparent;
  backdrop-filter: none;
  border: none;
  box-shadow: none;
}

/* Legacy card-block inside dashboard-card: remove padding overlap */
.dashboard-card .card-block {
  padding: 0;
}

/* ── Ensure internal scrolling works inside fixed-height cards ────── */
.dashboard-card.card-size-standard .dashboard-card__body {
  display: flex;
  flex-direction: column;
}

.dashboard-card.card-size-standard .dashboard-card__body > .table-wrap,
.dashboard-card.card-size-standard .dashboard-card__body > .scroll-wrap {
  flex: 1;
  min-height: 0;
  height: 100%;
  overflow-y: auto;
}

/* ── Content Spec Rules (170px inner height) ── */
.dashboard-card.card-size-standard .table-wrap th {
  height: 32px;
  padding: 8px 10px;
  font-size: 12px;
  box-sizing: border-box;
}

.dashboard-card.card-size-standard .table-wrap td {
  height: 44px;
  padding: 0 10px;
  font-size: 13px;
  vertical-align: middle;
  box-sizing: border-box;
}

/* Override #recent_scroll_wrap specifics restricting the new heights */
.dashboard-card.card-size-standard #recent_scroll_wrap th,
.dashboard-card.card-size-standard #recent_scroll_wrap td {
  padding-top: 0;
  padding-bottom: 0;
}

/* ── Duty card inside standard card — remove duplicate styling ────── */
.dashboard-card .duty-card {
  box-shadow: none;
  border-radius: 0;
  border: none;
  background: transparent;
  backdrop-filter: none;
}

.dashboard-card .duty-card .duty-card-head {
  display: none; /* header is in dashboard-card__header now */
}

/* ── Animation for Pulse ────────────────────────────────────────────── */
@keyframes pulse-anim-kf {
  0% { box-shadow: 0 0 0 0 rgba(255, 149, 0, 0.4); }
  70% { box-shadow: 0 0 0 6px rgba(255, 149, 0, 0); }
  100% { box-shadow: 0 0 0 0 rgba(255, 149, 0, 0); }
}
.pulse-anim {
  animation: pulse-anim-kf 2s infinite;
  border-radius: 12px;
}
