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

:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --success: #16a34a;
  --danger: #dc2626;
  --warning: #d97706;
  --bg: #f1f5f9;
  --surface: #ffffff;
  --border: #e2e8f0;
  --text: #1e293b;
  --text-muted: #64748b;
  --radius: 8px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

/* ── Header ── */
header {
  background: var(--primary);
  color: white;
  padding: 1rem 2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}
header h1 { font-size: 1.4rem; font-weight: 700; }
header .header-right { display: flex; align-items: center; gap: 1rem; font-size: 0.875rem; opacity: 0.9; }

/* ── Tabs ── */
.tab-bar {
  background: var(--surface);
  border-bottom: 2px solid var(--border);
  display: flex;
  padding: 0 2rem;
}
.tab-btn {
  padding: 1rem 1.5rem;
  border: none;
  background: none;
  cursor: pointer;
  font-size: 0.95rem;
  color: var(--text-muted);
  border-bottom: 3px solid transparent;
  margin-bottom: -2px;
  transition: all 0.2s;
  font-weight: 500;
}
.tab-btn:hover { color: var(--primary); }
.tab-btn.active { color: var(--primary); border-bottom-color: var(--primary); }

/* ── Layout ── */
.container { max-width: 960px; margin: 0 auto; padding: 2rem; }
.tab-content { display: none; }
.tab-content.active { display: block; }

/* ── Card ── */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: 1.5rem;
  margin-bottom: 1rem;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}
.card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 1rem;
}
.card-title { font-size: 1.1rem; font-weight: 600; }
.card-subtitle { font-size: 0.875rem; color: var(--text-muted); margin-top: 0.2rem; }

/* ── Badges ── */
.badge {
  display: inline-block;
  padding: 0.25rem 0.75rem;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 600;
}
.badge-green  { background: #dcfce7; color: var(--success); }
.badge-red    { background: #fee2e2; color: var(--danger); }
.badge-yellow { background: #fef3c7; color: var(--warning); }
.badge-blue   { background: #dbeafe; color: var(--primary); }

/* ── Forms ── */
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
  margin-bottom: 1rem;
}
.form-group { display: flex; flex-direction: column; gap: 0.4rem; }
.form-group label { font-size: 0.875rem; font-weight: 500; color: var(--text-muted); }

input, select, textarea {
  padding: 0.6rem 0.8rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.95rem;
  color: var(--text);
  background: var(--surface);
  transition: border-color 0.2s;
  width: 100%;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,0.1);
}
input[type="password"] { letter-spacing: 0.1em; }

/* ── Buttons ── */
.btn {
  padding: 0.6rem 1.2rem;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 600;
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  text-decoration: none;
}
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-success { background: var(--success); color: white; }
.btn-success:hover { background: #15803d; }
.btn-danger  { background: var(--danger); color: white; }
.btn-danger:hover  { background: #b91c1c; }
.btn-warning { background: var(--warning); color: white; }
.btn-warning:hover { background: #b45309; }
.btn-outline { background: transparent; border: 1px solid var(--border); color: var(--text); }
.btn-outline:hover { background: var(--bg); }
.btn-sm { padding: 0.35rem 0.75rem; font-size: 0.8rem; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ── Spots bar ── */
.spots-bar {
  height: 6px;
  background: var(--border);
  border-radius: 999px;
  overflow: hidden;
  margin: 0.5rem 0;
}
.spots-fill {
  height: 100%;
  border-radius: 999px;
  transition: width 0.3s;
}

/* ── Lists ── */
.appointment-list { display: flex; flex-direction: column; gap: 1rem; }
.reg-count { font-size: 0.8rem; color: var(--text-muted); margin-top: 0.25rem; }

/* ── Table ── */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}
.data-table th {
  text-align: left;
  padding: 0.6rem 0.8rem;
  background: var(--bg);
  border-bottom: 2px solid var(--border);
  font-weight: 600;
  color: var(--text-muted);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.data-table td {
  padding: 0.6rem 0.8rem;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: #f8fafc; }

/* ── Alerts ── */
.alert {
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  margin-bottom: 1rem;
  font-size: 0.9rem;
  display: none;
}
.alert-success { background: #dcfce7; color: var(--success); border: 1px solid #bbf7d0; }
.alert-error   { background: #fee2e2; color: var(--danger);  border: 1px solid #fecaca; }
.alert-info    { background: #dbeafe; color: var(--primary); border: 1px solid #bfdbfe; }
.alert.show    { display: block; }

/* ── Empty state ── */
.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text-muted);
}
.empty-state p { font-size: 1rem; }

/* ── Section header ── */
.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
}
.section-header h2 { font-size: 1.3rem; font-weight: 700; }

/* ── Divider ── */
.divider { border: none; border-top: 1px solid var(--border); margin: 1.5rem 0; }

/* ── Modal ── */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 100;
  align-items: center;
  justify-content: center;
}
.modal-overlay.open { display: flex; }
.modal {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 2rem;
  max-width: 500px;
  width: 90%;
  box-shadow: 0 20px 60px rgba(0,0,0,0.2);
  max-height: 90vh;
  overflow-y: auto;
}
.modal h3       { font-size: 1.2rem; margin-bottom: 0.4rem; }
.modal .subtitle { color: var(--text-muted); font-size: 0.875rem; margin-bottom: 1.5rem; }
.modal-actions  { display: flex; gap: 0.75rem; justify-content: flex-end; margin-top: 1.5rem; }

/* ── Login page ── */
.login-wrapper {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  padding: 1rem;
}
.login-box {
  background: var(--surface);
  border-radius: 12px;
  border: 1px solid var(--border);
  padding: 2.5rem;
  width: 100%;
  max-width: 380px;
  box-shadow: 0 4px 24px rgba(0,0,0,0.08);
}
.login-box .logo {
  text-align: center;
  margin-bottom: 2rem;
}
.login-box .logo h1 { font-size: 1.5rem; color: var(--primary); margin-top: 0.5rem; }
.login-box .logo p  { color: var(--text-muted); font-size: 0.875rem; margin-top: 0.25rem; }
.login-box .form-group { margin-bottom: 1rem; }
.login-box .btn      { width: 100%; justify-content: center; padding: 0.75rem; font-size: 1rem; margin-top: 0.5rem; }
.login-error {
  background: #fee2e2;
  color: var(--danger);
  border: 1px solid #fecaca;
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  font-size: 0.875rem;
  margin-bottom: 1rem;
}

/* ── DB settings ── */
.settings-section { margin-bottom: 2rem; }
.settings-section h3 { font-size: 1rem; font-weight: 600; margin-bottom: 1rem; padding-bottom: 0.5rem; border-bottom: 1px solid var(--border); }
.connection-status {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.875rem;
  padding: 0.5rem 1rem;
  border-radius: var(--radius);
  margin-top: 0.75rem;
}
.connection-status.ok      { background: #dcfce7; color: var(--success); }
.connection-status.error   { background: #fee2e2; color: var(--danger); }

/* ── Spinner ── */
.spinner {
  display: inline-block;
  width: 14px; height: 14px;
  border: 2px solid rgba(255,255,255,0.4);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  vertical-align: middle;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Checkbox Label ── */
.checkbox-label {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  font-size: 0.875rem;
  color: var(--text-muted);
  cursor: pointer;
  line-height: 1.5;
}
.checkbox-label input[type="checkbox"] {
  margin-top: 0.2rem;
  width: 1rem;
  height: 1rem;
  flex-shrink: 0;
  cursor: pointer;
  accent-color: var(--primary);
}
.checkbox-label a { color: var(--primary); }

/* ── Footer ── */
.site-footer {
  text-align: center;
  padding: 2rem 1rem;
  margin-top: 2rem;
  font-size: 0.85rem;
  color: var(--text-muted);
  display: flex;
  justify-content: center;
  gap: 0.75rem;
}
.site-footer a { color: var(--primary); text-decoration: none; }
.site-footer a:hover { text-decoration: underline; }

/* ── Datenschutz-Seite ── */
.datenschutz-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem;
  max-width: 800px;
  margin: 2rem auto;
  line-height: 1.7;
}
.datenschutz-box h2 { margin: 1.5rem 0 0.5rem; font-size: 1.1rem; color: var(--text); }
.datenschutz-box h1 { margin-bottom: 0.5rem; font-size: 1.4rem; }
.datenschutz-box p, .datenschutz-box ul { margin-bottom: 1rem; color: var(--text-muted); }
.datenschutz-box ul { padding-left: 1.5rem; }
.datenschutz-box .back-link { display:inline-block; margin-bottom:1.5rem; color:var(--primary); text-decoration:none; font-size:0.9rem; }
.datenschutz-box .back-link:hover { text-decoration:underline; }

/* ── Responsive ── */
@media (max-width: 640px) {
  .container   { padding: 1rem; }
  .tab-btn     { padding: 0.75rem 1rem; font-size: 0.85rem; }
  header       { padding: 1rem; }
  .login-box   { padding: 1.5rem; }
}
