/* Kursbuchung – Design angelehnt an ELMS (Topbar + Sidebar, Light/Dark über CSS-Variablen) */
:root {
  --red: #cf2e2e;
  --red-dark: #a82222;
  --green: #2f9e44;
  --amber: #ef8a17;
  --blue: #2f6fed;
  --grey: #8a929c;

  --bg: #f3f4f6;
  --surface: #ffffff;
  --surface-2: #f8f9fa;
  --border: #e3e6ea;
  --text: #1c2128;
  --muted: #6b7380;
  --topbar: #ffffff;
  --sidebar: #ffffff;
  --hover: #f1f3f5;
  --red-soft: rgba(207, 46, 46, .10);
  --green-soft: rgba(47, 158, 68, .12);
  --amber-soft: rgba(239, 138, 23, .14);
  --blue-soft: rgba(47, 111, 237, .12);
  --grey-soft: rgba(138, 146, 156, .16);
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 1px 3px rgba(16, 24, 40, .06);
  --radius: 10px;
  --topbar-h: 58px;
  --sidebar-w: 236px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1216; --surface: #171b21; --surface-2: #1d222a; --border: #2a3039;
    --text: #e6e9ee; --muted: #9aa3ae; --topbar: #14181d; --sidebar: #14181d; --hover: #212731;
    --red-soft: rgba(207, 46, 46, .20); --green-soft: rgba(47, 158, 68, .20);
    --amber-soft: rgba(239, 138, 23, .20); --blue-soft: rgba(47, 111, 237, .22); --grey-soft: rgba(138, 146, 156, .22);
    --shadow: 0 1px 2px rgba(0, 0, 0, .4);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0f1216; --surface: #171b21; --surface-2: #1d222a; --border: #2a3039;
  --text: #e6e9ee; --muted: #9aa3ae; --topbar: #14181d; --sidebar: #14181d; --hover: #212731;
  --red-soft: rgba(207, 46, 46, .20); --green-soft: rgba(47, 158, 68, .20);
  --amber-soft: rgba(239, 138, 23, .20); --blue-soft: rgba(47, 111, 237, .22); --grey-soft: rgba(138, 146, 156, .22);
  --shadow: 0 1px 2px rgba(0, 0, 0, .4);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--text);
  font: 14px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
.ic { flex-shrink: 0; vertical-align: middle; }
h1, h2, h3 { margin: 0; line-height: 1.25; }
h1 { font-size: 22px; font-weight: 700; }
h2 { font-size: 16px; font-weight: 650; }
h3 { font-size: 14px; font-weight: 650; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.mono { font-variant-numeric: tabular-nums; }

/* ---------- Gerüst ---------- */
.app { min-height: 100vh; }
.topbar {
  position: fixed; inset: 0 0 auto 0; height: var(--topbar-h); z-index: 30;
  display: flex; align-items: center; gap: 12px; padding: 0 16px;
  background: var(--topbar); border-bottom: 1px solid var(--border);
}
.topbar::before { content: ""; position: absolute; left: 0; right: 0; top: 0; height: 3px; background: var(--red); }
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); text-decoration: none !important; min-width: 0; }
.brand-mark {
  width: 34px; height: 34px; border-radius: 8px; display: grid; place-items: center;
  background: var(--red); color: #fff;
}
.brand-text { display: flex; flex-direction: column; min-width: 0; }
.brand-text strong { font-size: 15px; line-height: 1.1; }
.brand-text small { color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 6px; }
.icon-btn {
  display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: 8px;
  border: 0; background: transparent; color: var(--muted); cursor: pointer;
}
.icon-btn:hover { background: var(--hover); color: var(--text); text-decoration: none; }
.avatar {
  width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center;
  background: var(--red-soft); color: var(--red); font-weight: 700; font-size: 12px;
}
.only-dark { display: none; }
:root[data-theme="dark"] .only-dark { display: inline; }
:root[data-theme="dark"] .only-light { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .only-dark { display: inline; }
  :root:not([data-theme="light"]) .only-light { display: none; }
}
.nav-toggle { display: none; }

.sidebar {
  position: fixed; top: var(--topbar-h); bottom: 0; left: 0; width: var(--sidebar-w); z-index: 20;
  background: var(--sidebar); border-right: 1px solid var(--border);
  padding: 14px 10px; display: flex; flex-direction: column; gap: 2px; overflow-y: auto;
}
.nav-label { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding: 6px 12px; }
.nav-item {
  display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 8px;
  color: var(--text); font-weight: 500; position: relative;
}
.nav-item .ic { color: var(--muted); }
.nav-item:hover { background: var(--hover); text-decoration: none; }
.nav-item.active { background: var(--red-soft); color: var(--red); }
.nav-item.active .ic { color: var(--red); }
.nav-item.active::before {
  content: ""; position: absolute; left: -10px; top: 8px; bottom: 8px; width: 3px; border-radius: 0 3px 3px 0; background: var(--red);
}
.sidebar-foot { margin-top: auto; padding: 12px; font-size: 12px; color: var(--muted); border-top: 1px solid var(--border); }
.sidebar-foot strong { color: var(--text); }
.nav-backdrop { display: none; }

.content { margin-left: var(--sidebar-w); padding: calc(var(--topbar-h) + 22px) 26px 40px; max-width: 1400px; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }

@media (max-width: 900px) {
  .nav-toggle { display: inline-grid; }
  .sidebar { transform: translateX(-100%); transition: transform .2s; box-shadow: var(--shadow); }
  body.nav-open .sidebar { transform: none; }
  body.nav-open .nav-backdrop { display: block; position: fixed; inset: var(--topbar-h) 0 0 0; background: rgba(0,0,0,.35); z-index: 15; }
  .content { margin-left: 0; padding: calc(var(--topbar-h) + 16px) 16px 32px; }
  .brand-text small { display: none; }
}

/* ---------- Karten & Raster ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 18px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.card-head h2 { display: flex; align-items: center; gap: 8px; }
.card-head h2 .ic { color: var(--red); }
.card-body { padding: 18px; }
.card-body.flush { padding: 0; }
.grid { display: grid; gap: 18px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
@media (max-width: 1100px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } }

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; margin-bottom: 18px; }
.kpi {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px 16px; box-shadow: var(--shadow); display: flex; gap: 12px; align-items: center;
}
.kpi-ic { width: 40px; height: 40px; border-radius: 10px; display: grid; place-items: center; flex-shrink: 0; }
.kpi-ic.red { background: var(--red-soft); color: var(--red); }
.kpi-ic.green { background: var(--green-soft); color: var(--green); }
.kpi-ic.amber { background: var(--amber-soft); color: var(--amber); }
.kpi-ic.blue { background: var(--blue-soft); color: var(--blue); }
.kpi-val { font-size: 22px; font-weight: 700; line-height: 1.1; font-variant-numeric: tabular-nums; }
.kpi-lbl { color: var(--muted); font-size: 12.5px; }

/* ---------- Tabellen ---------- */
.table-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; }
.tbl th, .tbl td { padding: 10px 14px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: middle; }
.tbl th { font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; background: var(--surface-2); white-space: nowrap; }
.tbl tbody tr:hover { background: var(--hover); }
.tbl tbody tr:last-child td { border-bottom: 0; }
.tbl tr.vergangen td { opacity: .6; }
.tbl tr.storniert td { opacity: .55; }
.tbl tr.storniert .name { text-decoration: line-through; }
.tbl .chk { width: 34px; }
.empty { padding: 34px 18px; text-align: center; color: var(--muted); }

/* ---------- Badges ---------- */
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.badge-red { background: var(--red-soft); color: var(--red); }
.badge-green { background: var(--green-soft); color: var(--green); }
.badge-amber { background: var(--amber-soft); color: var(--amber); }
.badge-blue { background: var(--blue-soft); color: var(--blue); }
.badge-grey { background: var(--grey-soft); color: var(--muted); }
.tag { display: inline-block; padding: 1px 7px; border-radius: 6px; font-size: 11.5px; font-weight: 700; background: var(--surface-2); border: 1px solid var(--border); color: var(--muted); }

/* ---------- Kontingent ---------- */
.quota { min-width: 150px; }
.quota-bar { position: relative; height: 8px; border-radius: 99px; background: var(--grey-soft); overflow: hidden; }
.quota-fill, .quota-conf { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 99px; }
.bar-green .quota-fill { background: var(--green); opacity: .45; }
.bar-amber .quota-fill { background: var(--amber); opacity: .5; }
.bar-red .quota-fill { background: var(--red); opacity: .5; }
.bar-grey .quota-fill { background: var(--grey); }
.quota-conf { background: var(--green); }
.bar-red .quota-conf, .bar-amber .quota-conf { background: var(--green); }
.quota-txt { font-size: 12px; color: var(--muted); margin-top: 4px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.quota-txt strong { color: var(--text); }
.frei-green { color: var(--green); font-weight: 600; }
.frei-amber { color: var(--amber); font-weight: 600; }
.frei-red { color: var(--red); font-weight: 600; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--muted); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }

.date-box { display: inline-flex; flex-direction: column; align-items: center; justify-content: center; width: 46px; height: 46px; border-radius: 9px; background: var(--red-soft); color: var(--red); line-height: 1; flex-shrink: 0; }
.date-box b { font-size: 17px; }
.date-box small { font-size: 10.5px; text-transform: uppercase; margin-top: 3px; font-weight: 600; }
.termin-cell { display: flex; align-items: center; gap: 12px; }
.termin-cell .t-title { font-weight: 600; color: var(--text); }

/* ---------- Formulare ---------- */
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; }
.field { display: flex; flex-direction: column; gap: 5px; }
.field.wide { grid-column: 1 / -1; }
label, .lbl { font-size: 12.5px; font-weight: 600; color: var(--muted); }
input[type=text], input[type=email], input[type=password], input[type=date], input[type=number], input[type=search], select, textarea {
  width: 100%; padding: 8px 11px; border: 1px solid var(--border); border-radius: 8px;
  background: var(--surface); color: var(--text); font: inherit; min-height: 38px;
}
textarea { min-height: 80px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--red-soft); border-color: var(--red); }
input[type=file] { font: inherit; color: var(--muted); }
.check { display: inline-flex; align-items: center; gap: 8px; font-weight: 500; color: var(--text); cursor: pointer; }
input[type=checkbox] { width: 16px; height: 16px; accent-color: var(--red); }
.form-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 16px; }
.filter-bar { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
.filter-bar .field { min-width: 150px; flex: 1; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px; padding: 8px 14px; min-height: 38px;
  border-radius: 8px; border: 1px solid var(--border); background: var(--surface); color: var(--text);
  font: inherit; font-weight: 600; cursor: pointer; white-space: nowrap; text-decoration: none !important;
}
.btn:hover { background: var(--hover); }
.btn-primary { background: var(--red); border-color: var(--red); color: #fff; }
.btn-primary:hover { background: var(--red-dark); }
.btn-green { background: var(--green); border-color: var(--green); color: #fff; }
.btn-green:hover { filter: brightness(.93); background: var(--green); }
.btn-blue { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn-blue:hover { filter: brightness(.93); background: var(--blue); }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-danger { color: var(--red); }
.btn-sm { padding: 4px 9px; min-height: 30px; font-size: 13px; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.inline { display: inline; }

.alert { display: flex; gap: 10px; align-items: flex-start; padding: 11px 14px; border-radius: 9px; margin-bottom: 14px; border: 1px solid; }
.alert-success { background: var(--green-soft); border-color: transparent; color: var(--green); }
.alert-error { background: var(--red-soft); border-color: transparent; color: var(--red); }
.alert-info { background: var(--blue-soft); border-color: transparent; color: var(--blue); }
.alert span { color: var(--text); }

/* ---------- Buchungsformular ---------- */
.termin-pick { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 10px; }
.termin-opt { display: flex; gap: 10px; align-items: flex-start; padding: 12px; border: 1px solid var(--border); border-radius: 9px; cursor: pointer; background: var(--surface); }
.termin-opt:hover { border-color: var(--red); }
.termin-opt:has(input:checked) { border-color: var(--red); background: var(--red-soft); }
.termin-opt.voll { opacity: .5; cursor: not-allowed; }
.termin-opt .t-title { font-weight: 650; }
.tn-row td { padding: 6px 6px; }
.tn-row input, .tn-row select { min-height: 34px; padding: 6px 8px; }
.sticky-bar { position: sticky; bottom: 0; background: var(--surface); border-top: 1px solid var(--border); padding: 12px 18px; display: flex; gap: 10px; align-items: center; justify-content: space-between; flex-wrap: wrap; border-radius: 0 0 var(--radius) var(--radius); }

.bulk-bar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; padding: 12px 18px; border-top: 1px solid var(--border); background: var(--surface-2); }
.dropzone { border: 2px dashed var(--border); border-radius: 10px; padding: 18px; text-align: center; color: var(--muted); transition: border-color .15s, background .15s; }
.dropzone.drag { border-color: var(--red); background: var(--red-soft); }
.dropzone .ic { color: var(--red); }

.doc-list { list-style: none; margin: 0; padding: 0; }
.doc-list li { display: flex; align-items: center; gap: 10px; padding: 10px 18px; border-bottom: 1px solid var(--border); }
.doc-list li:last-child { border-bottom: 0; }
.doc-list .doc-ic { width: 34px; height: 34px; border-radius: 8px; background: var(--blue-soft); color: var(--blue); display: grid; place-items: center; flex-shrink: 0; }
.doc-list .doc-main { flex: 1; min-width: 0; }
.doc-list .doc-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: block; }

/* ---------- Diagramme (reines CSS/SVG) ---------- */
.hbars { display: flex; flex-direction: column; gap: 10px; }
.hbar { display: grid; grid-template-columns: minmax(110px, 200px) 1fr 54px; gap: 10px; align-items: center; }
.hbar-lbl { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hbar-track { height: 14px; background: var(--grey-soft); border-radius: 4px; overflow: hidden; display: flex; }
.hbar-track span { display: block; height: 100%; }
.seg-green { background: var(--green); }
.seg-blue { background: var(--blue); }
.seg-amber { background: var(--amber); }
.seg-red { background: var(--red); }
.seg-grey { background: var(--grey); }
.hbar-val { text-align: right; font-weight: 650; font-variant-numeric: tabular-nums; }
.vchart { width: 100%; height: auto; display: block; }
.vchart text { fill: var(--muted); font-size: 11px; font-family: inherit; }
.vchart .grid-l { stroke: var(--border); }
.vchart .bar { fill: var(--red); }
.vchart .bar:hover { fill: var(--red-dark); }
.vchart .val { fill: var(--text); font-weight: 600; }
.donut-wrap { display: flex; gap: 20px; align-items: center; flex-wrap: wrap; }
.donut-wrap svg { width: 150px; height: 150px; flex-shrink: 0; }
.donut-center { fill: var(--text); font-size: 22px; font-weight: 700; }
.donut-sub { fill: var(--muted); font-size: 10px; }
.matrix td.cell { text-align: center; font-variant-numeric: tabular-nums; }
.matrix td.cell.z { color: var(--muted); }

/* ---------- Login (Split-Screen) ---------- */
.auth { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; }
.auth-side {
  background: linear-gradient(150deg, var(--red) 0%, var(--red-dark) 100%); color: #fff;
  padding: 48px; display: flex; flex-direction: column; justify-content: space-between; position: relative; overflow: hidden;
}
.auth-side::after {
  content: ""; position: absolute; right: -120px; bottom: -120px; width: 420px; height: 420px; border-radius: 50%;
  border: 60px solid rgba(255,255,255,.07);
}
.auth-side .brand-mark { background: rgba(255,255,255,.18); width: 44px; height: 44px; }
.auth-side h1 { font-size: 34px; margin: 18px 0 10px; }
.auth-side p { opacity: .85; max-width: 420px; font-size: 15px; }
.auth-feat { list-style: none; padding: 0; margin: 26px 0 0; display: grid; gap: 12px; }
.auth-feat li { display: flex; gap: 10px; align-items: center; opacity: .95; }
.auth-main { display: flex; align-items: center; justify-content: center; padding: 32px; background: var(--surface); }
.auth-box { width: 100%; max-width: 360px; }
.auth-box h2 { font-size: 22px; margin-bottom: 4px; }
.auth-box .field { margin-top: 14px; }
.auth-box .btn { width: 100%; margin-top: 20px; }
@media (max-width: 860px) {
  .auth { grid-template-columns: 1fr; }
  .auth-side { padding: 28px; }
  .auth-side h1 { font-size: 24px; }
  .auth-feat { display: none; }
}

@media print {
  .topbar, .sidebar, .page-actions, .bulk-bar, .no-print, .btn { display: none !important; }
  .content { margin: 0; padding: 0; }
  .card { box-shadow: none; break-inside: avoid; }
}
