/* ==========================================================================
   Booklio — one stylesheet, three layers: base (desktop) → tablet → phone.
   Breakpoints: 1100px (drawer navigation, single-column layouts),
                600px (phone spacing), 360px (narrow phones).
   Scroll contract: the DOCUMENT is the only vertical scroll owner. Do not add
   overflow, fixed heights, transforms, filters or touch-action to app
   ancestors. Only open overlays and the calendar strip scroll locally.
   ========================================================================== */

/* -------- 1. Fonts & tokens -------- */
@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("assets/fonts/inter-latin-wght-normal.woff2") format("woff2");
  unicode-range:
    U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC,
    U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212,
    U+2215, U+FEFF, U+FFFD;
}
/* Metric-matched fallback so the swap to Inter does not shift layout. */
@font-face {
  font-family: "Inter Fallback";
  src: local("Arial");
  size-adjust: 107.4%;
  ascent-override: 90.2%;
  descent-override: 22.5%;
  line-gap-override: 0%;
}
:root {
  --ink: #101312;
  --ink-soft: #414641;
  --paper: #f4f3ef;
  --surface: #fffefa;
  --app-bg: #eef0eb;
  --muted: #5f6460;
  --line: #d9dbd6;
  --line-soft: #e4e7e1;
  --accent: #6675f7;
  --accent-strong: #5261d9;
  --accent-tint: #eef0ff;
  --accent-line: #c9cffc;
  --danger: #d75d4a;
  --danger-ink: #a23d2e;
  --danger-tint: #fde7e3;
  --warn-ink: #8a5b16;
  --warn-tint: #fff1d9;
  --ok-ink: #27693e;
  --ok-tint: #e7f4ea;
  --r: 18px;
  --shadow: 0 18px 60px rgba(16, 19, 18, 0.09);
  --font:
    "Inter", "Inter Fallback", ui-sans-serif, system-ui, -apple-system,
    BlinkMacSystemFont, "Segoe UI", sans-serif;
}

/* -------- 2. Base -------- */
* {
  box-sizing: border-box;
}
html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}
body {
  margin: 0;
  font-family: var(--font);
  font-size: 16px;
  background: var(--paper);
  color: var(--ink);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}
button {
  cursor: pointer;
}
a {
  color: inherit;
  text-decoration: none;
}
img,
svg {
  max-width: 100%;
}
h1,
h2,
h3 {
  text-wrap: balance;
}
p {
  text-wrap: pretty;
}
:focus-visible {
  outline: 3px solid var(--accent-strong);
  outline-offset: 3px;
}
/* The page heading receives programmatic focus after navigation; it is not a control. */
[tabindex="-1"]:focus {
  outline: none;
}
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}
.wrap {
  width: min(1180px, calc(100% - 32px));
  margin: auto;
}
.sub {
  font-size: 13px;
  color: var(--muted);
}
.kpi b,
.price,
.rcard-value b,
.match .score {
  font-variant-numeric: tabular-nums;
}

/* -------- 3. Shared components -------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 10px 18px;
  border: 1px solid var(--ink);
  background: transparent;
  color: var(--ink);
  border-radius: 999px;
  font-weight: 650;
  font-size: 15px;
  line-height: 1.2;
  text-align: center;
}
.btn.primary {
  background: var(--ink);
  color: #fff;
}
.btn.accent {
  background: var(--accent-strong);
  color: #fff;
  border-color: var(--accent-strong);
}
.btn.ghost {
  border-color: var(--line);
  background: #fff;
}
.btn.tiny {
  padding: 6px 12px;
  font-size: 13px;
  border-color: var(--line);
  background: #fff;
}
.btn.danger {
  color: var(--danger-ink);
  border-color: #efc9c2;
}
.btn.solid-danger {
  background: var(--danger-ink);
  color: #fff;
  border-color: var(--danger-ink);
}
.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
.eyebrow {
  display: inline-flex;
  border: 1px solid #cfd2cb;
  border-radius: 999px;
  padding: 6px 11px;
  font-size: 11.5px;
  font-weight: 750;
  letter-spacing: 0.1em;
  max-width: 100%;
}
.pill {
  display: inline-block;
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 11px;
  font-weight: 750;
  background: #272c29;
}
.pill.accent {
  background: #202447;
  color: #aeb7ff;
}
.status {
  display: inline-block;
  padding: 4px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  line-height: 1.4;
  background: #edf0eb;
  color: var(--ink-soft);
  white-space: nowrap;
}
.status.cancelled {
  background: var(--danger-tint);
  color: var(--danger-ink);
}
.status.confirmed {
  background: var(--ok-tint);
  color: var(--ok-ink);
}
.status.recovered,
.status.matched {
  background: #eceeff;
  color: #4652c4;
}
.status.matching {
  background: #f0f1ff;
  color: #4b5390;
}
.status.waiting,
.status.offered,
.status.offer-sent {
  background: var(--warn-tint);
  color: var(--warn-ink);
}
.status.open {
  background: #e7f0ff;
  color: #315c9a;
}
.status.expired {
  background: #eceeeb;
  color: #5c605d;
}
.chips {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin: 28px 0 0;
  padding: 0;
  list-style: none;
}
.chip {
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  font-weight: 600;
  font-size: 13px;
}
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 24px;
}
.card .num {
  font-size: 12px;
  font-weight: 800;
  color: var(--muted);
  letter-spacing: 0.04em;
}
.card h3 {
  font-size: 20px;
  margin: 20px 0 8px;
}
.grid3,
.grid4 {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  margin-top: 34px;
}
.grid4 {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}
.grid3 > *,
.grid4 > * {
  min-width: 0;
}
.notice {
  background: #f1f2ff;
  border: 1px solid #d9dcff;
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 13px;
  color: #454c85;
  margin: 14px 0;
}
.empty {
  display: grid;
  gap: 4px;
  padding: 24px;
  border: 1px dashed var(--line);
  border-radius: 14px;
  color: var(--muted);
  text-align: center;
  font-size: 14px;
}
.empty b {
  color: var(--ink);
}
.compact-empty {
  padding: 20px;
}
.compact-empty .btn {
  justify-self: center;
  margin-top: 8px;
}

/* -------- 4. Marketing site -------- */
.nav {
  position: relative;
  z-index: 30;
  background: var(--paper);
  border-bottom: 1px solid rgba(16, 19, 18, 0.08);
}
.navin {
  height: 72px;
  display: flex;
  align-items: center;
  gap: 28px;
}
.brand {
  display: flex;
  align-items: center;
  font-weight: 800;
  font-size: 22px;
}
.brand img {
  width: 118px;
  height: auto;
}
.links {
  display: flex;
  gap: 26px;
  margin-left: auto;
  color: var(--ink-soft);
  font-size: 14px;
  font-weight: 500;
}
.actions {
  display: flex;
  gap: 10px;
}
.skip-link {
  position: absolute;
  left: 12px;
  top: -64px;
  z-index: 200;
  background: var(--ink);
  color: #fff;
  padding: 10px 16px;
  border-radius: 10px;
  font-weight: 650;
}
.skip-link:focus {
  top: 12px;
}
.hero {
  padding: 84px 0 64px;
}
.hero-grid {
  display: grid;
  grid-template-columns: 1.05fr 0.95fr;
  gap: 56px;
  align-items: center;
}
.hero h1 {
  font-size: clamp(44px, 5.6vw, 78px);
  line-height: 0.98;
  letter-spacing: -0.05em;
  margin: 22px 0;
}
.hero p {
  font-size: 19px;
  color: #4f5651;
  max-width: 34em;
  margin: 0;
}
.hero-actions {
  display: flex;
  gap: 12px;
  margin-top: 30px;
  flex-wrap: wrap;
}
.micro,
.hero .micro {
  font-size: 12.5px;
  color: var(--muted);
  margin: 14px 0 0;
  max-width: none;
}
.product-shot {
  background: var(--ink);
  color: #fff;
  border-radius: 30px;
  padding: 22px;
  box-shadow: 0 12px 32px rgba(16, 19, 18, 0.12);
}
.shot-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 20px;
}
.flow-card {
  background: #1a1e1c;
  border: 1px solid #303633;
  border-radius: 20px;
  padding: 18px;
  margin-top: 12px;
}
.flow-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 16px;
  align-items: center;
}
.flow-card strong {
  display: block;
}
.product-shot .sub,
.dark .sub {
  color: #b7bfb9;
}
.match {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 11px 0;
  border-top: 1px solid var(--line-soft);
}
.product-shot .match {
  border-color: #303633;
}
.score {
  color: var(--accent-strong);
  font-size: 12px;
  font-weight: 750;
  letter-spacing: 0.02em;
  flex-shrink: 0;
}
.product-shot .score {
  color: #b5bdff;
}
.shot-recovered {
  background: #e9ebff;
  color: #151a44;
  border: 1px solid #cdd2ff;
  border-radius: 18px;
  padding: 18px;
  margin-top: 12px;
}
.shot-recovered .sub {
  color: #454c85;
}
.shot-recovered strong {
  display: block;
  font-size: 20px;
  line-height: 1.3;
}
.who {
  padding: 26px 0;
  border-top: 1px solid var(--line-soft);
  border-bottom: 1px solid var(--line-soft);
}
.who-in {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px 24px;
}
.who .eyebrow,
.who .chips {
  margin: 0;
}
.section {
  padding: 84px 0;
}
.section h2 {
  font-size: clamp(34px, 4.2vw, 56px);
  line-height: 1.02;
  letter-spacing: -0.045em;
  margin: 0 0 18px;
}
.section h2.spaced {
  margin-top: 18px;
}
.lead {
  font-size: 18px;
  color: #565c57;
  max-width: 700px;
}
.dark {
  background: var(--ink);
  color: #fff;
}
.dark .lead {
  color: #abb2ac;
}
.dark .card {
  background: #181c1a;
  border-color: #303532;
}
.dark .card .num {
  color: #98a19b;
}
.dark .eyebrow {
  border-color: #3a403c;
}
.price {
  font-size: 48px;
  font-weight: 800;
  letter-spacing: -0.05em;
  line-height: 1.1;
}
.price small {
  font-size: 14px;
  font-weight: 500;
  letter-spacing: 0;
  color: var(--muted);
}
.featured {
  outline: 2px solid var(--accent);
  position: relative;
}
.featured::before {
  content: "Featured";
  position: absolute;
  right: 16px;
  top: 16px;
  background: var(--accent-strong);
  color: #fff;
  padding: 4px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 750;
}
.faq {
  border-top: 1px solid var(--line);
  margin-top: 28px;
}
details {
  border-bottom: 1px solid var(--line);
  padding: 18px 0;
}
summary {
  font-weight: 700;
  cursor: pointer;
  min-height: 24px;
}
details p {
  color: #565c57;
  max-width: 62ch;
  margin: 10px 0 0;
}

/* -------- 5. Signature footer: an open slot becomes a recovered slot --------
   The decorative field of appointment blocks is inline SVG, aria-hidden and
   non-interactive. It is sized by width (height: auto), so it can never add
   horizontal overflow, and it contributes no scroll behavior. */
.site-footer {
  background: var(--surface);
  border-top: 1px solid var(--line);
}
.footer-cta {
  padding: 92px 0 56px;
  max-width: 760px;
}
.footer-cta h2 {
  font-size: clamp(34px, 4.6vw, 60px);
  line-height: 1.02;
  letter-spacing: -0.05em;
  margin: 0 0 16px;
}
.footer-cta p {
  color: #565c57;
  font-size: 18px;
  margin: 0 0 28px;
  max-width: 34em;
}
.footer-main {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(0, 2fr);
  gap: 40px;
  padding: 40px 0 30px;
  border-top: 1px solid var(--line-soft);
}
.footer-brand p {
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 14px;
  max-width: 30em;
}
.footer-nav {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 24px;
}
.footer-nav div {
  display: grid;
  align-content: start;
  gap: 2px;
}
.footer-nav b {
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 6px;
}
.footer-nav a {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  font-size: 14.5px;
  color: var(--ink-soft);
  width: fit-content;
}
.footer-fine {
  margin: 0;
  padding: 0 0 36px;
  color: var(--muted);
  font-size: 12.5px;
  max-width: 62ch;
}
.slots {
  display: block;
  line-height: 0;
  pointer-events: none;
  user-select: none;
  -webkit-user-select: none;
}
.slots svg {
  display: block;
  width: 100%;
  height: auto;
}
.slots .slots-narrow {
  display: none;
}
.footer--compact .footer-main {
  border-top: 0;
}
.footer--compact .footer-fine {
  padding-bottom: 44px;
}

/* -------- 6. Demo entry, legal and 404 pages -------- */
.auth {
  min-height: 100vh;
  min-height: 100svh;
  display: grid;
  place-items: center;
  background: var(--paper);
  padding: 20px;
}
.authbox {
  width: min(460px, 100%);
  background: #fff;
  padding: 32px;
  border-radius: 24px;
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}
.authbox .brand {
  margin-bottom: 26px;
}
.authbox h1 {
  font-size: 30px;
  line-height: 1.1;
  letter-spacing: -0.035em;
  margin: 0 0 10px;
}
.authbox .lead {
  font-size: 15.5px;
  margin: 0;
}
.entry-list {
  list-style: none;
  margin: 22px 0 24px;
  padding: 0;
  display: grid;
  gap: 12px;
}
.entry-list li {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr);
  gap: 12px;
  align-items: start;
  font-size: 14.5px;
  color: var(--ink-soft);
}
.entry-list i {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 9px;
  background: var(--accent-tint);
  color: #4652c4;
  font-style: normal;
  font-size: 12px;
  font-weight: 800;
}
.entry-list b {
  color: var(--ink);
  font-weight: 650;
}
.authbox .btn {
  width: 100%;
}
.eyebrow + h1 {
  margin-top: 18px;
}
.authbox .lead + .btn {
  margin-top: 22px;
}
.entry-back {
  display: block;
  text-align: center;
  margin-top: 6px;
  padding: 12px;
  font-size: 14px;
  color: var(--muted);
}
.legal {
  padding: 56px 0 72px;
}
.legal h1 {
  font-size: clamp(34px, 5vw, 52px);
  line-height: 1.05;
  letter-spacing: -0.045em;
  margin: 20px 0 16px;
}
.legal .card h2 {
  font-size: 20px;
  margin: 0 0 8px;
}
.legal .card h2:not(:first-child) {
  margin-top: 22px;
}
.legal .card p {
  margin: 0;
  color: #565c57;
}

/* -------- 7. App shell -------- */
.appbody {
  background: var(--app-bg);
}
.app {
  display: grid;
  grid-template-columns: 250px minmax(0, 1fr);
  align-items: stretch;
}
.sidebar {
  background: var(--ink);
  color: #fff;
}
/* Desktop only: the navigation stays in view while long pages scroll. */
.sidebar-inner {
  position: sticky;
  top: 0;
  max-height: 100vh;
  max-height: 100dvh;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 24px 18px;
}
.sidebar .brand img {
  filter: invert(1);
  width: 120px;
}
.demo-badge {
  display: inline-block;
  margin: 18px 0;
  background: #24263a;
  color: #aeb7ff;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 750;
  letter-spacing: 0.04em;
}
.drawer-brand {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.side-nav {
  display: grid;
  gap: 4px;
}
.side-nav button {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 44px;
  border: 0;
  background: transparent;
  color: #c9cfca;
  text-align: left;
  padding: 10px 13px;
  border-radius: 10px;
  font-size: 15px;
  font-weight: 500;
}
.side-nav svg {
  width: 18px;
  height: 18px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: 0.85;
}
.side-nav button.active {
  background: #222825;
  color: #fff;
}
.side-nav button.active svg {
  color: #aeb7ff;
  opacity: 1;
}
.sidebar :focus-visible {
  outline-color: #aeb7ff;
}
.sidebar-reset {
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid #333936;
}
.sidebar-reset .btn {
  color: #e5e7e5;
  border-color: #59615b;
  background: transparent;
  width: 100%;
}
.drawer-close {
  display: none;
  border: 0;
  background: transparent;
  color: #fff;
  font-size: 26px;
  min-width: 44px;
  min-height: 44px;
  flex-shrink: 0;
}
.menu-scrim,
.mobile-topbar,
.back-nav {
  display: none;
}
.appmain {
  padding: 34px 36px 48px;
  max-width: 1400px;
  width: 100%;
  margin: 0 auto;
  min-width: 0;
  overflow-wrap: anywhere;
  overflow: visible;
}
.topbar {
  margin-bottom: 26px;
}
.topbar h1 {
  margin: 0;
  font-size: 30px;
  line-height: 1.15;
  letter-spacing: -0.035em;
}
.topbar .sub {
  display: block;
  margin-top: 6px;
}
.view {
  display: none;
}
.view.active {
  display: block;
}

/* -------- 8. App components -------- */
.kpis {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1px;
  background: #dfe2dc;
  border: 1px solid #dfe2dc;
  border-radius: var(--r);
  overflow: clip;
}
.kpi {
  background: #fff;
  padding: 20px 22px;
  min-width: 0;
}
.kpi span {
  display: block;
  font-size: 12.5px;
  line-height: 1.35;
  color: var(--muted);
  font-weight: 600;
}
.kpi b {
  display: block;
  font-size: 30px;
  line-height: 1.15;
  letter-spacing: -0.03em;
  margin-top: 8px;
  overflow-wrap: anywhere;
}
.kpi.key b {
  color: var(--accent-strong);
}
.kpis + .panel-grid,
.panel-grid + .panel {
  margin-top: 16px;
}
.panel-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(0, 0.75fr);
  gap: 16px;
  margin-top: 16px;
}
.panel {
  background: #fff;
  border: 1px solid #dfe2dc;
  border-radius: var(--r);
  padding: 22px;
  min-width: 0;
}
.panel + .panel {
  margin-top: 16px;
}
.panel-grid .panel + .panel {
  margin-top: 0;
}
.panel h2 {
  font-size: 17px;
  line-height: 1.3;
  margin: 0 0 16px;
}
.toolbar {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  margin-bottom: 16px;
}
.toolbar > div {
  min-width: 0;
}
.toolbar h2 {
  margin: 0;
}
.toolbar .sub {
  display: block;
  margin-top: 4px;
}
.grid3.flush {
  margin-top: 0;
}
.modal-meta {
  margin: 0;
  font-size: 14.5px;
  color: var(--ink-soft);
}
.modal-meta b {
  color: var(--ink);
}
.lead-in {
  color: var(--ink-soft);
  font-size: 16px;
  max-width: 46em;
  margin: 0 0 20px;
}

/* Recovery card: cancelled slot → matched waitlist → offer → recovered value.
   Rendered from real state only (see recoveryCard() in app.js). */
.rcard {
  background: #fff;
  border: 1px solid #dfe2dc;
  border-radius: var(--r);
  padding: 22px;
  min-width: 0;
}
.rcard + .rcard {
  margin-top: 14px;
}
.rcard[data-status="open"],
.rcard[data-status="offer-sent"] {
  border-color: var(--accent-line);
  background: #fcfcff;
}
.rcard-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
}
.rcard-head > div {
  min-width: 0;
}
.rcard-when {
  display: block;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}
.rcard-title {
  font-size: 20px;
  line-height: 1.25;
  letter-spacing: -0.02em;
  margin: 4px 0 2px;
}
.rcard-sub {
  margin: 0;
  font-size: 14px;
  color: var(--muted);
}
.rcard-value {
  display: grid;
  justify-items: end;
  gap: 2px;
  text-align: right;
  flex-shrink: 0;
}
.rcard-value b {
  font-size: 24px;
  line-height: 1.1;
  letter-spacing: -0.03em;
}
.rcard-value small {
  font-size: 12px;
  color: var(--muted);
}
.rcard-value .status {
  margin-top: 8px;
}
.rflow {
  list-style: none;
  margin: 22px 0 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
}
.rstep {
  position: relative;
  min-width: 0;
  padding: 24px 12px 0 0;
}
.rstep::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #fff;
  border: 2px solid #c3c7c0;
}
.rstep::after {
  content: "";
  position: absolute;
  top: 6px;
  left: 20px;
  right: 6px;
  height: 2px;
  border-radius: 2px;
  background: var(--line);
}
.rstep:last-child::after {
  display: none;
}
.rstep.is-done::before {
  background: var(--ink);
  border-color: var(--ink);
}
.rstep.is-done::after {
  background: var(--ink);
}
.rstep.is-current::before {
  background: var(--accent-strong);
  border-color: var(--accent-strong);
  box-shadow: 0 0 0 4px rgba(82, 97, 217, 0.18);
}
.rstep.is-done:last-child::before {
  background: var(--accent-strong);
  border-color: var(--accent-strong);
}
.rstep-name {
  display: block;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.3;
}
.rstep-meta {
  display: block;
  margin-top: 2px;
  font-size: 12.5px;
  line-height: 1.35;
  color: var(--muted);
  overflow-wrap: anywhere;
}
.rstep:not(.is-done):not(.is-current) .rstep-name {
  color: var(--muted);
  font-weight: 600;
}
.rcard-foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px 16px;
  margin-top: 20px;
  padding-top: 18px;
  border-top: 1px solid var(--line-soft);
}
.rcard-foot p {
  margin: 0;
  font-size: 14px;
  color: var(--ink-soft);
  min-width: 0;
}
.rcard-foot p b {
  font-weight: 650;
}
.rcard--compact {
  padding: 18px;
}
.rcard--compact .rcard-title {
  font-size: 18px;
}
.rcard--compact .rflow {
  margin-top: 18px;
}
.rcard--compact .rstep-meta {
  display: none;
}
.rcard--compact .rcard-foot {
  margin-top: 16px;
  padding-top: 16px;
}

/* Tables (desktop) — become labelled cards at ≤1100px */
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
  table-layout: fixed;
}
.table th {
  text-align: left;
  padding: 10px 8px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--muted);
  border-bottom: 1px solid var(--line);
}
.table td {
  text-align: left;
  padding: 14px 8px;
  border-bottom: 1px solid var(--line-soft);
  overflow-wrap: anywhere;
  vertical-align: top;
}
.table tbody tr:last-child td {
  border-bottom: 0;
}
.table td[data-a="title"] {
  font-weight: 650;
}
.table td[colspan] {
  padding: 8px 0;
}
.table .row-actions {
  margin-top: 0;
}
.row-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 14px;
}
.field label,
.field .field-label {
  font-size: 13px;
  font-weight: 700;
}
.field {
  display: grid;
  gap: 6px;
  margin-bottom: 12px;
  min-width: 0;
}
.field .opt {
  font-weight: 500;
  color: var(--muted);
}
.field input,
.field select,
.field textarea,
.toolbar input,
.toolbar select {
  border: 1px solid #d5d9d2;
  border-radius: 10px;
  padding: 10px 12px;
  background: #fff;
  width: 100%;
  min-width: 0;
  min-height: 44px;
  font-size: 16px;
}
.field input:focus,
.field select:focus {
  border-color: var(--accent-strong);
  outline: 2px solid rgba(82, 97, 217, 0.25);
  outline-offset: 0;
}
.time-pair {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}
.days {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
  margin: 0 0 16px;
  min-width: 0;
}
.days legend {
  font-size: 13px;
  font-weight: 700;
  padding: 0 4px;
}
.days label {
  display: inline-flex;
  gap: 6px;
  margin: 2px 14px 2px 0;
  font-size: 14px;
  min-height: 44px;
  align-items: center;
}
.days input {
  width: 18px;
  height: 18px;
  accent-color: var(--accent-strong);
}
#settingsForm {
  max-width: 920px;
}
#settingsForm .grid3 {
  margin-top: 8px;
}

/* Services */
.service-card .row-actions {
  margin-top: 18px;
}
.service-card p {
  margin: 0 0 4px;
}

/* Calendar — the only component allowed to scroll (horizontally, in place) */
.calendar-scroll {
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  overflow-y: visible;
  border: 1px solid var(--line);
  border-radius: 14px;
}
.calendar {
  display: grid;
  grid-template-columns: 64px repeat(7, minmax(0, 1fr));
  width: 100%;
  min-width: 900px;
}
.calcell {
  min-height: 76px;
  border-right: 1px solid var(--line-soft);
  border-bottom: 1px solid var(--line-soft);
  padding: 7px;
  font-size: 12px;
  background: #fff;
  min-width: 0;
}
.calhead {
  font-weight: 700;
  background: #f4f5f1;
  min-height: 0;
  color: var(--ink-soft);
}
.calhead.is-today {
  background: var(--accent-tint);
  color: #3f4bb8;
}
.event {
  display: block;
  background: var(--accent-tint);
  border: 0;
  border-left: 3px solid var(--accent);
  padding: 6px 8px;
  border-radius: 8px;
  margin-top: 3px;
  width: 100%;
  text-align: left;
  color: var(--ink);
  min-height: 44px;
  font-size: 12px;
}
.event.cancel {
  background: var(--danger-tint);
  border-left-color: var(--danger);
}
.event small {
  display: block;
  opacity: 0.75;
  margin-top: 2px;
}

/* Analytics */
.chart-row {
  margin: 18px 0;
}
.chart-row .flow-row {
  font-size: 14px;
  margin-bottom: 8px;
}
.bar {
  height: 10px;
  background: #eceee9;
  border-radius: 999px;
  overflow: hidden;
}
.bar i {
  display: block;
  height: 100%;
  background: var(--accent);
  border-radius: 999px;
}
.panel .match:first-of-type {
  border-top: 0;
}
.activity-item {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 0;
  border-top: 1px solid var(--line-soft);
}
.activity-item:first-child {
  border-top: 0;
  padding-top: 0;
}
.activity-item .score {
  font-size: 14px;
}

/* Recovery filters */
.recovery-tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin: 22px 0 16px;
}
.recovery-tabs .chip {
  min-height: 44px;
  font-size: 14px;
  background: #fff;
}
.recovery-tabs .chip.active {
  background: var(--ink);
  color: #fff;
  border-color: var(--ink);
}

/* Overlays */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(16, 19, 18, 0.5);
  display: none;
  grid-template-rows: minmax(0, 1fr);
  grid-template-columns: minmax(0, 1fr);
  place-items: center;
  z-index: 100;
  padding: max(12px, env(safe-area-inset-top)) 12px
    max(12px, env(safe-area-inset-bottom));
}
.modal.open {
  display: grid;
}
.modalbox {
  background: #fff;
  border-radius: 22px;
  padding: 24px;
  width: min(560px, 100%);
  max-height: 100%;
  overflow: auto;
  overscroll-behavior: contain;
  overflow-wrap: anywhere;
}
.confirmbox {
  width: min(460px, 100%);
}
.modalhead {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 6px;
}
.modalhead h2 {
  margin: 4px 0 8px;
  font-size: 22px;
  line-height: 1.2;
  letter-spacing: -0.025em;
}
.modalbox h3 {
  font-size: 14px;
  margin: 18px 0 8px;
}
.modalbox .grid3 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-top: 8px;
  gap: 0 12px;
}
.close {
  border: 0;
  background: transparent;
  font-size: 26px;
  line-height: 1;
  min-width: 44px;
  min-height: 44px;
  flex-shrink: 0;
  margin: -8px -10px 0 0;
  border-radius: 12px;
}
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 18px;
}
.modalbox > .btn,
.modalbox > form > .btn {
  margin-top: 6px;
}
.success-panel {
  background: #f0f1ff;
  border: 1px solid #d9dcff;
  border-radius: 16px;
  padding: 18px;
}
.success-panel h3 {
  font-size: 18px;
  margin: 12px 0 6px;
}
.success-panel p {
  margin: 0;
  color: var(--ink-soft);
  font-size: 14.5px;
}
.selectable {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  cursor: pointer;
  border: 1px solid var(--line);
  padding: 14px;
  border-radius: 14px;
  margin-top: 8px;
}
.selectable:first-child {
  margin-top: 0;
}
.selectable:has(input:checked) {
  border-color: #8f99ff;
  background: #f6f7ff;
}
.selectable input {
  accent-color: var(--accent-strong);
  width: 20px;
  height: 20px;
  margin: 2px 0 0;
  flex-shrink: 0;
}
.match-main {
  min-width: 0;
  flex: 1;
}
.match-main b {
  display: block;
}
.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 6px;
  margin-top: 6px;
}
.tag {
  font-size: 12px;
  line-height: 1.3;
  padding: 2px 8px;
  border-radius: 999px;
  background: #eceeff;
  color: #4652c4;
  font-weight: 600;
}
.match-note {
  display: block;
  margin-top: 6px;
  font-size: 12.5px;
  color: var(--warn-ink);
}
.toast {
  position: fixed;
  right: 24px;
  bottom: max(20px, env(safe-area-inset-bottom));
  background: var(--ink);
  color: #fff;
  padding: 13px 18px;
  border-radius: 12px;
  font-size: 14px;
  display: none;
  z-index: 120;
  max-width: min(420px, calc(100% - 24px));
  box-shadow: 0 10px 30px rgba(16, 19, 18, 0.25);
}
.toast.show {
  display: block;
}
body.overlay-open {
  overflow: hidden;
}
.app[inert] {
  pointer-events: none;
}

/* -------- 9a. Tablet & phone navigation and layout (≤1100px) -------- */
@media (max-width: 1100px) {
  .hero-grid,
  .panel-grid {
    grid-template-columns: minmax(0, 1fr);
  }
  .grid3 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .grid4 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .links {
    display: none;
  }
  .navin .actions {
    margin-left: auto;
  }
  .footer-main {
    grid-template-columns: minmax(0, 1fr);
  }
  .app {
    display: block;
  }
  .appmain {
    padding: 26px 24px 40px;
  }
  /* Normal-flow header. Deliberately NOT sticky: the document scrolls it away
     naturally, so there is no fixed/sticky surface for iOS browser chrome to fight. */
  .mobile-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 60px;
    padding: 0 20px;
    background: var(--surface);
    border-bottom: 1px solid var(--line);
  }
  .mobile-topbar .brand img {
    width: 112px;
  }
  .menu-icon {
    display: grid;
    place-items: center;
    width: 44px;
    height: 44px;
    padding: 10px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: #fff;
  }
  .menu-icon svg,
  .back-nav svg {
    width: 22px;
    height: 22px;
  }
  .sidebar {
    display: none;
  }
  .sidebar-inner {
    position: static;
    max-height: none;
    overflow: visible;
  }
  body.menu-open .sidebar {
    display: block;
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    width: min(320px, 88%);
    overflow-y: auto;
    overscroll-behavior: contain;
    z-index: 90;
    padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom);
  }
  .drawer-close {
    display: block;
  }
  body.menu-open .menu-scrim {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(16, 19, 18, 0.5);
    z-index: 85;
  }
  /* Appears only once the header has scrolled out of view (IntersectionObserver in app.js). */
  .back-nav {
    display: grid;
    place-items: center;
    position: fixed;
    right: 16px;
    bottom: 16px;
    width: 44px;
    height: 44px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: #fff;
    color: var(--ink);
    z-index: 40;
    box-shadow: 0 2px 10px rgba(16, 19, 18, 0.12);
  }
  .back-nav[hidden] {
    display: none;
  }
  .btn.tiny {
    min-height: 44px;
    padding: 9px 14px;
  }
  /* Tables become cards: one hierarchy per table, defined by data-a areas. */
  .table,
  .table tbody {
    display: block;
    width: 100%;
  }
  .table thead {
    display: none;
  }
  .table tbody {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr));
    gap: 12px;
  }
  .table tr {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-content: start;
    gap: 4px 12px;
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 14px 16px;
    background: #fff;
  }
  .table td {
    display: block;
    padding: 0;
    border: 0;
    min-width: 0;
    font-size: 14px;
    color: var(--ink-soft);
  }
  .table td[data-a="title"] {
    grid-area: title;
    font-size: 16px;
    color: var(--ink);
  }
  .table td[data-a="status"] {
    grid-area: status;
    justify-self: end;
  }
  .table td[data-a="time"] {
    grid-area: time;
    font-weight: 650;
    color: var(--ink);
  }
  .table td[data-a="a"] {
    grid-area: a;
  }
  .table td[data-a="b"] {
    grid-area: b;
  }
  .table td[data-a="c"] {
    grid-area: c;
  }
  .table td[data-a="actions"] {
    grid-area: actions;
    margin-top: 10px;
    padding-top: 12px;
    border-top: 1px solid var(--line-soft);
  }
  .table td[data-a="b"] {
    justify-self: end;
    font-weight: 650;
    color: var(--ink);
  }
  .table td[data-label-show]::before {
    content: attr(data-label) " · ";
    color: var(--muted);
  }
  .table td[colspan] {
    grid-column: 1 / -1;
  }
  .table[data-layout="appointments"] tr {
    grid-template-areas:
      "title status"
      "a b"
      "c c"
      "actions actions";
  }
  .table[data-layout="waitlist"] tr {
    grid-template-areas:
      "title status"
      "a a"
      "c c"
      "actions actions";
  }
  .table[data-layout="customers"] tr {
    grid-template-areas:
      "title title"
      "a a"
      "b b"
      "c c"
      "actions actions";
  }
  .table[data-layout="customers"] td[data-a="b"] {
    justify-self: start;
    font-weight: 400;
    color: var(--ink-soft);
  }
  .table[data-layout="today"] tr {
    grid-template-areas:
      "time status"
      "title title"
      "a a";
  }
  .row-actions {
    margin-top: 0;
  }
}

/* -------- 9b. Phones (≤600px) -------- */
@media (max-width: 600px) {
  .wrap {
    width: calc(100% - 32px);
  }
  .navin {
    height: 60px;
    gap: 12px;
  }
  .brand img {
    width: 105px;
  }
  .actions .btn.ghost {
    display: none;
  }
  .navin .actions .btn {
    padding: 9px 16px;
    font-size: 14px;
  }
  .hero {
    padding: 36px 0 44px;
  }
  .hero-grid {
    gap: 30px;
  }
  .hero h1 {
    font-size: clamp(38px, 11.4vw, 48px);
    line-height: 1.03;
    margin: 18px 0;
  }
  .hero p,
  .lead {
    font-size: 16.5px;
  }
  .eyebrow {
    font-size: 10.5px;
    letter-spacing: 0.06em;
  }
  .hero-actions {
    gap: 10px;
    margin-top: 24px;
  }
  .hero-actions .btn {
    width: 100%;
  }
  .product-shot {
    padding: 16px;
    border-radius: 24px;
  }
  .flow-card {
    padding: 14px;
  }
  .section {
    padding: 52px 0;
  }
  .section h2 {
    font-size: 33px;
    line-height: 1.08;
  }
  .grid3,
  .grid4 {
    grid-template-columns: minmax(0, 1fr);
    gap: 12px;
    margin-top: 24px;
  }
  .card {
    padding: 20px;
  }
  .card h3 {
    margin-top: 14px;
  }
  .price {
    font-size: 42px;
  }
  .footer-cta {
    padding: 60px 0 36px;
  }
  .footer-cta h2 {
    font-size: 34px;
  }
  .footer-cta p {
    font-size: 16.5px;
  }
  .footer-cta .btn {
    width: 100%;
  }
  .footer-main {
    padding: 32px 0 24px;
    gap: 28px;
  }
  .footer-nav {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 18px 16px;
  }
  .footer-nav div:first-child {
    grid-row: span 2;
  }
  .footer-fine {
    padding-bottom: 32px;
  }
  .slots .slots-wide {
    display: none;
  }
  .slots .slots-narrow {
    display: block;
  }
  .appmain {
    padding: 22px 16px 36px;
  }
  .topbar {
    margin-bottom: 20px;
  }
  .topbar h1 {
    font-size: 27px;
  }
  .kpis {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .kpi {
    padding: 16px;
  }
  .kpi b {
    font-size: 25px;
  }
  .kpi span {
    font-size: 12px;
  }
  .panel {
    padding: 16px;
  }
  .panel-grid {
    gap: 16px;
  }
  .toolbar {
    align-items: stretch;
    flex-direction: column;
  }
  .toolbar .btn {
    align-self: flex-start;
  }
  .rcard {
    padding: 18px 16px;
  }
  .rcard-head {
    flex-wrap: wrap;
  }
  .rcard-value {
    justify-items: start;
    text-align: left;
    order: 2;
    flex-basis: 100%;
    grid-auto-flow: column;
    align-items: baseline;
    justify-content: start;
    gap: 8px;
  }
  .rcard-value .status {
    margin: 0 0 0 auto;
  }
  .rflow {
    grid-template-columns: minmax(0, 1fr);
  }
  .rstep {
    padding: 0 0 16px 30px;
  }
  .rstep:last-child {
    padding-bottom: 0;
  }
  .rstep::before {
    top: 2px;
  }
  .rstep::after {
    top: 20px;
    bottom: -2px;
    left: 6px;
    right: auto;
    width: 2px;
    height: auto;
  }
  .rcard--compact .rstep-meta {
    display: block;
  }
  .rcard-foot .btn {
    width: 100%;
  }
  .row-actions {
    gap: 8px;
  }
  .row-actions .btn {
    flex: 1 1 auto;
  }
  .modalbox {
    padding: 20px 18px;
    border-radius: 20px;
  }
  .modalbox .grid3 {
    grid-template-columns: minmax(0, 1fr);
  }
  .modal-actions {
    flex-direction: column-reverse;
  }
  .modal-actions .btn,
  .modalbox > .btn,
  .modalbox > form > .btn {
    width: 100%;
  }
  .toast {
    left: 12px;
    right: 12px;
    text-align: center;
    max-width: none;
  }
  .authbox {
    padding: 24px 20px;
  }
  .legal {
    padding: 36px 0 52px;
  }
}

/* -------- 9c. Narrow phones (≤360px) -------- */
@media (max-width: 360px) {
  .kpi {
    padding: 13px;
  }
  .kpi b {
    font-size: 22px;
  }
  .selectable {
    flex-direction: column;
  }
  .rcard-value b {
    font-size: 22px;
  }
}

/* -------- 10. Motion — only when the visitor has not asked for less --------
   Nothing here is tied to scrolling; every animation runs once on an
   explicit user action (open drawer/modal, press a button). */
@media (prefers-reduced-motion: no-preference) {
  .btn,
  .chip,
  .side-nav button,
  .menu-icon,
  .back-nav,
  .links a,
  .footer-nav a {
    transition:
      background-color 0.16s ease,
      color 0.16s ease,
      border-color 0.16s ease,
      transform 0.12s ease,
      box-shadow 0.16s ease;
  }
  .btn:active,
  .menu-icon:active,
  .back-nav:active,
  .chip:active {
    transform: scale(0.97);
  }
  body.menu-open .sidebar {
    animation: drawer-in 0.22s ease-out;
  }
  body.menu-open .menu-scrim,
  .modal.open {
    animation: fade-in 0.18s ease-out;
  }
  .modal.open .modalbox {
    animation: sheet-in 0.22s ease-out;
  }
  .toast.show {
    animation: fade-in 0.16s ease-out;
  }
  @keyframes drawer-in {
    from {
      opacity: 0;
      translate: -16px 0;
    }
  }
  @keyframes fade-in {
    from {
      opacity: 0;
    }
  }
  @keyframes sheet-in {
    from {
      opacity: 0;
      translate: 0 10px;
    }
  }
}
/* Hover affordances only where hover exists (never sticky-hover on touch). */
@media (hover: hover) {
  .btn:hover {
    background: rgba(16, 19, 18, 0.06);
  }
  .btn.primary:hover {
    background: #2a302d;
  }
  .btn.accent:hover {
    background: #4553c6;
  }
  .btn.ghost:hover,
  .btn.tiny:hover {
    background: #f4f5f1;
  }
  .btn.solid-danger:hover {
    background: #8c3324;
  }
  .btn:disabled:hover {
    background: transparent;
  }
  .side-nav button:hover {
    background: #1d2220;
    color: #fff;
  }
  .side-nav button.active:hover {
    background: #222825;
  }
  .links a:hover,
  .footer-nav a:hover {
    color: var(--ink);
    text-decoration: underline;
    text-underline-offset: 4px;
  }
  .chip:hover {
    border-color: #b9bdb5;
  }
  .recovery-tabs .chip.active:hover {
    border-color: var(--ink);
  }
  .event:hover {
    filter: none;
    background: #e3e6ff;
  }
  .event.cancel:hover {
    background: #fbd9d3;
  }
}
