:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-2: #fafbfc;
  --border: #dcdfe4;
  --border-strong: #c3c8d0;
  --text: #1c2024;
  --text-muted: #5b6370;
  --accent: #1f5f8b;
  --accent-text: #ffffff;
  --success-bg: #e3f4e8;
  --success-text: #1c6b38;
  --error-bg: #fdeaea;
  --error-text: #9b2020;
  --warn-bg: #fdf3e0;
  --warn-text: #8a5a08;
  --radius: 6px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14171a;
    --surface: #1c2024;
    --surface-2: #22272c;
    --border: #333a41;
    --border-strong: #454e57;
    --text: #e6e9ec;
    --text-muted: #9aa4b0;
    --accent: #5aa7db;
    --accent-text: #0c1116;
    --success-bg: #17301f;
    --success-text: #7fd39b;
    --error-bg: #351a1a;
    --error-text: #f19b9b;
    --warn-bg: #362a13;
    --warn-text: #e5bf72;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

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

/* --- Kopfzeile --- */
.topbar {
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 0 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  min-height: 56px;
  flex-wrap: wrap;
}
.brand { font-weight: 700; text-decoration: none; color: var(--text); letter-spacing: -0.2px; }
.topbar nav { display: flex; gap: 4px; flex: 1; flex-wrap: wrap; }
.topbar nav a {
  padding: 6px 12px;
  border-radius: var(--radius);
  text-decoration: none;
  color: var(--text-muted);
  font-weight: 500;
}
.topbar nav a:hover { background: var(--surface-2); color: var(--text); }
.topbar nav a.active { background: var(--accent); color: var(--accent-text); }
.topbar-right { display: flex; align-items: center; gap: 10px; }
.who { color: var(--text-muted); text-decoration: none; font-size: 14px; }
.who:hover { text-decoration: underline; }

.wrap { max-width: 900px; margin: 0 auto; padding: 24px 16px 60px; }
.foot { text-align: center; color: var(--text-muted); font-size: 13px; padding: 0 0 24px; }

/* --- Überschriften --- */
.page-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; flex-wrap: wrap; margin-bottom: 18px;
}
h1 { font-size: 22px; margin: 0; letter-spacing: -0.3px; }
h2 { font-size: 17px; margin: 0 0 12px; letter-spacing: -0.2px; }
h3 { font-size: 15px; margin: 0 0 8px; }
.sub { color: var(--text-muted); font-size: 14px; margin: 4px 0 0; }

/* --- Karten --- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 18px;
}
.card.tight { padding: 0; }
.grid { display: grid; gap: 18px; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 18px; }
.stat {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px 16px;
}
.stat .n { font-size: 26px; font-weight: 700; letter-spacing: -0.5px; }
.stat .l { color: var(--text-muted); font-size: 13px; }

/* --- Tabellen --- */
table { width: 100%; border-collapse: collapse; font-size: 14px; }
thead th {
  text-align: left; padding: 10px 12px; font-size: 12px; text-transform: uppercase;
  letter-spacing: 0.4px; color: var(--text-muted); border-bottom: 1px solid var(--border);
  background: var(--surface-2); font-weight: 600; white-space: nowrap;
}
tbody td { padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--surface-2); }
td.num, th.num { text-align: right; white-space: nowrap; }
td.nowrap, th.nowrap { white-space: nowrap; }
.table-scroll { overflow-x: auto; }

/* Gruppierungszeile je Tag (mehrere Buchungen moeglich) */
tr.day-head td {
  background: var(--surface-2);
  font-weight: 600;
  padding-top: 14px;
  border-bottom: 1px solid var(--border);
}
tr.day-head:first-child td { padding-top: 10px; }

/* --- Formulare --- */
label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 4px; color: var(--text-muted); }
input[type=text], input[type=email], input[type=password], input[type=date],
input[type=time], input[type=datetime-local], input[type=search], select, textarea {
  width: 100%; padding: 8px 10px; font: inherit; color: var(--text);
  background: var(--surface-2); border: 1px solid var(--border-strong);
  border-radius: var(--radius);
}
textarea { min-height: 90px; resize: vertical; font-family: inherit; }
input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--accent); outline-offset: -1px; border-color: var(--accent);
}
.field { margin-bottom: 14px; }
.row { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); }
.hint { color: var(--text-muted); font-size: 12px; margin-top: 4px; }

/* --- Schaltflächen --- */
.btn {
  display: inline-block; padding: 8px 14px; font: inherit; font-weight: 600; font-size: 14px;
  border-radius: var(--radius); border: 1px solid var(--border-strong);
  background: var(--surface-2); color: var(--text); cursor: pointer; text-decoration: none;
  white-space: nowrap;
}
.btn:hover { border-color: var(--accent); color: var(--accent); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn-primary:hover { filter: brightness(1.1); color: var(--accent-text); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-muted); }
.btn-ghost:hover { background: var(--surface-2); }
.btn-danger { color: var(--error-text); border-color: var(--border-strong); }
.btn-danger:hover { background: var(--error-bg); border-color: var(--error-text); color: var(--error-text); }
.btn-sm { padding: 4px 9px; font-size: 13px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.actions-end { justify-content: flex-end; }
form.inline { display: inline; }

/* --- Meldungen --- */
.flash {
  padding: 11px 14px; border-radius: var(--radius); margin-bottom: 14px;
  border: 1px solid transparent; font-size: 14px;
}
.flash ul { margin: 6px 0 0; padding-left: 20px; }
.flash-success { background: var(--success-bg); color: var(--success-text); border-color: currentColor; }
.flash-error { background: var(--error-bg); color: var(--error-text); border-color: currentColor; }
.flash-info { background: var(--surface); color: var(--text); border-color: var(--border); }

.overdue { color: var(--error-text); font-weight: 600; }
.muted { color: var(--text-muted); }
.small { font-size: 13px; }

dl.kv { margin: 0; display: grid; grid-template-columns: minmax(130px, auto) 1fr; gap: 8px 18px; }
dl.kv dt { color: var(--text-muted); font-size: 13px; font-weight: 600; }
dl.kv dd { margin: 0; }

/* --- Anmeldung --- */
.login-wrap { max-width: 380px; margin: 10vh auto; padding: 0 16px; }
.login-wrap h1 { text-align: center; margin-bottom: 6px; }
.login-wrap .sub { text-align: center; margin-bottom: 22px; }

@media (max-width: 720px) {
  .topbar { padding: 8px 14px; }
  dl.kv { grid-template-columns: 1fr; gap: 2px 0; }
  dl.kv dd { margin-bottom: 10px; }
}
