:root {
    --bg: var(--tg-theme-bg-color, #ffffff);
    --text: var(--tg-theme-text-color, #1a1a1a);
    --hint: var(--tg-theme-hint-color, #8b8b8b);
    --card: var(--tg-theme-secondary-bg-color, #f4f4f5);
    --accent: var(--tg-theme-button-color, #3390ec);
    --accent-text: var(--tg-theme-button-text-color, #ffffff);
    --border: rgba(128, 128, 128, 0.18);
}

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

body {
    margin: 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 15px;
    padding-bottom: 24px;
}

.screen { display: none; padding: 12px 12px 0; }
.screen.active { display: block; }

.hidden { display: none !important; }

.page-title { font-size: 20px; margin: 8px 4px 14px; }
.page-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.head-btn {
    border: none;
    background: var(--card);
    color: var(--text);
    border-radius: 18px;
    padding: 7px 14px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    margin: 8px 4px 14px;
}

/* ---------- История заказов ---------- */
.history-list { display: flex; flex-direction: column; gap: 12px; }
.history-item {
    background: var(--card);
    border-radius: 14px;
    padding: 12px 14px;
}
.history-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
}
.history-id { font-weight: 700; }
.history-badge {
    font-size: 12px;
    padding: 3px 9px;
    border-radius: 12px;
    background: var(--bg);
    white-space: nowrap;
}
.history-items { color: var(--hint); font-size: 13px; line-height: 1.4; margin-bottom: 10px; }
.history-foot { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.history-total { font-weight: 700; }
.repeat-btn {
    border: none;
    background: var(--accent);
    color: var(--accent-text);
    border-radius: 10px;
    padding: 8px 14px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
}

.empty { text-align: center; color: var(--hint); padding: 48px 16px; }

/* ---------- Поиск ---------- */
.menu-search {
    width: 100%;
    box-sizing: border-box;
    border: 1px solid var(--border);
    background: var(--card);
    color: var(--text);
    border-radius: 12px;
    padding: 11px 14px;
    font-size: 15px;
    margin: 0 0 12px;
    outline: none;
}
.menu-search:focus { border-color: var(--accent); }

/* ---------- Геолокация ---------- */
.geo-btn {
    margin-top: 6px;
    border: 1px solid var(--accent);
    background: transparent;
    color: var(--accent);
    border-radius: 10px;
    padding: 9px 12px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    width: 100%;
}

/* ---------- Сохранённые адреса ---------- */
.addr-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.addr-chip {
    border: 1px solid var(--border);
    background: var(--bg);
    color: var(--text);
    border-radius: 14px;
    padding: 5px 10px;
    font-size: 12px;
    cursor: pointer;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ---------- Вкладки категорий ---------- */
.tabs {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding: 0 4px 12px;
    margin: 0 -4px;
    scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
    flex: 0 0 auto;
    border: none;
    background: var(--card);
    color: var(--text);
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 600;
    white-space: nowrap;
    cursor: pointer;
}
.tab.active { background: var(--accent); color: var(--accent-text); }

/* ---------- Список блюд ---------- */
.menu-list { display: flex; flex-direction: column; gap: 12px; }

.card {
    display: flex;
    background: var(--card);
    border-radius: 14px;
    overflow: hidden;
    cursor: pointer;
}

.card-photo {
    width: 104px;
    min-width: 104px;
    height: 104px;
    object-fit: cover;
    background: var(--border);
}

.card-body {
    padding: 10px 12px;
    display: flex;
    flex-direction: column;
    flex: 1;
    min-width: 0;
}

.card-name { font-weight: 600; font-size: 15px; margin-bottom: 2px; }
.card-desc {
    color: var(--hint);
    font-size: 13px;
    line-height: 1.3;
    margin-bottom: 8px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.card-footer {
    margin-top: auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}
.card-price { font-weight: 700; font-size: 15px; white-space: nowrap; }

/* ---------- Кнопки добавления / степпер ---------- */
.add-btn {
    border: none;
    background: var(--accent);
    color: var(--accent-text);
    border-radius: 10px;
    padding: 8px 14px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
}

.stepper {
    display: inline-flex;
    align-items: center;
    background: var(--accent);
    color: var(--accent-text);
    border-radius: 10px;
    overflow: hidden;
}
.stepper button {
    border: none;
    background: transparent;
    color: var(--accent-text);
    width: 34px;
    height: 34px;
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
}
.stepper .qty { min-width: 26px; text-align: center; font-weight: 700; }

/* ---------- Карточка блюда ---------- */
.detail-photo {
    width: 100%;
    height: 240px;
    object-fit: cover;
    border-radius: 14px;
    background: var(--card);
}
.detail-body { padding: 14px 4px; }
.detail-name { font-size: 22px; margin: 0 0 6px; }
.detail-price { font-size: 20px; font-weight: 700; margin-bottom: 12px; }
.detail-desc { color: var(--text); line-height: 1.5; margin: 0; white-space: pre-wrap; }
.detail-action { padding: 16px 4px 8px; }
.detail-action .add-btn, .detail-action .stepper { width: 100%; justify-content: center; }
.detail-action .add-btn { padding: 14px; font-size: 16px; }
.detail-action .stepper { justify-content: space-between; }
.detail-action .stepper button { width: 25%; height: 48px; }

/* ---------- Корзина ---------- */
.cart-list { display: flex; flex-direction: column; gap: 10px; }
.cart-item {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--card);
    border-radius: 12px;
    padding: 10px;
}
.cart-item-photo { width: 54px; height: 54px; border-radius: 8px; object-fit: cover; }
.cart-item-info { flex: 1; min-width: 0; }
.cart-item-name { font-weight: 600; }
.cart-item-price { color: var(--hint); font-size: 13px; }
.cart-total { margin: 16px 4px; }
.sum-row {
    display: flex;
    justify-content: space-between;
    font-size: 15px;
    color: var(--hint);
    padding: 3px 0;
}
.sum-row.grand {
    font-size: 18px;
    font-weight: 700;
    color: var(--text);
    margin-top: 4px;
}
.sum-warn {
    margin-top: 10px;
    background: rgba(255, 176, 32, 0.15);
    color: var(--text);
    border-radius: 10px;
    padding: 10px 12px;
    font-size: 13px;
    text-align: center;
}

/* ---------- Экран оформления ---------- */
.seg {
    display: flex;
    gap: 6px;
    background: var(--card);
    border-radius: 12px;
    padding: 4px;
    margin: 0 4px 14px;
}
.seg-btn {
    flex: 1;
    border: none;
    background: transparent;
    color: var(--text);
    padding: 10px;
    border-radius: 9px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
}
.seg-btn.active {
    background: var(--accent);
    color: var(--accent-text);
}
.form { display: flex; flex-direction: column; gap: 12px; padding: 0 4px; }
.field { display: flex; flex-direction: column; gap: 5px; }
.field > span { font-size: 13px; color: var(--hint); padding-left: 2px; }
.field .req { color: #e53935; }
.field input, .field textarea {
    width: 100%;
    box-sizing: border-box;
    border: 1px solid var(--border);
    background: var(--bg);
    color: var(--text);
    border-radius: 10px;
    padding: 12px;
    font-size: 15px;
    font-family: inherit;
    outline: none;
}
.field input:focus, .field textarea:focus { border-color: var(--accent); }
.field textarea { resize: vertical; }
.field.hidden { display: none; }

/* ---------- Дата доставки / самовывоз ---------- */
.date-note {
    background: var(--card);
    border-radius: 10px;
    padding: 10px 12px;
    margin: 0 4px 10px;
    font-size: 14px;
    text-align: center;
}
.date-note b { color: var(--accent); }
.date-note .preorder { color: #e08a00; display: block; margin-top: 4px; font-size: 12px; }
.pickup-note {
    background: rgba(51, 144, 236, 0.1);
    border-radius: 10px;
    padding: 10px 12px;
    margin: 0 4px 10px;
    font-size: 13px;
}

/* ---------- Промокод и баллы ---------- */
.loyalty { padding: 14px 4px 0; display: flex; flex-direction: column; gap: 8px; }
.promo-row { display: flex; gap: 8px; }
.promo-row input {
    flex: 1;
    box-sizing: border-box;
    border: 1px solid var(--border);
    background: var(--bg);
    color: var(--text);
    border-radius: 10px;
    padding: 11px 12px;
    font-size: 15px;
    text-transform: uppercase;
    outline: none;
}
.promo-row button {
    border: none;
    background: var(--accent);
    color: var(--accent-text);
    border-radius: 10px;
    padding: 0 16px;
    font-weight: 600;
    cursor: pointer;
}
.promo-msg { font-size: 13px; padding-left: 2px; min-height: 1px; }
.promo-msg.ok { color: #2e9b4f; }
.promo-msg.err { color: #e53935; }
.points-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--card);
    border-radius: 10px;
    padding: 12px;
    font-size: 15px;
    cursor: pointer;
}
.points-row input { width: 20px; height: 20px; }

/* ---------- Экран "спасибо" ---------- */
.done-screen { text-align: center; padding-top: 80px; }
.done-emoji { font-size: 64px; }
.done-screen h2 { margin: 12px 0 6px; }
.hint { color: var(--hint); }
