:root {
    --brand-hue: 186;
    --radius: 12px;
    --radius-sm: 8px;
    --radius-lg: 18px;
    --tap: 48px;
    --gap: 16px;
    --gap-sm: 8px;
    --gap-lg: 24px;
    --shadow-soft: 0 1px 2px rgba(0,0,0,.04), 0 4px 12px rgba(0,0,0,.04);
    --shadow-lifted: 0 4px 8px rgba(0,0,0,.06), 0 16px 32px rgba(0,0,0,.08);
    --duration: 180ms;
    --ease: cubic-bezier(.4,0,.2,1);
    --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --mono: 'JetBrains Mono', ui-monospace, 'SF Mono', Consolas, monospace;

    --bg: #f6f8fa;
    --bg-elev: #ffffff;
    --bg-elev-2: #ffffff;
    --bg-hover: #eef1f4;
    --border: #e1e4e8;
    --border-strong: #d1d5da;
    --text: #1f2328;
    --text-muted: #59636e;
    --text-faint: #848d97;
    --accent: hsl(var(--brand-hue) 65% 42%);
    --accent-soft: hsl(var(--brand-hue) 70% 92%);
    --accent-text: hsl(var(--brand-hue) 65% 38%);
    --success: #1a7f37;
    --success-soft: #dafbe1;
    --warning: #9a6700;
    --warning-soft: #fff8c5;
    --danger: #cf222e;
    --danger-soft: #ffebe9;
    --info: #0969da;
    --info-soft: #ddf4ff;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
    font-family: var(--font);
    font-size: 15px;
    line-height: 1.5;
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3, h4, h5, h6, p { margin: 0; }
a { color: var(--accent-text); text-decoration: none; }
a:hover { text-decoration: underline; }
.mono { font-family: var(--mono); }

/* APP LAYOUT (portal) ------------------------------------- */
.portal-app { min-height: 100vh; display: grid; grid-template-columns: 240px 1fr; grid-template-rows: auto 1fr; grid-template-areas: 'sidebar top' 'sidebar main'; }
@media (max-width: 900px) {
    .portal-app { grid-template-columns: 1fr; grid-template-areas: 'top' 'main'; }
    .portal-sidebar { display: none; }
}

.portal-topbar {
    grid-area: top;
    height: 64px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    background: var(--bg-elev);
    border-bottom: 1px solid var(--border);
    position: sticky; top: 0;
    z-index: 50;
}
.portal-topbar .crumb { color: var(--text-muted); font-size: 13px; position: relative; }
.portal-topbar .title { font-size: 18px; font-weight: 600; letter-spacing: -.01em; }
.portal-topbar .right { display: flex; align-items: center; gap: 12px; }
.portal-topbar .who { font-size: 13px; color: var(--text-muted); }
.portal-topbar .who strong { color: var(--text); font-weight: 600; }

.customer-switcher {
    background: transparent; border: none; padding: 2px 4px; margin: -2px -4px;
    color: var(--text-muted); font: inherit; cursor: pointer; border-radius: 6px;
    display: inline-flex; align-items: center;
}
.customer-switcher:hover { background: var(--surface-hover); color: var(--text); }
.customer-switcher-menu {
    position: absolute; top: calc(100% + 4px); left: 0; z-index: 50;
    background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.08);
    min-width: 280px; max-height: 60vh; overflow-y: auto; padding: 4px;
}
.customer-switcher-item {
    display: flex; align-items: center; width: 100%; text-align: left;
    background: transparent; border: none; padding: 8px 12px; border-radius: 6px;
    color: var(--text); font-size: 14px; cursor: pointer;
}
.customer-switcher-item:hover { background: var(--surface-hover); }
.customer-switcher-item.active { background: var(--surface-hover); font-weight: 600; }

/* SIDEBAR -------------------------------------------------- */
.portal-sidebar {
    grid-area: sidebar;
    background: var(--bg-elev);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow: hidden;
}
.portal-sidebar-head {
    height: 64px;
    display: flex;
    align-items: center;
    padding: 0 20px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}
.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 700;
    font-size: 16px;
    letter-spacing: -.01em;
    color: var(--text);
}
.brand-mark {
    width: 32px; height: 32px;
    border-radius: 8px;
    background: linear-gradient(135deg, hsl(var(--brand-hue) 80% 55%), hsl(calc(var(--brand-hue) - 30) 80% 50%));
    display: grid; place-items: center;
    color: white;
    font-size: 18px;
    box-shadow: 0 4px 12px hsl(var(--brand-hue) 80% 40% / .3);
}
.brand-text { display: flex; flex-direction: column; line-height: 1.1; }
.brand-sub { font-size: 10px; color: var(--text-muted); font-weight: 500; letter-spacing: .04em; text-transform: uppercase; }

.portal-sidebar-nav { flex: 1; overflow-y: auto; padding: 12px 10px; }
.nav-item {
    display: flex; align-items: center; gap: 12px;
    min-height: var(--tap);
    padding: 0 14px;
    border-radius: var(--radius);
    color: var(--text-muted);
    font-weight: 500;
    font-size: 14px;
    transition: background var(--duration) var(--ease), color var(--duration) var(--ease);
    width: 100%;
    text-align: left;
    margin-bottom: 2px;
    cursor: pointer;
}
.nav-item:hover { background: var(--bg-hover); color: var(--text); text-decoration: none; }
.nav-item.active { background: var(--accent-soft); color: var(--accent-text); font-weight: 600; }
.nav-item i { font-size: 20px; flex-shrink: 0; }
.nav-badge { margin-left: auto; background: var(--border); color: var(--text); font-size: 11px; padding: 2px 8px; border-radius: 999px; font-weight: 600; }
.nav-item.active .nav-badge { background: var(--accent); color: white; }

.portal-sidebar-foot { border-top: 1px solid var(--border); padding: 12px; flex-shrink: 0; }
.user-chip { display: flex; align-items: center; gap: 12px; padding: 8px; border-radius: var(--radius); width: 100%; }
.user-chip:hover { background: var(--bg-hover); text-decoration: none; }
.user-chip-info { flex: 1; min-width: 0; text-align: left; }
.user-chip-info .name { font-weight: 600; font-size: 13px; line-height: 1.2; color: var(--text); }
.user-chip-info .role { font-size: 11px; color: var(--text-muted); line-height: 1.2; margin-top: 2px; }
.avatar-sm {
    width: 36px; height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, hsl(var(--brand-hue) 60% 45%), hsl(calc(var(--brand-hue) + 40) 60% 40%));
    color: white;
    display: grid; place-items: center;
    font-weight: 600;
    font-size: 13px;
    flex-shrink: 0;
}

/* MAIN ----------------------------------------------------- */
.portal-main { grid-area: main; padding: 28px 32px 80px; overflow-x: hidden; }
@media (max-width: 720px) { .portal-main { padding: 20px 16px 80px; } }

.page-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 24px; flex-wrap: wrap; }
.page-head h1 { font-size: 26px; font-weight: 700; letter-spacing: -.02em; }
.page-head .sub { color: var(--text-muted); font-size: 14px; margin-top: 4px; }
.page-head-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* CARDS ---------------------------------------------------- */
.card {
    background: var(--bg-elev);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    transition: border-color var(--duration) var(--ease), box-shadow var(--duration) var(--ease);
}
.card:hover { border-color: var(--border-strong); }
.card-head { padding: 18px 20px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.card-head h3 { font-size: 15px; font-weight: 600; }
.card-head .head-actions { display: flex; gap: 8px; }
.card-body { padding: 20px; }
.card-body.compact { padding: 12px; }
.card-foot { padding: 14px 20px; border-top: 1px solid var(--border); background: var(--bg); font-size: 13px; color: var(--text-muted); }

/* GRIDS ---------------------------------------------------- */
.grid { display: grid; gap: var(--gap); }
.grid.g2 { grid-template-columns: repeat(2, 1fr); }
.grid.g3 { grid-template-columns: repeat(3, 1fr); }
.grid.g4 { grid-template-columns: repeat(4, 1fr); }
.grid.main-split { grid-template-columns: 2fr 1fr; }
@media (max-width: 1100px) { .grid.g3, .grid.g4 { grid-template-columns: repeat(2, 1fr); } .grid.main-split { grid-template-columns: 1fr; } }
@media (max-width: 720px) { .grid.g2, .grid.g3, .grid.g4 { grid-template-columns: 1fr; } }

/* STATS ---------------------------------------------------- */
.stat { padding: 20px; display: flex; flex-direction: column; gap: 8px; }
.stat-label { font-size: 12px; font-weight: 500; color: var(--text-muted); text-transform: uppercase; letter-spacing: .04em; display: flex; align-items: center; gap: 6px; }
.stat-value { font-size: 32px; font-weight: 700; letter-spacing: -.02em; line-height: 1; font-variant-numeric: tabular-nums; }
.stat-value.danger { color: var(--danger); }
.stat-value.warning { color: var(--warning); }
.stat-sub { font-size: 13px; color: var(--text-muted); }

/* TILES (action CTAs) -------------------------------------- */
.tile {
    padding: 24px;
    min-height: 140px;
    display: flex; flex-direction: column; justify-content: space-between;
    background: var(--bg-elev);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    cursor: pointer;
    transition: transform var(--duration) var(--ease), border-color var(--duration) var(--ease), box-shadow var(--duration) var(--ease);
    text-decoration: none;
    color: var(--text);
}
.tile:hover { transform: translateY(-2px); border-color: var(--accent); box-shadow: var(--shadow-lifted); text-decoration: none; }
.tile-icon { width: 48px; height: 48px; border-radius: var(--radius); display: grid; place-items: center; background: var(--accent-soft); color: var(--accent-text); font-size: 24px; }
.tile-title { font-size: 16px; font-weight: 600; margin-top: 14px; }
.tile-desc { font-size: 13px; color: var(--text-muted); margin-top: 4px; }

/* TABLES --------------------------------------------------- */
.table-wrap { overflow-x: auto; }
.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
.tbl th, .tbl td { text-align: left; padding: 14px 18px; border-bottom: 1px solid var(--border); }
.tbl th { color: var(--text-muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; background: var(--bg); }
.tbl tbody tr:hover { background: var(--bg-hover); }
.tbl tbody tr:last-child td { border-bottom: 0; }
.tbl td.num { font-variant-numeric: tabular-nums; }
.tbl td.right { text-align: right; }

/* BADGES --------------------------------------------------- */
.badge {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 3px 10px;
    font-size: 11px;
    font-weight: 600;
    border-radius: 999px;
    background: var(--bg-hover);
    color: var(--text);
    text-transform: uppercase;
    letter-spacing: .04em;
}
.badge-success { background: var(--success-soft); color: var(--success); }
.badge-warning { background: var(--warning-soft); color: var(--warning); }
.badge-danger { background: var(--danger-soft); color: var(--danger); }
.badge-info { background: var(--info-soft); color: var(--info); }
.badge-accent { background: var(--accent-soft); color: var(--accent-text); }
.badge-muted { background: var(--bg-hover); color: var(--text-muted); }

/* BUTTONS -------------------------------------------------- */
.btn {
    min-height: var(--tap);
    padding: 0 18px;
    border-radius: var(--radius);
    font-weight: 600;
    font-size: 14px;
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    transition: transform var(--duration) var(--ease), background var(--duration) var(--ease), border-color var(--duration) var(--ease);
    user-select: none;
    white-space: nowrap;
    text-decoration: none;
}
.btn:active { transform: scale(.98); }
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: hsl(var(--brand-hue) 65% 36%); color: #fff; }
.btn-ghost { background: transparent; color: var(--text); border: 1px solid var(--border); }
.btn-ghost:hover { background: var(--bg-hover); border-color: var(--border-strong); color: var(--text); }
.btn-subtle { background: var(--bg-hover); color: var(--text); }
.btn-subtle:hover { background: var(--border); color: var(--text); }
/* btn-sm still smaller than primary tap target, but bumped from 32 → 40
   so it stays comfortably tappable on touch screens. */
.btn-sm { min-height: 40px; padding: 0 14px; font-size: 13px; }
.btn-icon { padding: 0; min-width: var(--tap); width: var(--tap); }

/* Default styling for bare <input>/<select>/<textarea class="input">.
   Form-grid (.field) descendants get the same shape via the override below,
   but standalone .input elements need the rule too so the portal forms
   are touch-friendly without inline style="height:48px" everywhere. */
.input {
    display: block;
    width: 100%;
    min-height: var(--tap);
    padding: 10px 14px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 15px;
    font-family: inherit;
    color: var(--text);
    box-sizing: border-box;
}
.input:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: var(--accent); }
select.input {
    appearance: none;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'><path fill='%2359636e' d='M3 4.5l3 3 3-3'/></svg>");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
}
textarea.input { min-height: 96px; resize: vertical; padding-top: 12px; }
/* Touch-friendly radio + checkbox rows. Wrap inputs in a label with this
   class to get ≥48px tap height + visible spacing between sibling options. */
.touch-check {
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: var(--tap);
    padding: 6px 10px;
    border-radius: var(--radius-sm);
    cursor: pointer;
}
.touch-check:hover { background: var(--bg-hover); }
.touch-check input[type=radio],
.touch-check input[type=checkbox] {
    width: 22px;
    height: 22px;
    flex-shrink: 0;
    accent-color: var(--accent);
}

/* ACTIVITY FEED -------------------------------------------- */
.activity { display: flex; flex-direction: column; }
.activity-item { display: flex; gap: 14px; padding: 14px 0; border-bottom: 1px solid var(--border); }
.activity-item:last-child { border-bottom: 0; }
.activity-item .when { font-size: 12px; color: var(--text-faint); width: 80px; flex-shrink: 0; padding-top: 2px; }
.activity-item .ico { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent-text); flex-shrink: 0; font-size: 16px; }
.activity-item .what { flex: 1; min-width: 0; font-size: 14px; }
.activity-item .what .by { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

/* PIPELINE (order status steps) ---------------------------- */
.pipeline { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.pipeline-step {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 3px 8px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 600;
    background: var(--bg-hover);
    color: var(--text-faint);
    text-transform: uppercase;
    letter-spacing: .04em;
}
.pipeline-step.done { background: var(--success-soft); color: var(--success); }
.pipeline-step.current { background: var(--accent-soft); color: var(--accent-text); }

/* SCHEDULE LIST -------------------------------------------- */
.schedule-row {
    display: flex; align-items: center; gap: 16px;
    padding: 16px 18px;
    border-bottom: 1px solid var(--border);
}
.schedule-row:last-child { border-bottom: 0; }
.schedule-when { width: 80px; flex-shrink: 0; text-align: center; }
.schedule-when .dow { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: .06em; font-weight: 600; }
.schedule-when .day { font-size: 22px; font-weight: 700; line-height: 1; margin-top: 2px; }
.schedule-when .mon { font-size: 11px; color: var(--text-muted); margin-top: 2px; }
.schedule-info { flex: 1; min-width: 0; }
.schedule-info .title { font-weight: 600; font-size: 15px; }
.schedule-info .meta { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.schedule-row .right { display: flex; align-items: center; gap: 8px; }

/* CALENDAR (mini) ------------------------------------------ */
.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal-head { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: .04em; font-weight: 600; text-align: center; padding: 6px 0; }
.cal-day {
    aspect-ratio: 1;
    display: grid; place-items: center;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: background var(--duration) var(--ease);
    color: var(--text);
}
.cal-day:hover { background: var(--bg-hover); }
.cal-day.muted { color: var(--text-faint); }
.cal-day.unavailable { color: var(--text-faint); cursor: not-allowed; text-decoration: line-through; }
.cal-day.unavailable:hover { background: transparent; }
.cal-day.available { background: var(--success-soft); color: var(--success); font-weight: 600; }
.cal-day.available:hover { background: var(--success); color: #fff; }
.cal-day.selected { background: var(--accent); color: #fff; font-weight: 700; }

/* UTILITY -------------------------------------------------- */
.text-muted { color: var(--text-muted); }
.text-faint { color: var(--text-faint); }
.text-sm { font-size: 13px; }
.text-xs { font-size: 12px; }
.font-semi { font-weight: 600; }
.mt-md { margin-top: 16px; }
.mt-lg { margin-top: 24px; }
.mb-md { margin-bottom: 16px; }
.flex { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-sm { gap: 8px; }
.gap-md { gap: 16px; }

/* DRIVER APP (mobile-first) ================================ */
.driver-app {
    min-height: 100vh;
    max-width: 480px;
    margin: 0 auto;
    background: var(--bg);
    display: grid;
    grid-template-rows: auto 1fr auto;
    grid-template-areas: 'top' 'main' 'tabs';
    box-shadow: 0 0 0 1px var(--border);
}
@media (min-width: 720px) {
    .driver-app { max-width: 720px; box-shadow: var(--shadow-lifted); }
}

/* Top bar */
.driver-topbar {
    grid-area: top;
    position: sticky; top: 0; z-index: 10;
    background: var(--bg-elev);
    border-bottom: 1px solid var(--border);
    display: flex; align-items: center; gap: 10px;
    padding: 10px 14px;
    min-height: 56px;
}
.topbar-back {
    width: var(--tap); height: var(--tap);
    display: grid; place-items: center;
    border-radius: var(--radius);
    color: var(--text);
    font-size: 22px;
    background: transparent;
}
.topbar-back:active { background: var(--bg-hover); }
.topbar-brand { display: flex; align-items: center; gap: 10px; }
.brand-mark.sm { width: 32px; height: 32px; font-size: 16px; }
.brand-mark { width: 36px; height: 36px; border-radius: 10px; background: var(--accent); color: #fff; display: grid; place-items: center; font-size: 18px; }
.topbar-title { flex: 1; font-size: 17px; font-weight: 600; letter-spacing: -.01em; text-align: center; }
.topbar-spacer { width: 0; }
.topbar-track {
    display: inline-flex; align-items: center; gap: 6px;
    font-size: 11px; font-weight: 600; color: var(--success);
    background: var(--success-soft);
    padding: 5px 9px; border-radius: 999px;
    text-transform: uppercase; letter-spacing: .04em;
}
.topbar-track .ph-fill { animation: pulse 1.6s ease-in-out infinite; font-size: 9px; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .35; } }

/* Main */
.driver-main { grid-area: main; padding: 16px 16px 24px; overflow-x: hidden; }
.driver-main h1 { font-size: 22px; font-weight: 700; letter-spacing: -.02em; margin-bottom: 4px; }
.driver-main h2 { font-size: 16px; font-weight: 600; margin-bottom: 10px; }
.driver-main .lead { color: var(--text-muted); font-size: 14px; margin-bottom: 16px; }

/* Bottom tabs */
.driver-tabs {
    grid-area: tabs;
    position: sticky; bottom: 0; z-index: 10;
    display: grid; grid-template-columns: repeat(4, 1fr);
    background: var(--bg-elev);
    border-top: 1px solid var(--border);
    padding: 4px 4px env(safe-area-inset-bottom, 8px);
}
.driver-tabs .tab {
    min-height: var(--tap);
    padding: 6px 4px;
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
    color: var(--text-muted);
    font-size: 11px; font-weight: 600;
    border-radius: var(--radius);
    text-decoration: none;
}
.driver-tabs .tab i { font-size: 22px; line-height: 1; }
.driver-tabs .tab.active { color: var(--accent-text); }
.driver-tabs .tab:active { background: var(--bg-hover); }

/* Hero (today's route) */
.driver-hero {
    background: linear-gradient(135deg, var(--accent) 0%, hsl(var(--brand-hue) 65% 36%) 100%);
    color: #fff;
    border-radius: var(--radius-lg);
    padding: 18px 20px;
    margin-bottom: 16px;
}
.driver-hero .hero-label { font-size: 11px; font-weight: 600; opacity: .85; text-transform: uppercase; letter-spacing: .06em; }
.driver-hero .hero-route { font-size: 22px; font-weight: 700; letter-spacing: -.01em; margin-top: 4px; }
.driver-hero .hero-meta { font-size: 13px; opacity: .9; margin-top: 4px; }
.driver-hero .hero-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 14px; }
.driver-hero .hero-stat { background: rgba(255,255,255,.14); border-radius: var(--radius); padding: 10px 12px; }
.driver-hero .hero-stat .v { font-size: 22px; font-weight: 700; line-height: 1; }
.driver-hero .hero-stat .l { font-size: 11px; opacity: .85; text-transform: uppercase; letter-spacing: .04em; margin-top: 4px; }

/* Stop card (next-stop on overview, used as list item too) */
.stop-card {
    display: block;
    background: var(--bg-elev);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 14px 16px;
    margin-bottom: 10px;
    color: var(--text);
    text-decoration: none;
    transition: border-color var(--duration) var(--ease), transform var(--duration) var(--ease);
}
.stop-card:active { transform: scale(.99); border-color: var(--accent); text-decoration: none; }
.stop-card:hover { text-decoration: none; }
.stop-card.current { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.stop-card.done { opacity: .58; }

.stop-row { display: flex; align-items: flex-start; gap: 12px; }
.stop-num {
    width: 36px; height: 36px; flex-shrink: 0;
    border-radius: 50%;
    display: grid; place-items: center;
    background: var(--bg-hover); color: var(--text-muted);
    font-weight: 700; font-size: 14px;
    font-variant-numeric: tabular-nums;
}
.stop-card.current .stop-num { background: var(--accent); color: #fff; }
.stop-card.done .stop-num { background: var(--success); color: #fff; }
.stop-body { flex: 1; min-width: 0; }
.stop-kind { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; }
.stop-kind.collect { color: var(--info); }
.stop-kind.deliver { color: var(--accent-text); }
.stop-customer { font-size: 16px; font-weight: 600; margin-top: 2px; line-height: 1.25; }
.stop-addr { font-size: 13px; color: var(--text-muted); margin-top: 2px; white-space: pre-line; }
.stop-meta { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; font-size: 12px; color: var(--text-muted); align-items: center; }
.stop-meta .dot { width: 3px; height: 3px; border-radius: 50%; background: var(--text-faint); }
.stop-go { color: var(--text-faint); font-size: 22px; align-self: center; }

/* Items count chips (filled bags / trolleys, ignore empties) */
.item-chips { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.item-chip {
    display: inline-flex; align-items: center; gap: 6px;
    background: var(--bg-hover); color: var(--text);
    padding: 6px 10px;
    border-radius: 999px;
    font-size: 13px; font-weight: 600;
}
.item-chip i { font-size: 15px; color: var(--accent-text); }

/* Big primary CTA on driver pages */
.driver-cta {
    width: 100%;
    min-height: 56px;
    border-radius: var(--radius-lg);
    background: var(--accent);
    color: #fff;
    font-size: 16px; font-weight: 700;
    display: inline-flex; align-items: center; justify-content: center; gap: 10px;
    text-decoration: none;
}
.driver-cta:active { background: hsl(var(--brand-hue) 65% 34%); transform: scale(.99); color: #fff; }
.driver-cta:hover { color: #fff; text-decoration: none; }
.driver-cta.danger { background: var(--danger); }
.driver-cta.danger:active { background: #a01622; }
.driver-cta.subtle { background: var(--bg-hover); color: var(--text); }
.driver-cta.subtle:active { background: var(--border); }
.driver-cta-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }

/* Tracking banner (in-page, not just topbar) */
.track-banner {
    display: flex; align-items: center; gap: 10px;
    background: var(--success-soft);
    color: var(--success);
    border-radius: var(--radius);
    padding: 10px 14px;
    font-size: 13px; font-weight: 600;
    margin-bottom: 14px;
}
.track-banner i { font-size: 18px; }
.track-banner .why { color: var(--success); opacity: .8; font-weight: 500; font-size: 12px; }

/* Confirmation methods on stop detail */
.confirm-card { background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 16px; margin-top: 14px; }
.confirm-card .confirm-head { display: flex; align-items: center; gap: 10px; font-weight: 600; margin-bottom: 10px; }
.confirm-card .confirm-head i { font-size: 20px; color: var(--accent-text); }
.confirm-card .confirm-sub { font-size: 12px; color: var(--text-muted); margin-bottom: 12px; }

/* Signature pad (visual mockup only) */
.sig-pad {
    border: 2px dashed var(--border-strong);
    border-radius: var(--radius);
    height: 180px;
    background: #fff;
    display: grid; place-items: center;
    color: var(--text-faint);
    font-size: 13px;
    position: relative;
    overflow: hidden;
}
.sig-pad::after {
    content: '';
    position: absolute; left: 16px; right: 16px; bottom: 38px;
    border-bottom: 1px solid var(--border);
}
.sig-pad .sig-x { position: absolute; left: 16px; bottom: 22px; color: var(--text-muted); font-weight: 600; font-size: 14px; }
.sig-name { display: block; width: 100%; min-height: 44px; padding: 10px 12px; margin-top: 10px; border: 1px solid var(--border); border-radius: var(--radius); font-size: 14px; background: var(--bg-elev); }
.sig-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 8px; }
.sig-actions .btn { min-height: 36px; }

/* Photo capture mockup */
.photo-frame {
    border: 2px dashed var(--border-strong);
    border-radius: var(--radius);
    aspect-ratio: 4 / 3;
    background: var(--bg);
    display: grid; place-items: center;
    color: var(--text-muted);
    text-align: center;
    padding: 20px;
}
.photo-frame i { font-size: 36px; color: var(--text-faint); margin-bottom: 8px; }

/* Scan page */
.scan-readout {
    background: var(--bg-elev);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 22px 18px;
    margin-bottom: 14px;
    text-align: center;
}
.scan-count { font-size: 64px; font-weight: 800; letter-spacing: -.04em; line-height: 1; font-variant-numeric: tabular-nums; }
.scan-count-label { font-size: 12px; color: var(--text-muted); text-transform: uppercase; letter-spacing: .06em; font-weight: 600; margin-top: 6px; }
.scan-status { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-muted); margin-top: 12px; }
.scan-status .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--text-faint); }
.scan-status.live .dot { background: var(--success); animation: pulse 1.2s ease-in-out infinite; }
.scan-list { display: flex; flex-direction: column; gap: 6px; }
.scan-item {
    background: var(--bg-elev);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 10px 12px;
    display: flex; align-items: center; gap: 10px;
}
.scan-item .epc { font-family: var(--mono); font-size: 12px; color: var(--text-muted); }
.scan-item .label { font-weight: 600; font-size: 14px; }
.scan-item .ignored { opacity: .55; }
.scan-item.ignored .label::after { content: ' · ignored'; color: var(--warning); font-weight: 500; font-size: 12px; }

/* Profile (/driver/me) */
.profile-card {
    background: var(--bg-elev);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px;
    text-align: center;
    margin-bottom: 14px;
}
.profile-avatar {
    width: 72px; height: 72px;
    border-radius: 50%;
    background: var(--accent-soft);
    color: var(--accent-text);
    font-size: 28px; font-weight: 700;
    display: grid; place-items: center;
    margin: 0 auto 10px;
}
.profile-name { font-size: 18px; font-weight: 700; }
.profile-role { font-size: 13px; color: var(--text-muted); margin-top: 2px; }
.profile-stat-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 14px; }
.profile-stat { background: var(--bg); border-radius: var(--radius); padding: 10px; }
.profile-stat .v { font-size: 20px; font-weight: 700; }
.profile-stat .l { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: .04em; }

.list-card { background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; }
.list-row {
    display: flex; align-items: center; gap: 12px;
    padding: 14px 16px;
    min-height: var(--tap);
    border-bottom: 1px solid var(--border);
    color: var(--text);
    text-decoration: none;
}
.list-row:last-child { border-bottom: 0; }
.list-row:hover { text-decoration: none; }
.list-row:active { background: var(--bg-hover); }
.list-row i.lead { font-size: 20px; color: var(--accent-text); width: 28px; text-align: center; }
.list-row .body { flex: 1; min-width: 0; }
.list-row .body .t { font-weight: 600; font-size: 15px; }
.list-row .body .s { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.list-row i.go { color: var(--text-faint); font-size: 18px; }

/* Map (Mapbox embed) */
.driver-map {
    position: relative;
    width: 100%;
    height: 220px;
    border-radius: var(--radius-lg);
    overflow: hidden;
    background: var(--bg-hover);
    margin-bottom: 14px;
    border: 1px solid var(--border);
}
.driver-map .mapboxgl-canvas { outline: none; }
.driver-map-empty {
    height: 100%;
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
    text-align: center;
    color: var(--text-muted);
    padding: 20px;
}
.driver-map-empty i { font-size: 28px; color: var(--text-faint); }
.driver-map-empty strong { font-size: 14px; color: var(--text); }
.driver-map-empty span { font-size: 12px; }
.driver-map-pin {
    width: 28px; height: 28px;
    border-radius: 50%;
    background: var(--accent);
    color: #fff;
    display: grid; place-items: center;
    font-size: 12px; font-weight: 700;
    border: 2px solid #fff;
    box-shadow: 0 2px 4px rgba(0,0,0,.2);
}
.driver-map-pin.done { background: var(--success); }
.driver-map-pin.current { background: var(--accent); transform: scale(1.15); }
.driver-map-popup { font-family: var(--font); font-size: 13px; padding: 4px 6px; }
.driver-map-me {
    position: relative; width: 22px; height: 22px;
    display: grid; place-items: center;
}
.driver-map-me .me-dot {
    width: 14px; height: 14px;
    border-radius: 50%;
    background: var(--info);
    border: 2px solid #fff;
    box-shadow: 0 2px 4px rgba(0,0,0,.3);
    z-index: 2;
}
.driver-map-me .me-pulse {
    position: absolute; inset: 0;
    border-radius: 50%;
    background: var(--info);
    opacity: .35;
    animation: me-pulse 1.8s ease-out infinite;
}
@keyframes me-pulse {
    0%   { transform: scale(.6); opacity: .5; }
    100% { transform: scale(2.2); opacity: 0; }
}
.map-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: -6px; margin-bottom: 14px; }
.map-action {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 6px 10px;
    background: var(--bg-elev);
    border: 1px solid var(--border);
    border-radius: 999px;
    font-size: 12px; font-weight: 600;
    color: var(--text);
    text-decoration: none;
}
.map-action:active { background: var(--bg-hover); text-decoration: none; }
.map-action:hover { text-decoration: none; }

/* Route state bar */
.state-bar {
    background: var(--bg-elev);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 14px;
    margin-bottom: 14px;
}
.state-bar .state-row { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.state-bar .state-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--text-faint); flex-shrink: 0; }
.state-bar.idle .state-dot { background: var(--text-faint); }
.state-bar.active .state-dot { background: var(--success); animation: pulse 1.6s ease-in-out infinite; }
.state-bar.break .state-dot { background: var(--warning); }
.state-bar.done .state-dot { background: var(--accent); }
.state-bar .state-label { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--text-muted); }
.state-bar .state-time { font-size: 13px; font-weight: 600; margin-top: 2px; }
.state-bar .state-time .muted { color: var(--text-muted); font-weight: 500; font-size: 12px; }

/* Vehicle check items */
.check-item {
    display: flex; align-items: center; gap: 12px;
    padding: 14px 16px;
    background: var(--bg-elev);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 8px;
    min-height: var(--tap);
}
.check-item .check-box {
    width: 28px; height: 28px; flex-shrink: 0;
    border-radius: 8px;
    border: 2px solid var(--border-strong);
    display: grid; place-items: center;
    color: transparent;
    font-size: 18px;
}
.check-item.done .check-box {
    background: var(--success);
    border-color: var(--success);
    color: #fff;
}
.check-item.fail .check-box {
    background: var(--danger);
    border-color: var(--danger);
    color: #fff;
}
.check-item .body { flex: 1; min-width: 0; }
.check-item .body .t { font-weight: 600; font-size: 15px; }
.check-item .body .s { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.check-item .check-fail-link { font-size: 12px; color: var(--danger); font-weight: 600; }

.checks-summary {
    display: flex; align-items: center; justify-content: space-between;
    padding: 14px 16px;
    background: var(--accent-soft);
    color: var(--accent-text);
    border-radius: var(--radius);
    margin-bottom: 14px;
    font-size: 14px; font-weight: 600;
}
.checks-summary.complete { background: var(--success-soft); color: var(--success); }

/* Defect form */
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 12px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: .04em; margin-bottom: 6px; }
.field select, .field input[type=text], .field textarea {
    width: 100%;
    min-height: var(--tap);
    padding: 10px 12px;
    background: var(--bg-elev);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 14px;
    color: var(--text);
}
.field textarea { min-height: 96px; resize: vertical; padding-top: 12px; }
.field select { appearance: none; background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'><path fill='%2359636e' d='M3 4.5l3 3 3-3'/></svg>"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 36px; }

.severity-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.severity {
    background: var(--bg-elev);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 10px 8px;
    text-align: center;
    font-size: 12px; font-weight: 600;
    color: var(--text);
    min-height: var(--tap);
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
}
.severity i { font-size: 20px; margin-bottom: 4px; }
.severity.green { color: var(--success); }
.severity.amber { color: var(--warning); }
.severity.red { color: var(--danger); }
.severity.selected.green { background: var(--success-soft); border-color: var(--success); }
.severity.selected.amber { background: var(--warning-soft); border-color: var(--warning); }
.severity.selected.red { background: var(--danger-soft); border-color: var(--danger); }

/* Photo upload row (mockup) */
.photo-add {
    display: flex; align-items: center; gap: 10px;
    padding: 14px;
    background: var(--bg-elev);
    border: 1px dashed var(--border-strong);
    border-radius: var(--radius);
    color: var(--text-muted);
    font-size: 13px; font-weight: 500;
    min-height: var(--tap);
}
.photo-add i { font-size: 22px; color: var(--text-faint); }


/* =====================================================================
   Portal landing — pre-auth welcome card + post-auth empty state
   ===================================================================== */
.portal-welcome {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: calc(100vh - 200px);
    padding: 32px 16px;
}
.welcome-card {
    max-width: 520px;
    width: 100%;
    background: var(--surface, #fff);
    border: 1px solid var(--border, #e5e7eb);
    border-radius: 16px;
    padding: 48px 40px;
    text-align: center;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.04);
}
.welcome-mark {
    width: 72px;
    height: 72px;
    margin: 0 auto 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, hsl(var(--brand-hue) 80% 55%), hsl(calc(var(--brand-hue) - 30) 80% 50%));
    color: #fff;
    font-size: 32px;
    box-shadow: 0 6px 18px hsl(var(--brand-hue) 80% 40% / .25);
}
.welcome-card h1 {
    margin: 0 0 12px;
    font-size: 26px;
    font-weight: 600;
    color: var(--text);
}
.welcome-sub {
    margin: 0 0 32px;
    color: var(--text-muted);
    font-size: 15px;
    line-height: 1.55;
}
.welcome-actions {
    margin: 0 0 24px;
}
.btn-lg {
    padding: 12px 28px;
    font-size: 15px;
    font-weight: 600;
    border-radius: 10px;
}
.btn-lg i {
    margin-right: 8px;
}
.welcome-footnote {
    margin: 0;
    color: var(--text-muted);
    font-size: 13px;
    line-height: 1.5;
}
.welcome-footnote a {
    color: var(--accent-text);
    text-decoration: none;
}
.welcome-footnote a:hover {
    text-decoration: underline;
}

/* Authed-but-not-connected empty state */
.portal-empty {
    padding: 56px 32px;
    text-align: center;
    color: var(--text-muted);
}
.portal-empty-icon {
    font-size: 40px;
    display: block;
    margin: 0 auto 16px;
    color: var(--accent);
    opacity: 0.7;
}
.portal-empty-title {
    color: var(--text);
    font-weight: 600;
    font-size: 16px;
    margin-bottom: 8px;
}
.portal-empty-sub {
    font-size: 14px;
    line-height: 1.55;
    max-width: 440px;
    margin: 0 auto;
}

/* Anonymous shell — full-viewport background for the pre-auth welcome card */
.portal-shell-anon {
    min-height: 100vh;
    background: linear-gradient(135deg, hsl(var(--brand-hue) 30% 96%) 0%, hsl(var(--brand-hue) 20% 92%) 100%);
}
.portal-shell-anon .portal-welcome { min-height: 100vh; }

/* =====================================================================
   Auth pages (Login / Register / Lockout / etc.) — match portal welcome
   ===================================================================== */
.welcome-card.auth-card { max-width: 460px; padding: 44px 36px 36px; }
.welcome-card.auth-card h1 { font-size: 24px; margin-bottom: 8px; }
.welcome-card.auth-card .welcome-sub { margin-bottom: 24px; font-size: 14px; }

.auth-form { display: flex; flex-direction: column; gap: 16px; text-align: left; }
.auth-field { display: flex; flex-direction: column; gap: 6px; }
.auth-field label {
    font-size: 13px;
    font-weight: 500;
    color: var(--text);
}
.auth-input {
    width: 100%;
    box-sizing: border-box;
    padding: 11px 14px;
    font-size: 15px;
    border: 1px solid var(--border, #d8dde3);
    border-radius: 8px;
    background: #fff;
    color: var(--text);
    transition: border-color .12s, box-shadow .12s;
}
.auth-input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px hsl(var(--brand-hue) 70% 85% / .35);
}
.auth-input::placeholder { color: var(--text-faint, #b3b9c2); }
.auth-validation { color: #c8392c; font-size: 13px; }

.auth-remember {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    color: var(--text-muted);
    cursor: pointer;
    user-select: none;
}
.auth-remember input { width: 16px; height: 16px; }

.auth-submit {
    width: 100%;
    justify-content: center;
    margin-top: 4px;
}

.auth-error {
    margin: 0 0 18px;
    padding: 12px 14px;
    border-radius: 8px;
    background: hsl(0 70% 96%);
    color: #a3261c;
    border: 1px solid hsl(0 60% 88%);
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 8px;
    text-align: left;
}
.auth-error i { font-size: 18px; }
