/* ==========================================================================
   Oráculo — components.css
   Tarjetas, botones, formularios, tablas, modales, heatmap, ranking.
   ========================================================================== */

/* ==========================================================================
   Card
   ========================================================================== */

.card {
  background: var(--surface-glass);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  backdrop-filter: blur(12px);
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  min-width: 0;
  animation: fade-up 340ms cubic-bezier(0.16, 1, 0.3, 1) both;
}

.card__head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 15px 18px;
  border-bottom: 1px solid var(--border);
}
.card__head h2, .card__head h3 { display: flex; align-items: center; gap: 9px; }
.card__head i.lead { color: var(--gold); font-size: 18px; }
.card__head .tools { margin-left: auto; display: flex; align-items: center; gap: 8px; }

.card__body { padding: 18px; flex: 1 1 auto; min-width: 0; }
.card__body--flush { padding: 0; }
.card__foot {
  padding: 12px 18px;
  border-top: 1px solid var(--border);
  color: var(--text-3);
  font-size: 0.76rem;
}

.card--accent { border-color: rgba(245, 196, 81, 0.28); }
.card--accent .card__head { background: linear-gradient(90deg, var(--gold-soft), transparent); }

/* ==========================================================================
   Botones
   ========================================================================== */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 38px;
  padding: 0 15px;
  border-radius: 10px;
  border: 1px solid var(--border-strong);
  background: var(--surface-2);
  color: var(--text);
  font-size: 0.84rem;
  font-weight: 600;
  white-space: nowrap;
  transition: background var(--fast), border-color var(--fast), transform var(--fast), color var(--fast);
}
.btn i { font-size: 17px; }
.btn:hover { background: var(--surface-3); border-color: rgba(255, 255, 255, 0.22); }
.btn:active { transform: translateY(1px); }
.btn[disabled] { opacity: 0.45; pointer-events: none; }

.btn--primary {
  background: linear-gradient(140deg, var(--gold), #E6A93A);
  border-color: transparent;
  color: #1A1206;
  box-shadow: 0 6px 18px rgba(245, 196, 81, 0.22);
}
.btn--primary:hover { filter: brightness(1.07); background: linear-gradient(140deg, var(--gold), #E6A93A); }

.btn--cyan {
  background: linear-gradient(140deg, var(--cyan), #23B3A4);
  border-color: transparent;
  color: #04201C;
}
.btn--cyan:hover { filter: brightness(1.07); }

.btn--ghost { background: transparent; border-color: var(--border); color: var(--text-2); }
.btn--ghost:hover { background: rgba(255, 255, 255, 0.05); color: var(--text); }

.btn--danger { background: var(--danger-soft); border-color: rgba(255, 107, 107, 0.32); color: var(--danger); }
.btn--danger:hover { background: rgba(255, 107, 107, 0.22); }

.btn--sm { height: 31px; padding: 0 11px; font-size: 0.78rem; border-radius: 8px; }
.btn--sm i { font-size: 15px; }
.btn--icon { width: 38px; padding: 0; }
.btn--icon.btn--sm { width: 31px; }
.btn--block { width: 100%; }

/* Botón de acción en tabla */
.icon-btn {
  width: 30px; height: 30px;
  display: inline-grid; place-items: center;
  border-radius: 8px;
  color: var(--text-2);
  transition: background var(--fast), color var(--fast);
}
.icon-btn i { font-size: 17px; }
.icon-btn:hover { background: var(--surface-3); color: var(--text); }
.icon-btn--danger:hover { background: var(--danger-soft); color: var(--danger); }

/* Grupo segmentado */
.segmented {
  display: inline-flex;
  padding: 3px;
  gap: 2px;
  border-radius: 10px;
  background: var(--surface-2);
  border: 1px solid var(--border);
}
.segmented button {
  padding: 5px 13px;
  border-radius: 7px;
  font-size: 0.79rem;
  font-weight: 600;
  color: var(--text-2);
  transition: background var(--fast), color var(--fast);
}
.segmented button:hover { color: var(--text); }
.segmented button.is-active { background: var(--surface-3); color: var(--gold); }

/* ==========================================================================
   Formularios
   ========================================================================== */

.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > label { font-size: 0.78rem; font-weight: 600; color: var(--text-2); }
.field__hint { font-size: 0.72rem; color: var(--text-3); }
.field__error { font-size: 0.74rem; color: var(--danger); display: flex; align-items: center; gap: 5px; }
.field__error i { font-size: 14px; }

.input, .select, .textarea {
  height: 38px;
  padding: 0 12px;
  border-radius: 10px;
  background: var(--bg-deep);
  border: 1px solid var(--border-strong);
  color: var(--text);
  font-size: 0.86rem;
  width: 100%;
  transition: border-color var(--fast), box-shadow var(--fast);
}
.textarea { height: auto; padding: 10px 12px; resize: vertical; min-height: 74px; line-height: 1.5; }
.input:focus, .select:focus, .textarea:focus {
  outline: none;
  border-color: var(--gold);
  box-shadow: 0 0 0 3px var(--gold-soft);
}
.input::placeholder { color: var(--text-3); }
.input.is-invalid, .select.is-invalid { border-color: var(--danger); box-shadow: 0 0 0 3px var(--danger-soft); }

.select {
  appearance: none;
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='%239BA9BC'%3E%3Cpath d='M8 11 3.5 6.5 4.56 5.44 8 8.88l3.44-3.44L12.5 6.5z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 16px;
  padding-right: 32px;
  cursor: pointer;
}
.select option { background: var(--surface-2); color: var(--text); }

.input-icon { position: relative; display: flex; align-items: center; }
.input-icon > i {
  position: absolute; left: 11px;
  font-size: 17px; color: var(--text-3); pointer-events: none;
}
.input-icon .input { padding-left: 35px; }

.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; }
.form-grid .full { grid-column: 1 / -1; }
@media (max-width: 640px) { .form-grid { grid-template-columns: 1fr; } }

/* Checkbox / switch */
.switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; user-select: none; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch__track {
  width: 42px; height: 24px;
  border-radius: 99px;
  background: var(--surface-3);
  border: 1px solid var(--border-strong);
  position: relative;
  transition: background var(--fast), border-color var(--fast);
  flex: 0 0 42px;
}
.switch__track::after {
  content: "";
  position: absolute;
  top: 2px; left: 2px;
  width: 18px; height: 18px;
  border-radius: 50%;
  background: var(--text-2);
  transition: transform var(--fast), background var(--fast);
}
.switch input:checked + .switch__track { background: var(--gold-soft); border-color: var(--gold); }
.switch input:checked + .switch__track::after { transform: translateX(18px); background: var(--gold); }
.switch input:focus-visible + .switch__track { box-shadow: 0 0 0 3px var(--gold-soft); }

.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; }
.check input[type="checkbox"] {
  appearance: none;
  width: 17px; height: 17px;
  border-radius: 5px;
  border: 1.5px solid var(--border-strong);
  background: var(--bg-deep);
  display: grid; place-items: center;
  cursor: pointer;
  transition: background var(--fast), border-color var(--fast);
  flex: 0 0 17px;
}
.check input[type="checkbox"]::after {
  content: "";
  width: 9px; height: 9px;
  clip-path: polygon(14% 44%, 0 60%, 39% 100%, 100% 22%, 84% 8%, 39% 68%);
  background: #1A1206;
  transform: scale(0);
  transition: transform var(--fast);
}
.check input[type="checkbox"]:checked { background: var(--gold); border-color: var(--gold); }
.check input[type="checkbox"]:checked::after { transform: scale(1); }

/* Chips de selección múltiple */
.chips { display: flex; flex-wrap: wrap; gap: 7px; }
.chip-toggle {
  padding: 5px 12px;
  border-radius: 99px;
  border: 1px solid var(--border-strong);
  background: var(--surface-2);
  color: var(--text-2);
  font-size: 0.78rem;
  font-weight: 600;
  transition: all var(--fast);
}
.chip-toggle:hover { border-color: var(--gold); color: var(--text); }
.chip-toggle.is-on { background: var(--gold-soft); border-color: var(--gold); color: var(--gold); }

/* Selector de color */
.swatches { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.swatch {
  width: 26px; height: 26px;
  border-radius: 8px;
  border: 2px solid transparent;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.3);
  transition: transform var(--fast), border-color var(--fast);
}
.swatch:hover { transform: scale(1.12); }
.swatch.is-on { border-color: var(--text); transform: scale(1.12); }
.swatch-native {
  width: 34px; height: 30px;
  padding: 2px;
  border-radius: 8px;
  background: var(--bg-deep);
  border: 1px solid var(--border-strong);
  cursor: pointer;
}

/* Slider de pesos */
.slider-row { display: grid; grid-template-columns: 128px 1fr 52px; align-items: center; gap: 12px; }
.slider-row > label { font-size: 0.8rem; color: var(--text-2); display: flex; align-items: center; gap: 7px; }
.slider-row > label i { font-size: 15px; color: var(--text-3); }
.slider-row output { font-size: 0.8rem; font-weight: 650; color: var(--gold); text-align: right; }

input[type="range"] {
  appearance: none;
  width: 100%;
  height: 5px;
  border-radius: 99px;
  background: var(--surface-3);
  cursor: pointer;
}
input[type="range"]::-webkit-slider-thumb {
  appearance: none;
  width: 16px; height: 16px;
  border-radius: 50%;
  background: var(--gold);
  border: 3px solid var(--bg);
  box-shadow: 0 0 0 1px var(--gold);
  transition: transform var(--fast);
}
input[type="range"]::-webkit-slider-thumb:hover { transform: scale(1.18); }
input[type="range"]::-moz-range-thumb {
  width: 14px; height: 14px;
  border-radius: 50%;
  background: var(--gold);
  border: 3px solid var(--bg);
  box-shadow: 0 0 0 1px var(--gold);
  cursor: pointer;
}

/* ==========================================================================
   Badges y chips
   ========================================================================== */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 9px;
  border-radius: 99px;
  font-size: 0.72rem;
  font-weight: 650;
  line-height: 1.6;
  border: 1px solid transparent;
  white-space: nowrap;
}
.badge i { font-size: 13px; }
.badge--ok     { background: var(--ok-soft);     color: var(--ok);     border-color: rgba(61, 220, 151, 0.28); }
.badge--warn   { background: var(--warn-soft);   color: var(--warn);   border-color: rgba(255, 180, 84, 0.28); }
.badge--danger { background: var(--danger-soft); color: var(--danger); border-color: rgba(255, 107, 107, 0.28); }
.badge--info   { background: var(--info-soft);   color: var(--info);   border-color: rgba(90, 169, 255, 0.28); }
.badge--gold   { background: var(--gold-soft);   color: var(--gold);   border-color: rgba(245, 196, 81, 0.28); }
.badge--mute   { background: var(--surface-3);   color: var(--text-2); border-color: var(--border); }

/* Chip de serial: hereda su color por variable inline --c */
.serial-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 3px 11px 3px 5px;
  border-radius: 99px;
  background: color-mix(in srgb, var(--c, var(--gold)) 14%, transparent);
  border: 1px solid color-mix(in srgb, var(--c, var(--gold)) 38%, transparent);
  color: var(--c, var(--gold));
  font-size: 0.76rem;
  font-weight: 650;
  white-space: nowrap;
}
.serial-chip__dot {
  width: 16px; height: 16px;
  border-radius: 50%;
  background: var(--c, var(--gold));
  flex: 0 0 16px;
}
.serial-chip--lg { font-size: 0.86rem; padding: 5px 14px 5px 6px; }
.serial-chip--lg .serial-chip__dot { width: 20px; height: 20px; flex-basis: 20px; }

.dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--c, var(--text-3));
  display: inline-block;
  flex: 0 0 10px;
}

/* ==========================================================================
   KPIs
   ========================================================================== */

/* auto-fit para que la misma clase sirva con 4 o con 5 tarjetas */
.kpi-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(198px, 1fr));
  gap: var(--gap);
}
@media (max-width: 440px) { .kpi-row { grid-template-columns: 1fr; } }

.kpi {
  position: relative;
  overflow: hidden;
  padding: 16px 18px;
  border-radius: var(--radius);
  background: var(--surface-glass);
  border: 1px solid var(--border);
  backdrop-filter: blur(12px);
  display: flex;
  flex-direction: column;
  gap: 5px;
  animation: fade-up 340ms cubic-bezier(0.16, 1, 0.3, 1) both;
  transition: border-color var(--fast), transform var(--fast);
}
.kpi:hover { border-color: var(--border-strong); transform: translateY(-2px); }
.kpi::after {
  content: "";
  position: absolute;
  right: -28px; top: -28px;
  width: 96px; height: 96px;
  border-radius: 50%;
  background: var(--k, var(--gold));
  opacity: 0.08;
}
.kpi__label { font-size: 0.72rem; color: var(--text-3); text-transform: uppercase; letter-spacing: 0.09em; font-weight: 600; }
.kpi__value { font-size: 1.72rem; font-weight: 700; letter-spacing: -0.03em; line-height: 1.12; color: var(--k, var(--text)); }
.kpi__value small { font-size: 0.95rem; font-weight: 600; opacity: 0.75; }
.kpi__meta { font-size: 0.75rem; color: var(--text-2); display: flex; align-items: center; gap: 6px; }
.kpi__meta i { font-size: 14px; }
.kpi__icon {
  position: absolute; right: 14px; bottom: 12px;
  font-size: 26px; color: var(--k, var(--gold)); opacity: 0.28;
}

/* ==========================================================================
   Predicción destacada
   ========================================================================== */

.hero-pred {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 22px;
  align-items: center;
}
@media (max-width: 640px) { .hero-pred { grid-template-columns: 1fr; justify-items: center; text-align: center; } }

.gauge { position: relative; width: 168px; height: 168px; flex: 0 0 168px; }
.gauge svg { transform: rotate(-90deg); width: 100%; height: 100%; }
.gauge__track { fill: none; stroke: var(--surface-3); stroke-width: 12; }
.gauge__fill {
  fill: none;
  stroke: var(--c, var(--gold));
  stroke-width: 12;
  stroke-linecap: round;
  transition: stroke-dashoffset 700ms cubic-bezier(0.16, 1, 0.3, 1);
  filter: drop-shadow(0 0 8px color-mix(in srgb, var(--c, var(--gold)) 55%, transparent));
}
.gauge__center {
  position: absolute; inset: 0;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 1px;
}
.gauge__pct { font-size: 2rem; font-weight: 750; letter-spacing: -0.04em; color: var(--c, var(--gold)); line-height: 1; }
.gauge__cap { font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.1em; color: var(--text-3); }

.pred__serial { font-size: 2.1rem; font-weight: 750; letter-spacing: -0.035em; line-height: 1.1; }
.pred__range { font-family: var(--mono); font-size: 0.95rem; color: var(--text-2); }

.hot-numbers { display: flex; gap: 8px; flex-wrap: wrap; }
.hot-number {
  display: grid; place-items: center;
  min-width: 46px; height: 46px;
  padding: 0 8px;
  border-radius: 12px;
  background: color-mix(in srgb, var(--c, var(--gold)) 13%, var(--surface-2));
  border: 1px solid color-mix(in srgb, var(--c, var(--gold)) 34%, transparent);
  font-family: var(--mono);
  font-size: 1.06rem;
  font-weight: 700;
  color: var(--c, var(--gold));
}
.hot-number small { display: block; font-size: 0.58rem; color: var(--text-3); font-family: var(--font); letter-spacing: 0.04em; }

/* Desglose "por qué" */
.factors { display: flex; flex-direction: column; gap: 9px; }
.factor { display: grid; grid-template-columns: 104px 1fr 44px; gap: 10px; align-items: center; font-size: 0.79rem; }
.factor__label { color: var(--text-2); display: flex; align-items: center; gap: 6px; }
.factor__label i { font-size: 14px; color: var(--text-3); }
.factor__bar { height: 6px; border-radius: 99px; background: var(--surface-3); overflow: hidden; }
.factor__fill { height: 100%; border-radius: 99px; background: var(--c, var(--cyan)); transition: width 600ms cubic-bezier(0.16, 1, 0.3, 1); }
.factor__val { text-align: right; font-weight: 650; color: var(--text-2); }

/* ==========================================================================
   Ranking
   ========================================================================== */

.rank-table { width: 100%; font-size: 0.84rem; }
.rank-table thead th {
  position: sticky; top: 0;
  background: var(--surface);
  padding: 10px 14px;
  text-align: left;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-3);
  font-weight: 650;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  z-index: 1;
}
.rank-table th.sortable { cursor: pointer; user-select: none; transition: color var(--fast); }
.rank-table th.sortable:hover { color: var(--text); }
.rank-table th.sortable::after { content: "\2195"; margin-left: 5px; opacity: 0.35; font-size: 0.85em; }
.rank-table th.sort-asc::after  { content: "\2191"; opacity: 1; color: var(--gold); }
.rank-table th.sort-desc::after { content: "\2193"; opacity: 1; color: var(--gold); }

.rank-table tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background var(--fast);
  cursor: pointer;
}
.rank-table tbody tr:hover { background: rgba(255, 255, 255, 0.035); }
.rank-table tbody tr:last-child { border-bottom: 0; }
.rank-table td { padding: 11px 14px; vertical-align: middle; }

.rank-pos {
  display: grid; place-items: center;
  width: 25px; height: 25px;
  border-radius: 8px;
  background: var(--surface-3);
  color: var(--text-2);
  font-size: 0.76rem;
  font-weight: 700;
}
.rank-pos--1 { background: linear-gradient(140deg, var(--gold), #E6A93A); color: #1A1206; }
.rank-pos--2 { background: #9FB0C4; color: #10151D; }
.rank-pos--3 { background: #C88B58; color: #1B1008; }

/* Barra de probabilidad con banda de confianza Wilson */
.prob-bar { position: relative; height: 22px; min-width: 120px; }
.prob-bar__track {
  position: absolute; inset: 7px 0;
  border-radius: 99px;
  background: var(--surface-3);
  overflow: hidden;
}
.prob-bar__fill {
  height: 100%;
  border-radius: 99px;
  background: linear-gradient(90deg, color-mix(in srgb, var(--c, var(--gold)) 62%, transparent), var(--c, var(--gold)));
  transition: width 550ms cubic-bezier(0.16, 1, 0.3, 1);
}
/* Intervalo de confianza al 95 % */
.prob-bar__ci {
  position: absolute; top: 4px; height: 14px;
  border-left: 1px solid var(--text-3);
  border-right: 1px solid var(--text-3);
}
.prob-bar__ci::before {
  content: "";
  position: absolute; top: 50%; left: 0; right: 0;
  height: 1px; background: var(--text-3); opacity: 0.65;
}
/* Marca de la probabilidad teórica 1/k */
.prob-bar__expected {
  position: absolute; top: 2px; bottom: 2px;
  width: 2px;
  background: repeating-linear-gradient(180deg, var(--text-2) 0 3px, transparent 3px 6px);
  opacity: 0.7;
}

.trend { display: inline-flex; align-items: center; gap: 4px; font-weight: 650; font-size: 0.78rem; }
.trend--up   { color: var(--ok); }
.trend--down { color: var(--danger); }
.trend--flat { color: var(--text-3); }

/* ==========================================================================
   Heatmap
   ========================================================================== */

.heatmap {
  display: grid;
  gap: 5px;
  grid-template-columns: repeat(10, minmax(0, 1fr));
}
.heat-cell {
  position: relative;
  aspect-ratio: 1;
  min-height: 30px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  font-family: var(--mono);
  font-size: 0.76rem;
  font-weight: 650;
  color: var(--text);
  background: color-mix(in srgb, var(--c, var(--gold)) calc(var(--i, 0) * 1%), var(--surface-2));
  border: 1px solid var(--border);
  cursor: pointer;
  transition: transform var(--fast), border-color var(--fast), box-shadow var(--fast);
}
.heat-cell:hover {
  transform: scale(1.14);
  z-index: 2;
  border-color: var(--c, var(--gold));
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.45);
}
.heat-cell.is-dim { opacity: 0.22; }
.heat-cell.is-top::after {
  content: "";
  position: absolute; top: 3px; right: 3px;
  width: 5px; height: 5px;
  border-radius: 50%;
  background: var(--text);
  box-shadow: 0 0 6px currentColor;
}
.heatmap--dense .heat-cell { min-height: 20px; font-size: 0.6rem; border-radius: 5px; }

.heat-legend { display: flex; align-items: center; gap: 10px; font-size: 0.73rem; color: var(--text-3); }
.heat-legend__scale {
  flex: 1 1 auto;
  height: 7px;
  border-radius: 99px;
  background: linear-gradient(90deg, var(--surface-2), var(--gold));
  max-width: 190px;
}

/* ==========================================================================
   Barra de cobertura de seriales
   ========================================================================== */

.coverage {
  display: flex;
  height: 38px;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--border-strong);
  background: repeating-linear-gradient(45deg, var(--surface-2) 0 7px, var(--bg-deep) 7px 14px);
}
.coverage__seg {
  display: grid;
  place-items: center;
  font-size: 0.7rem;
  font-weight: 700;
  color: #0B0E14;
  background: var(--c, var(--gold));
  border-right: 1px solid rgba(0, 0, 0, 0.35);
  overflow: hidden;
  white-space: nowrap;
  transition: filter var(--fast);
  cursor: default;
}
.coverage__seg:last-child { border-right: 0; }
.coverage__seg:hover { filter: brightness(1.18); }
.coverage__seg--gap {
  background: repeating-linear-gradient(45deg, rgba(255, 107, 107, 0.22) 0 6px, transparent 6px 12px);
  color: var(--danger);
  border-right: 1px dashed rgba(255, 107, 107, 0.5);
}
.coverage__seg--overlap {
  background: repeating-linear-gradient(45deg, rgba(255, 180, 84, 0.4) 0 6px, rgba(255, 180, 84, 0.12) 6px 12px);
  color: var(--warn);
}

/* ==========================================================================
   Tablas de datos (CRUD)
   ========================================================================== */

.table-wrap { overflow-x: auto; }

.data-table { width: 100%; font-size: 0.84rem; }
.data-table thead th {
  padding: 11px 14px;
  text-align: left;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-3);
  font-weight: 650;
  background: rgba(255, 255, 255, 0.018);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.data-table th.sortable { cursor: pointer; user-select: none; }
.data-table th.sortable:hover { color: var(--text); }
.data-table th.sortable::after { content: "\2195"; margin-left: 5px; opacity: 0.35; font-size: 0.85em; }
.data-table th.sort-asc::after  { content: "\2191"; opacity: 1; color: var(--gold); }
.data-table th.sort-desc::after { content: "\2193"; opacity: 1; color: var(--gold); }

.data-table tbody tr { border-bottom: 1px solid var(--border); transition: background var(--fast); }
.data-table tbody tr:hover { background: rgba(255, 255, 255, 0.032); }
.data-table tbody tr.is-selected { background: var(--gold-soft); }
.data-table tbody tr.is-inactive td:not(.actions) { opacity: 0.5; }
.data-table td { padding: 11px 14px; vertical-align: middle; }
.data-table td.actions { text-align: right; white-space: nowrap; }
.data-table .col-tight { width: 1%; white-space: nowrap; }

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 46px 20px;
  text-align: center;
  color: var(--text-3);
}
.empty-state i { font-size: 42px; opacity: 0.45; }
.empty-state h3 { color: var(--text-2); font-weight: 600; }

.toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
}
.toolbar .grow { flex: 1 1 220px; }

.pagination {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 18px;
  border-top: 1px solid var(--border);
  font-size: 0.79rem;
  color: var(--text-2);
  flex-wrap: wrap;
}
.pagination .pages { margin-left: auto; display: flex; gap: 4px; align-items: center; }
.page-btn {
  min-width: 30px; height: 30px;
  padding: 0 8px;
  border-radius: 8px;
  color: var(--text-2);
  font-size: 0.79rem;
  font-weight: 600;
  transition: background var(--fast), color var(--fast);
}
.page-btn:hover { background: var(--surface-3); color: var(--text); }
.page-btn.is-active { background: var(--gold-soft); color: var(--gold); }
.page-btn[disabled] { opacity: 0.35; pointer-events: none; }

/* ==========================================================================
   Modales
   ========================================================================== */

.modal-backdrop {
  position: fixed; inset: 0;
  z-index: 90;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 22px;
  background: rgba(4, 6, 11, 0.72);
  backdrop-filter: blur(4px);
  animation: fade-in var(--fast) both;
}

.modal {
  width: 100%;
  max-width: 620px;
  max-height: calc(100vh - 44px);
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  animation: pop 220ms cubic-bezier(0.16, 1, 0.3, 1) both;
  overflow: hidden;
}
.modal--sm { max-width: 440px; }
.modal--lg { max-width: 880px; }

.modal__head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 18px 22px;
  border-bottom: 1px solid var(--border);
}
.modal__head h2 { font-size: 1.05rem; display: flex; align-items: center; gap: 10px; }
.modal__head h2 i { color: var(--gold); font-size: 20px; }
.modal__head .close { margin-left: auto; }

.modal__body { padding: 22px; overflow-y: auto; display: flex; flex-direction: column; gap: 16px; }
.modal__foot {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 15px 22px;
  border-top: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.18);
}
.modal__foot .spacer { margin-left: auto; }

/* Aviso dentro de modal / página */
.notice {
  display: flex;
  gap: 11px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  background: var(--info-soft);
  border: 1px solid rgba(90, 169, 255, 0.26);
  color: var(--text-2);
  font-size: 0.79rem;
  line-height: 1.55;
}
.notice i { font-size: 18px; color: var(--info); flex: 0 0 18px; margin-top: 1px; }
.notice strong { color: var(--text); }
.notice--warn   { background: var(--warn-soft);   border-color: rgba(255, 180, 84, 0.26); }
.notice--warn i { color: var(--warn); }
.notice--danger { background: var(--danger-soft); border-color: rgba(255, 107, 107, 0.26); }
.notice--danger i { color: var(--danger); }
.notice--ok     { background: var(--ok-soft);     border-color: rgba(61, 220, 151, 0.26); }
.notice--ok i   { color: var(--ok); }

/* Vista previa de generación de seriales */
.preview-list {
  display: flex; flex-wrap: wrap; gap: 6px;
  max-height: 156px; overflow-y: auto;
  padding: 12px;
  border-radius: var(--radius-sm);
  background: var(--bg-deep);
  border: 1px solid var(--border);
}
.preview-pill {
  padding: 3px 9px;
  border-radius: 7px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  font-family: var(--mono);
  font-size: 0.73rem;
  color: var(--text-2);
}
.preview-pill b { color: var(--gold); font-weight: 700; }

/* ==========================================================================
   Gráficos
   ========================================================================== */

.chart-box { position: relative; height: 260px; width: 100%; }
.chart-box--tall { height: 320px; }
.chart-box--sm { height: 170px; }

/* ==========================================================================
   Simulador
   ========================================================================== */

/* Controles a la izquierda, resultados a la derecha; una columna en móvil. */
.grid--sim { grid-template-columns: 340px minmax(0, 1fr); gap: 22px; }
/* Dos columnas iguales para el detalle de serial. */
.grid--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
@media (max-width: 820px) {
  .grid--sim, .grid--2 { grid-template-columns: 1fr; }
}

.progress {
  height: 8px;
  border-radius: 99px;
  background: var(--surface-3);
  overflow: hidden;
}
.progress__fill {
  height: 100%;
  border-radius: 99px;
  background: linear-gradient(90deg, var(--cyan), var(--gold));
  width: 0;
  transition: width 90ms linear;
}

.sim-result {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}
@media (max-width: 600px) { .sim-result { grid-template-columns: 1fr; } }

.sim-stat {
  padding: 13px 15px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-left: 3px solid var(--c, var(--text-3));
}
.sim-stat__label { font-size: 0.72rem; color: var(--text-3); text-transform: uppercase; letter-spacing: 0.08em; font-weight: 600; }
.sim-stat__value { font-size: 1.42rem; font-weight: 700; color: var(--c, var(--text)); letter-spacing: -0.025em; }
.sim-stat__meta  { font-size: 0.73rem; color: var(--text-2); }

/* ==========================================================================
   Detalle de serial
   ========================================================================== */

.timeline { display: flex; flex-wrap: wrap; gap: 6px; }
.timeline__item {
  padding: 5px 10px;
  border-radius: 8px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  font-size: 0.75rem;
  display: flex;
  align-items: center;
  gap: 7px;
}
.timeline__item b { font-family: var(--mono); color: var(--c, var(--gold)); }

.stat-line { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; padding: 7px 0; border-bottom: 1px dashed var(--border); }
.stat-line:last-child { border-bottom: 0; }
.stat-line dt { color: var(--text-2); font-size: 0.8rem; }
.stat-line dd { margin: 0; font-weight: 650; font-size: 0.86rem; }

/* ==========================================================================
   Toast (Toastify)
   ========================================================================== */

.toastify {
  border-radius: 12px !important;
  font-family: var(--font) !important;
  font-size: 0.85rem !important;
  font-weight: 600 !important;
  box-shadow: var(--shadow) !important;
  padding: 12px 18px !important;
  border: 1px solid var(--border-strong) !important;
}

/* Tippy oscuro */
.tippy-box[data-theme~="oraculo"] {
  background: var(--surface-3);
  color: var(--text);
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  font-size: 0.78rem;
  box-shadow: var(--shadow);
}
.tippy-box[data-theme~="oraculo"] .tippy-arrow { color: var(--surface-3); }
.tippy-box[data-theme~="oraculo"] .tippy-content { padding: 8px 11px; line-height: 1.5; }

/* ==========================================================================
   Modo simple
   Vista en lenguaje llano: una sola recomendación, sin jerga estadística.
   ========================================================================== */

/* El conmutador decide qué se ve; las secciones técnicas no se destruyen,
   solo se ocultan, para poder volver al modo avanzado sin recargar. */
.page.es-simple [data-avanzado] { display: none; }
.page:not(.es-simple) [data-simple] { display: none; }

.simple {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr);
  gap: var(--gap);
}
@media (max-width: 940px) { .simple { grid-template-columns: 1fr; } }

/* --- Tarjeta principal --- */

.simple-hero {
  position: relative;
  overflow: hidden;
  padding: 28px;
  border-radius: var(--radius-lg);
  background:
    radial-gradient(520px 300px at 88% -30%, color-mix(in srgb, var(--c, var(--gold)) 22%, transparent), transparent 70%),
    var(--surface-glass);
  border: 1px solid color-mix(in srgb, var(--c, var(--gold)) 32%, var(--border));
  backdrop-filter: blur(12px);
  animation: fade-up 380ms cubic-bezier(0.16, 1, 0.3, 1) both;
}

.simple-hero__serial {
  font-size: clamp(3.2rem, 9vw, 4.6rem);
  font-weight: 800;
  letter-spacing: -0.05em;
  line-height: 0.95;
  color: var(--c, var(--gold));
}

.simple-hero__rango {
  font-size: 1.28rem;
  font-weight: 650;
  color: var(--text);
  margin-top: 2px;
}

.simple-hero__frase {
  font-size: 1rem;
  line-height: 1.65;
  color: var(--text-2);
  max-width: 52ch;
}
.simple-hero__frase b { color: var(--text); font-weight: 700; }

/* --- Semáforo de confianza --- */

.semaforo {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  padding: 7px 15px 7px 9px;
  border-radius: 99px;
  background: color-mix(in srgb, var(--sc) 14%, transparent);
  border: 1px solid color-mix(in srgb, var(--sc) 40%, transparent);
  color: var(--sc);
  font-weight: 700;
  font-size: 0.86rem;
}
.semaforo__luces { display: flex; gap: 4px; }
.semaforo__luz {
  width: 9px; height: 9px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.2;
}
.semaforo__luz.is-on { opacity: 1; box-shadow: 0 0 9px currentColor; }

.semaforo--alta  { --sc: var(--ok); }
.semaforo--media { --sc: var(--warn); }
.semaforo--baja  { --sc: var(--text-3); }

/* --- Números sugeridos --- */

.simple-numeros { display: flex; gap: 12px; flex-wrap: wrap; }

.simple-numero {
  display: grid;
  place-items: center;
  min-width: 74px;
  padding: 14px 12px;
  border-radius: 16px;
  background: color-mix(in srgb, var(--c, var(--gold)) 15%, var(--surface-2));
  border: 1px solid color-mix(in srgb, var(--c, var(--gold)) 38%, transparent);
  font-family: var(--mono);
  font-size: 1.9rem;
  font-weight: 750;
  line-height: 1;
  color: var(--c, var(--gold));
}
.simple-numero small {
  display: block;
  margin-top: 6px;
  font-family: var(--font);
  font-size: 0.66rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  color: var(--text-3);
}

/* --- Motivos --- */

.motivos { display: flex; flex-direction: column; gap: 11px; }

.motivo {
  display: grid;
  grid-template-columns: 24px 1fr;
  gap: 11px;
  align-items: start;
  font-size: 0.89rem;
  line-height: 1.5;
  color: var(--text-2);
}
.motivo b { color: var(--text); font-weight: 650; }
.motivo__icono {
  width: 24px; height: 24px;
  display: grid; place-items: center;
  border-radius: 50%;
  font-size: 15px;
}
.motivo--si   .motivo__icono { background: var(--ok-soft);     color: var(--ok); }
.motivo--no   .motivo__icono { background: var(--surface-3);   color: var(--text-3); }
.motivo--ojo  .motivo__icono { background: var(--warn-soft);   color: var(--warn); }

/* --- Alternativas --- */

.alternativa {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 14px;
  align-items: center;
  padding: 14px 16px;
  border-radius: var(--radius);
  background: var(--surface-2);
  border: 1px solid var(--border);
  transition: border-color var(--fast), transform var(--fast);
  cursor: pointer;
  width: 100%;
  text-align: left;
}
.alternativa:hover { border-color: var(--c, var(--gold)); transform: translateX(3px); }

.alternativa__pos {
  display: grid; place-items: center;
  width: 30px; height: 30px;
  border-radius: 10px;
  background: color-mix(in srgb, var(--c, var(--gold)) 18%, transparent);
  color: var(--c, var(--gold));
  font-weight: 750;
  font-size: 0.82rem;
}
.alternativa__nombre { font-weight: 700; color: var(--text); }
.alternativa__rango { font-family: var(--mono); font-size: 0.78rem; color: var(--text-3); }
.alternativa__dato { text-align: right; font-size: 0.8rem; color: var(--text-2); }
.alternativa__dato b { display: block; font-size: 1rem; color: var(--c, var(--gold)); }

/* --- Aviso honesto del modo simple --- */

.simple-aviso {
  display: flex;
  gap: 14px;
  padding: 18px 20px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--warn);
  font-size: 0.86rem;
  line-height: 1.6;
  color: var(--text-2);
}
.simple-aviso i { font-size: 24px; color: var(--warn); flex: 0 0 24px; }
.simple-aviso b { color: var(--text); }
