/* ============================================================================
   SIMA Energía · Diagnóstico Comercial — Hoja de estilos ejecutiva
   Paleta: azul marino (identidad ALLIANCE) + blanco + grises. Sin stock,
   sin animación decorativa. Tipografía corporativa vía Google Fonts.
   ============================================================================ */

:root {
  --navy-950: #0f1626;
  --navy-900: #16223b;
  --navy-800: #1e2f4f;
  --navy-700: #263c63;
  --navy-600: #324e7d;
  --navy-500: #3f5f96;
  --teal-600: #1f7e82;
  --teal-500: #2a9d94;
  --gray-900: #1f2429;
  --gray-700: #3d444d;
  --gray-500: #6b7280;
  --gray-300: #d1d5db;
  --gray-200: #e5e7eb;
  --gray-100: #f2f4f7;
  --gray-50: #f8f9fb;
  --white: #ffffff;
  --danger: #8a2c2c;
  --warn: #8a6a1f;
  --ok: #1f6d4a;
  --shadow-card: 0 1px 2px rgba(15, 22, 38, 0.06), 0 4px 12px rgba(15, 22, 38, 0.06);
  --radius: 10px;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  font-family: 'IBM Plex Sans', 'Inter', system-ui, -apple-system, Segoe UI, Arial, sans-serif;
  color: var(--gray-900);
  background: var(--gray-50);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

h1, h2, h3, h4, .font-serif-head {
  font-family: 'IBM Plex Serif', Georgia, 'Times New Roman', serif;
}

a { color: var(--navy-600); }
a:hover { color: var(--teal-600); }

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--navy-900);
  color: #fff;
  padding: 0.5rem 1rem;
  z-index: 10000;
}
.skip-link:focus {
  left: 0.5rem;
  top: 0.5rem;
}

/* ---------------------------------------------------------------------------
   Barra de clasificación persistente
   --------------------------------------------------------------------------- */
#sticky-top-group {
  position: sticky;
  top: 0;
  z-index: 500;
}
.confidential-bar {
  background: var(--navy-950);
  color: #fff;
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  text-align: center;
  padding: 0.4rem 0.75rem;
  padding-top: max(0.4rem, env(safe-area-inset-top));
  font-weight: 600;
}

/* ---------------------------------------------------------------------------
   Pantalla de acceso restringido (aviso obligatorio, no sustituye autenticación)
   --------------------------------------------------------------------------- */
#gate-screen {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: linear-gradient(160deg, var(--navy-950) 0%, var(--navy-800) 60%, var(--navy-700) 100%);
  color: #eef1f6;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
  padding-top: max(1.25rem, env(safe-area-inset-top));
  padding-bottom: max(1.25rem, env(safe-area-inset-bottom));
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
#gate-screen.gate-hidden { display: none; }
.gate-card {
  background: rgba(15, 22, 38, 0.55);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 14px;
  max-width: 720px;
  width: 100%;
  padding: 2rem 2rem 1.75rem;
  -webkit-backdrop-filter: blur(2px);
  backdrop-filter: blur(2px);
}
.gate-card .gate-logo { height: 34px; margin-bottom: 1.25rem; filter: brightness(0) invert(1); opacity: 0.95; }
.gate-card h1 {
  font-size: 1.35rem;
  color: #fff;
  margin-bottom: 1rem;
  letter-spacing: 0.01em;
}
.gate-card p { font-size: 0.92rem; line-height: 1.55; color: #d7dee9; margin-bottom: 0.85rem; }
.gate-entities {
  font-size: 0.82rem;
  color: #b9c4d4;
  border-left: 2px solid var(--teal-500);
  padding-left: 0.75rem;
  margin: 1rem 0 1.25rem;
}
.gate-checkbox-row {
  display: flex;
  gap: 0.6rem;
  align-items: flex-start;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 8px;
  padding: 0.85rem;
  margin-bottom: 1rem;
}
.gate-checkbox-row input[type="checkbox"] {
  margin-top: 0.2rem;
  width: 1.05rem;
  height: 1.05rem;
  accent-color: var(--teal-500);
  flex-shrink: 0;
}
.gate-checkbox-row label { font-size: 0.86rem; color: #eef1f6; line-height: 1.45; cursor: pointer; }
#gate-accept-btn {
  width: 100%;
  background: var(--teal-600);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 0.8rem 1rem;
  font-weight: 600;
  font-size: 0.95rem;
  letter-spacing: 0.02em;
  cursor: not-allowed;
  opacity: 0.5;
  transition: opacity 0.15s ease;
}
#gate-accept-btn.enabled { cursor: pointer; opacity: 1; }
#gate-accept-btn.enabled:hover { background: var(--teal-500); }
.gate-note {
  font-size: 0.72rem;
  color: #97a3b6;
  margin-top: 0.9rem;
  text-align: center;
  font-style: italic;
}

/* ---------------------------------------------------------------------------
   Encabezado y navegación
   --------------------------------------------------------------------------- */
#site-header {
  background: var(--white);
  border-bottom: 1px solid var(--gray-200);
}
#site-header .brand-logo { height: 30px; width: auto; object-fit: contain; }

#section-nav {
  background: var(--navy-900);
  color: #cfd7e4;
}
#section-nav a {
  color: #cfd7e4;
  font-size: 0.82rem;
  font-weight: 500;
  white-space: nowrap;
  padding: 0.7rem 0.85rem;
  display: inline-block;
  border-bottom: 2px solid transparent;
}
#section-nav a:hover, #section-nav a.active {
  color: #fff;
  border-bottom-color: var(--teal-500);
}
#nav-scroll { overflow-x: auto; scrollbar-width: thin; }
#nav-scroll::-webkit-scrollbar { height: 4px; }
#nav-scroll::-webkit-scrollbar-thumb { background: var(--navy-600); border-radius: 4px; }

#mobile-nav-toggle { display: none; }
@media (max-width: 768px) {
  #mobile-nav-toggle { display: inline-flex; }
  #nav-scroll { display: none; flex-direction: column; }
  #nav-scroll.open { display: flex; }
  #section-nav a { display: block; border-bottom: 1px solid rgba(255,255,255,0.08); border-left: 2px solid transparent; }
  #section-nav a.active { border-left-color: var(--teal-500); border-bottom-color: transparent; }
}

/* ---------------------------------------------------------------------------
   Layout general de secciones
   --------------------------------------------------------------------------- */
.exec-section { padding: 2.25rem 0; border-bottom: 1px solid var(--gray-200); }
.exec-section:last-of-type { border-bottom: none; }
.section-kicker {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--teal-600);
  margin-bottom: 0.35rem;
}
.section-title { font-size: 1.6rem; color: var(--navy-900); margin-bottom: 0.6rem; }
.section-lede { color: var(--gray-700); font-size: 0.95rem; max-width: 70ch; margin-bottom: 1.5rem; }

.card {
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 0.22rem 0.55rem;
  border-radius: 999px;
}
.badge-critica { background: #fbeaea; color: var(--danger); }
.badge-alta { background: #fdf3e2; color: var(--warn); }
.badge-favorable { background: #e6f3ec; color: var(--ok); }
.badge-navy { background: var(--navy-50, #eef1f7); color: var(--navy-700); background: #eef1f7; }
.badge-teal { background: #e4f3f2; color: var(--teal-600); }
.badge-gray { background: var(--gray-100); color: var(--gray-700); }

/* Tono de alternativas / veredictos */
.tone-riesgo { border-left: 4px solid var(--danger); }
.tone-neutro { border-left: 4px solid var(--warn); }
.tone-recomendada { border-left: 4px solid var(--ok); }

/* ---------------------------------------------------------------------------
   Matriz de madurez (barras de nivel)
   --------------------------------------------------------------------------- */
.maturity-bar { display: flex; gap: 3px; }
.maturity-dot { width: 16px; height: 8px; border-radius: 2px; background: var(--gray-200); }
.maturity-dot.filled-1 { background: var(--danger); }
.maturity-dot.filled-2 { background: var(--warn); }
.maturity-dot.filled-3 { background: var(--ok); }

/* ---------------------------------------------------------------------------
   Tooltip accesible (CSS, funciona con hover, foco y toggle táctil)
   --------------------------------------------------------------------------- */
.tt {
  position: relative;
  border-bottom: 1px dotted var(--navy-500);
  cursor: help;
  font-weight: 600;
  color: var(--navy-700);
}
.tt:focus { outline: 2px solid var(--teal-500); outline-offset: 2px; }
.tt-bubble {
  position: absolute;
  left: 0;
  bottom: calc(100% + 8px);
  background: var(--navy-950);
  color: #fff;
  font-size: 0.78rem;
  font-weight: 400;
  line-height: 1.4;
  padding: 0.55rem 0.7rem;
  border-radius: 6px;
  width: 240px;
  box-shadow: 0 6px 20px rgba(0,0,0,0.25);
  opacity: 0;
  visibility: hidden;
  transform: translateY(4px);
  transition: opacity 0.12s ease, transform 0.12s ease;
  z-index: 300;
}
.tt-bubble::after {
  content: '';
  position: absolute;
  top: 100%; left: 14px;
  border: 6px solid transparent;
  border-top-color: var(--navy-950);
}
.tt:hover .tt-bubble, .tt:focus .tt-bubble, .tt.tt-open .tt-bubble {
  opacity: 1; visibility: visible; transform: translateY(0);
}

/* ---------------------------------------------------------------------------
   Acordeones de perfiles (cerrados por defecto)
   --------------------------------------------------------------------------- */
.accordion-item { border: 1px solid var(--gray-200); border-radius: var(--radius); background: var(--white); overflow: hidden; }
.accordion-trigger {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  padding: 1rem 1.1rem;
  background: transparent;
  border: none;
  text-align: left;
  cursor: pointer;
  font-family: inherit;
}
.accordion-trigger:hover { background: var(--gray-50); }
.accordion-trigger .chev { transition: transform 0.15s ease; color: var(--gray-500); }
.accordion-item[data-open="true"] .accordion-trigger .chev { transform: rotate(180deg); }
.accordion-panel {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.2s ease;
}
.accordion-item[data-open="true"] .accordion-panel { max-height: none; }
.accordion-panel-inner { padding: 0 1.1rem 1.25rem; }

/* ---------------------------------------------------------------------------
   Tablas responsivas
   --------------------------------------------------------------------------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; border: 1px solid var(--gray-200); border-radius: var(--radius); }
table.exec-table { width: 100%; border-collapse: collapse; font-size: 0.86rem; min-width: 640px; }
table.exec-table th {
  background: var(--navy-900);
  color: #e7ebf2;
  text-align: left;
  padding: 0.65rem 0.85rem;
  font-weight: 600;
  font-size: 0.76rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  white-space: nowrap;
}
table.exec-table td { padding: 0.65rem 0.85rem; border-bottom: 1px solid var(--gray-200); vertical-align: top; }
table.exec-table tbody tr:hover { background: var(--gray-50); }
table.exec-table tbody tr:last-child td { border-bottom: none; }

/* ---------------------------------------------------------------------------
   Línea de tiempo 90 días
   --------------------------------------------------------------------------- */
.timeline-track { display: flex; overflow-x: auto; gap: 0; scrollbar-width: thin; padding-bottom: 0.5rem; }
.timeline-phase {
  flex: 0 0 260px;
  border-top: 4px solid var(--navy-600);
  padding: 0.9rem 1rem 0.2rem;
  cursor: pointer;
}
.timeline-phase.active { border-top-color: var(--teal-500); background: var(--gray-50); }
.timeline-phase-range { font-size: 0.72rem; color: var(--gray-500); font-weight: 700; text-transform: uppercase; }
.timeline-detail { display: none; }
.timeline-detail.active { display: block; }

/* ---------------------------------------------------------------------------
   Filtros de unidad (etiqueta operativa, no jurídica)
   --------------------------------------------------------------------------- */
.unit-filter-btn {
  font-size: 0.78rem;
  font-weight: 600;
  padding: 0.4rem 0.85rem;
  border-radius: 999px;
  border: 1px solid var(--gray-300);
  background: var(--white);
  color: var(--gray-700);
  cursor: pointer;
}
.unit-filter-btn.active { background: var(--navy-900); color: #fff; border-color: var(--navy-900); }

/* ---------------------------------------------------------------------------
   Footer
   --------------------------------------------------------------------------- */
#site-footer { background: var(--navy-950); color: #b9c4d4; }
#site-footer a { color: #d7dee9; }
#site-footer a:hover { color: #fff; }
.footer-tagline { font-size: 0.78rem; letter-spacing: 0.04em; text-transform: uppercase; color: #8a97ac; font-weight: 700; }

/* ---------------------------------------------------------------------------
   Botón de reporte de incidentes
   --------------------------------------------------------------------------- */
.incident-box { background: #241414; border: 1px solid #4a2222; border-radius: var(--radius); }

/* ---------------------------------------------------------------------------
   Impresión — sólo resumen ejecutivo, con marca de agua de confidencialidad
   --------------------------------------------------------------------------- */
@media print {
  /* Elimina del flujo (no solo oculta) todo lo que no sea el resumen ejecutivo,
     para que el documento impreso tenga la altura real de una sola página y
     no genere páginas en blanco adicionales por el contenido restante. */
  #gate-screen, #sticky-top-group, #site-footer, .no-print,
  #diagnostico, #dictamenes, #caminos, #plan90, #kpis, #perfiles, #riesgos, #fuentes {
    display: none !important;
  }
  body { background: #fff; margin: 0; }
  #main-content { margin: 0 !important; }
  #resumen { padding: 0 !important; border-bottom: none !important; }
  body * { visibility: hidden; }
  #print-area, #print-area * { visibility: visible; }
  #print-area {
    position: absolute; left: 0; top: 0; width: 100%;
  }
  #print-area::before {
    content: 'CONFIDENCIAL \2014 USO EXCLUSIVO DE DIRECTIVOS AUTORIZADOS';
    position: fixed;
    top: 45%; left: 50%;
    transform: translate(-50%, -50%) rotate(-30deg);
    font-size: 2.6rem;
    font-weight: 800;
    color: rgba(120,130,150,0.28);
    white-space: nowrap;
    z-index: 9999;
  }
  @page { margin: 1.5cm; }
}

@media (max-width: 640px) {
  .section-title { font-size: 1.3rem; }
  .gate-card { padding: 1.4rem 1.2rem; }
}
