:root {
    --azul: #1f6feb;
    --azul-osc: #1858c4;
    --verde: #2ea043;
    --rojo: #d1242f;
    --gris: #6b7280;
    --gris-bg: #f4f6f9;
    --borde: #e2e6ec;
    --texto: #1f2430;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    color: var(--texto);
    background: var(--gris-bg);
}

a { color: var(--azul); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- Barra superior ---------- */
.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    background: #fff;
    border-bottom: 1px solid var(--borde);
    padding: 0.7rem 1.4rem;
    position: sticky;
    top: 0;
    z-index: 10;
}
.brand { display: flex; align-items: center; gap: 0.6rem; font-weight: 700; font-size: 1.15rem; color: var(--texto); }
.brand:hover { text-decoration: none; }
.brand-logo { height: 40px; width: auto; display: block; }
.brand-sub { color: var(--gris); font-weight: 400; font-size: 0.85rem; }
.topnav { display: flex; align-items: center; gap: 1.2rem; }
.cart-link { position: relative; font-weight: 600; }
.badge {
    background: var(--azul); color: #fff; border-radius: 999px;
    font-size: 0.72rem; padding: 0.05rem 0.45rem; margin-left: 0.2rem; font-weight: 700;
}
.user { color: var(--gris); font-size: 0.9rem; max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.logout-form { display: inline; margin: 0; }

.content { max-width: 1180px; margin: 0 auto; padding: 1.6rem 1.4rem 3rem; }
h1 { font-size: 1.5rem; margin: 0.2rem 0 1.1rem; }

/* ---------- Botones ---------- */
.btn-primary {
    background: var(--azul); color: #fff; border: none; border-radius: 8px;
    padding: 0.5rem 1rem; font-weight: 600; cursor: pointer; font-size: 0.9rem;
}
.btn-primary:hover { background: var(--azul-osc); }
.btn-primary:disabled { background: #a9c2f2; cursor: default; }
.btn-link { background: none; border: none; color: var(--azul); cursor: pointer; font-size: 0.9rem; padding: 0.4rem 0.2rem; }
.btn-link:disabled { color: #b6bcc6; cursor: default; }

/* ---------- Filtros ---------- */
.filtros {
    display: flex; flex-wrap: wrap; gap: 0.9rem; align-items: end;
    background: #fff; border: 1px solid var(--borde); border-radius: 12px;
    padding: 1rem 1.2rem; margin-bottom: 1.3rem;
}
.campo { display: flex; flex-direction: column; gap: 0.3rem; }
.campo.crecer { flex: 1 1 240px; }
.campo label { font-size: 0.78rem; color: var(--gris); font-weight: 600; }
.campo select, .campo input, .carrito input {
    border: 1px solid var(--borde); border-radius: 8px; padding: 0.45rem 0.6rem;
    font-size: 0.9rem; background: #fff; min-width: 160px;
}
.campo.crecer input { width: 100%; min-width: 0; }

.estado, .conteo { color: var(--gris); }
.conteo { font-size: 0.85rem; margin-bottom: 0.8rem; }

/* ---------- Grid de productos ---------- */
/* Tarjetas anchas: con 230px casi todos los nombres del POS se partían en dos renglones.
   A 340px caben 3 columnas en vez de 4 y el texto disponible pasa de ~240px a ~335px.
   El min() es indispensable: sin él, en un celular más angosto que 340px la columna
   seguiría midiendo 340 y la página se desplazaría de lado. */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(340px, 100%), 1fr)); gap: 1rem; }
.card {
    background: #fff; border: 1px solid var(--borde); border-radius: 12px;
    padding: 0.9rem 1rem; display: flex; flex-direction: column; gap: 0.5rem;
}
.card.agotado { opacity: 0.72; }
.card.en-carrito { border-color: var(--verde); box-shadow: 0 0 0 1px var(--verde) inset; }
.chip-carrito {
    display: inline-flex; align-items: center; align-self: flex-start; gap: 0.3rem;
    background: #e8f6ec; color: #1a7f37; border: 1px solid #b7e0c2;
    border-radius: 999px; padding: 0.2rem 0.6rem; font-size: 0.78rem; font-weight: 700;
}
.chip-carrito:hover { background: #d7efdf; text-decoration: none; }
/* Ya no se reservan dos renglones para el nombre: ahora que la tarjeta es ancha, la
   mayoría entra en uno y el hueco fijo dejaba media línea vacía en casi todas. Los
   botones de la fila siguen alineados porque .agregar lleva margin-top:auto. */
.card .nombre { font-weight: 600; font-size: 0.92rem; line-height: 1.25; }
.card .precio { font-size: 1.2rem; font-weight: 700; color: var(--azul); }
.card .precio .unidad { font-size: 0.8rem; font-weight: 500; color: var(--gris); }
.card .stock { font-size: 0.8rem; }
.card .stock.ok { color: var(--verde); }
.card .stock.agotado-txt { color: var(--rojo); font-weight: 600; }
.card .agregar { display: flex; gap: 0.5rem; margin-top: auto; }
.card .agregar input { width: 70px; }

.paginacion { display: flex; align-items: center; gap: 1rem; justify-content: center; margin-top: 1.6rem; }

/* ---------- Toast ---------- */
.toast {
    position: fixed; bottom: 1.4rem; left: 50%; transform: translateX(-50%);
    background: var(--verde); color: #fff; padding: 0.7rem 1.2rem; border-radius: 10px;
    box-shadow: 0 6px 20px rgba(0,0,0,0.18); font-size: 0.9rem; z-index: 50;
}

/* ---------- Aviso de venta por peso ---------- */
.modal-fondo {
    position: fixed; inset: 0; background: rgba(15,20,30,0.55);
    display: flex; align-items: center; justify-content: center; padding: 1.2rem; z-index: 60;
}
.modal-peso {
    background: #fff; border-radius: 16px; padding: 1.9rem 1.9rem 1.6rem;
    max-width: 460px; width: 100%; text-align: center;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}
.modal-peso .modal-ico { font-size: 2.6rem; line-height: 1; margin-bottom: 0.6rem; }
.modal-peso h2 { margin: 0 0 0.8rem; font-size: 1.25rem; }
.modal-peso p { margin: 0 0 0.9rem; font-size: 0.93rem; line-height: 1.55; color: #414855; }
.modal-peso .btn-primary { margin-top: 0.4rem; padding: 0.6rem 1.6rem; }

.aviso-peso {
    display: flex; gap: 0.9rem; align-items: flex-start;
    background: #fff8e6; border: 1px solid #f2d98c; border-left: 6px solid #e0a800;
    border-radius: 12px; padding: 1rem 1.2rem; margin-bottom: 1.2rem;
}
.aviso-peso .aviso-ico { font-size: 1.5rem; line-height: 1.2; }
.aviso-peso p { margin: 0.35rem 0 0; font-size: 0.9rem; line-height: 1.5; color: #5c4a15; }
.aviso-peso .aviso-lista { font-size: 0.84rem; color: #7a6420; font-weight: 600; }

/* ---------- Carrito ---------- */
table.carrito { width: 100%; border-collapse: collapse; background: #fff; border-radius: 12px; overflow: hidden; border: 1px solid var(--borde); }
table.carrito th, table.carrito td { padding: 0.7rem 0.9rem; text-align: left; border-bottom: 1px solid var(--borde); }
table.carrito th { background: #fafbfc; font-size: 0.78rem; color: var(--gris); text-transform: uppercase; letter-spacing: 0.02em; }
table.carrito .unidad { color: var(--gris); font-size: 0.8rem; }
table.carrito input { width: 80px; }
table.carrito .total-lbl { text-align: right; font-weight: 600; }
table.carrito .total { font-weight: 700; font-size: 1.1rem; color: var(--azul); }
.acciones-carrito { display: flex; justify-content: space-between; align-items: center; margin-top: 1.2rem; }

.ok-checkout { background: #fff; border: 1px solid var(--borde); border-left: 6px solid var(--verde); border-radius: 12px; padding: 1.4rem 1.6rem; max-width: 560px; }
.ok-checkout h2 { margin-top: 0; color: var(--verde); }

.alert-error {
    background: #fdecec; border: 1px solid #f5c2c2; color: var(--rojo);
    border-radius: 10px; padding: 0.7rem 1rem; margin: 1rem 0; font-size: 0.9rem;
}

/* ---------- Login ---------- */
.login-shell { min-height: 100vh; display: flex; }
.login-split { flex: 1; display: grid; grid-template-columns: 1.05fr 0.95fr; }

/* Panel de marca */
.login-hero {
    position: relative;
    display: flex; flex-direction: column; justify-content: center;
    padding: 3rem 3.4rem;
    color: #fff;
    background:
        radial-gradient(1100px 480px at -10% -10%, rgba(246,197,0,0.20), transparent 60%),
        radial-gradient(900px 500px at 120% 120%, rgba(226,35,26,0.22), transparent 55%),
        linear-gradient(135deg, #0f3f8f 0%, #12508f 45%, #1f8f5f 100%);
    overflow: hidden;
}
.hero-inner { max-width: 470px; }
.hero-logo {
    display: inline-block; background: #fff; border-radius: 14px;
    padding: 0.7rem 1rem; margin-bottom: 1.7rem; box-shadow: 0 10px 30px rgba(0,0,0,0.22);
}
.hero-logo img { display: block; width: 300px; max-width: 100%; height: auto; }
.hero-logo:hover { text-decoration: none; transform: translateY(-2px); box-shadow: 0 14px 34px rgba(0,0,0,0.28); }
a.hero-logo { transition: transform .15s, box-shadow .15s; }
.logo-wordmark { display: flex; align-items: baseline; gap: 0.55rem; line-height: 1; }
.logo-wordmark .w-grupo { font-size: 1rem; letter-spacing: 0.45em; font-weight: 600; opacity: 0.85; }
.logo-wordmark .w-arero { font-size: 3.6rem; font-weight: 800; letter-spacing: 0.02em; }
.hero-accent {
    height: 6px; width: 190px; border-radius: 3px; margin: 0.9rem 0 1.7rem;
    background: linear-gradient(90deg, #1e5fb0 0 33%, #f6c500 33% 66%, #e2231a 66% 100%);
}
.hero-tagline { font-size: 1.18rem; font-weight: 700; margin: 0 0 0.6rem; }
.hero-desc { font-size: 0.98rem; line-height: 1.55; opacity: 0.92; margin: 0 0 1.7rem; }
.hero-props { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 0.75rem; }
.hero-props li { display: flex; align-items: center; gap: 0.75rem; font-size: 0.98rem; }
.hero-props .ico {
    display: inline-flex; align-items: center; justify-content: center;
    width: 2.1rem; height: 2.1rem; border-radius: 9px; background: rgba(255,255,255,0.15); font-size: 1.05rem;
}
.hero-eco { position: absolute; bottom: 1.4rem; left: 3.4rem; font-size: 0.8rem; opacity: 0.8; letter-spacing: 0.02em; }

/* Panel del formulario */
.login-panel { display: flex; align-items: center; justify-content: center; padding: 2rem; background: var(--gris-bg); }
.login-card { background: #fff; border-radius: 16px; padding: 2.4rem 2.4rem 1.8rem; width: 100%; max-width: 380px; box-shadow: 0 14px 44px rgba(0,0,0,0.10); border: 1px solid var(--borde); }
.login-card h1 { margin: 0 0 0.2rem; color: var(--texto); font-size: 1.6rem; }
.login-card .sub { color: var(--gris); margin: 0 0 1.5rem; font-size: 0.92rem; }
.login-card form { display: flex; flex-direction: column; gap: 0.9rem; }
.login-card label { display: flex; flex-direction: column; gap: 0.35rem; font-size: 0.82rem; font-weight: 600; color: var(--texto); }
.login-card input { border: 1px solid var(--borde); border-radius: 9px; padding: 0.65rem 0.75rem; font-size: 0.95rem; transition: border-color .15s, box-shadow .15s; }
.login-card input:focus { outline: none; border-color: var(--azul); box-shadow: 0 0 0 3px rgba(31,111,235,0.15); }
.login-card .btn-primary { margin-top: 0.6rem; padding: 0.7rem; font-size: 0.98rem; border-radius: 9px; }
.login-card .ayuda { text-align: center; color: var(--gris); font-size: 0.8rem; margin: 1.3rem 0 0; }
.login-card .volver-sitio { text-align: center; font-size: 0.82rem; margin: 1rem 0 0; padding-top: 0.9rem; border-top: 1px solid var(--borde); }
.login-card .volver-sitio a { color: var(--gris); font-weight: 600; }
.login-card .volver-sitio a:hover { color: var(--azul); text-decoration: none; }

@media (max-width: 860px) {
    /* El hero toma solo la altura de su contenido; el formulario ocupa el resto */
    .login-split { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
    .login-hero { padding: 1.9rem 1.7rem; }
    .logo-wordmark .w-arero { font-size: 2.8rem; }
    .hero-inner { max-width: 100%; }
    .hero-logo { margin-bottom: 1.1rem; padding: 0.55rem 0.8rem; }
    .hero-logo img { width: 215px; }
    .hero-tagline { font-size: 1.1rem; margin-bottom: 0.45rem; }
    .hero-desc { font-size: 0.9rem; line-height: 1.5; margin-bottom: 1.1rem; }
    .hero-props { gap: 0.55rem; }
    .hero-props li { font-size: 0.9rem; }
    .hero-props .ico { width: 1.85rem; height: 1.85rem; font-size: 0.95rem; }
    .hero-eco { display: none; }
    .login-panel { align-items: flex-start; padding: 1.6rem; }
}

@media (max-width: 620px) {
    .topnav { gap: 0.7rem; }
    .user { display: none; }
    .brand-sub { display: none; }
    .brand-logo { height: 34px; }
    .acciones-carrito { flex-direction: column-reverse; gap: 0.8rem; align-items: stretch; }

    .login-hero { padding: 1.6rem 1.3rem; }
    .hero-logo { margin-bottom: 0.95rem; }
    .hero-logo img { width: 185px; }
    .hero-tagline { font-size: 1.04rem; }
    .hero-desc { font-size: 0.86rem; margin-bottom: 0.95rem; }
    .hero-props { gap: 0.45rem; }
    .hero-props li { font-size: 0.86rem; gap: 0.6rem; }
    .hero-props .ico { width: 1.7rem; height: 1.7rem; font-size: 0.88rem; }
    .login-panel { padding: 1.4rem 1.1rem 2rem; }
    .login-card { padding: 1.8rem 1.6rem 1.4rem; }
}
