/* ASIS 2025 Región Cajamarca — versión web interactiva */
:root {
  color-scheme: light;
  --bg: #f4f6f9;
  --surface: #ffffff;
  --surface-2: #f0f3f7;
  --surface-3: #e6ebf2;
  --ink: #0f1a2a;
  --ink-2: #44505f;
  --muted: #6b7684;
  --line: #dde3ea;
  --line-2: #c9d2dc;
  --brand: #0b4f9c;
  --brand-ink: #0a4485;
  --brand-soft: #e5eefa;
  --accent: #1f8f4e;
  --accent-soft: #e3f4ea;
  --hl: #fff2a8;
  --shadow: 0 1px 2px rgba(15, 26, 42, .06), 0 4px 16px rgba(15, 26, 42, .06);
  --shadow-lg: 0 10px 40px rgba(15, 26, 42, .18);
  --radius: 12px;
  --read-size: 17px;
  --sidebar: 300px;
  --top: 60px;
  /* gráficos (paleta validada) */
  --chart-surface: #fcfcfb;
  --grid: #e1e0d9;
  --axis: #c3c2b7;
  --s1: #2a78d6; --s2: #eb6834; --s3: #1baf7a; --s4: #eda100;
  --s5: #e87ba4; --s6: #008300; --s7: #4a3aa7; --s8: #e34948;
  --seq-1: #cde2fb; --seq-2: #9ec5f4; --seq-3: #5598e7; --seq-4: #256abf; --seq-5: #104281;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0e1116; --surface: #161a21; --surface-2: #1c212a; --surface-3: #252b36;
    --ink: #eef1f5; --ink-2: #c2c9d3; --muted: #8b95a3; --line: #2a313c; --line-2: #39414d;
    --brand: #5b9bec; --brand-ink: #8dbaf3; --brand-soft: #1a2a40; --accent: #3cc077; --accent-soft: #15301f;
    --hl: #5c4e00;
    --shadow: 0 1px 2px rgba(0,0,0,.4), 0 4px 16px rgba(0,0,0,.3); --shadow-lg: 0 10px 40px rgba(0,0,0,.6);
    --chart-surface: #1a1a19; --grid: #2c2c2a; --axis: #383835;
    --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500;
    --s5: #d55181; --s6: #008300; --s7: #9085e9; --s8: #e66767;
    --seq-1: #184f95; --seq-2: #1c5cab; --seq-3: #2a78d6; --seq-4: #5598e7; --seq-5: #9ec5f4;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0e1116; --surface: #161a21; --surface-2: #1c212a; --surface-3: #252b36;
  --ink: #eef1f5; --ink-2: #c2c9d3; --muted: #8b95a3; --line: #2a313c; --line-2: #39414d;
  --brand: #5b9bec; --brand-ink: #8dbaf3; --brand-soft: #1a2a40; --accent: #3cc077; --accent-soft: #15301f;
  --hl: #5c4e00;
  --shadow: 0 1px 2px rgba(0,0,0,.4), 0 4px 16px rgba(0,0,0,.3); --shadow-lg: 0 10px 40px rgba(0,0,0,.6);
  --chart-surface: #1a1a19; --grid: #2c2c2a; --axis: #383835;
  --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500;
  --s5: #d55181; --s6: #008300; --s7: #9085e9; --s8: #e66767;
  --seq-1: #184f95; --seq-2: #1c5cab; --seq-3: #2a78d6; --seq-4: #5598e7; --seq-5: #9ec5f4;
}

* { box-sizing: border-box; }
html { scroll-padding-top: calc(var(--top) + 16px); }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 15px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--brand); }
svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
button { font: inherit; color: inherit; }
kbd { font: 11px/1 ui-monospace, monospace; padding: 3px 5px; border: 1px solid var(--line-2); border-bottom-width: 2px; border-radius: 5px; background: var(--surface); color: var(--muted); }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

#progress { position: fixed; top: 0; left: 0; height: 3px; width: 0; background: linear-gradient(90deg, var(--brand), var(--accent)); z-index: 60; transition: width .1s linear; }

/* ---------- barra superior ---------- */
.topbar {
  position: sticky; top: 0; z-index: 40; height: var(--top);
  display: flex; align-items: center; gap: 14px; padding: 0 16px;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); min-width: 0; }
.brand-mark { width: 34px; height: 34px; border-radius: 9px; background: linear-gradient(135deg, var(--brand), #1f8f4e); display: grid; place-items: center; }
.brand-mark svg { width: 22px; height: 22px; fill: #fff; stroke: none; }
.brand-text { display: flex; flex-direction: column; line-height: 1.1; }
.brand-text b { font-size: 15px; letter-spacing: .02em; }
.brand-text small { color: var(--muted); font-size: 12px; }
.search-trigger {
  flex: 1; max-width: 520px; margin-left: auto; display: flex; align-items: center; gap: 10px;
  height: 38px; padding: 0 10px 0 12px; border: 1px solid var(--line); border-radius: 10px;
  background: var(--surface-2); color: var(--muted); cursor: pointer; text-align: left;
}
.search-trigger:hover { border-color: var(--line-2); }
.search-trigger span { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top-actions { display: flex; align-items: center; gap: 4px; margin-left: auto; }
.icon-btn {
  display: inline-grid; place-items: center; min-width: 36px; height: 36px; padding: 0 6px;
  border: 0; border-radius: 9px; background: transparent; cursor: pointer; color: var(--ink-2);
  font-weight: 600; text-decoration: none; font-size: 15px;
}
.icon-btn:hover { background: var(--surface-3); color: var(--ink); }
.icon-btn sup { font-size: 10px; }
.i-moon { display: none; }
:root[data-theme="dark"] .i-sun { display: none; }
:root[data-theme="dark"] .i-moon { display: block; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .i-sun { display: none; }
  :root:not([data-theme="light"]) .i-moon { display: block; }
}
.btn {
  display: inline-flex; align-items: center; gap: 7px; height: 36px; padding: 0 14px;
  border-radius: 9px; border: 1px solid var(--line-2); background: var(--surface); color: var(--ink);
  font-weight: 600; font-size: 14px; text-decoration: none; cursor: pointer; white-space: nowrap;
}
.btn:hover { border-color: var(--brand); color: var(--brand); }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-primary:hover { color: #fff; filter: brightness(1.08); }
.btn-ghost { border-color: transparent; background: transparent; color: var(--ink-2); }
.btn-pdf {
  position: relative; overflow: hidden; height: 42px; padding: 0 8px 0 14px; gap: 9px; margin-left: 10px;
  border-radius: 11px; border-color: transparent; color: #fff; font-size: 15px; font-weight: 700;
  background: linear-gradient(135deg, #22a35a 0%, #147a3d 100%);
  box-shadow: 0 4px 14px rgba(20, 122, 61, .45), inset 0 1px 0 rgba(255,255,255,.25);
  animation: pdf-pulse 2.6s ease-out infinite; transition: transform .15s, box-shadow .15s;
}
.btn-pdf:hover { color: #fff; border-color: transparent; transform: translateY(-2px) scale(1.03); box-shadow: 0 8px 22px rgba(20, 122, 61, .55), inset 0 1px 0 rgba(255,255,255,.25); animation-play-state: paused; }
.btn-pdf .pdf-tag { display: inline-grid; place-items: center; height: 26px; padding: 0 8px; border-radius: 7px; background: #fff; color: #147a3d; font-size: 12.5px; font-weight: 800; letter-spacing: .06em; }
.btn-pdf::after { content: ""; position: absolute; inset: 0; background: linear-gradient(105deg, transparent 35%, rgba(255,255,255,.5) 50%, transparent 65%); transform: translateX(-120%); animation: pdf-shine 4s ease-in-out 1s infinite; pointer-events: none; }
@keyframes pdf-pulse { 0% { box-shadow: 0 4px 14px rgba(20,122,61,.45), 0 0 0 0 rgba(34,163,90,.55); } 70% { box-shadow: 0 4px 14px rgba(20,122,61,.45), 0 0 0 10px rgba(34,163,90,0); } 100% { box-shadow: 0 4px 14px rgba(20,122,61,.45), 0 0 0 0 rgba(34,163,90,0); } }
@keyframes pdf-shine { 0%, 70% { transform: translateX(-120%); } 85%, 100% { transform: translateX(120%); } }
.btn-pdf svg, .pdf-banner .btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.pdf-banner {
  position: relative; overflow: hidden; display: grid; grid-template-columns: auto minmax(0, 1fr); gap: clamp(20px, 4vw, 40px); align-items: center;
  max-width: 1100px; margin: 0 auto 34px; padding: clamp(22px, 4vw, 36px) clamp(20px, 4vw, 44px);
  border-radius: 18px; color: #fff; box-shadow: var(--shadow-lg);
  background: radial-gradient(circle at 92% 10%, rgba(255,255,255,.16) 0 120px, transparent 121px), radial-gradient(circle at 80% 120%, rgba(255,255,255,.10) 0 160px, transparent 161px), linear-gradient(120deg, #0b4f9c 0%, #0f6a8a 50%, #1f8f4e 100%);
}
.pdf-thumb { position: relative; display: block; width: 132px; aspect-ratio: 453 / 680; border-radius: 8px; overflow: visible; transform: rotate(-4deg); transition: transform .25s; }
.pdf-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; border-radius: 8px; border: 3px solid #fff; box-shadow: 0 14px 30px rgba(0,0,0,.35); }
.pdf-thumb span { position: absolute; right: -12px; bottom: 14px; padding: 4px 10px; border-radius: 6px; background: #d93025; color: #fff; font-weight: 800; font-size: 13px; letter-spacing: .06em; box-shadow: 0 4px 12px rgba(0,0,0,.3); }
.pdf-banner:hover .pdf-thumb { transform: rotate(0) scale(1.04); }
.pdf-kicker { display: inline-block; padding: 4px 11px; border-radius: 999px; background: rgba(255,255,255,.18); font-size: 12px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; }
.pdf-banner h2 { margin: 10px 0 8px; font-size: clamp(22px, 3vw, 32px); line-height: 1.15; letter-spacing: -.01em; color: #fff; text-wrap: balance; }
.pdf-banner p { margin: 0; max-width: 60ch; color: rgba(255,255,255,.88); font-size: 15.5px; }
.pdf-meta { display: flex; flex-wrap: wrap; gap: 8px; list-style: none; margin: 14px 0 0; padding: 0; }
.pdf-meta li { padding: 4px 10px; border-radius: 8px; background: rgba(0,0,0,.18); font-size: 13px; font-weight: 600; }
.pdf-btns { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 20px; }
.btn-light { height: 44px; padding: 0 20px; font-size: 15px; background: #fff; border-color: #fff; color: #0b4f9c; box-shadow: 0 6px 18px rgba(0,0,0,.2); }
.btn-light:hover { background: #fff; border-color: #fff; color: #1f8f4e; transform: translateY(-1px); }
.btn-outline-light { height: 44px; padding: 0 18px; font-size: 15px; background: transparent; border-color: rgba(255,255,255,.7); color: #fff; }
.btn-outline-light:hover { background: rgba(255,255,255,.12); border-color: #fff; color: #fff; }
@media (prefers-reduced-motion: reduce) { .btn-pdf, .btn-pdf::after { animation: none; } }
.btn-sm { height: 30px; padding: 0 10px; font-size: 13px; border-radius: 8px; }
.btn[aria-pressed="true"] { background: var(--brand-soft); border-color: var(--brand); color: var(--brand-ink); }

/* ---------- estructura ---------- */
.layout { display: grid; grid-template-columns: var(--sidebar) minmax(0, 1fr); min-height: calc(100vh - var(--top)); }
.sidebar {
  position: sticky; top: var(--top); height: calc(100vh - var(--top)); overflow-y: auto;
  border-right: 1px solid var(--line); background: var(--surface); padding: 14px 10px 40px;
  scrollbar-width: thin;
}
main { min-width: 0; padding: 28px clamp(16px, 4vw, 56px) 80px; outline: none; }
.scrim { display: none; }

/* navegación */
.nav-group { margin-bottom: 14px; }
.nav-label { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 700; padding: 6px 10px; }
.nav-link {
  display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: 8px;
  color: var(--ink-2); text-decoration: none; font-size: 14px; line-height: 1.3;
}
.nav-link:hover { background: var(--surface-2); color: var(--ink); }
.nav-link.active { background: var(--brand-soft); color: var(--brand-ink); font-weight: 600; }
.nav-link .num { flex: none; min-width: 30px; height: 22px; border-radius: 6px; display: grid; place-items: center; font-size: 11px; font-weight: 700; background: var(--surface-3); color: var(--ink-2); }
.nav-link.active .num { background: var(--brand); color: #fff; }
.nav-sub { margin: 2px 0 8px 22px; border-left: 2px solid var(--line); }
.nav-sub a { display: block; padding: 4px 10px; font-size: 13px; color: var(--muted); text-decoration: none; line-height: 1.35; border-left: 2px solid transparent; margin-left: -2px; }
.nav-sub a.l3 { padding-left: 22px; font-size: 12.5px; }
.nav-sub a.l4 { padding-left: 34px; font-size: 12px; }
.nav-sub a:hover { color: var(--ink); }
.nav-sub a.current { color: var(--brand-ink); border-left-color: var(--brand); font-weight: 600; }

/* ---------- vistas comunes ---------- */
.view-head { max-width: 1100px; margin: 0 auto 22px; }
.eyebrow { font-size: 12px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--accent); }
h1.view-title { font-size: clamp(26px, 3.4vw, 38px); line-height: 1.15; margin: 6px 0 10px; letter-spacing: -.01em; text-wrap: balance; }
.lead { color: var(--ink-2); font-size: 17px; max-width: 75ch; margin: 0; }
.wrap { max-width: 1100px; margin: 0 auto; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.chip-row { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  border: 1px solid var(--line-2); background: var(--surface); color: var(--ink-2); border-radius: 999px;
  padding: 5px 12px; font-size: 13px; cursor: pointer; font-weight: 500;
}
.chip:hover { border-color: var(--brand); color: var(--brand); }
.chip[aria-pressed="true"] { background: var(--brand); border-color: var(--brand); color: #fff; }
.field { height: 38px; padding: 0 12px; border: 1px solid var(--line-2); border-radius: 9px; background: var(--surface); color: var(--ink); font: inherit; font-size: 14px; min-width: 0; }
.field:focus, .search-head input:focus { outline: 2px solid var(--brand); outline-offset: -1px; }
select.field { padding-right: 28px; }

/* ---------- inicio ---------- */
.hero { display: grid; grid-template-columns: minmax(0, 300px) minmax(0, 1fr); gap: clamp(20px, 4vw, 48px); align-items: center; max-width: 1100px; margin: 0 auto 34px; }
.hero-cover { border-radius: 14px; overflow: hidden; box-shadow: var(--shadow-lg); aspect-ratio: 453 / 680; background: var(--surface-3); }
.hero-cover img { width: 100%; height: 100%; object-fit: cover; display: block; }
.hero h1 { font-size: clamp(30px, 4.4vw, 50px); line-height: 1.05; margin: 8px 0 14px; letter-spacing: -.02em; text-wrap: balance; }
.hero h1 span { background: linear-gradient(90deg, var(--brand), var(--accent)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 22px; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; max-width: 1100px; margin: 0 auto 34px; }
.stat { padding: 16px 18px; }
.stat-label { font-size: 13px; color: var(--muted); }
.stat-value { font-size: 28px; font-weight: 700; letter-spacing: -.01em; margin: 2px 0; }
.stat-sub { font-size: 12.5px; color: var(--ink-2); }
.section-title { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; max-width: 1100px; margin: 0 auto 12px; }
.section-title h2 { font-size: 20px; margin: 0; }
.chapters-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 12px; max-width: 1100px; margin: 0 auto 34px; }
.chap-card { display: flex; flex-direction: column; gap: 6px; padding: 16px 18px; text-decoration: none; color: var(--ink); transition: transform .15s, border-color .15s; }
.chap-card:hover { transform: translateY(-2px); border-color: var(--brand); }
.chap-card .roman { font-size: 12px; font-weight: 800; color: var(--brand); letter-spacing: .08em; }
.chap-card h3 { margin: 0; font-size: 16px; line-height: 1.3; }
.chap-card .meta { margin-top: auto; padding-top: 6px; display: flex; gap: 12px; font-size: 12.5px; color: var(--muted); }
.tools-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 12px; max-width: 1100px; margin: 0 auto 34px; }
.tool-card { padding: 18px; text-decoration: none; color: var(--ink); display: flex; gap: 14px; align-items: flex-start; }
.tool-card:hover { border-color: var(--brand); }
.tool-ico { width: 40px; height: 40px; border-radius: 10px; background: var(--brand-soft); color: var(--brand); display: grid; place-items: center; flex: none; }
.tool-ico svg { width: 22px; height: 22px; }
.tool-card h3 { margin: 0 0 3px; font-size: 15px; }
.tool-card p { margin: 0; font-size: 13.5px; color: var(--ink-2); }

/* ---------- lectura de capítulo ---------- */
.chapter { max-width: 860px; margin: 0 auto; font-size: var(--read-size); }
.chapter-head { margin-bottom: 26px; padding-bottom: 20px; border-bottom: 1px solid var(--line); }
.chapter-head .roman { font-size: 13px; font-weight: 800; letter-spacing: .12em; color: var(--accent); }
.chapter-head h1 { font-size: clamp(26px, 3.2vw, 36px); line-height: 1.15; margin: 6px 0 12px; text-wrap: balance; }
.chapter-meta { display: flex; flex-wrap: wrap; gap: 8px 16px; font-size: 13px; color: var(--muted); align-items: center; }
.chapter-meta a { color: var(--muted); }
.chapter p { margin: 0 0 1em; line-height: 1.7; text-align: left; hyphens: auto; }
.chapter p b, .chapter li b { font-weight: 650; }
.chapter ul, .chapter ol { margin: 0 0 1.1em; padding-left: 1.3em; line-height: 1.65; }
.chapter li { margin-bottom: .35em; }
.chapter ul.ord { list-style: none; padding-left: .2em; }
.chapter h2, .chapter h3, .chapter h4, .chapter h5 { line-height: 1.25; scroll-margin-top: calc(var(--top) + 16px); position: relative; text-wrap: balance; }
.chapter h2 { font-size: 1.45em; margin: 1.9em 0 .7em; padding-top: .4em; border-top: 1px solid var(--line); }
.chapter h3 { font-size: 1.2em; margin: 1.7em 0 .6em; }
.chapter h4 { font-size: 1.05em; margin: 1.5em 0 .5em; color: var(--ink); }
.chapter h5 { font-size: .98em; margin: 1.3em 0 .5em; color: var(--ink-2); }
.hnum { color: var(--brand); font-variant-numeric: tabular-nums; margin-right: .35em; }
.anchor { opacity: 0; margin-left: 6px; font-size: .75em; text-decoration: none; color: var(--muted); }
h2:hover .anchor, h3:hover .anchor, h4:hover .anchor, h5:hover .anchor { opacity: 1; }
.page-tag { display: inline-block; font-size: 11px; color: var(--muted); border: 1px solid var(--line); border-radius: 5px; padding: 0 5px; margin-left: 8px; text-decoration: none; vertical-align: middle; font-weight: 500; }
.page-tag:hover { color: var(--brand); border-color: var(--brand); }
.note { font-size: .8em; color: var(--muted); margin: -.4em 0 1.2em; font-style: italic; }
abbr[title] { text-decoration: underline dotted var(--muted); text-underline-offset: 3px; cursor: help; }
mark { background: var(--hl); color: inherit; border-radius: 3px; padding: 0 1px; }
.flash { animation: flash 2.2s ease-out; border-radius: 8px; }
@keyframes flash { 0%, 30% { box-shadow: 0 0 0 4px color-mix(in srgb, var(--brand) 45%, transparent); } 100% { box-shadow: 0 0 0 4px transparent; } }
.chapter-nav { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 48px; }
.chapter-nav a { padding: 14px 16px; text-decoration: none; color: var(--ink); font-size: 14px; }
.chapter-nav a:hover { border-color: var(--brand); }
.chapter-nav small { display: block; color: var(--muted); font-size: 12px; margin-bottom: 2px; }
.chapter-nav .next { text-align: right; grid-column: 2; }

/* figuras */
.figure { margin: 1.4em 0 1.8em; padding: 14px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); font-size: 15px; }
.fig-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 14px; margin: 1.4em 0 1.8em; }
.fig-row .figure { margin: 0; }
.fig-cap { display: flex; gap: 10px; align-items: flex-start; margin-bottom: 10px; }
.fig-cap .kind { flex: none; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; padding: 3px 8px; border-radius: 6px; background: var(--brand-soft); color: var(--brand-ink); }
.fig-cap .kind.k-mapa { background: var(--accent-soft); color: var(--accent); }
.fig-cap .t { font-weight: 650; line-height: 1.35; font-size: 14.5px; }
.fig-cap .t small { display: block; font-weight: 500; color: var(--muted); font-size: 12.5px; margin-top: 2px; }
.fig-img { position: relative; display: block; width: 100%; padding: 0; border: 0; background: #fff; border-radius: 8px; cursor: zoom-in; overflow: hidden; }
.fig-img img { width: 100%; height: auto; display: block; }
.fig-img::after { content: "Ampliar ⤢"; position: absolute; right: 8px; bottom: 8px; background: rgba(15,26,42,.75); color: #fff; font-size: 12px; padding: 4px 8px; border-radius: 6px; opacity: 0; transition: opacity .15s; }
.fig-img:hover::after, .fig-img:focus-visible::after { opacity: 1; }
:root[data-theme="dark"] .fig-img img { filter: brightness(.92); }
.fig-src { font-size: 12px; color: var(--muted); margin-top: 8px; line-height: 1.45; }
.fig-legend { font-size: 12px; color: var(--ink-2); margin-top: 6px; }

/* tablas interactivas */
.tbl { margin: 1.4em 0 1.9em; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); font-size: 14px; overflow: hidden; }
.tbl-head { padding: 14px 16px 10px; display: flex; gap: 12px; align-items: flex-start; }
.tbl-head .kind { flex: none; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; padding: 3px 8px; border-radius: 6px; background: var(--surface-3); color: var(--ink-2); margin-top: 1px; }
.tbl-title { font-weight: 650; line-height: 1.35; flex: 1; }
.tbl-tools { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 16px 12px; align-items: center; }
.tbl-tools .field { height: 32px; font-size: 13px; flex: 1 1 160px; max-width: 260px; }
.tbl-tools .spacer { flex: 1; }
.tbl-count { font-size: 12px; color: var(--muted); }
.tbl-scroll { overflow: auto; max-height: 70vh; border-top: 1px solid var(--line); }
.tbl table { border-collapse: separate; border-spacing: 0; width: 100%; font-variant-numeric: tabular-nums; }
.tbl th, .tbl td { padding: 7px 12px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; line-height: 1.4; }
.tbl thead th { position: sticky; top: 0; background: var(--surface-2); font-weight: 650; font-size: 12.5px; color: var(--ink-2); z-index: 1; border-bottom: 1px solid var(--line-2); }
.tbl thead tr:nth-child(2) th { top: var(--h1, 34px); }
.tbl thead tr:nth-child(3) th { top: calc(var(--h1, 34px) * 2); }
.tbl thead th.group { text-align: center; border-left: 1px solid var(--line); }
.tbl th.sortable { cursor: pointer; user-select: none; }
.tbl th.sortable:hover { color: var(--brand); }
.tbl th .arr { opacity: .35; font-size: 10px; margin-left: 3px; }
.tbl th[aria-sort] .arr { opacity: 1; color: var(--brand); }
.tbl td.num, .tbl th.num { text-align: right; white-space: nowrap; }
.tbl tbody tr:hover td { background: var(--surface-2); }
.tbl tr.total td { font-weight: 700; background: var(--surface-2); }
.tbl tr.sec td { background: var(--brand-soft); color: var(--brand-ink); font-weight: 650; font-size: 13px; }
.tbl td.grp-cont { color: transparent; border-top-color: transparent; }
.tbl tr.grp-start td { border-top: 2px solid var(--line-2); }
.tbl td.wide { min-width: 260px; }
.tbl .heat { position: relative; }
.tbl-foot { padding: 9px 16px; font-size: 12px; color: var(--muted); border-top: 1px solid var(--line); display: flex; gap: 12px; flex-wrap: wrap; justify-content: space-between; }
.tbl-chart { padding: 14px 16px 6px; border-top: 1px solid var(--line); background: var(--chart-surface); }
.tbl-chart .ctrl { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 10px; font-size: 13px; color: var(--ink-2); }
.tbl-chart .ctrl .field { height: 32px; font-size: 13px; }
.chart-box { position: relative; height: 340px; }
.tbl.expanded { position: fixed; inset: 12px; z-index: 70; margin: 0; display: flex; flex-direction: column; }
.tbl.expanded .tbl-scroll { max-height: none; flex: 1; }
.tbl-backdrop { position: fixed; inset: 0; background: rgba(8, 12, 20, .55); z-index: 69; }
.empty { padding: 26px; text-align: center; color: var(--muted); }

/* ---------- panel ---------- */
.dash-filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; max-width: 1100px; margin: 0 auto 16px; }
.dash-grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 14px; max-width: 1100px; margin: 0 auto 30px; }
.panel { grid-column: span 6; padding: 16px 18px 12px; display: flex; flex-direction: column; min-width: 0; }
.panel.w12 { grid-column: span 12; }
.panel.w4 { grid-column: span 4; }
.panel.w8 { grid-column: span 8; }
.panel.w3 { grid-column: span 3; }
.panel h3 { font-size: 15.5px; margin: 0; line-height: 1.3; }
.panel .sub { font-size: 12.5px; color: var(--muted); margin: 2px 0 10px; }
.panel-top { display: flex; gap: 10px; align-items: flex-start; justify-content: space-between; flex-wrap: wrap; }
.panel .chart-box { height: 300px; }
.panel.tall .chart-box { height: 420px; }
.panel.short .chart-box { height: 190px; }
.panel-foot { margin-top: 8px; display: flex; justify-content: space-between; gap: 10px; font-size: 12px; color: var(--muted); flex-wrap: wrap; }
.panel-foot a { color: var(--brand); text-decoration: none; font-weight: 600; }
.seg { display: inline-flex; border: 1px solid var(--line-2); border-radius: 9px; overflow: hidden; }
.seg button { border: 0; background: var(--surface); padding: 5px 11px; font-size: 13px; cursor: pointer; color: var(--ink-2); }
.seg button + button { border-left: 1px solid var(--line-2); }
.seg button[aria-pressed="true"] { background: var(--brand); color: #fff; }
.kpi-mini { display: flex; align-items: baseline; gap: 8px; margin: 2px 0 6px; }
.kpi-mini b { font-size: 24px; }
.delta { font-size: 12.5px; font-weight: 600; }
.delta.up { color: #b4342f; } .delta.down { color: #0f7a35; } .delta.flat { color: var(--muted); }
:root[data-theme="dark"] .delta.up { color: #ff8a80; } :root[data-theme="dark"] .delta.down { color: #5fd38d; }

/* ---------- explorador provincial ---------- */
.prov-picker { max-width: 1100px; margin: 0 auto 20px; }
.prov-layout { max-width: 1100px; margin: 0 auto; display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px; }
.prov-hero { padding: 20px 22px; display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; }
.prov-hero .big { grid-column: 1 / -1; display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.prov-hero .big h2 { margin: 0; font-size: 28px; }
.rank-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 12px; }
.rank-card { padding: 14px 16px; }
.rank-card h4 { margin: 0 0 8px; font-size: 13.5px; line-height: 1.35; font-weight: 600; }
.rank-card .val { font-size: 22px; font-weight: 700; }
.rank-card .reg { font-size: 12.5px; color: var(--muted); }
.bar-track { position: relative; height: 8px; border-radius: 4px; background: var(--surface-3); margin: 8px 0 6px; }
.bar-fill { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 4px; background: var(--s1); }
.bar-ref { position: absolute; top: -3px; bottom: -3px; width: 2px; background: var(--ink-2); }
.rank-pos { font-size: 12px; color: var(--ink-2); display: flex; justify-content: space-between; }
.rank-card a { font-size: 12px; text-decoration: none; }
.prov-rows { padding: 0; }
.prov-rows .row-item { padding: 12px 16px; border-bottom: 1px solid var(--line); }
.prov-rows .row-item:last-child { border-bottom: 0; }
.prov-rows .row-item h4 { margin: 0 0 6px; font-size: 13.5px; font-weight: 600; }
.mini-table { overflow-x: auto; }
.mini-table table { border-collapse: collapse; font-size: 12.5px; font-variant-numeric: tabular-nums; }
.mini-table th, .mini-table td { padding: 4px 10px; border: 1px solid var(--line); white-space: nowrap; text-align: right; }
.mini-table th { background: var(--surface-2); font-weight: 600; color: var(--ink-2); white-space: normal; min-width: 70px; }
.mini-table th:first-child, .mini-table td:first-child { text-align: left; }
.dist-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; }
.dist-card { padding: 14px 16px; }
.dist-card h4 { margin: 0 0 8px; font-size: 13.5px; }
.tag { display: inline-block; font-size: 12.5px; padding: 3px 9px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); margin: 0 4px 4px 0; font-weight: 600; }
.h-sec { max-width: 1100px; margin: 26px auto 12px; font-size: 18px; display: flex; align-items: center; gap: 10px; }
.h-sec small { font-size: 13px; color: var(--muted); font-weight: 500; }

/* ---------- catálogos ---------- */
.cat-tools { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; max-width: 1100px; margin: 0 auto 16px; }
.cat-tools .field { flex: 1 1 240px; max-width: 420px; }
.cat-list { max-width: 1100px; margin: 0 auto; }
.cat-item { display: grid; grid-template-columns: 64px minmax(0, 1fr) auto; gap: 14px; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--line); text-decoration: none; color: var(--ink); background: var(--surface); }
.cat-item:first-child { border-radius: var(--radius) var(--radius) 0 0; }
.cat-item:last-child { border-radius: 0 0 var(--radius) var(--radius); border-bottom: 0; }
.cat-item:hover { background: var(--surface-2); }
.cat-item .no { font-size: 12px; font-weight: 700; color: var(--brand); }
.cat-item .t { font-weight: 600; font-size: 14px; line-height: 1.35; }
.cat-item .m { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.cat-item .go { font-size: 12.5px; color: var(--muted); white-space: nowrap; }
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; max-width: 1100px; margin: 0 auto; }
.g-item { padding: 0; overflow: hidden; display: flex; flex-direction: column; cursor: pointer; text-align: left; border: 1px solid var(--line); background: var(--surface); border-radius: var(--radius); }
.g-item:hover { border-color: var(--brand); }
.g-thumb { aspect-ratio: 4 / 3; background: #fff; display: grid; place-items: center; overflow: hidden; border-bottom: 1px solid var(--line); }
.g-thumb img { width: 100%; height: 100%; object-fit: contain; }
.g-body { padding: 10px 12px 12px; }
.g-body .k { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--brand); }
.g-body .t { font-size: 13px; font-weight: 600; line-height: 1.35; margin-top: 2px; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.g-body .m { font-size: 12px; color: var(--muted); margin-top: 4px; }

/* glosario / créditos */
.gloss { max-width: 1100px; margin: 0 auto; display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 10px; }
.gloss-item { padding: 12px 16px; display: flex; gap: 14px; align-items: baseline; }
.gloss-item b { min-width: 86px; color: var(--brand); font-size: 14px; }
.gloss-item span { font-size: 14px; color: var(--ink-2); }
.credits { max-width: 1100px; margin: 0 auto; display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 12px; }
.credits .card { padding: 16px 18px; }
.credits h3 { font-size: 14px; margin: 0 0 8px; color: var(--brand); }
.credits ul { margin: 0; padding-left: 18px; font-size: 14px; color: var(--ink-2); line-height: 1.6; }

/* ---------- búsqueda ---------- */
.modal { position: fixed; inset: 0; z-index: 80; background: rgba(8, 12, 20, .55); display: flex; justify-content: center; align-items: flex-start; padding: 8vh 16px 16px; }
.modal-card { width: 100%; max-width: 760px; background: var(--surface); border-radius: 14px; box-shadow: var(--shadow-lg); overflow: hidden; display: flex; flex-direction: column; max-height: 82vh; border: 1px solid var(--line); }
.search-head { display: flex; align-items: center; gap: 10px; padding: 10px 12px 10px 16px; border-bottom: 1px solid var(--line); }
.search-head svg { color: var(--muted); width: 20px; height: 20px; }
.search-head input { flex: 1; border: 0; background: transparent; font: inherit; font-size: 17px; color: var(--ink); height: 40px; outline: none; min-width: 0; }
.search-filters { display: flex; gap: 6px; padding: 10px 16px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.search-results { overflow-y: auto; flex: 1; padding: 6px; }
.sr-item { display: block; padding: 10px 12px; border-radius: 9px; text-decoration: none; color: var(--ink); cursor: pointer; }
.sr-item[aria-selected="true"], .sr-item:hover { background: var(--brand-soft); }
.sr-meta { font-size: 11.5px; color: var(--muted); display: flex; gap: 8px; align-items: center; margin-bottom: 2px; }
.sr-type { font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--brand); }
.sr-title { font-weight: 600; font-size: 14px; }
.sr-snip { font-size: 13px; color: var(--ink-2); margin-top: 2px; line-height: 1.45; }
.search-foot { display: flex; gap: 16px; padding: 8px 16px; border-top: 1px solid var(--line); font-size: 12px; color: var(--muted); }
.search-foot kbd { margin-right: 3px; }
.search-empty { padding: 30px 16px; text-align: center; color: var(--muted); font-size: 14px; }
.search-hints { padding: 14px 10px; }
.search-hints .chip { margin: 0 4px 6px 0; }

/* ---------- visor ---------- */
.lightbox { position: fixed; inset: 0; z-index: 90; background: rgba(6, 9, 14, .94); display: flex; flex-direction: column; color: #fff; }
.lb-top { display: flex; align-items: center; gap: 12px; padding: 10px 14px; }
.lb-title { flex: 1; font-weight: 600; font-size: 14px; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lb-tools { display: flex; align-items: center; gap: 2px; }
.lb-tools .icon-btn { color: #dfe6ef; font-size: 18px; }
.lb-tools .icon-btn:hover { background: rgba(255,255,255,.12); color: #fff; }
#lbZoom { font-size: 12px; min-width: 44px; text-align: center; color: #b9c3cf; }
.lb-stage { flex: 1; overflow: hidden; position: relative; cursor: grab; touch-action: none; }
.lb-stage.dragging { cursor: grabbing; }
.lb-stage img { position: absolute; left: 0; top: 0; transform-origin: 0 0; background: #fff; border-radius: 4px; user-select: none; -webkit-user-drag: none; max-width: none; }
.lb-nav { position: absolute; top: 50%; transform: translateY(-50%); width: 46px; height: 64px; border: 0; border-radius: 10px; background: rgba(255,255,255,.1); color: #fff; font-size: 34px; cursor: pointer; }
.lb-nav:hover { background: rgba(255,255,255,.22); }
.lb-prev { left: 12px; } .lb-next { right: 12px; }
.lb-caption { padding: 10px 16px 14px; font-size: 13px; color: #c5ced9; text-align: center; max-height: 18vh; overflow: auto; }

.toast { position: fixed; bottom: 22px; left: 50%; transform: translate(-50%, 20px); background: var(--ink); color: var(--surface); padding: 9px 16px; border-radius: 10px; font-size: 14px; opacity: 0; pointer-events: none; transition: .2s; z-index: 100; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

.back-top { position: fixed; right: 20px; bottom: 20px; width: 42px; height: 42px; border-radius: 50%; border: 1px solid var(--line-2); background: var(--surface); box-shadow: var(--shadow); display: grid; place-items: center; cursor: pointer; opacity: 0; pointer-events: none; transition: opacity .2s; z-index: 30; color: var(--ink-2); }
.back-top.show { opacity: 1; pointer-events: auto; }

/* ---------- responsive ---------- */
.only-mobile { display: none; }
@media (max-width: 1080px) {
  .panel, .panel.w4, .panel.w8 { grid-column: span 12; }
  .panel.w3 { grid-column: span 6; }
}
@media (max-width: 900px) {
  :root { --read-size: 16px; }
  .layout { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: fixed; left: 0; top: var(--top); bottom: 0; width: min(320px, 86vw); z-index: 50; transform: translateX(-100%); transition: transform .22s; box-shadow: var(--shadow-lg); height: auto; }
  body.nav-open .sidebar { transform: none; }
  body.nav-open .scrim { display: block; position: fixed; inset: var(--top) 0 0 0; background: rgba(8, 12, 20, .45); z-index: 45; }
  .only-mobile { display: inline-grid; }
  .hide-mobile { display: none; }
  .pdf-long { display: none; }
  .btn-pdf { height: 38px; padding: 0 6px 0 8px; gap: 6px; margin-left: 4px; }
  .pdf-banner { grid-template-columns: minmax(0, 1fr); text-align: left; }
  .pdf-thumb { width: 96px; }
  .pdf-btns .btn { flex: 1; justify-content: center; }
  .search-trigger span, .search-trigger kbd { display: none; }
  .search-trigger { flex: none; width: 38px; padding: 0; justify-content: center; margin-left: auto; }
  .top-actions { margin-left: 0; }
  .brand-text small { display: none; }
  .hero { grid-template-columns: minmax(0, 1fr); }
  .hero-cover { max-width: 220px; }
  main { padding: 20px 16px 70px; }
  .cat-item { grid-template-columns: minmax(0, 1fr); gap: 4px; }
  .cat-item .go { display: none; }
  .panel.w3 { grid-column: span 12; }
  .lb-nav { display: none; }
  .tbl-tools .field { max-width: none; }
}

@media print {
  .topbar, .sidebar, .tbl-tools, .chapter-nav, .back-top, #progress, .page-tag, .anchor, .fig-img::after { display: none !important; }
  .layout { display: block; }
  main { padding: 0; }
  body { background: #fff; color: #000; }
  .tbl-scroll { max-height: none; overflow: visible; }
  .tbl, .figure { break-inside: avoid; box-shadow: none; }
}
.chapter-head + h2 { border-top: 0; margin-top: .6em; padding-top: 0; }
.fig-pair { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 14px; align-items: start; }
.seg { flex-wrap: wrap; }
@media (max-width: 900px) { .sidebar { box-shadow: none; } body.nav-open .sidebar { box-shadow: var(--shadow-lg); } }
.tbl td.wide { min-width: 220px; }
@media (max-width: 480px) {
  #fontDown, #fontUp { display: none; }
}
