* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
img { -webkit-user-drag: none; }

:root {
    --green-10: #1B4332;
    --green-30: #2D6A4F;
    --green-40: #40916C;
    --green-80: #B7E4C7;
    --green-90: #D8F3DC;
    --accent: #E76F51;
    --red: #E63E11;
    --bg: #FAFAF7;
    --surface: #FFFFFF;
    --text-primary: #1A1A1A;
    --text-secondary: #6B7280;
    --text-tertiary: #9CA3AF;
    --border: #E8E8E4;
    --warm: #FEFAE0;
    --pill-bg: #F0F0EC;
    --nutri-a: #038141;
    --nutri-b: #85BB2F;
    --nutri-c: #FECB02;
    --nutri-d: #EE8100;
    --nutri-e: #E63E11;
}

html, body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--bg);
    color: var(--text-primary);
    height: 100%;
    overflow: hidden;
}

#app {
    display: flex;
    flex-direction: column;
    height: 100%;
    max-width: 480px;
    margin: 0 auto;
}

/* Header */
#header {
    padding: 10px 16px;
    background: var(--bg);
}
.header-logo {
    height: 48px;
    object-fit: contain;
}

/* Auth avatar */
#header {
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.auth-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 2px solid var(--border);
    background: var(--pill-bg);
    color: var(--text-tertiary);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    padding: 0;
    transition: all 0.2s;
}
.auth-avatar.logged-in {
    background: var(--green-30);
    border-color: var(--green-30);
    color: white;
}
#auth-initial {
    font-size: 16px;
    font-weight: 800;
    line-height: 1;
}

/* Auth modal */
.auth-modal {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.auth-modal-content {
    background: var(--surface);
    border-radius: 20px;
    padding: 24px;
    width: 100%;
    max-width: 360px;
    position: relative;
}
.auth-modal-content h2 {
    font-size: 20px;
    font-weight: 800;
    color: var(--text-primary);
    margin-bottom: 20px;
    text-align: center;
}
.auth-modal-close {
    position: absolute;
    top: 12px;
    right: 12px;
    background: none;
    border: none;
    font-size: 20px;
    color: var(--text-tertiary);
    cursor: pointer;
}
.auth-google-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    padding: 12px;
    border: 1.5px solid var(--border);
    border-radius: 12px;
    background: var(--surface);
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
    cursor: pointer;
}
.auth-google-btn:active {
    background: var(--pill-bg);
}
.auth-divider {
    display: flex;
    align-items: center;
    margin: 16px 0;
    color: var(--text-tertiary);
    font-size: 13px;
}
.auth-divider::before, .auth-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border);
}
.auth-divider span {
    padding: 0 12px;
}
.auth-input {
    width: 100%;
    padding: 12px 14px;
    border: 1.5px solid var(--border);
    border-radius: 12px;
    font-size: 15px;
    margin-bottom: 10px;
    outline: none;
    background: var(--bg);
    box-sizing: border-box;
}
.auth-input:focus {
    border-color: var(--green-40);
}
.auth-pw-wrap {
    position: relative;
    width: 100%;
}
.auth-pw-wrap .auth-input {
    padding-right: 44px;
}
.pw-toggle {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    padding: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    margin-bottom: 10px;
}
.pw-toggle .hidden { display: none; }
.city-suggestions {
    position: absolute;
    left: 0;
    right: 0;
    top: 100%;
    background: var(--bg);
    border-radius: 0 0 12px 12px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    z-index: 10;
    overflow: hidden;
}
.city-suggestion {
    padding: 12px 14px;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-top: 1px solid var(--border);
}
.city-suggestion:first-child { border-top: none; }
.city-suggestion:hover, .city-suggestion:active {
    background: var(--pill-bg);
}
.city-name {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
}
.city-province {
    font-size: 13px;
    color: var(--text-tertiary);
}
.auth-forgot {
    text-align: right;
    margin: -4px 0 8px;
}
.auth-forgot a {
    font-size: 13px;
    color: var(--text-tertiary);
    text-decoration: none;
}
.auth-forgot a:hover {
    color: var(--green-30);
    text-decoration: underline;
}
.auth-field-error {
    font-size: 12px;
    color: #EF4444;
    margin: -6px 0 8px 2px;
}
.auth-input-error {
    border-color: #EF4444 !important;
}
.pw-checklist {
    margin-bottom: 10px;
    padding: 8px 12px;
    background: var(--pill-bg);
    border-radius: 10px;
}
.pw-rule {
    font-size: 12px;
    line-height: 1.8;
    transition: color 0.2s;
}
.pw-rule-icon {
    display: inline-block;
    width: 16px;
    font-weight: 700;
}
.pw-rule-fail { color: #EF4444; }
.pw-rule-ok { color: #16A34A; }
.account-menu-links {
    display: flex;
    flex-direction: column;
    gap: 0;
    margin-bottom: 12px;
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid var(--border);
}
.account-menu-link {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 14px;
    border: none;
    background: var(--surface);
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    cursor: pointer;
    text-align: left;
    border-bottom: 1px solid var(--border);
}
.account-menu-link:last-child { border-bottom: none; }
.account-menu-link:active { background: var(--pill-bg); }
.auth-submit-btn {
    width: 100%;
    padding: 12px;
    border: none;
    border-radius: 12px;
    background: var(--green-30);
    color: white;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    margin-top: 4px;
}
.auth-submit-btn:active {
    background: var(--green-10);
}
.auth-switch {
    text-align: center;
    font-size: 13px;
    color: var(--text-tertiary);
    margin-top: 12px;
}
.auth-switch a {
    color: var(--green-30);
    font-weight: 700;
    cursor: pointer;
}

/* Search bar */
#search-bar {
    padding: 8px 16px 8px;
    position: sticky;
    top: 0;
    z-index: 10;
    background: var(--bg);
    position: relative;
}
.search-input-wrap {
    display: flex;
    align-items: center;
    background: var(--surface);
    border: 1.5px solid var(--border);
    border-radius: 16px;
    padding: 14px 16px;
    gap: 10px;
    transition: border-color 0.2s;
}
.search-input-wrap:focus-within {
    border-color: var(--green-40);
}
#autocomplete-dropdown {
    position: absolute;
    left: 0;
    right: 0;
    top: 100%;
    background: var(--surface);
    border: 1.5px solid var(--border);
    border-top: none;
    border-radius: 0 0 14px 14px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    z-index: 20;
    max-height: 250px;
    overflow-y: auto;
}
.ac-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    cursor: pointer;
    border-bottom: 1px solid var(--border);
}
.ac-item:last-child {
    border-bottom: none;
}
.ac-item:active {
    background: var(--pill-bg);
}
.ac-item-emoji {
    font-size: 20px;
    flex-shrink: 0;
}
.ac-item-info {
    flex: 1;
    min-width: 0;
}
.ac-item-name {
    font-size: 14px;
    font-weight: 600;
}
.ac-item-meta {
    font-size: 11px;
    color: var(--text-tertiary);
}
#search-bar {
    position: relative;
}
.search-icon { flex-shrink: 0; }
#search-input {
    flex: 1;
    border: none;
    outline: none;
    font-size: 16px;
    background: transparent;
    color: var(--text-primary);
}
#search-input::placeholder { color: var(--text-tertiary); }
#clear-btn {
    border: none;
    background: var(--pill-bg);
    color: var(--text-secondary);
    font-size: 18px;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

/* Chain filters */
#chain-filters {
    display: flex;
    gap: 8px;
    padding: 4px 16px 8px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}
#chain-filters::-webkit-scrollbar { display: none; }
#chain-filters.dragging { cursor: grabbing; user-select: none; }
#chain-filters { cursor: grab; }
.chain-pill {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 6px;
    background: var(--surface);
    border: 1.5px solid var(--border);
    border-radius: 24px;
    padding: 10px 18px;
    font-size: 16px;
    font-weight: 600;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.15s;
    white-space: nowrap;
}
.chain-pill .chain-count {
    font-size: 14px;
    font-weight: 700;
    color: var(--text-tertiary);
}
.chain-pill.active {
    background: var(--green-30);
    border-color: var(--green-30);
    color: white;
}
.chain-pill.active .chain-count {
    color: var(--green-80);
}

/* Sort/filter bar */
#sort-filters {
    display: flex;
    gap: 8px;
    padding: 0 16px 8px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}
#sort-filters::-webkit-scrollbar { display: none; }
#sort-filters.dragging { cursor: grabbing; user-select: none; }
#sort-filters { cursor: grab; }
.sort-pill {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 6px;
    background: var(--surface);
    border: 1.5px solid var(--border);
    border-radius: 24px;
    padding: 10px 18px;
    font-size: 16px;
    font-weight: 600;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.15s;
    white-space: nowrap;
}
.sort-pill.active {
    background: var(--green-30);
    border-color: var(--green-30);
    color: white;
}
.pill-dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    box-shadow: 0 1px 2px rgba(0,0,0,0.15);
    flex-shrink: 0;
}
.pill-dot-green { background: #16A34A; }
.sort-pill.active .pill-dot { box-shadow: 0 0 0 2px rgba(255,255,255,0.35); }
.sort-pill[data-premium="1"]::after {
    content: '⭐';
    font-size: 10px;
    margin-left: -2px;
}
.sort-pill[data-premium="1"].active::after { content: ''; }

/* Deals area */
#deals-area {
    flex: 1;
    overflow-y: auto;
    padding: 0 12px 16px;
    -webkit-overflow-scrolling: touch;
}
#home-tabs {
    display: flex;
    gap: 0;
    padding: 8px 4px;
}
.home-tab {
    flex: 1;
    background: none;
    border: none;
    border-bottom: 3px solid transparent;
    padding: 8px 0;
    font-size: 16px;
    font-weight: 700;
    color: var(--text-tertiary);
    cursor: pointer;
    transition: all 0.15s;
}
.fav-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--red);
    color: white;
    font-size: 11px;
    font-weight: 800;
    min-width: 18px;
    height: 18px;
    border-radius: 9px;
    padding: 0 5px;
    margin-left: 4px;
}
.home-tab.active {
    color: var(--green-30);
    border-bottom-color: var(--green-30);
}
#favourites-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}
#favourites-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 40vh;
    gap: 4px;
    color: var(--text-tertiary);
    font-size: 15px;
}
.deals-section-title {
    font-size: 20px;
    font-weight: 800;
    color: var(--text-primary);
    margin: 12px 0 10px;
}
#deals-carousel {
    display: flex;
    gap: 12px;
    overflow-x: auto;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 12px;
    margin-bottom: 8px;
    scroll-snap-type: x proximity;
}
#deals-carousel::-webkit-scrollbar { display: none; }
#deals-carousel { cursor: grab; }
.carousel-card {
    flex-shrink: 0;
    width: 200px;
    height: 260px;
    border-radius: 18px;
    cursor: pointer;
    position: relative;
    color: white;
    overflow: hidden;
    background: #f0f0f0;
    scroll-snap-align: start;
}
.carousel-bg {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #e8f5e9 0%, #c8e6c9 100%);
}
.carousel-bg img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.carousel-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    background: linear-gradient(to bottom, rgba(0,0,0,0) 35%, rgba(0,0,0,0.7) 100%);
    padding: 14px;
}
.carousel-badge {
    position: absolute;
    top: 10px;
    left: 10px;
    background: #E53E3E;
    color: white;
    font-size: 14px;
    font-weight: 900;
    padding: 4px 10px;
    border-radius: 10px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}
.carousel-store-logo {
    position: absolute;
    top: 10px;
    right: 10px;
    background: rgba(255,255,255,0.92);
    border-radius: 8px;
    padding: 4px 8px;
    display: flex;
    align-items: center;
    box-shadow: 0 1px 4px rgba(0,0,0,0.1);
}
.carousel-store-logo img { height: 16px; object-fit: contain; }
.carousel-store-text { font-size: 10px; font-weight: 800; color: #333; }
.carousel-info { z-index: 1; }
.carousel-name {
    font-size: 13px;
    font-weight: 700;
    line-height: 1.25;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    margin-bottom: 4px;
    text-shadow: 0 1px 4px rgba(0,0,0,0.4);
}
.carousel-prices {
    display: flex;
    align-items: baseline;
    gap: 6px;
}
.carousel-price {
    font-size: 20px;
    font-weight: 900;
    text-shadow: 0 1px 4px rgba(0,0,0,0.4);
}
.carousel-original {
    font-size: 13px;
    text-decoration: line-through;
    opacity: 0.75;
}

#deals-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}
.deal-card {
    background: var(--surface);
    border-radius: 16px;
    box-shadow: 0 1px 6px rgba(0,0,0,0.08);
    overflow: hidden;
    cursor: pointer;
    transition: box-shadow 0.15s;
}
.deal-card:active {
    box-shadow: 0 2px 12px rgba(0,0,0,0.15);
}
.deal-img {
    position: relative;
    width: 100%;
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    background: #f8f8f5;
}
.deal-img img {
    max-width: 80%;
    max-height: 80%;
    object-fit: contain;
}
.deal-emoji {
    font-size: 48px;
    line-height: 1;
}
.deal-sconto-badge {
    position: absolute;
    top: 8px;
    left: 8px;
    background: var(--red);
    color: white;
    font-size: 12px;
    font-weight: 800;
    padding: 4px 10px;
    border-radius: 8px;
    line-height: 1.2;
    text-align: center;
    z-index: 2;
}
.deal-img .fav-heart {
    top: 8px;
    right: 8px;
}
.deal-info {
    padding: 10px 12px 12px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.deal-name {
    font-size: 14px;
    font-weight: 700;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    color: var(--text-primary);
}
.deal-prices {
    display: flex;
    align-items: baseline;
    gap: 6px;
    margin-top: 2px;
}
.deal-price {
    font-size: 22px;
    font-weight: 900;
    color: var(--green-30);
}
.deal-price.deal-promo {
    color: var(--red);
}
.deal-original {
    font-size: 15px;
    color: var(--text-tertiary);
    text-decoration: line-through;
}
.deal-bottom {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 6px;
}
.deal-store-logo {
    height: 20px;
    object-fit: contain;
}
.deal-store-text {
    font-size: 11px;
    font-weight: 700;
    color: var(--text-secondary);
    text-transform: uppercase;
}
.deal-add-btn {
    background: var(--green-30);
    color: white;
    border: none;
    border-radius: 20px;
    padding: 6px 16px;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
}
.deal-add-btn.added {
    background: var(--red);
    color: white;
}

/* Results area */
#results-area {
    flex: 1;
    overflow-y: auto;
    padding: 0 16px 16px;
    -webkit-overflow-scrolling: touch;
}

#empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 60vh;
    gap: 12px;
    color: var(--text-tertiary);
    font-size: 14px;
}

#results-count {
    font-size: 12px;
    color: var(--text-tertiary);
    padding: 8px 4px 4px;
}

/* Loading spinner */
.spinner {
    width: 28px;
    height: 28px;
    border: 3px solid var(--border);
    border-top-color: var(--green-30);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
    margin: 40px auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Error */
#error-msg {
    text-align: center;
    color: var(--accent);
    padding: 20px;
    font-size: 13px;
}

/* Product card */
.product-card {
    background: var(--surface);
    border-radius: 16px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.07);
    margin-bottom: 10px;
    display: flex;
    padding: 12px;
    gap: 12px;
    cursor: pointer;
    transition: box-shadow 0.15s;
    position: relative;
}
.card-right {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.card-right-top {
    display: flex;
    gap: 8px;
    justify-content: space-between;
}
.card-action-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.product-card:active {
    box-shadow: 0 1px 8px rgba(0,0,0,0.13);
}

/* Image area */
.card-img {
    width: 110px;
    height: 110px;
    background: white;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    position: relative;
}
.card-img img {
    max-width: 95%;
    max-height: 95%;
    object-fit: contain;
}
.card-img {
    overflow: hidden;
}
.card-img .emoji {
    font-size: 44px;
    line-height: 1;
}

/* Fallback icon */
.fallback-icon {
    display: inline-block;
    width: 48px;
    height: 48px;
    background: url('icon.png?v=2') center/contain no-repeat;
    opacity: 0.6;
    border-radius: 10px;
}
.deal-img .fallback-icon {
    width: 40px;
    height: 40px;
}

/* Favourite heart */
.fav-heart {
    position: absolute;
    bottom: 2px;
    right: 2px;
    background: none;
    border: none;
    cursor: pointer;
    transform: rotate(-12deg);
    padding: 0;
    transition: transform 0.2s;
}
.fav-heart svg {
    fill: rgba(255,255,255,0.7);
    stroke: rgba(0,0,0,0.25);
    stroke-width: 1.5;
    filter: drop-shadow(0 1px 3px rgba(0,0,0,0.2));
    transition: fill 0.2s, stroke 0.2s;
}
.fav-heart.fav-active svg {
    fill: var(--red);
    stroke: white;
    stroke-width: 1.5;
    filter: drop-shadow(0 2px 4px rgba(230,62,17,0.3));
}
.fav-heart.fav-active {
    transform: rotate(-12deg) scale(1.15);
}

/* Center info */
.card-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.card-brand {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-tertiary);
}
.card-name {
    font-size: 19px;
    font-weight: 700;
    line-height: 1.25;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.card-meta {
    font-size: 14px;
    color: var(--text-tertiary);
}
.card-meta .brand {
    color: var(--text-secondary);
}

/* Badges row (nutriscore + nova) */
.card-badges {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 4px;
}
.nova-pie {
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}
.nova-pie-card {
    position: absolute;
    bottom: 6px;
    left: 6px;
    width: 22px;
    height: 22px;
    z-index: 2;
}
.nova-pie-detail {
    width: 28px;
    height: 28px;
}
.detail-nova-row {
    margin-top: 8px;
}
.nova-detail-wrap {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    padding: 6px 12px;
    background: var(--pill-bg);
    border-radius: 10px;
}
.nova-detail-label {
    font-size: 13px;
    font-weight: 800;
    letter-spacing: 0.5px;
}
.nova-popup-scale {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-bottom: 16px;
}
.nova-popup-item {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.4;
    transition: transform 0.2s;
}
.nova-popup-item span {
    font-size: 18px;
    font-weight: 900;
    color: white;
}
.nova-popup-active {
    opacity: 1;
    transform: scale(1.3);
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

/* Nutri-Score badge */
.nutri-badge {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    background: white;
    border-radius: 6px;
    padding: 3px 4px;
    cursor: pointer;
    border: 1px solid #555;
}
.ns-label {
    font-size: 5px;
    font-weight: 800;
    color: var(--text-tertiary);
    letter-spacing: 0.5px;
}
.ns-letters {
    display: flex;
    border-radius: 3px;
    overflow: hidden;
}
.ns-letter {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 11px;
    height: 13px;
    font-family: 'Arial Black', 'Helvetica Neue', Arial, sans-serif;
    font-size: 7px;
    font-weight: 900;
    color: white;
    opacity: 0.4;
}
.ns-letter.ns-active {
    width: 16px;
    height: 16px;
    font-size: 10px;
    opacity: 1;
    border-radius: 2px;
}
.ns-a { background: var(--nutri-a); }
.ns-b { background: var(--nutri-b); }
.ns-c { background: var(--nutri-c); color: #333; }
.ns-d { background: var(--nutri-d); }
.ns-e { background: var(--nutri-e); }

.card-nutri-overlay {
    position: absolute;
    bottom: 4px;
    left: 4px;
    z-index: 2;
}
.nutri-dot.active.score-a { background: #038141; }
.nutri-dot.active.score-b { background: #85BB2F; }
.nutri-dot.active.score-c { background: #FECB02; }
.nutri-dot.active.score-d { background: #EE8100; }
.nutri-dot.active.score-e { background: #E63E11; }

.nutri-dots { cursor: pointer; }
.nutri-popup {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.nutri-popup-content {
    background: var(--bg);
    border-radius: 20px;
    padding: 24px;
    max-width: 340px;
    width: 100%;
    position: relative;
    text-align: center;
}
.nutri-popup-content h3 {
    font-size: 18px;
    color: var(--text-primary);
    margin-bottom: 10px;
}
.nutri-popup-desc {
    font-size: 14px;
    color: var(--text-secondary);
    line-height: 1.5;
    margin-bottom: 16px;
}
.nutri-popup-scale {
    display: flex;
    justify-content: center;
    gap: 6px;
    margin-bottom: 16px;
}
.nutri-popup-item {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.4;
    transition: transform 0.2s;
}
.nutri-popup-item.nutri-popup-active {
    opacity: 1;
    transform: scale(1.3);
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}
.nutri-popup-letter {
    font-size: 16px;
    font-weight: 900;
    color: white;
}
.nutri-popup-item.score-a { background: #038141; }
.nutri-popup-item.score-b { background: #85BB2F; }
.nutri-popup-item.score-c { background: #FECB02; }
.nutri-popup-item.score-d { background: #EE8100; }
.nutri-popup-item.score-e { background: #E63E11; }
.nutri-popup-current {
    font-size: 15px;
    color: var(--text-primary);
    margin-bottom: 6px;
}
.nutri-popup-explain {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.5;
    margin-bottom: 12px;
}
.nutri-popup-source {
    font-size: 11px;
    color: var(--text-tertiary);
}

/* Card info wrapper (for qty overlay) */
.card-info-wrap {
    flex: 1;
    min-width: 0;
    position: relative;
}

/* Quantity overlay */
.qty-overlay {
    position: absolute;
    inset: 0;
    background: rgba(255,255,255,0.75);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 24px;
    z-index: 2;
}
.qty-circle {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    border: 2px solid var(--green-30);
    background: var(--surface);
    color: var(--green-30);
    font-size: 18px;
    font-weight: 800;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.qty-circle:active {
    background: var(--green-90);
}
.qty-big {
    font-size: 60px;
    font-weight: 900;
    color: var(--green-30);
    line-height: 1;
}

/* Store price pills */
.store-pills {
    display: flex;
    flex-direction: column;
    gap: 5px;
    margin-top: 6px;
}
.store-pill {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: var(--pill-bg);
    border-radius: 8px;
    padding: 5px 10px;
    font-size: 13px;
    width: fit-content;
}
.store-pill .store-name {
    color: var(--text-secondary);
    font-weight: 600;
}
.store-pill .store-price {
    color: var(--text-primary);
    font-weight: 700;
}

/* Vertical divider */
.card-divider {
    width: 1px;
    background: var(--border);
    align-self: stretch;
    margin: 4px 0;
    flex-shrink: 0;
}

/* Right price section */
.card-price-section {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    justify-content: flex-start;
    flex-shrink: 0;
    text-align: right;
}
.price-top {
    text-align: center;
}
.best-label {
    font-size: 10px;
    font-weight: 900;
    font-style: italic;
    color: white;
    background: var(--red);
    border-radius: 4px;
    padding: 2px 6px;
    display: inline-block;
    transform: rotate(-4deg);
    line-height: 1;
    margin-bottom: 2px;
}
.best-price {
    font-size: 22px;
    font-weight: 900;
    color: var(--green-30);
    line-height: 1.1;
    text-align: right;
}
.original-price {
    font-size: 12px;
    color: var(--text-tertiary);
    text-decoration: line-through;
}
.discount-square {
    position: absolute;
    top: 8px;
    left: 8px;
    background: var(--red);
    color: white;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Arial, sans-serif;
    font-size: 15px;
    font-weight: 800;
    padding: 5px 11px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2;
    border-radius: 4px;
    line-height: 1;
    box-shadow: 0 2px 6px rgba(0,0,0,0.2);
}
.best-store {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-top: 2px;
    text-align: right;
}
.unit-price {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-tertiary);
    margin-top: 2px;
}

/* Add button */
.report-price-btn {
    background: none;
    border: 1.5px solid var(--border);
    border-radius: 20px;
    padding: 8px 12px;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    cursor: pointer;
    white-space: nowrap;
}
.report-price-btn:active { background: var(--green-90); }
.cart-report-btn {
    background: none;
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 4px 8px;
    font-size: 10px;
    font-weight: 600;
    color: var(--text-secondary);
    cursor: pointer;
    margin-top: 4px;
    white-space: nowrap;
}
.cart-report-btn:active { background: var(--green-90); }
.list-item-right {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}
.list-report-btn.report-cancel {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
    padding: 4px 6px;
    font-size: 12px;
}
.list-report-btn {
    background: none;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 4px 8px;
    font-size: 10px;
    font-weight: 600;
    color: var(--text-secondary);
    cursor: pointer;
    white-space: nowrap;
    flex-shrink: 0;
}
.cart-report-btn.report-cancel {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
}
.cart-report-btn.report-cancel:active { background: #c55a3e; }
.report-price-btn.report-cancel {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
}
.report-price-btn.report-cancel:active { background: #c55a3e; }
.reported-price { color: #3B82F6 !important; }

/* Report price sheet */
.report-price-sheet {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
}
.report-price-content {
    background: var(--surface);
    border-radius: 20px;
    padding: 24px;
    width: 90%;
    max-width: 360px;
    animation: sheetUp 0.2s ease;
}
.report-price-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
}
.report-price-header h3 {
    font-size: 18px;
    font-weight: 700;
    margin: 0;
}
.report-price-header button {
    background: none;
    border: none;
    font-size: 18px;
    color: var(--text-secondary);
    cursor: pointer;
}
.report-price-store {
    margin-bottom: 16px;
}
.report-price-store label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 6px;
}
.report-price-store select {
    width: 100%;
    padding: 10px 12px;
    border: 1.5px solid var(--border);
    border-radius: 12px;
    font-size: 15px;
    background: var(--bg);
    color: var(--text-primary);
    -webkit-appearance: none;
}
.report-store-detail {
    font-size: 12px;
    color: var(--text-tertiary);
    margin-top: 4px;
    padding-left: 2px;
}
.report-store-name {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-primary);
    padding: 8px 0;
}
.report-price-field {
    margin-bottom: 20px;
}
.report-price-field label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 6px;
}
.report-price-input-wrap {
    display: flex;
    align-items: center;
    border: 1.5px solid var(--border);
    border-radius: 12px;
    padding: 10px 12px;
    background: var(--bg);
}
.report-currency {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-primary);
    margin-right: 6px;
}
.report-price-input-wrap input {
    flex: 1;
    border: none;
    background: none;
    font-size: 20px;
    font-weight: 700;
    color: var(--text-primary);
    outline: none;
    width: 100%;
}
.report-submit-btn {
    width: 100%;
    padding: 14px;
    background: var(--green-30);
    color: white;
    border: none;
    border-radius: 14px;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
}
.report-submit-btn:active { background: var(--green-10); }
.add-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    flex: 1;
    background: var(--green-30);
    color: white;
    border: none;
    border-radius: 20px;
    padding: 10px 0;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.15s;
}
.add-btn:active {
    background: var(--green-10);
}
.add-btn.added {
    background: var(--red);
    color: white;
    border-radius: 20px;
}
.add-btn .plus {
    font-size: 16px;
    font-weight: 900;
}

.card-cart-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    flex-wrap: nowrap;
}
.card-stepper {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--pill-bg);
    border-radius: 20px;
    padding: 6px 10px;
}
.card-step-btn {
    background: none;
    border: none;
    font-size: 16px;
    font-weight: 700;
    color: var(--text-primary);
    cursor: pointer;
    padding: 2px 4px;
    line-height: 1;
}
.card-stepper .qty-big {
    font-size: 15px;
    font-weight: 800;
    min-width: 16px;
    text-align: center;
}
.card-remove-btn {
    background: var(--red);
    border: none;
    color: white;
    border-radius: 20px;
    padding: 10px 0;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    white-space: nowrap;
    flex: 1;
    text-align: center;
}
.card-remove-btn:active {
    opacity: 0.8;
}

/* Card in cart indicator */
.product-card.in-cart {
    border-left: 3px solid var(--green-40);
}

/* Cart badge */
.cart-badge {
    position: absolute;
    top: 2px;
    right: 50%;
    transform: translateX(14px);
    background: var(--red);
    color: white;
    font-size: 10px;
    font-weight: 800;
    min-width: 16px;
    height: 16px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
    line-height: 1;
}

/* Cart bounce */
@keyframes cartBounce {
    0% { transform: scale(1); }
    50% { transform: scale(1.3); }
    100% { transform: scale(1); }
}
.cart-bounce {
    animation: cartBounce 0.3s ease;
}

/* Cart view */
#cart-view {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

#cart-list-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 6px;
}
.list-arrow {
    font-size: 14px;
    color: var(--text-tertiary);
}

/* Lists popup */
.lists-popup {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    top: 0;
    z-index: 60;
    background: rgba(0,0,0,0.4);
    display: flex;
    align-items: flex-end;
}
.lists-popup-content {
    background: var(--surface);
    border-radius: 20px 20px 0 0;
    padding: 16px;
    width: 100%;
    max-height: 60%;
}
.lists-popup-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 17px;
    font-weight: 700;
    margin-bottom: 12px;
}
.lists-popup-header button {
    background: none;
    border: none;
    font-size: 18px;
    color: var(--text-tertiary);
    cursor: pointer;
}
.lists-popup-items {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-bottom: 12px;
}
.lists-popup-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 14px;
    border-radius: 12px;
    cursor: pointer;
    border: 1.5px solid var(--border);
}
.lists-popup-item.active {
    background: var(--green-90);
    border-color: var(--green-40);
}
.lists-item-name {
    font-size: 15px;
    font-weight: 600;
}
.lists-item-delete {
    background: none;
    border: none;
    color: var(--text-tertiary);
    font-size: 16px;
    cursor: pointer;
}

#cart-stores {
    display: flex;
    gap: 8px;
    padding: 8px 16px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    flex-shrink: 0;
}
#cart-stores::-webkit-scrollbar { display: none; }
.cart-store-card {
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    background: var(--surface);
    border: 2px solid var(--border);
    border-radius: 16px;
    padding: 12px 10px 10px;
    cursor: pointer;
    transition: all 0.15s;
    position: relative;
    width: 112px;
    box-sizing: border-box;
}
.store-base-card {
    background: var(--green-90) !important;
    border-color: var(--green-40) !important;
}
.store-base-card.selected {
    background: var(--green-30) !important;
    border-color: var(--green-30) !important;
}
.store-base-card.selected .cart-store-name,
.store-base-card.selected .cart-store-count {
    color: white;
}
.cart-store-kg {
    font-size: 10px;
    font-weight: 700;
    color: var(--text-primary);
    background: var(--pill-bg);
    padding: 2px 6px;
    border-radius: 6px;
    white-space: nowrap;
}
.store-header-prices {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 2px;
}
.store-header-kg {
    font-size: 12px;
    color: var(--text-tertiary);
    cursor: pointer;
}
.store-coverage-warn {
    width: 100%;
    font-size: 12px;
    color: #92400E;
    background: #FEF3C7;
    border-radius: 8px;
    padding: 6px 10px;
    margin-top: 6px;
}
.kg-help-popup {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
}
.kg-help-content {
    background: var(--bg);
    border-radius: 16px;
    padding: 24px;
    max-width: 320px;
    text-align: center;
}
.kg-help-content b {
    font-size: 16px;
    display: block;
    margin-bottom: 12px;
}
.kg-help-content p {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.5;
    margin-bottom: 8px;
}
.kg-help-content button {
    background: var(--green-30);
    color: white;
    border: none;
    border-radius: 20px;
    padding: 10px 24px;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    margin-top: 8px;
}
.store-card-top {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
    flex: 1;
    gap: 2px;
}
.store-card-top.no-badge {
    justify-content: center;
}
.store-card-bottom {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
}
.store-badge-label {
    font-size: 11px;
    font-weight: 700;
    color: white;
    background: var(--green-30);
    padding: 3px 9px;
    border-radius: 7px;
    white-space: nowrap;
}
.cart-store-card .cart-store-name {
    font-size: 13px;
    font-weight: 700;
    color: var(--text-primary);
    text-align: center;
    line-height: 1.2;
    max-height: 2.4em;
    overflow: hidden;
}
.cart-store-card .cart-store-total {
    font-size: 17px;
    font-weight: 900;
    color: var(--green-30);
}
.cart-store-card .cart-store-count {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-tertiary);
}
.cart-store-card.selected {
    background: var(--green-90);
    border-color: var(--green-30);
}
.cart-store-card.store-dragging {
    opacity: 0.7;
    transform: scale(1.1);
    box-shadow: 0 4px 16px rgba(0,0,0,0.2);
}
.cart-store-card.skeleton .cart-store-total {
    animation: pulse 1s infinite;
}
@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}
.store-star {
    position: absolute;
    top: -10px;
    right: -10px;
    font-size: 28px;
    line-height: 1;
    cursor: pointer;
}
.cart-item.unavailable {
    opacity: 0.7;
}
.cart-subs-banner {
    font-size: 12px;
    font-weight: 700;
    color: var(--green-30);
    background: var(--green-90);
    padding: 3px 10px;
    border-radius: 10px;
    margin-top: 3px;
    cursor: pointer;
    width: fit-content;
}
.cart-subs-banner:active {
    background: var(--green-80);
}
.cart-subs-undo {
    background: var(--warm);
    color: var(--accent);
}
.cart-subs-undo:active {
    background: #fef3c7;
}
.cart-item.substituted {
    border-left: 3px solid var(--accent);
}

/* Substitutes panel */
.subs-panel {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    max-height: 60%;
    background: var(--surface);
    border-radius: 16px 16px 0 0;
    box-shadow: 0 -4px 20px rgba(0,0,0,0.15);
    z-index: 50;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.subs-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
    font-size: 15px;
    font-weight: 700;
}
.subs-panel-close {
    background: none;
    border: none;
    font-size: 18px;
    color: var(--text-tertiary);
    cursor: pointer;
}
.subs-panel-list {
    overflow-y: auto;
    padding: 8px 16px;
    -webkit-overflow-scrolling: touch;
}
.subs-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
}
.subs-item:active {
    background: var(--pill-bg);
}
.subs-item-info {
    flex: 1;
    min-width: 0;
}
.subs-item-name {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
}
.subs-item-weight {
    font-size: 12px;
    color: var(--text-tertiary);
}
.subs-item-price {
    font-size: 16px;
    font-weight: 800;
    color: var(--green-30);
    flex-shrink: 0;
    margin-left: 10px;
}
.cart-item.unavailable .cart-item-price {
    color: var(--text-tertiary);
    font-size: 13px;
}

#cart-alt-row {
    display: flex;
    align-items: center;
    padding: 4px 16px 8px;
    gap: 8px;
    flex-shrink: 0;
    overflow: visible;
}
#cart-alt-row, #cart-filter-icons, #cart-list-header, #cart-filters {
    overflow: visible !important;
}
#cart-filter-icons {
    display: flex;
    gap: 6px;
    justify-content: center;
    flex: 1;
}
#cart-alt-icon {
    font-size: 24px;
    opacity: 0.3;
    pointer-events: none;
    flex-shrink: 0;
}
#cart-list-header {
    display: flex;
    align-items: center;
    padding: 4px 16px;
    border-bottom: 1px solid var(--border);
    position: relative;
    overflow: visible;
}
#cart-list-header #cart-list-name-old {
    display: none;
}
#cart-sort-reparto, #cart-sort-price {
    background: none;
    border: 1.5px solid var(--border);
    border-radius: 10px;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    padding: 4px 12px;
    color: var(--text-tertiary);
    -webkit-tap-highlight-color: transparent;
    position: relative;
    transition: all 0.15s;
    overflow: visible;
    z-index: 5;
}
#cart-sort-price {
    margin-left: auto;
}
/* Substitutes panel */
.subs-sheet {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 9999;
    display: flex;
    align-items: flex-end;
    justify-content: center;
}
.subs-sheet-content {
    background: var(--bg);
    border-radius: 20px 20px 0 0;
    padding: 0;
    width: 100%;
    max-width: 480px;
    height: 90vh;
    display: flex;
    flex-direction: column;
    animation: sheetUp 0.25s ease;
    overflow: hidden;
}

/* Subs hero — leaf image as full-width header */
.subs-hero {
    position: relative;
    min-height: 72px;
    background: linear-gradient(135deg, var(--green-30), var(--green-40, #52b788));
    border-radius: 20px 20px 0 0;
    padding: 18px 60px 18px 20px;
    display: flex;
    align-items: flex-end;
    flex-shrink: 0;
    overflow: hidden;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
}
.subs-hero.has-hero {
    min-height: 170px;
}
.subs-hero-overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg, rgba(0,0,0,0.1) 0%, rgba(0,0,0,0) 35%, rgba(0,0,0,0.7) 100%);
    pointer-events: none;
}
.subs-hero:not(.has-hero) .subs-hero-overlay { display: none; }
.subs-hero-close {
    position: absolute;
    top: 14px;
    right: 14px;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(255,255,255,0.92);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    border: none;
    font-size: 16px;
    font-weight: 800;
    color: #111;
    cursor: pointer;
    z-index: 3;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}
.subs-hero-text {
    position: relative;
    z-index: 2;
    color: #fff;
    max-width: 100%;
}
.subs-hero-label {
    font-size: 12px;
    font-weight: 700;
    opacity: 0.85;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    text-shadow: 0 1px 3px rgba(0,0,0,0.5);
    margin-bottom: 2px;
}
.subs-hero:not(.has-hero) .subs-hero-label { opacity: 1; }
.subs-hero-title {
    font-size: 20px;
    font-weight: 900;
    line-height: 1.15;
    margin: 0;
    letter-spacing: -0.3px;
    text-shadow: 0 2px 6px rgba(0,0,0,0.55);
}
.subs-hero:not(.has-hero) .subs-hero-title { text-shadow: none; }
.subs-filters {
    padding: 12px 16px 8px;
}
.subs-list {
    padding: 0 16px 16px;
    overflow-y: auto;
    flex: 1;
}
.subs-sheet-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}
.subs-sheet-header h3 {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
    flex: 1;
    text-align: center;
}
.subs-sheet-header button {
    background: var(--pill-bg);
    border: none;
    font-size: 18px;
    color: var(--text-secondary);
    cursor: pointer;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.subs-current-product {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 12px;
    background: var(--green-90);
    border-radius: 10px;
    margin-bottom: 10px;
    font-size: 13px;
    color: var(--text-secondary);
}
.subs-current-price {
    font-weight: 800;
    color: var(--green-30);
}
.subs-filters {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    scrollbar-width: none;
    margin-bottom: 12px;
    padding-bottom: 4px;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-x;
    flex-shrink: 0;
    cursor: grab;
}
.subs-filters::-webkit-scrollbar { display: none; }
.subs-filter-btn {
    border-radius: 20px;
    border: 1.5px solid var(--border);
    background: var(--surface);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    padding: 6px 14px;
    white-space: nowrap;
    transition: all 0.15s;
    color: var(--text-primary);
}
.subs-filter-btn.active {
    border-color: var(--green-30);
    background: var(--green-90);
    color: var(--green-10);
}
.subs-list {
    overflow-y: auto;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.subs-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: var(--surface);
    border-radius: 14px;
    border: 1.5px solid var(--border);
    cursor: pointer;
    transition: all 0.15s;
}
.subs-card:active {
    background: var(--pill-bg);
}
.subs-card-first {
    background: var(--green-30);
    border-color: var(--green-30);
}
.subs-card-first .subs-card-name,
.subs-card-first .subs-card-brand,
.subs-card-first .subs-card-price {
    color: white;
}
.subs-card-first .subs-card-price-original {
    color: rgba(255,255,255,0.6);
}
.subs-card-first .subs-card-price.subs-promo-price {
    color: #FCA5A5;
}
.subs-card-first .subs-card-meta span {
    color: rgba(255,255,255,0.8);
}
.subs-card-first .subs-nutri {
    background: rgba(255,255,255,0.2);
    color: white;
}
.subs-card-img {
    width: 56px;
    height: 56px;
    border-radius: 10px;
    background: var(--pill-bg);
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    position: relative;
}
.subs-card-first .subs-card-img {
    background: rgba(255,255,255,0.15);
}
.subs-card-img img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}
.subs-card-body {
    flex: 1;
    min-width: 0;
}
.subs-card-top {
    display: flex;
    gap: 8px;
}
.subs-card-info {
    flex: 1;
    min-width: 0;
}
.subs-card-name {
    font-size: 15px;
    font-weight: 700;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    cursor: pointer;
}
.subs-card-name:active {
    text-decoration: underline;
}
.subs-card-brand {
    font-size: 13px;
    color: var(--text-secondary);
    margin-top: 1px;
}
.subs-card-weight {
    font-size: 12px;
    color: var(--text-tertiary);
    margin-top: 1px;
}
.subs-card-scores {
    display: flex;
    gap: 10px;
    align-items: center;
    margin-top: 6px;
}
.subs-card-scores .nutri-badge {
    padding: 2px 4px;
}
.subs-card-scores .ns-label {
    font-size: 6px;
}
.nova-subs-wrap {
    display: flex;
    align-items: center;
    gap: 4px;
    cursor: pointer;
}
.nova-pie-subs {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    flex-shrink: 0;
}
.nova-subs-label {
    font-size: 11px;
    font-weight: 700;
}
.subs-card-first .nova-subs-label {
    color: rgba(255,255,255,0.8) !important;
}
.subs-nutri {
    padding: 1px 8px;
    border-radius: 6px;
    font-weight: 700;
    font-size: 11px;
}
.subs-nutri-a { background: var(--nutri-a); color: white; }
.subs-nutri-b { background: var(--nutri-b); color: white; }
.subs-nutri-c { background: var(--nutri-c); color: #333; }
.subs-nutri-d { background: var(--nutri-d); color: white; }
.subs-nutri-e { background: var(--nutri-e); color: white; }
.subs-card-right {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 4px;
    flex-shrink: 0;
}
.subs-card-heart {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
}
.subs-card-heart svg {
    display: block;
}
.subs-card-price-original {
    font-size: 12px;
    color: var(--text-tertiary);
    text-decoration: line-through;
}
.subs-card-price {
    font-size: 18px;
    font-weight: 800;
    color: var(--green-30);
}
.subs-card-price.subs-promo-price {
    color: var(--red);
}
.subs-item {
    display: flex;
    align-items: center;
    padding: 10px 8px;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    gap: 8px;
}
.subs-item:active {
    background: var(--pill-bg);
}
.subs-item.subs-current {
    background: var(--green-90);
    border-left: 3px solid var(--green-30);
}
.subs-item-info {
    flex: 1;
}
.subs-item-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    line-height: 1.3;
}
.subs-item-badges {
    display: flex;
    gap: 4px;
    margin-top: 4px;
    flex-wrap: wrap;
}
.subs-badge {
    font-size: 10px;
    font-weight: 700;
    padding: 1px 6px;
    border-radius: 6px;
    background: var(--pill-bg);
    color: var(--text-secondary);
}
.subs-nutri-a { background: #D1FAE5; color: #038141; }
.subs-nutri-b { background: #E8F5E9; color: #85BB2F; }
.subs-nutri-c { background: #FEF9C3; color: #A16207; }
.subs-nutri-d { background: #FEF3C7; color: #EE8100; }
.subs-nutri-e { background: #FEE2E2; color: #E63E11; }
.subs-nova { background: var(--pill-bg); }
.subs-bio { background: #D1FAE5; }
.subs-promo { background: #FEF3C7; }
.subs-pl { background: #E0E7FF; }
.subs-item-price {
    font-size: 16px;
    font-weight: 800;
    color: var(--green-30);
    flex-shrink: 0;
}
.cart-subs-link {
    font-size: 12px;
    font-weight: 600;
    color: var(--green-30);
    margin-top: 2px;
    cursor: pointer;
}

.reparto-sheet {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 9999;
    display: flex;
    align-items: flex-end;
    justify-content: center;
}
.reparto-sheet-content {
    background: var(--bg);
    border-radius: 20px 20px 0 0;
    padding: 16px;
    width: 100%;
    max-width: 480px;
    max-height: 70vh;
    display: flex;
    flex-direction: column;
    animation: sheetUp 0.25s ease;
}
@keyframes sheetUp {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
}
@keyframes sheetDown {
    from { transform: translateY(0); }
    to { transform: translateY(100%); }
}
.reparto-sheet-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
}
.reparto-sheet-header h3 {
    flex: 1;
    font-size: 22px;
    font-weight: 800;
    color: var(--text-primary);
}
.reparto-sheet-header button {
    background: none;
    border: none;
    font-size: 16px;
    font-weight: 700;
    color: var(--text-tertiary);
    cursor: pointer;
    padding: 6px 10px;
}
.reparto-sheet-hint {
    font-size: 14px;
    color: var(--text-tertiary);
    margin-bottom: 12px;
    line-height: 1.4;
}
.reparto-list {
    overflow-y: auto;
    flex: 1;
    touch-action: pan-y;
    -webkit-overflow-scrolling: touch;
}
.reparto-row {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 16px 10px;
    border-bottom: 1px solid var(--border);
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
    background: var(--bg);
    user-select: none;
    -webkit-user-select: none;
    -webkit-user-drag: none;
    -webkit-touch-callout: none;
}
.reparto-row.dragging {
    opacity: 0.5;
    background: var(--green-90);
}
.reparto-handle {
    font-size: 24px;
    color: var(--text-tertiary);
    cursor: grab;
    touch-action: none;
}
.reparto-save-btn {
    margin-top: 14px;
    padding: 15px;
    border: none;
    border-radius: 14px;
    background: var(--green-30);
    color: white;
    font-size: 18px;
    font-weight: 800;
    cursor: pointer;
}
#cart-sort-reparto.sort-active, #cart-sort-price.sort-active {
    color: var(--green-30);
    border-color: var(--green-30);
    background: var(--green-90);
}
.cart-filter-icon {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    border: 2px solid var(--border);
    background: var(--surface);
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    -webkit-tap-highlight-color: transparent;
    transition: all 0.2s;
}
.cart-filter-icon.active {
    border-color: var(--green-30);
    background: var(--green-90);
    transform: scale(1.1);
}
.cart-filter-icon {
    position: relative;
}
.filter-tooltip {
    position: fixed;
    background: var(--green-30);
    color: white;
    font-size: 14px;
    font-weight: 700;
    padding: 6px 14px;
    border-radius: 10px;
    white-space: nowrap;
    pointer-events: none;
    animation: tooltipPop 1.5s ease forwards;
    z-index: 9999;
}
@keyframes tooltipPop {
    0% { opacity: 0; transform: translateX(-50%) translateY(4px); }
    10% { opacity: 1; transform: translateX(-50%) translateY(0); }
    75% { opacity: 1; }
    100% { opacity: 0; }
}
.cart-filter-pill {
    flex-shrink: 0;
    background: var(--surface);
    border: 1.5px solid var(--border);
    border-radius: 20px;
    padding: 8px 14px;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-secondary);
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.15s;
}
.cart-filter-pill.active {
    background: var(--green-30);
    border-color: var(--green-30);
    color: white;
}
.cart-filter-banner {
    background: var(--warm) !important;
    color: var(--accent) !important;
}

#cart-list {
    flex: 1;
    overflow-y: auto;
    padding: 0 16px 90px;
    -webkit-overflow-scrolling: touch;
}
/* Optimize grid */
.reparto-section {
    margin-bottom: 16px;
}
.reparto-title {
    font-size: 19px;
    font-weight: 800;
    color: var(--text-primary);
    padding: 10px 0 8px;
    letter-spacing: -0.2px;
}
.opt-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}
.opt-card {
    background: var(--surface);
    border: 2px solid var(--green-30);
    border-radius: 12px;
    overflow: visible;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    min-width: 0;
}
.opt-card-remove {
    position: absolute;
    top: -6px;
    left: -6px;
    width: 24px;
    height: 24px;
    background: var(--red);
    color: white;
    border: 2px solid white;
    border-radius: 50%;
    font-size: 12px;
    font-weight: 800;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 10;
    box-shadow: 0 1px 4px rgba(0,0,0,0.2);
}
.opt-card {
    position: relative;
}
.opt-card-editing {
    animation: shake 0.3s;
}
@keyframes wobble {
    0% { transform: rotate(0deg); }
    25% { transform: rotate(-1.5deg); }
    50% { transform: rotate(1.5deg); }
    75% { transform: rotate(-1deg); }
    100% { transform: rotate(0deg); }
}
.opt-card-editing {
    animation: wobble 0.6s ease infinite;
    position: relative;
    z-index: 5;
}
.opt-card.unavailable > *:not(.opt-card-info) {
    opacity: 0.4;
}
.opt-card.unavailable .opt-card-info > *:not(.cart-report-btn) {
    opacity: 0.4;
}
.opt-unavail-label {
    position: absolute;
    bottom: 4px;
    left: 0;
    right: 0;
    text-align: center;
    font-size: 10px;
    font-weight: 700;
    color: white;
    background: rgba(0,0,0,0.5);
    padding: 2px 0;
    border-radius: 0 0 10px 10px;
}
.list-item.unavailable {
    opacity: 0.4;
}
.opt-card-img {
    position: relative;
    width: 100%;
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    background: white;
    overflow: hidden;
    border-radius: 10px 10px 0 0;
}
.opt-card-img img {
    max-width: 90%;
    max-height: 90%;
    object-fit: contain;
}
.opt-card-info {
    padding: 6px 8px 8px;
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    overflow: hidden;
}
.opt-card-name {
    font-size: 15px;
    font-weight: 700;
    line-height: 1.25;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    overflow-wrap: break-word;
    word-break: break-word;
}
.opt-card-weight {
    font-size: 12px;
    color: var(--text-tertiary);
    margin-top: 2px;
}
.opt-card-price {
    font-size: 22px;
    font-weight: 900;
    color: var(--green-30);
    margin-top: auto;
    padding-top: 6px;
    letter-spacing: -0.5px;
}
/* Stepper pill overlay on the image bottom (+20% over original) */
.opt-card-stepper {
    position: absolute;
    bottom: 6px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: 5px;
    background: rgba(255,255,255,0.96);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    border-radius: 18px;
    padding: 4px 5px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.12), 0 0 0 1px rgba(0,0,0,0.04);
    z-index: 3;
}
.opt-step-btn {
    width: 26px;
    height: 26px;
    border: none;
    border-radius: 50%;
    background: var(--green-30, #2D6A4F);
    color: #fff;
    font-size: 18px;
    font-weight: 800;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}
.opt-step-btn:active { transform: scale(0.88); }
.opt-step-trash { background: var(--red, #C92A2A); }
.opt-step-qty {
    min-width: 20px;
    text-align: center;
    font-size: 16px;
    font-weight: 800;
    color: var(--green-30, #2D6A4F);
    padding: 0 3px;
    line-height: 1;
}
.opt-card-img .opt-unavail-label {
    bottom: 42px;
}

/* Level card */
.stats-level-card {
    background: linear-gradient(135deg, #2D6A4F, #40916C);
    border-radius: 16px;
    padding: 16px 18px;
    margin-bottom: 14px;
    color: #fff;
}
.stats-level-head {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 8px;
}
.stats-level-title {
    font-size: 17px;
    font-weight: 900;
}
.stats-level-xp {
    font-size: 13px;
    font-weight: 700;
    opacity: 0.85;
}
.stats-level-bar {
    height: 8px;
    background: rgba(255,255,255,0.25);
    border-radius: 4px;
    overflow: hidden;
}
.stats-level-fill {
    height: 100%;
    background: #FFD700;
    border-radius: 4px;
    transition: width 0.4s;
}
.stats-level-next {
    font-size: 11px;
    opacity: 0.75;
    margin-top: 6px;
    text-align: right;
}

/* Badges / Achievements */
.stats-badges-subtitle {
    font-size: 12px;
    font-weight: 800;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.4px;
    margin: 6px 0 8px;
}
.stats-badges-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 10px;
    margin-bottom: 14px;
}
.stats-badge {
    background: var(--surface);
    border: 2.5px solid var(--border);
    border-radius: 16px;
    padding: 10px 6px 8px;
    text-align: center;
    cursor: pointer;
    transition: transform 0.1s;
}
.stats-badge:active { transform: scale(0.95); }
.stats-badge-locked {
    opacity: 0.45;
    filter: grayscale(0.6);
}
.stats-badge-icon {
    font-size: 32px;
    line-height: 1;
    margin-bottom: 4px;
}
.stats-badge-stars {
    font-size: 24px;
    letter-spacing: 3px;
    margin-bottom: 3px;
    line-height: 1;
}
.stats-badge-title {
    font-size: 10px;
    font-weight: 800;
    color: var(--text-primary);
    line-height: 1.2;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}
.stats-badges-progress-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.stats-badge-progress {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    background: var(--surface);
    border: 1.5px solid var(--border);
    border-radius: 14px;
}
.stats-badge-progress-icon {
    font-size: 28px;
    flex-shrink: 0;
    opacity: 0.5;
    filter: grayscale(0.5);
}
.stats-badge-progress-body {
    flex: 1;
    min-width: 0;
}
.stats-badge-progress-head {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 2px;
}
.stats-badge-progress-title {
    font-size: 14px;
    font-weight: 800;
    color: var(--text-primary);
}
.stats-badge-progress-count {
    font-size: 12px;
    font-weight: 700;
    color: var(--green-30);
}
.stats-badge-progress-desc {
    font-size: 11px;
    color: var(--text-tertiary);
    margin-bottom: 6px;
}
.stats-badge-progress-bar {
    height: 6px;
    background: var(--bg);
    border-radius: 3px;
    overflow: hidden;
}
.stats-badge-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--green-30), var(--green-40, #52b788));
    border-radius: 3px;
    transition: width 0.4s;
}

/* Insights cards (rule engine output) */
.stats-insights-grid {
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.stats-insight-card {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    padding: 16px 18px;
    border-radius: 16px;
    border: 1.5px solid var(--border);
    background: var(--surface);
}
.stats-insight-good {
    background: linear-gradient(135deg, #EDF8EF, #D8F3DC);
    border-color: var(--green-40, #52b788);
}
.stats-insight-warn {
    background: linear-gradient(135deg, #FEF3C7, #FDE68A);
    border-color: #E76F51;
}
.stats-insight-info {
    background: var(--surface);
    border-color: var(--border);
}
.stats-insight-icon {
    font-size: 28px;
    flex-shrink: 0;
    line-height: 1;
    margin-top: 2px;
}
.stats-insight-body {
    flex: 1;
    min-width: 0;
}
.stats-insight-title {
    font-size: 15px;
    font-weight: 800;
    color: var(--text-primary);
    margin-bottom: 4px;
}
.stats-insight-good .stats-insight-title { color: #1B4332; }
.stats-insight-warn .stats-insight-title { color: #78350F; }
.stats-insight-text {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.45;
}
.stats-insight-good .stats-insight-text { color: #2D6A4F; }
.stats-insight-warn .stats-insight-text { color: #92400E; }

/* Spend chart */
.chart-toggle-row {
    display: flex;
    gap: 6px;
    margin: 12px 0;
}
.chart-toggle-btn {
    flex: 1;
    border: 1.5px solid var(--border);
    background: var(--surface);
    border-radius: 12px;
    padding: 10px 8px;
    font-size: 13px;
    font-weight: 700;
    color: var(--text-primary);
    cursor: pointer;
    font-family: inherit;
    transition: all 0.15s;
}
.chart-toggle-btn.active {
    background: var(--green-30);
    border-color: var(--green-30);
    color: #fff;
}
.chart-toggle-btn:active { transform: scale(0.97); }
.chart-container {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding: 10px 0;
    scrollbar-width: none;
}
.chart-container::-webkit-scrollbar { display: none; }
.chart-summary {
    display: flex;
    justify-content: space-between;
    font-size: 13px;
    color: var(--text-secondary);
    padding-top: 8px;
    border-top: 1px solid var(--border);
    margin-top: 8px;
}
.chart-summary b { color: var(--green-30); }

/* Confirm dialog */
.confirm-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    animation: confirm-fade 0.15s ease;
}
@keyframes confirm-fade { from { opacity: 0; } to { opacity: 1; } }
.confirm-dialog {
    background: var(--surface, #fff);
    border-radius: 18px;
    padding: 22px 20px 14px;
    max-width: 320px;
    width: 100%;
    box-shadow: 0 20px 50px rgba(0,0,0,0.25);
}
.confirm-message {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary, #111);
    line-height: 1.4;
    text-align: center;
    margin-bottom: 18px;
}
.confirm-actions {
    display: flex;
    gap: 10px;
}
.confirm-actions button {
    flex: 1;
    border: none;
    border-radius: 12px;
    padding: 12px 14px;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    font-family: inherit;
}
.confirm-cancel {
    background: var(--bg, #F5F5F1);
    color: var(--text-primary, #111);
}
.confirm-ok {
    background: var(--green-30, #2D6A4F);
    color: #fff;
}
.confirm-ok.confirm-danger {
    background: var(--red, #C92A2A);
}
.confirm-actions button:active { transform: scale(0.97); }
.opt-card .cart-subs-btn {
    margin-top: 6px;
    font-size: 14px;
    padding: 7px 12px;
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}
.opt-card .cart-report-btn {
    font-size: 14px;
    padding: 7px 12px;
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}

/* List mode items */
.list-reparto-section {
    margin-bottom: 12px;
}
.list-reparto-card {
    border: 1.5px solid var(--border);
    border-radius: 16px;
    padding: 12px 14px;
    background: var(--surface);
    margin: 0;
}
.list-reparto-title {
    font-size: 17px;
    font-weight: 800;
    color: var(--text-primary);
    padding: 0 8px;
}
.list-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 0;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
}
.list-item:last-child {
    border-bottom: none;
}
.list-check {
    flex-shrink: 0;
    cursor: pointer;
}
.list-item-info {
    flex: 1;
    min-width: 0;
}
.list-item-name {
    font-size: 17px;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.25;
}
.list-checked .list-item-name {
    color: var(--text-primary);
    opacity: 0.5;
}
.list-item-meta {
    font-size: 14px;
    color: var(--text-tertiary);
    margin-top: 3px;
}
.list-item-price {
    font-size: 20px;
    font-weight: 900;
    color: var(--green-30);
    flex-shrink: 0;
    letter-spacing: -0.3px;
}
.list-checked .list-item-price {
    opacity: 0.5;
}
.list-percorso-btn-wrap {
    position: fixed;
    bottom: 70px;
    right: 16px;
    z-index: 50;
}
.list-percorso-btn {
    background: var(--green-30);
    color: white;
    border: none;
    border-radius: 24px;
    padding: 12px 28px;
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 2px 12px rgba(0,0,0,0.15);
}

.cart-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
    position: relative;
    cursor: pointer;
    transition: opacity 0.2s;
}
.cart-item-img {
    width: 56px;
    height: 56px;
    border-radius: 10px;
    background: var(--pill-bg);
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    position: relative;
}
.cart-item-img img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}
.cart-item-emoji {
    font-size: 28px;
}
.cart-item-qty-badge {
    position: absolute;
    bottom: -4px;
    left: -4px;
    width: 24px;
    height: 24px;
    background: var(--green-30);
    color: white;
    font-size: 11px;
    font-weight: 800;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 2;
    border: 2px solid var(--bg);
}
.cart-item-body {
    flex: 1;
    min-width: 0;
}
.cart-subs-btn {
    display: inline-block;
    margin-top: 4px;
    padding: 4px 14px;
    background: var(--green-30);
    color: white;
    font-size: 11px;
    font-weight: 700;
    border: none;
    border-radius: 20px;
    cursor: pointer;
}
.cart-item-unavail {
    font-size: 11px;
    color: var(--red);
    margin-top: 2px;
}
.cart-item.cart-dragging {
    opacity: 0.6;
    background: var(--green-90);
    box-shadow: 0 4px 16px rgba(0,0,0,0.15);
    z-index: 10;
    border-radius: 8px;
}
.cart-item.cart-checked {
    opacity: 0.5;
    background: var(--green-90);
    border-radius: 8px;
    padding-left: 8px;
    padding-right: 8px;
}
.cart-item.cart-checked .cart-item-name {
    text-decoration: line-through;
    color: var(--green-30);
}
.lists-item-actions {
    display: flex;
    gap: 4px;
    align-items: center;
}
.lists-item-edit {
    background: none;
    border: none;
    font-size: 14px;
    cursor: pointer;
    padding: 2px 4px;
}
.cart-check {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 22px;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    border: 1.5px solid var(--border);
    border-radius: 6px;
    background: none;
    transition: all 0.15s;
}
.cart-check.checked {
    border-color: transparent;
}
.cart-item-overlay {
    position: absolute;
    inset: 0;
    background: rgba(255,255,255,0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 20px;
    z-index: 2;
    border-radius: 8px;
}
.qty-stepper {
    display: inline-flex;
    align-items: center;
    background: var(--green-30);
    border-radius: 999px;
    height: 40px;
    user-select: none;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}
.qty-step-btn {
    width: 44px;
    height: 40px;
    border: none;
    background: none;
    color: white;
    font-size: 20px;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    -webkit-tap-highlight-color: transparent;
}
.qty-step-btn:active {
    background: rgba(255,255,255,0.15);
    border-radius: 999px;
}
.qty-step-val {
    min-width: 32px;
    text-align: center;
    font-size: 18px;
    font-weight: 900;
    color: white;
    line-height: 1;
}
.qty-bump {
    animation: qtyBump 0.2s ease;
}
@keyframes qtyBump {
    0% { transform: scale(1.4); }
    100% { transform: scale(1); }
}
.cart-item-qty {
    width: 30px;
    height: 30px;
    background: var(--green-30);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 800;
    flex-shrink: 0;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}
.cart-item-qty:active {
    transform: scale(0.9);
}
.cart-item-info {
    flex: 1;
    cursor: pointer;
    min-width: 0;
}
.cart-item-name {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
    line-height: 1.3;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.cart-item-ref {
    font-size: 13px;
    color: var(--text-tertiary);
    margin-top: 2px;
}
.cart-item-fill {
    font-size: 13px;
    color: var(--green-30);
    margin-top: 2px;
}
.cart-item-locked {
    font-size: 11px;
    color: var(--text-tertiary);
    margin-top: 2px;
}
.cart-heart {
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
    flex-shrink: 0;
    -webkit-tap-highlight-color: transparent;
}
.cart-heart svg {
    fill: none;
    stroke: var(--text-tertiary);
    stroke-width: 2;
}
.cart-heart.fav-active svg {
    fill: var(--red);
    stroke: var(--red);
}
.cart-item-weight {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-tertiary);
    white-space: nowrap;
}
.cart-list-mode-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 16px;
    width: 100%;
}
.cart-list-store-info {
    flex: 1;
    text-align: left;
}
.cart-list-store-name {
    font-size: 24px;
    font-weight: 800;
    color: var(--text-primary);
}
.cart-list-store-sub {
    font-size: 13px;
    color: var(--text-tertiary);
}
.cart-list-store-total {
    font-size: 22px;
    font-weight: 900;
    color: var(--green-30);
}
.optimize-logo {
    position: relative;
}
.optimize-gear {
    position: absolute;
    bottom: -2px;
    right: -2px;
    font-size: 16px;
}
.generic-list-btn {
    flex-shrink: 0;
    background: none;
    border: none;
    padding: 4px;
    cursor: pointer;
    opacity: 0.5;
    transition: opacity 0.2s;
    -webkit-tap-highlight-color: transparent;
}
.generic-list-btn.selected {
    opacity: 1;
}
.generic-list-btn img {
    border-radius: 8px;
    display: block;
}
.cart-item-price {
    font-size: 18px;
    font-weight: 800;
    color: var(--text-primary);
    margin-top: 2px;
}
.cart-item-remove {
    background: none;
    border: none;
    color: var(--text-tertiary);
    font-size: 16px;
    cursor: pointer;
    padding: 4px;
    flex-shrink: 0;
}
.cart-item-remove:active {
    color: var(--red);
}

#cart-empty {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    color: var(--text-tertiary);
    font-size: 15px;
}

/* Segmented toggle */
#cart-seg-toggle {
    display: flex;
    margin: 8px 16px;
    border: 2px solid var(--green-30);
    border-radius: 24px;
    overflow: hidden;
    flex-shrink: 0;
}
.seg-btn {
    flex: 1;
    padding: 10px 0;
    font-size: 15px;
    font-weight: 700;
    border: none;
    cursor: pointer;
    transition: all 0.2s;
    background: white;
    color: var(--green-30);
}
.seg-btn.active {
    background: var(--green-30);
    color: white;
}

/* Header list dropdown */
.header-right {
    display: flex;
    align-items: center;
    gap: 8px;
}
.header-list-btn {
    display: flex;
    align-items: center;
    gap: 4px;
    background: none;
    border: 1.5px solid var(--border);
    border-radius: 10px;
    padding: 8px 18px;
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
    cursor: pointer;
}
.header-list-btn .list-arrow {
    font-size: 14px;
    font-weight: 700;
    color: var(--text-secondary);
}

.header-share-btn {
    display: flex;
    align-items: center;
    gap: 4px;
    background: none;
    border: 1.5px solid var(--green-30);
    border-radius: 10px;
    padding: 6px 10px;
    font-size: 16px;
    cursor: pointer;
}
.header-share-btn .member-dot {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 800;
    color: white;
    margin-right: -6px;
    border: 2px solid white;
}

/* Share sheet */
.share-sheet {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
}
.share-sheet-content {
    background: var(--surface);
    border-radius: 20px;
    padding: 24px;
    width: 90%;
    max-width: 380px;
    animation: sheetUp 0.2s ease;
}
.share-sheet-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
}
.share-sheet-header h3 { font-size: 18px; font-weight: 700; margin: 0; }
.share-sheet-header button { background: none; border: none; font-size: 18px; color: var(--text-secondary); cursor: pointer; }
.share-members-list { margin-bottom: 16px; }
.share-member-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
}
.share-member-name { flex: 1; font-size: 14px; font-weight: 600; }
.share-member-role { font-size: 11px; color: var(--text-tertiary); }
.share-actions { display: flex; flex-direction: column; gap: 10px; }
.share-action-btn {
    width: 100%;
    padding: 14px;
    border: none;
    border-radius: 14px;
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
}
.share-invite-btn { background: var(--green-30); color: white; }
.share-invite-btn:active { background: var(--green-10); }
.share-join-btn { background: var(--bg); color: var(--text-primary); border: 1.5px solid var(--border) !important; }
.share-code-display { text-align: center; padding: 16px 0; }
.share-code-big {
    font-size: 36px;
    font-weight: 900;
    letter-spacing: 6px;
    color: var(--green-30);
    margin: 12px 0;
}
.share-code-timer { font-size: 13px; color: var(--text-tertiary); }
.share-code-input {
    width: 100%;
    text-align: center;
    font-size: 28px;
    font-weight: 900;
    letter-spacing: 8px;
    padding: 12px;
    border: 2px solid var(--border);
    border-radius: 14px;
    background: var(--bg);
    color: var(--text-primary);
    outline: none;
}
.share-code-input:focus { border-color: var(--green-30); }

.shared-toast {
    position: fixed;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--green-10);
    color: white;
    padding: 10px 20px;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 600;
    z-index: 10000;
    animation: toastIn 0.3s ease;
    white-space: nowrap;
    max-width: 90%;
    overflow: hidden;
    text-overflow: ellipsis;
}
@keyframes toastIn {
    from { opacity: 0; transform: translateX(-50%) translateY(20px); }
    to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

.share-leave-btn {
    background: none !important;
    color: var(--red) !important;
    border: 1.5px solid var(--red) !important;
}
.share-leave-btn:active { background: #fef2f2 !important; }

#cart-split-totals {
    display: flex;
    gap: 12px;
    padding: 12px 16px;
    background: var(--surface);
    border-radius: 14px;
    margin: 8px 0;
    justify-content: center;
    flex-wrap: wrap;
}
.split-person {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 14px;
}
.split-name { font-weight: 600; color: var(--text-primary); }
.split-amount { font-weight: 800; color: var(--green-30); }

.check-member-dot {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 800;
    color: white;
}

/* Store header (name + total) */
#cart-store-header {
    padding: 4px 16px 8px;
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    flex-shrink: 0;
    flex-wrap: wrap;
}
.store-header-name {
    font-size: 24px;
    font-weight: 900;
    color: var(--text-primary);
}
.store-header-total {
    font-size: 22px;
    font-weight: 900;
    color: var(--green-30);
}
#cart-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 20px;
    border-top: 1.5px solid var(--border);
    background: var(--surface);
    flex-shrink: 0;
}
.cart-total-label {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-secondary);
}
.cart-total-value {
    font-size: 26px;
    font-weight: 900;
    color: var(--green-30);
}

/* Debug view */
#info-page {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: var(--bg);
    z-index: 100;
    display: flex;
    flex-direction: column;
}
#info-page.hidden { display: none !important; }
#info-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: var(--green-30);
    color: white;
    flex-shrink: 0;
}
#info-header button {
    background: none;
    border: none;
    color: white;
    font-size: 22px;
    cursor: pointer;
    padding: 0;
}
#info-title {
    font-size: 17px;
    font-weight: 700;
}
#info-content {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}
#debug-view {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: var(--bg);
    z-index: 100;
    display: flex;
    flex-direction: column;
    max-width: 480px;
    margin: 0 auto;
}
#debug-view.hidden { display: none !important; }
#debug-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
    background: var(--surface);
}
#debug-header button {
    background: none; border: none; font-size: 22px; cursor: pointer;
    color: var(--accent); padding: 0 4px; font-weight: 700;
}
#debug-header span {
    font-size: 17px; font-weight: 700; color: var(--accent);
}
#debug-content {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    display: flex;
    flex-direction: column;
}
.debug-tab {
    flex: 1;
    padding: 10px;
    background: none;
    border: none;
    border-bottom: 3px solid transparent;
    font-size: 14px;
    font-weight: 700;
    color: var(--text-tertiary);
    cursor: pointer;
}
.debug-tab.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
}

/* Dettaglio prodotto */
#product-detail {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--bg);
    z-index: 100;
    display: flex;
    flex-direction: column;
    max-width: 480px;
    margin: 0 auto;
}
#product-detail.hidden { display: none !important; }

#detail-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
    background: var(--surface);
}
#detail-back {
    background: var(--pill-bg);
    border: none;
    font-size: 18px;
    cursor: pointer;
    color: var(--text-secondary);
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
#detail-header span {
    font-size: 17px;
    font-weight: 700;
    color: var(--text-primary);
}

#detail-content {
    flex: 1;
    overflow-y: auto;
    padding: 12px 16px;
    -webkit-overflow-scrolling: touch;
}

.detail-top {
    display: flex;
    gap: 14px;
    margin-bottom: 14px;
}
.detail-image {
    width: 110px;
    height: 110px;
    background: var(--warm);
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    position: relative;
}
.detail-image img {
    max-width: 90px;
    max-height: 90px;
    object-fit: contain;
}
.detail-emoji {
    font-size: 50px;
    line-height: 1;
}

.detail-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 2px;
}
.detail-brand {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.detail-name {
    font-size: 18px;
    font-weight: 800;
    line-height: 1.2;
    color: var(--text-primary);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.detail-weight {
    font-size: 13px;
    color: var(--text-secondary);
}
.detail-info .nutri-badge {
    margin: 4px 0;
}

.detail-section {
    margin-bottom: 12px;
}
.detail-section-title {
    font-size: 14px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 6px;
    display: flex;
    align-items: center;
    gap: 8px;
}
.detail-prices-count {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-tertiary);
    background: var(--pill-bg);
    padding: 3px 10px;
    border-radius: 12px;
}

.detail-prices-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.detail-price-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--surface);
    border-radius: 10px;
    padding: 8px 12px;
    border: 1.5px solid var(--border);
}
.detail-price-row.best {
    border-color: var(--green-40);
    background: var(--green-90);
}
.detail-price-row.selected {
    border-color: var(--green-40);
    background: var(--green-90);
}
.detail-price-chain {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
}
.chain-color-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}
.detail-distance {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-tertiary);
    background: var(--pill-bg);
    padding: 1px 6px;
    border-radius: 8px;
}
.detail-chain-name {
    font-size: 15px;
    font-weight: 700;
    color: var(--text-primary);
}
.detail-unit-price {
    font-size: 11px;
    color: var(--text-tertiary);
}
.detail-price-right {
    display: flex;
    align-items: center;
    gap: 6px;
}
.detail-discount {
    font-size: 11px;
    font-weight: 700;
    color: white;
    background: var(--red);
    border-radius: 4px;
    padding: 2px 5px;
}
.detail-original {
    font-size: 12px;
    color: var(--text-tertiary);
    text-decoration: line-through;
}
.detail-price {
    font-size: 18px;
    font-weight: 900;
    color: var(--text-primary);
}
.detail-price.best {
    color: var(--green-30);
}

/* Nutritional grid */
.nutri-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
}
.nutri-cell {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 8px 6px;
    text-align: center;
    display: flex;
    flex-direction: column;
    gap: 1px;
}
.nutri-val {
    font-size: 15px;
    font-weight: 800;
    color: var(--text-primary);
}
.nutri-label {
    font-size: 10px;
    font-weight: 600;
    color: var(--text-tertiary);
}

/* Price chart */
/* Detail tags (allergeni, additivi) */
.detail-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}
.detail-tag {
    font-size: 12px;
    font-weight: 600;
    padding: 4px 10px;
    border-radius: 10px;
}
.allergen-tag {
    background: #FEE2E2;
    color: #DC2626;
}
.additive-tag {
    background: #FEF3C7;
    color: #D97706;
}
.risk-dot {
    display: inline-block;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    margin-left: 6px;
    cursor: pointer;
    vertical-align: middle;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}
.risk-dot.risk-1 { background: #16A34A; }
.risk-dot.risk-2 { background: #EE8100; }
.risk-dot.risk-3 { background: #E63E11; }
.additive-tag { cursor: pointer; }
.additive-risk-1 { background: #D1FAE5 !important; color: #059669 !important; }
.additive-risk-2 { background: #FEF3C7 !important; color: #D97706 !important; }
.additive-risk-3 { background: #FEE2E2 !important; color: #DC2626 !important; }
.additive-risk-0 { background: var(--pill-bg) !important; color: var(--text-secondary) !important; }
.owner-toggle-btn {
    margin-top: 6px;
    padding: 3px 10px;
    font-size: 11px;
    font-weight: 600;
    border: 1px solid var(--red);
    border-radius: 8px;
    background: none;
    color: var(--red);
    cursor: pointer;
}
.owner-info-inline.hidden { display: none; }
.detail-ingredienti {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.4;
}

#price-chart {
    width: 100%;
    height: 120px;
    background: var(--surface);
    border-radius: 12px;
    border: 1px solid var(--border);
}

.detail-add-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    background: var(--green-30);
    color: white;
    border: none;
    border-radius: 24px;
    padding: 16px 0;
    font-size: 17px;
    font-weight: 700;
    cursor: pointer;
    margin-bottom: 16px;
}
.detail-bottom-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
}
.detail-qty {
    display: flex;
    align-items: center;
    gap: 10px;
}
.detail-qty-num {
    font-size: 28px;
}
.detail-add-btn:active {
    background: var(--green-10);
}
.detail-add-btn.added {
    background: var(--red);
    color: white;
}
.detail-add-btn .plus {
    font-size: 20px;
    font-weight: 900;
}

/* Recipes */
#recipes-view {
    flex: 1;
    overflow-y: auto;
    padding: 0 12px 16px;
    -webkit-overflow-scrolling: touch;
}
#recipes-search-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--surface);
    border: 1.5px solid var(--border);
    border-radius: 14px;
    padding: 10px 14px;
    margin-bottom: 10px;
}
#recipes-search-bar input {
    flex: 1;
    border: none;
    outline: none;
    font-size: 15px;
    background: none;
}
#recipe-cat-filters {
    display: flex;
    gap: 6px;
    overflow-x: auto;
    scrollbar-width: none;
    margin-bottom: 12px;
    -webkit-overflow-scrolling: touch;
}
#recipe-cat-filters::-webkit-scrollbar { display: none; }
.recipe-cat-pill {
    border: 1.5px solid var(--border);
    background: var(--surface);
    border-radius: 20px;
    padding: 6px 14px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
}
.recipe-cat-pill.active {
    background: var(--green-90);
    border-color: var(--green-30);
    color: var(--green-10);
}
#recipes-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
}
.recipe-card {
    background: var(--surface);
    border-radius: 14px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.07);
    overflow: hidden;
    cursor: pointer;
}
.recipe-card:active {
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}
.recipe-card-img {
    width: 100%;
    aspect-ratio: 1;
    background: var(--pill-bg);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 48px;
}
.recipe-card-img {
    position: relative;
}
.recipe-fav-heart {
    position: absolute;
    top: 6px;
    right: 6px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
}
.recipe-fav-heart svg {
    fill: rgba(255,255,255,0.6);
    stroke: rgba(0,0,0,0.2);
    stroke-width: 1.5;
    filter: drop-shadow(0 1px 2px rgba(0,0,0,0.2));
}
.recipe-fav-heart.fav-active svg {
    fill: var(--red);
    stroke: white;
}
.recipe-card-info {
    padding: 8px;
}
.recipe-cat-badge {
    display: inline-block;
    font-size: 10px;
    font-weight: 700;
    color: var(--green-30);
    background: var(--green-90);
    padding: 2px 8px;
    border-radius: 6px;
    margin-bottom: 4px;
}
.recipe-card-name {
    font-size: 13px;
    font-weight: 700;
    line-height: 1.2;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.recipe-card-meta {
    font-size: 11px;
    color: var(--text-tertiary);
    margin-top: 2px;
}

/* Recipe detail */
#recipe-detail {
    position: fixed;
    inset: 0;
    background: var(--bg);
    z-index: 100;
    display: flex;
    flex-direction: column;
    max-width: 480px;
    margin: 0 auto;
}
#recipe-detail-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    flex-shrink: 0;
}
#recipe-back {
    background: var(--pill-bg);
    border: none;
    font-size: 18px;
    color: var(--text-secondary);
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}
#recipe-detail-header span {
    font-size: 16px;
    font-weight: 700;
}
#recipe-detail-content {
    flex: 1;
    overflow-y: auto;
    padding: 0 16px 16px;
    -webkit-overflow-scrolling: touch;
}
.recipe-detail-name {
    font-size: 28px;
    font-weight: 900;
    margin-bottom: 10px;
}
.recipe-detail-badges {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
}
.recipe-detail-badge {
    border: 1.5px solid var(--border);
    border-radius: 20px;
    padding: 6px 14px;
    font-size: 13px;
    font-weight: 600;
}
.recipe-portions-ctrl {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}
.portion-btn {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    border: 1.5px solid var(--border);
    background: var(--surface);
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}
.portion-btn:active {
    background: var(--green-90);
}
#recipe-portions-val {
    font-weight: 800;
    min-width: 20px;
    text-align: center;
}
#recipe-clear-btn {
    background: none;
    border: none;
    font-size: 20px;
    color: var(--text-tertiary);
    cursor: pointer;
    padding: 0 4px;
}
.recipe-detail-section-title {
    font-size: 20px;
    font-weight: 800;
    margin-bottom: 10px;
}
.recipe-ing-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin-bottom: 16px;
}
.recipe-ing-card {
    background: var(--surface);
    border: 2px solid var(--border);
    border-radius: 12px;
    padding: 8px;
    text-align: center;
}
.recipe-ing-card.in-list {
    border-color: var(--green-30);
    background: var(--green-90);
}
.recipe-ing-img {
    width: 100%;
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 4px;
}
.recipe-ing-img img {
    border-radius: 8px;
}
.recipe-ing-name {
    font-size: 11px;
    font-weight: 600;
    line-height: 1.2;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.recipe-ing-qty {
    font-size: 12px;
    font-weight: 800;
    color: var(--text-secondary);
    margin-top: 2px;
}
.recipe-ing-inlist {
    font-size: 10px;
    font-weight: 700;
    color: var(--green-30);
    margin-top: 2px;
}
.recipe-prep-accordion {
    margin-bottom: 16px;
    cursor: pointer;
}
.recipe-prep-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 0;
    font-size: 16px;
    font-weight: 700;
    color: var(--text-primary);
    border-top: 1px solid var(--border);
}
.recipe-prep-arrow {
    font-size: 18px;
    color: var(--text-tertiary);
    transition: transform 0.2s;
}
.recipe-prep-accordion.open .recipe-prep-arrow {
    transform: rotate(90deg);
}
.recipe-prep-body {
    display: none;
    font-size: 14px;
    color: var(--text-secondary);
    line-height: 1.6;
    padding-bottom: 12px;
    white-space: pre-line;
}
.recipe-prep-accordion.open .recipe-prep-body {
    display: block;
}
.recipe-add-wrap {
    position: sticky;
    bottom: 0;
    padding: 12px 0;
    background: var(--bg);
}
.recipe-add-all-btn {
    width: 100%;
    background: var(--green-30);
    color: white;
    border: none;
    border-radius: 20px;
    padding: 14px 0;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
}

/* Bottom nav */
#bottom-nav {
    display: flex;
    background: var(--surface);
    border-top: 1px solid var(--border);
    padding: 6px 0 env(safe-area-inset-bottom, 8px);
    flex-shrink: 0;
}
.nav-btn {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    background: none;
    border: none;
    color: var(--text-tertiary);
    font-size: 11px;
    font-weight: 500;
    cursor: pointer;
    padding: 6px 0;
    transition: color 0.15s;
}
.nav-btn.active {
    color: var(--green-30);
    font-weight: 700;
    transform: scale(1.2);
}

/* Scroll to top */
.scroll-top {
    position: fixed;
    bottom: 80px;
    right: 16px;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: rgba(74,124,89,0.7);
    color: white;
    border: none;
    font-size: 20px;
    font-weight: 800;
    cursor: pointer;
    z-index: 40;
    display: flex;
    align-items: center;
    justify-content: center;
}

.hidden { display: none !important; }

/* ─── Product Detail v2 (pd-*) ─────────────────────────────── */
#detail-content { padding: 16px 0 24px; }

.pd-header {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    padding: 0 16px;
    margin-bottom: 14px;
    position: relative;
}
.pd-thumb {
    width: 96px;
    height: 96px;
    flex-shrink: 0;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}
.pd-thumb img {
    max-width: 84px;
    max-height: 84px;
    object-fit: contain;
}
.pd-hero-emoji { font-size: 56px; line-height: 1; }
.pd-header-info {
    flex: 1;
    min-width: 0;
    padding-top: 2px;
}
.pd-fav {
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    background: var(--surface);
    border: 1px solid var(--border);
    box-shadow: none;
    margin-top: 2px;
}

.pd-badges-row {
    padding: 0 16px;
    margin-bottom: 16px;
}
.pd-owner-row {
    padding: 0 16px;
    margin-bottom: 12px;
}
.pd-brand {
    font-size: 11px;
    font-weight: 700;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 4px;
}
.pd-name {
    font-size: 18px;
    font-weight: 800;
    line-height: 1.25;
    color: var(--text-primary);
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.pd-weight {
    font-size: 13px;
    color: var(--text-secondary);
    margin-top: 3px;
}
.pd-trust-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: var(--green-90);
    color: var(--green-10);
    font-size: 11px;
    font-weight: 700;
    padding: 3px 8px;
    border-radius: 10px;
    margin-top: 6px;
}
.pd-trust-badge svg { color: var(--green-30); }
.pd-warn-badge {
    display: inline-block;
    background: #FEF3C7;
    color: #92400E;
    font-size: 12px;
    font-weight: 700;
    padding: 4px 10px;
    border-radius: 12px;
    margin-top: 10px;
}

.pd-quick-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 12px;
}
.pd-pill {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px 6px 6px;
    border-radius: 22px;
    background: var(--surface);
    border: 1.5px solid var(--border);
    font-size: 13px;
    font-weight: 700;
    color: var(--text-primary);
    cursor: pointer;
    transition: transform 0.1s;
}
.pd-pill:active { transform: scale(0.96); }
.pd-pill-nova { padding-left: 12px; }
.pd-pill-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
    box-shadow: 0 1px 2px rgba(0,0,0,0.15);
}

.pd-price-strip {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--surface);
    border: 2px solid var(--green-30);
    margin: 0 16px 18px;
    padding: 14px 18px;
    border-radius: 14px;
}
.pd-price-strip-label {
    font-size: 11px;
    font-weight: 700;
    color: var(--green-30);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.pd-price-strip-big {
    font-size: 28px;
    font-weight: 900;
    color: var(--green-10);
    line-height: 1.1;
    margin-top: 2px;
}
.pd-price-strip-chain {
    font-size: 12px;
    color: var(--text-secondary);
    font-weight: 600;
    margin-top: 2px;
}
.pd-price-strip-btn {
    background: var(--green-30);
    color: white;
    text-decoration: none;
    font-size: 13px;
    font-weight: 700;
    padding: 10px 16px;
    border-radius: 20px;
}

.pd-section {
    margin: 0 16px 20px;
}
.pd-section-title {
    font-size: 16px;
    font-weight: 800;
    color: var(--text-primary);
    margin: 0 4px 8px;
    display: flex;
    align-items: center;
    gap: 8px;
}
.pd-section-sub {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-tertiary);
    background: var(--pill-bg);
    padding: 2px 10px;
    border-radius: 10px;
}
.pd-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 16px 18px;
}
.pd-text {
    font-size: 15px;
    line-height: 1.55;
    color: var(--text-primary);
}
.pd-card-warm {
    background: var(--warm);
    border-color: #F0E6B8;
    font-size: 15px;
    line-height: 1.55;
    color: #5C4A1F;
}
.pd-section-warm-title { color: #8C6D1F; }

/* Scheda salute (4 quadranti) */
.pd-health-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
}
.pd-health-cell {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 10px;
    background: var(--bg);
    border-radius: 12px;
    cursor: pointer;
    transition: transform 0.1s;
}
.pd-health-cell:active { transform: scale(0.97); }
.pd-health-icon {
    flex-shrink: 0;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 900;
}
.pd-health-icon.ns-letter {
    color: white;
    text-shadow: 0 1px 2px rgba(0,0,0,0.2);
}
.pd-health-label {
    font-size: 13px;
    font-weight: 700;
    color: var(--text-primary);
}

/* Valori nutrizionali (barre orizzontali) */
.pd-nutri-row {
    display: grid;
    grid-template-columns: 110px 1fr 70px;
    align-items: center;
    gap: 12px;
    padding: 9px 0;
    border-bottom: 1px solid var(--border);
}
.pd-nutri-row:last-child { border-bottom: none; }
.pd-nutri-row.pd-nutri-sub { padding-left: 12px; }
.pd-nutri-row.pd-nutri-sub .pd-nutri-label {
    font-size: 12px;
    color: var(--text-secondary);
    font-weight: 500;
}
.pd-nutri-label {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
}
.pd-nutri-bar {
    height: 8px;
    background: var(--pill-bg);
    border-radius: 4px;
    overflow: hidden;
}
.pd-nutri-fill {
    height: 100%;
    border-radius: 4px;
    transition: width 0.4s ease;
}
.pd-nutri-val {
    font-size: 14px;
    font-weight: 700;
    color: var(--text-primary);
    text-align: right;
    white-space: nowrap;
}
.pd-nutri-unit {
    font-size: 11px;
    color: var(--text-tertiary);
    font-weight: 600;
    margin-left: 1px;
}

/* Additivi Yuka-style */
.pd-additives-list { padding: 4px 0; }
.pd-additive-row {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px 14px;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    transition: background 0.15s;
}
.pd-additive-row:last-child { border-bottom: none; }
.pd-additive-row:active { background: var(--bg); }
.pd-additive-dot {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    flex-shrink: 0;
    box-shadow: 0 1px 3px rgba(0,0,0,0.15);
}
.pd-additive-main { flex: 1; min-width: 0; }
.pd-additive-name {
    font-size: 14px;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.3;
}
.pd-additive-code {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-tertiary);
    background: var(--pill-bg);
    padding: 1px 6px;
    border-radius: 6px;
    margin-left: 4px;
}
.pd-additive-meta {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 2px;
}
.pd-additive-arrow {
    font-size: 22px;
    color: var(--text-tertiary);
    flex-shrink: 0;
    line-height: 1;
}

.pd-ingredients {
    font-size: 14px;
    line-height: 1.55;
    color: var(--text-secondary);
}

/* Scheda fresco */
.pd-fresh-card { padding: 4px 18px; }
.pd-fresh-block {
    padding: 14px 0;
    border-bottom: 1px solid var(--border);
}
.pd-fresh-block:last-child { border-bottom: none; }
.pd-fresh-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    font-weight: 800;
    color: var(--text-primary);
    margin-bottom: 8px;
}
.pd-fresh-icon { font-size: 18px; }
.pd-fresh-text {
    font-size: 14px;
    color: var(--text-secondary);
    line-height: 1.5;
}

/* Stagionalità calendar (12 months) */
.pd-season-cal {
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    gap: 4px;
    margin: 6px 0 10px;
}
.pd-season-month {
    aspect-ratio: 1;
    background: var(--pill-bg);
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.pd-season-month.active {
    background: var(--green-30);
}
.pd-season-letter {
    font-size: 10px;
    font-weight: 800;
    color: var(--text-tertiary);
}
.pd-season-month.active .pd-season-letter { color: white; }

/* Provenienza protected labels */
.pd-fresh-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin: 0 0 8px;
}
.pd-protected-badge {
    display: inline-block;
    background: var(--green-90);
    color: var(--green-10);
    font-size: 11px;
    font-weight: 800;
    padding: 3px 9px;
    border-radius: 8px;
    letter-spacing: 0.5px;
}

/* Varietà bullet list */
.pd-varieta-list {
    margin: 0;
    padding-left: 20px;
    font-size: 14px;
    color: var(--text-secondary);
    line-height: 1.5;
}
.pd-varieta-list li { margin-bottom: 4px; }
.pd-varieta-list li:last-child { margin-bottom: 0; }

#detail-content .detail-bottom-bar {
    margin: 4px 16px 0;
}

/* ─── Home v2: editorial headline + bento categories ─────────── */
.home-headline {
    font-size: 28px;
    font-weight: 900;
    line-height: 1.1;
    color: var(--text-primary);
    padding: 4px 16px 14px;
    letter-spacing: -0.5px;
}
.home-headline-accent { color: var(--green-30); }

#categories-section {
    padding: 6px 6px 4px;
    margin-bottom: 8px;
}
.cat-section-title {
    font-size: 22px;
    font-weight: 900;
    line-height: 1.15;
    letter-spacing: -0.4px;
    color: var(--text-primary);
    margin: 12px 0 14px;
    padding: 0 4px;
}
.cat-section-accent { color: var(--green-30); }

/* Bento asymmetric grid: Freschissimi wide hero, F&V tall, Pasta wide, 6 small */
#categories-bento {
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-areas:
        "fresh fresh"
        "fv carne"
        "fv latt"
        "pasta pasta"
        "snack bev"
        "casa cosm";
    gap: 10px;
}
.bento-tile {
    border: none;
    border-radius: 18px;
    padding: 14px 16px;
    cursor: pointer;
    text-align: left;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    min-height: 88px;
    font-family: inherit;
    transition: transform 0.12s ease, box-shadow 0.12s ease;
    box-shadow: 0 2px 6px rgba(0,0,0,0.04);
    position: relative;
    overflow: hidden;
}
.bento-tile:active {
    transform: scale(0.97);
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}
.bento-fresh {
    grid-area: fresh;
    min-height: 140px;
    justify-content: flex-end;
}
.bento-fv {
    grid-area: fv;
    min-height: 186px;
}
.bento-carne { grid-area: carne; }
.bento-latt  { grid-area: latt; }
.bento-pasta { grid-area: pasta; min-height: 76px; }
.bento-snack { grid-area: snack; }
.bento-bev   { grid-area: bev; }
.bento-casa  { grid-area: casa; }
.bento-cosm  { grid-area: cosm; }

.bento-emoji {
    font-size: 36px;
    line-height: 1;
    position: relative;
    z-index: 2;
}
.bento-fv .bento-emoji { font-size: 56px; }
.bento-fresh .bento-emoji { font-size: 40px; }
.bento-pasta { flex-direction: row; align-items: center; gap: 12px; }
.bento-pasta .bento-emoji { font-size: 32px; }
.bento-pasta .bento-title { font-size: 17px; }

.bento-title {
    font-size: 15px;
    font-weight: 800;
    line-height: 1.2;
    margin-top: 8px;
    position: relative;
    z-index: 2;
}
.bento-fv .bento-title { font-size: 20px; }
.bento-fresh .bento-title { font-size: 22px; }

/* Category filter bars (live inside #category-view) */
.cat-filter-bar {
    display: flex;
    gap: 8px;
    padding: 8px 16px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}
.cat-filter-bar::-webkit-scrollbar { display: none; }
.cat-filter-bar.hidden { display: none; }
.cat-filter-bar .sort-pill,
.cat-filter-bar .chain-pill {
    flex-shrink: 0;
}

/* ─── Category view (sub-bento landing) ───────────────────── */
#category-view {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: var(--bg);
    z-index: 90;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    max-width: 480px;
    margin: 0 auto;
    padding-bottom: 80px;
}
#category-view.hidden { display: none !important; }

#category-hero {
    position: sticky;
    top: 0;
    z-index: 50;
    padding: 18px 20px 28px;
    border-bottom-left-radius: 24px;
    border-bottom-right-radius: 24px;
    margin-bottom: 18px;
    min-height: 140px;
    display: flex;
    align-items: flex-end;
    gap: 14px;
    overflow: hidden;
    transition: padding 0.25s ease, min-height 0.25s ease, border-radius 0.25s ease;
    will-change: min-height, padding;
}
#category-hero.has-hero {
    min-height: 220px;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
}
/* Collapsed state during scroll: compact sticky header */
#category-hero.collapsed {
    min-height: 64px !important;
    padding: 12px 20px 12px 64px;
    border-bottom-left-radius: 18px;
    border-bottom-right-radius: 18px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    align-items: center;
}
#category-hero.collapsed #cat-hero-title {
    font-size: 17px !important;
}
#category-hero.collapsed #cat-hero-sub,
#category-hero.collapsed .cat-hero-emoji {
    display: none;
}
#category-hero.collapsed.has-hero::after {
    background: linear-gradient(180deg, rgba(0,0,0,0.35) 0%, rgba(0,0,0,0.55) 100%);
}
#category-hero.has-hero::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg, rgba(0,0,0,0.15) 0%, rgba(0,0,0,0) 30%, rgba(0,0,0,0.65) 100%);
    z-index: 1;
    pointer-events: none;
}
#category-hero.has-hero .cat-hero-emoji { display: none; }
#category-hero.has-hero #cat-hero-title,
#category-hero.has-hero #cat-hero-sub {
    color: #fff;
    text-shadow: 0 2px 8px rgba(0,0,0,0.55);
    position: relative;
    z-index: 2;
}
#category-hero.has-hero #category-back {
    background: rgba(255,255,255,0.85);
    color: #111;
    z-index: 3;
}
#category-hero.has-hero .cat-hero-text {
    position: relative;
    z-index: 2;
}
#category-back {
    position: fixed;
    top: 14px;
    left: 14px;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: rgba(255,255,255,0.95);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: none;
    z-index: 100;
    box-shadow: 0 3px 12px rgba(0,0,0,0.18);
    font-size: 24px;
    font-weight: 800;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #111;
}
.cat-hero-emoji {
    font-size: 64px;
    line-height: 1;
    flex-shrink: 0;
    filter: drop-shadow(0 4px 8px rgba(0,0,0,0.1));
}
.cat-hero-text {
    flex: 1;
    min-width: 0;
}
#cat-hero-title {
    font-size: 26px;
    font-weight: 900;
    line-height: 1.1;
    letter-spacing: -0.5px;
    color: inherit;
}
#cat-hero-sub {
    font-size: 13px;
    margin-top: 4px;
    opacity: 0.78;
    line-height: 1.4;
    color: inherit;
}

.cat-section {
    padding: 0 16px;
    margin-bottom: 22px;
}
.cat-section-h {
    font-size: 18px;
    font-weight: 800;
    color: var(--text-primary);
    margin: 0 0 12px;
    padding: 0 4px;
}
#cat-prods-count {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-tertiary);
    background: var(--pill-bg);
    padding: 2px 10px;
    border-radius: 10px;
    margin-left: 6px;
}

#cat-subcats {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}
.cat-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: var(--surface);
    border: 1.5px solid var(--border);
    border-radius: 18px;
    padding: 8px 14px;
    font-size: 13px;
    font-weight: 700;
    color: var(--text-primary);
    cursor: pointer;
    font-family: inherit;
    transition: transform 0.1s;
}
.cat-chip:active { transform: scale(0.96); }
.cat-chip.active {
    background: var(--green-30);
    border-color: var(--green-30);
    color: white;
}
.cat-chip-count {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-tertiary);
    background: var(--pill-bg);
    padding: 1px 6px;
    border-radius: 8px;
}
.cat-chip.active .cat-chip-count {
    background: rgba(255,255,255,0.25);
    color: white;
}
.cat-skeleton {
    color: var(--text-tertiary);
    font-size: 13px;
    padding: 4px 4px 0;
}

#cat-products {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* Strikethrough original price + promo highlight on .product-card */
.original-price-strike {
    font-size: 14px;
    color: var(--text-tertiary);
    text-decoration: line-through;
    font-weight: 600;
    line-height: 1;
    margin-bottom: 2px;
}
.best-price-promo {
    color: var(--green-30) !important;
}

/* ═══════════════════════════════════════════════════════════════
   CLOSE TRIP — chiudi spesa flow
   ═══════════════════════════════════════════════════════════════ */

/* "Chiudi spesa" button in list header */
.list-close-trip-btn {
    background: var(--green-30);
    color: #fff;
    border: none;
    border-radius: 24px;
    padding: 14px 24px;
    font-size: 16px;
    font-weight: 800;
    font-family: inherit;
    cursor: pointer;
    box-shadow: 0 4px 14px rgba(45,106,79,0.3);
    margin-bottom: 10px;
    width: 100%;
    max-width: 260px;
}
.list-close-trip-btn.pulse {
    animation: close-trip-pulse 1.4s ease infinite;
}
@keyframes close-trip-pulse {
    0%, 100% { transform: scale(1); box-shadow: 0 4px 14px rgba(45,106,79,0.3); }
    50% { transform: scale(1.03); box-shadow: 0 6px 20px rgba(45,106,79,0.5); }
}
.list-percorso-btn-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0;
}

/* ─── Pre-save bottom sheet ──────────────────────────────────── */
.close-trip-sheet {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 9998;
    padding: 12px 14px calc(12px + env(safe-area-inset-bottom));
    transform: translateY(110%);
    transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
    pointer-events: none;
}
.close-trip-sheet.open { transform: translateY(0); }
.close-trip-sheet-inner {
    max-width: 480px;
    margin: 0 auto;
    background: var(--surface);
    border-radius: 20px;
    padding: 16px 18px;
    box-shadow: 0 -8px 32px rgba(0,0,0,0.18);
    pointer-events: auto;
    border: 1.5px solid var(--green-30);
}
.close-trip-sheet-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
}
.close-trip-sheet-title {
    font-size: 18px;
    font-weight: 800;
    color: var(--text-primary);
}
.close-trip-countdown {
    min-width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--green-30);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 15px;
    font-weight: 800;
    padding: 0 8px;
}
.close-trip-sheet-body {
    margin-bottom: 14px;
}
.close-trip-store {
    font-size: 15px;
    font-weight: 700;
    color: var(--text-secondary);
    margin-bottom: 2px;
}
.close-trip-stats {
    font-size: 14px;
    color: var(--text-tertiary);
    display: flex;
    gap: 6px;
}
.close-trip-sheet-actions {
    display: flex;
    gap: 8px;
}
.close-trip-btn {
    flex: 1;
    border: none;
    border-radius: 14px;
    padding: 13px 10px;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    font-family: inherit;
    white-space: nowrap;
}
.close-trip-btn.primary {
    background: var(--green-30);
    color: #fff;
}
.close-trip-btn.secondary {
    background: var(--bg);
    color: var(--text-primary);
}
.close-trip-btn.ghost {
    background: transparent;
    color: var(--green-30);
    border: 1.5px solid var(--green-30);
}
.close-trip-btn:active { transform: scale(0.97); }

/* ─── Full review modal ─────────────────────────────────────── */
.close-trip-modal {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
}
.close-trip-modal.open {
    opacity: 1;
    pointer-events: auto;
}
.close-trip-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.5);
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
}
.close-trip-modal-content {
    position: relative;
    background: var(--surface);
    border-radius: 22px 22px 0 0;
    width: 100%;
    max-width: 480px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    animation: sheetUp 0.28s ease;
}
.close-trip-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 20px 12px;
    border-bottom: 1px solid var(--border);
}
.close-trip-modal-header h3 {
    font-size: 20px;
    font-weight: 800;
    color: var(--text-primary);
    margin: 0;
}
.close-trip-modal-close {
    background: none;
    border: none;
    font-size: 22px;
    color: var(--text-tertiary);
    cursor: pointer;
    padding: 4px 10px;
}
.close-trip-modal-body {
    padding: 16px 20px;
    overflow-y: auto;
    flex: 1;
}
.close-trip-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 14px;
}
.close-trip-field span {
    font-size: 13px;
    font-weight: 700;
    color: var(--text-secondary);
}
.close-trip-field select,
.close-trip-field input {
    padding: 12px 14px;
    border-radius: 12px;
    border: 1.5px solid var(--border);
    background: var(--bg);
    font-size: 15px;
    font-family: inherit;
    color: var(--text-primary);
}
.close-trip-field select:focus,
.close-trip-field input:focus {
    outline: none;
    border-color: var(--green-30);
}
.close-trip-items-label {
    font-size: 13px;
    font-weight: 700;
    color: var(--text-secondary);
    margin-top: 6px;
    margin-bottom: 6px;
}
.close-trip-items {
    background: var(--bg);
    border-radius: 14px;
    padding: 6px;
    margin-bottom: 14px;
    max-height: 260px;
    overflow-y: auto;
}
.close-trip-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 10px;
    cursor: pointer;
    user-select: none;
}
.close-trip-item:hover { background: var(--surface); }
.close-trip-item.excluded {
    opacity: 0.45;
}
.close-trip-item.excluded .close-trip-item-name {
    text-decoration: line-through;
}
.close-trip-item-check {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    border: 2px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 800;
    color: #fff;
    flex-shrink: 0;
}
.close-trip-item:not(.excluded) .close-trip-item-check {
    background: var(--green-30);
    border-color: var(--green-30);
}
.close-trip-item-info {
    flex: 1;
    min-width: 0;
}
.close-trip-item-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
}
.close-trip-item-meta {
    font-size: 12px;
    color: var(--text-tertiary);
}
.close-trip-item-price {
    font-size: 14px;
    font-weight: 800;
    color: var(--green-30);
    flex-shrink: 0;
}
.close-trip-total-row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    padding: 12px 14px;
    background: var(--green-90, #EDF8EF);
    border-radius: 12px;
    margin-top: 8px;
}
.close-trip-total-row span:first-child {
    font-size: 14px;
    font-weight: 700;
    color: var(--text-secondary);
}
.close-trip-total-val {
    font-size: 22px;
    font-weight: 900;
    color: var(--green-30);
}
.close-trip-modal-footer {
    display: flex;
    gap: 10px;
    padding: 14px 20px calc(14px + env(safe-area-inset-bottom));
    border-top: 1px solid var(--border);
    background: var(--surface);
}

/* ─── Post-save countdown sheet ─────────────────────────────── */
.post-save-sheet {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 9998;
    padding: 12px 14px calc(12px + env(safe-area-inset-bottom));
    transform: translateY(110%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    pointer-events: none;
}
.post-save-sheet.open { transform: translateY(0); }
.post-save-inner {
    max-width: 480px;
    margin: 0 auto 8px;
    background: var(--surface);
    border-radius: 20px;
    padding: 16px 18px;
    box-shadow: 0 -8px 32px rgba(0,0,0,0.18);
    pointer-events: auto;
    display: flex;
    align-items: center;
    gap: 14px;
    border: 1.5px solid var(--green-30);
}
.post-save-main {
    flex: 1;
    min-width: 0;
}
.post-save-title {
    font-size: 17px;
    font-weight: 800;
    color: var(--green-30);
    margin-bottom: 2px;
}
.post-save-sub {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 2px;
}
.post-save-savings {
    font-size: 13px;
    font-weight: 700;
    color: var(--text-primary);
}
.post-save-countdown-ring {
    width: 56px;
    height: 56px;
    flex-shrink: 0;
}
.post-save-countdown-ring .ring-bg {
    fill: none;
    stroke: var(--border);
    stroke-width: 2.5;
}
.post-save-countdown-ring .ring-fg {
    fill: none;
    stroke: var(--green-30);
    stroke-width: 2.8;
    stroke-linecap: round;
    transform: rotate(-90deg);
    transform-origin: center;
    transition: stroke-dashoffset 1s linear;
}
.post-save-countdown-ring .ring-text {
    font-size: 11px;
    font-weight: 800;
    fill: var(--text-primary);
}
.post-save-actions {
    max-width: 480px;
    margin: 0 auto;
    display: flex;
    gap: 8px;
    pointer-events: auto;
}

/* ═══════════════════════════════════════════════════════════════
   STATISTICHE
   ═══════════════════════════════════════════════════════════════ */

#stats-view {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    background: var(--bg);
    padding: 16px 16px 80px;
}
#stats-view.hidden { display: none !important; }

.stats-loading {
    padding: 40px 20px;
    text-align: center;
    color: var(--text-tertiary);
}
.stats-empty {
    padding: 40px 24px;
    text-align: center;
}
.stats-empty h2 {
    font-size: 22px;
    font-weight: 800;
    margin-bottom: 10px;
    color: var(--text-primary);
}
.stats-empty p {
    font-size: 15px;
    color: var(--text-secondary);
    margin-bottom: 10px;
    line-height: 1.5;
}
.stats-empty-hint {
    font-size: 14px;
    color: var(--text-tertiary);
}

.stats-header {
    margin-bottom: 18px;
}
.stats-header h1 {
    font-size: 26px;
    font-weight: 900;
    color: var(--text-primary);
    letter-spacing: -0.5px;
    margin: 0;
}
.stats-header-sub {
    font-size: 13px;
    color: var(--text-tertiary);
    margin-top: 2px;
}

/* Hero card */
.stats-hero {
    border-radius: 22px;
    padding: 22px 22px 18px;
    margin-bottom: 20px;
    color: #fff;
    position: relative;
    overflow: hidden;
}
.stats-hero-saved {
    background: linear-gradient(135deg, #2D6A4F 0%, #40916C 100%);
    box-shadow: 0 6px 20px rgba(45,106,79,0.25);
}
.stats-hero-neutral {
    background: linear-gradient(135deg, #3D4A5C 0%, #5B6778 100%);
}
.stats-hero-warn {
    background: linear-gradient(135deg, #E76F51 0%, #F4A261 100%);
    box-shadow: 0 6px 20px rgba(231,111,81,0.25);
}
.stats-hero-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 12px;
}
.stats-hero-pill {
    background: rgba(255,255,255,0.22);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 800;
    color: #fff;
}

/* Risparmio dimostrabile */
.stats-demonstrable-card {
    background: linear-gradient(135deg, #D8F3DC 0%, #B7E4C7 100%);
    border: 1.5px solid var(--green-40, #52b788);
    border-radius: 18px;
    padding: 18px 20px;
}
.stats-demonstrable-total {
    font-size: 36px;
    font-weight: 900;
    color: #1B4332;
    line-height: 1;
    letter-spacing: -0.8px;
}
.stats-demonstrable-sub {
    font-size: 13px;
    color: #2D6A4F;
    font-weight: 700;
    margin-top: 2px;
    margin-bottom: 12px;
}
.stats-demonstrable-rows {
    background: rgba(255,255,255,0.5);
    border-radius: 12px;
    padding: 4px 12px;
}
.stats-demon-row {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    font-size: 13px;
    border-bottom: 1px solid rgba(45,106,79,0.15);
}
.stats-demon-row:last-child { border-bottom: none; }
.stats-demon-row span:first-child {
    color: #2D6A4F;
    font-weight: 600;
}
.stats-demon-row span:last-child {
    color: #1B4332;
    font-weight: 800;
}
.stats-demonstrable-hint {
    font-size: 11px;
    color: #52796f;
    margin-top: 10px;
    font-style: italic;
    text-align: center;
}
.stats-header {
    margin-bottom: 18px;
    position: relative;
}
.stats-export-btn {
    position: absolute;
    top: 0;
    right: 0;
    background: var(--surface);
    border: 1.5px solid var(--border);
    border-radius: 12px;
    padding: 8px 12px;
    font-size: 13px;
    font-weight: 700;
    color: var(--text-primary);
    cursor: pointer;
    font-family: inherit;
}
.stats-export-btn:active { transform: scale(0.96); }

.stats-choices-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}
.stats-choice-card {
    background: var(--surface);
    border: 1.5px solid var(--border);
    border-radius: 16px;
    padding: 14px 12px;
    text-align: center;
}
.stats-choice-icon {
    font-size: 26px;
    margin-bottom: 4px;
}
.stats-choice-val {
    font-size: 28px;
    font-weight: 900;
    color: var(--text-primary);
    line-height: 1;
}
.stats-choice-label {
    font-size: 12px;
    font-weight: 700;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.3px;
    margin-top: 4px;
}
.stats-choice-sub {
    font-size: 11px;
    color: var(--green-30);
    font-weight: 700;
    margin-top: 4px;
}
.stats-choice-card {
    padding: 12px 8px;
}
.stats-choice-icon { font-size: 22px; }
.stats-choice-val { font-size: 22px; }
.stats-choice-label { font-size: 11px; }

/* Nutrient card */
.stats-nutr-card {
    background: var(--surface);
    border: 1.5px solid var(--border);
    border-radius: 16px;
    padding: 14px 16px;
}
.stats-nutr-hint {
    font-size: 11px;
    color: var(--text-tertiary);
    text-align: center;
    margin-bottom: 10px;
    text-transform: uppercase;
    letter-spacing: 0.4px;
}
.stats-nutr-row {
    padding: 14px 4px;
    border-bottom: 1px solid var(--border);
}
.stats-nutr-row:last-child { border-bottom: none; }
.stats-nutr-row.clickable {
    cursor: pointer;
    transition: background 0.15s;
    border-radius: 8px;
}
.stats-nutr-row.clickable:active {
    background: var(--bg);
}
.stats-nutr-head-wrap {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
}
.stats-nutr-icon {
    font-size: 20px;
    flex-shrink: 0;
}
.stats-nutr-label {
    flex: 1;
    font-size: 14px;
    font-weight: 700;
    color: var(--text-primary);
}
.stats-nutr-val {
    font-size: 15px;
    font-weight: 800;
}
.stats-nutr-rda {
    font-size: 11px;
    font-weight: 800;
    color: var(--text-tertiary);
    background: var(--bg);
    padding: 3px 8px;
    border-radius: 10px;
    white-space: nowrap;
    margin-left: 8px;
}
.stats-nutr-scale {
    position: relative;
    padding: 0 2px;
}
.stats-nutr-scale-bar {
    position: relative;
    width: 100%;
    height: 10px;
    border-radius: 5px;
    overflow: visible;
    background: var(--bg);
}
.stats-nutr-seg {
    position: absolute;
    top: 0;
    bottom: 0;
    opacity: 0.88;
}
.stats-nutr-seg:first-of-type { border-radius: 5px 0 0 5px; }
.stats-nutr-seg:last-of-type { border-radius: 0 5px 5px 0; }
.stats-nutr-marker {
    position: absolute;
    top: -16px;
    transform: translateX(-50%);
    color: var(--text-primary);
    font-size: 14px;
    font-weight: 900;
    line-height: 1;
    text-shadow: 0 1px 2px rgba(255,255,255,0.95), 0 0 4px rgba(255,255,255,0.8);
    pointer-events: none;
}
.stats-nutr-ticks {
    position: relative;
    height: 16px;
    margin-top: 4px;
}
.stats-nutr-ticks span {
    position: absolute;
    transform: translateX(-50%);
    font-size: 10px;
    font-weight: 700;
    color: var(--text-tertiary);
    white-space: nowrap;
}
.stats-nutr-ticks span:first-child { transform: none; left: 0 !important; }

/* Nutrient info popup */
.nutr-info-sheet {
    position: fixed;
    inset: 0;
    z-index: 10000;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.2s;
    pointer-events: none;
}
.nutr-info-sheet.open {
    opacity: 1;
    pointer-events: auto;
}
.nutr-info-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.55);
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
}
.nutr-info-content {
    position: relative;
    width: 100%;
    max-width: 480px;
    max-height: 88vh;
    overflow-y: auto;
    background: var(--surface);
    border-radius: 22px 22px 0 0;
    padding: 24px 22px 28px;
    animation: sheetUp 0.28s ease;
}
.nutr-info-close {
    position: absolute;
    top: 14px;
    right: 14px;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: var(--bg);
    border: none;
    font-size: 16px;
    cursor: pointer;
}
.nutr-info-content h3 {
    font-size: 22px;
    font-weight: 900;
    color: var(--text-primary);
    margin: 0 0 8px;
}
.nutr-info-value {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 14px;
}
.nutr-info-value b {
    color: var(--green-30);
    font-size: 17px;
}
.nutr-info-rda {
    background: linear-gradient(135deg, #EDF8EF, #D8F3DC);
    border: 1.5px solid var(--green-40, #52b788);
    border-radius: 14px;
    padding: 14px 16px;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 14px;
}
.nutr-info-rda-big {
    font-size: 40px;
    font-weight: 900;
    color: #1B4332;
    line-height: 1;
    letter-spacing: -1px;
    flex-shrink: 0;
}
.nutr-info-rda-big span {
    font-size: 16px;
    font-weight: 800;
    margin-left: 2px;
}
.nutr-info-rda-desc {
    font-size: 12px;
    color: #2D6A4F;
    line-height: 1.4;
    flex: 1;
}
.nutr-info-rda-desc b { color: #1B4332; }
.nutr-info-content p {
    font-size: 14px;
    line-height: 1.5;
    color: var(--text-primary);
    margin: 0 0 14px;
}
.nutr-info-block {
    background: var(--bg);
    border-radius: 14px;
    padding: 14px 16px;
    margin-bottom: 14px;
}
.nutr-info-block-title {
    font-size: 12px;
    font-weight: 800;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.4px;
    margin-bottom: 8px;
}
.nutr-info-thresholds {
    font-size: 14px;
    line-height: 1.6;
    color: var(--text-primary);
}
.nutr-info-tip {
    background: linear-gradient(135deg, #EDF8EF, #D8F3DC);
    border: 1.5px solid var(--green-40, #52b788);
}
.nutr-info-tip p {
    margin: 0;
    font-size: 13px;
    color: #1B4332;
}
.nutr-info-action {
    background: linear-gradient(135deg, #FEF3C7, #FDE68A);
    border: 1.5px solid #F59E0B;
}
.nutr-info-action p {
    margin: 0;
    font-size: 13px;
    line-height: 1.5;
    color: #78350F;
}
.nutr-info-action-red {
    background: linear-gradient(135deg, #FEE2E2, #FECACA);
    border-color: #DC2626;
}
.nutr-info-action-red p { color: #7F1D1D; }
.nutr-info-action .nutr-info-block-title { color: #78350F; }
.nutr-info-action-red .nutr-info-block-title { color: #7F1D1D; }
.nutr-info-disclaimer {
    background: #FEF3C7;
    border-radius: 12px;
    padding: 12px 14px;
    font-size: 12px;
    color: #78350F;
    line-height: 1.5;
    margin-top: 4px;
}
.stats-hero-label {
    font-size: 13px;
    font-weight: 600;
    opacity: 0.85;
    margin-bottom: 6px;
}
.stats-hero-value {
    font-size: 42px;
    font-weight: 900;
    line-height: 1;
    letter-spacing: -1px;
    margin-bottom: 6px;
}
.stats-hero-sub {
    font-size: 14px;
    opacity: 0.9;
}

/* Sections */
.stats-section {
    margin-bottom: 22px;
}
.stats-section-title {
    font-size: 18px;
    font-weight: 800;
    color: var(--text-primary);
    margin: 0 0 10px 4px;
}

.stats-grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}
.stats-card {
    background: var(--surface);
    border-radius: 16px;
    padding: 16px 14px;
    border: 1.5px solid var(--border);
}
.stats-card-accent {
    background: linear-gradient(135deg, #EDF8EF 0%, #D8F3DC 100%);
    border-color: var(--green-30);
}
.stats-card-label {
    font-size: 12px;
    font-weight: 700;
    color: var(--text-tertiary);
    margin-bottom: 4px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}
.stats-card-value {
    font-size: 22px;
    font-weight: 900;
    color: var(--text-primary);
    line-height: 1.1;
    margin-bottom: 2px;
}
.stats-card-accent .stats-card-value { color: var(--green-30); }
.stats-card-sub {
    font-size: 12px;
    color: var(--text-tertiary);
}

/* Last trip */
.stats-last-trip {
    background: var(--surface);
    border: 1.5px solid var(--border);
    border-radius: 16px;
    padding: 16px;
    cursor: pointer;
}
.stats-last-trip:active { transform: scale(0.98); }
.stats-last-trip-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
}
.stats-last-store {
    font-size: 16px;
    font-weight: 800;
    color: var(--text-primary);
}
.stats-last-date {
    font-size: 13px;
    color: var(--text-tertiary);
}
.stats-last-total {
    font-size: 28px;
    font-weight: 900;
    color: var(--green-30);
    letter-spacing: -0.5px;
}
.stats-last-count {
    font-size: 13px;
    color: var(--text-secondary);
}

/* Top list */
.stats-top-list {
    background: var(--surface);
    border-radius: 16px;
    border: 1.5px solid var(--border);
    overflow: hidden;
}
.stats-top-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    border-bottom: 1px solid var(--border);
}
.stats-top-row:last-child { border-bottom: none; }
.stats-top-rank {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--green-90, #EDF8EF);
    color: var(--green-30);
    font-weight: 900;
    font-size: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.stats-top-info {
    flex: 1;
    min-width: 0;
}
.stats-top-name {
    font-size: 14px;
    font-weight: 700;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.stats-top-marca {
    font-size: 12px;
    color: var(--text-tertiary);
}
.stats-top-qty {
    font-size: 14px;
    font-weight: 800;
    color: var(--green-30);
    flex-shrink: 0;
}

/* Reparto bars */
.stats-reparto-list {
    background: var(--surface);
    border-radius: 16px;
    border: 1.5px solid var(--border);
    padding: 14px 16px;
}
.stats-reparto-row { margin-bottom: 12px; }
.stats-reparto-row:last-child { margin-bottom: 0; }
.stats-reparto-head {
    display: flex;
    justify-content: space-between;
    margin-bottom: 4px;
}
.stats-reparto-name {
    font-size: 13px;
    font-weight: 700;
    color: var(--text-primary);
}
.stats-reparto-val {
    font-size: 13px;
    font-weight: 800;
    color: var(--green-30);
}
.stats-reparto-bar {
    height: 6px;
    background: var(--bg);
    border-radius: 3px;
    overflow: hidden;
}
.stats-reparto-fill {
    height: 100%;
    background: var(--green-30);
    border-radius: 3px;
    transition: width 0.3s;
}

/* Breakdown (premium) */
.stats-breakdown {
    background: var(--surface);
    border-radius: 16px;
    border: 1.5px solid var(--border);
    padding: 6px 16px;
}
.stats-breakdown-row {
    display: flex;
    justify-content: space-between;
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
    font-size: 14px;
}
.stats-breakdown-row:last-child { border-bottom: none; }
.stats-breakdown-row span:first-child { color: var(--text-secondary); font-weight: 600; }
.stats-breakdown-row span:last-child { color: var(--green-30); font-weight: 800; }

/* Premium teaser */
.stats-premium-teaser {
    background: linear-gradient(135deg, #FEF3C7 0%, #FDE68A 100%);
    border-radius: 18px;
    padding: 20px;
    text-align: center;
}
.stats-premium-teaser h3 {
    font-size: 17px;
    font-weight: 800;
    color: #78350F;
    margin-bottom: 6px;
}
.stats-premium-teaser p {
    font-size: 13px;
    color: #92400E;
    line-height: 1.5;
    margin-bottom: 14px;
}

/* History */
.stats-history-list {
    background: var(--surface);
    border-radius: 16px;
    border: 1.5px solid var(--border);
    overflow: hidden;
}
.stats-history-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
}
.stats-history-row:last-child { border-bottom: none; }
.stats-history-row:active { background: var(--bg); }
.stats-history-main { flex: 1; min-width: 0; }
.stats-history-store {
    font-size: 15px;
    font-weight: 800;
    color: var(--text-primary);
}
.stats-history-date {
    font-size: 12px;
    color: var(--text-tertiary);
}
.stats-history-right {
    text-align: right;
    flex-shrink: 0;
}
.stats-history-total {
    font-size: 16px;
    font-weight: 900;
    color: var(--green-30);
}
.stats-history-saved {
    font-size: 11px;
    color: var(--text-tertiary);
    font-weight: 600;
}
.stats-history-more {
    padding: 14px 16px;
    text-align: center;
    font-size: 12px;
    color: var(--text-tertiary);
    font-style: italic;
}

/* Trip detail sheet */
.trip-detail-sheet {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: flex;
    align-items: flex-end;
    opacity: 0;
    transition: opacity 0.2s;
    pointer-events: none;
}
.trip-detail-sheet.open {
    opacity: 1;
    pointer-events: auto;
}
.trip-detail-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.55);
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
}
.trip-detail-content {
    position: relative;
    width: 100%;
    max-width: 480px;
    margin: 0 auto;
    max-height: 88vh;
    background: var(--surface);
    border-radius: 22px 22px 0 0;
    display: flex;
    flex-direction: column;
    animation: sheetUp 0.28s ease;
}
.trip-detail-header {
    padding: 20px 20px 12px;
    border-bottom: 1px solid var(--border);
    position: relative;
}
.trip-detail-header h3 {
    font-size: 22px;
    font-weight: 900;
    color: var(--text-primary);
    margin: 0;
}
.trip-detail-date {
    font-size: 13px;
    color: var(--text-tertiary);
    margin-top: 2px;
}
.trip-detail-close {
    position: absolute;
    top: 14px;
    right: 14px;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--bg);
    border: none;
    font-size: 16px;
    cursor: pointer;
}
.trip-detail-totals {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
}
.trip-detail-total-main {
    font-size: 32px;
    font-weight: 900;
    color: var(--green-30);
    letter-spacing: -1px;
    line-height: 1;
}
.trip-detail-saved {
    font-size: 14px;
    font-weight: 700;
    color: var(--text-primary);
    margin-top: 6px;
}
.trip-detail-count {
    font-size: 13px;
    color: var(--text-tertiary);
    margin-top: 4px;
}
.trip-detail-items {
    padding: 12px 20px;
    overflow-y: auto;
    flex: 1;
}
.trip-detail-item {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
    gap: 10px;
}
.trip-detail-item:last-child { border-bottom: none; }
.trip-detail-item-info {
    flex: 1;
    min-width: 0;
}
.trip-detail-item-name {
    font-size: 15px;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.3;
}
.trip-detail-item-meta {
    font-size: 12px;
    color: var(--text-tertiary);
    margin-top: 2px;
}
.trip-detail-item-sub {
    font-size: 12px;
    color: var(--green-30);
    margin-top: 4px;
    font-weight: 600;
}
.trip-detail-item-price {
    font-size: 15px;
    font-weight: 800;
    color: var(--green-30);
    flex-shrink: 0;
}
.trip-detail-notes {
    padding: 12px 20px;
    font-size: 13px;
    color: var(--text-secondary);
    font-style: italic;
    border-top: 1px solid var(--border);
}
.trip-detail-footer {
    padding: 14px 20px calc(14px + env(safe-area-inset-bottom));
    border-top: 1px solid var(--border);
    display: flex;
    gap: 10px;
}

/* ── Trip history ── */
.trip-history-btn {
    margin-top: 16px;
    padding: 12px 24px;
    background: var(--green-30);
    color: #fff;
    border: none;
    border-radius: 12px;
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
}
.seg-btn-history {
    min-width: 38px;
    padding: 0 8px;
    font-size: 18px;
    margin-left: auto;
    background: transparent;
    border: 1px solid var(--border);
}
.trip-history-list { display: flex; flex-direction: column; gap: 2px; }
.trip-history-row {
    display: flex; justify-content: space-between; align-items: center;
    padding: 12px 14px; border-radius: 12px; cursor: pointer;
    background: var(--surface); border: 1px solid var(--border);
}
.trip-history-row:active { background: var(--border); }
.trip-history-store { font-weight: 700; font-size: 14px; }
.trip-history-meta { font-size: 12px; color: var(--text-tertiary); margin-top: 2px; }
.trip-history-right { text-align: right; }
.trip-history-total { font-weight: 800; font-size: 15px; }
.trip-history-sav { font-size: 12px; color: var(--green-30); font-weight: 700; }

/* ── Locked history rows ── */
.stats-history-locked {
    opacity: 0.45;
    pointer-events: auto;
    cursor: pointer;
}
.stats-history-locked .stats-history-store,
.stats-history-locked .stats-history-date {
    filter: blur(1px);
}
.stats-history-lock {
    font-size: 12px;
    font-weight: 700;
    color: var(--green-30);
    background: var(--green-90);
    padding: 3px 10px;
    border-radius: 8px;
}
.stats-history-more {
    text-align: center;
    padding: 12px;
    font-size: 13px;
    font-weight: 700;
    color: var(--green-30);
    cursor: pointer;
}

/* ── Chart premium overlay ── */
.chart-premium-overlay {
    display: flex;
    justify-content: center;
    margin: -20px 0 10px;
    position: relative;
    z-index: 1;
}
.chart-premium-badge {
    text-align: center;
    padding: 16px 24px;
    background: var(--surface);
    border: 2px solid var(--green-30);
    border-radius: 16px;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(0,0,0,0.08);
}
.chart-premium-badge:active { transform: scale(0.97); }

/* ── Toast ── */
.toast-msg {
    position: fixed; bottom: calc(80px + env(safe-area-inset-bottom));
    left: 50%; transform: translateX(-50%) translateY(20px);
    background: var(--green-10); color: #fff;
    padding: 10px 20px; border-radius: 12px;
    font-size: 14px; font-weight: 700;
    opacity: 0; transition: all 0.3s ease;
    z-index: 10000; pointer-events: none;
}
.toast-msg.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ── Trip detail add buttons ── */
.trip-detail-item-right {
    display: flex; align-items: center; gap: 8px; flex-shrink: 0;
}
.trip-add-btn {
    width: 30px; height: 30px; border-radius: 50%;
    background: var(--green-30); color: #fff;
    border: none; font-size: 18px; font-weight: 700;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer; flex-shrink: 0;
}
.trip-add-btn:active { transform: scale(0.9); }
.trip-in-cart {
    width: 30px; height: 30px; border-radius: 50%;
    background: var(--green-80); color: var(--green-30);
    font-size: 14px; font-weight: 800;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}
