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

:root {
  --sidebar-width: 260px;
  --bg-app: #f0f4f8;
  --bg-card: #ffffff;
  --bg-card-hover: #f8fafc;
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;
  --text-inverse: #f8fafc;
  --border: rgba(0, 0, 0, 0.08);
  --brand-primary: #0d9488;
  --brand-secondary: #0ea5e9;
  --status-free: #10b981;
  --status-busy: #f59e0b;
  --status-break: #64748b;
  --status-alert: #f43f5e;

  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.07), 0 2px 4px -1px rgba(0, 0, 0, 0.04);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  --shadow-xl: 0 25px 50px -12px rgba(0, 0, 0, 0.15);

  /* Font */
  --font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

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

body.app-layout {
  font-family: var(--font-family);
  background-color: var(--bg-app);
  color: var(--text-primary);
  display: grid;
  grid-template-columns: var(--sidebar-width) 1fr;
  height: 100vh;
  overflow: hidden;
}

/* Sidebar Styling */
.sidebar {
  background: linear-gradient(180deg, #1e293b 0%, #0f172a 100%);
  color: var(--text-inverse);
  display: flex;
  flex-direction: column;
  height: 100vh;
  border-right: 1px solid rgba(255, 255, 255, 0.08);
  z-index: 1000;
}

.sidebar-brand {
  padding: 24px 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.sidebar-brand .brand-name {
  font-size: 1.5rem;
  font-weight: 800;
  background: linear-gradient(135deg, #0d9488 0%, #0ea5e9 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  display: flex;
  align-items: center;
  gap: 8px;
}

.sidebar-brand .brand-name i {
  -webkit-text-fill-color: #0d9488;
}

.sidebar-brand .brand-subtitle {
  font-size: 0.75rem;
  color: rgba(255, 255, 255, 0.4);
  margin-top: 4px;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.sidebar-nav {
  flex: 1;
  padding: 16px 12px;
  overflow-y: auto;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  color: #94a3b8;
  font-weight: 500;
  font-size: 0.9rem;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.2s ease;
  margin-bottom: 6px;
}

.nav-item:hover {
  background: rgba(255, 255, 255, 0.06);
  color: #f8fafc;
}

.nav-item.active {
  background: rgba(13, 148, 136, 0.2);
  color: #5eead4;
  font-weight: 600;
}

.nav-item .nav-icon {
  font-size: 1.2rem;
  width: 24px;
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
}

.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  font-size: 0.75rem;
  color: rgba(255, 255, 255, 0.4);
}

.sync-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: #64748b;
  transition: all 0.3s ease;
}

.dot.live {
  background-color: var(--status-free);
  box-shadow: 0 0 8px var(--status-free);
}

.dot.error {
  background-color: var(--status-alert);
  box-shadow: 0 0 8px var(--status-alert);
}

.version-tag {
  display: inline-block;
  font-size: 0.65rem;
  background: rgba(255, 255, 255, 0.08);
  padding: 2px 8px;
  border-radius: 10px;
  color: rgba(255, 255, 255, 0.5);
  font-weight: 500;
}

/* Main Content Layout */
.main-content {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow-y: auto;
}

.content-header {
  position: sticky;
  top: 0;
  background: rgba(240, 244, 248, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  padding: 16px 32px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border);
  z-index: 100;
}

.content-body {
  flex: 1;
  padding: 24px 32px;
  max-width: 1400px;
  width: 100%;
  margin: 0 auto;
}

/* View Sections */
.view-section {
  display: none;
  animation: viewFadeIn 0.3s ease-out;
}

.view-section.active {
  display: block;
}

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

/* Dashboard Elements */
.dashboard-greeting {
  font-size: 1.8rem;
  font-weight: 800;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.dashboard-date {
  font-size: 0.95rem;
  color: var(--text-muted);
  margin-bottom: 24px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 20px;
  margin-bottom: 32px;
}

.stat-card {
  border-radius: 16px;
  padding: 24px;
  color: #ffffff;
  position: relative;
  overflow: hidden;
  min-height: 120px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  box-shadow: var(--shadow-md);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.stat-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-lg);
}

.stat-card .stat-emoji {
  font-size: 1.5rem;
  z-index: 2;
}

.stat-card .stat-value {
  font-size: 2.5rem;
  font-weight: 800;
  line-height: 1;
  z-index: 2;
}

.stat-card .stat-label {
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  opacity: 0.9;
  z-index: 2;
}

.stat-card::after {
  content: '';
  position: absolute;
  top: -20px;
  right: -20px;
  width: 100px;
  height: 100px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 50%;
  z-index: 1;
}

.stat-card.teal { background: var(--gradient-teal); }
.stat-card.indigo { background: var(--gradient-indigo); }
.stat-card.emerald { background: var(--gradient-emerald); }
.stat-card.amber { background: var(--gradient-amber); }

.quick-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 32px;
}

.quick-action-card {
  background: var(--bg-card);
  border-radius: 16px;
  padding: 20px;
  border: 1px solid var(--border);
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  gap: 16px;
  box-shadow: var(--shadow-sm);
}

.quick-action-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: rgba(13, 148, 136, 0.3);
}

.quick-action-card .qa-icon {
  font-size: 2rem;
}

.quick-action-card .qa-text h4 {
  margin: 0;
  font-weight: 700;
  color: var(--text-primary);
  font-size: 1rem;
}

.quick-action-card .qa-text p {
  margin: 4px 0 0;
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.dashboard-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}

.dashboard-section {
  background: var(--bg-card);
  border-radius: 16px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.dashboard-section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px 20px;
  border-bottom: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.01);
}

.dashboard-section-header h3 {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.dashboard-section-header .section-badge {
  font-size: 0.75rem;
  background: rgba(13, 148, 136, 0.1);
  color: var(--brand-primary);
  padding: 2px 10px;
  border-radius: 20px;
  font-weight: 600;
}

.dashboard-section-body {
  padding: 16px;
  max-height: 480px;
  overflow-y: auto;
  flex: 1;
}

#dashboard-fleet {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

#dashboard-fleet .card {
  margin-bottom: 0;
}

@media (max-width: 500px) {
  #dashboard-fleet {
    grid-template-columns: 1fr;
  }
}

.dashboard-section-body:empty::after {
  content: 'Nothing here yet';
  display: block;
  text-align: center;
  padding: 40px 20px;
  color: var(--text-muted);
  font-size: 0.9rem;
  font-style: italic;
}

/* Fleet View */
.fleet-header {
  margin-bottom: 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.fleet-header h2 {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 800;
}

.fleet-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 16px;
}

/* Log Job View */
.log-job-container {
  max-width: 600px;
  background: var(--bg-card);
  padding: 32px;
  border-radius: 16px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}

.log-job-container h2 {
  font-size: 1.5rem;
  margin-bottom: 24px;
  font-weight: 800;
}

/* Cards UI */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-left: 4px solid var(--text-muted);
  border-radius: 12px;
  padding: 14px 16px;
  margin-bottom: 12px;
  cursor: pointer;
  transition: all 0.2s ease;
  position: relative;
  box-shadow: var(--shadow-sm);
}

.card:hover {
  transform: translateX(3px);
  box-shadow: var(--shadow-md);
  border-color: rgba(0, 0, 0, 0.12);
}

.card.free { border-left-color: var(--status-free); }
.card.busy { border-left-color: var(--status-busy); }
.card.break { border-left-color: var(--status-break); opacity: 0.75; }

.card.alert {
  border: 1px solid var(--status-alert);
  border-left: 4px solid var(--status-alert);
  animation: pulse-border 2s infinite;
}

@keyframes pulse-border {
  0% { box-shadow: 0 0 0 0 rgba(244, 63, 94, 0.4); }
  70% { box-shadow: 0 0 0 8px rgba(244, 63, 94, 0); }
  100% { box-shadow: 0 0 0 0 rgba(244, 63, 94, 0); }
}

/* Buttons */
.btn-main, .btn-sec, .btn-warn, .btn-danger {
  border: none;
  padding: 12px 20px;
  width: 100%;
  border-radius: 10px;
  font-weight: 600;
  font-size: 0.95rem;
  margin-bottom: 8px;
  color: #ffffff;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: var(--font-family);
}

.btn-main {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  box-shadow: 0 4px 6px rgba(16, 185, 129, 0.2);
}
.btn-main:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 12px rgba(16, 185, 129, 0.3);
}

.btn-sec {
  background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
  box-shadow: 0 4px 6px rgba(59, 130, 246, 0.2);
}
.btn-sec:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 12px rgba(59, 130, 246, 0.3);
}

.btn-warn {
  background: linear-gradient(135deg, #64748b 0%, #475569 100%);
  box-shadow: 0 4px 6px rgba(100, 116, 139, 0.2);
}
.btn-warn:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 12px rgba(100, 116, 139, 0.3);
}

.btn-danger {
  background: linear-gradient(135deg, #f43f5e 0%, #e11d48 100%);
  box-shadow: 0 4px 6px rgba(244, 63, 94, 0.2);
}
.btn-danger:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 12px rgba(244, 63, 94, 0.3);
}

.btn-cancel-job {
  background: rgba(0, 0, 0, 0.04);
  border: 1px solid rgba(0, 0, 0, 0.08);
  color: var(--text-secondary);
  border-radius: 6px;
  padding: 4px 8px;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.btn-cancel-job:hover {
  background: rgba(244, 63, 94, 0.1);
  color: var(--status-alert);
  border-color: rgba(244, 63, 94, 0.2);
}

.btn-head {
  background: rgba(0, 0, 0, 0.05);
  color: var(--text-secondary);
  border: 1px solid var(--border);
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.btn-head:hover {
  background: rgba(0, 0, 0, 0.08);
  color: var(--text-primary);
}

.btn-head.logout {
  background: rgba(244, 63, 94, 0.08);
  border-color: rgba(244, 63, 94, 0.2);
  color: var(--status-alert);
}

.btn-head.logout:hover {
  background: rgba(244, 63, 94, 0.15);
  color: #e11d48;
}

/* Inputs and Labels */
.input-std {
  width: 100%;
  padding: 12px 14px;
  margin-bottom: 16px;
  background: #ffffff;
  border: 1px solid rgba(0, 0, 0, 0.12);
  color: var(--text-primary);
  border-radius: 8px;
  transition: all 0.2s ease;
  font-size: 0.9rem;
  font-family: var(--font-family);
  outline: none;
}

.input-std:focus {
  border-color: var(--brand-primary);
  box-shadow: 0 0 0 3px rgba(13, 148, 136, 0.12);
}

.lbl {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-secondary);
  margin-bottom: 6px;
  display: block;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

#preview-box {
  background: rgba(13, 148, 136, 0.05);
  border: 1px solid rgba(13, 148, 136, 0.15);
  color: #0b7a70;
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 0.8rem;
  margin-bottom: 16px;
  display: none;
  font-weight: 500;
}

/* Database Table Styles */
.db-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
  text-align: left;
}

.db-table th {
  background: rgba(0, 0, 0, 0.02);
  padding: 12px 16px;
  border-bottom: 2px solid var(--border);
  color: var(--text-secondary);
  font-weight: 700;
  text-transform: uppercase;
  font-size: 0.75rem;
  letter-spacing: 0.5px;
}

.db-table td {
  padding: 12px 16px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.04);
  color: var(--text-primary);
  vertical-align: middle;
}

.btn-edit {
  color: #2563eb;
  font-weight: 600;
  cursor: pointer;
  padding: 4px 10px;
  border-radius: 6px;
  background: rgba(37, 99, 235, 0.08);
  margin-right: 6px;
  display: inline-block;
  transition: all 0.2s ease;
  font-size: 0.8rem;
  border: none;
}

.btn-edit:hover {
  background: rgba(37, 99, 235, 0.15);
}

.btn-del {
  color: #e11d48;
  font-weight: 600;
  cursor: pointer;
  padding: 4px 10px;
  border-radius: 6px;
  background: rgba(244, 63, 94, 0.08);
  display: inline-block;
  transition: all 0.2s ease;
  font-size: 0.8rem;
  border: none;
}

.btn-del:hover {
  background: rgba(244, 63, 94, 0.15);
}

/* Tab Switching Group */
.tab-group {
  display: flex;
  gap: 4px;
  margin-bottom: 20px;
  background: rgba(0, 0, 0, 0.04);
  padding: 4px;
  border-radius: 10px;
}

.tab-btn {
  flex: 1;
  padding: 10px;
  border: none;
  background: transparent;
  cursor: pointer;
  font-weight: 600;
  border-radius: 8px;
  color: var(--text-secondary);
  font-family: var(--font-family);
  transition: all 0.2s ease;
  font-size: 0.85rem;
}

.tab-btn.active {
  background: #ffffff;
  color: var(--text-primary);
  box-shadow: var(--shadow-sm);
}

/* Modals Overlay & Body */
.modal-mask {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(15, 23, 42, 0.4);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: none;
  justify-content: center;
  align-items: center;
  z-index: 5000;
}

.modal {
  background: #ffffff;
  padding: 32px;
  border-radius: 20px;
  width: 550px;
  max-width: 95vw;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-xl);
  border: 1px solid var(--border);
  animation: modalPop 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.modal h2 {
  margin-top: 0;
  margin-bottom: 20px;
  font-weight: 800;
  color: var(--text-primary);
  font-size: 1.5rem;
}

@keyframes modalPop {
  from {
    transform: scale(0.95);
    opacity: 0;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}

/* Login Screen Cover */
#login-screen {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #0f172a 0%, #1e293b 50%, #0d9488 100%);
}

#login-box {
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(20px);
  padding: 48px;
  border-radius: 24px;
  text-align: center;
  width: 380px;
  box-shadow: 0 25px 50px rgba(0, 0, 0, 0.3);
  animation: modalPop 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}

#login-box h1 {
  margin-top: 0;
  font-size: 2.2rem;
  margin-bottom: 5px;
  color: #0f172a;
  font-weight: 800;
}

#login-box h1 i {
  color: #0d9488;
  margin-right: 8px;
}

#login-box input {
  width: 100%;
  padding: 14px;
  margin-top: 16px;
  border-radius: 12px;
  border: 1px solid rgba(0, 0, 0, 0.12);
  font-size: 1rem;
  background: #ffffff;
  color: #0f172a;
  outline: none;
  font-family: var(--font-family);
  transition: all 0.2s ease;
}

#login-box input:focus {
  border-color: #0d9488;
  box-shadow: 0 0 0 3px rgba(13, 148, 136, 0.15);
}

#login-box button {
  width: 100%;
  padding: 14px;
  margin-top: 12px;
  border-radius: 12px;
  border: none;
  background: linear-gradient(135deg, #0d9488, #0ea5e9);
  color: #ffffff;
  font-weight: 700;
  font-size: 1rem;
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: var(--font-family);
}

#login-box button:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 20px rgba(13, 148, 136, 0.35);
}

/* Toast System */
#toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.toast {
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-left: 4px solid #3b82f6;
  color: #0f172a;
  padding: 14px 20px;
  border-radius: 10px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.12);
  font-size: 0.9rem;
  font-weight: 600;
  transform: translateX(120%);
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.3s, max-width 0.3s;
  opacity: 0;
  max-width: 350px;
}

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

.toast.success { border-left-color: #10b981; }
.toast.error { border-left-color: #f43f5e; }
.toast.warning { border-left-color: #f59e0b; }
.toast.info { border-left-color: #0ea5e9; }

/* Vehicle Toggle Buttons */
.veh-btn {
  flex: 1;
  padding: 12px;
  border: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.02);
  cursor: pointer;
  font-weight: 600;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: var(--text-primary);
  transition: all 0.2s ease;
  font-family: var(--font-family);
}

.veh-btn.active {
  background: rgba(13, 148, 136, 0.1);
  color: #0d9488;
  border-color: rgba(13, 148, 136, 0.3);
}

/* Badges and tags */
.time-badge {
  font-size: 0.75rem;
  background: rgba(14, 165, 233, 0.1);
  color: #0ea5e9;
  padding: 2px 8px;
  border-radius: 12px;
  font-weight: 600;
  display: inline-block;
}

.mileage-tag {
  background: rgba(0, 0, 0, 0.05);
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 0.75rem;
  color: var(--text-secondary);
  font-weight: 600;
  display: inline-block;
}

/* History Inline View Styles */
.history-header {
  margin-bottom: 20px;
}

.history-header h2 {
  font-size: 1.5rem;
  font-weight: 800;
  margin: 0;
  display: flex;
  align-items: center;
  gap: 10px;
}

.history-subtitle {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 4px;
}

.history-time-filters {
  display: flex;
  gap: 4px;
  margin-bottom: 16px;
  background: rgba(0, 0, 0, 0.04);
  padding: 4px;
  border-radius: 10px;
}

.history-time-btn {
  flex: 1;
  padding: 8px 6px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-weight: 600;
  font-size: 0.8rem;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: var(--font-family);
}

.history-time-btn:hover {
  background: rgba(0, 0, 0, 0.04);
  color: var(--text-primary);
}

.history-time-btn.active {
  background: linear-gradient(135deg, rgba(13, 148, 136, 0.15), rgba(14, 165, 233, 0.1));
  color: #0d9488;
  box-shadow: var(--shadow-sm);
}

.history-search-row {
  margin-bottom: 16px;
}

.history-stats {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.stat-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 600;
  background: rgba(0, 0, 0, 0.03);
  border: 1px solid var(--border);
  color: var(--text-secondary);
}

.stat-chip i { font-size: 0.75rem; }
.stat-chip:nth-child(1) i { color: #10b981; }
.stat-chip:nth-child(2) i { color: #0ea5e9; }
.stat-chip:nth-child(3) i { color: #6366f1; }

.history-results {
  max-height: 550px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #ffffff;
  padding: 16px;
}

.history-date-group {
  margin-bottom: 20px;
}

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

.history-date-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
}

.history-date-label {
  font-weight: 700;
  font-size: 0.85rem;
  color: #6366f1;
  white-space: nowrap;
}

.history-date-count {
  font-size: 0.75rem;
  color: var(--text-muted);
  background: rgba(0, 0, 0, 0.04);
  padding: 2px 8px;
  border-radius: 10px;
  font-weight: 600;
}

.history-date-line {
  flex: 1;
  height: 1px;
  background: var(--border);
}

.history-job {
  display: grid;
  grid-template-columns: 110px 1fr auto;
  gap: 16px;
  align-items: start;
  padding: 12px 14px;
  margin-bottom: 8px;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.01);
  border: 1px solid rgba(0, 0, 0, 0.03);
  transition: all 0.15s ease;
  animation: histFadeIn 0.3s ease-out;
}

.history-job:hover {
  background: rgba(0, 0, 0, 0.03);
  border-color: rgba(99, 102, 241, 0.15);
}

.history-job:last-child {
  margin-bottom: 0;
}

.history-job-meta {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.history-job-ref {
  font-weight: 800;
  font-size: 0.85rem;
  color: #0ea5e9;
}

.history-job-time {
  font-size: 0.75rem;
  color: var(--text-muted);
  white-space: nowrap;
}

.history-job-route {
  font-size: 0.9rem;
  font-weight: 600;
  margin-bottom: 4px;
}

.history-job-route .arrow {
  color: var(--text-muted);
  margin: 0 4px;
}

.history-job-details {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.history-job-detail {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.history-job-detail i {
  font-size: 0.7rem;
  color: var(--text-muted);
}

.history-job-miles {
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 700;
  background: rgba(14, 165, 233, 0.08);
  border: 1px solid rgba(14, 165, 233, 0.15);
  color: #0ea5e9;
  white-space: nowrap;
  align-self: center;
}

.history-empty {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-muted);
}

.history-empty i {
  font-size: 2.5rem;
  display: block;
  margin-bottom: 14px;
  opacity: 0.4;
}

.history-empty p {
  margin: 0;
  font-size: 0.9rem;
}

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

/* Controller Quick Guide Styles */
#controller-guide {
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}

#controller-guide h4 {
  margin: 0 0 14px;
  font-size: 0.85rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
}

#controller-guide h4 i {
  color: #6366f1;
}

.guide-steps {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 16px;
}

.guide-step {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.step-num {
  flex-shrink: 0;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: linear-gradient(135deg, #6366f1, #0ea5e9);
  color: #ffffff;
  font-size: 0.7rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 1px;
}

.step-text {
  font-size: 0.78rem;
  line-height: 1.45;
  color: var(--text-secondary);
}

.step-text strong {
  color: var(--text-primary);
  font-weight: 600;
}

.step-text em {
  color: #0d9488;
  font-style: normal;
  font-weight: 600;
}

.guide-reminder {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px;
  border-radius: 10px;
  background: rgba(245, 158, 11, 0.06);
  border: 1px solid rgba(245, 158, 11, 0.15);
  margin-top: 8px;
}

.guide-reminder > i {
  color: #f59e0b;
  font-size: 1rem;
  margin-top: 2px;
  flex-shrink: 0;
}

.guide-reminder strong {
  display: block;
  font-size: 0.8rem;
  color: #d97706;
  margin-bottom: 4px;
  font-weight: 700;
}

.guide-reminder p {
  margin: 0;
  font-size: 0.75rem;
  line-height: 1.5;
  color: var(--text-secondary);
}

/* NOK display inside rider menu modal */
.nok-warning-box {
  background: rgba(245, 158, 11, 0.06);
  border: 1px solid rgba(245, 158, 11, 0.15);
  color: #92400e;
  padding: 10px;
  border-radius: 8px;
  margin-bottom: 15px;
  font-size: 0.85rem;
  font-weight: 500;
}

/* Mobile Nav Bottom Bar */
#mobile-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 64px;
  background: #ffffff;
  border-top: 1px solid var(--border);
  z-index: 3000;
  justify-content: space-around;
  align-items: center;
  box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.05);
}

.nav-item-mobile {
  text-align: center;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.7rem;
  font-weight: 500;
  flex: 1;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  transition: all 0.2s ease;
  gap: 2px;
}

.nav-item-mobile.active {
  color: #0d9488;
  font-weight: 600;
}

.nav-item-mobile i {
  font-size: 1.3rem;
  margin-bottom: 2px;
}

/* Custom Scrollbars */
.main-content::-webkit-scrollbar {
  width: 6px;
}
.main-content::-webkit-scrollbar-track {
  background: transparent;
}
.main-content::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.15);
  border-radius: 4px;
}

.dashboard-section-body::-webkit-scrollbar,
.history-results::-webkit-scrollbar {
  width: 5px;
}
.dashboard-section-body::-webkit-scrollbar-track,
.history-results::-webkit-scrollbar-track {
  background: transparent;
}
.dashboard-section-body::-webkit-scrollbar-thumb,
.history-results::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.1);
  border-radius: 4px;
}

/* ============================================================
   DARK THEME OVERRIDES
   ============================================================ */
.dark-theme {
  --bg-app: #0f172a;
  --bg-card: #1e293b;
  --bg-card-hover: #334155;
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --border: rgba(255, 255, 255, 0.08);
  
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.2);
  --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.4);
}

.dark-theme .content-header {
  background: rgba(15, 23, 42, 0.85);
  border-bottom-color: rgba(255, 255, 255, 0.06);
}

.dark-theme .card {
  background: var(--bg-card);
  border-color: rgba(255, 255, 255, 0.06);
}

.dark-theme .card:hover {
  background: var(--bg-card-hover);
}

.dark-theme .dashboard-section {
  background: var(--bg-card);
  border-color: rgba(255, 255, 255, 0.06);
}

.dark-theme .dashboard-section-header {
  background: rgba(255, 255, 255, 0.02);
}

.dark-theme .quick-action-card {
  background: var(--bg-card);
  border-color: rgba(255, 255, 255, 0.06);
}

.dark-theme .quick-action-card:hover {
  background: var(--bg-card-hover);
}

.dark-theme .input-std {
  background: rgba(0, 0, 0, 0.3);
  border-color: rgba(255, 255, 255, 0.1);
  color: var(--text-primary);
}

.dark-theme .input-std option {
  background: #1e293b;
  color: #f8fafc;
}

.dark-theme .db-table th {
  background: rgba(0, 0, 0, 0.2);
  color: #94a3b8;
}

.dark-theme .db-table td {
  border-bottom-color: rgba(255, 255, 255, 0.04);
}

.dark-theme .tab-group {
  background: rgba(0, 0, 0, 0.2);
}

.dark-theme .tab-btn.active {
  background: rgba(255, 255, 255, 0.1);
  color: #f8fafc;
}

.dark-theme .modal {
  background: #1e293b;
  border-color: rgba(255, 255, 255, 0.08);
}

.dark-theme .modal h2 {
  color: #f8fafc;
}

.dark-theme #login-box {
  background: rgba(30, 41, 59, 0.95);
  box-shadow: 0 25px 50px rgba(0, 0, 0, 0.5);
}

.dark-theme #login-box h1 {
  color: #f8fafc;
}

.dark-theme #login-box input {
  background: rgba(0, 0, 0, 0.3);
  border-color: rgba(255, 255, 255, 0.1);
  color: #f8fafc;
}

.dark-theme .toast {
  background: rgba(30, 41, 59, 0.95);
  color: #f8fafc;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.3);
}

.dark-theme .btn-cancel-job {
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(255, 255, 255, 0.08);
  color: var(--text-secondary);
}

.dark-theme .btn-cancel-job:hover {
  background: rgba(244, 63, 94, 0.15);
  color: var(--status-alert);
}

.dark-theme .veh-btn {
  background: rgba(255, 255, 255, 0.04);
  border-color: rgba(255, 255, 255, 0.08);
  color: #e2e8f0;
}

.dark-theme .veh-btn.active {
  background: rgba(13, 148, 136, 0.2);
  color: #5eead4;
}

.dark-theme .history-time-filters {
  background: rgba(0, 0, 0, 0.2);
}

.dark-theme .stat-chip {
  background: rgba(255, 255, 255, 0.04);
  border-color: rgba(255, 255, 255, 0.06);
}

.dark-theme .history-results {
  background: #1e293b;
  border-color: rgba(255, 255, 255, 0.08);
}

.dark-theme .history-job {
  background: rgba(255, 255, 255, 0.01);
  border-color: rgba(255, 255, 255, 0.03);
}

.dark-theme .history-job:hover {
  background: rgba(255, 255, 255, 0.03);
}

.dark-theme .nok-warning-box {
  background: rgba(245, 158, 11, 0.1);
  color: #fbbf24;
}

.dark-theme #mobile-nav {
  background: #1e293b;
  border-top-color: rgba(255, 255, 255, 0.06);
  box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.2);
}

.dark-theme .btn-head {
  background: rgba(255, 255, 255, 0.05);
  color: #e2e8f0;
  border-color: rgba(255, 255, 255, 0.1);
}

.dark-theme .btn-head:hover {
  background: rgba(255, 255, 255, 0.1);
}

.dark-theme .main-content::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
}

/* ============================================================
   MOBILE RESPONSIVENESS
   ============================================================ */
@media (max-width: 768px) {
  body.app-layout {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr 64px;
    height: 100vh;
  }
  
  .sidebar {
    display: none; /* Hidden on mobile, replaced by bottom nav */
  }
  
  .main-content {
    grid-row: 1;
    height: calc(100vh - 64px);
  }
  
  #mobile-nav {
    display: flex !important;
    grid-row: 2;
  }
  
  .content-header {
    padding: 10px 14px;
    flex-wrap: wrap;
    gap: 8px;
  }
  .content-header > div {
    flex-wrap: wrap;
    justify-content: flex-start;
    gap: 6px;
  }
  .content-header .btn-head {
    padding: 7px 9px;
    font-size: 0.78rem;
  }
  .content-header .btn-head[title="Analytics"] { display: none; }

  .content-body {
    padding: 16px;
  }
  
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
  }
  
  .dashboard-grid {
    grid-template-columns: 1fr;
    gap: 16px;
  }
  
  .quick-actions {
    grid-template-columns: 1fr;
    gap: 12px;
  }
  
  .fleet-grid {
    grid-template-columns: 1fr;
  }
  
  .modal {
    width: 95% !important;
    max-height: 85vh;
    padding: 20px;
    border-radius: 16px;
  }
  
  .stat-card .stat-value {
    font-size: 2rem;
  }
  
  .history-job {
    grid-template-columns: 1fr;
    gap: 8px;
  }
  
  .history-job-miles {
    align-self: flex-start;
  }
  
  .history-time-filters {
    flex-wrap: wrap;
  }
}

@media (max-width: 500px) {
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
  }
  
  .stat-card {
    padding: 16px;
    min-height: 90px;
  }
  
  .stat-card .stat-value {
    font-size: 1.6rem;
  }
  
  .modal .row {
    grid-template-columns: 1fr;
    gap: 8px;
  }
  
  .dashboard-greeting {
    font-size: 1.4rem;
  }
}

/* --- 14-DAY CALENDAR ROTA --- */
.calendar-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 12px;
    margin-top: 15px;
}
.calendar-day {
    background: var(--bg-app, #ffffff);
    border: 1px solid var(--border, rgba(0,0,0,0.1));
    border-radius: 8px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    min-height: 120px;
}
.calendar-day.today {
    border-color: #0ea5e9;
    box-shadow: 0 0 10px rgba(14, 165, 233, 0.2);
}
.calendar-day.warning {
    border-color: #f43f5e;
}
.calendar-day-header {
    background: rgba(0,0,0,0.03);
    padding: 8px 10px;
    font-size: 0.85rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border, rgba(0,0,0,0.05));
    color: var(--text-primary, #0f172a);
}
.coverage-badge {
    background: rgba(244, 63, 94, 0.15);
    color: #f43f5e;
    padding: 2px 6px;
    border-radius: 12px;
    font-size: 0.7rem;
    font-weight: 600;
}
.calendar-day-body {
    padding: 10px;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.no-shifts {
    color: var(--text-muted, #94a3b8);
    font-size: 0.8rem;
    text-align: center;
    margin-top: auto;
    margin-bottom: auto;
}
.shift-entry {
    background: rgba(0,0,0,0.03);
    border-radius: 6px;
    padding: 6px;
    font-size: 0.8rem;
    border-left: 3px solid #0ea5e9;
}
.shift-time {
    color: var(--text-muted, #94a3b8);
    font-size: 0.75rem;
    margin-bottom: 3px;
}
.shift-details {
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.shift-person {
    color: var(--text-primary, #0f172a);
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 5px;
}
.btn-del-shift {
    background: none;
    border: none;
    color: #f43f5e;
    cursor: pointer;
    opacity: 0.7;
}
.btn-del-shift:hover {
    opacity: 1;
}

/* --- ITEM SELECTOR --- */
.item-selector-btn {
    width: 100%;
    padding: 10px 14px;
    margin-bottom: 12px;
    background: var(--bg-card-hover, #f8fafc);
    border: 1px solid var(--border, #e2e8f0);
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: all 0.2s;
    box-sizing: border-box;
}
.item-selector-btn:hover {
    border-color: var(--primary, #0ea5e9);
    background: var(--bg-card, #ffffff);
}

.item-category {
    margin-bottom: 8px;
    border: 1px solid var(--border, #e2e8f0);
    border-radius: 8px;
    overflow: hidden;
}
.item-category-header {
    background: var(--bg-card-hover, #f1f5f9);
    padding: 10px 15px;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 600;
    color: var(--text-primary, #0f172a);
}
.item-category-header:hover {
    background: var(--border, #e2e8f0);
}
.item-category-body {
    background: var(--bg-card, #ffffff);
}
.item-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 15px;
    border-top: 1px solid var(--border, #e2e8f0);
    font-size: 0.9rem;
    color: var(--text-primary, #1e293b);
}
.item-controls {
    display: flex;
    align-items: center;
    gap: 10px;
}
.btn-qty {
    background: var(--bg-card-hover, #f1f5f9);
    border: 1px solid var(--border, #cbd5e1);
    border-radius: 4px;
    width: 28px;
    height: 28px;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    font-weight: bold;
    color: var(--text-primary, #0f172a);
}
.btn-qty:hover {
    background: var(--primary, #0ea5e9);
    color: #ffffff;
    border-color: var(--primary, #0ea5e9);
}
.item-qty {
    min-width: 20px;
    text-align: center;
    font-weight: 600;
}
