:root {
  --azul: #1e3a8a;
  --azul-claro: #2563eb;
  --verde: #16a34a;
  --rojo: #dc2626;
  --gris-100: #f4f6f9;
  --gris-300: #d7dee7;
  --gris-600: #5b6b7f;
  --texto: #0b0b0b;
  --texto-secundario: #52514e;
  --texto-muted: #898781;
  --radio: 12px;

  /* Paleta categorica del grafico (orden fijo, validado para daltonismo) */
  --serie-1: #2a78d6; /* azul */
  --serie-2: #eb6834; /* naranja */
  --serie-3: #1baf7a; /* aqua */
  --serie-4: #eda100; /* amarillo/dorado */
  --serie-5: #e87ba4; /* magenta */
  --serie-banco: #94938c; /* gris neutro, no compite como serie */
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, 'Segoe UI', Arial, sans-serif;
  color: var(--texto);
  background: #fff;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--azul-claro); }

header.site-header {
  background: var(--azul);
  color: #fff;
  padding: 14px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.12);
}

header.site-header .logo {
  font-size: 1.3rem;
  font-weight: 800;
  color: #fff;
  text-decoration: none;
  letter-spacing: -0.01em;
}

header.site-header nav {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

header.site-header nav a {
  color: #dbe4f5;
  text-decoration: none;
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 0.92rem;
  font-weight: 500;
  transition: background 0.15s, color 0.15s;
}

header.site-header nav a:hover { color: #fff; background: rgba(255, 255, 255, 0.12); }

.hero {
  background: linear-gradient(135deg, var(--azul) 0%, var(--azul-claro) 100%);
  color: #fff;
  padding: 52px 24px 68px;
  text-align: center;
}

.hero h1 { font-size: 2.1rem; margin-bottom: 12px; line-height: 1.25; letter-spacing: -0.01em; }
.hero p { max-width: 720px; margin: 0 auto; color: #e3ecfb; font-size: 1.08rem; }

main { max-width: 1100px; margin: 0 auto; padding: 0 20px; }

.calculadora {
  background: #fff;
  border: 1px solid var(--gris-300);
  border-radius: var(--radio);
  padding: 30px;
  margin-top: -40px;
  box-shadow: 0 16px 40px rgba(20, 40, 80, 0.12);
  position: relative;
}

.calculadora h2 { margin-top: 0; font-size: 1.3rem; }

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
}

.form-grid label {
  display: block;
  font-weight: 600;
  font-size: 0.88rem;
  margin-bottom: 6px;
  color: var(--texto-secundario);
}

.form-grid input, .form-grid select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--gris-300);
  border-radius: 8px;
  font-size: 0.95rem;
  font-family: inherit;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.form-grid input:focus, .form-grid select:focus,
#picker-search:focus {
  outline: none;
  border-color: var(--azul-claro);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.picker {
  margin-top: 22px;
  border: 1px solid var(--gris-300);
  border-radius: 10px;
  padding: 16px;
  background: #fbfcfe;
}

.picker-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.picker-top input { padding: 9px 12px; border: 1px solid var(--gris-300); border-radius: 8px; flex: 1; min-width: 180px; background: #fff; }

#picker-count {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--azul-claro);
  white-space: nowrap;
  background: #eaf1fd;
  padding: 4px 10px;
  border-radius: 999px;
}

.picker-list {
  max-height: 300px;
  overflow-y: auto;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 4px 20px;
}

.picker-group h4 {
  margin: 12px 0 4px;
  font-size: 0.78rem;
  text-transform: uppercase;
  color: var(--texto-muted);
  letter-spacing: 0.05em;
  font-weight: 700;
}

.picker-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 6px;
  border-radius: 6px;
  font-size: 0.92rem;
  cursor: pointer;
  transition: background 0.12s;
}

.picker-row:hover { background: #eef2fb; }
.picker-row small { color: var(--texto-muted); }
.no-cotiza { color: var(--rojo); margin-left: 6px; }

.submit-row { margin-top: 22px; text-align: right; }

button#submit-btn {
  background: var(--azul-claro);
  color: #fff;
  border: none;
  padding: 13px 30px;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(37, 99, 235, 0.35);
  transition: background 0.15s, transform 0.1s;
}

button#submit-btn:disabled { opacity: 0.6; cursor: wait; box-shadow: none; }
button#submit-btn:hover:not(:disabled) { background: var(--azul); }
button#submit-btn:active:not(:disabled) { transform: translateY(1px); }

.errores-box {
  display: none;
  margin-top: 16px;
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #991b1b;
  padding: 12px 16px;
  border-radius: 8px;
  font-size: 0.9rem;
}

#resultados { display: none; margin: 44px 0; }
#resultados h2 { font-size: 1.4rem; }

.winner-banner {
  background: linear-gradient(135deg, #ecfdf5 0%, #d1fae5 100%);
  border: 1px solid #a7f3d0;
  color: #065f46;
  padding: 16px 20px;
  border-radius: 10px;
  font-size: 1.08rem;
  font-weight: 500;
  margin-bottom: 22px;
  box-shadow: 0 4px 14px rgba(6, 95, 70, 0.08);
}

.winner-banner strong { font-weight: 700; }

.tabla-wrap {
  overflow-x: auto;
  border: 1px solid var(--gris-300);
  border-radius: 10px;
}

table.resultados {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
  min-width: 640px;
}

table.resultados th, table.resultados td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--gris-300);
  text-align: left;
  white-space: nowrap;
}

table.resultados th {
  background: var(--gris-100);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--texto-secundario);
}

table.resultados td:first-child { white-space: normal; min-width: 200px; }
table.resultados tbody tr:hover { background: #f8fafc; }
table.resultados tbody tr:last-child td { border-bottom: none; }
.fila-banco { background: #f8fafc; font-style: italic; }
.fila-banco:hover { background: #f1f5f9 !important; }
.positivo { color: var(--verde); font-weight: 700; font-variant-numeric: tabular-nums; }
.negativo { color: var(--rojo); font-weight: 700; font-variant-numeric: tabular-nums; }
table.resultados td:nth-child(3), table.resultados td:nth-child(4) { font-variant-numeric: tabular-nums; }

.chart-wrap {
  margin-top: 30px;
  background: #fcfcfb;
  padding: 20px 16px 12px;
  border: 1px solid var(--gris-300);
  border-radius: 12px;
  box-shadow: 0 6px 20px rgba(20, 40, 80, 0.06);
}

.chart-canvas-wrap {
  position: relative;
  width: 100%;
  height: 340px;
}

section.contenido {
  margin: 56px 0;
  padding-top: 24px;
  border-top: 1px solid var(--gris-300);
}

section.contenido h2 { color: var(--azul); }

.disclaimer {
  background: #fffbeb;
  border: 1px solid #fde68a;
  color: #78350f;
  padding: 14px 18px;
  border-radius: 10px;
  font-size: 0.88rem;
  margin: 34px 0;
}

footer.site-footer {
  background: #0f172a;
  color: #cbd5e1;
  margin-top: 64px;
  padding: 32px 24px;
  font-size: 0.88rem;
}

footer.site-footer .footer-inner {
  max-width: 1100px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
}

footer.site-footer a { color: #93c5fd; margin-right: 14px; text-decoration: none; }
footer.site-footer a:hover { text-decoration: underline; }

.page-content {
  max-width: 800px;
  margin: 40px auto;
  padding: 0 20px 40px;
}

.page-content h1 { color: var(--azul); }
.page-content h2 { margin-top: 30px; }

@media (max-width: 700px) {
  .chart-canvas-wrap { height: 300px; }
}

@media (max-width: 600px) {
  header.site-header { padding: 12px 16px; }
  header.site-header nav a { padding: 5px 8px; font-size: 0.86rem; }
  .hero { padding: 36px 16px 50px; }
  .hero h1 { font-size: 1.55rem; }
  .hero p { font-size: 0.98rem; }
  .calculadora { padding: 20px 16px; margin-top: -30px; }
  .submit-row { text-align: stretch; }
  button#submit-btn { width: 100%; }
  .chart-wrap { padding: 14px 8px 8px; }
  .chart-canvas-wrap { height: 280px; }
  .winner-banner { font-size: 0.96rem; padding: 14px 16px; }
}
