/* ==========================================================================
   WorkPulse 人事打卡管理系統 - 核心樣式表 (完整 RWD 支援)
   ========================================================================== */

:root {
  /* 品牌色系與層次 */
  --primary-50: #eef2ff;
  --primary-100: #e0e7ff;
  --primary-500: #6366f1;
  --primary-600: #4f46e5;
  --primary-700: #4338ca;
  --primary-900: #312e81;

  /* 狀態色系 */
  --success-bg: #ecfdf5;
  --success-text: #047857;
  --success-border: #a7f3d0;
  --success-solid: #10b981;

  --danger-bg: #fef2f2;
  --danger-text: #b91c1c;
  --danger-border: #fecaca;
  --danger-solid: #ef4444;

  --warning-bg: #fffbeb;
  --warning-text: #b45309;
  --warning-border: #fde68a;
  --warning-solid: #f59e0b;

  --info-bg: #f0f9ff;
  --info-text: #0369a1;
  --info-border: #bae6fd;
  --info-solid: #0ea5e9;

  --weekend-bg: #f1f5f9;
  --weekend-text: #64748b;
  --weekend-border: #cbd5e1;

  /* 灰階與背景 */
  --bg-app: #f8fafc;
  --bg-surface: #ffffff;
  --bg-surface-elevated: #ffffff;
  --bg-sidebar: #0f172a;
  --sidebar-text: #94a3b8;
  --sidebar-text-active: #ffffff;
  --sidebar-hover: #1e293b;
  --sidebar-active-bg: #4f46e5;

  --text-main: #0f172a;
  --text-muted: #64748b;
  --text-subtle: #94a3b8;

  --border-light: #e2e8f0;
  --border-subtle: #f1f5f9;

  /* 陰影與圓角 */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --radius-full: 9999px;

  --shadow-xs: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-sm: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px -1px rgba(0, 0, 0, 0.1);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.08), 0 2px 4px -2px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -4px rgba(0, 0, 0, 0.04);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.04);

  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Noto Sans TC", "PingFang TC", sans-serif;
  --sidebar-width: 250px;
  --topbar-height: 70px;
  --bottom-nav-height: 64px;
}

/* Reset & Base */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-sans);
  background-color: var(--bg-app);
  color: var(--text-main);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  overflow-x: hidden;
}

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

button, input, select, textarea {
  font-family: inherit;
  font-size: inherit;
  touch-action: manipulation;
}

/* ==========================================================================
   登入頁面 (Auth Screen)
   ========================================================================== */
.auth-overlay {
  position: fixed;
  inset: 0;
  background: radial-gradient(circle at 80% 20%, rgba(99, 102, 241, 0.12) 0%, rgba(248, 250, 252, 1) 70%);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 16px;
  overflow-y: auto;
}

.auth-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
  width: 100%;
  max-width: 460px;
  padding: 32px 28px;
  margin: auto;
}

.auth-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 24px;
}

.brand-icon-box {
  width: 44px;
  height: 44px;
  background: linear-gradient(135deg, var(--primary-600), var(--primary-700));
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 22px;
  box-shadow: 0 4px 10px rgba(79, 70, 229, 0.3);
}

.brand-text h1 {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-main);
  letter-spacing: -0.3px;
}

.brand-text p {
  font-size: 13px;
  color: var(--text-muted);
}

.auth-header {
  margin-bottom: 24px;
}

.auth-header h2 {
  font-size: 22px;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 6px;
}

.auth-header p {
  font-size: 14px;
  color: var(--text-muted);
}

.quick-login-section {
  margin-bottom: 24px;
}

.quick-login-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-subtle);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.user-quick-list {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.quick-user-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  background: var(--bg-surface);
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: left;
}

.quick-user-btn:hover {
  border-color: var(--primary-500);
  background: var(--primary-50);
  transform: translateY(-1px);
}

.quick-user-btn.active {
  border-color: var(--primary-600);
  background: var(--primary-50);
  outline: 2px solid var(--primary-500);
}

.user-avatar-mini {
  width: 34px;
  height: 34px;
  border-radius: var(--radius-full);
  background: #cbd5e1;
  object-fit: cover;
  flex-shrink: 0;
}

.quick-user-info {
  overflow: hidden;
}

.quick-user-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-main);
  white-space: nowrap;
  text-overflow: ellipsis;
  overflow: hidden;
}

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

.divider {
  display: flex;
  align-items: center;
  text-align: center;
  margin: 20px 0;
  color: var(--text-subtle);
  font-size: 12px;
}

.divider::before, .divider::after {
  content: '';
  flex: 1;
  border-bottom: 1px solid var(--border-light);
}

.divider span {
  padding: 0 10px;
}

.form-group {
  margin-bottom: 16px;
}

.form-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-main);
  margin-bottom: 6px;
}

.form-input {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  background: var(--bg-surface);
  color: var(--text-main);
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.form-input:focus {
  border-color: var(--primary-600);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

.btn-primary {
  width: 100%;
  padding: 12px 18px;
  background: var(--primary-600);
  color: white;
  border: none;
  border-radius: var(--radius-md);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.btn-primary:hover {
  background: var(--primary-700);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(79, 70, 229, 0.25);
}

/* ==========================================================================
   系統主容器 (App Shell)
   ========================================================================== */
.app-container {
  display: flex;
  min-height: 100vh;
}

/* 手機版遮罩 */
.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(4px);
  z-index: 90;
}

/* 側邊欄 (Sidebar) */
.sidebar {
  width: var(--sidebar-width);
  background-color: var(--bg-sidebar);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: 100;
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar-header {
  height: var(--topbar-height);
  padding: 0 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.btn-close-sidebar {
  display: none;
  background: transparent;
  border: none;
  color: #94a3b8;
  font-size: 20px;
  cursor: pointer;
  padding: 4px;
}

.sidebar-brand-icon {
  width: 36px;
  height: 36px;
  background: linear-gradient(135deg, #6366f1, #4f46e5);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 18px;
}

.sidebar-brand-title {
  font-size: 16px;
  font-weight: 700;
  color: #ffffff;
  letter-spacing: -0.2px;
}

.sidebar-nav {
  padding: 20px 12px;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
  overflow-y: auto;
}

.nav-section-title {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: #64748b;
  padding: 8px 12px 4px 12px;
  font-weight: 700;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: var(--radius-md);
  color: var(--sidebar-text);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  border: none;
  background: transparent;
  width: 100%;
  text-align: left;
}

.nav-item:hover {
  background: var(--sidebar-hover);
  color: var(--sidebar-text-active);
}

.nav-item.active {
  background: var(--sidebar-active-bg);
  color: var(--sidebar-text-active);
  font-weight: 600;
  box-shadow: 0 4px 12px rgba(79, 70, 229, 0.35);
}

.nav-icon {
  font-size: 18px;
  width: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.sidebar-footer {
  padding: 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.sidebar-user-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.04);
  cursor: pointer;
  transition: background 0.2s;
}

.sidebar-user-card:hover {
  background: rgba(255, 255, 255, 0.08);
}

.sidebar-user-info {
  flex: 1;
  overflow: hidden;
}

.sidebar-user-name {
  font-size: 13px;
  font-weight: 600;
  color: white;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-user-role {
  font-size: 11px;
  color: #94a3b8;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ==========================================================================
   主內容區 (Main Content Layout)
   ========================================================================== */
.main-wrapper {
  flex: 1;
  margin-left: var(--sidebar-width);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  width: calc(100% - var(--sidebar-width));
}

/* 頂部導航列 (Top Bar) */
.topbar {
  height: var(--topbar-height);
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-light);
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 40;
  backdrop-filter: blur(8px);
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.btn-mobile-menu {
  display: none;
  background: transparent;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  font-size: 18px;
  color: var(--text-main);
  cursor: pointer;
}

.topbar-page-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar-realtime-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: var(--primary-50);
  border: 1px solid var(--primary-100);
  color: var(--primary-700);
  border-radius: var(--radius-full);
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
}

.live-dot {
  width: 8px;
  height: 8px;
  background-color: var(--success-solid);
  border-radius: 50%;
  animation: pulse-dot 2s infinite ease-in-out;
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.85); }
}

/* 右上角 Logo 與同仁切換區 */
.topbar-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.time-simulator-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border: 1px dashed var(--primary-500);
  border-radius: var(--radius-full);
  background: #fdf4ff;
  color: #a855f7;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

.topbar-company-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-right: 14px;
  border-right: 1px solid var(--border-light);
}

.logo-symbol {
  width: 32px;
  height: 32px;
  background: linear-gradient(135deg, #10b981, #059669);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 800;
  font-size: 15px;
  box-shadow: 0 2px 6px rgba(16, 185, 129, 0.25);
  flex-shrink: 0;
}

.logo-text {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-main);
  letter-spacing: -0.2px;
}

.logo-sub {
  font-size: 10px;
  color: var(--text-muted);
  font-weight: 500;
  line-height: 1;
}

.user-profile-menu {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: var(--radius-md);
  transition: background 0.2s;
}

.user-profile-menu:hover {
  background: var(--bg-app);
}

.user-profile-meta {
  text-align: right;
}

.user-profile-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-main);
  line-height: 1.2;
}

.user-profile-dept {
  font-size: 11px;
  color: var(--text-muted);
}

.btn-logout {
  padding: 6px 10px;
  border: 1px solid var(--border-light);
  background: white;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 12px;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
}

.btn-logout:hover {
  background: var(--danger-bg);
  border-color: var(--danger-border);
  color: var(--danger-text);
}

/* 主內容區域 */
.content-area {
  flex: 1;
  padding: 24px;
  max-width: 1400px;
  width: 100%;
  margin: 0 auto;
}

/* ==========================================================================
   通用卡片與狀態徽章 (Cards & Badges)
   ========================================================================== */
.card {
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: 24px;
  margin-bottom: 24px;
  transition: box-shadow 0.2s;
}

.card:hover {
  box-shadow: var(--shadow-md);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 10px;
}

.card-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 8px;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  font-size: 12px;
  font-weight: 600;
  line-height: 1.2;
  white-space: nowrap;
}

.badge-success { background: var(--success-bg); color: var(--success-text); border: 1px solid var(--success-border); }
.badge-danger { background: var(--danger-bg); color: var(--danger-text); border: 1px solid var(--danger-border); }
.badge-warning { background: var(--warning-bg); color: var(--warning-text); border: 1px solid var(--warning-border); }
.badge-info { background: var(--info-bg); color: var(--info-text); border: 1px solid var(--info-border); }
.badge-primary { background: var(--primary-50); color: var(--primary-700); border: 1px solid var(--primary-100); }
.badge-missing { background: #f1f5f9; color: #64748b; border: 1px solid #e2e8f0; }
.badge-weekend { background: #f8fafc; color: #94a3b8; border: 1px solid #e2e8f0; }
.badge-early { background: #eff6ff; color: #1d4ed8; border: 1px solid #bfdbfe; }

/* ==========================================================================
   VIEW 1: 首頁 (Dashboard / 出缺勤總覽)
   ========================================================================== */
.welcome-banner {
  background: linear-gradient(135deg, #1e1b4b 0%, #312e81 60%, #4338ca 100%);
  color: white;
  border-radius: var(--radius-xl);
  padding: 28px 32px;
  margin-bottom: 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: relative;
  overflow: hidden;
  box-shadow: 0 10px 25px -5px rgba(49, 46, 129, 0.4);
  gap: 20px;
}

.welcome-banner::after {
  content: '';
  position: absolute;
  right: -30px;
  top: -50px;
  width: 220px;
  height: 220px;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.12) 0%, rgba(255, 255, 255, 0) 70%);
  border-radius: 50%;
  pointer-events: none;
}

.welcome-info h2 {
  font-size: 24px;
  font-weight: 700;
  margin-bottom: 6px;
}

.welcome-info p {
  color: #c7d2fe;
  font-size: 14px;
  max-width: 650px;
}

.welcome-actions {
  flex-shrink: 0;
}

.btn-banner-action {
  background: #ffffff;
  color: #4338ca;
  padding: 12px 24px;
  border-radius: var(--radius-md);
  font-weight: 700;
  font-size: 15px;
  border: none;
  cursor: pointer;
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.btn-banner-action:hover {
  background: #f8fafc;
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.2);
}

/* KPI 統計數據卡片網格 */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 20px;
  margin-bottom: 24px;
}

.kpi-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: 20px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
}

.kpi-card::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 4px;
  background: var(--kpi-color, var(--primary-500));
}

.kpi-content {
  display: flex;
  flex-direction: column;
}

.kpi-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.kpi-value {
  font-size: 24px;
  font-weight: 800;
  color: var(--text-main);
  letter-spacing: -0.5px;
}

.kpi-sub {
  font-size: 12px;
  color: var(--text-subtle);
  margin-top: 4px;
}

.kpi-icon-box {
  width: 42px;
  height: 42px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  background: var(--kpi-bg, var(--primary-50));
  color: var(--kpi-color, var(--primary-600));
  flex-shrink: 0;
}

/* 今日個人打卡摘要區塊 */
.today-summary-grid {
  display: grid;
  grid-template-columns: 1.2fr 2fr;
  gap: 24px;
  margin-bottom: 24px;
}

.punch-status-card {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.punch-slots {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin: 16px 0;
}

.punch-slot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-radius: var(--radius-md);
  background: var(--bg-app);
  border: 1px solid var(--border-light);
  gap: 10px;
}

.slot-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.slot-icon {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  background: var(--primary-100);
  color: var(--primary-700);
  flex-shrink: 0;
}

.slot-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-main);
}

.slot-rule {
  font-size: 12px;
  color: var(--text-muted);
}

.slot-time {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-main);
  text-align: right;
}

.dash-card-footer {
  margin-top: auto;
  padding-top: 14px;
  border-top: 1px solid var(--border-light);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

/* 歷史出勤記錄表格 (最近 7 天) */
.table-container {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
}

.records-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  text-align: left;
  min-width: 600px;
}

.records-table th {
  background: var(--bg-app);
  padding: 12px 16px;
  font-weight: 600;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border-light);
  white-space: nowrap;
}

.records-table td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-main);
  vertical-align: middle;
}

.records-table tr:last-child td {
  border-bottom: none;
}

.records-table tr:hover td {
  background-color: #f8fafc;
}

.user-cell {
  display: flex;
  align-items: center;
  gap: 10px;
}

.user-cell-name {
  font-weight: 600;
  color: var(--text-main);
}

.user-cell-dept {
  font-size: 11px;
  color: var(--text-muted);
}

/* ==========================================================================
   VIEW 2: 我要打卡 (Clock In / Out Page)
   ========================================================================== */
.clockin-container {
  max-width: 860px;
  margin: 0 auto;
}

.clock-hero-card {
  text-align: center;
  padding: 36px 20px;
  background: radial-gradient(circle at 50% 0%, #1e1b4b 0%, #0f172a 100%);
  color: white;
  border-radius: var(--radius-xl);
  box-shadow: 0 16px 32px -8px rgba(15, 23, 42, 0.35);
  margin-bottom: 24px;
}

.clock-date-display {
  font-size: 15px;
  color: #94a3b8;
  font-weight: 500;
  margin-bottom: 6px;
}

.clock-digital {
  font-size: clamp(36px, 9vw, 58px);
  font-weight: 800;
  letter-spacing: 2px;
  font-variant-numeric: tabular-nums;
  color: #ffffff;
  text-shadow: 0 2px 10px rgba(99, 102, 241, 0.4);
  margin: 6px 0;
}

.clock-status-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  border-radius: var(--radius-full);
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.2);
  font-size: 13px;
  font-weight: 600;
  color: #e0e7ff;
  margin-top: 10px;
  max-width: 100%;
}

.rule-info-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 20px;
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: 14px 20px;
  margin-bottom: 24px;
  font-size: 13px;
  flex-wrap: wrap;
}

.rule-item {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-muted);
}

.rule-item strong {
  color: var(--text-main);
}

.rule-divider {
  color: var(--border-light);
}

/* 上下班打卡雙卡片 */
.punch-action-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  margin-bottom: 24px;
}

.punch-card {
  background: var(--bg-surface);
  border: 2px solid var(--border-light);
  border-radius: var(--radius-xl);
  padding: 28px 20px;
  text-align: center;
  transition: all 0.25s ease;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.punch-card.active-window {
  border-color: var(--primary-500);
  background: linear-gradient(180deg, #ffffff 0%, #fdfcff 100%);
  box-shadow: 0 8px 24px -4px rgba(99, 102, 241, 0.15);
}

.punch-card-header {
  margin-bottom: 16px;
}

.punch-type-badge {
  display: inline-block;
  padding: 4px 12px;
  border-radius: var(--radius-full);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
}

.punch-card-in .punch-type-badge { background: var(--primary-100); color: var(--primary-700); }
.punch-card-out .punch-type-badge { background: #fef3c7; color: #b45309; }

.punch-card-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-main);
}

.punch-window-text {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 4px;
}

.punch-button {
  width: 140px;
  height: 140px;
  border-radius: 50%;
  margin: 16px auto;
  border: none;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-size: 16px;
  font-weight: 700;
  color: white;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.punch-btn-in {
  background: linear-gradient(135deg, #6366f1 0%, #4f46e5 100%);
  box-shadow: 0 10px 25px -5px rgba(79, 70, 229, 0.45);
}

.punch-btn-in:hover {
  transform: scale(1.05);
  box-shadow: 0 14px 30px -4px rgba(79, 70, 229, 0.55);
}

.punch-btn-out {
  background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
  box-shadow: 0 10px 25px -5px rgba(245, 158, 11, 0.45);
}

.punch-btn-out:hover {
  transform: scale(1.05);
  box-shadow: 0 14px 30px -4px rgba(245, 158, 11, 0.55);
}

.punch-button:active {
  transform: scale(0.96);
}

.punch-btn-icon {
  font-size: 28px;
}

.punch-card-result {
  margin-top: 16px;
  padding: 12px;
  border-radius: var(--radius-md);
  background: var(--bg-app);
  font-size: 13px;
  min-height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
}

/* 打卡附加設定 (地點、備註) */
.punch-extras-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: 20px;
}

.extras-grid {
  display: grid;
  grid-template-columns: 1fr 1.5fr;
  gap: 16px;
}

/* ==========================================================================
   VIEW 3: 打卡紀錄 (Attendance Records & Calendar View)
   ========================================================================== */
.records-view-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 16px;
}

.tab-pills {
  display: inline-flex;
  background: var(--border-light);
  padding: 4px;
  border-radius: var(--radius-lg);
}

.tab-pill {
  padding: 8px 20px;
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 600;
  color: var(--text-muted);
  border: none;
  background: transparent;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.tab-pill.active {
  background: var(--bg-surface);
  color: var(--primary-600);
  box-shadow: var(--shadow-sm);
}

.filters-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.search-input-box {
  position: relative;
  min-width: 200px;
}

.search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-subtle);
  font-size: 14px;
}

.search-input {
  width: 100%;
  padding: 8px 12px 8px 34px;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  font-size: 13px;
  background: var(--bg-surface);
  outline: none;
}

.search-input:focus {
  border-color: var(--primary-600);
}

.filter-select {
  padding: 8px 12px;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  font-size: 13px;
  background: var(--bg-surface);
  color: var(--text-main);
  outline: none;
  cursor: pointer;
}

.records-layout-grid {
  display: grid;
  grid-template-columns: 340px 1fr;
  gap: 24px;
  align-items: start;
}

/* 互動式月曆元件 */
.calendar-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  position: sticky;
  top: calc(var(--topbar-height) + 20px);
}

.calendar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.calendar-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-main);
}

.cal-nav-btn {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-light);
  background: var(--bg-surface);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text-muted);
  transition: all 0.15s;
}

.cal-nav-btn:hover {
  background: var(--bg-app);
  color: var(--text-main);
}

.calendar-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  text-align: center;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-subtle);
  margin-bottom: 8px;
}

.calendar-days-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}

.cal-day-cell {
  aspect-ratio: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-md);
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  position: relative;
  transition: all 0.15s;
  border: 1px solid transparent;
  background: transparent;
}

.cal-day-cell:hover:not(.empty-day) {
  background: var(--primary-50);
  border-color: var(--primary-100);
}

.cal-day-cell.other-month {
  color: #cbd5e1;
  pointer-events: none;
}

.cal-day-cell.is-weekend {
  color: #94a3b8;
}

.cal-day-cell.is-today {
  font-weight: 700;
  color: var(--primary-600);
}

.cal-day-cell.is-selected {
  background: var(--primary-600) !important;
  color: white !important;
  font-weight: 700;
  box-shadow: 0 4px 10px rgba(79, 70, 229, 0.3);
}

.cal-day-dots {
  display: flex;
  gap: 2px;
  margin-top: 2px;
  height: 4px;
}

.cal-dot {
  width: 4px;
  height: 4px;
  border-radius: 50%;
}

.cal-dot.dot-success { background: var(--success-solid); }
.cal-dot.dot-danger { background: var(--danger-solid); }
.cal-dot.dot-warning { background: var(--warning-solid); }
.cal-dot.dot-info { background: var(--info-solid); }
.cal-dot.dot-weekend { background: #cbd5e1; }

.calendar-legend {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--border-light);
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  font-size: 11px;
  color: var(--text-muted);
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 5px;
}

/* 右側選取日期資訊條 */
.selected-date-banner {
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: 16px 20px;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}

.selected-date-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 8px;
}

.date-quick-nav {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.btn-sm-ghost {
  padding: 6px 12px;
  border: 1px solid var(--border-light);
  background: white;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s;
}

.btn-sm-ghost:hover {
  background: var(--bg-app);
  color: var(--text-main);
}

.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-muted);
}

.empty-state-icon {
  font-size: 40px;
  margin-bottom: 12px;
  color: var(--text-subtle);
}

.empty-state h4 {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-main);
  margin-bottom: 4px;
}

.empty-state p {
  font-size: 13px;
}

/* ==========================================================================
   時間模擬測試器 Modal (Time Simulator Debugger)
   ========================================================================== */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 16px;
  overflow-y: auto;
}

.modal-card {
  background: var(--bg-surface);
  border-radius: var(--radius-xl);
  width: 100%;
  max-width: 520px;
  padding: 24px;
  box-shadow: var(--shadow-xl);
  margin: auto;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.modal-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-close-modal {
  background: transparent;
  border: none;
  font-size: 20px;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
}

.sim-presets-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-bottom: 20px;
}

.sim-preset-btn {
  padding: 10px 12px;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  background: var(--bg-app);
  text-align: left;
  cursor: pointer;
  transition: all 0.2s;
}

.sim-preset-btn:hover {
  background: var(--primary-50);
  border-color: var(--primary-500);
}

.sim-preset-name {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-main);
}

.sim-preset-desc {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* Toast 通知提示 */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
  max-width: calc(100vw - 48px);
}

.toast {
  background: #0f172a;
  color: white;
  padding: 12px 18px;
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 500;
  box-shadow: var(--shadow-xl);
  display: flex;
  align-items: center;
  gap: 10px;
  animation: slide-in 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  pointer-events: auto;
}

.toast.toast-success { background: #065f46; border: 1px solid #059669; }
.toast.toast-error { background: #991b1b; border: 1px solid #dc2626; }

@keyframes slide-in {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ==========================================================================
   手機版底部快捷導航列 (Mobile Bottom Nav)
   ========================================================================== */
.mobile-bottom-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--bottom-nav-height);
  background: var(--bg-surface);
  border-top: 1px solid var(--border-light);
  box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.05);
  z-index: 80;
  padding: 0 8px;
}

.mobile-nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  padding: 6px 0;
  transition: color 0.2s;
}

.mobile-nav-item .mob-icon {
  font-size: 20px;
  line-height: 1;
}

.mobile-nav-item.active {
  color: var(--primary-600);
}

/* ==========================================================================
   完整 RWD 斷點樣式 (Responsive Breakpoints)
   ========================================================================== */

/* 1. 平板版 (Tablet: <= 1024px) */
@media (max-width: 1024px) {
  .records-layout-grid {
    grid-template-columns: 1fr;
  }

  .calendar-card {
    position: static;
  }

  .kpi-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .today-summary-grid {
    grid-template-columns: 1fr;
  }
}

/* 2. 手機版 (Mobile: <= 768px) */
@media (max-width: 768px) {
  body {
    padding-bottom: var(--bottom-nav-height);
  }

  /* 隱藏桌面固定側邊欄，改為抽屜 Drawer */
  .sidebar {
    transform: translateX(-100%);
    box-shadow: var(--shadow-xl);
    width: 280px;
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .sidebar-backdrop.active {
    display: block;
  }

  .btn-close-sidebar {
    display: block;
  }

  /* 主內容容器佔滿全螢幕 */
  .main-wrapper {
    margin-left: 0;
    width: 100%;
  }

  .topbar {
    padding: 0 14px;
  }

  .btn-mobile-menu {
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .topbar-company-logo {
    display: none;
  }

  .db-status-badge {
    display: none;
  }

  .user-profile-meta {
    display: none;
  }

  .content-area {
    padding: 16px;
  }

  /* 顯示手機底部導航列 */
  .mobile-bottom-nav {
    display: flex;
  }

  /* 歡迎橫幅垂直排列 */
  .welcome-banner {
    flex-direction: column;
    align-items: stretch;
    padding: 22px 20px;
    gap: 16px;
  }

  .btn-banner-action {
    width: 100%;
  }

  /* KPI 卡片 */
  .kpi-grid {
    grid-template-columns: 1fr 1fr;
    gap: 12px;
  }

  .kpi-card {
    padding: 14px;
  }

  .kpi-value {
    font-size: 20px;
  }

  .kpi-icon-box {
    width: 36px;
    height: 36px;
    font-size: 18px;
  }

  /* 打卡頁 */
  .punch-action-grid {
    grid-template-columns: 1fr;
    gap: 16px;
  }

  .punch-button {
    width: 124px;
    height: 124px;
  }

  .extras-grid {
    grid-template-columns: 1fr;
  }

  .rule-info-bar {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }

  .rule-divider {
    display: none;
  }

  /* 打卡紀錄頁 */
  .tab-pills {
    width: 100%;
  }

  .tab-pill {
    flex: 1;
  }

  .filters-bar {
    width: 100%;
  }

  .filter-select, .search-input-box {
    width: 100%;
  }

  .sim-presets-grid {
    grid-template-columns: 1fr;
  }

  .toast-container {
    bottom: calc(var(--bottom-nav-height) + 12px);
    right: 12px;
    left: 12px;
  }
}

/* 3. 超小手機 (Small Mobile: <= 480px) */
@media (max-width: 480px) {
  .kpi-grid {
    grid-template-columns: 1fr;
  }

  .topbar-realtime-badge {
    padding: 4px 8px;
    font-size: 12px;
  }

  .topbar-page-title {
    font-size: 15px;
  }

  .user-quick-list {
    grid-template-columns: 1fr;
  }
}
