/* ============================================================================
   NuevaIA · nv3-consumo.css — HISTORIAL DE CONSUMO DE CRÉDITOS   (I4)
   ----------------------------------------------------------------------------
   Va DESPUÉS de nv3-design.css, que es quien declara los tokens --nv-* (§17).
   Aquí no hay ni un color fijo: todo sale de esas variables, así que la hoja
   funciona igual en claro y en oscuro y no puede haber claro sobre claro.

   Contraste (WCAG AA, medido sobre los tokens de nv3-design.css §17):
     texto principal  --nv-text   sobre --nv-surface : 16,1:1 claro / 12,6:1 oscuro
     texto secundario --nv-text-2 sobre --nv-surface :  4,82:1 claro /  5,51:1 oscuro
     acento en texto  --nv-accent-txt sobre --nv-surface: 6,70:1 / 6,65:1
     blanco sobre --nv-accent-solid: 6,70:1 en los dos temas
   Ningún texto de esta hoja usa otra combinación.
   ========================================================================= */

.nv3c {
  display: flex;
  flex-direction: column;
  gap: 18px;
  color: var(--nv-text);
  font-size: 14px;
}

/* ---------- cabecera ---------- */
.nv3c-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 12px; flex-wrap: wrap;
}
.nv3c-h3 { margin: 0; font-size: 1.05rem; font-weight: 700; color: var(--nv-text); }
.nv3c-h4 { margin: 0 0 10px; font-size: .82rem; font-weight: 700; letter-spacing: .02em;
  text-transform: uppercase; color: var(--nv-text-2); }
.nv3c-sub { margin: 4px 0 0; font-size: .84rem; color: var(--nv-text-2); max-width: 62ch; }

/* ---------- botones ---------- */
.nv3c-btn {
  appearance: none; cursor: pointer;
  padding: 8px 14px; border-radius: 10px;
  border: 1px solid var(--nv-border);
  background: var(--nv-surface); color: var(--nv-text);
  font: inherit; font-size: .82rem; font-weight: 600;
  transition: background .15s ease, border-color .15s ease;
}
.nv3c-btn:hover { background: var(--nv-surface-2); border-color: var(--nv-accent-line); }
.nv3c-btn:disabled { opacity: .6; cursor: default; }
.nv3c-btn:focus-visible,
.nv3c-chip:focus-visible,
.nv3c-mini:focus-visible,
.nv3c-barra:focus-visible { outline: 2px solid var(--nv-accent); outline-offset: 2px; }
.nv3c-btn-sutil { background: transparent; color: var(--nv-text-2); }
.nv3c-btn-sutil:hover { color: var(--nv-text); }

/* ---------- resumen (hoy / semana / mes / total) ---------- */
.nv3c-resumen {
  display: grid; gap: 10px;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
}
.nv3c-tarjeta {
  display: flex; flex-direction: column; gap: 2px;
  padding: 14px 16px; border-radius: 14px;
  border: 1px solid var(--nv-border); background: var(--nv-surface);
}
.nv3c-et { font-size: .74rem; font-weight: 600; letter-spacing: .02em;
  text-transform: uppercase; color: var(--nv-text-2); }
.nv3c-num { font-size: 1.55rem; font-weight: 800; line-height: 1.15;
  color: var(--nv-text); font-variant-numeric: tabular-nums; }
.nv3c-uni { font-size: .74rem; color: var(--nv-text-2); }
.nv3c-tarjeta-ok { border-color: var(--nv-accent-line); background: var(--nv-accent-soft); }
.nv3c-tarjeta-ok .nv3c-num { color: var(--nv-accent-txt); }
/* Sobre el fondo tenue del acento, --nv-text-2 se queda en 4,38:1 (medido).
   --nv-text-3 sube a 10:1 en claro y 8,9:1 en oscuro: es el que va aquí. */
.nv3c-tarjeta-ok .nv3c-et,
.nv3c-tarjeta-ok .nv3c-uni { color: var(--nv-text-3); }

/* ---------- desglose por tipo ---------- */
.nv3c-desglose {
  padding: 16px; border-radius: 14px;
  border: 1px solid var(--nv-border); background: var(--nv-surface);
}
.nv3c-barras { display: flex; flex-direction: column; gap: 6px; }
.nv3c-barra {
  display: grid; align-items: center; gap: 10px;
  grid-template-columns: 22px minmax(90px, 1.2fr) minmax(60px, 2fr) auto 42px;
  width: 100%; padding: 7px 8px; border-radius: 10px;
  border: 1px solid transparent; background: transparent;
  color: var(--nv-text); font: inherit; font-size: .84rem;
  text-align: left; cursor: pointer;
}
.nv3c-barra:hover { background: var(--nv-surface-2); }
.nv3c-barra.nv3c-on { border-color: var(--nv-accent-line); background: var(--nv-accent-soft); }
.nv3c-barra-ic { color: var(--nv-text-2); display: inline-flex; }
.nv3c-barra-ic svg { width: 17px; height: 17px; }
.nv3c-barra-tx { color: var(--nv-text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nv3c-barra-pista { height: 7px; border-radius: 99px; background: var(--nv-border-2);
  border: 1px solid var(--nv-border); overflow: hidden; }
.nv3c-barra-pista i { display: block; height: 100%; background: var(--nv-accent); }
.nv3c-barra-n { font-weight: 700; font-variant-numeric: tabular-nums; color: var(--nv-text); }
.nv3c-barra-p { font-size: .76rem; color: var(--nv-text-2); text-align: right;
  font-variant-numeric: tabular-nums; }
.nv3c-vacio-min { margin: 0; font-size: .84rem; color: var(--nv-text-2); }

/* ---------- filtros ---------- */
.nv3c-filtros { display: flex; flex-direction: column; gap: 10px; }
.nv3c-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.nv3c-chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 12px; border-radius: 99px;
  border: 1px solid var(--nv-border); background: var(--nv-surface);
  color: var(--nv-text-3); font: inherit; font-size: .8rem; font-weight: 600;
  cursor: pointer; white-space: nowrap;
}
.nv3c-chip svg { width: 15px; height: 15px; opacity: .9; }
.nv3c-chip:hover { background: var(--nv-surface-2); color: var(--nv-text); }
.nv3c-chip.nv3c-on {
  background: var(--nv-accent-solid); border-color: var(--nv-accent-solid);
  color: #FFFFFF;   /* único literal de la hoja: el texto DEL botón sólido (6,70:1) */
}
.nv3c-rango { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px; }
.nv3c-campo { display: flex; flex-direction: column; gap: 4px; }
.nv3c-campo span { font-size: .74rem; font-weight: 600; color: var(--nv-text-2); }
.nv3c-campo input {
  padding: 7px 10px; border-radius: 10px;
  border: 1px solid var(--nv-border); background: var(--nv-surface-2);
  color: var(--nv-text); font: inherit; font-size: .82rem;
  color-scheme: light dark;   /* el calendario nativo sigue al tema */
}
.nv3c-campo input:focus { outline: 2px solid var(--nv-accent); outline-offset: 1px; }
.nv3c-atajos { display: flex; flex-wrap: wrap; gap: 6px; }
.nv3c-mini {
  padding: 5px 10px; border-radius: 8px;
  border: 1px solid var(--nv-border); background: transparent;
  color: var(--nv-text-2); font: inherit; font-size: .76rem; font-weight: 600; cursor: pointer;
}
.nv3c-mini:hover { color: var(--nv-text); background: var(--nv-surface-2); }
.nv3c-mini.nv3c-on { color: var(--nv-accent-txt); border-color: var(--nv-accent-line);
  background: var(--nv-accent-soft); }

/* ---------- lista ---------- */
.nv3c-lista { display: flex; flex-direction: column; gap: 4px; }
.nv3c-dia {
  margin: 14px 0 4px; font-size: .74rem; font-weight: 700; letter-spacing: .04em;
  text-transform: uppercase; color: var(--nv-text-2);
}
.nv3c-lista .nv3c-dia:first-child { margin-top: 0; }
.nv3c-item {
  display: grid; align-items: center; gap: 12px;
  grid-template-columns: 34px minmax(0, 1fr) auto auto;
  padding: 10px 12px; border-radius: 12px;
  border: 1px solid var(--nv-border); background: var(--nv-surface);
}
.nv3c-item-ic {
  width: 34px; height: 34px; border-radius: 10px;
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--nv-border); background: var(--nv-surface-2);
  color: var(--nv-text-2);
}
.nv3c-item-ic svg { width: 17px; height: 17px; }
.nv3c-item-tx { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.nv3c-item-tx b { font-size: .87rem; font-weight: 600; color: var(--nv-text);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nv3c-item-tx small { font-size: .76rem; color: var(--nv-text-2);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nv3c-item-cat {
  font-size: .72rem; font-weight: 600; color: var(--nv-text-2);
  padding: 3px 9px; border-radius: 99px;
  border: 1px solid var(--nv-border); background: var(--nv-surface-2); white-space: nowrap;
}
.nv3c-item-n {
  font-size: .9rem; font-weight: 800; color: var(--nv-text);
  font-variant-numeric: tabular-nums; white-space: nowrap;
}
.nv3c-item.nv3c-ing .nv3c-item-n { color: var(--nv-accent-txt); }
.nv3c-item.nv3c-ing .nv3c-item-ic { color: var(--nv-accent-txt);
  border-color: var(--nv-accent-line); background: var(--nv-accent-soft); }

/* esqueleto de carga: usa los mismos tokens, nunca gris quemado */
.nv3c-esq b, .nv3c-esq small, .nv3c-esq .nv3c-item-ic, .nv3c-esq .nv3c-item-n {
  background: var(--nv-border-2); border-radius: 6px; color: transparent;
  animation: nv3c-lat 1.4s ease-in-out infinite;
}
.nv3c-esq b { height: 11px; width: 55%; }
.nv3c-esq small { height: 9px; width: 35%; }
.nv3c-esq .nv3c-item-n { height: 14px; width: 54px; }
@keyframes nv3c-lat { 0%, 100% { opacity: .55 } 50% { opacity: 1 } }
@media (prefers-reduced-motion: reduce) { .nv3c-esq b, .nv3c-esq small,
  .nv3c-esq .nv3c-item-ic, .nv3c-esq .nv3c-item-n { animation: none } }

/* ---------- vacío y error ---------- */
.nv3c-vacio {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 34px 18px; border-radius: 14px;
  border: 1px dashed var(--nv-border); background: var(--nv-surface);
  text-align: center;
}
.nv3c-vacio svg { width: 26px; height: 26px; color: var(--nv-text-2); opacity: .7; }
.nv3c-vacio b { font-size: .92rem; color: var(--nv-text); }
.nv3c-vacio span { font-size: .82rem; color: var(--nv-text-2); max-width: 42ch; }
.nv3c-error {
  margin: 0; padding: 14px 16px; border-radius: 12px;
  border: 1px solid var(--nv-border); background: var(--nv-surface-2);
  color: var(--nv-text); font-size: .85rem;
}

/* ---------- pie ---------- */
.nv3c-pie { display: flex; align-items: center; justify-content: space-between;
  gap: 12px; flex-wrap: wrap; }
.nv3c-conteo { font-size: .78rem; color: var(--nv-text-2); font-variant-numeric: tabular-nums; }

/* ---------- 360 px ---------- */
@media (max-width: 560px) {
  .nv3c-item { grid-template-columns: 30px minmax(0, 1fr) auto; }
  .nv3c-item-ic { width: 30px; height: 30px; }
  .nv3c-item-cat { display: none; }           /* el concepto ya dice el tipo */
  .nv3c-barra { grid-template-columns: 20px minmax(0, 1fr) auto; }
  .nv3c-barra-pista { display: none; }
  .nv3c-num { font-size: 1.32rem; }
  .nv3c-head { flex-direction: column; align-items: stretch; }
}

/* ---------- convivencia con la pantalla vieja de movimientos ---------------
   Mientras el historial nuevo esté montado, la lista heredada
   (#mov-filter-chips + #movimientos-list-container, que siguen en el DOM con
   sus ids y sus handlers intactos) se oculta: dos historiales uno encima del
   otro confunden. Si nv3-consumo.js no cargara, esta clase nunca se pone y
   la pantalla vieja se ve como siempre.                                     */
body.nv3c-activo #n3-movs-legacy { display: none; }
