:root {
  --blue: #1554c0;
  --blue-dark: #0c3578;
  --red: #d72238;
  --bg: #f5f8ff;
  --card: #ffffff;
  --text: #172033;
  --muted: #667085;
  --line: #dce5f5;
  --good: #0d7a4f;
  --warn: #a16207;
  --danger: #b42318;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background: linear-gradient(180deg, #f8fbff 0%, var(--bg) 100%);
}
a { color: var(--blue); text-decoration: none; }
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(255,255,255,.94);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(10px);
  padding: 14px 22px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.brand {
  color: var(--text);
  font-weight: 800;
  display: flex;
  align-items: center;
  gap: 10px;
}
.mark {
  display: inline-grid;
  place-items: center;
  width: 38px;
  height: 38px;
  background: var(--blue);
  color: #fff;
  border-radius: 12px;
  box-shadow: 0 10px 22px rgba(21,84,192,.22);
}
nav { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; }
nav a { font-weight: 650; color: var(--blue-dark); font-size: 14px; }
.container { width: min(1180px, calc(100% - 28px)); margin: 28px auto 70px; }
.hero {
  display: grid;
  grid-template-columns: 1.5fr .8fr;
  gap: 22px;
  align-items: stretch;
}
.hero h1 {
  font-size: clamp(34px, 5vw, 62px);
  line-height: .98;
  letter-spacing: -2px;
  margin: 6px 0 18px;
}
.hero p { font-size: 18px; color: #3d4a62; max-width: 780px; }
.eyebrow {
  color: var(--red) !important;
  text-transform: uppercase;
  font-weight: 800;
  letter-spacing: .08em;
  font-size: 13px !important;
}
.panel, .card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 22px;
  box-shadow: 0 18px 45px rgba(30, 62, 118, .08);
  padding: 24px;
}
.panel {
  border-top: 5px solid var(--red);
}
.card { margin-bottom: 18px; }
.card.narrow { max-width: 520px; margin-left: auto; margin-right: auto; }
.card.success { border-top: 5px solid var(--good); }
.card.danger { border-top: 5px solid var(--danger); }
h1, h2, h3 { margin-top: 0; }
.muted { color: var(--muted); font-size: 14px; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 16px; }
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--blue-dark);
  border-radius: 12px;
  padding: 11px 15px;
  font-weight: 800;
  cursor: pointer;
}
.button.primary { background: var(--blue); color: #fff; border-color: var(--blue); }
.button.ghost { background: transparent; }
.button.small { padding: 7px 10px; font-size: 13px; }
.grid-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}
label { display: grid; gap: 7px; font-weight: 750; color: #283449; }
input, select, textarea {
  width: 100%;
  border: 1px solid #cbd7eb;
  border-radius: 12px;
  padding: 11px 12px;
  font: inherit;
  background: #fff;
}
textarea { min-height: 100px; }
.full { grid-column: 1 / -1; }
.check { display: flex; flex-direction: row; align-items: flex-start; gap: 10px; font-weight: 650; }
.check input { width: auto; margin-top: 4px; }
.flash {
  width: min(1180px, calc(100% - 28px));
  margin: 18px auto 0;
  border-radius: 14px;
  padding: 13px 16px;
  font-weight: 750;
  border: 1px solid var(--line);
  background: #fff;
}
.flash.success { border-color: #9ee0c1; color: var(--good); }
.flash.warning { border-color: #f4d27a; color: var(--warn); }
.flash.danger { border-color: #f0aaa3; color: var(--danger); }
.metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0,1fr));
  gap: 14px;
  margin-bottom: 18px;
}
.metric {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 18px;
  box-shadow: 0 14px 30px rgba(30,62,118,.06);
}
.metric-value { font-size: 34px; font-weight: 900; color: var(--blue); }
.metric-label { font-weight: 850; }
.metric-hint { color: var(--muted); font-size: 13px; margin-top: 4px; }
.table-card { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td {
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
  padding: 11px 9px;
}
th { color: #34405a; font-size: 13px; text-transform: uppercase; letter-spacing: .04em; }
.badge {
  display: inline-flex;
  border-radius: 999px;
  padding: 5px 9px;
  background: #eef4ff;
  color: var(--blue-dark);
  font-size: 12px;
  font-weight: 850;
}
.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: end;
}
.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}
.detail {
  border-bottom: 1px solid var(--line);
  padding: 9px 0;
  display: grid;
  grid-template-columns: 190px 1fr;
  gap: 12px;
}
.detail span { color: var(--muted); font-weight: 750; }
.detail strong { font-weight: 700; }
.note {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px;
  margin-bottom: 10px;
  background: #fbfdff;
}
.note span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-top: 3px;
}
.footer {
  width: min(1180px, calc(100% - 28px));
  margin: 0 auto 30px;
  color: var(--muted);
  font-size: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}
@media (max-width: 820px) {
  .topbar { align-items: flex-start; flex-direction: column; }
  .hero, .two-col, .grid-form, .metrics { grid-template-columns: 1fr; }
  .detail { grid-template-columns: 1fr; gap: 3px; }
  .container { width: min(100% - 20px, 1180px); margin-top: 18px; }
}

/* Phase 2 dispatch usability */
.metrics.compact .metric { padding: 15px; }
.dispatch-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin: 14px 0 18px;
}
.dispatch-summary div {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px;
  background: #fbfdff;
}
.dispatch-summary strong {
  display: block;
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.dispatch-summary span {
  display: block;
  margin-top: 4px;
  font-weight: 850;
}
.suggestions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}
.suggestion {
  border: 1px solid var(--line);
  border-radius: 18px;
  background: #fbfdff;
  padding: 15px;
}
.suggestion-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}
.suggestion-head strong {
  display: block;
  font-size: 18px;
}
.suggestion-head span {
  display: block;
  color: var(--muted);
  font-weight: 750;
  margin-top: 2px;
}
.score {
  min-width: 52px;
  height: 52px;
  border-radius: 16px;
  display: grid;
  place-items: center;
  color: #fff;
  background: var(--blue);
  font-weight: 950;
  font-size: 20px;
}
.scorebar {
  height: 9px;
  background: #e4ebf8;
  border-radius: 999px;
  margin: 12px 0;
  overflow: hidden;
}
.scorebar span {
  display: block;
  height: 100%;
  background: var(--blue);
}
.mini-list {
  margin: 10px 0;
  padding-left: 18px;
  font-size: 14px;
}
.good-list li::marker { color: var(--good); }
.warn-list li::marker { color: var(--warn); }
.warn-text { color: var(--warn); font-weight: 800; }
.priority-urgent {
  background: #fff1f1;
  color: var(--danger);
}
.priority-manual_review {
  background: #fff7df;
  color: var(--warn);
}
.priority-normal {
  background: #eef4ff;
  color: var(--blue-dark);
}
.urgent-row {
  background: #fffafa;
}
.review-row {
  background: #fffdf4;
}
@media (max-width: 820px) {
  .dispatch-summary,
  .suggestions {
    grid-template-columns: 1fr;
  }
}

/* Phase 2.1 workflow polish */
.quick-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 10px 0 18px;
}
.quick-actions form {
  margin: 0;
}
.driver-needs_review,
.driver-applied,
.bg-needs_review {
  background: #fff7df;
  color: var(--warn);
}
.driver-approved,
.bg-cleared {
  background: #eafaf2;
  color: var(--good);
}
.driver-pending_background_check,
.driver-background_check_submitted,
.bg-pending,
.bg-submitted {
  background: #eef4ff;
  color: var(--blue-dark);
}
.driver-rejected,
.driver-suspended,
.bg-failed {
  background: #fff1f1;
  color: var(--danger);
}
.driver-inactive,
.bg-expired,
.bg-not_started,
.bg-consent_received {
  background: #f2f4f7;
  color: #475467;
}

/* Phase 2.2 schedule board + assignment safety */
.workload-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}
.workload-card {
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 13px;
  background: #fbfdff;
}
.workload-card strong,
.workload-card span,
.workload-card b,
.workload-card em {
  display: block;
}
.workload-card strong {
  font-size: 16px;
}
.workload-card span {
  color: var(--muted);
  font-size: 13px;
  margin-top: 3px;
}
.workload-card b {
  color: var(--blue);
  font-size: 20px;
  margin-top: 8px;
}
.workload-card em {
  color: var(--muted);
  font-style: normal;
  font-size: 13px;
  margin-top: 3px;
}
.workload-card.medium {
  border-color: #f4d27a;
  background: #fffdf4;
}
.workload-card.high {
  border-color: #f0aaa3;
  background: #fffafa;
}
.notice {
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 15px;
  margin-bottom: 18px;
  background: #fff;
}
.notice.good {
  border-color: #9ee0c1;
  background: #f0fff7;
  color: var(--good);
}
.notice.warning {
  border-color: #f4d27a;
  background: #fffdf4;
  color: var(--warn);
}
.notice ul {
  margin: 8px 0 0;
  padding-left: 20px;
}
@media (max-width: 960px) {
  .workload-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
@media (max-width: 620px) {
  .workload-grid {
    grid-template-columns: 1fr;
  }
}

/* Phase 2.3 notification queue + confirmations */
.confirm-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}
.confirm-actions form {
  margin: 0;
}
.button.tiny {
  padding: 5px 8px;
  font-size: 12px;
  border-radius: 9px;
}
.channel-sms {
  background: #eef4ff;
  color: var(--blue-dark);
}
.channel-email {
  background: #eafaf2;
  color: var(--good);
}
.channel-internal {
  background: #f2f4f7;
  color: #475467;
}
.channel-web_push {
  background: #f5edff;
  color: #6941c6;
}
.notification-queued {
  background: #fff7df;
  color: var(--warn);
}
.notification-sent {
  background: #eafaf2;
  color: var(--good);
}
.notification-failed {
  background: #fff1f1;
  color: var(--danger);
}
.notification-skipped {
  background: #f2f4f7;
  color: #475467;
}

/* Phase 2.4 admin edit screens */
.form-section {
  margin: 10px 0 0;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  color: var(--blue-dark);
}
.grid-form .actions {
  margin-top: 8px;
}

/* Phase 2.5 reports + audit */
.quality-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 10px;
}
.quality-grid a {
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #fbfdff;
  padding: 13px;
  color: var(--text);
}
.quality-grid strong {
  display: block;
  color: var(--red);
  font-size: 28px;
  line-height: 1;
}
.quality-grid span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  font-weight: 750;
  margin-top: 6px;
}
code {
  white-space: normal;
  font-size: 12px;
  color: #344054;
}
@media (max-width: 1100px) {
  .quality-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}
@media (max-width: 620px) {
  .quality-grid {
    grid-template-columns: 1fr;
  }
}

/* Phase 3.0 mapping foundation */
.location-note {
  border: 1px dashed var(--line);
  border-radius: 14px;
  padding: 12px;
  background: #fbfdff;
  color: var(--muted);
}
