/* Pieces several screens share: sections, title pop-ups and their formulas, disclosures, the strips under lists,
   the stat strip and the risk matrix with its legend. */
/* ---------- sections: one card style, no nesting ---------- */
.section { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); margin-bottom: 20px; }
.section > header { display: flex; align-items: center; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.section > .body { padding: 18px; }
/* a title that explains its section: hover, focus or tap opens a short summary with a link to the guide (pages/guide.js) */
.tip { position: relative; width: fit-content; max-width: 100%; }  /* only the title opens it, not the empty space beside it */
.tip-on { cursor: help; border-radius: var(--r); text-decoration: underline dotted var(--ink-3); text-decoration-thickness: 1.5px; text-underline-offset: 5px; }
.tip-on .sub { display: inline-block; }  /* the dotted line stays on the title itself */
.tip-pop { position: absolute; top: 100%; left: -12px; z-index: 20; width: min(400px, calc(100vw - 32px)); margin-top: 10px; padding: 14px 16px;
  border: 1px solid var(--line-2); border-radius: var(--r-lg); background: var(--panel); box-shadow: 0 2px 6px rgb(var(--shade) / .14);
  color: var(--ink); font-family: var(--font-sans); font-size: var(--fs-sm); font-weight: 400; line-height: 1.45; text-align: left; visibility: hidden; opacity: 0; transition: opacity .12s ease-out, visibility .12s; }
.tip-pop::before { content: ""; position: absolute; inset: -11px 0 auto; height: 11px; }  /* keeps it open while the pointer crosses the gap */
.tip:is(:hover, :focus-within, .pinned):not(.closed) .tip-pop { visibility: visible; opacity: 1; }
.tip-pop p, .tip-pop ul { margin: 0; }
.tip-pop ul { display: grid; gap: 6px; padding-left: 18px; }
.tip-more { display: inline-block; margin-top: 12px; font-weight: 550; }
.tip.flip .tip-pop { left: auto; right: -12px; }  /* set by pages/guide.js when the pop-up would run past the window's right edge */
.stat .tip-pop { width: min(340px, calc(100vw - 32px)); }
/* a KPI's formula: a fraction (top over a rule over bottom) or an average, in the pop-up and in the guide */
.formula { margin-bottom: 10px; padding: 10px 12px; border-radius: var(--r); background: var(--sunken); color: var(--ink); font-weight: 550; line-height: 1.35; }
.frac { display: inline-grid; text-align: center; }
.frac > :last-child { margin-top: 4px; padding-top: 4px; border-top: 1.5px solid currentColor; }
.formula b { font-weight: 650; }
/* a section body spaces its own children (lists, notes, details); grid and row bodies use their gap instead */
.section > .body:not(.stack, .row, .split) > * + * { margin-top: 12px; }
.section > .body > ul:not([class]) { margin: 0; padding-left: 18px; }
.section > .help { padding: 12px 18px 16px; }
details > :not(summary) { margin-top: 8px; }
/* every disclosure ("Records behind this", "Rows not read") reads as something to open: accent text, a chevron that turns, a hand */
summary { display: inline-flex; align-items: center; gap: 8px; min-height: var(--target); color: var(--accent); font-weight: 550; cursor: pointer; list-style: none; user-select: none; border-radius: var(--r); text-underline-offset: 3px; }
summary::-webkit-details-marker { display: none; }
summary::before { content: ""; width: 6px; height: 6px; margin: 0 2px; border: solid currentColor; border-width: 0 1.5px 1.5px 0; transform: rotate(-45deg); transition: transform .15s ease-out; }
details[open] > summary::before { transform: rotate(45deg); }
/* strips above and below a table */
.footbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; padding: 12px 18px; }
.footbar { border-top: 1px solid var(--line); }
.footbar .err { margin: 0; }
/* ---------- findings: stat strip ---------- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
.stat { padding: 16px 18px; border-right: 1px solid var(--line); }
.stat:last-child { border-right: 0; }
.stat .k { color: var(--ink-2); font-size: var(--fs-sm); }
.stat .v { font-size: 22px; font-weight: 650; margin: 2px 0; }
.stat .goal { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; margin: 4px 0 6px; color: var(--ink-3); font-size: var(--fs-xs); }
.stat .s { color: var(--ink-3); font-size: var(--fs-xs); }
.stat .na { color: var(--ink-3); font-size: var(--fs-sm); margin-top: 6px; }
/* ---------- risk matrix (also its legend and the compare dialog) ---------- */
.matrix svg { width: 100%; max-width: 420px; display: block; overflow: visible; }
.mx-ax { fill: var(--ink-2); font-size: var(--fs-2xs); }
.mx-cl { fill: var(--ink); font-size: var(--fs-2xs); font-weight: 600; }
.mx-tip { fill: var(--ink); }
.mx-path { stroke: var(--ink); stroke-width: 1.75; }
.mx-ring { fill: none; stroke: var(--ink); stroke-width: 1.5; }
.mx-from { fill: var(--panel); stroke: var(--ink); stroke-width: 1.75; }
.mx-head { fill: var(--ink); stroke: var(--panel); stroke-width: 2; }
.mx-n { fill: var(--panel); font-size: var(--fs-2xs); font-weight: 600; pointer-events: none; }
.mx-hit { fill: transparent; }
.mv { cursor: pointer; outline: none; transition: opacity .15s ease-out; }
.mv:focus-visible .mx-head, .mv[aria-pressed="true"] .mx-head { stroke: var(--accent); stroke-width: 3; }
.hl .mv:not(.on) { opacity: .18; }
tr[data-action="mx-select"] { cursor: pointer; }
.hl tr.on > td { background: var(--accent-soft); }
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; color: var(--ink-2); font-size: var(--fs-sm); margin-top: 10px; }
.legend > span { display: inline-flex; align-items: center; gap: 4px; white-space: nowrap; }
.legend .mx-n { font-size: var(--fs-2xs); }
@media (max-width: 860px) {
  .stat { border-right: 0; border-bottom: 1px solid var(--line); }
}
@media (prefers-reduced-motion: reduce) {
  .mv, summary::before, .tip-pop { transition: none; }
}
