/* Observatorio Nacional del Bullying — Perú
   Diseño para familias: cálido, esperanzador, claro. Colores anti-bullying
   (naranja Unity Day + azul/teal de datos). Arte en SVG, sin dependencias externas. */

:root {
  /* Neutros cálidos (peruano, acogedor) */
  --bg: #fbf6ee;
  --bg-tint: #f6ede0;
  --surface: #ffffff;
  --surface-2: #f5ecdf;
  --border: #ecdfca;
  --text: #2c2419;
  --text-muted: #6d5f4d;
  --text-soft: #7a6a55;

  /* Marca / datos */
  --brand: #1f6fb2;
  --brand-dark: #14507f;
  --accent: #0f9d84;        /* teal */

  /* Anti-bullying (Unity Day) */
  --orange: #f97316;
  --orange-soft: #ffb877;

  /* Categorías */
  --c-bullying: #f97316;    /* naranja anti-bullying */
  --c-ciber: #8b5cf6;       /* violeta */
  --c-violencia: #2f80c4;   /* azul */
  --c-exposicion: #12a594;  /* teal */

  --up: #d4553a;
  --down: #2f9e6b;
  --warn-bg: #fff6e9;
  --warn-border: #f4c98a;
  --warn-text: #8a5300;

  --shadow-sm: 0 1px 2px rgba(18,32,46,.06), 0 2px 8px rgba(18,32,46,.05);
  --shadow: 0 2px 6px rgba(18,32,46,.06), 0 12px 30px rgba(18,32,46,.08);
  --radius: 16px;
  --radius-sm: 10px;
  --maxw: 1180px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0d141d;
    --bg-tint: #101a25;
    --surface: #16212d;
    --surface-2: #1c2a38;
    --border: #29394a;
    --text: #eaf1f8;
    --text-muted: #a7b6c7;
    --text-soft: #7c8da0;
    --brand: #4ea3e0;
    --brand-dark: #2b6fa5;
    --accent: #29c2b1;
    --warn-bg: #33280f;
    --warn-border: #6b5320;
    --warn-text: #f2cd8f;
    --shadow-sm: 0 1px 2px rgba(0,0,0,.3);
    --shadow: 0 2px 8px rgba(0,0,0,.35), 0 16px 40px rgba(0,0,0,.4);
  }
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
:focus-visible { outline: 3px solid var(--orange); outline-offset: 2px; border-radius: 6px; }
a:focus-visible, button:focus-visible, .side-nav a:focus-visible, .hb-chip:focus-visible { outline: 3px solid var(--orange); outline-offset: 2px; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
}
img { max-width: 100%; }
a { color: var(--brand); text-underline-offset: 2px; }
.wrap { max-width: var(--maxw); margin: 0 auto; padding-inline: 20px; }
.ic { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; vertical-align: middle; }

/* ---------- App layout / sidebar ---------- */
.app { display: grid; grid-template-columns: 244px minmax(0, 1fr); }
.main { min-width: 0; display: flex; flex-direction: column; overflow-x: clip; }
html, body { overflow-x: clip; }
/* Orden de secciones (prioriza acción y lo más completo arriba) */
.main > .hero { order: 0; }
.main > .helpbar { order: 1; }
.main > #resumen { order: 2; }
.main > #familias { order: 3; }
.main > #colegios { order: 4; }
.main > #mapa { order: 5; }
.main > #territorio { order: 6; }
.main > #serie { order: 7; }
.main > #estacional { order: 8; }
.main > #perfil { order: 9; }
.main > #prevalencia { order: 10; }
.main > #correlacion { order: 11; }
.main > #mundo { order: 12; }
.main > #comparacion { order: 13; }
.main > #academica { order: 14; }
.main > #noticias { order: 15; }
.main > #libros { order: 16; }
.main > #politicas { order: 17; }
.main > #datos { order: 18; }
.main > #metodologia { order: 19; }
.main > #limitaciones { order: 20; }
.main > #privacidad { order: 21; }
.main > #apoyo { order: 22; }
.main > .site-footer { order: 23; }
.sidebar {
  position: sticky; top: 0; align-self: start; height: 100vh; overflow-y: auto;
  background: var(--surface); border-right: 1px solid var(--border);
  padding: 18px 14px calc(18px + env(safe-area-inset-bottom,0px)); display: flex; flex-direction: column; gap: 6px;
}
.side-brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--text); font-weight: 800; font-size: 1rem; padding: 6px 10px 14px; line-height: 1.1; }
.side-brand small { color: var(--text-soft); font-weight: 600; font-size: .72rem; }
.side-logo { font-size: 1.5rem; }
.side-nav { display: flex; flex-direction: column; gap: 2px; }
.side-nav a { display: flex; align-items: center; gap: 11px; text-decoration: none; color: var(--text-muted); font-weight: 600; font-size: .88rem; padding: 9px 11px; border-radius: 10px; }
.side-nav a .ic { width: 18px; height: 18px; color: var(--text-soft); }
.side-nav a:hover { background: var(--surface-2); color: var(--brand); }
.side-nav a:hover .ic { color: var(--brand); }
.side-nav a.active { background: color-mix(in srgb, var(--brand) 12%, transparent); color: var(--brand); }
.side-nav a.active .ic { color: var(--brand); }
.side-denuncia { margin-top: auto; display: block; text-align: center; text-decoration: none; background: #c2410c; color: #fff; font-weight: 800; font-size: .85rem; padding: 11px; border-radius: 12px; box-shadow: 0 6px 16px rgba(249,115,22,.35); }
.menu-toggle { display: none; }
.sidebar-backdrop { display: none; }

@media (max-width: 960px) {
  .app { grid-template-columns: 1fr; }
  .menu-toggle { display: grid; place-items: center; position: fixed; top: 12px; left: 12px; z-index: 60; width: 44px; height: 44px; border: none; border-radius: 12px; background: var(--brand); color: #fff; font-size: 1.3rem; box-shadow: var(--shadow); cursor: pointer; }
  .sidebar { position: fixed; top: 0; left: 0; width: 260px; max-width: 84vw; transform: translateX(-102%); transition: transform .25s ease; z-index: 70; box-shadow: var(--shadow); }
  .sidebar.open { transform: translateX(0); }
  .sidebar-backdrop[hidden] { display: none; }
  .sidebar-backdrop { display: block; position: fixed; inset: 0; background: rgba(20,16,10,.45); z-index: 65; }
  .hero { padding-top: 62px; }
}

/* ---------- HERO ---------- */
.hero {
  position: relative;
  overflow: hidden;
  color: #fff;
  background: linear-gradient(135deg, #163f66 0%, #1f6fb2 45%, #12a594 100%);
  padding: 46px 0 40px;
}
.hero::before { /* mancha naranja decorativa */
  content: ""; position: absolute; inset: 0;
  background:
    radial-gradient(560px 320px at 88% -10%, rgba(249,115,22,.42), transparent 60%),
    radial-gradient(500px 300px at 6% 120%, rgba(18,165,148,.45), transparent 60%);
  pointer-events: none;
}
.hero .wrap { position: relative; display: grid; grid-template-columns: minmax(0,1.2fr) minmax(200px,300px); gap: 22px; align-items: center; }
@media (max-width: 1120px) { .hero .wrap { grid-template-columns: minmax(0,1fr) minmax(200px,260px); } }
@media (max-width: 760px) { .hero .wrap { grid-template-columns: 1fr; } .hero-art { display: none; } }
.hero-rail { align-self: stretch; }
.hero-rail .rail-viewport { height: 300px; }
.hero .ribbon {
  display: inline-flex; align-items: center; gap: 7px; background: rgba(255,255,255,.16);
  border: 1px solid rgba(255,255,255,.28); padding: 5px 13px; border-radius: 30px;
  font-size: .78rem; font-weight: 700; letter-spacing: .02em; margin-bottom: 14px; backdrop-filter: blur(4px);
}
.hero h1 { margin: 0; font-size: clamp(1.7rem, 4vw, 2.7rem); line-height: 1.08; letter-spacing: -.025em; font-weight: 800; }
.hero .sub { margin: 12px 0 0; color: #e2eef7; font-size: clamp(1rem,2vw,1.12rem); max-width: 46ch; }
.hero .updated { margin-top: 18px; font-size: .82rem; color: #cfe3f2; }
.hero .updated b { color: #fff; }
.hero-art { justify-self: center; width: 100%; max-width: 380px; }
.hero-art svg { display: block; width: 100%; height: auto; }
.hero-cta { margin-top: 18px; display: flex; gap: 10px; flex-wrap: wrap; }
.hero-cta a { text-decoration: none; font-weight: 700; font-size: .88rem; padding: 10px 16px; border-radius: 30px; }
.hero-cta .primary { background: #c2410c; color: #fff; box-shadow: 0 6px 18px rgba(249,115,22,.4); }
.hero-cta .ghost { background: rgba(255,255,255,.14); color: #fff; border: 1px solid rgba(255,255,255,.3); }

/* ---------- NAV ---------- */
.nav { position: sticky; top: 0; z-index: 20; background: color-mix(in srgb, var(--surface) 88%, transparent); backdrop-filter: blur(10px); border-bottom: 1px solid var(--border); }
.nav .wrap { display: flex; gap: 4px; overflow-x: auto; padding-block: 8px; scrollbar-width: none; }
.nav .wrap::-webkit-scrollbar { display: none; }
.nav a { white-space: nowrap; text-decoration: none; color: var(--text-muted); padding: 7px 12px; border-radius: 30px; font-size: .84rem; font-weight: 600; }
.nav a:hover { background: var(--surface-2); color: var(--brand); }

section { padding-block: 40px; scroll-margin-top: 58px; position: relative; }
.section-tint { background: var(--bg-tint); }
section > .wrap > h2 { font-size: clamp(1.3rem,2.5vw,1.6rem); margin: 0 0 4px; letter-spacing: -.015em; display: flex; align-items: center; gap: 10px; }
section > .wrap > h2 .ic { width: 30px; height: 30px; flex: none; color: var(--brand); }
section > .wrap > .lead { color: var(--text-muted); margin: 0 0 22px; max-width: 74ch; }

/* ---------- KPI cards ---------- */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow-sm); position: relative; overflow: hidden; transition: transform .15s, box-shadow .15s; }
.kpi:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.kpi::after { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--brand); }
.kpi.k-bullying::after { background: var(--c-bullying); } .kpi.k-ciber::after { background: var(--c-ciber); } .kpi.k-violencia::after { background: var(--c-violencia); } .kpi.k-rate::after { background: var(--c-exposicion); }
.kpi .label { font-size: .76rem; color: var(--text-muted); font-weight: 700; text-transform: uppercase; letter-spacing: .03em; padding-right: 76px; min-height: 2.2em; }
.kpi .value { font-size: 2rem; font-weight: 800; margin: 6px 0 2px; letter-spacing: -.03em; }
.kpi .meta { font-size: .8rem; color: var(--text-soft); }
.kpi .delta { font-weight: 800; font-size: .85rem; }
.kpi .delta.up { color: var(--up); } .kpi .delta.down { color: var(--down); }
.kpi .tag { position: absolute; top: 14px; right: 14px; font-size: .62rem; font-weight: 800; padding: 2px 8px; border-radius: 20px; text-transform: uppercase; letter-spacing: .04em; }
.tag-bullying { background: color-mix(in srgb, var(--c-bullying) 16%, transparent); color: var(--c-bullying); }
.tag-ciber { background: color-mix(in srgb, var(--c-ciber) 16%, transparent); color: var(--c-ciber); }
.tag-violencia { background: color-mix(in srgb, var(--c-violencia) 16%, transparent); color: var(--c-violencia); }

/* ---------- Panels ---------- */
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); padding: 20px; }
.panel h3 { margin-top: 0; font-size: 1rem; }
.grid-2 { display: grid; grid-template-columns: minmax(0,1fr) minmax(0,1fr); gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
@media (max-width: 860px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } }

.chart { width: 100%; height: 360px; }
.chart.tall { height: 440px; }
.chart.sm { height: 280px; }
#chart-world { height: 640px; }
@media (max-width: 860px) { #chart-world { height: 560px; } }
.controls { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; align-items: center; }
.controls label { font-size: .84rem; color: var(--text-muted); font-weight: 600; display: inline-flex; align-items: center; gap: 6px; }
.controls select, .controls button { font: inherit; font-size: .85rem; padding: 7px 12px; border-radius: 30px; border: 1px solid var(--border); background: var(--surface); color: var(--text); cursor: pointer; }
.controls .seg { display: inline-flex; border: 1px solid var(--border); border-radius: 30px; overflow: hidden; padding: 2px; gap: 2px; background: var(--surface); }
.controls .seg button { border: none; border-radius: 30px; background: transparent; padding: 6px 14px; }
.controls .seg button.active { background: var(--brand); color: #fff; }

.source { font-size: .76rem; color: var(--text-soft); margin-top: 12px; }
.source a { color: var(--text-muted); }

.callout { border: 1px solid var(--warn-border); background: var(--warn-bg); color: var(--warn-text); border-radius: 12px; padding: 13px 15px; font-size: .87rem; margin: 16px 0; display: flex; gap: 10px; }
.callout .ic { flex: none; width: 20px; height: 20px; margin-top: 1px; }
.callout.info { --warn-bg: #e9f4fb; --warn-border: #a9d3ec; --warn-text: #185273; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .callout.info { --warn-bg: #12303f; --warn-border: #2b6a94; --warn-text: #bfe0f2; } }

/* ---------- Map ---------- */
#map { height: 520px; border-radius: var(--radius); border: 1px solid var(--border); z-index: 1; background: linear-gradient(180deg, #dcebf6, #cfe4f2); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) #map { background: linear-gradient(180deg, #0f2231, #0c1a26); } }
.leaflet-container { background: transparent !important; font: inherit; }
.legend { background: var(--surface); padding: 9px 12px; border-radius: 10px; box-shadow: var(--shadow-sm); font-size: .76rem; line-height: 1.7; color: var(--text); }
.legend i { display: inline-block; width: 15px; height: 15px; margin-right: 6px; border-radius: 4px; vertical-align: -2px; }

/* ---------- Tables ---------- */
table.data { width: 100%; border-collapse: collapse; font-size: .84rem; }
table.data th, table.data td { text-align: left; padding: 9px 11px; border-bottom: 1px solid var(--border); }
table.data th { color: var(--text-muted); font-weight: 700; cursor: pointer; user-select: none; position: sticky; top: 0; background: var(--surface); z-index: 1; }
table.data tr:hover td { background: var(--surface-2); }
.table-scroll { max-height: 460px; overflow: auto; border: 1px solid var(--border); border-radius: 12px; }
.num { text-align: right; font-variant-numeric: tabular-nums; }

.badge { display: inline-block; font-size: .68rem; font-weight: 800; padding: 2px 8px; border-radius: 20px; }
.b-A { background: #dff2e6; color: #1c6b3f; } .b-B { background: #e5edf7; color: #2b5580; } .b-C { background: #fbeede; color: #8a5a00; } .b-D { background: #f0e2e2; color: #8a2a2a; }
.lv-REPORTADO { background: #fbeede; color: #8a5a00; } .lv-INVESTIGACION_PERIODISTICA { background: #efe6fb; color: #5a3a9a; } .lv-CONFIRMADO_OFICIAL { background: #dff2e6; color: #1c6b3f; }

/* ---------- Timeline ---------- */
.timeline { list-style: none; margin: 0; padding: 0; position: relative; }
.timeline::before { content: ""; position: absolute; left: 8px; top: 4px; bottom: 4px; width: 2px; background: linear-gradient(var(--brand), var(--accent)); }
.timeline li { position: relative; padding: 0 0 20px 32px; }
.timeline li::before { content: ""; position: absolute; left: 2px; top: 5px; width: 14px; height: 14px; border-radius: 50%; background: var(--orange); border: 3px solid var(--surface); box-shadow: 0 0 0 1px var(--border); }
.timeline .date { font-size: .78rem; color: var(--accent); font-weight: 800; }
.timeline .ev-title { font-weight: 700; }
.timeline .ev-desc { font-size: .85rem; color: var(--text-muted); }

/* ---------- News ---------- */
.news-list { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); }
.news-item { display: flex; gap: 12px; border: 1px solid var(--border); border-radius: 14px; padding: 12px; background: var(--surface); box-shadow: var(--shadow-sm); transition: transform .15s; text-decoration: none; color: inherit; }
.news-item:hover { transform: translateY(-2px); }
.news-thumb { flex: none; width: 84px; height: 84px; border-radius: 10px; background-size: cover; background-position: center; }
.news-thumb.ph { display: grid; place-items: center; color: #fff; font-weight: 800; font-size: 1.2rem; }
.news-body { min-width: 0; }
.news-item .meta { font-size: .72rem; color: var(--text-soft); display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.news-item h4 { margin: 6px 0 4px; font-size: .92rem; line-height: 1.3; }

/* ---------- Barra de ayuda (top) ---------- */
.helpbar { background: linear-gradient(90deg, #b3421f, #d4553a); color: #fff; }
.helpbar .wrap { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding-block: 10px; }
.helpbar .hb-label { font-weight: 800; font-size: .9rem; }
.helpbar .hb-chip { display: inline-flex; align-items: center; gap: 5px; background: rgba(255,255,255,.16); border: 1px solid rgba(255,255,255,.28); color: #fff; text-decoration: none; padding: 5px 12px; border-radius: 30px; font-size: .82rem; font-weight: 600; }
.helpbar .hb-chip b { color: #ffd9b0; }
.helpbar .hb-denuncia { margin-left: auto; background: #fff; color: #b3421f; text-decoration: none; font-weight: 800; font-size: .84rem; padding: 7px 16px; border-radius: 30px; }
@media (max-width: 640px) { .helpbar .hb-denuncia { margin-left: 0; } }

/* ---------- Top grid: KPIs + rail de noticias vertical ---------- */
.top-grid { display: grid; grid-template-columns: minmax(0,1fr) 320px; gap: 18px; align-items: start; }
@media (max-width: 900px) { .top-grid { grid-template-columns: 1fr; } }
.news-rail { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); overflow: hidden; }
.rail-head { background: linear-gradient(135deg, var(--brand-dark), var(--brand)); color: #fff; padding: 11px 14px; font-weight: 800; font-size: .88rem; }
.rail-foot { text-align: center; font-size: .72rem; color: var(--text-soft); padding: 8px; border-top: 1px solid var(--border); }
.rail-viewport { height: 380px; overflow: hidden; position: relative; -webkit-mask-image: linear-gradient(180deg, transparent, #000 7%, #000 93%, transparent); mask-image: linear-gradient(180deg, transparent, #000 7%, #000 93%, transparent); }
.rail-track { display: flex; flex-direction: column; gap: 10px; padding: 12px; animation: rail-scroll 28s linear infinite; }
.news-rail:hover .rail-track { animation-play-state: paused; }
@keyframes rail-scroll { from { transform: translateY(0); } to { transform: translateY(-50%); } }
.rail-item { display: flex; gap: 10px; text-decoration: none; color: var(--text); padding: 8px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface); }
.rail-item:hover { background: var(--surface-2); }
.rail-thumb { flex: none; width: 56px; height: 56px; border-radius: 9px; background-size: cover; background-position: center; }
.rail-thumb.ph { display: grid; place-items: center; color: #fff; font-weight: 800; }
.rail-body { min-width: 0; }
.rail-body .t { font-size: .8rem; font-weight: 700; line-height: 1.25; color: var(--text); display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.rail-body .m { font-size: .67rem; color: var(--text-muted); margin-top: 3px; }
@media (prefers-reduced-motion: reduce) { .rail-track { animation: none; } .rail-viewport { overflow-y: auto; } }

/* ---------- Books ---------- */
.books-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; }
.book { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px; box-shadow: var(--shadow-sm); }
.book .cover { width: 42px; height: 56px; border-radius: 5px; background: linear-gradient(135deg, var(--brand), var(--accent)); float: left; margin: 0 12px 6px 0; }
.book h4 { margin: 0 0 3px; font-size: .92rem; line-height: 1.2; }
.book .by { font-size: .76rem; color: var(--text-soft); }
.book .aud { display: inline-block; font-size: .66rem; font-weight: 700; background: var(--surface-2); color: var(--text-muted); border-radius: 20px; padding: 1px 8px; margin-top: 6px; }
.book p { font-size: .82rem; color: var(--text-muted); margin: 8px 0 0; clear: both; }
.ticker-vert { margin-top: 12px; display: grid; gap: 8px; }

/* ---------- Parents card ---------- */
.parents-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; }
.pcard { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow-sm); }
.pcard .pico { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; margin-bottom: 12px; color: #fff; }
.pcard h3 { margin: 0 0 8px; font-size: 1.02rem; }
.pcard ul { margin: 0; padding-left: 18px; color: var(--text-muted); font-size: .88rem; }
.pcard li { margin-bottom: 5px; }
.help-line { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 16px; }
.help-line .chip { background: var(--surface); border: 1px solid var(--border); border-radius: 30px; padding: 10px 16px; font-size: .86rem; font-weight: 600; box-shadow: var(--shadow-sm); }
.help-line .chip b { color: var(--orange); }

/* ---------- Chatbot ---------- */
.chat-fab { position: fixed; right: 20px; bottom: calc(20px + env(safe-area-inset-bottom,0px)); z-index: 40; background: linear-gradient(135deg, #c2410c, #ea580c); color: #fff; border: none; border-radius: 50px; padding: 13px 20px; font: inherit; font-weight: 800; box-shadow: 0 8px 24px rgba(249,115,22,.45); cursor: pointer; }
.chat-fab:hover { transform: translateY(-1px); }
.chat-panel { position: fixed; right: 20px; bottom: 78px; width: min(390px, calc(100vw - 40px)); height: 540px; max-height: calc(100vh - 110px); background: var(--surface); border: 1px solid var(--border); border-radius: 18px; box-shadow: var(--shadow); z-index: 40; display: flex; flex-direction: column; overflow: hidden; }
.chat-panel header { background: linear-gradient(135deg, var(--brand-dark), var(--brand)); color: #fff; padding: 13px 16px; font-weight: 800; display: flex; justify-content: space-between; align-items: center; }
.chat-panel header button { background: none; border: none; color: #fff; font-size: 1.3rem; cursor: pointer; }
.chat-log { flex: 1; overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.msg { padding: 10px 13px; border-radius: 14px; font-size: .87rem; max-width: 86%; }
.msg.user { background: var(--brand); color: #fff; align-self: flex-end; border-bottom-right-radius: 4px; }
.msg.bot { background: var(--surface-2); color: var(--text); align-self: flex-start; border-bottom-left-radius: 4px; }
.msg.bot .cite { display: block; margin-top: 6px; font-size: .72rem; color: var(--text-soft); }
.chat-input { display: flex; gap: 6px; padding: 10px; border-top: 1px solid var(--border); }
.chat-input input { flex: 1; font: inherit; padding: 9px 12px; border: 1px solid var(--border); border-radius: 30px; background: var(--surface); color: var(--text); }
.chat-input button { background: #c2410c; color: #fff; border: none; border-radius: 30px; padding: 0 16px; font-weight: 800; cursor: pointer; }
.chat-suggestions { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 14px 10px; }
.chat-suggestions button { font: inherit; font-size: .76rem; background: var(--surface-2); border: 1px solid var(--border); color: var(--text-muted); border-radius: 20px; padding: 6px 11px; cursor: pointer; }

/* ---------- Yape / apoyo ---------- */
.yape-card { display: flex; gap: 20px; align-items: center; flex-wrap: wrap; background: linear-gradient(135deg, #7423840d, #74238418); border: 1px solid #74238433; border-radius: var(--radius); padding: 22px; }
.yape-badge { flex: none; width: 64px; height: 64px; border-radius: 18px; display: grid; place-items: center; font-size: 2rem; background: #fff; box-shadow: var(--shadow-sm); }
.yape-text h3 { margin: 0 0 6px; font-size: 1.15rem; color: #742384; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .yape-text h3 { color: #c98fe0; } }
.yape-text p { margin: 0 0 10px; color: var(--text-muted); font-size: .9rem; max-width: 60ch; }
.pay-methods { display: flex; flex-wrap: wrap; gap: 10px; }
.pay-chip { display: inline-flex; align-items: center; gap: 6px; text-decoration: none; background: var(--surface); border: 1px solid color-mix(in srgb, var(--pc) 40%, var(--border)); color: var(--text); border-radius: 30px; padding: 8px 14px; font-size: .86rem; box-shadow: var(--shadow-sm); }
.pay-chip b { color: var(--pc); }

/* ---------- Footer ---------- */
.site-footer { background: linear-gradient(135deg, #14507f, #163f66); color: #cfe0ee; padding: 30px 0; font-size: .84rem; margin-top: 24px; }
.site-footer a { color: #fff; }
.site-footer .cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 20px; }

.pill { display: inline-block; padding: 2px 9px; border-radius: 20px; font-size: .7rem; font-weight: 700; background: rgba(255,255,255,.16); color: #fff; }
.loading { color: var(--text-soft); font-style: italic; padding: 20px; text-align: center; }
[hidden] { display: none !important; }

/* ---------- Nav groups ---------- */
.nav-group { font-size: .68rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: var(--text-soft); padding: 12px 11px 4px; }
.nav-group:first-child { padding-top: 4px; }

/* ---------- Colegios: panel integrado ---------- */
.school-panel { padding: 16px; }
.school-toolbar { display: flex; flex-direction: column; gap: 10px; margin-bottom: 12px; }
.school-search-wrap { position: relative; display: flex; align-items: center; }
.school-search-wrap .ic { position: absolute; left: 14px; width: 20px; height: 20px; color: var(--text-soft); pointer-events: none; }
.school-search-wrap input { width: 100%; font: inherit; font-size: 1rem; padding: 12px 14px 12px 44px; border: 2px solid var(--border); border-radius: 14px; background: var(--surface); color: var(--text); outline: none; transition: border-color .15s, box-shadow .15s; }
.school-search-wrap input:focus { border-color: var(--brand); box-shadow: 0 0 0 4px color-mix(in srgb, var(--brand) 14%, transparent); }
.school-filters { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; }
.school-filters label { font-size: .8rem; color: var(--text-muted); font-weight: 600; display: inline-flex; align-items: center; gap: 6px; }
.school-filters select { font: inherit; font-size: .84rem; padding: 6px 10px; border-radius: 30px; border: 1px solid var(--border); background: var(--surface); color: var(--text); max-width: 200px; }
.btn-ghost { font: inherit; font-size: .8rem; padding: 6px 12px; border-radius: 30px; border: 1px solid var(--border); background: transparent; color: var(--text-muted); cursor: pointer; }
.btn-ghost:hover { color: var(--brand); border-color: var(--brand); }
.school-panel .seg { align-self: flex-start; display: inline-flex; border: 1px solid var(--border); border-radius: 30px; padding: 2px; gap: 2px; background: var(--surface); }
.school-panel .seg button { font: inherit; font-size: .84rem; border: none; border-radius: 30px; background: transparent; padding: 6px 14px; cursor: pointer; color: var(--text); }
.school-panel .seg button.active { background: var(--brand); color: #fff; }
.school-status { font-size: .8rem; color: var(--text-muted); margin: 0 0 8px; min-height: 1.2em; }
.table-scroll-tall { max-height: 640px; }
.school-table td, .school-table th { padding: 8px 10px; vertical-align: middle; }
.school-table tr.sc-row { cursor: pointer; }
.school-table tr.sc-row.open td { background: color-mix(in srgb, var(--brand) 7%, transparent); }
.school-table .sc-name { font-weight: 700; }
.school-table .sc-sub { display: block; font-size: .72rem; color: var(--text-muted); font-weight: 500; }
.school-table .sc-tag { display: inline-block; font-size: .68rem; font-weight: 700; padding: 1px 7px; border-radius: 20px; background: var(--surface-2); color: var(--text-muted); }
.school-table .sc-tag.pub { background: #dff2e6; color: #1c6b3f; } .school-table .sc-tag.priv { background: #efe6fb; color: #5a3a9a; }
.school-table .sort-col { color: var(--brand); }
.spark { display: block; width: 112px; height: 26px; }
.spark rect { fill: color-mix(in srgb, var(--brand) 55%, transparent); }
.spark rect.hi { fill: var(--brand); }
.spark rect.partial { fill: var(--orange); }
.sc-detail td { background: var(--surface-2); padding: 12px 14px 16px; cursor: default; }
.sc-detail .sc-detail-grid { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.sc-detail .chart { height: 220px; }
.sc-detail table.data { font-size: .78rem; }
.sc-detail table.data th, .sc-detail table.data td { padding: 5px 8px; }
.sc-detail .sc-meta { font-size: .8rem; color: var(--text-muted); margin: 0 0 8px; }
.sc-detail .sc-meta b { color: var(--text); }
@media (max-width: 860px) { .sc-detail .sc-detail-grid { grid-template-columns: 1fr; } }

/* ---------- Stat tiles ---------- */
.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin: 4px 0 12px; }
.stat { background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px; padding: 10px 12px; }
.stat .v { font-size: 1.45rem; font-weight: 800; letter-spacing: -.02em; line-height: 1.1; }
.stat .l { font-size: .74rem; color: var(--text-muted); margin-top: 3px; }
.reading { font-size: .9rem; margin: 10px 0 0; padding: 10px 14px; border-left: 3px solid var(--brand); background: color-mix(in srgb, var(--brand) 6%, transparent); border-radius: 0 10px 10px 0; }

/* ---------- Móvil ---------- */
@media (max-width: 640px) {
  .wrap { padding-inline: 14px; }
  .panel { padding: 14px; }
  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .kpi .value { font-size: 1.5rem; }
  .controls { gap: 6px; }
  .controls label { width: 100%; justify-content: space-between; }
  .controls select { flex: 1; }
  .school-filters label { width: calc(50% - 6px); justify-content: space-between; }
  .school-filters select { flex: 1; max-width: none; }
  .school-panel .seg { align-self: stretch; }
  .school-panel .seg button { flex: 1; padding: 8px 6px; font-size: .78rem; }
  table.data { font-size: .78rem; }
  table.data th, table.data td { padding: 7px 8px; }
  .school-table > thead > tr > th:nth-child(3), .school-table > tbody > tr.sc-row > td:nth-child(3), .school-table > thead > tr > th:nth-child(4), .school-table > tbody > tr.sc-row > td:nth-child(4) { display: none; }
  .spark { width: 84px; }
  .chart.tall { height: 300px; }
  #map { height: 400px; }
  .table-scroll { -webkit-overflow-scrolling: touch; }
  .table-scroll-tall { max-height: 520px; }
  section > .wrap > .lead { font-size: .92rem; }
}
@media (max-width: 480px) {
  .school-filters label { width: 100%; }
  .school-table > thead > tr > th:nth-child(6), .school-table > tbody > tr.sc-row > td:nth-child(6), .school-table > thead > tr > th:nth-child(7), .school-table > tbody > tr.sc-row > td:nth-child(7) { display: none; }
  .school-table .sc-sub { font-size: .68rem; }
  .stat-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat .v { font-size: 1.2rem; }
}

/* ---------- Descargas ---------- */
.dl-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.dl-card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px; display: flex; flex-direction: column; gap: 6px; }
.dl-card .dl-title { font-weight: 700; font-size: .92rem; }
.dl-card .dl-desc { font-size: .78rem; color: var(--text-muted); flex: 1; }
.dl-card .dl-actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 4px; }
.dl-card .dl-actions a, .dl-card .dl-actions button { font: inherit; font-size: .78rem; font-weight: 700; padding: 5px 11px; border-radius: 30px; border: 1px solid var(--border); background: var(--surface-2); color: var(--brand); text-decoration: none; cursor: pointer; }
.dl-card .dl-actions a:hover, .dl-card .dl-actions button:hover { border-color: var(--brand); }
.dl-card .dl-size { font-size: .7rem; color: var(--text-soft); align-self: center; }

/* ---------- Mapa de sedes por distrito ---------- */
#district-map-wrap { margin: 4px 0 14px; }
.district-map-head { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; font-size: .9rem; }
#district-map { height: 380px; border-radius: 12px; border: 1px solid var(--border); background: linear-gradient(180deg, #eef4f8, #e3edf4); z-index: 1; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) #district-map { background: linear-gradient(180deg, #0f2231, #0c1a26); } }
@media (max-width: 640px) { #district-map { height: 300px; } }
.sede-pop { font-size: .8rem; line-height: 1.45; max-width: 260px; }
.sede-pop b { font-size: .86rem; }
.sede-pop .lv { display: inline-block; font-size: .68rem; padding: 1px 6px; border-radius: 20px; background: var(--surface-2); color: var(--text-muted); margin: 2px 2px 0 0; }
.sede-pop a { color: var(--brand); }
.nv-chip { display: inline-block; font-size: .66rem; padding: 1px 6px; border-radius: 20px; background: var(--surface-2); color: var(--text-muted); margin: 1px 2px 1px 0; white-space: nowrap; }

.dl-link { font-size: .74rem; font-weight: 600; color: var(--brand); text-decoration: none; margin-left: 6px; }
.dl-link:hover { text-decoration: underline; }

/* ---------- Móvil: revisión UI 25-09-2026 ---------- */
@media (max-width: 640px) {
  .kpi .tag { display: none; }
  .chat-fab { right: 14px; bottom: calc(14px + env(safe-area-inset-bottom,0px)); width: 56px; height: 56px; padding: 0; border-radius: 50%; font-size: 1.4rem; }
  .chat-fab .fab-label { display: none; }
  #map { height: 62vw; min-height: 300px; }
  .map-aux { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; align-items: flex-start; }
  .map-aux .legend, .map-aux .obs-dist-ctl { position: static !important; margin: 0 !important; }
  .obs-dist-btn { padding: 10px 12px; min-height: 44px; }
  .leaflet-touch .leaflet-bar a { width: 40px; height: 40px; line-height: 40px; }
  .controls .seg button, .school-panel .seg button, .btn-ghost { min-height: 40px; }
}

/* ---------- Privacidad ---------- */
#privacy-bar { position: fixed; left: 12px; right: 12px; bottom: calc(12px + env(safe-area-inset-bottom,0px)); z-index: 45; display: flex; flex-wrap: wrap; gap: 8px 14px; align-items: center; justify-content: space-between; background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow); padding: 10px 14px; font-size: .84rem; max-width: 720px; margin: 0 auto; }
#privacy-bar[hidden] { display: none; }
#privacy-bar button { font: inherit; font-size: .82rem; font-weight: 700; padding: 7px 12px; border-radius: 30px; border: 1px solid var(--border); background: var(--brand); color: #fff; cursor: pointer; }
#privacy-bar button.btn-ghost { background: transparent; color: var(--text-muted); }
.chat-notice { font-size: .72rem; color: var(--text-muted); margin: 4px 12px 6px; line-height: 1.4; }
.chat-notice a { color: var(--brand); }
@media (max-width: 640px) { #privacy-bar { bottom: calc(80px + env(safe-area-inset-bottom,0px)); } }

/* ---------- Noticias: carrusel (fuera del hero) ---------- */
#noticias .news-rail .rail-viewport { height: 220px; }
.school-empty { margin: 4px 0 10px; }
.school-empty[hidden] { display: none; }

.sc-dot { color: var(--text-soft); }
