:root {
  color-scheme: light;
  --bg: #f8fafc;
  --surface: #ffffff;
  --surface-2: #f1f5f9;
  --text: #0f172a;
  --muted: #64748b;
  --border-w: 2px;
  --border: rgba(100, 116, 139, 0.40);
  --border-weak: rgba(100, 116, 139, 0.28);
  --primary: #2563eb;
  --primary-700: #1d4ed8;
  --success: #16a34a;
  --danger: #dc2626;
  --warning: #f59e0b;
  --white: #ffffff;
  --primary-blue: var(--primary);
  --secondary-blue: rgba(37, 99, 235, 0.08);
  --gray-dark: var(--muted);
  --gray-light: var(--border);
  --matcha-green: #16a34a;
  --light-green: rgba(22, 163, 74, 0.10);
  --radius: 16px;
  --radius-sm: 12px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06);
  --shadow: 0 10px 30px rgba(15, 23, 42, 0.08);
  --ring: 0 0 0 4px rgba(37, 99, 235, 0.14);
  --login-bg-image: url('/uploads/login-bg.jpg');
  --login-hero-image: url('/uploads/login-bg.jpg');
}

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

body {
  font-family: 'Vazirmatn', 'Tahoma', 'Arial', sans-serif;
  font-weight: 700;
  background: radial-gradient(1200px 600px at 100% 0%, rgba(37, 99, 235, 0.10), transparent 55%),
              radial-gradient(900px 500px at 0% 20%, rgba(14, 165, 233, 0.08), transparent 55%),
              var(--bg);
  color: var(--text);
  line-height: 1.7;
}

body.theme-dark {
  color-scheme: dark;
  --bg: #070a13;
  --surface: rgba(15, 23, 42, 0.92);
  --surface-2: rgba(17, 24, 39, 0.92);
  --text: #e5e7eb;
  --muted: rgba(148, 163, 184, 0.92);
  --border: rgba(148, 163, 184, 0.22);
  --border-weak: rgba(148, 163, 184, 0.16);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.45);
  --shadow: 0 12px 32px rgba(0, 0, 0, 0.48);
  --ring: 0 0 0 4px rgba(59, 130, 246, 0.20);
  background: radial-gradient(1200px 600px at 100% 0%, rgba(59, 130, 246, 0.14), transparent 55%),
              radial-gradient(900px 500px at 0% 20%, rgba(14, 165, 233, 0.10), transparent 55%),
              var(--bg);
}

body {
  transition: background-color 0.3s ease, color 0.3s ease;
}

/* Dark Mode Scrollbar */
body.theme-dark::-webkit-scrollbar { width: 10px; height: 10px; }
body.theme-dark::-webkit-scrollbar-track { background: #020617; }
body.theme-dark::-webkit-scrollbar-thumb { background: #334155; border-radius: 5px; border: 2px solid #020617; }
body.theme-dark::-webkit-scrollbar-thumb:hover { background: #475569; }

/* Dark Mode Selection */
body.theme-dark ::selection { background: rgba(59, 130, 246, 0.3); color: #ffffff; }

/* Dark Mode Input Options */
body.theme-dark option { background: #1e293b; color: #e2e8f0; }

.material-symbols-rounded {
  font-variation-settings: 'FILL' 0, 'wght' 500, 'GRAD' 0, 'opsz' 24;
  font-size: 20px;
  line-height: 1;
  vertical-align: middle;
}

.toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 99999;
  max-width: min(440px, calc(100vw - 40px));
  display: grid;
  gap: 10px;
  pointer-events: none;
}
.toast-container .alert { margin: 0; box-shadow: var(--shadow-sm); animation: slideDown 0.18s ease; pointer-events: auto; }

.app-container {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(255, 255, 255, 0.82);
  border-bottom: var(--border-w) solid var(--border);
  backdrop-filter: blur(10px);
}

body.theme-dark .app-header { background: rgba(2, 6, 23, 0.70); }

.app-header-inner {
  padding: 14px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  max-width: none;
  margin: 0;
}

.header-left { display: flex; align-items: center; gap: 12px; min-width: 0; }
.header-right { display: flex; align-items: center; gap: 12px; }

.icon-btn {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  border: var(--border-w) solid var(--border);
  background: rgba(255, 255, 255, 0.9);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.15s ease;
}

body.theme-dark .icon-btn { background: rgba(15, 23, 42, 0.72); }

.icon-btn:hover { background: #ffffff; border-color: var(--border); }
.icon-btn:active { transform: translateY(1px); }

.notif-wrap { position: relative; display: inline-flex; }
.notif-badge {
  position: absolute;
  top: -6px;
  left: -6px;
  min-width: 18px;
  height: 18px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--danger);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 2px solid rgba(255, 255, 255, 0.9);
}

body.theme-dark .notif-badge { border-color: rgba(15, 23, 42, 0.72); }

.notif-dropdown {
  position: absolute;
  top: 48px;
  left: 0;
  width: min(420px, calc(100vw - 24px));
  max-height: 420px;
  overflow: auto;
  background: rgba(255, 255, 255, 0.98);
  border: var(--border-w) solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow-lg);
  padding: 10px;
  z-index: 60;
}

body.theme-dark .notif-dropdown { background: rgba(15, 23, 42, 0.96); }

.notif-item {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  padding: 10px;
  border-radius: 12px;
  border: var(--border-w) solid transparent;
}

.notif-item:hover { background: rgba(37, 99, 235, 0.06); border-color: rgba(37, 99, 235, 0.18); }
body.theme-dark .notif-item:hover { background: rgba(96, 165, 250, 0.10); border-color: rgba(96, 165, 250, 0.22); }

.notif-item-title { font-weight: 700; }
.notif-item-sub { font-size: 12px; color: var(--muted); margin-top: 2px; }

.notif-item.notif-more {
  cursor: pointer;
  border-color: var(--border-weak);
  background: rgba(248, 250, 252, 0.7);
}

body.theme-dark .notif-item.notif-more { background: rgba(30, 41, 59, 0.55); }

.brand { min-width: 0; display: grid; gap: 2px; }

.app-logo {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  border: var(--border-w) solid var(--border);
  background: #ffffff;
  object-fit: contain;
  box-shadow: var(--shadow-sm);
  flex: 0 0 auto;
}

.app-title {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.app-subtitle {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.current-date {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-radius: 14px;
  border: var(--border-w) solid var(--border);
  background: rgba(255, 255, 255, 0.9);
  color: var(--text);
  font-size: 13px;
  box-shadow: var(--shadow-sm);
  white-space: nowrap;
}
body.theme-dark .current-date {
  background: rgba(15, 23, 42, 0.72);
}

.app-body {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 18px;
  width: 100%;
  max-width: none;
  margin: 18px 0;
  padding: 0 18px 24px;
  flex: 1;
}

/* --- SIDEBAR REDESIGN --- */
.sidebar {
  width: 280px;
  background: var(--surface);
  border-left: var(--border-w) solid var(--border);
  padding: 24px 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  height: calc(100vh - 73px);
  position: sticky;
  top: 73px;
  overflow: hidden; /* Prevent double scrollbars, let nav scroll */
  border-radius: 0 0 0 var(--radius); /* Round bottom-left only */
  transition: background 0.3s ease, border-color 0.3s ease;
}

body.theme-dark .sidebar { 
  background: rgba(15, 23, 42, 0.85); 
  border-color: var(--border);
}

.sidebar-header {
  padding: 0 4px 12px;
  border-bottom: var(--border-w) solid var(--border-weak);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-shrink: 0;
}

.sidebar-title {
  font-size: 13px;
  color: var(--muted);
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.sidebar-nav {
  padding: 4px 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
  overflow-y: auto;
  flex: 1;
  min-height: 0;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

/* Custom Scrollbar for Sidebar */
.sidebar-nav::-webkit-scrollbar { width: 4px; }
.sidebar-nav::-webkit-scrollbar-track { background: transparent; }
.sidebar-nav::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

.menu-item {
  padding: 12px 16px;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  align-items: center;
  gap: 14px;
  color: var(--text);
  text-decoration: none;
  border-radius: 14px;
  border: 1px solid transparent;
  user-select: none;
  font-weight: 600;
  position: relative;
  overflow: hidden;
}

.menu-item:hover {
  background: var(--surface-2);
  color: var(--primary);
  transform: translateX(-2px);
}

.menu-item:active { transform: scale(0.97); }

.menu-item.active {
  background: var(--primary);
  color: #ffffff;
  font-weight: 700;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.25);
}

body.theme-dark .menu-item:hover {
  background: rgba(255, 255, 255, 0.05);
  color: #ffffff;
}

body.theme-dark .menu-item.active {
  background: var(--primary);
  color: #ffffff;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.4);
}

.menu-icon {
  width: 24px;
  height: 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: inherit;
  transition: transform 0.2s;
  opacity: 0.85;
}

.menu-item:hover .menu-icon { transform: scale(1.1); opacity: 1; }
.menu-item.active .menu-icon { opacity: 1; }

.menu-group {
  border: var(--border-w) solid var(--border-weak);
  border-radius: 16px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.5);
  transition: background 0.3s ease;
}
body.theme-dark .menu-group { background: rgba(2, 6, 23, 0.3); }

.menu-group-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 16px;
  cursor: pointer;
  user-select: none;
  transition: background 0.2s;
}
.menu-group-header:hover { background: rgba(0, 0, 0, 0.03); }
body.theme-dark .menu-group-header:hover { background: rgba(255, 255, 255, 0.05); }

.menu-group-title {
  display: inline-flex;
  align-items: center;
  gap: 14px;
  color: var(--text);
  font-weight: 700;
  font-size: 0.95em;
}

.menu-group-chevron { color: var(--muted); transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1); }
.menu-group.open .menu-group-chevron { transform: rotate(180deg); }

.submenu { 
  display: none; 
  padding: 6px 8px 8px; 
  border-top: var(--border-w) solid var(--border-weak); 
  background: rgba(0,0,0,0.02); 
}
body.theme-dark .submenu { background: rgba(0,0,0,0.1); }

.menu-group.open .submenu { display: grid; gap: 4px; animation: slideDown 0.2s ease-out; }

.submenu .menu-item {
  font-size: 0.9em;
  padding: 10px 12px;
  border-radius: 10px;
}
/* --- END SIDEBAR REDESIGN --- */


.content-area { min-width: 0; }
.page-section { display: none; }
.page-section.active { display: block; }

.card {
  background: rgba(255, 255, 255, 0.92);
  border: var(--border-w) solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
}
body.theme-dark .card { background: rgba(15, 23, 42, 0.78); }

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
  padding-bottom: 12px;
  border-bottom: var(--border-w) solid var(--border-weak);
}

.card-title {
  font-size: 16px;
  font-weight: 800;
  letter-spacing: -0.01em;
}

.card-subtitle {
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
}

.card-header-left { display: grid; }
.card-header-actions { display: inline-flex; gap: 10px; align-items: center; flex-wrap: wrap; }

.panel {
  border: var(--border-w) solid var(--border-weak);
  background: rgba(248, 250, 252, 0.75);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 14px;
}
body.theme-dark .panel { background: rgba(2, 6, 23, 0.30); }

.panel-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  font-weight: 800;
  margin-bottom: 12px;
}
.panel-title .material-symbols-rounded { color: var(--primary-700); }
body.theme-dark .panel-title .material-symbols-rounded { color: #60a5fa; }

.panel-title-actions {
  margin-right: auto;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.driver-docs { display: grid; gap: 12px; }
.driver-doc-item {
  display: grid;
  grid-template-columns: 1fr 260px;
  gap: 14px;
  border: var(--border-w) solid var(--border-weak);
  border-radius: 16px;
  padding: 12px;
  background: rgba(255, 255, 255, 0.6);
}
body.theme-dark .driver-doc-item { background: rgba(2, 6, 23, 0.25); }

.driver-doc-title {
  font-weight: 900;
  margin-bottom: 10px;
}

.driver-doc-fields {
  display: grid;
  grid-template-columns: 150px 150px minmax(260px, 1fr);
  gap: 14px;
}

.driver-doc-fields .form-group,
.driver-doc-side .form-group { margin-bottom: 0; }

.driver-doc-link { margin-top: 8px; }

@media (max-width: 980px) {
  .driver-doc-item { grid-template-columns: 1fr; }
  .panel-title-actions { margin-right: 0; width: 100%; justify-content: flex-start; }
}

#driverManageModal .driver-doc-item { grid-template-columns: 1fr 220px; }
#driverManageModal input[data-jdp],
#driverManageModal .driver-doc-side .form-select {
  padding: 9px 10px;
  font-size: 13px;
  border-radius: 12px;
}

.form-group { margin-bottom: 14px; }
.form-label {
  display: block;
  margin-bottom: 8px;
  font-weight: 700;
  font-size: 13px;
  color: var(--text);
}
.form-label.required::after { content: ' *'; color: var(--danger); }

.form-help { margin-top: 6px; font-size: 12px; color: var(--muted); }

.form-input,
.form-select,
.form-textarea,
.search-input {
  width: 100%;
  padding: 11px 12px;
  border: var(--border-w) solid var(--border);
  border-radius: 14px;
  font-size: 14px;
  font-family: inherit;
  background: rgba(255, 255, 255, 0.95);
  color: var(--text);
  transition: box-shadow 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}

body.theme-dark .form-input,
body.theme-dark .form-select,
body.theme-dark .form-textarea,
body.theme-dark .search-input {
  background: rgba(2, 6, 23, 0.35);
  border-color: rgba(148, 163, 184, 0.24);
  color: var(--text);
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus,
.search-input:focus {
  outline: none;
  border-color: rgba(37, 99, 235, 0.55);
  box-shadow: var(--ring);
  background: rgba(255, 255, 255, 0.98);
}

body.theme-dark .form-input:focus,
body.theme-dark .form-select:focus,
body.theme-dark .form-textarea:focus,
body.theme-dark .search-input:focus {
  background: rgba(2, 6, 23, 0.55);
  border-color: rgba(59, 130, 246, 0.70);
}

.form-textarea { min-height: 110px; resize: vertical; }

.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 360px));
  justify-content: start;
  gap: 14px;
}

.btn-group { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 10px; }

.btn {
  padding: 10px 14px;
  border: var(--border-w) solid transparent;
  border-radius: 14px;
  font-size: 14px;
  font-weight: 800;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.15s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: inherit;
  line-height: 1.1;
  white-space: nowrap;
}
.btn:active { transform: translateY(1px); }

.btn-primary {
  background: var(--primary);
  border-color: rgba(37, 99, 235, 0.35);
  color: #ffffff;
}
.btn-primary:hover { background: var(--primary-700); }

.btn-secondary {
  background: rgba(255, 255, 255, 0.9);
  border-color: var(--border);
  color: var(--text);
}
.btn-secondary:hover { background: #ffffff; }
body.theme-dark .btn-secondary {
    background: rgba(15, 23, 42, 0.6);
    border-color: var(--border);
    color: var(--text);
}
body.theme-dark .btn-secondary:hover {
    background: rgba(15, 23, 42, 0.8);
}


.btn-success {
  background: rgba(22, 163, 74, 0.12);
  border-color: rgba(22, 163, 74, 0.20);
  color: #166534;
}
body.theme-dark .btn-success {
    background: rgba(22, 163, 74, 0.2);
    color: #4ade80;
}


.btn-danger {
  background: rgba(220, 38, 38, 0.10);
  border-color: rgba(220, 38, 38, 0.18);
  color: #991b1b;
}
body.theme-dark .btn-danger {
    background: rgba(220, 38, 38, 0.2);
    color: #f87171;
}

.search-box { position: relative; margin-bottom: 14px; }
.search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  pointer-events: none;
}
.search-input { padding-left: 44px; }

.radio-group { display: flex; gap: 14px; flex-wrap: wrap; margin-top: 8px; }
.radio-label { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; user-select: none; }
.radio-label input[type="radio"], .radio-label input[type="checkbox"] { width: 18px; height: 18px; cursor: pointer; }

/* Alerts */
.alert {
  padding: 12px 14px;
  border-radius: 14px;
  margin-bottom: 14px;
  display: none;
  border: var(--border-w) solid transparent;
  background: rgba(255, 255, 255, 0.9);
}
.alert.show { display: block; }
.alert-success { border-color: rgba(22, 163, 74, 0.25); background: rgba(22, 163, 74, 0.10); color: #14532d; }
.alert-danger { border-color: rgba(220, 38, 38, 0.22); background: rgba(220, 38, 38, 0.08); color: #7f1d1d; }
.alert-warning { border-color: rgba(245, 158, 11, 0.25); background: rgba(245, 158, 11, 0.10); color: #7c2d12; }

body.theme-dark .alert-success { background: rgba(22, 163, 74, 0.2); color: #bbf7d0; border-color: rgba(22, 163, 74, 0.3); }
body.theme-dark .alert-danger { background: rgba(220, 38, 38, 0.2); color: #fecaca; border-color: rgba(220, 38, 38, 0.3); }
body.theme-dark .alert-warning { background: rgba(245, 158, 11, 0.2); color: #fde68a; border-color: rgba(245, 158, 11, 0.3); }


.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}

.stat-card {
  background: rgba(255, 255, 255, 0.92);
  border: var(--border-w) solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  box-shadow: var(--shadow-sm);
}
body.theme-dark .stat-card { background: rgba(15, 23, 42, 0.78); }

.stat-label { font-size: 12px; color: var(--muted); font-weight: 700; }
.stat-value { font-size: 26px; font-weight: 900; margin-top: 6px; letter-spacing: -0.02em; }

.dashboard-extras {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
@media (max-width: 980px) {
  .dashboard-extras { grid-template-columns: 1fr; }
}

.mini-card {
  border: var(--border-w) solid var(--border-weak);
  background: rgba(255, 255, 255, 0.92);
  border-radius: var(--radius);
  padding: 14px;
  box-shadow: var(--shadow-sm);
  min-width: 0;
}
body.theme-dark .mini-card { background: rgba(15, 23, 42, 0.78); }

.mini-card-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-weight: 900;
  font-size: 13px;
  margin-bottom: 12px;
  color: var(--text);
}

.donut-wrap {
  position: relative;
  width: 160px;
  height: 160px;
  margin: 4px auto 10px;
}

.donut {
  width: 160px;
  height: 160px;
  border-radius: 999px;
  background:
    conic-gradient(
      rgba(22, 163, 74, 0.95) calc(var(--p1) * 1%),
      rgba(37, 99, 235, 0.95) 0 calc((var(--p1) + var(--p2)) * 1%),
      rgba(220, 38, 38, 0.95) 0 calc((var(--p1) + var(--p2) + var(--p3)) * 1%),
      rgba(100, 116, 139, 0.25) 0
    );
  box-shadow: var(--shadow-sm);
  position: relative;
}

.donut::after {
  content: '';
  position: absolute;
  inset: 16px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.96);
  border: var(--border-w) solid var(--border-weak);
}
body.theme-dark .donut::after { background: rgba(15, 23, 42, 0.96); }


.donut-center {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  z-index: 2;
  pointer-events: none;
  text-align: center;
}

.donut-total { font-size: 22px; font-weight: 900; letter-spacing: -0.02em; }
.donut-caption { font-size: 12px; color: var(--muted); font-weight: 800; }

.legend {
  display: grid;
  gap: 8px;
  margin-top: 10px;
  font-size: 13px;
  color: var(--text);
}

.legend-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.legend-left { display: inline-flex; align-items: center; gap: 10px; min-width: 0; }
.legend-dot { width: 10px; height: 10px; border-radius: 999px; flex: 0 0 auto; }
.legend-name { font-weight: 800; color: rgba(15, 23, 42, 0.85); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
body.theme-dark .legend-name { color: var(--text); }
.legend-value { font-weight: 900; color: rgba(15, 23, 42, 0.85); }
body.theme-dark .legend-value { color: var(--text); }

.recent-list { display: grid; gap: 10px; }
.recent-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border: var(--border-w) solid var(--border-weak);
  border-radius: 14px;
  background: rgba(248, 250, 252, 0.65);
  min-width: 0;
}
body.theme-dark .recent-item { background: rgba(2, 6, 23, 0.30); }

.recent-main { display: grid; gap: 4px; min-width: 0; }
.recent-title { font-weight: 900; font-size: 13px; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.recent-sub { font-size: 12px; font-weight: 800; color: rgba(100, 116, 139, 0.95); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
body.theme-dark .recent-sub { color: var(--muted); }
.recent-right { display: inline-flex; align-items: center; gap: 10px; flex: 0 0 auto; }

.filters-section {
  background: rgba(255, 255, 255, 0.65);
  border: var(--border-w) solid var(--border-weak);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 14px;
  box-shadow: var(--shadow-sm);
}
body.theme-dark .filters-section { background: rgba(15, 23, 42, 0.60); }

.filters-title { display: flex; align-items: center; gap: 10px; font-weight: 900; font-size: 14px; margin-bottom: 10px; }
.filters-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; }

.data-table {
  width: 100%;
  border-collapse: collapse;
  background: rgba(255, 255, 255, 0.92);
  border: var(--border-w) solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  font-size: 13px;
}
body.theme-dark .data-table { background: rgba(15, 23, 42, 0.78); }

.data-table thead { background: rgba(37, 99, 235, 0.07); }
body.theme-dark .data-table thead { background: rgba(37, 99, 235, 0.15); }

.data-table th, .data-table td {
  padding: 10px 12px;
  text-align: right;
  border: var(--border-w) solid var(--border-weak);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  vertical-align: middle;
}

.data-table th { font-weight: 900; color: rgba(15, 23, 42, 0.80); }
body.theme-dark .data-table th { color: var(--text); }

.data-table tbody tr:hover { background: rgba(248, 250, 252, 0.8); }
body.theme-dark .data-table tbody tr:hover { background: rgba(255, 255, 255, 0.05); }

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 900;
  border: 1px solid transparent;
}

.badge-success { background: rgba(22, 163, 74, 0.10); border-color: rgba(22, 163, 74, 0.18); color: #166534; }
body.theme-dark .badge-success { background: rgba(22, 163, 74, 0.2); color: #4ade80; border-color: rgba(22, 163, 74, 0.3); }

.badge-danger { background: rgba(220, 38, 38, 0.08); border-color: rgba(220, 38, 38, 0.16); color: #991b1b; }
body.theme-dark .badge-danger { background: rgba(220, 38, 38, 0.2); color: #f87171; border-color: rgba(220, 38, 38, 0.3); }

.badge-primary { background: rgba(37, 99, 235, 0.10); border-color: rgba(37, 99, 235, 0.18); color: var(--primary-700); }
body.theme-dark .badge-primary { background: rgba(37, 99, 235, 0.2); color: #60a5fa; border-color: rgba(37, 99, 235, 0.3); }

.badge-secondary { background: rgba(100, 116, 139, 0.10); border-color: rgba(100, 116, 139, 0.18); color: #334155; }
body.theme-dark .badge-secondary { background: rgba(100, 116, 139, 0.2); color: #94a3b8; border-color: rgba(100, 116, 139, 0.3); }

.pagination-container {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 14px;
  background: rgba(255, 255, 255, 0.65);
  border: var(--border-w) solid var(--border-weak);
  border-radius: var(--radius);
  margin-top: 14px;
  box-shadow: var(--shadow-sm);
  flex-wrap: wrap;
  gap: 12px;
}
body.theme-dark .pagination-container { background: rgba(15, 23, 42, 0.60); }

.pagination-info { font-size: 13px; color: var(--muted); font-weight: 700; }
.pagination-buttons { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }

.pagination-btn {
  padding: 8px 12px;
  border: var(--border-w) solid var(--border);
  background: rgba(255, 255, 255, 0.92);
  color: var(--text);
  border-radius: 12px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 900;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.15s ease;
  font-family: inherit;
}

body.theme-dark .pagination-btn {
    background: rgba(15, 23, 42, 0.8);
    border-color: var(--border);
}

.pagination-btn:hover:not(:disabled) { border-color: rgba(37, 99, 235, 0.25); background: rgba(37, 99, 235, 0.08); }
.pagination-btn.active { background: rgba(37, 99, 235, 0.12); border-color: rgba(37, 99, 235, 0.22); color: var(--primary-700); }
body.theme-dark .pagination-btn.active { color: #60a5fa; background: rgba(37, 99, 235, 0.25); }
.pagination-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.pagination-dots { padding: 0 8px; color: rgba(100, 116, 139, 0.9); font-weight: 900; }
body.theme-dark .pagination-dots { color: var(--muted); }

.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.35);
  display: none;
  justify-content: center;
  align-items: center;
  z-index: 9999;
  backdrop-filter: blur(6px);
}
.loading-overlay.show { display: flex; }

.spinner {
  width: 44px;
  height: 44px;
  border: 4px solid rgba(255, 255, 255, 0.35);
  border-top-color: rgba(255, 255, 255, 0.95);
  border-radius: 999px;
  animation: spin 1s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes slideDown { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: translateY(0); } }

.modal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.40);
  z-index: 1000;
  overflow-y: auto;
}

.modal.show {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 18px;
}

.modal-content {
  background: rgba(255, 255, 255, 0.98);
  border: var(--border-w) solid var(--border-weak);
  border-radius: var(--radius);
  max-width: 860px;
  width: 100%;
  max-height: 92vh;
  overflow-y: auto;
  box-shadow: var(--shadow);
  animation: modalSlide 0.18s ease;
}
body.theme-dark .modal-content { background: #0f172a; border-color: var(--border); }

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

.modal-header {
  padding: 14px 16px;
  border-bottom: var(--border-w) solid var(--border-weak);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.modal-title { font-size: 15px; font-weight: 900; }

.modal-close {
  background: rgba(255, 255, 255, 0.9);
  border: var(--border-w) solid var(--border);
  width: 40px;
  height: 40px;
  border-radius: 12px;
  cursor: pointer;
  color: var(--text);
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
}
body.theme-dark .modal-close { background: rgba(15, 23, 42, 0.7); }

.modal-body { padding: 16px; }

.modal-footer {
  padding: 12px 16px;
  border-top: var(--border-w) solid var(--border-weak);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

.action-icon {
  cursor: pointer;
  padding: 8px;
  border-radius: 12px;
  transition: background 0.15s ease, transform 0.15s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid transparent;
}
.action-icon:hover { background: rgba(248, 250, 252, 0.85); border-color: var(--border); }
body.theme-dark .action-icon:hover { background: rgba(255, 255, 255, 0.1); }
.action-icon:active { transform: translateY(1px); }

.action-icon.edit { color: var(--primary-700); }
body.theme-dark .action-icon.edit { color: #60a5fa; }
.action-icon.delete { color: var(--danger); }
body.theme-dark .action-icon.delete { color: #f87171; }
.action-icon.print { color: #166534; }
body.theme-dark .action-icon.print { color: #4ade80; }
.action-icon.finish { color: #0f766e; }
body.theme-dark .action-icon.finish { color: #2dd4bf; }

#finishTripModal .modal-content { max-width: 740px; }
#driverManageModal .modal-content { max-width: 980px; }
#finishTripModal .form-row { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin-bottom: 12px; }
#finishTripModal .form-group { margin-bottom: 12px; }
#finishTripModal .input-hint { display: block; color: var(--muted); font-size: 12px; margin-top: 6px; text-align: right; }
#finishTripModal .btn-group { display: flex; gap: 10px; justify-content: flex-end; margin-top: 14px; padding-top: 12px; border-top: var(--border-w) solid var(--border-weak); }

.jalali-date-picker {
  position: absolute;
  z-index: 20000;
  width: 320px;
  background: rgba(255, 255, 255, 0.98);
  border: var(--border-w) solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 12px;
  display: none;
  backdrop-filter: blur(10px);
}
.jalali-date-picker.show { display: block; }
body.theme-dark .jalali-date-picker {
  background: rgba(2, 6, 23, 0.92);
  border-color: rgba(148, 163, 184, 0.22);
}

.jalali-date-picker-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.jalali-date-picker-title {
  font-weight: 900;
  color: var(--text);
  font-size: 13px;
  text-align: center;
  flex: 1;
}

.jalali-date-picker-nav {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  border: var(--border-w) solid var(--border);
  background: rgba(248, 250, 252, 0.9);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s ease, background 0.15s ease, border-color 0.15s ease;
  font-family: inherit;
}
.jalali-date-picker-nav:hover { background: rgba(37, 99, 235, 0.08); border-color: rgba(37, 99, 235, 0.22); }
.jalali-date-picker-nav:active { transform: translateY(1px); }

.jalali-date-picker-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
  margin-bottom: 8px;
  color: var(--muted);
  font-weight: 900;
  font-size: 12px;
  text-align: center;
}

.jalali-date-picker-days {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
}

.jalali-date-picker-day,
.jalali-date-picker-empty {
  height: 38px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 900;
  user-select: none;
}
.jalali-date-picker-empty { opacity: 0.0; pointer-events: none; }

.jalali-date-picker-day {
  cursor: pointer;
  border: var(--border-w) solid var(--border-weak);
  background: rgba(255, 255, 255, 0.92);
  color: var(--text);
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.15s ease;
}
.jalali-date-picker-day:hover { background: rgba(37, 99, 235, 0.08); border-color: rgba(37, 99, 235, 0.22); }
.jalali-date-picker-day:active { transform: translateY(1px); }
.jalali-date-picker-day.selected { background: rgba(37, 99, 235, 0.12); border-color: rgba(37, 99, 235, 0.22); color: var(--primary-700); }

body.theme-dark .jalali-date-picker-nav {
  background: rgba(15, 23, 42, 0.72);
  border-color: rgba(148, 163, 184, 0.22);
  color: var(--text);
}
body.theme-dark .jalali-date-picker-nav:hover {
  background: rgba(59, 130, 246, 0.14);
  border-color: rgba(59, 130, 246, 0.30);
}

body.theme-dark .jalali-date-picker-day {
  background: rgba(15, 23, 42, 0.72);
  border-color: rgba(148, 163, 184, 0.18);
  color: var(--text);
}
body.theme-dark .jalali-date-picker-day:hover {
  background: rgba(59, 130, 246, 0.14);
  border-color: rgba(59, 130, 246, 0.30);
}
body.theme-dark .jalali-date-picker-day.selected {
  background: rgba(59, 130, 246, 0.22);
  border-color: rgba(59, 130, 246, 0.38);
  color: var(--text);
}

@media (max-width: 980px) {
  .app-body { grid-template-columns: 1fr; }
  .sidebar { position: fixed; top: 74px; right: 18px; left: 18px; height: calc(100vh - 90px); max-height: none; display: none; z-index: 9990; }
  body.sidebar-open .sidebar { display: flex; }
  body.sidebar-open { overflow: hidden; }
  .app-header-inner { padding: 12px 14px; }
  
  body.sidebar-open .sidebar-backdrop { display: block; }
}

.sidebar-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.35);
  backdrop-filter: blur(6px);
  display: none;
  z-index: 9980;
}

/* User Chip */
.user-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 999px;
  border: 1px solid var(--border-weak);
  background: rgba(255, 255, 255, 0.70);
  backdrop-filter: blur(10px);
  color: var(--text);
  font-weight: 800;
  max-width: min(340px, 50vw);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
body.theme-dark .user-chip { background: rgba(2, 6, 23, 0.55); }

/* Login */
body.login-open { overflow: hidden; }

.login-overlay {
  position: fixed;
  inset: 0;
  z-index: 100000;
  display: none;
  place-items: center;
  padding: 20px;
  background: var(--login-bg-image, none);
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
}

.login-card {
  width: min(440px, calc(100vw - 40px));
  background: var(--surface);
  border: 1px solid var(--border-weak);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
}

.login-hero {
  height: 140px;
  border-radius: calc(var(--radius) - 6px);
  margin-bottom: 12px;
  background: var(--login-hero-image, none);
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  border: 1px solid rgba(255, 255, 255, 0.25);
}

.login-title { font-size: 18px; font-weight: 900; margin-bottom: 4px; }
.login-subtitle { font-size: 13px; color: var(--muted); margin-bottom: 12px; }
.login-error { min-height: 20px; color: var(--danger); font-weight: 800; margin-bottom: 10px; }

.login-password-row {
  display: flex;
  gap: 10px;
  align-items: center;
}
.login-password-row .form-input { flex: 1; }

body.auth-logged-out .app-container { display: none; }
body.auth-logged-out #sidebarBackdrop { display: none; }
body.auth-logged-out #alertContainer { display: none; }
body.auth-logged-out #loginOverlay { display: grid !important; }
body.auth-logged-in #loginOverlay { display: none !important; }

.jdp-fallback {
  position: absolute;
  top: 0;
  left: 0;
  width: 280px;
  display: none;
  z-index: 100001;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 10px;
}
body.theme-dark .jdp-fallback { background: #0f172a; }
.jdp-fallback.open { display: block; }
.jdp-fallback-header { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.jdp-fallback-title { font-weight: 900; color: var(--text); font-size: 13px; }
.jdp-fallback-weekdays { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; margin-bottom: 6px; color: var(--muted); font-size: 12px; font-weight: 800; text-align: center; }
.jdp-fallback-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.jdp-fallback-cell {
  width: 100%;
  aspect-ratio: 1 / 1;
  border-radius: 10px;
  border: 1px solid var(--border-weak);
  background: rgba(255, 255, 255, 0.65);
  color: var(--text);
  font-weight: 800;
  cursor: pointer;
}
body.theme-dark .jdp-fallback-cell { background: rgba(2, 6, 23, 0.35); }
.jdp-fallback-cell:hover { border-color: var(--border); background: rgba(59, 130, 246, 0.10); }
.jdp-fallback-cell.empty { visibility: hidden; pointer-events: none; }

body:not(.is-admin) .admin-only { display: none !important; }

/* Print Styles */
@media print {
  @page {
    size: A4;
    margin: 20mm;
  }
  
  body * {
    visibility: hidden;
  }
  
  #printArea, #printArea * {
    visibility: visible;
  }
  
  #printArea {
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
  }
}
