:root {
  --bg: #0d1117;
  --surface: #161b22;
  --surface2: #21262d;
  --border: #30363d;
  --text: #e6edf3;
  --text-muted: #8b949e;
  --accent: #388bfd;
  --accent-dark: #1f6feb;
  --success: #3fb950;
  --warning: #d29922;
  --danger: #f85149;
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, sans-serif;
  --radius: 8px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  min-height: 100dvh;
}

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

/* ── Auth pages ────────────────────────── */
.auth-page {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
}

.auth-container {
  width: 100%;
  max-width: 400px;
}

.auth-container h1 {
  font-size: 1.8rem;
  font-weight: 700;
  margin-bottom: 28px;
  line-height: 1.2;
}

.auth-link {
  margin-top: 20px;
  color: var(--text-muted);
  font-size: 0.9rem;
  text-align: center;
}

/* ── Forms ─────────────────────────────── */
.form-group {
  margin-bottom: 16px;
}

label {
  display: block;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 6px;
}

input[type="text"],
input[type="password"],
input[type="date"],
input[type="time"],
select,
textarea {
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--font);
  font-size: 1rem;
  padding: 10px 14px;
  appearance: none;
  -webkit-appearance: none;
  transition: border-color 0.15s;
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(56, 139, 253, 0.15);
}

textarea { resize: vertical; min-height: 80px; }

.username-preview {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-muted);
  font-family: monospace;
  font-size: 1rem;
  padding: 10px 14px;
  letter-spacing: 0.02em;
}

/* ── Buttons ───────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 18px;
  font-family: var(--font);
  font-size: 0.9375rem;
  font-weight: 600;
  border: 1px solid transparent;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  min-height: 44px;
  white-space: nowrap;
  text-decoration: none;
}

.btn-primary {
  background: var(--accent-dark);
  border-color: var(--accent);
  color: #fff;
}
.btn-primary:hover { background: var(--accent); text-decoration: none; }

.btn-success {
  background: #1a4731;
  border-color: var(--success);
  color: var(--success);
}
.btn-success:hover { background: #236040; text-decoration: none; }

.btn-danger {
  background: #3d1a1a;
  border-color: var(--danger);
  color: var(--danger);
}
.btn-danger:hover { background: #5c2222; text-decoration: none; }

.btn-ghost {
  background: transparent;
  border-color: var(--border);
  color: var(--text-muted);
}
.btn-ghost:hover { border-color: var(--text-muted); color: var(--text); text-decoration: none; }

.btn-full { width: 100%; }

.btn-sm { padding: 6px 12px; font-size: 0.8125rem; min-height: 32px; }

.btn-big {
  font-size: 1.125rem;
  padding: 18px 24px;
  min-height: 64px;
  border-radius: 12px;
  width: 100%;
  justify-content: flex-start;
  gap: 12px;
}

/* ── Messages ──────────────────────────── */
.msg {
  padding: 12px 16px;
  border-radius: var(--radius);
  margin-bottom: 20px;
  font-size: 0.9375rem;
  display: none;
}
.msg.error   { display: block; background: #3d1a1a; border: 1px solid var(--danger); color: var(--danger); }
.msg.success { display: block; background: #1a3d2b; border: 1px solid var(--success); color: var(--success); }
.msg.info    { display: block; background: #1a2d3d; border: 1px solid var(--accent); color: var(--accent); }

/* ── App header ────────────────────────── */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  height: 56px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}

.app-header h2 {
  font-size: 1.125rem;
  font-weight: 700;
}

.app-header .header-nav {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ── Container ─────────────────────────── */
.container {
  max-width: 720px;
  margin: 0 auto;
  padding: 24px 16px 80px;
}

/* ── Projecten lijst ───────────────────── */
.inline-form {
  display: flex;
  gap: 8px;
  margin-bottom: 24px;
}

.inline-input {
  flex: 1;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--font);
  font-size: 1rem;
  padding: 10px 14px;
  min-height: 44px;
}

.inline-input:focus {
  outline: none;
  border-color: var(--accent);
}

.project-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.project-card {
  display: block;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  text-decoration: none;
  color: var(--text);
  transition: border-color 0.15s, background 0.15s;
}

.project-card:hover {
  border-color: var(--accent);
  background: var(--surface2);
  text-decoration: none;
}

.project-card-title {
  font-size: 1.0625rem;
  font-weight: 600;
  margin-bottom: 6px;
}

.project-card-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.8125rem;
  color: var(--text-muted);
}

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
}

.badge.projectleider { background: #1a2d3d; color: var(--accent); border: 1px solid var(--accent-dark); }
.badge.medewerker    { background: var(--surface2); color: var(--text-muted); border: 1px solid var(--border); }

.empty { color: var(--text-muted); font-style: italic; padding: 32px 0; text-align: center; }
.loading { color: var(--text-muted); padding: 32px 0; text-align: center; }

/* ── Project pagina ────────────────────── */
.section-block {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 20px;
  overflow: hidden;
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--surface2);
}

.section-header h3 {
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.section-body { padding: 16px; }

.action-buttons {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 20px;
}

/* ── Individuen tabel ──────────────────── */
.individu-list {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.individu-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.individu-row:last-child { border-bottom: none; }

.individu-naam { font-weight: 600; min-width: 80px; }
.individu-meta { color: var(--text-muted); font-size: 0.875rem; flex: 1; }
.individu-actions { display: flex; gap: 6px; margin-left: auto; }

/* ── Mini kaart ────────────────────────── */
#miniKaart {
  width: 100%;
  height: 280px;
  border-radius: 0 0 var(--radius) var(--radius);
}

/* ── Gebruikers tabel ──────────────────── */
.gebruiker-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.gebruiker-row:last-child { border-bottom: none; }
.gebruiker-info { flex: 1; }
.gebruiker-naam { font-weight: 600; font-size: 0.9375rem; }
.gebruiker-username { font-size: 0.8125rem; color: var(--text-muted); font-family: monospace; }

/* ── Activiteiten ──────────────────────── */
.activiteit-item {
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.875rem;
}
.activiteit-item:last-child { border-bottom: none; }
.activiteit-tijd { color: var(--text-muted); font-size: 0.75rem; margin-top: 2px; }

/* ── Zoekresultaten ────────────────────── */
.zoek-resultaten {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-top: 4px;
  overflow: hidden;
  display: none;
}

.zoek-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  transition: background 0.1s;
}
.zoek-item:last-child { border-bottom: none; }
.zoek-item:hover { background: var(--surface); }

/* ── Modal ─────────────────────────────── */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 500;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.modal-overlay.open { display: flex; }

.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  width: 100%;
  max-width: 480px;
  padding: 24px;
  max-height: 90dvh;
  overflow-y: auto;
}

.modal h3 { font-size: 1.125rem; margin-bottom: 20px; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 20px; }

/* ── Export pagina ─────────────────────── */
.export-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 12px;
}
.export-card h3 { font-size: 1rem; margin-bottom: 8px; }
.export-card p { color: var(--text-muted); font-size: 0.875rem; margin-bottom: 16px; }

.stat-number {
  font-size: 3rem;
  font-weight: 700;
  color: var(--accent);
  line-height: 1;
}

.samenvatting-tabel {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}
.samenvatting-tabel th {
  text-align: left;
  padding: 8px 12px;
  background: var(--surface2);
  color: var(--text-muted);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.samenvatting-tabel td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
}
.samenvatting-tabel tr:last-child td { border-bottom: none; }

/* ── Veldpagina (volledig scherm) ──────── */
.veld-body {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  overflow: hidden;
  position: relative;
}

.veld-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 14px;
  height: 52px;
  background: rgba(13,17,23,0.92);
  border-bottom: 1px solid var(--border);
  position: relative;
  z-index: 400;
  backdrop-filter: blur(8px);
  flex-shrink: 0;
}

.veld-header h2 {
  font-size: 1rem;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.veld-teller {
  background: var(--accent-dark);
  color: #fff;
  border-radius: 999px;
  padding: 3px 12px;
  font-size: 0.8125rem;
  font-weight: 600;
  white-space: nowrap;
}

#kaart {
  flex: 1;
  z-index: 1;
}

/* GPS marker puls */
.gps-marker {
  width: 18px;
  height: 18px;
  background: #388bfd;
  border: 3px solid #fff;
  border-radius: 50%;
  box-shadow: 0 0 0 0 rgba(56,139,253,0.6);
  animation: gps-puls 2s infinite;
  position: relative;
}

@keyframes gps-puls {
  0%   { box-shadow: 0 0 0 0 rgba(56,139,253,0.6); }
  70%  { box-shadow: 0 0 0 14px rgba(56,139,253,0); }
  100% { box-shadow: 0 0 0 0 rgba(56,139,253,0); }
}

/* Bottom sheet */
.bottom-sheet {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--surface);
  border-top: 1px solid var(--border);
  border-radius: 16px 16px 0 0;
  padding: 0 16px 32px;
  z-index: 300;
  transform: translateY(100%);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  max-height: 92dvh;
  overflow-y: auto;
}

.bottom-sheet.open {
  transform: translateY(0);
}

.sheet-handle {
  width: 40px;
  height: 4px;
  background: var(--border);
  border-radius: 999px;
  margin: 12px auto 16px;
}

.sheet-title {
  font-size: 1.0625rem;
  font-weight: 700;
  margin-bottom: 16px;
}

.coord-display {
  display: flex;
  gap: 8px;
  margin-bottom: 4px;
}

.coord-pill {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 0.75rem;
  font-family: monospace;
  color: var(--text-muted);
  flex: 1;
}

.char-count {
  text-align: right;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 4px;
}

.sheet-actions {
  display: flex;
  gap: 10px;
  margin-top: 20px;
}

.sheet-actions .btn { flex: 1; min-height: 52px; font-size: 1rem; }

/* Leaflet popup aanpassingen */
.leaflet-popup-content-wrapper {
  background: var(--surface) !important;
  color: var(--text) !important;
  border: 1px solid var(--border) !important;
  border-radius: var(--radius) !important;
  box-shadow: 0 4px 20px rgba(0,0,0,0.5) !important;
}
.leaflet-popup-tip { background: var(--surface) !important; }
.leaflet-popup-content { font-family: var(--font) !important; font-size: 0.875rem; }
.popup-individu { font-weight: 700; font-size: 0.9375rem; }
.popup-gedrag { color: var(--accent); font-weight: 600; }
.popup-meta { color: var(--text-muted); font-size: 0.8125rem; margin-top: 4px; }
.popup-opmerking { margin-top: 6px; font-style: italic; font-size: 0.8125rem; }

/* Toggle schakelaar */
.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 0;
}

.toggle {
  position: relative;
  width: 44px;
  height: 24px;
  flex-shrink: 0;
}

.toggle input { opacity: 0; width: 0; height: 0; }

.toggle-slider {
  position: absolute;
  inset: 0;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.2s;
}

.toggle-slider:before {
  content: '';
  position: absolute;
  width: 16px;
  height: 16px;
  left: 3px;
  top: 3px;
  background: var(--text-muted);
  border-radius: 50%;
  transition: transform 0.2s, background 0.2s;
}

.toggle input:checked + .toggle-slider { background: var(--accent-dark); border-color: var(--accent); }
.toggle input:checked + .toggle-slider:before { transform: translateX(20px); background: #fff; }

/* Zwevende kaartwissel-knop op veldpagina */
.kaart-wissel-float {
  position: absolute;
  top: 64px;
  right: 12px;
  z-index: 400;
  width: 44px;
  height: 44px;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 20px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(0,0,0,0.6);
  transition: background 0.15s, border-color 0.15s;
  -webkit-tap-highlight-color: transparent;
}
.kaart-wissel-float:hover  { background: var(--surface2); }
.kaart-wissel-float.actief { background: var(--accent-dark); border-color: var(--accent); }

/* Responsive */
@media (min-width: 600px) {
  .action-buttons { flex-direction: row; }
  .bottom-sheet { max-width: 520px; left: 50%; transform: translateX(-50%) translateY(100%); border-radius: 16px 16px 0 0; }
  .bottom-sheet.open { transform: translateX(-50%) translateY(0); }
}
