:root {
  --dark-blue: #003584;
  --green: #33A92F;
  --faded-blue: #75A8C1;
  --orange: #FF6428;
  --bright-blue: #3C8CFA;
  --yellow: #FAC850;
  --light-green: #D2E9C8;
  --warm-grey: #998E83;
  --white: #FFFFFF;
  --eggshell: #F0ECEA;
  --anthracite: #2D2D2D;
  --text: #505050;

  --font: "Helvetica Now Text", "Helvetica Now", "Helvetica Neue", Helvetica, Arial, sans-serif;
  --bar-h: 52px;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: var(--font);
  color: var(--text);
  background: var(--white);
  display: grid;
  grid-template-rows: var(--bar-h) 1fr;
  height: 100dvh;
  overflow: hidden;
}
button { font: inherit; color: inherit; }

/* header */
.bar {
  background: var(--dark-blue);
  color: var(--white);
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 20px;
  min-width: 0;
}
.bar h1 {
  font-size: 18px;
  font-weight: 700;
  margin: 0;
  color: var(--white);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1 1 auto;
  min-width: 0;
}
.controls { display: flex; align-items: center; gap: 12px; flex: 0 0 auto; }
.seg {
  display: flex;
  align-items: center;
  background: rgba(255, 255, 255, .12);
  border-radius: 999px;
  padding: 3px;
}
.seg-label { font-size: 12px; padding: 0 8px 0 10px; color: var(--eggshell); }
.seg button {
  border: 0;
  background: transparent;
  color: var(--white);
  font-size: 13px;
  font-weight: 500;
  padding: 5px 12px;
  border-radius: 999px;
  cursor: pointer;
}
.seg button.on { background: var(--white); color: var(--dark-blue); font-weight: 700; }
.seg button:focus-visible, .ghost:focus-visible, .el:focus-visible { outline: 2px solid var(--bright-blue); outline-offset: 2px; }
#q {
  width: 220px;
  border: 0;
  border-radius: 999px;
  padding: 7px 14px;
  font: inherit;
  font-size: 13px;
  color: var(--anthracite);
  background: var(--white);
}
.ghost {
  border: 1px solid rgba(255, 255, 255, .6);
  background: transparent;
  color: var(--white);
  width: 30px;
  height: 30px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 15px;
  line-height: 1;
}

/* stage */
.stage { position: relative; min-height: 0; overflow: hidden; }
.table-wrap { position: absolute; inset: 0; padding: 12px 16px 14px; overflow: auto; }
.table {
  display: grid;
  grid-template-columns: repeat(18, minmax(0, 1fr));
  grid-template-rows: repeat(7, minmax(0, 1fr)) 22px repeat(2, minmax(0, 1fr));
  gap: 4px;
  height: 100%;
  min-height: 560px;
  min-width: 980px;
}

/* element */
.el {
  container-type: size;
  position: relative;
  border: 1px solid rgba(45, 45, 45, .25);
  border-radius: 3px;
  padding: 0;
  background: var(--white);
  color: var(--anthracite);
  cursor: pointer;
  overflow: hidden;
  text-align: left;
  transition: opacity .2s, filter .2s, transform .12s;
}
.el:hover { transform: scale(1.04); z-index: 2; box-shadow: 0 0 0 2px var(--dark-blue); }
.el.sel { box-shadow: 0 0 0 3px var(--orange); z-index: 3; }
.el.dim { opacity: .18; filter: grayscale(1); }
.el.priv { border: 2px dashed var(--orange); }
.el .nm {
  position: absolute; left: 0; right: 0; top: 0; height: 17%;
  padding: 0 4%;
  background: var(--band, var(--eggshell)); color: var(--band-ink, var(--anthracite));
  font-size: 9.5cqh; font-weight: 700; line-height: 17cqh;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.el img {
  position: absolute; left: 4%; top: 21%; width: 58%; height: 59%;
  object-fit: cover; border-radius: 2px;
}
.el .mass { position: absolute; right: 5%; top: 19%; font-size: 13cqh; font-weight: 700; }
.el .h {
  position: absolute; right: 5%; top: 39%;
  font-size: 13cqh; font-weight: 700; line-height: 1;
  border: 1px solid currentColor; padding: 1px 3px; border-radius: 2px;
}
.el .val { position: absolute; right: 6%; top: 60%; font-size: 12cqh; font-weight: 500; opacity: .75; }
.el .yr { position: absolute; left: 4%; bottom: 3%; font-size: 10.5cqh; font-weight: 700; }
.el .disc { font-weight: 400; margin-left: .35em; font-size: .85em; }
.el .kv {
  position: absolute; right: 3%; bottom: 3%;
  font-size: 10.5cqh; font-weight: 700; padding: 0 4px; border-radius: 2px; line-height: 1.3;
}
.est { font-style: italic; }
.est::before { content: "≈"; font-weight: 400; }

/* voltage badges */
.kv.k50 { background: var(--kv-50); color: var(--anthracite); }
.kv.k110 { background: var(--kv-110); color: var(--white); }
.kv.k150 { background: var(--kv-150); color: var(--white); }
.kv.k220 { background: var(--kv-220); color: var(--anthracite); }
.kv.k380 { background: var(--kv-380); color: var(--anthracite); }
.kv.hyb { color: var(--white); text-shadow: 0 0 2px rgba(0, 0, 0, .7); }

/* insets in the empty parts of the table */
.inset { min-width: 0; min-height: 0; }
.kpis { grid-row: 1; grid-column: 2 / 18; min-height: 0; overflow: hidden; display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 8px; align-items: stretch; }
.kpi {
  background: var(--eggshell); border: 0; border-radius: 4px; padding: 8px 12px; text-align: left; cursor: pointer;
  display: flex; flex-direction: column; justify-content: center; min-width: 0; min-height: 0; overflow: hidden;
}
.kpi:hover { box-shadow: inset 0 0 0 2px var(--dark-blue); }
.kpi small { font-size: 12px; color: var(--text); }
.kpi b { font-size: clamp(16px, min(2.4vw, 3.2vh), 30px); color: var(--dark-blue); line-height: 1.1; }
.kpi span { font-size: 12px; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.legend-box { grid-row: 2 / 4; grid-column: 3 / 9; display: flex; flex-direction: column; min-height: 0; padding: 4px 8px 0 4px; }
.legend-box h2, .decades h2 { font-size: 14px; color: var(--dark-blue); margin: 0 0 2px; }
.legend-box p, .decades p { font-size: 12px; margin: 0 0 6px; }
.legend { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 3px 10px; overflow: auto; min-height: 0; align-content: start; }
.legend button {
  display: flex; align-items: center; gap: 7px; background: none; border: 0; padding: 3px 4px;
  font-size: 12.5px; cursor: pointer; border-radius: 3px; text-align: left; color: var(--anthracite);
}
.legend button:hover, .legend button.on { background: var(--eggshell); }
.legend button.on { font-weight: 700; }
.legend i { width: 16px; height: 16px; border-radius: 2px; flex: 0 0 auto; border: 1px solid rgba(45, 45, 45, .3); }
.legend em { font-style: normal; margin-left: auto; color: var(--warm-grey); font-size: 11.5px; }

.decades { grid-row: 2 / 4; grid-column: 9 / 13; display: flex; flex-direction: column; min-height: 0; padding: 4px 4px 0 12px; }
.bars { flex: 1; display: flex; align-items: flex-end; gap: 4px; min-height: 0; padding-bottom: 18px; position: relative; }
.bars button {
  flex: 1; background: var(--dark-blue); border: 0; border-radius: 2px 2px 0 0; position: relative; cursor: pointer; padding: 0; min-height: 2px;
}
.bars button:hover, .bars button.on { background: var(--orange); }
.bars button span { position: absolute; bottom: -17px; left: 50%; transform: translateX(-50%); font-size: 10.5px; color: var(--text); }
.bars button b { position: absolute; top: -15px; left: 50%; transform: translateX(-50%); font-size: 10.5px; color: var(--dark-blue); }

.series-label {
  display: flex; flex-direction: column; justify-content: center; padding: 6px 8px; border-radius: 3px;
  font-size: 12px; color: var(--anthracite); line-height: 1.25;
}
.series-label b { font-size: 13px; }
.series-label.combinatie { background: #99D497; }
.series-label.onvolledig { background: #FFB293; }
.series-label.wide { grid-column: 1 / 3; overflow: hidden; container-type: size; }
.series-label.wide b { font-size: min(13px, 8.5cqw); overflow-wrap: anywhere; }
.series-label.wide span { font-size: min(12px, 7.5cqw); }
.series-label.slot { grid-column: 3; overflow: hidden; container-type: size; padding: 4px 6px; }
.series-label.slot b { font-size: min(13px, 15cqw); hyphens: manual; overflow-wrap: anywhere; }
.series-label.slot span { font-size: min(11px, 12cqw); }
.bracket {
  grid-row: 8; align-self: end; border: 2px solid var(--anthracite); border-bottom: 0; height: 8px;
  font-size: 11px; position: relative; margin: 0 2px;
}
.bracket span { position: absolute; bottom: 9px; left: 0; right: 0; text-align: center; white-space: nowrap; color: var(--text); }

/* drawer */
.drawer {
  position: absolute; top: 0; right: 0; bottom: 0; width: min(380px, 100%);
  background: var(--white); border-left: 4px solid var(--dark-blue);
  transform: translateX(105%); transition: transform .25s ease; z-index: 10;
  padding: 18px 20px; overflow: auto;
}
.drawer.open { transform: none; }
.drawer .close {
  position: absolute; top: 10px; right: 12px; border: 0; background: var(--eggshell); width: 30px; height: 30px;
  border-radius: 50%; font-size: 18px; cursor: pointer; color: var(--dark-blue);
}
.drawer h2 { color: var(--dark-blue); font-size: 22px; margin: 0 36px 4px 0; line-height: 1.2; }
.drawer h3 { color: var(--dark-blue); font-size: 15px; margin: 14px 0 4px; }
.drawer p { font-size: 14px; line-height: 1.45; margin: 6px 0; }
.drawer .fam { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 500; }
.drawer .fam i { width: 14px; height: 14px; border-radius: 2px; border: 1px solid rgba(45, 45, 45, .3); }
.drawer .tile { display: block; width: 100%; height: min(46vh, 420px); object-fit: cover; margin: 12px 0 8px; border-radius: 4px; background: var(--eggshell); }
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin: 8px 0; }
.stat { background: var(--eggshell); border-radius: 4px; padding: 8px 10px; }
.stat small { display: block; font-size: 11.5px; }
.stat b { font-size: 18px; color: var(--dark-blue); }
.flag { background: var(--light-green); color: var(--anthracite); padding: 6px 10px; border-radius: 4px; font-size: 13px; margin: 8px 0; }
.flag.priv { background: #FFD8C9; }
.drawer a { color: var(--dark-blue); }
.nav { display: flex; gap: 8px; margin-top: 12px; }
.nav button { flex: 1; border: 1px solid var(--dark-blue); background: var(--white); color: var(--dark-blue); border-radius: 999px; padding: 7px; cursor: pointer; font-weight: 500; font-size: 13px; }
.nav button:hover { background: var(--dark-blue); color: var(--white); }
.key { display: grid; grid-template-columns: auto 1fr; gap: 6px 12px; font-size: 13px; margin: 6px 0; }
.key dt { font-weight: 700; color: var(--anthracite); }
.key dd { margin: 0; }
.priv-swatch { display: inline-block; width: 26px; height: 14px; border: 2px dashed var(--orange); border-radius: 2px; vertical-align: middle; }
.credit { font-size: 12px; color: var(--warm-grey); }

/* small screens: table scrolls inside its panel, header compacts */
@media (max-width: 900px) {
  :root { --bar-h: 128px; }
  .bar { flex-wrap: wrap; align-content: center; gap: 6px 10px; padding: 6px 12px; }
  .bar h1 { font-size: 15px; flex-basis: 100%; }
  .controls { flex: 1 1 100%; gap: 8px; flex-wrap: wrap; }
  .seg { flex: 1 1 100%; justify-content: space-between; }
  .seg-label { display: none; }
  .seg button { padding: 5px 9px; font-size: 12px; }
  #q { width: auto; flex: 1; min-width: 0; }
  .table-wrap { padding: 8px; }
}
