:root {
  --brand: #20C161;
  --brand-dark: #148A46;
  --brand-light: #E8F9EF;
  --navy: #FAFAF8;
  --bg: #F5F5F3;
  --surface: #FFFFFF;
  --surface-quiet: #FAFAF8;
  --surface-pressed: #F0EFED;
  --border: #E2DFE0;
  --border-strong: #C4BEC0;
  --text: #33383E;
  --text-secondary: #6B6763;
  --muted: #7A7470;
  --green: #1B7D47;
  --amber: #B37C1F;
  --red: #D83C2D;
  --blue: #1E5A8E;
  --purple: #6C557C;
  --shadow: 0 6px 18px rgba(51, 56, 62, .07);
  --shadow-md: 0 12px 30px rgba(51, 56, 62, .10);
  --shadow-lg: 0 22px 52px rgba(51, 56, 62, .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(51, 56, 62, .16);
  --sticky-shadow: 0 8px 24px rgba(51, 56, 62, .10);
  --sticky-shadow-deep: 0 16px 40px rgba(51, 56, 62, .18);
  --sticky-table-shadow: 0 6px 16px rgba(51, 56, 62, .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(51, 56, 62, .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(32, 193, 97, .08);
  color: var(--text);
  transform: translateX(2px);
}
.nav-link:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 0px;
}
.nav-link.active {
  background: rgba(32, 193, 97, .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(32, 193, 97, .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(51, 56, 62, 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,
.global-search svg {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
}
.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(32, 193, 97, .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: #F5FCF8;
  outline: 2px solid rgba(32,193,97,.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: #F5FCF8;
}
.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); }
}
@keyframes spin {
  to { transform: rotate(360deg); }
}
.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(51,56,62,.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: var(--brand-light);
  color: #148A46;
  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(51, 56, 62, .04);
  transition: all var(--transition-base);
}
.card.hoverable:hover {
  border-color: rgba(32, 193, 97, .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(51, 56, 62, .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(51, 56, 62, .2);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(51, 56, 62, .12);
}
.btn.primary {
  background: linear-gradient(135deg, var(--brand), #48D783);
  border-color: var(--brand);
  color: #fff;
  font-weight: 700;
  box-shadow: 0 4px 12px rgba(32, 193, 97, .24);
}
.btn.primary:hover:not(:disabled) {
  box-shadow: 0 8px 20px rgba(32, 193, 97, .32);
  transform: translateY(-2px);
}
.btn.secondary { background: rgba(51, 56, 62, .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(51, 56, 62, .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(51, 56, 62, .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(32, 193, 97, .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: var(--brand-light);
}
th.sortable .sort-btn:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 0px;
  background: var(--brand-light);
}
.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(32, 193, 97, .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(51, 56, 62, .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: var(--brand-light); color: #148A46; }
.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-container .maplibregl-canvas {
  width: 100% !important;
  height: 100% !important;
}
.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(51,56,62,.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(51,56,62,.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: var(--brand-light); border-color: rgba(32,193,97,.45); color: #148A46; }
.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(51,56,62,.10);
}
.map-control-panel .icon-btn {
  width: 34px;
  height: 34px;
}
.map-status {
  position: absolute;
  z-index: 7;
  left: 14px;
  top: 14px;
  max-width: min(360px, calc(100% - 28px));
  display: grid;
  gap: 4px;
  padding: 10px 12px;
  border: 1px solid rgba(37,99,235,.18);
  border-radius: 8px;
  background: rgba(255,255,255,.96);
  color: var(--text);
  box-shadow: 0 10px 24px rgba(51,56,62,.12);
  font: 12px var(--font-ui);
  pointer-events: none;
}
.map-status b { font-size: 12px; }
.map-status span { color: var(--muted); line-height: 1.35; }
.map-status.is-error {
  border-color: rgba(220,38,38,.22);
}
.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(51,56,62,.12);
  border-radius: 8px;
  background: rgba(255,255,255,.94);
  box-shadow: 0 10px 24px rgba(51,56,62,.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(51,56,62,.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: #33383E; }
.map-line {
  width: 18px;
  height: 3px;
  border-radius: 999px;
  background: var(--green);
  display: inline-block;
  box-shadow: 0 0 0 2px rgba(32,193,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:focus-visible {
  outline: 2px solid #33383E;
  outline-offset: -2px;
}
@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: var(--brand-light); color: #148A46; 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: #33383E; 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(32,193,97,.45); background: #F0FBF5; }
.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(51,56,62,.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: #0F6F39;
  background: var(--brand-light);
  border: 1px solid rgba(32,193,97,.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: #F0FBF5; }
.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(32,193,97,.55);
  background: #F0FBF5;
}
.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; }
.app-tooltip {
  position: fixed;
  top: 0;
  left: 0;
  max-width: min(280px, calc(100vw - 16px));
  padding: 7px 9px;
  border-radius: 6px;
  background: #33383E;
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.35;
  box-shadow: 0 10px 24px rgba(51,56,62,.22);
  opacity: 0;
  transform: translateY(2px);
  pointer-events: none;
  z-index: 1000;
  transition: opacity .12s ease, transform .12s ease;
}
.app-tooltip.visible {
  opacity: 1;
  transform: translateY(0);
}
.app-tooltip::after {
  content: "";
  position: absolute;
  width: 8px;
  height: 8px;
  background: #33383E;
  transform: rotate(45deg);
}
.app-tooltip[data-placement="top"]::after {
  left: calc(50% - 4px);
  bottom: -4px;
}
.app-tooltip[data-placement="bottom"]::after {
  left: calc(50% - 4px);
  top: -4px;
}
.app-tooltip[data-placement="left"]::after {
  right: -4px;
  top: calc(50% - 4px);
}
.app-tooltip[data-placement="right"]::after {
  left: -4px;
  top: calc(50% - 4px);
}
.help-text,
.map-help-text {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}
.map-help-text {
  position: absolute;
  left: 14px;
  right: 14px;
  bottom: 12px;
  z-index: 5;
  width: fit-content;
  max-width: min(520px, calc(100% - 28px));
  padding: 7px 9px;
  border: 1px solid rgba(51,56,62,.12);
  border-radius: 6px;
  background: rgba(255,255,255,.92);
  color: #33383E;
  box-shadow: 0 8px 20px rgba(51,56,62,.08);
}
@media (prefers-reduced-motion: reduce) {
  .app-tooltip {
    transition: none;
  }
}

.login-page {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(420px, 500px) 1fr;
  background:
    linear-gradient(135deg, #ffffff 0%, #f5f5f3 46%, #ecefed 100%);
}
.login-panel {
  display: grid;
  align-items: center;
  padding: clamp(28px, 5vw, 56px);
  background: rgba(255, 255, 255, .92);
  border-right: 1px solid var(--border);
}
.login-card {
  width: 100%;
  max-width: 390px;
  margin: 0 auto;
}
.login-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 38px;
}
.login-brand .brand-mark {
  width: 38px;
  height: 38px;
}
.login-brand .brand-name {
  color: var(--text);
  font-size: 16px;
}
.login-copy {
  margin-bottom: 26px;
}
.login-eyebrow {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  margin-bottom: 10px;
  padding: 3px 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface-quiet);
  color: var(--brand-dark);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}
.login-eyebrow.light {
  border-color: rgba(255, 255, 255, .22);
  background: rgba(255, 255, 255, .12);
  color: #fff;
}
.login-copy h1,
.login-visual h1 {
  margin: 0;
  color: var(--text);
  font-family: var(--font-display);
  font-size: clamp(2rem, 5vw, 3rem);
  line-height: 1;
}
.login-copy p {
  margin: 14px 0 0;
  color: var(--text-secondary);
  font-size: 14px;
}
.login-form {
  display: grid;
  gap: 14px;
}
.login-field {
  margin: 0;
}
.login-input {
  position: relative;
  display: flex;
  align-items: center;
  min-height: 44px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 8px 22px rgba(51, 56, 62, .05);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}
.login-input:focus-within {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(32, 193, 97, .14), 0 12px 28px rgba(51, 56, 62, .08);
}
.login-input > i {
  width: 18px;
  height: 18px;
  margin-left: 12px;
  color: var(--muted);
  flex: 0 0 auto;
}
.login-input input {
  min-width: 0;
  width: 100%;
  height: 44px;
  border: 0;
  outline: 0;
  padding: 0 12px;
  background: transparent;
  color: var(--text);
}
.login-input .icon-btn {
  width: 36px;
  height: 36px;
  margin-right: 4px;
  border: 0;
  background: transparent;
  box-shadow: none;
  flex: 0 0 auto;
}
.login-error {
  min-height: 20px;
  margin: -2px 0 0;
  color: var(--red);
  font-weight: 700;
}
.login-form.has-error .login-input {
  border-color: var(--red);
}
.login-submit {
  width: 100%;
  min-height: 44px;
  margin-top: 2px;
}
.login-submit.is-loading i {
  animation: spin 900ms linear infinite;
}
.login-visual {
  position: relative;
  display: grid;
  align-content: center;
  padding: clamp(40px, 7vw, 84px);
  color: #fff;
  overflow: hidden;
  background-attachment: fixed;
  background-position: center 0;
  background:
    linear-gradient(135deg, rgba(51, 56, 62, .78), rgba(30, 90, 142, .66)),
    url("../../dashboard-full.png");
  background-size: cover;
}
.login-visual::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(90deg, rgba(51, 56, 62, .34), rgba(51, 56, 62, .06)),
    repeating-linear-gradient(45deg, rgba(255,255,255,.04) 0 1px, transparent 1px 28px);
}
.login-visual-content {
  position: relative;
  z-index: 1;
  max-width: 720px;
}
.login-visual h1 {
  color: #fff;
  font-size: clamp(2.4rem, 6vw, 4.8rem);
  max-width: 760px;
}
.login-visual p {
  max-width: 600px;
  margin: 18px 0 0;
  color: rgba(255, 255, 255, .82);
  font-size: 16px;
}
.login-metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  max-width: 620px;
  margin-top: 28px;
}
.login-metrics div {
  min-height: 88px;
  padding: 12px;
  border: 1px solid rgba(255, 255, 255, .18);
  border-radius: 8px;
  background: rgba(255, 255, 255, .10);
  backdrop-filter: blur(10px);
}
.login-metrics span {
  display: block;
  color: rgba(255, 255, 255, .68);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}
.login-metrics b {
  display: block;
  margin-top: 12px;
  color: #fff;
  font-family: var(--font-display);
  font-size: 24px;
  line-height: 1;
}

@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(51,56,62,.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(51, 56, 62, .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;
  }
}

/* Final UX correction layer: consistent operational controls and page containment */
html,
body,
#app,
.app-shell {
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
}

body {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, .68), rgba(245, 245, 243, .88) 42%, var(--bg) 100%);
}

.main-area,
.page,
.page-title-row,
.card,
.table-wrap,
.toolbar,
.filter-row {
  min-width: 0;
}

.sidebar {
  scrollbar-width: thin;
}

.sidebar-collapsed .brand-row {
  justify-content: center;
  gap: 6px;
  padding: 0 8px;
}

.sidebar-collapsed .brand-mark {
  width: 32px;
  height: 32px;
  flex: 0 0 32px;
}

.sidebar-collapsed .collapse-btn {
  position: absolute;
  right: 8px;
  top: 10px;
  width: 30px;
  height: 30px;
  opacity: 0;
}

.sidebar-collapsed .brand-row:hover .collapse-btn,
.sidebar-collapsed .collapse-btn:focus-visible {
  opacity: 1;
}

.sidebar-collapsed .nav-link {
  justify-content: center;
  min-height: 42px;
  margin: 4px 8px;
  padding: 0;
}

.sidebar-collapsed .nav-link i {
  width: 20px;
  height: 20px;
}

.topbar {
  gap: 12px;
}

.global-search i,
.global-search svg {
  width: 17px;
  height: 17px;
}

.nav-link svg,
.btn svg,
.icon-btn svg,
.collapse-btn svg,
.mobile-menu svg,
.map-control-panel svg,
.tracking-metric svg,
.tracking-event svg,
.route-option svg {
  width: 17px;
  height: 17px;
  flex: 0 0 auto;
}

.nav-link svg {
  width: 19px;
  height: 19px;
}

.icon-btn svg,
.collapse-btn svg,
.mobile-menu svg {
  width: 18px;
  height: 18px;
}

.global-search input,
.top-actions select,
.field,
textarea {
  min-height: 38px;
  border-width: 1px;
}

.btn,
.segmented button,
.icon-btn,
.collapse-btn,
.mobile-menu {
  position: relative;
  min-height: 38px;
  border-radius: 8px;
  line-height: 1;
}

button.chip,
.tracking-filter-chip,
#trackingNewEventsPill {
  min-height: 32px;
  padding: 0 10px;
  border-radius: 8px;
}

.btn {
  min-width: max-content;
  padding: 0 13px;
  white-space: nowrap;
}

.icon-btn,
.collapse-btn,
.mobile-menu {
  width: 38px;
  height: 38px;
  flex: 0 0 auto;
}

.btn,
.icon-btn,
.collapse-btn,
.mobile-menu,
.segmented button,
.tracking-truck-card,
.tracking-photo-card,
.route-option,
.planner-check,
.directory-node-main {
  touch-action: manipulation;
}

.btn:hover:not(:disabled),
.icon-btn:hover:not(:disabled),
.collapse-btn:hover:not(:disabled),
.mobile-menu:hover:not(:disabled),
.segmented button:hover:not(:disabled) {
  border-color: rgba(51, 56, 62, .24);
  background: #FFFFFF;
  box-shadow: 0 6px 16px rgba(51, 56, 62, .10);
}

.btn:active:not(:disabled),
.icon-btn:active:not(:disabled),
.collapse-btn:active:not(:disabled),
.mobile-menu:active:not(:disabled),
.segmented button:active:not(:disabled) {
  transform: translateY(0);
  box-shadow: 0 2px 7px rgba(51, 56, 62, .10);
}

.btn.primary,
.btn.danger {
  border-width: 1px;
}

.btn.ghost:hover:not(:disabled) {
  border-color: rgba(51, 56, 62, .08);
}

.btn:focus-visible,
.icon-btn:focus-visible,
.collapse-btn:focus-visible,
.mobile-menu:focus-visible,
.segmented button:focus-visible,
.nav-link:focus-visible,
.tracking-truck-card:focus-visible,
.tracking-photo-card:focus-visible,
.route-option:focus-visible,
.directory-node-main:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
  box-shadow: 0 0 0 4px rgba(32, 193, 97, .14);
}

.segmented {
  gap: 3px;
  padding: 3px;
  border-radius: 9px;
  overflow-x: auto;
}

.segmented button {
  min-height: 32px;
  border: 0;
  border-radius: 6px;
}

.segmented button.active {
  box-shadow: inset 0 0 0 1px rgba(32, 193, 97, .22);
}

.card {
  border-width: 1px;
  background: var(--surface);
  box-shadow: 0 1px 2px rgba(51, 56, 62, .05);
}

.card:hover {
  border-color: #D6D1D1;
}

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

.page-title-row h1 {
  max-width: 980px;
}

.page-title-row p {
  max-width: 980px;
  margin-bottom: 0;
}

.page-title-row .filter-row .btn,
.card-head .btn,
.toolbar .btn,
.api-action-row .btn {
  min-height: 36px;
}

.kpi .value,
.metric b,
.mini-stat b,
.profile-cell b,
.planner-summary-cell b,
.report-field b,
.api-status-metric b,
.source-pill b {
  letter-spacing: 0;
}

.kpi .sub,
.help-text,
.map-help-text,
.field-meta {
  color: var(--text-secondary);
}

.table-wrap {
  max-width: 100%;
}

th,
td {
  max-width: 360px;
}

td,
th,
.event-item b,
.metric b,
.profile-cell b,
.mini-stat b {
  overflow-wrap: anywhere;
}

tbody tr.clickable:hover,
.notification-row:hover,
.route-option:hover,
.tracking-truck-card:hover,
.tracking-photo-card:hover,
.planner-check:hover {
  border-color: rgba(32, 193, 97, .28);
  background: #F5FCF8;
}

.status-green,
.status-yellow,
.status-red,
.status-blue,
.status-neutral {
  border-width: 1px;
}

.modal-backdrop {
  backdrop-filter: blur(3px);
}

.modal {
  box-shadow: var(--shadow-lg);
}

.modal-head h2,
.drawer-head h2 {
  margin-bottom: 0;
}

.modal-foot {
  flex-wrap: wrap;
}

.modal-foot .btn {
  min-height: 38px;
}

.toast {
  background: #FFFFFF;
  color: var(--text);
  border-color: rgba(32, 193, 97, .30);
  border-left: 4px solid var(--brand);
}

.map-overlay {
  max-width: calc(100% - 24px);
}

.layer-panel,
.map-control-panel {
  border: 1px solid rgba(51, 56, 62, .10);
  border-radius: 9px;
  background: rgba(255, 255, 255, .94);
  box-shadow: 0 10px 24px rgba(51, 56, 62, .08);
}

.layer-panel button {
  min-height: 32px;
  border-radius: 6px;
  white-space: nowrap;
}

@media (prefers-reduced-motion: no-preference) {
  .btn:hover:not(:disabled),
  .icon-btn:hover:not(:disabled),
  .collapse-btn:hover:not(:disabled),
  .mobile-menu:hover:not(:disabled) {
    transform: translateY(-1px);
  }

  .card:hover,
  .event-item:hover,
  .metric:hover,
  .profile-cell:hover,
  .planner-summary-cell:hover,
  .source-pill:hover,
  .report-field:hover,
  .api-status-metric:hover {
    box-shadow: 0 7px 18px rgba(51, 56, 62, .08);
  }
}

@media (max-width: 1023px) {
  .topbar {
    flex-wrap: nowrap;
  }

  .top-actions {
    flex: 0 0 auto;
  }

  .page-title-row {
    align-items: flex-start;
  }
}

@media (max-width: 767px) {
  html,
  body {
    overflow-x: hidden;
  }

  .page {
    padding: 14px;
  }

  .topbar {
    padding: 0 10px;
  }

  .mobile-menu,
  .icon-btn,
  .collapse-btn {
    width: 40px;
    height: 40px;
  }

  .btn,
  .field,
  select,
  textarea,
  .segmented button {
    min-height: 40px;
  }

  button.chip,
  .tracking-filter-chip,
  #trackingNewEventsPill {
    min-height: 36px;
  }

  .btn {
    min-width: 0;
    width: auto;
    white-space: normal;
  }

  .page-title-row .filter-row .btn,
  .toolbar .btn,
  .api-action-row .btn,
  .planner-share-row .btn {
    width: 100%;
  }

  .card {
    padding: 12px;
  }

  .table-wrap {
    margin-inline: -2px;
  }

  th,
  td {
    max-width: 260px;
  }

  .modal-foot {
    display: grid;
    grid-template-columns: 1fr;
  }

  .modal-foot .btn {
    width: 100%;
  }
}
