/* BaseCero — shell de la app. Layout móvil-first, centrado en escritorio (max 480px).
   Proporciones de tab bar / FAB tomadas de design/Resumen.dc.html y design/Ajustes.dc.html. */

/* ===== estructura general ===== */
html, body { height: 100%; }
body {
  max-width: 480px;
  margin: 0 auto;
  position: relative;
  font-size: 15px;
  line-height: 1.4;
}
button { font: inherit; color: inherit; }
::selection { background: var(--text); color: var(--bg); }

main#screen {
  display: block;
  min-height: 100dvh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 20px 20px calc(84px + env(safe-area-inset-bottom, 0px) + 24px);
}

/* ===== componentes base (design/material-expresivo/DesignSystem.dc.html) =====
   .card y .btn-primary viven también en tokens.css (PR A): app.css carga después,
   misma especificidad → estas reglas ganan por cascada y sobrescriben el look viejo. */
.card {
  border: 0; /* principio 4: cards sin borde, elevación tonal */
}
.btn-primary {
  background: var(--text);
  color: var(--bg);
  border-radius: 999px;
  height: 52px;
  padding: 0 28px;
  /* width:100% se hereda de tokens.css — la mayoría de usos son CTA a todo el ancho
     al pie de un formulario; el ejemplo aislado del artboard no representa ese contexto. */
}
.btn-secondary {
  background: var(--card2);
  color: var(--text);
  border: 0;
  border-radius: 999px;
  height: 52px;
  padding: 0 28px;
  font: 600 16px var(--font-ui);
  cursor: pointer;
}

.section-title {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--text-2);
}

.divider {
  height: 1px;
  background: var(--rule);
  border: 0;
}

/* ===== cabecera de pantalla ===== */
.screen-header {
  display: flex;
  flex-direction: column;
  gap: 3px;
  margin-bottom: 16px;
}
.screen-header h1 {
  font-size: 20px;
  font-weight: 700;
  line-height: 1.2;
}
.screen-header p {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-2);
}

/* ===== botón icono (p.ej. cerrar pantalla) ===== */
.icon-btn {
  width: 36px;
  height: 36px;
  flex-shrink: 0;
  border-radius: var(--radius-sm);
  background: var(--card2);
  border: 0;
  color: var(--text-2);
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

/* ===== control segmentado (chips de tipo de movimiento, scroll horizontal) ===== */
.segmented {
  display: flex;
  gap: 4px;
  padding: 4px;
  background: var(--card);
  border: 0;
  border-radius: var(--radius-sm);
  overflow-x: auto;
  scrollbar-width: none;
}
.segmented::-webkit-scrollbar { display: none; }
.segmented button {
  flex: 0 0 auto;
  height: 38px;
  padding: 0 16px;
  border: 0;
  border-radius: 10px;
  background: none;
  color: var(--text-2);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
}
.segmented button.active {
  background: var(--text);
  color: var(--bg);
}

/* ===== selector "¿Devuelve un gasto?" (pantalla Registro, tipo devolución) ===== */
.refund-toggle {
  width: 100%;
  height: 48px;
  background: var(--card);
  border: 1px solid var(--rule);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.refund-list {
  max-height: 240px;
  overflow-y: auto;
}
.refund-row {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  height: 48px;
  background: none;
  border: 0;
  border-bottom: 1px solid var(--rule);
  color: var(--text);
  font-size: 13px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.refund-row:last-child { border-bottom: 0; }

/* ===== display del importe (pantalla Registro) ===== */
.amount-display {
  display: flex;
  align-items: baseline;
  gap: 8px;
  line-height: 1;
}
.amount-display .num {
  font-size: 56px;
  font-weight: 700;
  letter-spacing: -0.01em;
}
.amount-display .amount-currency {
  font-size: 26px;
  font-weight: 600;
  color: var(--text-3);
}

/* ===== barra de pestañas + FAB ===== */
.tabbar {
  position: fixed;
  left: 50%;
  bottom: 0;
  transform: translateX(-50%);
  width: 100%;
  max-width: 480px;
  height: calc(84px + env(safe-area-inset-bottom, 0px));
  padding: 0 14px env(safe-area-inset-bottom, 0px);
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg);
  border-top: 1px solid var(--rule);
  z-index: 20;
}

.tab {
  flex: 1 1 0;
  min-width: 0;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: none;
  border: 0;
  padding: 0;
  color: var(--text-3);
  font-size: 10px;
  font-weight: 500;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.tab svg {
  width: 21px;
  height: 21px;
  stroke: currentColor;
  fill: none;
}
.tab.active {
  color: var(--text);
  font-weight: 700;
}

.fab {
  flex-shrink: 0;
  width: 56px;
  height: 56px;
  border-radius: 19px;
  background: var(--text);
  color: var(--bg);
  border: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  line-height: 1;
  font-weight: 400;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.35);
}
.fab:active { background: color-mix(in srgb, var(--text) 88%, var(--bg)); }

/* ===== chips de categoría ===== */
.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.chip {
  height: 44px;
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 0 14px 0 8px;
  border-radius: 999px;
  background: var(--card2);
  border: 0;
  color: var(--text-2);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.chip-icon {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  line-height: 1;
  background: color-mix(in srgb, var(--cat, var(--text-2)) 18%, transparent);
  color: var(--cat, var(--text-2));
}
.chip-icon svg { width: 17px; height: 17px; }
.chip.active {
  background: var(--text);
  color: var(--bg);
  font-weight: 700;
}
.chip.active .chip-icon {
  background: color-mix(in srgb, var(--bg) 18%, transparent);
  color: var(--bg);
}

/* fila de chips de filtro en una sola línea con scroll horizontal (Movimientos, Task 4: «Todos» +
   una chip por categoría raíz presente + «Sin categoría · N») — mismo criterio de scroll oculto
   que .segmented/.chips-scroll, pero en una fila (flex nowrap por defecto) en vez de grid 2 filas. */
.chips-row {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 2px;
  scrollbar-width: none;
}
.chips-row::-webkit-scrollbar { display: none; }
.chips-row .chip { flex: 0 0 auto; }

/* chips de categoría en 2 filas con scroll horizontal (pantalla Registro) */
.chips-scroll {
  display: grid;
  grid-auto-flow: column;
  grid-template-rows: repeat(2, auto);
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 2px;
  scrollbar-width: none;
}
.chips-scroll::-webkit-scrollbar { display: none; }

/* variante vertical de chip: icono arriba, nombre debajo (categorías en Registro) */
.chip-v {
  flex: 0 0 auto;
  width: 74px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 10px 4px;
  border-radius: var(--radius-sm);
  background: var(--card2);
  border: 0;
  color: var(--text-2);
  font-size: 11px;
  font-weight: 500;
  line-height: 1.2;
  text-align: center;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.chip-v span:last-child {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.chip-v.active {
  background: var(--text);
  color: var(--bg);
  font-weight: 700;
}

/* ===== teclado numérico (con operadores, Task 3 — ver Registro.dc.html) ===== */
.keypad {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
}
.key {
  height: 52px;
  background: var(--card);
  border: 0;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-num);
  font-size: 19px;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.key:active { background: var(--rule); }
.key-comma { color: var(--text-2); }
.key-back svg { width: 23px; height: 23px; stroke: var(--text-2); fill: none; }
/* +/−/×/÷: fondo/color atenuados frente a los dígitos (artboard: .op) — back/coma se quedan con
   su tratamiento de siempre (key-back/key-comma), decisión explícita, ver registro.js. */
.key.op { background: var(--card2); color: var(--text-2); font-size: 17px; }
.key.op:active { background: var(--rule); }

/* ===== filas de movimiento ===== */
.tx-row {
  display: flex;
  align-items: center;
  gap: 12px;
}
.tx-icon {
  width: 40px;
  height: 40px;
  border-radius: 14px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: color-mix(in srgb, var(--cat, var(--text-3)) 18%, transparent);
  color: var(--cat, var(--text-3));
  font-size: 19px; /* iconForCategory devuelve emoji, no svg: sin esto se ve diminuto (ver task 4, .chip-icon) */
  line-height: 1;
}
.tx-icon svg { width: 19px; height: 19px; }
.tx-body {
  display: flex;
  flex-direction: column;
  gap: 3px;
  flex-grow: 1;
  min-width: 0;
}
.tx-title {
  font-size: 14px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.tx-sub {
  font-size: 11px;
  color: var(--text-3);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.tx-amount {
  font-family: var(--font-num);
  font-size: 15px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  flex-shrink: 0;
}
.tx-amount.negative { color: var(--red); }
.tx-amount.positive { color: var(--green); }
.tx-tag {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--text-2);
  background: var(--card2);
  border-radius: 6px;
  padding: 3px 6px;
  flex-shrink: 0;
}

/* ===== cabecera de grupo por día (lista de movimientos de Inicio) ===== */
.day-header {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--text-2);
}

/* ===== filas de lista genéricas (ajustes) ===== */
.list-row {
  display: flex;
  align-items: center;
  gap: 13px;
  padding: 13px 0;
}
.list-row-icon {
  width: 42px;
  height: 42px;
  border-radius: 15px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: color-mix(in srgb, var(--cat, var(--text-2)) 18%, transparent);
  color: var(--cat, var(--text-2));
}
.list-row-icon svg { width: 20px; height: 20px; }
.list-row-body { display: flex; flex-direction: column; gap: 3px; flex-grow: 1; min-width: 0; }
.list-row-title { font-size: 15px; font-weight: 600; }
.list-row-sub { font-size: 11px; color: var(--text-3); }
.list-row-chevron { flex-shrink: 0; color: var(--text-3); width: 17px; height: 17px; }

/* ===== campos de formulario ===== */
.field {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  height: 50px;
  padding: 0 16px;
  background: var(--card);
  border: 0;
  border-radius: var(--radius-sm);
}
.field-label {
  font-size: 13px;
  color: var(--text-2);
}
.field-value {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 600;
}
.field input,
.field select {
  border: 0;
  background: none;
  color: var(--text);
  font: 600 15px var(--font-ui);
  text-align: right;
  min-width: 0;
}
.field.field-stack {
  flex-direction: column;
  align-items: stretch;
  height: auto;
  padding: 12px 16px;
  gap: 6px;
}
.field.field-stack .field-label {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--text-2);
}
.field.field-stack input,
.field.field-stack select {
  text-align: left;
  font-size: 15px;
  width: 100%;
}

/* ===== interruptor (toggle) ===== */
.toggle {
  position: relative;
  display: inline-flex;
  width: 48px;
  height: 28px;
  flex-shrink: 0;
  cursor: pointer;
}
.toggle input[type="checkbox"] {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}
.toggle-track {
  position: absolute;
  inset: 0;
  background: var(--card2);
  border-radius: 14px;
  transition: background 0.15s ease;
  pointer-events: none;
}
.toggle-knob {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 22px;
  height: 22px;
  border-radius: 11px;
  background: var(--text);
  transition: transform 0.15s ease, background 0.15s ease;
}
.toggle input[type="checkbox"]:checked ~ .toggle-track {
  background: var(--text);
}
.toggle input[type="checkbox"]:checked ~ .toggle-track .toggle-knob {
  background: var(--bg);
  transform: translateX(20px);
}
.toggle input[type="checkbox"]:focus-visible ~ .toggle-track {
  outline: 2px solid var(--text);
  outline-offset: 2px;
}

/* ===== aviso / banner ===== */
.banner-aviso {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  background: color-mix(in srgb, var(--amber) 14%, var(--card));
  border: 1px solid color-mix(in srgb, var(--amber) 35%, var(--rule));
  font-size: 12px;
  line-height: 1.5;
  color: var(--text-2);
}
.banner-aviso svg {
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  margin-top: 1px;
  color: var(--amber);
}
.banner-aviso.red {
  background: color-mix(in srgb, var(--red) 14%, var(--card));
  border-color: color-mix(in srgb, var(--red) 35%, var(--rule));
}
.banner-aviso.red svg { color: var(--red); }

/* el aviso de almacenamiento no persistente se antepone a body (fuera de #screen):
   franja roja tenue fija arriba, a todo lo ancho del layout */
body > .banner-aviso {
  position: fixed;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 480px;
  z-index: 30;
  border-radius: 0;
  background: color-mix(in srgb, var(--red) 14%, var(--card));
  border: 1px solid color-mix(in srgb, var(--red) 35%, var(--rule));
  border-top: 0;
}
body:has(> .banner-aviso) main#screen { margin-top: 46px; }

/* ===== asistente de Nuevo periodo (Task 8) ===== */
/* stepper del % compartido ("Pagas de lo compartido") */
.stepper-btn {
  width: 20px;
  height: 19px;
  border: 0;
  background: none;
  color: var(--text-2);
  font-size: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.stepper-btn:active { color: var(--text); }

/* input € de cada presupuesto por categoría: vacío = "Sin límite", estilo punteado */
.budget-input {
  height: 42px;
  width: 92px;
  flex-shrink: 0;
  padding: 0 24px 0 10px;
  background: var(--card);
  border: 1px solid transparent;
  border-radius: 14px;
  color: var(--text);
  font: 600 15px var(--font-num);
  text-align: right;
}
.budget-input.is-empty {
  background: var(--bg);
  /* var(--rule) (rgba(154,153,166,0.16)) da ~1.3:1 sobre --card (#1C1C21): insuficiente para el
     borde funcional "vacío/sin límite" (WCAG 1.4.11, 3:1). Alpha subido a 0.65 → ~3.34:1 sobre
     --card, ~3.44:1 sobre --bg (ver cálculo en el report de Task 2). Los --rule restantes
     (separadores decorativos) no se tocan. */
  border: 1px dashed rgba(154, 153, 166, 0.65);
  color: var(--text-3);
  font: 500 12px var(--font-ui);
  text-align: center;
  padding: 0 10px;
}
.budget-input::-webkit-outer-spin-button,
.budget-input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.budget-input[type="number"] { -moz-appearance: textfield; }

/* chrome oculto durante el asistente de periodo (onboarding y cierre normal, ver main.js nav()) */
body.onboarding .tabbar,
body.onboarding .fab { display: none; }

/* ===== componentes nuevos del sistema (consumidos por las tareas 5-8) ===== */

/* icono redondo de categoría/comercio, color sólido + emoji encima (DesignSystem.dc.html) */
.dotico {
  width: 34px;
  height: 34px;
  flex-shrink: 0;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  line-height: 1;
  background: var(--cat, var(--text-2));
}

/* etiqueta versalitas 10.5/700/.09em — misma fórmula que .section-title/.day-header */
.day-label {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--text-2);
}

/* barra de progreso píldora de 8px; <i> es el relleno — el consumidor fija su ancho (width/%)
   y opcionalmente --cat para el color (categoría o estado: bien/al límite/excedido) */
.bar {
  height: 8px;
  border-radius: 999px;
  background: var(--card2);
  overflow: hidden;
}
.bar > i {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: var(--cat, var(--green));
}

/* anillo de progreso conic-gradient con hueco central; el consumidor fija --pct (0-100, número)
   y opcionalmente --cat para el color; el contenido (icono/span) se centra sobre el hueco */
.ring {
  width: 46px;
  height: 46px;
  flex-shrink: 0;
  border-radius: 50%;
  position: relative;
  display: grid;
  place-items: center;
  background: conic-gradient(var(--cat, var(--green)) calc(var(--pct, 0) * 1%), var(--card2) 0);
}
.ring::after {
  content: "";
  position: absolute;
  inset: 5px;
  border-radius: 50%;
  background: var(--card);
}
.ring > * {
  position: relative;
  z-index: 1;
  font-size: 16px;
}

/* importe héroe: 34/700 tabular; los céntimos van en un <small> al 60% (principio 3, jerarquía invertida) */
.amount-hero {
  font-size: 34px;
  font-weight: 700;
  letter-spacing: -0.01em;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}
.amount-hero small {
  font-size: 0.6em;
  font-weight: 600;
}

/* ===== animación de aviso (importe/categoría inválidos al guardar) ===== */
@keyframes bc-shake {
  10%, 90% { transform: translateX(-1px); }
  20%, 80% { transform: translateX(2px); }
  30%, 50%, 70% { transform: translateX(-4px); }
  40%, 60% { transform: translateX(4px); }
}
.shake { animation: bc-shake 0.4s; }

/* ---- Onboarding (PR F): indicador de progreso de 4 pasos ---- */
.onb-dots { display: flex; gap: 6px; justify-content: center; }
.onb-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--card2); }
.onb-dot.on { background: var(--text); width: 20px; border-radius: 999px; }

/* ===== accesibilidad (Task 2 P2) ===== */
/* foco visible global: reemplaza los `outline: none` de .field input/select y .budget-input
   eliminados más arriba — todo elemento enfocable por teclado queda con anillo visible. */
:focus-visible {
  outline: 2px solid var(--text);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  .shake { animation: none; }
  .toggle-track, .toggle-knob { transition: none; }
}
