:root {
    /* Светлая тема по умолчанию */
    --bg-color: #f6f7f9;
    --surface-card: #ffffff;
    --surface-muted: #f0f2f5;
    --surface-header: rgba(255, 255, 255, 0.94);
    --surface-nav: rgba(255, 255, 255, 0.96);
    --text-main: #111827;
    --text-muted: #6b7280;
    --text-subtle: #9ca3af;
    --border-subtle: rgba(0, 0, 0, 0.08);
    --border-card: rgba(0, 0, 0, 0.06);

    /* Акцентный цвет (Telegram primary или современный Azure) */
    --brand-primary: var(--tg-theme-button-color, #2563eb);
    --brand-primary-text: var(--tg-theme-button-text-color, #ffffff);
    --brand-primary-light: #eff6ff;
    --brand-primary-tint: rgba(37, 99, 235, 0.08);

    /* Цены и скидки */
    --price-color: #e11d48;
    --discount-accent: #f43f5e;
    --discount-gradient: linear-gradient(135deg, #f43f5e 0%, #e11d48 100%);
    --discount-bg: #fff1f2;

    /* Статусы */
    --success-accent: #10b981;
    --success-bg: #ecfdf5;
    --danger-accent: #ef4444;
    --danger-bg: #fef2f2;

    /* Тени и скругления */
    --card-shadow: 0 1px 3px rgba(0, 0, 0, 0.04), 0 3px 8px rgba(0, 0, 0, 0.02);
    --radius-sm: 8px;
    --radius-md: 14px;
    --radius-lg: 18px;
    --radius-full: 9999px;

    --font-family: -apple-system, BlinkMacSystemFont, 'Inter', 'SF Pro Display', 'Segoe UI', Roboto, sans-serif;
    --safe-bottom: env(safe-area-inset-bottom, 0px);
}

/* ТЁМНАЯ ТЕМА (когда Telegram в тёмном режиме или система dark) */
:root.dark,
body.dark,
.dark {
    --bg-color: var(--tg-theme-bg-color, #121316);
    --surface-card: var(--tg-theme-secondary-bg-color, #1e2026);
    --surface-muted: #282b34;
    --surface-header: rgba(22, 24, 30, 0.94);
    --surface-nav: rgba(22, 24, 30, 0.96);
    --text-main: var(--tg-theme-text-color, #f9fafb);
    --text-muted: var(--tg-theme-hint-color, #9ca3af);
    --text-subtle: #6b7280;
    --border-subtle: rgba(255, 255, 255, 0.09);
    --border-card: rgba(255, 255, 255, 0.07);

    --brand-primary: var(--tg-theme-button-color, #3b82f6);
    --brand-primary-text: var(--tg-theme-button-text-color, #ffffff);
    --brand-primary-light: rgba(59, 130, 246, 0.18);
    --brand-primary-tint: rgba(59, 130, 246, 0.15);

    --price-color: #fb7185;
    --discount-accent: #fb7185;
    --discount-gradient: linear-gradient(135deg, #f43f5e 0%, #e11d48 100%);
    --discount-bg: rgba(244, 63, 94, 0.2);

    --success-accent: #34d399;
    --success-bg: rgba(16, 185, 129, 0.2);

    --danger-accent: #f87171;
    --danger-bg: rgba(239, 68, 68, 0.2);

    --card-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
}

@media (prefers-color-scheme: dark) {
    :root:not(.light) {
        --bg-color: var(--tg-theme-bg-color, #121316);
        --surface-card: var(--tg-theme-secondary-bg-color, #1e2026);
        --surface-muted: #282b34;
        --surface-header: rgba(22, 24, 30, 0.94);
        --surface-nav: rgba(22, 24, 30, 0.96);
        --text-main: var(--tg-theme-text-color, #f9fafb);
        --text-muted: var(--tg-theme-hint-color, #9ca3af);
        --text-subtle: #6b7280;
        --border-subtle: rgba(255, 255, 255, 0.09);
        --border-card: rgba(255, 255, 255, 0.07);

        --brand-primary: var(--tg-theme-button-color, #3b82f6);
        --brand-primary-text: var(--tg-theme-button-text-color, #ffffff);
        --brand-primary-light: rgba(59, 130, 246, 0.18);

        --price-color: #fb7185;
        --discount-accent: #fb7185;
        --discount-bg: rgba(244, 63, 94, 0.2);
        --success-accent: #34d399;
        --success-bg: rgba(16, 185, 129, 0.2);
        --danger-accent: #f87171;
        --danger-bg: rgba(239, 68, 68, 0.2);
        --card-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
    }
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: var(--font-family);
    background-color: var(--bg-color);
    color: var(--text-main);
    line-height: 1.4;
    overflow-x: hidden;
    padding-bottom: calc(70px + var(--safe-bottom));
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

#app {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* --- ВЕРХНЯЯ ШАПКА ПОИСКА И ФИЛЬТРОВ --- */
.app-header {
    position: sticky;
    top: 0;
    z-index: 90;
    background: var(--surface-header);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--border-subtle);
    padding: 8px 12px 6px;
}

.search-bar-wrap {
    display: flex;
    align-items: center;
    background: var(--surface-muted);
    border-radius: var(--radius-full);
    padding: 7px 12px;
    position: relative;
    border: 1px solid var(--border-subtle);
    transition: all 0.2s ease;
}

.search-bar-wrap:focus-within {
    border-color: var(--brand-primary);
    box-shadow: 0 0 0 3px var(--brand-primary-tint);
}

.search-icon {
    font-size: 14px;
    margin-right: 8px;
    opacity: 0.55;
}

#searchInput {
    flex: 1;
    border: none;
    background: transparent;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-main);
    outline: none;
    font-family: inherit;
}

#searchInput::placeholder {
    color: var(--text-muted);
    font-weight: 400;
}

.clear-btn {
    border: none;
    background: rgba(148, 163, 184, 0.25);
    color: var(--text-muted);
    width: 20px;
    height: 20px;
    border-radius: 50%;
    font-size: 10px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s;
}

.clear-btn:active {
    background: rgba(148, 163, 184, 0.45);
}

/* Бейдж активного фильтра */
.active-filter-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--brand-primary-light);
    border: 1px solid rgba(37, 99, 235, 0.2);
    border-radius: var(--radius-sm);
    padding: 5px 10px;
    margin-top: 6px;
    animation: fadeIn 0.2s ease-in;
}

.filter-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--brand-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.filter-close-btn {
    border: none;
    background: rgba(37, 99, 235, 0.15);
    color: var(--brand-primary);
    width: 18px;
    height: 18px;
    border-radius: 50%;
    font-size: 10px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-left: 8px;
    transition: background 0.15s;
}

/* Строка статуса и сортировка */
.feed-controls {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 6px;
    font-size: 12px;
}

.results-count {
    color: var(--text-muted);
    font-weight: 500;
    font-size: 11px;
}

.sort-trigger-btn {
    border: 1px solid var(--border-subtle);
    background: var(--surface-muted);
    color: var(--text-main);
    font-size: 11px;
    font-weight: 600;
    padding: 5px 10px;
    border-radius: var(--radius-full);
    outline: none;
    cursor: pointer;
    font-family: inherit;
    display: flex;
    align-items: center;
    gap: 5px;
    transition: all 0.15s ease;
    white-space: nowrap;
}

.sort-trigger-btn:active {
    transform: scale(0.96);
    background: var(--surface-card);
}

.sort-trigger-arrow {
    font-size: 9px;
    color: var(--text-muted);
}

.sort-options-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding-top: 4px;
}

.sort-option-row {
    background: var(--surface-muted);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 12px 14px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    transition: all 0.15s ease;
}

.sort-option-row:active {
    transform: scale(0.985);
}

.sort-option-row.active {
    background: var(--brand-primary-light);
    border-color: var(--brand-primary);
}

.sort-option-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.sort-option-icon {
    font-size: 18px;
}

.sort-option-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-main);
}

.sort-option-row.active .sort-option-name {
    color: var(--brand-primary);
    font-weight: 700;
}

.sort-option-check {
    font-size: 14px;
    font-weight: 700;
    color: var(--brand-primary);
    opacity: 0;
    transition: opacity 0.15s ease;
}

.sort-option-row.active .sort-option-check {
    opacity: 1;
}

/* --- ОСНОВНАЯ ЧАСТЬ КОНТЕНТА --- */
.app-main {
    flex: 1;
    padding: 8px 10px;
}

.tab-pane {
    animation: fadeIn 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(4px); }
    to { opacity: 1; transform: translateY(0); }
}

/* --- 1. СЕТКА ТОВАРОВ (ЛЕНТА) --- */
.products-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
}

.product-card {
    background: var(--surface-card);
    border-radius: var(--radius-md);
    box-shadow: var(--card-shadow);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    position: relative;
    border: 1px solid var(--border-card);
    transition: transform 0.12s ease;
}

.product-card:active {
    transform: scale(0.98);
}

.card-img-wrap {
    position: relative;
    width: 100%;
    padding-top: 80%;
    background: #ffffff;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 12px 12px 0 0;
}

.card-img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
    padding: 6px;
    background: #ffffff;
}

.discount-badge {
    position: absolute;
    top: 6px;
    left: 6px;
    background: var(--discount-gradient);
    color: #ffffff;
    font-size: 11px;
    font-weight: 800;
    padding: 2px 7px;
    border-radius: var(--radius-full);
    box-shadow: 0 2px 6px rgba(244, 63, 94, 0.4);
    letter-spacing: -0.2px;
    z-index: 2;
}

.store-tag {
    position: absolute;
    bottom: 6px;
    left: 6px;
    background: rgba(15, 23, 42, 0.78);
    color: #ffffff;
    font-size: 10px;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: var(--radius-sm);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    max-width: 85%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    z-index: 2;
}

.card-content {
    padding: 8px 10px 10px;
    display: flex;
    flex-direction: column;
    flex: 1;
    background: var(--surface-card);
}

.product-title {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-main);
    line-height: 1.32;
    height: 32px;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    margin-bottom: 4px;
}

.product-dates {
    font-size: 10px;
    color: var(--text-muted);
    margin-bottom: 6px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.price-row {
    display: flex;
    align-items: baseline;
    gap: 6px;
    margin-bottom: 8px;
    margin-top: auto;
}

.current-price {
    font-size: 15px;
    font-weight: 800;
    color: var(--price-color);
    letter-spacing: -0.2px;
}

.old-price {
    font-size: 11px;
    color: var(--text-subtle);
    text-decoration: line-through;
    font-weight: 500;
}

.btn-add-cart {
    width: 100%;
    padding: 7px 0;
    border: none;
    border-radius: var(--radius-full);
    background: var(--brand-primary-light);
    color: var(--brand-primary);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
}

.btn-add-cart:active {
    transform: scale(0.96);
}

.btn-add-cart.in-cart {
    background: var(--success-bg);
    color: var(--success-accent);
}

/* Скелетон */
.product-card.skeleton {
    height: 220px;
    background: linear-gradient(90deg, var(--surface-card) 25%, var(--surface-muted) 50%, var(--surface-card) 75%);
    background-size: 200% 100%;
    animation: skeleton-loading 1.4s infinite ease-in-out;
}

@keyframes skeleton-loading {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

.load-more-wrap {
    text-align: center;
    margin: 16px 0 10px;
}

.btn-secondary {
    background: var(--surface-card);
    color: var(--brand-primary);
    border: 1px solid var(--border-subtle);
    padding: 9px 22px;
    border-radius: var(--radius-full);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    box-shadow: var(--card-shadow);
}

.empty-state {
    text-align: center;
    padding: 40px 16px;
    background: var(--surface-card);
    border-radius: var(--radius-lg);
    box-shadow: var(--card-shadow);
    margin: 16px 0;
    border: 1px solid var(--border-card);
}

.empty-icon {
    font-size: 40px;
    margin-bottom: 10px;
    opacity: 0.85;
}

.empty-state h3 {
    font-size: 15px;
    font-weight: 700;
    color: var(--text-main);
    margin-bottom: 6px;
}

.empty-state p {
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 16px;
    max-width: 280px;
    margin-left: auto;
    margin-right: auto;
}

.btn-primary {
    background: var(--brand-primary);
    color: var(--brand-primary-text);
    border: none;
    padding: 9px 20px;
    border-radius: var(--radius-full);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
}

/* --- 2. КАТАЛОГ (КАТЕГОРИИ И МАГАЗИНЫ) --- */
.segmented-control {
    display: flex;
    background: var(--surface-muted);
    padding: 3px;
    border-radius: var(--radius-full);
    margin-bottom: 12px;
    border: 1px solid var(--border-subtle);
}

.segment-btn {
    flex: 1;
    border: none;
    background: transparent;
    color: var(--text-muted);
    font-size: 13px;
    font-weight: 600;
    padding: 7px 12px;
    border-radius: var(--radius-full);
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    font-family: inherit;
}

.segment-btn.active {
    background: var(--surface-card);
    color: var(--text-main);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
}

.section-title-wrap {
    margin-bottom: 10px;
}

.section-title-wrap h2 {
    font-size: 15px;
    font-weight: 700;
    color: var(--text-main);
}

.section-subtitle {
    font-size: 11px;
    color: var(--text-muted);
}

.categories-grid, .stores-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
}

.category-card, .store-card {
    background: var(--surface-card);
    border-radius: var(--radius-md);
    padding: 12px;
    box-shadow: var(--card-shadow);
    border: 1px solid var(--border-card);
    cursor: pointer;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    transition: transform 0.12s ease;
}

.category-card:active, .store-card:active {
    transform: scale(0.97);
}

.cat-card-top, .store-card-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
}

.cat-icon, .store-emoji {
    font-size: 24px;
    background: var(--surface-muted);
    width: 40px;
    height: 40px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.cat-badge, .store-badge {
    background: var(--discount-bg);
    color: var(--discount-accent);
    font-size: 10px;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: var(--radius-full);
}

.cat-title, .store-name {
    font-size: 13px;
    font-weight: 700;
    color: var(--text-main);
    margin-bottom: 2px;
}

.cat-footer, .store-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 11px;
    color: var(--text-subtle);
    margin-top: 6px;
}

.cat-footer span, .store-footer span {
    color: var(--brand-primary);
    font-weight: 600;
}

/* --- 3. ПОДПИСКИ --- */
.subs-header-card {
    background: var(--surface-card);
    border-radius: var(--radius-md);
    padding: 12px 14px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
    border: 1px solid var(--border-card);
    box-shadow: var(--card-shadow);
}

.subs-header-info h2 {
    font-size: 15px;
    font-weight: 700;
    margin-bottom: 2px;
    color: var(--text-main);
}

.subs-header-info p {
    font-size: 11px;
    color: var(--text-muted);
    max-width: 230px;
}

.subs-counter-badge {
    background: var(--brand-primary-light);
    color: var(--brand-primary);
    font-size: 12px;
    font-weight: 700;
    padding: 5px 10px;
    border-radius: var(--radius-full);
    white-space: nowrap;
}

.expiring-header-card {
    background: linear-gradient(135deg, rgba(239, 68, 68, 0.08) 0%, rgba(245, 158, 11, 0.08) 100%);
    border-color: rgba(239, 68, 68, 0.25);
}

.expiring-badge-counter {
    background: rgba(239, 68, 68, 0.15);
    color: #ef4444;
}

.product-dates.expiring-urgent {
    color: #ef4444;
    font-weight: 700;
    font-size: 11px;
    background: rgba(239, 68, 68, 0.12);
    padding: 3px 7px;
    border-radius: 6px;
    display: inline-flex;
    align-items: center;
    gap: 3px;
    margin-bottom: 4px;
}

.product-dates.expiring-warning {
    color: #d97706;
    font-weight: 700;
    font-size: 11px;
    background: rgba(245, 158, 11, 0.14);
    padding: 3px 7px;
    border-radius: 6px;
    display: inline-flex;
    align-items: center;
    gap: 3px;
    margin-bottom: 4px;
}

.product-dates-sub {
    font-size: 10px;
    color: var(--text-muted);
    margin-bottom: 6px;
}

html.dark .product-dates.expiring-warning {
    color: #fbbf24;
    background: rgba(245, 158, 11, 0.2);
}

html.dark .product-dates.expiring-urgent {
    color: #f87171;
    background: rgba(239, 68, 68, 0.2);
}

.add-sub-box {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
}

#subKeywordInput {
    flex: 1;
    background: var(--surface-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 9px 12px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-main);
    outline: none;
    font-family: inherit;
    box-shadow: var(--card-shadow);
}

#subKeywordInput:focus {
    border-color: var(--brand-primary);
    box-shadow: 0 0 0 3px var(--brand-primary-tint);
}

.btn-add-sub {
    background: var(--brand-primary);
    color: var(--brand-primary-text);
    border: none;
    border-radius: var(--radius-md);
    padding: 0 14px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    box-shadow: var(--card-shadow);
}

.subs-list-header {
    display: flex;
    flex-direction: column;
    margin-bottom: 8px;
}

.subs-list-header span:first-child {
    font-size: 13px;
    font-weight: 700;
    color: var(--text-main);
}

.subs-hint {
    font-size: 10px;
    color: var(--text-muted);
}

.subs-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.sub-item-card {
    background: var(--surface-card);
    border-radius: var(--radius-md);
    padding: 12px;
    box-shadow: var(--card-shadow);
    border: 1px solid var(--border-card);
    display: flex;
    flex-direction: column;
    gap: 8px;
    cursor: pointer;
    transition: transform 0.12s ease;
}

.sub-item-card:active {
    transform: scale(0.985);
}

.sub-card-main-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.sub-item-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

.sub-emoji {
    font-size: 18px;
    background: var(--surface-muted);
    width: 34px;
    height: 34px;
    border-radius: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.sub-keyword {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-main);
    text-transform: capitalize;
}

.sub-item-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

.sub-deals-count {
    background: var(--discount-bg);
    color: var(--discount-accent);
    font-size: 11px;
    font-weight: 700;
    padding: 3px 8px;
    border-radius: var(--radius-full);
}

.sub-del-btn {
    border: none;
    background: var(--surface-muted);
    color: var(--text-muted);
    width: 26px;
    height: 26px;
    border-radius: 50%;
    font-size: 11px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
}

.sub-del-btn:active {
    background: var(--danger-accent);
    color: #ffffff;
}

/* Маленькие чипсы магазинов прямо на карточке подписки */
.sub-stores-chips {
    display: flex;
    gap: 6px;
    overflow-x: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
    padding-top: 2px;
}

.sub-stores-chips::-webkit-scrollbar {
    display: none;
}

.sub-store-chip {
    background: var(--surface-muted);
    color: var(--text-main);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-full);
    padding: 3px 8px;
    font-size: 11px;
    font-weight: 600;
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 4px;
    cursor: pointer;
    transition: all 0.15s ease;
}

.sub-store-chip:active {
    background: var(--brand-primary-light);
    color: var(--brand-primary);
    border-color: var(--brand-primary);
    transform: scale(0.96);
}

.sub-store-chip .chip-count {
    background: var(--discount-bg);
    color: var(--discount-accent);
    padding: 1px 5px;
    border-radius: var(--radius-full);
    font-size: 10px;
    font-weight: 700;
}

/* --- 4. КОРЗИНА --- */
.cart-summary-card {
    background: var(--surface-card);
    color: var(--text-main);
    border-radius: var(--radius-md);
    padding: 14px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
    box-shadow: var(--card-shadow);
    border: 1px solid var(--border-card);
}

.cart-summary-title {
    font-size: 14px;
    font-weight: 700;
}

.cart-summary-count {
    font-size: 11px;
    color: var(--text-muted);
}

.cart-total-label {
    font-size: 10px;
    color: var(--text-muted);
    text-align: right;
}

.cart-total-amount {
    font-size: 18px;
    font-weight: 800;
    color: var(--price-color);
}

.cart-action-bar {
    display: flex;
    gap: 8px;
    margin-bottom: 10px;
}

.btn-primary-compact {
    flex: 2;
    background: var(--brand-primary);
    color: var(--brand-primary-text);
    border: none;
    border-radius: var(--radius-md);
    padding: 9px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.btn-danger-compact {
    flex: 1;
    background: var(--danger-bg);
    color: var(--danger-accent);
    border: 1px solid rgba(239, 68, 68, 0.2);
    border-radius: var(--radius-md);
    padding: 9px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
}

.cart-checklist-hint {
    background: var(--surface-muted);
    padding: 6px 10px;
    border-radius: var(--radius-sm);
    font-size: 10px;
    color: var(--text-muted);
    margin-bottom: 10px;
    text-align: center;
}

.cart-items-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.cart-item-row {
    background: var(--surface-card);
    border-radius: var(--radius-md);
    padding: 10px 12px;
    box-shadow: var(--card-shadow);
    border: 1px solid var(--border-card);
    display: flex;
    align-items: center;
    gap: 10px;
    transition: opacity 0.2s;
}

.cart-item-row.completed {
    opacity: 0.5;
}

.cart-item-row.completed .cart-item-name {
    text-decoration: line-through;
    color: var(--text-muted);
}

.cart-checkbox {
    width: 20px;
    height: 20px;
    border-radius: 6px;
    border: 2px solid var(--text-subtle);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
    font-size: 11px;
    color: #ffffff;
    transition: all 0.15s ease;
}

.cart-checkbox.checked {
    background: var(--success-accent);
    border-color: var(--success-accent);
}

.cart-item-info {
    flex: 1;
    min-width: 0;
}

.cart-item-name {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-main);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 2px;
}

.cart-item-store {
    font-size: 10px;
    color: var(--text-muted);
}

.cart-item-price {
    font-size: 12px;
    font-weight: 700;
    color: var(--price-color);
    white-space: nowrap;
}

.cart-item-del-btn {
    border: none;
    background: transparent;
    color: var(--text-subtle);
    font-size: 14px;
    padding: 4px;
    cursor: pointer;
}

/* --- 5. НАСТРОЙКИ --- */
.settings-group {
    background: var(--surface-card);
    border-radius: var(--radius-md);
    padding: 12px 14px;
    margin-bottom: 10px;
    box-shadow: var(--card-shadow);
    border: 1px solid var(--border-card);
}

.settings-group-header {
    margin-bottom: 8px;
}

.settings-title {
    font-size: 13px;
    font-weight: 700;
    color: var(--text-main);
    margin-bottom: 2px;
}

.settings-sub {
    font-size: 11px;
    color: var(--text-muted);
}

.lang-selector {
    display: flex;
    gap: 8px;
    margin-top: 8px;
}

.lang-btn {
    flex: 1;
    border: 1px solid var(--border-subtle);
    background: var(--surface-muted);
    color: var(--text-main);
    padding: 8px 0;
    border-radius: var(--radius-sm);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    text-align: center;
    transition: all 0.15s;
    font-family: inherit;
}

.lang-btn.active {
    background: var(--brand-primary-light);
    color: var(--brand-primary);
    border-color: var(--brand-primary);
}

.theme-selector {
    display: flex;
    gap: 8px;
    margin-top: 8px;
}

.theme-btn {
    flex: 1;
    border: 1px solid var(--border-subtle);
    background: var(--surface-muted);
    color: var(--text-main);
    padding: 8px 4px;
    border-radius: var(--radius-sm);
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    text-align: center;
    transition: all 0.15s;
    font-family: inherit;
    white-space: nowrap;
}

.theme-btn:active {
    transform: scale(0.97);
}

.theme-btn.active {
    background: var(--brand-primary-light);
    color: var(--brand-primary);
    border-color: var(--brand-primary);
}

/* Аккордеон выбора магазинов в настройках */
.stores-accordion-btn {
    width: 100%;
    background: transparent;
    border: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 2px 0;
    cursor: pointer;
    font-family: inherit;
    text-align: left;
}

.accordion-left {
    display: flex;
    flex-direction: column;
}

.accordion-arrow {
    font-size: 10px;
    color: var(--text-muted);
    transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
    background: var(--surface-muted);
    width: 26px;
    height: 26px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.stores-accordion-btn.expanded .accordion-arrow {
    transform: rotate(180deg);
}

.stores-collapsible {
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid var(--border-subtle);
    animation: fadeIn 0.2s ease-out;
}

.stores-toolbar {
    display: flex;
    gap: 8px;
    margin-bottom: 8px;
}

.stores-tool-btn {
    flex: 1;
    background: var(--surface-muted);
    border: 1px solid var(--border-subtle);
    color: var(--text-main);
    font-size: 11px;
    font-weight: 600;
    padding: 6px 10px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.15s;
    font-family: inherit;
    text-align: center;
}

.stores-tool-btn:active {
    background: var(--brand-primary-light);
    color: var(--brand-primary);
    border-color: var(--brand-primary);
}

.stores-settings-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-top: 8px;
}

.store-setting-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 2px;
    border-bottom: 1px solid var(--border-subtle);
}

.store-setting-item:last-child {
    border-bottom: none;
}

.store-setting-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-main);
}

.custom-switch {
    position: relative;
    display: inline-block;
    width: 42px;
    height: 22px;
}

.custom-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--surface-muted);
    border: 1px solid var(--border-subtle);
    transition: .25s;
    border-radius: 22px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 16px;
    width: 16px;
    left: 2px;
    bottom: 2px;
    background-color: white;
    box-shadow: 0 1px 3px rgba(0,0,0,0.15);
    transition: .25s;
    border-radius: 50%;
}

input:checked + .slider {
    background-color: var(--success-accent);
    border-color: var(--success-accent);
}

input:checked + .slider:before {
    transform: translateX(20px);
}

.about-card {
    margin-top: 6px;
}

.about-text {
    font-size: 11px;
    color: var(--text-muted);
    line-height: 1.45;
    margin-bottom: 10px;
}

.about-stats {
    display: flex;
    gap: 8px;
}

.stat-item {
    flex: 1;
    background: var(--surface-muted);
    border-radius: var(--radius-sm);
    padding: 8px;
    text-align: center;
}

.stat-val {
    display: block;
    font-size: 16px;
    font-weight: 800;
    color: var(--brand-primary);
}

.stat-lbl {
    font-size: 10px;
    color: var(--text-muted);
}

/* --- НИЖНЯЯ ПАНЕЛЬ НАВИГАЦИИ --- */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: calc(54px + var(--safe-bottom));
    padding-bottom: var(--safe-bottom);
    background: var(--surface-nav);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-top: 1px solid var(--border-subtle);
    display: flex;
    align-items: center;
    justify-content: space-around;
    z-index: 100;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.05);
}

.nav-tab {
    flex: 1;
    height: 100%;
    background: transparent;
    border: none;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
    cursor: pointer;
    color: var(--text-muted);
    transition: color 0.15s ease;
    font-family: inherit;
}

.nav-icon {
    font-size: 18px;
    line-height: 1;
    margin-bottom: 2px;
    transition: transform 0.15s ease;
}

.nav-label {
    font-size: 10px;
    font-weight: 600;
}

.nav-tab.active {
    color: var(--brand-primary);
}

.nav-tab.active .nav-icon {
    transform: translateY(-1px) scale(1.08);
}

.nav-badge {
    position: absolute;
    top: 5px;
    right: calc(50% - 17px);
    background: var(--discount-accent);
    color: #ffffff;
    font-size: 10px;
    font-weight: 700;
    min-width: 15px;
    height: 15px;
    border-radius: 8px;
    padding: 0 3px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 1px 4px rgba(244, 63, 94, 0.4);
}

/* --- TOAST УВЕДОМЛЕНИЕ --- */
.toast-notification {
    position: fixed;
    bottom: calc(68px + var(--safe-bottom));
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: rgba(15, 23, 42, 0.92);
    color: #ffffff;
    font-size: 12px;
    font-weight: 600;
    padding: 7px 16px;
    border-radius: var(--radius-full);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.2);
    opacity: 0;
    pointer-events: none;
    transition: transform 0.22s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.22s ease;
    z-index: 200;
    white-space: nowrap;
}

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

/* --- BOTTOM SHEET ДЛЯ ВЫБОРА МАГАЗИНА ПО ПОДПИСКЕ --- */
.bottom-sheet-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 150;
    display: flex;
    align-items: flex-end;
    animation: fadeIn 0.2s ease-out;
}

.bottom-sheet-content {
    background: var(--surface-card);
    width: 100%;
    max-height: 75vh;
    border-radius: 20px 20px 0 0;
    padding: 16px 18px calc(24px + var(--safe-bottom));
    box-shadow: 0 -8px 24px rgba(0, 0, 0, 0.2);
    display: flex;
    flex-direction: column;
    animation: slideUp 0.25s cubic-bezier(0.16, 1, 0.3, 1);
    border-top: 1px solid var(--border-subtle);
}

@keyframes slideUp {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
}

.bottom-sheet-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border-subtle);
}

.sheet-title-wrap {
    display: flex;
    align-items: center;
    gap: 10px;
}

.sheet-emoji {
    font-size: 24px;
    background: var(--surface-muted);
    width: 42px;
    height: 42px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.sheet-title-wrap h3 {
    font-size: 15px;
    font-weight: 700;
    color: var(--text-main);
    text-transform: capitalize;
}

.sheet-sub {
    font-size: 11px;
    color: var(--text-muted);
}

.sheet-close-btn {
    border: none;
    background: var(--surface-muted);
    color: var(--text-muted);
    width: 28px;
    height: 28px;
    border-radius: 50%;
    font-size: 13px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.sub-stores-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    overflow-y: auto;
    max-height: 50vh;
    padding-right: 2px;
}

.sheet-store-row {
    background: var(--surface-muted);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 11px 14px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    transition: all 0.15s ease;
}

.sheet-store-row:active {
    background: var(--brand-primary-light);
    border-color: var(--brand-primary);
    transform: scale(0.985);
}

.sheet-store-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

.sheet-store-emoji {
    font-size: 20px;
}

.sheet-store-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-main);
}

.sheet-store-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

.sheet-store-badge {
    background: var(--discount-bg);
    color: var(--discount-accent);
    font-size: 11px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: var(--radius-full);
}

.sheet-store-arrow {
    color: var(--text-subtle);
    font-size: 13px;
}

/* --- ОБРАТНАЯ СВЯЗЬ И БАГИ В НАСТРОЙКАХ --- */
.feedback-box {
    margin-top: 10px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.feedback-textarea {
    width: 100% !important;
    box-sizing: border-box !important;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-subtle);
    background: var(--surface-muted) !important;
    color: var(--text-main) !important;
    padding: 12px 14px;
    font-size: 13px;
    font-family: inherit;
    resize: none;
    min-height: 80px;
    outline: none;
    transition: border-color 0.15s ease, background-color 0.15s ease;
    -webkit-appearance: none;
    display: block;
}

.feedback-textarea::placeholder {
    color: var(--text-muted);
    opacity: 0.8;
}

.feedback-textarea:focus {
    border-color: var(--brand-primary);
}

html.dark .feedback-textarea,
body.dark .feedback-textarea {
    background: rgba(255, 255, 255, 0.05) !important;
    color: #f3f4f6 !important;
    border-color: rgba(255, 255, 255, 0.12) !important;
}

html.light .feedback-textarea,
body.light .feedback-textarea {
    background: #f8fafc !important;
    color: #0f172a !important;
    border-color: #e2e8f0 !important;
}

.feedback-btn {
    width: 100%;
    padding: 11px 16px;
    font-size: 13px;
    font-weight: 600;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    cursor: pointer;
    background: var(--brand-primary);
    color: #ffffff;
    border: none;
    box-shadow: 0 2px 8px rgba(59, 130, 246, 0.25);
    transition: opacity 0.15s ease, transform 0.12s ease;
}

.feedback-btn:active {
    transform: scale(0.985);
    opacity: 0.9;
}

/* --- РАЗДЕЛЕНИЕ КОРЗИНЫ ПО МАГАЗИНАМ --- */
.cart-store-filter-bar {
    display: flex;
    gap: 6px;
    overflow-x: auto;
    padding-bottom: 8px;
    margin-bottom: 8px;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
}

.cart-store-filter-bar::-webkit-scrollbar {
    display: none;
}

.cart-filter-chip {
    flex-shrink: 0;
    background: var(--surface-muted);
    border: 1px solid var(--border-subtle);
    color: var(--text-main);
    padding: 6px 12px;
    border-radius: var(--radius-full);
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s ease;
    display: flex;
    align-items: center;
    gap: 5px;
    white-space: nowrap;
}

.cart-filter-chip.active {
    background: var(--brand-primary);
    color: #ffffff;
    border-color: var(--brand-primary);
}

.cart-store-group {
    background: var(--surface-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    margin-bottom: 12px;
    overflow: hidden;
    box-shadow: var(--card-shadow);
}

.cart-store-header {
    background: var(--surface-muted);
    padding: 10px 14px;
    border-bottom: 1px solid var(--border-subtle);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.cart-store-name-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
}

.cart-store-name-wrap .store-emoji {
    font-size: 16px;
}

.cart-store-name-wrap .store-title {
    font-size: 13px;
    font-weight: 700;
    color: var(--text-main);
}

.cart-store-meta {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    background: var(--surface-card);
    padding: 3px 8px;
    border-radius: var(--radius-full);
    border: 1px solid var(--border-subtle);
}

.cart-store-group .cart-item-row {
    margin-bottom: 0;
    border-radius: 0;
    border: none;
    border-bottom: 1px solid var(--border-subtle);
}

.cart-store-group .cart-item-row:last-child {
    border-bottom: none;
}
