/* ============================================================
   FF Gastos - PWA movil-first
   ============================================================ */

:root {
    /* Identidad Fresh Farms */
    --verde:        #3E7C5A;
    --verde-2:      #4A8B63;   /* degradados */
    --verde-osc:    #1E4620;   /* texto y acentos */
    --verde-claro:  #EDF4F0;   /* fondos suaves (chips, subgrupos) */
    --verde-borde:  #CDE0D5;

    /* Naranja: SOLO acciones primarias (Guardar, Entrar, Crear) */
    --naranja:      #E8641C;
    --naranja-2:    #F0851C;

    --texto:      #1F2933;
    --texto-sec:  #6B7280;
    --borde:      #E3E6EA;
    --fondo:      #F5F6F8;
    --superficie: #FFFFFF;

    --ok:      #2E7D46;
    --error:   #C0392B;
    --error-bg:#FDEDEA;

    --radio: 12px;
    --sombra: 0 1px 3px rgba(16, 24, 40, .08);

    --header-h: 64px;
    --nav-h: 62px;
    --safe-top: env(safe-area-inset-top, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }

/* El atributo hidden debe ganarle a cualquier display de las clases
   (.nav-btn, .dropzone y .install-banner usan display:flex). */
[hidden] { display: none !important; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--fondo);
    color: var(--texto);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
                 "Helvetica Neue", Arial, sans-serif;
    font-size: 16px;
    line-height: 1.45;
    -webkit-font-smoothing: antialiased;
    -webkit-tap-highlight-color: transparent;
    overscroll-behavior-y: contain;
}

h1, h2, h3, p { margin: 0; }

/* ------------------------- Pantallas ------------------------- */

.screen { display: none; }
.screen.is-active { display: block; }

/* ============================================================
   Login - estilo intranet Fresh Farms
   Todo va acotado a #screen-login para no afectar las demas
   pantallas, que comparten .field / .label / .btn.
   ============================================================ */

#screen-login {
    --ff-verde-osc: #1E4620;
    --ff-naranja:   #E8641C;
    --ff-naranja-2: #F0851C;

    min-height: 100vh;
    min-height: 100dvh;
    background: linear-gradient(180deg, #3E7C5A 0%, #4A8B63 100%);
    /* El espacio de arriba deja respirar a la mascota, que sobresale */
    padding: calc(78px + var(--safe-top)) 18px calc(28px + var(--safe-bottom));
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

#screen-login.is-active {
    display: flex;
    align-items: center;
    justify-content: center;
}

.login-card {
    position: relative;
    width: 100%;
    max-width: 420px;
    background: #fff;
    border-radius: 20px;
    padding: 46px 30px 26px;
    box-shadow: 0 18px 44px rgba(12, 40, 24, .22), 0 3px 10px rgba(12, 40, 24, .10);
}

/* --------- Mascota asomada en la esquina superior derecha --------- */

.login-mascota {
    position: absolute;
    top: -70px;
    right: 4px;
    width: auto;
    height: 110px;
    pointer-events: none;
    filter: drop-shadow(0 8px 12px rgba(12, 40, 24, .22));
}

/* --------- Logo y titulo --------- */

.login-brand {
    text-align: center;
    margin-bottom: 26px;
}

.login-logo {
    display: block;
    width: 130px;
    height: auto;
    margin: 0 auto 12px;
}

.login-title {
    font-size: 30px;
    font-weight: 800;
    letter-spacing: -.4px;
    line-height: 1.1;
}

.tx-fresh { color: var(--ff-verde-osc); }
.tx-farms { color: var(--ff-naranja); }

.login-kicker {
    margin-top: 7px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 2.2px;
    color: #6E7873;
    text-transform: uppercase;
}

/* --------- Campos --------- */

.lg-field { margin-bottom: 18px; }

.lg-label {
    display: block;
    font-size: 13.5px;
    font-weight: 600;
    color: #3B4A41;
    margin-bottom: 7px;
}

#screen-login input[type="text"],
#screen-login input[type="password"] {
    width: 100%;
    min-height: 54px;
    padding: 14px 16px;
    border: 1.5px solid #DCE4DE;
    border-radius: 12px;
    background: #F8FAF8;
    color: var(--texto);
    font-family: inherit;
    font-size: 16px; /* 16px evita el zoom automatico en iOS */
    transition: border-color .15s, background .15s, box-shadow .15s;
}

#screen-login input::placeholder { color: #A9B3AD; }

#screen-login input[type="text"]:focus,
#screen-login input[type="password"]:focus {
    outline: none;
    background: #fff;
    border-color: #4A8B63;
    box-shadow: 0 0 0 3px rgba(74, 139, 99, .16);
}

/* Ojito de mostrar/ocultar password */

.lg-pass { position: relative; }
.lg-pass input { padding-right: 52px; }

.lg-ojo {
    position: absolute;
    top: 50%;
    right: 6px;
    transform: translateY(-50%);
    width: 42px;
    height: 42px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    border-radius: 10px;
    background: none;
    color: #7C8A82;
    cursor: pointer;
}

.lg-ojo:hover { color: var(--ff-verde-osc); }
.lg-ojo:active { background: #EEF3EF; }

/* --------- Boton Entrar --------- */

.lg-btn {
    width: 100%;
    min-height: 54px;
    margin-top: 6px;
    border: none;
    border-radius: 12px;
    background: linear-gradient(135deg, var(--ff-naranja) 0%, var(--ff-naranja-2) 100%);
    color: #fff;
    font-family: inherit;
    font-size: 17px;
    font-weight: 700;
    letter-spacing: .2px;
    cursor: pointer;
    box-shadow: 0 6px 16px rgba(232, 100, 28, .32);
    transition: opacity .15s, box-shadow .15s, transform .08s;
}

.lg-btn:active {
    transform: translateY(1px);
    box-shadow: 0 3px 9px rgba(232, 100, 28, .3);
}

.lg-btn[disabled] {
    opacity: .62;
    cursor: default;
    box-shadow: none;
}

#screen-login .form-error { margin: 0 0 16px; }

/* --------- Pie --------- */

.login-copy {
    margin-top: 22px;
    text-align: center;
    font-size: 11.5px;
    color: #6E7873;
}

/* --------- Pantallas chicas --------- */

@media (max-width: 380px) {
    #screen-login { padding-top: calc(66px + var(--safe-top)); }
    .login-card { padding: 40px 22px 22px; }
    .login-mascota { height: 94px; top: -60px; }
    .login-logo { width: 112px; }
    .login-title { font-size: 26px; }
}

/* Pantallas muy bajas: la mascota estorba mas de lo que aporta */
@media (max-height: 560px) {
    .login-mascota { display: none; }
    #screen-login { padding-top: calc(24px + var(--safe-top)); }
}

/* --------- Pantalla de cambio de contraseña --------- */

/* Comparte la tarjeta y los campos del login */
#screen-password {
    --ff-verde-osc: #1E4620;
    --ff-naranja:   #E8641C;
    --ff-naranja-2: #F0851C;

    min-height: 100vh;
    min-height: 100dvh;
    background: linear-gradient(180deg, #3E7C5A 0%, #4A8B63 100%);
    padding: calc(30px + var(--safe-top)) 18px calc(28px + var(--safe-bottom));
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

#screen-password.is-active {
    display: flex;
    align-items: center;
    justify-content: center;
}

#screen-password input[type="password"] {
    width: 100%;
    min-height: 54px;
    padding: 14px 16px;
    border: 1.5px solid #DCE4DE;
    border-radius: 12px;
    background: #F8FAF8;
    color: var(--texto);
    font-family: inherit;
    font-size: 16px;
    transition: border-color .15s, background .15s, box-shadow .15s;
}

#screen-password input::placeholder { color: #A9B3AD; }

#screen-password input[type="password"]:focus {
    outline: none;
    background: #fff;
    border-color: #4A8B63;
    box-shadow: 0 0 0 3px rgba(74, 139, 99, .16);
}

#screen-password .form-error { margin: 0 0 16px; }

.pw-aviso {
    background: #FFF8E1;
    border: 1px solid #F0D48A;
    border-left: 4px solid #E0A800;
    border-radius: 10px;
    padding: 11px 13px;
    margin-bottom: 20px;
    font-size: 13.5px;
    line-height: 1.45;
    color: #6B4E06;
}

.lg-btn-cancelar {
    width: 100%;
    min-height: 48px;
    margin-top: 10px;
    border: none;
    border-radius: 12px;
    background: #EDEFF2;
    color: var(--texto);
    font-family: inherit;
    font-size: 15.5px;
    font-weight: 600;
    cursor: pointer;
}

.lg-btn-cancelar:active { opacity: .82; }

/* ------------------------- Header ------------------------- */

.app-header {
    position: fixed;
    inset: 0 0 auto 0;
    z-index: 30;
    background: var(--verde);
    padding-top: var(--safe-top);
    box-shadow: 0 2px 8px rgba(0, 0, 0, .12);
}

.app-header-inner {
    height: var(--header-h);
    padding: 0 18px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.app-title {
    color: #fff;
    font-size: 19px;
    font-weight: 700;
    line-height: 1.2;
}

.app-user {
    /* .9 se quedaba en 4.38:1 sobre el verde; .95 sube a 4.68:1 (AA) */
    color: rgba(255, 255, 255, .95);
    font-size: 12.5px;
    line-height: 1.3;
}

.app-header-acciones {
    display: flex;
    align-items: center;
    gap: 9px;
    flex-shrink: 0;
}

.header-btn {
    width: 38px;
    height: 38px;
    border: none;
    border-radius: 10px;
    background: rgba(255, 255, 255, .18);
    color: #fff;
    font-size: 17px;
    line-height: 1;
    cursor: pointer;
}

.header-btn:active { background: rgba(255, 255, 255, .3); }

.role-badge {
    background: var(--verde-osc);
    color: #fff;
    font-size: 10.5px;
    font-weight: 800;
    letter-spacing: .7px;
    padding: 4px 9px;
    border-radius: 999px;
    flex-shrink: 0;
}

/* ------------------------- Layout ------------------------- */

#mainArea {
    padding: calc(var(--header-h) + var(--safe-top) + 14px) 14px
             calc(var(--nav-h) + var(--safe-bottom) + 22px);
    max-width: 640px;
    margin: 0 auto;
}

.card {
    background: var(--superficie);
    border: 1px solid var(--borde);
    border-radius: var(--radio);
    padding: 18px 16px;
    box-shadow: var(--sombra);
    margin-bottom: 16px;
}

.card-title {
    font-size: 15px;
    font-weight: 700;
    margin-bottom: 14px;
}

/* ------------------------- Campos ------------------------- */

.field {
    display: block;
    margin-bottom: 17px;
}

.field:last-child { margin-bottom: 0; }

/* Los campos Card / Last 4 viven dentro de un wrapper propio (se ocultan
   enteros, label incluido), asi que .field:last-child les quitaria el
   margen. Aqui se les devuelve. */
.campo-wrapper > .field { margin-bottom: 17px; }

.label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--texto-sec);
    margin-bottom: 7px;
}

.req { color: var(--error); font-weight: 700; }

input[type="text"],
input[type="password"],
input[type="number"],
input[type="date"],
select,
textarea {
    width: 100%;
    min-height: 52px;
    padding: 13px 14px;
    border: 1.5px solid var(--borde);
    border-radius: 10px;
    background: var(--superficie);
    color: var(--texto);
    font-family: inherit;
    font-size: 16px; /* 16px evita el zoom automatico en iOS */
    appearance: none;
    -webkit-appearance: none;
}

textarea {
    min-height: 74px;
    resize: vertical;
    line-height: 1.4;
}

select {
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='14' height='9'><path d='M1 1l6 6 6-6' stroke='%236B7280' stroke-width='2' fill='none' stroke-linecap='round'/></svg>");
    background-repeat: no-repeat;
    background-position: right 15px center;
    padding-right: 40px;
}

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--verde);
    box-shadow: 0 0 0 3px rgba(62, 124, 90, .18);
}

input[type="date"] { min-height: 52px; }

.input-money { position: relative; }

.money-sign {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--texto-sec);
    font-size: 17px;
    font-weight: 600;
    pointer-events: none;
}

.input-money input {
    padding-left: 30px;
    font-size: 18px;
    font-weight: 600;
}

.grid-3 {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 9px;
}

.grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.grid-2 .field { margin-bottom: 17px; }

.nota-reporte {
    font-size: 12.5px;
    color: var(--texto-sec);
    line-height: 1.45;
    padding: 0 4px;
}

.grid-3 .field { margin-bottom: 0; }
.grid-3 input { padding-left: 10px; padding-right: 10px; }

.subgroup {
    background: var(--verde-claro);
    border: 1px solid var(--verde-borde);
    border-radius: 10px;
    padding: 14px;
    margin-bottom: 17px;
}

.subgroup-title {
    font-size: 13px;
    font-weight: 700;
    color: var(--verde-osc);
    margin-bottom: 11px;
}

/* ------------------------- Segmented (Card Type) ------------------------- */

.segmented {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.seg {
    min-height: 56px;
    padding: 10px 8px;
    border: 2px solid var(--borde);
    border-radius: 10px;
    background: #F4F5F7;              /* sin elegir: gris claro */
    color: var(--texto-sec);
    font-family: inherit;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: background .15s, border-color .15s, color .15s, box-shadow .15s;
}

/* El elegido queda en naranja para que se vea de un golpe cual es. */
.seg.is-active {
    background: var(--naranja);
    border-color: var(--naranja);
    color: #fff;
    box-shadow: 0 3px 10px rgba(232, 100, 28, .28);
}

.seg:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px rgba(232, 100, 28, .30);
}

/* ------------------------- Tarjeta fija del usuario ------------------------- */

/* El usuario tiene tarjeta asignada: se muestra bloqueada, no se cambia. */
input.input-bloqueado {
    background: var(--verde-claro);
    border-color: var(--verde-borde);
    color: var(--verde-osc);
    font-weight: 600;
    cursor: default;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='13' height='16'><path d='M3.2 7V4.6a3.3 3.3 0 016.6 0V7' fill='none' stroke='%231E4620' stroke-width='1.6'/><rect x='1.4' y='7' width='10.2' height='7.6' rx='1.6' fill='%231E4620'/></svg>");
    background-repeat: no-repeat;
    background-position: right 14px center;
    padding-right: 40px;
}

input.input-bloqueado:focus {
    border-color: var(--verde-borde);
    box-shadow: none;
}

/* ------------------------- Foto del ticket ------------------------- */

.dropzone {
    width: 100%;
    min-height: 108px;
    border: 2px dashed #D6D9DE;
    border-radius: 10px;
    background: #FAFBFC;
    color: var(--texto-sec);
    font-family: inherit;
    font-size: 15px;
    font-weight: 600;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    cursor: pointer;
}

.dropzone:active { background: #F1F3F5; }
.dropzone-icon { font-size: 28px; }

.dropzone-hint {
    font-size: 12px;
    font-weight: 500;
    color: var(--texto-sec);
    opacity: .8;
}

.preview {
    position: relative;
    border-radius: 10px;
    overflow: hidden;
    border: 1px solid var(--borde);
    background: #000;
}

.preview img,
.preview canvas {
    display: block;
    width: 100%;
    max-height: 300px;
    object-fit: contain;
}

/* Primera pagina del PDF: sobre blanco, que es como se imprime */
.preview-pdf { background: #fff; }

/* Respaldo cuando el PDF no se puede renderizar */
.preview-archivo {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 160px;
    padding: 24px 46px;
    background: var(--verde-claro);
    color: var(--verde-osc);
    text-align: center;
}

.preview-archivo-icono { font-size: 40px; }

.preview-archivo-nombre {
    font-size: 13px;
    font-weight: 600;
    word-break: break-all;
    line-height: 1.35;
}

.preview-remove {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 34px;
    height: 34px;
    border: none;
    border-radius: 50%;
    background: rgba(0, 0, 0, .62);
    color: #fff;
    font-size: 16px;
    cursor: pointer;
}

/* Spinner del OCR encima de la foto */

.ocr-cargando {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    background: rgba(15, 38, 26, .58);
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
    color: #fff;
    font-size: 14.5px;
    font-weight: 600;
}

.ocr-spinner {
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255, 255, 255, .35);
    border-top-color: #fff;
    border-radius: 50%;
    animation: giro .7s linear infinite;
}

/* ------------------------- Botones ------------------------- */

.btn {
    min-height: 52px;
    padding: 13px 20px;
    border: none;
    border-radius: 10px;
    font-family: inherit;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: opacity .15s, background .15s;
}

.btn:active { opacity: .82; }
.btn[disabled] { opacity: .55; cursor: default; }

.btn-primary {
    background: linear-gradient(135deg, var(--naranja) 0%, var(--naranja-2) 100%);
    color: #fff;
    box-shadow: 0 4px 12px rgba(232, 100, 28, .26);
}

.btn-primary[disabled] { box-shadow: none; }

.btn-ghost   { background: #EDEFF2; color: var(--texto); }
.btn-block   { width: 100%; }

.btn-small {
    min-height: 40px;
    padding: 8px 15px;
    font-size: 14px;
}

.btn-danger { background: var(--error-bg); color: var(--error); }
.btn-ok     { background: #E7F4EB; color: var(--ok); }

.form-actions {
    display: grid;
    grid-template-columns: 1fr 1.6fr;
    gap: 11px;
    margin-top: 22px;
}

.form-error {
    background: var(--error-bg);
    color: var(--error);
    border-radius: 9px;
    padding: 11px 13px;
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 15px;
}

/* ------------------- Aviso de posible duplicado ------------------- */

.alerta-dup {
    display: flex;
    align-items: flex-start;
    gap: 11px;
    background: #FFF8E1;
    border: 1px solid #F0D48A;
    border-left: 4px solid #E0A800;
    border-radius: var(--radio);
    padding: 13px 12px 13px 14px;
    margin-bottom: 16px;
    box-shadow: var(--sombra);
}

.alerta-dup-icono {
    font-size: 18px;
    line-height: 1.3;
    flex-shrink: 0;
}

.alerta-dup-texto {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 3px;
    font-size: 13.5px;
    color: #6B4E06;
    line-height: 1.4;
}

.alerta-dup-texto strong { font-size: 14.5px; }

.alerta-dup-texto em {
    font-style: normal;
    font-weight: 600;
    color: #8A6708;
}

.alerta-dup-cerrar {
    flex-shrink: 0;
    width: 30px;
    height: 30px;
    border: none;
    border-radius: 8px;
    background: none;
    color: #8A6708;
    font-size: 14px;
    cursor: pointer;
}

.alerta-dup-cerrar:active { background: #F6EAC4; }

/* ------------------------- Listas ------------------------- */

.list-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 13px;
}

.resumen {
    font-size: 13.5px;
    color: var(--texto-sec);
    font-weight: 500;
}

.resumen b { color: var(--texto); font-size: 15px; }

.list { display: flex; flex-direction: column; gap: 10px; }

.gasto-item {
    display: flex;
    align-items: center;
    gap: 13px;
    background: var(--superficie);
    border: 1px solid var(--borde);
    border-radius: var(--radio);
    padding: 12px;
    box-shadow: var(--sombra);
}

.gasto-thumb {
    width: 62px;
    height: 62px;
    flex-shrink: 0;
    border-radius: 9px;
    overflow: hidden;
    background: #EFF1F4;
    border: none;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    color: #A9B0B8;
    cursor: pointer;
}

/* Recibo en PDF: no hay miniatura, se marca con el icono en verde */
.gasto-thumb-pdf {
    background: var(--verde-claro);
    color: var(--verde-osc);
}

.gasto-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.gasto-body { flex: 1; min-width: 0; }

.gasto-top {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 10px;
}

.gasto-monto {
    font-size: 18px;
    font-weight: 700;
    white-space: nowrap;
}

.gasto-fecha {
    font-size: 12.5px;
    color: var(--texto-sec);
    white-space: nowrap;
}

.gasto-desc {
    font-size: 14px;
    margin-top: 2px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.gasto-meta {
    margin-top: 6px;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
}

.chip {
    display: inline-block;
    background: var(--verde-claro);
    color: var(--verde-osc);
    border-radius: 999px;
    padding: 3px 9px;
    font-size: 11.5px;
    font-weight: 700;
}

.chip-gris { background: #EEF0F3; color: var(--texto-sec); }

.gasto-user {
    font-size: 12px;
    color: var(--texto-sec);
}

/* Filas del panel admin */

.row-item {
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--superficie);
    border: 1px solid var(--borde);
    border-radius: var(--radio);
    padding: 13px 14px;
    box-shadow: var(--sombra);
}

.row-item.is-off { opacity: .55; }

.row-body { flex: 1; min-width: 0; }

.row-title {
    font-size: 15px;
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.row-sub {
    font-size: 12.5px;
    color: var(--texto-sec);
    margin-top: 2px;
}

/* Nota chica bajo un campo del formulario */
.field-nota {
    display: block;
    margin-top: 6px;
    font-size: 12px;
    line-height: 1.4;
    color: var(--texto-sec);
}

/* Botones apilados a la derecha de una fila de usuario */
.row-acciones {
    display: flex;
    flex-direction: column;
    gap: 6px;
    flex-shrink: 0;
}

/* Mini-form de password temporal dentro de la fila */
.mini-form {
    display: flex;
    flex-wrap: wrap;
    gap: 7px;
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px dashed var(--borde);
}

.mini-form input {
    flex: 1 1 150px;
    min-width: 0;
    min-height: 38px;
    padding: 7px 10px;
    border: 1.5px solid var(--borde);
    border-radius: 8px;
    background: var(--superficie);
    color: var(--texto);
    font-family: inherit;
    font-size: 14px;
}

.mini-form input:focus {
    outline: none;
    border-color: var(--verde);
    box-shadow: 0 0 0 3px rgba(62, 124, 90, .18);
}

.mini-form .btn-small { min-height: 38px; }

/* Selector de tarjeta por defecto dentro de la fila de usuario */
.row-select {
    width: 100%;
    max-width: 260px;
    min-height: 38px;
    margin-top: 9px;
    padding: 7px 30px 7px 10px;
    border: 1.5px solid var(--borde);
    border-radius: 8px;
    background-color: var(--superficie);
    background-position: right 10px center;
    color: var(--texto);
    font-family: inherit;
    font-size: 13.5px;
}

.row-select:focus {
    outline: none;
    border-color: var(--verde);
    box-shadow: 0 0 0 3px rgba(62, 124, 90, .18);
}

.row-select[disabled] { opacity: .6; }

.vacio {
    text-align: center;
    color: var(--texto-sec);
    font-size: 14.5px;
    padding: 42px 20px;
    background: var(--superficie);
    border: 1px dashed var(--borde);
    border-radius: var(--radio);
}

/* ------------------------- Tabs ------------------------- */

.tabs {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 6px;
    background: #E9ECEF;
    border-radius: 11px;
    padding: 5px;
    margin-bottom: 15px;
}

.tab {
    min-height: 42px;
    padding: 0 2px;
    border: none;
    border-radius: 8px;
    background: transparent;
    color: var(--texto-sec);
    font-family: inherit;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
}

.tab.is-active {
    background: var(--superficie);
    color: var(--texto);
    box-shadow: var(--sombra);
}

/* ------------------------- Nav inferior ------------------------- */

.bottom-nav {
    position: fixed;
    inset: auto 0 0 0;
    z-index: 30;
    display: flex;
    background: var(--superficie);
    border-top: 1px solid var(--borde);
    padding-bottom: var(--safe-bottom);
    box-shadow: 0 -2px 10px rgba(16, 24, 40, .06);
}

.nav-btn {
    flex: 1;
    height: var(--nav-h);
    border: none;
    background: none;
    color: var(--texto-sec);
    font-family: inherit;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    cursor: pointer;
}

.nav-btn.is-active { color: var(--verde); }
.nav-icon { font-size: 20px; line-height: 1; }
.nav-label { font-size: 11px; font-weight: 600; }

/* ------------------------- Banner de instalacion ------------------------- */

.install-banner {
    position: fixed;
    left: 12px;
    right: 12px;
    bottom: calc(var(--nav-h) + var(--safe-bottom) + 12px);
    z-index: 40;
    background: #1F2933;
    color: #fff;
    border-radius: var(--radio);
    padding: 14px 15px;
    box-shadow: 0 8px 26px rgba(0, 0, 0, .28);
    display: flex;
    flex-direction: column;
    gap: 11px;
    max-width: 616px;
    margin: 0 auto;
}

.install-text { display: flex; flex-direction: column; gap: 3px; }
.install-text strong { font-size: 15px; }
.install-text span { font-size: 13px; color: #C7CDD4; line-height: 1.4; }
.install-actions { display: flex; gap: 9px; }
.install-actions .btn { flex: 1; }
.install-banner .btn-ghost { background: #3A444F; color: #fff; }

/* ------------------------- Visor de ticket ------------------------- */

.lightbox {
    position: fixed;
    inset: 0;
    z-index: 60;
    background: rgba(0, 0, 0, .93);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.lightbox[hidden] { display: none; }

.lightbox img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.lightbox-close {
    position: absolute;
    top: calc(14px + var(--safe-top));
    right: 14px;
    width: 44px;
    height: 44px;
    border: none;
    border-radius: 50%;
    background: rgba(255, 255, 255, .16);
    color: #fff;
    font-size: 19px;
    cursor: pointer;
}

/* ------------------------- Toast / loader ------------------------- */

.toast {
    position: fixed;
    left: 50%;
    bottom: calc(var(--nav-h) + var(--safe-bottom) + 18px);
    transform: translateX(-50%);
    z-index: 70;
    background: #1F2933;
    color: #fff;
    padding: 13px 20px;
    border-radius: 999px;
    font-size: 14.5px;
    font-weight: 600;
    box-shadow: 0 6px 20px rgba(0, 0, 0, .26);
    max-width: 90vw;
    text-align: center;
}

.toast.is-ok    { background: var(--ok); }
.toast.is-error { background: var(--error); }

.loader {
    position: fixed;
    inset: 0;
    z-index: 80;
    background: rgba(255, 255, 255, .62);
    display: flex;
    align-items: center;
    justify-content: center;
}

.loader[hidden] { display: none; }

.spinner {
    width: 42px;
    height: 42px;
    border: 4px solid rgba(62, 124, 90, .26);
    border-top-color: var(--verde);
    border-radius: 50%;
    animation: giro .7s linear infinite;
}

@keyframes giro { to { transform: rotate(360deg); } }

/* ------------------------- Escritorio ------------------------- */

@media (min-width: 720px) {
    #mainArea { padding-left: 20px; padding-right: 20px; }
    .bottom-nav { justify-content: center; }
    .nav-btn { flex: 0 0 150px; }
}

/* ------------------------- Pop-up "Receipt saved" ------------------------- */

/* El body no se mueve detras del modal. */
body.sin-scroll { overflow: hidden; }

.modal {
    position: fixed;
    inset: 0;
    z-index: 120;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: rgba(15, 32, 22, .55);
    -webkit-backdrop-filter: blur(2px);
    backdrop-filter: blur(2px);
    animation: modal-fondo .18s ease-out;
}

.modal-card {
    width: 100%;
    max-width: 340px;
    padding: 28px 24px 22px;
    border-radius: 16px;
    background: var(--superficie);
    border-top: 5px solid var(--ok);
    box-shadow: 0 18px 44px rgba(16, 24, 40, .28);
    text-align: center;
    animation: modal-entra .22s cubic-bezier(.2, .9, .3, 1.2);
}

.modal-icono {
    width: 76px;
    height: 76px;
    margin: 0 auto 16px;
    border-radius: 50%;
    background: #E7F4EB;
    color: var(--ok);
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-titulo {
    font-size: 21px;
    font-weight: 700;
    color: var(--ok);
    margin-bottom: 6px;
}

.modal-texto {
    font-size: 14.5px;
    line-height: 1.45;
    color: var(--texto-sec);
    margin-bottom: 20px;
}

.modal-ok {
    width: 100%;
    background: var(--ok);
    color: #fff;
    box-shadow: 0 4px 12px rgba(46, 125, 70, .26);
}

@keyframes modal-fondo {
    from { opacity: 0; }
    to   { opacity: 1; }
}

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

@media (prefers-reduced-motion: reduce) {
    .modal, .modal-card { animation: none; }
}

/* ------------------------- Rol del usuario (panel admin) ------------------------- */

/* El nombre lleva al lado un chip con el rol, para verlo de un vistazo. */
.row-title-chip {
    display: flex;
    align-items: center;
    gap: 8px;
    white-space: normal;
    overflow: visible;
}

.row-nombre {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.chip-rol {
    flex: none;
    padding: 2px 9px;
    border-radius: 999px;
    border: 1px solid var(--verde-borde);
    background: var(--verde-claro);
    color: var(--verde-osc);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .3px;
    text-transform: uppercase;
    line-height: 1.6;
}

/* Admin: verde solido, se distingue del empleado sin tener que leer. */
.chip-rol.is-admin {
    background: var(--verde);
    border-color: var(--verde);
    color: #fff;
}
