*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --accent:       #4a6d8c;
  --accent-dark:  #375270;
  --accent-hover: #375270;
  --accent-light: #e8eef4;
  --sidebar-w:    300px;
  --header-h:     56px;
  --gray-50:      #faf7f2;
  --gray-100:     #f3f1ea;
  --gray-200:     #ddd5c7;
  --gray-400:     #9a9284;
  --gray-600:     #66605a;
  --gray-800:     #2b2622;
  --white:        #ffffff;
  --radius:       8px;
  --shadow:       0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.05);
  --error:        #b3261e;
  --success:      #15803d;
  --badge-green-bg:  #dcfce7; --badge-green-ink:  #15803d;
  --badge-yellow-bg: #fef9c3; --badge-yellow-ink: #a16207;
  --badge-blue-bg:   #dbeafe; --badge-blue-ink:   #1d4ed8;
  --icon-blue-bg:   #dbeafe; --icon-blue-ink:   #1d4ed8;
  --icon-green-bg:  #dcfce7; --icon-green-ink:  #15803d;
  --icon-purple-bg: #ede9fe; --icon-purple-ink: #7c3aed;
  --icon-orange-bg: #ffedd5; --icon-orange-ink: #c2410c;
  --icon-teal-bg:   #ccfbf1; --icon-teal-ink:   #0d9488;
  --icon-indigo-bg: #e0e7ff; --icon-indigo-ink: #4338ca;
  --icon-pink-bg:   #fce7f3; --icon-pink-ink:   #be185d;
  --icon-cyan-bg:   #cffafe; --icon-cyan-ink:   #0e7490;
  --payment-green:  #15803d;
  --payment-blue:   #1d4ed8;
  --payment-yellow: #a16207;
}

/* Dunkles Farbschema - Auswahl unter Einstellungen (settings.theme), global
   für den ganzen Betrieb (keine Pro-Mitarbeiter-Einstellung). "system" lässt
   data-theme ganz weg, dann greift nur die OS-Einstellung des Geräts über
   prefers-color-scheme. Belegpapier (.receipt-paper und Inhalt) ist davon
   bewusst ausgenommen - echtes Bondruckerpapier bleibt immer hell, dafür
   feste Farbwerte statt der Tokens hier drunter (siehe dort). */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    /* --accent bleibt unverändert - dient auch als Button-Hintergrund mit
       weisser Schrift (Primary-Button, Karten-Header), ein aufgehelltes Blau
       würde dort den Kontrast brechen. Nur die reinen Text-/Hover-Rollen
       werden pro Theme angepasst. */
    --accent-dark:  #a8c8e0;
    --accent-hover: #2f4d68;
    --accent-light: #24384a;
    --gray-50:      #1b1916;
    --gray-100:     #242220;
    --gray-200:     #3a3632;
    --gray-400:     #948c7f;
    --gray-600:     #c9c2b4;
    --gray-800:     #f1ede4;
    --white:        #252220;
    --shadow:       0 1px 3px rgba(0,0,0,.35), 0 1px 2px rgba(0,0,0,.25);
    --error:        #ff6b6b;
    --success:      #4ade80;
    --badge-green-bg:  #16321f; --badge-green-ink:  #6ee7a0;
    --badge-yellow-bg: #392c0d; --badge-yellow-ink: #f2c94c;
    --badge-blue-bg:   #14284a; --badge-blue-ink:   #7dabf8;
    --icon-blue-bg:   #14284a; --icon-blue-ink:   #7dabf8;
    --icon-green-bg:  #16321f; --icon-green-ink:  #6ee7a0;
    --icon-purple-bg: #2c2249; --icon-purple-ink: #b6a3f5;
    --icon-orange-bg: #3a2210; --icon-orange-ink: #ffab66;
    --icon-teal-bg:   #0f332f; --icon-teal-ink:   #5eead4;
    --icon-indigo-bg: #232355; --icon-indigo-ink: #a5b4fc;
    --icon-pink-bg:   #3a1730; --icon-pink-ink:   #f0a8cf;
    --icon-cyan-bg:   #123a42; --icon-cyan-ink:   #67e8f9;
    --payment-green:  #4ade80;
    --payment-blue:   #7dabf8;
    --payment-yellow: #f2c94c;
  }
}

:root[data-theme="dark"] {
  --accent-dark:  #a8c8e0;
  --accent-hover: #2f4d68;
  --accent-light: #24384a;
  --gray-50:      #1b1916;
  --gray-100:     #242220;
  --gray-200:     #3a3632;
  --gray-400:     #948c7f;
  --gray-600:     #c9c2b4;
  --gray-800:     #f1ede4;
  --white:        #252220;
  --shadow:       0 1px 3px rgba(0,0,0,.35), 0 1px 2px rgba(0,0,0,.25);
  --error:        #ff6b6b;
  --success:      #4ade80;
  --badge-green-bg:  #16321f; --badge-green-ink:  #6ee7a0;
  --badge-yellow-bg: #392c0d; --badge-yellow-ink: #f2c94c;
  --badge-blue-bg:   #14284a; --badge-blue-ink:   #7dabf8;
  --icon-blue-bg:   #14284a; --icon-blue-ink:   #7dabf8;
  --icon-green-bg:  #16321f; --icon-green-ink:  #6ee7a0;
  --icon-purple-bg: #2c2249; --icon-purple-ink: #b6a3f5;
  --icon-orange-bg: #3a2210; --icon-orange-ink: #ffab66;
  --icon-teal-bg:   #0f332f; --icon-teal-ink:   #5eead4;
  --icon-indigo-bg: #232355; --icon-indigo-ink: #a5b4fc;
  --icon-pink-bg:   #3a1730; --icon-pink-ink:   #f0a8cf;
  --icon-cyan-bg:   #123a42; --icon-cyan-ink:   #67e8f9;
  --payment-green:  #4ade80;
  --payment-blue:   #7dabf8;
  --payment-yellow: #f2c94c;
}

* { box-sizing: border-box; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 14px;
  color: var(--gray-800);
  background: var(--gray-50);
  margin: 0;
}

a { color: var(--accent-dark); }

h1 { font-size: 1.3rem; font-weight: 700; }
h2 { font-size: 1rem; font-weight: 600; margin: 1.5rem 0 0.6rem; }

.error { color: var(--error); font-weight: 600; margin-bottom: 1rem; }
.success { color: var(--success); font-weight: 600; margin-bottom: 1rem; }

/* ── App shell (sidebar + main) ── */
.app-shell {
  display: flex;
  height: 100vh;
  height: 100dvh; /* echte sichtbare Höhe auf iPad/Safari (100vh zählt die von der
                     Adressleiste verdeckte Fläche mit, dadurch wirkte die Seite
                     dort zu hoch / erzwang unerwünschtes Scrollen) */
  overflow: hidden;
  /* Zusammen mit "viewport-fit=cover" (siehe partials/head.ejs) rendert iOS
     jetzt bis unter Notch/Status-/Home-Leiste - ohne diesen Puffer könnte
     Inhalt (Sidebar/Header) davon verdeckt werden. env(...) ist 0, wo es
     nicht gebraucht wird (z.B. Desktop), also unschädlich. */
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

aside.sidebar {
  width: var(--sidebar-w);
  background: var(--white);
  border-right: 1px solid var(--gray-200);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

.brand {
  min-height: var(--header-h);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 28px 18px;
  border-bottom: 1px solid var(--gray-200);
}

.brand-logo {
  max-width: 100%;
  max-height: 128px;
  height: auto;
  width: auto;
  display: block;
}

nav.sidebar-nav { padding: 12px 10px; flex: 1; }

.nav-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--gray-400);
  padding: 8px 8px 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 12px;
  border-radius: var(--radius);
  color: var(--gray-600);
  font-weight: 500;
  font-size: 15px;
  text-decoration: none;
  transition: background .15s, color .15s;
}

.nav-item:hover { background: var(--gray-100); color: var(--gray-800); }
.nav-item.active { background: var(--accent-light); color: var(--accent-dark); }
.nav-item svg { width: 18px; height: 18px; flex-shrink: 0; }

.nav-item.disabled {
  color: var(--gray-400);
  cursor: default;
}
.nav-item.disabled:hover { background: none; color: var(--gray-400); }

.nav-divider { height: 1px; background: var(--gray-200); margin: 8px 8px; }

.soon-badge {
  margin-left: auto;
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .03em;
  background: var(--gray-100);
  color: var(--gray-400);
  padding: 2px 6px;
  border-radius: 10px;
}

.sidebar-footer {
  padding: 14px 18px;
  border-top: 1px solid var(--gray-200);
  display: flex;
  align-items: center;
  gap: 10px;
}

.avatar {
  width: 30px; height: 30px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700;
  flex-shrink: 0;
}

.user-info { flex: 1; min-width: 0; }
.user-name { font-weight: 600; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { font-size: 11px; color: var(--gray-400); }

.logout-form { margin-top: 8px; }
.inline-form { display: inline; }
.logout-btn {
  background: none;
  border: none;
  color: var(--gray-400);
  font-size: 12px;
  cursor: pointer;
  padding: 0;
  text-decoration: underline;
}
.logout-btn:hover { color: var(--accent-dark); }

main.app-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
}

header.app-header {
  height: var(--header-h);
  background: var(--white);
  border-bottom: 1px solid var(--gray-200);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  flex-shrink: 0;
  gap: 12px;
}

.page-title { font-size: 18px; font-weight: 600; }

.breadcrumb { display: flex; align-items: center; gap: 8px; font-size: 16px; }
.breadcrumb a { color: var(--accent-dark); text-decoration: none; font-weight: 500; }
.breadcrumb a:hover { text-decoration: underline; }
.breadcrumb-sep { color: var(--gray-400); }
.breadcrumb-current { color: var(--gray-600); font-weight: 500; }

.header-actions { display: flex; align-items: center; gap: 10px; }

.app-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  padding: 24px;
}

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  text-decoration: none;
  transition: background .15s;
  font-family: inherit;
}

.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); }

.btn-outline {
  background: var(--white);
  color: var(--gray-600);
  border: 1px solid var(--gray-200);
}
.btn-outline:hover { background: var(--gray-100); }

.btn:disabled {
  opacity: .45;
  cursor: not-allowed;
}
.btn:disabled:hover { background: var(--white); }

.form-row {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
}
.form-row label { flex: 1 1 200px; }

/* ── Login card (no sidebar) ── */
.centered {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--gray-50);
}

.card {
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: 12px;
  padding: 2rem;
  width: min(90vw, 360px);
}

.card h1 { text-align: center; margin-bottom: 1.5rem; }

/* Fehlerseite (views/error.ejs) - gleiche Karte wie der Login */
.error-page p { text-align: center; line-height: 1.5; }
.error-actions { display: flex; gap: 10px; justify-content: center; margin-top: 1.25rem; }
.error-ref { font-size: 12px; color: var(--gray-600); margin-top: 1rem; }

.login-brand { display: block; height: 32px; width: auto; margin: 0 auto 1.25rem; border-radius: 8px; }

form label {
  display: block;
  margin-bottom: 1rem;
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--gray-600);
}

input, select, button { font-size: 1rem; font-family: inherit; }

input[type="text"],
input[type="password"],
input[type="date"],
input[type="number"],
select {
  width: 100%;
  padding: 0.55rem 0.65rem;
  margin-top: 0.3rem;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  background: var(--white);
  color: var(--gray-800);
}

.card button[type="submit"] {
  width: 100%;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  padding: 0.65rem 1rem;
  cursor: pointer;
  font-weight: 600;
}
.card button[type="submit"]:hover { background: var(--accent-hover); }

/* ── Toolbar / filters ── */
.toolbar {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 16px;
  flex-shrink: 0;
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 14px;
}

.toolbar-period-row {
  padding-bottom: 12px;
  border-bottom: 1px solid var(--gray-200);
}

.toolbar-fields {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

.toolbar label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 0;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--gray-400);
  flex: 1 1 160px;
}

.toolbar input, .toolbar select {
  margin-top: 0;
  display: block;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  min-height: 34px;
  padding: 7px 10px;
  font-size: 13px;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  background: var(--white);
  color: var(--gray-800);
  box-sizing: border-box;
  /* Das umgebende <label> steht in Grossbuchstaben (siehe .toolbar label) -
     ohne diesen Reset erben Feldinhalt/Optionen das mit. */
  text-transform: none;
}

.toolbar input[type="date"] {
  -webkit-appearance: none;
  appearance: none;
  height: 34px;
  min-height: 34px;
}

.toolbar label:has(input[type="date"]) {
  flex: 0 0 150px;
}

.toolbar-actions {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 0 0 auto;
}

.toolbar-actions-spacer {
  font-size: 11px;
  line-height: 1;
  visibility: hidden;
}

.toolbar-actions-row {
  display: flex;
  align-items: center;
  min-height: 34px;
  gap: 10px;
}

.toolbar-actions a { font-size: 13px; color: var(--gray-600); }

/* ── Table card ── */
.table-card {
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.table-scroll {
  flex: 1;
  min-height: 0;
  overflow: auto;
}

table { width: 100%; border-collapse: collapse; }

thead { background: var(--gray-50); }

th {
  padding: 11px 16px;
  text-align: left;
  font-size: 13px;
  font-weight: 600;
  color: var(--gray-600);
  background: var(--gray-50);
  border-bottom: 1px solid var(--gray-200);
  white-space: nowrap;
  position: sticky;
  top: 0;
  z-index: 1;
}

.th-sort {
  color: inherit;
  text-decoration: none;
  cursor: pointer;
}
.th-sort:hover { color: var(--accent-dark); }

td {
  padding: 7px 16px;
  border-bottom: 1px solid var(--gray-100);
  font-size: 14px;
  vertical-align: middle;
  white-space: nowrap;
}

tr:last-child td { border-bottom: none; }
tbody tr:nth-child(even) td { background: var(--gray-50); }
tbody tr:hover td { background: var(--accent-light); }
tbody tr.row-link { cursor: pointer; }
tbody tr.row-highlighted td { background: var(--accent-light); }
tbody tr.row-highlighted td:first-child { box-shadow: inset 3px 0 0 var(--accent); }

.amount { text-align: right; font-variant-numeric: tabular-nums; font-weight: 500; }
th.amount { text-align: right; }

.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 9px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}

.badge-green  { background: var(--badge-green-bg); color: var(--badge-green-ink); }
.badge-yellow { background: var(--badge-yellow-bg); color: var(--badge-yellow-ink); }
.badge-blue   { background: var(--badge-blue-bg); color: var(--badge-blue-ink); }
.badge-gray   { background: var(--gray-100); color: var(--gray-600); }

/* Gelöschte Behandlungen (nur markiert): grau + durchgestrichen, zählen in
   keiner Summe. Badges sind inline-flex und werden deshalb nicht mit
   durchgestrichen. */
.row-deleted td { color: var(--gray-600); }
.row-deleted td:not(:last-child) { text-decoration: line-through; }
.badge-deleted { background: transparent; color: var(--error); border: 1px solid var(--error); }
.muted { color: var(--gray-600); }
.receipt-deleted-banner {
  max-width: 320px;
  margin: 0 auto 12px;
  padding: 8px 12px;
  border: 2px solid var(--error);
  border-radius: 6px;
  color: var(--error);
  font-weight: 700;
  text-align: center;
}

/* Belegversionierung: Versionsliste, Hinweis im Formular, Änderungsprotokoll */
.receipt-versions { max-width: 320px; margin: 0 auto 12px; font-size: 13px; text-align: center; color: var(--gray-600); }
.receipt-history { max-width: 720px; margin: 20px auto; font-size: 13px; }
.receipt-history summary { cursor: pointer; font-weight: 600; }
.receipt-history table { width: 100%; margin-top: 8px; border-collapse: collapse; }
.receipt-history th, .receipt-history td { padding: 4px 6px; text-align: left; vertical-align: top; border-bottom: 1px solid var(--gray-100); }
.notice { padding: 10px 12px; margin-bottom: 1rem; border: 1px solid var(--gray-400); border-radius: 6px; color: var(--gray-600); font-size: 14px; }

/* Kundenverwaltung: Dublette/ähnlicher Kunde beim Umbenennen */
.conflict-panel { border: 2px solid var(--accent); color: var(--gray-800, inherit); max-width: 900px; }
.conflict-panel p { margin: 0 0 8px; }
.conflict-actions { display: flex; flex-wrap: wrap; gap: 8px; }

/* Kundenverwaltung: Vorschlagsliste darf breiter als das Namensfeld sein (Nr., Behandlungen) */
#customer-form .autocomplete-list { right: auto; min-width: 100%; width: max-content; max-width: 460px; }

/* Kunde umbenennen (Admin, Behandlungsmaske) */
.client-rename { margin-top: 8px; }
/* .btn setzt display und würde das hidden-Attribut sonst überstimmen */
.client-rename [hidden] { display: none; }
.client-rename-panel { margin-top: 8px; padding: 10px 12px; border: 2px solid var(--accent); border-radius: 6px; }
.client-rename-panel .notice { margin-bottom: 8px; padding: 0; border: none; }
.client-rename-fields { display: flex; gap: 8px; }
.client-rename-fields input { flex: 1; min-width: 0; }
/* Die Vorschlagsliste schiebt die Knöpfe nach unten, statt "Speichern" zu überdecken */
.client-rename-fields { align-items: flex-start; }
.client-rename-fields .autocomplete-wrap { flex: 1; min-width: 0; }
.client-rename-fields .autocomplete-wrap input { width: 100%; }
.client-rename-fields .autocomplete-list { position: static; box-shadow: none; max-height: 160px; }
.client-rename .btn-small { padding: 6px 12px; font-size: 14px; }
.client-rename-actions { display: flex; gap: 8px; margin-top: 8px; }
.client-rename .success, .client-rename .error { margin: 6px 0 0; font-size: 14px; }
.meta-firstname-input[readonly] { color: var(--gray-600); }

/* Rückfrage bei ähnlichem Kundennamen (Behandlungsmaske) */
.near-match-dialog { max-width: 420px; padding: 20px; border: 1px solid var(--accent); border-radius: var(--radius); }
.near-match-dialog::backdrop { background: rgba(0, 0, 0, .35); }
.near-match-dialog p { margin: 0 0 10px; }
.near-match-choices, .near-match-actions { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }

/* Monatsabschluss (Banana-Export-Seite) */
.month-close-panel { display: flex; flex-direction: column; gap: 8px; }
.month-close-panel form { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.month-close-panel input[type="text"] { min-width: 260px; }
.month-close-log { font-size: 13px; color: var(--gray-600); margin: 0; padding-left: 18px; }

.action-btn {
  background: none;
  border: none;
  color: var(--gray-400);
  cursor: pointer;
  padding: 5px;
  margin: 0 2px;
  border-radius: 6px;
  transition: color .15s, background .15s;
  line-height: 0;
  text-decoration: none;
  display: inline-flex;
}
.action-btn:hover { color: var(--accent-dark); background: var(--accent-light); }
.action-btn svg { width: 17px; height: 17px; }

.table-footer {
  flex-shrink: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  border-top: 1px solid var(--gray-200);
  background: var(--gray-50);
  font-size: 12px;
  color: var(--gray-400);
}

.table-footer .amount {
  font-weight: 600;
  color: var(--gray-600);
}

.empty-state {
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 2rem;
  text-align: center;
  color: var(--gray-600);
}

/* ── Detail card (treatment form) ── */
.detail-card {
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  max-width: 720px;
  overflow: hidden;
}

/* Einstellungen-Seite: mehrere Karten nutzen die Bildschirmbreite über ein
   Grid statt starr untereinander zu stehen. auto-fit/minmax bricht auf
   schmalen Bildschirmen von selbst auf eine Spalte um. align-items:start
   verhindert, dass eine kurze Karte auf die Höhe einer langen Nachbarkarte
   in derselben Reihe gestreckt wird. */
.settings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(360px, 1fr));
  gap: 20px;
  align-items: start;
}
.settings-grid .detail-card { max-width: none; }
.settings-grid .settings-card-wide { grid-column: 1 / -1; }

/* Zwei Karten nebeneinander (z.B. Benutzer bearbeiten + 2FA) statt
   untereinander — reduziert die Gesamthöhe der Seite. flex-wrap sorgt
   dafür, dass auf schmalen Bildschirmen (iPad Hochformat, Handy) automatisch
   wieder untereinander gestapelt wird, sobald beide Karten nicht mehr
   nebeneinander passen. */
.form-cards-row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 20px;
}
/* Formular braucht mehr Breite als die schmalere Zweitkarte, sonst brechen
   die zweispaltigen .form-row-Zeilen im Formular unnötig früh um
   (.form-row-Labels brauchen min. 200px + Gap, siehe dort). */
.form-cards-row form { flex: 1 1 440px; }
.form-cards-row > .detail-card { flex: 1 1 280px; }

/* Grösseres Layout speziell für die Behandlungserfassung — overflow:visible,
   damit Autocomplete-Dropdowns über den Kartenrand hinausragen dürfen. */
.detail-card.detail-card-wide {
  max-width: 1040px;
  overflow: visible;
  /* War bisher linksbündig (kein auto-margin) - in der normalen Vollseite
     kaum merkbar, aber im neuen, bewusst sehr breiten Erfassungs-Popup
     (siehe .treatment-modal, 97vw) wurde dadurch der gesamte ungenutzte
     Platz als grosser Rand NUR auf der rechten Seite sichtbar (das war die
     eigentliche Ursache des seit mehreren Nachrichten gesuchten "weissen
     Rands" - nicht der Dialog/das iframe, die waren die ganze Zeit korrekt
     97% breit). Zentriert lässt den unvermeidbaren Rest gleichmässig auf
     beide Seiten verteilt und sieht dadurch beabsichtigt statt kaputt aus. */
  margin-left: auto;
  margin-right: auto;
}

.detail-card-header {
  background: var(--accent);
  color: #fff;
  padding: 16px 24px;
  font-size: 16px;
  font-weight: 700;
  border-radius: var(--radius) var(--radius) 0 0;
}

.detail-card-wide .detail-card-header {
  padding: 20px 28px;
  font-size: 19px;
}

.meta-grid {
  display: grid;
  /* Reihenfolge: Datum, Kunde, Sprache, Bedient von - Datum braucht wenig
     Platz (kurzes Feld), Bedient von öfter längere Namen (nicht abschneiden). */
  grid-template-columns: 0.45fr 2.35fr 0.55fr 0.95fr;
  border-bottom: 1px solid var(--gray-200);
}

.meta-cell {
  padding: 12px 18px;
  border-right: 1px solid var(--gray-200);
}
.meta-cell:last-child { border-right: none; }

.detail-card-wide .meta-cell { padding: 18px 24px; }

.meta-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--gray-400);
  margin-bottom: 4px;
}

.detail-card-wide .meta-label { font-size: 13px; margin-bottom: 6px; }

.meta-cell input,
.meta-cell select {
  border: none;
  padding: 2px 0;
  font-size: 14px;
  font-weight: 600;
  color: var(--gray-800);
  width: 100%;
  background: transparent;
}
.meta-cell input:focus,
.meta-cell select:focus {
  outline: none;
  border-bottom: 1px solid var(--accent);
}

.detail-card-wide .meta-cell input,
.detail-card-wide .meta-cell select { font-size: 18px; padding: 4px 0; }

.meta-inline-group { display: flex; align-items: baseline; gap: 8px; }
.meta-inline-group select { flex: 0 0 auto; width: auto; min-width: 60px; }
.meta-inline-group input,
.meta-inline-group .autocomplete-wrap { flex: 1; min-width: 0; }
.meta-inline-group input.meta-firstname-input { flex: 0 0 140px; }

.items-table { width: 100%; border-collapse: collapse; }

.detail-card-wide .items-table { table-layout: fixed; }
.detail-card-wide .items-table col.col-type { width: 195px; }
.detail-card-wide .items-table col.col-quantity { width: 90px; }
.detail-card-wide .items-table col.col-amount { width: 160px; }
.detail-card-wide .items-table col.col-action { width: 52px; }

.items-table th {
  padding: 10px 20px;
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  color: var(--gray-400);
  background: var(--gray-50);
  border-bottom: 1px solid var(--gray-200);
  text-transform: uppercase;
  letter-spacing: .04em;
}

.detail-card-wide .items-table th { padding: 14px 20px; font-size: 13px; }

.items-table td {
  padding: 8px 20px;
  border-bottom: 1px solid var(--gray-100);
  white-space: normal;
}

.detail-card-wide .items-table td { padding: 14px 20px; }

.items-table tbody tr:last-child td { border-bottom: none; }

.items-table select,
.items-table input {
  border: 1px solid transparent;
  padding: 5px 6px;
  border-radius: 6px;
  font-size: 13px;
  width: 100%;
  background: transparent;
}
.items-table select:hover, .items-table input:hover { border-color: var(--gray-200); }
.items-table select:focus, .items-table input:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--white);
}
.items-table input[name="item_amount"],
.items-table .item-unit-price,
.items-table .item-quantity { text-align: right; }
.items-table .item-amount[readonly] {
  background: var(--gray-50);
  color: var(--gray-600);
  font-weight: 600;
}
.items-table .item-amount[readonly]:hover,
.items-table .item-amount[readonly]:focus {
  border-color: transparent;
  background: var(--gray-50);
}

.detail-card-wide .items-table select,
.detail-card-wide .items-table input { font-size: 17px; padding: 9px 10px; }

/* Lieferschein-Review: kompaktere Zeilen als der sonstige .detail-card-wide-
   Standard (dort auf grosse Touch-Bedienung ausgelegt) — hier eher eine
   Prüf-/Korrektur-Liste, die auch bei vielen Positionen übersichtlich
   bleiben soll. Per ID statt Klasse, damit nichts anderes mitbetroffen ist. */
#lieferschein-positions th { padding: 6px 12px; font-size: 10px; }
#lieferschein-positions td { padding: 3px 12px; }
#lieferschein-positions select,
#lieferschein-positions input { font-size: 12px; padding: 3px 6px; }

/* Autocomplete-Dropdown (Kunde, Ware-Beschreibung) — echtes Textfeld bleibt,
   Vorschläge kommen aus einer eigenen JS-Liste statt <datalist> (auf iPad/Safari
   unzuverlässig, siehe Projekt-Memory zu Safari-Rendering-Eigenheiten). */
.autocomplete-wrap { position: relative; }
.autocomplete-list {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  z-index: 80;
  margin-top: 4px;
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: 8px;
  box-shadow: var(--shadow);
  max-height: 240px;
  overflow-y: auto;
  display: none;
  text-align: left;
  /* im Filter-Label (.toolbar label) sonst vererbt: Grossbuchstaben, Abstand */
  text-transform: none;
  letter-spacing: normal;
}
.autocomplete-list.open { display: block; }
.autocomplete-item {
  padding: 9px 14px;
  font-size: 15px;
  font-weight: 400;
  color: var(--gray-800);
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.autocomplete-item:hover,
.autocomplete-item.active {
  background: var(--accent-light);
}

.add-row-btn {
  margin: 10px 20px 16px;
  background: none;
  border: 1px dashed var(--gray-200);
  color: var(--gray-600);
  padding: 7px 14px;
  border-radius: var(--radius);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  width: calc(100% - 40px);
}
.add-row-btn:hover { border-color: var(--accent); color: var(--accent-dark); }

.total-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 24px;
  padding: 12px 20px;
  border-top: 2px solid var(--gray-200);
  background: var(--gray-50);
  font-size: 15px;
  font-weight: 700;
}

.total-label { color: var(--gray-600); }
.total-amount { font-variant-numeric: tabular-nums; color: var(--gray-800); }

/* Tip section */
.tip-section {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 20px;
  border-top: 1px solid var(--gray-200);
  flex-wrap: wrap;
}

.section-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--gray-400);
  margin-right: 4px;
  flex: 0 0 auto;
}

.pill-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 13px;
  border: 1px solid var(--gray-200);
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  color: var(--gray-600);
  cursor: pointer;
  background: var(--white);
  transition: all .15s;
  font-family: inherit;
}

.pill-btn svg,
.pill-btn img { flex: none; }

.pill-btn.selected {
  background: var(--accent-light);
  border-color: var(--accent);
  color: var(--accent-dark);
}

.tip-custom {
  display: flex; align-items: center;
  border: 1px solid var(--gray-200);
  border-radius: 20px;
  overflow: hidden;
  background: var(--white);
}
.tip-custom span { padding: 5px 4px 5px 12px; font-size: 12px; font-weight: 600; color: var(--gray-400); }
.tip-custom input {
  border: none; outline: none;
  font-size: 12px; font-weight: 600;
  width: 64px;
  padding: 5px 12px 5px 0;
  background: transparent;
  color: var(--gray-800);
}

/* Payment section (pills, radio-driven) */
.payment-section {
  padding: 14px 20px;
  border-top: 1px solid var(--gray-200);
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.payment-option {
  position: relative;
}
.payment-option input[type="radio"] {
  position: absolute;
  opacity: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  cursor: pointer;
}
.payment-option label {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border: 1px solid var(--gray-200);
  border-radius: 20px;
  font-size: 13px;
  font-weight: 500;
  color: var(--gray-600);
  cursor: pointer;
  transition: all .15s;
  margin: 0;
}
.payment-option input[type="radio"]:checked + label {
  background: var(--accent-light);
  border-color: var(--accent);
  color: var(--accent-dark);
}
.payment-option svg { width: 14px; height: 14px; flex-shrink: 0; }

.card-options {
  display: none;
  align-items: center;
  gap: 8px;
  padding: 10px 20px 14px;
  flex-wrap: wrap;
  border-top: 1px dashed var(--gray-200);
  background: var(--gray-50);
}
.card-options.visible { display: flex; }

.form-actions { padding: 18px 20px; display: flex; gap: 10px; }
.form-actions .btn-primary { flex: 1; width: 100%; justify-content: center; padding: 10px 14px; font-size: 14px; }
.form-actions .btn-outline { flex: 0 0 auto; justify-content: center; padding: 10px 14px; font-size: 14px; }

/* Grössere Bedienelemente in der Behandlungserfassung (Trinkgeld/Zahlungsart-
   Pills, Total, Speichern-Button) — Klassen wie .pill-btn/.section-label werden
   auch anderswo (Reports) verwendet, daher hier auf #treatment-form beschränkt. */
.detail-card-wide .add-row-btn { font-size: 14px; padding: 9px 16px; }
.detail-card-wide .total-row { font-size: 18px; padding: 16px 24px; }
.detail-card-wide .tip-section,
.detail-card-wide .payment-section { padding: 16px 24px; gap: 12px; }
.detail-card-wide .card-options { padding: 12px 24px 16px; }
#treatment-form .tip-section .section-label,
#treatment-form .payment-section .section-label,
#treatment-form .card-options .section-label { font-size: 13px; }
#treatment-form .tip-section .pill-btn,
#treatment-form .card-options .pill-btn { font-size: 14px; padding: 7px 16px; }
.detail-card-wide .tip-custom span,
.detail-card-wide .tip-custom input { font-size: 14px; }
.detail-card-wide .tip-custom input { width: 76px; }
.detail-card-wide .payment-option label { font-size: 15px; padding: 8px 16px; }
.detail-card-wide .payment-option svg { width: 16px; height: 16px; }
.detail-card-wide .form-actions .btn-primary,
.detail-card-wide .form-actions .btn-outline { font-size: 16px; padding: 13px 16px; }

/* Noch etwas grösser — nur auf breiten Desktop-Bildschirmen (min-width 1400px,
   sicher oberhalb jeder iPad-Breite inkl. 12.9" Querformat/1366px), damit die
   Grösse auf dem iPad (dort laut Nutzer "genau richtig") unverändert bleibt. */
@media (min-width: 1400px) {
  .detail-card.detail-card-wide { max-width: 1220px; }
  .detail-card-wide .detail-card-header { padding: 22px 30px; font-size: 20px; }
  .detail-card-wide .meta-cell { padding: 22px 28px; }
  .detail-card-wide .meta-label { font-size: 14px; }
  .detail-card-wide .meta-cell input,
  .detail-card-wide .meta-cell select { font-size: 19px; }
  .detail-card-wide .items-table col.col-type { width: 215px; }
  .detail-card-wide .items-table col.col-quantity { width: 100px; }
  .detail-card-wide .items-table col.col-amount { width: 175px; }
  .detail-card-wide .items-table col.col-action { width: 56px; }
  .detail-card-wide .items-table th { padding: 16px 22px; font-size: 14px; }
  .detail-card-wide .items-table td { padding: 16px 22px; }
  .detail-card-wide .items-table select,
  .detail-card-wide .items-table input { font-size: 18px; padding: 10px 12px; }
  .detail-card-wide .total-row { font-size: 19px; padding: 18px 26px; }
  .detail-card-wide .tip-section,
  .detail-card-wide .payment-section { padding: 18px 26px; }
  .detail-card-wide .payment-option label { font-size: 16px; padding: 9px 18px; }
  .detail-card-wide .form-actions .btn-primary,
  .detail-card-wide .form-actions .btn-outline { font-size: 17px; padding: 14px 18px; }
}

/* Im Erfassungs-Popup (.treatment-modal) soll die Karte das Popup wirklich
   ausfüllen statt bei 1040/1220px zu deckeln - sonst bleibt der ungenutzte
   Rest als sinnloser weisser Rand rund um die Karte stehen, obwohl das Popup
   selbst schon fast bildschirmfüllend ist. Gleiche Selektor-Spezifität wie
   die max-width-Regeln oben (zwei Klassen) und steht nach ihnen, damit sie
   in beiden Breakpoints gewinnt. */
.detail-card-wide.detail-card-popup {
  max-width: none;
  width: 100%;
}

/* ── Receipt (print target, no sidebar) ── */
.receipt-page { min-height: 100vh; background: var(--gray-50); }
.receipt-page .app-content { max-width: 560px; margin: 0 auto; padding-top: 32px; }

.receipt-actions {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}

/* "minimal=1" (Aufruf über /treatments/by-number/:belegnr, siehe receipt.ejs)
   zeigt nur noch den Drucken-Button - links ausgerichtet sähe er neben der
   mittig stehenden Quittung darunter schief aus. */
.receipt-actions-centered { justify-content: center; }

.receipt-print-form { display: inline-flex; }
.btn-large { padding: 10px 18px; font-size: 15px; font-weight: 600; }
/* "Schliessen" im Quittungs-Popup nur als X ganz rechts - mit "PDF" passen
   sonst nicht alle Buttons in eine Zeile des 440px schmalen Popups. */
.btn-icon-close { margin-left: auto; padding: 7px 9px; }
/* "PDF" in der iPad-App, solange das PDF im Hintergrund lädt (pdf-share.js). */
.btn.is-loading { opacity: .5; }

/* Bewusst schmal gehalten (~80mm-Bon-Optik), auch auf dem Bildschirm —
   das ist Teil des "repräsentativen" Looks, nicht nur Print-Vorbereitung. */
/* Feste Farbwerte statt Theme-Tokens (var(--gray-*)) ab hier bewusst - echtes
   Bondruckerpapier bleibt IMMER hell mit dunkler Schrift, unabhängig vom
   gewählten App-Farbschema (Einstellungen). Mit den Tokens würde dunkler
   Modus helle statt dunkler Schrift auf dieses weiterhin weisse Papier
   schreiben - unlesbar. */
/* Quittungsschrift JetBrains Mono (SIL Open Font License, public/fonts/
   JetBrainsMono-OFL.txt) - selbst ausgeliefert statt ui-monospace/SF Mono,
   damit Bildschirm und PDF (utils/pdfReceipt.js, gleiche Schrift als TTF)
   auf jedem Gerät identisch aussehen. Nur die verwendeten Stärken. */
@font-face { font-family: 'JetBrains Mono'; src: url('/fonts/JetBrainsMono-Regular.woff2') format('woff2'); font-weight: 400; font-display: swap; }
@font-face { font-family: 'JetBrains Mono'; src: url('/fonts/JetBrainsMono-SemiBold.woff2') format('woff2'); font-weight: 600; font-display: swap; }
@font-face { font-family: 'JetBrains Mono'; src: url('/fonts/JetBrainsMono-Bold.woff2') format('woff2'); font-weight: 700; font-display: swap; }

.receipt-paper {
  background: #fff;
  border-radius: 6px;
  box-shadow: 0 1px 3px rgba(0,0,0,.06), 0 10px 28px rgba(0,0,0,.08);
  padding: 1.6rem 1.3rem;
  max-width: 320px;
  margin: 0 auto;
  font-family: 'JetBrains Mono', ui-monospace, 'SF Mono', 'Menlo', 'Consolas', monospace;
  /* Keine Programmier-Ligaturen (z.B. "--" oder "->" als ein Zeichen). */
  font-variant-ligatures: none;
  font-feature-settings: "liga" 0, "calt" 0;
  color: #2b2622;
}

.receipt-header { text-align: center; margin-bottom: 0; }
.receipt-logo { display: block; width: 130px; height: auto; margin: 0 auto 0.6rem; }
.receipt-header p { margin: 0.1rem 0; color: #66605a; font-size: 0.75rem; }

.receipt-divider {
  border-top: 1px dashed #ddd5c7;
  margin: 0.9rem 0;
}

.receipt-meta p {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  margin: 0.3rem 0;
  font-size: 0.8rem;
}
.receipt-meta p span:first-child { color: #847d70; }
.receipt-meta p span:last-child { text-align: right; font-weight: 600; }

.receipt-items { width: 100%; border-collapse: collapse; font-size: 0.8rem; }
.receipt-items th {
  padding: 0 0 0.4rem;
  background: none;
  border-bottom: none;
  position: static;
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: #9a9284;
}
.receipt-items td {
  padding: 0.45rem 0;
  vertical-align: top;
  border-bottom: none;
}
.receipt-items th:first-child,
.receipt-items td:first-child { text-align: left; }
.receipt-items td:first-child { white-space: normal; }
.receipt-items tbody tr td { background: none; }
.receipt-item-qty {
  font-size: 0.8rem;
  color: #6f685c;
  margin-top: 1px;
}
.receipt-item-tag {
  font-size: 0.68rem;
  color: #9a9284;
  text-transform: uppercase;
  letter-spacing: .03em;
  margin-top: 1px;
}
.receipt-items tfoot td {
  font-weight: 700;
  font-size: 0.95rem;
  padding-top: 0.7rem;
  border-top: 1px dashed #ddd5c7;
}

.receipt-qr { text-align: center; font-size: 0.75rem; color: #66605a; }
.receipt-qr p { margin: 0.1rem 0; }
.receipt-qr-code { width: 46mm; max-width: 100%; margin: 0 auto 0.6rem; }
.receipt-qr-code svg { display: block; width: 100%; height: auto; }
.receipt-footer { text-align: center; margin-top: 0; color: #66605a; font-size: 0.78rem; }

/* ── Reports overview ── */
.reports-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

.report-card {
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px 24px;
  display: flex;
  align-items: flex-start;
  gap: 16px;
  cursor: pointer;
  transition: border-color .15s, box-shadow .15s, transform .1s;
  text-decoration: none;
  color: inherit;
}

.report-card:hover {
  border-color: var(--accent);
  box-shadow: 0 4px 12px rgba(74,109,140,.15);
  transform: translateY(-1px);
}

.report-card.disabled {
  cursor: default;
}
.report-card.disabled:hover {
  border-color: var(--gray-200);
  box-shadow: var(--shadow);
  transform: none;
}

.report-icon {
  width: 44px; height: 44px;
  border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.report-icon svg { width: 22px; height: 22px; }

.icon-blue   { background: var(--icon-blue-bg); color: var(--icon-blue-ink); }
.icon-green  { background: var(--icon-green-bg); color: var(--icon-green-ink); }
.icon-purple { background: var(--icon-purple-bg); color: var(--icon-purple-ink); }
.icon-orange { background: var(--icon-orange-bg); color: var(--icon-orange-ink); }
.icon-teal   { background: var(--icon-teal-bg); color: var(--icon-teal-ink); }
.icon-indigo { background: var(--icon-indigo-bg); color: var(--icon-indigo-ink); }
.icon-pink   { background: var(--icon-pink-bg); color: var(--icon-pink-ink); }
.icon-cyan   { background: var(--icon-cyan-bg); color: var(--icon-cyan-ink); }

.report-info { flex: 1; }

.report-title {
  font-size: 14px; font-weight: 600;
  color: var(--gray-800);
  margin-bottom: 4px;
  display: flex; align-items: center; gap: 8px;
}

.report-desc {
  font-size: 12px;
  color: var(--gray-400);
  line-height: 1.5;
}

.report-arrow {
  color: var(--gray-200);
  align-self: center;
  transition: color .15s, transform .15s;
}

.report-card:hover .report-arrow {
  color: var(--accent);
  transform: translateX(3px);
}

/* ── Report detail pages (period bar, KPIs, bar chart) ──
   Compact by design: these pages should fit one screen without scrolling,
   same principle as the treatments list (fixed chrome, minimal scrolling). */
.report-page .app-content { padding: 16px 24px; }

.report-panel {
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 12px 18px;
  margin-bottom: 10px;
  flex-shrink: 0;
}

/* Quittungs-Popup (Beleg-Suche) - zeigt die normale Quittungsseite per
   iframe an, damit die Suchergebnisse im Hintergrund unangetastet bleiben
   (siehe report_receipt_search.ejs). Natives <dialog> statt eigenem
   Overlay-Div: Backdrop, ESC-zum-Schliessen und Fokus-Handling kommen
   dadurch gratis vom Browser. */
.receipt-modal {
  border: none;
  border-radius: 12px;
  padding: 0;
  width: min(440px, 92vw);
  height: min(760px, 90vh);
  box-shadow: var(--shadow);
  background: var(--white);
  overflow: hidden;
  /* Der globale Reset "*, *::before, *::after { margin: 0 }" ganz oben in
     dieser Datei löscht auch das margin:auto, mit dem Browser ein <dialog>
     normalerweise automatisch zentrieren - hier bewusst wiederhergestellt,
     sonst hängt das Popup oben links im Viewport statt mittig. */
  margin: auto;
}
.receipt-modal::backdrop { background: rgba(0,0,0,.5); }
.receipt-modal iframe {
  display: block;
  width: 100%;
  height: 100%;
  border: none;
}

/* Grosse Erfassungsmaske (Neue Behandlung / Bearbeiten) als <dialog>+<iframe>,
   analog zum Quittungs-Popup oben - bewusst so gross wie möglich (fast
   Vollbild auf dem iPad), da hier ein komplettes Formular reinpassen muss,
   nicht nur eine schmale Quittung. Siehe partials/treatment_form_modal.ejs. */
.treatment-modal {
  /* Alle bisherigen Versuche mit vw/vh/dvh-Prozentrechnung liessen auf dem
     iPad (Safari) einen breiten Rand übrig, weil sich die
     Werkzeugleisten-Höhe nach dem Öffnen ändert und die %-Werte davon
     abhängig, aber nicht zuverlässig aktuell sind (auch dvh nicht - siehe
     Beobachtung auf echtem Gerät). Deshalb jetzt keine Berechnung mehr: Der
     Dialog wird per position:fixed + inset:0 exakt auf die Grösse des
     tatsächlich sichtbaren Viewports gesetzt - das ist eine seit Jahren
     stabile CSS-Technik ohne jede Prozent-/Einheiten-Arithmetik, die schief
     gehen könnte. Der kleine "Rahmen" um das Formular kommt jetzt über
     padding auf dem Dialog selbst (schiebt nur das iframe nach innen,
     bleibt aber exakt bildschirmgross). */
  position: fixed;
  inset: 0;
  margin: 0;
  width: auto;
  height: auto;
  border: none;
  border-radius: 0;
  padding: 10px;
  max-width: none;
  max-height: none;
  box-shadow: none;
  background: rgba(0,0,0,.5);
  overflow: hidden;
}
.treatment-modal::backdrop { background: rgba(0,0,0,.5); }
.treatment-modal iframe {
  display: block;
  width: 100%;
  height: 100%;
  border: none;
  border-radius: 12px;
  box-shadow: var(--shadow);
  background: var(--white);
}

/* Unstyled <button>, das wie ein normaler Fliesstext-Link aussieht - für
   Stellen, die aus JS-Gründen (Modal statt Navigation) einen <button>
   statt <a> brauchen, aber optisch nicht als Button auffallen sollen. */
.link-inline {
  background: none;
  border: none;
  padding: 0;
  margin: 0;
  font: inherit;
  color: var(--accent-dark);
  text-decoration: underline;
  cursor: pointer;
}

/* Nur dieser Bereich scrollt (Chart + Detailtabelle) — Zeitraum-Filter und
   Kennzahlen bleiben immer sichtbar, gleiches Prinzip wie bei der Behandlungsliste. */
.report-scroll-area {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
}
.report-scroll-area .report-panel:last-child { margin-bottom: 0; }

.period-bar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.period-bar .pill-btn {
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  box-sizing: border-box;
  height: 26px;
  line-height: normal;
}

.period-bar form.period-inline-form,
.period-bar form.period-custom-form {
  align-self: center;
}

.period-custom-form, .period-inline-form { display: flex; align-items: center; gap: 8px; }
.period-custom-form { margin-left: auto; }

.period-custom-form span { color: var(--gray-400); font-size: 12px; }

.period-custom-form input[type="date"],
.period-inline-form select {
  -webkit-appearance: none;
  appearance: none;
  height: 26px;
  min-height: 26px;
  width: auto;
  padding: 0 10px;
  border: 1px solid var(--gray-200);
  border-radius: 20px;
  font-size: 12px;
  background: var(--white);
  color: var(--gray-800);
  cursor: pointer;
}

.period-inline-form select.selected {
  background: var(--accent-light);
  border-color: var(--accent);
  color: var(--accent-dark);
}

.period-custom-form button.pill-btn,
.banana-month-form button.pill-btn {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.period-custom-form button.pill-btn:hover,
.banana-month-form button.pill-btn:hover { background: var(--accent-hover); border-color: var(--accent-hover); }

.banana-toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.banana-month-form { display: flex; align-items: center; gap: 8px; }
.banana-month-form select {
  -webkit-appearance: none;
  appearance: none;
  height: 26px;
  min-height: 26px;
  width: auto;
  padding: 0 10px;
  border: 1px solid var(--gray-200);
  border-radius: 20px;
  font-size: 12px;
  background: var(--white);
  color: var(--gray-800);
  cursor: pointer;
}
.banana-export-btn { margin-left: auto; }
.banana-reclass-row td { background: var(--gray-50); color: var(--gray-400); font-style: italic; }
.banana-footnote { font-size: 12px; color: var(--gray-400); padding: 10px 4px 0; }

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 8px 18px;
}

.kpi-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--gray-400);
  margin-bottom: 3px;
}

.kpi-value {
  font-size: 19px;
  font-weight: 700;
  color: var(--gray-800);
  font-variant-numeric: tabular-nums;
}

.report-panel .section-label { margin-bottom: 8px !important; }

.bar-chart { display: flex; flex-direction: column; gap: 7px; }

.bar-row { display: flex; align-items: center; gap: 10px; }

.bar-name {
  flex: 0 0 120px;
  font-size: 13px;
  font-weight: 600;
  color: var(--gray-800);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.bar-track {
  flex: 1;
  background: var(--gray-100);
  border-radius: 5px;
  height: 16px;
  overflow: hidden;
}

.bar-fill { height: 100%; background: var(--accent); border-radius: 5px; }
/* Verkaufsübersicht: Balken aus Behandlungen, Verkauf (Waren) und Trinkgeld */
.bar-track:has(.bar-seg) { display: flex; }
.bar-seg { height: 100%; flex: 0 0 auto; }
.bar-seg-behandlung { background: var(--accent); }
.bar-seg-ware { background: var(--payment-yellow); }
.bar-seg-trinkgeld { background: var(--gray-400); }
.bar-legend { display: flex; flex-wrap: wrap; gap: 4px 16px; margin-bottom: 10px; font-size: 12px; color: var(--gray-600); }
.bar-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 6px; }

.bar-fill.payment-fill-green  { background: var(--payment-green); }
.bar-fill.payment-fill-blue   { background: var(--payment-blue); }
.bar-fill.payment-fill-yellow { background: var(--payment-yellow); }

.bar-value {
  flex: 0 0 100px;
  text-align: right;
  font-size: 13px;
  font-weight: 600;
  color: var(--gray-800);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.report-panel table { width: 100%; }
.report-panel th { padding: 6px 12px; font-size: 11px; }
.report-panel td { padding: 4px 12px; font-size: 13px; }
.report-panel tfoot td {
  font-weight: 700;
  border-top: 2px solid var(--gray-200);
  background: var(--gray-50);
}

/* ── Zahlungsart-Icons ── */
.bar-name-icon { display: inline-flex; align-items: center; gap: 8px; }
.bar-name-icon svg { width: 15px; height: 15px; flex-shrink: 0; color: var(--gray-400); }

.brand-logo-img {
  height: 20px;
  width: auto;
  max-width: 44px;
  object-fit: contain;
  border-radius: 4px;
  border: 1px solid var(--gray-200);
  flex-shrink: 0;
  background: #fff;
}
.brand-logo-img.brand-logo-crop-top {
  width: 20px;
  height: 20px;
  object-fit: cover;
  object-position: top;
}

/* ── Responsive ──
   Tablets (iPad portrait is typically 768–834px) keep the same vertical
   sidebar as desktop — it has plenty of room. Only real phone-width screens
   get a different layout, and even there the sidebar stays a normal
   top-to-bottom stack (just full-width, scrollable) instead of being
   squeezed into a single horizontal row — with 5 nav items + logo + avatar,
   a horizontal row has no room and items overlap/disappear. */
@media (max-width: 860px) {
  .meta-grid { grid-template-columns: 1fr; }
  .meta-cell { border-right: none; border-bottom: 1px solid var(--gray-200); }
  .meta-cell:last-child { border-bottom: none; }
}

@media (max-width: 600px) {
  .app-shell { flex-direction: column; }
  aside.sidebar {
    width: 100%;
    max-height: 70vh;
    overflow-y: auto;
    border-right: none;
    border-bottom: 1px solid var(--gray-200);
  }
  .app-content { padding: 14px; }
  .receipt-paper { padding: 1.2rem; }
  th, td { padding: 8px 10px; }
}

/* ── Zeitkonto (Prototyp) ── */
.page-title { display: flex; align-items: center; gap: 10px; }

/* #timesheet-form steht zwischen .app-content und .table-card - ein <form>
   ist von Haus aus kein Flex-Container, ohne das hier würde .table-card
   (erwartet einen Flex-Elternteil für "flex:1; min-height:0") einfach auf
   volle Inhaltshöhe wachsen. Ergebnis: die ganze Seite (inkl. KPI-Kacheln
   und Speichern/Sperren-Buttons) scrollt gemeinsam mit der Tagestabelle statt
   nur die Tabellenzeilen - genau das war die "Panel/Fusszeile scrollt"-
   Beschwerde. Mit dieser Regel bleibt nur .table-scroll scrollbar, alles
   andere (Kopf, Filter, Kennzahlen, Buttons) bleibt fest sichtbar. */
#timesheet-form {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

.timesheet-table th.col-start,
.timesheet-table th.col-end,
.timesheet-table th.col-break,
.timesheet-table th.col-total { width: 110px; text-align: center; }
.timesheet-table th.col-absence { width: 130px; text-align: center; }
.timesheet-table td { text-align: center; }
.timesheet-table td.day-label { text-align: left; font-weight: 500; }

.timesheet-table tr.weekend td { background: var(--gray-50); color: var(--gray-400); }
.timesheet-table tr.weekend input { background: var(--gray-100) !important; cursor: not-allowed; }
.timesheet-table tr.today td { background: var(--badge-yellow-bg); }
.timesheet-table tr.today td.day-label { color: var(--badge-yellow-ink); font-weight: 700; }

.timesheet-table td.total { font-weight: 600; color: var(--gray-800); }
.timesheet-table td.total.negative { color: var(--error); }
.timesheet-table td.total.zero { color: var(--gray-400); }
.timesheet-table td.day-audit { text-align: left; color: var(--gray-400); font-size: 12px; }

.day-absence-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  font-size: 10px;
  line-height: 1;
  margin-right: 6px;
  vertical-align: middle;
}

/* Grösserer Abstand vor "Mitarbeiterin", damit die beiden Feldgruppen im
   selben .period-bar optisch getrennt bleiben statt wie ein durchgehendes
   Feld-Sammelsurium zu wirken - der normale .period-bar-gap (10px) reicht
   innerhalb einer Gruppe (Label+Auswahl), aber nicht zwischen zwei Gruppen. */
.field-group-gap { margin-left: 24px; }

.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { opacity: .88; }

@media print {
  @page { size: 80mm 200mm; margin: 4mm 3mm; }
  .no-print { display: none !important; }
  body { background: #fff; }
  .receipt-page { min-height: 0; background: #fff; }
  .receipt-page .app-content { max-width: 100%; margin: 0; padding: 0; }
  .receipt-paper {
    max-width: 100%;
    width: 100%;
    margin: 0;
    padding: 0;
    box-shadow: none;
    border-radius: 0;
    font-size: 12px;
  }
}

/* Customer Intelligence */
.kpi-sub { font-size: 12px; color: var(--gray-500, #6b7280); margin-top: 2px; }
.ci-hint { font-size: 12px; color: var(--gray-500, #6b7280); margin: 0 0 10px; }
.ci-form { display: flex; gap: 8px; }
.ci-form input[type="text"] { flex: 1; min-width: 0; }
.ci-answer { margin-top: 12px; padding: 12px 14px; border-radius: 8px; background: var(--gray-100); white-space: pre-wrap; line-height: 1.5; font-size: 14px; }
.ci-answer[hidden] { display: none; }
.ci-error { color: #b91c1c; }
.ci-bars { display: flex; flex-direction: column; gap: 4px; }
.ci-row { display: grid; grid-template-columns: minmax(90px, 160px) minmax(120px, 1fr) 110px 52px minmax(120px, 190px); gap: 10px; align-items: center; padding: 3px 6px; border-radius: 6px; color: inherit; text-decoration: none; font-size: 13px; }
.ci-row:hover { background: var(--gray-100); }
.ci-row-change { grid-template-columns: minmax(90px, 160px) minmax(120px, 1fr) 110px minmax(120px, 190px); }
.ci-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ci-track { position: relative; height: 14px; background: var(--gray-100); border-radius: 7px; }
.ci-fill { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 7px; }
.ci-marker { position: absolute; top: -3px; bottom: -3px; width: 2px; background: currentColor; opacity: .75; }
.ci-days small { color: var(--gray-500, #6b7280); }
.ci-factor { font-weight: 700; text-align: right; font-variant-numeric: tabular-nums; }
.ci-meta { color: var(--gray-500, #6b7280); font-size: 12px; text-align: right; white-space: nowrap; }
.ci-change { grid-column: 2 / span 1; }
.ci-arrow { color: var(--gray-500, #6b7280); }
.ci-fill.ci-yellow, .ci-dot.ci-yellow { background: #eab308; }
.ci-fill.ci-orange, .ci-dot.ci-orange { background: #f97316; }
.ci-fill.ci-red, .ci-dot.ci-red { background: #dc2626; }
.ci-fill.ci-green, .ci-dot.ci-green { background: #16a34a; }
.ci-factor.ci-yellow { color: #a16207; }
.ci-factor.ci-orange { color: #c2410c; }
.ci-factor.ci-red, .ci-red-text { color: #dc2626; }
.ci-factor.ci-green { color: #15803d; }
.ci-orange-text { color: #c2410c; }
.ci-legend { margin-top: 10px; font-size: 12px; color: var(--gray-500, #6b7280); display: flex; align-items: center; gap: 6px; }
.ci-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-left: 8px; }
@media (max-width: 760px) {
  .ci-row, .ci-row-change { grid-template-columns: 1fr auto; }
  .ci-track, .ci-change, .ci-days, .ci-meta { grid-column: 1 / -1; text-align: left; }
}

/* Hervorgehobene Report-Kachel (Customer Intelligence) */
.featured-report {
  display: flex; align-items: center; gap: 18px;
  padding: 20px 24px;
  margin-bottom: 4px;
  border: 1px solid var(--accent);
  border-left-width: 5px;
  border-radius: var(--radius);
  background: linear-gradient(135deg, var(--accent-light), var(--white) 70%);
  box-shadow: 0 4px 14px rgba(74,109,140,.18);
  color: inherit; text-decoration: none;
  transition: box-shadow .15s, transform .15s;
}
.featured-report:hover { box-shadow: 0 6px 18px rgba(74,109,140,.28); transform: translateY(-1px); }
.featured-icon {
  width: 56px; height: 56px; flex-shrink: 0;
  border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  background: var(--accent); color: #fff;
}
.featured-icon svg { width: 28px; height: 28px; }
.featured-title { font-size: 18px; font-weight: 700; color: var(--gray-800); display: flex; align-items: center; gap: 10px; }
.featured-badge { font-size: 11px; font-weight: 700; letter-spacing: .06em; padding: 2px 8px; border-radius: 999px; background: var(--accent); color: #fff; }
.featured-desc { font-size: 13px; color: var(--gray-500, var(--gray-400)); margin-top: 4px; line-height: 1.5; }
.featured-cta { display: flex; align-items: center; gap: 4px; font-weight: 600; color: var(--accent); white-space: nowrap; }
@media (max-width: 600px) { .featured-cta { display: none; } }
.ci-row-top { grid-template-columns: minmax(90px, 160px) minmax(120px, 1fr) 110px minmax(150px, 230px); }
.ci-fill.ci-class-A, .ci-dot.ci-class-A { background: var(--accent-dark, #375270); }
.ci-fill.ci-class-B, .ci-dot.ci-class-B { background: var(--accent, #4a6d8c); }
.ci-fill.ci-class-C, .ci-dot.ci-class-C { background: #9db4c9; }
@media (max-width: 760px) { .ci-row-top { grid-template-columns: 1fr auto; } }
.ci-spark { width: 18px; height: 18px; flex-shrink: 0; }
.ci-footer { display: flex; align-items: center; justify-content: center; gap: 8px; margin: 16px 0 4px; font-size: 12px; color: var(--gray-500, #6b7280); }
.ci-examples { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 10px; margin-top: 12px; }
.ci-example {
  text-align: left; cursor: pointer;
  padding: 12px 14px;
  font: inherit; font-size: 13px; font-weight: 600; line-height: 1.35;
  color: var(--accent-dark);
  background: var(--accent-light);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  box-shadow: 0 1px 3px rgba(74,109,140,.15);
  transition: background .15s, color .15s, transform .15s, box-shadow .15s;
}
.ci-example:hover { background: var(--accent); color: #fff; transform: translateY(-1px); box-shadow: 0 4px 10px rgba(74,109,140,.28); }
.ci-example:active { transform: translateY(0); }
