:root {
  --bg: #eef1f4;
  --bg-accent: #e8ecf0;
  --panel: #ffffff;
  --ink: #161a1f;
  --muted: #66707a;
  --line: #d8dde3;
  --brand: #c8102e;
  --brand-2: #a10d25;
  --good: #1f6b4a;
  --green: #2f7d4f;
  --amber: #a66b12;
  --red: #c8102e;
  --late: #7a0f1c;
  --sidebar: #0b0d10;
  --sidebar-ink: #f2f4f6;
  --shadow-xs: 0 1px 2px rgba(16, 22, 28, 0.04);
  --shadow-sm: 0 2px 6px rgba(16, 22, 28, 0.05);
  --shadow: 0 4px 14px rgba(16, 22, 28, 0.06);
  --shadow-md: 0 8px 24px rgba(16, 22, 28, 0.08);
  --radius: 10px;
  --radius-sm: 8px;
  --font: "DM Sans", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
  --sidebar-width: 240px;
  --topbar-height: 56px;
  --bottom-nav-height: 64px;
}

* { box-sizing: border-box; }

html {
  max-width: 100%;
  overflow-x: hidden;
}

body {
  margin: 0;
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
  min-height: 100vh;
  max-width: 100%;
  overflow-x: hidden;
}

body.mobile-nav-open {
  overflow: hidden;
}

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

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.icon {
  display: inline-block;
  width: 1.05em;
  height: 1.05em;
  flex-shrink: 0;
  vertical-align: -0.15em;
}

.shell {
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: 100vh;
}

.workspace {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.sidebar {
  background: #0b0d10;
  color: var(--sidebar-ink);
  padding: 18px 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  border-right: 1px solid rgba(255, 255, 255, 0.06);
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 8px 10px 14px;
}

.brand-logo {
  width: 52px;
  height: auto;
  display: block;
  flex-shrink: 0;
  background: #000;
  border-radius: 10px;
  padding: 5px;
  box-sizing: border-box;
  object-fit: contain;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.brand-logo-sm {
  width: 34px;
  padding: 3px;
  border-radius: 8px;
  background: #000;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.brand-mark {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  background: #000;
  color: #f2f4f6;
  font-weight: 700;
  display: grid;
  place-items: center;
  letter-spacing: 0.02em;
}

.brand-lockup {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.brand-name {
  font-weight: 700;
  font-size: 0.92rem;
  letter-spacing: 0.14em;
  line-height: 1.1;
  text-transform: uppercase;
  color: #fff;
}

.brand-dispatch {
  color: var(--brand);
  font-weight: 700;
  font-size: 0.72rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  line-height: 1.2;
}

.brand-support {
  margin-top: 4px;
  opacity: 0.45;
  font-size: 0.6rem;
  letter-spacing: 0.02em;
  font-weight: 500;
}

.brand-sub {
  opacity: 0.68;
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-section-label {
  margin: 10px 10px 4px;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(242, 244, 246, 0.42);
}

.nav a,
.nav .nav-link {
  color: var(--sidebar-ink);
  padding: 8px 10px;
  border-radius: 10px;
  text-decoration: none;
  opacity: 0.88;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.92rem;
  font-weight: 500;
  min-height: 40px;
}

.nav a .icon,
.nav .nav-link .icon {
  width: 18px;
  height: 18px;
  opacity: 0.9;
}

.nav a:hover,
.nav a.active,
.nav .nav-link:hover,
.nav .nav-link.active {
  background: rgba(200, 16, 46, 0.22);
  opacity: 1;
  text-decoration: none;
}

.nav a.active,
.nav .nav-link.active {
  background: rgba(200, 16, 46, 0.22);
  box-shadow: inset 3px 0 0 var(--brand);
  font-weight: 600;
}

.nav-link-signout {
  margin-top: 8px;
}

.sidebar-foot {
  margin-top: auto;
  font-size: 0.75rem;
  opacity: 0.9;
  line-height: 1.4;
  padding: 8px 6px 4px;
  display: grid;
  gap: 10px;
}

.sidebar-help {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.04);
  color: var(--sidebar-ink);
}

.sidebar-help-icon {
  width: 18px;
  height: 18px;
  opacity: 0.85;
  color: #fff;
}

.sidebar-help-title {
  font-size: 0.78rem;
  font-weight: 700;
}

.sidebar-help-meta {
  font-size: 0.68rem;
  opacity: 0.55;
}

.sidebar-user {
  opacity: 0.55;
  padding: 0 8px;
  font-size: 0.72rem;
}

/* Desktop premium top bar */
.desktop-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: var(--topbar-height);
  padding: 8px 24px;
  background: #ffffff;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 40;
  box-shadow: var(--shadow-xs);
}

.desktop-search {
  position: relative;
  flex: 1 1 auto;
  max-width: 440px;
}

.desktop-search-icon {
  position: absolute;
  left: 13px;
  top: 50%;
  transform: translateY(-50%);
  color: #8a939d;
  pointer-events: none;
  width: 16px;
  height: 16px;
}

.desktop-search input {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 9px 14px 9px 38px;
  font: inherit;
  font-size: 0.9rem;
  font-weight: 500;
  background: #f5f7f9;
  color: var(--ink);
  box-shadow: var(--shadow-xs);
  transition: border-color 120ms ease, background-color 120ms ease, box-shadow 120ms ease;
}

.desktop-search input::placeholder {
  color: #8f98a3;
  font-weight: 400;
}

.desktop-search input:hover {
  background: #f2f5f8;
  border-color: #c9d1d8;
}

.desktop-search input:focus {
  outline: none;
  border-color: rgba(200, 16, 46, 0.35);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(200, 16, 46, 0.12), var(--shadow-xs);
}

.desktop-topbar-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.system-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 10px;
  border-radius: 999px;
  background: #eaf7ef;
  color: var(--good);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.system-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #22a45a;
}

.topbar-clock {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.alert-bell {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  text-decoration: none;
}

.alert-bell:hover { text-decoration: none; background: #f7f9fb; }
.alert-bell:focus-visible {
  outline: 2px solid rgba(200, 16, 46, 0.45);
  outline-offset: 2px;
}

.alert-bell-count {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--brand);
  color: #fff;
  font-size: 0.68rem;
  font-weight: 700;
  display: grid;
  place-items: center;
}

.staff-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 4px 10px 4px 4px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #fff;
}

.staff-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: #161a1f;
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 0.7rem;
  font-weight: 700;
}

.staff-chip-text {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
}

.staff-chip-name {
  font-size: 0.8rem;
  font-weight: 700;
}

.staff-chip-role {
  font-size: 0.68rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* Mobile top bar + drawer — hidden on desktop */
.mobile-topbar,
.mobile-nav-backdrop {
  display: none;
}

.mobile-bottom-nav {
  display: none;
}

.mobile-nav-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  min-width: 44px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.28);
  background: rgba(255, 255, 255, 0.12);
  color: var(--sidebar-ink);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.mobile-nav-toggle-bars {
  width: 18px;
  height: 12px;
  display: inline-block;
  background:
    linear-gradient(var(--sidebar-ink), var(--sidebar-ink)) 0 0 / 100% 2px no-repeat,
    linear-gradient(var(--sidebar-ink), var(--sidebar-ink)) 0 5px / 100% 2px no-repeat,
    linear-gradient(var(--sidebar-ink), var(--sidebar-ink)) 0 10px / 100% 2px no-repeat;
}

.main {
  padding: 20px 24px 40px;
  min-width: 0;
  background: transparent;
}

.page-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 14px;
}

.page-kicker {
  margin: 0 0 2px;
  color: var(--brand);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.trips-page-head h1 {
  font-size: 1.5rem;
  letter-spacing: -0.025em;
  font-weight: 700;
}

.trips-page-head .lede {
  max-width: 62ch;
  font-size: 0.88rem;
  color: var(--muted);
  font-weight: 400;
}

.page-head-actions .btn-ghost {
  color: #5a6570;
  font-weight: 600;
}

.page-head-actions .btn-primary {
  min-width: 118px;
  font-weight: 600;
}

h1 {
  margin: 0 0 4px;
  font-size: 1.55rem;
  font-weight: 700;
  letter-spacing: -0.025em;
}

h2 {
  margin: 0 0 12px;
  font-size: 1.1rem;
}

.lede {
  margin: 0;
  color: var(--muted);
  max-width: 54ch;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border: 1px solid #d6dbe1;
  border-radius: var(--radius);
  padding: 10px 16px;
  min-height: 40px;
  font: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  line-height: 1.2;
  cursor: pointer;
  background: #fff;
  color: var(--ink);
  text-decoration: none;
  box-shadow: var(--shadow-xs);
  transition: background-color 140ms ease, border-color 140ms ease, box-shadow 140ms ease, color 140ms ease;
}

.btn:hover {
  text-decoration: none;
  background: #f6f8fa;
  border-color: #c4ccd4;
  box-shadow: var(--shadow-sm);
}

.btn:active {
  background: #eef1f4;
  border-color: #bcc5cd;
  box-shadow: inset 0 1px 2px rgba(16, 22, 28, 0.08);
}

.btn:focus-visible {
  outline: 2px solid rgba(200, 16, 46, 0.4);
  outline-offset: 2px;
}

.btn:disabled,
.btn[disabled],
.btn.is-disabled {
  opacity: 0.48;
  cursor: not-allowed;
  box-shadow: none;
  background: #f3f5f7;
  border-color: #dde2e7;
  color: #8a939d;
  pointer-events: none;
}

.btn-primary {
  background: var(--brand);
  color: #fff;
  border-color: transparent;
  box-shadow: 0 1px 2px rgba(200, 16, 46, 0.18), 0 4px 12px rgba(200, 16, 46, 0.16);
}

.btn-primary:hover {
  background: var(--brand-2);
  border-color: transparent;
  color: #fff;
  filter: none;
  box-shadow: 0 2px 4px rgba(200, 16, 46, 0.2), 0 6px 16px rgba(200, 16, 46, 0.2);
}

.btn-primary:active {
  background: #8f0b20;
  border-color: transparent;
  color: #fff;
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.2);
}

.btn-primary:disabled,
.btn-primary[disabled],
.btn-primary.is-disabled {
  background: #d9a0aa;
  border-color: transparent;
  color: rgba(255, 255, 255, 0.85);
  box-shadow: none;
}

.btn-ghost {
  background: #fff;
  border-color: #d6dbe1;
  color: #3a434c;
  box-shadow: var(--shadow-xs);
}

.btn-ghost:hover {
  background: #f7f9fb;
  border-color: #c4ccd4;
  color: var(--ink);
}

.btn-ghost:active {
  background: #eef1f4;
  box-shadow: inset 0 1px 2px rgba(16, 22, 28, 0.06);
}

.btn-danger {
  background: #fff;
  border-color: #e8b7bd;
  color: var(--brand);
  box-shadow: var(--shadow-xs);
}

.btn-danger:hover {
  background: #fff6f7;
  border-color: #d9929a;
  color: var(--brand-2);
}

.btn-danger:active {
  background: #fde8eb;
  box-shadow: inset 0 1px 2px rgba(161, 13, 37, 0.1);
}

.btn-small {
  padding: 7px 12px;
  min-height: 34px;
  font-size: 0.82rem;
  font-weight: 600;
  border-radius: var(--radius-sm);
  gap: 5px;
}

.alert-banner.ok {
  background: #e8f6ee;
  border-color: #a8d4b8;
  color: var(--good);
  animation: none;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.segmented,
.tabs {
  display: inline-flex;
  align-items: stretch;
  background: #f3f5f7;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  padding: 3px;
  gap: 2px;
  box-shadow: var(--shadow-xs);
}

.segmented a,
.tabs a {
  padding: 7px 12px;
  color: #4a545e;
  text-decoration: none;
  border-right: 0;
  border-radius: 7px;
  font-weight: 600;
  font-size: 0.84rem;
  letter-spacing: 0.01em;
  line-height: 1.2;
  transition: background-color 120ms ease, color 120ms ease, box-shadow 120ms ease;
}

.segmented a:last-child,
.tabs a:last-child { border-right: 0; }

.segmented a:hover,
.tabs a:hover {
  color: var(--ink);
  background: rgba(255, 255, 255, 0.65);
  text-decoration: none;
}

.segmented a.active,
.tabs a.active {
  background: #fff;
  color: var(--ink);
  box-shadow: var(--shadow-xs);
  font-weight: 700;
}

.tabs {
  margin-bottom: 14px;
}

.tabs em {
  font-style: normal;
  opacity: 0.65;
  margin-left: 4px;
  font-weight: 600;
}

.trips-filters {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 12px;
}

.filter-group {
  align-items: center;
  gap: 12px;
  margin-bottom: 0;
  padding: 10px 12px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-xs);
}

.filter-row {
  display: flex;
  flex-wrap: wrap;
}

.filter-group-label,
.filter-inline-label {
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: #80909b;
  min-width: 72px;
}

.filter-inline-label {
  margin-left: 6px;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.summary-card {
  position: relative;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 16px 14px 18px;
  box-shadow: var(--shadow);
  min-width: 0;
  min-height: 112px;
  overflow: hidden;
}

.summary-card::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: #b7c2cb;
}

.summary-card:hover {
  box-shadow: var(--shadow-md);
}

.summary-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.summary-icon {
  width: 32px;
  height: 32px;
  border-radius: 9px;
  display: grid;
  place-items: center;
  background: #f2f4f6;
  color: #5c6670;
}

.summary-icon .icon {
  width: 15px;
  height: 15px;
  opacity: 0.92;
}

.summary-card-checkins::before { background: #1f9d57; }
.summary-card-checkins .summary-icon {
  background: #eef8f2;
  color: #1f9d57;
}

.summary-card-transit::before { background: #2f6fed; }
.summary-card-transit .summary-icon {
  background: #eef3fb;
  color: #2f6fed;
}

.summary-card-upcoming::before { background: #d97706; }
.summary-card-upcoming .summary-icon {
  background: #fbf4ea;
  color: #d97706;
}

.summary-card-completed::before { background: #159a5a; }
.summary-card-completed .summary-icon {
  background: #eef8f2;
  color: #159a5a;
}

.summary-card-attention::before { background: var(--brand); }
.summary-card-attention .summary-icon {
  background: #faf0f2;
  color: var(--brand);
}

.summary-card-alert {
  border-color: #e7b4ba;
  background: #fffafb;
}

.summary-label {
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: #80909b;
}

.summary-value {
  margin-top: 10px;
  font-size: 1.9rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1;
  color: var(--ink);
}

.summary-meta {
  margin-top: 8px;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 500;
  line-height: 1.35;
}

.summary-trend-up { color: #1f9d57; font-weight: 600; }
.summary-trend-down { color: var(--brand); font-weight: 600; }
.summary-trend-flat { color: var(--muted); font-weight: 500; }

.ops-filter-link {
  display: inline-flex !important;
  align-items: center;
  gap: 6px;
}

.ops-filter-link .icon {
  width: 14px;
  height: 14px;
}

.source-whatsapp { color: #25d366; }
.ops-filter-link.active .source-whatsapp { color: #1ea952; }

.week-nav {
  display: inline-flex;
  align-items: center;
  gap: 14px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 8px 12px;
  font-weight: 600;
  box-shadow: var(--shadow-xs);
}

.week-nav a { color: var(--brand); text-decoration: none; }

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 14px;
  margin-bottom: 12px;
  padding: 9px 12px;
  color: #7a8692;
  font-size: 0.74rem;
  font-weight: 500;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-xs);
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
  margin-right: 6px;
}

.dot.good,
.dot.normal { background: #8aa3b5; }
.dot.green { background: var(--green); }
.dot.amber { background: var(--amber); }
.dot.red { background: var(--red); }
.dot.late { background: var(--late); }

.alert-banner {
  background: #fff5f6;
  border: 1px solid #e7b4ba;
  color: var(--late);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 18px;
  box-shadow: var(--shadow);
}

.alert-banner.warn {
  background: #fff7e8;
  border-color: #e5c48a;
  color: #7a4d00;
  animation: none;
}

.alert-banner strong { margin-right: 10px; }

.alert-banner ul {
  margin: 10px 0 0;
  padding-left: 18px;
}

@keyframes pulse-border {
  0%, 100% { box-shadow: var(--shadow); }
  50% { box-shadow: var(--shadow); }
}

.day-block {
  margin-bottom: 28px;
}

.day-block h2 {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: #8a959f;
  margin-bottom: 8px;
}

.table-wrap {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: auto;
  box-shadow: var(--shadow);
}

table.loads {
  width: 100%;
  border-collapse: collapse;
  min-width: 980px;
}

/* Desktop Trips: 9 info columns; actions sit on a full-width row below each load. */
table.loads.trips-table {
  width: 100%;
  min-width: 1040px;
  table-layout: auto;
  font-size: 13px;
}

table.loads.trips-table th,
table.loads.trips-table td {
  padding: 10px 10px;
  font-size: 12.5px;
  overflow-wrap: normal;
  word-break: normal;
}

table.loads.trips-table th {
  white-space: nowrap;
  font-weight: 700;
}

/* Fixed minimum widths; Route + Assignment absorb remaining space. */
table.loads.trips-table th:nth-child(1),
table.loads.trips-table tr.trip-info-row td:nth-child(1) { min-width: 110px; width: 110px; }   /* VRID */
table.loads.trips-table th:nth-child(2),
table.loads.trips-table tr.trip-info-row td:nth-child(2) { min-width: 120px; width: 120px; }   /* Company */
table.loads.trips-table th:nth-child(3),
table.loads.trips-table tr.trip-info-row td:nth-child(3) { min-width: 140px; width: 140px; }   /* Check-In */
table.loads.trips-table th:nth-child(4),
table.loads.trips-table tr.trip-info-row td:nth-child(4) { min-width: 140px; width: 140px; }   /* Time Left / Check-Out */
table.loads.trips-table th:nth-child(5),
table.loads.trips-table tr.trip-info-row td:nth-child(5) { min-width: 160px; width: auto; }    /* Route (flexible) */
table.loads.trips-table th:nth-child(6),
table.loads.trips-table tr.trip-info-row td:nth-child(6) { min-width: 160px; width: auto; }    /* Assignment (flexible) */
table.loads.trips-table th:nth-child(7),
table.loads.trips-table tr.trip-info-row td:nth-child(7) { min-width: 90px; width: 90px; }     /* Alert */
table.loads.trips-table th:nth-child(8),
table.loads.trips-table tr.trip-info-row td:nth-child(8) { min-width: 120px; width: 120px; }   /* Rates */
table.loads.trips-table th:nth-child(9),
table.loads.trips-table tr.trip-info-row td:nth-child(9) { min-width: 110px; width: 110px; }   /* Status */

.trips-desktop {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* Info row sits tight against its action row. */
table.loads.trips-table tr.trip-info-row td {
  border-bottom: none;
  padding-bottom: 4px;
}

table.loads.trips-table tr.trip-info-row {
  background: #fff;
}

table.loads.trips-table tr.trip-info-row:hover {
  background: #f8fafb;
}

table.loads.trips-table tr.trip-info-row:nth-child(4n+1) {
  background: #fcfdfe;
}

table.loads.trips-table tr.trip-info-row:nth-child(4n+1):hover {
  background: #f7f9fb;
}

table.loads.trips-table .trip-vrid {
  font-weight: 700;
  color: var(--brand-2);
  text-decoration: none;
}

table.loads.trips-table .trip-vrid:hover {
  text-decoration: underline;
}

table.loads.trips-table .route {
  font-size: 13px;
  font-weight: 600;
}

table.loads.trips-table .source-chip,
.source-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.78rem;
}

.pill-icon {
  width: 12px;
  height: 12px;
  margin-right: 2px;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  line-height: 1.35;
  background: #eef2f5;
  color: #44515c;
  border: 1px solid transparent;
}

.status-badge.status-in-transit,
.status-badge.status-checked-in {
  background: #eaf6ef;
  color: var(--good);
}

.status-badge.status-upcoming {
  background: #eef2f8;
  color: #3d556c;
}

.status-badge.status-completed {
  background: #f0f2f4;
  color: var(--muted);
}

/* Check-in / check-out: CSS traffic lights + neutral text (not color-only).
   IMPORTANT: .checkpoint-light MUST set display — empty spans are invisible
   without it (width/height do not apply to display:inline). */
.checkpoint-status {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.84rem;
  line-height: 1.3;
  color: var(--ink, #14201c);
}
.checkpoint-row {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 0.4rem 0.55rem;
  min-height: 1.7rem;
}
.checkpoint-label {
  min-width: 4.8rem;
  color: var(--muted, #5c6b64);
  font-weight: 600;
}
.checkpoint-state {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  min-height: 1.7rem;
  color: var(--ink, #1a2420);
}
.checkpoint-value {
  color: var(--ink, #1a2420);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.checkpoint-light {
  display: inline-block;
  width: 1.1rem;
  height: 1.1rem;
  min-width: 1.1rem;
  min-height: 1.1rem;
  border-radius: 50%;
  flex: 0 0 auto;
  flex-shrink: 0;
  box-sizing: border-box;
  background: #c5ced6;
  border: 1.5px solid rgba(0, 0, 0, 0.18);
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.35) inset,
    0 1px 2px rgba(0, 0, 0, 0.12);
  vertical-align: middle;
}
.checkpoint-state--complete .checkpoint-light {
  background: #1f9d66;
  border-color: #157a4e;
}
.checkpoint-state--pending .checkpoint-light {
  background: #d64535;
  border-color: #a83226;
}
.checkpoint-state--unknown .checkpoint-light {
  background: #c5ced6;
  border-color: #9aa6b2;
}
/* Legacy aliases (pre-rename) — keep dots visible if old markup is cached. */
.tl-dot,
.checkpoint-indicator .tl-dot {
  display: inline-block;
  width: 1.1rem;
  height: 1.1rem;
  min-width: 1.1rem;
  min-height: 1.1rem;
  border-radius: 50%;
  flex: 0 0 auto;
  flex-shrink: 0;
  box-sizing: border-box;
  background: #c5ced6;
  border: 1.5px solid rgba(0, 0, 0, 0.18);
  vertical-align: middle;
}
.tl-dot.tl-complete { background: #1f9d66; border-color: #157a4e; }
.tl-dot.tl-pending { background: #d64535; border-color: #a83226; }
.tl-dot.tl-unknown { background: #c5ced6; border-color: #9aa6b2; }
.checkpoint-indicator {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  min-height: 1.7rem;
}
.checkpoint-text {
  color: var(--ink, #1a2420);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.checkpoint-hide-label .checkpoint-label {
  display: none;
}

/* Identical Check-In / Check-Out column geometry on the board */
table.loads.trips-table .checkin-cell,
table.loads.trips-table .timeleft-checkout-cell {
  vertical-align: middle;
  padding-top: 0.65rem;
  padding-bottom: 0.65rem;
  padding-left: 10px;
  padding-right: 10px;
  min-width: 140px;
  width: 140px;
  box-sizing: border-box;
}
table.loads.trips-table .checkin-cell .checkpoint-status,
table.loads.trips-table .timeleft-checkout-cell .checkpoint-status {
  margin: 0;
  min-height: 1.7rem;
  justify-content: flex-start;
  align-items: flex-start;
}
table.loads.trips-table .checkin-cell .checkpoint-row,
table.loads.trips-table .timeleft-checkout-cell .checkpoint-row {
  min-height: 1.7rem;
  width: 100%;
}
table.loads.trips-table .checkin-cell .checkpoint-state,
table.loads.trips-table .timeleft-checkout-cell .checkpoint-state {
  min-height: 1.7rem;
}
table.loads.trips-table .checkin-cell,
table.loads.trips-table .timeleft-checkout-cell {
  white-space: nowrap;
}

/* Customer → route → source hierarchy (title case, not all-caps) */
.trip-route-stack {
  display: grid;
  gap: 0.2rem;
  min-width: 0;
}
.trip-customer {
  font-size: 1.05rem;
  font-weight: 800;
  letter-spacing: -0.01em;
  text-transform: none;
  color: #0d1713;
  line-height: 1.2;
  overflow-wrap: anywhere;
}
.trip-route {
  font-size: 0.92rem;
  font-weight: 600;
  color: #243028;
  line-height: 1.25;
}
.trip-source,
.trip-source .source-chip {
  font-size: 0.72rem;
  font-weight: 500;
  color: var(--muted, #5c6b64);
}
table.loads.trips-table .trip-customer {
  font-size: 1rem;
}
table.loads.trips-table .trip-route.route {
  font-size: 0.88rem;
  font-weight: 600;
}
.trip-card-route-wrap {
  margin: 14px 0 0;
  padding: 14px 12px;
  background: #f5f7f9;
  border-radius: var(--radius-sm);
}
.trip-card-route-wrap .trip-customer {
  font-size: 1.12rem;
}
.trip-card-route-wrap .trip-route {
  font-size: 0.98rem;
  margin-top: 0.2rem;
}
.trip-card-checkpoints {
  margin: 18px 0 18px;
  padding: 4px 0 4px;
}
.trip-card-checkpoints .checkpoint-status {
  font-size: 0.95rem;
  gap: 0.55rem;
}
.trip-card-checkpoints .checkpoint-row {
  min-height: 1.85rem;
}
.trip-card-assign {
  margin-top: 4px;
}
.trip-card-board {
  margin-top: 2px;
}
@media (max-width: 720px) {
  .checkpoint-status {
    font-size: 0.95rem;
  }
  .checkpoint-label {
    min-width: 5rem;
  }
  .checkpoint-light,
  .tl-dot {
    width: 1.15rem;
    height: 1.15rem;
    min-width: 1.15rem;
    min-height: 1.15rem;
  }
  .trip-customer {
    font-size: 1.12rem;
  }
  .trip-card-route-wrap {
    margin: 16px 0 0;
    margin-bottom: 0;
  }
  .trip-card-checkpoints {
    margin: 20px 0 20px;
  }
  .trip-card-assign {
    margin-top: 6px;
    margin-bottom: 14px;
  }
}

table.loads.trips-table tr.row-urgent.trip-info-row td:first-child,
table.loads.trips-table tr.row-red.trip-info-row td:first-child,
table.loads.trips-table tr.row-late.trip-info-row td:first-child {
  box-shadow: inset 3px 0 0 var(--brand);
}

/* Full-width action strip under each load. */
table.loads.trips-table tr.trip-actions-row td {
  padding-top: 6px;
  padding-bottom: 10px;
  border-top: 1px solid #e8ecf0;
  background: #f8fafb;
  vertical-align: middle;
}

table.loads.trips-table .trip-row-actions {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  max-width: 100%;
}

table.loads.trips-table .trip-row-actions .btn,
table.loads.trips-table .trip-row-actions .btn-small,
table.loads.trips-table .trip-row-actions button {
  white-space: nowrap;
  width: auto;
  flex: 0 0 auto;
  box-sizing: border-box;
  text-align: center;
  min-height: 34px;
  padding: 7px 12px;
  font-size: 0.82rem;
  line-height: 1.2;
}

table.loads.trips-table .pill {
  white-space: nowrap;
}

table.loads.trips-table .muted {
  font-size: 0.78rem;
  margin-top: 2px;
  color: #7a8692;
}

table.loads.trips-table .route {
  font-size: 13px;
}

table.loads.trips-table .checkin-cell,
table.loads.trips-table .rates-cell {
  white-space: nowrap;
}

table.loads th,
table.loads td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid #e7ebef;
  vertical-align: top;
}

table.loads th {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #80909b;
  background: #f6f8fa;
  font-weight: 700;
}

.mono { font-family: var(--mono); font-size: 0.9rem; }
.muted { color: var(--muted); font-size: 0.8rem; margin-top: 2px; font-weight: 500; }
.route { font-weight: 600; }

.pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  line-height: 1.35;
  background: #eef2f5;
  color: #44515c;
}

.pill-good { background: #e8eef3; color: #355064; }
.pill-green { background: #e7f5ee; color: var(--good); }
.pill-amber { background: #f8efd9; color: var(--amber); }
.pill-red { background: #f8e6e9; color: var(--red); }
.pill-late { background: #f0dce1; color: var(--late); }
.pill-checked-in,
.pill-in-transit { background: #e8f1f8; color: #355064; }
.pill-completed { background: #eef1f4; color: #44515c; }
.pill-normal { background: #eef2f5; color: var(--muted); }
.pill-upcoming { background: #eef2f8; color: #3d556c; }

.row-urgent {
  background: #fff1f2;
}

.row-late { background: #f8e8eb; }
.row-red { background: #fff5f6; }
.row-amber { background: #fffaf0; }

.actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

.actions form { margin: 0; }

.empty,
.empty-cell {
  padding: 28px;
  color: var(--muted);
  text-align: center;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  max-width: 860px;
  background: rgba(255, 255, 255, 0.85);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow);
}

.form-grid label,
.form-stack label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-weight: 600;
  font-size: 0.92rem;
}

.form-grid .full { grid-column: 1 / -1; }
.hidden { display: none !important; }

input,
select,
textarea {
  font: inherit;
  padding: 10px 12px;
  min-height: 40px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  box-shadow: var(--shadow-xs);
  transition: border-color 120ms ease, box-shadow 120ms ease;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: rgba(200, 16, 46, 0.35);
  box-shadow: 0 0 0 3px rgba(200, 16, 46, 0.12), var(--shadow-xs);
}

input::placeholder,
textarea::placeholder {
  color: #8f98a3;
}

.form-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-top: 4px;
}

.form-stack {
  display: flex;
  flex-direction: column;
  gap: 14px;
  max-width: 420px;
}

.auth-panel {
  max-width: 460px;
  background: rgba(255, 255, 255, 0.88);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 28px;
  box-shadow: var(--shadow);
}

.auth-forgot {
  margin-top: 16px;
}

.auth-forgot a {
  color: var(--accent, #1d4ed8);
  font-weight: 600;
  text-decoration: none;
}

.auth-forgot a:hover {
  text-decoration: underline;
}

.reset-password-dialog {
  max-width: 520px;
}

.temp-password-value {
  display: inline-block;
  margin-left: 0;
  padding: 6px 10px;
  background: rgba(15, 23, 42, 0.06);
  border-radius: 6px;
  font-size: 1.15rem;
  letter-spacing: 0.02em;
  user-select: all;
}

.password-masked {
  letter-spacing: 0.12em;
  font-weight: 700;
}

.login-copy-packet {
  display: none;
}

.warn-text {
  color: #b45309;
  font-weight: 700;
}

.driver-profile-card {
  max-width: 820px;
}

.password-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.send-channels .btn[disabled] {
  opacity: 0.55;
  cursor: not-allowed;
}

.section-title {
  margin: 28px 0 12px;
}

.page-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.meta-line {
  color: var(--muted);
  font-size: 0.92rem;
  margin: 0 0 18px;
}

.meta-line code,
.mono {
  font-family: var(--mono);
  font-size: 0.85em;
}

.conn-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  margin-bottom: 28px;
}

.conn-panel,
.review-panel {
  background: rgba(255, 255, 255, 0.88);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow);
}

.conn-panel h2,
.review-panel h2 {
  margin: 0 0 6px;
}

.conn-meta {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px 16px;
  margin: 16px 0 18px;
}

.conn-meta dt {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.conn-meta dd {
  margin: 2px 0 0;
  font-weight: 600;
}

.review-panel {
  margin-bottom: 22px;
}

.review-head {
  margin-bottom: 12px;
}

.email-excerpt {
  background: #f0f4f7;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 14px;
  max-height: 220px;
  overflow: auto;
  white-space: pre-wrap;
  font-family: var(--mono);
  font-size: 0.82rem;
  line-height: 1.45;
  margin: 0 0 16px;
}

@media (max-width: 900px) {
  .shell {
    grid-template-columns: 1fr;
    padding-top: 56px;
    padding-bottom: calc(var(--bottom-nav-height) + env(safe-area-inset-bottom, 0px));
  }
  .desktop-topbar {
    display: none;
  }
  .mobile-topbar {
    display: flex;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 300;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    min-height: 56px;
    padding: 8px 12px;
    padding-top: calc(8px + env(safe-area-inset-top, 0px));
    background: #0b0d10;
    color: var(--sidebar-ink);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.28);
  }
  .mobile-brand {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
    flex: 1 1 auto;
    justify-content: center;
  }
  .mobile-brand .brand-mark {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    font-size: 0.85rem;
  }
  .mobile-brand .brand-logo {
    width: 34px;
  }
  .mobile-brand-text {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 1px;
    line-height: 1;
    min-width: 0;
  }
  .mobile-brand-pn {
    font-size: 0.72rem;
    font-weight: 800;
    letter-spacing: 0.12em;
    color: #fff;
    white-space: nowrap;
  }
  .mobile-brand-dispatch {
    font-size: 0.68rem;
    font-weight: 800;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--brand);
    white-space: nowrap;
  }
  .mobile-brand-text .brand-name {
    font-size: 0.95rem;
    white-space: nowrap;
  }
  .mobile-topbar-right {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 72px;
    justify-content: flex-end;
  }
  .mobile-staff-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: #1c2128;
    border: 1px solid rgba(255, 255, 255, 0.14);
    color: #fff;
    display: grid;
    place-items: center;
    font-size: 0.68rem;
    font-weight: 700;
  }
  .alert-bell-mobile {
    width: 34px;
    height: 34px;
    background: rgba(255, 255, 255, 0.06);
    border-color: rgba(255, 255, 255, 0.16);
    color: #fff;
  }
  .mobile-page-title {
    /* Visually hidden; retained for a11y + mobile UI tests */
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
  }
  .mobile-nav-toggle {
    border-color: rgba(255, 255, 255, 0.18);
    background: rgba(255, 255, 255, 0.06);
    min-width: 44px;
  }
  .mobile-nav-toggle-label {
    display: none;
  }
  .mobile-nav-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 350;
    background: rgba(15, 30, 42, 0.45);
  }
  .mobile-nav-backdrop[hidden] {
    display: none !important;
  }
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: min(300px, 86vw);
    z-index: 400;
    transform: translateX(-105%);
    transition: transform 0.2s ease;
    overflow-y: auto;
    box-shadow: 8px 0 28px rgba(0, 0, 0, 0.45);
    padding-bottom: calc(24px + env(safe-area-inset-bottom, 0px));
  }
  .sidebar.is-open {
    transform: translateX(0);
  }
  .nav {
    flex-direction: column;
    flex-wrap: nowrap;
  }
  .nav a {
    min-height: 44px;
    display: flex;
    align-items: center;
    padding: 12px 14px;
  }
  .sidebar-foot { display: none; }
  .main { padding: 16px 14px calc(24px + var(--bottom-nav-height)); }
  .form-grid { grid-template-columns: 1fr; }
  .page-head { flex-direction: column; }
  .conn-grid { grid-template-columns: 1fr; }
  .conn-meta { grid-template-columns: 1fr; }

  .mobile-bottom-nav {
    display: grid;
    grid-template-columns: 1fr 1fr 64px 1fr 1fr;
    align-items: end;
    gap: 2px;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 320;
    min-height: var(--bottom-nav-height);
    padding: 8px 10px calc(8px + env(safe-area-inset-bottom, 0px));
    background: #ffffff;
    border-top: 1px solid rgba(16, 22, 28, 0.08);
    box-shadow: 0 -1px 0 rgba(16, 22, 28, 0.04), var(--shadow-md);
  }
  .mbnav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    min-height: 44px;
    padding: 4px 2px;
    border: 0;
    background: transparent;
    color: #7a8490;
    font: inherit;
    font-size: 0.68rem;
    font-weight: 600;
    letter-spacing: 0.01em;
    text-decoration: none;
    cursor: pointer;
  }
  .mbnav-item .icon {
    width: 20px;
    height: 20px;
    color: #8a939d;
  }
  .mbnav-item.active {
    color: var(--ink);
    font-weight: 700;
  }
  .mbnav-item.active .icon {
    color: var(--brand);
    opacity: 1;
  }
  .mbnav-item:hover,
  .mbnav-item:focus-visible {
    text-decoration: none;
    color: var(--ink);
  }
  .mbnav-item:focus-visible {
    outline: 2px solid rgba(200, 16, 46, 0.35);
    outline-offset: 2px;
    border-radius: 10px;
  }
  .mbnav-fab {
    width: 54px;
    height: 54px;
    margin: 0 auto 8px;
    border-radius: 50%;
    background: var(--brand);
    color: #fff;
    display: grid;
    place-items: center;
    text-decoration: none;
    box-shadow: 0 6px 16px rgba(200, 16, 46, 0.28);
    transform: translateY(-10px);
  }
  .mbnav-fab:hover {
    text-decoration: none;
    background: var(--brand-2);
    box-shadow: 0 8px 18px rgba(200, 16, 46, 0.32);
  }
  .mbnav-fab:active {
    background: #8f0b20;
    box-shadow: 0 3px 10px rgba(200, 16, 46, 0.24);
  }
  .mbnav-fab:focus-visible {
    text-decoration: none;
    outline: 2px solid rgba(200, 16, 46, 0.45);
    outline-offset: 3px;
  }
  .mbnav-fab-icon {
    width: 24px;
    height: 24px;
    stroke-width: 2.4;
  }
}

/* Phase 2.5 — assignment foundation */
.page-head-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

.filters-bar {
  flex-wrap: wrap;
  gap: 12px;
  align-items: flex-end;
}

.inline-filters {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: flex-end;
}

.inline-filters label {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: #80909b;
}

.inline-filters select,
.inline-filters input[type="search"] {
  min-width: 148px;
  min-height: 38px;
  padding: 8px 11px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  font: inherit;
  font-size: 0.88rem;
  font-weight: 500;
  background: #fff;
  color: var(--ink);
  box-shadow: var(--shadow-xs);
}

.inline-filters select:focus,
.inline-filters input[type="search"]:focus {
  outline: none;
  border-color: rgba(200, 16, 46, 0.35);
  box-shadow: 0 0 0 3px rgba(200, 16, 46, 0.12), var(--shadow-xs);
}

.row-unassigned {
  background: rgba(166, 107, 18, 0.08);
}

.row-unassigned td:first-child {
  box-shadow: inset 3px 0 0 var(--amber);
}

.dot.unassigned {
  background: var(--amber);
}

.pill-assign-unassigned {
  background: #f7efd9;
  color: #7a5310;
}

.pill-assign-own-truck {
  background: #e7f5ee;
  color: var(--good);
}

.pill-assign-brokered {
  background: #e8f1f8;
  color: #355064;
}

.form-card {
  max-width: 640px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow);
  display: grid;
  gap: 14px;
}

.form-card label {
  display: grid;
  gap: 6px;
  font-size: 0.9rem;
  font-weight: 600;
}

.form-card .field-hint {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--muted, #5b6b7c);
}

.form-card .external-trailer-fields {
  display: grid;
  gap: 14px;
  padding: 14px;
  border: 1px dashed var(--line);
  border-radius: 10px;
  background: rgba(248, 250, 252, 0.9);
}

.form-card .check {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
}

.form-card .check input {
  width: auto;
}

.form-card input,
.form-card select,
.form-card textarea {
  font: inherit;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.form-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 4px;
}

.flash {
  padding: 12px 14px;
  border-radius: 10px;
  margin-bottom: 16px;
  font-weight: 500;
}

.flash-ok {
  background: #d9ebe1;
  color: var(--good);
}

.flash-err {
  background: #f3d6da;
  color: var(--red);
}

.history-list {
  margin: 0;
  padding-left: 18px;
  font-size: 0.85rem;
}

.row-active-assign {
  background: rgba(31, 107, 74, 0.06);
}

.inline-admin {
  display: flex;
  gap: 6px;
  align-items: center;
  margin-bottom: 6px;
}

.inline-admin input {
  max-width: 140px;
  padding: 4px 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  font: inherit;
  font-size: 0.85rem;
}

@media (max-width: 900px) {
  .form-row { grid-template-columns: 1fr; }
}

/* Non-Amazon / multi-channel ops */
.form-card-wide { max-width: 820px; }
.ops-filters {
  flex-wrap: wrap;
  row-gap: 2px;
}
.detail-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}
.detail-card {
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow);
}
.detail-card h2 {
  margin: 0 0 12px;
  font-size: 1rem;
}
.detail-dl {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 8px 12px;
  margin: 0;
}
.detail-dl dt {
  color: var(--muted);
  font-size: 0.82rem;
}
.detail-dl dd { margin: 0; font-weight: 600; }
.attach-form { margin-bottom: 18px; max-width: 720px; }
@media (max-width: 900px) {
  .detail-grid { grid-template-columns: 1fr; }
  .detail-dl { grid-template-columns: 1fr; }
}

/* Master Locations */
.page-actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.loc-toolbar { gap: 10px; flex-wrap: wrap; }
.loc-search-input { min-width: 220px; flex: 1; }
.loc-meta {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
  margin: 0 0 28px;
  padding: 18px 20px;
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.loc-stats {
  display: flex;
  gap: 28px;
  margin: 12px 0 16px;
  flex-wrap: wrap;
}
.stat-n {
  display: block;
  font-size: 1.4rem;
  font-weight: 700;
  font-family: var(--mono);
  color: var(--brand);
}
.loc-history h2,
.loc-admin-actions h2 {
  margin: 0 0 12px;
  font-size: 1.1rem;
}
.unknown-card { margin-bottom: 18px; }
.unknown-head {
  display: flex;
  gap: 14px;
  align-items: baseline;
  margin-bottom: 8px;
  flex-wrap: wrap;
}
.unknown-code { font-size: 1.15rem; font-weight: 700; }
.loc-field { position: relative; }
.loc-typeahead { position: relative; }
.loc-typeahead-list {
  position: absolute;
  z-index: 40;
  left: 0;
  right: 0;
  top: calc(100% + 4px);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: var(--shadow);
  max-height: 260px;
  overflow: auto;
  padding: 6px;
}
.loc-typeahead-item {
  display: block;
  width: 100%;
  text-align: left;
  border: 0;
  background: transparent;
  padding: 10px 12px;
  border-radius: 8px;
  cursor: pointer;
  font: inherit;
  color: var(--ink);
}
.loc-typeahead-item:hover,
.loc-typeahead-item:focus {
  background: #e8f1f6;
  outline: none;
}
.loc-typeahead-create {
  color: var(--brand-2);
  font-weight: 600;
  border-top: 1px solid var(--line);
  margin-top: 4px;
  border-radius: 0 0 8px 8px;
}
.loc-typeahead-selected {
  margin-top: 6px;
  font-size: 0.85rem;
}
.loc-typeahead-hint {
  padding: 6px 10px;
  font-size: 0.8rem;
  border-bottom: 1px solid var(--border, #ddd);
}
@media (max-width: 900px) {
  .loc-meta { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 600px) {
  .loc-meta { grid-template-columns: 1fr; }
}

/* ---- Fleet Availability ---- */
.fleet-filters {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 12px;
  align-items: end;
  margin: 0 0 20px;
  padding: 16px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.fleet-filters label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.8rem;
  color: var(--muted);
}
.fleet-filters label.check {
  flex-direction: row;
  align-items: center;
  gap: 8px;
  padding-bottom: 8px;
}
.fleet-filters input,
.fleet-filters select {
  font: inherit;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
}
.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}
.stack-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.stack-form label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.85rem;
  color: var(--muted);
}
.stack-form input,
.stack-form select {
  font: inherit;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
}
.correct-pop {
  position: relative;
}
.correct-pop > summary {
  list-style: none;
  cursor: pointer;
}
.correct-pop > summary::-webkit-details-marker { display: none; }
.correct-form {
  position: absolute;
  right: 0;
  z-index: 5;
  min-width: 240px;
  padding: 12px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.correct-form label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.8rem;
  color: var(--muted);
}
.correct-form input,
.correct-form select {
  font: inherit;
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
}
.recommend-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-bottom: 12px;
}
.recommend-grid .big {
  font-size: 1.25rem;
  font-weight: 600;
  margin-top: 4px;
}
.list-tight {
  margin: 0 0 16px;
  padding-left: 18px;
}
.banner.good {
  background: #e6f4ec;
  color: var(--good);
  border: 1px solid #b7dcc6;
  padding: 10px 14px;
  border-radius: 10px;
  margin-bottom: 14px;
}
.banner.bad,
.banner.warn {
  background: #f8ecee;
  color: var(--red);
  border: 1px solid #e0b8be;
  padding: 10px 14px;
  border-radius: 10px;
  margin-bottom: 14px;
}
.banner.warn {
  background: #faf3e6;
  color: var(--amber);
  border-color: #e8d2a8;
}
@media (max-width: 800px) {
  .grid-2 { grid-template-columns: 1fr; }
  .recommend-grid { grid-template-columns: 1fr; }
}

/* Fleet board — simple operational badges */
.panel-company { border-left: 4px solid var(--brand-2); }
.panel-leased { border-left: 4px solid var(--amber); }
.panel-external { border-left: 4px solid #8a4b2a; }
.trailer-row.trailer-overdue { background: #fdf2f3; }
.pill-external,
.pill-own-carrier {
  background: #f3e6dc;
  color: #6b3a1f;
  margin-left: 4px;
  font-size: 0.72rem;
}
.pill-leased,
.pill-own-leased {
  background: #f7edd8;
  color: #7a5410;
  margin-left: 4px;
  font-size: 0.72rem;
}
.pill-own-company {
  background: #dcecf5;
  color: var(--brand);
  margin-left: 4px;
  font-size: 0.72rem;
}
.pill-own-review,
.pill-ownership-required {
  background: #f3e3c8;
  color: #8a5a12;
  margin-left: 4px;
  font-size: 0.72rem;
}
.trailer-ownership-required {
  background: rgba(243, 227, 200, 0.35);
}
.pill-return {
  background: #f7e7c6;
  color: var(--amber);
  margin-left: 6px;
  font-size: 0.72rem;
}
.pill-empty { background: #e8eef2; color: var(--muted); }
.pill-loaded { background: #dcecf5; color: var(--brand); }
.pill-fleet-available { background: #d7efe2; color: var(--good); }
.pill-fleet-assigned { background: #dcecf5; color: var(--brand); }
.pill-fleet-in-transit { background: #f7e7c6; color: var(--amber); }
.pill-fleet-maintenance,
.pill-fleet-out-of-service { background: #f6d5d9; color: var(--red); }
.pill-fleet-unknown,
.pill-fleet-off-duty,
.pill-fleet-home { background: #e8eef2; color: var(--muted); }

.pill-motive-live { background: #d7efe2; color: var(--good); }
.pill-motive-recent { background: #dcecf5; color: var(--brand); }
.pill-motive-stale { background: #f7e7c6; color: var(--amber); }
.pill-motive-not-linked { background: #e8eef2; color: var(--muted); }
.pill-motive-motive-offline,
.pill-motive-offline { background: #f6d5d9; color: var(--red); }
.pill-motive-motive-not-configured,
.pill-motive-not-configured { background: #e8eef2; color: var(--muted); }

.motive-fleet-status {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem 1.25rem;
  margin: 0 0 1rem;
  padding: 0.75rem 1rem;
  border: 1px solid var(--border, #d5dee5);
  border-radius: 6px;
  background: linear-gradient(180deg, #f7fafc 0%, #eef3f7 100%);
}
.motive-fleet-status-title {
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 0.15rem;
}
.motive-fleet-status-message {
  font-size: 0.95rem;
  color: var(--text, #1a2430);
}
.motive-fleet-status-live {
  color: var(--brand, #1f5f8b);
  font-weight: 600;
}
.motive-fleet-status.is-failed .motive-fleet-status-message {
  color: var(--red, #a12834);
}
.motive-fleet-status.is-success .motive-fleet-status-message {
  color: var(--good, #1f6b45);
}
.motive-fleet-status-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}
.motive-fleet-status-actions [hidden] {
  display: none !important;
}

.flash-warn {
  background: #f7e7c6;
  color: #6a4e16;
  border: 1px solid #e6d2a8;
  padding: 0.65rem 0.85rem;
  border-radius: 6px;
  margin-bottom: 0.85rem;
}
.warn-inline {
  color: var(--amber);
  font-size: 0.75rem;
  margin-top: 4px;
}
.fleet-toolbar .inline-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: end;
}
.fleet-toolbar .check-inline {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.85rem;
  color: var(--muted);
  padding-bottom: 8px;
}
.fleet-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

/* ---- Fleet command center (Trips sibling) ---- */
.fleet-page-head .lede {
  max-width: 42rem;
}
.fleet-summary-grid {
  margin-top: 4px;
}
.summary-card-fleet-total::before { background: #5c6670; }
.summary-card-fleet-total .summary-icon {
  background: #f2f4f6;
  color: #5c6670;
}
.summary-card-fleet-available::before { background: #1f9d57; }
.summary-card-fleet-available .summary-icon {
  background: #eef8f2;
  color: #1f9d57;
}
.summary-card-fleet-onload::before { background: #2f6fed; }
.summary-card-fleet-onload .summary-icon {
  background: #eef3fb;
  color: #2f6fed;
}
.summary-card-fleet-review::before { background: #d97706; }
.summary-card-fleet-review .summary-icon {
  background: #fbf4ea;
  color: #d97706;
}
.summary-card-fleet-oos::before { background: var(--brand); }
.summary-card-fleet-oos .summary-icon {
  background: #faf0f2;
  color: var(--brand);
}

.fleet-filters-wrap {
  margin-bottom: 14px;
}
.fleet-section {
  margin-bottom: 16px;
}
.fleet-card-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.fleet-card {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr);
  gap: 12px 14px;
  align-items: start;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px 16px 12px 14px;
  position: relative;
  overflow: hidden;
}
.fleet-card::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: #b7c2cb;
}
.fleet-card-available::before { background: #1f9d57; }
.fleet-card-assigned::before { background: #2f6fed; }
.fleet-card-review::before { background: #d97706; }
.fleet-card-oos::before { background: var(--brand); }
.fleet-card-unknown::before { background: #8a939d; }

.fleet-card-icon {
  width: 40px;
  height: 40px;
  border-radius: 9px;
  display: grid;
  place-items: center;
  background: #f2f4f6;
  color: #5c6670;
  margin-top: 2px;
}
.fleet-card-available .fleet-card-icon {
  background: #eef8f2;
  color: #1f9d57;
}
.fleet-card-assigned .fleet-card-icon {
  background: #eef3fb;
  color: #2f6fed;
}
.fleet-card-review .fleet-card-icon {
  background: #fbf4ea;
  color: #d97706;
}
.fleet-card-oos .fleet-card-icon {
  background: #faf0f2;
  color: var(--brand);
}
.fleet-card-icon .icon {
  width: 18px;
  height: 18px;
}
.fleet-card-body {
  min-width: 0;
}
.fleet-card-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
  margin-bottom: 10px;
}
.fleet-card-kicker {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--muted);
}
.fleet-card-title {
  font-size: 1.15rem;
  font-weight: 750;
  color: var(--ink);
  letter-spacing: -0.02em;
  text-decoration: none;
  line-height: 1.2;
}
a.fleet-card-title:hover { color: var(--brand-2); }
.fleet-card-sub {
  color: var(--muted);
  font-size: 0.82rem;
  margin-top: 2px;
}
.fleet-card-badge {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  flex-shrink: 0;
}
.fleet-card-waiting {
  font-size: 0.72rem;
}
.fleet-card-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px 14px;
  margin: 0 0 12px;
}
.fleet-card-grid > div {
  min-width: 0;
}
.fleet-card-grid dt {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 3px;
}
.fleet-card-grid dd {
  margin: 0;
  font-size: 0.9rem;
  color: var(--ink);
  line-height: 1.35;
}
.fleet-card-grid dd a {
  color: var(--brand);
  font-weight: 700;
  text-decoration: none;
}
.fleet-card-grid dd a:hover { color: var(--brand-2); }
.fleet-loc-line {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.fleet-loc-icon {
  display: inline-flex;
  color: var(--muted);
}
.fleet-loc-icon .icon {
  width: 14px;
  height: 14px;
}
.fleet-hos {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.fleet-hos-label {
  display: inline-block;
  min-width: 2.6rem;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 600;
}
.fleet-card-actions {
  margin-top: 2px;
  padding-top: 10px;
  border-top: 1px solid #eef1f4;
  background: transparent;
}
.fleet-more-wrap {
  display: contents;
}
.fleet-more-wrap.is-collapsed > * {
  display: none !important;
}
.fleet-more-wrap.is-expanded {
  display: contents;
}
.fleet-card-more-btn {
  margin-top: 8px;
}
.fleet-empty {
  text-align: center;
  padding: 36px 20px;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  background: #fbfcfd;
}
.fleet-empty-title {
  font-weight: 700;
  font-size: 1.05rem;
  margin-bottom: 6px;
}
.fleet-empty .btn {
  margin-top: 12px;
}

@media (max-width: 1100px) {
  .fleet-card-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}
@media (max-width: 900px) {
  .fleet-card {
    grid-template-columns: 36px minmax(0, 1fr);
    padding: 12px;
  }
  .fleet-card-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .fleet-card-title {
    font-size: 1.05rem;
  }
  .fleet-card-actions .btn,
  .fleet-card-actions .inline-action .btn {
    flex: 1 1 calc(50% - 6px);
    min-width: 7.5rem;
    min-height: 44px;
  }
}
.inline-action { display: inline; margin: 0; }
.suggest-reason {
  margin: 8px 0 16px;
  line-height: 1.45;
}
.suggest-alts {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.suggest-alts li {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}
.suggest-alts li:last-child { border-bottom: 0; }
.form-section-title {
  margin: 8px 0 4px;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--ink);
  grid-column: 1 / -1;
}
.field-hint {
  display: block;
  margin-top: 4px;
  font-size: 0.8rem;
  color: var(--muted);
}
.assign-card-wide {
  max-width: 860px;
}
.assign-block {
  margin: 8px 0 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.55);
}
@media (max-width: 800px) {
  .suggest-alts li { flex-direction: column; align-items: flex-start; }
}

@media (max-width: 900px) {
  .fleet-actions {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: stretch;
    gap: 6px;
  }
  .fleet-actions .btn,
  .fleet-actions .inline-action .btn {
    flex: 1 1 calc(33.33% - 6px);
    min-width: 7.5rem;
    min-height: 44px;
    white-space: nowrap;
  }
  .fleet-toolbar .inline-filters {
    width: 100%;
  }
  .fleet-toolbar .inline-filters label {
    flex: 1 1 100%;
  }
  .fleet-toolbar .inline-filters input,
  .fleet-toolbar .inline-filters select {
    width: 100%;
    min-width: 0;
  }
  .fleet-toolbar .fleet-filter-apply-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    width: 100%;
    align-items: center;
  }
  .filters-bar .segmented {
    display: flex;
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  .filters-bar .segmented a {
    flex: 0 0 auto;
    white-space: nowrap;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
  }
  .page-head-actions {
    width: 100%;
  }
  .page-head-actions .btn,
  .page-head-actions .inline-action .btn {
    flex: 1 1 calc(50% - 8px);
    min-height: 44px;
    white-space: nowrap;
  }
}

/* Phase 5A — carrier assignment + mobile Trips cards */
.carrier-driver-name {
  font-weight: 700;
}
.carrier-company-name {
  margin-top: 2px;
}
.rates-cell {
  white-space: normal;
  font-size: 0.82rem;
  line-height: 1.35;
}
.carrier-inline-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin: -6px 0 12px;
}
.form-inline-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.trips-mobile {
  display: none;
}

.trip-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px 14px 12px;
  margin-bottom: 12px;
  border-left: 3px solid transparent;
}
.trip-card.row-urgent,
.trip-card.row-red,
.trip-card.row-late {
  border-left-color: var(--brand);
}
.trip-card.row-amber {
  border-left-color: var(--amber);
}
.trip-card.row-green {
  border-left-color: var(--green);
}
.trip-card.row-unassigned {
  border-left-color: #8aa3b5;
}
.trip-card-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
}
.trip-card-vrid {
  font-weight: 700;
  font-size: 1.05rem;
  text-decoration: none;
  color: var(--brand-2);
  letter-spacing: -0.01em;
}
.trip-card-company {
  color: var(--muted);
  font-size: 0.8rem;
  margin-top: 3px;
  font-weight: 500;
}
/* Customer prominence moved to .trip-customer in route stack. */
.trip-card-time {
  text-align: right;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
}
.trip-card-route {
  margin: 0;
  padding: 0;
  background: transparent;
  border-radius: 0;
  font-weight: 600;
  font-size: 0.98rem;
}
.trip-card-assign {
  margin-bottom: 10px;
  display: grid;
  gap: 6px;
}
.trip-card-assign .pill {
  margin-bottom: 0;
  width: fit-content;
}
.trip-card-rates {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  font-size: 0.8rem;
  margin-bottom: 8px;
  padding: 10px 0;
  border-top: 1px solid #e7ebef;
  border-bottom: 1px solid #e7ebef;
  color: var(--muted);
}
.trip-card-status {
  margin-bottom: 10px;
  font-size: 0.8rem;
}
.trip-card-actions {
  gap: 8px;
  margin-top: 2px;
}
.trip-card-actions .btn,
.trip-card-actions .btn-small {
  min-height: 38px;
  padding: 8px 13px;
}
.trip-card-actions.is-collapsible .is-secondary-action {
  display: none;
}
.trip-card-actions.is-collapsible.is-expanded .is-secondary-action {
  display: inline-flex;
}
.trip-card-more-btn {
  margin-top: 6px;
  width: 100%;
  min-height: 40px;
}

@media (max-width: 1100px) {
  .summary-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 900px) {
  .summary-grid {
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: minmax(148px, 72%);
    grid-template-columns: none;
    overflow-x: auto;
    gap: 10px;
    padding-bottom: 4px;
    scroll-snap-type: x proximity;
    -webkit-overflow-scrolling: touch;
  }
  .summary-card {
    scroll-snap-align: start;
    min-height: 96px;
    padding: 12px;
  }
  .summary-value {
    font-size: 1.55rem;
  }
  .page-head-secondary {
    display: none;
  }
  .trips-page-head .lede {
    font-size: 0.84rem;
  }
  .filter-group {
    align-items: flex-start;
    flex-direction: column;
  }
  .filter-group-label {
    min-width: 0;
  }
  .filter-inline-label {
    margin-left: 0;
  }
  .trips-desktop {
    display: none;
  }
  .trips-mobile {
    display: block;
  }
  .day-block .table-wrap.trips-desktop {
    display: none;
  }
  .page-head-actions .btn {
    min-height: 40px;
  }
}



/* WhatsApp freight inbox */
.wa-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 20px;
}
.wa-tab {
  display: inline-block;
  padding: 8px 14px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.7);
  color: inherit;
  text-decoration: none;
  font-weight: 600;
  font-size: 0.9rem;
}
.wa-tab.active {
  background: var(--ink, #16324f);
  color: #fff;
  border-color: transparent;
}
.wa-card-list {
  display: grid;
  gap: 14px;
}
.wa-card {
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow);
}
.wa-card-top {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
}
.wa-card-title {
  font-weight: 700;
  font-size: 1.05rem;
}
.wa-card-time {
  font-size: 0.82rem;
  color: var(--muted);
  white-space: nowrap;
}
.wa-card-preview {
  margin: 10px 0 12px;
  color: var(--ink, #16324f);
  line-height: 1.45;
}
.wa-card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 12px;
}
.wa-card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}
@media (max-width: 900px) {
  .wa-card-top { flex-direction: column; }
  .wa-card-actions { width: 100%; }
  .wa-card-actions .btn { flex: 1 1 auto; text-align: center; }
}

.wa-map-panel {
  margin-top: 16px;
  padding: 12px 14px;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  background: rgba(255,255,255,0.55);
}
.wa-map-panel summary {
  cursor: pointer;
  font-weight: 600;
  margin-bottom: 8px;
}
.check-confirm {
  display: flex;
  gap: 8px;
  align-items: center;
  margin: 12px 0;
  font-weight: 600;
}

/* ---- Shared mobile list cards (Trips visual standard) ---- */
.desktop-only { display: block; }
.table-wrap.desktop-only { display: block; }
.mobile-only { display: none; }

.mobile-card {
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px 14px 12px;
  margin-bottom: 12px;
}
.mobile-card-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
}
.mobile-card-title {
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--ink);
  text-decoration: none;
}
.mobile-card-title:hover { text-decoration: none; }
.mobile-card-sub {
  color: var(--muted);
  font-size: 0.85rem;
  margin-top: 2px;
}
.mobile-card-badge {
  text-align: right;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  flex-shrink: 0;
}
.mobile-card-fields {
  margin: 10px 0 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.9rem;
}
.mobile-card-fields .field-label {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 600;
  margin-right: 4px;
}
.mobile-card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: stretch;
  margin-top: 4px;
}
.mobile-card-actions .btn,
.mobile-card-actions .inline-action .btn {
  flex: 1 1 calc(33.33% - 6px);
  min-width: 7.5rem;
  min-height: 44px;
  white-space: nowrap;
}
.mobile-card-actions .inline-action {
  display: contents;
}

.fleet-mobile,
.drivers-mobile,
.submissions-mobile,
.deleted-mobile,
.locations-mobile,
.customers-mobile,
.carriers-mobile,
.staff-mobile,
.motive-mapping-mobile,
.gmail-review-mobile,
.billing-mobile {
  display: none;
}

.billing-summary {
  grid-template-columns: repeat(6, minmax(0, 1fr));
  margin-bottom: 16px;
}
a.billing-summary-card {
  text-decoration: none;
  color: inherit;
  display: block;
  cursor: pointer;
}
a.billing-summary-card.is-active {
  border-color: var(--brand);
  box-shadow: 0 0 0 1px rgba(200, 16, 46, 0.25);
}
.billing-summary-card .summary-sub {
  margin-top: 4px;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--muted);
}
.billing-summary-not_invoiced::before { background: #5c6670; }
.billing-summary-draft::before { background: #d97706; }
.billing-summary-ready::before { background: #2f6fed; }
.billing-summary-sent::before { background: #7c3aed; }
.billing-summary-overdue::before { background: var(--brand); }
.billing-summary-paid::before { background: #1f9d57; }

.billing-company-tabs {
  margin: 0 0 14px;
}
.billing-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}
.billing-status-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  align-items: center;
  border: 0;
  margin: 0;
  padding: 0;
  min-width: 0;
}
.billing-result-meta {
  margin: 0 0 12px;
  font-size: 0.88rem;
}
.billing-amount-label {
  font-size: 0.78rem;
}
.billing-pill-not_invoiced { background: #eef1f4; color: #3a4450; }
.billing-pill-draft { background: #fff4e5; color: #9a5b00; }
.billing-pill-ready { background: #e8f0ff; color: #1d4ed8; }
.billing-pill-sent { background: #f3e8ff; color: #6b21a8; }
.billing-pill-overdue { background: #fde8eb; color: #9f1239; }
.billing-pill-paid { background: #e7f8ef; color: #166534; }
.billing-pill-void { background: #f1f1f1; color: #525252; }
.billing-pagination {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 16px 0 8px;
  flex-wrap: wrap;
}
.billing-table th,
.billing-table td {
  white-space: nowrap;
}
.billing-table td:nth-child(3),
.billing-table td.actions {
  white-space: normal;
}

.customers-summary {
  grid-template-columns: repeat(5, minmax(0, 1fr));
}

.carriers-summary {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.customers-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.customers-filter-check {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.9rem;
  color: var(--muted);
  white-space: nowrap;
}

.customers-load-note {
  margin: 0 0 12px;
  font-size: 0.88rem;
}

.customers-anyway-box {
  margin-top: 14px;
  padding: 14px;
  border: 1px solid #e6d3a8;
  border-radius: var(--radius);
  background: #fffaf0;
}

.customers-match-panel {
  margin-bottom: 18px;
}

.customers-alias-form {
  margin-top: 16px;
}

.customers-dup-group {
  margin-bottom: 16px;
}

.customers-merged-banner {
  border-left: 4px solid #c05621;
  background: #fff7ed;
  color: #7b341e;
}

.customers-merge-steps {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 20px;
  list-style: none;
  padding: 0;
  margin: 0 0 18px;
}

.customers-merge-steps .is-current {
  color: var(--text, #1a202c);
  font-weight: 600;
}

.customers-merge-survivor {
  border: 1px solid #d9e2ec;
  border-radius: 8px;
  padding: 12px 14px;
  margin: 14px 0;
}

.customers-merge-choice {
  display: block;
  margin: 8px 0;
}

.customers-merge-compare .customers-merge-conflict td {
  background: #fff8e6;
}

.customers-merge-impact {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 10px 16px;
  margin: 16px 0;
}

.customers-merge-impact > div {
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 10px 12px;
}

.customers-merge-impact dt {
  font-size: 0.85rem;
  color: #52606d;
}

.customers-merge-impact dd {
  margin: 4px 0 0;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.inline-choice {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-right: 10px;
}

.pill-muted {
  background: #eef2f6;
  color: #52606d;
}

.inline-action {
  display: inline-block;
  margin: 0;
}

.carriers-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.carriers-filter-check {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.9rem;
  color: var(--muted);
  white-space: nowrap;
}

.carriers-load-note {
  margin: 0 0 12px;
  font-size: 0.88rem;
}

.carriers-anyway-box {
  margin-top: 14px;
  padding: 14px;
  border: 1px solid #e6d3a8;
  border-radius: var(--radius);
  background: #fffaf0;
}

.carriers-match-panel {
  margin-bottom: 18px;
}

.carriers-alias-form,
.carriers-driver-form {
  margin-top: 16px;
}

.carriers-dup-group {
  margin-bottom: 16px;
}

.compliance-pill-wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

@media (max-width: 900px) {
  .customers-summary,
  .carriers-summary {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .customers-toolbar .loc-search-input,
  .carriers-toolbar .loc-search-input {
    width: 100%;
    min-width: 0;
  }
  #customer-form .form-actions,
  #carrier-form .form-actions,
  #carrier-driver-form .form-actions {
    bottom: calc(var(--bottom-nav-height) + env(safe-area-inset-bottom, 0px));
  }
  .customers-match-panel .actions,
  .customers-match-panel .inline-action .btn,
  .carriers-match-panel .actions,
  .carriers-match-panel .inline-action .btn {
    min-height: 44px;
  }
  .customers-mobile,
  .customers-desktop,
  .carriers-mobile,
  .carriers-desktop,
  .main {
    overflow-x: hidden;
  }
}

.motive-summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}
.motive-summary-card {
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px;
}
.motive-summary-card .label {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 600;
}
.motive-summary-card .value {
  font-weight: 700;
  font-size: 1.2rem;
  margin-top: 4px;
}

.email-excerpt-details {
  margin: 0 0 16px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #f0f4f7;
  overflow: hidden;
}
.email-excerpt-details summary {
  cursor: pointer;
  font-weight: 600;
  padding: 12px 14px;
  min-height: 44px;
  display: flex;
  align-items: center;
}
.email-excerpt-details .email-excerpt {
  margin: 0;
  border: 0;
  border-radius: 0;
  border-top: 1px solid var(--line);
  max-height: 240px;
}

.notice-card-preview {
  margin: 8px 0 10px;
  font-size: 0.9rem;
  line-height: 1.4;
  color: var(--ink);
}

.load-detail-actions-mobile {
  display: none;
}

@media (max-width: 900px) {
  .desktop-only,
  .table-wrap.desktop-only,
  .fleet-desktop,
  .drivers-desktop,
  .submissions-desktop,
  .deleted-desktop,
  .locations-desktop,
  .customers-desktop,
  .carriers-desktop,
  .staff-desktop,
  .motive-mapping-desktop,
  .billing-desktop {
    display: none !important;
  }
  .mobile-only,
  .fleet-mobile,
  .drivers-mobile,
  .submissions-mobile,
  .deleted-mobile,
  .locations-mobile,
  .customers-mobile,
  .carriers-mobile,
  .staff-mobile,
  .motive-mapping-mobile,
  .gmail-review-mobile,
  .billing-mobile {
    display: block;
  }
  .billing-summary {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .billing-status-filters {
    width: 100%;
  }
  .billing-mobile-card .mobile-card-fields {
    gap: 4px;
  }

  .form-card,
  .form-card-wide,
  .form-grid,
  .assign-card-wide {
    max-width: 100%;
    width: 100%;
  }
  .form-row {
    grid-template-columns: 1fr;
  }
  .form-card input,
  .form-card select,
  .form-card textarea,
  .form-grid input,
  .form-grid select,
  .form-grid textarea,
  .inline-filters select,
  .inline-filters input {
    max-width: 100%;
    width: 100%;
    min-width: 0;
  }
  .form-actions,
  .form-grid .form-actions,
  .form-card .form-actions {
    position: sticky;
    bottom: 0;
    z-index: 20;
    flex-wrap: wrap;
    gap: 8px;
    margin: 12px -4px 0;
    padding: 12px 4px;
    background: linear-gradient(180deg, rgba(247, 250, 252, 0) 0%, rgba(247, 250, 252, 0.96) 28%, rgba(247, 250, 252, 1) 100%);
  }
  .form-actions .btn {
    min-height: 44px;
    flex: 1 1 auto;
    white-space: nowrap;
  }
  /* Documents actions live in a table — keep them compact, never sticky. */
  .documents-table .document-actions {
    position: static;
    z-index: auto;
    margin: 0;
    padding: 0;
    background: none;
  }
  .documents-table .document-actions .btn {
    flex: 0 1 auto;
    min-height: 36px;
  }

  .motive-summary-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .page-head-actions.load-detail-actions-desktop {
    display: none;
  }
  .load-detail-actions-mobile {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin: 0 0 16px;
  }
  .load-detail-actions-mobile .btn {
    flex: 1 1 calc(50% - 6px);
    min-height: 44px;
    white-space: nowrap;
  }

  .review-panel {
    padding: 14px;
  }
  .review-panel .form-actions {
    width: 100%;
  }

  .timeline-table,
  .status-events-table {
    display: block;
  }

  /* Searchable select dropdowns stay within viewport */
  .loc-typeahead,
  .customer-typeahead,
  .carrier-typeahead {
    max-width: 100%;
  }
  .loc-typeahead-list,
  .typeahead-menu,
  .autocomplete-list {
    max-width: min(100vw - 32px, 100%);
    left: 0 !important;
    right: auto;
    width: 100%;
  }

  .loc-toolbar {
    flex-direction: column;
    align-items: stretch;
  }
  .loc-toolbar input,
  .loc-toolbar select,
  .loc-toolbar .btn {
    width: 100%;
    min-height: 44px;
  }

  .word-safe,
  .mobile-card,
  .trip-card,
  .detail-card,
  .wa-card,
  .review-panel {
    overflow-wrap: anywhere;
    word-break: normal;
  }
  .mobile-card-actions .btn,
  .fleet-actions .btn,
  .trip-card-actions .btn {
    word-break: keep-all;
    overflow-wrap: normal;
  }
}

/* Payroll Zones & Payable Miles Matrix (PR B) */
.payroll-miles-filters {
  flex-wrap: wrap;
  gap: 8px 12px;
  align-items: center;
}
.payroll-miles-filters .check {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.875rem;
  color: var(--muted);
  white-space: nowrap;
}
.payroll-miles-filters .check input {
  width: 1rem;
  height: 1rem;
}
.inline-form {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin: 0;
}
.table.loads td.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}
.payroll-sticky-form .form-actions {
  position: sticky;
  bottom: 0;
  background: var(--panel);
  padding-top: 12px;
  padding-bottom: 4px;
  border-top: 1px solid var(--line);
  z-index: 2;
}
/* Driver Pay Rate History — card layout (desktop + mobile) */
.page-head-pay-rates {
  align-items: flex-start;
  gap: 16px;
}
.page-head-title-row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px 16px;
  width: 100%;
}
.btn-add-rate {
  font-size: 1.05rem;
  padding: 12px 18px;
  white-space: nowrap;
}
.pay-rate-section {
  margin-top: 20px;
}
.pay-rate-section-title {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 12px;
  font-size: 1rem;
}
.pay-rate-card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px;
}
.pay-rate-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.pay-rate-card-current {
  border-color: #2f9e6a;
  box-shadow: 0 0 0 1px rgba(47, 158, 106, 0.18);
}
.pay-rate-card-future {
  border-color: #3b7dd8;
}
.pay-rate-card-ended,
.pay-rate-card-history {
  border-color: #b0b6bf;
}
.pay-rate-card-inactive {
  border-color: #d4883a;
}
.pay-rate-card-needs-review {
  border-color: #c9a227;
}
.pay-rate-card-type {
  margin: 8px 0 4px;
  font-size: 1.15rem;
}
.pay-rate-card-amount {
  font-size: 1.35rem;
  font-weight: 650;
}
.pay-rate-card-meta {
  display: grid;
  gap: 8px;
  margin: 0;
}
.pay-rate-card-meta dt {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  margin: 0 0 2px;
}
.pay-rate-card-meta dd {
  margin: 0;
}
.pay-rate-card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: auto;
  padding-top: 4px;
}
.rate-status-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 4px 8px;
  border-radius: 999px;
  border: 1px solid transparent;
}
.rate-status-badge::before {
  content: "";
  width: 0.55em;
  height: 0.55em;
  border-radius: 50%;
  background: currentColor;
}
.rate-status-current {
  color: #1f7a4d;
  background: #e8f7ef;
  border-color: #b7e0c8;
}
.rate-status-future {
  color: #1f5fad;
  background: #e8f1fc;
  border-color: #b7d0f0;
}
.rate-status-ended,
.rate-status-history {
  color: #5c6570;
  background: #eef0f3;
  border-color: #d5d9df;
}
.rate-status-inactive {
  color: #9a5b12;
  background: #fff1e0;
  border-color: #f0c48a;
}
.rate-status-needs-review {
  color: #8a6a10;
  background: #fff8e1;
  border-color: #e6d28a;
}
.pay-rate-empty {
  display: grid;
  gap: 12px;
  justify-items: start;
}
.payroll-summary-card .payroll-current-rate {
  font-size: 1.2rem;
  font-weight: 650;
}
.pay-rate-replacement-box {
  text-align: left;
}
.status-text {
  font-weight: 600;
}
@media (max-width: 900px) {
  .page-head-title-row {
    flex-direction: column;
    align-items: stretch;
  }
  .btn-add-rate {
    width: 100%;
    text-align: center;
  }
  .pay-rate-card-grid {
    grid-template-columns: 1fr;
  }
  .payroll-sticky-form .form-actions {
    bottom: calc(var(--bottom-nav-height) + env(safe-area-inset-bottom, 0px));
  }
  .payroll-miles-filters {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }
  .payroll-miles-filters .loc-search-input,
  .payroll-miles-filters button[type="submit"] {
    grid-column: 1 / -1;
  }
  .payroll-miles-filters .check {
    white-space: normal;
  }
  .inline-form {
    flex-direction: column;
    align-items: stretch;
  }
  .inline-form select {
    width: 100%;
    min-height: 44px;
  }
}

/* Driver portal / payroll history responsive helpers (PR #71) */
.desktop-only { display: block; }
.mobile-only { display: none; }
@media (max-width: 820px) {
  .desktop-only { display: none !important; }
  .mobile-only { display: block !important; }
}

/* Staff Driver Pay Period workspace */
.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
.alert-banner.info {
  background: #e8f1f8;
  border-color: #8eb4d4;
  color: #1d3557;
}
.page-head-pay-period {
  margin-bottom: 16px;
}
.pay-period-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 20px;
  align-items: flex-end;
  justify-content: space-between;
  margin: 0 0 16px;
}
.pay-period-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.pay-period-company-form label,
.pay-employer-form label,
.pay-employer-change-form label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.9rem;
}
.pay-period-company-form select,
.pay-employer-form select,
.pay-employer-change-form select {
  min-width: 220px;
  min-height: 40px;
}
.pay-period-employer {
  margin: 0 0 16px;
  display: grid;
  gap: 12px;
}
.pay-employer-form,
.pay-employer-change-form,
.pay-employer-selected {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 16px;
  align-items: flex-end;
}
.pay-employer-selected {
  background: linear-gradient(180deg, #f7f9fc 0%, #eef3f8 100%);
  border: 1px solid #d5deea;
  padding: 14px 16px;
}
.pay-period-audit {
  margin: 0 0 24px;
}
.pay-audit-details > summary {
  list-style: none;
  cursor: pointer;
  margin-bottom: 8px;
}
.pay-audit-details > summary::-webkit-details-marker { display: none; }
.pay-audit-panel {
  border: 1px solid #d5deea;
  background: #fbfcfe;
  padding: 14px 16px;
  display: grid;
  gap: 14px;
}
.pay-audit-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: flex-start;
  justify-content: space-between;
}
.pay-audit-toolbar .lede {
  margin: 0;
  max-width: 52rem;
}
.pay-audit-table {
  width: 100%;
  font-size: 0.9rem;
}
.pay-audit-subtotals h3 {
  margin: 0 0 8px;
  font-size: 1rem;
}
.pay-period-banner p {
  margin: 6px 0 0;
}
.pay-bulk-recalc {
  margin: 0 0 16px;
}
.pay-bulk-recalc-form {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 16px;
  align-items: center;
  background: linear-gradient(180deg, #f4f7fb 0%, #e9eef5 100%);
  border: 1px solid #c9d5e4;
  padding: 14px 16px;
}
.pay-bulk-recalc-lede {
  margin: 0;
  flex: 1 1 18rem;
  max-width: 46rem;
  color: #243447;
  font-size: 0.95rem;
  line-height: 1.45;
}
.pay-bulk-recalc-counts {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  width: 100%;
  color: #31465f;
  font-size: 0.9rem;
}
.pay-bulk-recalc-counts li::before {
  content: "• ";
}
.btn-bulk-recalc {
  background: #1d3557;
  color: #fff;
  border-color: transparent;
  box-shadow: 0 1px 2px rgba(29, 53, 87, 0.18);
  white-space: normal;
  text-align: center;
}
.btn-bulk-recalc:hover {
  background: #15263f;
  color: #fff;
  border-color: transparent;
}
.btn-bulk-recalc:active {
  background: #101c2e;
  color: #fff;
}
.btn-bulk-recalc:disabled,
.btn-bulk-recalc[disabled],
.btn-bulk-recalc.is-disabled {
  background: #8a9bb0;
  color: rgba(255, 255, 255, 0.9);
  border-color: transparent;
}
.pay-bulk-recalc-result {
  margin: 0 0 16px;
}
.pay-bulk-recalc-list {
  margin: 8px 0 0;
  padding-left: 1.2rem;
  list-style: disc;
}
.pay-bulk-recalc-list li {
  margin: 2px 0;
  line-height: 1.4;
}
.pay-period-summary {
  display: grid;
  grid-template-columns: minmax(240px, 1fr) minmax(280px, 2fr);
  gap: 16px;
  margin: 16px 0 24px;
}
.pay-summary-card {
  background: linear-gradient(180deg, #f7f9fc 0%, #eef3f8 100%);
  border: 1px solid #d5deea;
  padding: 16px 18px;
}
.pay-summary-dl {
  display: grid;
  gap: 10px 18px;
  margin: 0;
}
.pay-summary-dl > div {
  display: grid;
  gap: 2px;
}
.pay-summary-dl dt {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #5b6b7c;
  margin: 0;
}
.pay-summary-dl dd {
  margin: 0;
  font-size: 1.05rem;
}
.pay-summary-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
.pay-summary-gross {
  font-weight: 700;
  font-size: 1.2rem;
}
.pay-summary-note {
  margin: 12px 0 0;
  font-size: 0.88rem;
}
.pay-period-loads h2,
.pay-period-level h2,
.pay-period-add h2 {
  margin: 0 0 8px;
}
.pay-period-table {
  width: 100%;
  font-size: 0.92rem;
}
.pay-period-table th,
.pay-period-table td {
  vertical-align: top;
  white-space: nowrap;
}
.pay-period-table .pay-endpoint {
  white-space: normal;
  min-width: 110px;
  line-height: 1.35;
}
.payroll-status-badge {
  display: inline-block;
  font-size: 0.78rem;
  font-weight: 650;
  letter-spacing: 0.02em;
  padding: 3px 8px;
  border: 1px solid #c5d0dc;
  background: #f4f7fa;
}
.payroll-status-badge.status-estimated { background: #e8f6ee; border-color: #9dccb0; }
.payroll-status-badge.status-no-rule { background: #fff4e5; border-color: #e0b56b; }
.payroll-status-badge.status-no-rate { background: #fff4e5; border-color: #e0b56b; }
.payroll-status-badge.status-needs-review { background: #fdecec; border-color: #d99; }
.payroll-status-badge.status-payroll-pending { background: #eef1f5; border-color: #b8c2ce; }
.payroll-status-badge.status-under-review { background: #fff4e5; border-color: #e0b56b; }
.payroll-status-badge.status-approved { background: #e8f6ee; border-color: #9dccb0; }
.payroll-status-badge.status-paid { background: #e7eef8; border-color: #9bb0cf; }
.payroll-status-badge.status-in-progress { background: #eef1f5; border-color: #b8c2ce; }

.pay-lifecycle-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: flex-end;
  margin: 0 0 1.1rem;
  padding: 0.85rem 1rem;
  border: 1px solid rgba(15, 23, 42, 0.1);
  border-radius: 12px;
  background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
}
.pay-lifecycle-form {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  align-items: flex-end;
}
.pay-lifecycle-form label {
  display: grid;
  gap: 0.25rem;
  font-size: 0.82rem;
  color: #475569;
}
.pay-lifecycle-form input[type="date"],
.pay-lifecycle-form input[type="text"] {
  min-height: 40px;
  min-width: 10rem;
}
.pay-blocker-list {
  margin: 0.5rem 0 0;
  padding-left: 1.2rem;
}
.pay-blocker-list a {
  color: inherit;
  text-decoration: underline;
}
@media (max-width: 820px) {
  .pay-lifecycle-actions {
    flex-direction: column;
    align-items: stretch;
  }
  .pay-lifecycle-form,
  .pay-lifecycle-actions .btn {
    width: 100%;
  }
  .pay-lifecycle-form .btn,
  .pay-lifecycle-actions > .btn {
    min-height: 44px;
  }
}
/* Review Pay slide-out drawer (desktop) / sheet (mobile) */
body.pay-review-drawer-open {
  position: fixed;
  width: 100%;
  overflow: hidden;
}
.pay-review-drawer-root {
  position: fixed;
  inset: 0;
  z-index: 460;
  display: flex;
  justify-content: flex-end;
  align-items: stretch;
  max-width: 100vw;
  overflow: hidden;
}
.pay-review-drawer-root[hidden] {
  display: none !important;
}
.pay-review-drawer-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 32, 0.42);
  border: 0;
  padding: 0;
  cursor: pointer;
}
.pay-review-drawer {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  width: min(440px, 100vw);
  max-width: 100%;
  height: 100%;
  max-height: 100%;
  background: #fff;
  border-left: 1px solid #c5d0dc;
  box-shadow: -12px 0 32px rgba(20, 35, 55, 0.16);
  outline: none;
  overflow: hidden;
}
.pay-review-drawer-header {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 16px 12px;
  border-bottom: 1px solid #d5deea;
  background: #fff;
}
.pay-review-drawer-kicker {
  margin: 0 0 2px;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #5a6b7b;
}
.pay-review-drawer-heading h2 {
  margin: 0;
  font-size: 1.15rem;
  line-height: 1.25;
  word-break: break-word;
}
.pay-review-drawer-x {
  flex: 0 0 auto;
  width: 40px;
  height: 40px;
  border: 1px solid #c5d0dc;
  border-radius: 8px;
  background: #f4f7fa;
  color: #1c2a37;
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
}
.pay-review-drawer-x:focus-visible,
.pay-review-drawer-footer .btn:focus-visible,
[data-pay-review-open]:focus-visible {
  outline: 2px solid #2f6fed;
  outline-offset: 2px;
}
.pay-review-drawer-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  padding: 14px 16px 20px;
  -webkit-overflow-scrolling: touch;
}
.pay-review-drawer-footer {
  position: sticky;
  bottom: 0;
  z-index: 2;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid #d5deea;
  background: #fff;
}
.pay-review-drawer-panel[hidden] {
  display: none !important;
}
.pay-review-drawer-meta {
  margin-bottom: 14px;
  padding-bottom: 12px;
  border-bottom: 1px solid #e4ebf2;
}
.pay-review-meta-dl {
  display: grid;
  gap: 10px;
  margin: 0;
}
.pay-review-meta-dl > div {
  display: grid;
  gap: 2px;
}
.pay-review-meta-dl dt {
  font-size: 0.75rem;
  font-weight: 600;
  color: #5a6b7b;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.pay-review-meta-dl dd {
  margin: 0;
  font-size: 0.95rem;
  overflow-wrap: anywhere;
  word-break: break-word;
}
.pay-review-calc-dl {
  margin: 0;
}
.pay-review-section-title {
  margin: 14px 0 8px;
  font-size: 0.98rem;
}
[data-load-row].is-review-selected {
  outline: 2px solid #2f6fed;
  outline-offset: -2px;
  background: #eef4ff;
}
.pay-period-table [data-load-row].is-review-selected td {
  background: #eef4ff;
}
.pay-load-card.is-review-selected {
  box-shadow: inset 0 0 0 2px #2f6fed;
}
.pay-override-form,
.pay-accept-form,
.pay-add-form,
.pay-edit-form,
.pay-void-form {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}
.pay-accept-form {
  padding-top: 10px;
  border-top: 1px solid #d5deea;
}
.pay-accept-lede {
  margin: 0;
  font-size: 0.9rem;
  color: #3d4d5c;
}
.pay-accept-form .btn {
  min-height: 40px;
}
.pay-lookup-diagnostic {
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px dashed #c5d0dc;
  font-size: 0.85rem;
}
.pay-lookup-diagnostic summary {
  cursor: pointer;
  color: #3d4d5c;
}
.pay-lookup-diagnostic pre {
  margin: 8px 0 0;
  padding: 8px;
  max-height: 280px;
  overflow: auto;
  white-space: pre-wrap;
  background: #f4f7fa;
  border-radius: 6px;
  font-size: 0.78rem;
  line-height: 1.35;
}
.pay-override-form {
  padding-top: 10px;
  border-top: 1px solid #e4ebf2;
}
.pay-override-form label,
.pay-add-form label,
.pay-edit-form label,
.pay-void-form label {
  display: grid;
  gap: 4px;
  font-size: 0.9rem;
}
.pay-item-list {
  margin: 0;
  padding-left: 18px;
}
.pay-item-list li { margin: 4px 0; }
.pay-add-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  margin-top: 12px;
}
.pay-add-form {
  background: #f7f9fc;
  border: 1px solid #d5deea;
  padding: 14px;
}
.pay-add-form h3 {
  margin: 0 0 8px;
  font-size: 1rem;
}
.pay-period-mobile { display: none; }
.pay-period-desktop { display: block; overflow-x: auto; }

@media (max-width: 1100px) {
  .pay-period-summary {
    grid-template-columns: 1fr;
  }
  .pay-add-grid {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 900px) {
  .pay-period-desktop { display: none; }
  .pay-period-mobile { display: grid; gap: 12px; }
  .pay-period-controls {
    flex-direction: column;
    align-items: stretch;
  }
  .pay-bulk-recalc-form {
    flex-direction: column;
    align-items: stretch;
  }
  .pay-bulk-recalc-lede {
    max-width: none;
  }
  .btn-bulk-recalc {
    width: 100%;
    min-height: 44px;
  }
  .pay-bulk-recalc-result,
  .pay-bulk-recalc-list {
    overflow-wrap: anywhere;
    word-break: break-word;
  }
  .pay-period-nav .btn {
    flex: 1 1 auto;
    text-align: center;
  }
  .pay-period-company-form select,
  .pay-employer-form select,
  .pay-employer-change-form select {
    width: 100%;
  }
  .pay-employer-form,
  .pay-employer-change-form,
  .pay-employer-selected {
    flex-direction: column;
    align-items: stretch;
  }
  .pay-audit-toolbar {
    flex-direction: column;
  }
  .pay-summary-grid {
    grid-template-columns: 1fr 1fr;
  }
  .pay-add-grid {
    grid-template-columns: 1fr;
  }
  /* Review Pay: full-width slide-up sheet above bottom nav */
  .pay-review-drawer-root {
    align-items: flex-end;
    justify-content: stretch;
  }
  .pay-review-drawer {
    width: 100%;
    max-width: 100vw;
    height: min(92vh, 100%);
    max-height: calc(100vh - 8px);
    border-left: 0;
    border-top: 1px solid #c5d0dc;
    border-radius: 14px 14px 0 0;
    box-shadow: 0 -10px 28px rgba(20, 35, 55, 0.18);
    /* Keep footer actions above the mobile bottom nav */
    padding-bottom: calc(var(--bottom-nav-height) + env(safe-area-inset-bottom, 0px));
  }
  .pay-review-drawer-header {
    position: sticky;
    top: 0;
  }
  .pay-review-drawer-footer {
    padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px));
  }
  .pay-review-drawer-footer .btn,
  .pay-review-drawer-body .btn {
    min-height: 44px;
  }
  .pay-review-drawer-body {
    overflow-x: hidden;
  }
  .sticky-save-area {
    position: sticky;
    bottom: 0;
    z-index: 4;
    padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px));
    background: linear-gradient(180deg, rgba(255,255,255,0) 0%, #fff 18%);
  }
  .sticky-save-area .pay-add-form .btn {
    min-height: 44px;
  }
  .pay-load-card .mobile-card-fields {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 390px) {
  .pay-summary-grid {
    grid-template-columns: 1fr;
  }
  .pay-load-card .mobile-card-fields {
    grid-template-columns: 1fr;
  }
  .pay-period-nav {
    flex-direction: column;
  }
  .pay-review-drawer,
  .pay-review-drawer-body,
  .pay-review-drawer-header,
  .pay-review-drawer-footer {
    max-width: 100vw;
    overflow-x: hidden;
  }
  .pay-bulk-recalc-form,
  .pay-bulk-recalc-result {
    padding-left: 12px;
    padding-right: 12px;
  }
}

/* Customer invoice review */
.invoice-totals {
  margin-top: 1.25rem;
  max-width: 22rem;
  margin-left: auto;
  padding: 1rem 1.1rem;
  background: linear-gradient(180deg, #f7f9fc 0%, #eef3f8 100%);
  border: 1px solid #d5deea;
}
.invoice-totals-row {
  display: flex;
  justify-content: space-between;
  gap: 1.5rem;
  font-size: 1.05rem;
  padding: 0.2rem 0;
}
.invoice-totals-total {
  margin-top: 0.55rem;
  padding-top: 0.65rem;
  border-top: 2px solid #1f2a37;
  font-size: 1.35rem;
  font-weight: 700;
}
.invoice-totals-currency {
  margin: 0.45rem 0 0;
  text-align: right;
  font-size: 0.85rem;
}
.invoice-ready-hero {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  border-left: 4px solid #1f7a4c;
}
.invoice-ready-number {
  margin: 0.15rem 0 0.4rem;
  font-size: 1.55rem;
  letter-spacing: 0.02em;
}
.invoice-ready-status {
  margin: 0;
  display: flex;
  align-items: center;
  gap: 0.55rem;
}
.invoice-document {
  border-left: 4px solid #1f7a4c;
}
.invoice-document-number {
  margin: 0.2rem 0 1rem;
  font-size: 1.65rem;
  letter-spacing: 0.02em;
}
.invoice-document-meta {
  max-width: 36rem;
}
.invoice-action-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
}
.invoice-inline-form {
  display: inline;
  margin: 0;
}
.invoice-audit > summary {
  cursor: pointer;
  font-weight: 650;
  list-style: none;
}
.invoice-audit > summary::-webkit-details-marker {
  display: none;
}
.invoice-audit > summary::before {
  content: "▶ ";
  font-size: 0.85em;
}
.invoice-audit[open] > summary::before {
  content: "▼ ";
}
.invoice-ready-warnings ul {
  margin: 0.5rem 0 0.75rem;
  padding-left: 1.1rem;
}

/* Invoice Ready blockers — compact address row + Edit Customer */
.invoice-blocker-list {
  list-style: none;
  margin: 0.5rem 0 0.75rem;
  padding: 0;
}
.invoice-blocker-item {
  margin: 0 0 0.65rem;
  padding: 0.65rem 0.75rem;
  border: 1px solid #f0c7c7;
  background: #fff7f7;
}
.invoice-blocker-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
}
.invoice-blocker-missing {
  margin: 0.35rem 0 0;
  font-size: 0.85rem;
  line-height: 1.35;
}
.bill-to-address-blocker {
  margin-top: 0.75rem;
}
.bill-to-heading-row {
  margin-bottom: 0.75rem;
}
.bill-to-heading-row .bill-to-heading {
  margin: 0;
}
.invoice-missing-customer-error {
  margin: 0.5rem 0 0;
  font-size: 0.92rem;
}
.invoice-missing-customer-error a {
  margin-left: 0.35rem;
  font-weight: 600;
}

/* Invoice customer billing drawer (desktop) / sheet (mobile) */
body.invoice-customer-drawer-open {
  position: fixed;
  width: 100%;
  overflow: hidden;
}
.invoice-customer-drawer-root {
  position: fixed;
  inset: 0;
  z-index: 470;
  display: flex;
  justify-content: flex-end;
  align-items: stretch;
  max-width: 100vw;
  overflow: hidden;
}
.invoice-customer-drawer-root[hidden] {
  display: none !important;
}
.invoice-customer-drawer-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 32, 0.42);
  border: 0;
  padding: 0;
  cursor: pointer;
}
.invoice-customer-drawer {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  width: min(440px, 100vw);
  max-width: 100%;
  height: 100%;
  max-height: 100%;
  background: #fff;
  border-left: 1px solid #c5d0dc;
  box-shadow: -12px 0 32px rgba(20, 35, 55, 0.16);
  outline: none;
  overflow: hidden;
}
.invoice-customer-drawer-header {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 16px 12px;
  border-bottom: 1px solid #d5deea;
  background: #fff;
}
.invoice-customer-drawer-kicker {
  margin: 0 0 2px;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #5a6b7b;
}
.invoice-customer-drawer-heading h2 {
  margin: 0;
  font-size: 1.15rem;
  line-height: 1.25;
}
.invoice-customer-drawer-x {
  flex: 0 0 auto;
  width: 40px;
  height: 40px;
  border: 1px solid #c5d0dc;
  background: #fff;
  border-radius: 8px;
  font-size: 1.35rem;
  line-height: 1;
  cursor: pointer;
}
.invoice-customer-drawer-form {
  display: flex;
  flex-direction: column;
  min-height: 0;
  flex: 1;
  margin: 0;
}
.invoice-customer-drawer-body {
  flex: 1;
  overflow: auto;
  padding: 16px;
  -webkit-overflow-scrolling: touch;
}
.invoice-customer-drawer-body .form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}
.invoice-customer-drawer-footer {
  position: sticky;
  bottom: 0;
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  padding: 12px 16px 16px;
  border-top: 1px solid #d5deea;
  background: #fff;
}
.invoice-tax-reason-required {
  font-weight: 600;
}
.invoice-tax-reason-required [data-invoice-tax-reason] {
  border-color: #b45309;
}

.invoice-customer-full-link {
  margin: 0.5rem 0 0;
  font-size: 0.9rem;
}
.invoice-customer-drawer-footer .btn,
.invoice-blocker-row .btn {
  min-height: 40px;
}

@media (max-width: 720px) {
  .invoice-customer-drawer-root {
    align-items: flex-end;
  }
  .invoice-customer-drawer {
    width: 100vw;
    max-width: 100vw;
    height: min(92vh, 100%);
    max-height: 92vh;
    border-left: 0;
    border-top: 1px solid #c5d0dc;
    border-radius: 16px 16px 0 0;
    box-shadow: 0 -10px 28px rgba(20, 35, 55, 0.18);
  }
  .invoice-customer-drawer-body .form-row {
    grid-template-columns: 1fr;
  }
  .invoice-customer-drawer-footer {
    padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  }
  .invoice-customer-drawer-footer .btn,
  .invoice-blocker-row .btn,
  .invoice-customer-drawer-body .btn {
    min-height: 44px;
  }
  .invoice-blocker-row {
    flex-direction: column;
    align-items: stretch;
  }
}
