/* theme_presupuesto.css
   -----------------------------------------------------------------------
   Sistema de diseño de Mindscending, inspirado en la interfaz de Revolut:
   superficies casi negras en modo oscuro, tarjetas muy redondeadas y sin
   sombras, jerarquía apoyada en el tamaño del monto y listas planas en
   vez de una tarjeta por fila. 

   Se mantienen los nombres de tokens estilo Material 3 (--color-primary,
   --color-surface-container…) para no romper las clases de Tailwind que
   ya usaban las páginas; lo que cambia son los valores y los componentes
   .rv-* definidos más abajo.
   ----------------------------------------------------------------------- */

/* ----------------------------- Tokens: claro ----------------------------- */
:root {
    /* Hace que los controles nativos (fechas, selects) sigan el tema. */
    color-scheme: light;

    /* Zonas seguras de iOS. Las páginas usan viewport-fit=cover y la barra
       de estado translúcida, así que el contenido llega hasta el borde:
       estas variables son las que apartan la barra superior del Dynamic
       Island y la navegación inferior del indicador de inicio. En un
       navegador de escritorio valen 0px y no cambian nada. */
    --safe-top: env(safe-area-inset-top, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    --safe-left: env(safe-area-inset-left, 0px);
    --safe-right: env(safe-area-inset-right, 0px);

    /* Alto de la navegación inferior (sin contar la zona segura). */
    --nav-height: 66px;

    /* Fondos: página blanca y tarjetas en gris muy claro (Revolut light). */
    --color-background: 255 255 255;
    --color-surface: 255 255 255;
    --color-surface-bright: 255 255 255;
    --color-surface-dim: 240 241 244;
    --color-surface-container-lowest: 255 255 255;
    --color-surface-container-low: 247 247 249;
    --color-surface-container: 243 244 246;
    --color-surface-container-high: 235 236 240;
    --color-surface-container-highest: 226 228 233;
    --color-surface-variant: 233 235 239;

    /* Texto */
    --color-on-background: 9 9 11;
    --color-on-surface: 9 9 11;
    --color-on-surface-variant: 110 116 126;
    --color-inverse-surface: 24 25 29;
    --color-inverse-on-surface: 247 247 248;

    /* Líneas */
    --color-outline: 158 164 173;
    --color-outline-variant: 226 228 233;

    /* Verde de la marca: el acento del módulo de finanzas. */
    --color-primary: 0 138 92;
    --color-on-primary: 255 255 255;
    --color-primary-container: 214 245 230;
    --color-on-primary-container: 0 66 43;
    --color-primary-fixed: 111 251 190;
    --color-primary-fixed-dim: 78 222 163;
    --color-on-primary-fixed: 0 33 19;
    --color-on-primary-fixed-variant: 0 82 54;
    --color-inverse-primary: 78 222 163;
    --color-surface-tint: 0 138 92;

    /* Gris neutro para acentos secundarios. */
    --color-secondary: 87 92 102;
    --color-on-secondary: 255 255 255;
    --color-secondary-container: 235 236 240;
    --color-on-secondary-container: 60 64 72;
    --color-secondary-fixed: 235 236 240;
    --color-secondary-fixed-dim: 214 217 223;
    --color-on-secondary-fixed: 24 25 29;
    --color-on-secondary-fixed-variant: 87 92 102;

    /* Azul informativo: segundo acento, muy presente en Revolut. */
    --color-tertiary: 19 97 245;
    --color-on-tertiary: 255 255 255;
    --color-tertiary-container: 224 234 254;
    --color-on-tertiary-container: 11 63 168;
    --color-tertiary-fixed: 224 234 254;
    --color-tertiary-fixed-dim: 168 196 253;
    --color-on-tertiary-fixed: 6 33 89;
    --color-on-tertiary-fixed-variant: 11 63 168;

    /* Rojo de gasto y sobregiro. */
    --color-error: 216 42 51;
    --color-on-error: 255 255 255;
    --color-error-container: 253 228 228;
    --color-on-error-container: 138 18 22;
}

/* ----------------------------- Tokens: oscuro ----------------------------- */
html.dark {
    color-scheme: dark;
    --color-background: 11 11 13;
    --color-surface: 11 11 13;
    --color-surface-bright: 42 43 49;
    --color-surface-dim: 6 6 8;
    --color-surface-container-lowest: 8 8 10;
    --color-surface-container-low: 20 21 24;
    --color-surface-container: 25 26 30;
    --color-surface-container-high: 33 34 39;
    --color-surface-container-highest: 44 45 51;
    --color-surface-variant: 44 45 51;

    --color-on-background: 247 247 248;
    --color-on-surface: 247 247 248;
    --color-on-surface-variant: 148 152 161;
    --color-inverse-surface: 247 247 248;
    --color-inverse-on-surface: 11 11 13;

    --color-outline: 110 114 122;
    --color-outline-variant: 44 45 51;

    --color-primary: 78 222 163;
    --color-on-primary: 0 51 34;
    --color-primary-container: 0 74 48;
    --color-on-primary-container: 150 251 205;
    --color-inverse-primary: 0 138 92;
    --color-surface-tint: 78 222 163;

    --color-secondary: 176 181 190;
    --color-on-secondary: 33 34 39;
    --color-secondary-container: 44 45 51;
    --color-on-secondary-container: 224 226 231;

    --color-tertiary: 91 141 255;
    --color-on-tertiary: 6 33 89;
    --color-tertiary-container: 18 34 74;
    --color-on-tertiary-container: 199 216 255;

    --color-error: 255 99 104;
    --color-on-error: 74 0 4;
    --color-error-container: 58 16 19;
    --color-on-error-container: 255 196 196;
}

/* -------------------------------- Base -------------------------------- */
*,
*::before,
*::after {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    padding: 0;
}

body {
    background-color: rgb(var(--color-background));
    color: rgb(var(--color-on-surface));
    font-family: Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
    font-size: 15px;
    line-height: 1.45;
    -webkit-font-smoothing: antialiased;
    overscroll-behavior-y: none;
    /* Bloquea el doble-tap para hacer zoom: se siente app, no página web. */
    touch-action: manipulation;
}

::-webkit-scrollbar {
    display: none;
}

* {
    scrollbar-width: none;
}

/* Transición suave al cambiar de tema. Las clases .rv-* la sobreescriben
   cuando necesitan animar algo más que el color. */
body,
body *:not(svg *) {
    transition: background-color .25s ease, border-color .25s ease, color .25s ease;
}

h1,
h2,
h3,
h4 {
    margin: 0;
    letter-spacing: -.02em;
}

p {
    margin: 0;
}

a {
    color: inherit;
}

.material-symbols-outlined {
    user-select: none;
}

.rv-filled {
    font-variation-settings: 'FILL' 1;
}

@media (prefers-reduced-motion: reduce) {

    *,
    *::before,
    *::after {
        animation-duration: .01ms !important;
        transition-duration: .01ms !important;
    }
}

/* ------------------------------- Montos ------------------------------- */
/* Revolut apoya la jerarquía en el monto: entero grande, centavos más
   pequeños y atenuados. .rv-amount es el bloque, .rv-cents el sufijo. */
.rv-amount {
    font-weight: 700;
    letter-spacing: -.03em;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.rv-cents {
    font-size: .62em;
    opacity: .5;
    letter-spacing: 0;
}

.rv-amount--hero {
    font-size: 42px;
    line-height: 1.05;
}

.rv-amount--xl {
    font-size: 28px;
    line-height: 1.1;
}

.rv-amount--lg {
    font-size: 20px;
    line-height: 1.2;
}

.rv-amount--md {
    font-size: 16px;
    line-height: 1.25;
}

@media (min-width: 768px) {
    .rv-amount--hero {
        font-size: 54px;
    }
}

.rv-num {
    font-variant-numeric: tabular-nums;
}

/* ----------------------------- Tipografía ----------------------------- */
.rv-display {
    font-size: 28px;
    font-weight: 700;
    line-height: 1.15;
    letter-spacing: -.03em;
}

@media (min-width: 768px) {
    .rv-display {
        font-size: 34px;
    }
}

.rv-title {
    font-size: 19px;
    font-weight: 700;
    line-height: 1.25;
}

.rv-subtitle {
    font-size: 15px;
    font-weight: 600;
}

.rv-body {
    font-size: 15px;
    color: rgb(var(--color-on-surface-variant));
}

.rv-eyebrow {
    font-size: 13px;
    font-weight: 600;
    color: rgb(var(--color-on-surface-variant));
}

.rv-caption {
    font-size: 13px;
    line-height: 1.35;
    color: rgb(var(--color-on-surface-variant));
}

.rv-muted {
    color: rgb(var(--color-on-surface-variant));
}

.rv-pos {
    color: rgb(var(--color-primary));
}

.rv-neg {
    color: rgb(var(--color-error));
}

.rv-link {
    background: none;
    border: 0;
    padding: 0;
    font: inherit;
    font-size: 14px;
    font-weight: 600;
    color: rgb(var(--color-primary));
    cursor: pointer;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 2px;
}

.rv-link:hover {
    opacity: .75;
}

/* ------------------------------ Tarjetas ------------------------------ */
.rv-card {
    background-color: rgb(var(--color-surface-container));
    border: 1px solid rgb(var(--color-outline-variant) / .8);
    border-radius: 22px;
    padding: 20px;
}

.rv-card--flat {
    background-color: rgb(var(--color-surface-container-low));
}

.rv-card--plain {
    background-color: transparent;
    border-color: transparent;
    padding: 0;
}

.rv-card--tight {
    padding: 14px;
}

@media (min-width: 768px) {
    .rv-card {
        padding: 24px;
    }

    .rv-card--tight {
        padding: 16px;
    }
}

/* Tarjeta física estilo Revolut: metal oscuro con brillo diagonal. */
.rv-paycard {
    position: relative;
    overflow: hidden;
    border-radius: 26px;
    padding: 22px;
    min-height: 196px;
    color: #fff;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    background: radial-gradient(130% 120% at 88% 0%, #1d6b4f 0%, #0b3527 42%, #07110d 100%);
    transform-style: preserve-3d;
}

.rv-paycard::after {
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
    background: linear-gradient(128deg, rgb(255 255 255 / .16) 0%, rgb(255 255 255 / 0) 46%);
}

.rv-paycard>* {
    position: relative;
    z-index: 1;
}

.rv-paycard__label {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .09em;
    text-transform: uppercase;
    color: rgb(255 255 255 / .6);
}

.rv-paycard__digits {
    font-size: 13px;
    font-weight: 600;
    letter-spacing: .2em;
    color: rgb(255 255 255 / .7);
    font-variant-numeric: tabular-nums;
}

/* -------------------------------- Filas -------------------------------- */
/* Lista plana: sin tarjeta por fila, separadas por aire y no por bordes. */
.rv-list {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.rv-list--divided>*+* {
    border-top: 1px solid rgb(var(--color-outline-variant) / .75);
}

.rv-row {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 10px 8px;
    margin: 0;
    border: 0;
    border-radius: 16px;
    background: transparent;
    color: inherit;
    font: inherit;
    text-align: left;
    text-decoration: none;
}

.rv-list--divided .rv-row {
    border-radius: 0;
    padding: 14px 8px;
}

button.rv-row,
a.rv-row,
.rv-row--tappable {
    cursor: pointer;
}

button.rv-row:hover,
a.rv-row:hover,
.rv-row--tappable:hover {
    background-color: rgb(var(--color-surface-container-high) / .6);
}

.rv-row__body {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.rv-row__title {
    font-size: 15px;
    font-weight: 600;
    line-height: 20px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.rv-row__sub {
    font-size: 13px;
    line-height: 18px;
    color: rgb(var(--color-on-surface-variant));
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.rv-row__value {
    flex: 0 0 auto;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 1px;
    text-align: right;
}

.rv-row__actions {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 2px;
}

/* Fila de ajuste (nombre a la izquierda, valor a la derecha). El título se
   reparte en dos líneas antes que recortarse: en un móvil de 375px un
   nombre como "Gastos fijos y variables" no cabe en una sola. */
.rv-row--setting .rv-row__title {
    white-space: normal;
    overflow: visible;
}

.rv-row--setting .rv-row__value {
    max-width: 46%;
}

/* Con un valor a la derecha, en un móvil no queda ancho para una tercera
   pieza de texto: el subtítulo se esconde y la fila se lee como en la app
   de ajustes del teléfono (icono, nombre y valor). */
@media (max-width: 480px) {
    .rv-row--valued .rv-row__body .rv-row__sub {
        display: none;
    }
}

@media (min-width: 768px) {
    .rv-row__actions--hover {
        opacity: 0;
        transition: opacity .18s ease;
    }

    .rv-row:hover .rv-row__actions--hover,
    .rv-row:focus-within .rv-row__actions--hover {
        opacity: 1;
    }
}

/* Encabezado de grupo por fecha: "Hoy", "Ayer", "8 de septiembre". */
.rv-day {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    padding: 16px 8px 6px;
    font-size: 13px;
    font-weight: 600;
    color: rgb(var(--color-on-surface-variant));
}

/* ------------------------------ Avatares ------------------------------ */
.rv-avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    flex: 0 0 auto;
    background-color: rgb(var(--color-surface-container-high));
    color: rgb(var(--color-on-surface));
    font-weight: 700;
}

.rv-avatar .material-symbols-outlined {
    font-size: 22px;
}

.rv-avatar--sm {
    width: 36px;
    height: 36px;
}

.rv-avatar--sm .material-symbols-outlined {
    font-size: 18px;
}

.rv-avatar--lg {
    width: 52px;
    height: 52px;
}

.rv-avatar--lg .material-symbols-outlined {
    font-size: 26px;
}

/* Rellenos del avatar cuando lleva un icono en vez de iniciales: se usan
   en las listas de ajustes para separar lo informativo (tint/neutral) de
   lo que borra o cierra algo (danger). */
.rv-avatar--tint {
    background-color: rgb(var(--color-primary) / .14);
    color: rgb(var(--color-primary));
}

.rv-avatar--neutral {
    background-color: rgb(var(--color-surface-container-high));
    color: rgb(var(--color-on-surface-variant));
}

.rv-avatar--danger {
    background-color: rgb(var(--color-error) / .14);
    color: rgb(var(--color-error));
}

/* -------------------------- Acciones rápidas -------------------------- */
.rv-actions {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 8px;
}

.rv-action {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    flex: 1 1 0;
    min-width: 0;
    padding: 0;
    border: 0;
    background: none;
    color: inherit;
    font: inherit;
    cursor: pointer;
    text-decoration: none;
}

.rv-action__icon {
    width: 54px;
    height: 54px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    background-color: rgb(var(--color-surface-container-high));
    color: rgb(var(--color-on-surface));
    transition: transform .16s cubic-bezier(.2, .9, .25, 1), background-color .2s ease, filter .2s ease;
}

.rv-action:hover .rv-action__icon {
    background-color: rgb(var(--color-surface-container-highest));
}

.rv-action:active .rv-action__icon {
    transform: scale(.9);
}

.rv-action__label {
    font-size: 12px;
    font-weight: 600;
    color: rgb(var(--color-on-surface-variant));
    text-align: center;
}

.rv-action--primary .rv-action__icon {
    background-color: rgb(var(--color-primary));
    color: rgb(var(--color-on-primary));
}

.rv-action--primary:hover .rv-action__icon {
    background-color: rgb(var(--color-primary));
    filter: brightness(1.07);
}

/* ------------------------------- Botones ------------------------------- */
.rv-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    height: 52px;
    padding: 0 22px;
    border: 0;
    border-radius: 999px;
    font: inherit;
    font-size: 15px;
    font-weight: 700;
    white-space: nowrap;
    cursor: pointer;
    text-decoration: none;
    background-color: rgb(var(--color-surface-container-high));
    color: rgb(var(--color-on-surface));
    transition: transform .12s ease, filter .2s ease, background-color .2s ease, opacity .2s ease;
}

.rv-btn:active {
    transform: scale(.98);
}

.rv-btn--block {
    width: 100%;
}

.rv-btn--sm {
    height: 42px;
    font-size: 14px;
    padding: 0 18px;
}

.rv-btn--primary {
    background-color: rgb(var(--color-primary));
    color: rgb(var(--color-on-primary));
}

.rv-btn--primary:hover {
    filter: brightness(1.07);
}

/* Secundario: el mismo relleno tonal de la base, con nombre propio para
   que en el HTML se lea el papel del botón y no solo su ausencia. */
.rv-btn--tonal {
    background-color: rgb(var(--color-surface-container-high));
    color: rgb(var(--color-on-surface));
}

.rv-btn--tonal:hover {
    background-color: rgb(var(--color-surface-container-highest));
}

.rv-btn--dark {
    background-color: rgb(var(--color-on-surface));
    color: rgb(var(--color-surface));
}

.rv-btn--dark:hover {
    filter: brightness(1.3);
}

/* Acciones que borran datos: nunca es el botón por defecto de una hoja. */
.rv-btn--danger {
    background-color: rgb(var(--color-error));
    color: rgb(var(--color-on-error));
}

.rv-btn--danger:hover {
    filter: brightness(1.07);
}

.rv-btn--ghost {
    background-color: transparent;
    color: rgb(var(--color-on-surface-variant));
}

.rv-btn--ghost:hover {
    background-color: rgb(var(--color-surface-container-high) / .7);
}

.rv-btn[disabled] {
    opacity: .4;
    cursor: not-allowed;
    transform: none;
}

/* Botón de icono circular: barra superior, editar, borrar… */
.rv-icon-btn {
    width: 40px;
    height: 40px;
    border: 0;
    border-radius: 50%;
    display: grid;
    place-items: center;
    background: transparent;
    color: rgb(var(--color-on-surface-variant));
    cursor: pointer;
    flex: 0 0 auto;
    transition: background-color .18s ease, color .18s ease;
}

.rv-icon-btn:hover {
    background-color: rgb(var(--color-surface-container-high));
    color: rgb(var(--color-on-surface));
}

/* Icono de la cabecera que lleva a la página abierta (Ajustes en el móvil). */
.rv-icon-btn[aria-current="page"] {
    background-color: rgb(var(--color-surface-container-high));
    color: rgb(var(--color-on-surface));
}

.rv-icon-btn--sm {
    width: 32px;
    height: 32px;
}

.rv-icon-btn--sm .material-symbols-outlined {
    font-size: 18px;
}

.rv-icon-btn--danger:hover {
    background-color: rgb(var(--color-error) / .14);
    color: rgb(var(--color-error));
}

/* -------------------------- Control segmentado -------------------------- */
.rv-seg {
    position: relative;
    display: flex;
    padding: 4px;
    border-radius: 999px;
    background-color: rgb(var(--color-surface-container-high));
}

.rv-seg__thumb {
    position: absolute;
    top: 4px;
    bottom: 4px;
    left: 4px;
    border-radius: 999px;
    background-color: rgb(var(--color-surface-container-lowest));
    box-shadow: 0 1px 4px rgb(0 0 0 / .18);
    transition: transform .3s cubic-bezier(.4, 0, .2, 1);
}

html.dark .rv-seg__thumb {
    background-color: rgb(var(--color-surface-container-highest));
}

.rv-seg--2 .rv-seg__thumb {
    width: calc(50% - 4px);
}

.rv-seg--3 .rv-seg__thumb {
    width: calc((100% - 8px) / 3);
}

.rv-seg__btn {
    position: relative;
    z-index: 1;
    flex: 1 1 0;
    padding: 9px 10px;
    border: 0;
    border-radius: 999px;
    background: none;
    font: inherit;
    font-size: 14px;
    font-weight: 600;
    color: rgb(var(--color-on-surface-variant));
    cursor: pointer;
    transition: color .2s ease;
}

.rv-seg__btn[aria-selected="true"] {
    color: rgb(var(--color-on-surface));
}

/* -------------------------------- Chips -------------------------------- */
.rv-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 7px 14px 7px 7px;
    border: 0;
    border-radius: 999px;
    background-color: rgb(var(--color-surface-container-high));
    color: rgb(var(--color-on-surface));
    font: inherit;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background-color .2s ease, color .2s ease, transform .1s ease;
}

.rv-chip:active {
    transform: scale(.96);
}

.rv-chip__dot {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    flex: 0 0 auto;
}

.rv-chip__dot .material-symbols-outlined {
    font-size: 17px;
}

.rv-chip[aria-pressed="true"] {
    background-color: rgb(var(--color-on-surface));
    color: rgb(var(--color-surface));
}

.rv-chip--plain {
    padding: 7px 14px;
}

/* Chip que llena su celda de una rejilla y deja partir el texto en dos
   líneas (opciones de selección múltiple del onboarding). */
.rv-chip--tile {
    width: 100%;
    min-height: 52px;
    padding: 8px 12px 8px 8px;
    border-radius: 16px;
    text-align: left;
    line-height: 1.25;
}

/* Marca al final de un chip (p. ej. un gasto fijo que se cobra solo). */
.rv-chip__tail {
    font-size: 16px;
    opacity: .55;
    margin-left: -2px;
}

/* Etiqueta pequeña de estado: porcentaje, "Sobregiro"… */
.rv-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 9px;
    border-radius: 999px;
    background-color: rgb(var(--color-surface-container-high));
    color: rgb(var(--color-on-surface-variant));
    font-size: 12px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.rv-badge--pos {
    background-color: rgb(var(--color-primary) / .16);
    color: rgb(var(--color-primary));
}

.rv-badge--neg {
    background-color: rgb(var(--color-error) / .16);
    color: rgb(var(--color-error));
}

.rv-badge--info {
    background-color: rgb(var(--color-tertiary) / .16);
    color: rgb(var(--color-tertiary));
}

.rv-badge .material-symbols-outlined {
    font-size: 14px;
}

/* ------------------------------ Progreso ------------------------------ */
.rv-progress {
    height: 6px;
    border-radius: 999px;
    background-color: rgb(var(--color-surface-variant));
    overflow: hidden;
}

.rv-progress--thin {
    height: 4px;
}

.rv-progress__fill {
    height: 100%;
    border-radius: 999px;
    background-color: rgb(var(--color-primary));
    transition: width 1s cubic-bezier(.2, .8, .2, 1);
}

/* Dona de reparto de gastos, estilo "Analytics" de Revolut. */
.rv-donut {
    transform: rotate(-90deg);
}

.rv-donut circle {
    fill: none;
    stroke-linecap: round;
    transition: stroke-dashoffset 1s cubic-bezier(.2, .8, .2, 1);
}

/* ----------------------------- Formularios ----------------------------- */
.rv-field {
    display: flex;
    flex-direction: column;
    gap: 7px;
}

.rv-label {
    font-size: 13px;
    font-weight: 600;
    color: rgb(var(--color-on-surface-variant));
}

.rv-input {
    width: 100%;
    height: 52px;
    padding: 0 16px;
    border: 1px solid rgb(var(--color-outline-variant));
    border-radius: 16px;
    background-color: rgb(var(--color-surface-container-low));
    color: rgb(var(--color-on-surface));
    font: inherit;
    font-size: 16px;
    outline: none;
    transition: border-color .2s ease, background-color .2s ease;
}

.rv-input:focus {
    border-color: rgb(var(--color-primary));
    background-color: rgb(var(--color-surface-container-lowest));
}

.rv-input::placeholder {
    color: rgb(var(--color-on-surface-variant) / .8);
}

textarea.rv-input {
    height: auto;
    padding: 14px 16px;
    resize: none;
    line-height: 1.45;
}

select.rv-input {
    appearance: none;
    cursor: pointer;
    padding-right: 42px;
}

.rv-select {
    position: relative;
}

.rv-select>.material-symbols-outlined {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    pointer-events: none;
    color: rgb(var(--color-on-surface-variant));
}

.rv-input-amount {
    width: 100%;
    border: 0;
    background: transparent;
    outline: none;
    color: inherit;
    font: inherit;
    text-align: center;
    font-weight: 700;
    letter-spacing: -.03em;
    font-variant-numeric: tabular-nums;
    font-size: 46px;
    line-height: 1.1;
    caret-color: rgb(var(--color-primary));
}

.rv-input-amount::placeholder {
    color: rgb(var(--color-on-surface-variant) / .35);
}

.rv-input-amount::-webkit-outer-spin-button,
.rv-input-amount::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

/* Monto editable dentro de una fila (límites de presupuesto). */
.rv-inline-money {
    display: flex;
    align-items: center;
    gap: 2px;
    height: 40px;
    padding: 0 12px;
    border-radius: 12px;
    border: 1px solid transparent;
    background-color: rgb(var(--color-surface-container-high));
    transition: border-color .2s ease, background-color .2s ease;
}

.rv-inline-money:focus-within {
    border-color: rgb(var(--color-primary));
    background-color: rgb(var(--color-surface-container-lowest));
}

.rv-inline-money__prefix {
    font-size: 15px;
    font-weight: 600;
    color: rgb(var(--color-on-surface-variant));
}

.rv-inline-money input {
    width: 84px;
    border: 0;
    background: transparent;
    outline: none;
    color: inherit;
    font: inherit;
    font-size: 16px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    text-align: right;
    appearance: textfield;
    -moz-appearance: textfield;
}

.rv-inline-money input::-webkit-outer-spin-button,
.rv-inline-money input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

/* Monto con un selector al lado (día de cobro de un gasto fijo). */
.rv-money-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

.rv-select--mini > select {
    height: 40px;
    padding: 0 30px 0 12px;
    border: 1px solid transparent;
    border-radius: 12px;
    background-color: rgb(var(--color-surface-container-high));
    color: rgb(var(--color-on-surface));
    font: inherit;
    font-size: 14px;
    font-weight: 600;
    appearance: none;
    -webkit-appearance: none;
    cursor: pointer;
    outline: none;
    transition: border-color .2s ease, background-color .2s ease;
}

.rv-select--mini > select:focus {
    border-color: rgb(var(--color-primary));
    background-color: rgb(var(--color-surface-container-lowest));
}

.rv-select--mini > .material-symbols-outlined {
    right: 8px;
    font-size: 18px;
}

/* En pantallas estrechas el monto salta a su propia línea, para que el
   nombre del apartado no quede recortado a tres letras. */
.rv-row--wrap {
    flex-wrap: wrap;
}

/* El cuerpo parte de ancho cero: así un subtítulo largo se recorta en vez
   de mandar el monto a la línea de abajo en pantallas anchas. */
.rv-row--wrap .rv-row__body {
    flex-basis: 0;
}

@media (max-width: 540px) {
    .rv-row--wrap .rv-row__money {
        order: 3;
        flex: 1 1 100%;
    }

    .rv-row--wrap .rv-row__actions {
        order: 2;
    }

    .rv-row--wrap .rv-inline-money {
        width: 100%;
    }

    .rv-row--wrap .rv-money-group .rv-inline-money {
        flex: 1 1 auto;
        width: auto;
        min-width: 0;
    }

    /* Un input aporta su ancho por defecto (unos 220px) al mínimo de la
       fila: junto al selector de día eso la desborda. Con base 0 solo ocupa
       el hueco que queda. */
    .rv-row--wrap .rv-row__money {
        min-width: 0;
    }

    .rv-row--wrap .rv-money-group .rv-inline-money input {
        flex: 1 1 0;
        width: 0;
        min-width: 0;
    }

    .rv-row--wrap .rv-inline-money input {
        flex: 1 1 auto;
        width: auto;
    }
}

/* Barra de acción fija al fondo, por encima de la navegación móvil. */
.rv-sticky-bar {
    position: sticky;
    bottom: calc(var(--nav-height) + 10px + var(--safe-bottom));
    z-index: 20;
    padding: 20px 0 12px;
    background: linear-gradient(to top,
            rgb(var(--color-background)) 0,
            rgb(var(--color-background)) 74%,
            rgb(var(--color-background) / 0) 100%);
}

@media (min-width: 768px) {
    .rv-sticky-bar {
        bottom: 12px;
    }
}

/* Interruptor estilo iOS/Revolut. */
.rv-switch {
    position: relative;
    display: inline-flex;
    flex: 0 0 auto;
}

.rv-switch input {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    margin: 0;
    opacity: 0;
    cursor: pointer;
    z-index: 1;
}

.rv-switch__track {
    position: relative;
    width: 50px;
    height: 30px;
    border-radius: 999px;
    background-color: rgb(var(--color-surface-container-highest));
    transition: background-color .25s ease;
}

.rv-switch__track::after {
    content: "";
    position: absolute;
    top: 3px;
    left: 3px;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 1px 3px rgb(0 0 0 / .3);
    transition: transform .25s cubic-bezier(.4, 0, .2, 1);
}

.rv-switch input:checked+.rv-switch__track {
    background-color: rgb(var(--color-primary));
}

.rv-switch input:checked+.rv-switch__track::after {
    transform: translateX(20px);
}

/* ------------------------------- Teclado ------------------------------- */
.rv-keypad {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
}

.rv-key {
    height: 62px;
    border: 0;
    border-radius: 20px;
    background: transparent;
    color: rgb(var(--color-on-surface));
    font: inherit;
    font-size: 26px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    cursor: pointer;
    display: grid;
    place-items: center;
    transition: background-color .15s ease, transform .1s ease;
}

.rv-key:hover {
    background-color: rgb(var(--color-surface-container-low));
}

.rv-key:active {
    background-color: rgb(var(--color-surface-container-high));
    transform: scale(.94);
}

/* Teclado con calculadora: una cuarta columna para + − × ÷. */
.rv-keypad--calc {
    grid-template-columns: repeat(4, 1fr);
}

.rv-key--op {
    font-size: 28px;
    color: rgb(var(--color-primary));
    background-color: rgb(var(--color-primary) / .10);
}

.rv-key--op:hover {
    background-color: rgb(var(--color-primary) / .16);
}

.rv-key--op:active {
    background-color: rgb(var(--color-primary) / .24);
}

/* Mientras hay una operación, el monto grande muestra la cuenta y encoge
   para que quepa; debajo va el resultado. */
.rv-amount-expression {
    white-space: normal;
    overflow-wrap: anywhere;
    text-align: center;
}

.rv-amount--fit-md {
    font-size: 32px;
}

.rv-amount--fit-sm {
    font-size: 24px;
}

@media (min-width: 768px) {
    .rv-amount--fit-md {
        font-size: 40px;
    }

    .rv-amount--fit-sm {
        font-size: 30px;
    }
}

.rv-amount-result {
    border: 0;
    padding: 2px 10px;
    border-radius: 999px;
    background: transparent;
    font: inherit;
    font-size: 17px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    color: rgb(var(--color-primary));
    cursor: pointer;
}

.rv-amount-result:hover {
    background-color: rgb(var(--color-primary) / .10);
}

.rv-amount-result[disabled] {
    color: rgb(var(--color-error));
    cursor: default;
    background: transparent;
}

/* ------------------------- Barras de navegación ------------------------- */
.rv-topbar {
    position: sticky;
    top: 0;
    z-index: 50;
    /* El relleno superior es la altura de la barra de estado: sin esto el
       contenido de la cabecera queda tapado por el Dynamic Island. */
    padding-top: var(--safe-top);
    background-color: rgb(var(--color-background) / .88);
    backdrop-filter: blur(20px) saturate(1.4);
    -webkit-backdrop-filter: blur(20px) saturate(1.4);
    border-bottom: 1px solid rgb(var(--color-outline-variant) / .8);
}

.rv-topbar__inner {
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.rv-tabs {
    display: none;
    align-items: center;
    gap: 4px;
}

@media (min-width: 768px) {
    .rv-tabs {
        display: flex;
    }
}

.rv-tab {
    padding: 8px 14px;
    border-radius: 999px;
    font-size: 14px;
    font-weight: 600;
    color: rgb(var(--color-on-surface-variant));
    text-decoration: none;
    transition: background-color .2s ease, color .2s ease;
}

.rv-tab:hover {
    background-color: rgb(var(--color-surface-container-high) / .7);
    color: rgb(var(--color-on-surface));
}

.rv-tab[aria-current="page"] {
    background-color: rgb(var(--color-surface-container-high));
    color: rgb(var(--color-on-surface));
}

/* Píldora con el presupuesto activo, junto al avatar. Abre la lista para
   cambiar de presupuesto o crear otro. Es lo único de la cabecera que
   encoge: si falta sitio, el nombre se recorta con puntos suspensivos. */
.rv-ledger-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
    height: 36px;
    padding: 0 8px 0 4px;
    border: 0;
    border-radius: 999px;
    background-color: rgb(var(--color-surface-container-high));
    color: rgb(var(--color-on-surface));
    font: inherit;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
}

.rv-ledger-btn:hover {
    background-color: rgb(var(--color-surface-container-highest));
}

/* El color real lo pone selector_presupuesto.js; este es el del principal. */
.rv-ledger-btn__icon {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    flex: 0 0 auto;
    background-color: rgb(var(--color-primary) / .16);
    color: rgb(var(--color-primary));
}

.rv-ledger-btn__icon .material-symbols-outlined {
    font-size: 16px;
}

.rv-ledger-btn__name {
    min-width: 0;
    max-width: 160px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.rv-ledger-btn__caret {
    flex: 0 0 auto;
    font-size: 18px;
    color: rgb(var(--color-on-surface-variant));
}

/* Fila de la lista: tocar la fila cambia de presupuesto; el lápiz lo edita. */
.rv-ledger-item {
    display: flex;
    align-items: center;
    gap: 2px;
}

.rv-ledger-item>.rv-row {
    flex: 1 1 auto;
    min-width: 0;
}

.rv-ledger-item__check {
    flex: 0 0 auto;
    font-size: 20px;
    color: rgb(var(--color-primary));
}

.rv-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 50;
    display: flex;
    align-items: center;
    justify-content: space-around;
    /* La barra crece para incluir la zona del indicador de inicio, en vez
       de comprimir los iconos dentro de los 66px: así no se salen de su
       sitio en los iPhone con notch o Dynamic Island. */
    height: calc(var(--nav-height) + var(--safe-bottom));
    padding-bottom: var(--safe-bottom);
    padding-left: var(--safe-left);
    padding-right: var(--safe-right);
    background-color: rgb(var(--color-background) / .92);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-top: 1px solid rgb(var(--color-outline-variant) / .8);
}

@media (min-width: 768px) {
    .rv-nav {
        display: none;
    }
}

.rv-nav__item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    min-width: 66px;
    text-decoration: none;
    color: rgb(var(--color-on-surface-variant));
    font-size: 10px;
    font-weight: 700;
    letter-spacing: .02em;
}

.rv-nav__item[aria-current="page"] {
    color: rgb(var(--color-on-surface));
}

.rv-nav__fab {
    width: 52px;
    height: 52px;
    margin-top: -20px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    background-color: rgb(var(--color-primary));
    color: rgb(var(--color-on-primary));
    box-shadow: 0 8px 22px rgb(var(--color-primary) / .38);
}

/* ------------------------- Hojas y diálogos ------------------------- */
.rv-overlay {
    position: fixed;
    inset: 0;
    z-index: 70;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    background: rgb(0 0 0 / .55);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
}

@media (min-width: 768px) {
    .rv-overlay {
        align-items: center;
    }
}

.rv-sheet {
    width: 100%;
    max-width: 460px;
    max-height: 88vh;
    overflow-y: auto;
    background-color: rgb(var(--color-surface-container-low));
    border-radius: 28px 28px 0 0;
    padding: 20px 20px calc(20px + var(--safe-bottom));
    display: flex;
    flex-direction: column;
    gap: 18px;
    animation: rv-sheet-in .3s cubic-bezier(.2, .9, .25, 1);
}

@media (min-width: 768px) {
    .rv-sheet {
        border-radius: 28px;
        padding: 24px;
    }
}

/* El editor de gastos fijos y variables lleva dos listas y un total, así
   que necesita más ancho que una hoja de confirmación. */
.rv-sheet--wide {
    max-width: 560px;
}

/* Lista de presupuestos: hoja inferior en el móvil y, en escritorio, un menú
   que cuelga de la píldora de la cabecera (selector_presupuesto.js calcula
   --menu-top y --menu-left al abrirlo). */
@media (min-width: 768px) {
    .rv-overlay--menu {
        align-items: flex-start;
        justify-content: flex-start;
        background: transparent;
        backdrop-filter: none;
        -webkit-backdrop-filter: none;
    }

    .rv-overlay--menu .rv-sheet {
        position: absolute;
        top: var(--menu-top, 72px);
        left: var(--menu-left, 32px);
        width: 320px;
        max-height: min(70vh, 520px);
        padding: 12px;
        gap: 8px;
        border: 1px solid rgb(var(--color-outline-variant));
        border-radius: 22px;
        box-shadow: 0 18px 48px rgb(0 0 0 / .18);
        animation: rv-menu-in .16s ease-out;
    }

    .rv-overlay--menu .rv-sheet__grip {
        display: none;
    }
}

@keyframes rv-menu-in {
    from {
        transform: translateY(-6px);
        opacity: 0;
    }

    to {
        transform: none;
        opacity: 1;
    }
}

/* Elegir icono y color (hoja de presupuesto). */
.rv-choice-icon {
    width: 100%;
    aspect-ratio: 1;
    border: 0;
    border-radius: 14px;
    display: grid;
    place-items: center;
    background-color: rgb(var(--color-surface-container-high));
    color: rgb(var(--color-on-surface-variant));
    cursor: pointer;
}

.rv-choice-icon .material-symbols-outlined {
    font-size: 20px;
}

.rv-choice-icon[aria-pressed="true"] {
    background-color: rgb(var(--color-on-surface));
    color: rgb(var(--color-surface));
}

.rv-choice-color {
    width: 36px;
    height: 36px;
    border: 0;
    border-radius: 999px;
    cursor: pointer;
    transition: box-shadow .2s ease;
}

.rv-choice-color[aria-pressed="true"] {
    box-shadow: 0 0 0 3px rgb(var(--color-surface-container-low)), 0 0 0 5px rgb(var(--color-on-surface));
}

@keyframes rv-sheet-in {
    from {
        transform: translateY(28px);
        opacity: 0;
    }

    to {
        transform: none;
        opacity: 1;
    }
}

.rv-sheet__grip {
    width: 42px;
    height: 4px;
    border-radius: 999px;
    background-color: rgb(var(--color-outline) / .45);
    margin: -6px auto 0;
}

/* Aviso breve de que algo se guardó, se envió o se borró. Aparece sobre la
   navegación inferior y se va solo. */
.rv-toast {
    position: fixed;
    left: 50%;
    bottom: calc(var(--nav-height) + 18px + var(--safe-bottom));
    z-index: 90;
    max-width: min(92vw, 420px);
    padding: 12px 18px;
    border-radius: 999px;
    background-color: rgb(var(--color-inverse-surface));
    color: rgb(var(--color-inverse-on-surface));
    font-size: 14px;
    font-weight: 600;
    text-align: center;
    box-shadow: 0 10px 30px rgb(0 0 0 / .28);
    opacity: 0;
    transform: translate(-50%, 12px);
    pointer-events: none;
    transition: opacity .22s ease, transform .22s ease;
}

.rv-toast--on {
    opacity: 1;
    transform: translate(-50%, 0);
}

@media (min-width: 768px) {
    .rv-toast {
        bottom: 26px;
    }
}

/* ----------------------------- Utilidades ----------------------------- */
.rv-shell {
    width: 100%;
    margin: 0 auto;
    padding-left: calc(18px + var(--safe-left));
    padding-right: calc(18px + var(--safe-right));
}

@media (min-width: 768px) {
    .rv-shell {
        max-width: 1120px;
        padding-left: calc(32px + var(--safe-left));
        padding-right: calc(32px + var(--safe-right));
    }
}

/* Contenido principal: deja libre la navegación inferior y su zona segura. */
.rv-main {
    padding-bottom: calc(var(--nav-height) + 30px + var(--safe-bottom));
}

@media (min-width: 768px) {
    .rv-main {
        padding-bottom: 48px;
    }
}

/* Páginas de una sola tarjeta centrada (acceso y onboarding). */
.rv-centered-page {
    min-height: 100dvh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: calc(40px + var(--safe-top)) calc(20px + var(--safe-right)) calc(40px + var(--safe-bottom)) calc(20px + var(--safe-left));
}

.rv-hairline {
    border: 0;
    border-top: 1px solid rgb(var(--color-outline-variant) / .8);
    margin: 0;
}

.rv-scroll-x {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 4px;
    scroll-snap-type: x proximity;
    -webkit-overflow-scrolling: touch;
}

.rv-scroll-x>* {
    scroll-snap-align: start;
    flex: 0 0 auto;
}

@keyframes rv-in {
    from {
        opacity: 0;
        transform: translateY(7px);
    }

    to {
        opacity: 1;
        transform: none;
    }
}

.rv-in {
    animation: rv-in .34s cubic-bezier(.2, .9, .25, 1) both;
}

@keyframes rv-pop {
    0% {
        transform: scale(1);
    }

    45% {
        transform: scale(1.06);
    }

    100% {
        transform: scale(1);
    }
}

.rv-pop {
    animation: rv-pop .42s cubic-bezier(.2, .9, .25, 1);
}

.rv-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    text-align: center;
    padding: 32px 16px;
}

.rv-empty__icon {
    width: 58px;
    height: 58px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    background-color: rgb(var(--color-surface-container-high));
    color: rgb(var(--color-on-surface-variant));
}

.rv-empty__icon .material-symbols-outlined {
    font-size: 28px;
}