:root {
  --bg: #f4f6f8;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --border: #dde3ea;
  --text: #16202b;
  --muted: #5d6b7a;
  --accent: #1f6feb;
  --accent-text: #ffffff;
  --warn-bg: #fff8e5;
  --warn-border: #e6c34a;
  --warn-text: #6b4e00;
  --error-bg: #fdecec;
  --error-border: #e08585;
  --error-text: #8a1f1f;
  --ok-bg: #e9f7ee;
  --ok-border: #7cc496;
  --ok-text: #1c5c34;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16,32,48,.06), 0 4px 12px rgba(16,32,48,.05);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12171d;
    --surface: #1a212a;
    --surface-2: #202932;
    --border: #2d3944;
    --text: #e6edf3;
    --muted: #9aa9b8;
    --accent: #4d8ef7;
    --warn-bg: #2e2814;
    --warn-border: #7a6420;
    --warn-text: #ffd97a;
    --error-bg: #2f1a1a;
    --error-border: #7d3a3a;
    --error-text: #ff9b9b;
    --ok-bg: #16281d;
    --ok-border: #35643f;
    --ok-text: #8ee0a8;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 4px 14px rgba(0,0,0,.25);
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  -webkit-font-smoothing: antialiased;
}

h1 { font-size: 1.45rem; margin: 0 0 .2rem; letter-spacing: -.01em; }
h2 { font-size: 1rem; margin: 0 0 .9rem; letter-spacing: -.005em; }
.muted { color: var(--muted); }
.small { font-size: .8rem; }
.hidden { display: none !important; }
.r { text-align: right; }

/* ---------- layout ---------- */
.layout { display: flex; min-height: 100vh; }

.sidebar {
  width: 232px;
  flex: 0 0 232px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 1.1rem .75rem;
  display: flex;
  flex-direction: column;
  gap: .2rem;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand {
  display: flex; align-items: center; gap: .55rem;
  font-weight: 650; font-size: .95rem;
  padding: .2rem .5rem 1.1rem;
}
/* Das Zeichen liegt als SVG im Markup, nicht als Buchstabe in einem Kasten:
   so ist es dasselbe H wie auf dem App-Symbol, und currentColor faerbt es
   mit. Geometrie und Erzeugung: tools/logo.py */
.brand-mark {
  width: 26px; height: 26px;
  color: var(--accent);
  flex: none;
}

.nav-item {
  display: flex; align-items: center; gap: .6rem;
  width: 100%; text-align: left;
  background: none; border: 0; border-radius: 8px;
  padding: .55rem .6rem;
  font: inherit; color: var(--text); cursor: pointer;
}
.nav-item span { width: 1.1rem; text-align: center; opacity: .75; }
.nav-item:hover { background: var(--surface-2); }
.nav-item.active { background: var(--accent); color: var(--accent-text); }
.nav-item.active span { opacity: 1; }

.sidebar-foot {
  margin-top: auto; padding: .6rem .6rem 0;
  border-top: 1px solid var(--border); font-size: .82rem;
}
#practice-name { font-weight: 600; margin-bottom: .15rem; }

.content { flex: 1; padding: 1.6rem 1.9rem 4rem; max-width: 1180px; }
.view-head { margin-bottom: 1.1rem; }
.view-head p { margin: 0; font-size: .88rem; }

/* ---------- cards ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.1rem 1.15rem;
  margin-bottom: 1.1rem;
}
.card-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem; margin-bottom: .9rem;
}
.card-head h2 { margin: 0; }
.split { display: grid; grid-template-columns: minmax(280px, 380px) 1fr; gap: 1.1rem; align-items: start; }
.row-gap { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }

/* ---------- forms ---------- */
label { display: block; font-size: .82rem; color: var(--muted); font-weight: 500; }
label > input, label > select, label > textarea {
  display: block; width: 100%; margin-top: .28rem;
  padding: .48rem .6rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 7px;
  color: var(--text); font: inherit; font-size: .92rem;
}
label > small { display: block; margin-top: .25rem; font-size: .75rem; }
input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--accent); outline-offset: -1px; background: var(--surface);
}
textarea { resize: vertical; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: .8rem; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: .8rem; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: .8rem; }
.span2 { grid-column: span 2; }
.span3 { grid-column: span 3; }
@media (max-width: 900px) {
  .grid-3, .grid-4 { grid-template-columns: 1fr 1fr; }
  .span3 { grid-column: span 2; }
  .split { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; }
}

.check { display: flex; align-items: center; gap: .5rem; font-size: .85rem; color: var(--text); }
.check input { width: auto; margin: 0; }

/* Ein Schalter mit Erklärung darunter: das Kästchen oben ausrichten, sonst
   sitzt es mittig neben einem dreizeiligen Text und zeigt auf nichts. */
.check.einstellung { align-items: flex-start; gap: .7rem; padding: .5rem 0; }
.check.einstellung > span { display: flex; flex-direction: column; gap: .2rem; }
.check.einstellung input { margin-top: .2rem; }

/* ---------- buttons ---------- */
.btn {
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  border-radius: 7px;
  padding: .48rem .85rem;
  font: inherit; font-size: .88rem; font-weight: 500;
  cursor: pointer;
}
.btn:hover:not(:disabled) { border-color: var(--muted); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn.big { padding: .62rem 1.4rem; font-size: .95rem; }
.btn.danger { color: var(--error-text); border-color: var(--error-border); }
.linkbtn {
  background: none; border: 0; padding: 0;
  color: var(--accent); font: inherit; font-size: .75rem;
  cursor: pointer; text-decoration: underline;
}
.iconbtn {
  background: none; border: 0; color: var(--muted);
  cursor: pointer; font-size: 1.05rem; line-height: 1; padding: .2rem .35rem;
}
.iconbtn:hover { color: var(--error-text); }

/* ---------- tables ---------- */
.table-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .88rem; }
th {
  text-align: left; font-weight: 600; font-size: .74rem;
  text-transform: uppercase; letter-spacing: .04em;
  color: var(--muted); padding: 0 .45rem .45rem;
  border-bottom: 1px solid var(--border); white-space: nowrap;
}
td { padding: .3rem .45rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
.list tbody tr { cursor: default; }
.list tbody tr.clickable:hover { background: var(--surface-2); }
.num { font-variant-numeric: tabular-nums; }

.lines td { padding: .22rem .3rem; }
.lines input, .lines select {
  width: 100%; margin: 0; padding: .34rem .45rem; font-size: .86rem;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 6px; color: var(--text); font-family: inherit;
}
.lines .desc { font-size: .84rem; color: var(--muted); padding-left: .2rem; }
.lines .money { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }

.empty { padding: 1.4rem .5rem; text-align: center; color: var(--muted); font-size: .88rem; }

/* ---------- banners / toasts ---------- */
.banner {
  border-radius: var(--radius); padding: .75rem .95rem; margin-bottom: 1.1rem;
  font-size: .87rem; display: flex; gap: 1rem; align-items: center; justify-content: space-between;
}
.banner.warn { background: var(--warn-bg); border: 1px solid var(--warn-border); color: var(--warn-text); }
.banner.error { background: var(--error-bg); border: 1px solid var(--error-border); color: var(--error-text); }
.banner ul { margin: .35rem 0 0; padding-left: 1.1rem; }
.banner li { margin: .15rem 0; }

#toasts {
  position: fixed; top: 1rem; right: 1rem; z-index: 50;
  display: flex; flex-direction: column; gap: .5rem;
}
.toast {
  background: var(--surface); border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: 8px; box-shadow: var(--shadow);
  padding: .65rem .9rem; font-size: .87rem; max-width: 380px;
}
.toast.ok { border-left-color: var(--ok-border); }
.toast.err { border-left-color: var(--error-border); }

/* ---------- summary ---------- */
.summary { display: flex; align-items: flex-end; gap: 1.4rem; flex-wrap: wrap; }
.summary .notes { flex: 1; min-width: 240px; }
.total-block { text-align: right; }
.total-block .muted { font-size: .78rem; }
.total { font-size: 1.5rem; font-weight: 650; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }

.justifications { margin-top: .7rem; display: flex; flex-direction: column; gap: .4rem; }
.justifications label { font-size: .78rem; }

/* ---------- import report ---------- */
.report {
  margin-top: 1rem; padding: .85rem 1rem; border-radius: var(--radius);
  background: var(--surface-2); border: 1px solid var(--border); font-size: .86rem;
}
.report.ok { background: var(--ok-bg); border-color: var(--ok-border); color: var(--ok-text); }
.report.bad { background: var(--error-bg); border-color: var(--error-border); color: var(--error-text); }
.report ul { margin: .4rem 0 0; padding-left: 1.1rem; }
.report .counts { display: flex; gap: 1.4rem; margin: .5rem 0; flex-wrap: wrap; }
.report .counts b { font-size: 1.1rem; display: block; font-variant-numeric: tabular-nums; }

/* ---------- dialog ---------- */
dialog {
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface); color: var(--text);
  box-shadow: 0 12px 40px rgba(0,0,0,.25);
  padding: 1.3rem; max-width: 760px; width: calc(100vw - 3rem);
}
dialog::backdrop { background: rgba(10,16,22,.5); }
.dialog-actions { display: flex; justify-content: flex-end; gap: .5rem; margin-top: 1.1rem; }
.detail-head { display: flex; justify-content: space-between; gap: 1rem; margin-bottom: .9rem; }
.detail-head h2 { margin: 0 0 .15rem; font-size: 1.2rem; }
.badge {
  display: inline-block; padding: .12rem .5rem; border-radius: 99px;
  font-size: .72rem; font-weight: 600; border: 1px solid var(--border);
}
.badge.storno { background: var(--error-bg); border-color: var(--error-border); color: var(--error-text); }
.badge.cancelled { background: var(--warn-bg); border-color: var(--warn-border); color: var(--warn-text); }
.kv { display: grid; grid-template-columns: auto 1fr; gap: .2rem .8rem; font-size: .85rem; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }

/* ---------- Anmeldung ---------- */
.auth-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 2rem 1rem;
  background: var(--bg);
}
.auth-card {
  width: 100%;
  max-width: 420px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.6rem 1.5rem;
}
.auth-brand { padding: 0 0 1.2rem; font-size: 1.05rem; }
.auth-tabs {
  display: flex; gap: .3rem; margin-bottom: 1.2rem;
  background: var(--surface-2); padding: .25rem; border-radius: 8px;
}
.auth-tab {
  flex: 1; border: 0; background: none; border-radius: 6px;
  padding: .45rem .5rem; font: inherit; font-size: .86rem; font-weight: 500;
  color: var(--muted); cursor: pointer;
}
.auth-tab.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.auth-form { display: flex; flex-direction: column; gap: .85rem; }
.auth-form .btn { margin-top: .3rem; }
.auth-note { margin: 1.2rem 0 0; line-height: 1.45; }
#auth-error { margin: 1rem 0 0; display: block; }

/* ---------- Zahlungsverfolgung ---------- */
.nav-count {
  margin-left: auto; min-width: 1.3rem; padding: 0 .35rem;
  border-radius: 99px; background: var(--warn-border); color: #2a2205;
  font-size: .7rem; font-weight: 700; text-align: center;
}
.nav-item.active .nav-count { background: var(--accent-text); color: var(--accent); }

.kpis { display: flex; gap: 1.1rem; margin-bottom: 1.1rem; flex-wrap: wrap; }
.kpi {
  flex: 1; min-width: 180px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow); padding: .95rem 1.1rem;
}
.kpi.overdue { border-color: var(--warn-border); background: var(--warn-bg); }
.kpi.overdue .kpi-label, .kpi.overdue .kpi-sub { color: var(--warn-text); opacity: .85; }
.kpi.overdue .kpi-value { color: var(--warn-text); }
.kpi-label { font-size: .76rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.kpi-value {
  font-size: 1.6rem; font-weight: 650; letter-spacing: -.02em;
  font-variant-numeric: tabular-nums; margin: .15rem 0 .05rem;
}
.kpi-sub { font-size: .78rem; }

.badge.offen { background: var(--surface-2); }
.badge.teilweise { background: var(--warn-bg); border-color: var(--warn-border); color: var(--warn-text); }
.badge.bezahlt { background: var(--ok-bg); border-color: var(--ok-border); color: var(--ok-text); }
.badge.ueberfaellig { background: var(--error-bg); border-color: var(--error-border); color: var(--error-text); }

.payment-section {
  margin-top: 1.2rem; padding-top: 1rem; border-top: 1px solid var(--border);
}
.payment-section h3 { margin: 0 0 .6rem; font-size: .95rem; }
.payment-form {
  display: flex; gap: .6rem; align-items: flex-end; flex-wrap: wrap; margin-top: .7rem;
}
.payment-form label { flex: 1; min-width: 110px; }
.payment-form label > input { margin-top: .2rem; padding: .4rem .5rem; font-size: .86rem; }
.payment-rows { font-size: .85rem; }
.payment-rows .row {
  display: flex; align-items: center; gap: .6rem;
  padding: .3rem 0; border-bottom: 1px solid var(--border);
}
.payment-rows .row:last-child { border-bottom: 0; }
.payment-rows .amount { font-variant-numeric: tabular-nums; font-weight: 600; min-width: 5.5rem; }
.payment-rows .grow { flex: 1; color: var(--muted); }

/* ---------- Patientenverwaltung ---------- */
#patient-search { min-width: 190px; }
.patient-history {
  margin-top: 1.2rem; padding-top: 1rem; border-top: 1px solid var(--border);
}
.patient-history h3 { margin: 0 0 .6rem; font-size: .95rem; }
.patient-history .row {
  display: flex; align-items: center; gap: .6rem;
  padding: .35rem 0; border-bottom: 1px solid var(--border);
  font-size: .85rem; cursor: pointer;
}
.patient-history .row:last-child { border-bottom: 0; }
.patient-history .row:hover { background: var(--surface-2); }
.patient-history .nr { font-variant-numeric: tabular-nums; min-width: 5.5rem; }
.patient-history .amount {
  margin-left: auto; font-variant-numeric: tabular-nums; font-weight: 600;
}
tr.archived td { opacity: .55; }
.badge.archiviert { background: var(--surface-2); color: var(--muted); }

/* ---------- E-Mail-Bestätigung ---------- */
.verify-link {
  color: inherit; font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: .78rem; word-break: break-all; text-decoration: underline;
}
#password-match.ok { color: var(--ok-text); }
#password-match.bad { color: var(--error-text); }

/* ---------- Datumsfelder ---------- */
input.ungueltig,
.lines input.ungueltig {
  border-color: var(--error-border);
  background: var(--error-bg);
  color: var(--error-text);
}
input.zukunft,
.lines input.zukunft {
  border-color: var(--warn-border);
  background: var(--warn-bg);
}

/* ---------- Offline-Hinweis ---------- */
.offline-leiste {
  position: fixed; inset: 0 0 auto 0; z-index: 60;
  background: var(--warn-bg); color: var(--warn-text);
  border-bottom: 1px solid var(--warn-border);
  padding: .5rem 1rem; font-size: .85rem; text-align: center;
}
.offline-leiste:not(.hidden) ~ .layout .sidebar { top: 2.2rem; }

/* Auf dem Startbildschirm installiert: Platz für die Statusleiste lassen. */
@media (display-mode: standalone) {
  .sidebar { padding-top: calc(1.1rem + env(safe-area-inset-top)); }
  .content { padding-top: calc(1.6rem + env(safe-area-inset-top)); }
}

/* ---------- Installationsknopf ---------- */
.install-btn {
  width: 100%; margin-top: .6rem; font-size: .82rem;
  border-color: var(--accent); color: var(--accent);
}
#install-hinweis { margin-top: .5rem; line-height: 1.4; }

/* ---------------------------------------------------------- Serienrechnung */

/* Blockierte Entwürfe werden gedämpft, aber nicht versteckt: sie sind
   der Grund, warum die Serie nicht vollständig durchläuft. */
.drafts tr.blockiert { background: var(--warn-bg); }
.drafts tr.blockiert td { color: var(--warn-text); }

.draft-meldungen {
  margin: .35rem 0 0; padding-left: 1.1rem;
  font-size: .8rem; line-height: 1.45;
}
.draft-meldungen li { margin: 0; }
.warn-text { color: var(--warn-text); }

.drafts input[type="checkbox"] { width: 1.05rem; height: 1.05rem; }
.drafts input[type="checkbox"]:disabled { cursor: not-allowed; }

#serie-blockiert:not(:empty) { margin-top: .3rem; }
#serie-bericht ul { margin: .5rem 0 0; padding-left: 1.2rem; line-height: 1.6; }

/* --------------------------------------------------------------- Mahnwesen */

.banner.info {
  background: color-mix(in srgb, var(--accent) 8%, transparent);
  border: 1px solid color-mix(in srgb, var(--accent) 35%, transparent);
}
.banner.info ul { margin: .4rem 0; padding-left: 1.2rem; line-height: 1.6; }
.banner.info p { margin: .2rem 0; }

/* Ankreuzfeld mit Erklärung darunter - die Erklärung ist hier wichtiger
   als das Feld, weil ein falsches Häkchen eine unberechtigte Forderung
   erzeugt. */
.checkline {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: .1rem .55rem;
  align-items: start;
  margin: .9rem 0 .2rem;
  font-size: .88rem;
  color: var(--text);
  font-weight: 500;
}
.checkline input { margin-top: .15rem; width: 1.05rem; height: 1.05rem; }
.checkline small { grid-column: 2; font-weight: 400; }

.card-actions {
  display: flex; gap: .6rem; flex-wrap: wrap;
  margin: 1rem 0 .2rem;
}

#mahn-ergebnis { margin-top: 1.2rem; }
#mahn-uebersprungen:not(:empty) { margin-top: .6rem; line-height: 1.5; }
#zins-form { margin-bottom: 1.1rem; }

/* Amtliche Leistungsbezeichnungen sind lang - die zu Nr. 7 umfasst zehn
   Zeilen. In der Erfassungstabelle dient die Bezeichnung nur der
   Orientierung, deshalb auf zwei Zeilen begrenzt; der volle Wortlaut steht
   im Titel-Attribut und - wo er hingehört - auf der Rechnung. § 12 Abs. 2
   Nr. 2 GOÄ verlangt ihn dort, nicht in der Eingabemaske. */
.lines .desc {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  cursor: help;
}

/* Der Block für den gesetzlichen Vertreter erscheint nur bei
   Minderjährigen - siehe pruefeMinderjaehrig() in app.js. */
.vertreter {
  border-top: 1px solid var(--border);
  padding-top: 1rem;
  margin-top: .4rem;
}


/* --- Auswertungen -------------------------------------------------- */
.split.gleich { grid-template-columns: 1fr 1fr; }
/* Ohne min-width: 0 nimmt ein Rasterfeld die Mindestbreite seines Inhalts an -
   eine Tabelle mit nicht umbrechenden Beträgen schiebt dann die ganze Seite
   seitlich hinaus, statt in ihrem eigenen Bereich zu scrollen. */
.split.gleich > * { min-width: 0; }
/* Zwei Spalten erst, wenn beide Tabellen ihre Beträge ungekürzt zeigen
   können - vorher untereinander. Ein abgeschnittener Betrag ist schlimmer
   als eine lange Seite. */
@media (max-width: 1200px) { .split.gleich { grid-template-columns: 1fr; } }

.row { display: flex; align-items: flex-end; }
.row.wrap { flex-wrap: wrap; }
.row.gap, .gap { gap: .8rem; }

/* Balken statt Diagrammbibliothek: eine Zahlenreihe mit Länge. Nichts
   nachzuladen, nichts zu pflegen, und auf dem Ausdruck noch lesbar. */
.balken { display: flex; flex-direction: column; gap: .45rem; }
.balken-zeile { display: grid; grid-template-columns: 5.5rem 1fr 7rem; gap: .7rem; align-items: center; }
.balken-spur { background: var(--surface-2, rgba(127,127,127,.14)); border-radius: 4px; height: 1.4rem; }
.balken-fuell { background: var(--accent); border-radius: 4px; height: 100%; min-width: 2px; }
.list td.money { white-space: nowrap; }

/* Summenzeile. Ohne eigene Linie liest sie sich als weitere Datenzeile -
   und damit als Bestandteil dessen, was sie zusammenfasst. */
.list tfoot th {
  border-top: 2px solid var(--border);
  padding-top: .55rem;
  font-weight: 600;
  color: var(--text);
  text-transform: none;
  letter-spacing: 0;
}
.balken-wert { text-align: right; font-variant-numeric: tabular-nums; }
.balken-monat { color: var(--muted); font-size: .82rem; font-variant-numeric: tabular-nums; }


/* --- Analogbewertung (§ 6 Abs. 2 GOÄ) ------------------------------- */
/* Eine analog bewertete Zeile sieht auf der Rechnung anders aus als die
   Ziffer, die im Feld steht. Das muss beim Erfassen sichtbar sein. */
.analog-aktiv .l-code { border-color: var(--accent); }
.analog-row td { padding-top: 0; }
.nowrap { white-space: nowrap; }


/* --- Einwilligungen -------------------------------------------------- */
.list tr.widerrufen td { opacity: .55; text-decoration: line-through; }
.list tr.widerrufen td:first-child { text-decoration: none; }
.einwilligung-neu { margin-top: 1rem; }
.einwilligung-neu summary { cursor: pointer; color: var(--accent); font-size: .9rem; }
.einwilligung-neu form { margin-top: .8rem; }


/* --- Übersicht -------------------------------------------------------- */
/* Bewusst flach: vier Meldungen mit voller Kastenhöhe schieben die Zahlen
   unter die Falz, und dann sieht man den Stand erst nach dem Scrollen. */
.banner.handlung {
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem; cursor: pointer;
  padding: .45rem .8rem; margin-bottom: .4rem;
}
.banner.handlung > div { font-size: .9rem; }
.banner.handlung .btn { flex: none; padding: .2rem .7rem; font-size: .8rem; }

/* Kennzeichnung abgetretener Forderungen. Kein Zusatz in Klammern, sondern
   ein eigenes Zeichen - in einer Liste mit dreissig Zeilen wird Text nicht
   gelesen, eine Marke schon. */
.badge-verkauft {
  display: inline-block; padding: .05rem .4rem; border-radius: 4px;
  background: var(--surface-2, rgba(127,127,127,.16));
  color: var(--muted); font-size: .72rem; white-space: nowrap;
}


/* --- Navigation in Gruppen ------------------------------------------- */
.nav-gruppe {
  margin: 1rem 0 .25rem; padding: 0 .9rem;
  font-size: .68rem; text-transform: uppercase; letter-spacing: .08em;
  color: var(--muted); opacity: .7;
}

/* --- Werkzeuge, die man selten braucht ------------------------------- */
/* Zugeklappt statt weggelassen: die Liste ist das, worauf man schaut,
   Kontoauszug und Mahnlauf sind Handgriffe von Zeit zu Zeit. Sechs
   gleichrangige Kästen liessen beides gleich wichtig aussehen. */
.werkzeug { margin-bottom: 1.1rem; }
.werkzeug > summary {
  cursor: pointer; padding: .7rem 1rem;
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
  font-weight: 600; font-size: .95rem; list-style: none;
}
.werkzeug > summary::-webkit-details-marker { display: none; }
.werkzeug > summary::before { content: "▸ "; color: var(--muted); }
.werkzeug[open] > summary { border-radius: 10px 10px 0 0; border-bottom: none; }
.werkzeug[open] > summary::before { content: "▾ "; }
.werkzeug[open] > .card { border-radius: 0 0 10px 10px; margin-top: 0; }


/* Zwischenüberschrift zwischen Kartengruppen. Ohne sie stehen elf Kästen
   gleichrangig nebeneinander, und man liest jeden, um zu sehen, wozu er
   gehört. */
h2.abschnitt {
  margin: 1.6rem 0 .7rem; font-size: .82rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: .07em; color: var(--muted);
}
h2.abschnitt:first-of-type { margin-top: .8rem; }


/* Wiederherstellungscodes: zum Abtippen von Papier gedacht, also
   Festbreitenschrift und grosszügiger Abstand. */
ul.codes { list-style: none; padding: 0; margin: .8rem 0;
  display: grid; grid-template-columns: repeat(auto-fill, minmax(11rem, 1fr));
  gap: .4rem; }
ul.codes code { font-size: 1.02rem; letter-spacing: .05em; }

/* --- Gebührenordnung je Position (§ 6 Abs. 2 GOZ) ---------------------
   Der Zahnarzt darf einzelne ärztliche Ziffern mitberechnen, also trägt
   jede Zeile ihre eigene Ordnung. Die Arztpraxis hat diese Wahl nicht -
   bei ihr verschwindet die Auswahl ganz, statt ausgegraut Platz und
   Aufmerksamkeit zu kosten. Sichtbar wird sie über `body.zahnarzt`,
   gesetzt aus der Sitzung. */
.ziffer-zelle { display: flex; gap: 0; }
.ziffer-zelle .l-code { flex: 1; min-width: 4.5rem; }

/* Der Umschlag hat overflow-x:auto - ohne Mindestbreite nutzt das nichts,
   die Tabelle schrumpft stattdessen mit und quetscht das Ziffernfeld auf
   wenige Pixel. Mit Mindestbreite schiebt sie sich lieber seitwärts. */
table.lines { min-width: 46rem; }
body.zahnarzt table.lines { min-width: 50rem; }

.l-cat { display: none; }
body.zahnarzt .l-cat {
  display: block;
  flex: 0 0 auto;
  width: 4rem;
  padding-inline: 0.3rem;
  border-top-right-radius: 0;
  border-bottom-right-radius: 0;
  border-right: none;
  color: var(--muted);
  background: var(--surface-2);
}
body.zahnarzt .ziffer-zelle .l-code {
  border-top-left-radius: 0;
  border-bottom-left-radius: 0;
}

/* Die abweichende Ordnung ist die Ausnahme und soll als solche auffallen -
   sie ist der Punkt, an dem eine Rechnung nach der falschen Verordnung
   entsteht, ohne dass der Betrag verdächtig aussieht. Die Klasse setzt das
   JS beim Wechsel; über ein Attribut ginge es nicht, ein <select> spiegelt
   seinen Wert nicht ins Markup. */
body.zahnarzt .l-cat.fremd {
  color: var(--text);
  font-weight: 600;
}

/* Nur der Zahnarztpraxis gezeigt. Gegenstück zu .l-cat: was der Arzt nicht
   wählen kann, steht ihm auch nicht im Weg. */
.zahnarzt-only { display: none; }
body.zahnarzt .zahnarzt-only { display: revert; }
