/* ============================================================
   KKM Attendance — Apple-Inspired Design System
   PT KONEKSINDO KARYA MANDIRI
   Minimal, clean, professional with native-mobile feel
   ============================================================ */

:root {
  /* KKM Custom Palette */
  --pink: #FE9EC7;
  --cream: #F9F6C4;
  --sky: #89D4FF;
  --blue: #44ACFF;
  --blue-dark: #3595e0;
  --green: #34c759;
  --green-dark: #248a3d;
  --yellow: #ff9500;
  --orange: #ff9500;
  --red: #ff3b30;
  --red-dark: #c62828;
  --purple: #af52de;
  --indigo: #5856d6;
  --teal: #5ac8fa;

  /* Grays */
  --gray-50: #f9f9f9;
  --gray-100: #f2f2f7;
  --gray-200: #e5e5ea;
  --gray-300: #d1d1d6;
  --gray-400: #aeaeb2;
  --gray-500: #8e8e93;
  --gray-600: #636366;
  --gray-700: #48484a;
  --gray-800: #363639;
  --gray-900: #1c1c1e;

  /* Backgrounds */
  --bg-primary: #ffffff;
  --bg-secondary: #f2f2f7;
  --bg-tertiary: #e5e5ea;
  --bg-glass: rgba(255, 255, 255, 0.72);

  /* Text */
  --text-primary: #1c1c1e;
  --text-secondary: #8e8e93;
  --text-tertiary: #aeaeb2;
  --text-inverse: #ffffff;

  /* Typography */
  --font: 'Poppins', -apple-system, 'Helvetica Neue', 'SF Pro Display', system-ui, sans-serif;
  --font-mono: 'SF Mono', 'SFMono-Regular', ui-monospace, monospace;

  /* Spacing */
  --xs: 4px;
  --sm: 8px;
  --md: 16px;
  --lg: 24px;
  --xl: 32px;
  --xxl: 48px;

  /* Radius */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --radius-full: 9999px;

  /* Shadows */
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.06);
  --shadow-lg: 0 8px 30px rgba(0,0,0,0.08);
  --shadow-xl: 0 20px 60px rgba(0,0,0,0.1);

  /* Transitions */
  --ease: cubic-bezier(0.25, 0.1, 0.25, 1);
  --spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --duration: 0.3s;
}

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

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font);
  background: var(--bg-secondary);
  color: var(--text-primary);
  line-height: 1.5;
  min-height: 100vh;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: contain;
}

a { color: var(--blue); text-decoration: none; -webkit-tap-highlight-color: transparent; }
a:hover { color: var(--blue-dark); }

code {
  font-family: var(--font-mono);
  font-size: 0.8125em;
  background: var(--gray-100);
  padding: 2px 6px;
  border-radius: 4px;
  color: var(--gray-800);
}

img { max-width: 100%; height: auto; }

/* --- Typography --- */
h1, h2, h3, h4 { font-weight: 700; line-height: 1.2; letter-spacing: -0.02em; color: var(--text-primary); }
.text-muted { color: var(--text-secondary); font-size: 0.8125rem; }
.text-center { text-align: center; }

/* --- Navbar (Desktop) — Rounded Centered Card --- */
.navbar {
  background: linear-gradient(135deg, #FE9EC7 0%, #F9F6C4 40%, #89D4FF 70%, #44ACFF 100%);
  position: sticky;
  top: 12px;
  z-index: 100;
  box-shadow: 0 2px 20px rgba(68,172,255,0.2);
  max-width: 980px;
  margin: 12px auto 0;
  border-radius: 16px;
}

.navbar-inner {
  display: flex;
  align-items: center;
  padding: 0 var(--lg);
  height: 56px;
  gap: var(--md);
}

.navbar-brand {
  display: flex;
  align-items: center;
  gap: var(--sm);
  color: #1c1c1e;
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: -0.01em;
}

.brand-icon {
  background: rgba(255,255,255,0.6);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  color: #1c1c1e;
  padding: 4px 10px;
  border-radius: 8px;
  font-size: 0.8rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  border: 0.5px solid rgba(255,255,255,0.3);
}

.brand-text { display: none; }

.brand-logo-img { height: 32px; width: auto; border-radius: 6px; }

.nav-links {
  display: flex;
  list-style: none;
  gap: 2px;
  margin-left: auto;
}

.nav-link {
  color: rgba(28,28,30,0.65);
  padding: 6px 14px;
  border-radius: var(--radius-full);
  font-size: 0.8125rem;
  font-weight: 500;
  transition: all var(--duration) var(--ease);
}
.nav-link:hover {
  color: #fff;
  background: #1c1c1e;
}
.nav-link.active {
  color: #fff;
  background: #1c1c1e;
  font-weight: 600;
}

.nav-user { display: flex; align-items: center; gap: var(--sm); margin-left: var(--md); }

.user-badge {
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  color: #fff;
  background: #F69D39;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  border: none;
}

.nav-user .btn-outline {
  font-size: 0.75rem;
  padding: 4px 14px;
  border-radius: var(--radius-full);
  border: 1px solid rgba(28,28,30,0.2);
  background: transparent;
  color: rgba(28,28,30,0.7);
  cursor: pointer;
  transition: all var(--duration) var(--ease);
  font-family: var(--font);
  font-weight: 500;
}
.nav-user .btn-outline:hover { background: rgba(255,255,255,0.5); color: #1c1c1e; }

.nav-user .btn-logout {
  font-size: 0.75rem;
  padding: 4px 14px;
  border-radius: var(--radius-full);
  border: none;
  background: #D92243;
  color: #fff;
  cursor: pointer;
  transition: all var(--duration) var(--ease);
  font-family: var(--font);
  font-weight: 600;
  text-decoration: none;
  display: inline-block;
}
.nav-user .btn-logout:hover { background: #b81d38; color: #fff; }

/* --- Bottom Tab Bar (Mobile) --- */
.mobile-tab-bar {
  display: none;
  position: fixed;
  bottom: 12px;
  left: 12px;
  right: 12px;
  height: 60px;
  background: linear-gradient(135deg, #FE9EC7 0%, #F9F6C4 40%, #89D4FF 70%, #44ACFF 100%);
  border: none;
  z-index: 100;
  padding: 0;
  box-shadow: 0 4px 24px rgba(68,172,255,0.25);
  border-radius: 16px;
}

.mobile-tab-inner {
  display: flex;
  height: 100%;
  align-items: center;
  justify-content: space-around;
  padding: 0 4px;
}

.tab-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  padding: 4px 8px;
  border-radius: var(--radius-md);
  transition: all var(--duration) var(--ease);
  -webkit-tap-highlight-color: transparent;
  cursor: pointer;
  min-width: 44px;
}

.tab-icon {
  font-size: 1.2rem;
  line-height: 1;
  color: rgba(28,28,30,0.45);
  transition: color var(--duration) var(--ease);
}

.tab-label {
  font-size: 0.5625rem;
  font-weight: 500;
  color: rgba(28,28,30,0.45);
  letter-spacing: -0.01em;
  transition: color var(--duration) var(--ease);
}

.tab-item.active .tab-icon,
.tab-item.active .tab-label { color: #1c1c1e; }

/* --- Main Content --- */
.main-content {
  max-width: 980px;
  margin: 0 auto;
  padding: var(--md) var(--md) calc(var(--md) + 84px);
  min-height: calc(100vh - 52px);
}

/* --- Page Header --- */
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  margin-bottom: var(--lg);
  flex-wrap: wrap;
  gap: var(--sm);
}

.page-title {
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  margin-bottom: 2px;
}

.page-subtitle {
  color: var(--text-secondary);
  font-size: 0.8125rem;
  font-weight: 400;
}

.header-time {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 1px;
}
.header-time-clock {
  font-family: var(--font-mono);
  font-size: 1.15rem;
  font-weight: 700;
  color: #1c1c1e;
  line-height: 1.2;
  letter-spacing: 0.02em;
}
.header-time-clock span {
  font-weight: 400;
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin-left: 4px;
}
.header-time-date {
  font-size: 0.65rem;
  color: var(--text-secondary);
  letter-spacing: 0.02em;
  line-height: 1.2;
}

/* --- Cards (iOS style) --- */
.card {
  background: var(--bg-primary);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  margin-bottom: var(--md);
  overflow: hidden;
  border: 0.5px solid rgba(0,0,0,0.04);
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--md) var(--lg);
  border-bottom: 0.5px solid var(--gray-100);
  flex-wrap: wrap;
  gap: var(--sm);
}

.card-title {
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.card-badge {
  font-size: 0.6875rem;
  color: var(--text-secondary);
  background: var(--gray-100);
  padding: 4px 12px;
  border-radius: var(--radius-full);
  font-weight: 500;
}

.card-body { padding: var(--lg); }
.card-body.p-0 { padding: 0; }

.card-footer {
  display: flex;
  justify-content: space-between;
  padding: var(--md) var(--lg);
  border-top: 0.5px solid var(--gray-100);
  background: var(--gray-50);
}

/* --- Quick Menu (Admin Dashboard) --- */
.quick-menu {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: var(--sm);
  margin-bottom: var(--md);
}
.quick-menu-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 16px 8px;
  border-radius: var(--radius-md);
  text-decoration: none;
  color: #1c1c1e;
  font-weight: 600;
  font-size: 0.8125rem;
  gap: 6px;
  transition: all var(--duration) var(--ease);
  box-shadow: var(--shadow-sm);
  min-height: 80px;
}
.quick-menu-item:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.quick-menu-icon { font-size: 1.5rem; line-height: 1; }
.quick-menu-label { text-align: center; }

@media (max-width: 768px) {
  .quick-menu { grid-template-columns: repeat(3, 1fr); gap: 6px; }
  .quick-menu-item { min-height: 64px; padding: 12px 8px; font-size: 0.75rem; }
  .quick-menu-icon { font-size: 1.25rem; }
}

.card-actions { display: flex; gap: var(--sm); }
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: var(--md);
}

/* --- Stats (iOS Widget Style) --- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--sm);
  margin-bottom: var(--lg);
}

.stat-card {
  background: var(--bg-primary);
  border-radius: var(--radius-md);
  padding: var(--md);
  box-shadow: var(--shadow-sm);
  text-align: center;
  border: 0.5px solid rgba(0,0,0,0.04);
  position: relative;
  overflow: hidden;
}
.stat-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  border-radius: var(--radius-md) var(--radius-md) 0 0;
}
.stat-tepat::before { background: var(--green); }
.stat-terlambat::before { background: var(--orange); }
.stat-alpha::before { background: var(--red); }
.stat-jam::before { background: var(--blue); }
.stat-luar::before { background: var(--teal); }
.stat-dispensasi::before { background: var(--purple); }
.stat-total::before { background: var(--pink); }

.stat-value {
  font-size: 1.625rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.1;
  margin-bottom: 2px;
}

.stat-label {
  font-size: 0.6875rem;
  color: var(--text-secondary);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

/* Stat colors */
.stat-tepat .stat-value { color: var(--green); }
.stat-terlambat .stat-value { color: var(--orange); }
.stat-alpha .stat-value { color: var(--red); }
.stat-jam .stat-value { color: var(--blue); }
.stat-luar .stat-value { color: var(--teal); }
.stat-dispensasi .stat-value { color: var(--purple); }
.stat-total .stat-value { color: var(--text-primary); }

/* --- Buttons (iOS style) --- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sm);
  padding: 10px 20px;
  border-radius: var(--radius-full);
  font-size: 0.875rem;
  font-weight: 600;
  font-family: var(--font);
  border: none;
  cursor: pointer;
  transition: all var(--duration) var(--spring);
  text-decoration: none;
  white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
  letter-spacing: -0.01em;
}

.btn:active { transform: scale(0.96); }

.btn-primary {
  background: var(--blue);
  color: var(--text-inverse);
}
.btn-primary:hover { background: var(--blue-dark); color: white; }
.btn-primary:active { background: #3595e0; }

.btn-outline {
  background: transparent;
  color: var(--blue);
  border: 1.5px solid var(--blue);
}
.btn-outline:hover { background: rgba(68,172,255,0.08); }

.btn-block { width: 100%; justify-content: center; }
.btn-lg { padding: 14px 28px; font-size: 1rem; }
.btn-sm { padding: 6px 14px; font-size: 0.75rem; }
.btn:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }

.action-group { display: flex; gap: 4px; flex-wrap: nowrap; align-items: center; }
.btn-icon { font-size: 1.1em; }
.btn-icon-square {
  width: 34px; height: 34px; padding: 0;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 1rem; border-radius: 10px; border: none;
  text-decoration: none; transition: all 0.2s ease; line-height: 1;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08); flex-shrink: 0;
}
.btn-icon-delete { background: #fde8e8; color: #ff3b30; }
.btn-icon-delete:hover { background: #ff3b30; color: #fff; }
.btn-icon-edit { background: #e8f4fd; color: #44ACFF; }
.btn-icon-edit:hover { background: #44ACFF; color: #fff; }
.btn-icon-toggle-on { background: #e8f8ec; color: #34c759; }
.btn-icon-toggle-on:hover { background: #34c759; color: #fff; }
.btn-icon-toggle-off { background: #f2f2f7; color: #8e8e93; }
.btn-icon-toggle-off:hover { background: #8e8e93; color: #fff; }

/* --- Forms (iOS style) --- */
.form-group { margin-bottom: var(--md); flex: 1; }

.form-label {
  display: block;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 6px;
  letter-spacing: -0.01em;
}

.form-input, .form-select {
  width: 100%;
  padding: 12px 14px;
  border: 1.5px solid var(--gray-200);
  border-radius: var(--radius-md);
  font-size: 0.9375rem;
  font-family: var(--font);
  background: var(--bg-primary);
  color: var(--text-primary);
  transition: all var(--duration) var(--ease);
  -webkit-appearance: none;
  appearance: none;
}

.form-input:focus, .form-select:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 4px rgba(68,172,255,0.15);
}

.form-input::placeholder { color: var(--text-tertiary); }

.form-select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238e8e93' stroke-width='2.5'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 36px;
}

.form-input-sm, .form-select-sm { padding: 8px 12px; font-size: 0.8125rem; }

.input-hint {
  display: block;
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin-top: 4px;
}

.form-row { display: flex; gap: var(--md); }

.file-input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 120px;
  border: 2px dashed var(--gray-300);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--duration) var(--ease);
  background: var(--gray-50);
}
.file-input-wrapper:hover { border-color: var(--blue); background: rgba(68,172,255,0.06); }
.file-input-wrapper input[type="file"] {
  position: absolute;
  opacity: 0;
  width: 100%;
  height: 100%;
  cursor: pointer;
}
.file-input-label { color: var(--text-secondary); font-size: 0.875rem; pointer-events: none; }

/* --- Alerts (iOS style) --- */
.alert {
  position: relative;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  margin-bottom: var(--md);
  display: flex;
  align-items: center;
  gap: var(--sm);
  font-weight: 500;
}
.alert-success { background: #e8f8ee; color: #1a7d36; }
.alert-danger { background: #ffe9e8; color: #bc1c16; }
.alert-warning { background: #fff4e5; color: #b86a00; }
.alert-info { background: #e8f4ff; color: #0066cc; }
.alert-close {
  margin-left: auto;
  background: none;
  border: none;
  font-size: 1.25rem;
  cursor: pointer;
  color: inherit;
  opacity: 0.4;
  line-height: 1;
}
.alert-close:hover { opacity: 0.8; }

/* --- Badges (iOS pills) --- */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: var(--radius-full);
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.01em;
}
.badge-success { background: #e8f8ee; color: #1a7d36; }
.badge-warning { background: #fff4e5; color: #b86a00; }
.badge-danger { background: #ffe9e8; color: #bc1c16; }
.badge-info { background: #e8f4ff; color: #0066cc; }
.badge-muted { background: var(--gray-100); color: var(--text-secondary); }

/* --- Tables --- */
.table-responsive {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.table th {
  text-align: left;
  padding: 12px 16px;
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-secondary);
  background: var(--gray-50);
  border-bottom: 0.5px solid var(--gray-200);
}

.table td {
  padding: 12px 16px;
  border-bottom: 0.5px solid var(--gray-100);
  vertical-align: middle;
}

.table tr:last-child td { border-bottom: none; }
.table tr:hover td { background: var(--gray-50); }

/* --- Today Card (Attendance) --- */
.today-card .card-body { text-align: center; padding: var(--xl) var(--lg); }

.attendance-status { max-width: 360px; margin: 0 auto; }

.status-indicator {
  display: inline-flex;
  align-items: center;
  gap: var(--sm);
  padding: 10px 20px;
  border-radius: var(--radius-full);
  margin-bottom: var(--md);
  font-weight: 600;
  font-size: 0.875rem;
}

.status-indicator.success { background: #e8f8ee; color: #1a7d36; }
.status-indicator.warning { background: #fff4e5; color: #b86a00; }

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.status-indicator.success .status-dot { background: var(--green); }
.status-indicator.warning .status-dot { background: var(--orange); }

.attendance-detail {
  text-align: left;
  font-size: 0.875rem;
  background: var(--gray-50);
  border-radius: var(--radius-md);
  padding: var(--md);
}

.attendance-detail p { margin-bottom: 4px; }
.attendance-detail p:last-child { margin-bottom: 0; }

.clock-in-section { margin-top: var(--md); }
.location-select-wrapper { margin-bottom: var(--md); }
.location-select-wrapper .form-select { width: 100%; padding: 14px; font-size: 1rem; border-radius: 12px; }

.non-attendance-divider {
  display: flex; align-items: center; gap: 12px;
  margin: 16px 0; color: var(--text-secondary); font-size: 0.8125rem;
}
.non-attendance-divider::before,
.non-attendance-divider::after {
  content: ''; flex: 1; height: 1px; background: var(--gray-200);
}
.non-attendance-buttons {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin-bottom: 12px;
}
.btn-non-attendance {
  padding: 10px; border-radius: 12px; border: 1.5px solid var(--gray-200);
  background: var(--bg-primary); color: #1c1c1e; font-weight: 600;
  font-size: 0.8125rem; cursor: pointer; transition: all 0.2s ease;
  text-align: center;
}
.btn-non-attendance:hover { border-color: var(--blue); background: #f0f8ff; }
.btn-non-attendance.active {
  background: linear-gradient(135deg, #FE9EC7, #44ACFF);
  color: #fff; border-color: transparent;
  box-shadow: 0 4px 12px rgba(68,172,255,0.3);
}
.non-attendance-form { margin-top: 0; }
.non-attendance-form textarea { border-radius: 12px 12px 0 0 !important; border-bottom: none !important; }
.non-attendance-actions { display: flex; gap: 6px; }
.non-attendance-actions .btn { flex: 1; justify-content: center; border-radius: 0 0 12px 12px; }

/* GPS Status */
.gps-status {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--sm);
  margin-top: var(--sm);
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.gps-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--orange);
  animation: pulse 1.5s ease infinite;
}

.gps-dot.active { background: var(--green); animation: none; }
.gps-dot.error { background: var(--red); animation: none; }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

.countdown-timer {
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  color: var(--text-secondary);
  margin-top: var(--sm);
  font-weight: 500;
}

/* --- Week Grid --- */
.week-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
}

.week-day {
  text-align: center;
  padding: 10px 4px;
  border-radius: 12px;
  background: var(--gray-50);
  border-top: 3px solid transparent;
  transition: transform 0.2s, box-shadow 0.2s;
}

.week-day.today {
  background: #fff;
  box-shadow: 0 2px 12px rgba(68,172,255,0.15), inset 0 0 0 1.5px var(--blue);
}

.week-day.future { opacity: 0.35; }

.week-day-name {
  font-size: 0.625rem;
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 2px;
}

.week-day-date {
  font-size: 1.125rem;
  font-weight: 800;
  color: var(--text-primary);
  line-height: 1.2;
  margin-bottom: 6px;
}

.week-day-time {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
}

.week-day-badge {
  display: inline-block;
  font-size: 0.625rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 6px;
  letter-spacing: 0.02em;
}

.week-day-dash {
  font-size: 1rem;
  color: var(--text-tertiary);
  line-height: 1;
}

/* --- Calendar --- */
.calendar-header {
  text-align: center;
  font-weight: 700;
  margin-bottom: var(--md);
  font-size: 0.9375rem;
  letter-spacing: -0.01em;
}

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

.cal-header {
  text-align: center;
  font-size: 0.625rem;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--text-tertiary);
  padding: 4px 0;
}

.cal-day {
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  border-radius: var(--radius-sm);
  font-weight: 500;
  position: relative;
}

.cal-day.empty { background: transparent; }

.cal-today {
  font-weight: 700;
  box-shadow: inset 0 0 0 2px var(--blue);
  color: var(--blue);
}

.cal-green { background: #e8f8ee; color: #1a7d36; }
.cal-amber { background: #fff4e5; color: #b86a00; }
.cal-red { background: #ffe9e8; color: #bc1c16; }
.cal-blue { background: #e8f4ff; color: #0066cc; }
.cal-purple { background: #f0e8ff; color: #6b21a8; }

.calendar-legend {
  display: flex;
  gap: var(--md);
  justify-content: center;
  margin-top: var(--md);
  flex-wrap: wrap;
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 4px;
}
.dot-green { background: var(--green); }
.dot-amber { background: var(--orange); }
.dot-red { background: var(--red); }
.dot-blue { background: var(--teal); }

/* --- Auth Pages (iOS-style) --- */
.auth-wrapper {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  overflow-y: auto;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 60px var(--lg);
  background: linear-gradient(135deg, #FE9EC7 0%, #F9F6C4 40%, #89D4FF 70%, #44ACFF 100%);
  z-index: 999;
}

.auth-card {
  background: rgba(255,255,255,0.95);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-radius: var(--radius-xl);
  box-shadow: 0 20px 60px rgba(0,0,0,0.2);
  padding: var(--xl);
  width: 100%;
  max-width: 400px;
  border: 0.5px solid rgba(255,255,255,0.2);
}

.auth-card-lg { max-width: 540px; }

.auth-header { text-align: center; margin-bottom: var(--xl); }

.auth-logo {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 72px;
  height: 72px;
  background: linear-gradient(135deg, #FE9EC7, #44ACFF);
  color: white;
  font-size: 1.75rem;
  font-weight: 800;
  border-radius: var(--radius-xl);
  margin-bottom: var(--md);
  box-shadow: 0 8px 24px rgba(68,172,255,0.3);
}

.auth-logo-img {
  width: 80px;
  height: 80px;
  object-fit: contain;
  border-radius: 20px;
  margin-bottom: var(--md);
  box-shadow: 0 8px 24px rgba(0,0,0,0.1);
}

.auth-title {
  font-size: 1.625rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  margin-bottom: 2px;
  color: #1c1c1e;
}

.auth-subtitle {
  color: rgba(28,28,30,0.55);
  font-size: 0.875rem;
}

.auth-form { margin-bottom: var(--lg); }
.auth-footer { text-align: center; font-size: 0.875rem; color: var(--text-secondary); }
.auth-footer a { color: var(--blue); font-weight: 600; }

.divider {
  border: none;
  border-top: 0.5px solid var(--gray-200);
  margin: var(--lg) 0;
}

.section-title {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: var(--md);
  letter-spacing: -0.01em;
}

/* --- Profile --- */
.profile-header {
  display: flex;
  align-items: center;
  gap: var(--lg);
  margin-bottom: var(--lg);
  padding-bottom: var(--lg);
  border-bottom: 0.5px solid var(--gray-100);
}

.profile-avatar {
  position: relative;
  width: 88px;
  height: 88px;
  flex-shrink: 0;
}

.avatar-img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
  border: 3px solid var(--bg-primary);
  box-shadow: var(--shadow-sm);
}

.avatar-placeholder {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: rgba(68,172,255,0.12);
  color: var(--blue);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.75rem;
  font-weight: 700;
  border: 3px solid var(--bg-primary);
  box-shadow: var(--shadow-sm);
}

.avatar-edit {
  position: absolute;
  bottom: 2px;
  right: 2px;
  width: 30px;
  height: 30px;
  background: var(--blue);
  color: white;
  border: 2px solid white;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8125rem;
  box-shadow: var(--shadow-sm);
  transition: all var(--duration) var(--ease);
}
.avatar-edit:hover { transform: scale(1.1); }

.profile-info h2 { font-size: 1.25rem; margin-bottom: 2px; }
.profile-info .text-muted { font-size: 0.8125rem; }

/* --- Search / Filter --- */
.search-form, .filter-form {
  display: flex;
  gap: var(--sm);
  align-items: center;
  flex-wrap: nowrap;
}
.search-form .form-input { min-width: 200px; flex: 1; }

/* Filter items with icons */
.filter-item {
  display: flex;
  align-items: center;
  gap: 4px;
}
.filter-icon { display: none; }
.filter-form .form-input,
.filter-form .form-select { min-width: 0; flex: 0 1 auto; }
.filter-form input[type="date"] { width: 140px; }
.filter-form input[name="search"] { width: 160px; }
.filter-form select[name="employee_id"] { width: 140px; }

/* --- Pagination --- */
.pagination { display: flex; gap: 4px; }

.page-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 36px;
  height: 36px;
  padding: 0 8px;
  border-radius: var(--radius-sm);
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-primary);
  background: var(--bg-primary);
  border: 0.5px solid var(--gray-200);
  transition: all var(--duration) var(--ease);
}
.page-link:hover, .page-link.active { background: var(--blue); color: white; border-color: var(--blue); }

/* --- Progress Bar --- */
.progress-bar-wrapper { margin-bottom: var(--md); }

.progress-bar {
  display: flex;
  height: 8px;
  border-radius: var(--radius-full);
  overflow: hidden;
  background: var(--gray-100);
}

.progress-segment { transition: width 0.5s var(--ease); }
.bg-green { background: var(--green); }
.bg-amber { background: var(--orange); }
.bg-blue { background: var(--teal); }
.bg-purple { background: var(--purple); }
.bg-red { background: var(--red); }
.bg-orange { background: var(--orange); }
.bg-indigo { background: var(--indigo); }
.bg-teal { background: var(--teal); }

.stats-detail { font-size: 0.875rem; }
.stats-detail p { margin-bottom: 4px; }

/* --- Map --- */
.map-container {
  width: 100%;
  min-height: 300px;
  border-radius: var(--radius-md);
  overflow: hidden;
}

.location-map {
  height: 200px;
  border-radius: var(--radius-md);
  overflow: hidden;
}

/* Keep Leaflet maps below sticky headers/navs */
.leaflet-pane,
.leaflet-top,
.leaflet-bottom,
.leaflet-control { z-index: 1 !important; }
.leaflet-map-pane { z-index: 0 !important; }

/* Detail map container stacking */
#detailMap { isolation: isolate; position: relative; z-index: 0; }

/* Modal animation */
@keyframes modalIn { from { opacity:0; transform:scale(0.92) translateY(10px) } to { opacity:1; transform:scale(1) translateY(0) } }

/* --- Spacing --- */
.mt-1 { margin-top: var(--sm); }
.mt-2 { margin-top: var(--md); }
.mb-1 { margin-bottom: var(--sm); }
.mb-2 { margin-bottom: var(--md); }
.p-0 { padding: 0; }

/* --- Footer --- */
.footer {
  display: none;
}
.footer-inner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.75rem;
  color: var(--text-tertiary);
}

/* --- Error Page --- */
.error-page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--lg);
  text-align: center;
  background: var(--bg-secondary);
}

.error-code {
  font-size: 5rem;
  font-weight: 800;
  color: var(--gray-300);
  line-height: 1;
  letter-spacing: -0.05em;
}

.error-title {
  font-size: 1.5rem;
  margin-bottom: var(--sm);
}

.error-desc {
  color: var(--text-secondary);
  margin-bottom: var(--lg);
}

/* --- Offline Banner --- */
.offline-banner {
  background: var(--orange);
  color: white;
  text-align: center;
  padding: 8px 16px;
  font-size: 0.8125rem;
  font-weight: 500;
}

/* --- Mobile Header --- */
.mobile-header { display: none; }

@media (max-width: 768px) {
  .mobile-header {
    display: block;
    position: sticky;
    top: 0;
    z-index: 500;
    background: linear-gradient(135deg, #FFF6DE, #8BDFDD, #F48F68, #FFE394);
    border-bottom: 0.5px solid rgba(0,0,0,0.06);
    padding-top: env(safe-area-inset-top, 0px);
  }
  .mobile-header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 16px;
    max-width: 980px;
    margin: 0 auto;
  }
  .mobile-header-brand {
    display: flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
  }
  .mobile-header-logo {
    height: 28px;
    width: auto;
    border-radius: 6px;
  }
  .mobile-header-icon {
    background: rgba(255,255,255,0.5);
    color: #1c1c1e;
    padding: 3px 8px;
    border-radius: 6px;
    font-size: 0.7rem;
    font-weight: 800;
    letter-spacing: -0.02em;
  }
  .mobile-header-text {
    font-size: 0.9rem;
    font-weight: 700;
    color: #1c1c1e;
    letter-spacing: -0.01em;
  }
  .mobile-header-right {
    display: flex;
    align-items: center;
    gap: 8px;
  }
  .mobile-header-badge {
    font-size: 0.65rem;
    font-weight: 600;
    color: #1c1c1e;
    background: rgba(255,255,255,0.5);
    padding: 3px 10px;
    border-radius: 20px;
    backdrop-filter: blur(4px);
  }
  .main-content {
    padding: 12px 12px calc(84px + env(safe-area-inset-bottom, 0px));
    padding-top: 12px;
    max-width: 100%;
  }
}

/* Mobile cards (hidden on desktop, shown on mobile) */
.mobile-cards { display: none; }
@media (max-width: 768px) {
  .mobile-cards { display: flex; flex-direction: column; gap: 10px; padding: 12px; }
  .table-responsive { display: none; }
}

/* --- Mobile (iOS Native Feel) --- */
@media (max-width: 768px) {
  .navbar { display: none; }

  .main-content {
    padding: 12px 12px calc(84px + env(safe-area-inset-bottom, 0px));
    padding-top: 12px;
    max-width: 100%;
  }

  .mobile-tab-bar { display: block; }

  .page-header { flex-direction: row; align-items: center; gap: 8px; margin-bottom: 12px; }
  .page-title { font-size: 1.375rem; }
  .page-subtitle { font-size: 0.75rem; }
  .page-header > div { flex: 1; min-width: 0; }
  .page-header > div > * { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .page-subtitle { font-size: 0.75rem; }
  .header-time-clock { font-size: 1rem; }
  .header-time-date { font-size: 0.6rem; }

  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 6px;
    margin-bottom: 12px;
  }

  .stat-card { padding: 8px 12px; }
  .stat-value { font-size: 1.25rem; }
  .stat-label { font-size: 0.625rem; }

  .form-row { flex-direction: column; gap: 0; }
  .card-grid { grid-template-columns: 1fr; }
  .week-grid { gap: 3px; }
  .week-day { padding: 8px 2px; border-radius: 10px; }
  .week-day-date { font-size: 1rem; margin-bottom: 4px; }
  .week-day-time { font-size: 0.6875rem; }
  .week-day-badge { font-size: 0.5625rem; padding: 1px 6px; }

  /* Filter form: icons only on mobile, 1 row */
  .filter-icon {
    display: inline-flex;
    font-size: 1.1rem;
    line-height: 1;
    background: var(--bg-primary);
    border: 0.5px solid var(--gray-200);
    border-radius: 10px;
    padding: 8px 10px;
    cursor: pointer;
    box-shadow: var(--shadow-sm);
    transition: all var(--duration) var(--ease);
    width: 100%;
    justify-content: center;
    align-items: center;
    min-height: 38px;
  }
  .filter-icon:active { transform: scale(0.94); background: var(--gray-100); }
  .filter-form { flex-wrap: nowrap; gap: 4px; }
  .filter-item { flex: 0 0 auto; min-width: 0; }
  .filter-form .form-input,
  .filter-form .form-select { display: none; }
  .filter-form .btn { font-size: 0.75rem; padding: 8px 12px; white-space: nowrap; flex-shrink: 0; }

  .auth-card {
    padding: var(--lg);
    border-radius: var(--radius-lg);
    background: rgba(255,255,255,0.95);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
  }
  .auth-card-lg { max-width: 100%; }
  .auth-wrapper {
    padding: var(--md);
    background: linear-gradient(135deg, #FE9EC7 0%, #F9F6C4 40%, #89D4FF 70%, #44ACFF 100%);
    align-items: flex-start;
    padding-top: calc(env(safe-area-inset-top, 0px) + var(--lg));
  }

  .card { border-radius: var(--radius-md); }
  .card-body { padding: 12px; }

  .card-header {
    padding: 12px;
    flex-wrap: wrap;
    gap: 6px;
  }
  .card-title { font-size: 0.9375rem; }

  .table { font-size: 0.75rem; }
  .table th, .table td { padding: 8px 8px; }

  .today-card .card-body { padding: var(--lg) var(--md); }

  .profile-header { flex-direction: column; text-align: center; }
  .profile-avatar { width: 72px; height: 72px; }

  /* Calendar */
  .calendar-grid { gap: 2px; }
  .cal-day { padding: 4px 0; font-size: 0.75rem; }
  .cal-header { font-size: 0.625rem; padding: 4px 0; }

  /* Attendance status */
  .status-indicator { font-size: 0.8125rem; padding: 8px 14px; }
  .attendance-detail { font-size: 0.75rem; padding: 8px 12px; }

  /* Buttons */
  .btn { padding: 10px 18px; font-size: 0.875rem; }
  .btn-sm { padding: 6px 12px; font-size: 0.75rem; }
  .btn-lg { padding: 12px 20px; font-size: 0.9375rem; }
  .form-input, .form-select { padding: 12px; font-size: 0.9375rem; }

  /* Card grid */
  .card-actions { gap: 6px; }
  .card-actions .form-select { font-size: 0.75rem; padding: 6px 10px; }

  /* Bottom tab safe area */
  .main-content > *:last-child { margin-bottom: 0; }
}

@media (max-width: 480px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 4px; }
  .stat-card { padding: 8px 10px; }
  .stat-value { font-size: 1.125rem; }
  .stat-label { font-size: 0.5625rem; }
  .week-day-name { font-size: 0.5625rem; }
  .week-day-date { font-size: 0.625rem; }
  .table { font-size: 0.6875rem; }
  .table th, .table td { padding: 6px 6px; }
  .card-body { padding: 10px; }
  .msg-form-card { max-width: none; }
  .msg-recipient-card { padding: 12px 14px; }
  .msg-recipient-avatar { width: 36px; height: 36px; font-size: 0.875rem; border-radius: 10px; }
  .msg-recipient-name { font-size: 0.875rem; }
  .msg-recipient-action { width: 32px; height: 32px; font-size: 0.875rem; }
}

/* ============================================================
   Modal Overlay
   ============================================================ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.modal-container {
  background: var(--card-bg, #fff);
  border-radius: 20px;
  width: 100%;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
  animation: modalSlideUp 0.3s ease;
}

@keyframes modalSlideUp {
  from { opacity: 0; transform: translateY(30px); }
  to { opacity: 1; transform: translateY(0); }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--gray-100, #e5e5ea);
}

.modal-title {
  font-size: 1.125rem;
  font-weight: 700;
  margin: 0;
}

.modal-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--text-secondary, #8e8e93);
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: background 0.2s;
}

.modal-close:hover { background: var(--gray-50, #f2f2f7); }

.modal-body {
  padding: 16px 20px;
  overflow-y: auto;
  flex: 1;
}

.modal-footer {
  display: flex;
  align-items: center;
  padding: 12px 20px;
  gap: 8px;
  border-top: 1px solid var(--gray-100, #e5e5ea);
}

/* ============================================================
   Message Popup Items
   ============================================================ */
.message-popup-item {
  padding: 12px 0;
  border-bottom: 1px solid var(--gray-50, #f2f2f7);
}

.message-popup-item:last-child { border-bottom: none; }

.message-popup-subject {
  font-weight: 700;
  font-size: 0.9375rem;
  margin-bottom: 4px;
}

.message-popup-preview {
  font-size: 0.8125rem;
  color: var(--text-secondary, #8e8e93);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-bottom: 4px;
}

.message-popup-time {
  font-size: 0.75rem;
  color: var(--text-tertiary, #aeaeb2);
}

/* ============================================================
   Message Cards (Employee)
   ============================================================ */
.message-card {
  transition: border-color 0.2s;
}

.message-unread {
  border-left: 4px solid var(--teal, #5ac8fa);
}

.message-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}

.message-subject {
  font-weight: 700;
  font-size: 1rem;
}

.message-meta {
  font-size: 0.75rem;
  color: var(--text-secondary, #8e8e93);
}

.message-body {
  font-size: 0.875rem;
  line-height: 1.6;
  color: var(--text-primary, #1c1c1e);
  white-space: pre-wrap;
}

.mark-read-btn {
  font-size: 0.75rem;
}

/* ============================================================
   Message Recipient Cards (Mobile)
   ============================================================ */
.msg-recipient-empty {
  text-align: center;
  padding: 32px 16px;
  color: var(--text-secondary, #8e8e93);
  font-size: 0.875rem;
}

.msg-recipient-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--gray-50, #f2f2f7);
  transition: background 0.2s;
}

.msg-recipient-card:last-child { border-bottom: none; }

.msg-recipient-card:active { background: var(--gray-50, #f2f2f7); }

.msg-recipient-body {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
  min-width: 0;
}

.msg-recipient-avatar {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: linear-gradient(135deg, #89D4FF, #44ACFF);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1rem;
  flex-shrink: 0;
}

.msg-recipient-info {
  min-width: 0;
  flex: 1;
}

.msg-recipient-name {
  font-weight: 600;
  font-size: 0.9375rem;
  color: var(--text-primary, #1c1c1e);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.msg-recipient-meta {
  font-size: 0.75rem;
  color: var(--text-secondary, #8e8e93);
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 2px;
}

.msg-recipient-bn {
  font-family: 'SF Mono', 'Menlo', monospace;
  font-weight: 500;
}

.msg-recipient-divider {
  opacity: 0.4;
}

.msg-recipient-action {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: var(--teal, #5ac8fa);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  text-decoration: none;
  flex-shrink: 0;
  transition: transform 0.2s, box-shadow 0.2s;
}

.msg-recipient-action:active {
  transform: scale(0.92);
  box-shadow: 0 2px 8px rgba(90, 200, 250, 0.4);
}

.msg-form-card {
  max-width: 720px;
  margin-bottom: var(--md);
}

/* ── PWA Install Banner ── */
.install-banner {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  display: none;
  flex-direction: column;
  background: #fff;
  box-shadow: 0 -4px 20px rgba(0,0,0,0.15);
  padding: var(--sm) var(--md);
  z-index: 9999;
  border-radius: 16px 16px 0 0;
}
.install-banner-body {
  display: flex;
  align-items: center;
  gap: var(--sm);
  margin-bottom: var(--sm);
}
.install-banner-icon {
  width: 48px;
  height: 48px;
  background: var(--c-primary);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 24px;
  flex-shrink: 0;
}
.install-banner-text {
  flex: 1;
}
.install-banner-title {
  font-weight: 700;
  font-size: 14px;
  color: var(--c-dark);
}
.install-banner-desc {
  font-size: 12px;
  color: var(--c-muted);
}
.install-banner-actions {
  display: flex;
  gap: var(--sm);
  justify-content: flex-end;
}
.install-banner-btn {
  border: none;
  background: none;
  padding: 8px 20px;
  border-radius: 8px;
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  font-family: inherit;
  color: var(--c-muted);
}
.install-banner-btn-primary {
  background: var(--c-primary);
  color: #fff;
}
