/* ── Reset & base ─────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-light: #eff6ff;
  --danger: #dc2626;
  --danger-light: #fef2f2;
  --success: #16a34a;
  --success-light: #f0fdf4;
  --warning: #d97706;
  --warning-light: #fffbeb;
  --gray-50: #f8fafc;
  --gray-100: #f1f5f9;
  --gray-200: #e2e8f0;
  --gray-300: #cbd5e1;
  --gray-400: #94a3b8;
  --gray-500: #64748b;
  --gray-600: #475569;
  --gray-700: #334155;
  --gray-800: #1e293b;
  --gray-900: #0f172a;
  --sidebar-w: 240px;
  --header-h: 56px;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,.12), 0 1px 2px rgba(0,0,0,.08);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,.1), 0 2px 4px -1px rgba(0,0,0,.06);
}
html, body { height: 100%; font-family: system-ui, -apple-system, sans-serif; font-size: 14px; color: var(--gray-800); background: var(--gray-50); }

/* ── Auth layout ─────────────────────────────────────────────────────── */
.auth-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg, #1e3a5f 0%, #2563eb 100%); }
.auth-card { background: #fff; border-radius: 16px; padding: 40px; width: 100%; max-width: 420px; box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.auth-logo { text-align: center; margin-bottom: 28px; }
.auth-logo .logo-icon { font-size: 3rem; }
.auth-logo h1 { font-size: 1.5rem; font-weight: 700; color: var(--gray-900); margin-top: 8px; }
.auth-logo .auth-subtitle { color: var(--gray-500); font-size: .875rem; margin-top: 4px; }
.auth-form h2 { font-size: 1.2rem; font-weight: 600; margin-bottom: 20px; color: var(--gray-800); }
.auth-footer { text-align: center; margin-top: 20px; font-size: .875rem; color: var(--gray-500); }
.auth-footer a { color: var(--primary); text-decoration: none; }
.auth-footer a:hover { text-decoration: underline; }
.admin-link { margin-top: 8px; }
.admin-link a { color: var(--gray-400); font-size: .8rem; }

/* ── App layout ─────────────────────────────────────────────────────── */
.app-layout { display: flex; height: 100vh; overflow: hidden; }
.sidebar { width: var(--sidebar-w); background: var(--gray-900); color: #fff; display: flex; flex-direction: column; flex-shrink: 0; overflow-y: auto; }
.sidebar-brand { padding: 20px 16px 12px; border-bottom: 1px solid rgba(255,255,255,.08); }
.sidebar-brand .brand-icon { font-size: 1.5rem; }
.sidebar-brand h2 { font-size: 1rem; font-weight: 700; color: #fff; margin-top: 6px; line-height: 1.2; }
.sidebar-brand .brand-sub { font-size: .65rem; font-weight: 400; opacity: .55; letter-spacing: .08em; text-transform: uppercase; }
.dev-badge { display: inline-block; margin-top: 8px; padding: 2px 8px; background: #f59e0b; color: #000; font-size: .65rem; font-weight: 700; letter-spacing: .1em; border-radius: 4px; text-transform: uppercase; }
.sidebar nav { flex: 1; padding: 12px 0; }
.nav-section { padding: 16px 16px 4px; font-size: .65rem; font-weight: 600; text-transform: uppercase; letter-spacing: .08em; color: var(--gray-500); }

/* Collapsible-Sidebar-Sektionen: <details>/<summary> nativ, mit gleichem
   Look-and-Feel wie die alten statischen nav-section-Headings. Der Default-
   Browser-Marker (▶) wird entfernt; stattdessen zeigen wir einen eigenen
   Caret rechts in der Zeile, der bei geöffneter Sektion nach unten zeigt. */
.nav-group { border: 0; padding: 0; margin: 0; }
.nav-group > summary.nav-section {
  cursor: pointer;
  list-style: none;          /* Firefox */
  user-select: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  transition: color .15s, background .15s;
}
.nav-group > summary.nav-section::-webkit-details-marker { display: none; }  /* Chrome/Safari */
.nav-group > summary.nav-section::after {
  content: '▸';
  font-size: .75rem;
  transition: transform .15s;
  opacity: .6;
}
.nav-group[open] > summary.nav-section::after { transform: rotate(90deg); }
.nav-group > summary.nav-section:hover { color: var(--gray-300); background: rgba(255,255,255,.04); }
.nav-item { display: flex; align-items: center; gap: 10px; padding: 9px 16px; color: var(--gray-400); text-decoration: none; font-size: .875rem; border-radius: 0; cursor: pointer; border: none; background: none; width: 100%; text-align: left; transition: color .15s, background .15s; }
.nav-item:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav-item.active { background: var(--primary); color: #fff; }
.nav-item .nav-icon { width: 18px; text-align: center; flex-shrink: 0; }
.nav-item.nav-sub { padding-left: 36px; font-size: .82rem; opacity: .85; }
.nav-item.nav-sub::before { content: '↳'; margin-right: 6px; opacity: .5; font-size: .75rem; }
.sidebar-footer { padding: 12px 16px; border-top: 1px solid rgba(255,255,255,.08); }
.sidebar-user { display: flex; align-items: center; gap: 10px; padding: 8px 0; }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--primary); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: .75rem; flex-shrink: 0; }
.sidebar-user .user-info .name { font-size: .85rem; font-weight: 600; color: #fff; }
.sidebar-user .user-info .role { font-size: .72rem; color: var(--gray-400); }
.logout-btn { display: flex; align-items: center; gap: 8px; padding: 8px 0; color: var(--gray-400); cursor: pointer; font-size: .8rem; background: none; border: none; width: 100%; }
.logout-btn:hover { color: #fff; }

.main-area { flex: 1; display: flex; flex-direction: column; overflow: hidden; }
.topbar { height: var(--header-h); background: #fff; border-bottom: 1px solid var(--gray-200); display: flex; align-items: center; padding: 0 24px; gap: 12px; flex-shrink: 0; box-shadow: var(--shadow); }
.topbar h1 { font-size: 1.1rem; font-weight: 600; color: var(--gray-900); flex: 1; }
.content { flex: 1; overflow-y: auto; padding: 24px; }

/* ── Cards & grid ─────────────────────────────────────────────────────── */
.card { background: #fff; border-radius: var(--radius); border: 1px solid var(--gray-200); box-shadow: var(--shadow); }
.card-header { padding: 16px 20px; border-bottom: 1px solid var(--gray-200); display: flex; align-items: center; gap: 12px; }
.card-header h3 { font-size: 1rem; font-weight: 600; flex: 1; }
.card-body { padding: 20px; }
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat-card { background: #fff; border-radius: var(--radius); border: 1px solid var(--gray-200); padding: 20px; box-shadow: var(--shadow); display: flex; align-items: center; gap: 16px; cursor: pointer; transition: box-shadow .15s, transform .15s; }
.stat-card:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }
.stat-icon { width: 48px; height: 48px; border-radius: 12px; display: flex; align-items: center; justify-content: center; font-size: 1.4rem; flex-shrink: 0; }
.stat-icon.blue { background: #dbeafe; }
.stat-icon.green { background: #dcfce7; }
.stat-icon.orange { background: #fef3c7; }
.stat-icon.purple { background: #f3e8ff; }
.stat-value { font-size: 1.8rem; font-weight: 700; color: var(--gray-900); line-height: 1; }
.stat-label { font-size: .8rem; color: var(--gray-500); margin-top: 2px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 768px) { .grid-2 { grid-template-columns: 1fr; } }

/* ── Forms ─────────────────────────────────────────────────────────────── */
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: .85rem; font-weight: 500; color: var(--gray-700); margin-bottom: 6px; }
.form-group input, .form-group select, .form-group textarea {
  width: 100%; padding: 9px 12px; border: 1px solid var(--gray-300); border-radius: var(--radius);
  font-size: .9rem; color: var(--gray-800); background: #fff; outline: none; transition: border-color .15s, box-shadow .15s;
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
  border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,.15);
}
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 600px) { .form-row { grid-template-columns: 1fr; } }

/* Kompakte Input+Button-Zeile (z.B. wiederholbare Listen-Einträge ohne Label).
   Inputs darin bekommen dasselbe Styling wie .form-group input. */
.form-row-inline { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.form-row-inline input:not([type="checkbox"]):not([type="radio"]),
.form-row-inline select,
.form-row-inline textarea {
  flex: 1; padding: 9px 12px; border: 1px solid var(--gray-300); border-radius: var(--radius);
  font-size: .9rem; color: var(--gray-800); background: #fff; outline: none; transition: border-color .15s, box-shadow .15s;
}
.form-row-inline input:focus, .form-row-inline select:focus, .form-row-inline textarea:focus {
  border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,.15);
}

/* Inputs innerhalb der KI-Datenprofil-Tabelle bekommen das gleiche Styling
   wie .form-group-Inputs, da sie sonst als nackte Browser-Defaults erscheinen. */
#kidTable input[type="text"], #kidTable input[type="number"], #kidTable select {
  width: 100%; padding: 6px 10px; border: 1px solid var(--gray-300); border-radius: var(--radius);
  font-size: .85rem; color: var(--gray-800); background: #fff; outline: none;
  transition: border-color .15s, box-shadow .15s;
}
#kidTable input[type="text"]:focus, #kidTable input[type="number"]:focus, #kidTable select:focus {
  border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,.15);
}
#kidTable input[type="number"] { width: 80px; }
#kidTable select { width: auto; min-width: 0; padding-right: 28px; }
#kidTable td { vertical-align: middle; }


/* ── Buttons ─────────────────────────────────────────────────────────────── */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 9px 16px; border-radius: var(--radius); font-size: .875rem; font-weight: 500; cursor: pointer; border: 1px solid transparent; transition: all .15s; text-decoration: none; white-space: nowrap; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-primary:hover:not(:disabled) { background: var(--primary-dark); border-color: var(--primary-dark); }
.btn-secondary { background: #fff; color: var(--gray-700); border-color: var(--gray-300); }
.btn-secondary:hover:not(:disabled) { background: var(--gray-50); border-color: var(--gray-400); }
.btn-danger { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-danger:hover:not(:disabled) { background: #b91c1c; }
.btn-success { background: var(--success); color: #fff; border-color: var(--success); }
.btn-success:hover:not(:disabled) { background: #15803d; }
.btn-sm { padding: 5px 10px; font-size: .8rem; }
.btn-full { width: 100%; justify-content: center; }
.btn-icon { padding: 6px 8px; }

/* ── Alerts ─────────────────────────────────────────────────────────────── */
.alert { padding: 12px 16px; border-radius: var(--radius); font-size: .875rem; margin-bottom: 16px; }
.alert-error { background: var(--danger-light); color: var(--danger); border: 1px solid #fca5a5; }
.alert-success { background: var(--success-light); color: var(--success); border: 1px solid #86efac; }
.alert-warning { background: var(--warning-light); color: var(--warning); border: 1px solid #fcd34d; }
.alert-info { background: var(--primary-light); color: var(--primary); border: 1px solid #93c5fd; }

/* ── Table ─────────────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .875rem; }
thead th { padding: 10px 14px; text-align: left; font-size: .75rem; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--gray-500); background: var(--gray-50); border-bottom: 1px solid var(--gray-200); }
tbody td { padding: 12px 14px; border-bottom: 1px solid var(--gray-100); vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: var(--gray-50); }

/* ── Badges ─────────────────────────────────────────────────────────────── */
.badge { display: inline-flex; align-items: center; padding: 2px 8px; border-radius: 99px; font-size: .72rem; font-weight: 600; }
.badge-blue { background: #dbeafe; color: #1e40af; }
.badge-green { background: #dcfce7; color: #166534; }
.badge-red { background: #fee2e2; color: #991b1b; }
.badge-orange { background: #fef3c7; color: #92400e; }
.badge-purple { background: #f3e8ff; color: #6b21a8; }
.badge-gray { background: var(--gray-100); color: var(--gray-600); }
.badge-yellow { background: #fef9c3; color: #854d0e; }

/* ── Modal ─────────────────────────────────────────────────────────────── */
.modal-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 100; display: flex; align-items: center; justify-content: center; padding: 16px; }
.modal { background: #fff; border-radius: 12px; width: 100%; max-width: 520px; max-height: 90vh; overflow-y: auto; box-shadow: 0 25px 50px rgba(0,0,0,.25); }
.modal-header { padding: 20px 24px 16px; border-bottom: 1px solid var(--gray-200); display: flex; align-items: center; justify-content: space-between; }
.modal-header h3 { font-size: 1.1rem; font-weight: 600; }
.modal-close { background: none; border: none; font-size: 1.3rem; cursor: pointer; color: var(--gray-400); padding: 4px; border-radius: 4px; }
.modal-close:hover { color: var(--gray-700); background: var(--gray-100); }
.modal-body { padding: 20px 24px; }
.modal-footer { padding: 16px 24px; border-top: 1px solid var(--gray-200); display: flex; gap: 10px; justify-content: flex-end; }

/* ── Misc ─────────────────────────────────────────────────────────────── */
.toolbar { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; }
.search-input { padding: 8px 12px; border: 1px solid var(--gray-300); border-radius: var(--radius); font-size: .875rem; width: 240px; outline: none; }
.search-input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,.15); }
.empty-state { text-align: center; padding: 48px 24px; color: var(--gray-400); }
.empty-state .empty-icon { font-size: 2.5rem; margin-bottom: 12px; }
.empty-state p { font-size: .9rem; }
.spinner { display: inline-block; width: 20px; height: 20px; border: 2px solid var(--gray-200); border-top-color: var(--primary); border-radius: 50%; animation: spin .6s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.loading-overlay { display: flex; align-items: center; justify-content: center; padding: 48px; }
.text-muted { color: var(--gray-400); }
.text-sm { font-size: .8rem; }
.gap-1 { gap: 4px; }
.flex { display: flex; }
.items-center { align-items: center; }
.flex-wrap { flex-wrap: wrap; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
hr { border: none; border-top: 1px solid var(--gray-200); margin: 16px 0; }
.section-title { font-size: .9rem; font-weight: 600; color: var(--gray-700); margin-bottom: 12px; display: flex; align-items: center; gap: 8px; }
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 24px; }
.detail-row { padding: 8px 0; border-bottom: 1px solid var(--gray-100); }
.detail-label { font-size: .75rem; font-weight: 500; color: var(--gray-500); text-transform: uppercase; letter-spacing: .04em; margin-bottom: 2px; }
.detail-value { font-size: .9rem; color: var(--gray-800); }

/* ── Mobile-First: Burger, Drawer, Topbar-Avatar ────────────────────────── */
.burger {
  display: none;
  width: 44px; height: 44px;
  align-items: center; justify-content: center;
  background: none; border: none; cursor: pointer;
  color: var(--gray-700); font-size: 1.4rem;
  border-radius: var(--radius);
  flex-shrink: 0;
}
.burger:hover { background: var(--gray-100); }
.topbar-user { display: flex; align-items: center; gap: 8px; }
.sidebar-backdrop { display: none; }

/* Card-Liste – Alternative zu Tabellen auf Mobile (opt-in per .swap-mobile) */
.card-list { display: none; flex-direction: column; gap: 10px; }
.list-item {
  background: #fff; border: 1px solid var(--gray-200); border-radius: var(--radius);
  padding: 14px; box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: 6px;
}
.list-item .li-title { font-weight: 600; color: var(--gray-900); display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; }
.list-item .li-sub { font-size: .8rem; color: var(--gray-500); }
.list-item .li-meta { display: flex; gap: 10px; font-size: .78rem; color: var(--gray-600); flex-wrap: wrap; margin-top: 4px; }

@media (max-width: 767px) {
  .sidebar {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    width: min(280px, 85vw);
    z-index: 110;
    transform: translateX(-100%);
    transition: transform .22s ease;
    box-shadow: 0 10px 40px rgba(0,0,0,.4);
  }
  .sidebar.is-open { transform: translateX(0); }

  .sidebar-backdrop {
    display: block;
    position: fixed; inset: 0;
    background: rgba(0,0,0,.5);
    z-index: 100;
    opacity: 0; pointer-events: none;
    transition: opacity .22s ease;
  }
  .sidebar-backdrop.is-open { opacity: 1; pointer-events: auto; }

  .burger { display: inline-flex; }
  .topbar { padding: 0 12px; gap: 8px; }
  .topbar h1 { font-size: 1rem; }

  .nav-item { min-height: 44px; padding: 12px 16px; }
  .logout-btn { min-height: 44px; }

  .content { padding: 14px; }

  .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 16px; }
  .stat-card { padding: 12px; gap: 10px; }
  .stat-icon { width: 40px; height: 40px; font-size: 1.2rem; }
  .stat-value { font-size: 1.35rem; }

  .card-header { padding: 14px 16px; }
  .card-body { padding: 16px; }

  .toolbar { gap: 8px; }
  .search-input { width: 100%; }

  .swap-mobile .table-wrap { display: none; }
  .swap-mobile .card-list { display: flex; }

  /* Tabellen auf Mobile: Zeilen vertikal stapeln (Zeile = Mini-Karte) */
  .table-wrap { overflow-x: visible; }
  .table-wrap table,
  .table-wrap tbody,
  .table-wrap tr { display: block; width: 100%; }
  .table-wrap thead { display: none; }
  .table-wrap tr {
    padding: 12px 14px;
    border-bottom: 1px solid var(--gray-200);
  }
  .table-wrap tbody tr:last-child { border-bottom: none; }
  .table-wrap tbody tr:hover td { background: transparent; }
  .table-wrap td {
    display: block;
    border: none !important;
    padding: 3px 0 !important;
    font-size: .85rem;
  }
  .table-wrap td:first-child {
    font-weight: 600; font-size: 1rem; color: var(--gray-900);
    margin-bottom: 4px;
  }
  .table-wrap td:last-child {
    margin-top: 8px;
    padding-top: 10px !important;
    border-top: 1px solid var(--gray-100) !important;
    display: flex; gap: 6px; flex-wrap: wrap;
  }
  .table-wrap td[colspan] { text-align: left; }

  input, select, textarea { font-size: 16px; }

  .modal-backdrop { padding: 0; }
  .modal { border-radius: 0; max-width: 100%; max-height: 100vh; height: 100vh; }
  .modal-footer { position: sticky; bottom: 0; background: #fff; }

  .auth-card { padding: 28px 20px; border-radius: 12px; }
}

@media (min-width: 768px) {
  .sidebar { transform: none !important; }
}

/* ── Passwort-Feld mit Show/Hide-Button ─────────────────────────────────── */
.pw-wrap { position: relative; display: block; }
.pw-wrap input { padding-right: 40px; width: 100%; }
.pw-toggle {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  background: transparent;
  border: none;
  cursor: pointer;
  font-size: 1.15rem;
  line-height: 1;
  padding: 6px 8px;
  color: var(--gray-500);
  border-radius: 4px;
}
.pw-toggle:hover { color: var(--gray-700); background: var(--gray-100); }
.pw-toggle:focus-visible { outline: 2px solid var(--primary); outline-offset: 1px; }

/* ── Dashboard / Detail / Profil — UI-Konzept (v2) ────────────────────── */

/* Begrüßungsbanner oben auf Dashboards */
.dash-greeting {
  background: linear-gradient(135deg, #1e3a5f, #2563eb);
  color: #fff;
  padding: 20px 24px;
  border-radius: var(--radius);
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 16px;
}
.dash-greeting .av {
  width: 48px; height: 48px; border-radius: 50%;
  background: rgba(255,255,255,.2);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700;
}
.dash-greeting .name { font-size: 1.1rem; font-weight: 600; }
.dash-greeting .sub { font-size: .85rem; opacity: .85; margin-top: 4px; }
.dash-greeting .pill {
  background: rgba(255,255,255,.15);
  padding: 4px 10px;
  border-radius: 99px;
  font-size: .8rem;
}

/* Zonen-Überschrift (klein, kapitalisiert) */
.dash-zone-title {
  font-size: .85rem;
  font-weight: 600;
  color: var(--gray-500);
  text-transform: uppercase;
  letter-spacing: .05em;
  margin: 24px 0 10px;
}

/* Aufgaben-Reihe (oranger Akzent) */
.dash-task-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
}
.dash-task-card {
  background: #fff;
  border: 1px solid var(--gray-200);
  border-left: 4px solid #f59e0b;
  border-radius: var(--radius);
  padding: 14px 16px;
  cursor: pointer;
  transition: all .15s;
  display: flex;
  align-items: center;
  gap: 12px;
}
.dash-task-card:hover {
  border-color: #f59e0b;
  box-shadow: 0 0 0 3px rgba(245,158,11,.15);
}
.dash-task-card.urgent { border-left-color: #dc2626; }
.dash-task-card .icon { font-size: 1.6rem; }
.dash-task-card .body { flex: 1; min-width: 0; }
.dash-task-card .count { font-size: 1.4rem; font-weight: 700; line-height: 1; }
.dash-task-card .label { color: var(--gray-600); font-size: .85rem; margin-top: 2px; }
.dash-task-card .arrow { color: var(--gray-400); font-size: 1.2rem; }

/* Praxis-Karte mit eingebetteten Service-Kacheln */
.dash-practice-card {
  background: #fff;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
}
.dash-practice-head {
  display: flex; align-items: center; gap: 12px;
  margin-bottom: 16px; padding-bottom: 14px;
  border-bottom: 1px solid var(--gray-100);
}
.dash-practice-head h2 { font-size: 1.15rem; margin: 0; flex: 1; }

.dash-service-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 10px;
}
.dash-service-tile {
  background: var(--gray-50);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 12px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  transition: all .15s;
}
.dash-service-tile:hover { border-color: var(--primary); background: #fff; }
.dash-service-tile .ic { font-size: 1.4rem; }
.dash-service-tile .info { flex: 1; min-width: 0; }
.dash-service-tile .name {
  font-size: .78rem; color: var(--gray-500);
  text-transform: uppercase; letter-spacing: .05em;
}
.dash-service-tile .status {
  display: flex; align-items: center; gap: 6px; margin-top: 4px;
  flex-wrap: wrap;
}
.dash-service-tile .arrow { color: var(--gray-400); }

/* Bestand-Reihe (kleine, neutrale Stat-Kacheln unten) */
.dash-bestand-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 10px;
}
.dash-bestand-tile {
  background: #fff;
  border: 1px solid var(--gray-100);
  border-radius: var(--radius);
  padding: 12px 14px;
  text-align: center;
}
.dash-bestand-tile .num { font-size: 1.4rem; font-weight: 600; }
.dash-bestand-tile .lbl { font-size: .78rem; color: var(--gray-500); }

/* Praxen-Tabelle (Admin-Dashboard, Listen-Seiten) */
.dash-practice-tbl {
  width: 100%;
  background: #fff;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  border-collapse: collapse;
  overflow: hidden;
}
.dash-practice-tbl th, .dash-practice-tbl td {
  padding: 10px 14px;
  text-align: left;
  border-bottom: 1px solid var(--gray-100);
  font-size: .9rem;
}
.dash-practice-tbl th {
  background: var(--gray-50);
  font-size: .75rem;
  color: var(--gray-500);
  text-transform: uppercase;
  letter-spacing: .05em;
}
.dash-practice-tbl tbody tr { cursor: pointer; transition: background .12s; }
.dash-practice-tbl tbody tr:hover { background: #f0f7ff; }

/* Action-Card (große CTA, z.B. "Neue Praxis anlegen") */
.dash-action-card {
  background: linear-gradient(135deg, #0ea5e9, #2563eb);
  color: #fff;
  padding: 18px 22px;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  gap: 14px;
  margin-top: 16px;
  cursor: pointer;
  transition: transform .15s;
}
.dash-action-card:hover { transform: translateY(-1px); }
.dash-action-card .ic { font-size: 2rem; }
.dash-action-card .ttl { font-weight: 600; font-size: 1rem; }
.dash-action-card .sub { font-size: .85rem; opacity: .85; }

/* Detail-Seiten Header (über zweispaltigem Body) */
.detail-head {
  background: #fff;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 18px 22px;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}
.detail-head .av {
  width: 56px; height: 56px; border-radius: 50%;
  background: var(--primary); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700;
}
.detail-head h1 { margin: 0; font-size: 1.4rem; }
.detail-head .sub { color: var(--gray-500); font-size: .9rem; margin-top: 4px; }
.detail-head .right { margin-left: auto; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

.detail-grid2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
@media (max-width: 800px) {
  .detail-grid2 { grid-template-columns: 1fr; }
}

/* Field-Row Pattern (Profil + Detail) */
.kv-row {
  display: grid;
  grid-template-columns: 140px 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid var(--gray-100);
}
.kv-row:last-child { border-bottom: none; }
.kv-row .lbl { color: var(--gray-500); font-size: .85rem; }
.kv-row .val { font-weight: 500; min-width: 0; word-break: break-word; }
.kv-row .acts { display: flex; gap: 4px; }

/* Mini-Iconbutton, einheitlich */
.icon-btn {
  width: 28px; height: 28px;
  border-radius: 6px;
  border: 1px solid var(--gray-200);
  background: #fff;
  cursor: pointer;
  font-size: .9rem;
  display: inline-flex; align-items: center; justify-content: center;
}
.icon-btn:hover { background: var(--gray-100); }

/* Section (Profil, Dossier-Karten) */
.ui-section {
  background: #fff;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  margin-bottom: 16px;
  overflow: hidden;
}
.ui-section-head {
  padding: 14px 18px;
  background: var(--gray-50);
  border-bottom: 1px solid var(--gray-200);
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: .95rem;
}
.ui-section-body { padding: 14px 18px; }

/* ── Topbar Benutzer-Bereich ─────────────────────────────────────────── */
.topbar-user { position: relative; }

/* Desktop: alles inline (Avatar + Name + Badge + Profil-Button + Abmelden) */
.topbar-user-inline { display: flex; align-items: center; gap: 10px; }
.topbar-user-inline .avatar { width: 32px; height: 32px; font-size: .75rem; }
.topbar-user-inline .topbar-user-text { text-align: left; line-height: 1.15; }
.topbar-user-inline .topbar-user-text .name { font-size: .82rem; font-weight: 600; color: var(--gray-800); }
.topbar-user-inline .topbar-user-text .role { font-size: .7rem; color: var(--gray-500); margin-top: 2px; }
.topbar-action {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 6px 10px;
  background: transparent;
  border: 1px solid var(--gray-200);
  border-radius: 99px;
  cursor: pointer;
  font-size: .82rem;
  color: var(--gray-700);
  font-family: inherit;
}
.topbar-action:hover { background: var(--gray-100); color: var(--gray-900); border-color: var(--gray-300); }

/* Schmale Variante: Avatar + Caret als Dropdown-Trigger */
.topbar-user-btn {
  display: none; align-items: center; gap: 8px;
  padding: 4px 10px 4px 4px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 99px;
  cursor: pointer;
  font-family: inherit;
}
.topbar-user-btn:hover { background: var(--gray-100); border-color: var(--gray-200); }
.topbar-user-btn .avatar { width: 32px; height: 32px; font-size: .75rem; }
.topbar-user-btn .role-mobile { display: inline-flex; align-items: center; }
.topbar-user-btn .caret { color: var(--gray-500); font-size: .7rem; }

.topbar-user-menu {
  position: absolute; right: 0; top: calc(100% + 6px);
  background: #fff; border: 1px solid var(--gray-200); border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  min-width: 200px;
  padding: 6px;
  display: none;
  z-index: 100;
}
.topbar-user-menu.open { display: block; }
.user-menu-head {
  padding: 8px 12px 10px;
  border-bottom: 1px solid var(--gray-100);
  margin-bottom: 4px;
}
.user-menu-head .name { font-size: .88rem; font-weight: 600; color: var(--gray-800); }
.user-menu-head .role { margin-top: 2px; }
.topbar-user-menu button {
  display: flex; align-items: center; gap: 8px;
  width: 100%;
  background: transparent; border: none; cursor: pointer;
  padding: 8px 12px;
  border-radius: 6px;
  font-size: .88rem;
  color: var(--gray-700);
  text-align: left;
  font-family: inherit;
}
.topbar-user-menu button:hover { background: var(--gray-100); color: var(--gray-900); }

/* Schmal (Tablet/Mobile): Inline ausblenden, Dropdown einblenden */
@media (max-width: 900px) {
  .topbar-user-inline { display: none; }
  .topbar-user-btn { display: inline-flex; }
}
@media (max-width: 480px) {
  .topbar-user-btn .role-mobile { display: none; }
}

/* ── Chat-Typing-Indicator (Pfoten-Spur) ─────────────────────────────────
   Erscheint im Kunden-Chat zwischen dem optimistischen Senden und dem
   Eintreffen der Agent-Antwort. Drei Pfotenabdrücke tauchen nacheinander
   auf, wie Spuren im Sand — der Tierarzt-Bezug ist auf den ersten Blick
   erkennbar, und das sequenzielle Erscheinen signalisiert Progress. */
.chat-typing-bubble {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  /* Vertikales Padding etwas größer, weil die Pfoten je nach rechts/links
     ±3 px vertikal versetzt sind — sonst würden sie am Rand clippen. */
  padding: 12px;
  background: #ffffff;
  color: #111;
  border: 1px solid var(--gray-200);
  border-radius: 12px;
  font-size: 13px;
  line-height: 1;
}
/* Jede Pfote blitzt einzeln auf und verschwindet, BEVOR die nächste erscheint
   — nur EINE Pfote ist gleichzeitig sichtbar. Die ersten drei Pfoten kurz
   (je ~0,15 s), die letzten zwei doppelt so lange (je ~0,30 s) — wie
   „tick-tick-tick, taaap, taaap". Rotation ~90° nach rechts für Laufrichtung;
   pro Pfote eine kleine Variation damit die Spur natürlich wirkt. */
.chat-typing-paw {
  display: inline-block;
  opacity: 0;
  /* Zyklus 5 s:
     - Pfote 1 erscheint bei 0,0 s
     - Pfote 2 erscheint bei 0,4 s (fast, +0,4)
     - Pfote 3 erscheint bei 0,8 s (fast, +0,4)
     - Pfote 4 erscheint bei 1,6 s (slow, +0,8)
     - Pfote 5 erscheint bei 2,4 s (slow, +0,8)
     - Jede Pfote BLEIBT sichtbar, bis alle 5 gemeinsam bei 3,4 s gelöscht
       werden (= 1 s Hold nach dem letzten Abdruck).
     - 3,4 s – 5,0 s leere Bubble, dann Zyklus von vorne. */
  animation-duration: 5s;
  animation-iteration-count: infinite;
  animation-timing-function: linear;
}
/* Abwechselnd rechte (ungerade) und linke (gerade) Pfoten: linke werden per
   scaleX(-1) gespiegelt; zusätzlich leichter Vertikalversatz nach unten/oben
   damit echte Trittspuren entstehen (rechte Pfote unten, linke Pfote oben
   relativ zur Laufachse). Jede Pfote hat ein eigenes Keyframe, weil der
   „clear"-Zeitpunkt synchron für alle bei 3,4 s absolut liegen muss — je
   nach Erscheinungs-Delay ergibt das andere %-Werte im eigenen Zyklus. */
.chat-typing-paw:nth-child(1) { animation-name: chat-paw-keep-1; animation-delay: 0.0s; transform: translateY(3px)  rotate(82deg); }
.chat-typing-paw:nth-child(2) { animation-name: chat-paw-keep-2; animation-delay: 0.4s; transform: translateY(-3px) rotate(98deg)  scaleX(-1); }
.chat-typing-paw:nth-child(3) { animation-name: chat-paw-keep-3; animation-delay: 0.8s; transform: translateY(3px)  rotate(85deg); }
.chat-typing-paw:nth-child(4) { animation-name: chat-paw-keep-4; animation-delay: 1.6s; transform: translateY(-3px) rotate(95deg)  scaleX(-1); }
.chat-typing-paw:nth-child(5) { animation-name: chat-paw-keep-5; animation-delay: 2.4s; transform: translateY(3px)  rotate(88deg); }
/* clear-Zeitpunkt (3,4 s absolut) als %-Wert im eigenen 5-s-Zyklus:
   Pfote 1 → 68%, Pfote 2 → 60%, Pfote 3 → 52%, Pfote 4 → 36%, Pfote 5 → 20%.
   Jede Pfote: 0-1% unsichtbar (erscheint), 1-clear% sichtbar, clear+1%-100% wieder weg. */
@keyframes chat-paw-keep-1 { 0%{opacity:0} 1%{opacity:1} 68%{opacity:1} 69%{opacity:0} 100%{opacity:0} }
@keyframes chat-paw-keep-2 { 0%{opacity:0} 1%{opacity:1} 60%{opacity:1} 61%{opacity:0} 100%{opacity:0} }
@keyframes chat-paw-keep-3 { 0%{opacity:0} 1%{opacity:1} 52%{opacity:1} 53%{opacity:0} 100%{opacity:0} }
@keyframes chat-paw-keep-4 { 0%{opacity:0} 1%{opacity:1} 36%{opacity:1} 37%{opacity:0} 100%{opacity:0} }
@keyframes chat-paw-keep-5 { 0%{opacity:0} 1%{opacity:1} 20%{opacity:1} 21%{opacity:0} 100%{opacity:0} }
/* Reduced-Motion: zeige alle drei Pfoten statisch sichtbar, ohne Animation. */
@media (prefers-reduced-motion: reduce) {
  .chat-typing-paw { animation: none; opacity: 0.7; }
}
