/* DentaPlan components (VORAAA-7). Needs tokens.css first.
 * Ported from the mockup look (mockup/web/app.css + patient.css), extended for the
 * production screens. Specs: docs/design/README.md, tooth-chart.md, screens.md.
 * Sections: base · layout · buttons · cards · chips & tags · forms · stepper ·
 * action bar · sheet · toast · lists · tooth chart · finding picker · alternatives ·
 * costs · signature · patient page · before/after · utilities · media
 */

/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; font-family: var(--font); font-size: var(--fs-md); line-height: var(--lh);
  color: var(--ink); background: var(--bg); -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent-text); text-decoration: none; }
a:hover { text-decoration: underline; }
a.btn:hover, a.card:hover, a.row:hover, a.brand:hover, a.step:hover { text-decoration: none; }
h1, h2, h3 { margin: 0; letter-spacing: var(--tracking-tight); line-height: var(--lh-tight); }
h1 { font-size: var(--fs-2xl); font-weight: var(--fw-bold); }
h2 { font-size: 18px; font-weight: 650; }
h3 { font-size: var(--fs-md); font-weight: 650; }
:focus-visible { outline: 0; box-shadow: var(--focus); border-radius: var(--r-sm); }
.muted { color: var(--ink-2); }
.small { font-size: var(--fs-sm); }
.tiny { font-size: var(--fs-xs); color: var(--ink-3); }
.num { font-variant-numeric: tabular-nums; }
.caps { font-size: var(--fs-xs); font-weight: var(--fw-bold); letter-spacing: var(--tracking-caps); text-transform: uppercase; color: var(--ink-3); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- layout ---------- */
.topbar {
  position: sticky; top: 0; z-index: var(--z-sticky); display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3);
  padding: var(--sp-3) var(--gutter); padding-top: calc(var(--sp-3) + env(safe-area-inset-top));
  background: var(--glass); backdrop-filter: saturate(180%) blur(14px); -webkit-backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--ink); }
.brand b { display: block; font-size: 16px; letter-spacing: -.01em; }
.brand small { display: block; font-size: var(--fs-xs); color: var(--ink-3); line-height: var(--lh-tight); }
.logo { width: 36px; height: 36px; border-radius: 11px; display: grid; place-items: center; color: #fff; background: var(--accent-grad); box-shadow: 0 4px 12px rgba(15, 159, 143, .35); }
.logo svg { width: 22px; height: 22px; }
.avatar { flex: none; width: var(--touch); height: var(--touch); border-radius: 50%; display: grid; place-items: center; font-size: var(--fs-sm); font-weight: var(--fw-bold); background: var(--accent-50); color: var(--accent-text); }
main, .main { max-width: var(--content-max); margin: 0 auto; padding: var(--sp-6) var(--gutter) 120px; }
.reading { max-width: var(--reading-max); margin-inline: auto; }
.view { animation: rise var(--t-slow) var(--ease); }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--sp-4); margin-bottom: var(--sp-5); flex-wrap: wrap; }
.page-head p { margin: 6px 0 0; }
.section-title { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: var(--sp-1); flex-wrap: wrap; }
.grid-2 { display: grid; grid-template-columns: 1.15fr 1fr; gap: var(--sp-4); align-items: start; }
.stack-v { display: grid; gap: var(--sp-4); }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--sp-2); min-height: var(--btn-h);
  border: 1px solid transparent; cursor: pointer; padding: 0 var(--btn-px); border-radius: var(--r-md); font-weight: var(--fw-semi); font-size: var(--fs-md); line-height: 1.2;
  transition: transform var(--t-fast), box-shadow var(--t), background var(--t); -webkit-tap-highlight-color: transparent; white-space: nowrap; text-decoration: none;
}
.btn:active { transform: scale(.97); }
.btn svg { width: var(--btn-icon); height: var(--btn-icon); flex: none; }
/* variants: primary (one per area) · secondary = .btn-ghost · quiet (Abbrechen, low-weight) · danger (outline) · danger-fill (destructive confirm) */
.btn-primary { background: var(--primary-fill); color: var(--on-accent); box-shadow: var(--shadow-accent); }
.btn-primary:hover { background: var(--primary-fill-hover); }
.btn-ghost { background: var(--card); border-color: var(--line); color: var(--ink); }
.btn-ghost:hover { border-color: var(--accent-100); background: var(--accent-50); }
.btn-quiet { background: transparent; color: var(--accent-text); padding-inline: var(--btn-px-sm); }
.btn-quiet:hover { background: var(--accent-50); }
.btn-danger { background: var(--card); border-color: var(--red-50); color: var(--red); }
.btn-danger:hover { background: var(--red-50); }
/* destructive confirm (ConfirmDialog): filled */
.btn-danger-fill { background: var(--danger-fill); color: var(--on-danger); }
.btn-danger-fill:hover { filter: brightness(1.08); }
/* quiet destructive link (Entfernen): neutral at rest, red on hover/focus */
.btn-quiet.danger { color: var(--ink-2); }
.btn-quiet.danger:hover, .btn-quiet.danger:focus-visible { color: var(--red); background: var(--red-50); }
.btn-ghost.danger { color: var(--ink); }
.btn-ghost.danger:hover, .btn-ghost.danger:focus-visible { color: var(--red); border-color: var(--red-50); background: var(--red-50); }
/* compact size: same radius, weight and gap; only height, padding, text and icon shrink */
.btn-sm { min-height: var(--btn-h-sm); padding: 0 var(--btn-px-sm); font-size: var(--fs-sm); }
.btn-sm svg { width: var(--btn-icon-sm); height: var(--btn-icon-sm); }
.btn-block { width: 100%; }
/* icon-only: square, as wide as it is high */
.btn-icon { width: var(--btn-h); padding: 0; }
.btn-sm.btn-icon { width: var(--btn-h-sm); }
.btn[disabled], .btn[aria-disabled="true"] { opacity: .45; pointer-events: none; }
.btn.busy { pointer-events: none; }
.btn.busy::after { content: ""; width: 14px; height: 14px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; animation: spin .7s linear infinite; }
/* action groups: page header (.page-actions), cards and bars (.btn-row). Secondary left, primary right. */
.page-actions, .btn-row { display: flex; gap: var(--sp-2); align-items: center; justify-content: flex-end; flex-wrap: wrap; }
.btn-row.start { justify-content: flex-start; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- cards ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: var(--sp-5); }
.card + .card { margin-top: var(--sp-4); }
.grid-2 > .card, .kpis > .card, .cost-grid > .card { margin-top: 0; }
.card-head { display: flex; align-items: baseline; justify-content: space-between; gap: var(--sp-3); margin-bottom: var(--sp-3); flex-wrap: wrap; }
.inset { background: var(--sunk); border: 1px solid var(--line); border-radius: var(--r-lg); padding: var(--sp-3) var(--sp-4); }
.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: var(--sp-5); }
.kpi { padding: var(--sp-4) 18px; }
.kpi .label { font-size: var(--fs-xs); color: var(--ink-3); text-transform: uppercase; letter-spacing: var(--tracking-caps); font-weight: var(--fw-semi); }
.kpi .value { font-size: var(--fs-num); font-weight: var(--fw-bold); letter-spacing: var(--tracking-tight); margin-top: var(--sp-1); font-variant-numeric: tabular-nums; }
.kpi .sub { font-size: var(--fs-xs); color: var(--ink-2); }
.empty { padding: 28px var(--sp-4); text-align: center; color: var(--ink-3); border: 1.5px dashed var(--line); border-radius: var(--r-lg); font-size: 14px; }

/* ---------- alerts ---------- */
.alert { display: flex; gap: 10px; align-items: flex-start; padding: var(--sp-3) 14px; border-radius: var(--r-lg); font-size: 14px; background: var(--blue-50); color: var(--info-ink); }
.alert svg { width: 18px; height: 18px; flex: none; margin-top: 2px; }
.alert.warn { background: var(--amber-50); color: var(--warn-ink); }
.alert.error { background: var(--red-50); color: var(--error-ink); }
.alert.ok { background: var(--green-50); color: var(--ok-ink); }

/* ---------- chips & tags ---------- */
.chip { display: inline-flex; align-items: center; gap: 6px; padding: var(--sp-1) 10px; border-radius: var(--r-pill); font-size: 12.5px; font-weight: var(--fw-semi); white-space: nowrap; background: var(--neutral-50); color: var(--chip-ink); }
.chip::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
/* HKP status (draft → sent to patient → chosen → signed → submitted → approved/rejected → done, or expired) */
.chip.entwurf { background: var(--neutral-50); color: var(--chip-ink); }
.chip.versendet { background: var(--accent-50); color: var(--accent-700); }
.chip.gewaehlt { background: var(--green-50); color: var(--green); }
.chip.unterschrieben { background: var(--green-50); color: var(--green); }
.chip.eingereicht { background: var(--blue-50); color: var(--blue); }
.chip.genehmigt { background: var(--green-50); color: var(--green); }
.chip.abgelehnt { background: var(--red-50); color: var(--red); }
.chip.abgelaufen { background: var(--amber-50); color: var(--amber); }
.chip.abgeschlossen { background: var(--neutral-50); color: var(--ink-2); }
.tag { display: inline-block; padding: 2px 8px; border-radius: var(--r-xs); font-size: 11.5px; font-weight: var(--fw-bold); background: var(--neutral-50); color: var(--ink-2); letter-spacing: .02em; }
.tag.gkv { background: var(--accent-50); color: var(--accent-700); }
.tag.pkv, .tag.goz { background: var(--violet-50); color: var(--violet); }
.tag.bema { background: var(--accent-50); color: var(--accent-700); }
.tag.bel { background: var(--amber-50); color: var(--amber); }
.tag.opt-r { background: var(--opt-r-50); color: var(--opt-r); }
.tag.opt-g { background: var(--opt-g-50); color: var(--opt-g); }
.tag.opt-a { background: var(--opt-a-50); color: var(--opt-a); }

/* ---------- forms ---------- */
.field { display: grid; gap: 6px; margin-top: 14px; }
.field label, .field .label { font-size: var(--fs-sm); font-weight: var(--fw-semi); color: var(--ink-2); }
.field .hint { font-size: var(--fs-xs); color: var(--ink-3); }
.field .err { font-size: var(--fs-xs); color: var(--red); font-weight: var(--fw-semi); }
.input, .field input:not([type="checkbox"]):not([type="radio"]), .field select, .field textarea {
  min-height: var(--touch); padding: 10px 13px; border-radius: var(--r-md); border: 1px solid var(--field-border); background: var(--field-bg); outline: 0;
  transition: border-color var(--t-fast), box-shadow var(--t-fast); width: 100%;
}
.field textarea { min-height: 96px; resize: vertical; }
.field input:focus, .field textarea:focus, .input:focus { border-color: var(--accent); box-shadow: var(--ring); }
.field.invalid input, .field.invalid .dp-ctl { border-color: var(--red); }
.field-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 0 var(--sp-3); }
.check-row { display: flex; gap: var(--sp-3); align-items: flex-start; padding: var(--sp-2) 0; cursor: pointer; }
/* checkboxes: custom 22px box, works in both themes (accent-color alone is not enough) */
input[type="checkbox"] { -webkit-appearance: none; appearance: none; width: 22px; height: 22px; margin: 1px 0 0; flex: none; border: 1.5px solid var(--field-border); border-radius: 7px; background: var(--field-bg); display: inline-grid; place-content: center; cursor: pointer; transition: background var(--t-fast), border-color var(--t-fast); }
input[type="checkbox"]::before { content: ""; width: 12px; height: 7px; border: solid var(--on-accent); border-width: 0 0 2.5px 2.5px; transform: rotate(-45deg) translate(1px, -1px) scale(0); transition: transform var(--t-fast) var(--ease); }
input[type="checkbox"]:checked { background: var(--primary-fill); border-color: var(--primary-fill); }
input[type="checkbox"]:checked::before { transform: rotate(-45deg) translate(1px, -1px) scale(1); }
input[type="checkbox"]:disabled { opacity: .5; cursor: default; }
.check-row { min-height: var(--touch); }
.search { flex: 1; min-width: 200px; display: flex; align-items: center; gap: var(--sp-2); padding: 0 14px; min-height: var(--touch); background: var(--card); border: 1px solid var(--field-border); border-radius: var(--r-md); }
.search:focus-within { border-color: var(--accent); box-shadow: var(--ring); }
.search input { border: 0; outline: 0; flex: 1; background: transparent; }
.search svg { width: 18px; height: 18px; color: var(--ink-3); }
.seg { display: inline-flex; background: var(--seg-bg); padding: var(--sp-1); border-radius: var(--r-md); gap: var(--sp-1); flex-wrap: wrap; }
.seg button { border: 0; background: transparent; min-height: 36px; padding: 6px 14px; border-radius: var(--r-sm); cursor: pointer; font-weight: var(--fw-semi); font-size: 14px; color: var(--ink-2); transition: all var(--t); }
.seg button[aria-pressed="true"], .seg button[aria-checked="true"], .seg button.on { background: var(--seg-on); color: var(--ink); box-shadow: 0 1px 3px rgba(15, 42, 51, .12); }
.pills { display: flex; gap: 6px; flex-wrap: wrap; }
.pill { border: 1px solid var(--line-2); background: var(--card); color: var(--ink); border-radius: var(--r-pill); min-height: 36px; padding: 6px 12px; font-size: var(--fs-sm); cursor: pointer; transition: all var(--t-fast); }
.pill[aria-pressed="true"], .pill.on { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.bonusbar { display: flex; gap: 6px; margin-top: 6px; }
.bonusbar i { flex: 1; height: 6px; border-radius: 4px; background: var(--line); }
.bonusbar i.on { background: var(--accent); }

/* ---------- stepper (planning flow) ---------- */
.stepper { display: flex; gap: 6px; margin: 0 0 22px; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
.stepper::-webkit-scrollbar { display: none; }
.step { flex: 1; min-width: 0; min-height: var(--touch); display: flex; align-items: center; gap: var(--sp-2); padding: 10px var(--sp-3); border-radius: var(--r-md); font-size: var(--fs-sm); color: var(--ink-3); background: var(--card); border: 1px solid var(--line); cursor: pointer; white-space: nowrap; transition: all var(--t); }
.step .n { width: 22px; height: 22px; flex: none; border-radius: 50%; display: grid; place-items: center; font-size: var(--fs-xs); font-weight: var(--fw-bold); background: var(--neutral-50); color: var(--ink-2); }
.step.done { color: var(--ink-2); }
.step.done .n { background: var(--accent-100); color: var(--accent-text); }
.step[aria-current="step"], .step.active { color: var(--ink); border-color: var(--accent); box-shadow: var(--ring); font-weight: var(--fw-semi); }
.step[aria-current="step"] .n, .step.active .n { background: var(--primary-fill); color: var(--on-accent); }
.step.locked { cursor: default; opacity: .7; }
.step.warn .n { background: var(--amber-50); color: var(--amber); }

/* ---------- action bar (sticky bottom: running total + next step) ---------- */
.actionbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: var(--z-actionbar); padding: var(--sp-3) var(--gutter) calc(var(--sp-3) + env(safe-area-inset-bottom)); background: var(--glass); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); border-top: 1px solid var(--line); }
.actionbar .inner { max-width: 1040px; margin: 0 auto; display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); }
.actionbar .info { font-size: var(--fs-sm); color: var(--ink-2); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.actionbar .info b { color: var(--ink); font-size: 16px; font-variant-numeric: tabular-nums; }
.actionbar .actions { display: flex; gap: var(--sp-2); flex: none; }

/* ---------- sheet (bottom sheet on phones, dialog from 600px) ---------- */
.backdrop { position: fixed; inset: 0; background: var(--backdrop); z-index: var(--z-backdrop); animation: fade var(--t); }
@keyframes fade { from { opacity: 0; } }
.sheet {
  --sheet-pb: calc(var(--sp-5) + env(safe-area-inset-bottom));
  position: fixed; z-index: var(--z-sheet); left: 0; right: 0; bottom: 0; max-height: 88vh; overflow-y: auto; overscroll-behavior: contain;
  background: var(--raised); border-radius: var(--r-xl) var(--r-xl) 0 0; padding: var(--sp-3) var(--sp-5) var(--sheet-pb);
  box-shadow: var(--shadow-lg); animation: sheetUp .28s var(--ease);
}
.sheet::before { content: ""; display: block; width: 40px; height: 4px; border-radius: 2px; background: var(--line-2); margin: 0 auto var(--sp-3); }
@keyframes sheetUp { from { transform: translateY(24px); opacity: 0; } }
.sheet-head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--sp-3); }
/* sheet/dialog footer: [Abbrechen (quiet)] [secondary] [primary], right-aligned, all default height */
.sheet-foot { display: flex; gap: var(--sp-2); justify-content: flex-end; align-items: center; flex-wrap: wrap; margin-top: var(--sp-4); }
.sheet-foot .btn { min-height: var(--btn-h); padding-inline: var(--btn-px); font-size: var(--fs-md); }
.sheet-foot .btn-quiet { padding-inline: var(--btn-px-sm); }
/* three footer buttons don't fit the 560 px dialog: such sheets get the wide width (like .sheet.wide) */
@media (min-width: 600px) { .sheet:has(.sheet-foot > .btn:nth-child(3)) { width: min(720px, calc(100vw - 32px)); } }

/* ---------- overlay stack (ui.js open / confirmDialog) ---------- */
.ov .backdrop { z-index: var(--z-backdrop); }
.ov .sheet { z-index: var(--z-sheet); }
.ov.closing .backdrop { animation: fadeOut var(--t-fast) forwards; }
.ov.closing .sheet { animation: sheetOut var(--t-fast) forwards; }
@keyframes fadeOut { to { opacity: 0; } }
@keyframes sheetOut { to { opacity: 0; transform: translateY(12px); } }
.sheet:focus { outline: 0; }
.sheet-head .btn-icon { margin: -6px -10px 0 0; }
.dlg-confirm { max-width: 460px; }
.dlg-head { display: flex; gap: var(--sp-4); align-items: flex-start; }
.dlg-head h2 { margin-top: 6px; }
.dlg-body { margin-top: var(--sp-2); color: var(--ink-2); }
.dlg-body p { margin: 0 0 var(--sp-2); }
.dlg-icon { width: 44px; height: 44px; flex: none; border-radius: 50%; display: grid; place-items: center; background: var(--accent-50); color: var(--accent-text); }
.dlg-icon.danger { background: var(--red-50); color: var(--red); }
.dlg-icon svg { width: 22px; height: 22px; }

/* ---------- on-screen keyboard (VORAAA-29) ----------
   ui.js mirrors window.visualViewport into --vvh (visible height), --vvt (its offset in the layout
   viewport) and --kb (layout-viewport space hidden under the keyboard) and sets body.kb-open.
   Sheets sit on top of the keyboard and never get taller than the visible area; their footer
   (main button) sticks to the bottom; fixed bars step aside while a field is being typed in. */
.sheet { bottom: var(--kb, 0px); max-height: min(88dvh, calc(var(--vvh, 100dvh) - 12px)); }
/* bottom = -padding: the sticky box may extend into the sheet's bottom padding, so it never covers content when nothing scrolls */
.sheet .sheet-foot:last-child { position: sticky; bottom: calc(-1 * var(--sheet-pb)); z-index: 2; background: var(--raised); padding-top: var(--sp-3); margin-bottom: calc(-1 * var(--sheet-pb)); padding-bottom: var(--sheet-pb); }
body.kb-open .actionbar { display: none; }
body.kb-open .topbar { position: static; }
/* while typing, plain confirmations step aside so they never cover the field; errors and undo stay */
body.kb-open .toast-item:not(.tone-error):not(.has-act) { display: none; }
body.kb-open .toasts { bottom: auto; top: calc(var(--vvt, 0px) + var(--sp-3) + env(safe-area-inset-top)); }
body.kb-open .sheet { --sheet-pb: var(--sp-3); max-height: calc(var(--vvh, 100dvh) - 8px); }

/* ---------- toasts (stack, newest on top) ---------- */
.toasts { position: fixed; z-index: var(--z-toast); left: 50%; transform: translateX(-50%); bottom: calc(92px + env(safe-area-inset-bottom)); width: min(440px, calc(100vw - 24px)); display: flex; flex-direction: column; align-items: center; gap: var(--sp-2); pointer-events: none; }
/* While a sheet or dialog is open, toasts move to the top so they never cover its buttons (N2). */
body.ov-open .toasts { bottom: auto; top: calc(var(--sp-3) + env(safe-area-inset-top)); }
body.ov-open .toast-item { animation-name: toastDown; }
@keyframes toastDown { from { opacity: 0; transform: translateY(-12px); } }
.toasts > div { display: flex; flex-direction: column; align-items: center; gap: var(--sp-2); max-width: 100%; }
.toast-item { pointer-events: auto; display: flex; align-items: center; gap: var(--sp-2); max-width: 100%; padding: 4px 4px 4px 14px; border-radius: var(--r-pill); background: var(--toast-bg); color: var(--toast-ink); font-size: var(--fs-sm); font-weight: var(--fw-medium); line-height: 1.3; box-shadow: 0 6px 18px rgba(0, 0, 0, .22); animation: toastIn var(--t) var(--ease); }
.toast-item.compact { padding: 8px 16px 8px 12px; cursor: pointer; }
.toast-item.out { animation: fadeOut .15s forwards; }
.toast-item .ti-icon { display: grid; flex: none; }
.toast-item .ti-icon svg { width: 16px; height: 16px; }
.toast-item.tone-success .ti-icon { color: var(--toast-ok); }
.toast-item.tone-error { border-radius: var(--r-lg); background: var(--danger-fill); color: var(--on-danger); }
.toast-item .ti-msg { flex: 1 1 auto; min-width: 0; padding: 4px 0; }
.toast-item button { border: 0; background: transparent; color: inherit; cursor: pointer; min-height: 36px; border-radius: var(--r-pill); font-weight: var(--fw-bold); }
.toast-item .ti-act { padding: 0 var(--sp-3); text-decoration: underline; text-underline-offset: 3px; }
.toast-item .ti-x { flex: none; width: 36px; min-height: 36px; display: grid; place-items: center; opacity: .8; }
.toast-item .ti-x svg { width: 16px; height: 16px; }
.toast-item button:focus-visible { box-shadow: 0 0 0 2px currentColor; }
@keyframes toastIn { from { opacity: 0; transform: translateY(12px); } }
/* legacy single toast (kept for pages without ui.js) */
.toast { position: fixed; left: 50%; bottom: 96px; transform: translate(-50%, 20px); opacity: 0; pointer-events: none; z-index: var(--z-toast); background: var(--toast-bg); color: var(--toast-ink); padding: var(--sp-3) 18px; border-radius: var(--r-lg); font-size: 14px; transition: all .3s; max-width: calc(100vw - 32px); }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- custom form controls (ui.js: dp-select, dp-seg, dp-combo, dp-date, dp-stepper) ---------- */
dp-select, dp-combo, dp-date, dp-stepper { display: block; min-width: 0; }
dp-select > option, dp-combo > option, dp-seg > option { display: none; }
dp-seg.seg { display: inline-flex; }
.dp-ctl { display: flex; align-items: center; gap: var(--sp-2); width: 100%; min-height: var(--touch); border-radius: var(--r-md); border: 1px solid var(--field-border); background: var(--field-bg); color: var(--ink); transition: border-color var(--t-fast), box-shadow var(--t-fast); }
.dp-ctl:focus-within, .dp-trigger:focus-visible { border-color: var(--accent); box-shadow: var(--ring); }
.field .dp-ctl input, .dp-ctl input { border: 0 !important; background: transparent !important; box-shadow: none !important; outline: 0; min-height: 0 !important; padding: 0 !important; flex: 1; min-width: 0; width: auto; align-self: stretch; font: inherit; color: inherit; }
.dp-trigger { padding: 10px 12px 10px 13px; text-align: left; cursor: pointer; font: inherit; justify-content: space-between; }
.dp-trigger .dp-val { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dp-trigger .dp-val.ph { color: var(--ink-3); }
.dp-trigger[aria-expanded="true"] .dp-chev { transform: rotate(180deg); }
.dp-chev { width: 18px; height: 18px; flex: none; color: var(--ink-3); transition: transform var(--t-fast); }
.dp-trigger:disabled, .dp-ctl:has(input:disabled) { background: var(--sunk); color: var(--ink-2); cursor: default; border-style: dashed; }
.dp-combo-field { padding: 0 4px 0 12px; }
.dp-combo-field > svg { width: 18px; height: 18px; color: var(--ink-3); flex: none; }
.dp-clear, .dp-cal-btn { border: 0; background: transparent; color: var(--ink-3); cursor: pointer; width: 40px; height: 40px; flex: none; display: grid; place-items: center; border-radius: var(--r-sm); }
.dp-clear:hover, .dp-cal-btn:hover { background: var(--accent-50); color: var(--accent-text); }
.dp-clear svg { width: 16px; height: 16px; }
.dp-cal-btn svg { width: 20px; height: 20px; }
.dp-date-field { padding: 0 2px 0 13px; }
.dp-err { display: block; margin-top: 6px; }
.dp-stepper-field { padding: 0; width: auto; display: inline-flex; gap: 0; }
.dp-stepper-field input { text-align: center; width: 3.2em !important; flex: none !important; font-variant-numeric: tabular-nums; }
.dp-step { width: var(--touch); height: 42px; flex: none; border: 0; background: transparent; color: var(--accent-text); cursor: pointer; display: grid; place-items: center; border-radius: var(--r-md); touch-action: manipulation; }
.dp-step:hover { background: var(--accent-50); }
.dp-step:disabled { color: var(--ink-4); cursor: default; background: transparent; }
.dp-step svg { width: 18px; height: 18px; }
dp-stepper.sm .dp-stepper-field { min-height: 36px; }
dp-stepper.sm .dp-step { width: 34px; height: 34px; position: relative; }
dp-stepper.sm .dp-step::after { content: ""; position: absolute; inset: -5px 0; } /* 44px hit area */
dp-stepper.sm input { width: 2.4em !important; font-size: var(--fs-sm); }
/* popover layer (portal under <body>) */
.dp-pop-layer { position: fixed; inset: 0; z-index: var(--z-pop); pointer-events: none; }
.dp-scrim { display: none; }
.dp-pop { pointer-events: auto; position: fixed; overflow-y: auto; overscroll-behavior: contain; background: var(--raised); color: var(--ink); border: 1px solid var(--line-2); border-radius: var(--r-lg); box-shadow: var(--shadow-lg); padding: var(--sp-1); animation: popIn var(--t-fast) var(--ease); outline: 0; }
.dp-pop-layer.up .dp-pop { animation-name: popInUp; }
@keyframes popIn { from { opacity: 0; transform: translateY(-4px); } }
@keyframes popInUp { from { opacity: 0; transform: translateY(4px); } }
.dp-lb { outline: 0; }
.dp-sheet-head { display: none; }
.dp-opt { display: flex; align-items: center; gap: var(--sp-3); min-height: 44px; padding: 8px 10px; border-radius: var(--r-md); cursor: pointer; font-size: 14.5px; }
.dp-opt.active { background: var(--accent-50); }
.dp-opt[aria-selected="true"] { font-weight: var(--fw-semi); }
.dp-opt[aria-disabled="true"] { color: var(--ink-4); cursor: default; }
.dp-tick { width: 18px; flex: none; color: var(--accent-text); visibility: hidden; display: grid; }
.dp-tick svg { width: 16px; height: 16px; }
.dp-opt[aria-selected="true"] .dp-tick { visibility: visible; }
.dp-code { flex: none; min-width: 44px; text-align: center; font-size: var(--fs-xs); font-weight: var(--fw-bold); font-family: var(--font-mono); padding: 3px 6px; border-radius: var(--r-xs); background: var(--neutral-50); color: var(--ink-2); }
.dp-lbl { min-width: 0; }
.dp-lbl small { display: block; color: var(--ink-3); font-size: 12.5px; font-weight: var(--fw-regular); }
.dp-opt mark { background: var(--amber-50); color: inherit; border-radius: 3px; padding: 0 1px; font-weight: var(--fw-bold); }
.dp-group-h { padding: 10px 10px 4px; font-size: 11.5px; font-weight: var(--fw-bold); letter-spacing: var(--tracking-caps); text-transform: uppercase; color: var(--ink-3); }
.dp-empty, .dp-more { padding: 12px 10px; color: var(--ink-3); font-size: var(--fs-sm); display: flex; gap: var(--sp-2); align-items: center; }
.dp-create { color: var(--accent-text); font-weight: var(--fw-semi); border-top: 1px solid var(--line); border-radius: 0 0 var(--r-md) var(--r-md); }
.dp-create svg { width: 18px; height: 18px; flex: none; }
.dp-spin { width: 14px; height: 14px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; animation: spin .7s linear infinite; }
/* calendar */
.dp-cal { padding: var(--sp-3); width: 320px; max-width: calc(100vw - 16px); }
.dp-cal-head { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-2); margin-bottom: var(--sp-2); }
.dp-cal-title { border: 0; background: transparent; font: inherit; font-weight: var(--fw-bold); color: var(--ink); min-height: var(--touch); padding: 0 var(--sp-3); border-radius: var(--r-md); cursor: pointer; }
button.dp-cal-title:hover { background: var(--accent-50); }
.dp-grid { width: 100%; border-collapse: collapse; table-layout: fixed; }
.dp-grid th { font-size: var(--fs-xs); color: var(--ink-3); font-weight: var(--fw-semi); padding-bottom: 4px; }
.dp-grid td { padding: 1px; text-align: center; }
.dp-day, .dp-year { width: 100%; aspect-ratio: 1; min-height: 40px; border: 0; background: transparent; color: var(--ink); border-radius: var(--r-md); cursor: pointer; font: inherit; font-variant-numeric: tabular-nums; }
.dp-day:hover, .dp-year:hover { background: var(--accent-50); }
.dp-day.today { box-shadow: inset 0 0 0 1.5px var(--accent); }
.dp-day.on, .dp-year.on { background: var(--primary-fill); color: var(--on-accent); font-weight: var(--fw-bold); }
.dp-day[aria-disabled="true"], .dp-year:disabled { color: var(--ink-4); cursor: default; background: transparent; text-decoration: line-through; }
.dp-years { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; }
.dp-year { aspect-ratio: auto; min-height: var(--touch); }
.dp-cal-foot { display: flex; justify-content: space-between; margin-top: var(--sp-2); }

/* ---------- status timeline (step 4) ---------- */
.timeline { list-style: none; display: flex; gap: 0; padding: 0; margin: var(--sp-3) 0 var(--sp-2); overflow-x: auto; scrollbar-width: none; }
.timeline li { flex: 1; min-width: 86px; display: grid; justify-items: center; gap: 6px; text-align: center; font-size: var(--fs-xs); color: var(--ink-3); position: relative; }
.timeline li::before { content: ""; position: absolute; top: 11px; left: -50%; right: 50%; height: 2px; background: var(--line-2); }
.timeline li:first-child::before { display: none; }
.timeline .dot-t { width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; background: var(--card); border: 2px solid var(--line-2); position: relative; z-index: 1; }
.timeline .dot-t svg { width: 13px; height: 13px; }
.timeline li.done { color: var(--ink-2); }
.timeline li.done::before, .timeline li.cur::before { background: var(--accent); }
.timeline li.done .dot-t { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.timeline li.cur { color: var(--ink); font-weight: var(--fw-bold); }
.timeline li.cur .dot-t { border-color: var(--accent); box-shadow: var(--ring); }
.timeline li.bad .dot-t { border-color: var(--red); background: var(--red-50); }
.timeline li.bad { color: var(--red); }
.lifecycle-n { display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; background: var(--neutral-50); color: var(--ink-2); font-size: var(--fs-xs); font-weight: var(--fw-bold); margin-right: var(--sp-2); vertical-align: 2px; }

/* ---------- grouped hints (one panel instead of stacked alerts) ---------- */
.hints { display: block; }
.hints > b { display: block; margin-bottom: 4px; }
.hints ul { margin: 0; padding-left: 18px; display: grid; gap: 4px; }
.alert.hints.warn { border: 1px solid color-mix(in srgb, var(--amber) 25%, transparent); }

/* ---------- incomplete amounts (VORAAA-20 F3) ---------- */
.chip.incomplete { background: var(--amber-50); color: var(--amber); }
.amt-from { font-weight: var(--fw-regular); color: var(--ink-2); font-size: .7em; margin-right: .25em; letter-spacing: 0; }

/* ---------- theme toggle ---------- */
.theme-toggle { margin-top: var(--sp-3); }
.theme-toggle button { display: inline-flex; align-items: center; gap: 6px; }

/* ---------- lists (HKP list, patient list) ---------- */
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.list { display: grid; gap: 10px; }
.row { display: grid; grid-template-columns: 44px 1.6fr 1.2fr 1fr auto 20px; align-items: center; gap: 14px; padding: 14px 18px; background: var(--card); border: 1px solid var(--line); border-radius: 16px; cursor: pointer; transition: border-color var(--t-fast), box-shadow var(--t), transform var(--t-fast); color: inherit; text-decoration: none; }
.row:hover { border-color: var(--accent-100); box-shadow: var(--shadow); transform: translateY(-1px); text-decoration: none; }
.row .initials, .initials { width: 44px; height: 44px; border-radius: var(--r-lg); display: grid; place-items: center; font-weight: var(--fw-bold); font-size: 14px; background: var(--accent-50); color: var(--accent-text); }
.row .name b { display: block; }
.row .amount { text-align: right; font-weight: 650; font-variant-numeric: tabular-nums; }
.row .chev { color: var(--ink-3); }

/* ---------- tooth chart (see toothchart.js) ---------- */
.chart-wrap { overflow-x: auto; margin: 6px -8px 0; padding: var(--sp-1) var(--sp-2); -webkit-overflow-scrolling: touch; }
.chart { min-width: calc(16 * var(--touch-tooth) + 40px); position: relative; }
.jaw-row { display: grid; grid-template-columns: 1fr 10px 1fr; }
.jaw.upper .jaw-row { align-items: end; }
.jaw.lower .jaw-row { align-items: start; }
.quad { display: grid; grid-template-columns: repeat(8, 1fr); gap: 3px; }
.midline { width: 2px; justify-self: center; align-self: stretch; background: var(--line); border-radius: 2px; position: relative; }
.jaw-sep { height: 1px; margin: 6px 0; background: linear-gradient(90deg, transparent, var(--line) 10%, var(--line) 90%, transparent); }
.jaw-note { text-align: center; font-size: var(--fs-xs); font-weight: var(--fw-semi); color: var(--coral); margin: 2px 0; }
.tooth { position: relative; border: 0; background: transparent; padding: var(--sp-1) 0; display: grid; justify-items: stretch; gap: 2px; border-radius: var(--r-md); transition: background var(--t-fast); -webkit-tap-highlight-color: transparent; min-width: 0; }
button.tooth { cursor: pointer; }
button.tooth:hover { background: var(--accent-50); }
.tooth.sel { background: var(--accent-50); box-shadow: inset 0 0 0 1.5px var(--accent); }
.tooth .codes .code:not([class*="st-"]):not([class*="fam-"]):not(.r-r):not(.r-tp) { color: var(--ink-2); }
.tooth svg { justify-self: center; width: 100%; max-width: 46px; height: 58px; overflow: visible; }
.tooth .no { justify-self: center; font-size: 11.5px; font-weight: var(--fw-semi); color: var(--ink-3); font-variant-numeric: tabular-nums; }
.tooth .codes { display: grid; gap: 2px; justify-items: center; }
.tooth .code { min-width: 0; max-width: 100%; height: 20px; font-size: 11px; font-weight: var(--fw-bold); padding: 1px 5px; border-radius: var(--r-xs); line-height: 18px; overflow: hidden; text-overflow: clip; white-space: nowrap; }
.tooth .code:empty { visibility: hidden; }
.tooth .code.r-r, .tooth .code.r-tp { font-weight: var(--fw-semi); background: var(--sunk); color: var(--ink-2); }
/* tooth body */
.tooth .body { fill: var(--tooth-enamel); stroke: var(--tooth-stroke); stroke-width: 1.4; transition: fill var(--t), stroke var(--t); }
.tooth .root { fill: var(--tooth-root); stroke: var(--tooth-root-stroke); stroke-width: 1.2; }
.tooth .metal { fill: var(--tooth-metal-fill); stroke: var(--tooth-metal); stroke-width: 1.2; }
.tooth .thread { stroke: var(--tooth-metal); stroke-width: 1.6; stroke-linecap: round; }
.tooth .metal-dot { fill: var(--tooth-metal); }
.tooth .cap { fill: none; stroke: currentColor; stroke-width: 2; }
.tooth .cap.inner { stroke-width: 1.4; }
.tooth .wing { fill: var(--tooth-metal-fill); stroke: var(--tooth-metal); stroke-width: 1; }
.tooth .saddle { fill: var(--tooth-gum-50); stroke: var(--tooth-gum); stroke-width: 1.2; }
.tooth .mark { fill: none; stroke: currentColor; stroke-width: 3.2; stroke-linecap: round; stroke-linejoin: round; }
.tooth .mark.thin { stroke-width: 2; }
.tooth .ghost .body { fill: transparent; stroke: var(--st-missing); stroke-dasharray: 4 3; }
.tooth .ghost .root { opacity: .25; }
.tooth .closed { fill: none; stroke: var(--st-missing); stroke-width: 2.4; stroke-linecap: round; }
/* status colours: the SVG uses currentColor for caps and marks */
/* the drawing keeps its light palette in both themes (--tc-*): teeth are a light object on the card */
.tooth { color: var(--tc-ink); }
.tooth.st-intact { color: var(--tc-intact); }
.tooth.st-intact .body { fill: var(--tc-intact-50); stroke: var(--tooth-intact-stroke); }
.tooth.st-renew { color: var(--tc-renew); }
.tooth.st-renew .body { fill: var(--tooth-renew-fill); stroke: var(--tc-renew); }
.tooth.st-renew .cap { stroke-dasharray: 3 2.5; }
.tooth.st-remove { color: var(--tc-remove); }
.tooth.st-remove .body { fill: var(--tooth-remove-fill); stroke: var(--tc-remove); }
.tooth.st-defect { color: var(--tc-defect); }
.tooth.st-defect .body { fill: var(--tc-defect-50); stroke: var(--tooth-defect-stroke); }
.tooth.st-info { color: var(--tc-info); }
.tooth.g-natural.st-info .body { fill: var(--tooth-enamel); stroke: var(--tooth-stroke); }
.code.st-intact { background: var(--st-intact-50); color: var(--st-intact); }
.code.st-renew { background: var(--st-renew-50); color: var(--st-renew); }
.code.st-remove { background: var(--st-remove-50); color: var(--st-remove); }
.code.st-defect { background: var(--st-defect-50); color: var(--st-defect); }
.code.st-info { background: var(--st-info-50); color: var(--st-info); }
.code.st-missing { background: var(--st-missing-50); color: var(--ink-2); }
.code.fam-crown { background: var(--accent-50); color: var(--accent-text); }
.code.fam-bridge { background: var(--blue-50); color: var(--blue); }
.code.fam-denture { background: var(--coral-50); color: var(--coral); }
.code.fam-implant { background: var(--neutral-50); color: var(--ink-2); }
/* connectors: .link sits between tooth and number; bridge = dark bar, saddle = pink band.
 * Halves reach into the 3px grid gap so neighbouring halves meet. */
.tooth .link { position: relative; height: 6px; }
.tooth.bridge-l .link::before, .tooth.bridge-r .link::after,
.tooth.saddle-l .link::before, .tooth.saddle-r .link::after { content: ""; position: absolute; top: 1px; height: 4px; background: var(--tooth-link); }
.tooth.saddle-l .link::before, .tooth.saddle-r .link::after { background: var(--tooth-gum); top: 0; height: 6px; }
.tooth.bridge-l .link::before, .tooth.saddle-l .link::before { left: -2px; right: 50%; }
.tooth.bridge-r .link::after, .tooth.saddle-r .link::after { left: 50%; right: -2px; }
.tooth.bridge-l.bridge-r .link::before { right: 0; }
.tooth.saddle-l.saddle-r .link::before { right: 0; }
.tooth.bridge-l .link::before, .tooth.saddle-l .link::before { border-radius: 0; }
.tooth.bridge-r:not(.bridge-l) .link::after, .tooth.saddle-r:not(.saddle-l) .link::after { border-radius: 3px 0 0 3px; }
.tooth.bridge-l:not(.bridge-r) .link::before, .tooth.saddle-l:not(.saddle-r) .link::before { border-radius: 0 3px 3px 0; }
.tooth .link { z-index: 1; }
/* across the midline column (10px): the halves of 11/21 and 41/31 reach into it */
.tooth.mid-r.bridge-r .link::after, .tooth.mid-r.saddle-r .link::after { right: -6px; }
.tooth.mid-l.bridge-l .link::before, .tooth.mid-l.saddle-l .link::before { left: -6px; }
/* multi-row chart (B, R, TP like the HKP form): row labels at the left edge */
.chart[data-rows] { padding-left: 28px; }
.chart[data-rows]::before { content: "TP\A R\A B"; white-space: pre; position: absolute; left: 0; top: 4px; font-size: 10px; line-height: 22px; font-weight: var(--fw-bold); color: var(--ink-3); }
.chart[data-rows]::after { content: "B\A R\A TP"; white-space: pre; position: absolute; left: 0; bottom: 2px; font-size: 10px; line-height: 22px; font-weight: var(--fw-bold); color: var(--ink-3); }
/* mini chart (patient page, PDF, list preview) */
.chart-mini { min-width: 0; }
.chart-mini .tooth { padding: 0; }
.chart-mini .tooth svg { height: 36px; }
.chart-mini .tooth .code { height: 16px; font-size: 9.5px; line-height: 14px; padding: 1px 3px; }
.chart-mini .tooth .no { font-size: 9px; }
.chart-mini .tooth .link { height: 4px; }
.tooth.pop svg { animation: pop var(--t-slow) var(--ease-spring); }
@keyframes pop { 0% { transform: scale(.85); } 100% { transform: scale(1); } }
.legend { display: flex; flex-wrap: wrap; gap: var(--sp-2) var(--sp-4); margin-top: var(--sp-4); font-size: var(--fs-sm); color: var(--ink-2); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.chart-tools { display: flex; gap: var(--sp-2); align-items: center; justify-content: space-between; flex-wrap: wrap; margin-bottom: var(--sp-2); }

/* ---------- finding picker (in a .sheet) ---------- */
.picker-teeth { display: flex; gap: 6px; flex-wrap: wrap; margin-top: var(--sp-1); }
.picker-group { margin-top: var(--sp-4); }
.picker-group > summary { list-style: none; cursor: pointer; display: flex; justify-content: space-between; align-items: center; min-height: 36px; }
.picker-group > summary::-webkit-details-marker { display: none; }
.picker-group > summary::after { content: "›"; transform: rotate(90deg); color: var(--ink-3); transition: transform var(--t); }
.picker-group:not([open]) > summary::after { transform: none; }
.opts { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 220px), 1fr)); gap: var(--sp-2); margin-top: var(--sp-2); }
.opt { display: flex; align-items: center; gap: var(--sp-3); min-height: 52px; padding: 10px var(--sp-3); border-radius: var(--r-lg); border: 1.5px solid var(--line); background: var(--card); color: var(--ink); cursor: pointer; text-align: left; transition: all var(--t-fast); }
.opt:hover { border-color: var(--accent-100); background: var(--sunk); }
.opt[aria-pressed="true"], .opt.on { border-color: var(--accent); background: var(--accent-50); }
.opt .code { min-width: 38px; text-align: center; font-size: var(--fs-xs); font-weight: var(--fw-bold); padding: 3px 6px; border-radius: 7px; flex: none; }
.opt small { display: block; color: var(--ink-3); font-size: 12.5px; }
.findings { display: grid; gap: var(--sp-2); margin-top: var(--sp-3); }
.finding { display: flex; align-items: center; gap: var(--sp-3); padding: 10px var(--sp-3); border-radius: var(--r-md); background: var(--sunk); border: 1px solid var(--line); }
.finding .tno { font-weight: var(--fw-bold); min-width: 30px; font-variant-numeric: tabular-nums; }
.finding .x { margin-left: auto; border: 0; background: transparent; cursor: pointer; color: var(--ink-3); font-size: 18px; line-height: 1; min-width: 36px; min-height: 36px; border-radius: var(--r-sm); }
.finding .x:hover { background: var(--red-50); color: var(--red); }

/* ---------- alternatives (R / G / A) ---------- */
.alts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.alt { position: relative; display: flex; flex-direction: column; text-align: left; cursor: pointer; padding: var(--sp-5); border-radius: var(--radius); background: var(--card); border: 1.5px solid var(--line); transition: all var(--t); box-shadow: var(--shadow); }
.alt:hover { transform: translateY(-2px); }
.alt[aria-pressed="true"], .alt.on { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-50), var(--shadow); }
.alt .kind { font-size: var(--fs-xs); font-weight: var(--fw-bold); letter-spacing: var(--tracking-caps); text-transform: uppercase; color: var(--ink-3); }
.alt.r .kind { color: var(--opt-r); } .alt.g .kind { color: var(--opt-g); } .alt.a .kind { color: var(--opt-a); }
.alt h3 { margin: 6px 0 var(--sp-1); font-size: 18px; }
.alt ul { list-style: none; padding: 0; margin: var(--sp-3) 0 14px; display: grid; gap: var(--sp-2); font-size: 13.5px; }
.alt li { display: flex; gap: var(--sp-2); }
.alt li .t { font-weight: var(--fw-bold); min-width: 30px; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.alt .price { margin-top: auto; padding-top: 14px; border-top: 1px dashed var(--line); }
.alt .price b { font-size: 24px; letter-spacing: var(--tracking-tight); font-variant-numeric: tabular-nums; }
.alt .badge { position: absolute; top: 14px; right: 14px; font-size: 11px; font-weight: var(--fw-bold); padding: 3px var(--sp-2); border-radius: var(--r-pill); background: var(--primary-fill); color: var(--on-accent); }
.alt .add { margin-top: var(--sp-3); }
.pros { display: flex; flex-wrap: wrap; gap: 6px; }
.pros span { font-size: var(--fs-xs); padding: 3px 0; color: var(--ink-2); }
.pros span + span::before { content: "·"; margin-right: 6px; color: var(--ink-4); }
/* comparison table (tablet landscape / desktop): rows = criteria, columns = options */
.compare { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 14px; }
.compare th, .compare td { padding: 10px var(--sp-3); border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.compare thead th { position: sticky; top: 64px; background: var(--card); z-index: 1; font-size: var(--fs-sm); }
.compare tbody th { color: var(--ink-3); font-weight: var(--fw-semi); font-size: var(--fs-sm); width: 22%; }
.compare td.r { text-align: right; font-variant-numeric: tabular-nums; }
.compare .best { background: var(--accent-50); }
.compare tr.total td { font-weight: var(--fw-bold); font-size: 16px; border-bottom: 0; }

/* ---------- costs ---------- */
.cost-grid { display: grid; grid-template-columns: 1.35fr 1fr; gap: var(--sp-4); align-items: start; }
.breakdown { width: 100%; border-collapse: collapse; }
.breakdown td { padding: var(--sp-3) 0; border-bottom: 1px solid var(--line); }
.breakdown td:last-child { text-align: right; font-variant-numeric: tabular-nums; font-weight: var(--fw-semi); white-space: nowrap; }
.breakdown tr.minus td:last-child { color: var(--green); }
.breakdown tr.total td { border-bottom: 0; padding-top: var(--sp-4); font-size: 18px; font-weight: var(--fw-bold); }
.breakdown tr.total td:last-child { color: var(--accent-text); font-size: var(--fs-num); }
.breakdown .lbl small { display: block; color: var(--ink-3); font-size: var(--fs-xs); font-weight: var(--fw-regular); }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: var(--sp-2); }
.bar { display: flex; height: 14px; border-radius: var(--sp-2); overflow: hidden; background: var(--seg-bg); margin: 14px 0 var(--sp-1); }
.bar.bar-pending { background: repeating-linear-gradient(-45deg, var(--seg-bg) 0 8px, transparent 8px 16px); outline: 1px dashed var(--line-2); outline-offset: -1px; }
.bar i { display: block; height: 100%; transition: width .5s var(--ease); }
.big { font-size: var(--fs-hero); font-weight: 750; letter-spacing: -.03em; line-height: 1.1; font-variant-numeric: tabular-nums; }
.ribbon { display: inline-block; font-size: 11px; font-weight: var(--fw-bold); letter-spacing: var(--tracking-caps); text-transform: uppercase; padding: 3px var(--sp-2); border-radius: var(--r-xs); background: var(--amber-50); color: var(--amber); }
.lines { width: 100%; border-collapse: collapse; font-size: 13.5px; margin-top: var(--sp-2); }
.lines th { text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-3); font-weight: var(--fw-semi); padding: var(--sp-2) 6px var(--sp-2) 0; border-bottom: 1px solid var(--line); }
.lines td { padding: 9px 6px 9px 0; border-bottom: 1px solid var(--row-line); vertical-align: top; }
.lines td.r, .lines th.r { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.lines .sys { font-size: 11px; font-weight: var(--fw-bold); padding: 1px 6px; border-radius: 5px; background: var(--neutral-50); color: var(--ink-2); }
.lines .sys.goz { background: var(--violet-50); color: var(--violet); }
.lines .sys.bel { background: var(--amber-50); color: var(--amber); }
.lines-scroll { overflow-x: auto; }

/* ---------- signature ---------- */
.sign-doc { max-height: 46vh; overflow-y: auto; padding: var(--sp-4); border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--sunk); font-size: 14px; }
.sign-pad { position: relative; margin-top: var(--sp-3); height: 200px; border-radius: var(--r-lg); background: var(--paper); border: 1.5px dashed var(--field-border); touch-action: none; overflow: hidden; }
.sign-pad canvas { position: absolute; inset: 0; width: 100%; height: 100%; cursor: crosshair; }
.sign-pad .baseline { position: absolute; left: 24px; right: 24px; bottom: 48px; border-bottom: 1.5px solid var(--ink-3); pointer-events: none; }
.sign-pad .baseline::before { content: "×"; position: absolute; left: -16px; bottom: -4px; font-size: 18px; color: var(--ink-3); }
.sign-pad .hint { position: absolute; left: 0; right: 0; bottom: 18px; text-align: center; font-size: var(--fs-xs); color: var(--ink-3); pointer-events: none; }
.sign-pad.signed { border-style: solid; border-color: var(--accent); }
.sign-pad.signed .hint { visibility: hidden; }
.sign-meta { display: flex; justify-content: space-between; gap: var(--sp-3); flex-wrap: wrap; margin-top: var(--sp-2); font-size: var(--fs-xs); color: var(--ink-3); }
.sign-steps { display: flex; gap: var(--sp-2); flex-wrap: wrap; margin-bottom: var(--sp-3); }
.sign-steps .chip.todo { background: var(--card); border: 1px solid var(--line); color: var(--ink-3); }
.handover { text-align: center; padding: var(--sp-10) var(--sp-5); }
.handover .ring, .success .ring { width: 84px; height: 84px; border-radius: 50%; margin: 0 auto 18px; display: grid; place-items: center; background: var(--accent-50); color: var(--accent-text); }
.handover .ring svg, .success .ring svg { width: 40px; height: 40px; }
.success { text-align: center; padding: var(--sp-12) var(--sp-5); }

/* ---------- patient page (public decision link) ---------- */
body.pt { background: linear-gradient(180deg, var(--accent-50) 0, var(--bg) 260px); }
.pt-top { display: flex; gap: var(--sp-3); align-items: center; padding: 14px 18px; max-width: var(--reading-max); margin: 0 auto; }
.pt-top .logo { width: 38px; height: 38px; border-radius: var(--r-md); }
.pt-top b { display: block; font-size: var(--fs-md); }
.pt-top small { color: var(--ink-2); font-size: 12.5px; }
.pt-main { max-width: var(--reading-max); margin: 0 auto; padding: 14px 14px var(--sp-12); }
.hello-card { padding: 10px 6px var(--sp-4); }
.hello-card h1 { font-size: 27px; margin: 6px 0; }
.hello-card p { margin: 0; color: var(--ink-2); }
.pt-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; margin-top: 14px; }
.pt-card h3 { margin: 0; font-size: var(--fs-lg); }
.find-list { list-style: none; padding: 0; margin: 0; display: grid; gap: var(--sp-2); }
.find-list li { background: var(--sunk); border-radius: var(--r-md); padding: 9px var(--sp-3); font-size: 14px; }
.opt-head { display: flex; justify-content: space-between; align-items: baseline; margin: var(--sp-6) var(--sp-1) 10px; }
.opt-scroll { display: grid; gap: var(--sp-4); }
.opt-card { position: relative; background: var(--card); border: 1px solid var(--line); border-radius: var(--r-xl); box-shadow: var(--shadow); padding: 18px; display: flex; flex-direction: column; min-width: 0; }
.opt-card.rec { border: 2px solid var(--accent); box-shadow: 0 0 0 5px var(--accent-50), var(--shadow); }
.opt-card.chosen { border: 2px solid var(--green); box-shadow: 0 0 0 5px var(--green-50), var(--shadow); }
.opt-card .kind { font-size: var(--fs-xs); font-weight: var(--fw-bold); letter-spacing: var(--tracking-caps); text-transform: uppercase; color: var(--accent-text); }
.opt-card h2 { font-size: 18px; margin: var(--sp-1) 0 var(--sp-3); line-height: 1.3; }
.rec-badge { align-self: flex-start; font-size: 11.5px; font-weight: var(--fw-bold); padding: var(--sp-1) 10px; border-radius: var(--r-pill); background: var(--primary-fill); color: var(--on-accent); margin-bottom: 10px; }
.facts { display: grid; grid-template-columns: auto 1fr; gap: 6px var(--sp-3); margin: 14px 0 0; font-size: 13.5px; }
.facts dt { color: var(--ink-3); font-weight: var(--fw-semi); }
.facts dd { margin: 0; }
.pc { list-style: none; padding: 0; margin: 14px 0 0; display: grid; gap: 7px; font-size: 14px; }
.pc li { display: flex; gap: var(--sp-2); align-items: flex-start; }
.pc svg { width: 18px; height: 18px; flex: none; padding: 3px; border-radius: 50%; margin-top: 1px; }
.pc .pro svg { background: var(--green-50); color: var(--green); }
.pc .con svg { background: var(--neutral-50); color: var(--ink-2); }
.money { display: grid; grid-template-columns: 1fr 1fr 1.2fr; gap: 6px; margin-top: var(--sp-4); padding-top: 14px; border-top: 1px dashed var(--line); }
.money small { display: block; font-size: 11.5px; color: var(--ink-3); }
.money b { font-size: var(--fs-md); font-variant-numeric: tabular-nums; }
.money .me b { font-size: 21px; color: var(--accent-text); letter-spacing: var(--tracking-tight); }
.opt-card .choose { margin-top: 14px; width: 100%; white-space: normal; text-align: center; }
.opt-card .choose[disabled] { opacity: 1; color: var(--green); border-color: var(--green); }
.chosen-note { margin-top: 14px; display: flex; gap: var(--sp-2); align-items: flex-start; background: var(--green-50); color: var(--ok-ink); border-radius: var(--r-lg); padding: var(--sp-3) 14px; font-size: 14px; }
.link-expired { text-align: center; padding: var(--sp-12) var(--sp-5); }

/* ---------- before/after slider ---------- */
.ba { position: relative; border-radius: 16px; overflow: hidden; aspect-ratio: 16 / 9; background: var(--ill-bg); touch-action: pan-y; }
.ba img, .ba svg { display: block; width: 100%; height: 100%; object-fit: cover; }
.ba-after, .ba-before { position: absolute; inset: 0; }
.ba-before { clip-path: inset(0 calc(100% - var(--pos, 50%)) 0 0); }
.ba-handle { position: absolute; top: 0; bottom: 0; left: var(--pos, 50%); width: 3px; margin-left: -1.5px; background: #fff; box-shadow: 0 0 6px rgba(0, 0, 0, .25); pointer-events: none; }
.ba-handle span { position: absolute; top: 50%; left: 50%; width: 30px; height: 30px; margin: -15px 0 0 -15px; border-radius: 50%; background: #fff; box-shadow: 0 2px 8px rgba(0, 0, 0, .25); }
.ba-handle span::before { content: "‹ ›"; position: absolute; inset: 0; display: grid; place-items: center; font-weight: var(--fw-bold); color: var(--accent-600); font-size: 14px; }
.ba-tag { position: absolute; bottom: var(--sp-2); font-size: 11px; font-weight: var(--fw-bold); padding: 2px var(--sp-2); border-radius: var(--r-pill); background: rgba(15, 42, 51, .7); color: #fff; pointer-events: none; }
.ba-tag.l { left: var(--sp-2); } .ba-tag.r { right: var(--sp-2); }
.ba-chip { position: absolute; top: var(--sp-2); transform: translateX(-50%); font-size: 11px; font-weight: var(--fw-semi); padding: 2px var(--sp-2); border-radius: var(--r-pill); background: rgba(232, 247, 244, .92); color: var(--accent-600); white-space: nowrap; pointer-events: none; }
.ba-chip.warn { background: rgba(253, 236, 236, .92); color: #b23a3a; }
.ba-tag, .ba-chip { transition: opacity var(--t-fast); }
.ba-tag.off, .ba-chip.off { opacity: 0; }
.ba input[type="range"] { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; margin: 0; cursor: ew-resize; }
.ba.single .ba-handle, .ba.single .ba-tag { display: none; } /* explainer images (endo, augmentation) have no slider */

/* ---------- media ---------- */
@media (min-width: 600px) {
  .sheet { --sheet-pb: var(--sp-5); left: 50%; right: auto; bottom: auto; top: calc(var(--vvt, 0px) + var(--vvh, 100dvh) / 2); transform: translate(-50%, -50%); width: min(560px, calc(100vw - 32px)); max-height: min(88dvh, calc(var(--vvh, 100dvh) - 24px)); border-radius: var(--r-xl); padding: var(--sp-5) var(--sp-6) var(--sheet-pb); animation: sheetIn .28s cubic-bezier(.2, .9, .3, 1.1); }
  body.kb-open .sheet { max-height: calc(var(--vvh, 100dvh) - 16px); }
  .sheet::before { display: none; }
  @keyframes sheetIn { from { opacity: 0; transform: translate(-50%, -46%) scale(.97); } }
  .chart { min-width: 0; }
}
@media (min-width: 900px) {
  .pt-main { max-width: 1180px; }
  .opt-scroll { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
}
@media (max-width: 1023px) {
  .kpis { grid-template-columns: repeat(2, 1fr); }
  .grid-2, .cost-grid { grid-template-columns: 1fr; }
  .alts { grid-template-columns: 1fr; }
  .row { grid-template-columns: 44px 1fr auto; row-gap: 6px; }
  .row .kasse, .row .chev { display: none; }
  .row .amount { grid-column: 3; grid-row: 1; }
  .row .status { grid-column: 2 / 4; }
}
@media (min-width: 600px) and (max-width: 1023px) { .alts { grid-template-columns: repeat(3, minmax(0, 1fr)); } .alt { padding: var(--sp-4); } }
@media (max-width: 599px) {
  body { font-size: 14.5px; }
  /* select / calendar popovers become bottom sheets */
  .dp-pop-layer.as-sheet { pointer-events: auto; }
  .dp-pop-layer.as-sheet .dp-scrim { display: block; position: absolute; inset: 0; background: var(--backdrop); animation: fade var(--t); }
  .dp-pop-layer.as-sheet .dp-pop { left: 0; right: 0; bottom: var(--kb, 0px); top: auto; width: auto; max-height: min(70vh, calc(var(--vvh, 100dvh) - 24px)); border-radius: var(--r-xl) var(--r-xl) 0 0; padding: var(--sp-2) var(--sp-3) calc(var(--sp-4) + env(safe-area-inset-bottom)); animation: sheetUp .24s var(--ease); }
  .dp-pop-layer.as-sheet .dp-pop::before { content: ""; display: block; width: 40px; height: 4px; border-radius: 2px; background: var(--line-2); margin: 0 auto var(--sp-2); }
  .dp-pop-layer.as-sheet .dp-sheet-head { display: block; font-weight: var(--fw-bold); padding: 4px 10px 8px; }
  .dp-pop-layer.as-sheet .dp-opt { min-height: 52px; }
  .dp-pop-layer.as-sheet .dp-cal { width: auto; max-width: none; }
  .toasts { bottom: calc(84px + env(safe-area-inset-bottom)); }
  .sheet-foot { flex-direction: column-reverse; align-items: stretch; }
  .sheet-foot .btn { width: 100%; }
  /* keyboard open: the form keeps the space. "Abbrechen" steps aside (× and Esc still close),
     the remaining buttons sit side by side. */
  body.kb-open .sheet-foot { flex-direction: row; }
  body.kb-open .sheet-foot [data-close]:not(.btn-primary) { display: none; }
  body.kb-open .sheet-foot .btn { width: auto; flex: 1 1 0; min-width: 0; }
  .step .lbl { display: none; }
  .step[aria-current="step"] .lbl, .step.active .lbl { display: inline; }
  .step { flex: none; }
  .step[aria-current="step"], .step.active { flex: 1; }
  .kpi .value { font-size: 22px; }
  .card { padding: var(--sp-4); }
  .big { font-size: 34px; }
  .btn { --btn-px: 14px; padding-inline: var(--btn-px); }
  .btn-quiet, .btn-sm { padding-inline: var(--btn-px-sm); }
  /* page header actions: primary takes its own full-width row on top, the others share the row below */
  .page-head > .page-actions { width: 100%; }
  .page-actions .btn { flex: 1 1 0; min-width: 0; }
  .page-actions .btn-primary { flex-basis: 100%; order: -1; }
  .actionbar .info { white-space: normal; line-height: 1.25; font-size: var(--fs-xs); }
  .actionbar .info b { display: block; font-size: var(--fs-md); }
  .actionbar .info .chip { display: none; }
  .quad { gap: 1px; }
  .tooth svg { height: 44px; }
  .tooth .no { font-size: 10px; }
  .tooth .code { font-size: 9.5px; padding: 0 2px; height: 16px; line-height: 16px; }
  .sign-pad { height: 180px; }
  .money { grid-template-columns: 1fr 1fr; }
  .money .me { grid-column: 1 / -1; }
}
@media print {
  .topbar, .actionbar, .stepper, .toast, .toasts, .backdrop, .sheet, .ov, .dp-pop-layer, .no-print { display: none !important; }
  body { background: #fff; color: #111; }
  main, .main { padding: 0; }
  .card { box-shadow: none; border: 0; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
/* coarse pointers (tablets, phones): 44 px minimum targets also for compact controls (F9) */
@media (pointer: coarse) {
  .btn-sm { min-height: var(--touch); }
  .btn-sm.btn-icon { width: var(--touch); }
  .pill { min-height: var(--touch); }
  .seg button { min-height: 40px; }
  .finding .x { min-width: var(--touch); min-height: var(--touch); }
}

/* ---------- DentaPlan 2.0: Behandlungsfall (VORAAA-51, ported from web/design/v2/v2.css, D2) ---------- */
.crumb { font-size: var(--fs-sm); color: var(--ink-3); }
.crumb a { color: var(--accent-text); text-decoration: none; }
.mt-2 { margin-top: var(--sp-2); } .mt-3 { margin-top: var(--sp-3); } .mt-4 { margin-top: var(--sp-4); } 
.mt-6 { margin-top: var(--sp-6); }
.fall-head { display: grid; grid-template-columns: 1fr auto; gap: var(--sp-3) var(--sp-5); align-items: start; }
.fall-head h1 { margin: 4px 0 2px; font-size: var(--fs-2xl); letter-spacing: var(--tracking-tight); display: flex; gap: var(--sp-2); align-items: center; flex-wrap: wrap; }
.fall-head .meta { font-size: var(--fs-sm); color: var(--ink-2); display: flex; gap: var(--sp-2); flex-wrap: wrap; align-items: center; }
.chip.kind-rep { background: var(--amber-50); color: var(--amber); }
.chip.kind-new { background: var(--accent-50); color: var(--accent-text); }

/* ---- Phase bar (W1) ---- */
.phasebar { list-style: none; margin: var(--sp-5) 0; padding: 0; display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 4px; }
.phasebar li { position: relative; padding: 10px 12px 10px 14px; background: var(--card); border: 1px solid var(--line); border-radius: var(--r-md); min-width: 0; }
.phasebar li b { display: flex; align-items: center; gap: 6px; font-size: var(--fs-sm); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.phasebar li small { display: block; font-size: var(--fs-xs); color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; }
.phasebar .n { display: inline-grid; place-items: center; width: 20px; height: 20px; border-radius: 50%; font-size: 11px; background: var(--neutral-50); color: var(--ink-2); flex: none; }
.phasebar li.done { background: var(--sunk); }
.phasebar li.done .n { background: var(--green-50); color: var(--green); }
.phasebar li.cur { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-50); }
.phasebar li.cur .n { background: var(--primary-fill); color: var(--on-accent); }
.phasebar li.wait small { color: var(--warn-ink); font-weight: var(--fw-semi); }
.phasebar li.skip { border-style: dashed; background: transparent; }
.phasebar li.skip b, .phasebar li.later b { color: var(--ink-3); }
.phasebar li::after { content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 3px; border-radius: 0 0 var(--r-md) var(--r-md); }
.phasebar li.done::after { background: var(--green); }
.phasebar li.cur::after { background: var(--accent); }
.phase-mobile { display: none; }
.nextbar { display: flex; gap: var(--sp-3); align-items: center; flex-wrap: wrap; padding: var(--sp-4); border-radius: var(--radius); background: var(--accent-50); border: 1px solid var(--accent-100); }
.nextbar .what { flex: 1 1 260px; min-width: 0; }
.nextbar .what b { display: block; }
.nextbar .what span { font-size: var(--fs-sm); color: var(--ink-2); }
.override { display: flex; gap: var(--sp-2); flex-wrap: wrap; align-items: center; margin-top: var(--sp-3); font-size: var(--fs-sm); color: var(--ink-3); }
.estimate-note { display: flex; gap: var(--sp-2); align-items: flex-start; font-size: var(--fs-sm); color: var(--info-ink); background: var(--blue-50); border-radius: var(--r-md); padding: 10px 12px; }
.optgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 14px; }
.optc { position: relative; display: flex; flex-direction: column; padding: var(--sp-4); border-radius: var(--radius); background: var(--card); border: 1.5px solid var(--line); box-shadow: var(--shadow); min-width: 0; }
.optc.rec { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-50), var(--shadow); }
.optc.chosen { border-color: var(--green); box-shadow: 0 0 0 4px var(--green-50), var(--shadow); }
.optc.not { opacity: .72; }
.optc .top { display: flex; gap: var(--sp-2); align-items: center; }
.optc h3 { margin: var(--sp-2) 0 4px; font-size: var(--fs-lg); }
.optc ul { list-style: none; padding: 0; margin: var(--sp-2) 0; display: grid; gap: 4px; font-size: var(--fs-sm); color: var(--ink-2); }
.optc .thumb { aspect-ratio: 16 / 9; border-radius: var(--r-md); background: var(--ill-bg); overflow: hidden; margin-top: var(--sp-2); }
.optc .thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.optc .amt { margin-top: auto; padding-top: var(--sp-3); border-top: 1px dashed var(--line); display: flex; justify-content: space-between; align-items: baseline; gap: var(--sp-2); }
.optc .amt b { font-size: 22px; font-variant-numeric: tabular-nums; letter-spacing: var(--tracking-tight); }
.optc .amt small { font-size: var(--fs-xs); color: var(--ink-3); }
.optc .diff { font-size: var(--fs-xs); font-weight: var(--fw-semi); color: var(--ink-2); }
.optc .amt-r { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; }
.rec-pill { margin-left: auto; font-size: 11px; font-weight: var(--fw-bold); padding: 3px 8px; border-radius: var(--r-pill); background: var(--primary-fill); color: var(--on-accent); }
.chosen-pill { margin-left: auto; font-size: 11px; font-weight: var(--fw-bold); padding: 3px 8px; border-radius: var(--r-pill); background: var(--green-50); color: var(--green); }
.optc.add { align-items: center; justify-content: center; text-align: center; border-style: dashed; box-shadow: none; background: transparent; color: var(--ink-2); min-height: 180px; gap: var(--sp-2); }
.optc.add svg { width: 28px; height: 28px; flex: none; }
.ca { font-weight: var(--fw-semi); color: var(--ink-3); font-size: .7em; margin-right: 3px; }
.callback { display: grid; grid-template-columns: auto 1fr auto; gap: var(--sp-3); align-items: center; padding: var(--sp-4); border-radius: var(--radius); background: var(--amber-50); border: 1px solid var(--line-2); }
.callback .ic { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; background: var(--card); color: var(--amber); }
.callback b { display: block; color: var(--warn-ink); }
.callback span { font-size: var(--fs-sm); color: var(--ink-2); }
.callback q { font-style: normal; color: var(--ink); }

/* ---- Dashboard board (W1) ---- */
.board { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: var(--sp-3); align-items: start; }
.col { background: var(--sunk); border: 1px solid var(--line); border-radius: var(--radius); padding: var(--sp-3); min-width: 0; }
.col-h { display: flex; align-items: center; gap: var(--sp-2); margin: 2px 4px var(--sp-3); font-size: var(--fs-sm); font-weight: var(--fw-bold); }
.col-h .cnt { margin-left: auto; font-size: var(--fs-xs); padding: 2px 8px; border-radius: var(--r-pill); background: var(--card); color: var(--ink-2); border: 1px solid var(--line); }
.col.hot { background: var(--amber-50); }
.col.hot .col-h { color: var(--warn-ink); }
.col.wait .col-h { color: var(--accent-text); }
.fcard { display: block; background: var(--card); border: 1px solid var(--line); border-radius: var(--r-lg); padding: var(--sp-3); box-shadow: var(--shadow); color: var(--ink); text-decoration: none; }
.fcard + .fcard { margin-top: var(--sp-2); }
.fcard b { display: block; font-size: var(--fs-sm); }
.fcard .t { font-size: var(--fs-sm); color: var(--ink-2); margin-top: 2px; }
.fcard .m { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; font-size: var(--fs-xs); color: var(--ink-3); margin-top: var(--sp-2); }
.fcard .topic { margin-top: var(--sp-2); font-size: var(--fs-sm); padding: 6px 8px; border-radius: var(--r-sm); background: var(--sunk); }
.fcard .acts { display: flex; gap: 6px; margin-top: var(--sp-2); }
.board-tabs { display: none; }
.kind-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); flex: none; }
.kind-dot.rep { background: var(--amber); }
.q { margin-top: var(--sp-4); }
.q > .lbl { display: block; font-size: var(--fs-xs); font-weight: var(--fw-bold); color: var(--ink-3); text-transform: uppercase; letter-spacing: var(--tracking-caps); margin-bottom: 6px; }
.mchips { display: flex; gap: var(--sp-2); flex-wrap: wrap; }
.mchip { min-height: var(--touch); display: inline-flex; align-items: center; gap: 6px; padding: 0 14px; border-radius: var(--r-pill); border: 1.5px solid var(--line-2); background: var(--card); color: var(--ink); font: inherit; font-size: var(--fs-sm); font-weight: var(--fw-semi); cursor: pointer; }
.mchip[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-50); color: var(--accent-text); }
.mchip .def { font-size: 10px; font-weight: var(--fw-bold); color: var(--ink-3); text-transform: uppercase; }
.mchip:disabled { color: var(--ink-4); border-style: dashed; cursor: not-allowed; }
.pt-intro { margin: var(--sp-4) var(--sp-1) 0; }
.pt-intro h1 { font-size: 24px; margin: 0 0 6px; letter-spacing: var(--tracking-tight); }
.pt-intro p { margin: 0; color: var(--ink-2); }
.pt-help { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-3); margin-top: var(--sp-3); }
.pt-help button { min-height: 64px; display: flex; gap: var(--sp-3); align-items: center; text-align: left; padding: var(--sp-3) var(--sp-4); border-radius: var(--r-lg); border: 1.5px solid var(--line-2); background: var(--card); color: var(--ink); font: inherit; font-weight: var(--fw-semi); cursor: pointer; }
.pt-help button small { display: block; font-weight: var(--fw-regular); font-size: var(--fs-xs); color: var(--ink-3); }
.pt-help .ic { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; background: var(--accent-50); color: var(--accent-text); flex: none; }
.opt-card .est { font-size: var(--fs-xs); color: var(--ink-3); margin-top: 6px; }
.opt-card .rec-badge { position: absolute; top: -11px; left: 18px; }
.timechips { display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--sp-2); }
.timechips .mchip { justify-content: center; }
.counter { font-size: var(--fs-xs); color: var(--ink-3); text-align: right; }
.done-state { text-align: center; padding: var(--sp-6) var(--sp-4); }
.done-state .ic { width: 56px; height: 56px; border-radius: 50%; display: grid; place-items: center; margin: 0 auto var(--sp-3); background: var(--green-50); color: var(--green); }
.radio-cards { display: grid; gap: var(--sp-2); }
.rcard { display: grid; grid-template-columns: 22px 1fr auto; gap: var(--sp-3); align-items: center; padding: 12px 14px; border-radius: var(--r-lg); border: 1.5px solid var(--line-2); background: var(--card); font-size: var(--fs-sm); }
.rcard.on { border-color: var(--accent); background: var(--accent-50); }
.rcard .rd { width: 20px; height: 20px; border-radius: 50%; border: 2px solid var(--field-border); }
.rcard.on .rd { border: 6px solid var(--primary-fill); }
.rcard b { display: block; font-size: var(--fs-md); }
.audit { display: flex; gap: 6px; align-items: center; font-size: var(--fs-xs); color: var(--ink-3); margin-top: var(--sp-3); }
.secret-src { display: flex; gap: var(--sp-2); align-items: center; padding: 10px 12px; border-radius: var(--r-md); background: var(--sunk); font-size: var(--fs-sm); color: var(--ink-2); border: 1px dashed var(--line-2); }
.fall-acts { display: flex; gap: var(--sp-2); flex-wrap: wrap; align-items: center; justify-content: flex-end; }
.optc .acts { display: flex; gap: var(--sp-2); flex-wrap: wrap; margin-top: var(--sp-3); }
.optc .notpill { margin-left: auto; font-size: 11px; font-weight: var(--fw-semi); color: var(--ink-3); }
.rcard { width: 100%; text-align: left; font: inherit; color: var(--ink); cursor: pointer; }
.rcard[aria-checked="true"] { border-color: var(--accent); background: var(--accent-50); }
.rcard[aria-checked="true"] .rd { border: 6px solid var(--primary-fill); }
.rcard:focus-visible { outline: none; box-shadow: var(--ring); }
.mchip:focus-visible, .pt-help button:focus-visible { outline: none; box-shadow: var(--ring); }
.fcard .acts .btn { flex: 0 1 auto; }
.fcard.chosen-c { border-color: var(--green); }
.board .empty-col { font-size: var(--fs-xs); color: var(--ink-3); padding: var(--sp-2) 4px; }
.chair { max-width: 1100px; margin: 0 auto; }
.chair .opt-card .choose { margin-top: var(--sp-4); }
@media (max-width: 1023px) {
  .board { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 599px) {
  .fall-head { grid-template-columns: 1fr; }
  .fall-acts { justify-content: flex-start; }
  .phasebar { display: none; }
  .phase-mobile { display: grid; grid-template-columns: auto 1fr auto; gap: var(--sp-3); align-items: center; margin: var(--sp-4) 0; padding: var(--sp-3); border-radius: var(--r-lg); background: var(--card); border: 1px solid var(--line); }
  .phase-mobile .dots { grid-column: 1 / -1; display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 3px; }
  .phase-mobile .dots i { height: 5px; border-radius: 3px; background: var(--neutral-50); }
  .phase-mobile .dots i.done { background: var(--green); } .phase-mobile .dots i.cur { background: var(--accent); } .phase-mobile .dots i.skip { background: transparent; border: 1px dashed var(--line-2); }
  .phase-mobile .ring { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; font-weight: var(--fw-bold); background: var(--primary-fill); color: var(--on-accent); }
  .phase-mobile b { display: block; } .phase-mobile small { color: var(--ink-3); font-size: var(--fs-xs); }
  .optgrid { grid-template-columns: 1fr; }
  .board { display: block; }
  .board .col { display: none; background: transparent; border: 0; padding: 0; }
  .board .col.show { display: block; }
  .board .col-h { display: none; }
  .board-tabs { display: flex; gap: 6px; overflow-x: auto; margin-bottom: var(--sp-3); padding-bottom: 2px; }
  .board-tabs .pill { white-space: nowrap; }
  .callback { grid-template-columns: auto 1fr; } .callback .btn { grid-column: 1 / -1; }
  .pt-help { grid-template-columns: 1fr; }
}
.phasebar li > a { display: block; color: inherit; text-decoration: none; margin: -10px -12px -10px -14px; padding: 10px 12px 10px 14px; border-radius: var(--r-md); }
.phasebar li > a:hover b { color: var(--accent-text); }
.phasebar li > a:focus-visible { outline: none; box-shadow: var(--ring); }
.handover.chair { text-align: left; padding: var(--sp-6) 0; max-width: 1100px; margin: 0 auto; }
.handover.chair > h1 { margin: var(--sp-2) 0 6px; }
.handover.chair .optgrid { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.handover.chair .opt-card .thumb { aspect-ratio: 16 / 9; border-radius: var(--r-md); background: var(--ill-bg); overflow: hidden; margin-bottom: var(--sp-3); }
.handover.chair .opt-card .thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.handover.chair .opt-card .choose { margin-top: var(--sp-4); justify-content: center; }
.handover.chair .ring { margin-top: var(--sp-8); }
.handover.chair .pt-help { max-width: 520px; }
.fcard > a { color: inherit; text-decoration: none; display: block; }
.btn-block { width: 100%; justify-content: center; }
@media (max-width: 599px) { .handover.chair .optgrid { grid-template-columns: 1fr; } }
.amt-open { font-size: var(--fs-md); color: var(--amber); font-weight: var(--fw-semi); }
.estimate-note > svg, .callback .ic svg, .pt-help .ic svg, .col-h > svg, .fcard .m svg, .secret-src > svg, .audit > svg { width: 18px; height: 18px; flex: none; }

/* ---------- DentaPlan 2.0: ZE-Reparatur (VORAAA-54, ported from web/design/v2/v2.css, D2 § 7) ---------- */
.cfg-bar { position: sticky; bottom: 0; z-index: var(--z-actionbar); margin-top: var(--sp-5); display: flex; gap: var(--sp-3); align-items: center; flex-wrap: wrap; padding: var(--sp-3) var(--sp-4); border-radius: var(--radius); background: var(--glass); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); border: 1px solid var(--line-2); box-shadow: var(--shadow-lg); }
.cfg-bar .info { flex: 1 1 200px; min-width: 0; font-size: var(--fs-sm); color: var(--ink-2); }
.cfg-bar .info b { color: var(--ink); font-size: var(--fs-md); }
.src { font-size: var(--fs-xs); color: var(--accent-text); white-space: nowrap; text-decoration: none; font-weight: var(--fw-semi); }
/* "Quelle ›" as a button (2.1 Planen/Beraten, N2): a text link that opens the Herleitung sheet */
button.src-b { background: none; border: 0; padding: 4px 0; min-height: 24px; cursor: pointer; font: inherit; font-size: var(--fs-xs); font-weight: var(--fw-semi); color: var(--accent-text); text-decoration: underline; text-underline-offset: 2px; }
.existing { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: var(--sp-5); align-items: start; }
.ze-list { list-style: none; padding: 0; margin: 0; display: grid; gap: var(--sp-2); }
.ze-list li { display: grid; grid-template-columns: 36px 1fr auto; gap: var(--sp-3); align-items: center; padding: 10px 12px; border-radius: var(--r-md); background: var(--sunk); font-size: var(--fs-sm); border: 1.5px solid transparent; }
.ze-list li.on { border-color: var(--accent); background: var(--accent-50); }
.ze-list li .jaw-b { width: 36px; height: 36px; border-radius: var(--r-md); display: grid; place-items: center; font-size: 11px; font-weight: var(--fw-bold); background: var(--card); color: var(--ink-2); }
.ze-list li b { display: block; font-size: var(--fs-md); }
.dmg-groups { display: grid; gap: var(--sp-4); }
.dmg-groups h4 { margin: 0 0 var(--sp-2); font-size: var(--fs-xs); color: var(--ink-3); text-transform: uppercase; letter-spacing: var(--tracking-caps); }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: var(--sp-2); }
.tile { display: flex; flex-direction: column; gap: 8px; align-items: flex-start; text-align: left; min-height: 104px; padding: var(--sp-3); border-radius: var(--r-lg); background: var(--card); border: 1.5px solid var(--line); font: inherit; font-size: var(--fs-sm); font-weight: var(--fw-semi); color: var(--ink); cursor: pointer; }
.tile .ti { width: 34px; height: 34px; border-radius: var(--r-md); display: grid; place-items: center; background: var(--amber-50); color: var(--amber); }
.tile[aria-pressed="true"] { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-50); }
.tile[aria-pressed="true"] .ti { background: var(--primary-fill); color: var(--on-accent); }
.tile.na { opacity: .5; }
.tile small { font-weight: var(--fw-regular); color: var(--ink-3); font-size: var(--fs-xs); }
.derived { display: grid; gap: 6px; padding: var(--sp-4); border-radius: var(--r-lg); background: var(--sunk); border: 1px dashed var(--line-2); font-size: var(--fs-sm); }
.derived .k { display: grid; grid-template-columns: 150px 1fr auto; gap: var(--sp-2); align-items: baseline; }
.derived .k span:first-child { color: var(--ink-3); }
.fz { font-family: var(--font-mono); font-weight: var(--fw-bold); padding: 1px 6px; border-radius: var(--r-xs); background: var(--card); color: var(--accent-text); border: 1px solid var(--line); }
.noappr { display: inline-flex; gap: 6px; align-items: center; font-size: var(--fs-xs); font-weight: var(--fw-bold); padding: 3px 10px; border-radius: var(--r-pill); background: var(--green-50); color: var(--green); }
.path { list-style: none; padding: 0; margin: var(--sp-2) 0 0; display: flex; gap: 6px; flex-wrap: wrap; align-items: center; font-size: var(--fs-sm); }
.path li { padding: 4px 10px; border-radius: var(--r-pill); background: var(--neutral-50); color: var(--ink-2); }
.path li.cur { background: var(--accent-50); color: var(--accent-text); font-weight: var(--fw-semi); }
.path li.x { text-decoration: line-through; color: var(--ink-3); background: transparent; border: 1px dashed var(--line-2); }
.hint-inline { display: flex; gap: var(--sp-2); align-items: center; padding: 10px 12px; border-radius: var(--r-md); background: var(--blue-50); color: var(--info-ink); font-size: var(--fs-sm); }
.tile { position: relative; }
.tile:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.tile .why { font-weight: var(--fw-regular); color: var(--ink-3); font-size: var(--fs-xs); }
.ze-list li { padding: 0; background: none; border: 0; display: block; }
.ze-list .ze-b { display: grid; grid-template-columns: 36px 1fr auto; gap: var(--sp-3); align-items: center; width: 100%; min-height: 44px; padding: 10px 12px; border-radius: var(--r-md); background: var(--sunk); border: 1.5px solid transparent; font: inherit; font-size: var(--fs-sm); color: inherit; text-align: left; cursor: pointer; }
.ze-list .ze-b[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-50); }
.ze-list .ze-b .jaw-b { width: 36px; height: 36px; border-radius: var(--r-md); display: grid; place-items: center; font-size: 11px; font-weight: var(--fw-bold); background: var(--card); color: var(--ink-2); }
.ze-list .ze-b b { display: block; font-size: var(--fs-md); }
.dmg-card { border-left: 3px solid var(--amber); }
.dmg-card .q { display: flex; flex-wrap: wrap; gap: var(--sp-2) var(--sp-4); align-items: center; margin-top: var(--sp-3); }
.dmg-card .q .lbl { flex: 1 1 220px; font-size: var(--fs-sm); }
.dmg-card .issue { margin-top: var(--sp-2); }
.tchips { display: flex; flex-wrap: wrap; gap: 6px; }
.tchip { min-width: 44px; min-height: 44px; border-radius: var(--r-md); border: 1.5px solid var(--line); background: var(--card); font: inherit; font-weight: var(--fw-semi); color: var(--ink); cursor: pointer; }
.tchip[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-50); color: var(--accent-text); }
.needappr { display: inline-flex; gap: 6px; align-items: center; font-size: var(--fs-xs); font-weight: var(--fw-bold); padding: 3px 10px; border-radius: var(--r-pill); background: var(--amber-50); color: var(--warn-ink); }
.noappr svg, .needappr svg { width: 14px; height: 14px; flex: none; }
.noappr, .needappr { width: fit-content; max-width: 100%; }
.derived .k .src { background: none; border: 0; padding: 0; cursor: pointer; font: inherit; font-size: var(--fs-xs); color: var(--accent-text); font-weight: var(--fw-semi); }
.qe-mini { display: flex; gap: var(--sp-2); margin-top: var(--sp-3); }
.qe-mini input { flex: 1; min-width: 0; font-family: var(--font-mono); }
.rep-lines td.num { text-align: right; white-space: nowrap; }
@media (max-width: 1023px) { .existing { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 599px) {
  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .derived .k { grid-template-columns: 1fr auto; } .derived .k span:first-child { grid-column: 1 / -1; }
  .cfg-bar { position: fixed; left: 0; right: 0; bottom: 0; border-radius: var(--r-xl) var(--r-xl) 0 0; margin: 0; padding-bottom: calc(var(--sp-3) + env(safe-area-inset-bottom)); }
  .cfg-bar .btn-primary { flex: 1 1 100%; }
  .rep-page { padding-bottom: 140px; }
}
.tchip { padding: 0 10px; }
fieldset.plain { border: 0; padding: 0; margin: 0; min-width: 0; }
/* labelled switch (role=switch): 40 × 24 track, row height = --ctl-h (36 compact, 44 touch). VORAAA-104 */
.sw24 { display: inline-flex; align-items: center; gap: 10px; min-height: var(--ctl-h, var(--touch)); padding: 0 4px; border: 0; background: transparent; color: var(--ink-2); font: inherit; font-size: var(--fs-sm); font-weight: var(--fw-semi); cursor: pointer; }
.sw24 .sw-track { position: relative; width: 40px; height: 24px; border-radius: var(--r-pill); background: var(--line-2); flex: none; transition: background var(--t) var(--ease); }
.sw24 .sw-track::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: var(--card); box-shadow: 0 1px 3px rgba(15, 42, 51, .25); transition: transform var(--t) var(--ease); }
.sw24[aria-checked="true"] { color: var(--ink); }
.sw24[aria-checked="true"] .sw-track { background: var(--primary-fill); }
.sw24[aria-checked="true"] .sw-track::after { transform: translateX(16px); }
.sw24:disabled { opacity: .45; cursor: not-allowed; }
.sw24:focus-visible { outline: 0; }
.sw24:focus-visible .sw-track { box-shadow: 0 0 0 3px var(--accent-100); }
.switch-row { display: flex; gap: var(--sp-2); align-items: center; font-weight: var(--fw-regular); }
.switch-row input { width: 22px; height: 22px; flex: none; }
.dmg-card .dp-stepper-field { border: 1px solid var(--field-border); border-radius: var(--r-md); background: var(--card); }
.hint-inline > svg { width: 18px; height: 18px; flex: none; }
.hint-inline .src, .derived .k .src { background: none; border: 0; padding: 0; cursor: pointer; font: inherit; font-size: var(--fs-sm); color: var(--accent-text); font-weight: var(--fw-semi); text-decoration: underline; text-underline-offset: 2px; min-height: 0; }
.derived .k .src { font-size: var(--fs-xs); text-decoration: none; }
