/* ============================================================
   bCare by bTaskee — Đặt lịch Chăm sóc người bệnh (ca lẻ)
   Tokens: registered palette only; everything else is derived.
   ============================================================ */
:root {
  --bg: #fffae6;
  --surface: #ffffff;
  --fg: #111827;
  --muted: #6b7280;
  --border: #e8d99a;
  --accent: #ff5f00;
  --navy: #002379;
  --ok: #1bb55c;       /* success tick only — the green of icons/payment-tickdone.svg, outside the registered palette */
  --danger: #d32f2f;   /* field errors only — outside the registered palette, pending a red from Figma */

  --accent-hover: color-mix(in srgb, var(--accent) 88%, var(--fg));
  --accent-tint: color-mix(in srgb, var(--accent) 10%, transparent);
  --accent-soft: color-mix(in srgb, var(--accent) 5%, var(--surface));
  --accent-line: color-mix(in srgb, var(--accent) 22%, transparent);
  --accent-glow: color-mix(in srgb, var(--accent) 28%, transparent);
  --navy-tint: color-mix(in srgb, var(--navy) 8%, transparent);
  --copy: color-mix(in srgb, var(--fg) 80%, var(--surface));
  --disabled: color-mix(in srgb, var(--muted) 22%, var(--surface));
  --field-border: color-mix(in srgb, var(--border) 62%, var(--fg));   /* edge of inputs and choice cards: 3:1 on white and cream */
  --focus: var(--accent-hover);                                        /* focus ring: 3:1 on cream, plain --accent is not */
  --bg-glass: color-mix(in srgb, var(--bg) 97%, transparent);
  --scrim: color-mix(in srgb, var(--navy) 45%, transparent);
  --shadow-card: 0 1px 3px color-mix(in srgb, var(--fg) 5%, transparent), 0 1px 2px color-mix(in srgb, var(--fg) 3%, transparent);
  --shadow-modal: 0 16px 40px color-mix(in srgb, var(--navy) 18%, transparent);

  --font: "Montserrat", -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --page-max: 1200px;
  --page-px: 48px;
  --nav-h: 72px;
  /* fluid heading sizes: one curve from 360px to ~780px instead of a jump at each breakpoint */
  --h-lg: clamp(20px, 17px + .9vw, 24px); --h-md: clamp(18px, 16px + .8vw, 22px); --h-sm: clamp(17px, 15px + .7vw, 20px);
  --r-sm: 8px; --r-md: 12px; --r-lg: 16px; --r-pill: 9999px;
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-tap-highlight-color: var(--accent-tint); }
body { margin: 0; background: var(--bg); color: var(--fg); font: 500 16px/1.7 var(--font); -webkit-font-smoothing: antialiased; }
img { display: block; max-width: 100%; }
::selection { background: color-mix(in srgb, var(--accent) 24%, var(--surface)); color: var(--fg); }
input, textarea { caret-color: var(--accent); }
h1, h2, h3, h4, p, dl, dd, fieldset, legend { margin: 0; padding: 0; }
fieldset { border: 0; min-width: 0; }
h1, h2, h3, h4 { color: var(--navy); text-wrap: balance; }   /* headings: lines of even length */
p, li, dd, small, label, legend { text-wrap: pretty; }       /* running text: never a lone last word */
ul { margin: 0; padding: 0; list-style: none; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: inherit; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 3px; border-radius: 4px; }
[tabindex="-1"]:focus { outline: none; }   /* headings that only take focus from the script */
.icon { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.icon-sm { width: 16px; height: 16px; }
.icon-lg { width: 24px; height: 24px; stroke-width: 1.75; }
.wrap { max-width: var(--page-max); margin: 0 auto; padding: 0 var(--page-px); }
.hl { color: var(--accent); }
.num { font-variant-numeric: tabular-nums; white-space: nowrap; }   /* prices, phone numbers: never split */
a[href^="tel:"] { white-space: nowrap; }

/* ---------- Buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 50px; padding: 0 32px; border: 0; border-radius: var(--r-sm); font-size: 15px; font-weight: 700; text-decoration: none; cursor: pointer; white-space: nowrap; transition: background .25s, transform .25s, color .25s, border-color .25s; }
.btn-primary { background: var(--accent); color: var(--surface); box-shadow: 0 4px 14px var(--accent-glow); }
.btn-primary:hover { background: var(--accent-hover); transform: translateY(-2px); }
.btn-navy { background: var(--navy); color: var(--surface); }
.btn-navy:hover { transform: translateY(-2px); }
.btn-ghost { background: var(--surface); color: var(--navy); border: 1px solid var(--border); }
.btn-ghost:hover { border-color: var(--accent); background: var(--accent-soft); }
.btn[aria-disabled="true"], .btn:disabled { background: var(--disabled); color: var(--muted); box-shadow: none; cursor: not-allowed; transform: none; }
.btn-block { width: 100%; }
.link { display: inline-flex; align-items: center; gap: 6px; min-height: 44px; font-size: 14px; font-weight: 700; color: var(--navy); text-decoration: underline; text-underline-offset: 3px; background: none; border: 0; padding: 0; cursor: pointer; }
.link:hover { text-decoration-color: var(--accent); text-decoration-thickness: 2px; }

/* ---------- Navbar ---------- */
.nav { position: fixed; inset: 0 0 auto 0; height: var(--nav-h); z-index: 1000; background: var(--bg); border-bottom: 1px solid transparent; transition: border-color .25s, background .25s; }
.nav.scrolled { background: var(--bg-glass); backdrop-filter: blur(12px); border-bottom-color: var(--border); }
.nav-in { height: 100%; display: flex; align-items: center; justify-content: space-between; gap: 24px; }
.nav-logo img { height: 34px; width: auto; }
.nav-call { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 14px; border-radius: var(--r-sm); font-size: 14px; font-weight: 700; color: var(--navy); text-decoration: none; }
.nav-call:hover { background: var(--accent-tint); }

/* ---------- Page top (no hero: the form is the first thing on the page) ---------- */
main { padding: calc(var(--nav-h) + 32px) 0 96px; }
.elder { padding: 0 4px; font-size: 13px; color: var(--muted); line-height: 1.5; }
.elder a { color: var(--navy); font-weight: 700; }

/* ---------- Views ---------- */
.view { display: none; }
body[data-view="flow"] #view-flow, body[data-view="patient"] #view-patient, body[data-view="task"] #view-task { display: block; }
.narrow { max-width: 720px; margin: 0 auto; }

/* ---------- Mobile progress (hidden on desktop) ---------- */
.progress { display: none; }

/* ---------- Flow layout ---------- */
.flow { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 32px; align-items: start; }
.steps { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; min-width: 0; container-type: inline-size; }
.step { min-width: 0; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--shadow-card); }

.step-head { display: flex; align-items: center; gap: 14px; padding: 20px 28px; }
.step-no { width: 32px; height: 32px; flex: none; display: grid; place-items: center; border-radius: 50%; background: var(--disabled); color: var(--muted); font-size: 14px; font-weight: 700; line-height: 1; }
.step h2 { font-size: 20px; font-weight: 700; line-height: 1.25; color: var(--muted); }
.step-recap { flex: 1; min-width: 0; font-size: 14px; color: var(--copy); line-height: 1.45; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* Edit = icon-only button (square-pen), 44px target, named by aria-label */
.edit { flex: none; width: 44px; height: 44px; display: inline-grid; place-items: center; padding: 0; background: none; border: 0; border-radius: var(--r-sm); color: var(--navy); cursor: pointer; transition: background .2s, color .2s; }
.edit:hover { background: var(--navy-tint); color: var(--accent); }
.step-edit { margin: -6px -10px -6px auto; }
.step-body { display: none; padding: 4px 28px 28px; }
.step.is-active .step-body { display: block; }
.step.is-active .step-no { background: var(--navy); color: var(--surface); }
.step.is-active h2 { color: var(--navy); font-size: var(--h-lg); }
.step.is-active .step-head { padding: 28px 28px 16px; }   /* open card: top inset matches the sides */
.step.is-done .step-head { padding: 12px 28px; }          /* answered step: one compact recap row */
.step.is-done .step-no { background: var(--accent-tint); color: var(--accent); }
.step.is-done h2 { color: var(--navy); font-size: 16px; flex: none; }
.step:not(.is-done) .step-recap, .step:not(.is-done) .step-edit { display: none; }
.step-foot { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; margin-top: 28px; }
.step-foot .hint { margin: 0; }
.step-foot .hint.is-blocked { color: var(--danger); font-weight: 700; }   /* "Tiếp tục" was pressed while this was missing */

/* ---------- Fields ---------- */
.field { margin-top: 24px; }
.field:first-child, .msg + .field { margin-top: 0; }
.label { display: block; font-size: 13px; font-weight: 700; color: var(--navy); margin-bottom: 8px; }
.label small { font-weight: 500; color: var(--muted); font-size: 12px; }
.label.optional { color: var(--muted); }   /* optional field: grey label; required: red * (.req) */
.hint { font-size: 13px; color: var(--muted); line-height: 1.5; margin-bottom: 10px; }
.input, .select, .textarea { width: 100%; min-height: 48px; padding: 0 14px; background: var(--surface); border: 1.5px solid var(--field-border); border-radius: var(--r-sm); font-size: 15px; font-weight: 500; }
.textarea { padding: 12px 14px; min-height: 88px; resize: vertical; line-height: 1.6; }
/* Native select: same chevron as the custom dropdown (stroke = --muted; a data URI cannot read the token) */
.select { appearance: none; -webkit-appearance: none; padding-right: 36px; cursor: pointer; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; background-size: 18px; }
.input:focus-visible, .select:focus-visible, .textarea:focus-visible { border-color: var(--focus); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 40%, transparent); outline: none; }
.input.is-invalid, .select.is-invalid, .tp.is-invalid, .field.is-invalid .opt-box, .field.is-invalid .day span { border-color: var(--danger); }
.check input.is-invalid { outline: 2px solid var(--danger); outline-offset: 2px; }
/* Field error: red text under the field, bottom-right */
.err { margin-top: 6px; font-size: 13px; font-weight: 600; line-height: 1.4; color: var(--danger); text-align: right; }
.err:empty { display: none; }
.req { color: var(--danger); }
.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.row-2.lead-short { grid-template-columns: minmax(210px, 1fr) 2fr; }   /* short picker + long free-text field */
.row-2:has(> [hidden]) { grid-template-columns: 1fr; }
.msg { display: flex; gap: 10px; align-items: flex-start; margin-top: 12px; padding: 12px 14px; border-radius: var(--r-sm); background: var(--navy-tint); font-size: 14px; font-weight: 600; color: var(--navy); line-height: 1.5; }
.msg .icon { color: var(--accent); margin-top: 1px; }
.msg a { font-weight: 700; white-space: nowrap; }

/* ---------- Choice cards ---------- */
.opts { display: grid; gap: 12px; }
.cols-2 { grid-template-columns: repeat(2, 1fr); }
.cols-4 { grid-template-columns: repeat(4, 1fr); }
.opt { position: relative; display: block; cursor: pointer; }
.opt input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
.opt-box { display: block; height: 100%; padding: 18px; background: var(--surface); border: 1.5px solid var(--field-border); border-radius: var(--r-md); transition: border-color .2s, background .2s, box-shadow .2s; }
.opt:hover .opt-box { border-color: var(--accent); }
.opt input:checked + .opt-box { border-color: var(--accent); background: var(--accent-soft); box-shadow: 0 0 0 3px var(--accent-tint); }
.opt input:focus-visible + .opt-box { outline: 2px solid var(--focus); outline-offset: 3px; }
.opt input:disabled { cursor: not-allowed; }
.opt input:disabled + .opt-box { background: color-mix(in srgb, var(--muted) 6%, var(--surface)); border-color: var(--disabled); }
.opt:has(input:disabled):hover .opt-box { border-color: var(--disabled); }
.opt-title { display: block; font-size: 16px; font-weight: 700; color: var(--navy); line-height: 1.35; }
.opt-desc { display: block; font-size: 13px; color: var(--muted); line-height: 1.5; margin-top: 4px; }
.opt input:disabled + .opt-box .opt-title { color: var(--muted); }
.tile { width: 44px; height: 44px; flex: none; display: grid; place-items: center; border-radius: var(--r-md); background: var(--accent-tint); color: var(--accent); }
.media .opt-box { display: flex; gap: 14px; align-items: center; }
/* Figma assets (PNG): keep their own colours in every state; selected / locked is shown by the card border and background. */
.tile-img { width: 56px; height: 56px; flex: none; object-fit: contain; border-radius: var(--r-md); }
.ph { flex: none; border-radius: 25%; }
.pkg-lock { display: block; font-size: 13px; font-weight: 600; color: var(--navy); line-height: 1.5; margin-top: 6px; }
.pkg-lock a { position: relative; z-index: 1; font-weight: 700; white-space: nowrap; }   /* above the radio that covers the card */
.pkg-text { flex: 1; min-width: 0; }
.pkg-name { display: flex; align-items: center; gap: 4px; }
.pkg-name .opt-title { display: inline; cursor: pointer; }
.help { position: relative; z-index: 1; flex: none; width: 28px; height: 28px; margin: -4px 0; display: grid; place-items: center; background: none; border: 0; border-radius: 50%; color: var(--navy); cursor: pointer; }
.help::before { content: ""; position: absolute; inset: -8px; }   /* 44px hit area around the 28px glyph */
.help:hover { background: var(--navy-tint); }
.dur .opt-box { text-align: center; padding: 14px 8px; }
.dur b { display: block; font-size: 16px; color: var(--navy); line-height: 1.3; }
.dur span { font-size: 14px; color: var(--copy); font-weight: 600; }
.pay .opt-box { display: flex; align-items: center; gap: 14px; padding: 14px 16px; }   /* cash is the only method for now: one card, selected */
.pay .icon { color: var(--navy); }

/* ---------- Address search + map ---------- */
.search { position: relative; }
.search .icon { position: absolute; left: 14px; top: 14px; color: var(--muted); pointer-events: none; }
.search .input { padding-left: 44px; }
.sugg { position: absolute; z-index: 20; left: 0; right: 0; top: calc(100% + 6px); background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md); box-shadow: 0 10px 28px color-mix(in srgb, var(--fg) 10%, transparent); padding: 6px; max-height: 280px; overflow-y: auto; scrollbar-width: thin; scrollbar-color: var(--border) transparent; }
.sugg button { display: flex; gap: 10px; align-items: flex-start; width: 100%; min-height: 44px; padding: 10px 12px; background: none; border: 0; border-radius: var(--r-sm); text-align: left; font-size: 14px; line-height: 1.45; cursor: pointer; }
.sugg button:hover, .sugg button:focus-visible { background: var(--accent-tint); }
.sugg .pin-img { width: 14px; height: 18px; flex: none; margin-top: 1px; }
.sugg-empty { padding: 12px; font-size: 14px; color: var(--muted); }

/* ---------- Dropdown (Loại nhà) ---------- */
.dd { position: relative; }
.dd-btn { display: flex; align-items: center; gap: 10px; font-family: inherit; text-align: left; color: var(--fg); cursor: pointer; }
.dd-btn > span { flex: 1; min-width: 0; }
.dd-btn > .icon:first-child, .dd-list .icon { color: var(--navy); }
.dd-btn .dd-chev { color: var(--muted); transition: transform .2s; }
.dd-btn[aria-expanded="true"] .dd-chev { transform: rotate(180deg); }
.dd-list { position: absolute; z-index: 20; left: 0; right: 0; top: calc(100% + 6px); margin: 0; padding: 6px; list-style: none; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md); box-shadow: 0 10px 28px color-mix(in srgb, var(--fg) 10%, transparent); }
.dd-list li { display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 0 12px; border-radius: var(--r-sm); font-size: 15px; font-weight: 500; cursor: pointer; }
.dd-list li:hover, .dd-list li:focus-visible { background: var(--accent-tint); }
.dd-list li::after { content: ""; flex: none; width: 18px; height: 18px; margin-left: auto; border: 1.5px solid var(--field-border); border-radius: 50%; }
.dd-list li[aria-selected="true"] { font-weight: 700; color: var(--navy); }
.dd-list li[aria-selected="true"]::after { border-color: var(--accent); background: radial-gradient(circle, var(--accent) 0 5px, transparent 5.5px); }
.map { position: relative; height: 220px; margin-top: 12px; border: 1px solid var(--border); border-radius: var(--r-md); overflow: hidden; background-color: color-mix(in srgb, var(--border) 22%, var(--surface));
  background-image: linear-gradient(var(--surface) 0 0), linear-gradient(var(--surface) 0 0), repeating-linear-gradient(0deg, transparent 0 54px, var(--surface) 54px 60px), repeating-linear-gradient(90deg, transparent 0 84px, var(--surface) 84px 90px);
  background-size: 100% 14px, 18px 100%, auto, auto; background-position: 0 58%, 38% 0, 0 0, 0 0; background-repeat: no-repeat, no-repeat, repeat, repeat; }
.map-tag { position: absolute; left: 10px; top: 10px; padding: 3px 10px; border-radius: var(--r-pill); background: var(--surface); border: 1px solid var(--border); font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.pin { position: absolute; width: 44px; height: 44px; margin: -40px 0 0 -22px; display: grid; place-items: center; background: none; border: 0; color: var(--accent); cursor: grab; touch-action: none; }   /* only the pin takes the gesture: a swipe across the map scrolls the page */
.pin:active { cursor: grabbing; }
.pin svg { width: 36px; height: 36px; fill: var(--accent); stroke: var(--surface); stroke-width: 1.5; filter: drop-shadow(0 4px 6px color-mix(in srgb, var(--fg) 25%, transparent)); }

/* ---------- Date strip + time ---------- */
.label-ico .icon { vertical-align: -5px; margin-right: 8px; color: var(--navy); }
.legend { display: flex; flex-wrap: wrap; gap: 4px 16px; font-size: 13px; line-height: 1.5; color: var(--copy); }   /* a key, not a control: no box */
.legend i { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--navy); margin-right: 6px; }
.legend i.peak { background: var(--accent); }
/* 7 days. Overflowing strip: hold-and-drag with the mouse (.can-drag), native swipe on touch, thin scrollbar stays visible. */
.days { position: relative; display: flex; gap: 8px; overflow-x: auto; padding: 12px 4px 10px; margin: 0 -4px; scroll-snap-type: x proximity; user-select: none; -webkit-user-select: none; }
/* Standard scrollbar props would hand Chrome/Safari back to auto-hiding overlay bars; only use them where ::-webkit-scrollbar is missing. */
@supports not selector(::-webkit-scrollbar) { .days { scrollbar-width: thin; scrollbar-color: var(--border) transparent; } }
.days::-webkit-scrollbar { height: 6px; }
.days::-webkit-scrollbar-track { background: transparent; }
.days::-webkit-scrollbar-thumb { background: var(--border); border-radius: var(--r-pill); }
.days.can-drag .day input:not(:disabled) { cursor: grab; }
.days.dragging { scroll-snap-type: none; }
.days.dragging .day input { cursor: grabbing; }
.day { flex: 0 0 64px; scroll-snap-align: start; position: relative; }
.day input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
.day span { display: grid; justify-items: center; gap: 0; padding: 8px 0 10px; border: 1.5px solid var(--field-border); border-radius: var(--r-md); background: var(--surface); line-height: 1.25; transition: border-color .2s, background .2s; }
.day small { font-size: 12px; color: var(--muted); font-weight: 600; }
.day b { font-size: 20px; font-weight: 800; color: var(--navy); }
.day input:checked + span { background: var(--accent-soft); border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-tint); }   /* same as a selected choice card; solid orange is the primary button's */
.day input:disabled + span { background: var(--disabled); border-color: var(--disabled); }
.day input:disabled + span b { color: var(--muted); }
.day input:disabled { cursor: not-allowed; }
.day input:focus-visible + span { outline: 2px solid var(--focus); outline-offset: 3px; }
/* Dots under the date: navy = today, orange = peak day (weekend surcharge) */
.day.today::after, .day.wk::after { content: ""; position: absolute; left: 50%; bottom: 3px; width: 6px; height: 6px; margin-left: -3px; border-radius: 50%; background: var(--navy); }
.day.wk::after { background: var(--accent); }
.day.today.wk::after { background: var(--navy); margin-left: -7px; box-shadow: 8px 0 0 var(--accent); }
/* Start time: hour / minute dropdowns at every width (the phone opens its own picker). The wheels (.tp) are kept but not
   shown: inside a scrolling page a thumb passing over them changed the start time, and with it the price.
   Surcharges are not marked here; the notice below the picker carries them. */
.time-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.tsel { display: flex; align-items: center; gap: 12px; }
.tsel .select { width: 112px; padding: 0 32px; text-align: center; text-align-last: center; font-size: 18px; font-weight: 700; color: var(--navy); }
.tp { display: none; align-items: center; gap: 8px; width: 100%; max-width: 360px; padding: 0 16px; background: var(--surface); border: 1.5px solid var(--field-border); border-radius: var(--r-md); }
.tp-col { flex: 1; height: 132px; padding: 44px 0; overflow-y: auto; scroll-snap-type: y mandatory; overscroll-behavior: contain; scrollbar-width: none; border-radius: var(--r-sm); }
.tp-col::-webkit-scrollbar { display: none; }
.tp-item { position: relative; height: 44px; display: grid; place-items: center; scroll-snap-align: center; color: var(--muted); cursor: pointer; user-select: none; -webkit-user-select: none; }
.tp-item b { font-size: 20px; font-weight: 500; font-variant-numeric: tabular-nums; }
.tp-item.on b { font-size: 28px; font-weight: 800; color: var(--navy); }
.tp-item.off b { opacity: .45; text-decoration: line-through; }
.tsel .colon { font-size: 20px; font-weight: 800; color: var(--navy); }
.tp .colon { font-size: 24px; font-weight: 800; color: var(--navy); }
.asap { min-height: 48px; padding: 0 16px; background: var(--surface); border: 1.5px solid var(--field-border); border-radius: var(--r-sm); font: 600 14px/1 var(--font); color: var(--navy); cursor: pointer; transition: border-color .2s, background .2s; }   /* a shortcut, not a second primary */
.asap:hover { border-color: var(--accent); background: var(--accent-soft); }

/* ---------- Price-increase message (peak hour / weekend / short notice) ---------- */
.fees { display: flex; gap: 10px; align-items: flex-start; margin-top: 12px; padding: 12px 16px; border-radius: var(--r-sm); background: var(--accent-tint); border: 1px solid var(--accent-line); }
.fees > .icon { color: var(--accent); margin-top: 1px; }
.fees p { flex: 1; min-width: 0; font-size: 14px; font-weight: 600; color: var(--fg); line-height: 1.5; }
.endtime { font-size: 14px; color: var(--copy); margin-top: 12px; }
.endtime b { color: var(--navy); }

/* ---------- Voucher / terms ---------- */
.voucher { display: flex; gap: 10px; }
.voucher .input { flex: 1; text-transform: uppercase; }
.voucher .input::placeholder { text-transform: none; }
.voucher .btn { padding: 0 20px; min-height: 48px; }
.check { display: flex; gap: 12px; align-items: flex-start; min-height: 44px; font-size: 14px; color: var(--copy); cursor: pointer; line-height: 1.55; }
.check input { width: 20px; height: 20px; margin: 2px 0 0; flex: none; accent-color: var(--accent); cursor: pointer; }
.check a { color: var(--navy); font-weight: 700; }

/* ---------- Summary ticket ---------- */
.summary { position: sticky; top: calc(var(--nav-h) + 24px); display: grid; gap: 16px; }
.ticket { padding: 24px 28px; }
.ticket h3 { font-size: 18px; font-weight: 700; margin-bottom: 10px; }
.srow { display: flex; justify-content: space-between; gap: 16px; padding: 7px 0; font-size: 14px; line-height: 1.5; }
.srow dt { color: var(--muted); flex: none; }
/* Edit links in the ticket: mobile confirm step only (desktop edits from the step headers) */
.srow dd.has-edit { display: flex; justify-content: flex-end; align-items: flex-start; gap: 8px; }   /* value, then the edit glyph pinned to the right edge, level with the first line */
.srow dd.has-edit > span { min-width: 0; text-wrap: balance; }
.srow dd .empty { color: var(--muted); font-weight: 500; }
.srow-edit { display: none; position: relative; width: 16px; height: 21px; border-radius: 4px; }   /* 21px = one text line */
.srow-edit::before { content: ""; position: absolute; inset: -12px -14px; }                          /* 44px target around it */
.srow-edit:hover { background: none; }
.srow dd { text-align: right; text-wrap: balance; font-weight: 600; color: var(--fg); min-width: 0; overflow-wrap: anywhere; }
.srow dd.empty { color: var(--muted); font-weight: 500; }
.cut { position: relative; margin: 14px -28px; border-top: 1.5px dashed var(--border); }
.cut::before, .cut::after { content: ""; position: absolute; top: -11px; width: 20px; height: 20px; border-radius: 50%; background: var(--bg); border: 1px solid var(--border); }
.cut::before { left: -11px; } .cut::after { right: -11px; }
.total { align-items: baseline; padding-top: 10px; }
.total dt { color: var(--navy); font-weight: 700; font-size: 15px; white-space: nowrap; }
.total dd { font-size: 26px; font-weight: 800; color: var(--accent); letter-spacing: -.01em; white-space: nowrap; overflow-wrap: normal; }
.total dd.empty { font-size: 15px; font-weight: 500; letter-spacing: 0; }

/* ---------- Mobile action bar (hidden on desktop) ---------- */
.mbar { display: none; }

/* ---------- Shift screen + patient form ---------- */
.ok { display: grid; justify-items: center; text-align: center; padding: 24px 24px 20px; margin-bottom: 20px; }
.ok h2 { font-size: var(--h-lg); font-weight: 800; line-height: 1.2; margin-top: 12px; }
.ok p { font-size: 14px; color: var(--copy); line-height: 1.5; }
/* Tick: static by default; with .play (set once, right after the booking is posted) the disc pops, the tick draws and one ring spreads out */
.ok-mark { position: relative; width: 56px; height: 56px; }
.ok-mark::before, .ok-mark::after { content: ""; position: absolute; border-radius: 50%; }
.ok-mark::before { inset: 0; background: color-mix(in srgb, var(--ok) 14%, transparent); }
.ok-mark::after { inset: 7px; border: 2px solid var(--ok); opacity: 0; }
.ok-mark svg { position: relative; display: block; width: 56px; height: 56px; }
.ok-disc { fill: var(--ok); transform-origin: 48px 48px; }
.ok-tick { fill: none; stroke: var(--surface); stroke-width: 6; stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: 1; }
.ok.play .ok-mark::before { animation: ok-halo .5s .1s ease-out both; }
.ok.play .ok-mark::after { animation: ok-ring .9s .3s ease-out both; }
.ok.play .ok-disc { animation: ok-pop .45s cubic-bezier(.2, .9, .3, 1.3) both; }
.ok.play .ok-tick { animation: ok-draw .4s .35s ease-out both; }
@keyframes ok-halo { from { transform: scale(.4); opacity: 0; } }
@keyframes ok-ring { from { transform: scale(1); opacity: .7; } to { transform: scale(1.9); opacity: 0; } }
@keyframes ok-pop { from { transform: scale(0); } }
@keyframes ok-draw { from { stroke-dashoffset: 1; } }
/* Waiting line: grey icon in front, three dots blinking in turn at the end */
.ok .finding { margin-top: 6px; color: var(--muted); text-wrap: balance; }   /* icon and dots are inline: they wrap with the words, never alone */
.ok .finding .icon { display: inline-block; vertical-align: -6px; margin-right: 8px; }
.nowrap { white-space: nowrap; }
.wait-dots i { display: inline-block; width: 3px; height: 3px; margin-left: 3px; border-radius: 50%; background: currentColor; animation: dot 1.2s infinite both; }
.wait-dots i:nth-child(2) { animation-delay: .2s; }
.wait-dots i:nth-child(3) { animation-delay: .4s; }
@keyframes dot { 0%, 80%, 100% { opacity: .2; } 40% { opacity: 1; } }
.panel { padding: 28px; }
.panel h2 { font-size: var(--h-lg); font-weight: 700; line-height: 1.2; }
.panel .cut { margin: 14px -28px; }
.panel > .hint { margin: 6px 0 20px; font-size: 14px; }
.conds { display: grid; grid-template-columns: 1fr 1fr; gap: 0 24px; }
.cond { display: flex; gap: 12px; padding: 10px 0; min-height: 44px; cursor: pointer; align-items: flex-start; }
.cond input { width: 20px; height: 20px; margin: 2px 0 0; flex: none; accent-color: var(--accent); cursor: pointer; }
.cond b { display: block; font-size: 15px; font-weight: 600; line-height: 1.4; }
.cond span span { display: block; font-size: 13px; color: var(--muted); line-height: 1.5; }
.actions { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 28px; }
.actions .btn { flex: 1; min-width: 220px; }
/* Patient card on the shift screen: a prompt first, then a single reminder line */
.pt { margin-top: 20px; }
.pt:has(.pt-ask[hidden]) { padding-block: 16px; }
.pt-ask { display: grid; grid-template-columns: 44px minmax(0, 1fr); gap: 0 16px; align-items: start; }
.pt-ask h2 { font-size: var(--h-sm); line-height: 1.3; }
.pt-ask p { font-size: 15px; color: var(--copy); line-height: 1.6; margin-top: 4px; }
.pt-actions { grid-column: 1 / -1; display: flex; gap: 12px; flex-wrap: wrap; margin-top: 20px; }
.pt-actions .btn { flex: 1 1 200px; }
.pt-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.pt-row > div { min-width: 0; }
.pt-label { font-size: 13px; font-weight: 700; color: var(--navy); line-height: 1.5; }
#t-patient { font-size: 15px; font-weight: 600; color: var(--fg); line-height: 1.5; overflow-wrap: anywhere; }
#t-patient.empty { color: var(--muted); font-weight: 500; }
.pt-row .link { flex: none; }
.pt-row .edit { margin: -6px -10px -6px 0; }
.back { margin-bottom: 8px; }
.app { display: grid; grid-template-columns: minmax(0, 1fr) 148px; gap: 28px; align-items: center; margin-top: 20px; }
.app h2 { font-size: var(--h-md); }
.app li { display: flex; gap: 10px; align-items: flex-start; font-size: 15px; color: var(--copy); line-height: 1.5; margin-top: 10px; }
.app li .icon { color: var(--accent); margin-top: 2px; }
.stores { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 20px; }
.store { display: block; border-radius: 7px; transition: transform .2s; }   /* official store badges, 44px tall */
.store[hidden] { display: none; }
.store img { display: block; height: 44px; width: auto; }
.store:hover { transform: translateY(-2px); }
.qr { aspect-ratio: 1; display: grid; place-items: center; text-align: center; border: 1.5px dashed var(--border); border-radius: var(--r-md); background: var(--navy-tint); font-size: 12px; font-weight: 600; color: var(--muted); padding: 12px; line-height: 1.5; }
.after { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-top: 20px; font-size: 14px; color: var(--copy); }
.after a { font-weight: 700; color: var(--navy); }

/* ---------- Dialogs ---------- */
dialog { width: min(480px, calc(100vw - 32px)); max-height: min(88dvh, 760px); padding: 0; border: 1px solid var(--border); border-radius: var(--r-lg); background: var(--surface); color: var(--fg); box-shadow: var(--shadow-modal); }
dialog.wide { width: min(520px, calc(100vw - 32px)); }
dialog::backdrop { background: var(--scrim); }
/* The dialog is the frame, .dlg scrolls inside it: the close button stays in reach on long content */
dialog[open] { display: flex; flex-direction: column; overflow: hidden; }
.dlg { flex: 1; min-height: 0; padding: 32px 28px 28px; overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; scrollbar-color: var(--border) transparent; }
.dlg-x { position: absolute; top: 10px; right: 10px; width: 44px; height: 44px; display: grid; place-items: center; background: var(--surface); border: 0; border-radius: 50%; color: var(--muted); cursor: pointer; }
.dlg-x:hover { background: color-mix(in srgb, var(--navy) 8%, var(--surface)); color: var(--navy); }
.dlg h3 { font-size: var(--h-md); font-weight: 700; line-height: 1.25; padding-right: 36px; }
.dlg .sub { font-size: 15px; color: var(--copy); margin-top: 8px; line-height: 1.6; }
.dlg .sub b { color: var(--fg); }
.dlg-body { margin-top: 20px; padding: 20px; background: var(--navy-tint); border-radius: var(--r-md); }
.dlg-body em { display: block; font-size: 15px; color: var(--navy); font-weight: 600; margin-bottom: 14px; }
.dlg-body h4 { font-size: 15px; font-weight: 700; margin: 16px 0 6px; }
.dlg-body li { position: relative; padding-left: 18px; font-size: 14px; color: var(--copy); line-height: 1.6; }
.dlg-body li + li { margin-top: 4px; }
.dlg-body li::before { content: ""; position: absolute; left: 4px; top: .7em; width: 5px; height: 5px; border-radius: 50%; background: var(--muted); }
.dlg-body .incl { font-size: 14px; font-style: italic; font-weight: 600; color: var(--navy); margin-top: 14px; }
.stage { margin-top: 20px; }
.stage .btn { margin-top: 20px; }
.otp { letter-spacing: .5em; text-align: center; font-size: 24px; font-weight: 800; color: var(--navy); min-height: 60px; }
.resend { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 8px; font-size: 13px; color: var(--muted); }
.spinner { width: 44px; height: 44px; margin: 12px auto 16px; border-radius: 50%; border: 4px solid var(--accent-tint); border-top-color: var(--accent); animation: spin .9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.center { text-align: center; }
.compare { display: flex; align-items: baseline; justify-content: center; gap: 14px; margin: 16px 0 4px; }
.compare s { font-size: 16px; color: var(--muted); }
.compare b { font-size: 28px; font-weight: 800; color: var(--accent); }
.two { display: flex; gap: 12px; flex-wrap: wrap; }
.two .btn { flex: 1; min-width: 180px; }
.only-m { display: none; }

/* ---------- Contact: one floating button + menu, on every screen and view ---------- */
.consult { position: fixed; right: 20px; bottom: 20px; z-index: 90; display: grid; justify-items: end; gap: 10px; }
.consult-btn { width: 72px; padding: 0; border: 0; border-radius: 50%; background: none; cursor: pointer; transition: transform .25s; }
.consult-btn img { width: 100%; height: auto; }
.consult-btn:hover { transform: translateY(-3px); }
.consult-menu { width: min(288px, calc(100vw - 40px)); transform-origin: 100% 100%; animation: consult-in .18s ease-out; padding: 6px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md); box-shadow: 0 10px 28px color-mix(in srgb, var(--fg) 10%, transparent); }
@keyframes consult-in { from { opacity: 0; transform: translateY(6px) scale(.97); } }
.contact-row { display: flex; align-items: center; gap: 12px; min-height: 60px; padding: 8px 10px; border-radius: var(--r-sm); text-decoration: none; }
.contact-row:hover { background: var(--accent-tint); }
.contact-row .tile, .contact-row > img { width: 40px; height: 40px; flex: none; }
.tile.navy { background: var(--navy-tint); color: var(--navy); }
.contact-row b { display: block; font-size: 14px; font-weight: 700; color: var(--navy); line-height: 1.4; }
.contact-row small { display: block; font-size: 12px; color: var(--muted); line-height: 1.4; }

/* ============================================================
   Responsive — max-width 1024 / 768 / 480
   ============================================================ */
/* The form column gets narrow beside the summary (769–1024px) long before the viewport does: reflow on its own width. */
@container (max-width: 520px) {
  .cols-2.stack { grid-template-columns: 1fr; }
  .row-2, .row-2.lead-short { grid-template-columns: 1fr; }
}
@container (max-width: 400px) {
  .cols-4 { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 1024px) {
  :root { --page-px: 32px; }
  .flow { grid-template-columns: minmax(0, 1fr) 320px; gap: 24px; }
  .ticket { padding: 20px 22px; }
  .ticket .total dd { font-size: 22px; }   /* 320px column: keep the total on one line */
  .cut { margin: 14px -22px; }
}

/* Mobile: wizard — one step per screen, progress on top, action bar at the bottom */
@media (max-width: 768px) {
  .time-row { flex-direction: column; align-items: flex-start; }
  .tsel, .asap { width: 100%; max-width: 360px; }   /* the shortcut is as wide as the picker it sets */
  .tsel .select { flex: 1; width: auto; }
  main { padding: calc(var(--nav-h) + 16px) 0 120px; }

  .progress { display: block; margin-bottom: 16px; }
  .progress-top { display: flex; align-items: center; gap: 8px; min-height: 44px; }
  .progress-back { width: 44px; height: 44px; margin-left: -10px; display: grid; place-items: center; background: none; border: 0; border-radius: 50%; color: var(--navy); cursor: pointer; }
  .progress-back[hidden] + .progress-label { margin-left: 0; }
  .progress-label { font-size: 13px; font-weight: 700; color: var(--muted); letter-spacing: .04em; text-transform: uppercase; }
  .dots { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
  .dots i { height: 4px; border-radius: var(--r-pill); background: var(--disabled); }
  .dots i.on { background: var(--accent); }

  .flow { grid-template-columns: 1fr; gap: 16px; }
  .step:not(.is-active) { display: none; }
  .step { border: 0; background: none; box-shadow: none; border-radius: 0; }
  .step-head, .step.is-active .step-head { padding: 0 0 12px; }
  .step-no { display: none; }
  .step-body { padding: 0; }
  .step-foot { margin-top: 16px; }
  .step-foot .btn { display: none; }
  .step-foot .hint.is-blocked { display: none; }   /* the bottom bar and the field already say it */
  .field-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); padding: 20px 16px; }

  .summary { display: contents; }
  .steps { order: 1; }
  .summary .ticket { order: 0; }
  .summary .elder { order: 2; padding: 0; }
  body:not([data-step="4"]) .summary .ticket { display: none; }
  body[data-step="4"] .steps { margin-top: 16px; }   /* heading sits closer to its form than to the ticket above */
  .srow-edit { display: inline-grid; }

  .mbar { display: flex; position: fixed; inset: auto 0 0 0; z-index: 100; align-items: center; gap: 12px; padding: 12px 20px calc(12px + env(safe-area-inset-bottom)); background: var(--surface); border-top: 1px solid var(--border); }
  body:not([data-view="flow"]) .mbar { display: none; }
  .mbar div { flex: 1; min-width: 0; font-size: 12px; color: var(--muted); line-height: 1.4; }
  .mbar b { display: block; font-size: 20px; font-weight: 800; color: var(--accent); white-space: nowrap; }
  .mbar b.empty { font-size: 14px; font-weight: 600; color: var(--navy); }
  .mbar #m-sum, .mbar-why { display: block; }
  .mbar-why { font-size: 13px; font-weight: 700; line-height: 1.35; color: var(--danger); text-wrap: balance; }
  .mbar .btn { padding: 0 20px; }
  /* the button floats above the bottom bar (flow) and the sticky form actions (patient form); 74px = 12 + 50 + 12 */
  .consult { right: 16px; bottom: calc(86px + env(safe-area-inset-bottom)); }
  body[data-view="task"] .consult { bottom: 20px; }
  .consult-btn { width: 56px; }
  .conds { grid-template-columns: 1fr; }
  .app { grid-template-columns: 1fr; }
  .only-m { display: inline-flex; }
  .input, .textarea { font-size: 16px; }   /* under 16px iOS Safari zooms the page when the field takes focus */
  /* Patient form is several screens long: its two actions stay at the bottom of the screen, side by side */
  .panel .actions { position: sticky; bottom: 0; z-index: 2; flex-wrap: nowrap; margin: 20px -28px -28px; padding: 12px 28px calc(12px + env(safe-area-inset-bottom)); background: var(--surface); border-top: 1px solid var(--border); border-radius: 0 0 var(--r-lg) var(--r-lg); }
  .panel .actions .btn { min-width: 0; padding: 0 8px; font-size: 14px; }
  .qr { display: none; }

  /* auth = full screen */
  dialog#dlg-auth { width: 100vw; max-width: 100vw; height: 100dvh; max-height: 100dvh; margin: 0; border: 0; border-radius: 0; }
  dialog#dlg-auth .dlg { padding-top: 64px; }
}
@media (max-width: 480px) {
  :root { --page-px: 20px; }
  .cols-4 { grid-template-columns: repeat(2, 1fr); }
  .cols-2.stack { grid-template-columns: 1fr; }
  .row-2, .row-2.lead-short { grid-template-columns: 1fr; }
  .panel { padding: 20px 16px; }
  .panel .cut { margin: 14px -16px; }
  .ok { padding: 20px 16px; }
  .ticket { padding: 20px 16px; }
  .cut { margin: 14px -16px; }
  .dlg { padding: 28px 20px 20px; }
  .panel .actions { margin: 20px -16px -20px; padding-left: 16px; padding-right: 16px; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { transition: none !important; animation: none !important; }
}
