[hidden] { display: none !important; }

:root {
  --bg: #f4f6f9;
  --panel: #ffffff;
  --panel-2: #f8fafc;
  --line: #e2e8f0;
  --line-strong: #cbd5e1;
  --text: #0f172a;
  --muted: #64748b;
  --accent: #2563eb;
  --accent-soft: #dbeafe;
  --lkw: #2563eb;
  --lkw-soft: #dbeafe;
  --sprinter: #0d9488;
  --sprinter-soft: #ccfbf1;
  --leer: #94a3b8;
  --stand: #f59e0b;
  --stand-soft: #fef3c7;
  --ok: #16a34a;
  --ok-soft: #dcfce7;
  --warn: #d97706;
  --warn-soft: #fef3c7;
  --bad: #dc2626;
  --bad-soft: #fee2e2;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .06), 0 4px 12px rgba(15, 23, 42, .05);
  font-family: Inter, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); }
h1 { font-size: 22px; margin: 0; letter-spacing: -.01em; }
h2 { font-size: 16px; margin: 0 0 10px; }
h3 { font-size: 14px; margin: 0 0 8px; }
a { color: var(--accent); }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.nowrap { white-space: nowrap; }
.num { font-variant-numeric: tabular-nums; }

.app { display: grid; grid-template-columns: 220px minmax(0, 1fr); min-height: 100vh; }
.sidebar { background: #0f172a; color: #cbd5e1; padding: 18px 12px; position: sticky; top: 0; height: 100vh; }
.brand { display: flex; align-items: center; gap: 10px; color: #fff; font-weight: 700; font-size: 16px; padding: 4px 8px 18px; }
.brand svg { width: 28px; height: 28px; color: var(--accent); }
nav a { display: block; padding: 9px 12px; border-radius: 8px; color: #cbd5e1; text-decoration: none; margin-bottom: 2px; }
nav a:hover { background: rgba(255, 255, 255, .06); color: #fff; }
nav a.active { background: var(--accent); color: #fff; }
main { padding: 22px 26px 60px; min-width: 0; outline: none; }

.page-head { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; justify-content: space-between; margin-bottom: 18px; }
.page-head .sub { color: var(--muted); margin-top: 4px; }
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

.btn { appearance: none; border: 1px solid var(--line-strong); background: var(--panel); color: var(--text); padding: 8px 14px; border-radius: 8px; font: inherit; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: #1d4ed8; }
.btn.danger { color: var(--bad); border-color: #fca5a5; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.sm { padding: 4px 9px; font-size: 12px; }
.btn:disabled { opacity: .5; cursor: default; }

input, select, textarea { font: inherit; color: inherit; border: 1px solid var(--line-strong); border-radius: 7px; padding: 7px 9px; background: #fff; min-width: 0; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
textarea { width: 100%; min-height: 160px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }
label.field { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); }
label.field > input, label.field > select, label.field > textarea { color: var(--text); font-size: 14px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; }
.form-grid .wide { grid-column: 1 / -1; }
.check { display: inline-flex; gap: 6px; align-items: center; margin-right: 12px; color: var(--text); font-size: 14px; }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; min-width: 0; }
.grid-2 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; margin-top: 16px; }

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; box-shadow: var(--shadow); }
.kpi .label { color: var(--muted); font-size: 12px; }
.kpi .value { font-size: 22px; font-weight: 700; margin-top: 2px; font-variant-numeric: tabular-nums; }
.kpi .hint { color: var(--muted); font-size: 12px; margin-top: 2px; }

.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 600; background: var(--panel-2); border: 1px solid var(--line); color: var(--muted); white-space: nowrap; }
.badge.lkw { background: var(--lkw-soft); color: #1e40af; border-color: transparent; }
.badge.sprinter { background: var(--sprinter-soft); color: #115e59; border-color: transparent; }
.badge.offen { background: var(--warn-soft); color: #92400e; border-color: transparent; }
.badge.geplant { background: var(--accent-soft); color: #1e40af; border-color: transparent; }
.badge.erledigt { background: var(--ok-soft); color: #166534; border-color: transparent; }
.badge.storniert { background: var(--bad-soft); color: #991b1b; border-color: transparent; text-decoration: line-through; }
.badge.bad { background: var(--bad-soft); color: #991b1b; border-color: transparent; }
.badge.angebot { background: #ede9fe; color: #5b21b6; border-color: transparent; }
.badge.warn { background: var(--warn-soft); color: #92400e; border-color: transparent; }

/* ---------------- Zeitleiste */
.gantt { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow-x: auto; }
.gantt-inner { min-width: 900px; }
.g-row { display: grid; grid-template-columns: 220px 1fr; border-bottom: 1px solid var(--line); }
.g-row:last-child { border-bottom: 0; }
.g-label { padding: 10px 12px; border-right: 1px solid var(--line); background: var(--panel); position: sticky; left: 0; z-index: 3; }
.g-label .kz { font-weight: 700; display: flex; gap: 6px; align-items: center; }
.g-label .meta { color: var(--muted); font-size: 12px; margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.util { height: 5px; background: var(--line); border-radius: 3px; margin-top: 6px; overflow: hidden; }
.util > span { display: block; height: 100%; background: var(--ok); }
.util.mid > span { background: var(--warn); }
.util.low > span { background: var(--bad); }
.g-track { position: relative; min-height: 64px; }
.g-head .g-track { min-height: 30px; }
.g-head .g-label { font-size: 12px; color: var(--muted); display: flex; align-items: center; }
.tick { position: absolute; top: 0; bottom: 0; border-left: 1px solid var(--line); }
.tick span { position: absolute; top: 7px; left: 4px; font-size: 11px; color: var(--muted); }
.g-track .gridline { position: absolute; top: 0; bottom: 0; border-left: 1px dashed #eef2f7; }
.betrieb { position: absolute; top: 0; bottom: 0; background: rgba(37, 99, 235, .025); }
.now-line { position: absolute; top: 0; bottom: 0; border-left: 2px solid var(--bad); z-index: 2; }
.seg { position: absolute; top: 12px; height: 40px; border-radius: 6px; font-size: 11px; line-height: 1.25; padding: 4px 6px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.seg.tour { background: var(--lkw); color: #fff; cursor: pointer; z-index: 1; box-shadow: 0 1px 2px rgba(0, 0, 0, .15); }
.seg.tour.sprinter { background: var(--sprinter); }
.seg.tour.erledigt { opacity: .6; }
.seg.tour:hover { filter: brightness(1.08); }
.seg.tour b { display: block; }
.seg.leer, .seg.rueck { top: 26px; height: 12px; padding: 0; background: repeating-linear-gradient(45deg, var(--leer) 0 4px, transparent 4px 8px); border: 1px solid var(--leer); border-radius: 3px; }
.seg.rueck { opacity: .55; }
.seg.stand { top: 18px; height: 28px; background: transparent; border: 1px dashed var(--line-strong); color: var(--muted); display: flex; align-items: center; justify-content: center; font-size: 11px; }
.seg.luecke { border: 2px dashed var(--stand); background: var(--stand-soft); color: #92400e; cursor: pointer; font-weight: 600; z-index: 1; display: flex; align-items: center; justify-content: center; gap: 4px; }
.seg.luecke:hover { background: #fde68a; }
.seg.luecke.ganz { border: 1px dashed var(--line-strong); background: var(--panel-2); color: var(--muted); font-weight: 500; }
.seg.luecke.ganz:hover { background: #eef2f7; }
.seg.sperre { top: 14px; height: 36px; background: repeating-linear-gradient(45deg, var(--bad-soft) 0 8px, #fff 8px 16px); border: 1px solid #fca5a5; color: #991b1b; display: flex; align-items: center; justify-content: center; font-weight: 600; }
.g-row.idle .g-label .kz { color: var(--muted); }

.legend { display: flex; flex-wrap: wrap; gap: 14px; margin: 10px 2px 0; color: var(--muted); font-size: 12px; }
.legend i { display: inline-block; width: 18px; height: 10px; border-radius: 3px; vertical-align: middle; margin-right: 5px; }

/* ---------------- Listen */
.list { display: flex; flex-direction: column; gap: 8px; }
.item { border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; background: var(--panel); }
.item .row { display: flex; gap: 8px; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.item .route { font-weight: 600; }
.item .meta { color: var(--muted); font-size: 12px; margin-top: 3px; }
.item .actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; align-items: center; }
.item.suggest { border-left: 4px solid var(--stand); }
.empty { color: var(--muted); padding: 18px; text-align: center; border: 1px dashed var(--line-strong); border-radius: 8px; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { padding: 4px 10px; border-radius: 999px; font-size: 12px; border: 1px solid var(--line); background: var(--panel); }
.chip.verfuegbar { background: var(--ok-soft); border-color: transparent; color: #166534; }
.chip.verplant { background: var(--accent-soft); border-color: transparent; color: #1e40af; }
.chip.abwesend { background: var(--bad-soft); border-color: transparent; color: #991b1b; }
.chip.frei-kein-dienst { color: var(--muted); }

table.tbl { width: 100%; border-collapse: collapse; }
.tbl th, .tbl td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.tbl th { font-size: 12px; color: var(--muted); font-weight: 600; background: var(--panel-2); position: sticky; top: 0; }
.tbl tr:hover td { background: #fafcff; }
.tbl td input, .tbl td select { width: 100%; padding: 5px 6px; font-size: 13px; }
.tbl td.nowrap input { width: auto; }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); box-shadow: var(--shadow); }

/* Fahrer-Wochenraster */
.week { display: grid; grid-template-columns: 200px repeat(7, minmax(92px, 1fr)); min-width: 880px; }
.week > div { border-bottom: 1px solid var(--line); border-right: 1px solid var(--line); padding: 8px; min-height: 64px; }
.week .wh { min-height: 0; font-size: 12px; color: var(--muted); font-weight: 600; background: var(--panel-2); }
.week .wh.today { color: var(--accent); }
.week .wn { cursor: pointer; }
.week .wn:hover b { color: var(--accent); }
.day { font-size: 12px; border-radius: 6px; }
.day.frei { background: var(--ok-soft); }
.day.teilweise { background: #eef6ff; }
.day.ausgelastet { background: var(--accent-soft); }
.day.abwesend { background: var(--bad-soft); }
.day.kein-dienst { background: repeating-linear-gradient(45deg, #f8fafc 0 6px, #f1f5f9 6px 12px); color: var(--muted); }
.day .st { font-weight: 600; }

/* Import */
.drop { display: block; border: 2px dashed var(--line-strong); border-radius: var(--radius); padding: 34px; text-align: center; background: var(--panel); cursor: pointer; transition: .15s; }
.drop:hover, .drop.over { border-color: var(--accent); background: #f5f9ff; }
.drop b { font-size: 16px; }
.warnings { color: #92400e; font-size: 12px; }
pre.raw { white-space: pre-wrap; font-size: 12px; background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; padding: 10px; max-height: 320px; overflow: auto; }

/* Modal */
.modal-bg { position: fixed; inset: 0; background: rgba(15, 23, 42, .45); display: flex; align-items: flex-start; justify-content: center; padding: 40px 16px; z-index: 50; overflow-y: auto; }
.modal { background: var(--panel); border-radius: 12px; width: min(760px, 100%); box-shadow: 0 20px 60px rgba(0, 0, 0, .25); }
.modal.wide { width: min(1100px, 100%); }
.modal header { display: flex; justify-content: space-between; align-items: center; padding: 16px 18px; border-bottom: 1px solid var(--line); }
.modal header h2 { margin: 0; }
.modal .body { padding: 16px 18px; }
.modal footer { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 18px; border-top: 1px solid var(--line); flex-wrap: wrap; }
.x { border: 0; background: transparent; font-size: 22px; cursor: pointer; color: var(--muted); line-height: 1; }

#toasts { position: fixed; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 100; }
.toast { background: #0f172a; color: #fff; padding: 10px 14px; border-radius: 8px; box-shadow: var(--shadow); max-width: 380px; }
.toast.err { background: var(--bad); }
.toast.ok { background: var(--ok); }

.reasons { margin: 4px 0 0; padding-left: 18px; color: var(--muted); font-size: 12px; }
.section-gap { margin-top: 16px; }
.abw-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; padding: 6px 0; border-bottom: 1px solid var(--line); }
.worktimes { display: grid; grid-template-columns: 90px 1fr 1fr; gap: 6px 10px; align-items: center; }

@media (max-width: 900px) {
  .app { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto 1fr; }
  .sidebar { position: static; height: auto; padding: 10px 12px; }
  .brand { padding-bottom: 8px; }
  nav { display: flex; overflow-x: auto; gap: 4px; }
  nav a { white-space: nowrap; }
  main { padding: 16px; }
  .grid-2 { grid-template-columns: 1fr; }
  .g-row { grid-template-columns: 150px 1fr; }
}

/* Anmeldung */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px; background: var(--bg); }
.login { width: min(420px, 100%); padding: 28px; }
.login h1 { margin: 12px 0 14px; }
.login-brand { color: var(--text); padding: 0; }
.login-form { display: flex; flex-direction: column; gap: 12px; }
.login-form .btn { justify-content: center; margin-top: 4px; }
.konto { position: absolute; left: 12px; right: 12px; bottom: 16px; padding: 10px 12px; border-top: 1px solid rgba(255,255,255,.1); font-size: 13px; }
.konto-name { color: #fff; font-weight: 600; }
.konto-rolle { color: #94a3b8; font-size: 12px; }
.konto-aktionen { margin-top: 6px; }
.konto-aktionen a { color: #93c5fd; text-decoration: none; }
.sidebar { position: sticky; }
@media (max-width: 900px) { .konto { position: static; border-top: 0; padding: 8px 0 0; } }
.toast.warn { background: #b45309; }
.login-links { margin: 14px 0 0; text-align: center; }
.login-links a { color: var(--accent); }
.hinweis-ok { background: #ecfdf5; color: #065f46; border: 1px solid #a7f3d0; border-radius: 8px; padding: 10px 12px; font-size: 13px; margin-bottom: 10px; }
.code-eingabe { font-family: ui-monospace, monospace; font-size: 20px; letter-spacing: 3px; text-align: center; }
.qr { display: flex; justify-content: center; margin: 6px 0 10px; }
.qr svg { width: 220px; height: 220px; max-width: 100%; border: 1px solid var(--line); border-radius: 8px; }
.schluessel { font-size: 13px; word-break: break-all; user-select: all; }
.codes { display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px; }
.codes code { font-size: 15px; background: var(--panel-2); border: 1px solid var(--line); border-radius: 6px; padding: 6px; text-align: center; user-select: all; }
.startpasswort { font-size: 20px; font-family: ui-monospace, monospace; background: var(--panel-2); padding: 10px; border-radius: 8px; user-select: all; }
.seg.tour.vortag { border-top-left-radius: 0; border-bottom-left-radius: 0; background-image: linear-gradient(90deg, rgba(0,0,0,.18), transparent 14px); }
.seg.tour.folgetag { border-top-right-radius: 0; border-bottom-right-radius: 0; background-image: linear-gradient(270deg, rgba(0,0,0,.18), transparent 14px); }

/* ---- Fahrer-App (mobil) */
body.fahrermodus { background: var(--bg); }
#fahrerapp { max-width: 640px; margin: 0 auto; padding: 0 12px 40px; }
.fa-kopf { position: sticky; top: 0; z-index: 5; display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 12px 4px; background: var(--bg); border-bottom: 1px solid var(--line); }
.fa-kopf-aktionen { display: flex; gap: 6px; }
#fahrerapp h2 { font-size: 18px; margin: 18px 0 8px; }
#fahrerapp h3 { font-size: 15px; margin: 16px 0 6px; }
.fa-karte { display: block; width: 100%; text-align: left; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; margin-bottom: 8px; font: inherit; color: inherit; cursor: pointer; }
.fa-karte .row { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.fa-karte.fertig { opacity: .65; }
.fa-route { font-size: 16px; font-weight: 600; margin: 4px 0 2px; }
.fa-tag { margin: 10px 0 4px; }
.fa-titel { display: flex; align-items: center; gap: 10px; }
.fa-titel h2 { margin: 10px 0 2px !important; }
.fa-ort { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; margin: 8px 0; display: grid; gap: 4px; }
.fa-ort .btn { justify-self: start; }
.fa-hinweis { margin: 6px 0; }
.fa-gross { width: 100%; justify-content: center; font-size: 18px; padding: 16px; margin: 12px 0 8px; border-radius: 12px; }
.fa-knoepfe { display: grid; gap: 8px; }
.fa-knoepfe .btn { justify-content: center; padding: 12px; }
.fa-menue { display: grid; gap: 8px; }
.fa-bilder { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 6px; }
.fa-bilder img { width: 96px; height: 72px; object-fit: contain; background: #fff; border: 1px solid var(--line); border-radius: 8px; }
canvas.unterschrift { width: 100%; height: 180px; background: #fff; border: 1px dashed var(--line); border-radius: 8px; touch-action: none; display: block; margin: 4px 0; }
.mini-bild { width: 56px; height: 42px; object-fit: cover; border-radius: 6px; border: 1px solid var(--line); }
.re-summen { display: grid; grid-template-columns: 1fr auto; gap: 4px 24px; max-width: 320px; margin: 10px 0 0 auto; font-size: 14px; }
.re-summen > div:nth-child(even) { text-align: right; }
.alert { background: #fef2f2; border: 1px solid #fecaca; color: #991b1b; border-radius: 10px; padding: 10px 14px; margin: 0 0 14px; font-size: 14px; }
.alert a { color: #991b1b; font-weight: 600; }
.bad-text { color: var(--bad); }
.ladeliste { text-decoration: none; font-size: 13px; }
[draggable="true"] { cursor: grab; }
body.zieht .g-track { outline: 1px dashed var(--line-strong); }
.g-track.drop-ziel { background: rgba(37, 99, 235, .08); outline: 2px solid var(--accent) !important; }
.aw-chart { position: relative; }
.aw-grid { stroke: var(--line); stroke-width: 1; }
.aw-grid.null { stroke: #94a3b8; }
.aw-achse { fill: var(--muted); font-size: 11px; }
.aw-saeule { fill: var(--accent); }
.aw-treffer { fill: transparent; cursor: default; }
.aw-treffer.aktiv { fill: rgba(15, 23, 42, .04); }
.aw-tip { position: absolute; top: 8px; width: 220px; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; font-size: 12px; box-shadow: 0 4px 12px rgba(0,0,0,.08); pointer-events: none; }
.aw-balken { display: inline-block; height: 8px; background: var(--accent); border-radius: 0 4px 4px 0; vertical-align: middle; }
.bn-vorschau { white-space: pre-wrap; font-size: 12px; background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; padding: 10px; max-height: 300px; overflow: auto; }
.check input[type=checkbox] { flex-shrink: 0; }
