/* ==========================================================================
   Postcode Intelligence — design system
   Zwart / wit / donkergrijs met subtiele rode accenten. Veel whitespace,
   afgeronde hoeken, subtiele shadows. Geïnspireerd op een strak, luxe
   zakelijk intern platform (geen Bootstrap-look).
   ========================================================================== */

:root {
  --pi-black: #0b0b0c;
  --pi-near-black: #16161a;
  --pi-dark: #212126;
  --pi-dark-2: #2c2c33;
  --pi-grey-700: #4a4a52;
  --pi-grey-500: #7a7a84;
  --pi-grey-300: #c7c7cf;
  --pi-grey-100: #eeeef1;
  --pi-white: #ffffff;
  --pi-red: #c8242c;
  --pi-red-dark: #a01d24;
  --pi-red-soft: #fbe9ea;

  --pi-green: #1c8a4c;
  --pi-green-soft: #e6f5ec;
  --pi-amber: #b8860b;
  --pi-amber-soft: #fbf1de;
  --pi-orange: #c56a1f;
  --pi-orange-soft: #fbeee0;

  --pi-radius: 14px;
  --pi-radius-sm: 9px;
  --pi-shadow: 0 1px 2px rgba(16,16,20,0.04), 0 8px 24px rgba(16,16,20,0.06);
  --pi-shadow-lg: 0 12px 40px rgba(16,16,20,0.12);
  --pi-sidebar-w: 264px;
  --pi-header-h: 72px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--pi-grey-100);
  color: var(--pi-near-black);
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
ul { list-style: none; margin: 0; padding: 0; }

/* ---------- Auth screens ---------- */
.auth-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(1200px 600px at 15% -10%, #232329 0%, transparent 60%),
    linear-gradient(160deg, var(--pi-black) 0%, var(--pi-near-black) 55%, var(--pi-dark) 100%);
  padding: 24px;
}
.auth-card {
  width: 100%;
  max-width: 400px;
  background: var(--pi-white);
  border-radius: var(--pi-radius);
  box-shadow: var(--pi-shadow-lg);
  padding: 40px 36px 32px;
  animation: pi-fade-in .5s ease both;
}
.auth-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 28px;
}
.auth-brand .dot { width: 10px; height: 10px; border-radius: 3px; background: var(--pi-red); }
.auth-brand span { font-weight: 700; letter-spacing: .2px; font-size: 17px; }
.auth-card h1 { font-size: 20px; margin: 0 0 4px; }
.auth-card p.sub { color: var(--pi-grey-500); font-size: 13.5px; margin: 0 0 24px; }
.field { margin-bottom: 16px; }
.field label { display: block; font-size: 12.5px; font-weight: 600; color: var(--pi-grey-700); margin-bottom: 6px; text-transform: uppercase; letter-spacing: .4px; }
.field input, .field select {
  width: 100%;
  padding: 11px 13px;
  border: 1px solid var(--pi-grey-300);
  border-radius: var(--pi-radius-sm);
  font-size: 14.5px;
  background: var(--pi-white);
  transition: border-color .15s, box-shadow .15s;
}
.field input:focus, .field select:focus {
  outline: none;
  border-color: var(--pi-dark);
  box-shadow: 0 0 0 3px rgba(33,33,38,0.08);
}
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: none; cursor: pointer;
  border-radius: var(--pi-radius-sm);
  font-weight: 600; font-size: 14px;
  padding: 11px 18px;
  transition: transform .1s ease, background .15s ease, box-shadow .15s ease;
}
.btn:active { transform: scale(0.98); }
.btn-primary { background: var(--pi-near-black); color: var(--pi-white); }
.btn-primary:hover { background: var(--pi-black); }
.btn-red { background: var(--pi-red); color: var(--pi-white); }
.btn-red:hover { background: var(--pi-red-dark); }
.btn-ghost { background: transparent; color: var(--pi-near-black); border: 1px solid var(--pi-grey-300); }
.btn-ghost:hover { background: var(--pi-grey-100); }
.btn-block { width: 100%; }
.btn-sm { padding: 7px 12px; font-size: 12.5px; }
.alert {
  padding: 11px 14px; border-radius: var(--pi-radius-sm); font-size: 13.5px; margin-bottom: 16px;
}
.alert-error { background: var(--pi-red-soft); color: var(--pi-red-dark); border: 1px solid #f2c6c8; }
.alert-success { background: var(--pi-green-soft); color: #146238; border: 1px solid #bfe6cf; }

/* ---------- App shell ---------- */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--pi-sidebar-w);
  background: var(--pi-black);
  color: var(--pi-grey-300);
  position: fixed; top: 0; left: 0; bottom: 0;
  display: flex; flex-direction: column;
  z-index: 40;
}
.sidebar-brand {
  padding: 22px 22px 18px;
  display: flex; align-items: center; gap: 10px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}
.sidebar-brand .dot { width: 11px; height: 11px; border-radius: 3px; background: var(--pi-red); box-shadow: 0 0 0 4px rgba(200,36,44,0.15); }
.sidebar-brand strong { color: var(--pi-white); font-size: 15.5px; letter-spacing: .2px; }
.sidebar-brand small { display:block; color: var(--pi-grey-500); font-size: 10.5px; letter-spacing: .6px; text-transform: uppercase; margin-top: 1px;}

.sidebar-nav { padding: 14px 12px; overflow-y: auto; flex: 1; }
.sidebar-group-title { font-size: 10.5px; text-transform: uppercase; letter-spacing: .8px; color: var(--pi-grey-500); padding: 14px 12px 6px; }
.sidebar-nav a {
  display: flex; align-items: center; gap: 11px;
  padding: 10px 12px; border-radius: 10px;
  font-size: 13.8px; color: var(--pi-grey-300);
  margin-bottom: 2px;
  transition: background .15s, color .15s;
}
.sidebar-nav a:hover { background: rgba(255,255,255,0.06); color: var(--pi-white); }
.sidebar-nav a.active { background: var(--pi-red); color: var(--pi-white); }
.sidebar-nav a .ic { width: 16px; text-align: center; opacity: .9; font-size: 13px; }
.sidebar-foot { padding: 16px 20px; border-top: 1px solid rgba(255,255,255,0.06); font-size: 11.5px; color: var(--pi-grey-500); }

.main {
  margin-left: var(--pi-sidebar-w);
  flex: 1;
  display: flex; flex-direction: column;
  min-width: 0;
}

.topbar {
  height: var(--pi-header-h);
  background: var(--pi-white);
  border-bottom: 1px solid var(--pi-grey-100);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 28px;
  position: sticky; top: 0; z-index: 30;
}
.topbar h1 { font-size: 18px; margin: 0; font-weight: 700; letter-spacing: .1px; }
.topbar .meta { display: flex; align-items: center; gap: 18px; font-size: 12.8px; color: var(--pi-grey-700); }
.topbar .meta .import-time strong { display: block; color: var(--pi-near-black); font-size: 13px; }
.avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--pi-dark); color: white; display: flex; align-items: center; justify-content: center;
  font-size: 12.5px; font-weight: 700;
}

.content { padding: 26px 28px 60px; animation: pi-fade-in .35s ease both; }
.content-header { display: flex; align-items: flex-end; justify-content: space-between; margin-bottom: 20px; flex-wrap: wrap; gap: 12px;}
.content-header h2 { font-size: 22px; margin: 0 0 4px; }
.content-header p { margin: 0; color: var(--pi-grey-700); font-size: 13.5px; }

/* ---------- Cards / KPIs ---------- */
.card {
  background: var(--pi-white);
  border-radius: var(--pi-radius);
  box-shadow: var(--pi-shadow);
  padding: 20px;
}
.kpi-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 14px; margin-bottom: 22px; }
@media (max-width: 1400px) { .kpi-grid { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 760px) { .kpi-grid { grid-template-columns: repeat(2, 1fr); } }
.kpi-card {
  background: var(--pi-white);
  border-radius: var(--pi-radius);
  box-shadow: var(--pi-shadow);
  padding: 18px 18px 16px;
  position: relative;
  overflow: hidden;
  animation: pi-slide-up .4s ease both;
}
.kpi-card::before {
  content: ""; position: absolute; top: 0; left: 0; width: 3px; height: 100%; background: var(--pi-grey-300);
}
.kpi-card.accent-red::before { background: var(--pi-red); }
.kpi-card.accent-green::before { background: var(--pi-green); }
.kpi-card.accent-amber::before { background: var(--pi-amber); }
.kpi-card .label { font-size: 11px; text-transform: uppercase; letter-spacing: .6px; color: var(--pi-grey-500); font-weight: 700; }
.kpi-card .value { font-size: 30px; font-weight: 800; margin-top: 6px; letter-spacing: -.5px; }
.kpi-card .sub { font-size: 12px; color: var(--pi-grey-500); margin-top: 4px; }

/* ---------- Badges / status pills ---------- */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 4px 10px; border-radius: 99px; font-size: 11.5px; font-weight: 700; letter-spacing: .2px; white-space: nowrap; }
.badge::before { content:""; width:6px; height:6px; border-radius:50%; }
.badge-beschikbaar { background: var(--pi-green-soft); color: #146238; }
.badge-beschikbaar::before { background: var(--pi-green); }
.badge-bijna-beschikbaar { background: var(--pi-amber-soft); color: #7a5c07; }
.badge-bijna-beschikbaar::before { background: var(--pi-amber); }
.badge-cooldown { background: var(--pi-red-soft); color: var(--pi-red-dark); }
.badge-cooldown::before { background: var(--pi-red); }
.badge-onbekend { background: var(--pi-grey-100); color: var(--pi-grey-700); }
.badge-onbekend::before { background: var(--pi-grey-500); }

.score-dot { display:inline-block; width:9px; height:9px; border-radius:2px; margin-right:6px; }
.score-zeer-sterk { background:#0d5c33; }
.score-sterk { background:#2f9e5e; }
.score-matig { background:#e0b400; }
.score-zwak { background:#e2802a; }
.score-zeer-zwak { background:#c8242c; }
.score-onbekend { background:#c7c7cf; }

/* ---------- Layout: split / grid ---------- */
.split { display: grid; grid-template-columns: 1.15fr 1fr; gap: 18px; align-items: start; }
@media (max-width: 1100px) { .split { grid-template-columns: 1fr; } }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.grid-3 { display: grid; grid-template-columns: repeat(3,1fr); gap: 18px; }
@media (max-width: 1000px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } }

.card h3 { margin: 0 0 14px; font-size: 15px; font-weight: 700; }
.card h3 .muted { color: var(--pi-grey-500); font-weight: 500; font-size: 12.5px; }

/* ---------- Map ---------- */
#map { height: 560px; width: 100%; border-radius: var(--pi-radius-sm); overflow: hidden; background: var(--pi-grey-100); }
.map-legend { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; margin-top: 12px; font-size: 12.5px; color: var(--pi-grey-700); }
.map-legend .item { display: flex; align-items: center; gap: 6px; }
.map-legend .sw { width: 12px; height: 12px; border-radius: 3px; }
.leaflet-popup-content-wrapper { border-radius: 10px !important; }

/* ---------- Filters ---------- */
.filterbar { background: var(--pi-white); border-radius: var(--pi-radius); box-shadow: var(--pi-shadow); padding: 16px 18px; margin-bottom: 18px; }
.filterbar-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; }
.filterbar .field { margin-bottom: 0; min-width: 150px; flex: 1; }
.filterbar .field.search { flex: 2; min-width: 220px; }
.filterbar .field label { margin-bottom: 5px; }
.filterbar select, .filterbar input { padding: 9px 11px; font-size: 13.5px; }
.filter-actions { display: flex; gap: 8px; }
.chip-row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.chip {
  padding: 6px 13px; border-radius: 99px; font-size: 12.5px; font-weight: 600;
  border: 1px solid var(--pi-grey-300); color: var(--pi-grey-700); cursor: pointer; background: var(--pi-white);
  transition: all .15s;
}
.chip:hover { border-color: var(--pi-near-black); color: var(--pi-near-black); }
.chip.active { background: var(--pi-near-black); border-color: var(--pi-near-black); color: white; }

/* ---------- Table ---------- */
.table-wrap { background: var(--pi-white); border-radius: var(--pi-radius); box-shadow: var(--pi-shadow); overflow: hidden; }
table.data-table { width: 100%; border-collapse: collapse; font-size: 13.3px; }
table.data-table thead th {
  text-align: left; padding: 12px 14px; background: var(--pi-grey-100); color: var(--pi-grey-700);
  font-size: 11px; text-transform: uppercase; letter-spacing: .5px; font-weight: 700;
  cursor: pointer; user-select: none; white-space: nowrap;
  border-bottom: 1px solid #e2e2e7;
}
table.data-table thead th:hover { color: var(--pi-near-black); }
table.data-table thead th.sorted::after { content: " \25BE"; }
table.data-table tbody td { padding: 11px 14px; border-bottom: 1px solid var(--pi-grey-100); white-space: nowrap; }
table.data-table tbody tr { cursor: pointer; transition: background .12s; }
table.data-table tbody tr:hover { background: #fafafb; }
table.data-table tbody tr:last-child td { border-bottom: none; }
.table-toolbar { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; border-top: 1px solid var(--pi-grey-100); }
.pagination { display: flex; gap: 6px; align-items: center; }
.pagination button {
  border: 1px solid var(--pi-grey-300); background: white; border-radius: 8px; padding: 6px 11px; font-size: 12.5px; cursor: pointer;
}
.pagination button.active { background: var(--pi-near-black); color: white; border-color: var(--pi-near-black); }
.pagination button:disabled { opacity: .4; cursor: not-allowed; }
.pagesize select { border: 1px solid var(--pi-grey-300); border-radius: 8px; padding: 6px 8px; font-size: 12.5px; }

.empty-state { text-align: center; padding: 60px 20px; color: var(--pi-grey-500); }
.empty-state .ic { font-size: 34px; margin-bottom: 10px; }
.skeleton { background: linear-gradient(90deg, var(--pi-grey-100) 25%, #e5e5ea 37%, var(--pi-grey-100) 63%); background-size: 400% 100%; animation: pi-shimmer 1.4s ease infinite; border-radius: 8px; }

/* ---------- Detail panel (drawer) ---------- */
.drawer-overlay { position: fixed; inset: 0; background: rgba(11,11,12,0.45); z-index: 60; opacity: 0; pointer-events: none; transition: opacity .2s; }
.drawer-overlay.open { opacity: 1; pointer-events: auto; }
.drawer { position: fixed; top: 0; right: -460px; width: 440px; max-width: 92vw; height: 100vh; background: white; z-index: 61; box-shadow: var(--pi-shadow-lg); transition: right .25s ease; overflow-y: auto; }
.drawer.open { right: 0; }
.drawer-head { padding: 22px 22px 14px; border-bottom: 1px solid var(--pi-grey-100); display:flex; justify-content: space-between; align-items:flex-start; }
.drawer-head h2 { margin: 0; font-size: 21px; }
.drawer-head .close { cursor: pointer; font-size: 18px; color: var(--pi-grey-500); padding: 4px; }
.drawer-body { padding: 18px 22px 40px; }
.detail-row { display: flex; justify-content: space-between; padding: 9px 0; border-bottom: 1px dashed var(--pi-grey-100); font-size: 13.5px; }
.detail-row .k { color: var(--pi-grey-500); }
.detail-row .v { font-weight: 600; text-align: right; }
.detail-section-title { font-size: 11px; text-transform: uppercase; letter-spacing: .6px; color: var(--pi-grey-500); font-weight: 700; margin: 22px 0 6px; }
.cooldown-box { background: var(--pi-grey-100); border-radius: var(--pi-radius-sm); padding: 14px; margin: 14px 0; }
.cooldown-box .days { font-size: 26px; font-weight: 800; }

/* ---------- Presets (Kansen page) ---------- */
.preset-row { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 18px; }

/* ---------- Progress ---------- */
.progress { height: 8px; background: var(--pi-grey-100); border-radius: 99px; overflow: hidden; }
.progress > div { height: 100%; background: var(--pi-red); transition: width .3s ease; }

/* ---------- Upload dropzone ---------- */
.dropzone {
  border: 2px dashed var(--pi-grey-300); border-radius: var(--pi-radius); padding: 40px 20px; text-align: center;
  color: var(--pi-grey-500); cursor: pointer; transition: border-color .15s, background .15s;
}
.dropzone:hover, .dropzone.dragover { border-color: var(--pi-red); background: var(--pi-red-soft); color: var(--pi-red-dark); }
.dropzone .ic { font-size: 30px; margin-bottom: 8px; }

/* ---------- Misc ---------- */
.muted { color: var(--pi-grey-500); }
.mt-0{margin-top:0} .mb-0{margin-bottom:0}
.flex { display: flex; align-items: center; }
.flex.between { justify-content: space-between; }
.gap-8 { gap: 8px; } .gap-12 { gap: 12px; }
.text-right { text-align: right; }
.small { font-size: 12px; }
.up { color: #146238; } .down { color: var(--pi-red-dark); }

@keyframes pi-fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes pi-slide-up { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
@keyframes pi-shimmer { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }

.count-up { display: inline-block; }

@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); transition: transform .2s; }
  .sidebar.open { transform: translateX(0); }
  .main { margin-left: 0; }
  .topbar { padding: 0 16px; }
  .content { padding: 18px 16px 50px; }
}
