:root {
  --bg-page: #0a0e17;
  --bg-card: #111827;
  --bg-card-hover: #172033;
  --bg-option: #151d2f;
  --bg-option-hover: #1c273e;
  --bg-option-selected: rgba(59, 130, 246, 0.15);
  --border-color: #1f2937;
  --border-focus: #3b82f6;
  --border-selected: #3b82f6;
  --text-primary: #f3f4f6;
  --text-secondary: #9ca3af;
  --text-muted: #6b7280;
  --primary: #3b82f6;
  --primary-hover: #2563eb;
  --primary-glow: rgba(59, 130, 246, 0.25);
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-full: 9999px;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 12px 30px rgba(0, 0, 0, 0.5);
  --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

[data-theme="light"] {
  --bg-page: #f8fafc;
  --bg-card: #ffffff;
  --bg-card-hover: #f1f5f9;
  --bg-option: #f8fafc;
  --bg-option-hover: #f1f5f9;
  --bg-option-selected: rgba(37, 99, 235, 0.08);
  --border-color: #e2e8f0;
  --border-focus: #2563eb;
  --border-selected: #2563eb;
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #64748b;
  --primary-glow: rgba(37, 99, 235, 0.15);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 12px 30px rgba(0, 0, 0, 0.1);
}

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

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background-color: var(--bg-page);
  color: var(--text-primary);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: clip;
  width: 100%;
  max-width: 100%;
}

h1, h2, h3, h4, h5, h6 {
  font-family: 'Outfit', sans-serif;
  font-weight: 700;
  letter-spacing: -0.02em;
}

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

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

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

/* Tarjeta principal con ancho enfocado (860px) para máxima legibilidad ergonómica */
.card-main {
  max-width: 860px;
  margin: 0 auto 2.5rem;
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 2rem;
  box-shadow: var(--shadow-md);
}

@media (max-width: 768px) {
  .card-main {
    padding: 1.25rem;
  }
}

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

.badge-tag {
  display: inline-flex;
  align-items: center;
  padding: 0.35rem 0.85rem;
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background-color: rgba(59, 130, 246, 0.15);
  color: var(--primary);
}

.badge-privacy {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.test-intro {
  font-size: 0.95rem;
  line-height: 1.6;
  color: var(--text-secondary);
  margin-bottom: 1.5rem;
}

/* Presets con chips */
.presets-container {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
}

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

.presets-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.btn-preset-chip {
  background-color: var(--bg-option);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  font-size: 0.8rem;
  font-weight: 500;
  padding: 0.45rem 0.85rem;
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: var(--transition);
  display: inline-flex;
  align-items: center;
}

.btn-preset-chip:hover {
  background-color: var(--bg-card-hover);
  border-color: var(--primary);
  color: var(--text-primary);
}

.btn-preset-chip.is-active {
  background-color: rgba(59, 130, 246, 0.15);
  border-color: var(--primary);
  color: var(--primary);
  font-weight: 600;
}

/* Barra de puntuación acumulada en vivo */
.live-score-card {
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.1) 0%, rgba(59, 130, 246, 0.02) 100%);
  border: 1px solid rgba(59, 130, 246, 0.3);
  border-radius: var(--radius-md);
  padding: 1rem 1.25rem;
  margin-bottom: 2rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.live-score-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.live-score-left {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
}

.live-score-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.live-score-num {
  font-family: 'JetBrains Mono', monospace;
  font-size: 1.75rem;
  font-weight: 800;
  color: var(--primary);
  line-height: 1;
}

.live-score-max {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.progress-info-text {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.progress-track {
  height: 8px;
  background-color: var(--border-color);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #3b82f6, #60a5fa);
  border-radius: var(--radius-full);
  transition: width 0.3s ease;
}

/* Grupos de preguntas */
.ipss-form {
  display: flex;
  flex-direction: column;
  gap: 1.75rem;
}

.question-group {
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.5rem;
  background-color: var(--bg-card);
  transition: var(--transition);
}

.question-group.is-answered {
  border-color: rgba(16, 185, 129, 0.4);
}

.question-group.q-quality {
  border-color: rgba(245, 158, 11, 0.4);
  background: linear-gradient(180deg, rgba(245, 158, 11, 0.04) 0%, transparent 100%);
}

.question-title {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-primary);
  padding: 0 0.5rem;
}

.q-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: var(--radius-full);
  background-color: var(--primary);
  color: #ffffff;
  font-size: 0.85rem;
  font-family: 'JetBrains Mono', monospace;
  font-weight: 700;
}

.q-num-qol {
  background-color: var(--warning);
  color: #111827;
  font-size: 0.75rem;
  width: 36px;
}

.question-desc {
  font-size: 0.9rem;
  color: var(--text-secondary);
  line-height: 1.5;
  margin: 0.75rem 0 1.25rem;
}

/* Cuadrícula de opciones */
.options-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.75rem;
}

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

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

.options-qol {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

@media (max-width: 700px) {
  .options-qol {
    grid-template-columns: 1fr;
  }
}

.option-card {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background-color: var(--bg-option);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0.85rem 1rem;
  cursor: pointer;
  min-height: 48px;
  transition: var(--transition);
  user-select: none;
}

.option-card:hover {
  background-color: var(--bg-option-hover);
  border-color: var(--border-selected);
}

.option-card input[type="radio"] {
  accent-color: var(--primary);
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.option-card.is-selected {
  background-color: var(--bg-option-selected);
  border-color: var(--border-selected);
  box-shadow: 0 0 0 1px var(--border-selected);
}

.option-card span {
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--text-primary);
  line-height: 1.3;
}

/* Botones de acción */
.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  margin-top: 1rem;
}

.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
  color: #ffffff;
  font-weight: 600;
  font-size: 0.95rem;
  padding: 0.85rem 1.75rem;
  border-radius: var(--radius-md);
  border: none;
  cursor: pointer;
  box-shadow: 0 4px 14px var(--primary-glow);
  transition: var(--transition);
  min-height: 48px;
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(59, 130, 246, 0.4);
}

.btn-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background-color: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border-color);
  font-weight: 500;
  font-size: 0.9rem;
  padding: 0.85rem 1.25rem;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: var(--transition);
  min-height: 48px;
}

.btn-secondary:hover {
  background-color: var(--bg-card-hover);
  color: var(--text-primary);
  border-color: var(--border-selected);
}

@media (max-width: 640px) {
  .btn-primary, .btn-secondary {
    width: 100%;
  }
}

/* Resultados IPSS */
.results-container {
  margin-top: 2.5rem;
  padding-top: 2rem;
  border-top: 1px dashed var(--border-color);
  animation: fadeIn 0.4s ease-out;
}

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

.results-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.results-title {
  font-size: 1.35rem;
  color: var(--text-primary);
}

.badge-status {
  padding: 0.35rem 0.85rem;
  border-radius: var(--radius-full);
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  display: inline-flex;
  align-items: center;
}

.badge-mild {
  background-color: rgba(16, 185, 129, 0.15);
  color: var(--success);
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.badge-moderate {
  background-color: rgba(245, 158, 11, 0.15);
  color: var(--warning);
  border: 1px solid rgba(245, 158, 11, 0.3);
}

.badge-severe {
  background-color: rgba(239, 68, 68, 0.15);
  color: var(--danger);
  border: 1px solid rgba(239, 68, 68, 0.3);
}

/* Métricas numéricas */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

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

.metric-card {
  background-color: var(--bg-card-hover);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.metric-card.metric-primary {
  border-color: rgba(59, 130, 246, 0.4);
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.1) 0%, rgba(59, 130, 246, 0.02) 100%);
}

.metric-label {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-primary);
}

.metric-subtag {
  font-size: 0.72rem;
  font-weight: 500;
  color: var(--text-secondary);
}

.metric-value-box {
  display: flex;
  align-items: baseline;
  gap: 0.35rem;
}

.metric-num {
  font-family: 'JetBrains Mono', monospace;
  font-size: 2.2rem;
  font-weight: 800;
  color: var(--text-primary);
  line-height: 1;
}

.metric-primary .metric-num {
  color: var(--primary);
}

.metric-unit {
  font-family: 'JetBrains Mono', monospace;
  font-size: 1rem;
  color: var(--text-secondary);
}

.metric-secondary-val {
  font-size: 0.8rem;
  color: var(--text-secondary);
  line-height: 1.4;
}

/* Tarjeta QoL */
.qol-result-card {
  background-color: var(--bg-card-hover);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  margin-bottom: 1.5rem;
}

.qol-result-header {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 0.4rem;
}

.qol-pill {
  padding: 0.2rem 0.55rem;
  background-color: var(--warning);
  color: #111827;
  font-size: 0.72rem;
  font-weight: 800;
  border-radius: var(--radius-sm);
}

.qol-result-title {
  font-size: 0.98rem;
  color: var(--text-primary);
}

.qol-result-desc {
  font-size: 0.9rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

/* Conducta clínica */
.clinical-assessment-card {
  background-color: var(--bg-card-hover);
  border-left: 4px solid var(--primary);
  border-radius: var(--radius-sm);
  padding: 1.25rem;
  margin-bottom: 1.5rem;
}

.assessment-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--primary);
  margin-bottom: 0.5rem;
}

.assessment-title {
  font-size: 1.05rem;
  color: var(--text-primary);
}

.assessment-text {
  font-size: 0.92rem;
  line-height: 1.6;
  color: var(--text-secondary);
}

.assessment-text strong {
  color: var(--text-primary);
}

/* Acciones finales */
.result-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.btn-action-outline {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background-color: transparent;
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  padding: 0.65rem 1.2rem;
  border-radius: var(--radius-md);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  min-height: 40px;
}

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

@media (max-width: 640px) {
  .btn-action-outline {
    width: 100%;
    justify-content: center;
  }
}

/* GUÍA MÉDICA EDITORIAL CANÓNICA (2 Columnas + Full-width Table + Callouts) */
.seo-guide-section {
  max-width: 860px;
  margin: 3rem auto 0;
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

.seo-guide-header {
  text-align: center;
  max-width: 780px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.seo-guide-badge {
  display: inline-flex;
  align-self: center;
  padding: 0.35rem 0.85rem;
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background-color: rgba(59, 130, 246, 0.15);
  color: var(--primary);
}

.seo-guide-title {
  font-size: 1.75rem;
  color: var(--text-primary);
  line-height: 1.3;
}

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

.seo-guide-subtitle {
  font-size: 0.95rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

.seo-editorial-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1.5rem;
}

@media (max-width: 800px) {
  .seo-editorial-grid {
    grid-template-columns: 1fr;
  }
}

.seo-editorial-card {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.75rem;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.seo-editorial-card h3 {
  font-size: 1.15rem;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  line-height: 1.35;
}

.seo-editorial-card h3 svg {
  color: var(--primary);
  flex-shrink: 0;
}

.seo-editorial-card p {
  font-size: 0.92rem;
  line-height: 1.6;
  color: var(--text-secondary);
}

.seo-bullet-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  padding-left: 0.25rem;
}

.seo-bullet-list li {
  font-size: 0.88rem;
  line-height: 1.55;
  color: var(--text-secondary);
  position: relative;
  padding-left: 1.25rem;
}

.seo-bullet-list li::before {
  content: "•";
  color: var(--primary);
  font-weight: bold;
  font-size: 1.2rem;
  position: absolute;
  left: 0;
  top: -2px;
}

.seo-bullet-list strong {
  color: var(--text-primary);
}

.seo-callout-card {
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.08) 0%, rgba(59, 130, 246, 0.02) 100%);
  border: 1px solid rgba(59, 130, 246, 0.3);
  border-radius: var(--radius-lg);
  padding: 1.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.seo-callout-card.seo-callout-alert {
  background: linear-gradient(135deg, rgba(239, 68, 68, 0.08) 0%, rgba(239, 68, 68, 0.02) 100%);
  border-color: rgba(239, 68, 68, 0.3);
}

.seo-callout-card.seo-callout-alert h3 {
  color: var(--danger);
}

.seo-callout-card.seo-callout-alert .seo-bullet-list li::before {
  color: var(--danger);
}

.seo-callout-card h3 {
  font-size: 1.15rem;
  color: var(--primary);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.seo-callout-card p {
  font-size: 0.92rem;
  line-height: 1.6;
  color: var(--text-secondary);
}

.seo-callout-card strong {
  color: var(--text-primary);
}

/* TABLA AL 100 % ANCHO */
.seo-table-section {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.75rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.seo-table-header {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.seo-table-title {
  font-size: 1.2rem;
  color: var(--text-primary);
}

.seo-table-sub {
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.seo-table-wrapper {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
}

.seo-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
  min-width: 620px;
}

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

.seo-table th {
  background-color: var(--bg-card-hover);
  color: var(--text-primary);
  font-family: 'Outfit', sans-serif;
  font-weight: 600;
  font-size: 0.85rem;
}

.seo-table td {
  color: var(--text-secondary);
  font-size: 0.85rem;
  line-height: 1.45;
}

.seo-table td:first-child {
  font-family: 'JetBrains Mono', monospace;
  font-weight: 700;
  color: var(--text-primary);
}

.seo-table tr:last-child td {
  border-bottom: none;
}

.seo-table tbody tr:hover {
  background-color: var(--bg-card-hover);
}

/* Modales canónicos */
.app-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}

.app-modal.is-active {
  display: flex;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background-color: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
}

.modal-window {
  position: relative;
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  max-width: 500px;
  width: 100%;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  z-index: 10;
  animation: modalIn 0.25s ease-out;
}

@keyframes modalIn {
  from { opacity: 0; transform: scale(0.95); }
  to { opacity: 1; transform: scale(1); }
}

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

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

.btn-close-modal {
  background: none;
  border: none;
  font-size: 1.6rem;
  line-height: 1;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 0 0.5rem;
}

.modal-body {
  padding: 1.5rem;
  font-size: 0.92rem;
  line-height: 1.6;
  color: var(--text-secondary);
}

.modal-footer {
  padding: 1rem 1.5rem;
  background-color: var(--bg-card-hover);
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: flex-end;
}
