/* ─── APP SHELL ───────────────────────────────────────── */

body {
  background: var(--bg);
  color: var(--text-primary);
  transition: background var(--dur-base) var(--ease-out),
              color var(--dur-base) var(--ease-out);
}

#app {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  width: 100vw;
  overflow: hidden;
}

#screens {
  flex: 1;
  overflow: hidden;
  position: relative;
}

/* ─── SCREENS ─── */

.screen {
  position: absolute;
  inset: 0;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px);
  transition: opacity var(--dur-base) var(--ease-out),
              transform var(--dur-base) var(--ease-out);
  padding-bottom: calc(var(--nav-height) + var(--safe-bottom) + 16px);
}

.screen.active {
  opacity: 1;
  pointer-events: all;
  transform: translateY(0);
}

.screen-content {
  padding: 0 var(--sp-5);
  padding-top: calc(env(safe-area-inset-top, 0px) + 56px);
  max-width: 480px;
  margin: 0 auto;
}

/* ─── BOTTOM NAV ─── */

#bottom-nav {
  display: flex;
  align-items: center;
  justify-content: space-around;
  height: calc(var(--nav-height) + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  background: var(--bg);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}

.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 8px 12px;
  border-radius: var(--radius-md);
  color: var(--text-tertiary);
  transition: color var(--dur-fast) var(--ease-out),
              background var(--dur-fast) var(--ease-out);
  min-width: 52px;
}

.nav-item span {
  font-size: var(--text-xs);
  font-weight: 500;
  letter-spacing: 0.01em;
}

.nav-item.active {
  color: var(--text-primary);
}

.nav-item svg {
  transition: transform var(--dur-base) var(--ease-spring);
}

.nav-item.active svg {
  transform: scale(1.05);
}

/* ─── SCREEN HEADERS ─── */

.screen-header {
  margin-bottom: var(--sp-6);
}

.screen-title {
  font-size: var(--text-lg);
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-primary);
}

.screen-subtitle {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  margin-top: var(--sp-1);
}

/* ─── INICIO ─── */

.home-header {
  margin-bottom: var(--sp-8);
}

.home-meta {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.label-small {
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-tertiary);
}

.total-amount {
  font-size: clamp(42px, 12vw, 64px);
  font-weight: 700;
  letter-spacing: -0.04em;
  line-height: 1;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
}

.falta-label {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  margin-top: 2px;
}

/* ─── BOTE WRAPPER ─── */

.bote-wrapper {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  margin: 0 auto;
  width: 100%;
  max-width: 340px;
}

#bote-canvas {
  width: 100%;
  height: auto;
  max-height: 380px;
}

.bote-meta-label {
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-tertiary);
  margin-top: var(--sp-3);
  text-align: center;
}

/* ─── PROGRESS ─── */

.progress-section {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  margin-top: var(--sp-6);
}

.progress-bar-track {
  flex: 1;
  height: 4px;
  background: var(--border-strong);
  border-radius: 2px;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  background: var(--text-primary);
  border-radius: 2px;
  width: 0%;
  transition: width 0.6s var(--ease-out);
}

.progress-pct {
  font-size: var(--text-xs);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--text-secondary);
  min-width: 32px;
  text-align: right;
}

/* ─── BILLETES ─── */

.billetes-list {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
}

.billete-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--sp-4) var(--sp-5);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  transition: background var(--dur-fast) var(--ease-out);
}

.billete-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.billete-valor {
  font-size: var(--text-md);
  font-weight: 600;
  letter-spacing: -0.01em;
  font-variant-numeric: tabular-nums;
}

.billete-subtotal {
  font-size: var(--text-xs);
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
}

.billete-controls {
  display: flex;
  align-items: center;
  gap: var(--sp-4);
}

.billete-btn {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--accent-bg);
  border-radius: 50%;
  color: var(--text-primary);
  font-size: 18px;
  font-weight: 400;
  transition: background var(--dur-fast) var(--ease-out),
              transform var(--dur-fast) var(--ease-spring);
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.billete-btn:active {
  background: var(--accent-hover);
  transform: scale(0.92);
}

.billete-cantidad {
  font-size: var(--text-md);
  font-weight: 600;
  min-width: 28px;
  text-align: center;
  font-variant-numeric: tabular-nums;
  color: var(--text-primary);
}

/* ─── HISTORIAL ─── */

.historial-list {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
}

.mov-item {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-4);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background var(--dur-fast) var(--ease-out);
  -webkit-tap-highlight-color: transparent;
}

.mov-item:active {
  background: var(--surface-2);
}

.mov-icon {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
}

.mov-icon.positivo { background: var(--positive-bg); }
.mov-icon.negativo { background: var(--negative-bg); }

.mov-content {
  flex: 1;
  min-width: 0;
}

.mov-categoria {
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--text-primary);
}

.mov-nota {
  font-size: var(--text-xs);
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.mov-fecha {
  font-size: var(--text-xs);
  color: var(--text-tertiary);
}

.mov-amount {
  font-size: var(--text-base);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
  flex-shrink: 0;
}

.mov-amount.positivo { color: var(--positive); }
.mov-amount.negativo { color: var(--negative); }

.empty-state {
  padding: var(--sp-12) var(--sp-6);
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--sp-2);
}

.empty-state p {
  font-size: var(--text-base);
  font-weight: 500;
  color: var(--text-secondary);
}

.empty-state span {
  font-size: var(--text-sm);
  color: var(--text-tertiary);
}

/* ─── STATS ─── */

.stats-grid {
  display: flex;
  flex-direction: column;
  gap: var(--sp-4);
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--sp-5);
}

.stat-card-label {
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-tertiary);
  margin-bottom: var(--sp-4);
}

.stat-card-value {
  font-size: var(--text-xl);
  font-weight: 700;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
}

.stat-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--sp-3) 0;
  border-bottom: 1px solid var(--border);
}

.stat-row:last-child {
  border-bottom: none;
}

.stat-row-label {
  font-size: var(--text-sm);
  color: var(--text-secondary);
}

.stat-row-value {
  font-size: var(--text-sm);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

/* distribución billetes */
.dist-bill-row {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-2) 0;
}

.dist-bill-label {
  font-size: var(--text-sm);
  font-weight: 500;
  min-width: 48px;
  font-variant-numeric: tabular-nums;
}

.dist-bill-bar-track {
  flex: 1;
  height: 3px;
  background: var(--border-strong);
  border-radius: 2px;
  overflow: hidden;
}

.dist-bill-bar-fill {
  height: 100%;
  background: var(--text-primary);
  border-radius: 2px;
  transition: width 0.5s var(--ease-out);
}

.dist-bill-count {
  font-size: var(--text-xs);
  color: var(--text-tertiary);
  min-width: 20px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* mini chart evolución */
.mini-chart {
  width: 100%;
  height: 80px;
  margin-top: var(--sp-2);
}

/* ─── AJUSTES ─── */

.ajustes-list {
  display: flex;
  flex-direction: column;
  gap: var(--sp-6);
}

.ajustes-group {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.ajustes-group-label {
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-tertiary);
  padding: 0 var(--sp-4);
  margin-bottom: var(--sp-1);
}

.ajuste-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--sp-4);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: var(--text-base);
  transition: background var(--dur-fast) var(--ease-out);
  -webkit-tap-highlight-color: transparent;
}

.ajuste-item + .ajuste-item {
  margin-top: var(--sp-2);
}

button.ajuste-item:active {
  background: var(--surface-2);
}

.ajuste-item svg {
  color: var(--text-tertiary);
}

.ajuste-value {
  font-size: var(--text-sm);
  color: var(--text-secondary);
}

/* Toggle */
.toggle-btn {
  width: 48px;
  height: 28px;
  background: var(--border-strong);
  border-radius: 14px;
  position: relative;
  transition: background var(--dur-base) var(--ease-out);
  cursor: pointer;
  flex-shrink: 0;
}

.toggle-btn[aria-checked="true"] {
  background: var(--text-primary);
}

.toggle-thumb {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 22px;
  height: 22px;
  background: var(--bg);
  border-radius: 50%;
  transition: transform var(--dur-base) var(--ease-spring),
              background var(--dur-base) var(--ease-out);
  box-shadow: var(--shadow-sm);
}

[data-theme="light"] .toggle-thumb {
  background: #FFFFFF;
}

.toggle-btn[aria-checked="true"] .toggle-thumb {
  transform: translateX(20px);
}

/* ─── CATEGORIAS ─── */

.categorias-list {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
}

.categoria-item {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  background: var(--surface-2);
  border-radius: var(--radius-sm);
}

.categoria-nombre {
  flex: 1;
  font-size: var(--text-sm);
}

.categoria-delete {
  color: var(--text-tertiary);
  padding: 4px;
  transition: color var(--dur-fast);
}

.categoria-delete:hover {
  color: var(--negative);
}

/* ─── TOAST ─── */

.toast {
  position: fixed;
  bottom: calc(var(--nav-height) + var(--safe-bottom) + 12px);
  left: 50%;
  transform: translateX(-50%) translateY(8px);
  background: var(--text-primary);
  color: var(--bg);
  padding: var(--sp-3) var(--sp-5);
  border-radius: var(--radius-xl);
  font-size: var(--text-sm);
  font-weight: 500;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--dur-base) var(--ease-out),
              transform var(--dur-base) var(--ease-spring);
  z-index: 1000;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.toast.hidden {
  display: none;
}
