:root {
  --navy: #0f2942;
  --navy-light: #1b436b;
  --emerald: #10b981;
  --emerald-dark: #059669;
  --blue: #257fe0;
  --bg: #f3f6fa;
  --card: #ffffff;
  --border: #dfe6ef;
  --text: #0f172a;
  --muted: #64748b;
  --warn-bg: #fff7ed;
  --warn-border: #fdba74;
  --warn-text: #9a3412;
  --radius: 16px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.45;
}

.hidden {
  display: none !important;
}

/* Topbar */
.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 28px;
  background: linear-gradient(135deg, var(--navy), var(--navy-light));
  color: #fff;
  box-shadow: 0 4px 18px rgba(15, 41, 66, 0.16);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  width: 40px;
  height: 40px;
  border-radius: 11px;
  background: rgba(255, 255, 255, 0.12);
  border: 1.5px solid rgba(16, 185, 129, 0.7);
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 20px;
  color: var(--emerald);
}

.brand h1 {
  margin: 0;
  font-size: 18px;
  letter-spacing: -0.01em;
}

.brand-sub {
  margin: 0;
  font-size: 12px;
  color: rgba(255, 255, 255, 0.74);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

/* Buttons & Badges */
.btn {
  border: 0;
  border-radius: 10px;
  padding: 9px 14px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.08s ease, opacity 0.15s ease, background 0.15s ease;
}

.btn:active {
  transform: scale(0.98);
}

.btn-primary {
  background: var(--emerald);
  color: #fff;
}

.btn-primary:hover {
  background: var(--emerald-dark);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
}

.panel .btn-secondary,
.auth-card .btn-secondary {
  background: #e9eff6;
  color: var(--navy);
}

.btn-ghost {
  background: transparent;
  color: rgba(255, 255, 255, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.28);
}

.btn-sm {
  padding: 6px 11px;
  font-size: 12px;
}

.btn-lg {
  padding: 12px 20px;
  font-size: 14px;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 11px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}

.badge-ok {
  background: rgba(16, 185, 129, 0.22);
  color: #a7f3d0;
}

.badge-demo {
  background: rgba(251, 146, 60, 0.24);
  color: #fed7aa;
}

.badge-muted {
  background: rgba(255, 255, 255, 0.14);
  color: rgba(255, 255, 255, 0.85);
}

.panel .badge-muted {
  background: rgba(16, 185, 129, 0.14);
  color: var(--emerald-dark);
}

/* Auth Screen */
.auth-screen {
  max-width: 780px;
  margin: 44px auto;
  padding: 0 20px;
}

.auth-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 22px;
  padding: 36px;
  box-shadow: 0 14px 36px rgba(15, 41, 66, 0.08);
  text-align: center;
}

.auth-icon {
  width: 64px;
  height: 64px;
  margin: 0 auto 16px;
  border-radius: 18px;
  background: linear-gradient(135deg, var(--navy), var(--navy-light));
  color: var(--emerald);
  display: grid;
  place-items: center;
  font-size: 32px;
  font-weight: 800;
}

.auth-card h2 {
  margin: 0 0 10px;
  font-size: 26px;
  color: var(--navy);
}

.auth-lead {
  color: var(--muted);
  max-width: 600px;
  margin: 0 auto 22px;
  font-size: 15px;
}

.auth-cta-row {
  display: flex;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
  margin: 22px 0 28px;
}

.callout {
  text-align: left;
  padding: 14px 16px;
  border-radius: 12px;
  font-size: 13px;
  margin: 16px 0;
}

.callout-warn {
  background: var(--warn-bg);
  border: 1px solid var(--warn-border);
  color: var(--warn-text);
}

.callout-error {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #991b1b;
}

.inline-token-form {
  display: flex;
  gap: 8px;
  margin-top: 10px;
  flex-wrap: wrap;
}

.inline-token-form input,
.inline-token-form select {
  flex: 1 1 220px;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--warn-border);
  background: #fff;
  font-size: 13px;
}

.privacy-grid {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 12px;
  text-align: left;
}

.privacy-grid li {
  background: var(--bg);
  border-radius: 12px;
  padding: 14px;
}

.privacy-grid strong {
  display: block;
  color: var(--navy);
  font-size: 13px;
  margin-bottom: 4px;
}

.privacy-grid span {
  font-size: 12px;
  color: var(--muted);
}

/* Dashboard */
.dashboard {
  max-width: 1440px;
  margin: 0 auto;
  padding: 20px 24px 40px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.filter-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.segmented {
  display: inline-flex;
  background: #e2e8f0;
  padding: 3px;
  border-radius: 10px;
}

.seg-btn {
  border: 0;
  background: transparent;
  padding: 7px 13px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
}

.seg-btn.active {
  background: #fff;
  color: var(--navy);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
}

.select-input,
.text-input,
textarea,
.field input {
  padding: 9px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #fff;
  font-size: 13px;
  color: var(--text);
  font-family: inherit;
}

.text-input {
  flex: 1 1 220px;
}

.checkbox-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 12px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
}

/* KPI Grid */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(180px, 1fr));
  gap: 14px;
}

.kpi-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.kpi-card.clickable {
  cursor: pointer;
}

.kpi-card.clickable:hover {
  border-color: var(--emerald);
}

.kpi-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
}

.kpi-value {
  font-size: 26px;
  font-variant-numeric: tabular-nums;
  color: var(--navy);
}

.kpi-value.accent {
  color: var(--emerald-dark);
}

.kpi-value.warn {
  color: #d97706;
}

.kpi-sub {
  font-size: 12px;
  color: var(--muted);
}

/* Panels */
.panel {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.panel-header h2 {
  margin: 0;
  font-size: 16px;
  color: var(--navy);
}

.muted {
  color: var(--muted);
  font-size: 12px;
}

/* Map */
.overview-map {
  width: 100%;
  height: 370px;
  border-radius: 12px;
  border: 1px solid var(--border);
  z-index: 1;
}

.map-controls {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.legend {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  color: var(--muted);
  font-weight: 600;
}

.dot {
  width: 9px;
  height: 9px;
  border-radius: 999px;
  display: inline-block;
}

.dot-dienstlich { background: var(--emerald); }
.dot-arbeitsweg { background: var(--blue); }
.dot-privat { background: #64748b; }

/* Split View */
.split-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(340px, 0.95fr);
  gap: 18px;
  align-items: start;
}

.table-wrap {
  overflow-x: auto;
  max-height: 540px;
  overflow-y: auto;
}

.trips-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.trips-table th {
  position: sticky;
  top: 0;
  background: #f8fafc;
  text-align: left;
  padding: 10px 10px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
}

.trips-table td {
  padding: 10px 10px;
  border-bottom: 1px solid #eef2f7;
  vertical-align: top;
}

.trips-table tbody tr {
  cursor: pointer;
  transition: background 0.12s ease;
}

.trips-table tbody tr:hover {
  background: #f8fafc;
}

.trips-table tbody tr.selected {
  background: rgba(16, 185, 129, 0.11);
}

.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.cat-pill {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
}

.cat-Dienstlich { background: rgba(16, 185, 129, 0.16); color: #047857; }
.cat-Arbeitsweg { background: rgba(37, 127, 224, 0.15); color: #1d4ed8; }
.cat-Privat { background: #e2e8f0; color: #475569; }

.missing-tag {
  color: #d97706;
  font-weight: 600;
  font-size: 12px;
}

/* Detail Form */
.empty-state {
  color: var(--muted);
  font-size: 13px;
  padding: 28px 8px;
  text-align: center;
}

.detail-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.meta-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  background: var(--bg);
  padding: 12px;
  border-radius: 12px;
}

.meta-grid span {
  display: block;
  font-size: 11px;
  color: var(--muted);
}

.meta-grid strong {
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.field span {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
}

.form-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.audit-box {
  border-top: 1px solid var(--border);
  padding-top: 12px;
}

.audit-box h3 {
  margin: 0 0 8px;
  font-size: 13px;
  color: var(--navy);
}

.audit-box ul {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.audit-box li {
  background: var(--bg);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 12px;
}

/* Print / Finanzamt A4 PDF */
.print-only {
  display: none;
}

@media (max-width: 1024px) {
  .kpi-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .split-layout {
    grid-template-columns: 1fr;
  }
}

@media print {
  body {
    background: #fff;
  }
  .no-print {
    display: none !important;
  }
  .dashboard {
    padding: 0;
    max-width: none;
  }
  .print-only {
    display: block !important;
    font-size: 10pt;
    color: #111;
  }
  .print-header {
    background: #0f2942;
    color: #fff;
    padding: 14px 18px;
    border-left: 6px solid #10b981;
    border-radius: 6px;
    margin-bottom: 12px;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
  .print-meta {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    background: #f4f7fa;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    padding: 10px 12px;
    margin-bottom: 14px;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
  .print-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 8.5pt;
    margin-bottom: 16px;
  }
  .print-table th {
    background: #0f2942;
    color: #fff;
    padding: 6px;
    text-align: left;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
  .print-table td {
    border-bottom: 1px solid #d5dde7;
    padding: 5px 6px;
    vertical-align: top;
  }
  .print-sig {
    display: flex;
    justify-content: space-between;
    margin-top: 34px;
  }
  .print-sig div {
    width: 42%;
    border-top: 1px solid #334155;
    padding-top: 4px;
    font-size: 8.5pt;
  }
}

/* FahrtTreu Team / Fuhrpark-Portal */
.btn-navy {
  background: var(--navy);
  color: #ffffff;
}

.btn-navy:hover {
  background: #1b436b;
}

.team-login-box {
  margin-top: 24px;
  padding: 20px;
  border-radius: 14px;
  border: 1px solid #cbd5e1;
  background: #f8fafc;
  text-align: left;
}

.team-login-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 6px;
}

.team-login-sub {
  margin: 0 0 14px;
  font-size: 13px;
  color: var(--muted);
  line-height: 1.5;
}

.team-login-form {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.team-login-form input {
  flex: 1;
  min-width: 220px;
  padding: 10px 14px;
  border-radius: 10px;
  border: 1px solid #cbd5e1;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.team-panel .panel-header {
  flex-wrap: wrap;
}

.team-add-form {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.team-add-form input {
  padding: 8px 12px;
  border-radius: 9px;
  border: 1px solid var(--border);
  font-size: 13px;
}

.team-feedback {
  margin-bottom: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 13px;
  background: #ecfdf5;
  color: #065f46;
  border: 1px solid #a7f3d0;
}

.team-feedback.error {
  background: #fef2f2;
  color: #991b1b;
  border-color: #fecaca;
}

.code-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 13px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 8px;
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
  color: var(--navy);
}

.driver-tag {
  display: inline-block;
  margin-top: 3px;
  font-size: 11px;
  font-weight: 600;
  color: #0f2942;
  background: #e2e8f0;
  padding: 1px 6px;
  border-radius: 999px;
}
