/* =====================================================================
   T&H Delivery Tracker — design system

   One theme only: white, light blue, dark grey. No dark mode, no theme
   switching. Built for a phone held in one hand, in a van, in a hurry.

   Sizing rules that are not negotiable:
     - nothing tappable is smaller than 48px
     - primary driver actions are 56px
     - body text is 16px, never smaller than 13px
   ===================================================================== */

:root {
  color-scheme: light;

  /* brand */
  --blue:        #2b5fe0;   /* buttons, icons */
  --blue-dark:   #1c4bd1;   /* pressed */
  --blue-tint:   #eaf2ff;   /* light blue surfaces */
  --blue-tint-2: #d8e6fd;

  /* status */
  --green:       #16a34a;
  --green-tint:  #e7f6ec;
  --orange:      #e08600;   /* fills only */
  --orange-ink:  #8a5600;   /* 5.5:1 - use for any orange TEXT */
  --orange-tint: #fdf2e0;
  --red:         #dc2626;
  --red-tint:    #fdeceb;
  --grey:        #8a949f;
  --grey-tint:   #f0f2f5;

  /* surfaces */
  --bg:      #ffffff;
  --card:    #ffffff;
  --sunken:  #f6f8fa;
  --border:  #e6eaef;
  --border-strong: #d5dbe3;

  /* text */
  --text:    #2a3441;   /* dark grey, not black */
  --text-2:  #6b7785;
  --text-3:  #6b7785;   /* 4.6:1 - was #97a1ad at 2.6:1, failed AA */
  --text-faint: #97a1ad; /* decorative glyphs only, never text */
  --on-blue: #ffffff;

  --radius:    14px;
  --radius-lg: 18px;
  --shadow:    0 1px 3px rgba(42, 52, 65, .07);
  --shadow-up: 0 -1px 0 var(--border);
  --shadow-sheet: 0 -8px 40px rgba(42, 52, 65, .18);

  --tap:    48px;
  --tap-lg: 56px;
  --nav-h:  66px;
  --topbar-h: 58px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  overscroll-behavior-y: none;
}

body {
  color: var(--text);
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
}

button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--blue); }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 8px; }
::-webkit-scrollbar-track { background: transparent; }

/* ==================================================================
   Layout
   ================================================================== */
#app { min-height: 100%; }

.app-shell { display: flex; min-height: 100vh; min-height: 100dvh; }

.main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom, 0px));
}

.page {
  padding: 14px;
  padding-left: calc(14px + env(safe-area-inset-left, 0px));
  padding-right: calc(14px + env(safe-area-inset-right, 0px));
  display: flex;
  flex-direction: column;
  gap: 14px;
  width: 100%;
  max-width: 1180px;
}
.page.wide { max-width: 1500px; }

/* ---- top bar ---------------------------------------------------- */
.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 12px;
  min-height: 58px;
  padding: 10px 16px;
  padding-top: calc(10px + env(safe-area-inset-top, 0px));
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}
.topbar h1 { font-size: 20px; margin: 0; font-weight: 700; letter-spacing: -.4px; }
.topbar .sub { font-size: 13px; color: var(--text-3); margin-top: 1px; }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }

/* ---- sidebar (admin, desktop only) ------------------------------ */
.sidebar { display: none; }

/* Superseded by the role-based rules in the TABLET section below. */

.sidebar .brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 18px; }
.sidebar .brand-mark {
  width: 36px; height: 36px; border-radius: 10px; flex: none;
  background: var(--blue); color: #fff;
  display: grid; place-items: center; font-weight: 800; font-size: 13px; letter-spacing: -.4px;
}
.sidebar .brand-text b { display: block; font-size: 15px; letter-spacing: -.2px; }
.sidebar .brand-text span { font-size: 12px; color: var(--text-3); }

.nav-link {
  display: flex; align-items: center; gap: 12px;
  min-height: var(--tap);
  padding: 0 12px; border-radius: 10px;
  color: var(--text-2); background: none; border: 0;
  font-size: 15px; font-weight: 550; text-align: left; width: 100%;
}
.nav-link svg { width: 20px; height: 20px; flex: none; color: var(--text-3); }
.nav-link:hover { background: var(--grey-tint); color: var(--text); }
.nav-link.active { background: var(--blue-tint); color: var(--blue-dark); font-weight: 650; }
.nav-link.active svg { color: var(--blue); }
.nav-spacer { flex: 1; }

/* ---- bottom tab bar --------------------------------------------- */
.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 40;
  display: flex;
  background: var(--bg);
  border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
.tabbar button {
  flex: 1; border: 0; background: none; color: var(--text-3);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  min-height: var(--nav-h);
  padding: 8px 4px;
  font-size: 13px; font-weight: 600;
  position: relative;
}
.tabbar button svg { width: 24px; height: 24px; }
.tabbar button.active { color: var(--blue); }
.tabbar .tab-badge {
  position: absolute; top: 8px; left: 50%; margin-left: 6px;
  background: var(--orange); color: #fff;
  font-size: 12px; font-weight: 700; line-height: 1;
  min-width: 22px; height: 22px; border-radius: 11px; padding: 0 6px;
  display: grid; place-items: center;
}

/* ==================================================================
   Cards
   ================================================================== */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.card-pad { padding: 16px; }
.card-head {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 16px; border-bottom: 1px solid var(--border);
}
.card-head h2 { margin: 0; font-size: 16px; font-weight: 700; letter-spacing: -.2px; }
.card-head .spacer { flex: 1; }

.section-title {
  font-size: 13px; font-weight: 700; color: var(--text-3);
  letter-spacing: .2px; margin: 4px 0 -4px;
}

/* ==================================================================
   Driver home — the three big numbers
   ================================================================== */

.bar-track { height: 10px; background: var(--grey-tint); border-radius: 6px; overflow: hidden; }
.bar-fill { height: 100%; background: var(--green); border-radius: 6px; transition: width .3s ease; }

/* ==================================================================
   Search
   ================================================================== */
.search-sticky {
  position: sticky; top: calc(var(--topbar-h) + env(safe-area-inset-top, 0px)); z-index: 20;
  background: var(--bg);
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  margin: -14px -14px 0;
}
.search-wrap { position: relative; }
.search-wrap > svg {
  position: absolute; left: 15px; top: 50%; transform: translateY(-50%);
  width: 21px; height: 21px; color: var(--text-3); pointer-events: none;
}
.search-wrap .input {
  padding-left: 46px; padding-right: 44px;
  min-height: var(--tap-lg);
  font-size: 17px;
  background: var(--sunken);
  border-color: transparent;
}
.search-wrap .input:focus { background: var(--card); border-color: var(--blue); }
.search-wrap .clear {
  position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
  border: 0; background: var(--border); color: var(--text-2);
  width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center;
}
.search-wrap .clear svg { width: 16px; height: 16px; }

/* ==================================================================
   Buttons
   ================================================================== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 9px;
  min-height: var(--tap); padding: 0 18px;
  border-radius: 12px; border: 1.5px solid var(--border-strong);
  background: var(--card); color: var(--text);
  font-weight: 650; font-size: 16px; letter-spacing: -.1px;
  white-space: nowrap;
  transition: background .12s, transform .08s;
}
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .45; pointer-events: none; }
.btn svg { width: 20px; height: 20px; flex: none; }

.btn.primary { background: var(--blue); border-color: var(--blue); color: var(--on-blue); }
.btn.primary:active { background: var(--blue-dark); }
.btn.tint { background: var(--blue-tint); border-color: transparent; color: var(--blue-dark); }
.btn.tint svg { color: var(--blue); }
.btn.subtle { background: var(--sunken); border-color: transparent; color: var(--text-2); }
.btn.ghost { background: none; border-color: transparent; color: var(--text-2); }
.btn.ghost:hover { background: var(--grey-tint); }
.btn.danger { background: var(--red); border-color: var(--red); color: #fff; }
.btn.lg { min-height: var(--tap-lg); font-size: 17px; border-radius: 14px; }
.btn.sm { min-height: 38px; font-size: 14px; padding: 0 12px; border-radius: 9px; }
.btn.sm svg { width: 16px; height: 16px; }
.btn.block { width: 100%; }
.btn.icon { width: var(--tap); padding: 0; }
.btn.icon.sm { width: 38px; }

.btn-row { display: flex; gap: 10px; flex-wrap: wrap; }
.btn-row .btn { flex: 1; }

/* ==================================================================
   Badges
   ================================================================== */
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 11px; border-radius: 999px;
  font-size: 13px; font-weight: 650; white-space: nowrap;
  background: var(--grey-tint); color: var(--text-2);
}
.badge .dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; flex: none; }
.badge.green  { background: var(--green-tint);  color: var(--green); }
.badge.orange { background: var(--orange-tint); color: var(--orange); }
.badge.red    { background: var(--red-tint);    color: var(--red); }
.badge.blue   { background: var(--blue-tint);   color: var(--blue-dark); }
.badge.grey   { background: var(--grey-tint);   color: var(--text-2); }
.badge.lg     { font-size: 14px; padding: 6px 14px; }

.pill-row { display: flex; flex-wrap: wrap; gap: 8px; }

/* ==================================================================
   Inputs
   ================================================================== */
.field { display: flex; flex-direction: column; gap: 7px; }
.field > label { font-size: 14px; font-weight: 650; color: var(--text-2); }
.field .hint { font-size: 13px; color: var(--text-3); }

.input, .select, .textarea {
  width: 100%;
  min-height: var(--tap);
  padding: 12px 14px;
  border: 1.5px solid var(--border-strong);
  border-radius: 12px;
  background: var(--card);
  color: var(--text);
  font-size: 16px;             /* 16px stops iOS zooming on focus */
  outline: none;
  transition: border-color .12s;
}
.textarea { min-height: 96px; resize: vertical; }
.input:focus, .select:focus, .textarea:focus { border-color: var(--blue); }
.input::placeholder, .textarea::placeholder { color: var(--text-3); }
.select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%236b7785' stroke-width='2.5' stroke-linecap='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center; background-size: 18px;
  padding-right: 40px;
}

.form-grid { display: grid; gap: 14px; }
@media (min-width: 620px) {
  .form-grid.two { grid-template-columns: 1fr 1fr; }
  .form-grid .span-2 { grid-column: 1 / -1; }
}

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

/* ---- filter chips ----------------------------------------------- */
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 2px 0; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  border: 1.5px solid var(--border-strong); background: var(--card);
  border-radius: 999px; padding: 0 16px; min-height: 44px;
  font-size: 15px; font-weight: 600; color: var(--text-2); white-space: nowrap;
}
.chip.active { background: var(--blue); border-color: var(--blue); color: #fff; }


/* ==================================================================
   Lists
   ================================================================== */
.list { display: flex; flex-direction: column; }
.list-row {
  display: flex; align-items: center; gap: 13px;
  padding: 14px 16px; min-height: 68px;
  border: 0; border-bottom: 1px solid var(--border);
  background: var(--card); text-align: left; width: 100%;
}
.list-row:last-child { border-bottom: 0; }
.list-row:active { background: var(--sunken); }
.list-row .grow { flex: 1; min-width: 0; }
.list-row .title { font-weight: 650; font-size: 16px; letter-spacing: -.2px; }
.list-row .meta {
  font-size: 14px; color: var(--text-3); margin-top: 3px;
  display: flex; gap: 7px; align-items: center; flex-wrap: wrap;
}
.list-row .meta .sep { opacity: .55; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.avatar {
  width: 42px; height: 42px; border-radius: 12px; flex: none;
  display: grid; place-items: center; font-weight: 700; font-size: 14px;
  background: var(--blue-tint); color: var(--blue-dark);
}
.avatar > svg { width: 20px; height: 20px; }

/* Any bare icon dropped into a flex container needs a size, or the SVG
   expands to fill it. `.chart` is excluded — charts set their own size. */
.list-row > svg:not(.chart),
.card-head > svg:not(.chart),
.row > svg:not(.chart),
.card-pad > svg:not(.chart) {
  width: 20px; height: 20px; flex: none; color: var(--text-3);
}

/* ==================================================================
   Tables (admin only)
   ================================================================== */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.data { width: 100%; border-collapse: collapse; font-size: 14.5px; min-width: 640px; }
table.data th {
  text-align: left; font-size: 12.5px; letter-spacing: .3px; text-transform: uppercase;
  color: var(--text-3); font-weight: 700; padding: 11px 13px;
  background: var(--sunken); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 1; white-space: nowrap;
}
table.data td { padding: 13px; border-bottom: 1px solid var(--border); }
table.data tr:last-child td { border-bottom: 0; }
table.data tbody tr:hover { background: var(--sunken); }
table.data td.num { text-align: right; font-variant-numeric: tabular-nums; }
table.data td.actions { text-align: right; white-space: nowrap; }

/* ==================================================================
   Bottom sheets
   ================================================================== */
.sheet-backdrop {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(42, 52, 65, .45);
  display: flex; align-items: flex-end; justify-content: center;
}
@media (min-width: 700px) { .sheet-backdrop { align-items: center; padding: 24px; } }

.sheet {
  background: var(--card);
  width: 100%; max-width: 560px;
  border-radius: 20px 20px 0 0;
  box-shadow: var(--shadow-sheet);
  max-height: 92vh; max-height: 92dvh;
  display: flex; flex-direction: column;
  animation: slideUp .22s ease;
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
@media (min-width: 700px) { .sheet { border-radius: var(--radius-lg); animation: none; } }
.sheet.wide { max-width: 880px; }

.sheet-head {
  display: flex; align-items: center; gap: 12px;
  padding: 16px 18px 14px; border-bottom: 1px solid var(--border);
}
.sheet-head h2 { margin: 0; font-size: 19px; font-weight: 700; letter-spacing: -.35px; }
.sheet-head .sub { font-size: 14px; color: var(--text-3); margin-top: 2px; }
.sheet-body { padding: 16px 18px; overflow-y: auto; flex: 1; display: flex; flex-direction: column; gap: 15px; }
.sheet-foot { padding: 14px 18px 18px; border-top: 1px solid var(--border); display: flex; gap: 10px; }
.sheet-foot .btn { flex: 1; min-height: var(--tap-lg); }
.grabber { width: 40px; height: 4px; border-radius: 2px; background: var(--border-strong); margin: 9px auto 0; }
@media (min-width: 700px) { .grabber { display: none; } }

@keyframes slideUp { from { transform: translateY(16px); } }

/* status choices in the mark-delivery sheet */
.status-choice {
  display: flex; align-items: center; gap: 14px;
  width: 100%; min-height: 60px; padding: 0 16px;
  border: 1.5px solid var(--border-strong); border-radius: 13px;
  background: var(--card); color: var(--text);
  font-size: 17px; font-weight: 600; text-align: left;
}
.status-choice .swatch { width: 13px; height: 13px; border-radius: 50%; flex: none; }
.status-choice .check { margin-left: auto; width: 22px; height: 22px; color: var(--blue); display: none; }
.status-choice.on { border-color: var(--blue); background: var(--blue-tint); color: var(--blue-dark); }
.status-choice.on .check { display: block; }

/* ==================================================================
   Toasts
   ================================================================== */
.toasts {
  position: fixed; z-index: 200; left: 50%; transform: translateX(-50%);
  bottom: calc(var(--nav-h) + 16px + env(safe-area-inset-bottom, 0px));
  display: flex; flex-direction: column; gap: 8px;
  width: min(460px, calc(100vw - 24px)); pointer-events: none;
}
@media (min-width: 900px) { .toasts { bottom: 22px; left: auto; right: 22px; transform: none; } }
.toast {
  background: var(--text); color: #fff;
  padding: 14px 16px; border-radius: 13px;
  box-shadow: 0 6px 24px rgba(42, 52, 65, .28);
  display: flex; align-items: center; gap: 11px;
  font-size: 15px; font-weight: 550;
  animation: slideUp .18s ease; pointer-events: auto;
}
.toast svg { width: 20px; height: 20px; flex: none; }
.toast.ok svg { color: #5fe0a0; }
.toast.err { background: var(--red); }
.toast.warn { background: var(--orange); }

/* ==================================================================
   Sync status — four states, no technical detail
   ================================================================== */
.sync-pill {
  display: inline-flex; align-items: center; gap: 7px;
  min-height: 44px; padding: 0 14px; border-radius: 999px;
  font-size: 14px; font-weight: 650; border: 0;
  background: var(--grey-tint); color: var(--text-2);
}
.sync-pill .dot { width: 9px; height: 9px; border-radius: 50%; background: currentColor; flex: none; }
.sync-pill.synced  { background: var(--green-tint);  color: var(--green); }
.sync-pill.offline { background: var(--orange-tint); color: var(--orange); }
.sync-pill.syncing { background: var(--blue-tint);   color: var(--blue-dark); }
.sync-pill.failed  { background: var(--red-tint);    color: var(--red); }
.sync-pill.syncing .dot { animation: blink 1s infinite; }
@keyframes blink { 50% { opacity: .3; } }

.banner {
  display: flex; align-items: center; justify-content: center; gap: 9px;
  padding: 11px 16px; font-size: 14.5px; font-weight: 600;
  background: var(--orange-tint); color: #8a5600;
}
.banner svg { width: 18px; height: 18px; flex: none; }
.banner.failed { background: var(--red-tint); color: var(--red); }

/* ==================================================================
   Login
   ================================================================== */
.auth {
  min-height: 100vh; min-height: 100dvh;
  display: grid; place-items: center; padding: 24px;
  background: var(--bg);
}
.auth-card { width: 100%; max-width: 400px; }
.auth-brand { display: flex; flex-direction: column; align-items: center; gap: 14px; margin-bottom: 30px; }
.auth-brand .mark {
  width: 68px; height: 68px; border-radius: 20px;
  background: var(--blue); color: #fff;
  display: grid; place-items: center; font-weight: 800; font-size: 22px; letter-spacing: -.7px;
}
.auth-brand h1 { margin: 0; font-size: 24px; font-weight: 750; letter-spacing: -.6px; text-align: center; }
.auth-brand p { margin: 0; font-size: 15px; color: var(--text-3); text-align: center; }

.pin-pad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.pin-pad button {
  min-height: 66px; border-radius: 15px;
  border: 1.5px solid var(--border-strong); background: var(--card);
  font-size: 24px; font-weight: 600;
}
.pin-pad button:active { background: var(--blue-tint); }
.pin-dots { display: flex; gap: 14px; justify-content: center; margin: 22px 0 26px; }
.pin-dots i { width: 15px; height: 15px; border-radius: 50%; background: var(--border-strong); }
.pin-dots i.on { background: var(--blue); }

/* ==================================================================
   Switch
   ================================================================== */
.switch { display: flex; align-items: center; gap: 13px; cursor: pointer; min-height: var(--tap); }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch .track {
  width: 51px; height: 31px; border-radius: 16px; background: var(--border-strong);
  position: relative; transition: background .18s; flex: none;
}
.switch .track::after {
  content: ''; position: absolute; top: 3px; left: 3px;
  width: 25px; height: 25px; border-radius: 50%; background: #fff;
  box-shadow: 0 1px 3px rgba(0,0,0,.2); transition: transform .18s;
}
.switch input:checked + .track { background: var(--green); }
.switch input:checked + .track::after { transform: translateX(20px); }
.switch .switch-label { font-size: 16px; font-weight: 600; }
.switch .switch-sub { font-size: 13.5px; color: var(--text-3); margin-top: 2px; }

/* ==================================================================
   Charts (admin only)
   ================================================================== */
.chart { width: 100%; }
.chart .grid-line { stroke: var(--border); stroke-width: 1; }
.chart .axis-text { fill: var(--text-3); font-size: 11px; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 13px; color: var(--text-2); }
.legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; margin-right: 6px; }

.stats { display: grid; gap: 10px; grid-template-columns: repeat(2, 1fr); }
@media (min-width: 700px) { .stats { grid-template-columns: repeat(4, 1fr); } }
.stat { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 15px; }
.stat .label { font-size: 13px; color: var(--text-3); font-weight: 600; }
.stat .value { font-size: 27px; font-weight: 750; letter-spacing: -1px; margin-top: 3px; line-height: 1.1; }
.stat .foot { font-size: 12.5px; color: var(--text-3); margin-top: 3px; }
.stat.accent { background: var(--blue-tint); border-color: transparent; }
.stat.accent .value { color: var(--blue-dark); }

/* ==================================================================
   Utilities
   ================================================================== */
.empty {
  text-align: center; padding: 48px 24px; color: var(--text-3);
  display: flex; flex-direction: column; align-items: center; gap: 12px;
}
.empty > svg { width: 48px; height: 48px; color: var(--border-strong); }
.empty b { color: var(--text); font-size: 17px; font-weight: 650; }
.empty p { margin: 0; font-size: 15px; max-width: 320px; line-height: 1.5; }

.skeleton {
  background: var(--sunken); border-radius: 12px;
  animation: pulse 1.4s ease-in-out infinite;
}
@keyframes pulse { 50% { opacity: .55; } }

.divider { height: 1px; background: var(--border); }
.stack { display: flex; flex-direction: column; gap: 12px; }
.row { display: flex; align-items: center; gap: 11px; }
.row.wrap { flex-wrap: wrap; }
.spacer { flex: 1; }
.muted { color: var(--text-3); }
.small { font-size: 14px; }
.center { text-align: center; }
.nowrap { white-space: nowrap; }
.mono { font-variant-numeric: tabular-nums; }

.thumb { width: 46px; height: 46px; border-radius: 9px; object-fit: cover; border: 1px solid var(--border); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* ==================================================================
   DRIVER — the stop card and everything around it

   Sizing here is deliberate and load-bearing:
     DONE      64px, full width, solid green   — the 85% action
     MAP       56px, tinted, in the header row — separated from DONE
     Problem   48px, 62% width, quiet          — the 15% action
   ================================================================== */

.driver-page { gap: 12px; }

/* ---- the one number at the top ---------------------------------- */
.count-head { padding: 4px 2px 2px; }
.count-main { display: flex; align-items: center; gap: 14px; }
.count-n {
  font-size: 46px; font-weight: 800; letter-spacing: -2.5px;
  line-height: 1; color: var(--text); font-variant-numeric: tabular-nums;
}
.count-icon { width: 46px; height: 46px; display: grid; place-items: center; color: var(--text-3); }
.count-icon svg { width: 40px; height: 40px; }
.count-icon.done { color: var(--green); }
.count-words b { display: block; font-size: 19px; font-weight: 700; letter-spacing: -.3px; line-height: 1.15; }
.count-words span { font-size: 14px; color: var(--text-3); }

/* one segment per stop — progress read by shape, not by number */
.segbar { display: flex; gap: 3px; margin-top: 12px; }
.segbar i {
  flex: 1; height: 8px; border-radius: 2px;
  background: var(--grey-tint); transition: background .25s ease;
}
.segbar i.on { background: var(--green); }

/* ---- the card --------------------------------------------------- */
.stop {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  padding: 14px;
}
/* "do this one first" is a black bar, not a word */
.stop-first { border-left: 6px solid var(--text); padding-left: 10px; }
.stop-done { background: var(--sunken); }

.stop-head { display: flex; align-items: flex-start; gap: 12px; }
.stop-id { flex: 1; min-width: 0; }
.stop-name {
  margin: 0; font-size: 20px; font-weight: 700;
  letter-spacing: -.4px; line-height: 1.2; color: var(--text);
}
.stop-addr { font-size: 15px; color: var(--text-2); margin-top: 4px; line-height: 1.35; }

.stop-map {
  flex: none; width: 64px; min-height: 56px;
  border: 1.5px solid var(--blue-tint-2); border-radius: 12px;
  background: var(--blue-tint); color: var(--blue-dark);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  font-size: 11px; font-weight: 700; letter-spacing: .4px;
}
.stop-map svg { width: 22px; height: 22px; }
.stop-map:active { background: var(--blue-tint-2); }

/* the office note, in full — truncating it defeats its whole purpose */
.stop-note {
  display: flex; gap: 9px; align-items: flex-start;
  margin-top: 11px; padding: 10px 12px;
  background: var(--orange-tint); color: var(--orange-ink);
  border-radius: 10px; font-size: 15px; font-weight: 550; line-height: 1.4;
}
.stop-note svg { width: 19px; height: 19px; flex: none; margin-top: 1px; }

/* ---- actions ---------------------------------------------------- */
.stop-actions { display: flex; flex-direction: column; align-items: center; gap: 8px; margin-top: 13px; }

.btn-done {
  width: 100%; min-height: 64px;
  border: 0; border-radius: 14px;
  background: var(--green); color: #fff;
  font-size: 21px; font-weight: 800; letter-spacing: .6px;
  display: flex; align-items: center; justify-content: center; gap: 12px;
  transition: transform .08s;
}
.btn-done svg { width: 28px; height: 28px; stroke-width: 3; }
.btn-done:active { transform: scale(.98); background: #12833d; }
.btn-done:disabled { opacity: .6; }

.btn-problem {
  width: 62%; min-height: 48px;
  border: 1.5px solid var(--border-strong); border-radius: 12px;
  background: var(--card); color: var(--text-2);
  font-size: 15px; font-weight: 650;
  display: flex; align-items: center; justify-content: center; gap: 8px;
}
.btn-problem svg { width: 18px; height: 18px; color: var(--orange-ink); }
.btn-problem:active { background: var(--grey-tint); }

/* ---- a finished stop -------------------------------------------- */
.stop-status { display: flex; align-items: center; gap: 11px; margin-top: 12px; }
.stop-status-mark {
  width: 42px; height: 42px; border-radius: 12px; flex: none;
  display: grid; place-items: center;
  background: color-mix(in srgb, var(--s) 13%, #fff); color: var(--s);
}
.stop-status-mark svg { width: 22px; height: 22px; stroke-width: 2.5; }
.stop-status-text { flex: 1; min-width: 0; }
.stop-status-text b { display: block; font-size: 16px; font-weight: 650; }
.stop-status-text span { font-size: 14px; color: var(--text-3); }
.stop-cloud { color: var(--orange-ink); }
.stop-cloud svg { width: 20px; height: 20px; }
.stop-change {
  flex: none; min-height: 44px; padding: 0 16px;
  border: 1.5px solid var(--border-strong); border-radius: 11px;
  background: var(--card); color: var(--text-2);
  font-size: 13px; font-weight: 750; letter-spacing: .5px;
}
.stop-change.small { min-height: 44px; padding: 0 13px; }

/* ---- the problem / change sheet --------------------------------- */
.problem-list { display: flex; flex-direction: column; gap: 11px; }
.problem-row {
  display: flex; align-items: center; gap: 15px;
  width: 100%; min-height: 72px; padding: 0 16px;
  border: 1.5px solid var(--border-strong); border-radius: 14px;
  background: var(--card); text-align: left;
}
.problem-row:active { background: color-mix(in srgb, var(--s) 10%, #fff); border-color: var(--s); }
.problem-mark {
  width: 44px; height: 44px; border-radius: 13px; flex: none;
  display: grid; place-items: center;
  background: color-mix(in srgb, var(--s) 14%, #fff); color: var(--s);
}
.problem-mark svg { width: 26px; height: 26px; stroke-width: 2.5; }
.problem-label { font-size: 18px; font-weight: 650; letter-spacing: -.2px; line-height: 1.25; }
.problem-note { font-size: 14px; color: var(--text-3); text-align: center; padding-top: 4px; }

/* ---- the undo bar ----------------------------------------------- */
.undo-bar {
  position: fixed; left: 0; right: 0; z-index: 90;
  bottom: calc(var(--nav-h) + env(safe-area-inset-bottom, 0px));
  background: var(--text); color: #fff;
  animation: undoIn .18s ease;
}
.role-admin .undo-bar { bottom: 0; }
@keyframes undoIn { from { transform: translateY(100%); } }

.undo-row { display: flex; align-items: center; gap: 12px; padding: 11px 14px; min-height: 56px; }
.undo-mark { width: 32px; height: 32px; border-radius: 10px; flex: none; display: grid; place-items: center; color: #fff; }
.undo-mark svg { width: 20px; height: 20px; stroke-width: 3; }
.undo-text { flex: 1; min-width: 0; }
.undo-text b { display: block; font-size: 16px; font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.undo-text span { font-size: 13.5px; opacity: .75; }
.undo-btn {
  flex: none; min-height: 44px; padding: 0 20px;
  border: 2px solid rgba(255, 255, 255, .5); border-radius: 11px;
  background: none; color: #fff; font-size: 15px; font-weight: 800; letter-spacing: .6px;
}
.undo-btn:active { background: rgba(255, 255, 255, .16); }
.undo-note {
  flex: none; min-height: 44px; padding: 0 14px;
  border: 0; border-radius: 11px;
  background: rgba(255, 255, 255, .14); color: #fff;
  font-size: 13px; font-weight: 700; letter-spacing: .4px;
  display: flex; align-items: center; gap: 6px;
}
.undo-note svg { width: 16px; height: 16px; }
.undo-timer { height: 3px; background: rgba(255, 255, 255, .18); }
.undo-timer i { display: block; height: 100%; width: 100%; }

/* ---- the Done list ---------------------------------------------- */
.day-head { display: flex; align-items: baseline; gap: 8px; padding: 0 2px; }
.day-head b { font-size: 16px; font-weight: 700; }
.day-head span { font-size: 14px; color: var(--text-3); }

.done-row {
  display: flex; align-items: center; gap: 12px;
  padding: 13px 14px; min-height: 64px;
  border-bottom: 1px solid var(--border); background: var(--card);
}
.done-row:last-child { border-bottom: 0; }
.done-mark {
  width: 40px; height: 40px; border-radius: 12px; flex: none;
  display: grid; place-items: center;
  background: color-mix(in srgb, var(--s) 13%, #fff); color: var(--s);
}
.done-mark svg { width: 21px; height: 21px; stroke-width: 2.5; }
.done-text { flex: 1; min-width: 0; }
.done-text b { display: block; font-size: 16.5px; font-weight: 650; line-height: 1.25; }
.done-text span { font-size: 14px; color: var(--text-3); }
.done-text em { display: block; font-size: 13.5px; color: var(--text-2); font-style: normal; margin-top: 3px; }


.big-check { color: var(--green); }
.big-check svg { width: 54px; height: 54px; stroke-width: 2.5; }

/* ---- driver topbar: icon buttons, no title clutter -------------- */
.topbar-driver { gap: 8px; }
.top-icon {
  width: 48px; height: 48px; flex: none;
  border: 0; border-radius: 12px; background: var(--sunken); color: var(--text-2);
  display: grid; place-items: center;
}
.top-icon svg { width: 22px; height: 22px; }
.top-icon:active { background: var(--grey-tint); }

/* sync pill gains an icon so the state survives being unread */
.sync-pill svg { width: 17px; height: 17px; }
.sync-pill .sync-word { font-size: 13.5px; }
@media (max-width: 380px) { .sync-pill .sync-word { display: none; } }

/* ==================================================================
   TABLET & iPad

   The navigation shape is decided by ROLE, not by screen width or by
   sniffing hover/pointer:

     driver  -> bottom tabs on every device, always. A driver holding an
                iPad in a van still wants the two tabs under their thumb,
                and an iPad reports pointer:coarse so the old media query
                took the sidebar away from office staff by accident.
     admin   -> sidebar from 900px up, on touch or not. Office staff on an
                iPad are sitting at a desk with the whole route in view.

   The driver's content is also capped and centred. A 64px DONE button
   stretched across 1024px is not a better button, and a 900px line of
   address text is harder to read, not easier.
   ================================================================== */

/* ---- admin: sidebar from 900px, touch or not -------------------- */
@media (min-width: 900px) {
  .role-admin .sidebar {
    display: flex; flex-direction: column; gap: 3px;
    width: 236px; flex: 0 0 236px;
    background: var(--sunken);
    border-right: 1px solid var(--border);
    padding: 16px 12px;
    position: sticky; top: 0;
    height: 100vh; height: 100dvh;
  }
  .role-admin .tabbar { display: none; }
  .role-admin .main { padding-bottom: 0; }
  .role-admin .page { padding: 20px 24px 40px; }
}

/* an iPad-sized admin gets roomier rows than a mouse user needs */
@media (min-width: 900px) and (pointer: coarse) {
  .role-admin .nav-link { min-height: 52px; font-size: 16px; }
  .role-admin table.data td { padding: 15px 13px; }
  .role-admin .btn.sm { min-height: 44px; font-size: 15px; }
  .role-admin .btn.icon.sm { width: 44px; }
}

/* ---- driver: tabs everywhere, content centred ------------------- */
.role-driver .sidebar { display: none !important; }
.role-driver .tabbar { display: flex !important; }
.role-driver .main { padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom, 0px)); }

/* Cap the driver's column so a stop card stays a card, not a banner. */
@media (min-width: 700px) {
  .role-driver .page { max-width: 680px; margin: 0 auto; }
  .role-driver .topbar { padding-left: 22px; padding-right: 22px; }

  /* bigger type — an iPad is held further from the face than a phone */
  .role-driver .stop-name { font-size: 22px; }
  .role-driver .stop-addr { font-size: 16px; }
  .role-driver .btn-done { min-height: 70px; font-size: 23px; }
  .role-driver .btn-done svg { width: 30px; height: 30px; }
  .role-driver .count-n { font-size: 54px; }
  .role-driver .count-words b { font-size: 21px; }

  /* the tab bar should not span a metre of glass */
  .role-driver .tabbar { justify-content: center; }
  .role-driver .tabbar button { flex: 0 1 220px; }

  /* the undo bar tracks the same centred column */
  .undo-bar { left: 50%; transform: translateX(-50%); width: min(680px, 100%); border-radius: 14px 14px 0 0; }
  @keyframes undoIn { from { transform: translate(-50%, 100%); } }
}

/* Landscape iPad: two columns of stops, so a full route is visible at
   once without scrolling past the fold. */
@media (min-width: 1000px) and (orientation: landscape) {
  .role-driver .page { max-width: 1000px; }
  .role-driver .stop-list { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; align-items: start; }
  /* Done and the empty states stay a single readable column. */
  .role-driver .driver-page > .card,
  .role-driver .driver-page > .stack:not(.stop-list) { max-width: 620px; margin-left: auto; margin-right: auto; width: 100%; }
  .undo-bar { width: min(1000px, 100%); }
}

/* ---- sheets on a tablet ----------------------------------------- */
@media (min-width: 700px) {
  .sheet { max-width: 620px; }
  .problem-row { min-height: 78px; }
  .problem-label { font-size: 19px; }
}

/* ---- split view / very narrow windows on iPad ------------------- */
@media (max-width: 400px) {
  .stop-map { width: 58px; min-height: 52px; }
  .stop-name { font-size: 18.5px; }
  .btn-done { font-size: 19px; min-height: 60px; }
}
