/* Praxis Chiropraktik Bastian Kirsten – Mockup Styles */

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

:root {
  /* Markenfarben aus dem Praxis-Logo (Petrol/Türkis) */
  --green: #33696a;          /* Mittleres Petrol — Hauptakzent (Buttons, aktive Tabs, Links) */
  --green-dark: #004445;     /* Sehr dunkles Petrol — Überschriften, Hover, Logo-Hauptton */
  --green-light: #e2ecec;    /* Helles Petrol — Background für Hover/Active-Bereiche */
  --green-soft: #f0f6f6;     /* Sehr heller Verlauf-Ton für Header-Hintergründe */
  --grey-50: #f7f7f8;
  --grey-100: #ececee;
  --grey-200: #d8d8dc;
  /* Fliesstext-Grau. Frueher #8a8a92 - das ergab bei 12px nur rund 3,4:1
     Kontrast und lag damit unter dem Mindestwert 4,5:1 fuer Lesbarkeit.
     Betroffen war fast der gesamte Erklaertext fuer Patienten, unter
     anderem der Satz "Code ist 10 Minuten gueltig, max. 5 Falscheingaben"
     auf der Anmeldeseite. Jetzt rund 5,6:1. */
  --grey-400: #66666e;
  /* Textfarbe im orangen Warnkasten. Das Orange selbst erreicht auf dem
     hellen Orange nur 2,5:1 - ausgerechnet dort steht die wichtigste
     Nachricht des Portals ("1. Mahnung - bitte ueberweisen Sie bis ..."). */
  --orange-text: #8a4b00;
  --grey-700: #3d3d44;
  --grey-900: #1a1a1f;
  --red: #c92a2a;
  --red-light: #fde8e8;
  --orange: #e8800a;
  --orange-light: #fdf0dd;
  --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.04);
}

body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--grey-50);
  color: var(--grey-900);
  line-height: 1.5;
  font-size: 15px;
}

/* ===== Top-Navigation (Praxis) ===== */
body.has-topbar-praxis { background: var(--grey-50); }
.topbar {
  background: white;
  border-bottom: 1px solid var(--grey-200);
  padding: 0 24px;
  display: flex;
  align-items: center;
  gap: 28px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 1px 0 rgba(0,0,0,0.02);
  height: 64px;
}
.tb-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: inherit;
  padding: 8px 4px 8px 0;
}
.tb-logo {
  width: 42px; height: 42px;
  background-image: url('logo.svg');
  background-size: contain;
  background-position: center;
  background-repeat: no-repeat;
  /* Text-Inhalt ('C') versteckt halten, falls noch im HTML */
  font-size: 0;
  color: transparent;
}
.tb-brand-name { font-weight: 600; font-size: 14px; line-height: 1.2; color: var(--grey-900); }
.tb-brand-sub {
  font-size: 11px; color: var(--grey-400);
  text-transform: uppercase; letter-spacing: 0.6px; font-weight: 600;
  margin-top: 2px;
}

.tb-nav {
  display: flex;
  gap: 4px;
  flex: 1;
  align-items: center;
  height: 100%;
}
.tb-tab {
  position: relative;
  padding: 0 14px;
  height: 100%;
  display: flex;
  align-items: center;
  color: var(--grey-700);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  transition: color 0.1s;
}
.tb-tab:hover { color: var(--green-dark); }
.tb-tab.active { color: var(--green-dark); font-weight: 600; }
.tb-tab.active::after {
  content: '';
  position: absolute;
  left: 14px; right: 14px; bottom: -1px;
  height: 3px;
  background: var(--green);
  border-radius: 2px 2px 0 0;
}

.tb-user-dropdown { position: relative; }
.tb-user-trigger {
  display: flex; align-items: center; gap: 10px;
  border: 1px solid transparent;
  background: transparent;
  padding: 6px 10px 6px 6px;
  border-radius: 8px;
  cursor: pointer;
  font-family: inherit;
}
.tb-user-trigger:hover { background: var(--grey-50); border-color: var(--grey-200); }
.tb-avatar {
  width: 34px; height: 34px;
  border-radius: 50%;
  background: var(--green-light);
  color: var(--green-dark);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 14px;
}
.tb-user-info { text-align: left; }
.tb-user-name { font-size: 13px; font-weight: 600; line-height: 1.1; }
.tb-user-role { font-size: 11px; color: var(--grey-400); }
.tb-caret { color: var(--grey-400); font-size: 12px; margin-left: 4px; }

.tb-dropdown-menu {
  position: absolute;
  top: calc(100% + 6px); right: 0;
  background: white;
  border: 1px solid var(--grey-200);
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.12);
  min-width: 200px;
  padding: 6px;
  display: none;
}
.tb-user-dropdown.open .tb-dropdown-menu { display: block; }
.tb-dropdown-item {
  display: block;
  padding: 9px 12px;
  border-radius: 6px;
  color: var(--grey-700);
  text-decoration: none;
  font-size: 14px;
}
.tb-dropdown-item:hover { background: var(--grey-50); }
.tb-dropdown-item.danger { color: var(--red); }
.tb-dropdown-item.danger:hover { background: var(--red-light); }
.tb-dropdown-sep { height: 1px; background: var(--grey-100); margin: 4px 0; }

.tb-burger {
  display: none;
  background: transparent; border: 1px solid var(--grey-200);
  font-size: 18px; padding: 6px 12px; border-radius: 6px;
  cursor: pointer;
}

@media (max-width: 900px) {
  .topbar { gap: 12px; padding: 0 14px; }
  .tb-brand-sub { display: none; }
  .tb-nav { display: none; }
  .tb-user-info { display: none; }
  .tb-caret { display: none; }
  .tb-burger { display: block; }
  .topbar.mobile-open .tb-nav {
    display: flex; flex-direction: column;
    position: absolute; top: 100%; left: 0; right: 0;
    background: white; border-bottom: 1px solid var(--grey-200);
    padding: 8px;
    gap: 2px;
  }
  .topbar.mobile-open .tb-tab {
    padding: 12px 14px;
    height: auto;
    border-radius: 6px;
  }
  .topbar.mobile-open .tb-tab.active { background: var(--green-light); }
  .topbar.mobile-open .tb-tab.active::after { display: none; }
}

/* ===== Patientenportal-Header ===== */
body.has-topbar-patient { background: var(--grey-50); }
.patient-header {
  background: linear-gradient(135deg, var(--green-soft) 0%, var(--green-light) 100%);
  border-bottom: 1px solid var(--green-light);
  padding: 28px 24px 24px;
}
.patient-header-inner {
  max-width: 1100px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}
.patient-brand { display: flex; align-items: center; gap: 16px; }
.patient-brand .pat-logo { width: 64px; height: 64px; }
.pat-logo {
  width: 80px; height: 80px;
  background-image: url('logo.svg');
  background-size: contain;
  background-position: center;
  background-repeat: no-repeat;
  /* Falls 'C' im HTML steht — verstecken */
  font-size: 0;
  color: transparent;
  flex-shrink: 0;
}
.patient-brand-name {
  font-size: 22px;
  font-weight: 600;
  margin: 0;
  color: var(--green-dark);
  line-height: 1.2;
}
.patient-brand-sub {
  font-size: 13px;
  color: var(--grey-700);
  text-transform: uppercase;
  letter-spacing: 1.2px;
  font-weight: 600;
  margin-top: 4px;
}
.patient-user { display: flex; align-items: center; gap: 14px; font-size: 14px; color: var(--grey-700); }
.patient-user-greeting { color: var(--grey-700); }
.patient-logout {
  color: var(--green-dark);
  text-decoration: none;
  font-size: 13px;
  border: 1px solid var(--green);
  padding: 6px 12px;
  border-radius: 6px;
  font-weight: 500;
}
.patient-logout:hover { background: var(--green); color: white; }

@media (max-width: 600px) {
  .patient-brand-name { font-size: 18px; }
  .patient-header { padding: 20px 16px; }
  .patient-user-greeting { display: none; }
}

/* Patient-Tabs unter dem Header */
.patient-tabs {
  background: white;
  border-bottom: 1px solid var(--grey-200);
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 10;
}
.patient-tabs-inner {
  max-width: 1100px;
  margin: 0 auto;
  display: flex;
  gap: 4px;
  /* Die vier Reiter brauchen zusammen rund 400px, ein iPhone hat 375px.
     Ohne diese Regeln schrumpfen sie nicht (Flex-Elemente unterschreiten
     ihre Mindestbreite nicht), die Beschriftungen brechen ungleichmaessig
     um und die Leiste laeuft ueber den Rand. Jetzt scrollt die Leiste
     seitlich statt der ganzen Seite. */
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.patient-tabs-inner::-webkit-scrollbar { display: none; }
.patient-tab {
  position: relative;
  flex: 0 0 auto;
  white-space: nowrap;
  padding: 14px 18px;
  text-decoration: none;
  color: var(--grey-700);
  font-size: 14px;
  font-weight: 500;
  transition: color 0.1s;
  display: flex;
  align-items: center;
  gap: 6px;
}
.patient-tab:hover { color: var(--green-dark); }
.patient-tab.active {
  color: var(--green-dark);
  font-weight: 600;
}
.patient-tab.active::after {
  content: '';
  position: absolute;
  left: 18px; right: 18px; bottom: -1px;
  height: 3px;
  background: var(--green);
  border-radius: 2px 2px 0 0;
}
@media (max-width: 600px) {
  .patient-tabs { padding: 0 10px; }
  .patient-tab { padding: 12px 12px; font-size: 13px; }
}

/* ===== Import-Übersicht (2-spaltig) ===== */
.import-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-bottom: 16px;
}
@media (max-width: 800px) {
  .import-grid { grid-template-columns: 1fr; }
}
.import-card {
  background: white;
  border-radius: 10px;
  box-shadow: var(--shadow);
  padding: 22px;
}
.import-card-head {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 18px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--grey-100);
}
.import-card-icon {
  width: 46px; height: 46px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.12);
}
.csv-drop {
  border: 2px dashed var(--grey-200);
  border-radius: 10px;
  padding: 28px 18px;
  text-align: center;
  background: var(--grey-50);
  transition: all 0.15s;
  cursor: pointer;
  position: relative;
}
.csv-drop:hover { border-color: var(--green); background: var(--green-light); }
.csv-drop.dragover {
  border-color: var(--green);
  background: var(--green-light);
  transform: scale(1.01);
}
.csv-drop.has-file { border-color: var(--green); border-style: solid; background: var(--green-light); }
.csv-drop input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}
.csv-drop .dz-filename {
  margin-top: 12px;
  font-family: 'Consolas', monospace;
  font-size: 13px;
  color: var(--green-dark);
  font-weight: 600;
}

/* ===== Login-Seiten (Patient + Praxis) ===== */
.patient-login-page, .praxis-login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
  background: linear-gradient(135deg, var(--green-soft) 0%, var(--green-light) 100%);
}
.patient-login-card, .praxis-login-card {
  background: white;
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.08);
  padding: 36px 32px;
  width: 100%;
  max-width: 480px;
}
.login-brand {
  text-align: center;
  margin-bottom: 28px;
}
.login-brand .pat-logo {
  margin: 0 auto 14px;
  width: 220px;
  height: 220px;
}
.login-brand h1 {
  font-size: 22px;
  font-weight: 700;
  color: var(--green-dark);
  margin-bottom: 8px;
  line-height: 1.2;
}
.login-brand .login-sub {
  font-size: 25px;
  color: var(--green-dark);
  font-weight: 500;
  text-transform: none;
  display: block;
  white-space: nowrap;
  line-height: 1.3;
}

/* ===== Sidebar (alt — wird nicht mehr verwendet, aber für Übergang vorerst lassen) ===== */
/* Sidebar (Praxis-Layout) */
body.has-sidebar {
  display: flex;
  min-height: 100vh;
  background: var(--grey-50);
}
.sidebar {
  width: 240px;
  flex: 0 0 240px;
  background: white;
  border-right: 1px solid var(--grey-200);
  padding: 18px 12px;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}
.main-content { flex: 1; min-width: 0; padding: 0; }
.sb-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 10px 18px 10px;
  border-bottom: 1px solid var(--grey-100);
  margin-bottom: 14px;
}
.sb-brand-name { font-weight: 600; font-size: 14px; line-height: 1.2; }
.sb-brand-sub { font-size: 11px; color: var(--grey-400); letter-spacing: 0.5px; text-transform: uppercase; }

.sb-group { margin-bottom: 18px; }
.sb-group-title {
  font-size: 11px;
  color: var(--grey-400);
  text-transform: uppercase;
  letter-spacing: 0.6px;
  font-weight: 600;
  padding: 0 12px;
  margin-bottom: 6px;
}
.sb-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: 6px;
  color: var(--grey-700);
  text-decoration: none;
  font-size: 14px;
  margin-bottom: 2px;
  transition: background 0.1s;
}
.sb-item:hover { background: var(--grey-100); }
.sb-item.active {
  background: var(--green-light);
  color: var(--green-dark);
  font-weight: 600;
}
.sb-icon { font-size: 16px; width: 22px; text-align: center; }

.sb-bottom { margin-top: auto; padding-top: 14px; border-top: 1px solid var(--grey-100); }
.sb-user { padding: 8px 12px 12px; }
.sb-user-name { font-weight: 600; font-size: 13px; }
.sb-user-role { font-size: 11px; color: var(--grey-400); text-transform: uppercase; letter-spacing: 0.5px; }
.sb-logout { color: var(--grey-400); }
.sb-logout:hover { background: var(--red-light); color: var(--red); }

/* Auf Mobile: Sidebar oben, nicht links */
@media (max-width: 800px) {
  body.has-sidebar { flex-direction: column; }
  .sidebar {
    width: 100%; flex: 0 0 auto; height: auto;
    position: static; border-right: none;
    border-bottom: 1px solid var(--grey-200);
    flex-direction: row; flex-wrap: wrap;
    padding: 10px;
  }
  .sb-brand { border-bottom: none; padding: 6px 10px; margin-bottom: 0; width: 100%; }
  .sb-group { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 0; flex: 1 1 100%; }
  .sb-group-title { display: none; }
  .sb-bottom { border-top: none; padding-top: 0; flex: 1 1 100%; display: flex; justify-content: space-between; align-items: center; }
  .sb-user { padding: 4px 10px; }
}

/* Header */
.header {
  background: white;
  border-bottom: 1px solid var(--grey-200);
  padding: 18px 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.header .brand {
  display: flex;
  align-items: center;
  gap: 14px;
}
.header .brand-mark {
  width: 42px; height: 42px;
  background-image: url('logo.svg');
  background-size: contain;
  background-position: center;
  background-repeat: no-repeat;
  font-size: 0;
  color: transparent;
}
.header .brand-text { line-height: 1.15; }
.header .brand-text .name { font-weight: 600; font-size: 15px; }
.header .brand-text .sub { font-size: 12px; color: var(--grey-400); letter-spacing: 0.8px; text-transform: uppercase; }
.header .user-area {
  display: flex; align-items: center; gap: 14px;
  font-size: 14px; color: var(--grey-700);
}
.header .logout {
  color: var(--grey-400);
  text-decoration: none;
  font-size: 13px;
}
.header .logout:hover { color: var(--green); }

/* Layout */
.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 32px;
}
.container-narrow {
  max-width: 480px;
  margin: 0 auto;
  padding: 60px 32px;
}

h1 { font-size: 26px; font-weight: 600; margin-bottom: 8px; }
h2 { font-size: 18px; font-weight: 600; margin-bottom: 12px; }
.lead { color: var(--grey-400); margin-bottom: 28px; }

/* Cards */
.card {
  background: white;
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 24px;
  margin-bottom: 16px;
}

/* Stats row (Praxis dashboard) */
.stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 28px;
}
.stat {
  background: white;
  padding: 18px;
  border-radius: 8px;
  box-shadow: var(--shadow);
}
.stat .label {
  font-size: 12px;
  color: var(--grey-400);
  text-transform: uppercase;
  letter-spacing: 0.6px;
  margin-bottom: 8px;
}
.stat .value { font-size: 24px; font-weight: 600; }
.stat .value.red { color: var(--red); }
.stat .value.orange { color: var(--orange); }
.stat .value.green { color: var(--green-dark); }

/* Table */
table {
  width: 100%;
  border-collapse: collapse;
}
th {
  text-align: left;
  font-size: 12px;
  color: var(--grey-400);
  text-transform: uppercase;
  letter-spacing: 0.6px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--grey-200);
  font-weight: 600;
}
td {
  padding: 16px 14px;
  border-bottom: 1px solid var(--grey-100);
  font-size: 14px;
  vertical-align: middle;
}
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--grey-50); }
tr[data-href] { cursor: pointer; }
tr[data-href]:hover td { background: var(--green-light); }
tr[data-href] td a { color: var(--green-dark); font-weight: 500; }

/* "Geteilte" Zelle: Klick auf Patient-Spalte → Patientenakte,
   Klick auf Rest der Zeile → Rechnungs-Detail */
td.cell-patient { padding: 0; }
td.cell-patient .cell-link {
  display: block;
  padding: 16px 14px;
  color: inherit;
  text-decoration: none;
  height: 100%;
}
td.cell-patient .cell-link strong { color: var(--grey-900); }
tr[data-href]:hover td.cell-patient { background: var(--grey-50); }
tr[data-href] td.cell-patient:hover { background: #d8ebd0 !important; }
tr[data-href] td.cell-patient:hover .cell-link strong {
  color: var(--green-dark);
}

.amount { font-variant-numeric: tabular-nums; font-weight: 500; }
.amount.red { color: var(--red); font-weight: 600; }

/* Status badges */
.badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.3px;
}
.badge.paid { background: var(--green-light); color: var(--green-dark); }
.badge.open { background: var(--grey-100); color: var(--grey-700); }
.badge.overdue { background: var(--red-light); color: var(--red); }
.badge.dunning1 { background: var(--orange-light); color: var(--orange-text); }
.badge.dunning2 { background: var(--red); color: white; }
.badge.collection { background: #4a0000; color: white; }
.badge.cancelled { background: var(--grey-200); color: var(--grey-400); text-decoration: line-through; }
.badge.pending { background: var(--orange-light); color: var(--orange-text); }
.badge.assigned { background: var(--green-light); color: var(--green-dark); }
.badge.rejected { background: var(--grey-200); color: var(--grey-400); }

/* Editierbare Karten: Toggle zwischen Anzeige- und Bearbeiten-Modus */
.editable-card .edit-mode { display: none; }
.editable-card.editing .view-mode { display: none; }
.editable-card.editing .edit-mode { display: block; }
.editable-card.editing .edit-toggle { display: none; }

/* Klickbare Karte: Hover-Effekt */
.clickable-card:hover {
  box-shadow: 0 4px 14px rgba(51,105,106,0.18);
  transform: translateY(-1px);
  transition: all 0.15s;
}

/* PDF Drop-Zone für Drag-and-Drop-Upload */
.drop-zone {
  border: 2px dashed var(--grey-200);
  border-radius: 10px;
  padding: 22px 18px;
  text-align: center;
  background: var(--grey-50);
  transition: all 0.15s;
  cursor: pointer;
  margin-bottom: 18px;
}
.drop-zone:hover { border-color: var(--green); background: var(--green-light); }
.drop-zone.dragover {
  border-color: var(--green);
  background: var(--green-light);
  transform: scale(1.005);
}
.drop-zone .dz-icon { font-size: 28px; margin-bottom: 6px; opacity: 0.6; }
.drop-zone .dz-text { font-weight: 600; color: var(--grey-700); }
.drop-zone .dz-sub { font-size: 13px; color: var(--grey-400); margin-top: 4px; }
.drop-zone input[type="file"] { display: none; }

/* Vollseite-Overlay beim Drag über die Seite */
.drop-overlay {
  position: fixed;
  inset: 0;
  background: rgba(51,105,106,0.18);
  border: 4px dashed var(--green);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  pointer-events: none;
}
.drop-overlay.active { display: flex; }
.drop-overlay .drop-msg {
  background: white;
  border-radius: 10px;
  padding: 28px 40px;
  font-size: 18px;
  font-weight: 600;
  color: var(--green-dark);
  box-shadow: 0 8px 24px rgba(0,0,0,0.16);
}

/* Upload-Liste */
.upload-list { margin-bottom: 20px; }
.upload-row {
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  gap: 14px;
  align-items: center;
  padding: 10px 14px;
  border: 1px solid var(--grey-200);
  border-radius: 8px;
  background: white;
  margin-bottom: 6px;
  font-size: 13px;
}
.upload-row.pending { border-left: 4px solid var(--orange); background: var(--orange-light); }
.upload-row.assigned { border-left: 4px solid var(--green); }
.upload-row.rejected { border-left: 4px solid var(--grey-400); opacity: 0.7; }
.upload-row .ur-icon { font-size: 18px; }
.upload-row .ur-meta { color: var(--grey-400); font-size: 11px; margin-top: 2px; }
.upload-row .ur-action { font-size: 12px; }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 16px;
  border-radius: 6px;
  border: none;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  font-family: inherit;
}
.btn-primary {
  background: var(--green);
  color: white;
}
.btn-primary:hover { background: var(--green-dark); }
.btn-secondary {
  background: var(--grey-100);
  color: var(--grey-700);
}
.btn-secondary:hover { background: var(--grey-200); }
.btn-link {
  background: transparent;
  color: var(--green);
  padding: 4px 0;
}
.btn-block { width: 100%; justify-content: center; padding: 12px 16px; }

/* Form */
.form-group { margin-bottom: 18px; }
.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--grey-700);
  margin-bottom: 6px;
}
.form-group input, .form-group textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--grey-200);
  border-radius: 6px;
  font-size: 15px;
  font-family: inherit;
}
.form-group input:focus, .form-group textarea:focus {
  outline: none;
  border-color: var(--green);
  box-shadow: 0 0 0 3px var(--green-light);
}
/* 13px statt 12px: Die Klasse traegt fast den gesamten Erklaertext fuer
   Patienten, und viele von ihnen sind aeltere Menschen. */
.hint { font-size: 13px; color: var(--grey-400); margin-top: 6px; }

/* Warnings */
.warning {
  padding: 14px 16px;
  border-radius: 6px;
  font-size: 14px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 16px;
}
.warning-red {
  background: var(--red-light);
  color: var(--red);
  border-left: 4px solid var(--red);
}
/* Erfolgsmeldungen. Diese Klasse wurde in mehreren Vorlagen verwendet,
   war hier aber nie definiert — die Meldung erschien als unformatierter
   grauer Fliesstext mit einem Haekchen davor und ging neben den korrekt
   eingefaerbten Kaesten unter. */
.warning-green {
  background: var(--green-light);
  color: var(--green-dark);
  border-left: 4px solid var(--green);
}
.warning-orange {
  background: var(--orange-light);
  color: var(--orange-text);
  border-left: 4px solid var(--orange);
}
.warning .icon { font-size: 16px; line-height: 1.4; }

/* Filter bar */
.filters {
  display: flex;
  gap: 10px;
  margin-bottom: 10px;
  flex-wrap: wrap;
  align-items: center;
}
.filters input, .filters select {
  padding: 8px 12px;
  border: 1px solid var(--grey-200);
  border-radius: 6px;
  font-size: 14px;
  font-family: inherit;
  background: white;
}
.filters input { flex: 1; min-width: 220px; }
.filter-clear {
  padding: 6px 12px;
  border: none;
  background: transparent;
  color: var(--grey-400);
  cursor: pointer;
  font-size: 13px;
  font-family: inherit;
}
.filter-clear:hover { color: var(--red); }
.filter-count {
  font-size: 12px;
  color: var(--grey-400);
  margin-bottom: 12px;
  margin-left: 4px;
}

/* Detail page */
.invoice-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 20px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--grey-100);
}
.invoice-meta {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px 28px;
  margin-bottom: 20px;
}
.invoice-meta .meta-label {
  font-size: 12px;
  color: var(--grey-400);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 2px;
}
.invoice-meta .meta-value { font-size: 16px; font-weight: 500; }
.invoice-meta .meta-value.red { color: var(--red); }
.invoice-meta .meta-value.big { font-size: 22px; font-weight: 600; }

.notes-section { margin-top: 18px; }
.note {
  padding: 12px 14px;
  border-radius: 6px;
  background: var(--grey-50);
  margin-bottom: 10px;
  font-size: 14px;
}
.note .note-meta {
  font-size: 12px;
  color: var(--grey-400);
  margin-bottom: 4px;
}
.note.from-praxis { background: var(--green-light); }
.note.from-praxis .note-meta { color: var(--green-dark); font-weight: 600; }

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--grey-400);
  text-decoration: none;
  font-size: 14px;
  margin-bottom: 16px;
}
.back-link:hover { color: var(--green); }

/* Breadcrumb-Navigation: Pfad mit klickbaren Buttons */
.breadcrumbs {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  align-items: center;
  margin-bottom: 16px;
  font-size: 13px;
}
.breadcrumbs .bc-item {
  padding: 4px 10px;
  border-radius: 5px;
  text-decoration: none;
  transition: all 0.12s;
  white-space: nowrap;
}
.breadcrumbs a.bc-item {
  color: var(--green-dark);
  background: var(--grey-100);
}
.breadcrumbs a.bc-item:hover {
  background: var(--green-light);
  color: var(--green-dark);
}
.breadcrumbs .bc-current {
  color: var(--grey-700);
  font-weight: 600;
  background: transparent;
  padding-left: 4px;
}
.breadcrumbs .bc-sep {
  color: var(--grey-400);
  font-size: 12px;
  user-select: none;
}

/* Zahlungsabgleich: Upload-Bereich */
.upload-area {
  border: 2px dashed var(--grey-200);
  border-radius: 8px;
  padding: 30px;
  text-align: center;
  background: var(--grey-50);
  transition: all 0.2s;
}
.upload-area:hover {
  border-color: var(--green);
  background: var(--green-light);
}
.upload-area .upload-icon { font-size: 36px; margin-bottom: 8px; opacity: 0.5; }
.upload-area .upload-text { color: var(--grey-700); margin-bottom: 6px; font-weight: 500; }
.upload-area .upload-sub { color: var(--grey-400); font-size: 13px; }

/* Match-Badges (interne Sicht) */
.match {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}
.match.exact   { background: var(--green-light); color: var(--green-dark); }
.match.likely  { background: var(--orange-light); color: var(--orange-text); }
.match.partial { background: var(--orange-light); color: var(--orange-text); }
.match.none    { background: var(--red-light); color: var(--red); }
.match.ambig   { background: var(--red-light); color: var(--red); }
.match.ignore  { background: var(--grey-100); color: var(--grey-400); }
.match.confirmed { background: var(--green); color: white; }

/* Internal-only Hinweis */
.internal-banner {
  background: linear-gradient(90deg, #fff8e6 0%, #fef0d4 100%);
  border-left: 4px solid #d9a200;
  padding: 14px 18px;
  border-radius: 6px;
  margin-bottom: 20px;
  font-size: 14px;
  color: #6b5000;
}
.internal-banner strong { color: #4a3800; }

/* Inline action select */
.row-action {
  padding: 4px 8px;
  font-size: 12px;
  border: 1px solid var(--grey-200);
  border-radius: 4px;
  background: white;
  cursor: pointer;
  font-family: inherit;
}
.row-action:hover { border-color: var(--green); }

/* Zuordnungs-Seite: zwei-spaltiges Layout */
.assignment-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  align-items: start;
}
@media (max-width: 900px) {
  .assignment-grid { grid-template-columns: 1fr; }
}

.pdf-preview {
  background: white;
  border: 1px solid var(--grey-200);
  border-radius: 8px;
  padding: 14px;
  box-shadow: var(--shadow);
}
.pdf-preview .pdf-frame {
  background: var(--grey-50);
  border: 1px dashed var(--grey-200);
  border-radius: 6px;
  height: 540px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--grey-400);
  font-size: 13px;
  text-align: center;
  padding: 20px;
  margin-bottom: 12px;
}
.pdf-preview .pdf-meta {
  font-size: 12px;
  color: var(--grey-400);
}

/* Queue-Liste (oben auf der Zuordnungsseite) */
.queue {
  display: flex;
  gap: 8px;
  margin-bottom: 18px;
  overflow-x: auto;
  padding-bottom: 4px;
}
.queue-item {
  flex: 0 0 auto;
  padding: 10px 14px;
  border: 1px solid var(--grey-200);
  border-radius: 6px;
  background: white;
  cursor: pointer;
  font-size: 13px;
  min-width: 180px;
}
.queue-item:hover { border-color: var(--green); }
.queue-item.active {
  border-color: var(--green);
  background: var(--green-light);
}
.queue-item .qi-type {
  font-size: 11px;
  color: var(--grey-400);
  text-transform: uppercase;
  letter-spacing: 0.4px;
  margin-bottom: 4px;
}
.queue-item .qi-name { font-weight: 600; }
.queue-item .qi-sub { font-size: 12px; color: var(--grey-400); margin-top: 2px; }

/* Extracted-Box */
.extracted {
  background: var(--grey-50);
  padding: 14px;
  border-radius: 6px;
  margin-bottom: 16px;
  font-size: 13px;
}
.extracted dl {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 6px 14px;
  margin: 0;
}
.extracted dt { color: var(--grey-400); }
.extracted dd { font-weight: 500; margin: 0; }

/* Auswahl-Liste (Patienten / Rechnungen) */
.option-list {
  border: 1px solid var(--grey-200);
  border-radius: 6px;
  max-height: 220px;
  overflow-y: auto;
}
.option-list .option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--grey-100);
  cursor: pointer;
  font-size: 14px;
}
.option-list .option:last-child { border-bottom: none; }
.option-list .option:hover { background: var(--grey-50); }
.option-list .option.selected { background: var(--green-light); }
.option-list .option input[type="radio"] { accent-color: var(--green); }
.option .option-main { flex: 1; }
.option .option-sub { font-size: 12px; color: var(--grey-400); margin-top: 2px; }

.action-bar {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--grey-100);
}

/* Document links inside table cells */
.doc-list {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}
.doc-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 9px;
  font-size: 12px;
  font-weight: 500;
  background: var(--grey-100);
  color: var(--grey-700);
  text-decoration: none;
  border-radius: 4px;
  white-space: nowrap;
}
.doc-link:hover { background: var(--green); color: white; }
.doc-link.warn { background: var(--orange-light); color: var(--orange-text); }
.doc-link.warn:hover { background: var(--orange); color: white; }
.doc-link.danger { background: var(--red-light); color: var(--red); }
.doc-link.danger:hover { background: var(--red); color: white; }

/* Timeline (for detail view) */
.timeline { margin-top: 8px; }
.timeline-item {
  display: grid;
  grid-template-columns: 130px 1fr auto;
  gap: 14px;
  padding: 14px 0;
  border-bottom: 1px solid var(--grey-100);
  align-items: center;
}
.timeline-item:last-child { border-bottom: none; }
.timeline-date {
  font-size: 12px;
  color: var(--grey-400);
  text-transform: uppercase;
  letter-spacing: 0.4px;
}
.timeline-title { font-weight: 500; font-size: 14px; }
.timeline-sub { font-size: 12px; color: var(--grey-400); margin-top: 2px; }
.timeline-sub.red { color: var(--red); }

/* Dokumenten-Aktionen (Bearbeiten-Menü neben jedem Dokument) */
.timeline-item-row { margin-bottom: 4px; }
.timeline-item-row.active .timeline-item {
  background: #eef4fd;
  border-radius: 6px;
  padding-left: 12px;
  padding-right: 12px;
}
.timeline-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}
.dok-action-wrapper {
  position: relative;
  display: inline-block;
}
.dok-action-btn {
  background: transparent;
  border: 1px solid var(--grey-200);
  width: 32px;
  height: 32px;
  border-radius: 6px;
  font-size: 18px;
  cursor: pointer;
  color: var(--grey-400);
  margin-left: 6px;
}
.dok-action-btn:hover { background: var(--grey-100); color: var(--grey-700); border-color: var(--grey-400); }
.dok-action-menu {
  position: absolute;
  top: 100%; right: 0;
  background: white;
  border: 1px solid var(--grey-200);
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.12);
  min-width: 180px;
  padding: 4px;
  display: none;
  z-index: 50;
  margin-top: 4px;
}
.dok-action-wrapper.open .dok-action-menu { display: block; }
.dok-action-item {
  display: block;
  width: 100%;
  text-align: left;
  background: transparent;
  border: none;
  padding: 8px 12px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 13px;
  color: var(--grey-700);
}
.dok-action-item:hover { background: var(--grey-50); }
.dok-action-item.danger { color: var(--red); }
.dok-action-item.danger:hover { background: var(--red-light); }

.dok-inline-form {
  display: none;
  background: var(--grey-50);
  padding: 12px 14px;
  border-radius: 6px;
  margin-top: 4px;
  border-left: 3px solid var(--green);
}
.dok-inline-form.open { display: block; }
.dok-inline-form[id*="delete"] { border-left-color: var(--red); }
.dok-inline-form[id*="move"] { border-left-color: #2d8ec5; }

/* Aktuellstes Dokument (oben) hervorheben: fett + blau */
.timeline-item.active .timeline-date,
.timeline-item.active .timeline-title,
.timeline-item.active .timeline-sub {
  color: #1e5fb8;
  font-weight: 700;
}
.timeline-item.active .timeline-title { font-size: 15px; }
/* Hinweis: .timeline-item.active style ist jetzt in .timeline-item-row.active definiert */

/* Mockup navigation strip (only for preview) */
.mockup-nav {
  background: var(--grey-900);
  color: white;
  padding: 10px 20px;
  font-size: 12px;
  display: flex;
  gap: 18px;
  align-items: center;
}
.mockup-nav .label { color: var(--grey-400); }
.mockup-nav a { color: white; text-decoration: none; padding: 4px 10px; border-radius: 4px; }
.mockup-nav a.active { background: var(--green); }
.mockup-nav a:hover { background: var(--grey-700); }
.mockup-nav a.active:hover { background: var(--green-dark); }

/* ===================================================================
   Handy-Darstellung
   Patienten öffnen das Portal überwiegend auf dem Handy (Link aus der
   Benachrichtigungs-Mail). Ohne diese Regeln blieben die Kennzahl-Kacheln
   vierspaltig und der Seitenrand fräße ein Sechstel der Bildschirmbreite.
   =================================================================== */
@media (max-width: 700px) {
  .container { padding: 20px 14px; }
  .container-narrow { padding: 32px 16px; }

  /* Kennzahlen: 4 Spalten -> 2, sonst je ~78 px auf einem 375-px-Display */
  .stats { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .stat .value { font-size: 20px; }

  h1 { font-size: 22px; }

  /* Breite Tabellen dürfen scrollen statt die Seite zu sprengen.
     `min-width` allein genügt nicht — ohne scrollenden Rahmen bläht es die
     Tabelle nur auf und schiebt die Seite seitlich weg. Die meisten Vorlagen
     setzen den Rahmen selbst; wo er fehlte (Jahresbescheinigung, Inkasso,
     Prüfprotokoll, Mitarbeiterliste, Aufbewahrung, Aufgabenliste), lief die
     Seite über. Die Karte übernimmt das jetzt zentral. */
  .card { overflow-x: auto; }
  .card > table,
  .card > div > table { min-width: 460px; }

  /* Zweispaltige Formular-Raster (Einstellungen) untereinander */
  .form-grid-2 { grid-template-columns: 1fr !important; }
}

@media (max-width: 420px) {
  .stats { grid-template-columns: 1fr; }
}
