/* ============ Tokens ============ */
:root {
  --bg: #f5f5f8;
  --surface: #ffffff;
  --surface-2: #f0eff6;
  --ink: #16141f;
  --ink-2: #474457;
  --muted: #6f6c80;
  --line: #e2e0ea;

  --brand: #5b3fd6;          /* violeta Libertad */
  --brand-ink: #4429b5;
  --brand-soft: #ece8fd;

  --af: #3a8fb7;             /* identidad gestión Fernández (gráficos) */
  --mi: #6a42e0;             /* identidad gestión Milei (gráficos) */
  --other: #9a98a8;

  --good: #18794a;  --good-soft: #e2f3e9;
  --bad: #c0331e;   --bad-soft: #fbe6e2;
  --warn: #a45f00;  --warn-soft: #fdf0d8;

  --radius: 14px;
  --shadow: 0 1px 2px rgba(20, 16, 40, .06), 0 4px 16px rgba(20, 16, 40, .05);
  --font: "Public Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --serif: "Source Serif 4", Georgia, serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e0e14; --surface: #16161e; --surface-2: #1d1c27;
    --ink: #eeedf5; --ink-2: #c3c1d2; --muted: #9592a8; --line: #2b2a38;
    --brand: #8b6cf0; --brand-ink: #a993f5; --brand-soft: #262040;
    --af: #3b98c6; --mi: #8b6cf0; --other: #6e6c7e;
    --good: #4cc38a; --good-soft: #13291f;
    --bad: #f0735e;  --bad-soft: #33181a;
    --warn: #f0b44c; --warn-soft: #2f2412;
    --shadow: 0 1px 2px rgba(0,0,0,.4);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0e0e14; --surface: #16161e; --surface-2: #1d1c27;
  --ink: #eeedf5; --ink-2: #c3c1d2; --muted: #9592a8; --line: #2b2a38;
  --brand: #8b6cf0; --brand-ink: #a993f5; --brand-soft: #262040;
  --af: #3b98c6; --mi: #8b6cf0; --other: #6e6c7e;
  --good: #4cc38a; --good-soft: #13291f;
  --bad: #f0735e;  --bad-soft: #33181a;
  --warn: #f0b44c; --warn-soft: #2f2412;
  --shadow: 0 1px 2px rgba(0,0,0,.4);
  color-scheme: dark;
}

/* ============ Base ============ */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 130px; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 400 16px/1.55 var(--font); -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { margin: 0; line-height: 1.15; text-wrap: balance; }
h1, h2 { font-family: var(--serif); font-weight: 700; letter-spacing: -.01em; }
p { margin: 0; }
a { color: var(--brand-ink); }
button { font: inherit; color: inherit; }
.wrap { width: 100%; max-width: 1180px; margin: 0 auto; padding: 0 16px; }
.muted { color: var(--muted); font-size: .875rem; }
.eyebrow { font-size: .75rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--brand-ink); margin-bottom: 6px; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--brand); color: #fff; padding: 8px 12px; border-radius: 8px; z-index: 100; }
.skip:focus { left: 8px; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

/* ============ Navbar ============ */
.nav {
  position: sticky; top: 0; z-index: 50;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--line);
}
.nav__row { display: flex; align-items: center; gap: 12px; padding-top: 10px; padding-bottom: 10px; flex-wrap: wrap; }
.logo { display: inline-flex; align-items: center; gap: 8px; text-decoration: none; color: var(--ink); }
.logo__mark {
  display: grid; place-items: center; width: 32px; height: 32px; border-radius: 9px;
  background: var(--brand); color: #fff; font: 800 18px/1 var(--serif);
}
.logo__text { font-weight: 600; font-size: 1.05rem; letter-spacing: -.01em; }
.logo__text b { color: var(--brand-ink); font-weight: 800; }
.logo__text small { color: var(--muted); font-weight: 500; font-size: .85em; }
.icon-btn {
  margin-left: auto; width: 38px; height: 38px; display: grid; place-items: center;
  border: 1px solid var(--line); background: var(--surface); border-radius: 10px; cursor: pointer;
}
.icon-btn svg { width: 18px; height: 18px; fill: var(--ink-2); }

.search { position: relative; order: 3; flex: 1 1 100%; }
.search input {
  width: 100%; height: 40px; padding: 0 12px 0 38px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--surface-2); color: var(--ink); font: inherit; font-size: .95rem;
}
.search input:focus { outline: none; border-color: var(--brand); background: var(--surface); box-shadow: 0 0 0 3px var(--brand-soft); }
.search__icon { position: absolute; left: 12px; top: 50%; width: 17px; height: 17px; transform: translateY(-50%); fill: var(--muted); pointer-events: none; }
.search__results {
  position: absolute; left: 0; right: 0; top: calc(100% + 6px); margin: 0; padding: 6px; list-style: none;
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow);
  max-height: 60vh; overflow: auto;
}
.search__results li button {
  display: flex; width: 100%; gap: 10px; align-items: baseline; text-align: left;
  border: 0; background: none; padding: 9px 10px; border-radius: 8px; cursor: pointer;
}
.search__results li button:hover, .search__results li button[aria-selected="true"] { background: var(--surface-2); }
.search__results .type { flex: none; font-size: .68rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--brand-ink); width: 70px; }
.search__results .none { padding: 10px; color: var(--muted); font-size: .9rem; }

.nav__links { padding-bottom: 10px; }
.chips { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
.chips--wrap { flex-wrap: wrap; overflow: visible; }
a.chip { text-decoration: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; border: 1px solid var(--line); background: var(--surface); color: var(--ink-2);
  padding: 6px 12px; border-radius: 999px; font-size: .82rem; font-weight: 600; cursor: pointer; white-space: nowrap;
}
.chip:hover { border-color: var(--brand); color: var(--brand-ink); }
.chip[aria-pressed="true"] { background: var(--brand); border-color: var(--brand); color: #fff; }

@media (min-width: 760px) {
  .search { order: 0; flex: 0 1 420px; margin-left: auto; }
  .icon-btn { margin-left: 0; }
}

/* ============ Hero / KPIs ============ */
.hero { padding: 36px 0 32px; background: linear-gradient(180deg, var(--brand-soft), var(--bg) 85%); }
.hero h1 { font-size: clamp(2rem, 6vw, 3.4rem); max-width: 16ch; }
.hero h1 em { font-style: normal; color: var(--brand-ink); }
.lead { margin-top: 12px; font-size: 1.05rem; color: var(--ink-2); max-width: 62ch; }
.hero__meta { margin-top: 10px; font-size: .82rem; color: var(--muted); }
.kpis { display: grid; grid-template-columns: 1fr; gap: 12px; margin-top: 24px; }
@media (min-width: 560px) { .kpis { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1000px) { .kpis { grid-template-columns: repeat(4, 1fr); } }
.kpi {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 6px;
}
.kpi__title { font-size: .8rem; font-weight: 700; color: var(--ink-2); text-transform: uppercase; letter-spacing: .05em; }
.kpi__value { font: 700 clamp(1.7rem, 6vw, 2.2rem)/1.05 var(--font); font-variant-numeric: tabular-nums; letter-spacing: -.02em; white-space: nowrap; }
@media (min-width: 1000px) { .kpi__value { font-size: clamp(1.6rem, 2.4vw, 2.1rem); } }
.kpi__value small { font-size: .45em; font-weight: 600; color: var(--muted); letter-spacing: 0; }
.kpi__when { font-size: .8rem; color: var(--muted); }
.kpi__before { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 6px 8px; align-items: center; margin-top: auto; padding-top: 10px; border-top: 1px dashed var(--line); font-size: .85rem; color: var(--ink-2); }
.kpi__src { font-size: .72rem; color: var(--muted); }

/* ============ Badges ============ */
.badge {
  display: inline-flex; align-items: center; gap: 4px; padding: 3px 8px; border-radius: 999px;
  font-size: .72rem; font-weight: 700; white-space: nowrap; border: 1px solid transparent;
}
.badge--good { background: var(--good-soft); color: var(--good); }
.badge--bad { background: var(--bad-soft); color: var(--bad); }
.badge--warn { background: var(--warn-soft); color: var(--warn); }
.badge--neutral { background: var(--surface-2); color: var(--ink-2); border-color: var(--line); }
.badge--cat { background: var(--brand-soft); color: var(--brand-ink); }

/* ============ Sections ============ */
.section { padding: 44px 0; }
.section--alt { background: var(--surface-2); border-block: 1px solid var(--line); }
.section h2 { font-size: clamp(1.5rem, 4vw, 2rem); }
.section__head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 18px; }

/* Tabs */
.tabs { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; border-bottom: 1px solid var(--line); margin-bottom: 16px; }
.tabs::-webkit-scrollbar { display: none; }
.tab {
  flex: none; border: 0; background: none; padding: 10px 12px; font-weight: 600; font-size: .9rem; color: var(--muted);
  border-bottom: 2px solid transparent; margin-bottom: -1px; cursor: pointer; white-space: nowrap;
}
.tab:hover { color: var(--ink); }
.tab[aria-selected="true"] { color: var(--brand-ink); border-bottom-color: var(--brand); }
.tab .count { font-size: .72rem; color: var(--muted); margin-left: 4px; font-variant-numeric: tabular-nums; }
.tabs--sm .tab { font-size: .85rem; }

/* Switch */
.switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; user-select: none; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch__track { width: 42px; height: 24px; border-radius: 999px; background: var(--line); position: relative; transition: background .2s; flex: none; }
.switch__thumb { position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.25); transition: transform .2s; }
.switch input:checked + .switch__track { background: var(--brand); }
.switch input:checked + .switch__track .switch__thumb { transform: translateX(18px); }
.switch input:focus-visible + .switch__track { outline: 2px solid var(--brand); outline-offset: 2px; }
.switch__label { font-size: .9rem; font-weight: 600; color: var(--ink-2); }
@media (prefers-reduced-motion: reduce) { .switch__track, .switch__thumb { transition: none; } }

/* Legend */
.legend-row { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: .8rem; color: var(--ink-2); margin-bottom: 14px; }
.legend-row span { display: inline-flex; align-items: center; gap: 6px; }
.key { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.key--af { background: var(--af); }
.key--mi { background: var(--mi); }
.key--other { background: var(--other); }
.key--good { background: var(--good); }
.key--bad { background: var(--bad); }

/* ============ Destacados ============ */
.band { background: var(--brand); color: #fff; }
:root[data-theme="dark"] .band { background: #2a1f5c; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .band { background: #2a1f5c; } }
.band__grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 20px 16px; padding-top: 24px; padding-bottom: 24px; }
@media (min-width: 900px) { .band__grid { grid-template-columns: repeat(4, 1fr); } }
.band__value { font: 700 clamp(1.5rem, 4.5vw, 2rem)/1.1 var(--serif); font-variant-numeric: tabular-nums; }
.band__text { font-size: .86rem; margin-top: 4px; opacity: .92; }
.band__src { font-size: .7rem; margin-top: 4px; opacity: .7; text-transform: uppercase; letter-spacing: .06em; font-weight: 600; }

/* ============ Logros ============ */
.section__sub { margin-top: 6px; color: var(--muted); font-size: .9rem; }
.logros { display: grid; grid-template-columns: 1fr; gap: 14px; }
@media (min-width: 900px) { .logros { grid-template-columns: 1fr 1fr; } }
.logro {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 18px; scroll-margin-top: 140px; transition: box-shadow .3s, border-color .3s;
  display: flex; flex-direction: column; gap: 12px; min-width: 0;
}
.logro.is-flash, .tl.is-flash .tl__body { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.logro__head { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.logro__delta { margin-left: auto; font-weight: 800; font-size: .9rem; color: var(--good); font-variant-numeric: tabular-nums; }
.logro h3 { font-size: 1.12rem; line-height: 1.3; }

.cmp { display: grid; grid-template-columns: 1fr auto 1fr; align-items: stretch; gap: 8px; }
.cmp--solo { grid-template-columns: 1fr; }
.cmp__col { border-radius: 10px; padding: 10px 12px; background: var(--surface-2); min-width: 0; }
.cmp__col--antes { border-left: 3px solid var(--other); }
.cmp__col--ahora { border-left: 3px solid var(--good); background: var(--good-soft); }
.cmp__who { font-size: .68rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.cmp__col--ahora .cmp__who { color: var(--good); }
.cmp__dato { font-weight: 700; font-size: 1rem; line-height: 1.3; margin-top: 3px; font-variant-numeric: tabular-nums; }
.cmp__col--antes .cmp__dato { color: var(--ink-2); font-weight: 600; }
.cmp__per { font-size: .78rem; color: var(--muted); margin-top: 3px; }
.cmp__arrow { align-self: center; color: var(--muted); font-size: 1.1rem; }
@media (max-width: 479px) {
  .cmp { grid-template-columns: 1fr; }
  .cmp__arrow { transform: rotate(90deg); justify-self: center; line-height: 1; }
}
.sin-comparar .cmp { grid-template-columns: 1fr; }
.sin-comparar .cmp__col--antes, .sin-comparar .cmp__arrow { display: none; }

.logro__desc { font-size: .92rem; color: var(--ink-2); }
.logro__nota { font-size: .8rem; color: var(--muted); }
.logro__nota b { color: var(--ink-2); font-weight: 600; }
.logro__src { margin-top: auto; padding-top: 10px; border-top: 1px dashed var(--line); font-size: .78rem; color: var(--muted); display: flex; flex-wrap: wrap; gap: 4px 12px; }
.logro__src a { color: var(--brand-ink); font-weight: 600; text-decoration: none; overflow-wrap: anywhere; }
.logro__src a:hover { text-decoration: underline; }
.empty { padding: 24px; text-align: center; color: var(--muted); }

/* ============ Cronología ============ */
.timeline { list-style: none; margin: 0; padding: 0; position: relative; display: grid; gap: 10px; }
.timeline::before { content: ""; position: absolute; left: 7px; top: 6px; bottom: 6px; width: 2px; background: var(--line); }
.tl { position: relative; padding-left: 30px; scroll-margin-top: 140px; }
.tl::before { content: ""; position: absolute; left: 1px; top: 16px; width: 14px; height: 14px; border-radius: 50%; background: var(--surface); border: 3px solid var(--brand); }
.tl__date { font-size: .75rem; font-weight: 700; color: var(--brand-ink); letter-spacing: .04em; text-transform: uppercase; padding-top: 12px; }
.tl__body { margin-top: 4px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; transition: box-shadow .3s, border-color .3s; }
.tl__body h3 { font-size: 1rem; }
.tl__body p { font-size: .88rem; color: var(--ink-2); margin-top: 3px; }
@media (min-width: 760px) {
  .timeline { grid-template-columns: 1fr 1fr; column-gap: 28px; }
  .timeline::before { display: none; }
  .tl { padding-left: 0; display: grid; grid-template-columns: 110px 1fr; gap: 12px; align-items: start; }
  .tl::before { display: none; }
  .tl__date { padding-top: 14px; text-align: right; }
  .tl__body { margin-top: 0; border-left: 3px solid var(--brand); }
}

/* ============ Charts ============ */
.chart-card { margin: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.chart-card__head h3 { font-size: 1rem; margin-bottom: 8px; }
.legend-row--chart { margin-bottom: 4px; }
.chart-box { position: relative; height: 320px; }
@media (min-width: 760px) { .chart-box { height: 380px; } }
.chart-card__foot { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px; margin-top: 10px; }
.link-btn { border: 0; background: none; color: var(--brand-ink); font-weight: 600; font-size: .85rem; cursor: pointer; padding: 0; }
.chart-table { margin-top: 12px; overflow-x: auto; }
.chart-table table { border-collapse: collapse; width: 100%; font-size: .85rem; font-variant-numeric: tabular-nums; }
.chart-table th, .chart-table td { padding: 6px 10px; border-bottom: 1px solid var(--line); text-align: left; }
.chart-table td:last-child, .chart-table th:last-child { text-align: right; }

/* ============ Medidas ============ */
.med-tools { display: grid; gap: 10px; margin-bottom: 14px; }
.search--inline { order: 0; flex: none; margin-left: 0; max-width: 560px; }
.search--inline input { background: var(--surface); }
.table-wrap { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.med-table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.med-table th { text-align: left; font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding: 12px 14px; background: var(--surface-2); border-bottom: 1px solid var(--line); }
.med-table td { padding: 12px 14px; border-bottom: 1px solid var(--line); vertical-align: top; }
.med-table tr:last-child td { border-bottom: 0; }
.med-table .med__name { font-weight: 600; }
.med-table .med__detail { font-size: .82rem; color: var(--muted); margin-top: 2px; }
.med-table .norma { font-weight: 600; color: var(--brand-ink); white-space: nowrap; }
.med-table mark { background: var(--brand-soft); color: inherit; border-radius: 3px; padding: 0 2px; }
@media (max-width: 719px) {
  .med-table thead { display: none; }
  .med-table, .med-table tbody, .med-table tr, .med-table td { display: block; width: 100%; }
  .med-table tr { padding: 12px 14px; border-bottom: 1px solid var(--line); }
  .med-table tr:last-child { border-bottom: 0; }
  .med-table td { padding: 2px 0; border: 0; }
  .med-table td[data-label]:not(:first-child) { display: inline-block; width: auto; margin-right: 10px; font-size: .82rem; }
  .med-table td[data-label="Fecha"]::before { content: "· "; color: var(--muted); }
}

/* ============ Footer ============ */
.footer { background: var(--surface); border-top: 1px solid var(--line); padding: 40px 0 32px; font-size: .9rem; color: var(--ink-2); }
.footer__grid { display: grid; gap: 28px; }
@media (min-width: 860px) { .footer__grid { grid-template-columns: 1.4fr 1.2fr .9fr; } }
.footer h3 { font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; color: var(--ink); margin: 0 0 8px; }
.logo--footer { margin-bottom: 18px; }
.footer__list { margin: 0 0 10px; padding-left: 18px; }
.footer__list li { margin-bottom: 4px; }
.share { display: flex; flex-wrap: wrap; gap: 8px; }
.share__btn {
  display: inline-flex; align-items: center; padding: 8px 12px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--surface-2); color: var(--ink); text-decoration: none; font-weight: 600; font-size: .85rem; cursor: pointer;
}
.share__btn:hover { border-color: var(--brand); color: var(--brand-ink); }

/* Counter-safe: values never jump layout */
.kpi__value, .col__dato { font-variant-numeric: tabular-nums; }
