:root {
  /* --- Marken-Design-Tokens --- */
  --brand-primary: #1E2B7A;      /* Kopf/Nav + primäre Buttons (weiße Schrift) */
  --brand-primary-hell: #2C3DA0; /* Hover primär */
  --brand-accent: #14C0C0;       /* Akzent: Linien, Fokusringe, Links, Tints — NIE als gefüllte Fläche mit weißer Schrift */
  --brand-accent-tint: #E5FAFA;  /* heller Akzent-Hintergrund */

  /* Rückwärtskompatible Aliase (bestehender Code nutzt --primary etc.) */
  --primary: var(--brand-primary);
  --primary-hell: var(--brand-primary-hell);
  --accent: #0F9D66;             /* Grün für Plan/positiv */

  --bg: #f4f6f9;
  --panel: #ffffff;
  --border: #E2E8F0;
  --text: #0F172A;
  --muted: #64748b;
  --text-secondary: #64748b;  /* gedämpftes Grau für dezente Beschriftungen (z. B. BR-Zeile) */

  /* Warnungen / Konflikt */
  --warn: #c0392b;
  --warn-bg: #fdecea;
  --konflikt: #DC2626;
  --konflikt-bg: #FEF2F2;

  /* Schichtblock */
  --block-bg: #ffffff;
  --block-border: #E2E8F0;
  --block-akzent: #94A3B8;       /* Default-Akzentbalken wenn keine BR-Farbe */
  --block-text: #0F172A;
  --urlaub-bg: #E7F6EE;
  --urlaub-text: #0F7A4F;
  --hotel-grau: #94A3B8;

  --schatten: 0 1px 3px rgba(0, 0, 0, 0.08);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
}
button { font-family: inherit; }
a { color: var(--primary-hell); }

.hidden { display: none !important; }

/* ---------- Login ---------- */
#login {
  display: flex; align-items: center; justify-content: center; height: 100vh; padding: 16px;
}
.login-box {
  background: var(--panel); padding: 28px; border-radius: 12px; box-shadow: var(--schatten);
  width: 100%; max-width: 360px;
}
.login-logo { display: block; width: 100%; max-width: 260px; height: auto; margin: 0 auto 20px; }
.login-box h1 { margin: 0 0 4px; color: var(--primary); font-size: 22px; text-align: center; }
.login-box > p { text-align: center; }
@media (max-width: 480px) { .login-logo { max-width: 200px; } }
.login-box p { margin: 0 0 20px; color: var(--muted); }
.login-box label { display: block; margin: 12px 0 4px; font-weight: 600; }
.login-box input { width: 100%; }
.login-fehler { color: var(--warn); margin-top: 12px; min-height: 18px; }

/* ---------- Formularelemente ---------- */
input, select, textarea {
  padding: 8px 10px; border: 1px solid var(--border); border-radius: 7px; font-size: 14px;
  background: #fff; color: var(--text);
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand-accent); outline-offset: -1px; }
button:focus-visible, .btn:focus-visible { outline: 2px solid var(--brand-accent); outline-offset: 1px; }

button, .btn {
  cursor: pointer; border: 1px solid var(--border); background: #fff; color: var(--text);
  padding: 8px 14px; border-radius: 7px; font-size: 14px; font-weight: 600;
}
button:hover { background: #f0f3f7; }
.btn-primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-hell); }
.btn-accent { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn-danger { color: var(--warn); border-color: #e6b3ae; }
.btn-danger:hover { background: var(--warn-bg); }
.btn-klein { padding: 4px 9px; font-size: 12px; }

/* ---------- Layout Büro ---------- */
header.topbar {
  display: flex; align-items: center; gap: 16px; background: var(--primary); color: #fff;
  padding: 10px 18px;
}
header.topbar .marke { font-weight: 700; font-size: 17px; display: inline-flex; align-items: center; gap: 9px; }
.logo-pill { background: #fff; border-radius: 6px; padding: 3px 8px; display: inline-flex; align-items: center; box-shadow: 0 1px 2px rgba(0,0,0,0.12); }
.logo-pill img { height: 18px; width: auto; display: block; }
.f-topbar .logo-pill img { height: 17px; }
header.topbar nav { display: flex; gap: 4px; flex: 1; }
header.topbar nav button {
  background: transparent; border: none; color: #cdd9ea; font-weight: 600; padding: 7px 12px; border-radius: 6px;
}
header.topbar nav button:hover { background: rgba(255,255,255,0.12); color: #fff; }
header.topbar nav button.aktiv { color: #fff; box-shadow: inset 0 -3px 0 var(--brand-accent); border-radius: 6px 6px 0 0; }
header.topbar .rechts { display: flex; align-items: center; gap: 12px; }
header.topbar .rechts .user { color: #cdd9ea; font-size: 13px; }
header.topbar .rechts button { background: rgba(255,255,255,0.12); border: none; color: #fff; }

main { padding: 16px 18px; }
.tab { display: none; }
.tab.aktiv { display: block; }

.panel { background: var(--panel); border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--schatten); }
.panel-kopf {
  display: flex; align-items: center; gap: 12px; padding: 10px 14px; border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.panel-kopf h2 { margin: 0; font-size: 16px; }
.panel-kopf .spacer { flex: 1; }
.panel-inhalt { padding: 14px; }

/* ---------- Timeline ---------- */
.plan-steuerung { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.plan-steuerung .wochenlabel { font-weight: 700; font-size: 15px; min-width: 150px; }
.plan-steuerung .zoom-btn { min-width: 34px; font-size: 16px; line-height: 1; padding: 6px 10px; }
#timeline { margin-top: 10px; }

/* Zeilenhöhe je Fahrer: drei Blockzeilen (Uhrzeit / Strecke / BR) passen sicher untereinander */
#timeline .vis-labelset .vis-label,
#timeline .vis-foreground .vis-group { min-height: 68px; }
#timeline .vis-labelset .vis-label .vis-inner { padding: 4px 6px; width: 100%; }

/* Pool-Zeile "Nicht verplant" oben, deutlich abgesetzt */
#timeline .vis-foreground .vis-group.pool-group { background: var(--brand-accent-tint); }
#timeline .vis-labelset .vis-label.pool-group { background: var(--brand-accent-tint); border-left: 3px solid var(--brand-accent); }

.vis-item .vis-item-content { padding: 3px 7px; }

/* Schichtblock: weiß, dünner grauer Rahmen, farbiger linker Akzentbalken (3px), dunkler Text */
.vis-item.schicht {
  background: var(--block-bg);
  border: 1px solid var(--block-border);
  border-left: 3px solid var(--block-akzent);
  border-radius: 5px;
  color: var(--block-text);
}
.vis-item.schicht.vis-selected { box-shadow: 0 0 0 2px var(--brand-accent); border-color: var(--brand-accent); background: var(--block-bg); }
.vis-item.hotel {
  border: 1px dashed var(--hotel-grau);
  border-left: 3px dashed var(--hotel-grau);
  background: #F8FAFC; color: #475569;
}
.vis-item.urlaub {
  background: var(--urlaub-bg);
  border: 1px solid #BBE6CE; border-left: 3px solid var(--urlaub-text);
  color: var(--urlaub-text);
}
/* Konflikt überschreibt BR-Farbe: roter Balken + Rahmen + Hintergrund */
.vis-item.schicht.konflikt {
  border-color: var(--konflikt) !important;
  border-left-color: var(--konflikt) !important;
  background: var(--konflikt-bg) !important;
}
.vis-item.br-warnung { box-shadow: 0 0 0 2px var(--warn); }

.vis-item.uebergang {
  background: rgba(15,157,102,0.12); border: none; color: #0F7A4F; font-size: 11px; text-align: center;
}
.vis-item.uebergang.warn { background: var(--warn-bg); color: var(--warn); font-weight: 700; }
.vis-item.uebergang .vis-item-content { width: 100%; text-align: center; }

/* Blockinhalt: drei Zeilen (Uhrzeit / Strecke / BR dezent), je Zeile Ellipsis statt hartem Abschnitt */
.schicht-inhalt { font-size: 12px; line-height: 1.3; overflow: hidden; }
.schicht-inhalt > div { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.schicht-inhalt .s-zeit { font-weight: 600; color: var(--block-text); }
.schicht-inhalt .s-strecke { font-weight: 500; color: var(--block-text); }
.schicht-inhalt .s-br { font-size: 10.5px; color: var(--text-secondary); font-weight: 500; }
.schicht-inhalt .warn-dreieck { color: var(--konflikt); font-weight: 700; }
.schicht-inhalt .ist-punkt { color: var(--accent); font-weight: 700; }

.badge { display: inline-block; padding: 1px 6px; border-radius: 4px; font-size: 10.5px; font-weight: 700; color: #fff; }

/* Fahrer-Spalte (Gruppen-Label) mit Stundenleiste */
.grp { padding: 4px 2px; }
.grp .grp-name { font-weight: 700; color: var(--text); line-height: 1.2; }
.grp .grp-ort { font-size: 11px; color: var(--muted); margin-bottom: 4px; }
.grp .grp-pool { font-weight: 700; color: var(--brand-primary); }
.mini-leiste { width: 150px; }
.mini-bar { position: relative; height: 7px; background: #EDF1F5; border-radius: 4px; overflow: hidden; margin-bottom: 2px; }
.mini-bar .fuell { position: absolute; left: 0; top: 0; bottom: 0; }
.mini-bar .fuell.solide { background: var(--accent); }
.mini-bar .fuell.hell { background: #9AD9BE; }
.mini-bar .fuell.ueber { background: var(--konflikt); }
.mini-bar .soll-mark { position: absolute; top: -1px; bottom: -1px; border-left: 2px dashed #64748b88; }
.mini-text { font-size: 10.5px; color: var(--muted); line-height: 1.2; white-space: normal; }
.mini-text .ueber-rot { color: var(--konflikt); font-weight: 700; }

/* ---------- Tabellen ---------- */
table { border-collapse: collapse; width: 100%; }
th, td { text-align: left; padding: 7px 10px; border-bottom: 1px solid var(--border); }
th { font-size: 12px; text-transform: uppercase; letter-spacing: 0.3px; color: var(--muted); }
tr:hover td { background: #fafbfc; }
.tabelle-aktionen { display: flex; gap: 6px; }

/* ---------- Stunden-Balken ---------- */
.stunden-name { font-weight: 700; }
.balken-wrap { display: flex; flex-direction: column; gap: 3px; min-width: 180px; }
.balken { position: relative; height: 12px; background: #eceff3; border-radius: 6px; overflow: hidden; }
.balken .fuell { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 6px; }
.balken .fuell.plan { background: var(--primary-hell); }
.balken .fuell.ist { background: var(--accent); }
.balken .fuell.ueber { background: var(--warn); }
.balken-legende { font-size: 11px; color: var(--muted); }
.chip { display: inline-block; padding: 1px 7px; border-radius: 10px; font-size: 11px; font-weight: 700; }
.chip.gruen { background: #e6f4ea; color: #1e7d3a; }
.chip.rot { background: var(--warn-bg); color: var(--warn); }

/* ---------- Modal ---------- */
.modal-hg { position: fixed; inset: 0; background: rgba(20,30,45,0.45); display: flex; align-items: flex-start; justify-content: center; padding: 30px 16px; overflow: auto; z-index: 50; }
.modal { background: #fff; border-radius: 12px; width: 100%; max-width: 560px; box-shadow: 0 12px 40px rgba(0,0,0,0.25); }
.modal-kopf { display: flex; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--border); }
.modal-kopf h3 { margin: 0; font-size: 17px; }
.modal-kopf .schliessen { margin-left: auto; background: none; border: none; font-size: 22px; line-height: 1; padding: 0 4px; color: var(--muted); }
.modal-inhalt { padding: 18px; }
.modal-fuss { display: flex; gap: 10px; justify-content: flex-end; padding: 14px 18px; border-top: 1px solid var(--border); }
.feld { margin-bottom: 12px; }
.feld label { display: block; font-weight: 600; margin-bottom: 4px; }
.feld input, .feld select, .feld textarea { width: 100%; }
.feld-reihe { display: flex; gap: 12px; }
.feld-reihe > .feld { flex: 1; }
.hinweisbox { background: var(--warn-bg); color: var(--warn); border: 1px solid #e6b3ae; border-radius: 7px; padding: 8px 11px; margin-bottom: 12px; font-weight: 600; }
.via-liste { display: flex; flex-direction: column; gap: 6px; }
.via-zeile { display: flex; gap: 6px; }
.checkbox-liste { display: flex; flex-wrap: wrap; gap: 8px; }
.checkbox-liste label { display: flex; align-items: center; gap: 5px; font-weight: 500; background: #f2f5f9; padding: 5px 10px; border-radius: 6px; cursor: pointer; }
.checkbox-liste input { width: auto; }

.farbe-punkt { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: 6px; vertical-align: middle; border: 1px solid rgba(0,0,0,0.15); }

.leer { color: var(--muted); text-align: center; padding: 30px; }
.toast { position: fixed; bottom: 20px; right: 20px; background: #1c2530; color: #fff; padding: 12px 18px; border-radius: 8px; box-shadow: var(--schatten); z-index: 100; opacity: 0; transform: translateY(10px); transition: all .2s; }
.toast.zeigen { opacity: 1; transform: translateY(0); }
.toast.fehler { background: var(--warn); }

/* ---------- Fahrer-Ansicht (mobil) ---------- */
#fahrer-app { max-width: 640px; margin: 0 auto; }
.f-topbar { background: var(--primary); color: #fff; padding: 14px 16px; display: flex; align-items: center; gap: 12px; position: sticky; top: 0; z-index: 10; }
.f-topbar .marke { font-weight: 700; font-size: 16px; flex: 1; display: inline-flex; align-items: center; gap: 8px; }
.f-topbar button { background: rgba(255,255,255,0.15); border: none; color: #fff; }
.f-woche { display: flex; align-items: center; gap: 10px; padding: 12px 16px; background: #fff; border-bottom: 1px solid var(--border); position: sticky; top: 52px; z-index: 9; }
.f-woche .label { font-weight: 700; flex: 1; text-align: center; }
.f-tag { margin: 12px 16px; }
.f-tag h3 { margin: 0 0 8px; font-size: 15px; color: var(--primary); border-bottom: 2px solid #e4e9f0; padding-bottom: 5px; }
.f-schicht { background: #fff; border: 1px solid var(--border); border-left: 4px solid var(--primary); border-radius: 8px; padding: 11px 13px; margin-bottom: 9px; box-shadow: var(--schatten); }
.f-schicht.hotel { border-left-color: #9aa7b6; background: #f7f9fb; }
.f-schicht.urlaub { border-left-color: var(--accent); background: #f0f8f2; }
.f-schicht .kopf { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.f-schicht .zeit { font-weight: 700; font-size: 15px; }
.f-schicht .weg { color: var(--text); margin: 3px 0; }
.f-schicht .meta { color: var(--muted); font-size: 13px; }
.f-frei { color: var(--muted); font-style: italic; padding: 4px 0; }
.f-hinweis { background: #fff8e1; border: 1px solid #f0d98a; color: #8a6d1a; padding: 12px 16px; margin: 12px 16px; border-radius: 8px; }

@media (max-width: 700px) {
  header.topbar { flex-wrap: wrap; }
  header.topbar nav { order: 3; width: 100%; overflow-x: auto; }
  .feld-reihe { flex-direction: column; gap: 0; }
}

/* ---------- Erweiterungen: neue Typen, Raster, Ampel, Bestätigung ---------- */

/* Wochenend-/Feiertags-Hintergrund im Zeitstrahl */
.vis-item.vis-background.tag-frei { background: rgba(100, 116, 139, 0.10); }

/* gelber Warnchip */
.chip.gelb { background: #FEF3C7; color: #92610a; }

/* Abwesenheitsraster */
table.raster { border-collapse: collapse; font-size: 12px; }
table.raster th, table.raster td { border: 1px solid #E2E8F0; padding: 2px 4px; text-align: center; }
table.raster th.raster-tag { min-width: 22px; font-weight: 600; color: var(--text); text-transform: none; letter-spacing: 0; }
table.raster th.raster-tag .dow { font-weight: 400; color: var(--muted); font-size: 10px; }
table.raster .raster-fix { position: sticky; left: 0; background: #fff; z-index: 1; text-align: left; min-width: 130px; }
table.raster td.rz { height: 24px; }
table.raster td.rz.dienst { color: var(--muted); }
table.raster .frei { background: rgba(100, 116, 139, 0.12); }
.leg { display: inline-flex; align-items: center; gap: 4px; margin-right: 6px; }
.leg-farbe { display: inline-block; width: 13px; height: 13px; border-radius: 3px; border: 1px solid #cbd5e1; }
.leg-farbe.frei { background: rgba(100, 116, 139, 0.12); }

/* Fahrer-Ansicht: Bestätigung */
.f-best-bar { display: flex; align-items: center; gap: 10px; justify-content: space-between; flex-wrap: wrap;
  background: #fff8e1; border: 1px solid #f0d98a; color: #8a6d1a; padding: 12px 16px; margin: 12px 16px; border-radius: 8px; }
.f-best-bar button { flex-shrink: 0; }
.f-bestaetigt { background: #E7F6EE; border: 1px solid #BBE6CE; color: var(--urlaub-text); padding: 10px 16px; margin: 12px 16px; border-radius: 8px; font-weight: 600; }

/* ---------- Schicht-Aktionen: Kontextmenü, Modal-Aktionen, Zugnummer ---------- */
.kontextmenu {
  position: absolute; z-index: 200; background: #fff; border: 1px solid var(--border);
  border-radius: 8px; box-shadow: 0 6px 24px rgba(0,0,0,0.18); padding: 4px; min-width: 190px;
}
.kontextmenu button {
  display: block; width: 100%; text-align: left; border: none; background: none;
  padding: 8px 12px; border-radius: 6px; font-size: 13px; font-weight: 500; cursor: pointer;
}
.kontextmenu button:hover { background: #f0f3f7; }
.kontextmenu button.gefahr { color: var(--warn); }
.kontextmenu button.gefahr:hover { background: var(--warn-bg); }

.modal-aktionen { display: flex; gap: 8px; margin-bottom: 12px; padding-bottom: 12px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }

.schicht-inhalt .zug { color: #475569; font-weight: 600; }

/* ---------- Ausfall / interne Notiz ---------- */
.vis-item.schicht.ausfall {
  opacity: 0.7;
  background: #f1f5f9 !important;
  border-left-color: #94a3b8 !important;
}
.vis-item.schicht.ausfall .s-zeit,
.vis-item.schicht.ausfall .s-strecke,
.vis-item.schicht.ausfall .s-br { text-decoration: line-through; }
.ausfall-badge {
  display: inline-block; font-size: 10px; font-weight: 700; padding: 0 5px; border-radius: 4px;
  background: #e2e8f0; color: #475569; text-decoration: none; vertical-align: baseline;
}
.ausfall-badge.bezahlt { background: #FEF3C7; color: #92610a; }
.ausfall-badge.unbezahlt { background: #e2e8f0; color: #475569; }
.schicht-inhalt .notiz-icon { text-decoration: none; }

/* Mobile Fahrer-Ansicht: Ausfall */
.f-schicht.ausfall { opacity: 0.75; border-left-color: #94a3b8; }
.f-schicht.ausfall .zeit, .f-schicht.ausfall .weg { text-decoration: line-through; }
.f-schicht.ausfall .ausfall-badge { text-decoration: none; }
