/* Per-100k section. Loaded only when the build has per100k ON. Party colours are validated (scripts/validate_palette.js)
   as a pair on both surfaces: light ΔE 30 normal / 24 protan; dark 29.5 / 20. Cycle is encoded by line style, not colour. */
:root { --p-dem: #2a78d6; --p-rep: #c43c3c; --p-bar: #52514e; }
@media (prefers-color-scheme: dark) { :root:where(:not([data-theme="light"])) { --p-dem: #3987e5; --p-rep: #e46060; --p-bar: #c3c2b7; } }
:root[data-theme="dark"] { --p-dem: #3987e5; --p-rep: #e46060; --p-bar: #c3c2b7; }

#per100k .attrib { margin: 0 0 8px; font-size: .95rem; font-weight: 600; }
#per100k .seg button { min-height: 36px; }
table.p100k th.pgh, table.p100k td.pgh { text-align: left; font-weight: 650; color: var(--ink); background: var(--hover); position: sticky; left: 0; }
table.p100k td.pgh .sw { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 8px; vertical-align: -1px; }
table.p100k td.rt { text-align: right; }
table.p100k td.rt .rv { display: inline-block; min-width: 3.6em; text-align: right; margin-right: 8px; }
table.p100k td.rt svg { width: 90px; height: 12px; vertical-align: middle; }
table.p100k td.rt svg .trk { fill: var(--grid); }
table.p100k td.rt svg .mid { stroke: var(--ink2); stroke-width: 1.5; }
table.p100k td.rt svg .bar { fill: var(--p-bar); }
table.p100k td.st .sv { display: inline-block; min-width: 3.6em; text-align: right; margin-right: 8px; }
table.p100k td.st svg { width: 70px; height: 10px; vertical-align: middle; }
table.p100k td.st svg .d { fill: var(--p-dem); } table.p100k td.st svg .r { fill: var(--p-rep); }
table.p100k td.st svg .m { stroke: var(--surface); stroke-width: 1.5; }
table.p100k thead tr.grp th { border-bottom: 1px solid var(--line); padding-bottom: 4px; }
table.p100k td.sub { color: var(--muted); }
#per100k .legend .lk { display: inline-block; width: 12px; height: 12px; border-radius: 2px; }
details.model { margin: 18px 0 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); }
details.model > summary { cursor: pointer; padding: 10px 14px; font-weight: 600; }
details.model .modelbody { padding: 0 14px 12px; max-width: 80ch; }
details.model .modelbody p, details.model .modelbody li { color: var(--ink2); }
details.model .modelbody h4 { margin: 14px 0 4px; font-size: .95rem; }
details.model .stats { display: flex; flex-wrap: wrap; gap: 8px 12px; margin: 8px 0; }
details.model .stat { border: 1px solid var(--line); border-radius: 6px; padding: 6px 10px; }
details.model .stat b { display: block; font-size: 1.3rem; letter-spacing: -.01em; }
details.model .stat span { font-size: .78rem; color: var(--muted); }
details.model .tablewrap { max-width: 100%; }
@media (max-width: 560px) {
  table.p100k td.st svg { width: 44px; } table.p100k td.st .sv { margin-right: 4px; }
  #per100k .controls .btn { width: 100%; }
  table.p100k th, table.p100k td { padding: 6px 6px; }
  table.p100k td:first-child, table.p100k thead th:first-child { white-space: normal; min-width: 104px; max-width: 120px; }
  table.p100k td.rt svg { width: 44px; } table.p100k td.rt .rv { min-width: 3em; margin-right: 3px; }
}
@media (forced-colors: active) { table.p100k td.rt svg .bar, table.p100k td.st svg .d, table.p100k td.st svg .r { fill: CanvasText; } }
