:root {
  --bg: #f6f7f9;
  --fg: #1f2937;
  --muted: #6b7280;
  --line: #e5e7eb;
  --card: #ffffff;
  --accent: #2563eb;
  --weekend: #eef1f5;
  --radius: 8px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  padding: 0 20px 60px;
  background: var(--bg);
  color: var(--fg);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

body.centered {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 20px;
}

h1 { font-size: 20px; margin: 0; }
h2 { font-size: 16px; margin: 28px 0 10px; }
h3 { font-size: 16px; margin: 0 0 12px; }

.muted { color: var(--muted); }

/* ---------------------------------------------------------- Kopfzeile */

.topbar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  padding: 16px 0;
  border-bottom: 1px solid var(--line);
  margin-bottom: 14px;
}
.brand .sub { color: var(--muted); font-size: 13px; }
.topbar-actions { display: flex; gap: 8px; align-items: center; }

.badge {
  background: #dcfce7;
  color: #166534;
  border-radius: 999px;
  padding: 3px 10px;
  font-size: 12px;
  font-weight: 600;
}

/* ---------------------------------------------------------- Buttons */

.btn {
  display: inline-block;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--fg);
  border-radius: var(--radius);
  padding: 7px 12px;
  font-size: 14px;
  text-decoration: none;
  cursor: pointer;
  font-family: inherit;
}
.btn:hover { border-color: #cbd5e1; background: #f9fafb; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: #1d4ed8; }
.btn.danger { background: #dc2626; border-color: #dc2626; color: #fff; }
.btn.danger:hover { background: #b91c1c; }
.btn.ghost { background: transparent; }
.btn.tiny { padding: 3px 8px; font-size: 12px; }

/* ---------------------------------------------------------- Navigation */

.monthnav {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-bottom: 16px;
}
.monthnav .jump { display: flex; gap: 6px; align-items: center; margin-left: auto; }
.monthnav .jump label { display: flex; gap: 6px; align-items: center; font-size: 13px; color: var(--muted); }
.monthnav input[type="month"] {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 6px 8px;
  font: inherit;
}

/* ---------------------------------------------------------- Kalender */

.calendar-scroll { overflow-x: auto; padding-bottom: 8px; }

.calendar {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  min-width: min-content;
}

.month {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  min-width: 190px;
  flex: 0 0 auto;
}

.month-head {
  background: #f3f4f6;
  border-bottom: 1px solid var(--line);
  border-radius: var(--radius) var(--radius) 0 0;
  padding: 8px 10px;
  font-weight: 600;
  font-size: 14px;
}

.days > .day:last-child { border-radius: 0 0 7px 7px; }

.days { display: flex; flex-direction: column; }

.day {
  display: grid;
  grid-template-columns: 26px 26px 1fr;
  align-items: center;
  gap: 4px;
  width: 100%;
  padding: 3px 8px;
  min-height: 26px;
  border: 0;
  border-top: 1px solid #f1f2f4;
  background: transparent;
  font: inherit;
  text-align: left;
  color: inherit;
  cursor: default;
}
.days > .day:first-child { border-top: 0; }
button.day { cursor: pointer; }
button.day:hover { background: #eef2ff; }

.day.weekend { background: var(--weekend); }
.day.weekend:hover { background: #e2e8f0; }

.day.today .dnum {
  background: var(--accent);
  color: #fff;
  border-radius: 4px;
  text-align: center;
}

.dnum { font-variant-numeric: tabular-nums; font-size: 13px; color: var(--muted); }
.dwd  { font-size: 12px; color: var(--muted); }
.dname {
  font-size: 12.5px;
  font-weight: 600;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.day.booked {
  background: color-mix(in srgb, var(--c) 16%, white);
  border-left: 4px solid var(--c);
  padding-left: 4px;
}
.day.booked:hover { background: color-mix(in srgb, var(--c) 26%, white); }
.day.booked .dname { color: var(--c); }
.day.booked.seg-start { border-top: 1px solid var(--c); }
.day.booked.seg-end   { border-bottom: 1px solid var(--c); }

/* Fallback, falls color-mix nicht unterstützt wird */
@supports not (background: color-mix(in srgb, red 10%, white)) {
  .day.booked { background: #eef2ff; }
}

/* ---------------------------------------------------------- Liste */

.list { max-width: 1000px; }
.list table {
  width: 100%;
  border-collapse: collapse;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}
.list th, .list td {
  text-align: left;
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
  font-size: 14px;
}
.list th { background: #f3f4f6; font-size: 13px; color: var(--muted); font-weight: 600; }
.list tr:last-child td { border-bottom: 0; }
.list .num { text-align: right; font-variant-numeric: tabular-nums; }
.list .rowactions { text-align: right; }

.dot {
  display: inline-block;
  width: 11px; height: 11px;
  border-radius: 50%;
}

/* ---------------------------------------------------------- Dialog / Formular */

/* Fallback für Browser ohne <dialog>-Unterstützung */
dialog:not([open]) { display: none; }

dialog {
  border: 0;
  border-radius: 12px;
  padding: 22px;
  width: min(440px, 92vw);
  box-shadow: 0 20px 50px rgba(0,0,0,.22);
}
dialog::backdrop { background: rgba(15, 23, 42, .45); }

dialog label, .card label {
  display: block;
  margin-bottom: 12px;
  font-size: 13px;
  color: var(--muted);
}
dialog input, dialog select, dialog textarea,
.card input {
  display: block;
  width: 100%;
  margin-top: 4px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 8px 10px;
  font: inherit;
  color: var(--fg);
  background: #fff;
}
dialog textarea { resize: vertical; }

.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.hint { font-size: 12.5px; color: var(--muted); margin: -4px 0 12px; }
.hint.bad { color: #b91c1c; }

dialog menu {
  display: flex;
  gap: 8px;
  padding: 0;
  margin: 18px 0 0;
  justify-content: flex-end;
}
dialog menu .btn.danger { margin-right: auto; }

/* ---------------------------------------------------------- Login-Karte */

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 26px;
  width: min(360px, 92vw);
  box-shadow: 0 8px 24px rgba(0,0,0,.06);
}
.card h1 { margin-bottom: 4px; }
.card .btn { width: 100%; }
.card p { font-size: 13px; }

/* ---------------------------------------------------------- Meldungen */

.flash {
  border-radius: var(--radius);
  padding: 10px 12px;
  margin: 0 0 14px;
  font-size: 14px;
}
.flash.ok  { background: #dcfce7; color: #14532d; }
.flash.err { background: #fee2e2; color: #7f1d1d; }

.foot {
  margin-top: 30px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 13px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1115; --fg: #e5e7eb; --muted: #9ca3af;
    --line: #262b33; --card: #161a20; --weekend: #1b2027;
  }
  .month-head, .list th { background: #1b2027; }
  .day.booked { background: #1f2937; }
  .day.booked { background: color-mix(in srgb, var(--c) 26%, #161a20); }
  .day.booked:hover { background: color-mix(in srgb, var(--c) 38%, #161a20); }
  button.day:hover { background: #1f2630; }
  dialog, .card { background: var(--card); color: var(--fg); }
  dialog input, dialog select, dialog textarea, .card input { background: #10141a; color: var(--fg); }
  .btn { background: #1b2027; color: var(--fg); }
  .flash.ok  { background: #14321f; color: #86efac; }
  .flash.err { background: #3b1414; color: #fca5a5; }
}
