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

:root {
    --cream:    #FAF6EF;
    --warm:     #F0E6D0;
    --sand:     #D9C9A8;
    --brown:    #7C5C3A;
    --espresso: #2E1A0E;
    --accent:   #B5470F;
    --green:    #4A6741;
    --text:     #2E1A0E;
    --muted:    #8C7B68;
    --radius:   14px;
}

body {
    background-color: var(--cream);
    /* background dinámico por horario — seteado por app.js */
    background-size: cover;
    background-position: center top;
    background-attachment: fixed;
    color: var(--text);
    font-family: 'DM Sans', sans-serif;
    font-weight: 400;
    min-height: 100vh;
}

body::before {
    content: '';
    position: fixed;
    inset: 0;
    background: rgba(250, 246, 239, 0.20);
    pointer-events: none;
    z-index: 0;
}

/* Grain texture overlay */

header {
    background: transparent;
    color: var(--espresso);
    padding: 2.5rem 1.25rem 2rem;
    text-align: center;
    position: relative;
    overflow: hidden;
}

.logo {
    height: 160px;
    width: auto;
    display: block;
    margin: 0 auto 0.5rem;
}

.tagline {
    font-size: 0.8rem;
    font-weight: bold;
    color: var(--espresso);
    letter-spacing: 0.15em;
    text-transform: uppercase;
    margin-top: 0.4rem;
}

.updated {
    font-size: 0.72rem;
    color: var(--muted);
    margin-top: 0.5rem;
    opacity: 0.8;
}

main {
    position: relative;
    z-index: 1;
    max-width: 640px;
    margin: 0 auto;
    padding: 1.5rem 1rem 4rem;
}

.loading {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--muted);
    font-size: 0.9rem;
}

.spinner {
    width: 32px;
    height: 32px;
    border: 2.5px solid var(--warm);
    border-top-color: var(--brown);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto 1rem;
}

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

.error {
    background: #fff0eb;
    border: 1px solid #f4c4a8;
    border-radius: var(--radius);
    padding: 1.25rem;
    color: var(--accent);
    text-align: center;
    font-size: 0.88rem;
}

/* Categoría acordeón */
.categoria {
    margin-bottom: 0.75rem;
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: 0 1px 4px rgba(46,26,14,0.07);
    animation: fadeUp 0.4s ease both;
}

@keyframes fadeUp {
    from { opacity: 0; transform: translateY(12px); }
    to   { opacity: 1; transform: translateY(0); }
}

.cat-header {
    width: 100%;
    background: var(--espresso);
    color: var(--cream);
    border: none;
    padding: 1rem 1.25rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    text-align: left;
    gap: 0.75rem;
    -webkit-tap-highlight-color: transparent;
}

.cat-header:active { opacity: 0.85; }

.cat-left {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.cat-icon {
    font-size: 1.25rem;
    line-height: 1;
}

.cat-name {
    font-family: 'Playfair Display', serif;
    font-size: 1rem;
    font-weight: 700;
    letter-spacing: 0.01em;
}

.cat-count {
    font-size: 0.72rem;
    color: var(--sand);
    font-weight: 300;
    margin-top: 0.1rem;
}

.cat-chevron {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    transition: transform 0.3s ease;
    opacity: 0.7;
}

.cat-header[aria-expanded="true"] .cat-chevron {
    transform: rotate(180deg);
}

/* Acordeón body */
.cat-body {
    background: white;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.35s ease;
}

.cat-body.open {
    max-height: 9999px;
}

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

/* Fila de producto */
.prod-nombre-row td {
    padding: 0.9rem 1.25rem 0.2rem;
    font-weight: 500;
    font-size: 0.92rem;
    color: var(--espresso);
    border-top: 1px solid var(--warm);
}

.prod-nombre-row:first-child td {
    border-top: none;
}

.prod-grupo-clicable { cursor: pointer; }

.prod-link {
    color: inherit;
    text-decoration: none;
}

tr.prod-grupo-highlight .prod-link {
    color: var(--accent);
    text-decoration: underline;
}

.prod-desc {
    font-size: 0.75rem;
    color: var(--muted);
    font-weight: 300;
    display: block;
    margin-top: 0.1rem;
}

/* Filas de formatos */
.formato-row {
    transition: background-color 0.15s ease;
}

.formato-row td {
    padding: 0.3rem 1.25rem;
    font-size: 0.85rem;
    color: var(--muted);
    transition: color 0.15s ease;
}

.formato-row:last-of-type td {
    padding-bottom: 0.9rem;
}

tr.prod-grupo-highlight td {
    background-color: var(--warm);
    color: var(--espresso);
}

tr.prod-grupo-highlight.formato-row .formato-precio {
    color: var(--accent);
}

.formato-etiqueta {
    width: 60%;
    padding-left: 1.5rem !important;
    position: relative;
}

.formato-etiqueta::before {
    content: '·';
    position: absolute;
    left: 0.75rem;
    color: var(--sand);
}

.formato-precio {
    text-align: right;
    font-weight: 500;
    color: var(--brown);
    font-size: 0.9rem;
    font-variant-numeric: tabular-nums;
}

/* Producto no disponible */
.no-disponible .prod-nombre-row td,
.no-disponible .formato-row td {
    opacity: 0.4;
}

.badge-estado {
    display: inline-block;
    font-size: 0.65rem;
    font-weight: 500;
    border-radius: 4px;
    padding: 0.1rem 0.4rem;
    margin-left: 0.4rem;
    vertical-align: middle;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

.badge-estado--agotado {
    background: var(--warm);
    color: var(--muted);
}

.badge-estado--sin-stock {
    background: #fce8d5;
    color: #a0522d;
}

.badge-estado--a-pedido {
    background: #e8f0e8;
    color: var(--green);
}

footer {
    position: relative;
    z-index: 1;
    text-align: center;
    padding: 1.5rem 1rem 2rem;
    font-size: 0.75rem;
    color: var(--muted);
}

footer strong {
    color: var(--brown);
    font-weight: 500;
}

.footer-links {
    display: flex;
    justify-content: center;
    gap: 1.5rem;
    margin-bottom: 0.75rem;
}

.footer-link {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    color: var(--brown);
    text-decoration: none;
    font-size: 0.8rem;
    font-weight: 500;
    transition: opacity 0.2s;
}

.footer-link:hover { opacity: 0.7; }

.footer-link-icon {
    width: 2rem;
    height: 2rem;
    object-fit: contain;
}