:root {
    --bg: #FAFAF8;
    --bg-alt: #F1F0EC;
    --ink: #17181C;
    --muted: #6B6B66;
    --line: #E4E3DD;
    --accent: #2F4BE0;
    --accent-2: #5E7A5C;
    --white: #FFFFFF;
    --danger: #C0324A;
    --font-display: 'Space Grotesk', sans-serif;
    --font-body: 'IBM Plex Sans', sans-serif;
    --font-mono: 'IBM Plex Mono', monospace;
    --container: 1180px;
    --radius: 6px;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font-family: var(--font-body);
    line-height: 1.6;
}

h1,
h2,
h3 {
    font-family: var(--font-display);
    font-weight: 600;
    margin: 0;
    letter-spacing: -0.01em;
}

a {
    color: inherit;
}

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

button {
    font-family: inherit;
}

.tag {
    font-family: var(--font-mono);
    font-size: 12.5px;
    letter-spacing: 0.06em;
    color: var(--accent-2);
    margin: 0 0 14px;
}

.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 22px;
    border-radius: var(--radius);
    font-weight: 600;
    font-size: 14.5px;
    border: 1px solid transparent;
    cursor: pointer;
    transition: transform .15s ease, background .15s ease;
}

.btn:hover {
    transform: translateY(-1px);
}

.btn-primary {
    background: var(--ink);
    color: var(--white);
}

.btn-primary:hover {
    background: var(--accent);
}

.btn-outline {
    background: transparent;
    color: var(--ink);
    border-color: var(--line);
}

.btn-outline:hover {
    border-color: var(--ink);
}


/* ---------- Banner de demo ---------- */

.demo-banner {
    background: var(--ink);
    color: var(--white);
    font-size: 13px;
    text-align: center;
    padding: 10px 16px;
}

.demo-banner strong {
    color: #B9C4FF;
}


/* ---------- Header ---------- */

.site-header {
    position: sticky;
    top: 0;
    z-index: 50;
    background: rgba(250, 250, 248, 0.92);
    backdrop-filter: blur(8px);
    border-bottom: 1px solid var(--line);
}

.header-inner {
    max-width: var(--container);
    margin: 0 auto;
    padding: 0 24px;
    height: 68px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.brand-logo {
    height: 28px;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.mode-switch {
    display: flex;
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 3px;
    gap: 2px;
}

.mode-btn {
    border: none;
    background: transparent;
    font-family: var(--font-mono);
    font-size: 11px;
    letter-spacing: .03em;
    padding: 6px 12px;
    border-radius: 999px;
    color: var(--muted);
    cursor: pointer;
}

.mode-btn.is-active {
    background: var(--ink);
    color: var(--white);
}

.icon-btn {
    position: relative;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    border: 1px solid var(--line);
    background: var(--white);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.icon-btn svg {
    width: 18px;
    height: 18px;
}

.icon-btn .badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: var(--accent);
    color: var(--white);
    font-size: 10px;
    font-weight: 700;
    min-width: 16px;
    height: 16px;
    border-radius: 999px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 3px;
}

.btn-add-product,
.btn-admin-tool {
    display: none;
    padding: 10px 16px;
    font-size: 13.5px;
}

body[data-mode="admin"] .btn-add-product,
body[data-mode="admin"] .btn-admin-tool {
    display: inline-flex;
}


/* ---------- Encabezado de catálogo ---------- */

.catalog-hero {
    max-width: var(--container);
    margin: 0 auto;
    padding: 56px 24px 24px;
}

.catalog-hero h1 {
    font-size: clamp(1.9rem, 4vw, 2.6rem);
    margin-bottom: 12px;
}

.catalog-hero-text {
    color: var(--muted);
    max-width: 560px;
    margin: 0 0 28px;
}

.filters {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.filter-btn {
    border: 1px solid var(--line);
    background: var(--white);
    color: var(--muted);
    padding: 8px 16px;
    border-radius: 999px;
    font-size: 13.5px;
    cursor: pointer;
}

.filter-btn.is-active {
    background: var(--ink);
    color: var(--white);
    border-color: var(--ink);
}


/* ---------- Grid de productos ---------- */

.section {
    max-width: var(--container);
    margin: 0 auto;
    padding: 8px 24px 100px;
}

.product-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
    gap: 20px;
}

.product-card {
    background: var(--white);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    position: relative;
}

.product-img-wrap {
    position: relative;
    aspect-ratio: 4/5;
    overflow: hidden;
    background: var(--bg-alt);
    cursor: pointer;
}

.product-img-wrap img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.discount-pill {
    position: absolute;
    top: 10px;
    left: 10px;
    background: var(--danger);
    color: var(--white);
    font-size: 11px;
    font-weight: 700;
    padding: 4px 9px;
    border-radius: 999px;
}

.fav-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid var(--line);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.fav-btn svg {
    width: 16px;
    height: 16px;
    stroke: var(--ink);
    fill: none;
}

.fav-btn.is-active svg {
    fill: var(--danger);
    stroke: var(--danger);
}

.admin-controls {
    position: absolute;
    bottom: 8px;
    right: 8px;
    display: none;
    gap: 6px;
}

body[data-mode="admin"] .admin-controls {
    display: flex;
}

.admin-controls button {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    border: 1px solid var(--line);
    background: var(--white);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
}

.admin-controls button.danger {
    color: var(--danger);
}

.product-info {
    padding: 14px 16px 18px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 1;
}

.product-cat {
    font-family: var(--font-mono);
    font-size: 10.5px;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: .04em;
}

.product-name {
    font-weight: 600;
    font-size: 15px;
}

.product-price-row {
    display: flex;
    align-items: baseline;
    gap: 8px;
    margin-top: 4px;
}

.price-final {
    font-weight: 700;
    font-size: 15.5px;
}

.price-old {
    text-decoration: line-through;
    color: var(--muted);
    font-size: 12.5px;
}

.stock-note {
    font-size: 11.5px;
    color: var(--muted);
    margin-top: 2px;
}

.add-cart-btn {
    margin-top: 10px;
    border: 1px solid var(--ink);
    background: transparent;
    color: var(--ink);
    padding: 8px 12px;
    border-radius: var(--radius);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
}

.add-cart-btn:hover {
    background: var(--ink);
    color: var(--white);
}


/* ---------- Overlays / paneles ---------- */

.overlay {
    position: fixed;
    inset: 0;
    background: rgba(23, 24, 28, 0.4);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 200;
    padding: 20px;
}

.overlay.is-open {
    display: flex;
}

.overlay.side {
    justify-content: flex-end;
    padding: 0;
}

#cartOverlay,
#favOverlay {
    justify-content: flex-end;
    padding: 0;
}

.panel {
    background: var(--white);
    border-radius: var(--radius);
    max-width: 480px;
    width: 100%;
    max-height: 88vh;
    overflow-y: auto;
}

.panel--cart {
    border-radius: 0;
    height: 100%;
    max-height: 100%;
    max-width: 400px;
    display: flex;
    flex-direction: column;
}

.panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid var(--line);
}

.close-btn {
    background: none;
    border: none;
    font-size: 22px;
    cursor: pointer;
    color: var(--muted);
    line-height: 1;
}


/* Detalle de producto */

.panel--detail .detail-body {
    padding: 0;
}

.detail-img {
    width: 100%;
    aspect-ratio: 4/3;
    object-fit: cover;
    background: var(--bg-alt);
}

.detail-content {
    padding: 24px;
}

.detail-content .product-cat {
    margin-bottom: 6px;
}

.detail-content h2 {
    font-size: 1.4rem;
    margin-bottom: 8px;
}

.detail-desc {
    color: var(--muted);
    font-size: 14.5px;
    margin: 10px 0 18px;
}

.option-group {
    margin-bottom: 16px;
}

.option-group label {
    display: block;
    font-size: 12.5px;
    font-weight: 600;
    margin-bottom: 8px;
}

.option-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.option-pill {
    border: 1px solid var(--line);
    background: var(--white);
    padding: 7px 14px;
    border-radius: 999px;
    font-size: 13px;
    cursor: pointer;
}

.option-pill.is-active {
    background: var(--ink);
    color: var(--white);
    border-color: var(--ink);
}

.qty-row {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 18px 0;
}

.qty-row button {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 1px solid var(--line);
    background: var(--white);
    cursor: pointer;
    font-size: 16px;
}


/* Formulario admin */

.product-form {
    padding: 20px 24px 24px;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.product-form label {
    font-size: 12.5px;
    font-weight: 600;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.product-form input {
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 10px 12px;
    font-size: 14px;
    font-weight: 400;
    font-family: var(--font-body);
}


/* Carrito */

.cart-items {
    flex: 1;
    overflow-y: auto;
    padding: 12px 24px;
}

.cart-item {
    display: flex;
    gap: 12px;
    padding: 14px 0;
    border-bottom: 1px solid var(--line);
}

.cart-item img {
    width: 60px;
    height: 60px;
    object-fit: cover;
    border-radius: var(--radius);
    background: var(--bg-alt);
}

.cart-item-info {
    flex: 1;
}

.cart-item-name {
    font-weight: 600;
    font-size: 14px;
}

.cart-item-meta {
    font-size: 12px;
    color: var(--muted);
    margin: 2px 0 8px;
}

.cart-item-qty {
    display: flex;
    align-items: center;
    gap: 8px;
}

.cart-item-qty button {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: 1px solid var(--line);
    background: var(--white);
    cursor: pointer;
    font-size: 13px;
}

.cart-item-remove {
    background: none;
    border: none;
    color: var(--danger);
    font-size: 12px;
    cursor: pointer;
    margin-top: 6px;
}

.cart-empty {
    color: var(--muted);
    font-size: 14px;
    padding: 40px 0;
    text-align: center;
}

.cart-footer {
    padding: 18px 24px 24px;
    border-top: 1px solid var(--line);
}

.cart-total {
    display: flex;
    justify-content: space-between;
    font-size: 15px;
    margin-bottom: 16px;
}

.cart-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.cart-actions .btn {
    width: 100%;
    justify-content: center;
}


/* Toast */

.toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: var(--ink);
    color: var(--white);
    padding: 12px 20px;
    border-radius: 999px;
    font-size: 13.5px;
    opacity: 0;
    pointer-events: none;
    transition: opacity .2s ease, transform .2s ease;
    z-index: 400;
}

.toast.is-visible {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}


/* ---------- Upload de imagen (formulario producto) ---------- */

.upload-area {
    position: relative;
    border: 1.5px dashed var(--line);
    background: var(--bg-alt);
    border-radius: var(--radius);
    padding: 26px 16px;
    text-align: center;
    cursor: pointer;
    transition: border-color .15s ease, background .15s ease;
}

.upload-area:hover,
.upload-area.is-drag {
    border-color: var(--ink);
    background: var(--white);
}

.upload-area input[type="file"] {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
    width: 100%;
    height: 100%;
}

.upload-text {
    font-size: 12.5px;
    color: var(--muted);
    font-weight: 400;
}

.preview-wrap {
    display: none;
    position: relative;
    margin-top: 10px;
}

.preview-wrap.is-visible {
    display: block;
}

.preview-wrap img {
    width: 100%;
    max-height: 180px;
    object-fit: contain;
    background: var(--bg-alt);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 6px;
}

.preview-clear {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--ink);
    color: var(--white);
    border: none;
    cursor: pointer;
    font-size: 13px;
    line-height: 1;
}


/* ---------- Switch de descuento ---------- */

.desc-toggle {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 4px 0 2px;
    cursor: pointer;
    user-select: none;
    font-size: 12.5px;
    font-weight: 600;
}

.toggle-switch {
    width: 34px;
    height: 18px;
    background: var(--line);
    border-radius: 999px;
    position: relative;
    transition: background .15s ease;
}

.toggle-switch::after {
    content: '';
    position: absolute;
    width: 14px;
    height: 14px;
    background: var(--white);
    border-radius: 50%;
    top: 2px;
    left: 2px;
    transition: transform .15s ease;
    box-shadow: 0 1px 3px rgba(0, 0, 0, .2);
}

.toggle-switch.is-on {
    background: var(--ink);
}

.toggle-switch.is-on::after {
    transform: translateX(16px);
}


/* ---------- Gestor de categorías ---------- */

.cat-manager {
    padding: 20px 24px 24px;
}

.cat-add-row {
    display: flex;
    gap: 8px;
    margin-bottom: 18px;
}

.cat-add-row input {
    flex: 1;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 10px 12px;
    font-size: 14px;
}

.cat-list {
    display: flex;
    flex-direction: column;
    gap: 1px;
    background: var(--line);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    overflow: hidden;
}

.cat-row {
    background: var(--white);
    padding: 12px 14px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 14px;
}

.cat-row-count {
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--muted);
    margin-left: 8px;
}

.cat-row-actions button {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--danger);
    font-size: 12.5px;
}


/* ---------- Analíticas ---------- */

.analytics-body {
    padding: 20px 24px 28px;
}

.analytics-cards {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    margin-bottom: 22px;
}

.analytics-card {
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 14px;
}

.analytics-card .num {
    font-family: var(--font-display);
    font-size: 1.5rem;
    font-weight: 700;
}

.analytics-card .lbl {
    font-size: 11px;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: .04em;
    margin-top: 2px;
}

.analytics-section-title {
    font-family: var(--font-mono);
    font-size: 11.5px;
    color: var(--accent-2);
    letter-spacing: .04em;
    margin: 18px 0 8px;
}

.analytics-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid var(--line);
    font-size: 13.5px;
}

.analytics-row:last-child {
    border-bottom: none;
}

.analytics-empty {
    color: var(--muted);
    font-size: 13px;
}