/* ============================================================================
   INDICARIA — layout.css
   Arquitectura de vistas A / B / C
   NO modifica styles.css existente.
   Versión: 1.0 — Capa 1
   ============================================================================ */

/* ── TOKENS DE DISEÑO ──────────────────────────────────────────────────────
   Fuente única de verdad para colores, tipografía y espaciado.
   Para cambiar el tema completo: solo editar estas variables.
   ────────────────────────────────────────────────────────────────────────── */
:root {
  /* Tipografía */
  --font-sans:  'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono:  'DM Mono', 'SFMono-Regular', Consolas, monospace;

  /* Vista A — interfaz clara (mapa global) */
  --a-bg:         #f2f1ed;
  --a-surface:    #ffffff;
  --a-border:     #e4e2db;
  --a-border2:    #ccc9bf;
  --a-text:       #1a1c22;
  --a-text2:      #4a4d57;
  --a-muted:      #8a8d99;
  --a-accent:     #2563eb;
  --a-accent-s:   rgba(37, 99, 235, 0.10);
  --a-accent-g:   rgba(37, 99, 235, 0.20);

  /* Sidebar — siempre oscuro */
  --sb-bg:        #13161f;
  --sb-text:      #c8ccd8;
  --sb-muted:     #464c5e;
  --sb-border:    rgba(255, 255, 255, 0.06);
  --sb-hover:     rgba(255, 255, 255, 0.05);
  --sb-active:    rgba(79, 255, 176, 0.08);
  --sb-accent:    #4fffb0;

  /* Vistas B y C — interfaz oscura (país + indicador) */
  --b-bg:         #0f1117;
  --b-surface:    #161b27;
  --b-surface2:   #1c2235;
  --b-border:     rgba(255, 255, 255, 0.07);
  --b-border2:    rgba(255, 255, 255, 0.13);
  --b-text:       #e8ecf5;
  --b-muted:      #5a6178;
  --b-accent:     #4fffb0;
  --b-accent-s:   rgba(79, 255, 176, 0.10);

  /* Categorías de indicadores */
  --cat-economia:   #f59e0b;
  --cat-salud:      #10b981;
  --cat-demografia: #8b5cf6;
  --cat-educacion:  #ef4444;
  --cat-ambiente:   #38bdf8;

  /* Layout */
  --sb-width:     272px;
  --topbar-h:     54px;
  --slider-h:     68px;
  --radius-sm:    8px;
  --radius-md:    12px;
  --radius-lg:    16px;
  --shadow-sm:    0 2px 8px rgba(0,0,0,0.07);
  --shadow-md:    0 4px 20px rgba(0,0,0,0.10);
  --shadow-lg:    0 8px 40px rgba(0,0,0,0.15);

  /* Transiciones */
  --t-fast:   0.12s ease;
  --t-mid:    0.20s ease;
  --t-slow:   0.30s ease;
}

/* ── RESET PARA NUEVOS COMPONENTES ───────────────────────────────────────── */
.indicaria-app *,
.indicaria-app *::before,
.indicaria-app *::after {
  box-sizing: border-box;
}

/* ── CARGA DE FUENTES (Google Fonts) ─────────────────────────────────────── */
/* Se importa aquí para no tocar index.html en Capa 1 */
@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@300;400;500;600&family=DM+Mono:wght@400;500&family=Syne:wght@600;700;800&display=swap');

/* ============================================================================
   ROUTER DE VISTAS
   Sistema mínimo de navegación por estado.
   showView(id) es la única función que controla qué se muestra.
   ============================================================================ */
.view {
  display: none;
  width: 100%;
  height: 100vh;
  overflow: hidden;
  font-family: var(--font-sans);
}
.view.active {
  display: flex;
}

/* Vista A: row (sidebar + mapa) */
#view-A { flex-direction: row; background: var(--a-bg); }

/* Vista B: column (topbar + tabs + grid de cards) */
#view-B { flex-direction: column; background: var(--b-bg); }

/* Vista C: column (topbar + gráfico expandido + tabla) */
#view-C { flex-direction: column; background: var(--b-bg); }

/* Vistas futuras — solo agregar aquí con su flex-direction */
/* #view-D { flex-direction: column; background: var(--b-bg); } */

/* ============================================================================
   SIDEBAR (Vista A)
   ============================================================================ */
.ind-sidebar {
  width: var(--sb-width);
  min-width: var(--sb-width);
  background: var(--sb-bg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 4px 0 28px rgba(0,0,0,0.22);
  z-index: 10;
  transition: transform var(--t-slow);
}

/* Cabecera del sidebar */
.sb-head {
  padding: 20px 18px 14px;
  border-bottom: 1px solid var(--sb-border);
  flex-shrink: 0;
}

.sb-logo {
  font-family: 'Syne', var(--font-sans);
  font-size: 20px;
  font-weight: 800;
  color: #ffffff;
  letter-spacing: -0.5px;
  text-decoration: none;
}
.sb-logo em {
  color: var(--sb-accent);
  font-style: normal;
}

/* Búsqueda unificada */
.sb-search {
  margin-top: 12px;
  position: relative;
}
.sb-search input {
  width: 100%;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.09);
  border-radius: var(--radius-sm);
  padding: 8px 12px 8px 32px;
  color: #ffffff;
  font-family: var(--font-sans);
  font-size: 13px;
  outline: none;
  transition: border-color var(--t-mid);
}
.sb-search input::placeholder { color: var(--sb-muted); }
.sb-search input:focus { border-color: var(--sb-accent); }
.sb-search-icon {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--sb-muted);
  font-size: 13px;
  pointer-events: none;
}

/* Cuerpo scrolleable */
.sb-body {
  flex: 1;
  overflow-y: auto;
  padding: 8px 0;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.07) transparent;
}
.sb-body::-webkit-scrollbar { width: 4px; }
.sb-body::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.07); border-radius: 2px; }

/* Separadores de sección */
.sb-section-sep {
  padding: 14px 18px 5px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--sb-muted);
  display: flex;
  align-items: center;
  gap: 8px;
}
.sb-section-sep::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--sb-border);
}

/* Lista de países */
.sb-country-list { padding: 2px 8px 10px; }

.sb-country-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--t-fast);
}
.sb-country-item:hover { background: var(--sb-hover); }
.sb-country-item:focus { outline: 2px solid var(--sb-accent); outline-offset: -2px; }

.sb-country-icon {
  /* Chip de iniciales — reemplaza emojis de bandera */
  width: 26px;
  height: 18px;
  border-radius: 3px;
  background: rgba(255,255,255,0.08);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: 500;
  color: rgba(255,255,255,0.5);
  letter-spacing: 0.05em;
  flex-shrink: 0;
  border: 1px solid rgba(255,255,255,0.06);
}
.sb-country-name { font-size: 13px; color: var(--sb-text); flex: 1; }
.sb-country-val {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--sb-muted);
  white-space: nowrap;
}

/* Acordeones de categorías */
.sb-cat { margin-bottom: 2px; }

.sb-cat-header {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 18px;
  cursor: pointer;
  user-select: none;
  transition: background var(--t-fast);
}
.sb-cat-header:hover { background: var(--sb-hover); }

.sb-cat-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}
.sb-cat-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--sb-muted);
  flex: 1;
}
.sb-cat-arrow {
  color: var(--sb-muted);
  font-size: 9px;
  transition: transform var(--t-mid);
  /* Usamos texto en lugar de emoji — más controlable */
}
.sb-cat.open .sb-cat-arrow { transform: rotate(90deg); }

.sb-cat-list { display: none; padding: 2px 0 6px; }
.sb-cat.open .sb-cat-list { display: block; }

/* Items de indicador */
.sb-ind-item {
  display: flex;
  align-items: flex-start;
  gap: 0;
  padding: 8px 18px 8px 35px;
  cursor: pointer;
  transition: background var(--t-fast);
  position: relative;
  border: none;
  background: transparent;
  width: 100%;
  text-align: left;
}
.sb-ind-item:hover { background: var(--sb-hover); }
.sb-ind-item.active { background: var(--sb-active); }
.sb-ind-item.active::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: var(--sb-accent);
  border-radius: 0 2px 2px 0;
}
.sb-ind-name {
  font-size: 13px;
  color: var(--sb-text);
  line-height: 1.3;
  display: block;
}
.sb-ind-item.active .sb-ind-name { color: #ffffff; font-weight: 500; }
.sb-ind-years {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--sb-muted);
  margin-top: 1px;
  display: block;
}

/* Pie del sidebar */
.sb-foot {
  padding: 12px 18px;
  border-top: 1px solid var(--sb-border);
  font-size: 11px;
  color: var(--sb-muted);
  flex-shrink: 0;
}

/* ── SIDEBAR MOBILE (bottom sheet) ──────────────────────────────────────── */
.sb-mobile-toggle {
  display: none; /* visible solo en mobile */
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 300;
  background: var(--sb-bg);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 100px;
  padding: 10px 20px;
  color: #fff;
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(0,0,0,0.4);
  gap: 8px;
  align-items: center;
}

.sb-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 200;
  backdrop-filter: blur(2px);
}
.sb-overlay.open { display: block; }

/* ============================================================================
   VISTA A — ÁREA DE MAPA
   ============================================================================ */
.map-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0; /* fix flex overflow */
}

/* Topbar del mapa */
.map-topbar {
  background: var(--a-surface);
  border-bottom: 1px solid var(--a-border);
  padding: 0 24px;
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  gap: 14px;
  flex-shrink: 0;
}
.map-topbar-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--a-text);
  letter-spacing: -0.2px;
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.map-topbar-meta {
  font-size: 11px;
  color: var(--a-muted);
  font-family: var(--font-mono);
  white-space: nowrap;
}
.map-year-badge {
  background: var(--a-accent-s);
  border: 1px solid rgba(37,99,235,0.2);
  color: var(--a-accent);
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 500;
  padding: 5px 12px;
  border-radius: var(--radius-sm);
  white-space: nowrap;
}
.map-btn-reset {
  padding: 7px 13px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--a-border);
  background: transparent;
  font-family: var(--font-sans);
  font-size: 13px;
  color: var(--a-text2);
  cursor: pointer;
  transition: all var(--t-fast);
  white-space: nowrap;
}
.map-btn-reset:hover { background: var(--a-bg); border-color: var(--a-border2); }

/* Canvas del mapa */
.map-canvas {
  flex: 1;
  position: relative;
  overflow: hidden;
}

/* Slider de año */
.map-slider-bar {
  background: var(--a-surface);
  border-top: 1px solid var(--a-border);
  padding: 11px 24px 13px;
  flex-shrink: 0;
  height: var(--slider-h);
}
.map-slider-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 7px;
}
.map-slider-label {
  font-size: 11px;
  color: var(--a-muted);
  font-weight: 500;
}
.map-slider-year {
  font-family: var(--font-mono);
  font-size: 16px;
  font-weight: 500;
  color: var(--a-text);
}

/* Input range — estilo Indicaria */
.map-slider-input {
  width: 100%;
  -webkit-appearance: none;
  height: 4px;
  border-radius: 4px;
  outline: none;
  cursor: pointer;
  background: linear-gradient(
    to right,
    var(--a-accent) 0%,
    var(--a-accent) var(--pct, 80%),
    var(--a-border2) var(--pct, 80%),
    var(--a-border2) 100%
  );
}
.map-slider-input::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 17px;
  height: 17px;
  border-radius: 50%;
  background: var(--a-surface);
  border: 3px solid var(--a-accent);
  box-shadow: 0 2px 8px var(--a-accent-g);
  transition: transform var(--t-fast);
  cursor: pointer;
}
.map-slider-input::-webkit-slider-thumb:hover { transform: scale(1.15); }
.map-slider-input::-moz-range-thumb {
  width: 17px;
  height: 17px;
  border-radius: 50%;
  background: var(--a-surface);
  border: 3px solid var(--a-accent);
  cursor: pointer;
}

.map-slider-ticks {
  display: flex;
  justify-content: space-between;
  margin-top: 5px;
}
.map-slider-tick {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--a-muted);
  text-align: center;
  line-height: 1;
}
.map-slider-tick::before {
  content: '';
  display: block;
  width: 1px;
  height: 4px;
  background: currentColor;
  margin: 0 auto 2px;
}
.map-slider-tick.active { color: var(--a-accent); }

/* ============================================================================
   VISTA B — COUNTRY PROFILE
   ============================================================================ */

/* Topbar */
.cp-topbar {
  background: var(--b-surface);
  border-bottom: 1px solid var(--b-border);
  padding: 0 28px;
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  gap: 0;
  flex-shrink: 0;
}
.cp-back-btn {
  display: flex;
  align-items: center;
  gap: 7px;
  background: transparent;
  border: none;
  font-family: var(--font-sans);
  font-size: 13px;
  color: var(--b-muted);
  cursor: pointer;
  padding: 0 18px 0 0;
  border-right: 1px solid var(--b-border);
  margin-right: 18px;
  height: 100%;
  transition: color var(--t-fast);
}
.cp-back-btn:hover { color: var(--b-text); }

/* Chip de país — reemplaza emoji de bandera */
.cp-country-chip {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 22px;
  background: rgba(255,255,255,0.07);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 500;
  color: rgba(255,255,255,0.6);
  letter-spacing: 0.05em;
  margin-right: 10px;
  flex-shrink: 0;
}

.cp-country-name {
  font-family: 'Syne', var(--font-sans);
  font-size: 17px;
  font-weight: 700;
  color: var(--b-text);
}
.cp-region {
  font-size: 11px;
  color: var(--b-muted);
  font-family: var(--font-mono);
  margin-left: 10px;
  padding-left: 10px;
  border-left: 1px solid var(--b-border);
}
.cp-topbar-right {
  margin-left: auto;
  text-align: right;
  flex-shrink: 0;
}
.cp-pib-val {
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 500;
  color: var(--b-accent);
}
.cp-pib-lbl {
  font-size: 10px;
  color: var(--b-muted);
}

/* Breadcrumb */
.cp-breadcrumb {
  padding: 9px 28px;
  background: var(--b-surface);
  border-bottom: 1px solid var(--b-border);
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--b-muted);
  font-family: var(--font-mono);
  flex-shrink: 0;
}
.cp-breadcrumb-link {
  cursor: pointer;
  transition: color var(--t-fast);
  background: transparent;
  border: none;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--b-muted);
  padding: 0;
}
.cp-breadcrumb-link:hover { color: var(--b-text); }
.cp-breadcrumb-sep { opacity: 0.35; }
.cp-breadcrumb-current { color: var(--b-text); }

/* Tabs de categoría */
.cp-tabs {
  display: flex;
  gap: 6px;
  padding: 11px 28px;
  background: var(--b-bg);
  border-bottom: 1px solid var(--b-border);
  flex-shrink: 0;
  overflow-x: auto;
  scrollbar-width: none;
}
.cp-tabs::-webkit-scrollbar { display: none; }

.cp-tab {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: 100px;
  border: 1px solid var(--b-border);
  background: transparent;
  color: var(--b-muted);
  font-family: var(--font-sans);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--t-fast);
  white-space: nowrap;
}
.cp-tab:hover { border-color: var(--b-border2); color: var(--b-text); }
.cp-tab.active {
  background: var(--b-accent-s);
  border-color: rgba(79,255,176,0.25);
  color: var(--b-accent);
}
.cp-tab-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* Grid de cards */
.cp-body {
  flex: 1;
  overflow-y: auto;
  padding: 22px 28px 40px;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.07) transparent;
}
.cp-body::-webkit-scrollbar { width: 4px; }
.cp-body::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.07); border-radius: 2px; }

.cp-section { margin-bottom: 28px; }
.cp-section-title {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.cp-section-title::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--b-border);
}

.cp-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(255px, 1fr));
  gap: 12px;
}

/* ── CARD DE INDICADOR (con grilla) ─────────────────────────────────────── */
.ind-card {
  background: var(--b-surface);
  border: 1px solid var(--b-border);
  border-radius: var(--radius-md);
  padding: 16px;
  cursor: pointer;
  transition: all var(--t-mid);
  position: relative;
  overflow: hidden;
}
/* Barra de color de categoría */
.ind-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: var(--card-cat-color, transparent);
  opacity: 0.55;
  transition: opacity var(--t-mid);
}
.ind-card:hover {
  border-color: var(--b-border2);
  box-shadow: 0 8px 32px rgba(0,0,0,0.28);
  transform: translateY(-1px);
}
.ind-card:hover::before { opacity: 1; }
.ind-card:focus { outline: 2px solid var(--b-accent); outline-offset: 2px; }

/* Iconos SVG de la card — reemplaza emojis */
.card-icon {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--card-cat-color, var(--b-muted));
  opacity: 0.8;
}
.card-icon svg {
  width: 20px;
  height: 20px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.card-trend-badge {
  font-size: 10px;
  padding: 2px 7px;
  border-radius: 100px;
  font-weight: 500;
  font-family: var(--font-mono);
  white-space: nowrap;
}
.card-trend-badge.up   { background: rgba(16,185,129,0.15); color: #34d399; }
.card-trend-badge.down { background: rgba(239,68,68,0.15);  color: #f87171; }
.card-trend-badge.flat { background: rgba(255,255,255,0.06); color: var(--b-muted); }

.card-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--b-text);
  margin-bottom: 2px;
  letter-spacing: -0.1px;
}
.card-source {
  font-size: 10px;
  color: var(--b-muted);
  font-family: var(--font-mono);
  margin-bottom: 12px;
}

/* Sparkline con grilla */
.card-chart {
  height: 64px;
  position: relative;
  margin-bottom: 10px;
}
.card-chart svg {
  width: 100%;
  height: 100%;
  overflow: visible;
}

.card-footer {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  padding-top: 8px;
  border-top: 1px solid var(--b-border);
}
.card-value {
  font-family: var(--font-mono);
  font-size: 17px;
  font-weight: 500;
  color: var(--b-text);
  letter-spacing: -0.5px;
}
.card-unit {
  font-size: 10px;
  color: var(--b-muted);
  margin-bottom: 1px;
}
.card-years {
  font-size: 10px;
  color: var(--b-muted);
  font-family: var(--font-mono);
}

/* Animación de entrada */
@keyframes ind-card-in {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}
.ind-card { animation: ind-card-in 0.28s ease both; }

/* ============================================================================
   VISTA C — INDICADOR EXPANDIDO
   ============================================================================ */
.ic-topbar {
  background: var(--b-surface);
  border-bottom: 1px solid var(--b-border);
  padding: 0 28px;
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  gap: 14px;
  flex-shrink: 0;
}
.ic-back-btn {
  display: flex;
  align-items: center;
  gap: 7px;
  background: transparent;
  border: none;
  font-family: var(--font-sans);
  font-size: 13px;
  color: var(--b-muted);
  cursor: pointer;
  padding: 0 16px 0 0;
  border-right: 1px solid var(--b-border);
  margin-right: 2px;
  height: 100%;
  transition: color var(--t-fast);
}
.ic-back-btn:hover { color: var(--b-text); }

.ic-body {
  flex: 1;
  overflow-y: auto;
  padding: 24px 32px 48px;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.07) transparent;
}
.ic-body::-webkit-scrollbar { width: 4px; }
.ic-body::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.07); border-radius: 2px; }

/* Header del indicador */
.ic-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 22px;
  gap: 20px;
}
.ic-ind-name {
  font-family: 'Syne', var(--font-sans);
  font-size: 22px;
  font-weight: 700;
  color: var(--b-text);
  letter-spacing: -0.5px;
  margin-bottom: 4px;
}
.ic-ind-meta {
  font-size: 12px;
  color: var(--b-muted);
  font-family: var(--font-mono);
}
.ic-big-val {
  font-family: var(--font-mono);
  font-size: 32px;
  font-weight: 500;
  letter-spacing: -1.5px;
  text-align: right;
}
.ic-big-unit {
  font-size: 11px;
  color: var(--b-muted);
  text-align: right;
  margin-top: 2px;
}

/* Stats row */
.ic-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-bottom: 20px;
}
.ic-stat {
  background: var(--b-surface);
  border: 1px solid var(--b-border);
  border-radius: 10px;
  padding: 13px 15px;
}
.ic-stat-val {
  font-family: var(--font-mono);
  font-size: 15px;
  font-weight: 500;
  color: var(--b-text);
  margin-bottom: 3px;
}
.ic-stat-lbl { font-size: 10px; color: var(--b-muted); }

/* Contenedor del gráfico */
.ic-chart-wrap {
  background: var(--b-surface);
  border: 1px solid var(--b-border);
  border-radius: var(--radius-md);
  padding: 20px 20px 16px;
  margin-bottom: 20px;
}
.ic-chart-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
  flex-wrap: wrap;
  gap: 8px;
}
.ic-chart-title {
  font-size: 11px;
  font-weight: 600;
  color: var(--b-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.ic-chart-legend {
  display: flex;
  gap: 16px;
  font-size: 11px;
  color: var(--b-muted);
  font-family: var(--font-mono);
  align-items: center;
  flex-wrap: wrap;
}
.ic-legend-item {
  display: flex;
  align-items: center;
  gap: 5px;
}
.ic-legend-line {
  display: inline-block;
  width: 20px;
  height: 2px;
  border-radius: 2px;
}
.ic-chart-area { height: 220px; position: relative; }
.ic-chart-area svg { width: 100%; height: 100%; overflow: visible; }

/* Tabla histórica */
.ic-table-wrap {
  background: var(--b-surface);
  border: 1px solid var(--b-border);
  border-radius: var(--radius-md);
  overflow: hidden;
}
.ic-table-head {
  padding: 13px 18px;
  border-bottom: 1px solid var(--b-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.ic-table-title {
  font-size: 11px;
  font-weight: 600;
  color: var(--b-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.ic-table-note {
  font-size: 10px;
  color: var(--b-muted);
  font-family: var(--font-mono);
}

.ic-table {
  width: 100%;
  border-collapse: collapse;
}
.ic-table thead tr { border-bottom: 1px solid var(--b-border); }
.ic-table th {
  padding: 8px 18px;
  font-size: 10px;
  font-weight: 600;
  color: var(--b-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  text-align: left;
  font-family: var(--font-mono);
}
.ic-table th.right { text-align: right; }
.ic-table tbody tr {
  border-bottom: 1px solid rgba(255,255,255,0.03);
  transition: background var(--t-fast);
}
.ic-table tbody tr:hover { background: rgba(255,255,255,0.03); }
.ic-table tbody tr.highlighted { background: rgba(79,255,176,0.05); }
.ic-table tbody tr:last-child { border-bottom: none; }
.ic-table td {
  padding: 9px 18px;
  font-size: 12px;
  color: var(--b-text);
  font-family: var(--font-mono);
}
.ic-table td.right { text-align: right; }

.td-bar-wrap { display: flex; align-items: center; gap: 8px; }
.td-bar {
  height: 4px;
  border-radius: 2px;
  background: var(--b-accent);
  opacity: 0.45;
  min-width: 2px;
}
.td-delta {
  font-size: 10px;
  padding: 1px 5px;
  border-radius: 4px;
  font-family: var(--font-mono);
}
.td-delta.pos { color: #34d399; background: rgba(16,185,129,0.12); }
.td-delta.neg { color: #f87171; background: rgba(239,68,68,0.12); }
.td-delta.neu { color: var(--b-muted); }

/* ============================================================================
   RESPONSIVE — Mobile first
   ============================================================================ */

/* Tablet (768px - 1024px): sidebar más angosto */
@media (max-width: 1024px) {
  :root { --sb-width: 240px; }

  .ic-stats { grid-template-columns: repeat(2, 1fr); }
  .cp-cards-grid { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
}

/* Mobile (< 768px): sidebar → bottom sheet */
@media (max-width: 767px) {
  /* Vista A: el sidebar se convierte en un panel deslizable desde abajo */
  #view-A { flex-direction: column; }

  .ind-sidebar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    top: auto;
    width: 100%;
    min-width: 100%;
    height: 70vh;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    transform: translateY(100%);
    transition: transform var(--t-slow);
    z-index: 250;
    box-shadow: 0 -8px 40px rgba(0,0,0,0.4);
  }
  .ind-sidebar.mobile-open {
    transform: translateY(0);
  }

  /* Handle visual del bottom sheet */
  .ind-sidebar::before {
    content: '';
    display: block;
    width: 36px;
    height: 4px;
    background: rgba(255,255,255,0.15);
    border-radius: 2px;
    margin: 10px auto 6px;
  }

  .sb-mobile-toggle { display: flex; }

  /* El mapa ocupa toda la pantalla en mobile */
  .map-main { height: 100vh; }

  /* Topbar más compacto */
  .map-topbar { padding: 0 12px; gap: 8px; }
  .map-topbar-meta { display: none; } /* Ocultar en mobile */

  /* Slider más compacto */
  .map-slider-bar { padding: 8px 12px 10px; }

  /* Vistas B y C */
  .cp-topbar { padding: 0 14px; }
  .cp-region { display: none; }
  .cp-body { padding: 14px 14px 32px; }

  .ic-body { padding: 16px 14px 32px; }
  .ic-stats { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .ic-header { flex-direction: column; gap: 10px; }
  .ic-big-val { font-size: 24px; text-align: left; }

  .cp-cards-grid { grid-template-columns: 1fr; }

  /* Tabla horizontal scrolleable en mobile */
  .ic-table-wrap { overflow-x: auto; }
  .ic-table { min-width: 500px; }

  /* Ocultar columnas menos importantes en mobile */
  .ic-table .hide-mobile { display: none; }
}

/* Print — por si el usuario imprime un perfil de país */
@media print {
  #view-A, #view-C { display: none !important; }
  #view-B { display: block !important; height: auto !important; }
  .cp-topbar, .cp-tabs { position: static; }
  .cp-body { overflow: visible; }
  .ind-card { break-inside: avoid; }
}
