:root {
  color-scheme: light;
  --brand: #03588c;
  --brand-2: #0388a6;
  --accent: #f2811d;
  --ink: #0f172a;
  --muted: #64748b;
  --border: rgba(3, 88, 140, 0.1);
}

* {
  box-sizing: border-box;
}

body {
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select {
  font: inherit;
}

.shell-grid {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  min-height: 100vh;
}

.glass-panel {
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid var(--border);
  box-shadow: 0 18px 55px rgba(15, 23, 42, 0.08);
  backdrop-filter: blur(18px);
}

.brand-gradient {
  background:
    radial-gradient(circle at top left, rgba(242, 129, 29, 0.12), transparent 32%),
    linear-gradient(135deg, rgba(3, 88, 140, 0.1), rgba(3, 136, 166, 0.06) 44%, rgba(255, 255, 255, 0.9));
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  width: 100%;
  border-radius: 1rem;
  padding: 0.75rem 0.875rem;
  color: #475569;
  transition: 160ms ease;
}

.nav-item:hover,
.nav-item.active {
  background: rgba(3, 88, 140, 0.08);
  color: var(--brand);
}

.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-height: 44px;
  border-radius: 1rem;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  color: white;
  padding: 0.75rem 1rem;
  font-weight: 700;
  transition: 160ms ease;
  box-shadow: 0 14px 28px rgba(3, 88, 140, 0.18);
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 18px 38px rgba(3, 88, 140, 0.22);
}

.btn-soft {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-height: 44px;
  border-radius: 1rem;
  border: 1px solid var(--border);
  background: white;
  color: var(--ink);
  padding: 0.75rem 1rem;
  font-weight: 700;
  transition: 160ms ease;
}

.btn-soft:hover {
  border-color: rgba(3, 88, 140, 0.24);
  color: var(--brand);
}

.field {
  width: 100%;
  min-height: 46px;
  border-radius: 1rem;
  border: 1px solid var(--border);
  background: white;
  padding: 0.75rem 0.875rem;
  outline: none;
  transition: 160ms ease;
}

.field:focus {
  border-color: rgba(3, 88, 140, 0.45);
  box-shadow: 0 0 0 4px rgba(3, 88, 140, 0.08);
}

.metric-card {
  border: 1px solid var(--border);
  background: white;
  border-radius: 1rem;
  padding: 1rem;
  box-shadow: 0 12px 35px rgba(15, 23, 42, 0.045);
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  border-radius: 999px;
  padding: 0.35rem 0.625rem;
  font-size: 0.75rem;
  font-weight: 700;
}

.toast {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  z-index: 60;
  max-width: min(420px, calc(100vw - 2rem));
  transform: translateY(1rem);
  opacity: 0;
  pointer-events: none;
  transition: 180ms ease;
}

.toast.show {
  transform: translateY(0);
  opacity: 1;
}

.camera-frame {
  aspect-ratio: 4 / 3;
  overflow: hidden;
  border-radius: 1rem;
  background: #0f172a;
  position: relative;
}

.camera-frame video,
.camera-frame canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.bottom-nav {
  display: none;
}

@media (max-width: 900px) {
  .shell-grid {
    display: block;
    padding-bottom: 76px;
  }

  aside {
    display: none;
  }

  .bottom-nav {
    display: flex;
    align-items: stretch;
    position: fixed;
    left: 0.5rem;
    right: 0.5rem;
    bottom: 0.5rem;
    z-index: 40;
    border-radius: 1.1rem;
    border: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.97);
    box-shadow: 0 18px 55px rgba(15, 23, 42, 0.14);
    backdrop-filter: blur(18px);
    overflow: hidden;
    padding: 4px;
  }

  .bottom-nav button {
    flex: 1 1 0;
    min-width: 0;
    min-height: 54px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    color: #64748b;
    border-radius: 0.85rem;
    transition: all 0.18s ease;
    padding: 4px 2px;
  }

  .bottom-nav .bn-icon { font-size: 1.05rem; line-height: 1; }
  .bottom-nav .bn-label {
    font-size: 0.6rem;
    font-weight: 700;
    line-height: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
  }

  /* When 6+ items, hide labels for inactive to save space, show only active label */
  .bottom-nav[data-count="7"] .bn-label,
  .bottom-nav[data-count="6"] .bn-label { font-size: 0.55rem; }

  .bottom-nav button.active {
    color: #fff;
    background: var(--brand);
    box-shadow: 0 6px 16px rgba(3, 88, 140, 0.3);
  }
  .bottom-nav button.active .bn-label { font-weight: 800; }
}

/* PWA Standalone Mode */
.pwa-standalone .shell-grid > aside { padding-top: max(env(safe-area-inset-top), 20px); }
.pwa-standalone .bottom-nav { padding-bottom: max(env(safe-area-inset-bottom), 8px); }
@media (display-mode: standalone) {
  body { overscroll-behavior-y: contain; }
}

/* ============ SETTINGS — TAB NAVIGATION ============ */
.settings-tabs {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding: 6px;
  background: rgba(3, 88, 140, 0.05);
  border: 1px solid var(--border);
  border-radius: 1rem;
  margin-bottom: 1rem;
  scrollbar-width: none;
}
.settings-tabs::-webkit-scrollbar { display: none; }
.settings-tab {
  flex: 0 0 auto;
  padding: 10px 16px;
  border-radius: 0.75rem;
  font-weight: 700;
  font-size: 0.85rem;
  color: #64748b;
  background: transparent;
  border: none;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.16s ease;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.settings-tab:hover { color: var(--brand); background: rgba(3, 88, 140, 0.06); }
.settings-tab.active {
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  color: #fff;
  box-shadow: 0 6px 16px rgba(3, 88, 140, 0.22);
}
.settings-panel { display: none; }
.settings-panel.active { display: block; animation: fadeIn 0.22s ease; }
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ============ MAP PICKER ============ */
.map-picker {
  height: 320px;
  width: 100%;
  border-radius: 1rem;
  overflow: hidden;
  border: 1px solid var(--border);
  background: #f1f5f9;
}
.map-picker .leaflet-control-attribution { font-size: 9px; }
.map-coords-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(3, 88, 140, 0.08);
  color: var(--brand);
  font-size: 0.7rem;
  font-weight: 700;
  direction: ltr;
}

.map-banner {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 14px;
  border-radius: 0.9rem;
  background: rgba(3, 136, 166, 0.06);
  border: 1px solid rgba(3, 136, 166, 0.18);
  color: #075985;
  font-size: 0.78rem;
  font-weight: 600;
  line-height: 1.6;
}
.map-banner i { flex-shrink: 0; margin-top: 3px; }
.map-banner.is-ok {
  background: rgba(16, 185, 129, 0.08);
  border-color: rgba(16, 185, 129, 0.22);
  color: #047857;
}

/* Google Places Autocomplete dropdown — keep it on top of our map and styled */
.pac-container {
  z-index: 9999 !important;
  border-radius: 12px;
  box-shadow: 0 12px 30px rgba(15, 23, 42, 0.12);
  font-family: 'Cairo', sans-serif;
  border: 1px solid var(--border);
  margin-top: 4px;
}
.pac-item {
  padding: 8px 12px;
  font-size: 0.85rem;
  cursor: pointer;
  direction: rtl;
  text-align: right;
}
.pac-item:hover { background: rgba(3, 88, 140, 0.06); }
.pac-item-query { font-weight: 700; color: var(--ink); }
.pac-matched { color: var(--brand); }

/* ============ EMPLOYEE ACTION ICON BUTTONS ============ */
.emp-actions {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-wrap: nowrap;
}
.emp-action-btn {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid transparent;
  background: rgba(3, 88, 140, 0.06);
  color: #475569;
  cursor: pointer;
  transition: all 0.16s ease;
  font-size: 0.95rem;
  position: relative;
}
.emp-action-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 14px rgba(15, 23, 42, 0.08);
}
.emp-action-btn.is-edit {
  background: rgba(3, 88, 140, 0.08);
  color: var(--brand);
  border-color: rgba(3, 88, 140, 0.18);
}
.emp-action-btn.is-edit:hover {
  background: var(--brand);
  color: #fff;
  border-color: var(--brand);
}
.emp-action-btn.is-face-on {
  background: rgba(16, 185, 129, 0.1);
  color: #047857;
  border-color: rgba(16, 185, 129, 0.25);
}
.emp-action-btn.is-face-on:hover {
  background: #10b981;
  color: #fff;
  border-color: #10b981;
}
.emp-action-btn.is-face-off {
  background: rgba(99, 102, 241, 0.08);
  color: #4338ca;
  border-color: rgba(99, 102, 241, 0.22);
}
.emp-action-btn.is-face-off:hover {
  background: #6366f1;
  color: #fff;
  border-color: #6366f1;
}
.emp-action-btn.is-del {
  background: rgba(239, 68, 68, 0.08);
  color: #b91c1c;
  border-color: rgba(239, 68, 68, 0.2);
}
.emp-action-btn.is-del:hover {
  background: #dc2626;
  color: #fff;
  border-color: #dc2626;
}
.emp-action-btn:focus { outline: 2px solid rgba(3, 88, 140, 0.3); outline-offset: 2px; }

/* ============ CALENDAR ============ */
.cal-card { padding: 1.25rem; }
.cal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.cal-reset-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-radius: 0.75rem;
  background: rgba(239, 68, 68, 0.06);
  border: 1px solid rgba(239, 68, 68, 0.2);
  color: #b91c1c;
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.16s ease;
}
.cal-reset-btn:hover:not([disabled]) {
  background: #dc2626;
  color: #fff;
  border-color: #dc2626;
}
.cal-reset-btn[disabled] { opacity: 0.55; cursor: not-allowed; }

.cal-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 10px;
  background: rgba(3, 88, 140, 0.04);
  border: 1px solid var(--border);
  border-radius: 0.85rem;
  margin-bottom: 18px;
}
.cal-month-nav {
  display: inline-flex;
  align-items: center;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  overflow: hidden;
}
.cal-nav-btn {
  width: 38px;
  height: 38px;
  background: transparent;
  border: none;
  cursor: pointer;
  color: var(--brand);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  transition: background 0.14s ease;
}
.cal-nav-btn:hover { background: rgba(3, 88, 140, 0.08); }
.cal-month-input {
  min-height: 38px;
  border: none;
  background: transparent;
  padding: 0 12px;
  font-weight: 700;
  color: var(--ink);
  font-family: 'Cairo', sans-serif;
  outline: none;
}
.cal-emp-sel { min-height: 42px; max-width: 220px; }
.cal-load-btn { padding: 0.55rem 1.1rem; min-height: 42px; }

.cal-stats {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 10px;
  margin-bottom: 18px;
}
.cal-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 12px 8px;
  border-radius: 0.85rem;
  border: 1px solid transparent;
}
.cal-stat-label { font-size: 0.7rem; font-weight: 700; opacity: 0.85; }
.cal-stat-value { font-size: 1.6rem; font-weight: 800; line-height: 1; }
.cal-stat--present { background: rgba(16, 185, 129, 0.08); border-color: rgba(16, 185, 129, 0.2); color: #047857; }
.cal-stat--late    { background: rgba(245, 158, 11, 0.08); border-color: rgba(245, 158, 11, 0.25); color: #b45309; }
.cal-stat--absent  { background: rgba(239, 68, 68, 0.07); border-color: rgba(239, 68, 68, 0.2); color: #b91c1c; }
.cal-stat--leave   { background: rgba(59, 130, 246, 0.07); border-color: rgba(59, 130, 246, 0.2); color: #1d4ed8; }
.cal-stat--holiday { background: rgba(100, 116, 139, 0.07); border-color: rgba(100, 116, 139, 0.18); color: #475569; }
@media (max-width: 640px) {
  .cal-stats { grid-template-columns: repeat(5, 1fr); gap: 6px; }
  .cal-stat { padding: 10px 4px; }
  .cal-stat-label { font-size: 0.62rem; }
  .cal-stat-value { font-size: 1.2rem; }
}

.cal-month-title {
  text-align: center;
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--brand);
  margin-bottom: 12px;
  padding: 6px;
  background: rgba(3, 88, 140, 0.04);
  border-radius: 0.6rem;
}

.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
}
.cal-day-header {
  text-align: center;
  font-size: 0.72rem;
  font-weight: 700;
  color: #94a3b8;
  padding: 8px 4px;
}
.cal-day-header.is-off { color: #f87171; font-weight: 800; }

.cal-cell {
  min-height: 72px;
  border-radius: 0.7rem;
  border: 1px solid transparent;
  padding: 6px 4px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 2px;
  font-family: 'Cairo', sans-serif;
}
.cal-cell.is-blank { background: transparent; border: none; min-height: 0; }
.cal-cell-day { font-size: 0.85rem; font-weight: 700; }
.cal-cell-icon { font-size: 0.72rem; line-height: 1; }
.cal-cell-time { font-size: 0.62rem; font-weight: 700; line-height: 1.25; }
.cal-cell-time--out { opacity: 0.85; }
.cal-cell-time--muted { color: #cbd5e1; }

.cal-cell--present { background: rgba(16, 185, 129, 0.08); border-color: rgba(16, 185, 129, 0.25); color: #065f46; }
.cal-cell--present .cal-cell-icon { color: #10b981; }
.cal-cell--late    { background: rgba(245, 158, 11, 0.08); border-color: rgba(245, 158, 11, 0.3); color: #92400e; }
.cal-cell--late .cal-cell-icon { color: #f59e0b; }
.cal-cell--absent  { background: rgba(239, 68, 68, 0.06); border-color: rgba(239, 68, 68, 0.18); color: #ef4444; }
.cal-cell--absent .cal-cell-icon { color: #f87171; }
.cal-cell--leave   { background: rgba(59, 130, 246, 0.07); border-color: rgba(59, 130, 246, 0.25); color: #1e3a8a; }
.cal-cell--leave .cal-cell-icon { color: #3b82f6; }
.cal-cell--holiday { background: rgba(241, 245, 249, 0.8); border-color: rgba(203, 213, 225, 0.7); color: #94a3b8; }
.cal-cell--holiday .cal-cell-icon { color: #94a3b8; }
.cal-cell--future  { background: rgba(248, 250, 252, 0.5); border-color: rgba(226, 232, 240, 0.5); color: #cbd5e1; }
.cal-cell.is-today {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
  box-shadow: 0 8px 18px rgba(3, 88, 140, 0.16);
  font-weight: 800;
}

.cal-legend {
  margin-top: 16px;
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  font-size: 0.72rem;
  font-weight: 700;
  color: #64748b;
  padding-top: 14px;
  border-top: 1px dashed var(--border);
}
.cal-legend > span { display: inline-flex; align-items: center; gap: 6px; }
.cal-legend-meta { margin-inline-start: auto; color: #94a3b8; }
.cal-dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.cal-dot--present { background: #10b981; }
.cal-dot--late    { background: #f59e0b; }
.cal-dot--absent  { background: #f87171; }
.cal-dot--leave   { background: #3b82f6; }
.cal-dot--holiday { background: #cbd5e1; }

.photo-dropzone {
  position: relative;
  border: 2px dashed rgba(3, 88, 140, 0.3);
  background: linear-gradient(135deg, rgba(3, 88, 140, 0.03), rgba(3, 136, 166, 0.04));
  border-radius: 1.25rem;
  padding: 32px 20px;
  text-align: center;
  cursor: pointer;
  transition: all 0.18s ease;
}
.photo-dropzone:hover {
  border-color: var(--brand);
  background: linear-gradient(135deg, rgba(3, 88, 140, 0.06), rgba(3, 136, 166, 0.08));
  transform: translateY(-1px);
}
.photo-dropzone.is-dragover {
  border-color: var(--accent);
  background: rgba(242, 129, 29, 0.06);
}
.photo-dropzone-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: rgba(3, 88, 140, 0.1);
  color: var(--brand);
  font-size: 1.6rem;
  margin-bottom: 10px;
}
.photo-preview-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 12px;
  border-radius: 1rem;
  background: rgba(3, 88, 140, 0.03);
}
.photo-preview-img {
  width: 180px;
  height: 180px;
  border-radius: 50%;
  object-fit: cover;
  border: 4px solid #fff;
  box-shadow: 0 12px 30px rgba(3, 88, 140, 0.18);
}
.photo-status-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  border-radius: 1rem;
  padding: 12px 16px;
  font-size: 0.85rem;
  font-weight: 700;
}
.photo-status-banner.is-ok { background: rgba(16, 185, 129, 0.08); color: #047857; border: 1px solid rgba(16, 185, 129, 0.2); }
.photo-status-banner.is-warn { background: rgba(245, 158, 11, 0.08); color: #b45309; border: 1px solid rgba(245, 158, 11, 0.25); }
.photo-status-banner.is-info { background: rgba(3, 88, 140, 0.06); color: var(--brand); border: 1px solid rgba(3, 88, 140, 0.18); }
.photo-status-banner.is-error { background: rgba(239, 68, 68, 0.07); color: #b91c1c; border: 1px solid rgba(239, 68, 68, 0.2); }

/* ============ SELF-CAPTURE WEBCAM (employee profile) ============ */
.self-cam-frame {
  position: relative;
  aspect-ratio: 1 / 1;
  max-width: 320px;
  margin: 0 auto;
  border-radius: 50%;
  overflow: hidden;
  background: #0f172a;
  border: 4px solid #fff;
  box-shadow: 0 14px 40px rgba(3, 88, 140, 0.22);
}
.self-cam-frame video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scaleX(-1);
}
.self-cam-overlay {
  position: absolute;
  inset: 12px;
  border-radius: 50%;
  border: 2px dashed rgba(255, 255, 255, 0.45);
  pointer-events: none;
}
