/* =========================================================================
   RTG Repuestos · Dashboard de Inteligencia de Mercado
   Paleta tomada del logotipo: rojo RTG, gris carbón y plata.
   ========================================================================= */

:root {
  --rtg-red: #E31B23;
  --rtg-red-deep: #A8121A;
  --rtg-red-soft: rgba(227, 27, 35, .14);
  --rtg-charcoal: #3A3A3A;
  --rtg-silver: #BDBDBD;

  /* Tema oscuro (por defecto) */
  --bg: #0D0D0F;
  --bg-2: #141417;
  --surface: rgba(255, 255, 255, .045);
  --surface-2: rgba(255, 255, 255, .075);
  --surface-solid: #18181B;
  --border: rgba(255, 255, 255, .09);
  --border-strong: rgba(255, 255, 255, .16);
  --text: #F4F4F5;
  --text-2: #C9C9CF;
  --muted: #8E8E96;
  --grid: rgba(255, 255, 255, .07);
  --glass: rgba(20, 20, 24, .38);
  --glass-border: rgba(255, 255, 255, .12);
  --shadow: 0 20px 50px -20px rgba(0, 0, 0, .7);
  --chart-charcoal: #6B6B73;
  --chart-silver: #C7C7CC;
  --chart-wine: #7A1016;
  --chart-muted: #3C3C42;
  --backdrop-opacity: .22;

  --radius: 18px;
  --radius-sm: 12px;
  --sidebar-w: 276px;
  --sidebar-w-collapsed: 84px;
  --font-display: 'Outfit', 'Segoe UI', system-ui, sans-serif;
  --font-body: 'Manrope', 'Segoe UI', system-ui, sans-serif;
  color-scheme: dark;
}

:root[data-theme="light"] {
  --bg: #F3F3F4;
  --bg-2: #FFFFFF;
  --surface: rgba(255, 255, 255, .78);
  --surface-2: rgba(255, 255, 255, .95);
  --surface-solid: #FFFFFF;
  --border: rgba(20, 20, 25, .08);
  --border-strong: rgba(20, 20, 25, .16);
  --text: #1B1B1E;
  --text-2: #3A3A3A;
  --muted: #6E6E76;
  --grid: rgba(0, 0, 0, .07);
  --glass: rgba(255, 255, 255, .42);
  --glass-border: rgba(255, 255, 255, .7);
  --shadow: 0 18px 40px -22px rgba(30, 30, 40, .35);
  --chart-charcoal: #3A3A3A;
  --chart-silver: #B5B5BA;
  --chart-wine: #7A1016;
  --chart-muted: #DCDCE0;
  --backdrop-opacity: .1;
  color-scheme: light;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.55;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}
img { max-width: 100%; display: block; }
a { color: inherit; }
button { font: inherit; color: inherit; cursor: pointer; }
.num, .kpi-value, td.n { font-variant-numeric: tabular-nums; }

/* ---------- Fondo detrás del sidebar transparente ---------- */
.backdrop {
  position: fixed; inset: 0; z-index: 0; pointer-events: none; overflow: hidden;
}
.backdrop::before {
  content: ""; position: absolute; inset: -40px;
  background: url('../assets/hero.jpg') center / cover no-repeat;
  opacity: var(--backdrop-opacity);
  filter: blur(26px) saturate(1.2);
}
.backdrop::after {
  content: ""; position: absolute; inset: 0;
  background:
    radial-gradient(900px 600px at 0% 0%, rgba(227, 27, 35, .28), transparent 60%),
    radial-gradient(700px 500px at 100% 100%, rgba(227, 27, 35, .12), transparent 60%),
    linear-gradient(180deg, transparent, var(--bg) 85%);
}

/* ---------- Sidebar de vidrio ---------- */
.sidebar {
  position: fixed; z-index: 40; top: 14px; left: 14px; bottom: 14px;
  width: var(--sidebar-w);
  display: flex; flex-direction: column;
  padding: 18px 14px;
  background: var(--glass);
  border: 1px solid var(--glass-border);
  border-radius: 24px;
  backdrop-filter: blur(22px) saturate(1.5);
  -webkit-backdrop-filter: blur(22px) saturate(1.5);
  box-shadow: var(--shadow), inset 0 1px 0 rgba(255, 255, 255, .08);
  transition: width .3s cubic-bezier(.2, .8, .2, 1), transform .3s;
}
.brand {
  display: flex; align-items: center; justify-content: center;
  background: #fff; border-radius: 14px; padding: 10px 14px; margin-bottom: 18px;
  box-shadow: 0 6px 18px -8px rgba(227, 27, 35, .55);
}
.brand img { height: auto; width: 100%; max-height: 64px; object-fit: contain; }
.brand .brand-mini { display: none; }

.nav-label {
  font-size: 11px; letter-spacing: .14em; text-transform: uppercase;
  color: var(--muted); padding: 10px 12px 6px; font-weight: 700;
}
.nav { display: flex; flex-direction: column; gap: 2px; overflow-y: auto; flex: 1; scrollbar-width: none; }
.nav::-webkit-scrollbar { display: none; }
.nav button {
  display: flex; align-items: center; gap: 12px;
  width: 100%; text-align: left; border: 0; background: transparent;
  padding: 10px 12px; border-radius: 12px;
  color: var(--text-2); font-weight: 600; font-size: 14px;
  position: relative; transition: background .2s, color .2s;
}
.nav button svg { width: 19px; height: 19px; flex: none; opacity: .85; }
.nav button .nav-num {
  margin-left: auto; font-size: 11px; color: var(--muted); font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.nav button:hover { background: var(--surface-2); color: var(--text); }
.nav button.active {
  background: linear-gradient(90deg, rgba(227, 27, 35, .9), rgba(168, 18, 26, .85));
  color: #fff; box-shadow: 0 8px 22px -10px rgba(227, 27, 35, .9);
}
.nav button.active .nav-num { color: rgba(255, 255, 255, .8); }

.side-tools {
  border-top: 1px solid var(--glass-border);
  padding-top: 12px; margin-top: 10px;
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px;
}
.tool {
  display: grid; place-items: center; height: 40px; border-radius: 11px;
  border: 1px solid var(--glass-border); background: var(--surface);
  transition: background .2s, border-color .2s, color .2s;
}
.tool svg { width: 18px; height: 18px; }
.tool:hover { background: var(--surface-2); border-color: var(--border-strong); }
.tool.on { background: var(--rtg-red); border-color: var(--rtg-red); color: #fff; }
.side-foot { font-size: 11px; color: var(--muted); text-align: center; margin-top: 10px; }

/* Sidebar colapsado */
body.collapsed .sidebar { width: var(--sidebar-w-collapsed); }
body.collapsed .nav button span, body.collapsed .nav button .nav-num,
body.collapsed .nav-label, body.collapsed .side-foot { display: none; }
body.collapsed .nav button { justify-content: center; padding: 11px 0; }
body.collapsed .brand { padding: 8px; }
body.collapsed .brand .brand-full { display: none; }
body.collapsed .brand .brand-mini { display: block; width: 40px; height: 40px; }
body.collapsed .side-tools { grid-template-columns: 1fr; }

/* ---------- Área principal ---------- */
.main {
  position: relative; z-index: 1;
  margin-left: calc(var(--sidebar-w) + 28px);
  padding: 22px 28px 60px 0;
  transition: margin-left .3s cubic-bezier(.2, .8, .2, 1);
  min-width: 0;
}
body.collapsed .main { margin-left: calc(var(--sidebar-w-collapsed) + 28px); }

.topbar {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  margin-bottom: 20px;
}
.crumb { font-size: 12px; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); font-weight: 700; }
.crumb b { color: var(--rtg-red); }
.topbar .spacer { flex: 1; }
.pill {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 7px 13px; border-radius: 999px; font-size: 12.5px; font-weight: 600;
  background: var(--surface); border: 1px solid var(--border); color: var(--text-2);
  backdrop-filter: blur(10px);
}
.pill .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--rtg-red); box-shadow: 0 0 0 4px var(--rtg-red-soft); }
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 9px 15px; border-radius: 11px; font-weight: 700; font-size: 13px;
  border: 1px solid var(--border-strong); background: var(--surface-2);
  transition: transform .15s, background .2s;
}
.btn svg { width: 16px; height: 16px; }
.btn:hover { transform: translateY(-1px); }
.btn.primary { background: var(--rtg-red); border-color: var(--rtg-red); color: #fff; }
.btn.primary:hover { background: #F02A32; }
.btn.ghost { background: transparent; }
.menu-toggle { display: none; }

/* ---------- Secciones ---------- */
.section { display: none; animation: rise .5s cubic-bezier(.2, .8, .2, 1); }
.section.active { display: block; }
@keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }

.sec-head { margin: 6px 0 22px; max-width: 900px; }
.eyebrow {
  display: inline-flex; align-items: center; gap: 10px;
  font-size: 12px; letter-spacing: .16em; text-transform: uppercase; font-weight: 800;
  color: var(--rtg-red);
}
.eyebrow::before { content: ""; width: 26px; height: 3px; background: var(--rtg-red); border-radius: 3px; }
h1, h2, h3, h4 { font-family: var(--font-display); margin: 0; letter-spacing: -.01em; }
.sec-head h2 { font-size: clamp(28px, 3.2vw, 42px); line-height: 1.08; margin-top: 8px; font-weight: 700; }
.sec-head p { color: var(--text-2); font-size: 16px; margin: 10px 0 0; }

/* ---------- Portada ---------- */
.cover {
  position: relative; border-radius: 28px; overflow: hidden;
  min-height: calc(100vh - 110px);
  display: flex; flex-direction: column; justify-content: flex-end;
  padding: clamp(28px, 4vw, 56px);
  border: 1px solid var(--border);
  background: #0b0b0c url('../assets/hero.jpg') right center / cover no-repeat;
  color: #fff;
}
.cover::before {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(90deg, rgba(8, 8, 9, .96) 0%, rgba(8, 8, 9, .82) 38%, rgba(8, 8, 9, .15) 75%),
              linear-gradient(0deg, rgba(8, 8, 9, .9), transparent 45%);
}
.cover > * { position: relative; }
.cover .cover-logo { background: #fff; border-radius: 14px; padding: 10px 16px; width: fit-content; margin-bottom: auto; }
.cover .cover-logo img { height: 50px; width: auto; }
.cover .eyebrow { margin-top: 40px; }
.cover h1 {
  font-size: clamp(42px, 6.4vw, 92px); line-height: .95; font-weight: 800;
  margin: 14px 0 14px; max-width: 760px; text-transform: uppercase;
}
.cover h1 em { font-style: normal; color: var(--rtg-red); }
.cover .lead { font-size: clamp(15px, 1.4vw, 19px); color: #D8D8DC; max-width: 600px; margin: 0; }
.cover-kpis {
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px;
  margin-top: 34px; max-width: 820px;
}
.cover-kpi {
  padding: 18px 20px; border-radius: 16px;
  background: rgba(255, 255, 255, .06); border: 1px solid rgba(255, 255, 255, .14);
  backdrop-filter: blur(12px);
}
.cover-kpi .kpi-value { white-space: nowrap; font-family: var(--font-display); font-size: clamp(24px, 2.3vw, 36px); font-weight: 700; line-height: 1; }
.cover-kpi .kpi-label { font-size: 12.5px; color: #BEBEC4; margin-top: 8px; }
.cover-meta { display: flex; gap: 22px; flex-wrap: wrap; margin-top: 26px; font-size: 12px; color: #A9A9B0; letter-spacing: .08em; text-transform: uppercase; font-weight: 700; }
.cover-meta span b { color: #fff; }

/* ---------- Banner de país ---------- */
.banner {
  position: relative; border-radius: 26px; overflow: hidden;
  min-height: 300px; padding: clamp(24px, 3.4vw, 44px);
  display: flex; flex-direction: column; justify-content: flex-end;
  border: 1px solid var(--border); margin-bottom: 22px; color: #fff;
  background: #0b0b0c center / cover no-repeat;
}
.banner::before {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(90deg, rgba(8, 8, 9, .94) 0%, rgba(8, 8, 9, .7) 42%, rgba(8, 8, 9, .05) 85%);
}
.banner > * { position: relative; }
.banner h2 { font-size: clamp(34px, 4.4vw, 60px); font-weight: 800; line-height: 1; margin: 10px 0 10px; }
.banner p { margin: 0; color: #D6D6DB; max-width: 560px; font-size: 16px; }
.banner .flagline { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 18px; }
.banner .flagline .pill { background: rgba(255, 255, 255, .1); border-color: rgba(255, 255, 255, .18); color: #fff; }
.banner.ec { background-image: url('../assets/ecuador.jpg'); }
.banner.pa { background-image: url('../assets/panama.jpg'); }
.banner.rd { background-image: url('../assets/rd.jpg'); }

/* ---------- Grid y tarjetas ---------- */
.grid { display: grid; gap: 18px; margin-bottom: 18px; }
.g-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.g-5-7 { grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); }
.g-7-5 { grid-template-columns: minmax(0, 7fr) minmax(0, 5fr); }
.span-2 { grid-column: span 2; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  min-width: 0;
}
.card h3 { font-size: 18px; font-weight: 700; }
.card h3 + p, .card .sub { color: var(--muted); font-size: 13px; margin: 4px 0 0; }
.card p { color: var(--text-2); }
.card-head { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 14px; }
.card-head > div { flex: 1; min-width: 0; }

/* KPI */
.kpi { position: relative; overflow: hidden; }
.kpi::after {
  content: ""; position: absolute; right: -30px; top: -30px; width: 110px; height: 110px;
  border-radius: 50%; background: radial-gradient(circle, rgba(227, 27, 35, .22), transparent 70%);
}
.kpi .kpi-label { font-size: 12px; text-transform: uppercase; letter-spacing: .1em; font-weight: 700; color: var(--muted); }
.kpi .kpi-value { font-family: var(--font-display); font-size: clamp(26px, 2.4vw, 34px); font-weight: 700; line-height: 1.1; margin-top: 8px; }
.kpi .kpi-foot { font-size: 12.5px; color: var(--text-2); margin-top: 6px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.delta { font-weight: 800; font-size: 12px; padding: 2px 8px; border-radius: 999px; background: rgba(34, 197, 94, .14); color: #3FD07A; }
:root[data-theme="light"] .delta { color: #15803D; }
.kpi.accent { background: linear-gradient(140deg, rgba(227, 27, 35, .95), rgba(140, 14, 20, .95)); border-color: transparent; color: #fff; }
.kpi.accent .kpi-label, .kpi.accent .kpi-foot { color: rgba(255, 255, 255, .85); }
.kpi.accent::after { background: radial-gradient(circle, rgba(255, 255, 255, .2), transparent 70%); }

/* Chart cards */
.chart-card .chart-box { position: relative; height: 320px; }
.chart-card .chart-box.tall { height: 420px; }
.chart-card .chart-box.short { height: 260px; }
.chart-note { font-size: 12px; color: var(--muted); margin-top: 12px; border-top: 1px dashed var(--border); padding-top: 10px; }
.chart-actions { display: flex; gap: 6px; flex: none; }
.icon-btn {
  display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 10px;
  border: 1px solid var(--border); background: var(--surface-2); color: var(--text-2);
  transition: color .2s, border-color .2s, background .2s;
}
.icon-btn svg { width: 16px; height: 16px; }
.icon-btn:hover { color: var(--rtg-red); border-color: var(--rtg-red); }
.chart-type {
  height: 34px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface-2);
  color: var(--text-2); padding: 0 8px; font: inherit; font-size: 12.5px; font-weight: 600;
}

/* Callouts */
.callout {
  display: flex; gap: 16px; align-items: flex-start;
  border-radius: var(--radius); padding: 20px 22px; margin-bottom: 18px;
  background: linear-gradient(110deg, rgba(227, 27, 35, .16), rgba(227, 27, 35, .03));
  border: 1px solid rgba(227, 27, 35, .35);
}
.callout .ico { flex: none; width: 40px; height: 40px; border-radius: 12px; background: var(--rtg-red); color: #fff; display: grid; place-items: center; }
.callout .ico svg { width: 20px; height: 20px; }
.callout h4 { font-size: 16px; margin-bottom: 4px; }
.callout p { margin: 0; color: var(--text-2); }
.callout.neutral { background: var(--surface); border-color: var(--border); }
.callout.neutral .ico { background: var(--rtg-charcoal); }

/* Listas */
.list { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.list li { display: flex; gap: 12px; color: var(--text-2); }
.list li::before {
  content: ""; flex: none; width: 8px; height: 8px; margin-top: 8px; border-radius: 2px;
  background: var(--rtg-red); transform: rotate(45deg);
}
.list li b { color: var(--text); }

/* Tablas */
.table-wrap { overflow-x: auto; border-radius: var(--radius-sm); border: 1px solid var(--border); }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th, td { padding: 11px 14px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: top; }
th {
  font-size: 11px; text-transform: uppercase; letter-spacing: .1em; color: var(--muted);
  font-weight: 800; background: var(--surface-2); position: sticky; top: 0; white-space: nowrap;
}
tbody tr:last-child td { border-bottom: 0; }
tbody tr { transition: background .15s; }
tbody tr:hover { background: var(--surface-2); }
td.n, th.n { text-align: right; white-space: nowrap; }
td:first-child { font-weight: 700; color: var(--text); }
td { color: var(--text-2); }

.tag {
  display: inline-flex; align-items: center; gap: 6px; white-space: nowrap;
  padding: 3px 10px; border-radius: 999px; font-size: 11.5px; font-weight: 800;
  border: 1px solid var(--border-strong); color: var(--text-2);
}
.tag.p1 { background: var(--rtg-red); border-color: var(--rtg-red); color: #fff; }
.tag.p2 { background: rgba(227, 27, 35, .16); border-color: rgba(227, 27, 35, .5); color: #FF6B70; }
:root[data-theme="light"] .tag.p2 { color: var(--rtg-red-deep); }
.tag.p3 { background: var(--surface-2); }
.tag.log { border-style: dashed; }

/* Comparativa país */
.country-col h4 { display: flex; align-items: center; gap: 10px; font-size: 17px; margin-bottom: 12px; }
.country-col h4 .badge { font-size: 11px; padding: 3px 8px; border-radius: 7px; background: var(--rtg-red); color: #fff; letter-spacing: .06em; }
.stat-row { display: flex; justify-content: space-between; gap: 12px; padding: 9px 0; border-bottom: 1px dashed var(--border); font-size: 13.5px; }
.stat-row:last-child { border-bottom: 0; }
.stat-row span:first-child { color: var(--muted); }
.stat-row span:last-child { font-weight: 700; text-align: right; }

/* Barras de participación */
.meter { margin: 10px 0 4px; }
.meter-top { display: flex; justify-content: space-between; font-size: 13px; margin-bottom: 6px; }
.meter-top b { font-variant-numeric: tabular-nums; }
.meter-track { height: 8px; border-radius: 99px; background: var(--surface-2); overflow: hidden; }
.meter-fill { height: 100%; border-radius: 99px; background: linear-gradient(90deg, var(--rtg-red-deep), var(--rtg-red)); width: 0; transition: width 1s cubic-bezier(.2, .8, .2, 1); }

/* Timeline 90 días */
.timeline { position: relative; display: grid; gap: 14px; }
.timeline::before { content: ""; position: absolute; left: 25px; top: 10px; bottom: 10px; width: 2px; background: linear-gradient(var(--rtg-red), transparent); }
.step { display: grid; grid-template-columns: 52px 1fr; gap: 16px; align-items: start; }
.step .dot {
  width: 52px; height: 52px; border-radius: 16px; display: grid; place-items: center;
  background: var(--surface-solid); border: 2px solid var(--rtg-red); color: var(--rtg-red);
  font-family: var(--font-display); font-weight: 800; font-size: 18px; position: relative; z-index: 1;
}
.step .card { padding: 18px 20px; }
.step .when { font-size: 11.5px; letter-spacing: .12em; text-transform: uppercase; font-weight: 800; color: var(--rtg-red); }
.step h4 { font-size: 16.5px; margin: 4px 0 10px; }
.step .cols { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; font-size: 13.5px; }
.step .cols small { display: block; font-size: 11px; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); font-weight: 800; margin-bottom: 3px; }

/* Mayorista vs retail */
.vs { display: grid; grid-template-columns: 170px 1fr 1fr; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.vs > div { padding: 13px 16px; border-bottom: 1px solid var(--border); font-size: 13.5px; color: var(--text-2); }
.vs > .h { font-family: var(--font-display); font-weight: 700; font-size: 16px; color: #fff; }
.vs > .h.b2b { background: var(--rtg-red); }
.vs > .h.ret { background: var(--rtg-charcoal); }
.vs > .k { font-weight: 800; color: var(--text); font-size: 12px; text-transform: uppercase; letter-spacing: .08em; background: var(--surface-2); }
.vs > div:nth-last-child(-n+3) { border-bottom: 0; }

/* Herramientas de tabla */
.table-tools { display: flex; gap: 10px; align-items: center; margin-bottom: 12px; flex-wrap: wrap; }
.search {
  flex: 1; min-width: 200px; height: 40px; border-radius: 11px; padding: 0 14px 0 38px;
  border: 1px solid var(--border); background: var(--surface-2) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%238E8E96' stroke-width='2' viewBox='0 0 24 24'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='m20 20-3.5-3.5'/%3E%3C/svg%3E") 13px center no-repeat;
  color: var(--text); font: inherit;
}
.search:focus { outline: 2px solid var(--rtg-red); outline-offset: 1px; }
.seg { display: inline-flex; padding: 4px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--border); gap: 2px; }
.seg button { border: 0; background: transparent; padding: 7px 13px; border-radius: 9px; font-weight: 700; font-size: 13px; color: var(--text-2); }
.seg button.on { background: var(--rtg-red); color: #fff; }

.sources { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.source { display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--border); background: var(--surface); text-decoration: none; transition: border-color .2s; }
.source:hover { border-color: var(--rtg-red); }
.source code { flex: none; font-size: 11.5px; font-weight: 800; color: var(--rtg-red); background: var(--rtg-red-soft); padding: 3px 7px; border-radius: 6px; }
.source span { font-size: 13px; color: var(--text-2); }

/* ---------- Modo edición ---------- */
body.editing [data-ed] { outline: 1px dashed rgba(227, 27, 35, .55); outline-offset: 3px; border-radius: 4px; cursor: text; }
body.editing [data-ed]:hover { background: rgba(227, 27, 35, .08); }
body.editing [data-ed]:focus { outline: 2px solid var(--rtg-red); background: rgba(227, 27, 35, .1); }
.edit-banner {
  position: fixed; z-index: 60; left: 50%; bottom: 22px; transform: translate(-50%, 140%);
  display: flex; align-items: center; gap: 14px; padding: 10px 12px 10px 18px;
  background: var(--surface-solid); border: 1px solid var(--rtg-red); border-radius: 14px;
  box-shadow: var(--shadow); transition: transform .35s cubic-bezier(.2, .8, .2, 1), opacity .35s; font-size: 13.5px; font-weight: 600;
  opacity: 0; visibility: hidden; pointer-events: none;
}
body.editing .edit-banner { transform: translate(-50%, 0); opacity: 1; visibility: visible; pointer-events: auto; }
.edit-banner .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--rtg-red); animation: pulse 1.6s infinite; }
@keyframes pulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(227, 27, 35, .6); } 50% { box-shadow: 0 0 0 7px rgba(227, 27, 35, 0); } }

/* ---------- Modal editor de datos ---------- */
.modal { position: fixed; inset: 0; z-index: 80; display: grid; place-items: center; padding: 20px; background: rgba(0, 0, 0, .6); backdrop-filter: blur(6px); }
.modal-card {
  width: min(860px, 100%); max-height: 88vh; display: flex; flex-direction: column;
  background: var(--surface-solid); border: 1px solid var(--border-strong); border-radius: 20px; box-shadow: var(--shadow);
}
.modal-head { display: flex; align-items: center; gap: 12px; padding: 18px 22px; border-bottom: 1px solid var(--border); }
.modal-head h3 { flex: 1; font-size: 18px; }
.modal-body { padding: 18px 22px; overflow: auto; }
.modal-foot { display: flex; gap: 10px; padding: 14px 22px; border-top: 1px solid var(--border); flex-wrap: wrap; }
.modal-foot .spacer { flex: 1; }
.data-grid input {
  width: 100%; min-width: 90px; height: 36px; border-radius: 8px; padding: 0 10px;
  border: 1px solid var(--border); background: var(--surface-2); color: var(--text); font: inherit; font-size: 13.5px;
}
.data-grid input:focus { outline: 2px solid var(--rtg-red); }
.data-grid td, .data-grid th { padding: 6px; border: 0; }
.data-grid td:first-child { font-weight: 400; }
.field { display: grid; gap: 6px; margin-bottom: 14px; }
.field label { font-size: 11.5px; text-transform: uppercase; letter-spacing: .1em; font-weight: 800; color: var(--muted); }
.field input { height: 40px; border-radius: 10px; padding: 0 12px; border: 1px solid var(--border); background: var(--surface-2); color: var(--text); font: inherit; }

.toast {
  position: fixed; z-index: 90; right: 22px; top: 22px; padding: 12px 18px; border-radius: 12px;
  background: var(--surface-solid); border: 1px solid var(--border-strong); box-shadow: var(--shadow), inset 0 0 0 1px rgba(227, 27, 35, .35);
  box-shadow: var(--shadow); font-weight: 600; font-size: 13.5px;
  transform: translateY(-20px); opacity: 0; transition: all .3s; pointer-events: none;
}
.toast.show { transform: none; opacity: 1; }

/* ---------- Modo presentación ---------- */
.present-bar { display: none; }
body.presenting .sidebar { transform: translateX(calc(-100% - 30px)); }
body.presenting .main { margin-left: 28px; padding-right: 28px; }
body.presenting .topbar, body.presenting .chart-actions { display: none; }
body.presenting .present-bar {
  display: flex; position: fixed; z-index: 50; left: 50%; bottom: 18px; transform: translateX(-50%);
  align-items: center; gap: 8px; padding: 6px; border-radius: 14px;
  background: var(--glass); border: 1px solid var(--glass-border); backdrop-filter: blur(18px);
  opacity: .35; transition: opacity .3s;
}
body.presenting .present-bar:hover { opacity: 1; }
.present-bar .count { font-size: 12.5px; font-weight: 800; padding: 0 10px; font-variant-numeric: tabular-nums; }
.progress { position: fixed; z-index: 55; top: 0; left: 0; height: 3px; background: var(--rtg-red); width: 0; transition: width .4s; box-shadow: 0 0 12px var(--rtg-red); }

/* ---------- Responsive ---------- */
@media (max-width: 1280px) {
  .g-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 1080px) {
  .g-3, .g-5-7, .g-7-5 { grid-template-columns: minmax(0, 1fr); }
  .g-2 { grid-template-columns: minmax(0, 1fr); }
  .span-2 { grid-column: auto; }
  .sources { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 860px) {
  .sidebar { transform: translateX(calc(-100% - 30px)); width: var(--sidebar-w) !important; }
  body.nav-open .sidebar { transform: none; }
  .main, body.collapsed .main { margin-left: 0; padding: 16px 16px 60px; }
  .menu-toggle { display: inline-flex; }
  .cover-kpis { grid-template-columns: minmax(0, 1fr); }
  .vs { grid-template-columns: 110px 1fr 1fr; }
  .step .cols { grid-template-columns: minmax(0, 1fr); }
  .collapse-btn { display: none !important; }
}
@media (max-width: 560px) {
  .g-4 { grid-template-columns: minmax(0, 1fr); }
  .vs { grid-template-columns: minmax(0, 1fr); }
  .vs > .k { background: transparent; padding-bottom: 0; }
  .topbar .btn span { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---------- Impresión ---------- */
@media print {
  .sidebar, .topbar, .chart-actions, .backdrop, .edit-banner, .present-bar, .progress { display: none !important; }
  .main { margin: 0; padding: 0; }
  .section { display: block !important; page-break-after: always; }
  .card { backdrop-filter: none; }
}

/* ---------- Cambiar imagen (solo en modo edición) ---------- */
.img-swap {
  position: absolute !important; top: 16px; right: 16px; z-index: 2;
  display: none; background: rgba(15, 15, 17, .75); border-color: rgba(255, 255, 255, .25); color: #fff;
  backdrop-filter: blur(8px);
}
body.editing .img-swap { display: inline-flex; }

/* ---------- Impresión de todas las secciones ---------- */
body.print-all .section { display: block; animation: none; margin-bottom: 30px; }
table.compact th, table.compact td { padding: 10px 11px; }
table.compact td:first-child { min-width: 130px; }
.chart-card .card-head { flex-wrap: wrap; }
.chart-card .card-head > div:first-child { flex: 1 1 220px; }
.chart-card .chart-actions { margin-left: auto; }
.chart-type { max-width: 170px; }
.card-head > .chart-actions { flex: none; min-width: auto; }
