:root {
    --bg: #f4f7f1;
    --surface: #ffffff;
    --surface-2: #f9fcf7;
    --surface-3: #eef6ef;
    --text: #1b2a22;
    --muted: #5d6d63;
    --line: rgba(25, 68, 42, 0.12);
    --line-strong: rgba(25, 68, 42, 0.2);
    --primary: #0d7a43;
    --primary-strong: #085f34;
    --accent: #ef9a1a;
    --danger: #c83d3d;
    --shadow: 0 12px 30px rgba(11, 47, 26, 0.1);
    --shadow-soft: 0 8px 20px rgba(11, 47, 26, 0.08);
    --radius-md: 18px;
    --radius-lg: 24px;
    --max-width: 1380px;
    --font-ui: "Segoe UI", Arial, sans-serif;
}

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

html {
    scroll-behavior: smooth;
}

body {
    margin: 0;
    font-family: var(--font-ui);
    color: var(--text);
    background:
        radial-gradient(circle at top left, rgba(110, 201, 139, 0.22), transparent 24rem),
        radial-gradient(circle at top right, rgba(255, 210, 135, 0.2), transparent 22rem),
        linear-gradient(180deg, #f8fbf6 0%, var(--bg) 100%);
}

img {
    max-width: 100%;
    display: block;
}

button,
input,
textarea {
    font: inherit;
}

button {
    cursor: pointer;
}

.app-shell {
    min-height: 100vh;
    padding-bottom: 6rem;
}

.app-header {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 1rem 1rem 0;
}

/* ── STICKY MODE BAR ────────────────────────────────── */
.mode-bar {
    position: sticky;
    top: 0;
    z-index: 20;
    background: rgba(12, 122, 67, 0.97);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    box-shadow: 0 2px 10px rgba(11, 47, 26, 0.18);
}

.mode-bar__inner {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 0.55rem 1rem;
}

.header-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 0.85rem;
    text-decoration: none;
    color: inherit;
    min-width: 0;
}

.brand-logo {
    width: 2.75rem;
    height: 2.75rem;
    padding: 0.45rem;
    border-radius: 0.95rem;
    background: linear-gradient(180deg, #ffffff 0%, #edf7ef 100%);
    box-shadow: var(--shadow-soft);
}

.brand-copy {
    min-width: 0;
}

.brand-eyebrow,
.section-label,
.hero-kicker {
    display: block;
    font-size: 0.74rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--primary);
    font-weight: 700;
}

.brand-title {
    display: block;
    font-size: 1rem;
    line-height: 1.2;
}

.header-cart-button {
    display: inline-flex;
    align-items: center;
    gap: 0.55rem;
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.9);
    color: var(--text);
    padding: 0.8rem 0.95rem;
    border-radius: 999px;
    box-shadow: var(--shadow-soft);
}

.header-cart-button__text {
    font-weight: 700;
}

.header-cart-button__badge {
    display: inline-grid;
    place-items: center;
    min-width: 1.4rem;
    height: 1.4rem;
    padding: 0 0.3rem;
    border-radius: 999px;
    background: var(--danger);
    color: #fff;
    font-size: 0.72rem;
    font-weight: 800;
}

.hero-panel {
    display: grid;
    gap: 1rem;
    margin-top: 1rem;
    padding: 1.15rem;
    background: linear-gradient(135deg, rgba(12, 122, 67, 0.97), rgba(9, 97, 53, 0.93));
    color: #fff;
    border-radius: var(--radius-lg);
    box-shadow: 0 16px 40px rgba(11, 47, 26, 0.2);
}

.hero-panel h1 {
    margin: 0.35rem 0 0.45rem;
    font-size: clamp(1.7rem, 3.4vw, 2.6rem);
    line-height: 1.05;
}

.hero-description {
    margin: 0;
    max-width: 46rem;
    color: rgba(255, 255, 255, 0.9);
    line-height: 1.45;
}

.hero-controls,
.search-field,
.form-field,
.cart-actions,
.modal__body {
    display: grid;
    gap: 0.5rem;
}

.search-field__label,
.form-field span {
    font-size: 0.86rem;
    font-weight: 700;
}

.search-field input,
.form-field input,
.form-field textarea {
    width: 100%;
    border: 1px solid rgba(255, 255, 255, 0.18);
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
    padding: 0.95rem 1rem;
    border-radius: 1rem;
    outline: none;
}

.search-field input::placeholder,
.form-field input::placeholder,
.form-field textarea::placeholder {
    color: rgba(255, 255, 255, 0.72);
}

.mode-switcher {
    display: flex;
    gap: 0.5rem;
    overflow-x: auto;
    padding-bottom: 0.2rem;
    scrollbar-width: none;
}

.mode-switcher::-webkit-scrollbar {
    display: none;
}

.mode-chip {
    border: none;
    border-radius: 999px;
    padding: 0.8rem 1rem;
    min-width: max-content;
    background: rgba(255, 255, 255, 0.12);
    color: rgba(255, 255, 255, 0.86);
}

.mode-chip strong,
.mode-chip span,
.mobile-cart-bar strong,
.mobile-cart-bar small {
    display: block;
}

.mode-chip strong {
    font-size: 0.95rem;
}

.mode-chip span {
    font-size: 0.73rem;
    opacity: 0.8;
}

/* Colores inactivos por modo (sobre fondo verde oscuro) */
.mode-chip[data-mode-id="publico"] { background: rgba(148, 163, 184, 0.22); }
.mode-chip[data-mode-id="0"]       { background: rgba(99,  202, 183, 0.22); }
.mode-chip[data-mode-id="5"]       { background: rgba(250, 204,  21, 0.22); }
.mode-chip[data-mode-id="8"]       { background: rgba(251, 146,  60, 0.22); }
.mode-chip[data-mode-id="15"]      { background: rgba(248, 113, 113, 0.22); }

/* Colores activos por modo */
.mode-chip.is-active                          { background: #fff; color: var(--primary); }
.mode-chip.is-active[data-mode-id="publico"]  { background: #e2e8f0; color: #334155; }
.mode-chip.is-active[data-mode-id="0"]        { background: #ccfbf1; color: #0f766e; }
.mode-chip.is-active[data-mode-id="5"]        { background: #fef9c3; color: #854d0e; }
.mode-chip.is-active[data-mode-id="8"]        { background: #ffedd5; color: #9a3412; }
.mode-chip.is-active[data-mode-id="15"]       { background: #fee2e2; color: #991b1b; }

.layout {
    max-width: var(--max-width);
    margin: 1rem auto 0;
    padding: 0 1rem;
    display: grid;
    gap: 1rem;
}

.catalog-section,
.cart-panel,
.modal__dialog {
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(10px);
}

.catalog-section {
    padding: 1rem;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
}

.section-heading {
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 0.85rem;
}

.section-heading h2,
.cart-panel__header h2,
.modal__header h2 {
    margin: 0.08rem 0 0;
    font-size: 0.95rem;
}

.section-meta,
.status-banner,
.cart-row__meta,
.cart-row__code,
.mobile-cart-bar small {
    color: var(--muted);
}

.promo-strip,
.cart-list,
.cart-bonuses {
    display: grid;
    gap: 0.4rem;
}

.promo-card,
.product-card,
.cart-row,
.cart-bonus-card,
.cart-totals {
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    background: linear-gradient(180deg, var(--surface) 0%, var(--surface-2) 100%);
    box-shadow: var(--shadow-soft);
}

/* ── COLUMNA CATALOGO (promos + productos apilados) ── */
.catalog-column {
    display: grid;
    gap: 1rem;
}

/* ── CARD PROMOCIONES ─────────────────────────────── */
.promos-section {
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(10px);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.promos-section__header {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 1rem;
    background: none;
    border: none;
    text-align: left;
    cursor: pointer;
}

.promos-section__header:hover {
    background: var(--surface-3);
}

.promos-section__title {
    display: block;
    font-size: 1.05rem;
    margin-top: 0.12rem;
    color: var(--text);
}

.promos-toggle-right {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.84rem;
    font-weight: 700;
    color: var(--primary);
    white-space: nowrap;
    flex-shrink: 0;
}

.promos-toggle__arrow {
    font-size: 0.65rem;
    transition: transform 0.2s ease;
}

.promos-section__header[aria-expanded="true"] .promos-toggle__arrow {
    transform: rotate(90deg);
}

.promo-strip {
    padding: 0 1rem 1rem;
    display: grid;
    gap: 0.75rem;
}

.promo-strip.is-collapsed {
    display: none;
}

.promo-card {
    padding: 1rem;
    text-align: left;
}

.promo-card__title,
.product-card__title,
.cart-row__title,
.cart-bonus-card p {
    margin: 0;
}

.promo-card__description {
    margin: 0.5rem 0 0;
    line-height: 1.45;
    font-size: 0.93rem;
}

.promo-card__hint {
    margin-top: 0.65rem;
    font-size: 0.82rem;
    color: var(--primary);
    font-weight: 700;
}

.product-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.8rem;
}

.product-card {
    display: grid;
    overflow: hidden;
    cursor: pointer;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    transition: transform 0.1s ease, box-shadow 0.1s ease;
}

.product-card:active {
    transform: scale(0.97);
    box-shadow: none;
}

.product-card.in-cart {
    border-color: rgba(13, 122, 67, 0.35);
    box-shadow: 0 0 0 2px rgba(13, 122, 67, 0.15), var(--shadow-soft);
}

.product-card__media {
    position: relative;
    aspect-ratio: 1 / 1;
    display: grid;
    place-items: center;
    padding: 1rem;
    background: radial-gradient(circle at top, rgba(255, 255, 255, 0.95), rgba(237, 246, 239, 0.9));
}

.product-card__media img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.product-badge,
.product-qty-badge,
.product-promo,
.cart-mode-pill,
.cart-bonus-card__label {
    position: absolute;
    padding: 0.3rem 0.55rem;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 800;
}

.product-badge {
    top: 0.65rem;
    left: 0.65rem;
    background: rgba(13, 122, 67, 0.95);
    color: #fff;
}

.product-qty-badge {
    top: 0.65rem;
    right: 0.65rem;
    background: rgba(239, 154, 26, 0.95);
    color: #2a1903;
}

.product-promo {
    top: auto;
    bottom: 0.65rem;
    right: 0.65rem;
    background: rgba(255, 255, 255, 0.96);
    border: 1px solid rgba(239, 154, 26, 0.35);
}

.product-card__body {
    display: grid;
    gap: 0.4rem;
    padding: 0.75rem;
}

.product-card__title {
    font-size: 0.95rem;
    line-height: 1.35;
    min-height: 2.55rem;
}

.product-card__pricing {
    display: grid;
    gap: 0.2rem;
}

.product-card__price {
    font-size: 1.06rem;
    font-weight: 800;
    color: #9a5d00;
}

.product-card__pv {
    font-size: 0.84rem;
    color: #3f5fd7;
}

.button,
.qty-control,
.drawer-close,
.phone-prefix {
    border-radius: 0.95rem;
}

.button {
    border: 1px solid transparent;
    padding: 0.65rem 1rem;
    font-weight: 800;
    font-size: 0.9rem;
}

.button--primary {
    background: linear-gradient(180deg, #26c565 0%, #16a34a 100%);
    color: #fff;
}

.button--ghost {
    background: #fff;
    border-color: var(--line);
    color: var(--text);
}

.qty-control {
    display: grid;
    grid-template-columns: 2rem 1fr 2rem;
    align-items: center;
    border: 1px solid rgba(13, 122, 67, 0.2);
    background: #f1f8f2;
    overflow: hidden;
}

.qty-button {
    border: none;
    background: transparent;
    color: var(--primary);
    font-size: 1rem;
    font-weight: 900;
    min-height: 2.1rem;
}

.qty-value {
    text-align: center;
    font-weight: 800;
    font-size: 0.88rem;
}

.empty-state {
    padding: 1.2rem;
    border: 1px dashed var(--line-strong);
    border-radius: var(--radius-md);
    text-align: center;
    color: var(--muted);
    background: rgba(255, 255, 255, 0.55);
}

.cart-panel {
    position: fixed;
    inset: auto 0 0 0;
    z-index: 40;
    display: grid;
    gap: 0.6rem;
    padding: 0.75rem;
    border-radius: 1.3rem 1.3rem 0 0;
    transform: translateY(105%);
    transition: transform 0.22s ease;
    max-height: 84vh;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    box-shadow: 0 -16px 36px rgba(11, 47, 26, 0.2);
}

.cart-panel.is-open {
    transform: translateY(0);
}

.cart-panel__header,
.modal__header,
.cart-row__top,
.total-line,
.mobile-cart-bar {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
}

.drawer-close {
    border: 1px solid var(--line);
    background: #fff;
    width: 2.2rem;
    height: 2.2rem;
}

.cart-row {
    padding: 0.55rem 0.7rem;
    display: grid;
    gap: 0.4rem;
}

.cart-row__title {
    font-size: 0.82rem;
    line-height: 1.3;
}

.cart-row__total {
    font-weight: 800;
    white-space: nowrap;
    font-size: 0.88rem;
}

.cart-bonus-card {
    padding: 0.55rem 0.7rem;
    background: linear-gradient(180deg, #f7fff8 0%, #eef8f0 100%);
}

.cart-bonus-card__label,
.cart-mode-pill {
    position: static;
    display: inline-block;
}

.cart-bonus-card__label {
    background: rgba(13, 122, 67, 0.12);
    color: var(--primary);
    margin-bottom: 0.45rem;
}

.cart-totals {
    padding: 0.6rem 0.7rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
}

.total-main {
    display: flex;
    align-items: baseline;
    gap: 0.35rem;
    flex-wrap: wrap;
}

.total-main__label {
    font-size: 0.72rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    color: var(--muted);
    text-transform: uppercase;
}

.total-main__amount {
    font-size: 1.35rem;
    font-weight: 900;
    color: var(--primary-strong);
    line-height: 1;
}

.total-main__pv {
    font-size: 0.8rem;
    font-weight: 700;
    color: #3f5fd7;
}

.cart-mode-pill {
    justify-self: start;
    background: var(--surface-3);
    color: var(--primary-strong);
    font-size: 0.78rem;
}

.mobile-cart-bar {
    position: fixed;
    left: 1rem;
    right: 1rem;
    bottom: 1rem;
    z-index: 35;
    align-items: center;
    border: 1px solid rgba(13, 122, 67, 0.16);
    border-radius: 1.2rem;
    padding: 0.95rem 1rem;
    background: rgba(255, 255, 255, 0.94);
    box-shadow: var(--shadow);
}

.mobile-cart-bar__cta {
    font-weight: 800;
    color: var(--primary);
}

body.has-drawer .mobile-cart-bar {
    opacity: 0;
    pointer-events: none;
    transform: translateY(1rem);
}

.drawer-overlay,
.modal {
    position: fixed;
    inset: 0;
    background: rgba(16, 31, 21, 0.42);
}

.drawer-overlay {
    z-index: 30;
}

.modal {
    z-index: 50;
    display: grid;
    place-items: center;
    padding: 1rem;
}

.modal__dialog {
    width: min(32rem, 100%);
    border-radius: var(--radius-lg);
    padding: 1rem;
    box-shadow: 0 20px 50px rgba(11, 47, 26, 0.26);
}

.modal .form-field input,
.modal .form-field textarea {
    border-color: var(--line);
    background: #fff;
    color: var(--text);
}

.modal .form-field input::placeholder,
.modal .form-field textarea::placeholder {
    color: #9aa6a0;
}

.phone-field {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 0.6rem;
}

.phone-prefix {
    display: inline-grid;
    place-items: center;
    padding: 0.9rem 0.95rem;
    background: var(--surface-3);
    border: 1px solid var(--line);
    font-weight: 800;
}

[hidden] {
    display: none !important;
}

body.has-drawer,
body.has-modal {
    overflow: hidden;
}

@media (max-width: 759px) {
    .app-header {
        padding: 0.75rem 0.75rem 0;
    }

    .mode-bar__inner {
        padding: 0.45rem 0.75rem;
    }

    .layout {
        margin-top: 0.75rem;
        padding: 0 0.75rem;
    }

    .header-bar {
        gap: 0.65rem;
        align-items: flex-start;
    }

    .brand {
        gap: 0.65rem;
        align-items: flex-start;
    }

    .brand-logo {
        width: 2.7rem;
        height: 2.7rem;
        padding: 0.4rem;
    }

    .brand-eyebrow {
        font-size: 0.68rem;
        letter-spacing: 0.08em;
    }

    .brand-title {
        font-size: 0.9rem;
        line-height: 1.15;
    }

    .header-cart-button {
        gap: 0.4rem;
        padding: 0.72rem 0.8rem;
        flex-shrink: 0;
    }

    .header-cart-button__text {
        font-size: 0.9rem;
    }

    .hero-panel {
        gap: 0.8rem;
        margin-top: 0.8rem;
        padding: 0.95rem;
        border-radius: 1.75rem;
    }

    .hero-kicker {
        font-size: 0.62rem;
    }

    .hero-panel h1 {
        margin: 0.2rem 0 0.35rem;
        font-size: 1rem;
        line-height: 1.1;
    }

    .hero-description {
        font-size: 0.74rem;
        line-height: 1.35;
    }

    .hero-controls,
    .search-field {
        gap: 0.6rem;
    }

    .search-field__label {
        font-size: 0.76rem;
    }

    .search-field input {
        padding: 0.8rem 0.9rem;
        border-radius: 0.95rem;
    }

    .mode-switcher {
        display: grid;
        grid-template-columns: repeat(5, minmax(0, 1fr));
        gap: 0.35rem;
        overflow: visible;
        padding-bottom: 0;
    }

    .mode-chip {
        min-width: 0;
        padding: 0.6rem 0.2rem;
        border-radius: 1rem;
    }

    .mode-chip strong {
        font-size: 0.68rem;
    }

    .mode-chip span {
        font-size: 0.57rem;
        line-height: 1.15;
    }

    .cart-panel {
        padding: 1rem 1rem calc(7.5rem + env(safe-area-inset-bottom));
        max-height: min(86vh, calc(100vh - 1rem));
    }
}

@media (min-width: 760px) {
    .hero-panel {
        grid-template-columns: 1.3fr 1fr;
        align-items: end;
        padding: 1.4rem;
    }

    .promo-strip {
        grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr));
    }

    .product-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .modal__actions {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 0.7rem;
    }
}

@media (min-width: 1080px) {
    .layout {
        grid-template-columns: minmax(0, 1fr) 23rem;
        align-items: start;
    }

    .catalog-column {
        min-width: 0;
    }

    .product-grid {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }

    .cart-panel {
        position: sticky;
        top: 1rem;
        inset: auto;
        transform: none;
        max-height: calc(100vh - 2rem);
        border-radius: var(--radius-lg);
        box-shadow: var(--shadow);
    }

    .drawer-close,
    .header-cart-button,
    .mobile-cart-bar,
    .drawer-overlay {
        display: none;
    }

    .app-shell {
        padding-bottom: 2rem;
    }
}
