/* =============================================================================
 * vAutoHire — App stylesheet
 * Re-skinned to the LANDING palette: navy structure + teal CTA/accent,
 * terracotta warm accent, light content area. System font stack.
 * (Token + component re-skin only — layout/structure/class names unchanged.)
 * =========================================================================== */
:root {
  /* --- Landing brand palette --------------------------------------------- */
  --navy: #10324e;            /* structure / sidebar / headings */
  --navy-dark: #0a2438;
  --teal-brand: #1f9e8f;      /* PRIMARY action / CTA + accent */
  --teal-brand-dark: #178074;
  --teal-soft: #e3f3f0;
  --terracotta: #d98a6a;      /* sparing warm accent */

  /* canonical brand var (legacy name retained — value is now teal) */
  --primary-green: #1f9e8f;
  --primary-green-dark: #178074;
  --green-bg: rgba(31, 158, 143, 0.12);

  /* Gray scale (neutral surfaces, tuned to landing line/ink) */
  --gray-100: #f8fafb;
  --gray-200: #eef2f5;
  --gray-300: #dde4ea;
  --gray-400: #c2ccd4;
  --gray-500: #9aa6ae;
  --gray-600: #7c8a93;
  --gray-700: #41525f;
  --gray-800: #1f3346;
  --gray-900: #10324e;

  /* Dark surfaces (login backdrop) — navy family */
  --dark-bg: #0a2438;
  --dark-surface: #10324e;
  --dark-elevated: #1f3346;
  --dark-text-secondary: #7c8a93;

  /* --- Legacy brand aliases (kept so existing JS/CSS hooks recolor safely) -
   * --teal is a legacy alias that now holds the brand teal; many page modules
   * and ui.js reference --teal/--accent/--primary for the brand accent. */
  --teal: var(--teal-brand);
  --teal-dark: var(--teal-brand-dark);
  --teal-bg: var(--teal-soft);

  --primary: var(--teal-brand);
  --primary-hover: var(--teal-brand-dark);
  --accent: var(--teal-brand);

  /* Surfaces / text (light content area) */
  --bg: #f8fafb;
  --surface: #ffffff;
  --elevated: #f4f7f8;
  --text: #10324e;
  --text-secondary: #41525f;
  --text-muted: #7c8a93;

  /* Aliases consumed as fallback vars in injected page styles
   * (checkin.js / reports.js) — defined so off-palette fallbacks never apply. */
  --bg-card: var(--surface);
  --card-bg: var(--surface);
  --bg-hover: var(--elevated);
  --bg-sidebar: var(--sidebar-bg);
  --border-color: var(--border);

  /* Semantic colors (landing-aligned) */
  --success: #1f9e8f;
  --success-bg: rgba(31, 158, 143, 0.12);
  --warning: #b9770c;
  --warning-bg: rgba(185, 119, 12, 0.12);
  --danger: #c0392b;
  --danger-bg: rgba(192, 57, 43, 0.10);
  --info: #2b7cb8;
  --info-bg: rgba(43, 124, 184, 0.10);

  --border: #dde4ea;
  --radius: 8px;
  --radius-lg: 12px;
  --shadow: 0 1px 3px rgba(16, 50, 78, 0.08);
  --shadow-lg: 0 8px 28px rgba(16, 50, 78, 0.16);

  --sidebar-w: 248px;
  --topbar-h: 60px;

  /* Navy sidebar with teal active accent + white active text */
  --sidebar-bg: #10324e;
  --sidebar-text: #b9c6d1;
  --sidebar-text-active: #ffffff;
  --sidebar-hover: rgba(255, 255, 255, 0.08);
  --sidebar-active: var(--teal-brand);
  --sidebar-border: rgba(255, 255, 255, 0.10);

  --tap: 44px; /* minimum tablet tap target */
}

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

html, body { height: 100%; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--teal); text-decoration: none; }
a:hover { text-decoration: underline; }

::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--gray-400); border-radius: 5px; }
::-webkit-scrollbar-thumb:hover { background: var(--gray-500); }

.hidden { display: none !important; }

/* =============================================================================
 * LOGIN
 * =========================================================================== */
#login-view {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 20px;
  background: linear-gradient(135deg, var(--dark-bg) 0%, var(--dark-surface) 55%, var(--gray-800) 100%);
}

.login-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 40px 36px;
  width: 400px;
  max-width: 100%;
  box-shadow: var(--shadow-lg);
}

.login-brand {
  display: flex;
  align-items: baseline;
  gap: 2px;
  font-size: 30px;
  font-weight: 800;
  letter-spacing: -0.5px;
}
.login-logo { color: var(--gray-900); }
.login-logo-accent { color: var(--primary-green); }
.login-tagline { color: var(--text-secondary); margin: 4px 0 24px; font-size: 14px; }

.login-step { display: flex; flex-direction: column; }
.login-hint { color: var(--text-secondary); font-size: 13px; margin-bottom: 14px; }

.login-error {
  background: var(--danger-bg);
  color: var(--danger);
  border: 1px solid rgba(255, 59, 48, 0.25);
  border-radius: var(--radius);
  padding: 10px 12px;
  font-size: 13px;
  margin-bottom: 16px;
}

/* =============================================================================
 * FORMS
 * =========================================================================== */
.form-group { margin-bottom: 16px; }

.form-group label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.4px;
  margin-bottom: 6px;
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  min-height: var(--tap);
  padding: 11px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 15px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px var(--teal-bg);
}

.form-group textarea { resize: vertical; min-height: 88px; }
.form-group select { cursor: pointer; appearance: auto; }

/* Standalone .form-control inputs (used outside .form-group, e.g. compact rows) */
input.form-control, select.form-control, textarea.form-control {
  width: 100%;
  min-height: var(--tap);
  padding: 8px 12px;
  font-size: 15px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-sizing: border-box;
}
input.form-control:focus, select.form-control:focus, textarea.form-control:focus {
  outline: none;
  border-color: var(--primary-green);
  box-shadow: 0 0 0 3px var(--teal-soft);
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  text-transform: none;
  letter-spacing: 0;
  cursor: pointer;
  min-height: var(--tap);
}
.checkbox-label input[type="checkbox"] {
  width: 20px; height: 20px; min-height: 0; flex: 0 0 auto; cursor: pointer;
}

.field-help { font-size: 12px; color: var(--text-muted); margin-top: 5px; }

.form-row { display: flex; gap: 14px; flex-wrap: wrap; }
.form-row .form-group { flex: 1 1 200px; }

/* =============================================================================
 * BUTTONS
 * =========================================================================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: var(--tap);
  padding: 10px 20px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, opacity 0.15s;
  text-decoration: none;
  white-space: nowrap;
}
.btn:hover { text-decoration: none; }

.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }

/* Secondary = neutral gray-700 per design system (primary stays green) */
.btn-secondary { background: var(--gray-700); color: #fff; }
.btn-secondary:hover { background: var(--gray-800); }

.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { opacity: 0.9; }

.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { opacity: 0.9; }

.btn-outline { background: transparent; border-color: var(--border); color: var(--text); }
.btn-outline:hover { border-color: var(--teal); color: var(--teal); }

.btn-sm { min-height: 34px; padding: 6px 12px; font-size: 13px; }
.btn-block { width: 100%; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* =============================================================================
 * APP SHELL LAYOUT
 * =========================================================================== */
#app-shell { display: flex; min-height: 100vh; }

/* Sidebar */
#sidebar {
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 200;
  transition: transform 0.25s ease;
}

.sidebar-header {
  padding: 18px 20px;
  border-bottom: 1px solid var(--sidebar-border);
  display: flex;
  align-items: baseline;
  gap: 1px;
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.3px;
}
.sidebar-header .logo-main { color: #fff; }
.sidebar-header .logo-accent { color: var(--teal); }

#sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 12px 0;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: var(--tap);
  padding: 10px 20px;
  color: var(--sidebar-text);
  cursor: pointer;
  font-size: 14.5px;
  font-weight: 500;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  border-left: 3px solid transparent;
  transition: background 0.15s, color 0.15s;
}
.nav-item:hover { color: var(--sidebar-text-active); background: var(--sidebar-hover); text-decoration: none; }
.nav-item.active {
  color: #fff;
  background: var(--sidebar-hover);
  border-left-color: var(--sidebar-active);
}
.nav-item .nav-icon { font-size: 18px; width: 22px; height: 20px; display: inline-flex; align-items: center; justify-content: center; text-align: center; flex: 0 0 auto; }
.nav-item .nav-icon .vh-icon { display: block; }

/* Inline SVG icon — inherits text colour, sits with the baseline of text */
.vh-icon { display: inline-block; vertical-align: -0.18em; flex: 0 0 auto; }

.sidebar-footer {
  padding: 14px 20px;
  border-top: 1px solid var(--sidebar-border);
  font-size: 12px;
  color: var(--text-muted);
}

/* Main column */
#app-body {
  flex: 1;
  margin-left: var(--sidebar-w);
  display: flex;
  flex-direction: column;
  min-width: 0;
}

/* Topbar */
#topbar {
  height: var(--topbar-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 20px;
  position: sticky;
  top: 0;
  z-index: 100;
}

#hamburger-btn {
  display: none;
  width: var(--tap); height: var(--tap);
  border: none; background: none;
  font-size: 22px; cursor: pointer; color: var(--gray-900);
  border-radius: var(--radius);
}
#hamburger-btn:hover { background: var(--elevated); }

#topbar-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#topbar-context { text-align: right; line-height: 1.25; display: flex; flex-direction: column; align-items: flex-end; gap: 2px; }
.context-label { font-size: 13px; font-weight: 600; color: var(--text); }
.context-sub { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; }

/* Super-admin View-As control (rendered in topbar context) */
.viewas-control { display: flex; align-items: center; gap: 6px; margin-top: 4px; flex-wrap: wrap; justify-content: flex-end; }
.viewas-input {
  width: 92px; min-height: 34px;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
}
.viewas-input:focus { outline: none; border-color: var(--teal); box-shadow: 0 0 0 3px var(--teal-soft); }

/* User menu */
#topbar-user { position: relative; }
.user-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: var(--tap);
  padding: 5px 8px;
  background: none;
  border: 1px solid transparent;
  border-radius: var(--radius);
  cursor: pointer;
  font-family: inherit;
}
.user-btn:hover { background: var(--elevated); border-color: var(--border); }
.user-avatar {
  width: 34px; height: 34px;
  border-radius: 50%;
  background: var(--teal);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 15px; flex: 0 0 auto;
}
.user-btn-label { display: flex; flex-direction: column; text-align: left; }
.user-btn-name { font-size: 13px; font-weight: 600; color: var(--text); }
.user-btn-role { font-size: 11px; color: var(--text-muted); text-transform: capitalize; }
.user-btn-caret { color: var(--text-muted); font-size: 11px; }

.user-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  width: 230px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  z-index: 300;
}
.user-menu-header { padding: 14px 16px; border-bottom: 1px solid var(--border); }
.user-menu-name { font-weight: 600; font-size: 14px; }
.user-menu-email { font-size: 12px; }
.user-menu-item {
  display: block;
  width: 100%;
  text-align: left;
  min-height: var(--tap);
  padding: 11px 16px;
  background: none;
  border: none;
  font-size: 14px;
  font-family: inherit;
  color: var(--text);
  cursor: pointer;
}
.user-menu-item:hover { background: var(--elevated); }

/* Main scroll area */
#app-main {
  flex: 1;
  padding: 24px;
  overflow-y: auto;
}
.page-content { max-width: 1280px; }

/* Mobile sidebar overlay */
#sidebar-overlay {
  visibility: hidden;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 150;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}
#sidebar-overlay.active { visibility: visible; opacity: 1; pointer-events: auto; }

/* =============================================================================
 * PAGE HEADER
 * =========================================================================== */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 22px;
  flex-wrap: wrap;
}
.page-header h1 { font-size: 24px; font-weight: 700; }
.page-header h2 { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.page-header .actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* Page toolbar (list search row) + pager + header actions */
.page-toolbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; flex-wrap: wrap; margin-bottom: 18px;
}
.toolbar-search { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; flex: 1 1 280px; min-width: 0; }
.toolbar-search input { flex: 1 1 200px; min-width: 0; }
.pager-row { display: flex; align-items: center; justify-content: center; gap: 10px; flex-wrap: wrap; margin-top: 16px; }
.page-header-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* DL photo grid (modal) — wraps + scales thumbs on narrow screens */
.photo-grid { display: flex; flex-wrap: wrap; gap: 10px; }
.photo-thumb-link { display: inline-flex; }
.photo-thumb { max-width: 160px; max-height: 120px; }
@media (max-width: 480px) {
  .photo-grid { gap: 8px; }
  .photo-thumb { max-width: 46vw; }
}

.back-btn {
  display: inline-flex; align-items: center; gap: 6px;
  color: var(--text-secondary); font-size: 13px;
  background: none; border: none; cursor: pointer;
  margin-bottom: 14px; min-height: 34px; font-family: inherit;
}
.back-btn:hover { color: var(--gray-900); }

/* =============================================================================
 * CARDS / KPI
 * =========================================================================== */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow);
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.kpi-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow);
  border-left: 4px solid var(--teal);
}
.kpi-card .kpi-value { font-size: 30px; font-weight: 700; line-height: 1.1; color: var(--gray-900); }
.kpi-card .kpi-label { font-size: 12px; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.5px; margin-top: 6px; }
.kpi-card.kpi-warning { border-left-color: var(--warning); }
.kpi-card.kpi-danger { border-left-color: var(--danger); }
.kpi-card.kpi-info { border-left-color: var(--info); }

/* Quick-link cards (dashboard) */
.quicklink-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 16px;
}
.quicklink-card {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: border-color 0.15s, transform 0.1s, box-shadow 0.15s;
}
.quicklink-card:hover { border-color: var(--teal); box-shadow: var(--shadow-lg); transform: translateY(-1px); }
.quicklink-card.disabled { cursor: default; opacity: 0.6; }
.quicklink-card.disabled:hover { border-color: var(--border); box-shadow: var(--shadow); transform: none; }
.quicklink-icon {
  width: 46px; height: 46px;
  border-radius: var(--radius);
  background: var(--teal-bg);
  color: var(--teal-dark);
  display: flex; align-items: center; justify-content: center;
  font-size: 22px; flex: 0 0 auto;
}
.quicklink-icon .vh-icon { width: 24px; height: 24px; }
.quicklink-title { font-weight: 700; font-size: 15px; color: var(--gray-900); }
.quicklink-desc { font-size: 13px; }

/* =============================================================================
 * TABLES
 * =========================================================================== */
.table-container {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow);
}
/* Tables can be wider than the viewport on narrow screens — scroll the table
 * body horizontally inside its rounded container rather than break layout. */
.table-container > table { min-width: 100%; }
.table-container { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.table-toolbar .filters { display: flex; gap: 8px; flex-wrap: wrap; }
.table-scroll { overflow-x: auto; }

.search-input, .filter-select {
  min-height: var(--tap);
  padding: 9px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 14px;
}
.search-input { min-width: 220px; }
.search-input:focus, .filter-select:focus { border-color: var(--teal); outline: none; box-shadow: 0 0 0 3px var(--teal-bg); }
.filter-select { cursor: pointer; }

table { width: 100%; border-collapse: collapse; }
table th {
  text-align: left;
  padding: 12px 16px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-secondary);
  border-bottom: 2px solid var(--border);
  background: var(--elevated);
  white-space: nowrap;
}
table td { padding: 13px 16px; border-bottom: 1px solid var(--border); font-size: 14px; vertical-align: middle; }
table tbody tr { transition: background 0.12s; }
table tbody tr:hover { background: var(--elevated); }
table tbody tr:last-child td { border-bottom: none; }
table tbody tr.clickable { cursor: pointer; }

.table-empty { text-align: center; padding: 48px 16px; color: var(--text-secondary); }

/* =============================================================================
 * BADGES & STATUS PILLS
 * =========================================================================== */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  white-space: nowrap;
  background: var(--elevated);
  color: var(--text-secondary);
}
.badge-success { background: var(--success-bg); color: var(--teal-dark); }
.badge-warning { background: var(--warning-bg); color: var(--warning); }
.badge-danger  { background: var(--danger-bg); color: var(--danger); }
.badge-info    { background: var(--info-bg); color: var(--info); }
.badge-primary { background: var(--teal-bg); color: var(--teal-dark); }
.badge-vip     { background: #fff3cd; color: #7c5a00; }

/* Settings tab bar: wraps to multiple rows on narrow screens. row-gap:0 +
   padding-bottom keeps each row's active-tab underline aligned to the border. */
.vh-settings-tabs { row-gap: 0; padding-bottom: 2px; }

/* Status pills — auto-classed by VH.ui.statusPill(); generic fallback + known */
.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 11px;
  border-radius: 14px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  background: var(--elevated);
  color: var(--text-secondary);
  border: 1px solid transparent;
}
.status-pill::before {
  content: '';
  width: 7px; height: 7px; border-radius: 50%;
  background: currentColor; opacity: 0.85;
}
/* Common hire lifecycle states */
.status-pill--available,
.status-pill--active,
.status-pill--on_hire,
.status-pill--checked_out,
.status-pill--approved,
.status-pill--passed,
.status-pill--paid,
.status-pill--complete,
.status-pill--completed { background: var(--success-bg); color: var(--teal-dark); }

.status-pill--pending,
.status-pill--booked,
.status-pill--reserved,
.status-pill--awaiting,
.status-pill--due,
.status-pill--review_required,
.status-pill--in_progress { background: var(--warning-bg); color: var(--warning); }

.status-pill--overdue,
.status-pill--cancelled,
.status-pill--failed,
.status-pill--expired,
.status-pill--rejected,
.status-pill--damaged,
.status-pill--off_road { background: var(--danger-bg); color: var(--danger); }

.status-pill--draft,
.status-pill--returned,
.status-pill--closed,
.status-pill--archived,
.status-pill--unknown { background: var(--elevated); color: var(--text-secondary); }

.status-pill--scheduled,
.status-pill--info,
.status-pill--quoted { background: var(--info-bg); color: var(--info); }

/* =============================================================================
 * MODAL
 * =========================================================================== */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0, 0, 0, 0.45);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000;
  opacity: 0; visibility: hidden;
  transition: opacity 0.2s, visibility 0.2s;
  padding: 20px;
}
.modal-overlay.active { opacity: 1; visibility: visible; }
.modal {
  background: var(--surface);
  border-radius: var(--radius-lg);
  width: 520px;
  max-width: 100%;
  max-height: 88vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  transform: translateY(8px);
  transition: transform 0.2s;
}
.modal-overlay.active .modal { transform: translateY(0); }
.modal-lg { width: 760px; }
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 20px; border-bottom: 1px solid var(--border);
}
.modal-header h3 { font-size: 18px; font-weight: 700; }
.modal-close {
  background: none; border: none; color: var(--text-secondary);
  font-size: 26px; line-height: 1; cursor: pointer;
  width: 36px; height: 36px; border-radius: var(--radius);
}
.modal-close:hover { color: var(--text); background: var(--elevated); }
.modal-body { padding: 20px; }
.modal-footer {
  display: flex; justify-content: flex-end; gap: 8px;
  padding: 16px 20px; border-top: 1px solid var(--border);
  flex-wrap: wrap;
}

/* =============================================================================
 * TOASTS
 * =========================================================================== */
.toast-container {
  position: fixed; top: 18px; right: 18px;
  z-index: 2000;
  display: flex; flex-direction: column; gap: 8px;
}
.toast {
  padding: 13px 18px;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 500;
  color: #fff;
  box-shadow: var(--shadow-lg);
  animation: vh-slidein 0.25s ease;
  min-width: 260px;
  max-width: 360px;
}
.toast-success { background: var(--success); }
.toast-error   { background: var(--danger); }
.toast-info    { background: var(--info); }
@keyframes vh-slidein { from { transform: translateX(90px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* =============================================================================
 * SPINNER / LOADING / EMPTY
 * =========================================================================== */
.loading { display: flex; align-items: center; justify-content: center; padding: 56px; }
.spinner {
  width: 34px; height: 34px;
  border: 3px solid var(--border);
  border-top-color: var(--teal);
  border-radius: 50%;
  animation: vh-spin 0.8s linear infinite;
}
@keyframes vh-spin { to { transform: rotate(360deg); } }

.empty-state { text-align: center; padding: 60px 20px; }
.empty-state h2 { font-size: 20px; margin-bottom: 8px; color: var(--text); }
.empty-state p { margin-bottom: 20px; }

/* =============================================================================
 * WIZARD STEPPER
 * =========================================================================== */
.wizard { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow); overflow: hidden; }
.wizard-steps {
  display: flex;
  align-items: center;
  gap: 0;
  padding: 18px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--elevated);
  overflow-x: auto;
}
.wizard-step {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1 1 auto;
  min-width: 0;
}
.wizard-step:not(:last-child)::after {
  content: '';
  flex: 1;
  height: 2px;
  background: var(--border);
  margin: 0 12px;
  min-width: 24px;
}
.wizard-step.completed:not(:last-child)::after { background: var(--teal); }
.wizard-step-circle {
  width: 32px; height: 32px;
  border-radius: 50%;
  flex: 0 0 auto;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 700;
  background: var(--surface);
  border: 2px solid var(--border);
  color: var(--text-muted);
}
.wizard-step.active .wizard-step-circle { border-color: var(--teal); color: var(--teal); }
.wizard-step.completed .wizard-step-circle { background: var(--teal); border-color: var(--teal); color: #fff; }
.wizard-step-label { font-size: 13px; font-weight: 600; color: var(--text-secondary); white-space: nowrap; }
.wizard-step.active .wizard-step-label { color: var(--gray-900); }
.wizard-step.completed .wizard-step-label { color: var(--text); }
.wizard-body { padding: 24px 20px; }
.wizard-footer { display: flex; justify-content: space-between; gap: 8px; padding: 16px 20px; border-top: 1px solid var(--border); }

/* =============================================================================
 * DETAIL PAGE
 * =========================================================================== */
.detail-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 20px; margin-bottom: 22px; }
.detail-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 20px; box-shadow: var(--shadow); }
.detail-card h3 { font-size: 13px; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 14px; }
.detail-row { display: flex; justify-content: space-between; gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--border); }
.detail-row:last-child { border-bottom: none; }
.detail-row .label { color: var(--text-secondary); font-size: 13px; }
.detail-row .value { font-weight: 600; font-size: 14px; text-align: right; }

/* Detail page sections (customer detail: Drivers, etc.) */
.detail-section { margin-bottom: 22px; }
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}
.section-header h3 { font-size: 16px; font-weight: 700; color: var(--text); }

/* Forms: stacked field grid + actions row (shared by customer/driver forms) */
.detail-form { display: block; }
.form-grid { display: flex; flex-direction: column; gap: 0; }
.form-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 8px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

/* Driver cards (customer detail) */
.drivers-body { display: flex; flex-direction: column; gap: 14px; }
.driver-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  box-shadow: var(--shadow);
  border-left: 4px solid var(--teal);
}
.driver-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 6px;
}
.driver-card-title {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  font-size: 15px;
  color: var(--text);
}
.driver-card-title strong { font-weight: 700; }
.driver-card-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.driver-meta { margin: 4px 0 2px; }

/* Licence check history (collapsible inside driver card) */
.check-history { margin-top: 10px; border-top: 1px solid var(--border); }
.check-history-toggle { color: var(--text-secondary); }
.check-history-toggle:hover { color: var(--teal); }
.check-history-toggle .toggle-arrow { color: var(--teal); }
.check-history-body { margin-top: 8px; }

/* DL photo URL list (driver modal) */
.url-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 8px; }
.url-row { display: flex; align-items: center; gap: 8px; }
.url-row input { flex: 1 1 auto; min-width: 0; }

/* Pager label */
.pager-info { font-size: 13px; color: var(--text-secondary); }

/* =============================================================================
 * UTILITIES
 * =========================================================================== */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-muted { color: var(--text-secondary); }
.text-sm { font-size: 12px; }
.mt-8 { margin-top: 8px; } .mt-16 { margin-top: 16px; } .mt-24 { margin-top: 24px; }
.mb-8 { margin-bottom: 8px; } .mb-16 { margin-bottom: 16px; } .mb-24 { margin-bottom: 24px; }
.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.flex-wrap { flex-wrap: wrap; }
.gap-8 { gap: 8px; } .gap-12 { gap: 12px; } .gap-16 { gap: 16px; }
.clickable { cursor: pointer; }

/* =============================================================================
 * RESPONSIVE — sidebar collapses to off-canvas drawer under 800px
 * =========================================================================== */
/* Tablet — sidebar collapses to off-canvas drawer */
@media (max-width: 800px) {
  #sidebar { transform: translateX(-100%); box-shadow: var(--shadow-lg); }
  #sidebar.open { transform: translateX(0); }
  #app-body { margin-left: 0; }
  #hamburger-btn { display: flex; align-items: center; justify-content: center; }
  /* Keep the dealer/context label but drop the secondary View-As control to
   * avoid topbar overflow; full View-As stays available on desktop. */
  .context-sub { display: none; }
  .viewas-control { display: none; }
  .user-btn-label { display: none; }
  #app-main { padding: 16px; }
  .detail-row .value { text-align: left; }
  .modal-footer { flex-direction: column-reverse; }
  .modal-footer .btn { width: 100%; }

  /* Dashboard quick-links: 2 columns on tablet */
  .quicklink-grid { grid-template-columns: 1fr 1fr; }

  /* Wizard: let the stepper scroll, keep step content + footer reachable */
  .wizard-steps { padding: 14px 14px; }
  .wizard-body { padding: 18px 16px; }
  .wizard-footer { padding: 14px 16px; }
}

/* Phone */
@media (max-width: 480px) {
  #topbar { gap: 8px; padding: 0 12px; }
  #topbar-title { font-size: 16px; }
  /* Hide the textual context entirely on phone — title + user menu only */
  #topbar-context { display: none; }
  .page-header h1 { font-size: 20px; }
  .kpi-grid { grid-template-columns: 1fr 1fr; }
  .search-input { min-width: 0; width: 100%; }

  /* Dashboard quick-links: single column on phone */
  .quicklink-grid { grid-template-columns: 1fr; }

  /* Forms: multi-column rows collapse to a single column; inputs full-width */
  .form-row { flex-direction: column; gap: 0; }
  .form-row .form-group { flex: 1 1 100%; width: 100%; }

  /* Wizard: stepper scrolls horizontally; hide step labels to fit circles;
   * footer buttons stack full-width and stay tappable (≥44px). */
  .wizard-step-label { display: none; }
  .wizard-step:not(:last-child)::after { margin: 0 6px; min-width: 14px; }
  .wizard-footer { flex-direction: column-reverse; gap: 8px; }
  .wizard-footer .btn { width: 100%; }

  /* Modal padding tightens; internal scroll preserved via max-height */
  .modal { max-height: 92vh; }
  .modal-body { padding: 16px; }
  .modal-header { padding: 14px 16px; }

  /* Detail + toolbar: full width controls */
  .toolbar-search { flex: 1 1 100%; }
  .toolbar-search input { width: 100%; max-width: none; }
  .page-toolbar { gap: 10px; }
  .page-toolbar .btn-primary { width: 100%; }

  /* Driver cards: header + actions stack; buttons full-width and tappable */
  .driver-card { padding: 16px; }
  .driver-card-header { flex-direction: column; gap: 10px; }
  .driver-card-actions { width: 100%; }
  .driver-card-actions .btn { flex: 1 1 100%; min-height: var(--tap); }
  .section-header { flex-direction: column; align-items: stretch; }
  .section-header .btn { width: 100%; }
  .form-actions { flex-direction: column-reverse; }
  .form-actions .btn { width: 100%; }
  .url-row .btn { flex: 0 0 auto; }
}

/* ===========================================================================
   Bookings — List/Calendar view toggle + resource-timeline calendar
   (DEV-154 Amend 5)
   =========================================================================== */
.vh-view-toggle { display: inline-flex; gap: 4px; }

/* Horizontal scroll on small screens; the vehicle column stays pinned left. */
.vh-cal { overflow-x: auto; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); }
.vh-cal-inner { min-width: 760px; }

.vh-cal-head,
.vh-cal-row { display: flex; align-items: stretch; }
.vh-cal-head { position: sticky; top: 0; z-index: 3; background: var(--elevated); border-bottom: 1px solid var(--border); }
.vh-cal-row { border-bottom: 1px solid var(--border); }
.vh-cal-row:last-child { border-bottom: 0; }

/* Pinned vehicle column. */
.vh-cal-veh {
  flex: 0 0 180px; width: 180px; box-sizing: border-box;
  padding: 8px 12px; border-right: 1px solid var(--border);
  position: sticky; left: 0; z-index: 2; background: var(--surface);
  display: flex; flex-direction: column; justify-content: center;
}
.vh-cal-head .vh-cal-veh { background: var(--elevated); }
.vh-cal-veh-head { font-weight: 700; color: var(--text-secondary); font-size: 13px; }
.vh-cal-veh-reg { font-weight: 700; color: var(--text); font-size: 14px; }
.vh-cal-veh-mm { font-size: 12px; color: var(--text-muted); }

/* Day columns area — flex row of equal cells; bars overlay absolutely. */
.vh-cal-days { position: relative; display: flex; flex: 1 1 auto; min-height: 44px; }
.vh-cal-day-head { flex: 1 1 0; min-width: 44px; text-align: center; padding: 6px 2px; border-left: 1px solid var(--border); }
.vh-cal-day-head .vh-cal-dow { font-size: 11px; color: var(--text-muted); text-transform: uppercase; }
.vh-cal-day-head .vh-cal-dom { font-size: 14px; font-weight: 600; color: var(--text); }
.vh-cal-day-head.is-today { background: var(--teal-bg); }
.vh-cal-day-head.is-today .vh-cal-dom { color: var(--teal-dark); }

.vh-cal-cell { flex: 1 1 0; min-width: 44px; border-left: 1px solid var(--border); }
.vh-cal-cell.is-today { background: rgba(31, 158, 143, 0.06); }
.vh-cal-cell.is-bookable { cursor: pointer; position: relative; }
.vh-cal-cell.is-bookable:hover { background: var(--teal-bg); box-shadow: inset 0 0 0 1px var(--teal); }
/* Persistent affordance so "tap a free day to book" is visible on touch
   devices (no hover). pointer-events:none so it never blocks the cell click. */
.vh-cal-plus { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: var(--teal); opacity: 0.3; font-weight: 700; font-size: 1.05rem; line-height: 1; pointer-events: none; }
.vh-cal-cell.is-bookable:hover .vh-cal-plus { opacity: 0.75; }

/* Booking bars positioned by left%/width% over the day cells. */
.vh-cal-bar {
  position: absolute; top: 5px; bottom: 5px; box-sizing: border-box;
  margin: 0 2px; padding: 0 8px; border-radius: 6px;
  font-size: 12px; line-height: 1; color: #fff; cursor: pointer;
  display: flex; align-items: center; overflow: hidden; white-space: nowrap;
  text-overflow: ellipsis; z-index: 1;
}
.vh-cal-bar:hover { filter: brightness(1.05); }
.vh-cal-bar--active    { background: var(--teal); }
.vh-cal-bar--draft     { background: var(--text-muted); }
.vh-cal-bar--returned  { background: var(--navy); }
