/* ============================================================
   RP-planvoorraad — view-specifieke stijl
   Bouwt voort op styles.css (tokens, topbar, kpi, search).
   ============================================================ */

:root {
  --rp-cell: 18px;      /* ponskaart-cel grootte */
  --rp-cell-gap: 3px;
}

/* Deze view scrollt als document i.p.v. de vaste map-grid */
html.rp, body.rp {
  height: auto;
  overflow: auto;
}
body.rp {
  display: block;
  min-height: 100vh;
}

/* Topbar sticky houden in scrollende view */
.rp .topbar {
  position: sticky;
  top: 0;
  height: var(--h-top);
}

/* Sub-navigatie tussen de twee views */
.viewnav {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 0 4px;
}
.viewnav a {
  font-size: 12px;
  font-weight: 500;
  color: var(--ink-muted);
  padding: 6px 12px;
  border-radius: 4px;
  white-space: nowrap;
}
.viewnav a:hover { background: var(--bg-sunk); color: var(--ink); }
.viewnav a.active { background: var(--ink-strong); color: var(--bg-card); }

/* RP-pagina heeft 3 KPI's (geen "deze snapshot") i.p.v. 4 op de kaart */
body.rp .kpis { grid-template-columns: repeat(3, 1fr); }

/* ---------- KPI delta die ook negatief/positief inkleurt ---------- */
.delta.warn { background: var(--yellow-soft); color: #8a6800; }
.delta.warn::before { content: "△ "; font-size: 9px; }
.delta.good { background: var(--green-soft); color: var(--green-deep); }
.delta.good::before { content: "▼ "; font-size: 9px; }

/* ---------- Hoofdlayout: twee kolommen ---------- */
.rp-main {
  display: grid;
  grid-template-columns: minmax(320px, 4fr) minmax(0, 7fr);
  align-items: start;
  gap: 1px;
  background: var(--line);
  border-bottom: 1px solid var(--line);
}
.rp-col {
  background: var(--bg-card);
  min-width: 0;
}

/* ---------- Linkerkolom: gemeentelijst ---------- */
.gem-head {
  position: sticky; top: var(--h-top);
  background: var(--bg-card);
  border-bottom: 1px solid var(--line);
  padding: 14px 18px 12px;
  z-index: 4;
}
.gem-head h2 {
  font-size: 13px; font-weight: 600; margin: 0;
  color: var(--ink-strong);
  letter-spacing: -0.01em;
}
.gem-head .sub {
  font-size: 11px; color: var(--ink-faint); margin-top: 2px;
}
.gem-sort {
  display: flex; gap: 2px; margin-top: 10px;
}
.gem-sort button {
  border: 1px solid var(--line);
  background: var(--bg-card);
  font-size: 11px; color: var(--ink-muted);
  padding: 4px 9px; border-radius: 4px;
}
.gem-sort button:hover { background: var(--bg-sunk); color: var(--ink); }
.gem-sort button.active { background: var(--ink-strong); color: var(--bg-card); border-color: var(--ink-strong); }

.gem-list { display: flex; flex-direction: column; }
.gem-row {
  display: grid;
  grid-template-columns: 10px 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 11px 18px;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
  border-left: 2px solid transparent;
}
.gem-row:hover { background: var(--bg-sunk); }
.gem-row.selected { background: var(--green-soft); border-left-color: var(--green); }
.gem-dot {
  width: 9px; height: 9px; border-radius: 50%;
  justify-self: center;
}
.gem-dot.green  { background: var(--green); }
.gem-dot.yellow { background: var(--yellow); }
.gem-dot.gray   { background: var(--gray); }
.gem-mid { min-width: 0; }
.gem-name {
  font-size: 13px; font-weight: 500; color: var(--ink);
  display: flex; align-items: center; gap: 7px;
}
.gem-name .code {
  font-family: var(--mono); font-size: 10px; color: var(--ink-faint);
}
.gem-meta {
  font-size: 11px; color: var(--ink-muted);
  margin-top: 3px;
  display: flex; align-items: center; gap: 6px;
}
.gem-meta .mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.gem-meta .sep { color: var(--line-strong); }
.gem-bar {
  width: 64px; height: 5px; background: var(--gray-soft);
  border-radius: 3px; overflow: hidden; margin-top: 5px;
}
.gem-bar > i { display: block; height: 100%; background: var(--green); border-radius: 3px; }
.gem-right { text-align: right; }
.gem-pct {
  font-family: var(--mono); font-size: 14px; font-weight: 600;
  color: var(--ink-strong); font-variant-numeric: tabular-nums;
}
.gem-pct .u { font-size: 10px; color: var(--ink-faint); font-weight: 500; }
.gem-sub2 { font-size: 10px; color: var(--ink-faint); margin-top: 2px; }
.gem-flag {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 16px; height: 16px; padding: 0 4px;
  border-radius: 8px;
  background: var(--yellow-soft); color: #8a6800;
  font-family: var(--mono); font-size: 10px; font-weight: 600;
  margin-left: 2px;
}

/* ---------- Rechterkolom: detailpaneel ---------- */
.detail-head {
  position: sticky; top: var(--h-top);
  background: var(--bg-card);
  border-bottom: 1px solid var(--line);
  padding: 16px 22px 0;
  z-index: 3;
}
.detail-title-row {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 16px;
}
.detail-title {
  font-size: 22px; font-weight: 600; letter-spacing: -0.02em;
  color: var(--ink-strong); margin: 0;
}
.detail-sub {
  font-size: 12px; color: var(--ink-muted); margin-top: 3px;
  display: flex; align-items: center; gap: 8px;
}
.detail-sub .mono { font-family: var(--mono); }
.detail-stats {
  display: flex; gap: 22px;
  padding: 14px 0 14px;
}
.dstat .v {
  font-family: var(--mono); font-size: 22px; font-weight: 600;
  color: var(--ink-strong); font-variant-numeric: tabular-nums; line-height: 1;
}
.dstat .v.green { color: var(--green); }
.dstat .v.yellow { color: var(--yellow); }
.dstat .l {
  font-size: 10px; text-transform: uppercase; letter-spacing: 0.07em;
  color: var(--ink-muted); margin-top: 5px; font-weight: 500;
}

/* ---------- Filterbalk ---------- */
.filterbar {
  position: sticky; top: calc(var(--h-top));
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px;
  padding: 12px 22px;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
  border-top: 1px solid var(--line);
  z-index: 2;
}
.fb-group { display: flex; align-items: center; gap: 6px; }
.fb-label {
  font-size: 10px; text-transform: uppercase; letter-spacing: 0.07em;
  color: var(--ink-faint); font-weight: 600;
}
.class-toggle {
  display: inline-flex; align-items: center; gap: 6px;
  border: 1px solid var(--line-strong);
  background: var(--bg-card);
  padding: 5px 10px 5px 8px;
  border-radius: 14px;
  font-size: 12px; color: var(--ink-muted);
  user-select: none;
}
.class-toggle:hover { border-color: var(--ink-faint); }
.class-toggle .chip-dot {
  width: 9px; height: 9px; border-radius: 50%;
}
.class-toggle.green  .chip-dot { background: var(--green); }
.class-toggle.yellow .chip-dot { background: var(--yellow); }
.class-toggle.gray   .chip-dot { background: var(--gray); }
.class-toggle .cnt {
  font-family: var(--mono); font-size: 10px; color: var(--ink-faint);
  font-variant-numeric: tabular-nums;
}
.class-toggle.on { color: var(--ink); background: var(--bg-sunk); border-color: var(--ink-faint); }
.class-toggle.off { opacity: 0.45; text-decoration: line-through; }
.class-toggle.off .chip-dot { background: var(--gray) !important; }

.fb-select, .fb-search {
  height: 30px;
  border: 1px solid var(--line-strong);
  border-radius: 5px;
  background: var(--bg-card);
  font-size: 12px; color: var(--ink);
  padding: 0 10px;
  outline: none;
}
.fb-search { padding-left: 30px; width: 200px; }
.fb-search-wrap { position: relative; }
.fb-search-wrap svg {
  position: absolute; left: 9px; top: 50%; transform: translateY(-50%);
  width: 14px; height: 14px; color: var(--ink-faint); pointer-events: none;
}
.fb-select:focus, .fb-search:focus {
  border-color: var(--green); box-shadow: 0 0 0 3px rgba(31,107,67,0.12);
}
.fb-spacer { flex: 1; }
.fb-period {
  font-family: var(--mono); font-size: 11px; color: var(--ink-muted);
  font-variant-numeric: tabular-nums;
}

/* ---------- Planlijst ---------- */
.planlist { padding: 6px 0 24px; }
.plan-row {
  display: grid;
  grid-template-columns: 138px 1fr auto;
  gap: 18px;
  align-items: center;
  padding: 14px 22px;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
}
.plan-row:hover { background: var(--bg-sunk); }

/* datum-blok (vervangt de ponskaart-cellen rechts in de rij) */
.plan-dates {
  display: flex; flex-direction: column; gap: 6px;
  align-items: flex-end; min-width: 168px;
}
.pd-row { display: flex; align-items: baseline; gap: 8px; }
.pd-label {
  font-size: 10px; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--ink-faint); font-weight: 600;
}
.pd-val {
  font-family: var(--mono); font-size: 12px; color: var(--ink-strong);
  font-variant-numeric: tabular-nums; min-width: 84px; text-align: right;
}
.pd-val.weg { color: var(--green-deep); font-weight: 600; }
.pd-val.nu  { color: var(--ink-muted); font-family: var(--sans); }

/* statusbadge */
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 9px 4px 7px;
  border-radius: 5px;
  font-size: 11px; font-weight: 600;
  border: 1px solid transparent;
  white-space: nowrap;
}
.badge .bg {
  width: 16px; height: 16px; border-radius: 4px;
  display: grid; place-items: center;
  font-size: 11px; color: #fff; line-height: 1;
}
.badge.green  { background: var(--green-soft); color: var(--green-deep); border-color: rgba(31,107,67,0.2); }
.badge.green .bg { background: var(--green); }
.badge.yellow { background: var(--yellow-soft); color: #8a6800; border-color: rgba(212,160,23,0.28); }
.badge.yellow .bg { background: var(--yellow); }
.badge.gray   { background: var(--gray-soft); color: var(--ink-muted); border-color: var(--line-strong); }
.badge.gray .bg { background: var(--gray); }

.plan-mid { min-width: 0; }
.plan-badge {
  display: flex; flex-direction: column; align-items: flex-start; gap: 6px;
}
.weg-date {
  font-family: var(--mono); font-size: 11px; font-weight: 500;
  color: var(--green-deep);
  font-variant-numeric: tabular-nums;
  padding-left: 1px;
}
.plan-titel {
  font-size: 14px; font-weight: 500; color: var(--ink-strong);
  letter-spacing: -0.01em;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.plan-ids {
  display: flex; align-items: center; gap: 10px; margin-top: 4px;
  font-family: var(--mono); font-size: 11px; color: var(--ink-faint);
  font-variant-numeric: tabular-nums;
}
.plan-ids .imro { color: var(--ink-muted); }
.plan-tags { display: flex; gap: 6px; margin-top: 7px; }
.tag {
  font-size: 10px; color: var(--ink-muted);
  background: var(--bg-sunk);
  border: 1px solid var(--line);
  padding: 2px 7px; border-radius: 3px;
  letter-spacing: 0.01em;
}
.tag.proc { background: var(--yellow-soft); color: #8a6800; border-color: rgba(212,160,23,0.28); }

/* planstatus-chip — duidelijk zichtbaar */
.pstatus {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 11px; font-weight: 600;
  padding: 3px 9px; border-radius: 4px;
  border: 1px solid var(--line-strong);
  white-space: nowrap;
}
.pstatus .d { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }
.pstatus.ink    { color: var(--ink-strong); background: var(--bg-sunk); border-color: var(--line-strong); }
.pstatus.ink .d { background: var(--ink-strong); }
.pstatus.green    { color: var(--green-deep); background: var(--green-soft); border-color: rgba(31,107,67,0.22); }
.pstatus.green .d { background: var(--green); }
.pstatus.yellow    { color: #8a6800; background: var(--yellow-soft); border-color: rgba(212,160,23,0.3); }
.pstatus.yellow .d { background: var(--yellow); }
.pstatus.gray    { color: var(--ink-muted); background: var(--gray-soft); border-color: var(--line-strong); }
.pstatus.gray .d { background: var(--gray); }

/* extra chip-dot kleur voor planstatus-toggle */
.class-toggle.ink .chip-dot { background: var(--ink-strong); }

/* ---------- Ponskaart-tijdlijn (hero) ---------- */
.punchcard {
  display: flex; flex-direction: column; gap: 5px;
  align-items: flex-end;
}
.pc-cells {
  display: flex; gap: var(--rp-cell-gap);
}
.pc-cell {
  width: var(--rp-cell); height: var(--rp-cell);
  border-radius: 3px;
  background: var(--bg-sunk);
  border: 1px solid var(--line);
  position: relative;
  transition: transform .1s;
}
.pc-cell.filled { background: var(--ink-strong); border-color: var(--ink-strong); }
.pc-cell.filled.green  { background: var(--green); border-color: var(--green); }
.pc-cell.filled.yellow { background: var(--yellow); border-color: var(--yellow); }
.pc-cell.filled.gray   { background: var(--gray); border-color: var(--gray); }
/* "gat" geponst — kleine binnenstip om punch-metafoor te versterken */
.pc-cell.filled::after {
  content: ""; position: absolute; inset: 0; margin: auto;
  width: 4px; height: 4px; border-radius: 50%;
  background: rgba(255,255,255,0.55);
}
/* terugkeer-cel: ring rond de gevulde cel */
.pc-cell.returned { box-shadow: 0 0 0 2px var(--bg-card), 0 0 0 3px var(--yellow); }
.pc-cell:hover { transform: scale(1.18); z-index: 2; }
.pc-axis {
  display: flex; gap: var(--rp-cell-gap);
  font-family: var(--mono); font-size: 8px; color: var(--ink-faint);
}
.pc-axis span {
  width: var(--rp-cell); text-align: center;
}
.pc-pattern {
  font-family: var(--mono); font-size: 11px; color: var(--ink-faint);
  letter-spacing: 1px;
}

/* hover-tooltip op cel */
.pc-tip {
  position: fixed;
  pointer-events: none;
  background: var(--ink-strong); color: var(--bg-card);
  font-size: 11px; padding: 6px 9px; border-radius: 5px;
  z-index: 200; max-width: 220px;
  box-shadow: var(--shadow-md);
  transition: opacity .1s;
}
.pc-tip .d { font-family: var(--mono); font-weight: 600; }
.pc-tip .s { color: var(--gray-soft); margin-top: 2px; display: block; }
.pc-tip[hidden] { display: none; }

/* ---------- Lege/klaar-staat ---------- */
.empty-done {
  margin: 40px 22px;
  border: 1px solid rgba(31,107,67,0.25);
  background: var(--green-soft);
  border-radius: var(--radius);
  padding: 40px 32px;
  text-align: center;
  display: flex; flex-direction: column; align-items: center; gap: 14px;
}
.empty-done .ico {
  width: 56px; height: 56px; border-radius: 50%;
  background: var(--green); color: #fff;
  display: grid; place-items: center; font-size: 28px;
  box-shadow: 0 0 0 6px rgba(31,107,67,0.14);
}
.empty-done h3 {
  font-size: 20px; font-weight: 600; color: var(--green-deep); margin: 0;
  letter-spacing: -0.01em;
}
.empty-done p {
  font-size: 13px; color: var(--ink-muted); margin: 0; max-width: 440px;
  line-height: 1.55;
}
.empty-done .meta {
  font-family: var(--mono); font-size: 12px; color: var(--green-deep);
  background: var(--bg-card); border: 1px solid rgba(31,107,67,0.25);
  padding: 6px 12px; border-radius: 5px;
}

.no-results {
  padding: 48px 22px; text-align: center;
  color: var(--ink-faint); font-size: 13px;
}

/* ---------- Loading skeletons (ponskaart-stijl) ---------- */
.skel-row {
  display: grid; grid-template-columns: 138px 1fr auto; gap: 18px;
  align-items: center; padding: 14px 22px; border-bottom: 1px solid var(--line);
}
.skel { background: var(--bg-sunk); border-radius: 4px; position: relative; overflow: hidden; }
.skel::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.6), transparent);
  animation: shimmer 1.3s infinite;
}
@keyframes shimmer { 100% { transform: translateX(200%); } }
.skel-cells { display: flex; gap: var(--rp-cell-gap); }
.skel-cell { width: var(--rp-cell); height: var(--rp-cell); border-radius: 3px; background: var(--bg-sunk); }
.skel-cell.on { background: var(--gray-soft); }

/* ---------- Detail-overlay ---------- */
.overlay-scrim {
  position: fixed; inset: 0;
  background: rgba(26,26,23,0.42);
  z-index: 100;
  display: flex; align-items: flex-start; justify-content: center;
  padding: 56px 20px;
  overflow-y: auto;
}
.overlay-scrim[hidden] { display: none; }
.overlay {
  background: var(--bg-card);
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  box-shadow: var(--shadow-md);
  width: 100%; max-width: 720px;
  overflow: hidden;
}
.ov-head {
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--line);
  display: flex; align-items: flex-start; justify-content: space-between; gap: 16px;
}
.ov-titel { font-size: 19px; font-weight: 600; color: var(--ink-strong); margin: 0; letter-spacing: -0.01em; }
.ov-sub { font-size: 12px; color: var(--ink-muted); margin-top: 4px; }
.ov-close {
  border: 1px solid var(--line-strong); background: var(--bg-card);
  width: 30px; height: 30px; border-radius: 5px;
  display: grid; place-items: center; color: var(--ink-muted); font-size: 16px;
  flex-shrink: 0;
}
.ov-close:hover { background: var(--bg-sunk); color: var(--ink); }
.ov-body { padding: 20px 24px 24px; }

.ov-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 1px;
  background: var(--line); border: 1px solid var(--line);
  border-radius: var(--radius); overflow: hidden; margin-bottom: 20px;
}
.ov-kv { background: var(--bg-card); padding: 10px 14px; }
.ov-kv .k {
  font-size: 10px; text-transform: uppercase; letter-spacing: 0.07em;
  color: var(--ink-muted); font-weight: 500;
}
.ov-kv .v {
  font-family: var(--mono); font-size: 13px; color: var(--ink-strong);
  margin-top: 4px; word-break: break-all; font-variant-numeric: tabular-nums;
}
.ov-kv .v.sans { font-family: var(--sans); }

.ov-section-h {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.07em;
  color: var(--ink-muted); font-weight: 600; margin: 22px 0 12px;
  display: flex; align-items: center; gap: 8px;
}
.ov-section-h::after { content: ""; flex: 1; height: 1px; background: var(--line); }

.ov-timeline { padding: 4px 0 8px; }

/* weggehaald-callout in overlay */
.weg-callout {
  display: flex; align-items: center; gap: 14px;
  background: var(--green-soft);
  border: 1px solid rgba(31,107,67,0.25);
  border-radius: var(--radius);
  padding: 14px 16px;
}
.weg-callout .wc-ico {
  flex-shrink: 0; width: 34px; height: 34px; border-radius: 50%;
  background: var(--green); color: #fff; display: grid; place-items: center;
  font-size: 17px;
}
.weg-callout .wc-date {
  font-family: var(--mono); font-size: 17px; font-weight: 600;
  color: var(--green-deep); font-variant-numeric: tabular-nums;
}
.weg-callout .wc-sub {
  font-size: 12px; color: var(--ink-muted); margin-top: 3px; line-height: 1.5;
}

/* diff-blok */
.diff {
  border: 1px solid var(--line); border-radius: var(--radius);
  overflow: hidden;
}
.diff-row {
  display: grid; grid-template-columns: 120px 1fr 1fr;
  border-bottom: 1px solid var(--line);
  font-size: 12px;
}
.diff-row:last-child { border-bottom: 0; }
.diff-row .dh {
  background: var(--bg-sunk); padding: 9px 12px;
  font-size: 10px; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--ink-muted); font-weight: 600; display: flex; align-items: center;
}
.diff-row .dv {
  padding: 9px 12px; font-family: var(--mono); color: var(--ink);
  word-break: break-all; border-left: 1px solid var(--line);
}
.diff-row.head .dv { font-weight: 600; font-family: var(--sans); font-size: 10px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--ink-faint); }
.diff-old { color: var(--ink-muted); }
.diff-new { color: var(--green-deep); background: var(--green-soft); }
.diff-flag {
  margin-top: 12px;
  display: flex; align-items: flex-start; gap: 10px;
  background: var(--yellow-soft); border: 1px solid rgba(212,160,23,0.3);
  border-radius: var(--radius); padding: 12px 14px;
  font-size: 12px; color: #7a5c00; line-height: 1.5;
}
.diff-flag .fi {
  flex-shrink: 0; width: 20px; height: 20px; border-radius: 50%;
  background: var(--yellow); color: #fff; display: grid; place-items: center;
  font-size: 12px; font-weight: 700;
}
.diff-note {
  font-size: 12px; color: var(--ink-muted); margin-top: 12px; line-height: 1.55;
}
.diff-note b { color: var(--ink); font-weight: 600; }

/* ---------- Footer-strip ---------- */
.rp-foot {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  flex-wrap: wrap;
  padding: 16px 22px 28px;
  font-size: 11px; color: var(--ink-faint); line-height: 1.5;
}
.rp-foot .legenda { display: flex; gap: 16px; flex-wrap: wrap; }
.rp-foot .lg { display: inline-flex; align-items: center; gap: 6px; }
.rp-foot .lg .chip-dot { width: 9px; height: 9px; border-radius: 50%; }
.rp-foot .lg.green .chip-dot { background: var(--green); }
.rp-foot .lg.yellow .chip-dot { background: var(--yellow); }
.rp-foot .lg.gray .chip-dot { background: var(--gray); }

@media (max-width: 980px) {
  .rp-main { grid-template-columns: 1fr; }
  .plan-row { grid-template-columns: 1fr; gap: 12px; }
  .punchcard { align-items: flex-start; }
  .gem-head, .detail-head { position: static; }
}
@media (max-width: 1100px) {
  .kpi-value { font-size: 40px; }
}
