/* apothekerschrank — Erscheinungsbild an das Kids-Dashboard angeglichen.
   Werte direkt aus dessen app.css uebernommen:
   dunkler Grund #05070f / Karten #0e1426, Akzent Neon-Tuerkis #2ee6ff,
   Personenpalette tuerkis / violett / bernstein (+ magenta, blau, pink),
   Schriften IBM Plex Sans, Chakra Petch (Ueberschriften, Zahlen), IBM Plex Mono.
   Hell-Modus: Palette aus html[data-kd-theme="light"] des Dashboards.
   Keine Farbe traegt Bedeutung allein — jeder Zustand hat Symbol + Text. */

@font-face { font-family:'IBM Plex Sans'; font-style:normal; font-weight:400; font-display:swap;
  src:url('fonts/IBMPlexSans-400-latin.woff2') format('woff2'); }
@font-face { font-family:'IBM Plex Sans'; font-style:normal; font-weight:500; font-display:swap;
  src:url('fonts/IBMPlexSans-500-latin.woff2') format('woff2'); }
@font-face { font-family:'IBM Plex Sans'; font-style:normal; font-weight:600; font-display:swap;
  src:url('fonts/IBMPlexSans-600-latin.woff2') format('woff2'); }
@font-face { font-family:'Chakra Petch'; font-style:normal; font-weight:500; font-display:swap;
  src:url('fonts/ChakraPetch-500-latin.woff2') format('woff2'); }
@font-face { font-family:'Chakra Petch'; font-style:normal; font-weight:600; font-display:swap;
  src:url('fonts/ChakraPetch-600-latin.woff2') format('woff2'); }
@font-face { font-family:'IBM Plex Mono'; font-style:normal; font-weight:400; font-display:swap;
  src:url('fonts/IBMPlexMono-400-latin.woff2') format('woff2'); }
@font-face { font-family:'IBM Plex Mono'; font-style:normal; font-weight:500; font-display:swap;
  src:url('fonts/IBMPlexMono-500-latin.woff2') format('woff2'); }

:root {
  color-scheme: dark;

  --bg:        #05070f;
  --bg-2:      #0a0f1e;
  --surface:   #0e1426;
  --surface-2: #16203a;
  --surface-3: #1b2742;
  --line:        rgba(120,160,220,.14);
  --line-strong: rgba(120,180,240,.28);

  --text:   #e6ebf3;
  --text-2: #a9b3c6;
  --text-3: #7a859b;

  --accent:      #2ee6ff;   /* Neon-Tuerkis: nur Akzent, nie Fliesstext */
  --accent-rgb:  46,230,255;
  --accent-ink:  #07121b;   /* Text auf der Akzentflaeche */

  /* Armarium-Zeichen: im Dunkelmodus das Tuerkis des Logos,
     im Hellmodus das Marineblau — dieselbe Geometrie, nur die Tinte dreht. */
  --brand-ink:   #01fad9;
  --brand-navy:  #021134;

  --st-ok:      #4fd9c4;    /* in Ordnung: Tuerkis, gedaempft */
  --st-ok-rgb:  79,217,196;
  --st-change:  #ffd25e;    /* laeuft ab: Bernstein */
  --st-change-rgb: 255,210,94;
  --st-cancel:  #ff6b81;    /* abgelaufen / entfaellt: gedaempftes Rot */
  --st-cancel-rgb: 255,107,129;
  --st-idle:    #9aa6bb;

  --r: 14px;
  --r-sm: 9px;
  --r-pill: 999px;

  --font: 'IBM Plex Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --display: 'Chakra Petch', 'IBM Plex Sans', sans-serif;
  --mono: 'IBM Plex Mono', ui-monospace, monospace;
  --ease: cubic-bezier(.2,.7,.2,1);

  --sidebar-w: 236px;
  --shadow: 0 1px 0 rgba(255,255,255,.03) inset, 0 20px 40px -24px rgba(0,0,0,.6);

  /* Aliasse: app.js setzt an einigen Stellen noch die alten Namen inline. */
  --text-soft: var(--text-2);
  --ok: var(--st-ok);
  --warn: var(--st-change);
  --bad: var(--st-cancel);
  --accent-soft: rgba(var(--accent-rgb), .1);
}

/* ---------------------------------------------- Hell-Modus (Dashboard) --- */
html[data-theme="light"] {
  color-scheme: light;
  --bg:        #f3f6fb;
  --bg-2:      #e9eff8;
  --surface:   #ffffff;
  --surface-2: #eaf0f8;
  --surface-3: #dfe8f4;
  --line:        rgba(42,65,96,.18);
  --line-strong: rgba(42,65,96,.34);

  --text:   #17243a;
  --text-2: #41526c;
  --text-3: #53647b;

  --accent:     #006d83;
  --accent-rgb: 0,109,131;
  --accent-ink: #ffffff;

  /* Hell: das Zeichen in Marineblau, damit es auf Weiss traegt. */
  --brand-ink:  #021134;

  --st-ok:      #0f6f60;
  --st-ok-rgb:  15,111,96;
  --st-change:  #805900;
  --st-change-rgb: 128,89,0;
  --st-cancel:  #b41e3a;
  --st-cancel-rgb: 180,30,58;
  --st-idle:    #6d7b90;

  --shadow: 0 5px 18px rgba(24,44,72,.07);
}

/* --------------------------------------------- Personenfarben (Chips, ..) -
   pc-1 .. pc-6, feste Reihenfolge wie im Dashboard: tuerkis, violett,
   bernstein, magenta, blau, pink. Im Hell-Modus dunklere Varianten,
   damit die Farbe als Text und Kontur lesbar bleibt. */
.pc-0 { --pc-rgb: 154,166,187; }
.pc-1 { --pc-rgb: 46,230,255; }
.pc-2 { --pc-rgb: 169,134,255; }
.pc-3 { --pc-rgb: 255,154,61; }
.pc-4 { --pc-rgb: 224,92,208; }
.pc-5 { --pc-rgb: 106,160,255; }
.pc-6 { --pc-rgb: 255,140,220; }

html[data-theme="light"] .pc-0 { --pc-rgb: 64,76,97; }
html[data-theme="light"] .pc-1 { --pc-rgb: 0,109,131; }
html[data-theme="light"] .pc-2 { --pc-rgb: 105,67,181; }
html[data-theme="light"] .pc-3 { --pc-rgb: 165,75,0; }
html[data-theme="light"] .pc-4 { --pc-rgb: 163,44,139; }
html[data-theme="light"] .pc-5 { --pc-rgb: 30,84,190; }
html[data-theme="light"] .pc-6 { --pc-rgb: 160,40,110; }

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }

body {
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  padding-bottom: calc(78px + env(safe-area-inset-bottom));
}

/* Sehr dezentes Raster + Tiefenlicht, wie im Dashboard */
body::before {
  content: ''; position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background:
    radial-gradient(1100px 540px at 12% -8%, rgba(var(--accent-rgb), .07), transparent 60%),
    radial-gradient(900px 460px at 96% 0%, rgba(155,123,255,.07), transparent 60%),
    linear-gradient(rgba(120,170,255,.035) 1px, transparent 1px) 0 0 / 48px 48px,
    linear-gradient(90deg, rgba(120,170,255,.035) 1px, transparent 1px) 0 0 / 48px 48px,
    linear-gradient(180deg, var(--bg-2), var(--bg) 70%);
}
html[data-theme="light"] body::before {
  background:
    radial-gradient(1100px 540px at 12% -8%, rgba(0,109,131,.06), transparent 60%),
    radial-gradient(900px 460px at 96% 0%, rgba(105,67,181,.05), transparent 60%),
    linear-gradient(180deg, var(--bg-2), var(--bg) 70%);
}

button, input, select, textarea { font-family: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px;
  box-shadow: 0 0 0 5px rgba(var(--accent-rgb), .18);
}

/* Typografie: grosse fette Ueberschriften, Zahlen in Chakra Petch/Mono */
h1, h2, h3 { margin: 0; font-family: var(--display); font-weight: 600; letter-spacing: .01em; }
h1 { font-size: 30px; line-height: 1.1; }
h2 { font-size: 17px; margin: 26px 0 12px; }
h3 { font-size: 16px; }
.sub, .page-head .sub { color: var(--text-2); }
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.hidden { display: none !important; }

/* Kleines Grossbuchstaben-Label ueber Werten */
.eyebrow,
label.field > span {
  display: block;
  font-family: var(--display);
  font-size: 11.5px;
  font-weight: 500;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--text-3);
}

/* ------------------------------------------------------------ top (mobil) */

header.top {
  position: sticky; top: 0; z-index: 50;
  min-height: 58px;
  background: rgba(5,7,15,.86);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 8px 16px;
}
html[data-theme="light"] header.top { background: rgba(255,255,255,.9); }
header.top .brand {
  font-family: var(--display); font-weight: 600; font-size: 19px;
  letter-spacing: .02em; line-height: 1;
  display: flex; align-items: center; gap: 10px;
  min-width: 0;
}
header.top .brand .brand-mark svg { width: 26px; height: 26px; }
header.top .brand .brand-name { color: var(--text); }
header.top .brand .brand-sub {
  display: block; font-family: var(--font); font-weight: 500;
  font-size: 10.5px; letter-spacing: .09em; text-transform: uppercase;
  color: var(--text-3); margin-top: 3px;
}
header.top .brand .brand-text { display: flex; flex-direction: column; min-width: 0; }

/* Das Armarium-Zeichen: eine Farbe, keine Verlaeufe, keine Schatten. */
.brand-mark { color: var(--brand-ink); display: flex; flex: none; }
.brand-mark svg { width: 100%; height: 100%; display: block; }
.brand-mark use { color: inherit; }

/* Design-Umschalter (Kopfzeile + Seitenleiste) */
.theme-btn {
  display: inline-flex; align-items: center; gap: 7px;
  min-height: 38px; padding: 6px 13px;
  border: 1px solid var(--line); border-radius: var(--r-pill);
  background: var(--surface); color: var(--text-2);
  font-size: 13px; font-weight: 500;
  transition: border-color .2s, color .2s;
}
.theme-btn:hover { color: var(--text); border-color: var(--line-strong); }
.theme-btn .ti { width: 15px; height: 15px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; }

main {
  padding: 20px 16px 32px;
  max-width: 780px;
  margin: 0 auto;
}

/* ---------------------------------------------------------- nav (mobil) */

nav.bottom {
  position: fixed; bottom: 0; left: 0; right: 0;
  padding-bottom: env(safe-area-inset-bottom);
  background: rgba(6,9,18,.94);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid var(--line-strong);
  display: grid; grid-template-columns: repeat(4, 1fr);
  z-index: 60;
}
html[data-theme="light"] nav.bottom { background: rgba(255,255,255,.95); }
nav.bottom a {
  position: relative;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 4px; text-decoration: none; color: var(--text-3);
  font-size: 10.5px; letter-spacing: .02em;
  min-height: 58px; padding-top: 4px; border-radius: 10px;
}
nav.bottom a:hover { text-decoration: none; color: var(--text-2); }
nav.bottom a.active { color: var(--accent); }
nav.bottom a.active::before {
  content: ''; position: absolute; top: 0; width: 26px; height: 2px; border-radius: 2px;
  background: var(--accent); box-shadow: 0 0 10px var(--accent);
}
nav.bottom svg { width: 21px; height: 21px; fill: currentColor; }

/* ------------------------------------------------------ sidebar (desktop) */

aside.sidebar {
  position: fixed; top: 0; left: 0; bottom: 0; width: var(--sidebar-w);
  background: rgba(8,12,24,.92);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-right: 1px solid var(--line);
  display: flex; flex-direction: column;
  padding: 22px 14px 16px;
  z-index: 70;
}
html[data-theme="light"] aside.sidebar { background: rgba(255,255,255,.94); }
.side-brand { display: flex; align-items: center; gap: 11px; padding: 0 8px 22px; }
.side-brand .brand-mark svg { width: 27px; height: 27px; }
.side-brand .brand-text { display: flex; flex-direction: column; min-width: 0; }
.side-brand .brand-name {
  font-family: var(--display); font-weight: 600; font-size: 18px; letter-spacing: .02em;
  line-height: 1.1; color: var(--text);
}
.side-brand .brand-sub {
  font-size: 10px; letter-spacing: .1em; text-transform: uppercase;
  color: var(--text-3); margin-top: 3px; line-height: 1;
}

.side-nav { display: flex; flex-direction: column; gap: 3px; }
.side-nav a {
  display: flex; align-items: center; gap: 11px;
  padding: 10px 12px; border-radius: var(--r-pill);
  border: 1px solid transparent;
  text-decoration: none; color: var(--text-2);
  font-size: 14.5px; font-weight: 500;
  transition: background .2s, color .2s, border-color .2s;
}
.side-nav a:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.side-nav a.active {
  color: var(--accent); border-color: rgba(var(--accent-rgb), .35);
  background: rgba(var(--accent-rgb), .08);
  box-shadow: inset 0 0 18px rgba(var(--accent-rgb), .1);
}
.side-nav .ico { width: 18px; text-align: center; font-size: 14px; opacity: .9; }

.side-foot {
  margin-top: auto; padding: 14px 6px 0;
  border-top: 1px solid var(--line);
  display: flex; flex-direction: column; gap: 9px;
  font-size: 12.5px; color: var(--text-3);
}
.who { line-height: 1.35; display: flex; align-items: center; gap: 9px; }
.who .av-self {
  width: 32px; height: 32px; border-radius: 50%; flex: none;
  display: grid; place-items: center;
  font-family: var(--display); font-size: 13px; font-weight: 600;
  color: var(--accent); border: 1px solid rgba(var(--accent-rgb), .45);
  background: rgba(var(--accent-rgb), .1);
}
.who .nm { display: block; color: var(--text); font-weight: 500; font-size: 13px; }
.who .em { display: block; font-size: 11.5px; color: var(--text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
button.logout {
  display: flex; align-items: center; gap: 8px;
  width: 100%; min-height: 40px; padding: 8px 12px;
  background: transparent; border: 1px solid var(--line);
  color: var(--text-2); font-size: 13px; font-weight: 500;
  border-radius: var(--r-pill);
}
button.logout svg { width: 16px; height: 16px; fill: currentColor; flex: 0 0 auto; }
button.logout:hover { border-color: var(--st-cancel); color: var(--st-cancel); background: rgba(var(--st-cancel-rgb), .08); }

/* ------------- Avatare (Buchstabe im Kreis, Farbe je Person) ------------- */
.av {
  width: 26px; height: 26px; flex: none; border-radius: 50%;
  display: inline-grid; place-items: center;
  font-family: var(--display); font-weight: 600; font-size: 11.5px; line-height: 1;
  color: rgb(var(--pc-rgb));
  border: 1px solid rgba(var(--pc-rgb), .5);
  background: rgba(var(--pc-rgb), .12);
}
.av.md { width: 38px; height: 38px; font-size: 16px; }
.av.lg { width: 46px; height: 46px; font-size: 19px; border-radius: 13px; }
html[data-theme="light"] .av { background: rgba(var(--pc-rgb), .1); }

/* ---------------------------------------------------------------- forms */

label.field { display: block; margin-bottom: 16px; }
label.field > span { margin-bottom: 7px; }
label.field > small { display: block; color: var(--text-3); font-size: 12px; margin-top: 5px; }

input, select, textarea {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--text);
  font-size: 15px;
  padding: 11px 13px;
  border-radius: var(--r-sm);
  min-height: 44px;
  appearance: none;
}
textarea { min-height: 96px; resize: vertical; }
input::placeholder, textarea::placeholder { color: var(--text-3); }
input:hover, select:hover, textarea:hover { border-color: var(--line-strong); }
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(var(--accent-rgb), .18);
}
input:disabled, input[readonly] { background: var(--surface-2); color: var(--text-3); }
select {
  background-image: linear-gradient(45deg, transparent 50%, var(--text-2) 50%),
                    linear-gradient(135deg, var(--text-2) 50%, transparent 50%);
  background-position: calc(100% - 16px) 50%, calc(100% - 11px) 50%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-right: 32px;
}

/* Dateiauswahl im dunklen Thema: der native Knopf bleibt sonst hell */
input[type="file"] {
  padding: 8px 10px;
  font-size: 13.5px;
  color: var(--text-2);
  background: var(--bg-2);
}
input[type="file"]::file-selector-button {
  font: inherit; font-size: 13px; font-weight: 500;
  margin-right: 12px; padding: 7px 14px;
  color: var(--text); background: var(--surface-2);
  border: 1px solid var(--line-strong); border-radius: var(--r-pill);
  cursor: pointer;
}
input[type="file"]::file-selector-button:hover { border-color: var(--accent); color: var(--accent); }
input[type="date"] { color-scheme: inherit; }
input[type="date"]::-webkit-calendar-picker-indicator { filter: invert(1); opacity: .55; cursor: pointer; }
html[data-theme="light"] input[type="date"]::-webkit-calendar-picker-indicator { filter: none; opacity: .6; }

button, .btn {
  font-size: 14.5px; font-weight: 500;
  min-height: 44px; padding: 10px 20px;
  border-radius: var(--r-pill);
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--text);
  text-decoration: none;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  transition: border-color .2s, color .2s, background .2s, box-shadow .2s;
}
button:hover, .btn:hover { border-color: var(--text-3); text-decoration: none; }
button.primary, .btn.primary {
  background: var(--accent); border-color: var(--accent); color: var(--accent-ink);
  font-weight: 600;
  box-shadow: 0 0 22px -6px rgba(var(--accent-rgb), .55);
}
button.primary:hover, .btn.primary:hover { filter: brightness(1.08); text-decoration: none; }
button.primary:not(.wide) { width: auto; }
.btn.wide, button.wide { width: 100%; }
button.ghost { background: transparent; }
button.small { font-size: 13px; min-height: 34px; padding: 6px 13px; }
button.danger { color: var(--st-cancel); border-color: rgba(var(--st-cancel-rgb), .45); }
button:disabled { opacity: .45; cursor: default; }

.actions { display: grid; gap: 10px; margin-top: 22px; }
.actions.row { grid-auto-flow: column; grid-auto-columns: 1fr; }
.actions.inline { display: flex; gap: 9px; margin-top: 0; flex-wrap: wrap; }

.form-grid { display: grid; gap: 0 16px; }
@media (min-width: 640px) { .form-grid.two { grid-template-columns: 1fr 1fr; } }

/* ---------------------------------------------------------------- cards */

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 18px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
  scroll-margin-top: 74px;
}
.card-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 14px; flex-wrap: wrap; margin-bottom: 6px;
}
.card-head h2 { margin: 0; }
.card.tight { padding: 0; overflow: hidden; }

.page-head {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 16px; margin: 4px 0 22px; flex-wrap: wrap;
}
.page-head .sub { color: var(--text-2); font-size: 13.5px; margin: 7px 0 0; }

/* Kennzahlen: kleines Grossbuchstaben-Label ueber grossem Wert */
.stats { display: flex; gap: 26px; margin-top: 16px; flex-wrap: wrap; }
.stat { display: flex; flex-direction: column; gap: 1px; }
.stat .eyebrow { margin: 0; }
.stat .val { font-family: var(--display); font-size: 26px; font-weight: 600; line-height: 1.1; }
.stat .val.bad  { color: var(--st-cancel); }
.stat .val.warn { color: var(--st-change); }
.stat-btn {
  all: unset; display: flex; flex-direction: column; gap: 1px;
  cursor: pointer; border-radius: 8px; padding: 0 4px; margin: 0 -4px;
  transition: background .15s;
}
.stat-btn:hover { background: var(--surface-2); }
.stat-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.who-txt { min-width: 0; display: flex; flex-direction: column; }

/* ------------------------------------------------ Schrank: Faecher (mobil) */

.drawer { margin-bottom: 20px; }

/* Ablauf-Warnung im Schrank (ohne eigenen Menuepunkt) */
.expiry-banner h3 { margin: 0 0 4px; }
details.expiry-det { margin-top: 10px; border-top: 1px solid var(--line); padding-top: 8px; }
details.expiry-det summary {
  cursor: pointer; font-size: 13px; color: var(--text-2);
  list-style: none; padding: 4px 0;
}
details.expiry-det summary::-webkit-details-marker { display: none; }
details.expiry-det summary::before { content: '▸ '; color: var(--text-3); }
details.expiry-det[open] summary::before { content: '▾ '; }
details.expiry-det summary:hover { color: var(--text); }
details.expiry-det ul.list { border: 0; background: transparent; box-shadow: none; margin-top: 4px; }
details.expiry-det ul.list li { cursor: pointer; }
.drawer-head {
  display: flex; align-items: center; gap: 10px;
  padding: 0 2px 9px;
}
.drawer-head .nm {
  font-family: var(--display); font-size: 15px; font-weight: 600; letter-spacing: .01em;
}
.drawer-head .ct {
  font-family: var(--mono); font-size: 12px; color: var(--text-2);
  border: 1px solid var(--line); border-radius: var(--r-pill);
  padding: 0 8px; line-height: 20px;
}
.drawer-head::after { content: ''; flex: 1; height: 1px; background: var(--line); margin-left: 4px; }

ul.list { list-style: none; margin: 0; padding: 0; }
ul.list li {
  background: var(--surface);
  border: 1px solid var(--line);
  border-bottom-width: 0;
  padding: 14px 16px;
  display: flex; justify-content: space-between; align-items: flex-start;
  gap: 12px; cursor: pointer;
  transition: background .2s, border-color .2s;
}
ul.list li:hover { background: var(--surface-2); }
ul.list li:first-child { border-radius: var(--r) var(--r) 0 0; }
ul.list li:last-child { border-bottom-width: 1px; border-radius: 0 0 var(--r) var(--r); }
ul.list li:only-child { border-radius: var(--r); }
ul.list .main { flex: 1; min-width: 0; }
ul.list .name { font-size: 15.5px; font-weight: 500; word-break: break-word; }
ul.list .meta { font-size: 12.5px; color: var(--text-2); margin-top: 3px; }

/* Personenfarbe an der Karte: feine farbige Kontur links */
ul.list li.pc-mark { border-left: 2px solid rgb(var(--pc-rgb)); }
ul.list li .lst-person { display: flex; align-items: center; gap: 7px; font-size: 12.5px; color: var(--text-2); }

/* Fach mit Personenfarbe: farbige Kante + farbiger Rahmen */
.drawer-person ul.list { border-radius: var(--r); overflow: hidden; border-left: 2px solid rgb(var(--pc-rgb)); }
.drawer-person ul.list li:first-child { border-radius: 0; }
.drawer-person ul.list li:last-child { border-radius: 0; }

/* pillen / Zustand */

.tag {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 12px; font-weight: 600;
  padding: 2px 9px; border-radius: var(--r-pill); white-space: nowrap;
  border: 1px solid var(--line);
  background: var(--surface-2); color: var(--text-2);
}
.tag.warn { color: var(--st-change); border-color: rgba(var(--st-change-rgb), .42); background: rgba(var(--st-change-rgb), .09); }
.tag.bad  { color: var(--st-cancel); border-color: rgba(var(--st-cancel-rgb), .45); background: rgba(var(--st-cancel-rgb), .09); }
.tag.ok   { color: var(--st-ok);     border-color: rgba(var(--st-ok-rgb), .4);     background: rgba(var(--st-ok-rgb), .09); }
.tag.verified { color: var(--accent); border-color: rgba(var(--accent-rgb), .4); background: rgba(var(--accent-rgb), .09); }
.tag.neutral { color: var(--text-3); }
.tag.ok::before   { content: "✓"; font-weight: 700; }
.tag.warn::before { content: "!"; font-weight: 700; }
.tag.bad::before  { content: "×"; font-weight: 700; }

/* Personenauswahl (Chips) */
.personbar {
  display: flex; gap: 8px; align-items: center; flex-wrap: wrap;
  margin: 0 0 18px;
}
.chip {
  display: inline-flex; align-items: center; gap: 7px;
  min-height: 38px; padding: 5px 13px 5px 6px;
  border: 1px solid var(--line); border-radius: var(--r-pill);
  background: var(--surface); color: var(--text-2);
  font-size: 13.5px; font-weight: 500; text-decoration: none;
  transition: border-color .2s, color .2s, background .2s, box-shadow .2s;
}
.chip:hover { border-color: var(--line-strong); color: var(--text); text-decoration: none; }
.chip.on {
  color: rgb(var(--pc-rgb));
  border-color: rgba(var(--pc-rgb), .6);
  background: rgba(var(--pc-rgb), .12);
  box-shadow: inset 0 0 16px rgba(var(--pc-rgb), .1);
}
.chip .n {
  font-family: var(--mono); font-size: 11.5px; opacity: .85;
  border-left: 1px solid var(--line); padding-left: 7px; margin-left: 1px;
}
.chip.plain { padding-left: 13px; }

/* ------------------------------------------------------------- Tabelle */

.table-wrap {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r);
  overflow: hidden;
  box-shadow: var(--shadow);
}
.toolbar {
  display: flex; gap: 10px; align-items: center; flex-wrap: wrap;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  background: transparent;
}
.toolbar input, .toolbar select { min-height: 38px; padding: 7px 32px 7px 12px; font-size: 13.5px; width: auto; flex: 0 0 auto; }
.toolbar input[type="search"] {
  background-image: none; padding-right: 12px;
  flex: 1 1 200px; max-width: 320px;
  background: var(--bg-2);
}
.toolbar select { background-color: var(--bg-2); }
.toolbar .grow { flex: 1 1 auto; }
.toolbar .count { font-family: var(--mono); font-size: 12.5px; color: var(--text-2); white-space: nowrap; }

.toolbar-person {
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
}
.toolbar-person .personbar { margin: 0; }
.toolbar-person .chip { background: var(--bg-2); }

.table-scroll { overflow-x: auto; }
table.grid { width: 100%; border-collapse: collapse; font-size: 13.5px; table-layout: fixed; }
table.grid th, table.grid td { overflow: hidden; }
table.grid th {
  text-align: left; font-family: var(--display); font-weight: 500;
  font-size: 11px; letter-spacing: .12em; text-transform: uppercase;
  color: var(--text-3);
  padding: 12px 8px; border-bottom: 1px solid var(--line);
  white-space: nowrap; user-select: none; line-height: 1.25;
}
table.grid th.sortable { cursor: pointer; }
table.grid th.sortable:hover { color: var(--text); }
table.grid th .arrow { opacity: .4; margin-left: 4px; font-size: 9px; }
table.grid th.sorted { color: var(--text); }
table.grid th.sorted .arrow { opacity: 1; color: var(--accent); }
table.grid td { padding: 7px 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.grid tbody tr:hover { background: var(--surface-2); }
table.grid tbody tr:last-child td { border-bottom: 0; }
table.grid td.nowrap { white-space: nowrap; }
table.grid td.muted { color: var(--text-2); }
table.grid .pzn { font-family: var(--mono); font-size: 12.5px; }
td.person-cell { display: flex; align-items: center; gap: 7px; }

.cell-input {
  width: 100%; min-height: 32px; padding: 5px 7px;
  font-size: 13px; border: 1px solid transparent; background: transparent;
  border-radius: 6px;
}
table.grid input, table.grid select { min-width: 0; max-width: 100%; }
th, td { max-width: 380px; }
td select.cell-input { width: 100%; background-image: none; padding-right: 6px; }
/* Platzhalter in der Tabelle nicht dauerhaft anzeigen — erst beim Bearbeiten */
table.grid .cell-input::placeholder { color: transparent; }
table.grid .cell-input:focus::placeholder,
table.grid .cell-input:hover::placeholder { color: var(--text-3); }
.cell-input:hover { border-color: var(--line); background: var(--surface); }
.cell-input:focus { border-color: var(--accent); background: var(--surface); box-shadow: 0 0 0 2px rgba(var(--accent-rgb), .2); }
tr.saving { opacity: .6; }
tr.saved td { animation: flash 1.2s ease; }
@keyframes flash { from { background: rgba(var(--accent-rgb), .16); } to { background: transparent; } }

/* --------------------------------------------------------------- misc */

.empty {
  text-align: center; color: var(--text-2); font-size: 14.5px;
  padding: 48px 16px;
}

.note {
  border-left: 2px solid rgba(var(--accent-rgb), .7);
  padding: 6px 0 6px 14px;
  font-size: 12.5px; color: var(--text-3);
  margin: 18px 0;
}
.note strong { color: var(--text-2); }

.answer {
  white-space: pre-wrap; font-size: 15px; line-height: 1.65;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r); padding: 18px; margin-top: 16px;
}

.spinner {
  display: inline-block; width: 15px; height: 15px;
  border: 2px solid var(--line-strong); border-top-color: var(--accent);
  border-radius: 50%; animation: spin .8s linear infinite;
  vertical-align: -3px; margin-right: 8px;
}
@keyframes spin { to { transform: rotate(360deg); } }

.err   { color: var(--st-cancel); font-size: 14px; margin: 10px 0; }
.okmsg { color: var(--st-ok);     font-size: 14px; margin: 10px 0; }

.photo {
  width: 100%; max-height: 240px; object-fit: contain;
  background: var(--bg-2); border: 1px solid var(--line);
  border-radius: var(--r); margin-bottom: 16px;
}

.ocr {
  font-family: var(--mono); font-size: 12px; color: var(--text-2);
  max-height: 140px; overflow: auto;
  border: 1px dashed var(--line-strong); border-radius: var(--r-sm);
  padding: 10px; margin-bottom: 16px; white-space: pre-wrap;
}

.verified-box {
  border: 1px solid rgba(var(--accent-rgb), .45);
  background: rgba(var(--accent-rgb), .07);
  border-radius: var(--r);
  padding: 14px 16px;
  margin-bottom: 16px;
  font-size: 14px;
}
.verified-box .hd { font-weight: 600; color: var(--accent); margin-bottom: 6px; }
.verified-box dl { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: 3px 12px; }
.verified-box dt { color: var(--text-2); font-size: 12px; }
.verified-box dd { margin: 0; }
.verified-box .stamp { font-size: 11.5px; color: var(--text-3); margin-top: 8px; }

.kv { display: grid; grid-template-columns: 160px 1fr; gap: 7px 16px; font-size: 14.5px; }
.kv dt { color: var(--text-3); font-size: 12.5px; }
.kv dd { margin: 0; }

.seg {
  display: inline-flex; padding: 4px; gap: 2px;
  border: 1px solid var(--line); border-radius: var(--r-pill);
  background: var(--bg-2);
}
.seg button {
  border: 0; background: transparent; padding: 6px 14px; min-height: 34px;
  border-radius: var(--r-pill); font-size: 13px; color: var(--text-2);
}
.seg button:hover { color: var(--text); background: rgba(var(--accent-rgb), .06); }
.seg button.on { background: var(--accent); color: var(--accent-ink); box-shadow: 0 0 18px rgba(var(--accent-rgb), .35); }

/* --------------------------------------------------------------- dialog */

.dlg {
  border: 1px solid var(--line-strong);
  border-radius: var(--r);
  background: var(--surface); color: var(--text);
  padding: 0; width: min(680px, calc(100vw - 32px));
  max-height: calc(100vh - 64px);
  box-shadow: 0 30px 70px -30px rgba(0,0,0,.75);
}
.dlg::backdrop { background: rgba(2,4,10,.62); backdrop-filter: blur(3px); }
.dlg-inner { display: flex; flex-direction: column; max-height: calc(100vh - 64px); }
.dlg-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 16px 20px; border-bottom: 1px solid var(--line);
}
.dlg-head h2 { margin: 0; font-size: 17px; }
.dlg-body { padding: 20px; overflow: auto; }
.dlg-foot {
  display: flex; justify-content: flex-end; gap: 10px;
  padding: 14px 20px; border-top: 1px solid var(--line);
  background: var(--bg-2);
}

@media (min-width: 1000px) {
  .dlg { margin-right: 0; margin-left: auto; height: 100vh; max-height: 100vh; border-radius: 0 0 0 var(--r); border-right: 0; }
  .dlg-inner { height: 100vh; max-height: 100vh; }
}

/* ---------------------------------------------------------------- login */

.login-wrap {
  min-height: 100dvh; display: flex; flex-direction: column; justify-content: center;
  padding: 32px 20px; max-width: 400px; margin: 0 auto;
}
.login-brand { margin-bottom: 6px; }
.login-brand .brand-mark { width: 56px; height: 56px; margin-bottom: 18px; }
.login-brand h1 {
  font-size: 34px; letter-spacing: .01em; margin: 0 0 6px; color: var(--text);
}
.login-brand .login-sub {
  margin: 0; font-size: 11.5px; letter-spacing: .18em; text-transform: uppercase;
  color: var(--text-3); font-weight: 500;
}
.login-wrap .sub { color: var(--text-2); font-size: 13.5px; margin: 22px 0 26px; }

/* =========================================================== DESKTOP ==== */

@media (min-width: 900px) {
  body { padding-bottom: 0; padding-left: var(--sidebar-w); }
  header.top, nav.bottom, .mob-only { display: none !important; }
  aside.sidebar.hidden { display: flex !important; }
  body.on-login { padding-left: 0; }
  body.on-login aside.sidebar { display: none !important; }

  main { padding: 34px 40px 64px; max-width: 1440px; margin: 0; }
  main.wide { max-width: none; }
  h1 { font-size: 32px; }
  .page-head { margin-bottom: 26px; }
  .desk-only { display: initial; }
  .personbar { margin-bottom: 4px; }
}

@media (max-width: 899px) {
  aside.sidebar { display: none !important; }
  .desk-only { display: none !important; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ------------------------------------------------------------ scan/form */
/* Provenienz und Konfidenz je Feld: ruhige Marke rechts im Label, Farbe nur
   als Rand. Was unsicher ist, hat zusaetzlich einen Bernstein-Rand links. */

label.field > span {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
}
label.field .src {
  font-family: var(--mono); font-size: 10.5px; font-weight: 500;
  letter-spacing: .04em; text-transform: uppercase;
  padding: 2px 7px; border-radius: var(--r-pill);
  border: 1px solid transparent; white-space: nowrap;
}
label.field .src.sicher { color: var(--st-ok); border-color: rgba(var(--st-ok-rgb), .4); background: rgba(var(--st-ok-rgb), .08); }
label.field .src.pruefen { color: var(--st-change); border-color: rgba(var(--st-change-rgb), .45); background: rgba(var(--st-change-rgb), .1); }
label.field .src.none { color: var(--text-3); border-color: var(--line); background: transparent; }

label.field.needs-check input,
label.field.needs-check textarea {
  border-color: rgba(var(--st-change-rgb), .55);
  background: rgba(var(--st-change-rgb), .05);
}
label.field.needs-check input:focus,
label.field.needs-check textarea:focus {
  border-color: var(--st-change);
  box-shadow: 0 0 0 3px rgba(var(--st-change-rgb), .18);
}
label.field.filled-sicher input { border-color: rgba(var(--st-ok-rgb), .35); }

.form-h {
  font-family: var(--display); font-size: 13px; font-weight: 600;
  letter-spacing: .12em; text-transform: uppercase;
  color: var(--text-3); margin: 4px 0 14px;
}
.form-h + .form-grid { margin-bottom: 10px; }
#medForm .form-grid.two + .form-h { margin-top: 22px; }

.scan-card .note, .note {
  font-size: 12.5px; color: var(--text-3); line-height: 1.5; margin: 0;
}
.scan-card .form-grid.two { gap: 0 16px; }
.scan-card label.field { margin-bottom: 8px; }

.card.tightpad { padding: 14px 16px; margin-bottom: 16px; }

.scan-strip {
  display: flex; gap: 10px; flex-wrap: wrap; margin-top: 14px;
}
.scan-strip:empty { display: none; }
.scan-thumb { margin: 0; position: relative; }
.scan-thumb img {
  display: block; width: 84px; height: 108px; object-fit: cover;
  border-radius: var(--r-sm); border: 1px solid var(--line);
  background: var(--surface-2);
}
.scan-thumb figcaption {
  font-family: var(--mono); font-size: 10px; letter-spacing: .04em;
  text-transform: uppercase; color: var(--text-3); margin-top: 4px; text-align: center;
}

label.field .alt-hint {
  display: block; font-size: 11.5px; color: var(--st-change);
  margin-top: 4px; line-height: 1.3;
}
label.field .alt-hint[hidden] { display: none; }

.note.subtle {
  font-size: 11.5px; color: var(--text-3); margin-top: 10px; letter-spacing: .01em;
}

.ocr-det { margin-top: 12px; }
.ocr-det summary {
  cursor: pointer; font-size: 12.5px; color: var(--text-3);
  padding: 6px 0;
}
.ocr-det summary:hover { color: var(--text-2); }
.ocr-det .ocr { margin-top: 8px; }

@media (max-width: 640px) {
  .scan-thumb img { width: 68px; height: 88px; }
}

/* ------------------------------------------------------------ beipackzettel */

.leaflet-box { margin-top: 0; }
.leaflet-box + .card { margin-top: 16px; }
.leaflet-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; flex-wrap: wrap; margin-bottom: 12px;
}
.leaflet-head .pdf-link {
  font-size: 12.5px; text-decoration: none; display: inline-flex;
  align-items: center; gap: 6px; padding: 6px 12px; border-radius: var(--r-pill);
  border: 1px solid var(--line); color: var(--text-2);
}
.leaflet-head .pdf-link:hover { border-color: var(--text-3); color: var(--text); }
.leaflet-kv dt:first-of-type { padding-top: 0; }
