:root {
  --pink: #E81A85;
  --purple: #B02CE0;
  --purple-deep: #5B21B6;
  --bg: #FAFAFB;
  --card: #FFFFFF;
  --text: #111827;
  --muted: #6B7280;
  --border: #E5E7EB;
  --up: #059669;
  --down: #DC2626;
  --accent-gradient: linear-gradient(135deg, var(--purple), var(--pink));
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: 'Manrope', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

.wrap { max-width: 1280px; margin: 0 auto; padding: 32px 24px 96px; }

h1, h2, h3, h4 {
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 700;
  letter-spacing: -0.015em;
  color: var(--text);
}
h1 { font-size: 30px; margin: 0 0 6px; }
h1 .accent, .brand-accent { background: var(--accent-gradient); -webkit-background-clip: text; background-clip: text; color: transparent; }
h2 { font-size: 20px; margin: 40px 0 16px; font-weight: 600; }
h3 { font-size: 15px; margin: 0 0 12px; font-weight: 600; }
.sub { color: var(--muted); font-size: 14px; }
.muted { color: var(--muted); }

.topnav {
  background: white; border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 20;
}
.topnav-inner {
  max-width: 1280px; margin: 0 auto; padding: 14px 24px;
  display: flex; justify-content: space-between; align-items: center;
}
.brand {
  font-family: 'Space Grotesk'; font-weight: 700; font-size: 18px;
  text-decoration: none; color: var(--text);
}
.topnav nav { display: flex; gap: 6px; align-items: center; }
.topnav nav a {
  padding: 8px 14px; border-radius: 8px; text-decoration: none;
  color: var(--muted); font-size: 14px; font-weight: 600;
}
.topnav nav a:hover { color: var(--text); background: #F3F4F6; }
.topnav nav a.active { color: white; background: var(--accent-gradient); }
.linkbtn {
  background: none; border: none; padding: 8px 14px; cursor: pointer;
  color: var(--muted); font-size: 14px; font-weight: 600; font-family: inherit;
}
.linkbtn:hover { color: var(--text); }

.card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: 14px; padding: 22px;
}

.refresh-bar {
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  margin: 18px 0 24px;
  padding: 14px 18px;
  background: white; border: 1px solid var(--border); border-radius: 12px;
}
.refresh-bar .stamp { font-size: 13px; color: var(--muted); flex: 1; min-width: 200px; }
.refresh-bar .stamp strong { color: var(--text); }
.btn-primary {
  background: var(--accent-gradient);
  color: white; border: none; padding: 9px 18px;
  border-radius: 8px; font-weight: 600; font-family: inherit; font-size: 14px;
  cursor: pointer;
}
.btn-primary:disabled { opacity: 0.5; cursor: wait; }
.btn-secondary {
  background: white; color: var(--text); border: 1px solid var(--border);
  padding: 9px 16px; border-radius: 8px; font-weight: 600; font-family: inherit;
  font-size: 14px; cursor: pointer;
}
.btn-secondary:hover { border-color: var(--purple); }

.refresh-progress {
  width: 100%; margin-top: 12px;
  max-height: 180px; overflow-y: auto;
  background: #0F172A; color: #E2E8F0;
  border-radius: 8px; padding: 10px 12px;
  font-family: 'SF Mono', Menlo, Consolas, monospace;
  font-size: 12px; line-height: 1.55;
  display: none;
}
.refresh-progress.visible { display: block; }

.grid { display: grid; gap: 16px; }
.kpi-grid { grid-template-columns: 1.4fr repeat(4, 1fr); }
@media (max-width: 1000px) { .kpi-grid { grid-template-columns: 1fr 1fr; } }

.kpi { position: relative; border-top: 3px solid var(--accent, var(--purple)); }
.kpi h3 {
  margin: 0 0 8px; font-size: 12px; text-transform: uppercase;
  letter-spacing: 0.06em; color: var(--muted);
  font-family: 'Manrope', sans-serif; font-weight: 600;
}
.kpi .val { font-family: 'Space Grotesk'; font-size: 26px; font-weight: 700; line-height: 1.15; }
.kpi-total .val { font-size: 32px; }
.kpi .delta { font-size: 13px; margin-top: 6px; font-weight: 600; }
.kpi .sub-line { font-size: 12px; color: var(--muted); margin-top: 4px; }
.up { color: var(--up); }
.down { color: var(--down); }

.row-2 { grid-template-columns: 1fr 1fr; }
@media (max-width: 900px) { .row-2 { grid-template-columns: 1fr; } }
.row-two-third { grid-template-columns: 2fr 3fr; }
@media (max-width: 900px) { .row-two-third { grid-template-columns: 1fr; } }

.filter-row { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 18px; }
.filter-row button {
  border: 1px solid var(--border); background: white;
  padding: 6px 14px; border-radius: 999px;
  font-family: 'Manrope'; font-size: 13px; cursor: pointer;
  font-weight: 500; color: var(--text);
}
.filter-row button:hover { border-color: var(--purple); }
.filter-row button.active { background: var(--accent-gradient); color: white; border-color: transparent; }

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 9px 10px; text-align: left; border-bottom: 1px solid var(--border); }
th { font-family: 'Space Grotesk'; font-weight: 500; color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td.strong { font-weight: 700; }
.total-row td { border-top: 2px solid var(--border); border-bottom: none; font-weight: 700; background: #FAFAFB; }
td.current { font-style: italic; }
.pill { display:inline-block; padding:1px 8px; border-radius:999px; background: var(--accent-gradient); color:white; font-size:11px; font-weight:600; margin-left:6px; vertical-align:middle; }

.map-pill { display:inline-block; padding:3px 12px; border-radius:999px; color:white; font-size:12px; font-weight:600; }
#orderMap { position: relative; transition: box-shadow .15s ease; }
#orderMap.map-active { box-shadow: 0 0 0 2px var(--purple); }
#orderMap::after {
  content: 'Klik voor scroll-zoom';
  position: absolute; top: 10px; right: 10px; z-index: 500;
  background: rgba(17, 24, 39, 0.75); color: white;
  padding: 4px 10px; border-radius: 999px;
  font-family: 'Manrope', sans-serif; font-size: 11px; font-weight: 600;
  pointer-events: none;
  transition: background .15s;
}
#orderMap.map-active::after {
  content: 'Scroll om te zoomen · klik buiten om te sluiten';
  background: linear-gradient(135deg, var(--purple), var(--pink));
}
.leaflet-popup-content { font-family: 'Manrope', sans-serif; font-size: 13px; }
.leaflet-popup-content b { font-family: 'Space Grotesk', sans-serif; }
.chart-holder { position: relative; }
.donut-wrap { max-width: 460px; margin: 0 auto; }

footer.foot {
  margin-top: 48px; font-size: 13px; color: var(--muted);
  border-top: 1px solid var(--border); padding-top: 16px; line-height: 1.55;
}
footer.foot strong { color: var(--text); }

/* --- Login ------------------------------------------------------------- */
.login-wrap {
  max-width: 380px; margin: 15vh auto 0;
  padding: 32px 28px;
  background: white; border: 1px solid var(--border); border-radius: 16px;
  box-shadow: 0 10px 40px -20px rgba(176, 44, 224, 0.35);
}
.login-wrap h1 { font-size: 24px; margin-bottom: 6px; }
.login-wrap .sub { margin-bottom: 22px; }
.login-wrap label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; color: var(--muted); }
.login-wrap input[type="password"] {
  width: 100%; padding: 11px 14px; font-size: 15px;
  border: 1px solid var(--border); border-radius: 10px; font-family: inherit;
  outline: none; transition: border-color .15s;
}
.login-wrap input[type="password"]:focus { border-color: var(--purple); }
.login-wrap button {
  width: 100%; margin-top: 16px; padding: 11px;
  background: var(--accent-gradient); color: white; border: none;
  border-radius: 10px; font-weight: 700; font-size: 15px; cursor: pointer;
  font-family: inherit;
}
.login-error {
  margin-top: 14px; padding: 10px 12px; border-radius: 8px;
  background: #FEF2F2; color: #991B1B; font-size: 13px;
}
.login-notice {
  margin-top: 14px; padding: 10px 12px; border-radius: 8px;
  background: #EEF2FF; color: #3730A3; font-size: 13px;
}

/* --- Chat -------------------------------------------------------------- */
.chat-shell {
  display: grid; grid-template-columns: 1fr;
  gap: 16px; max-width: 900px; margin: 0 auto;
}
.chat-log {
  background: white; border: 1px solid var(--border); border-radius: 14px;
  min-height: 55vh; max-height: 65vh; overflow-y: auto;
  padding: 22px;
}
.chat-msg { margin-bottom: 20px; }
.chat-msg .who { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); margin-bottom: 6px; }
.chat-msg.user .who { color: var(--purple); }
.chat-msg.assistant .who { color: var(--text); }
.chat-msg .body { font-size: 15px; line-height: 1.55; white-space: pre-wrap; }
.chat-msg .tools { margin-top: 10px; font-size: 12px; }
.chat-msg .tools details { background: #F9FAFB; border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; margin-top: 6px; }
.chat-msg .tools summary { cursor: pointer; color: var(--muted); font-weight: 600; }
.chat-msg .tools pre { margin: 8px 0 0; font-size: 11px; overflow-x: auto; color: var(--text); font-family: 'SF Mono', Menlo, Consolas, monospace; }
.chat-input {
  display: flex; gap: 10px; align-items: flex-start;
  background: white; border: 1px solid var(--border); border-radius: 14px; padding: 12px;
}
.chat-input textarea {
  flex: 1; border: none; outline: none; resize: none;
  font-family: inherit; font-size: 15px; padding: 8px 10px;
  min-height: 48px; max-height: 200px;
}
.chat-input button { align-self: flex-end; }
.chat-empty {
  text-align: center; padding: 40px 20px; color: var(--muted);
}
.chat-empty h3 { font-size: 17px; margin-bottom: 6px; color: var(--text); }
.chat-empty ul { list-style: none; padding: 0; margin: 20px auto 0; max-width: 480px; text-align: left; }
.chat-empty ul li {
  padding: 10px 14px; background: #F9FAFB; border-radius: 8px;
  margin-bottom: 8px; cursor: pointer; font-size: 14px; color: var(--text);
  border: 1px solid transparent;
}
.chat-empty ul li:hover { border-color: var(--purple); background: white; }

.notice {
  padding: 14px 16px; background: #FEF3C7; color: #78350F;
  border-radius: 10px; margin: 10px 0 20px; font-size: 14px;
}
.notice code { background: rgba(0,0,0,0.05); padding: 1px 5px; border-radius: 4px; }

.year-select {
  font-family: inherit; font-size: 14px; font-weight: 600;
  padding: 6px 12px; border-radius: 8px;
  border: 1px solid var(--border); background: white; color: var(--text);
  cursor: pointer;
}
.year-select:hover { border-color: var(--purple); }
.year-select:focus { outline: none; border-color: var(--purple); box-shadow: 0 0 0 3px rgba(176, 44, 224, 0.15); }
