:root {
  --navy: #252A34;
  --brand: #3A9F7C;
  --brand-press: #2e8267;
  --cream: #F7F5EF;
  --cream-deep: #EFE9DA;
  --cool-gray: #EAEAEA;
  --ink: #14171d;
  --text-strong: #1c212a;
  --text-body: #545b66;
  --text-muted: #8a8f98;
  --text-on-brand: #ffffff;
  --white: #ffffff;
  --border-subtle: rgba(37,42,52,0.12);
  --radius-lg: 16px;
  --radius-sm: 8px;
  --radius-pill: 999px;
  --shadow-lg: 0 20px 44px rgba(20,23,29,0.18);
  --font-body: 'Poppins', sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font-body);
  background: var(--cream);
  color: var(--text-strong);
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; }

.calc-topbar {
  background: var(--navy);
  color: var(--white);
  padding: 18px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.calc-topbar .marca {
  font-weight: 600;
  letter-spacing: 0.02em;
  font-size: 0.95rem;
}

.calc-topbar .marca span { color: var(--brand); }

.calc-topbar a.volver {
  font-size: 0.8rem;
  color: rgba(255,255,255,0.75);
  text-decoration: none;
}

.calc-shell {
  max-width: 720px;
  margin: 0 auto;
  padding: 32px 20px 64px;
}

.calc-card {
  background: var(--white);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-subtle);
  box-shadow: var(--shadow-lg);
  padding: 28px 26px;
  margin-bottom: 20px;
}

.calc-card h1 {
  font-size: 1.35rem;
  margin: 0 0 4px;
  color: var(--navy);
}

.calc-card h2 {
  font-size: 1.05rem;
  margin: 0 0 14px;
  color: var(--navy);
}

.calc-sub {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin: 0 0 22px;
}

.campo {
  margin-bottom: 16px;
}

.campo label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--navy);
  margin-bottom: 6px;
}

.campo .ayuda {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-top: 4px;
}

.campo input[type="text"],
.campo input[type="password"],
.campo input[type="number"],
.campo input[type="date"],
.campo select {
  width: 100%;
  padding: 11px 13px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
  font-family: var(--font-body);
  font-size: 0.92rem;
  background: var(--cream);
  color: var(--text-strong);
}

.campo input:focus, .campo select:focus {
  outline: none;
  border-color: var(--brand);
  background: var(--white);
}

.fila-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.radio-grupo {
  display: flex;
  gap: 18px;
}

.radio-grupo label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-strong);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: var(--navy);
  color: var(--white);
  border: none;
  border-radius: var(--radius-pill);
  padding: 13px 24px;
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 0.92rem;
  cursor: pointer;
  transition: background 160ms ease;
  width: 100%;
}

.btn:hover { background: var(--brand); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.error-msg {
  background: #fdecec;
  color: #b33a3a;
  border: 1px solid #f3c8c8;
  border-radius: var(--radius-sm);
  padding: 10px 13px;
  font-size: 0.82rem;
  margin-bottom: 16px;
}

.resultado-tabla {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}

.resultado-tabla tr {
  border-bottom: 1px solid var(--border-subtle);
}

.resultado-tabla tr:last-child { border-bottom: none; }

.resultado-tabla td {
  padding: 10px 0;
}

.resultado-tabla td.label { color: var(--text-body); }

.resultado-tabla td.valor {
  text-align: right;
  font-weight: 600;
  color: var(--navy);
  font-variant-numeric: tabular-nums;
}

.resultado-tabla tr.destacado td {
  color: var(--brand-press);
  font-size: 1.05rem;
}

.resultado-tabla tr.destacado td.valor { color: var(--brand); }

.lista-calculadoras {
  display: grid;
  gap: 12px;
}

.lista-calculadoras a {
  display: block;
  background: var(--white);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 16px 18px;
  text-decoration: none;
  transition: border-color 160ms ease;
}

.lista-calculadoras a:hover { border-color: var(--brand); }

.lista-calculadoras .nombre {
  font-weight: 600;
  color: var(--navy);
  font-size: 0.95rem;
}

.lista-calculadoras .desc {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 3px;
}

.lista-calculadoras .proximamente {
  opacity: 0.5;
  pointer-events: none;
}

.cargando {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 60vh;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.detalle-texto {
  font-size: 0.85rem;
  line-height: 1.7;
  color: var(--text-body);
}

.detalle-texto .seccion {
  font-weight: 600;
  color: var(--navy);
  margin: 18px 0 6px;
}

.detalle-texto .seccion:first-child { margin-top: 0; }

.detalle-texto .linea {
  padding-left: 14px;
  position: relative;
}

.detalle-texto .linea::before {
  content: "•";
  position: absolute;
  left: 0;
  color: var(--brand);
}

.detalle-texto .total {
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid var(--border-subtle);
  font-weight: 700;
  color: var(--brand-press);
  font-size: 1rem;
}

.calc-shell--ancho {
  max-width: 1180px;
}

.tabla-periodos-wrap {
  overflow-x: auto;
  margin-bottom: 6px;
}

.tabla-periodos {
  width: 100%;
  min-width: 920px;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.tabla-periodos th {
  text-align: left;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--text-muted);
  padding: 6px;
  border-bottom: 2px solid var(--border-subtle);
  white-space: nowrap;
}

.tabla-periodos td {
  padding: 6px;
  border-bottom: 1px solid var(--border-subtle);
  vertical-align: middle;
}

.tabla-periodos tr.fila-totales td {
  font-weight: 700;
  color: var(--navy);
  border-bottom: none;
  border-top: 2px solid var(--border-subtle);
  padding-top: 12px;
  white-space: nowrap;
}

.tabla-periodos input[type="text"],
.tabla-periodos input[type="number"] {
  width: 100%;
  min-width: 96px;
  padding: 8px 9px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
  font-family: var(--font-body);
  font-size: 0.85rem;
  background: var(--cream);
  color: var(--text-strong);
}

.tabla-periodos input:focus {
  outline: none;
  border-color: var(--brand);
  background: var(--white);
}

.tabla-periodos td.celda-calculada {
  color: var(--text-body);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.badge-estado {
  display: inline-block;
  padding: 3px 9px;
  border-radius: var(--radius-pill);
  font-size: 0.7rem;
  font-weight: 600;
  white-space: nowrap;
}

.badge-estado.completo { background: #e5f3ee; color: var(--brand-press); }
.badge-estado.recortado { background: #fff8e6; color: #8a6d1d; }
.badge-estado.no-usado { background: var(--cool-gray); color: var(--text-muted); }
.badge-estado.vacio { background: var(--cool-gray); color: var(--text-muted); }

.btn-quitar-fila {
  background: none;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  color: #b33a3a;
  padding: 6px 10px;
  font-family: var(--font-body);
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

.btn-quitar-fila:hover { background: #fdecec; }

.periodos-lista {
  margin-bottom: 6px;
}

.periodo-fila {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr auto;
  gap: 10px;
  align-items: end;
  margin-bottom: 14px;
  padding-bottom: 14px;
  border-bottom: 1px dashed var(--border-subtle);
}

.periodo-fila:last-child {
  border-bottom: none;
  margin-bottom: 0;
  padding-bottom: 0;
}

.periodo-fila .campo { margin-bottom: 0; }

.btn-quitar {
  background: none;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  width: 40px;
  height: 40px;
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  flex-shrink: 0;
}

.btn-quitar:hover { border-color: #b33a3a; color: #b33a3a; }

.btn-secundario {
  display: block;
  background: none;
  border: 1px dashed var(--brand);
  color: var(--brand-press);
  border-radius: var(--radius-pill);
  padding: 10px 20px;
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 0.85rem;
  cursor: pointer;
  width: 100%;
  margin: 6px 0 20px;
}

.btn-secundario:hover { background: var(--cream-deep); }

.aviso-msg {
  background: #fff8e6;
  color: #8a6d1d;
  border: 1px solid #f0dfa8;
  border-radius: var(--radius-sm);
  padding: 10px 13px;
  font-size: 0.82rem;
  margin-bottom: 16px;
}

.enlace-siguiente {
  display: inline-block;
  margin-top: 16px;
  font-size: 0.85rem;
  color: var(--brand-press);
  font-weight: 600;
  text-decoration: none;
}

.enlace-siguiente:hover { text-decoration: underline; }

.print-header {
  display: none;
}

.print-footer {
  display: none;
}

@media print {
  .calc-topbar, #form-calc, .btn, .enlace-siguiente { display: none !important; }
  .print-header {
    display: block;
    margin-bottom: 18px;
    padding-bottom: 14px;
    border-bottom: 2px solid var(--navy);
  }
  .print-header .marca { font-weight: 700; color: var(--navy); font-size: 1.1rem; }
  .print-header .datos { font-size: 0.85rem; color: var(--text-muted); margin-top: 4px; }
  .calc-shell { max-width: 100%; padding: 0 0 40px; }
  .calc-card { box-shadow: none; border: none; padding: 0; margin-bottom: 24px; }
  body { background: var(--white); }
  .print-footer {
    display: block;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    text-align: center;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    padding: 8px 0;
    border-top: 1px solid var(--border-subtle);
    background: var(--white);
  }
}
