:root {
    --fondo: #f3f3f1;
    --superficie: #ffffff;
    --texto: #161616;
    --suave: #5c5c5c;
    --linea: #e2e2de;
    --linea-fuerte: #cfcfc8;
    --marca: #111111;
    --ok: #1c6b45;
    --ok-fondo: #e7f5ee;
    --peligro: #9b1c1c;
    --ppto: #b42318;
    --venta: #1d4e89;
    --aviso-ok: #e7f5ee;
    --aviso-error: #f8e8e8;
    --sombra: 0 1px 2px rgba(17, 17, 17, 0.04), 0 1px 1px rgba(17, 17, 17, 0.03);
    --sombra-2: 0 6px 16px -6px rgba(17, 17, 17, 0.14), 0 2px 4px rgba(17, 17, 17, 0.05);
    --sombra-3: 0 18px 40px -12px rgba(17, 17, 17, 0.28), 0 4px 10px rgba(17, 17, 17, 0.08);
    --s1: 4px;
    --s2: 8px;
    --s3: 12px;
    --s4: 16px;
    --s5: 24px;
    --s6: 32px;
    --suave-2: #77776f;
    --cerca: #8a5a00;
    --cerca-fondo: #fdf1cf;
    --lejos: #a3231a;
    --lejos-fondo: #fbe8e5;
    --curva: cubic-bezier(0.2, 0.7, 0.2, 1);
    --radio: 14px;
    --fuente: "Noto Sans", "Segoe UI", system-ui, -apple-system, sans-serif;
}

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

html {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

html, body {
    margin: 0;
    padding: 0;
    background: var(--fondo);
    color: var(--texto);
    font-family: var(--fuente);
    font-size: 16px;
    line-height: 1.5;
}

a { color: var(--texto); }

.top {
    background: var(--superficie);
    border-bottom: 1px solid var(--linea);
    position: sticky;
    top: 0;
    z-index: 40;
    padding-top: env(safe-area-inset-top, 0px);
}

.top__inner {
    max-width: 1120px;
    margin: 0 auto;
    padding: 0.85rem 1.25rem;
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem 1.5rem;
    align-items: center;
    justify-content: space-between;
}

.marca {
    text-decoration: none;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.marca-grupo {
    display: flex;
    align-items: center;
    gap: 0.5rem 0.65rem;
    min-width: 0;
}

.marca__nombre { font-size: 1.05rem; }

.icono { display: block; flex-shrink: 0; }

.nav {
    display: flex;
    flex-wrap: nowrap;
    gap: 0.15rem;
    align-items: center;
}

.nav__link {
    text-decoration: none;
    padding: 0.4rem 0.7rem;
    border-radius: 10px;
    color: var(--suave);
    font-size: 0.9rem;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    line-height: 1.2;
}

.nav__link .icono { width: 18px; height: 18px; }

.nav__link:hover { color: var(--texto); background: var(--fondo); }

.nav__link.is-activa {
    color: #fff;
    background: var(--marca);
    font-weight: 600;
}

.salir { margin: 0; display: inline-flex; }

.salir__boton {
    appearance: none;
    border: 0;
    background: none;
    color: var(--suave);
    font: inherit;
    font-size: 0.9rem;
    padding: 0.4rem 0.7rem;
    border-radius: 10px;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    cursor: pointer;
    line-height: 1.2;
}

.salir__boton .icono { width: 18px; height: 18px; }
.salir__boton:hover { color: var(--texto); background: var(--fondo); }

.nav-bottom { display: none; }

.main {
    max-width: 1120px;
    margin: 0 auto;
    padding: 1.5rem 1.25rem 3rem;
}

.titulo {
    font-size: 1.75rem;
    line-height: 1.2;
    letter-spacing: -0.035em;
    font-weight: 700;
    margin: 0 0 1.25rem;
}

.subtitulo {
    font-size: 1.05rem;
    margin: 0 0 0.75rem;
}

.ayuda, .vacio, .muted {
    color: var(--suave);
}

.ayuda { margin: 0 0 1rem; }

.vacio {
    background: var(--superficie);
    border: 1px solid var(--linea);
    border-radius: var(--radio);
    padding: 1.25rem 1.4rem;
}

.aviso {
    border-radius: var(--radio);
    padding: 0.8rem 1rem;
    margin: 0 0 1.25rem;
    border: 1px solid var(--linea);
}

.aviso--ok { background: var(--aviso-ok); border-color: #cfe6d9; }
.aviso--error { background: var(--aviso-error); border-color: #ead3d3; color: var(--peligro); }

.resumen {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 0.85rem;
    margin: 0 0 1.25rem;
    min-width: 0;
    width: 100%;
}

.resumen--compacto { margin-bottom: 1rem; }

.dato {
    background: var(--superficie);
    border: 1px solid var(--linea);
    border-radius: var(--radio);
    padding: 0.9rem 1rem;
    box-shadow: var(--sombra);
    width: 100%;
    max-width: none;
    min-width: 0;
}

.dato--ok { background: var(--ok-fondo); border-color: #cfe6d9; }

.dato__etiqueta {
    margin: 0;
    color: var(--suave);
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 600;
}

.dato__valor {
    margin: 0.2rem 0 0;
    font-size: 1.4rem;
    line-height: 1.25;
    font-weight: 700;
    letter-spacing: -0.02em;
    font-variant-numeric: tabular-nums;
}

.tabla-wrap {
    overflow: auto;
    max-height: min(68vh, 640px);
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    max-width: 100%;
    width: 100%;
    min-width: 0;
    background: var(--superficie);
    border: 1px solid var(--linea);
    border-radius: var(--radio);
    box-shadow: var(--sombra);
}

.tabla {
    width: 100%;
    border-collapse: collapse;
}

.tabla th, .tabla td {
    padding: 0.7rem 0.85rem;
    text-align: left;
    border-bottom: 1px solid var(--linea);
    vertical-align: middle;
    white-space: nowrap;
}

.tabla__edicion { white-space: normal; }

.tabla thead th {
    position: sticky;
    top: 0;
    z-index: 2;
    box-shadow: inset 0 -1px 0 var(--linea);
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--suave);
    font-weight: 600;
    background: #fafaf8;
}

.tabla tfoot th {
    background: #fafaf8;
    font-weight: 700;
}

.tabla tbody tr:last-child td,
.tabla tbody tr:last-child th { border-bottom: 0; }

.tabla .num,
.tabla__total {
    text-align: right;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.tabla tr.is-ok td,
.tabla tr.is-ok th {
    background: var(--ok-fondo);
    color: var(--ok);
}

.col-ppto,
.dato--ppto .dato__valor,
.tabla tfoot th.col-ppto {
    color: var(--ppto);
}

.col-venta,
.dato--venta .dato__valor,
.tabla tfoot th.col-venta {
    color: var(--venta);
}

.tabla tr.is-ok td.col-ppto,
.tabla tr.is-ok th.col-ppto {
    color: var(--ppto);
}

.tabla tr.is-ok td.col-venta,
.tabla tr.is-ok th.col-venta {
    color: var(--venta);
}

.tabla tr.is-inactiva th,
.tabla tr.is-inactiva td { opacity: 0.7; }

.tabla--compacta th, .tabla--compacta td { padding: 0.55rem 0.7rem; font-size: 0.95rem; }

.entrada, input[type="text"], input[type="number"], input[type="date"], input[type="password"], select {
    font: inherit;
    font-size: 16px;
    color: var(--texto);
    background: #fff;
    border: 1px solid var(--linea-fuerte);
    border-radius: 8px;
    padding: 0.55rem 0.7rem;
    width: 100%;
    min-height: 2.75rem;
}

.entrada--peso, .entrada--pct {
    text-align: right;
    font-variant-numeric: tabular-nums;
    min-width: 7.5rem;
}

.entrada--pct { min-width: 4.5rem; }

input:focus, select:focus, button:focus-visible {
    outline: 2px solid var(--texto);
    outline-offset: 1px;
}

.campo { display: flex; flex-direction: column; gap: 0.3rem; }
.campo span { font-size: 0.85rem; color: var(--suave); }
.campo--crece { flex: 1; min-width: 200px; }
.campo--boton { justify-content: flex-end; }

.form-fila, .acciones {
    display: flex;
    flex-wrap: wrap;
    gap: 0.7rem;
    align-items: flex-end;
}

.acciones { margin-top: 1rem; }

.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 0.8rem;
    align-items: end;
}

.boton {
    appearance: none;
    border: 0;
    background: var(--marca);
    color: #fff;
    font: inherit;
    font-weight: 600;
    padding: 0.55rem 1rem;
    border-radius: 8px;
    cursor: pointer;
    text-decoration: none;
    display: inline-block;
}

.boton:hover { background: #2a2a2a; }

.boton--suave {
    background: #fff;
    color: var(--texto);
    border: 1px solid var(--linea-fuerte);
}

.boton--suave:hover { background: var(--fondo); }

.enlace {
    background: none;
    border: 0;
    padding: 0;
    font: inherit;
    color: var(--texto);
    text-decoration: underline;
    text-underline-offset: 2px;
    cursor: pointer;
}

.enlace--peligro { color: var(--peligro); }

.enlinea { display: inline; }

.bloque {
    background: var(--superficie);
    border: 1px solid var(--linea);
    border-radius: var(--radio);
    padding: 1.15rem 1.2rem;
    margin: 0 0 1.15rem;
    box-shadow: var(--sombra);
    width: 100%;
    max-width: none;
    min-width: 0;
}

.bloque .tabla-wrap {
    box-shadow: none;
}

.herramientas {
    display: flex;
    gap: 0.8rem;
    align-items: flex-end;
    margin: 0 0 1rem;
}

.herramientas .campo { min-width: 280px; }

.subnav {
    display: flex;
    flex-wrap: wrap;
    gap: 0.3rem;
    margin: 0 0 1.2rem;
}

.subnav__link {
    text-decoration: none;
    padding: 0.4rem 0.8rem;
    border-radius: 999px;
    border: 1px solid var(--linea);
    background: var(--superficie);
    color: var(--suave);
    font-size: 0.95rem;
}

.subnav__link.is-activa {
    background: var(--marca);
    color: #fff;
    border-color: var(--marca);
    font-weight: 600;
}

.tarjetas {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.1rem;
    min-width: 0;
    width: 100%;
}

.tarjeta {
    background: var(--superficie);
    border: 1px solid var(--linea);
    border-radius: 16px;
    padding: 1.15rem 1.2rem 1.2rem;
    box-shadow: var(--sombra);
    width: 100%;
    max-width: none;
    min-width: 0;
}

.tarjeta--ok { border-color: #b7dbc8; box-shadow: 0 0 0 1px #d8efe4; }

.tarjeta--inactiva { opacity: 0.78; }

.tarjeta__cab {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem 0.75rem;
    align-items: center;
    margin-bottom: 0.9rem;
}

.tarjeta__cab h2 {
    margin: 0;
    font-size: 1.2rem;
    letter-spacing: -0.02em;
}

.pill {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    border: 1px solid var(--linea-fuerte);
    border-radius: 999px;
    padding: 0.15rem 0.5rem;
    color: var(--suave);
}

.pill--ok {
    background: var(--ok-fondo);
    border-color: #b7dbc8;
    color: var(--ok);
}

.lista { list-style: none; margin: 0; padding: 0; }
.lista__item {
    padding: 0.85rem 0;
    border-bottom: 1px solid var(--linea);
}
.lista__item:last-child { border-bottom: 0; }

.lista__fila, .lista__acciones {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    align-items: center;
}

.lista__fila { justify-content: space-between; }

.cuerpo-login {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem 1rem;
}

.login { width: 100%; }

.login__tarjeta {
    max-width: 400px;
    margin: 0 auto;
    background: var(--superficie);
    border: 1px solid var(--linea);
    border-radius: 16px;
    padding: 1.6rem 1.4rem 1.5rem;
    box-shadow: var(--sombra);
}

.login__titulo {
    margin: 0 0 1.1rem;
    font-size: 1.45rem;
    letter-spacing: -0.03em;
    text-align: center;
}

.login__formulario { display: flex; flex-direction: column; gap: 0.9rem; }
.login__boton { width: 100%; min-height: 2.75rem; }

.filtro {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin: 0 0 1.15rem;
}

.filtro__chip {
    text-decoration: none;
    padding: 0.4rem 0.85rem;
    border-radius: 999px;
    border: 1px solid var(--linea-fuerte);
    background: var(--superficie);
    color: var(--suave);
    font-size: 0.95rem;
    min-height: 2.5rem;
    display: inline-flex;
    align-items: center;
    line-height: 1.2;
}

.filtro__chip:hover { color: var(--texto); background: var(--fondo); }

.filtro__chip.is-activa {
    background: var(--marca);
    color: #fff;
    border-color: var(--marca);
    font-weight: 600;
}

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

    body {
        padding-bottom: calc(4.4rem + env(safe-area-inset-bottom, 0px));
    }

    .cuerpo-login { padding-bottom: 1.5rem; }

    .nav-bottom {
        display: flex;
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 50;
        background: var(--superficie);
        border-top: 1px solid var(--linea);
        padding: 0.2rem 0.15rem calc(0.25rem + env(safe-area-inset-bottom, 0px));
        justify-content: space-around;
        box-shadow: 0 -1px 8px rgba(0, 0, 0, 0.04);
    }

    .nav-bottom__link {
        flex: 1;
        min-width: 0;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 0.15rem;
        padding: 0.35rem 0.15rem;
        min-height: 3.15rem;
        text-decoration: none;
        color: var(--suave);
        font-size: 0.62rem;
        font-weight: 500;
        letter-spacing: 0.01em;
        border-radius: 10px;
    }

    .nav-bottom__link .icono { width: 22px; height: 22px; }

    .nav-bottom__link span {
        max-width: 100%;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .nav-bottom__link.is-activa {
        color: var(--texto);
        font-weight: 700;
        background: var(--fondo);
    }

    .resumen,
    .resumen--compacto,
    .tarjetas,
    .form-grid {
        grid-template-columns: 1fr;
    }

    .dato,
    .tarjeta,
    .bloque,
    .resumen,
    .tarjetas,
    .login__tarjeta {
        width: 100%;
        max-width: none;
    }

    .subnav {
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        padding-bottom: 0.2rem;
    }

    .subnav__link { flex: 0 0 auto; }

    .form-grid, .form-fila, .herramientas, .lista__fila, .lista__acciones, .tarjeta__cab {
        flex-direction: column;
        align-items: stretch;
    }

    .tarjeta__cab { align-items: flex-start; }

    .campo--crece, .herramientas .campo, .herramientas { min-width: 0; width: 100%; }

    .titulo { font-size: 1.35rem; }
    .dato__valor { font-size: 1.15rem; }
    .main { padding: 1.15rem 0.9rem 1.25rem; }
    .boton { min-height: 2.75rem; width: auto; }
    .acciones .boton, .form-fila .boton, .campo--boton .boton { width: 100%; }
}

@media (max-width: 420px) {
    .top__inner, .main { padding-left: 0.8rem; padding-right: 0.8rem; }
    .login__tarjeta { padding: 1.3rem 1.05rem 1.2rem; }
    .tarjeta { padding: 1rem 0.9rem 1rem; }
    .bloque { padding: 1rem 0.9rem; }
    .marca__nombre { font-size: 0.98rem; }
}


/* =====================================================================
 * v1.6 · pulido general, insignias, progreso, gráficas, avisos, modal,
 * transiciones y entradas suaves. Solo transform/opacity en animaciones.
 * ===================================================================== */

::selection { background: #1111111f; }

.dato__pie { margin: 0.45rem 0 0; }

/* Estados: hover, foco y pulsado ---------------------------------- */
.nav__link,
.salir__boton,
.menu-cuenta__boton,
.subnav__link,
.filtro__chip,
.boton,
.enlace {
    transition: background-color 0.16s ease, color 0.16s ease, border-color 0.16s ease,
        box-shadow 0.16s ease, transform 0.16s var(--curva);
}

.boton:active, .subnav__link:active, .filtro__chip:active, .nav-bottom__link:active { transform: scale(0.97); }

.boton { box-shadow: 0 1px 0 rgba(255, 255, 255, 0.12) inset, 0 1px 2px rgba(17, 17, 17, 0.18); }
.boton--suave { box-shadow: var(--sombra); }
.boton--peligro { background: var(--peligro); }
.boton--peligro:hover { background: #7f1616; }

a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible,
.filtro__chip:focus-visible, .nav-bottom__link:focus-visible {
    outline: 2px solid var(--texto);
    outline-offset: 2px;
    border-radius: 8px;
}

input:focus, select:focus {
    border-color: var(--texto);
    box-shadow: 0 0 0 3px rgba(17, 17, 17, 0.08);
    outline: none;
}

@media (hover: hover) {
    .dato, .tarjeta, .bloque {
        transition: box-shadow 0.25s ease, transform 0.25s var(--curva), border-color 0.25s ease;
    }
    .dato:hover, .tarjeta:hover { box-shadow: var(--sombra-2); transform: translateY(-2px); border-color: var(--linea-fuerte); }
    .tabla tbody tr { transition: background-color 0.15s ease; }
    .tabla tbody tr:hover td, .tabla tbody tr:hover th { background: #f8f8f5; }
    .tabla tbody tr.is-ok:hover td, .tabla tbody tr.is-ok:hover th { background: #dcf1e6; }
}

/* Encabezado: más aire y marca ---------------------------------------- */
.top { box-shadow: 0 1px 0 rgba(17, 17, 17, 0.02); }
.marca__nombre { font-size: 1.08rem; letter-spacing: -0.03em; }

/* Estados vacíos más amables ------------------------------------------- */
.vacio {
    text-align: center;
    border-style: dashed;
    border-color: var(--linea-fuerte);
    padding: 1.6rem 1.4rem;
    background: transparent;
}

.vacio::before {
    content: "";
    display: block;
    width: 44px;
    height: 44px;
    margin: 0 auto 0.7rem;
    opacity: 0.55;
    background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23161616' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3 13l3-8h12l3 8'/%3E%3Cpath d='M3 13v6a1 1 0 0 0 1 1h16a1 1 0 0 0 1-1v-6h-5a3 3 0 0 1-6 0z'/%3E%3C/svg%3E") center / contain no-repeat;
}

/* Insignias (badges) ----------------------------------------------------- */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.74rem;
    font-weight: 600;
    line-height: 1.2;
    letter-spacing: 0.01em;
    padding: 0.22rem 0.6rem;
    border-radius: 999px;
    white-space: nowrap;
    background: #eeeeea;
    color: #3f3f3a;
}

.badge::before {
    content: "";
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
    opacity: 0.85;
}

.badge--tipo-jefe { background: #efe8fb; color: #4a2a8c; }
.badge--tipo-planta { background: #dff3f0; color: #0b5a53; }
.badge--tipo-auxiliar { background: #fbe6f0; color: #8a2058; }

.badge--estado-ok { background: #e1f4ea; color: #14633d; }
.badge--estado-cerca { background: var(--cerca-fondo); color: var(--cerca); }
.badge--estado-lejos { background: var(--lejos-fondo); color: var(--lejos); }
.badge--estado-neutro { background: #eeeeea; color: #4a4a45; }

.badge--activo { background: #e1f4ea; color: #14633d; }
.badge--inactivo { background: #eeeeea; color: #4a4a45; }

/* Barra de progreso con marcas en cada tramo ---------------------------- */
.progreso { margin: 0 0 1rem; padding: 0 2px; }

.progreso__pista {
    position: relative;
    height: 10px;
    border-radius: 999px;
    background: #ebebe7;
    overflow: hidden;
}

.progreso__relleno {
    position: absolute;
    inset: 0 auto 0 0;
    border-radius: 999px;
    background: #6e6e68;
    transform-origin: left center;
    animation: llenar 0.95s var(--curva) 0.2s backwards;
}

.progreso--ok .progreso__relleno { background: #2b9a66; }
.progreso--cerca .progreso__relleno { background: #d9a21b; }
.progreso--lejos .progreso__relleno { background: #d4574a; }

.progreso__tick {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 2px;
    margin-left: -1px;
    background: rgba(255, 255, 255, 0.9);
    box-shadow: 0 0 0 0.5px rgba(17, 17, 17, 0.12);
}

.progreso__marcas { position: relative; height: 1.1rem; margin-top: 0.3rem; }

.progreso__marca {
    position: absolute;
    top: 0;
    transform: translateX(-100%);
    padding-right: 3px;
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--suave-2);
    font-variant-numeric: tabular-nums;
}

.progreso__marca.is-alcanzada { color: var(--ok); }

@keyframes llenar {
    from { transform: translateX(-101%); }
    to { transform: translateX(0); }
}

/* Mini gráficas de ventas por día ----------------------------------------- */
.grafica { margin: 0 0 1rem; }

.grafica__titulo {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 0.2rem 0.75rem;
    margin: 0 0 0.4rem;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--suave);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.grafica__dato { text-transform: none; letter-spacing: 0; font-weight: 500; color: var(--venta); }

.grafica__svg {
    display: block;
    width: 100%;
    height: 64px;
    overflow: visible;
}

.grafica__barra {
    fill: var(--venta);
    opacity: 0.9;
    transform-box: fill-box;
    transform-origin: bottom;
    animation: crecer 0.6s var(--curva) backwards;
    animation-delay: calc(var(--i, 0) * 14ms + 150ms);
}

.grafica__barra.is-cero { fill: #cfcfc8; opacity: 0.7; }
.grafica__barra:hover { opacity: 1; }

.grafica__ejes {
    display: flex;
    justify-content: space-between;
    margin-top: 0.25rem;
    font-size: 0.7rem;
    color: var(--suave-2);
}

.grafica--vacia { margin: 0; }
.grafica__nota { margin: 0; color: var(--suave); font-size: 0.9rem; }
.bloque--grafica { padding-bottom: 0.9rem; }
.bloque--grafica .grafica { margin: 0; }

@keyframes crecer {
    from { transform: scaleY(0); opacity: 0; }
    to { transform: scaleY(1); opacity: 0.9; }
}

/* Avisos emergentes (toast) ------------------------------------------------ */
.toasts {
    position: fixed;
    z-index: 90;
    top: calc(env(safe-area-inset-top, 0px) + 72px);
    right: 16px;
    width: min(380px, calc(100vw - 32px));
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
}

.toast {
    position: relative;
    overflow: hidden;
    pointer-events: auto;
    display: flex;
    align-items: flex-start;
    gap: 0.65rem;
    padding: 0.8rem 0.7rem 0.8rem 0.9rem;
    background: var(--superficie);
    border: 1px solid var(--linea);
    border-left: 4px solid var(--ok);
    border-radius: var(--radio);
    box-shadow: var(--sombra-3);
    animation: toast-entra 0.42s var(--curva) both;
    transition: opacity 0.22s ease, transform 0.22s ease;
}

.toast--error { border-left-color: var(--lejos); }
.toast.is-saliendo { opacity: 0; transform: translateY(-8px) scale(0.98); }

.toast__icono { display: flex; padding-top: 1px; color: var(--ok); }
.toast--error .toast__icono { color: var(--lejos); }
.toast__icono .icono { width: 22px; height: 22px; }

.toast__texto { margin: 0; flex: 1; font-size: 0.93rem; line-height: 1.4; padding-top: 1px; }

.toast__cerrar {
    appearance: none;
    border: 0;
    background: none;
    color: var(--suave);
    padding: 0.2rem;
    margin: -0.1rem 0 0;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
}

.toast__cerrar:hover { background: var(--fondo); color: var(--texto); }
.toast__cerrar .icono { width: 18px; height: 18px; }

.toast__tiempo {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 3px;
    background: currentColor;
    color: rgba(43, 154, 102, 0.55);
    transform-origin: left center;
    animation: toast-tiempo 3s linear forwards;
}

.toast--error .toast__tiempo { color: rgba(163, 35, 26, 0.5); }

@keyframes toast-entra {
    from { opacity: 0; transform: translateY(-14px) scale(0.97); }
    to { opacity: 1; transform: none; }
}

@keyframes toast-tiempo {
    from { transform: scaleX(1); }
    to { transform: scaleX(0); }
}

/* Modal de confirmación ---------------------------------------------------- */
.modal {
    border: 0;
    padding: 0;
    border-radius: 18px;
    width: min(380px, calc(100vw - 32px));
    background: var(--superficie);
    color: var(--texto);
    box-shadow: var(--sombra-3);
    overflow: hidden;
    animation: modal-entra 0.3s var(--curva) both;
}

.modal::backdrop {
    background: rgba(17, 17, 17, 0.5);
    animation: aparecer 0.25s ease both;
}

.modal__cuerpo { padding: 1.5rem 1.4rem 1.1rem; text-align: center; }

.modal__icono {
    width: 52px;
    height: 52px;
    margin: 0 auto 0.85rem;
    display: grid;
    place-items: center;
    border-radius: 50%;
    background: var(--fondo);
    color: var(--texto);
}

.modal__icono--peligro { background: var(--lejos-fondo); color: var(--lejos); }

.modal__titulo { margin: 0 0 0.35rem; font-size: 1.2rem; letter-spacing: -0.02em; }
.modal__texto { margin: 0; color: var(--suave); font-size: 0.95rem; }

.modal__acciones {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.6rem;
    padding: 0.4rem 1.2rem 1.2rem;
}

.modal__acciones .boton { width: 100%; min-height: 2.75rem; text-align: center; }

@keyframes modal-entra {
    from { opacity: 0; transform: translateY(12px) scale(0.96); }
    to { opacity: 1; transform: none; }
}

@keyframes aparecer {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* Entradas suaves en cascada (tarjetas y filas) ----------------------------- */
@keyframes subir {
    from { opacity: 0; transform: translateY(12px); }
    to { opacity: 1; transform: none; }
}

@keyframes fila-entra {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: none; }
}

.resumen > *,
.tarjetas > *,
.bloque,
.filtro,
.subnav,
.herramientas,
.vacio,
.tabla-wrap,
.login__tarjeta {
    animation: subir 0.5s var(--curva) backwards;
    animation-delay: calc(var(--i, 0) * 70ms);
}

.resumen > :nth-child(1), .tarjetas > :nth-child(1) { --i: 1; }
.resumen > :nth-child(2), .tarjetas > :nth-child(2) { --i: 2; }
.resumen > :nth-child(3), .tarjetas > :nth-child(3) { --i: 3; }
.resumen > :nth-child(4), .tarjetas > :nth-child(4) { --i: 4; }
.tarjetas > :nth-child(n+5) { --i: 5; }
.main > :nth-child(2) { --i: 1; }
.main > :nth-child(3) { --i: 2; }
.main > :nth-child(4) { --i: 3; }
.main > :nth-child(n+5) { --i: 4; }

.tabla tbody tr {
    animation: fila-entra 0.4s var(--curva) backwards;
    animation-delay: calc(var(--f, 0) * 35ms + 180ms);
}

.tabla tbody tr:nth-child(1) { --f: 1; }
.tabla tbody tr:nth-child(2) { --f: 2; }
.tabla tbody tr:nth-child(3) { --f: 3; }
.tabla tbody tr:nth-child(4) { --f: 4; }
.tabla tbody tr:nth-child(5) { --f: 5; }
.tabla tbody tr:nth-child(6) { --f: 6; }
.tabla tbody tr:nth-child(7) { --f: 7; }
.tabla tbody tr:nth-child(n+8) { --f: 8; }

/* La animación de tarjetas dentro de tarjetas no se repite (ya vienen con su padre) */
.tarjeta .resumen > *, .tarjeta .tabla-wrap, .bloque .tabla-wrap, .bloque .vacio { animation: none; }
.tarjeta .tabla tbody tr, .bloque .tabla tbody tr { animation-delay: calc(var(--f, 0) * 35ms + 300ms); }

/* Barra inferior: indicador del activo ------------------------------------ */
.nav-bottom__link { position: relative; }
.nav-bottom__link .icono { transition: transform 0.25s var(--curva); }
.nav-bottom__link.is-activa .icono { transform: translateY(-1px) scale(1.08); }

/* Transiciones entre páginas (View Transitions entre documentos) ---------
 * La regla va en el nivel superior (Chrome no la toma dentro de @media);
 * con movimiento reducido se anulan sus animaciones más abajo. */
@view-transition { navigation: auto; }

.top { view-transition-name: cabecera; }
.nav-bottom { view-transition-name: barra-inferior; }
.main { view-transition-name: contenido; }

::view-transition-group(root) { animation-duration: 0s; }
::view-transition-old(root), ::view-transition-new(root) { animation: none; mix-blend-mode: normal; }

::view-transition-old(contenido) { animation: 0.16s ease-in both vt-sale; }
::view-transition-new(contenido) { animation: 0.32s var(--curva) 0.06s both vt-entra; }

@keyframes vt-sale { to { opacity: 0; transform: translateY(-4px); } }
@keyframes vt-entra { from { opacity: 0; transform: translateY(10px); } }

/* Respaldo (Firefox y otros sin transiciones entre documentos) */
.sin-vt .main { animation: aparecer 0.35s ease both; }

/* Móvil ----------------------------------------------------------------- */
@media (max-width: 768px) {
    .toasts {
        top: calc(env(safe-area-inset-top, 0px) + 64px);
        right: 12px;
        left: 12px;
        width: auto;
    }
    .titulo { font-size: 1.5rem; }
    .dato__valor { font-size: 1.3rem; }
    .grafica__svg { height: 56px; }
    .tabla-wrap { max-height: 60vh; }

    /* Título de la app centrado de verdad (el botón de la cuenta no lo desplaza) */
    .top__inner {
        display: grid;
        grid-template-columns: 2.5rem minmax(0, 1fr) 2.5rem;
        align-items: center;
        gap: 0.2rem 0.35rem;
    }
    .marca-grupo {
        grid-column: 2;
        justify-self: center;
        flex-direction: column;
        align-items: center;
        gap: 0.12rem;
        min-width: 0;
        max-width: 100%;
        text-align: center;
    }
    .marca {
        grid-column: auto;
        justify-self: center;
        min-width: 0;
        max-width: 100%;
        text-align: center;
    }
    .menu-cuenta {
        grid-column: 3;
        grid-row: 1;
        justify-self: end;
        align-self: center;
    }
    .marca-grupo { grid-row: 1; }
    .marca__nombre {
        display: block;
        font-weight: 800;
        font-size: clamp(1.12rem, 5.4vw, 1.32rem);
        letter-spacing: -0.04em;
        line-height: 1.15;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
    .marca-grupo .badge--semana {
        font-size: 0.68rem;
        padding: 0.12rem 0.5rem;
    }
}

@media (max-width: 420px) {
    .modal__acciones { padding: 0.3rem 1rem 1rem; }
}

/* =====================================================================
 * v1.6.2 · tarjetas de resumen a la misma altura, e interruptores
 * de apariencia. El escritorio no cambia de paleta ni de disposición.
 * ===================================================================== */

.resumen {
    align-items: stretch;
}

.dato {
    display: flex;
    flex-direction: column;
    height: 100%;
    align-self: stretch;
}

.dato__etiqueta { flex: 0 0 auto; }

.dato__valor { flex: 0 0 auto; }

.dato__pie {
    margin: auto 0 0;
    min-height: 1.7rem;
    display: flex;
    align-items: flex-end;
}

/* Interruptores de Apariencia ----------------------------------------- */
.form-apariencia { display: flex; flex-direction: column; gap: 0; max-width: 36rem; }

.interruptor {
    display: flex;
    gap: 0.85rem;
    align-items: flex-start;
    padding: 0.9rem 0;
    cursor: pointer;
    border-bottom: 1px solid var(--linea);
}

.interruptor input[type="checkbox"] {
    position: absolute;
    opacity: 0;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
}

.interruptor__pista {
    flex: 0 0 auto;
    width: 44px;
    height: 26px;
    border-radius: 999px;
    background: #d4d4ce;
    position: relative;
    transition: background-color 0.2s ease;
    margin-top: 0.15rem;
}

.interruptor__pista::after {
    content: "";
    position: absolute;
    top: 3px;
    left: 3px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 1px 3px rgba(17, 17, 17, 0.25);
    transition: transform 0.2s var(--curva);
}

.interruptor:has(input[type="checkbox"]:checked) .interruptor__pista { background: var(--marca); }
.interruptor:has(input[type="checkbox"]:checked) .interruptor__pista::after { transform: translateX(18px); }
.interruptor:has(input[type="checkbox"]:focus-visible) .interruptor__pista {
    outline: 2px solid var(--marca);
    outline-offset: 3px;
}

.interruptor__texto {
    font-weight: 600;
    line-height: 1.4;
    padding-top: 0.15rem;
}

.form-apariencia .campo--boton { margin-top: 1.1rem; }

@media (max-width: 768px) {
    .resumen:not(.resumen--compacto) > .dato {
        min-height: 7.4rem;
    }
}

/* v1.6.3 · badge de la semana actual en la cabecera -------------------- */
.badge--semana {
    background: #eceaf3;
    color: #3b3358;
    font-variant-numeric: tabular-nums;
    flex-shrink: 0;
    letter-spacing: 0.02em;
}

@media (max-width: 768px) {
    .toasts {
        top: calc(env(safe-area-inset-top, 0px) + 76px);
    }
}

/* Accesibilidad: sin animaciones si el sistema lo pide ----------------------- */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.001ms !important;
        animation-delay: 0s !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.001ms !important;
        scroll-behavior: auto !important;
    }
    .toast__tiempo { display: none; }
    ::view-transition-group(*), ::view-transition-old(*), ::view-transition-new(*) { animation: none !important; }
    .dato:hover, .tarjeta:hover { transform: none; }
}

/* =====================================================================
 * v2.0 (experimental) · menú de la cuenta (Ajustes + Salir) y presupuesto diario
 * ===================================================================== */

.nav--top { margin-left: auto; }

.menu-cuenta { position: relative; display: flex; }

.menu-cuenta__boton {
    appearance: none;
    border: 1px solid transparent;
    background: none;
    color: var(--suave);
    width: 2.5rem;
    height: 2.5rem;
    padding: 0;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.menu-cuenta__boton .icono { width: 20px; height: 20px; }
.menu-cuenta__boton:hover { color: var(--texto); background: var(--fondo); }
.menu-cuenta__boton[aria-expanded="true"] { color: var(--texto); background: var(--fondo); border-color: var(--linea); }

.menu-cuenta__boton.is-activa,
.menu-cuenta__boton.is-activa:hover {
    color: #fff;
    background: var(--marca);
    border-color: var(--marca);
}

.menu-cuenta__lista {
    position: absolute;
    top: calc(100% + 0.5rem);
    right: 0;
    z-index: 70;
    min-width: 12rem;
    max-width: calc(100vw - 1.6rem);
    padding: 0.35rem;
    background: var(--superficie);
    border: 1px solid var(--linea);
    border-radius: 12px;
    box-shadow: 0 10px 28px rgba(17, 17, 17, 0.14), 0 2px 6px rgba(17, 17, 17, 0.06);
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
    transform-origin: top right;
    /* cerrado: invisible y fuera del orden de tabulación */
    visibility: hidden;
    opacity: 0;
    transform: translateY(-6px) scale(0.97);
    transition: opacity 0.16s ease, transform 0.18s var(--curva), visibility 0s linear 0.18s;
}

.menu-cuenta.is-abierto .menu-cuenta__lista,
html:not(.js) .menu-cuenta:focus-within .menu-cuenta__lista {
    visibility: visible;
    opacity: 1;
    transform: none;
    transition-delay: 0s;
}

.menu-cuenta__item {
    appearance: none;
    border: 0;
    background: none;
    font: inherit;
    font-size: 0.95rem;
    color: var(--texto);
    text-decoration: none;
    width: 100%;
    min-height: 2.6rem;
    padding: 0.5rem 0.75rem;
    border-radius: 8px;
    display: flex;
    align-items: center;
    gap: 0.65rem;
    cursor: pointer;
    text-align: left;
    line-height: 1.2;
}

.menu-cuenta__item .icono { width: 18px; height: 18px; color: var(--suave); }
.menu-cuenta__item:hover, .menu-cuenta__item:focus-visible { background: var(--fondo); color: var(--texto); }
.menu-cuenta__item.is-activa { font-weight: 700; background: var(--fondo); }
.menu-cuenta .salir { display: block; width: 100%; }
.menu-cuenta .salir .salir__boton { padding: 0.5rem 0.75rem; color: var(--texto); }
.menu-cuenta .salir .salir__boton .icono { width: 18px; height: 18px; }

@media (min-width: 769px) and (max-width: 1000px) {
    .nav__link .icono { display: none; }
    .nav__link { padding: 0.4rem 0.6rem; }
    .top__inner { gap: 0.75rem 0.75rem; }
}

@media (min-width: 769px) and (max-width: 860px) {
    .nav__link { padding: 0.4rem 0.4rem; font-size: 0.86rem; }
    .top__inner { gap: 0.5rem; }
}

/* Pantallas muy angostas: 5 pestañas sin cortar "Presupuesto" */
@media (max-width: 340px) {
    .nav-bottom__link { font-size: 0.56rem; padding-left: 0.05rem; padding-right: 0.05rem; }
}

/* Presupuesto diario ---------------------------------------------------- */
.aviso--cuadre {
    background: var(--cerca-fondo);
    border-color: #ecd9a0;
    color: var(--cerca);
}
.aviso--cuadre a { color: inherit; font-weight: 600; }

.cuadre-semana {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem 1.75rem;
    align-items: center;
    padding: 0.7rem 1rem;
    margin: 0 0 1rem;
    background: var(--superficie);
    border: 1px solid var(--linea);
    border-left-width: 4px;
    border-radius: var(--radio);
}
.cuadre-semana--cuadra { border-left-color: #2f9e6b; }
.cuadre-semana--difiere { border-left-color: #d9a21b; }
.cuadre-semana__linea { margin: 0; display: flex; flex-wrap: wrap; align-items: center; gap: 0.35rem 0.6rem; font-size: 0.93rem; }
.cuadre-semana__linea span:first-child { color: var(--suave); }
.cuadre-semana__linea strong { font-variant-numeric: tabular-nums; }

.tabla--ppto th, .tabla--ppto td { white-space: nowrap; vertical-align: top; }
.tabla--ppto thead th.num { vertical-align: bottom; }
.tabla--ppto td { min-width: 6.5rem; }
.tabla--ppto .fila-tienda th, .tabla--ppto .fila-tienda td { background: var(--fondo); }

.dia-acciones { display: flex; flex-direction: column; align-items: flex-end; gap: 0.25rem; margin-top: 0.4rem; }
html:not(.js) .dia-acciones { display: none; }

.mini {
    appearance: none;
    font: inherit;
    font-size: 0.72rem;
    font-weight: 500;
    color: var(--suave);
    background: var(--superficie);
    border: 1px solid var(--linea);
    border-radius: 999px;
    padding: 0.2rem 0.6rem;
    cursor: pointer;
    line-height: 1.3;
}
.mini:hover { color: var(--texto); border-color: var(--linea-fuerte); }

.celda-pct__pesos {
    display: block;
    min-height: 1.1rem;
    margin-top: 0.2rem;
    font-size: 0.78rem;
    text-align: right;
    color: var(--suave);
    font-variant-numeric: tabular-nums;
}

.suma-dia { font-variant-numeric: tabular-nums; font-size: 0.85rem; }
.suma-dia--ok { color: #14633d; background: #e1f4ea; }
.suma-dia--falta, .suma-dia--sobra { color: var(--lejos); background: var(--lejos-fondo); }
.suma-dia--vacio { color: var(--suave); }

.ayuda--pie { margin-top: 0.85rem; font-size: 0.88rem; }

.toast--aviso { border-left-color: #d9a21b; }
.toast--aviso .toast__icono { color: var(--cerca); }

@media (max-width: 768px) {
    .menu-cuenta__lista { min-width: 11.5rem; }
    .nav-bottom__link span { letter-spacing: 0; }
}
