:root {
  --sidebar-width: 240px;
  --sidebar-bg: #1a2332;
  --sidebar-hover: #243447;
  --sidebar-active: #2d6a4f;
  --primary: #2d6a4f;
  --primary-light: #40916c;
  --accent: #52b788;
  --topbar-h: 56px;
  --text-muted: #6c757d;
}

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

body { font-family: 'Microsoft YaHei', 'PingFang SC', sans-serif; background: #f0f2f5; color: #333; }

/* ── Wrapper ── */
.wrapper { display: flex; min-height: 100vh; }

/* ── Sidebar ── */
.sidebar {
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  color: #c8d6e5;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0;
  height: 100vh;
  z-index: 1000;
  transition: width .3s ease;
  overflow: hidden;
}

.sidebar.collapsed { width: 60px; }
.sidebar.collapsed .logo-text,
.sidebar.collapsed .menu-item span:not(.badge),
.sidebar.collapsed .menu-divider,
.sidebar.collapsed .user-detail { display: none; }
.sidebar.collapsed .menu-item a { justify-content: center; }
.sidebar.collapsed .sidebar-header { justify-content: center; padding: 16px 0; }

.sidebar-header {
  display: flex; align-items: center; gap: 12px;
  padding: 20px 16px; border-bottom: 1px solid #2c3e50;
  min-height: 64px;
}

.logo-icon { font-size: 22px; color: var(--accent); flex-shrink: 0; }
.logo-text { font-size: 15px; font-weight: 600; color: #fff; white-space: nowrap; }

.sidebar-menu { flex: 1; overflow-y: auto; padding: 8px 0; }
.sidebar-menu::-webkit-scrollbar { width: 3px; }
.sidebar-menu::-webkit-scrollbar-thumb { background: #3d5166; border-radius: 2px; }

.menu-divider {
  font-size: 11px; color: #5a7a99; text-transform: uppercase;
  padding: 12px 16px 4px; letter-spacing: .8px;
  white-space: nowrap;
}

.menu-item a {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 16px; color: #c8d6e5; text-decoration: none;
  border-radius: 6px; margin: 1px 8px;
  transition: background .2s, color .2s;
  white-space: nowrap;
}
.menu-item a i { font-size: 17px; flex-shrink: 0; width: 20px; text-align: center; }
.menu-item a:hover { background: var(--sidebar-hover); color: #fff; }
.menu-item.active a { background: var(--sidebar-active); color: #fff; }

.sidebar-footer {
  padding: 12px 16px; border-top: 1px solid #2c3e50;
}
.user-info { display: flex; align-items: center; gap: 10px; }
.user-avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--accent); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 600; font-size: 15px; flex-shrink: 0;
}
.user-name { font-size: 13px; font-weight: 600; color: #e0e8f0; }
.user-role { font-size: 11px; color: #7a9ab5; }

/* ── Main Content ── */
.main-content {
  margin-left: var(--sidebar-width);
  flex: 1;
  transition: margin-left .3s;
  display: flex; flex-direction: column;
}
.main-content.expanded { margin-left: 60px; }

/* ── Topbar ── */
.topbar {
  height: var(--topbar-h);
  background: #fff;
  box-shadow: 0 1px 4px rgba(0,0,0,.08);
  display: flex; align-items: center; gap: 16px;
  padding: 0 24px;
  position: sticky; top: 0; z-index: 100;
}
.sidebar-toggle { background: none; border: none; font-size: 20px; color: #555; cursor: pointer; padding: 4px; }
.sidebar-toggle:hover { color: var(--primary); }
.topbar-title { font-size: 16px; font-weight: 600; color: #333; flex: 1; }
.topbar-right { display: flex; gap: 8px; }
.topbar-btn { font-size: 18px; color: #666; padding: 6px; border-radius: 6px; transition: background .2s; }
.topbar-btn:hover { background: #f0f2f5; color: var(--primary); }

/* ── Page Content ── */
.page-content { padding: 24px; flex: 1; }

/* ── Cards ── */
.card { border: none; border-radius: 12px; box-shadow: 0 2px 8px rgba(0,0,0,.06); }
.card-header { background: #fff; border-bottom: 1px solid #f0f2f5; border-radius: 12px 12px 0 0 !important; padding: 16px 20px; }
.card-header h5, .card-header h6 { margin: 0; font-weight: 600; }

/* ── Stat Cards ── */
.stat-card {
  background: #fff; border-radius: 12px;
  padding: 20px; box-shadow: 0 2px 8px rgba(0,0,0,.06);
  display: flex; align-items: center; gap: 16px;
}
.stat-icon {
  width: 52px; height: 52px; border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 24px; flex-shrink: 0;
}
.stat-icon.green { background: #e8f5e9; color: #2d6a4f; }
.stat-icon.red { background: #fdecea; color: #c62828; }
.stat-icon.orange { background: #fff3e0; color: #e65100; }
.stat-icon.blue { background: #e3f2fd; color: #1565c0; }
.stat-icon.purple { background: #f3e5f5; color: #6a1b9a; }
.stat-icon.teal { background: #e0f2f1; color: #00695c; }
.stat-value { font-size: 28px; font-weight: 700; color: #1a2332; }
.stat-label { font-size: 13px; color: var(--text-muted); margin-top: 2px; }

/* ── Clock Panel ── */
.clock-panel {
  background: linear-gradient(135deg, #1a2332 0%, #2d3e50 100%);
  border-radius: 16px; padding: 40px; text-align: center; color: #fff;
  box-shadow: 0 4px 20px rgba(0,0,0,.15);
}
.clock-time { font-size: 64px; font-weight: 300; letter-spacing: 4px; font-variant-numeric: tabular-nums; }
.clock-date { font-size: 16px; color: #9eb3c9; margin-top: 8px; }
.clock-shift { font-size: 14px; color: #7a9ab5; margin-top: 4px; }
.clock-btn {
  padding: 14px 40px; font-size: 16px; font-weight: 600;
  border-radius: 50px; border: none; cursor: pointer;
  transition: transform .1s, box-shadow .2s;
  margin: 8px;
}
.clock-btn:hover { transform: translateY(-1px); box-shadow: 0 4px 12px rgba(0,0,0,.2); }
.clock-btn:active { transform: translateY(0); }
.btn-clock-in { background: #40916c; color: #fff; }
.btn-clock-out { background: #e76f51; color: #fff; }
.btn-clock-in:disabled, .btn-clock-out:disabled { background: #555; color: #999; cursor: not-allowed; }

/* ── Status Badges ── */
.badge-status { padding: 4px 10px; border-radius: 20px; font-size: 12px; font-weight: 500; }
.status-normal { background: #e8f5e9; color: #1b5e20; }
.status-late { background: #fff3cd; color: #856404; }
.status-early_leave { background: #fff3cd; color: #856404; }
.status-late_early { background: #ffe0b2; color: #e65100; }
.status-absent { background: #ffebee; color: #c62828; }
.status-holiday { background: #e0f2f1; color: #00695c; }
.status-weekend { background: #f5f5f5; color: #757575; }
.status-leave { background: #e3f2fd; color: #1565c0; }
.status-makeup { background: #f3e5f5; color: #6a1b9a; }

.badge-approval-pending { background: #fff3cd; color: #856404; }
.badge-approval-approved { background: #e8f5e9; color: #1b5e20; }
.badge-approval-rejected { background: #ffebee; color: #c62828; }

/* ── Tables ── */
.table { font-size: 14px; }
.table th { font-weight: 600; color: #555; background: #f8f9fa; border-top: none; }
.table td { vertical-align: middle; }
.table-hover tbody tr:hover { background: #f8f9fa; }

/* ── Monthly Calendar Table ── */
.calendar-table { font-size: 12px; }
.calendar-table th { text-align: center; padding: 6px 4px; white-space: nowrap; min-width: 38px; }
.calendar-table td { text-align: center; padding: 4px; min-width: 38px; }
.cal-weekend { background: #fafafa; }
.cal-holiday { background: #e8f5e9; }
.cal-today { background: #e3f2fd; font-weight: 600; }

/* ── Form ── */
.form-label { font-weight: 500; font-size: 14px; }
.form-control, .form-select { font-size: 14px; border-radius: 8px; }
.form-control:focus, .form-select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(82,183,136,.15); }

/* ── Buttons ── */
.btn-primary { background: var(--primary); border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-light); border-color: var(--primary-light); }
.btn-sm { font-size: 12px; padding: 4px 10px; border-radius: 6px; }

/* ── Login Page ── */
.login-page {
  min-height: 100vh;
  background: linear-gradient(135deg, #1a2332 0%, #2d3e50 60%, #1a3a2a 100%);
  display: flex; align-items: center; justify-content: center;
}
.login-card {
  background: #fff; border-radius: 16px;
  padding: 48px 40px; width: 100%; max-width: 400px;
  box-shadow: 0 20px 60px rgba(0,0,0,.3);
}
.login-logo { text-align: center; margin-bottom: 32px; }
.login-logo .icon { font-size: 48px; color: var(--primary); }
.login-logo h2 { font-size: 22px; font-weight: 700; margin-top: 8px; color: #1a2332; }
.login-logo p { font-size: 13px; color: #888; }

/* ── Approval Status ── */
.approval-timeline { border-left: 2px solid #e0e0e0; padding-left: 20px; }
.timeline-item { position: relative; padding-bottom: 20px; }
.timeline-item::before {
  content: ''; position: absolute; left: -25px; top: 4px;
  width: 10px; height: 10px; border-radius: 50%; background: #ccc;
}
.timeline-item.done::before { background: var(--accent); }
.timeline-item.rejected::before { background: #e53935; }

/* ── Report Table ── */
.report-table-wrap { overflow-x: auto; }
.report-table { font-size: 12px; min-width: 1200px; }
.report-table th, .report-table td { padding: 5px 6px; text-align: center; white-space: nowrap; border: 1px solid #dee2e6; }
.report-table thead th { background: #1F4E79; color: #fff; font-weight: 600; }
.report-table .col-name { text-align: left; min-width: 80px; }
.report-table .day-normal { color: #2d6a4f; }
.report-table .day-late { background: #fff9c4; color: #f57f17; }
.report-table .day-absent { background: #ffebee; color: #c62828; }
.report-table .day-leave { background: #e3f2fd; color: #1565c0; }
.report-table .day-holiday { background: #e8f5e9; color: #2e7d32; }
.report-table .day-weekend { background: #f5f5f5; color: #9e9e9e; }

/* ── Responsive ── */
@media (max-width: 768px) {
  .sidebar { width: 60px; }
  .sidebar .logo-text, .sidebar .menu-item span:not(.badge),
  .sidebar .menu-divider, .sidebar .user-detail { display: none; }
  .sidebar .menu-item a { justify-content: center; }
  .main-content { margin-left: 60px; }
  .clock-time { font-size: 48px; }
}
