/* ==========================================================================
   Calculadora de baja laboral - Hoja de estilos canónica
   Estándares Fijate Tools (Modelo Test-Burnout / Payroll Studio)
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. Variables de diseño y temas (Oscuro / Claro)
   -------------------------------------------------------------------------- */
:root {
  /* Paleta base en modo oscuro por defecto */
  --bg-page: #0b0f19;
  --bg-card: rgba(17, 24, 39, 0.85);
  --bg-card-hover: rgba(24, 33, 54, 0.95);
  --bg-input: rgba(15, 23, 42, 0.7);
  --bg-pill: rgba(30, 41, 59, 0.7);
  --bg-pill-hover: rgba(51, 65, 85, 0.9);
  --bg-pill-active: #2563eb;
  
  --border-color: rgba(255, 255, 255, 0.08);
  --border-focus: #3b82f6;
  --border-subtle: rgba(255, 255, 255, 0.05);

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

  --accent-blue: #3b82f6;
  --accent-blue-hover: #2563eb;
  --accent-emerald: #10b981;
  --accent-emerald-dark: #059669;
  --accent-amber: #f59e0b;
  --accent-rose: #f43f5e;
  --accent-purple: #8b5cf6;

  --badge-bg-comun: rgba(59, 130, 246, 0.15);
  --badge-text-comun: #93c5fd;
  --badge-border-comun: rgba(59, 130, 246, 0.3);

  --badge-bg-prof: rgba(245, 158, 11, 0.15);
  --badge-text-prof: #fcd34d;
  --badge-border-prof: rgba(245, 158, 11, 0.3);

  --badge-bg-ss: rgba(16, 185, 129, 0.15);
  --badge-text-ss: #6ee7b7;
  --badge-border-ss: rgba(16, 185, 129, 0.3);

  --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 10px 25px -5px rgba(0, 0, 0, 0.5);

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-xl: 20px;

  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-heading: 'Outfit', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
}

[data-theme="light"] {
  --bg-page: #f8fafc;
  --bg-card: #ffffff;
  --bg-card-hover: #f1f5f9;
  --bg-input: #ffffff;
  --bg-pill: #e2e8f0;
  --bg-pill-hover: #cbd5e1;
  --bg-pill-active: #2563eb;

  --border-color: #e2e8f0;
  --border-focus: #2563eb;
  --border-subtle: #f1f5f9;

  --text-primary: #0f172a;
  --text-secondary: #334155;
  --text-muted: #64748b;
  --text-dim: #94a3b8;

  --accent-blue: #2563eb;
  --accent-blue-hover: #1d4ed8;
  --accent-emerald: #059669;
  --accent-emerald-dark: #047857;
  --accent-amber: #d97706;
  --accent-rose: #e11d48;
  --accent-purple: #7c3aed;

  --badge-bg-comun: rgba(37, 99, 235, 0.1);
  --badge-text-comun: #1d4ed8;
  --badge-border-comun: rgba(37, 99, 235, 0.25);

  --badge-bg-prof: rgba(217, 119, 6, 0.1);
  --badge-text-prof: #b45309;
  --badge-border-prof: rgba(217, 119, 6, 0.25);

  --badge-bg-ss: rgba(5, 150, 105, 0.1);
  --badge-text-ss: #047857;
  --badge-border-ss: rgba(5, 150, 105, 0.25);

  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.06);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 10px 25px -5px rgba(0, 0, 0, 0.1);
}

/* --------------------------------------------------------------------------
   2. Reset y contención de viewport
   -------------------------------------------------------------------------- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-sans);
  background-color: var(--bg-page);
  color: var(--text-primary);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  line-height: 1.5;
  overflow-x: clip;
  width: 100%;
  max-width: 100%;
  transition: background-color 0.25s ease, color 0.25s ease;
}

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-heading);
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.25;
}

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

/* --------------------------------------------------------------------------
   3. Layout canónico y contención
   -------------------------------------------------------------------------- */
.tool-layout {
  max-width: 1200px;
  margin: 1.5rem auto 3rem;
  padding: 0 1rem;
  width: 100%;
  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%;
}

/* --------------------------------------------------------------------------
   4. Tarjeta principal contenedora
   -------------------------------------------------------------------------- */
.card-main {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xl);
  padding: 1.5rem;
  box-shadow: var(--shadow-md);
  backdrop-filter: blur(12px);
  margin-bottom: 2rem;
}

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

/* --------------------------------------------------------------------------
   5. Selector de modo de cálculo (Duración total vs Nómina del mes)
   -------------------------------------------------------------------------- */
.mode-switch-wrapper {
  margin-bottom: 1.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.mode-switch-nav {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 4px;
  gap: 4px;
}

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

.btn-mode-tab:hover {
  color: var(--text-primary);
  background: var(--bg-pill-hover);
}

.btn-mode-tab.active {
  background: var(--accent-blue);
  color: #ffffff;
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.4);
}

.btn-mode-tab svg {
  flex-shrink: 0;
}

/* --------------------------------------------------------------------------
   6. Píldoras de presets rápidos
   -------------------------------------------------------------------------- */
.presets-section {
  margin-bottom: 1.5rem;
  padding-bottom: 1.25rem;
  border-bottom: 1px dashed var(--border-color);
}

.presets-label {
  display: block;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.65rem;
}

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

.btn-preset {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.45rem 0.85rem;
  border-radius: 9999px;
  border: 1px solid var(--border-color);
  background: var(--bg-pill);
  color: var(--text-secondary);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.18s ease;
  min-height: 36px;
}

.btn-preset:hover {
  background: var(--bg-pill-hover);
  color: var(--text-primary);
  border-color: var(--border-focus);
  transform: translateY(-1px);
}

.btn-preset.active {
  background: var(--accent-blue);
  color: #ffffff;
  border-color: var(--accent-blue);
}

/* --------------------------------------------------------------------------
   7. Formulario modular y campos interactivos
   -------------------------------------------------------------------------- */
.form-grid-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1.25rem;
  margin-bottom: 1.25rem;
}

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

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

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

.form-label {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

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

/* Input con wrapper para sufijos y unidades */
.input-affix-wrapper {
  display: flex;
  align-items: center;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 0 0.75rem;
  min-height: 42px;
  width: 100%;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.input-affix-wrapper:focus-within {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}

.input-affix-field {
  flex: 1 1 0%;
  width: 0;
  min-width: 0;
  border: none;
  background: transparent;
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 1.05rem;
  font-weight: 600;
  padding: 0.5rem 0;
  outline: none;
}

.input-affix-text {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-left: 0.5rem;
  user-select: none;
}

/* Inputs estándar no agrupados */
.form-control {
  width: 100%;
  min-height: 42px;
  padding: 0.5rem 0.75rem;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 0.95rem;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  outline: none;
}

.form-control:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}

/* Selector <select> con flecha SVG y contraste explícito */
.form-select {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  min-height: 42px;
  padding: 0.5rem 2.5rem 0.5rem 0.75rem;
  background-color: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 0.92rem;
  font-weight: 500;
  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='%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");
  background-repeat: no-repeat;
  background-position: right 0.85rem center;
  background-size: 16px;
  text-overflow: ellipsis;
  white-space: nowrap;
  overflow: hidden;
  cursor: pointer;
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

[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' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
}

.form-select:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}

.form-select option,
.form-select optgroup {
  background-color: #1e293b;
  color: #f8fafc;
}

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

/* Grupos de botones de opción compactos */
.btn-toggle-group {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.35rem;
  background: var(--bg-input);
  padding: 3px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
}

.btn-toggle-option {
  border: none;
  background: transparent;
  color: var(--text-secondary);
  padding: 0.5rem;
  font-size: 0.88rem;
  font-weight: 600;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.18s ease;
  min-height: 38px;
  text-align: center;
}

.btn-toggle-option:hover {
  color: var(--text-primary);
  background: var(--bg-pill-hover);
}

.btn-toggle-option.active {
  background: var(--accent-blue);
  color: #ffffff;
}

/* Alerta informativa de carencia */
.alert-carencia-box {
  display: none;
  background: rgba(244, 63, 94, 0.12);
  border: 1px solid rgba(244, 63, 94, 0.3);
  border-radius: var(--radius-sm);
  padding: 0.75rem 1rem;
  color: #fecdd3;
  font-size: 0.88rem;
  margin-top: 0.5rem;
}

[data-theme="light"] .alert-carencia-box {
  color: #9f1239;
  background: #ffe4e6;
  border-color: #fecdd3;
}

.alert-carencia-box a {
  color: inherit;
  font-weight: 600;
  text-decoration: underline;
  cursor: pointer;
}

/* --------------------------------------------------------------------------
   8. Panel de resultados y tarjetas métricas KPI
   -------------------------------------------------------------------------- */
.results-container {
  margin-top: 2rem;
  padding-top: 1.75rem;
  border-top: 1px solid var(--border-color);
}

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

.results-title {
  font-size: 1.35rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

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

/* Tarjetas KPI principales */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1rem;
  margin-bottom: 1.75rem;
}

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

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

.kpi-card {
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1rem 1.15rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  transition: transform 0.2s ease, border-color 0.2s ease;
}

.kpi-card:hover {
  border-color: var(--border-focus);
  transform: translateY(-2px);
}

.kpi-card-featured {
  background: linear-gradient(135deg, rgba(37, 99, 235, 0.15) 0%, rgba(16, 185, 129, 0.1) 100%);
  border-color: rgba(59, 130, 246, 0.4);
}

.kpi-label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 0.35rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.kpi-value {
  font-family: var(--font-mono);
  font-size: 1.65rem;
  font-weight: 800;
  color: var(--text-primary);
  line-height: 1.15;
  margin-bottom: 0.35rem;
}

.kpi-value.text-emerald {
  color: var(--accent-emerald);
}

.kpi-value.text-amber {
  color: var(--accent-amber);
}

.kpi-value.text-rose {
  color: var(--accent-rose);
}

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

/* --------------------------------------------------------------------------
   9. Barra apilada de distribución de pagadores
   -------------------------------------------------------------------------- */
.distribution-section {
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  margin-bottom: 1.75rem;
}

.distribution-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.85rem;
  font-size: 0.9rem;
  font-weight: 600;
}

.stacked-bar-container {
  height: 24px;
  background: rgba(0, 0, 0, 0.2);
  border-radius: 9999px;
  overflow: hidden;
  display: flex;
  margin-bottom: 0.85rem;
}

.stacked-segment {
  height: 100%;
  transition: width 0.4s ease;
  position: relative;
}

.segment-ss {
  background: var(--accent-emerald);
}

.segment-employer {
  background: var(--accent-blue);
}

.segment-supplement {
  background: var(--accent-purple);
}

.segment-gap {
  background: var(--accent-rose);
  opacity: 0.85;
}

.distribution-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  font-size: 0.82rem;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  color: var(--text-secondary);
}

.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* --------------------------------------------------------------------------
   10. Cronograma / Tabla de tramos legales
   -------------------------------------------------------------------------- */
.brackets-section {
  margin-bottom: 1.75rem;
}

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

.table-responsive {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background: var(--bg-input);
}

.table-brackets {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
  text-align: left;
}

.table-brackets th {
  background: rgba(0, 0, 0, 0.15);
  padding: 0.75rem 1rem;
  font-weight: 600;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border-color);
  white-space: nowrap;
}

.table-brackets td {
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-primary);
  vertical-align: middle;
}

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

.table-brackets .col-mono {
  font-family: var(--font-mono);
  font-weight: 600;
  white-space: nowrap;
}

/* Badges de pagador */
.badge-payer {
  display: inline-flex;
  align-items: center;
  padding: 0.25rem 0.6rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 600;
  line-height: 1.2;
  white-space: nowrap;
}

.badge-unpaid {
  background: rgba(244, 63, 94, 0.15);
  color: #fca5a5;
  border: 1px solid rgba(244, 63, 94, 0.3);
}

.badge-employer {
  background: rgba(59, 130, 246, 0.15);
  color: #93c5fd;
  border: 1px solid rgba(59, 130, 246, 0.3);
}

.badge-ss {
  background: rgba(16, 185, 129, 0.15);
  color: #6ee7b7;
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.badge-ss-high {
  background: rgba(16, 185, 129, 0.25);
  color: #a7f3d0;
  border: 1px solid rgba(16, 185, 129, 0.5);
  font-weight: 700;
}

.badge-prof {
  background: rgba(245, 158, 11, 0.15);
  color: #fde68a;
  border: 1px solid rgba(245, 158, 11, 0.3);
}

[data-theme="light"] .badge-unpaid {
  background: #fee2e2;
  color: #991b1b;
  border-color: #fca5a5;
}

[data-theme="light"] .badge-employer {
  background: #dbeafe;
  color: #1e40af;
  border-color: #bfdbfe;
}

[data-theme="light"] .badge-ss,
[data-theme="light"] .badge-ss-high {
  background: #d1fae5;
  color: #065f46;
  border-color: #a7f3d0;
}

[data-theme="light"] .badge-prof {
  background: #fef3c7;
  color: #92400e;
  border-color: #fde68a;
}

/* --------------------------------------------------------------------------
   11. Panel de deducciones y neto
   -------------------------------------------------------------------------- */
.deductions-box {
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  margin-bottom: 1.75rem;
}

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

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

.deduction-item {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

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

.deduction-val {
  font-family: var(--font-mono);
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-primary);
}

/* --------------------------------------------------------------------------
   12. Botones de acción principales
   -------------------------------------------------------------------------- */
.btn-action-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 1.5rem;
}

.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  background: var(--accent-blue);
  color: #ffffff;
  border: none;
  border-radius: var(--radius-sm);
  padding: 0.75rem 1.5rem;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  min-height: 44px;
  transition: all 0.2s ease;
}

.btn-primary:hover {
  background: var(--accent-blue-hover);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.35);
}

.btn-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  background: var(--bg-pill);
  color: var(--text-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 0.75rem 1.25rem;
  font-size: 0.92rem;
  font-weight: 600;
  cursor: pointer;
  min-height: 44px;
  transition: all 0.2s ease;
}

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

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

/* --------------------------------------------------------------------------
   13. Sección de Historial en LocalStorage
   -------------------------------------------------------------------------- */
.history-section {
  margin-top: 2rem;
  padding-top: 1.75rem;
  border-top: 1px solid var(--border-color);
}

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

.history-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1rem;
}

.history-card {
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  transition: all 0.2s ease;
}

.history-card:hover {
  border-color: var(--border-focus);
  transform: translateY(-2px);
}

.history-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.5rem;
}

.history-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.history-badge {
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
}

.badge-hist-comun {
  background: var(--badge-bg-comun);
  color: var(--badge-text-comun);
  border: 1px solid var(--badge-border-comun);
}

.badge-hist-prof {
  background: var(--badge-bg-prof);
  color: var(--badge-text-prof);
  border: 1px solid var(--badge-border-prof);
}

.badge-hist-neutral {
  background: var(--bg-pill);
  color: var(--text-muted);
}

.history-date {
  font-size: 0.75rem;
  color: var(--text-dim);
  white-space: nowrap;
}

.history-card-body {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.5rem;
  font-size: 0.85rem;
}

.history-stat {
  display: flex;
  flex-direction: column;
}

.history-stat-label {
  font-size: 0.72rem;
  color: var(--text-muted);
}

.history-stat-val {
  font-weight: 600;
  color: var(--text-primary);
}

.text-net {
  color: var(--accent-emerald);
  font-size: 1.05rem;
}

.history-card-actions {
  display: flex;
  gap: 0.5rem;
  border-top: 1px solid var(--border-subtle);
  padding-top: 0.65rem;
}

.btn-history-restore {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  background: var(--bg-pill);
  color: var(--text-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 0.4rem 0.65rem;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  min-height: 36px;
  transition: all 0.18s ease;
}

.btn-history-restore:hover {
  background: var(--accent-blue);
  color: #ffffff;
  border-color: var(--accent-blue);
}

.btn-history-delete {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  color: var(--text-dim);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 0.4rem 0.65rem;
  cursor: pointer;
  min-height: 36px;
  transition: all 0.18s ease;
}

.btn-history-delete:hover {
  color: var(--accent-rose);
  border-color: var(--accent-rose);
  background: rgba(244, 63, 94, 0.1);
}

.empty-state {
  text-align: center;
  padding: 2.5rem 1rem;
  color: var(--text-muted);
  font-size: 0.92rem;
  background: var(--bg-input);
  border: 1px dashed var(--border-color);
  border-radius: var(--radius-md);
}

/* --------------------------------------------------------------------------
   14. Modales nativos accesibles (sin window.alert)
   -------------------------------------------------------------------------- */
.modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(8px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  padding: 1rem;
}

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

.modal-dialog {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 540px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: modalScaleIn 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal-dialog-lg {
  max-width: 720px;
}

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

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

.modal-title {
  font-size: 1.15rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.btn-modal-close {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0.35rem;
  border-radius: var(--radius-sm);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: color 0.18s ease;
}

.btn-modal-close:hover {
  color: var(--text-primary);
  background: var(--bg-pill-hover);
}

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

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

/* --------------------------------------------------------------------------
   15. Toast flotante de notificaciones
   -------------------------------------------------------------------------- */
.app-toast {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  background: #1e293b;
  color: #f8fafc;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: var(--radius-md);
  padding: 0.85rem 1.25rem;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.4);
  font-size: 0.9rem;
  font-weight: 500;
  z-index: 10000;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  opacity: 0;
  transform: translateY(15px);
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
}

.app-toast.show {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

/* --------------------------------------------------------------------------
   16. Reglas de impresión (@media print)
   -------------------------------------------------------------------------- */
@media print {
  body {
    background: #ffffff !important;
    color: #000000 !important;
  }
  .app-header,
  .tools-ad-banner-section,
  .tool-ad-sidebar,
  .fijate-footer,
  .presets-section,
  .mode-switch-wrapper,
  .btn-action-row,
  .history-section,
  .results-actions,
  .modal-backdrop,
  .app-toast {
    display: none !important;
  }
  .tool-layout,
  .card-main {
    max-width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
    box-shadow: none !important;
    border: none !important;
    background: transparent !important;
  }
  .table-responsive {
    overflow: visible !important;
    border: 1px solid #ccc !important;
  }
  .table-brackets th,
  .table-brackets td {
    color: #000000 !important;
    border-color: #ddd !important;
  }
}
