/* NH.analityka — zakładka „Analityka pacjentów” (Kampanie / Marketing, 15.10). Scoped .nh-an, tylko tokeny.
   Kolory: w Kampaniach dziedziczą ich tokeny (--ink, --muted, --line, --teal, --clay, --warn…), poza nimi — tokeny Huba (tokens.css).
   Tabela źródeł szeroka (10 kolumn) → przewija się we WŁASNYM pudełku, strona nie. */
.nh-an {
  --an-ink: var(--ink, var(--nh-text));
  --an-mut: var(--muted, var(--nh-text-2));
  --an-line: var(--line, var(--nh-line));
  --an-soft: var(--line-soft, var(--nh-line-soft));
  --an-warn: var(--warn, var(--nh-warn-text));
  --an-warn-bg: var(--warn-soft, var(--nh-warn-bg));
  --an-surface: var(--surface, var(--nh-surface));
  --an-accent: var(--teal, var(--nh-accent));
  color: var(--an-ink);
  min-width: 0;
}
.nh-an .an-sec { margin-top: var(--space-6); background: var(--an-surface); border: 1px solid var(--an-line); border-radius: var(--radius-lg); padding: var(--space-4) var(--space-5) var(--space-5); min-width: 0; }
.nh-an .an-sec:first-of-type { margin-top: var(--space-4); }
.nh-an .an-sec-h { display: flex; align-items: baseline; gap: var(--space-3); flex-wrap: wrap; margin-bottom: var(--space-4); }
.nh-an .an-secn { display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; background: var(--nh-act); color: var(--nh-text-on-dark); font: 600 var(--nh-text-sm) var(--nh-font-body); flex: none; align-self: center; }
.nh-an .an-h { margin: 0; font: 500 var(--nh-text-lg) var(--nh-font-head); text-transform: uppercase; letter-spacing: var(--nh-ls-section); line-height: 1.1; color: var(--an-ink); }
.nh-an .an-cap { font-size: var(--nh-text-sm); color: var(--an-mut); }
.nh-an .an-mut { color: var(--an-mut); }
.nh-an .an-warn { color: var(--an-warn); }
.nh-an .an-empty, .nh-an .an-loading { padding: var(--space-6) var(--space-4); text-align: center; color: var(--an-mut); margin: 0; }
.nh-an .an-lead { margin: var(--space-4) 0 0; max-width: 75ch; line-height: 1.55; }
.nh-an .an-note { margin: var(--space-2) 0 0; max-width: 75ch; font-size: var(--nh-text-sm); color: var(--an-mut); line-height: 1.5; }
.nh-an .an-alarm { margin-top: var(--space-4); padding: var(--space-3) var(--space-4); border-radius: var(--radius-md); background: var(--an-warn-bg); color: var(--an-warn); }
.nh-an .an-alarm ul { margin: var(--space-1) 0 0; padding-left: var(--space-5); font-size: var(--nh-text-sm); }

/* 1) Porównanie źródeł */
.nh-an .an-scroll { overflow-x: auto; }
.nh-an .an-t { width: 100%; min-width: 960px; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.nh-an .an-t th { font-size: var(--nh-text-sm); font-weight: 500; color: var(--an-mut); text-align: right; vertical-align: bottom; line-height: 1.3; padding: 0 0 var(--space-3) var(--space-4); border-bottom: 1px solid var(--an-line); }
.nh-an .an-t td { text-align: right; padding: var(--space-3) 0 var(--space-3) var(--space-4); border-bottom: 1px solid var(--an-soft); white-space: nowrap; vertical-align: top; }
.nh-an .an-t th:first-child, .nh-an .an-t td:first-child { text-align: left; padding-left: 0; }
.nh-an .an-t td small { display: block; font-size: var(--nh-text-xs); white-space: normal; }
.nh-an .an-src { white-space: nowrap; }
.nh-an .an-dot { display: inline-block; width: 9px; height: 9px; border-radius: 3px; margin-right: var(--space-2); vertical-align: 1px; }
.nh-an .an-p { display: inline-block; min-width: 3em; margin-left: var(--space-1); font-size: var(--nh-text-xs); color: var(--an-mut); text-align: right; }
.nh-an .an-sum > td { font-weight: 700; border-bottom: 0; }
.nh-an .an-drill { appearance: none; background: none; border: 0; padding: 0; margin: 0; font: inherit; color: inherit; cursor: pointer; border-radius: var(--radius-sm); }
.nh-an .an-drill .an-n { text-decoration: underline; text-decoration-color: var(--an-line); text-underline-offset: 3px; }
.nh-an .an-drill:hover .an-n { text-decoration-color: var(--an-accent); }
.nh-an .an-drill:focus-visible { outline: 2px solid var(--an-accent); outline-offset: 2px; }

/* 2) Płatne a organiczne — słupki CSS (wysokość = --h z JS) */
.nh-an .an-legend { display: flex; flex-wrap: wrap; gap: var(--space-2) var(--space-4); font-size: var(--nh-text-sm); margin-bottom: var(--space-3); }
.nh-an .an-leg { display: inline-flex; align-items: center; gap: var(--space-2); }
.nh-an .an-leg-dot { width: 10px; height: 10px; border-radius: 3px; }
.nh-an .an-chart { display: flex; align-items: flex-end; gap: var(--space-4); min-height: 220px; padding-top: var(--space-5); border-bottom: 1px solid var(--an-line); overflow-x: auto; }
.nh-an .an-col { flex: 1 1 0; min-width: 64px; display: flex; flex-direction: column; align-items: stretch; }
.nh-an .an-bars { display: flex; align-items: flex-end; justify-content: center; gap: var(--space-1); height: 180px; }
.nh-an .an-bar { position: relative; flex: 0 1 28px; height: var(--h); min-height: 2px; background: var(--c); border-radius: var(--space-1) var(--space-1) 0 0; outline-offset: 2px; }
.nh-an .an-bar.is-young { opacity: .55; }
.nh-an .an-bar:focus-visible { outline: 2px solid var(--an-accent); }
.nh-an .an-bar-v { position: absolute; bottom: 100%; left: 50%; transform: translateX(-50%); padding-bottom: 2px; font-size: var(--nh-text-xs); font-variant-numeric: tabular-nums; color: var(--an-ink); white-space: nowrap; }
.nh-an .an-col-l { text-align: center; font-size: var(--nh-text-sm); color: var(--an-mut); padding: var(--space-2) 0 var(--space-1); white-space: nowrap; }
.nh-an .an-young { color: var(--an-warn); margin-left: 2px; }

/* 3) Wartość pacjenta w czasie */
.nh-an .an-vlist { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: var(--space-4) var(--space-6); }
.nh-an .an-vsrc { min-width: 0; }
.nh-an .an-vsrc.is-few { color: var(--an-mut); }
.nh-an .an-vname { font-weight: 600; margin-bottom: var(--space-2); }
.nh-an .an-vrow { display: grid; grid-template-columns: 4.5em minmax(0, 1fr) auto auto; align-items: center; gap: var(--space-2); font-variant-numeric: tabular-nums; padding: 2px 0; }
.nh-an .an-vlab { font-size: var(--nh-text-sm); color: var(--an-mut); }
.nh-an .an-vbar { height: 10px; width: var(--w); min-width: 2px; background: var(--an-accent); border-radius: 0 var(--space-1) var(--space-1) 0; }
.nh-an .an-vbar.is-few { background: var(--an-line); }
.nh-an .an-vrow .an-mut { font-size: var(--nh-text-sm); white-space: nowrap; }

/* 4) W przygotowaniu */
.nh-an .an-plan { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: var(--space-3) var(--space-5); }
.nh-an .an-plan li { display: flex; flex-direction: column; gap: var(--space-1); padding: var(--space-3) 0; border-top: 1px solid var(--an-soft); min-width: 0; }
.nh-an .an-plan span { font-size: var(--nh-text-sm); color: var(--an-mut); line-height: 1.45; }
.nh-an .an-plan .an-need { color: var(--an-warn); }

@media (max-width: 640px) {
  .nh-an .an-sec { padding: var(--space-3) var(--space-3) var(--space-4); }
  .nh-an .an-chart { gap: var(--space-2); }
  .nh-an .an-col { min-width: 0; }
  .nh-an .an-bar { flex-basis: 16px; }
  .nh-an .an-bar-v { font-size: var(--nh-text-xs); transform: translateX(-50%) scale(.85); }
}
