/* ═══════════════════════════════════════════════════════════════
   Reinicio, tipografia y armazon de la aplicacion
   ═══════════════════════════════════════════════════════════════ */

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

* { margin: 0; }

/* El atributo hidden tiene que ganar siempre.
   Varios contenedores de esta hoja declaran su propio display (grid, flex), y
   eso pisa el [hidden] que trae el navegador: sin esta regla la pantalla de
   carga nunca desaparece y las hojas deslizables no se cierran. */
[hidden] { display: none !important; }

html {
    -webkit-text-size-adjust: 100%;
    -webkit-tap-highlight-color: transparent;
}

body {
    min-height: 100dvh;
    font-family: var(--f-texto);
    font-size: var(--t-base);
    line-height: 1.5;
    color: var(--c-texto);
    background: var(--c-fondo);
    -webkit-font-smoothing: antialiased;
    /* Se usa de pie y con prisa: un texto seleccionado por accidente
       al mantener el dedo estorba mas de lo que ayuda. */
    -webkit-user-select: none;
    user-select: none;
    overscroll-behavior-y: none;
}

input, textarea, [contenteditable] { -webkit-user-select: text; user-select: text; }

img, svg { display: block; max-width: 100%; }

button, input, select, textarea {
    font: inherit;
    color: inherit;
}

button { cursor: pointer; border: none; background: none; }

a { color: var(--c-marca-fuerte); }

.sprite { display: none; }

.sin-js { padding: 2rem; }

/* Los importes se leen en columna: cifras de ancho fijo */
.cifra, .dinero, td.num, .num { font-variant-numeric: tabular-nums; }

h1, h2, h3 { line-height: 1.25; font-weight: 650; letter-spacing: -0.01em; }
h1 { font-size: var(--t-xl); }
h2 { font-size: var(--t-lg); }
h3 { font-size: var(--t-md); }

:focus-visible {
    outline: 3px solid var(--c-marca);
    outline-offset: 2px;
    border-radius: var(--r-sm);
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: .01ms !important;
        transition-duration: .01ms !important;
    }
}

/* ── Pantalla de arranque ────────────────────────────────────── */
.arranque {
    position: fixed;
    inset: 0;
    display: grid;
    place-content: center;
    justify-items: center;
    gap: var(--e-6);
    background: var(--c-nav);
    z-index: 100;
}
.arranque__marca { font-size: 3.5rem; }
.arranque__giro {
    width: 34px; height: 34px;
    border: 3px solid rgba(255, 255, 255, .18);
    border-top-color: var(--c-marca);
    border-radius: 50%;
    animation: girar .8s linear infinite;
}
@keyframes girar { to { transform: rotate(360deg); } }

/* ── Armazon ─────────────────────────────────────────────────── */
.app { display: flex; min-height: 100dvh; }

.marco {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    min-height: 100dvh;
}

.vista {
    flex: 1;
    padding: var(--e-4);
    padding-bottom: calc(var(--barra-alta) + env(safe-area-inset-bottom) + var(--e-6));
    max-width: 1200px;
    width: 100%;
    margin-inline: auto;
}
.vista:focus { outline: none; }

/* ── Cabecera ────────────────────────────────────────────────── */
.cabecera {
    position: sticky;
    top: 0;
    z-index: var(--z-barra);
    display: flex;
    align-items: center;
    gap: var(--e-3);
    min-height: var(--barra-alta);
    padding: var(--e-2) var(--e-4);
    padding-top: calc(var(--e-2) + env(safe-area-inset-top));
    background: var(--c-nav);
    color: var(--c-texto-inv);
}
.cabecera__titulo { flex: 1; min-width: 0; }
.cabecera__titulo h1 {
    font-size: var(--t-lg);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.cabecera__sub {
    font-size: var(--t-xs);
    color: var(--c-nav-texto);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.cabecera__accion {
    display: grid;
    place-items: center;
    width: 44px; height: 44px;
    border-radius: var(--r-md);
    color: var(--c-texto-inv);
    background: rgba(255, 255, 255, .08);
    flex: none;
}
.cabecera__accion:hover { background: rgba(255, 255, 255, .16); }

/* ── Navegacion inferior (movil) ─────────────────────────────── */
.navegacion {
    position: fixed;
    left: 0; right: 0; bottom: 0;
    z-index: var(--z-nav);
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    background: var(--c-superficie);
    border-top: 1px solid var(--c-borde);
    padding-bottom: env(safe-area-inset-bottom);
    box-shadow: var(--s-alta);
}
.navegacion__item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    min-height: var(--barra-alta);
    font-size: 10px;
    font-weight: 600;
    letter-spacing: .01em;
    color: var(--c-texto-3);
    text-decoration: none;
    transition: color var(--tr-rapida);
}
.navegacion__item svg { width: 22px; height: 22px; }
.navegacion__item[aria-current="page"] { color: var(--c-marca); }

/* El boton central de registrar es el mas importante de la aplicacion */
.navegacion__item--principal { color: var(--c-marca); }
.navegacion__item--principal svg {
    width: 44px; height: 44px;
    padding: 10px;
    margin-top: -18px;
    border-radius: var(--r-full);
    background: var(--c-marca);
    color: #fff;
    box-shadow: var(--s-2);
}
.navegacion__item--principal[aria-current="page"] svg { background: var(--c-marca-fuerte); }

/* ── Barra lateral (escritorio) ──────────────────────────────── */
.lateral { display: none; }

@media (min-width: 1024px) {
    .navegacion { display: none; }

    .lateral {
        display: flex;
        flex-direction: column;
        width: var(--lateral-ancho);
        flex: none;
        background: var(--c-nav);
        color: var(--c-nav-texto);
        padding: var(--e-4) var(--e-3);
        gap: var(--e-1);
        position: sticky;
        top: 0;
        height: 100dvh;
        overflow-y: auto;
    }
    .lateral__marca {
        display: flex;
        align-items: center;
        gap: var(--e-3);
        padding: var(--e-2) var(--e-3) var(--e-5);
        color: #fff;
        font-weight: 700;
    }
    .lateral__marca span:first-child { font-size: 1.6rem; }
    .lateral__grupo {
        padding: var(--e-4) var(--e-3) var(--e-2);
        font-size: var(--t-xs);
        text-transform: uppercase;
        letter-spacing: .08em;
        color: #64748b;
        font-weight: 700;
    }
    .lateral__item {
        display: flex;
        align-items: center;
        gap: var(--e-3);
        padding: var(--e-3);
        border-radius: var(--r-md);
        color: var(--c-nav-texto);
        text-decoration: none;
        font-weight: 550;
        transition: background var(--tr-rapida), color var(--tr-rapida);
    }
    .lateral__item svg { width: 20px; height: 20px; flex: none; }
    .lateral__item:hover { background: var(--c-nav-2); color: #fff; }
    .lateral__item[aria-current="page"] {
        background: var(--c-marca-fuerte);
        color: #fff;
    }
    .lateral__pie { margin-top: auto; padding-top: var(--e-4); }

    .cabecera { padding-inline: var(--e-6); }
    .vista { padding: var(--e-6); padding-bottom: var(--e-10); }
}

/* Los iconos del sprite comparten trazo */
.ico {
    width: 24px; height: 24px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.9;
    stroke-linecap: round;
    stroke-linejoin: round;
    flex: none;
}
.ico--sm { width: 18px; height: 18px; }
.ico--lg { width: 32px; height: 32px; stroke-width: 1.7; }
