/*
 * PrestamiPE — hoja de estilos única.
 *
 * Escrita a mano y servida estática: sin build, sin toolchain, sin npm.
 * Objetivo duro: la pantalla /ruta pesa menos de 100 KB en total.
 *
 * Pensada para un Android de gama baja, al sol, sostenido con una mano.
 * De ahí las cuatro reglas que mandan sobre cualquier capricho estético:
 *   1. Contraste alto. La pantalla se lee a mediodía en la calle.
 *   2. Áreas táctiles de 48 px. Se usa en movimiento y con prisa.
 *   3. El dinero nunca se parte en dos líneas ni cambia de sitio.
 *   4. Siempre en claro. El modo oscuro se lee peor bajo el sol, y hacía
 *      que la app se viera distinta según el celular de cada uno.
 */

/* ==========================================================================
   1. Tokens
   ========================================================================== */

:root {
    /* Marca */
    --verde: #067a4e;
    --verde-fuerte: #045c3a;
    --verde-tinte: #e8f5ef;
    --verde-borde: #b6e0cd;

    /* Estados */
    --rojo: #c02626;
    --rojo-tinte: #fdeceb;
    --rojo-borde: #f5c2bf;
    --ambar: #8a5a00;
    --ambar-tinte: #fff4e0;
    --ambar-borde: #f0d199;

    /* Neutros */
    --tinta: #101318;
    --tinta-media: #4a5361;
    --tinta-suave: #6b7686;
    --linea: #e2e6ec;
    --linea-fuerte: #cdd4dd;
    --fondo: #f5f7f9;
    --papel: #ffffff;
    --papel-hundido: #f0f3f6;

    /* Formas */
    --r-chico: 8px;
    --r: 12px;
    --r-grande: 16px;

    --sombra-1: 0 1px 2px rgb(16 19 24 / 6%);
    --sombra-2: 0 1px 3px rgb(16 19 24 / 8%), 0 6px 16px -6px rgb(16 19 24 / 10%);
    --sombra-3: 0 2px 6px rgb(16 19 24 / 10%), 0 16px 32px -12px rgb(16 19 24 / 16%);

    /* Área táctil mínima. No bajar de aquí: se usa en movimiento. */
    --toque: 48px;

    --ancho: 780px;
}

/* ==========================================================================
   2. Base
   ========================================================================== */

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

html {
    /* Siempre claro, aunque el celular esté en modo oscuro. Así también salen
       claros los controles nativos: selects, calendarios y barras de scroll. */
    color-scheme: light;
    background: var(--fondo);
    -webkit-text-size-adjust: 100%;
    scroll-behavior: smooth;
}

body {
    margin: 0;
    background: var(--fondo);
    color: var(--tinta);
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    font-size: 16px;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

h1, h2, h3 {
    margin: 0 0 0.4rem;
    line-height: 1.2;
    letter-spacing: -0.015em;
    font-weight: 700;
}

h1 { font-size: 1.55rem; }
h2 { font-size: 1.15rem; margin-top: 1.75rem; }
h3 { font-size: 0.98rem; }

h2:first-child,
h1 + h2 { margin-top: 0; }

p { margin: 0 0 0.75rem; }
p:last-child { margin-bottom: 0; }

a {
    color: var(--verde);
    text-decoration: none;
    font-weight: 500;
}

a:hover { text-decoration: underline; }

:focus-visible {
    outline: 2px solid var(--verde);
    outline-offset: 2px;
    border-radius: var(--r-chico);
}

/* ==========================================================================
   3. Estructura
   ========================================================================== */

.cont {
    max-width: var(--ancho);
    margin: 0 auto;
    padding: 1.15rem 1rem 4rem;
}

.barra {
    background: var(--verde);
    color: #fff;
    padding: 0.7rem 1rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    box-shadow: var(--sombra-1);
}

.barra a { color: #fff; }

.barra .marca {
    font-weight: 800;
    font-size: 1.05rem;
    letter-spacing: -0.02em;
    margin-right: auto;
}

.barra .marca:hover { text-decoration: none; opacity: 0.9; }

.barra form { margin: 0; }

.barra .btn-suave {
    background: rgb(255 255 255 / 15%);
    border-color: rgb(255 255 255 / 25%);
    color: #fff;
    min-height: 38px;
    padding: 0.3rem 0.8rem;
    font-size: 0.88rem;
}

.barra .btn-suave:hover { background: rgb(255 255 255 / 25%); }

.barra .chico { opacity: 0.85; }

/* Navegación: se desplaza en horizontal sin que se note el corte. */
.nav {
    display: flex;
    gap: 0.15rem;
    overflow-x: auto;
    background: var(--papel);
    border-bottom: 1px solid var(--linea);
    padding: 0 0.5rem;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
}

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

.nav a {
    padding: 0.8rem 0.7rem 0.7rem;
    color: var(--tinta-suave);
    font-size: 0.9rem;
    font-weight: 600;
    white-space: nowrap;
    border-bottom: 2.5px solid transparent;
    flex: 0 0 auto;
}

.nav a:hover { color: var(--tinta); text-decoration: none; }

.nav a.activo {
    color: var(--verde);
    border-bottom-color: var(--verde);
}

/* Cinta de la demostración: visible sin robarle sitio a la aplicación. */
.cinta-demo {
    background: var(--ambar-tinte);
    border-bottom: 1px solid var(--ambar-borde);
    color: var(--ambar);
    padding: 0.5rem 1rem;
    text-align: center;
    font-size: 0.82rem;
    font-weight: 600;
    line-height: 1.4;
}

.cinta-demo a {
    color: var(--ambar);
    text-decoration: underline;
    white-space: nowrap;
}

/* ==========================================================================
   4. Tarjetas y cifras
   ========================================================================== */

.tarjeta {
    background: var(--papel);
    border: 1px solid var(--linea);
    border-radius: var(--r);
    padding: 1.15rem;
    margin-bottom: 0.85rem;
    box-shadow: var(--sombra-1);
}

.tarjeta > h2:first-child,
.tarjeta > h3:first-child { margin-top: 0; }

.cifras {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(9.5rem, 1fr));
    gap: 0.6rem;
    margin-bottom: 1.25rem;
}

.cifra {
    background: var(--papel);
    border: 1px solid var(--linea);
    border-radius: var(--r);
    padding: 0.85rem 0.95rem;
    box-shadow: var(--sombra-1);
    min-width: 0;
}

.cifra .rotulo {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--tinta-suave);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* El dinero NO se parte en dos líneas: encoge antes que envolver. */
.cifra .valor {
    font-size: clamp(1.15rem, 5.5vw, 1.6rem);
    font-weight: 800;
    letter-spacing: -0.03em;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
    margin-top: 0.15rem;
    line-height: 1.15;
}

.cifra.alerta .valor { color: var(--rojo); }
.cifra.bien .valor { color: var(--verde); }

/* ==========================================================================
   5. Formularios
   ========================================================================== */

.campo { margin-bottom: 1.05rem; }
.campo:last-child { margin-bottom: 0; }

.campo label {
    display: block;
    font-weight: 650;
    font-size: 0.9rem;
    margin-bottom: 0.35rem;
    color: var(--tinta);
}

.campo .ayuda {
    font-size: 0.83rem;
    line-height: 1.45;
    color: var(--tinta-suave);
    margin: 0.35rem 0 0;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="date"],
input[type="tel"],
input[type="file"],
select,
textarea {
    width: 100%;
    min-height: var(--toque);
    padding: 0.65rem 0.8rem;
    border: 1.5px solid var(--linea-fuerte);
    border-radius: var(--r-chico);
    background: var(--papel);
    color: var(--tinta);
    font: inherit;
    /* 16px evita que Safari haga zoom al enfocar. */
    font-size: 16px;
    transition: border-color 0.12s ease, box-shadow 0.12s ease;
}

textarea { min-height: 5rem; resize: vertical; }

select {
    appearance: none;
    background-image: linear-gradient(45deg, transparent 50%, var(--tinta-suave) 50%),
                      linear-gradient(135deg, var(--tinta-suave) 50%, transparent 50%);
    background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%;
    background-size: 5px 5px, 5px 5px;
    background-repeat: no-repeat;
    padding-right: 2.25rem;
}

input::placeholder, textarea::placeholder { color: var(--tinta-suave); opacity: 0.75; }

input:hover, select:hover, textarea:hover { border-color: var(--tinta-suave); }

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--verde);
    box-shadow: 0 0 0 3px rgb(6 122 78 / 16%);
}

input[type="checkbox"] {
    width: 22px;
    height: 22px;
    min-height: 22px;
    accent-color: var(--verde);
    flex: 0 0 auto;
}

.error {
    color: var(--rojo);
    font-size: 0.84rem;
    font-weight: 500;
    margin: 0.35rem 0 0;
}

input.malo, select.malo, textarea.malo {
    border-color: var(--rojo);
    background: var(--rojo-tinte);
}

/* ==========================================================================
   6. Botones
   ========================================================================== */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    min-height: var(--toque);
    padding: 0.55rem 1.05rem;
    border: 1.5px solid transparent;
    border-radius: var(--r-chico);
    background: var(--verde);
    color: #fff;
    font: inherit;
    font-weight: 650;
    line-height: 1.2;
    cursor: pointer;
    text-align: center;
    white-space: nowrap;
    box-shadow: var(--sombra-1);
    transition: background 0.12s ease, transform 0.06s ease, box-shadow 0.12s ease;
}

.btn:hover {
    background: var(--verde-fuerte);
    text-decoration: none;
    color: #fff;
    box-shadow: var(--sombra-2);
}

.btn:active { transform: translateY(1px); box-shadow: var(--sombra-1); }

.btn:disabled, .btn[disabled] {
    opacity: 0.5;
    cursor: not-allowed;
    box-shadow: none;
}

.btn-suave {
    background: var(--papel);
    color: var(--tinta);
    border-color: var(--linea-fuerte);
}

.btn-suave:hover {
    background: var(--papel-hundido);
    color: var(--tinta);
    border-color: var(--tinta-suave);
}

.btn-peligro { background: var(--rojo); }
.btn-peligro:hover { background: var(--rojo); filter: brightness(0.9); }

.btn-ancho { width: 100%; }

.btn-grande {
    min-height: 58px;
    font-size: 1.08rem;
    border-radius: var(--r);
}

.fila-botones {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    align-items: center;
}

/* ==========================================================================
   7. Opciones del asistente
   ========================================================================== */

.opciones {
    display: grid;
    gap: 0.6rem;
    margin-bottom: 1.25rem;
}

.opcion {
    display: block;
    width: 100%;
    text-align: left;
    padding: 1rem 1.1rem;
    border: 2px solid var(--linea);
    border-radius: var(--r);
    background: var(--papel);
    color: var(--tinta);
    font: inherit;
    cursor: pointer;
    min-height: var(--toque);
    transition: border-color 0.12s ease, background 0.12s ease, transform 0.06s ease;
}

.opcion:hover {
    border-color: var(--verde);
    background: var(--verde-tinte);
}

.opcion:active { transform: translateY(1px); }

.opcion.elegida {
    border-color: var(--verde);
    background: var(--verde-tinte);
}

.opcion .titulo {
    font-weight: 700;
    display: block;
    margin-bottom: 0.1rem;
}

.opcion .detalle {
    font-size: 0.87rem;
    line-height: 1.45;
    color: var(--tinta-suave);
}

/* ==========================================================================
   8. Listas
   ========================================================================== */

.lista {
    list-style: none;
    margin: 0;
    padding: 0;
}

.lista li {
    background: var(--papel);
    border: 1px solid var(--linea);
    border-radius: var(--r);
    margin-bottom: 0.45rem;
    box-shadow: var(--sombra-1);
    overflow: hidden;
}

.lista a,
.lista .fila {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    padding: 0.8rem 1rem;
    min-height: var(--toque);
    color: inherit;
    font-weight: 400;
    transition: background 0.12s ease;
}

.lista a:hover {
    background: var(--verde-tinte);
    text-decoration: none;
}

.fila .principal { flex: 1; min-width: 0; }

/* `display:block` explícito: en la pantalla de ruta el nombre y el detalle
   son <span>, y sin esto quedaban en la misma línea, montados sobre el monto. */
.fila .principal > * { display: block; }

.fila .nombre {
    font-weight: 650;
    letter-spacing: -0.01em;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/*
 * Una sola línea, siempre. Con dos, las filas de la ruta crecen a 98 px y
 * caben cuatro clientes en pantalla en vez de siete — el cobrador acaba
 * haciendo scroll en vez de cobrar.
 */
.fila .secundario {
    font-size: 0.84rem;
    color: var(--tinta-suave);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.4;
}

.fila .secundario .etiqueta { margin: 0 0.15rem; vertical-align: baseline; }

.fila .monto {
    font-weight: 750;
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.02em;
    white-space: nowrap;
    flex: 0 0 auto;
}

/* Desglose de lo que debe el cliente, dentro de la pantalla de cobro. */
.desglose {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
    margin-bottom: 0.85rem;
}

.desglose > div {
    background: var(--papel-hundido);
    border-radius: var(--r-chico);
    padding: 0.5rem 0.7rem;
    min-width: 0;
}

.desglose .rotulo {
    display: block;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--tinta-suave);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.desglose .cifra-chica {
    display: block;
    font-size: 1.05rem;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.02em;
    white-space: nowrap;
}

/* ==========================================================================
   9. Tablas (solo panel, nunca en /ruta)
   ========================================================================== */

.tabla-scroll {
    overflow-x: auto;
    border-radius: var(--r-chico);
    -webkit-overflow-scrolling: touch;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.89rem;
}

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

tr:last-child td { border-bottom: 0; }

th {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--tinta-suave);
    background: var(--papel-hundido);
    position: sticky;
    top: 0;
}

td.num, th.num {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

tbody tr:hover { background: var(--papel-hundido); }

details > summary {
    list-style: none;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    min-height: 40px;
}

details > summary::-webkit-details-marker { display: none; }

details > summary::before {
    content: "▸";
    color: var(--tinta-suave);
    transition: transform 0.15s ease;
}

details[open] > summary::before { transform: rotate(90deg); }

/* ==========================================================================
   10. Calendario de cobros
   ========================================================================== */

.calendario-grilla {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 4px;
}

.calendario-inicial {
    text-align: center;
    font-size: 0.68rem;
    font-weight: 800;
    letter-spacing: 0.04em;
    color: var(--tinta-suave);
    padding-bottom: 0.3rem;
}

.calendario-dia {
    aspect-ratio: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border-radius: var(--r-chico);
    background: var(--papel-hundido);
    font-variant-numeric: tabular-nums;
    line-height: 1.05;
    padding: 0;
    min-width: 0;
}

.calendario-dia .numero {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--tinta-suave);
}

.calendario-dia .monto {
    font-size: 0.68rem;
    font-weight: 800;
    letter-spacing: -0.02em;
    max-width: 100%;
    overflow: hidden;
}

.calendario-dia.fuera {
    background: transparent;
    opacity: 0.3;
}

.calendario-dia.con-cobro {
    background: var(--verde);
    color: #fff;
    box-shadow: var(--sombra-1);
}

.calendario-dia.con-cobro .numero { color: rgb(255 255 255 / 75%); }

.calendario-dia.es-hoy {
    outline: 2.5px solid var(--ambar);
    outline-offset: -2.5px;
}

.calendario-dia.elegido {
    outline: 3px solid var(--tinta);
    outline-offset: -3px;
    opacity: 1 !important;
}

button.calendario-dia {
    font: inherit;
    border: 0;
    cursor: pointer;
    transition: transform 0.06s ease;
}

button.calendario-dia:hover { filter: brightness(1.08); }
button.calendario-dia:active { transform: scale(0.94); }

/* Paginador del mes: nunca debe partirse en dos líneas. */
.mes-nav {
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.85rem;
}

.mes-nav strong {
    text-align: center;
    font-size: 1rem;
    letter-spacing: -0.01em;
}

.mes-nav .btn {
    padding: 0.4rem 0.75rem;
    min-height: 42px;
    font-size: 1.1rem;
    line-height: 1;
}

/* ==========================================================================
   11. Avisos y etiquetas
   ========================================================================== */

.aviso {
    border-radius: var(--r);
    padding: 0.85rem 1rem;
    margin-bottom: 1rem;
    border: 1px solid;
    border-left-width: 4px;
    font-size: 0.92rem;
    line-height: 1.5;
}

.aviso strong { display: block; margin-bottom: 0.1rem; }

.aviso-ok {
    background: var(--verde-tinte);
    border-color: var(--verde-borde);
    border-left-color: var(--verde);
    color: var(--tinta);
}

.aviso-alerta {
    background: var(--ambar-tinte);
    border-color: var(--ambar-borde);
    border-left-color: var(--ambar);
    color: var(--tinta);
}

.aviso-malo {
    background: var(--rojo-tinte);
    border-color: var(--rojo-borde);
    border-left-color: var(--rojo);
    color: var(--tinta);
}

.etiqueta {
    display: inline-block;
    padding: 0.1rem 0.5rem;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 750;
    letter-spacing: 0.01em;
    white-space: nowrap;
}

.etiqueta-atraso { background: var(--rojo-tinte); color: var(--rojo); }
.etiqueta-hoy { background: var(--verde-tinte); color: var(--verde); }
.etiqueta-neutra { background: var(--papel-hundido); color: var(--tinta-suave); }

/* ==========================================================================
   12. Utilidades mínimas
   ========================================================================== */

.entre {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
}

.entre h1, .entre h2 { min-width: 0; }

.suave { color: var(--tinta-suave); }
.chico { font-size: 0.85rem; line-height: 1.5; }
.num { font-variant-numeric: tabular-nums; }
.centro { text-align: center; }
.mt { margin-top: 1.5rem; }
.mb0 { margin-bottom: 0; }

.vacio {
    padding: 2.25rem 1.25rem;
    text-align: center;
    color: var(--tinta-suave);
}

.vacio p { margin-bottom: 0.85rem; }
.vacio .btn { margin-top: 0.25rem; }

/* Paginación de Livewire */
nav[role="navigation"] { font-size: 0.9rem; }

/* ==========================================================================
   12b. Visitas (solo superusuario)
   ========================================================================== */

.filtro-visitas {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 0.75rem;
}

.filtro-visitas .campo {
    margin-bottom: 0;
    flex: 1 1 8rem;
}

/* Un botón que se lee como enlace: la IP se puede tocar para filtrar por
   ella, pero no lleva a otra página. */
.enlace {
    background: none;
    border: 0;
    padding: 0;
    font: inherit;
    color: var(--verde);
    cursor: pointer;
    text-decoration: underline;
    text-underline-offset: 2px;
}

.enlace:hover { color: var(--verde-fuerte); }

.acciones-visita {
    display: flex;
    gap: 0.35rem;
    justify-content: flex-end;
}

.acciones-visita .btn {
    padding: 0.35rem 0.6rem;
    font-size: 0.82rem;
    min-height: 0;
}

tr.fila-abierta > td { background: var(--verde-tinte); }

.detalle-visita > td { background: var(--papel-hundido); }

.recorrido {
    list-style: none;
    margin: 0;
    padding: 0;
    max-height: 18rem;
    overflow-y: auto;
}

.recorrido li {
    display: flex;
    align-items: baseline;
    gap: 0.6rem;
    padding: 0.25rem 0;
    border-bottom: 1px solid var(--linea);
    font-size: 0.86rem;
}

.recorrido li:last-child { border-bottom: 0; }

.recorrido .hora {
    color: var(--tinta-suave);
    font-variant-numeric: tabular-nums;
    flex: 0 0 4.5rem;
}

.recorrido .ruta {
    font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
    word-break: break-all;
}

/* ==========================================================================
   13. Pantallas anchas
   ========================================================================== */

@media (min-width: 640px) {
    .cont { padding: 1.75rem 1.5rem 4rem; }

    h1 { font-size: 1.8rem; }

    .cifras { gap: 0.85rem; }

    .cifra { padding: 1rem 1.15rem; }

    .cifra .valor { font-size: 1.65rem; }

    .barra { padding: 0.8rem 1.5rem; }

    .nav { padding: 0 1.25rem; }

    .nav a { padding: 0.9rem 0.9rem 0.75rem; font-size: 0.92rem; }
}
