:root {
    --bg: #f3f7f1;
    --surface: rgba(255, 255, 255, 0.88);
    --surface-strong: #ffffff;
    --ink: #0f2417;
    --muted: #5b6e60;
    --brand: #2f8f4d;          /* verde medio (hojas) */
    --brand-dark: #1f6b3a;     /* verde oscuro (hoja del logo) */
    --accent: #c79b46;         /* dorado/amarillo de la cola del ave */
    --success: #166534;
    --error: #b14545;
    --border: rgba(31, 107, 58, 0.18);
    --shadow: 0 24px 60px rgba(31, 107, 58, 0.18);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: "Manrope", sans-serif;
    color: var(--ink);
    background:
        radial-gradient(circle at top left, rgba(199, 155, 70, 0.18), transparent 30%),
        radial-gradient(circle at bottom right, rgba(31, 107, 58, 0.22), transparent 35%),
        var(--bg);
}

body.modal-open {
    overflow: hidden;
}

a {
    color: inherit;
    text-decoration: none;
}

img {
    max-width: 100%;
    display: block;
}

button,
input,
select,
textarea {
    font: inherit;
}

button,
.button-link {
    border: none;
    border-radius: 999px;
    background: linear-gradient(135deg, var(--brand-dark), var(--brand));
    color: white;
    padding: 0.9rem 1.2rem;
    cursor: pointer;
    box-shadow: var(--shadow);
}

.button-link.secondary,
.nav-button {
    background: rgba(16, 32, 67, 0.08);
    color: var(--brand-dark);
    box-shadow: none;
}

.danger-button {
    background: linear-gradient(135deg, #7f1d1d, #b14545);
}

.site-shell {
    width: min(1280px, calc(100% - 2rem));
    margin: 0 auto;
    padding: 1.25rem 0 4rem;
}

.topbar,
.panel,
.book-page,
.auth-card,
.hero-note {
    backdrop-filter: blur(18px);
}

.topbar {
    position: sticky;
    top: 1rem;
    z-index: 10;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 24px;
    padding: 1rem 1.2rem;
    box-shadow: var(--shadow);
}

.brand,
h1,
h2,
h3,
h4 {
    font-family: "Fraunces", serif;
}

.brand {
    font-size: 1.3rem;
    font-weight: 700;
}

.topnav {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.badge {
    display: inline-flex;
    min-width: 1.4rem;
    justify-content: center;
    padding: 0.1rem 0.35rem;
    border-radius: 999px;
    background: var(--accent);
    color: white;
    font-size: 0.8rem;
}

.flash-stack {
    margin: 1rem 0;
    display: grid;
    gap: 0.6rem;
}

.flash {
    padding: 0.9rem 1rem;
    border-radius: 16px;
    border: 1px solid var(--border);
    background: var(--surface-strong);
}

.flash-success { border-left: 4px solid var(--success); }
.flash-error { border-left: 4px solid var(--error); }

.hero {
    display: grid;
    grid-template-columns: 1.7fr 1fr;
    gap: 1rem;
    padding: 2rem 0 1.5rem;
    align-items: start;
}

.eyebrow {
    text-transform: uppercase;
    letter-spacing: 0.18em;
    font-size: 0.78rem;
    color: var(--brand);
    margin-bottom: 0.75rem;
}

.hero h1,
.auth-card h1,
.panel h1 {
    margin: 0;
    font-size: clamp(2.2rem, 4vw, 4.6rem);
    line-height: 0.98;
}

.hero-copy,
.hero-note p,
.product-meta p,
.quote-meta,
.empty-state p {
    color: var(--muted);
}

.hero-actions {
    display: flex;
    gap: 0.8rem;
    flex-wrap: wrap;
    margin-top: 1.4rem;
}

.hero-note,
.panel,
.auth-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 28px;
    padding: 1.4rem;
    box-shadow: var(--shadow);
}

.catalog-search-panel {
    margin-bottom: 1.2rem;
}

.catalog-search-head {
    align-items: end;
}

.search-input-wrap {
    display: block;
}

.search-input-wrap input {
    font-size: 1.05rem;
}

.search-counter {
    color: var(--muted);
    white-space: nowrap;
}

.book-controls,
.section-head,
.price-row,
.cart-row,
.quote-total,
.quote-meta,
.quote-actions,
dl div {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.quote-actions {
    margin-top: 0.5rem;
}

.book-controls {
    margin: 0.6rem 0 1rem;
}

.book-viewer.is-searching .book-controls {
    display: none;
}

.category-jump-bar {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
    justify-content: center;
    margin-top: 1rem;
}

.category-jump-button {
    padding: 0.8rem 1rem;
    border-radius: 999px;
    background: rgba(16, 32, 67, 0.08);
    color: var(--brand-dark);
    box-shadow: none;
}

.category-jump-button.is-active {
    background: linear-gradient(135deg, var(--brand-dark), var(--brand));
    color: white;
    box-shadow: var(--shadow);
}

.book-stage {
    position: relative;
    min-height: 1280px;
}

.book-page {
    display: none;
    overflow: hidden;
    border-radius: 34px;
    border: 1px solid var(--border);
    background: rgba(255, 253, 249, 0.92);
    box-shadow: var(--shadow);
}

.book-page.is-active {
    display: grid;
    grid-template-columns: minmax(260px, 28%) 1fr;
    animation: page-turn 420ms ease;
}

.book-viewer.is-searching .book-stage {
    min-height: auto;
    display: grid;
    gap: 1rem;
}

.book-viewer.is-searching .book-page.has-search-match {
    display: grid;
    grid-template-columns: minmax(260px, 28%) 1fr;
}

@keyframes page-turn {
    from {
        opacity: 0;
        transform: perspective(1200px) rotateY(18deg) translateX(18px);
        transform-origin: left center;
    }
    to {
        opacity: 1;
        transform: perspective(1200px) rotateY(0) translateX(0);
    }
}

.category-cover {
    min-height: 100%;
    background-size: cover;
    background-position: center;
    color: white;
    padding: 2rem;
    display: flex;
    align-items: end;
}

.category-cover h2 {
    margin: 0 0 0.6rem;
    font-size: clamp(2rem, 3vw, 3.2rem);
}

.category-content {
    padding: 1.5rem;
    max-height: 1230px;
    overflow: auto;
}

.class-section + .class-section {
    margin-top: 1.5rem;
}

.class-empty-message {
    margin: 0.25rem 0 0;
    color: var(--muted);
}

.product-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1rem;
}

.product-card {
    overflow: hidden;
    border-radius: 24px;
    background: var(--bg);
    border: 1px solid var(--border);
}

.product-card img {
    height: 190px;
    object-fit: contain;
    width: 100%;
    background: var(--bg);
    padding: .4rem;
}

.product-meta {
    padding: 1rem;
}

.sku,
.book-status,
.price-lock {
    font-size: 0.85rem;
    color: var(--muted);
}

.stock-badge {
    display: inline-flex;
    align-items: center;
    width: fit-content;
    margin: 0.3rem 0 0;
    padding: 0.45rem 0.8rem;
    border-radius: 999px;
    font-size: 0.84rem;
    font-weight: 700;
}

.stock-available {
    background: rgba(23, 107, 82, 0.12);
    color: var(--success);
}

.stock-low {
    background: rgba(204, 140, 59, 0.16);
    color: #9a611a;
}

.stock-out {
    background: rgba(177, 69, 69, 0.14);
    color: var(--error);
}

.card-form,
.stack-form,
.auth-card,
.compact-list,
.cart-items,
.dashboard-grid,
.cart-layout,
.quote-sheet {
    display: grid;
    gap: 1rem;
}

.card-form {
    grid-template-columns: 74px 1fr;
    margin-top: 1rem;
}

input,
select,
textarea {
    width: 100%;
    border-radius: 14px;
    border: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.95);
    padding: 0.85rem 1rem;
    margin-top: 0.4rem;
}

label {
    display: block;
}

.dashboard-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: start;
}

.panel-wide {
    grid-column: 1 / -1;
}

.two-columns {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.full-width {
    grid-column: 1 / -1;
}

.compact-list > div,
.cart-row,
dl div {
    padding: 0.9rem 1rem;
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.85);
    border: 1px solid var(--border);
}

.panel-note {
    margin: 0 0 1rem;
    color: var(--muted);
}

.product-admin-list > div,
.row-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.8rem;
}

.row-actions {
    flex-wrap: wrap;
}

.edit-panel {
    margin-top: 1.5rem;
}

.sku-search-form {
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: end;
}

.search-feedback {
    padding: 1rem 1.1rem;
    border-radius: 18px;
    border: 1px solid var(--border);
}

.success-feedback {
    background: rgba(23, 107, 82, 0.08);
}

.error-feedback {
    background: rgba(177, 69, 69, 0.08);
}

.modal-shell {
    position: fixed;
    inset: 0;
    z-index: 30;
    display: none;
}

.modal-shell.is-open {
    display: block;
}

.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(16, 32, 67, 0.5);
}

.modal-card {
    position: relative;
    width: min(920px, calc(100% - 2rem));
    max-height: calc(100vh - 2rem);
    overflow: auto;
    margin: 1rem auto;
    padding: 1.4rem;
    border-radius: 28px;
    border: 1px solid var(--border);
    background: rgba(255, 253, 249, 0.98);
    box-shadow: var(--shadow);
}

.modal-close {
    padding-inline: 1rem;
}

.image-preview-card {
    display: grid;
    gap: 0.8rem;
    padding: 1rem;
    border-radius: 20px;
    border: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.7);
}

.image-preview-card img {
    max-height: 240px;
    width: 100%;
    object-fit: contain;
    border-radius: 18px;
    background: white;
}

.cart-layout {
    grid-template-columns: 1.5fr 0.9fr;
    align-items: start;
}

.summary-card {
    position: sticky;
    top: 6rem;
}

dl {
    margin: 0;
}

dt,
dd {
    margin: 0;
}

.quote-sheet {
    margin-top: 1.4rem;
}

.quote-table {
    width: 100%;
    border-collapse: collapse;
}

.quote-table th,
.quote-table td {
    text-align: left;
    padding: 1rem;
    border-bottom: 1px solid var(--border);
}

.empty-state {
    margin-top: 2rem;
    padding: 3rem;
    text-align: center;
}

.auth-layout {
    display: grid;
    place-items: center;
    padding-top: 2rem;
}

@media (max-width: 980px) {
    .hero,
    .book-page.is-active,
    .dashboard-grid,
    .cart-layout,
    .two-columns,
    .sku-search-form {
        grid-template-columns: 1fr;
    }

    .book-stage {
        min-height: auto;
    }

    .category-content {
        max-height: none;
    }
}

@media (max-width: 720px) {
    .site-shell {
        width: min(100% - 1rem, 1280px);
    }

    .topbar {
        position: static;
    }

    .topnav,
    .book-controls,
    .cart-row,
    .section-head,
    .quote-total {
        flex-direction: column;
        align-items: stretch;
    }
}

/* === Barra superior de categorias (chips) === */
.category-jump-panel {
    margin-top: 1.2rem;
    padding: 1rem 1.2rem;
}
.category-jump-panel .eyebrow {
    margin: 0 0 .6rem;
    color: var(--brand-dark);
    font-weight: 700;
    letter-spacing: .12em;
    text-transform: uppercase;
    font-size: .75rem;
}
.category-jump-panel .category-jump-bar {
    display: flex;
    flex-wrap: wrap;
    gap: .5rem;
}
.category-jump-button {
    border: 1px solid var(--border);
    background: rgba(31, 107, 58, 0.08);
    color: var(--brand-dark);
    padding: .55rem 1rem;
    border-radius: 999px;
    font-weight: 600;
    cursor: pointer;
    transition: background-color .15s ease, color .15s ease;
}
.category-jump-button:hover {
    background: rgba(31, 107, 58, 0.18);
}
.category-jump-button.is-active {
    background: linear-gradient(135deg, var(--brand-dark), var(--brand));
    color: #fff;
    box-shadow: 0 6px 18px rgba(31, 107, 58, 0.28);
}

/* === Formulario de cambio de portada por categoria (admin) === */
.category-cover { position: relative; }
.category-cover-upload {
    position: absolute;
    bottom: 1rem;
    right: 1rem;
    background: rgba(255, 255, 255, 0.92);
    color: var(--ink);
    border-radius: 14px;
    padding: .35rem .6rem;
    box-shadow: 0 6px 14px rgba(0,0,0,.18);
    max-width: 280px;
    font-size: .85rem;
}
.category-cover-upload details summary {
    cursor: pointer;
    font-weight: 600;
    color: var(--brand-dark);
    list-style: none;
}
.category-cover-upload details[open] summary { margin-bottom: .5rem; }
.category-cover-upload label {
    display: block;
    font-size: .75rem;
    color: var(--muted);
    margin: .3rem 0 .15rem;
}
.category-cover-upload input[type="file"],
.category-cover-upload input[type="url"] {
    width: 100%;
    padding: .35rem .5rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #fff;
}
.category-cover-upload button {
    margin-top: .5rem;
    padding: .4rem .9rem;
    font-size: .8rem;
    border-radius: 999px;
}

.category-banner-inferior { margin: 1rem 0 0; }
.category-banner-inferior img { display: block; width: 100%; height: auto; border-radius: 16px; }

.cart-row { display: grid; grid-template-columns: 2fr auto auto auto; gap: .8rem; align-items: center; padding: .8rem 0; border-bottom: 1px solid var(--border); }
.cart-row-update, .cart-row-remove { display: flex; gap: .4rem; align-items: center; margin: 0; }
.button-danger { background: #b14545; color: #fff; border: none; padding: .45rem .9rem; border-radius: 999px; cursor: pointer; font-weight: 600; }
.button-danger:hover { background: #993939; }
.button-danger-outline { background: transparent; color: #b14545; border: 1px solid #b14545; padding: .45rem .9rem; border-radius: 999px; cursor: pointer; font-weight: 600; margin-top: 1rem; }
.button-danger-outline:hover { background: #b14545; color: #fff; }
.cart-clear { display: flex; justify-content: flex-end; }

/* === Recuadros destacados (proveedores / productos) === */
.highlights-panel { margin-top: 1.2rem; }
.highlights-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: .9rem;
    margin-top: 1rem;
}
@media (max-width: 1100px) { .highlights-grid { grid-template-columns: repeat(4, 1fr); } }
@media (max-width: 720px)  { .highlights-grid { grid-template-columns: repeat(2, 1fr); } }

.highlight-card {
    position: relative;
    aspect-ratio: 1 / 1;
    border-radius: 16px;
    border: 1px solid var(--border);
    background: #fff;
    overflow: hidden;
    box-shadow: 0 6px 14px rgba(31, 107, 58, 0.08);
    display: flex;
    flex-direction: column;
}
.highlight-card .highlight-link { display: contents; color: inherit; text-decoration: none; }
.highlight-card img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    background: #f7faf6;
    padding: .4rem;
}
.highlight-empty {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--muted);
    background: linear-gradient(135deg, rgba(31,107,58,.06), rgba(199,155,70,.06));
    font-size: .8rem;
    text-align: center;
    gap: .25rem;
}
.highlight-slot-number {
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--brand-dark);
    opacity: .35;
}
.highlight-title {
    position: absolute;
    bottom: 0; left: 0; right: 0;
    background: linear-gradient(to top, rgba(0,0,0,.65), transparent);
    color: #fff;
    padding: .35rem .5rem .4rem;
    font-size: .75rem;
    font-weight: 600;
    text-align: center;
}
.highlight-admin {
    position: absolute;
    top: .25rem;
    right: .25rem;
    background: rgba(255,255,255,.95);
    border-radius: 10px;
    padding: .15rem .4rem;
    box-shadow: 0 4px 10px rgba(0,0,0,.18);
    font-size: .72rem;
    max-width: 90%;
}
.highlight-admin summary {
    cursor: pointer;
    color: var(--brand-dark);
    font-weight: 600;
    list-style: none;
}
.highlight-admin[open] { padding: .5rem; }
.highlight-admin label { display: block; margin: .25rem 0 .1rem; color: var(--muted); }
.highlight-admin input { width: 100%; padding: .25rem .35rem; border: 1px solid var(--border); border-radius: 6px; font-size: .72rem; }
.highlight-admin button { margin-top: .35rem; padding: .3rem .6rem; font-size: .7rem; border-radius: 999px; }

/* Paneles ligeros: sin fondo blanco, sin sombra, integrados al fondo */
.category-jump-panel,
.catalog-search-panel,
.highlights-panel {
    background: transparent;
    border: none;
    box-shadow: none;
    padding: .8rem 0;
}
.catalog-search-panel .search-input-wrap input {
    background: rgba(255,255,255,.7);
}
