/* cards.css — el estilo de las CARDS del panel de negocio (sesión BUILD/UI-CARDS).
 *
 * El sistema visual es el del panel de referencia transcrito en
 * checks/brief_cards_estilo.md §2:
 *   · la card es una "plate" con borde --accent-bord de 1 px y radio 10-12 px;
 *   · el eyebrow es sans 9-10 px, tracking .10em, mayúsculas, en --text-low;
 *   · el VALOR GRANDE es sans bold 22-30 px, tabular-nums, en --accent;
 *   · el título de la card es serif (Palatino/Georgia) MAYÚSCULAS con
 *     tracking .12em, en --accent-2;
 *   · la BARRA es de bullet: pista --line, relleno (verde si el valor está en
 *     o por encima de la referencia, coral si está por debajo) y un TICK
 *     vertical blanco de 2 px que marca la referencia;
 *   · el cuerpo es sans 11-12 px en --text-low;
 *   · CERO emoji: sólo trazo y tipografía.
 *
 * Los tokens NO se inventan aquí: son los que ya declara web/index.html
 * (:root). Aquí sólo se añaden los dos del sistema de barras: el éxito
 * (#76FF03) y el coral (#FF9E6B), que se usan EXCLUSIVAMENTE para "por encima
 * / por debajo de la referencia" (la semántica de docs/PALETA_JADES.md §2.2).
 */

.cd {
  border: 1px solid var(--accent-bord);
  background: var(--ink-800);
  border-radius: 11px;
  padding: 11px 13px 12px;
  margin: 0 0 8px;
  min-width: 0;
}
.cd .cd-head {
  display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px;
  margin-bottom: 4px;
}
.cd .cd-eyebrow {
  font-family: -apple-system, system-ui, "Segoe UI", sans-serif;
  font-size: 9.5px; letter-spacing: .10em; text-transform: uppercase;
  color: var(--text-low); font-weight: 600;
}
.cd .cd-cnt {
  font-size: 9px; letter-spacing: .04em; color: var(--text-low); margin-left: auto;
  text-align: right;
}
.cd .cd-title {
  font-family: "Palatino Linotype", Palatino, Georgia, serif;
  font-size: 12px; letter-spacing: .12em; text-transform: uppercase;
  color: var(--accent-2); font-weight: 400;
}

/* el valor grande: sans bold, tabular, en oro */
.cd .cd-vrow { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px; margin: 2px 0 1px; }
.cd .cd-val {
  font-family: -apple-system, system-ui, "Segoe UI", sans-serif;
  font-size: 25px; font-weight: 700; letter-spacing: -.01em;
  font-variant-numeric: tabular-nums; color: var(--accent);
  line-height: 1.1; overflow-wrap: anywhere;
}
.cd .cd-val.small { font-size: 19px; }
.cd .cd-val.nd { color: var(--text-low); font-weight: 400; font-style: italic; font-size: 19px; }
.cd .cd-vunit { font-size: 10px; color: var(--text-mid); }
.cd .cd-cmp { margin: 1px 0 0; }

/* el cuerpo: sans 11 px en --text-low */
.cd .cd-ctx { font-size: 10px; line-height: 1.45; color: var(--text-low); }
.cd .cd-ctx .mut { color: #6F8E98; }
.cd .cd-motivo {
  font-size: 9px; line-height: 1.45; color: var(--text-mid);
  border-left: 2px solid var(--accent-bord); padding-left: 6px; margin-top: 4px;
}
.cd .cd-regla { font-size: 9px; line-height: 1.4; color: #6F8E98; margin-top: 3px; }
.cd .cd-sub { font-size: 10.5px; color: var(--text-low); line-height: 1.45; }
.cd .cd-why { font-size: 10.5px; line-height: 1.5; color: #A9C4CC; margin: 2px 0 6px; }
.cd .cd-why-line { margin: 1px 0; }

/* ── U3 (S-B3) · EL BLOQUE EJECUTIVO ────────────────────────────────────────
 * Cada dato de una card se lee en cuatro renglones: QUÉ ES · MAGNITUD ·
 * QUÉ NO MIDE · CAVEAT PROPIO. La etiqueta del renglón es fija y corta (la
 * lee el lector de un vistazo); el valor va a su derecha.
 */
.cd .ej {
  display: flex; flex-direction: column; gap: 2px;
  margin: 3px 0 6px; padding: 6px 0 5px;
  border-top: 1px solid var(--line); border-bottom: 1px solid var(--line);
}
.cd .ej-l { display: flex; gap: 7px; align-items: baseline; }
.cd .ej-k {
  flex: 0 0 74px;
  font-family: -apple-system, system-ui, "Segoe UI", sans-serif;
  font-size: 8px; letter-spacing: .09em; text-transform: uppercase;
  color: #6F8E98; font-weight: 600; white-space: nowrap;
}
.cd .ej-v {
  flex: 1 1 auto; min-width: 0;
  font-size: 10.5px; line-height: 1.45; color: #A9C4CC;
}
.cd .ej-mag .ej-v { color: var(--text-hi); }
.cd .ej-mag .ej-v .cd-vrow { display: inline-flex; margin: 0; }
.cd .ej-mag .ej-v .cd-val { font-size: 21px; }
.cd .ej-no .ej-v, .cd .ej-cav .ej-v { color: var(--text-mid); }

/* ── U3 (S-B3) · EL TOOLKIT DE FUENTES ─────────────────────────────────────
 * La procedencia deja de ser texto corrido: son chips pequeños. Cada chip
 * lleva el texto íntegro en su tooltip y abre la pestaña FUENTES.
 */
.cd .tk { margin: 4px 0 6px; }
.cd .tk-linea {
  font-size: 9px; line-height: 1.4; color: #6F8E98; margin-bottom: 3px;
}
.cd .tk-chips { display: flex; flex-wrap: wrap; gap: 4px; }
.cd .tk-chip {
  font-family: -apple-system, system-ui, "Segoe UI", sans-serif;
  font-size: 9px; line-height: 1.3; letter-spacing: .02em;
  color: var(--text-mid); background: rgba(10, 30, 40, .7);
  border: 1px solid var(--accent-bord); border-radius: 9px;
  padding: 2px 7px; cursor: pointer; max-width: 100%;
  overflow-wrap: anywhere; text-align: left;
}
.cd .tk-chip:hover { color: var(--text-hi); border-color: var(--accent-2); }
.cd .tk-chip:focus-visible { outline: 1px solid var(--accent-2); outline-offset: 1px; }

/* los rótulos del nombre del municipio */
.cd .cd-nombre {
  font-family: "Palatino Linotype", Palatino, Georgia, serif;
  font-size: 22px; line-height: 1.15; letter-spacing: .02em; color: var(--accent);
}
.cd .cd-sub { margin-bottom: 5px; }

/* los badges: la pastilla del ratio y los puestos */
.cd .cd-badges { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 6px; }
.cd .cd-badge {
  display: inline-flex; flex-direction: column; gap: 1px;
  border-radius: 999px; padding: 3px 9px;
  font-family: -apple-system, system-ui, "Segoe UI", sans-serif;
  font-size: 10px; font-weight: 600; line-height: 1.25;
  border: 1px solid var(--accent-bord); color: var(--accent);
  background: rgba(0, 229, 255, .16); white-space: nowrap;
}
.cd .cd-badge.up { border-color: rgba(118, 255, 3, .55); color: #76FF03; background: rgba(118, 255, 3, .14); }
.cd .cd-badge.down { border-color: rgba(111, 142, 152, .5); color: var(--text-low); background: rgba(111, 142, 152, .12); }
.cd .cd-badge.muted { border-color: rgba(111, 142, 152, .45); color: var(--text-hi); background: rgba(16, 44, 56, .75); }
.cd .cd-badge .cd-bk { font-size: 8.5px; letter-spacing: .09em; text-transform: uppercase; font-weight: 600; opacity: .85; }
.cd .cd-badge .cd-bv { font-size: 12px; font-variant-numeric: tabular-nums; color: var(--accent); }
.cd .cd-badge.up .cd-bv { color: #76FF03; }
.cd .cd-badge.down .cd-bv { color: var(--text-low); }
.cd .cd-badge .cd-bt { font-size: 8.5px; font-weight: 400; color: var(--text-low); letter-spacing: .02em; max-width: 190px; white-space: normal; }
.cd .cd-badge.banda { border-color: var(--accent-2); background: rgba(0, 229, 255, .16); }

/* LA BARRA DE BULLET: pista + relleno + tick vertical blanco.
   Las reglas son de la BARRA (no de la card): la misma barra vive dentro de
   una card (.cd) y dentro de una fila del ranking (.rank). */
.cd-bar {
  position: relative; display: block; height: 6px; border-radius: 3px;
  background: #1D4553; margin: 7px 0 0; overflow: visible;
}
.cd-bar .cd-fill {
  display: block; height: 100%; border-radius: 3px; min-width: 0;
  background: var(--accent-2);
}
.cd-bar .cd-fill.up { background: #76FF03; }
.cd-bar .cd-fill.down { background: #FF9E6B; }
.cd-bar .cd-fill.acento { background: linear-gradient(90deg, #00BCD4, #00E5FF); }
.cd-bar .cd-tick {
  position: absolute; top: -2px; width: 2px; height: 10px;
  background: #FFFFFF; border-radius: 1px; transform: translateX(-50%);
}

/* las filas de dato (rótulo + valor) */
.cd .cd-rows { border-top: 1px solid var(--line); margin-top: 7px; }
.cd .cd-row {
  display: flex; justify-content: space-between; gap: 8px;
  padding: 5px 0; border-bottom: 1px solid var(--line); font-size: 11px;
}
.cd .cd-row:last-child { border-bottom: none; }
.cd .cd-row span { color: var(--text-low); flex: none; }
.cd .cd-row b { font-weight: 600; color: var(--text-hi); text-align: right; min-width: 0; }

/* el GRID de los seis indicadores */
.cd .cd-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 7px; margin-top: 6px; }
.cd .cd-ind { margin: 0; padding: 9px 10px 10px; border-radius: 9px; }
.cd .cd-ind .cd-val { font-size: 21px; }
.cd .cd-ind .cd-eyebrow { font-size: 8.5px; }

/* las barras de factor y de componente */
.cd .cd-facs { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
.cd .cd-fac { margin: 0; padding: 8px 10px 9px; border-radius: 9px; background: rgba(16, 44, 56, .5); }
.cd .cd-fac .cd-fname {
  font-family: "Palatino Linotype", Palatino, Georgia, serif;
  font-size: 12px; letter-spacing: .08em; text-transform: uppercase; color: var(--accent-2);
}
.cd .cd-fac .cd-peso { font-size: 9.5px; color: var(--text-low); margin-left: auto; }
.cd .cd-fac .cd-val { color: var(--text-hi); }
.cd .cd-comps { margin-top: 5px; padding-left: 7px; border-left: 2px solid var(--line); }
.cd .cd-comp { display: flex; flex-wrap: wrap; gap: 2px 8px; font-size: 9.5px; padding: 2px 0; }
.cd .cd-comp .cc-n { color: var(--accent); font-weight: 600; min-width: 110px; }
.cd .cd-comp .cc-m { color: var(--text-hi); flex: 1 1 auto; min-width: 0; }
.cd .cd-comp .cc-p { color: var(--text-low); font-variant-numeric: tabular-nums; }
.cd .cd-comp.nd .cc-n, .cd .cd-comp.nd .cc-m { color: var(--text-low); font-weight: 400; font-style: italic; }

/* las nueve capas de contexto */
.cd .cd-capas { display: flex; flex-direction: column; gap: 6px; margin-top: 6px; }
.cd .cd-capa { margin: 0; padding: 0; border-radius: 9px; background: rgba(16, 44, 56, .5); }
.cd .cd-capa > summary {
  cursor: pointer; list-style: none; padding: 8px 10px; margin: 0;
  display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px;
}
.cd .cd-capa > summary::-webkit-details-marker { display: none; }
.cd .cd-capa > summary::before {
  content: ""; width: 0; height: 0; flex: none;
  border-left: 4px solid var(--accent);
  border-top: 3px solid transparent; border-bottom: 3px solid transparent;
}
.cd .cd-capa[open] > summary::before { transform: rotate(90deg); }
.cd .cd-capa-bd { padding: 0 10px 9px; }
.cd .cd-capa-bd .ind { border-bottom: 1px solid rgba(29, 69, 83, .55); }
.cd .cd-capa-bd .ind:last-child { border-bottom: none; }

/* ── las filas del RANKING: cada fila es una card ───────────────────────── */
.finder .rank {
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr) auto auto;
  grid-template-areas: "n nm sc tie" ". sub bd bd" ". bar bar bar" ". top top top";
  column-gap: 8px; row-gap: 1px;
  align-items: baseline;
  padding: 7px 6px 8px;
  border-bottom: 1px solid rgba(29, 69, 83, .5);
  cursor: pointer; font-size: 12px; line-height: 1.3;
}
.finder .rank:hover { background: rgba(0,229,255,.07); }
.finder .rank .n {
  grid-area: n; width: auto; text-align: right; color: #6F8E98;
  font-size: 10.5px; font-variant-numeric: tabular-nums; flex: none;
}
.finder .rank .nm {
  grid-area: nm; min-width: 0; color: var(--text-hi); font-weight: 600; font-size: 12.5px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.finder .rank .sc {
  grid-area: sc; color: var(--accent); font-weight: 700; font-size: 19px;
  font-variant-numeric: tabular-nums; letter-spacing: -.01em; flex: none;
}
.finder .rank .sc.nd { color: #A9C4CC; font-weight: 400; font-style: italic; font-size: 12px; }
.finder .rank .bd {
  grid-area: bd; justify-self: end; align-self: center;
  flex: none; font-size: 8.5px; letter-spacing: .08em; padding: 1px 4px;
  border-radius: 3px; border: 1px solid rgba(0, 229, 255, .5);
  color: var(--accent); background: rgba(0, 229, 255, .14);
}
.finder .rank .tie { grid-area: tie; justify-self: end; align-self: center; }
.finder .rank .rk-sub {
  grid-area: sub; min-width: 0; font-size: 10px; color: var(--text-low);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.finder .rank .rk-bar { grid-area: bar; margin: 5px 0 0; }
.finder .rank .rk-top {
  grid-area: top; font-size: 9.5px; color: var(--text-mid); letter-spacing: .02em;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.finder .rank.sel { background: rgba(0,229,255,.14); box-shadow: inset 2px 0 0 var(--accent); }

/* la regla de la barra de las filas: se escribe UNA vez, en la cabecera */
.finder .cd-regla-panel {
  font-size: 9px; line-height: 1.4; color: #6F8E98; padding: 4px 0 5px;
  border-top: 1px solid var(--line); margin-top: 4px;
}

/* ── el teléfono (390 px): todo cabe sin scroll horizontal ─────────────── */
@media (max-width:1200px) {
  .cd .cd-grid { grid-template-columns: minmax(0, 1fr); }
  .cd .cd-val { font-size: 23px; }
}
@media (max-width:559px) {
  .cd { padding: 9px 10px 10px; border-radius: 10px; margin-bottom: 7px; }
  .cd .cd-grid { grid-template-columns: minmax(0, 1fr); gap: 6px; }
  .cd .cd-val { font-size: 21px; }
  .cd .cd-val.small { font-size: 17px; }
  .cd .cd-nombre { font-size: 19px; }
  .cd .cd-eyebrow { font-size: 9px; }
  .cd .cd-badge .cd-bt { max-width: 150px; }
  .cd .cd-fac .cd-fname { font-size: 11px; }
  .cd .cd-comp .cc-n { min-width: 92px; }
  .finder .rank { grid-template-columns: 18px minmax(0, 1fr) auto auto; column-gap: 6px; }
  .finder .rank .sc { font-size: 17px; }
  .finder .rank .nm { font-size: 12px; }
}
