:root,
[data-theme="dark"] {
  --font-main: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-heading: 'Outfit', 'Inter', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;

  --bg-page: #0b0f17;
  --bg-card: #131b2e;
  --bg-card-subtle: #162036;
  --bg-card-header: #19243d;
  --bg-input: #0f172a;
  --bg-surface: #181c24;

  --text-main: #f8fafc;
  --text-primary: #f8fafc;
  --text-muted: #94a3b8;
  --text-secondary: #94a3b8;
  --text-dim: #64748b;

  --border-color: #1e293b;
  --border-strong: #334155;

  --primary: #38bdf8;
  --primary-color: #0ea5e9;
  --primary-hover: #0284c7;
  --primary-light: rgba(56, 189, 248, 0.14);

  --status-critical: #ef4444;
  --status-critical-bg: rgba(239, 68, 68, 0.14);
  --status-critical-border: rgba(239, 68, 68, 0.38);

  --status-warn: #f59e0b;
  --status-warn-bg: rgba(245, 158, 11, 0.14);
  --status-warn-border: rgba(245, 158, 11, 0.38);

  --status-ok: #10b981;
  --status-ok-bg: rgba(16, 185, 129, 0.14);
  --status-ok-border: rgba(16, 185, 129, 0.38);

  --status-muted: #94a3b8;
  --status-muted-bg: rgba(148, 163, 184, 0.12);
  --status-muted-border: rgba(148, 163, 184, 0.28);

  --shadow-card: 0 12px 28px -8px rgba(0, 0, 0, 0.45);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
}

[data-theme="light"] {
  --bg-page: #f1f5f9;
  --bg-card: #ffffff;
  --bg-card-subtle: #f8fafc;
  --bg-card-header: #f1f5f9;
  --bg-input: #ffffff;
  --bg-surface: #f8fafc;

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

  --border-color: #e2e8f0;
  --border-strong: #cbd5e1;

  --primary: #0284c7;
  --primary-color: #0284c7;
  --primary-hover: #0369a1;
  --primary-light: rgba(2, 132, 199, 0.1);

  --status-critical: #dc2626;
  --status-critical-bg: #fef2f2;
  --status-critical-border: #fecaca;

  --status-warn: #b45309;
  --status-warn-bg: #fffbeb;
  --status-warn-border: #fde68a;

  --status-ok: #047857;
  --status-ok-bg: #ecfdf5;
  --status-ok-border: #a7f3d0;

  --status-muted: #475569;
  --status-muted-bg: #f1f5f9;
  --status-muted-border: #cbd5e1;

  --shadow-card: 0 6px 20px -4px rgba(15, 23, 42, 0.08);
}

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

body {
  font-family: var(--font-main);
  background-color: 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;
  line-height: 1.5;
}

h1, h2, h3, h4, h5, h6,
.brand-title,
.hero-title,
.section-title {
  font-family: var(--font-heading);
}

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

.tool-layout {
  margin-top: 1.25rem;
  margin-bottom: 3rem;
  flex: 1 0 auto;
}

.brand-logo-box-energy {
  background: var(--primary-light);
  color: var(--primary);
  border-color: var(--primary-color);
}

/* Cabecera contextual de la herramienta */
.audit-hero-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.35rem 1.5rem;
  margin-bottom: 1.25rem;
  box-shadow: var(--shadow-card);
}

.audit-hero-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0.25rem 0.65rem;
  border-radius: 999px;
  background: var(--primary-light);
  color: var(--primary);
  border: 1px solid rgba(56, 189, 248, 0.25);
}

[data-theme="light"] .hero-badge {
  border-color: rgba(2, 132, 199, 0.25);
}

.hero-badge-amber {
  background: var(--status-warn-bg);
  color: var(--status-warn);
  border-color: var(--status-warn-border);
}

.hero-badge-green {
  background: var(--status-ok-bg);
  color: var(--status-ok);
  border-color: var(--status-ok-border);
}

.audit-hero-title {
  margin: 0 0 0.45rem 0;
  font-size: clamp(1.25rem, 2.2vw, 1.65rem);
  font-weight: 800;
  color: var(--text-main);
  line-height: 1.25;
}

.audit-hero-desc {
  margin: 0;
  font-size: 0.92rem;
  color: var(--text-muted);
  max-width: 920px;
}

/* Barra de perfiles predefinidos */
.presets-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.15rem 1.35rem;
  margin-bottom: 1.25rem;
  box-shadow: var(--shadow-card);
}

.presets-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-bottom: 0.85rem;
}

.presets-title {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-family: var(--font-heading);
  font-size: 0.96rem;
  font-weight: 700;
  color: var(--text-main);
  margin: 0;
}

.presets-title svg {
  color: var(--primary);
  flex-shrink: 0;
}

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

.presets-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(195px, 1fr));
  gap: 0.65rem;
}

.btn-preset {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  text-align: left;
  gap: 0.2rem;
  min-height: 44px;
  padding: 0.7rem 0.85rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  background: var(--bg-input);
  color: var(--text-main);
  cursor: pointer;
  transition: border-color 0.2s ease, background-color 0.2s ease, transform 0.15s ease;
  font-family: var(--font-main);
}

.btn-preset strong {
  font-size: 0.86rem;
  font-weight: 700;
  color: var(--text-main);
  line-height: 1.25;
}

.btn-preset small {
  font-size: 0.76rem;
  color: var(--text-muted);
  line-height: 1.3;
}

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

.btn-preset.active {
  border-color: var(--primary-color);
  background: var(--primary-light);
  box-shadow: inset 0 0 0 1px var(--primary-color);
}

/* Rejilla principal de configuración + resultados */
.audit-workspace {
  display: grid;
  grid-template-columns: minmax(0, 1.02fr) minmax(0, 1.18fr);
  gap: 1.35rem;
  align-items: start;
}

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

.audit-col-inputs,
.audit-col-results {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1.15rem;
}

.section-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  box-shadow: var(--shadow-card);
  min-width: 0;
}

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

.section-card-title {
  margin: 0;
  font-size: 1.02rem;
  font-weight: 700;
  color: var(--text-main);
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.section-card-title svg {
  color: var(--primary);
  flex-shrink: 0;
}

.section-pill {
  font-size: 0.72rem;
  font-weight: 700;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  background: var(--bg-card-subtle);
  color: var(--text-muted);
  border: 1px solid var(--border-color);
}

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

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

@media (max-width: 640px) {
  .form-grid-2,
  .form-grid-3 {
    grid-template-columns: 1fr;
  }
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  min-width: 0;
  margin-bottom: 0.85rem;
}

.form-group:last-child {
  margin-bottom: 0;
}

.form-group label {
  font-size: 0.83rem;
  font-weight: 600;
  color: var(--text-main);
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.field-hint {
  font-size: 0.74rem;
  font-weight: 500;
  color: var(--text-muted);
}

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

.form-control[type="number"],
.form-control[type="date"] {
  font-family: var(--font-mono);
}

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

.form-select {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 40px;
  text-overflow: ellipsis;
  white-space: nowrap;
  overflow: hidden;
  cursor: pointer;
  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 0.75rem center;
}

[data-theme="light"] .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='%23475569' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
}

.form-select option {
  background-color: #131b2e;
  color: #f8fafc;
}

[data-theme="light"] .form-select option {
  background-color: #ffffff;
  color: #0f172a;
}

.input-unit-wrap {
  display: flex;
  align-items: stretch;
  width: 100%;
  min-width: 0;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--bg-input);
  overflow: hidden;
  min-height: 44px;
}

.input-unit-wrap:focus-within {
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px var(--primary-light);
}

.input-unit-wrap input {
  flex: 1 1 0%;
  width: 0;
  min-width: 0;
  border: none;
  background: transparent;
  color: var(--text-main);
  padding: 0.55rem 0.75rem;
  font-family: var(--font-mono);
  font-size: 0.92rem;
  outline: none;
  min-height: 42px;
}

.input-unit {
  display: inline-flex;
  align-items: center;
  padding: 0 0.75rem;
  background: var(--bg-card-subtle);
  border-left: 1px solid var(--border-color);
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 0.78rem;
  font-weight: 600;
  white-space: nowrap;
  flex-shrink: 0;
}

/* Checkboxes */
.check-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.55rem;
  margin-top: 0.5rem;
}

.check-option {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  padding: 0.6rem 0.75rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  background: var(--bg-input);
  cursor: pointer;
  min-height: 44px;
  font-size: 0.85rem;
  color: var(--text-main);
  transition: border-color 0.15s ease;
}

.check-option:hover {
  border-color: var(--primary-color);
}

.check-option input[type="checkbox"] {
  width: 18px;
  height: 18px;
  margin-top: 2px;
  accent-color: var(--primary-color);
  flex-shrink: 0;
  cursor: pointer;
}

.check-option span {
  line-height: 1.4;
}

.check-option small {
  display: block;
  color: var(--text-muted);
  font-size: 0.76rem;
  margin-top: 0.1rem;
}

/* Medidor visual de Terajulios (EED) */
.tj-meter-box {
  margin-top: 0.9rem;
  padding: 0.95rem 1rem;
  border-radius: var(--radius-md);
  background: var(--bg-input);
  border: 1px solid var(--border-color);
}

.tj-meter-top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 0.55rem;
}

.tj-meter-title {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text-main);
}

.tj-meter-val {
  font-family: var(--font-mono);
  font-size: 1rem;
  font-weight: 700;
  color: var(--primary);
}

.tj-bar-track {
  position: relative;
  height: 12px;
  border-radius: 999px;
  background: var(--bg-card-subtle);
  border: 1px solid var(--border-color);
  overflow: visible;
  margin: 0.65rem 0 0.85rem 0;
}

.tj-bar-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #10b981 0%, #38bdf8 55%, #f59e0b 80%, #ef4444 100%);
  width: 0%;
  transition: width 0.3s ease;
}

.tj-marker {
  position: absolute;
  top: -5px;
  bottom: -5px;
  width: 2px;
  background: var(--text-main);
  opacity: 0.75;
}

.tj-marker-label {
  position: absolute;
  top: 15px;
  transform: translateX(-50%);
  font-family: var(--font-mono);
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--text-muted);
  white-space: nowrap;
}

.tj-status-note {
  margin: 0.85rem 0 0 0;
  font-size: 0.8rem;
  color: var(--text-muted);
  line-height: 1.45;
}

/* Vigencias colapsables */
.dates-details {
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  background: var(--bg-input);
  overflow: hidden;
}

.dates-summary {
  padding: 0.85rem 1rem;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  cursor: pointer;
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 0.92rem;
  color: var(--text-main);
  list-style: none;
  user-select: none;
}

.dates-summary::-webkit-details-marker {
  display: none;
}

.dates-summary-meta {
  font-family: var(--font-main);
  font-size: 0.76rem;
  font-weight: 600;
  color: var(--primary);
}

.dates-body {
  padding: 0.95rem 1rem 1rem;
  border-top: 1px solid var(--border-color);
}

.quick-actions-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.9rem;
}

.btn-chip {
  min-height: 40px;
  padding: 0.45rem 0.75rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--bg-card-subtle);
  color: var(--text-main);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 0.15s ease, background-color 0.15s ease;
}

.btn-chip:hover {
  border-color: var(--primary-color);
  background: var(--primary-light);
}

/* Panel de KPIs */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.85rem;
}

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

.kpi-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1rem 1.1rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  box-shadow: var(--shadow-card);
  min-width: 0;
}

.kpi-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
}

.kpi-label {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-muted);
}

.kpi-badge {
  font-size: 0.7rem;
  font-weight: 700;
  padding: 0.18rem 0.55rem;
  border-radius: 999px;
  white-space: nowrap;
}

.kpi-badge.status-critical {
  background: var(--status-critical-bg);
  color: var(--status-critical);
  border: 1px solid var(--status-critical-border);
}

.kpi-badge.status-warn {
  background: var(--status-warn-bg);
  color: var(--status-warn);
  border: 1px solid var(--status-warn-border);
}

.kpi-badge.status-ok {
  background: var(--status-ok-bg);
  color: var(--status-ok);
  border: 1px solid var(--status-ok-border);
}

.kpi-badge.status-muted {
  background: var(--status-muted-bg);
  color: var(--status-muted);
  border: 1px solid var(--status-muted-border);
}

.kpi-value {
  font-family: var(--font-mono);
  font-size: clamp(1.3rem, 2.1vw, 1.65rem);
  font-weight: 800;
  color: var(--text-main);
  line-height: 1.15;
  word-break: break-word;
}

.kpi-sub {
  font-size: 0.77rem;
  color: var(--text-muted);
  line-height: 1.35;
}

/* Barra de acciones de informe */
.report-toolbar {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0.85rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.report-toolbar-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  width: 100%;
}

.btn-primary-action,
.btn-secondary-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  min-height: 44px;
  padding: 0.55rem 0.95rem;
  border-radius: var(--radius-sm);
  font-family: var(--font-main);
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
  transition: background-color 0.2s ease, border-color 0.2s ease, transform 0.1s ease;
}

.btn-primary-action {
  background: #0284c7;
  color: #ffffff;
  border: 1px solid #0284c7;
  flex: 1 1 185px;
}

.btn-primary-action:hover {
  background: #0369a1;
  border-color: #0369a1;
}

.btn-secondary-action {
  background: var(--bg-input);
  color: var(--text-main);
  border: 1px solid var(--border-strong);
  flex: 0 1 auto;
}

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

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

/* Pestañas de diagnóstico */
.diag-tabs {
  display: flex;
  gap: 0.45rem;
  background: var(--bg-input);
  padding: 0.35rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  flex-wrap: wrap;
}

.diag-tab-btn {
  flex: 1 1 140px;
  min-height: 42px;
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-muted);
  font-family: var(--font-main);
  font-size: 0.83rem;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  transition: all 0.18s ease;
}

.diag-tab-btn:hover {
  color: var(--text-main);
  background: var(--bg-card-subtle);
}

.diag-tab-btn.active {
  background: var(--primary-light);
  color: var(--primary);
  border-color: var(--primary-color);
}

.diag-tab-panel {
  display: none;
}

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

/* Controles de filtro en dictamen */
.rules-filter-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-bottom: 0.85rem;
}

.filter-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.filter-pill {
  min-height: 36px;
  padding: 0.3rem 0.7rem;
  border-radius: 999px;
  border: 1px solid var(--border-color);
  background: var(--bg-input);
  color: var(--text-muted);
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
}

.filter-pill.active {
  border-color: var(--primary-color);
  background: var(--primary-light);
  color: var(--primary);
}

/* Tarjetas individuales de normativa */
.rules-list {
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
}

.rule-card {
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-left: 4px solid var(--border-strong);
  border-radius: var(--radius-md);
  padding: 1rem 1.1rem;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.rule-card.sev-critical {
  border-left-color: var(--status-critical);
}

.rule-card.sev-warn {
  border-left-color: var(--status-warn);
}

.rule-card.sev-ok {
  border-left-color: var(--status-ok);
}

.rule-card.sev-muted {
  border-left-color: var(--border-strong);
  opacity: 0.85;
}

.rule-card-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.rule-card-title-group {
  min-width: 0;
  flex: 1 1 220px;
}

.rule-law-code {
  font-family: var(--font-mono);
  font-size: 0.74rem;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 0.15rem;
}

.rule-title {
  margin: 0;
  font-size: 0.98rem;
  font-weight: 700;
  color: var(--text-main);
  line-height: 1.3;
}

.rule-status-badge {
  font-size: 0.74rem;
  font-weight: 700;
  padding: 0.24rem 0.6rem;
  border-radius: 999px;
  white-space: nowrap;
}

.rule-status-badge.sev-critical {
  background: var(--status-critical-bg);
  color: var(--status-critical);
  border: 1px solid var(--status-critical-border);
}

.rule-status-badge.sev-warn {
  background: var(--status-warn-bg);
  color: var(--status-warn);
  border: 1px solid var(--status-warn-border);
}

.rule-status-badge.sev-ok {
  background: var(--status-ok-bg);
  color: var(--status-ok);
  border: 1px solid var(--status-ok-border);
}

.rule-status-badge.sev-muted {
  background: var(--status-muted-bg);
  color: var(--status-muted);
  border: 1px solid var(--status-muted-border);
}

.rule-reason {
  margin: 0;
  font-size: 0.86rem;
  color: var(--text-main);
  line-height: 1.5;
}

.rule-meta-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(175px, 1fr));
  gap: 0.55rem;
  padding-top: 0.55rem;
  border-top: 1px dashed var(--border-color);
  font-size: 0.8rem;
}

.rule-meta-item strong {
  display: block;
  font-size: 0.72rem;
  color: var(--text-muted);
  font-weight: 600;
  margin-bottom: 0.1rem;
}

.rule-meta-item span {
  color: var(--text-main);
  font-weight: 600;
}

.rule-action-box {
  background: var(--bg-card-subtle);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 0.55rem 0.75rem;
  font-size: 0.81rem;
  color: var(--text-muted);
  line-height: 1.45;
}

.rule-action-box strong {
  color: var(--text-main);
}

/* Calendario y checklist */
.timeline-list {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.timeline-item {
  display: flex;
  gap: 0.85rem;
  align-items: flex-start;
  padding: 0.85rem 1rem;
  border-radius: var(--radius-md);
  background: var(--bg-input);
  border: 1px solid var(--border-color);
}

.timeline-date-pill {
  min-width: 112px;
  text-align: center;
  padding: 0.35rem 0.55rem;
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 0.76rem;
  font-weight: 700;
  flex-shrink: 0;
}

.timeline-date-pill.sev-critical {
  background: var(--status-critical-bg);
  color: var(--status-critical);
  border: 1px solid var(--status-critical-border);
}

.timeline-date-pill.sev-warn {
  background: var(--status-warn-bg);
  color: var(--status-warn);
  border: 1px solid var(--status-warn-border);
}

.timeline-date-pill.sev-ok {
  background: var(--status-ok-bg);
  color: var(--status-ok);
  border: 1px solid var(--status-ok-border);
}

.timeline-date-pill.sev-muted {
  background: var(--status-muted-bg);
  color: var(--status-muted);
  border: 1px solid var(--status-muted-border);
}

.timeline-content {
  min-width: 0;
  flex: 1;
}

.timeline-content h4 {
  margin: 0 0 0.2rem 0;
  font-size: 0.92rem;
  color: var(--text-main);
}

.timeline-content p {
  margin: 0;
  font-size: 0.82rem;
  color: var(--text-muted);
  line-height: 1.45;
}

@media (max-width: 560px) {
  .timeline-item {
    flex-direction: column;
  }
  .timeline-date-pill {
    min-width: 0;
    width: auto;
  }
}

/* Checklist documental */
.checklist-progress-wrap {
  margin-bottom: 1rem;
  padding: 0.85rem 1rem;
  border-radius: var(--radius-md);
  background: var(--bg-input);
  border: 1px solid var(--border-color);
}

.checklist-progress-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.84rem;
  font-weight: 700;
  margin-bottom: 0.45rem;
}

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

.checklist-bar-fill {
  height: 100%;
  background: var(--status-ok);
  width: 0%;
  transition: width 0.25s ease;
}

.checklist-items {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.checklist-row {
  display: flex;
  align-items: flex-start;
  gap: 0.65rem;
  padding: 0.75rem 0.9rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  background: var(--bg-input);
  cursor: pointer;
  min-height: 44px;
}

.checklist-row.is-done {
  border-color: var(--status-ok-border);
  background: var(--status-ok-bg);
}

.checklist-row input[type="checkbox"] {
  width: 18px;
  height: 18px;
  margin-top: 2px;
  accent-color: var(--status-ok);
  flex-shrink: 0;
  cursor: pointer;
}

.checklist-row-text strong {
  display: block;
  font-size: 0.86rem;
  color: var(--text-main);
}

.checklist-row-text small {
  display: block;
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 0.15rem;
}

/* Nota legal de exención y privacidad */
.privacy-inline-note {
  margin-top: 0.75rem;
  padding: 0.75rem 0.95rem;
  border-radius: var(--radius-sm);
  background: var(--bg-card-subtle);
  border: 1px solid var(--border-color);
  font-size: 0.8rem;
  color: var(--text-muted);
  display: flex;
  align-items: flex-start;
  gap: 0.55rem;
  line-height: 1.45;
}

.privacy-inline-note svg {
  color: var(--status-ok);
  flex-shrink: 0;
  margin-top: 2px;
}

/* Modales accesibles */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(2, 6, 23, 0.76);
  backdrop-filter: blur(4px);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  z-index: 10000;
}

.modal-backdrop.is-open {
  display: flex;
}

.modal-dialog {
  width: 100%;
  max-width: 780px;
  max-height: 90vh;
  background: var(--bg-card);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.6);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.modal-dialog-sm {
  max-width: 460px;
}

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

.modal-title {
  margin: 0;
  font-size: 1.08rem;
  font-weight: 700;
  color: var(--text-main);
}

.modal-close-btn {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  background: var(--bg-input);
  color: var(--text-main);
  font-size: 1.3rem;
  line-height: 1;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

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

.modal-body {
  padding: 1.25rem;
  overflow-y: auto;
  font-size: 0.9rem;
  color: var(--text-main);
}

.modal-footer {
  padding: 0.9rem 1.25rem;
  border-top: 1px solid var(--border-color);
  background: var(--bg-card-subtle);
  display: flex;
  justify-content: flex-end;
  gap: 0.65rem;
  flex-wrap: wrap;
}

.report-preview-box {
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.15rem;
}

.report-preview-box h4 {
  margin: 1rem 0 0.45rem 0;
  font-size: 0.96rem;
  color: var(--primary);
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 0.25rem;
}

.report-preview-box h4:first-child {
  margin-top: 0;
}

.report-summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 0.65rem;
  margin-bottom: 0.85rem;
}

.report-summary-stat {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 0.6rem 0.75rem;
}

.report-summary-stat span {
  display: block;
  font-size: 0.74rem;
  color: var(--text-muted);
}

.report-summary-stat strong {
  font-family: var(--font-mono);
  font-size: 0.95rem;
  color: var(--text-main);
}

.report-table-wrap {
  overflow-x: auto;
  max-width: 100%;
}

.report-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
  min-width: 540px;
}

.report-table th,
.report-table td {
  padding: 0.55rem 0.65rem;
  border-bottom: 1px solid var(--border-color);
  text-align: left;
  vertical-align: top;
}

.report-table th {
  font-family: var(--font-heading);
  color: var(--text-muted);
  font-weight: 700;
}

/* Toast visual */
.toast-banner {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%) translateY(16px);
  background: var(--bg-card-header);
  color: var(--text-main);
  border: 1px solid var(--primary-color);
  border-radius: var(--radius-md);
  padding: 0.7rem 1.15rem;
  font-size: 0.86rem;
  font-weight: 600;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.45);
  z-index: 10050;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s ease;
  max-width: calc(100vw - 2rem);
  text-align: center;
}

.toast-banner.is-visible {
  opacity: 1;
  visibility: visible;
  transform: translateX(-50%) translateY(0);
}

/* Hoja oculta exclusiva para impresión limpia */
.print-only-header {
  display: none;
}

@media print {
  @page {
    size: A4 portrait;
    margin: 14mm;
  }

  body {
    background: #ffffff !important;
    color: #0f172a !important;
    display: block !important;
  }

  .app-header,
  .tools-ad-banner-section,
  .tool-ad-sidebar,
  .tool-breadcrumbs,
  .presets-card,
  .audit-col-inputs,
  .report-toolbar,
  .diag-tabs,
  .rules-filter-row,
  .amazon-affiliate-showcase,
  .seo-guide-section,
  .related-tools-section,
  .fijate-footer,
  .toast-banner,
  .modal-backdrop {
    display: none !important;
  }

  .tool-layout,
  .tool-with-sidebar,
  .tool-main-content,
  .audit-workspace,
  .audit-col-results {
    display: block !important;
    width: 100% !important;
    max-width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
  }

  .print-only-header {
    display: block !important;
    border-bottom: 2px solid #0f172a;
    padding-bottom: 0.6rem;
    margin-bottom: 1rem;
  }

  .section-card,
  .kpi-card,
  .rule-card,
  .timeline-item {
    background: #ffffff !important;
    color: #0f172a !important;
    border-color: #cbd5e1 !important;
    box-shadow: none !important;
    break-inside: avoid;
  }

  .diag-tab-panel {
    display: block !important;
    margin-bottom: 1rem;
  }

  .kpi-label,
  .kpi-sub,
  .rule-action-box,
  .timeline-content p,
  .checklist-row-text small {
    color: #334155 !important;
  }
}
