:root {
  --text-xs: clamp(0.75rem, 0.7rem + 0.25vw, 0.875rem);
  --text-sm: clamp(0.875rem, 0.8rem + 0.35vw, 1rem);
  --text-base: clamp(1rem, 0.95rem + 0.25vw, 1.125rem);
  --text-lg: clamp(1.125rem, 1rem + 0.75vw, 1.35rem);
  --text-xl: clamp(1.5rem, 1.2rem + 1.25vw, 2.1rem);

  --space-1: 0.25rem; --space-2: 0.5rem; --space-3: 0.75rem;
  --space-4: 1rem;    --space-5: 1.25rem; --space-6: 1.5rem;
  --space-8: 2rem;    --space-10: 2.5rem;  --space-12: 3rem;

  --color-bg: #f7f4ee;
  --color-surface: #fbf8f3;
  --color-surface-2: #f0e9de;
  --color-surface-accent: #e8ddd1;
  --color-border: rgba(40,37,29,.11);
  --color-divider: rgba(40,37,29,.08);
  --color-text: #28251d;
  --color-text-muted: #706a63;
  --color-text-faint: #a49d94;
  --color-primary: #1b5b57;
  --color-primary-hover: #144844;
  --color-success: #2f6f4f;
  --color-error: #915041;
  --color-warning: #9b6a1d;

  --shadow-sm: 0 1px 2px rgba(35,28,23,.06), 0 8px 24px rgba(35,28,23,.05);
  --shadow-md: 0 2px 6px rgba(35,28,23,.07), 0 16px 40px rgba(35,28,23,.10);

  --radius-sm: 12px; --radius-md: 18px; --radius-lg: 26px;
  --radius-xl: 32px; --radius-full: 999px;

  --font-display: 'Boska', Georgia, serif;
  --font-body: 'Satoshi', Inter, sans-serif;
  --phone-width: 420px;
}

* { box-sizing: border-box; }
html { -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; }
body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at top left, rgba(229,219,208,.55), transparent 32%),
    linear-gradient(180deg, #f1ece4 0%, #f8f5ef 52%, #f4efe8 100%);
  color: var(--color-text);
  font-family: var(--font-body);
  font-size: var(--text-base);
  line-height: 1.55;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }

.auth-gate {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: var(--space-8) var(--space-4);
}
.auth-card {
  width: min(100%, 430px);
  display: grid;
  gap: 16px;
  padding: 28px;
  border-radius: var(--radius-xl);
  background: linear-gradient(180deg, rgba(255,255,255,.82), rgba(244,238,230,.95));
  border: 1px solid var(--color-border);
  box-shadow: var(--shadow-md);
}
.auth-logo { width: 54px; height: 54px; }
.auth-card h1 {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 500;
  font-size: var(--text-xl);
  line-height: 1.04;
  letter-spacing: -.02em;
}
.auth-card p { margin: 0; color: var(--color-text-muted); }
.auth-form { display: grid; gap: 10px; }
.auth-form label {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .12em;
  color: var(--color-text-muted);
}
.auth-form input {
  width: 100%;
  min-height: 48px;
  border-radius: 16px;
  border: 1px solid var(--color-border);
  background: rgba(255,255,255,.78);
  padding: 11px 13px;
}
.password-field { position: relative; display: block; }
/* Leave room so typed/masked characters never slide under the toggle. */
.password-field input { padding-right: 68px; }
.password-toggle {
  position: absolute;
  top: 50%;
  right: 6px;
  transform: translateY(-50%);
  /* Sit above the input so iOS routes the tap to the button, not the field
     underneath, and make sure taps are never swallowed. */
  z-index: 2;
  pointer-events: auto;
  touch-action: manipulation;
  min-height: 36px;
  padding: 0 12px;
  border: 1px solid var(--color-border);
  border-radius: 12px;
  background: var(--color-surface-2);
  color: var(--color-text-muted);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
}
.password-toggle:hover { color: var(--color-text); }
.password-toggle[aria-pressed="true"] {
  background: var(--color-surface);
  color: var(--color-text);
}
.password-field input[hidden] + .password-toggle { display: none; }
.auth-status {
  min-height: 20px;
  font-size: 13px;
  color: var(--color-text-muted);
}
.auth-status[data-tone="ok"] { color: var(--color-success); }
.auth-status[data-tone="error"] { color: var(--color-error); }
.auth-status[data-tone="warn"] { color: #7d5920; font-weight: 500; }
/* Retry / Sign out escape hatch shown when the post-login workspace boot
   fails or times out, so staff are never stuck on an infinite loading line. */
.auth-recovery {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}
.auth-recovery.hidden { display: none; }
.auth-recovery .action-btn,
.auth-recovery .soft-btn { flex: 1; }
#captureStatus { margin-top: 4px; }
#captureStatus:empty { display: none; }

/* Stripe payment-link feedback. Without distinct tone colors the status text
   looked identical whether the call was pending, succeeded, or failed, so the
   button felt unresponsive. */
.stripe-status {
  min-height: 20px;
  font-size: 13px;
  font-weight: 600;
  color: var(--color-text-muted);
}
.stripe-status[data-tone="info"] { color: var(--color-primary); }
.stripe-status[data-tone="ok"] { color: var(--color-success); }
.stripe-status[data-tone="error"] { color: var(--color-error); }
.stripe-status[data-tone="info"]::before {
  content: "";
  display: inline-block;
  width: 12px;
  height: 12px;
  margin-right: 6px;
  vertical-align: -1px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: stripe-spin 0.7s linear infinite;
}
@keyframes stripe-spin { to { transform: rotate(360deg); } }

.stripe-result {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  align-items: center;
  margin-top: var(--space-2);
}
.stripe-result.hidden { display: none; }
.stripe-result-url {
  flex: 1 1 220px;
  min-width: 0;
  font-size: 12px;
  padding: 6px 8px;
  border: 1px solid var(--color-border, #ccc);
  border-radius: 6px;
  background: var(--color-surface, #fff);
  color: var(--color-text, #222);
}
.stripe-result-actions { display: flex; gap: var(--space-2); }

.shell {
  width: min(100%, 1560px);
  margin: 0 auto;
  padding: var(--space-8) var(--space-4) var(--space-10);
  display: grid;
  gap: var(--space-8);
  grid-template-columns: minmax(320px, var(--phone-width)) minmax(360px, 1fr);
  align-items: start;
}
.phone {
  background: #111;
  border-radius: 40px;
  padding: 12px;
  box-shadow: 0 30px 80px rgba(26,20,16,.22);
  position: sticky;
  top: 18px;
}
.screen {
  height: min(820px, calc(100vh - 36px));
  min-height: 680px;
  background: var(--color-bg);
  border-radius: 30px;
  overflow: hidden;
  position: relative;
  display: flex;
  flex-direction: column;
}
.statusbar {
  display:flex; justify-content:space-between; align-items:center;
  padding: 14px 20px 6px;
  font-size: 12px;
  color: var(--color-text-muted);
}
.header {
  display:flex; justify-content:space-between; align-items:flex-start;
  padding: 10px 20px 16px;
  gap: 12px;
}
.header-compact {
  justify-content: flex-end;
  padding-top: 4px;
  padding-bottom: 12px;
}
.header-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: flex-end;
}
.header-actions .pill {
  max-width: 128px;
  overflow: hidden;
  text-overflow: ellipsis;
}
.brand { display:flex; gap: 12px; align-items:center; }
.brand-mark {
  width: 42px; height: 42px; border-radius: 50%;
  background: rgba(255,255,255,.7);
  border: 1px solid var(--color-border);
  box-shadow: var(--shadow-sm);
  display:grid; place-items:center;
  color: var(--color-text);
}
.brand-mark svg { width: 20px; height: 20px; }
.eyebrow {
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: .16em;
  color: var(--color-text-muted);
}
.header-copy strong { display:block; font-size: var(--text-sm); }
.header-copy span { font-size: 12px; color: var(--color-text-muted); }
.icon-btn {
  width: 42px; height: 42px; border-radius: 50%;
  border: 1px solid var(--color-border);
  background: rgba(255,255,255,.72);
  display:grid; place-items:center;
  box-shadow: var(--shadow-sm);
}

.screen-body {
  flex: 1;
  min-height: 0;
  overflow: hidden;
  padding: 0 20px 170px;
}
.screen.no-bottom-bar .screen-body {
  padding-bottom: 20px;
}
/* Guest Receipts dashboard: the bottom tray here is a single row of side-by-side
   buttons (shorter than the stacked trays on other views), so reserve less bottom
   clearance and hand the reclaimed height to the scrolling booking list. */
.screen-body:has(#view-bookings:not(.hidden)) {
  padding-bottom: calc(96px + env(safe-area-inset-bottom));
}
.view:not(.hidden) {
  height: 100%;
  min-height: 0;
  overflow-y: auto;
  display: grid;
  gap: 10px;
  align-content: start;
  padding-bottom: 12px;
}
/* Send/report view: the bottom bar is taller here (step nav + the stacked
   Generate Payment Link / Send Invoice to Guest controls + status lines), so
   give the scroll content extra clearance to keep content above the fixed
   controls. */
#view-report:not(.hidden) {
  padding-bottom: 120px;
}
#view-bookings:not(.hidden) {
  overflow-y: auto;
  grid-template-rows: auto auto auto auto minmax(180px, 1fr);
}
#bookingList {
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding-right: 2px;
  align-content: start;
}

.page-title {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 25px;
  line-height: 1.02;
  letter-spacing: -.02em;
  max-width: none;
  margin: 0;
  white-space: nowrap;
}
.booking-heading {
  position: sticky;
  top: 0;
  z-index: 4;
  gap: 3px;
  padding: 2px 0 8px;
  background: linear-gradient(180deg, var(--color-bg) 0%, rgba(247,244,238,.94) 72%, rgba(247,244,238,0) 100%);
}
.booking-heading .eyebrow {
  font-size: 13px;
  letter-spacing: .22em;
  color: var(--color-text);
}
.booking-heading.with-back {
  padding-top: 4px;
}
.back-chevron {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  margin: 0 0 6px -6px;
  padding: 0;
  border: 1px solid var(--color-border);
  border-radius: 50%;
  background: var(--color-surface);
  color: var(--color-text);
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: transform .15s ease, background .15s ease;
  -webkit-tap-highlight-color: transparent;
}
.back-chevron:hover { background: #f1ede5; }
.back-chevron:active { transform: scale(.94); }
.back-chevron:focus-visible {
  outline: 2px solid var(--color-text);
  outline-offset: 2px;
}
.lede { color: var(--color-text-muted); font-size: var(--text-sm); max-width: 34ch; margin: 0; }

.hero-card, .card, .pdf-sheet {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  box-shadow: var(--shadow-sm);
}
.hero-card {
  padding: 10px 12px;
  border-radius: 22px;
  display:grid; gap:8px;
  background: linear-gradient(180deg, rgba(255,255,255,.78), rgba(244,238,230,.95));
}
.card-title { font-size: 15px; }
.hero-stat-grid { display:grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.hero-stat {
  padding: 8px 10px;
  border-radius: 16px;
  background: rgba(255,255,255,.7);
  border: 1px solid var(--color-border);
}
.hero-stat span { display:block; font-size: 11px; color: var(--color-text-muted); }
.hero-stat strong { display:block; font-size: 18px; margin-top: 1px; line-height: 1; }

.hero-stat-btn,
.mini-stat-btn {
  appearance: none;
  width: 100%;
  text-align: left;
  cursor: pointer;
  font: inherit;
  color: inherit;
  position: relative;
  transition: transform 80ms ease, box-shadow 80ms ease, border-color 80ms ease;
}
.hero-stat-btn:hover,
.mini-stat-btn:hover {
  border-color: var(--color-accent);
}
.hero-stat-btn:active,
.mini-stat-btn:active { transform: scale(.98); }
.hero-stat-btn[aria-expanded="true"],
.mini-stat-btn[aria-expanded="true"] {
  border-color: var(--color-accent);
  box-shadow: 0 0 0 1px var(--color-accent) inset;
}
.hero-stat-btn::after,
.mini-stat-btn::after {
  content: "›";
  position: absolute;
  top: 6px;
  right: 9px;
  font-size: 12px;
  line-height: 1;
  color: var(--color-text-muted);
  transition: transform 120ms ease;
}
.hero-stat-btn[aria-expanded="true"]::after,
.mini-stat-btn[aria-expanded="true"]::after { transform: rotate(90deg); color: var(--color-accent); }

.glance-panel {
  margin-top: 2px;
  border-radius: 16px;
  background: rgba(255,255,255,.78);
  border: 1px solid var(--color-border);
  padding: 10px 12px;
  display: grid;
  gap: 8px;
  box-shadow: var(--shadow-sm);
}
.glance-panel.hidden { display: none; }
.glance-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.glance-head strong {
  font-size: 13px;
  line-height: 1.2;
}
.glance-head .meta { font-size: 11px; }
.glance-close {
  appearance: none;
  border: 1px solid var(--color-border);
  background: rgba(255,255,255,.85);
  color: var(--color-text-muted);
  border-radius: 999px;
  width: 26px;
  height: 26px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  padding: 0;
}
.glance-close:hover { color: var(--color-text); border-color: var(--color-accent); }
.glance-list {
  display: grid;
  gap: 6px;
  max-height: 280px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding-right: 2px;
}
.glance-item {
  display: grid;
  grid-template-columns: 1fr auto;
  column-gap: 8px;
  row-gap: 2px;
  padding: 8px 10px;
  border-radius: 12px;
  background: rgba(251,248,243,.92);
  border: 1px solid var(--color-border);
}
.glance-item-vendor {
  font-weight: 600;
  font-size: 13px;
  line-height: 1.2;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.glance-item-amount {
  font-weight: 600;
  font-size: 13px;
  line-height: 1.2;
  font-variant-numeric: tabular-nums;
  text-align: right;
  white-space: nowrap;
}
.glance-item-meta {
  font-size: 11px;
  color: var(--color-text-muted);
  line-height: 1.25;
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  gap: 4px 8px;
  align-items: center;
}
.glance-item-tag {
  display: inline-block;
  padding: 1px 7px;
  border-radius: 999px;
  background: rgba(27,91,87,.10);
  color: var(--color-accent);
  font-size: 10px;
  letter-spacing: .04em;
  text-transform: uppercase;
  font-weight: 600;
}
.glance-item-tag.warn { background: rgba(183,126,72,.18); color: #8a5a2b; }
.glance-item-tag.muted { background: rgba(0,0,0,.06); color: var(--color-text-muted); }
.glance-empty {
  text-align: center;
  padding: 18px 12px 16px;
  color: var(--color-text-muted);
  font-size: 12px;
  display: grid;
  gap: 6px;
  justify-items: center;
}
.glance-empty-emoji {
  font-size: 22px;
  line-height: 1;
}
.glance-empty strong {
  font-size: 13px;
  color: var(--color-text);
}

.management-hero {
  margin-top: 2px;
}
.choice-card {
  appearance: none;
  text-align: left;
  display: grid;
  gap: 7px;
  width: 100%;
  padding: 16px;
  border-radius: 22px;
  border: 1px solid var(--color-border);
  background:
    linear-gradient(135deg, rgba(27,91,87,.08), transparent 50%),
    rgba(255,255,255,.78);
  color: var(--color-text);
  box-shadow: var(--shadow-sm);
}
.choice-card strong {
  font-size: 20px;
  line-height: 1.1;
}
.choice-card span:last-child {
  color: var(--color-text-muted);
  font-size: 13px;
  line-height: 1.45;
}
.choice-eyebrow {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .18em;
  color: var(--color-accent);
}
.scan-toast {
  border-radius: 18px;
  padding: 14px 16px;
  background: rgba(27,91,87,.95);
  color: #fffaf0;
  font-weight: 700;
  text-align: center;
  box-shadow: var(--shadow-md);
}

.unbilled-card {
  background:
    linear-gradient(135deg, rgba(27,91,87,.08), transparent 48%),
    rgba(251,248,243,.92);
}
.drive-preview {
  background:
    linear-gradient(135deg, rgba(183,126,72,.10), transparent 52%),
    rgba(251,248,243,.92);
}
.mini-stat-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}
.mini-stat {
  padding: 8px 7px;
  border-radius: 15px;
  background: rgba(255,255,255,.72);
  border: 1px solid var(--color-border);
}
.mini-stat span {
  display: block;
  font-size: 10px;
  line-height: 1.15;
  color: var(--color-text-muted);
}
.mini-stat strong {
  display: block;
  margin-top: 2px;
  font-size: 18px;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.segmented {
  display:flex; gap:8px; padding: 6px; border-radius: var(--radius-full);
  border:1px solid var(--color-border); background: rgba(255,255,255,.66);
}
.segmented button {
  flex:1; border:none; background: transparent; color: var(--color-text-muted);
  border-radius: var(--radius-full); padding: 10px 12px; min-height: 42px;
  transition: background .18s ease, color .18s ease;
}
.segmented button.active { background: var(--color-text); color: #f6f2eb; }

.card { border-radius: 22px; padding: 11px 12px; display:grid; gap: 8px; }
.booking-card {
  width: 100%;
  align-self: start;
  border: 1px solid var(--color-border);
  transition: outline-color .18s ease, transform .18s ease;
}
.booking-card.active { outline: 2px solid rgba(27,91,87,.28); background: linear-gradient(180deg, #fffdf9, #f7f1e8); }
/* Selected booking card mirrors the "current step" treatment in the bottom
   nav: light green fill with primary-color text, primary-color outline. */
.booking-card.selected {
  background: rgba(27,91,87,.1);
  border-color: var(--color-primary);
  outline: 2px solid rgba(27,91,87,.45);
  color: var(--color-primary);
}
.booking-card.selected strong,
.booking-card.selected .booking-code,
.booking-card.selected .meta { color: var(--color-primary); }
.booking-card.selected .pill {
  background: rgba(255,255,255,.7);
  color: var(--color-primary);
}

.booking-select-instruction {
  margin: 0;
  color: var(--color-text-muted);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: .01em;
}
.booking-card-top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
}
.booking-card-top strong {
  font-size: 15px;
  line-height: 1.2;
}
.booking-code {
  flex: 0 0 auto;
  font-size: 12px;
  color: var(--color-text-muted);
  font-variant-numeric: tabular-nums;
}

/* Compact stacked layout used by every booking card; the selected card
   emphasizes the chip column with vertical stacking, while non-selected
   cards keep a tighter footprint and let chips wrap on the right. */
.booking-card-body {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: start;
}
.booking-card-left {
  display: grid;
  gap: 4px;
  text-align: left;
  min-width: 0;
}
.booking-card-left strong {
  font-size: 15px;
  line-height: 1.2;
  overflow-wrap: anywhere;
}
.booking-card-left .meta {
  font-size: 12px;
  line-height: 1.25;
  font-variant-numeric: tabular-nums;
}
.booking-card-left .booking-code {
  font-size: 12px;
  color: var(--color-text-muted);
  font-variant-numeric: tabular-nums;
  letter-spacing: .02em;
}
@media (max-width: 380px) {
  .booking-card-body { gap: 8px; }
  .booking-card-left strong { font-size: 14px; }
  .booking-card-left .meta { font-size: 11px; }
  .booking-card-chips { min-width: 118px; }
}
/* Both selected and non-selected booking cards use the same stacked chip
   column on the right. Non-selected cards keep the neutral .pill treatment
   while selected cards use the green metric-chip styling, but the geometry
   stays consistent so cards don't shift when selection changes. */
.booking-card-chips {
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: stretch;
  justify-content: flex-start;
  flex: 0 0 auto;
  min-width: 130px;
}
.booking-card-chips .pill,
.booking-card-chips .metric-chip {
  justify-content: center;
  white-space: nowrap;
  width: 100%;
}

.row { display:flex; justify-content:space-between; gap: 12px; align-items:flex-start; }
.stack { display:grid; gap: 4px; }
.stack strong { font-size: 17px; }
.meta { color: var(--color-text-muted); font-size: 13px; }

.pill {
  display:inline-flex; align-items:center; gap:6px;
  background: var(--color-surface-2);
  color: var(--color-text-muted);
  border-radius: var(--radius-full);
  padding: 5px 9px;
  font-size: 11px;
  white-space: nowrap;
}
.pill.dark { background: var(--color-text); color: #f7f4ee; }
.pill.success { background: #edf4ef; color: #275239; }
.pill.warning { background: #f5efe2; color: #7d5920; }
.pill.error { background: #f5e9e5; color: #7a4337; }
.inline-pills { display:flex; gap:6px; flex-wrap:wrap; }

/* Booking metric chips — interactive pills on the selected booking card.
   Stronger green outline + bolder weight signal they're tappable. Non-selected
   cards keep the subdued static .pill treatment. */
.booking-card.selected .metric-chip {
  background: #fff;
  color: var(--color-primary);
  border: 1.5px solid var(--color-primary);
  font-weight: 700;
  cursor: pointer;
  padding: 5px 11px;
  letter-spacing: .01em;
  transition: background .14s ease, transform .14s ease, box-shadow .14s ease;
  box-shadow: 0 1px 0 rgba(27,91,87,.08);
}
.booking-card.selected .metric-chip:hover,
.booking-card.selected .metric-chip:focus-visible {
  background: var(--color-primary);
  color: #fff;
  outline: none;
}
.booking-card.selected .metric-chip:active { transform: translateY(1px); }
.booking-card.selected .metric-chip .metric-chip-count {
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}
.booking-card.selected .metric-chip[data-empty="true"] {
  opacity: .7;
}

/* Unpaid-invoices alert badge — a red flag under the booking code, distinct
   from the neutral stat bubbles. On the selected card it becomes tappable and
   opens the Invoices-Sent popup filtered to unpaid rows. */
.unpaid-alert-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  align-self: flex-start;
  margin-top: 4px;
  background: #f5e3df;
  color: var(--color-error);
  border: 1px solid #e3b8af;
  border-radius: var(--radius-full);
  padding: 3px 9px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .01em;
  white-space: nowrap;
}
.unpaid-alert-count { font-variant-numeric: tabular-nums; font-weight: 800; }
.booking-card.selected .unpaid-alert-badge {
  cursor: pointer;
  transition: background .14s ease, transform .14s ease;
}
.booking-card.selected .unpaid-alert-badge:hover,
.booking-card.selected .unpaid-alert-badge:focus-visible {
  background: var(--color-error);
  color: #fbf3ee;
  outline: none;
}
.booking-card.selected .unpaid-alert-badge:active { transform: translateY(1px); }

/* Step-3 unpaid invoice row: a tappable invoice card (opens the action sheet),
   the Sent status pill, and a small red Cancel control beside it. */
.unpaid-invoice-trigger {
  display: flex; flex-direction: column; gap: 4px; width: 100%;
  background: none; border: none; padding: 0; margin: 0;
  text-align: left; cursor: pointer; color: inherit;
}
.unpaid-invoice-line {
  display: flex; align-items: center; gap: 8px;
  justify-content: space-between;
}
.unpaid-invoice-id { font-size: 14px; }
.unpaid-invoice-status {
  display: inline-flex; align-items: center; gap: 6px; flex-wrap: wrap;
  justify-content: flex-end;
}
.cancel-chip {
  display: inline-flex; align-items: center; gap: 5px;
  background: #f5e3df;
  color: var(--color-error);
  border: 1px solid #e3b8af;
  border-radius: var(--radius-full);
  padding: 3px 10px 3px 4px;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  transition: background .14s ease, color .14s ease, transform .14s ease;
}
.cancel-chip-x {
  display: inline-flex; align-items: center; justify-content: center;
  width: 16px; height: 16px;
  border-radius: 50%;
  background: var(--color-error);
  color: #fbf3ee;
  font-size: 12px; line-height: 1; font-weight: 800;
}
.cancel-chip:hover, .cancel-chip:focus-visible {
  background: var(--color-error); color: #fbf3ee; outline: none;
}
.cancel-chip:hover .cancel-chip-x, .cancel-chip:focus-visible .cancel-chip-x {
  background: #fbf3ee; color: var(--color-error);
}
.cancel-chip:active { transform: translateY(1px); }
.invoice-actions {
  display: flex; gap: 6px; margin-top: 10px; flex-wrap: nowrap;
}
.invoice-actions[hidden] { display: none; }
.invoice-actions .action-btn,
.invoice-actions .soft-btn,
.invoice-actions .danger-btn {
  flex: 1 1 0; min-width: 0; min-height: 42px;
  font-size: 13px; padding-left: 8px; padding-right: 8px;
  white-space: nowrap;
}

.metric-detail-list {
  display: flex; flex-direction: column; gap: 8px;
  max-height: 320px; overflow-y: auto;
  margin-top: 4px;
}
.metric-detail-row {
  display: flex; flex-direction: column; gap: 2px;
  border: 1px solid var(--color-border);
  background: var(--color-surface-2);
  border-radius: var(--radius-md);
  padding: 10px 12px;
}
/* The whole row header is a tap target that expands the row's actions. */
.metric-detail-trigger {
  display: flex; flex-direction: column; gap: 2px;
  width: 100%;
  background: none; border: none; padding: 0; margin: 0;
  text-align: left; cursor: pointer; color: inherit;
}
.metric-detail-top { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.metric-detail-vendor { font-weight: 700; color: var(--color-text); }
.metric-detail-amount { font-weight: 700; color: var(--color-text); font-variant-numeric: tabular-nums; }
.metric-detail-meta { color: var(--color-text-muted); font-size: .82rem; }
/* Unbilled receipt rows are a single tappable trigger: info on the left, amount
   on the right. Tapping opens the receipt action sheet (Edit / Delete / Close). */
.metric-detail-row--receipt { flex-direction: row; align-items: stretch; }
.metric-detail-trigger--receipt {
  display: flex; flex-direction: row; align-items: center; justify-content: space-between;
  gap: 12px; width: 100%;
}
.metric-detail-info { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
/* Left-hand vendor/meta truncate before the amount is allowed to wrap, so the
   amount + currency ("$2,795.96 MXN") always stays on a single line. */
.metric-detail-trigger--receipt .metric-detail-vendor,
.metric-detail-trigger--receipt .metric-detail-meta {
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%;
}
.metric-detail-trigger--receipt .metric-detail-amount {
  flex: 0 0 auto;
  white-space: nowrap;
  font-size: .95rem;
}
/* Per-row actions are revealed when the row is expanded. */
.metric-detail-actions { display: none; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.metric-detail-row.is-open .metric-detail-actions { display: flex; }
.metric-detail-actions .action-btn,
.metric-detail-actions .soft-btn,
.metric-detail-actions .danger-btn {
  flex: 1 1 auto; min-height: 42px; font-size: 13px;
}
/* Footer flow shortcuts (capture / send invoice) on the unbilled popup. */
.metric-detail-footer {
  display: flex; flex-direction: column; gap: 10px;
  margin-top: 14px; padding-top: 14px;
  border-top: 1px solid var(--color-border);
}
.metric-detail-empty {
  border: 1px dashed var(--color-border);
  border-radius: var(--radius-md);
  padding: 18px 14px;
  text-align: center;
  color: var(--color-text-muted);
  background: var(--color-surface-2);
}
.metric-detail-empty-title { font-weight: 700; color: var(--color-text); margin-bottom: 4px; }

.action-grid { display:grid; gap: 12px; }
.action-btn, .ghost-btn, .soft-btn, .danger-btn {
  min-height: 48px;
  border-radius: 18px;
  border: 1px solid transparent;
  padding: 0 16px;
  display:inline-flex; align-items:center; justify-content:center; gap:10px;
  font-weight: 700;
  transition: transform .14s ease, background .18s ease, box-shadow .18s ease;
  cursor: pointer;
}
.action-btn { background: var(--color-primary); color:#f8f4ed; box-shadow: var(--shadow-md); }
.action-btn:hover { background: var(--color-primary-hover); }
.action-btn:active { transform: translateY(1px); }
.action-btn[disabled] { background: #cdc7be; color: #6b665e; box-shadow: none; cursor: not-allowed; }
.ghost-btn { background: rgba(255,255,255,.72); border-color: var(--color-border); }
.soft-btn { background: var(--color-surface-2); border-color: var(--color-border); }
.ghost-btn[disabled], .soft-btn[disabled] { opacity: .55; cursor: not-allowed; }
/* Ready-to-act emphasis: a button turns green once its preconditions are met
   (manual item fully entered, payment link generated). */
.soft-btn.is-ready:not([disabled]),
.action-btn.is-ready:not([disabled]) {
  background: var(--color-success);
  color: #f8f4ed;
  border-color: var(--color-success);
  box-shadow: var(--shadow-md);
}
.soft-btn.is-ready:not([disabled]):hover,
.action-btn.is-ready:not([disabled]):hover { background: #275f43; }
.danger-btn {
  background: var(--color-error);
  color: #fbf3ee;
  box-shadow: var(--shadow-md);
}
.danger-btn:hover { background: #7a4034; }
.danger-btn:active { transform: translateY(1px); }

.primary-action-row { display: grid; gap: 8px; }
.primary-action-row.paired { grid-template-columns: 1fr 1fr; }
.primary-action-row.submit-pair { grid-template-columns: 1fr 1fr; }
/* Side-by-side buttons (e.g. bookings step: Capture Receipt + Send Invoice)
   must fit on one line: never wrap, shrink the label to fit narrow phones, and
   keep both buttons the same text size so neither looks dominant. min-width:0
   lets the grid cells shrink below their content width instead of overflowing. */
.primary-action-row.paired .action-btn {
  white-space: nowrap;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: clamp(13px, 3.6vw, 15px);
  padding-left: 10px;
  padding-right: 10px;
}

/* Guest Receipts post-OCR booking details card — sits in the same slot as
   the Villa Receipts "Today at a glance" hero. Tight key/value rows so the
   card height matches the stat grid it replaces. */
.booking-details-grid {
  display: grid;
  gap: 6px;
}
.booking-detail-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  padding: 4px 0;
}
.booking-detail-row + .booking-detail-row {
  border-top: 1px dashed var(--color-border);
}
.booking-detail-label {
  font-size: 12px;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--color-text-muted);
}
.booking-detail-value {
  font-size: 14px;
  color: var(--color-text);
  text-align: right;
  font-weight: 600;
}

/* Guest Receipts capture heading — short stack with eyebrow + page title +
   meta. Matches Villa Receipts visual rhythm above the receipt illustration. */
.guest-capture-heading {
  gap: 6px;
  margin-bottom: 4px;
}
.guest-capture-heading .eyebrow {
  font-size: 12px;
  letter-spacing: .18em;
  color: var(--color-primary);
  text-transform: uppercase;
}
.guest-capture-heading .meta {
  margin: 0;
  color: var(--color-text-muted);
  font-size: 13px;
  line-height: 1.4;
}

.bottom-bar {
  position: absolute; inset: auto 14px 14px;
  background: rgba(251,248,243,.92);
  border: 1px solid var(--color-border);
  border-radius: 24px;
  padding: 10px;
  backdrop-filter: blur(18px);
  box-shadow: var(--shadow-md);
  display:grid; gap:10px;
}
.nav-tabs { display:grid; grid-template-columns: repeat(4, 1fr); gap:8px; }
.nav-tabs.three-tabs { grid-template-columns: repeat(3, 1fr); }
.nav-tabs button {
  border:none; background: transparent; border-radius: 16px; min-height: 56px; padding: 8px 4px;
  font-size: 11px; color: var(--color-text-muted); display:grid; gap:6px; place-items:center;
  transition: background .18s ease, color .18s ease;
}
.nav-tabs button.active { background: rgba(27,91,87,.1); color: var(--color-primary); }
.nav-icon { width: 20px; height: 20px; border-radius: 7px; border: 1px solid currentColor; display:grid; place-items:center; font-size: 11px; }

/* Step indicator: passive progress UI, not interactive */
.nav-tabs.step-indicator > * {
  border: none;
  background: transparent;
  border-radius: 16px;
  min-height: 56px;
  padding: 8px 4px;
  font-size: 11px;
  color: var(--color-text-muted);
  display: grid;
  gap: 6px;
  place-items: center;
  cursor: default;
  pointer-events: none;
  user-select: none;
  font-weight: 400;
  transition: background .18s ease, color .18s ease, font-weight .18s ease;
}
/* Current step: outlined green + bold */
.nav-tabs.step-indicator > [data-step-state="current"] {
  background: rgba(27,91,87,.1);
  color: var(--color-primary);
  font-weight: 700;
}
/* Completed step: filled green with light text + check inside the icon */
.nav-tabs.step-indicator > [data-step-state="done"] {
  background: var(--color-primary);
  color: #f8f4ed;
  font-weight: 500;
}
.nav-tabs.step-indicator > [data-step-state="done"] .nav-icon {
  background: #f8f4ed;
  color: var(--color-primary);
  border-color: #f8f4ed;
  font-weight: 700;
}
/* Upcoming step: muted */
.nav-tabs.step-indicator > [data-step-state="upcoming"] {
  opacity: .55;
}

/* Send step fixed controls — Generate Payment Link + Send Invoice to Guest
   stacked vertically beneath the step indicators in the bottom bar. Status
   lines sit directly under their buttons, above the bottom safe area. */
.send-cta-stack {
  display: grid;
  gap: 8px;
}
.send-cta-stack.hidden { display: none; }
/* Stripe Link + Send Invoice share one row, splitting the width evenly. Labels
   never wrap; the font shrinks to fit and both buttons use the SAME clamped
   size, so they stay visually matched even when one label is longer. */
.send-cta-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.send-cta-stack .action-btn {
  width: 100%;
  min-width: 0;
  border-radius: 22px;
  min-height: 52px;
  font-size: clamp(12px, 3.4vw, 15px);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding-left: 8px;
  padding-right: 8px;
}
.send-cta-stack .stripe-status:empty { display: none; }

.share-message {
  display: grid;
  gap: 8px;
}
.share-message.hidden { display: none; }
.share-message-text {
  width: 100%;
  resize: vertical;
  font-size: 13px;
  line-height: 1.4;
  padding: 8px 10px;
  border: 1px solid var(--color-border, #ccc);
  border-radius: 10px;
  background: var(--color-surface, #fff);
  color: var(--color-text, #222);
}
.share-message .soft-btn { width: 100%; }

.receipt-shot {
  background: linear-gradient(180deg,#efe7db 0%,#e7ddcf 100%);
  border-radius: 24px;
  border:1px solid rgba(40,37,29,.08);
  padding: 18px;
  display:grid; gap:12px;
  transition: border-color .18s ease, box-shadow .18s ease, transform .18s ease;
}
.receipt-shot.is-dragging {
  border-color: rgba(27,91,87,.45);
  box-shadow: 0 18px 38px rgba(27,91,87,.15);
  transform: translateY(-1px);
}
.receipt-paper {
  background: #fffdfa;
  border-radius: 18px;
  padding: 16px 14px;
  min-height: 250px;
  border: 1px solid rgba(40,37,29,.08);
  box-shadow: 0 16px 30px rgba(33,26,20,.08);
  font-size: 12px;
  color:#36312b;
}
.receipt-paper img { width: 100%; height: auto; max-height: 320px; object-fit: contain; border-radius: 12px; }

/* Review-OCR mode: editable fields come first, then a compact thumbnail of the
   scanned receipt. Tapping the thumbnail opens the full-size viewer modal. */
.review-thumb-wrap {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 14px;
}
.review-thumb-label {
  font-size: 12px;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--color-text-muted);
}
.review-thumb {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  align-self: flex-start;
  width: auto;
  height: auto;
  max-width: 200px;
  padding: 0;
  border: 1px solid var(--color-border);
  border-radius: 12px;
  background: var(--color-surface-2);
  overflow: hidden;
  cursor: pointer;
  color: var(--color-text-muted);
  line-height: 0;            /* no inline-baseline gap that strips the image height */
}
/* Empty state still needs a sensible minimum so the placeholder box is tappable. */
.review-thumb:not(.has-image) {
  min-width: 96px;
  min-height: 120px;
}
.review-thumb.has-image { cursor: zoom-in; }
.review-thumb:disabled { cursor: default; }
/* Height drives the thumbnail (tall receipt → tall narrow preview; wide → width-
   capped). object-fit:contain guarantees no distortion if a box is ever forced. */
.review-thumb-img {
  display: block;
  width: auto;
  height: auto;
  object-fit: contain;
  max-width: 200px;
  max-height: 260px;
}
.review-thumb-empty {
  padding: 8px;
  text-align: center;
  font-size: 11px;
  line-height: 1.3;
}

/* Full-size scanned-receipt viewer modal. */
.receipt-image-viewer-card { max-width: min(92vw, 520px); }
.receipt-image-viewer-frame {
  display: flex;
  align-items: center;
  justify-content: center;
  max-height: 70vh;
  overflow: auto;
  border-radius: 12px;
  background: var(--color-surface-2);
}
.receipt-image-viewer-img {
  max-width: 100%;
  max-height: 70vh;
  object-fit: contain;
  display: block;
}

/* Decorative receipt graphic shown on the Villa Receipts capture step */
.receipt-shot.decorative {
  pointer-events: none;
  user-select: none;
  margin-top: 4px;
}
/* Same visual as .decorative, but keeps pointer events so the capture
   dropzone (tap to open picker, drag/drop) still works. */
.receipt-shot.decorative-interactive {
  user-select: none;
  margin-top: 4px;
}
/* Neutral receipt illustration (RECEIPT heading + item rows with dotted
   leaders + total summary). Wavy/torn top + bottom edges are produced by
   masking the paper with an inline SVG silhouette. */
.receipt-paper.decorative-paper {
  --decorative-ink: #2a2620;
  min-height: 240px;
  padding: 26px 22px 26px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  border-radius: 0;
  border: none;
  box-shadow: none;
  background: #fffdfa;
  -webkit-mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 80 240' preserveAspectRatio='none'><path d='M0 10 C 5 0 15 0 20 10 S 35 20 40 10 S 55 0 60 10 S 75 20 80 10 L 80 230 C 75 240 65 240 60 230 S 45 220 40 230 S 25 240 20 230 S 5 220 0 230 Z' fill='black'/></svg>");
          mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 80 240' preserveAspectRatio='none'><path d='M0 10 C 5 0 15 0 20 10 S 35 20 40 10 S 55 0 60 10 S 75 20 80 10 L 80 230 C 75 240 65 240 60 230 S 45 220 40 230 S 25 240 20 230 S 5 220 0 230 Z' fill='black'/></svg>");
  -webkit-mask-size: 100% 100%;
          mask-size: 100% 100%;
  -webkit-mask-repeat: no-repeat;
          mask-repeat: no-repeat;
}
.decorative-receipt-heading {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 6px;
}
.decorative-receipt-rule {
  flex: 1;
  height: 1.5px;
  background: var(--decorative-ink);
}
.decorative-receipt-title {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: .28em;
  color: var(--decorative-ink);
}
.decorative-receipt-rows {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 4px;
}
.decorative-receipt-row {
  display: flex;
  align-items: center;
  gap: 6px;
}
.decorative-receipt-item,
.decorative-receipt-amount,
.decorative-receipt-total-label,
.decorative-receipt-total-amount {
  display: block;
  height: 6px;
  border-radius: 2px;
  background: var(--decorative-ink);
}
.decorative-receipt-dots {
  flex: 1;
  height: 6px;
  background-image: radial-gradient(circle, var(--decorative-ink) 1px, transparent 1.4px);
  background-size: 6px 6px;
  background-repeat: repeat-x;
  background-position: left center;
}
.decorative-receipt-total {
  margin-top: auto;
  padding-top: 12px;
  border-top: 1.5px solid var(--decorative-ink);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}
.decorative-receipt-total-label {
  width: 30%;
  height: 8px;
}
.decorative-receipt-total-amount {
  width: 22%;
  height: 8px;
}
.paper-line { height: 8px; background: linear-gradient(90deg, rgba(36,33,28,.82), rgba(36,33,28,.28)); border-radius: 999px; margin: 8px 0; }
.paper-line.short { width: 48%; }
.paper-line.mid { width: 72%; }
.paper-line.long { width: 94%; }

.field-grid { display:grid; gap: 10px; }
.field { display:grid; gap:6px; }
.field label { font-size: 12px; text-transform: uppercase; letter-spacing: .12em; color: var(--color-text-muted); }
.field input, .field select, .field textarea {
  width: 100%; min-height: 46px; border-radius: 14px; border: 1px solid var(--color-border);
  background: rgba(255,255,255,.76); padding: 11px 13px;
  transition: border-color .18s ease, box-shadow .18s ease;
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none; border-color: rgba(27,91,87,.45); box-shadow: 0 0 0 3px rgba(27,91,87,.12);
}
.field textarea { min-height: 88px; resize: vertical; }

.validation { display:grid; gap:10px; }
.validation-row {
  display:flex; justify-content:space-between; gap:12px; align-items:center;
  border-radius: 16px; padding: 11px 13px;
}
.validation-row.ok { background:#edf4ef; color:#245039; }
.validation-row.bad { background:#f6e7e3; color:#7b4038; }
.validation-row.warn { background:#f8f1e5; color:#7d5920; }

/* Edit-first scanned-result rows: each row is the editable control itself,
   keeping the compact mobile look while letting staff edit without scrolling. */
.validation.edit-first { gap: 8px; }
.validation-edit-row {
  display: grid;
  grid-template-columns: 88px 1fr;
  gap: 10px 12px;
  align-items: center;
  border-radius: 16px;
  padding: 8px 12px;
  background: rgba(255,255,255,.62);
  border: 1px solid var(--color-border);
  transition: background-color .18s ease, border-color .18s ease;
}
.validation-edit-row.ok { background:#edf4ef; border-color: rgba(47,111,79,.35); }
.validation-edit-row.warn { background:#f8f1e5; border-color: rgba(155,106,29,.40); }
.validation-edit-row.bad { background:#f6e7e3; border-color: rgba(145,80,65,.45); }
.validation-edit-row.hidden { display: none; }
.validation-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .12em;
  color: var(--color-text-muted);
  font-weight: 600;
}
.validation-edit-row.ok .validation-label { color:#245039; }
.validation-edit-row.warn .validation-label { color:#7d5920; }
.validation-edit-row.bad .validation-label { color:#7b4038; }
.validation-input {
  width: 100%;
  height: 40px;
  min-height: 40px;
  box-sizing: border-box;
  border-radius: 12px;
  border: 1px solid var(--color-border);
  background: rgba(255,255,255,.92);
  padding: 8px 11px;
  font: inherit;
  line-height: 1.2;
  color: inherit;
  text-align: left;
  -webkit-appearance: none;
  appearance: none;
  transition: border-color .18s ease, box-shadow .18s ease;
}
textarea.validation-input { height: auto; }
select.validation-input {
  background-image: linear-gradient(45deg, transparent 50%, currentColor 50%),
                    linear-gradient(135deg, currentColor 50%, transparent 50%);
  background-position: calc(100% - 16px) 50%, calc(100% - 11px) 50%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-right: 28px;
}
input.validation-input[type="date"] {
  font-variant-numeric: tabular-nums;
  text-align: left;
}
input.validation-input[type="date"]::-webkit-date-and-time-value {
  text-align: left;
  margin: 0;
}
input.validation-input[type="date"]::-webkit-calendar-picker-indicator {
  margin-left: auto;
  opacity: .55;
  cursor: pointer;
}
.validation-input:focus {
  outline: none;
  border-color: rgba(27,91,87,.45);
  box-shadow: 0 0 0 3px rgba(27,91,87,.12);
}
.validation-textarea { min-height: 64px; resize: vertical; grid-column: 1 / -1; }
.validation-edit-row[data-row="note"] { grid-template-columns: 1fr; gap: 6px; }
.validation-edit-row[data-row="note"] .validation-label { grid-column: 1 / -1; }
.validation-hint {
  grid-column: 2 / -1;
  font-size: 11px;
  letter-spacing: .03em;
  font-variant-numeric: tabular-nums;
  color: var(--color-text-muted);
  margin-top: -2px;
}
.validation-edit-row.ok .validation-hint { color:#245039; }
.validation-edit-row.warn .validation-hint { color:#7d5920; }
.validation-edit-row.bad .validation-hint { color:#7b4038; }
.validation-hint:empty { display: none; }
.validation-split {
  display: grid;
  grid-template-columns: 1fr 88px;
  gap: 8px;
  align-items: center;
}
.validation-input[data-confidence="high"] {
  border-color: rgba(47,111,79,.55);
  box-shadow: inset 0 0 0 1px rgba(47,111,79,.20);
}
.validation-input[data-confidence="medium"] {
  border-color: rgba(155,106,29,.55);
  box-shadow: inset 0 0 0 1px rgba(155,106,29,.22);
}
.validation-input[data-confidence="low"] {
  border-color: rgba(145,80,65,.60);
  box-shadow: inset 0 0 0 1px rgba(145,80,65,.24);
}
.validation-input[data-confidence]:focus {
  box-shadow: 0 0 0 3px rgba(27,91,87,.12);
}
@media (max-width: 380px) {
  .validation-edit-row { grid-template-columns: 1fr; gap: 6px; padding: 8px 10px; }
  .validation-hint { grid-column: 1 / -1; }
}

/* ── Vendor typeahead (QuickBooks-backed autocomplete) ────────────────────── */
/* The autocomplete wraps the vendor <input> at runtime so the dropdown can be
   absolutely positioned against it. The wrapper takes the input's old grid cell
   and the input stretches to fill it, so the layout is unchanged. */
.vendor-typeahead {
  position: relative;
  width: 100%;
  min-width: 0;
}
.vendor-typeahead > .validation-input {
  width: 100%;
}
.vendor-typeahead-menu {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  z-index: 60;
  margin: 0;
  padding: 4px;
  list-style: none;
  max-height: 248px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  background: #fff;
  border: 1px solid var(--color-border);
  border-radius: 12px;
  box-shadow: 0 12px 28px rgba(31, 49, 41, .18);
}
.vendor-typeahead-menu.hidden { display: none; }
.vendor-typeahead-item {
  padding: 11px 12px;
  min-height: 44px;
  display: flex;
  align-items: center;
  border-radius: 9px;
  font-size: 15px;
  line-height: 1.25;
  color: var(--color-text);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.vendor-typeahead-item + .vendor-typeahead-item { margin-top: 2px; }
.vendor-typeahead-item.active,
.vendor-typeahead-item:hover {
  background: #edf4ef;
  color: #245039;
}

/* Per-field confidence colors — high/medium/low map to green/amber/red.
   Applied to the input/select itself so staff can see field health while editing. */
.field input[data-confidence="high"],
.field select[data-confidence="high"] {
  border-color: rgba(47,111,79,.55);
  box-shadow: inset 0 0 0 1px rgba(47,111,79,.25);
  color: #245039;
}
.field input[data-confidence="medium"],
.field select[data-confidence="medium"] {
  border-color: rgba(155,106,29,.55);
  box-shadow: inset 0 0 0 1px rgba(155,106,29,.28);
  color: #7d5920;
}
.field input[data-confidence="low"],
.field select[data-confidence="low"] {
  border-color: rgba(145,80,65,.65);
  box-shadow: inset 0 0 0 1px rgba(145,80,65,.30);
  color: var(--color-error);
}
.field input[data-confidence="high"]:focus,
.field input[data-confidence="medium"]:focus,
.field input[data-confidence="low"]:focus,
.field select[data-confidence]:focus {
  box-shadow: 0 0 0 3px rgba(27,91,87,.12);
}
.queue-item { display:grid; gap: 12px; padding-bottom: 12px; border-bottom:1px solid var(--color-divider); }
.queue-item:not(.manual-item) { grid-template-columns: minmax(0,1fr) auto; align-items: flex-start; }
.queue-item:last-child { padding-bottom: 0; border-bottom: 0; }
.queue-main { display:flex; gap:12px; align-items:flex-start; min-width:0; }
.manual-item-panel {
  display: grid;
  gap: 10px;
  padding: 12px;
  border-radius: 18px;
  border: 1px dashed rgba(27,91,87,.28);
  background: rgba(255,255,255,.52);
}
.manual-item {
  background: rgba(27,91,87,.05);
  border-radius: 16px;
  padding: 10px;
  border-bottom: 0;
}
.compact-fields {
  gap: 8px;
}
.queue-top { display:flex; gap:12px; align-items:flex-start; }
.check {
  width: 22px; height: 22px; border-radius: 7px; flex:0 0 auto;
  border:1px solid var(--color-border); background:#fff; display:grid; place-items:center; margin-top:2px;
}
.check.active { background: var(--color-primary); color:#fff; border-color: transparent; }
.check[disabled] { background: #efe9df; cursor: not-allowed; color: var(--color-text-faint); }
.queue-actions { display:flex; gap:8px; flex-wrap:wrap; }
.queue-actions button {
  min-height: 36px; border-radius: 999px; border:1px solid var(--color-border);
  background: rgba(255,255,255,.68); padding: 0 12px; font-size: 13px;
}
.queue-item:not(.manual-item) .queue-actions {
  flex-direction: column; flex-wrap: nowrap; flex: 0 0 auto; align-items: stretch;
}
.queue-item:not(.manual-item) .queue-actions button { white-space: nowrap; }
.queue-item.queue-item-selectable { grid-template-columns: minmax(0,1fr); }
.queue-receipt-open {
  display: flex; flex-direction: column; gap: 4px; flex: 1; min-width: 0;
  border: 0; background: transparent; padding: 0; margin: 0;
  text-align: left; cursor: pointer; color: inherit; font: inherit;
}
.queue-receipt-open:active { opacity: .6; }

.totals-card {
  background: #211d19;
  color: #f6f1ea;
  border-radius: 28px;
  padding: 18px;
  display:grid; gap: 10px;
  box-shadow: var(--shadow-md);
}
.totals-row { display:flex; justify-content:space-between; gap:12px; font-size: 14px; color: rgba(246,241,234,.78); }
.totals-row strong { color:#fff; }
.totals-row.total { border-top:1px solid rgba(255,255,255,.12); padding-top:10px; font-size: 16px; }

.desktop {
  display:grid; gap: 18px;
  grid-template-columns: minmax(320px, 420px) minmax(420px, 1fr);
}
.panel, .pdf-sheet { border-radius: 28px; padding: 22px; }
.panel h2, .pdf-sheet h2 {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 500;
  font-size: clamp(1.7rem, 1.5rem + .4vw, 2.4rem);
  line-height: 1.02;
}
.panel p { margin: 0; color: var(--color-text-muted); }
.panel code { background: rgba(40,37,29,.06); padding: 1px 6px; border-radius: 6px; font-size: 12px; }

.spec-list { display:grid; gap: 0; margin-top: 8px; }
.spec-item {
  padding: 14px 0;
  border-bottom: 1px solid var(--color-divider);
  display:grid; gap: 6px;
}
.spec-item:first-child { padding-top: 0; }
.spec-item:last-child { border-bottom: 0; padding-bottom: 0; }
.spec-item strong { font-size: 15px; }
.spec-item .meta { color: var(--color-text-muted); font-size: 13px; line-height: 1.5; }

.pdf-sheet { display:grid; gap: 22px; background: #fff; }
.pdf-header {
  display:flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  border-bottom: 2px solid #111;
  padding-bottom: 14px;
}
.pdf-logo { text-align: left; }
.pdf-logo-img {
  display: block;
  height: 64px;
  width: auto;
  max-width: 260px;
}
.pdf-header-meta { text-align: right; }
.pdf-doc-title { margin: 0; font-size: 20px; color: #111; }
.pdf-header .pdf-note { margin: 4px 0 0; }
.pdf-summary-stack { display:grid; grid-template-columns: 1fr; gap: 18px; }
.summary-box, .detail-box {
  border:1px solid rgba(40,37,29,.1);
  border-radius: 18px;
  padding: 18px;
  background: #fcfaf7;
}
.summary-box h3, .detail-box h3 {
  margin: 0 0 12px;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: .12em;
  color: var(--color-text-muted);
}
.amount-big { font-size: 42px; font-weight: 700; letter-spacing: -.04em; line-height: 1; }
.pdf-note { color: var(--color-text-muted); font-size: 14px; }

table { width:100%; border-collapse: collapse; }
th, td { text-align:left; padding: 11px 0; border-bottom: 1px solid rgba(40,37,29,.08); font-size: 14px; vertical-align: top; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--color-text-muted); }
.detail-box td:last-child,
.detail-box th:last-child {
  text-align: right;
}
.money {
  display: inline-block;
  min-width: 112px;
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1, "lnum" 1;
}

.note-box {
  border-left: 2px solid rgba(27,91,87,.35);
  padding-left: 14px;
  color: var(--color-text-muted);
  font-size: 14px;
}
/* Pay Invoice CTA lives inside the Total Due bubble (.summary-box), so it
   reads as part of that card rather than a separate floating block. */
.summary-box .pdf-pay {
  display: flex; flex-direction: column; gap: 8px;
  margin: 16px 0 0;
  padding: 16px 0 0;
  border-top: 1px solid rgba(40,37,29,.1);
}
.pdf-pay-link {
  display: inline-block; align-self: flex-start;
  padding: 10px 18px; border-radius: 8px;
  background: #2f6a4a; color: #fff; font-weight: 600;
  text-decoration: none;
}
.pdf-pay-link:hover { background: #1f4f37; }
.pdf-pay .pdf-note { margin: 0; color: var(--color-text-muted); font-size: 13px; }
.pdf-receipts { display:grid; grid-template-columns: 1fr; gap: 18px; }
.pdf-receipt {
  border:1px solid rgba(40,37,29,.08); border-radius: 18px; overflow:hidden; background:#faf8f3;
}
.pdf-receipt .label {
  padding: 12px 14px; border-bottom:1px solid rgba(40,37,29,.08);
  text-transform: uppercase; letter-spacing: .08em; font-size: 12px; color: var(--color-text-muted);
}
.pdf-receipt .img { padding:18px; background:#f4efe6; }
.pdf-receipt .img img { width:100%; height: auto; max-height: 240px; object-fit: contain; border-radius: 12px; background:#fffdfa; }
.pdf-receipt .receipt-img-loading,
.pdf-receipt .receipt-img-fallback {
  display:flex; flex-direction: column; align-items:center; justify-content:center;
  min-height: 120px; text-align:center;
  color: var(--color-text-muted); font-size: 13px; line-height: 1.5;
  border: 1px dashed rgba(40,37,29,.25); border-radius: 12px; background:#fffdfa; padding: 16px;
}
.pdf-receipt .receipt-img-fallback span { font-size: 12px; opacity: .8; }

.empty {
  padding: 24px; border-radius: 24px; border:1px dashed var(--color-border); background: rgba(255,255,255,.5); text-align:center; color: var(--color-text-muted);
}
.hidden { display: none !important; }

/* Duplicate-receipt warning modal — mobile-first, polished. */
.duplicate-modal {
  position: fixed; inset: 0; z-index: 1000;
  display: grid; place-items: end center;
  padding: 16px;
}
.duplicate-modal-backdrop {
  position: absolute; inset: 0;
  background: rgba(28,25,20,.48);
  backdrop-filter: blur(2px);
}
.duplicate-modal-card {
  position: relative;
  width: 100%;
  max-width: 420px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 22px 20px 18px;
  box-shadow: var(--shadow-md);
  display: flex; flex-direction: column; gap: 12px;
  animation: duplicate-modal-pop .18s ease-out;
}
@keyframes duplicate-modal-pop {
  from { transform: translateY(12px); opacity: 0; }
  to   { transform: translateY(0); opacity: 1; }
}
.duplicate-modal-eyebrow {
  font-size: 11px; letter-spacing: .14em; text-transform: uppercase;
  color: var(--color-warning); font-weight: 700;
}
.duplicate-modal-card h2 {
  margin: 0; font-family: var(--font-display);
  font-size: 1.25rem; line-height: 1.25; color: var(--color-text);
}
.duplicate-modal-body { margin: 0; color: var(--color-text-muted); font-size: .95rem; }
.duplicate-modal-matches {
  display: flex; flex-direction: column; gap: 8px;
  max-height: 220px; overflow-y: auto;
}
.duplicate-match {
  display: flex; flex-direction: column; gap: 2px;
  border: 1px solid var(--color-border);
  background: var(--color-surface-2);
  border-radius: var(--radius-md);
  padding: 10px 12px;
}
.duplicate-match-top { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.duplicate-match-vendor { font-weight: 700; color: var(--color-text); }
.duplicate-match-amount { font-weight: 700; color: var(--color-text); }
.duplicate-match-meta { color: var(--color-text-muted); font-size: .8rem; }
.duplicate-modal-actions {
  display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 4px;
}
.duplicate-modal-actions .ghost-btn,
.duplicate-modal-actions .action-btn { width: 100%; }
.cancel-modal-actions {
  grid-template-columns: 1fr;
}
.cancel-modal-actions .ghost-btn,
.cancel-modal-actions .danger-btn,
.cancel-modal-actions .soft-btn { width: 100%; }

.submit-progress-card {
  align-items: center;
  text-align: center;
  padding: 28px 22px 22px;
}
.submit-progress-state {
  display: flex; flex-direction: column; align-items: center; gap: 12px;
}
.submit-progress-state h2 { text-align: center; }
.submit-progress-state .duplicate-modal-body { text-align: center; }
.submit-progress-spinner {
  width: 48px; height: 48px;
  border-radius: 50%;
  border: 4px solid var(--color-border);
  border-top-color: var(--color-accent, #1b5b57);
  animation: submit-progress-spin 0.9s linear infinite;
}
.submit-progress-state[data-state="complete"] .submit-progress-spinner { display: none; }
.submit-progress-state[data-state="complete"] .submit-progress-check { display: flex; }
.submit-progress-check {
  width: 56px; height: 56px;
  border-radius: 50%;
  background: #2f8f6c;
  color: #fff;
  display: none;
  align-items: center; justify-content: center;
  animation: duplicate-modal-pop .2s ease-out;
}
@keyframes submit-progress-spin {
  to { transform: rotate(360deg); }
}

#reimbursementSuccessModal .duplicate-modal-card {
  align-items: center;
  text-align: center;
  padding: 24px 22px 22px;
}
#reimbursementSuccessModal .submit-progress-check { display: flex; margin: 0 auto; }
#reimbursementSuccessModal h2 { text-align: center; }
#reimbursementSuccessModal .cancel-modal-actions .action-btn { width: 100%; }

@media (min-width: 540px) {
  .duplicate-modal { place-items: center; }
}

@media (max-width: 1180px) {
  .shell { grid-template-columns: 1fr; }
  .phone { position: static; width: min(100%, 440px); margin: 0 auto; }
  .desktop { grid-template-columns: 1fr; }
  .pdf-summary-stack, .pdf-receipts { grid-template-columns: 1fr; }
}

/* Real phone: drop the device-mockup chrome so the app renders as a full-screen
   PWA instead of inside a fake iPhone bezel. The black frame, rounded corners and
   simulated "9:41" status bar are a desktop-only preview affordance; on an actual
   handset they make the staff app look like a mockup rather than an installed app.
   The .desktop column is an engineering-notes/PDF preview panel with no place on a
   phone. .bottom-bar is absolutely positioned within .screen, so a full-viewport
   .screen keeps it correctly anchored. */
@media (max-width: 640px) {
  .shell {
    width: 100%;
    margin: 0;
    padding: 0;
    gap: 0;
    grid-template-columns: 1fr;
  }
  .phone {
    position: static;
    width: 100%;
    margin: 0;
    background: none;
    border-radius: 0;
    padding: 0;
    box-shadow: none;
  }
  .screen {
    height: 100dvh;
    min-height: 100dvh;
    border-radius: 0;
  }
  /* Simulated handset status bar — redundant behind the real one on a phone. */
  .statusbar { display: none; }
  /* Clear the real status bar / notch when running full-screen or installed. */
  .header,
  .header-compact { padding-top: calc(10px + env(safe-area-inset-top)); }
  /* Desktop-only operator notes + PDF preview panel. */
  .desktop { display: none; }
  /* Lift the floating tab bar clear of the iPhone home indicator. */
  .bottom-bar { inset: auto 10px calc(14px + env(safe-area-inset-bottom)); }
}

.final-review-card { padding: 14px; gap: 10px; }
.final-review-title { font-size: 15px; line-height: 1.25; }
.final-review-body {
  display: grid;
  grid-template-columns: 64px 1fr;
  gap: 12px;
  align-items: start;
}
.final-review-thumb {
  width: 64px;
  min-height: 64px;
  max-height: 120px;
  border-radius: 10px;
  overflow: hidden;
  background: var(--cream, #f4ede2);
  border: 1px solid rgba(0,0,0,0.08);
  display: flex;
  align-items: center;
  justify-content: center;
  color: rgba(0,0,0,0.45);
  flex-shrink: 0;
}
.final-review-thumb img {
  width: 100%;
  height: auto;
  max-height: 120px;
  object-fit: contain;
  display: block;
}
.final-review-fields {
  margin: 0;
  display: grid;
  gap: 6px;
  min-width: 0;
}
.final-review-row {
  display: grid;
  grid-template-columns: 76px 1fr;
  gap: 8px;
  align-items: baseline;
}
.final-review-row dt {
  margin: 0;
  font-size: 11px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: rgba(0,0,0,0.55);
  font-weight: 600;
}
.final-review-row dd {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  color: inherit;
  word-break: break-word;
}

/* =========================================================================
   Install prompt — Android/Chromium native banner + iPhone instruction sheet
   ========================================================================= */

/* Persistent "Install SAVINA on your phone" link on the sign-in card. Always
   available so the prompt is never permanently hidden by a 7-day dismissal. */
.install-link {
  margin-top: 2px;
  font-size: 13px;
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.install-link.hidden { display: none; }

.install-banner {
  position: fixed;
  left: 50%;
  bottom: 16px;
  transform: translate(-50%, 24px);
  z-index: 90;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 12px;
  width: min(calc(100% - 24px), 480px);
  padding: 12px 14px;
  background: var(--color-surface, #fbf8f3);
  color: var(--color-text, #28251d);
  border: 1px solid var(--color-border, rgba(40,37,29,.11));
  border-radius: var(--radius-md, 18px);
  box-shadow: var(--shadow-md, 0 16px 40px rgba(35,28,23,.18));
  opacity: 0;
  transition: opacity .22s ease, transform .22s ease;
  /* Respect iPhone home-indicator safe area. */
  padding-bottom: max(12px, calc(env(safe-area-inset-bottom) + 8px));
  bottom: max(16px, calc(env(safe-area-inset-bottom) + 8px));
}
.install-banner.hidden { display: none; }
.install-banner.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}
.install-banner-icon {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: var(--radius-full, 999px);
  background: var(--color-primary, #1b5b57);
  color: #fff;
}
.install-banner-icon svg { width: 22px; height: 22px; }
.install-banner-copy {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.install-banner-title {
  font-size: 13px;
  font-weight: 700;
  line-height: 1.25;
  color: var(--color-text, #28251d);
}
.install-banner-meta {
  font-size: 11.5px;
  line-height: 1.3;
  color: var(--color-text-muted, #706a63);
}
.install-banner-actions {
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: stretch;
}
.install-banner-primary {
  appearance: none;
  border: 0;
  background: var(--color-primary, #1b5b57);
  color: #fff;
  font-family: inherit;
  font-weight: 600;
  font-size: 12.5px;
  padding: 8px 14px;
  border-radius: var(--radius-full, 999px);
  cursor: pointer;
  white-space: nowrap;
  transition: background-color .15s ease;
}
.install-banner-primary:hover,
.install-banner-primary:focus-visible {
  background: var(--color-primary-hover, #144844);
}
.install-banner-dismiss {
  appearance: none;
  background: transparent;
  border: 0;
  color: var(--color-text-muted, #706a63);
  font-family: inherit;
  font-size: 11.5px;
  padding: 4px 6px;
  cursor: pointer;
}
.install-banner-dismiss:hover { color: var(--color-text, #28251d); }

@media (min-width: 480px) {
  .install-banner-actions {
    flex-direction: row;
    align-items: center;
  }
}

.install-sheet {
  position: fixed;
  inset: 0;
  z-index: 120;
  display: grid;
  place-items: center;
  padding: 16px;
  opacity: 0;
  transition: opacity .18s ease;
}
.install-sheet.hidden { display: none; }
.install-sheet.is-visible { opacity: 1; }
.install-sheet-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(20, 18, 14, 0.5);
}
.install-sheet-card {
  position: relative;
  width: min(100%, 420px);
  background: var(--color-surface, #fbf8f3);
  color: var(--color-text, #28251d);
  border-radius: var(--radius-lg, 26px);
  padding: 22px 22px 18px;
  box-shadow: var(--shadow-md, 0 16px 40px rgba(35,28,23,.20));
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-height: calc(100vh - 32px);
  overflow-y: auto;
}
.install-sheet-eyebrow {
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--color-text-muted, #706a63);
  font-weight: 600;
}
.install-sheet-card h2 {
  margin: 0;
  font-family: var(--font-display, Georgia, serif);
  font-size: 22px;
  line-height: 1.2;
  color: var(--color-text, #28251d);
}
.install-sheet-steps {
  margin: 6px 0 4px;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.install-sheet-steps li {
  display: grid;
  grid-template-columns: 28px 1fr;
  gap: 10px;
  align-items: flex-start;
  font-size: 14px;
  line-height: 1.4;
}
.install-sheet-step-num {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: var(--radius-full, 999px);
  background: var(--color-surface-2, #f0e9de);
  color: var(--color-primary, #1b5b57);
  font-weight: 700;
  font-size: 12px;
}
.install-sheet-step-text strong { font-weight: 700; }
.install-sheet-glyph {
  display: inline-grid;
  place-items: center;
  vertical-align: -4px;
  width: 22px;
  height: 22px;
  margin: 0 2px;
  border-radius: 6px;
  background: var(--color-surface-2, #f0e9de);
  color: var(--color-primary, #1b5b57);
}
.install-sheet-note {
  margin: 0;
  font-size: 12.5px;
  color: var(--color-text-muted, #706a63);
  line-height: 1.4;
}
.install-sheet-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 4px;
}
.install-sheet-close {
  appearance: none;
  border: 0;
  background: var(--color-primary, #1b5b57);
  color: #fff;
  font-family: inherit;
  font-weight: 600;
  font-size: 13px;
  padding: 10px 18px;
  border-radius: var(--radius-full, 999px);
  cursor: pointer;
  transition: background-color .15s ease;
}
.install-sheet-close:hover,
.install-sheet-close:focus-visible {
  background: var(--color-primary-hover, #144844);
}
