/* HONDT — herramienta de escrutinio. Papel y tinta; el color lo ponen los partidos. */

@font-face { font-family: "Plex"; font-weight: 400; font-style: normal; font-display: swap; src: url("fonts/ibm-plex-sans-latin-400-normal.woff2") format("woff2"); }
@font-face { font-family: "Plex"; font-weight: 500; font-style: normal; font-display: swap; src: url("fonts/ibm-plex-sans-latin-500-normal.woff2") format("woff2"); }
@font-face { font-family: "Plex"; font-weight: 600; font-style: normal; font-display: swap; src: url("fonts/ibm-plex-sans-latin-600-normal.woff2") format("woff2"); }

:root {
  /* superficies */
  --bg: #f3f0e8;
  --surface: #fbfaf6;
  --surface-2: #ebe7dc;
  --track: #e4dfd2;
  --line: #d6d0c1;
  --line-strong: #b9b2a0;
  /* tinta */
  --ink: #1b1a17;
  --ink-2: #504d44;
  --ink-3: #6a665b;
  /* acentos con significado */
  --accent: #b23a1e; /* barrera, sorteo, pérdida: lo "legal" */
  --accent-soft: #f1d9d0;
  --focus: #1f4fd1;
  --ok: #2a6b48;
  --shadow: 0 1px 0 rgba(27, 26, 23, .04), 0 8px 24px -12px rgba(27, 26, 23, .18);

  --font: "Plex", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --r: 6px;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121110;
    --surface: #1a1917;
    --surface-2: #232220;
    --track: #2b2926;
    --line: #34322d;
    --line-strong: #4d4a42;
    --ink: #efece3;
    --ink-2: #bdb8aa;
    --ink-3: #98927f;
    --accent: #ee7a58;
    --accent-soft: #3a2119;
    --focus: #8aa8ff;
    --ok: #6fc796;
    --shadow: 0 1px 0 rgba(0, 0, 0, .4), 0 10px 28px -14px rgba(0, 0, 0, .7);
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 400 15px/1.45 var(--font);
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
::selection { background: color-mix(in oklab, var(--accent) 30%, transparent); }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 3px; }
h1, h2, h3, p, ul, ol { margin: 0; padding: 0; }
ul, ol { list-style: none; }
b { font-weight: 600; }
code { font: 500 .88em ui-monospace, SFMono-Regular, Menlo, monospace; background: var(--surface-2); padding: 1px 5px; border-radius: 3px; }
.muted { color: var(--ink-3); }
.small { font-size: 12.5px; }
.r { text-align: right; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.loading, .fatal { display: grid; place-items: center; min-height: 60vh; color: var(--ink-3); }

/* ------------------------------------------------------------------ marco */
.shell { max-width: 1480px; margin: 0 auto; padding: 0 20px 24px; }
.top {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: end;
  gap: 24px;
  padding: 16px 0 14px;
  border-bottom: 1px solid var(--line-strong);
}
.brand { display: flex; align-items: center; gap: 10px; padding-bottom: 4px; }
.brand__mark { width: 30px; height: auto; color: var(--ink); }
.brand__name { font-weight: 600; font-size: 20px; letter-spacing: -.01em; }
.controls { display: flex; flex-wrap: wrap; align-items: end; gap: 14px 18px; }
.field { display: grid; gap: 3px; }
.field > span { font-size: 11.5px; color: var(--ink-3); letter-spacing: .01em; }
select, .num {
  font: inherit;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--r);
  height: 34px;
  padding: 0 10px;
}
select {
  appearance: none;
  padding-right: 30px;
  min-width: 180px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M2 4.5l4 4 4-4' fill='none' stroke='%23777' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 9px center;
  background-size: 12px;
  cursor: pointer;
}
select:hover { border-color: var(--ink-3); }

.seg { display: inline-flex; padding: 3px; gap: 2px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 8px; }
.seg button {
  font: 500 13.5px var(--font);
  color: var(--ink-2);
  background: transparent;
  border: 0;
  border-radius: 5px;
  padding: 5px 12px;
  cursor: pointer;
  transition: background .15s, color .15s;
}
.seg button:hover { color: var(--ink); }
.seg button[aria-selected="true"], .seg button[aria-pressed="true"] { background: var(--ink); color: var(--bg); }
.seg--small button { padding: 3px 10px; font-size: 12.5px; }

.btn {
  font: 500 13.5px var(--font);
  color: var(--bg);
  background: var(--ink);
  border: 1px solid var(--ink);
  border-radius: var(--r);
  padding: 6px 12px;
  cursor: pointer;
}
.btn:hover { filter: brightness(1.15); }
.btn:active { transform: translateY(1px); }
.btn--ghost { background: transparent; color: var(--ink); border-color: var(--line-strong); }
.btn--ghost:hover { background: var(--surface-2); filter: none; }

/* ------------------------------------------------------------------ reparto */
.main {
  display: grid;
  grid-template-columns: minmax(440px, 1.05fr) minmax(0, 1fr);
  gap: 28px;
  align-items: start;
  padding-top: 22px;
}
.panel { order: -1; }
.stage { min-width: 0; }
.stage__top { position: sticky; top: 0; z-index: 3; background: var(--bg); padding: 0 0 6px; }

.summary { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 4px; }
.summary__title { font-weight: 600; font-size: 28px; letter-spacing: -.02em; line-height: 1.15; }
.summary__meta { color: var(--ink-3); font-size: 13.5px; margin-top: 2px; }
.summary__status { display: flex; align-items: center; gap: 10px; padding-top: 4px; }
.badge {
  font: 500 12.5px var(--font);
  border: 1px solid var(--line-strong);
  border-radius: 99px;
  padding: 3px 10px;
  color: var(--ink-2);
  background: var(--surface);
  white-space: nowrap;
}
.badge--lot { color: var(--accent); border-color: var(--accent); background: var(--accent-soft); }

.hemi { display: block; width: 100%; max-width: calc(560px * var(--rel, 1)); height: auto; margin: 6px auto 0; overflow: visible; }
.hemi--big { max-width: calc(760px * var(--rel, 1)); }
.seat { stroke: var(--bg); stroke-width: .8; transition: fill .32s cubic-bezier(.2, .7, .2, 1); }
.seat--empty { fill: var(--line); }
.seat--lot { fill: url(#lot-hatch); stroke: var(--accent); stroke-width: 1; }
.legend { display: flex; flex-wrap: wrap; gap: 4px 16px; justify-content: center; font-size: 13px; color: var(--ink-2); margin: 4px 0 6px; }
.legend li { display: inline-flex; align-items: center; gap: 6px; }
.swatch { display: inline-block; width: 10px; height: 10px; border-radius: 3px; flex: none; }
.swatch--blank { background: repeating-linear-gradient(45deg, var(--ink-3) 0 2px, transparent 2px 4px); }
.swatch--lot { background: repeating-linear-gradient(45deg, var(--accent) 0 2px, var(--surface) 2px 4px); border: 1px solid var(--accent); }
.base { display: flex; flex-wrap: wrap; gap: 4px 18px; font-size: 13px; color: var(--ink-2); padding: 8px 0 12px; border-bottom: 1px solid var(--line); }
.notice { margin: 8px 0; padding: 8px 12px; border-radius: var(--r); background: var(--surface-2); color: var(--ink-2); font-size: 13.5px; }
.notice--warn { background: var(--accent-soft); color: var(--accent); }

/* ------------------------------------------------------------------ lista de candidaturas */
.panel__tools { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding-bottom: 10px; }
.hint { font-size: 12px; color: var(--ink-3); text-align: right; }

.list { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow); padding: 4px 16px 6px; }
.list__head, .row {
  display: grid;
  grid-template-columns: minmax(96px, 150px) minmax(120px, 1fr) 104px 62px 84px;
  column-gap: 12px;
  align-items: center;
}
.list__head { font-size: 11.5px; color: var(--ink-3); padding: 10px 0 6px; border-bottom: 1px solid var(--line); }
.list__scale { position: relative; }
.mark-label { color: var(--accent); font-weight: 500; white-space: nowrap; }
.row { padding: 11px 0 9px; border-bottom: 1px solid var(--line); row-gap: 5px; }
.row:last-child { border-bottom: 0; }
.row__who { display: flex; align-items: center; gap: 8px; min-width: 0; flex-wrap: wrap; }
.row__acr { font-weight: 600; font-size: 15px; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row__group { flex-basis: 100%; font-size: 11.5px; color: var(--ink-3); padding-left: 18px; margin-top: -3px; }
.row--out .row__acr { color: var(--ink-2); font-weight: 500; }

.bar {
  position: relative;
  height: 26px;
  background: var(--track);
  border-radius: 4px;
  cursor: ew-resize;
  touch-action: none;
  user-select: none;
}
.bar__fill { position: absolute; inset: 0; border-radius: 4px; transform-origin: left center; transition: transform .2s cubic-bezier(.2, .7, .2, 1), background .2s; }
.bar--dim .bar__fill { opacity: .5; background-image: repeating-linear-gradient(135deg, rgba(255, 255, 255, .5) 0 3px, transparent 3px 7px) !important; background-blend-mode: normal; }
.bar__mark { position: absolute; top: -5px; bottom: -5px; width: 2px; margin-left: -1px; background: var(--accent); border-radius: 1px; pointer-events: none; transition: left .2s; }
.bar__grip { position: absolute; top: 3px; bottom: 3px; width: 5px; margin-left: -3px; border-radius: 3px; background: var(--surface); border: 1.5px solid var(--ink); box-shadow: 0 1px 2px rgba(0, 0, 0, .25); pointer-events: none; transition: left .2s cubic-bezier(.2, .7, .2, 1); }
.bar:hover .bar__grip, .bar:focus-visible .bar__grip { background: var(--ink); }
.shell[data-dragging="true"] .bar__fill, .shell[data-dragging="true"] .bar__grip, .shell[data-dragging="true"] .bar__mark { transition: none; }

.num { width: 100%; height: 30px; text-align: right; padding: 0 8px; font-variant-numeric: tabular-nums; font-weight: 500; }
.num:hover { border-color: var(--ink-3); }
.pct { text-align: right; color: var(--ink-2); font-size: 13.5px; }
.seatcell { display: grid; justify-items: end; line-height: 1.1; }
.seatcell__n { font-size: 24px; font-weight: 600; letter-spacing: -.02em; }
.seatcell__n--lot { color: var(--accent); }
.seatcell__n sup { font-size: 13px; margin-left: 1px; }
.seatcell small { font-size: 11px; color: var(--ink-3); }
.delta { font-weight: 500; }
.delta--up { color: var(--ok); }
.delta--down { color: var(--accent); }
.row--changed .seatcell small.delta { margin-top: 1px; }

.row__frontier { grid-column: 2 / -1; min-height: 18px; transition: opacity .15s; }
.row__frontier.is-stale { opacity: .45; }
.frontier { display: flex; flex-wrap: wrap; gap: 2px 16px; font-size: 12.5px; color: var(--ink-2); }
.frontier .f { display: inline-flex; align-items: center; gap: 4px; }
.f--down, .f--cliff, .f--lot { color: var(--accent); }
.chev { width: 11px; height: 11px; flex: none; }
.chip { font-size: 11.5px; font-weight: 500; padding: 1px 7px; border-radius: 99px; border: 1px solid currentColor; }
.chip--warn { color: var(--accent); }
.frontier--out { align-items: center; gap: 4px 10px; color: var(--ink-2); }
.row--blank .row__acr { font-weight: 500; }

/* ------------------------------------------------------------------ tabla de cocientes */
.qt { margin-top: 14px; overflow-x: auto; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }
.qt table { border-collapse: collapse; width: 100%; font-size: 12.5px; }
.qt th, .qt td { padding: 6px 9px; text-align: right; white-space: nowrap; border-bottom: 1px solid var(--line); }
.qt thead th { color: var(--ink-3); font-weight: 500; font-size: 11.5px; background: var(--surface-2); }
.qt tr:last-child th, .qt tr:last-child td { border-bottom: 0; }
.qt__who { text-align: left !important; position: sticky; left: 0; background: var(--surface); font-weight: 600; z-index: 1; }
.qt thead .qt__who { background: var(--surface-2); }
.qt .qt__who .swatch { margin-right: 7px; vertical-align: -1px; }
.qt td.lost { color: var(--ink-3); }
.qt td.won { background: color-mix(in oklab, var(--c) 20%, var(--surface)); box-shadow: inset 0 -2px 0 var(--c); font-weight: 600; color: var(--ink); }
.qt td.lot { background: repeating-linear-gradient(45deg, var(--accent-soft) 0 4px, transparent 4px 8px); color: var(--accent); font-weight: 600; }
.qt td.cut { outline: 2px solid var(--ink); outline-offset: -2px; }
.qt td.out { outline: 2px dashed var(--accent); outline-offset: -2px; color: var(--accent); }
.qt__legend { display: flex; flex-wrap: wrap; gap: 4px 18px; padding: 8px 12px; font-size: 12px; color: var(--ink-3); border-top: 1px solid var(--line); }
.key { display: inline-block; width: 12px; height: 12px; vertical-align: -2px; margin-right: 5px; border-radius: 2px; }
.key--cut { border: 2px solid var(--ink); }
.key--out { border: 2px dashed var(--accent); }
.key--lot { background: repeating-linear-gradient(45deg, var(--accent) 0 2px, var(--surface) 2px 4px); }

/* ------------------------------------------------------------------ informe */
.report { margin-top: 14px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }
.report > summary { cursor: pointer; padding: 11px 14px; font-weight: 500; list-style: none; display: flex; align-items: center; gap: 8px; }
.report > summary::before { content: ""; width: 7px; height: 7px; border-right: 1.6px solid var(--ink-2); border-bottom: 1.6px solid var(--ink-2); transform: rotate(-45deg); transition: transform .15s; }
.report[open] > summary::before { transform: rotate(45deg); }
.report__body { padding: 0 16px 14px; display: grid; gap: 6px; font-size: 13.5px; }
.report__body h3 { font-size: 12px; font-weight: 600; color: var(--ink-3); margin-top: 8px; text-transform: none; letter-spacing: .01em; }
.steps { display: grid; gap: 2px; }
.steps li { display: grid; grid-template-columns: 34px minmax(70px, 150px) 1fr; gap: 10px; padding: 3px 0; border-bottom: 1px dotted var(--line); }
.steps__n { color: var(--ink-3); }
.steps__q { color: var(--ink-2); }
.steps__lot { color: var(--accent); }
.norms li { margin-bottom: 8px; }

/* ------------------------------------------------------------------ vista nacional */
.main--national { display: block; }
.national { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(280px, .8fr); gap: 28px; align-items: start; }
.national__main { min-width: 0; }
.gtable { width: 100%; border-collapse: collapse; margin-top: 12px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; font-size: 13.5px; overflow: hidden; }
.gtable th, .gtable td { padding: 8px 12px; border-bottom: 1px solid var(--line); text-align: right; }
.gtable thead th { font-size: 11.5px; font-weight: 500; color: var(--ink-3); background: var(--surface-2); }
.gtable tbody th { text-align: left; font-weight: 500; white-space: nowrap; }
.gtable tr:last-child > * { border-bottom: 0; }
.gtable__slider { display: flex; align-items: center; justify-content: flex-end; gap: 8px; }
.gtable__slider output { width: 48px; text-align: right; color: var(--ink-2); }
input[type="range"] { accent-color: var(--ink); width: 150px; }
.lotmark { color: var(--accent); margin-left: 2px; }
.tiles h3 { font-size: 13px; font-weight: 600; color: var(--ink-3); margin-bottom: 8px; }
.tiles ul { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 6px; }
.tile {
  position: relative; width: 100%; display: grid; gap: 1px; text-align: left; cursor: pointer;
  padding: 7px 9px; border: 1px solid var(--line); border-radius: 6px; font: inherit; color: var(--ink);
  background: color-mix(in oklab, var(--c) 20%, var(--surface));
}
.tile:hover { border-color: var(--ink-3); }
.tile__n { font-weight: 600; font-size: 17px; line-height: 1; }
.tile__name { font-size: 11.5px; color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tile__lot { position: absolute; top: 4px; right: 7px; color: var(--accent); font-weight: 600; }

.foot { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 6px 24px; margin-top: 28px; padding-top: 12px; border-top: 1px solid var(--line); font-size: 12px; color: var(--ink-3); }

/* ------------------------------------------------------------------ modo Explorar */

/* ------------------------------------------------------------------ adaptación */
@media (max-width: 1100px) {
  .main { display: flex; flex-direction: column; align-items: stretch; gap: 10px; }
  .national { grid-template-columns: minmax(0, 1fr); }
  .stage { display: contents; }
  .stage__top { order: 1; padding-top: 6px; box-shadow: 0 8px 10px -10px rgba(0, 0, 0, .55); }
  .legend { order: 2; }
  .base { order: 3; }
  .panel { order: 4; }
  .calc { order: 5; }
  .top { grid-template-columns: 1fr auto; gap: 10px 12px; padding: 12px 0 10px; }
  .controls { grid-column: 1 / -1; order: 3; gap: 8px 12px; }
  .controls .field { flex: 1 1 200px; }
  .hemi, .hemi--big { max-width: calc(300px * var(--rel, 1)); margin-top: 2px; }
  .summary__title { font-size: 24px; }
}
@media (max-width: 640px) {
  .shell { padding: 0 14px 20px; }
  select { min-width: 0; width: 100%; }
  .summary__title { font-size: 20px; }
  .summary__meta { display: none; }
  .hemi, .hemi--big { max-width: calc(250px * var(--rel, 1)); }
  .summary__status .btn { padding: 4px 9px; font-size: 12.5px; }
  .list { padding: 2px 12px 4px; }
  .list__head { display: none; }
  .row { grid-template-columns: minmax(0, 1fr) 96px 70px; }
  .row .bar { grid-column: 1 / -1; grid-row: 2; }
  .row .pct { display: none; }
  .row__frontier { grid-column: 1 / -1; }
  .hint { display: none; }
  .gtable th, .gtable td { padding: 7px 6px; }
  input[type="range"] { width: 96px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: .001ms !important; animation-duration: .001ms !important; }
}

/* ------------------------------------------------------------------ escenario libre */
.main--national:has(.free) { display: block; }
.free { display: grid; grid-template-columns: minmax(480px, 1.05fr) minmax(0, 1fr); gap: 28px; align-items: start; }
.free__panel { display: grid; gap: 12px; min-width: 0; }
.free__result { min-width: 0; order: 2; }
.free__tools { display: flex; flex-wrap: wrap; align-items: end; gap: 10px 14px; }
.inline { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.free__tools .field select { min-width: 150px; }
.field--inline { display: inline-grid; }
.addbox { display: grid; gap: 10px; padding: 12px; background: var(--surface); border: 1px solid var(--line-strong); border-radius: 10px; box-shadow: var(--shadow); }
.btn:disabled { opacity: .45; cursor: default; }
.filebtn { display: inline-flex; align-items: center; cursor: pointer; }
.filebtn input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.filebtn:focus-within { outline: 2px solid var(--focus); outline-offset: 2px; }
.linkbtn { font: 500 12.5px var(--font); color: var(--ink-2); background: none; border: 0; padding: 0; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; text-decoration-color: var(--line-strong); }
.linkbtn:hover { color: var(--ink); text-decoration-color: var(--ink); }
.linkbtn--danger:hover { color: var(--accent); text-decoration-color: var(--accent); }
.colorpick { width: 22px; height: 22px; padding: 0; border: 1.5px solid var(--line-strong); border-radius: 5px; background: none; cursor: pointer; flex: none; }
.colorpick::-webkit-color-swatch-wrapper { padding: 0; }
.colorpick::-webkit-color-swatch { border: 0; border-radius: 3px; }
.namefield { font: 600 14.5px var(--font); color: var(--ink); background: transparent; border: 1px solid transparent; border-radius: 4px; padding: 2px 5px; min-width: 0; width: 100%; }
.namefield:hover, .namefield:focus { border-color: var(--line-strong); background: var(--surface); }
.namefield--wide { width: 220px; background: var(--surface); border-color: var(--line-strong); font-weight: 500; }
.num--small { width: 72px; height: 30px; }

.free__head, .free__row { display: grid; grid-template-columns: minmax(96px, 150px) minmax(100px, 1fr) 104px 60px 62px; column-gap: 12px; align-items: center; }
.free__head { font-size: 11.5px; color: var(--ink-3); padding: 10px 0 6px; border-bottom: 1px solid var(--line); }
.free__list { padding: 4px 16px 6px; }
.free__sub { grid-column: 2 / -1; display: flex; flex-wrap: wrap; align-items: center; gap: 4px 14px; min-height: 18px; }
.free__tmpl { grid-column: 1 / -1; padding: 6px 0 2px; }
.row--smallsum { display: block; padding: 10px 0; text-align: center; }
.free__zero { margin-top: 10px; }
.tiles--free ul { grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); }
.tiles--free { margin-top: 12px; }

@media (max-width: 1100px) {
  .free { display: flex; flex-direction: column; align-items: stretch; gap: 10px; }
  .free__result { display: contents; }
  .free__result > .stage__top { order: 1; }
  .free__result > .sharebox { order: 2; }
  .free__result > .legend { order: 3; }
  .free__result > .bloc { order: 4; }
  .free__result > .notice { order: 5; }
  .free__panel { order: 6; }
  .free__result > .tiles--free { order: 7; }
}
@media (max-width: 640px) {
  .free__head { display: none; }
  .free__row { grid-template-columns: minmax(0, 1fr) 96px 56px; }
  .free__row .bar { grid-column: 1 / -1; grid-row: 2; }
  .free__row .pct { display: none; }
  .free__sub { grid-column: 1 / -1; }
  .namefield--wide { width: 100%; }
}

/* swing regional */
.swing { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; }
.swing > summary { cursor: pointer; padding: 11px 14px; font-weight: 500; list-style: none; display: flex; align-items: center; gap: 8px; }
.swing > summary::before { content: ""; width: 7px; height: 7px; border-right: 1.6px solid var(--ink-2); border-bottom: 1.6px solid var(--ink-2); transform: rotate(-45deg); transition: transform .15s; }
.swing[open] > summary::before { transform: rotate(45deg); }
.swing__body { display: grid; gap: 10px; padding: 0 14px 14px; }
.swing__tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.swing__tbl th, .swing__tbl td { padding: 4px 8px; border-bottom: 1px solid var(--line); text-align: left; }
.swing__tbl thead th { font-size: 11.5px; font-weight: 500; color: var(--ink-3); }
.swing__tbl tbody th { font-weight: 500; white-space: nowrap; }
.swing__tbl tr.is-active th { color: var(--accent); }
.swing__tbl .r { text-align: right; white-space: nowrap; }
.swing__ctl { display: flex; align-items: center; gap: 8px; }
.swing__ctl input[type="range"] { width: 130px; flex: none; }
.swing__ctl .num { width: 64px; flex: none; }
.swing__active { display: flex; flex-wrap: wrap; gap: 6px 8px; align-items: center; }
.tag { font: 500 12px var(--font); color: var(--accent); background: var(--accent-soft); border: 1px solid var(--accent); border-radius: 99px; padding: 2px 9px; cursor: pointer; }
.tag:hover { filter: brightness(.96); }
@media (max-width: 640px) { .swing__ctl input[type="range"] { width: 90px; } .swing__tbl th, .swing__tbl td { padding: 4px 4px; } }

/* objetivos de escaños y buscador */
.targetfield { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--ink-2); }
.num--tiny { width: 52px; height: 24px; font-size: 12.5px; padding: 0 6px; }
.chip--ok { color: var(--ok); }
.solvebar { display: grid; gap: 8px; padding: 10px 12px; background: var(--surface); border: 1px solid var(--line-strong); border-radius: 10px; box-shadow: var(--shadow); font-size: 13.5px; }
.solvebar .notice { margin: 0; }

/* swing discreto (opcional, casi no se usa) */
.swing--quiet { background: transparent; border: 0; border-top: 1px solid var(--line); border-radius: 0; margin-top: 6px; }
.swing--quiet > summary { padding: 10px 0; font-size: 12.5px; font-weight: 400; color: var(--ink-3); }
.swing--quiet > summary:hover { color: var(--ink-2); }
.swing--quiet .swing__body { padding: 0 0 10px; }

.famtargets { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 0 14px; }
.famtargets > summary { cursor: pointer; padding: 10px 0; font-size: 13px; font-weight: 500; color: var(--ink-2); }
.famtargets[open] > summary { color: var(--ink); }
.famtargets__list { display: grid; gap: 6px; padding: 8px 0 12px; }
.famtargets__list li { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.famtargets__name { flex: 1 1 200px; }

/* escaños directos */
.direct__head, .direct__row { display: grid; grid-template-columns: 38px minmax(0, 1fr) 140px 52px; column-gap: 10px; align-items: center; }
.direct__head { font-size: 11.5px; color: var(--ink-3); padding: 10px 0 6px; border-bottom: 1px solid var(--line); }
.direct__row input[type="checkbox"] { width: 17px; height: 17px; accent-color: var(--ink); justify-self: center; }
.stepper { display: inline-flex; align-items: center; gap: 4px; justify-self: end; }
.stepper__b { padding: 0; width: 28px; height: 30px; font-size: 16px; line-height: 1; }
.num--seats { width: 54px; text-align: center; font-weight: 600; font-size: 15px; }
.bloc { display: grid; gap: 8px; padding: 10px 12px; margin: 8px 0; background: var(--surface); border: 1px solid var(--line-strong); border-radius: 10px; font-size: 13.5px; }
.bloc .ok { color: var(--ok); font-weight: 500; }
.bloc__bar { position: relative; height: 8px; background: var(--track); border-radius: 99px; }
.bloc__fill { height: 100%; background: var(--ink); border-radius: 99px; transition: width .2s; }
.bloc__mark { position: absolute; top: -4px; bottom: -4px; width: 2px; background: var(--accent); margin-left: -1px; }
@media (max-width: 640px) { .direct__head { display: none; } .direct__row { grid-template-columns: 30px minmax(0, 1fr) 128px; } .direct__row > .linkbtn { grid-column: 2 / -1; justify-self: start; } }

/* escribir escaños en el escenario libre */
.seatinput { width: 58px; font: 600 22px/1.1 var(--font); letter-spacing: -.02em; text-align: right; color: var(--ink); background: transparent; border: 1px solid transparent; border-radius: 6px; padding: 1px 5px; font-variant-numeric: tabular-nums; }
.seatinput:hover { border-color: var(--line-strong); background: var(--surface); }
.seatinput:focus { border-color: var(--focus); background: var(--surface); }
.seatinput--pinned { border-color: var(--ink-3); background: var(--surface-2); }
.seatinput--lot { color: var(--accent); }
.seatcell__lot { color: var(--accent); font-size: 12px; }
.pin { font: 500 11px var(--font); color: var(--ink-2); background: none; border: 0; padding: 0; cursor: pointer; text-decoration: underline; text-underline-offset: 2px; white-space: nowrap; }
.pin:hover { color: var(--accent); }
.autosolve { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--ink-2); }
.autosolve input { accent-color: var(--ink); }
.tag--pick { color: var(--ink-2); background: var(--surface); border-color: var(--line-strong); margin: 2px 4px 2px 0; }
.tag--pick.is-on { color: var(--bg); background: var(--ink); border-color: var(--ink); }
.bloc__pick { line-height: 2; }

.intro { display: flex; gap: 14px; align-items: flex-start; justify-content: space-between; padding: 12px 14px; background: var(--surface); border: 1px solid var(--line-strong); border-radius: 10px; font-size: 13.5px; color: var(--ink-2); }
.intro p { max-width: 62ch; }
.intro b { color: var(--ink); }

/* compartir */
.sharebox { display: grid; gap: 8px; padding: 12px; margin: 8px 0; background: var(--surface); border: 1px solid var(--line-strong); border-radius: 10px; box-shadow: var(--shadow); }
.sharebox__link { flex: 1 1 260px; min-width: 0; font: 400 13px var(--font); color: var(--ink-2); background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r); height: 34px; padding: 0 10px; }

/* móvil: que nada se salga de la pantalla y los controles se puedan tocar bien */
@media (max-width: 640px) {
  .swing__body, .famtargets, .addbox, .sharebox, .solvebar { min-width: 0; max-width: 100%; }
  .swing__body > * { min-width: 0; max-width: 100%; }
  .swing__tbl { display: block; overflow-x: auto; max-width: 100%; }
  .btn, .seg button, select { min-height: 38px; }
  .num { height: 36px; }
  .num--tiny { height: 30px; }
  .linkbtn { padding: 6px 2px; }
  .tag, .pin { padding-top: 5px; padding-bottom: 5px; }
  .sharebox__link { flex-basis: 100%; }
  .sharebox .inline .btn { flex: 1 1 auto; }
}

/* Ajustes avanzados y desplegable "Ver el cálculo" */
.adv { margin-top: 8px; font-size: 13px; color: var(--muted, #666); }
.adv summary { cursor: pointer; padding: 4px 0; }
.adv__opt { display: flex; gap: 8px; align-items: flex-start; padding: 6px 0; cursor: pointer; }
.adv__opt input { margin-top: 3px; }
.adv__opt small { display: block; opacity: .8; margin-top: 2px; }
.calc { margin-top: 14px; border-top: 1px solid var(--line); padding-top: 8px; }
.calc > summary { cursor: pointer; font-weight: 600; padding: 6px 0; }
