/* ═══════════════════════════════════════════════════
   Alquimia Digital Agency · ROI Flow Optimizer
   Premium Design System v3.0 (Industrial Edition)
   ═══════════════════════════════════════════════════ */

:root {
  /* Gray palette - Slate/Navy base */
  --gray-50:  #f8fafc; --gray-100: #f1f5f9; --gray-200: #e2e8f0;
  --gray-300: #cbd5e1; --gray-400: #94a3b8; --gray-500: #64748b;
  --gray-600: #475569; --gray-700: #334155; --gray-800: #1e293b;
  --gray-900: #0f172a; --gray-950: #020617;

  --white: #ffffff;
  --bg-app: #f8fafc;

  /* Brand Palette */
  --primary: #1e293b;         /* Deep Navy */
  --secondary: #64748b;       /* Steel Gray */
  --success: #10b981;         /* Emerald Success */
  --success-dark: #059669;    
  --danger: #ef4444;          /* Brick Red */
  --danger-light: rgba(239, 68, 68, 0.08);

  /* Spacing */
  --sp-1: 4px; --sp-2: 8px; --sp-3: 12px; --sp-4: 16px;
  --sp-5: 20px; --sp-6: 24px; --sp-8: 32px; --sp-10: 40px;

  /* Radius */
  --r-sm: 6px; --r-md: 10px; --r-lg: 14px; --r-xl: 20px;

  /* Shadows */
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.1);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.05);
  --shadow-lg: 0 12px 24px rgba(0,0,0,0.08);

  /* Layout */
  --header-h: 64px;
  --panel-left-w: 240px;
  --panel-right-w: 240px;
}

/* ── Global Reset ──────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: 'Inter', -apple-system, sans-serif;
  background: var(--bg-app);
  color: var(--gray-800);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ── Header ───────────────────────────────────── */
.header {
  height: var(--header-h);
  background: var(--primary);
  color: #fff;
  padding: 0 var(--sp-6);
  display: flex;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 4px 20px rgba(0,0,0,0.2);
}
.header__inner { width: 100%; display: flex; justify-content: space-between; align-items: center; }
.header__brand { display: flex; align-items: center; gap: var(--sp-4); }
.header__logo-img { height: 36px; border-radius: var(--r-sm); }
.header__title h1 { font-size: 1.1rem; font-weight: 800; letter-spacing: -0.01em; }
.header__subtitle { font-size: 0.7rem; color: var(--gray-400); font-weight: 500; text-transform: uppercase; letter-spacing: 0.05em; }

.header__actions { display: flex; align-items: center; gap: var(--sp-3); }
.header__badge { 
  font-size: 0.65rem; font-weight: 700; background: rgba(255,255,255,0.1); 
  padding: 4px 12px; border-radius: 99px; letter-spacing: 0.04em; 
}

.btn-lang {
  background: transparent; border: 1px solid rgba(255,255,255,0.2); color: #fff;
  padding: 4px 8px; font-size: 0.75rem; font-weight: 700; cursor: pointer;
  border-radius: var(--r-sm); transition: all 0.2s;
}
.btn-lang:hover { background: rgba(255,255,255,0.1); border-color: rgba(255,255,255,0.4); }

.btn-icon {
  background: transparent; border: none; color: #fff; font-size: 1.2rem; cursor: pointer;
  transition: transform 0.2s;
}
.btn-icon:hover { transform: scale(1.1); }

/* ── Main Layout ──────────────────────────────── */
.main-grid {
  display: grid;
  grid-template-columns: var(--panel-left-w) 1fr var(--panel-right-w);
  height: calc(100vh - var(--header-h));
  transition: grid-template-columns 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.main-grid.left-collapsed { grid-template-columns: 48px 1fr var(--panel-right-w); }
.main-grid.right-collapsed { grid-template-columns: var(--panel-left-w) 1fr 48px; }

/* Panels */
.panel {
  background: #fff;
  border-right: 1px solid var(--gray-200);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
}
.panel--right { border-right: none; border-left: 1px solid var(--gray-200); }

.panel__header {
  padding: var(--sp-4);
  border-bottom: 1px solid var(--gray-100);
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--gray-50);
}
.panel__title { font-size: 0.75rem; font-weight: 800; text-transform: uppercase; letter-spacing: 0.08em; color: var(--gray-600); }

.panel__collapse-btn {
  background: none; border: none; cursor: pointer; color: var(--gray-400); 
  padding: 4px; font-size: 0.8rem; transition: color 0.2s;
}
.panel__collapse-btn:hover { color: var(--primary); }

.main-grid.left-collapsed .panel--left .form-body,
.main-grid.left-collapsed .panel--left .panel__actions,
.main-grid.left-collapsed .panel--left .panel__header-text,
.main-grid.right-collapsed .panel--right .scenario-params,
.main-grid.right-collapsed .panel--right .panel__header-text {
  display: none;
}

.main-grid.left-collapsed .panel--left .panel__header,
.main-grid.right-collapsed .panel--right .panel__header {
  justify-content: center;
  padding: var(--sp-4) 0;
}

/* ── Roadmap (Formerly Stepper) ──────────────── */
.roadmap { display: flex; flex-direction: column; gap: 0; position: relative; padding-left: 24px; margin-top: 16px; }
.roadmap::before { 
  content: ''; position: absolute; left: 7px; top: 10px; bottom: 10px; 
  width: 2px; background: var(--gray-200); 
}

.roadmap-card { 
  margin-bottom: 32px; flex: 1; background: var(--white); border: 2px solid var(--gray-100); 
  border-radius: var(--r-md); padding: 24px; box-shadow: var(--shadow-sm);
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1); position: relative; overflow: hidden;
}
.roadmap-step:last-child .roadmap-card { margin-bottom: 0; }
.roadmap-card:hover { border-color: var(--primary); transform: translateX(8px); box-shadow: var(--shadow-md); }

.roadmap-step--featured .roadmap-card { 
  border-color: var(--success); background: linear-gradient(135deg, rgba(16, 185, 129, 0.03) 0%, #fff 100%); 
}

.roadmap-marker { 
  position: absolute; left: -24px; top: 24px; width: 16px; height: 16px; 
  border-radius: 50%; background: var(--white); border: 2px solid var(--gray-300); 
  z-index: 2; transition: all 0.3s;
}
.roadmap-step--active .roadmap-marker { border-color: var(--primary); background: var(--primary); transform: scale(1.2); }

.card-h-badge { 
  font-size: 0.6rem; font-weight: 800; text-transform: uppercase; 
  color: var(--primary); opacity: 0.5; margin-bottom: 8px; display: block;
}

/* ── Structural Transformation Chart ────────── */
.chart-container--structural { height: 450px; margin: 32px 0; padding: 24px; background: #fff; border-radius: var(--r-md); border: 1px solid var(--gray-200); position: relative; }
.chart-legend-custom { display: flex; justify-content: center; gap: 20px; margin-top: 16px; flex-wrap: wrap; }
.legend-item { display: flex; align-items: center; gap: 8px; font-size: 0.7rem; font-weight: 700; color: var(--secondary); text-transform: uppercase; }
.legend-color { width: 12px; height: 12px; border-radius: 3px; }

/* Segment Colors */
.bg-error { background: #ef4444; }
.bg-lost { background: #f97316; }
.bg-manual { background: #94a3b8; }
.bg-recovery { background: #10b981; }
.bg-maintenance { background: #3b82f6; }
.bg-residual { background: #cbd5e1; }

/* ── Evidence Chart Cards ───────────────────── */
.chart-evidence-card { 
  background: #fff; border: 1px solid var(--gray-200); border-radius: 14px; 
  padding: 30px; margin-bottom: 32px; box-shadow: var(--shadow-sm); 
}
.chart-card-title { 
  font-size: 0.85rem; font-weight: 900; color: var(--primary); 
  text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 24px;
  border-bottom: 1px solid var(--gray-100); padding-bottom: 12px;
}


/* Inputs */
.form { display: flex; flex-direction: column; flex: 1; overflow: hidden; }
.form-body { flex: 1; overflow-y: auto; padding: var(--sp-4); }
.field { margin-bottom: var(--sp-4); }
.field__label { display: block; font-size: 0.7rem; font-weight: 700; color: var(--gray-500); margin-bottom: 6px; text-transform: uppercase; }
.field__input, .field__select {
  width: 100%; padding: 8px 12px; border: 1px solid var(--gray-200); border-radius: var(--r-sm);
  font-family: inherit; font-size: 0.85rem; font-weight: 600; outline: none; transition: border-color 0.2s;
}
.field__input:focus { border-color: var(--success); }
.field__group { display: flex; }
.field__group .field__input { border-top-right-radius: 0; border-bottom-right-radius: 0; }
.field__group .field__select { 
  border-left: none; border-top-left-radius: 0; border-bottom-left-radius: 0; 
  background: var(--gray-50); width: auto; font-size: 0.75rem;
}
.field__group .field__unit {
  border-left: none; border-top-left-radius: 0; border-bottom-left-radius: 0;
  background: var(--gray-100); width: auto; font-size: 0.85rem; font-weight: 800;
  padding: 0 12px; display: flex; align-items: center; justify-content: center;
  color: var(--secondary); border: 1px solid var(--gray-200); border-left: none;
}

.panel__actions { padding: var(--sp-4); border-top: 1px solid var(--gray-100); background: var(--gray-50); }

/* ── Buttons ──────────────────────────────────── */
.btn {
  width: 100%; padding: 12px; border-radius: var(--r-md); border: none; font-weight: 700; cursor: pointer;
  display: flex; align-items: center; justify-content: center; gap: 8px; transition: all 0.2s;
}
.btn--primary { background: var(--primary); color: #fff; }
.btn--primary:hover { background: #2d3e5a; transform: translateY(-1px); }
.btn--ghost { background: transparent; color: var(--gray-500); font-size: 1rem; margin-top: 8px; }
.btn--export { background: #fff; border: 1px solid var(--gray-200); color: var(--gray-700); font-size: 0.8rem; width: auto; padding: 8px 16px; }
.btn--export:hover { border-color: var(--primary); color: var(--primary); }

/* ── Results Area (Center) ────────────────────── */
.results-area { padding: var(--sp-8); overflow-y: auto; background: #fff; }

.section-title { font-size: 1.15rem; font-weight: 900; color: var(--primary); letter-spacing: -0.02em; margin-bottom: 24px; }
.section-divider { border: none; border-top: 1px solid var(--gray-100); margin: 32px 0; }

/* Clinical Table */
.clinical-table-container { border-radius: var(--r-lg); border: 1px solid var(--gray-200); overflow: hidden; }
.clinical-table { width: 100%; border-collapse: collapse; table-layout: fixed; }
.clinical-table thead { background: var(--primary); color: #fff; }
.clinical-table thead th { padding: 12px 16px; text-align: right; font-size: 0.65rem; font-weight: 800; letter-spacing: 0.05em; text-transform: uppercase; }
.clinical-table thead th:first-child { text-align: left; width: 25%; }
.clinical-table thead th:nth-child(2) { width: 25%; }
.clinical-table th {
  padding: 10px 12px;
  text-align: left !important;
  font-weight: 800;
  text-transform: uppercase;
  color: var(--white);
  border-bottom: 2px solid var(--gray-200);
}

.clinical-table td {
  padding: 10px 12px;
  vertical-align: middle;
  border-bottom: 1px solid var(--gray-100);
  font-size: 0.85rem;
  color: var(--gray-700);
  text-align: left !important;
  font-weight: 800 !important;
}
.clinical-table tbody td:first-child { text-align: left !important; font-weight: 800 !important; color: var(--gray-800); }
.clinical-table tbody tr:hover td { background: var(--gray-50); }

.table-group-header td { background: var(--gray-100); color: var(--secondary); font-size: 0.65rem; font-weight: 800; letter-spacing: 0.05em; padding: 10px 16px !important; }

/* KPI Cards */
.kpi-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; margin-bottom: 24px; }
.kpi-card { 
  background: #fff; border-radius: var(--r-lg); padding: 24px; border: 1px solid var(--gray-200); 
  box-shadow: var(--shadow-md); position: relative; overflow: hidden;
}
.kpi-card::before { content: ''; position: absolute; top: 0; left: 0; right: 0; height: 4px; background: var(--gray-300); }
.kpi-card--roi::before { background: var(--success); }
.kpi-card--payback::before { background: #8b5cf6; }

.kpi-card__label { font-size: 0.65rem; font-weight: 700; text-transform: uppercase; color: var(--gray-500); margin-bottom: 8px; }
.kpi-card__value { font-size: 1.6rem; font-weight: 900; color: var(--primary); letter-spacing: -0.03em; }
.kpi-card__sub { font-size: 0.75rem; color: var(--gray-400); font-weight: 500; margin-top: 4px; }
.value--negative { color: var(--danger) !important; }

/* Waterfall */
.waterfall-container { margin-bottom: 40px; }

/* Scenario Blocks */
.scenario-params { padding: var(--sp-4); overflow-y: auto; }
.sc-block { background: #fff; border: 1px solid var(--gray-200); border-radius: var(--r-md); padding: 16px; margin-bottom: 16px; }
.sc-block--featured { border-color: var(--success); background: linear-gradient(135deg, rgba(16, 185, 129, 0.02) 0%, #fff 100%); }
.sc-block__title { font-size: 0.65rem; font-weight: 800; color: var(--secondary); text-transform: uppercase; border-bottom: 1px solid var(--gray-100); padding-bottom: 8px; margin-bottom: 12px; }

.sc-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; font-size: 0.75rem; font-weight: 600; color: var(--gray-600); }
.sc-row__input-wrap { display: flex; align-items: center; background: var(--gray-50); border: 1px solid var(--gray-200); border-radius: 4px; width: 68px; padding: 2px 6px; }
.sc-row__input { width: 100%; border: none; background: transparent; font-weight: 700; text-align: right; outline: none; font-size: 0.85rem; }
.sc-row__unit { color: var(--gray-400); margin-left: 2px; }

/* ── Stepper (Execution Plan) ────────────────── */
.stepper { display: flex; flex-direction: column; gap: 0; position: relative; padding-left: 24px; margin-top: 16px; }
.stepper::before { 
  content: ''; position: absolute; left: 7px; top: 10px; bottom: 10px; 
  width: 2px; background: var(--gray-200); 
}

.step { position: relative; padding-bottom: 32px; display: flex; gap: 16px; }
.step:last-child { padding-bottom: 0; }
.step__marker { 
  position: absolute; left: -24px; top: 4px; width: 16px; height: 16px; 
  border-radius: 50%; background: var(--white); border: 2px solid var(--gray-300); 
  z-index: 2; transition: all 0.3s;
}
.step--active .step__marker { border-color: var(--primary); background: var(--primary); }
.step--featured .step__marker { border-color: var(--success); background: var(--success); }

.step__card { 
  flex: 1; background: var(--white); border: 1px solid var(--gray-200); 
  border-radius: var(--r-md); padding: 20px; box-shadow: var(--shadow-sm);
  transition: transform 0.2s, box-shadow 0.2s;
}
.step--featured .step__card { border-left: 4px solid var(--success); box-shadow: var(--shadow-md); }
.step__card:hover { transform: translateX(4px); box-shadow: var(--shadow-md); }

.step__header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 8px; }
.step__title { font-size: 0.95rem; font-weight: 800; color: var(--primary); display: flex; align-items: center; gap: 8px; }
.step__icon { font-size: 1.2rem; }
.step__badge { 
  font-size: 0.65rem; font-weight: 800; text-transform: uppercase; 
  padding: 4px 10px; border-radius: 4px; background: var(--gray-100); color: var(--gray-600);
}
.step--featured .step__badge { background: rgba(16, 185, 129, 0.1); color: var(--success-dark); }

.step__desc { font-size: 0.85rem; color: var(--gray-500); line-height: 1.5; margin-bottom: 12px; }
.step__meta { display: flex; gap: 16px; font-size: 0.8rem; font-weight: 700; color: var(--gray-700); }
.step__meta span { display: flex; align-items: center; gap: 4px; }
.step__meta i { color: var(--gray-400); font-style: normal; font-weight: 400; }

/* ── Utility Classes ─────────────────────────── */
.text-reduction { color: var(--danger); font-weight: 700; }
.text-recovery { color: var(--success); font-weight: 800; }

.table-row--savings td:nth-child(n+3) { color: var(--success); font-weight: 800; }

.btn-lang--active { 
  background: var(--primary); 
  color: #fff !important; 
  border-color: var(--primary); 
}


/* ── Benefits ─────────────────────────────────── */
.benefits-vertical { display: flex; flex-direction: column; gap: 16px; }
.benefit-card { display: flex; gap: 20px; padding: 20px; background: #fff; border: 1px solid var(--gray-200); border-radius: 12px; box-shadow: var(--shadow-sm); }
.benefit-card__icon { font-size: 1.8rem; }
.benefit-card h4 { font-size: 0.9rem; font-weight: 800; color: var(--primary); margin-bottom: 4px; }
.benefit-card p { font-size: 0.85rem; color: var(--gray-500); line-height: 1.6; }

/* ── Print ────────────────────────────────────── */
@media print {
  .header, .panel, .panel__collapse-btn, .export-bar { display: none !important; }
  .main-grid { grid-template-columns: 1fr !important; }
  .results-area { padding: 0; }
  .kpi-card { break-inside: avoid; border: 2px solid #eee; }
}

/* ── Responsive ───────────────────────────────── */
@media (max-width: 1024px) {
  .main-grid { grid-template-columns: 1fr; height: auto; }
  .panel { height: auto; border: none; border-bottom: 1px solid var(--gray-200); }
}

/* ── REPOSITORIO DE SESIONES (DRAWER) ── */
.drawer-backdrop {
  position: fixed; top: 0; left: 0; width: 100vw; height: 100vh;
  background: rgba(15,23,42,0.6); z-index: 1000;
  opacity: 0; pointer-events: none; transition: opacity 0.3s;
}
.drawer-backdrop--open { opacity: 1; pointer-events: auto; }

.drawer {
  position: fixed; top: 0; right: 0; width: 400px; height: 100vh;
  background: #fff; z-index: 1001; box-shadow: -10px 0 40px rgba(0,0,0,0.1);
  transform: translateX(100%); transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex; flex-direction: column;
}
.drawer--open { transform: translateX(0); }

.drawer__header {
  padding: 24px; border-bottom: 1px solid var(--gray-200);
  display: flex; justify-content: space-between; align-items: center;
  background: var(--gray-50);
}
.drawer__header h3 { font-size: 1.1rem; font-weight: 800; color: var(--primary); }
.btn-close {
  background: none; border: none; font-size: 1.5rem; color: var(--gray-500);
  cursor: pointer; transition: color 0.2s; padding: 0 8px; line-height: 1;
}
.btn-close:hover { color: var(--danger); }

.drawer__content {
  flex: 1; overflow-y: auto; padding: 24px; background: #fff;
}
.repo-list { list-style: none; padding: 0; margin: 0; }
.repo-item {
  padding: 16px; border: 1px solid var(--gray-200); border-radius: var(--r-md);
  margin-bottom: 12px; cursor: pointer; transition: all 0.2s;
  background: #fff; box-shadow: var(--shadow-sm);
}
.repo-item:hover { border-color: var(--primary); transform: translateY(-2px); box-shadow: var(--shadow-md); }
.repo-item__company { font-weight: 800; color: var(--primary); font-size: 0.95rem; margin-bottom: 4px; }
.repo-item__date { font-size: 0.75rem; color: var(--gray-500); }
. m a t h