/* BKF-Verwaltung – Oberfläche im Karteikarten-Stil
   Keine externen Schriften (DSGVO): Systemschriften. */
:root {
  --primary: #1f5aa6;
  --primary-dark: #17467f;
  --primary-soft: #e8f0fa;
  --accent: #f2b100;
  --accent-soft: #fff6d6;
  --ink: #142030;
  --ink-2: #1c2c40;
  --ink-3: #2a3d55;
  --bg: #f3f2ee;
  --surface: #ffffff;
  --surface-2: #faf9f6;
  --border: #e3e1da;
  --border-strong: #cfccc3;
  --text: #1a2330;
  --muted: #6a7382;
  --success: #1e7d46;
  --success-soft: #e3f4ea;
  --warning: #a56800;
  --warning-soft: #fdf0d5;
  --danger: #b8352a;
  --danger-soft: #fbe6e3;
  --info: #2a62a8;
  --info-soft: #e5eef9;
  --radius: 8px;
  --radius-sm: 5px;
  --shadow: 0 1px 2px rgba(20,32,48,.06), 0 2px 8px rgba(20,32,48,.04);
  --shadow-lg: 0 8px 30px rgba(20,32,48,.16);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --sidebar-w: 248px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 14.5px/1.5 var(--font); color: var(--text); background: var(--bg); }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0 0 .5em; line-height: 1.25; font-weight: 650; letter-spacing: -.01em; }
h1 { font-size: 1.55rem; } h2 { font-size: 1.2rem; } h3 { font-size: 1.05rem; } h4 { font-size: .95rem; }
p { margin: 0 0 .8em; }
small, .small { font-size: .85em; }
.muted { color: var(--muted); }
.mono { font-family: var(--mono); font-size: .92em; }
.num { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.nowrap { white-space: nowrap; }
.hidden { display: none !important; }
hr { border: 0; border-top: 1px solid var(--border); margin: 1.2rem 0; }
.icon { flex: none; vertical-align: -3px; }

/* ---------- Layout ---------- */
.app { display: flex; min-height: 100vh; }
.sidebar { width: var(--sidebar-w); background: var(--ink); color: #c9d2de; position: fixed; inset: 0 auto 0 0; display: flex; flex-direction: column; z-index: 40; transition: transform .2s; }
.sidebar .brand { display: flex; align-items: center; gap: .7rem; padding: 1rem 1.1rem; color: #fff; font-weight: 700; font-size: 1.02rem; border-bottom: 1px solid rgba(255,255,255,.07); min-height: 60px; }
.sidebar .brand img { max-height: 34px; max-width: 120px; background: #fff; border-radius: 4px; padding: 2px; }
.sidebar .brand .mark { width: 32px; height: 32px; border-radius: 6px; background: var(--accent); color: var(--ink); display: grid; place-items: center; font-weight: 800; font-size: .68rem; letter-spacing: .02em; flex: none; }
.sidebar nav { flex: 1; overflow-y: auto; padding: .6rem 0 1rem; }
.sidebar .nav-group { padding: .9rem 1.1rem .3rem; font-size: .7rem; text-transform: uppercase; letter-spacing: .09em; color: #7f8ca0; font-weight: 600; }
.sidebar a.nav { display: flex; align-items: center; gap: .65rem; padding: .48rem 1.1rem; color: #c9d2de; border-left: 3px solid transparent; font-size: .93rem; }
.sidebar a.nav:hover { background: var(--ink-2); color: #fff; text-decoration: none; }
.sidebar a.nav.active { background: var(--ink-2); color: #fff; border-left-color: var(--accent); }
.sidebar a.nav .count { margin-left: auto; background: var(--accent); color: var(--ink); border-radius: 9px; font-size: .72rem; font-weight: 700; padding: 0 .45rem; line-height: 1.5; }
.sidebar .side-foot { padding: .7rem 1.1rem; font-size: .75rem; color: #7f8ca0; border-top: 1px solid rgba(255,255,255,.07); }
.main { flex: 1; margin-left: var(--sidebar-w); min-width: 0; display: flex; flex-direction: column; }
.topbar { height: 60px; background: var(--surface); border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: .8rem; padding: 0 1.4rem; position: sticky; top: 0; z-index: 30; }
.topbar .search { flex: 1; max-width: 460px; position: relative; }
.topbar .search input { width: 100%; padding: .5rem .8rem .5rem 2.2rem; border: 1px solid var(--border); border-radius: 20px; background: var(--surface-2); }
.topbar .search .icon { position: absolute; left: .75rem; top: .62rem; color: var(--muted); }
.topbar .spacer { flex: 1; }
.topbar .mandant select { border: 1px solid var(--border); border-radius: 6px; padding: .35rem .5rem; background: var(--surface-2); max-width: 220px; }
.icon-btn { position: relative; background: none; border: 0; padding: .45rem; border-radius: 6px; color: var(--text); cursor: pointer; display: inline-flex; }
.icon-btn:hover { background: var(--bg); }
.icon-btn .dot { position: absolute; top: 2px; right: 0; background: var(--danger); color: #fff; font-size: .65rem; font-weight: 700; border-radius: 8px; padding: 0 .3rem; line-height: 1.45; }
.menu-toggle { display: none; }
.content { padding: 1.5rem 1.6rem 3rem; max-width: 1500px; width: 100%; }
.backdrop { display: none; }

@media (max-width: 1024px) {
  .sidebar { transform: translateX(-100%); }
  body.nav-open .sidebar { transform: none; box-shadow: var(--shadow-lg); }
  body.nav-open .backdrop { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 35; }
  .main { margin-left: 0; }
  .menu-toggle { display: inline-flex; }
  .topbar .mandant { display: none; }
  .content { padding: 1rem; }
}

/* ---------- Seitenkopf ---------- */
.page-head { display: flex; align-items: flex-start; gap: 1rem; margin-bottom: 1.2rem; flex-wrap: wrap; }
.page-head .titles { flex: 1; min-width: 220px; }
.page-head h1 { margin-bottom: .15rem; }
.page-head .sub { color: var(--muted); }
.page-head .actions { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
.breadcrumb { font-size: .82rem; color: var(--muted); margin-bottom: .3rem; }
.breadcrumb a { color: var(--muted); }

/* ---------- Karten / Karteikarten ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 1.2rem; }
.card-head { display: flex; align-items: center; gap: .7rem; padding: .85rem 1.1rem; border-bottom: 1px solid var(--border); }
.card-head h2, .card-head h3 { margin: 0; font-size: 1rem; flex: 1; }
.card-head .actions { display: flex; gap: .4rem; }
.card-body { padding: 1.1rem; }
.card-body.flush { padding: 0; }
.card-foot { padding: .75rem 1.1rem; border-top: 1px solid var(--border); background: var(--surface-2); border-radius: 0 0 var(--radius) var(--radius); display: flex; gap: .5rem; justify-content: flex-end; flex-wrap: wrap; }
.tabs { display: flex; gap: .25rem; padding: 0 .4rem; margin-bottom: -1px; position: relative; z-index: 1; overflow-x: auto; scrollbar-width: none; }
.tabs a { padding: .55rem 1rem; border: 1px solid transparent; border-bottom: 0; border-radius: var(--radius) var(--radius) 0 0; color: var(--muted); white-space: nowrap; font-weight: 550; font-size: .92rem; }
.tabs a:hover { color: var(--text); text-decoration: none; background: rgba(255,255,255,.55); }
.tabs a.active { background: var(--surface); border-color: var(--border); color: var(--text); box-shadow: 0 -2px 0 var(--accent) inset; }
.tabs a .count { font-size: .75rem; color: var(--muted); margin-left: .25rem; }
.tabbed > .card { border-top-left-radius: 0; }
.grid { display: grid; gap: 1.2rem; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-sidebar { grid-template-columns: minmax(0, 1fr) 340px; }
@media (max-width: 1100px) { .grid-3, .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .grid-sidebar { grid-template-columns: 1fr; } }
@media (max-width: 720px) { .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; } }

/* ---------- Kennzahlen ---------- */
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem 1.1rem; box-shadow: var(--shadow); display: block; color: inherit; }
a.stat:hover { text-decoration: none; border-color: var(--border-strong); }
.stat .label { font-size: .8rem; color: var(--muted); font-weight: 550; }
.stat .value { font-size: 1.75rem; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.2; margin-top: .2rem; }
.stat .hint { font-size: .8rem; color: var(--muted); }
.stat.warn .value { color: var(--warning); } .stat.bad .value { color: var(--danger); } .stat.good .value { color: var(--success); }

/* ---------- Tabellen ---------- */
.table-wrap { overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: .6rem .8rem; text-align: left; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table th { font-size: .76rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 600; background: var(--surface-2); white-space: nowrap; }
.table th a.sort { color: var(--muted); }
.table tbody tr:hover { background: #fbfaf7; }
.table tr:last-child td { border-bottom: 0; }
.table td.actions { text-align: right; white-space: nowrap; }
.table .row-link { color: inherit; font-weight: 600; }
.table.compact th, .table.compact td { padding: .4rem .6rem; }
.table tr.muted td { color: var(--muted); }
.table tfoot td { font-weight: 650; background: var(--surface-2); }
.cell-sub { display: block; font-size: .82rem; color: var(--muted); font-weight: 400; }

/* ---------- Badges / Chips ---------- */
.badge { display: inline-block; padding: .08rem .5rem; border-radius: 10px; font-size: .76rem; font-weight: 600; white-space: nowrap; line-height: 1.55; background: #eceae4; color: #454c57; }
.badge-success { background: var(--success-soft); color: var(--success); }
.badge-warning { background: var(--warning-soft); color: var(--warning); }
.badge-danger { background: var(--danger-soft); color: var(--danger); }
.badge-info { background: var(--info-soft); color: var(--info); }
.badge-primary { background: var(--primary-soft); color: var(--primary); }
.badge-dark { background: var(--ink-3); color: #fff; }
.chip { display: inline-flex; align-items: center; gap: .25rem; padding: .05rem .45rem; border-radius: 4px; font-size: .78rem; font-weight: 600; font-family: var(--mono); border: 1px solid var(--border); background: var(--surface-2); margin: 0 .2rem .25rem 0; }
.chip.ok { background: var(--success-soft); border-color: #bfe3cc; color: var(--success); }
.chip.open { background: var(--surface); border-style: dashed; color: var(--muted); }
.chip.old { background: #f1f1ef; color: #9aa0a8; text-decoration: line-through; }
.dot-color { display: inline-block; width: 10px; height: 10px; border-radius: 50%; vertical-align: 0; margin-right: .3rem; }

/* ---------- Buttons ---------- */
.btn { display: inline-flex; align-items: center; gap: .4rem; padding: .48rem .9rem; border-radius: 6px; border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); font: inherit; font-weight: 550; font-size: .9rem; cursor: pointer; line-height: 1.3; white-space: nowrap; }
.btn:hover { text-decoration: none; background: var(--surface-2); border-color: #b9b5aa; }
.btn:disabled, .btn.disabled { opacity: .55; pointer-events: none; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); color: #fff; }
.btn-accent { background: var(--accent); border-color: var(--accent); color: var(--ink); }
.btn-accent:hover { background: #e0a400; border-color: #e0a400; }
.btn-danger { color: var(--danger); border-color: #e5b6b0; }
.btn-danger:hover { background: var(--danger-soft); border-color: var(--danger); }
.btn-danger.solid { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-ghost:hover { background: var(--bg); border-color: transparent; }
.btn-sm { padding: .28rem .6rem; font-size: .82rem; }
.btn-xs { padding: .12rem .45rem; font-size: .76rem; }
.btn-block { width: 100%; justify-content: center; }
.btn-group { display: inline-flex; }
.btn-group .btn { border-radius: 0; margin-left: -1px; }
.btn-group .btn:first-child { border-radius: 6px 0 0 6px; margin-left: 0; }
.btn-group .btn:last-child { border-radius: 0 6px 6px 0; }
.btn-group .btn.active { background: var(--primary-soft); border-color: var(--primary); color: var(--primary); z-index: 1; }
form.inline { display: inline; }

/* ---------- Formulare ---------- */
.form-grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: .2rem 1rem; }
.form-grid > .field { grid-column: span 6; }
.form-grid > .span-2 { grid-column: span 2; } .form-grid > .span-3 { grid-column: span 3; } .form-grid > .span-4 { grid-column: span 4; }
.form-grid > .span-5 { grid-column: span 5; } .form-grid > .span-8 { grid-column: span 8; } .form-grid > .span-9 { grid-column: span 9; } .form-grid > .span-12, .form-grid > .full { grid-column: 1 / -1; }
@media (max-width: 720px) { .form-grid > .field, .form-grid > [class*=span-] { grid-column: 1 / -1; } }
.form-section { grid-column: 1 / -1; margin: .9rem 0 .2rem; padding-bottom: .3rem; border-bottom: 1px solid var(--border); font-weight: 650; font-size: .95rem; }
.form-section:first-child { margin-top: 0; }
.field { margin-bottom: .75rem; }
.field label { display: block; font-size: .83rem; font-weight: 600; margin-bottom: .25rem; color: #3a4350; }
.field .req { color: var(--danger); }
input[type=text], input[type=email], input[type=password], input[type=date], input[type=time], input[type=number], input[type=search], input[type=url], input[type=tel], input[type=datetime-local], select, textarea {
  width: 100%; padding: .5rem .65rem; border: 1px solid var(--border-strong); border-radius: 6px; font: inherit; color: var(--text); background: #fff; transition: border-color .15s, box-shadow .15s;
}
textarea { resize: vertical; min-height: 70px; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(31,90,166,.15); }
input[readonly] { background: var(--surface-2); }
.is-invalid input, .is-invalid select, .is-invalid textarea { border-color: var(--danger); }
.field-error { color: var(--danger); font-size: .8rem; margin-top: .2rem; }
.help { color: var(--muted); font-size: .8rem; margin-top: .2rem; }
.input-group { display: flex; }
.input-group input { border-radius: 6px 0 0 6px; }
.input-group .suffix { border: 1px solid var(--border-strong); border-left: 0; padding: .5rem .65rem; border-radius: 0 6px 6px 0; background: var(--surface-2); color: var(--muted); }
label.check { display: inline-flex; align-items: center; gap: .45rem; font-weight: 500; cursor: pointer; font-size: .92rem; margin-right: 1rem; }
label.check input { width: 16px; height: 16px; accent-color: var(--primary); }
.field-check { padding-top: .2rem; }
.check-group { display: flex; flex-direction: column; gap: .3rem; }
.check-group.inline { flex-direction: row; flex-wrap: wrap; gap: .3rem 0; }
.filters { display: flex; gap: .6rem; flex-wrap: wrap; align-items: flex-end; margin-bottom: 1rem; }
.filters .field { margin: 0; min-width: 150px; }
.filters input, .filters select { padding: .42rem .6rem; }

/* ---------- Meldungen ---------- */
.alert { padding: .75rem 1rem; border-radius: var(--radius-sm); margin-bottom: 1rem; border: 1px solid; display: flex; gap: .6rem; align-items: flex-start; }
.alert .icon { margin-top: 2px; }
.alert-success { background: var(--success-soft); border-color: #bfe3cc; color: #145a33; }
.alert-error, .alert-danger { background: var(--danger-soft); border-color: #efc2bc; color: #8c2219; }
.alert-warning { background: var(--warning-soft); border-color: #f0d79f; color: #7a4d00; }
.alert-info { background: var(--info-soft); border-color: #c4d8f1; color: #1f4a80; }
.alert ul { margin: .3rem 0 0; padding-left: 1.2rem; }
.empty { text-align: center; padding: 2.5rem 1rem; color: var(--muted); }
.empty .icon { width: 36px; height: 36px; color: #b9b5aa; margin-bottom: .4rem; }

/* ---------- Detail-Listen ---------- */
dl.props { display: grid; grid-template-columns: minmax(130px, 38%) 1fr; gap: .35rem .9rem; margin: 0; }
dl.props dt { color: var(--muted); font-size: .86rem; }
dl.props dd { margin: 0; font-weight: 500; overflow-wrap: anywhere; }
.kv-inline { display: flex; gap: 1.5rem; flex-wrap: wrap; }
.kv-inline div span { display: block; font-size: .78rem; color: var(--muted); }

/* ---------- Avatare / Personen ---------- */
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--primary-soft); color: var(--primary); display: inline-grid; place-items: center; font-weight: 700; font-size: .8rem; flex: none; }
.avatar.lg { width: 54px; height: 54px; font-size: 1.1rem; }
.person { display: flex; align-items: center; gap: .6rem; }

/* ---------- Dropdowns / Modal ---------- */
.dropdown { position: relative; }
.dropdown-menu { position: absolute; right: 0; top: calc(100% + 6px); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-lg); min-width: 220px; z-index: 50; display: none; padding: .35rem 0; }
.dropdown.open .dropdown-menu { display: block; }
.dropdown-menu a, .dropdown-menu button { display: flex; gap: .5rem; align-items: center; width: 100%; padding: .45rem .9rem; color: var(--text); background: none; border: 0; font: inherit; text-align: left; cursor: pointer; }
.dropdown-menu a:hover, .dropdown-menu button:hover { background: var(--bg); text-decoration: none; }
.dropdown-menu .sep { border-top: 1px solid var(--border); margin: .3rem 0; }
.dropdown-menu .head { padding: .5rem .9rem; font-size: .82rem; color: var(--muted); }
.notif-list { max-height: 380px; overflow-y: auto; min-width: 320px; }
.notif-list a { display: block; padding: .55rem .9rem; border-bottom: 1px solid var(--border); }
.notif-list a strong { display: block; font-size: .88rem; }
.notif-list a span { font-size: .8rem; color: var(--muted); }
.modal { position: fixed; inset: 0; background: rgba(20,32,48,.45); display: none; align-items: flex-start; justify-content: center; padding: 6vh 1rem; z-index: 100; overflow-y: auto; }
.modal.open { display: flex; }
.modal-box { background: var(--surface); border-radius: 10px; box-shadow: var(--shadow-lg); width: 100%; max-width: 560px; }
.modal-box.wide { max-width: 860px; }
.modal-head { padding: .9rem 1.1rem; border-bottom: 1px solid var(--border); display: flex; align-items: center; }
.modal-head h3 { margin: 0; flex: 1; }
.modal-body { padding: 1.1rem; }
.modal-foot { padding: .8rem 1.1rem; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: .5rem; background: var(--surface-2); border-radius: 0 0 10px 10px; }

/* ---------- Fortschritt ---------- */
.progress { height: 8px; background: #e8e6df; border-radius: 4px; overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--primary); border-radius: 4px; transition: width .3s; }
.progress.ok > span { background: var(--success); } .progress.warn > span { background: var(--accent); } .progress.bad > span { background: var(--danger); }
.progress-lg { height: 14px; }
.job-box { border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem; background: var(--surface-2); }
.job-box .job-msg { margin-top: .5rem; font-size: .88rem; color: var(--muted); }

/* ---------- Zeitleiste / Verlauf ---------- */
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { position: relative; padding: 0 0 .9rem 1.4rem; border-left: 2px solid var(--border); margin-left: .4rem; }
.timeline li::before { content: ''; position: absolute; left: -6px; top: .3rem; width: 10px; height: 10px; border-radius: 50%; background: var(--surface); border: 2px solid var(--primary); }
.timeline li:last-child { border-left-color: transparent; }
.timeline .when { font-size: .78rem; color: var(--muted); }

/* ---------- Kalender ---------- */
.cal-wrap { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 1.2rem; }
@media (max-width: 1100px) { .cal-wrap { grid-template-columns: 1fr; } }
.cal-head { display: flex; align-items: center; gap: .6rem; margin-bottom: .6rem; flex-wrap: wrap; }
.cal-head h2 { margin: 0; min-width: 170px; }
.calendar { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); border-top: 1px solid var(--border); border-left: 1px solid var(--border); background: var(--surface); border-radius: var(--radius); overflow: hidden; }
.calendar .dow { background: var(--surface-2); font-size: .74rem; text-transform: uppercase; color: var(--muted); font-weight: 600; padding: .4rem .5rem; border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.calendar .day { min-height: 104px; border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); padding: .3rem; position: relative; display: block; color: inherit; }
.calendar .day:hover { background: #fbfaf6; text-decoration: none; }
.calendar .day.other { background: #f8f7f3; color: #a8a49a; }
.calendar .day.today .dnum { background: var(--primary); color: #fff; }
.calendar .day.selected { box-shadow: inset 0 0 0 2px var(--accent); }
.calendar .dnum { display: inline-block; min-width: 22px; height: 22px; line-height: 22px; text-align: center; border-radius: 11px; font-size: .8rem; font-weight: 600; }
.calendar .day .add { position: absolute; right: 4px; top: 3px; opacity: 0; font-size: .9rem; color: var(--muted); }
.calendar .day:hover .add { opacity: 1; }
.cal-ev { display: block; font-size: .74rem; padding: .08rem .35rem; border-radius: 3px; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; border-left: 3px solid; }
.cal-ev.m95 { background: #e6eefb; border-color: #1f5aa6; color: #173f73; }
.cal-ev.schulung { background: #e5f4ec; border-color: #1e7d46; color: #145a33; }
.cal-ev.bgq { background: #fdf0d5; border-color: #c88a00; color: #6d4700; }
.cal-ev.abgesagt { text-decoration: line-through; opacity: .6; }
.legend { display: flex; gap: 1rem; font-size: .8rem; color: var(--muted); flex-wrap: wrap; }
.legend span::before { content: ''; display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: .3rem; vertical-align: -1px; }
.legend .m95::before { background: #1f5aa6; } .legend .schulung::before { background: #1e7d46; } .legend .bgq::before { background: #c88a00; }
.ev-card { border: 1px solid var(--border); border-left: 4px solid var(--primary); border-radius: 6px; padding: .6rem .75rem; margin-bottom: .6rem; background: var(--surface); display: block; color: inherit; }
.ev-card:hover { text-decoration: none; border-color: var(--border-strong); }
.ev-card.schulung { border-left-color: var(--success); } .ev-card.bgq { border-left-color: #c88a00; }
.ev-card .t { font-weight: 650; }
.ev-card .m { font-size: .82rem; color: var(--muted); }

/* ---------- Kapazität ---------- */
.seats { display: flex; gap: 2px; flex-wrap: wrap; }
.seats i { width: 12px; height: 12px; border-radius: 2px; background: #e6e3dc; display: inline-block; }
.seats i.b { background: var(--primary); } .seats i.r { background: var(--accent); } .seats i.a { background: #9db8de; }

/* ---------- Matrix (Anwesenheit / Module) ---------- */
.matrix th, .matrix td { text-align: center; }
.matrix th:first-child, .matrix td:first-child { text-align: left; }
.matrix .cell-toggle { width: 30px; height: 30px; border-radius: 6px; border: 1px solid var(--border-strong); background: #fff; cursor: pointer; display: inline-grid; place-items: center; }
.matrix .cell-toggle.on { background: var(--success); border-color: var(--success); color: #fff; }
.matrix .cell-toggle.off { background: var(--danger-soft); border-color: #e5b6b0; color: var(--danger); }
.matrix .cell-toggle:disabled { opacity: .4; cursor: default; }
.sig-thumb { height: 26px; vertical-align: middle; border: 1px solid var(--border); border-radius: 3px; background: #fff; }

/* ---------- Signatur / QR ---------- */
.sig-pad { border: 2px dashed var(--border-strong); border-radius: 8px; background: #fff; touch-action: none; width: 100%; height: 200px; display: block; cursor: crosshair; }
.qr-video { width: 100%; max-width: 520px; border-radius: 8px; background: #000; display: block; margin: 0 auto; }
.scan-result { font-size: 1.05rem; font-weight: 650; text-align: center; padding: .7rem; border-radius: 6px; margin-top: .6rem; }
.scan-result.ok { background: var(--success-soft); color: var(--success); }
.scan-result.err { background: var(--danger-soft); color: var(--danger); }

/* ---------- Auth / einfache Seiten ---------- */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 2rem 1rem; background: var(--ink) linear-gradient(135deg, var(--ink) 0%, var(--ink-3) 100%); }
.auth-box { width: 100%; max-width: 410px; background: var(--surface); border-radius: 12px; box-shadow: var(--shadow-lg); padding: 2rem; }
.auth-box.wide { max-width: 760px; }
.auth-brand { display: flex; align-items: center; gap: .7rem; margin-bottom: 1.4rem; }
.auth-brand .mark { width: 40px; height: 40px; border-radius: 8px; background: var(--accent); display: grid; place-items: center; font-weight: 800; color: var(--ink); }
.auth-brand img { max-height: 48px; max-width: 180px; }
.auth-brand .name { font-weight: 700; font-size: 1.1rem; }
.auth-foot { margin-top: 1rem; font-size: .85rem; text-align: center; color: var(--muted); }
.bare { padding: 2rem 1rem; max-width: 900px; margin: 0 auto; }
.steps { display: flex; gap: .4rem; margin-bottom: 1.4rem; flex-wrap: wrap; }
.steps span { flex: 1; min-width: 90px; text-align: center; padding: .4rem; border-radius: 5px; background: var(--bg); font-size: .8rem; color: var(--muted); font-weight: 600; }
.steps span.active { background: var(--primary); color: #fff; }
.steps span.done { background: var(--success-soft); color: var(--success); }
.checklist { list-style: none; padding: 0; margin: 0; }
.checklist li { padding: .4rem 0; border-bottom: 1px solid var(--border); display: flex; gap: .5rem; align-items: center; }
.checklist li .r { margin-left: auto; font-size: .85rem; color: var(--muted); }
.ok-ico { color: var(--success); } .bad-ico { color: var(--danger); } .warn-ico { color: var(--warning); }

/* ---------- Portal (Fahrer / Firma) ---------- */
.portal-top { background: var(--ink); color: #fff; }
.portal-top .inner { max-width: 1100px; margin: 0 auto; display: flex; align-items: center; gap: 1rem; padding: .7rem 1rem; }
.portal-top a { color: #dbe3ee; }
.portal-top .brand { font-weight: 700; color: #fff; display: flex; align-items: center; gap: .6rem; }
.portal-top .brand img { max-height: 32px; background: #fff; border-radius: 4px; padding: 2px; }
.portal-nav { background: var(--surface); border-bottom: 1px solid var(--border); }
.portal-nav .inner { max-width: 1100px; margin: 0 auto; display: flex; gap: .2rem; padding: 0 1rem; overflow-x: auto; }
.portal-nav a { padding: .7rem .9rem; color: var(--muted); font-weight: 550; white-space: nowrap; border-bottom: 3px solid transparent; }
.portal-nav a.active { color: var(--text); border-bottom-color: var(--accent); }
.portal-nav a:hover { text-decoration: none; color: var(--text); }
.portal-main { max-width: 1100px; margin: 0 auto; padding: 1.4rem 1rem 3rem; }
.qr-card { text-align: center; padding: 1.4rem; }
.qr-card canvas, .qr-card img, .qr-card svg { max-width: 260px; width: 100%; height: auto; image-rendering: pixelated; }
.pwa-hint { display: none; }

/* ---------- Sonstiges ---------- */
.toolbar { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; margin-bottom: .8rem; }
.toolbar .grow { flex: 1; }
.letter-filter { display: flex; gap: 2px; flex-wrap: wrap; margin-bottom: .8rem; }
.letter-filter a { min-width: 26px; text-align: center; padding: .15rem .3rem; border-radius: 4px; font-size: .8rem; font-weight: 600; color: var(--muted); }
.letter-filter a.active, .letter-filter a:hover { background: var(--primary); color: #fff; text-decoration: none; }
.pager { display: flex; gap: .25rem; align-items: center; justify-content: flex-end; padding: .7rem 1rem; flex-wrap: wrap; }
.pager a, .pager span { min-width: 30px; text-align: center; padding: .25rem .5rem; border-radius: 5px; font-size: .85rem; }
.pager a { border: 1px solid var(--border); color: var(--text); }
.pager a:hover { background: var(--bg); text-decoration: none; }
.pager .current { background: var(--primary); color: #fff; font-weight: 700; }
.pager .pager-info, .pager-info { margin-right: auto; color: var(--muted); font-size: .85rem; padding: .7rem 1rem; }
.pager .pager-info { padding: 0; }
.kpi-row { display: flex; gap: 2rem; flex-wrap: wrap; }
.stand-box { display: grid; gap: .6rem; }
.stand-box .line { display: flex; justify-content: space-between; font-size: .88rem; }
.callout { background: var(--accent-soft); border: 1px solid #f1dc95; border-radius: 6px; padding: .6rem .8rem; font-size: .88rem; }
.code-block { background: var(--ink); color: #e3e9f1; padding: .8rem 1rem; border-radius: 6px; font-family: var(--mono); font-size: .82rem; overflow-x: auto; white-space: pre; }
.kbd { font-family: var(--mono); background: var(--surface-2); border: 1px solid var(--border); border-radius: 4px; padding: 0 .3rem; font-size: .85em; }
.dyn-rows .dyn-row { display: grid; gap: .5rem; align-items: end; padding: .5rem 0; border-bottom: 1px dashed var(--border); }
.dyn-rows .dyn-row .field { margin: 0; }
.pos-table input, .pos-table select, .pos-table textarea { padding: .35rem .45rem; font-size: .88rem; }
.pos-table td { vertical-align: top; }
.toast-area { position: fixed; right: 1rem; bottom: 1rem; z-index: 200; display: flex; flex-direction: column; gap: .5rem; }
.toast { background: var(--ink); color: #fff; padding: .65rem 1rem; border-radius: 6px; box-shadow: var(--shadow-lg); font-size: .9rem; max-width: 360px; }
.toast.err { background: var(--danger); }
.ac-list { position: absolute; left: 0; right: 0; top: 100%; background: var(--surface); border: 1px solid var(--border); border-radius: 6px; box-shadow: var(--shadow-lg); z-index: 60; max-height: 300px; overflow-y: auto; }
.ac-list a { display: block; padding: .45rem .7rem; color: var(--text); border-bottom: 1px solid var(--border); }
.ac-list a:hover, .ac-list a.sel { background: var(--primary-soft); text-decoration: none; }
.ac-list a small { color: var(--muted); display: block; }
.ac-wrap { position: relative; }
.bar-chart { display: flex; align-items: flex-end; gap: 6px; height: 180px; padding-top: 10px; }
.bar-chart .bar { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; min-width: 0; }
.bar-chart .bar span.v { font-size: .72rem; color: var(--muted); margin-bottom: 2px; }
.bar-chart .bar i { width: 100%; max-width: 46px; background: var(--primary); border-radius: 3px 3px 0 0; min-height: 2px; }
.bar-chart .bar small { font-size: .7rem; color: var(--muted); margin-top: 4px; white-space: nowrap; }
@media print {
  .sidebar, .topbar, .page-head .actions, .no-print, .tabs { display: none !important; }
  .main { margin: 0; } .content { padding: 0; } .card { box-shadow: none; }
  body { background: #fff; }
}

/* Detail-Liste */
.kv { display: grid; grid-template-columns: max-content 1fr; gap: .35rem .9rem; margin: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; word-break: break-word; }

/* Nachrichten (Chat-Verlauf) */
.msgs { display: flex; flex-direction: column; gap: .6rem; padding: 1rem; max-height: 60vh; overflow-y: auto; background: var(--surface-2); }
.msg { max-width: 78%; padding: .6rem .8rem; border-radius: 10px; background: var(--surface); border: 1px solid var(--border); }
.msg.mine { align-self: flex-end; background: var(--primary-soft, #e7eefb); border-color: #c9d8f3; }
.msg .meta { font-size: .74rem; color: var(--muted); margin-bottom: .2rem; }
.msg .text { white-space: pre-wrap; word-break: break-word; }
.msg .subj { font-weight: 600; font-size: .88rem; }
/* Portal-Kacheln */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: .8rem; }
.tile { display: flex; flex-direction: column; gap: .3rem; align-items: flex-start; padding: 1rem; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); color: inherit; box-shadow: var(--shadow); }
.tile:hover { text-decoration: none; border-color: var(--primary); }
.tile .icon { width: 22px; height: 22px; color: var(--primary); }
.tile strong { font-size: .95rem; }
.tile span { font-size: .8rem; color: var(--muted); }
.termin-card { display: grid; grid-template-columns: 74px 1fr auto; gap: .9rem; align-items: center; padding: .9rem 1rem; border-bottom: 1px solid var(--border); }
.termin-card:last-child { border-bottom: 0; }
.termin-card .datebox { text-align: center; border: 1px solid var(--border); border-radius: 8px; padding: .35rem .2rem; background: var(--surface-2); line-height: 1.15; }
.termin-card .datebox .d { font-size: 1.35rem; font-weight: 700; }
.termin-card .datebox .m { font-size: .72rem; text-transform: uppercase; color: var(--muted); font-weight: 600; }
@media (max-width: 640px) { .termin-card { grid-template-columns: 58px 1fr; } .termin-card > :last-child { grid-column: 1 / -1; } .msg { max-width: 92%; } }
.qr-big { background: #fff; padding: 1rem; border-radius: 12px; display: inline-block; box-shadow: var(--shadow); }
.qr-big svg { width: min(72vw, 300px); height: auto; display: block; }
/* Widget */
body.widget { background: transparent; }
.widget-wrap { padding: .5rem; max-width: 980px; margin: 0 auto; }
/* Säulendiagramme */
.bars { display: flex; align-items: flex-end; gap: 4px; }
.bar { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; min-width: 0; }
.bar-col { width: 100%; max-width: 46px; background: var(--primary); border-radius: 3px 3px 0 0; opacity: .85; }
.bar:hover .bar-col { opacity: 1; }
.bar-val { font-size: .66rem; color: var(--muted); white-space: nowrap; margin-bottom: 2px; }
.bar-lbl { font-size: .68rem; color: var(--muted); margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
/* Handbuch */
.handbuch { max-width: 820px; line-height: 1.6; }
.handbuch h1 { margin-top: 0; } .handbuch h2 { margin-top: 2rem; padding-top: .6rem; border-top: 1px solid var(--border); } .handbuch h3 { margin-top: 1.4rem; }
.handbuch code { background: var(--surface-2); border: 1px solid var(--border); border-radius: 4px; padding: 0 .3rem; font-size: .86em; }
.handbuch pre.code { background: #1b2433; color: #e8edf5; padding: .8rem 1rem; border-radius: 6px; overflow-x: auto; font-size: .85rem; }
.handbuch .callout { margin: .8rem 0; }
.handbuch li { margin-bottom: .25rem; }
@media print { .sidebar, .topbar, .hilfe aside { display: none !important; } .hilfe { display: block; } .main { margin: 0 !important; } }

/* =====================================================================
   Design 1.2 – modernes Flat-Design (hell/dunkel)
   Überschreibt die Grundwerte oben. Dunkelmodus: automatisch nach
   Systemeinstellung oder fest über <html data-theme="light|dark">.
   ===================================================================== */
:root {
  color-scheme: light;
  --primary: #0a66d8; --primary-dark: #0856b8; --primary-soft: rgba(10, 102, 216, .1);
  --link: var(--primary);
  --accent: #ff9f0a; --accent-soft: rgba(255, 159, 10, .14);
  --ink: #1d1d1f; --ink-2: #2c2c2e; --ink-3: #3a3a3c;
  --bg: #f5f5f7; --surface: #ffffff; --surface-2: #f9f9fb; --surface-3: #f0f0f3;
  --sidebar-bg: rgba(242, 242, 245, .92); --sidebar-text: #3a3a3c; --sidebar-muted: #8e8e93; --sidebar-hover: rgba(0, 0, 0, .05);
  --topbar-bg: rgba(255, 255, 255, .78);
  --border: rgba(0, 0, 0, .08); --border-strong: rgba(0, 0, 0, .16);
  --text: #1d1d1f; --text-2: #3a3a3c; --muted: #6e6e73;
  --success: #1f8a3b; --success-soft: rgba(52, 199, 89, .14);
  --warning: #b25e00; --warning-soft: rgba(255, 159, 10, .15);
  --danger: #d70015; --danger-soft: rgba(255, 59, 48, .11);
  --info: #0a66d8; --info-soft: rgba(10, 132, 255, .1);
  --radius: 14px; --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(0, 0, 0, .04), 0 1px 1px rgba(0, 0, 0, .02);
  --shadow-lg: 0 12px 40px rgba(0, 0, 0, .14), 0 2px 8px rgba(0, 0, 0, .06);
  --input-bg: #ffffff; --hover-row: rgba(0, 0, 0, .025);
  --cal-m95: rgba(10, 132, 255, .12); --cal-m95-t: #0a4fa8; --cal-sch: rgba(52, 199, 89, .14); --cal-sch-t: #17652b; --cal-bgq: rgba(255, 159, 10, .16); --cal-bgq-t: #8a4b00;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI Variable Text", "Segoe UI", system-ui, Roboto, "Helvetica Neue", Arial, sans-serif;
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --link: color-mix(in srgb, var(--primary) 60%, #ffffff);
  --primary-soft: color-mix(in srgb, var(--primary) 24%, transparent);
  --accent-soft: rgba(255, 159, 10, .18);
  --bg: #0f0f11; --surface: #1c1c1e; --surface-2: #232326; --surface-3: #2a2a2d;
  --sidebar-bg: rgba(22, 22, 24, .94); --sidebar-text: #e5e5ea; --sidebar-muted: #8e8e93; --sidebar-hover: rgba(255, 255, 255, .06);
  --topbar-bg: rgba(28, 28, 30, .78);
  --border: rgba(255, 255, 255, .09); --border-strong: rgba(255, 255, 255, .18);
  --text: #f5f5f7; --text-2: #d1d1d6; --muted: #98989f;
  --success: #32d74b; --success-soft: rgba(50, 215, 75, .16);
  --warning: #ffb340; --warning-soft: rgba(255, 159, 10, .18);
  --danger: #ff6961; --danger-soft: rgba(255, 69, 58, .18);
  --info: #64b5ff; --info-soft: rgba(10, 132, 255, .2);
  --shadow: 0 0 0 1px rgba(255, 255, 255, .04);
  --shadow-lg: 0 16px 48px rgba(0, 0, 0, .55), 0 0 0 1px rgba(255, 255, 255, .06);
  --input-bg: #2a2a2d; --hover-row: rgba(255, 255, 255, .035);
  --cal-m95: rgba(10, 132, 255, .22); --cal-m95-t: #9ccbff; --cal-sch: rgba(50, 215, 75, .18); --cal-sch-t: #8de59b; --cal-bgq: rgba(255, 159, 10, .2); --cal-bgq-t: #ffcc80;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]):not([data-theme="dark"]) {
    color-scheme: dark;
    --link: color-mix(in srgb, var(--primary) 60%, #ffffff);
    --primary-soft: color-mix(in srgb, var(--primary) 24%, transparent);
    --accent-soft: rgba(255, 159, 10, .18);
    --bg: #0f0f11; --surface: #1c1c1e; --surface-2: #232326; --surface-3: #2a2a2d;
    --sidebar-bg: rgba(22, 22, 24, .94); --sidebar-text: #e5e5ea; --sidebar-muted: #8e8e93; --sidebar-hover: rgba(255, 255, 255, .06);
    --topbar-bg: rgba(28, 28, 30, .78);
    --border: rgba(255, 255, 255, .09); --border-strong: rgba(255, 255, 255, .18);
    --text: #f5f5f7; --text-2: #d1d1d6; --muted: #98989f;
    --success: #32d74b; --success-soft: rgba(50, 215, 75, .16);
    --warning: #ffb340; --warning-soft: rgba(255, 159, 10, .18);
    --danger: #ff6961; --danger-soft: rgba(255, 69, 58, .18);
    --info: #64b5ff; --info-soft: rgba(10, 132, 255, .2);
    --shadow: 0 0 0 1px rgba(255, 255, 255, .04);
    --shadow-lg: 0 16px 48px rgba(0, 0, 0, .55), 0 0 0 1px rgba(255, 255, 255, .06);
    --input-bg: #2a2a2d; --hover-row: rgba(255, 255, 255, .035);
    --cal-m95: rgba(10, 132, 255, .22); --cal-m95-t: #9ccbff; --cal-sch: rgba(50, 215, 75, .18); --cal-sch-t: #8de59b; --cal-bgq: rgba(255, 159, 10, .2); --cal-bgq-t: #ffcc80;
  }
}

/* Grundlagen */
body { font: 14.5px/1.5 var(--font); letter-spacing: -.003em; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; background: var(--bg); color: var(--text); }
a { color: var(--link); }
h1, h2, h3, h4 { font-weight: 650; letter-spacing: -.02em; }
h1 { font-size: 1.75rem; font-weight: 700; letter-spacing: -.025em; }
::selection { background: color-mix(in srgb, var(--primary) 25%, transparent); }
* { scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }

/* Seitenleiste – hell wie macOS, dunkel im Dark Mode */
.sidebar { background: var(--sidebar-bg); color: var(--sidebar-text); border-right: 1px solid var(--border); -webkit-backdrop-filter: saturate(180%) blur(20px); backdrop-filter: saturate(180%) blur(20px); }
.sidebar .brand { color: var(--text); border-bottom: 0; padding: 1.1rem 1.1rem .6rem; }
.sidebar .brand img { background: transparent; padding: 0; }
.sidebar .brand .mark { border-radius: 9px; background: linear-gradient(145deg, #ffb340, #ff9500); color: #1d1d1f; box-shadow: 0 1px 2px rgba(0, 0, 0, .15); }
.sidebar nav { padding: .2rem .6rem 1rem; }
.sidebar .nav-group { color: var(--sidebar-muted); padding: 1rem .6rem .3rem; font-size: .68rem; letter-spacing: .06em; }
.sidebar a.nav { color: var(--sidebar-text); border-left: 0; border-radius: 8px; padding: .42rem .6rem; margin: 1px 0; font-size: .92rem; font-weight: 500; }
.sidebar a.nav .icon { color: var(--primary); opacity: .9; }
.sidebar a.nav:hover { background: var(--sidebar-hover); color: var(--text); }
.sidebar a.nav.active { background: var(--primary); color: #fff; }
.sidebar a.nav.active .icon { color: #fff; opacity: 1; }
.sidebar a.nav .count { background: var(--danger); color: #fff; font-weight: 600; border-radius: 10px; }
.sidebar a.nav.active .count { background: rgba(255, 255, 255, .25); }
.sidebar .side-foot { color: var(--sidebar-muted); border-top: 1px solid var(--border); }

/* Kopfleiste mit Milchglas */
.topbar { background: var(--topbar-bg); border-bottom: 1px solid var(--border); -webkit-backdrop-filter: saturate(180%) blur(20px); backdrop-filter: saturate(180%) blur(20px); height: 56px; }
.topbar .search input { background: var(--surface-3); border: 1px solid transparent; border-radius: 10px; padding: .45rem .8rem .45rem 2.1rem; }
.topbar .search input:focus { background: var(--input-bg); }
.topbar .search .icon { top: .58rem; }
.topbar .mandant select { border-radius: 9px; background: var(--surface-3); border-color: transparent; }
.icon-btn { border-radius: 9px; color: var(--text-2); }
.icon-btn:hover { background: var(--surface-3); }
.content { padding: 1.8rem 2rem 3.5rem; }
@media (max-width: 1024px) { .content { padding: 1rem; } }

/* Karten, Kennzahlen */
.card, .stat, .tile { border: 1px solid var(--border); box-shadow: var(--shadow); }
.card-head { padding: .95rem 1.2rem; border-bottom-color: var(--border); }
.card-head h2, .card-head h3 { font-size: 1rem; font-weight: 650; }
.card-body { padding: 1.2rem; }
.card-foot { background: transparent; border-top-color: var(--border); padding: .85rem 1.2rem; }
.stat { padding: 1.1rem 1.2rem; }
.stat .label { font-size: .8rem; font-weight: 500; }
.stat .value { font-size: 1.9rem; font-weight: 700; letter-spacing: -.03em; }
a.stat, a.tile { transition: transform .15s ease, box-shadow .15s ease; }
a.stat:hover, a.tile:hover { transform: translateY(-1px); box-shadow: 0 6px 20px rgba(0, 0, 0, .08); border-color: var(--border); }

/* Reiter als Segmented Control */
.tabs { gap: 2px; padding: 3px; margin: 0 0 1rem; background: var(--surface-3); border-radius: 11px; width: fit-content; max-width: 100%; }
.tabs a { border: 0; border-radius: 8px; padding: .38rem .95rem; font-size: .88rem; font-weight: 500; color: var(--text-2); }
.tabs a:hover { background: var(--hover-row); color: var(--text); }
.tabs a.active { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgba(0, 0, 0, .12), 0 0 0 .5px rgba(0, 0, 0, .04); }
.tabbed > .card { border-top-left-radius: var(--radius); }

/* Tabellen */
.table th { background: transparent; text-transform: none; letter-spacing: 0; font-size: .78rem; font-weight: 600; color: var(--muted); border-bottom: 1px solid var(--border); }
.table th, .table td { padding: .65rem .9rem; border-bottom-color: var(--border); }
.table tbody tr:hover { background: var(--hover-row); }
.table tfoot td { background: transparent; }

/* Buttons */
.btn { border-radius: 9px; border: 1px solid transparent; background: var(--surface-3); color: var(--text); font-weight: 500; padding: .5rem .95rem; transition: background .15s, filter .15s, transform .05s; }
.btn:hover { background: color-mix(in srgb, var(--surface-3) 85%, var(--text)); border-color: transparent; }
.btn:active { transform: scale(.98); }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary); filter: brightness(1.08); color: #fff; }
.btn-accent { background: var(--accent); color: #1d1d1f; }
.btn-danger { color: var(--danger); background: var(--danger-soft); border-color: transparent; }
.btn-danger:hover { background: var(--danger); color: #fff; border-color: transparent; }
.btn-ghost { background: transparent; }
.btn-ghost:hover { background: var(--surface-3); }
.btn-sm { border-radius: 8px; padding: .3rem .7rem; }
.btn-xs { border-radius: 7px; padding: .16rem .5rem; }
.btn-group { background: var(--surface-3); padding: 2px; border-radius: 10px; gap: 2px; }
.btn-group .btn, .btn-group .btn:first-child, .btn-group .btn:last-child { border-radius: 8px; margin: 0; background: transparent; }
.btn-group .btn.active { background: var(--surface); color: var(--text); border-color: transparent; box-shadow: 0 1px 3px rgba(0, 0, 0, .12); }

/* Formulare */
input[type=text], input[type=email], input[type=password], input[type=date], input[type=time], input[type=number], input[type=search], input[type=url], input[type=tel], input[type=datetime-local], select, textarea {
  background: var(--input-bg); border: 1px solid var(--border-strong); border-radius: 9px; color: var(--text);
}
input:focus, select:focus, textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 4px color-mix(in srgb, var(--primary) 22%, transparent); }
input[readonly] { background: var(--surface-2); }
.field label { color: var(--text-2); font-weight: 500; }
.form-section { border-bottom: 0; font-size: .82rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 600; margin-top: 1.2rem; }
.input-group .suffix { background: var(--surface-3); border-color: var(--border-strong); border-radius: 0 9px 9px 0; }
.input-group input { border-radius: 9px 0 0 9px; }
input[type=color] { border-radius: 9px; background: var(--input-bg); border: 1px solid var(--border-strong); }

/* Badges, Chips, Meldungen */
.badge { background: var(--surface-3); color: var(--text-2); font-weight: 600; border-radius: 6px; padding: .1rem .5rem; }
.badge-dark { background: var(--ink-3); color: #fff; }
.chip { background: var(--surface-3); border-color: transparent; border-radius: 6px; }
.chip.ok { background: var(--success-soft); border-color: transparent; }
.chip.open { background: transparent; border: 1px dashed var(--border-strong); }
.chip.old { background: var(--surface-2); color: var(--muted); }
.alert { border: 0; border-radius: 12px; color: var(--text); }
.alert .icon { opacity: .9; }
.alert-success { background: var(--success-soft); } .alert-success .icon { color: var(--success); }
.alert-error, .alert-danger { background: var(--danger-soft); } .alert-error .icon, .alert-danger .icon { color: var(--danger); }
.alert-warning { background: var(--warning-soft); } .alert-warning .icon { color: var(--warning); }
.alert-info { background: var(--info-soft); } .alert-info .icon { color: var(--info); }
.callout { background: var(--accent-soft); border: 0; border-radius: 10px; }
.empty .icon { color: var(--border-strong); }

/* Menüs, Dialoge, Toasts */
.dropdown-menu { border-radius: 12px; padding: .35rem; border: 1px solid var(--border); background: color-mix(in srgb, var(--surface) 92%, transparent); -webkit-backdrop-filter: blur(20px); backdrop-filter: blur(20px); }
.dropdown-menu a, .dropdown-menu button { border-radius: 7px; padding: .45rem .7rem; }
.dropdown-menu a:hover, .dropdown-menu button:hover { background: var(--primary); color: #fff; }
.dropdown-menu a:hover .icon, .dropdown-menu button:hover .icon { color: #fff; }
.modal { background: rgba(0, 0, 0, .35); -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px); }
.modal-box { border-radius: 16px; border: 1px solid var(--border); }
.modal-head, .modal-foot { border-color: var(--border); }
.modal-foot { background: transparent; }
.toast { background: var(--ink-2); border-radius: 12px; }
.ac-list { border-radius: 10px; }
.ac-list a:hover, .ac-list a.sel { background: var(--primary); color: #fff; }
.ac-list a:hover small, .ac-list a.sel small { color: rgba(255, 255, 255, .8); }

/* Fortschritt, Zeitleiste, Kalender, Sonstiges */
.progress { background: var(--surface-3); border-radius: 99px; }
.progress > span { border-radius: 99px; }
.job-box { background: var(--surface-2); }
.timeline li::before { background: var(--primary); border-color: var(--surface); box-shadow: 0 0 0 2px var(--primary); width: 8px; height: 8px; left: -5px; }
.calendar { border-color: var(--border); }
.calendar .dow { background: transparent; }
.calendar .day:hover { background: var(--hover-row); }
.calendar .day.other { background: var(--surface-2); color: var(--muted); }
.cal-ev { border-left: 0; border-radius: 6px; }
.cal-ev.m95 { background: var(--cal-m95); color: var(--cal-m95-t); }
.cal-ev.schulung { background: var(--cal-sch); color: var(--cal-sch-t); }
.cal-ev.bgq { background: var(--cal-bgq); color: var(--cal-bgq-t); }
.legend .m95::before { background: #0a84ff; } .legend .schulung::before { background: #34c759; } .legend .bgq::before { background: #ff9f0a; }
.ev-card { border-radius: 10px; border-left-width: 4px; }
.seats i { background: var(--surface-3); }
.matrix .cell-toggle { background: var(--input-bg); border-color: var(--border-strong); border-radius: 8px; }
.sig-pad { background: #fff; }
.pager a { border-color: transparent; background: var(--surface-3); border-radius: 8px; }
.pager .current { border-radius: 8px; }
.letter-filter a { border-radius: 6px; }
.code-block, .handbuch pre.code { background: #1c1c1e; border-radius: 10px; }
.handbuch code, .kbd { background: var(--surface-3); border-color: transparent; }
.steps span { background: var(--surface-3); border-radius: 8px; }
.termin-card .datebox { background: var(--surface-2); border-color: var(--border); border-radius: 10px; }
.termin-card .datebox .m { color: var(--danger); }
.msgs { background: var(--surface-2); }
.msg { border-radius: 16px; border-color: var(--border); background: var(--surface); }
.msg.mine { background: var(--primary); color: #fff; border-color: transparent; }
.msg.mine .meta { color: rgba(255, 255, 255, .78); }
.bar-col, .bar-chart .bar i { border-radius: 5px 5px 2px 2px; }
.avatar { background: var(--primary-soft); color: var(--link); }

/* Anmeldung, einfache Seiten */
.auth { background: radial-gradient(1200px 600px at 20% -10%, color-mix(in srgb, var(--primary) 18%, var(--bg)), var(--bg) 60%); }
.auth-box { border-radius: 20px; border: 1px solid var(--border); box-shadow: var(--shadow-lg); padding: 2.2rem; }
.auth-brand .mark { border-radius: 10px; background: linear-gradient(145deg, #ffb340, #ff9500); color: #1d1d1f; }

/* Portale */
.portal-top { background: var(--topbar-bg); color: var(--text); border-bottom: 1px solid var(--border); -webkit-backdrop-filter: saturate(180%) blur(20px); backdrop-filter: saturate(180%) blur(20px); position: sticky; top: 0; z-index: 20; }
.portal-top a, .portal-top .brand { color: var(--text); }
.portal-top .brand img { background: transparent; padding: 0; }
.portal-top .who { color: var(--muted); }
.portal-top .icon-btn { color: var(--text-2) !important; }
.portal-nav { background: transparent; border-bottom: 0; padding-top: .7rem; }
.portal-nav .inner { gap: 2px; }
.portal-nav a { border-bottom: 0; border-radius: 9px; padding: .45rem .85rem; color: var(--text-2); font-weight: 500; }
.portal-nav a:hover { background: var(--surface-3); }
.portal-nav a.active { background: var(--primary); color: #fff; }

/* Hell/Dunkel-Umschalter */
.theme-toggle .icon { width: 19px; height: 19px; }
.theme-toggle [data-ico] { display: none; }
:root:not([data-theme]) .theme-toggle [data-ico=auto], :root[data-theme=auto] .theme-toggle [data-ico=auto],
:root[data-theme=light] .theme-toggle [data-ico=light], :root[data-theme=dark] .theme-toggle [data-ico=dark] { display: inline-flex; }

/* Widget immer hell (wird in fremde Websites eingebettet) */
body.widget { color-scheme: light; }
@media print { :root { color-scheme: light; } body { background: #fff; color: #000; } }
@media (max-width: 560px) { .portal-top .who { display: none; } .portal-top .inner { gap: .3rem; } .portal-top .brand span { font-size: .95rem; line-height: 1.2; } }

/* ===================================================================== Online-Anmeldung (Portal + Widget, 1.7) */
.btn-lg { padding: .75rem 1.4rem; font-size: 1rem; border-radius: 12px; }
body.ap { background: var(--bg); min-height: 100vh; display: flex; flex-direction: column; }
.ap-container { width: 100%; max-width: 1080px; margin: 0 auto; padding: 0 16px; }
.ap-header { background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 20; backdrop-filter: saturate(180%) blur(12px); }
.ap-header-inner { display: flex; align-items: center; justify-content: space-between; gap: 1rem; min-height: 64px; }
.ap-brand { display: flex; align-items: center; gap: .7rem; color: var(--text, var(--ink)); text-decoration: none; font-weight: 700; font-size: 1.05rem; }
.ap-brand img { max-height: 40px; max-width: 160px; }
.ap-brand .mark { background: var(--primary); color: #fff; border-radius: 10px; padding: .35rem .5rem; font-size: .85rem; }
.ap-brand small { display: block; font-weight: 400; font-size: .78rem; color: var(--muted); }
.ap-kontakt { text-align: right; color: var(--muted); line-height: 1.35; }
.ap-main { flex: 1; padding-top: 1.5rem; padding-bottom: 3rem; }
.ap-footer { border-top: 1px solid var(--border); padding: 1.2rem 0; font-size: .8rem; color: var(--muted); }
.ap-footer .ap-container { display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.ap-links a { margin-left: 1rem; color: var(--muted); }
.ap-hero { padding: 1.5rem 0 1rem; }
.ap-hero h1 { font-size: clamp(1.6rem, 4vw, 2.3rem); letter-spacing: -.02em; margin: 0 0 .5rem; line-height: 1.15; }
.ap-hero p { font-size: 1.08rem; color: var(--muted); max-width: 720px; margin: 0; }
.ap-filter { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: .8rem; margin: 1rem 0 .6rem; box-shadow: var(--shadow); }
.ap-arten { display: flex; gap: .35rem; flex-wrap: wrap; margin-bottom: .6rem; }
.ap-arten a { padding: .4rem .9rem; border-radius: 999px; background: var(--surface-2); color: var(--text, var(--ink)); text-decoration: none; font-size: .88rem; font-weight: 500; }
.ap-arten a.active { background: var(--primary); color: #fff; }
.ap-filter-felder { display: flex; gap: .5rem; flex-wrap: wrap; }
.ap-filter-felder select { width: auto; flex: 0 1 200px; }
.ap-suche { flex: 1 1 260px; position: relative; display: flex; align-items: center; margin: 0; }
.ap-suche svg { position: absolute; left: .7rem; width: 16px; height: 16px; color: var(--muted); pointer-events: none; }
.ap-suche input { padding-left: 2.1rem; }
.ap-treffer { margin: .4rem .2rem .8rem; }
.ap-liste { display: flex; flex-direction: column; gap: .75rem; }
.ap-card { display: grid; grid-template-columns: 76px 1fr auto; gap: 1.1rem; align-items: center; background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 1rem 1.1rem; box-shadow: var(--shadow); transition: transform .15s, box-shadow .15s; }
.ap-card:hover { transform: translateY(-1px); box-shadow: var(--shadow-lg); }
.ap-date { display: flex; flex-direction: column; align-items: center; justify-content: center; background: var(--surface-2); border-radius: 14px; padding: .55rem 0; text-decoration: none; color: var(--text, var(--ink)); }
.ap-date .d { font-size: 1.7rem; font-weight: 700; line-height: 1.1; }
.ap-date .m { font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.ap-card h2 { font-size: 1.12rem; margin: .25rem 0 .35rem; letter-spacing: -.01em; }
.ap-card h2 a { color: var(--text, var(--ink)); text-decoration: none; }
.ap-meta { display: flex; flex-wrap: wrap; gap: .25rem 1rem; font-size: .88rem; color: var(--muted); }
.ap-meta span { display: inline-flex; align-items: center; gap: .3rem; }
.ap-meta svg { width: 15px; height: 15px; }
.ap-module { margin-top: .45rem; }
.ap-card-side { text-align: right; display: flex; flex-direction: column; align-items: flex-end; gap: .35rem; min-width: 170px; }
.ap-preis { font-size: 1.3rem; font-weight: 700; line-height: 1.1; }
.ap-preis small { display: block; font-size: .72rem; font-weight: 400; color: var(--muted); }
.ap-plaetze { font-size: .85rem; color: var(--success); font-weight: 500; }
.ap-plaetze.knapp { color: var(--warning); }
.ap-plaetze.voll { color: var(--danger); }
.ap-leer { text-align: center; padding: 3rem 1rem; color: var(--muted); background: var(--surface); border-radius: 16px; border: 1px dashed var(--border); }
.ap-leer svg { width: 36px; height: 36px; }
.ap-zurueck { margin: 0 0 .8rem; }
.ap-detail { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); gap: 1.5rem; align-items: start; }
.ap-detail-info h1 { font-size: clamp(1.4rem, 3vw, 1.9rem); letter-spacing: -.02em; margin: .4rem 0 1rem; line-height: 1.2; }
.ap-detail-info { position: sticky; top: 84px; }
.ap-fakten { display: grid; grid-template-columns: auto 1fr; gap: .5rem 1rem; margin: 0 0 1.2rem; }
.ap-fakten dt { color: var(--muted); display: flex; gap: .35rem; align-items: flex-start; font-size: .9rem; }
.ap-fakten dt svg { width: 16px; height: 16px; margin-top: 2px; }
.ap-fakten dd { margin: 0; }
.ap-ablauf { padding-left: 1.2rem; margin: .3rem 0 1rem; }
.ap-ablauf li { margin-bottom: .45rem; }
.ap-detail-form { border-radius: 18px; }
.ap-detail-form h2 { margin-top: 0; font-size: 1.3rem; }
.ap-block { margin-bottom: 1.3rem; }
.ap-block h3 { font-size: 1rem; margin: 0 0 .6rem; }
.ap-block.is-invalid .ap-tage { outline: 2px solid var(--danger); outline-offset: 4px; border-radius: 12px; }
.ap-tage { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: .5rem; }
.ap-tag, .ap-wahl label { display: flex; gap: .55rem; align-items: flex-start; border: 1.5px solid var(--border); border-radius: 12px; padding: .65rem .75rem; cursor: pointer; font-weight: 400; margin: 0; background: var(--surface); }
.ap-tag:has(input:checked), .ap-wahl label:has(input:checked) { border-color: var(--primary); background: var(--primary-soft); }
.ap-tag input, .ap-wahl input { margin-top: .2rem; }
.ap-wahl { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; }
.ap-wahl span { display: flex; flex-direction: column; gap: .1rem; font-weight: 600; }
.ap-wahl span svg { width: 18px; height: 18px; display: inline; vertical-align: -3px; margin-right: .2rem; }
.ap-wahl small { font-weight: 400; color: var(--muted); font-size: .8rem; }
.ap-person { border: 1px solid var(--border); border-radius: 14px; padding: .8rem .9rem .2rem; margin-bottom: .7rem; background: var(--surface-2); }
.ap-form [hidden] { display: none !important; }
.ap-person-kopf { display: flex; justify-content: space-between; align-items: center; margin-bottom: .5rem; }
.ap-klassen label { margin-right: .8rem; font-weight: 400; }
.ap-fertig { max-width: 640px; margin: 1rem auto; text-align: center; border-radius: 18px; }
.ap-fertig-icon { width: 64px; height: 64px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 2rem; margin: .5rem auto 1rem; color: #fff; background: var(--success); }
.ap-fertig-icon.warn { background: var(--warning); }
.ap-zusammenfassung { text-align: left; background: var(--surface-2); border-radius: 12px; padding: .9rem 1rem; margin: 1rem 0; }
.ap-schritte { text-align: left; margin: 0 auto 1rem; max-width: 460px; }
@media (max-width: 860px) {
  .ap-detail { grid-template-columns: 1fr; }
  .ap-detail-info { position: static; }
}
@media (max-width: 640px) {
  .ap-card { grid-template-columns: 60px 1fr; gap: .8rem; }
  .ap-card-side { grid-column: 1 / -1; flex-direction: row; align-items: center; justify-content: space-between; text-align: left; min-width: 0; flex-wrap: wrap; }
  .ap-wahl { grid-template-columns: 1fr; }
  .ap-kontakt { display: none; }
  .ap-filter-felder select { flex: 1 1 45%; }
}
/* Widget nutzt dieselben Bausteine, kompakter */
body.widget .ap-detail { grid-template-columns: 1fr; }
body.widget .ap-detail-info { position: static; }
