/* v4.65: the Inter @import from Google Fonts is gone. The typeface is our own copy,
   declared in ui.css (which index2.html loads first); 'Inter' below now means it. */

: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;

  /* Dashboard stat-card gradients. These were referenced by .stat-card.teal
     etc. but never defined, so the cards rendered transparent — white text on
     the near-white page, i.e. invisible numbers. Defined here so the four hero
     stats read clearly (white-on-colour, strong contrast) in both themes. */
  --gradient-teal:    linear-gradient(135deg, #0d9488 0%, #0ea5e9 100%);
  --gradient-indigo:  linear-gradient(135deg, #6366f1 0%, #4f46e5 100%);
  --gradient-emerald: linear-gradient(135deg, #10b981 0%, #059669 100%);
  --gradient-amber:   linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
}

/* 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;
  /* v4.66: View → Text size magnifies the page; divide so it still fits the window. */
  height: calc(100vh / var(--ui-z, 1));
  overflow: hidden;
}

/* Sidebar Styling */
.sidebar {
  background: linear-gradient(180deg, #1e293b 0%, #0f172a 100%);
  color: var(--text-inverse);
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: calc(100vh / var(--ui-z, 1));
  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, .sidebar-brand .brand-name .ui-icon {
  -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;
  height: calc(100vh / var(--ui-z, 1));
  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;
}

/* ---- Map-style header controls: view toggle + View/Tools dropdown menus.
   Mirrors the Map console header (style.css) but themed with the Dashboard's
   own CSS variables so it adapts to light and dark mode automatically. ---- */
.seg { display: inline-flex; background: rgba(0, 0, 0, 0.05); border: 1px solid var(--border); border-radius: 8px; padding: 3px; gap: 2px; }
.seg button { border: none; background: transparent; height: 30px; padding: 0 12px; border-radius: 6px; font-size: 0.82rem; font-weight: 600; color: var(--text-secondary); cursor: pointer; display: inline-flex; align-items: center; gap: 6px; }
.seg button.on { background: var(--brand-secondary); color: #fff; }
.seg button:not(.on):hover { background: rgba(0, 0, 0, 0.06); color: var(--text-primary); }

.hmenu { position: relative; }
.hmenu-panel { position: absolute; top: calc(100% + 6px); right: 0; min-width: 244px; z-index: 6500; background: var(--bg-card); border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow-lg, 0 12px 40px rgba(0, 0, 0, 0.25)); padding: 6px; display: none; }
.hmenu.open .hmenu-panel { display: block; }
.hmenu-item { display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; background: transparent; border: none; padding: 9px 10px; border-radius: 6px; font-size: 0.85rem; color: var(--text-primary); cursor: pointer; }
.hmenu-item:hover { background: rgba(14, 165, 233, 0.12); }
.hmenu-ic { width: 20px; text-align: center; color: var(--text-muted); flex: none; }
.hmenu-label { font-size: 0.62rem; text-transform: uppercase; letter-spacing: 0.09em; color: var(--text-muted); padding: 7px 10px 3px; font-weight: 800; }
.hmenu-sep { height: 1px; background: var(--border); margin: 5px 4px; }
.hmenu-row { display: flex; align-items: center; gap: 8px; padding: 6px 10px; font-size: 0.82rem; color: var(--text-primary); }

/* 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;
}

/* Solid fill + white text: readable for colour-blind users and in either theme
   (the old coloured-text-on-tint buttons were near-invisible on dark). The
   label, not the colour, says what each button does. */
.btn-edit {
  color: #fff;
  font-weight: 600;
  cursor: pointer;
  padding: 4px 10px;
  border-radius: 6px;
  background: #1d4ed8;
  margin-right: 6px;
  margin-bottom: 3px;
  display: inline-block;
  transition: all 0.2s ease;
  font-size: 0.8rem;
  border: none;
}

.btn-edit:hover {
  filter: brightness(1.15);
}

.btn-del {
  color: #fff;
  font-weight: 600;
  cursor: pointer;
  padding: 4px 10px;
  border-radius: 6px;
  background: #b91c1c;
  margin-bottom: 3px;
  display: inline-block;
  transition: all 0.2s ease;
  font-size: 0.8rem;
  border: none;
}

.btn-del:hover {
  filter: brightness(1.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;
  max-height: calc(90vh / var(--ui-z, 1));
  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, #login-box h1 .ui-icon {
  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;
}
/* v4.27 — above the 💬 button, not on top of it (a late warning now stays until tapped). */
#toast-container { bottom: 140px; max-width: min(420px, calc(100vw - 32px)); }

.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; }

/* SKELETON / SHIMMER LOADING PLACEHOLDERS
   Same helper as style.css, so a placeholder looks identical in either console.
   Decorative only; call sites mark the wrapper aria-hidden. */
.sk-card {
  pointer-events: none;
}

.sk-line {
  height: 12px;
  margin: 10px 0;
  border-radius: 6px;
  background: linear-gradient(90deg, rgba(255, 255, 255, 0.06) 25%, rgba(255, 255, 255, 0.16) 37%, rgba(255, 255, 255, 0.06) 63%);
  background-size: 400% 100%;
  animation: sk-shimmer 1.4s ease-in-out infinite;
}

@keyframes sk-shimmer {
  0% { background-position: 100% 50%; }
  100% { background-position: 0 50%; }
}

@media (prefers-reduced-motion: reduce) {
  .sk-line { animation: none; }
}

/* 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, .stat-chip .ui-icon { font-size: 0.75rem; }
.stat-chip:nth-child(1) i, .stat-chip:nth-child(1) .ui-icon { color: #10b981; }
.stat-chip:nth-child(2) i, .stat-chip:nth-child(2) .ui-icon { color: #0ea5e9; }
.stat-chip:nth-child(3) i, .stat-chip:nth-child(3) .ui-icon { 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, .history-job-detail .ui-icon {
  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, .history-empty .ui-icon {
  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, #controller-guide h4 .ui-icon {
  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, .guide-reminder > .ui-icon {
  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, .nav-item-mobile .ui-icon {
  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;
    /* v4.19: on a phone 100vh is the height with the browser's address bar
       HIDDEN, so while it shows, the bottom of every page sat behind the bottom
       bar and couldn't be scrolled to. dvh is the height actually on screen. */
    height: 100dvh;
    height: calc(100dvh / var(--ui-z, 1));
  }

  .sidebar {
    display: none; /* Hidden on mobile, replaced by bottom nav */
  }

  .main-content {
    grid-row: 1;
    height: calc(100vh - 64px);
    height: calc(100dvh - 64px);
    height: calc(100dvh / var(--ui-z, 1) - 64px);
  }

  /* v4.19: room at the end of each page so the last button scrolls clear of
     the chat button and the phone's own gesture bar. */
  .main-content .content-body {
    padding-bottom: calc(88px + env(safe-area-inset-bottom, 0px));
  }
  
  #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;
    max-height: calc(85vh / var(--ui-z, 1));
    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;
}

/* ============================================================
   v2.24 VISUAL IMPROVEMENTS
   (urgent pulse · job-age colours · status chips · focus polish
    · empty states) — Dashboard is light-first, dark overrides below
   ============================================================ */

/* --- Urgent jobs pulse slowly so they physically draw the eye --- */
@keyframes urgent-pulse {
  0%   { box-shadow: 0 0 0 0 rgba(220, 38, 38, 0.5); }
  70%  { box-shadow: 0 0 0 9px rgba(220, 38, 38, 0); }
  100% { box-shadow: 0 0 0 0 rgba(220, 38, 38, 0); }
}
.urgent-pulse { animation: urgent-pulse 1.8s ease-out infinite; }
@media (prefers-reduced-motion: reduce) {
  .urgent-pulse, .card.alert { animation: none; }
  .urgent-pulse { box-shadow: 0 0 0 2px rgba(220, 38, 38, 0.5); }
}

/* --- Job age: neutral < 30 min, amber 30–60, red > 60 --- */
.job-age-warn {
  background: rgba(245, 158, 11, 0.15) !important;
  color: #92400e !important;
  border: 1px solid rgba(245, 158, 11, 0.4) !important;
  border-radius: 12px; padding: 2px 8px;
}
.job-age-late {
  background: rgba(220, 38, 38, 0.12) !important;
  color: #991b1b !important;
  border: 1px solid rgba(220, 38, 38, 0.4) !important;
  border-radius: 12px; padding: 2px 8px; font-weight: 700;
}
.dark-theme .job-age-warn { color: #fbbf24 !important; background: rgba(245, 158, 11, 0.22) !important; }
.dark-theme .job-age-late { color: #fca5a5 !important; background: rgba(220, 38, 38, 0.22) !important; }

/* --- Rider acceptance line on a job (awaiting vs accepted) --- */
/* Solid colours + dark text so it's unmistakable and reads in both themes. */
.job-accept { margin-top: 6px; border-radius: 6px; padding: 5px 10px; font-size: 0.75rem; font-weight: 800; letter-spacing: 0.02em; }
.job-accept.accepted { background: #10b981; color: #04231a; }
.job-accept.awaiting { background: #f59e0b; color: #1f2933; }

/* --- Status chips: one consistent style, symbol + word (colour-blind safe) --- */
.status-chip {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 0.68rem; font-weight: 800; letter-spacing: 0.04em;
  padding: 2px 9px; border-radius: 10px; text-transform: uppercase;
  white-space: nowrap; vertical-align: middle; line-height: 1.5;
}
.status-chip.free    { background: rgba(16, 185, 129, 0.12);  color: #047857; border: 1px solid rgba(16, 185, 129, 0.3); }
.status-chip.busy    { background: rgba(245, 158, 11, 0.14);  color: #92400e; border: 1px solid rgba(245, 158, 11, 0.35); }
.status-chip.break   { background: rgba(100, 116, 139, 0.12); color: #475569; border: 1px solid rgba(100, 116, 139, 0.3); }
.status-chip.onboard { background: rgba(142, 68, 173, 0.12);  color: #6b21a8; border: 1px solid rgba(142, 68, 173, 0.3); }
.dark-theme .status-chip.free    { color: #34d399; }
.dark-theme .status-chip.busy    { color: #fbbf24; }
.dark-theme .status-chip.break   { color: #a8b3c2; }
.dark-theme .status-chip.onboard { color: #d8b4fe; }

/* --- Keyboard-focus visibility (accessibility) --- */
button:focus-visible, a:focus-visible, select:focus-visible,
input:focus-visible, textarea:focus-visible, [onclick]:focus-visible {
  outline: 2px solid #0d9488;
  outline-offset: 2px;
  border-radius: 4px;
}
.dark-theme button:focus-visible, .dark-theme a:focus-visible,
.dark-theme select:focus-visible, .dark-theme input:focus-visible,
.dark-theme textarea:focus-visible, .dark-theme [onclick]:focus-visible {
  outline-color: #5eead4;
}

/* --- Empty-state panels (friendlier than bare text) --- */
.empty-state {
  text-align: center; padding: 30px 16px; color: var(--text-muted);
}
.empty-state i, .empty-state .ui-icon { font-size: 1.8rem; display: block; margin-bottom: 8px; opacity: 0.45; }
.empty-state .es-title { font-weight: 600; font-size: 0.9rem; margin-bottom: 3px; color: var(--text-secondary); }
.empty-state .es-hint { font-size: 0.78rem; line-height: 1.5; }

/* ════════════════════════════════════════════════════════════════════
   REDESIGN 2026 — "Artery Control" visual language (v2.49 experiment)
   Appended as one block so the whole treatment can be reasoned about —
   and removed — in one place. Two deliberate shifts:
   1. RED MEANS ACT. The brand red is reserved for URGENT/SOS/alerts;
      routine actions move to a calm blue, good states to green.
   2. The nav rail is a dark instrument panel in BOTH themes, so the
      console reads as one product whether on day or night shift.
   ════════════════════════════════════════════════════════════════════ */

:root {
  --bg-app: #EDF1F7;
  --bg-card: #FFFFFF;
  --bg-card-hover: #F6F9FD;
  --text-primary: #101828;
  --text-secondary: #46556E;
  --text-muted: #8593AB;
  --border: #E2E8F2;
  --brand-primary: #2E5EAA;      /* calm action blue (was teal) */
  --brand-secondary: #3B82D8;
  --status-free: #17A45C;
  --status-busy: #D97706;        /* amber = waiting on a human */
  --status-break: #64748B;
  --status-alert: #E11D2E;       /* the artery red — urgent only */
  --rail-bg: #0D1522;            /* instrument rail, both themes */
  --rail-line: #20304B;
  --rail-text: #8DA1BF;
}
.dark-theme {
  --bg-app: #0B1120;
  --bg-card: #101929;
  --bg-card-hover: #14203466;
  --text-primary: #E9EEF7;
  --text-secondary: #A9B8D0;
  --text-muted: #8DA1BF;
  --border: #20304B;
  --brand-primary: #3B82D8;
  --brand-secondary: #4FA3F2;
  --status-free: #2BD576;
  --status-busy: #F5B93E;
  --status-break: #64748B;
  --status-alert: #E11D2E;
}

/* ---- nav rail: dark instrument panel in both themes ---- */
.sidebar { background: var(--rail-bg); border-right: 1px solid var(--rail-line); }
.sidebar .nav-item { color: var(--rail-text); border-radius: 10px; margin: 2px 10px; transition: background .15s, color .15s; }
.sidebar .nav-item:hover { background: #16223A66; color: #E9EEF7; }
.sidebar .nav-item.active { background: #16223A; color: #E9EEF7; box-shadow: inset 3px 0 0 var(--status-alert); }
.sidebar-brand, .sidebar-footer { color: #E9EEF7; border-color: var(--rail-line); }
.sidebar-brand .version-badge { background: #16223A; color: var(--rail-text); }

/* ---- cards: seams instead of shadows ---- */
.card { border: 1px solid var(--border); box-shadow: none; border-radius: 10px; }
.card:hover { box-shadow: 0 4px 16px rgba(10, 20, 40, .10); }
.dark-theme .card { background: var(--bg-card); border-color: var(--border); }
.dark-theme .card:hover { box-shadow: 0 6px 20px rgba(0, 0, 0, .35); }
.dashboard-section, .dark-theme .dashboard-section { border: 1px solid var(--border); box-shadow: none; border-radius: 12px; background: var(--bg-card); }
.dashboard-section-header, .dark-theme .dashboard-section-header { background: transparent; border-bottom: 1px solid var(--border); }

/* ---- stat tiles: quiet chips, colour only in the number ---- */
.stat-card, .stat-card.teal, .stat-card.indigo, .stat-card.emerald, .stat-card.amber {
  background: var(--bg-card); border: 1px solid var(--border); box-shadow: none; border-radius: 12px;
}
.stat-card::before, .stat-card::after { display: none; }   /* retire the corner blob */
.stat-card .stat-emoji { font-size: 1.05rem; opacity: .85; }
.stat-card .stat-value, .stat-card .stat-label { color: var(--text-muted); }
.stat-card .stat-value { font-variant-numeric: tabular-nums; font-weight: 800; }
.stat-card.teal .stat-value { color: var(--brand-secondary); }
.stat-card.indigo .stat-value { color: var(--text-primary); }
.stat-card.emerald .stat-value { color: var(--status-free); }
.stat-card.amber .stat-value { color: var(--status-busy); }

/* ---- attention lanes on the job board ---- */
.lane-h { display: flex; align-items: center; gap: 8px; margin: 14px 2px 8px;
  font-size: .72rem; font-weight: 800; letter-spacing: .14em; text-transform: uppercase; color: var(--text-muted); }
.lane-h:first-child { margin-top: 2px; }
.lane-dot { width: 8px; height: 8px; border-radius: 50%; }
.lane-cnt { margin-left: auto; font-weight: 600; color: var(--text-muted); opacity: .8; font-variant-numeric: tabular-nums; }
.done-mini { display: flex; align-items: center; gap: 10px; padding: 8px 12px; opacity: .82; font-size: .8rem; cursor: default; }
.done-mini .dm-ref { color: var(--text-muted); font-variant-numeric: tabular-nums; }
.done-mini .dm-route { flex: 1; color: var(--text-secondary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.done-mini .dm-tag { color: var(--status-free); font-weight: 700; font-size: .74rem; white-space: nowrap; }
/* Closed-not-delivered (stood down, NTC, etc.) must not read as a green delivery */
.done-mini .dm-tag-closed { color: var(--text-secondary); font-weight: 600; }
.done-more { text-align: center; font-size: .78rem; color: var(--brand-secondary); cursor: pointer; padding: 7px; }
.done-more:hover { text-decoration: underline; }

/* ---- acceptance pills: amber = waiting, green = go ---- */
.job-accept.awaiting { background: rgba(245, 185, 62, .16); color: #B45309; border: 1px solid rgba(245, 185, 62, .45); }
.dark-theme .job-accept.awaiting { color: #F5B93E; }
.job-accept.accepted { background: rgba(43, 213, 118, .14); color: #15803D; border: 1px solid rgba(43, 213, 118, .4); }
.dark-theme .job-accept.accepted { color: #2BD576; }

/* ---- board-first dashboard shape (Phase 1.5) ---- */
.ops-top { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; margin-bottom: 14px; }
.ops-top .ops-greet { min-width: 200px; }
.ops-top .dashboard-greeting { font-size: 1.25rem; margin-bottom: 0; }
.ops-top .dashboard-date { font-size: .78rem; margin-bottom: 0; }
.ops-top .stats-grid { display: flex; gap: 10px; margin: 0; flex: 1; }
.ops-top .stat-card { display: flex; align-items: baseline; gap: 8px; padding: 9px 14px; flex: 0 1 auto; }
.ops-top .stat-card .stat-emoji { display: none; }
.ops-top .stat-card .stat-value { font-size: 1.25rem; margin: 0; }
.ops-top .stat-card .stat-label { font-size: .62rem; letter-spacing: .1em; margin: 0; white-space: nowrap; }
.ops-top .quick-actions { display: flex; gap: 10px; margin: 0; }
.ops-top .quick-action-card { display: flex; align-items: center; gap: 10px; padding: 9px 16px; margin: 0; border-radius: 10px; }
.ops-top .quick-action-card .qa-icon { font-size: 1.1rem; }
.ops-top .quick-action-card .qa-text h4 { font-size: .82rem; margin: 0; }
.ops-top .quick-action-card .qa-text p { display: none; }
.ops-top .quick-action-card:first-child { background: var(--brand-primary); border-color: var(--brand-primary); }
.ops-top .quick-action-card:first-child h4 { color: #fff; }

.ops-grid { display: grid; grid-template-columns: 1fr 300px; gap: 16px; align-items: start; }
@media (max-width: 1150px) { .ops-grid { grid-template-columns: 1fr; } }
.ops-board .dashboard-section-body { max-height: none; }
/* Active Fleet needs the same uncapped-height treatment as the Job Board —
   the base .dashboard-section-body max-height:480px (line ~395) was only
   ever overridden for .ops-board, so with a full team on shift the fleet
   list exceeded 480px and had to scroll/clip inside its own box instead of
   just growing with the page, which is what produced the visual glitching
   reported with a large roster (fine with few riders, broken with many). */
.ops-fleetcol .dashboard-section-body { max-height: none; }

.lanes-wrap { display: grid; grid-template-columns: repeat(auto-fit, minmax(255px, 1fr)); gap: 14px; align-items: start; }
.lane-col { background: var(--bg-app); border: 1px solid var(--border); border-radius: 10px; padding: 10px; min-height: 120px; }
.dark-theme .lane-col { background: #0D1522; }
.lane-col .card { margin-bottom: 10px; }
.lane-col .card:last-child { margin-bottom: 0; }
.lane-empty { border: 1px dashed var(--border); border-radius: 8px; text-align: center; color: var(--text-muted); font-size: .78rem; padding: 18px 8px; }

/* fleet column: compact rows */
.ops-fleetcol #dashboard-fleet { display: flex; flex-direction: column; gap: 8px; }
.ops-fleetcol #dashboard-fleet .card { padding: 10px 12px; margin: 0; min-height: 0; }

/* ---- journey spine: Accepted → Collecting → Delivered ---- */
.spine { display: flex; align-items: center; margin-top: 10px; }
.spine .node { width: 10px; height: 10px; border-radius: 50%; border: 2px solid var(--border); background: var(--bg-card); flex: 0 0 auto; }
.spine .node.done { background: var(--status-free); border-color: var(--status-free); }
.spine .node.now { border-color: var(--brand-secondary); box-shadow: 0 0 0 3px rgba(79, 163, 242, .22); }
.spine .seg { flex: 1; height: 2px; background: var(--border); }
.spine .seg.done { background: var(--status-free); }
.spine-l { display: flex; justify-content: space-between; font-size: .6rem; color: var(--text-muted); margin-top: 3px; letter-spacing: .06em; text-transform: uppercase; }

/* ---- mobile bottom nav now carries ALL destinations (8 items) ----
   Trends / Events / Rota were unreachable on phones before; tighten the
   items so the full set fits a 360px screen. */
.nav-item-mobile { font-size: 0.56rem; gap: 1px; min-width: 0; padding: 0 1px; }
.nav-item-mobile span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-item-mobile i, .nav-item-mobile .ui-icon { font-size: 1.05rem; margin-bottom: 1px; }
.nav-item-mobile.active { color: var(--brand-secondary); }

/* ---- urgent: a steady red ring, not a strobing card ---- */
.urgent-pulse { animation: none; box-shadow: 0 0 0 1px rgba(225, 29, 46, .45), 0 6px 22px rgba(225, 29, 46, .10); }
@media (prefers-reduced-motion: no-preference) {
  .urgent-pulse { animation: urgent-breathe 2.6s ease-in-out infinite; }
  @keyframes urgent-breathe {
    0%, 100% { box-shadow: 0 0 0 1px rgba(225, 29, 46, .45), 0 6px 22px rgba(225, 29, 46, .10); }
    50%      { box-shadow: 0 0 0 2px rgba(225, 29, 46, .70), 0 6px 26px rgba(225, 29, 46, .22); }
  }
}

/* ---------------------------------------------------------------------------
   Header dropdowns on a phone.
   .hmenu-panel is anchored right:0 to its button and is 244px wide. In a header
   that has wrapped onto two rows the button sits near the LEFT edge, so the
   panel extends 244px further left — off the screen entirely. A controller
   working from a phone that cannot be rotated then has no way to reach Tools.
   On narrow screens the panel is anchored to the HEADER instead of the button
   and spans the full width, so it can never leave the viewport.
   --------------------------------------------------------------------------- */
@media (max-width: 768px) {
    /* .content-header is position:sticky, which already makes it a positioned
       ancestor — the panel just needs to stop anchoring to the button. */
    .hmenu { position: static; }
    .hmenu-panel {
        left: 10px;
        right: 10px;
        top: calc(100% + 6px);
        min-width: 0;
        width: auto;
        max-height: 70vh;
        max-height: calc(70vh / var(--ui-z, 1));
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }
}

/* ---------------------------------------------------------------------------
   v4.20 — the Dashboard on a phone, tidied.
   Header: two short rows instead of three — who's signed on + Sign Off on top,
   the view switch, sound, View and Tools below. The little ? buttons leave the
   header on a phone only (Tools → Help has all of it). Bottom bar: five items,
   the rest under More. Today's numbers as a 2×2 block that fits the screen.
   Nothing is removed; it is only arranged.
   --------------------------------------------------------------------------- */
@media (max-width: 768px) {
  .content-header { flex-wrap: wrap; align-items: center; justify-content: flex-start; column-gap: 6px; row-gap: 6px; padding: 8px 12px; }
  #menu-view > .btn-head { font-size: 0; }
  #menu-view > .btn-head::before { content: "\f1de"; font-family: "Font Awesome 6 Free"; font-weight: 900; font-size: 0.95rem; margin-right: 5px; }
  .content-header > .head-actions { display: contents !important; }   /* beats its inline display:flex */
  .content-header > .head-who { order: 0; gap: 6px; min-width: 0; }
  .content-header > .head-actions > * { order: 2; }
  .content-header #btn-auth { order: 1; margin-left: auto; }
  .content-header::after { content: ''; order: 1; flex-basis: 100%; height: 0; }
  .content-header .help-q { display: none; }
  .content-header .seg button { font-size: 0; gap: 0; padding: 0 12px; }
  .content-header .seg button i, .content-header .seg button .ui-icon { font-size: 0.9rem; }
  .content-header .btn-head { padding: 7px 10px; }

  #mobile-nav .nav-in-more { display: none; }
  .nav-item-mobile { font-size: 0.66rem; }
  .nav-item-mobile i, .nav-item-mobile .ui-icon { font-size: 1.15rem; }

  #more-sheet { position: fixed; inset: 0 0 64px 0; z-index: 3100; background: rgba(2, 6, 23, .45); display: flex; align-items: flex-end; }
  #more-sheet .more-panel { width: 100%; background: var(--bg-card, #fff); border-radius: 16px 16px 0 0; padding: 8px 8px 10px; box-shadow: 0 -10px 30px rgba(0, 0, 0, .25); }
  .more-item { display: flex; align-items: center; gap: 14px; width: 100%; min-height: 50px; padding: 0 14px; border: 0; border-radius: 10px; background: none; color: var(--text-primary); font-family: inherit; font-size: 1rem; font-weight: 600; text-align: left; cursor: pointer; }
  .more-item i, .more-item .ui-icon { width: 22px; text-align: center; color: var(--brand-secondary); font-size: 1.05rem; }
  .more-item:active, .more-item:hover { background: rgba(128, 128, 128, .12); }
  .more-foot { font-size: .75rem; color: var(--text-muted); padding: 8px 14px 2px; }

  .ops-top { gap: 10px; }
  .ops-top .ops-greet { min-width: 0; flex-basis: 100%; }
  .ops-top .dashboard-greeting { font-size: 1.1rem; }
  .ops-top .stats-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; flex-basis: 100%; }
  .ops-top .stat-card { min-width: 0; padding: 8px 12px; }
  .ops-top .stat-card .stat-label { white-space: normal; overflow-wrap: anywhere; }
  .ops-top .quick-actions { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; flex-basis: 100%; }   /* 4 since v4.26 */
  .ops-top .quick-action-card { padding: 9px 10px; min-width: 0; }
}
/* Never on a PC: More is a phone thing. */
@media (min-width: 769px) { #more-sheet { display: none !important; } }

/* v4.20 — the rota on a phone: one day per screen width, swipe for the next,
   opening on today (rotaRenderer.js). Kept identical to the copy in style.css. */
@media (max-width: 768px) {
  .rota-week { grid-template-columns: repeat(7, 88%) !important; scroll-snap-type: x mandatory; overscroll-behavior-x: contain; padding-bottom: 6px; }
  .rota-week > .rota-day { scroll-snap-align: start; }
}

/* ---------------------------------------------------------------------------
   v4.23 — Live Control (step 4 of the tidy-up, from the approved mock-up).
   --------------------------------------------------------------------------- */
/* The strip under the header: an open SOS and waiting hospital requests, on
   every page, for as long as they are open (app2.js renderLiveStrip). */
.content-header { flex-wrap: wrap; }
#live-strip { order: 99; flex-basis: 100%; display: flex; flex-direction: column; gap: 6px; }
#live-strip .ls-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; padding: 8px 12px; border-radius: 10px; font-size: .9rem; }
#live-strip .ls-sos { background: #B3121F; color: #fff; }
#live-strip .ls-req { background: #173A66; color: #E6EDF7; }
#live-strip .ls-tag { font-weight: 800; font-size: .72rem; letter-spacing: .08em; border-radius: 6px; padding: 3px 8px; background: #fff; }
#live-strip .ls-sos .ls-tag { color: #B3121F; }
#live-strip .ls-req .ls-tag { color: #173A66; }
#live-strip .ls-text { flex: 1 1 220px; min-width: 0; }
#live-strip .ls-btn { display: inline-flex; align-items: center; min-height: 36px; padding: 0 12px; border: 1px solid rgba(255,255,255,.7); border-radius: 8px; background: transparent; color: #fff; font-weight: 700; font-size: .85rem; text-decoration: none; cursor: pointer; }
#live-strip .ls-btn:hover { background: rgba(255,255,255,.14); }
/* v4.29 — the running-late line (replaces the sticky toast): slim, one line for
   everyone who is late, each name opens the job. Kept in step with style.css. */
#live-strip .ls-late { background: #9A3412; color: #fff; padding: 4px 10px; }
#live-strip .ls-late .ls-tag { color: #9A3412; }
#live-strip .ls-items { display: flex; flex-wrap: wrap; gap: 4px 8px; }
#live-strip .ls-item { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 0 6px; min-height: 32px; padding: 2px 10px; border: 1px solid rgba(255,255,255,.55); border-radius: 8px; background: transparent; color: #fff; font: inherit; font-size: .85rem; text-align: left; cursor: pointer; }
#live-strip .ls-item:hover { background: rgba(255,255,255,.14); }
#live-strip .ls-chk { background: #fff; color: #B3121F; font-weight: 800; font-size: .68rem; border-radius: 5px; padding: 1px 6px; }
#live-strip .ls-ack { font-weight: 600; }

/* Lanes stack: Needs you first and loudest, Moving as a grid, Done today folded. */
.lanes-wrap { display: flex; flex-direction: column; align-items: stretch; gap: 14px; }   /* the older grid rule set align-items:start */
.lane-col.lane-needs.has-items { border: 2px solid rgba(245, 185, 62, .7); background: rgba(245, 185, 62, .07); }
.lane-col.lane-needs .lane-h { font-size: .9rem; }
.lane-col.lane-needs.has-items .lane-h { color: #92400E; }
.dark-theme .lane-col.lane-needs.has-items .lane-h { color: #F5D38A; }
.lane-col.lane-moving { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 10px; align-items: start; }
.lane-col.lane-moving > .lane-h, .lane-col.lane-moving > .lane-empty { grid-column: 1 / -1; margin-bottom: 0; }
.lane-col.lane-moving > .card { margin-bottom: 0; }
/* v4.33 — "Needs you" uses the width too: compact cards in columns (like Moving),
   still in the same order, left to right then down. */
.lane-col.lane-needs { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(340px, 100%), 1fr)); gap: 10px; align-items: start; }
.lane-col.lane-needs > .lane-h, .lane-col.lane-needs > .lane-empty { grid-column: 1 / -1; margin-bottom: 0; }
.lane-col.lane-needs > .card { margin-bottom: 0 !important; }
.lane-col.lane-done { min-height: 0; }
.lane-col.lane-done > summary { cursor: pointer; list-style: none; margin: 2px; min-height: 32px; }
.lane-col.lane-done > summary::-webkit-details-marker { display: none; }
.lane-col.lane-done .lane-cnt { margin-left: 8px; }
.lane-col.lane-done .lane-fold { margin-left: auto; font-size: .78rem; font-weight: 700; color: var(--brand-secondary); }
.lane-col.lane-done[open] > summary { margin-bottom: 8px; }

/* Today's numbers as compact chips (the base .stat-card's min-height and
   column direction were still making them tall cards). */
.ops-top .stat-card { flex-direction: row; min-height: 0; justify-content: flex-start; align-items: baseline; }

/* v4.24 — right-hand column: job details (PC) in place of the fleet, then Recent. */
.ops-side { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.ops-grid.panel-open { grid-template-columns: 1fr 420px; }
.ops-grid.panel-open .ops-fleetcol { display: none; }
.ops-jobpanel { padding: 16px; display: flex; flex-direction: column; gap: 10px; border: 2px solid var(--brand-secondary); outline: none; }
.ops-jobpanel[hidden] { display: none; }
.ops-jobpanel .jp-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.ops-jobpanel .jp-ref { margin: 0; font-size: 1.15rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.ops-jobpanel .jp-urgent { background: #dc2626; color: #fff; font-size: .7rem; font-weight: 800; border-radius: 5px; padding: 2px 8px; }
.ops-jobpanel .jp-x { min-width: 36px; min-height: 36px; border: 1px solid var(--border); border-radius: 8px; background: transparent; color: var(--text-primary); cursor: pointer; }
.ops-jobpanel .jp-phase { font-weight: 700; color: var(--text-secondary); font-size: .9rem; }
.ops-jobpanel .jp-grid { display: grid; grid-template-columns: 84px minmax(0, 1fr); gap: 6px 10px; font-size: .88rem; }
.ops-jobpanel .jp-k { color: var(--text-muted); }
.ops-jobpanel .jp-v { overflow-wrap: anywhere; }
.ops-jobpanel .jp-v a { color: var(--brand-secondary); font-weight: 700; }
.ops-jobpanel .jp-tl { border-top: 1px solid var(--border); padding-top: 8px; }
.ops-jobpanel .jp-tl-h { font-size: .68rem; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; color: var(--text-muted); margin-bottom: 4px; }
.ops-jobpanel .jp-tl-row { font-size: .8rem; color: var(--text-secondary); padding: 2px 0; font-variant-numeric: tabular-nums; }
.ops-jobpanel .jp-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.ops-jobpanel .jp-btn { min-height: 40px; padding: 0 14px; border: 1px solid var(--border); border-radius: 8px; background: transparent; color: var(--text-primary); font-weight: 700; font-size: .85rem; cursor: pointer; }
.ops-jobpanel .jp-btn.jp-primary { background: var(--brand-secondary); border-color: var(--brand-secondary); color: #fff; }
.ops-jobpanel .jp-btn:disabled { opacity: .6; cursor: wait; }
.ops-jobpanel .jp-note { margin: 0; font-size: .75rem; color: var(--text-muted); }
.lane-col .card.is-selected { outline: 3px solid var(--brand-secondary); outline-offset: 1px; }
.ops-recent .dashboard-section-body { display: flex; flex-direction: column; gap: 4px; padding-top: 8px; }
.ops-recent .rc-row { display: flex; gap: 10px; font-size: .8rem; color: var(--text-secondary); line-height: 1.35; }
.ops-recent .rc-t { color: var(--text-muted); font-variant-numeric: tabular-nums; flex: none; }

/* Header title on the home view. */
.ops-top .ops-title { margin: 0; font-size: 1.35rem; font-weight: 800; line-height: 1.2; }
.ops-top .ops-title + .dashboard-greeting { font-size: .85rem; font-weight: 600; color: var(--text-secondary); }

/* Sidebar grouped like the Tools menu. */
.sidebar .nav-group { margin: 14px 22px 4px; font-size: .64rem; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; color: rgba(233, 238, 247, .5); }
.sidebar .nav-group:first-child { margin-top: 4px; }
.sidebar .nav-group-note { text-transform: none; letter-spacing: 0; font-weight: 500; font-size: .72rem; margin-top: 18px; }

/* --- Site-kind artwork (v3.30) ---------------------------------------------
   Hospitals and GP surgeries draw as pictures rather than emoji, because 🏥
   and 🩺 read as the same blob at small sizes. This console has no map, but it
   shows the same Locations directory, so it needs the same rule — kept
   identical to the copy in style.css. Sized in `em` so it follows whatever
   text it sits beside. */
img.loc-ic { width: 1.15em; height: 1.15em; object-fit: contain; vertical-align: -0.2em; }

/* v4.29 — the "⚠ already offered / position … old" note under a suggestion
   (jobinfo.js suggestCaveat). This page is light unless .dark-theme. */
.jx-caveat { color: #92400e; }
.dark-theme .jx-caveat { color: #fbbf24; }

/* ===== v4.37 - fixes from the phone/tablet audit (batch 2) ===== */
/* C4 - "Close job..." and Cancel/Abort on their own row, well apart, under a
   dashed line, so the everyday buttons never sit next to them. */
.jx-endrow { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 14px; padding-top: 10px; border-top: 1px dashed var(--border, rgba(148,163,184,.35)); }
/* C2 - the "Back to Live Control" button on pages off the board. */
.view-back { width: auto !important; margin: 0 0 12px !important; display: inline-flex; align-items: center; gap: 8px; }
/* C10 - light theme: muted text was #8593AB (about 3:1 on white). */
:root:not(.dark-theme), html:not(.dark-theme) body { --text-muted: #5B6880; }
html:not(.dark-theme) .ops-top .dashboard-date { color: var(--text-secondary); }
.ops-top .stat-card .stat-label { font-size: .7rem; }
html:not(.dark-theme) .lane-h, html:not(.dark-theme) .lane-cnt { color: #46556E; opacity: 1; }
html:not(.dark-theme) #view-dashboard [style*="color:#0ea5e9"] { color: #0369a1 !important; }
@media (max-width: 768px) {
  /* C1 - a handover note sits above the bottom bar, under any window. */
  #handover-stack { bottom: calc(64px + 10px + env(safe-area-inset-bottom, 0px)) !important; max-height: calc(38vh / var(--ui-z, 1)) !important; z-index: 2900 !important; }
  /* C5 - header buttons big enough for a thumb; inputs at 16px so a phone
     doesn't zoom in on them now that pinch-zoom is allowed. */
  .head-actions .btn-head, .head-actions .seg button, .head-actions .hmenu > button { min-height: 44px; }
  input, select, textarea { font-size: 16px; }
  /* C9 - room under the last card for the round message button. */
  #view-dashboard { padding-bottom: 84px; }
}
/* ===== v4.37 - the rota on a phone: thumb-sized (phone audit P7/C11) =====
   Kept identical to the copy in style.css. */
@media (max-width: 768px) {
    .rota-week .rota-x { min-width: 44px; min-height: 44px; font-size: 1.3rem !important; }
    .rota-week .rota-add { display: inline-flex; align-items: center; min-height: 36px; padding: 0 10px !important; font-size: .8rem !important; }
    .rota-week .rota-block { padding: 8px 10px !important; min-height: 44px; }
    .rota-week .rota-entry { font-size: .85rem !important; min-height: 44px; }
    .rota-week .rota-lbl { font-size: .75rem !important; }
}

/* ---- v4.58: usability review batch 2 (Dashboard) ---- */
/* F3: the live activity feed had a 48%-wide slot in the header at 1280px and its
   lines were cut off. Up to 1500px it gets its own full-width line under the
   header (after the LATE line), two lines tall. Phones still hide it (desktop first). */
@media (min-width: 769px) and (max-width: 1500px) {
  .content-header > #job-ticker { display: block !important; order: 50; flex: 1 1 100%; max-width: none; margin: 8px 0 0; height: 52px; }   /* beats the page's own #job-ticker rule */
}
/* F9: between 769 and 1000px the stats ran off the right edge and End Shift
   broke onto two lines. Stats and header buttons now wrap; buttons stay whole. */
@media (min-width: 769px) and (max-width: 1000px) {
  .content-header { padding: 12px 16px; row-gap: 8px; }
  .content-header > .head-actions { flex-wrap: wrap; justify-content: flex-end; }
  .content-header .btn-head, .content-header #btn-auth { white-space: nowrap; }
  .ops-top .stats-grid { flex-wrap: wrap; }
  .ops-top .stat-card { flex: 1 1 140px; }
  .ops-top .stat-card .stat-label { white-space: normal; }
}

/* v4.58 (usability review F11): on a phone the first job sat two-thirds down the
   screen. The greeting and date go, the four numbers share one row, and New Job /
   Phone Job (both already in the bottom bar) leave the quick actions. Nothing is
   removed from the page on a PC. */
@media (max-width: 768px) {
  .ops-top .dashboard-greeting, .ops-top .dashboard-date { display: none; }
  .ops-top .ops-title { margin: 0; font-size: 1.15rem; }
  .ops-top .stats-grid { grid-template-columns: repeat(4, 1fr) !important; gap: 6px !important; }
  .ops-top .stat-card { flex-direction: column !important; align-items: flex-start !important; gap: 0 !important; padding: 6px 8px !important; }
  .ops-top .stat-card .stat-value { font-size: 1.05rem !important; }
  .ops-top .stat-card .stat-label { font-size: .58rem !important; letter-spacing: .04em !important; line-height: 1.2; }
  .ops-top .stat-card .help-q { display: none; }
  .ops-top .quick-action-card[onclick^="switchView('log-job')"], .ops-top .quick-action-card.qa-phonejob { display: none !important; }
}

/* v4.61: the area picker above Active Fleet sits inside the card */
#area-filter:not(:empty) { padding: 0 16px; }

/* v4.87 — redesign stage 9: contrast. Every piece of text at least 4.5:1 against what is
   behind it (measured by docs/tutorials/screenshots/audit-v487.mjs, light and dark). */
/* Done today: the rows were faded (.82) on top of muted colours, and in the dark theme they
   sat on a white card. */
.done-mini { opacity: 1; }
.dark-theme .card.done-mini { background: var(--bg-card) !important; color: var(--text-primary); }
html:not(.dark-theme) .done-mini .dm-tag { color: #15803d; }
/* "Show" on Done today: blue on the lane's grey was 3.5:1. */
html:not(.dark-theme) .lane-col.lane-done .lane-fold { color: #1d5fb4; }
/* The "5 jobs" / "5 riders" counts in the dark theme: 4.0-4.4:1. */
.dark-theme #jobs-count-badge, .dark-theme #fleet-count-badge { color: #8cc4ff; }
/* The rail's selected item in the dark theme: dark red on near black was 2.4:1 (the frame's
   own dark rule looked for .dark-theme on body; the class is on <html>). */
html.dark-theme body.cf-on.cf-dash .sidebar .nav-item.active { color: #ff8a98; background: rgba(255, 138, 152, .12); }
/* The green "Suggested: …" line and its Assign button (written inline, the same in both
   consoles): white on #10b981 was 2.5:1, and the green words on white 2.5:1. */
button[style*="background:#10b981"] { background: #047857 !important; }
html:not(.dark-theme) [style*="color:#10b981"] { color: #047857 !important; }
/* Confirm Pickup (blue) and Confirm Delivery (green): white words on the light end of their
   gradients were 3.7 and 2.5:1. A step darker: 5.2:1 and 5.5:1 at the light end. */
.btn-sec { background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%); }
.btn-main { background: linear-gradient(135deg, #047857 0%, #065f46 100%); }
/* Bright red words (URGENT and others written inline) on white: 3.8:1. */
html:not(.dark-theme) [style*="color:#ef4444"], html:not(.dark-theme) [style*="color: #ef4444"] { color: #dc2626 !important; }
