:root {
    --page: #E8F0F2;
    --panel: #FBFCFC;
    --ink: #202A2C;
    --muted: #60717A;
    --line: #CBD8DD;
    --brand: #243436;
    --brand-soft: rgba(111, 157, 180, 0.18);
    --action: #9A4D35;
    --action-dark: #763626;
    --success: #2F7D66;
    --success-soft: rgba(47, 125, 102, 0.14);
    --soft: #DDE8EB;
    --green: var(--brand);
    --green-soft: var(--brand-soft);
    --logo-shadow: #243436;
    --stone: #6F9DB4;
    --autumn: var(--action);
    --shadow: 0 16px 34px rgba(36, 52, 54, 0.12);
}

body.dark {
    --ink: #f8fafc;
    --muted: #b8c2d1;
    --line: rgba(248, 250, 252, 0.16);
    --panel: #172026;
    --page: #10181c;
    --soft: #1f2b31;
    --brand: #E8F0F2;
    --brand-soft: rgba(111, 157, 180, 0.2);
    --logo-shadow: #F8FAFC;
    --stone: #9BC4D6;
    --action: #C96D4D;
    --action-dark: #9A4D35;
    --success: #62C799;
    --success-soft: rgba(34, 197, 94, 0.16);
    --green: #62C799;
    --green-soft: rgba(34, 197, 94, 0.16);
    --shadow: 0 14px 34px rgba(0, 0, 0, 0.28);
}

* { box-sizing: border-box; }

body {
    min-height: 100vh;
    background:
        linear-gradient(180deg, rgba(111,157,180,0.2), rgba(255,255,255,0) 340px),
        var(--page);
    color: var(--ink);
    font-family: Arial, Helvetica, sans-serif;
}

.app-shell { max-width: 1440px; }

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    padding: 28px 8px 22px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 230px;
    border: 0;
    background: transparent;
    color: inherit;
    padding: 0;
    text-align: left;
}

.brand:hover .brand-title,
.brand:focus-visible .brand-title {
    color: var(--action-dark);
}

.brand-icon {
    display: grid;
    position: relative;
    width: 54px;
    height: 54px;
    place-items: center;
    border-radius: 16px;
    background: var(--logo-shadow);
    color: white;
    box-shadow: 0 10px 24px rgba(36, 52, 54, 0.22);
}

.cart-badge {
    position: absolute;
    top: -7px;
    right: -7px;
    display: none;
    min-width: 24px;
    height: 24px;
    padding: 0 7px;
    border: 2px solid var(--page);
    border-radius: 999px;
    background: var(--action);
    color: white;
    font-size: 12px;
    font-weight: 900;
    line-height: 20px;
    text-align: center;
}

.cart-badge.show { display: block; }

body.dark .brand-icon {
    background: #243436;
    color: #E8F0F2;
}

.brand-title {
    margin: 0;
    color: var(--logo-shadow);
    font-size: 34px;
    font-weight: 900;
    line-height: 1;
}

.brand-title span { color: var(--stone); }

.brand-subtitle {
    margin: 4px 0 0;
    color: var(--muted);
    font-size: 14px;
}

.nav-tabs-app {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 34px;
    flex: 1;
    color: var(--muted);
    font-weight: 700;
}

/* .icon-btn.mobile-menu-toggle: la doble clase gana la especificidad contra
   el display de .icon-btn, que se declara mas abajo. */
.mobile-menu, .icon-btn.mobile-menu-toggle { display: none; }

.nav-tabs-app button {
    border: 0;
    border-bottom: 3px solid transparent;
    background: transparent;
    color: inherit;
    padding: 11px 0;
    font-weight: 800;
}

.nav-tabs-app button.active {
    color: var(--brand);
    border-bottom-color: var(--brand);
}

.top-actions { display: flex; gap: 12px; }

.icon-btn {
    display: grid;
    width: 44px;
    height: 44px;
    place-items: center;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: var(--panel);
    color: var(--ink);
}

.fallback-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.15em;
    height: 1.15em;
    font-style: normal;
    line-height: 1;
}

.view { display: none; }
.view.active { display: block; }

.home-intro {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 18px;
    align-items: end;
    margin: 4px 0 18px;
}

.home-kicker {
    margin: 0 0 6px;
    color: var(--brand);
    font-size: 13px;
    font-weight: 900;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.home-title {
    margin: 0;
    font-size: 34px;
    font-weight: 900;
    line-height: 1.08;
}

.home-subtitle {
    max-width: 680px;
    margin: 8px 0 0;
    color: var(--muted);
    font-size: 16px;
}

.frescura {
    margin: 10px 0 0;
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 5px 11px;
    border-radius: 999px;
    background: var(--success-soft);
    color: var(--success);
    font-size: 13px;
    font-weight: 700;
}
.frescura::before {
    content: "";
    width: 8px;
    height: 8px;
    border-radius: 999px;
    background: currentColor;
}
.pipeline-alerta {
    margin-top: 10px;
    padding: 9px 11px;
    border-radius: 10px;
    background: rgba(154, 77, 53, 0.14);
    border: 1px solid var(--action);
    color: var(--action);
    font-size: 12px;
    font-weight: 700;
    line-height: 1.35;
}
.pipeline-alerta ul { margin: 6px 0 0; padding-left: 16px; font-weight: 600; }

.frescura.vieja {
    background: rgba(154, 77, 53, 0.14);
    color: var(--action);
}

.home-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 10px;
}

.action-chip {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 42px;
    padding: 8px 13px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--panel);
    color: var(--ink);
    font-weight: 900;
    box-shadow: 0 8px 20px rgba(18, 33, 38, 0.06);
}

.action-chip.primary {
    border-color: var(--brand);
    background: var(--brand);
    color: white;
}

.action-chip:hover {
    border-color: var(--brand);
    color: var(--brand);
}

.action-chip.primary:hover {
    color: white;
    filter: brightness(1.05);
}

.hero-search {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 120px;
    gap: 14px;
    max-width: 920px;
    margin: 0 auto 22px;
}

.search-input-wrap {
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 64px;
    padding: 0 20px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: var(--panel);
    box-shadow: var(--shadow);
}

.search-input-wrap input {
    flex: 1;
    border: 0;
    outline: 0;
    background: transparent;
    color: var(--ink);
    font-size: 18px;
}

/* Desplegable de sugerencias propio: el <datalist> nativo lo dibuja el
   navegador donde quiere (en Brave salia pegado al borde derecho, tapando
   media pagina) y no se puede estilar. */
.search-input-wrap { position: relative; }

.search-suggestions {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    right: 0;
    z-index: 40;
    max-height: 320px;
    overflow-y: auto;
    padding: 6px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--panel);
    box-shadow: var(--shadow);
}

.search-suggestions button {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    width: 100%;
    min-height: 40px;
    padding: 0 12px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: var(--ink);
    font: inherit;
    text-align: left;
    cursor: pointer;
}

.search-suggestions button:hover,
.search-suggestions button.resaltada {
    background: var(--brand-soft);
}

.search-suggestions .sug-conteo {
    font-size: 12px;
    color: var(--muted);
    white-space: nowrap;
}

.clear-btn {
    border: 0;
    background: transparent;
    color: var(--muted);
}

.btn-go {
    border: 0;
    border-radius: 12px;
    background: linear-gradient(180deg, var(--action), var(--action-dark));
    color: white;
    font-weight: 800;
    box-shadow: 0 10px 22px rgba(154, 77, 53, 0.22);
}

.btn-outline-go {
    border: 1px solid var(--brand);
    border-radius: 9px;
    background: transparent;
    color: var(--brand);
    font-weight: 900;
}








.content-grid {
    display: grid;
    grid-template-columns: 240px minmax(0, 1fr) 310px;
    gap: 28px;
}

.section-title {
    margin: 0 0 18px;
    font-size: 18px;
    font-weight: 900;
}

.filters {
    display: grid;
    align-content: start;
    gap: 22px;
}

.mobile-filter-toggle { display: none; }

.filter-head,
.results-head,
.total-line {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.reco-banner {
    margin-top: 12px;
    padding: 12px 14px;
    border-radius: 12px;
    border: 1px solid var(--line);
    background: var(--soft);
    color: var(--ink);
    font-size: 0.92rem;
    line-height: 1.4;
}
.reco-banner .reco-headline { font-weight: 700; display: block; }
.reco-banner .reco-ahorro { margin-top: 4px; font-size: 0.85rem; color: var(--muted); }
.reco-banner.reco-dividir_compra,
.reco-banner.reco-dividir_fuerte {
    border-color: var(--success);
    background: var(--success-soft);
}
.reco-banner.reco-dividir_compra .reco-ahorro,
.reco-banner.reco-dividir_fuerte .reco-ahorro { color: var(--success); font-weight: 600; }

.results-context {
    display: none;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    margin: 0 0 14px;
    padding: 12px 14px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--panel);
    box-shadow: 0 10px 22px rgba(36, 52, 54, 0.08);
}

.results-context.show {
    display: flex;
}

.context-path {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    color: var(--muted);
    font-weight: 800;
}

.context-pill {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    min-height: 30px;
    padding: 6px 10px;
    border: 1px solid transparent;
    border-radius: 999px;
    background: var(--brand-soft);
    color: var(--ink);
    font-weight: 900;
}

.context-pill button {
    display: inline-grid;
    place-items: center;
    width: 18px;
    height: 18px;
    border: 0;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.46);
    color: inherit;
    font-size: 13px;
    line-height: 1;
}

.context-pill button:hover {
    background: var(--brand);
    color: white;
}

.link-clear {
    border: 0;
    background: none;
    color: var(--brand);
    font-weight: 700;
}

.filter-block label { margin-bottom: 10px; font-weight: 800; }

.filter-range {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}

.form-select,
.form-control,
.form-check-input {
    border-color: var(--line);
    background-color: var(--panel);
    color: var(--ink);
}

.form-select { min-height: 48px; border-radius: 9px; }
.form-check-input:checked { background-color: var(--brand); border-color: var(--brand); }

.alert-box {
    padding: 18px;
    border-radius: 12px;
    background: linear-gradient(135deg, rgba(249,115,22,0.1), var(--panel));
}

.view-toggle {
    display: flex;
    gap: 6px;
    padding: 6px;
    border-radius: 10px;
    background: var(--soft);
}

.view-toggle button {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    border: 0;
    border-radius: 8px;
    padding: 8px 12px;
    background: transparent;
    color: var(--muted);
    font-weight: 800;
}

.view-toggle .active {
    background: var(--panel);
    color: var(--brand);
    box-shadow: 0 3px 12px rgba(16, 24, 40, 0.08);
}

.results-list { display: grid; gap: 18px; }

.results-table-wrap {
    overflow-x: auto;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: var(--panel);
    box-shadow: var(--shadow);
}

.results-table {
    width: 100%;
    min-width: 680px;
    border-collapse: collapse;
}

.results-table th,
.results-table td {
    padding: 13px 12px;
    border-bottom: 1px solid var(--line);
    vertical-align: middle;
}

.results-table th {
    color: var(--muted);
    font-size: 13px;
    font-weight: 900;
    text-transform: uppercase;
}

.results-table tr:last-child td { border-bottom: 0; }

.table-product {
    display: grid;
    grid-template-columns: 48px minmax(0, 1fr);
    gap: 12px;
    align-items: center;
}

.table-product img {
    width: 48px;
    height: 58px;
    object-fit: contain;
}

.table-product-name {
    font-weight: 900;
    line-height: 1.2;
}

.product-card {
    display: grid;
    grid-template-columns: 260px minmax(0, 1fr);
    overflow: hidden;
    border-radius: 14px;
}

.product-info {
    display: flex;
    flex-direction: column;
    gap: 18px;
    align-items: stretch;
    padding: 24px;
    background: linear-gradient(180deg, rgba(15,118,110,0.06), rgba(255,255,255,0));
}

.product-image-box {
    display: grid;
    width: 100%;
    min-height: 188px;
    place-items: center;
    border-radius: 12px;
    background: var(--soft);
}

.product-image {
    max-width: 150px;
    max-height: 164px;
    object-fit: contain;
}

.product-name {
    margin: 0 0 10px;
    color: var(--logo-shadow);
    font-size: 24px;
    font-weight: 900;
    line-height: 1.24;
}

.product-meta {
    display: grid;
    gap: 8px;
    margin-bottom: 16px;
    color: var(--muted);
    font-size: 15px;
}

.product-actions {
    display: grid;
    gap: 10px;
}

.details-btn.primary {
    border-color: var(--action);
    background: var(--action);
    color: white;
}

.details-btn.primary.added,
.details-btn.primary:disabled {
    border-color: var(--success);
    background: var(--success);
    color: white;
    cursor: default;
    opacity: 1;
}

.details-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: 44px;
    padding: 0 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
    color: var(--ink);
    font-weight: 700;
}

.prices-table {
    display: grid;
    align-content: start;
    border-left: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.34);
}

body.dark .prices-table {
    background: rgba(255, 255, 255, 0.03);
}

body.dark .product-info {
    background: rgba(255, 255, 255, 0.02);
}

.prices-header,
.price-row {
    display: grid;
    grid-template-columns: minmax(120px, 1fr) 110px 130px;
    gap: 14px;
    align-items: center;
    padding: 14px 18px;
}

.prices-header {
    color: var(--muted);
    font-size: 14px;
    font-weight: 800;
}

.price-row { border-top: 1px solid var(--line); }
.store-name { color: var(--ink); font-weight: 900; }

.best-pill {
    display: inline-flex;
    margin-left: 8px;
    padding: 5px 9px;
    border-radius: 999px;
    background: var(--success-soft);
    color: var(--success);
    font-size: 13px;
    font-weight: 800;
}

.offer-pill {
    display: inline-flex;
    margin-left: 8px;
    padding: 5px 9px;
    border-radius: 999px;
    background: rgba(249, 115, 22, 0.12);
    color: var(--action-dark);
    font-size: 13px;
    font-weight: 900;
}

.price-value { font-weight: 900; }
.price-value.best { color: var(--green); }

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

.reference-price {
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
}

.buy-btn {
    display: inline-flex;
    justify-content: center;
    min-height: 38px;
    padding: 8px 12px;
    border: 1px solid var(--action);
    border-radius: 8px;
    color: var(--action-dark);
    font-weight: 900;
    text-decoration: none;
}

.buy-btn:hover { background: var(--action); color: white; }

.side-panel {
    display: grid;
    align-content: start;
    gap: 22px;
}

.panel-card {
    padding: 20px;
    border-radius: 14px;
}

.panel-title {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0 0 16px;
    font-size: 20px;
    font-weight: 900;
}

.optimal-list {
    display: grid;
    gap: 15px;
    padding: 16px 0;
    border-top: 1px solid var(--line);
    border-bottom: 1px solid var(--line);
}

.market-total-list {
    display: grid;
    gap: 10px;
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--line);
}

.market-total-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 12px;
    align-items: center;
}

.market-total-name {
    font-weight: 900;
}

.market-total-price {
    color: var(--ink);
    font-weight: 900;
}

.market-total-row.best .market-total-price,
.market-total-row.best .market-total-name {
    color: var(--success);
}

.optimal-item,
.saved-item,
.history-item,
.alert-item {
    display: grid;
    grid-template-columns: 46px minmax(0, 1fr) auto;
    gap: 12px;
    align-items: center;
}

.optimal-item img,
.saved-item img,
.history-item img,
.alert-item img {
    width: 42px;
    height: 54px;
    object-fit: contain;
}

.optimal-name,
.saved-name {
    overflow: hidden;
    font-weight: 900;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.optimal-meta,
.saved-meta,
.market-total-meta {
    color: var(--muted);
    font-size: 13px;
}

.optimal-price,
.total-value {
    color: var(--success);
    font-weight: 900;
}

.total-value { font-size: 26px; }

.history-chart {
    height: 92px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background:
        linear-gradient(135deg, transparent 48%, rgba(22,163,74,0.18) 48% 52%, transparent 52%),
        var(--soft);
}

.reason-list { display: grid; gap: 18px; }
.reason-item { display: grid; grid-template-columns: 28px 1fr; gap: 12px; }

.data-status {
    display: grid;
    gap: 12px;
}

.data-status-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--line);
}

.data-status-row:last-child {
    border-bottom: 0;
    padding-bottom: 0;
}

.data-status-label {
    color: var(--muted);
    font-size: 13px;
    font-weight: 800;
}

.data-status-value {
    font-weight: 900;
    text-align: right;
}

.empty-state {
    padding: 42px 18px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: var(--panel);
    color: var(--muted);
    text-align: center;
}

.empty-state strong {
    color: var(--ink);
}

.start-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
    margin-top: 18px;
    text-align: left;
}

.start-action {
    display: grid;
    gap: 10px;
    min-height: 156px;
    padding: 18px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--panel);
    color: var(--ink);
}

.start-action i {
    color: var(--brand);
}

.start-action h3 {
    margin: 0;
    font-size: 19px;
    font-weight: 900;
}

.start-action p {
    margin: 0;
    color: var(--muted);
}

.start-action-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-self: end;
}

.suggestion-chips {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 9px;
    margin-top: 16px;
}

.suggestion-chip {
    min-height: 34px;
    padding: 7px 12px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: var(--brand-soft);
    color: var(--brand);
    font-size: 13px;
    font-weight: 850;
}

.suggestion-chip:hover {
    border-color: var(--brand);
    background: var(--brand);
    color: white;
}

.utility-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 22px;
}

.utility-card {
    padding: 22px;
    border-radius: 14px;
}

.utility-card button { min-height: 42px; }

.categories-hero {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 18px;
    align-items: end;
    margin-bottom: 22px;
}

.categories-kicker {
    margin: 0 0 8px;
    color: var(--action-dark);
    font-size: 13px;
    font-weight: 900;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.categories-title {
    margin: 0;
    font-size: 36px;
    font-weight: 900;
}

.categories-copy {
    max-width: 620px;
    margin: 8px 0 0;
    color: var(--muted);
    font-size: 17px;
}

.category-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 18px;
}

.category-group-title {
    grid-column: 1 / -1;
    margin: 10px 0 -6px;
    font-size: 0.82rem;
    font-weight: 700;
    letter-spacing: 0.09em;
    text-transform: uppercase;
    color: var(--brand, #0f766e);
}

.category-group-title:first-child {
    margin-top: 0;
}

.category-card {
    display: grid;
    gap: 16px;
    cursor: pointer;
    min-height: 220px;
    padding: 20px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background:
        linear-gradient(145deg, rgba(111, 157, 180, 0.1), transparent 44%),
        var(--panel);
    box-shadow: var(--shadow);
    color: var(--ink);
    font: inherit;
    text-align: left;
    transition: transform 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
}

.category-card:hover,
.category-card:focus-visible,
.category-card.active {
    transform: translateY(-2px);
    border-color: rgba(154, 77, 53, 0.42);
    box-shadow: 0 20px 42px rgba(36, 52, 54, 0.16);
}

.category-card.active {
    outline: 3px solid rgba(154, 77, 53, 0.14);
}

.category-top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 14px;
}

.category-icon {
    display: inline-grid;
    place-items: center;
    width: 46px;
    height: 46px;
    border-radius: 12px;
    background: var(--brand-soft);
    color: var(--action-dark);
}

.category-icon i {
    width: 24px;
    height: 24px;
}

.category-count {
    padding: 6px 10px;
    border-radius: 999px;
    background: var(--soft);
    color: var(--muted);
    font-size: 13px;
    font-weight: 800;
}

.category-card h3 {
    margin: 0;
    font-size: 24px;
    font-weight: 900;
}

.category-card p {
    margin: 6px 0 0;
    color: var(--muted);
    font-size: 15px;
}

.category-chip-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-self: end;
}

.category-chip,
.subcategory-chip {
    min-height: 34px;
    padding: 7px 11px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.46);
    color: var(--ink);
    font-size: 13px;
    font-weight: 800;
    cursor: pointer;
    user-select: none;
}

body.dark .category-chip,
body.dark .subcategory-chip {
    background: rgba(255, 255, 255, 0.04);
}

.category-chip:hover,
.category-chip:focus-visible {
    border-color: var(--action);
    color: var(--action-dark);
}

.category-open {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    width: 100%;
    padding: 0;
    border: 0;
    background: transparent;
    color: var(--action-dark);
    font: inherit;
    font-weight: 900;
    text-align: left;
}

.category-open:hover {
    color: var(--action);
}

.subcategory-panel {
    display: none;
    margin: 22px 0 0;
    padding: 22px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: var(--panel);
    box-shadow: var(--shadow);
}

.subcategory-panel.show {
    display: block;
}

.subcategory-head {
    display: flex;
    align-items: start;
    justify-content: space-between;
    gap: 18px;
    margin-bottom: 18px;
}

.subcategory-head h3 {
    margin: 0;
    font-size: 24px;
    font-weight: 900;
}

.subcategory-head p {
    margin: 5px 0 0;
    color: var(--muted);
}

.subcategory-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.subcategory-chip {
    min-height: 40px;
    background: var(--panel);
}

.subcategory-chip:hover {
    border-color: var(--action);
    color: var(--action-dark);
}

.list-stack { display: grid; gap: 14px; }

.toast-app {
    position: fixed;
    right: 20px;
    bottom: 20px;
    z-index: 20;
    display: none;
    padding: 14px 18px;
    border-radius: 12px;
    background: var(--ink);
    color: var(--panel);
    box-shadow: var(--shadow);
    font-weight: 800;
}

.toast-app.show { display: block; }

/* Barra inferior fija con el resumen de compra (solo movil). Da acceso
   persistente al total/recomendacion cuando el panel queda bajo el fold. */
.sticky-compra {
    display: none;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 15;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 16px calc(12px + env(safe-area-inset-bottom, 0px));
    background: var(--brand);
    color: var(--panel);
    box-shadow: 0 -8px 24px rgba(0, 0, 0, 0.18);
    cursor: pointer;
}
.sticky-compra-info { display: flex; align-items: center; gap: 12px; min-width: 0; }
.sticky-compra-count {
    flex: none;
    min-width: 26px;
    height: 26px;
    padding: 0 8px;
    border-radius: 999px;
    background: var(--panel);
    color: var(--brand);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 900;
    font-size: 0.85rem;
}
.sticky-compra-texto { display: flex; flex-direction: column; line-height: 1.15; min-width: 0; }
.sticky-compra-total { font-size: 1.05rem; font-weight: 900; }
.sticky-compra-reco {
    font-size: 0.78rem;
    opacity: 0.85;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 52vw;
}
.sticky-compra-cta { flex: none; display: inline-flex; align-items: center; gap: 6px; font-weight: 800; font-size: 0.9rem; }
@media (max-width: 1024px) {
    .sticky-compra:not([hidden]) { display: flex; }
    body.has-sticky-compra { padding-bottom: 76px; }
}

/* Capa visual profesional - reversible desde backups/index_antes_redisenio_*.html */
:root {
    --page: #F5F7FA;
    --panel: #FFFFFF;
    --ink: #17242B;
    --muted: #64727E;
    --line: #DDE5EA;
    --brand: #1F6F78;
    --brand-soft: rgba(31, 111, 120, 0.1);
    --action: #2E8B7C;
    --action-dark: #23695F;
    --success: #2E8B7C;
    --success-soft: rgba(46, 139, 124, 0.14);
    --soft: #EEF3F5;
    --green: #2E8B7C;
    --green-soft: rgba(46, 139, 124, 0.14);
    --logo-shadow: #17242B;
    --stone: #7AA7B0;
    --shadow: 0 14px 34px rgba(23, 36, 43, 0.08);
}

body.dark {
    --page: #0E161A;
    --panel: #152126;
    --ink: #F4F8FA;
    --muted: #A8B6BE;
    --line: rgba(226, 237, 241, 0.14);
    --brand: #7FC7C0;
    --brand-soft: rgba(127, 199, 192, 0.14);
    --action: #4CB6A7;
    --action-dark: #7FC7C0;
    --success: #7FC7C0;
    --success-soft: rgba(127, 199, 192, 0.14);
    --soft: #1D2B31;
    --green: #7FC7C0;
    --green-soft: rgba(127, 199, 192, 0.14);
    --logo-shadow: #F4F8FA;
    --stone: #7FC7C0;
    --shadow: 0 16px 34px rgba(0, 0, 0, 0.28);
}

body {
    background:
        linear-gradient(180deg, rgba(122, 167, 176, 0.18), rgba(255, 255, 255, 0) 280px),
        var(--page);
    font-family: Inter, Arial, Helvetica, sans-serif;
}

body.dark {
    background:
        linear-gradient(180deg, rgba(76, 182, 167, 0.12), rgba(14, 22, 26, 0) 280px),
        var(--page);
}

body.dark .brand-icon {
    background: linear-gradient(135deg, #1F6F78, #4CB6A7);
    color: #F4F8FA;
    box-shadow: 0 12px 26px rgba(0, 0, 0, 0.28);
}

body.dark .icon-btn,
body.dark .search-input-wrap,
body.dark .action-chip,
body.dark body.dark .panel-card,
body.dark .product-card,
body.dark .utility-card,
body.dark .category-card,
body.dark .subcategory-panel,
body.dark .results-context,
body.dark .empty-state,
body.dark .start-action,
body.dark .results-table-wrap {
    background: var(--panel);
    border-color: var(--line);
}

body.dark .product-info {
    background: linear-gradient(180deg, rgba(127, 199, 192, 0.08), rgba(21, 33, 38, 0));
}

body.dark .product-image-box,
body.dark .history-chart,
body.dark .view-toggle {
    background: var(--soft);
}

body.dark .prices-table {
    background: #111C21;
}

body.dark .category-chip,
body.dark .subcategory-chip,
body.dark .details-btn {
    background: #18262C;
    border-color: var(--line);
}

body.dark .form-select,
body.dark .form-control {
    background-color: #152126;
    border-color: var(--line);
    color: var(--ink);
}

body.dark .form-select:disabled,
body.dark .form-control:disabled {
    background-color: #1D2B31;
    border-color: rgba(226, 237, 241, 0.12);
    color: #7D8D96;
    opacity: 1;
}

body.dark .form-select option {
    background-color: #152126;
    color: var(--ink);
}

body.dark .form-control::placeholder {
    color: #7D8D96;
}

body.dark .reason-list {
    gap: 14px;
}

body.dark .reason-item {
    color: var(--ink);
}

body.dark .view-toggle .active {
    background: #223238;
}

body.dark .btn-go {
    background: linear-gradient(180deg, #4CB6A7, #2F8278);
    color: #061214;
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.22);
}

body.dark .buy-btn {
    color: var(--brand);
    border-color: var(--brand);
}

body.dark .buy-btn:hover {
    background: var(--brand);
    color: #061214;
}

.app-shell {
    max-width: 1320px;
}

.topbar {
    padding: 22px 4px 18px;
}

.brand-icon {
    width: 48px;
    height: 48px;
    border-radius: 14px;
    background: linear-gradient(135deg, #1F6F78, #2E8B7C);
    box-shadow: 0 12px 26px rgba(31, 111, 120, 0.18);
}

.brand-title {
    font-size: 30px;
    letter-spacing: -0.02em;
}

.brand-title span,
.nav-tabs-app button.active {
    color: var(--brand);
}

.nav-tabs-app {
    gap: 28px;
    font-size: 15px;
}

.nav-tabs-app button {
    font-weight: 750;
}

.nav-tabs-app button.active {
    border-bottom-color: var(--brand);
}

.hero-search {
    max-width: 980px;
    grid-template-columns: minmax(0, 1fr) 132px;
    margin-bottom: 20px;
}

.home-intro {
    margin-top: 2px;
}

.home-title {
    font-size: 32px;
}

.home-subtitle {
    font-size: 15px;
}

.search-input-wrap {
    min-height: 58px;
    border-radius: 12px;
    box-shadow: 0 16px 36px rgba(18, 33, 38, 0.08);
}

.search-input-wrap input {
    font-size: 17px;
}

.btn-go {
    min-height: 46px;
    border-radius: 10px;
    background: linear-gradient(180deg, #2E8B7C, #23695F);
    box-shadow: 0 12px 24px rgba(31, 111, 120, 0.18);
    font-weight: 850;
}

.btn-go:hover {
    background: linear-gradient(180deg, #349B8A, #1F6F78);
}

.btn-outline-go {
    border-color: var(--brand);
    color: var(--brand);
}






.content-grid {
    grid-template-columns: 230px minmax(0, 1fr) 286px;
    gap: 18px;
    align-items: start;
}

.filters,
.side-panel {
    position: sticky;
    top: 14px;
}

.filters {
    gap: 17px;
    padding-right: 4px;
}

.alert-box {
    background: linear-gradient(135deg, var(--brand-soft), var(--panel));
}

.filter-head {
    margin-bottom: 2px;
}

.section-title {
    font-size: 16px;
}

.filter-block label {
    margin-bottom: 8px;
    font-size: 13px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

.form-select,
.form-control {
    min-height: 42px;
    border-radius: 9px;
    font-size: 14px;
}

.form-check-label {
    font-size: 14px;
}

.alert-box {
    padding: 15px;
    background: var(--brand-soft);
}

.results-head {
    margin-bottom: 12px;
}

.view-toggle {
    padding: 4px;
    border-radius: 9px;
}

.view-toggle button {
    padding: 7px 10px;
    font-size: 14px;
}

.results-list {
    gap: 14px;
}

.product-card {
    grid-template-columns: 248px minmax(0, 1fr);
    border-radius: 12px;
}

.product-info {
    gap: 14px;
    padding: 18px;
    background: linear-gradient(180deg, rgba(31, 111, 120, 0.055), rgba(255, 255, 255, 0));
}

.product-image-box {
    min-height: 150px;
    border-radius: 10px;
    background: #F4F8F7;
}

.product-image {
    max-width: 124px;
    max-height: 132px;
}

.product-name {
    display: -webkit-box;
    overflow: hidden;
    margin-bottom: 8px;
    color: var(--ink);
    font-size: 20px;
    line-height: 1.22;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
}

.product-meta {
    gap: 5px;
    margin-bottom: 12px;
    font-size: 14px;
}

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

.details-btn {
    min-height: 36px;
    padding: 0 9px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 800;
}

.prices-table {
    background: #FFFFFF;
}

.prices-header,
.price-row {
    grid-template-columns: minmax(120px, 1fr) 108px 108px;
    gap: 10px;
    padding: 12px 16px;
}

.prices-header {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.store-name {
    font-weight: 850;
}

.best-pill,
.offer-pill {
    margin-left: 0;
    margin-top: 5px;
    padding: 4px 8px;
    font-size: 12px;
}

.price-value {
    font-size: 17px;
}

.reference-price {
    margin-top: 2px;
}

.buy-btn {
    min-height: 34px;
    padding: 7px 10px;
    border-radius: 8px;
    color: var(--brand);
    font-size: 13px;
}

.buy-btn:hover {
    background: var(--brand);
}

.panel-card {
    padding: 17px;
    border-radius: 12px;
}

.panel-title {
    margin-bottom: 12px;
    font-size: 18px;
}

.side-panel {
    gap: 14px;
}

.side-panel .panel-card:nth-of-type(n+2) {
    padding: 15px;
}

.side-panel .panel-card:nth-of-type(n+3) {
    opacity: 0.9;
}

.history-chart {
    display: none;
}

.optimal-list {
    gap: 12px;
    padding: 13px 0;
}

.optimal-item {
    grid-template-columns: 38px minmax(0, 1fr) auto;
}

.optimal-item img {
    width: 34px;
    height: 44px;
}

.total-value {
    font-size: 24px;
}

.categories-hero {
    align-items: center;
    margin-bottom: 18px;
}

.categories-title {
    font-size: 32px;
}

.category-grid {
    gap: 14px;
}

.category-card {
    min-height: 178px;
    padding: 18px;
    border-radius: 12px;
    box-shadow: 0 10px 26px rgba(18, 33, 38, 0.07);
}

.category-card:hover,
.category-card:focus-visible,
.category-card.active {
    border-color: rgba(31, 111, 120, 0.34);
    box-shadow: 0 18px 38px rgba(18, 33, 38, 0.12);
}

.category-card.active {
    outline-color: rgba(31, 111, 120, 0.14);
}

.category-icon {
    color: var(--brand);
}

.category-card h3 {
    font-size: 22px;
}

.category-chip,
.subcategory-chip {
    min-height: 31px;
    padding: 6px 10px;
    font-size: 12px;
}

.category-open,
.subcategory-chip:hover {
    color: var(--brand);
}

@media (max-width: 1180px) {
    .content-grid { grid-template-columns: 220px minmax(0, 1fr); }
    .side-panel { grid-column: 1 / -1; grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .utility-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .category-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

.qty-controls {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-top: 4px;
}

.qty-btn {
    display: grid;
    place-items: center;
    width: 32px;
    height: 32px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: var(--panel);
    color: var(--ink);
    flex-shrink: 0;
}

.qty-btn:disabled { opacity: 0.4; cursor: not-allowed; }

.qty-num {
    min-width: 24px;
    text-align: center;
    font-weight: 700;
    font-size: 14px;
}

@media (max-width: 1024px) {
    .topbar {
        display: grid;
        grid-template-columns: 1fr auto;
        gap: 10px;
        padding-top: 12px;
        padding-bottom: 8px;
    }

    .brand { min-width: 0; }
    .brand-icon { width: 32px; height: 32px; border-radius: 10px; }
    .brand-title { font-size: 22px; }
    .brand-subtitle { display: none; }

    .nav-tabs-app { display: none; }

    /* FEEDBACK G: una sola fila (marca + acciones + hamburguesa) y el menu
       como dropdown, en vez del <select> que sumaba una fila al header. */
    .icon-btn.mobile-menu-toggle { display: inline-flex; }
    .mobile-menu {
        display: grid;
        grid-column: 1 / -1;
        gap: 2px;
        padding: 6px;
        border: 1px solid var(--line);
        border-radius: 12px;
        background: var(--panel);
        box-shadow: var(--shadow);
    }
    .mobile-menu[hidden] { display: none; }
    .mobile-menu button {
        min-height: 44px;
        padding: 0 14px;
        border: 0;
        border-radius: 8px;
        background: transparent;
        color: var(--ink);
        font: inherit;
        font-weight: 700;
        text-align: left;
    }
    .mobile-menu button.active {
        background: var(--brand-soft);
        color: var(--brand);
    }

    .top-actions {
        justify-content: end;
    }

    .icon-btn { width: 36px; height: 36px; }
    .home-intro { display: none; }
    .panel-card:has(#estadoDatos),
    .panel-card:has(.reason-list) { display: none; }
    .home-title { font-size: 28px; }
    .home-subtitle { font-size: 14px; }
    .home-actions {
        justify-content: stretch;
    }
    .action-chip {
        flex: 1 1 145px;
        min-height: 44px;
    }
    .hero-search { grid-template-columns: 1fr; }
    .prices-table { border-left: 0; border-top: 1px solid var(--line); }
    .categories-hero,
    .category-grid,
    .subcategory-head {
        grid-template-columns: 1fr;
    }
    .categories-hero,
    .subcategory-head {
        display: grid;
    }
    .categories-title { font-size: 30px; }

    .mobile-filter-toggle {
        display: flex;
        align-items: center;
        justify-content: space-between;
        min-height: 48px;
        padding: 0 14px;
        border: 1px solid var(--line);
        border-radius: 10px;
        background: var(--panel);
        color: var(--ink);
        font-weight: 900;
    }

    .filters.mobile-collapsed > :not(.mobile-filter-toggle) {
        display: none;
    }

    .start-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 560px) {
    .prices-header,
    .price-row,
    .product-info {
        grid-template-columns: 1fr;
    }

    .prices-header { display: none; }

    .home-title { font-size: 25px; }
    .search-input-wrap {
        min-height: 54px;
        padding: 0 14px;
    }
    .search-input-wrap input {
        font-size: 16px;
    }
    .hero-search .btn-go {
        min-height: 50px;
    }
    .action-chip {
        flex-basis: 100%;
    }
    .start-action {
        min-height: 140px;
        padding: 16px;
    }
}
