/* Mobile mockup styles - layout + components for the Pass 1 screens.
   Phone-first. The "device frame" is a desktop-viewing affordance only; on a real phone the
   screen fills the viewport. All colours/radii come from tokens.css (no hardcoded values). */

* { box-sizing: border-box; margin: 0; padding: 0; }

.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;
}

html, body { height: 100%; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  background: var(--secondary);
  color: var(--foreground);
  -webkit-font-smoothing: antialiased;
  display: flex;
  justify-content: center;
  align-items: flex-start;
}

/* ---- Device frame (desktop only) ---- */
.device {
  width: 100%;
  max-width: 402px;
  height: 100dvh; /* viewport-locked app shell: .screen scrolls, chrome + tabbar stay put */
  background: var(--background);
  position: relative;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
@media (min-width: 440px) {
  body { align-items: center; padding: 24px 0; }
  .device {
    height: 860px;
    min-height: 0;
    border-radius: 44px;
    border: 10px solid #111;
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.35);
  }
}
/* Installed PWA on a phone: lock the document and use 100svh (never over-estimates, no dynamic
   toolbars in standalone) so the in-flow tab bar can't be pushed below the visible area.
   Scoped under 440px so the desktop phone frame above is unaffected. */
@media (display-mode: standalone) and (max-width: 439.98px) {
  html, body { height: 100%; overflow: hidden; overscroll-behavior: none; }
  .device { height: 100svh; max-height: 100svh; }
}

/* iOS-style status bar */
.statusbar {
  height: 44px;
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 22px;
  font-size: 13px;
  font-weight: 600;
  color: var(--foreground);
  background: var(--background);
}
.statusbar .sb-right { display: flex; gap: 5px; align-items: center; }

/* When installed to the home screen (standalone PWA), the OS draws the real status
   bar, so hide the faux one to avoid doubling it up. Kept for in-browser + desktop
   frame. Must come AFTER the base .statusbar rule above so this display wins. */
@media (display-mode: standalone) {
  .statusbar { display: none !important; }
}

/* ---- App header ---- */
.appbar {
  flex: 0 0 auto;
  background: var(--background);
  padding: 4px 16px 10px;
}
.appbar-top { display: flex; align-items: center; justify-content: space-between; min-height: 36px; }
.appbar-title { font-size: 26px; font-weight: 700; letter-spacing: -0.02em; }
.appbar-sub { font-size: 13px; color: var(--muted-foreground); margin-top: 2px; }
.appbar-actions { display: flex; gap: 6px; }

.icon-btn {
  width: 40px; height: 40px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 999px; border: none; background: transparent;
  color: var(--foreground); cursor: pointer;
}
.icon-btn:active { background: var(--muted); }
.icon-btn svg { width: 22px; height: 22px; }

/* Back button (detail screens) - circular, icon-only, centred title */
.navback {
  width: 40px; height: 40px; min-height: 44px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 999px; border: none; cursor: pointer;
  background: var(--muted); color: var(--foreground);
  text-decoration: none; -webkit-tap-highlight-color: transparent;
}
.navback:active { background: var(--border); }
.navback:focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; }
.navback svg { width: 22px; height: 22px; }

/* 3-slot app header: [back] [centred title] [actions] */
.nav-slot { flex: 0 0 auto; min-width: 44px; display: flex; align-items: center; }
.nav-slot--end { justify-content: flex-end; }
.appbar-titlewrap { flex: 1 1 auto; min-width: 0; text-align: center; }
.appbar-titlewrap .appbar-title {
  font-size: 17px; font-weight: 600; letter-spacing: -0.01em;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.appbar-titlewrap .appbar-sub { margin-top: 1px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---- Week strip ---- */
.weekstrip {
  display: flex; gap: 6px; padding: 6px 12px 12px; overflow-x: auto;
  background: var(--background); flex: 0 0 auto;
  scrollbar-width: none;
}
.weekstrip::-webkit-scrollbar { display: none; }
.daypill {
  flex: 0 0 auto; width: 46px; min-height: 60px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  border-radius: var(--radius); border: 1px solid transparent;
  background: var(--secondary); cursor: pointer;
}
.daypill .dow { font-size: 11px; color: var(--muted-foreground); text-transform: uppercase; letter-spacing: 0.04em; }
.daypill .dom { font-size: 17px; font-weight: 600; }
.daypill .dot { width: 5px; height: 5px; border-radius: 999px; background: var(--primary); }
.daypill.is-today { background: var(--primary); border-color: var(--primary); }
.daypill.is-today .dow, .daypill.is-today .dom { color: var(--primary-foreground); }
.daypill.is-today .dot { background: var(--primary-foreground); }

/* ---- Scrollable content ---- */
.screen {
  flex: 1 1 auto;
  min-height: 0; /* allow the flex child to shrink so its own overflow scrolls */
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 96px; /* room above tab bar */
}
/* Tab-bar pages: the bar is now in-flow, so the 96px reserve would double the gap. */
.device:has(.tabbar) .screen { padding-bottom: 16px; }
.screen.pad { padding-left: 16px; padding-right: 16px; }

/* Section label in the agenda */
.agenda-sectionhead {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px 6px;
}
.agenda-sectionhead .lbl { font-size: 13px; font-weight: 600; color: var(--muted-foreground); text-transform: uppercase; letter-spacing: 0.05em; }
.agenda-sectionhead .count { font-size: 12px; color: var(--muted-foreground); }

/* Queue banner */
.queue-banner {
  margin: 8px 16px 2px; padding: 12px 14px;
  background: var(--primary-tint); border-radius: var(--radius);
  display: flex; align-items: center; gap: 10px;
}
.queue-banner svg { width: 20px; height: 20px; color: var(--primary); flex: 0 0 auto; }
.queue-banner .qb-text { font-size: 13.5px; color: var(--foreground); }
.queue-banner .qb-text b { color: var(--primary); }

/* ---- Appointment cards (agenda) ---- */
.agenda-list { display: flex; flex-direction: column; gap: 10px; padding: 8px 16px 0; }
.appt-card {
  display: grid; grid-template-columns: 56px 1fr auto; align-items: center;
  gap: 10px; padding: 12px; min-height: 72px;
  background: var(--card); color: var(--card-foreground);
  border: 1px solid var(--border); border-radius: var(--radius);
  cursor: pointer; text-decoration: none;
  border-left: 4px solid var(--border);
}
.appt-card:active { background: var(--secondary); }
.appt-time { text-align: left; }
.appt-time .t { font-size: 15px; font-weight: 700; }
.appt-time .ampm { font-size: 11px; color: var(--muted-foreground); font-weight: 600; }
.appt-time .dur { font-size: 11px; color: var(--muted-foreground); margin-top: 2px; }
.appt-main .name { font-size: 15.5px; font-weight: 600; line-height: 1.2; }
.appt-main .meta { font-size: 12.5px; color: var(--muted-foreground); margin-top: 3px; display: flex; align-items: center; gap: 5px; }
.appt-main .meta svg { width: 13px; height: 13px; }
.appt-end { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
.chev { color: var(--muted-foreground); }
.chev svg { width: 18px; height: 18px; }

/* status accent on the left rail */
.appt-card.s-confirmed { border-left-color: var(--success); }
.appt-card.s-checkedin { border-left-color: var(--primary); }
.appt-card.s-booked    { border-left-color: var(--warning); }
.appt-card.s-cancelled { border-left-color: var(--destructive); opacity: 0.72; }
.appt-card.s-cancelled .name { text-decoration: line-through; }

/* ---- Status chip (colour + ALWAYS a label; icon too) ---- */
.chip {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 11.5px; font-weight: 600; line-height: 1;
  padding: 5px 8px; border-radius: 999px; white-space: nowrap;
}
.chip svg { width: 12px; height: 12px; }
.chip.confirmed { background: var(--success-tint); color: var(--success); }
.chip.checkedin { background: var(--primary-tint); color: var(--primary); }
.chip.booked    { background: var(--warning-tint); color: var(--warning); }
.chip.cancelled { background: var(--danger-tint); color: var(--destructive); }
.chip.queue     { background: var(--primary); color: var(--primary-foreground); }

/* empty state */
.empty {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; gap: 10px; padding: 48px 28px; color: var(--muted-foreground);
}
.empty svg { width: 40px; height: 40px; opacity: 0.5; }
.empty .et { font-size: 15px; font-weight: 600; color: var(--foreground); }
.empty .es { font-size: 13px; }

/* ---- Appointment detail ---- */
.patient-head {
  display: flex; align-items: center; gap: 14px; padding: 8px 16px 18px;
}
.avatar {
  width: 60px; height: 60px; border-radius: 999px; flex: 0 0 auto;
  background: var(--primary); color: var(--primary-foreground);
  display: flex; align-items: center; justify-content: center;
  font-size: 22px; font-weight: 700;
}
.patient-head .ph-name { font-size: 20px; font-weight: 700; letter-spacing: -0.01em; }
.patient-head .ph-sub { font-size: 13.5px; color: var(--muted-foreground); margin-top: 3px; }

.detail-card {
  margin: 0 16px 14px; padding: 4px 14px;
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
}
.detail-row {
  display: flex; align-items: center; gap: 12px; padding: 13px 0;
  border-bottom: 1px solid var(--border);
}
.detail-row:last-child { border-bottom: none; }
.detail-row svg { width: 20px; height: 20px; color: var(--muted-foreground); flex: 0 0 auto; }
.detail-row .dr-label { font-size: 13px; color: var(--muted-foreground); }
.detail-row .dr-value { font-size: 15px; font-weight: 500; margin-top: 1px; }
.detail-row .dr-body { flex: 1 1 auto; }
.detail-row.link { cursor: pointer; }
.detail-row.link .chev { margin-left: auto; }

.section-label { font-size: 12.5px; font-weight: 600; color: var(--muted-foreground); text-transform: uppercase; letter-spacing: 0.05em; padding: 4px 18px 8px; }

/* ---- Buttons ---- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; min-height: 50px; padding: 0 18px;
  border-radius: 999px; border: 1px solid transparent;
  font-size: 16px; font-weight: 600; cursor: pointer; text-decoration: none;
}
.btn svg { width: 19px; height: 19px; }
.btn-primary { background: var(--primary); color: var(--primary-foreground); }
.btn-primary:active { filter: brightness(0.94); }
.btn-outline { background: transparent; color: var(--foreground); border-color: var(--border); }
.btn-outline:active { background: var(--secondary); }
.btn-danger { background: transparent; color: var(--destructive); border-color: var(--border); }
.btn-ghost { background: transparent; color: var(--primary); border: none; }

.action-stack { display: flex; flex-direction: column; gap: 10px; padding: 4px 16px 16px; }
.action-row { display: flex; gap: 10px; }
.action-row > .btn { flex: 1; }

/* ---- Bottom tab bar ---- */
.tabbar {
  flex: 0 0 auto; /* pinned by the .device flex column (robust in standalone where 100dvh over-estimates) */
  height: calc(76px + env(safe-area-inset-bottom, 0px));
  padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 10px);
  display: flex; align-items: flex-start; justify-content: space-around;
  background: var(--background); border-top: 1px solid var(--border);
  padding-top: 8px;
}
.tab {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px;
  background: transparent; border: none; cursor: pointer; text-decoration: none;
  color: var(--muted-foreground); font-size: 11px; font-weight: 600;
  min-height: 48px; padding-top: 4px;
}
.tab svg {
  width: 24px; height: 24px; box-sizing: content-box; padding: 3px 14px;
  border-radius: 999px; background: transparent;
  transition: background 0.18s ease, transform 0.12s ease;
}
/* Active tab: solid accent pill (non-colour cue too, WCAG 1.4.1) with the icon reversed; label stays accent. */
.tab.is-active { color: var(--primary); }
.tab.is-active svg { background: var(--primary); color: var(--primary-foreground); }
.tab:active svg { transform: scale(0.92); }
.tab:focus-visible { outline: none; }
.tab:focus-visible svg { outline: 2px solid var(--ring); outline-offset: 2px; }
.tab-fab {
  flex: 0 0 auto; width: 56px;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
}
.tab-fab .fab {
  width: 56px; height: 56px; border-radius: 999px; margin-top: -18px;
  background: var(--primary); color: var(--primary-foreground);
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 8px 20px color-mix(in srgb, var(--primary) 40%, transparent);
  border: none; cursor: pointer; transition: transform 0.12s ease;
}
.tab-fab .fab:active { transform: scale(0.94); }
.tab-fab .fab:focus-visible { outline: 2px solid var(--ring); outline-offset: 3px; }
.tab-fab .fab svg { width: 28px; height: 28px; }
.tab-fab .fab-label { font-size: 11px; font-weight: 600; color: var(--muted-foreground); }

/* ---- Bottom sheet (check-in confirm) ---- */
.sheet-scrim {
  position: absolute; inset: 0; background: rgba(0,0,0,0.45);
  display: flex; align-items: flex-end; opacity: 0; pointer-events: none;
  transition: opacity 0.22s ease; z-index: 20;
}
.sheet-scrim.open { opacity: 1; pointer-events: auto; }
.sheet {
  width: 100%; background: var(--popover); color: var(--popover-foreground);
  border-radius: 20px 20px 0 0; padding: 10px 16px 22px;
  transform: translateY(100%); transition: transform 0.26s cubic-bezier(.2,.8,.2,1);
}
.sheet-scrim.open .sheet { transform: translateY(0); }
.sheet-grip { width: 38px; height: 4px; border-radius: 999px; background: var(--border); margin: 4px auto 12px; }
.sheet-title { font-size: 18px; font-weight: 700; text-align: center; }
.sheet-sub { font-size: 14px; color: var(--muted-foreground); text-align: center; margin: 6px 4px 16px; }
.sheet-actions { display: flex; flex-direction: column; gap: 10px; }

/* confirmation (check-in success) */
.confirm-wrap {
  flex: 1 1 auto; display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; gap: 14px; padding: 24px 28px;
}
.confirm-badge {
  width: 84px; height: 84px; border-radius: 999px; background: var(--success-tint);
  display: flex; align-items: center; justify-content: center;
}
.confirm-badge svg { width: 44px; height: 44px; color: var(--success); }
.confirm-wrap h2 { font-size: 22px; font-weight: 700; }
.confirm-wrap p { font-size: 15px; color: var(--muted-foreground); max-width: 300px; }
.queue-token {
  margin-top: 6px; padding: 14px 24px; border-radius: var(--radius);
  background: var(--primary-tint); color: var(--primary);
  display: flex; flex-direction: column; align-items: center; gap: 2px;
}
.queue-token .qt-num { font-size: 34px; font-weight: 800; line-height: 1; }
.queue-token .qt-lbl { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; }

/* small helpers */
.spacer { flex: 1 1 auto; }
.muted { color: var(--muted-foreground); }

/* ============ Pass 2 - Patient chart ============ */

/* consult banner */
.consult-banner {
  display: flex; align-items: center; gap: 10px; margin: 0 16px 10px;
  padding: 11px 14px; border-radius: var(--radius);
  background: var(--primary); color: var(--primary-foreground); text-decoration: none;
}
.consult-banner svg { width: 20px; height: 20px; flex: 0 0 auto; }
.consult-banner .cb-text { font-size: 13.5px; font-weight: 600; flex: 1 1 auto; }
.consult-banner .cb-go { font-size: 12.5px; opacity: 0.9; }

/* sticky patient header */
.chart-header {
  position: sticky; top: 0; z-index: 5;
  background: var(--background); padding: 2px 16px 12px;
  border-bottom: 1px solid var(--border);
}
.ch-row { display: flex; align-items: center; gap: 12px; }
.ch-id { display: flex; align-items: baseline; gap: 7px; flex-wrap: wrap; }
.ch-name { font-size: 19px; font-weight: 700; letter-spacing: -0.01em; }
.ch-pid { font-size: 13px; color: var(--muted-foreground); font-weight: 600; }
.ch-demo { font-size: 13px; color: var(--muted-foreground); margin-top: 2px; }
.ch-quick { display: flex; gap: 8px; margin-top: 12px; }
.ch-quick .btn { min-height: 40px; font-size: 14px; }
.balance-chip {
  display: inline-flex; align-items: center; gap: 4px; margin-top: 8px;
  font-size: 12.5px; font-weight: 700; padding: 5px 9px; border-radius: 999px;
}
.balance-chip svg { width: 13px; height: 13px; }
.balance-chip.due { background: var(--danger-tint); color: var(--destructive); }
.balance-chip.advance { background: var(--success-tint); color: var(--success); }

/* segmented control */
.segmented {
  display: flex; gap: 4px; margin: 12px 16px 6px; padding: 4px;
  background: var(--secondary); border-radius: 999px; position: sticky; top: 92px; z-index: 4;
}
.segmented button {
  flex: 1; border: none; background: transparent; cursor: pointer;
  font-size: 13.5px; font-weight: 600; color: var(--muted-foreground);
  padding: 9px 6px; border-radius: 999px; min-height: 40px;
}
.segmented button.active { background: var(--primary); color: var(--primary-foreground); box-shadow: 0 1px 3px color-mix(in srgb, var(--primary) 30%, transparent); }
.segpanel { display: none; }
.segpanel.active { display: block; }

/* visit timeline cards */
.visit-list { display: flex; flex-direction: column; gap: 10px; padding: 8px 16px 0; }
.visit-card {
  display: block; text-decoration: none; color: var(--card-foreground);
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 12px; cursor: pointer;
}
.visit-card:active { background: var(--secondary); }
.vc-top { display: flex; align-items: center; gap: 10px; }
.vc-doc {
  width: 38px; height: 38px; border-radius: 999px; flex: 0 0 auto;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 13px; font-weight: 700;
}
.vc-doc.d1 { background: var(--doctor-1); }
.vc-doc.d2 { background: var(--doctor-2); }
.vc-doc.d3 { background: var(--doctor-3); }
.vc-head { flex: 1 1 auto; min-width: 0; }
.vc-title { font-size: 14.5px; font-weight: 600; }
.vc-meta { font-size: 12.5px; color: var(--muted-foreground); margin-top: 2px; }
.vc-date { text-align: right; font-size: 11.5px; font-weight: 700; color: var(--muted-foreground); line-height: 1.25; }
.vc-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.tag-sm { font-size: 11px; font-weight: 600; padding: 3px 8px; border-radius: 999px; background: var(--muted); color: var(--muted-foreground); }
.vc-empty { font-size: 12.5px; color: var(--muted-foreground); font-style: italic; margin-top: 8px; }

/* billing */
.balance-summary {
  margin: 10px 16px 2px; padding: 14px; border-radius: var(--radius);
  background: var(--card); border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.balance-summary .bs-lbl { font-size: 13px; color: var(--muted-foreground); }
.balance-summary .bs-amt { font-size: 20px; font-weight: 800; }
.balance-summary .bs-amt.due { color: var(--destructive); }
.bill-card { margin: 10px 16px 0; background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.bill-head { display: flex; align-items: center; justify-content: space-between; padding: 11px 13px; background: var(--secondary); }
.bill-head .bh-date { font-size: 12.5px; font-weight: 700; color: var(--muted-foreground); }
.bill-sub { padding: 10px 13px; border-top: 1px solid var(--border); }
.bill-sub .bs-h { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted-foreground); margin-bottom: 6px; }
.kv { display: flex; align-items: center; justify-content: space-between; padding: 4px 0; font-size: 13.5px; }
.kv .k { color: var(--muted-foreground); }
.kv .v { font-weight: 600; }
.kv .v.strong { font-size: 15px; }

/* medical: conditions + about (reuses .detail-card/.detail-row) */
.cond-wrap { padding: 4px 16px 0; }
.cond-card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; }
.cond-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.cond-chip { display: inline-flex; align-items: center; gap: 6px; background: var(--muted); color: var(--foreground); font-size: 13px; font-weight: 500; padding: 7px 10px; border-radius: 999px; }
.cond-chip button { border: none; background: transparent; color: var(--muted-foreground); cursor: pointer; display: inline-flex; padding: 0; }
.cond-chip button svg { width: 14px; height: 14px; }
.cond-add { margin-top: 12px; display: flex; align-items: center; gap: 6px; color: var(--primary); font-size: 14px; font-weight: 600; background: transparent; border: none; cursor: pointer; padding: 6px 0; }
.cond-add svg { width: 18px; height: 18px; }
.cond-updated { font-size: 12px; color: var(--muted-foreground); margin-top: 10px; }

/* comms card */
.comms-card { margin: 12px 16px 0; background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; }
.comms-card .cc-title { font-size: 14px; font-weight: 600; }
.comms-card .cc-sub { font-size: 13px; color: var(--muted-foreground); margin-top: 4px; }

/* floating action button (chart) */
.fab-float {
  position: absolute; right: 18px; bottom: 22px; z-index: 8;
  display: inline-flex; align-items: center; gap: 8px; height: 50px; padding: 0 18px;
  border-radius: 999px; background: var(--primary); color: var(--primary-foreground);
  border: none; cursor: pointer; font-size: 15px; font-weight: 600;
  box-shadow: 0 8px 20px color-mix(in srgb, var(--primary) 40%, transparent); text-decoration: none;
}
.fab-float svg { width: 20px; height: 20px; }

/* ---- Visit detail: record blocks ---- */
.visit-detail-head { padding: 6px 16px 14px; }
.vdh-title { font-size: 18px; font-weight: 700; }
.vdh-sub { font-size: 13.5px; color: var(--muted-foreground); margin-top: 3px; }
.record-block { margin: 0 16px 12px; background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.rb-head { display: flex; align-items: center; gap: 9px; padding: 11px 13px; border-bottom: 1px solid var(--border); }
.rb-head svg { width: 18px; height: 18px; color: var(--primary); }
.rb-head .rb-title { font-size: 14px; font-weight: 700; }
.rb-body { padding: 12px 13px; }
.rb-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 14px; }
.rb-field .f-lbl { font-size: 11.5px; color: var(--muted-foreground); text-transform: uppercase; letter-spacing: 0.03em; }
.rb-field .f-val { font-size: 15px; font-weight: 600; margin-top: 2px; }
.rb-field .f-val small { font-size: 12px; font-weight: 500; color: var(--muted-foreground); }
.rb-sub { font-size: 11.5px; color: var(--muted-foreground); text-transform: uppercase; letter-spacing: 0.04em; margin: 2px 0 6px; }
.rb-chiplist { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.rb-chip { font-size: 12.5px; font-weight: 500; padding: 5px 9px; border-radius: 999px; background: var(--muted); color: var(--foreground); }
.rb-note { font-size: 13.5px; line-height: 1.45; color: var(--foreground); }
.rx-item { padding: 9px 0; border-bottom: 1px solid var(--border); }
.rx-item:last-child { border-bottom: none; }
.rx-item .rx-drug { font-size: 14.5px; font-weight: 600; }
.rx-item .rx-meta { font-size: 12.5px; color: var(--muted-foreground); margin-top: 2px; }
.plan-item { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--border); }
.plan-item:last-child { border-bottom: none; }
.plan-item .pi-name { font-size: 14px; font-weight: 500; }
.plan-item .pi-sub { font-size: 12px; color: var(--muted-foreground); margin-top: 2px; }
.mark-banner { display: flex; align-items: center; gap: 8px; margin: 10px 13px 0; padding: 10px 12px; border-radius: var(--radius); background: var(--warning-tint); color: var(--warning); font-size: 13px; font-weight: 600; }
.mark-banner svg { width: 16px; height: 16px; }

/* sheet list (add records) */
.sheet-list { display: flex; flex-direction: column; }
.sheet-list button {
  display: flex; align-items: center; gap: 13px; width: 100%;
  background: transparent; border: none; border-bottom: 1px solid var(--border);
  padding: 14px 4px; font-size: 15.5px; color: var(--foreground); cursor: pointer; text-align: left;
}
.sheet-list button:last-child { border-bottom: none; }
.sheet-list button svg { width: 21px; height: 21px; color: var(--primary); flex: 0 0 auto; }

/* form fields in a sheet */
/* Softer radius scoped to form controls only (leaves cards at --radius, so a full-bleed
   field never out-rounds its container). --radius stays hand-synced with the web theme. */
:root { --radius-field: calc(var(--radius) + 3px); }
.field { margin-bottom: 14px; text-align: left; }
.field label { display: block; font-size: 13px; font-weight: 600; color: var(--muted-foreground); margin-bottom: 6px; padding-left: 12px; }
.field input, .field textarea {
  width: 100%; font: inherit; font-size: 15px; color: var(--foreground);
  background: var(--background); border: 1px solid var(--input); border-radius: var(--radius-field);
  padding: 11px 12px; resize: vertical;
}
.field input:focus, .field textarea:focus { outline: 2px solid var(--ring); outline-offset: -1px; border-color: var(--ring); }

/* phone input group: decorative flag + fixed dial code (no caret / no country picker -
   the app is single-variant locale), then the number. Mirrors the web InputGroup. */
.phone-field {
  display: flex; align-items: stretch; width: 100%; min-height: 44px; overflow: hidden;
  background: var(--background); border: 1px solid var(--input); border-radius: var(--radius-field);
}
.phone-field:focus-within { outline: 2px solid var(--ring); outline-offset: -1px; border-color: var(--ring); }
.phone-field .pf-country {
  display: inline-flex; align-items: center; gap: 7px; flex: 0 0 auto;
  padding: 0 11px; border-right: 1px solid var(--border);
  font: inherit; font-size: 15px; font-weight: 500; color: var(--muted-foreground);
}
/* national-flag colours are content, not UI chrome, so they are not tokenised (Rule 2) */
.phone-field .pf-country .flag { width: 20px; height: 14px; border-radius: 2px; flex: 0 0 auto; }
.phone-field input {
  flex: 1; min-width: 0; border: 0; border-radius: 0; background: transparent;
  font: inherit; font-size: 15px; color: var(--foreground); padding: 11px 12px;
}
.phone-field input:focus { outline: none; }
/* read-only phone display: flag prefix kept for consistency, muted like .ro-field */
.phone-field--ro { background: var(--secondary); cursor: pointer; }
.phone-field .pf-num { display: flex; align-items: center; flex: 1; min-width: 0; padding: 11px 12px; font-size: 15px; font-weight: 600; color: var(--muted-foreground); }

/* ============ Pass 3 - Telemedicine consult ============ */

/* full-screen call: the device becomes the dark video stage */
.device.call { background: var(--grey-900); }
.call-stage {
  position: absolute; inset: 0; z-index: 1;
  background: linear-gradient(160deg, var(--primary-900), var(--grey-900));
  display: flex; flex-direction: column; color: #fff;
}

/* top overlay: back/minimize + timer */
.call-top {
  position: relative; z-index: 3;
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(env(safe-area-inset-top, 0px) + 12px) 14px 10px;
}
.call-top .glass-btn {
  width: 40px; height: 40px; border-radius: 999px; border: none; cursor: pointer;
  background: rgba(255,255,255,0.16); color: #fff;
  display: inline-flex; align-items: center; justify-content: center;
}
.call-top .glass-btn svg { width: 22px; height: 22px; }
.call-timer {
  display: inline-flex; align-items: center; gap: 7px;
  background: rgba(0,0,0,0.38); color: #fff; border-radius: 999px;
  padding: 6px 12px; font-size: 13.5px; font-weight: 700; font-variant-numeric: tabular-nums;
}
.call-timer .dot { width: 8px; height: 8px; border-radius: 999px; background: var(--success-500); }

/* patient fills the stage */
.stage-main { flex: 1 1 auto; position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; }
.stage-avatar {
  width: 112px; height: 112px; border-radius: 999px;
  background: rgba(255,255,255,0.14); color: #fff;
  display: flex; align-items: center; justify-content: center; font-size: 40px; font-weight: 700;
}
.stage-name { display: inline-flex; align-items: center; gap: 8px; font-size: 18px; font-weight: 600; }
.stage-name .dot { width: 9px; height: 9px; border-radius: 999px; background: var(--success-500); }
.stage-sub { font-size: 13.5px; color: rgba(255,255,255,0.72); margin-top: -6px; }

/* doctor self-view PiP */
.pip {
  position: absolute; top: 14px; right: 14px; z-index: 2;
  width: 96px; height: 128px; border-radius: 14px; overflow: hidden;
  background: rgba(0,0,0,0.5); border: 1px solid rgba(255,255,255,0.18);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
}
.pip .pip-circle { width: 44px; height: 44px; border-radius: 999px; display: flex; align-items: center; justify-content: center; color: #fff; font-size: 15px; font-weight: 700; }
.pip .pip-off { display: flex; flex-direction: column; align-items: center; gap: 4px; color: rgba(255,255,255,0.7); font-size: 11px; }
.pip .pip-off svg { width: 20px; height: 20px; }
.pip .pip-label { position: absolute; bottom: 5px; left: 6px; display: inline-flex; align-items: center; gap: 4px; font-size: 10.5px; font-weight: 600; color: #fff; }
.pip .pip-label svg { width: 12px; height: 12px; color: var(--danger-500); }

/* control bar */
.call-controls {
  position: relative; z-index: 3;
  display: flex; align-items: center; justify-content: center; gap: 16px;
  padding: 16px 16px calc(env(safe-area-inset-bottom, 0px) + 24px);
}
.ctrl {
  width: 56px; height: 56px; border-radius: 999px; border: none; cursor: pointer;
  background: rgba(255,255,255,0.18); color: #fff;
  display: inline-flex; align-items: center; justify-content: center; position: relative;
}
.ctrl svg { width: 24px; height: 24px; }
.ctrl .ctrl-cap { position: absolute; bottom: -20px; left: 50%; transform: translateX(-50%); font-size: 10.5px; color: rgba(255,255,255,0.8); white-space: nowrap; }
.ctrl.off { background: #fff; color: var(--grey-900); }
.ctrl.end { background: var(--danger-500); color: #fff; }
.ctrl .badge { position: absolute; top: -2px; right: -2px; min-width: 18px; height: 18px; padding: 0 4px; border-radius: 999px; background: var(--danger-500); color: #fff; font-size: 11px; font-weight: 700; display: flex; align-items: center; justify-content: center; }

/* waiting phase extras (self-preview reuses .pip centered) */
.pre-actions { display: flex; flex-direction: column; align-items: center; gap: 14px; padding: 8px 24px calc(env(safe-area-inset-bottom, 0px) + 28px); position: relative; z-index: 3; }
.pre-toggles { display: flex; gap: 14px; }
.btn-join {
  display: inline-flex; align-items: center; justify-content: center; gap: 9px;
  min-height: 54px; padding: 0 30px; border-radius: 999px; border: none; cursor: pointer;
  background: var(--success-500); color: #fff; font-size: 17px; font-weight: 700;
}
.btn-join svg { width: 20px; height: 20px; }

/* chat sheet thread */
.chat-thread { display: flex; flex-direction: column; gap: 8px; max-height: 46vh; overflow-y: auto; padding: 4px 2px 10px; text-align: left; }
.chat-empty { text-align: center; color: var(--muted-foreground); font-size: 13.5px; padding: 28px 0; }
.bubble-row { display: flex; flex-direction: column; max-width: 82%; }
.bubble-row.me { align-self: flex-end; align-items: flex-end; }
.bubble-row.them { align-self: flex-start; align-items: flex-start; }
.bubble { padding: 9px 12px; border-radius: 14px; font-size: 14px; line-height: 1.35; }
.bubble-row.me .bubble { background: var(--primary); color: var(--primary-foreground); border-bottom-right-radius: 4px; }
.bubble-row.them .bubble { background: var(--muted); color: var(--foreground); border-bottom-left-radius: 4px; }
.bubble-cap { font-size: 11px; color: var(--muted-foreground); margin-top: 3px; }
.chat-composer { display: flex; gap: 8px; align-items: center; padding-top: 6px; }
.chat-composer input { flex: 1; font: inherit; font-size: 15px; color: var(--foreground); background: var(--background); border: 1px solid var(--input); border-radius: 999px; padding: 11px 15px; }
.chat-composer input:focus { outline: 2px solid var(--ring); outline-offset: -1px; }
.chat-send { width: 44px; height: 44px; flex: 0 0 auto; border-radius: 999px; border: none; cursor: pointer; background: var(--primary); color: var(--primary-foreground); display: inline-flex; align-items: center; justify-content: center; }
.chat-send svg { width: 20px; height: 20px; }
.chat-send:disabled { opacity: 0.45; }

/* in-progress / ended consult banner variants (patient.html) */
.consult-banner.inprogress { background: var(--warning-500); color: var(--grey-900); }
.consult-banner.ended { background: var(--muted); color: var(--muted-foreground); }

/* online badge on schedule card meta */
.online-badge { display: inline-flex; align-items: center; gap: 3px; color: var(--primary); font-weight: 700; }
.online-badge svg { width: 13px; height: 13px; }

/* ============ Pass 4 - Billing money flow ============ */

/* step indicator */
.stepper { display: flex; align-items: center; gap: 6px; padding: 8px 16px 10px; }
.stepper .dot { height: 4px; flex: 1; border-radius: 999px; background: var(--muted); }
.stepper .dot.active { background: var(--primary); }
.stepper .dot.done { background: var(--primary); opacity: 0.55; }
.step-title { padding: 2px 16px 4px; }
.step-title .st-h { font-size: 20px; font-weight: 700; letter-spacing: -0.01em; }
.step-title .st-s { font-size: 13px; color: var(--muted-foreground); margin-top: 2px; }

/* appointment/patient strip on invoice */
.bill-patient { display: flex; align-items: center; gap: 11px; padding: 6px 16px 12px; }
.bill-patient .bp-name { font-size: 15px; font-weight: 700; }
.bill-patient .bp-sub { font-size: 12.5px; color: var(--muted-foreground); margin-top: 1px; }
.adv-chip { margin-left: auto; font-size: 12px; font-weight: 700; padding: 5px 9px; border-radius: 999px; background: var(--success-tint); color: var(--success); white-space: nowrap; }

/* line item cards */
.line-list { display: flex; flex-direction: column; gap: 10px; padding: 4px 16px 0; }
.line-card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px; }
.line-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.line-name { font-size: 15px; font-weight: 600; }
.line-total { font-size: 15px; font-weight: 700; white-space: nowrap; }
.line-meta { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.line-meta .mchip { font-size: 11.5px; font-weight: 500; padding: 4px 8px; border-radius: 999px; background: var(--muted); color: var(--muted-foreground); }
.line-meta .mchip.discount { background: var(--success-tint); color: var(--success); }
.line-actions { display: flex; gap: 6px; margin-top: 10px; }
.line-actions button { flex: 1; min-height: 38px; font-size: 13px; border-radius: var(--radius); border: 1px solid var(--border); background: transparent; color: var(--foreground); cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.line-actions button svg { width: 15px; height: 15px; }
.line-actions .rm { color: var(--destructive); }
.add-item-btn { display: flex; align-items: center; justify-content: center; gap: 8px; width: calc(100% - 32px); margin: 10px 16px 0; min-height: 46px; border-radius: var(--radius); border: 1px dashed var(--border); background: transparent; color: var(--primary); font-size: 14.5px; font-weight: 600; cursor: pointer; }
.add-item-btn svg { width: 18px; height: 18px; }

/* totals */
.totals { margin: 14px 16px 0; padding: 14px; background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); }
.totals .trow { display: flex; align-items: center; justify-content: space-between; padding: 5px 0; font-size: 14px; }
.totals .trow .k { color: var(--muted-foreground); }
.totals .grand { border-top: 1px solid var(--border); margin-top: 6px; padding-top: 10px; font-size: 18px; font-weight: 800; }

/* sticky action bar */
.sticky-bar { position: absolute; left: 0; right: 0; bottom: 0; z-index: 8; background: var(--background); border-top: 1px solid var(--border); padding: 12px 16px calc(env(safe-area-inset-bottom, 0px) + 14px); }
.sticky-bar .bar-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.sticky-bar .bar-row .bl { font-size: 12.5px; color: var(--muted-foreground); }
.sticky-bar .bar-row .br { font-size: 17px; font-weight: 800; }

/* money input + fields */
.money { display: flex; align-items: center; border: 1px solid var(--input); border-radius: var(--radius); background: var(--background); overflow: hidden; }
.money .cur { padding: 0 2px 0 12px; color: var(--muted-foreground); font-weight: 600; font-size: 15px; }
.money input { flex: 1; border: none; background: transparent; font: inherit; font-size: 16px; font-weight: 600; color: var(--foreground); padding: 11px 12px 11px 6px; width: 100%; }
.money input:focus { outline: none; }
.money:focus-within { outline: 2px solid var(--ring); outline-offset: -1px; border-color: var(--ring); }

/* choice chips (mode / discount type / tax) */
.choices { display: flex; flex-wrap: wrap; gap: 8px; }
.choice { border: 1px solid var(--border); background: transparent; color: var(--foreground); font-size: 13.5px; font-weight: 600; padding: 9px 14px; border-radius: 999px; cursor: pointer; min-height: 40px; }
.choice.active { background: var(--primary); color: var(--primary-foreground); border-color: var(--primary); }
/* equal-width choice groups (grid) - children share the row evenly */
.choices.cols-2, .choices.cols-3 { display: grid; gap: 8px; }
.choices.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.choices.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.choices.cols-2 .choice, .choices.cols-3 .choice { text-align: center; padding-left: 8px; padding-right: 8px; }
.seg-mini { display: inline-flex; border: 1px solid var(--border); border-radius: 999px; overflow: hidden; }
.seg-mini button { border: none; background: transparent; color: var(--foreground); font-size: 14px; font-weight: 700; padding: 8px 16px; cursor: pointer; }
.seg-mini button.active { background: var(--primary); color: var(--primary-foreground); }

/* payment rows */
.pay-row { display: flex; align-items: center; justify-content: space-between; padding: 12px 0; border-bottom: 1px solid var(--border); font-size: 15px; }
.pay-row:last-child { border-bottom: none; }
.pay-row .pk { color: var(--muted-foreground); font-size: 13px; }
.pay-row .pv { font-weight: 700; }

/* receipt summary */
.receipt-card { margin: 4px 16px 0; background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 4px 14px; }
.receipt-card .rrow { display: flex; align-items: center; justify-content: space-between; padding: 11px 0; border-bottom: 1px solid var(--border); font-size: 14.5px; }
.receipt-card .rrow:last-child { border-bottom: none; }
.receipt-card .rrow .rk { color: var(--muted-foreground); font-size: 13px; }
.receipt-card .rrow .rv { font-weight: 600; }
.receipt-card .rrow .rv.big { font-size: 18px; font-weight: 800; }

/* ledger */
.ledger-head, .ledger-row { display: grid; grid-template-columns: 1fr auto auto auto; gap: 8px; align-items: center; padding: 10px 14px; font-size: 12.5px; }
.ledger-head { color: var(--muted-foreground); font-weight: 700; text-transform: uppercase; letter-spacing: 0.03em; font-size: 10.5px; border-bottom: 1px solid var(--border); position: sticky; top: 0; background: var(--background); }
.ledger-row { border-bottom: 1px solid var(--border); }
.ledger-row .ld-det { min-width: 0; }
.ledger-row .ld-det .d1 { display: block; font-weight: 600; font-size: 13px; }
.ledger-row .ld-det .d2 { display: block; color: var(--muted-foreground); font-size: 11.5px; margin-top: 1px; }
.ledger-row .num { text-align: right; font-variant-numeric: tabular-nums; min-width: 62px; }
.ledger-row .num.credit { color: var(--success); }
.ledger-row .num.debit { color: var(--foreground); }
.ledger-row .num.bal { font-weight: 700; }
.ledger-total { display: flex; align-items: center; justify-content: space-between; padding: 14px; font-weight: 800; }
.ledger-total .lt-due { color: var(--destructive); }

/* ============ Pass 5 - New appointment booking ============ */

/* native select styled */
.select {
  width: 100%; font: inherit; font-size: 16px; font-weight: 500; color: var(--foreground);
  background: var(--background); border: 1px solid var(--input); border-radius: var(--radius-field);
  padding: 11px 38px 11px 12px; -webkit-appearance: none; appearance: none; cursor: pointer;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24' fill='none' stroke='%235b5f5f' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><path d='m6 9 6 6 6-6'/></svg>");
  background-repeat: no-repeat; background-position: right 10px center;
}
.select:focus { outline: 2px solid var(--ring); outline-offset: -1px; border-color: var(--ring); }

/* picker field (tap to open a sheet) */
.picker-field {
  width: 100%; display: flex; align-items: center; gap: 8px;
  font: inherit; font-size: 16px; text-align: left; color: var(--foreground);
  background: var(--background); border: 1px solid var(--input); border-radius: var(--radius-field);
  padding: 11px 12px; cursor: pointer; min-height: 48px;
}
.picker-field.placeholder { color: var(--muted-foreground); font-weight: 400; }
.picker-field .pf-val { flex: 1; font-weight: 500; }
.picker-field .new-badge { font-size: 10.5px; font-weight: 700; padding: 2px 7px; border-radius: 999px; background: var(--success-tint); color: var(--success); }
.picker-field svg { width: 20px; height: 20px; color: var(--muted-foreground); flex: 0 0 auto; }

/* read-only field value */
.ro-field { font-size: 15px; font-weight: 600; padding: 11px 12px; background: var(--secondary); border: 1px solid var(--border); border-radius: var(--radius-field); color: var(--muted-foreground); }

/* switch toggle rows */
.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 11px 0; }
.switch-row .sr-label { font-size: 14.5px; }
.switch-row .sr-sub { font-size: 12px; color: var(--muted-foreground); margin-top: 1px; }
.switch { position: relative; width: 46px; height: 28px; flex: 0 0 auto; }
.switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.switch .track { position: absolute; inset: 0; border-radius: 999px; background: var(--muted); transition: background 0.18s; }
.switch .thumb { position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 999px; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,0.3); transition: transform 0.18s; }
.switch input:checked ~ .track { background: var(--primary); }
.switch input:checked ~ .thumb { transform: translateX(18px); }

/* selected procedures chips */
.sel-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 4px; }
.sel-chip { display: inline-flex; align-items: center; gap: 6px; background: var(--primary-tint); color: var(--primary); font-size: 13px; font-weight: 600; padding: 7px 10px; border-radius: 999px; }
.sel-chip button { border: none; background: transparent; color: var(--primary); cursor: pointer; display: inline-flex; padding: 0; }
.sel-chip button svg { width: 13px; height: 13px; }

/* date+time row */
.dt-row { display: flex; gap: 10px; }
.dt-row .field { flex: 1; margin-bottom: 0; }

/* toast */
.toast {
  position: absolute; left: 16px; right: 16px; bottom: calc(env(safe-area-inset-bottom, 0px) + 90px); z-index: 30;
  display: flex; align-items: center; gap: 10px;
  background: var(--success-500); color: #fff; border-radius: var(--radius);
  padding: 13px 15px; box-shadow: 0 10px 30px rgba(0,0,0,0.3);
  transform: translateY(16px); opacity: 0; transition: transform 0.25s, opacity 0.25s; pointer-events: none;
}
.toast.show { transform: translateY(0); opacity: 1; }
.toast svg { width: 20px; height: 20px; flex: 0 0 auto; }
.toast .tt { font-size: 14px; font-weight: 600; }

/* ============ Pass 6 - Patients list + search ============ */

/* sticky search bar */
.search-bar { position: sticky; top: 0; z-index: 6; background: var(--background); padding: 6px 16px 10px; }
.search-input { display: flex; align-items: center; gap: 9px; background: var(--secondary); border: 1px solid var(--border); border-radius: 999px; padding: 10px 14px; }
.search-input svg { width: 19px; height: 19px; color: var(--muted-foreground); flex: 0 0 auto; }
.search-input input { flex: 1; border: none; background: transparent; font: inherit; font-size: 15px; color: var(--foreground); }
.search-input input:focus { outline: none; }
.search-input .clear { border: none; background: transparent; color: var(--muted-foreground); cursor: pointer; display: none; padding: 0; }
.search-input .clear svg { width: 17px; height: 17px; }
.search-input.has-text .clear { display: inline-flex; }

/* patient list */
.plist { display: flex; flex-direction: column; }
.prow {
  display: flex; align-items: center; gap: 12px; padding: 11px 16px; min-height: 60px;
  text-decoration: none; color: var(--foreground); border-bottom: 1px solid var(--border); cursor: pointer;
}
.prow:active { background: var(--secondary); }
.prow .pr-av { width: 40px; height: 40px; flex: 0 0 auto; border-radius: 999px; background: var(--primary); color: var(--primary-foreground); display: flex; align-items: center; justify-content: center; font-size: 14px; font-weight: 700; }
.prow .pr-body { flex: 1 1 auto; min-width: 0; }
.prow .pr-name { display: block; font-size: 15px; font-weight: 600; }
.prow .pr-sub { display: block; font-size: 12.5px; color: var(--muted-foreground); margin-top: 2px; }
.prow .pr-sub b { color: var(--foreground); font-weight: 600; }
.prow .chev { color: var(--muted-foreground); }
.prow .chev svg { width: 18px; height: 18px; }

/* today row: time instead of avatar + waiting badge */
.prow .pr-time { width: 56px; flex: 0 0 auto; text-align: left; }
.prow .pr-time .t { font-size: 14px; font-weight: 700; font-variant-numeric: tabular-nums; }
.prow .pr-time .ampm { font-size: 10.5px; font-weight: 600; color: var(--muted-foreground); }
.wait-badge { display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px; font-weight: 600; color: var(--destructive); }
.wait-badge .dot { width: 7px; height: 7px; border-radius: 999px; background: var(--destructive); }

/* A-Z sticky letter dividers */
.letter-div { position: sticky; top: 0; z-index: 3; background: var(--secondary); color: var(--muted-foreground); font-size: 12px; font-weight: 700; padding: 5px 16px; letter-spacing: 0.04em; }

/* section header (Due/Met) reuses .agenda-sectionhead */
.add-patient-row { display: flex; align-items: center; gap: 12px; padding: 14px 16px; color: var(--primary); font-weight: 600; font-size: 15px; cursor: pointer; border-bottom: 1px solid var(--border); background: transparent; width: 100%; border-left: none; border-right: none; border-top: none; text-align: left; }
.add-patient-row svg { width: 20px; height: 20px; }

/* ============ Pass 7 - More hub, Communications reports, gated chat ============ */

/* more-hub rows */
.more-group { margin-top: 6px; }
.more-row {
  display: flex; align-items: center; gap: 14px; padding: 13px 16px; min-height: 52px;
  text-decoration: none; color: var(--foreground); border-bottom: 1px solid var(--border);
  background: transparent; width: 100%; border-left: none; border-right: none; border-top: none;
  text-align: left; cursor: pointer; font: inherit;
}
.more-row:active { background: var(--secondary); }
.more-row .mr-ic { width: 34px; height: 34px; flex: 0 0 auto; border-radius: 9px; background: var(--primary-tint); color: var(--primary); display: flex; align-items: center; justify-content: center; }
.more-row .mr-ic svg { width: 19px; height: 19px; }
.more-row .mr-label { flex: 1 1 auto; font-size: 15px; font-weight: 500; }
.more-row .mr-sub { display: block; font-size: 12px; color: var(--muted-foreground); font-weight: 400; margin-top: 2px; }
.more-row .chev { color: var(--muted-foreground); }
.more-row .chev svg { width: 18px; height: 18px; }
.more-row.danger .mr-ic { background: var(--danger-tint); color: var(--destructive); }
.more-row.danger .mr-label { color: var(--destructive); }

/* account identity header on More */
.more-id { display: flex; align-items: center; gap: 13px; padding: 10px 16px 16px; }
.more-id .mi-name { font-size: 17px; font-weight: 700; }
.more-id .mi-sub { font-size: 13px; color: var(--muted-foreground); margin-top: 2px; }

/* tappable identity header → Account hub */
.more-id-link {
  min-height: 56px; margin: 2px 0 8px; border-radius: 12px;
  text-decoration: none; color: inherit; cursor: pointer;
}
.more-id-link .mi-text { flex: 1 1 auto; }
.more-id-link .chev { color: var(--muted-foreground); margin-left: auto; }
.more-id-link .chev svg { width: 18px; height: 18px; }
.more-id-link:hover, .more-id-link:active { background: var(--secondary); }
.more-id-link:focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; }

/* credits strip */
.credit-strip { display: flex; gap: 10px; padding: 10px 16px 4px; }
.credit-card { flex: 1; background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px; }
.credit-card .cc-lbl { font-size: 11.5px; color: var(--muted-foreground); text-transform: uppercase; letter-spacing: 0.03em; }
.credit-card .cc-val { font-size: 18px; font-weight: 800; margin-top: 4px; }
.credit-card .cc-val small { font-size: 12px; font-weight: 600; color: var(--muted-foreground); }

/* stat tiles (delivery summary) */
.stat-tiles { display: flex; gap: 10px; padding: 10px 16px 2px; }
.stat-tile { flex: 1; background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px; text-align: center; }
.stat-tile .st-num { font-size: 24px; font-weight: 800; }
.stat-tile .st-lbl { font-size: 12px; color: var(--muted-foreground); margin-top: 2px; display: inline-flex; align-items: center; gap: 5px; }
.stat-tile .st-lbl .d { width: 8px; height: 8px; border-radius: 999px; }
.stat-tile.ok .st-num { color: var(--success); }
.stat-tile.bad .st-num { color: var(--destructive); }
.stat-tile.ok .st-lbl .d { background: var(--success); }
.stat-tile.bad .st-lbl .d { background: var(--destructive); }

/* delivery rows */
.deliv-group-head { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted-foreground); padding: 14px 16px 4px; }
.deliv-row { display: flex; align-items: flex-start; gap: 10px; padding: 11px 16px; border-bottom: 1px solid var(--border); }
.deliv-row .dv-body { flex: 1 1 auto; min-width: 0; }
.deliv-row .dv-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.deliv-row .dv-name { font-size: 14.5px; font-weight: 600; }
.deliv-row .dv-meta { font-size: 12px; color: var(--muted-foreground); margin-top: 1px; }
.deliv-row .dv-msg { font-size: 13px; color: var(--foreground); margin-top: 5px; line-height: 1.35; }
.deliv-row .dv-fail { font-size: 12px; color: var(--destructive); margin-top: 4px; }
.deliv-row .resend { font-size: 13px; font-weight: 600; color: var(--primary); background: transparent; border: none; cursor: pointer; padding: 6px 0 0; }

/* locked messaging state */
.locked-note { display: flex; align-items: center; gap: 9px; padding: 11px 13px; border-radius: var(--radius); background: var(--secondary); border: 1px dashed var(--border); color: var(--muted-foreground); font-size: 13px; }
.locked-note svg { width: 18px; height: 18px; flex: 0 0 auto; }
.btn:disabled { opacity: 0.5; cursor: default; }

/* full-screen chat thread (reuses .bubble-row/.bubble from the consult chat) */
.thread-ctx { display: flex; align-items: center; gap: 6px; justify-content: center; padding: 2px 16px 10px; font-size: 12px; color: var(--muted-foreground); }
.thread-ctx svg { width: 13px; height: 13px; color: var(--success); }
.thread-scroll { flex: 1 1 auto; min-height: 0; overflow-y: auto; padding: 4px 16px 10px; display: flex; flex-direction: column; gap: 8px; }
.thread-composer { flex: 0 0 auto; display: flex; gap: 8px; align-items: center; padding: 10px 16px calc(env(safe-area-inset-bottom, 0px) + 14px); border-top: 1px solid var(--border); background: var(--background); }
.thread-composer input { flex: 1; font: inherit; font-size: 15px; color: var(--foreground); background: var(--secondary); border: 1px solid var(--border); border-radius: 999px; padding: 11px 15px; }
.thread-composer input:focus { outline: 2px solid var(--ring); outline-offset: -1px; }
.date-divider { text-align: center; font-size: 11.5px; color: var(--muted-foreground); margin: 6px 0; }

/* ============ Pass 8 - More sub-pages (Reports / Inventory / Expenses / Settings / Account) ============ */

/* Reports: lightweight CSS-only chart stand-ins (no chart lib in the mockups) */
.repbars { display: flex; flex-direction: column; gap: 13px; padding: 12px 16px 4px; }
.repbar .repbar-row { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 5px; }
.repbar .repbar-k { font-size: 13px; color: var(--muted-foreground); }
.repbar .repbar-v { font-size: 13.5px; font-weight: 700; font-variant-numeric: tabular-nums; }
.repbar .repbar-track { height: 9px; border-radius: 999px; background: var(--muted); overflow: hidden; }
.repbar .repbar-fill { height: 100%; border-radius: 999px; background: var(--primary); }

.rep-donut-wrap { display: flex; align-items: center; gap: 18px; padding: 16px 16px 8px; }
.rep-donut { width: 132px; height: 132px; flex: 0 0 auto; border-radius: 999px; position: relative; }
.rep-donut::after { content: ''; position: absolute; inset: 26px; border-radius: 999px; background: var(--card); }
.rep-donut .rd-center { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; z-index: 1; }
.rep-donut .rd-total { font-size: 17px; font-weight: 800; }
.rep-donut .rd-lbl { font-size: 10px; color: var(--muted-foreground); text-transform: uppercase; letter-spacing: 0.04em; }
.rep-legend { flex: 1 1 auto; display: flex; flex-direction: column; gap: 9px; }
.rep-legend .rl-row { display: flex; align-items: center; gap: 9px; font-size: 13px; }
.rep-legend .rl-dot { width: 11px; height: 11px; border-radius: 3px; flex: 0 0 auto; }
.rep-legend .rl-k { color: var(--foreground); flex: 1 1 auto; }
.rep-legend .rl-v { font-weight: 700; font-variant-numeric: tabular-nums; }

/* a single big KPI tile (totals: New Patients / Appointments / Amount Due) */
.kpi-hero { margin: 12px 16px 2px; padding: 18px; border-radius: var(--radius); background: var(--card); border: 1px solid var(--border); text-align: center; }
.kpi-hero .kh-num { font-size: 32px; font-weight: 800; letter-spacing: -0.01em; }
.kpi-hero .kh-num.due { color: var(--destructive); }
.kpi-hero .kh-lbl { font-size: 12px; color: var(--muted-foreground); text-transform: uppercase; letter-spacing: 0.04em; margin-top: 4px; }

/* a plain report/table row inside a .detail-card */
.rep-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 11px 0; border-bottom: 1px solid var(--border); }
.rep-row:last-child { border-bottom: none; }
.rep-row .rr-main { min-width: 0; }
.rep-row .rr-name { font-size: 14px; font-weight: 600; }
.rep-row .rr-sub { font-size: 12px; color: var(--muted-foreground); margin-top: 2px; }
.rep-row .rr-val { font-size: 14px; font-weight: 700; white-space: nowrap; font-variant-numeric: tabular-nums; }

/* a simple summing total row (expenses / reports) */
.sum-row { display: flex; align-items: center; justify-content: space-between; margin: 12px 16px 4px; padding: 14px; border-radius: var(--radius); background: var(--secondary); font-weight: 800; }
.sum-row .sr-v { font-variant-numeric: tabular-nums; }

/* stock filter row (inventory) - reuses .choices/.choice, this is just a wrapper */
.filter-row { display: flex; align-items: center; gap: 10px; padding: 2px 16px 6px; overflow-x: auto; scrollbar-width: none; }
.filter-row::-webkit-scrollbar { display: none; }

/* tier badge on a settings row */
.tier { font-size: 10px; font-weight: 700; padding: 3px 7px; border-radius: 999px; text-transform: uppercase; letter-spacing: 0.03em; white-space: nowrap; }
.tier.readonly { background: var(--muted); color: var(--muted-foreground); }
.tier.out { background: var(--muted); color: var(--muted-foreground); }
.tier.simulated { background: var(--warning-tint); color: var(--warning); }

/* autosave pill (settings communications) */
.save-pill { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 600; color: var(--success); }
.save-pill svg { width: 14px; height: 14px; }

/* info banner (settings) */
.info-banner { display: flex; align-items: flex-start; gap: 9px; margin: 6px 16px 10px; padding: 11px 13px; border-radius: var(--radius); background: var(--primary-tint); color: var(--foreground); font-size: 13px; line-height: 1.4; }
.info-banner svg { width: 18px; height: 18px; color: var(--primary); flex: 0 0 auto; margin-top: 1px; }

/* small matrix table (settings communications) */
.matrix { margin: 4px 16px 0; }
.matrix-row { display: grid; grid-template-columns: 1fr auto auto; gap: 10px; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--border); }
.matrix-row:last-child { border-bottom: none; }
.matrix-row .mx-name { font-size: 14px; font-weight: 500; }
.matrix-row .mx-sub { font-size: 12px; color: var(--muted-foreground); margin-top: 1px; }
.matrix-head { display: grid; grid-template-columns: 1fr auto auto; gap: 10px; padding: 8px 0 4px; font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.03em; color: var(--muted-foreground); }
.matrix-head span:not(:first-child), .matrix-row .mx-col { width: 44px; text-align: center; }

/* current-plan card (account subscriptions) */
.plan-card { margin: 10px 16px 0; padding: 16px; border-radius: var(--radius); background: var(--card); border: 1px solid var(--border); }
.plan-card .pc-name { font-size: 16px; font-weight: 700; }
.plan-card .pc-sub { font-size: 13px; color: var(--muted-foreground); margin-top: 3px; }
.plan-card .pc-badge { display: inline-flex; align-items: center; gap: 4px; font-size: 11px; font-weight: 700; padding: 4px 9px; border-radius: 999px; background: var(--success-tint); color: var(--success); margin-top: 10px; }

/* ============ Pass 9 - polish & states (swipe actions, pull-to-refresh, loading/empty/error) ============ */

/* swipe-to-reveal actions on an agenda card */
.swipe { position: relative; overflow: hidden; border-radius: var(--radius); }
.swipe-actions { position: absolute; top: 0; right: 0; bottom: 0; display: flex; align-items: stretch; z-index: 0; }
.swipe-action { display: inline-flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; width: 76px; border: none; cursor: pointer; color: #fff; font-size: 12px; font-weight: 700; }
.swipe-action svg { width: 20px; height: 20px; }
.swipe-action.checkin { background: var(--primary); color: var(--primary-foreground); }
.swipe-action.cancel { background: var(--destructive); color: var(--destructive-foreground); }
.swipe .appt-card { position: relative; z-index: 1; margin: 0; touch-action: pan-y; transition: transform 0.22s cubic-bezier(.2,.8,.2,1); will-change: transform; }
.swipe.dragging .appt-card { transition: none; }
/* the agenda uses .agenda-list gap; each card is now wrapped, so target the wrapper */
.agenda-list .swipe + .swipe { margin-top: 0; }

/* pull-to-refresh indicator */
.ptr { height: 0; overflow: hidden; display: flex; align-items: center; justify-content: center; gap: 8px; color: var(--muted-foreground); font-size: 12.5px; font-weight: 600; transition: height 0.2s ease; }
.ptr.pulling { transition: none; }
.ptr.show { height: 48px; }
.spinner { width: 18px; height: 18px; border-radius: 999px; border: 2.5px solid var(--muted); border-top-color: var(--primary); animation: spin 0.7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* loading skeleton */
.skeleton { background: linear-gradient(100deg, var(--muted) 30%, var(--secondary) 50%, var(--muted) 70%); background-size: 200% 100%; animation: shimmer 1.3s linear infinite; border-radius: var(--radius); }
@keyframes shimmer { to { background-position: -200% 0; } }
.sk-list { display: flex; flex-direction: column; gap: 10px; padding: 8px 16px 0; }
.sk-card { height: 72px; }
.sk-row { display: flex; align-items: center; gap: 12px; padding: 11px 16px; border-bottom: 1px solid var(--border); }
.sk-av { width: 40px; height: 40px; border-radius: 999px; flex: 0 0 auto; }
.sk-lines { flex: 1 1 auto; display: flex; flex-direction: column; gap: 7px; }
.sk-line { height: 11px; }
.sk-line.sh { width: 55%; }

/* error / retry state (reuses .empty) */
.empty .btn { width: auto; min-height: 42px; padding: 0 20px; margin-top: 4px; }
.empty.error svg { color: var(--destructive); opacity: 0.8; }

/* ============ Pass 10 - Treatment Communications (plan editor) ============ */
/* plans list */
.create-plan { display: flex; align-items: center; justify-content: center; gap: 8px; width: calc(100% - 32px); margin: 12px 16px 6px; min-height: 48px; border: 1px dashed var(--border); border-radius: var(--radius); background: var(--card); color: var(--muted-foreground); font-size: 14px; font-weight: 600; cursor: pointer; }
.create-plan:active { background: var(--muted); }
.create-plan svg { width: 18px; height: 18px; }
.plan-list { display: flex; flex-direction: column; margin: 6px 16px 0; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; background: var(--card); }
.plan-row { display: flex; align-items: center; gap: 10px; padding: 14px; border-bottom: 1px solid var(--border); text-decoration: none; color: var(--foreground); }
.plan-row:last-child { border-bottom: none; }
.plan-row:active { background: var(--muted); }
.pr-name { flex: 1 1 auto; font-size: 14.5px; font-weight: 600; }
.plan-row .chev { color: var(--muted-foreground); }
.plan-row .chev svg { width: 18px; height: 18px; }
.chip.neverused { background: var(--danger-tint); color: var(--destructive); }
.chip.newplan { background: var(--success-tint); color: var(--success); }

/* plan detail */
.plan-titlebar { display: flex; align-items: center; gap: 6px; padding: 0 16px; }
.plan-titlebar .appbar-title { flex: 1 1 auto; min-width: 0; }
.plan-actions { display: flex; gap: 10px; padding: 12px 16px 0; }
.plan-actions .btn { min-height: 40px; font-size: 13.5px; }
.add-card { margin: 12px 16px 0; padding: 14px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--card); }
.add-card-q { font-size: 13.5px; color: var(--muted-foreground); margin-bottom: 10px; }
.add-card-btns { display: flex; gap: 10px; }
.add-card-btns .btn { min-height: 42px; font-size: 13.5px; }
.plan-counts { padding: 14px 18px 6px; font-size: 12.5px; color: var(--muted-foreground); }

.week-group { margin: 0 16px; border: 1px solid var(--border); border-top: none; background: var(--card); }
.week-group:first-of-type { border-top: 1px solid var(--border); border-radius: var(--radius) var(--radius) 0 0; }
.week-group:last-of-type { border-radius: 0 0 var(--radius) var(--radius); }
.week-head { display: flex; align-items: center; gap: 6px; width: 100%; padding: 10px 12px; background: var(--muted); color: var(--muted-foreground); border: none; font-size: 12px; font-weight: 700; letter-spacing: 0.05em; cursor: pointer; }
.week-head svg { width: 16px; height: 16px; transition: transform 0.15s ease; }
.plan-item { display: flex; align-items: center; gap: 10px; padding: 11px 12px; border-top: 1px solid var(--border); cursor: pointer; }
.plan-item:active { background: var(--muted); }
.pi-day { width: 48px; flex: 0 0 auto; font-size: 12.5px; color: var(--muted-foreground); }
.pi-ic { flex: 0 0 auto; color: var(--muted-foreground); }
.pi-ic svg { width: 17px; height: 17px; display: block; }
.pi-body { flex: 1 1 auto; min-width: 0; }
.pi-title { font-size: 14px; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pi-time { font-size: 12px; color: var(--muted-foreground); }
.pi-thumb { flex: 0 0 auto; width: 40px; height: 30px; border-radius: 6px; background: var(--primary-tint); color: var(--primary); font-size: 12px; font-weight: 700; display: flex; align-items: center; justify-content: center; }
.pi-del { flex: 0 0 auto; background: none; border: none; color: var(--muted-foreground); padding: 4px; cursor: pointer; }
.pi-del svg { width: 17px; height: 17px; display: block; }

/* add-reminder / add-article sheet bits */
.rt-count { font-size: 12px; color: var(--muted-foreground); margin-top: 6px; text-align: right; }
.sms-preview { margin: -4px 0 14px; padding: 10px 12px; border-radius: var(--radius); background: var(--muted); font-size: 13px; color: var(--muted-foreground); }
.sms-preview .sp-label { display: block; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; margin-bottom: 4px; }
.rt-toolbar { display: flex; align-items: center; gap: 2px; padding: 4px; border: 1px solid var(--input); border-bottom: none; border-radius: var(--radius) var(--radius) 0 0; background: var(--card); }
.rt-toolbar button { min-width: 34px; height: 32px; border: none; background: none; color: var(--foreground); font-size: 15px; border-radius: 6px; cursor: pointer; }
.rt-toolbar button:active { background: var(--muted); }
.rt-toolbar button svg { width: 17px; height: 17px; vertical-align: middle; }
.rt-editor { min-height: 120px; max-height: 180px; overflow-y: auto; padding: 10px 12px; border: 1px solid var(--input); border-radius: 0 0 var(--radius) var(--radius); background: var(--card); color: var(--foreground); font-size: 14px; line-height: 1.5; text-align: left; }
.rt-editor:focus { outline: 2px solid var(--ring); outline-offset: -1px; }
.rt-editor ul { margin: 6px 0; padding-left: 20px; list-style: disc; }

/* ============ Pass 11 - UI polish: app-shell + touch targets ============ */
/* App shell is now viewport-locked at all widths (.device height:100dvh,
   .screen/.thread-scroll min-height:0), so the bottom nav stays pinned and
   content scrolls inside .screen instead of the page scrolling under the bar.
   The rest of this block floors interactive controls at a comfortable size. */

/* form controls: floor native date/time and short inputs at 44px */
.field input, .field select, .field textarea, .select { min-height: 44px; }

/* small icon actions get a real hit area without changing the icon size */
.pi-del { min-width: 40px; min-height: 40px; display: inline-flex; align-items: center; justify-content: center; }

/* compact pill toggles (chart/table, group-by) a touch taller */
.seg-mini button { min-height: 36px; }

/* two-up field rows need bottom spacing like a normal .field, else the next
   label (Reason / Website / Country / TIN...) crams against the row above.
   A dt-row wrapped inside a labelled .field keeps 0 so it isn't double-spaced. */
.dt-row { margin-bottom: 14px; }
.field > .dt-row { margin-bottom: 0; }

/* .switch is a <label> with explicit width/height; inline elements ignore those
   unless blockified by a flex parent. In the Communications .matrix (grid cell)
   the switch collapsed, the track went zero-size and only the thumb showed as a
   white circle. inline-block makes the track + checked (teal) state render everywhere. */
.switch { display: inline-block; }
.matrix-head span:not(:first-child), .matrix-row .mx-col { width: 48px; }

/* ============ Pass 12 - Settings sub-pages (staff / billing / printouts / calendar) ============ */
/* Config rows reused by Practice Staff, Billing and Calendar timings. */
.cfg-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px 6px; }
.cfg-pad { padding: 0 16px; }
.cfg-addbtn { width: auto; min-height: 40px; padding: 0 18px; flex: 0 0 auto; font-size: 15px; }
.cfg-sublabel { display: block; font-size: 13px; font-weight: 600; color: var(--muted-foreground); margin: 4px 0 8px; }

.cfg-row { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--border); }
.cfg-row:last-child { border-bottom: none; }
/* doctor calendar-colour dot is data, not UI chrome (Rule 2 exception, as elsewhere) */
.cfg-dot { width: 12px; height: 12px; border-radius: 999px; flex: 0 0 auto; }
.cfg-main { flex: 1 1 auto; min-width: 0; }
.cfg-name { font-size: 15px; font-weight: 600; color: var(--foreground); display: flex; align-items: center; gap: 8px; }
.cfg-sub { font-size: 13px; color: var(--muted-foreground); margin-top: 1px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cfg-rate { font-size: 14px; font-weight: 600; color: var(--foreground); flex: 0 0 auto; }
.cfg-actions { display: flex; gap: 2px; flex: 0 0 auto; }
.cfg-ibtn { width: 40px; height: 40px; display: inline-flex; align-items: center; justify-content: center; border: none; background: transparent; color: var(--muted-foreground); border-radius: 10px; cursor: pointer; }
.cfg-ibtn:active { background: var(--secondary); color: var(--foreground); }
.cfg-ibtn.danger:active { color: var(--destructive); }
.cfg-ibtn[disabled] { opacity: 0.3; cursor: default; }
.cfg-ibtn svg { width: 18px; height: 18px; }

/* doctor colour swatch picker (swatch backgrounds are data colours, set inline - Rule 2 exception) */
.swatches { display: flex; flex-wrap: wrap; gap: 10px; }
.swatch { width: 32px; height: 32px; border-radius: 999px; border: 2px solid transparent; padding: 0; cursor: pointer; }
.swatch.active { border-color: var(--foreground); box-shadow: 0 0 0 2px var(--background) inset; }

/* 4-up choice grid for the day picker */
.choices.cols-4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.choices.cols-4 .choice { text-align: center; padding-left: 6px; padding-right: 6px; }

/* Printouts live preview */
.pv-doc { max-width: 260px; margin: 0 auto; border: 1px solid var(--border); border-radius: 10px; background: var(--background); padding: 14px; font-size: 11px; color: var(--muted-foreground); transition: max-width 0.2s, filter 0.2s; }
.pv-doc.landscape { max-width: 100%; }
.pv-grey { filter: grayscale(1); }
.pv-head { border-bottom: 1px solid var(--border); padding-bottom: 8px; text-align: center; }
.pv-title { font-size: 13px; font-weight: 700; color: var(--foreground); }
.pv-hrow { display: flex; justify-content: space-between; gap: 8px; font-size: 10px; margin-top: 3px; }
.pv-body { padding: 10px 0; }
.pv-doctype { font-weight: 700; color: var(--foreground); font-size: 12px; margin-bottom: 4px; }
.pv-line { margin: 2px 0; }
.pv-kv { display: flex; justify-content: space-between; margin: 2px 0; }
.pv-kv.strong { border-top: 1px solid var(--border); margin-top: 4px; padding-top: 4px; color: var(--foreground); font-weight: 700; }
.pv-foot { border-top: 1px solid var(--border); padding-top: 8px; }
.pv-full { text-align: center; font-size: 10px; }

/* ============ Pass 13 - Add-records forms (visit.html) ============ */
/* tall forms scroll inside the sheet */
.sheet { max-height: 88dvh; overflow-y: auto; }

/* repeating-row forms (prescription / lab / treatment plan / completed procedures) */
.rec-rows { display: flex; flex-direction: column; gap: 12px; }
.rec-row { border: 1px solid var(--border); border-radius: var(--radius-field); padding: 12px; }
.rec-row .field:last-of-type { margin-bottom: 0; }
.rec-row-actions { display: flex; justify-content: flex-end; margin-top: 4px; }
.rec-remove { border: none; background: transparent; color: var(--muted-foreground); font: inherit; font-size: 13px; font-weight: 600; cursor: pointer; padding: 6px 4px; min-height: 36px; }
.rec-remove:active { color: var(--destructive); }
.rec-add { display: inline-flex; align-items: center; gap: 6px; border: none; background: transparent; color: var(--primary); font: inherit; font-size: 14px; font-weight: 600; cursor: pointer; padding: 10px 2px; min-height: 40px; }
.rec-add svg { width: 17px; height: 17px; }

/* line / totals inside forms + appended blocks */
.rec-line { display: flex; align-items: center; justify-content: space-between; font-size: 14px; }
.rec-tot { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; border-top: 1px solid var(--border); padding-top: 10px; font-size: 14px; }
.rec-tot .rt-lbl { font-size: 11px; color: var(--muted-foreground); }
.rec-err { font-size: 12px; color: var(--destructive); margin-top: 4px; min-height: 0; }
.pi-amt { font-weight: 600; font-size: 14px; color: var(--foreground); }

/* files list (form + read view) */
.file-list { list-style: none; display: flex; flex-direction: column; gap: 8px; margin: 10px 0 0; }
.file-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 14px; }
.file-row span { display: inline-flex; align-items: center; gap: 8px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-row svg { width: 16px; height: 16px; color: var(--muted-foreground); flex: 0 0 auto; }
.file-row button { border: none; background: transparent; color: var(--muted-foreground); cursor: pointer; padding: 4px; display: inline-flex; }
.file-row button svg { width: 14px; height: 14px; }

/* "Shared" tag on a record block */
.rb-shared { margin-left: auto; font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.03em; background: var(--primary-tint); color: var(--primary); padding: 3px 7px; border-radius: 999px; }

/* right-aligned header actions (Shared badge + Edit pencil) */
.rb-actions { margin-left: auto; display: flex; align-items: center; gap: 6px; }
.rb-actions .rb-shared { margin-left: 0; }
.rb-edit { display: inline-flex; align-items: center; justify-content: center; width: 28px; height: 28px; padding: 0; border: none; background: transparent; color: var(--muted-foreground); border-radius: 8px; cursor: pointer; }
.rb-edit:active { background: var(--muted); }
.rb-edit svg { width: 16px; height: 16px; }

/* ============ Pass 14 - record-form UX fixes ============ */
/* sheets scroll internally without a classic scrollbar squaring the rounded top corners (mobile feel) */
.sheet { scrollbar-width: none; }
.sheet::-webkit-scrollbar { display: none; }

/* in-sheet catalog combobox (replaces native <datalist>, which popped outside the device frame) */
.combo { position: relative; }
.combo-menu {
  display: none; margin-top: 6px; max-height: 200px; overflow-y: auto;
  background: var(--popover); color: var(--popover-foreground);
  border: 1px solid var(--border); border-radius: var(--radius-field); padding: 4px;
}
.combo-menu.open { display: block; }
.combo-opt {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 10px 10px; border-radius: 8px; font-size: 15px; cursor: pointer; min-height: 40px;
}
.combo-opt:active, .combo-opt:hover { background: var(--secondary); }
.combo-badge { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.03em; background: var(--primary-tint); color: var(--primary); padding: 2px 7px; border-radius: 999px; flex: 0 0 auto; }

/* Add-records items that are already on the visit are greyed + disabled (matches the web app) */
.sheet-list button.is-done { opacity: 0.5; cursor: default; }
.sheet-list button.is-done .al-label::after { content: ' · Added'; color: var(--muted-foreground); font-size: 12px; font-weight: 600; }

/* Integrations (Pass 11) - intro heading, data lists, connect status; reuses detail-card/switch-row/btn/chip */
.int-intro { padding: 12px 18px 6px; }
.int-intro h2 { font-size: 17px; font-weight: 700; margin: 0; }
.int-intro p { font-size: 13.5px; color: var(--muted-foreground); line-height: 1.45; margin: 5px 0 0; }
.int-list { list-style: none; margin: 2px 0; padding: 0; }
.int-list li { display: flex; align-items: flex-start; gap: 10px; padding: 11px 0; border-bottom: 1px solid var(--border); font-size: 14.5px; }
.int-list li:last-child { border-bottom: none; }
.int-list li svg { width: 18px; height: 18px; color: var(--primary); flex: 0 0 auto; margin-top: 1px; }
.int-status { display: flex; justify-content: center; padding: 4px 0 2px; }
