/* ============================================================
   Tourenplaner – Design-System
   Schrift: IBM Plex Sans · Farbe: tiefes Petrol, ruhige Neutrals
   ============================================================ */

* { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }

:root {
  /* Marke */
  --brand:        oklch(44% 0.075 215);   /* tiefes Petrol */
  --brand-strong: oklch(38% 0.075 215);   /* Hover/aktiv */
  --brand-soft:   oklch(94% 0.02 210);    /* getönte Flächen */
  --brand-ring:   oklch(80% 0.06 210);    /* Fokusring */
  --accent:       oklch(78% 0.11 180);    /* helles Aqua – nur Akzentpunkte */
  --brand-tile:   oklch(50% 0.08 215);    /* Logokachel auf dunklem Grund */
  --brand-dot:    var(--accent);

  /* Neutrals (leicht Richtung Markenton getönt) */
  --bg:          oklch(97.3% 0.004 220);
  --surface:     #ffffff;
  --surface-2:   oklch(98.5% 0.003 220);
  --line:        oklch(91% 0.008 220);
  --line-strong: oklch(85% 0.012 220);
  --ink:         oklch(26% 0.02 235);
  --ink-2:       oklch(45% 0.018 235);

  /* Sidebar – zweite, dunkle Neutral-Ebene im Markenton */
  --sidebar:       oklch(24% 0.032 225);
  --sidebar-2:     oklch(29% 0.036 225);
  --sidebar-line:  oklch(33% 0.034 225);
  --sidebar-ink:   oklch(93% 0.008 210);
  --sidebar-ink-2: oklch(72% 0.02 215);

  /* Semantik */
  --ok:          oklch(50% 0.12 155);
  --ok-soft:     oklch(95% 0.03 155);
  --warn:        oklch(52% 0.12 75);
  --warn-soft:   oklch(96% 0.035 85);
  --warn-line:   oklch(85% 0.07 85);
  --danger:      oklch(50% 0.17 27);
  --danger-soft: oklch(96% 0.02 25);
  --danger-line: oklch(87% 0.05 25);

  /* Geometrie & Tiefe */
  --r-s: 8px; --r-m: 12px; --r-l: 16px;
  --shadow-sm: 0 1px 2px oklch(30% 0.02 235 / .05), 0 1px 3px oklch(30% 0.02 235 / .07);
  --shadow-md: 0 2px 4px oklch(30% 0.02 235 / .05), 0 8px 24px oklch(30% 0.02 235 / .09);
  --shadow-lg: 0 8px 16px oklch(30% 0.02 235 / .12), 0 24px 56px oklch(30% 0.02 235 / .18);

  /* Bewegung */
  --t: 160ms;
  --ease: cubic-bezier(.19, 1, .22, 1);

  /* Z-Ebenen */
  --z-login: 40;
  --z-busy: 50;
  --z-toast: 60;

  --sidebar-w: 256px;
}

html { font-size: 16px; }
html, body { height: 100%; }
body {
  font-family: "IBM Plex Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: .875rem;
  line-height: 1.5;
  background: var(--bg);
  color: var(--ink);
  display: flex;
  -webkit-font-smoothing: antialiased;
}

::selection { background: var(--brand-soft); }

/* ============================== Sidebar ============================== */
.sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  background: var(--sidebar);
  color: var(--sidebar-ink);
  display: flex;
  flex-direction: column;
  height: 100vh;
  position: sticky;
  top: 0;
}
.brand {
  display: flex; align-items: center; gap: 12px;
  padding: 20px 18px;
  font-size: 1.0625rem; font-weight: 700; letter-spacing: -0.01em;
  border-bottom: 1px solid var(--sidebar-line);
}
.brand-mark { width: 30px; height: 30px; flex: none; display: block; }
.brand-mark-lg { width: 38px; height: 38px; }

.sidebar-section { flex: 1; overflow-y: auto; padding: 16px 12px; }
.sidebar-heading {
  display: flex; justify-content: space-between; align-items: center;
  font-size: .6875rem; font-weight: 600; text-transform: uppercase; letter-spacing: .08em;
  color: var(--sidebar-ink-2); padding: 0 8px 10px;
}
.btn-icon {
  background: var(--sidebar-2); color: var(--sidebar-ink); border: none; border-radius: 7px;
  width: 26px; height: 26px; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  transition: background var(--t) var(--ease);
}
.btn-icon svg { width: 14px; height: 14px; }
.btn-icon:hover { background: var(--brand-tile); }

.project-list { list-style: none; display: flex; flex-direction: column; gap: 2px; }
.project-list li {
  padding: 9px 12px; border-radius: var(--r-s); cursor: pointer;
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  color: var(--sidebar-ink);
  font-weight: 500;
  transition: background var(--t) var(--ease);
}
.project-list li:hover { background: var(--sidebar-2); }
.project-list li.active { background: var(--brand-tile); }
.project-list li > span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.project-list .meta { font-size: .6875rem; font-weight: 400; color: var(--sidebar-ink-2); white-space: nowrap; }
.project-list li.active .meta { color: oklch(85% 0.03 210); }

.sidebar-footer {
  padding: 14px 12px;
  border-top: 1px solid var(--sidebar-line);
  display: flex; flex-direction: column; gap: 8px;
}
.user-row { display: flex; align-items: center; gap: 8px; padding: 0 4px 2px; }
.user-name {
  flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-size: .75rem; font-weight: 600; color: var(--sidebar-ink);
}
.provider-badge { font-size: .6875rem; color: var(--sidebar-ink-2); padding: 0 4px; }

/* ============================== Buttons ============================== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--ink);
  border-radius: var(--r-s);
  padding: 8px 14px;
  font-family: inherit;
  font-size: .8125rem; font-weight: 500;
  cursor: pointer;
  transition: background var(--t) var(--ease), border-color var(--t) var(--ease),
              color var(--t) var(--ease), box-shadow var(--t) var(--ease);
}
.btn:hover { background: var(--surface-2); border-color: oklch(78% 0.015 220); }
.btn:active { background: var(--brand-soft); }
.btn:disabled { opacity: .55; cursor: default; }
.btn-ico { width: 14px; height: 14px; flex: none; }

.btn-primary {
  background: var(--brand); border-color: var(--brand); color: #fff; font-weight: 600;
}
.btn-primary:hover { background: var(--brand-strong); border-color: var(--brand-strong); }
.btn-primary:active { background: oklch(33% 0.07 215); }

.btn-secondary {
  background: var(--brand-soft); border-color: oklch(86% 0.035 210); color: var(--brand-strong); font-weight: 600;
}
.btn-secondary:hover { background: oklch(91% 0.03 210); border-color: oklch(80% 0.05 210); }

.btn-small { padding: 4px 10px; font-size: .75rem; }
.btn-big { width: 100%; padding: 12px; font-size: .9375rem; margin-top: 14px; }

.btn-danger-ghost { color: var(--danger); border-color: var(--danger-line); background: var(--surface); }
.btn-danger-ghost:hover { background: var(--danger-soft); border-color: var(--danger-line); }
.btn-iconic { padding: 8px; }
.btn-iconic svg { width: 15px; height: 15px; }

.btn-sidebar { background: var(--sidebar-2); border-color: transparent; color: var(--sidebar-ink); }
.btn-sidebar:hover { background: var(--sidebar-line); border-color: transparent; }

:is(button, input, select, textarea, [tabindex]):focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

/* ============================== Hauptbereich ============================== */
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; height: 100vh; overflow: hidden; }

.empty-state { flex: 1; display: flex; align-items: center; justify-content: center; padding: 24px; }
.empty-card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-l); box-shadow: var(--shadow-md);
  padding: 48px 52px; text-align: center; max-width: 460px;
}
.empty-illu { width: 150px; height: auto; margin-bottom: 18px; }
.empty-card h2 { font-size: 1.25rem; letter-spacing: -0.01em; margin-bottom: 8px; text-wrap: balance; }
.empty-card p { color: var(--ink-2); margin-bottom: 24px; text-wrap: pretty; }

.project-view { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.project-header {
  display: flex; align-items: center; gap: 16px;
  padding: 10px 24px;
  background: var(--surface); border-bottom: 1px solid var(--line);
}
.project-title {
  font-family: inherit;
  font-size: 1.0625rem; font-weight: 700; letter-spacing: -0.01em;
  border: 1px solid transparent;
  border-radius: var(--r-s); padding: 6px 10px;
  min-width: 120px; max-width: 340px; flex: 0 1 auto;
  background: transparent; color: var(--ink);
  transition: border-color var(--t) var(--ease), background var(--t) var(--ease);
}
.project-title:hover { border-color: var(--line); background: var(--surface-2); }
.project-title:focus { border-color: var(--brand); background: var(--surface); outline: none; box-shadow: 0 0 0 3px var(--brand-soft); }

/* Tabs: ruhige Unterstreichung statt Pillen */
.tabs { display: flex; gap: 2px; margin-left: auto; align-self: stretch; }
.tab {
  position: relative;
  border: none; background: transparent;
  padding: 0 14px;
  font-family: inherit; font-size: .8125rem; font-weight: 500;
  color: var(--ink-2); cursor: pointer;
  display: inline-flex; align-items: center; gap: 6px;
  transition: color var(--t) var(--ease);
}
.tab::after {
  content: ''; position: absolute; left: 10px; right: 10px; bottom: -1px;
  height: 2px; border-radius: 2px 2px 0 0; background: transparent;
  transition: background var(--t) var(--ease);
}
.tab:hover { color: var(--ink); }
.tab.active { color: var(--brand-strong); font-weight: 600; }
.tab.active::after { background: var(--brand); }

.pill {
  display: inline-block; min-width: 20px; padding: 1px 7px; border-radius: 99px;
  background: var(--bg); border: 1px solid var(--line);
  color: var(--ink-2); font-size: .6875rem; font-weight: 600; text-align: center;
  font-variant-numeric: tabular-nums;
}
.tab.active .pill { background: var(--brand-soft); border-color: transparent; color: var(--brand-strong); }
.card-head .pill { position: relative; top: -1px; }

.tab-panel { flex: 1; overflow-y: auto; padding: 24px; min-height: 0; }

/* ============================== Planung ============================== */
.plan-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr) minmax(0, 1fr);
  gap: 20px;
  align-items: start;
  max-width: 1600px;
}
@media (max-width: 1100px) { .plan-grid { grid-template-columns: minmax(0, 1fr); } }
.card { min-width: 0; }

.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-m); box-shadow: var(--shadow-sm);
  padding: 18px; display: flex; flex-direction: column; gap: 10px;
}
.card-head { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 8px; min-height: 28px; }
.card-head h3 { font-size: .9375rem; font-weight: 600; letter-spacing: -0.005em; display: flex; align-items: center; gap: 8px; }
.card-actions { display: flex; gap: 6px; flex-wrap: wrap; }

/* Formularelemente */
textarea, input[type=text], input[type=password], input[type=number], select {
  font-family: inherit;
  border: 1px solid var(--line-strong); border-radius: var(--r-s);
  padding: 8px 12px;
  font-size: .8125rem; color: var(--ink); background: var(--surface);
  width: 100%;
  transition: border-color var(--t) var(--ease), box-shadow var(--t) var(--ease);
}
textarea:focus, input:focus, select:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-soft);
}
::placeholder { color: var(--ink-2); opacity: .8; }
textarea { resize: vertical; line-height: 1.55; }
select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M3 4.5l3 3 3-3' fill='none' stroke='%23536070' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 12px;
  padding-right: 32px;
}
input[type=range] { accent-color: var(--brand); }
input[type=checkbox] { accent-color: var(--brand); width: 15px; height: 15px; }

.field-label { font-size: .75rem; font-weight: 600; color: var(--ink-2); margin-top: 8px; }
.field-hint { font-size: .6875rem; color: var(--ink-2); margin-top: -4px; line-height: 1.4; }

/* Adressliste */
.address-list { list-style: none; display: flex; flex-direction: column; gap: 6px; max-height: 430px; overflow-y: auto; }
.address-list li {
  display: flex; align-items: center; gap: 10px;
  border: 1px solid var(--line); border-radius: var(--r-s); padding: 8px 12px;
  background: var(--surface-2);
  transition: border-color var(--t) var(--ease);
}
.address-list li:hover { border-color: var(--line-strong); }
.address-list .addr-label { flex: 1; min-width: 0; }
.address-list .addr-text { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: block; }
.address-list .addr-sub { font-size: .6875rem; color: var(--ink-2); font-variant-numeric: tabular-nums; }

.status-dot { width: 9px; height: 9px; border-radius: 50%; flex: none; }
.status-dot.ok { background: var(--ok); }
.status-dot.fail { background: var(--danger); box-shadow: 0 0 0 3px var(--danger-soft); }
.status-dot.pending { background: var(--warn); animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .35; } }

.name-input { width: 118px !important; flex: none; padding: 4px 8px !important; font-size: .75rem !important; }
.persons-input { width: 54px !important; text-align: center; padding: 4px 6px !important; font-variant-numeric: tabular-nums; }
.addr-del {
  border: none; background: none; color: var(--ink-2); cursor: pointer;
  font-size: .875rem; line-height: 1; padding: 4px 6px; border-radius: 6px;
  transition: color var(--t) var(--ease), background var(--t) var(--ease);
}
.addr-del:hover { color: var(--danger); background: var(--danger-soft); }

/* Fahrzeuge */
.vehicle-quickadd { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.vehicle-quickadd input { width: 64px; text-align: center; font-variant-numeric: tabular-nums; }
.vehicle-quickadd span { font-size: .8125rem; color: var(--ink-2); }
.vehicle-list { list-style: none; display: flex; flex-direction: column; gap: 6px; max-height: 340px; overflow-y: auto; }
.vehicle-list li {
  display: flex; align-items: center; gap: 8px;
  border: 1px solid var(--line); border-radius: var(--r-s); padding: 7px 12px;
  background: var(--surface-2);
}
.vehicle-list input.veh-name { flex: 1; border-color: transparent; background: transparent; font-weight: 500; padding: 4px 8px; }
.vehicle-list input.veh-name:hover { border-color: var(--line-strong); background: var(--surface); }
.vehicle-list input.veh-name:focus { background: var(--surface); }
.vehicle-list input.veh-seats { width: 58px; text-align: center; padding: 4px 6px; font-variant-numeric: tabular-nums; }
.seats-suffix { font-size: .75rem; color: var(--ink-2); }
.capacity-summary { font-size: .75rem; color: var(--ink-2); border-top: 1px dashed var(--line-strong); padding-top: 10px; }
.capacity-summary b { font-variant-numeric: tabular-nums; }
.capacity-summary b.ok { color: var(--ok); }
.capacity-summary b.warn { color: var(--danger); }

/* Parameter */
.slider-row { display: flex; align-items: center; gap: 10px; }
.slider-row input[type=range] { flex: 1; }
.slider-label { font-size: .65rem; color: var(--ink-2); text-align: center; line-height: 1.3; }
.slider-value { text-align: center; font-size: .75rem; font-weight: 600; color: var(--brand-strong); }
.checkbox-row { display: flex; align-items: center; gap: 8px; font-size: .8125rem; margin-top: 6px; cursor: pointer; }
.checkbox-row input { width: auto; }

/* ============================== Ergebnis ============================== */
.result-empty { color: var(--ink-2); padding: 48px; text-align: center; }
.result-view { display: flex; flex-direction: column; gap: 16px; height: 100%; min-height: 0; }

.result-summary { display: flex; gap: 12px; flex-wrap: wrap; }
.sum-box {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-m);
  padding: 12px 18px; box-shadow: var(--shadow-sm); min-width: 136px;
}
.sum-box .sum-val {
  font-size: 1.1875rem; font-weight: 700; letter-spacing: -0.01em;
  font-variant-numeric: tabular-nums;
}
.sum-box .sum-key { font-size: .6875rem; font-weight: 500; color: var(--ink-2); margin-top: 2px; }
.sum-box.warn { border-color: var(--danger-line); background: var(--danger-soft); }
.sum-box.warn .sum-val { color: var(--danger); font-size: .9375rem; }
.sum-box.note { border-color: var(--warn-line); background: var(--warn-soft); }
.sum-box.note .sum-val { color: var(--warn); font-size: .9375rem; }

.result-body { display: grid; grid-template-columns: 430px minmax(0, 1fr); gap: 16px; flex: 1; min-height: 380px; }
@media (max-width: 1100px) { .result-body { grid-template-columns: minmax(0, 1fr); } }
.result-routes { overflow-y: auto; display: flex; flex-direction: column; gap: 12px; padding-right: 2px; }

.route-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-m);
  box-shadow: var(--shadow-sm); padding: 14px 16px;
}
.route-card-head { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; flex-wrap: wrap; }
.route-color { width: 11px; height: 11px; border-radius: 3.5px; flex: none; }
.route-card-head b { font-size: .875rem; letter-spacing: -0.005em; }
.route-name {
  width: 110px !important; flex: 0 1 auto;
  font-size: .875rem !important; font-weight: 600;
  border-color: transparent !important; background: transparent !important;
  padding: 3px 6px !important; margin-left: -6px;
}
.route-name:hover { border-color: var(--line-strong) !important; background: var(--surface) !important; }
.route-name:focus { border-color: var(--brand) !important; background: var(--surface) !important; }
.route-vehicle { font-size: .6875rem; color: var(--ink-2); white-space: nowrap; }
.route-stats { margin-left: auto; font-size: .75rem; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.route-load {
  font-size: .6875rem; font-weight: 600; padding: 2px 9px; border-radius: 99px;
  background: var(--bg); border: 1px solid var(--line); color: var(--ink-2);
  font-variant-numeric: tabular-nums;
}
.route-load.full { background: var(--warn-soft); border-color: var(--warn-line); color: var(--warn); }
.route-load.warn { background: var(--danger-soft); border-color: var(--danger-line); color: var(--danger); }

/* Stoppliste mit verbindender Routenlinie */
.route-stops { --line-x: 10px; list-style: none; display: flex; flex-direction: column; position: relative; }
.route-stops::before {
  content: ''; position: absolute; left: var(--line-x); top: 12px; bottom: 12px;
  width: 2px; border-radius: 1px; background: var(--line);
}
/* Mit Tourenzeitplan: Zeitspalte vor den Stoppnummern */
.route-stops.with-times { --line-x: 63px; }
.stop-time {
  min-width: 41px; text-align: right; flex: none;
  font-size: .75rem; font-weight: 600; color: var(--brand-strong);
  font-variant-numeric: tabular-nums;
}
.route-stops li { display: flex; gap: 12px; align-items: center; padding: 3.5px 0; font-size: .8125rem; position: relative; }
.stop-num {
  position: relative;
  min-width: 22px; height: 22px; border-radius: 50%;
  color: #fff; font-size: .6875rem; font-weight: 700;
  display: inline-flex; align-items: center; justify-content: center;
  box-shadow: 0 0 0 3px var(--surface);
  font-variant-numeric: tabular-nums;
}
.stop-num.terminal { background: var(--sidebar) !important; border-radius: 7px; }
.route-stops li > span:nth-child(2) { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stop-persons { margin-left: auto; font-size: .6875rem; color: var(--ink-2); white-space: nowrap; font-variant-numeric: tabular-nums; }
.stop-name { color: var(--ink-2); }

/* Manuelles Verschieben */
.route-stops li[draggable] { cursor: grab; border-radius: 6px; }
.route-stops li[draggable]:hover { background: var(--surface-2); }
.route-stops li.dragging { opacity: .45; cursor: grabbing; }
.route-stops li.drop-before { box-shadow: 0 -2px 0 0 var(--brand); }
.route-stops li.drop-end { box-shadow: 0 2px 0 0 var(--brand); }
.stop-tools { display: inline-flex; gap: 3px; margin-left: 8px; flex: none; visibility: hidden; }
.route-stops li:hover .stop-tools { visibility: visible; }
.stop-mv {
  width: 20px; height: 20px; border: 1px solid var(--line); border-radius: 5px;
  background: var(--surface); color: var(--ink-2); font-size: .6875rem; line-height: 1;
  cursor: pointer; display: inline-flex; align-items: center; justify-content: center;
  transition: background var(--t) var(--ease), color var(--t) var(--ease);
}
.stop-mv:hover { background: var(--brand-soft); color: var(--brand-strong); border-color: transparent; }
.route-card.drag-over { border-color: var(--brand); box-shadow: 0 0 0 2px var(--brand-soft); }
.drop-hint { display: none; font-size: .75rem; color: var(--ink-2); padding: 8px 2px 2px; }
#resultRoutes.dnd-active .drop-hint { display: block; }

.result-map-wrap {
  min-height: 380px; border-radius: var(--r-m); overflow: hidden;
  border: 1px solid var(--line); box-shadow: var(--shadow-sm);
}
#map { width: 100%; height: 100%; min-height: 380px; background: var(--bg); }
.result-actions { display: flex; gap: 10px; flex-wrap: wrap; }

/* Kartenmarker */
.map-marker {
  display: flex; align-items: center; justify-content: center;
  width: 26px; height: 26px; border-radius: 50%;
  color: #fff; font-weight: 700; font-size: .75rem;
  border: 2px solid #fff; box-shadow: 0 1px 4px oklch(20% 0.02 235 / .45);
  font-variant-numeric: tabular-nums;
}
.map-marker.terminal { border-radius: 8px; background: var(--sidebar); }
.leaflet-container { font-family: inherit; }

/* ============================== Touren-Liste ============================== */
.tour-list { list-style: none; display: flex; flex-direction: column; gap: 10px; max-width: 780px; }
.tour-list li {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-m);
  box-shadow: var(--shadow-sm); padding: 14px 18px;
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  transition: border-color var(--t) var(--ease);
}
.tour-list li:hover { border-color: var(--line-strong); }
.tour-info { flex: 1; min-width: 200px; }
.tour-info b { font-size: .875rem; letter-spacing: -0.005em; }
.tour-info .tour-meta { font-size: .75rem; color: var(--ink-2); margin-top: 2px; font-variant-numeric: tabular-nums; }

/* ============================== Login ============================== */
.login-screen {
  position: fixed; inset: 0; z-index: var(--z-login);
  background:
    radial-gradient(1200px 600px at 80% -10%, oklch(30% 0.05 220 / .8), transparent 60%),
    var(--sidebar);
  display: flex; align-items: center; justify-content: center; padding: 24px;
}
.login-card {
  background: var(--surface); border-radius: var(--r-l); box-shadow: var(--shadow-lg);
  padding: 36px 40px; width: min(400px, 94vw);
  display: flex; flex-direction: column; gap: 10px;
  animation: rise 300ms var(--ease) both;
}
.login-brand {
  display: flex; align-items: center; justify-content: center; gap: 12px;
  font-size: 1.1875rem; font-weight: 700; letter-spacing: -0.01em;
  padding-bottom: 4px;
}
.login-card h2 {
  text-align: center; font-size: .8125rem; font-weight: 500;
  color: var(--ink-2); margin-bottom: 10px;
}
.login-card .btn-big { margin-top: 10px; }
.login-error {
  background: var(--danger-soft); border: 1px solid var(--danger-line); color: var(--danger);
  border-radius: var(--r-s); padding: 8px 12px; font-size: .75rem; font-weight: 500;
}

/* ============================== Dialog ============================== */
dialog {
  margin: auto; /* Reset überschreibt die UA-Zentrierung – hier wiederherstellen */
  border: none; border-radius: var(--r-l); box-shadow: var(--shadow-lg);
  padding: 0; width: min(540px, 92vw);
  color: var(--ink);
}
dialog::backdrop { background: oklch(20% 0.02 235 / .5); }
dialog[open] { animation: rise 240ms var(--ease) both; }
.dialog-inner { padding: 28px; display: flex; flex-direction: column; gap: 10px; }
.dialog-inner h3 { font-size: 1.0625rem; letter-spacing: -0.01em; margin-bottom: 4px; }
.dialog-inner h4 { margin-top: 12px; font-size: .75rem; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-2); }
.hint { font-size: .75rem; color: var(--ink-2); line-height: 1.55; }
.hint code { font-size: .6875rem; background: var(--bg); border: 1px solid var(--line); border-radius: 4px; padding: 1px 5px; }
.dialog-row { display: flex; gap: 8px; flex-wrap: wrap; }
.check-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 2px 16px; }
.check-grid .checkbox-row { margin-top: 0; }
.dialog-buttons { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }

/* ============================== Overlay & Toast ============================== */
.overlay {
  position: fixed; inset: 0; z-index: var(--z-busy);
  background: oklch(20% 0.02 235 / .45);
  display: flex; align-items: center; justify-content: center;
  animation: fade 200ms var(--ease) both;
}
.overlay-card {
  background: var(--surface); border-radius: var(--r-l); padding: 30px 40px;
  display: flex; flex-direction: column; align-items: center; gap: 16px;
  box-shadow: var(--shadow-lg); text-align: center;
}
.spinner {
  width: 32px; height: 32px; border-radius: 50%;
  border: 3px solid var(--brand-soft); border-top-color: var(--brand);
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.overlay-text { font-size: .8125rem; font-weight: 600; white-space: pre-line; }

.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  z-index: var(--z-toast);
  background: var(--sidebar); color: var(--sidebar-ink);
  padding: 11px 20px; border-radius: 10px;
  font-size: .8125rem; font-weight: 500;
  box-shadow: var(--shadow-lg);
  max-width: 82vw;
  animation: toast-in 240ms var(--ease) both;
}
.toast.error { background: var(--danger); color: #fff; }

@keyframes rise { from { opacity: 0; transform: translateY(8px); } }
@keyframes fade { from { opacity: 0; } }
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 8px); } to { opacity: 1; transform: translate(-50%, 0); } }

/* ============================== Mobil ============================== */
@media (max-width: 860px) {
  body { flex-direction: column; }
  .sidebar {
    width: 100%; min-width: 0; height: auto; position: static;
  }
  .sidebar-section { padding: 10px 12px; }
  .project-list { flex-direction: row; flex-wrap: wrap; gap: 6px; }
  .project-list li { padding: 7px 12px; }
  .project-list .meta { display: none; }
  .sidebar-footer { flex-direction: row; flex-wrap: wrap; align-items: center; }
  .user-row { padding: 0; }
  .main { height: auto; overflow: visible; }
  .tab-panel { padding: 16px; overflow: visible; }
  .project-header { padding: 10px 16px; flex-wrap: wrap; }
  .tabs { order: 3; width: 100%; margin-left: 0; border-top: 1px solid var(--line); padding-top: 4px; }
  .tab { padding: 10px 12px; }
  .tab::after { bottom: 0; }
}

/* ============================== Reduzierte Bewegung ============================== */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
  .spinner { animation-duration: .8s !important; animation-iteration-count: infinite !important; }
}

/* ============================== Druckbogen ============================== */
#printSheet { display: none; font-size: 11pt; color: #111; }
#printSheet h1 { font-size: 15pt; letter-spacing: -0.01em; margin-bottom: 1.5mm; }
#printSheet .print-meta { font-size: 9pt; color: #444; margin-bottom: 7mm; }
#printSheet .print-route { break-inside: avoid; margin-bottom: 8mm; }
#printSheet h2 { font-size: 11.5pt; margin-bottom: 2mm; display: flex; align-items: center; gap: 6px; }
#printSheet .print-dot { width: 9px; height: 9px; border-radius: 3px; display: inline-block; }
#printSheet table { width: 100%; border-collapse: collapse; }
#printSheet th {
  text-align: left; font-size: 8pt; font-weight: 600; text-transform: uppercase;
  letter-spacing: .05em; color: #555; border-bottom: 1pt solid #999; padding: 1.5mm 2mm;
}
#printSheet td { padding: 1.7mm 2mm; border-bottom: 0.5pt solid #ccc; vertical-align: top; }
#printSheet .c-nr { width: 9mm; color: #666; }
#printSheet td.c-time, #printSheet th.c-time { width: 17mm; }
#printSheet td.c-time { font-weight: 600; font-variant-numeric: tabular-nums; }
#printSheet td.c-pers, #printSheet th.c-persons { width: 12mm; text-align: right; }
#printSheet tr.terminal td { font-weight: 600; background: #f2f2f2; }

/* ============================== Druck ============================== */
@media print {
  .sidebar, .project-header .tabs, .btn, .result-map-wrap, .result-actions,
  .provider-badge, .login-screen { display: none !important; }
  body { background: #fff; }
  .main { height: auto; overflow: visible; }
  .tab-panel { overflow: visible; }
  .result-body { grid-template-columns: 1fr; }
  .route-card, .sum-box { break-inside: avoid; box-shadow: none; }
  .stop-num { box-shadow: none; }

  /* Gefilterter Druck über den Druckbogen: nur den Bogen ausgeben */
  body.print-mode .sidebar, body.print-mode .main, body.print-mode dialog,
  body.print-mode .overlay, body.print-mode .toast, body.print-mode .login-screen {
    display: none !important;
  }
  body.print-mode #printSheet { display: block; }
}
