/* Selta Med – Enterprise UI
   Ruhiges, geschäftliches Design: gedeckte Farben, dezente Schatten,
   klare Typografie, SVG-Icons statt Emojis. */
:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-2: #f9fafb;
  --border: #e5e7eb;
  --border-strong: #d1d5db;
  --text: #111827;
  --text-2: #4b5563;
  --muted: #9ca3af;
  --brand: #2563eb;
  --brand-700: #1d4ed8;
  --danger: #dc2626;
  --ok: #16a34a;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, .05);
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .1);
  --shadow-lg: 0 10px 15px -3px rgba(16, 24, 40, .08), 0 4px 6px -4px rgba(16, 24, 40, .05);
  --radius: 10px;
  --radius-sm: 8px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica,
    Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--brand); text-decoration: none; }
svg { display: block; }

/* ------------------------------- Topbar -------------------------------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  height: 56px;
  padding: 0 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.topbar .brand { display: flex; align-items: center; gap: 11px; }
.brand .logo {
  width: 32px; height: 32px;
  border-radius: 8px;
  background: var(--brand);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
}
.brand .logo svg { width: 18px; height: 18px; }
.brand .titles { display: flex; flex-direction: column; line-height: 1.15; }
.brand .name { font-weight: 600; font-size: 15px; letter-spacing: -.01em; }
.brand .sub { color: var(--muted); font-size: 12px; }
.topbar .right { display: flex; align-items: center; gap: 14px; }

.toolbar-toggle {
  display: flex; align-items: center; gap: 7px;
  font-size: 13px; color: var(--text-2); cursor: pointer; user-select: none;
}

/* Verbindungsanzeige */
.conn {
  display: inline-flex; align-items: center; gap: 7px;
  font-size: 12.5px; color: var(--text-2);
  padding: 5px 10px; border: 1px solid var(--border);
  border-radius: 999px; background: var(--surface-2);
}
.conn .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); }
.conn.online .dot { background: var(--ok); }
.conn.offline .dot { background: var(--danger); }

/* ------------------------------- Buttons ------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 8px 14px;
  font-size: 13.5px; font-weight: 600;
  cursor: pointer;
  background: var(--brand); color: #fff;
  transition: background .12s ease, border-color .12s ease, box-shadow .12s ease;
  white-space: nowrap;
}
.btn:hover { background: var(--brand-700); }
.btn:active { transform: translateY(.5px); }
.btn svg { width: 15px; height: 15px; }
.btn.secondary { background: var(--surface); color: var(--text); border-color: var(--border-strong); }
.btn.secondary:hover { background: var(--surface-2); }
.btn.danger { background: var(--surface); color: var(--danger); border-color: #fecaca; }
.btn.danger:hover { background: #fef2f2; }
.btn.danger-solid { background: var(--danger); color: #fff; }
.btn.danger-solid:hover { background: #b91c1c; }
.btn.block { width: 100%; }
.btn.sm { padding: 6px 10px; font-size: 12.5px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* -------------------------------- Badge -------------------------------- */
.badge {
  --c: #64748b;
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 9px 3px 8px;
  border-radius: 6px;
  font-size: 12px; font-weight: 600;
  background: #f1f5f9;
  color: var(--c);
  background: color-mix(in srgb, var(--c) 11%, white);
  border: 1px solid color-mix(in srgb, var(--c) 22%, white);
}
.badge::before {
  content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--c);
}

/* ------------------------ Dashboard / Zentrale ------------------------- */
.layout { display: grid; grid-template-columns: 372px 1fr; height: calc(100vh - 56px); }
.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  padding: 14px;
}
.sidebar-head {
  display: flex; align-items: center; justify-content: space-between;
  margin: 2px 2px 12px;
}
.sidebar-head h2 {
  margin: 0; font-size: 12px; font-weight: 600; letter-spacing: .04em;
  text-transform: uppercase; color: var(--muted);
}
#map { height: 100%; width: 100%; background: #e8eaed; }

.trip-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 13px;
  margin-bottom: 10px;
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: border-color .12s ease, box-shadow .12s ease;
}
.trip-card:hover { border-color: var(--border-strong); box-shadow: var(--shadow); }
.trip-card .row {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 10px;
}
.trip-card .ident { display: flex; align-items: center; gap: 11px; min-width: 0; }
.veh-chip {
  width: 34px; height: 34px; flex: 0 0 34px;
  border-radius: 8px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-2);
  display: flex; align-items: center; justify-content: center;
}
.veh-chip svg { width: 19px; height: 19px; }
.trip-card .label { font-weight: 600; font-size: 14px; line-height: 1.2; }
.trip-card .code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  letter-spacing: .5px; font-size: 11.5px; color: var(--muted); margin-top: 2px;
}
.trip-card .meta {
  color: var(--text-2); font-size: 12.5px; margin-top: 9px;
  display: flex; align-items: center; gap: 6px;
}
.trip-card .meta svg { width: 13px; height: 13px; color: var(--muted); }
.trip-card .seen { font-size: 12px; margin-top: 7px; display: flex; align-items: center; gap: 6px; }
.trip-card .seen .ind { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); }
.trip-card .seen.live { color: var(--ok); }
.trip-card .seen.live .ind { background: var(--ok); }
.trip-card .seen.stale { color: var(--muted); }
.trip-card .actions { display: flex; gap: 7px; margin-top: 11px; }

.empty {
  text-align: center; color: var(--muted); padding: 48px 14px; font-size: 13px;
  line-height: 1.6;
}

/* -------------------------------- Modal -------------------------------- */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(17, 24, 39, .45);
  display: none; align-items: center; justify-content: center;
  padding: 16px; z-index: 1000;
}
.modal-backdrop.open { display: flex; }
.modal {
  background: var(--surface);
  border-radius: 14px;
  width: 100%; max-width: 440px;
  box-shadow: var(--shadow-lg);
  max-height: 92vh; overflow-y: auto;
}
.modal-head { padding: 18px 22px; border-bottom: 1px solid var(--border); }
.modal-head h3 { margin: 0; font-size: 16px; font-weight: 600; }
.modal-head p { margin: 4px 0 0; color: var(--muted); font-size: 13px; }
.modal-body { padding: 18px 22px; }
.field { margin-bottom: 14px; }
.field:last-child { margin-bottom: 0; }
.field label {
  display: block; font-size: 12.5px; font-weight: 600; margin-bottom: 6px; color: var(--text-2);
}
.field input, .field select, .field textarea {
  width: 100%; padding: 9px 11px;
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  font-size: 14px; font-family: inherit; color: var(--text); background: var(--surface);
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none; border-color: var(--brand);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 15%, white);
}
.field textarea { resize: vertical; min-height: 58px; }
.modal-foot {
  display: flex; gap: 10px; padding: 16px 22px; border-top: 1px solid var(--border);
  background: var(--surface-2); border-radius: 0 0 14px 14px;
}

/* Segmentierte Auswahl (Fahrzeugtyp) */
.seg { display: flex; gap: 8px; }
.seg label {
  flex: 1; display: flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  padding: 11px; cursor: pointer; font-weight: 600; font-size: 13.5px; color: var(--text-2);
}
.seg label svg { width: 18px; height: 18px; }
.seg input { display: none; }
.seg label:has(input:checked) {
  border-color: var(--brand); color: var(--brand);
  background: color-mix(in srgb, var(--brand) 7%, white);
}

/* ----------------------------- QR / Share ----------------------------- */
.share { text-align: center; }
.share .qr-wrap {
  display: inline-flex; padding: 12px; background: #fff;
  border: 1px solid var(--border); border-radius: 12px;
}
.share img { width: 208px; height: 208px; display: block; }
.share .code-big {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 30px; letter-spacing: 5px; font-weight: 700; margin: 16px 0 4px;
}
.share .hint { color: var(--muted); font-size: 12.5px; }
.share .link {
  word-break: break-all; font-size: 12.5px; color: var(--text-2);
  background: var(--surface-2); border: 1px solid var(--border);
  padding: 10px; border-radius: var(--radius-sm); margin: 12px 0; text-align: left;
}

/* -------------------------------- Fahrer ------------------------------- */
.driver-wrap { max-width: 560px; margin: 0 auto; padding: 18px 16px 36px; }
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-sm);
  padding: 18px; margin-bottom: 14px;
}
.card-title {
  font-size: 12px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase;
  color: var(--muted); margin: 0 0 12px;
}
.trip-head { display: flex; align-items: center; gap: 13px; }
.trip-head .veh-chip { width: 46px; height: 46px; flex-basis: 46px; border-radius: 10px; }
.trip-head .veh-chip svg { width: 26px; height: 26px; }
.trip-head .label { font-size: 18px; font-weight: 700; line-height: 1.2; }
.trip-head .code {
  font-family: ui-monospace, monospace; color: var(--muted);
  letter-spacing: 1px; font-size: 13px; margin-top: 3px;
}
.route { margin-top: 16px; display: flex; flex-direction: column; gap: 2px; }
.route .leg { display: flex; gap: 11px; align-items: flex-start; padding: 5px 0; font-size: 14px; }
.route .leg .ic {
  width: 9px; height: 9px; border-radius: 50%; margin-top: 5px; flex: 0 0 9px;
  border: 2px solid var(--border-strong);
}
.route .leg.from .ic { background: var(--ok); border-color: var(--ok); }
.route .leg.via .ic { background: #2563eb; border-color: #2563eb; }
.route .leg.to .ic { background: var(--danger); border-color: var(--danger); }
.route .leg.note .ic { border: none; width: 16px; height: 16px; margin-top: 0; color: var(--muted); }
.route .leg .lbl { color: var(--text-2); }
.route .leg .lbl b { color: var(--text); font-weight: 600; }

.status-now { display: flex; align-items: center; gap: 10px; margin-bottom: 4px; }
.status-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; margin-top: 14px; }
.status-btn {
  --c: #64748b;
  border: 1px solid var(--border-strong); background: var(--surface);
  border-radius: var(--radius-sm); padding: 14px 10px;
  font-size: 13.5px; font-weight: 600; color: var(--text); cursor: pointer;
  display: flex; align-items: center; gap: 9px; text-align: left;
  transition: border-color .1s ease, background .1s ease;
}
.status-btn .swatch { width: 9px; height: 9px; border-radius: 50%; background: var(--c); flex: 0 0 9px; }
.status-btn:hover { border-color: var(--border-strong); background: var(--surface-2); }
.status-btn.active {
  color: var(--c); border-color: var(--c);
  background: color-mix(in srgb, var(--c) 9%, white);
}

.gps-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.gps-state { display: flex; align-items: center; gap: 10px; font-weight: 600; }
.pulse { width: 9px; height: 9px; border-radius: 50%; background: var(--muted); flex: 0 0 9px; }
.pulse.on { background: var(--ok); box-shadow: 0 0 0 0 rgba(22, 163, 74, .5); animation: pulse 1.8s infinite; }
.pulse.err { background: var(--danger); }
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(22, 163, 74, .45); }
  70% { box-shadow: 0 0 0 8px rgba(22, 163, 74, 0); }
  100% { box-shadow: 0 0 0 0 rgba(22, 163, 74, 0); }
}
.hint { color: var(--muted); font-size: 12.5px; margin-top: 11px; line-height: 1.55; }

.toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%);
  background: var(--text); color: #fff; padding: 11px 16px;
  border-radius: var(--radius-sm); font-size: 13.5px; box-shadow: var(--shadow-lg);
  opacity: 0; pointer-events: none; transition: opacity .2s ease; z-index: 2000;
}
.toast.show { opacity: 1; }

/* --------------------------- Zentrierte Seiten ------------------------- */
.center-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.center-box {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 14px; box-shadow: var(--shadow); padding: 32px; width: 100%; max-width: 400px;
}
.center-box .logo {
  width: 44px; height: 44px; border-radius: 10px; background: var(--brand); color: #fff;
  display: flex; align-items: center; justify-content: center; margin: 0 auto 16px;
}
.center-box .logo svg { width: 24px; height: 24px; }
.center-box h1 { font-size: 19px; margin: 0 0 6px; text-align: center; }
.center-box p { color: var(--text-2); margin: 0 0 20px; text-align: center; font-size: 13.5px; line-height: 1.5; }
.center-box .code-input {
  width: 100%; text-align: center;
  font-family: ui-monospace, monospace; font-size: 26px; letter-spacing: 7px;
  text-transform: uppercase; padding: 13px;
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm); margin-bottom: 14px;
}
.center-box .code-input:focus {
  outline: none; border-color: var(--brand);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 15%, white);
}
.center-box .foot { margin-top: 18px; font-size: 12.5px; color: var(--muted); text-align: center; }

/* ------------------------------- Landing ------------------------------- */
.choice { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin: 22px 0 8px; }
.choice a {
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  text-align: center; text-decoration: none;
  border: 1px solid var(--border-strong); border-radius: 14px;
  padding: 26px 18px; color: var(--text);
  transition: border-color .12s ease, box-shadow .12s ease, transform .05s ease;
}
.choice a:hover { border-color: var(--brand); box-shadow: var(--shadow); }
.choice a:active { transform: translateY(1px); }
.choice .ic {
  width: 52px; height: 52px; border-radius: 12px; display: flex;
  align-items: center; justify-content: center; background: var(--surface-2); color: var(--brand);
}
.choice .ic svg { width: 28px; height: 28px; }
.choice .t { font-weight: 700; font-size: 15px; }
.choice .s { font-size: 12.5px; color: var(--muted); }

.footer-links {
  display: flex; gap: 16px; justify-content: center; flex-wrap: wrap;
  margin-top: 22px; font-size: 12.5px;
}
.footer-links a { color: var(--muted); }
.footer-links a:hover { color: var(--text-2); }

/* ----------------------------- Rechtsseiten ---------------------------- */
.page { max-width: 760px; margin: 0 auto; padding: 28px 18px 60px; }
.page h1 { font-size: 22px; margin: 0 0 6px; }
.page h2 { font-size: 16px; margin: 26px 0 8px; }
.page p, .page li { color: var(--text-2); line-height: 1.6; font-size: 14px; }
.page .muted { color: var(--muted); }
.page .back { display: inline-block; margin-bottom: 18px; font-size: 13px; }
.page .todo {
  background: #fffbeb; border: 1px solid #fde68a; color: #92400e;
  padding: 12px 14px; border-radius: 10px; font-size: 13px; margin: 12px 0;
}

@media (max-width: 520px) { .choice { grid-template-columns: 1fr; } }

/* Leaflet-Marker */
.veh-marker .pin {
  --c: #64748b;
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--c); border: 2px solid #fff; color: #fff;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 1px 4px rgba(16, 24, 40, .35);
}
.veh-marker .pin svg { width: 16px; height: 16px; }
.veh-marker .pin.stale { opacity: .45; filter: grayscale(.4); }

@media (max-width: 760px) {
  .layout { grid-template-columns: 1fr; height: auto; }
  #map { height: 52vh; order: -1; }
  .sidebar { height: auto; }
  .topbar .right .hide-sm { display: none; }
}
