/* Import Modern Typography */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=Outfit:wght@400;500;600;700;800&display=swap');

/* Color Variables and Reset */
:root {
  --font-heading: 'Outfit', sans-serif;
  --font-body: 'Inter', sans-serif;

  /* HSL Corporate Dark Colors (Graphite & Slate theme) */
  --bg-primary-hsl: 220, 16%, 8%;     /* #0b0f17 (Deep graphite charcoal) */
  --bg-secondary-hsl: 220, 14%, 13%;   /* #151f32 (Slate card background) */
  --bg-tertiary-hsl: 220, 12%, 18%;    /* #242f47 (Input and hover background) */
  
  --bg-primary: hsl(var(--bg-primary-hsl));
  --bg-secondary: hsl(var(--bg-secondary-hsl));
  --bg-tertiary: hsl(var(--bg-tertiary-hsl));
  
  /* Corporate Accents (Steel Blue - Sleek, Professional) */
  --accent-cyan: 217, 91%, 60%;      /* #3b82f6 (Steel Blue) */
  --accent-indigo: 224, 76%, 48%;    /* #1e3a8a (Navy) */
  --accent-gradient: linear-gradient(135deg, hsl(217, 91%, 60%) 0%, hsl(224, 76%, 48%) 100%);
  
  /* Text */
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  
  /* Statuses (Professional Muted Colors) */
  --status-active: #10b981;      /* Green */
  --status-maintenance: #f59e0b; /* Amber */
  --status-inactive: #ef4444;    /* Red */
  
  --border-glow: rgba(59, 130, 246, 0.1);
  --border-light: rgba(255, 255, 255, 0.06);
  
  --shadow-main: 0 8px 30px rgba(0, 0, 0, 0.4);
  --shadow-glow: 0 0 15px rgba(59, 130, 246, 0.1);
  
  --transition-smooth: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);

  /* Accent primary alias (used by tab-btn-active) */
  --accent-primary: #3b82f6;
}

/* Light Theme Variable Overrides */
body.light-theme {
  --bg-primary-hsl: 210, 40%, 98%;   /* #f8fafc (Clean soft slate-grey backdrop) */
  --bg-secondary-hsl: 0, 0%, 100%;    /* #ffffff (White cards/sidebar) */
  --bg-tertiary-hsl: 210, 20%, 95%;   /* #f1f5f9 (Input/hover background) */
  
  --bg-primary: hsl(var(--bg-primary-hsl));
  --bg-secondary: hsl(var(--bg-secondary-hsl));
  --bg-tertiary: hsl(var(--bg-tertiary-hsl));
  
  --text-primary: #0f172a;            /* Dark slate primary text */
  --text-secondary: #475569;          /* Medium slate grey text */
  --text-muted: #94a3b8;              /* Slate grey muted text */
  
  --border-light: rgba(15, 23, 42, 0.08); /* Clean grey border lines */
  --border-glow: rgba(37, 99, 235, 0.12);
  
  --shadow-main: 0 4px 20px -2px rgba(15, 23, 42, 0.05);

  /* Explicit overrides to ensure browser picks up the change */
  background-color: #f8fafc;
  color: #0f172a;
}

/* Light Theme Component Overrides */
body.light-theme header,
body.light-theme .topbar {
  background: rgba(255, 255, 255, 0.85) !important;
  border-bottom: 1px solid rgba(0, 0, 0, 0.08) !important;
}

body.light-theme .topbar-title {
  color: #0f172a !important;
}

body.light-theme .sidebar-logo h2 {
  color: #0f172a !important;
}

body.light-theme .logo-icon {
  background: #1e3a8a !important; /* Corporate Navy */
  color: #ffffff !important;
  box-shadow: none !important;
}

body.light-theme .btn-primary {
  background: #2563eb !important; /* Corporate Royal Blue */
  color: #ffffff !important;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.15) !important;
}

body.light-theme .btn-primary:hover {
  background: #1d4ed8 !important;
  box-shadow: 0 6px 16px rgba(37, 99, 235, 0.25) !important;
}

body.light-theme .btn-secondary {
  border-color: rgba(0, 0, 0, 0.15) !important;
  color: #0f172a !important;
  background: #ffffff !important;
}

body.light-theme .btn-secondary:hover {
  background: #f9fafb !important;
  border-color: rgba(0, 0, 0, 0.25) !important;
}

body.light-theme .btn-settings {
  background: rgba(0, 0, 0, 0.04) !important;
  border: 1px solid rgba(0, 0, 0, 0.08) !important;
  color: #4b5563 !important;
}

body.light-theme .btn-settings:hover {
  background: rgba(0, 0, 0, 0.08) !important;
  color: #0f172a !important;
}

body.light-theme th {
  background: rgba(229, 231, 235, 0.6) !important;
  color: #1f2937 !important;
  border-bottom: 1px solid rgba(0, 0, 0, 0.1) !important;
}

body.light-theme tr:hover td {
  background: rgba(0, 0, 0, 0.01) !important;
}

body.light-theme .sidebar-link {
  color: #4b5563 !important;
}

body.light-theme .sidebar-link:hover {
  background: rgba(0, 0, 0, 0.03) !important;
  color: #1f2937 !important;
}

body.light-theme .sidebar-link.active {
  color: #4f46e5 !important;
  background: rgba(79, 70, 229, 0.08) !important;
  border-left-color: #4f46e5 !important;
}

body.light-theme .sidebar {
  border-right: 1px solid rgba(0, 0, 0, 0.08) !important;
  background: #ffffff !important;
}

body.light-theme .table-input {
  color: #1f2937 !important;
}

body.light-theme .table-input option {
  background: #ffffff !important;
  color: #1f2937 !important;
}

body.light-theme .search-input {
  background: #ffffff !important;
  border-color: rgba(0, 0, 0, 0.12) !important;
  color: #1f2937 !important;
}

body.light-theme .search-input:focus {
  background: #ffffff !important;
  border-color: #4f46e5 !important;
  box-shadow: 0 0 0 2px rgba(79, 70, 229, 0.15) !important;
}

body.light-theme .filter-select {
  background: #ffffff !important;
  border-color: rgba(0, 0, 0, 0.12) !important;
  color: #1f2937 !important;
}

body.light-theme .stat-card {
  background: #ffffff !important;
  border: 1px solid rgba(0, 0, 0, 0.06) !important;
  box-shadow: 0 4px 20px -2px rgba(0, 0, 0, 0.04) !important;
}

body.light-theme .table-card {
  background: #ffffff !important;
  border: 1px solid rgba(0, 0, 0, 0.06) !important;
}

body.light-theme dialog {
  background: #ffffff !important;
  color: #1f2937 !important;
  border: 1px solid rgba(0, 0, 0, 0.1) !important;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15) !important;
}

body.light-theme .dialog-header {
  border-bottom: 1px solid rgba(0, 0, 0, 0.08) !important;
}

body.light-theme .dialog-footer {
  border-top: 1px solid rgba(0, 0, 0, 0.08) !important;
  background: #f9fafb !important;
}

body.light-theme .dialog-section-title {
  color: #4f46e5 !important;
  border-bottom: 1px solid rgba(0, 0, 0, 0.08) !important;
}

body.light-theme .form-control {
  background: #f9fafb !important;
  border-color: rgba(0, 0, 0, 0.12) !important;
  color: #1f2937 !important;
}

body.light-theme .form-control:focus {
  border-color: #4f46e5 !important;
  background: #ffffff !important;
}

body.light-theme .settings-info {
  background: rgba(79, 70, 229, 0.05) !important;
  border-color: rgba(79, 70, 229, 0.15) !important;
  color: #4f46e5 !important;
}

body.light-theme .tab-btn {
  color: #4b5563 !important;
}

body.light-theme .tab-btn:hover {
  color: #1f2937 !important;
}

body.light-theme .tab-btn.active {
  color: #4f46e5 !important;
}

body.light-theme .tab-btn.tab-btn-active {
  color: #ffffff !important;
}

/* Badges for Light Theme */
body.light-theme .badge-demo {
  background: rgba(245, 158, 11, 0.12) !important;
  color: #b45309 !important;
  border: 1px solid rgba(245, 158, 11, 0.25) !important;
}

body.light-theme .badge-supabase {
  background: rgba(16, 185, 129, 0.12) !important;
  color: #047857 !important;
  border: 1px solid rgba(16, 185, 129, 0.25) !important;
}

/* Cell warnings highlighting overrides for high contrast and readability */
body.light-theme .cell-expired {
  background-color: rgba(239, 68, 68, 0.1) !important;
  color: #b91c1c !important; /* Deep Dark Red */
}

body.light-theme .cell-warning {
  background-color: rgba(245, 158, 11, 0.08) !important;
  color: #b45309 !important; /* Deep Dark Amber */
}

body.light-theme .cell-valid {
  background-color: rgba(16, 185, 129, 0.06) !important;
  color: #047857 !important; /* Deep Dark Green */
}

body.light-theme .cell-missing {
  background-color: rgba(100, 116, 139, 0.08) !important;
  color: #475569 !important;
}

/* Hide theme icons based on active state */
body.light-theme .theme-icon-light {
  display: none;
}

body:not(.light-theme) .theme-icon-dark {
  display: none;
}

/* Sticky Table Header for Trips
   Note: sticky is relative to #table-trips-card .table-wrapper (overflow scrollport),
   NOT the page/topbar — so tops start at 0. */
#table-trips {
  --trips-thead-h: 44px;
  --trips-date-h: 40px;
}

#table-trips thead th {
  position: sticky;
  top: 0;
  z-index: 15;
  height: var(--trips-thead-h);
  padding-top: 0;
  padding-bottom: 0;
  line-height: var(--trips-thead-h);
  box-sizing: border-box;
  background: var(--bg-secondary) !important;
  border-bottom: 1px solid var(--border-light);
  white-space: nowrap;
}

/* Date group header: sticks under column headers; next date pushes previous away */
.group-header-row td {
  position: sticky;
  top: var(--trips-thead-h);
  z-index: 14;
  height: var(--trips-date-h) !important;
  padding: 0 12px !important;
  box-sizing: border-box;
  vertical-align: middle;
  background: var(--bg-secondary) !important;
  background-image: linear-gradient(
    color-mix(in srgb, #4f46e5 12%, transparent),
    color-mix(in srgb, #4f46e5 12%, transparent)
  ) !important;
  color: #818cf8 !important;
  border-bottom: 1px solid var(--border-light) !important;
  border-top: 1px solid var(--border-light) !important;
  box-shadow: 0 6px 10px -6px rgba(0, 0, 0, 0.45);
}

/* Trip data rows stay under sticky date (no hover paint-over) */
#table-trips tbody tr:not(.group-header-row):hover td {
  background: color-mix(in srgb, var(--bg-tertiary) 55%, transparent);
}

.group-header-row td div,
.group-header-row td span {
  color: #818cf8 !important;
}

.group-header-row td i,
.group-header-row td svg {
  color: #818cf8 !important;
}

.group-header-row td span[style*="var(--text-secondary)"] {
  color: var(--text-secondary) !important;
}

body.light-theme .group-header-row td {
  background: var(--bg-secondary) !important;
  background-image: linear-gradient(
    color-mix(in srgb, #4f46e5 8%, transparent),
    color-mix(in srgb, #4f46e5 8%, transparent)
  ) !important;
  color: #4f46e5 !important;
  box-shadow: 0 6px 10px -6px rgba(15, 23, 42, 0.18);
}

body.light-theme .group-header-row td div,
body.light-theme .group-header-row td span {
  color: #4f46e5 !important;
}

body.light-theme .group-header-row td i,
body.light-theme .group-header-row td svg {
  color: #4f46e5 !important;
}

body.light-theme .group-header-row td span[style*="var(--text-secondary)"] {
  color: #4b5563 !important;
}

/* Toast Notifications for Light Theme */
body.light-theme .toast {
  background: rgba(255, 255, 255, 0.95) !important;
  border-color: rgba(0, 0, 0, 0.08) !important;
  color: #1f2937 !important;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.08) !important;
}

body.light-theme .toast i,
body.light-theme .toast svg {
  color: #4b5563 !important;
}

body.light-theme .toast.toast-success {
  border-left-color: #10b981 !important;
}

body.light-theme .toast.toast-error {
  border-left-color: #ef4444 !important;
}

body.light-theme .toast.toast-warning {
  border-left-color: #f59e0b !important;
}

body.light-theme .toast.toast-info {
  border-left-color: #3b82f6 !important;
}

/* Salaries Summary Card & Checkbox overrides for Light Theme */
body.light-theme .summary-card {
  background: #ffffff !important;
  border-color: rgba(0, 0, 0, 0.08) !important;
  color: var(--text-primary) !important;
  box-shadow: 0 4px 20px -2px rgba(0, 0, 0, 0.05) !important;
}

body.light-theme .summary-text {
  color: #4b5563 !important;
}

body.light-theme .summary-amount {
  color: #d97706 !important; /* Keep warning color readable on light bg */
}

body.light-theme .table-checkbox-label {
  color: #4b5563 !important;
}

body.light-theme .table-checkbox-label input[type="checkbox"] {
  accent-color: #4f46e5 !important;
}

/* Status Pills for Light Theme */
body.light-theme .status-active-pill {
  background: rgba(16, 185, 129, 0.12) !important;
  color: #047857 !important;
}

body.light-theme .status-maintenance-pill {
  background: rgba(245, 158, 11, 0.12) !important;
  color: #b45309 !important;
}

body.light-theme .status-inactive-pill {
  background: rgba(239, 68, 68, 0.12) !important;
  color: #b91c1c !important;
}

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

body {
  font-family: var(--font-body);
  background-color: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  display: flex;
  flex-direction: row;
  line-height: 1.5;
  overflow-x: clip; /* clip keeps sticky working; hidden would force a scroll container */
}

/* Scrollbar Styling */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: var(--bg-primary);
}
::-webkit-scrollbar-thumb {
  background: var(--bg-tertiary);
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: hsl(var(--accent-indigo));
}

/* Sidebar Layout */
.sidebar {
  width: 260px;
  background-color: var(--bg-secondary);
  border-right: 1px solid var(--border-light);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 1.75rem 1.25rem;
  z-index: 110;
  flex-shrink: 0;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.25rem 0.5rem 2.25rem 0.5rem;
}

.sidebar-logo h2 {
  font-family: var(--font-heading);
  font-size: 1.3rem;
  font-weight: 800;
  letter-spacing: -0.5px;
  color: var(--text-primary);
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  flex: 1;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.8rem 1rem;
  color: var(--text-secondary);
  border-radius: 10px;
  text-decoration: none;
  font-weight: 500;
  font-size: 0.95rem;
  transition: var(--transition-smooth);
  border-left: 3px solid transparent;
}

.sidebar-link i {
  width: 18px;
  height: 18px;
  color: var(--text-muted);
  transition: var(--transition-smooth);
}

.sidebar-link:hover {
  background-color: var(--bg-tertiary);
  color: var(--text-primary);
}

.sidebar-link:hover i {
  color: var(--text-secondary);
}

.sidebar-link.active {
  background-color: rgba(59, 130, 246, 0.08);
  color: #93c5fd;
  border-left: 3px solid #3b82f6;
  padding-left: calc(1rem - 3px);
  font-weight: 600;
}

.sidebar-link.active i {
  color: #3b82f6;
}

.sidebar-footer {
  padding-top: 1rem;
  border-top: 1px solid var(--border-light);
  font-size: 0.75rem;
  color: var(--text-muted);
  text-align: center;
}

/* Main Content Wrapper */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 100vh;
}

/* Header & Top Bar */
header, .topbar {
  background: rgba(15, 21, 39, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-light);
  padding: 1.25rem 2rem;
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  justify-content: space-between;
  align-items: center;
  height: 72px;
}

.topbar-title {
  font-family: var(--font-heading);
  font-size: 1.4rem;
  font-weight: 700;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 1rem;
}


/* Header Navigation Menu */
.header-nav {
  display: flex;
  gap: 1rem;
}

.nav-link {
  color: var(--text-secondary);
  text-decoration: none;
  font-family: var(--font-heading);
  font-weight: 600;
  font-size: 0.95rem;
  padding: 0.5rem 1rem;
  border-radius: 8px;
  border: 1px solid transparent;
  transition: var(--transition-smooth);
}

.nav-link:hover {
  color: var(--text-primary);
  background: var(--bg-tertiary);
}

.nav-link.active {
  color: hsl(var(--accent-cyan));
  background: rgba(0, 242, 254, 0.05);
  border-color: rgba(0, 242, 254, 0.2);
}

.logo-section {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.logo-icon {
  background: hsl(var(--accent-cyan));
  width: 40px;
  height: 40px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #ffffff;
}

.logo-section h1 {
  font-family: var(--font-heading);
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.5px;
  color: var(--text-primary);
}

.db-status-bar {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.85rem;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.2px;
  text-transform: uppercase;
  transition: var(--transition-smooth);
}

.badge-demo {
  background: rgba(245, 158, 11, 0.1);
  color: var(--status-maintenance);
  border: 1px solid rgba(245, 158, 11, 0.2);
}

.badge-supabase {
  background: rgba(16, 185, 129, 0.1);
  color: var(--status-active);
  border: 1px solid rgba(16, 185, 129, 0.2);
}

.badge::before {
  content: '';
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 8px currentColor;
}

.btn-settings {
  background: var(--bg-tertiary);
  border: 1px solid var(--border-light);
  color: var(--text-primary);
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition-smooth);
}

.btn-settings:hover {
  border-color: hsl(var(--accent-cyan));
  color: hsl(var(--accent-cyan));
  box-shadow: var(--border-glow);
  transform: rotate(30deg);
}

/* Dashboard Wrapper */
main {
  max-width: 1300px;
  width: 100%;
  margin: 0 auto;
  padding: 2rem;
  flex: 1;
}

/* Statistics Grid */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1.5rem;
  margin-bottom: 2.5rem;
}

.stat-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-light);
  border-radius: 16px;
  padding: 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: var(--shadow-main);
  position: relative;
  overflow: hidden;
  transition: var(--transition-smooth);
}

.stat-card:hover {
  transform: translateY(-4px);
  border-color: rgba(255, 255, 255, 0.15);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.4);
}

.stat-card::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 4px;
  height: 100%;
  background: var(--accent-gradient);
}

.stat-info h3 {
  font-size: 0.85rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 0.5rem;
}

.stat-value {
  font-family: var(--font-heading);
  font-size: 2rem;
  font-weight: 700;
  line-height: 1;
}

.stat-icon {
  background: var(--bg-tertiary);
  color: hsl(var(--accent-cyan));
  width: 48px;
  height: 48px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
}

/* Tab Navigation */
.tabs-navigation {
  display: flex;
  border-bottom: 1px solid var(--border-light);
  gap: 2rem;
  margin-bottom: 2rem;
}

.tab-btn {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-family: var(--font-heading);
  font-size: 1.15rem;
  font-weight: 600;
  padding: 1rem 0.5rem;
  cursor: pointer;
  position: relative;
  transition: var(--transition-smooth);
}

.tab-btn:hover {
  color: var(--text-primary);
}

.tab-btn.active {
  color: hsl(var(--accent-cyan));
}

.tab-btn.active::after {
  content: '';
  position: absolute;
  bottom: -1px;
  left: 0;
  width: 100%;
  height: 2px;
  background: var(--accent-gradient);
  box-shadow: 0 0 10px rgba(0, 242, 254, 0.5);
}

/* Tab Panels */
.tab-panel {
  display: none;
  animation: fadeIn 0.4s ease-out;
}

.tab-panel.active {
  display: block;
}

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

/* Directory Header & Toolbar */
.directory-toolbar {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: 16px;
  padding: 1.25rem;
  margin-bottom: 1.75rem;
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.25rem;
  flex-wrap: wrap;
}

.search-filter-group {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  flex: 1;
  max-width: none !important;
  width: 100%;
}

.search-filter-group > * {
  margin: 0;
}

/* Individual Filter Item Sizing */
.search-filter-group .search-wrapper {
  flex: 2 1 240px;
  max-width: 360px;
}

.search-filter-group .custom-select-container,
.search-filter-group select {
  height: 42px;
}

.search-filter-group .custom-select-container[data-for="filter-trips-driver"],
.search-filter-group select#filter-trips-driver {
  flex: 1.5 1 180px;
  max-width: 260px;
}

.search-filter-group .custom-select-container[data-for="filter-trips-status"],
.search-filter-group select#filter-trips-status {
  flex: 1 1 130px;
  max-width: 160px;
}

.search-filter-group .custom-select-container[data-for="filter-trips-sort"],
.search-filter-group select#filter-trips-sort {
  flex: 1.2 1 180px;
  max-width: 220px;
}

.search-filter-group .date-filter-wrapper {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex: 0 1 auto;
}

.search-filter-group .date-filter-wrapper input[type="date"] {
  height: 42px;
  width: 140px;
  margin: 0;
  border-radius: 10px;
}

.search-filter-group button {
  height: 42px;
  border-radius: 10px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 0 1rem;
  white-space: nowrap;
}

#btn-reset-filters {
  border-color: rgba(239, 68, 68, 0.2) !important;
  color: var(--status-inactive) !important;
  background: rgba(239, 68, 68, 0.03) !important;
  transition: var(--transition-smooth);
}

#btn-reset-filters:hover {
  background: rgba(239, 68, 68, 0.08) !important;
  border-color: var(--status-inactive) !important;
}

.custom-select-trigger {
  background-image: none !important;
}

.search-wrapper {
  position: relative;
  flex: 1;
}

.search-input {
  width: 100%;
  height: 42px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-light);
  border-radius: 10px;
  padding: 0.75rem 1rem 0.75rem 2.75rem;
  color: var(--text-primary);
  font-family: var(--font-body);
  transition: var(--transition-smooth);
}

.search-input:focus {
  outline: none;
  border-color: hsl(var(--accent-cyan));
  box-shadow: var(--shadow-glow);
  background: var(--bg-tertiary);
}

.search-icon-inside {
  position: absolute;
  left: 1rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
}

.filter-select {
  background: var(--bg-secondary);
  border: 1px solid var(--border-light);
  color: var(--text-primary);
  padding: 0.75rem 2rem 0.75rem 1rem;
  border-radius: 10px;
  font-family: var(--font-body);
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  background-size: 1rem;
  transition: var(--transition-smooth);
  height: 42px;
}

.filter-select:focus {
  outline: none;
  border-color: hsl(var(--accent-cyan));
  box-shadow: var(--shadow-glow);
}

/* Custom Buttons */
.btn-primary {
  background: #3b82f6; /* Corporate steel blue */
  color: #ffffff;
  border: none;
  padding: 0.75rem 1.5rem;
  border-radius: 8px;
  font-family: var(--font-heading);
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.15);
  transition: var(--transition-smooth);
}

.btn-primary:hover {
  transform: translateY(-1px);
  background: #2563eb;
  box-shadow: 0 6px 16px rgba(59, 130, 246, 0.25);
}

.btn-secondary {
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border: 1px solid var(--border-light);
  padding: 0.75rem 1.5rem;
  border-radius: 8px;
  font-family: var(--font-heading);
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition-smooth);
}

.btn-secondary:hover {
  border-color: rgba(255, 255, 255, 0.2);
  background: var(--bg-secondary);
}

/* Data Table Container */
.table-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-light);
  border-radius: 16px;
  overflow: hidden; /* clip to rounded corners; scroll happens inside wrapper */
  box-shadow: var(--shadow-main);
}

.table-wrapper {
  overflow: auto;
  max-width: 100%;
  -webkit-overflow-scrolling: touch;
}

#table-trips-card {
  max-width: 100%;
}

#table-trips-card .table-wrapper {
  overflow: auto;
  max-width: 100%;
  max-height: calc(100vh - 140px);
  min-height: 420px;
}

table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  text-align: left;
}

table tr:first-child th:first-child {
  border-top-left-radius: 15px;
}
table tr:first-child th:last-child {
  border-top-right-radius: 15px;
}
table tr:last-child td:first-child {
  border-bottom-left-radius: 15px;
}
table tr:last-child td:last-child {
  border-bottom-right-radius: 15px;
}

th {
  background: rgba(23, 32, 59, 0.5);
  color: var(--text-secondary);
  font-weight: 600;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--border-light);
}

td {
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--border-light);
  color: var(--text-primary);
  font-size: 0.95rem;
  vertical-align: middle;
}

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

tr:hover td {
  background: rgba(255, 255, 255, 0.02);
}

/* Custom Table Row Status Badges */
.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.25rem 0.75rem;
  border-radius: 12px;
  font-size: 0.8rem;
  font-weight: 600;
  line-height: 1.2;
}

/* Dynamic statuses */
.status-active-pill {
  background: rgba(16, 185, 129, 0.1);
  color: var(--status-active);
}

.status-maintenance-pill {
  background: rgba(245, 158, 11, 0.1);
  color: var(--status-maintenance);
}

.status-inactive-pill {
  background: rgba(239, 68, 68, 0.1);
  color: var(--status-inactive);
}

/* Actions in Table */
.actions-cell {
  display: flex;
  gap: 0.5rem;
}

.btn-icon {
  background: none;
  border: none;
  color: var(--text-secondary);
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition-smooth);
}

.btn-icon:hover {
  background: var(--bg-tertiary);
}

.btn-edit:hover {
  color: hsl(var(--accent-cyan));
  background: rgba(59, 130, 246, 0.1);
}

.btn-delete:hover {
  color: var(--status-inactive);
  background: rgba(239, 68, 68, 0.1);
}

/* Empty Table View */
.empty-state {
  text-align: center;
  padding: 3.5rem 2rem;
  color: var(--text-secondary);
}

.empty-icon {
  font-size: 3rem;
  color: var(--text-muted);
  margin-bottom: 1rem;
}

.empty-state h3 {
  color: var(--text-primary);
  font-family: var(--font-heading);
  margin-bottom: 0.25rem;
}

/* Modal / Dialog Styling */
dialog {
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(15, 21, 39, 0.96);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-radius: 16px;
  color: var(--text-primary);
  padding: 0;
  max-width: 500px;
  width: calc(100% - 2rem);
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.6);
  margin: auto;
  
  /* Native Discrete Animations */
  transform: scale(0.95);
  opacity: 0;
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), 
              opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1), 
              display 0.3s cubic-bezier(0.4, 0, 0.2, 1) allow-discrete;
}

dialog[open] {
  transform: scale(1);
  opacity: 1;
}

@starting-style {
  dialog[open] {
    transform: scale(0.95);
    opacity: 0;
  }
}

dialog::backdrop {
  background: rgba(2, 6, 23, 0.7);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  opacity: 0;
  transition: opacity 0.3s ease, display 0.3s ease allow-discrete;
}

dialog[open]::backdrop {
  opacity: 1;
}

@starting-style {
  dialog[open]::backdrop {
    opacity: 0;
  }
}

/* Dialog Inner Layout */
.dialog-header {
  padding: 1.5rem;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.dialog-header h2 {
  font-family: var(--font-heading);
  font-size: 1.35rem;
  font-weight: 700;
}

.btn-close-dialog {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  transition: var(--transition-smooth);
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.btn-close-dialog:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

.dialog-body {
  padding: 1.5rem;
}

.dialog-footer {
  padding: 1.25rem 1.5rem;
  border-top: 1px solid var(--border-light);
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  background: rgba(15, 21, 39, 0.4);
}

/* Forms in Dialog */
.form-group {
  margin-bottom: 1.25rem;
}

.form-group:last-child {
  margin-bottom: 0;
}

.form-label {
  display: block;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 0.5rem;
}

.form-control {
  width: 100%;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-light);
  border-radius: 8px;
  padding: 0.75rem 1rem;
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 0.95rem;
  transition: var(--transition-smooth);
}

.form-control:focus {
  outline: none;
  border-color: hsl(var(--accent-indigo));
  box-shadow: 0 0 0 3px rgba(79, 172, 254, 0.15);
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

/* Modern Validation Styles (:user-valid / :invalid) */
.form-control:invalid:not(:placeholder-shown) {
  border-color: var(--status-inactive);
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.15);
}

/* Settings Informational Box */
.settings-info {
  background: rgba(0, 242, 254, 0.05);
  border: 1px solid rgba(0, 242, 254, 0.15);
  border-radius: 8px;
  padding: 0.75rem 1rem;
  font-size: 0.85rem;
  color: hsl(var(--accent-cyan));
  margin-bottom: 1.25rem;
  line-height: 1.4;
}

/* Footer Section */
footer {
  text-align: center;
  padding: 1.5rem;
  font-size: 0.85rem;
  color: var(--text-muted);
  border-top: 1px solid var(--border-light);
  margin-top: auto;
}

footer a {
  color: hsl(var(--accent-cyan));
  text-decoration: none;
}

footer a:hover {
  text-decoration: underline;
}

/* Toast Notifications */
.toast-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  z-index: 1000;
}

.toast {
  background: rgba(15, 21, 39, 0.92);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid var(--border-light);
  border-left: 3px solid hsl(var(--accent-indigo));
  padding: 0.5rem 0.85rem; /* Compact padding */
  border-radius: 6px;
  color: var(--text-primary);
  font-size: 0.825rem; /* Smaller font */
  font-weight: 500;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.35);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  transform: translateX(100%);
  opacity: 0;
  animation: slideIn 0.35s forwards cubic-bezier(0.16, 1, 0.3, 1);
  transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
  max-width: 320px;
}

.toast i, .toast svg {
  width: 16px !important;
  height: 16px !important;
  flex-shrink: 0;
}

.toast.toast-success {
  border-left-color: var(--status-active);
}

.toast.toast-error {
  border-left-color: var(--status-inactive);
}

@keyframes slideIn {
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

.toast.slide-out {
  transform: translateX(120%);
  opacity: 0;
  transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Wide Dialog Layout for complex forms */
.dialog-wide {
  max-width: 680px;
}

/* Inline Table Inputs & Custom Elements */
.table-input {
  width: 120px;
  padding: 0.35rem 0.65rem;
  font-size: 0.9rem;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-light);
  border-radius: 6px;
  color: var(--text-primary);
  text-align: right;
  transition: var(--transition-smooth);
}

.table-input:focus {
  outline: none;
  border-color: hsl(var(--accent-indigo));
  box-shadow: 0 0 0 2px rgba(79, 172, 254, 0.15);
}

.table-input.text-left {
  text-align: left;
}

.table-input.w-full {
  width: 100%;
}


.table-checkbox-label {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.9rem;
  cursor: pointer;
  color: var(--text-secondary);
  user-select: none;
}

.table-checkbox-label input[type="checkbox"] {
  accent-color: hsl(var(--accent-cyan));
  cursor: pointer;
  width: 16px;
  height: 16px;
}

/* Summary Payout Bar */
.summary-card {
  background: rgba(15, 21, 39, 0.6);
  border: 1px solid var(--border-light);
  border-radius: 16px;
  padding: 1.5rem 2rem;
  margin-top: 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: var(--shadow-main);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.summary-text {
  font-size: 1.05rem;
  font-weight: 500;
  color: var(--text-secondary);
}

.summary-amount {
  font-family: var(--font-heading);
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--status-maintenance);
  margin-left: 0.5rem;
}

/* Document Control Styles */
.passport-thumb {
  width: 60px;
  height: 40px;
  border-radius: 6px;
  object-fit: cover;
  border: 1px solid var(--border-light);
  cursor: pointer;
  display: block;
  margin: 0 auto;
  transition: var(--transition-smooth);
}

.passport-thumb:hover {
  transform: scale(1.1);
  border-color: hsl(var(--accent-cyan));
  box-shadow: 0 0 10px rgba(0, 242, 254, 0.4);
}

.no-passport {
  font-size: 0.8rem;
  color: var(--text-muted);
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  justify-content: center;
  width: 100%;
}

/* Cell warnings highlighting */
.cell-expired {
  background-color: rgba(239, 68, 68, 0.15) !important;
  color: #fca5a5 !important;
  border-left: 3px solid var(--status-inactive) !important;
}

.cell-warning {
  background-color: rgba(245, 158, 11, 0.12) !important;
  color: #fde047 !important;
  border-left: 3px solid var(--status-maintenance) !important;
}

.cell-valid {
  background-color: rgba(16, 185, 129, 0.08) !important;
  color: #a7f3d0 !important;
}

.cell-missing {
  background-color: rgba(100, 116, 139, 0.16) !important;
  color: #cbd5e1 !important;
  border-left: 3px solid var(--text-muted) !important;
}

body.light-theme .cell-missing {
  background-color: rgba(100, 116, 139, 0.08) !important;
  color: #475569 !important;
}

/* Document date field: date OR "information missing" */
.doc-date-field {
  margin-bottom: 1.25rem;
}

.doc-date-mode-toggle {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.65rem;
}

.doc-date-mode-option {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.4rem 0.75rem;
  border: 1px solid var(--border-light);
  border-radius: 8px;
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  user-select: none;
}

.doc-date-mode-option input {
  accent-color: var(--accent-primary);
}

.doc-date-mode-option:has(input:checked) {
  border-color: rgba(59, 130, 246, 0.45);
  color: var(--text-primary);
  background: rgba(59, 130, 246, 0.1);
}

.doc-date-input:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

/* Full Preview Modal Image */
.preview-image {
  max-width: 100%;
  max-height: 75vh;
  border-radius: 8px;
  display: block;
  margin: 0 auto;
  box-shadow: 0 5px 25px rgba(0, 0, 0, 0.5);
}

/* Compact Table Cells and Inputs for Spreadsheet-like Tables */
#table-trips th,
#table-salaries th,
#table-cash th {
  padding: 10px 12px;
}

#table-trips td,
#table-salaries td,
#table-cash td {
  padding: 6px 8px; /* Greatly reduced from 1rem 1.5rem to give text maximum space */
}

.table-input {
  background: transparent;
  border: 1px solid transparent;
  border-radius: 4px;
  color: var(--text-primary);
  padding: 4px 6px;
  font-size: 0.825rem;
  width: 100%;
  text-overflow: ellipsis;
  white-space: nowrap;
  overflow: hidden;
  transition: var(--transition-smooth);
}

/* Table Column Resizer Handle */
.resizer {
  position: absolute;
  top: 0;
  right: 0;
  width: 5px;
  cursor: col-resize;
  user-select: none;
  height: 100%;
}

.resizer:hover, .resizing {
  background-color: var(--accent-primary);
  opacity: 0.5;
}

th {
  position: relative;
}

.table-input:hover {
  background: var(--bg-tertiary);
  border-color: var(--border-light);
}

.table-input:focus {
  background: var(--bg-tertiary);
  border-color: hsl(var(--accent-indigo));
  box-shadow: 0 0 0 2px rgba(79, 172, 254, 0.15);
  outline: none;
}

/* Make Date & Time input compact and fit 160px */
#table-trips input[type="datetime-local"].table-input {
  font-size: 0.8rem;
  padding: 3px 4px;
  max-width: 160px;
}

/* Dialog Section Titles */
.dialog-section-title {
  font-family: var(--font-heading);
  font-size: 0.9rem;
  font-weight: 600;
  color: #818cf8; /* Light Indigo */
  margin-top: 1.5rem;
  margin-bottom: 0.75rem;
  padding-bottom: 0.25rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

/* Active State for 7 days ahead Filter Button */
#btn-filter-7days.active {
  background: #4f46e5 !important; /* Indigo Accent */
  color: #ffffff !important;
  border-color: #4f46e5 !important;
  box-shadow: 0 0 0 3px rgba(79, 172, 254, 0.25);
}

/* ===== Compact Pill Tab Buttons (Salaries / Cash) ===== */
.tab-btn-active {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border: none;
  border-radius: 8px;
  font-family: var(--font-body);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.18s ease;
  background: var(--accent-primary);
  color: #fff;
}

.tab-btn:not(.tab-btn-active) {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border: none;
  border-radius: 8px;
  font-family: var(--font-body);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.18s ease;
  background: transparent;
  color: var(--text-secondary);
}

.tab-btn:not(.tab-btn-active):hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

/* Archive rows — muted / read-only appearance */
tr.row-archived td {
  opacity: 0.65;
}

tr.row-archived td input[type="number"],
tr.row-archived td input[type="checkbox"] {
  pointer-events: none;
  opacity: 0.5;
}

body.light-theme .tab-btn:not(.tab-btn-active) {
  color: var(--text-secondary);
}

body.light-theme .tab-btn:not(.tab-btn-active):hover {
  background: rgba(0,0,0,0.06);
  color: var(--text-primary);
}

/* ===== Smooth Scrolling ===== */
html {
  scroll-behavior: smooth;
}

/* ===== Focus Visible Accessibility ===== */
:focus-visible {
  outline: 2px solid hsl(var(--accent-cyan));
  outline-offset: 2px;
  border-radius: 4px;
}

/* ===== Responsive – Tablet (≤1200px): Narrow sidebar ===== */
@media (max-width: 1200px) {
  .sidebar {
    width: 220px;
    padding: 1.5rem 1rem;
  }
  .sidebar-logo h2 {
    font-size: 1.1rem;
  }
  main {
    padding: 1.5rem;
  }
}

/* ===== Responsive – Small Tablet (≤900px): Icon-only sidebar ===== */
@media (max-width: 900px) {
  .sidebar {
    width: 68px;
    padding: 1.5rem 0.5rem;
    overflow: hidden;
  }
  .sidebar-logo h2 {
    display: none;
  }
  .sidebar-logo {
    justify-content: center;
    padding-bottom: 1.5rem;
  }
  .sidebar-link span {
    display: none;
  }
  .sidebar-link {
    justify-content: center;
    padding: 0.8rem;
    border-left: none;
    border-radius: 10px;
  }
  .sidebar-link.active {
    border-left: none;
    padding-left: 0.8rem;
  }
  .sidebar-footer {
    display: none;
  }
  .sidebar-link i {
    width: 20px;
    height: 20px;
  }
}

/* ===== Responsive – Mobile (≤768px): Sticky Bottom Navigation Bar ===== */
@media (max-width: 768px) {
  body {
    flex-direction: column;
    padding-bottom: 76px; /* Space for the bottom navigation bar */
  }
  
  .sidebar {
    position: fixed;
    top: auto !important;
    bottom: 0 !important;
    left: 0;
    right: 0;
    width: 100% !important;
    height: 64px !important;
    z-index: 1000;
    background: rgba(15, 21, 39, 0.95);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-right: none !important;
    border-top: 1px solid var(--border-light);
    padding: 0 0.5rem !important;
    display: flex;
    flex-direction: row !important;
    justify-content: space-around;
    align-items: center;
    box-shadow: 0 -8px 30px rgba(0, 0, 0, 0.4);
    overflow: visible;
  }

  body.light-theme .sidebar {
    background: rgba(255, 255, 255, 0.96);
    border-top: 1px solid rgba(0, 0, 0, 0.08);
    box-shadow: 0 -8px 24px rgba(0, 0, 0, 0.06);
  }

  .sidebar-logo {
    display: none !important;
  }

  .sidebar-nav {
    display: flex;
    flex-direction: row !important;
    justify-content: space-around;
    align-items: center;
    width: 100%;
    gap: 2px !important;
    margin: 0 !important;
    padding: 0 !important;
    overflow: visible;
  }

  .sidebar-link {
    flex: 1;
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 4px !important;
    padding: 6px 2px !important;
    font-size: 0.65rem !important;
    border-left: none !important;
    border-radius: 8px !important;
    color: var(--text-secondary);
    transition: var(--transition-smooth);
    background: transparent !important;
    min-height: auto !important;
    text-align: center;
    white-space: nowrap;
  }

  .sidebar-link span {
    display: block !important;
    font-size: 0.625rem !important;
    font-weight: 500;
  }

  .sidebar-link i {
    width: 18px !important;
    height: 18px !important;
  }

  .sidebar-link.active {
    color: var(--accent-primary) !important;
    background: transparent !important;
    box-shadow: none !important;
  }

  body.light-theme .sidebar-link.active {
    color: #4f46e5 !important;
  }

  /* Logout button alignment on mobile bar */
  #btn-logout {
    margin-top: 0 !important;
    color: var(--status-inactive) !important;
  }

  .sidebar-footer {
    display: none !important;
  }

  .main-content {
    min-height: auto;
    width: 100%;
  }

  /* Header & Top Bar Mobile styling */
  header, .topbar {
    position: sticky;
    top: 0;
    z-index: 99;
    background: rgba(10, 15, 29, 0.85);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-light);
    height: auto !important;
    padding: 0.75rem 1rem !important;
    flex-wrap: wrap;
    gap: 0.5rem;
  }

  body.light-theme header, 
  body.light-theme .topbar {
    background: rgba(244, 246, 250, 0.85);
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
  }

  .topbar-title {
    font-size: 1.1rem;
  }

  /* Responsive Sticky Headers for Trips Table */
  #table-trips-card .table-wrapper {
    max-height: calc(100vh - 140px);
    min-height: 320px;
  }

  main {
    padding: 1rem !important;
  }

  /* Grids and layout structures */
  .stats-grid {
    grid-template-columns: 1fr !important;
    gap: 0.75rem !important;
    margin-bottom: 1.25rem !important;
  }

  /* Forms & Dialogs adaptation for narrow viewports */
  .form-row {
    grid-template-columns: 1fr !important;
    gap: 0.75rem !important;
  }

  dialog {
    width: 95% !important;
    max-width: 95% !important;
    margin: auto !important;
    position: fixed !important;
    top: 50% !important;
    left: 50% !important;
    transform: translate(-50%, -50%) scale(0.95) !important;
    max-height: 85vh !important;
    overflow-y: auto !important;
    box-sizing: border-box;
  }

  dialog[open] {
    transform: translate(-50%, -50%) scale(1) !important;
  }

  @starting-style {
    dialog[open] {
      transform: translate(-50%, -50%) scale(0.95) !important;
    }
  }

  .dialog-body {
    padding: 1.25rem !important;
    max-height: calc(85vh - 120px);
    overflow-y: auto;
  }

  .dialog-footer {
    padding: 1rem 1.25rem !important;
  }

  /* Toolbars and filters stacking */
  .directory-toolbar {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 0.75rem !important;
    padding: 1rem !important;
  }

  .search-filter-group {
    max-width: 100% !important;
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 0.5rem !important;
  }

  .search-filter-group > * {
    flex: none !important;
    width: 100% !important;
    max-width: none !important;
    height: auto !important;
  }

  .search-filter-group .date-filter-wrapper {
    width: 100% !important;
    justify-content: space-between !important;
  }

  .search-filter-group .date-filter-wrapper input[type="date"] {
    flex: 1 !important;
    width: auto !important;
    max-width: none !important;
  }

  .search-wrapper {
    min-width: 100% !important;
  }

  .filter-select {
    width: 100% !important;
  }

  .btn-primary {
    justify-content: center !important;
  }

  .table-wrapper {
    border-radius: 8px;
    border: 1px solid var(--border-light);
    overflow: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* Badges & Text Sizes on mobile */
  .badge {
    font-size: 0.68rem !important;
    padding: 0.3rem 0.5rem !important;
  }

  /* Topbar: compact on mobile */
  .topbar-actions {
    gap: 0.35rem !important;
  }

  .topbar-actions > div:not(.topbar-actions) {
    display: none;
  }

  /* Hide user name block on very small screens — keep theme/settings */
  .topbar-actions > div[style*="flex-direction: column"] {
    display: none !important;
  }

  #db-status-badge {
    display: none !important;
  }

  .btn-settings {
    width: 36px !important;
    height: 36px !important;
    padding: 0 !important;
  }

  /* Bottom nav: logout as compact item */
  #btn-logout {
    flex: 0 0 auto !important;
    min-width: 52px !important;
    color: var(--status-inactive) !important;
  }

  #btn-logout span {
    font-size: 0.58rem !important;
  }

  /* Tabs: scrollable row on mobile */
  .tabs-navigation {
    display: flex !important;
    flex-wrap: nowrap !important;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch;
    width: 100% !important;
    max-width: 100% !important;
    gap: 4px !important;
    padding: 4px !important;
    scrollbar-width: none;
  }

  .tabs-navigation::-webkit-scrollbar {
    display: none;
  }

  .tabs-navigation .tab-btn,
  .tabs-navigation .tab-btn-active {
    flex: 0 0 auto !important;
    white-space: nowrap !important;
    font-size: 0.78rem !important;
    padding: 8px 12px !important;
  }

  .salary-subtabs,
  .cash-subtabs {
    width: 100% !important;
    max-width: 100% !important;
  }

  /* Trips calendar — mobile layout & touch targets */
  .trips-control-panel {
    gap: 0.85rem;
    margin-bottom: 0.85rem;
  }

  .trips-calendar-pane {
    max-width: none;
    width: 100%;
    margin: 0;
    padding: 1rem;
  }

  .trips-control-panel .custom-calendar-card {
    height: auto;
    min-height: 0;
  }

  .trips-control-panel .calendar-nav-btn {
    width: 44px;
    height: 44px;
    min-width: 44px;
    min-height: 44px;
    touch-action: manipulation;
  }

  .trips-control-panel .calendar-weekdays {
    gap: 3px;
    font-size: 0.68rem;
  }

  .trips-control-panel .calendar-days-grid {
    width: 100%;
    gap: 3px;
  }

  .trips-control-panel .calendar-day {
    min-height: 44px;
    min-width: 0;
    aspect-ratio: auto;
    font-size: 0.92rem;
    padding: 8px 0;
    box-sizing: border-box;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
  }

  .trips-control-panel .calendar-day:active:not(.disabled) {
    background: rgba(99, 102, 241, 0.25);
    transform: scale(0.96);
  }

  .trips-control-panel .calendar-day.selected-start,
  .trips-control-panel .calendar-day.selected-end,
  .trips-control-panel .calendar-day.in-range {
    border-radius: 8px !important;
  }

  .trips-filters-pane {
    padding: 1rem;
  }

  /* Trips: top action buttons */
  .trips-toolbar-actions {
    position: sticky;
    top: 56px;
    z-index: 40;
    display: flex;
    flex-direction: column;
    gap: 0.55rem;
    margin: 0 0 0.85rem;
    padding: 0.35rem 0;
    background: color-mix(in srgb, var(--bg-primary) 92%, transparent);
    backdrop-filter: blur(8px);
  }

  .trips-toolbar-actions .btn-primary,
  .trips-toolbar-actions .btn-secondary {
    width: 100%;
    justify-content: center;
    min-height: 44px;
    padding: 0.75rem 1rem !important;
    font-size: 0.92rem !important;
  }

  /* Desktop table hidden on mobile; cards shown */
  #table-trips-card {
    display: none !important;
  }

  .trips-mobile-list {
    display: flex !important;
    flex-direction: column;
    gap: 1rem;
    margin-bottom: 5rem;
  }

  .trips-mobile-empty {
    padding: 1.5rem 1rem;
    text-align: center;
    color: var(--text-muted);
    background: var(--bg-secondary);
    border: 1px solid var(--border-light);
    border-radius: 14px;
  }

  .trips-mobile-day-title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin: 0 0 0.65rem;
    font-size: 0.92rem;
    font-weight: 700;
    color: var(--text-primary);
  }

  .trips-mobile-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-light);
    border-radius: 14px;
    padding: 0.85rem 0.9rem 1rem;
    box-shadow: var(--shadow-main);
    display: flex;
    flex-direction: column;
    gap: 0.7rem;
    margin-bottom: 0.75rem;
  }

  .trips-mobile-card-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
  }

  .trips-mobile-card-time {
    display: flex;
    align-items: center;
    gap: 0.5rem;
  }

  .trips-mobile-card-time [data-status-dot] {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
  }

  .trips-mobile-card-time input[type="time"] {
    width: 110px;
    font-weight: 700;
  }

  .trips-mobile-card-actions {
    display: flex;
    align-items: center;
    gap: 0.15rem;
  }

  .trips-mobile-card-actions .btn-icon {
    width: 40px;
    height: 40px;
  }

  .trips-mobile-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.65rem;
  }

  .trips-mobile-field {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    min-width: 0;
  }

  .trips-mobile-field > span {
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
  }

  .trips-mobile-seats {
    height: 42px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    color: var(--text-secondary);
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-light);
    border-radius: 8px;
  }

  body.light-theme .trips-mobile-seats {
    background: #f8fafc;
  }

  body.light-theme .trips-toolbar-actions {
    background: color-mix(in srgb, #f4f6fa 92%, transparent);
  }

  /* Trips table scroll area unused on mobile cards */
  #table-trips-card .table-wrapper {
    max-height: calc(100vh - 160px);
    min-height: 280px;
  }

  /* Documents page layout */
  .docs-layout {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-bottom: 1.25rem;
  }

  .docs-calendar-pane,
  .docs-events-pane {
    width: 100%;
    min-width: 0;
    height: auto;
  }

  .docs-calendar-card,
  .docs-events-card {
    padding: 1rem 1.1rem !important;
    height: auto !important;
    min-height: 0;
  }

  .docs-cal-header {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
  }

  .docs-calendar-card .calendar-nav-btn {
    width: 44px;
    height: 44px;
    min-width: 44px;
    min-height: 44px;
    touch-action: manipulation;
  }

  .docs-cal-grid {
    gap: 3px;
  }

  .docs-calendar-card .calendar-weekdays,
  .docs-calendar-card .calendar-days-grid {
    display: grid !important;
    grid-template-columns: repeat(7, 1fr) !important;
    width: 100%;
  }

  .docs-calendar-card .doc-calendar-day {
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
  }

  .docs-events-card {
    min-height: 240px;
    max-height: 360px;
    display: flex;
    flex-direction: column;
  }

  .docs-events-content {
    overflow-y: auto;
    flex: 1;
    min-height: 0;
  }

  .docs-toolbar-inner {
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
    width: 100%;
  }

  .docs-search {
    width: 100%;
    position: relative;
  }

  .docs-search .search-input {
    width: 100%;
    height: 44px;
    padding-left: 2.75rem;
  }

  .docs-search .search-icon-inside {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
  }

  .docs-sort-select {
    width: 100% !important;
    height: 44px !important;
  }

  /* Salaries panel */
  .salary-filters {
    flex-direction: column !important;
    align-items: stretch !important;
  }

  .salary-field,
  .salary-field-grow,
  .salary-field-action {
    width: 100% !important;
    min-width: 0 !important;
  }

  .salary-field-action .btn-primary {
    width: 100%;
    justify-content: center;
    min-height: 44px;
  }

  .salary-summary-bar {
    bottom: 76px;
    flex-direction: column;
    align-items: stretch;
    gap: 0.75rem;
  }

  .salary-summary-actions {
    width: 100%;
  }

  .salary-summary-actions .btn-primary,
  .salary-summary-actions .btn-secondary {
    flex: 1;
    justify-content: center;
    min-height: 44px;
  }

  .salary-table-scroll {
    max-height: min(50vh, 420px);
  }

  /* Cash page date filters */
  .date-filter-wrapper {
    flex-wrap: wrap !important;
    gap: 0.5rem !important;
  }

  .date-filter-wrapper input[type="date"] {
    flex: 1 1 120px !important;
    min-width: 0 !important;
  }

  /* Touch-friendly table inputs */
  .table-input,
  .custom-select-trigger {
    min-height: 36px !important;
    font-size: 0.9rem !important;
  }

  .salary-amount-input {
    width: 100% !important;
    max-width: 140px;
  }

  /* Dialog footer buttons stack on narrow screens */
  .dialog-footer {
    flex-direction: column-reverse !important;
    gap: 0.5rem !important;
  }

  .dialog-footer .btn-primary,
  .dialog-footer .btn-secondary {
    width: 100%;
    justify-content: center;
    min-height: 44px;
  }

  .dialog-footer [style*="margin-right: auto"] {
    margin-right: 0 !important;
    width: 100%;
  }
}

/* Expandable Stats Cards */
.stat-card.expandable {
  cursor: pointer;
  transition: var(--transition-smooth);
}
.stat-card.expandable:hover {
  transform: translateY(-2px);
  border-color: var(--accent-primary) !important;
  box-shadow: var(--shadow-glow);
}
.expanded-list {
  scrollbar-width: thin;
}
.expanded-list::-webkit-scrollbar {
  width: 4px;
}
.expanded-list::-webkit-scrollbar-thumb {
  background: var(--border-light);
  border-radius: 2px;
}

/* Empty input highlight */
select.table-input.input-empty {
  border: 1px solid rgba(239, 68, 68, 0.5) !important;
  background-color: rgba(239, 68, 68, 0.04) !important;
  box-shadow: 0 0 4px rgba(239, 68, 68, 0.2) !important;
}
select.table-input.input-empty:focus {
  border-color: var(--status-inactive) !important;
  box-shadow: 0 0 6px rgba(239, 68, 68, 0.4) !important;
}

/* Custom Searchable Select Dropdowns */
.custom-select-container {
  position: relative;
  width: 100%;
}
.custom-select-trigger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  width: 100%;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 4px 8px;
  color: var(--text-primary);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition-smooth);
  min-height: 32px;
  box-sizing: border-box;
  text-align: left;
}
.custom-select-trigger span {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex-grow: 1;
}
.custom-select-trigger:hover {
  border-color: var(--border-light);
  background: rgba(255, 255, 255, 0.03);
}
.light-theme .custom-select-trigger:hover {
  background: rgba(0, 0, 0, 0.02);
}
.custom-select-trigger.input-empty {
  border: 1px solid rgba(239, 68, 68, 0.45) !important;
  background-color: rgba(239, 68, 68, 0.03) !important;
  box-shadow: 0 0 4px rgba(239, 68, 68, 0.15) !important;
}
.custom-select-arrow {
  color: var(--text-secondary);
  opacity: 0.7;
  flex-shrink: 0;
}
.custom-select-dropdown {
  /* Position & size are set inline by JS using position:fixed + getBoundingClientRect */
  position: fixed;
  z-index: 9999;
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: 8px;
  margin-top: 0;
  box-shadow: var(--shadow-lg);
  padding: 6px;
  backdrop-filter: blur(10px);
  box-sizing: border-box;
  min-width: 180px;
}
.custom-select-search {
  width: 100%;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-light);
  border-radius: 6px;
  padding: 6px 10px;
  color: var(--text-primary);
  font-size: 0.825rem;
  margin-bottom: 6px;
  box-sizing: border-box;
  outline: none;
  transition: var(--transition-smooth);
}
.light-theme .custom-select-search {
  background: rgba(0, 0, 0, 0.03);
}
.custom-select-search:focus {
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.2);
}
.custom-select-options {
  max-height: 180px;
  overflow-y: auto;
  scrollbar-width: thin;
}
.custom-select-options::-webkit-scrollbar {
  width: 4px;
}
.custom-select-options::-webkit-scrollbar-thumb {
  background: var(--border-light);
  border-radius: 2px;
}
.custom-select-option {
  padding: 6px 10px;
  font-size: 0.825rem;
  border-radius: 4px;
  cursor: pointer;
  color: var(--text-primary);
  transition: var(--transition-smooth);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-align: left;
}
.custom-select-option:hover {
  background: rgba(255, 255, 255, 0.08);
}
.light-theme .custom-select-option:hover {
  background: rgba(0, 0, 0, 0.04);
}
.custom-select-option.selected {
  background: var(--accent-primary);
  color: white;
  font-weight: 600;
}

/* open-upward: coordinates are set inline by JS */
.custom-select-dropdown.open-upward {
  /* JS sets bottom inline; this class is kept as a marker only */
}

/* ===== Read-only styling for Viewer mode inputs ===== */
.table-input:disabled,
.custom-select-trigger.disabled {
  background: transparent !important;
  border-color: transparent !important;
  color: var(--text-primary) !important;
  cursor: default !important;
  padding: 4px 0 !important;
  font-weight: 600 !important;
  box-shadow: none !important;
  pointer-events: none !important;
  appearance: none !important;
  -webkit-appearance: none !important;
}

/* ===== Trips Control Panel (calendar left, filters right) ===== */
.trips-control-panel {
  display: grid;
  grid-template-columns: minmax(280px, 340px) minmax(0, 1fr);
  gap: 1.25rem;
  align-items: start;
  margin-bottom: 1rem;
}

.trips-calendar-pane,
.trips-filters-pane {
  background: var(--bg-secondary);
  border: 1px solid var(--border-light);
  border-radius: 16px;
  box-shadow: var(--shadow-main);
}

.trips-calendar-pane {
  padding: 1.1rem 1.15rem 1.2rem;
}

.trips-filters-pane {
  padding: 1.25rem 1.4rem;
  display: flex;
  flex-direction: column;
  gap: 1.1rem;
  min-width: 0;
}

.trips-control-panel .custom-calendar-card {
  background: transparent;
  border: none;
  padding: 0;
  box-shadow: none;
  height: 100%;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.trips-control-panel .calendar-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  padding-bottom: 0.65rem;
  border-bottom: 1px solid var(--border-light);
}

.trips-control-panel .calendar-header #calendar-month-year {
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--text-primary);
  text-transform: capitalize;
  letter-spacing: -0.01em;
}

.trips-control-panel .calendar-nav-btn {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  border: 1px solid var(--border-light);
  background: rgba(255, 255, 255, 0.03);
  color: var(--text-primary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition-smooth);
}

.trips-control-panel .calendar-nav-btn:hover {
  border-color: rgba(59, 130, 246, 0.35);
  background: rgba(59, 130, 246, 0.1);
  color: #93c5fd;
}

.trips-control-panel .calendar-weekdays {
  font-size: 0.72rem;
}

.trips-control-panel .calendar-days-grid {
  gap: 4px;
}

.trips-control-panel .calendar-day {
  font-size: 0.88rem;
  border-radius: 10px;
}

.trips-filters-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
  padding-bottom: 0.15rem;
}

.trips-filters-header h2 {
  font-family: var(--font-heading);
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.02em;
}

.trips-period-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.4rem 0.75rem;
  border-radius: 999px;
  background: rgba(59, 130, 246, 0.1);
  border: 1px solid rgba(59, 130, 246, 0.22);
  color: var(--text-secondary);
  font-size: 0.82rem;
  font-weight: 600;
  white-space: nowrap;
}

.trips-period-badge i,
.trips-period-badge svg {
  color: var(--accent-primary);
  flex-shrink: 0;
}

.trips-period-badge strong {
  color: var(--accent-primary);
  font-weight: 700;
}

.trips-search {
  width: 100%;
  flex: 0 0 auto;
  position: relative;
  display: block;
  align-self: stretch;
}

.trips-search .search-input {
  width: 100%;
  height: 46px;
  font-size: 0.95rem;
  padding-left: 2.75rem;
}

.trips-search .search-icon-inside {
  position: absolute;
  left: 1rem;
  top: 50%;
  transform: translateY(-50%);
  width: 18px;
  height: 18px;
  margin: 0;
  display: block;
  color: var(--text-muted);
  pointer-events: none;
  z-index: 1;
}

.trips-filter-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.trips-filter-field {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.trips-filter-field label {
  font-size: 0.72rem;
  color: var(--text-secondary);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.trips-filter-field .filter-select,
.trips-filter-field .custom-select-container {
  width: 100%;
}

.trips-filter-actions {
  margin-top: auto;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  padding-top: 0.25rem;
}

.trips-reset-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.65rem 1rem;
  font-weight: 600;
  color: var(--status-inactive);
  border-color: rgba(239, 68, 68, 0.25);
}

.trips-reset-btn:hover {
  border-color: rgba(239, 68, 68, 0.45);
  background: rgba(239, 68, 68, 0.08);
}

body.light-theme .trips-calendar-pane,
body.light-theme .trips-filters-pane {
  background: #ffffff;
}

body.light-theme .trips-control-panel .calendar-nav-btn {
  background: #f8fafc;
}

body.light-theme .calendar-nav-btn {
  background: #f8fafc;
}

body.light-theme .trips-period-badge {
  background: rgba(37, 99, 235, 0.08);
  border-color: rgba(37, 99, 235, 0.18);
}

@media (max-width: 980px) {
  .trips-control-panel {
    grid-template-columns: 1fr;
  }

  .trips-calendar-pane {
    max-width: 420px;
    width: 100%;
    margin: 0 auto;
  }
}

@media (max-width: 640px) {
  .trips-filter-grid {
    grid-template-columns: 1fr;
  }

  .trips-filters-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .trips-reset-btn {
    width: 100%;
    justify-content: center;
  }
}

/* ===== Shared Calendar Grid (Trips + Documents) ===== */
.calendar-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
  text-align: center;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.calendar-days-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
  text-align: center;
  width: 100%;
}

.calendar-nav-btn {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  border: 1px solid var(--border-light);
  background: rgba(255, 255, 255, 0.03);
  color: var(--text-primary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition-smooth);
  flex-shrink: 0;
}

.calendar-nav-btn:hover {
  border-color: rgba(59, 130, 246, 0.35);
  background: rgba(59, 130, 246, 0.1);
  color: #93c5fd;
}

/* ===== Custom Calendar Range Picker Styles ===== */
.calendar-day {
  padding: 6px 0;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-primary);
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  aspect-ratio: 1;
  transition: var(--transition-smooth);
  user-select: none;
}
.calendar-day:hover:not(.disabled) {
  background: rgba(99, 102, 241, 0.15);
  color: var(--accent-primary);
}
.calendar-day.other-month {
  color: var(--text-muted);
  opacity: 0.4;
}
.calendar-day.disabled {
  color: var(--text-muted);
  opacity: 0.2;
  cursor: not-allowed;
}
.calendar-day.today {
  border: 1px dashed var(--accent-primary);
}
.calendar-day.selected-start {
  background: var(--accent-primary) !important;
  color: white !important;
  border-radius: 6px 0 0 6px !important;
}
.calendar-day.selected-end {
  background: var(--accent-primary) !important;
  color: white !important;
  border-radius: 0 6px 6px 0 !important;
}
.calendar-day.selected-start.selected-end {
  border-radius: 6px !important;
}
.calendar-day.in-range {
  background: rgba(99, 102, 241, 0.15) !important;
  color: var(--accent-primary) !important;
  border-radius: 0 !important;
}

/* Document Control Page Redesign Styles */

.doc-calendar-day {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  font-size: 0.85rem;
  font-weight: 500;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
  user-select: none;
  padding: 6px 2px;
  min-height: 44px;
  box-sizing: border-box;
}

.doc-calendar-day.empty-day {
  color: var(--text-muted);
  opacity: 0.25;
  cursor: default;
  pointer-events: none;
}

.doc-calendar-day.active-day {
  color: var(--text-primary);
  background-color: rgba(255, 255, 255, 0.02);
  border: 1px solid transparent;
}

.doc-calendar-day.active-day:hover {
  background-color: rgba(255, 255, 255, 0.08);
  border-color: var(--border-light);
}

.doc-calendar-day.today-day {
  font-weight: 700;
  color: hsl(var(--accent-cyan)) !important;
  background-color: rgba(6, 182, 212, 0.1) !important;
  border: 1px dashed hsl(var(--accent-cyan)) !important;
}

.doc-calendar-day.selected-day {
  background-color: #4f46e5 !important;
  color: #ffffff !important;
  font-weight: 700;
  border-color: #4f46e5 !important;
  box-shadow: 0 4px 12px rgba(79, 70, 229, 0.3);
}

.day-number {
  font-weight: 600;
  font-size: 0.85rem;
}

/* Bus Plate Badges inside Day Cell */
.calendar-day-buses {
  display: flex;
  flex-direction: column;
  gap: 2px;
  width: 100%;
  align-items: center;
  margin-top: 4px;
}

.calendar-bus-badge {
  font-size: 0.52rem;
  font-weight: 700;
  letter-spacing: -0.3px;
  padding: 1px 2px;
  border-radius: 4px;
  width: 100%;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: clip;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
  display: inline-block;
  box-sizing: border-box;
}

.bus-badge-expired {
  background-color: rgba(239, 68, 68, 0.12) !important;
  color: #ef4444 !important;
  border: 1px solid rgba(239, 68, 68, 0.35) !important;
}

.bus-badge-warning {
  background-color: rgba(245, 158, 11, 0.12) !important;
  color: #f59e0b !important;
  border: 1px solid rgba(245, 158, 11, 0.35) !important;
}

.bus-badge-valid {
  background-color: rgba(16, 185, 129, 0.12) !important;
  color: #10b981 !important;
  border: 1px solid rgba(16, 185, 129, 0.35) !important;
}

/* On selected day, make badges white/contrast */
.doc-calendar-day.selected-day .calendar-bus-badge {
  background-color: rgba(255, 255, 255, 0.2) !important;
  color: #ffffff !important;
  border: 1px solid rgba(255, 255, 255, 0.4) !important;
}

/* ===== Salaries page layout ===== */
.salary-subtabs {
  display: flex;
  gap: 0;
  margin-bottom: 1.25rem;
  background: var(--bg-secondary);
  border: 1px solid var(--border-light);
  border-radius: 12px;
  padding: 4px;
  width: fit-content;
}

.salary-panel {
  background: var(--bg-secondary);
  border: 1px solid var(--border-light);
  border-radius: 16px;
  padding: 1.15rem 1.35rem;
  margin-bottom: 1.25rem;
  box-shadow: var(--shadow-main);
}

.salary-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.9rem 1rem;
  align-items: flex-end;
}

.salary-field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  min-width: 150px;
}

.salary-field-grow {
  flex: 1 1 240px;
  min-width: 220px;
}

.salary-field-action {
  min-width: auto;
}

.salary-field .form-control,
.salary-field .filter-select,
.salary-field .custom-select-container {
  width: 100%;
  height: 42px;
}

.salary-field-action .btn-primary {
  height: 42px;
  white-space: nowrap;
}

.salary-meta-hint {
  margin-top: 0.85rem;
  font-size: 0.88rem;
  color: var(--text-secondary);
  font-weight: 500;
}

.salary-meta-hint strong {
  color: var(--accent-primary);
}

.salary-block {
  margin-bottom: 1.5rem;
}

.salary-block-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.salary-block-header h2 {
  font-family: var(--font-heading);
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-primary);
}

.salary-block-muted {
  color: var(--text-muted) !important;
}

.salary-count-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 28px;
  height: 24px;
  padding: 0 0.5rem;
  border-radius: 999px;
  background: rgba(59, 130, 246, 0.12);
  color: var(--accent-primary);
  font-size: 0.78rem;
  font-weight: 700;
}

.salary-table-scroll {
  overflow: auto;
  max-height: min(52vh, 560px);
}

.salary-amount-input {
  width: 110px !important;
  text-align: right;
  display: inline-block;
  font-weight: 700;
}

.salary-note-cell {
  max-width: 220px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text-secondary);
  font-size: 0.88rem;
}

.salary-summary-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  background: var(--bg-secondary);
  border: 1px solid var(--border-light);
  border-radius: 12px;
  padding: 1rem 1.25rem;
  margin: 0 0 1.75rem;
  position: sticky;
  bottom: 12px;
  z-index: 8;
  box-shadow: var(--shadow-main);
}

.salary-summary-total {
  display: flex;
  align-items: baseline;
  gap: 0.55rem;
  color: var(--text-secondary);
  font-size: 0.9rem;
}

.salary-summary-total strong {
  color: var(--accent-primary);
  font-size: 1.2rem;
  font-weight: 800;
}

.salary-summary-actions {
  display: flex;
  gap: 0.65rem;
  flex-wrap: wrap;
}

.salary-open-details {
  padding: 0.35rem 0.75rem !important;
  font-size: 0.82rem !important;
  height: auto !important;
}

.salary-details-meta {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.75rem 1rem;
  padding: 0.85rem 1rem;
  border: 1px solid var(--border-light);
  border-radius: 12px;
  background: var(--bg-tertiary);
  font-size: 0.9rem;
  color: var(--text-secondary);
}

.salary-details-meta strong {
  color: var(--text-primary);
  font-weight: 700;
}

@media (max-width: 768px) {
  .salary-subtabs {
    width: 100%;
  }

  .salary-subtabs .tab-btn {
    flex: 1;
    justify-content: center;
  }

  .salary-summary-bar {
    bottom: 84px;
  }

  .salary-summary-actions {
    width: 100%;
  }

  .salary-summary-actions .btn-secondary,
  .salary-summary-actions .btn-primary {
    flex: 1;
    justify-content: center;
  }
}

/* ===== Documents page layout ===== */
.docs-layout {
  display: flex;
  gap: 1.5rem;
  margin-bottom: 1.5rem;
  align-items: stretch;
}

.docs-calendar-pane {
  flex: 1.2;
  min-width: 320px;
}

.docs-events-pane {
  flex: 1;
  min-width: 320px;
}

.docs-calendar-card,
.docs-events-card {
  padding: 1.25rem 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  height: 500px;
  box-sizing: border-box;
}

.docs-cal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border-light);
  padding-bottom: 0.5rem;
  margin-bottom: 0.25rem;
}

.docs-cal-title {
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--text-primary);
  text-transform: capitalize;
  font-family: var(--font-heading);
}

.docs-cal-grid {
  gap: 6px;
}

.docs-calendar-card .calendar-weekdays,
.docs-calendar-card .calendar-days-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  width: 100%;
}

.docs-events-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0 0 0.25rem;
  border-bottom: 1px solid var(--border-light);
  padding-bottom: 0.5rem;
  flex: 0 0 auto;
}

.docs-events-content {
  font-size: 0.85rem;
  color: var(--text-secondary);
  overflow-y: auto;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding-right: 4px;
  min-height: 0;
}

.docs-toolbar-inner {
  display: flex;
  gap: 1.5rem;
  align-items: center;
  width: 100%;
  flex-wrap: wrap;
}

.docs-search {
  flex: 2.5;
  min-width: 280px;
  position: relative;
}

.docs-sort-select {
  flex: 1;
  min-width: 200px;
  height: 42px;
}

/* Trips top action buttons */
.trips-toolbar-actions {
  display: flex;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin: 0 0 1rem;
}

.trips-toolbar-actions .btn-primary,
.trips-toolbar-actions .btn-secondary {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 0.7rem 1.35rem;
  font-size: 0.95rem;
}

/* Mobile trips list — hidden on desktop only */
@media (min-width: 769px) {
  .trips-mobile-list {
    display: none !important;
  }
}

/* Trips bottom action buttons (legacy, unused) */
.trips-bottom-actions {
  display: none;
}

/* Hide Supabase status badge and connection settings button from the topbar */
#db-status-badge,
#btn-open-settings {
  display: none !important;
}




