/* ============================================================
   考勤监控台 UI v3 —— 响应式 / 规范 / 自适应任何屏幕
   深色为默认主题；TG 浅色模式下自动切换（body.tg-light）
   ============================================================ */

:root {
  --bg: #0f172a;
  --bg-soft: #172033;
  --card: #1e293b;
  --card-hover: #263449;
  --line: #334155;
  --txt: #e2e8f0;
  --muted: #94a3b8;
  --primary: #2563eb;
  --primary-hover: #3b82f6;
  --ok: #22c55e;
  --warn: #f59e0b;
  --danger: #ef4444;
  --work: #22c55e;
  --stream: #3b82f6;
  --live: #a855f7;
  --smoke: #ec4899;
  --toilet: #ec4899;
  --meal: #ec4899;
  --abnormal: #ef4444;
  --dark: #111827;
  --idle: #ef4444;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 4px 16px rgba(0, 0, 0, .25);
  --font: -apple-system, BlinkMacSystemFont, 'PingFang SC', 'HarmonyOS Sans SC',
    'Microsoft YaHei', 'Segoe UI', Roboto, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

/* TG 浅色模式 */
body.tg-light {
  --bg: #f1f5f9;
  --bg-soft: #e8eef5;
  --card: #ffffff;
  --card-hover: #f1f5f9;
  --line: #dbe3ee;
  --txt: #0f172a;
  --muted: #64748b;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --dark: #e2e8f0;
  --idle: #ef4444;
  --shadow: 0 4px 16px rgba(15, 23, 42, .08);
}

body.tg-light .att-table th { background: #1e3a5f; }
body.tg-light .att-table tbody tr:nth-child(even) { background: rgba(37, 99, 235, .05); }

* { box-sizing: border-box; margin: 0; padding: 0; }

html { -webkit-text-size-adjust: 100%; }

body {
  background: var(--bg);
  color: var(--txt);
  font-family: var(--font);
  min-height: 100vh;
  max-width: 1100px;
  margin: 0 auto;
  padding: calc(env(safe-area-inset-top, 0px) + 14px) 14px calc(env(safe-area-inset-bottom, 0px) + 18px);
  transition: background .25s, color .25s;
}

/* ---------- 头部 ---------- */
header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 4px 2px 14px;
}
h1 {
  font-size: 19px;
  font-weight: 700;
  letter-spacing: .2px;
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}
.meta { display: flex; gap: 8px; align-items: center; font-size: 12px; color: var(--muted); white-space: nowrap; }

.badge {
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--card);
  border: 1px solid var(--line);
  font-size: 12px;
  font-weight: 600;
  transition: all .2s;
}
.badge.ok { color: var(--ok); }
.badge.bad { color: var(--danger); }

/* ---------- 标签页（吸顶） ---------- */
.tabs {
  display: flex;
  gap: 8px;
  position: sticky;
  top: calc(env(safe-area-inset-top, 0px) + 8px);
  z-index: 40;
  margin-bottom: 14px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  padding: 6px 2px;
  border-radius: var(--radius);
}
.tab {
  flex: 1;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--txt);
  border-radius: var(--radius-sm);
  padding: 10px 8px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  text-align: center;
  transition: all .18s;
  white-space: nowrap;
}
.tab:hover { border-color: var(--primary); }
.tab.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
  font-weight: 600;
  box-shadow: 0 3px 10px rgba(37, 99, 235, .35);
}

.view.hidden { display: none; }

/* ---------- 平台切换条 ---------- */
/* 平台艺术字标题（2026-08-18 主人要求） */
.art-title {
  font-family: 'Georgia', 'STKaiti', 'KaiTi', 'PingFang SC', 'Microsoft YaHei', serif;
  font-size: 28px;
  font-weight: 800;
  letter-spacing: 6px;
  line-height: 1.2;
  background: linear-gradient(135deg, #f6d365 0%, #fda085 30%, #ff6b6b 55%, #c084fc 80%, #f6d365 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 2px 8px rgba(255, 170, 60, .45));
  text-align: center;
  white-space: nowrap;
}
/* 装饰底线：渐变分隔线 */
.art-title::after {
  content: '';
  display: block;
  height: 3px;
  margin: 8px auto 0;
  width: 62%;
  border-radius: 3px;
  background: linear-gradient(90deg, transparent, rgba(255, 180, 80, .85), transparent);
}
/* toolbar 内的平台标题（原拉取建卡按钮位置；2026-08-18 主人要求） */
.art-title.toolbar-title {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%); /* 严格居中（2026-08-18 主人要求，绝对定位保证） */
  background: none;                    /* 覆盖基类彩虹渐变 → 与平台风格协调（2026-08-18） */
  -webkit-background-clip: initial;
  background-clip: initial;
  color: #f0e6d0;                      /* 柔和米金 */
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, .5));
  font-size: 17px;                     /* 调小防重叠（2026-08-18 主人要求） */
  font-weight: 600;
  letter-spacing: 3px;
  line-height: 1;
}
/* 标题下方细线装饰（高级感；2026-08-18 主人要求） */
.art-title.toolbar-title::after {
  content: '';
  display: block;
  height: 1px;
  margin-top: 6px;
  width: 100%;
  border-radius: 1px;
  background: linear-gradient(90deg, transparent, rgba(212, 175, 105, .9), transparent);
}
.toolbar-hint { margin-left: auto; } /* 右侧提示靠右 */
.dept-bar {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 2px 0 12px;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.dept-bar::-webkit-scrollbar { display: none; }
.dept-chip {
  flex: 0 0 auto;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--txt);
  border-radius: 999px;
  padding: 8px 15px;
  font-size: 13px;
  cursor: pointer;
  white-space: nowrap;
  transition: all .18s;
}
.dept-chip:hover { border-color: var(--primary); }
.dept-chip.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
  font-weight: 600;
}
.dept-chip.add { border-style: dashed; }

/* ---------- 数据报表平台标签页（2026-08-13 各平台数据隔离显示） ---------- */
.rp-tabs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 2px 0 12px;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.rp-tabs::-webkit-scrollbar { display: none; }
.rp-tab {
  flex: 0 0 auto;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--txt);
  border-radius: 999px;
  padding: 8px 15px;
  font-size: 13px;
  cursor: pointer;
  white-space: nowrap;
  transition: all .18s;
}
.rp-tab:hover { border-color: var(--primary); }
.rp-tab.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
  font-weight: 600;
}
.rp-tab.has-data::after {
  content: '';
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #22c55e;
  margin-left: 6px;
  vertical-align: 2px;
}

/* ---------- 5 格统计 ---------- */
.summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(64px, 1fr));
  gap: 8px;
  margin-bottom: 14px;
}
.stat {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 10px 6px;
  text-align: center;
  transition: transform .15s, border-color .2s;
}
.stat:hover { border-color: var(--primary); transform: translateY(-1px); }
.stat b {
  display: block;
  font-size: 22px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  line-height: 1.3;
}
.stat span { font-size: 11.5px; color: var(--muted); }

.today-stats {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 14px;
  line-height: 1.7;
}
.today-stats.hidden { display: none; }

/* ---------- 工具栏 ---------- */
.toolbar {
  position: relative;   /* 标题绝对定位的参照（2026-08-18） */
  display: flex;
  align-items: center;
  min-height: 48px;     /* 容纳标题+细线，防止与上下模块重叠 */
  padding: 12px 0 16px;
  margin-bottom: 14px;
}
/* 「＋ 添加员工卡」：内容自适应 + 桌面保底 22.22%
   2026-08-18 修复：固定 22.22% 在窄屏（<520px）装不下文字导致字体溢出按钮；改内容自适应，窄屏再缩小字号 */
#add-emp-btn {
  flex: 0 0 auto;
  width: auto;
  min-width: 22.22%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis; /* 极端窄屏兜底不出界 */
}
.toolbar-hint { font-size: 12px; color: var(--muted); }

/* ---------- 座位网格（自适应列数：屏幕够宽自动多排；主人要求 2026-08-10） ---------- */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 10px;
}

.seat {
  position: relative;
  background: var(--dark);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 13px 11px;
  min-height: 92px;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
  color: #fff;
  cursor: pointer;
  text-align: left;
  transition: transform .12s, box-shadow .2s, border-color .2s;
  overflow: hidden;
}
.seat:hover { transform: translateY(-2px); box-shadow: var(--shadow); border-color: rgba(255, 255, 255, .25); }
.seat:active { transform: scale(.97); }

.s-name {
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.s-status {
  padding-right: 46px; /* 右下角头像避让（2026-08-18） */
  font-size: 12px;
  opacity: .92;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
/* TG 头像（员工卡右下角；2026-08-18） */
.s-avatar {
  position: absolute;
  right: 6px;
  bottom: 6px;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid rgba(255, 255, 255, .25);
  background: var(--dark);
  z-index: 2;
  pointer-events: none;
}
.s-avatar-ph {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  line-height: 1;
  color: #fff;
  opacity: .85;
}
.s-timer {
  font-size: 13px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: .5px;
}
/* 屏幕共享/直播连接徽章：深色半透明底 + 亮色图标 + 光晕，任何座位底色上都清晰（2026-08-12） */
.s-conn { display: inline-flex; gap: 4px; margin-left: 5px; vertical-align: middle; }
.conn-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 7px;
  background: rgba(15, 23, 42, .55);
  flex: none;
}
.conn-badge svg { width: 15px; height: 15px; display: block; }
.conn-stream { color: #60a5fa; box-shadow: 0 0 8px rgba(59, 130, 246, .5); }
.conn-video { color: #c084fc; box-shadow: 0 0 8px rgba(168, 85, 247, .5); animation: connpulse 2.2s ease-in-out infinite; }
@keyframes connpulse {
  50% { box-shadow: 0 0 14px rgba(168, 85, 247, .85); }
}
.s-dept {
  font-size: 11px;
  opacity: .85;
  padding: 2px 6px;
  border-radius: 6px;
  background: rgba(0, 0, 0, .22);
  align-self: flex-start;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.s-wt-onsite, .s-wt-remote {
  /* 工作类型角标：固定在员工卡右上角（主人要求 2026-08-09） */
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 1;
  white-space: nowrap;
}
.s-wt-onsite { background: rgba(245, 158, 11, .25); color: #fbbf24; }
.s-wt-remote { background: rgba(59, 130, 246, .25); color: #93c5fd; }

.seat.flash { animation: flashpulse .8s ease; }
@keyframes flashpulse {
  0% { filter: brightness(2.4); transform: scale(1.06); }
  100% { filter: brightness(1); transform: scale(1); }
}

.seat-work { background: var(--work); }
.seat-stream { background: var(--stream); }
.seat-live { background: var(--live); }
.seat-smoke { background: var(--smoke); }
.seat-toilet { background: var(--toilet); }
.seat-early { background: #f97316; color: #fff; } /* 早退/待确认/结算异常警示橙（区别于活动粉；2026-08-11） */
.seat-meal { background: var(--meal); }
.seat-dark { background: var(--dark); color: var(--muted); }
.seat-idle { background: var(--idle); }
.seat-leave { background: #3b82f6; } /* 请假/休息蓝（2026-08-12 主人要求换色） */
.seat-abnormal { background: var(--abnormal); animation: blink 1s step-end infinite; }
@keyframes blink { 50% { opacity: .4; } }

/* ---------- 按钮 ---------- */
.btn {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 10px 15px;
  font-size: 14px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  background: var(--card);
  color: var(--txt);
  transition: all .16s;
  white-space: nowrap;
}
.btn:hover { border-color: var(--primary); color: var(--primary-hover); }
.btn:active { transform: scale(.97); }
.btn:focus-visible, .tab:focus-visible, .seat:focus-visible,
.dept-chip:focus-visible, input:focus-visible, select:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}
.btn.primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn.primary:hover { background: var(--primary-hover); color: #fff; }
.btn.danger { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn.danger:hover { background: #dc2626; color: #fff; }
.btn.ghost { background: transparent; }
.btn.mini { padding: 5px 9px; font-size: 12px; border-radius: 8px; }

/* ---------- 表单 ---------- */
.form-row {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  flex-wrap: wrap;
  margin-bottom: 10px;
}
.form-row label {
  display: flex;
  flex-direction: column;
  font-size: 12px;
  color: var(--muted);
  gap: 5px;
  flex: 1;
  min-width: 90px;
}
.form-row label > input, .form-row label > select, .form-row label > textarea { width: 100%; }

textarea {
  background: var(--bg-soft);
  border: 1px solid var(--line);
  color: var(--txt);
  border-radius: 9px;
  padding: 9px 10px;
  font-size: 14px;
  font-family: inherit;
  min-width: 0;
  width: 100%;
  resize: vertical;
}
textarea:focus { outline: none; border-color: var(--accent); }

input[type=text], input[type=time], input[type=date], select {
  background: var(--bg-soft);
  border: 1px solid var(--line);
  color: var(--txt);
  border-radius: 9px;
  padding: 9px 10px;
  font-size: 14px;
  font-family: inherit;
  min-width: 0;
  transition: border-color .15s;
}
input[type=text]:focus, input[type=time]:focus, input[type=date]:focus, select:focus {
  border-color: var(--primary);
  outline: none;
}
select { width: 100%; }

.time-pair { display: flex; gap: 4px; width: 100%; }
.time-pair input[type=time] { flex: 1; min-width: 0; width: 100%; }

/* 员工卡表单：4 列网格（主人要求 2026-08-07） */
.emp-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-bottom: 12px;
}
.emp-grid label {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 12px;
  color: var(--muted);
  min-width: 0;
}
.emp-grid label > input, .emp-grid label > select { width: 100%; }
.emp-grid .span-2 { grid-column: span 2; }
.emp-grid .check-row {
  flex-direction: row !important;
  align-items: center !important;
  gap: 6px !important;
  padding-top: 20px;
}
.emp-grid .check-row input { width: auto; }
@media (max-width: 520px) {
  .emp-grid { grid-template-columns: repeat(2, 1fr); }
  .emp-grid .span-2 { grid-column: span 2; }
}

.check-row {
  flex-direction: row !important;
  align-items: center !important;
  gap: 6px !important;
  padding-top: 20px;
  min-width: 90px;
}
.check-row input { width: auto; }

/* ---------- 模态框 ---------- */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(2, 6, 23, .72);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  padding: calc(env(safe-area-inset-top, 0px) + 16px) 16px calc(env(safe-area-inset-bottom, 0px) + 16px);
  animation: fadeIn .18s ease;
}
.modal.hidden { display: none; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.modal-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 20px;
  width: 100%;
  max-width: 380px;
  max-width: min(380px, calc(100vw - 24px)); /* 兜底：极端窄屏不超屏（2026-08-18） */
  max-height: 88vh;
  overflow-y: auto;
  box-shadow: var(--shadow);
  animation: popIn .2s ease;
}
@keyframes popIn { from { opacity: 0; transform: scale(.94) translateY(8px); } to { opacity: 1; transform: scale(1) translateY(0); } }
.modal-card.error { border-color: var(--danger); }
.modal-card.danger { border-color: var(--danger); }
.modal-card.wide { max-width: min(500px, calc(100vw - 24px)); } /* 兜底不超屏（2026-08-18） */
.modal-title { font-size: 17px; font-weight: 700; margin-bottom: 10px; display: flex; align-items: center; gap: 6px; }
.modal-text { font-size: 13.5px; color: var(--muted); margin-bottom: 14px; line-height: 1.7; }

/* 弹窗头部：标题+状态 左，关闭按钮右上角（主人要求 2026-08-10） */
.modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 6px;
}
.modal-header .modal-title { margin-bottom: 4px; }
.modal-header .emp-status { margin-bottom: 0; }
.modal-close {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 50%;
  background: var(--bg-soft);
  color: var(--muted);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .15s, color .15s;
}
.modal-close:hover { background: var(--line); color: var(--txt); }

/* 群组管理：勾选 + 踢出按钮 分行两端（主人要求 2026-08-10） */
.kick-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 2px;
}
.kick-checks { display: flex; gap: 14px; }

/* 危险操作区：红框警示（主人要求 2026-08-10） */
.danger-zone {
  border: 1px solid rgba(198, 40, 40, .35);
  background: rgba(198, 40, 40, .05);
  border-radius: var(--radius-sm);
  padding: 12px 12px 14px;
}
.danger-zone .modal-section-title { color: var(--danger); margin-bottom: 10px; }
.btn.wide { width: 100%; }

.emp-info {
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 11px 13px;
  margin-bottom: 12px;
  font-size: 12.5px;
  color: var(--muted);
  line-height: 1.9;
  word-break: break-all;
}

.modal-section {
  border-top: 1px solid var(--line);
  padding-top: 12px;
  margin-top: 12px;
}
.modal-section-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 5px;
}
.emp-status { font-size: 14px; font-weight: 600; color: var(--txt); margin-bottom: 10px; }
.emp-groups { margin-bottom: 8px; font-size: 12.5px; }
.form-row label.chk {
  flex-direction: row;
  align-items: center;
  gap: 6px;
  min-width: auto;
  font-size: 13px;
  color: var(--txt);
}
.form-row label.chk input { width: auto; }
.modal-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 14px;
}
.modal-actions .spacer { flex: 1; }

.dept-list { max-height: 46vh; overflow-y: auto; margin-bottom: 12px; scrollbar-width: thin; }

.dept-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 12px;
  margin-bottom: 8px;
  transition: border-color .15s;
}
.dept-item:hover { border-color: var(--primary); }
.dept-item.inactive { opacity: .55; }
.dept-item-name { font-size: 14.5px; font-weight: 600; margin-bottom: 4px; }
.dept-item-meta { font-size: 12px; color: var(--muted); line-height: 1.7; word-break: break-all; }
.dept-item-ops { display: flex; flex-direction: column; gap: 6px; flex: 0 0 auto; }
.dept-empty {
  text-align: center;
  color: var(--muted);
  font-size: 13px;
  padding: 24px 0;
}

/* ---------- 考勤表 / 数据报表 ---------- */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 12px;
}
.tool-card .att-filters { margin-bottom: 12px; }
/* 时间筛选折叠（默认收起，主人要求 2026-08-07） */
.filter-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  color: var(--muted);
  cursor: pointer;
  user-select: none;
  padding: 4px 6px;
  margin-bottom: 10px;
  border: none;
  background: none;
  border-radius: 8px;
  transition: color .15s, background .15s;
}
.filter-toggle:hover { color: var(--txt); background: var(--bg-soft); }
.ft-arrow { display: inline-block; transition: transform .2s; }
.filter-toggle.open .ft-arrow { transform: rotate(90deg); }
.att-filters.collapsed { display: none; }
.att-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  border-top: 1px dashed var(--line);
  padding-top: 12px;
}
.att-actions .toolbar-hint {
  flex: 1 1 100%;
  text-align: left;
  line-height: 1.6;
}
@media (min-width: 760px) {
  .att-actions .toolbar-hint { flex: 1 1 auto; text-align: right; }
}

.att-filters {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  flex-wrap: wrap;
}
.att-filters label {
  display: flex;
  flex-direction: column;
  font-size: 12px;
  color: var(--muted);
  gap: 5px;
  flex: 1;
  min-width: 120px;
}
.att-filters label > input, .att-filters label > select { width: 100%; }
.att-filters select { min-width: 130px; }
.att-filters .btn { flex: 0 0 auto; }

.att-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--card);
  margin-bottom: 12px;
  -webkit-overflow-scrolling: touch;
}
.att-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
  min-width: 620px;
}
.att-table th {
  background: #1e3a5f;
  color: #fff;
  padding: 10px 9px;
  text-align: center;
  position: sticky;
  top: 0;
  z-index: 2;
  white-space: nowrap;
  font-weight: 600;
}
.att-table td {
  padding: 9px 8px;
  text-align: center;
  border-top: 1px solid var(--line);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.att-table tbody tr { transition: background .12s; }
.att-table tbody tr:hover { background: rgba(37, 99, 235, .12); }
.att-table tbody tr:nth-child(even) { background: rgba(30, 58, 95, .25); }
.att-table tbody tr:nth-child(even):hover { background: rgba(37, 99, 235, .16); }
/* 底部合计行：跟随深浅主题，与表格协调（主人要求 2026-08-08） */
.att-table tfoot td {
  background: var(--card-hover);
  border-top: 2px solid var(--line);
  font-weight: 700;
  font-size: 12.5px;
  padding: 10px 8px;
}
/* 休息安排弹窗 */
.rest-emp-list {
  max-height: 180px;
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px 12px;
  margin-bottom: 8px;
}
.rest-emp-item { font-size: 13px; display: flex; align-items: center; gap: 6px; }
.rest-existing { margin-top: 12px; border-top: 1px solid var(--line); padding-top: 8px; }
.rest-existing-title { font-size: 13px; font-weight: 600; color: var(--muted); margin-bottom: 6px; }
.rest-item { font-size: 13px; display: flex; justify-content: space-between; align-items: center; padding: 4px 0; border-bottom: 1px dashed var(--line); gap: 8px; }
.rest-empty { font-size: 13px; color: var(--muted); padding: 6px 0; }

.st-ok { color: var(--ok); font-weight: 600; }
.st-warn { color: var(--danger); font-weight: 600; }
.st-pending { color: var(--muted); }
.st-noshow { color: var(--warn); font-weight: 600; }

.att-admin td { opacity: .75; }
.att-admin td:nth-child(3)::after { content: " 👑"; }

.report-head {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-size: 14.5px;
  font-weight: 700;
  color: #93c5fd;
  margin-bottom: 10px;
  text-align: center;
  letter-spacing: .2px;
}

.att-highlight td { background: rgba(37, 99, 235, .45) !important; animation: flashpulse 1.2s ease 2; }

/* ---------- 滚动条 ---------- */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: var(--line); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--muted); }
::-webkit-scrollbar-track { background: transparent; }

/* ---------- 窄屏（手机） ---------- */
@media (max-width: 520px) {
  body { padding: calc(env(safe-area-inset-top, 0px) + 10px) 10px calc(env(safe-area-inset-bottom, 0px) + 14px); }
  h1 { font-size: 17px; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 8px; }
  .seat { min-height: 84px; padding: 11px 9px; }
  .stat b { font-size: 19px; }
  .att-filters label { min-width: 100px; }
  .att-filters select { min-width: 110px; }
  .btn { padding: 9px 12px; font-size: 13.5px; }
  /* 窄屏：按钮字号/内边距收窄，避免与居中标题重叠（2026-08-18 修复） */
  #add-emp-btn { font-size: clamp(12px, 3.4vw, 13.5px); padding: 9px 8px; }
  .art-title.toolbar-title { font-size: 16px; letter-spacing: 2px; }
  .modal-card { padding: 16px; }
  .dept-item { flex-direction: column; align-items: stretch; }
  .dept-item-ops { flex-direction: row; }
  .att-actions .toolbar-hint { flex: 1 1 100%; }
  .att-actions .btn { flex: 1 1 auto; }
}

/* ---------- 鉴权遮罩：验证通过前不显示任何系统 UI（主人要求 2026-08-08） ---------- */
body.no-auth header,
body.no-auth nav.tabs,
body.no-auth section.view,
body.no-auth #dept-bar,
body.no-auth .summary,
body.no-auth .report-head,
body.no-auth .modal,
body.no-auth footer { display: none !important; }

#unauth {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg, #0f172a);
  z-index: 9999;
  padding: 20px;
}
#unauth .unauth-card {
  max-width: 340px; width: 100%;
  background: var(--card, #1e293b);
  border: 1px solid var(--line, #334155);
  border-radius: 14px;
  padding: 28px 22px;
  text-align: center;
}
#unauth .unauth-title { font-size: 17px; font-weight: 700; margin-bottom: 10px; color: var(--txt, #e2e8f0); }
#unauth .unauth-text { font-size: 13.5px; color: var(--muted, #94a3b8); line-height: 1.6; }
#unauth .btn { margin-top: 16px; }

/* 修复：鉴权成功后面板必须能隐藏（ID 优先级高于 .hidden，需显式覆盖——主人反馈 2026-08-08） */
#unauth.hidden { display: none !important; }
/* 通用隐藏（按钮等任意元素；2026-08-10 补：此前只有 .view/.modal/.today-stats 专属规则，按钮隐藏不生效） */
.hidden { display: none !important; }

/* ===== 代理账号管理（2026-08-11）：表单 + 表格 ===== */
.agent-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 170px 180px auto;
  gap: 10px;
  align-items: end;
  padding: 14px;
  margin-bottom: 12px;
  background: var(--bg-soft, rgba(127, 127, 127, .06));
  border: 1px solid var(--line, rgba(127, 127, 127, .14));
  border-radius: 12px;
}
.agent-form-field { display: flex; flex-direction: column; gap: 6px; }
.agent-form-field.grow { grid-column: span 1; }
.agent-form-field label {
  font-size: 12px;
  color: var(--muted);
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 6px;
  flex-wrap: wrap; /* 修复：长提示换行不撑破（2026-08-18） */
}
.agent-form-field label .hint { font-size: 11px; opacity: .75; white-space: normal; min-width: 0; } /* 修复：长提示换行不撑破表单（2026-08-18） */
.agent-form-field input,
.agent-form-field select,
.agent-form-field textarea { width: 100%; }
.agent-form > .btn { height: 38px; padding: 0 18px; white-space: nowrap; }
.agent-table-wrap {
  max-height: 44vh;
  overflow-x: auto; /* 修复：窄屏表格横向滑动，不再撑破弹窗（2026-08-18） */
  overflow-y: auto;
  border: 1px solid var(--line, rgba(127, 127, 127, .14));
  border-radius: 12px;
  margin-bottom: 4px;
}
.agent-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.agent-table thead th {
  position: sticky; top: 0; z-index: 1;
  text-align: left;
  padding: 10px 12px;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  background: var(--bg-soft, rgba(127, 127, 127, .08));
  border-bottom: 1px solid var(--line, rgba(127, 127, 127, .16));
  letter-spacing: .02em;
}
.agent-table tbody td {
  padding: 9px 12px;
  border-bottom: 1px solid var(--line, rgba(127, 127, 127, .08));
  vertical-align: middle;
}
.agent-table tbody tr:last-child td { border-bottom: none; }
.agent-table tbody tr { transition: background .12s ease; }
.agent-table tbody tr:hover { background: rgba(99, 102, 241, .05); }
.agent-table td.agent-name { font-weight: 600; font-variant-numeric: tabular-nums; }
.agent-table td.ops { text-align: right; white-space: nowrap; width: 110px; }
.agent-table td.empty { text-align: center; color: var(--muted); padding: 28px 12px; }
.agent-table .hire-val {
  font-variant-numeric: tabular-nums;
  color: var(--primary, #6366f1);
  font-weight: 500;
}
.agent-table .muted { color: var(--muted); opacity: .6; }
.agent-table .hire-edit { width: 140px; padding: 5px 8px; font-size: 13px; }
@media (max-width: 760px) {
  .agent-form { grid-template-columns: minmax(0, 1fr); } /* minmax(0) 允许压缩，防长内容撑破（2026-08-18） */
}

/* ===== 统计图表（2026-08-12） ===== */
.chart-panel { margin: 4px 0 10px; }
.chart-panel.collapsed { display: none; }
.chart-bar { display: flex; gap: 6px; align-items: center; margin: 4px 0 8px; flex-wrap: wrap; }
.chart-bar select { padding: 4px 6px; border-radius: 6px; border: 1px solid var(--line, rgba(127,127,127,.25)); background: var(--bg-soft, #fff); font-size: 12px; max-width: 130px; }
.chart-bar select { padding: 6px 8px; border-radius: 8px; border: 1px solid var(--line, rgba(127,127,127,.25)); background: var(--bg-soft, #fff); font-size: 13px; }
.chart-wrap { background: var(--bg-soft, rgba(127,127,127,.04)); border: 1px solid var(--line, rgba(127,127,127,.14)); border-radius: 12px; padding: 12px 8px 6px; margin-bottom: 12px; }
.chart-title { text-align: center; font-size: 13px; font-weight: 600; color: var(--muted, #666); margin-bottom: 8px; }
.chart-loading { text-align: center; color: var(--muted, #888); padding: 30px 0; font-size: 13px; }
.chart-legend { display: flex; flex-wrap: wrap; gap: 6px 14px; justify-content: center; margin-bottom: 6px; font-size: 12px; }
.chart-legend-item { display: inline-flex; align-items: center; gap: 5px; color: #555; }
.chart-legend-item i { width: 12px; height: 3px; border-radius: 2px; display: inline-block; }
.chart-legend-item b { color: #333; font-weight: 700; margin-left: 2px; font-variant-numeric: tabular-nums; }
.chart-empty { color: var(--muted, #999); font-size: 13px; margin-left: 8px; }




/* 通用确认弹窗（2026-08-15 规整专业） */
.confirm-card { max-width: 360px; }
.confirm-msg { white-space: pre-line; margin-bottom: 18px; font-size: 14px; }
.confirm-actions { justify-content: flex-end; }
.confirm-actions .btn { min-width: 88px; justify-content: center; }
