:root {
  --brand: #FF3B1F;
  --brand-dark: #C91F0B;
  --brand-light: #FFE8E3;
  --navy: #FAFAF8;
  --bg: #F5F5F3;
  --surface: #FFFFFF;
  --surface-quiet: #FAFAF8;
  --surface-pressed: #F0EFED;
  --border: #E2DFE0;
  --border-strong: #C4BEC0;
  --text: #0F0E0D;
  --text-secondary: #6B6763;
  --muted: #7A7470;
  --green: #1B7D47;
  --amber: #B37C1F;
  --red: #D83C2D;
  --blue: #1E5A8E;
  --purple: #6C557C;
  --shadow: 0 6px 18px rgba(15, 14, 13, .07);
  --shadow-md: 0 12px 30px rgba(15, 14, 13, .10);
  --shadow-lg: 0 22px 52px rgba(15, 14, 13, .13);
  --radius-card: 8px;
  --radius-input: 8px;
  --radius-badge: 6px;
  --sidebar: 244px;
  --sidebar-closed: 68px;
  --topbar: 56px;
  --font-display: "Outfit", "Poppins", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-ui: "Source Sans 3", "Inter", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-mono: "Fira Code", "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --space-page: clamp(14px, 3vw, 24px);
  --space-card: clamp(10px, 1.7vw, 14px);
  --shadow-hover: 0 12px 32px rgba(15, 14, 13, .16);
  --sticky-shadow: 0 8px 24px rgba(15, 14, 13, .10);
  --sticky-shadow-deep: 0 16px 40px rgba(15, 14, 13, .18);
  --sticky-table-shadow: 0 6px 16px rgba(15, 14, 13, .12);
  --transition-fast: 150ms cubic-bezier(.4, 0, .2, 1);
  --transition-base: 200ms cubic-bezier(.4, 0, .2, 1);
  --transition-slow: 300ms cubic-bezier(.4, 0, .2, 1);
}

* { box-sizing: border-box; }
html {
  height: 100%;
  background: var(--bg);
  scroll-padding-top: calc(var(--topbar) + 16px);
  scroll-behavior: smooth;
}
body {
  margin: 0;
  height: 100%;
  background:
    radial-gradient(circle at top right, rgba(30, 90, 142, .08), transparent 34rem),
    linear-gradient(135deg, var(--bg) 0%, #F8F6F4 100%);
  color: var(--text);
  font: 13px/1.45 var(--font-ui);
  letter-spacing: 0;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
:target,
[id] {
  scroll-margin-top: calc(var(--topbar) + 16px);
}
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
.mono,
.num,
td.money,
th.money,
.value,
.metric b,
.kpi .value,
.rank-num,
time {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}
.muted { color: var(--muted); }
.hide { display: none !important; }

.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar) 1fr;
  min-height: 100%;
}
.app-shell.sidebar-collapsed { grid-template-columns: var(--sidebar-closed) 1fr; }
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: auto;
  background: linear-gradient(180deg, var(--navy) 0%, #F7F5F2 100%);
  color: var(--text);
  z-index: 30;
  border-right: 1px solid var(--border);
  box-shadow: inset -1px 0 0 0 rgba(15, 14, 13, .05);
}
.brand-row {
  height: 56px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 16px;
  border-bottom: 1px solid var(--border);
}
.brand-mark {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  color: #fff;
  background: var(--brand);
  font-weight: 800;
}
.brand-name { font-weight: 800; color: var(--text); line-height: 1.1; }
.brand-sub { display: block; font-size: 10px; color: var(--muted); font-weight: 500; }
.sidebar-collapsed .brand-name,
.sidebar-collapsed .nav-section-title,
.sidebar-collapsed .nav-label { display: none; }
.collapse-btn {
  margin-left: auto;
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 6px;
  color: var(--text);
  background: var(--surface-pressed);
}
.nav-section-title {
  padding: 18px 18px 8px;
  color: var(--muted);
  text-transform: uppercase;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .06em;
}
.nav-link {
  position: relative;
  min-height: 38px;
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 3px 10px;
  padding: 10px 13px;
  border-radius: 8px;
  color: var(--text-secondary);
  transition: all var(--transition-fast);
  font-weight: 500;
  outline: 2px solid transparent;
  outline-offset: -2px;
}
.nav-link:hover {
  background: rgba(255, 59, 31, .08);
  color: var(--text);
  transform: translateX(2px);
}
.nav-link:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 0px;
}
.nav-link.active {
  background: rgba(255, 59, 31, .12);
  color: var(--text);
  font-weight: 600;
}
.nav-link.active::before {
  content: "";
  position: absolute;
  left: -10px;
  top: 50%;
  transform: translateY(-50%);
  width: 5px;
  height: 24px;
  border-radius: 0 4px 4px 0;
  background: var(--brand);
  box-shadow: 2px 0 8px rgba(255, 59, 31, .24);
}
.nav-link i { width: 19px; height: 19px; flex: 0 0 19px; }
.main-area { min-width: 0; }
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  height: var(--topbar);
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 clamp(14px, 2.2vw, 24px);
  border-bottom: 1px solid rgba(226, 223, 224, .5);
  background: rgba(255, 255, 255, .88);
  backdrop-filter: blur(12px) saturate(130%);
  min-width: 0;
  overflow: visible;
  contain: layout style;
  isolation: isolate;
  box-shadow: 0 0 0 rgba(15, 14, 13, 0);
  transition: all var(--transition-base);
}
.topbar.scrolled {
  border-bottom-color: var(--border);
  background: rgba(255, 255, 255, .96);
  box-shadow: var(--sticky-shadow-deep);
}
.mobile-menu {
  display: none;
  width: 44px;
  height: 44px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
}
.global-search {
  position: relative;
  flex: 1;
  max-width: 520px;
  min-width: 220px;
}
.global-search i {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  width: 17px;
}
.global-search input {
  width: 100%;
  height: 34px;
  padding: 0 14px 0 40px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-input);
  background: linear-gradient(135deg, rgba(250, 250, 248, .6), rgba(245, 245, 243, .8));
  outline: none;
  transition: all var(--transition-fast);
}
.global-search input:focus,
.field:focus, select:focus, textarea:focus {
  border-color: var(--brand);
  background: rgba(255, 255, 255, .95);
  box-shadow: 0 0 0 3px rgba(255, 59, 31, .15);
}
.top-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.top-actions select,
.field,
textarea {
  height: 38px;
  border: 1px solid var(--border);
  border-radius: var(--radius-input);
  background: var(--surface);
  color: var(--text);
  padding: 0 10px;
}
textarea { height: auto; min-height: 92px; padding: 10px; resize: vertical; }
.field,
select,
textarea,
input {
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast), background-color var(--transition-fast), outline-color var(--transition-fast);
}
.field:focus,
select:focus,
textarea:focus,
input:focus {
  background-color: #FFF8F6;
  outline: 2px solid rgba(255,59,31,.22);
  outline-offset: 2px;
}
.field:focus-visible,
select:focus-visible,
textarea:focus-visible,
input:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
  background-color: #FFF8F6;
}
.form-row.enhanced-field {
  position: relative;
}
.form-row.enhanced-field label {
  width: fit-content;
  transform-origin: left top;
  transition: transform 150ms ease-in-out, color 150ms ease-in-out, background-color 150ms ease-in-out;
}
.form-row.enhanced-field:focus-within label,
.form-row.enhanced-field.has-value label {
  color: var(--brand-dark);
  transform: translateY(-2px) scale(.92);
}
.form-row.enhanced-field.is-invalid .field,
.form-row.enhanced-field.is-invalid select,
.form-row.enhanced-field.is-invalid textarea,
.form-row.enhanced-field.is-invalid input {
  border-color: var(--red);
  animation: shake 260ms ease-in-out;
}
.form-row.enhanced-field.is-success .field,
.form-row.enhanced-field.is-success select,
.form-row.enhanced-field.is-success textarea,
.form-row.enhanced-field.is-success input {
  border-color: var(--green);
}
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-4px); }
  50% { transform: translateX(4px); }
  75% { transform: translateX(-2px); }
}
.icon-btn {
  position: relative;
  width: 40px;
  height: 40px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  display: inline-grid;
  place-items: center;
}
.icon-btn:hover, .btn:hover { border-color: var(--border-strong); box-shadow: 0 4px 12px rgba(20,24,23,.06); }
.unread {
  position: absolute;
  top: -5px;
  right: -5px;
  min-width: 18px;
  height: 18px;
  border-radius: 999px;
  padding: 0 5px;
  display: grid;
  place-items: center;
  background: var(--red);
  color: #fff;
  font: 700 10px/1 var(--font-ui);
}
.avatar {
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: #FFE8E3;
  color: #8F1B0B;
  font-weight: 800;
}
.role-chip, .chip, .badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 22px;
  padding: 3px 7px;
  border-radius: var(--radius-badge);
  border: 1px solid var(--border);
  background: var(--surface-quiet);
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}
.breadcrumbs {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 var(--space-page);
  border-bottom: 1px solid var(--border);
  color: var(--muted);
  font-size: .72rem;
  overflow-x: auto;
  white-space: nowrap;
}
.page {
  padding: clamp(18px, 3.6vw, 28px) var(--space-page);
  max-width: 1680px;
  margin: 0 auto;
}
.page.full-map-page {
  max-width: none;
  padding: 0;
}
.page-title-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
  min-width: 0;
  flex-wrap: wrap;
}
.page-title-row > div:first-child { min-width: min(100%, 420px); }
.page-title-row .filter-row { justify-content: flex-end; }
h1, h2, h3, p { margin-top: 0; }
h1 {
  font-size: 1.55rem;
  line-height: 1.15;
  margin-bottom: 6px;
  font-weight: 800;
  font-family: var(--font-display);
  letter-spacing: 0;
}
.page-title-muted {
  color: var(--text-secondary);
  font-size: .40em;
  font-weight: 500;
  vertical-align: middle;
}
h2 {
  font-size: 1.05rem;
  margin-bottom: 14px;
  font-weight: 700;
  font-family: var(--font-display);
  letter-spacing: 0;
}
h3 {
  font-size: .9rem;
  margin-bottom: 10px;
  font-weight: 700;
  letter-spacing: 0;
}
p { color: var(--muted); }
.grid { display: grid; gap: 16px; }
.grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.card {
  background: linear-gradient(135deg, var(--surface) 0%, rgba(250, 250, 248, .5) 100%);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-card);
  padding: var(--space-card);
  box-shadow: 0 1px 3px rgba(15, 14, 13, .04);
  transition: all var(--transition-base);
}
.card.hoverable:hover {
  border-color: rgba(255, 59, 31, .3);
  box-shadow: var(--shadow-hover);
}
.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
  min-width: 0;
  flex-wrap: wrap;
}
.kpi-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: clamp(10px, 2vw, 16px);
  margin-bottom: 16px;
}
.kpi .label {
  color: var(--text-secondary);
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
}
.kpi .value {
  margin-top: 8px;
  font-size: 1.45rem;
  font-weight: 800;
  font-family: var(--font-mono);
  line-height: 1.1;
  letter-spacing: 0;
  overflow-wrap: anywhere;
}
.kpi .sub {
  margin-top: 6px;
  color: var(--text-secondary);
  font-size: 11px;
  font-weight: 500;
}
.stat-delta {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  width: fit-content;
  margin-top: 8px;
  padding: 4px 8px;
  border-radius: 999px;
  border: 1.5px solid transparent;
  color: var(--green);
  background: rgba(27, 125, 71, .1);
  font: 700 11px/1.3 var(--font-mono);
  transition: all var(--transition-fast);
}
.stat-delta.negative {
  color: var(--red);
  background: rgba(216, 60, 45, .1);
  border-color: transparent;
}
.stat-delta.neutral {
  color: var(--text-secondary);
  background: rgba(15, 14, 13, .06);
}
.status-dot { width: 12px; height: 12px; border-radius: 50%; display: inline-block; }
.green { color: var(--green); }
.amber { color: var(--amber); }
.red { color: var(--red); }
.status-green { background: #EAF3EE; color: var(--green); border-color: #BFD4C9; }
.status-yellow { background: #F7EFE3; color: var(--amber); border-color: #DDC4A0; }
.status-red { background: #FFE8E3; color: var(--red); border-color: #F2B1A5; }
.status-blue { background: #E8EEF3; color: var(--blue); border-color: #BBCAD7; }
.status-neutral { background: var(--surface-quiet); color: var(--muted); }
.btn {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 12px;
  border-radius: var(--radius-input);
  border: 1.5px solid var(--border);
  background: linear-gradient(135deg, var(--surface), rgba(250, 250, 248, .6));
  color: var(--text);
  font-weight: 600;
  transition: all var(--transition-base);
}
.btn:hover:not(:disabled) {
  border-color: rgba(15, 14, 13, .2);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(15, 14, 13, .12);
}
.btn.primary {
  background: linear-gradient(135deg, var(--brand), #FF5433);
  border-color: var(--brand);
  color: #fff;
  font-weight: 700;
  box-shadow: 0 4px 12px rgba(255, 59, 31, .24);
}
.btn.primary:hover:not(:disabled) {
  box-shadow: 0 8px 20px rgba(255, 59, 31, .32);
  transform: translateY(-2px);
}
.btn.secondary { background: rgba(15, 14, 13, .04); border-color: transparent; }
.btn.ghost {
  border-color: transparent;
  background: transparent;
  color: var(--text-secondary);
  transition: all var(--transition-fast);
}
.btn.ghost:hover:not(:disabled) {
  background: rgba(15, 14, 13, .06);
  color: var(--text);
}
.btn.danger {
  background: linear-gradient(135deg, var(--red), #E44936);
  color: #fff;
  border-color: var(--red);
  font-weight: 700;
}
.btn:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}
.btn:disabled { cursor: not-allowed; opacity: .48; transform: none !important; }
.btn i { width: 16px; height: 16px; }

.table-wrap {
  overflow: auto;
  overscroll-behavior-x: contain;
  overscroll-behavior-y: auto;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-card);
  background: linear-gradient(135deg, var(--surface), rgba(250, 250, 248, .4));
  box-shadow: 0 1px 3px rgba(15, 14, 13, .04);
  contain: paint;
  scrollbar-gutter: stable both-edges;
}
table {
  width: 100%;
  border-collapse: collapse;
  font-size: .78rem;
  font-variant-numeric: tabular-nums;
}
th, td {
  padding: 9px 10px;
  border-bottom: 1px solid rgba(226, 223, 224, .6);
  text-align: left;
  vertical-align: middle;
  white-space: nowrap;
}
th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: linear-gradient(180deg, var(--surface-quiet), rgba(250, 250, 248, .8));
  color: var(--text);
  font-weight: 700;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .05em;
  transition: all var(--transition-fast);
}
.table-wrap.is-scrolled-y th {
  background: rgba(255, 255, 255, .95);
  box-shadow: var(--sticky-table-shadow);
}
tbody tr:nth-child(even) { background: rgba(245, 245, 243, .5); }
tbody tr:hover { background: rgba(255, 59, 31, .04); }
th.sortable { padding: 0; }
th.sortable .sort-btn {
  width: 100%;
  min-height: 37px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 11px;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
  text-transform: inherit;
  letter-spacing: inherit;
  transition: all var(--transition-fast);
  outline: 2px solid transparent;
  outline-offset: -2px;
}
th.sortable .sort-btn:hover {
  background: #FFE8E3;
}
th.sortable .sort-btn:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 0px;
  background: #FFE8E3;
}
.enhanced-sort-btn {
  width: 100%;
  min-height: 37px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 11px;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
  text-transform: inherit;
  letter-spacing: inherit;
}
.sort-indicator {
  width: 0;
  height: 0;
  flex: 0 0 auto;
  opacity: .34;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-top: 5px solid currentColor;
}
.sort-indicator.asc {
  opacity: .95;
  border-top: 0;
  border-bottom: 5px solid currentColor;
}
.sort-indicator.desc { opacity: .95; }
tbody tr { cursor: default; }
tbody tr.clickable { cursor: pointer; }
tbody tr:hover { background: rgba(255, 59, 31, .08); }
td:first-child.sticky, th:first-child.sticky {
  position: sticky;
  left: 0;
  z-index: 3;
  background: inherit;
  transition: box-shadow 160ms ease-in-out, background-color 160ms ease-in-out;
}
.table-wrap.is-scrolled-x td:first-child.sticky,
.table-wrap.is-scrolled-x th:first-child.sticky {
  box-shadow: 8px 0 14px -10px rgba(20, 24, 23, .45);
}
body[data-page="jobs"] .table-wrap {
  max-height: calc(100vh - var(--topbar) - 220px);
  min-height: 320px;
  overflow: auto;
}
.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}
.filter-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; min-width: 0; }
.segmented {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  background: var(--surface);
  max-width: 100%;
}
.segmented button {
  min-height: 32px;
  border: 0;
  border-right: 1px solid var(--border);
  background: transparent;
  padding: 0 9px;
  color: var(--muted);
  font-weight: 700;
  white-space: nowrap;
}
.segmented button:last-child { border-right: 0; }
.segmented button.active { background: #FFE8E3; color: #8F1B0B; }
.map-card { padding: 0; overflow: hidden; }
.map-hero { height: 430px; min-height: 320px; background: #DCE7EC; position: relative; }
.map-full { height: calc(100vh - var(--topbar) - 45px); min-height: 640px; position: relative; background: #DCE7EC; }
.map-small { height: 360px; min-height: 260px; position: relative; background: #DCE7EC; }
.map-fallback {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(90deg, rgba(255,255,255,.5) 1px, transparent 1px),
    linear-gradient(rgba(255,255,255,.5) 1px, transparent 1px),
    #DCE7EC;
  background-size: 42px 42px;
}
.vehicle-marker {
  width: 22px;
  height: 22px;
  border: 3px solid #fff;
  border-radius: 50% 50% 50% 0;
  transform: rotate(-45deg);
  box-shadow: 0 5px 14px rgba(17,24,39,.28);
}
.vehicle-marker span {
  display: block;
  width: 6px;
  height: 6px;
  margin: 5px;
  border-radius: 50%;
  background: #fff;
}
.marker-green { background: var(--green); }
.marker-yellow { background: var(--amber); }
.marker-red { background: var(--red); }
.map-overlay {
  position: absolute;
  z-index: 5;
  top: 14px;
  left: 14px;
  right: 14px;
  display: flex;
  justify-content: space-between;
  pointer-events: none;
}
.map-overlay > * { pointer-events: auto; }
.layer-panel, .floating-panel {
  background: rgba(255,255,255,.96);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px;
  box-shadow: 0 8px 22px rgba(17,24,39,.10);
}
.layer-panel { display: flex; gap: 6px; flex-wrap: wrap; max-width: 540px; }
.layer-panel button { min-height: 30px; border: 1px solid var(--border); border-radius: 6px; background: #fff; padding: 0 8px; font-size: 12px; font-weight: 700; }
.layer-panel button.active { background: #FFE8E3; border-color: rgba(255,59,31,.45); color: #8F1B0B; }
.map-control-panel {
  display: flex;
  gap: 6px;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(255,255,255,.96);
  box-shadow: 0 8px 22px rgba(17,24,39,.10);
}
.map-control-panel .icon-btn {
  width: 34px;
  height: 34px;
}
.map-hud {
  position: absolute;
  z-index: 4;
  left: 14px;
  bottom: 14px;
  max-width: min(520px, calc(100% - 28px));
  padding: 10px 12px;
  border: 1px solid rgba(17,24,39,.12);
  border-radius: 8px;
  background: rgba(255,255,255,.94);
  box-shadow: 0 10px 24px rgba(17,24,39,.12);
  font: 12px var(--font-ui);
  color: var(--text);
  pointer-events: none;
}
.map-hud-title {
  font-weight: 800;
  margin-bottom: 7px;
}
.map-hud-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 7px 12px;
  align-items: center;
  color: var(--muted);
  font-weight: 700;
}
.map-hud-grid span {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
}
.map-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  display: inline-block;
  box-shadow: inset 0 0 0 1px rgba(17,24,39,.08);
}
.map-dot.green { background: var(--green); }
.map-dot.amber { background: var(--amber); }
.map-dot.red { background: var(--red); }
.map-dot.neutral { background: #9CA3AF; }
.map-dot.stale { background: #111827; }
.map-line {
  width: 18px;
  height: 3px;
  border-radius: 999px;
  background: var(--green);
  display: inline-block;
  box-shadow: 0 0 0 2px rgba(32,194,97,.14);
}
.map-line.loading {
  background: #2563EB;
  box-shadow: 0 0 0 2px rgba(37,99,235,.14);
}
.popup-card { font: 12px var(--font-ui); min-width: 230px; }
.popup-card b { display: block; font-size: 13px; margin-bottom: 6px; }
.popup-grid { display: grid; grid-template-columns: 96px 1fr; gap: 4px 8px; }

.timeline {
  display: flex;
  align-items: stretch;
  min-height: 72px;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  background: var(--surface-quiet);
}
.timeline-seg {
  position: relative;
  min-width: 36px;
  padding: 10px 6px;
  color: #fff;
  font-size: 11px;
  font-weight: 800;
  display: flex;
  align-items: flex-end;
}
.seg-moved { background: var(--green); }
.seg-idled { background: var(--amber); }
.seg-off { background: #4B5563; }
.timeline-seg:hover::after {
  content: attr(data-tip);
  position: absolute;
  left: 8px;
  bottom: calc(100% + 8px);
  max-width: 220px;
  padding: 6px 8px;
  border-radius: 6px;
  background: #111827;
  color: #fff;
  white-space: normal;
  animation: fadeIn .15s ease;
  z-index: 10;
}
@keyframes fadeIn { from { opacity: 0; transform: translateY(2px); } to { opacity: 1; transform: translateY(0); } }
.metric-row {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
  margin-top: 10px;
}
.metric {
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px;
  background: var(--surface-quiet);
}
.metric span { display: block; color: var(--muted); font-size: 11px; }
.metric b { font-family: var(--font-mono); font-size: 13px; }

.waypoint-track {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(188px, 1fr);
  gap: 12px;
  overflow-x: auto;
  padding-bottom: 8px;
}
.waypoint-card {
  position: relative;
  min-height: 172px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  padding: 12px;
  cursor: pointer;
}
.waypoint-card::after {
  content: "";
  position: absolute;
  top: 35px;
  left: 100%;
  width: 12px;
  border-top: 2px solid #CBD5E1;
}
.waypoint-card:last-child::after { display: none; }
.waypoint-card.red-flag { border-color: rgba(220,38,38,.45); background: #FFF7F7; }
.waypoint-card h3 { min-height: 34px; margin-bottom: 10px; }
.waypoint-meta { display: grid; gap: 5px; font-size: 12px; color: var(--muted); }
.waypoint-meta b { color: var(--text); font-family: var(--font-mono); }
.rank-list { display: grid; gap: 8px; }
.rank-item {
  display: grid;
  grid-template-columns: 28px 1fr auto;
  gap: 8px;
  align-items: center;
  padding: 9px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-quiet);
}
.rank-num { width: 24px; height: 24px; display: grid; place-items: center; border-radius: 50%; background: #FFE8E3; color: #8F1B0B; font-weight: 800; }

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.form-row label { display: block; color: var(--muted); font-size: 12px; font-weight: 800; margin-bottom: 5px; }
.form-row input, .form-row select { width: 100%; }
.formula {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px;
  background: var(--surface-quiet);
  margin-bottom: 8px;
}
.formula code { display: block; color: #374151; font: 12px/1.5 var(--font-mono); white-space: normal; }
.drawer {
  position: fixed;
  top: var(--topbar);
  right: 0;
  width: min(460px, 100vw);
  height: calc(100vh - var(--topbar));
  z-index: 60;
  transform: translateX(105%);
  transition: transform .18s ease;
  background: var(--surface);
  border-left: 1px solid var(--border);
  box-shadow: var(--shadow);
  overflow: auto;
  padding: 18px;
}
.drawer.open { transform: translateX(0); }
.drawer-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 14px;
  margin-bottom: 12px;
  border-bottom: 1px solid var(--border);
}
.drawer-head p { margin-bottom: 0; }
.drawer-wide { width: 100%; margin-top: 12px; }
.notification-list { display: grid; gap: 8px; }
.notification-row {
  display: grid;
  gap: 5px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-quiet);
}
.notification-row:hover { border-color: rgba(255,59,31,.45); background: #FFF4F1; }
.notification-row span:last-child { color: var(--muted); font-size: 12px; }
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: none;
  place-items: center;
  padding: 20px;
  background: rgba(17,24,39,.42);
}
.modal-backdrop.open { display: grid; }
.modal {
  width: min(620px, 100%);
  max-height: 90vh;
  overflow: auto;
  background: var(--surface);
  border-radius: 8px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}
.modal-head, .modal-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--border); }
.modal-foot { border-bottom: 0; border-top: 1px solid var(--border); justify-content: flex-end; }
.modal-body { padding: 16px; }
.toast-stack {
  position: fixed;
  right: 18px;
  bottom: 18px;
  display: grid;
  gap: 8px;
  z-index: 90;
}
.toast {
  min-width: 260px;
  padding: 12px 14px;
  border-radius: 8px;
  color: #5D1308;
  background: #FFE8E3;
  border: 1px solid rgba(255,59,31,.28);
  box-shadow: var(--shadow);
  font-weight: 700;
}
.skeleton {
  display: grid;
  gap: 16px;
}
.sk-line, .sk-card {
  border-radius: 8px;
  background: linear-gradient(90deg, #EEF1F4 25%, #F8FAFC 37%, #EEF1F4 63%);
  background-size: 400% 100%;
  animation: shimmer 1.1s ease infinite;
}
.sk-line { height: 18px; width: 70%; }
.sk-card { height: 140px; }
.empty-state::after,
.table-wrap:has(tbody:empty)::after {
  content: "";
  display: block;
  height: 72px;
  margin-top: 12px;
  border-radius: 8px;
  background: linear-gradient(90deg, #EEF1F4 25%, #F8FAFC 37%, #EEF1F4 63%);
  background-size: 400% 100%;
  animation: shimmer 1.1s ease infinite;
}
@keyframes shimmer { 0% { background-position: 100% 0; } 100% { background-position: 0 0; } }

.progress { height: 8px; border-radius: 999px; background: #E5E7EB; overflow: hidden; }
.progress span { display: block; height: 100%; background: var(--brand); width: var(--value, 0%); transition: width .25s ease; }
.upload-zone {
  min-height: 180px;
  display: grid;
  place-items: center;
  text-align: center;
  border: 2px dashed #CBD5E1;
  border-radius: 8px;
  background: #FBFCFD;
}
.upload-zone.dragover { border-color: var(--brand); background: #FFF4F1; }
.stop-item {
  display: grid;
  grid-template-columns: 28px 1fr auto;
  gap: 8px;
  align-items: center;
  margin-bottom: 8px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
}
.stop-item.dragging { opacity: .45; }
.selected-route {
  border-color: rgba(255,59,31,.55);
  background: #FFF4F1;
}
.node-list {
  display: grid;
  gap: 6px;
  max-height: 260px;
  overflow: auto;
  margin-bottom: 12px;
}
.directory-list { max-height: 420px; }
.directory-node {
  display: grid;
  grid-template-columns: minmax(140px, 1fr) auto auto auto;
  gap: 8px;
  align-items: center;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  font-size: 12px;
}
.directory-node b,
.directory-node span { overflow-wrap: anywhere; }
.directory-node div span {
  display: block;
  margin-top: 2px;
  color: var(--muted);
}
.directory-node a {
  color: var(--brand);
  font-weight: 800;
}
.directory-node .mono { color: var(--text); }
@media (max-width: 767px) {
  .directory-node { grid-template-columns: 1fr; }
}
.role-debug { display: flex; align-items: center; gap: 6px; }
.tooltip { position: relative; }
.tooltip:hover::after {
  content: attr(data-tip);
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  max-width: 220px;
  padding: 6px 8px;
  border-radius: 6px;
  background: #111827;
  color: #fff;
  font-size: 12px;
  animation: fadeIn .15s ease;
  z-index: 100;
}

.login-page {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(420px, 520px) 1fr;
  background: var(--navy);
}
.login-panel {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 48px;
  background: #fff;
}
.login-visual {
  position: relative;
  display: grid;
  align-content: center;
  padding: 56px;
  color: #fff;
  overflow: hidden;
  background-attachment: fixed;
  background-position: center 0;
}
.login-visual::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(120deg, rgba(255,59,31,.24), transparent 45%),
    repeating-linear-gradient(45deg, rgba(255,255,255,.05) 0 1px, transparent 1px 26px);
}
.login-visual > * { position: relative; z-index: 1; max-width: 680px; }

@media (max-width: 1279px) {
  .grid.cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid.cols-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpi-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 767px) {
  .app-shell, .app-shell.sidebar-collapsed { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed;
    left: 0;
    transform: translateX(-105%);
    transition: transform .18s ease;
    width: min(320px, 86vw);
  }
  .sidebar.open { transform: translateX(0); }
  .mobile-menu { display: inline-grid; place-items: center; }
  .topbar { padding: 0 12px; gap: 8px; }
  .top-actions select, .role-chip, .avatar { display: none; }
  .page { padding: 20px; }
  .grid.cols-2, .grid.cols-3, .grid.cols-4, .kpi-strip, .form-grid { grid-template-columns: 1fr; }
  .metric-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .map-hero { height: 360px; }
  .map-hud {
    left: 10px;
    right: 10px;
    bottom: 10px;
    max-width: none;
  }
  .map-hud-grid {
    gap: 6px 9px;
  }
  .map-hud-grid span {
    white-space: normal;
  }
  th:first-child, td:first-child { position: sticky; left: 0; background: inherit; }
  .login-page { grid-template-columns: 1fr; }
  .login-visual { display: none; }
  .login-panel { min-height: 100vh; padding: 28px; }
  .btn, .icon-btn, .nav-link, .field, .top-actions select { min-height: 44px; }
}

@media (prefers-reduced-motion: no-preference) {
  /* MICRO-ANIMATION: button hover */
  button:not(:disabled),
  .btn:not(:disabled),
  .icon-btn:not(:disabled),
  .collapse-btn:not(:disabled),
  .nav-link,
  .route-option,
  .tracking-truck-card,
  .tracking-photo-card,
  .planner-check,
  .notification-row {
    transition: all 200ms ease-in-out;
  }
  button:not(:disabled):hover,
  .btn:not(:disabled):hover,
  .icon-btn:not(:disabled):hover,
  .collapse-btn:not(:disabled):hover,
  .nav-link:hover,
  .route-option:hover,
  .tracking-truck-card:hover,
  .tracking-photo-card:hover,
  .planner-check:hover,
  .notification-row:hover {
    box-shadow: 0 7px 18px rgba(20,24,23,.10);
    transform: translateY(-2px);
  }
  /* MICRO-ANIMATION: card hover */
  .card,
  .event-item,
  .metric,
  .profile-cell,
  .planner-summary-cell,
  .waypoint-card,
  .source-pill,
  .report-field,
  .api-status-metric {
    transition: all 200ms ease-in-out;
  }
  .card:hover,
  .event-item:hover,
  .metric:hover,
  .profile-cell:hover,
  .planner-summary-cell:hover,
  .waypoint-card:hover,
  .source-pill:hover,
  .report-field:hover,
  .api-status-metric:hover {
    box-shadow: var(--shadow-hover);
  }
  /* PARALLAX: hero section */
  .parallax-section {
    background-attachment: fixed;
    background-position: center 0;
    background-size: cover;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: .001ms !important;
  }
  .parallax-section,
  .login-visual {
    background-attachment: scroll !important;
    background-position: center !important;
  }
}

/* RESPONSIVE: mobile-first grid defaults */
.grid.cols-2,
.grid.cols-3,
.grid.cols-4,
.kpi-strip,
.form-grid {
  grid-template-columns: 1fr;
}

@media (min-width: 768px) {
  .grid.cols-2,
  .grid.cols-3,
  .grid.cols-4,
  .kpi-strip,
  .form-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (min-width: 1280px) {
  .grid.cols-3 {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
  .grid.cols-4,
  .kpi-strip {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

/* UI polish pass: responsive, dense, operational surfaces */
button,
.btn,
.icon-btn,
.collapse-btn,
.nav-link,
.segmented button {
  -webkit-tap-highlight-color: transparent;
}

.btn,
.segmented button,
.chip,
.badge,
.role-chip {
  overflow-wrap: anywhere;
}

.toolbar > *,
.filter-row > *,
.card-head > * {
  min-width: 0;
}

.toolbar .field,
.filter-row .field,
.filter-row select {
  max-width: 100%;
}

.tabs {
  overflow-x: auto;
  scrollbar-width: thin;
}

.tabs.segmented {
  width: fit-content;
}

.map-overlay {
  gap: 10px;
}

.layer-panel {
  max-height: min(220px, calc(100% - 28px));
  overflow: auto;
}

.maplibregl-ctrl-bottom-left,
.maplibregl-ctrl-bottom-right {
  max-width: calc(100% - 24px);
}

.empty-state {
  min-height: 160px;
  display: grid;
  align-content: center;
}

@media (prefers-reduced-motion: no-preference) {
  .card.hoverable:hover,
  .card:hover,
  .metric:hover,
  .profile-cell:hover,
  .planner-summary-cell:hover,
  .source-pill:hover,
  .report-field:hover,
  .api-status-metric:hover {
    transform: none;
  }
}

@media (max-width: 1023px) {
  .topbar {
    gap: 10px;
  }

  .global-search {
    min-width: 160px;
    max-width: none;
  }

  .page-title-row {
    align-items: stretch;
  }

  .page-title-row .filter-row {
    justify-content: flex-start;
    width: 100%;
  }

  .map-hero {
    height: 400px;
  }
}

@media (max-width: 767px) {
  body {
    font-size: 14px;
  }

  .sidebar {
    box-shadow: 20px 0 42px rgba(15, 14, 13, .22);
  }

  .topbar {
    height: var(--topbar);
  }

  .global-search {
    min-width: 0;
  }

  .page {
    padding: 16px;
  }

  h1 {
    font-size: 1.55rem;
  }

  h2 {
    font-size: 1.15rem;
  }

  .kpi .value {
    font-size: 1.7rem;
  }

  .toolbar,
  .filter-row,
  .card-head,
  .page-title-row {
    gap: 10px;
  }

  .toolbar .field,
  .toolbar select,
  .filter-row .field,
  .filter-row select,
  .page-title-row .btn,
  .page-title-row .field {
    flex: 1 1 100%;
    width: 100%;
  }

  .segmented {
    overflow-x: auto;
    justify-content: flex-start;
  }

  .segmented button {
    flex: 0 0 auto;
  }

  th,
  td {
    padding: 10px;
  }

  .map-overlay {
    align-items: flex-start;
    flex-direction: column;
  }

  .layer-panel {
    max-width: min(100%, 460px);
  }

  .map-control-panel {
    flex-wrap: wrap;
  }

  .modal-backdrop {
    padding: 12px;
  }

  .modal {
    max-height: calc(100vh - 24px);
  }

  .toast-stack {
    left: 12px;
    right: 12px;
    bottom: 12px;
  }

  .toast {
    min-width: 0;
    width: 100%;
  }
}

@media (max-width: 640px) {
  .global-search {
    display: none;
  }

  .top-actions {
    gap: 6px;
  }
}

@media (prefers-reduced-motion: no-preference) {
  .nav-link:hover {
    transform: translateX(2px);
  }

  .tracking-truck-card:hover,
  .tracking-photo-card:hover,
  .route-option:hover,
  .planner-check:hover,
  .notification-row:hover,
  .event-item:hover {
    transform: none;
  }
}

/* Compact density override requested for the full application */
.icon-btn,
.collapse-btn,
.mobile-menu {
  width: 34px;
  height: 34px;
}

.avatar {
  width: 30px;
  height: 30px;
}

.nav-link {
  font-size: 12px;
}

.field,
select,
textarea,
input,
.top-actions select {
  font-size: 12px;
}

.label,
.kpi .label,
.metric span,
.mini-stat span,
.form-row label {
  font-size: 10px;
}

.metric b {
  font-size: 12px;
}

.toast,
.modal,
.drawer {
  font-size: 12px;
}

@media (max-width: 767px) {
  body {
    font-size: 12.5px;
  }

  h1 {
    font-size: 1.3rem;
  }

  h2 {
    font-size: 1rem;
  }

  h3 {
    font-size: .85rem;
  }

  .btn,
  .icon-btn,
  .nav-link,
  .field,
  .top-actions select {
    min-height: 34px;
  }

  .btn {
    padding: 0 10px;
  }

  .kpi .value {
    font-size: 1.25rem;
  }
}
