/* Open Clinic CRM: one stylesheet.
 *
 * Art direction: tasteskill v2 app sheet "Framed sheet" (seed 1611487514, kind smb-admin, light; brand
 * palette and type kept; crm/.taste-skill/app/direction.json, UI.md "Look").
 *   Idea        A clinic's day is a chair-by-chair board. The one thing only this product has is that
 *               board drawn as a per-doctor day strip with a live "now" line, and the Came / No-show tick
 *               as the one job a person does; the automations fill everything else.
 *   Composition One butter L-frame (sidebar + 48px top bar, no rule between them) holds the chrome; the
 *               work sits on a cream sheet inset 8px from the window's right and bottom, 1px edge, 16px
 *               corners, no shadow. Frame, sheet, card: never a fourth level. One question per screen, its
 *               answer biggest and first; lists are rules and alignment, money right-aligned.
 *   Type        Karla for everything, tabular figures for phones, times and money; Fraunces only for page
 *               titles and the Summary figures. Sentence-case labels, no tracked capitals, no monospace.
 *   Palette     butter #FBF5DF frame, cream #FFFEF7 sheet, butter-3 #EDE2BC edges, ink #14120F, muted
 *               #564F45 / #6E655A. Orange #C9541F (#A8431A for small text) only on the mark, the 2px active
 *               underline, the one primary button, the main data series and the selected state; under 3%.
 *               Status is marks (dot, fill, outline, hatch, dashed) with words, never panel fills.
 *   Grid        Desktop: 228px sidebar + sheet; the sheet's content has 24px padding and a 1200px measure;
 *               KPI cells and list rows share the sheet's two edges (24 + content + 24). Phone: the frame
 *               disappears, the sheet is the screen, 16px margins, a 48px top bar and the bottom tab bar.
 * Logical properties throughout, so Arabic (dir=rtl) is a flip, not a rewrite. */

:root {
  --frame: #FBF5DF;
  --sheet: #FFFEF7;
  --edge: #EDE2BC;
  --rule: #ECE6D6;
  --hover: rgba(20, 18, 15, .04);
  --press: rgba(20, 18, 15, .07);
  --field: #FFFFFF;
  --field-edge: #D9CDA4;
  --ink: #14120F;
  --ink-2: #564F45;
  --ink-3: #6E655A;
  --accent: #C9541F;
  --accent-ink: #A8431A;
  --green: #0B4F3F;
  --green-lit: #15A183;
  --green-pale: #DCEDE6;
  --red: #A3261C;
  --red-dot: #D2463A;
  --amber: #7A5200;
  --amber-dot: #D59B1E;
  --radius: 16px;
  --r: 8px;
  --sans: 'Karla', 'Segoe UI', system-ui, sans-serif;
  --serif: 'Fraunces', Georgia, serif;
  --side-w: 228px;
  --top-h: 48px;
  --tab-h: 62px;
  --pad: 24px;
  --ease: cubic-bezier(.2, .8, .2, 1);
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }
html { background: var(--frame); -webkit-text-size-adjust: 100%; }
html, body { margin: 0; min-height: 100%; }
body {
  color: var(--ink); background: var(--frame);
  font-family: var(--sans); font-size: 15px; line-height: 1.5;
  font-variant-numeric: tabular-nums; -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
body.has-panel { overflow: hidden; }
a { color: var(--accent-ink); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
button { font: inherit; color: inherit; cursor: pointer; }
button:disabled { cursor: default; }
a, button, label, summary, select { touch-action: manipulation; }
::selection { background: var(--ink); color: var(--frame); }
:focus { outline: none; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
h1, h2, h3 { margin: 0; letter-spacing: -.005em; }
p { margin: 0; }
small { font-size: 13px; }
.num { font-variant-numeric: tabular-nums; letter-spacing: 0; }
.muted { color: var(--ink-3); }
.small { font-size: 13px; }
.pad { padding: 14px var(--pad); }
.pre { white-space: pre-line; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; inset-inline-start: 8px; top: -60px; z-index: 100; background: var(--ink); color: var(--frame); padding: 10px 14px; border-radius: var(--r); }
.skip:focus { top: 8px; }
[hidden] { display: none !important; }

.ic { width: 18px; height: 18px; flex: 0 0 auto; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.ic .fill { fill: currentColor; stroke: none; }
.ic .thin { stroke-width: 1.2; }
.ic.tiny { width: 14px; height: 14px; }
.logo { width: 24px; height: 24px; color: var(--ink); flex: 0 0 auto; }
.logo circle { fill: var(--accent); }

/* ---------- the frame ---------- */

.shell { min-height: 100vh; min-height: 100dvh; }
.main { min-width: 0; }
.rail { display: none; }
.topbar {
  position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 12px;
  height: calc(var(--top-h) + env(safe-area-inset-top)); padding: env(safe-area-inset-top) 16px 0; background: var(--frame);
}
.top-brand { display: flex; align-items: center; gap: 9px; color: var(--ink); min-width: 0; }
.top-brand:hover { text-decoration: none; }
.top-brand b { font-weight: 700; font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top-search { display: none; }
.top-time { margin-inline-start: auto; color: var(--ink-3); font-size: 13px; white-space: nowrap; }

/* phone: the sheet is the screen */
.view {
  display: block; outline: none; min-height: calc(100dvh - var(--top-h));
  background: var(--sheet); border-top: 1px solid var(--edge);
  padding: 16px 16px calc(var(--tab-h) + 32px + env(safe-area-inset-bottom));
}

.tabbar {
  position: fixed; inset-inline: 0; bottom: 0; z-index: 40;
  display: grid; grid-auto-flow: column; grid-auto-columns: 1fr;
  height: calc(var(--tab-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
  background: var(--frame); border-top: 1px solid var(--edge);
}
.tabbar a {
  position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  color: var(--ink-3); font-size: 11.5px; font-weight: 600; min-height: 48px; min-width: 0;
}
.tabbar a:hover { text-decoration: none; color: var(--ink); }
.tabbar a .ic { width: 22px; height: 22px; }
.tabbar a.on { color: var(--ink); }
.tabbar a.on::after { content: ''; position: absolute; bottom: 6px; inset-inline: 30%; height: 2px; border-radius: 2px; background: var(--accent); }
.tabbar span:not(.nav-badge) { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.nav-badge { position: absolute; top: 5px; inset-inline-start: calc(50% + 6px); }
.badge {
  display: inline-grid; place-items: center; min-width: 19px; height: 19px; padding: 0 5px;
  border-radius: 10px; background: var(--ink); color: var(--frame); font: 700 11px/1 var(--sans);
}

@media (min-width: 960px) {
  .shell { display: grid; grid-template-columns: var(--side-w) minmax(0, 1fr); }
  .tabbar { display: none; }
  .rail { display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; padding: 12px 10px 14px; overflow-y: auto; background: var(--frame); }
  .topbar { padding: 0 8px 0 0; }
  .top-brand { display: none; }
  .top-search {
    display: flex; align-items: center; gap: 8px; width: min(548px, 60%); margin: 0 auto; height: 32px;
    background: var(--field); border: 1px solid var(--edge); border-radius: var(--r); padding: 0 6px 0 10px; color: var(--ink-3);
  }
  .top-search:focus-within { border-color: var(--ink-3); outline: 2px solid var(--accent); outline-offset: 1px; }
  .top-search input, .top-search input[type=search] { flex: 1; border: 0; min-width: 0; background: none; border: 0; color: var(--ink); font: inherit; font-size: 14px; height: 100%; min-height: 0; outline: none; padding: 0; }
  .top-search input::-webkit-search-cancel-button { display: none; }
  .top-search kbd { font: 600 11px var(--sans); color: var(--ink-3); border: 1px solid var(--edge); border-radius: 4px; padding: 0 5px; }
  .top-time { margin-inline-start: 0; position: absolute; inset-inline-end: 20px; }
  .view {
    min-height: calc(100vh - var(--top-h) - 8px); margin: 0 8px 8px 0; border: 1px solid var(--edge); border-radius: var(--radius);
    padding: 20px var(--pad) 40px;
  }
  .view > * { max-width: 1200px; margin-inline: auto; }
  [dir=rtl] .view { margin: 0 0 8px 8px; }
}

/* sidebar */
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px 18px; color: var(--ink); min-height: 44px; }
.brand:hover { text-decoration: none; }
.brand .logo { width: 26px; height: 26px; }
.brand-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
.brand-text b { font-weight: 700; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-text em { font-style: normal; font-size: 12.5px; color: var(--ink-3); }
.rail-nav, .rail-group { display: flex; flex-direction: column; gap: 2px; }
.rail-group { margin-top: 26px; }
.rail-label { font-size: 12.5px; color: var(--ink-3); padding: 0 12px 6px; margin: 0; }
.rail a { display: flex; align-items: center; gap: 10px; min-height: 36px; padding: 0 12px; border-radius: var(--r); color: var(--ink-2); font-size: 14px; font-weight: 500; }
.rail a:hover { background: var(--hover); color: var(--ink); text-decoration: none; }
.rail a.on { background: rgba(20, 18, 15, .06); color: var(--ink); font-weight: 600; }
.rail .nav-badge { position: static; margin-inline-start: auto; }
.rail-foot { margin-top: auto; display: flex; align-items: center; gap: 10px; padding: 12px 4px 0; }
.rail-foot .who { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; flex: 1; }
.rail-foot .who b { font-size: 13.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rail-foot .who em { font-style: normal; font-size: 12.5px; color: var(--ink-3); }

/* ---------- title row and sections ---------- */

.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px 20px; margin: 4px 0 20px; }
.page-title { min-width: 0; }
.page-head h1 { font-family: var(--serif); font-weight: 500; font-size: 26px; line-height: 1.15; letter-spacing: -.015em; }
.page-head .sub { color: var(--ink-2); margin-top: 4px; font-size: 15px; max-width: 64ch; }
.page-tools { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
@media (min-width: 960px) { .page-head h1 { font-size: 28px; } }

.section-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 4px 14px; margin: 28px 0 10px; }
.section-head h2 { font-size: 16px; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.section-head .muted { font-size: 13.5px; }
.section-head.in-card { margin: 0; padding: 14px 18px 10px; border-bottom: 1px solid var(--rule); }
.count { font-weight: 600; font-size: 13px; color: var(--ink-3); }
.subsection h3 { font-size: 14.5px; font-weight: 700; margin: 22px 0 8px; display: flex; align-items: center; gap: 8px; }
.crumb { margin-bottom: 8px; }
.back { display: inline-flex; align-items: center; gap: 6px; color: var(--ink-2); min-height: 40px; font-weight: 500; }
.back .ic { width: 16px; height: 16px; }

/* ---------- cards ---------- */

.card { background: var(--sheet); border: 1px solid var(--edge); border-radius: 12px; min-width: 0; }
.card + .card, .card + section, section + .card { margin-top: 16px; }

/* ---------- buttons: flat, one radius (8px) ---------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 40px; padding: 0 16px; border-radius: var(--r);
  background: var(--sheet); color: var(--ink); border: 1px solid var(--field-edge);
  font-weight: 600; font-size: 14px; white-space: nowrap; transition: background .15s, border-color .15s;
}
.btn:hover { background: var(--hover); border-color: var(--ink-3); text-decoration: none; }
.btn:active { background: var(--press); }
.btn .ic { width: 17px; height: 17px; }
.btn-primary { background: #B44A1B; color: #FFFFFF; border-color: #B44A1B; }
.btn-primary:hover { background: #983D15; border-color: #983D15; }
.btn-primary:active { background: #8E3815; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--ink-2); }
.btn-ghost:hover { background: var(--hover); border-color: transparent; color: var(--ink); }
.btn-danger { background: var(--sheet); color: var(--red); border-color: rgba(163, 38, 28, .45); }
.btn-danger:hover { background: rgba(163, 38, 28, .06); border-color: var(--red); }
.btn-sm { min-height: 34px; padding: 0 12px; font-size: 13.5px; }
.btn-block { width: 100%; }
.btn:disabled, .btn.is-busy { opacity: .5; pointer-events: none; }
.icon-btn { display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: var(--r); background: transparent; border: 0; color: var(--ink-2); flex: 0 0 auto; }
.icon-btn:hover { background: var(--hover); color: var(--ink); text-decoration: none; }
.link-btn { background: none; border: 0; padding: 10px 0; color: var(--accent-ink); font-weight: 600; text-align: start; min-height: 44px; }
.link-btn:hover { text-decoration: underline; text-underline-offset: 3px; }
.as-link { all: unset; box-sizing: border-box; cursor: pointer; }
.as-link:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
.as-link:disabled { cursor: default; }
a.as-link:hover { text-decoration: none; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.fab {
  position: fixed; inset-inline-end: 16px; bottom: calc(var(--tab-h) + 16px + env(safe-area-inset-bottom)); z-index: 35;
  width: 56px; height: 56px; border-radius: 50%; display: grid; place-items: center;
  background: #B44A1B; color: #FFFFFF; border: 0; box-shadow: 0 6px 18px rgba(20, 18, 15, .22); /* taste-skill-ignore: floats over the list */
}
.fab .ic { width: 24px; height: 24px; stroke-width: 2.2; }
.page-tools .btn-primary { display: none; }
@media (min-width: 960px) { .fab { display: none; } .page-tools .btn-primary { display: inline-flex; } }
@media (pointer: coarse) {
  .btn, .btn-sm { min-height: 44px; }
  .icon-btn { width: 44px; height: 44px; }
}

/* ---------- tabs: words with a 2px underline ---------- */

.tabs { display: flex; flex-wrap: nowrap; gap: 4px; overflow-x: auto; max-width: 100%; scrollbar-width: none; border-bottom: 1px solid var(--rule); }
.tabs::-webkit-scrollbar { display: none; }
.tabs a, .tabs button, .tabs .tab-cal {
  position: relative; display: inline-flex; align-items: center; justify-content: center; gap: 6px; flex: 0 0 auto;
  min-height: 40px; padding: 0 10px; border: 0; background: none; color: var(--ink-3); font-size: 14px; font-weight: 600; white-space: nowrap;
}
.tabs a:hover, .tabs button:hover, .tabs .tab-cal:hover { color: var(--ink); text-decoration: none; }
.tabs .on { color: var(--ink); }
.tabs .on::after { content: ''; position: absolute; inset-inline: 4px; bottom: 0; height: 2px; border-radius: 2px; background: var(--accent); }
.tabs-sm a, .tabs-sm button { min-height: 36px; font-size: 13.5px; }
/* "Pick a day": one Tab stop (the button); the date input under it only anchors the browser's picker */
.tabs .tab-cal { padding: 0; }
.tab-cal button { cursor: pointer; border-radius: 6px; }
.tab-cal input { position: absolute; inset: 0; opacity: 0; width: 100%; height: 100%; border: 0; padding: 0; min-height: 0; pointer-events: none; }
.tab-cal:has(input:focus) { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
@media (pointer: coarse) { .tabs a, .tabs button, .tabs .tab-cal { min-height: 44px; } }

/* ---------- status marks: a shape and a word, never a filled pill ---------- */

.chips { display: inline-flex; flex-wrap: wrap; gap: 4px 12px; }
.mark { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 500; color: var(--ink-2); white-space: nowrap; }
.mark i { width: 10px; height: 10px; border-radius: 50%; background: var(--ink-3); flex: 0 0 auto; }
.mark-green i { background: var(--green-lit); }
.mark-amber i { background: var(--amber-dot); }
.mark-amber { color: var(--amber); }
.mark-red i { background: var(--red-dot); }
.mark-red { color: var(--red); }
.mark-accent i { background: var(--accent); }
.mark-accent { color: var(--accent-ink); font-weight: 600; }
.mark-ink i { background: var(--ink-3); }
.mark-muted i { background: transparent; border: 1.5px solid var(--ink-3); }
/* visit marks: the same shapes the day strip draws, scaled down */
.mark-confirmed i, .mark-unconfirmed i, .mark-attended i, .mark-noshow i, .mark-cancelled i { width: 14px; height: 9px; border-radius: 3px; }
.mark-confirmed i { background: var(--green-pale); border: 1px solid #A9CFC0; }
.mark-unconfirmed i { background: transparent; border: 1.5px solid var(--ink-2); }
.mark-attended i { background: var(--ink); }
.mark-noshow i { background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='5' height='5'%3E%3Cpath d='M-1 1l2-2M0 5l5-5M4 6l2-2' stroke='%23D2463A' stroke-width='1'/%3E%3C/svg%3E"); border: 1px solid var(--red-dot); }
.mark-noshow { color: var(--red); }
.mark-cancelled i { background: transparent; border: 1.5px dashed var(--ink-3); }
.mark-cancelled { color: var(--ink-3); }
.dot { width: 8px; height: 8px; border-radius: 50%; flex: 0 0 auto; background: var(--ink-3); }
.dot-red { background: var(--red-dot); }
.dot-amber { background: var(--amber-dot); }
.dot-green { background: var(--green-lit); }
.dot-ink { background: #B6AC98; }

/* ---------- lists: rules and alignment ---------- */

.list { display: flex; flex-direction: column; }
.row {
  display: flex; align-items: center; gap: 12px; min-height: 56px; padding: 10px 18px;
  border-top: 1px solid var(--rule); color: var(--ink); background: none; border-inline: 0; border-bottom: 0;
  text-align: start; width: 100%; min-width: 0;
}
.list > .row:first-child, .card > .row:first-child { border-top: 0; }
a.row:hover, button.row:hover { background: var(--hover); text-decoration: none; }
.row-main { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.row-main b { font-weight: 600; overflow-wrap: anywhere; }
.row-main small { color: var(--ink-3); overflow-wrap: anywhere; }
.row-main .chips { margin-top: 3px; }
.row-side { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; text-align: end; color: var(--ink-3); flex: 0 0 auto; max-width: 46%; }
.row-side .next { color: var(--ink-2); }
.row-act { flex: 0 0 auto; display: flex; align-items: center; gap: 6px; }
.row-ic { display: grid; place-items: center; width: 32px; height: 32px; color: var(--ink-3); flex: 0 0 auto; }
.row .chev { color: var(--ink-3); width: 16px; }
.row-more { justify-content: center; color: var(--accent-ink); font-weight: 600; font-size: 14px; cursor: pointer; min-height: 48px; }
.row.is-off { opacity: .55; }
.avatar {
  display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: 50%; flex: 0 0 auto;
  background: #F3EAD0; color: var(--ink-2); font-weight: 700; font-size: 13.5px; text-transform: uppercase;
}
.avatar .ic { width: 16px; height: 16px; color: var(--ink-3); }
.avatar.sm { width: 26px; height: 26px; font-size: 12px; }
.avatar.lg { width: 52px; height: 52px; font-size: 18px; }
.phone { white-space: nowrap; }

/* ---------- states ---------- */

.empty { display: flex; flex-direction: column; align-items: flex-start; gap: 10px; padding: 18px; color: var(--ink-2); }
.empty p { max-width: 56ch; }
.empty-ic { display: none; }
.empty.error p { color: var(--red); }
.empty .btn { min-height: 36px; }
.skeleton { padding: 4px 0; }
.sk-row { display: flex; flex-direction: column; gap: 8px; padding: 14px 18px; border-top: 1px solid var(--rule); }
.sk-row:first-child { border-top: 0; }
.sk { display: block; height: 12px; border-radius: 4px; background: #F1E9D2; }
.sk-a { width: 40%; } .sk-b { width: 66%; height: 10px; }
.sk-row:nth-child(2n) .sk-a { width: 30%; } .sk-row:nth-child(3n) .sk-b { width: 52%; }
.sk-kpi .sk-row { padding: 18px; } .sk-kpi .sk-a { height: 24px; width: 26%; }
.boot { display: grid; place-items: center; min-height: 50vh; }
.boot-mark { width: 10px; height: 10px; border-radius: 50%; background: var(--accent); }
.boot-error { display: grid; gap: 14px; justify-items: start; padding: 40px 0; }

/* ---------- forms ---------- */

.form { display: flex; flex-direction: column; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; border: 0; padding: 0; margin: 0; }
.field > span, .field legend, .notes label { font-size: 13.5px; font-weight: 600; color: var(--ink-2); display: flex; align-items: center; gap: 8px; padding: 0; }
.field .opt { font-style: normal; font-weight: 400; color: var(--ink-3); }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
input[type=text], input[type=email], input[type=password], input[type=tel], input[type=search], input[type=number], input[type=date], input[type=month], input:not([type]), select, textarea {
  width: 100%; min-height: 44px; padding: 9px 12px; font: inherit; font-size: 16px; color: var(--ink);
  background: var(--field); border: 1px solid var(--field-edge); border-radius: var(--r); transition: border-color .15s;
}
textarea { resize: vertical; line-height: 1.45; }
select { appearance: none; -webkit-appearance: none; padding-inline-end: 34px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%23564F45' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E"); background-position: calc(100% - 13px) 50%; background-size: 10px 6px; background-repeat: no-repeat; }
[dir=rtl] select { background-position: 13px 50%; }
input:hover, select:hover, textarea:hover { border-color: #C2B48A; }
input:focus, select:focus, textarea:focus { border-color: var(--ink-2); outline: 2px solid var(--accent); outline-offset: 1px; }
input::placeholder, textarea::placeholder { color: #8A8073; }
.hint { font-size: 13px; color: var(--ink-3); }
.form-error { color: var(--red); background: #FBEDEA; border-inline-start: 3px solid var(--red-dot); padding: 9px 12px; border-radius: 4px; font-size: 14px; }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; flex-wrap: wrap; margin-top: 4px; }
.inline-form { display: flex; gap: 10px; flex-wrap: wrap; padding: 4px 18px 18px; }
.inline-form input { flex: 1 1 220px; }
.lead { color: var(--ink-2); }
.pills { display: flex; flex-wrap: wrap; gap: 8px; }
.pill-radio { position: relative; }
.pill-radio input { position: absolute; opacity: 0; inset: 0; margin: 0; }
.pill-radio span { display: inline-flex; align-items: center; min-height: 44px; padding: 0 14px; border-radius: var(--r); border: 1px solid var(--field-edge); background: var(--field); color: var(--ink-2); font-weight: 600; cursor: pointer; }
.pill-radio input:checked + span { border: 2px solid var(--accent); padding: 0 13px; color: var(--ink); }
.pill-radio input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.amount-field input { font-size: 24px; font-weight: 600; min-height: 54px; }

.switch { display: inline-flex; align-items: center; gap: 10px; background: none; border: 0; padding: 4px 0; min-height: 44px; color: var(--ink-2); font-weight: 600; font-size: 14px; }
.switch i { position: relative; width: 40px; height: 22px; border-radius: 22px; background: #E4DAC0; transition: background .15s; flex: 0 0 auto; }
.switch i::after { content: ''; position: absolute; top: 3px; inset-inline-start: 3px; width: 16px; height: 16px; border-radius: 50%; background: #FFFFFF; transition: transform .15s var(--ease); }
.switch.on i { background: var(--green); }
.switch.on i::after { transform: translateX(18px); }
[dir=rtl] .switch.on i::after { transform: translateX(-18px); }
.switch.danger.on i { background: var(--red); }
.switch.on { color: var(--ink); }
.switch:disabled { opacity: .55; }

.search-bar { position: sticky; top: var(--top-h); z-index: 20; margin: 0 -16px 4px; padding: 8px 16px 10px; background: var(--sheet); }
@media (min-width: 960px) { .search-bar { margin: 0 0 4px; padding: 8px 0 10px; } }
.search-bar .hint { margin: 8px 2px 0; }
.search { display: flex; align-items: center; gap: 10px; padding: 0 14px; min-height: 52px; border-radius: 12px; background: var(--field); border: 1px solid var(--field-edge); color: var(--ink-3); }
.search:focus-within { border-color: var(--ink-2); outline: 2px solid var(--accent); outline-offset: 1px; }
.search .ic { width: 20px; height: 20px; }
.search input { flex: 1; min-width: 0; border: 0 !important; background: none !important; outline: none !important; font-size: 17px; padding: 0; min-height: 50px; }

/* ---------- toast ---------- */

.toasts { position: fixed; z-index: 90; inset-inline: 12px; bottom: calc(var(--tab-h) + 12px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; }
@media (min-width: 960px) { .toasts { bottom: 24px; inset-inline-start: calc(var(--side-w) + 12px); } }
.toast {
  pointer-events: auto; display: flex; align-items: center; gap: 8px; max-width: min(560px, 100%);
  padding: 6px 6px 6px 16px; border-radius: 10px; background: var(--ink); color: var(--frame); font-size: 14.5px;
  box-shadow: 0 10px 28px rgba(20, 18, 15, .22); /* taste-skill-ignore: a toast floats */
  transform: translateY(8px); opacity: 0; transition: transform .18s var(--ease), opacity .18s;
}
.toast.in { transform: none; opacity: 1; }
.toast-msg { flex: 1; min-width: 0; }
.toast-error { background: #6E1A13; }
.toast-undo { background: none; border: 0; color: #F2B08F; font-weight: 700; padding: 0 12px; min-height: 40px; border-radius: 6px; }
.toast-undo:hover { background: rgba(255, 255, 255, .1); }
.toast-x { background: none; border: 0; color: rgba(251, 245, 223, .75); display: grid; place-items: center; width: 36px; height: 36px; border-radius: 6px; }
.toast-x .ic { width: 15px; height: 15px; }
@media (pointer: coarse) { .toast-undo, .toast-x { min-height: 44px; min-width: 44px; } }

/* ---------- panel: bottom sheet on phone, side panel on desktop ---------- */

.panel-wrap { position: fixed; inset: 0; z-index: 70; }
.panel-scrim { position: absolute; inset: 0; background: rgba(20, 18, 15, .42); opacity: 0; transition: opacity .2s; }
.panel {
  position: absolute; inset-inline: 0; bottom: 0; max-height: 92dvh; display: flex; flex-direction: column;
  border-radius: 16px 16px 0 0; background: var(--sheet); border-top: 1px solid var(--edge);
  transform: translateY(100%); transition: transform .24s var(--ease); padding-bottom: env(safe-area-inset-bottom);
}
.panel-wrap.open .panel { transform: none; }
.panel-wrap.open .panel-scrim { opacity: 1; }
.panel-grip { width: 36px; height: 4px; border-radius: 4px; background: #DDD1AE; margin: 8px auto 0; flex: 0 0 auto; }
.panel-head { display: flex; align-items: center; gap: 10px; padding: 4px 8px 4px 18px; min-height: 52px; border-bottom: 1px solid var(--rule); flex: 0 0 auto; }
.panel-title { flex: 1; min-width: 0; font-weight: 700; font-size: 17px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.panel-body { overflow-y: auto; padding: 16px 18px 24px; overscroll-behavior: contain; }
.panel-patient .panel-body { padding: 14px 14px 24px; }
@media (min-width: 960px) {
  .panel { inset: 8px 8px 8px auto; width: min(560px, calc(100vw - 16px)); max-height: none; border-radius: 16px; border: 1px solid var(--edge); transform: translateX(calc(100% + 16px)); box-shadow: 0 18px 48px rgba(20, 18, 15, .18); /* taste-skill-ignore: a dialog panel floats */ }
  [dir=rtl] .panel { inset: 8px auto 8px 8px; transform: translateX(calc(-100% - 16px)); }
  .panel-wide { width: min(720px, calc(100vw - 16px)); }
  .panel-small { width: min(460px, calc(100vw - 16px)); }
  .panel-grip { display: none; }
}

/* ---------- Today ---------- */

.needs { margin-bottom: 4px; }
.needs-main > .section-head:first-child { margin-top: 0; }
.needs-rail .subsection:first-child h3 { margin-top: 28px; }
@media (min-width: 1100px) {
  .today-top { display: grid; grid-template-columns: minmax(0, 1fr) 384px; gap: 24px; align-items: start; }
  .needs-rail .subsection:first-child h3 { margin-top: 2px; margin-bottom: 10px; line-height: 1.6; }
}
.need .row-main small { -webkit-line-clamp: 2; display: -webkit-box; -webkit-box-orient: vertical; overflow: hidden; }
.need.is-hidden { display: none; }
.need.is-done { opacity: .45; }
.need.is-done .row-act { pointer-events: none; }

/* the signature: the day per doctor, open hours across, now as an orange line */
.strip-sec .section-head { align-items: center; }
.legend { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 13px; color: var(--ink-2); }
.legend li { display: inline-flex; align-items: center; gap: 6px; }
.legend .sw { display: inline-block; width: 16px; height: 10px; border-radius: 3px; }
.strip-card { overflow-x: auto; }
.strip { position: relative; min-width: 620px; padding: 6px 16px 12px 0; }
.strip-row { display: grid; grid-template-columns: 150px minmax(0, 1fr); align-items: center; min-height: 40px; }
.strip-who { padding: 0 14px 0 16px; font-weight: 600; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.strip-track { position: relative; height: 40px; }
.strip-row + .strip-row:not(.strip-hours) .strip-track { border-top: 1px solid var(--rule); }
.strip-hours .strip-track { height: 26px; }
.hr { position: absolute; top: 0; height: 9999px; border-inline-start: 1px solid var(--rule); pointer-events: none; }
.strip-card .strip { overflow: hidden; }
.hr em { position: absolute; top: 4px; inset-inline-start: 4px; font-style: normal; font-size: 12px; color: var(--ink-3); white-space: nowrap; }
.strip-hours .hr:last-of-type em { display: none; }
.now { position: absolute; top: 0; height: 9999px; z-index: 2; border-inline-start: 1px solid var(--accent); pointer-events: none; }
.now em { position: absolute; top: 4px; inset-inline-start: 4px; font-style: normal; font-size: 12px; font-weight: 700; color: var(--accent-ink); white-space: nowrap; background: var(--sheet); padding-inline-end: 4px; }
.now-full { display: none; }
.hr em.is-covered { visibility: hidden; }
.bar {
  position: absolute; top: 9px; height: 22px; border-radius: 4px; padding: 0 6px; overflow: hidden; border: 0; z-index: 3;
  display: flex; align-items: center; font: inherit; font-size: 12px; font-weight: 600; color: var(--ink); text-align: start; cursor: pointer; min-width: 6px;
}
.bar span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar:hover { filter: brightness(.95); }
.bar-confirmed { background: var(--green-pale); border: 1px solid #A9CFC0; }
.bar-unconfirmed { background: var(--sheet); border: 1.5px solid var(--ink-2); }
.bar-attended { background: var(--ink); color: var(--frame); }
.bar-noshow { background: var(--sheet) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='5' height='5'%3E%3Cpath d='M-1 1l2-2M0 5l5-5M4 6l2-2' stroke='%23D2463A' stroke-width='1'/%3E%3C/svg%3E"); border: 1px solid var(--red-dot); color: var(--red); }
.bar-cancelled { background: var(--sheet); border: 1.5px dashed var(--ink-3); color: var(--ink-3); }
.bar-person, .legend .sw.bar-person { border-inline-start: 3px solid var(--accent); }

.prov-grid { display: grid; gap: 16px; }
@media (min-width: 1100px) { .prov-grid { grid-template-columns: repeat(auto-fit, minmax(440px, 1fr)); align-items: start; } }
.prov-grid .card + .card { margin-top: 0; }
.prov-head { display: flex; align-items: center; gap: 10px; padding: 12px 18px; border-bottom: 1px solid var(--rule); }
.prov-head h3 { font-size: 15px; font-weight: 700; flex: 1; min-width: 0; }
.prov-head .muted { font-size: 13px; }
.free { justify-content: flex-start; font-size: 14px; }
.booking { display: grid; grid-template-columns: 62px minmax(0, 1fr) auto; grid-template-areas: "time main icons" "time act act"; align-items: start; gap: 8px 10px; padding: 12px 10px 12px 16px; }
.b-time { grid-area: time; display: flex; flex-direction: column; padding-top: 1px; }
.b-time b { font-size: 14px; font-weight: 700; color: var(--ink); white-space: nowrap; }
.b-time small { color: var(--ink-3); font-size: 12.5px; }
.booking .row-main { grid-area: main; }
.b-act { grid-area: act; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.b-icons { grid-area: icons; display: inline-flex; margin-top: -6px; }
.booking.is-cancelled .row-main b { text-decoration: line-through; text-decoration-color: rgba(20, 18, 15, .35); color: var(--ink-3); }
@media (min-width: 640px) {
  .booking { grid-template-columns: 72px minmax(0, 1fr) auto auto; grid-template-areas: "time main act icons"; align-items: center; padding: 10px 14px 10px 18px; }
  .b-icons { margin-top: 0; }
}
.seg { display: inline-flex; border: 1px solid var(--field-edge); border-radius: var(--r); overflow: hidden; background: var(--field); }
.seg button { display: inline-flex; align-items: center; gap: 5px; min-height: 34px; padding: 0 12px; border: 0; background: none; color: var(--ink-2); font-size: 13.5px; font-weight: 600; }
.seg button + button { border-inline-start: 1px solid var(--field-edge); }
.seg button .ic { width: 15px; height: 15px; }
.seg button:hover { background: var(--hover); color: var(--ink); }
.seg button.on.yes { background: var(--ink); color: var(--frame); }
.seg button.on.no { color: var(--red); outline: 2px solid var(--red-dot); outline-offset: -2px; }
@media (pointer: coarse) { .seg button { min-height: 44px; } }
.now-line { display: flex; align-items: center; gap: 10px; padding: 0 18px; height: 24px; color: var(--accent-ink); font-size: 12.5px; font-weight: 700; }
.now-line::after { content: ''; flex: 1; height: 1px; background: var(--accent); }
.now-line + .row { border-top: 0; }

/* ---------- Patients ---------- */

.results .section-head { margin-top: 12px; }
.pat-row { gap: 14px; }
.pat-row .row-side small { white-space: nowrap; }
@media (max-width: 520px) { .pat-row .row-side { display: none; } }
.pp { display: flex; flex-direction: column; gap: 16px; }
.pp .card + .card { margin-top: 0; }
.pp-head { padding: 18px; display: flex; flex-direction: column; gap: 14px; }
.pp-id { display: flex; gap: 14px; align-items: flex-start; }
.pp-name { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.pp-name h1 { font-weight: 700; font-size: 22px; line-height: 1.2; overflow-wrap: anywhere; }
.pp-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 8px; color: var(--ink-2); font-size: 14.5px; }
.pp-meta .sep { color: #B6AC98; }
.pp-edit { margin-top: -4px; }
.pp-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.pp-actions .btn { flex: 1 1 auto; }
.pp-actions .btn-ghost { flex: 0 0 auto; width: 44px; padding: 0; border: 1px solid var(--field-edge); }
@media (min-width: 640px) { .pp-actions .btn { flex: 0 0 auto; } }
.pp-dnc { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 14px; padding-top: 10px; border-top: 1px solid var(--rule); }
.pp-dnc small { flex: 1 1 200px; color: var(--ink-3); }
.pp-grid { display: grid; gap: 16px; }
.pp-grid > * { min-width: 0; }
@media (min-width: 1100px) {
  .pp:not(.in-sheet) .pp-grid { grid-template-columns: minmax(0, 1fr) 340px; align-items: start; }
  .pp:not(.in-sheet) .pp-facts { order: 2; position: sticky; top: calc(var(--top-h) + 16px); }
}
.visit-card { padding-bottom: 16px; }
.visit-card .section-head.in-card { border-bottom: 0; padding-bottom: 4px; }
.visit-card > p, .visit-card .btn-row { padding: 0 18px; }
.visit-line { font-size: 15px; }
.facts { padding: 4px 0 12px; }
.facts dl { margin: 0; }
.fact { padding: 12px 18px; border-top: 1px solid var(--rule); display: flex; flex-direction: column; gap: 3px; }
.fact:first-child { border-top: 0; }
.fact dt { font-size: 13px; color: var(--ink-3); }
.fact dd { margin: 0; display: flex; flex-direction: column; gap: 3px; align-items: flex-start; }
.fact dd small { color: var(--ink-3); }
.fact .plan + .plan { margin-top: 8px; }
.fact-line { display: flex; flex-direction: column; gap: 2px; align-items: flex-start; }
.fact-line + .fact-line { margin-top: 6px; }
.money-owed { color: var(--amber); }
.notes { padding: 12px 18px 4px; border-top: 1px solid var(--rule); display: flex; flex-direction: column; gap: 6px; }
.notes textarea { min-height: 76px; }
.notes .btn { align-self: flex-start; }
.facts > .link-btn { margin: 4px 18px 0; }
.pp-timeline .section-head.in-card { gap: 8px; }
.pp-timeline .tabs { border-bottom: 0; }
.tl { list-style: none; margin: 0; padding: 2px 0; }
.tl-item { display: grid; grid-template-columns: 28px minmax(0, 1fr); grid-template-areas: "ic time" "ic main"; gap: 1px 12px; padding: 12px 18px; border-top: 1px solid var(--rule); }
.tl-item:first-child { border-top: 0; }
.tl-item time { grid-area: time; font-size: 12.5px; color: var(--ink-3); }
.tl-ic { grid-area: ic; display: grid; place-items: center; width: 28px; height: 28px; color: var(--ink-3); }
.tl-ic .ic { width: 16px; height: 16px; }
.tl-ic.out { color: var(--accent-ink); }
.tl-ic.red { color: var(--red); }
.tl-main { grid-area: main; min-width: 0; display: flex; flex-direction: column; gap: 3px; align-items: flex-start; }
.tl-main b { font-weight: 600; }
.tl-main small { color: var(--ink-3); }
.tl-item.tl-calendar { padding-block: 8px; }
.tl-quiet { padding-top: 5px; }
.msg-body { color: var(--ink); overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; }
.kind { font-style: normal; font-size: 12.5px; color: var(--ink-3); }
.fail { color: var(--red); }
@media (min-width: 720px) {
  .tl-item { grid-template-columns: 112px 28px minmax(0, 1fr); grid-template-areas: "time ic main"; align-items: start; }
  .tl-item time { padding-top: 4px; }
}
.merge-list { margin-top: 12px; border: 1px solid var(--edge); border-radius: 12px; overflow: hidden; }
.merge-list:empty { display: none; }
.merge-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 14px; }
.merge-side, .dup-side { display: flex; flex-direction: column; gap: 2px; padding: 12px 14px; border-radius: 10px; border: 1px solid var(--edge); min-width: 0; }
.merge-side b, .dup-side b { overflow-wrap: anywhere; }

/* ---------- Inbox ---------- */

.inbox { display: grid; gap: 16px; }
.inbox-list { overflow: hidden; }
.inbox-list-head { padding: 16px 18px 0; }
.inbox-list-head h1 { font-family: var(--serif); font-weight: 500; font-size: 26px; }
.inbox-filters { margin: 8px 12px 0; }
.thread-row { align-items: flex-start; gap: 12px; padding: 12px 16px; color: var(--ink); }
.thread-row.on { background: rgba(20, 18, 15, .055); border-inline-start: 2px solid var(--accent); padding-inline-start: 14px; }
.thread-row.is-waiting .thread-top b { font-weight: 700; }
.thread-top { display: flex; align-items: baseline; gap: 8px; }
.thread-top b { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.thread-top time { font-size: 12.5px; color: var(--ink-3); white-space: nowrap; }
.thread-row .last { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; color: var(--ink-2); }
.thread-row .you { color: var(--ink-3); margin-inline-end: 4px; vertical-align: -2px; }
.thread { display: flex; flex-direction: column; min-height: 60vh; overflow: hidden; }
.thread > .empty { margin: auto; align-items: center; text-align: center; }
.thread-head { display: flex; align-items: center; gap: 10px; padding: 8px 10px 8px 16px; border-bottom: 1px solid var(--rule); flex: 0 0 auto; min-height: 56px; }
.thread-who { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.25; }
.thread-who .tn { font-size: 16px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; align-self: flex-start; max-width: 100%; }
.thread-who small { color: var(--ink-3); }
.banner { display: flex; align-items: center; gap: 10px; padding: 9px 16px; font-size: 14px; border-bottom: 1px solid var(--rule); color: var(--ink-2); }
.banner .ic { width: 16px; height: 16px; }
.banner-amber .ic { color: var(--amber-dot); }
.msgs { flex: 1 1 auto; overflow-y: auto; padding: 16px 14px; display: flex; flex-direction: column; gap: 10px; overscroll-behavior: contain; }
.day-sep { display: flex; justify-content: center; margin: 6px 0 0; }
.day-sep span { font-size: 12.5px; font-weight: 600; color: var(--ink-3); }
.msg { display: flex; flex-direction: column; max-width: min(82%, 560px); gap: 3px; }
.msg-in { align-self: flex-start; align-items: flex-start; }
.msg-out { align-self: flex-end; align-items: flex-end; }
.bubble { padding: 9px 13px; border-radius: 14px; white-space: pre-wrap; overflow-wrap: anywhere; font-size: 15.5px; line-height: 1.45; }
.msg-in .bubble { background: #FFFFFF; border: 1px solid var(--edge); border-end-start-radius: 4px; }
.msg-out .bubble { background: #F5ECCB; border: 1px solid #E7D9A8; border-end-end-radius: 4px; }
.msg-meta { display: flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--ink-3); padding: 0 4px; flex-wrap: wrap; }
.msg-meta .tick { color: var(--green-lit); display: inline-flex; }
.msg-meta .sending { font-style: italic; }
.msg-fail { font-size: 13px; color: var(--red); padding: 2px 4px 0; }
.msg.is-failed .bubble { border-color: var(--red-dot); }
.window-note { font-size: 13px; padding: 6px 16px 0; }
.composer { display: flex; align-items: flex-end; gap: 8px; padding: 10px 12px 12px; border-top: 1px solid var(--rule); flex: 0 0 auto; background: var(--sheet); }
.composer textarea { min-height: 44px; max-height: 160px; resize: none; border-radius: 10px; padding: 10px 12px; }
.composer .send { flex: 0 0 auto; width: 44px; padding: 0; min-height: 44px; }
.composer .send span { display: none; }
@media (min-width: 1100px) { .composer .send { width: auto; padding: 0 16px; } .composer .send span { display: inline; } .composer .send .ic { display: none; } }
.composer-note { display: flex; align-items: flex-start; gap: 10px; padding: 14px 16px; border-top: 1px solid var(--rule); color: var(--ink-2); font-size: 14.5px; flex: 0 0 auto; }
.composer-note .ic { width: 18px; height: 18px; color: var(--ink-3); margin-top: 2px; }
@media (max-width: 959px) {
  .inbox.has-thread .thread { position: fixed; z-index: 45; inset: 0; border-radius: 0; border: 0; min-height: 0; margin: 0; background: var(--sheet); padding-top: env(safe-area-inset-top); padding-bottom: env(safe-area-inset-bottom); }
  .inbox.has-thread .thread-head { padding-inline-start: 4px; background: var(--frame); }
}
@media (min-width: 960px) {
  .inbox { grid-template-columns: 340px minmax(0, 1fr); height: calc(100vh - var(--top-h) - 8px - 20px - 22px); }
  .inbox > .card { min-height: 0; margin-top: 0; }
  .inbox-list { display: flex; flex-direction: column; }
  .inbox-list .threads { flex: 1; overflow-y: auto; }
  .thread { min-height: 0; }
  .view-inbox { padding-bottom: 20px; }
}
@media (min-width: 1280px) { .inbox { grid-template-columns: 380px minmax(0, 1fr); } }

/* ---------- KPIs: one container split by dividers ---------- */

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); overflow: hidden; }
.kpis > .skeleton { grid-column: 1 / -1; }
.kpi { padding: 16px 18px; display: flex; flex-direction: column; gap: 2px; min-width: 0; border-inline-end: 1px solid var(--rule); border-bottom: 1px solid var(--rule); margin: 0 -1px -1px 0; }
.kpi-label { font-size: 14px; color: var(--ink-2); font-weight: 600; }
.kpi-num { font-weight: 600; font-size: 24px; line-height: 1.2; overflow-wrap: anywhere; }
.kpi-num small { font-family: var(--sans); font-size: 13px; color: var(--ink-3); margin-inline-start: 4px; font-weight: 500; }
.kpi-read { color: var(--ink-3); font-size: 13px; }
.kpi-amber .kpi-num { color: var(--amber); }
.kpis-sum { grid-template-columns: 1fr; }
@media (min-width: 640px) { .kpis-sum { grid-template-columns: repeat(2, minmax(0, 1fr)); } .kpis-sum .kpi:last-child:nth-child(2n+1) { grid-column: span 2; } }
@media (min-width: 1100px) {
  .kpis-sum { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .kpis-sum .kpi:last-child:nth-child(2n+1) { grid-column: auto; }
  .kpis-sum .kpi:last-child:nth-child(4n+3) { grid-column: span 2; }
  .kpis-sum .kpi:last-child:nth-child(4n+2) { grid-column: span 3; }
}
.kpi-big { padding: 18px 20px 16px; gap: 4px; }
.kpi-big .kpi-num { font-family: var(--serif); font-weight: 400; font-size: 36px; letter-spacing: -.015em; margin: 2px 0; }
.kpi-big .kpi-read { color: var(--ink); font-size: 14.5px; }
.kpi-red .kpi-label::after { content: ''; display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--red-dot); margin-inline-start: 8px; vertical-align: 1px; }
.delta { font-size: 13px; color: var(--ink-3); margin-top: 2px; }
.delta.good { color: var(--green); font-weight: 600; }
.delta.bad { color: var(--red); font-weight: 600; }
.strip-bars { display: flex; align-items: flex-end; gap: 3px; height: 36px; margin-top: 12px; }
.strip-bars .bar-c { flex: 1 1 0; height: 100%; display: flex; align-items: flex-end; min-width: 3px; }
.strip-bars .bar-c i { display: block; width: 100%; border-radius: 2px 2px 0 0; background: #D9CDA4; }
.strip-bars .bar-c:last-child i { background: var(--accent); }
.foot-note { margin-top: 16px; }
.two-col { display: grid; gap: 0 20px; }
@media (min-width: 1100px) { .two-col { grid-template-columns: 1fr 1fr; align-items: start; } }

/* money rows: identity left, amounts right-aligned */
.pay-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "main amt" "main act"; gap: 4px 12px; align-items: center; }
.pay-row .b-time { display: none; }
.pay-row .row-main { grid-area: main; }
.pay-row .amounts { grid-area: amt; display: flex; flex-direction: column; align-items: flex-end; text-align: end; }
.pay-row .row-act { grid-area: act; justify-self: end; }
.amounts b { font-weight: 600; }
.amounts small { color: var(--ink-3); }
.amounts small.ok { color: var(--green); }
.amounts .owed { color: var(--amber); }
.paid-tick { color: var(--green-lit); display: inline-grid; place-items: center; width: 34px; height: 34px; }
@media (min-width: 720px) {
  .pay-row { grid-template-columns: 72px minmax(0, 1fr) 160px 150px; grid-template-areas: "time main amt act"; }
  .pay-row .b-time { display: flex; grid-area: time; }
  .pay-row .row-act { justify-self: end; }
  .money-list .pay-row:not(:has(.b-time)) { grid-template-columns: minmax(0, 1fr) 150px 150px; grid-template-areas: "main amt act"; }
}

/* ---------- Import ---------- */

.stepper { list-style: none; display: flex; gap: 4px; margin: 0 0 18px; padding: 0; overflow-x: auto; border-bottom: 1px solid var(--rule); }
.stepper li { position: relative; display: flex; align-items: center; gap: 6px; color: var(--ink-3); font-size: 14px; font-weight: 600; white-space: nowrap; padding: 8px 10px; }
.st-dot { display: none; }
.stepper li.done { color: var(--ink-2); }
.stepper li.done .st-dot { display: inline-grid; color: var(--green); }
.stepper li.on { color: var(--ink); }
.stepper li.on::after { content: ''; position: absolute; inset-inline: 6px; bottom: 0; height: 2px; border-radius: 2px; background: var(--accent); }
.drop { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 44px 20px; text-align: center; border: 1.5px dashed var(--field-edge); border-radius: 12px; cursor: pointer; transition: background .15s, border-color .15s; }
.drop.over, .drop:hover { background: rgba(251, 245, 223, .6); border-color: var(--ink-3); }
.drop.is-busy { pointer-events: none; opacity: .7; }
.drop-ic { color: var(--ink-3); }
.drop-ic .ic { width: 28px; height: 28px; }
.drop b { font-size: 17px; }
.drop .form-error { margin-top: 8px; }
.map-list { display: flex; flex-direction: column; }
.map-row { display: grid; grid-template-columns: 1fr; gap: 10px; padding: 14px 18px; border-top: 1px solid var(--rule); }
.map-row:first-child { border-top: 0; }
.map-src, .map-to, .map-samples { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.map-src b { overflow-wrap: anywhere; }
.map-select { display: flex; align-items: center; gap: 10px; }
.conf { width: 10px; height: 10px; border-radius: 50%; flex: 0 0 auto; }
.conf-high { background: var(--green-lit); }
.conf-mid { background: var(--amber-dot); }
.conf-low { background: var(--red-dot); }
.conf-none { background: transparent; border: 1.5px solid var(--ink-3); }
.map-samples ul { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 4px 0; }
.map-samples li { font-size: 13.5px; color: var(--ink-2); max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.map-samples li + li::before { content: '·'; color: #B6AC98; margin: 0 8px; }
.map-warn { grid-column: 1 / -1; display: flex; align-items: flex-start; gap: 8px; font-size: 14px; color: var(--amber); border-inline-start: 3px solid var(--amber-dot); padding: 6px 12px; }
.map-warn .ic { margin-top: 2px; }
@media (min-width: 900px) { .map-row { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1.5fr); align-items: center; } }
.imp-body > .card + .card { margin-top: 16px; }
.imp-body .form-actions { padding: 14px 18px 18px; }
.imp-body > .form-actions { padding: 18px 0 0; }
.imp-body .form-error { margin: 0 18px; }
.count-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); overflow: hidden; border-radius: 0 0 12px 12px; }
.count-cell { border-inline-end: 1px solid var(--rule); border-bottom: 1px solid var(--rule); margin: 0 -1px -1px 0; padding: 14px 18px; display: flex; flex-direction: column; gap: 1px; }
.count-cell b { font-weight: 600; font-size: 24px; line-height: 1.2; }
.count-cell small { color: var(--ink-3); }
.count-cell.warn b { color: var(--amber); }
.issue-group { border-top: 1px solid var(--rule); padding: 0 18px; }
.issue-group:first-child { border-top: 0; }
.issue-group summary { display: flex; align-items: center; gap: 10px; min-height: 48px; cursor: pointer; list-style: none; }
.issue-group summary::-webkit-details-marker { display: none; }
.issue-group summary b { flex: 1; font-weight: 600; }
.issue-group > p { margin-bottom: 8px; }
.issue-list { list-style: none; margin: 0 0 12px; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.issue-list li { display: flex; gap: 12px; font-size: 14px; }
.issue-list .num { color: var(--ink-3); white-space: nowrap; min-width: 64px; }
.issue-list .raw { color: var(--ink); overflow-wrap: anywhere; min-width: 0; }
.dup { padding: 12px 18px; border-top: 1px solid var(--rule); display: flex; flex-direction: column; gap: 8px; }
.dup:first-child { border-top: 0; }
.dup-pair { display: grid; grid-template-columns: 1fr; gap: 8px; }
@media (min-width: 640px) { .dup-pair { grid-template-columns: 1fr 1fr; } }
.sticky-actions { position: sticky; bottom: calc(var(--tab-h) + env(safe-area-inset-bottom)); background: var(--sheet); border-top: 1px solid var(--rule); padding: 12px 0 !important; z-index: 5; }
@media (min-width: 960px) { .sticky-actions { bottom: 0; } }
.done-card { padding: 24px; display: flex; flex-direction: column; align-items: flex-start; gap: 10px; }
.done-ic { color: var(--green); }
.done-card h2 { font-size: 20px; font-weight: 700; }
.done-lines { margin: 0; padding-inline-start: 18px; color: var(--ink); display: flex; flex-direction: column; gap: 4px; }
.callout { padding: 10px 14px; border-inline-start: 3px solid var(--accent); color: var(--ink); font-weight: 600; }
.done-card .form-actions { padding: 8px 0 0 !important; align-self: stretch; justify-content: flex-start; }

/* ---------- Export & Settings ---------- */

.export-all { display: flex; align-items: center; gap: 14px; padding: 16px 18px; flex-wrap: wrap; }
.exp-ic { color: var(--ink-3); display: grid; place-items: center; }
.export-list .row { color: var(--ink); }
.set-jump { margin-bottom: 16px; }
.set-sec { scroll-margin-top: calc(var(--top-h) + 16px); }
.set-sec + .set-sec { margin-top: 16px; }
.set-sec .form { padding: 14px 18px 18px; }
.set-sec > .lead, .set-sec > .muted, .set-sec > h3 { padding: 0 18px; }
.set-sec > h3 { font-size: 15px; font-weight: 700; padding-top: 14px; margin-bottom: 4px; }
.set-sec > .lead { padding-top: 12px; padding-bottom: 16px; }
.set-sec > .lead + .set-note { margin-top: -8px; padding-bottom: 16px; margin-bottom: 0; }
.set-sec > .muted { margin-bottom: 12px; }
.set-sec > .btn { margin: 6px 18px 18px; }
.set-sec.narrow { max-width: 520px; }
.user-act { flex-wrap: wrap; justify-content: flex-end; }
.user-act select { width: auto; min-height: 36px; padding-block: 4px; font-size: 14px; }
@media (max-width: 720px) {
  .user-row { flex-wrap: wrap; }
  .user-row .row-main { flex-basis: calc(100% - 52px); }
  .user-act { width: 100%; justify-content: flex-start; padding-inline-start: 48px; }
}
.token-new:not(:empty) { padding: 14px 18px 0; }
.token-once { padding: 12px 14px; border-inline-start: 3px solid var(--accent); background: rgba(251, 245, 223, .7); display: flex; flex-direction: column; gap: 10px; }
.token-once p { display: flex; gap: 8px; align-items: flex-start; font-size: 14.5px; font-weight: 600; }
.token-val { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.token-val code { flex: 1 1 200px; min-width: 0; overflow-wrap: anywhere; background: var(--field); border: 1px solid var(--edge); border-radius: 6px; padding: 9px 11px; font: 500 13.5px var(--sans); user-select: all; }
.tokens .list { border-top: 1px solid var(--rule); margin-top: 10px; }
.audit-list { list-style: none; margin: 0; padding: 4px 0; max-height: 520px; overflow-y: auto; }
.audit-list li { display: grid; grid-template-columns: 130px minmax(0, 1fr); gap: 12px; padding: 8px 18px; border-top: 1px solid var(--rule); font-size: 14px; }
.audit-list li:first-child { border-top: 0; }
.audit-list time { color: var(--ink-3); font-size: 13px; padding-top: 1px; }
.audit-list b { font-weight: 600; }
@media (max-width: 520px) { .audit-list li { grid-template-columns: 1fr; gap: 0; } }
.list-nav .row { min-height: 56px; }

/* book panel: patient lookup */
.lookup { position: relative; }
.suggest { position: absolute; inset-inline: 0; top: calc(100% + 4px); z-index: 5; border-radius: 10px; overflow: hidden; background: var(--field); border: 1px solid var(--edge); box-shadow: 0 10px 28px rgba(20, 18, 15, .14); /* taste-skill-ignore: a dropdown floats */ display: flex; flex-direction: column; }
.suggest-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 10px; padding: 10px 14px; text-align: start; background: none; border: 0; border-top: 1px solid var(--rule); min-height: 48px; }
.suggest-row:first-child { border-top: 0; }
.suggest-row:hover, .suggest-row:focus-visible { background: var(--hover); }
.suggest-row b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.suggest-row .num { color: var(--ink-3); font-size: 13px; }
.suggest-row small { grid-column: 1 / -1; color: var(--ink-3); }
.found-chip { font-style: normal; font-size: 12.5px; color: var(--green); font-weight: 600; }

/* ---------- login ---------- */

.login-page { display: grid; place-items: center; min-height: 100dvh; padding: 24px 16px; }
.login { width: 100%; max-width: 400px; display: flex; flex-direction: column; gap: 18px; }
.login-brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 17px; }
.login-brand .logo { width: 28px; height: 28px; }
.login-card { padding: 26px 22px; display: flex; flex-direction: column; gap: 16px; border-radius: 16px; }
.login-card h1 { font-family: var(--serif); font-weight: 500; font-size: 28px; letter-spacing: -.015em; }
.login-card .lead { margin-top: -8px; }
.login-card .btn { margin-top: 4px; min-height: 48px; font-size: 15px; }

/* names and messages as typed: an Arabic name keeps its own direction but sits at the row's start */
.row-main > [dir=auto], .tl-main > [dir=auto], .fact dd > [dir=auto], .pp-name > [dir=auto], .suggest-row b, .dup-side b, .merge-side b { align-self: flex-start; max-width: 100%; text-align: start; }

@media (max-width: 639px) {
  /* one compact trailing action per row on a phone: the icon carries it, the name is its label */
  .needs .row { align-items: flex-start; padding-inline-end: 10px; }
  .needs .row .dot { margin-top: 7px; }
  .needs .row-act .btn-sm:has(.ic) { width: 44px; padding: 0; }
  .needs .row-act .btn-sm:has(.ic) span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .needs .row-act .seg { flex-direction: column; }
  .needs .row-act .seg button + button { border-inline-start: 0; border-top: 1px solid var(--field-edge); }
  .top-time { font-size: 12px; }
  .page-head { margin-bottom: 12px; }
}
@media (max-width: 359px) { .field-row { grid-template-columns: 1fr; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition: none !important; animation: none !important; } }
@media (max-width: 639px) {
  .kpis-3 { grid-template-columns: 1fr 1fr; }
  .kpis-3 .kpi:last-child:nth-child(odd) { grid-column: span 2; }
}
.kpi-big .kpi-num small { font-family: var(--serif); font-size: 18px; }

/* ---------- set your own password (first sign-in prompt, Settings) ---------- */

body.gated .shell, body.gated .skip { display: none; }
.gate { display: grid; place-items: center; min-height: 100dvh; padding: 24px 16px; }
.gate .login-card { background: var(--sheet); border: 1px solid var(--edge); }
.gate .link-btn { align-self: flex-start; }
.pw-rule { font-style: normal; font-weight: 500; font-size: 13px; color: var(--ink-3); margin-inline-start: auto; display: inline-flex; align-items: center; gap: 6px; }
.pw-rule::before { content: ''; width: 8px; height: 8px; border-radius: 50%; border: 1.5px solid var(--ink-3); }
.pw-rule.ok { color: var(--green); }
.pw-rule.ok::before { background: var(--green-lit); border-color: var(--green-lit); }
.field-err { color: var(--red); font-size: 13.5px; font-weight: 600; }
input[aria-invalid=true] { border-color: var(--red-dot); }

/* ---------- patient page: message consents ---------- */

.consents { display: flex; flex-direction: column; gap: 6px; align-self: stretch; }
.consent { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.consent-txt { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.consent-txt small { color: var(--ink-3); }
.consent-note { overflow-wrap: anywhere; }
.consent .switch { flex: 0 0 auto; }
.consent-dnc { color: var(--red); }

/* ---------- today: amount and how it was paid ---------- */

.b-amt { grid-area: amt; display: flex; flex-direction: column; align-items: flex-end; text-align: end; }
.b-amt b { font-size: 14px; font-weight: 600; white-space: nowrap; }
.b-amt small { color: var(--ink-3); font-size: 12.5px; }
.booking.has-amt { grid-template-areas: "time main icons" "time act amt"; }
@media (min-width: 640px) {
  .booking.has-amt { grid-template-columns: 72px minmax(0, 1fr) auto auto auto; grid-template-areas: "time main amt act icons"; }
  .b-amt { padding-inline: 4px; }
}

/* ---------- summary: by doctor, by source ---------- */

.sum-tables { display: grid; gap: 16px; margin-top: 16px; }
.sum-tables:empty { display: none; }
.sum-tables .card + .card { margin-top: 0; }
@media (min-width: 1100px) { .sum-tables { grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; } }
.tbl-wrap { overflow-x: auto; }
.mini-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.mini-table th, .mini-table td { padding: 12px 10px; text-align: end; white-space: nowrap; }
.mini-table thead th { font-size: 12.5px; font-weight: 600; color: var(--ink-3); padding-block: 8px; border-bottom: 1px solid var(--rule); }
.mini-table tbody th { font-weight: 600; text-align: start; white-space: normal; overflow-wrap: anywhere; min-width: 110px; }
.mini-table thead th:first-child { text-align: start; }
.mini-table tr > :first-child { padding-inline-start: 18px; }
.mini-table tr > :last-child { padding-inline-end: 18px; }
.mini-table tbody tr + tr > * { border-top: 1px solid var(--rule); }
.mini-table td small { color: var(--ink-3); font-size: 12px; }

/* ---------- import result, export note ---------- */

.callout.no-phone { border-inline-start-color: var(--amber-dot); font-weight: 400; align-self: stretch; }
.callout.no-phone p { font-weight: 600; }
.name-list { margin: 8px 0 0; padding-inline-start: 18px; display: flex; flex-direction: column; gap: 2px; color: var(--ink-2); }
.exp-note { margin: 0 2px 12px; }

/* ---------- inbox: reply limit, retry, who is on it; book: the day in words ---------- */

.reply-count { align-self: flex-end; color: var(--ink-3); font-size: 12px; white-space: nowrap; }
.reply-count:empty { display: none; }
.reply-count.near { color: var(--red); font-weight: 600; }
.retry-send { min-height: 44px; padding: 0 4px; font-size: 13.5px; }
.handled-by { color: var(--ink-2); }
.day-label { font-variant-numeric: tabular-nums; }

/* ---------- a patient imported without a mobile ---------- */
.pp-np { max-width: 760px; }
.np-why { color: var(--ink-2); max-width: 62ch; }
.np-form .lead { margin: 0; }
.np-preview b { font-weight: 700; color: var(--ink); }
.np-conflict { padding: 10px 14px; border-inline-start: 3px solid var(--amber-dot); }
.np-conflict p { font-weight: 600; }
.np-conflict .btn-row { margin-top: 8px; }

/* ================= second wave (API.md 7, UI.md "Second wave") ================= */

/* Day | Week, the week's own picker */
/* Day | Week is a two-way switch, not a second row of tabs: the orange underline stays with the day / week picker */
.view-switch { border: 1px solid var(--field-edge); border-radius: var(--r); gap: 0; padding: 2px; overflow: visible; }
.view-switch a { min-height: 32px; padding: 0 14px; border-radius: 6px; }
.view-switch .on { background: var(--ink); color: var(--frame); }
.view-switch .on::after { display: none; }
.view-switch a.on:hover { color: var(--frame); }
@media (pointer: coarse) { .view-switch a { min-height: 40px; } }
.week-nav a .ic { width: 16px; height: 16px; }
.mark-cal { color: var(--amber); }
.mark-cal .ic { width: 14px; height: 14px; }

/* the week: days across, doctors as bands, each booking a block with its mark */
.week-card { overflow-x: auto; }
.week { display: grid; grid-template-columns: 148px repeat(7, minmax(112px, 1fr)); min-width: 940px; }
.wk-row { display: contents; }
.wk-who { padding: 12px 14px 12px 18px; font-weight: 600; font-size: 14px; border-top: 1px solid var(--rule); overflow-wrap: anywhere; }
.wk-heads .wk-who { border-top: 0; }
.wk-dhead { display: flex; flex-direction: column; gap: 1px; padding: 10px 10px 8px; border-inline-start: 1px solid var(--rule); border-top: 2px solid transparent; }
.wk-dname { font-size: 13px; color: var(--ink-3); display: flex; gap: 6px; align-items: baseline; }
.wk-dname b { font-size: 14px; font-weight: 700; color: var(--ink); }
.wk-dhead small { font-size: 12.5px; color: var(--ink-3); }
.wk-dhead.is-today { border-top-color: var(--accent); }
.wk-dhead.is-today small { color: var(--accent-ink); font-weight: 700; }
.wk-cell { display: flex; flex-direction: column; gap: 4px; padding: 6px; min-height: 64px; border-top: 1px solid var(--rule); border-inline-start: 1px solid var(--rule); min-width: 0; }
.wk-cell.is-closed, .wk-dhead.is-closed { background: var(--hover); }
.wk-b {
  display: flex; align-items: center; gap: 6px; width: 100%; min-height: 28px; padding: 3px 7px; border-radius: 4px; border: 0;
  font: inherit; font-size: 12.5px; color: var(--ink); text-align: start; cursor: pointer; min-width: 0;
}
.wk-b b { font-weight: 700; flex: 0 0 auto; white-space: nowrap; }
.wk-ampm { font-size: .8em; font-weight: 600; margin-inline-start: 2px; }
.wk-b span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.wk-b:hover { filter: brightness(.95); }
.wk-b.bar-attended { color: var(--frame); }
.wk-b.bar-noshow { color: var(--red); }
.wk-b.bar-cancelled { color: var(--ink-3); }
.wk-b.bar-cancelled span { text-decoration: line-through; }
.wk-cal { display: inline-grid; margin-inline-start: auto; color: var(--amber); font-style: normal; }
.wk-b.bar-attended .wk-cal { color: var(--amber-dot); }
.wk-hint { margin-top: 10px; }
.wk-agenda { display: flex; flex-direction: column; gap: 12px; }
.wk-agenda .card + .card { margin-top: 0; }
.wk-dayc .wk-dhead { flex-direction: row; align-items: baseline; justify-content: space-between; padding: 12px 16px 10px; border-inline-start: 0; border-bottom: 1px solid var(--rule); border-radius: 12px 12px 0 0; }
.wk-band-p { padding: 10px 16px 12px; }
.wk-band-p + .wk-band-p { border-top: 1px solid var(--rule); }
.wk-pname { font-size: 13px; color: var(--ink-3); margin-bottom: 6px; }
.wk-blocks { display: grid; grid-template-columns: repeat(auto-fill, minmax(132px, 1fr)); gap: 6px; }
.wk-blocks .wk-b { min-height: 44px; font-size: 14px; padding: 4px 10px; }
.wk-none { padding: 12px 16px; font-size: 14px; }
.wk-dayc.is-today { border-top: 2px solid var(--accent); }
.wk-dayc.is-quiet .wk-dhead { border-bottom: 0; padding-block: 10px; }
.wk-dayc.is-quiet .wk-dname, .wk-dayc.is-quiet .wk-dname b { color: var(--ink-3); font-weight: 600; }

/* Your tasks on Today */
.mytasks .section-head .link-btn { min-height: 0; padding: 0; font-size: 14px; }
.mytasks .row-side { max-width: none; }

/* Patients: Search | Lists, filters, saved lists */
.pat-tabs { border-bottom: 0; }
.pat-tabs .ic { width: 16px; height: 16px; }
.saved-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 0 0 12px; }
.saved-label { font-size: 13px; color: var(--ink-3); margin-inline-end: 2px; }
.saved { display: inline-flex; align-items: center; gap: 8px; min-height: 36px; padding: 0 12px; border-radius: var(--r); border: 1px solid var(--edge); background: var(--sheet); color: var(--ink); font-size: 14px; font-weight: 600; max-width: 100%; }
.saved:hover { background: var(--hover); text-decoration: none; }
.saved span[dir] { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.saved.on { border: 1.5px solid var(--ink); padding: 0 11.5px; }
.saved .mark { font-size: 12.5px; }
.lists-filters { padding: 14px 16px 16px; display: flex; flex-direction: column; gap: 14px; }
.fchips { display: flex; flex-wrap: wrap; gap: 8px; }
.fchip {
  display: inline-flex; align-items: center; gap: 6px; min-height: 36px; padding: 0 12px; border-radius: var(--r);
  border: 1px solid var(--field-edge); background: var(--field); color: var(--ink-2); font-size: 13.5px; font-weight: 600; white-space: nowrap;
}
.fchip:hover { border-color: var(--ink-3); color: var(--ink); }
.fchip.on { border: 1.5px solid var(--ink); padding: 0 11.5px; color: var(--ink); }
.fchip .ic { width: 14px; height: 14px; }
.fsels { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 10px 12px; }
@media (max-width: 639px) {
  .fsels { grid-template-columns: 1fr 1fr; }
  .saved-bar { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin-inline: -16px; padding-inline: 16px; }
  .saved-bar::-webkit-scrollbar { display: none; }
  .saved { flex: 0 0 auto; }
  .lists-filters { padding: 12px; gap: 12px; }
}
.fsub { padding-bottom: 14px; border-bottom: 1px solid var(--rule); }
.fsel > span { font-size: 12.5px; font-weight: 600; color: var(--ink-3); }
.fsel select { min-height: 40px; font-size: 14px; padding-block: 6px; }
.lists-bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px 12px; margin: 16px 0 8px; min-height: 36px; }
.lists-count { font-size: 14px; font-weight: 600; color: var(--ink-2); }
.lists-count:empty { display: none; }
.lists-tools, .tasks-tools { display: inline-flex; gap: 4px; margin-inline-start: auto; flex-wrap: wrap; }
@media (pointer: coarse) { .fchip, .saved { min-height: 44px; } .fsel select { min-height: 44px; } }

/* patient page: notes, the plan, moving an upcoming visit */
.notes-card .note-new { padding: 12px 18px 14px; display: flex; flex-direction: column; gap: 6px; border-bottom: 1px solid var(--rule); }
.notes-card .note-new textarea { min-height: 64px; }
.note-new-act { display: flex; justify-content: flex-end; }
.note-list { list-style: none; margin: 0; padding: 0; }
.note { padding: 12px 18px; border-top: 1px solid var(--rule); display: flex; flex-direction: column; gap: 4px; }
.note:first-child { border-top: 0; }
.note-body { overflow-wrap: anywhere; }
.note-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 32px; }
.note-foot small { color: var(--ink-3); }
.note-pin { display: inline-flex; align-items: center; gap: 4px; color: var(--ink); font-weight: 600; }
.note.is-pinned .note-body { font-weight: 500; }
.note-acts { display: inline-flex; margin-inline-end: -8px; flex: 0 0 auto; }
.note-acts .icon-btn { width: 32px; height: 32px; }
.note-acts .icon-btn .ic { width: 16px; height: 16px; }
.note-acts [aria-pressed=true] { color: var(--ink); }
.note-legacy .note-body { color: var(--ink-2); }
.note-edit { gap: 8px; }
.note-edit .form-actions { margin-top: 0; }
@media (pointer: coarse) { .note-acts .icon-btn { width: 44px; height: 44px; } }
.tl-move { align-self: flex-start; margin-top: 6px; }
.plan-note { padding: 8px 12px; border-inline-start: 3px solid var(--edge); color: var(--ink); }

/* Inbox: hand back */
.banner { flex-wrap: wrap; }
.banner > span { flex: 1 1 220px; }
.banner .hand-back { margin-inline-start: auto; }

/* More -> Tasks */
.tasks-bar { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 8px 16px; margin-bottom: 4px; border-bottom: 1px solid var(--rule); }
.tasks-bar .tabs { border-bottom: 0; }
.tasks-filters { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding-bottom: 6px; }
.tasks-filters select { min-height: 36px; font-size: 14px; padding-block: 4px; width: auto; }
.tasks-list .section-head:first-child { margin-top: 16px; }
.tasks-count { margin: 16px 2px 8px; font-size: 14px; font-weight: 600; color: var(--ink-2); }
.task-row { gap: 12px; }
/* the ring is drawn on the icon, so the button can be a 44px target around a 26px circle */
.task-check { display: grid; place-items: center; width: 36px; height: 36px; flex: 0 0 auto; border: 0; border-radius: 50%; background: none; color: transparent; padding: 0; }
.task-check .ic { width: 26px; height: 26px; padding: 5px; stroke-width: 2.2; border: 1.5px solid var(--ink-3); border-radius: 50%; }
.task-check:hover { color: var(--ink-2); }
.task-check:hover .ic { border-color: var(--ink-2); }
.task-check.on .ic { background: var(--ink); border-color: var(--ink); color: var(--frame); }
.task-row.is-done .row-main b { color: var(--ink-2); }
.row-main small.is-late { color: var(--amber); }
.task-note { display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; overflow: hidden; }
.task-row .row-main .chips { margin-top: 2px; }
.task-who { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; color: var(--ink-2); }
.task-who .link-btn { min-height: 0; padding: 0; }
.task-done-btn { margin-inline-end: auto; }
@media (pointer: coarse) { .task-check { width: 44px; height: 44px; } }
@media (max-width: 639px) { .tasks-filters { width: 100%; } }

@media (max-width: 520px) { .fact-row .switch-word { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); } }

/* Settings -> Automation link */
.link-state { padding: 14px 18px 6px; }
.link-state .mark { font-size: 14.5px; font-weight: 600; color: var(--ink); }
#set-link .events { padding-bottom: 8px; }
#set-link .events .list { border-top: 1px solid var(--rule); margin-top: 8px; }

/* ---------- the Calendar tab: a real time grid (UI.md "Calendar tab") ----------
 * Day: doctors as columns; Week: days as columns, or each day split into narrow doctor lanes; Month: six weeks.
 * Open hours down the left in 30-minute rows with faint 1px lines; closed time one tone step darker; now a 1px
 * orange line with its time. Bookings are blocks at radius 4 carrying the day strip's own marks. */
.cal-head .page-tools { gap: 10px 14px; }
.cal-views { border-bottom: 0; }
.cal-nav { display: inline-flex; align-items: center; gap: 2px; }
.cal-nav .icon-btn .ic { width: 16px; height: 16px; }
.cal-today { min-height: 34px; }
@media (max-width: 767px) { .cal-today, .cal-sechead .cal-toggle { min-height: 44px; } }
.cal-today.is-on { color: var(--ink-3); }
.cal-pick { position: relative; display: inline-grid; }
.cal-pick input { position: absolute; inset: 0; opacity: 0; width: 100%; height: 100%; border: 0; padding: 0; min-height: 0; pointer-events: none; }
.cal-open { display: inline-flex; align-items: center; gap: 6px; padding: 0 4px; }
.cal-open .ic { width: 16px; height: 16px; }

.cal-filters { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 18px; margin: -4px 0 4px; }
.cal-pills { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; min-width: 0; max-width: 100%; padding: 2px; }
.cal-pills::-webkit-scrollbar { display: none; }
.pill {
  flex: 0 0 auto; display: inline-flex; align-items: center; min-height: 34px; padding: 0 14px; border-radius: 17px;
  border: 1px solid var(--field-edge); background: var(--sheet); color: var(--ink-2); font-size: 13.5px; font-weight: 600; white-space: nowrap;
}
.pill:hover { border-color: var(--ink-3); color: var(--ink); }
.pill[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: var(--frame); }
.cal-toggle { display: inline-flex; align-items: center; gap: 8px; min-height: 40px; font-size: 14px; color: var(--ink-2); cursor: pointer; }
.cal-toggle input { width: 16px; height: 16px; margin: 0; accent-color: var(--ink); }
@media (pointer: coarse) { .pill { min-height: 44px; border-radius: 22px; } .cal-toggle { min-height: 44px; } }

.cal-sechead { margin-top: 10px; align-items: center; }
.cal-sechead-l { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 18px; }
.cal-sechead .cal-toggle { font-size: 13.5px; min-height: 36px; }
.cal-note { margin: 0 0 10px; color: var(--ink-2); font-size: 14.5px; }
.cal-hint { margin-top: 10px; }
.cal-card { overflow-x: auto; }
.cal-grid { --axis: 56px; --cols: 1; --dcols: 1; --colmin: 0px; min-width: calc(var(--axis) + var(--cols) * var(--colmin)); }
.cal-row { display: grid; grid-template-columns: var(--axis) repeat(var(--cols), minmax(0, 1fr)); }
.cal-row.cal-days { grid-template-columns: var(--axis) repeat(var(--dcols), minmax(0, 1fr)); }
.cal-corner { display: block; }
.cal-hcell { display: flex; flex-direction: column; gap: 1px; min-width: 0; padding: 10px 10px 8px; border-inline-start: 1px solid var(--rule); }
.cal-hcell b { font-size: 14px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cal-hcell .cal-wd { color: var(--ink-3); font-weight: 600; font-size: 13px; }
/* the sub line may wrap ("Today · Closed · 8 bookings" was cut off at 1440, review round 8 minor 6) */
.cal-hcell small { font-size: 12.5px; color: var(--ink-3); line-height: 1.3; }
.cal-hcell.is-today b, .cal-hcell.is-today .cal-wd { color: var(--ink); }
.cal-hcell.is-today small { color: var(--ink); font-weight: 600; }
.cal-hcell.is-closed { background: var(--hover); }
.cal-days .cal-hcell { border-inline-start-color: var(--field-edge); }
.cal-lane { padding: 4px 6px 5px; font-size: 12px; color: var(--ink-3); border-top: 1px solid var(--rule); border-inline-start: 1px solid var(--rule); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.cal-lane.first { border-inline-start-color: var(--field-edge); }
.cal-lanes .cal-corner { border-top: 1px solid var(--rule); }

.cal-body { position: relative; isolation: isolate; border-top: 1px solid var(--rule); }
.cal-lines { position: absolute; top: 0; bottom: 0; inset-inline: var(--axis) 0; z-index: 1; pointer-events: none; }
.cl { position: absolute; inset-inline: 0; border-top: 1px solid #F5F0E2; }
.cl.hr { border-top-color: var(--rule); }
.cal-axis { position: relative; }
.ca { position: absolute; inset-inline-end: 8px; margin-top: 3px; font-size: 12px; color: var(--ink-3); white-space: nowrap; }
.ca.is-covered { visibility: hidden; }
.ca-now { position: absolute; inset-inline-end: 4px; transform: translateY(-50%); z-index: 2; padding: 0 3px; background: var(--sheet); font-size: 12px; font-weight: 700; color: var(--accent-ink); white-space: nowrap; }
.cal-nowline { position: absolute; z-index: 4; border-top: 1px solid var(--accent); pointer-events: none; }
.cal-col { position: relative; min-width: 0; border-inline-start: 1px solid var(--rule); }
.cal-col.first { border-inline-start-color: var(--field-edge); }
.cc { position: absolute; inset-inline: 0; z-index: 0; background: var(--hover); }
.cs {
  position: absolute; inset-inline: 2px; z-index: 2; display: flex; align-items: center; gap: 4px; padding: 0 6px;
  border: 0; border-radius: 4px; background: none; color: transparent; font-size: 12px; font-weight: 600; text-align: start; overflow: hidden; white-space: nowrap;
}
.cs .ic { opacity: 0; }
.cs:hover, .cs:focus-visible { background: var(--hover); color: var(--ink-2); }
.cs:hover .ic, .cs:focus-visible .ic { opacity: 1; }
/* a phone has no hover: show open times as quiet text so they can be found (review round 8, minor 3) */
@media (hover: none) { .cs { color: var(--ink-3); } .cs .ic { opacity: .7; } }
.cs:focus-visible { outline-offset: -2px; }
.cb { position: absolute; z-index: 3; display: block; padding: 1px 2px 1px 1px; border: 0; background: none; font: inherit; text-align: start; cursor: pointer; }
.cb:hover, .cb:focus-visible { z-index: 5; }
.cb:focus-visible { outline-offset: 0; border-radius: 5px; }
.cb-in {
  position: relative; display: flex; flex-direction: column; height: 100%; padding: 2px 6px; border-radius: 4px; overflow: hidden;
  font-size: 12px; line-height: 1.3; color: var(--ink);
}
.cb-in:hover { filter: brightness(.96); }
.cb-name { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cb-svc { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--ink-2); }
.cb.is-short .cb-in { flex-direction: row; align-items: center; gap: 4px; padding-block: 0; }
.cb.is-short .cb-svc { flex: 1 1 0; min-width: 0; }
.cb.is-short .cb-name { flex: 0 1 auto; }
.cb-in.bar-attended, .cb-in.bar-attended .cb-svc { color: var(--frame); }
.cb-in.bar-noshow, .cb-in.bar-noshow .cb-svc { color: var(--red); }
.cb-in.bar-cancelled, .cb-in.bar-cancelled .cb-svc { color: var(--ink-3); }
.cb-in.bar-cancelled .cb-name { text-decoration: line-through; }
.cb-cal { position: absolute; top: 2px; inset-inline-end: 3px; display: inline-grid; color: var(--amber); font-style: normal; background: inherit; }
.cb-in.bar-attended .cb-cal { color: var(--amber-dot); }
.cb-time {
  display: none; position: absolute; bottom: calc(100% + 2px); inset-inline-start: 0; z-index: 6; padding: 1px 6px; border-radius: 4px;
  background: var(--ink); color: var(--frame); font-size: 12px; font-weight: 600; white-space: nowrap; pointer-events: none;
}
.cb:hover .cb-time, .cb:focus-visible .cb-time { display: block; }
.cb-sk { position: absolute; inset-inline: 3px; z-index: 3; border-radius: 4px; }

/* the booking panel: a popover on a desk (no shadow: its edge carries it), the sheet on a phone */
.cal-pop { position: fixed; z-index: 60; width: 344px; max-width: calc(100vw - 16px); background: var(--sheet); border: 1px solid var(--field-edge); border-radius: 12px; }
.cal-pop-head { display: flex; align-items: center; gap: 8px; padding: 4px 6px 4px 16px; min-height: 44px; border-bottom: 1px solid var(--rule); }
.cal-pop-head h2 { flex: 1; font-size: 13.5px; font-weight: 600; color: var(--ink-3); }
.cp { display: flex; flex-direction: column; gap: 12px; padding: 12px 16px 16px; }
.cal-sheet .cp { padding: 0; }
.cp-name { font-size: 18px; font-weight: 700; color: var(--ink); overflow-wrap: anywhere; }
a.cp-name:hover { color: var(--accent-ink); }
.cp-facts { display: grid; grid-template-columns: 72px minmax(0, 1fr); gap: 6px 12px; margin: 0; font-size: 14px; }
.cp-facts dt { color: var(--ink-3); }
.cp-facts dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.cp-facts dd a { color: var(--ink); }
.cp-acts { display: flex; flex-wrap: wrap; gap: 8px; padding-top: 4px; }
.cp-cancel { color: var(--red); }

/* Week on a phone: an agenda grouped by day */
.cal-ag { display: flex; flex-direction: column; gap: 10px; }
.cal-ag .card + .card { margin-top: 0; }
.cal-aghead { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; min-height: 44px; padding: 10px 16px; color: var(--ink); border-bottom: 1px solid var(--rule); }
.cal-aghead:hover { text-decoration: none; background: var(--hover); }
.cal-aghead small { color: var(--ink-3); font-size: 13px; }
.cal-agday.is-today .cal-aghead small { color: var(--ink); font-weight: 700; }
.cal-agday.is-quiet .cal-aghead { border-bottom: 0; }
.cal-agday.is-quiet .cal-aghead b { color: var(--ink-3); font-weight: 600; }
.cal-agrow { display: grid; grid-template-columns: 64px minmax(0, 1fr); align-items: start; gap: 10px; padding: 10px 16px; cursor: pointer; font: inherit; }
.cal-agrow:hover { background: var(--hover); }
.cal-agrow .b-time, .cal-agrow .row-main { grid-area: auto; }
.cal-pop:focus { outline: none; }
.cal-agrow.is-cancelled .row-main b { text-decoration: line-through; color: var(--ink-3); }

/* Month: six weeks, Saturday first */
.cm-wds, .cm { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); }
.cm-wd { padding: 8px 10px; font-size: 12.5px; color: var(--ink-3); }
.cm-day {
  display: flex; flex-direction: column; gap: 4px; min-width: 0; min-height: 116px; padding: 8px 10px 10px;
  border-top: 1px solid var(--rule); border-inline-start: 1px solid var(--rule); color: var(--ink);
}
.cm-day:nth-child(7n + 1) { border-inline-start: 0; }
.cm-day:hover { text-decoration: none; background: var(--hover); }
.cm-day.is-closed { background: var(--hover); }
.cm-day.is-other { color: var(--ink-3); }
.cm-top { display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.cm-num { display: inline-grid; place-items: center; min-width: 26px; height: 26px; margin-inline-start: -5px; border-radius: 13px; font-size: 14px; font-weight: 700; }
.cm-day.is-today .cm-num { background: var(--ink); color: var(--frame); }
.cm-closed { font-size: 12px; color: var(--ink-3); }
.cm-docs { display: flex; flex-wrap: wrap; gap: 4px 10px; font-size: 12.5px; color: var(--ink-2); font-weight: 600; }
.cm-doc { display: inline-flex; align-items: center; gap: 4px; }
.cm-doc i { display: inline-grid; place-items: center; width: 18px; height: 18px; border-radius: 9px; border: 1px solid var(--field-edge); font-style: normal; font-size: 11px; font-weight: 700; color: var(--ink-2); }
.cm-names { display: flex; flex-direction: column; min-width: 0; font-size: 12.5px; line-height: 1.45; }
.cm-names > span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cm-names b { font-weight: 700; }
.cm-names b small { font-size: 11px; margin-inline-start: 1px; }
.cm-names .is-cancelled { color: var(--ink-3); text-decoration: line-through; }
.cm-more { font-size: 12px; color: var(--ink-3); }
.cm-dots { display: none; align-items: center; gap: 3px; }
.cm-dots i { width: 6px; height: 6px; border-radius: 3px; background: var(--ink-2); }
.cm-dots em { font-style: normal; font-size: 11px; color: var(--ink-3); margin-inline-start: 2px; }
.cm-sk { width: 70%; height: 10px; }

@media (max-width: 639px) {
  /* one row for the title and the date arrows, one for Day / Week / Month */
  .cal-head { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 4px 8px; margin-bottom: 8px; }
  .cal-head .page-tools { display: contents; }
  .cal-head .cal-nav { grid-column: 2; grid-row: 1; }
  .cal-head .cal-views { grid-column: 1 / -1; grid-row: 2; }
  .cal-head .cal-today { padding: 0 10px; }
  .cal-filters { margin: 0; }
  .cal-sechead { margin-top: 6px; }
  .cal-grid { --axis: 48px; }
  .cm-day { min-height: 56px; padding: 6px 4px 8px; align-items: center; gap: 4px; }
  .cm-top { justify-content: center; }
  .cm-num { margin: 0; font-size: 13.5px; }
  .cm-closed, .cm-docs, .cm-names, .cm-more { display: none; }
  .cm-dots { display: flex; }
  .cm-wd { padding: 8px 0; text-align: center; }
}
@media (min-width: 960px) {
  .list-nav .more-phone-only { display: none; }
  .list-nav .more-phone-only + .row:not(.more-phone-only) { border-top: 0; }
}

/* ---------- v2 (UI.md "v2 (9 Nov)") ---------- */

.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; }

/* the draft-ready mark: an outline dot and words */
.mark-draft { color: var(--ink); font-weight: 600; }
.mark-draft i { background: transparent; border: 1.5px solid var(--ink); }

/* Inbox: the drafted reply card sits above the composer, on the sheet (1px edge, no fill) */
.draft-card { margin: 10px 12px 0; padding: 12px 14px; display: flex; flex-direction: column; gap: 6px; flex: 0 0 auto; border-radius: 10px; }
.draft-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 28px; }
.draft-label { font-size: 13px; font-weight: 600; color: var(--ink-2); }
.draft-text { font-size: 16px; color: var(--ink); line-height: 1.5; white-space: pre-wrap; overflow-wrap: anywhere; max-height: 30vh; overflow-y: auto; }
.draft-meta { font-size: 12px; color: var(--ink-3); }
.draft-why { font-size: 14.5px; color: var(--ink-2); }
.draft-acts { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 4px; }
.draft-acts .btn { min-height: 40px; }
.draft-card.is-off { border-style: dashed; }
.draft-card.is-editing { padding-block: 6px; }
.draft-x { width: 32px; height: 32px; margin: -4px -6px -4px 0; }
.draft-x .ic { width: 16px; height: 16px; }
.draft-writing { display: flex; flex-direction: column; gap: 8px; }
.draft-writing .sk-a { width: 70%; }
.composer .ask-btn { flex: 0 0 auto; width: 44px; padding: 0; min-height: 44px; color: var(--ink-2); }
.composer .ask-btn span { display: none; }
.composer-sub { font-size: 12.5px; padding: 0 16px 10px; margin-top: -4px; background: var(--sheet); }
@media (min-width: 1280px) { .composer .ask-btn { width: auto; padding: 0 12px; } .composer .ask-btn span { display: inline; } }
@media (pointer: coarse) { .draft-x { width: 44px; height: 44px; } .draft-acts .btn { min-height: 44px; } }

/* Enquiries: six columns on a desk (Lost folded to a strip), a stage switcher on a phone */
.enq-board { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)) 40px; gap: 8px; overflow-x: auto; height: calc(100vh - var(--top-h) - 170px); min-height: 440px; padding-bottom: 4px; }
.enq-board.lost-open { grid-template-columns: repeat(6, minmax(164px, 1fr)); }
.enq-col { display: flex; flex-direction: column; min-height: 0; min-width: 0; border: 1px solid var(--rule); border-radius: 12px; background: var(--sheet); }
.enq-col-head { padding: 12px 14px 10px; border-bottom: 1px solid var(--rule); flex: 0 0 auto; }
.enq-col-head h2 { font-size: 14.5px; font-weight: 700; }
.enq-col-title { display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.enq-col-title .icon-btn { width: 30px; height: 30px; margin: -6px -8px -6px 0; }
.enq-sum { font-size: 13.5px; color: var(--ink-2); margin-top: 2px; }
.enq-est { font-size: 12px; color: var(--ink-3); }
.enq-cards { flex: 1 1 auto; min-height: 0; overflow-y: auto; padding: 8px; scrollbar-width: thin; display: flex; flex-direction: column; gap: 8px; overscroll-behavior: contain; }
.enq-cards .card + .card { margin-top: 0; }
.enq-none { font-size: 13px; color: var(--ink-3); padding: 4px; }
.enq-card { position: relative; padding: 10px; display: flex; flex-direction: column; gap: 2px; border-radius: 10px; }
.enq-card[draggable="true"] { cursor: grab; }
.enq-card-top { display: flex; align-items: flex-start; gap: 6px; padding-inline-end: 26px; } /* room for the menu, on the card's side (the name is dir=auto) */
.enq-name { flex: 1 1 auto; min-width: 0; font-weight: 700; color: var(--ink); align-self: center; text-align: start; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.enq-name::after { content: ""; position: absolute; inset: 0; border-radius: 10px; }
.enq-name:hover { text-decoration: none; }
.enq-card:hover { border-color: var(--ink-3); }
.enq-menu { position: absolute; z-index: 1; top: 4px; inset-inline-end: 4px; width: 28px; height: 28px; margin: 0; }
.enq-menu .ic { width: 18px; height: 18px; }
.enq-svc { font-size: 14px; color: var(--ink-2); overflow-wrap: anywhere; }
.enq-src { font-size: 13px; color: var(--ink-3); }
.enq-val { font-size: 14px; font-weight: 600; margin-top: 2px; }
.enq-val-est { font-weight: 500; color: var(--ink-3); }
.enq-days { font-size: 12.5px; color: var(--ink-3); }
.enq-card .chips { margin-top: 4px; }
.enq-why { font-size: 13px; color: var(--ink-2); margin-top: 2px; }
.enq-strip { display: flex; flex-direction: column; align-items: center; justify-content: flex-start; gap: 10px; padding: 14px 0; border: 1px solid var(--rule); border-radius: 12px; background: var(--sheet); color: var(--ink-2); font-weight: 700; min-height: 0; }
.enq-strip:hover { border-color: var(--ink-3); color: var(--ink); }
.enq-strip-label { writing-mode: vertical-rl; font-size: 14px; }
.enq-strip-n { font-size: 13px; color: var(--ink-3); }
.enq-drop-hint { display: none; font-size: 12.5px; color: var(--ink-3); padding: 8px 14px 0; }
.enq.is-dragging [data-drop=lost] { border: 1.5px dashed var(--ink-2); }
.enq.is-dragging .enq-drop-hint { display: block; }
.enq [data-drop=lost].is-over { border: 2px solid var(--accent); }
.enq-pills { margin: 0 -2px 10px; }
.enq-pills .num { color: inherit; opacity: .7; margin-inline-start: 6px; }
.enq-phone-head { margin: 0 0 10px; }
.enq-list { display: flex; flex-direction: column; gap: 8px; }
.enq-list .card + .card { margin-top: 0; }
.enq-list .enq-card { padding: 12px 14px 14px; }
@media (pointer: coarse) { .enq-menu { width: 44px; height: 44px; top: 0; inset-inline-end: 0; } .enq-card-top { padding-inline-end: 38px; } }

/* Your assistant: read-only blocks */
.asst-grid { display: grid; gap: 16px; align-items: start; }
.asst-grid .card + .card { margin-top: 0; }
@media (min-width: 1100px) { .asst-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } .asst-wide { grid-column: 1 / -1; } }
.asst-block .section-head.in-card { align-items: center; }
.asst-ask { min-height: 32px; padding: 0; font-size: 13.5px; }
@media (pointer: coarse) { .asst-ask { min-height: 44px; } }
.asst-hour { min-height: 44px; }
.asst-hour-v { color: var(--ink); text-align: end; }
.asst-hour.is-closed b { color: var(--ink-3); font-weight: 500; }
.asst-topic { padding: 12px 18px 4px; }
.asst-topic + .asst-topic { border-top: 1px solid var(--rule); }
.asst-topic h3 { font-size: 13.5px; font-weight: 600; color: var(--ink-2); margin-bottom: 4px; }
.asst-facts, .asst-rules { margin: 0; padding: 4px 18px 12px 36px; display: flex; flex-direction: column; gap: 6px; }
.asst-facts { padding-inline-start: 18px; }
.asst-facts li, .asst-rules li { line-height: 1.5; overflow-wrap: anywhere; }
.asst-rules { padding-top: 12px; }
.asst-req .row-main { gap: 4px; }
.asst-req-body { white-space: pre-wrap; overflow-wrap: anywhere; color: var(--ink); }
.row-main small.asst-note { color: var(--ink-2); }

/* Summary: replies, what the automations did, money waiting */
.sum-v2 { display: grid; gap: 16px; margin-top: 16px; }
.sum-v2:empty { display: none; }
.sum-v2 .card + .card { margin-top: 0; }
.kpis-3 { grid-template-columns: 1fr; }
@media (min-width: 900px) { .kpis-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.kpi-cap { font-size: 12px; color: var(--ink-3); }
.act-list .row { min-height: 48px; }
.act-list .row-side { max-width: 40%; font-size: 13px; }
.sum-sub { font-size: 14.5px; font-weight: 700; padding: 14px 18px 6px; border-top: 1px solid var(--rule); }
.recent-list { list-style: none; margin: 0; padding: 0 0 6px; }
.recent-list li { display: grid; grid-template-columns: 112px minmax(0, 1fr); gap: 12px; padding: 9px 18px; border-top: 1px solid var(--rule); font-size: 14.5px; }
.recent-list li:first-child { border-top: 0; }
.recent-list time { color: var(--ink-3); font-size: 13.5px; white-space: nowrap; }
.recent-list a { color: var(--ink); justify-self: start; text-align: start; }
@media (max-width: 520px) { .recent-list li { grid-template-columns: 1fr; gap: 0; } }
.sum-money-body { padding: 16px 18px 18px; display: flex; flex-direction: column; align-items: flex-start; gap: 6px; }
.sum-money-fig { font-family: var(--serif); font-size: 36px; font-weight: 400; letter-spacing: -.015em; line-height: 1.15; }
.sum-money-body .btn { margin-top: 6px; }

/* Settings: how the assistant answers questions */
.radio-set { border: 0; margin: 0; padding: 12px 18px 4px; display: flex; flex-direction: column; gap: 8px; }
.radio-row { display: flex; align-items: flex-start; gap: 12px; padding: 12px 14px; border: 1px solid var(--rule); border-radius: 10px; cursor: pointer; }
.radio-row:hover { border-color: var(--field-edge); }
.radio-row:has(input:checked) { border: 2px solid var(--accent); padding: 11px 13px; }
.radio-row input { margin: 3px 0 0; width: 18px; height: 18px; accent-color: var(--ink); flex: 0 0 auto; }
.radio-row.is-off { opacity: .55; cursor: default; }
.radio-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.radio-text b { font-weight: 700; }
.radio-text small { color: var(--ink-2); font-size: 14px; line-height: 1.45; }
.set-sec > .set-note { padding: 0 18px; margin: 8px 0 0; max-width: 80ch; }
.asst-warn .mark { white-space: normal; align-items: flex-start; }
.asst-warn .mark i { margin-top: 4px; }
.set-switch { padding: 10px 18px 16px; border-top: 1px solid var(--rule); margin-top: 14px; }
.set-switch .muted { font-size: 13.5px; }
#set-assistant > .lead { padding-bottom: 6px; }
#set-assistant > .set-note:last-child { padding-bottom: 16px; }

/* rows in the scrolling thread list keep their height (they shrank and overlapped once a list was longer than the pane) */
.inbox-list .threads > .row { flex-shrink: 0; }

/* Notifications on this phone (Settings, every role; API.md 10.2) */
.notify-body .set-note { padding: 0 18px; margin: 4px 0 0; max-width: 80ch; }
.notify-acts { display: flex; flex-wrap: wrap; gap: 8px; padding: 12px 18px 16px; }
.notify-acts:empty { display: none; }
.notify-body:has(.notify-acts:empty) { padding-bottom: 14px; }

/* Inbox-only clinics (API.md 10.1): Today is "Needs a person" alone */
.needs-only .card.list { max-width: 880px; }

/* ---------- Inbox: photos, voice notes, files, follow-ups, New chat (UI.md; API.md 11). Phone first: every
   control 44 px or more, the composer and the recorder at the bottom within a thumb's reach, sheets from the
   bottom, the photo viewer the whole screen. Same look as the rest: flat fills, 1 px edges, no shadow, no blur. ---------- */

.new-chat { flex: 0 0 auto; }
.new-chat .ic { width: 16px; height: 16px; }
.inbox-list-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
@media (pointer: coarse) { .new-chat { min-height: 44px; } }

/* the composer: attach, the words, then the microphone (empty) or Send (typed) in the same place */
.comp-btn { flex: 0 0 auto; display: grid; place-items: center; width: 44px; height: 44px; border-radius: 10px; border: 0; background: transparent; color: var(--ink-2); touch-action: manipulation; }
.comp-btn:hover { background: var(--hover); color: var(--ink); }
.comp-btn:active { background: var(--press); }
.comp-btn .ic { width: 22px; height: 22px; }
.comp-mic { background: #B44A1B; color: #FFFFFF; border-radius: 50%; }
.comp-mic:hover { background: #983D15; color: #FFFFFF; }
.composer.has-mic:not(.has-text) .send { display: none; }
.composer.has-text .comp-mic { display: none; }
.composer textarea { font-size: 16px; } /* 16 px: iOS does not zoom into the field */
.thread .composer, .thread .recorder, .thread .followup { padding-bottom: calc(12px + var(--safe-b, 0px)); }

/* a photo, a voice note, a file inside a bubble */
.bubble.has-media { padding: 4px; display: flex; flex-direction: column; gap: 4px; white-space: normal; }
.bubble.has-media .media-cap { padding: 2px 8px 4px; white-space: pre-wrap; }
.bubble.media-sticker { background: transparent; border-color: transparent; }
.media-img { display: block; padding: 0; border: 0; background: #EFE7CF; border-radius: 10px; overflow: hidden; cursor: zoom-in; width: min(260px, 64vw); }
.media-img img { display: block; width: 100%; height: auto; max-height: 320px; object-fit: cover; min-height: 120px; }
.media-img.is-sticker { width: 128px; background: transparent; }
.media-img.is-sticker img { object-fit: contain; min-height: 0; }
.media-img:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.media-video { display: block; width: min(260px, 62vw); max-width: 100%; max-height: 360px; border-radius: 10px; background: #14120F; }
.media-missing { display: flex; align-items: center; gap: 6px; margin: 0; padding: 6px 8px; color: var(--ink-3); font-size: 14px; }

.voice { display: flex; align-items: center; gap: 10px; min-width: min(250px, 62vw); padding: 2px 8px 2px 2px; }
.voice-play { flex: 0 0 auto; display: grid; place-items: center; width: 44px; height: 44px; border-radius: 50%; border: 0; background: var(--ink); color: #FFFEF7; touch-action: manipulation; }
.voice-play .ic { width: 18px; height: 18px; }
.voice-play:active { transform: scale(.96); }
.voice-seek { flex: 1 1 auto; min-width: 60px; height: 44px; margin: 0; accent-color: var(--accent); background: transparent; }
.voice-time { flex: 0 0 auto; display: inline-flex; align-items: center; gap: 4px; font-size: 13px; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.voice.is-failed .voice-play { background: var(--ink-3); }
.voice-dl { font-size: 13px; font-weight: 600; color: var(--accent-ink); padding: 12px 4px; }
.transcript { padding: 0 8px 6px; font-size: 14px; color: var(--ink-2); }
.transcript summary { min-height: 36px; display: flex; align-items: center; gap: 6px; cursor: pointer; font-weight: 600; color: var(--ink-2); list-style: none; }
.transcript summary::-webkit-details-marker { display: none; }
.transcript summary::before { content: ""; width: 7px; height: 7px; border-inline-end: 1.6px solid currentColor; border-bottom: 1.6px solid currentColor; transform: rotate(-45deg); transition: transform .15s var(--ease); }
.transcript[open] summary::before { transform: rotate(45deg); }
.transcript p { margin: 0; color: var(--ink); white-space: pre-wrap; }

.file-card { display: flex; align-items: center; gap: 12px; min-height: 56px; min-width: min(250px, 62vw); padding: 8px 12px 8px 8px; border-radius: 10px; background: #FFFFFF; border: 1px solid var(--edge); color: var(--ink); text-decoration: none; }
.file-card:hover { text-decoration: none; background: #FFFDF6; }
.file-card:active { background: var(--press); }
.file-ic { flex: 0 0 auto; display: grid; place-items: center; width: 40px; height: 40px; border-radius: 8px; background: #F5ECCB; color: var(--ink-2); }
.file-main { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.file-main b { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.file-main small { color: var(--ink-3); font-size: 13px; font-variant-numeric: tabular-nums; }
.file-dl { flex: 0 0 auto; color: var(--ink-3); }
.file-card.is-static { min-width: 0; }

/* the photo viewer: the whole screen, dark, the photo fitted, close top-left */
body.has-viewer { overflow: hidden; }
.viewer { position: fixed; inset: 0; z-index: 95; display: flex; flex-direction: column; background: #0C0B09; opacity: 0; transition: opacity .18s var(--ease); touch-action: none; }
.viewer.open { opacity: 1; }
.viewer-bar { display: flex; align-items: center; gap: 8px; padding: calc(8px + env(safe-area-inset-top)) 8px 8px; color: #FBF5DF; flex: 0 0 auto; }
.viewer-btn { display: grid; place-items: center; width: 48px; height: 48px; border-radius: 50%; border: 0; background: rgba(251, 245, 223, .12); color: #FBF5DF; }
.viewer-btn:hover { background: rgba(251, 245, 223, .2); text-decoration: none; }
.viewer-btn .ic { width: 22px; height: 22px; }
.viewer-who { flex: 1; min-width: 0; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.viewer-stage { flex: 1 1 auto; min-height: 0; display: grid; place-items: center; padding: 8px; }
.viewer-stage img { max-width: 100%; max-height: 100%; object-fit: contain; transition: transform .2s var(--ease); user-select: none; -webkit-user-drag: none; }
.viewer-cap { flex: 0 0 auto; margin: 0; padding: 12px 16px calc(16px + env(safe-area-inset-bottom)); color: #FBF5DF; font-size: 16px; line-height: 1.45; max-height: 30vh; overflow-y: auto; }

/* the recorder takes the composer's place: delete on the left, stop / send on the right under the thumb */
.recorder { display: flex; align-items: center; gap: 10px; padding: 10px 12px 12px; border-top: 1px solid var(--rule); background: var(--sheet); flex: 0 0 auto; }
.rec-btn { flex: 0 0 auto; display: grid; place-items: center; width: 52px; height: 52px; border-radius: 50%; border: 1px solid var(--field-edge); background: var(--field); color: var(--ink-2); touch-action: manipulation; }
.rec-btn .ic { width: 22px; height: 22px; }
.rec-btn:active { transform: scale(.96); }
.rec-stop, .rec-send { background: #B44A1B; border-color: #B44A1B; color: #FFFFFF; }
.rec-live { flex: 1 1 auto; display: flex; align-items: center; gap: 10px; min-height: 52px; font-size: 16px; }
.rec-live i { width: 12px; height: 12px; border-radius: 50%; background: var(--red-dot); animation: rec-pulse 1.2s ease-in-out infinite; }
.rec-time { font-weight: 700; font-variant-numeric: tabular-nums; min-width: 3.2em; }
.rec-word { color: var(--ink-2); }
.recorder .voice { flex: 1 1 auto; min-width: 0; padding: 0; }
@keyframes rec-pulse { 50% { opacity: .35; } }

/* after 24 hours: one sentence and one big button where the composer was */
.followup { display: flex; flex-direction: column; gap: 10px; padding: 12px 16px 14px; border-top: 1px solid var(--rule); background: var(--sheet); flex: 0 0 auto; }
.followup-why { display: flex; align-items: flex-start; gap: 10px; margin: 0; color: var(--ink-2); font-size: 14.5px; }
.followup-why .ic { width: 18px; height: 18px; color: var(--ink-3); margin-top: 2px; }
.followup-btn { min-height: 48px; font-size: 16px; }

/* sheets: attach, the follow-up picker, New chat */
.attach-choices { display: flex; flex-direction: column; gap: 8px; }
.attach-row { display: flex; align-items: center; gap: 14px; min-height: 64px; padding: 10px 14px; border-radius: 12px; border: 1px solid var(--edge); background: #FFFFFF; cursor: pointer; }
.attach-row:hover { background: #FFFDF6; }
.attach-row:active { background: var(--press); }
.attach-row:focus-within { outline: 2px solid var(--accent); outline-offset: 2px; }
.attach-row > .ic { width: 26px; height: 26px; color: var(--ink-2); }
.attach-row span { display: flex; flex-direction: column; gap: 2px; }
.attach-row small { color: var(--ink-3); font-size: 13.5px; }
.attach-img { border-radius: 12px; overflow: hidden; background: #EFE7CF; display: grid; place-items: center; max-height: 46dvh; }
.attach-img img { display: block; max-width: 100%; max-height: 46dvh; object-fit: contain; }

.tpl { display: flex; flex-direction: column; gap: 16px; }
.tpl-lang { align-self: flex-start; }
.tpl-lang button { min-height: 44px; padding: 0 16px; }
.tpl-lang button.on { background: var(--ink); color: #FFFEF7; }
.tpl-list { display: flex; flex-direction: column; gap: 8px; border: 0; padding: 0; margin: 0; }
.tpl-opt { display: flex; align-items: center; gap: 12px; min-height: 60px; padding: 10px 14px; border-radius: 12px; border: 1px solid var(--edge); background: #FFFFFF; cursor: pointer; }
.tpl-opt.on { border-color: var(--ink); outline: 1px solid var(--ink); outline-offset: -2px; }
.tpl-opt.is-off { cursor: default; color: var(--ink-3); background: transparent; }
.tpl-opt input { width: 20px; height: 20px; accent-color: var(--ink); flex: 0 0 auto; margin: 0; }
.tpl-opt-main { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.tpl-opt-main small { color: var(--ink-3); font-size: 13px; }
.tpl-fields { display: flex; flex-direction: column; gap: 12px; }
.tpl-fields input { min-height: 48px; font-size: 16px; }
.tpl-prev-wrap { display: flex; flex-direction: column; gap: 6px; }
.tpl-prev-label { margin: 0; font-size: 13.5px; font-weight: 600; color: var(--ink-2); }
.tpl-preview { align-self: flex-end; max-width: 92%; background: #F5ECCB; border: 1px solid #E7D9A8; border-end-end-radius: 4px; }
.tpl-note { margin: 0; color: var(--ink-2); font-size: 14px; }
.tpl-actions { position: sticky; bottom: 0; padding: 8px 0 4px; background: var(--sheet); }
.tpl-actions .btn { min-height: 52px; font-size: 16px; }
.tpl-why { margin: 0 0 14px; color: var(--ink-2); }
.tpl-loading { display: flex; flex-direction: column; gap: 12px; padding: 8px 0; }
.tpl-loading .sk { height: 56px; border-radius: 12px; }

.newchat { display: flex; flex-direction: column; gap: 10px; }
.newchat input { min-height: 48px; font-size: 16px; }
.newchat-lead { margin: 0; font-size: 14px; }
.newchat-row { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 60px; padding: 8px 4px; border: 0; border-top: 1px solid var(--rule); background: none; text-align: start; color: var(--ink); }
.newchat-row:first-child { border-top: 0; }
.newchat-row > .ic { color: var(--ink-3); }

/* phones: the open chat fills the screen above the keyboard (inbox.js sets --kb from the visual viewport) */
@media (max-width: 959px) {
  .inbox.has-thread .thread { bottom: var(--kb, 0px); --safe-b: env(safe-area-inset-bottom); padding-bottom: 0; }
  .panel-tpl .panel-body, .panel-attach .panel-body, .panel-newchat .panel-body { padding-bottom: calc(16px + env(safe-area-inset-bottom)); }
  .panel-tpl { max-height: 94dvh; }
}
@media (min-width: 960px) { .media-img { width: 300px; } }
@media (prefers-reduced-motion: reduce) { .rec-live i { animation: none; } .viewer, .viewer-stage img { transition: none; } }
/* a file still on its way (API.md 11.1), and the hint under a follow-up field */
.media-missing.is-arriving { color: var(--ink-2); }
.sk-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--amber-dot); animation: rec-pulse 1.2s ease-in-out infinite; flex: 0 0 auto; }
.field-hint { color: var(--ink-3); font-size: 13px; line-height: 1.4; }
@media (prefers-reduced-motion: reduce) { .sk-dot { animation: none; } }
/* the two export cards keep their icon beside the words at phone width */
.export-all .row-main { flex: 1 1 180px; min-width: 0; }

/* ---------- Inbox: the clinic's WhatsApp (UI.md "Inbox: the clinic's WhatsApp", API.md 12) ----------
 * Same Framed sheet: flat fills, 1px edges, no shadow. Orange only on the unread count (the one thing to act on in a
 * row), the read ticks and the selected filter. Labels are dots with words, like every other status mark. */

/* search: one field above the filters, 44px, the list's place while typed */
.inbox-search { position: relative; display: flex; align-items: center; margin: 12px 12px 0; }
.inbox-search input { width: 100%; min-height: 44px; padding: 0 44px 0 40px; border-radius: 22px; border: 1px solid var(--field-edge); background: var(--field); font: inherit; font-size: 16px; color: var(--ink); }
.inbox-search input::-webkit-search-cancel-button { display: none; }
.inbox-search input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.inbox-search-ic { position: absolute; inset-inline-start: 13px; display: inline-flex; color: var(--ink-3); pointer-events: none; }
.inbox-search-ic .ic { width: 18px; height: 18px; }
.inbox-search-x { position: absolute; inset-inline-end: 2px; width: 40px; height: 40px; border-radius: 20px; }
.list-group { font-size: 13px; font-weight: 600; color: var(--ink-3); margin: 14px 16px 2px; }
.search-hit mark, .thread-top mark { background: #F5DFAF; color: inherit; border-radius: 2px; padding: 0 1px; }
.search-none { padding: 20px 16px; }

/* filters: Waiting, Unread, Drafts, All, Mine, then the owner's labels; one row that scrolls sideways */
.inbox-labels { display: inline-flex; align-items: stretch; gap: 4px; flex: 0 0 auto; }
.inbox-labels:empty { display: none; }
.inbox-labels-sep { width: 1px; background: var(--rule); margin: 10px 4px; }
.inbox-labels button .lbl { pointer-events: none; }

/* a label: a coloured square and its name */
.lbl { display: inline-flex; align-items: center; gap: 5px; font-size: 12.5px; font-weight: 600; color: var(--ink-2); white-space: nowrap; max-width: 160px; }
.lbl > span { overflow: hidden; text-overflow: ellipsis; }
.lbl i { width: 8px; height: 8px; border-radius: 2px; flex: 0 0 auto; background: var(--ink-3); }
.lbl-orange i { background: var(--accent); }
.lbl-green i { background: var(--green-lit); }
.lbl-amber i { background: var(--amber-dot); }
.lbl-red i { background: var(--red-dot); }
.lbl-ink i { background: var(--ink); }
.lbl-grey i { background: #B7AE9C; }

/* a list row: the unread count, the "why" line */
.thread-mid { display: flex; align-items: center; gap: 8px; min-width: 0; }
.thread-mid .last { flex: 1; min-width: 0; }
.unread-n { flex: 0 0 auto; min-width: 22px; height: 22px; padding: 0 7px; border-radius: 11px; background: var(--accent); color: #FFFFFF; font-size: 12.5px; font-weight: 700; display: inline-grid; place-items: center; }
.unread-n:empty { min-width: 12px; width: 12px; height: 12px; padding: 0; }
.thread-row.is-unread .thread-top b { font-weight: 700; }
.thread-row.is-unread .thread-top time { color: var(--accent-ink); font-weight: 600; }
.thread-row.is-unread .last { color: var(--ink); }
.alert-line { display: flex; align-items: flex-start; gap: 5px; color: var(--ink); font-size: 13.5px; line-height: 1.35; margin-top: 2px; }
.alert-line .ic { width: 13px; height: 13px; color: var(--accent); flex: 0 0 auto; margin-top: 2px; }
.alert-line span { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

/* the thread head: the name opens the patient file */
.thread-who.as-btn { background: none; border: 0; padding: 4px 6px; margin: -4px -6px; border-radius: 8px; text-align: start; font: inherit; color: inherit; cursor: pointer; min-height: 44px; justify-content: center; }
.thread-who.as-btn:hover { background: var(--hover); }
.thread-who.as-btn:active { background: var(--press); }
.thread-head .icon-btn { width: 44px; height: 44px; }
.thread-labels { padding: 6px 16px; border-bottom: 1px solid var(--rule); gap: 4px 12px; }

/* ticks: one = sent, two = delivered, two in the accent = read */
.msg-meta .tick { color: var(--ink-3); }
.msg-meta .tick-read { color: var(--accent); }
.msg-meta .tick .ic { width: 15px; height: 15px; }

/* the message a reply quotes */
.quote { display: flex; flex-direction: column; gap: 1px; width: 100%; margin: -2px 0 6px; padding: 6px 10px; border: 0; border-inline-start: 3px solid var(--ink-3);
  border-radius: 6px; background: rgba(20, 18, 15, .05); font: inherit; font-size: 13.5px; text-align: start; color: var(--ink-2); cursor: pointer; white-space: normal; }
.quote b { font-size: 12.5px; color: var(--ink); }
.quote span { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.quote-clinic { border-inline-start-color: var(--accent); }
.quote.is-gone { cursor: default; font-style: italic; }
.msg.is-flash .bubble { outline: 2px solid var(--accent); outline-offset: 2px; }

/* a reaction on its message */
.reacts { align-self: flex-start; margin-top: -10px; margin-inline-start: 10px; padding: 1px 7px; border-radius: 12px; background: #FFFFFF; border: 1px solid var(--edge); font-size: 14px; line-height: 20px; }
.msg-out .reacts { align-self: flex-end; margin-inline-end: 10px; }

/* a shared place or contact card */
.bubble.has-share { padding: 6px; }
.share-card { display: flex; align-items: center; gap: 12px; min-height: 56px; min-width: min(250px, 62vw); padding: 8px 12px 8px 8px; border-radius: 10px; background: #FFFFFF; border: 1px solid var(--edge); color: var(--ink); text-decoration: none; white-space: normal; }
.share-card + .share-card { margin-top: 6px; }
.share-card .file-main { display: flex; flex-direction: column; min-width: 0; }
.share-card .file-main a { color: var(--ink); font-size: 14px; display: inline-block; min-height: 32px; line-height: 32px; }
a.share-card:hover { text-decoration: none; background: #FFFDF6; }

/* tap a message: Reply and Copy under it */
.msg-acts { display: flex; gap: 8px; margin-top: 2px; }
.msg-acts .btn { min-height: 44px; }
.msg-out .msg-acts { justify-content: flex-end; }

/* replying to one message: the strip above the composer */
.reply-strip { display: flex; align-items: center; gap: 10px; padding: 8px 8px 0 16px; border-top: 1px solid var(--rule); background: var(--sheet); flex: 0 0 auto; }
.reply-strip-bar { width: 3px; align-self: stretch; border-radius: 2px; background: var(--accent); }
.reply-strip-main { flex: 1; min-width: 0; display: flex; flex-direction: column; font-size: 13.5px; }
.reply-strip-main b { font-size: 12.5px; }
.reply-strip-main span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--ink-2); }
.reply-strip .icon-btn { width: 44px; height: 44px; }
.reply-strip + .composer { border-top: 0; }

/* a doctor's view of a file they cannot open */
.media-missing.is-locked { align-items: flex-start; max-width: 300px; white-space: normal; }
.media-missing.is-locked .ic { margin-top: 3px; flex: 0 0 auto; }

/* who a file, voice note or template goes to (the wrong-patient guard) */
.to-line { display: flex; flex-direction: column; gap: 2px; margin: 10px 0 4px; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--edge); background: #FFFFFF; }
.to-who { display: flex; align-items: center; gap: 8px; font-size: 15px; color: var(--ink); }
.to-who .ic { width: 18px; height: 18px; color: var(--ink-3); flex: 0 0 auto; }
.to-line small { color: var(--ink-3); font-size: 13px; }
.thread .to-line { margin: 8px 12px 0; }

/* quick replies */
.qr { display: flex; flex-direction: column; gap: 10px; }
.qr-list { display: flex; flex-direction: column; gap: 8px; max-height: 52dvh; overflow-y: auto; }
.qr-row { display: flex; flex-direction: column; gap: 3px; width: 100%; min-height: 56px; padding: 10px 14px; border-radius: 12px; border: 1px solid var(--edge); background: #FFFFFF; font: inherit; text-align: start; color: var(--ink); cursor: pointer; }
.qr-row:hover { background: #FFFDF6; }
.qr-row:active { background: var(--press); }
.qr-row small { color: var(--ink-2); font-size: 14px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; white-space: pre-wrap; }
.qr-lang { font-style: normal; font-weight: 500; font-size: 12.5px; color: var(--ink-3); margin-inline-start: 6px; }
.qr-find input { min-height: 44px; font-size: 16px; }
.form-err { color: var(--red); font-size: 14px; margin: 0; }
.form-err:empty { display: none; }
.btn-danger-ghost { color: var(--red); }

/* the chat menu and labels sheets: big rows */
.attach-choices button.attach-row, .attach-choices a.attach-row { width: 100%; text-align: start; font: inherit; color: var(--ink); text-decoration: none; }
.attach-row .chips { margin-top: 2px; }
.lbl-list { display: flex; flex-direction: column; gap: 6px; border: 0; padding: 0; margin: 0 0 8px; }
.lbl-opt { display: flex; align-items: center; gap: 12px; min-height: 48px; padding: 0 12px; border-radius: 10px; border: 1px solid var(--edge); background: #FFFFFF; cursor: pointer; }
.lbl-opt input { width: 20px; height: 20px; accent-color: var(--accent); }
.lbl-opt .lbl { font-size: 15px; max-width: none; }
.lbl-new { display: flex; flex-direction: column; gap: 10px; padding-top: 8px; border-top: 1px solid var(--rule); }
.lbl-colors { display: flex; flex-wrap: wrap; gap: 6px; border: 0; padding: 0; margin: 0; }
.lbl-colors legend { font-size: 14px; font-weight: 600; color: var(--ink-2); margin-bottom: 6px; padding: 0; }
.lbl-color { position: relative; }
.lbl-color input { position: absolute; opacity: 0; inset: 0; }
.lbl-color .lbl { min-height: 44px; padding: 0 12px; border-radius: 22px; border: 1px solid var(--edge); background: #FFFFFF; font-size: 13.5px; }
.lbl-color input:checked + .lbl { border: 2px solid var(--ink); padding: 0 11px; }
.lbl-color input:focus-visible + .lbl { outline: 2px solid var(--accent); outline-offset: 2px; }
.lbl-manage { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.lbl-manage li { display: flex; align-items: center; justify-content: space-between; min-height: 48px; border-bottom: 1px solid var(--rule); }
.lbl-manage .icon-btn { width: 44px; height: 44px; }

/* Settings → Inbox */
.inbox-set { display: flex; flex-direction: column; gap: 16px; padding: 14px 18px 18px; }
.inbox-set > h3 { font-size: 15px; font-weight: 700; margin: 6px 0 -6px; }
.inbox-set .inline-form { margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.set-field select { min-height: 44px; font-size: 16px; max-width: 360px; width: 100%; }
.ibx-switch { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; }
.ibx-switch .switch { text-align: start; }
.ibx-switch .field-hint { max-width: 60ch; }

/* Summary → Chats (owner) */
.sum-inbox { margin-top: 16px; }
.sum-inbox .kpis-flat { border-top: 1px solid var(--rule); }
.sum-inbox-sub { font-size: 15px; margin: 18px 18px 4px; }
@media (max-width: 639px) { .sum-inbox .kpis-flat { grid-template-columns: 1fr 1fr; } }
.sum-inbox .tbl-wrap { padding: 0 8px 8px; }
.sum-people th[scope=row] { text-align: start; font-weight: 600; }

@media (max-width: 959px) {
  .inbox-search { margin: 4px 0 0; }
  .inbox-filters { margin: 4px 0 0; }
}
.attach-row .chips { display: inline-flex; flex-direction: row; flex-wrap: wrap; }
.attach-row .lbl { flex-direction: row; display: inline-flex; }
.attach-row .lbl > span { display: inline; }
.attach-row > .ic, .attach-row > svg { flex: 0 0 auto; }
