/*
 * Omnx Flow — the phone surface (component sheet)
 * ---------------------------------------------------------------------------
 * Bottom tab bar, bottom sheets, list rows and the stat tiles the staff app is
 * built from. Ported from the Xeva mobile shell, token-native.
 *
 * THE FIVE RULES THAT MAKE A WEB APP FEEL NATIVE ON A PHONE, all applied here:
 *   1. 44px minimum touch target. Anything smaller is a mis-tap on a forecourt
 *      in the rain.
 *   2. 16px font on every input. Below that, iOS Safari zooms the viewport on
 *      focus and the person loses the page.
 *   3. env(safe-area-inset-bottom) on the fixed bar AND on the body padding —
 *      and it only returns a non-zero value when the page also sets
 *      viewport-fit=cover, which every page using this sheet must.
 *   4. -webkit-overflow-scrolling: touch on scrollers, or momentum dies.
 *   5. Hover-only affordances forced visible, because there is no hover.
 */

/* ============================================================
   APP SHELL
   ============================================================ */
.app-mobile {
  /* 100dvh, not 100vh: on iOS Safari 100vh is the LARGE viewport (URL bar
     hidden), so a 100vh frame is ~60-100px taller than what the person can
     see and the page always has phantom scroll at the bottom. The vh line
     stays first as the fallback for a browser without dvh. */
  min-height: 100vh;
  min-height: 100dvh;
  padding-bottom: calc(64px + var(--safe-bottom));
  background: var(--surface);
}

.mobile-topbar {
  position: sticky;
  top: 0;
  z-index: var(--z-sticky);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--spacing-sm);
  /* GROWS by the top inset instead of sitting under it. Installed on a
     notched phone there is no browser chrome above this bar, so without the
     inset the title and the back button run under the status bar. Reads 0 in
     a tab, so nothing moves in a browser. */
  height: calc(52px + var(--safe-top));
  padding: var(--safe-top) calc(var(--spacing-md) + var(--safe-right))
           0 calc(var(--spacing-md) + var(--safe-left));
  /* Sticky elements MUST paint an opaque background or content scrolls
     through them. */
  background: var(--surface-bar);
  border-bottom: 1px solid var(--line);
}
.mobile-title {
  margin: 0;
  font-size: var(--text-xl);
  font-weight: 500;
  letter-spacing: var(--tracking-tight);
  color: var(--text-primary);
}
.mobile-subtitle { font-size: var(--text-sm); color: var(--text-muted-2); }

.mobile-page { padding: var(--spacing-md); }
.mobile-page[hidden] { display: none; }

/* ============================================================
   BOTTOM TAB BAR
   ============================================================ */
.mobile-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: var(--z-nav);
  display: flex;
  height: calc(64px + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  background: var(--surface-bar);
  border-top: 1px solid var(--line);
  box-shadow: var(--shadow-nav-up);
}
.mobile-nav-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-height: 48px;
  padding: var(--spacing-sm) 0;
  background: none;
  border: none;
  color: var(--text-muted-2);
  cursor: pointer;
  position: relative;
  transition: color var(--transition-fast);
}
.mobile-nav-btn.active { color: var(--primary); }
.mobile-nav-btn .material-symbols-outlined { font-size: var(--text-3xl); }
.mobile-nav-label { font-size: var(--text-2xs); font-weight: 500; letter-spacing: 0.02em; }

/* Pinned to the top-right of a centred 24px icon inside a flex-1 column of
   unknown width — no wrapper element needed. */
.mobile-nav-badge {
  position: absolute;
  top: 4px;
  right: calc(50% - 20px);
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 16px;
  height: 16px;
  padding: 0 var(--spacing-xs);
  border-radius: var(--radius-sm);
  background: var(--status-danger);
  color: var(--md-sys-color-on-error);
  font-size: var(--text-2xs);
  font-weight: 600;
}
.mobile-nav-badge[hidden] { display: none; }

/* ============================================================
   BOTTOM SHEET — the phone's modal
   ============================================================ */
.sheet-backdrop {
  position: fixed;
  inset: 0;
  z-index: var(--z-sheet);
  background: var(--overlay-scrim);
}
.sheet-backdrop[hidden], .sheet[hidden] { display: none; }

.sheet {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: calc(var(--z-sheet) + 1);
  max-height: 88vh;
  padding-bottom: env(safe-area-inset-bottom, 0px);
  background: var(--surface-panel);
  border: 1px solid var(--line);
  border-bottom: none;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  box-shadow: var(--shadow-pop);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  animation: sheet-up var(--duration-normal) var(--ease-standard);
}
@keyframes sheet-up {
  from { transform: translateY(100%); }
  to   { transform: translateY(0); }
}
/* The grab handle. Purely an affordance — it says "this came from the bottom
   and goes back there", which is what makes a sheet read as a sheet. */
.sheet-handle {
  width: 36px;
  height: 4px;
  margin: var(--space-10) auto var(--spacing-xs);
  border-radius: 2px;
  background: var(--text-muted);
}
.sheet-header {
  position: sticky;
  top: 0;
  z-index: var(--z-lift);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--spacing-sm);
  padding: var(--spacing-sm) var(--spacing-md);
  background: var(--surface-panel);
}
.sheet-title { margin: 0; font-size: var(--text-xl); font-weight: 500; letter-spacing: var(--tracking-tight); color: var(--text-primary); }
.sheet-body { padding: 0 var(--spacing-md) var(--spacing-md); }
.sheet-footer {
  display: flex;
  gap: var(--spacing-sm);
  padding: var(--spacing-sm) var(--spacing-md) var(--spacing-lg);
}
.sheet-footer .primary-button, .sheet-footer .secondary-button { flex: 1; }

/* ============================================================
   CARDS, TILES, LIST ROWS
   ============================================================ */
.m-card {
  padding: var(--spacing-md);
  margin-bottom: var(--space-12);
  background: var(--surface-panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
}
.m-card-title {
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
  margin: 0 0 var(--space-12);
  font-size: var(--text-md);
  font-weight: 500;
  letter-spacing: var(--tracking-tight);
  color: var(--text-primary);
}
.m-card-title .material-symbols-outlined { font-size: var(--text-xl); color: var(--text-muted); }

/* The hero card: the next shift, drawn like a boarding pass. Deliberately the
   largest thing on the screen -- it is the one question the app exists to
   answer. The time is the display number; site, code and length under it;
   the countdown and ONE button. */
.next-shift {
  position: relative;
  overflow: hidden;
  padding: var(--spacing-lg) var(--spacing-md) var(--spacing-md);
  background: linear-gradient(160deg, var(--md-sys-color-primary-container) 0%, var(--surface-panel) 70%);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  margin-bottom: var(--space-12);
}
.next-shift::before {
  content: '';
  position: absolute;
  top: -40%;
  right: -20%;
  width: 220px;
  height: 220px;
  border-radius: 50%;
  background: radial-gradient(closest-side, var(--accent-tint-30), transparent);
  pointer-events: none;
}
.next-shift > * { position: relative; }
.next-shift-when {
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--primary);
  text-transform: uppercase;
  letter-spacing: var(--tracking-caps);
}
.next-shift-countdown {
  font-size: var(--text-md);
  font-weight: 500;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
}
.next-shift-receipt-text {
  display: block;
  font-size: var(--text-xs);
  color: var(--text-muted);
  margin-top: var(--space-2);
}
/* The receipt row (FR-APP-14): the countdown with the question under it, and
   one button -- or the tick. */
.next-shift-receipt {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--spacing-sm);
  margin-top: var(--spacing-md);
}
.next-shift-receipt.confirmed { color: var(--status-success); justify-content: flex-start; font-size: var(--text-sm); }
.next-shift-receipt .material-symbols-outlined { font-size: var(--text-xl); }
.next-shift-receipt .primary-button {
  flex: 0 0 auto;
  min-height: 40px;
  padding: 0 var(--space-20);
  border-radius: var(--space-10);
  font-size: var(--text-base);
}
.next-shift-actions { display: flex; gap: var(--spacing-sm); margin-top: var(--space-12); flex-wrap: wrap; }

/* This week: the ring beside its facts, the strip beneath. */
.m-card-note { margin-left: auto; font-weight: 400; font-size: var(--text-xs); letter-spacing: 0; color: var(--text-muted); }
.week-hours { display: flex; align-items: center; gap: var(--spacing-md); }
.week-hours .ch-svg { width: 132px; height: 132px; flex: 0 0 auto; }
.week-hours-facts { display: flex; flex-direction: column; gap: var(--spacing-sm); min-width: 0; }
.fact { display: flex; flex-direction: column; }
.fact-value { font-size: var(--text-xl); font-weight: 500; letter-spacing: var(--tracking-tight); color: var(--text-primary); font-variant-numeric: tabular-nums; }
.fact-value.warn { color: var(--status-warning); }
.fact-label { font-size: var(--text-xs); color: var(--text-muted-2); }
.week-strip { display: grid; grid-template-columns: repeat(7, 1fr); gap: var(--spacing-xs); margin-top: var(--spacing-md); }
/* The 7-chip week strip. Each chip carries a 4px BAND in the shift-family
   hue -- the same day / late / night / leave vocabulary as the console's
   pills -- and a small glyph for a screen reader's sake. */
.week-day {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-2);
  min-height: var(--touch-target);
  padding: var(--space-6) 0 var(--space-10);
  background: var(--surface-tile);
  border: 1px solid transparent;
  border-radius: var(--space-10);
  color: var(--text-secondary);
  cursor: pointer;
}
.week-day.today { border-color: var(--primary); }
.week-day-name { font-size: var(--text-2xs); text-transform: uppercase; letter-spacing: var(--tracking-caps); color: var(--text-muted); }
.week-day-num { font-size: var(--text-lg); font-weight: 500; color: var(--text-primary); font-variant-numeric: tabular-nums; }
.week-day-band { display: flex; align-items: center; justify-content: center; height: 14px; }
.week-day-band .material-symbols-outlined { font-size: var(--text-sm); }
.week-day::after {
  content: '';
  position: absolute;
  left: var(--spacing-sm);
  right: var(--spacing-sm);
  bottom: var(--space-6);
  height: 4px;
  border-radius: 2px;
  background: var(--line-strong);
}
.week-day.band-day .week-day-band { color: var(--shift-day); }
.week-day.band-day::after { background: var(--shift-day); }
.week-day.band-late .week-day-band { color: var(--shift-late); }
.week-day.band-late::after { background: var(--shift-late); }
.week-day.band-night .week-day-band { color: var(--shift-night); }
.week-day.band-night::after { background: var(--shift-night); }
.week-day.band-leave .week-day-band { color: var(--shift-leave); }
.week-day.band-leave::after { background: var(--shift-leave); }
.week-day.band-off .week-day-band { color: var(--shift-off); }
.week-day-hours { font-size: var(--text-2xs); color: var(--text-muted-2); font-variant-numeric: tabular-nums; min-height: 1em; }

/* A tile whose value is a small ring. */
.tile-ring { display: flex; flex-direction: column; align-items: center; gap: var(--space-2); }
.tile-ring .ch-svg { width: 72px; height: 72px; }
.tile-ring .ch-donut-value { font-size: var(--text-lg); }

.offer-actions { display: flex; flex-direction: column; gap: var(--space-6); align-items: stretch; }
.flag-text { color: var(--status-warning); }
.flag-text.danger { color: var(--status-danger); }
.sheet-intro { margin: 0 0 var(--spacing-md); font-size: var(--text-sm); color: var(--text-muted-2); }

/* The first-visit install banner on Today. */
.install-banner { border-color: var(--accent-tint-40); }
.install-banner-row { display: flex; gap: var(--spacing-sm); align-items: flex-start; }
.install-banner-row > .material-symbols-outlined { color: var(--primary); font-size: var(--text-3xl); }
.install-banner-text { font-size: var(--text-sm); color: var(--text-secondary); }
.install-banner-text strong { display: block; color: var(--text-primary); }
.install-banner-text .material-symbols-outlined.inline { font-size: var(--text-md); vertical-align: -3px; }
.install-banner-actions { display: flex; gap: var(--spacing-sm); justify-content: flex-end; margin-top: var(--spacing-sm); }
.next-shift-time {
  margin: var(--space-6) 0 var(--space-2);
  font-size: var(--text-hero);
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.05;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
}
.next-shift-time small { font-size: var(--text-lg); font-weight: 500; letter-spacing: 0; color: var(--text-secondary); }
.next-shift-meta { display: flex; flex-wrap: wrap; gap: var(--space-10); font-size: var(--text-md); color: var(--text-secondary); }
.next-shift-none { margin-top: var(--space-6); font-size: var(--text-lg); font-weight: 500; color: var(--text-secondary); }

.tile-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(96px, 1fr));
  gap: var(--spacing-sm);
  margin-bottom: var(--spacing-md);
}
.tile {
  padding: var(--space-14) var(--spacing-sm);
  background: var(--surface-panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  text-align: center;
}
.tile-value {
  font-size: var(--text-3xl);
  font-weight: 500;
  letter-spacing: var(--tracking-tight);
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;   /* so figures do not jitter as they change */
}
.tile-label {
  margin-top: var(--space-2);
  font-size: var(--text-xs);
  color: var(--text-muted);
}

.list-row {
  display: flex;
  align-items: center;
  gap: var(--spacing-md);
  width: 100%;
  min-height: 56px;
  padding: var(--space-10) var(--space-12);
  background: var(--surface-tile);
  border: 1px solid transparent;
  border-radius: var(--space-10);
  margin-bottom: var(--spacing-sm);
  color: var(--text-primary);
  text-align: left;
  cursor: pointer;
  transition: background var(--transition-fast);
}
.list-row:hover { background: var(--surface-hover); }
.list-row-main { flex: 1; min-width: 0; }
.list-row-title { font-size: var(--text-base); font-weight: 500; color: var(--text-primary); }
.list-row-sub { font-size: var(--text-sm); color: var(--text-muted-2); }
/* A family pill inside a row (an offer, a swap side): same class as the grid. */
.list-row .pill-shift { flex: 0 0 auto; min-width: 56px; justify-content: center; }
.list-row-side { font-size: var(--text-sm); color: var(--text-muted-2); text-align: right; white-space: nowrap; }

.m-empty {
  padding: var(--spacing-xl) var(--spacing-md);
  text-align: center;
  color: var(--text-muted-2);
}
.m-empty .material-symbols-outlined {
  font-size: 48px;
  color: var(--text-placeholder);
  display: block;
  margin-bottom: var(--spacing-sm);
}

/* ============================================================
   TOUCH SIZING — applied everywhere this sheet is loaded
   ============================================================ */
/* TOUCH SIZING IS GATED ON THE POINTER, NOT ON THE WIDTH.
 *
 * This block used to read `max-width: 720px`, which is a proxy for "is this a
 * finger" -- and it is wrong for exactly the device the question was asked
 * about. MEASURED 2026-09-06 on an iPad viewport: at 768, 834, 1024 and 1194
 * `pointer: coarse` is true and 4 to 9 controls per page sat under 44px,
 * including a 22px text button and a 24px ghost button. A tablet is a touch
 * device at every width.
 *
 * `pointer` reports the PRIMARY input, so a touchscreen laptop with a trackpad
 * still reads `fine` and keeps the compact desktop targets -- which is why
 * this is not `any-pointer`. Every phone is coarse too, so nothing that used
 * to be sized here has stopped being sized. */
@media (pointer: coarse) {
  /* --touch-target, not a literal 44: the number is declared once in
     tokens.css and this sheet was the last place typing it by hand.
     .text-button joined the list because it was MEASURED at 22px on the
     console's own Today feed ("Continue setup", "Email to payroll") -- a
     link-shaped button is still a button under a thumb. */
  .primary-button, .secondary-button, .ghost-button, .text-button,
  .tab-button, .app-switch-trigger, .permission-icon-toggle {
    min-height: var(--touch-target);
  }
  /* A text button is inline by default, so min-height alone leaves the label
     at the top of the box; centre it in the taller target. */
  .text-button {
    display: inline-flex;
    align-items: center;
  }
  .icon-button { width: var(--touch-target); height: var(--touch-target); }
  /* 16px or iOS zooms the viewport on focus -- on an iPad as well as a
     phone. Non-negotiable. */
  .form-input, .form-select, .form-textarea, .filter-input {
    font-size: var(--text-lg);
    min-height: var(--touch-target);
  }
}

/* Width-gated layout concessions -- these are about how much room there is,
   not about what is pointing, so they stay on the phone breakpoint. A table
   that fits on an iPad must not be forced into a horizontal scroller. */
@media (max-width: 720px) {
  table { display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; }
}
