:root {
    --tpo-bg: #071315;
    --tpo-surface: #0d2023;
    --tpo-surface-2: #123034;
    --tpo-border: rgba(230, 189, 100, .2);
    --tpo-border-strong: rgba(230, 189, 100, .55);
    --tpo-text: #f7f3e8;
    --tpo-muted: #a8b3b5;
    --tpo-gold: #e6bd64;
    --tpo-teal: #14c99a;
    --tpo-danger: #fb7185;
    --tpo-warning: #fbbf24;
    --tpo-radius: 16px;
    --tpo-shadow: 0 18px 50px rgba(0, 0, 0, .38);
}

.tpo-hidden { display: none !important; }
.tpo-no-scroll { overflow: hidden !important; }

.tpo-network-banner {
    position: fixed;
    inset: 0 0 auto;
    z-index: 9990;
    display: none;
    align-items: center;
    justify-content: center;
    gap: 10px;
    flex-wrap: wrap;
    min-height: 52px;
    padding: 8px max(14px, env(safe-area-inset-right)) 8px max(14px, env(safe-area-inset-left));
    direction: rtl;
    font-family: inherit;
    color: #211701;
    background: linear-gradient(135deg, #f8d37c, #d9a63d);
    box-shadow: 0 8px 28px rgba(0, 0, 0, .3);
}

.tpo-network-banner[data-tone="danger"] { color: #fff; background: linear-gradient(135deg, #e11d48, #9f1239); }
.tpo-network-banner[data-tone="sync"] { color: #021711; background: linear-gradient(135deg, #5ee6bd, #14c99a); }
.tpo-network-banner__text { font-size: 14px; font-weight: 900; }
.tpo-network-banner__meta { padding: 3px 9px; border-radius: 999px; background: rgba(0, 0, 0, .14); font-size: 12px; font-weight: 800; }

.tpo-btn {
    appearance: none;
    border: 1px solid var(--tpo-border);
    border-radius: 12px;
    min-height: 42px;
    padding: 9px 15px;
    font: inherit;
    font-size: 14px;
    font-weight: 900;
    cursor: pointer;
    color: var(--tpo-text);
    background: var(--tpo-surface-2);
    transition: transform .12s ease, border-color .12s ease, opacity .12s ease;
    -webkit-tap-highlight-color: transparent;
}
.tpo-btn:hover:not(:disabled) { border-color: var(--tpo-border-strong); transform: translateY(-1px); }
.tpo-btn:active:not(:disabled) { transform: translateY(0); }
.tpo-btn:focus-visible, .tpo-input:focus-visible { outline: 3px solid rgba(20, 201, 154, .32); outline-offset: 2px; }
.tpo-btn:disabled { opacity: .45; cursor: not-allowed; }
.tpo-btn--light { color: #102021; border-color: transparent; background: #fff; }
.tpo-btn--primary { color: #03130f; border-color: transparent; background: linear-gradient(135deg, #65e6bf, #14c99a); }
.tpo-btn--gold { color: #211701; border-color: transparent; background: linear-gradient(135deg, #f8d37c, #d9a63d); }
.tpo-btn--danger { color: #fecdd3; border-color: rgba(251, 113, 133, .22); background: rgba(190, 24, 93, .18); }

.tpo-status-dock {
    position: fixed;
    z-index: 9980;
    inset-inline-end: 18px;
    bottom: max(18px, env(safe-area-inset-bottom));
    display: none;
    align-items: center;
    gap: 8px;
    max-width: min(340px, calc(100vw - 36px));
    min-height: 46px;
    padding: 9px 14px;
    border: 1px solid var(--tpo-border);
    border-radius: 999px;
    color: var(--tpo-text);
    background: rgba(7, 19, 21, .94);
    box-shadow: 0 10px 32px rgba(0, 0, 0, .3);
    backdrop-filter: blur(14px);
    font: inherit;
    font-size: 12px;
    font-weight: 850;
    direction: rtl;
    cursor: pointer;
}
.tpo-status-dock__dot { width: 9px; height: 9px; flex: 0 0 auto; border-radius: 50%; background: var(--tpo-teal); box-shadow: 0 0 0 4px rgba(20, 201, 154, .13); }
.tpo-status-dock[data-state="checking"] .tpo-status-dock__dot { background: var(--tpo-muted, #94a3b8); box-shadow: 0 0 0 4px rgba(148, 163, 184, .13); }
.tpo-status-dock[data-state="offline"] .tpo-status-dock__dot { background: var(--tpo-warning); box-shadow: 0 0 0 4px rgba(251, 191, 36, .13); }
.tpo-status-dock[data-state="error"] .tpo-status-dock__dot { background: var(--tpo-danger); box-shadow: 0 0 0 4px rgba(251, 113, 133, .13); }

.tpo-overlay {
    position: fixed;
    inset: 0;
    z-index: 9995;
    display: none;
    flex-direction: column;
    direction: rtl;
    color-scheme: dark;
    color: var(--tpo-text);
    font-family: "Alexandria", Tahoma, "Segoe UI", system-ui, sans-serif;
    background:
        radial-gradient(850px 440px at 100% -140px, rgba(230, 189, 100, .08), transparent 64%),
        radial-gradient(700px 460px at -180px 100%, rgba(20, 201, 154, .08), transparent 68%),
        var(--tpo-bg);
}
.tpo-overlay.is-open { display: flex; }

.tpo-header {
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 72px;
    padding: max(12px, env(safe-area-inset-top)) max(18px, env(safe-area-inset-right)) 12px max(18px, env(safe-area-inset-left));
    border-bottom: 1px solid var(--tpo-border);
    background: rgba(7, 19, 21, .88);
    backdrop-filter: blur(18px);
}
.tpo-brand { display: flex; align-items: center; gap: 11px; min-width: 0; }
.tpo-brand__mark { display: grid; place-items: center; width: 42px; height: 42px; flex: 0 0 auto; border-radius: 13px; color: #032018; background: linear-gradient(145deg, #6debc5, #14c99a); font-size: 20px; font-weight: 950; }
.tpo-brand h1 { margin: 0; font-size: 18px; font-weight: 950; letter-spacing: -.02em; }
.tpo-brand p { margin: 3px 0 0; color: var(--tpo-muted); font-size: 11px; font-weight: 750; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tpo-header__spacer { flex: 1; }
.tpo-head-badges { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; justify-content: flex-end; }
.tpo-badge { display: inline-flex; align-items: center; gap: 6px; min-height: 29px; padding: 5px 10px; border-radius: 999px; font-size: 11px; font-weight: 900; white-space: nowrap; color: #9ff2d8; background: rgba(20, 201, 154, .12); border: 1px solid rgba(20, 201, 154, .16); }
.tpo-badge--warn { color: #fde68a; background: rgba(251, 191, 36, .11); border-color: rgba(251, 191, 36, .17); }
.tpo-badge--danger { color: #fecdd3; background: rgba(251, 113, 133, .11); border-color: rgba(251, 113, 133, .17); }

.tpo-main { flex: 1; display: grid; grid-template-columns: minmax(0, 1.65fr) minmax(340px, .8fr); gap: 14px; min-height: 0; padding: 14px; }
.tpo-catalog { display: flex; flex-direction: column; gap: 10px; min-width: 0; min-height: 0; }
.tpo-cart-panel { display: flex; flex-direction: column; min-width: 0; min-height: 0; padding: 13px; border: 1px solid var(--tpo-border); border-radius: var(--tpo-radius); background: rgba(13, 32, 35, .92); box-shadow: var(--tpo-shadow); }

.tpo-search-wrap { position: relative; flex: 0 0 auto; }
.tpo-input { width: 100%; min-height: 50px; padding: 11px 15px; border: 1px solid var(--tpo-border); border-radius: 13px; color: var(--tpo-text); background: var(--tpo-surface); font: inherit; font-size: 15px; font-weight: 750; }
.tpo-input::placeholder { color: #718084; }
.tpo-search-hint { margin: 5px 3px 0; color: #758387; font-size: 10px; font-weight: 700; }
.tpo-categories { display: flex; flex: 0 0 auto; gap: 7px; overflow: auto hidden; scrollbar-width: thin; padding: 1px 0 4px; }
.tpo-category { flex: 0 0 auto; min-height: 38px; padding: 7px 14px; border-radius: 999px; }
.tpo-category.is-active { color: #211701; border-color: transparent; background: var(--tpo-gold); }

.tpo-results-meta { flex: 0 0 auto; display: flex; align-items: center; justify-content: space-between; min-height: 20px; color: var(--tpo-muted); font-size: 11px; font-weight: 750; }
.tpo-grid { flex: 1; display: grid; grid-template-columns: repeat(auto-fill, minmax(154px, 1fr)); gap: 10px; align-content: start; overflow-y: auto; padding: 1px 2px 10px; scrollbar-width: thin; }
.tpo-product { position: relative; display: grid; grid-template-rows: 76px minmax(38px, auto) auto auto; gap: 7px; min-height: 175px; padding: 10px; text-align: start; border: 1px solid var(--tpo-border); border-radius: 14px; color: var(--tpo-text); background: var(--tpo-surface); box-shadow: 0 5px 18px rgba(0, 0, 0, .2); cursor: pointer; font: inherit; transition: transform .12s ease, border-color .12s ease; }
.tpo-product:hover:not(:disabled) { transform: translateY(-2px); border-color: var(--tpo-border-strong); }
.tpo-product:disabled { cursor: not-allowed; opacity: .52; }
.tpo-product__image { display: grid; place-items: center; width: 100%; height: 76px; overflow: hidden; border-radius: 10px; color: #769095; background: linear-gradient(145deg, #16383c, #0b2528); font-size: 24px; }
.tpo-product__image img { width: 100%; height: 100%; object-fit: cover; }
.tpo-product__name { font-size: 13px; line-height: 1.45; font-weight: 900; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.tpo-product__price { padding-top: 7px; border-top: 1px dashed rgba(230, 189, 100, .15); color: var(--tpo-gold); font-size: 17px; font-weight: 950; font-variant-numeric: tabular-nums; }
.tpo-stock { width: fit-content; max-width: 100%; padding: 3px 7px; border-radius: 999px; color: #a7f3d0; background: rgba(20, 201, 154, .11); font-size: 9px; line-height: 1.35; font-weight: 850; }
.tpo-stock.is-low { color: #fde68a; background: rgba(251, 191, 36, .11); }
.tpo-stock.is-out { color: #fecdd3; background: rgba(251, 113, 133, .11); }

.tpo-cart-title { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
.tpo-cart-title h2 { margin: 0; font-size: 15px; font-weight: 950; }
.tpo-cart-list { flex: 1; min-height: 80px; overflow-y: auto; display: flex; flex-direction: column; gap: 7px; padding-inline-end: 2px; }
.tpo-empty { display: grid; place-items: center; min-height: 130px; padding: 22px; border: 1px dashed var(--tpo-border); border-radius: 13px; color: var(--tpo-muted); text-align: center; font-size: 13px; line-height: 1.8; font-weight: 750; }
.tpo-cart-line { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; padding: 9px; border: 1px solid rgba(230, 189, 100, .11); border-radius: 12px; background: var(--tpo-surface-2); }
.tpo-cart-line.is-invalid { border-color: rgba(251, 113, 133, .55); background: rgba(136, 19, 55, .18); }
.tpo-line-name { min-width: 0; font-size: 12px; line-height: 1.45; font-weight: 900; }
.tpo-line-name small { display: block; color: var(--tpo-muted); font-size: 9px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tpo-line-total { align-self: start; color: var(--tpo-gold); font-size: 12px; font-weight: 950; font-variant-numeric: tabular-nums; }
.tpo-line-actions { grid-column: 1 / -1; display: flex; align-items: center; gap: 6px; }
.tpo-qty { min-width: 34px; text-align: center; font-size: 12px; font-weight: 950; font-variant-numeric: tabular-nums; }
.tpo-qty-btn { width: 34px; height: 34px; min-height: 34px; padding: 0; border-radius: 9px; font-size: 17px; }
.tpo-remove { margin-inline-start: auto; min-height: 34px; padding: 5px 9px; color: #fecdd3; border-color: transparent; background: transparent; }

.tpo-summary { margin-top: 10px; padding-top: 10px; border-top: 1px solid rgba(255, 255, 255, .07); }
.tpo-summary-row { display: flex; justify-content: space-between; gap: 14px; margin: 5px 0; color: #cbd3d4; font-size: 12px; font-weight: 750; }
.tpo-summary-row strong { color: var(--tpo-text); font-variant-numeric: tabular-nums; }
.tpo-summary-row.is-total { align-items: center; margin-top: 9px; padding: 11px 12px; border-radius: 12px; color: #dffbf2; background: linear-gradient(135deg, #0f766e, #064e4b); }
.tpo-summary-row.is-total strong { font-size: 21px; }
.tpo-payment { display: grid; grid-template-columns: 1fr auto; gap: 7px; margin-top: 9px; }
.tpo-payment .tpo-input { min-height: 48px; text-align: center; font-size: 17px; font-variant-numeric: tabular-nums; }
.tpo-checkout { width: 100%; min-height: 57px; margin-top: 8px; font-size: 16px; }
.tpo-safe-note { margin: 7px 2px 0; color: #809095; font-size: 9px; line-height: 1.6; text-align: center; font-weight: 700; }

.tpo-sheet { position: fixed; inset: 0; z-index: 9998; display: none; align-items: flex-end; justify-content: center; padding-top: 42px; background: rgba(0, 0, 0, .68); backdrop-filter: blur(4px); direction: rtl; }
.tpo-sheet.is-open { display: flex; }
.tpo-sheet__card { width: 100%; max-width: 620px; max-height: min(82vh, 760px); overflow-y: auto; padding: 17px; border: 1px solid var(--tpo-border); border-radius: 20px 20px 0 0; color: var(--tpo-text); background: var(--tpo-surface); box-shadow: var(--tpo-shadow); font-family: inherit; }
.tpo-sheet__head { display: flex; align-items: center; gap: 8px; margin-bottom: 13px; }
.tpo-sheet__head h2 { flex: 1; margin: 0; font-size: 17px; font-weight: 950; }
.tpo-option { width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 7px; padding: 12px; text-align: start; }
.tpo-option strong { color: var(--tpo-gold); font-variant-numeric: tabular-nums; }

.tpo-queue-row { margin-bottom: 9px; padding: 12px; border: 1px solid rgba(230, 189, 100, .13); border-radius: 13px; background: var(--tpo-surface-2); }
.tpo-queue-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.tpo-queue-amount { font-size: 15px; font-weight: 950; }
.tpo-queue-meta { margin-top: 3px; color: var(--tpo-muted); font-size: 10px; line-height: 1.6; font-weight: 700; }
.tpo-queue-items { margin: 8px 0 0; padding: 8px 11px; border-radius: 10px; color: #c8d2d3; background: rgba(0, 0, 0, .13); font-size: 10px; line-height: 1.8; }
.tpo-queue-error { margin-top: 8px; padding: 8px 10px; border-radius: 9px; color: #fecdd3; background: rgba(190, 24, 93, .14); font-size: 10px; line-height: 1.7; font-weight: 800; }
.tpo-queue-actions { display: flex; gap: 7px; margin-top: 9px; }
.tpo-queue-actions .tpo-btn { flex: 1; }

.tpo-state { flex: 1; display: none; place-items: center; padding: 24px; }
.tpo-state.is-visible { display: grid; }
.tpo-state__card { width: min(480px, 100%); padding: 26px; border: 1px solid var(--tpo-border); border-radius: 20px; text-align: center; background: var(--tpo-surface); box-shadow: var(--tpo-shadow); }
.tpo-state__icon { display: grid; place-items: center; width: 64px; height: 64px; margin: 0 auto 14px; border-radius: 20px; color: #211701; background: linear-gradient(145deg, #f8d37c, #d9a63d); font-size: 27px; }
.tpo-state h2 { margin: 0 0 8px; font-size: 20px; font-weight: 950; }
.tpo-state p { margin: 0 0 17px; color: var(--tpo-muted); font-size: 13px; line-height: 1.9; font-weight: 700; }

.tpo-receipt { display: none; flex: 1; place-items: center; overflow-y: auto; padding: 22px; }
.tpo-receipt.is-visible { display: grid; }
.tpo-receipt__paper { width: min(430px, 100%); padding: 25px; border-radius: 18px; color: #17201e; background: #fffdf7; box-shadow: var(--tpo-shadow); text-align: center; }
.tpo-receipt__check { display: grid; place-items: center; width: 58px; height: 58px; margin: 0 auto 12px; border-radius: 50%; color: #fff; background: #059669; font-size: 27px; font-weight: 950; }
.tpo-receipt h2 { margin: 0; font-size: 20px; }
.tpo-receipt p { margin: 6px 0 15px; color: #52615e; font-size: 12px; line-height: 1.7; }
.tpo-receipt__row { display: flex; justify-content: space-between; gap: 14px; padding: 7px 0; border-bottom: 1px dashed #d8dedb; font-size: 12px; font-weight: 750; }
.tpo-receipt__row strong { font-variant-numeric: tabular-nums; }
.tpo-receipt__actions { display: flex; gap: 7px; margin-top: 17px; }
.tpo-receipt__actions .tpo-btn { flex: 1; }

.tpo-toast { position: fixed; z-index: 10010; inset-inline: 16px; bottom: max(24px, env(safe-area-inset-bottom)); display: none; justify-content: center; pointer-events: none; direction: rtl; }
.tpo-toast span { max-width: min(520px, 100%); padding: 11px 17px; border: 1px solid rgba(255, 255, 255, .12); border-radius: 999px; color: #fff; background: rgba(4, 46, 41, .96); box-shadow: 0 10px 34px rgba(0, 0, 0, .36); font-family: inherit; font-size: 12px; line-height: 1.6; text-align: center; font-weight: 850; }

@media (max-width: 900px) {
    .tpo-main { grid-template-columns: minmax(0, 1.25fr) minmax(300px, .85fr); }
    .tpo-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
}

@media (max-width: 720px) {
    .tpo-header { min-height: 62px; padding: 10px 12px; }
    .tpo-brand__mark { width: 36px; height: 36px; border-radius: 11px; font-size: 17px; }
    .tpo-brand h1 { font-size: 15px; }
    .tpo-brand p, .tpo-head-badges .tpo-badge:not(:first-child) { display: none; }
    .tpo-main { display: flex; flex-direction: column; overflow-y: auto; padding: 9px; }
    .tpo-catalog { min-height: 57vh; }
    .tpo-cart-panel { min-height: 52vh; overflow: visible; }
    .tpo-cart-list { overflow: visible; }
    .tpo-grid { min-height: 350px; overflow: visible; grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .tpo-status-dock { inset-inline: 10px; justify-content: center; max-width: none; bottom: max(10px, env(safe-area-inset-bottom)); }
    .tpo-network-banner { justify-content: space-between; }
    .tpo-network-banner__meta { display: none; }
}

@media (max-width: 390px) {
    .tpo-grid { grid-template-columns: 1fr 1fr; gap: 7px; }
    .tpo-product { min-height: 164px; padding: 8px; }
    .tpo-head-badges { display: none; }
}

@media (prefers-reduced-motion: reduce) {
    .tpo-btn, .tpo-product { transition: none; }
}

@media print {
    body > *:not(.tpo-overlay) { display: none !important; }
    .tpo-overlay { position: static !important; display: block !important; background: #fff !important; }
    .tpo-header, .tpo-main, .tpo-state, .tpo-network-banner, .tpo-status-dock, .tpo-toast { display: none !important; }
    .tpo-receipt.is-visible { display: grid !important; padding: 0; }
    .tpo-receipt__paper { box-shadow: none; }
    .tpo-receipt__actions { display: none; }
}
