/**
 * Optimizador de Potencia Contratada y Luz Datadis - Estilos Canónicos
 * Fijate Tools
 */

:root {
  --font-main: 'Inter', system-ui, -apple-system, sans-serif;
  --font-heading: 'Outfit', 'Inter', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;

  /* Colores base - Tema Claro */
  --bg-app: #f8fafc;
  --bg-card: #ffffff;
  --bg-subtle: #f1f5f9;
  --bg-input: #ffffff;
  --border-color: #e2e8f0;
  --border-focus: #0284c7;

  --text-main: #0f172a;
  --text-muted: #475569;
  --text-subtle: #64748b;

  --primary: #0284c7;
  --primary-hover: #0369a1;
  --primary-light: #e0f2fe;

  --accent-amber: #d97706;
  --accent-amber-light: #fef3c7;

  --accent-green: #059669;
  --accent-green-light: #d1fae5;

  --accent-red: #dc2626;
  --accent-red-light: #fee2e2;

  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1);

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-full: 9999px;
}

[data-theme="dark"] {
  --bg-app: #0b0f17;
  --bg-card: #131b26;
  --bg-subtle: #1a2434;
  --bg-input: #101722;
  --border-color: #243247;
  --border-focus: #38bdf8;

  --text-main: #f1f5f9;
  --text-muted: #94a3b8;
  --text-subtle: #64748b;

  --primary: #38bdf8;
  --primary-hover: #0ea5e9;
  --primary-light: rgba(56, 189, 248, 0.12);

  --accent-amber: #fbbf24;
  --accent-amber-light: rgba(251, 191, 36, 0.12);

  --accent-green: #34d399;
  --accent-green-light: rgba(52, 211, 153, 0.12);

  --accent-red: #f87171;
  --accent-red-light: rgba(248, 113, 113, 0.12);

  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.4);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.5);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.6);
}

/* Reset y estructura global */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-main);
  background-color: var(--bg-app);
  color: var(--text-main);
  line-height: 1.5;
  overflow-x: clip;
  width: 100%;
  max-width: 100%;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

h1, h2, h3, h4, h5, h6,
.brand-title,
.hero-title,
.section-subtitle,
.chart-title,
.sim-title,
.icp-title,
.letter-title,
.faq-section-title {
  font-family: var(--font-heading);
  letter-spacing: -0.015em;
  font-weight: 700;
}

.text-mono {
  font-family: var(--font-mono);
}

.text-success {
  color: var(--accent-green) !important;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

/* Layout principal */
.main-wrapper.tool-layout {
  max-width: 1200px;
  width: 100%;
  margin: 1.5rem auto 3rem;
  padding: 0 1rem;
  flex: 1 0 auto;
}

.tool-with-sidebar {
  display: flex;
  gap: 1.5rem;
  align-items: flex-start;
}

.tool-main-content {
  flex: 1 1 0%;
  min-width: 0;
  width: 100%;
}

.tool-ad-sidebar {
  display: none;
  width: 300px;
  flex-shrink: 0;
}

@media (min-width: 1536px) {
  .tool-ad-sidebar {
    display: block;
  }
}

.ad-sticky-box {
  position: sticky;
  top: 1.5rem;
}

/* Tarjeta principal */
.card-main {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: 1.75rem;
  margin-top: 1rem;
}

@media (max-width: 640px) {
  .card-main {
    padding: 1rem;
    border-radius: var(--radius-md);
  }
}

/* Hero introductorio */
.hero-block {
  margin-bottom: 2rem;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 1.75rem;
}

.hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--primary-light);
  color: var(--primary);
  font-size: 0.825rem;
  font-weight: 600;
  padding: 0.35rem 0.75rem;
  border-radius: var(--radius-full);
  margin-bottom: 0.75rem;
}

.hero-title {
  font-size: 1.75rem;
  line-height: 1.25;
  color: var(--text-main);
  margin-bottom: 0.75rem;
}

@media (max-width: 640px) {
  .hero-title {
    font-size: 1.35rem;
  }
}

.hero-desc {
  font-size: 1rem;
  color: var(--text-muted);
  max-width: 860px;
  margin-bottom: 1.25rem;
}

.hero-highlights-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1rem;
  margin-top: 1.25rem;
}

@media (max-width: 768px) {
  .hero-highlights-grid {
    grid-template-columns: 1fr;
  }
}

.highlight-item {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  background: var(--bg-subtle);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0.875rem;
}

.hl-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  background: var(--primary-light);
  color: var(--primary);
  flex-shrink: 0;
}

.hl-title {
  font-size: 0.875rem;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 0.2rem;
}

.hl-text {
  font-size: 0.775rem;
  color: var(--text-muted);
  line-height: 1.4;
}

/* Tabs de método de entrada */
.input-mode-tabs {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.5rem;
  background: var(--bg-subtle);
  padding: 0.375rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  margin-bottom: 1.5rem;
}

@media (max-width: 640px) {
  .input-mode-tabs {
    grid-template-columns: 1fr;
  }
}

.tab-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-height: 44px;
  padding: 0.6rem 1rem;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-family: var(--font-main);
  font-size: 0.9rem;
  font-weight: 600;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s ease;
  width: 100%;
}

.tab-btn.active {
  background: var(--bg-card);
  color: var(--text-main);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-color);
}

.badge-tab-rec {
  background: var(--accent-green);
  color: #ffffff;
  font-size: 0.675rem;
  font-weight: 700;
  padding: 0.15rem 0.45rem;
  border-radius: var(--radius-full);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* Zona de subida CSV */
.csv-upload-container {
  border: 2px dashed var(--border-color);
  border-radius: var(--radius-lg);
  padding: 2.25rem 1.5rem;
  text-align: center;
  background: var(--bg-subtle);
  transition: all 0.2s ease;
  margin-bottom: 1.5rem;
  cursor: pointer;
}

.csv-upload-container:hover,
.csv-upload-container.dragover {
  border-color: var(--primary);
  background: var(--primary-light);
}

.csv-upload-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 64px;
  height: 64px;
  margin: 0 auto 1rem;
  border-radius: 50%;
  background: var(--bg-card);
  color: var(--primary);
  box-shadow: var(--shadow-sm);
}

.csv-upload-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 0.35rem;
}

.csv-upload-sub {
  font-size: 0.875rem;
  color: var(--text-muted);
  max-width: 580px;
  margin: 0 auto 1.25rem;
}

.csv-upload-actions {
  display: flex;
  justify-content: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}

@media (max-width: 640px) {
  .csv-upload-actions .btn {
    width: 100%;
  }
}

.privacy-note {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.775rem;
  color: var(--text-muted);
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  padding: 0.4rem 0.85rem;
  border-radius: var(--radius-full);
  margin-top: 0.5rem;
}

/* Tarjeta resumen de archivo cargado */
.file-summary-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  margin-bottom: 1.5rem;
  box-shadow: var(--shadow-sm);
}

.file-summary-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.75rem;
  padding-bottom: 0.875rem;
  margin-bottom: 0.875rem;
  border-bottom: 1px solid var(--border-color);
}

.file-summary-title-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.file-status-badge {
  background: var(--accent-green-light);
  color: var(--accent-green);
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0.2rem 0.6rem;
  border-radius: var(--radius-full);
}

.file-name-text {
  font-size: 0.85rem;
  color: var(--text-main);
  font-weight: 600;
}

.btn-text-action {
  background: transparent;
  border: none;
  color: var(--primary);
  font-size: 0.825rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: underline;
  padding: 0.25rem 0.5rem;
}

.file-stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.75rem;
}

@media (max-width: 900px) {
  .file-stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 500px) {
  .file-stats-grid {
    grid-template-columns: 1fr;
  }
}

.f-stat-item {
  background: var(--bg-subtle);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 0.75rem;
  display: flex;
  flex-direction: column;
}

.f-stat-label {
  font-size: 0.725rem;
  color: var(--text-muted);
  margin-bottom: 0.25rem;
}

.f-stat-val {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-main);
}

.f-stat-sub {
  font-size: 0.7rem;
  color: var(--text-subtle);
  margin-top: 0.2rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Panel Manual */
.section-subtitle {
  font-size: 1.15rem;
  color: var(--text-main);
  margin-bottom: 0.35rem;
}

.section-subdesc {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 1.25rem;
}

.grid-inputs-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1.25rem;
  margin-bottom: 1.5rem;
}

@media (max-width: 768px) {
  .grid-inputs-row {
    grid-template-columns: 1fr;
  }
}

.input-card {
  background: var(--bg-subtle);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.25rem;
}

.input-card-title {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 1rem;
}

.form-group-duo {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.875rem;
}

@media (max-width: 480px) {
  .form-group-duo {
    grid-template-columns: 1fr;
  }
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.form-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-main);
}

.form-hint {
  font-size: 0.725rem;
  color: var(--text-muted);
}

.form-control {
  width: 100%;
  min-height: 42px;
  padding: 0.55rem 0.85rem;
  font-size: 0.95rem;
  font-family: var(--font-main);
  color: var(--text-main);
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.form-control:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--primary-light);
}

.form-select {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  text-overflow: ellipsis;
  white-space: nowrap;
  overflow: hidden;
  padding-right: 40px;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23475569' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  cursor: pointer;
}

[data-theme="dark"] .form-select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
}

.input-with-suffix {
  display: flex;
  align-items: center;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.input-with-suffix input {
  flex: 1 1 0%;
  width: 0;
  min-width: 0;
  border: none;
  outline: none;
  padding: 0.55rem 0.75rem;
  background: transparent;
  color: var(--text-main);
  font-size: 0.95rem;
}

.input-suffix {
  padding: 0.55rem 0.75rem;
  background: var(--bg-subtle);
  color: var(--text-muted);
  font-size: 0.8rem;
  font-weight: 600;
  border-left: 1px solid var(--border-color);
}

/* Barra de opciones de confort y tarifas */
.options-bar-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1rem 1.25rem;
  margin-bottom: 2rem;
  box-shadow: var(--shadow-sm);
}

.options-row-flex {
  display: flex;
  align-items: flex-end;
  gap: 1rem;
  flex-wrap: wrap;
}

.option-item-col {
  flex: 1 1 240px;
  min-width: 0;
}

.action-btn-col {
  flex: 0 0 auto;
}

@media (max-width: 640px) {
  .action-btn-col {
    width: 100%;
  }
  .action-btn-col .btn {
    width: 100%;
  }
}

.advanced-prices-box {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px dashed var(--border-color);
}

.advanced-prices-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1rem;
}

@media (max-width: 900px) {
  .advanced-prices-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 500px) {
  .advanced-prices-grid {
    grid-template-columns: 1fr;
  }
}

/* Botones universales */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-height: 42px;
  padding: 0.6rem 1.25rem;
  font-family: var(--font-main);
  font-size: 0.875rem;
  font-weight: 600;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.15s ease;
  text-decoration: none;
}

.btn-primary {
  background: var(--primary);
  color: #ffffff;
}

.btn-primary:hover {
  background: var(--primary-hover);
}

.btn-secondary {
  background: var(--bg-subtle);
  color: var(--text-main);
  border-color: var(--border-color);
}

.btn-secondary:hover {
  background: var(--border-color);
}

.btn-secondary-outline {
  background: transparent;
  color: var(--text-main);
  border-color: var(--border-color);
}

.btn-secondary-outline:hover {
  background: var(--bg-subtle);
}

/* ==============================================
   PANEL DE RESULTADOS Y KPIS
   ============================================== */
.results-container {
  margin-top: 1.5rem;
}

.kpi-hero-grid {
  display: grid;
  grid-template-columns: 1.25fr 1.25fr 1fr;
  gap: 1.25rem;
  margin-bottom: 2rem;
}

@media (max-width: 1024px) {
  .kpi-hero-grid {
    grid-template-columns: 1fr;
  }
}

.kpi-card {
  background: var(--bg-subtle);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
}

.kpi-saving-card {
  background: linear-gradient(135deg, rgba(5, 150, 105, 0.08) 0%, rgba(2, 132, 199, 0.05) 100%);
  border-color: rgba(5, 150, 105, 0.3);
}

[data-theme="dark"] .kpi-saving-card {
  background: linear-gradient(135deg, rgba(52, 211, 153, 0.08) 0%, rgba(56, 189, 248, 0.05) 100%);
  border-color: rgba(52, 211, 153, 0.25);
}

.kpi-header-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.875rem;
}

.kpi-badge {
  font-size: 0.725rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0.2rem 0.6rem;
  border-radius: var(--radius-full);
  background: var(--accent-green-light);
  color: var(--accent-green);
}

.kpi-badge-teal {
  background: var(--primary-light);
  color: var(--primary);
}

.kpi-icon-circ {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-card);
  color: var(--text-main);
  box-shadow: var(--shadow-sm);
}

.kpi-main-val {
  font-size: 2.5rem;
  font-weight: 800;
  line-height: 1.1;
  color: var(--accent-green);
  margin-bottom: 0.35rem;
}

.kpi-sub-line {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 1.25rem;
}

.kpi-breakdown-row {
  display: flex;
  gap: 1rem;
  padding-top: 0.875rem;
  border-top: 1px solid var(--border-color);
  margin-top: auto;
}

.kpi-mini-item {
  flex: 1;
}

.kpi-mini-label {
  display: block;
  font-size: 0.725rem;
  color: var(--text-muted);
}

.kpi-mini-val {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-main);
}

/* Tarjeta Potencia Recomendada */
.recommended-power-row {
  display: flex;
  align-items: center;
  gap: 0.875rem;
  margin-bottom: 1rem;
}

.rec-power-box {
  flex: 1;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0.875rem 0.75rem;
  text-align: center;
}

.rec-period-label {
  display: block;
  font-size: 0.725rem;
  font-weight: 700;
  color: var(--text-muted);
  margin-bottom: 0.25rem;
}

.rec-kw-val {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--primary);
  line-height: 1.2;
}

.rec-diff-tag {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 0.15rem 0.5rem;
  border-radius: var(--radius-full);
  margin-top: 0.35rem;
  background: var(--accent-green-light);
  color: var(--accent-green);
}

.rec-divider-arrow {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-muted);
}

.rec-amort-note {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.775rem;
  color: var(--text-muted);
  background: var(--bg-card);
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  margin-top: auto;
}

/* Tarjeta Semáforo / Diagnóstico */
.status-indicator-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--accent-green);
  box-shadow: 0 0 0 3px var(--accent-green-light);
}

.status-indicator-dot.dot-critical {
  background: var(--accent-red);
  box-shadow: 0 0 0 3px var(--accent-red-light);
}

.status-indicator-dot.dot-warning {
  background: var(--accent-amber);
  box-shadow: 0 0 0 3px var(--accent-amber-light);
}

.status-title-text {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 0.35rem;
}

.status-desc-text {
  font-size: 0.825rem;
  color: var(--text-muted);
  line-height: 1.4;
  margin-bottom: 1rem;
}

.usage-meter-box {
  margin-top: auto;
}

.usage-labels-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 0.35rem;
}

.usage-bar-track {
  width: 100%;
  height: 10px;
  background: var(--border-color);
  border-radius: var(--radius-full);
  overflow: hidden;
  margin-bottom: 0.4rem;
}

.usage-bar-fill {
  height: 100%;
  background: var(--primary);
  border-radius: var(--radius-full);
  transition: width 0.4s ease;
}

.usage-hint-text {
  display: block;
  font-size: 0.7rem;
  color: var(--text-subtle);
  line-height: 1.3;
}

/* Gráfico Canvas comparativo mensual */
.chart-section-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  margin-bottom: 2rem;
  box-shadow: var(--shadow-sm);
}

.chart-header-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.chart-title {
  font-size: 1.15rem;
  color: var(--text-main);
  margin-bottom: 0.25rem;
}

.chart-subtitle {
  font-size: 0.825rem;
  color: var(--text-muted);
}

.chart-legend-box {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.legend-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 500;
}

.legend-color-box {
  width: 12px;
  height: 12px;
  border-radius: 2px;
}

.legend-color-line {
  width: 16px;
  height: 3px;
  border-radius: 1px;
}

.chip-contracted .legend-color-box { background: #94a3b8; }
.chip-peak-p1 .legend-color-box { background: #0284c7; }
.chip-peak-p2 .legend-color-box { background: #818cf8; }
.chip-recommended .legend-color-line { background: #10b981; }

.canvas-chart-wrapper {
  position: relative;
  width: 100%;
  height: 320px;
  background: var(--bg-subtle);
  border-radius: var(--radius-md);
  padding: 0.5rem;
  border: 1px solid var(--border-color);
}

.canvas-chart-wrapper canvas {
  width: 100%;
  height: 100%;
  display: block;
}

/* Simulador de electrodomésticos */
.appliance-sim-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  margin-bottom: 2rem;
  box-shadow: var(--shadow-sm);
}

.sim-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.sim-title {
  font-size: 1.15rem;
  color: var(--text-main);
  margin-bottom: 0.25rem;
}

.sim-desc {
  font-size: 0.85rem;
  color: var(--text-muted);
  max-width: 680px;
}

.sim-total-badge {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  background: var(--bg-subtle);
  border: 1px solid var(--border-color);
  padding: 0.5rem 0.875rem;
  border-radius: var(--radius-md);
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
}

.sim-kw-num {
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--primary);
}

.appliances-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}

@media (max-width: 480px) {
  .appliances-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.appliance-toggle-btn {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.75rem 0.875rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  background: var(--bg-subtle);
  color: var(--text-muted);
  cursor: pointer;
  text-align: left;
  transition: all 0.15s ease;
  user-select: none;
  min-height: 52px;
}

.appliance-toggle-btn:hover {
  border-color: var(--primary);
  background: var(--bg-card);
}

.appliance-toggle-btn.is-active {
  background: var(--primary-light);
  border-color: var(--primary);
  color: var(--text-main);
}

.app-icon-wrap {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-card);
  color: var(--primary);
  flex-shrink: 0;
}

.app-info-wrap {
  flex: 1;
  min-width: 0;
}

.app-name {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.app-kw {
  display: block;
  font-size: 0.725rem;
  font-family: var(--font-mono);
  color: var(--text-muted);
}

.sim-tolerance-box {
  background: var(--bg-subtle);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1rem 1.25rem;
  transition: all 0.25s ease;
}

.tolerance-status-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.35rem;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.tol-indicator-left {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.tol-dot-pulse {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent-green);
}

.tol-dot-pulse.warn { background: var(--accent-amber); }
.tol-dot-pulse.danger { background: var(--accent-red); }

.tol-headline {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-main);
}

.tol-ratio-tag {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-muted);
}

.tol-explanation {
  font-size: 0.825rem;
  color: var(--text-muted);
  line-height: 1.4;
}

/* Explicador ICP UNE-EN 60898 */
.icp-info-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  margin-bottom: 2rem;
  box-shadow: var(--shadow-sm);
}

.icp-header-row {
  display: flex;
  align-items: center;
  gap: 0.875rem;
  margin-bottom: 1.25rem;
}

.icp-icon {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  background: var(--primary-light);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.icp-title {
  font-size: 1.15rem;
  color: var(--text-main);
  margin-bottom: 0.2rem;
}

.icp-subtitle {
  font-size: 0.825rem;
  color: var(--text-muted);
}

.icp-steps-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1rem;
}

@media (max-width: 900px) {
  .icp-steps-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 480px) {
  .icp-steps-grid {
    grid-template-columns: 1fr;
  }
}

.icp-step-item {
  background: var(--bg-subtle);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1rem;
  display: flex;
  flex-direction: column;
}

.icp-step-badge {
  display: inline-block;
  align-self: flex-start;
  font-size: 0.725rem;
  font-weight: 700;
  background: var(--primary-light);
  color: var(--primary);
  padding: 0.2rem 0.5rem;
  border-radius: var(--radius-full);
  margin-bottom: 0.5rem;
}

.icp-step-time {
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--text-main);
  margin-bottom: 0.35rem;
}

.icp-step-text {
  font-size: 0.775rem;
  color: var(--text-muted);
  line-height: 1.4;
}

/* Escrito de solicitud para la comercializadora */
.letter-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  margin-bottom: 2rem;
  box-shadow: var(--shadow-sm);
}

.letter-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.letter-title {
  font-size: 1.15rem;
  color: var(--text-main);
  margin-bottom: 0.25rem;
}

.letter-desc {
  font-size: 0.85rem;
  color: var(--text-muted);
  max-width: 600px;
}

.letter-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

@media (max-width: 640px) {
  .letter-actions {
    width: 100%;
  }
  .letter-actions .btn {
    flex: 1;
  }
}

.letter-text-box {
  background: var(--bg-subtle);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  max-height: 280px;
  overflow-y: auto;
}

.letter-pre {
  font-size: 0.825rem;
  line-height: 1.6;
  color: var(--text-main);
  white-space: pre-wrap;
  word-break: break-word;
}

/* Tutorial de descarga de CSV */
.tutorial-section {
  margin-top: 2.5rem;
  margin-bottom: 2.5rem;
  border-top: 1px solid var(--border-color);
  padding-top: 2rem;
}

.tutorial-steps-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1.25rem;
  margin-top: 1.25rem;
}

@media (max-width: 768px) {
  .tutorial-steps-grid {
    grid-template-columns: 1fr;
  }
}

.t-step-card {
  background: var(--bg-subtle);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  position: relative;
}

.t-step-num {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--primary);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.85rem;
  margin-bottom: 0.875rem;
}

.t-step-title {
  font-size: 0.95rem;
  color: var(--text-main);
  margin-bottom: 0.5rem;
}

.t-step-text {
  font-size: 0.825rem;
  color: var(--text-muted);
  line-height: 1.5;
}

/* Acordeón FAQ */
.faq-section {
  margin-top: 2.5rem;
  margin-bottom: 2rem;
  border-top: 1px solid var(--border-color);
  padding-top: 2rem;
}

.faq-section-title {
  font-size: 1.35rem;
  color: var(--text-main);
  margin-bottom: 1.25rem;
}

.faq-accordion {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.faq-item {
  background: var(--bg-subtle);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  overflow: hidden;
  transition: all 0.15s ease;
}

.faq-item[open] {
  background: var(--bg-card);
  box-shadow: var(--shadow-sm);
}

.faq-question {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.25rem;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-main);
  cursor: pointer;
  list-style: none;
  user-select: none;
}

.faq-question::-webkit-details-marker {
  display: none;
}

.faq-chevron {
  transition: transform 0.2s ease;
  color: var(--text-muted);
  flex-shrink: 0;
}

.faq-item[open] .faq-chevron {
  transform: rotate(180deg);
}

.faq-answer {
  padding: 0 1.25rem 1.25rem;
  font-size: 0.875rem;
  color: var(--text-muted);
  line-height: 1.6;
}

/* Modal corporativo accesible */
.app-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  padding: 1rem;
}

.app-modal-dialog {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  max-width: 480px;
  width: 100%;
  box-shadow: var(--shadow-lg);
  animation: modalFadeIn 0.2s ease;
}

@keyframes modalFadeIn {
  from { opacity: 0; transform: scale(0.96); }
  to { opacity: 1; transform: scale(1); }
}

.app-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.25rem;
  border-bottom: 1px solid var(--border-color);
}

.app-modal-title {
  font-size: 1.15rem;
  color: var(--text-main);
}

.app-modal-close {
  background: transparent;
  border: none;
  font-size: 1.5rem;
  line-height: 1;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0.25rem;
}

.app-modal-body {
  padding: 1.25rem;
  font-size: 0.925rem;
  color: var(--text-muted);
  line-height: 1.5;
}

.app-modal-footer {
  padding: 1rem 1.25rem;
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: flex-end;
}

/* Estilos de impresión */
@media print {
  body {
    background: #ffffff !important;
    color: #000000 !important;
  }
  .app-header,
  .tools-ad-banner-section,
  .tool-ad-sidebar,
  .input-mode-tabs,
  .csv-upload-container,
  .options-bar-card,
  .appliances-grid,
  .letter-actions,
  .tutorial-section,
  .faq-section,
  .affiliate-showcase-section,
  .related-tools-section,
  .fijate-footer,
  #btn-browse-csv,
  #btn-load-sample,
  #btn-reset-csv {
    display: none !important;
  }
  .card-main {
    border: none !important;
    box-shadow: none !important;
    padding: 0 !important;
  }
  .letter-text-box {
    max-height: none !important;
    overflow: visible !important;
    border: 1px solid #cccccc !important;
  }
}
