/* Fahrzeugbuchung – ohne externe Schriften/CDNs (DSGVO-freundlich) */
:root {
  --red: #c8102e; --red-d: #9e0c24; --red-soft: #fbe9ec;
  --ink: #1b2430; --ink-2: #4a5565; --muted: #6b7584;
  --line: #e2e5ea; --line-2: #eef0f3; --bg: #f5f6f8; --card: #fff;
  --navy: #17202c;
  --ok: #17803d; --ok-bg: #e6f4ea; --ok-line: #9fd3ae;
  --wait: #9a5b00; --wait-bg: #fff4dd; --wait-line: #f0c46a;
  --no: #8a1c1c; --no-bg: #fdecec;
  --dienst: #1d4f91; --dienst-bg: #e7effa; --dienst-line: #9db9e2;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(20,30,45,.06), 0 2px 8px rgba(20,30,45,.05);
  font-size: 16px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; color: var(--ink); background: var(--bg); line-height: 1.45; }
a { color: var(--red-d); }
h1 { font-size: 1.55rem; margin: .2rem 0 1rem; letter-spacing: -.01em; }
h2 { font-size: 1.1rem; margin: 0 0 .8rem; }
h3 { font-size: 1rem; margin: 1.2rem 0 .5rem; }
.wrap { max-width: 1400px; margin: 0 auto; padding: 0 16px; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.nowrap { white-space: nowrap; }

/* Kopfzeile */
.top { background: var(--navy); color: #fff; position: sticky; top: 0; z-index: 30; border-bottom: 3px solid var(--red); }
.topbar { display: flex; align-items: center; gap: 16px; min-height: 56px; }
.brand { display: flex; align-items: center; gap: 10px; color: #fff; text-decoration: none; font-weight: 700; white-space: nowrap; }
.mainnav { display: flex; gap: 2px; margin-left: auto; flex-wrap: wrap; align-items: center; }
.mainnav a { color: #d5dbe3; text-decoration: none; padding: 8px 11px; border-radius: 7px; font-size: .94rem; }
.mainnav a:hover { background: rgba(255,255,255,.08); color: #fff; }
.mainnav a.active { background: rgba(255,255,255,.14); color: #fff; }
.mainnav a.me { border: 1px solid rgba(255,255,255,.2); margin-left: 6px; }
.badge { display: inline-block; min-width: 20px; padding: 0 6px; border-radius: 10px; background: var(--red); color: #fff; font-size: .75rem; font-weight: 700; text-align: center; }
.navtoggle { display: none; margin-left: auto; background: none; border: 1px solid rgba(255,255,255,.3); color: #fff; font-size: 1.2rem; border-radius: 7px; padding: 4px 10px; }
@media (max-width: 900px) {
  .navtoggle { display: block; }
  .mainnav { display: none; position: absolute; left: 0; right: 0; top: 59px; background: var(--navy); flex-direction: column; align-items: stretch; padding: 8px 16px 14px; }
  .navopen .mainnav { display: flex; }
  .mainnav a.me { margin: 6px 0 0; }
}
main.wrap { padding-top: 20px; padding-bottom: 40px; min-height: 70vh; }
.foot { color: var(--muted); font-size: .8rem; padding-bottom: 24px; }

/* Karten, Formulare */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); margin-bottom: 16px; }
.card.narrow { max-width: 460px; margin: 30px auto; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 16px; align-items: start; }
.grid3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; }
.form { display: grid; gap: 12px; }
.form .row { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
label { display: grid; gap: 4px; font-size: .9rem; font-weight: 600; color: var(--ink-2); }
label.check { display: flex; align-items: center; gap: 8px; font-weight: 500; color: var(--ink); }
input, select, textarea { font: inherit; font-weight: 400; color: var(--ink); padding: 9px 11px; border: 1px solid #cdd2da; border-radius: 8px; background: #fff; width: 100%; }
input[type=checkbox] { width: 18px; height: 18px; accent-color: var(--red); }
textarea { min-height: 74px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(200,16,46,.25); border-color: var(--red); }
.hint { font-size: .82rem; color: var(--muted); font-weight: 400; }
.btn { display: inline-flex; align-items: center; gap: 6px; font: inherit; font-weight: 600; font-size: .92rem; padding: 9px 15px; border-radius: 8px; border: 1px solid #c8ced7; background: #fff; color: var(--ink); cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn:hover { background: #f1f3f6; }
.btn.primary { background: var(--red); border-color: var(--red); color: #fff; }
.btn.primary:hover { background: var(--red-d); }
.btn.ok { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn.danger { color: var(--no); border-color: #e6b3b3; }
.btn.small { padding: 5px 10px; font-size: .84rem; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.flash { padding: 11px 14px; border-radius: 8px; margin-bottom: 14px; border: 1px solid; }
.flash.ok { background: var(--ok-bg); border-color: var(--ok-line); color: #11502a; }
.flash.warn { background: var(--wait-bg); border-color: var(--wait-line); color: #6b4000; }
.flash.err { background: var(--no-bg); border-color: #efb4b4; color: var(--no); }
.dl { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 0 0 14px; }
.dl dt { color: var(--muted); }
.dl dd { margin: 0; }

/* Tabellen */
.tbl-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; font-size: .92rem; }
.tbl th, .tbl td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--line-2); vertical-align: top; }
.tbl th { font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 700; background: #fafbfc; }
.tbl tr.off td { color: #9aa2ad; }
.pill { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: .78rem; font-weight: 700; white-space: nowrap; }
.st-genehmigt { background: var(--ok-bg); color: var(--ok); }
.st-beantragt { background: var(--wait-bg); color: var(--wait); }
.st-abgelehnt { background: var(--no-bg); color: var(--no); }
.st-storniert { background: #eef0f3; color: #6b7584; }
.tag { display: inline-block; padding: 1px 7px; border-radius: 5px; background: #eef0f3; font-size: .78rem; color: var(--ink-2); }

/* Board */
.boardhead { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; margin-bottom: 14px; }
.boardhead h1 { margin: 0; margin-right: auto; }
.weeknav { display: flex; gap: 6px; align-items: center; }
.weeknav .range { font-weight: 700; padding: 0 6px; min-width: 190px; text-align: center; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: .82rem; color: var(--ink-2); margin: 0 0 12px; }
.legend i { display: inline-block; width: 12px; height: 12px; border-radius: 3px; vertical-align: -1px; margin-right: 5px; }
.now-strip { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.now-strip .lbl { font-weight: 700; font-size: .85rem; color: var(--ink-2); }
.chip { display: inline-flex; gap: 6px; align-items: center; background: #fff; border: 1px solid var(--line); border-left: 4px solid var(--ok); border-radius: 7px; padding: 4px 10px; font-size: .85rem; text-decoration: none; color: var(--ink); }
.chip.dienst { border-left-color: var(--dienst); }

.board { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); overflow: auto; box-shadow: var(--shadow); max-height: calc(100vh - 230px); }
.board table { border-collapse: separate; border-spacing: 0; width: 100%; min-width: 1050px; table-layout: fixed; }
.board th, .board td { border-bottom: 1px solid var(--line-2); border-right: 1px solid var(--line-2); padding: 5px; vertical-align: top; }
.board thead th { position: sticky; top: 0; background: #fafbfc; z-index: 3; font-size: .82rem; font-weight: 700; color: var(--ink-2); text-align: left; padding: 8px; }
.board thead th.today { background: var(--red-soft); color: var(--red-d); }
.board th.veh { position: sticky; left: 0; background: #fff; z-index: 2; width: 170px; text-align: left; }
.board thead th.veh { z-index: 4; background: #fafbfc; }
.board td.today { background: #fffafa; }
.board .veh b { display: block; font-size: .95rem; }
.board .veh span { display: block; font-size: .75rem; color: var(--muted); font-weight: 400; line-height: 1.25; }
.board tr.cat th { text-align: left; position: sticky; left: 0; background: #f1f3f6; font-size: .75rem; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-2); padding: 6px 8px; z-index: 2; }
.board tr.cat td { background: #f1f3f6; }
.board tr.dis th.veh b { color: #9aa2ad; }
.cell { min-height: 38px; display: flex; flex-direction: column; gap: 4px; height: 100%; }
.cell .add { display: block; flex: 1; min-height: 22px; border-radius: 6px; color: transparent; text-decoration: none; text-align: center; font-size: 1.1rem; line-height: 22px; }
.cell:hover .add { color: #b8bec7; background: #fafbfc; }
.ev { display: block; text-decoration: none; color: var(--ink); border-radius: 6px; padding: 4px 6px; font-size: .78rem; line-height: 1.25; border: 1px solid; border-left-width: 4px; }
.ev b { display: block; font-size: .78rem; }
.ev .who { color: var(--ink-2); display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ev.genehmigt { background: var(--ok-bg); border-color: var(--ok-line); border-left-color: var(--ok); }
.ev.beantragt { background: repeating-linear-gradient(-45deg, var(--wait-bg), var(--wait-bg) 6px, #fff9ec 6px, #fff9ec 12px); border-color: var(--wait-line); border-left-color: #d08a00; }
.ev.dienst { background: var(--dienst-bg); border-color: var(--dienst-line); border-left-color: var(--dienst); }
.ev:hover { filter: brightness(.97); }

/* Agenda (mobile Ansicht des Boards) */
.agenda { display: none; }
.agenda .day { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 12px; overflow: hidden; }
.agenda .day h3 { margin: 0; padding: 10px 14px; background: #fafbfc; border-bottom: 1px solid var(--line-2); font-size: .95rem; }
.agenda .day.today h3 { background: var(--red-soft); color: var(--red-d); }
.agenda .item { display: grid; grid-template-columns: 74px 1fr; gap: 10px; padding: 9px 14px; border-bottom: 1px solid var(--line-2); text-decoration: none; color: var(--ink); }
.agenda .item:last-child { border-bottom: 0; }
.agenda .item .veh { font-weight: 800; }
.agenda .item .meta { font-size: .85rem; color: var(--ink-2); }
.agenda .empty { padding: 10px 14px; color: var(--muted); font-size: .88rem; }
@media (max-width: 760px) {
  .board { display: none; }
  .agenda { display: block; }
  .legend .desk-only { display: none; }
  .weeknav .range { min-width: 0; }
  .card { padding: 14px; }
}
body.kiosk .board { max-height: none; }

/* Dienstplan */
.dp { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.dp .da { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow); }
.dp .da.next { border-color: var(--dienst-line); box-shadow: 0 0 0 3px var(--dienst-bg); }
.dp .da.off { opacity: .6; }
.dp .da h3 { margin: 0 0 2px; }
.dp .da ul { list-style: none; padding: 0; margin: 10px 0 0; display: grid; gap: 6px; }
.dp .da li { display: flex; justify-content: space-between; gap: 10px; padding: 6px 9px; border-radius: 7px; background: #f6f7f9; }
.dp .da li.mine { background: var(--dienst-bg); font-weight: 700; }
.matrix td.mine { background: var(--dienst-bg); font-weight: 700; }

/* Verwaltung */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; }
.tile { display: block; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; text-decoration: none; color: var(--ink); box-shadow: var(--shadow); }
.tile:hover { border-color: #c5cbd3; }
.tile b { display: block; font-size: 1.05rem; margin-bottom: 4px; }
.tile span { color: var(--muted); font-size: .9rem; }
.tile .num { font-size: 1.8rem; font-weight: 800; color: var(--red); display: block; margin-bottom: 2px; }
.sortlist { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.sortlist li { display: flex; align-items: center; gap: 8px; padding: 7px 10px; background: #f6f7f9; border-radius: 7px; }
.sortlist li .grow { flex: 1; }
.conflict { background: var(--no-bg); border: 1px solid #efb4b4; border-radius: 8px; padding: 10px 14px; margin-bottom: 14px; color: var(--no); }
.conflict ul { margin: 6px 0 0; padding-left: 18px; }
.pwlist { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .88rem; }

/* Buchungszwecke */
.swatch { width: 14px; height: 14px; border-radius: 4px; flex: none; }
.sortlist li.off { opacity: .55; }
.check.small { font-size: .85rem; white-space: nowrap; }

/* Statistik – Farben der Zwecke kommen aus purpose_colors() (validierte Reihenfolge, fest je Zweck) */
.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 14px; }
.filters select { width: auto; }
.seg { display: inline-flex; border: 1px solid #cdd2da; border-radius: 8px; overflow: hidden; background: #fff; }
.seg a { padding: 8px 14px; text-decoration: none; color: var(--ink-2); font-size: .92rem; font-weight: 600; }
.seg a.on { background: var(--navy); color: #fff; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 2px; }
.kpi .kv { font-size: 1.7rem; font-weight: 800; letter-spacing: -.02em; color: var(--ink); line-height: 1.15; }
.kpi .kv-s { font-size: 1.15rem; padding: .25rem 0; }
.kpi .kl { font-size: .8rem; color: var(--muted); }
.viz h2 { margin-bottom: 2px; }
.sub { margin: 0 0 14px; font-size: .84rem; color: var(--muted); }
.hbars { display: grid; gap: 7px; }
.hrow { display: grid; grid-template-columns: minmax(90px, 30%) 1fr auto; gap: 10px; align-items: center; padding: 2px 0; cursor: default; }
.stacked .hrow { grid-template-columns: 70px 1fr auto; }
.hlab { font-size: .86rem; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.htrack { position: relative; height: 18px; }
.hbar, .hstack { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 0 4px 4px 0; min-width: 3px; }
.hstack { display: flex; gap: 2px; background: #fff; }
.hstack .seg-b { height: 100%; min-width: 2px; }
.hstack .seg-b:last-child { border-radius: 0 4px 4px 0; }
.hrow:hover .hbar, .hstack .seg-b:hover { filter: brightness(.92); }
.hval { font-size: .84rem; font-weight: 700; color: var(--ink); white-space: nowrap; font-variant-numeric: tabular-nums; }
.hval .pct { font-weight: 400; color: var(--muted); margin-left: 6px; }
.legend-row { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: .82rem; color: var(--ink-2); margin-bottom: 12px; }
.legend-row i, .dot { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.cols { display: grid; grid-template-columns: repeat(var(--n), 1fr); gap: 4px; align-items: end; height: 200px; padding-top: 18px; border-bottom: 1px solid var(--line); }
.col { position: relative; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; }
.cbar { width: 100%; max-width: 34px; background: #2a78d6; border-radius: 4px 4px 0 0; }
.col:hover .cbar { filter: brightness(.9); }
.cval { font-size: .74rem; font-weight: 700; color: var(--ink); margin-bottom: 3px; white-space: nowrap; min-height: 1em; }
.clab { position: absolute; top: 100%; margin-top: 4px; font-size: .7rem; color: var(--muted); text-align: center; line-height: 1.15; }
.viz .cols { margin-bottom: 34px; }
.matrix-stat td.num, .matrix-stat th { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.matrix-stat td:first-child, .matrix-stat th:first-child { text-align: left; }
.matrix-stat tfoot td { border-top: 2px solid var(--line); }
.tip { position: fixed; z-index: 50; pointer-events: none; background: var(--navy); color: #fff; font-size: .8rem; padding: 6px 9px; border-radius: 6px; max-width: 280px; box-shadow: 0 4px 14px rgba(0,0,0,.18); }
.matrix-stat thead th { text-transform: none; letter-spacing: 0; font-size: .78rem; white-space: normal; vertical-align: bottom; min-width: 70px; max-width: 120px; }
@media (max-width: 760px) { .hrow { grid-template-columns: minmax(80px, 38%) 1fr auto; } .hval .pct { display: none; } .kpi .kv { font-size: 1.4rem; } }
