:root {
  --brand: #5a368d;
  --brand-dark: #492c73;
  --sale: #5a368d;
  --rent: #d97706;
  --bg: #f5f6f8;
  --card-bg: #ffffff;
  --border: #e2e5ea;
  --text: #1f2430;
  --text-muted: #6b7280;
  --radius: 10px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; color: var(--text); background: var(--bg); }
body { display: flex; flex-direction: column; height: 100vh; overflow: hidden; }

.topbar { display: flex; align-items: center; justify-content: space-between; padding: 10px 16px; background: var(--card-bg); border-bottom: 1px solid var(--border); flex-wrap: wrap; gap: 8px; }
.brand { display: flex; align-items: baseline; gap: 8px; }
.brand-mark { font-weight: 700; font-size: 18px; color: var(--brand-dark); }
.brand-sub { font-size: 14px; color: var(--text-muted); }
.tabs { display: flex; gap: 4px; }
.tab-btn { border: none; background: transparent; padding: 8px 14px; border-radius: 8px; font-size: 14px; cursor: pointer; color: var(--text-muted); }
.tab-btn.active { background: var(--brand); color: white; }

main { flex: 1; min-height: 0; display: flex; flex-direction: column; overflow: hidden; }
.tab-panel { display: none; flex: 1; min-height: 0; flex-direction: column; overflow: auto; padding: 12px 16px; }
.tab-panel.active { display: flex; }
#tab-kaart.active { padding: 0; overflow: hidden; }

.filter-bar { display: flex; flex-wrap: wrap; align-items: end; gap: 12px; padding: 10px 16px; background: var(--card-bg); border-bottom: 1px solid var(--border); }
.filter-group { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--text-muted); position: relative; }
.filter-group label { font-weight: 600; }
.filter-group select, .filter-group input[type="text"] { padding: 6px 8px; border: 1px solid var(--border); border-radius: 8px; font-size: 14px; min-width: 160px; }
.type-toggle-group { display: flex; flex-direction: row; gap: 14px; align-items: center; }
.type-toggle { display: flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 600; color: var(--text); cursor: pointer; }
.type-toggle input { width: auto; }
.type-swatch { display: inline-block; width: 12px; height: 12px; border-radius: 50%; }
.type-swatch.sale { background: var(--sale); }
.type-swatch.rent { background: var(--rent); }

.search-group { flex: 1; min-width: 200px; }
.address-results { position: absolute; top: 100%; left: 0; right: 0; background: white; border: 1px solid var(--border); border-radius: 8px; max-height: 220px; overflow: auto; z-index: 1000; display: none; }
.address-results.visible { display: block; }
.address-result-item { padding: 8px 10px; font-size: 13px; cursor: pointer; border-bottom: 1px solid var(--border); }
.address-result-item:hover { background: #f0f4ff; }

.btn { border: none; border-radius: 8px; padding: 9px 16px; font-size: 14px; cursor: pointer; font-weight: 600; }
.btn-primary { background: var(--brand); color: white; }
.btn-primary:hover { background: var(--brand-dark); }
.btn-ghost { background: transparent; color: var(--text-muted); border: 1px solid var(--border); }
.btn-danger { background: #dc2626; color: white; }
.btn-small { padding: 4px 8px; font-size: 12px; }

.map-wrap { position: relative; flex: 1; min-height: 0; }
#map { position: absolute; inset: 0; }

.count-box { position: absolute; top: 12px; left: 50%; transform: translateX(-50%); z-index: 900; background: white; border-radius: 10px; box-shadow: 0 4px 16px rgba(0,0,0,0.15); padding: 10px 16px; font-size: 14px; text-align: center; max-width: 92vw; }
.count-box .count-main { font-weight: 700; font-size: 16px; color: var(--brand-dark); }
.count-box .count-sub { color: var(--text-muted); font-size: 12px; margin-top: 2px; }

.legend { position: absolute; bottom: 16px; left: 16px; background: white; border-radius: 10px; box-shadow: 0 2px 10px rgba(0,0,0,0.12); padding: 10px 12px; font-size: 12px; z-index: 900; }
.legend-item { display: flex; align-items: center; gap: 6px; margin: 3px 0; }
.legend-swatch { width: 12px; height: 12px; border-radius: 50%; display: inline-block; }

.login-gate { position: absolute; inset: 0; background: var(--bg); display: flex; align-items: center; justify-content: center; z-index: 950; text-align: center; padding: 24px; }
.login-gate h3 { margin: 0 0 6px 0; }
.login-gate .form-hint { margin-bottom: 14px; }

.property-marker-icon { background: transparent; border: none; }
.property-cluster-icon { background: transparent; border: none; }
.property-cluster-icon > div { display: flex; align-items: center; justify-content: center; border-radius: 50%; color: white; font-weight: 700; font-size: 13px; background: var(--brand); box-shadow: 0 0 0 3px rgba(90,54,141,0.25); }

.office-marker-icon { background: transparent; border: none; }
.office-marker { width: 100%; height: 100%; border-radius: 8px; background: white; border: 2.5px solid #999; box-shadow: 0 2px 6px rgba(0,0,0,0.35); display: flex; align-items: center; justify-content: center; overflow: hidden; }
.office-marker img { width: 100%; height: 100%; min-width: 0; min-height: 0; object-fit: contain; padding: 3px; }
.office-marker .office-fallback-label { display: none; font-weight: 800; font-size: 15px; }
.office-marker.logo-fallback .office-fallback-label { display: block; }
.badge.brand-badge { color: white; }
.brand-swatch { display: inline-block; width: 12px; height: 12px; border-radius: 50%; vertical-align: middle; }

.locate-control a { font-size: 16px; display: flex; align-items: center; justify-content: center; text-decoration: none; }

.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 16px; }
.card { background: var(--card-bg); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; }
.card h3 { margin: 0 0 12px 0; font-size: 15px; }

.admin-add-row { display: flex; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; }
.admin-add-row input[type="text"], .admin-add-row input[type="password"], .admin-add-row input[type="number"] { flex: 1; min-width: 140px; padding: 8px; border: 1px solid var(--border); border-radius: 8px; }
.admin-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 6px; max-height: 360px; overflow: auto; }
.admin-list li { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 6px 8px; border: 1px solid var(--border); border-radius: 8px; font-size: 13px; }
.admin-list .row-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.admin-list .row-main .addr { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.admin-list .row-main .meta { color: var(--text-muted); font-size: 12px; }
.admin-list .row-actions { display: flex; gap: 6px; flex-shrink: 0; }
.admin-list li.inactive { opacity: 0.55; }
.badge { display: inline-block; padding: 1px 8px; border-radius: 10px; font-size: 11px; font-weight: 700; color: white; }
.badge.sale { background: var(--sale); }
.badge.rent { background: var(--rent); }
.badge-warn { background: #fef3c7; color: #92400e; }

.pin-cell { font-family: "SFMono-Regular", Consolas, monospace; background: #eef1f5; padding: 2px 8px; border-radius: 6px; font-size: 12px; letter-spacing: 1px; }

.session-box { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.session-info { color: var(--text-muted); }
.session-info strong { color: var(--text); }
.hidden { display: none !important; }

.readonly-field { padding: 8px; border: 1px solid var(--border); border-radius: 8px; font-size: 14px; background: #f8f9fb; color: var(--text-muted); }
.form-hint { font-size: 12px; font-weight: 400; color: var(--text-muted); }

.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.4); display: flex; align-items: center; justify-content: center; z-index: 2000; padding: 16px; }
.modal-overlay.hidden { display: none; }
.modal { background: white; border-radius: 12px; padding: 20px; width: 100%; max-width: 460px; max-height: 90vh; overflow: auto; }
.modal.modal-wide { max-width: 720px; }
.modal h3 { margin-top: 0; }
.modal form, .modal .modal-form { display: flex; flex-direction: column; gap: 12px; }
.modal label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; font-weight: 600; color: var(--text-muted); }
.modal select, .modal input, .modal textarea { padding: 8px; border: 1px solid var(--border); border-radius: 8px; font-size: 14px; font-family: inherit; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; margin-top: 6px; }

.mini-map { height: 220px; border-radius: 8px; border: 1px solid var(--border); }

.leaflet-popup-content { font-size: 13px; min-width: 180px; }
.popup-title { font-weight: 700; margin-bottom: 4px; }
.popup-row { color: var(--text-muted); margin: 2px 0; }

.import-dropzone { border: 2px dashed var(--border); border-radius: 10px; padding: 20px; text-align: center; color: var(--text-muted); font-size: 13px; }
.import-progress-track { background: #eef1f5; border-radius: 6px; height: 12px; overflow: hidden; margin: 8px 0; }
.import-progress-fill { height: 100%; background: var(--brand); border-radius: 6px; width: 0%; transition: width 0.2s; }
.import-review-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.import-review-table th, .import-review-table td { padding: 5px 8px; border-bottom: 1px solid var(--border); text-align: left; }
.import-review-table td.num { text-align: right; }

.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: #1f2430; color: white; padding: 10px 18px; border-radius: 8px; font-size: 13px; z-index: 3000; }
.toast.hidden { display: none; }
.toast.error { background: #dc2626; }

.filter-fields { display: contents; }
.filter-toggle { display: none; }

@media (max-width: 720px) {
  .filter-bar { flex-wrap: wrap; align-items: stretch; }
  .filter-toggle { display: inline-flex; align-items: center; gap: 6px; order: 1; }
  .filter-fields { display: none; order: 3; width: 100%; flex-direction: column; align-items: stretch; gap: 12px; margin-top: 8px; }
  .filter-fields.expanded { display: flex; }
  .filter-group select, .filter-group input[type="text"] { min-width: 0; width: 100%; }
  .brand-sub { display: none; }
  .count-box { left: 8px; right: 8px; transform: none; top: 8px; }
}

/* De tool is vooral gemaakt om aan een klant te tonen op iPad (liggend) of computer,
   maar moet ook bruikbaar blijven op een smartphone in rechtopstaande stand. */
@media (max-height: 480px) {
  .topbar { padding: 6px 12px; }
  .filter-bar { padding: 6px 12px; gap: 8px; }
  .legend { padding: 6px 8px; font-size: 11px; bottom: 8px; left: 8px; }
}
