/* Escenas de Empezar. Calcan src/index.css (.pin-card y .login-*,
   .period-selector, .year-stepper, .overview-hero, .iva-stack-*, .sidebar-*,
   .mobile-menu-*) con la escala del marco (--t-*). */

/* El cambio de tema: un fundido de toda la interfaz a la vez */
.st-fading, .st-fading *:not(.st-sheet):not(.st-scrim):not(.fluid-highlight):not(.st-period-pill) {
  transition: background-color 0.32s ease, color 0.32s ease, border-color 0.32s ease, box-shadow 0.32s ease !important;
}

/* ── Entrar (LoginScreen) ─────────────────────────────────────────────── */
/* La entrada ocupa la ventana entera, con los semáforos encima; abajo deja
   lo que el borde de la escena corta (40 px) */
.st-login-win .win-bar { position: relative; z-index: 3; }
.st-login-screen {
  position: absolute; inset: 0 0 40px; z-index: 2;
  display: flex; align-items: center; justify-content: center;
  transition: opacity var(--spring-slow), transform var(--spring-slow);
}
.st-login-screen.st-gone { opacity: 0; transform: scale(0.98); pointer-events: none; transition: opacity var(--spring-slow-exit), transform var(--spring-slow-exit); }
.st-login-card {
  --login-h: 37px;
  width: 100%; max-width: 340px;
  padding: 44px 32px 40px;
  background: var(--surface);
  border-radius: var(--radius-xl);
}
.st-login-inner {
  display: flex; flex-direction: column; align-items: center; gap: 12px;
  transition: opacity var(--spring-moderate), transform var(--spring-moderate);
}
.st-login-inner.st-login-in { opacity: 0; transform: translateX(16px); }
.st-login-inner.st-login-out { opacity: 0; transform: translateX(-16px); transition: opacity var(--spring-moderate-exit), transform var(--spring-moderate-exit); }
.st-login-head { display: flex; flex-direction: column; align-items: center; gap: 4px; margin-bottom: 20px; }
.st-login-logo { font-size: var(--t-2xl); font-weight: 700; letter-spacing: -0.03em; line-height: 1.1; color: var(--text); }
.st-login-lead { font-size: var(--t-base); color: var(--text-subtle); }
.st-login-lead--tight { margin: -8px 0 12px; }
.st-login-form { width: 100%; display: flex; flex-direction: column; gap: 16px; }
.st-login-input {
  width: 100%; height: var(--login-h); padding: 0 12px;
  background: var(--control-fill); border: none; border-radius: var(--radius-sm);
  color: var(--text); font: inherit; font-size: var(--t-base); outline: none;
  transition: background-color var(--spring-fast), box-shadow var(--spring-fast);
}
.st-login-input::placeholder { color: var(--text-subtle); }
.st-login-input:is(:hover, [data-hover]):not(:focus):not([data-focus]) { background-color: var(--control-fill-hover); }
.st-login-input:focus { box-shadow: var(--focus-ring); }
.stage .st-login-input.st-login-input--error { box-shadow: 0 0 0 1px var(--red), 0 0 0 4px var(--red-dim); }
.st-login-wrap { position: relative; display: flex; align-items: center; }
.st-login-wrap .st-login-input { padding-right: 40px; }
.st-login-eye { position: absolute; right: 8px; display: flex; align-items: center; padding: 4px; border: none; border-radius: var(--radius-sm); background: none; color: var(--text-muted); cursor: pointer; transition: color var(--spring-fast); }
.st-login-eye:is(:hover, [data-hover]) { color: var(--text); }
/* El error se despliega entre el campo y el botón (Fade) */
.st-login-error { margin: -16px 0 0 !important; max-height: 0; overflow: hidden; opacity: 0; font-size: var(--t-sm); color: var(--red); transition: max-height var(--spring-moderate), margin var(--spring-moderate), opacity var(--spring-moderate); }
.st-login-error.show { margin-top: 4px !important; max-height: 3em; opacity: 1; }
.st-login-submit {
  width: 100%; height: var(--login-h); margin-top: 2px; padding: 0;
  display: inline-flex; align-items: center; justify-content: center;
  border: none; border-radius: var(--radius-pill);
  background: var(--control-fill); color: var(--brand);
  font: inherit; font-size: var(--t-sm); font-weight: 400; cursor: pointer;
  transition: background-color var(--spring-fast), transform var(--spring-fast);
}
.st-login-submit:is(:hover, [data-hover]):not(:disabled) { background: var(--control-fill-hover); }
.st-login-submit:active:not(:disabled) { transform: scale(0.98); }
.st-login-submit:disabled { filter: opacity(0.45); cursor: default; }
.st-login-switch { margin-top: 12px; padding: 4px 8px; border: none; border-radius: var(--radius-sm); background: none; color: var(--text-subtle); font: inherit; font-size: var(--t-sm); cursor: pointer; transition: color var(--spring-fast); }
.st-login-switch:is(:hover, [data-hover]) { color: var(--text); }
.st-login-avatar { width: 72px; height: 72px; margin: 0 auto 12px; border-radius: 50%; display: flex; align-items: center; justify-content: center; background: var(--brand-dim); color: var(--brand); font-size: var(--t-2xl); font-weight: 700; }
.st-login-name { margin: 0 0 16px; font-size: var(--t-lg); font-weight: 600; letter-spacing: -0.01em; color: var(--text); text-align: center; }
.st-shake { animation: st-shake 0.42s cubic-bezier(0.36, 0.07, 0.19, 0.97) both; }
@keyframes st-shake { 0%, 100% { transform: none; } 15% { transform: translateX(-8px); } 30% { transform: translateX(8px); } 45% { transform: translateX(-6px); } 60% { transform: translateX(6px); } 75% { transform: translateX(-3px); } 90% { transform: translateX(3px); } }

/* En el móvil, a pantalla completa: sin tarjeta, campos más altos */
.st-login-screen--phone { inset: 54px 0 60px; padding: 0 40px 48px; background: var(--bg); }
.st-login-screen--phone .st-login-card { --login-h: 45px; max-width: none; padding: 0; background: none; border-radius: 0; }
.st-login-screen--phone .st-login-head { margin-bottom: 16px; }
.st-login-screen--phone .st-login-input { border-radius: var(--radius); }
.st-login-screen--phone .st-login-submit { margin-top: 6px; border-radius: var(--radius); font-size: var(--t-base); }

/* Dentro: el Resumen entra con un fundido */
.st-signed { opacity: 0; transform: translateY(8px); pointer-events: none; transition: opacity var(--spring-slow), transform var(--spring-slow); }
.st-signed.st-shown { opacity: 1; transform: none; pointer-events: auto; }

/* ── Periodo y año (PeriodSelector, YearSelector) ─────────────────────── */
.st-toolbar { display: flex; align-items: center; gap: 8px; }
.st-period { position: relative; display: inline-flex; align-items: center; gap: 2px; padding: 3px; border-radius: var(--radius-pill); background: var(--control-fill); }
.st-period-btn { position: relative; z-index: 1; height: 28px; padding: 0 12px; border: none; border-radius: var(--radius-pill); background: none; color: var(--text-muted); font: inherit; font-size: var(--t-sm); font-weight: 500; white-space: nowrap; cursor: pointer; transition: color var(--spring-fast); }
.st-period-btn:is(:hover, [data-hover]), .st-period-btn.active { color: var(--text); }
.st-period-btn.active { font-weight: 600; }
.st-period-divider { width: 1px; height: 16px; margin: 0 3px; flex-shrink: 0; background: var(--border-strong); }
.st-period-pill { position: absolute; top: 3px; bottom: 3px; left: 0; border-radius: var(--radius-pill); background: var(--surface); pointer-events: none; transition: transform var(--spring-moderate), width var(--spring-moderate); }
.st-year { display: inline-flex; align-items: center; gap: 1px; padding: 3px; border-radius: var(--radius); background: var(--control-fill); }
.st-year-step { display: inline-flex; align-items: center; justify-content: center; width: 26px; height: 28px; border: none; border-radius: var(--radius-pill); background: none; color: var(--text-muted); cursor: pointer; transition: color var(--spring-fast), background-color var(--spring-fast); }
.st-year-step:is(:hover, [data-hover]):not(:disabled) { color: var(--text); background: var(--surface); }
.st-year-step:disabled { filter: opacity(0.3); cursor: default; }
.st-year-label { height: 28px; padding: 0 8px; border: none; border-radius: var(--radius); background: none; color: var(--text); font: inherit; font-size: var(--t-sm); font-weight: 600; letter-spacing: -0.01em; font-variant-numeric: tabular-nums; cursor: pointer; transition: background-color var(--spring-fast); }
.st-year-label:is(:hover, [data-hover]) { background: var(--surface); }
/* En el móvil: en una línea a todo lo ancho, en cápsula y de cristal */
.st-toolbar--phone { width: 100%; padding: 6px 0; margin-bottom: 12px; }
.st-toolbar--phone .st-period { flex: 1; min-width: 0; justify-content: space-between; }
.st-toolbar--phone :is(.st-period, .st-year) { border-radius: var(--radius-pill); background: color-mix(in srgb, var(--surface-hover) 72%, transparent); -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px); }
[data-theme="light"] .st-toolbar--phone :is(.st-period, .st-year) { background: var(--control-fill); }
.st-toolbar--phone .st-year { flex-shrink: 0; }
.st-toolbar--phone :is(.st-period-btn, .st-year-step, .st-year-label) { height: 30px; }
.st-toolbar--phone .st-period-btn { padding: 0 6px; }
/* El iPhone de la escena es más estrecho que uno de verdad: el año, justo */
.st-toolbar--phone { gap: 6px; }
.st-toolbar--phone .st-year-step { width: 22px; }
.st-toolbar--phone .st-year-label { padding: 0 4px; }

/* ── Las tarjetas del Resumen ─────────────────────────────────────────── */
/* El bento: a lo ancho, el neto y lo que lo forma; al lado, la tarjeta
   oscura (--statement-*), que cambia de lo del año a lo del trimestre en la
   misma celda. */
.st-dash { display: grid; grid-template-columns: minmax(0, 1.9fr) minmax(0, 1fr); gap: 16px; align-items: stretch; }
.st-dash--compact { grid-template-columns: minmax(0, 1fr); gap: 12px; }
.st-card { min-width: 0; padding: 24px; border-radius: var(--radius-lg); background: var(--surface); }
.phone .st-card { padding: 16px; }
.st-hero { display: flex; flex-direction: column; }
.st-label { font-size: var(--t-sm); font-weight: 500; line-height: 1.25; color: var(--text-muted); }
.st-label--dot { display: inline-flex; align-items: center; gap: 6px; }
.st-dot { flex: none; width: 7px; height: 7px; border-radius: 50%; }
.st-dot--income { background: var(--green); }
.st-dot--expense { background: var(--red); }
.st-stats { display: flex; gap: 32px; margin-top: 16px; }
.st-stat { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.st-fig { display: block; width: max-content; white-space: nowrap; font-variant-numeric: tabular-nums; }
.st-fig--hero { margin-top: 8px; font-size: var(--t-hero); font-weight: 600; letter-spacing: -0.04em; line-height: 1; }
.st-fig--stat { font-size: var(--t-lg); font-weight: 600; letter-spacing: -0.01em; line-height: 1.25; }
.st-fig--st { margin-top: 8px; font-size: var(--t-2xl); font-weight: 700; letter-spacing: -0.03em; line-height: 1.1; color: var(--statement-text); }
.st-fig--st .st-unit { font-size: 0.6em; font-weight: 600; letter-spacing: 0; }
.st-fig--hero .st-unit { font-size: 0.6em; font-weight: 600; letter-spacing: 0; }
.st-green { color: var(--green); }
.st-red { color: var(--red); }
.st-yellow { color: var(--yellow); }
/* La curva del año, dentro de la tarjeta: con un trimestre se pliega */
.st-curve-wrap { display: grid; grid-template-rows: 1fr; opacity: 1; transition: grid-template-rows var(--spring-slow), opacity var(--spring-slow); }
.st-dash--quarter .st-curve-wrap { grid-template-rows: 0fr; opacity: 0; transition: grid-template-rows var(--spring-slow), opacity var(--spring-moderate-exit); }
.st-curve { min-height: 0; overflow: hidden; }
.st-curve svg { display: block; width: 100%; height: 96px; margin-top: 20px; }
.st-statement { display: grid; grid-template-rows: 1fr 0fr; align-content: start; min-width: 0; padding: 24px; border-radius: var(--radius-lg); background: var(--statement-bg); color: var(--statement-text); transition: grid-template-rows var(--spring-slow); }
.phone .st-statement { padding: 16px; }
.st-dash--quarter .st-statement { grid-template-rows: 0fr 1fr; }
.st-sv { display: flex; flex-direction: column; min-width: 0; min-height: 0; overflow: hidden; transition: opacity var(--spring-slow); }
.st-sv--quarter, .st-dash--quarter .st-sv--year { opacity: 0; pointer-events: none; transition-duration: 0.18s; }
.st-dash--quarter .st-sv--quarter { opacity: 1; pointer-events: auto; transition-delay: 0.1s; }
.st-statement .st-label { color: var(--statement-muted); }
.st-bar { display: block; height: 6px; border-radius: 99px; background: color-mix(in srgb, var(--statement-text) 16%, transparent); }
.st-hint { display: flex; flex-direction: column; gap: 6px; margin-top: 12px; }
.st-st-section { margin-top: 16px; font-size: var(--t-xs); color: var(--statement-muted); }
.st-st-row { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; padding-top: 8px; border-top: 0.5px solid var(--statement-line); }
.st-rule { height: 0.5px; margin: 16px 0; background: var(--statement-line); }
/* Debajo, lo que sigue: el IVA del año, cortado por el borde */
.st-below { margin-top: 16px; }
.phone .st-below { margin-top: 12px; }
.st-below-title { font-size: var(--t-sm); font-weight: 600; color: var(--text); }
.st-tiles { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; margin-top: 12px; }
.phone .st-tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.st-tile { display: flex; flex-direction: column; gap: 22px; padding: 10px 12px 12px; border-radius: var(--radius); background: var(--control-fill); }
.st-tile-q { font-size: var(--t-xs); color: var(--text-muted); }
.st-tile-bar { display: block; height: 8px; border-radius: 99px; background: color-mix(in srgb, var(--yellow) 55%, transparent); }

/* El móvil desplaza por debajo de la barra de arriba; periodo y año se
   quedan pegados bajo ella */
.st-scroll { position: absolute; top: 54px; left: 0; right: 0; bottom: 60px; overflow-y: auto; overscroll-behavior: contain; scrollbar-width: none; padding: 0 16px 24px; }
.st-scroll::-webkit-scrollbar { display: none; }
.st-sticky-top { position: sticky; top: 0; z-index: 3; box-sizing: border-box; height: 50px; margin: 0 -16px 6px; padding: 4px 16px 2px; background: color-mix(in srgb, var(--bg) 94%, transparent); -webkit-backdrop-filter: blur(20px) saturate(1.4); backdrop-filter: blur(20px) saturate(1.4); }
/* Periodo y año, con la misma franja de fondo que la barra de arriba: lo que
   pasa por debajo no se lee entre las cápsulas */
.st-sticky-bar { position: sticky; top: 50px; z-index: 2; margin: 0 -16px 12px; padding: 6px 16px; width: auto; background: color-mix(in srgb, var(--bg) 94%, transparent); -webkit-backdrop-filter: blur(20px) saturate(1.4); backdrop-filter: blur(20px) saturate(1.4); }

/* ── Cómo se mueve: el menú lateral (Sidebar) ─────────────────────────── */
.win-body.st-shell { display: flex; padding: 0; }
.st-side { width: 232px; flex-shrink: 0; display: flex; flex-direction: column; padding: 0 8px; }
.st-side-logo { display: flex; align-items: center; min-height: 40px; padding: 0 20px; font-size: var(--t-2xl); font-weight: 700; letter-spacing: -0.03em; color: var(--text); }
.st-side-search { display: flex; align-items: center; gap: 8px; margin: 12px 8px 0; padding: 6px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); color: var(--text-subtle); font-size: var(--t-sm); }
.st-side-search > span:nth-child(2) { flex: 1; }
.st-side-search svg { width: 14px; height: 14px; flex-shrink: 0; }
.st-kbds { display: inline-flex; gap: 2px; }
.st-kbds kbd { display: inline-flex; align-items: center; justify-content: center; min-width: 16px; height: 16px; padding: 0 4px; border-radius: var(--radius-xs); background: var(--control-fill); color: var(--text-subtle); font: inherit; font-size: var(--t-xs); }
.st-side-nav { position: relative; display: flex; flex-direction: column; gap: 2px; padding: 12px 8px; }
/* El resaltado, un velo más claro que el gris de lo elegido */
.st-side-nav .fluid-highlight { border-radius: var(--radius-sm); background: color-mix(in srgb, var(--surface-hover) 40%, transparent); }
.st-side-item { position: relative; z-index: 1; display: flex; align-items: center; gap: 12px; width: 100%; min-height: 40px; padding: 8px 12px; border: none; border-radius: var(--radius-sm); background: none; color: var(--text-muted); font: inherit; font-size: var(--t-base); font-weight: 500; text-align: left; white-space: nowrap; cursor: pointer; transition: background-color var(--spring-fast), color var(--spring-fast); }
.st-side-item.fluid-active { color: var(--text); }
.st-side-item.active { background: var(--surface-hover); color: var(--text); font-weight: 600; }
.st-side-icon { display: inline-flex; align-items: center; justify-content: center; width: 18px; height: 18px; flex-shrink: 0; filter: opacity(0.7); }
.st-side-icon svg { width: 18px; height: 18px; }
.st-side-item.active .st-side-icon { filter: none; }
.st-content { flex: 1; min-width: 0; padding: 4px 28px 0 20px; }
.st-page { transition: opacity var(--spring-moderate), transform var(--spring-moderate); }
.st-page.st-page-out { opacity: 0; transform: translateY(4px); transition: opacity var(--spring-moderate-exit), transform var(--spring-moderate-exit); }
.st-rows { display: flex; flex-direction: column; }
.st-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; height: 44px; padding: 0 8px; background-image: linear-gradient(color-mix(in srgb, var(--border) 55%, transparent), color-mix(in srgb, var(--border) 55%, transparent)); background-size: calc(100% - 16px) 1px; background-position: center bottom; background-repeat: no-repeat; }

/* ── Cómo se mueve: la hoja «Más» del móvil (MobileMoreSheet) ─────────── */
.st-mcards { display: flex; flex-direction: column; gap: 8px; }
.st-mcard { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-radius: var(--radius-lg); background: var(--surface); }
.st-mcard-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.st-mcard-title { font-size: var(--t-base); font-weight: 600; line-height: 1.25; color: var(--text); text-wrap: balance; }
.st-mcard-end { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.st-mcard-amount { font-size: var(--t-base); font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; color: var(--text); }
.st-scrim { position: absolute; inset: 0; z-index: 20; background: var(--scrim); opacity: 0; pointer-events: none; transition: opacity var(--spring-slow-exit); }
.st-scrim.open { opacity: 1; pointer-events: auto; transition: opacity var(--spring-slow); }
/* Abajo, lo que el borde de la escena corta del iPhone (60 px) va de relleno */
.st-sheet {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 21;
  display: flex; flex-direction: column; gap: 20px;
  padding: 12px 20px calc(32px + 60px);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  -webkit-backdrop-filter: blur(28px) saturate(1.4); backdrop-filter: blur(28px) saturate(1.4);
  transform: translateY(100%);
  transition: transform var(--spring-slow-exit);
}
.st-sheet.open { transform: none; transition: transform var(--spring-slow); }
.st-sheet-grab { display: flex; justify-content: center; }
.st-sheet-grab span { width: 36px; height: 4px; border-radius: 2px; background: var(--border-strong); }
.st-sheet-profile { display: flex; align-items: center; gap: 12px; width: 100%; padding: 4px 0 0; border: none; background: none; color: var(--text); font: inherit; text-align: left; cursor: pointer; }
.st-avatar { width: 44px; height: 44px; flex-shrink: 0; display: inline-flex; align-items: center; justify-content: center; border-radius: 50%; background: var(--surface-hover); box-shadow: inset 0 0 0 1px var(--border-strong); font-size: var(--t-base); font-weight: 600; color: var(--text); }
.st-sheet-who { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.st-sheet-who b { font-size: var(--t-base); font-weight: 600; }
.st-sheet-who span { font-size: var(--t-xs); color: var(--text-muted); }
.st-sheet-chev { display: inline-flex; color: var(--text-subtle); }
.st-sheet-actions { display: flex; flex-direction: column; gap: 4px; }
.st-sheet-btn { display: flex; align-items: center; gap: 12px; padding: 12px 8px; border: none; border-radius: var(--radius-sm); background: none; color: var(--text); font: inherit; font-size: var(--t-base); font-weight: 500; text-align: left; cursor: pointer; transition: background-color var(--spring-fast); }
.st-sheet-btn.pressed { background: var(--surface-hover); }
.st-sheet-btn--danger { color: var(--red); }
