/* detailed census tables (explorer fiche + riding pages) ------------------------------------ */
.ct-grid { --up: #1B4FA0; --down: #D9822B;
  column-count: 2; column-gap: 12px; }
:root[data-theme="dark"] .ct-grid, :root[data-theme="dark"] .ct-legend { --up: #7FA6F5; --down: #F0A55A; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .ct-grid,
  :root:not([data-theme="light"]) .ct-legend { --up: #7FA6F5; --down: #F0A55A; } }
.ct-legend { --up: #1B4FA0; --down: #D9822B; display: flex; flex-wrap: wrap; gap: 6px 16px; align-items: center;
  font-size: 12.5px; margin: 0 0 12px; }
.ct-legend span { display: inline-flex; align-items: center; gap: 6px; }
.ct-legend .sw { width: 22px; height: 8px; border-radius: 4px; display: inline-block; }
.ct-legend .sw.up { background: linear-gradient(90deg, color-mix(in srgb, var(--up) 25%, transparent), var(--up)); }
.ct-legend .sw.down { background: linear-gradient(90deg, var(--down), color-mix(in srgb, var(--down) 25%, transparent)); }

.ct { border: 1px solid var(--border); border-radius: 12px; background: var(--surface); overflow: hidden;
  break-inside: avoid; display: block; margin: 0 0 12px; }
.ct summary { cursor: pointer; padding: 11px 14px; list-style: none; display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto; gap: 10px; align-items: center; }
.ct summary::-webkit-details-marker { display: none; }
.ct summary:hover { background: var(--surface-2); }
.ct-title { font-weight: 700; font-size: 14.5px; }
.ct-title::before { content: "▸"; display: inline-block; margin-right: 8px; color: var(--muted); transition: transform .15s; }
.ct[open] .ct-title::before { transform: rotate(90deg); }
.ct-top { font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ct-top b { font-weight: 700; padding: 1px 6px; border-radius: 6px; margin-left: 4px; }
.ct-top.up b { color: var(--up); background: color-mix(in srgb, var(--up) 12%, transparent); }
.ct-top.down b { color: var(--down); background: color-mix(in srgb, var(--down) 14%, transparent); }
.ct-n { font-size: 11px; color: var(--muted); background: var(--surface-2); border-radius: 999px; padding: 2px 8px; font-variant-numeric: tabular-nums; }

.ct-body { padding: 2px 14px 12px; border-top: 1px solid var(--border); }
.ct-row { display: grid; grid-template-columns: minmax(0, 1fr) 62px 56px 76px 44px; gap: 8px; align-items: center;
  font-size: 12.5px; padding: 3px 6px; margin: 0 -6px; border-radius: 6px; }
.ct-head { color: var(--muted); font-size: 11px; padding-top: 8px; }
.ct-head span:nth-child(n+2) { text-align: right; }
.ct-head .ct-axis { text-align: center !important; }
.ct-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ct-val, .ct-qc, .ct-gap { text-align: right; font-variant-numeric: tabular-nums; }
.ct-val { font-weight: 600; }
.ct-qc { color: var(--muted); font-size: 11.5px; }
.ct-div { position: relative; height: 10px; }
.ct-div::before { content: ""; position: absolute; left: 50%; top: -2px; bottom: -2px; width: 1px; background: var(--border); }
.ct-div i { position: absolute; top: 1px; bottom: 1px; border-radius: 3px; }
.ct-row.up .ct-div i { background: var(--up); }
.ct-row.down .ct-div i { background: var(--down); }
.ct-gap { font-size: 11.5px; font-weight: 700; }
.ct-row.up .ct-gap { color: var(--up); }
.ct-row.down .ct-gap { color: var(--down); }
/* intensity by size of the gap */
.ct-row.lv0 .ct-div i { opacity: .3; }
.ct-row.lv1 .ct-div i { opacity: .55; }
.ct-row.lv2 .ct-div i { opacity: .8; }
.ct-row.lv2.up { background: color-mix(in srgb, var(--up) 4%, transparent); }
.ct-row.lv2.down { background: color-mix(in srgb, var(--down) 5%, transparent); }
.ct-row.lv3.up { background: color-mix(in srgb, var(--up) 7%, transparent); }
.ct-row.lv3.down { background: color-mix(in srgb, var(--down) 9%, transparent); }
.ct-row.lv4.up { background: color-mix(in srgb, var(--up) 13%, transparent); }
.ct-row.lv4.down { background: color-mix(in srgb, var(--down) 16%, transparent); }
.ct-row.lv0 .ct-val { font-weight: 500; }
.ct-group { font-size: 11px; font-weight: 700; letter-spacing: .02em; color: var(--muted); margin: 12px 0 3px; line-height: 1.35; }
.ct-note { font-size: 12px; color: var(--muted); margin: 12px 0 0; }
@media (max-width: 900px) { .ct-grid { column-count: 1; } }
@media (max-width: 480px) { .ct-row { grid-template-columns: minmax(0, 1fr) 58px 60px 40px; } .ct-qc, .ct-head span:nth-child(3) { display: none; } }
