:root {
  --bg-page: #0a0e17;
  --bg-card: #111827;
  --bg-card-hover: #172033;
  --bg-input: #1a2234;
  --border-color: #1f2937;
  --border-focus: #10b981;
  --text-primary: #f3f4f6;
  --text-secondary: #9ca3af;
  --text-muted: #6b7280;
  --primary: #10b981;
  --primary-hover: #059669;
  --primary-glow: rgba(16, 185, 129, 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: #f0fdf4;
  --bg-card: #ffffff;
  --bg-card-hover: #f0fdf4;
  --bg-input: #ffffff;
  --border-color: #bbf7d0;
  --border-focus: #059669;
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #64748b;
  --primary-glow: rgba(5, 150, 105, 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;
}

/* WORKSPACE EN 2 COLUMNAS (Formulario + Diagnóstico) */
.t-workspace-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1.5rem;
  align-items: stretch;
  margin-bottom: 2rem;
}

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

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

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

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

.card-section-title {
  font-size: 1.25rem;
  color: var(--text-primary);
}

.badge-group {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

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

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

.btn-text-action {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
  transition: var(--transition);
}

.btn-text-action:hover {
  color: var(--primary);
}

/* Presets con chips */
.presets-container {
  display: flex;
  flex-direction: column;
  gap: 0.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-input);
  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(16, 185, 129, 0.15);
  border-color: var(--primary);
  color: var(--primary);
  font-weight: 600;
}

/* Formularios */
.calc-form {
  display: flex;
  flex-direction: column;
  gap: 1.1rem;
}

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

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

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

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

.form-control,
.form-select {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  height: 48px;
  min-height: 40px;
  padding: 0.75rem 1rem;
  background-color: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: 0.95rem;
  font-family: inherit;
  transition: var(--transition);
}

.form-control {
  font-family: 'JetBrains Mono', monospace;
  font-weight: 600;
}

.form-select {
  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='%2310b981' 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 1rem center;
  background-size: 16px;
  padding-right: 2.5rem;
  text-overflow: ellipsis;
  white-space: nowrap;
  overflow: hidden;
  cursor: pointer;
}

.form-control:focus,
.form-select:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--primary-glow);
}

.form-select option,
.form-select optgroup {
  background-color: var(--bg-card);
  color: var(--text-primary);
}

.input-hint {
  font-size: 0.75rem;
  color: var(--text-secondary);
  line-height: 1.4;
}

/* Dashboard de resultados */
.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-optimal {
  background-color: rgba(16, 185, 129, 0.15);
  color: var(--success);
  border: 1px solid rgba(16, 185, 129, 0.3);
}

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

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

/* Hero Metric */
.hero-metric-box {
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.12) 0%, rgba(16, 185, 129, 0.03) 100%);
  border: 1px solid rgba(16, 185, 129, 0.3);
  border-radius: var(--radius-md);
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.hero-metric-header {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.hero-metric-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-primary);
}

.hero-metric-sub {
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.hero-value-wrap {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  margin: 0.25rem 0;
}

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

.hero-unit {
  font-family: 'JetBrains Mono', monospace;
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-secondary);
}

.hero-equivalences {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
  font-size: 0.82rem;
  color: var(--text-secondary);
  padding-top: 0.5rem;
  border-top: 1px solid rgba(16, 185, 129, 0.2);
}

.hero-pct-pill {
  display: inline-flex;
  align-items: center;
  background-color: rgba(16, 185, 129, 0.15);
  color: var(--primary);
  padding: 0.2rem 0.5rem;
  border-radius: var(--radius-full);
  font-weight: 600;
}

/* Desglose en mini grid */
.pregnancy-fractions-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
}

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

.fraction-item {
  background-color: var(--bg-card-hover);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0.85rem;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.fraction-title {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.fraction-val-row {
  display: flex;
  align-items: baseline;
  gap: 0.25rem;
}

.fraction-val-row strong {
  font-family: 'JetBrains Mono', monospace;
  font-size: 1.15rem;
  color: var(--text-primary);
}

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

.fraction-sub {
  font-size: 0.72rem;
  color: var(--text-secondary);
  line-height: 1.3;
}

/* Interpretación clínica */
.clinical-assessment-box {
  background-color: var(--bg-card-hover);
  border-left: 4px solid var(--primary);
  border-radius: var(--radius-sm);
  padding: 0.85rem 1rem;
}

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

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

/* Botones de acción */
.action-buttons-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: auto;
}

.btn-action-outline {
  flex: 1 1 0%;
  min-width: 140px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  background-color: transparent;
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  padding: 0.65rem 1rem;
  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: 480px) {
  .btn-action-outline {
    flex: 1 1 100%;
  }
}

/* TARJETA DEL GRÁFICO SVG A ANCHO COMPLETO */
.chart-card {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.75rem;
  box-shadow: var(--shadow-md);
  margin-bottom: 2.5rem;
}

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

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

.chart-subtitle {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-top: 0.2rem;
}

.chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.chart-legend-item {
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

.chart-legend-box {
  width: 14px;
  height: 10px;
  border-radius: 2px;
}

.box-band {
  background: rgba(16, 185, 129, 0.25);
  border: 1px solid rgba(16, 185, 129, 0.5);
}

.box-line {
  background: #10b981;
  height: 3px;
}

.chart-legend-dot {
  width: 10px;
  height: 10px;
  border-radius: var(--radius-full);
}

.dot-actual {
  background-color: #3b82f6;
  box-shadow: 0 0 6px rgba(59, 130, 246, 0.8);
}

.chart-svg-wrapper {
  width: 100%;
  overflow-x: auto;
}

.pregnancy-svg {
  width: 100%;
  height: auto;
  min-height: 280px;
  display: block;
}

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

.seo-guide-header {
  text-align: center;
  max-width: 800px;
  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(16, 185, 129, 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: 860px) {
  .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(16, 185, 129, 0.08) 0%, rgba(16, 185, 129, 0.02) 100%);
  border: 1px solid rgba(16, 185, 129, 0.3);
  border-radius: var(--radius-lg);
  padding: 1.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.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: 650px;
}

.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: 'Outfit', sans-serif;
  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;
}
