/* US Macro Monitor v4 — sistema de diseño
   Tokens (color, tipografía, radios) en :root; tema oscuro por sistema o por elección (data-theme);
   letra grande por elección (data-letra="grande"). Todos los componentes usan sólo estos tokens. */
:root {
  color-scheme: light;
  --bg: #f4f6f9; --surface: #ffffff; --surface-2: #f6f7fa; --ink: #111722; --ink-2: #465063; --muted: #6f7a8c;
  --grid: #e5e8ee; --axis: #c5cbd5; --line: rgba(17, 23, 34, 0.10); --band: rgba(42, 120, 214, 0.08);
  --rec: rgba(17, 23, 34, 0.06);
  --hover: rgba(17, 23, 34, 0.045); --track: rgba(17, 23, 34, 0.055); --chip: #ffffff; --scrim: rgba(12, 16, 24, 0.55); --hoy: #fff4d6;
  --s1: #2a78d6; --s2: #eb6834; --s3: #1baf7a; --s4: #eda100; --ref: #52514e;
  --ok: #0c8a0c; --alerta: #b87400; --error: #c43a3a; --neutro: #8a93a3;
  --div-lo: #2a78d6; --div-mid: #dedcd6; --div-hi: #e34948;
  --font: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --r: 10px;
  --fs: 15px;          /* texto base */
  --fs-s: 13px;        /* texto secundario */
  --fs-xs: 12px;       /* rótulos */
}
:root[data-letra="grande"] { --fs: 17px; --fs-s: 15px; --fs-xs: 13.5px; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0e1117; --surface: #161b24; --surface-2: #1b212c; --ink: #eef1f6; --ink-2: #b6bfcc; --muted: #8791a2;
    --grid: #252c38; --axis: #353e4c; --line: rgba(255,255,255,0.09); --band: rgba(57,135,229,0.12);
    --rec: rgba(255,255,255,0.06);
    --hover: rgba(255,255,255,0.05); --track: rgba(255,255,255,0.06); --chip: #2a313d; --scrim: rgba(0,0,0,0.65); --hoy: #3a3220;
    --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500; --ref: #c3c2b7;
    --ok: #2fb35a; --alerta: #e0a030; --error: #e66767; --neutro: #7d8697;
    --div-lo: #3987e5; --div-mid: #383835; --div-hi: #e66767;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0e1117; --surface: #161b24; --surface-2: #1b212c; --ink: #eef1f6; --ink-2: #b6bfcc; --muted: #8791a2;
  --grid: #252c38; --axis: #353e4c; --line: rgba(255,255,255,0.09); --band: rgba(57,135,229,0.12);
  --rec: rgba(255,255,255,0.06);
  --hover: rgba(255,255,255,0.05); --track: rgba(255,255,255,0.06); --chip: #2a313d; --scrim: rgba(0,0,0,0.65); --hoy: #3a3220;
  --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500; --ref: #c3c2b7;
  --ok: #2fb35a; --alerta: #e0a030; --error: #e66767; --neutro: #7d8697;
  --div-lo: #3987e5; --div-mid: #383835; --div-hi: #e66767;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--ink); font-family: var(--font); font-size: var(--fs); line-height: 1.5; }
body.bloqueado { overflow: hidden; }
.wrap { max-width: 1340px; margin: 0 auto; padding-inline: clamp(16px, 3vw, 32px); padding-block: 16px 48px; }
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--s1); outline-offset: 2px; }
.num { font-variant-numeric: tabular-nums; }
[hidden] { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
kbd { font-family: inherit; font-size: 0.8em; border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 4px; padding: 0 5px; color: var(--ink-2); background: var(--surface); }
a { color: var(--s1); }

/* ───────── Cabecera ───────── */
.top { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px 24px; padding-block: 6px 14px; border-bottom: 1px solid var(--line); }
.marca { display: flex; align-items: center; gap: 12px; min-width: 0; }
.logo { width: 34px; height: 34px; border-radius: 8px; background: var(--ink); color: var(--surface); display: grid; place-items: center; flex: none; }
.logo svg { width: 20px; height: 20px; }
.marca h1 { margin: 0; font-size: 22px; font-weight: 600; letter-spacing: -0.01em; line-height: 1.15; }
.marca h1 small { font-size: 11px; font-weight: 600; color: var(--muted); letter-spacing: 0.04em; margin-left: 6px; vertical-align: 3px; }
.marca .fila { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; margin-top: 2px; }
.marca p { margin: 0; color: var(--muted); font-size: var(--fs-s); }
.marca p b { color: var(--ink-2); font-weight: 500; }
.marca p .aviso { color: var(--s2); font-weight: 500; }
.vigia { display: inline-flex; align-items: center; gap: 7px; border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 2px 10px 2px 8px; font-size: var(--fs-xs); color: var(--ink-2); cursor: pointer; }
.vigia:hover { background: var(--hover); }
.vigia i { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); flex: none; }
.vigia.alerta i { background: var(--alerta); }
.vigia.error i { background: var(--error); }
.herr { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.buscar-btn { display: inline-flex; align-items: center; gap: 8px; border: 1px solid var(--line); background: var(--surface); border-radius: 8px; padding: 6px 10px; color: var(--muted); font-size: var(--fs-s); cursor: pointer; min-width: 200px; }
.buscar-btn:hover { border-color: var(--axis); }
.buscar-btn svg { width: 15px; height: 15px; flex: none; }
.buscar-btn span { flex: 1; text-align: left; }
.icono-btn { border: 1px solid var(--line); background: var(--surface); border-radius: 8px; width: 36px; height: 34px; display: grid; place-items: center; cursor: pointer; color: var(--ink-2); flex: none; }
.icono-btn:hover { background: var(--hover); }
.icono-btn svg { width: 17px; height: 17px; }
/* Selector segmentado: una pista gris y la opción elegida como una ficha blanca apoyada encima */
.seg { display: inline-flex; flex-wrap: wrap; gap: 2px; padding: 3px; border-radius: 10px; background: var(--track); }
.seg button { border: 0; background: none; border-radius: 7px; padding: 5px 12px; font-size: var(--fs-s); font-weight: 500; color: var(--muted); cursor: pointer; white-space: nowrap; transition: background .15s, color .15s, box-shadow .15s; }
.seg button[aria-pressed="true"] { background: var(--chip); color: var(--ink); font-weight: 600; box-shadow: 0 1px 2px rgba(15, 20, 30, 0.10), 0 0 0 0.5px var(--line); }
.seg button:not([aria-pressed="true"]):hover { color: var(--ink); }
.seg.chico { padding: 2px; border-radius: 8px; }
.seg.chico button { padding: 3px 9px; font-size: var(--fs-xs); border-radius: 6px; }
.periodo { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.periodo #rango button { min-width: 56px; text-align: center; }
.ub { display: none; }
.b-fechas { display: inline-flex; align-items: center; gap: 6px; border: 0; background: var(--track); border-radius: 10px; padding: 8px 13px; font-size: var(--fs-s); font-weight: 500; color: var(--muted); cursor: pointer; white-space: nowrap; transition: background .15s, color .15s; }
.b-fechas svg { width: 15px; height: 15px; }
.b-fechas:hover { color: var(--ink); }
.b-fechas[aria-pressed="true"], .b-fechas[aria-expanded="true"] { background: var(--chip); color: var(--ink); font-weight: 600; box-shadow: 0 1px 2px rgba(15, 20, 30, 0.10), 0 0 0 0.5px var(--line); }
.manual { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: var(--fs-s); color: var(--ink-2); width: 100%; justify-content: flex-end; }
.manual label { display: inline-flex; align-items: center; gap: 6px; }
.manual input { border: 1px solid var(--line); border-radius: 6px; background: var(--surface); padding: 4px 8px; font-size: var(--fs-s); }
.manual button { border: 1px solid var(--ink); background: var(--ink); color: var(--surface); border-radius: 6px; padding: 4px 12px; font-size: var(--fs-s); cursor: pointer; }

/* Menú de ajustes y menús emergentes */
.pop { position: absolute; z-index: 65;   /* encima del gráfico ampliado (50) */ background: var(--surface); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 12px 32px rgba(0,0,0,0.16); padding: 6px; min-width: 220px; }
.pop h4 { margin: 8px 8px 4px; font-size: var(--fs-xs); color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; }
.pop .fila { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 4px 8px; font-size: var(--fs-s); }
.pop button.item { display: flex; align-items: center; gap: 10px; width: 100%; border: 0; background: none; text-align: left; padding: 7px 10px; border-radius: 6px; cursor: pointer; font-size: var(--fs-s); color: var(--ink); }
.pop button.item:hover, .pop button.item:focus-visible { background: var(--hover); }
.pop button.item small { color: var(--muted); margin-left: auto; font-size: var(--fs-xs); }
.pop hr { border: 0; border-top: 1px solid var(--line); margin: 4px 0; }

/* ───────── Navegación ───────── */
.tabs { position: sticky; top: 0; z-index: 20; background: var(--bg); display: flex; gap: 2px; overflow-x: auto; padding-block: 8px; margin-bottom: 8px; scrollbar-width: none; border-bottom: 1px solid transparent; align-items: center; }
.tabs.con-sombra { border-bottom-color: var(--line); }
.tabs::-webkit-scrollbar { display: none; }
.tabs a { flex: none; text-decoration: none; padding: 7px 12px; border-radius: 8px; font-size: 14.5px; font-weight: 500; color: var(--ink-2); }
:root[data-letra="grande"] .tabs a { font-size: 16px; }
.tabs a:hover { background: var(--hover); }
.tabs a[aria-current="page"] { background: var(--surface); color: var(--ink); box-shadow: 0 0 0 1px var(--line); }
.tabs .sep { width: 1px; height: 20px; background: var(--line); margin: 0 6px; flex: none; }
.nav-movil { display: none; position: sticky; top: 0; z-index: 20; background: var(--bg); padding-block: 8px; margin-bottom: 6px; gap: 8px; }
.nav-movil select { flex: 1; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); padding: 8px 10px; font-size: 15px; font-weight: 500; }

/* ───────── Indicadores ───────── */
.tiles { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 12px; }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 12px 14px 10px; display: grid; gap: 2px; min-width: 0; align-content: start; position: relative; cursor: pointer; }
.tile:hover { border-color: var(--axis); }
.tile .lab { font-size: var(--fs-s); color: var(--ink-2); font-weight: 500; padding-right: 22px; line-height: 1.3; }
.tile .val { font-size: 27px; font-weight: 600; letter-spacing: -0.015em; line-height: 1.15; margin-top: 2px; }
:root[data-letra="grande"] .tile .val { font-size: 30px; }
.tile .val small { font-size: 15px; font-weight: 500; color: var(--ink-2); margin-left: 3px; }
.tile .del { font-size: var(--fs-xs); color: var(--muted); }
.tile .cmb { font-size: var(--fs-xs); color: var(--ink-2); font-variant-numeric: tabular-nums; min-height: 1.5em; }
.tile svg.spark { display: block; width: 100%; height: 30px; margin-top: 2px; }
.tile .star { position: absolute; top: 8px; right: 8px; }
/* Los indicadores de una fila comparten renglones: valor, nota, cambio, sparkline y percentil quedan a la misma altura */
@supports (grid-template-rows: subgrid) {
  .tiles > .tile { grid-template-rows: subgrid; grid-row: span 6; row-gap: 2px; }
  .tiles > .tile > .pctl { align-self: end; }
}
.pctl { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 8px; font-size: 11.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.pctl i { position: relative; display: block; height: 4px; border-radius: 2px; background: var(--grid); }
.pctl i s { position: absolute; top: 0; height: 4px; background: var(--band); outline: 1px solid var(--line); border-radius: 2px; text-decoration: none; }
.pctl i b { position: absolute; top: -3px; width: 2px; height: 10px; border-radius: 1px; background: var(--ink-2); }
.star { border: 0; background: none; padding: 2px; width: 24px; height: 24px; display: grid; place-items: center; cursor: pointer; color: var(--axis); border-radius: 6px; flex: none; }
.star:hover { color: var(--s4); background: var(--hover); }
.star[aria-pressed="true"] { color: var(--s4); }
.star svg { width: 16px; height: 16px; }

/* ───────── Bloques de página ───────── */
.cabecera { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 18px 20px; margin-bottom: 8px; display: grid; gap: 14px; }
.cabecera h2 { margin: 0; font-size: 20px; font-weight: 600; letter-spacing: -0.01em; }
.cabecera p { margin: 2px 0 0; font-size: var(--fs); color: var(--ink-2); max-width: 120ch; }
.cabecera .tiles { grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 10px; }
.cabecera .tile { background: var(--surface-2); border-color: transparent; }
.cabecera .tile:hover { border-color: var(--axis); }
.cabecera .tile .val { font-size: 23px; }
.dupla { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; margin-top: 16px; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 16px 20px; min-width: 0; }
.panel h2 { margin: 0 0 10px; font-size: 15px; font-weight: 600; display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.panel h2 a, .panel h2 button { border: 0; background: none; color: var(--s1); font-size: var(--fs-s); font-weight: 500; cursor: pointer; padding: 0; text-decoration: none; }
.lectura ul { margin: 0; padding: 0; list-style: none; display: grid; gap: 9px; }
.lectura li { display: grid; grid-template-columns: 124px 1fr; gap: 12px; font-size: var(--fs); color: var(--ink); max-width: 118ch; }
.lectura li span { font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); padding-top: 3px; }
.nota { margin: 12px 0 0; font-size: var(--fs-s); color: var(--muted); max-width: 118ch; }
.lista { margin: 0; padding: 0; list-style: none; display: grid; gap: 2px; }
.lista li { display: grid; grid-template-columns: 132px 1fr; gap: 12px; padding: 7px 8px; border-radius: 6px; font-size: 14px; }
.lista li.hoy { background: var(--hoy); }
.lista .fch { color: var(--ink-2); font-weight: 500; font-variant-numeric: tabular-nums; }
.lista .fch small { display: block; font-weight: 400; color: var(--muted); font-size: var(--fs-xs); white-space: nowrap; }
.lista .rel b { font-weight: 500; }
.lista .rel .det { display: block; color: var(--muted); font-size: 12.5px; }
.lista a { color: inherit; text-decoration: none; }
.lista a:hover b { text-decoration: underline; }
.vacio-txt { color: var(--muted); font-size: 14px; margin: 4px 0; }
h2.bloque { margin: 26px 0 12px; font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.07em; color: var(--muted); }
.imp { display: inline-flex; gap: 2px; vertical-align: 1px; margin-left: 6px; }
.imp i { width: 5px; height: 5px; border-radius: 50%; background: var(--grid); }
.imp i.on { background: var(--s2); }

.avisos { display: grid; gap: 6px; margin-bottom: 12px; }
.aviso-b { display: flex; gap: 10px; align-items: flex-start; border: 1px solid var(--line); border-left: 3px solid var(--alerta); background: var(--surface); border-radius: 8px; padding: 8px 12px; font-size: var(--fs-s); color: var(--ink-2); }

/* ───────── Tarjeta de gráfico ───────── */
.grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 16px 18px 10px; display: flex; flex-direction: column; min-width: 0; }
/* Las tarjetas de una misma fila comparten sus renglones (título, subtítulo, selectores, leyenda, gráfico, pie):
   así los gráficos vecinos arrancan a la misma altura aunque un título ocupe más líneas que el otro */
@supports (grid-template-rows: subgrid) {
  .grid > .card { display: grid; grid-template-rows: subgrid; grid-row: span 7; row-gap: 0; align-content: start; }
  .grid > .card > .card-h, .grid > .card > .sub, .grid > .card > .barra { align-self: start; }
  .grid > .card > .cuerpo { display: grid; grid-template-rows: subgrid; grid-row: span 2; row-gap: 0; min-width: 0; }
  .grid > .card > .cuerpo > .leyenda { align-self: end; }
  .grid > .card > .cuerpo > :only-child { grid-row: span 2; }
  .grid > .card > .meta-g { align-self: start; }
  .grid > .card > footer { align-self: end; }
}
.card.ancha { grid-column: 1 / -1; }
.card-h { display: flex; gap: 8px; align-items: flex-start; justify-content: space-between; }
.card h3 { margin: 0; font-size: 17px; font-weight: 600; line-height: 1.3; text-wrap: balance; }
:root[data-letra="grande"] .card h3 { font-size: 19px; }
.card .sub { margin: 4px 0 0; font-size: 13.5px; color: var(--muted); }
:root[data-letra="grande"] .card .sub { font-size: 15px; }
.barra { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 8px 12px; margin-top: 10px; }
.pestanas { display: inline-flex; gap: 2px; border-bottom: 1px solid var(--line); }
.pestanas button { border: 0; background: none; padding: 4px 10px 6px; font-size: var(--fs-s); color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.pestanas button[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--ink); font-weight: 500; }
.selectores { display: flex; flex-wrap: wrap; gap: 6px; }
.card .chart { height: 320px; margin-top: 4px; }
.card.ancha .chart { height: 370px; }
.card.alta .chart { height: 470px; }
.card.grande .chart { height: min(62vh, 680px); }
:root[data-letra="grande"] .card .chart { height: 350px; }
:root[data-letra="grande"] .card.ancha .chart { height: 400px; }
.leyenda { display: flex; flex-wrap: nowrap; gap: 4px 14px; margin-top: 10px; font-size: 13px; color: var(--ink-2); min-height: 20px; align-items: flex-start; }
.leyenda .items { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 14px; flex: 1; min-width: 0; }
.leyenda .items:empty { display: none; }
.leyenda .fija.desde { margin-left: auto; font-size: 12px; font-style: italic; }
:root[data-letra="grande"] .leyenda, :root[data-letra="grande"] .leyenda button { font-size: 14.5px; }
.leyenda:empty { display: none; }
.leyenda .fecha { font-weight: 600; color: var(--ink); font-variant-numeric: tabular-nums; min-width: 52px; flex: none; padding: 1px 0; }
.leyenda button { border: 0; background: none; padding: 1px 0; display: inline-flex; align-items: center; gap: 7px; cursor: pointer; color: var(--ink-2); font-size: 13px; text-align: left; }
.leyenda button[aria-pressed="false"] { opacity: 0.4; }
.leyenda span.fija { display: inline-flex; align-items: center; gap: 7px; color: var(--muted); }
.leyenda b { color: var(--ink); font-weight: 600; font-variant-numeric: tabular-nums; }
.leyenda small.der { color: var(--muted); font-size: 11px; font-weight: 500; letter-spacing: .01em; margin-left: 1px; }
.leyenda .ley-det { flex-basis: 100%; display: flex; flex-wrap: wrap; align-items: center; gap: 2px 0; margin-top: 2px; font-size: 12px; color: var(--muted); line-height: 1.5; }
.leyenda .ley-det .sep { margin: 0 8px; opacity: .6; }
.leyenda .ley-det .nber { display: inline-flex; align-items: center; gap: 6px; }
.sw { flex: none; display: inline-block; width: 16px; height: 0; border-top: 2.5px solid currentColor; border-radius: 2px; }
.sw.barra { display: inline-block; margin: 0; gap: 0; height: 10px; border: 0; background: currentColor; border-radius: 2px; width: 10px; }   /* la clase choca con la barra de pestañas (.barra): se anula su margen */
.sw.barra.suave { opacity: 0.4; }
.sw.area { height: 10px; border: 0; background: currentColor; opacity: 0.55; border-radius: 2px; width: 12px; }
.sw.punteada { border-top-style: dashed; }
.sw.fina { border-top-width: 1.5px; opacity: 0.6; }
.sw.punto { width: 8px; height: 8px; border: 2.5px solid currentColor; transform: rotate(45deg); margin: 0 3px; background: var(--surface); }
.card.muy-alta .chart { height: 780px; }
@media (max-width: 900px) { .card.muy-alta .chart { height: 900px; } }
.sw.ref { border-top: 1.5px dashed var(--ref); }
.sw.banda { height: 10px; width: 14px; border: 0; background: var(--band); outline: 1px solid var(--line); }
.sw.rec { height: 10px; width: 14px; border: 0; background: var(--rec); outline: 1px solid var(--line); }
.meta-g { margin-top: 6px; font-size: var(--fs-xs); color: var(--muted); display: flex; flex-wrap: wrap; gap: 2px 12px; }
.meta-g span[title] { cursor: help; }
.card footer { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 8px 12px; border-top: 1px solid var(--line); margin-top: 8px; padding-top: 8px; font-size: var(--fs-xs); color: var(--muted); }
.acciones { display: flex; gap: 6px; flex-wrap: wrap; margin-left: auto; }
.acciones button { border: 1px solid var(--line); background: none; border-radius: 6px; padding: 4px 10px; font-size: 12.5px; color: var(--ink-2); cursor: pointer; display: inline-flex; align-items: center; gap: 5px; }
.acciones button:hover { background: var(--hover); }
.acciones svg { width: 13px; height: 13px; }
.panel-tabla { margin-top: 10px; max-height: 360px; overflow: auto; border: 1px solid var(--line); border-radius: 8px; }
.card.grande .panel-tabla { max-height: 62vh; }
table.datos { border-collapse: collapse; width: 100%; font-size: 13px; font-variant-numeric: tabular-nums; }
table.datos th, table.datos td { padding: 6px 10px; text-align: right; white-space: nowrap; border-bottom: 1px solid var(--grid); }
table.datos th:first-child, table.datos td:first-child { text-align: left; }
table.datos thead th { position: sticky; top: 0; background: var(--surface); color: var(--ink-2); font-weight: 500; }
.panel-fuentes { margin-top: 10px; display: grid; gap: 14px; font-size: var(--fs-s); color: var(--ink-2); }
.panel-fuentes h4 { margin: 0 0 6px; font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); font-weight: 600; }
.panel-fuentes p { margin: 0; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 8px; }
.stats div { background: var(--surface-2); border-radius: 8px; padding: 8px 10px; }
.stats div span { display: block; font-size: var(--fs-xs); color: var(--muted); }
.stats div b { font-size: 16px; font-weight: 600; color: var(--ink); font-variant-numeric: tabular-nums; }
.stats div small { display: block; font-size: 11.5px; color: var(--muted); }

/* ───────── Tablero ───────── */
.filtros { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; align-items: center; }
.filtros > button { border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 4px 12px; font-size: var(--fs-s); color: var(--ink-2); cursor: pointer; }
.filtros > button[aria-pressed="true"] { background: var(--ink); color: var(--surface); border-color: var(--ink); }
.filtros .der { margin-left: auto; display: flex; gap: 8px; align-items: center; font-size: var(--fs-xs); color: var(--muted); }
.btn { border: 1px solid var(--line); background: var(--surface); border-radius: 6px; padding: 5px 12px; font-size: var(--fs-s); cursor: pointer; color: var(--ink-2); display: inline-flex; align-items: center; gap: 6px; }
.btn:hover { background: var(--hover); }
.btn svg { width: 14px; height: 14px; }
.tablero { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); overflow-x: auto; }
.tablero table { border-collapse: collapse; width: 100%; font-size: 13.5px; min-width: 960px; font-variant-numeric: tabular-nums; }
:root[data-letra="grande"] .tablero table { font-size: 15px; }
.tablero th, .tablero td { padding: 8px 9px; text-align: right; white-space: nowrap; border-bottom: 1px solid var(--grid); }
.tablero th:first-child, .tablero td:first-child { text-align: left; }
.tablero thead th { background: var(--surface); color: var(--muted); font-weight: 500; font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: 0.04em; cursor: pointer; user-select: none; }
.tablero thead th[aria-sort="ascending"]::after { content: " ▲"; font-size: 9px; }
.tablero thead th[aria-sort="descending"]::after { content: " ▼"; font-size: 9px; }
.tablero tr.grupo td { background: var(--surface-2); color: var(--ink-2); font-weight: 600; font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: 0.06em; padding-top: 10px; }
.tablero tbody tr.fila { cursor: pointer; }
.tablero tbody tr.fila:hover td { background: var(--hover); }
.tablero td.nom b { font-weight: 500; }
.tablero td.nom small { display: block; color: var(--muted); font-size: var(--fs-xs); }
.tablero td.val { font-weight: 600; font-size: 14.5px; }
.tablero td svg { width: 92px; height: 26px; display: block; margin-left: auto; }
.barra-p { display: inline-flex; align-items: center; gap: 8px; }
.barra-p i { position: relative; display: inline-block; width: 60px; height: 4px; background: var(--grid); border-radius: 2px; }
.barra-p i s { position: absolute; top: 0; height: 4px; background: var(--band); outline: 1px solid var(--line); text-decoration: none; }
.barra-p i b { position: absolute; top: -3px; width: 2px; height: 10px; background: var(--ink-2); border-radius: 1px; }
.rev { color: var(--s2); font-weight: 600; cursor: help; }

/* ───────── Calendario ───────── */
.cal-nav { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; margin-bottom: 12px; }
.cal-nav h2 { margin: 0; font-size: 18px; font-weight: 600; flex: 1 1 auto; }
.semana-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px; }
.dia { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); min-width: 0; display: flex; flex-direction: column; }
.dia.hoy { border-color: var(--s4); box-shadow: 0 0 0 1px var(--s4); }
.dia header { padding: 10px 14px 8px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.dia header b { font-size: 14px; font-weight: 600; text-transform: capitalize; }
.dia header span { font-size: var(--fs-xs); color: var(--muted); }
.dia header .etiq-hoy { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; color: var(--ink); background: var(--hoy); padding: 0 6px; border-radius: 4px; }
.dia .eventos { padding: 8px; display: grid; gap: 8px; align-content: start; flex: 1; }
.evento { border: 1px solid var(--line); border-left: 3px solid var(--axis); border-radius: 8px; padding: 8px 10px; background: var(--surface); display: grid; gap: 3px; text-decoration: none; color: inherit; }
a.evento:hover { border-color: var(--axis); background: var(--hover); }
.evento.alta { border-left-color: var(--s2); }
.evento .hora { font-size: 11.5px; color: var(--muted); font-variant-numeric: tabular-nums; display: flex; justify-content: space-between; gap: 6px; flex-wrap: wrap; }
.estado-r { font-weight: 600; font-size: 11px; display: inline-flex; align-items: center; gap: 4px; }
.estado-r i { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.estado-r.pub { color: var(--ok); } .estado-r.esp { color: var(--alerta); } .estado-r.sin { color: var(--neutro); } .estado-r.prog { color: var(--muted); }
.evento b { font-size: 13.5px; font-weight: 600; line-height: 1.3; }
.evento .res { font-size: 12.5px; color: var(--ink-2); display: grid; gap: 1px; }
.evento .res span b { font-size: 12.5px; font-variant-numeric: tabular-nums; color: var(--ink); }
.evento .res small { color: var(--muted); }
.dia .nada { color: var(--muted); font-size: 12.5px; padding: 6px 6px; }
.cal-pie { margin-top: 12px; font-size: 12.5px; color: var(--muted); max-width: 118ch; }
.leyenda-estados { display: flex; flex-wrap: wrap; gap: 4px 16px; font-size: var(--fs-xs); color: var(--muted); margin-top: 8px; }

/* ───────── Explorador ───────── */
.explorador { display: grid; gap: 16px; }
.selector { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 16px 18px; display: grid; gap: 10px; }
.selector .filas { display: grid; gap: 8px; }
.selector .fila { display: grid; grid-template-columns: 14px minmax(0, 2.2fr) minmax(0, 1.4fr) auto; gap: 10px; align-items: center; }
.selector .fila i { width: 12px; height: 12px; border-radius: 3px; }
.selector select { border: 1px solid var(--line); border-radius: 6px; background: var(--surface); padding: 6px 8px; font-size: var(--fs-s); min-width: 0; width: 100%; }
.selector .botones { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.selector .op { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; font-size: var(--fs-s); color: var(--ink-2); border-top: 1px solid var(--line); padding-top: 10px; }
.selector .op select { width: auto; }

/* ───────── Metodología ───────── */
.metodo { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 20px; align-items: start; }
.metodo nav { position: sticky; top: 64px; display: grid; gap: 2px; }
.metodo nav a { text-decoration: none; color: var(--ink-2); padding: 7px 10px; border-radius: 6px; font-size: var(--fs-s); }
.metodo nav a:hover { background: var(--hover); }
.metodo nav a[aria-current="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 0 0 1px var(--line); font-weight: 500; }
.doc { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 22px 26px; min-width: 0; }
.doc h2 { margin: 0 0 6px; font-size: 20px; }
.doc h3 { margin: 22px 0 6px; font-size: 16px; }
.doc p, .doc li { color: var(--ink-2); max-width: 90ch; }
.doc dl { display: grid; grid-template-columns: 200px 1fr; gap: 8px 16px; margin: 12px 0 0; }
.doc dt { font-weight: 600; color: var(--ink); }
.doc dd { margin: 0; color: var(--ink-2); }
.doc .tabla-wrap { overflow-x: auto; margin-top: 12px; border: 1px solid var(--line); border-radius: 8px; }
.doc table.datos td, .doc table.datos th { text-align: left; }
.ficha-g { border-top: 1px solid var(--line); padding: 12px 0; }
.ficha-g b a { color: var(--ink); text-decoration: none; }
.ficha-g b a:hover { text-decoration: underline; }
.ficha-g p { margin: 3px 0 0; font-size: var(--fs-s); }
.punto { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; background: var(--ok); }
.punto.alerta { background: var(--alerta); } .punto.error { background: var(--error); }

/* ───────── Ventanas ───────── */
.modal { position: fixed; inset: 0; z-index: 50; background: var(--scrim); display: grid; place-items: center; padding: clamp(8px, 3vw, 32px); }
.dialogo { background: var(--surface); border-radius: 12px; width: min(1400px, 100%); max-height: 100%; overflow: auto; display: flex; flex-direction: column; box-shadow: 0 20px 60px rgba(0,0,0,0.3); min-width: 0; position: relative; }
.dialogo > .card { border: 0; padding: 20px 22px 12px; }
.dialogo .cerrar { position: absolute; top: 12px; right: 12px; z-index: 2; }
.dialogo .panel-doc { padding: 22px; }
.dialogo .panel-doc h2 { margin: 0 0 4px; font-size: 20px; padding-right: 44px; }
.dialogo .panel-doc > p { margin: 0 0 8px; color: var(--muted); font-size: var(--fs-s); }
.cerrar { border: 1px solid var(--line); background: var(--surface); border-radius: 8px; width: 36px; height: 36px; cursor: pointer; flex: none; display: grid; place-items: center; }
.cerrar:hover { background: var(--hover); }
.card.grande .card-h { padding-right: 44px; }
.card.grande h3 { font-size: 20px; }
.estado-tabla { margin-top: 12px; max-height: 60vh; overflow: auto; }
.estado-tabla table { border-collapse: collapse; width: 100%; font-size: 13px; }
.estado-tabla th, .estado-tabla td { padding: 6px 10px; border-bottom: 1px solid var(--grid); text-align: left; white-space: nowrap; }
.estado-tabla thead th { position: sticky; top: 0; background: var(--surface); color: var(--muted); font-weight: 500; font-size: 12px; }

/* Buscador */
.buscador { position: fixed; inset: 0; z-index: 60; background: var(--scrim); display: flex; justify-content: center; align-items: flex-start; padding: 12vh 16px 16px; }
.buscador .caja { width: min(640px, 100%); background: var(--surface); border-radius: 12px; box-shadow: 0 20px 60px rgba(0,0,0,0.3); overflow: hidden; display: flex; flex-direction: column; max-height: 70vh; }
.buscador input { border: 0; border-bottom: 1px solid var(--line); padding: 16px 18px; font-size: 17px; background: none; outline: none; }
.buscador .res { overflow: auto; padding: 6px; }
.buscador .grupo { font-size: var(--fs-xs); color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; padding: 8px 12px 4px; font-weight: 600; }
.buscador .item { display: flex; gap: 12px; align-items: baseline; padding: 8px 12px; border-radius: 8px; cursor: pointer; }
.buscador .item[aria-selected="true"] { background: var(--hover); box-shadow: inset 2px 0 0 var(--s1); }
.buscador .item span { flex: 1; min-width: 0; }
.buscador .item small { color: var(--muted); font-size: var(--fs-xs); white-space: nowrap; }
.buscador .pie-b { border-top: 1px solid var(--line); padding: 8px 14px; font-size: var(--fs-xs); color: var(--muted); display: flex; gap: 14px; flex-wrap: wrap; }
.ayuda-atajos { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px 24px; margin-top: 8px; }
.ayuda-atajos div { display: flex; justify-content: space-between; gap: 12px; padding: 5px 0; border-bottom: 1px solid var(--grid); font-size: var(--fs-s); }

.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 70; background: var(--ink); color: var(--surface); border-radius: 8px; padding: 8px 14px; font-size: var(--fs-s); box-shadow: 0 8px 24px rgba(0,0,0,0.2); }
.estado { margin-top: 40px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 28px; max-width: 640px; }
.estado h2 { margin: 0 0 8px; font-size: 18px; }
.estado p { margin: 0; color: var(--ink-2); }
.vacio-mi { background: var(--surface); border: 1px dashed var(--axis); border-radius: var(--r); padding: 24px; color: var(--ink-2); }
.pie { margin-top: 36px; font-size: 12.5px; color: var(--muted); display: flex; flex-wrap: wrap; gap: 6px 18px; justify-content: space-between; }
.pie a { color: var(--muted); }

@media (max-width: 1100px) {
  .tiles { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .cabecera .tiles { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .semana-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .buscar-btn { min-width: 0; }
  .buscar-btn span, .buscar-btn kbd { display: none; }
}
@media (max-width: 900px) {
  .grid, .dupla { grid-template-columns: minmax(0, 1fr); }
  .card .chart { height: 300px; }
  .card.alta .chart { height: 520px; }
  .semana-grid { grid-template-columns: minmax(0, 1fr); }
  .metodo { grid-template-columns: minmax(0, 1fr); }
  .metodo nav { position: static; display: flex; flex-wrap: wrap; }
  .tabs { display: none; }
  .nav-movil { display: flex; }
  .buscar-btn { display: none; }
  .herr { width: 100%; justify-content: space-between; }
  .periodo { min-width: 0; flex: 1; }
  .periodo .seg { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; max-width: 100%; }
  .periodo .seg::-webkit-scrollbar { display: none; }
  .periodo { flex-wrap: nowrap; gap: 6px; }
  .periodo .seg { min-width: 0; }
  .b-fechas { padding: 6px 9px; flex: none; }
  .b-fechas span { display: none; }
}
@media (max-width: 560px) {
  .marca h1 { font-size: 19px; }
  /* cabecera: período a lo ancho, con botones iguales; fechas y ajustes como íconos al lado */
  .herr { flex-wrap: nowrap; gap: 6px; }
  .periodo { flex: 1; min-width: 0; gap: 6px; }
  .periodo .seg { flex: 1; overflow: visible; }
  .periodo #rango button { flex: 1; min-width: 0; padding: 6px 2px; font-size: 13px; }
  .ua { display: none; }
  .ub { display: inline; }
  .seg.periodo { flex-wrap: nowrap; max-width: 100%; }
  .seg.periodo button { flex: 1; padding: 3px 6px; }
  .b-fechas { padding: 8px 10px; }
  /* indicadores: una fila por dato, como una lista de cotizaciones (nombre y fecha · tendencia · valor y cambio) */
  .tiles, .cabecera .tiles { grid-template-columns: minmax(0, 1fr); gap: 8px; }
  .tiles > .tile, .tile { grid-row: auto; grid-template-rows: none; grid-template-columns: minmax(0, 1fr) 76px auto;
    grid-template-areas: "lab spark val" "del spark cmb" "pctl pctl pctl"; column-gap: 12px; row-gap: 1px; align-items: center; padding: 10px 12px; }
  .tile .lab { grid-area: lab; padding-right: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .tile .del { grid-area: del; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .tile svg.spark { grid-area: spark; height: 30px; margin: 0; }
  .tile .val, .cabecera .tile .val { grid-area: val; font-size: 21px; margin: 0; text-align: right; white-space: nowrap; }
  .tile .val small { font-size: 13px; }
  .tile .cmb { grid-area: cmb; text-align: right; white-space: nowrap; min-height: 0; }
  .tile > .pctl { grid-area: pctl; margin-top: 4px; grid-template-columns: 1fr auto; }
  .tile .star { display: none; }
  .tile .cmb .vs { display: none; }
  .lectura li, .lista li { grid-template-columns: 1fr; gap: 2px; }
  .card { padding: 14px 12px 10px; }
  .card h3 { font-size: 16px; }
  .dialogo > .card { padding: 14px 12px 10px; }
  .periodo, .manual { justify-content: flex-start; }
  .herr { justify-content: flex-start; width: 100%; }
  .selector .fila { grid-template-columns: 12px minmax(0, 1fr) auto; }
  .selector .fila select[data-campo="k"] { grid-column: 2 / 4; }
  .selector .fila select[data-campo="t"] { grid-column: 2; }
  .cabecera { padding: 14px; }
  .filtros .der { margin-left: 0; width: 100%; }
  .doc { padding: 16px; }
  .doc dl { grid-template-columns: 1fr; }
  .ayuda-atajos { grid-template-columns: 1fr; }
  .buscador { padding-top: 8vh; }
}
@media print {
  .top .herr, .tabs, .nav-movil, .acciones, .star, .pestanas, .selectores, .pie { display: none !important; }
  body { background: #fff; }
  .card, .panel, .cabecera { break-inside: avoid; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* "?" de cada gráfico */
.ayuda-b { font: 700 13px/1 var(--font); color: var(--muted); border: 1.3px solid var(--axis); border-radius: 50%; width: 20px; height: 20px; margin-top: 2px; }
.ayuda-b:hover { color: var(--ink); border-color: var(--ink-2); background: var(--hover); }
.card-h .ayuda-b + .star { margin-left: -4px; }
.pop.ayuda { max-width: 360px; padding: 12px 14px; font-size: 13.5px; line-height: 1.5; color: var(--ink-2); }
.pop.ayuda p { margin: 0; }
.pop.ayuda p + p { margin-top: 8px; }
.pop.ayuda b { color: var(--ink); font-weight: 600; }
.card-h > h3 { flex: 1; min-width: 0; }
/* tarjeta: sólo el nombre; el contexto aparece al ampliar */
.card .sub:empty { margin: 0; min-height: 0; }
.card.grande .contexto { margin: 6px 0 2px; font-size: 15px; line-height: 1.5; color: var(--ink); font-weight: 500; max-width: 980px; }
.card.grande .sub { max-width: 980px; }
.card.grande .selectores { flex-wrap: wrap; gap: 8px; }
.seg.periodo button[aria-pressed="true"] { font-weight: 600; }
/* logo y nombre llevan a la portada */
.marca a.inicio { color: inherit; text-decoration: none; cursor: pointer; }
.marca a.logo.inicio { display: grid; place-items: center; color: var(--surface); }
.marca h1 a.inicio:hover { opacity: 0.8; }
