/* ==========================================================================
   Aromas del Alto — sistema de diseño
   Paleta tomada del logo (oliva, ocre, bordó, crema). Para ajustar colores,
   tocar solo las variables de :root.
   ========================================================================== */

:root {
    /* Superficies */
    --bg: #faf7f2;
    --surface: #ffffff;
    --surface-2: #f4efe7;
    --surface-3: #ebe4d8;
    --border: #e7dfd2;
    --border-strong: #d6cbb9;

    /* Texto */
    --text: #2a2118;
    --text-2: #5c5044;
    --muted: #7a6e60;

    /* Marca */
    --primary: #506317;          /* oliva */
    --primary-hover: #435314;
    --primary-soft: #eef2e1;
    --accent: #c67f20;           /* ocre */
    --accent-soft: #fbf1e2;
    --brand-dark: #772715;       /* bordó */

    /* Estados */
    --success: #2f7a32;
    --success-soft: #e9f5e9;
    --danger: #b42318;
    --danger-soft: #fdeceb;
    --warning: #a05a00;
    --warning-soft: #fdf3e2;
    --info: #3b5b7a;
    --info-soft: #e9f0f7;
    --whatsapp: #1fa855;
    --whatsapp-hover: #188f47;

    /* Forma */
    --radius-sm: 10px;
    --radius: 14px;
    --radius-lg: 20px;
    --radius-pill: 999px;
    --shadow-sm: 0 1px 2px rgba(42, 33, 24, 0.06);
    --shadow: 0 2px 8px rgba(42, 33, 24, 0.06), 0 1px 2px rgba(42, 33, 24, 0.04);
    --shadow-lg: 0 12px 32px rgba(42, 33, 24, 0.12);

    /* Tipografía */
    --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --font-display: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;

    /* Layout */
    --header-h: 60px;
    --tabbar-h: 64px;
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    --container: 1120px;
}

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

html { -webkit-text-size-adjust: 100%; scroll-padding-top: calc(var(--header-h) + 80px); }

body {
    font-family: var(--font);
    font-size: 16px;
    line-height: 1.5;
    color: var(--text);
    background: var(--bg);
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    -webkit-font-smoothing: antialiased;
    -webkit-tap-highlight-color: transparent;
}

/* El atributo hidden siempre gana sobre los display de los componentes */
[hidden] { display: none !important; }

img, svg { display: block; max-width: 100%; }
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }

:focus-visible {
    outline: 3px solid color-mix(in srgb, var(--primary) 45%, transparent);
    outline-offset: 2px;
}

.sr-only {
    position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

.container {
    width: 100%;
    max-width: var(--container);
    margin: 0 auto;
    padding: 0 16px;
}

@media (min-width: 640px) {
    .container { padding: 0 24px; }
}

/* ---------- Tipografía ---------- */
.display {
    font-family: var(--font-display);
    font-weight: 600;
    letter-spacing: -0.01em;
    line-height: 1.15;
}

.page-title {
    font-family: var(--font-display);
    font-size: clamp(26px, 5vw, 36px);
    font-weight: 600;
    letter-spacing: -0.01em;
    line-height: 1.15;
}

.page-subtitle { color: var(--muted); font-size: 15px; margin-top: 4px; }

.section-title { font-size: 17px; font-weight: 650; }

.text-muted { color: var(--muted); }

/* ---------- Header ---------- */
.site-header {
    position: sticky;
    top: 0;
    z-index: 100;
    height: var(--header-h);
    background: color-mix(in srgb, var(--bg) 88%, transparent);
    backdrop-filter: saturate(160%) blur(16px);
    -webkit-backdrop-filter: saturate(160%) blur(16px);
    border-bottom: 1px solid var(--border);
}

.site-header .container {
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    min-width: 0;
}

.brand img { height: 34px; width: auto; }

.brand-name {
    font-family: var(--font-display);
    font-size: 19px;
    font-weight: 600;
    letter-spacing: -0.01em;
    white-space: nowrap;
}

.header-nav { display: flex; align-items: center; gap: 4px; }

.header-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 40px;
    padding: 0 12px;
    border-radius: var(--radius-pill);
    font-size: 15px;
    font-weight: 500;
    color: var(--text-2);
    text-decoration: none;
    transition: background 0.15s, color 0.15s;
}

.header-link:hover { background: var(--surface-2); color: var(--text); }
.header-link.is-active { color: var(--primary); }
.header-link svg { width: 20px; height: 20px; }

.header-link--cart {
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text);
}

.badge-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    border-radius: var(--radius-pill);
    background: var(--primary);
    color: #fff;
    font-size: 12px;
    font-weight: 700;
    line-height: 1;
}

.badge-count:empty, .badge-count[data-count="0"] { display: none; }

@keyframes bump { 0%, 100% { transform: scale(1); } 40% { transform: scale(1.35); } }
.bump { animation: bump 0.4s ease; }

@media (max-width: 479px) {
    .brand-name { font-size: 17px; }
    .label-desktop { display: none; }
    .header-link { padding: 0 10px; }
}

/* ---------- Main / footer ---------- */
.main { flex: 1; padding: 20px 0 48px; }

@media (min-width: 640px) {
    .main { padding: 32px 0 64px; }
}

.site-footer {
    border-top: 1px solid var(--border);
    padding: 28px 0 calc(28px + var(--safe-bottom));
    color: var(--muted);
    font-size: 14px;
}

.site-footer .container {
    display: flex;
    flex-wrap: wrap;
    gap: 12px 24px;
    align-items: center;
    justify-content: space-between;
}

.site-footer a { color: var(--text-2); text-decoration: none; }
.site-footer a:hover { color: var(--primary); }
.footer-links { display: flex; gap: 20px; flex-wrap: wrap; }

/* Espacio extra cuando hay barras fijas abajo */
body.has-bottom-bar .site-footer { padding-bottom: calc(96px + var(--safe-bottom)); }

/* ---------- Botones ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 44px;
    padding: 0 18px;
    border: 1px solid transparent;
    border-radius: var(--radius);
    font-size: 15px;
    font-weight: 600;
    line-height: 1.2;
    text-decoration: none;
    white-space: nowrap;
    cursor: pointer;
    user-select: none;
    transition: background 0.15s, border-color 0.15s, color 0.15s, transform 0.1s, box-shadow 0.15s;
}

.btn:active { transform: scale(0.97); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: 0.45; cursor: not-allowed; transform: none; }
.btn svg, .icon-btn svg, .header-link svg { flex-shrink: 0; max-width: none; }
.btn svg { width: 18px; height: 18px; }

.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }

.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border-strong); }
.btn-secondary:hover { background: var(--surface-2); }

.btn-ghost { background: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }

.btn-danger { background: var(--surface); color: var(--danger); border-color: color-mix(in srgb, var(--danger) 30%, transparent); }
.btn-danger:hover { background: var(--danger-soft); }

.btn-whatsapp { background: var(--whatsapp); color: #fff; }
.btn-whatsapp:hover { background: var(--whatsapp-hover); }

.btn-success-soft { background: var(--primary-soft); color: var(--primary); }

.btn-lg { min-height: 52px; font-size: 16px; padding: 0 24px; border-radius: var(--radius); }
.btn-sm { min-height: 36px; font-size: 14px; padding: 0 12px; border-radius: var(--radius-sm); }
.btn-block { width: 100%; }

.icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border-radius: var(--radius-pill);
    border: none;
    background: transparent;
    color: var(--text-2);
    text-decoration: none;
    transition: background 0.15s, color 0.15s;
}

.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn svg { width: 20px; height: 20px; }
.icon-btn--danger:hover { background: var(--danger-soft); color: var(--danger); }

/* ---------- Formularios ---------- */
.field { display: flex; flex-direction: column; gap: 6px; }
.field-label { font-size: 14px; font-weight: 600; color: var(--text); }
.field-help { font-size: 13px; color: var(--muted); }

.form-control {
    width: 100%;
    min-height: 48px;
    padding: 12px 14px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    background: var(--surface);
    font-size: 16px; /* 16px evita el zoom automático en iOS */
    transition: border-color 0.15s, box-shadow 0.15s;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px color-mix(in srgb, var(--primary) 15%, transparent);
}

.form-control::placeholder { color: #a99d8e; }

textarea.form-control { min-height: 96px; resize: vertical; }

select.form-control, .select {
    appearance: none;
    -webkit-appearance: none;
    padding-right: 40px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%237a6e60' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    cursor: pointer;
}

.input-icon { position: relative; }
.input-icon > svg {
    position: absolute; left: 14px; top: 50%; transform: translateY(-50%);
    width: 18px; height: 18px; color: var(--muted); pointer-events: none;
}
.input-icon > .form-control { padding-left: 42px; }

.form-grid { display: grid; gap: 16px; }
@media (min-width: 640px) {
    .form-grid--2 { grid-template-columns: 1fr 1fr; }
    .form-grid--3 { grid-template-columns: 1fr 1fr 1fr; }
}
.form-grid--3-always { display: grid; gap: 10px; grid-template-columns: 1fr 1fr 1fr; }

/* Interruptor (switch) */
.switch {
    position: relative;
    flex-shrink: 0;
    width: 50px;
    height: 30px;
    border: none;
    border-radius: var(--radius-pill);
    background: var(--surface-3);
    transition: background 0.2s;
    padding: 0;
}

.switch::after {
    content: "";
    position: absolute;
    top: 3px;
    left: 3px;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
    transition: transform 0.2s;
}

.switch[aria-checked="true"], input.switch:checked { background: var(--primary); }
.switch[aria-checked="true"]::after, input.switch:checked::after { transform: translateX(20px); }
.switch.is-loading { opacity: 0.6; pointer-events: none; }
input.switch { appearance: none; -webkit-appearance: none; cursor: pointer; }

.toggle-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 14px 16px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
}

/* ---------- Tarjetas / chips / badges ---------- */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
}

.card-pad { padding: 20px; }
@media (min-width: 640px) { .card-pad { padding: 28px; } }

.chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    height: 24px;
    padding: 0 10px;
    border-radius: var(--radius-pill);
    background: var(--surface-2);
    color: var(--text-2);
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
}

.chip--accent { background: var(--accent-soft); color: #8a5512; }
.chip--success { background: var(--success-soft); color: var(--success); }
.chip--danger { background: var(--danger-soft); color: var(--danger); }
.chip--warning { background: var(--warning-soft); color: var(--warning); }

.status-dot {
    display: inline-flex; align-items: center; gap: 6px;
    font-size: 13px; font-weight: 600;
}
.status-dot::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.status-dot--in { color: var(--success); }
.status-dot--out { color: var(--danger); }

/* Filtros tipo pestaña */
.segmented {
    display: flex;
    gap: 6px;
    overflow-x: auto;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
}
.segmented::-webkit-scrollbar { display: none; }

.segmented button, .segmented a {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 36px;
    padding: 0 14px;
    border-radius: var(--radius-pill);
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text-2);
    font-size: 14px;
    font-weight: 600;
    text-decoration: none;
}

.segmented .is-active {
    background: var(--text);
    border-color: var(--text);
    color: #fff;
}

.segmented .count { font-weight: 500; opacity: 0.7; }

/* ---------- Toasts / mensajes ---------- */
.toast-region {
    position: fixed;
    top: calc(var(--header-h) + 10px);
    left: 50%;
    transform: translateX(-50%);
    z-index: 300;
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: min(440px, calc(100% - 24px));
    pointer-events: none;
}

.toast {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 14px;
    border-radius: var(--radius);
    background: var(--text);
    color: #fff;
    font-size: 14px;
    font-weight: 500;
    box-shadow: var(--shadow-lg);
    pointer-events: auto;
    animation: toast-in 0.25s ease;
}

.toast::before {
    content: "";
    flex-shrink: 0;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #9fc36a;
}

.toast--error::before { background: #ff8a80; }
.toast--warning::before { background: #ffc266; }
.toast--info::before { background: #9cc3e6; }
.toast.is-leaving { animation: toast-out 0.25s ease forwards; }
.toast-text { flex: 1; }
.toast-close {
    background: none; border: none; color: rgba(255,255,255,0.7);
    font-size: 20px; line-height: 1; padding: 0 2px;
}

@keyframes toast-in { from { opacity: 0; transform: translateY(-8px); } }
@keyframes toast-out { to { opacity: 0; transform: translateY(-8px); } }

/* ---------- Estado vacío ---------- */
.empty-state {
    text-align: center;
    padding: 48px 20px;
    color: var(--muted);
}
.empty-state svg { width: 56px; height: 56px; margin: 0 auto 16px; color: var(--border-strong); }
.empty-state h2, .empty-state h3 { color: var(--text); font-size: 20px; margin-bottom: 6px; }
.empty-state p { margin-bottom: 20px; }

/* ==========================================================================
   Catálogo
   ========================================================================== */

.hero {
    display: grid;
    gap: 20px;
    align-items: center;
    margin-bottom: 20px;
}

.hero-banner { max-height: 96px; width: auto; margin: 0 auto; }

.hero-text { text-align: center; }
.hero-text p { color: var(--text-2); max-width: 520px; margin: 6px auto 0; }

.steps {
    list-style: none;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    max-width: 640px;
    margin: 0 auto;
    width: 100%;
}

.steps li {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 12px 8px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 13px;
    line-height: 1.3;
    color: var(--text-2);
    text-align: center;
}

.steps .step-num {
    display: inline-flex; align-items: center; justify-content: center;
    width: 26px; height: 26px; border-radius: 50%;
    background: var(--primary-soft); color: var(--primary);
    font-size: 13px; font-weight: 700;
}

@media (min-width: 900px) {
    .hero { grid-template-columns: auto 1fr; gap: 40px; margin-bottom: 28px; text-align: left; }
    .hero-banner { max-height: 150px; margin: 0; }
    .hero-text { text-align: left; }
    .hero-text p { margin-left: 0; }
    .steps { margin: 16px 0 0; }
    .steps li { flex-direction: row; text-align: left; padding: 12px; }
}

/* Barra de búsqueda fija */
.catalog-toolbar {
    position: sticky;
    top: var(--header-h);
    z-index: 50;
    margin: 0 -16px 16px;
    padding: 10px 16px;
    background: color-mix(in srgb, var(--bg) 92%, transparent);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

@media (min-width: 640px) {
    .catalog-toolbar { margin: 0 -24px 20px; padding: 12px 24px; }
}

.catalog-toolbar .search-row { display: flex; align-items: center; gap: 12px; }
.catalog-toolbar .input-icon { flex: 1; }
.catalog-toolbar .form-control { border-radius: var(--radius-pill); background: var(--surface); }
.result-count { font-size: 13px; color: var(--muted); white-space: nowrap; }

/* Grilla de productos */
.product-grid {
    display: grid;
    gap: 12px;
    grid-template-columns: 1fr;
}

@media (min-width: 760px) {
    .product-grid { grid-template-columns: 1fr 1fr; gap: 16px; }
}

@media (min-width: 1100px) {
    .product-grid { grid-template-columns: 1fr 1fr 1fr; }
}

.product-card {
    display: flex;
    flex-direction: column;
    gap: 14px;
    padding: 16px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    transition: box-shadow 0.2s, border-color 0.2s;
}

.product-card:hover { box-shadow: var(--shadow); border-color: var(--border-strong); }
.product-card.is-in-cart { border-color: color-mix(in srgb, var(--primary) 45%, var(--border)); }

.product-card__body { flex: 1; min-width: 0; }

.product-card__title {
    font-size: 17px;
    font-weight: 650;
    line-height: 1.3;
    color: var(--text);
}

.product-card__meta { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.product-card__meta:empty { display: none; }

.product-card__desc {
    margin-top: 6px;
    font-size: 14px;
    line-height: 1.45;
    color: var(--muted);
}

.product-card__footer {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding-top: 14px;
    border-top: 1px solid var(--surface-2);
}

.price { display: flex; flex-direction: column; line-height: 1.15; min-width: 0; }
.price-value { font-size: 20px; font-weight: 700; letter-spacing: -0.01em; font-variant-numeric: tabular-nums; }
.price-unit { font-size: 13px; color: var(--muted); white-space: nowrap; }

.add-form { display: flex; align-items: center; gap: 8px; margin-left: auto; }

.qty-select {
    height: 44px;
    min-width: 92px;
    padding: 0 34px 0 12px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    background-color: var(--surface-2);
    font-size: 15px;
    font-weight: 600;
    background-position: right 10px center;
}

.qty-fixed {
    display: inline-flex; align-items: center;
    height: 44px; padding: 0 12px;
    border-radius: var(--radius-sm);
    background: var(--surface-2);
    font-size: 15px; font-weight: 600; color: var(--text-2);
}

.btn-add { min-width: 108px; }
.btn-add .when-in-cart { display: none; }
.is-in-cart .btn-add { background: var(--primary-soft); color: var(--primary); }
.is-in-cart .btn-add .when-in-cart { display: inline-flex; align-items: center; gap: 6px; }
.is-in-cart .btn-add .when-not-in-cart { display: none; }
.btn-add .when-dirty { display: none; }
.is-in-cart.is-dirty .btn-add { background: var(--primary); color: #fff; }
.is-in-cart.is-dirty .btn-add .when-in-cart { display: none; }
.is-in-cart.is-dirty .btn-add .when-dirty { display: inline; }

.product-card.is-out { background: var(--surface-2); box-shadow: none; }
.product-card.is-out .product-card__title { color: var(--text-2); }
.product-card.is-out .price-value { color: var(--muted); }

@media (max-width: 380px) {
    .product-card__footer { flex-direction: column; align-items: stretch; }
    .add-form { margin-left: 0; }
    .add-form .btn-add { flex: 1; }
}

@media (min-width: 1100px) {
    /* Tarjetas angostas: precio arriba, selector + botón abajo a todo el ancho */
    .product-card__footer { flex-direction: column; align-items: stretch; }
    .product-card__footer .price { flex-direction: row; align-items: baseline; gap: 6px; }
    .add-form { margin-left: 0; }
    .add-form .qty-select, .add-form .qty-fixed { flex: 1; }
    .add-form .btn-add { flex: 1.4; }
}

/* Barra fija "Ver carrito" (mobile) / botón flotante (desktop) */
.cart-bar {
    position: fixed;
    left: 12px;
    right: 12px;
    bottom: calc(12px + var(--safe-bottom));
    z-index: 90;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    min-height: 56px;
    padding: 0 8px 0 18px;
    border-radius: var(--radius-lg);
    background: var(--text);
    color: #fff;
    text-decoration: none;
    font-weight: 600;
    box-shadow: var(--shadow-lg);
    transform: translateY(0);
    transition: transform 0.3s ease, opacity 0.3s ease;
}

.cart-bar[hidden] {
    display: flex !important; /* se anima en lugar de desaparecer de golpe */
    transform: translateY(150%);
    opacity: 0;
    visibility: hidden; /* no enfocable con teclado mientras está oculta */
    pointer-events: none;
    transition: transform 0.3s ease, opacity 0.3s ease, visibility 0s linear 0.3s;
}
.cart-bar .cart-bar__cta {
    display: inline-flex; align-items: center; gap: 6px;
    height: 40px; padding: 0 14px; border-radius: var(--radius);
    background: var(--primary); font-size: 15px;
}
.cart-bar .cart-bar__cta svg { width: 18px; height: 18px; }

@media (min-width: 760px) {
    .cart-bar { left: auto; right: 24px; bottom: 24px; min-width: 300px; }
}

/* ==========================================================================
   Carrito
   ========================================================================== */

.cart-header { margin-bottom: 20px; }

.cart-layout { display: grid; gap: 16px; align-items: start; }

@media (min-width: 900px) {
    .cart-layout { grid-template-columns: 1fr 340px; gap: 24px; }
    .cart-summary { position: sticky; top: calc(var(--header-h) + 20px); }
}

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

.cart-item {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 12px 16px;
    padding: 16px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
}

.cart-item__name { font-size: 16px; font-weight: 650; line-height: 1.3; }
.cart-item__unit { font-size: 13px; color: var(--muted); margin-top: 2px; }
.cart-item__price { font-size: 17px; font-weight: 700; text-align: right; font-variant-numeric: tabular-nums; }

.cart-item > div:first-child { grid-column: 1; grid-row: 1; min-width: 0; }
.cart-item__price { grid-column: 2; grid-row: 1; }

.cart-item__controls {
    grid-column: 1 / -1;
    grid-row: 2;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

@media (min-width: 560px) {
    .cart-item { grid-template-columns: 1fr auto auto; align-items: center; }
    .cart-item__controls { grid-column: 2; grid-row: 1; }
    .cart-item__price { grid-column: 3; grid-row: 1; min-width: 84px; }
}

.stepper {
    display: inline-flex;
    align-items: center;
    background: var(--surface-2);
    border-radius: var(--radius-pill);
    padding: 3px;
}

.stepper button {
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 50%;
    background: var(--surface);
    box-shadow: var(--shadow-sm);
    font-size: 20px;
    font-weight: 500;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.1s, opacity 0.15s;
}

.stepper button:active { transform: scale(0.92); }
.stepper button:disabled { opacity: 0.35; cursor: not-allowed; box-shadow: none; }
.stepper-value {
    min-width: 72px;
    text-align: center;
    font-size: 15px;
    font-weight: 650;
    font-variant-numeric: tabular-nums;
}

.cart-summary { padding: 20px; }
.summary-row { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.summary-total { font-size: 28px; font-weight: 750; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.summary-note { font-size: 13px; color: var(--muted); margin: 8px 0 18px; }
.summary-actions { display: flex; flex-direction: column; gap: 10px; }
.summary-secondary { display: flex; gap: 10px; }
.summary-secondary .btn { flex: 1; }

/* Barra de checkout fija en mobile */
.checkout-bar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 90;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px calc(12px + var(--safe-bottom));
    background: color-mix(in srgb, var(--surface) 94%, transparent);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-top: 1px solid var(--border);
}

.checkout-bar__total { display: flex; flex-direction: column; line-height: 1.15; }
.checkout-bar__total small { font-size: 12px; color: var(--muted); }
.checkout-bar__total strong { font-size: 20px; font-variant-numeric: tabular-nums; }
.checkout-bar .btn { flex: 1; }

@media (min-width: 900px) {
    .checkout-bar { display: none; }
}

@media (max-width: 899px) {
    .cart-summary .btn-whatsapp { display: none; }
}

.is-updating { opacity: 0.6; transition: opacity 0.15s; }

/* ==========================================================================
   Autenticación
   ========================================================================== */

.auth-wrap { max-width: 420px; margin: 16px auto 0; }
@media (min-width: 640px) { .auth-wrap { margin-top: 48px; } }
.auth-head { text-align: center; margin-bottom: 24px; }
.auth-head img { height: 56px; width: auto; margin: 0 auto 12px; }
.auth-form { display: flex; flex-direction: column; gap: 16px; }
.auth-foot {
    margin-top: 24px; padding-top: 20px;
    border-top: 1px solid var(--border);
    text-align: center; font-size: 14px; color: var(--muted);
    display: flex; flex-direction: column; gap: 10px;
}
.auth-foot a { color: var(--primary); font-weight: 600; text-decoration: none; }
.auth-foot a.link-muted { color: var(--muted); font-weight: 500; }

/* ==========================================================================
   Panel de administración
   ========================================================================== */

body.is-admin .main { padding-top: 0; }

.admin-shell { padding-top: 16px; }
@media (min-width: 640px) { .admin-shell { padding-top: 28px; } }

.admin-tabs {
    display: none;
    gap: 4px;
    padding: 4px;
    margin-bottom: 24px;
    background: var(--surface-2);
    border-radius: var(--radius);
    width: fit-content;
}

.admin-tabs a {
    display: inline-flex; align-items: center; gap: 8px;
    height: 40px; padding: 0 16px;
    border-radius: var(--radius-sm);
    color: var(--text-2);
    font-size: 14px; font-weight: 600;
    text-decoration: none;
}

.admin-tabs a svg { width: 18px; height: 18px; }
.admin-tabs a:hover { color: var(--text); }
.admin-tabs a.is-active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }

@media (min-width: 760px) {
    .admin-tabs { display: flex; }
}

.admin-page-head {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 16px;
}

.admin-page-head .actions { display: flex; gap: 8px; flex-shrink: 0; }

/* Barra de pestañas inferior (mobile) */
.tabbar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 95;
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    height: calc(var(--tabbar-h) + var(--safe-bottom));
    padding-bottom: var(--safe-bottom);
    background: color-mix(in srgb, var(--surface) 94%, transparent);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-top: 1px solid var(--border);
}

.tabbar a {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    color: var(--muted);
    font-size: 11px;
    font-weight: 600;
    text-decoration: none;
}

.tabbar a svg { width: 24px; height: 24px; }
.tabbar a.is-active { color: var(--primary); }

.tabbar .tab-new span.tab-new-icon {
    display: flex; align-items: center; justify-content: center;
    width: 44px; height: 44px; margin-top: -4px;
    border-radius: 50%;
    background: var(--primary); color: #fff;
    box-shadow: 0 4px 12px color-mix(in srgb, var(--primary) 40%, transparent);
}
.tabbar .tab-new span.tab-new-icon svg { width: 22px; height: 22px; }

body.is-admin { padding-bottom: calc(var(--tabbar-h) + var(--safe-bottom)); }
body.is-admin .site-footer { display: none; }

@media (min-width: 760px) {
    .tabbar { display: none; }
    body.is-admin { padding-bottom: 0; }
}

/* Dashboard */
.stat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 20px; }
.stat {
    padding: 14px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    text-decoration: none;
}
.stat-value { font-size: 26px; font-weight: 750; letter-spacing: -0.02em; line-height: 1.1; font-variant-numeric: tabular-nums; }
.stat-label { font-size: 12px; font-weight: 600; color: var(--muted); margin-top: 2px; }
.stat--success .stat-value { color: var(--success); }
.stat--danger .stat-value { color: var(--danger); }
.stat--warning .stat-value { color: var(--warning); }

@media (min-width: 640px) {
    .stat { padding: 20px; }
    .stat-value { font-size: 32px; }
    .stat-label { font-size: 13px; }
}

.stat-grid--4 { grid-template-columns: repeat(2, 1fr); }
@media (min-width: 640px) { .stat-grid--4 { grid-template-columns: repeat(4, 1fr); } }

.quick-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 24px; }
@media (min-width: 640px) { .quick-actions { grid-template-columns: repeat(4, 1fr); } }

.quick-action {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 16px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    text-decoration: none;
    font-size: 14px;
    font-weight: 600;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.quick-action:hover { border-color: var(--border-strong); box-shadow: var(--shadow); }
.quick-action .qa-icon {
    display: flex; align-items: center; justify-content: center;
    width: 40px; height: 40px; border-radius: var(--radius-sm);
    background: var(--primary-soft); color: var(--primary);
}
.quick-action .qa-icon svg { width: 22px; height: 22px; }
.quick-action--accent .qa-icon { background: var(--accent-soft); color: var(--accent); }
.quick-action--info .qa-icon { background: var(--info-soft); color: var(--info); }
.quick-action--warning .qa-icon { background: var(--warning-soft); color: var(--warning); }

/* Toolbar de productos */
.admin-toolbar {
    position: sticky;
    top: var(--header-h);
    z-index: 40;
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin: 0 -16px 12px;
    padding: 10px 16px;
    background: color-mix(in srgb, var(--bg) 94%, transparent);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

@media (min-width: 640px) {
    .admin-toolbar { margin: 0 -24px 16px; padding: 12px 24px; }
}

@media (min-width: 900px) {
    .admin-toolbar { flex-direction: row; align-items: center; }
    .admin-toolbar .input-icon { flex: 1; max-width: 420px; }
}

/* Lista de productos del admin */
.admin-list {
    list-style: none;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.admin-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 8px 12px 16px;
    border-bottom: 1px solid var(--surface-2);
}

.admin-item:last-child { border-bottom: none; }
.admin-item.is-out .admin-item__name { color: var(--muted); }

.admin-item__main {
    flex: 1;
    min-width: 0;
    text-decoration: none;
    display: block;
    padding: 2px 0;
}

.admin-item__name {
    font-size: 15px;
    font-weight: 650;
    line-height: 1.3;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.admin-item__meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px 10px;
    margin-top: 3px;
    font-size: 13px;
    color: var(--muted);
}

.admin-item__price { color: var(--text); font-weight: 600; font-variant-numeric: tabular-nums; }

.admin-item__stock { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.admin-item__stock-label { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); }

@media (min-width: 760px) {
    .admin-item { padding: 14px 12px 14px 20px; gap: 20px; }
    .admin-item__meta { font-size: 13px; }
}

/* Formulario de producto */
.form-card { display: flex; flex-direction: column; gap: 18px; }

.form-section-title {
    font-size: 13px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--muted);
}

.details {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
}

.details summary {
    display: flex; align-items: center; justify-content: space-between;
    padding: 14px 16px;
    font-size: 15px; font-weight: 600;
    cursor: pointer;
    list-style: none;
}
.details summary::-webkit-details-marker { display: none; }
.details summary::after {
    content: "";
    width: 10px; height: 10px;
    border-right: 2px solid var(--muted);
    border-bottom: 2px solid var(--muted);
    transform: rotate(45deg) translateY(-3px);
    transition: transform 0.2s;
}
.details[open] summary::after { transform: rotate(-135deg) translateY(-3px); }
.details-body { padding: 0 16px 16px; display: flex; flex-direction: column; gap: 12px; }

.form-actions {
    position: sticky;
    bottom: calc(var(--tabbar-h) + var(--safe-bottom));
    z-index: 30;
    display: flex;
    gap: 10px;
    margin: 20px -16px 0;
    padding: 12px 16px;
    background: color-mix(in srgb, var(--bg) 94%, transparent);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-top: 1px solid var(--border);
}

.form-actions .btn-primary { flex: 2; }
.form-actions .btn-secondary { flex: 1; }

@media (min-width: 760px) {
    .form-actions { position: static; margin: 24px 0 0; padding: 0; background: none; border: none; backdrop-filter: none; }
}

.danger-zone {
    margin-top: 32px;
    padding: 16px;
    border: 1px solid color-mix(in srgb, var(--danger) 25%, transparent);
    border-radius: var(--radius);
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.danger-zone p { font-size: 14px; color: var(--muted); }

.narrow { max-width: 640px; margin: 0 auto; }

.back-link {
    display: inline-flex; align-items: center; gap: 4px;
    margin-bottom: 8px;
    color: var(--primary); font-size: 14px; font-weight: 600;
    text-decoration: none;
}
.back-link svg { width: 18px; height: 18px; }

/* Seguridad */
.log-list {
    list-style: none;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.log-item {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 4px 12px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--surface-2);
    font-size: 14px;
}
.log-item:last-child { border-bottom: none; }
.log-item__who { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.log-item__sub { font-size: 12px; color: var(--muted); grid-column: 1 / -1; }

.log-head {
    display: flex; justify-content: space-between; align-items: baseline; gap: 12px;
    margin-bottom: 10px;
}

.pagination {
    display: flex; justify-content: center; align-items: center; gap: 8px;
    margin-top: 20px;
    font-size: 14px; color: var(--muted);
}

/* Log de actividad */
.log-filters { margin-bottom: 16px; }
.log-filters summary .chip { margin-left: 8px; margin-right: auto; }

.activity-list {
    list-style: none;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    /* Sin overflow: hidden, que rompería el encabezado de fecha fijo (sticky) */
}
.activity-list > :first-child { border-top-left-radius: inherit; border-top-right-radius: inherit; }
.activity-list > :last-child { border-bottom-left-radius: inherit; border-bottom-right-radius: inherit; }

.activity-day {
    position: sticky;
    top: var(--header-h);
    z-index: 5;
    padding: 6px 16px;
    background: var(--surface-2);
    border-bottom: 1px solid var(--border);
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.03em;
    color: var(--text-2);
}

.activity-item {
    padding: 12px 16px;
    border-bottom: 1px solid var(--surface-2);
    font-size: 14px;
}
.activity-item:last-child { border-bottom: none; }

.activity-head { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 10px; }
.activity-target {
    flex: 1;
    min-width: 0;
    font-weight: 650;
    color: var(--text);
    text-decoration: none;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
a.activity-target:hover { color: var(--primary); text-decoration: underline; }
.activity-time { margin-left: auto; font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }

.activity-changes {
    list-style: none;
    margin: 8px 0 0;
    padding: 8px 12px;
    background: var(--surface-2);
    border-radius: var(--radius-sm);
    display: flex;
    flex-direction: column;
    gap: 2px;
    font-size: 13px;
    overflow-wrap: anywhere;
}
.activity-changes del { color: var(--muted); }

.activity-meta { margin-top: 6px; font-size: 12px; color: var(--muted); }
.activity-meta summary { cursor: pointer; list-style: none; width: fit-content; }
.activity-meta summary::-webkit-details-marker { display: none; }
.activity-meta summary::after { content: " ▸"; }
.activity-meta[open] summary::after { content: " ▾"; }
.activity-meta dl {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 2px 12px;
    margin-top: 6px;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    overflow-wrap: anywhere;
}
.activity-meta dt { font-weight: 600; color: var(--text-2); }

.section-head {
    display: flex; justify-content: space-between; align-items: baseline; gap: 12px;
    margin: 28px 0 10px;
}
.section-head a { font-size: 14px; font-weight: 600; color: var(--primary); text-decoration: none; }

/* Lista simple (sin stock en dashboard) */
.simple-list {
    list-style: none;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
}
.simple-list li {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    padding: 10px 12px 10px 16px;
    border-bottom: 1px solid var(--surface-2);
    font-size: 15px;
}
.simple-list li:last-child { border-bottom: none; }

/* Movimiento reducido */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
