/* Una sola hoja de estilos. Claro por defecto; oscuro solo si el sistema lo pide (sin boton ni JS).
   Los pares de colores estan verificados en tests/test_website.py (contraste WCAG AA). */
:root {
  --bg: #ffffff;
  --fg: #14181c;
  --muted: #5b6670;
  --line: #dfe3e7;
  --accent: #0b5cad;
  --up: #a4241b;
  --down: #137333;
  --notice-bg: #fff3d6;
  --notice-fg: #5c3f00;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1418;
    --fg: #e8ecef;
    --muted: #9aa5ae;
    --line: #26303a;
    --accent: #6cb2ff;
    --up: #ff8a80;
    --down: #7fd99a;
    --notice-bg: #2b2410;
    --notice-fg: #f0d58a;
  }
}

* { box-sizing: border-box; }
html { font: 16px/1.55 var(--font); background: var(--bg); color: var(--fg); -webkit-text-size-adjust: 100%; }
body { margin: 0; }
a { color: var(--accent); }
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.wrap { max-width: 56rem; margin: 0 auto; padding: 0 1rem; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.r { text-align: right; }
.up { color: var(--up); }
.down { color: var(--down); }

header.site { border-bottom: 1px solid var(--line); }
header.site .wrap { display: flex; flex-wrap: wrap; align-items: baseline; gap: .25rem 1.5rem; padding-block: .75rem; }
.brand { margin-right: auto; font-weight: 700; color: var(--fg); text-decoration: none; }
.asof { order: 3; color: var(--muted); font-size: .85rem; white-space: nowrap; }
nav { display: flex; flex-wrap: wrap; gap: .25rem 1.25rem; }
nav a { color: var(--fg); text-decoration: none; padding-block: .1rem; border-bottom: 2px solid transparent; }
nav a[aria-current="page"] { border-bottom-color: var(--accent); font-weight: 600; }

.notice { background: var(--notice-bg); color: var(--notice-fg); font-size: .9rem; }
.notice .wrap { padding-block: .5rem; }

h1 { font-size: 1.75rem; line-height: 1.2; margin: 1.75rem 0 .5rem; }
h2 { font-size: 1.15rem; line-height: 1.3; margin: 2.25rem 0 .5rem; }
h3 { font-size: .95rem; line-height: 1.3; margin: .25rem 0 .35rem; color: var(--muted); font-weight: 600; }
p, ul { margin: .5rem 0 1rem; }
ul { padding-left: 1.25rem; }
.lead { color: var(--muted); max-width: 42rem; }
.prose { max-width: 42rem; }

.hero { display: grid; grid-template-columns: repeat(auto-fit, minmax(18rem, 1fr)); gap: 1rem 2rem; align-items: center; margin: 2rem 0 1.5rem; }
.hero h1 { margin: 0 0 .5rem; font-size: 1.5rem; font-weight: 600; }
.hero p { margin: .25rem 0; }
.hero .trend { margin-top: .5rem; }
.hero-chart { margin: 0; }
.big { display: block; font-size: clamp(2.75rem, 11vw, 4.25rem); font-weight: 700; line-height: 1.05; }

.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr)); gap: 1px; margin: 0 0 1rem; background: var(--line); border: 1px solid var(--line); }
.facts > div { background: var(--bg); padding: .9rem 1rem; }
.facts dt { color: var(--muted); font-size: .875rem; }
.facts dd { margin: .1rem 0 0; }
.facts .value { font-size: 1.6rem; font-weight: 600; }
.facts .sub { color: var(--muted); font-size: .85rem; }

.movers { display: grid; grid-template-columns: repeat(auto-fit, minmax(17rem, 1fr)); gap: 0 2rem; }
.moves { list-style: none; margin: 0; padding: 0; }
.moves li { display: grid; grid-template-columns: 1fr auto 5.5rem; gap: .5rem; padding: .45rem 0; border-bottom: 1px solid var(--line); }
.moves a { overflow-wrap: anywhere; }
.moves .num { text-align: right; }

.tablewrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .95rem; }
th, td { padding: .55rem .5rem; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { color: var(--muted); font-size: .85rem; font-weight: 600; }
th.r, td.r { text-align: right; }
td.num, th.r { white-space: nowrap; }
td .sub { display: block; color: var(--muted); font-size: .85rem; }
.when { display: none; }
th button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
th button::after { content: " ↕"; opacity: .45; }
th[aria-sort="ascending"] button::after { content: " ↑"; opacity: 1; }
th[aria-sort="descending"] button::after { content: " ↓"; opacity: 1; }
tfoot th, tfoot td { border-bottom: 0; color: var(--fg); font-size: 1rem; }
tr.missing td { color: var(--muted); }

.filters { display: grid; gap: .6rem; margin: 1rem 0 .5rem; }
.filters input { font: inherit; padding: .45rem .6rem; color: var(--fg); background: var(--bg); border: 1px solid var(--line); border-radius: 4px; width: 100%; max-width: 24rem; }
.chips { display: flex; flex-wrap: wrap; gap: .4rem; }
.chip { font: inherit; font-size: .875rem; padding: .25rem .7rem; color: var(--fg); background: var(--bg); border: 1px solid var(--line); border-radius: 999px; cursor: pointer; }
.chip .n { color: var(--muted); margin-left: .15rem; }
.chip[aria-pressed="true"] { color: #fff; background: var(--accent); border-color: var(--accent); }
.chip[aria-pressed="true"] .n { color: inherit; }
#count { margin: .25rem 0; }

figure { margin: .5rem 0 1rem; }
figcaption { margin-top: .25rem; }
.chart { display: block; width: 100%; max-width: 40rem; height: auto; }
.chart .grid { stroke: var(--line); stroke-width: 1; vector-effect: non-scaling-stroke; }
.chart .line { fill: none; stroke: var(--accent); stroke-width: 2; stroke-linejoin: round; vector-effect: non-scaling-stroke; }
.chart .dot { fill: var(--accent); }

.crumbs { margin: 1.25rem 0 0; font-size: .9rem; }
footer.site { margin-top: 3rem; border-top: 1px solid var(--line); color: var(--muted); font-size: .875rem; }
footer.site .wrap { padding-block: 1.25rem 2rem; }
footer.site .links { display: flex; flex-wrap: wrap; gap: .25rem 1rem; }
footer.site a { color: var(--muted); }
footer.site p { margin: .5rem 0; }

.consent { position: fixed; inset: auto 0 0 0; z-index: 10; background: var(--bg); border-top: 1px solid var(--line); font-size: .9rem; }
.consent .wrap { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem 1rem; padding-block: .75rem; }
.consent p { margin: 0; flex: 1 1 18rem; }
.consent button { font: inherit; padding: .4rem .9rem; color: var(--fg); background: var(--bg); border: 1px solid var(--line); border-radius: 4px; cursor: pointer; }
.consent button.primary { color: #fff; background: var(--accent); border-color: var(--accent); }
@media (prefers-color-scheme: dark) {
  .consent button.primary, .chip[aria-pressed="true"] { color: #0f1418; }
}

@media (max-width: 40rem) {
  .asof { order: 0; }
  header.site nav { order: 3; flex-basis: 100%; }
  .moves li { grid-template-columns: 1fr auto 5rem; }
  th, td { padding: .5rem .35rem; }
  .hide-sm { display: none; }
  .when { display: inline; }
}
[hidden] { display: none !important; }
