/* ============================================================
   FeriePro — Design System v3
   Mobile-first, accessible, legally compliant UI
   ============================================================ */

/* --- Custom Properties ------------------------------------ */
:root {
  --bg: #f0f4f8;
  --bg-subtle: #e8edf5;
  --card: #ffffff;
  --text: #1a2332;
  --text-secondary: #556477;
  --muted: #8494a7;
  --primary: #4f6ef7;
  --primary-hover: #3b57d9;
  --primary-light: #eef1fe;
  --primary-surface: #f5f7ff;
  --ok: #10b981;
  --ok-light: #d1fae5;
  --ok-dark: #065f46;
  --warn: #f59e0b;
  --warn-light: #fef3c7;
  --warn-dark: #92400e;
  --danger: #ef4444;
  --danger-light: #fee2e2;
  --danger-dark: #991b1b;
  --border: #e2e8f0;
  --border-light: #f1f5f9;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.07);
  --shadow-lg: 0 12px 32px rgba(0,0,0,0.08);
  --shadow-xl: 0 20px 48px rgba(0,0,0,0.1);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --radius-full: 999px;
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  --sidebar-w: 264px;
  --navbar-h: 64px;
}

/* --- Reset & Base ----------------------------------------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
a:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
  border-radius: 2px;
}
img { max-width: 100%; display: block; }

/* --- Utilities -------------------------------------------- */
.hidden { display: none !important; }
.mt-8 { margin-top: 8px; }
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mb-8 { margin-bottom: 8px; }
.wrap { flex-wrap: wrap; }

/* --- Typography ------------------------------------------- */
h1 { font-size: 1.75rem; font-weight: 700; letter-spacing: -0.02em; line-height: 1.2; }
h2 { font-size: 1.35rem; font-weight: 700; letter-spacing: -0.01em; line-height: 1.3; }
h3 { font-size: 1.05rem; font-weight: 650; line-height: 1.4; }
h4 { font-size: 0.92rem; font-weight: 600; line-height: 1.4; color: var(--text-secondary); }
h1, h2, h3, h4 { margin: 0 0 8px; }

/* --- Background Accent ------------------------------------ */
.bg-accent {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 320px;
  background: linear-gradient(135deg, #4f6ef7 0%, #6366f1 40%, #818cf8 100%);
  z-index: -1;
  pointer-events: none;
}

/* --- Layout ----------------------------------------------- */
.layout {
  max-width: 1200px;
  margin: 0 auto;
  padding: 40px 24px;
  min-height: 100vh;
}

/* --- Card ------------------------------------------------- */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-md);
  transition: box-shadow var(--transition);
}
.card:hover {
  box-shadow: var(--shadow-lg);
}

/* --- Auth Card -------------------------------------------- */
.auth-card {
  max-width: 440px;
  margin: 80px auto 0;
  padding: 40px 36px;
  border-radius: var(--radius-xl);
  border: none;
  box-shadow: var(--shadow-xl);
  text-align: center;
}
.auth-logo {
  margin-bottom: 12px;
}
.auth-logo-icon {
  display: block;
  color: #4f6ef7;
  line-height: 1;
}
button svg, .secondary svg {
  vertical-align: middle;
}
.auth-card h1 {
  font-size: 2rem;
  background: linear-gradient(135deg, #4f6ef7, #6366f1);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 4px;
}
.subtitle {
  margin: 0 0 28px;
  color: var(--text-secondary);
  font-size: 0.95rem;
  background: none;
  padding: 0;
  border-radius: 0;
}
.auth-card .helper {
  margin-top: 12px;
  font-size: 0.82rem;
}
.auth-legal {
  margin-top: 16px;
  font-size: 0.78rem;
  color: var(--muted);
  line-height: 1.5;
}
.auth-legal a {
  color: var(--primary);
}

/* --- Password Toggle -------------------------------------- */
.input-with-toggle {
  position: relative;
  display: flex;
  align-items: center;
}
.input-with-toggle input {
  width: 100%;
  padding-right: 44px;
}
.toggle-password {
  position: absolute;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  box-shadow: none;
  color: var(--muted);
  padding: 0 12px;
  min-height: unset;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
}
.toggle-password:hover {
  background: none;
  box-shadow: none;
  transform: translateY(-50%);
  color: var(--text);
}
.toggle-password:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: -2px;
  border-radius: var(--radius-sm);
}
.eye-icon { pointer-events: none; }

/* --- Forms ------------------------------------------------ */
.stack { display: grid; gap: 14px; }
.stack.compact { gap: 10px; }

label {
  display: grid;
  gap: 5px;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-secondary);
}

.optional-label {
  font-weight: 400;
  color: var(--muted);
  font-size: 0.8rem;
}

input, select, textarea {
  font: inherit;
  font-size: 0.9rem;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--border);
  background: var(--card);
  color: var(--text);
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
  width: 100%;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79, 110, 247, 0.12);
}
input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 0;
}
input::placeholder, textarea::placeholder {
  color: var(--muted);
}
input:invalid:not(:placeholder-shown) {
  border-color: var(--danger);
}
textarea { resize: vertical; min-height: 64px; }
select { cursor: pointer; }


fieldset {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
}

legend {
  padding: 0 6px;
  font-size: 0.82rem;
  color: var(--text-secondary);
  font-weight: 600;
}

#email-events-summary {
  padding-left: 18px;
}

#email-events-summary li + li {
  margin-top: 6px;
}

#email-events-checkboxes label {
  grid-template-columns: auto 1fr;
  align-items: start;
  column-gap: 8px;
}

#email-events-checkboxes .helper {
  margin-top: 2px;
}

/* --- Buttons ---------------------------------------------- */
button {
  font: inherit;
  font-size: 0.88rem;
  font-weight: 600;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  border: none;
  cursor: pointer;
  transition: all var(--transition);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: var(--primary);
  color: #fff;
  box-shadow: 0 1px 3px rgba(79, 110, 247, 0.3);
}
button:hover {
  background: var(--primary-hover);
  box-shadow: 0 4px 12px rgba(79, 110, 247, 0.35);
  transform: translateY(-1px);
}
button:active {
  transform: translateY(0);
  box-shadow: 0 1px 2px rgba(79, 110, 247, 0.3);
}
button:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}
button.secondary {
  background: var(--primary-light);
  color: var(--primary);
  box-shadow: none;
}
button.secondary:hover {
  background: #dde3fc;
  box-shadow: none;
  transform: none;
}
button.secondary.active {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 1px 3px rgba(79, 110, 247, 0.3);
}
button.secondary.danger {
  background: #fde8e8;
  color: #c0392b;
}
button.secondary.danger:hover {
  background: #fad0d0;
  box-shadow: none;
  transform: none;
}
.btn-primary-full {
  width: 100%;
  padding: 12px 20px;
  font-size: 0.95rem;
}

/* --- Helper text ------------------------------------------ */
.helper {
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.5;
}

/* --- Chip / Badge ----------------------------------------- */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin: 0 0 8px;
  padding: 3px 10px;
  border-radius: var(--radius-full);
  background: var(--primary-light);
  color: var(--primary);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

/* --- Dashboard -------------------------------------------- */
.dashboard {
  display: grid;
  gap: 20px;
}

/* --- Dashboard Header ------------------------------------- */
.dashboard-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  border: none;
  background: linear-gradient(135deg, #4f6ef7 0%, #6366f1 50%, #818cf8 100%);
  color: #fff;
  border-radius: var(--radius-xl);
  padding: 28px 32px;
  box-shadow: 0 8px 32px rgba(79, 110, 247, 0.25);
}
.dashboard-header-info { flex: 1; min-width: 0; }
.dashboard-header-actions { flex-shrink: 0; }
.dashboard-header h2 {
  color: #fff;
  font-size: 1.5rem;
  margin-bottom: 4px;
}
.dashboard-header .chip {
  background: rgba(255,255,255,0.2);
  color: #fff;
  backdrop-filter: blur(4px);
}
.dashboard-header .helper {
  color: rgba(255,255,255,0.8);
  margin-top: 4px;
}
.dashboard-intro {
  max-width: 580px;
  margin-top: 0;
}
.dashboard-header #logout-btn,
.dashboard-header #admin-view-btn {
  background: rgba(255,255,255,0.15);
  color: #fff;
  border: 1px solid rgba(255,255,255,0.25);
  backdrop-filter: blur(4px);
  box-shadow: none;
  white-space: nowrap;
}
.dashboard-header #logout-btn:hover,
.dashboard-header #admin-view-btn:hover {
  background: rgba(255,255,255,0.25);
  transform: none;
}
.dashboard-header-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-shrink: 0;
}

/* --- Admin mode: hide employee sections ------------------- */
.dashboard.admin-mode #metrics-grid,
.dashboard.admin-mode .two-col,
.dashboard.admin-mode #balances-card,
.dashboard.admin-mode #employee-calendar-card {
  display: none !important;
}
.dashboard.admin-mode #admin-panel {
  margin-top: 0;
}


/* --- Grid ------------------------------------------------- */
.grid { display: grid; gap: 16px; }
.two-col { grid-template-columns: repeat(2, 1fr); }

/* --- Metrics ---------------------------------------------- */
.metrics { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
.metric {
  padding: 18px 20px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--card);
  transition: all var(--transition);
}
.metric:hover {
  border-color: var(--primary);
  background: var(--primary-surface);
}
.metric small {
  font-size: 0.78rem;
  color: var(--muted);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.metric b {
  font-size: 1.6rem;
  display: block;
  margin-top: 6px;
  color: var(--text);
  letter-spacing: -0.01em;
}

/* --- Tables ----------------------------------------------- */
.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: var(--radius-sm);
  /* Scroll hint gradient */
  background:
    linear-gradient(to right, var(--card) 4px, transparent 4px),
    linear-gradient(to left, var(--card) 4px, transparent 4px) right,
    radial-gradient(farthest-side at left center, rgba(0,0,0,0.10), transparent) left,
    radial-gradient(farthest-side at right center, rgba(0,0,0,0.10), transparent) right;
  background-repeat: no-repeat;
  background-size: 20px 100%, 20px 100%, 12px 100%, 12px 100%;
  background-attachment: local, local, scroll, scroll;
}
table { width: 100%; border-collapse: collapse; }
thead { background: #f8fafc; }
th {
  text-align: left;
  padding: 10px 14px;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
}
td {
  padding: 12px 14px;
  font-size: 0.88rem;
  border-bottom: 1px solid var(--border-light);
  color: var(--text);
  vertical-align: middle;
}
tbody tr {
  transition: background var(--transition);
}
tbody tr:hover {
  background: #f8fafc;
}
tbody tr:last-child td {
  border-bottom: none;
}

/* --- Status Badges ---------------------------------------- */
.status {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  font-size: 0.73rem;
  font-weight: 650;
  letter-spacing: 0.02em;
  white-space: nowrap;
}
.status.APPROVED { background: var(--ok-light); color: var(--ok-dark); }
.status.PENDING { background: var(--warn-light); color: var(--warn-dark); }
.status.REJECTED { background: var(--danger-light); color: var(--danger-dark); }
.status.CANCELLED { background: #f1f5f9; color: #64748b; }

/* --- Toast ------------------------------------------------ */
.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  background: var(--text);
  color: #fff;
  padding: 12px 20px;
  border-radius: var(--radius-md);
  font-size: 0.88rem;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  z-index: 200;
  animation: toastIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  max-width: calc(100vw - 48px);
}
@keyframes toastIn {
  from { opacity: 0; transform: translateY(12px) scale(0.95); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* --- Inline Actions & Row --------------------------------- */
.inline-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.inline-actions button,
#employees-body button {
  padding: 6px 12px;
  font-size: 0.82rem;
}
.row-inline {
  display: flex;
  align-items: flex-end;
  gap: 12px;
}
#employees-body input[type='number'],
#employees-body select {
  min-width: 100px;
}
#policies-body input,
#policies-body select {
  min-width: 90px;
}
.row-inline.wrap label {
  min-width: 140px;
}


/* --- Calendar --------------------------------------------- */
.calendar-header-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
  flex-wrap: wrap;
  margin-bottom: 4px;
}
.calendar-nav {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.calendar-nav button {
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
}
.calendar-nav strong {
  min-width: 160px;
  text-align: center;
  text-transform: capitalize;
  font-size: 0.95rem;
}

/* Calendar legend */
.calendar-legend {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin: 8px 0 4px;
}
.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.75rem;
  color: var(--text-secondary);
  font-weight: 500;
}
.legend-item::before {
  content: '';
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 3px;
  flex-shrink: 0;
}
.legend-approved::before { background: var(--ok-light); border: 1px solid #86efac; }
.legend-pending::before { background: var(--warn-light); border: 1px solid #fcd34d; }
.legend-holiday::before { background: #f3e8ff; border: 1px solid #a855f7; }
.legend-selected::before { background: var(--primary-light); border: 1px solid var(--primary); }

.employee-calendar-weekdays {
  margin-top: 12px;
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
  text-align: center;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border-light);
}

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

.employee-calendar-day {
  min-height: 44px;
  border: 1.5px solid transparent;
  background: var(--card);
  color: var(--text);
  padding: 8px 4px;
  border-radius: var(--radius-sm);
  font-weight: 500;
  font-size: 0.85rem;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
  cursor: pointer;
  transition: all var(--transition);
  text-align: center;
}
.employee-calendar-day:hover {
  background: var(--primary-surface);
  border-color: var(--primary);
}
.employee-calendar-day:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 1px;
}
.employee-calendar-day.outside {
  opacity: 0.3;
}
.employee-calendar-day.holiday {
  box-shadow: inset 0 0 0 2px #a855f7;
}
.employee-calendar-day.weekend {
  background: #f8fafc;
}
.employee-calendar-day.non-selectable,
.employee-calendar-day:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}
.employee-calendar-day.non-selectable:hover,
.employee-calendar-day:disabled:hover {
  background: #f8fafc;
  border-color: transparent;
}
.employee-calendar-day.status-approved {
  background: var(--ok-light);
  border-color: #86efac;
  color: var(--ok-dark);
  font-weight: 600;
}
.employee-calendar-day.status-pending {
  background: var(--warn-light);
  border-color: #fcd34d;
  color: var(--warn-dark);
  font-weight: 600;
}
.employee-calendar-day.selected-range {
  background: var(--primary-light);
  border-color: var(--primary);
  color: var(--primary);
  font-weight: 700;
  box-shadow: 0 0 0 2px rgba(79, 110, 247, 0.15);
}


/* ============================================================
   Admin Panel – Desktop Persistent Sidebar
   ============================================================ */
.admin-panel {
  display: grid;
  gap: 16px;
}

.admin-layout {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  gap: 20px;
  align-items: start;
}

/* --- Sidebar ---------------------------------------------- */
.admin-sidebar {
  position: sticky;
  top: 20px;
  border-radius: var(--radius-lg);
  padding: 20px;
  max-height: calc(100vh - 40px);
  overflow-y: auto;
  scrollbar-width: thin;
}
.admin-sidebar::-webkit-scrollbar { width: 4px; }
.admin-sidebar::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

.admin-sidebar > .chip {
  margin-bottom: 16px;
}
.admin-sidebar > h3 {
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin-bottom: 12px;
}

.admin-subnav-group {
  display: grid;
  gap: 4px;
  margin-bottom: 16px;
}
.admin-group-title {
  margin: 0;
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  color: var(--muted);
  text-transform: uppercase;
  font-weight: 700;
  padding: 8px 0 4px;
  border-top: 1px solid var(--border-light);
}
.admin-subnav-group:first-of-type .admin-group-title {
  border-top: none;
  padding-top: 0;
}
.admin-subnav {
  display: grid;
  gap: 2px;
}
.admin-subnav button {
  text-align: left;
  padding: 8px 10px;
  font-size: 0.84rem;
  font-weight: 500;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-secondary);
  box-shadow: none;
  transition: all var(--transition);
  justify-content: flex-start;
  gap: 8px;
}
.admin-subnav button:hover {
  background: var(--primary-light);
  color: var(--primary);
  transform: none;
  box-shadow: none;
}
.admin-subnav button.active {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 2px 8px rgba(79, 110, 247, 0.25);
}

.admin-sidebar-toggle {
  display: none;
}
.admin-sidebar-head {
  display: none;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}
.admin-sidebar-head h3 { margin: 0; }
.admin-sidebar-close {
  display: none;
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: var(--radius-sm);
  font-size: 1.1rem;
}
.admin-sidebar-backdrop { display: none; }

.admin-content {
  display: grid;
  gap: 16px;
  min-width: 0;
}
.admin-section {
  grid-template-columns: 1fr;
}

/* --- Modal ------------------------------------------------ */
.modal {
  position: fixed;
  inset: 0;
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(26, 35, 50, 0.55);
  backdrop-filter: blur(3px);
  z-index: 0;
}
.modal-box {
  position: relative;
  z-index: 1;
  max-width: 560px;
  width: 100%;
  border-radius: var(--radius-xl);
  padding: 0;
  overflow: hidden;
  animation: modalIn 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}
@keyframes modalIn {
  from { opacity: 0; transform: scale(0.95) translateY(12px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--border);
}
.modal-header h3 { margin: 0; font-size: 1rem; }
.modal-body {
  padding: 20px 24px;
  font-size: 0.87rem;
  line-height: 1.6;
  color: var(--text-secondary);
  max-height: 60vh;
  overflow-y: auto;
}
.modal-body p strong { color: var(--text); }
.modal-footer {
  padding: 16px 24px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
}

/* ============================================================
   RESPONSIVE: Tablet (max-width: 1024px)
   ============================================================ */
@media (max-width: 1024px) {
  .layout {
    padding: 32px 16px;
  }

  .two-col {
    grid-template-columns: 1fr;
  }

  .admin-layout {
    grid-template-columns: 1fr;
  }

  /* Sidebar collapses on tablet */
  .admin-sidebar-toggle {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    position: sticky;
    top: 12px;
    z-index: 25;
    box-shadow: var(--shadow-md);
    width: fit-content;
  }
  .admin-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: min(84vw, 320px);
    max-width: 320px;
    border-radius: 0 var(--radius-lg) var(--radius-lg) 0;
    z-index: 50;
    overflow-y: auto;
    transform: translateX(-105%);
    transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: var(--shadow-xl);
    padding: 24px 20px;
  }
  .admin-sidebar.open {
    transform: translateX(0);
  }
  .admin-sidebar-head {
    display: flex;
  }
  .admin-sidebar-close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }
  .admin-sidebar-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(26, 35, 50, 0.5);
    z-index: 40;
    backdrop-filter: blur(2px);
  }
  .admin-sidebar-backdrop.visible {
    display: block;
  }
}

/* ============================================================
   RESPONSIVE: Mobile (max-width: 640px)
   ============================================================ */
@media (max-width: 640px) {
  :root {
    --navbar-h: 56px;
  }

  body {
    font-size: 13.5px;
  }

  .bg-accent {
    height: 200px;
  }

  .layout {
    padding: 16px 12px 24px;
  }

  .card {
    padding: 16px;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
  }

  /* Auth mobile */
  .auth-card {
    margin-top: 32px;
    padding: 28px 20px;
    border-radius: var(--radius-lg);
  }
  .auth-card h1 {
    font-size: 1.6rem;
  }
  .auth-logo-icon svg {
    width: 32px;
    height: 32px;
  }

  /* Dashboard header mobile — stack vertically */
  .dashboard-header {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
    padding: 20px 16px;
    border-radius: var(--radius-lg);
  }
  .dashboard-header h2 {
    font-size: 1.15rem;
  }
  .dashboard-header .helper {
    display: none; /* save space on mobile */
  }
  .dashboard-header-actions {
    justify-content: flex-start;
    gap: 8px;
    flex-wrap: wrap;
  }
  .dashboard-header #logout-btn,
  .dashboard-header #admin-view-btn {
    font-size: 0.82rem;
    padding: 8px 14px;
    min-height: 36px;
  }

  /* Tables mobile — better spacing */
  th, td {
    padding: 8px 10px;
    font-size: 0.82rem;
  }
  th {
    font-size: 0.7rem;
  }

  /* Touch-friendly inputs */
  input, select, textarea, button {
    min-height: 44px;
    font-size: 16px; /* Prevents iOS zoom on focus */
  }
  label {
    font-size: 0.82rem;
  }
  .helper {
    font-size: 0.78rem;
  }
  .optional-label {
    font-size: 0.74rem;
  }

  /* Sticky submit button inside forms on mobile */
  .btn-submit-sticky {
    position: sticky;
    bottom: 12px;
    z-index: 10;
    width: 100%;
    box-shadow: 0 4px 16px rgba(79, 110, 247, 0.35);
  }

  /* Metrics */
  .metrics {
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }
  .metric {
    padding: 12px;
  }
  .metric b {
    font-size: 1.25rem;
  }
  .metric small {
    font-size: 0.72rem;
  }

  /* Calendar mobile */
  .employee-calendar-day {
    min-height: 36px;
    padding: 4px 2px;
    font-size: 0.78rem;
    border-radius: 6px;
  }
  .employee-calendar-weekdays {
    font-size: 0.65rem;
    margin-top: 8px;
  }
  .calendar-header-row {
    flex-direction: column;
    gap: 10px;
  }
  .calendar-nav {
    width: 100%;
    justify-content: space-between;
  }
  .calendar-nav strong {
    min-width: auto;
    flex: 1;
    text-align: center;
    font-size: 0.9rem;
  }
  .calendar-legend {
    gap: 10px;
  }
  .legend-item {
    font-size: 0.7rem;
  }

  /* Row inline mobile */
  .row-inline {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }
  .row-inline.wrap label {
    min-width: auto;
  }
  .row-inline button {
    width: 100%;
    min-height: 44px;
  }

  /* Admin sidebar mobile */
  .admin-panel {
    padding-top: 0;
  }
  .admin-sidebar-toggle {
    position: sticky;
    top: 8px;
    left: 0;
    z-index: 25;
    box-shadow: var(--shadow-lg);
    font-size: 0.82rem;
    padding: 8px 16px;
    min-height: 44px;
    width: 100%;
    justify-content: center;
    border-radius: var(--radius-md);
    margin-bottom: 4px;
  }

  /* Toast mobile */
  .toast {
    left: 12px;
    right: 12px;
    bottom: calc(env(safe-area-inset-bottom, 0px) + 12px);
    text-align: center;
    font-size: 0.84rem;
  }

  /* Two col stacks */
  .two-col {
    grid-template-columns: 1fr;
  }

  h1 { font-size: 1.35rem; }
  h2 { font-size: 1.1rem; }
  h3 { font-size: 0.95rem; }
  h4 { font-size: 0.85rem; }

  /* Modal mobile */
  .modal {
    padding: 12px;
    align-items: flex-end;
  }
  .modal-box {
    border-radius: var(--radius-lg) var(--radius-lg) var(--radius-md) var(--radius-md);
    max-width: 100%;
  }
  .modal-body {
    max-height: 55vh;
    font-size: 0.84rem;
    padding: 16px;
  }
  .modal-header, .modal-footer {
    padding: 16px;
  }

  /* Admin table compact */
  #admin-pending-body td:nth-child(3),
  #calendar-body td:nth-child(3) {
    display: none; /* hide "Tipo" col on very small screens */
  }
  #admin-pending-body th:nth-child(3),
  #calendar-body th:nth-child(3) {
    display: none;
  }

}

/* ============================================================
   RESPONSIVE: Desktop wide (min-width: 1280px)
   ============================================================ */
@media (min-width: 1280px) {
  .layout {
    max-width: 1320px;
    padding: 48px 32px;
  }
  .auth-card {
    margin-top: 100px;
  }
  .dashboard-header {
    padding: 32px 40px;
  }
  .admin-layout {
    gap: 28px;
  }
  .admin-sidebar {
    width: 280px;
    padding: 24px;
  }
}

/* ============================================================
   Print styles
   ============================================================ */
@media print {
  .bg-accent,
  .admin-sidebar,
  .admin-sidebar-toggle,
  .toast,
  button,
  .modal { display: none !important; }
  .layout { max-width: 100%; padding: 0; }
  .card { box-shadow: none; border: 1px solid #ccc; break-inside: avoid; }
  a { color: inherit; }
}


/* ============================================================
   AG Grid — design-system integration
   ============================================================ */

/* Hide the raw HTML table that acts as data source */
.table-wrap table.ag-grid-source-table {
  display: none;
}

/* ── Grid container ──────────────────────────────────────── */
.feriepro-ag-grid {
  width: 100%;

  /* Typography */
  --ag-font-family: var(--font);
  --ag-font-size: 13px;

  /* Background */
  --ag-background-color: var(--card);
  --ag-foreground-color: var(--text);
  --ag-secondary-foreground-color: var(--text-secondary);

  /* Header */
  --ag-header-background-color: var(--bg-subtle);
  --ag-header-foreground-color: var(--text-secondary);
  --ag-header-height: 40px;
  --ag-header-column-resize-handle-color: var(--border);

  /* Rows */
  --ag-row-height: 44px;
  --ag-row-border-color: var(--border-light);
  --ag-odd-row-background-color: var(--card);
  --ag-row-hover-color: var(--primary-surface);
  --ag-selected-row-background-color: var(--primary-light);

  /* Borders */
  --ag-border-color: var(--border);
  --ag-cell-horizontal-border: none;
  --ag-range-selection-border-color: var(--primary);

  /* Filter inputs */
  --ag-input-focus-border-color: var(--primary);
  --ag-input-border-color: var(--border);

  /* Icons */
  --ag-icon-color: var(--muted);

  /* Padding */
  --ag-cell-horizontal-padding: 14px;

  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  background: var(--card);
}

/* ── Header ──────────────────────────────────────────────── */
.feriepro-ag-grid .ag-header {
  border-bottom: 1px solid var(--border);
}

.feriepro-ag-grid .ag-header-cell-label {
  font-size: 0.71rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.feriepro-ag-grid .ag-header-cell:hover .ag-header-cell-label {
  color: var(--text-secondary);
}

.feriepro-ag-grid .ag-sort-indicator-icon .ag-icon {
  color: var(--primary);
}

/* ── Floating filter row ─────────────────────────────────── */
.feriepro-ag-grid .ag-floating-filter-input input {
  font-family: var(--font);
  font-size: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 3px 8px;
  height: 26px;
  background: var(--card);
  color: var(--text);
  transition: border-color var(--transition), box-shadow var(--transition);
}

.feriepro-ag-grid .ag-floating-filter-input input:focus {
  border-color: var(--primary);
  outline: none;
  box-shadow: 0 0 0 3px rgba(79, 110, 247, 0.12);
}

/* ── Cells ───────────────────────────────────────────────── */
.feriepro-ag-grid .ag-cell {
  display: flex;
  align-items: center;
  line-height: 1.4;
}

.feriepro-ag-grid .ag-cell strong {
  font-weight: 600;
}

/* Status badge inside cell */
.feriepro-ag-grid .status {
  margin: 0;
}

/* ── Row states ──────────────────────────────────────────── */
.feriepro-ag-grid .ag-row-selected {
  background-color: var(--primary-light) !important;
}

/* ── Action buttons inside cells ─────────────────────────── */
.feriepro-ag-grid .ag-cell .btn {
  min-height: 28px;
  font-size: 0.78rem;
  padding: 4px 10px;
}

.feriepro-ag-grid .ag-cell .btn + .btn {
  margin-left: 6px;
}

/* ── No-rows overlay ─────────────────────────────────────── */
.feriepro-ag-grid .ag-overlay-no-rows-wrapper {
  padding: 48px 20px;
}

.ag-no-rows-msg {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 0.85rem;
}

.ag-no-rows-msg svg {
  opacity: 0.35;
}

/* ── Custom scrollbar ────────────────────────────────────── */
.feriepro-ag-grid ::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

.feriepro-ag-grid ::-webkit-scrollbar-track {
  background: var(--bg-subtle);
}

.feriepro-ag-grid ::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}

.feriepro-ag-grid ::-webkit-scrollbar-thumb:hover {
  background: var(--muted);
}

/* ── Mobile (≤ 640px) ────────────────────────────────────── */
@media (max-width: 640px) {
  .feriepro-ag-grid {
    --ag-font-size: 12px;
    --ag-row-height: 40px;
    --ag-header-height: 34px;
    --ag-cell-horizontal-padding: 10px;
    border-radius: var(--radius-sm);
    box-shadow: none;
  }

  .feriepro-ag-grid .ag-header-cell-label {
    font-size: 0.63rem;
    letter-spacing: 0.04em;
  }

  .feriepro-ag-grid .ag-floating-filter-input input {
    height: 22px;
    font-size: 11px;
    padding: 2px 6px;
  }

  .feriepro-ag-grid .ag-cell .btn {
    font-size: 0.74rem;
    padding: 3px 8px;
    min-height: 26px;
  }
}

/* ── Tablet (641 – 1024px) ───────────────────────────────── */
@media (min-width: 641px) and (max-width: 1024px) {
  .feriepro-ag-grid {
    --ag-font-size: 12.5px;
    --ag-cell-horizontal-padding: 12px;
  }
}
