/* ==========================================================================
   NorthShoreXpress — Dispatch Console
   ========================================================================== */

html, body { height: 100%; }
body.admin {
  margin: 0;
  background: var(--surface-3);
  font-size: 15px;
  overflow: hidden;
}

.app {
  display: grid;
  grid-template-rows: auto auto auto 1fr;
  height: 100vh;
  height: 100dvh;
}

/* ---------------------------------------------------------------- app bar */
.appbar {
  display: flex; align-items: center; gap: 14px;
  padding: 0 18px; height: 58px;
  background: var(--navy-900); color: #cfe0ec;
  border-bottom: 1px solid #000;
}
.appbar .brand-mark { width: 32px; height: 32px; border-radius: 9px; }
.appbar .brand-mark svg { width: 18px; height: 18px; }
.appbar-title { font-size: 0.98rem; font-weight: 800; color: #fff; letter-spacing: -0.02em; }
.appbar-title span { display: block; font-size: 0.66rem; font-weight: 700; letter-spacing: 0.14em; text-transform: uppercase; color: var(--amber-400); margin-top: 1px; }
.appbar .spacer { flex: 1; }

.sync-chip {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 5px 12px; border-radius: 999px;
  background: rgba(255,255,255,0.08); border: 1px solid rgba(255,255,255,0.14);
  font-size: 0.76rem; font-weight: 700; color: #b9d0e0;
}
.sync-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--amber-500); flex: none; }
.sync-chip.online .sync-dot { background: #34d399; }
.sync-chip.error .sync-dot { background: #f87171; }

.icon-btn {
  width: 34px; height: 34px; flex: none;
  display: grid; place-items: center;
  border: 1px solid rgba(255,255,255,0.16); border-radius: 9px;
  background: rgba(255,255,255,0.06); color: #cfe0ec; cursor: pointer;
  transition: background 0.14s;
}
.icon-btn:hover { background: rgba(255,255,255,0.16); }
.icon-btn svg { width: 17px; height: 17px; }

/* Text buttons in the dark app bar (setup / maintenance actions) */
.bar-btn {
  border: 1px solid rgba(255,255,255,0.16); border-radius: 9px;
  background: rgba(255,255,255,0.06); color: #cfe0ec;
  font: inherit; font-size: 0.79rem; font-weight: 700;
  padding: 7px 13px; cursor: pointer; white-space: nowrap;
  transition: background 0.14s;
}
.bar-btn:hover { background: rgba(255,255,255,0.16); color: #fff; }

/* ---------------------------------------------------------------- toolbar */
.toolbar {
  display: flex; align-items: center; gap: 9px; flex-wrap: wrap;
  padding: 11px 16px; background: #fff; border-bottom: 1px solid var(--line);
}

.viewtabs { display: inline-flex; background: var(--surface-3); border-radius: 9px; padding: 3px; gap: 2px; }
.viewtabs button {
  border: 0; background: none; font: inherit; font-size: 0.85rem; font-weight: 700;
  color: var(--ink-2); padding: 7px 15px; border-radius: 7px; cursor: pointer;
  transition: background 0.14s, color 0.14s, box-shadow 0.14s;
}
.viewtabs button:hover { color: var(--navy-900); }
.viewtabs button[aria-pressed="true"] { background: #fff; color: var(--navy-900); box-shadow: var(--shadow-sm); }

.datenav { display: inline-flex; align-items: center; gap: 6px; }
.datenav .nav-btn {
  width: 32px; height: 32px; display: grid; place-items: center;
  border: 1px solid var(--line); border-radius: 8px; background: #fff;
  cursor: pointer; color: var(--ink-2);
}
.datenav .nav-btn:hover { background: var(--surface-2); border-color: var(--ink-3); }
.datenav .nav-btn svg { width: 15px; height: 15px; }
.datenav .range {
  font-weight: 800; font-size: 0.95rem; color: var(--navy-900);
  min-width: 152px; text-align: center; letter-spacing: -0.015em;
}

.search-box { position: relative; flex: 1; min-width: 160px; max-width: 250px; }
.search-box svg {
  position: absolute; left: 11px; top: 50%; transform: translateY(-50%);
  width: 15px; height: 15px; color: var(--muted); pointer-events: none;
}
.search-box input {
  width: 100%; padding: 8px 12px 8px 34px;
  border: 1.5px solid var(--line); border-radius: 8px;
  font: inherit; font-size: 0.87rem; background: var(--surface-2);
}
.search-box input:focus {
  outline: none; background: #fff; border-color: var(--teal-500);
  box-shadow: 0 0 0 3px rgba(20,163,174,.15);
}

.filter-sel {
  padding: 8px 30px 8px 11px; border: 1.5px solid var(--line); border-radius: 8px;
  font: inherit; font-size: 0.85rem; font-weight: 650; background: #fff; color: var(--ink-2);
  -webkit-appearance: none; appearance: none; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='7' viewBox='0 0 12 8'%3E%3Cpath fill='%235d798f' d='M1.4 0 6 4.6 10.6 0 12 1.4 6 7.4 0 1.4z'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center;
}
.filter-sel:focus { outline: none; border-color: var(--teal-500); box-shadow: 0 0 0 3px rgba(20,163,174,.15); }

/* ------------------------------------------------------------- stat strip */
.statstrip {
  display: grid; grid-template-columns: repeat(5, 1fr); gap: 1px;
  background: var(--line); border-bottom: 1px solid var(--line);
}
.stat-cell { background: #fff; padding: 11px 18px; display: flex; align-items: baseline; gap: 9px; }
.stat-cell b { font-size: 1.35rem; font-weight: 800; color: var(--navy-900); letter-spacing: -0.03em; line-height: 1; }
.stat-cell span { font-size: 0.78rem; font-weight: 650; color: var(--muted); }
.stat-cell.alert b { color: var(--danger); }
.stat-cell.alert { background: #fff7f7; }
.stat-cell.warn b { color: var(--warn); }

/* ------------------------------------------------------------------ views */
.viewport { overflow: auto; background: var(--surface-3); position: relative; }

/* ===================== SPREADSHEET GRID ===================== */
.sheet-wrap { background: #fff; min-height: 100%; }

table.sheet {
  /* `fixed` is essential — it makes the browser honour the <colgroup> widths
     exactly, which is what keeps the frozen columns aligned. Total width is
     set inline by admin.js from the column definitions. */
  table-layout: fixed;
  border-collapse: separate; border-spacing: 0;
  font-size: 0.84rem;
  font-variant-numeric: tabular-nums;
}
table.sheet th, table.sheet td {
  border-right: 1px solid var(--line-2);
  border-bottom: 1px solid var(--line-2);
  padding: 0; text-align: left; white-space: nowrap;
  height: 34px; vertical-align: middle;
  overflow: hidden; text-overflow: ellipsis;
}
table.sheet thead th {
  position: sticky; top: 0; z-index: 3;
  background: var(--surface-2); color: var(--ink-2);
  font-size: 0.72rem; font-weight: 800; letter-spacing: 0.05em;
  text-transform: uppercase;
  border-bottom: 2px solid var(--line);
  padding: 0 10px; cursor: pointer; user-select: none;
}
table.sheet thead th:hover { background: var(--surface-3); color: var(--navy-900); }
table.sheet thead th .sortmark { color: var(--teal-600); margin-left: 4px; font-size: 0.8em; }

table.sheet td { padding: 0 10px; color: var(--ink-2); }
table.sheet td.num { text-align: right; }

/* frozen first two columns */
table.sheet th.frz1, table.sheet td.frz1 { position: sticky; left: 0; z-index: 2; background: #fff; }
table.sheet th.frz2, table.sheet td.frz2 { position: sticky; left: 46px; z-index: 2; background: #fff; }
table.sheet thead th.frz1, table.sheet thead th.frz2 { z-index: 4; background: var(--surface-2); }
table.sheet td.frz2 { border-right: 2px solid var(--line); font-weight: 750; color: var(--navy-900); }
table.sheet th.frz2 { border-right: 2px solid var(--line); }

table.sheet tbody tr:hover td { background: var(--teal-50); }
table.sheet tbody tr:hover td.frz1, table.sheet tbody tr:hover td.frz2 { background: var(--teal-50); }
table.sheet tbody tr.is-selected td { background: #e4f4ff !important; }
table.sheet tbody tr.is-past td { color: #93a7b7; }

.rownum {
  color: var(--muted); font-size: 0.72rem; font-weight: 700;
  text-align: center; width: 46px;
}

/* date separator rows */
tr.daybreak td {
  background: var(--navy-800) !important; color: #fff;
  font-weight: 800; font-size: 0.76rem; letter-spacing: 0.09em;
  text-transform: uppercase; padding: 0 12px; height: 30px;
  position: sticky; top: 34px; z-index: 1;
}
tr.daybreak td .dcount { font-weight: 600; color: #9db9cf; margin-left: 10px; text-transform: none; letter-spacing: 0; }

/* status cell */
.st {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 9px; border-radius: 999px;
  font-size: 0.71rem; font-weight: 800; letter-spacing: 0.02em;
  text-transform: uppercase;
}
.st-new       { background: var(--info-bg);   color: var(--info); }
.st-confirmed { background: var(--ok-bg);     color: var(--ok); }
.st-assigned  { background: var(--teal-100);  color: var(--teal-700); }
.st-enroute   { background: #ede4fb;          color: #6335b8; }
.st-completed { background: var(--surface-3); color: var(--ink-3); }
.st-cancelled { background: var(--danger-bg); color: var(--danger); }

/* verification ticks */
.vfy { display: inline-flex; gap: 3px; }
.vfy button {
  width: 22px; height: 22px; border-radius: 6px; cursor: pointer;
  border: 1px solid var(--line); background: #fff;
  display: grid; place-items: center; padding: 0;
  font-size: 0.62rem; font-weight: 900; color: #b3c2ce;
  transition: all 0.12s;
}
.vfy button:hover { border-color: var(--ink-3); }
.vfy button.on { background: var(--ok-bg); border-color: #9fd9c4; color: var(--ok); }
.vfy button.na { opacity: 0.32; cursor: default; }

.flag-dot {
  display: inline-block; width: 7px; height: 7px; border-radius: 50%;
  background: var(--danger); margin-right: 6px; vertical-align: middle;
}

.cell-edit {
  width: 100%; height: 100%; border: 0; padding: 0 10px; margin: 0;
  font: inherit; font-size: 0.84rem; background: #fffbe8;
  box-shadow: inset 0 0 0 2px var(--teal-600);
}
.cell-edit:focus { outline: none; }
.cell-edit[type="date"], .cell-edit[type="time"] { padding: 0 4px; font-size: 0.8rem; }
.cell-select {
  width: 100%; height: 100%; border: 0; padding: 0 6px; margin: 0;
  font: inherit; font-size: 0.84rem; background: #fffbe8;
  box-shadow: inset 0 0 0 2px var(--teal-600);
}
table.sheet td[data-edit] { cursor: cell; }
table.sheet td[data-edit]:hover { box-shadow: inset 0 0 0 1px #9fc4d8; }

/* row delete button — appears on hover in the row-number cell */
.row-del {
  display: none; width: 26px; height: 22px; margin: 0 auto;
  border: 0; border-radius: 4px; background: #fff0f0; color: var(--danger);
  font-size: 0.8rem; line-height: 22px; cursor: pointer; padding: 0;
}
table.sheet tbody tr:hover .row-del { display: block; }
table.sheet tbody tr:hover .rownum .rn { display: none; }
.row-del:hover { background: var(--danger); color: #fff; }

/* pop-up editor for multi-value cells */
table.sheet td.is-editing { position: relative; overflow: visible; z-index: 20; }
.cell-pop {
  position: absolute; z-index: 30; min-width: 280px; max-width: 340px;
  background: #fff; border: 1px solid var(--line); border-radius: 10px;
  box-shadow: 0 12px 32px rgba(6,21,35,.22); padding: 12px 14px;
  text-align: left; white-space: normal; line-height: 1.3; cursor: default; font-weight: 400;
}
.cell-pop .cp-title { font-weight: 750; color: var(--navy-900); margin-bottom: 8px; font-size: 0.86rem; }
.cell-pop .cp-field { display: block; margin-bottom: 8px; }
.cell-pop .cp-field span { display: block; font-size: 0.7rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin-bottom: 3px; }
.cell-pop input[type="text"], .cell-pop input[type="number"], .cell-pop textarea {
  width: 100%; box-sizing: border-box; border: 1px solid var(--line); border-radius: 6px;
  padding: 6px 8px; font: inherit; font-size: 0.86rem;
}
.cell-pop input:focus, .cell-pop textarea:focus { outline: none; border-color: var(--teal-600); box-shadow: 0 0 0 2px #cdeae4; }
.cell-pop .cp-check { display: inline-flex; align-items: center; gap: 6px; margin: 0 14px 8px 0; font-size: 0.86rem; color: var(--ink-2); }
.cell-pop .cp-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; }

/* ===================== CALENDAR VIEWS ===================== */
.cal { padding: 16px; }

.cal-month {
  display: grid; grid-template-columns: repeat(7, 1fr);
  gap: 1px; background: var(--line);
  border: 1px solid var(--line); border-radius: var(--r);
  overflow: hidden;
}
.cal-dowhead {
  background: var(--surface-2); padding: 9px 10px;
  font-size: 0.7rem; font-weight: 800; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--muted); text-align: center;
}
.cal-day {
  background: #fff; min-height: 116px; padding: 7px 7px 9px;
  display: flex; flex-direction: column; gap: 3px;
}
.cal-day.other { background: var(--surface-2); }
.cal-day.today { background: #fffdf3; box-shadow: inset 0 0 0 2px var(--amber-500); }
.cal-daynum {
  font-size: 0.76rem; font-weight: 800; color: var(--ink-2);
  display: flex; justify-content: space-between; align-items: center; margin-bottom: 2px;
}
.cal-day.other .cal-daynum { color: #b3c2ce; }
.cal-daynum .cnt {
  font-size: 0.64rem; font-weight: 800; color: #fff; background: var(--navy-700);
  border-radius: 999px; padding: 1px 6px;
}

.chip {
  display: block; width: 100%; text-align: left;
  border: 0; border-left: 3px solid var(--teal-600);
  background: var(--teal-50); border-radius: 4px;
  padding: 3px 6px; font: inherit; font-size: 0.71rem; font-weight: 700;
  color: var(--navy-900); cursor: pointer; overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap;
  transition: filter 0.12s;
}
.chip:hover { filter: brightness(0.95); }
.chip .t { font-variant-numeric: tabular-nums; color: var(--teal-700); margin-right: 4px; }
.chip.s-new       { border-left-color: var(--info);     background: var(--info-bg); }
.chip.s-confirmed { border-left-color: var(--ok);       background: var(--ok-bg); }
.chip.s-assigned  { border-left-color: var(--teal-600); background: var(--teal-100); }
.chip.s-enroute   { border-left-color: #6335b8;         background: #ede4fb; }
.chip.s-completed { border-left-color: #98a9b8;         background: var(--surface-3); }
.chip.s-cancelled { border-left-color: var(--danger);   background: var(--danger-bg); text-decoration: line-through; opacity: .7; }
.chip.flagged { box-shadow: inset 0 0 0 1.5px var(--danger); }

.cal-more { font-size: 0.68rem; font-weight: 700; color: var(--muted); padding-left: 3px; }

/* week view */
.cal-week { display: grid; grid-template-columns: repeat(7, minmax(0,1fr)); gap: 12px; }
.week-col {
  background: #fff; border: 1px solid var(--line);
  border-radius: var(--r); overflow: hidden; display: flex; flex-direction: column;
}
.week-colhead {
  padding: 9px 11px; background: var(--surface-2);
  border-bottom: 1px solid var(--line);
}
.week-colhead .dow { font-size: 0.68rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.week-colhead .dnum { font-size: 1.18rem; font-weight: 800; color: var(--navy-900); line-height: 1.1; }
.week-col.today .week-colhead { background: var(--amber-100); }
.week-col.today .dnum { color: var(--amber-600); }
.week-body { padding: 8px; display: flex; flex-direction: column; gap: 5px; min-height: 120px; }
.week-empty { font-size: 0.74rem; color: #b3c2ce; text-align: center; padding: 16px 0; }

/* day view — chronological run sheet */
.runsheet { max-width: 1000px; margin: 0 auto; }
.run-item {
  display: grid; grid-template-columns: 92px 1fr auto;
  gap: 18px; align-items: start;
  background: #fff; border: 1px solid var(--line);
  border-radius: var(--r); padding: 15px 18px; margin-bottom: 10px;
  cursor: pointer; transition: border-color .14s, box-shadow .14s;
}
.run-item:hover { border-color: var(--teal-500); box-shadow: var(--shadow); }
.run-time {
  font-size: 1.18rem; font-weight: 800; color: var(--navy-900);
  font-variant-numeric: tabular-nums; letter-spacing: -0.02em;
}
.run-time small { display: block; font-size: 0.68rem; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .07em; }
.run-name { font-size: 1rem; font-weight: 800; color: var(--navy-900); margin-bottom: 2px; }
.run-route { font-size: 0.86rem; color: var(--ink-2); }
.run-meta { font-size: 0.78rem; color: var(--muted); margin-top: 5px; display: flex; gap: 12px; flex-wrap: wrap; }
.run-right { display: flex; flex-direction: column; align-items: flex-end; gap: 7px; }
.run-item.past { opacity: 0.55; }

.empty-state { text-align: center; padding: 70px 20px; color: var(--muted); }
.empty-state svg { width: 46px; height: 46px; color: #c3d0da; margin: 0 auto 14px; }
.empty-state h3 { color: var(--ink-2); font-size: 1.1rem; }

/* ---------------------------------------------------------------- drawer */
.drawer-scrim {
  position: fixed; inset: 0; background: rgba(6,21,35,.42);
  opacity: 0; pointer-events: none; transition: opacity .2s; z-index: 90;
}
.drawer-scrim.open { opacity: 1; pointer-events: auto; }

.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(520px, 100%);
  background: #fff; z-index: 100; display: flex; flex-direction: column;
  transform: translateX(100%); transition: transform .24s cubic-bezier(.4,0,.2,1);
  box-shadow: var(--shadow-lg);
}
.drawer.open { transform: none; }

.drawer-head {
  padding: 18px 22px; border-bottom: 1px solid var(--line);
  display: flex; align-items: flex-start; gap: 14px; background: var(--navy-800);
}
.drawer-head h2 { color: #fff; font-size: 1.18rem; margin: 0 0 3px; }
.drawer-head .ref { font-family: var(--font-mono); font-size: .78rem; color: var(--amber-400); font-weight: 700; }
.drawer-head .icon-btn { margin-left: auto; }

.drawer-body { flex: 1; overflow-y: auto; padding: 20px 22px 30px; }
.drawer-foot {
  padding: 14px 22px; border-top: 1px solid var(--line);
  background: var(--surface-2); display: flex; gap: 10px; flex-wrap: wrap;
}
.drawer-foot .spacer { flex: 1; }

.d-section { margin-bottom: 22px; }
.d-section > h4 {
  font-size: .71rem; font-weight: 800; letter-spacing: .1em;
  text-transform: uppercase; color: var(--muted);
  margin: 0 0 10px; padding-bottom: 7px; border-bottom: 1px solid var(--line-2);
}
.d-row { display: grid; grid-template-columns: 120px 1fr; gap: 10px; padding: 6px 0; font-size: .88rem; }
.d-row dt { color: var(--muted); font-weight: 650; }
.d-row dd { margin: 0; color: var(--ink); font-weight: 650; word-break: break-word; }

.verify-list { display: grid; gap: 8px; }
.verify-row {
  display: flex; align-items: center; gap: 11px;
  padding: 11px 13px; border: 1.5px solid var(--line); border-radius: var(--r-sm);
  background: #fff; cursor: pointer; transition: all .14s;
}
.verify-row:hover { border-color: var(--ink-3); }
.verify-row.on { background: var(--ok-bg); border-color: #9fd9c4; }
.verify-row .vbox {
  width: 22px; height: 22px; border-radius: 6px; flex: none;
  border: 2px solid var(--line); display: grid; place-items: center;
  color: transparent; background: #fff;
}
.verify-row.on .vbox { background: var(--ok); border-color: var(--ok); color: #fff; }
.verify-row .vbox svg { width: 13px; height: 13px; }
.verify-row strong { display: block; font-size: .88rem; color: var(--ink); }
.verify-row span { font-size: .76rem; color: var(--muted); }

.mini-label { font-size: .74rem; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin-bottom: 5px; display: block; }
.mini-input {
  width: 100%; padding: 9px 11px; border: 1.5px solid var(--line);
  border-radius: var(--r-sm); font: inherit; font-size: .88rem; background: #fff;
}
.mini-input:focus { outline: none; border-color: var(--teal-500); box-shadow: 0 0 0 3px rgba(20,163,174,.15); }

/* ---------------------------------------------------------------- modal */
.modal-scrim {
  position: fixed; inset: 0; background: rgba(6,21,35,.5); z-index: 110;
  display: none; align-items: center; justify-content: center; padding: 20px;
  overflow-y: auto;
}
.modal-scrim.open { display: flex; }
.modal {
  background: #fff; border-radius: var(--r-lg); width: min(660px, 100%);
  max-height: 90vh; display: flex; flex-direction: column; box-shadow: var(--shadow-lg);
}
.modal-head { padding: 20px 24px; border-bottom: 1px solid var(--line); display: flex; align-items: center; }
.modal-head h2 { margin: 0; font-size: 1.2rem; }
.modal-head .icon-btn {
  margin-left: auto; border-color: var(--line); background: #fff; color: var(--ink-2);
}
.modal-head .icon-btn:hover { background: var(--surface-2); }
.modal-body { padding: 22px 24px; overflow-y: auto; }
.modal-foot { padding: 15px 24px; border-top: 1px solid var(--line); background: var(--surface-2); display: flex; gap: 10px; justify-content: flex-end; }

/* ---------------------------------------------------------------- gate */
.gate {
  position: fixed; inset: 0; z-index: 200;
  background: linear-gradient(165deg, var(--navy-800), var(--navy-900));
  display: grid; place-items: center; padding: 24px;
}
.gate-card {
  background: #fff; border-radius: var(--r-lg); padding: 34px;
  width: min(400px, 100%); box-shadow: var(--shadow-lg); text-align: center;
}
.gate-card .brand-mark { width: 52px; height: 52px; margin: 0 auto 18px; border-radius: 14px; }
.gate-card .brand-mark svg { width: 28px; height: 28px; }
.gate-card h1 { font-size: 1.35rem; margin-bottom: 6px; }
.gate-card p { font-size: .88rem; color: var(--muted); margin-bottom: 22px; }

.toast {
  position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%) translateY(120%);
  background: var(--navy-900); color: #fff; padding: 12px 22px;
  border-radius: 999px; font-size: .87rem; font-weight: 700;
  box-shadow: var(--shadow-lg); z-index: 300; transition: transform .25s;
}
.toast.show { transform: translateX(-50%) translateY(0); }

/* ------------------------------------------------- master-sheet colors */
/* The owner's color language, matched to his Google Sheet:
   orange = assigned driver + pay · green = completed / paid            */
table.sheet td.cell-orange {
  background: #ffab2e !important;
  color: #3d2800;
  font-weight: 750;
}
table.sheet td.cell-green {
  background: #35d24a !important;
  color: #0b3d14;
  font-weight: 750;
}
tr.is-past table.sheet td.cell-green, table.sheet tr.is-past td.cell-green { opacity: 1; }
.dp-pax { font-weight: 550; opacity: 0.75; }

.arrival-btn {
  border: 1.5px solid var(--line); border-radius: 999px;
  background: #fff; color: var(--muted);
  font: inherit; font-size: 0.76rem; font-weight: 750;
  padding: 4px 12px; cursor: pointer;
}
.arrival-btn:hover { border-color: var(--teal-500); color: var(--teal-700); }
.arrival-btn.on {
  background: var(--ok-bg); border-color: #9ed9c2; color: var(--ok);
}

/* ------------------------------------------------------- staging inbox */
.inbox {
  position: sticky; left: 0;
  max-width: 100%;
  padding: 14px 16px 16px;
  background: #fff7e8;
  border-bottom: 2px solid #f0d9a8;
  display: grid; gap: 10px;
  box-sizing: border-box;
  width: min(100%, 1200px);
}
.inbox-head { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.inbox-head h3 { margin: 0; font-size: 0.95rem; color: #7c4e05; }
.inbox-head span { font-size: 0.8rem; font-weight: 650; color: #a2751f; }

.inbox-card {
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  background: #fff; border: 1px solid #eed9ac; border-radius: 12px;
  padding: 12px 16px; box-shadow: 0 1px 2px rgba(122, 82, 8, 0.06);
}
.inbox-main { flex: 1; min-width: 240px; }
.inbox-top { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; font-size: 0.92rem; }
.inbox-top strong { color: var(--navy-900); }
.inbox-top span { font-size: 0.85rem; color: var(--muted); }
.inbox-sub { font-size: 0.83rem; color: var(--ink-2); margin-top: 4px; }

.src-badge {
  display: inline-flex; padding: 3px 10px; border-radius: 999px;
  font-size: 0.7rem !important; font-weight: 800; letter-spacing: 0.05em;
  text-transform: uppercase; color: #fff !important;
}
.src-website { background: var(--teal-600); }
.src-email { background: #7c5cd6; }
.src-text { background: #2e8b57; }
.src-phone { background: var(--navy-600); }
.src-messenger { background: #0084ff; }

.inbox-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.ibtn {
  border: 1.5px solid var(--line); border-radius: 999px; background: #fff;
  font: inherit; font-size: 0.8rem; font-weight: 750; color: var(--ink-2);
  padding: 7px 14px; cursor: pointer; white-space: nowrap;
}
.ibtn:hover { border-color: var(--navy-600); }
.ibtn-lock { background: var(--navy-800); border-color: var(--navy-800); color: #fff; }
.ibtn-lock:hover { background: var(--navy-700); }
.ibtn-dismiss:hover { border-color: var(--danger); color: var(--danger); }

.st-inquiry { background: var(--info-bg); color: var(--info); }

/* Keep day-banner labels visible while scrolling the sheet sideways */
table.sheet tr.daybreak td .db-wrap {
  position: sticky; left: 14px;
  display: inline-flex; align-items: baseline; gap: 10px;
}

/* -------------------------------------------- sign in (texted code) */
.gate-card form { text-align: left; }
.gate-card .field { margin-bottom: 14px; }
.gate-loading { font-size: .9rem; color: var(--muted); padding: 10px 0 4px; }
.gate-card p.gate-sent { margin: 0 0 14px; font-size: .86rem; color: var(--ink-2); text-align: left; }
.gate-code { font-size: 1.35rem; letter-spacing: .3em; font-variant-numeric: tabular-nums; text-align: center; }
.gate-link {
  display: block; width: 100%; margin-top: 12px; border: 0; background: none; cursor: pointer;
  font: inherit; font-size: .82rem; font-weight: 650; color: var(--teal-700); text-decoration: underline;
}
.gate-err { display: block; margin-top: 12px; text-align: left; }
.gate-card p.gate-note { margin: 18px 0 0; font-size: .76rem; color: var(--muted); }

/* --------------------------------------- statuses + sources (reservation book) */
.st-booked      { background: var(--ok-bg);     color: var(--ok); }
.st-rescheduled { background: #ede4fb;          color: #6335b8; }
.st-no_show     { background: var(--warn-bg);   color: var(--warn); }
.st-logged      { background: var(--surface-3); color: var(--ink-3); }
.src-manual { background: #7c5cd6; }
table.sheet .src-badge { padding: 2px 8px; font-size: .64rem !important; }

table.sheet tbody tr[data-id] { cursor: pointer; }
table.sheet tr.is-cancelled td[data-col="customer"],
table.sheet tr.is-cancelled td[data-col="puaddr"],
table.sheet tr.is-cancelled td[data-col="dropoff"] { text-decoration: line-through; color: #93a7b7; }
.muted-cell { color: #b3c2ce; font-weight: 600; }

/* ------------------------------------------------- drawer: fare + cancel */
.fare-box { background: var(--surface-2); border: 1.5px solid var(--line); border-radius: var(--r-sm); padding: 14px 16px; }
.fare-box > h4 { border-bottom: 0; padding-bottom: 0; }
.pay-pill { display: inline-block; font-size: .78rem; font-weight: 750; padding: 5px 11px; border-radius: 999px; margin-bottom: 6px; }
.pay-pill.wait { background: var(--warn-bg); color: var(--warn); }
.pay-pill.sent { background: var(--teal-50); color: var(--teal-700); }
.pay-pill.paid { background: var(--ok-bg); color: var(--ok); }
.pay-pill.off  { background: var(--surface-3); color: var(--ink-2); }
.fare-hint { margin: 6px 0 0; font-size: .82rem; color: var(--muted); }
.fare-form { margin-top: 12px; }
.fare-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.fare-row .mini-input { width: 7.5em; flex: none; font-size: 1.05rem; font-weight: 750; font-variant-numeric: tabular-nums; }
.fare-dollar { font-size: 1.1rem; font-weight: 800; color: var(--navy-900); }
.pay-link { margin-top: 12px; display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; align-items: center; }
.pay-link .mini-label { grid-column: 1 / -1; margin: 0; }
.pay-link a { font-size: .82rem; font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.dw-msg { margin-top: 10px; font-size: .84rem; font-weight: 700; color: var(--ink-2); }
.dw-msg.ok { color: var(--ok); }
.dw-msg.err { color: var(--danger); }
.d-notes { margin: 0; white-space: pre-line; font-size: .88rem; color: var(--ink); }

.dw-cancel-btn { color: var(--danger); border-color: #f0c8c8; }
.cancel-box { background: var(--danger-bg); border: 1.5px solid #f0c8c8; border-radius: var(--r-sm); padding: 14px 16px; }
.cancel-box > h4 { color: var(--danger); border-bottom-color: #f0c8c8; }
.cancel-box p { margin: 0 0 8px; font-size: .88rem; color: var(--ink); }
.cancel-note { font-weight: 600; }
.cancel-actions { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; }
.btn-danger { background: var(--danger); border: 1.5px solid var(--danger); color: #fff; }
.btn-danger:hover { filter: brightness(1.1); }
.btn-danger:disabled, .fare-row .btn:disabled { opacity: .55; cursor: not-allowed; }

/* ------------------------------------------------- drivers: per leg + roster */
.drv-picks { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.drv-pick select { cursor: pointer; }
.drv-inline { display: inline; width: auto; margin: 0; padding: 0; }

.drv-modal { width: min(560px, 100%); }
.drv-hint { margin: 0 0 14px; }
.drv-list { display: grid; gap: 8px; margin-bottom: 18px; }
.drv-row {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  border: 1.5px solid var(--line); border-radius: var(--r-sm); padding: 10px 12px; background: #fff;
}
.drv-row.is-off { background: var(--surface-2); }
.drv-row.is-off strong { color: var(--muted); }
.drv-who { flex: 1; min-width: 150px; }
.drv-who strong { display: block; color: var(--navy-900); font-size: .92rem; }
.drv-who span { font-size: .8rem; color: var(--muted); }
.drv-row-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.drv-form { border-top: 1px solid var(--line-2); padding-top: 14px; }
.drv-form h3 { margin: 0 0 12px; font-size: .95rem; color: var(--navy-900); }
.drv-check { display: inline-flex; align-items: center; gap: 8px; font-size: .86rem; color: var(--ink-2); margin: 4px 0 10px; }
.drv-err { display: block; margin-bottom: 8px; }
.drv-actions { display: flex; gap: 10px; justify-content: flex-end; }

/* ------------------------------------------------- reminder text previews */
.sms-previews { display: grid; gap: 12px; margin-top: 12px; }
.sms-preview .mini-label { margin-bottom: 4px; }
.sms-bubble {
  white-space: pre-wrap; word-break: break-word; font-size: .84rem; line-height: 1.4; color: var(--ink);
  background: var(--teal-50); border: 1px solid var(--line-2); border-radius: 14px 14px 14px 4px; padding: 10px 12px;
}

/* ---------------------------------------------------------------- resp. */
@media (max-width: 1100px) {
  .statstrip { grid-template-columns: repeat(3, 1fr); }
  .cal-week { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 760px) {
  .statstrip { grid-template-columns: repeat(2, 1fr); }
  .cal-week { grid-template-columns: 1fr; }
  .toolbar { gap: 8px; }
  .datenav .range { min-width: 130px; font-size: .86rem; }
  .appbar-title span { display: none; }
  .run-item { grid-template-columns: 70px 1fr; }
  .run-right { grid-column: 1 / -1; flex-direction: row; align-items: center; }
  .cal-day { min-height: 84px; }

  /* Keep the whole app inside the phone's screen — only the
     spreadsheet itself scrolls sideways, never the page. */
  .appbar {
    flex-wrap: wrap; height: auto; min-height: 54px;
    padding: 8px 12px; row-gap: 8px; column-gap: 8px;
  }
  .appbar-title { font-size: 0.92rem; }
  .bar-btn { font-size: 0.74rem; padding: 6px 10px; }
  .sync-chip { font-size: 0.7rem; padding: 4px 9px; }
  .icon-btn { width: 31px; height: 31px; }

  .toolbar { padding: 9px 10px; }
  .viewtabs { width: 100%; }
  .viewtabs button { flex: 1; padding: 7px 6px; font-size: 0.8rem; }
  .search-box { flex: 1 1 100%; max-width: none; }
  .filter-sel { flex: 1 1 auto; min-width: 0; font-size: 0.8rem; }

  .stat-cell { padding: 9px 13px; }
  .stat-cell b { font-size: 1.15rem; }
  .stat-cell span { font-size: 0.72rem; }
}

@media (max-width: 480px) {
  .drv-picks { grid-template-columns: 1fr; }
  .statstrip { grid-template-columns: repeat(2, 1fr); }
  .stat-cell:last-child { grid-column: 1 / -1; }
  .datenav { width: 100%; justify-content: center; }
}

@media print {
  .appbar, .toolbar, .statstrip, .drawer, .drawer-scrim { display: none !important; }
  body.admin, .app, .viewport { overflow: visible; height: auto; }
}
