@font-face { font-family: 'Barlow'; font-weight: 400; font-display: swap; src: url(fonts/barlow-latin-400-normal.woff2) format('woff2'); }
@font-face { font-family: 'Barlow'; font-weight: 500; font-display: swap; src: url(fonts/barlow-latin-500-normal.woff2) format('woff2'); }
@font-face { font-family: 'Barlow'; font-weight: 600; font-display: swap; src: url(fonts/barlow-latin-600-normal.woff2) format('woff2'); }
@font-face { font-family: 'Barlow'; font-weight: 700; font-display: swap; src: url(fonts/barlow-latin-700-normal.woff2) format('woff2'); }

:root {
  color-scheme: light;
  --page: #f3f5f7; --surface: #fcfcfb; --ink: #12151a; --ink2: #4b525c; --muted: #7d848e;
  --grid: #e3e6ea; --axis: #c4c9d0; --border: rgba(11, 11, 11, .10); --good: #006300; --bad: #b32d2d;
  --band: rgba(42, 120, 214, .08); --shadow: 0 6px 24px rgba(10, 20, 40, .14);
  --s1: #2a78d6; --s2: #eb6834; --s3: #1baf7a; --s4: #eda100; --s5: #e87ba4; --s6: #008300; --s7: #6250d6; --s8: #e34948;
  --s-other: #a3a9b1; --s-muted: #a3a9b1;
  --h0: #eaf2fc; --h1: #cde2fb; --h2: #b7d3f6; --h3: #86b6ef; --h4: #5598e7; --h5: #2a78d6; --h6: #1c5cab; --h7: #104281; --h8: #0d366b;
}
@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme='light'])) {
    color-scheme: dark;
    --page: #0e1013; --surface: #1a1a19; --ink: #f0efec; --ink2: #c3c2b7; --muted: #8e9199;
    --grid: #2c2c2a; --axis: #3d3d3a; --border: rgba(255, 255, 255, .10); --good: #3fbf3f; --bad: #ef6b6b;
    --band: rgba(57, 135, 229, .14); --shadow: 0 6px 24px rgba(0, 0, 0, .5);
    --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500; --s5: #d55181; --s6: #008300; --s7: #9085e9; --s8: #e66767;
    --s-other: #6d7380; --s-muted: #6d7380;
    --h0: #22262b; --h1: #1f3552; --h2: #1c4373; --h3: #1c5cab; --h4: #256abf; --h5: #2a78d6; --h6: #3987e5; --h7: #6da7ec; --h8: #9ec5f4;
  }
}
:root[data-theme='dark'] {
  color-scheme: dark;
  --page: #0e1013; --surface: #1a1a19; --ink: #f0efec; --ink2: #c3c2b7; --muted: #8e9199;
  --grid: #2c2c2a; --axis: #3d3d3a; --border: rgba(255, 255, 255, .10); --good: #3fbf3f; --bad: #ef6b6b;
  --band: rgba(57, 135, 229, .14); --shadow: 0 6px 24px rgba(0, 0, 0, .5);
  --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500; --s5: #d55181; --s6: #008300; --s7: #9085e9; --s8: #e66767;
  --s-other: #6d7380; --s-muted: #6d7380;
  --h0: #22262b; --h1: #1f3552; --h2: #1c4373; --h3: #1c5cab; --h4: #256abf; --h5: #2a78d6; --h6: #3987e5; --h7: #6da7ec; --h8: #9ec5f4;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--page); color: var(--ink); font: 400 15px/1.5 'Barlow', system-ui, -apple-system, 'Segoe UI', sans-serif; }
button, select, input { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--s1); outline-offset: 2px; border-radius: 4px; }
h1, h2, h3, p { margin: 0; }
.wrap { max-width: 1240px; margin: 0 auto; padding: 0 20px; }

/* ---------- encabezado ---------- */
.top { background: var(--surface); border-bottom: 1px solid var(--border); }
.top .wrap { display: flex; align-items: center; gap: 28px; min-height: 64px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); }
.brand img { width: 30px; height: 30px; }
.brand b { font-size: 21px; font-weight: 700; letter-spacing: -.01em; line-height: 1; }
.brand small { display: block; font-size: 12px; color: var(--muted); font-weight: 500; margin-top: 3px; letter-spacing: .01em; }
nav[role='tablist'] { display: flex; gap: 4px; align-self: stretch; }
nav button { background: none; border: 0; padding: 0 14px; cursor: pointer; font-weight: 600; font-size: 15px; color: var(--ink2); border-bottom: 3px solid transparent; margin-bottom: -1px; }
nav button:hover { color: var(--ink); }
nav button[aria-selected='true'] { color: var(--ink); border-bottom-color: var(--s1); }
.user { margin-left: auto; display: flex; align-items: center; gap: 12px; font-size: 13.5px; color: var(--ink2); }
.user button { background: none; border: 1px solid var(--border); border-radius: 6px; padding: 5px 10px; cursor: pointer; color: var(--ink2); }
.user button:hover { color: var(--ink); border-color: var(--axis); }

/* ---------- filtros ---------- */
.filters { position: sticky; top: 0; z-index: 20; background: color-mix(in srgb, var(--page) 92%, transparent); backdrop-filter: blur(8px); border-bottom: 1px solid var(--border); }
.filters .wrap { display: flex; align-items: center; gap: 18px; padding-top: 10px; padding-bottom: 10px; flex-wrap: wrap; }
.field { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--ink2); }
.field > span { font-weight: 500; }
select, input[type='month'], input[type='search'] { background: var(--surface); border: 1px solid var(--border); border-radius: 6px; padding: 6px 10px; min-height: 34px; }
select:hover, input:hover { border-color: var(--axis); }
.seg { display: inline-flex; background: var(--surface); border: 1px solid var(--border); border-radius: 7px; padding: 2px; }
.seg button { background: none; border: 0; padding: 5px 12px; border-radius: 5px; cursor: pointer; color: var(--ink2); font-weight: 500; font-size: 14px; }
.seg button:hover { background: color-mix(in srgb, var(--ink) 6%, transparent); }
.seg button[aria-pressed='true'] { background: var(--ink); color: var(--surface); }
.seg.small button { padding: 3px 10px; font-size: 13px; }
#range-note { margin-left: auto; font-size: 13px; color: var(--muted); }
#f-custom { display: flex; gap: 8px; align-items: center; }
#f-custom[hidden] { display: none; }

/* ---------- contenido ---------- */
main { padding: 26px 0 40px; transition: opacity .15s; }
main.loading { opacity: .55; }
.hero { display: grid; grid-template-columns: minmax(300px, 5fr) 7fr; gap: 28px 40px; align-items: end; margin-bottom: 26px; }
.hero-l { font-weight: 600; font-size: 15px; color: var(--ink2); }
.hero-n { display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px 12px; margin: 2px 0 6px; }
.hero-n > span:first-child { font-size: clamp(60px, 9vw, 96px); font-weight: 700; line-height: .95; letter-spacing: -.025em; }
.hero-u { font-size: 20px; font-weight: 500; color: var(--ink2); }
.hero-d { font-size: 17px; }
.hero-r { margin-top: 6px; color: var(--muted); font-size: 13.5px; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.chip { border: 1px solid var(--axis); border-radius: 99px; padding: 0 9px; font-size: 12px; color: var(--ink2); }
.tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 14px 16px 15px; }
.tile-l { font-size: 13.5px; color: var(--ink2); min-height: 40px; }
.tile-v { font-size: 30px; font-weight: 600; line-height: 1.1; margin-top: 4px; letter-spacing: -.01em; }
.tile-d, .tile-n { margin-top: 6px; font-size: 14px; color: var(--muted); }
.delta { font-weight: 600; white-space: nowrap; }
.delta.up { color: var(--good); } .delta.down { color: var(--bad); } .delta.none { color: var(--muted); font-weight: 400; }
.delta.sm { font-size: 13px; }
.hero-d .delta + * { font-weight: 400; }

.cards { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 18px 20px 16px; min-width: 0; }
.card.wide { grid-column: 1 / -1; }
.card-h { display: flex; justify-content: space-between; gap: 16px; align-items: flex-start; margin-bottom: 10px; }
.card-h h3 { font-size: 17px; font-weight: 600; letter-spacing: -.005em; }
.sub { font-size: 13.5px; color: var(--muted); margin-top: 2px; max-width: 78ch; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 18px; margin: 4px 0 6px; font-size: 13.5px; color: var(--ink2); }
.lg-item { display: inline-flex; align-items: center; gap: 7px; }
.lg-line { width: 16px; height: 3px; border-radius: 2px; display: inline-block; }
.lg-rect { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
.plot { min-height: 40px; }
svg.chart { display: block; width: 100%; height: auto; touch-action: pan-y; }
svg.chart:focus-visible { outline-offset: 4px; }
.grid { stroke: var(--grid); stroke-width: 1; } .axis { stroke: var(--axis); stroke-width: 1; }
.tick { fill: var(--muted); font-size: 11.5px; font-family: inherit; }
.endlab { fill: var(--ink2); font-size: 12.5px; font-weight: 600; font-family: inherit; }
.vline { stroke: var(--axis); stroke-width: 1; } .band { fill: var(--band); }
.tbl { max-height: 420px; overflow: auto; border-top: 1px solid var(--border); margin-top: 6px; }
table.data { border-collapse: collapse; width: 100%; font-size: 13.5px; }
table.data th, table.data td { padding: 6px 10px; text-align: left; border-bottom: 1px solid var(--grid); }
table.data thead th { position: sticky; top: 0; background: var(--surface); font-weight: 600; z-index: 1; }
table.data .num { text-align: right; font-variant-numeric: tabular-nums; }
table.data tbody th { font-weight: 500; }

/* ---------- ranking ---------- */
.split { display: grid; grid-template-columns: minmax(420px, 1fr) 1fr; gap: 16px; align-items: start; }
.split > .card:last-child { position: sticky; top: 76px; }
.rank { list-style: none; margin: 0; padding: 0; }
.rk { width: 100%; display: grid; grid-template-columns: 14px 24px minmax(90px, 1.5fr) minmax(50px, 1fr) minmax(76px, auto) 76px 84px; gap: 10px; align-items: center; text-align: left; background: none; border: 0; border-bottom: 1px solid var(--grid); padding: 7px 4px; cursor: default; }
button.rk[aria-pressed] { cursor: pointer; }
button.rk[aria-pressed]:hover { background: color-mix(in srgb, var(--ink) 4%, transparent); }
.rk-dot { width: 12px; height: 12px; border-radius: 50%; border: 2px solid var(--axis); }
.rk-dot.on { border-color: transparent; }
.rk-n { color: var(--muted); font-size: 13px; text-align: right; font-variant-numeric: tabular-nums; }
.rk-name { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rk-bar { height: 8px; background: color-mix(in srgb, var(--s1) 12%, transparent); border-radius: 4px; overflow: hidden; }
.rk-bar i { display: block; height: 100%; background: var(--s1); border-radius: 0 4px 4px 0; }
.rk-val { text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; line-height: 1.15; }
.rk-val small { display: block; font-weight: 400; color: var(--muted); font-size: 12px; }
.rk-d { text-align: right; }
.rk-sp { display: flex; justify-content: flex-end; }
.routes .rk { grid-template-columns: 24px minmax(120px, 1.6fr) minmax(50px, 1fr) minmax(86px, auto) 76px 84px; }
.routes .rk-dot { display: none; }
.link { background: none; border: 0; color: var(--s1); font-weight: 600; cursor: pointer; padding: 10px 4px 0; }
.link:hover { text-decoration: underline; }
.foot { font-size: 12.5px; color: var(--muted); margin-top: 12px; max-width: 90ch; }
.search { width: 240px; }
.empty-msg, .error { color: var(--ink2); padding: 18px 4px; }
.error { color: var(--bad); }

/* ---------- mapa de calor ---------- */
.heat-wrap { overflow-x: auto; }
table.heat { border-collapse: separate; border-spacing: 2px; width: 100%; min-width: 560px; table-layout: fixed; }
table.heat th { font-size: 11.5px; font-weight: 500; color: var(--muted); text-align: center; padding: 0 0 2px; }
table.heat tbody th { text-align: right; padding-right: 8px; width: 44px; font-variant-numeric: tabular-nums; }
td.cell { height: 17px; border-radius: 3px; }
td.cell:hover { outline: 2px solid var(--ink); outline-offset: -1px; }
td.cell.prov { outline: 1px dashed var(--ink2); outline-offset: -2px; }
.heat-scale { display: flex; align-items: center; gap: 10px; font-size: 12.5px; color: var(--muted); margin-top: 10px; }
.ramp { width: 160px; height: 10px; border-radius: 5px; background: linear-gradient(90deg, var(--h0), var(--h2), var(--h4), var(--h6), var(--h8)); }

/* ---------- tooltip ---------- */
.tip { position: fixed; z-index: 60; display: none; pointer-events: none; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; box-shadow: var(--shadow); padding: 8px 11px; font-size: 13.5px; min-width: 150px; }
.tip-title { font-weight: 600; margin-bottom: 4px; }
.tip-row { display: flex; align-items: center; gap: 8px; line-height: 1.7; }
.tip-row strong { font-variant-numeric: tabular-nums; min-width: 64px; }
.tip-row span:last-child { color: var(--ink2); }
.tip-key { width: 12px; height: 3px; border-radius: 2px; flex: none; }
.tip-note { margin-top: 4px; font-size: 12px; color: var(--muted); }

/* ---------- pie ---------- */
footer { border-top: 1px solid var(--border); padding: 22px 0 40px; color: var(--ink2); font-size: 13px; }
footer details { max-width: 900px; } footer summary { cursor: pointer; font-weight: 600; }
footer ul { margin: 8px 0 0; padding-left: 18px; } footer li { margin: 3px 0; }
footer p { margin-top: 10px; color: var(--muted); }

/* ---------- login ---------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-box { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 36px 34px; width: min(420px, 100%); text-align: left; }
.login-box img { width: 44px; height: 44px; }
.login-box h1 { font-size: 30px; font-weight: 700; letter-spacing: -.015em; margin: 14px 0 4px; }
.login-box p { color: var(--ink2); }
#g-btn { margin-top: 26px; min-height: 44px; }
#msg { margin-top: 14px; font-size: 14px; color: var(--bad); min-height: 20px; }
.login-box .small { font-size: 12.5px; color: var(--muted); margin-top: 22px; }

@media (max-width: 980px) {
  .cards, .split { grid-template-columns: 1fr; }
  .split > .card:last-child { position: static; }
  .hero { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .wrap { padding: 0 14px; }
  .tiles { grid-template-columns: 1fr; }
  .tile-l { min-height: 0; }
  .rk { grid-template-columns: 12px 20px 1fr minmax(70px, auto) 70px; }
  .rk-bar, .rk-sp { display: none; }
  .routes .rk { grid-template-columns: 20px 1fr minmax(70px, auto) 70px; }
  #range-note { margin-left: 0; width: 100%; }
  .user span { display: none; }
  .search { width: 100%; }
  .card-h { flex-wrap: wrap; }
}
@media (prefers-reduced-motion: reduce) { main { transition: none; } }
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
