:root {
    --bg-color: #111311;
    --surface: #191d19;
    --surface-strong: #222821;
    --border-color: rgba(234, 232, 220, 0.12);
    --text-primary: #f4f0e6;
    --text-secondary: #aaa99d;
    --muted: #77776c;
    --accent-color: #1f8a70;
    --accent-soft: rgba(31, 138, 112, 0.14);
    --warning-color: #d7a742;
    --success-color: #42c18b;
    --danger-color: #e66b62;
    --shadow: 0 16px 40px rgba(0, 0, 0, 0.24);
}

* {
    box-sizing: border-box;
    font-family: "Outfit", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

body {
    background: var(--bg-color);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
}

button,
input {
    font: inherit;
}

button {
    cursor: pointer;
}

.screens-container {
    padding-bottom: 20px;
}

.screen {
    display: none;
}

.screen.active {
    display: block;
}

.store-header {
    align-items: center;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    padding: 18px 16px 14px;
}

.user-info {
    align-items: center;
    display: flex;
    gap: 12px;
    min-width: 0;
}

.avatar-placeholder,
.avatar-large {
    align-items: center;
    background: var(--accent-color);
    color: #07130f;
    display: flex;
    font-weight: 800;
    justify-content: center;
}

.avatar-placeholder {
    border-radius: 8px;
    flex: 0 0 auto;
    font-size: 20px;
    height: 44px;
    width: 44px;
}

.user-details {
    min-width: 0;
}

.store-kicker {
    color: var(--warning-color);
    display: block;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0;
    margin-bottom: 2px;
}

.user-details h2 {
    font-size: 1.05rem;
    line-height: 1.15;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.balance-pill {
    background: var(--surface);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    flex: 0 0 auto;
    padding: 8px 10px;
    text-align: right;
}

.balance-pill span {
    color: var(--text-secondary);
    display: block;
    font-size: 0.68rem;
}

.balance-pill strong {
    color: var(--success-color);
    display: block;
    font-size: 0.86rem;
    margin-top: 2px;
}

.trust-strip {
    display: grid;
    gap: 8px;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    padding: 14px 16px 10px;
}

.trust-item {
    background: var(--surface);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 10px;
}

.trust-item span {
    display: block;
    font-size: 1rem;
    font-weight: 800;
}

.trust-item small {
    color: var(--text-secondary);
    display: block;
    font-size: 0.68rem;
    line-height: 1.25;
    margin-top: 2px;
}

.categories-section {
    background: rgba(17, 19, 17, 0.96);
    border-bottom: 1px solid var(--border-color);
    padding: 10px 16px 8px;
    position: sticky;
    top: 0;
    z-index: 10;
}

.search-wrap {
    margin-bottom: 10px;
}

#product-search {
    background: var(--surface);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-primary);
    outline: none;
    padding: 11px 12px;
    width: 100%;
}

#product-search:focus {
    border-color: rgba(66, 193, 139, 0.7);
}

.categories-scroll {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 4px;
    scrollbar-width: none;
}

.categories-scroll::-webkit-scrollbar {
    display: none;
}

.cat-btn {
    background: transparent;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-secondary);
    flex: 0 0 auto;
    font-weight: 700;
    padding: 8px 12px;
    white-space: nowrap;
}

.cat-btn.active {
    background: var(--accent-soft);
    border-color: rgba(66, 193, 139, 0.55);
    color: var(--success-color);
}

.catalog-section {
    padding: 16px;
}

.section-row {
    align-items: center;
    display: flex;
    justify-content: space-between;
    margin-bottom: 12px;
}

.section-row h1,
.screen-header h2 {
    font-size: 1.2rem;
    line-height: 1.2;
}

.section-row span {
    color: var(--text-secondary);
    font-size: 0.8rem;
}

.products-grid {
    display: grid;
    gap: 12px;
    grid-template-columns: repeat(auto-fill, minmax(164px, 1fr));
}

.product-card,
.history-card,
.profile-card,
.help-section,
.empty-state {
    background: var(--surface);
    border: 1px solid var(--border-color);
    border-radius: 8px;
}

.product-card {
    display: flex;
    flex-direction: column;
    min-height: 244px;
    padding: 12px;
}

.product-topline {
    align-items: center;
    display: flex;
    gap: 10px;
    min-width: 0;
}

.product-icon {
    align-items: center;
    background: var(--surface-strong);
    border-radius: 8px;
    display: flex;
    flex: 0 0 auto;
    font-size: 1.8rem;
    height: 44px;
    justify-content: center;
    overflow: hidden;
    width: 44px;
}

.product-name {
    font-size: 0.92rem;
    line-height: 1.25;
    margin-bottom: 3px;
    overflow-wrap: anywhere;
}

.product-price {
    color: var(--warning-color);
    font-size: 0.86rem;
    font-weight: 800;
}

.product-description {
    color: var(--text-secondary);
    display: -webkit-box;
    font-size: 0.78rem;
    line-height: 1.38;
    margin: 12px 0 10px;
    min-height: 4.2em;
    overflow: hidden;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 3;
}

.product-meta {
    color: var(--text-secondary);
    display: flex;
    font-size: 0.72rem;
    gap: 8px;
    justify-content: space-between;
    margin-bottom: 10px;
}

.product-meta span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.product-meta .in-stock {
    color: var(--success-color);
}

.product-meta .out-stock {
    color: var(--danger-color);
}

.product-actions {
    margin-top: auto;
}

.add-btn,
.btn-primary {
    background: var(--accent-color);
    border: 0;
    border-radius: 8px;
    color: #f7fff9;
    font-weight: 800;
    min-height: 40px;
    padding: 10px;
    width: 100%;
}

.add-btn:disabled {
    background: var(--surface-strong);
    color: var(--muted);
    cursor: not-allowed;
}

.cart-controls {
    align-items: center;
    background: var(--surface-strong);
    border-radius: 8px;
    display: grid;
    grid-template-columns: 40px 1fr 40px;
    min-height: 40px;
    overflow: hidden;
}

.cart-btn {
    background: transparent;
    border: 0;
    color: var(--text-primary);
    font-size: 1.05rem;
    font-weight: 800;
    height: 40px;
}

.qty-display {
    color: var(--success-color);
    font-weight: 800;
    text-align: center;
}

.screen-header {
    padding: 20px 16px 10px;
}

.history-list {
    display: grid;
    gap: 10px;
    padding: 16px;
}

.history-card {
    padding: 12px;
}

.history-header,
.history-body {
    align-items: center;
    display: flex;
    gap: 12px;
    justify-content: space-between;
}

.history-header {
    color: var(--text-secondary);
    font-size: 0.78rem;
    margin-bottom: 8px;
}

.history-title {
    font-weight: 800;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.history-price {
    color: var(--warning-color);
    flex: 0 0 auto;
    font-weight: 800;
}

.history-date {
    color: var(--muted);
    font-size: 0.76rem;
    margin-top: 6px;
}

.history-status {
    background: var(--surface-strong);
    border-radius: 8px;
    color: var(--success-color);
    padding: 4px 8px;
}

.profile-card {
    margin: 16px;
    padding: 22px 18px;
    text-align: center;
}

.avatar-large {
    border-radius: 8px;
    font-size: 32px;
    height: 76px;
    margin: 0 auto 14px;
    width: 76px;
}

.profile-name {
    font-size: 1.2rem;
    margin-bottom: 4px;
}

.profile-id {
    color: var(--text-secondary);
    font-size: 0.82rem;
}

.balance-box {
    background: var(--surface-strong);
    border-radius: 8px;
    margin: 18px 0;
    padding: 14px;
}

.balance-box .label {
    color: var(--text-secondary);
    display: block;
    font-size: 0.75rem;
    margin-bottom: 4px;
}

.amount {
    color: var(--success-color);
    font-size: 1.35rem;
}

.help-section {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin: 0 16px 16px;
    padding: 14px;
    text-align: center;
}

.empty-state {
    color: var(--text-secondary);
    grid-column: 1 / -1;
    padding: 22px;
    text-align: center;
}

.empty-state strong,
.empty-state span {
    display: block;
}

.empty-state strong {
    color: var(--text-primary);
    margin-bottom: 4px;
}

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

.bottom-padding {
    height: 86px;
}

.bottom-nav {
    background: rgba(25, 29, 25, 0.96);
    border-top: 1px solid var(--border-color);
    bottom: 0;
    display: flex;
    gap: 8px;
    justify-content: space-around;
    left: 0;
    padding: 10px 16px;
    position: fixed;
    right: 0;
    z-index: 100;
}

.nav-item {
    align-items: center;
    background: transparent;
    border: 0;
    border-radius: 8px;
    color: var(--text-secondary);
    display: flex;
    flex: 1;
    flex-direction: column;
    gap: 4px;
    min-height: 50px;
    padding: 7px 8px;
}

.nav-item.active {
    background: var(--accent-soft);
    color: var(--success-color);
}

.nav-icon {
    font-size: 1.15rem;
    font-weight: 800;
    line-height: 1;
}

.nav-text {
    font-size: 0.72rem;
    font-weight: 800;
}

.shimmer-card {
    background: var(--surface);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    height: 220px;
    overflow: hidden;
    position: relative;
}

.shimmer-card::after {
    animation: shimmer 1.4s infinite;
    background: linear-gradient(90deg, transparent, rgba(244, 240, 230, 0.08), transparent);
    content: "";
    inset: 0;
    position: absolute;
    transform: translateX(-100%);
}

@keyframes shimmer {
    100% {
        transform: translateX(100%);
    }
}

@media (max-width: 360px) {
    .products-grid {
        grid-template-columns: 1fr;
    }

    .trust-strip {
        grid-template-columns: 1fr;
    }
}
