/* MC Carrier — OTR Breakdowns
   Dark navy maintenance board. Tokens match Available Freight. Mobile-first, desktop split. */

:root {
  --bg: #070b16;
  --bg-2: #0c1224;
  --header: #080d1a;
  --brand: #36409f;
  --brand-2: #4d59c4;
  --brand-deep: #2a409a;
  --ink: #eef1fb;
  --muted: #93a0c2;
  --faint: #6d7898;
  --card: #ffffff;
  --card-ink: #14192c;
  --card-muted: #5c6580;
  --line: rgba(255, 255, 255, 0.08);
  --card-line: #e6e9f2;
  --gold: #d99212;
  --gold-soft: #fff4d6;
  --gold-ink: #8a5a00;
  --call: #16a34a;
  --call-hover: #15803d;
  --reefer: #0e8aa0;
  --van: #36409f;
  --flat: #c2410c;
  --other: #4b5568;
  --danger: #dc2626;
  --shadow: 0 10px 28px rgba(4, 8, 20, 0.28);
  --radius: 16px;
  --tap: 44px;
  --font: "Barlow", "Sarabun", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --display: "Barlow Condensed", "Barlow", ui-sans-serif, system-ui, sans-serif;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  --air: #0e8aa0;
  --electrical: #7c3aed;
  --open: #dc2626;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { color-scheme: dark; }
body {
  font-family: var(--font);
  background:
    radial-gradient(1200px 500px at 10% -10%, rgba(54, 64, 159, 0.28), transparent 50%),
    radial-gradient(900px 400px at 100% 0%, rgba(232, 163, 23, 0.08), transparent 45%),
    var(--bg);
  color: var(--ink);
  min-height: 100dvh;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
}

img { max-width: 100%; display: block; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; }

.skip {
  position: absolute;
  left: -999px;
  top: 0;
  background: var(--brand);
  color: #fff;
  padding: 8px 12px;
  z-index: 100;
}
.skip:focus { left: 8px; top: 8px; }

/* ——— Header ——— */
.top {
  padding: calc(12px + var(--safe-t)) 16px 10px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, #050814 0%, rgba(8, 13, 26, 0.92) 100%);
}
.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  max-width: 1280px;
  margin: 0 auto;
}
.logo {
  width: auto;
  height: 56px;
  object-fit: contain;
  mix-blend-mode: screen;
  flex: 0 0 auto;
}
.brand-copy { min-width: 0; }
.eyebrow {
  margin: 0 0 2px;
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 600;
}
h1 {
  margin: 0;
  font-family: var(--display);
  font-weight: 800;
  font-size: clamp(26px, 4vw, 34px);
  letter-spacing: 0.03em;
  text-transform: uppercase;
  line-height: 1;
}
.live {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
}
.live b { color: #fff; font-weight: 700; }
.live .dot {
  display: inline-block;
  width: 7px; height: 7px;
  border-radius: 50%;
  background: #22c55e;
  margin-right: 6px;
  box-shadow: 0 0 0 4px rgba(34, 197, 94, 0.16);
  vertical-align: 1px;
}

/* ——— Stats ——— */
.stats {
  max-width: 1280px;
  margin: 0 auto;
  padding: 14px 16px 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}
.stat {
  background: #10182e;
  border: 1px solid #2a355c;
  border-radius: var(--radius);
  padding: 12px 14px 10px;
  min-height: 78px;
}
.stat .n {
  font-family: var(--display);
  font-weight: 800;
  font-size: clamp(28px, 5vw, 36px);
  letter-spacing: 0.02em;
  line-height: 1;
  color: #fff;
}
.stat .n.open { color: #f87171; }
.stat .n.gold { color: #f5c14a; }
.stat .n.muted { color: var(--muted); }
.stat .lbl {
  margin-top: 6px;
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 700;
}

/* ——— Watch list ——— */
.watch {
  max-width: 1280px;
  margin: 0 auto;
  padding: 12px 16px 0;
}
.watch-box {
  background: #14101c;
  border: 1px solid #4a2c38;
  border-radius: var(--radius);
  padding: 12px 14px;
}
.watch-kicker {
  margin: 0 0 8px;
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: #e7a0a0;
  font-weight: 700;
}
.watch-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.watch-chip {
  border: 1px solid #5b3340;
  background: #1c1218;
  color: #f3d6d6;
  border-radius: 999px;
  padding: 8px 12px;
  min-height: 40px;
  font-weight: 600;
  font-size: 14px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.watch-chip .tag {
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-weight: 800;
  border-radius: 999px;
  padding: 3px 7px;
  background: #7f1d1d;
  color: #fff;
}
.watch-chip .tag.repeat { background: var(--brand); }
.watch-chip .tag.tire { background: var(--gold); color: #1a1200; }
.watch-empty { margin: 0; color: var(--muted); font-size: 13px; }

/* ——— Controls ——— */
.controls {
  max-width: 1280px;
  margin: 0 auto;
  padding: 14px 16px 8px;
}
.search-form { position: relative; }
.search-row {
  display: flex;
  gap: 8px;
  align-items: stretch;
  flex-wrap: wrap;
}
.search-wrap {
  flex: 1 1 180px;
  min-width: 160px;
  position: relative;
}
.date-field {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 1px;
  background: #121a33;
  border: 1px solid #2a355c;
  border-radius: 12px;
  padding: 4px 12px 6px;
  min-height: var(--tap);
  min-width: 154px;
  flex: 0 1 180px;
}
.date-field:focus-within {
  border-color: var(--brand-2);
  box-shadow: 0 0 0 3px rgba(54, 64, 159, 0.35);
}
.date-label {
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 700;
}
.type-field select {
  background: transparent;
  border: 0;
  outline: 0;
  min-height: 26px;
  width: 100%;
  color: var(--ink);
  color-scheme: dark;
  font-weight: 600;
  font-size: 15px;
}
.search-field {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  background: #121a33;
  border: 1px solid #2a355c;
  border-radius: 12px;
  padding: 0 10px 0 12px;
  min-height: var(--tap);
}
.search-field.loc-field {
  flex-direction: column;
  align-items: stretch;
  justify-content: center;
  gap: 1px;
  padding: 4px 10px 6px 12px;
}
.search-input {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.search-field:focus-within {
  border-color: var(--brand-2);
  box-shadow: 0 0 0 3px rgba(54, 64, 159, 0.35);
}
.search-field .pin { width: 20px; height: 20px; color: #e8a317; flex: 0 0 auto; }
.search-field.dest-field .pin { color: #5eead4; }
.search-field.handled-field .pin { color: #c4b5fd; }
#truck, #trailer, #handled {
  flex: 1;
  background: transparent;
  border: 0;
  outline: 0;
  min-width: 0;
  min-height: 26px;
  font-size: 16px;
  font-weight: 500;
}
#truck::placeholder, #trailer::placeholder, #handled::placeholder { color: #7d89ab; }
.icon-btn {
  width: 36px; height: 36px;
  border: 0;
  border-radius: 8px;
  background: #1c2644;
  color: #d7def4;
  font-size: 20px;
  line-height: 1;
}
.icon-btn:hover { background: #263056; }

.btn {
  border: 0;
  border-radius: 12px;
  min-height: var(--tap);
  padding: 0 16px;
  font-weight: 700;
  letter-spacing: 0.02em;
}
.btn.primary {
  background: var(--brand);
  color: #fff;
  white-space: nowrap;
}
.btn.primary:hover { background: var(--brand-2); }
.btn.call {
  background: var(--call);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-decoration: none;
  min-width: 108px;
}
.btn.call:hover { background: var(--call-hover); }
.btn.ghost {
  background: #eef1f8;
  color: var(--card-ink);
  border: 1px solid var(--card-line);
}
.btn.ghost:hover { background: #e4e8f2; }

.hint { margin: 8px 0 0; color: var(--faint); font-size: 12px; }

.suggest {
  position: absolute;
  left: 0; right: 0;
  top: calc(100% - 4px);
  z-index: 30;
  background: #10182e;
  border: 1px solid #31406c;
  border-radius: 12px;
  margin: 0;
  padding: 6px;
  list-style: none;
  box-shadow: var(--shadow);
  max-height: 280px;
  overflow: auto;
}
.suggest[hidden] { display: none; }
.suggest li { margin: 0; }
.suggest button {
  width: 100%;
  text-align: left;
  border: 0;
  background: transparent;
  color: var(--ink);
  padding: 10px 12px;
  border-radius: 8px;
  min-height: 44px;
  display: flex;
  justify-content: space-between;
  gap: 12px;
}
.suggest button:hover,
.suggest button[aria-selected="true"] { background: #1c2748; }
.suggest .st { color: var(--muted); font-weight: 700; letter-spacing: 0.04em; }

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 14px;
  align-items: center;
  justify-content: space-between;
  margin-top: 14px;
}
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  border: 1px solid #2d3a63;
  background: #121a33;
  color: #d5dcf2;
  border-radius: 999px;
  padding: 8px 14px;
  min-height: 40px;
  font-weight: 600;
  font-size: 14px;
}
.chip.on {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
}
.chip:focus-visible { outline: 2px solid #e8a317; outline-offset: 2px; }

.status {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 13px;
  min-height: 1.2em;
}

/* ——— Workspace ——— */
.workspace {
  max-width: 1280px;
  margin: 0 auto;
  padding: 8px 16px 28px;
}
.list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* Cards */
.card {
  background: var(--card);
  color: var(--card-ink);
  border-radius: var(--radius);
  padding: 14px 14px 12px;
  border: 2px solid transparent;
  box-shadow: var(--shadow);
  cursor: pointer;
  text-align: left;
  width: 100%;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 6px 12px;
}
.card:hover { border-color: #c9d0ea; }
.card.selected,
.card[aria-selected="true"] {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(54, 64, 159, 0.25), var(--shadow);
}
.card:focus-visible { outline: 3px solid var(--brand-2); outline-offset: 2px; }

.card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  grid-column: 1 / -1;
}
.pill {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 3px 8px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.pill.open { background: #fee2e2; color: #991b1b; }
.pill.rolling { background: var(--gold-soft); color: var(--gold-ink); }
.pill.complete { background: #dcfce7; color: #166534; }

.unit {
  font-family: var(--display);
  font-weight: 800;
  font-size: clamp(28px, 6vw, 40px);
  letter-spacing: 0.02em;
  line-height: 0.95;
  grid-column: 1;
}
.trailer-line {
  font-weight: 700;
  color: var(--card-muted);
  font-size: 14px;
  grid-column: 1;
}
.driver-line {
  font-weight: 700;
  font-size: 16px;
  grid-column: 1 / -1;
}
.handled-line {
  font-size: 13px;
  color: var(--card-muted);
  font-weight: 600;
  grid-column: 1 / -1;
}
.loc-line {
  color: var(--card-muted);
  font-size: 14px;
  font-weight: 600;
  grid-column: 1 / -1;
}
.reported-line {
  font-size: 13px;
  color: var(--card-muted);
  font-weight: 600;
  grid-column: 1 / -1;
}
.clock {
  font-family: var(--display);
  font-weight: 800;
  font-size: clamp(20px, 5vw, 26px);
  letter-spacing: 0.02em;
  line-height: 1;
  color: var(--card-ink);
  grid-column: 1 / -1;
}
.clock-ok { color: var(--card-muted); }
.clock-warn { color: #b45309; }
.clock-hot { color: var(--danger); }
.started-line {
  font-size: 12px;
  color: var(--card-muted);
  font-weight: 600;
  grid-column: 1 / -1;
}
.meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 8px;
  align-items: center;
  color: var(--card-muted);
  font-size: 13px;
  font-weight: 500;
  grid-column: 1 / -1;
}
.badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 3px 8px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #fff;
  background: var(--other);
}
.badge.tire { background: var(--gold); color: #1a1200; }
.badge.air { background: var(--air); }
.badge.electrical { background: var(--electrical); }
.badge.damage { background: var(--danger); }
.badge.load { background: #eef2ff; color: var(--brand); }
.badge.empty { background: #f1f5f9; color: #475569; }
.flag {
  display: inline-flex;
  align-items: center;
  border-radius: 6px;
  padding: 2px 6px;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.flag.repeat { background: #eef2ff; color: var(--brand); }
.flag.damage { background: #fee2e2; color: #991b1b; }
.cost {
  font-family: var(--display);
  font-weight: 800;
  font-size: 22px;
  color: var(--gold-ink);
  justify-self: end;
  align-self: start;
}

.empty {
  background: #10182e;
  border: 1px dashed #31406c;
  border-radius: var(--radius);
  padding: 36px 20px;
  text-align: center;
  color: var(--muted);
}
.empty h2 {
  font-family: var(--display);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #fff;
  margin: 8px 0 6px;
}
.empty p { margin: 0 auto; max-width: 36ch; }

/* Detail — mobile bottom sheet */
.detail {
  background: var(--card);
  color: var(--card-ink);
  border-radius: 20px 20px 0 0;
  position: fixed;
  left: 0; right: 0; bottom: 0;
  max-height: min(90dvh, 760px);
  z-index: 40;
  transform: translateY(110%);
  transition: transform 0.28s ease;
  box-shadow: 0 -12px 40px rgba(0, 0, 0, 0.4);
  overflow: auto;
  padding: 8px 18px calc(20px + var(--safe-b));
}
.detail.open { transform: translateY(0); }
.detail-handle {
  width: 42px; height: 4px;
  background: #d0d5e4;
  border-radius: 4px;
  margin: 6px auto 10px;
}
.detail-kicker {
  margin: 0 0 4px;
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--card-muted);
  font-weight: 700;
}
.detail-empty { padding: 18px 4px 8px; color: var(--card-muted); display: none; }
.detail-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: flex-start;
}
.detail-lane {
  font-family: var(--display);
  font-weight: 800;
  font-size: 30px;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  line-height: 1.05;
  margin: 0 0 8px;
}
.close-sheet {
  border: 0;
  background: #eef1f8;
  width: 40px; height: 40px;
  border-radius: 10px;
  font-size: 22px;
  color: var(--card-ink);
  flex: 0 0 auto;
}
.kv {
  display: grid;
  grid-template-columns: 92px 1fr;
  gap: 6px 10px;
  margin: 12px 0;
  font-size: 15px;
}
.kv dt { color: var(--card-muted); font-weight: 600; }
.kv dd { margin: 0; font-weight: 600; }
.timeline {
  margin: 4px 0 14px;
  border: 1px solid var(--card-line);
  border-radius: 12px;
  overflow: hidden;
  background: #f8f9fd;
}
.timeline-row {
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr) auto;
  gap: 4px 10px;
  padding: 8px 12px;
  border-top: 1px solid var(--card-line);
  font-size: 14px;
  align-items: baseline;
}
.timeline-row:first-child { border-top: 0; }
.timeline-label {
  color: var(--card-muted);
  font-weight: 600;
}
.timeline-when { font-weight: 700; }
.timeline-dur {
  font-family: var(--display);
  font-weight: 800;
  font-size: 16px;
  color: var(--card-muted);
  white-space: nowrap;
  justify-self: end;
}
.timeline .clock {
  font-size: 16px;
  grid-column: auto;
}
.notes {
  background: #f4f6fb;
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 14px;
  line-height: 1.45;
  margin: 8px 0 14px;
  white-space: pre-wrap;
}
.team-list {
  list-style: none;
  margin: 0 0 14px;
  padding: 0;
  border: 1px solid var(--card-line);
  border-radius: 12px;
  overflow: hidden;
}
.team-list li {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border-top: 1px solid var(--card-line);
}
.team-list li:first-child { border-top: 0; }
.team-list .nm { font-weight: 700; }
.team-list .role {
  color: var(--card-muted);
  font-size: 13px;
  font-weight: 600;
  text-transform: capitalize;
}
.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  position: sticky;
  bottom: 0;
  background: linear-gradient(#fff0, #fff 18%);
  padding-top: 10px;
}
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(18px + var(--safe-b));
  transform: translateX(-50%);
  background: #111827;
  color: #fff;
  padding: 10px 14px;
  border-radius: 999px;
  font-weight: 600;
  z-index: 60;
  box-shadow: var(--shadow);
}
.backdrop {
  position: fixed;
  inset: 0;
  background: rgba(4, 8, 18, 0.55);
  z-index: 35;
}
.backdrop[hidden] { display: none; }

/* Desktop */
@media (min-width: 900px) {
  .top { padding: 14px 24px 12px; }
  .logo { height: 68px; }
  .stats { padding: 16px 24px 0; grid-template-columns: repeat(6, minmax(0, 1fr)); }
  .watch { padding: 12px 24px 0; }
  .controls { padding: 16px 24px 8px; }
  .workspace {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 380px;
    gap: 16px;
    align-items: start;
    padding: 8px 24px 40px;
  }
  .detail {
    position: sticky;
    top: 12px;
    transform: none;
    border-radius: var(--radius);
    max-height: calc(100dvh - 24px);
    box-shadow: var(--shadow);
    padding: 18px 18px 20px;
  }
  .detail-handle,
  .close-sheet { display: none; }
  .detail-empty { display: block; }
  .detail.open .detail-empty { display: none; }
  .backdrop { display: none !important; }
  .backdrop.for-modal { display: block !important; }
  .search-row { max-width: none; flex-wrap: wrap; }
}

@media (max-width: 899px) {
  .detail-empty { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .detail { transition: none; }
}

/* ——— Follow up ——— */
.btn.followup {
  background: #d97706;
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  white-space: nowrap;
}
.btn.followup:hover { background: #b45309; }
.btn.followup.stale {
  background: #c2410c;
  box-shadow: 0 0 0 3px rgba(194, 65, 12, 0.28);
}
.btn.followup.stale:hover { background: #9a3412; }
a.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}

.card.stale {
  border-color: #f59e0b;
  box-shadow: 0 0 0 2px rgba(245, 158, 11, 0.22), var(--shadow);
}
.card.stale.selected,
.card.stale[aria-selected="true"] {
  border-color: #c2410c;
  box-shadow: 0 0 0 3px rgba(194, 65, 12, 0.22), var(--shadow);
}
.followed-line {
  font-size: 12px;
  color: var(--gold-ink);
  font-weight: 700;
  grid-column: 1 / -1;
}
.fu-chip {
  border: 0;
  border-radius: 999px;
  padding: 5px 10px;
  min-height: 28px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  background: #f59e0b;
  color: #1a1200;
  justify-self: start;
  grid-column: 1 / -1;
}
.fu-chip:hover { background: #d97706; color: #fff; }

.backdrop.for-modal { z-index: 50; }

.modal {
  position: fixed;
  inset: 0;
  z-index: 55;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 12px 12px calc(12px + var(--safe-b));
  pointer-events: none;
}
.modal[hidden] { display: none; }
.modal-card {
  pointer-events: auto;
  width: min(520px, 100%);
  max-height: min(88dvh, 720px);
  overflow: auto;
  background: var(--card);
  color: var(--card-ink);
  border-radius: 20px;
  padding: 16px 16px 14px;
  box-shadow: var(--shadow);
}
.modal-title {
  margin: 0 0 12px;
  font-family: var(--display);
  font-weight: 800;
  font-size: 28px;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  line-height: 1.05;
}
.modal-input {
  width: 100%;
  background: #121a33;
  border: 1px solid #2a355c;
  border-radius: 12px;
  color: var(--ink);
  padding: 10px 12px;
  min-height: var(--tap);
  font-size: 16px;
  font-weight: 500;
  margin: 4px 0 12px;
  outline: 0;
}
.modal-input:focus {
  border-color: var(--brand-2);
  box-shadow: 0 0 0 3px rgba(54, 64, 159, 0.35);
}
.modal-textarea {
  min-height: 160px;
  resize: vertical;
  line-height: 1.4;
  font-weight: 500;
}
.modal .date-label { color: var(--card-muted); }
.modal-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  position: sticky;
  bottom: 0;
  background: linear-gradient(#fff0, #fff 22%);
  padding-top: 8px;
}
.modal-actions .btn { flex: 1 1 140px; }
.toast[hidden] { display: none; }

@media (min-width: 900px) {
  .modal { align-items: center; padding: 24px; }
  .modal-card { border-radius: var(--radius); }
}
