/* ==============================================================================
   ESTILOS INSTITUCIONALES PROFESIONALES (TEMA CLARO / LIGHT THEME)
   Diseño: GovTech / Observatorio de Políticas Públicas y Pobreza (ODS 1)
   Inspirado en portales analíticos modernos (Banco Mundial, PNUD, INEI)
   ============================================================================== */

:root {
  --font-main: 'Outfit', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;

  /* Paleta Tema Claro */
  --bg-body: #f8fafc;
  --bg-card: #ffffff;
  --bg-card-hover: #ffffff;
  --bg-elevated: #f1f5f9;
  --bg-subtle: #f8fafc;
  --border-color: #e2e8f0;
  --border-hover: #cbd5e1;
  --border-focus: #10b981;

  --text-main: #0f172a;       /* Slate 900 */
  --text-muted: #334155;      /* Slate 700 */
  --text-dim: #64748b;        /* Slate 500 */

  /* Acentos de estado */
  --accent-primary: #059669;  /* Esmeralda Institucional */
  --accent-light: #ecfdf5;
  --color-danger: #dc2626;    /* Rojo */
  --color-warning: #d97706;   /* Ámbar */
  --color-info: #2563eb;      /* Azul */
  --color-success: #059669;   /* Verde */
  --color-purple: #7c3aed;    /* Púrpura */

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-full: 9999px;

  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-card: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
  --shadow-hover: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -4px rgba(0, 0, 0, 0.04);
  --transition: all 0.2s ease-in-out;
}

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-main);
  background-color: var(--bg-body);
  color: var(--text-main);
  min-height: 100vh;
  line-height: 1.6;
  overflow-x: hidden;
  position: relative;
}

/* Desactivar brillos oscuros de IA */
.ambient-glow {
  display: none;
}

/* ==============================================================================
   LAYOUT GENERAL CON BARRA LATERAL IZQUIERDA
   ============================================================================== */

.app-layout {
  display: flex;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
  background-color: var(--bg-body);
}

/* Barra Lateral Izquierda (Fija) */
.left-sidebar {
  width: 270px;
  min-width: 270px;
  height: 100vh;
  background: #ffffff;
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  box-shadow: 2px 0 10px rgba(0, 0, 0, 0.03);
  z-index: 100;
  user-select: none;
}

.sidebar-brand {
  padding: 22px 20px 18px;
  border-bottom: 1px solid var(--border-color);
  background: #ffffff;
}

.sidebar-brand-title {
  font-size: 1.15rem;
  font-weight: 800;
  color: #0f172a;
  letter-spacing: -0.02em;
  margin-top: 6px;
  line-height: 1.25;
}

.sidebar-brand-sub {
  font-size: 0.76rem;
  color: var(--text-dim);
  font-weight: 500;
  margin-top: 3px;
}

.sidebar-nav {
  padding: 18px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
  overflow-y: auto;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  border-radius: var(--radius-md);
  background: transparent;
  border: 1px solid transparent;
  color: #334155;
  font-family: var(--font-main);
  font-size: 0.88rem;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
  transition: var(--transition);
  position: relative;
}

.nav-item svg {
  color: #64748b;
  flex-shrink: 0;
  transition: var(--transition);
}

.nav-item:hover {
  background: #f1f5f9;
  color: #0f172a;
}

.nav-item:hover svg {
  color: #059669;
}

.nav-item.active {
  background: #ecfdf5;
  color: #047857;
  border-color: #a7f3d0;
  font-weight: 700;
}

.nav-item.active svg {
  color: #059669;
}

.nav-counter {
  margin-left: auto;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: var(--radius-full);
  background: #e2e8f0;
  color: #475569;
  transition: var(--transition);
}

.nav-item.active .nav-counter {
  background: #059669;
  color: #ffffff;
}

.sidebar-footer {
  padding: 16px;
  border-top: 1px solid var(--border-color);
  background: #fafbfc;
}

.btn-download-colab {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  width: 100%;
  padding: 10px 14px;
  border-radius: var(--radius-md);
  background: #ffffff;
  color: #0f172a;
  border: 1px solid #cbd5e1;
  font-family: var(--font-main);
  font-size: 0.84rem;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: var(--transition);
}

.btn-download-colab:hover {
  background: #ecfdf5;
  border-color: #059669;
  color: #047857;
  box-shadow: var(--shadow-hover);
  transform: translateY(-1px);
}

.btn-download-colab svg {
  color: #059669;
}

/* Área de Trabajo Principal */
.main-workspace {
  flex: 1;
  min-width: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background-color: var(--bg-body);
}

/* Topbar Superior */
.topbar {
  height: 72px;
  min-height: 72px;
  background: #ffffff;
  border-bottom: 1px solid var(--border-color);
  padding: 0 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.03);
  z-index: 50;
}

.topbar-title {
  font-size: 1.22rem;
  font-weight: 800;
  color: #0f172a;
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.topbar-subtitle {
  font-size: 0.8rem;
  color: var(--text-dim);
  margin-top: 2px;
}

.topbar-badge-status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  color: #15803d;
  font-size: 0.78rem;
  font-weight: 700;
  padding: 6px 12px;
  border-radius: var(--radius-full);
}

.status-indicator {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: #22c55e;
  box-shadow: 0 0 0 2px rgba(34, 197, 94, 0.25);
}

/* Contenedor Scrollable del Contenido */
.content-scrollable {
  flex: 1;
  overflow-y: auto;
  padding: 24px 32px 48px;
}

/* Control de Vistas (SPA) */
.view-panel {
  display: none;
  animation: fadeIn 0.22s ease-in-out;
}

.view-panel.active {
  display: block;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.container {
  width: 100%;
  max-width: 1240px;
  margin: 0 auto;
  position: relative;
}

.brand-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: #ecfdf5;
  border: 1px solid #a7f3d0;
  color: #047857;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: var(--radius-full);
  letter-spacing: 0.3px;
  text-transform: uppercase;
}

.badge-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background-color: #059669;
}

/* Botones */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-main);
  font-size: 0.86rem;
  font-weight: 600;
  padding: 9px 16px;
  border-radius: var(--radius-md);
  text-decoration: none;
  cursor: pointer;
  transition: var(--transition);
}

.btn-primary {
  background: #059669;
  color: #ffffff;
  border: 1px solid #047857;
  box-shadow: var(--shadow-sm);
}

.btn-primary:hover {
  background: #047857;
  transform: translateY(-1px);
}

.btn-outline {
  background: #ffffff;
  color: var(--text-main);
  border: 1px solid var(--border-color);
}

.btn-outline:hover {
  background: var(--bg-elevated);
  border-color: var(--border-hover);
  transform: translateY(-1px);
}

/* Presets Bar */
.presets-section {
  margin: 24px 0 20px;
}

.section-tag {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 1.2px;
  color: var(--text-dim);
  margin-bottom: 10px;
}

.presets-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 12px;
}

.preset-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  text-align: left;
  cursor: pointer;
  transition: var(--transition);
  box-shadow: var(--shadow-sm);
}

.preset-card:hover {
  border-color: #cbd5e1;
  box-shadow: var(--shadow-hover);
  transform: translateY(-2px);
}

.preset-card.active {
  border-color: #059669;
  border-width: 2px;
  background: #f0fdf4;
  box-shadow: 0 0 0 1px #059669, var(--shadow-sm);
}

.preset-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}

.preset-pill {
  font-size: 0.68rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: var(--radius-sm);
  text-transform: uppercase;
}

.pill-danger  { background: #fee2e2; color: #b91c1c; border: 1px solid #fca5a5; }
.pill-warning { background: #fef3c7; color: #b45309; border: 1px solid #fde68a; }
.pill-success { background: #dcfce7; color: #15803d; border: 1px solid #86efac; }
.pill-purple  { background: #f3e8ff; color: #7e22ce; border: 1px solid #d8b4fe; }

.preset-type {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--text-main);
}

.preset-desc {
  font-size: 0.8rem;
  color: var(--text-muted);
  line-height: 1.35;
  margin-bottom: 6px;
}

.preset-meta {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--text-dim);
}

/* Dashboard Grid */
.dashboard-grid {
  display: grid;
  grid-template-columns: 1fr 1.15fr;
  gap: 22px;
  margin-bottom: 30px;
}

@media (max-width: 960px) {
  .dashboard-grid {
    grid-template-columns: 1fr;
  }
}

/* Tarjetas */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  overflow: hidden;
}

.card-header {
  padding: 18px 22px;
  border-bottom: 1px solid var(--border-color);
  background: #ffffff;
}

.card-title-group {
  display: flex;
  align-items: center;
  gap: 12px;
}

.icon-circle {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.icon-input {
  background: #eff6ff;
  color: #2563eb;
  border: 1px solid #bfdbfe;
}

.icon-output {
  background: #ecfdf5;
  color: #059669;
  border: 1px solid #a7f3d0;
}

.icon-docs {
  background: #f5f3ff;
  color: #7c3aed;
  border: 1px solid #ddd6fe;
}

.card-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-main);
}

.card-subtitle {
  font-size: 0.8rem;
  color: var(--text-dim);
}

.card-body {
  padding: 22px;
}

/* Entradas */
.input-group {
  margin-bottom: 16px;
}

.input-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 8px;
}

.input-label {
  font-size: 0.9rem;
  color: var(--text-main);
}

.label-formula {
  font-size: 0.76rem;
  color: var(--text-dim);
  margin-left: 4px;
}

.input-value-badge {
  font-family: var(--font-mono);
  font-size: 0.9rem;
  font-weight: 700;
  background: #f1f5f9;
  border: 1px solid #cbd5e1;
  padding: 2px 9px;
  border-radius: var(--radius-sm);
  color: #0f172a;
}

/* Slider Personalizado */
.custom-range {
  width: 100%;
  height: 6px;
  background: #e2e8f0;
  border-radius: var(--radius-full);
  outline: none;
  -webkit-appearance: none;
  cursor: pointer;
  margin: 6px 0;
}

.custom-range::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #059669;
  cursor: pointer;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
  border: 2px solid #ffffff;
  transition: transform 0.1s ease;
}

.custom-range::-webkit-slider-thumb:hover {
  transform: scale(1.15);
}

.range-marks {
  display: flex;
  justify-content: space-between;
  font-size: 0.7rem;
  color: var(--text-dim);
  margin-bottom: 8px;
}

/* Etiquetas de Membresía */
.membership-tags {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
}

.mf-tag {
  font-size: 0.74rem;
  padding: 2px 7px;
  border-radius: var(--radius-sm);
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  color: var(--text-dim);
  transition: var(--transition);
}

.mf-tag.active {
  background: #ecfdf5;
  border-color: #6ee7b7;
  color: #047857;
  font-weight: 600;
}

.separator {
  border: none;
  border-top: 1px solid #f1f5f9;
  margin: 16px 0;
}

/* Mini Gráficos SVG */
.mini-chart {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: var(--radius-sm);
  padding: 4px;
}

.mini-chart svg {
  width: 100%;
  height: 80px;
  display: block;
}

/* Desglose de Privaciones */
.privations-collapse {
  margin-top: 10px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  font-size: 0.8rem;
}

.privations-collapse summary {
  cursor: pointer;
  color: #2563eb;
  font-weight: 600;
}

.privations-checklist {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-top: 8px;
  padding-left: 2px;
}

.privations-checklist label {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-muted);
  cursor: pointer;
}

.privations-checklist input[type="checkbox"] {
  accent-color: #059669;
  width: 15px;
  height: 15px;
}

/* Resultado: Hero Banner */
.result-banner {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: var(--radius-md);
  padding: 20px;
  margin-bottom: 18px;
  display: grid;
  grid-template-columns: 1fr 1.3fr;
  gap: 20px;
  align-items: center;
  box-shadow: var(--shadow-sm);
}

@media (max-width: 640px) {
  .result-banner {
    grid-template-columns: 1fr;
  }
}

.result-caption {
  font-size: 0.7rem;
  letter-spacing: 0.8px;
  color: var(--text-dim);
  font-weight: 700;
}

.result-metric {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin: 2px 0 6px;
}

.metric-number {
  font-family: var(--font-mono);
  font-size: 2.8rem;
  font-weight: 800;
  color: #0f172a;
  line-height: 1;
}

.metric-unit {
  font-size: 0.82rem;
  color: var(--text-dim);
}

.result-cog-sub {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.75rem;
  color: var(--text-dim);
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
  font-family: var(--font-mono);
}

.cog-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #2563eb;
}

.category-badge {
  display: inline-block;
  padding: 4px 12px;
  border-radius: var(--radius-full);
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.badge-urgente { background: #fee2e2; color: #991b1b; border: 1px solid #f87171; }
.badge-alta    { background: #fef3c7; color: #92400e; border: 1px solid #fcd34d; }
.badge-media   { background: #dbeafe; color: #1e40af; border: 1px solid #93c5fd; }
.badge-baja    { background: #dcfce7; color: #166534; border: 1px solid #86efac; }

.result-policy-box {
  background: #f8fafc;
  border-left: 3px solid #059669;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  padding: 12px 14px;
  border-top: 1px solid #e2e8f0;
  border-right: 1px solid #e2e8f0;
  border-bottom: 1px solid #e2e8f0;
}

.policy-title {
  font-size: 0.72rem;
  font-weight: 700;
  color: #047857;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  display: block;
  margin-bottom: 4px;
}

.policy-text {
  font-size: 0.85rem;
  color: var(--text-muted);
  line-height: 1.45;
}

/* Comparación CLIPS vs Mamdani */
.comparison-box {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: var(--radius-md);
  padding: 12px 16px;
  margin-bottom: 20px;
  gap: 12px;
}

.comp-col {
  flex: 1;
}

.comp-label {
  font-size: 0.7rem;
  color: var(--text-dim);
  display: block;
  margin-bottom: 3px;
}

.comp-value {
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--text-muted);
}

.comp-highlight {
  color: #047857;
}

.comp-vs {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 800;
  color: var(--text-dim);
  padding: 3px 8px;
  background: #e2e8f0;
  border-radius: var(--radius-sm);
}

/* Sección de Desfuzificación y Gráfica */
.defuzz-section {
  margin-bottom: 20px;
}

.defuzz-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.section-subtitle {
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--text-main);
}

.defuzz-formula {
  font-family: var(--font-mono);
  font-size: 0.76rem;
  color: var(--text-dim);
}

.large-chart {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: var(--radius-md);
  padding: 10px;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.02);
}

.large-chart svg {
  width: 100%;
  height: 180px;
  display: block;
}

.chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  font-size: 0.74rem;
  color: var(--text-muted);
  margin-top: 8px;
  justify-content: center;
}

.leg-item {
  display: flex;
  align-items: center;
  gap: 5px;
}

.leg-box {
  width: 11px;
  height: 11px;
  border-radius: 2px;
}

.leg-baja { background: #2563eb; }
.leg-media { background: #059669; }
.leg-alta { background: #d97706; }
.leg-urgente { background: #dc2626; }
.leg-line {
  width: 13px;
  height: 3px;
}
.leg-cog { background: #0f172a; }

/* Tabla de Reglas */
.rules-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.rules-count-pill {
  font-size: 0.72rem;
  background: #ecfdf5;
  border: 1px solid #a7f3d0;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  color: #047857;
  font-weight: 600;
}

.rules-table-wrapper {
  max-height: 180px;
  overflow-y: auto;
  border: 1px solid #e2e8f0;
  border-radius: var(--radius-sm);
  background: #ffffff;
}

.rules-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.78rem;
  text-align: left;
}

.rules-table th {
  background: #f8fafc;
  padding: 7px 10px;
  color: var(--text-dim);
  font-weight: 600;
  border-bottom: 1px solid #e2e8f0;
  position: sticky;
  top: 0;
}

.rules-table td {
  padding: 7px 10px;
  border-bottom: 1px solid #f1f5f9;
  color: var(--text-muted);
}

.rules-table tr:hover {
  background: #f8fafc;
}

.rule-id {
  font-family: var(--font-mono);
  font-weight: 700;
  color: #2563eb;
}

.rule-alpha {
  font-family: var(--font-mono);
  font-weight: 700;
  color: #059669;
}

/* Marco Teórico */
.docs-section {
  margin-bottom: 36px;
}

.docs-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(270px, 1fr));
  gap: 16px;
}

.doc-card {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: var(--radius-md);
  padding: 16px;
  box-shadow: var(--shadow-sm);
}

.doc-title {
  font-size: 0.92rem;
  font-weight: 700;
  color: #0f172a;
  margin-bottom: 8px;
  border-bottom: 2px solid #ecfdf5;
  padding-bottom: 4px;
}

.doc-card p {
  font-size: 0.83rem;
  color: var(--text-muted);
  line-height: 1.5;
  margin-bottom: 8px;
}

.doc-list {
  padding-left: 16px;
  font-size: 0.82rem;
  color: var(--text-muted);
  line-height: 1.55;
}

.doc-list code {
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
  padding: 1px 4px;
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: #0f172a;
}

/* Footer */
.app-footer {
  border-top: 1px solid #e2e8f0;
  padding: 20px 0;
  text-align: center;
  font-size: 0.8rem;
  color: var(--text-dim);
  background: #ffffff;
}

.footer-content p {
  margin: 3px 0;
}

/* ==============================================================================
   CALCULADORAS EN LÍNEA (MONETARIA Y DEMOGRÁFICA)
   ============================================================================== */
.inline-calc-box {
  margin-top: 10px;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: var(--radius-sm);
  padding: 12px;
}

.calc-helper-note {
  font-size: 0.78rem;
  color: var(--text-dim);
  margin-bottom: 8px;
  line-height: 1.4;
}

.calc-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 8px;
}

.calc-grid-3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
  margin-bottom: 8px;
}

.calc-col label {
  display: block;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.calc-col input[type="number"] {
  width: 100%;
  padding: 6px 8px;
  border: 1px solid #cbd5e1;
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 0.82rem;
  color: #0f172a;
  background: #f8fafc;
  outline: none;
  transition: var(--transition);
}

.calc-col input[type="number"]:focus {
  border-color: #059669;
  background: #ffffff;
}

.calc-badge-res {
  background: #f1f5f9;
  border-left: 3px solid #059669;
  padding: 6px 10px;
  border-radius: 0 4px 4px 0;
  font-size: 0.76rem;
  color: #0f172a;
}

/* ==============================================================================
   VISTAS DEDICADAS: REGLAS, HERRAMIENTAS Y MARCO TEÓRICO
   ============================================================================== */

.full-width-card {
  width: 100%;
  margin-bottom: 24px;
}

.full-filter-bar {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 20px;
  background: #f8fafc;
  padding: 16px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
}

.sidebar-search-input {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid #cbd5e1;
  border-radius: var(--radius-sm);
  font-family: var(--font-main);
  font-size: 0.88rem;
  color: #0f172a;
  outline: none;
  background: #ffffff;
  transition: var(--transition);
}

.sidebar-search-input:focus {
  border-color: #059669;
  box-shadow: 0 0 0 3px rgba(5, 150, 105, 0.12);
}

.filter-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip {
  background: #ffffff;
  border: 1px solid #cbd5e1;
  padding: 6px 12px;
  border-radius: var(--radius-full);
  font-size: 0.78rem;
  font-weight: 600;
  color: #334155;
  cursor: pointer;
  transition: var(--transition);
}

.chip:hover {
  background: #f1f5f9;
  border-color: #94a3b8;
}

.chip.active {
  background: #059669;
  color: #ffffff;
  border-color: #047857;
  box-shadow: var(--shadow-sm);
}

.chip-active-only {
  background: #ecfdf5;
  color: #047857;
  border-color: #a7f3d0;
}

.chip-active-only.active {
  background: #059669;
  color: #ffffff;
  border-color: #047857;
}

/* Grilla de 27 Reglas en Pantalla Completa */
.rules-grid-full {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 14px;
}

.sidebar-rule-item {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: var(--radius-md);
  padding: 14px 16px;
  transition: var(--transition);
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.sidebar-rule-item:hover {
  border-color: #cbd5e1;
  box-shadow: var(--shadow-hover);
}

.sidebar-rule-item.is-active {
  background: #f0fdf4;
  border-color: #86efac;
  border-left: 4px solid #059669;
  box-shadow: 0 4px 12px rgba(5, 150, 105, 0.08);
}

.s-rule-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2px;
}

.s-rule-id {
  font-family: var(--font-mono);
  font-size: 0.84rem;
  font-weight: 700;
  color: #2563eb;
}

.s-rule-strength {
  font-family: var(--font-mono);
  font-size: 0.74rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  background: #e2e8f0;
  color: var(--text-dim);
}

.sidebar-rule-item.is-active .s-rule-strength {
  background: #dcfce7;
  color: #15803d;
}

.s-rule-ant {
  font-size: 0.82rem;
  color: #334155;
  line-height: 1.4;
}

.s-rule-cons {
  font-size: 0.84rem;
  font-weight: 700;
  color: #0f172a;
  margin-top: 2px;
}

/* Vista Herramientas / Auditoría */
.audit-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
  gap: 16px;
  flex-wrap: wrap;
}

.audit-note {
  font-size: 0.84rem;
  color: var(--text-muted);
}

.btn-sm {
  padding: 7px 14px;
  font-size: 0.82rem;
}

.audit-status-tag {
  font-size: 0.8rem;
  color: #059669;
  font-weight: 700;
}

.audit-preview {
  background: #0f172a;
  color: #e2e8f0;
  font-family: var(--font-mono);
  font-size: 0.82rem;
  line-height: 1.55;
  padding: 20px;
  border-radius: var(--radius-md);
  white-space: pre-wrap;
  word-break: break-all;
  max-height: 600px;
  overflow-y: auto;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.2);
}

/* Vista Marco Teórico: 3 Columnas */
.docs-grid-three {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 20px;
}

@media (max-width: 900px) {
  .app-layout {
    flex-direction: column;
    height: auto;
    overflow: visible;
  }

  .left-sidebar {
    width: 100%;
    min-width: 100%;
    height: auto;
    border-right: none;
    border-bottom: 1px solid var(--border-color);
  }

  .main-workspace {
    height: auto;
    overflow: visible;
  }

  .content-scrollable {
    overflow: visible;
    padding: 16px;
  }

  .topbar {
    padding: 0 16px;
    height: auto;
    min-height: 60px;
    flex-wrap: wrap;
    padding: 12px 16px;
  }

  .rules-grid-full, .docs-grid-three {
    grid-template-columns: 1fr;
  }
}

/* ==============================================================================
   EVALUACIÓN COMPARATIVA DUAL (SISTEMA EXPERTO VS SISTEMA DIFUSO)
   ============================================================================== */

.dual-eval-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-bottom: 24px;
}

@media (max-width: 900px) {
  .dual-eval-grid {
    grid-template-columns: 1fr;
  }
}

.eval-card {
  background: #ffffff;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  box-shadow: var(--shadow-sm);
  transition: var(--transition);
}

.eval-card:hover {
  box-shadow: var(--shadow-hover);
}

.eval-card-expert {
  border-top: 4px solid #2563eb;
}

.eval-card-fuzzy {
  border-top: 4px solid #059669;
}

.eval-card-header {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.eval-badge {
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.5px;
  padding: 3px 8px;
  border-radius: var(--radius-full);
  display: inline-block;
  width: fit-content;
}

.badge-expert-tag {
  background: #eff6ff;
  color: #1d4ed8;
  border: 1px solid #bfdbfe;
}

.badge-fuzzy-tag {
  background: #ecfdf5;
  color: #047857;
  border: 1px solid #a7f3d0;
}

.eval-card-title {
  font-size: 1.15rem;
  font-weight: 800;
  color: #0f172a;
}

.eval-status-box {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: var(--radius-sm);
  padding: 12px 14px;
}

.eval-status-label {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.eval-status-val {
  font-size: 1.3rem;
  font-weight: 800;
  margin-top: 2px;
}

.status-expert-val {
  color: #1e3a8a;
}

.eval-fuzzy-val {
  display: flex;
  align-items: center;
  gap: 10px;
}

.metric-number-inline {
  font-family: var(--font-mono);
  font-size: 1.6rem;
  font-weight: 800;
  color: #0f172a;
}

.eval-details-list {
  display: flex;
  flex-direction: column;
  gap: 7px;
  font-size: 0.82rem;
}

.eval-detail-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 4px 0;
  border-bottom: 1px dashed #e2e8f0;
  color: var(--text-muted);
}

.eval-detail-row strong {
  color: #0f172a;
  font-family: var(--font-mono);
  font-size: 0.78rem;
}

.eval-detail-row.alert-row {
  background: #fffbeb;
  padding: 4px 8px;
  border-radius: 4px;
  border: 1px solid #fde68a;
}

.eval-detail-row.alert-row strong {
  color: #b45309;
}

.eval-detail-row.highlight-row strong {
  color: #059669;
}

.eval-policy-box {
  background: #f8fafc;
  border-radius: var(--radius-sm);
  padding: 12px;
  border-left: 3px solid;
}

.policy-expert {
  border-left-color: #2563eb;
}

.policy-fuzzy {
  border-left-color: #059669;
}

.policy-tag {
  display: block;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  margin-bottom: 4px;
  color: var(--text-dim);
}

.eval-policy-box p {
  font-size: 0.82rem;
  color: var(--text-main);
  line-height: 1.45;
}

/* ==============================================================================
   VISTA DEDICADA: SISTEMA EXPERTO CLIPS
   ============================================================================== */

.expert-wm-box {
  background: #0f172a;
  border-radius: var(--radius-md);
  padding: 16px;
  margin-bottom: 24px;
  box-shadow: var(--shadow-sm);
}

.expert-wm-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  color: #e2e8f0;
}

.wm-title {
  font-size: 0.86rem;
  font-weight: 700;
}

.wm-badge {
  font-size: 0.7rem;
  font-family: var(--font-mono);
  background: #1e293b;
  color: #38bdf8;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  border: 1px solid #0284c7;
}

.expert-facts-terminal {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: #a7f3d0;
  line-height: 1.6;
  max-height: 220px;
  overflow-y: auto;
  padding: 8px 12px;
  background: #020617;
  border-radius: var(--radius-sm);
}

.expert-layers-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 20px;
}

.expert-layer-card {
  background: #ffffff;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.layer-header {
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border-color);
}

.layer-tag {
  font-size: 0.7rem;
  font-weight: 800;
  padding: 2px 6px;
  border-radius: 4px;
  font-family: var(--font-mono);
}

.layer-capa1 .layer-tag {
  background: #dbeafe;
  color: #1e40af;
}

.layer-capa2 .layer-tag {
  background: #fef3c7;
  color: #92400e;
}

.layer-capa3 .layer-tag {
  background: #dcfce7;
  color: #166534;
}

.layer-header h4 {
  font-size: 1rem;
  font-weight: 800;
  color: #0f172a;
  margin-top: 4px;
}

.layer-desc {
  font-size: 0.82rem;
  color: var(--text-muted);
  line-height: 1.45;
}

.layer-rules-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 4px;
}

.exp-rule-item {
  font-size: 0.78rem;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  color: #334155;
}

.exp-rule-item code {
  font-family: var(--font-mono);
  font-weight: 700;
  color: #2563eb;
}
