/* ── Reset & Base ─────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:         #0f1117;
  --surface:    #1a1d27;
  --surface2:   #222536;
  --border:     #2e3148;
  --accent:     #3b82f6;
  --accent-h:   #2563eb;
  --green:      #22c55e;
  --red:        #ef4444;
  --yellow:     #f59e0b;
  --text:       #e2e8f0;
  --text-muted: #64748b;
  --radius:     8px;
  --shadow:     0 4px 24px rgba(0,0,0,.45);
  font-size: 15px;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  line-height: 1.6;
  min-height: 100vh;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

code {
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 0.85em;
  background: var(--surface2);
  padding: 1px 6px;
  border-radius: 4px;
}

/* ── Navbar ───────────────────────────────────────────────── */
.navbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .75rem 2rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}

.brand {
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -.02em;
  color: var(--text);
}
.brand:hover { text-decoration: none; }

.nav-links {
  display: flex;
  align-items: center;
  gap: 1.25rem;
}

.nav-links a { color: var(--text-muted); font-size: .9rem; }
.nav-links a:hover { color: var(--text); text-decoration: none; }
.nav-links .nav-admin { color: var(--yellow); }
.nav-links .nav-admin:hover { color: #fcd34d; }

/* ── Buttons ──────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  padding: .45rem 1rem;
  border-radius: var(--radius);
  border: none;
  font-size: .875rem;
  font-weight: 500;
  cursor: pointer;
  transition: background .15s, opacity .15s;
  text-decoration: none;
}
.btn:hover { opacity: .9; text-decoration: none; }

.btn-primary  { background: var(--accent);  color: #fff; }
.btn-primary:hover { background: var(--accent-h); }

.btn-sm { padding: .3rem .7rem; font-size: .8rem; }

.btn-warn   { background: var(--yellow); color: #000; }
.btn-danger { background: var(--red);   color: #fff; }

.btn-link {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: .9rem;
  cursor: pointer;
  padding: 0;
}
.btn-link:hover { color: var(--text); }

/* ── Alerts ───────────────────────────────────────────────── */
.alert {
  padding: .75rem 1rem;
  border-radius: var(--radius);
  margin-bottom: 1rem;
  font-size: .9rem;
}
.alert-error   { background: rgba(239,68,68,.12);  border: 1px solid rgba(239,68,68,.35);  color: #fca5a5; }
.alert-success { background: rgba(34,197,94,.12);  border: 1px solid rgba(34,197,94,.35);  color: #86efac; }

/* ── Auth pages ───────────────────────────────────────────── */
.auth-page {
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 5rem 1rem;
}

.auth-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 2.5rem 2rem;
  width: 100%;
  max-width: 400px;
  box-shadow: var(--shadow);
}

.auth-card h1 {
  margin-bottom: 1.5rem;
  font-size: 1.4rem;
}

.auth-card form { display: flex; flex-direction: column; gap: 1rem; }

.auth-card label {
  display: flex;
  flex-direction: column;
  gap: .35rem;
  font-size: .875rem;
  color: var(--text-muted);
}

.auth-card input[type="email"],
.auth-card input[type="password"] {
  padding: .55rem .75rem;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: .95rem;
  outline: none;
  transition: border-color .15s;
}
.auth-card input:focus { border-color: var(--accent); }

.auth-footer {
  margin-top: 1.25rem;
  font-size: .875rem;
  color: var(--text-muted);
  text-align: center;
}

.hint { font-size: .8rem; color: var(--text-muted); margin-left: .25rem; }

/* ── Main pages ───────────────────────────────────────────── */
.page {
  max-width: 1100px;
  margin: 0 auto;
  padding: 2rem 1.5rem 4rem;
}

.page-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.75rem;
}

.page-header h1 { font-size: 1.5rem; font-weight: 700; }

.back-link {
  font-size: .85rem;
  color: var(--text-muted);
  display: block;
  margin-bottom: .25rem;
}

/* ── Tables ───────────────────────────────────────────────── */
.table-wrap {
  overflow-x: auto;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .875rem;
}

.data-table thead {
  background: var(--surface2);
}

.data-table th {
  padding: .7rem 1rem;
  text-align: left;
  font-weight: 600;
  color: var(--text-muted);
  font-size: .8rem;
  text-transform: uppercase;
  letter-spacing: .04em;
  white-space: nowrap;
}

.data-table td {
  padding: .7rem 1rem;
  border-top: 1px solid var(--border);
  vertical-align: middle;
}

.data-table tbody tr:hover { background: rgba(255,255,255,.03); }

.mono { font-family: monospace; color: var(--text-muted); }
.muted { color: var(--text-muted); }
.row-inactive { opacity: .5; }

/* ── Badges ───────────────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: .2rem .6rem;
  border-radius: 999px;
  font-size: .75rem;
  font-weight: 600;
  background: var(--surface2);
  color: var(--text-muted);
}
.badge-green { background: rgba(34,197,94,.15);  color: var(--green); }
.badge-red   { background: rgba(239,68,68,.15);  color: var(--red);   }

/* ── Cards ────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem 1.5rem;
}
.card h2 { font-size: 1rem; margin-bottom: .9rem; color: var(--text-muted); }

/* ── Route meta grid ──────────────────────────────────────── */
.route-meta-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.meta-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .75rem 1.25rem;
  min-width: 140px;
}

.meta-label {
  display: block;
  font-size: .75rem;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--text-muted);
  margin-bottom: .2rem;
}

.meta-value {
  font-size: 1rem;
  font-weight: 600;
}

/* ── Inline form ──────────────────────────────────────────── */
.inline-form {
  display: flex;
  gap: .75rem;
  align-items: center;
  flex-wrap: wrap;
}

.input-text {
  padding: .5rem .75rem;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: .9rem;
  outline: none;
  width: 220px;
}
.input-text:focus { border-color: var(--accent); }
.input-text--sm   { width: 160px; font-size: .85rem; padding: .35rem .6rem; }

/* ── Token display ────────────────────────────────────────── */
.token-display {
  font-size: .85rem;
  word-break: break-all;
  padding: 3px 8px;
  background: var(--surface2);
  border-radius: 4px;
  user-select: all;
}
.token-short { color: var(--text-muted); cursor: help; }

/* ── Help text ────────────────────────────────────────────── */
.help-text {
  font-size: .875rem;
  color: var(--text-muted);
  line-height: 1.7;
  margin-bottom: 1.5rem;
}

/* ── Empty state ──────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text-muted);
  font-size: .95rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
}

/* ── Actions column ───────────────────────────────────────── */
.actions { display: flex; gap: .4rem; flex-wrap: wrap; }

/* ── Admin: Benutzer anlegen Form ────────────────────────── */
.create-user-form .form-row {
  display: flex;
  gap: 1rem;
  align-items: flex-end;
  flex-wrap: wrap;
}

.create-user-form label {
  display: flex;
  flex-direction: column;
  gap: .3rem;
  font-size: .85rem;
  color: var(--text-muted);
}

.label-checkbox {
  flex-direction: row !important;
  align-items: center;
  gap: .5rem !important;
  font-size: .9rem !important;
  color: var(--text) !important;
  padding-bottom: .1rem;
}

.label-checkbox input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
  cursor: pointer;
}

/* ── Map markers (Leaflet divIcon) ────────────────────────── */
.map-marker {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  font-size: 13px;
  font-weight: bold;
  box-shadow: 0 2px 8px rgba(0,0,0,.5);
}
.map-marker--start { background: #22c55e; color: #fff; }
.map-marker--end   { background: #ef4444; color: #fff; }

/* ── Responsive ───────────────────────────────────────────── */
@media (max-width: 640px) {
  .navbar { padding: .65rem 1rem; }
  .page   { padding: 1.5rem 1rem 3rem; }
  .auth-card { padding: 1.75rem 1.25rem; }
  .route-meta-grid { flex-direction: column; }
  .create-user-form .form-row { flex-direction: column; align-items: stretch; }
  .share-url-row { flex-direction: column; align-items: stretch; }
  .share-actions  { flex-direction: column; }
  .map-toolbar    { gap: .4rem; }
}

/* ── Map toolbar (layer switcher) ─────────────────────────── */
.map-toolbar {
  display: flex;
  align-items: center;
  gap: .6rem;
  flex-wrap: wrap;
  margin-top: 1.25rem;
  margin-bottom: .5rem;
}
.layer-btn {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  padding: .35rem .85rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--text-muted);
  font-size: .82rem;
  cursor: pointer;
  transition: background .15s, color .15s, border-color .15s;
}
.layer-btn:hover  { background: var(--surface); color: var(--text); }
.layer-btn.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.layer-sep        { width: 1px; height: 24px; background: var(--border); margin: 0 .2rem; }

/* ── Share panel ──────────────────────────────────────────── */
.share-panel {
  margin-top: 1.25rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
}
.share-panel h3 {
  font-size: .9rem;
  font-weight: 600;
  margin-bottom: .75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .04em;
}
.share-url-row {
  display: flex;
  gap: .5rem;
  align-items: center;
  flex-wrap: wrap;
}
.share-url-input {
  flex: 1;
  min-width: 0;
  padding: .45rem .75rem;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: .85rem;
  font-family: monospace;
  outline: none;
}
.share-hint   { font-size: .8rem; color: var(--text-muted); }
.share-actions { display: flex; gap: .5rem; flex-wrap: wrap; }

/* ── Shared public route page ─────────────────────────────── */
.shared-badge {
  display: inline-block;
  font-size: .8rem;
  padding: .2rem .65rem;
  background: rgba(59,130,246,.15);
  border: 1px solid rgba(59,130,246,.35);
  border-radius: 999px;
  color: #93c5fd;
}
.shared-readonly-hint {
  margin-top: 1rem;
  font-size: .82rem;
  color: var(--text-muted);
  text-align: center;
}
