/* ==========================================================================
   GoGetCab design system
   Palette taken from the logo: amber #F7A81B, charcoal #17161A, white.
   Mobile first — every layout starts at 360px and grows from there.
   Amber is a FILL colour only. Amber text on white is ~2:1 contrast and
   fails WCAG, so labels and body copy always use charcoal or --muted.
   ========================================================================== */

:root {
  /* brand */
  --amber: #f7a81b;
  --amber-600: #e0940c;
  --amber-700: #b5720a;
  --amber-soft: #fff3dc;
  --amber-ring: rgba(247, 168, 27, .3);

  /* charcoal app shell */
  --ink: #17161a;
  --ink-2: #221f26;
  --ink-3: #2e2a33;
  --ink-line: rgba(255, 255, 255, .1);
  --on-ink: #f6f4f1;
  --on-ink-muted: #a9a4b0;

  /* light content surfaces */
  --bg: #faf8f5;
  --surface: #ffffff;
  --surface-2: #f6f3ef;
  --border: #eae5dd;
  --border-strong: #ddd6cb;
  --text: #1b1a1f;
  --muted: #6d6a74;

  /* status */
  --new: #b5720a;
  --new-soft: #fff1d6;
  --contacted: #37479c;
  --contacted-soft: #eaecfa;
  --converted: #0f7a4d;
  --converted-soft: #e3f6ee;
  --closed: #6d6a74;
  --closed-soft: #efece8;
  --danger: #b3261e;
  --danger-soft: #fdecea;
  --wa: #25d366;
  --wa-dark: #1eb255;

  /* shape */
  --r-xs: 8px;
  --r-sm: 10px;
  --r: 14px;
  --r-lg: 20px;
  --r-pill: 999px;
  --tap: 44px;

  --shadow-1: 0 1px 2px rgba(23, 22, 26, .06);
  --shadow-2: 0 2px 6px rgba(23, 22, 26, .06), 0 10px 28px rgba(23, 22, 26, .07);
  --shadow-3: 0 18px 44px rgba(23, 22, 26, .18);

  --topbar-h: 56px;
  --tabbar-h: 60px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}

h1, h2, h3 { margin: 0; line-height: 1.2; letter-spacing: -.02em; font-weight: 700; }
h1 { font-size: 1.4rem; }
h2 { font-size: 1.08rem; }
h3 { font-size: .96rem; }
p { margin: 0; }
a { color: var(--text); text-decoration: none; }
a.underline { text-decoration: underline; text-underline-offset: 2px; }

:focus-visible {
  outline: 2px solid var(--amber-600);
  outline-offset: 2px;
  border-radius: 4px;
}

.muted { color: var(--muted); }
.small { font-size: .82rem; }
.tiny { font-size: .74rem; }
.strong { font-weight: 700; }
.center { text-align: center; }
.hidden { display: none !important; }
.nowrap { white-space: nowrap; }
.mono { font-variant-numeric: tabular-nums; }
.row { display: flex; gap: 10px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.row.tight { gap: 6px; }
.col { display: grid; gap: 10px; }
.spacer { flex: 1; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.skip-link {
  position: absolute; left: 12px; top: -60px; z-index: 100;
  background: var(--surface); color: var(--text); padding: 10px 14px;
  border-radius: var(--r-sm); box-shadow: var(--shadow-2);
}
.skip-link:focus { top: calc(8px + var(--safe-t)); }

/* ---------------------------------------------------------------- app shell */

.topbar {
  background: var(--ink);
  color: var(--on-ink);
  position: sticky;
  top: 0;
  z-index: 30;
  padding-top: var(--safe-t);
  box-shadow: 0 1px 0 var(--ink-line);
}
.topbar-inner {
  max-width: 1120px;
  margin: 0 auto;
  min-height: var(--topbar-h);
  padding: 8px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand { display: flex; align-items: center; gap: 10px; min-width: 0; color: inherit; }
.brand-mark {
  width: 32px; height: 32px; flex: none;
  color: #fff; /* the G inherits this */
}
.brand-mark svg { display: block; width: 100%; height: 100%; }
.wordmark {
  font-size: 1.08rem; font-weight: 800; letter-spacing: -.03em; white-space: nowrap;
}
.wordmark em { color: var(--amber); font-style: normal; }
.brand-sub {
  display: block; font-size: .72rem; font-weight: 500; letter-spacing: .01em;
  color: var(--on-ink-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  max-width: 42vw;
}
.tagline {
  font-size: .66rem; font-weight: 700; letter-spacing: .22em; text-transform: uppercase;
  color: var(--muted);
}

.page {
  max-width: 1120px;
  margin: 0 auto;
  padding: 16px 14px calc(28px + var(--safe-b));
}
.page.narrow { max-width: 640px; }
.page-head { margin-bottom: 14px; }
.page-head h1 { margin-bottom: 2px; }

body.has-tabbar .page { padding-bottom: calc(var(--tabbar-h) + 24px + var(--safe-b)); }

/* ------------------------------------------------------------- bottom tabs */

.tabbar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 40;
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  background: var(--ink);
  border-top: 1px solid var(--ink-line);
  padding-bottom: var(--safe-b);
}
.tab {
  position: relative;
  display: grid;
  place-items: center;
  gap: 2px;
  min-height: var(--tabbar-h);
  padding: 8px 4px;
  color: var(--on-ink-muted);
  font-size: .68rem;
  font-weight: 600;
  letter-spacing: .02em;
  background: none;
  border: none;
  font-family: inherit;
  cursor: pointer;
}
.tab svg { width: 22px; height: 22px; }
.tab[aria-current="page"], .tab.is-active { color: var(--amber); }
.tab[aria-current="page"]::before, .tab.is-active::before {
  content: ""; position: absolute; top: 0; left: 22%; right: 22%; height: 3px;
  background: var(--amber); border-radius: 0 0 3px 3px;
}
.tab-badge {
  position: absolute; top: 6px; left: calc(50% + 8px);
  min-width: 17px; height: 17px; padding: 0 4px;
  border-radius: var(--r-pill); background: var(--amber); color: var(--ink);
  font-size: .66rem; font-weight: 800; display: grid; place-items: center;
}

/* -------------------------------------------------------------------- cards */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  box-shadow: var(--shadow-1);
  padding: 16px;
}
.card + .card, .card + .section-head, .section-head + .card { margin-top: 12px; }
.card.flush { padding: 0; overflow: hidden; }
.card-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.card-head h2, .card-head h3 { min-width: 0; }
.section-head { display: flex; align-items: center; gap: 10px; margin: 18px 0 10px; }

.hero {
  background: linear-gradient(160deg, var(--ink) 0%, #2b2531 100%);
  color: var(--on-ink);
  border-radius: var(--r-lg);
  padding: 18px;
  box-shadow: var(--shadow-2);
}
.hero .muted { color: var(--on-ink-muted); }
.hero-value { font-size: 2.4rem; font-weight: 800; letter-spacing: -.04em; line-height: 1; }
.hero-chips { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; }
.hero-chip {
  background: rgba(255, 255, 255, .08);
  border: 1px solid var(--ink-line);
  border-radius: var(--r-pill);
  padding: 6px 12px;
  font-size: .78rem;
  font-weight: 600;
}
.hero-chip b { color: var(--amber); }

.metrics { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
/* For counts that aren't a multiple of two or four (the admin's five tiles). */
.stats.auto { grid-template-columns: repeat(auto-fit, minmax(138px, 1fr)); }
.stat {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r); padding: 12px 14px; box-shadow: var(--shadow-1);
}
.stat-label {
  font-size: .7rem; text-transform: uppercase; letter-spacing: .07em;
  color: var(--muted); font-weight: 700;
}
.stat-value { font-size: 1.5rem; font-weight: 800; letter-spacing: -.03em; margin-top: 2px; }

/* --------------------------------------------------------------------- form */

.field { margin-bottom: 14px; }
.field:last-child { margin-bottom: 0; }
label { display: block; font-weight: 600; font-size: .84rem; margin-bottom: 6px; }
.hint { color: var(--muted); font-size: .78rem; margin-top: 6px; }

input, select, textarea {
  width: 100%;
  min-height: var(--tap);
  padding: 11px 13px;
  font: inherit;
  font-size: 16px; /* keeps iOS from zooming on focus */
  color: inherit;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-sm);
  outline: none;
  transition: border-color .15s, box-shadow .15s;
  appearance: none;
}
select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='9' viewBox='0 0 14 9'%3E%3Cpath d='M1 1l6 6 6-6' fill='none' stroke='%236d6a74' stroke-width='2' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 13px center;
  padding-right: 36px;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--amber-600);
  box-shadow: 0 0 0 3px var(--amber-ring);
}
input::placeholder, textarea::placeholder { color: #a5a1aa; }
textarea { min-height: 84px; resize: vertical; }
.grid-2 { display: grid; grid-template-columns: 1fr; gap: 0 12px; }
.error { color: var(--danger); font-size: .8rem; margin-top: 5px; }
input[aria-invalid="true"], select[aria-invalid="true"], textarea[aria-invalid="true"] {
  border-color: #e07b74;
  background: #fffafa;
}

/* chip radios (trip type, vehicle) */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { position: relative; }
.chip input {
  position: absolute; inset: 0; opacity: 0; margin: 0; min-height: 0; cursor: pointer;
}
.chip span {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 40px; padding: 8px 14px;
  border: 1px solid var(--border-strong); border-radius: var(--r-pill);
  background: var(--surface); font-size: .86rem; font-weight: 600; color: var(--text);
  transition: background .15s, border-color .15s, color .15s;
}
.chip input:checked + span {
  background: var(--amber); border-color: var(--amber); color: var(--ink);
}
.chip input:focus-visible + span { outline: 2px solid var(--amber-600); outline-offset: 2px; }

/* document picker (verification step 1) — two up on a phone, four across on desktop */
.doc-picker { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.doc-opt { position: relative; }
.doc-opt input {
  position: absolute; inset: 0; opacity: 0; margin: 0; min-height: 0; cursor: pointer;
}
.doc-opt span {
  display: flex; flex-direction: column; gap: 2px; height: 100%;
  min-height: 62px; padding: 10px 12px;
  border: 1px solid var(--border-strong); border-radius: var(--r-sm);
  background: var(--surface); transition: background .15s, border-color .15s, box-shadow .15s;
}
.doc-opt span b { font-size: .88rem; font-weight: 700; color: var(--text); }
.doc-opt span em { font-style: normal; font-size: .72rem; line-height: 1.3; color: var(--muted); }
.doc-opt input:checked + span {
  border-color: var(--amber); background: var(--amber-ring); box-shadow: inset 0 0 0 1px var(--amber);
}
.doc-opt input:checked + span em { color: var(--text); }
.doc-opt input:focus-visible + span { outline: 2px solid var(--amber-600); outline-offset: 2px; }

/* the two ways to supply a document */
.fetch-box {
  position: relative; padding: 14px;
  border: 1px solid var(--border); border-radius: var(--r-sm); background: var(--surface-2);
}
.fetch-box.recommended { border-color: var(--amber); background: var(--surface); }
.fetch-tag {
  position: absolute; top: -9px; right: 12px;
  padding: 2px 8px; border-radius: var(--r-pill);
  background: var(--amber); color: var(--ink);
  font-size: .64rem; font-weight: 800; letter-spacing: .06em; text-transform: uppercase;
}
.or-split { display: flex; align-items: center; gap: 12px; margin: 12px 0; }
.or-split::before, .or-split::after {
  content: ''; flex: 1; height: 1px; background: var(--border);
}
.or-split span {
  font-size: .72rem; font-weight: 700; letter-spacing: .08em;
  text-transform: uppercase; color: var(--muted);
}

/* one upload row, for the chosen document only */
.up-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.up-row .up-state { font-size: .78rem; color: var(--muted); min-width: 0; flex: 1; }
.up-row .up-state.ok { color: var(--converted); font-weight: 600; }
.up-row .up-state.bad { color: var(--danger); }

/* switch */
.switch { display: flex; align-items: center; gap: 12px; cursor: pointer; }
.switch input {
  position: absolute; opacity: 0; width: 0; height: 0; min-height: 0; padding: 0; margin: 0; border: 0;
}
.switch-track {
  width: 48px; height: 28px; flex: none; border-radius: var(--r-pill);
  background: var(--border-strong); position: relative; transition: background .18s;
}
.switch-track::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px;
  border-radius: 50%; background: #fff; box-shadow: var(--shadow-1); transition: transform .18s;
}
.switch input:checked + .switch-track { background: var(--amber); }
.switch input:checked + .switch-track::after { transform: translateX(20px); }
.switch input:focus-visible + .switch-track { outline: 2px solid var(--amber-600); outline-offset: 2px; }

/* ------------------------------------------------------------------ buttons */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: var(--tap); padding: 11px 18px;
  font: inherit; font-weight: 700; line-height: 1.2; cursor: pointer;
  border: 1px solid transparent; border-radius: var(--r-sm);
  background: var(--amber); color: var(--ink);
  transition: background .15s, transform .04s, box-shadow .15s, border-color .15s;
  text-align: center;
}
.btn:hover { background: var(--amber-600); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: not-allowed; transform: none; }
.btn.block { width: 100%; }

.btn.ghost { background: var(--surface); color: var(--text); border-color: var(--border-strong); }
.btn.ghost:hover { background: var(--surface-2); border-color: var(--muted); }

.btn.dark { background: var(--ink); color: var(--on-ink); }
.btn.dark:hover { background: var(--ink-3); }

.btn.on-dark {
  background: rgba(255, 255, 255, .08); color: var(--on-ink); border-color: var(--ink-line);
}
.btn.on-dark:hover { background: rgba(255, 255, 255, .16); }

.btn.danger { background: var(--danger-soft); color: var(--danger); border-color: #f3c9c5; }
.btn.danger:hover { background: #fbdcd9; }

.btn.sm { min-height: 38px; padding: 8px 14px; font-size: .84rem; }
.btn.wa { background: var(--wa); color: #06331a; font-size: 1rem; min-height: 52px; }
.btn.wa:hover { background: var(--wa-dark); }
.btn.link {
  background: none; border: none; color: var(--muted); min-height: 36px;
  padding: 6px 4px; font-weight: 600; text-decoration: underline; text-underline-offset: 2px;
}
.btn.link:hover { background: none; color: var(--text); }

.icon-btn {
  position: relative;
  width: var(--tap); height: var(--tap); flex: none;
  display: grid; place-items: center;
  background: rgba(255, 255, 255, .08); color: var(--on-ink);
  border: 1px solid var(--ink-line); border-radius: var(--r-sm);
  cursor: pointer; font: inherit;
}
.icon-btn:hover { background: rgba(255, 255, 255, .16); }
.icon-btn svg { width: 20px; height: 20px; }
.icon-btn.light {
  background: var(--surface); color: var(--text); border-color: var(--border-strong);
}
.icon-btn.light:hover { background: var(--surface-2); }
.bell-dot {
  position: absolute; top: 4px; right: 4px;
  min-width: 16px; height: 16px; padding: 0 4px;
  border-radius: var(--r-pill); background: var(--amber); color: var(--ink);
  font-size: .64rem; font-weight: 800; display: grid; place-items: center;
}

/* ------------------------------------------------------------------- badges */

.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 4px 9px; border-radius: var(--r-pill);
  font-size: .68rem; font-weight: 800; letter-spacing: .06em; text-transform: uppercase;
  white-space: nowrap;
}
.badge.NEW, .badge.ASSIGNED { background: var(--new-soft); color: var(--new); }
.badge.CONTACTED { background: var(--contacted-soft); color: var(--contacted); }
.badge.CONVERTED { background: var(--converted-soft); color: var(--converted); }
.badge.CLOSED { background: var(--closed-soft); color: var(--closed); }
.badge.solid { background: var(--amber); color: var(--ink); }
.badge.dot::before {
  content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor;
}

/* segmented filter (tablist) */
.segmented {
  display: flex; gap: 6px; overflow-x: auto; padding: 3px;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--r-pill); scrollbar-width: none;
}
.segmented::-webkit-scrollbar { display: none; }
.segmented button {
  flex: 1 0 auto; min-height: 38px; padding: 8px 16px;
  background: none; border: none; border-radius: var(--r-pill);
  font: inherit; font-size: .86rem; font-weight: 700; color: var(--muted);
  cursor: pointer; white-space: nowrap;
}
.segmented button[aria-selected="true"] {
  background: var(--ink); color: var(--on-ink); box-shadow: var(--shadow-1);
}

/* --------------------------------------------------------------- lead cards */

.lead-list { display: grid; gap: 10px; }

.lead-card {
  position: relative;
  display: block;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 14px;
  box-shadow: var(--shadow-1);
  color: inherit;
  transition: box-shadow .15s, border-color .15s, transform .04s;
}
.lead-card:active { transform: scale(.995); }
.lead-card:hover { border-color: var(--border-strong); box-shadow: var(--shadow-2); }
/* An enquiry somebody else bought. Still listed, visibly out of reach. */
.lead-card.is-soldout { opacity: .62; }
.lead-card.is-soldout .lead-name, .lead-card.is-soldout .route b { text-decoration: line-through; }

.lead-card.is-new {
  border-color: #f2d9a5;
  box-shadow: var(--shadow-1), inset 3px 0 0 var(--amber);
}
.lead-card.is-hot { box-shadow: var(--shadow-1), inset 3px 0 0 #e5484d; }

.lead-top { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.age { font-size: .72rem; font-weight: 800; letter-spacing: .02em; color: var(--muted); }
.age.hot { color: #c22b2f; }
.lead-name { font-size: 1.06rem; font-weight: 700; letter-spacing: -.02em; }

/* pickup -> drop route line */
.route { display: grid; gap: 4px; margin: 10px 0; }
.route-line { display: flex; align-items: center; gap: 8px; font-size: .92rem; min-width: 0; }
.route-line b { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pip { width: 9px; height: 9px; border-radius: 50%; flex: none; border: 2px solid var(--muted); }
.pip.to { border-color: var(--amber-600); background: var(--amber); }

.facts { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0 12px; }
.fact {
  display: inline-flex; align-items: center; gap: 5px;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--r-xs); padding: 5px 9px;
  font-size: .78rem; color: var(--text);
}
.fact b { font-weight: 700; }
.fact.money b { font-variant-numeric: tabular-nums; }

.lead-actions { display: grid; grid-template-columns: 1fr auto; gap: 8px; }

/* ------------------------------------------------------------ detail layout */

.detail-list { display: grid; }
.detail-row {
  display: grid; grid-template-columns: 1fr; gap: 2px;
  padding: 11px 0; border-bottom: 1px solid var(--border);
}
.detail-row:first-child { padding-top: 0; }
.detail-row:last-child { border-bottom: none; padding-bottom: 0; }
.detail-row dt { color: var(--muted); font-size: .8rem; font-weight: 600; }
.detail-row dd { margin: 0; font-weight: 600; }

.preview {
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--r-sm); padding: 12px 14px;
  font-size: .9rem; color: #3a3740; white-space: pre-wrap; word-break: break-word;
}

.sticky-cta {
  position: sticky; bottom: 0; z-index: 20;
  padding: 12px 0 calc(12px + var(--safe-b));
  background: linear-gradient(180deg, rgba(250, 248, 245, 0) 0%, var(--bg) 40%);
}

/* ------------------------------------------------------------------- tables */

.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; font-size: .88rem; }
th, td { padding: 10px 12px; text-align: left; white-space: nowrap; }
th {
  font-size: .7rem; text-transform: uppercase; letter-spacing: .07em;
  color: var(--muted); border-bottom: 1px solid var(--border); font-weight: 700;
}
tbody tr { border-bottom: 1px solid var(--surface-2); }
tbody tr:last-child { border-bottom: none; }
td.mono { font-variant-numeric: tabular-nums; color: var(--muted); }

/* Card list that replaces a table on small screens (built by JS). */
.row-cards { display: grid; gap: 10px; }
.row-card {
  border: 1px solid var(--border); border-radius: var(--r);
  padding: 12px; background: var(--surface);
}
.row-card-top { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.row-card dl { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; margin: 8px 0 0; }
.row-card dt { color: var(--muted); font-size: .8rem; }
.row-card dd { margin: 0; font-size: .84rem; font-weight: 600; }

/* ------------------------------------------------------- connection banner */

.conn-banner {
  position: fixed;
  left: 0; right: 0;
  top: calc(var(--safe-t) + var(--topbar-h));
  z-index: 25;
  padding: 9px 14px;
  background: #3a2f14;
  color: #ffe6b0;
  font-size: .82rem;
  font-weight: 600;
  text-align: center;
  box-shadow: var(--shadow-1);
}

/* ------------------------------------------------------------ setup wizard */

.steps { display: flex; align-items: center; gap: 8px; margin-bottom: 16px; }
.step-pip {
  flex: 1; height: 5px; border-radius: var(--r-pill); background: var(--border);
}
.step-pip.done { background: var(--amber); }
.step-pip.now { background: var(--amber); box-shadow: 0 0 0 3px var(--amber-ring); }
.step-count {
  font-size: .74rem; font-weight: 800; letter-spacing: .06em;
  text-transform: uppercase; color: var(--muted); white-space: nowrap;
}

.wizard-actions {
  display: grid; grid-template-columns: 1fr; gap: 8px;
  margin-top: 18px;
}

/* ----------------------------------------------------- copyable invite link */

.copy-row { display: flex; gap: 8px; align-items: stretch; }
.copy-row input {
  font-size: .82rem; font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  background: var(--surface-2);
}

/* ------------------------------------------------------------- danger zone */

.danger-zone {
  margin-top: 18px; padding: 14px;
  border: 1px solid #f3c9c5; border-radius: var(--r); background: #fffafa;
}
.danger-zone h3 { color: var(--danger); }

/* -------------------------------------------------------- notices & empties */

.notice {
  border-radius: var(--r-sm); padding: 12px 14px; font-size: .88rem;
  border: 1px solid transparent;
}
.notice.info { background: var(--amber-soft); color: #6b4a05; border-color: #f4e0b8; }
.notice.bad { background: var(--danger-soft); color: var(--danger); border-color: #f3c9c5; }
.notice.ok { background: var(--converted-soft); color: var(--converted); border-color: #c2e8d6; }

.empty {
  display: grid; gap: 8px; justify-items: center;
  padding: 34px 18px; text-align: center; color: var(--muted);
  background: var(--surface); border: 1px dashed var(--border-strong); border-radius: var(--r);
}
.empty-mark {
  width: 46px; height: 46px; border-radius: 50%; display: grid; place-items: center;
  background: var(--amber-soft); color: var(--amber-700);
}
.empty-mark svg { width: 24px; height: 24px; }

/* ---------------------------------------------------------------- skeletons */

.skeleton {
  background: linear-gradient(90deg, var(--surface-2) 25%, #eee9e2 37%, var(--surface-2) 63%);
  background-size: 400% 100%;
  animation: shimmer 1.3s ease-in-out infinite;
  border-radius: var(--r-xs);
}
.sk-line { height: 12px; margin-bottom: 8px; }
.sk-line.w-40 { width: 40%; }
.sk-line.w-60 { width: 60%; }
.sk-line.w-80 { width: 80%; }
.sk-btn { height: 38px; width: 120px; border-radius: var(--r-sm); margin-top: 12px; }
@keyframes shimmer { from { background-position: 100% 0; } to { background-position: 0 0; } }

/* ------------------------------------------------------- sheets and toasts */

.scrim {
  position: fixed; inset: 0; z-index: 45;
  background: rgba(23, 22, 26, .5);
  animation: fade .16s ease-out;
}
.sheet {
  position: fixed; z-index: 46;
  left: 0; right: 0; bottom: 0;
  max-height: 78vh;
  display: flex; flex-direction: column;
  background: var(--surface);
  border-radius: var(--r-lg) var(--r-lg) 0 0;
  box-shadow: var(--shadow-3);
  padding-bottom: var(--safe-b);
  animation: rise .2s ease-out;
}
.sheet-grab {
  width: 40px; height: 4px; border-radius: var(--r-pill);
  background: var(--border-strong); margin: 10px auto 2px;
}
.sheet-head {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 16px; border-bottom: 1px solid var(--border);
}
.sheet-body { overflow-y: auto; overscroll-behavior: contain; }

.notif-item {
  display: block; padding: 13px 16px; border-bottom: 1px solid var(--surface-2);
  cursor: pointer; color: inherit;
}
.notif-item:last-child { border-bottom: none; }
.notif-item:hover { background: var(--surface-2); }
.notif-item.unread { background: var(--amber-soft); }
.notif-item .t { font-weight: 700; font-size: .9rem; }
.notif-item .b { color: var(--muted); font-size: .84rem; }

.toast-stack {
  position: fixed; z-index: 60;
  left: 12px; right: 12px;
  bottom: calc(12px + var(--safe-b));
  display: grid; gap: 8px;
}
body.has-tabbar .toast-stack { bottom: calc(var(--tabbar-h) + 12px + var(--safe-b)); }
.toast {
  background: var(--ink); color: var(--on-ink);
  border-left: 4px solid var(--amber);
  border-radius: var(--r-sm); padding: 12px 14px;
  box-shadow: var(--shadow-3); animation: rise .18s ease-out; cursor: pointer;
}
.toast .small, .toast .muted { color: var(--on-ink-muted); }
.toast.ok { border-left-color: var(--wa); }
.toast.bad { border-left-color: #e5484d; }

@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

/* -------------------------------------------------------------- login page */

.auth-wrap {
  min-height: 100dvh;
  display: grid;
  align-content: start;
  gap: 16px;
  padding: calc(24px + var(--safe-t)) 16px calc(24px + var(--safe-b));
  max-width: 440px; margin: 0 auto;
}
.auth-logo {
  display: grid; justify-items: center; gap: 10px; text-align: center;
  padding: 8px 0 4px;
}
.auth-logo img {
  width: 100%; max-width: 260px; height: auto; display: block;
  mix-blend-mode: multiply; /* the source JPEG has a white background */
}

.demo-creds { display: grid; gap: 8px; margin-top: 14px; }
.demo-cred {
  display: flex; align-items: center; gap: 10px; width: 100%;
  min-height: var(--tap); padding: 10px 12px;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--r-sm); cursor: pointer; font: inherit; text-align: left;
}
.demo-cred:hover { border-color: var(--amber); background: var(--amber-soft); }
.demo-cred code { font-size: .78rem; color: var(--muted); }

/* ------------------------------------------------------------ profile page */

.profile-head {
  display: grid; grid-template-columns: auto 1fr; gap: 14px; align-items: center;
}
.avatar {
  width: 58px; height: 58px; border-radius: var(--r); flex: none;
  display: grid; place-items: center;
  background: var(--amber); color: var(--ink);
  font-size: 1.35rem; font-weight: 800; letter-spacing: -.02em;
}
.avatar.lg { width: 72px; height: 72px; font-size: 1.7rem; }

.kv { display: grid; gap: 10px; }
.kv-row {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 0; border-bottom: 1px solid var(--border);
}
.kv-row:last-child { border-bottom: none; }
.kv-row .k { color: var(--muted); font-size: .84rem; }
.kv-row .v { font-weight: 600; margin-left: auto; text-align: right; word-break: break-word; }

.tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tag {
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--r-pill); padding: 5px 11px; font-size: .8rem; font-weight: 600;
}

.meter { height: 8px; border-radius: var(--r-pill); background: var(--surface-2); overflow: hidden; }
.meter span { display: block; height: 100%; background: var(--amber); border-radius: inherit; }

.session-row {
  display: grid; gap: 2px; padding: 11px 0; border-bottom: 1px solid var(--border);
}
.session-row:last-child { border-bottom: none; }

/* -------------------------------------------------------------- responsive */

@media (min-width: 560px) {
  .grid-2 { grid-template-columns: 1fr 1fr; }
  .doc-picker { grid-template-columns: repeat(4, 1fr); }
  .metrics, .stats { grid-template-columns: repeat(4, 1fr); }
  .toast-stack { left: auto; right: 16px; width: min(360px, calc(100vw - 32px)); }
  .wizard-actions { grid-template-columns: auto auto; justify-content: space-between; }
}

@media (min-width: 760px) {
  body { font-size: 15.5px; }
  h1 { font-size: 1.7rem; }
  .page { padding: 22px 20px calc(40px + var(--safe-b)); }
  .card { padding: 18px; }
  .detail-row { grid-template-columns: 170px 1fr; gap: 12px; align-items: baseline; }
  .brand-sub { max-width: none; }
  .row-cards { display: none; }          /* wide screens get the real table */
  .lead-actions { grid-template-columns: auto auto; justify-content: start; }
  .hero { padding: 22px; }
  .hero-value { font-size: 2.8rem; }
  .auth-wrap { max-width: 460px; padding-top: 40px; }

  /* the tab bar is a phone pattern; on desktop the topbar links are enough */
  .tabbar { display: none; }
  body.has-tabbar .page { padding-bottom: calc(40px + var(--safe-b)); }
  body.has-tabbar .toast-stack { bottom: 16px; }
}

@media (max-width: 759px) {
  .table-wrap { display: none; }         /* phones get .row-cards instead */
  .desktop-only { display: none !important; }
}

@media (min-width: 760px) {
  .mobile-only { display: none !important; }
}

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

@media print {
  .topbar, .tabbar, .sticky-cta, .toast-stack { display: none !important; }
}
