:root {
  --ink: #0f172a;
  --ink-2: #1e293b;
  --bg: #f4f6f9;
  --surface: #ffffff;
  --border: #e3e8ef;
  --text: #0f172a;
  --muted: #64748b;
  --brand: #1d4ed8;
  --brand-600: #1e40af;
  --st-neu: #64748b;
  --st-zugewiesen: #2563eb;
  --st-angenommen: #b45309;
  --st-unterwegs: #047857;
  --st-abgeschlossen: #94a3b8;
  --st-storniert: #b91c1c;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(15,23,42,.06), 0 4px 12px rgba(15,23,42,.05);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, Inter, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  line-height: 1.45;
}
h1, h2, h3 { margin: 0; letter-spacing: -0.01em; }
button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; font-size: 16px; }

/* ---------- Topbar ---------- */
.topbar {
  background: linear-gradient(135deg, #13234d 0%, #1e3a8a 68%, #22539e 100%);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 11px 18px;
  position: sticky;
  top: 0;
  z-index: 20;
  box-shadow: 0 6px 20px rgba(10,16,32,.35);
}
.topbar .brand { display: flex; align-items: center; gap: 12px; font-weight: 700; }
.logo-badge { width: 42px; height: 42px; border-radius: 12px; background: #fff; display: grid; place-items: center;
  box-shadow: 0 6px 16px rgba(0,0,0,.28); flex: 0 0 auto; }
.logo-badge img { width: 32px; height: 32px; display: block; }
.brandtext { display: flex; flex-direction: column; line-height: 1.12; }
.brandtext b { font-weight: 800; font-size: 16.5px; letter-spacing: .2px; }
.brandtext b em { color: #6cc4f5; font-style: normal; }
.brandtext small { font-size: 11px; color: #bcd0ec; margin-top: 2px; letter-spacing: .3px; }
.topbar .brand .dot { width: 10px; height: 10px; border-radius: 50%; background: #38bdf8; box-shadow: 0 0 0 4px rgba(56,189,248,.2); }
.topbar .who { font-size: 13px; color: #cbd5e1; }
.topbar button.logout {
  background: transparent; color: #cbd5e1; border: 1px solid #334155;
  padding: 6px 12px; border-radius: 8px; font-size: 13px;
}
.topbar button.logout:hover { color: #fff; border-color: #475569; }

/* ---------- Layout ---------- */
.wrap { max-width: 1080px; margin: 0 auto; padding: 20px 16px 60px; }
.driver-wrap { max-width: 560px; }

/* ---------- Status-Pill (Signatur-Element) ---------- */
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; font-weight: 700; letter-spacing: .02em; text-transform: uppercase;
  padding: 4px 10px; border-radius: 999px; color: #fff; white-space: nowrap;
}
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: rgba(255,255,255,.85); }
.pill.neu { background: var(--st-neu); }
.pill.zugewiesen { background: var(--st-zugewiesen); }
.pill.angenommen { background: var(--st-angenommen); }
.pill.unterwegs { background: var(--st-unterwegs); }
.pill.abgeschlossen { background: var(--st-abgeschlossen); }
.pill.storniert { background: var(--st-storniert); }

/* ---------- Cards / Board ---------- */
.section-head { display: flex; align-items: center; justify-content: space-between; margin: 24px 0 12px; }
.section-head h2 { font-size: 15px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px;
}
.rides { display: grid; gap: 12px; }

.ride {
  background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--st-neu);
  border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px 16px;
}
.ride.zugewiesen { border-left-color: var(--st-zugewiesen); }
.ride.angenommen { border-left-color: var(--st-angenommen); }
.ride.unterwegs { border-left-color: var(--st-unterwegs); }
.ride.abgeschlossen { border-left-color: var(--st-abgeschlossen); opacity: .7; }
.ride.storniert { border-left-color: var(--st-storniert); opacity: .6; }

.ride-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 8px; }
.route { font-weight: 700; font-size: 16px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.route .arrow { color: var(--brand); font-weight: 800; }
.meta { color: var(--muted); font-size: 13px; margin-top: 2px; display: flex; flex-wrap: wrap; gap: 4px 14px; }
.meta b { color: var(--text); font-weight: 600; }
.when { font-variant-numeric: tabular-nums; font-weight: 700; color: var(--ink-2); }

.ride-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.assign-row { display: flex; gap: 8px; align-items: center; margin-top: 12px; }
.assign-row select { flex: 1; }

/* ---------- Forms / Buttons ---------- */
label { display: block; font-size: 13px; font-weight: 600; color: var(--ink-2); margin: 0 0 4px; }
.field { margin-bottom: 12px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
input[type=text], input[type=password], input[type=tel], input[type=number],
input[type=datetime-local], select, textarea {
  width: 100%; padding: 10px 12px; border: 1px solid var(--border);
  border-radius: 10px; background: #fff; color: var(--text); outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(29,78,216,.14); }
textarea { min-height: 64px; resize: vertical; }

.btn {
  border: 1px solid transparent; border-radius: 10px; padding: 11px 16px;
  font-weight: 700; font-size: 14px; background: linear-gradient(135deg, var(--brand), var(--brand-600)); color: #fff;
}
.btn:hover { filter: brightness(1.07); }
.btn:disabled { opacity: .55; cursor: default; }
.btn.block { width: 100%; }
.btn.ghost { background: #fff; color: var(--ink-2); border-color: var(--border); }
.btn.ghost:hover { background: #f8fafc; }
.btn.big { padding: 16px; font-size: 16px; }
.btn.go { background: var(--st-unterwegs); } .btn.go:hover { filter: brightness(.94); }
.btn.accept { background: var(--st-zugewiesen); } .btn.accept:hover { filter: brightness(.94); }
.btn.done { background: var(--ink-2); } .btn.done:hover { background: var(--ink); }
.btn.danger { background: #fff; color: var(--st-storniert); border-color: #fca5a5; }
.btn.danger:hover { background: #fef2f2; }
.btn.small { padding: 7px 12px; font-size: 13px; }

/* ---------- Login ---------- */
.login-screen { min-height: 100dvh; display: grid; place-items: center; padding: 20px;
  background: radial-gradient(1200px 600px at 50% -10%, #1e293b, var(--ink)); }
.login-card { width: 100%; max-width: 380px; background: var(--surface); border-radius: 16px;
  box-shadow: 0 20px 50px rgba(0,0,0,.35); padding: 28px 24px; }
.login-card .brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 20px; margin-bottom: 4px; }
.login-card .brand .dot { width: 11px; height: 11px; border-radius: 50%; background: #38bdf8; }
.login-card .sub { color: var(--muted); font-size: 13px; margin-bottom: 20px; }

/* ---------- Utilities ---------- */
.error { background: #fef2f2; border: 1px solid #fecaca; color: var(--st-storniert);
  padding: 10px 12px; border-radius: 10px; font-size: 14px; margin-bottom: 12px; }
.error:empty { display: none; }
.empty { text-align: center; color: var(--muted); padding: 40px 16px; font-size: 15px; }
.hidden { display: none !important; }
.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 4px; }
.tab { border: 1px solid var(--border); background: #fff; color: var(--muted);
  padding: 7px 14px; border-radius: 999px; font-size: 13px; font-weight: 600; }
.tab.active { background: var(--ink); color: #fff; border-color: var(--ink); }
.count { font-variant-numeric: tabular-nums; }

/* ---------- Kalender ---------- */
.viewswitch { display: flex; gap: 6px; margin-bottom: 4px; }
.vtab { border: 1px solid var(--border); background: #fff; color: var(--muted);
  padding: 8px 16px; border-radius: 999px; font-size: 14px; font-weight: 700; }
.vtab.active { background: var(--brand); color: #fff; border-color: var(--brand); }

.cal-toolbar { display: flex; align-items: center; justify-content: space-between;
  gap: 12px; flex-wrap: wrap; margin: 18px 0 14px; }
.cal-nav { display: flex; gap: 6px; }
.cal-title { font-weight: 800; font-size: 18px; letter-spacing: -0.01em; }
.cal-modes { margin: 0; }

.cal-scroll { overflow-x: auto; }
.cal-week { display: grid; grid-template-columns: repeat(7, minmax(130px, 1fr)); gap: 8px; min-width: 780px; }

.cal-day { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); min-height: 120px; padding: 8px; display: flex; flex-direction: column; gap: 6px; }
.cal-day.today { border-color: var(--brand); box-shadow: 0 0 0 2px rgba(29,78,216,.15); }
.cal-day .dhead { display: flex; justify-content: space-between; align-items: baseline;
  font-size: 13px; font-weight: 700; color: var(--ink-2); }
.cal-day .dhead .wd { color: var(--muted); text-transform: uppercase; letter-spacing: .04em; font-size: 11px; }
.cal-day .dnum { font-variant-numeric: tabular-nums; }
.cal-empty { color: var(--muted); font-size: 12px; }

.cal-month { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.cal-month .wdhead { text-align: center; font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .04em; color: var(--muted); padding: 2px 0; }
.cal-month .cal-day { min-height: 92px; }
.cal-month .cal-day.other { opacity: .45; }

.cal-day { cursor: pointer; }
.cal-day:hover { border-color: var(--brand); }
.cal-add { margin-top: auto; padding-top: 4px; font-size: 11px; font-weight: 700; color: var(--brand); opacity: 0; }
.cal-day:hover .cal-add { opacity: 1; }

/* ---------- Tagesplan (Fahrer) ---------- */
.day-group { margin-bottom: 20px; }
.day-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px;
  font-size: 14px; font-weight: 800; text-transform: capitalize; color: var(--ink);
  padding: 4px 2px 8px; border-bottom: 2px solid var(--border); margin-bottom: 12px; }
.day-head .day-count { font-size: 12px; font-weight: 700; color: var(--muted); text-transform: none; }
.day-group .ride { margin-bottom: 12px; }
.seq { display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 50%;
  background: var(--brand); color: #fff; font-size: 12px; font-weight: 800; margin-right: 8px;
  vertical-align: middle; }

.weekdays { display: flex; gap: 6px; flex-wrap: wrap; }
.weekdays .wd { border: 1px solid var(--border); background: #fff; color: var(--muted);
  padding: 8px 12px; border-radius: 10px; font-weight: 700; font-size: 14px; min-width: 46px; }
.weekdays .wd.active { background: var(--brand); color: #fff; border-color: var(--brand); }

.daybody { display: flex; flex-direction: column; gap: 4px; }

.ride-chip { width: 100%; text-align: left; border: 1px solid var(--border); border-left: 3px solid var(--st-neu);
  background: #f8fafc; border-radius: 8px; padding: 4px 7px; font-size: 12px; cursor: pointer;
  display: flex; flex-direction: column; gap: 1px; }
.ride-chip:hover { background: #eef2f7; }
.ride-chip.zugewiesen { border-left-color: var(--st-zugewiesen); }
.ride-chip.angenommen { border-left-color: var(--st-angenommen); }
.ride-chip.unterwegs { border-left-color: var(--st-unterwegs); }
.ride-chip.abgeschlossen { border-left-color: var(--st-abgeschlossen); opacity: .75; }
.ride-chip.storniert { border-left-color: var(--st-storniert); opacity: .6; text-decoration: line-through; }
.rc-line { display: flex; gap: 6px; align-items: baseline; min-width: 0; }
.rc-time { font-weight: 700; font-variant-numeric: tabular-nums; color: var(--ink-2); }
.rc-who { font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rc-drv { font-size: 11px; color: var(--st-unterwegs); font-weight: 600; }
.rc-drv.nodrv { color: var(--st-angenommen); }

.cal-nodate { margin-top: 16px; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow); padding: 12px 14px; }
.cal-nodate-head { font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em;
  color: var(--muted); margin-bottom: 8px; }
.cal-nodate-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 6px; }

/* ---------- Detailfenster (Modal) ---------- */
.modal { position: fixed; inset: 0; background: rgba(15,23,42,.5); z-index: 50;
  display: flex; align-items: center; justify-content: center; padding: 20px; }
.modal-card { background: var(--surface); border-radius: 16px; box-shadow: 0 20px 50px rgba(0,0,0,.35);
  width: 100%; max-width: 440px; padding: 20px; }
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.modal-x { background: transparent; border: none; font-size: 18px; color: var(--muted); line-height: 1; }
.modal-x:hover { color: var(--text); }
.modal-route { font-weight: 800; font-size: 18px; display: flex; gap: 8px; flex-wrap: wrap;
  align-items: center; margin-bottom: 10px; }
.modal-route .arrow { color: var(--brand); }
.modal-meta { color: var(--ink-2); font-size: 14px; display: flex; flex-direction: column; gap: 4px; margin-bottom: 16px; }
.modal-actions { display: flex; justify-content: space-between; gap: 8px; margin-top: 14px; }

/* ---------- Dashboard "Heute auf einen Blick" ---------- */
.dash { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-bottom: 10px; }
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 12px 14px; display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.tile-num { font-size: 26px; font-weight: 800; line-height: 1; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.tile-lbl { font-size: 12px; color: var(--muted); font-weight: 700; text-transform: uppercase; letter-spacing: .03em; }
.tile.warn { border-color: var(--st-storniert); }
.tile.warn .tile-num { color: var(--st-storniert); }
.tile.go .tile-num { color: var(--st-unterwegs); }
.tile.next { justify-content: center; }
.tile-next { font-size: 15px; font-weight: 700; color: var(--brand); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile-click { cursor: pointer; transition: transform .06s ease, border-color .15s ease; }
.tile-click:hover { border-color: var(--brand); }
.tile-click:active { transform: scale(.98); }
.tile { position: relative; overflow: hidden; }
.tile::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--brand); }
.tile.warn::before { background: var(--st-storniert); }
.tile.go::before { background: var(--st-unterwegs); }
.tile.next::before { background: var(--st-zugewiesen); }

/* Fahrer-Farben: Punkt + Legende */
.drv-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 5px; vertical-align: baseline; }
.cal-legend { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-bottom: 12px; }
.cal-legend:empty { display: none; }
.cal-legend .leg { font-size: 12px; color: var(--muted); font-weight: 600; display: inline-flex; align-items: center; }

/* ---------- Fahrer-Ortung (Karte) ---------- */
#mapCanvas { height: 440px; border-radius: var(--radius); border: 1px solid var(--border);
  box-shadow: var(--shadow); overflow: hidden; z-index: 0; }
.maplist { margin-top: 12px; display: grid; gap: 6px; }
.loc-row { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 9px 12px; font-size: 14px; }
/* Standort teilen (Fahrer) */
.sharebar { background: #064e3b; color: #a7f3d0; border: 1px solid #065f46; border-radius: 10px;
  padding: 9px 12px; font-size: 13px; font-weight: 600; text-align: center; margin-bottom: 12px; }
.btn.ghost.sharing { background: var(--st-unterwegs); color: #fff; border-color: var(--st-unterwegs); }

/* ---------- Theme-Knopf + Offline-Leiste ---------- */
.themebtn { background: transparent; border: 1px solid #334155; color: #cbd5e1;
  width: 36px; height: 32px; border-radius: 8px; font-size: 15px; line-height: 1; padding: 0; }
.themebtn:hover { border-color: #475569; color: #fff; }
.offlinebar { background: #7c2d12; color: #ffedd5; border: 1px solid #9a3412;
  border-radius: 10px; padding: 9px 12px; font-size: 13px; font-weight: 600; text-align: center; margin-bottom: 12px; }

@media (max-width: 560px) {
  .grid2 { grid-template-columns: 1fr; }
  .ride-top { flex-direction: column; }
  .cal-month .cal-day { min-height: 64px; padding: 5px; }
  .dash { grid-template-columns: 1fr 1fr; }
}

/* ================= DARK MODE (Leitstelle) ================= */
:root[data-theme="dark"] {
  color-scheme: dark;
  --ink: #0f1a30;
  --ink-2: #e9f0fc;
  --bg: #0a1020;
  --surface: #131f38;
  --border: #243352;
  --text: #e9f0fc;
  --muted: #8ea6c8;
  --brand: #4f8ef7;
  --brand-600: #2f6fe0;
  --shadow: 0 1px 2px rgba(0,0,0,.5), 0 10px 26px rgba(0,0,0,.45);
}
/* sanftes Leuchten im Hintergrund */
:root[data-theme="dark"] body {
  background:
    radial-gradient(1100px 480px at 82% -8%, rgba(56,182,240,.08), transparent 60%),
    radial-gradient(820px 480px at -6% 0%, rgba(79,142,247,.09), transparent 55%),
    var(--bg);
}
/* Panels als feine Verläufe (Leitstellen-Look) */
:root[data-theme="dark"] .card,
:root[data-theme="dark"] .ride,
:root[data-theme="dark"] .tile,
:root[data-theme="dark"] .cal-day,
:root[data-theme="dark"] .loc-row,
:root[data-theme="dark"] .cal-nodate { background: linear-gradient(180deg, #16233f, #101a30); }
:root[data-theme="dark"] .tile.next { background: linear-gradient(135deg, #16305e, #1c3a76); }
:root[data-theme="dark"] .tile.next .tile-next { color: #bfe3ff; }
/* leuchtende Kennzahlen */
:root[data-theme="dark"] .tile.warn .tile-num { color: #f2465e; text-shadow: 0 0 22px rgba(242,70,94,.35); }
:root[data-theme="dark"] .tile.go .tile-num { color: #2fd08a; text-shadow: 0 0 22px rgba(38,192,126,.30); }
/* Elemente mit fest verdrahtetem Weiss im Dunkelmodus anpassen */
:root[data-theme="dark"] input[type=text],
:root[data-theme="dark"] input[type=password],
:root[data-theme="dark"] input[type=tel],
:root[data-theme="dark"] input[type=number],
:root[data-theme="dark"] input[type=datetime-local],
:root[data-theme="dark"] input[type=date],
:root[data-theme="dark"] input[type=time],
:root[data-theme="dark"] select,
:root[data-theme="dark"] textarea { background: #0f1b30; color: var(--text); border-color: var(--border); }
:root[data-theme="dark"] .btn.ghost { background: var(--surface); color: var(--text); }
:root[data-theme="dark"] .btn.ghost:hover { background: #1f2d49; }
:root[data-theme="dark"] .tab,
:root[data-theme="dark"] .vtab,
:root[data-theme="dark"] .weekdays .wd { background: var(--surface); }
:root[data-theme="dark"] .ride-chip { background: #0f1b30; }
:root[data-theme="dark"] .ride-chip:hover { background: #1a2740; }
:root[data-theme="dark"] .btn.danger { background: var(--surface); }
:root[data-theme="dark"] .btn.done { background: #33415c; }
:root[data-theme="dark"] .btn.done:hover { background: #3f4f6e; }
:root[data-theme="dark"] .error { background: #3a1c1f; border-color: #7f1d1d; color: #fca5a5; }
:root[data-theme="dark"] .tile.warn { border-color: #7f1d1d; }
