/* ============================================================
   POLARIS DESIGN SYSTEM — app.css
   Implements every token, component, and layout from
   static/polaris-design-system.html. Do not add hardcoded hex
   values anywhere; always reference a token.
   ============================================================ */

/* ── Tokens ─────────────────────────────────────────────── */
:root {
  /* Navy — brand primary */
  --navy-950: #060E18;
  --navy-900: #0D1B2A;
  --navy-800: #122030;
  --navy-700: #1A2E44;
  --navy-600: #243D58;
  --navy-500: #2E4D6C;
  --navy-400: #3D6485;

  /* Cream — surfaces */
  --cream-50:  #FDFAF5;
  --cream-100: #F8F3E8;
  --cream-200: #EFE6D0;
  --cream-300: #E2D4B4;

  /* Gold — accent */
  --gold-600: #B8880E;
  --gold-500: #D4A017;
  --gold-400: #E0B535;
  --gold-200: #F5E4AA;
  --gold-100: #FBF3D5;

  /* Arctic — information / focus */
  --arctic-500: #3490AD;
  --arctic-400: #4BA3C3;
  --arctic-300: #72BDD6;
  --arctic-100: #E0F3FA;

  /* Signal */
  --green-600: #15784F;
  --green-500: #1EA06A;
  --green-100: #D4F4E5;
  --amber-500: #D4A017;
  --amber-100: #FDF3CC;
  --red-600:   #B83035;
  --red-500:   #D64045;
  --red-100:   #FAE0E1;
  --purple-500: #7C5CBF;
  --purple-100: #EDE8F8;

  /* Neutrals */
  --slate-900: #0F172A;
  --slate-800: #1E293B;
  --slate-700: #334155;
  --slate-600: #475569;
  --slate-500: #64748B;
  --slate-400: #94A3B8;
  --slate-300: #CBD5E1;
  --slate-200: #E2E8F0;
  --slate-100: #F1F5F9;
  --slate-50:  #F8FAFC;
  --white:     #FFFFFF;

  /* Semantic */
  --color-bg:             var(--cream-50);
  --color-bg-section:     var(--cream-100);
  --color-surface:        var(--white);
  --color-border:         var(--cream-200);
  --color-border-dark:    var(--cream-300);
  --color-text-primary:   #111827;
  --color-text-secondary: #4B5563;
  --color-text-muted:     #9CA3AF;
  --color-brand:          var(--navy-900);
  --color-accent:         var(--gold-500);
  --color-skeleton-base:  var(--arctic-100);
  --color-skeleton-shimmer: color-mix(in srgb, var(--arctic-100) 70%, var(--arctic-300));

  /* Legacy aliases (keep existing templates working) */
  --ink:        var(--navy-900);
  --text-muted: var(--color-text-muted);
  --border:     var(--color-border);
  --bg:         var(--color-bg);
  --primary:    var(--navy-900);
  --success:    var(--green-500);
  --warning:    var(--amber-500);
  --danger:     var(--red-500);

  /* Type */
  --font-sans: 'Outfit', system-ui, -apple-system, "Segoe UI", Roboto, Ubuntu, "Helvetica Neue", Arial, sans-serif;
  --font-mono: var(--font-sans);

  /* Spacing */
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 20px;
  --s6: 24px; --s8: 32px; --s10: 40px; --s12: 48px; --s16: 64px;

  /* Radius */
  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 14px;
  --r-xl: 20px;
  --r-full: 9999px;
  /* Legacy aliases */
  --radius:    var(--r-md);
  --radius-sm: var(--r-sm);

  /* Shadow */
  --shadow-sm:   0 1px 3px rgba(0,0,0,0.07), 0 0 0 1px rgba(0,0,0,0.04);
  --shadow-md:   0 4px 16px rgba(0,0,0,0.08), 0 0 0 1px rgba(0,0,0,0.04);
  --shadow-lg:   0 8px 32px rgba(0,0,0,0.12), 0 0 0 1px rgba(0,0,0,0.05);
  --shadow-navy: 0 4px 16px rgba(13,27,42,0.25);
  --shadow:      var(--shadow-sm);
}

/* ── Base ───────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
html { font-size: 14px; }
body {
  margin: 0;
  font-family: var(--font-sans);
  background: var(--color-bg);
  color: var(--color-text-primary);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
a { color: var(--arctic-500); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4, h5, h6 { margin: 0; color: var(--navy-900); letter-spacing: -0.01em; }
p { margin: 0; }
img { max-width: 100%; height: auto; }

/* ── Typography ─────────────────────────────────────────── */
.t-page-title      { font-size: 28px; font-weight: 700; letter-spacing: -0.02em; color: var(--navy-900); line-height: 1.2; }
.t-section-heading { font-size: 20px; font-weight: 600; letter-spacing: -0.01em; color: var(--navy-900); }
.t-card-title      { font-size: 15px; font-weight: 600; color: var(--navy-900); }
.t-body            { font-size: 14px; color: var(--color-text-secondary); line-height: 1.7; }
.t-label           { font-size: 12px; font-weight: 700; letter-spacing: 0.18em; text-transform: uppercase; color: var(--gold-500); }
.t-caption         { font-size: 12px; color: var(--color-text-muted); }
.t-mono            { font-family: var(--font-mono); font-size: 12px; color: var(--navy-700); }

/* ── Buttons ────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s2);
  padding: 9px 18px;
  border-radius: var(--r-sm);
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.01em;
  cursor: pointer;
  border: none;
  transition: background 0.18s, transform 0.05s, box-shadow 0.15s, color 0.15s, border-color 0.15s;
  white-space: nowrap;
  text-decoration: none;
  background: var(--white);
  color: var(--navy-900);
  border: 1px solid var(--color-border);
}
.btn:hover        { text-decoration: none; }
.btn:focus-visible{ outline: 2px solid var(--arctic-400); outline-offset: 2px; }
.btn:disabled,
.btn[aria-disabled="true"] { opacity: 0.5; cursor: not-allowed; pointer-events: none; }

.btn-primary,
.btn.primary {
  background: var(--navy-900);
  color: var(--white);
  border-color: var(--navy-900);
  box-shadow: var(--shadow-navy);
}
.btn-primary:hover,
.btn.primary:hover { background: var(--navy-700); border-color: var(--navy-700); color: var(--white); transform: translateY(-1px); }

.btn-secondary,
.btn.secondary {
  background: transparent;
  color: var(--navy-900);
  border: 1.5px solid var(--cream-300);
}
.btn-secondary:hover,
.btn.secondary:hover { background: var(--cream-100); border-color: var(--cream-300); }

.btn-gold {
  background: var(--gold-500);
  color: var(--white);
  border-color: var(--gold-500);
  box-shadow: 0 2px 8px rgba(212,160,23,0.3);
}
.btn-gold:hover { background: var(--gold-600); border-color: var(--gold-600); color: var(--white); transform: translateY(-1px); }

.btn-ghost {
  background: transparent;
  color: var(--color-text-secondary);
  border: 1px solid var(--slate-200);
}
.btn-ghost:hover { background: var(--slate-50); color: var(--navy-900); }

.btn-danger,
.btn.danger {
  background: var(--red-500);
  color: var(--white);
  border-color: var(--red-500);
}
.btn-danger:hover,
.btn.danger:hover { background: var(--red-600); border-color: var(--red-600); color: var(--white); transform: translateY(-1px); }

.btn-sm, .btn.sm { padding: 6px 12px; font-size: 12px; }
.btn-lg          { padding: 12px 24px; font-size: 15px; }
.btn-row         { display: flex; gap: var(--s3); flex-wrap: wrap; align-items: center; }

/* ── Badges ─────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: var(--r-full);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  white-space: nowrap;
}
.badge-dot {
  width: 6px; height: 6px; border-radius: 50%;
  display: inline-block; flex-shrink: 0;
}
.badge-active,
.badge-in_progress,
.badge-success     { background: var(--green-100);  color: var(--green-600); }
.badge-pending     { background: var(--amber-100);  color: var(--gold-600); }
.badge-assigned,
.badge-info        { background: var(--arctic-100); color: var(--arctic-500); }
.badge-cancelled,
.badge-danger      { background: var(--red-100);    color: var(--red-600); }
.badge-completed,
.badge-dropped_off { background: var(--slate-100);  color: var(--slate-700); }
.badge-scheduled   { background: var(--purple-100); color: var(--purple-500); }
.badge-en_route_pickup,
.badge-picked_up,
.badge-at_dropoff  { background: var(--purple-100); color: var(--purple-500); }
.badge-billed      { background: var(--purple-100); color: var(--purple-500); }
.badge-warning     { background: var(--amber-100);  color: var(--gold-600); }
.badge-navy        { background: var(--navy-900);   color: var(--white); }
.badge-row         { display: flex; gap: var(--s2); flex-wrap: wrap; }

.dot-green { background: var(--green-500); }
.dot-amber { background: var(--amber-500); }
.dot-red   { background: var(--red-500); }
.dot-gray  { background: var(--slate-300); }
.dot-navy  { background: var(--navy-600); }

/* ── Cards ──────────────────────────────────────────────── */
.card {
  background: var(--white);
  border: 1px solid var(--color-border);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.card-header {
  padding: var(--s5) var(--s6);
  border-bottom: 1px solid var(--color-border);
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--s4);
}
.card-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--gold-500);
  margin-bottom: 3px;
}
.card-rule {
  height: 1px;
  background: var(--gold-500);
  opacity: 0.2;
  margin-bottom: var(--s4);
}
.card-title { font-size: 14px; font-weight: 600; color: var(--navy-900); }
.card-body  { padding: var(--s5) var(--s6); }
.card-footer {
  padding: var(--s4) var(--s6);
  background: var(--cream-50);
  border-top: 1px solid var(--color-border);
  display: flex; align-items: center; justify-content: flex-end;
  gap: var(--s3);
}

/* Stat cards */
.stat-card {
  background: var(--white);
  border: 1px solid var(--color-border);
  border-top: 3px solid var(--gold-500);
  border-radius: var(--r-md);
  padding: var(--s5) var(--s6);
  box-shadow: var(--shadow-sm);
}
.stat-card.accent-green  { border-top-color: var(--green-500); }
.stat-card.accent-arctic { border-top-color: var(--arctic-400); }
.stat-card.accent-navy   { border-top-color: var(--navy-600); }
.stat-card.accent-amber  { border-top-color: var(--amber-500); }
.stat-card.accent-red    { border-top-color: var(--red-500); }
.stat-value {
  font-size: 32px; font-weight: 700; letter-spacing: -0.03em;
  color: var(--navy-900); line-height: 1;
}
.stat-label {
  font-size: 12px; font-weight: 700; letter-spacing: 0.14em;
  text-transform: uppercase; color: var(--color-text-muted);
  margin-top: 4px;
}
.stat-delta      { font-size: 12px; font-weight: 600; margin-top: 6px; }
.stat-delta.up   { color: var(--green-500); }
.stat-delta.down { color: var(--red-500); }
.stat-delta.flat { color: var(--slate-400); }
.stat-grid       { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--s4); }

/* ── Forms ──────────────────────────────────────────────── */
.field { margin-bottom: var(--s5); }
.field-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--navy-800);
  margin-bottom: var(--s2);
  letter-spacing: 0.02em;
}
.field-required { color: var(--red-500); margin-left: 3px; }
.field-hint  { font-size: 12px; color: var(--slate-400); margin-top: 5px; }
.field-error { font-size: 12px; color: var(--red-500); margin-top: 5px; font-weight: 500; }

input[type="text"],
input[type="email"],
input[type="password"],
input[type="date"],
input[type="time"],
input[type="datetime-local"],
input[type="tel"],
input[type="number"],
input[type="search"],
input[type="url"],
select,
textarea {
  width: 100%;
  padding: 9px 12px;
  font-family: var(--font-sans);
  font-size: 14px;
  background: var(--white);
  border: 1.5px solid var(--cream-300);
  border-radius: var(--r-sm);
  color: var(--color-text-primary);
  transition: border-color 0.15s, box-shadow 0.15s;
  outline: none;
  appearance: none;
  -webkit-appearance: none;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--arctic-400);
  box-shadow: 0 0 0 3px rgba(75, 163, 195, 0.15);
}
input.error, select.error, textarea.error {
  border-color: var(--red-500);
  box-shadow: 0 0 0 3px rgba(214, 64, 69, 0.12);
}
input::placeholder, textarea::placeholder { color: var(--slate-400); }

select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%239CA3AF' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}
textarea { resize: vertical; min-height: 80px; line-height: 1.6; }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s5); }
.form-section-title {
  font-size: 12px; font-weight: 700; letter-spacing: 0.18em;
  text-transform: uppercase; color: var(--gold-500);
  margin-bottom: var(--s2); margin-top: var(--s6);
}
.form-section-rule {
  height: 1px; background: var(--gold-500); opacity: 0.18;
  margin-bottom: var(--s5);
}
.checkbox-row { display: flex; align-items: center; gap: var(--s3); margin-bottom: var(--s3); }
.checkbox-row input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--navy-900); cursor: pointer; }
.checkbox-row label { font-size: 13px; color: var(--color-text-secondary); cursor: pointer; }

/* ── Tables ─────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table-scroll { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
thead { background: var(--navy-900); }
thead th {
  padding: 11px 14px;
  text-align: left;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.65);
  white-space: nowrap;
}
thead th:first-child { border-radius: var(--r-sm) 0 0 0; }
thead th:last-child  { border-radius: 0 var(--r-sm) 0 0; }
tbody tr {
  border-bottom: 1px solid var(--cream-100);
  transition: background 0.12s;
}
tbody tr.clickable { cursor: pointer; }
tbody tr:hover   { background: var(--cream-50); }
tbody tr:last-child { border-bottom: none; }
tbody td {
  padding: 12px 14px;
  color: var(--color-text-primary);
  vertical-align: middle;
}
.td-muted   { color: var(--color-text-muted); font-size: 12px; }
.td-mono    { font-family: var(--font-mono); font-size: 12px; }
.td-actions { display: flex; gap: var(--s2); justify-content: flex-end; }
tfoot td {
  padding: 11px 14px;
  background: var(--cream-100);
  border-top: 1px solid var(--cream-200);
  font-weight: 600;
  font-size: 13px;
  color: var(--navy-900);
}

/* Filter bar */
.filter-bar {
  display: flex;
  align-items: center;
  gap: var(--s3);
  padding: var(--s4) var(--s5);
  background: var(--white);
  border-bottom: 1px solid var(--color-border);
  flex-wrap: wrap;
}
.filter-bar input, .filter-bar select { width: auto; min-width: 140px; }
.filter-bar-label {
  font-size: 12px; font-weight: 700; letter-spacing: 0.1em;
  text-transform: uppercase; color: var(--slate-400); white-space: nowrap;
}

/* Pagination */
.pagination { display: flex; align-items: center; gap: var(--s2); }
.pg-btn {
  padding: 6px 14px;
  border-radius: var(--r-sm);
  border: 1px solid var(--cream-300);
  background: var(--white);
  font-size: 12px; font-weight: 600;
  cursor: pointer;
  color: var(--navy-800);
  transition: all 0.12s;
}
.pg-btn:hover { background: var(--cream-100); }
.pg-btn.active { background: var(--navy-900); color: var(--white); border-color: var(--navy-900); }
.pg-info { font-size: 12px; color: var(--slate-400); margin: 0 var(--s2); }

/* ── App shell ──────────────────────────────────────────── */
.app-shell {
  display: flex;
  min-height: 100vh;
}
.app-sidebar {
  width: 220px;
  flex-shrink: 0;
  background: var(--navy-900);
  display: flex;
  flex-direction: column;
  border-right: 1px solid rgba(255,255,255,0.06);
  position: fixed;
  top: 0; bottom: 0; left: 0;
  z-index: 40;
  overflow: hidden;
}
.sidebar-top {
  padding: var(--s5) var(--s5) var(--s4);
  border-bottom: 1px solid rgba(255,255,255,0.07);
  display: flex; align-items: center; gap: var(--s3);
}
.sidebar-logo-mark {
  width: 32px; height: 32px;
  border-radius: var(--r-sm);
  background: var(--gold-500);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.sidebar-logo-mark svg { width: 18px; height: 18px; }
.sidebar-brand {
  font-size: 15px;
  font-weight: 700;
  color: var(--white);
  letter-spacing: 0.04em;
}
.sidebar-brand span { color: var(--gold-400); }

.sidebar-nav {
  flex: 1;
  padding: var(--s3) 0;
  overflow-y: auto;
}
.sidebar-nav-section {
  padding: var(--s4) var(--s5) var(--s1);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.25);
}
.sidebar-link {
  display: flex; align-items: center; gap: var(--s3);
  padding: 9px var(--s5);
  font-size: 13px;
  font-weight: 500;
  color: rgba(255,255,255,0.55);
  transition: all 0.15s;
  cursor: pointer;
  border-left: 3px solid transparent;
  text-decoration: none;
}
.sidebar-link:hover {
  color: rgba(255,255,255,0.9);
  background: rgba(255,255,255,0.05);
  text-decoration: none;
}
.sidebar-link.active {
  color: var(--white);
  background: rgba(255,255,255,0.08);
  border-left-color: var(--gold-500);
}
.sidebar-link svg { width: 16px; height: 16px; opacity: 0.7; flex-shrink: 0; }
.sidebar-link.active svg { opacity: 1; }

.sidebar-footer {
  padding: var(--s4) var(--s5);
  border-top: 1px solid rgba(255,255,255,0.07);
  display: flex; align-items: center; gap: var(--s3);
}
.user-avatar {
  width: 40px; height: 40px;
  overflow: hidden;
  border-radius: 50%;
  background: var(--navy-600);
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700; color: var(--white);
  flex-shrink: 0;
}
.user-name { font-size: 12px; font-weight: 600; color: rgba(255,255,255,0.85); }
.user-role { font-size: 11px; color: rgba(255,255,255,0.35); }
.sidebar-logout {
  margin-left: auto;
  background: transparent;
  border: 1px solid rgba(255,255,255,0.15);
  color: rgba(255,255,255,0.6);
  border-radius: var(--r-sm);
  padding: 4px 8px;
  font-size: 12px;
  cursor: pointer;
}
.sidebar-logout:hover { color: var(--white); background: rgba(255,255,255,0.1); }

.app-main {
  flex: 1;
  margin-left: 220px;
  background: var(--color-bg);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-width: 0;
}
.app-topbar {
  background: var(--white);
  border-bottom: 1px solid var(--color-border);
  padding: 0 var(--s6);
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
  position: sticky;
  top: 0;
  z-index: 30;
}
.page-breadcrumb { display: flex; align-items: center; gap: var(--s2); font-size: 13px; }
.breadcrumb-parent { color: var(--slate-400); }
.breadcrumb-sep    { color: var(--slate-300); }
.breadcrumb-current{ color: var(--navy-900); font-weight: 600; }
.topbar-actions    { display: flex; align-items: center; gap: var(--s3); }

.app-content {
  flex: 1;
  overflow-y: auto;
  padding: var(--s6);
  min-width: 0;
}
/* Defensive: if a page template still wraps its content in an inline-styled
   <section max-width=...>, strip those so the layout stays edge-to-edge.
   Only modals, the login card, and toasts may have max-width. */
.app-content > section,
.app-content > div,
.app-content > article,
.app-content > main,
.app-content > form {
  max-width: none !important;
  margin-left: 0 !important;
  margin-right: 0 !important;
  width: 100%;
}
/* But do not override true dialogs rendered inside the main area */
.app-content > dialog,
.app-content .modal,
.app-content .modal-backdrop,
.app-content .confirm-overlay,
.app-content .modal-overlay {
  max-width: revert !important;
  margin-left: revert !important;
  margin-right: revert !important;
  width: revert;
}

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--s4);
  margin-bottom: var(--s6);
}
.page-title    { font-size: 22px; font-weight: 700; letter-spacing: -0.02em; color: var(--navy-900); }
.page-subtitle { font-size: 13px; color: var(--slate-400); margin-top: 3px; }

/* Mobile menu toggle */
.sidebar-toggle {
  display: none;
  position: fixed;
  top: 10px; left: 10px;
  z-index: 60;
  width: 36px; height: 36px;
  border-radius: var(--r-sm);
  background: var(--navy-900);
  color: var(--white);
  border: none;
  cursor: pointer;
  align-items: center;
  justify-content: center;
}
@media (max-width: 900px) {
  .app-sidebar { transform: translateX(-100%); transition: transform 0.2s ease; }
  .app-sidebar.open { transform: translateX(0); box-shadow: var(--shadow-lg); }
  .app-main { margin-left: 0; }
  .sidebar-toggle { display: inline-flex; }
  .app-topbar { padding-left: 56px; }
}

/* ── Modals ───────────────────────────────────────────────
   The look comes from modal.css (.pm-card, .pm-head, …); these rules only
   place the legacy overlays and size their cards. */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 9500;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--s6);
}
.modal { width: 100%; max-width: 520px; }
.modal-lg { max-width: 640px; }
.confirm-overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  padding: var(--s4);
}
.confirm-modal { width: 100%; max-width: 520px; }
.confirm-modal .confirm-msg { margin: 0; color: var(--color-text-primary); font-size: 14px; line-height: 1.6; }
.prompt-modal .confirm-msg { display: block; margin-bottom: 8px; font-size: 12px; font-weight: 700; }

/* ── Status stepper ─────────────────────────────────────── */
.stepper { display: flex; align-items: center; gap: 0; }
.step {
  display: flex; flex-direction: column; align-items: center; flex: 1;
  position: relative;
}
.step:not(:last-child)::after {
  content: '';
  position: absolute;
  top: 14px; left: 50%; right: -50%;
  height: 2px;
  background: var(--cream-300);
  z-index: 0;
}
.step.done:not(:last-child)::after,
.step.active:not(:last-child)::after { background: var(--navy-700); }
.step-circle {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--cream-200);
  border: 2px solid var(--cream-300);
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700;
  color: var(--slate-400);
  position: relative;
  z-index: 1;
}
.step.done .step-circle   { background: var(--navy-900);  border-color: var(--navy-900);  color: var(--white); }
.step.active .step-circle { background: var(--gold-500);  border-color: var(--gold-500);  color: var(--white); }
.step-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  margin-top: 6px;
  color: var(--slate-400);
  text-align: center;
}
.step.done .step-label   { color: var(--navy-700); }
.step.active .step-label { color: var(--gold-600); }

/* ── Alerts (inline) ────────────────────────────────────── */
.alert {
  display: flex;
  gap: var(--s4);
  padding: var(--s4) var(--s5);
  border-radius: var(--r-md);
  border-left: 3px solid;
  margin-bottom: var(--s3);
}
.alert-icon  { font-size: 16px; flex-shrink: 0; margin-top: 1px; }
.alert-title { font-size: 13px; font-weight: 700; margin-bottom: 3px; }
.alert-body  { font-size: 12px; line-height: 1.6; }
.alert-info    { background: var(--arctic-100); border-color: var(--arctic-400); color: var(--arctic-500); }
.alert-success { background: var(--green-100);  border-color: var(--green-500);  color: var(--green-600); }
.alert-warning { background: var(--amber-100);  border-color: var(--amber-500);  color: var(--gold-600); }
.alert-danger  { background: var(--red-100);    border-color: var(--red-500);    color: var(--red-600); }

/* Subscription notices share the page with its workspace, including flex layouts. */
.subscription-required-notice {
  flex: 0 0 auto;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  min-width: 0;
  color: var(--navy-800);
  font-size: 14px;
  line-height: 1.5;
}
.subscription-required-message { flex: 1 1 240px; min-width: 0; }
.subscription-required-message strong { display: block; font-size: 15px; }
.subscription-required-message p { margin: 3px 0 0; }
.subscription-required-notice .btn { flex: 0 0 auto; }

/* ── Toasts ─────────────────────────────────────────────── */
#toast-container {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: var(--s2);
  pointer-events: none;
  max-width: 340px;
  width: calc(100vw - 32px);
}
.toast-stack { display: flex; flex-direction: column; gap: var(--s2); max-width: 340px; }
.toast {
  display: flex;
  align-items: flex-start;
  gap: var(--s3);
  background: var(--navy-900);
  color: var(--white);
  padding: var(--s3) var(--s4);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-lg);
  border-left: 3px solid var(--gold-400);
  font-size: 13px;
  pointer-events: all;
  animation: toast-in 0.2s ease;
  line-height: 1.4;
}
.toast.out            { animation: toast-out 0.25s ease forwards; }
.toast.toast-success,
.toast.success        { border-left-color: var(--green-500); }
.toast.toast-error,
.toast.error          { border-left-color: var(--red-500); }
.toast.toast-warning,
.toast.warning        { border-left-color: var(--amber-500); }
.toast.toast-info,
.toast.info           { border-left-color: var(--arctic-400); }
.toast-icon  { font-size: 14px; flex-shrink: 0; margin-top: 1px; color: rgba(255,255,255,0.85); }
.toast-msg,
.toast-body  { flex: 1; }
.toast-title { font-weight: 600; font-size: 13px; }
.toast-sub   { font-size: 12px; color: rgba(255,255,255,0.55); margin-top: 2px; }
.toast-close,
.toast-x {
  background: none;
  border: none;
  cursor: pointer;
  color: rgba(255,255,255,0.45);
  font-size: 14px;
  padding: 0 2px;
  flex-shrink: 0;
}
.toast-close:hover { color: var(--white); }
@keyframes toast-in  { from { opacity: 0; transform: translateX(24px); } to { opacity: 1; transform: none; } }
@keyframes toast-out { from { opacity: 1; transform: none; } to { opacity: 0; transform: translateX(24px); } }

/* NProgress */
#nprogress {
  pointer-events: none;
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 3px;
  z-index: 99999;
}
#nprogress .bar {
  background: var(--gold-500);
  height: 3px;
  width: 0%;
  transition: width 0.2s ease;
}

/* ── Skeleton ───────────────────────────────────────────── */
@keyframes shimmer {
  0%   { background-position: -600px 0; }
  100% { background-position:  600px 0; }
}
.skeleton {
  background: linear-gradient(90deg, var(--color-skeleton-base) 25%, var(--color-skeleton-shimmer) 50%, var(--color-skeleton-base) 75%);
  background-size: 600px 100%;
  animation: shimmer 1.4s infinite linear;
  border-radius: var(--r-sm);
  color: transparent;
  user-select: none;
}
.skeleton-row { height: 18px; margin: 10px 0; border-radius: var(--r-sm); }
.skeleton-row.wide { width: 90%; }
.skeleton-row.mid  { width: 60%; }
.skeleton-row.slim { width: 35%; }
.sk-row   { display: flex; gap: var(--s3); align-items: center; margin-bottom: var(--s3); }
.sk-block { border-radius: var(--r-sm); }

/* ── Empty and error states ─────────────────────────────── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--s12) var(--s6);
  color: var(--color-text-muted);
  text-align: center;
  gap: var(--s3);
}
.empty-state .empty-icon {
  width: 48px; height: 48px;
  border-radius: 50%;
  background: var(--cream-100);
  display: flex; align-items: center; justify-content: center;
  color: var(--gold-500);
}
.empty-state .empty-msg { font-size: 14px; color: var(--color-text-secondary); }
.error-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: var(--s8);
  background: var(--red-100);
  border: 1px solid rgba(214, 64, 69, 0.25);
  border-left: 3px solid var(--red-500);
  border-radius: var(--r-md);
  color: var(--red-600);
  text-align: center;
  gap: var(--s3);
}
.error-state .error-msg { font-size: 14px; color: var(--red-600); }

/* ── Dispatch board ─────────────────────────────────────── */
.dispatch-layout {
  display: grid;
  grid-template-columns: 280px 1fr;
  height: calc(100vh - 52px);
  border-radius: 0;
  overflow: hidden;
  border: 1px solid var(--color-border);
}
.dispatch-sidebar {
  background: var(--white);
  border-right: 1px solid var(--color-border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.dispatch-sidebar-header {
  padding: var(--s4) var(--s5);
  border-bottom: 1px solid var(--color-border);
  background: var(--navy-900);
}
.dispatch-sidebar-title {
  font-size: 12px; font-weight: 700; letter-spacing: 0.16em;
  text-transform: uppercase; color: rgba(255,255,255,0.5);
}
.dispatch-search {
  margin-top: var(--s3);
  padding: 7px 10px;
  border-radius: var(--r-sm);
  background: rgba(255,255,255,0.07);
  border: 1px solid rgba(255,255,255,0.1);
  font-size: 12px;
  color: var(--white);
  width: 100%;
  font-family: var(--font-sans);
  outline: none;
}
.dispatch-search::placeholder { color: rgba(255,255,255,0.3); }
.driver-list { flex: 1; overflow-y: auto; }
.driver-card {
  padding: var(--s3) var(--s5);
  border-bottom: 1px solid var(--cream-100);
  cursor: pointer;
  transition: background 0.12s;
  display: flex;
  gap: var(--s3);
  align-items: center;
}
.driver-card:hover { background: var(--cream-50); }
.driver-card.selected { background: var(--arctic-100); }
.driver-initials {
  width: 34px; height: 34px;
  border-radius: var(--r-sm);
  background: var(--navy-900);
  color: var(--white);
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700;
  flex-shrink: 0;
}
.driver-info     { flex: 1; min-width: 0; }
.driver-name     { font-size: 13px; font-weight: 600; color: var(--navy-900); }
.driver-sub      { font-size: 12px; color: var(--slate-400); margin-top: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.driver-status-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }

.dispatch-map-area {
  background: #E8EDF2;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}
.map-placeholder      { text-align: center; }
.map-placeholder-grid {
  position: absolute; inset: 0;
  background-image:
    linear-gradient(rgba(13,27,42,0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(13,27,42,0.04) 1px, transparent 1px);
  background-size: 40px 40px;
}
.map-label { font-size: 12px; color: var(--slate-500); font-weight: 500; position: relative; z-index: 1; }

.map-pin { position: absolute; display: flex; flex-direction: column; align-items: center; }
.map-pin-dot {
  width: 14px; height: 14px;
  border-radius: 50%;
  border: 2px solid var(--white);
  box-shadow: 0 2px 6px rgba(0,0,0,0.25);
}
.map-pin-label {
  margin-top: 4px;
  background: var(--navy-900);
  color: var(--white);
  font-size: 11px; font-weight: 600;
  padding: 2px 6px;
  border-radius: var(--r-sm);
  white-space: nowrap;
  box-shadow: var(--shadow-sm);
}
.pin-green { background: var(--green-500); }
.pin-gold  { background: var(--gold-500); }
.pin-navy  { background: var(--navy-600); }
.pin-red   { background: var(--red-500); }

/* ── Dark page topbar variant ───────────────────────────── */
.page-topbar {
  background: var(--navy-900);
  border-bottom: 2px solid var(--gold-500);
  padding: 0 var(--s6);
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.topbar-logo { font-size: 16px; font-weight: 700; color: var(--white); letter-spacing: 0.05em; }
.topbar-logo span { color: var(--gold-400); }
.topbar-right { display: flex; align-items: center; gap: var(--s5); }
.topbar-user  { display: flex; align-items: center; gap: var(--s3); }
.topbar-user-name { font-size: 13px; color: rgba(255,255,255,0.75); }

/* ── Login page ─────────────────────────────────────────── */
.login-page {
  background: var(--navy-900);
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
  padding: var(--s6);
}
.login-page::before {
  content: '';
  position: absolute;
  top: -120px;
  right: -80px;
  width: 500px;
  height: 500px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(212,160,23,0.1) 0%, transparent 65%);
  pointer-events: none;
}
.login-page::after {
  content: '';
  position: absolute;
  bottom: -100px;
  left: -60px;
  width: 400px;
  height: 400px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(75,163,195,0.08) 0%, transparent 65%);
  pointer-events: none;
}
.login-card {
  background: var(--white);
  border-radius: var(--r-xl);
  padding: var(--s10);
  width: 100%;
  max-width: 400px;
  box-shadow: var(--shadow-lg);
  position: relative;
  z-index: 1;
}
.login-logo-area { text-align: center; margin-bottom: var(--s8); }
.login-logotype  { font-size: 22px; font-weight: 700; color: var(--navy-900); letter-spacing: 0.06em; }
.login-logotype em { color: var(--gold-500); font-style: normal; }
.login-tagline   { font-size: 12px; color: var(--slate-400); margin-top: 4px; letter-spacing: 0.06em; text-transform: uppercase; }
.login-divider   { height: 1px; background: var(--cream-200); margin: var(--s6) 0; }

/* ── Misc utilities ─────────────────────────────────────── */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s5); }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: var(--s5); }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.flex-center  { display: flex; align-items: center; gap: var(--s3); }
.text-muted   { color: var(--color-text-muted); }
.text-gold    { color: var(--gold-500); }
.text-navy    { color: var(--navy-900); }
.fw-700       { font-weight: 700; }
.mb-2 { margin-bottom: var(--s2); }
.mb-3 { margin-bottom: var(--s3); }
.mb-4 { margin-bottom: var(--s4); }
.mb-5 { margin-bottom: var(--s5); }
.mb-6 { margin-bottom: var(--s6); }
.mt-4 { margin-top: var(--s4); }
.mt-6 { margin-top: var(--s6); }
.gap-2 { gap: var(--s2); }
.gap-3 { gap: var(--s3); }
.gap-4 { gap: var(--s4); }
.flex       { display: flex; }
.flex-col   { display: flex; flex-direction: column; }
.items-center { align-items: center; }
.w-full     { width: 100%; }
.hidden     { display: none !important; }

code {
  font-family: var(--font-mono);
  font-size: 12px;
  background: var(--cream-100);
  padding: 2px 6px;
  border-radius: var(--r-sm);
  color: var(--navy-700);
}

/* Legacy wrappers used by older templates. The app shell already constrains
   layout and applies edge-to-edge padding, so these must never center or cap
   width. Kept as no-ops only to preserve className-based selectors. */
.container,
.page-container {
  max-width: none;
  margin: 0;
  padding: 0;
  width: 100%;
}

/* Print styles: hide chrome for scheduling print view */
@media print {
  .app-sidebar, .app-topbar, .sidebar-toggle, #toast-container, #nprogress { display: none !important; }
  .app-main { margin-left: 0; }
  body { background: var(--white); }
}

/* ============================================================
   LEGACY SHIMS — map older class names used by the long-tail
   templates onto the design system so everything renders in the
   correct navy/cream/gold language without a per-file rewrite.
   ============================================================ */

/* Trip detail status-timeline */
.detail-grid {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(0, 1fr);
  gap: var(--s5);
}
@media (max-width: 900px) { .detail-grid { grid-template-columns: 1fr; } }

.timeline {
  display: flex;
  align-items: center;
  gap: 0;
  padding: var(--s5);
  background: var(--white);
  border: 1px solid var(--color-border);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-sm);
}
.timeline .step,
.timeline-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: 1;
  position: relative;
}
.timeline-step:not(:last-child)::after {
  content: '';
  position: absolute;
  top: 14px; left: 50%; right: -50%;
  height: 2px;
  background: var(--cream-300);
  z-index: 0;
}
.timeline-step.done:not(:last-child)::after,
.timeline-step.active:not(:last-child)::after { background: var(--navy-700); }

/* Section title used on cards (old name) */
.section-title {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--gold-500);
  margin: 0 0 var(--s3);
  padding-bottom: var(--s2);
  border-bottom: 1px solid rgba(212, 160, 23, 0.25);
}

/* Older form field variants */
.field-select {
  display: block;
  width: 100%;
  padding: 9px 12px;
  font-family: var(--font-sans);
  font-size: 14px;
  background: var(--white);
  border: 1.5px solid var(--cream-300);
  border-radius: var(--r-sm);
  color: var(--color-text-primary);
}
.field-select:focus {
  border-color: var(--arctic-400);
  box-shadow: 0 0 0 3px rgba(75, 163, 195, 0.15);
  outline: none;
}

/* Modal overlay (legacy companies markup) */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 9500;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--s4);
}

/* Small helpers used by dispatch/trips pages */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: var(--r-full);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  background: var(--cream-100);
  color: var(--navy-800);
  border: 1px solid var(--cream-200);
}
.count-pill {
  display: inline-block;
  background: var(--cream-100);
  border: 1px solid var(--cream-200);
  border-radius: var(--r-full);
  padding: 2px 10px;
  font-size: 12px;
  font-weight: 700;
  color: var(--navy-800);
}

/* Dispatch board legacy columns */
.kanban .col {
  background: var(--white) !important;
  border: 1px solid var(--color-border) !important;
  border-radius: var(--r-md) !important;
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.kanban .col-header {
  background: var(--navy-900);
  color: var(--white) !important;
  border-bottom: 2px solid var(--gold-500) !important;
  padding: var(--s3) var(--s4) !important;
  font-size: 12px !important;
  font-weight: 700 !important;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}
.kanban .col-header .count { color: rgba(255, 255, 255, 0.65) !important; }

.trip-card {
  border: 1px solid var(--color-border) !important;
  border-left: 3px solid var(--gold-500);
  border-radius: var(--r-md) !important;
  padding: var(--s3) var(--s4) !important;
  margin-bottom: var(--s3) !important;
  background: var(--white) !important;
  box-shadow: var(--shadow-sm);
  font-size: 13px;
}
.trip-card strong { color: var(--navy-900); font-family: var(--font-mono); font-size: 12px; }

.btn.xs { padding: 4px 10px; font-size: 12px; border-radius: var(--r-sm); }

/* Dispatch driver "On the road" cream tint for dark sidebar hover */
.tag-chip {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px; border-radius: var(--r-full);
  font-size: 12px; font-weight: 600;
  border: 1px solid var(--cream-300);
  background: var(--cream-50);
  color: var(--navy-800);
}

/* ============================================================
   TEAM MODULE
   ------------------------------------------------------------
   Mental model: a shift is created on a van, then a driver and
   attendants are assigned to that shift. Every surface reflects
   that progression — vans on the left, shifts on the timeline,
   assignments inside each card.
   ============================================================ */

/* ── Team tabs (sub-nav) ─────────────────────────────────── */
.team-tabs {
  display: flex;
  gap: var(--s1);
  align-items: stretch;
  padding: 4px;
  margin-bottom: var(--s5);
  background: var(--white);
  border: 1px solid var(--color-border);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-sm);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
}
.team-tab {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s2);
  padding: 9px 16px;
  border-radius: var(--r-sm);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.01em;
  color: var(--color-text-secondary);
  text-decoration: none;
  white-space: nowrap;
  transition: background 0.15s, color 0.15s, box-shadow 0.15s;
}
.team-tab:hover {
  background: var(--cream-50);
  color: var(--navy-900);
  text-decoration: none;
}
.team-tab.active {
  background: var(--navy-900);
  color: var(--white);
  box-shadow: var(--shadow-navy);
}
.team-tab.active::after {
  content: "";
  position: absolute;
  left: 14px; right: 14px; bottom: 4px;
  height: 2px;
  background: var(--gold-400);
  border-radius: 2px;
  opacity: 0.85;
}
.team-tab[data-count]::after { /* numeric badge slot */
  content: attr(data-count);
  position: static;
  margin-left: 4px;
  padding: 1px 7px;
  background: var(--cream-200);
  color: var(--navy-800);
  border-radius: var(--r-full);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  height: auto;
}
.team-tab.active[data-count]::after {
  background: var(--gold-400);
  color: var(--navy-900);
}

/* ── Team back link (eyebrow) ───────────────────────────── */
.team-back-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--gold-500);
  text-decoration: none;
}
.team-back-link::before {
  content: "←";
  font-size: 13px;
  letter-spacing: 0;
  color: var(--gold-500);
}
.team-back-link:hover { color: var(--gold-600); text-decoration: none; }

/* ── Team toolbar (search + filters + actions) ───────────── */
.team-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--s3);
  padding: var(--s3) var(--s4);
  margin-bottom: var(--s4);
  background: var(--white);
  border: 1px solid var(--color-border);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-sm);
}
.team-toolbar input[type="text"],
.team-toolbar input[type="search"],
.team-toolbar select {
  height: 38px;
  border: 1.5px solid var(--cream-300);
  background: var(--cream-50);
}
.team-toolbar input[type="text"]:focus,
.team-toolbar input[type="search"]:focus,
.team-toolbar select:focus {
  background: var(--white);
}
.team-toolbar > .grow { flex: 1; min-width: 200px; }
.team-toolbar .toolbar-spacer { flex: 1; }

/* ── Team summary row (counts) ──────────────────────────── */
.summary-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--s4);
  margin-bottom: var(--s5);
}
.summary-card {
  position: relative;
  padding: var(--s4) var(--s5);
  background: var(--white);
  border: 1px solid var(--color-border);
  border-radius: var(--r-md);
  border-top: 3px solid var(--gold-500);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.summary-card::before {
  content: "";
  position: absolute;
  top: -40px; right: -30px;
  width: 110px; height: 110px;
  background: radial-gradient(circle, rgba(212,160,23,0.08), transparent 70%);
  pointer-events: none;
}
.summary-card .num {
  font-size: 30px;
  font-weight: 700;
  letter-spacing: -0.025em;
  color: var(--navy-900);
  line-height: 1;
  font-family: var(--font-sans);
}
.summary-card .lbl {
  margin-top: 6px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--color-text-muted);
}
.summary-card.success { border-top-color: var(--green-500); }
.summary-card.success .num { color: var(--green-600); }
.summary-card.warning { border-top-color: var(--amber-500); }
.summary-card.warning .num { color: var(--gold-600); }
.summary-card.danger  { border-top-color: var(--red-500); }
.summary-card.danger .num { color: var(--red-600); }
@media (max-width: 720px) {
  .summary-row { grid-template-columns: 1fr; }
}

/* ── .ttable refinement (scoped polish, design-system aligned) ─ */
table.ttable { border-radius: var(--r-md); overflow: hidden; }
table.ttable thead th {
  background: var(--navy-900);
  color: rgba(255,255,255,0.78);
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  padding: 12px 14px;
  border-bottom: 2px solid var(--gold-500);
}
table.ttable tbody tr { border-bottom: 1px solid var(--cream-100); }
table.ttable tbody tr:nth-child(even) { background: var(--cream-50); }
table.ttable tbody tr:hover { background: var(--cream-100); }
table.ttable tbody td { padding: 13px 14px; vertical-align: middle; }

/* ── Team form (driver_new.html and similar) ────────────── */
.team-form-card {
  padding: var(--s6) var(--s6) var(--s5);
  margin-top: var(--s4);
}
.team-form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--s4) var(--s5);
}
.team-form-grid .field { margin-bottom: 0; }
.team-form-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--s3);
  margin-top: var(--s6);
  padding-top: var(--s5);
  border-top: 1px solid var(--color-border);
}
.team-form-status {
  flex: 1;
  font-size: 13px;
  color: var(--color-text-secondary);
  min-height: 18px;
  text-align: left;
}
.team-form-status.error { color: var(--red-500); font-weight: 600; }
@media (max-width: 720px) {
  .team-form-grid { grid-template-columns: 1fr; }
  .team-form-actions { flex-wrap: wrap; }
  .team-form-actions .btn { flex: 1; justify-content: center; }
}

/* ============================================================
   SCHEDULING (Planby) — shift = van slot, then assign crew
   ============================================================ */
.planby-page {
  padding: var(--s4);
  display: flex;
  flex-direction: column;
  gap: var(--s4);
}
.planby-shell {
  display: flex;
  flex-direction: column;
  background: var(--white);
  border: 1px solid var(--color-border);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-sm);
  min-height: 600px;
  overflow: hidden;
}

/* Topbar — week nav + search + actions */
.planby-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--s3);
  padding: var(--s4) var(--s5);
  background: var(--cream-50);
  border-bottom: 1px solid var(--color-border);
}
.planby-topbar-left {
  display: flex;
  align-items: center;
  gap: var(--s2);
}
.planby-topbar input[type="search"] {
  height: 36px;
  width: 220px;
  padding-left: 32px;
  background: var(--white) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%2394A3B8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cpath d='m21 21-4.35-4.35'/%3E%3C/svg%3E") no-repeat 10px center;
  border: 1.5px solid var(--cream-300);
  border-radius: var(--r-sm);
  font-size: 13px;
}
.planby-pill {
  display: inline-flex;
  align-items: center;
  padding: 7px 14px;
  background: var(--navy-900);
  color: var(--white);
  border-radius: var(--r-full);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  box-shadow: var(--shadow-navy);
  border: 1px solid var(--navy-700);
}

/* Day strip + legend */
.planby-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--s3);
  padding: var(--s3) var(--s5);
  background: var(--white);
  border-bottom: 1px solid var(--color-border);
}
.planby-daystrip {
  display: flex;
  gap: 4px;
  padding: 4px;
  background: var(--cream-100);
  border-radius: var(--r-md);
  border: 1px solid var(--cream-200);
}
.planby-daybtn {
  appearance: none;
  background: transparent;
  border: none;
  padding: 7px 14px;
  border-radius: var(--r-sm);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--color-text-secondary);
  cursor: pointer;
  transition: background 0.15s, color 0.15s, box-shadow 0.15s;
  font-family: var(--font-sans);
}
.planby-daybtn:hover { background: var(--white); color: var(--navy-900); }
.planby-daybtn[aria-current="true"] {
  background: var(--white);
  color: var(--navy-900);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--cream-300);
}

.planby-legend {
  display: flex;
  align-items: center;
  gap: var(--s3);
  font-size: 12px;
  font-weight: 600;
  color: var(--color-text-secondary);
  letter-spacing: 0.04em;
}
.planby-legend-dot {
  display: inline-block;
  width: 9px; height: 9px;
  border-radius: 50%;
  margin-right: 4px;
  vertical-align: middle;
  box-shadow: 0 0 0 2px var(--white);
}
.planby-legend-dot.purple { background: var(--purple-500); }
.planby-legend-tag {
  margin-left: var(--s2);
  padding: 3px 10px;
  background: var(--cream-100);
  border: 1px solid var(--cream-300);
  border-radius: var(--r-full);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--color-text-muted);
}

/* View mode bar — Timeline / Calendar toggle */
.sched-modebar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--s3);
  padding: 10px 12px;
  background: var(--white);
  border: 1px solid var(--color-border);
  border-radius: 14px;
  box-shadow: var(--shadow-sm);
}
.sched-modebar .left {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.sched-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border: 1px solid var(--cream-300);
  border-radius: var(--r-full);
  background: var(--white);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--navy-900);
}
.sched-chip .dot { width: 9px; height: 9px; border-radius: 50%; }
.sched-chip .dot.purple { background: var(--purple-500); }
.sched-chip .dot.green  { background: var(--green-500); }
.sched-chip.timeline {
  border-color: var(--purple-500);
  border-color: color-mix(in srgb, var(--purple-500) 40%, white);
  background: var(--purple-100);
}
.sched-chip.calendar {
  border-color: var(--green-500);
  border-color: color-mix(in srgb, var(--green-500) 40%, white);
  background: var(--green-100);
}
.sched-help { color: var(--color-text-muted); font-size: 12px; }

/* Body — timeline + sidebar shell */
.planby-main {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}
.planby-card-body {
  flex: 1;
  min-height: 480px;
  position: relative;
  background:
    linear-gradient(var(--cream-50) 0%, var(--white) 100%);
}
.planby-root-inner {
  position: absolute;
  inset: 0;
  padding: var(--s2);
}

/* ── Modals (create + edit) ─────────────────────────────── */
.planby-backdrop {
  position: fixed; inset: 0;
  background: rgba(6,14,24,0.55);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  display: none;
  z-index: 9400;
}
.planby-backdrop.show { display: block; }
.planby-modal {
  position: fixed; inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 9500;
  padding: var(--s4);
}
.planby-modal.show { display: flex; }
.planby-modal-card {
  width: min(540px, calc(100vw - 32px));
  animation: planby-modal-in 0.18s ease-out;
}
@keyframes planby-modal-in {
  from { opacity: 0; transform: translateY(8px) scale(0.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* Modal section anatomy — labelled groups so the user sees
   "Step 1: pick the van. Step 2: assign crew." */
.planby-field {
  margin-bottom: var(--s4);
}
.planby-field:last-child { margin-bottom: 0; }
.planby-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--s3);
  margin-bottom: var(--s4);
}
.planby-row:last-child { margin-bottom: 0; }
.planby-row-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.planby-row .planby-field { margin-bottom: 0; }
.planby-label {
  display: block;
  font-size: 12px;
  font-weight: 700;
  color: var(--navy-900);
  margin-bottom: 8px;
}
.planby-help {
  color: var(--color-text-muted, #637384);
  font-weight: 400;
  font-size: 12px;
  margin-left: 4px;
}
.planby-help a {
  color: var(--arctic-500);
  font-weight: 600;
}
.planby-input,
.planby-select {
  width: 100%;
  min-height: 46px;
  padding: 11px 12px;
  font-family: var(--font-sans);
  font-size: 14px;
  background: var(--white);
  border: 1.5px solid var(--cream-300);
  border-radius: var(--r-sm);
  color: var(--color-text-primary);
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
}
.planby-input:hover,
.planby-select:hover { border-color: var(--cream-300); background: var(--cream-50); }
.planby-input:focus,
.planby-select:focus {
  border-color: var(--arctic-400);
  box-shadow: 0 0 0 3px rgba(75,163,195,0.18);
  background: var(--white);
  outline: none;
}
.planby-error {
  margin-top: var(--s3);
  padding: 8px 12px;
  background: var(--red-100);
  border: 1px solid rgba(214,64,69,0.3);
  border-left: 3px solid var(--red-500);
  border-radius: var(--r-sm);
  color: var(--red-600);
  font-size: 12px;
  font-weight: 500;
  min-height: 0;
}
.planby-error:empty {
  display: none;
}

/* Toast */
.planby-toast {
  position: fixed;
  top: 16px;
  right: 16px;
  background: var(--navy-900);
  color: var(--white);
  padding: var(--s3) var(--s4);
  padding-left: 18px;
  border-radius: var(--r-md);
  border-left: 3px solid var(--gold-400);
  font-size: 13px;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  display: none;
  z-index: 9600;
  animation: planby-toast-in 0.22s ease-out;
}
.planby-toast.show { display: block; }
@keyframes planby-toast-in {
  from { opacity: 0; transform: translateY(-8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Topbar right cluster ───────────────────────────────── */
.planby-topbar-right {
  display: flex;
  align-items: center;
  gap: var(--s2);
}

/* ── Day-strip number + label stack ─────────────────────── */
.planby-daybtn .d-name {
  display: block;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--color-text-muted);
  line-height: 1.1;
}
.planby-daybtn .d-num {
  display: block;
  font-size: 16px;
  font-weight: 700;
  color: inherit;
  line-height: 1.15;
  margin-top: 2px;
  letter-spacing: -0.01em;
}
.planby-daybtn[aria-current="true"] .d-name { color: var(--gold-500); }

/* ── Modal step anatomy (create + edit) ─────────────────── */
.planby-step-eyebrow {
  margin-bottom: 14px;
  color: var(--navy-900);
  font-size: 13px;
  font-weight: 750;
}
.planby-step-divider {
  height: 1px;
  background: var(--color-border, #d8e0e8);
  margin: 22px 0 18px;
}
.planby-help-note {
  font-size: 12px;
  color: var(--color-text-muted);
  margin-top: var(--s2);
  line-height: 1.5;
}
.planby-help-note a { color: var(--arctic-500); font-weight: 600; }

/* ============================================================
   SCHEDULE GRID — custom timeline (replaces Planby EPG)
   Layout: a single CSS grid with 2 columns (rail | tracks)
   and 2 rows (hours header | body). Rail is sticky on
   horizontal scroll; hours header is sticky on vertical
   scroll. Shift cards are absolutely positioned within
   each van's track using minute math.
   ============================================================ */
.schedule-shell {
  position: relative;
  flex: 1;
  min-height: 480px;
  max-height: calc(100vh - 280px);
  background: var(--cream-50);
  overflow: auto;
  -webkit-overflow-scrolling: touch;
}
.schedule-grid {
  display: grid;
  grid-template-columns: var(--rail-w) var(--tracks-w);
  grid-template-rows: 56px auto;
  position: relative;
  min-width: max-content;
}
.schedule-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--s10) var(--s5);
  color: var(--color-text-muted);
  font-size: 13px;
  text-align: center;
  min-height: 240px;
}
.schedule-empty.error { color: var(--red-500); }
.schedule-empty a {
  margin-left: 4px;
  color: var(--arctic-500);
  font-weight: 600;
}

/* Top-left corner: van count + total shifts */
.schedule-corner {
  grid-row: 1; grid-column: 1;
  position: sticky; top: 0; left: 0; z-index: 6;
  background: var(--navy-900);
  color: var(--white);
  border-right: 1px solid var(--navy-700);
  border-bottom: 2px solid var(--gold-500);
  padding: 8px var(--s4);
  display: flex;
  flex-direction: column;
  justify-content: center;
  width: var(--rail-w);
}
.schedule-corner-eyebrow {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--gold-400);
}
.schedule-corner-count {
  font-size: 12px;
  font-weight: 600;
  color: rgba(255,255,255,0.78);
  margin-top: 3px;
}
.schedule-corner-count .unassigned-count {
  color: var(--amber-500);
  font-weight: 700;
}

/* Hours header (top strip, sticky to top of scroll shell) */
.schedule-hours {
  grid-row: 1; grid-column: 2;
  position: sticky; top: 0; z-index: 5;
  display: flex;
  height: 56px;
  background: var(--navy-900);
  border-bottom: 2px solid var(--gold-500);
}
.schedule-hour {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  padding-left: var(--s3);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.72);
  border-left: 1px solid rgba(255,255,255,0.08);
  position: relative;
}
.schedule-hour:first-child { border-left: none; }
.schedule-hour::after {
  content: "";
  position: absolute;
  bottom: 0; left: 0;
  width: 1px; height: 6px;
  background: rgba(255,255,255,0.18);
}

/* Vehicle rail (left column, sticky on horizontal scroll) */
.schedule-rail {
  grid-row: 2; grid-column: 1;
  position: sticky; left: 0; z-index: 4;
  background: var(--white);
  border-right: 1px solid var(--color-border);
  width: var(--rail-w);
}
.van-row {
  display: grid;
  grid-template-columns: 44px 1fr auto;
  align-items: center;
  gap: var(--s3);
  height: var(--row-h);
  padding: 0 var(--s4);
  border-bottom: 1px solid var(--cream-200);
  background: var(--white);
}
.van-row:nth-child(even) { background: var(--cream-50); }
.van-row:hover { background: var(--cream-100); }
.van-tile {
  width: 44px; height: 44px;
  border-radius: var(--r-md);
  background: linear-gradient(135deg, var(--navy-700) 0%, var(--navy-900) 100%);
  color: var(--white);
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 800; letter-spacing: 0.08em;
  font-family: var(--font-mono);
  box-shadow: 0 2px 8px rgba(13,27,42,0.18), inset 0 0 0 1px rgba(255,255,255,0.06);
  position: relative;
}
.van-tile::after {
  content: "";
  position: absolute;
  left: 8px; right: 8px; bottom: 4px;
  height: 1px;
  background: var(--gold-400);
  opacity: 0.55;
}
.van-info { min-width: 0; }
.van-plate {
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 700;
  color: var(--navy-900);
  letter-spacing: 0.04em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.van-name {
  font-size: 12px;
  color: var(--color-text-muted);
  letter-spacing: 0.02em;
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.van-status-dot {
  width: 9px; height: 9px;
  border-radius: 50%;
  flex-shrink: 0;
  box-shadow: 0 0 0 2px var(--white);
}

/* Tracks pane (right column) — single scroll context is .schedule-shell */
.schedule-tracks {
  grid-row: 2; grid-column: 2;
  position: relative;
  display: flex;
  flex-direction: column;
  background: linear-gradient(var(--cream-50), var(--white));
}
.schedule-track {
  position: relative;
  height: var(--row-h);
  border-bottom: 1px solid var(--cream-200);
  cursor: crosshair;
}
.schedule-track:nth-child(even) { background: rgba(248,243,232,0.4); }
.schedule-track:hover { background: rgba(248,243,232,0.7); }
.schedule-track-grid {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background-image:
    /* hour lines */
    linear-gradient(to right, rgba(13,27,42,0.06) 1px, transparent 1px),
    /* half-hour ticks */
    linear-gradient(to right, rgba(13,27,42,0.025) 1px, transparent 1px);
  background-size: var(--hour-w) 100%, calc(var(--hour-w) / 2) 100%;
  background-position: 0 0, 0 0;
}
.schedule-track-add {
  position: absolute;
  top: 50%;
  right: 12px;
  transform: translateY(-50%);
  width: 28px; height: 28px;
  border-radius: var(--r-full);
  border: 1.5px dashed var(--cream-300);
  background: var(--white);
  color: var(--color-text-muted);
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s, background 0.15s, color 0.15s, border-color 0.15s;
  z-index: 2;
}
.schedule-track:hover .schedule-track-add {
  opacity: 1;
}
.schedule-track-add:hover {
  background: var(--navy-900);
  color: var(--white);
  border-color: var(--navy-900);
  border-style: solid;
}

/* Now-line (vertical red line at current time, child of .schedule-tracks) */
.schedule-now-line {
  position: absolute;
  top: 0; bottom: 0;
  width: 2px;
  background: var(--red-500);
  pointer-events: none;
  z-index: 3;
  box-shadow: 0 0 12px rgba(214,64,69,0.4);
}
.schedule-now-line::before {
  content: "";
  position: absolute;
  top: -6px;
  left: -5px;
  width: 12px; height: 12px;
  background: var(--red-500);
  border-radius: 50%;
  box-shadow: 0 0 0 3px var(--white), 0 2px 6px rgba(214,64,69,0.4);
}

/* Now-marker pip in the hours header */
.schedule-hour-now {
  position: absolute;
  top: 50%;
  transform: translate(-50%, -50%);
  padding: 3px 8px;
  background: var(--red-500);
  color: var(--white);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  border-radius: var(--r-full);
  white-space: nowrap;
  pointer-events: none;
  box-shadow: 0 2px 6px rgba(214,64,69,0.4);
  z-index: 6;
}

/* ── Shift card ─────────────────────────────────────────── */
.shift-card {
  position: absolute;
  top: 8px;
  bottom: 8px;
  min-width: 60px;
  padding: 8px 12px;
  border-radius: var(--r-md);
  background: linear-gradient(135deg, var(--purple-500) 0%, #5a3fa0 100%);
  color: var(--white);
  cursor: pointer;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 2px;
  box-shadow: 0 2px 6px rgba(124,92,191,0.3), 0 0 0 1px rgba(255,255,255,0.08) inset;
  transition: transform 0.12s, box-shadow 0.15s, filter 0.15s;
  z-index: 1;
}
.shift-card:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(124,92,191,0.4), 0 0 0 1px rgba(255,255,255,0.16) inset;
  z-index: 2;
}
.shift-card-time {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: rgba(255,255,255,0.85);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.shift-card-driver {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: -0.005em;
  color: var(--white);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.shift-card-att {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  font-weight: 500;
  color: rgba(255,255,255,0.78);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.shift-card-att-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px; height: 16px;
  border-radius: 50%;
  background: rgba(255,255,255,0.18);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0;
  flex-shrink: 0;
}
.shift-card-rev {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  color: rgba(255,255,255,0.7);
  letter-spacing: 0.04em;
  margin-top: 2px;
}
.shift-card-handle {
  position: absolute;
  right: 4px; top: 50%;
  transform: translateY(-50%);
  width: 3px; height: 32px;
  background: rgba(255,255,255,0.25);
  border-radius: 2px;
  pointer-events: none;
}

/* Shift status variants */
.shift-card.status-active {
  background: linear-gradient(135deg, var(--purple-500) 0%, #5a3fa0 100%);
  box-shadow: 0 2px 6px rgba(124,92,191,0.3), inset 0 0 0 1px rgba(255,255,255,0.08);
}

/* Unassigned shift = dashed cream-tone w/ navy text + gold CTA */
.shift-card.is-unassigned {
  background: var(--white);
  color: var(--navy-900);
  border: 2px dashed var(--cream-300);
  box-shadow: 0 1px 3px rgba(13,27,42,0.05);
  filter: none;
}
.shift-card.is-unassigned:hover {
  border-color: var(--gold-500);
  background: var(--cream-50);
  box-shadow: 0 4px 12px rgba(212,160,23,0.18);
}
.shift-card.is-unassigned .shift-card-time { color: var(--color-text-muted); }
.shift-card.is-unassigned .shift-card-driver,
.shift-card.is-unassigned .shift-card-unassigned-cta {
  color: var(--gold-600);
  font-weight: 700;
  letter-spacing: 0.02em;
}
.shift-card.is-unassigned .shift-card-att,
.shift-card.is-unassigned .shift-card-rev { color: var(--color-text-muted); }
.shift-card.is-unassigned .shift-card-handle { background: var(--cream-300); }

/* ── Mobile / responsive ────────────────────────────────── */
@media (max-width: 900px) {
  .planby-topbar { padding: var(--s3); }
  .planby-topbar-right { flex-wrap: wrap; }
  .planby-topbar input[type="search"] { width: 100%; }
  .planby-controls { flex-direction: column; align-items: stretch; }
  .planby-daystrip { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .planby-row { grid-template-columns: 1fr; }

  .schedule-grid { grid-template-columns: 180px 1fr; }
  .van-row { grid-template-columns: 36px 1fr auto; padding: 0 var(--s3); }
  .van-tile { width: 36px; height: 36px; font-size: 12px; }
}

/* Old .btn.light = ghost */
.btn.light {
  background: transparent;
  color: var(--color-text-secondary);
  border: 1px solid var(--slate-200);
}
.btn.light:hover { background: var(--slate-50); color: var(--navy-900); }

/* Vehicle create/edit form */
.vehicle-form-page {
  width: 100%;
  margin: 0;
}
.vehicle-form-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--s4);
  margin-bottom: var(--s5);
}
.vehicle-form-header h1 {
  font-size: 26px;
  line-height: 1.2;
  letter-spacing: 0;
}
.vehicle-form-kicker {
  color: var(--gold-500);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
  margin-bottom: var(--s1);
}
.vehicle-form-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-sm);
  padding: var(--s5);
}
.vehicle-form-section {
  padding: var(--s5) 0;
  border-top: 1px solid var(--color-border);
}
.vehicle-form-section:first-child { padding-top: 0; border-top: 0; }
.vehicle-form-section h2 {
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0;
  margin-bottom: var(--s4);
}
.vehicle-form-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--s4);
}
.vehicle-form-grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.vehicle-form-card .field {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: var(--s2);
}
.vehicle-form-card label {
  color: var(--navy-800);
  font-size: 12px;
  font-weight: 700;
}
.vehicle-form-card input,
.vehicle-form-card select,
.vehicle-form-card textarea {
  width: 100%;
  min-height: 40px;
  border: 1.5px solid var(--cream-300);
  border-radius: var(--r-sm);
  background: var(--white);
  color: var(--color-text-primary);
  font: inherit;
  padding: 9px 12px;
}
.vehicle-form-card textarea { resize: vertical; min-height: 96px; }
.vehicle-form-card input:focus,
.vehicle-form-card select:focus,
.vehicle-form-card textarea:focus {
  border-color: var(--arctic-400);
  box-shadow: 0 0 0 3px rgba(75, 163, 195, 0.15);
  outline: none;
}
.vehicle-form-card .required { color: var(--red-500); }
.vehicle-form-card .error-msg {
  display: none;
  color: var(--red-500);
  font-size: 12px;
}
.vehicle-form-card .has-error input {
  border-color: var(--red-500);
  box-shadow: 0 0 0 3px rgba(214, 64, 69, 0.12);
}
.vehicle-form-card .has-error .error-msg { display: block; }
.vehicle-tag-picker {
  border: 1px solid var(--color-border);
  border-radius: var(--r-md);
  background: var(--cream-50);
  padding: var(--s4);
}
.vehicle-tag-select-row,
.vehicle-tag-create-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: var(--s3);
}
.vehicle-tag-create-row {
  margin-top: var(--s4);
  padding-top: var(--s4);
  border-top: 1px solid var(--color-border);
}
.vehicle-tag-chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s2);
  min-height: 32px;
  margin-top: var(--s3);
}
.vehicle-tag-empty {
  color: var(--color-text-muted);
  font-size: 13px;
  align-self: center;
}
.vehicle-tag-chip {
  display: inline-flex;
  align-items: center;
  gap: var(--s2);
  min-height: 30px;
  max-width: 100%;
  border: 1px solid var(--color-border);
  border-left: 4px solid var(--tag-color, var(--arctic-400));
  border-radius: var(--r-full);
  background: var(--white);
  color: var(--navy-900);
  cursor: pointer;
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  padding: 5px 12px;
}
.vehicle-tag-chip::after {
  content: "x";
  color: var(--color-text-muted);
  font-weight: 700;
}
.vehicle-tag-chip:hover {
  border-color: var(--cream-300);
  background: var(--cream-100);
}
.vehicle-form-status {
  min-height: 20px;
  color: var(--color-text-secondary);
  font-size: 13px;
  margin-top: var(--s3);
}
.vehicle-form-status[data-type="error"] { color: var(--red-500); }
.vehicle-form-status[data-type="success"] { color: var(--green-600); }
.vehicle-form-actions {
  display: flex;
  justify-content: flex-end;
  gap: var(--s3);
  margin-top: var(--s4);
}
@media (max-width: 900px) {
  .vehicle-form-grid,
  .vehicle-form-grid-4 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
@media (max-width: 640px) {
  .vehicle-form-header {
    align-items: stretch;
    flex-direction: column;
  }
  .vehicle-form-card { padding: var(--s4); }
  .vehicle-form-grid,
  .vehicle-form-grid-4,
  .vehicle-tag-select-row,
  .vehicle-tag-create-row {
    grid-template-columns: 1fr;
  }
  .vehicle-form-actions {
    flex-direction: column-reverse;
  }
  .vehicle-form-actions .btn { justify-content: center; }
}

/* ============================================================
   POLARIS — unified application finish
   Solid white/silver surfaces, arctic-blue focus, Polaris navy.
   This final layer intentionally normalizes legacy page styles.
   ============================================================ */
:root {
  --navy-900: #102b44;
  --cream-50: #f4f5f7;
  --cream-100: #eef0f2;
  --cream-200: #d8dde3;
  --cream-300: #bcc4cd;
  --gold-600: #1f6f9b;
  --gold-500: #4098c7;
  --gold-400: #73bee4;
  --gold-200: #cceafb;
  --gold-100: #e9f7ff;
  --arctic-500: #227fac;
  --arctic-400: #43a4d1;
  --arctic-300: #7cc7e8;
  --arctic-100: #e4f5fd;
  --color-bg: var(--cream-50);
  --color-bg-section: var(--cream-100);
  --color-surface: var(--white);
  --color-border: var(--cream-200);
  --color-border-dark: var(--cream-300);
  --color-text-primary: #17202a;
  --color-text-secondary: #536170;
  --color-text-muted: #7b8794;
  --color-accent: var(--arctic-400);
  --font-sans: 'Manrope', system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: var(--font-sans);
  --r-sm: 9px;
  --r-md: 13px;
  --r-lg: 18px;
  --r-xl: 24px;
  --shadow-sm: 0 1px 2px rgba(11, 35, 55, 0.04), 0 8px 24px rgba(26, 65, 96, 0.05);
  --shadow-md: 0 18px 48px rgba(24, 59, 87, 0.10), inset 0 1px 0 rgba(255,255,255,.75);
  --shadow-lg: 0 28px 80px rgba(10, 32, 50, 0.17), inset 0 1px 0 rgba(255,255,255,.8);
  --shadow-navy: 0 12px 28px rgba(13, 38, 61, 0.22);
}

html { background: var(--color-bg); }
body {
  background: var(--color-bg);
  letter-spacing: -0.006em;
}

::selection { color: var(--navy-950); background: rgba(114, 198, 232, .42); }
:focus-visible { outline-color: var(--arctic-400); }

.app-shell { min-height: 100vh; background: transparent; }
.app-sidebar {
  background: var(--company-sidebar-bg, var(--navy-900));
  border-right: 1px solid rgba(255,255,255,.08) !important;
  box-shadow: 12px 0 40px rgba(7, 29, 47, .11) !important;
}
.sidebar-top { border-bottom: 1px solid rgba(255,255,255,.07); }
.sidebar-company {
  color: rgba(219, 238, 250, .68);
  font-weight: 600;
  letter-spacing: .05em;
}
.sidebar-company-tools { display:grid; grid-template-columns:minmax(0,1fr) 34px; align-items:center; gap:9px; padding:12px 14px 5px; }
.user-avatar img { width:100%; height:100%; object-fit:cover; display:block; border-radius:inherit; }
.sidebar-company { overflow:hidden; text-overflow:ellipsis; white-space:nowrap; font-size:11px; text-transform:uppercase; }
.sidebar-notifications { width:32px; height:32px; position:relative; display:grid; place-items:center; border-radius:9px; color:rgba(223,239,249,.72); text-decoration:none; }
.sidebar-notifications:hover { color:#fff; background:rgba(255,255,255,.08); }
.sidebar-notifications svg { width:17px; height:17px; color:var(--arctic-400); }
.sidebar-notification-label { display:none; }
.sidebar-notification-badge { position:absolute; top:3px; right:3px; min-width:16px; height:16px; padding:0 3px; border-radius:99px; display:grid; place-items:center; background:var(--red-500); color:var(--white); font-size:11px; line-height:1; font-weight:800; }
.sidebar-nav { scrollbar-color: rgba(255,255,255,.16) transparent; }
.sidebar-nav-section { color: rgba(181, 216, 237, .45); letter-spacing: .14em; }
.sidebar-link {
  min-height: 42px;
  margin: 2px 9px;
  padding: 9px 12px;
  border: 1px solid transparent;
  border-radius: 12px;
  color: rgba(223, 239, 249, .73);
  transition: color .18s ease, background .18s ease, border-color .18s ease, transform .18s ease;
}
.sidebar-link svg { opacity: .76; }
.sidebar-link:hover {
  color: #fff;
  background: rgba(255,255,255,.075);
  border-color: rgba(255,255,255,.08);
  transform: translateX(2px);
}
.sidebar-link.active {
  color: #fff;
  background: var(--company-sidebar-active);
  border-color: rgba(153, 218, 246, .20);
  box-shadow: inset 3px 0 0 #79c9eb, 0 10px 24px rgba(1, 15, 27, .16);
}
.sidebar-link.active svg { color: #9bddf6; opacity: 1; }
.sidebar-footer {
  background: rgba(255,255,255,.055);
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 15px;
  margin: 10px;
  backdrop-filter: blur(18px) saturate(135%);
  -webkit-backdrop-filter: blur(18px) saturate(135%);
}
.user-avatar {
  background: var(--arctic-300);
  color: #082137;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.65), 0 6px 18px rgba(0,0,0,.22);
}

.app-main { background: transparent; }
.app-topbar {
  min-height: 62px;
  background: var(--color-surface);
  border-bottom: 1px solid rgba(127, 160, 184, .20);
  box-shadow: 0 8px 34px rgba(31, 68, 95, .045);
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}
.page-breadcrumb { color: var(--color-text-secondary); font-weight: 600; }
.breadcrumb-current { color: var(--navy-800); }
.app-content { padding: clamp(18px, 2.25vw, 34px); }

.page-header { margin-bottom: 24px; }
.page-title, .t-page-title {
  color: var(--navy-900);
  font-size: clamp(25px, 2.3vw, 34px);
  font-weight: 800;
  letter-spacing: -.04em;
}
.page-subtitle { max-width: 720px; color: var(--color-text-secondary); }
.page-eyebrow, .t-label, .card-label, .vehicle-form-kicker {
  color: var(--arctic-500);
  font-weight: 800;
  letter-spacing: .12em;
}

.card,
.panel,
.stat-card,
.metric-card,
.vehicle-form-card,
.settings-card,
.builder-step,
.reports-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  box-shadow: var(--shadow-md), 0 0 0 1px rgba(103, 138, 165, .12);
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}
.card::before, .stat-card::before, .metric-card::before {
  border-radius: inherit;
}
.card-header, .card-footer {
  background: rgba(242, 248, 252, .48);
  border-color: rgba(111, 147, 174, .18);
}
.card-title { color: var(--navy-900); font-weight: 750; }

.btn {
  min-height: 39px;
  border-radius: 11px;
  font-weight: 700;
  letter-spacing: -.01em;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.72), 0 6px 18px rgba(26, 66, 96, .07);
}
.btn-primary, .btn.primary {
  background: var(--navy-900);
  border-color: rgba(7, 31, 50, .9);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.15), 0 12px 26px rgba(10, 38, 61, .23);
}
.btn-primary:hover, .btn.primary:hover {
  background: var(--navy-700);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.17), 0 14px 30px rgba(10, 38, 61, .28);
}
.btn-secondary, .btn.secondary, .btn-ghost, .btn.light {
  background: rgba(255,255,255,.56);
  border: 1px solid rgba(107, 142, 168, .27);
  color: var(--navy-800);
}
.btn-secondary:hover, .btn.secondary:hover, .btn-ghost:hover, .btn.light:hover {
  background: rgba(235, 247, 253, .9);
  border-color: rgba(69, 153, 195, .42);
}
.btn-gold {
  color: #082337;
  background: var(--arctic-300);
  border-color: #63bde4;
  box-shadow: 0 10px 24px rgba(57, 145, 188, .2);
}

input:not([type="checkbox"]):not([type="radio"]), select, textarea,
.vehicle-form-card input, .vehicle-form-card select, .vehicle-form-card textarea,
.prompt-input {
  border: 1px solid rgba(111, 145, 170, .30);
  border-radius: 11px;
  background: rgba(255,255,255,.69);
  color: var(--navy-900);
  box-shadow: inset 0 1px 2px rgba(25, 56, 79, .035), 0 1px 0 rgba(255,255,255,.8);
  transition: border-color .16s ease, box-shadow .16s ease, background .16s ease;
}
input:not([type="checkbox"]):not([type="radio"]):focus, select:focus, textarea:focus,
.prompt-input:focus {
  background: rgba(255,255,255,.94);
  border-color: var(--arctic-400);
  box-shadow: 0 0 0 4px rgba(67, 164, 209, .14), inset 0 1px 2px rgba(25, 56, 79, .025);
  outline: none;
}
label, .field-label { color: var(--navy-800); font-weight: 700; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.form-card { width: 100%; min-width: 0; }
.span-2 { grid-column: 1 / -1; }

.table-wrap, .table-scroll {
  border: 1px solid rgba(115, 148, 173, .20);
  border-radius: 14px;
  background: rgba(255,255,255,.42);
}
table { border-collapse: separate; border-spacing: 0; }
thead th {
  background: rgba(224, 238, 247, .72);
  color: #365169;
  border-color: rgba(105, 140, 166, .18);
  font-size: 11px;
  letter-spacing: .10em;
}
tbody td { border-color: rgba(119, 151, 176, .14); }
tbody tr { transition: background .15s ease; }
tbody tr:hover { background: rgba(226, 244, 252, .42); }

.badge { border: 1px solid rgba(255,255,255,.65); box-shadow: inset 0 1px 0 rgba(255,255,255,.5); }
.tabs, .team-tabs, .segmented-control {
  background: rgba(255,255,255,.48);
  border-color: rgba(111, 146, 172, .19);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

.prompt-input { width: 100%; min-height: 46px; padding: 11px 12px; margin: 0; font: inherit; }
.empty-state .empty-icon {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  margin: 0 auto 12px;
  border-radius: 15px;
  color: var(--arctic-500);
  background: var(--arctic-100);
  border: 1px solid rgba(98, 177, 213, .2);
  box-shadow: var(--shadow-sm);
}
.empty-state .empty-icon svg { width: 24px; height: 24px; }

.login-page {
  background: var(--color-bg);
}
.login-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 26px;
  box-shadow: 0 35px 100px rgba(12, 45, 69, .19), inset 0 1px 0 rgba(255,255,255,.9);
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}

.audit-list { display: grid; gap: 10px; }
.audit-item {
  display: grid;
  grid-template-columns: 12px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: start;
  padding: 12px;
  border: 1px solid var(--color-border);
  border-radius: 12px;
  background: rgba(255,255,255,.54);
}
.audit-dot { width: 9px; height: 9px; margin-top: 5px; border-radius: 50%; background: var(--arctic-400); box-shadow: 0 0 0 4px rgba(67,164,209,.13); }
.audit-action { color: var(--navy-900); font-weight: 750; }
.audit-meta, .audit-time { color: var(--color-text-muted); font-size: 12px; }

#assignDialog {
  color: var(--navy-900);
  background: var(--color-surface);
  border-color: rgba(255,255,255,.92) !important;
  border-radius: 20px !important;
  box-shadow: 0 30px 90px rgba(5, 29, 47, .30), 0 0 0 1px rgba(103, 145, 176, .18);
  backdrop-filter: blur(30px) saturate(150%);
  -webkit-backdrop-filter: blur(30px) saturate(150%);
}
#assignDialog::backdrop {
  background: rgba(5, 19, 31, .48);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
#assignDialog #assignConfirm:disabled { opacity: .48; cursor: not-allowed; box-shadow: none; }

@media (max-width: 780px) {
  .app-content { padding: 16px; }
  .form-grid { grid-template-columns: 1fr; }
  .span-2 { grid-column: auto; }
  .page-title, .t-page-title { font-size: 25px; }
  .card, .vehicle-form-card { border-radius: 16px; }
}

/* ── Polaris authentication experience ─────────────────── */
.login-page { padding:28px; background:var(--color-bg); }
.login-shell { position:relative; z-index:1; width:min(1060px,100%); min-height:650px; display:grid; grid-template-columns:minmax(0,1.2fr) minmax(380px,.8fr); overflow:hidden; border:1px solid rgba(255,255,255,.92); border-radius:30px; background:var(--color-surface); box-shadow:0 38px 110px rgba(8,37,57,.22); }
.login-brand-panel { position:relative; display:flex; flex-direction:column; justify-content:space-between; padding:48px; overflow:hidden; color:#fff; background:var(--navy-900); }
.login-brand-panel::after { content:''; position:absolute; width:430px; height:430px; right:-170px; bottom:-170px; border:1px solid rgba(255,255,255,.11); border-radius:50%; box-shadow:0 0 0 55px rgba(255,255,255,.025),0 0 0 110px rgba(255,255,255,.02); }
.login-brand-logo { position:relative; z-index:1; width:185px; max-height:64px; object-fit:contain; object-position:left center; filter:brightness(0) invert(1); }
.login-brand-copy { position:relative; z-index:1; max-width:520px; }
.login-eyebrow { color:var(--gold-400); font-size:12px; font-weight:800; letter-spacing:.17em; }
.login-brand-copy h1 { max-width:480px; margin:16px 0 18px; color:#fff; font-size:clamp(38px,5vw,58px); line-height:1.04; letter-spacing:-.045em; }
.login-brand-copy p { max-width:480px; margin:0; color:rgba(255,255,255,.68); font-size:15px; line-height:1.75; }
.login-brand-foot { position:relative; z-index:1; color:rgba(255,255,255,.42); font-size:12px; letter-spacing:.04em; }
.login-shell .login-card { align-self:center; width:auto; max-width:none; margin:30px; padding:46px 42px; border:1px solid rgba(255,255,255,.96); border-radius:24px; background:var(--color-surface); box-shadow:0 18px 55px rgba(15,55,79,.12); }
.login-card-logo { width:152px; max-height:58px; object-fit:contain; }
.login-shell .login-logo-area { text-align:left; margin-bottom:28px; }
.login-shell .login-tagline { margin-top:22px; color:var(--navy-900); font-size:24px; font-weight:800; letter-spacing:-.025em; text-transform:none; }
.login-card-intro { margin:5px 0 0; color:var(--slate-400); font-size:12px; }
.login-shell .field { margin-bottom:17px; }
.login-shell .field input { min-height:46px; background:rgba(255,255,255,.9); }
.login-submit { width:100%; justify-content:space-between; margin-top:8px; padding:12px 16px; font-size:13px; }
.login-create-account { display:flex; flex-wrap:wrap; justify-content:center; gap:7px; color:var(--slate-400); font-size:12px; }
.login-create-account a { color:var(--navy-800); font-weight:700; }
.auth-field-grid { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:12px; }
.auth-field-grid input { width:100%; min-width:0; }
@media (max-width:850px) { .login-shell { min-height:auto; grid-template-columns:1fr; max-width:480px; }.login-brand-panel { display:none; }.login-shell .login-card { margin:0; padding:42px 34px; border-radius:28px; } }
@media (max-width:520px) { .login-page { padding:14px; }.login-shell .login-card { padding:36px 24px; }.login-shell { border-radius:24px; } }
@media (max-width:380px) { .auth-field-grid { grid-template-columns:1fr; gap:0; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
