/* Shared component library. Every module uses these — no hand-rolled
   one-off styling per screen (the Apple/Google bar in PLAN.md §2c). */

/* ---- App bar ---- */
.appbar {
  position: sticky;
  top: 0;
  z-index: 20;
  height: var(--appbar-h);
  display: flex;
  align-items: center;
  gap: var(--space);
  padding: 0 calc(var(--space) * 2);
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}
/* On wide screens the bar's content aligns with the centered content column. */
@media (min-width: 700px) {
  .appbar { padding: 0 max(calc(var(--space) * 2), calc((100% - var(--content-max)) / 2)); }
  .bottomnav { padding-left: max(0px, calc((100% - var(--content-max)) / 2)); padding-right: max(0px, calc((100% - var(--content-max)) / 2)); }
}

.appbar__brand { display: flex; align-items: center; gap: 10px; font-weight: 700; }
.appbar__logo { width: 28px; height: 28px; border-radius: 7px; display: block; }
.appbar__title { font-size: var(--font-section); letter-spacing: -0.01em; }
.appbar__role {
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em;
  color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, transparent);
  padding: 3px 8px; border-radius: var(--radius-pill);
}
/* Back button (T2) — leftmost in the app bar on non-root screens. */
.appbar__back {
  display: inline-flex; align-items: center; gap: 2px;
  min-height: 44px; padding: 0 12px 0 8px; flex-shrink: 0;
  border: 1px solid var(--border); border-radius: var(--radius-ctl);
  background: var(--surface); color: var(--accent);
  font-size: var(--font-body); font-weight: 700; cursor: pointer;
}
.appbar__back:active { background: var(--hover); }
.appbar__back-chev { font-size: 22px; line-height: 1; margin-top: -2px; }

/* ---- Buttons ---- */
.btn {
  appearance: none;
  border: 1px solid transparent;
  border-radius: var(--radius-ctl);
  padding: 13px 18px;
  font-size: var(--font-body);
  font-weight: 600;
  min-height: 48px;            /* thumb-friendly target */
  cursor: pointer;
  transition: transform .04s ease, background .15s ease, opacity .15s ease;
}
.btn:active { transform: scale(0.985); }
.btn:disabled { opacity: 0.55; cursor: default; }
.btn--primary { background: var(--accent); color: #fff; }
.btn--ghost { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn--block { display: block; width: 100%; }
.btn--lg { min-height: 54px; font-size: var(--font-section); }
/* Compact action button — still clears the 44px glove-friendly floor. Use for
   in-row actions (View / ✕ / Done / Resolve) instead of inline min-height:32px. */
.btn--sm { min-height: 44px; padding: 6px 12px; font-size: var(--font-caption); }

/* ---- Cards ---- */
.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
  padding: calc(var(--space) * 2);
}

/* ---- Module grid (the one front door) ---- */
.tile-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: calc(var(--space) * 1.5);
}
@media (min-width: 600px) { .tile-grid { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 1100px) { .tile-grid { grid-template-columns: repeat(4, 1fr); } }

.tile {
  display: flex;
  flex-direction: column;
  gap: 10px;
  text-align: left;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
  padding: calc(var(--space) * 2);
  min-height: 116px;
  color: var(--text);
  cursor: pointer;
  transition: transform .06s ease, border-color .15s ease;
}
.tile:active { transform: scale(0.98); }
.tile:hover { border-color: color-mix(in srgb, var(--accent) 40%, var(--border)); }
.tile__icon {
  width: 40px; height: 40px; border-radius: var(--radius-ctl);
  display: flex; align-items: center; justify-content: center;
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  color: var(--accent);
  font-size: 22px;
}
.tile__title { font-weight: 700; font-size: var(--font-body); }
.tile__sub { font-size: var(--font-caption); color: var(--muted); }
.tile__icon--green { background: color-mix(in srgb, var(--brand-green) 14%, transparent); color: var(--pass-text); }
.tile--external .tile__title::after { content: ' ↗'; color: var(--muted); font-weight: 400; }

/* "Advanced" disclosure — folds engineer/rare tooling out of a new admin's way
   (A26 Settings data tools, A31 Integrations importers). Native <details> so
   it's keyboard- and screen-reader-friendly with no JS. */
.advanced { border: 1px solid var(--border); border-radius: var(--radius-card); background: var(--surface0); margin-bottom: 16px; overflow: hidden; }
.advanced > summary {
  cursor: pointer; list-style: none; min-height: 44px; padding: 12px 16px;
  display: flex; align-items: center; gap: 8px; font-weight: 800; color: var(--text);
}
.advanced > summary::-webkit-details-marker { display: none; }
.advanced > summary::after { content: '▸'; margin-left: auto; color: var(--muted); font-weight: 700; }
.advanced[open] > summary::after { content: '▾'; }
.advanced[open] > summary { border-bottom: 1px solid var(--border); }
.advanced__hint { font-weight: 400; color: var(--muted); font-size: var(--font-caption); }
.advanced__body { padding: 14px 14px 2px; }
/* Section-jump chips (A23) — quick scroll targets atop the long Settings scroll. */
.jumprow { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.jumpchip {
  min-height: 44px; padding: 0 14px; border-radius: var(--radius-pill);
  border: 1px solid var(--border); background: var(--surface); color: var(--accent);
  font-size: var(--font-caption); font-weight: 700; cursor: pointer;
}
.jumpchip:active { background: var(--hover); }

/* ---- Bottom navigation ---- */
.bottomnav {
  /* A normal flex item at the bottom of #app (NOT position:fixed) so it can't
     drift during iOS momentum scroll. The body's safe-area padding already lifts
     #app above the home indicator, so the bar needs no extra bottom inset here.
     On Mac it becomes a fixed left rail (see the desktop block). */
  flex: 0 0 auto;
  z-index: 20;
  height: var(--bottomnav-h);
  display: flex;
  background: var(--bg);
  border-top: 1px solid var(--border);
}
.bottomnav__item {
  flex: 1;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px;
  border: none; background: none; cursor: pointer;
  color: var(--muted);
  font-size: 11px; font-weight: 600;
}
.bottomnav__item[aria-current="page"] { color: var(--accent); }
.bottomnav__glyph { font-size: 22px; line-height: 1; }
.bottomnav__glyph svg, .tile__icon svg { display: block; }
.bottomnav__brand { display: none; } /* shown only as the rail header on Mac (see the desktop block) */

/* ---- Form fields ---- */
.field { margin-bottom: calc(var(--space) * 2); }
.field__label { display: block; font-size: var(--font-caption); font-weight: 600; color: var(--muted); margin-bottom: 6px; }
.input {
  width: 100%;
  min-height: 48px;
  padding: 12px 14px;
  font-size: var(--font-body);
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-ctl);
}
.input:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: var(--accent); }

/* ---- States: empty / error / loading ---- */
.state {
  text-align: center;
  padding: calc(var(--space) * 5) calc(var(--space) * 2);
  color: var(--muted);
}
.state__glyph { font-size: 40px; margin-bottom: var(--space); }
.state__title { font-weight: 700; color: var(--text); margin-bottom: 4px; }

.banner {
  border-radius: var(--radius-ctl);
  padding: 12px 14px;
  font-size: var(--font-caption);
  margin-bottom: calc(var(--space) * 2);
}
.banner--error { background: var(--fail-fill); color: var(--fail-text); border: 1px solid var(--fail-edge); }
.banner--info  { background: color-mix(in srgb, var(--info) 12%, transparent); color: var(--info); border: 1px solid color-mix(in srgb, var(--info) 45%, transparent); }

/* ---- Login ---- */
.login {
  /* Login mounts straight into #app (no #screen-root), so it owns its own
     scroll — fills the frame, scrolls if the keyboard shrinks the space. */
  min-height: 100%;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  display: flex; flex-direction: column; justify-content: center;
  max-width: 400px; margin: 0 auto; padding: calc(var(--space) * 3);
}
.login__logo { width: 76px; height: 76px; border-radius: 18px; margin: 0 auto calc(var(--space) * 2); display: block;
  box-shadow: 0 6px 18px color-mix(in srgb, var(--brand-blue) 28%, transparent); }
.login__title { text-align: center; font-size: 27px; font-weight: 800; letter-spacing: -0.01em; }
.login__sub { text-align: center; color: var(--muted); font-size: var(--font-body); margin-bottom: calc(var(--space) * 3); }

/* ---- Login (U19): logo plate, password eye, keep-signed-in, trust line ---- */
/* The real wordmark logo sits on a white plate so it stays legible in BOTH
   light and dark themes (the logo's navy text would vanish on the dark bg). */
.login__logoplate {
  margin: 0 auto calc(var(--space) * 2.5); background: #fff;
  border-radius: 18px; padding: 16px 22px; width: fit-content; max-width: 300px;
  box-shadow: 0 6px 20px rgba(26, 31, 54, 0.14); border: 1px solid rgba(0, 0, 0, 0.04);
}
.login__logoplate img { display: block; width: 236px; max-width: 100%; height: auto; }
.login__inwrap { position: relative; display: flex; }
.login__pw { padding-right: 52px; }
.login__eye {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  width: 40px; height: 40px; border: none; background: none; cursor: pointer;
  color: var(--faint); display: flex; align-items: center; justify-content: center; border-radius: 9px;
}
.login__eye:active { background: var(--surface); }
.login__remember { display: flex; align-items: center; gap: 9px; font-size: 14px; font-weight: 600; color: var(--text); margin: 2px 2px 14px; cursor: pointer; }
.login__remember input { width: 20px; height: 20px; accent-color: var(--accent); cursor: pointer; }
.login__stuck { text-align: center; margin-top: 14px; }
.login__stuck-link { background: none; border: none; color: var(--faint); font: inherit; font-size: 13px; text-decoration: underline; cursor: pointer; min-height: 44px; }
.login__stuck-panel { display: none; flex-direction: column; gap: 8px; margin-top: 4px; }
.login__stuck-panel.open { display: flex; }
.login__mini {
  display: flex; align-items: center; justify-content: center; min-height: 46px;
  border: 1px solid var(--border); background: var(--surface); border-radius: 11px;
  color: var(--text); font: inherit; font-weight: 600; font-size: 14px; cursor: pointer; text-decoration: none;
}
.login__mini:active { background: var(--hover); }
.login__foot { margin-top: 24px; text-align: center; color: var(--faint); font-size: var(--font-caption);
  display: flex; align-items: center; justify-content: center; gap: 6px; }
.banner--ok   { background: var(--pass-fill); color: var(--pass-text); border: 1px solid var(--pass-edge); }
.banner--warn { background: var(--warn-fill); color: var(--warn-text); border: 1px solid var(--warn-edge); }

/* ---- Weekly Recap ---- */
.weeknav {
  display: flex;
  align-items: center;
  gap: var(--space);
  margin-bottom: calc(var(--space) * 2);
}
.weeknav__btn {
  width: 44px; height: 44px;
  display: flex; align-items: center; justify-content: center;
  font-size: 24px; line-height: 1;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-ctl);
  cursor: pointer;
  transition: transform .04s ease, opacity .15s ease;
}
.weeknav__btn:active { transform: scale(0.94); }
.weeknav__btn:disabled { opacity: 0.35; cursor: default; }
.weeknav__mid { flex: 1; text-align: center; }
.weeknav__label { font-weight: 700; font-size: var(--font-section); font-variant-numeric: tabular-nums; }
.weeknav__sub { font-size: var(--font-caption); color: var(--muted); }
.weeknav__sub--now, .weeknav__sub--past { display: inline-block; padding: 1px 9px; border-radius: 999px; font-weight: 700; }
.weeknav__sub--now  { background: var(--pass-fill); color: var(--pass-text); }
.weeknav__sub--past { background: var(--warn-fill); color: var(--warn-text); }

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: calc(var(--space) * 1.5);
  margin-bottom: calc(var(--space) * 2);
}
@media (min-width: 700px) { .kpi-grid { grid-template-columns: repeat(3, 1fr); } }
.kpi {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
  padding: 14px 16px;
}
.kpi__label { font-size: var(--font-caption); font-weight: 600; color: var(--muted); margin-bottom: 4px; }
.kpi__value { font-size: 24px; font-weight: 800; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }

.section-title { font-size: var(--font-section); font-weight: 700; margin: calc(var(--space) * 2) 0 var(--space); }

.tier-row {
  display: flex; justify-content: space-between; align-items: baseline;
  padding: 9px 0;
  border-bottom: 1px solid var(--border);
  font-variant-numeric: tabular-nums;
}
.tier-row:last-of-type { border-bottom: none; }
.tier-row__pct { font-size: var(--font-caption); font-weight: 700; color: var(--muted); }
.tier-row__amt { font-weight: 700; }

.joblog { padding: 0; overflow: hidden; }
.joblog__row {
  display: flex; align-items: center; gap: calc(var(--space) * 1.5);
  padding: 12px 16px;
  border-top: 1px solid var(--border);
}
.joblog__row:first-child { border-top: none; }
.joblog__main { flex: 1; min-width: 0; }
.joblog__name { font-weight: 600; }
.joblog__desc {
  font-size: var(--font-caption); color: var(--muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.joblog__meta { font-size: var(--font-caption); color: var(--faint); margin-top: 2px; }
.joblog__right { text-align: right; flex-shrink: 0; }
.joblog__amt { font-weight: 700; font-variant-numeric: tabular-nums; }
.joblog__who { font-size: 11px; font-weight: 700; color: var(--accent); margin-top: 2px; letter-spacing: 0.03em; }
.joblog__due { font-size: var(--font-caption); color: var(--warn-text); margin-top: 2px; }

.reminder {
  border-color: var(--warn-edge);
  background: var(--warn-fill);
  margin-bottom: calc(var(--space) * 2);
  padding: 0;
  overflow: hidden;
}
.reminder__head {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 14px 16px 12px;
}
.reminder__head .tile__title { color: var(--warn-text); }
.reminder__head .tile__sub { color: var(--warn-text); opacity: 0.85; margin-top: 2px; }
.reminder__icon { font-size: 20px; line-height: 1.3; }
.reminder__list { background: var(--card-bg); border-top: 1px solid var(--warn-edge); }
.reminder__list .joblog__row:first-child { border-top: none; }

/* ---- Admin: commission tier rows ---- */
.person-row {
  display: flex; align-items: center; justify-content: space-between; gap: var(--space);
  padding: 12px 16px;
  border-top: 1px solid var(--border);
}
.person-row__who { min-width: 0; }
.seg {
  display: flex;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-ctl);
  padding: 2px;
  flex-shrink: 0;
}
.seg__btn {
  border: none; background: none; cursor: pointer;
  min-height: 44px; min-width: 48px;   /* glove-friendly (44px floor) */
  padding: 0 10px;
  font-size: var(--font-caption); font-weight: 700;
  color: var(--muted);
  border-radius: calc(var(--radius-ctl) - 3px);
  transition: background .12s ease, color .12s ease;
}
.seg__btn--on { background: var(--accent); color: #fff; }
.seg__btn--clear { min-width: 44px; }

.tier-chip {
  font-size: 11px; font-weight: 700;
  color: var(--pass-text);
  background: color-mix(in srgb, var(--brand-green) 14%, transparent);
  padding: 2px 7px; border-radius: var(--radius-pill);
}

/* ---- Asset detail sheet (Fleet): read-only field list + ⋯ overflow menu ---- */
.asset-ro { display: grid; grid-template-columns: auto 1fr; gap: 9px 16px; margin: 6px 0 0; font-size: 14px; }
.asset-ro dt { color: var(--muted); font-weight: 500; }
.asset-ro dd { margin: 0; text-align: right; font-weight: 600; color: var(--text); word-break: break-word; }
.sheet-menu { position: absolute; top: 100%; right: 10px; background: var(--bg); border: 1px solid var(--border); border-radius: 12px; box-shadow: 0 8px 30px rgba(0,0,0,.18); padding: 6px; min-width: 184px; z-index: 30; }
.sheet-menu__item { display: block; width: 100%; text-align: left; border: 0; background: transparent; padding: 11px 12px; border-radius: 8px; font-size: 14px; font-weight: 600; color: var(--text); cursor: pointer; min-height: 44px; }
.sheet-menu__item:active, .sheet-menu__item:hover { background: var(--surface); }
.sheet-menu__item--on { color: var(--accent); background: var(--surface); }

/* ---- Reports (U12 polish): light secondary sub-row + compact Compare ----
   The group tabs stay a full segmented bar; the view-within-a-group and the
   occasional Compare control sit on one quiet underlined row beneath them, so
   the screen reads "main tab → its view" instead of three look-alike bars. */
.reports-ctrl { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 44px; border-bottom: 1px solid var(--surface2); margin: 0 0 14px; }
.subtabs { display: flex; gap: 18px; }
.subtab { border: 0; background: transparent; cursor: pointer; min-height: 44px; padding: 10px 0; position: relative; font-size: 14px; font-weight: 600; color: var(--muted); }
.subtab--on { color: var(--accent); }
.subtab--on::after { content: ''; position: absolute; left: 0; right: 0; bottom: -1px; height: 3px; border-radius: 3px; background: var(--accent); }
.cmp-btn { border: 1px solid var(--border); background: var(--surface); color: var(--muted); cursor: pointer; border-radius: var(--radius-pill); padding: 0 14px; min-height: 44px; white-space: nowrap; font-size: var(--font-caption); font-weight: 700; }
.cmp-btn--active { color: var(--accent); border-color: var(--accent); }

/* ---- Tappable list rows + slide-up sheet (job detail) ---- */
.joblog__row--tap { cursor: pointer; transition: background .12s ease; }
.joblog__row--tap:active { background: var(--hover); }
.joblog__row--tap::after { content: '›'; color: var(--faint); font-size: 20px; margin-left: 4px; flex-shrink: 0; }

/* ---- Schedule (U18): Today reset, now-marker, search clear + count ---- */
.sched-today {
  height: 44px; padding: 0 14px; flex-shrink: 0;
  border: 1px solid var(--accent); background: var(--bg); color: var(--accent);
  font-weight: 700; font-size: 14px; border-radius: var(--radius-ctl);
  cursor: pointer; white-space: nowrap;
}
.sched-today:active { transform: scale(0.96); }
.searchwrap { position: relative; margin-bottom: 8px; }
.searchwrap .input { padding-right: 44px; }
.input[type=search]::-webkit-search-cancel-button { -webkit-appearance: none; display: none; }
.search-clear {
  position: absolute; right: 7px; top: 50%; transform: translateY(-50%);
  width: 34px; height: 34px; border: none; background: none;
  font-size: 18px; color: var(--faint); cursor: pointer; border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
}
.search-clear[hidden] { display: none; } /* `display:flex` above would otherwise defeat the hidden attribute */
.search-count { font-size: var(--font-caption); color: var(--muted); margin: 0 2px 12px; }
.joblog__row--now { background: color-mix(in srgb, var(--pass-fill) 55%, transparent); box-shadow: inset 3px 0 0 var(--brand-green); }
.tag-now  { display: inline-block; background: var(--brand-green); color: #fff; padding: 2px 8px; border-radius: var(--radius-pill); font-size: 11px; font-weight: 800; }
.tag-next { display: inline-block; background: var(--accent);      color: #fff; padding: 2px 8px; border-radius: var(--radius-pill); font-size: 11px; font-weight: 800; }
.nowline { display: flex; align-items: center; gap: 8px; padding: 5px 16px; }
.nowline__dot { width: 9px; height: 9px; border-radius: 50%; background: var(--brand-green); flex-shrink: 0; box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand-green) 25%, transparent); }
.nowline__rule { flex: 1; height: 0; border-top: 2px dashed var(--brand-green); }
.nowline__txt { font-size: 11px; font-weight: 800; color: var(--brand-green); letter-spacing: .03em; }

.sheet {
  position: fixed; inset: 0; z-index: 110;
  background: var(--bg);
  display: flex; flex-direction: column;
  animation: sheet-in .24s ease;
}
@keyframes sheet-in { from { transform: translateY(100%); } to { transform: translateY(0); } }
@keyframes sheet-in-right { from { transform: translateX(100%); } to { transform: translateX(0); } }

/* A sheet that always slides in from the RIGHT — even on phones — for an
   iOS-style push-navigation feel. Used by the Receipts panel (a full-screen
   takeover on phones, a side panel on tablets/desktop). */
.sheet--right {
  left: auto;
  width: min(560px, 100vw);
  animation: sheet-in-right .24s ease;
}
@media (min-width: 700px) {
  .sheet--right { width: min(560px, 92vw); border-left: 1px solid var(--border); box-shadow: var(--shadow-overlay); }
}

/* iPad / Mac: details slide in as a panel from the RIGHT instead of a full-
   screen takeover — the content you tapped stays visible underneath. */
@media (min-width: 700px) {
  .sheet {
    left: auto;
    width: min(540px, 92vw);
    border-left: 1px solid var(--border);
    box-shadow: var(--shadow-overlay);
    animation: sheet-in-right .22s ease;
  }
  @keyframes sheet-in-right { from { transform: translateX(100%); } to { transform: translateX(0); } }
}
.sheet__bar {
  display: flex; align-items: center; gap: var(--space);
  height: var(--appbar-h); flex-shrink: 0;
  padding: 0 calc(var(--space) * 2);
  border-bottom: 1px solid var(--border);
}
.sheet__close {
  width: 44px; height: 44px; border: none; background: var(--surface);   /* glove-friendly */
  border-radius: var(--radius-ctl); cursor: pointer; font-size: 17px; color: var(--text);
}
.sheet__title { font-weight: 700; font-size: var(--font-section); }
.sheet__body { flex: 1; overflow-y: auto; }

/* ---- Reorderable (homepage cards/tiles, fleet): long-press → jiggle → drag,
   like the iPhone Home Screen. No edit button. ---- */
.rl-item { -webkit-touch-callout: none; user-select: none; }
.rl-edit > .rl-item { animation: rl-jiggle .26s ease-in-out infinite; }
.rl-edit > .rl-item:nth-child(2n) { animation-delay: -.13s; animation-duration: .3s; }
@keyframes rl-jiggle { 0% { transform: rotate(-1.1deg); } 50% { transform: rotate(1.1deg); } 100% { transform: rotate(-1.1deg); } }
.rl-clone { z-index: 300; pointer-events: none; opacity: .96; transform: scale(1.05);
  box-shadow: 0 10px 28px rgba(0,0,0,.28); border-radius: var(--radius-ctl, 12px); }
.rl-done { position: fixed; top: calc(env(safe-area-inset-top, 0px) + 10px); right: 14px; z-index: 310;
  background: var(--accent); color: #fff; border: none; border-radius: 999px; padding: 8px 18px;
  font-weight: 700; font-size: 14px; box-shadow: 0 2px 10px rgba(0,0,0,.22); cursor: pointer; }

/* ---- Update available bar ---- */
.updatebar {
  position: fixed;
  top: env(safe-area-inset-top); left: 0; right: 0;
  z-index: 120;
  display: flex; align-items: center; gap: var(--space);
  padding: 10px 16px;
  background: var(--accent); color: #fff;
  font-size: var(--font-caption); font-weight: 600;
  box-shadow: var(--shadow-overlay);
  animation: updatebar-in .25s ease;
}
.updatebar__text { flex: 1; }
.updatebar__btn {
  appearance: none; border: none; cursor: pointer;
  background: rgba(255, 255, 255, 0.22); color: #fff;
  font-weight: 700; font-size: var(--font-caption);
  padding: 7px 16px; border-radius: var(--radius-pill);
}
@keyframes updatebar-in { from { transform: translateY(-100%); } to { transform: translateY(0); } }

/* ---- Hero cards (Tech Pay / dashboard) — the badass numbers ---- */
.card--hero {
  background: linear-gradient(135deg, var(--accent), color-mix(in srgb, var(--accent) 65%, #001070));
  border: none;
  color: #fff;
}
.hero__label {
  font-size: 11px; font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase;
  opacity: 0.85; margin-bottom: 4px;
}
.hero__value {
  font-size: 38px; font-weight: 800; letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums; line-height: 1.1;
}
.hero__sub { font-size: var(--font-caption); opacity: 0.85; margin-top: 8px; line-height: 1.5; }
.hero__row { display: flex; gap: 18px; margin-top: 10px; }
.hero__stat { font-size: var(--font-caption); opacity: 0.9; }
.hero__stat b { display: block; font-size: 16px; font-variant-numeric: tabular-nums; }

/* ---- Owner command center / admin recap ---- */
.recap-grid { display: block; }
@media (min-width: 1000px) {
  .recap-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }
}
.avatar {
  width: 38px; height: 38px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  background: color-mix(in srgb, var(--accent) 14%, transparent);
  color: var(--accent); font-weight: 800; font-size: 13px; flex-shrink: 0;
}
.rankbar { height: 8px; border-radius: 999px; background: var(--surface2); overflow: hidden; }
.rankbar__fill { height: 100%; border-radius: 999px; background: var(--accent); transition: width .4s ease; }
.alertbar {
  width: 100%; display: flex; align-items: center; gap: 8px;
  border: 1px solid var(--warn-edge); background: var(--warn-fill); color: var(--warn-text);
  border-radius: var(--radius-ctl); padding: 11px 14px; margin-bottom: 12px;
  font-size: var(--font-caption); font-weight: 700; cursor: pointer;
}
.daychart { display: flex; align-items: flex-end; gap: 8px; }
.daychart__col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.daychart__bar { width: 100%; max-width: 44px; border-radius: 6px 6px 0 0; background: color-mix(in srgb, var(--accent) 55%, transparent); }
.daychart__bar--today { background: var(--accent); }
.daychart__val { font-size: var(--font-caption); font-weight: 700; color: var(--muted); font-variant-numeric: tabular-nums; }
.daychart__lbl { font-size: 12px; color: var(--muted); }

/* ---- Goal progress bars ---- */
.goalbar {
  height: 10px; border-radius: 999px;
  background: var(--surface2);
  overflow: hidden;
}
.goalbar__fill { height: 100%; border-radius: 999px; transition: width .4s ease; }
.goalbar__fill--pass { background: var(--brand-green); }
.goalbar__fill--warn { background: var(--warn-edge); }
.goalbar__fill--fail { background: var(--fail-edge); }
.goal-hit {
  color: var(--pass-text); background: var(--pass-fill);
  animation: goal-pop .5s ease;
}
@keyframes goal-pop {
  0% { transform: scale(0.6); }
  60% { transform: scale(1.15); }
  100% { transform: scale(1); }
}

/* ---- Confirm dialog ---- */
.confirm {
  position: fixed; inset: 0; z-index: 130;
  background: rgba(10, 14, 24, 0.45);
  display: flex; align-items: center; justify-content: center;
  padding: calc(var(--space) * 3);
  animation: confirm-in .15s ease;
}
@keyframes confirm-in { from { opacity: 0; } to { opacity: 1; } }
.confirm__card {
  width: 100%; max-width: 340px;
  background: var(--bg);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-overlay);
  padding: calc(var(--space) * 2.5);
}
.confirm__title { font-weight: 700; font-size: var(--font-section); margin-bottom: 6px; }
.confirm__msg { color: var(--muted); font-size: var(--font-caption); margin-bottom: 16px; line-height: 1.5; white-space: pre-line; }
.confirm__actions { display: flex; gap: 10px; }
.confirm__actions .btn { flex: 1; }
.confirm__danger { background: var(--fail-edge); color: #fff; }

/* ---- Lock screen (Face ID gate) ---- */
.lockscreen {
  position: fixed; inset: 0; z-index: 100;
  background: var(--bg);
  display: flex; align-items: center; justify-content: center;
  padding: calc(var(--space) * 3);
}
.lockscreen__inner { width: 100%; max-width: 360px; text-align: center; }

/* Respect reduced motion */
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

/* ===== Mac / desktop only — sidebar + wide dashboard.
   Gated by hover+pointer so touch iPhone/iPad keep the mobile layout untouched.
   (Chris is on Safari; flexbox/grid/color-mix/position:fixed are all supported.)
   An iPad with a Magic Keyboard/trackpad reports pointer:fine and would get
   this too — there's no reliable browser way to tell it from a Mac. ===== */
@media (min-width: 1100px) and (hover: hover) and (pointer: fine) {
  /* Make room for a fixed left nav rail: the rail is position:fixed so it
     ignores this padding and pins left; the appbar + content shift right. */
  #app { padding-left: var(--rail-w); }

  /* Bottom tab bar → fixed left sidebar rail (re-pin it; the phone layout has
     it as a flex item, here it's taken out of flow and the content shifts right). */
  .bottomnav {
    position: fixed;
    top: 0; bottom: 0; left: 0; right: auto;
    width: var(--rail-w);
    flex-direction: column; justify-content: flex-start; gap: 4px;
    padding: 12px 12px calc(env(safe-area-inset-bottom) + 12px);
    border-top: none; border-right: 1px solid var(--border);
  }
  .bottomnav__brand {
    display: flex; align-items: center; gap: 10px;
    padding: 6px 12px 14px; font-weight: 800; font-size: 17px; color: var(--text);
  }
  .bottomnav__item {
    flex: 0 0 auto; flex-direction: row; justify-content: flex-start;
    width: 100%; gap: 12px; padding: 11px 14px;
    border-radius: var(--radius-ctl); font-size: 14.5px;
    transition: background .12s ease, color .12s ease;
  }
  .bottomnav__item:hover { background: var(--hover); color: var(--text); }
  .bottomnav__item[aria-current="page"] {
    background: color-mix(in srgb, var(--accent) 12%, transparent);
    color: var(--accent);
  }
  .bottomnav__glyph { font-size: 20px; }

  /* Top bar: the rail carries the brand now, so drop the duplicate; the
     refresh button + role chip float to the right via the existing spacer. */
  .appbar { padding: 0 24px; }
  .appbar__brand { display: none; }

  /* Content fills the area right of the rail (no bottom-bar clearance). */
  .screen { max-width: 1480px; padding: calc(var(--space) * 3); }

  /* Denser tile grid on the wide screen. */
  .tile-grid { grid-template-columns: repeat(6, 1fr); }

  /* Owner dashboard cards two-up; the top card (hero/week) spans full width. */
  .home-cards {
    display: grid; grid-template-columns: 1fr 1fr;
    gap: calc(var(--space) * 1.5); align-items: start;
  }
  .home-cards > * { margin-bottom: 0 !important; }
  .home-cards > :first-child { grid-column: 1 / -1; }

  /* A little lift for mouse users. */
  .tile:hover { transform: translateY(-1px); }
}

/* ===== Fleet overview (Phase 4) — KPI board, status strip, charts ===== */

/* 4-up KPI grid on tablet/desktop; stays 2-up on a phone (cards stay legible). */
.kpi-grid--4 { grid-template-columns: repeat(2, 1fr); }
@media (min-width: 720px) { .kpi-grid--4 { grid-template-columns: repeat(4, 1fr); } }

.kpi__top { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.kpi__icon { color: var(--muted); flex-shrink: 0; display: flex; }
.kpi__icon svg { display: block; }
.kpi__sub { font-size: var(--font-caption); color: var(--muted); margin-top: 4px; }
.kpi__drill { color: var(--accent); font-weight: 700; white-space: nowrap; }
.kpi__spark { margin-top: 8px; }
.kpi__spark svg { display: block; width: 100%; height: 26px; }
.kpi--tap { cursor: pointer; transition: background .12s ease; }
.kpi--tap:active { background: var(--hover); }
/* Tinted alert cards — red = needs attention, amber = watch. */
.kpi--fail { background: var(--fail-fill); border-color: var(--fail-edge); }
.kpi--fail .kpi__value { color: var(--fail-text); }
.kpi--fail .kpi__icon { color: var(--fail-edge); }
.kpi--warn { background: var(--warn-fill); border-color: var(--warn-edge); }
.kpi--warn .kpi__value { color: var(--warn-text); }
.kpi--warn .kpi__icon { color: var(--warn-edge); }
.kpi--muted .kpi__value { color: var(--faint); }

/* Fleet status strip — "6 in service · 1 out of service · 0 down". */
.status-strip {
  display: flex; flex-wrap: wrap; gap: 16px;
  font-size: var(--font-caption); font-weight: 600; color: var(--muted);
  margin-bottom: 14px;
}
.status-strip b { color: var(--text); font-weight: 700; }
.sdot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 6px; vertical-align: middle; }

/* Charts (hand-rolled, no library): stacked bars reuse the daychart row;
   line + donut are inline SVG. */
.chart-cap { font-size: var(--font-caption); font-weight: 600; color: var(--muted); margin-bottom: 6px; }
.stackbar {
  width: 100%; max-width: 44px;
  display: flex; flex-direction: column; justify-content: flex-end;
  border-radius: 6px 6px 0 0; overflow: hidden;
}
.stackbar__seg { width: 100%; }
.fleetchart svg { display: block; max-width: 100%; }
.chart-legend { display: flex; flex-wrap: wrap; gap: 16px; margin-top: 12px; font-size: 12.5px; color: var(--muted); }
.chart-legend span { display: inline-flex; align-items: center; gap: 6px; }
.chart-legend i { width: 11px; height: 11px; border-radius: 3px; display: inline-block; }
.chart-empty { color: var(--muted); font-size: var(--font-caption); padding: 28px 0; text-align: center; }
