/* 💊 Medikamenten-Liste (A-064, medikamente.js). Farben vom Nutzer gewählt (22.11.: „A mit Füllfarb-Kräftigkeit von C“):
   Kopfzeilen App-Grün mit weißer Schrift, Spalten Morgen gelb · Mittag apricot · Abend salbei · Nacht blau.
   Alle Farben als Variablen – im Dunkelmodus abgedunkelt (Text ≥ 4,5 : 1), im Druck immer die hellen. */
:root {
  --med-kopf: #3f7306; --med-kopf-text: #fff;
  --med-morgen: #ffe98a; --med-mittag: #f7c6a3; --med-abend: #c5dcae; --med-nacht: #bccbe6;
  --med-name: #fff; --med-text: #1f2a17; --med-rand: #b9c2b0;
  --med-trenn: #5c6a52; --med-abschnitt: #8a9680;
  --med-leer: #c62828; --med-leer-text: #fff;
  --med-hinweis: #fff4d1; --med-leise: #4f5b47;
}
html.dark {
  --med-kopf: #3f7306; --med-kopf-text: #fff;
  --med-morgen: #5a4b0c; --med-mittag: #5e3720; --med-abend: #33492a; --med-nacht: #2c3a58;
  --med-name: #1f242a; --med-text: #f2f4ef; --med-rand: #4a5246;
  --med-trenn: #9aa68f; --med-abschnitt: #6b7563;
  --med-leer: #b71c1c; --med-leer-text: #fff;
  --med-hinweis: #3d3620; --med-leise: #c9d1c2;
}

.med-hilfe { color: var(--med-leise); font-size: 14px; margin: 4px 0 12px; }
.med-tabellen { color: var(--med-text); }
.med-tabelle { width: 100%; border-collapse: collapse; table-layout: fixed; font-size: 1em; }
.med-tabelle col.med-c-name { width: 34%; }
.med-tabelle th, .med-tabelle td { border: 1px solid var(--med-rand); padding: .35em .5em; text-align: center; vertical-align: middle; overflow-wrap: anywhere; hyphens: auto; }
.med-tabelle thead th { background: var(--med-kopf); color: var(--med-kopf-text); font-weight: 700; }
.med-tabelle thead th:first-child, .med-tabelle td.med-name { text-align: left; }
.med-tabelle td.med-name { background: var(--med-name); padding: 0; }
.med-tabelle td.med-morgen { background: var(--med-morgen); }
.med-tabelle td.med-mittag { background: var(--med-mittag); }
.med-tabelle td.med-abend { background: var(--med-abend); }
.med-tabelle td.med-nacht { background: var(--med-nacht); }
.med-tabelle tbody tr.med-zeile { cursor: pointer; }
.med-name-knopf { display: block; width: 100%; min-height: 2.4em; padding: .35em .5em; border: 0; background: transparent; color: inherit; font: inherit; text-align: left; cursor: pointer; }
.med-name-knopf:focus-visible { outline: 3px solid #1565c0; outline-offset: -3px; }
.med-tabelle tr.med-zeile:hover td.med-name { box-shadow: inset 4px 0 0 var(--med-kopf); }
/* Leer: rot + Marke „LEER“ als Text (Farbe nie allein) + wer, wann */
.med-tabelle tr.med-leer td.med-name { background: var(--med-leer); color: var(--med-leer-text); font-weight: 700; }
.med-leer-marke { display: inline-block; margin-left: .4em; padding: 0 .35em; border-radius: 4px; background: #fff; color: var(--med-leer); font-size: .72em; font-weight: 800; letter-spacing: .04em; vertical-align: .1em; }
.med-leer-wer { display: block; font-size: .78em; font-weight: 400; }
/* Gruppen-Trennzeile (schraffiert) und Abschnitts-Trenner */
.med-tabelle tr.med-trenn td { height: .7em; padding: 0; border-color: var(--med-trenn);
  background: repeating-linear-gradient(-45deg, var(--med-trenn) 0 3px, transparent 3px 7px), var(--med-name); }
.med-abschnitt-trenner { height: .8em; background: var(--med-abschnitt); }
.med-fussnoten { list-style: none; padding: 0; margin: 10px 0 0; font-size: .92em; }
.med-fussnoten li { margin: 2px 0; }
.med-fussnoten .med-fn-z { display: inline-block; min-width: 2.2em; font-weight: 700; }
.med-hinweis-text { background: var(--med-hinweis); color: var(--med-text); border-radius: 10px; padding: 10px 12px; margin: 12px 0 0; white-space: pre-line; font-size: .95em; }
.med-knoepfe { display: flex; gap: 10px; flex-wrap: wrap; justify-content: space-between; margin-top: 14px; }
.med-knoepfe > span { display: flex; gap: 10px; flex-wrap: wrap; }
.med-leer-liste { margin: 0 0 12px; }

/* Am Handy: schmalere Spalten, Umbruch */
@media (max-width: 600px) {
  .med-tabelle { font-size: 14px; }
  .med-tabelle col.med-c-name { width: 32%; }
  .med-tabelle th, .med-tabelle td { padding: .3em .2em; }
  .med-tabelle thead th { font-size: 12.5px; }
}

/* Vollbild: Menü und Reiter weg, schmale Leiste oben, Schrift wächst mit der Breite (Tablet quer ohne Scrollen) */
.med-vollbild { position: fixed; inset: 0; z-index: 9000; background: var(--card-bg, #fff); display: flex; flex-direction: column; color: var(--med-text); }
html.dark .med-vollbild { background: #15191d; }
.med-vb-leiste { display: flex; align-items: center; gap: 8px; padding: 6px 10px; background: linear-gradient(#437604, #315f03); color: #fff; }
.med-vb-leiste h2 { flex: 1; margin: 0; font-size: 18px; color: #fff; }
.med-vb-leiste .btn { min-height: 40px; }
.med-vb-inhalt { flex: 1; overflow: auto; padding: 8px 12px 16px; font-size: clamp(14px, 1.75vw, 30px); }
.med-vb-inhalt .med-tabelle { font-size: 1em; }
.med-vb-inhalt .med-tabelle thead th { font-size: 1em; }
@media (orientation: landscape) and (min-width: 700px) { .med-vb-inhalt { font-size: clamp(14px, min(1.75vw, 2.1vh), 30px); } }
.med-vb-inhalt .med-name-knopf { min-height: 1.9em; padding: .2em .45em; }
.med-vb-inhalt .med-tabelle th, .med-vb-inhalt .med-tabelle td { padding-top: .2em; padding-bottom: .2em; }
.med-vb-inhalt .med-hinweis-text { margin-top: 8px; padding: 6px 10px; }
.med-vb-inhalt .med-fussnoten { margin-top: 6px; }
body.med-vb-offen { overflow: hidden; }

/* Blatt „✓ Da / Leer“ */
.med-blatt h3 { color: var(--primary-color, #3f7306); }
.med-blatt-info { margin: 4px 0 12px; }
.med-blatt-knoepfe { display: flex; gap: 10px; margin: 14px 0 8px; }
.med-blatt-knoepfe .btn { flex: 1; min-height: 52px; font-size: 18px; font-weight: 700; }
.med-blatt-knoepfe .btn.med-aktiv { outline: 3px solid var(--med-text); outline-offset: 2px; }
.med-blatt-fuss { font-size: 13px; color: var(--med-leise); }
.hc-sheet.med-form { max-width: 560px; }
.med-zeiten { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.med-zeiten label { margin: 0 !important; padding: 6px 8px; border-radius: 8px; color: #1f2a17; font-size: 13px; }
.med-zeiten input { width: 100%; box-sizing: border-box; margin-top: 4px; }
.med-zeiten .med-morgen { background: #ffe98a; } .med-zeiten .med-mittag { background: #f7c6a3; }
.med-zeiten .med-abend { background: #c5dcae; } .med-zeiten .med-nacht { background: #bccbe6; }
@media (max-width: 420px) { .med-zeiten { grid-template-columns: repeat(2, 1fr); } }
.med-fn-warnung { background: var(--med-hinweis); color: var(--med-text); border-radius: 8px; padding: 6px 10px; font-size: 14px; margin-top: 8px; }
.med-form-knoepfe { display: flex; justify-content: space-between; gap: 10px; margin-top: 18px; }
.med-form-knoepfe > span { display: flex; gap: 10px; }
.med-check { display: flex !important; gap: 8px; align-items: center; font-weight: 400 !important; }
.med-check input { width: 20px; height: 20px; }

/* Bearbeiten (nur Admin) */
.med-edit-liste { list-style: none; padding: 0; margin: 6px 0 12px; }
.med-edit-liste li { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; padding: 4px 0; border-bottom: 1px solid var(--med-rand); }
.med-edit-liste li > .med-edit-name { flex: 1; min-width: 120px; }
.med-edit-liste input[type="text"] { flex: 1; min-width: 100px; }
.med-fn-zeile input.med-fn-zeichen { flex: 0 0 70px; min-width: 60px; }
.med-edit h3 { margin: 16px 0 4px; }

/* Druck (A4, wie das bisherige Blatt): nur das Druckblatt, helle Farben */
#medDruck { display: none; }
@media print {
  @page { size: A4; margin: 12mm; }
  html.med-drucken body > *:not(#medDruck) { display: none !important; }
  html.med-drucken body { background: #fff !important; }
  html.med-drucken #medDruck { display: block; color: #1f2a17; font-size: 11pt; font-family: "Atkinson Hyperlegible", Arial, sans-serif;
    -webkit-print-color-adjust: exact; print-color-adjust: exact;
    --med-kopf: #3f7306; --med-kopf-text: #fff; --med-morgen: #ffe98a; --med-mittag: #f7c6a3; --med-abend: #c5dcae; --med-nacht: #bccbe6;
    --med-name: #fff; --med-text: #1f2a17; --med-rand: #8f9887; --med-trenn: #5c6a52; --med-abschnitt: #8a9680; --med-hinweis: #fff; }
  #medDruck .med-tabelle { page-break-inside: auto; }
  #medDruck .med-tabelle tr { page-break-inside: avoid; }
  #medDruck .med-hinweis-text { padding: 0; margin-top: 10px; }
  #medDruck .med-stand { margin-top: 14px; font-size: 9pt; color: #5c6a52; }
}

/* Dunkelmodus: theme.css färbt alle Kopfzellen grau und alle Rahmen gleich (!important) – die Medikamenten-Tabelle behält
   ihre grüne Kopfzeile und ihre Rahmen (Nutzerwahl 22.11.) */
html.dark .med-tabelle thead th { background: var(--med-kopf) !important; color: var(--med-kopf-text) !important; }
html.dark .med-tabelle :is(th, td) { border-color: var(--med-rand) !important; }
html.dark .med-tabelle tr.med-trenn td { border-color: var(--med-trenn) !important; }
/* „Leer“ im Blatt: kräftig rot mit weißer Schrift wie im Entwurf (sonst wäre .btn-danger ohne Symbol weiß mit roter Schrift,
   im Dunkelmodus grau) */
html .med-blatt-knoepfe .btn.btn-danger.med-leer-knopf, html.dark .med-blatt-knoepfe .btn.btn-danger.med-leer-knopf.med-leer-knopf {
  background: #c62828 !important; border-color: #c62828 !important; color: #fff !important; }
html .med-blatt-knoepfe .btn.btn-danger.med-leer-knopf:hover { background: #a61f1f !important; }
/* A-090: Ziehen + automatische Gruppen */
.med-pfeil-platz { display: inline-block; width: 44px; height: 1px; }
.med-edit-liste li.med-edit-neue-gruppe { border-top: 3px double var(--med-trenn, #9aa59a); margin-top: 4px; }
.med-zieh-hinweis { background: #fff3cd; color: #3d3000; border-radius: 8px; padding: 8px 10px; margin: 6px 0; font-weight: 600; }
html.dark .med-zieh-hinweis { background: #4a3f0a; color: #fff4c2; }
.med-tabelle tr.med-zeile.sortable-ghost { opacity: .45; }
.med-tabelle tr.med-zeile.sortable-chosen { outline: 3px solid #3f7306; outline-offset: -3px; }
@media (hover: hover) { .med-tabelle tbody[data-abschnitt] tr.med-zeile { cursor: grab; } }
@media print { .med-zieh-hinweis { display: none; } }
