/* SJV | LABELED · estilos propios. Colores, radios y espacios SOLO por tokens de vendor/sjv-design/tokens.css.
   Nada translúcido, sin opacity < 1 ni filter en bloques; «oculto» = color muted opaco + tachado.
   Móvil 375 px primero; PC desde 1024 px con grilla de 12 columnas y 1280 px. */

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--fg);
  /* espacio para la barra fija de «Copiar nombre» */
  padding: 0 var(--s-4) calc(120px + env(safe-area-inset-bottom));
}
h1, h2, p, ol, ul { margin: 0; }
ol, ul { padding: 0; list-style: none; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; -webkit-tap-highlight-color: transparent; }
button:disabled { cursor: default; }
kbd { font-family: var(--font-mono); font-size: 12px; color: var(--muted); }

.mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.num { font-variant-numeric: tabular-nums; }
.ico { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }

:focus-visible { outline: 2px solid var(--link); outline-offset: 2px; }
.sjv-input:focus-visible { outline: 2px solid var(--link); outline-offset: 2px; }

.solo-lector { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.saltar { position: absolute; left: var(--s-4); top: -64px; z-index: 60; background: var(--accent); color: var(--accent-fg); padding: var(--s-3) var(--s-4); border-radius: var(--radius-md); text-decoration: none; }
.saltar:focus { top: var(--s-2); }
[hidden] { display: none !important; }
.portapapeles { position: fixed; top: 0; left: -9999px; width: 1px; height: 1px; }

/* ------------------------------------------------------------------ página */

.barra {
  max-width: var(--mobile-max);
  margin: 0 auto;
  min-height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-3);
}
.barra .sjv-wordmark { margin: 0; }

.tema { grid-auto-columns: 44px; }
.tema button { height: 44px; display: grid; place-items: center; color: var(--muted); }
.tema button[aria-pressed="true"] { color: var(--fg); }

.grilla {
  max-width: var(--mobile-max);
  margin: 0 auto;
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: var(--s-3);
  align-items: start;
}
@media (min-width: 768px) { .grilla { align-items: stretch; } .pila { align-content: start; } }
.grilla:focus { outline: none; }
.col { grid-column: span 12; min-width: 0; }
.pila { display: grid; gap: var(--s-3); }

@media (min-width: 768px) {
  .barra, .grilla { max-width: var(--content-max); }
  body { padding-left: var(--s-6); padding-right: var(--s-6); }
  .col-md-6 { grid-column: span 6; }
}

@media (min-width: 1024px) {
  body { padding: 0 var(--s-8) var(--s-8); }
  .barra { min-height: 80px; }
  .grilla { gap: var(--s-4); }
  .col-8 { grid-column: span 8; }
  .col-4 { grid-column: span 4; }
  .col-12 { grid-column: span 12; }
  .pila { gap: var(--s-4); }
}

/* ------------------------------------------------------------------ cabecera de tarjeta */

.sjv-card { display: grid; gap: var(--s-4); align-content: start; }
.cab { display: flex; align-items: flex-start; gap: var(--s-3); min-width: 0; }
.cab__disco { flex: none; width: 36px; height: 36px; background: var(--bg); }
.cab__texto { flex: 1; min-width: 0; padding-top: 2px; }
.cab__titulo { font-size: 17px; font-weight: 600; line-height: 1.25; text-wrap: balance; }
.cab__desc { font-size: 13px; color: var(--muted); margin-top: 2px; text-wrap: pretty; }
.cab__der { display: flex; align-items: center; gap: var(--s-1); flex: none; }

/* ------------------------------------------------------------------ Hero */

.hero { gap: var(--s-2); padding: var(--s-5) var(--s-4) var(--s-4); }
.hero__nombre {
  display: block;
  font: 600 20px/1.35 var(--font-mono);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
  overflow-wrap: break-word;
  min-height: 2.7em;
  color: var(--hero-fg);
}
.hero__vacio { font-size: 15px; color: var(--hero-muted); min-height: 2.7em; }
.hero .sjv-hero__row > div { min-width: 0; }
.hero .sjv-hero__row span { display: block; }
.hero .sjv-hero__row .apagado span, .hero .sjv-hero__row .apagado b { color: var(--hero-muted); text-decoration: line-through; }

@media (min-width: 1024px) {
  .hero { padding: var(--s-6); }
  .hero__nombre { font-size: 28px; line-height: 1.3; }
}

/* ------------------------------------------------------------------ Aviso de compatibilidad */

.aviso { background: var(--card); border-radius: var(--radius-lg); padding: var(--s-4); display: grid; gap: var(--s-2); }
.aviso__cab { display: flex; align-items: center; gap: var(--s-2); }
.aviso__ico { color: var(--aviso); }
.aviso__titulo { font-size: 15px; font-weight: 600; }
.aviso__lista { display: grid; gap: var(--s-1); padding-left: var(--s-6); list-style: disc; font-size: 13px; color: var(--fg-2); }
.aviso__lista li::marker { color: var(--aviso); }
.aviso__nota { font-size: 13px; color: var(--muted); }
.aviso__compatible { font-size: 15px; overflow-wrap: anywhere; padding: var(--s-2) var(--s-3); background: var(--bg); border-radius: var(--radius-md); }
.aviso .sjv-pill { justify-self: start; }

/* ------------------------------------------------------------------ acciones y barra fija */

.acciones { display: grid; gap: var(--s-3); }
.acciones__copiar { display: none; }
.acciones__nota { font-size: 13px; color: var(--muted); margin-top: var(--s-2); text-align: center; }
.acciones__guardar { min-height: 52px; }

.barra-copiar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 40;
  background: var(--bg);
  padding: var(--s-3) var(--s-4) calc(var(--s-3) + env(safe-area-inset-bottom));
  box-shadow: 0 -1px 0 var(--line);
}
.barra-copiar__dentro { max-width: var(--mobile-max); margin: 0 auto; display: grid; gap: var(--s-1); }
.barra-copiar__nota { font-size: 12px; color: var(--muted); text-align: center; }

@media (min-width: 1024px) {
  .barra-copiar { display: none; }
  .acciones { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); align-items: start; }
  .acciones__copiar { display: block; }
}

.sjv-btn { min-height: 52px; }
.sjv-btn:disabled { opacity: 1; background: var(--track); color: var(--muted); }

/* Pills: 44 px de alto (área táctil), sobre una tarjeta van en `track`. */
.sjv-pill { min-height: 44px; transition: transform .1s ease-out; }
.sjv-pill:active:not(:disabled) { transform: scale(.98); }
.sjv-pill:disabled { background: var(--track); color: var(--muted); }
.pill-track { background: var(--track); }
.pill-accent { background: var(--accent); color: var(--accent-fg); }
.pill-chica { padding: 0 var(--s-3); }
.fila-botones { display: flex; flex-wrap: wrap; gap: var(--s-2); }

/* ------------------------------------------------------------------ controles */

.ojo, .icono-btn {
  width: 44px; height: 44px; flex: none;
  border: 0; border-radius: var(--radius-pill);
  background: transparent; color: var(--fg);
  display: grid; place-items: center;
  transition: transform .1s ease-out;
}
.ojo:active, .icono-btn:active:not(:disabled) { transform: scale(.95); }
.ojo--apagado { color: var(--muted); }
.icono-btn:disabled { color: var(--faint); }
.icono-btn--peligro { color: var(--gasto); }
.icono-btn--peligro:disabled { color: var(--faint); }

.stepper { display: inline-flex; align-items: center; gap: var(--s-1); flex: none; }
.stepper__btn {
  width: 44px; height: 44px; border: 0; border-radius: var(--radius-pill);
  background: var(--track); color: var(--fg); display: grid; place-items: center;
  transition: transform .1s ease-out;
}
.stepper__btn:active:not(:disabled) { transform: scale(.95); }
.stepper__btn:disabled { color: var(--faint); }
.stepper__valor, .stepper__input {
  min-width: 56px; width: 72px; height: 44px; text-align: center;
  font: 600 17px/44px var(--font-mono); font-variant-numeric: tabular-nums;
}
.stepper__input { border: 0; border-radius: var(--radius-md); background: var(--bg); color: var(--fg); padding: 0 var(--s-1); }

.campo { display: grid; gap: 6px; }
.campo__cab { display: flex; align-items: center; justify-content: space-between; margin: -6px 0 -6px; }
.campo .sjv-input { background: var(--bg); }

.lista { display: grid; }
.lista > * + * { border-top: 1px solid var(--line); }
.fila { display: flex; align-items: center; gap: var(--s-2); min-height: 56px; padding: var(--s-1) 0; min-width: 0; }
.fila__etiqueta { flex: 1; min-width: 0; font-size: 15px; font-weight: 500; }
.fila__valor { display: grid; justify-items: end; padding-right: var(--s-2); }
.fila__valor b { font: 600 17px/1.2 var(--font-mono); font-variant-numeric: tabular-nums; }
.fila__valor small { font-size: 12px; color: var(--link); }
.fila--apagada .fila__etiqueta, .fila--apagada .campo__etiqueta, .fila--apagada .fila__valor b, .fila--apagada .bloque__nombre, .fila--apagada .bloque__valor {
  color: var(--muted); text-decoration: line-through;
}
.fila--apagada .fila__valor small { color: var(--muted); }

/* ------------------------------------------------------------------ catálogos */

.opciones { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s-2); }
.opcion {
  min-height: 60px; min-width: 0;
  display: grid; align-content: center; gap: 2px;
  text-align: left; padding: var(--s-2) var(--s-3);
  border: 0; border-radius: var(--radius-md);
  background: var(--bg); color: var(--fg);
  transition: transform .1s ease-out;
}
.opcion:active { transform: scale(.98); }
.opcion__codigo { font-size: 15px; font-weight: 600; overflow-wrap: anywhere; }
.opcion__etiqueta { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.opcion--activa { background: var(--accent); color: var(--accent-fg); }
.opcion--activa .opcion__etiqueta { color: var(--accent-fg); }
.opcion.apagado .opcion__codigo { color: var(--muted); text-decoration: line-through; }
.opcion--activa.apagado { background: var(--sel-muted); color: var(--fg); }
.opcion--activa.apagado .opcion__codigo, .opcion--activa.apagado .opcion__etiqueta { color: var(--fg); }
.nota-oculto { margin-top: calc(var(--s-2) * -1); }

.edicion { display: grid; gap: var(--s-2); }
.edicion__fila { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr) 44px; gap: var(--s-2); align-items: center; }
.edicion .sjv-input { background: var(--bg); padding-left: var(--s-3); padding-right: var(--s-3); }
.sjv-card > .sjv-pill { justify-self: start; }

/* ------------------------------------------------------------------ bloques */

.grupo { display: grid; gap: var(--s-2); }
.grupo__etiqueta { font-size: 13px; color: var(--muted); }
.seg-44 button { height: 44px; font-size: 17px; }
.chips { display: flex; flex-wrap: wrap; gap: var(--s-2); }
.chip-44 { height: 44px; padding: 0 var(--s-4); cursor: pointer; }
.chip-44:active { transform: scale(.98); }

.bloques { display: grid; }
.bloques > * + * { border-top: 1px solid var(--line); }
.bloque { display: flex; align-items: center; gap: var(--s-1); min-height: 56px; min-width: 0; }
.bloque__texto { flex: 1; min-width: 0; display: grid; }
.bloque__nombre { font-size: 15px; font-weight: 500; }
.bloque__valor { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ------------------------------------------------------------------ formatos, lote e historial */

.formatos, .historial { display: grid; gap: var(--s-2); }
.formato { display: flex; align-items: center; gap: var(--s-1); min-width: 0; }
.formato__aplicar {
  flex: 1; min-width: 0; min-height: 56px;
  display: grid; gap: 2px; text-align: left;
  padding: var(--s-2) var(--s-3);
  border: 0; border-radius: var(--radius-md);
  background: var(--bg); color: var(--fg);
  transition: transform .1s ease-out;
}
.formato__aplicar:active { transform: scale(.98); }
.formato__nombre { display: flex; align-items: center; gap: var(--s-2); font-size: 15px; font-weight: 600; min-width: 0; overflow-wrap: anywhere; }
.formato__resumen { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.formato--editando .sjv-input { flex: 1; min-width: 0; background: var(--bg); }

.lote__lista { display: grid; gap: var(--s-1); max-height: 360px; overflow-y: auto; overscroll-behavior: contain; }
@media (min-width: 1024px) { .lote__lista { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s-2); } }

.item-copiar {
  width: 100%; min-height: 44px;
  display: flex; align-items: center; gap: var(--s-3);
  text-align: left; padding: var(--s-2) var(--s-3);
  border: 0; border-radius: var(--radius-md);
  background: var(--bg); color: var(--fg);
  transition: transform .1s ease-out;
}
.item-copiar:active { transform: scale(.98); }
.item-copiar__texto { flex: 1; min-width: 0; display: grid; gap: 2px; }
.item-copiar__nombre { flex: 1; min-width: 0; font-size: 13px; overflow-wrap: anywhere; }
.item-copiar__hora { font-size: 12px; color: var(--muted); }
.item-copiar__ico { color: var(--muted); }
.historial { max-height: 420px; overflow-y: auto; overscroll-behavior: contain; }

.vacio { font-size: 13px; color: var(--muted); }
.nota-aviso { display: flex; align-items: flex-start; gap: var(--s-2); font-size: 13px; color: var(--fg); }
.punto { width: 8px; height: 8px; border-radius: var(--radius-pill); flex: none; margin-top: 5px; }
.punto--aviso { background: var(--aviso); }

.firma { display: flex; justify-content: space-between; gap: var(--s-2); padding-top: var(--s-3); border-top: 1px solid var(--line); }

/* ------------------------------------------------------------------ toast */

.toast-zona {
  position: fixed; left: 0; right: 0;
  bottom: calc(112px + env(safe-area-inset-bottom));
  z-index: 50; display: flex; justify-content: center;
  padding: 0 var(--s-4); pointer-events: none;
}
.toast {
  width: 100%; max-width: var(--mobile-max);
  pointer-events: auto;
  visibility: hidden;
  transform: translateY(16px) scale(.98);
  opacity: 0;
  /* resorte críticamente amortiguado aproximado (apple-design: 0.3 s, rebote 0) */
  transition: transform .3s cubic-bezier(.2, .9, .3, 1), opacity .2s ease-out, visibility 0s linear .3s;
}
.toast.visible { visibility: visible; transform: none; opacity: 1; transition: transform .3s cubic-bezier(.2, .9, .3, 1), opacity .15s ease-out, visibility 0s; }
.toast__texto { flex: 1; min-width: 0; font-size: 15px; line-height: 1.3; overflow-wrap: anywhere; }
.toast__ico--ok { color: var(--ingreso); }
.toast__ico--error { color: var(--gasto); }
.toast__ico--aviso { color: var(--aviso); }
.toast__accion { min-height: 44px; padding: 0 var(--s-2); flex: none; }
@media (min-width: 1024px) { .toast-zona { bottom: var(--s-6); } }

@media (prefers-reduced-motion: reduce) {
  .toast, .toast.visible { transform: none; transition: opacity .2s ease, visibility 0s linear .2s; }
  .toast.visible { transition: opacity .2s ease, visibility 0s; }
  .sjv-btn, .sjv-pill, .ojo, .icono-btn, .stepper__btn, .opcion, .item-copiar, .formato__aplicar, .chip-44 { transition: none; }
  .sjv-btn:active, .sjv-pill:active, .ojo:active, .icono-btn:active, .stepper__btn:active, .opcion:active, .item-copiar:active, .formato__aplicar:active, .chip-44:active { transform: none; }
}
