/* ══════════════════════════════════════════════════════════════════
   Servei · Gestió del coneixement — l'Observatori (lab)
   ------------------------------------------------------------------
   Styles for the cross-filtered dashboard that srv-coneixement-lab.js
   builds inside [data-gc-mount="lab"]. Every selector here targets
   nodes the script creates (.gc-lab*), so without JS nothing in this
   file applies and the shell's static poster table stays as it is.

   Posture: a white instrument on the ruled bone page, newspaper-table
   hairlines (the 1px grid gap shows the line colour through), mono for
   everything that is «system», Inter Tight 800 for the figures.
   Accents: teal + magenta only. Selection is a 2px ink outline, never
   yellow; teal is a fill, never text; magenta text never appears.
   ══════════════════════════════════════════════════════════════════ */

.gc-lab {
  --gc-lab-pad: clamp(16px, 1.9vw, 24px);
  --gc-lab-tint: rgba(17, 17, 17, .035);
  --gc-lab-teal-a: rgba(27, 182, 162, .6);
  position: relative;
  color: var(--gc-fg);
}
/* Zero-specificity reset so every button class below can set its own type. */
:where(.gc-lab, .gc-lab__sheet) button { font: inherit; color: inherit; }

.gc-lab__frame {
  position: relative;
  background: var(--pz-white);
  border: 1px solid var(--gc-line-strong);
  border-radius: 1px;
}

/* ─── Control bar (sticky inside the frame) ─────────────────────── */
.gc-lab__bar {
  position: sticky;
  top: calc(var(--gc-nav-h) + 2px);
  z-index: var(--gc-z-sticky);
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  grid-template-areas: "count ctrls" "count filters";
  align-items: center;
  column-gap: clamp(20px, 2.4vw, 36px);
  row-gap: 10px;
  padding: 14px var(--gc-lab-pad) 12px;
  background: var(--pz-white);
  border-bottom: 1px solid var(--gc-line-strong);
}
.gc-lab__bar.is-flash { animation: gc-lab-flash 400ms var(--gc-ease); }
/* Keyboard focus below the bar: the root scroll-padding clears the nav,
   this margin clears the sticky bar too (its height is published on
   <html> by the lab script while the lab is on screen), and the bottom
   one keeps controls above the dock. HTML controls and SVG marks alike. */
.gc-lab__kpis button,
.gc-lab__grid :is(button, [tabindex]),
.gc-lab__rows button {
  scroll-margin-top: calc(var(--gc-lab-bar-h, 0px) + 12px);
  scroll-margin-bottom: 12px;
}
@keyframes gc-lab-flash {
  0%   { outline: 2px solid var(--pz-ink); outline-offset: -2px; }
  100% { outline: 2px solid transparent; outline-offset: -2px; }
}

.gc-lab__count {
  grid-area: count;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
  align-self: stretch;
  justify-content: center;
  padding-right: clamp(20px, 2.4vw, 36px);
  border-right: 1px solid var(--gc-line);
}
.gc-lab__cpre,
.gc-lab__segl,
.gc-lab__fl,
.gc-lab__kl,
.gc-lab__pk,
.gc-lab__sheett {
  font-family: var(--gc-mono);
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--gc-mute);
}
.gc-lab__crow { display: flex; align-items: baseline; gap: 10px; white-space: nowrap; }
.gc-lab__cn {
  font-family: var(--gc-display);
  font-weight: 800;
  font-size: 40px;
  line-height: .9;
  letter-spacing: -0.045em;
  font-variant-numeric: tabular-nums;
  min-width: 2.6ch;
}
.gc-lab__cpost,
.gc-lab__ccompact {
  font-family: var(--gc-mono);
  font-size: 12px;
  color: var(--gc-mute);
}
.gc-lab__ccompact { display: none; }

.gc-lab__ctrls {
  grid-area: ctrls;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 20px;
  min-width: 0;
}
.gc-lab__acts { display: flex; flex-wrap: wrap; gap: 6px; margin-left: auto; }

/* Segmented controls */
.gc-lab__seg { display: inline-flex; align-items: center; gap: 10px; }
.gc-lab__segb {
  display: inline-flex;
  gap: 2px;
  padding: 2px;
  border: 1px solid var(--gc-line-strong);
  border-radius: 2px;
}
.gc-lab__segbtn {
  font-family: var(--gc-mono);
  font-size: 11px;
  letter-spacing: .02em;
  padding: 5px 10px;
  border: 0;
  border-radius: 1px;
  background: transparent;
  cursor: pointer;
  white-space: nowrap;
  transition: background-color 200ms ease, color 200ms ease;
}
.gc-lab__segbtn:hover { background: var(--gc-lab-tint); }
.gc-lab__segbtn[aria-pressed="true"] { background: var(--pz-ink); color: var(--pz-bone); }
.gc-lab__seg--sm .gc-lab__segl {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap;
}
.gc-lab__seg--sm .gc-lab__segbtn { padding: 4px 8px; font-size: 10.5px; }

/* Text actions */
.gc-lab__act,
.gc-lab__tbtn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-family: var(--gc-mono);
  font-size: 11px;
  letter-spacing: .02em;
  padding: 6px 10px;
  border: 1px solid var(--gc-line-strong);
  border-radius: 2px;
  background: transparent;
  cursor: pointer;
  white-space: nowrap;
  transition: background-color 200ms ease, color 200ms ease, border-color 200ms ease, opacity 200ms ease;
}
.gc-lab__act:hover:not(:disabled),
.gc-lab__tbtn:hover {
  background: var(--pz-ink);
  border-color: var(--pz-ink);
  color: var(--pz-bone);
}
.gc-lab__act[aria-pressed="true"],
.gc-lab__tbtn[aria-pressed="true"] {
  background: var(--pz-ink);
  border-color: var(--pz-ink);
  color: var(--pz-bone);
}
.gc-lab__act:disabled { opacity: .38; cursor: default; }
.gc-lab__ico { font-size: 12px; line-height: 1; }

/* Active filters */
.gc-lab__filters {
  grid-area: filters;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 10px;
  min-height: 30px;
  padding-top: 9px;
  border-top: 1px dashed var(--gc-line);
}
.gc-lab__chips { list-style: none; display: flex; flex-wrap: wrap; gap: 6px; margin: 0; padding: 0; }
.gc-lab__chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--gc-mono);
  font-size: 11px;
  line-height: 1.3;
  padding: 0 0 0 8px;
  border: 1px solid var(--pz-ink);
  border-radius: 2px;
  background: var(--pz-white);
  animation: gc-lab-chip 240ms var(--gc-ease) both;
}
@keyframes gc-lab-chip {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: none; }
}
.gc-lab__chipc { color: var(--gc-mute); }
.gc-lab__chipx {
  display: inline-grid;
  place-items: center;
  width: 24px;
  height: 24px;
  margin-left: 2px;
  border: 0;
  border-left: 1px solid var(--gc-line);
  background: transparent;
  font-family: var(--gc-mono);
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  transition: background-color 160ms ease, color 160ms ease;
}
.gc-lab__chipx:hover { background: var(--pz-ink); color: var(--pz-bone); }
.gc-lab__none {
  font-family: var(--gc-mono);
  font-size: 11px;
  color: var(--gc-mute);
}

.gc-lab__mbtn { display: none; }

/* Raw-corpus warning and the transient clean deltas */
.gc-lab__warn {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 0;
  padding: 10px var(--gc-lab-pad);
  font-family: var(--gc-mono);
  font-size: 11.5px;
  line-height: 1.5;
  color: var(--pz-ink);
  background: rgba(216, 74, 203, .07);
  border-bottom: 1px solid var(--gc-line);
  animation: gc-lab-drop 320ms var(--gc-ease) both;
}
.gc-lab__warn::before {
  content: "";
  flex: none;
  align-self: stretch;
  width: 3px;
  min-height: 16px;
  background: var(--gc-magenta);
}
.gc-lab__warn.is-clean { background: rgba(27, 182, 162, .08); }
.gc-lab__warn.is-clean::before { background: var(--gc-teal); }
@keyframes gc-lab-drop {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: none; }
}

/* ─── KPI strip ─────────────────────────────────────────────────── */
.gc-lab__kpis {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  border-bottom: 1px solid var(--gc-line-strong);
}
.gc-lab__kpi {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 128px;
  margin: 0;
  padding: 18px var(--gc-lab-pad) 16px;
  border: 0;
  background: transparent;
  text-align: left;
  min-width: 0;
}
.gc-lab__kpi + .gc-lab__kpi { border-left: 1px solid var(--gc-line); }
.gc-lab__kv { display: flex; align-items: baseline; gap: 4px; }
.gc-lab__kn {
  font-family: var(--gc-display);
  font-weight: 800;
  font-size: 48px;
  line-height: .9;
  letter-spacing: -0.05em;
  font-variant-numeric: tabular-nums;
}
.gc-lab__ku {
  font-family: var(--gc-mono);
  font-size: 13px;
  color: var(--gc-mute);
}
.gc-lab__kd {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-top: auto;
  font-family: var(--gc-mono);
  font-size: 11px;
  line-height: 1.4;
  color: var(--gc-mute);
}
.gc-lab__kd.is-raw,
.gc-lab__kd.is-clean { color: var(--pz-ink); }
.gc-lab__kd.is-raw::before,
.gc-lab__kd.is-clean::before {
  content: "";
  flex: none;
  width: 8px;
  height: 8px;
  background: var(--gc-magenta);
}
.gc-lab__kd.is-clean::before { background: var(--gc-teal); }
.gc-lab__kpi--btn { cursor: pointer; transition: background-color 200ms ease; }
.gc-lab__kpi--btn:hover { background: var(--gc-lab-tint); }
.gc-lab__kpi--btn .gc-lab__kd { color: var(--pz-ink); }
.gc-lab__kpi--btn[aria-pressed="true"] { outline: 2px solid var(--pz-ink); outline-offset: -2px; }
.gc-lab__kpi--btn.is-idle { cursor: default; }
.gc-lab__kpi--btn.is-idle:hover { background: transparent; }
.gc-lab__kpi--btn.is-idle .gc-lab__kd { color: var(--gc-mute); }

/* ─── Panel grid (hairlines through the 1px gap) ────────────────── */
.gc-lab__grid {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 1px;
  background: var(--gc-line);
}
.gc-lab__panel {
  display: flex;
  flex-direction: column;
  min-width: 0;
  margin: 0;
  padding: 22px var(--gc-lab-pad) 18px;
  background: var(--pz-white);
}
.gc-lab__panel--map { grid-column: 1 / 6; }
.gc-lab__panel--mx  { grid-column: 6 / 13; }
.gc-lab__panel--sk  { grid-column: 1 / 8; }
.gc-lab__panel--tri { grid-column: 8 / 13; }
.gc-lab__panel--ev  {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: minmax(0, 4fr) minmax(0, 8fr);
  column-gap: clamp(24px, 3vw, 44px);
}

.gc-lab__ph {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}
.gc-lab__phl { min-width: 0; }
.gc-lab__pt {
  margin-top: 8px;
  font-family: var(--gc-display);
  font-weight: 700;
  font-size: 20px;
  line-height: 1.15;
  letter-spacing: -0.015em;
}
.gc-lab__phelp {
  margin-top: 6px;
  max-width: 48ch;
  font-size: 13.5px;
  line-height: 1.45;
  color: var(--gc-mute);
}
/* Inherits the core stamp's 10px: the illustrative-data label must read. */
.gc-lab__stamp { flex: none; padding: 2px 6px; }

.gc-lab__tools {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  min-height: 30px;
  margin-top: 14px;
}
.gc-lab__tbtn { margin-left: auto; padding: 4px 8px; font-size: 10.5px; }

.gc-lab__hint {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--gc-mono);
  font-size: 11px;
  color: var(--pz-ink);
  animation: gc-lab-drop 320ms var(--gc-ease) both;
}
.gc-lab__hint::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--gc-teal);
  animation: gc-lab-ping 1.6s ease-in-out infinite;
}
@keyframes gc-lab-ping {
  0%, 100% { transform: scale(1); opacity: 1; }
  50%      { transform: scale(.55); opacity: .55; }
}

.gc-lab__body {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 0;
  margin-top: 12px;
}
.gc-lab__tbl { margin-top: 12px; }
.gc-lab__foot {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 14px;
  padding-top: 10px;
  border-top: 1px solid var(--gc-line);
}
/* The table already says everything the readout and legend would. */
.gc-lab__panel.is-table .gc-lab__foot { display: none; }
.gc-lab__ro {
  min-height: 1.6em;
  font-family: var(--gc-mono);
  font-size: 11px;
  line-height: 1.6;
  color: var(--pz-ink);
  font-variant-numeric: tabular-nums;
}
.gc-lab__legend {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 16px;
  font-family: var(--gc-mono);
  font-size: 10.5px;
  line-height: 1.4;
  color: var(--gc-mute);
}
.gc-lab__lg { display: inline-flex; align-items: center; gap: 6px; }
.gc-lab__lg--ramp { gap: 2px; }
.gc-lab__lg--ramp .gc-lab__lgt:first-child { margin-right: 6px; }
.gc-lab__lg--ramp .gc-lab__lgt:last-child { margin-left: 6px; }
.gc-lab__note { flex-basis: 100%; margin-top: 2px; line-height: 1.55; }

/* Swatches (legends and the KPI semaphore) */
.gc-lab__sw { display: inline-block; flex: none; width: 10px; height: 10px; border-radius: 1px; }
.gc-lab__sw.q1 { background: var(--gc-ramp-1); }
.gc-lab__sw.q2 { background: var(--gc-ramp-2); }
.gc-lab__sw.q3 { background: var(--gc-ramp-3); }
.gc-lab__sw.q4 { background: var(--gc-ramp-4); }
.gc-lab__sw.q5 { background: var(--gc-ramp-5); }
.gc-lab__sw.q6 { background: var(--gc-ramp-6); }
.gc-lab__sw--ok { background: var(--gc-teal); }
.gc-lab__sw--warn { background: var(--gc-smoke); }
.gc-lab__sw--alert {
  background-color: var(--gc-magenta);
  background-image: repeating-linear-gradient(45deg, rgba(251, 250, 248, .55) 0 1.5px, transparent 1.5px 4px);
}
.gc-lab__sw--dup {
  width: 0;
  height: 0;
  border-radius: 0;
  border-top: 9px solid var(--gc-magenta);
  border-left: 9px solid transparent;
}
.gc-lab__sw--low { border: 1px dashed var(--gc-line-strong); background: transparent; }
.gc-lab__sw--rib { background: rgba(17, 17, 17, .14); }
.gc-lab__sw--teal { background: var(--gc-lab-teal-a); }
.gc-lab__dot { display: inline-block; flex: none; width: 9px; height: 9px; border-radius: 50%; }
.gc-lab__dot--i { background: var(--pz-ink); }
.gc-lab__dot--e { border: 1.5px solid var(--pz-ink); background: var(--pz-white); }
.gc-lab__rl { display: inline-block; flex: none; width: 3px; height: 12px; }
.gc-lab__rl--conv { background: var(--gc-teal); }
.gc-lab__rl--mat { background: repeating-linear-gradient(to bottom, var(--gc-smoke) 0 3px, transparent 3px 5px); }
.gc-lab__rl--div { background: var(--gc-magenta); }

/* ─── SVG common ────────────────────────────────────────────────── */
.gc-lab__svg { display: block; max-width: 100%; height: auto; overflow: visible; }
/* :where() keeps this base at element specificity, so any single-class
   rule below (slug, tick, column heads…) can recolour its text. */
:where(.gc-lab__svg) text {
  font-family: var(--gc-mono);
  fill: var(--pz-ink);
  font-variant-numeric: tabular-nums;
}
.gc-lab__svg [role="button"] { cursor: pointer; }
/* Marks draw their own focus rings (an outline on an SVG group is a
   loose bounding box in some engines and nothing in others). */
.gc .gc-lab__svg [tabindex]:focus-visible,
.gc .gc-lab__svg [tabindex]:focus { outline: none; }
/* The chart itself is focusable only by script (tabindex -1, so a click
   on empty space may focus it): no browser ring around the whole chart. */
.gc .gc-lab__svg[tabindex]:focus,
.gc .gc-lab__svg[tabindex]:focus-visible { outline: none; }
/* Empty marks (no matching action) are not filters. */
.gc-lab__svg [aria-disabled="true"] { cursor: default; }
.gc-lab__hit { fill: transparent; }
.gc-lab__slug { font-size: 9.5px; fill: var(--gc-mute); letter-spacing: .02em; }

/* ─── 01 · Territori ────────────────────────────────────────────── */
.gc-lab__map { max-height: 420px; }
.gc-lab__seaHatch { fill: rgba(17, 17, 17, .16); }
.gc-lab__seal { font-size: 9.5px; letter-spacing: .24em; text-transform: uppercase; fill: var(--gc-mute); }
.gc-lab__hex { transition: opacity 300ms var(--gc-ease); }
.gc-lab__hex.is-out { opacity: .32; }
.gc-lab__hexbg {
  fill: var(--gc-ramp-1);
  transition: fill 300ms var(--gc-ease);
}
.gc-lab__hex.q1 .gc-lab__hexbg { fill: var(--gc-ramp-1); }
.gc-lab__hex.q2 .gc-lab__hexbg { fill: var(--gc-ramp-2); }
.gc-lab__hex.q3 .gc-lab__hexbg { fill: var(--gc-ramp-3); }
.gc-lab__hex.q4 .gc-lab__hexbg { fill: var(--gc-ramp-4); }
.gc-lab__hex.q5 .gc-lab__hexbg { fill: var(--gc-ramp-5); }
.gc-lab__hex.q6 .gc-lab__hexbg { fill: var(--gc-ramp-6); }
.gc-lab__hex.s-ok .gc-lab__hexbg { fill: var(--gc-teal); }
.gc-lab__hex.s-warn .gc-lab__hexbg { fill: var(--gc-smoke); }
.gc-lab__hex.s-alert .gc-lab__hexbg { fill: var(--gc-magenta); }
.gc-lab__hex.is-empty .gc-lab__hexbg,
.gc-lab__hex.s-low .gc-lab__hexbg {
  fill: transparent;
  stroke: var(--gc-line-strong);
  stroke-dasharray: 3 3;
}
.gc-lab__hexhatch { opacity: 0; pointer-events: none; transition: opacity 300ms ease; }
.gc-lab__hex.is-hatch .gc-lab__hexhatch { opacity: 1; }
.gc-lab__hatchLine { fill: rgba(251, 250, 248, .42); }
.gc-lab__hex text { pointer-events: none; }
.gc-lab__hex.is-dark text { fill: var(--pz-bone); }
.gc-lab__hexcode { letter-spacing: .06em; opacity: .72; }
.gc-lab__svg .gc-lab__hexname {
  font-family: var(--gc-display);
  font-weight: 700;
  letter-spacing: -0.01em;
}
.gc-lab__hexval { font-weight: 500; }
.gc-lab__svg .gc-lab__hexbang {
  font-family: var(--gc-display);
  font-weight: 800;
  font-size: 15px;
  opacity: 0;
}
.gc-lab__hex.is-alert .gc-lab__hexbang { opacity: 1; }
.gc-lab__hexsel {
  fill: none;
  stroke: var(--pz-ink);
  stroke-width: 2;
  opacity: 0;
  transition: opacity 200ms ease;
}
.gc-lab__hex:hover .gc-lab__hexsel,
.gc-lab__hex.is-hover .gc-lab__hexsel { opacity: .55; }
.gc-lab__hex.is-sel .gc-lab__hexsel { opacity: 1; }
.gc-lab__hex:focus-visible .gc-lab__hexsel { opacity: 1; stroke-dasharray: 4 3; }
.gc-lab__hex.is-sel:focus-visible .gc-lab__hexsel { stroke-dasharray: none; stroke-width: 3; }
.gc-lab__hex.is-dark.is-sel .gc-lab__hexsel { stroke: var(--pz-bone); }
.gc-lab__hexghost {
  fill: none;
  stroke: var(--pz-ink);
  stroke-width: 1.5;
  stroke-dasharray: 3 2;
  vector-effect: non-scaling-stroke;
  transform-box: fill-box;
  transform-origin: center;
  transform: scale(0);
  opacity: 0;
  pointer-events: none;
  transition: transform 260ms var(--gc-ease), opacity 200ms ease;
}
.gc-lab__hex.is-dark .gc-lab__hexghost { stroke: var(--pz-bone); }

/* ─── 02 · Matriu ───────────────────────────────────────────────── */
.gc-lab__band { fill: rgba(17, 17, 17, .05); opacity: 0; pointer-events: none; transition: opacity 160ms ease; }
.gc-lab__mxhl { font-size: 10px; }
.gc-lab__mxrl { font-size: 11px; }
.gc-lab__mxh .gc-lab__hit { transition: fill 160ms ease; }
.gc-lab__mxh:hover .gc-lab__hit { fill: var(--gc-lab-tint); }
.gc-lab__mxh:focus-visible .gc-lab__hit {
  stroke: var(--pz-ink);
  stroke-width: 1.5;
  stroke-dasharray: 3 2;
}
.gc-lab__mxh.is-sel text { font-weight: 600; }
.gc-lab__und { fill: var(--pz-ink); opacity: 0; transition: opacity 200ms ease; }
.gc-lab__mxh.is-sel .gc-lab__und { opacity: 1; }
.gc-lab__cellbg {
  fill: rgba(17, 17, 17, .025);
  transition: fill 300ms var(--gc-ease), fill-opacity 300ms var(--gc-ease);
}
.gc-lab__cell.q0 .gc-lab__cellbg { fill: rgba(17, 17, 17, .025); stroke: var(--gc-line); stroke-width: 1; }
.gc-lab__cell.q1 .gc-lab__cellbg { fill: var(--gc-ramp-1); }
.gc-lab__cell.q2 .gc-lab__cellbg { fill: var(--gc-ramp-2); }
.gc-lab__cell.q3 .gc-lab__cellbg { fill: var(--gc-ramp-3); }
.gc-lab__cell.q4 .gc-lab__cellbg { fill: var(--gc-ramp-4); }
.gc-lab__cell.q5 .gc-lab__cellbg { fill: var(--gc-ramp-5); }
.gc-lab__cell.q6 .gc-lab__cellbg { fill: var(--gc-ramp-6); }
.gc-lab__cell.is-out .gc-lab__cellbg { fill-opacity: .2; }
.gc-lab__cellv { font-size: 11px; pointer-events: none; transition: opacity 200ms ease; }
.gc-lab__cell.is-dark .gc-lab__cellv { fill: var(--pz-bone); }
.gc-lab__cell.is-out .gc-lab__cellv { fill: var(--pz-ink); opacity: .38; }
.gc-lab__dup { fill: var(--gc-magenta); opacity: 0; pointer-events: none; transition: opacity 240ms ease; }
.gc-lab__cell.has-dup .gc-lab__dup { opacity: 1; }
.gc-lab__cellmark { fill: var(--gc-teal); opacity: 0; pointer-events: none; transition: opacity 200ms ease; }
.gc-lab__cell.is-sel .gc-lab__cellmark { opacity: 1; }
.gc-lab__cellghost {
  fill: none;
  stroke: var(--pz-ink);
  stroke-width: 1.2;
  stroke-dasharray: 2 2;
  pointer-events: none;
}
.gc-lab__cell.is-dark .gc-lab__cellghost { stroke: var(--pz-bone); }
.gc-lab__rings { pointer-events: none; }
.gc-lab__cellsel {
  fill: none;
  stroke: var(--pz-ink);
  stroke-width: 2;
  opacity: 0;
  transition: opacity 160ms ease;
}
.gc-lab__cellsel.is-hover,
.gc-lab__cellsel.is-sel { opacity: 1; }
.gc-lab__mbar { fill: var(--gc-ramp-4); }
.gc-lab__mnum { font-size: 10px; fill: var(--gc-mute); }
.gc-lab__mtot { font-size: 9.5px; letter-spacing: .16em; text-transform: uppercase; fill: var(--gc-mute); }

/* ─── 03 · Traçabilitat ─────────────────────────────────────────── */
.gc-lab__colh { font-size: 9.5px; letter-spacing: .18em; text-transform: uppercase; fill: var(--gc-mute); }
.gc-lab__rib {
  fill: var(--pz-ink);
  fill-opacity: .12;
  transition: fill-opacity 240ms ease;
}
.gc-lab__ribs:not(.gc-lab__ribs--over) .gc-lab__rib:hover { fill-opacity: .22; }
.gc-lab__ribs--over { pointer-events: none; }
.gc-lab__ribs--over .gc-lab__rib { fill: var(--gc-teal); fill-opacity: .55; }
.gc-lab__sk.has-sel .gc-lab__ribs:not(.gc-lab__ribs--over) .gc-lab__rib { fill-opacity: .08; }
.gc-lab__sk.has-pv .gc-lab__ribs:not(.gc-lab__ribs--over) .gc-lab__rib { fill-opacity: .06; }
.gc-lab__sk.has-pv .gc-lab__ribs--over .gc-lab__rib { fill-opacity: .7; }
.gc-lab__nodebg { fill: var(--pz-ink); }
.gc-lab__node.is-zero .gc-lab__nodebg { fill: var(--gc-line-strong); }
.gc-lab__nodesel {
  fill: none;
  stroke: var(--pz-ink);
  stroke-width: 2;
  opacity: 0;
  transition: opacity 160ms ease;
}
.gc-lab__node:hover .gc-lab__nodesel,
.gc-lab__node.is-hover .gc-lab__nodesel { opacity: .5; }
.gc-lab__node.is-sel .gc-lab__nodesel { opacity: 1; }
.gc-lab__node:focus-visible .gc-lab__nodesel { opacity: 1; stroke-dasharray: 3 2; }
.gc-lab__nodel {
  font-size: 10.5px;
  paint-order: stroke;
  stroke: var(--pz-white);
  stroke-width: 3.5px;
  stroke-linejoin: round;
}
.gc-lab__sk.is-vert .gc-lab__nodel { font-size: 10px; }
.gc-lab__nodelc { fill: var(--gc-mute); }
.gc-lab__node.is-sel .gc-lab__nodeln { font-weight: 600; }
.gc-lab__node.is-zero .gc-lab__nodel { fill-opacity: .45; }

/* ─── 04 · Triangulació ─────────────────────────────────────────── */
.gc-lab__gl { stroke: var(--gc-line); stroke-width: 1; }
.gc-lab__tick { font-size: 9.5px; fill: var(--gc-mute); }
.gc-lab__trow { transition: opacity 240ms ease; }
.gc-lab__trow.is-out { opacity: .5; }
.gc-lab__trow .gc-lab__hit { transition: fill 160ms ease; }
.gc-lab__trow:hover .gc-lab__hit,
.gc-lab__trow.is-hover .gc-lab__hit { fill: var(--gc-lab-tint); }
.gc-lab__trowsel { fill: none; stroke: var(--pz-ink); stroke-width: 2; opacity: 0; transition: opacity 160ms ease; }
.gc-lab__trow.is-sel .gc-lab__trowsel { opacity: 1; }
.gc-lab__trow:focus-visible .gc-lab__trowsel { opacity: 1; stroke-dasharray: 3 2; }
.gc-lab__rule { stroke: var(--gc-line-strong); stroke-width: 3; }
.gc-lab__trow.c-conv .gc-lab__rule { stroke: var(--gc-teal); }
.gc-lab__trow.c-mat .gc-lab__rule { stroke: var(--gc-smoke); stroke-dasharray: 3 2; }
.gc-lab__trow.c-div .gc-lab__rule { stroke: var(--gc-magenta); }
.gc-lab__tl { font-size: 11px; }
.gc-lab__trow.is-sel .gc-lab__tl { font-weight: 600; }
.gc-lab__conn { stroke: var(--pz-ink); stroke-width: 1; }
.gc-lab__di { fill: var(--pz-ink); transition: opacity 200ms ease; }
.gc-lab__de { fill: var(--pz-white); stroke: var(--pz-ink); stroke-width: 1.5; transition: opacity 200ms ease; }
.gc-lab__gi,
.gc-lab__ge {
  fill: none;
  stroke: var(--pz-ink);
  stroke-width: 1;
  stroke-dasharray: 2 2;
  opacity: 0;
  pointer-events: none;
  transition: opacity 200ms ease;
}
.gc-lab__ge { stroke-dasharray: 1 2; }
.gc-lab__tcls { font-size: 10px; letter-spacing: .08em; text-transform: uppercase; }
.gc-lab__trow.c-div .gc-lab__tcls { font-weight: 600; }
.gc-lab__trow.is-none .gc-lab__tcls { fill: var(--gc-mute); }

/* ─── 05 · Lectura ràpida + Evidències ──────────────────────────── */
.gc-lab__read {
  padding-right: clamp(20px, 2.6vw, 40px);
  border-right: 1px solid var(--gc-line);
}
.gc-lab__readb {
  margin-top: 14px;
  max-width: 40ch;
  font-size: 17px;
  line-height: 1.55;
  color: var(--pz-ink);
  text-wrap: pretty;
}
.gc-lab__ev { min-width: 0; }
.gc-lab__evl {
  list-style: none;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin: 18px 0 0;
  padding: 0;
}
.gc-lab__evi[hidden] { display: none; }
.gc-lab__fitxa {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 6px;
  width: 100%;
  height: 100%;
  min-height: 104px;
  padding: 10px 12px 10px 16px;
  border: 1px solid var(--gc-line-strong);
  border-radius: 1px;
  background: var(--pz-white);
  text-align: left;
  cursor: pointer;
  transition: border-color 200ms ease, background-color 200ms ease;
}
.gc-lab__fitxa:hover { border-color: var(--pz-ink); background: var(--gc-lab-tint); }
.gc-lab__fitxa.is-open { outline: 2px solid var(--pz-ink); outline-offset: -2px; }
.gc-lab__fbar { position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--pz-ink); }
/* Type is encoded by ink tone, not colour (the fitxa motif). */
.gc-lab__fbar.tone-1 { background: rgba(17, 17, 17, 1); }
.gc-lab__fbar.tone-2 { background: rgba(17, 17, 17, .82); }
.gc-lab__fbar.tone-3 { background: rgba(17, 17, 17, .66); }
.gc-lab__fbar.tone-4 { background: rgba(17, 17, 17, .52); }
.gc-lab__fbar.tone-5 { background: rgba(17, 17, 17, .40); }
.gc-lab__fbar.tone-6 { background: rgba(17, 17, 17, .30); }
.gc-lab__fbar.tone-7 { background: rgba(17, 17, 17, .22); }
.gc-lab__fbar.tone-8 { background: rgba(17, 17, 17, .15); }
.gc-lab__ftop {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-family: var(--gc-mono);
  font-size: 10px;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--gc-mute);
}
.gc-lab__ftype { color: var(--pz-ink); font-weight: 500; }
.gc-lab__fname {
  font-family: var(--gc-mono);
  font-size: 11.5px;
  line-height: 1.38;
  overflow-wrap: anywhere;
}
/* Messy names read like spell-check errors: legible, visibly wrong. */
.gc-lab__fitxa.is-raw .gc-lab__fvis {
  text-decoration: underline wavy var(--gc-magenta);
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}
.gc-lab__ftags { font-family: var(--gc-mono); font-size: 10px; line-height: 1.4; color: var(--gc-mute); }
.gc-lab__fn {
  margin-top: auto;
  font-family: var(--gc-mono);
  font-size: 10.5px;
  font-variant-numeric: tabular-nums;
}
.gc-lab__empty {
  margin-top: 18px;
  font-family: var(--gc-mono);
  font-size: 12px;
  color: var(--gc-mute);
}

.gc-lab__drawer {
  grid-column: 1 / -1;
  margin-top: 18px;
  padding: 16px 20px 18px;
  border: 1px solid var(--pz-ink);
  border-radius: 1px;
  background: var(--pz-bone);
  animation: gc-lab-drop 320ms var(--gc-ease) both;
}
.gc-lab__drawer:focus { outline: none; }
.gc-lab__drawer:focus-visible { outline: 2px solid var(--pz-ink); outline-offset: 3px; }
.gc-lab__drh { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; }
.gc-lab__drh .gc-lab__act { margin-left: auto; }
.gc-lab__imm {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--gc-mono);
  font-size: 11px;
}
.gc-lab__imm::before { content: ""; width: 8px; height: 8px; background: var(--gc-teal); }
.gc-lab__yaml {
  margin-top: 12px;
  font-family: var(--gc-mono);
  font-size: 12px;
  line-height: 1.75;
  overflow-wrap: anywhere;
}
.gc-lab__yrule { color: var(--gc-mute); }
.gc-lab__yname { font-weight: 500; }
.gc-lab__ybrut { color: var(--gc-mute); }
.gc-lab__ybrut::before { content: "→ "; }
.gc-lab__ydl { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 0 14px; margin: 0; }
.gc-lab__yrow { display: contents; }
.gc-lab__ydl dt { color: var(--gc-mute); }
.gc-lab__ydl dd { margin: 0; }
.gc-lab__ydl dd.v-superat { text-decoration: line-through; text-decoration-color: var(--gc-magenta); }

/* ─── Tables (per panel, and the paginated row table) ───────────── */
/* Caption above the scroller (srv-coneixement-lab.js tableEl), styled
   like .gc-table caption so it reads the same as the other tables. */
.gc-lab__tcap {
  margin: 0;
  padding-bottom: 12px;
  font-family: var(--gc-mono);
  font-size: 11.5px;
  line-height: 1.5;
  color: var(--gc-mute);
}
.gc-lab__tscroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
/* Separate borders (no spacing, same look): with collapsed borders a
   sticky header cell's background paints over its own hairline. */
.gc-lab__table { border-collapse: separate; border-spacing: 0; }
/* A fade, not a shadow, on the edge that still hides columns. */
.gc-lab__tscroll.is-scroll {
  -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 28px), transparent);
  mask-image: linear-gradient(to right, #000 calc(100% - 28px), transparent);
}
.gc-lab__table th[scope="row"] {
  position: sticky;
  left: 0;
  z-index: 1;
  white-space: nowrap;
  background: var(--pz-white);
}
.gc-lab__table thead th:first-child {
  position: sticky;
  left: 0;
  z-index: 2;
  background: var(--pz-white);
}
/* Hairline on the frozen column once something has scrolled under it. */
.gc-lab__tscroll.is-scrolled .gc-lab__table th[scope="row"]::after {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 1px;
  background: var(--gc-line);
}
.gc-lab__tslug { color: var(--gc-mute); }
/* A panel in table mode takes the full row, and so does its partner. */
.gc-lab__panel.is-wide { grid-column: 1 / -1; }
.gc-lab__table td.gc-lab__tl { text-align: left; }
.gc-lab__table tfoot th,
.gc-lab__table tfoot td { font-weight: 500; border-bottom: 0; }
.gc-lab__rows {
  padding: 22px var(--gc-lab-pad);
  border-top: 1px solid var(--gc-line-strong);
}
.gc-lab__rows .gc-lab__tcap { margin-top: 6px; }
.gc-lab__rows .gc-table { min-width: 760px; }
/* One line per action: the table scrolls sideways (frozen id column,
   fade on the hidden edge) rather than stacking each row three lines tall. */
.gc-lab__rows .gc-table td { text-align: left; white-space: nowrap; }
.gc-lab__rows .gc-table td:nth-child(8) { text-align: right; }
.gc-lab__pager {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 14px;
  margin-top: 14px;
}
.gc-lab__pinfo { font-family: var(--gc-mono); font-size: 11px; color: var(--gc-mute); }

/* ─── Mobile bottom sheet ───────────────────────────────────────── */
.gc-lab__sheet {
  position: fixed;
  inset: 0;
  z-index: 89;               /* under the dock (90) and the motion control (91) */
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
}
.gc-lab__scrim {
  position: absolute;
  inset: 0;
  background: rgba(17, 17, 17, .38);
  animation: gc-lab-fade 240ms ease both;
}
@keyframes gc-lab-fade { from { opacity: 0; } to { opacity: 1; } }
.gc-lab__sheetp {
  position: relative;
  max-height: 82vh;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 16px 16px calc(84px + env(safe-area-inset-bottom, 0px));
  background: var(--pz-white);
  border-top: 1px solid var(--pz-ink);
  animation: gc-lab-sheet 320ms var(--gc-ease) both;
}
@keyframes gc-lab-sheet { from { transform: translateY(24px); opacity: 0; } to { transform: none; opacity: 1; } }
/* While the modal sheet is open the dock CTA and the motion button stand
   down (they sit above it, z 90/91), so the page shows one bottom bar and
   the sheet no longer needs to clear them. */
html.gc-lab-sheet-open .gc-dock,
html.gc-lab-sheet-open .gc-motion { visibility: hidden; }
html.gc-lab-sheet-open .gc-lab__sheetp { padding-bottom: calc(20px + env(safe-area-inset-bottom, 0px)); }
.gc-lab__sheeth {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}
.gc-lab__sheett { color: var(--pz-ink); }
.gc-lab__sheetb .gc-lab__ctrls { flex-direction: column; align-items: stretch; gap: 14px; }
.gc-lab__sheetb .gc-lab__seg { justify-content: space-between; }
.gc-lab__sheetb .gc-lab__acts { margin-left: 0; }
.gc-lab__sheetb .gc-lab__filters { margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--gc-line); }

/* ─── Responsive ────────────────────────────────────────────────── */
@media (min-width: 1024px) {
  /* Keep the meter's hover strip (top-left, ≤360px) over plain text:
     the counter is the only thing living there. */
  .gc-lab__count { min-width: 236px; }
}
/* Icon-only actions when they would otherwise wrap under the controls
   (measured in fitBar, whatever the width or the language): the sticky
   bar stays at count + one row of controls + the filters. */
.gc-lab__bar.is-tight .gc-lab__act { padding: 6px 9px; }
.gc-lab__bar.is-tight .gc-lab__actl {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap;
}
/* Short desktop viewports (1280×720, iPad landscape): a slimmer stuck bar,
   and no empty filter row when nothing is filtered. */
@media (min-width: 961px) and (max-height: 820px) {
  .gc-lab__bar { padding-block: 10px 8px; row-gap: 6px; }
  .gc-lab__bar .gc-lab__filters.is-empty { display: none; }
  .gc-lab__cn { font-size: 32px; }
}
@media (max-width: 1180px) {
  .gc-lab__panel--ev { grid-template-columns: minmax(0, 1fr); }
  .gc-lab__read {
    padding: 0 0 18px;
    border-right: 0;
    border-bottom: 1px solid var(--gc-line);
    margin-bottom: 18px;
  }
  .gc-lab__readb { max-width: 64ch; }
}
@media (max-width: 1024px) {
  .gc-lab__panel--map,
  .gc-lab__panel--mx,
  .gc-lab__panel--sk,
  .gc-lab__panel--tri { grid-column: span 6; }
  .gc-lab__kn { font-size: 40px; }
}
@media (max-width: 860px) {
  .gc-lab__panel--map,
  .gc-lab__panel--mx,
  .gc-lab__panel--sk,
  .gc-lab__panel--tri { grid-column: 1 / -1; }
  .gc-lab__evl { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* Compact bar (JS adds .is-compact at ≤960px): «{n} de {total}» plus a
   «Filtres (k)» button that opens the bottom sheet. */
.gc-lab.is-compact .gc-lab__bar {
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas: "count mbtn";
  padding: 10px 14px;
}
.gc-lab.is-compact .gc-lab__count {
  padding-right: 0;
  border-right: 0;
  flex-direction: row;
  align-items: center;
  justify-content: flex-start;
}
.gc-lab.is-compact .gc-lab__cpre,
.gc-lab.is-compact .gc-lab__cpost { display: none; }
.gc-lab.is-compact .gc-lab__ccompact { display: inline; }
.gc-lab.is-compact .gc-lab__cn { font-size: 30px; min-width: 0; }
.gc-lab.is-compact .gc-lab__mbtn {
  grid-area: mbtn;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border: 1px solid var(--pz-ink);
  border-radius: 2px;
  background: var(--pz-ink);
  color: var(--pz-bone);
  font-family: var(--gc-mono);
  font-size: 11.5px;
  cursor: pointer;
}

/* Touch: the dashboard's switches and buttons get a 40px target. */
@media (pointer: coarse), (max-width: 768px) {
  .gc-lab__segbtn,
  .gc-lab__seg--sm .gc-lab__segbtn { min-height: 40px; padding-inline: 12px; }
  .gc-lab__tbtn,
  .gc-lab__act,
  .gc-lab__mbtn { min-height: 40px; }
  .gc-lab__segb { padding: 2px; }
}

/* Narrow tables: slugs in column heads, labels in row heads (the other
   half stays for screen readers), and a frozen first column. */
@media (max-width: 600px) {
  .gc-lab__table th[scope="row"] .gc-lab__tslug,
  .gc-lab__table th[scope="col"] .gc-lab__tname {
    position: absolute; width: 1px; height: 1px; overflow: hidden;
    clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap;
  }
}

@media (max-width: 640px) {
  .gc-lab-wrap { padding-left: 16px; padding-right: 16px; }
  .gc-lab { --gc-lab-pad: 14px; }
  .gc-lab__kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .gc-lab__kpi { min-height: 112px; padding: 14px; }
  .gc-lab__kpi:nth-child(3) { border-left: 0; }
  .gc-lab__kpi:nth-child(n + 3) { border-top: 1px solid var(--gc-line); }
  .gc-lab__kn { font-size: 36px; }
  .gc-lab__kd { font-size: 10.5px; }
  .gc-lab__panel { padding: 18px 14px 14px; }
  .gc-lab__ph { flex-direction: column; gap: 10px; }
  .gc-lab__evl { grid-template-columns: minmax(0, 1fr); }
  .gc-lab__fitxa { min-height: 0; }
  .gc-lab__readb { font-size: 16px; }
  .gc-lab__drawer { padding: 14px; }
  .gc-lab__ydl { grid-template-columns: minmax(0, 1fr); }
  .gc-lab__ydl dd { margin-bottom: 6px; }
  .gc-lab__map { max-height: 320px; }
}

/* Reduced motion: site.css already shortens transitions; the loops and
   entrance keyframes go entirely. */
@media (prefers-reduced-motion: reduce) {
  .gc-lab__hint::before,
  .gc-lab__chip,
  .gc-lab__warn,
  .gc-lab__drawer,
  .gc-lab__scrim,
  .gc-lab__sheetp,
  .gc-lab__bar.is-flash { animation: none; }
  .gc-lab__hexghost { transition: none; }
}
