/* Befunddokumentation – Gestaltung nach Entwurf A1 (Farbklima 01). */

/* Titillium Web liegt auf dem eigenen Server (SIL Open Font License, siehe OFL.txt).
   Keine Verbindung zu Google Fonts: keine Daten an Dritte (Google),
   und externe Schriftdienste würden IP-Adressen an Dritte senden. */
@font-face { font-family: "Titillium Web"; font-style: normal; font-weight: 300; font-display: swap; src: url("../fonts/titillium-web/titillium-web-latin-300-normal.woff2") format("woff2"); }
@font-face { font-family: "Titillium Web"; font-style: normal; font-weight: 400; font-display: swap; src: url("../fonts/titillium-web/titillium-web-latin-400-normal.woff2") format("woff2"); }
@font-face { font-family: "Titillium Web"; font-style: normal; font-weight: 600; font-display: swap; src: url("../fonts/titillium-web/titillium-web-latin-600-normal.woff2") format("woff2"); }
@font-face { font-family: "Titillium Web"; font-style: normal; font-weight: 700; font-display: swap; src: url("../fonts/titillium-web/titillium-web-latin-700-normal.woff2") format("woff2"); }

:root {
  /* Farbklima 01 */
  --sand: #D3C8A6;
  --mint: #7A8F77;
  --gruen: #0F5229;
  --bordeaux: #630F24;

  /* abgeleitete Töne */
  --grund: #F6F2E7;         /* Seitenhintergrund, helles Sand */
  --flaeche: #FFFFFF;       /* Karten */
  --text: #1E231C;
  --text-leise: #5C5A4E;
  --linie: #E2DAC3;
  --linie-feld: #C9BF9F;
  --gruen-dunkel: #0A3A1D;
  --gruen-hell: #E4EBE2;    /* Auswahl hinterlegt, aus Mint aufgehellt */
  --mint-dunkel: #4E6B4A;
  --bordeaux-hell: #F3E3E6;
  --warnung-hell: #F5ECD2;
}

* { box-sizing: border-box; }
html { font-size: 16px; }
body {
  margin: 0;
  font-family: "Titillium Web", "Segoe UI", system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.45;
  color: var(--text);
  background: var(--grund);
}
a { color: var(--gruen); }
a:hover { color: var(--gruen-dunkel); }
h1 { font-size: 1.85rem; font-weight: 700; line-height: 1.15; margin: 0 0 .75rem; }
h2 { font-size: 1.15rem; font-weight: 700; margin: 1.25rem 0 .5rem; }
small { color: var(--text-leise); }
:focus-visible { outline: 2px solid var(--gruen); outline-offset: 2px; }

/* --- Rahmen: Seitenleiste und Inhalt ------------------------------------- */

.rahmen { display: flex; flex-wrap: wrap; min-height: 100vh; }
.seitenleiste {
  flex: 1 1 232px;
  max-width: 100%;
  background: var(--flaeche);
  border-right: 1px solid var(--linie);
  padding: 1.5rem 1rem;
  display: flex;
  flex-direction: column;
  gap: .25rem;
}
.marke { display: flex; align-items: center; gap: .6rem; padding: 0 .5rem 1.5rem; font-weight: 700; font-size: 1.25rem; color: var(--text); text-decoration: none; }
.marke svg { flex: none; }
.seitenleiste nav { display: flex; flex-direction: column; gap: .25rem; }
.seitenleiste nav a {
  display: flex; align-items: center; min-height: 44px; padding: 0 .75rem;
  border-radius: 8px; color: var(--text); text-decoration: none;
}
.seitenleiste nav a:hover { background: var(--grund); }
.seitenleiste nav a[aria-current="page"] { background: var(--gruen-hell); color: var(--gruen-dunkel); font-weight: 600; }
.seitenleiste .abstand { flex-grow: 1; }
.konto { border-top: 1px solid var(--linie); padding: 1rem .75rem 0; font-size: .9rem; color: var(--text-leise); }
.konto strong { display: block; color: var(--text); }
.konto form { margin: .5rem 0 0; }
.konto button { margin: 0; }

.inhalt { flex: 999 1 640px; min-width: 0; padding: 1.75rem 2rem 2.5rem; }
.inhalt > * { max-width: 72rem; }
.ohne-anmeldung .inhalt { max-width: 28rem; margin: 4rem auto; flex: 0 1 28rem; }

/* Schmale Bildschirme: Seitenleiste wird zur Leiste oben. */
@media (max-width: 900px) {
  .seitenleiste { flex-basis: 100%; border-right: 0; border-bottom: 1px solid var(--linie); padding: .75rem 1rem; flex-direction: row; flex-wrap: wrap; align-items: center; }
  .marke { padding: 0 .5rem 0 0; }
  .seitenleiste nav { flex-direction: row; flex-wrap: wrap; }
  .seitenleiste .abstand { display: none; }
  .konto { border-top: 0; padding: 0; margin-left: auto; display: flex; align-items: center; gap: .75rem; }
  .konto form { margin: 0; }
  .inhalt { padding: 1.25rem 1rem 2rem; }
}

/* --- Karten, Meldungen, Tabellen ----------------------------------------- */

.karte { background: var(--flaeche); border: 1px solid var(--linie); border-radius: 12px; padding: 1.25rem 1.5rem; }
.karte + .karte { margin-top: 1.25rem; }
.karte > :first-child { margin-top: 0; }

.meldung { padding: .7rem 1rem; margin: 0 0 1rem; border-radius: 8px; background: var(--gruen-hell); border: 1px solid #C7D3C4; }
.meldung.warning { background: var(--warnung-hell); border-color: #E0CF9C; }
.meldung.success { background: var(--gruen-hell); }
.meldung.error { background: var(--bordeaux-hell); border-color: #DDB5BE; }
.fehler { color: var(--bordeaux); font-weight: 600; }
.hinweis { color: var(--bordeaux); margin-left: .5rem; }

table { border-collapse: collapse; width: 100%; margin-top: 1rem; }
th, td { text-align: left; padding: .55rem .7rem; border-bottom: 1px solid var(--linie); }
th { font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; color: var(--text-leise); font-weight: 700; }
tbody tr:hover { background: #FAF8F1; }

dl { display: grid; grid-template-columns: max-content 1fr; gap: .35rem 1.5rem; }
dt { font-weight: 600; color: var(--text-leise); }
dd { margin: 0; }

/* --- Formularelemente ----------------------------------------------------- */

label { display: block; margin-top: .75rem; }
input[type=text], input[type=password], input[type=search], input[type=email], input[type=number], input[type=date], select, textarea {
  font: inherit;
  color: var(--text);
  background: var(--flaeche);
  border: 1px solid var(--linie-feld);
  border-radius: 8px;
  padding: .45rem .65rem;
  min-height: 44px;
}
input[type=text], input[type=password], input[type=search], input[type=email] { width: 100%; max-width: 22rem; }
textarea { width: 100%; min-height: auto; }
input:focus, select:focus, textarea:focus { border-color: var(--gruen); outline: 2px solid rgba(15, 82, 41, .18); outline-offset: 0; }
input[type=checkbox], input[type=radio] { accent-color: var(--gruen); width: 18px; height: 18px; vertical-align: -3px; }

button, .knopf {
  font: inherit;
  font-weight: 600;
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 44px;
  margin-top: 1rem;
  padding: 0 1.25rem;
  border-radius: 8px;
  border: 1px solid var(--gruen);
  background: var(--gruen);
  color: #FFFFFF;
  cursor: pointer;
  text-decoration: none;
}
button:hover, .knopf:hover { background: var(--gruen-dunkel); border-color: var(--gruen-dunkel); color: #FFFFFF; }
button.leise, .knopf.leise { background: var(--flaeche); color: var(--text); border-color: var(--linie-feld); }
button.leise:hover, .knopf.leise:hover { background: var(--grund); color: var(--text); }

/* --- Kopf der Akte -------------------------------------------------------- */

.zurueck { display: inline-block; margin-bottom: .5rem; text-decoration: none; font-weight: 600; }
.vorzeile { font-size: .8rem; text-transform: uppercase; letter-spacing: .08em; font-weight: 600; color: var(--text-leise); margin: 0; }
.leise-text { color: var(--text-leise); font-weight: 300; }
/* Patientendaten und Überweiser nebeneinander, wenn Platz ist, sonst untereinander */
.akte-spalten { display: grid; grid-template-columns: repeat(auto-fit, minmax(20rem, 1fr)); gap: 1rem 2.5rem; align-items: start; }
.akte-ueberweiser > h2:first-child { margin-top: 0; }

/* --- Odontogramm --------------------------------------------------------- */

.odontogramm { overflow-x: auto; }
.odontogramm .seiten { display: flex; justify-content: space-between; min-width: 40rem; max-width: 52rem; font-size: .8rem; color: var(--text-leise); padding: 0 .25rem; }
.zahnreihe { display: grid; grid-template-columns: repeat(16, minmax(2.4rem, 1fr)); gap: .35rem; min-width: 40rem; max-width: 52rem; margin: .35rem 0; }
.zahnreihe + .zahnreihe { border-top: 1px solid var(--linie); padding-top: .6rem; margin-top: .6rem; }
.zahn {
  display: flex; flex-direction: column; align-items: center; gap: .15rem;
  padding: .25rem .1rem;
  border: 1px solid #D8CFB4; border-radius: 8px;
  background: var(--flaeche); color: var(--text);
  font-weight: 600; text-decoration: none;
}
.zahn:hover { border-color: var(--gruen); color: var(--gruen-dunkel); }
.zahn.mitte { margin-left: .75rem; }
.odontogramm .zahnreihe { grid-template-columns: repeat(8, minmax(2.4rem, 1fr)) .5rem repeat(8, minmax(2.4rem, 1fr)); }
.odontogramm .zahn.mitte { margin-left: 0; grid-column-start: 10; }
.zahn.hat-befund { background: var(--gruen-hell); border: 2px solid var(--gruen); color: var(--gruen-dunkel); }

/* Endodontische Markierungen (Schritt 3c) */
.odontogramm { --og-gelb: #C98A0B; --og-gelb-hell: #F3D58C; --og-mint-hell: #B9CBB5; }
.zahn .nummer { font-size: .85rem; }
.zahn .og-symbol { width: 100%; max-width: 2.25rem; height: auto; max-height: 4.4rem; }
.zahn .kuerzel { display: flex; flex-direction: column; align-items: center; min-height: 3.1em; font-size: .68rem; line-height: 1.05; font-weight: 600; white-space: nowrap; letter-spacing: -.01em; }
.zahnreihe-oben .zahn .kuerzel { justify-content: flex-end; }
.zahnreihe-unten .zahn .kuerzel { justify-content: flex-start; }
.k-gruen { color: var(--gruen); }
.k-rot { color: var(--bordeaux); }
.k-gelb { color: var(--og-gelb); }
.k-grau { color: var(--text-leise); }
.og-symbol path, .og-symbol rect, .og-symbol circle { fill: none; vector-effect: non-scaling-stroke; }
.og-umriss { stroke: var(--text-leise); stroke-width: 1; }
.og-pulpa { stroke: var(--text-leise); stroke-width: .75; }
.og-kanal { stroke: var(--text-leise); stroke-width: .75; }
.og-symbol .og-pulpa-gruen { fill: var(--og-mint-hell); stroke: var(--gruen); stroke-width: .75; }
.og-symbol .og-pulpa-gelb { fill: var(--og-gelb-hell); stroke: var(--og-gelb); stroke-width: .75; }
.og-gruen { stroke: var(--gruen); stroke-width: 2.4; }
.og-rot { stroke: var(--bordeaux); stroke-width: 2.4; }
.og-gelb { stroke: var(--og-gelb); stroke-width: 2.4; stroke-dasharray: 4 2.5; }
.og-doppel { stroke-width: 1.6; }
.og-gestrichelt { stroke-dasharray: 3 2; }
.og-schnitt { stroke: var(--bordeaux); stroke-width: 2.5; }
.og-ost, .og-fistel { stroke: var(--bordeaux); stroke-width: 1.5; }
.odontogramm-legende { display: grid; grid-template-columns: repeat(auto-fill, minmax(14rem, 1fr)); gap: .2rem 1.25rem; margin: 1rem 0 .5rem; font-size: .85rem; }
.odontogramm-legende div { display: flex; gap: .5rem; }
.odontogramm-legende dt { min-width: 3.6rem; font-weight: 700; }
.odontogramm-legende dd { margin: 0; color: var(--text-leise); }

/* --- Befundformular ------------------------------------------------------ */

fieldset { border: 1px solid var(--linie); border-radius: 12px; margin: 1.25rem 0; padding: .75rem 1.25rem 1.25rem; background: var(--flaeche); }
legend { font-weight: 700; font-size: .85rem; text-transform: uppercase; letter-spacing: .08em; color: var(--gruen); padding: 0 .4rem; }
.feld { margin-top: .6rem; }
.feld.kurz { display: inline-block; min-width: 15rem; margin-right: 1rem; }
.feld.kurz label { display: inline; margin: 0; }

.unterabschnitt { margin-top: .75rem; }
.unterabschnitt h3 { font-size: 1rem; font-weight: 700; margin: 1rem 0 .25rem; color: var(--gruen-dunkel); border-bottom: 1px solid var(--linie); padding-bottom: .25rem; }

.zeile { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem 1.5rem; padding: .5rem 0; border-bottom: 1px dashed var(--linie); }
.zeile .ober { display: inline; margin: 0; min-width: 14rem; font-weight: 600; }
.zeile .ober.normal { font-weight: normal; }
.zeile .unterpunkte { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem 1.1rem; }
.zeile .unterpunkte label { display: inline; margin: 0; }
.zeile .unterpunkte input[type=text], .zeile .unterpunkte input[type=number] { width: 12rem; }
.zeile .fehler { flex-basis: 100%; }
/* Zeile ohne Überschrift: Häkchen in denselben Spalten wie die Häkchen darüber (.feld.kurz). */
.zeile.ohne-titel .unterpunkte { column-gap: calc(1rem + .25em); } /* .25em = Leerzeichen zwischen den inline-block-Feldern */
.zeile.ohne-titel .unterpunkte > label { display: inline-block; min-width: 15rem; }
.zeile .unterpunkte-block { display: flex; flex-direction: column; gap: .35rem; }
.janein-zeile .unterpunkte-block { flex-basis: 100%; padding-left: 1.5rem; }
[hidden] { display: none !important; }

/* Auswahllisten: Einfachauswahl als runde Schaltflächen, Mehrfachauswahl als Häkchen. */
.auswahl { display: inline-flex; flex-wrap: wrap; gap: .4rem; }
.auswahl > div { display: inline-block; margin: 0; }
.auswahl label { display: inline; margin: 0 1rem 0 0; }
.auswahl label:has(> input[type=radio]) {
  display: inline-flex; align-items: center;
  min-height: 40px; margin: 0; padding: 0 .9rem;
  border: 1px solid var(--linie-feld); border-radius: 20px;
  background: var(--flaeche); cursor: pointer;
}
.auswahl label:has(> input[type=radio]):hover { border-color: var(--gruen); }
.auswahl label > input[type=radio] { position: absolute; opacity: 0; width: 1px; height: 1px; }
.auswahl label:has(> input[type=radio]:checked) { background: var(--gruen); border-color: var(--gruen); color: #FFFFFF; font-weight: 600; }
.auswahl label:has(> input[type=radio]:focus-visible) { outline: 2px solid var(--gruen); outline-offset: 2px; }
.auswahl label:has(> input[type=radio]:disabled) { cursor: default; }

/* Ja/Nein-Schaltflächen */
.janein { display: inline-flex; gap: .4rem; }
.janein > div { margin: 0; }
.zeile .janein label { display: inline-flex; justify-content: center; align-items: center; width: 4.5rem; min-height: 40px; margin: 0; border: 2px solid; border-radius: 8px; background: var(--flaeche); font-weight: 600; cursor: pointer; }
.janein input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.janein > div:first-child label { border-color: var(--gruen); color: var(--gruen); }
.janein > div:last-child label { border-color: var(--bordeaux); color: var(--bordeaux); }
.janein > div:first-child label:has(input:checked) { background: var(--gruen); color: #FFFFFF; }
.janein > div:last-child label:has(input:checked) { background: var(--bordeaux); color: #FFFFFF; }
.janein label:has(input:focus-visible) { outline: 2px solid var(--gruen); outline-offset: 2px; }
.janein label:has(input:disabled) { cursor: default; }

/* Kariesflächen */
.flaechen { display: grid; grid-template-columns: repeat(3, 2.75rem); grid-template-rows: repeat(3, 2.75rem); gap: 3px; margin-top: .3rem; }
.flaechen > span { position: relative; }
.flaechen .pos-top { grid-area: 1 / 2; } .flaechen .pos-left { grid-area: 2 / 1; } .flaechen .pos-center { grid-area: 2 / 2; }
.flaechen .pos-right { grid-area: 2 / 3; } .flaechen .pos-bottom { grid-area: 3 / 2; }
.flaechen input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.flaechen label, .zeile .unterpunkte .flaechen label { display: flex; align-items: center; justify-content: center; height: 100%; margin: 0; border: 1px solid var(--linie-feld); border-radius: 4px; background: var(--flaeche); cursor: pointer; font-weight: 600; }
.flaechen input:checked + label { background: var(--bordeaux); border-color: var(--bordeaux); color: #FFFFFF; }
.flaechen input:focus-visible + label { outline: 2px solid var(--gruen); outline-offset: 1px; }
.flaechen input:disabled + label { cursor: default; }

.formular-fuss { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: .75rem; border-top: 1px solid var(--linie); padding-top: 1rem; margin-top: 1rem; }
.formular-fuss button { margin: 0; }

/* Livesuche Überweiser (Patient anlegen) */
.treffer { list-style: none; padding: 0; margin: .4rem 0 0; max-width: 32rem; display: flex; flex-direction: column; gap: .3rem; }
.treffer button { display: block; width: 100%; margin: 0; text-align: left; }
.treffer small { display: block; font-weight: normal; }
.feld > small { display: block; margin-top: .2rem; }
