/* ==========================================================================
   Calculadora de Becas MEC - Estilos Oficiales Canónicos Fijate Tools
   ========================================================================== */

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

  /* Tema Oscuro (por defecto) */
  --bg-main: #0a0f1d;
  --bg-card: #121a2f;
  --bg-card-subtle: #18223d;
  --bg-input: #0e1628;
  --border-color: #243254;
  --border-hover: #3b5082;
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --primary: #3b82f6;
  --primary-hover: #2563eb;
  --primary-glow: rgba(59, 130, 246, 0.25);
  --success: #10b981;
  --success-glow: rgba(16, 185, 129, 0.2);
  --warning: #f59e0b;
  --warning-glow: rgba(245, 158, 11, 0.2);
  --danger: #ef4444;
  --danger-glow: rgba(239, 68, 68, 0.2);
  --accent: #8b5cf6;
  --card-shadow: 0 10px 30px -5px rgba(0, 0, 0, 0.5), 0 0 1px 1px rgba(255, 255, 255, 0.05);
  --select-arrow: 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");
}

[data-theme="light"] {
  --bg-main: #f1f5f9;
  --bg-card: #ffffff;
  --bg-card-subtle: #f8fafc;
  --bg-input: #ffffff;
  --border-color: #cbd5e1;
  --border-hover: #94a3b8;
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #64748b;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-glow: rgba(37, 99, 235, 0.15);
  --success: #059669;
  --warning: #d97706;
  --danger: #dc2626;
  --accent: #7c3aed;
  --card-shadow: 0 10px 25px -5px rgba(15, 23, 42, 0.08), 0 1px 3px rgba(15, 23, 42, 0.05);
  --select-arrow: 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");
}

/* Reset y base */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-body);
  background-color: var(--bg-main);
  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: var(--font-heading);
  font-weight: 700;
  line-height: 1.25;
}

/* Layout y Contención */
.tool-layout {
  max-width: 1200px;
  margin: 1.5rem auto 3.5rem;
  padding: 0 1rem;
  width: 100%;
  flex: 1;
}

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

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

/* Tarjeta Principal */
.card-main {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 18px;
  padding: 2.25rem 2rem;
  box-shadow: var(--card-shadow);
  margin-bottom: 2.5rem;
  backdrop-filter: blur(12px);
}

.card-header-hero {
  margin-bottom: 2rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--border-color);
}

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

.card-title {
  font-size: 1.85rem;
  margin-bottom: 0.65rem;
  color: var(--text-primary);
}

.card-intro {
  font-size: 1.025rem;
  line-height: 1.6;
  color: var(--text-secondary);
}

/* Formulario y Secciones */
.form-grid {
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

.form-section {
  background-color: var(--bg-card-subtle);
  border: 1px solid var(--border-color);
  border-radius: 14px;
  padding: 1.5rem;
}

.section-heading {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 1.15rem;
  color: var(--text-primary);
  margin-bottom: 1.25rem;
}

.step-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--primary);
  color: #ffffff;
  font-size: 0.85rem;
  font-family: var(--font-mono);
  font-weight: 700;
}

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

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

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

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

.field-hint {
  font-size: 0.78rem;
  color: var(--text-muted);
  line-height: 1.4;
}

/* Tooltip button */
.btn-tooltip-trigger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--border-color);
  color: var(--text-secondary);
  border: none;
  font-size: 0.75rem;
  cursor: pointer;
  transition: all 0.2s;
  font-family: var(--font-mono);
}

.btn-tooltip-trigger:hover {
  background: var(--primary);
  color: #ffffff;
}

/* Inputs y Selects */
.form-control {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  height: 44px;
  padding: 0.65rem 0.85rem;
  border-radius: 10px;
  border: 1px solid var(--border-color);
  background-color: var(--bg-input);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 0.95rem;
  transition: border-color 0.2s, box-shadow 0.2s;
}

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

.form-select {
  appearance: none;
  -webkit-appearance: none;
  background-image: var(--select-arrow);
  background-repeat: no-repeat;
  background-position: right 14px center;
  background-size: 16px;
  padding-right: 40px;
  text-overflow: ellipsis;
  white-space: nowrap;
  overflow: hidden;
  cursor: pointer;
}

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

/* Input con sufijo */
.input-with-suffix {
  display: flex;
  align-items: center;
  border: 1px solid var(--border-color);
  border-radius: 10px;
  background-color: var(--bg-input);
  overflow: hidden;
  height: 44px;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.input-with-suffix:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
}

.input-with-suffix .form-control {
  border: none;
  background: transparent;
  flex: 1 1 0%;
  width: 0;
  min-width: 0;
  height: 100%;
  box-shadow: none;
  font-family: var(--font-mono);
  font-size: 1.05rem;
  font-weight: 600;
}

.input-suffix {
  padding: 0 0.85rem;
  font-size: 0.85rem;
  color: var(--text-muted);
  font-weight: 600;
  background-color: var(--bg-card-subtle);
  height: 100%;
  display: flex;
  align-items: center;
  border-left: 1px solid var(--border-color);
  white-space: nowrap;
}

/* Stepper */
.stepper-wrapper {
  display: flex;
  align-items: center;
  border: 1px solid var(--border-color);
  border-radius: 10px;
  background-color: var(--bg-input);
  overflow: hidden;
  height: 44px;
}

.btn-stepper {
  width: 44px;
  height: 100%;
  background: var(--bg-card-subtle);
  border: none;
  color: var(--text-primary);
  font-size: 1.25rem;
  font-weight: bold;
  cursor: pointer;
  transition: background 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.btn-stepper:hover {
  background: var(--border-color);
}

.input-stepper {
  border: none;
  background: transparent;
  text-align: center;
  font-family: var(--font-mono);
  font-size: 1.1rem;
  font-weight: 700;
  height: 100%;
  flex: 1 1 0%;
  width: 0;
  min-width: 0;
}

.input-stepper::-webkit-inner-spin-button,
.input-stepper::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

/* Deductions Grid */
.deductions-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}

.deduction-card {
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 0.85rem 1rem;
}

.deduction-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.4rem;
  font-size: 0.85rem;
  font-weight: 600;
}

.deduction-badge {
  font-size: 0.72rem;
  color: var(--primary);
  background: var(--primary-glow);
  padding: 0.15rem 0.5rem;
  border-radius: 6px;
  font-family: var(--font-mono);
}

.checkbox-pill-card {
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 0.85rem 1rem;
  display: flex;
  align-items: center;
}

.custom-checkbox {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  cursor: pointer;
  width: 100%;
}

.custom-checkbox input {
  position: absolute;
  opacity: 0;
  cursor: pointer;
}

.checkbox-box {
  width: 20px;
  height: 20px;
  border-radius: 6px;
  border: 2px solid var(--border-color);
  background: var(--bg-card);
  margin-top: 2px;
  flex-shrink: 0;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.custom-checkbox input:checked ~ .checkbox-box {
  background: var(--primary);
  border-color: var(--primary);
}

.custom-checkbox input:checked ~ .checkbox-box::after {
  content: "";
  width: 6px;
  height: 10px;
  border: solid white;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
  margin-bottom: 2px;
}

.checkbox-text {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.checkbox-text strong {
  font-size: 0.875rem;
  color: var(--text-primary);
}

.checkbox-text small {
  font-size: 0.75rem;
  color: var(--text-muted);
}

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

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  height: 48px;
  padding: 0 1.5rem;
  border-radius: 10px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  border: 1px solid transparent;
}

.btn-primary {
  background-color: var(--primary);
  color: #ffffff;
  box-shadow: 0 4px 14px var(--primary-glow);
}

.btn-primary:hover {
  background-color: var(--primary-hover);
  transform: translateY(-1px);
}

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

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

.btn-calc {
  flex: 2;
}

.btn-reset {
  flex: 1;
}

/* Resultados */
.results-area {
  margin-top: 2rem;
  animation: fadeIn 0.4s ease-out;
}

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

.results-divider {
  border: none;
  border-top: 1px solid var(--border-color);
  margin-bottom: 2rem;
}

/* Veredicto Banner */
.veredicto-card {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  padding: 1.5rem;
  border-radius: 14px;
  border: 1px solid var(--border-color);
  margin-bottom: 1.75rem;
  background: var(--bg-card-subtle);
}

.veredicto-icon-box {
  width: 56px;
  height: 56px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.veredicto-badge {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0.2rem 0.65rem;
  border-radius: 12px;
  margin-bottom: 0.4rem;
}

.veredicto-title {
  font-size: 1.35rem;
  margin-bottom: 0.35rem;
}

.veredicto-desc {
  font-size: 0.95rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

/* Estados de Veredicto */
.veredicto-card.status-u1 {
  border-color: rgba(16, 185, 129, 0.4);
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.1), var(--bg-card-subtle));
}
.veredicto-card.status-u1 .veredicto-icon-box {
  background: rgba(16, 185, 129, 0.2);
  color: var(--success);
}
.veredicto-card.status-u1 .veredicto-badge {
  background: rgba(16, 185, 129, 0.2);
  color: var(--success);
}

.veredicto-card.status-u2 {
  border-color: rgba(59, 130, 246, 0.4);
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.1), var(--bg-card-subtle));
}
.veredicto-card.status-u2 .veredicto-icon-box {
  background: rgba(59, 130, 246, 0.2);
  color: var(--primary);
}
.veredicto-card.status-u2 .veredicto-badge {
  background: rgba(59, 130, 246, 0.2);
  color: var(--primary);
}

.veredicto-card.status-u3 {
  border-color: rgba(245, 158, 11, 0.4);
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.1), var(--bg-card-subtle));
}
.veredicto-card.status-u3 .veredicto-icon-box {
  background: rgba(245, 158, 11, 0.2);
  color: var(--warning);
}
.veredicto-card.status-u3 .veredicto-badge {
  background: rgba(245, 158, 11, 0.2);
  color: var(--warning);
}

.veredicto-card.status-out {
  border-color: rgba(239, 68, 68, 0.4);
  background: linear-gradient(135deg, rgba(239, 68, 68, 0.1), var(--bg-card-subtle));
}
.veredicto-card.status-out .veredicto-icon-box {
  background: rgba(239, 68, 68, 0.2);
  color: var(--danger);
}
.veredicto-card.status-out .veredicto-badge {
  background: rgba(239, 68, 68, 0.2);
  color: var(--danger);
}

/* Termómetro de Umbrales */
.thermo-card {
  background: var(--bg-card-subtle);
  border: 1px solid var(--border-color);
  border-radius: 14px;
  padding: 1.5rem;
  margin-bottom: 1.75rem;
}

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

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

.thermo-legend {
  font-family: var(--font-mono);
  font-size: 0.9rem;
  color: var(--text-secondary);
  font-weight: 600;
}

.thermo-track-wrapper {
  padding: 1.5rem 0 1rem;
}

.thermo-track {
  display: flex;
  height: 28px;
  border-radius: 14px;
  overflow: visible;
  position: relative;
  background: #1e293b;
  border: 1px solid var(--border-color);
}

.thermo-segment {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 0.85rem;
  position: relative;
  font-size: 0.75rem;
  font-weight: 700;
  color: #ffffff;
}

.seg-u1 {
  background: linear-gradient(90deg, #059669, #10b981);
  border-radius: 13px 0 0 13px;
  flex: 3;
}

.seg-u2 {
  background: linear-gradient(90deg, #2563eb, #3b82f6);
  flex: 3.5;
}

.seg-u3 {
  background: linear-gradient(90deg, #d97706, #f59e0b);
  flex: 1.5;
}

.seg-out {
  background: linear-gradient(90deg, #dc2626, #ef4444);
  border-radius: 0 13px 13px 0;
  flex: 2;
  justify-content: center;
}

.seg-label {
  white-space: nowrap;
}

.seg-limit {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  opacity: 0.9;
}

/* Aguja del Termómetro */
.thermo-needle {
  position: absolute;
  top: -12px;
  width: 4px;
  height: 48px;
  background: #ffffff;
  box-shadow: 0 0 10px rgba(255, 255, 255, 0.8), 0 0 20px rgba(59, 130, 246, 0.6);
  border-radius: 2px;
  transform: translateX(-50%);
  transition: left 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
  z-index: 10;
}

.needle-bubble {
  position: absolute;
  top: -30px;
  left: 50%;
  transform: translateX(-50%);
  background: #ffffff;
  color: #0f172a;
  padding: 0.2rem 0.65rem;
  border-radius: 6px;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 700;
  white-space: nowrap;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
}

.needle-arrow {
  position: absolute;
  bottom: -6px;
  left: 50%;
  transform: translateX(-50%);
  width: 0;
  height: 0;
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-top: 6px solid #ffffff;
}

.thermo-explanation {
  margin-top: 1rem;
  font-size: 0.875rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

/* Desglose de Cuantías (Cheque) */
.grant-breakdown-card {
  background: var(--bg-card-subtle);
  border: 1px solid var(--border-color);
  border-radius: 14px;
  padding: 1.5rem;
  margin-bottom: 1.75rem;
}

.breakdown-header {
  margin-bottom: 1.25rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border-color);
}

.breakdown-title {
  font-size: 1.15rem;
  color: var(--text-primary);
  margin-bottom: 0.25rem;
}

.breakdown-subtitle {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.grant-items-list {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  margin-bottom: 1.5rem;
}

.grant-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.85rem 1rem;
  border-radius: 10px;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  transition: transform 0.2s;
}

.grant-row:hover {
  transform: translateX(4px);
}

.grant-row-info {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.grant-row-icon {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--primary-glow);
  color: var(--primary);
  flex-shrink: 0;
}

.grant-row-names {
  display: flex;
  flex-direction: column;
}

.grant-row-title {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-primary);
}

.grant-row-desc {
  font-size: 0.78rem;
  color: var(--text-muted);
}

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

.grant-row-amount.granted {
  color: var(--success);
}

.grant-row-amount.zero {
  color: var(--text-muted);
}

/* Total Box */
.grant-total-box {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 1.5rem;
  border-radius: 12px;
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.15), rgba(139, 92, 246, 0.15));
  border: 1px solid rgba(59, 130, 246, 0.3);
}

.total-info {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.total-label {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-primary);
}

.total-subtext {
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.total-amount {
  font-family: var(--font-mono);
  font-size: 2.1rem;
  font-weight: 800;
  color: var(--primary);
}

/* Patrimonio Card */
.patrimonio-card {
  background: rgba(245, 158, 11, 0.08);
  border: 1px solid rgba(245, 158, 11, 0.25);
  border-radius: 12px;
  padding: 1.25rem 1.5rem;
  margin-bottom: 1.75rem;
}

.patrimonio-header {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  color: var(--warning);
  margin-bottom: 0.6rem;
}

.patrimonio-card p {
  font-size: 0.875rem;
  color: var(--text-secondary);
  line-height: 1.5;
  margin-bottom: 0.65rem;
}

.patrimonio-list {
  padding-left: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.patrimonio-list li {
  font-size: 0.85rem;
  color: var(--text-secondary);
}

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

/* Barra de Acciones */
.results-action-bar {
  display: flex;
  gap: 1rem;
}

.btn-action {
  flex: 1;
}

/* Modales */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(5px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  z-index: 9999;
}

.modal-box {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  max-width: 520px;
  width: 100%;
  padding: 1.75rem;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.6);
  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;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}

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

.modal-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  color: var(--text-muted);
  cursor: pointer;
  line-height: 1;
}

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

.modal-body p {
  margin-bottom: 0.75rem;
}

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

.modal-body ul {
  padding-left: 1.25rem;
  margin-top: 0.5rem;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
}

/* ==========================================================================
   Responsive & Mobile (Reglas Estrictas Canónicas)
   ========================================================================== */

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

@media (max-width: 768px) {
  .tool-layout {
    padding: 0 0.75rem;
    margin: 1rem auto 2rem;
  }

  .card-main {
    padding: 1.5rem 1rem;
    border-radius: 14px;
  }

  .card-title {
    font-size: 1.45rem;
  }

  .inputs-grid-2,
  .inputs-grid-3,
  .deductions-grid {
    grid-template-columns: 1fr;
  }

  .form-actions {
    flex-direction: column;
  }

  .btn-calc,
  .btn-reset,
  .btn-action {
    width: 100%;
    min-height: 48px;
  }

  .results-action-bar {
    flex-direction: column;
  }

  .thermo-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
  }

  .thermo-segment .seg-limit {
    display: none;
  }

  .grant-total-box {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.75rem;
  }

  .total-amount {
    font-size: 1.85rem;
  }
}

/* Oculto en pantalla estándar */
.print-mec-header {
  display: none;
}

/* ================================================================
   DICTAMEN OFICIAL IMPRIMIBLE • BECA GENERAL MEC (RD 163/2025)
   Exclusivo para @media print / generación PDF limpia
   ================================================================ */
@media print {
  @page {
    size: A4 portrait;
    margin: 10mm 12mm 10mm 12mm;
  }

  html, body {
    background: #ffffff !important;
    color: #111111 !important;
    font-size: 9pt !important;
    line-height: 1.35 !important;
    width: 100% !important;
    height: auto !important;
    margin: 0 !important;
    padding: 0 !important;
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }

  /* Ocultar elementos interactivos, publicidad, encabezado web y formulario */
  .app-header,
  .tools-ad-banner-section,
  .tool-ad-sidebar,
  .fijate-footer,
  .card-header-hero,
  .calculator-form,
  .form-actions,
  .results-action-bar,
  .results-divider,
  .btn-tooltip-trigger,
  .seo-guide-card,
  .modal-overlay {
    display: none !important;
  }

  .main-wrapper,
  .tool-layout,
  .tool-with-sidebar,
  .tool-main-content {
    display: block !important;
    width: 100% !important;
    max-width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
    border: none !important;
    box-shadow: none !important;
  }

  .card-main {
    border: none !important;
    box-shadow: none !important;
    padding: 0 !important;
    background: transparent !important;
  }

  .results-area {
    display: block !important;
    margin: 0 !important;
    padding: 0 !important;
  }

  /* Cabecera oficial del dictamen en papel */
  .print-mec-header {
    display: block !important;
    border-bottom: 2px solid #111111;
    padding-bottom: 8px;
    margin-bottom: 12px;
  }

  .print-doc-title-row {
    display: flex !important;
    justify-content: space-between !important;
    align-items: flex-start !important;
    margin-bottom: 8px !important;
  }

  .print-brand-badge {
    font-size: 8pt !important;
    font-weight: 700 !important;
    color: #444444 !important;
    text-transform: uppercase !important;
    letter-spacing: 0.5px !important;
    border: 1px solid #777777 !important;
    padding: 2px 6px !important;
    border-radius: 3px !important;
  }

  .print-doc-titles {
    text-align: right !important;
  }

  .print-doc-h1 {
    font-family: 'Outfit', sans-serif !important;
    font-size: 13pt !important;
    font-weight: 800 !important;
    color: #000000 !important;
    margin: 0 0 2px 0 !important;
    letter-spacing: -0.2px !important;
  }

  .print-doc-law {
    font-size: 7.5pt !important;
    color: #444444 !important;
    margin: 0 !important;
    font-style: italic !important;
  }

  .print-meta-box {
    margin-top: 8px !important;
  }

  .print-meta-table {
    width: 100% !important;
    border-collapse: collapse !important;
    font-size: 8pt !important;
    border: 1px solid #222222 !important;
  }

  .print-meta-table td {
    padding: 4px 8px !important;
    border: 1px solid #cccccc !important;
    color: #111111 !important;
  }

  /* Tarjeta de Veredicto */
  .veredicto-card {
    border: 1.5px solid #222222 !important;
    box-shadow: none !important;
    padding: 10px 14px !important;
    margin-bottom: 12px !important;
    background: #f8fafc !important;
    page-break-inside: avoid;
    break-inside: avoid;
  }

  .veredicto-title {
    font-size: 11pt !important;
    color: #000000 !important;
  }

  .veredicto-desc {
    font-size: 8pt !important;
    color: #333333 !important;
    line-height: 1.35 !important;
  }

  /* Termómetro */
  .thermo-card {
    border: 1px solid #cccccc !important;
    box-shadow: none !important;
    padding: 10px 12px !important;
    margin-bottom: 12px !important;
    page-break-inside: avoid;
    break-inside: avoid;
  }

  .thermo-title {
    font-size: 9pt !important;
  }

  .thermo-legend {
    font-size: 8pt !important;
    color: #222222 !important;
  }

  .thermo-track {
    border: 1px solid #444444 !important;
    height: 32px !important;
  }

  .seg-label {
    font-size: 7pt !important;
  }

  .seg-limit {
    font-size: 6.8pt !important;
  }

  .thermo-explanation {
    font-size: 7.5pt !important;
    line-height: 1.3 !important;
    color: #333333 !important;
  }

  /* Cheque de Cuantías */
  .grant-breakdown-card {
    border: 1px solid #cccccc !important;
    box-shadow: none !important;
    padding: 10px 12px !important;
    margin-bottom: 12px !important;
    page-break-inside: avoid;
    break-inside: avoid;
  }

  .breakdown-title {
    font-size: 9.5pt !important;
  }

  .grant-row {
    border: 1px solid #e2e8f0 !important;
    background: #ffffff !important;
    padding: 6px 10px !important;
    margin-bottom: 6px !important;
  }

  .grant-row-title {
    font-size: 8.5pt !important;
  }

  .grant-row-desc {
    font-size: 7pt !important;
  }

  .grant-row-amount {
    font-size: 9pt !important;
  }

  .grant-total-box {
    border: 2px solid #000000 !important;
    background: #f1f5f9 !important;
    padding: 8px 12px !important;
    margin-top: 10px !important;
  }

  .total-label {
    font-size: 8pt !important;
  }

  .total-amount {
    font-size: 13pt !important;
    color: #000000 !important;
  }

  /* Requisitos de patrimonio */
  .patrimonio-card {
    border: 1px solid #cccccc !important;
    background: #ffffff !important;
    padding: 8px 12px !important;
    page-break-inside: avoid;
    break-inside: avoid;
  }

  .patrimonio-card h4 {
    font-size: 8pt !important;
  }

  .patrimonio-card p {
    font-size: 7pt !important;
    margin-bottom: 4px !important;
  }

  .patrimonio-list li {
    font-size: 6.8pt !important;
    line-height: 1.3 !important;
  }
}
