* { box-sizing: border-box; }
body { font-family: 'Segoe UI', system-ui, sans-serif; margin: 0; padding: 16px 16px 16px 236px; background: #f5f5f5; color: #1a1a1a; transition: padding-left .25s ease; }
a { color: #0d6efd; text-decoration: none; }
a:hover { text-decoration: underline; }
/* Sidebar Navigation */
.sidebar { position: fixed; left: 0; top: 0; bottom: 0; width: 220px; background: #fff; box-shadow: 2px 0 8px rgba(0,0,0,.06); z-index: 1000; display: flex; flex-direction: column; overflow-y: auto; transition: width .25s ease, transform .25s ease; }
.sidebar-brand { padding: 20px 16px 12px; font-size: 1.2rem; font-weight: 700; color: #0d6efd; border-bottom: 1px solid #eee; display: flex; align-items: center; justify-content: space-between; }
.sidebar-toggle { background: none; border: 1px solid #ddd; border-radius: 4px; cursor: pointer; font-size: 16px; color: #666; padding: 2px 7px; line-height: 1; }
.sidebar-toggle:hover { background: #f0f4ff; color: #0d6efd; }
.sidebar-group { padding: 12px 0 4px; }
.sidebar-group-label { padding: 4px 16px 6px; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .5px; color: #999; white-space: nowrap; overflow: hidden; }
.sidebar a { display: block; padding: 9px 16px 9px 20px; color: #333; font-weight: 500; font-size: 14px; text-decoration: none; border-left: 3px solid transparent; transition: background .15s, border-color .15s; white-space: nowrap; overflow: hidden; }
.sidebar a:hover { background: #f0f4ff; text-decoration: none; }
.sidebar a.active { background: #e7f0ff; color: #0d6efd; border-left-color: #0d6efd; font-weight: 600; }
.sidebar-footer { margin-top: auto; padding: 12px 16px; border-top: 1px solid #eee; overflow: hidden; }
/* Collapsed sidebar */
.sidebar.collapsed { width: 48px; }
.sidebar.collapsed .sidebar-brand span { display: none; }
.sidebar.collapsed .sidebar-group-label { visibility: hidden; height: 0; padding: 0 16px; }
.sidebar.collapsed a { font-size: 0; padding: 10px 0; text-align: center; border-left: 3px solid transparent; position: relative; }
.sidebar.collapsed a::before { font-size: 16px; display: block; }
.sidebar.collapsed a:hover::after { content: attr(data-label); position: absolute; left: 48px; top: 50%; transform: translateY(-50%); background: #333; color: #fff; padding: 4px 10px; border-radius: 4px; font-size: 13px; white-space: nowrap; z-index: 1002; pointer-events: none; }
.sidebar.collapsed a[href="index.html"]::before { content: '🏠'; }
.sidebar.collapsed a[href="clients.html"]::before { content: '👥'; }
.sidebar.collapsed a[href="invoices.html"]::before { content: '📄'; }
.sidebar.collapsed a[href="calendar.html"]::before { content: '📅'; }
.sidebar.collapsed a[href="reports.html"]::before { content: '📊'; }
.sidebar.collapsed a[href="items.html"]::before { content: '📋'; }
.sidebar.collapsed a[href="company.html"]::before { content: '🏢'; }
.sidebar.collapsed a[href="diagnoses.html"]::before { content: '🩺'; }
.sidebar.collapsed a[href="datenbank.html"]::before { content: '💾'; }
.sidebar.collapsed a[href="admin.html"]::before { content: '⚙️'; }
.sidebar.collapsed a[href="hilfe.html"]::before { content: '❓'; }
.sidebar.collapsed .sidebar-footer .btn { font-size: 0; padding: 8px 4px; }
.sidebar.collapsed .sidebar-footer .btn-logout::before { content: '🚪'; font-size: 14px; }
.sidebar.collapsed .sidebar-footer .btn-end-app::before { content: '✕'; font-size: 14px; }
.sidebar.collapsed #currentUserLabel { font-size: 0; padding: 4px 0; margin-bottom: 4px; }
.sidebar.collapsed #currentUserLabel span { font-size: 14px; }
body.sidebar-collapsed { padding-left: 64px; }
.hamburger { display: none; position: fixed; top: 12px; left: 12px; z-index: 1001; background: #fff; border: 1px solid #ddd; border-radius: 6px; padding: 8px 12px; cursor: pointer; font-size: 18px; box-shadow: 0 1px 4px rgba(0,0,0,.1); }
.container { max-width: 1600px; margin: 0 auto; padding: 0 24px; }
.card { background: #fff; border-radius: 8px; padding: 20px; margin-bottom: 16px; box-shadow: 0 1px 3px rgba(0,0,0,.08); }
.card h2 { margin: 0 0 16px 0; font-size: 1.25rem; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 10px 12px; text-align: left; border-bottom: 1px solid #eee; }
th { background: #f8f9fa; font-weight: 600; }
tr:hover { background: #f8f9fa; }
.btn { display: inline-block; padding: 8px 14px; border-radius: 6px; border: none; cursor: pointer; font-size: 14px; }
.btn-primary { background: #0d6efd; color: #fff; }
.btn-primary:hover { background: #0b5ed7; }
.btn-secondary { background: #6c757d; color: #fff; }
.btn-secondary:hover { background: #5c636a; }
.btn-success { background: #198754; color: #fff; }
.btn-danger { background: #dc3545; color: #fff; }
.btn-sm { padding: 4px 10px; font-size: 12px; margin-right: 4px; }
input, select, textarea { padding: 9px 11px; border: 1px solid #ddd; border-radius: 6px; font-size: 14px; }
/* Größere, gut lesbare Felder für zentrale Formulare */
input.input-readable, select.input-readable, textarea.input-readable { padding: 10px 12px; font-size: 15px; min-width: 200px; width: 100%; box-sizing: border-box; }
textarea.input-readable { min-height: 2.5em; width: 100%; box-sizing: border-box; }
/* Suchfelder einheitlich */
input[type="text"][placeholder*="suchen"], input[type="text"][placeholder*="Suchen"], input[type="text"][placeholder*="eingeben"] { min-width: 240px; padding: 9px 12px; font-size: 14px; }
label { display: block; margin-bottom: 4px; font-weight: 500; }
.form-group { margin-bottom: 12px; }
.form-row { display: flex; gap: 16px; flex-wrap: wrap; }
.form-row .form-group { flex: 1; min-width: 140px; }
.form-row .form-group.form-group-kunde { flex: 1 1 400px; min-width: 320px; }
/* Positionen-Formular: klare Abstände, keine Überlappung */
.form-row-items { gap: 20px; }
.form-row-items .form-group-code { flex: 0 0 auto; min-width: 120px; max-width: 140px; }
.form-row-items .form-group-name { flex: 1 1 220px; min-width: 0; }
.form-row-items .form-group-unit { flex: 0 0 auto; min-width: 90px; max-width: 100px; }
.form-row-items .form-group-price { flex: 0 0 auto; min-width: 100px; max-width: 120px; }
.form-row-items .form-group-tax { flex: 0 0 auto; min-width: 80px; max-width: 100px; }
/* Kunde anlegen / bearbeiten: Felder nutzen Platz, keine Überlappung */
.form-row-client { gap: 20px; }
.form-row-client .form-group { min-width: 0; }
.form-row-client .form-group-anrede { flex: 0 0 auto; min-width: 100px; max-width: 120px; }
.form-row-client .form-group-vorname,
.form-row-client .form-group-nachname { flex: 1 1 160px; }
.form-row-client .form-group-email,
.form-row-client .form-group-phone { flex: 1 1 200px; }
.form-row-client .form-group-address { flex: 1 1 100%; min-width: 0; }
.form-client-new .form-group-address .input-address,
.form-client-edit .form-group-address .input-address { width: 100%; max-width: 100%; box-sizing: border-box; }
.form-row-client .form-group-plz { flex: 0 0 auto; min-width: 90px; max-width: 100px; }
.form-row-client .form-group-city { flex: 1 1 180px; }
.form-row-client .form-group-country { flex: 0 0 auto; min-width: 130px; max-width: 180px; }
.form-client-new .input-readable,
.form-client-edit .input-readable { width: 100%; min-width: 0; box-sizing: border-box; }
.form-client-new textarea.input-readable,
.form-client-edit textarea.input-readable { width: 100%; max-width: 100%; }
/* Diagnosen: Bezeichnung nutzt verfügbaren Platz */
.form-row-diagnosis { gap: 20px; }
.form-row-diagnosis .form-group { min-width: 0; }
.form-row-diagnosis .form-group-diagnosis-code { flex: 0 0 auto; min-width: 100px; max-width: 120px; }
.form-row-diagnosis .form-group-diagnosis-name { flex: 1 1 280px; }
.form-diagnosis .form-group-diagnosis-code .input-readable,
.form-diagnosis .form-group-diagnosis-name .input-readable { width: 100%; min-width: 0; box-sizing: border-box; }
.form-diagnosis .form-group:not(.form-group-diagnosis-code):not(.form-group-diagnosis-name) .input-readable { width: 100%; max-width: 100%; min-width: 0; }
.form-group-wide { flex: 1 1 100% !important; min-width: 100% !important; }
.input-address { width: 100%; max-width: 100%; min-width: 280px; }
.select-search { min-width: 320px; max-width: 100%; }
.select-search option { padding: 4px 8px; }
.dashboard-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 16px; margin-bottom: 24px; }
.stat-card { background: #fff; border-radius: 8px; padding: 20px; box-shadow: 0 1px 3px rgba(0,0,0,.08); }
.stat-card .number { font-size: 2rem; font-weight: 700; color: #0d6efd; }
.stat-card .label { color: #666; font-size: 0.9rem; }
.badge { display: inline-block; padding: 2px 8px; border-radius: 4px; font-size: 12px; }
.badge-draft { background: #ffc107; color: #000; }
.badge-sent, .badge-sent_email, .badge-sent_post, .badge-handed_over { background: #198754; color: #fff; }
.badge-paid { background: #0d6efd; color: #fff; }
.alert { padding: 12px 16px; border-radius: 6px; margin-bottom: 16px; }
.alert-success { background: #d1e7dd; color: #155724; }
.alert-error { background: #f8d7da; color: #721c24; }
.invoice-lines table { margin-top: 12px; }
.invoice-lines input { width: 100%; max-width: 80px; }
.invoice-lines input.description { max-width: 100%; }
/* Overdue badge */
.badge-overdue { background: #dc3545; color: #fff; }
/* Focus states */
a:focus-visible, .btn:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 2px solid #0d6efd; outline-offset: 2px; }
/* Toast notifications */
.toast-container { position: fixed; top: 16px; right: 16px; z-index: 9999; display: flex; flex-direction: column; gap: 8px; pointer-events: none; }
.toast { pointer-events: auto; min-width: 260px; max-width: 420px; padding: 12px 40px 12px 16px; border-radius: 8px; font-size: 14px; color: #fff; box-shadow: 0 4px 12px rgba(0,0,0,.18); animation: toast-in .3s ease; position: relative; }
.toast-success { background: #198754; }
.toast-error { background: #dc3545; }
.toast-info { background: #0d6efd; }
.toast-close { position: absolute; top: 8px; right: 10px; background: none; border: none; color: inherit; font-size: 18px; cursor: pointer; line-height: 1; opacity: .7; }
.toast-close:hover { opacity: 1; }
@keyframes toast-in { from { opacity: 0; transform: translateX(40px); } to { opacity: 1; transform: translateX(0); } }
/* Loading spinner */
.spinner { display: inline-block; width: 20px; height: 20px; border: 3px solid rgba(0,0,0,.15); border-top-color: #0d6efd; border-radius: 50%; animation: spin .6s linear infinite; vertical-align: middle; margin-right: 6px; }
@keyframes spin { to { transform: rotate(360deg); } }
/* Empty state */
.empty-state { text-align: center; padding: 40px 20px; color: #888; }
.empty-state p { margin-bottom: 16px; font-size: 15px; }
/* Filter bar */
.filter-bar { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; margin-bottom: 16px; }
.filter-bar input, .filter-bar select { padding: 7px 10px; font-size: 14px; }
.filter-bar input[type="text"] { min-width: 200px; }
.toggle-paid-label { display: inline-flex; align-items: center; gap: 5px; font-size: 13px; color: #555; cursor: pointer; user-select: none; padding: 6px 10px; border: 1px solid #ddd; border-radius: 6px; background: #f8f9fa; transition: background .15s, border-color .15s; }
.toggle-paid-label:hover { background: #e9ecef; }
.toggle-paid-label:has(input:checked) { background: #d1e7dd; border-color: #198754; color: #0f5132; }
.btn-paid { background: #198754; color: #fff; border: none; border-radius: 6px; cursor: pointer; font-weight: 600; transition: background .15s; }
.btn-paid:hover { background: #157347; }
.loading-indicator { padding: 12px; color: #666; font-style: italic; }
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); width: 220px !important; }
  .sidebar.open { transform: translateX(0); }
  .sidebar.collapsed { width: 220px !important; }
  .sidebar.collapsed .sidebar-brand span { display: inline; }
  .sidebar.collapsed .sidebar-group-label { visibility: visible; height: auto; padding: 4px 16px 6px; }
  .sidebar.collapsed a { font-size: 14px; padding: 9px 16px 9px 20px; text-align: left; }
  .sidebar.collapsed a::before { display: none; }
  .sidebar.collapsed .sidebar-footer .btn { font-size: 12px; padding: 4px 10px; }
  .sidebar.collapsed .sidebar-footer .btn::before { content: none; }
  .hamburger { display: block; }
  body, body.sidebar-collapsed { padding: 60px 12px 16px 12px; }
  .sidebar-toggle { display: none; }
}
@media (min-width: 1400px) {
  .form-row .form-group { min-width: 180px; }
  .form-row-client .form-group-vorname, .form-row-client .form-group-nachname { flex: 1 1 220px; }
  .form-row-client .form-group-email { flex: 1 1 280px; }
  .form-row-client .form-group-city { flex: 1 1 240px; }
  .dashboard-grid { grid-template-columns: repeat(5, 1fr); }
}
@media print { body { background: #fff; padding: 0; } .no-print { display: none !important; } }
.collapse-section { border: 1px solid #e0e0e0; border-radius: 8px; margin-bottom: 16px; overflow: hidden; }
.collapse-section summary { padding: 12px 16px; cursor: pointer; font-weight: 600; background: #f8f9fa; list-style: none; display: flex; align-items: center; justify-content: space-between; }
.collapse-section summary::-webkit-details-marker { display: none; }
.collapse-section summary::after { content: '+'; font-size: 1.2rem; }
.collapse-section[open] summary::after { content: '−'; }
.collapse-section .collapse-body { padding: 16px; border-top: 1px solid #e0e0e0; }
.btn-add-wrap { margin-bottom: 16px; }
.btn-add-wrap .btn { margin-right: 8px; }
#appointmentsListCard { display: block !important; }
#appointmentsListCard table { min-height: 100px; }
