/* Simulador de incapacidad permanente • Estilos duales claro/oscuro */
:root {
  --font-main: 'Inter', system-ui, -apple-system, sans-serif;
  --font-heading: 'Outfit', 'Inter', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;

  --bg-page: #f8fafc;
  --bg-card: #ffffff;
  --bg-card-subtle: #f1f5f9;
  --bg-input: #ffffff;
  --border-color: #e2e8f0;
  --border-focus: #2563eb;

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

  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-light: #eff6ff;
  --primary-border: #bfdbfe;

  --success: #059669;
  --success-light: #ecfdf5;
  --success-border: #a7f3d0;
  --success-text: #065f46;

  --warning: #d97706;
  --warning-light: #fffbeb;
  --warning-border: #fde68a;

  --danger: #dc2626;
  --danger-light: #fef2f2;
  --danger-border: #fecaca;
}

[data-theme="dark"] {
  --bg-page: #0b0f17;
  --bg-card: #131b26;
  --bg-card-subtle: #1a2434;
  --bg-input: #0f1724;
  --border-color: #233044;
  --border-focus: #60a5fa;

  --text-main: #f1f5f9;
  --text-muted: #cbd5e1;
  --text-dim: #94a3b8;

  --primary: #3b82f6;
  --primary-hover: #60a5fa;
  --primary-light: rgba(59, 130, 246, 0.16);
  --primary-border: #1e3a8a;

  --success: #34d399;
  --success-light: rgba(16, 185, 129, 0.14);
  --success-border: #065f46;
  --success-text: #a7f3d0;

  --warning: #fbbf24;
  --warning-light: rgba(245, 158, 11, 0.14);
  --warning-border: #78350f;

  --danger: #f87171;
  --danger-light: rgba(239, 68, 68, 0.14);
  --danger-border: #7f1d1d;
}

/* Blindaje obligatorio de cabecera institucional */
[data-theme="dark"] .app-header { background: #131b2e !important; border-bottom: 1px solid #1e293b !important; }
[data-theme="dark"] .brand-title { color: #f8fafc !important; }
[data-theme="light"] .app-header { background: #ffffff !important; border-bottom: 1px solid #cbd5e1 !important; }
[data-theme="light"] .brand-title { color: #0f172a !important; }

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

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

h1, h2, h3, h4, .brand-title, .guide-heading {
  font-family: var(--font-heading);
}

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

.tool-layout {
  width: 100%;
  max-width: 1200px;
  margin: 1.5rem auto 3rem;
  padding: 0 1rem;
  flex: 1 0 auto;
}

.tool-with-sidebar {
  display: flex;
  gap: 2rem;
  align-items: flex-start;
  width: 100%;
}

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

.card-main, .seo-guide-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  padding: 1.5rem;
  margin-bottom: 1.5rem;
}

/* Navegación de pestañas */
.nav-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 1rem;
  margin-bottom: 1.25rem;
}

.tab-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  min-height: 42px;
  padding: 0.6rem 1rem;
  border-radius: 10px;
  border: 1px solid var(--border-color);
  background: var(--bg-card-subtle);
  color: var(--text-muted);
  font-family: var(--font-main);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.18s ease;
}

.tab-btn:hover { color: var(--text-main); border-color: var(--primary); }
.tab-btn.active {
  background: var(--primary);
  color: #ffffff;
  border-color: var(--primary);
}

.tab-panel { display: none; }
.tab-panel.active { display: block; }

.panel-intro-card {
  background: var(--primary-light);
  border: 1px solid var(--primary-border);
  border-radius: 12px;
  padding: 1rem 1.15rem;
  margin-bottom: 1.25rem;
}

.intro-badge {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--primary);
  margin-bottom: 0.35rem;
}

.panel-intro-card p {
  margin: 0;
  font-size: 0.92rem;
  line-height: 1.5;
  color: var(--text-main);
}

.calc-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr);
  gap: 1.5rem;
  align-items: start;
}

.section-heading {
  font-size: 1.05rem;
  font-weight: 700;
  margin: 0 0 1rem;
}

.sub-heading {
  font-size: 0.95rem;
  font-weight: 700;
  margin: 1.25rem 0 0.75rem;
}

.form-group {
  margin-bottom: 0.95rem;
  min-width: 0;
}

.form-group label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 0.35rem;
}

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

.form-control {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  min-height: 42px;
  padding: 0.55rem 0.75rem;
  border-radius: 9px;
  border: 1px solid var(--border-color);
  background: var(--bg-input);
  color: var(--text-main);
  font-family: var(--font-main);
  font-size: 0.94rem;
}

select.form-control {
  color-scheme: dark light;
  appearance: none;
  padding-right: 40px;
  text-overflow: ellipsis;
  white-space: nowrap;
  overflow: hidden;
  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.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
}

select.form-control option {
  background-color: var(--bg-card);
  color: var(--text-main);
}

.form-control:focus {
  outline: none;
  border-color: var(--border-focus);
}

.field-hint {
  display: block;
  font-size: 0.76rem;
  color: var(--text-dim);
  margin-top: 0.25rem;
}

.checkbox-card {
  background: var(--bg-card-subtle);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 0.75rem 0.9rem;
}

.check-label {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  font-size: 0.86rem;
  color: var(--text-main);
  cursor: pointer;
}

.check-label input {
  width: 18px;
  height: 18px;
  margin-top: 2px;
  accent-color: var(--primary);
  flex-shrink: 0;
}

.form-range {
  width: 100%;
  accent-color: var(--primary);
}

.range-meta {
  display: flex;
  justify-content: space-between;
  font-size: 0.8rem;
  color: var(--text-dim);
}

/* KPI principal */
.hero-kpi-card {
  background: var(--bg-card-subtle);
  border: 1px solid var(--primary-border);
  border-radius: 14px;
  padding: 1.25rem;
}

.hero-kpi-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 0.65rem;
}

.kpi-badge {
  background: var(--primary);
  color: #fff;
  font-size: 0.76rem;
  font-weight: 700;
  padding: 0.25rem 0.6rem;
  border-radius: 999px;
}

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

.hero-kpi-value {
  font-size: 2.15rem;
  font-weight: 800;
  color: var(--text-main);
  line-height: 1.15;
}

.hero-kpi-value span {
  font-size: 1rem;
  font-weight: 500;
  color: var(--text-dim);
}

.hero-kpi-sub {
  margin-top: 0.45rem;
  font-size: 0.86rem;
  color: var(--text-muted);
}

.kpi-mini-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.65rem;
  margin-top: 1rem;
  padding-top: 0.9rem;
  border-top: 1px solid var(--border-color);
}

.kpi-mini {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 9px;
  padding: 0.55rem 0.65rem;
}

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

.kpi-mini-val {
  display: block;
  font-size: 0.88rem;
  font-weight: 700;
  margin-top: 0.15rem;
}

.text-success { color: var(--success); }

/* Tarjetas de los 4 grados */
.grades-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
}

.grade-card {
  background: var(--bg-card-subtle);
  border: 1px solid var(--border-color);
  border-radius: 11px;
  padding: 0.85rem;
  cursor: pointer;
  transition: border-color 0.15s ease, transform 0.15s ease;
}

.grade-card:hover { border-color: var(--primary); }
.grade-card.is-selected {
  border-color: var(--primary);
  background: var(--primary-light);
}

.grade-card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.4rem;
  margin-bottom: 0.35rem;
}

.grade-name {
  font-size: 0.84rem;
  font-weight: 700;
}

.grade-pct {
  font-size: 0.74rem;
  font-weight: 700;
  padding: 0.15rem 0.45rem;
  border-radius: 6px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
}

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

.grade-note {
  font-size: 0.75rem;
  color: var(--text-dim);
  margin-top: 0.25rem;
}

.action-bar {
  display: flex;
  gap: 0.75rem;
  margin-top: 1rem;
  flex-wrap: wrap;
}

.btn-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  min-height: 40px;
  padding: 0.5rem 0.95rem;
  border-radius: 9px;
  border: 1px solid var(--border-color);
  background: var(--bg-card-subtle);
  color: var(--text-main);
  font-family: var(--font-main);
  font-size: 0.86rem;
  font-weight: 600;
  cursor: pointer;
}

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

/* Verificador de carencia */
.verdict-card {
  border-radius: 14px;
  padding: 1.25rem;
  border: 1px solid var(--success-border);
  background: var(--success-light);
}

.verdict-card.is-fail {
  border-color: var(--danger-border);
  background: var(--danger-light);
}

.verdict-status {
  display: inline-block;
  font-size: 0.76rem;
  font-weight: 700;
  text-transform: uppercase;
  padding: 0.25rem 0.6rem;
  border-radius: 999px;
  background: var(--bg-card);
  margin-bottom: 0.6rem;
}

.verdict-card h3 {
  margin: 0 0 0.45rem;
  font-size: 1.15rem;
}

.verdict-card p {
  margin: 0 0 1rem;
  font-size: 0.9rem;
  color: var(--text-main);
}

.carencia-bar-item {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 9px;
  padding: 0.7rem 0.85rem;
  margin-top: 0.6rem;
}

.carencia-bar-top {
  display: flex;
  justify-content: space-between;
  font-size: 0.82rem;
  font-weight: 600;
  margin-bottom: 0.35rem;
}

.progress-track {
  height: 8px;
  background: var(--bg-card-subtle);
  border-radius: 999px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--success);
  border-radius: 999px;
}

.progress-fill.is-fail { background: var(--danger); }

/* Tabla */
.table-responsive {
  width: 100%;
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}

.data-table th, .data-table td {
  padding: 0.75rem 0.8rem;
  border-bottom: 1px solid var(--border-color);
  text-align: left;
}

.data-table th {
  background: var(--bg-card-subtle);
  font-weight: 700;
  color: var(--text-muted);
}

/* FAQ y guía */
.guide-heading {
  font-size: 1.2rem;
  margin: 0 0 0.75rem;
}

.seo-guide-card > p {
  color: var(--text-muted);
  font-size: 0.94rem;
  line-height: 1.6;
  margin: 0 0 1rem;
}

.faq-list {
  display: grid;
  gap: 0.65rem;
}

.faq-item {
  border: 1px solid var(--border-color);
  border-radius: 10px;
  background: var(--bg-card-subtle);
}

.faq-question {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  padding: 0.85rem 1rem;
  font-weight: 600;
  font-size: 0.92rem;
  cursor: pointer;
  list-style: none;
}

.faq-question::-webkit-details-marker { display: none; }
.faq-item[open] .faq-arrow { transform: rotate(180deg); }
.faq-arrow { transition: transform 0.2s ease; flex-shrink: 0; }

.faq-answer {
  padding: 0 1rem 0.95rem;
  color: var(--text-muted);
  font-size: 0.89rem;
  line-height: 1.55;
}

.faq-answer p { margin: 0; }

.toast-feedback {
  position: fixed;
  bottom: 1.25rem;
  right: 1.25rem;
  background: var(--text-main);
  color: var(--bg-page);
  padding: 0.7rem 1rem;
  border-radius: 10px;
  font-size: 0.86rem;
  font-weight: 600;
  z-index: 9999;
}

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

@media (max-width: 768px) {
  .form-row-2, .kpi-mini-grid, .grades-grid { grid-template-columns: 1fr; }
  .tab-btn, .btn-secondary { width: 100%; justify-content: center; }
}

@media print {
  .app-header, .tools-ad-banner-section, .tool-ad-sidebar, .nav-tabs, .action-bar, .related-tools-section, .fijate-footer {
    display: none !important;
  }
  .card-main { border: none; padding: 0; }
}
