/* ========== CSS RESET & BASE ========== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-text-size-adjust: 100%; }
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: #f5f6fa;
    color: #1a1a2e;
    line-height: 1.5;
    min-height: 100vh;
    overscroll-behavior: none;
    -webkit-tap-highlight-color: transparent;
}
input, select, textarea, button { font-family: inherit; font-size: inherit; }
a { color: #2563eb; text-decoration: none; }

/* ========== UTILITY ========== */
.hidden { display: none !important; }
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-danger { color: #ef4444; }
.text-success { color: #22c55e; }
.text-muted { color: #94a3b8; font-size: 0.85rem; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }

/* ========== LAYOUT ========== */
.app-container { max-width: 480px; margin: 0 auto; padding-bottom: 80px; }

/* Top bar */
.top-bar {
    background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
    color: #fff;
    padding: 14px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}
.top-bar h1 { font-size: 1.2rem; font-weight: 700; letter-spacing: 1px; }
.top-bar .user-info {
    font-size: 0.8rem;
    opacity: 0.85;
    background: rgba(255,255,255,0.1);
    padding: 3px 10px;
    border-radius: 12px;
}
.top-bar button {
    background: rgba(255,255,255,0.15);
    border: none;
    color: #fff;
    font-size: 1.1rem;
    cursor: pointer;
    padding: 6px 10px;
    border-radius: 8px;
    transition: background 0.2s;
}
.top-bar button:active { background: rgba(255,255,255,0.25); }

/* Bottom nav */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: #fff;
    border-top: 1px solid #e2e8f0;
    display: flex;
    justify-content: space-around;
    padding: 8px 0 calc(8px + env(safe-area-inset-bottom, 0px));
    z-index: 100;
    max-width: 480px;
    margin: 0 auto;
    box-shadow: 0 -2px 10px rgba(0,0,0,0.06);
}
@media (min-width: 481px) {
    .bottom-nav { left: 50%; transform: translateX(-50%); }
}
.bottom-nav button {
    background: none;
    border: none;
    color: #94a3b8;
    font-size: 0.68rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    padding: 4px 14px;
    transition: color 0.2s;
    border-radius: 8px;
}
.bottom-nav button .nav-icon { font-size: 1.4rem; }
.bottom-nav button.active { color: #3b82f6; }

/* ========== SCREENS ========== */
.screen { display: none; padding: 16px; }
.screen.active { display: block; }

/* ========== LOGIN ========== */
.login-screen {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 24px;
    background: linear-gradient(135deg, #0f172a 0%, #1e293b 50%, #334155 100%);
    color: #fff;
}
.login-screen .login-box {
    background: #fff;
    color: #1a1a2e;
    border-radius: 20px;
    padding: 36px 24px;
    width: 100%;
    max-width: 360px;
    box-shadow: 0 12px 40px rgba(0,0,0,0.4);
}
.login-screen .login-box h2 {
    text-align: center;
    margin-bottom: 24px;
    font-size: 1.5rem;
    font-weight: 700;
}
.login-screen .login-box .shop-title {
    text-align: center;
    font-size: 0.9rem;
    color: #3b82f6;
    margin-bottom: 4px;
    font-weight: 600;
    letter-spacing: 2px;
    text-transform: uppercase;
}

/* ========== FORMS ========== */
.form-group { margin-bottom: 16px; }
.form-group label {
    display: block;
    font-size: 0.82rem;
    font-weight: 600;
    margin-bottom: 5px;
    color: #475569;
}
.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 13px 14px;
    border: 2px solid #e2e8f0;
    border-radius: 12px;
    font-size: 1rem;
    background: #f8fafc;
    transition: border-color 0.2s, background 0.2s;
    color: #1e293b;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #3b82f6;
    background: #fff;
}
.form-row { display: flex; gap: 12px; }
.form-row .form-group { flex: 1; }

/* ========== BUTTONS ========== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 14px 20px;
    border: none;
    border-radius: 14px;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    transition: transform 0.1s, box-shadow 0.2s;
    width: 100%;
    text-align: center;
}
.btn:active { transform: scale(0.97); }
.btn-primary { background: linear-gradient(135deg, #3b82f6, #2563eb); color: #fff; box-shadow: 0 4px 12px rgba(37,99,235,0.3); }
.btn-primary:hover { box-shadow: 0 6px 16px rgba(37,99,235,0.4); }
.btn-success { background: linear-gradient(135deg, #22c55e, #16a34a); color: #fff; box-shadow: 0 4px 12px rgba(22,163,74,0.3); }
.btn-danger { background: linear-gradient(135deg, #ef4444, #dc2626); color: #fff; }
.btn-outline {
    background: #fff;
    color: #475569;
    border: 2px solid #e2e8f0;
}
.btn-outline:hover { background: #f8fafc; }
.btn-whatsapp { background: linear-gradient(135deg, #25d366, #128c7e); color: #fff; box-shadow: 0 4px 12px rgba(37,211,102,0.3); }
.btn-sm { padding: 10px 14px; font-size: 0.88rem; border-radius: 10px; }
.btn-lg { padding: 18px 24px; font-size: 1.15rem; border-radius: 16px; }
.btn-block { width: 100%; }
.btn + .btn { margin-top: 8px; }

/* ========== POS SCREEN ========== */
.search-bar {
    display: flex;
    gap: 10px;
    margin-bottom: 14px;
}
.search-bar input {
    flex: 1;
    padding: 14px 16px;
    border: 2px solid #e2e8f0;
    border-radius: 14px;
    font-size: 1.05rem;
    background: #fff;
    font-weight: 500;
    box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}
.search-bar input:focus { outline: none; border-color: #3b82f6; box-shadow: 0 2px 12px rgba(59,130,246,0.15); }
.search-bar input::placeholder { color: #94a3b8; }
.scan-btn {
    padding: 14px 18px;
    background: linear-gradient(135deg, #3b82f6, #2563eb);
    color: #fff;
    border: none;
    border-radius: 14px;
    font-size: 1.4rem;
    cursor: pointer;
    white-space: nowrap;
    min-width: 56px;
    box-shadow: 0 4px 12px rgba(37,99,235,0.3);
    transition: transform 0.1s;
}
.scan-btn:active { transform: scale(0.95); }

.search-results {
    background: #fff;
    border-radius: 14px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.12);
    margin-bottom: 14px;
    max-height: 280px;
    overflow-y: auto;
    border: 1px solid #e2e8f0;
}
.search-result-item {
    padding: 14px 16px;
    border-bottom: 1px solid #f1f5f9;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: background 0.15s;
}
.search-result-item:last-child { border-bottom: none; }
.search-result-item:active { background: #eff6ff; }
.search-result-item .product-info { flex: 1; }
.search-result-item .product-name { font-weight: 600; font-size: 0.95rem; }
.search-result-item .product-sku { font-size: 0.75rem; color: #94a3b8; margin-top: 2px; }
.search-result-item .product-price { font-weight: 700; color: #3b82f6; font-size: 1rem; }
.search-result-item .product-stock { font-size: 0.75rem; color: #94a3b8; }
.search-result-item .add-icon {
    color: #22c55e;
    font-size: 1.5rem;
    margin-left: 8px;
    font-weight: bold;
}

/* Cart */
.cart-section {
    background: #fff;
    border-radius: 16px;
    padding: 16px;
    margin-bottom: 14px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.04);
    border: 1px solid #e2e8f0;
}
.cart-section h3 { font-size: 0.9rem; margin-bottom: 12px; color: #64748b; font-weight: 700; text-transform: uppercase; letter-spacing: 1px; }
.cart-empty { text-align: center; color: #94a3b8; padding: 32px 0; font-size: 0.95rem; }

.cart-item {
    display: flex;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid #f1f5f9;
    gap: 8px;
}
.cart-item:last-child { border-bottom: none; }
.cart-item .item-info { flex: 1; min-width: 0; }
.cart-item .item-name { font-weight: 600; font-size: 0.92rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: #1e293b; }
.cart-item .item-price { font-size: 0.78rem; color: #94a3b8; }
.cart-item .item-discount { font-size: 0.75rem; color: #ef4444; cursor: pointer; }

.qty-control {
    display: flex;
    align-items: center;
    gap: 2px;
}
.qty-btn {
    width: 36px;
    height: 36px;
    border: 2px solid #e2e8f0;
    border-radius: 10px;
    background: #f8fafc;
    font-size: 1.2rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #475569;
    font-weight: 700;
    transition: background 0.15s;
}
.qty-btn:active { background: #e2e8f0; }
.qty-input {
    width: 42px;
    text-align: center;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    padding: 6px 2px;
    font-size: 1rem;
    font-weight: 700;
    color: #1e293b;
}
.qty-input:focus { outline: none; border-color: #3b82f6; }

.cart-item .item-total { font-weight: 700; min-width: 58px; text-align: right; font-size: 0.95rem; color: #1e293b; }
.cart-item .item-remove {
    color: #ef4444;
    background: #fef2f2;
    border: none;
    font-size: 1rem;
    cursor: pointer;
    padding: 6px 8px;
    border-radius: 8px;
    font-weight: 700;
    transition: background 0.15s;
}
.cart-item .item-remove:active { background: #fecaca; }

/* Cart totals */
.cart-totals {
    background: #f8fafc;
    border-radius: 14px;
    padding: 14px;
    margin-top: 14px;
    border: 1px solid #e2e8f0;
}
.cart-totals .total-row {
    display: flex;
    justify-content: space-between;
    padding: 5px 0;
    font-size: 0.9rem;
    color: #475569;
}
.cart-totals .total-row.grand-total {
    font-size: 1.3rem;
    font-weight: 800;
    border-top: 2px solid #cbd5e1;
    margin-top: 8px;
    padding-top: 10px;
    color: #0f172a;
}
.cart-discount-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 10px;
}
.cart-discount-row label { font-size: 0.78rem; color: #94a3b8; white-space: nowrap; }
.cart-discount-row input {
    width: 90px;
    padding: 8px 10px;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 600;
}
.cart-discount-row input:focus { outline: none; border-color: #3b82f6; }

/* Item discount popup */
.discount-popup {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}
.discount-popup-content {
    background: #fff;
    border-radius: 20px;
    padding: 24px;
    width: 100%;
    max-width: 340px;
    box-shadow: 0 12px 40px rgba(0,0,0,0.2);
}

/* Payment section */
.payment-section { margin-top: 14px; }
.payment-methods { display: flex; gap: 8px; margin-bottom: 14px; flex-wrap: wrap; }
.payment-method-btn {
    flex: 1;
    min-width: 80px;
    padding: 14px 8px;
    border: 2px solid #e2e8f0;
    border-radius: 14px;
    background: #fff;
    text-align: center;
    cursor: pointer;
    font-weight: 700;
    font-size: 0.85rem;
    transition: all 0.2s;
    color: #475569;
}
.payment-method-btn.selected {
    border-color: #3b82f6;
    background: linear-gradient(135deg, #eff6ff, #dbeafe);
    color: #2563eb;
    box-shadow: 0 2px 8px rgba(59,130,246,0.15);
}
.payment-method-btn .pm-icon { font-size: 1.4rem; display: block; margin-bottom: 4px; }

.cash-input {
    display: flex;
    gap: 8px;
    align-items: center;
    margin-bottom: 14px;
}
.cash-input input {
    flex: 1;
    padding: 16px;
    border: 2px solid #e2e8f0;
    border-radius: 14px;
    font-size: 1.3rem;
    font-weight: 700;
    text-align: center;
    color: #1e293b;
}
.cash-input input:focus { outline: none; border-color: #3b82f6; }
.change-display {
    background: linear-gradient(135deg, #f0fdf4, #dcfce7);
    border: 2px solid #bbf7d0;
    border-radius: 14px;
    padding: 14px;
    text-align: center;
    margin-bottom: 14px;
}
.change-display .change-label { font-size: 0.78rem; color: #64748b; font-weight: 600; text-transform: uppercase; letter-spacing: 1px; }
.change-display .change-amount {
    font-size: 1.6rem;
    font-weight: 800;
    color: #16a34a;
}

/* ========== SCANNER ========== */
.scanner-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: #000;
    z-index: 300;
    display: flex;
    flex-direction: column;
}
.scanner-overlay .scanner-header {
    background: rgba(0,0,0,0.8);
    color: #fff;
    padding: 14px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 2;
}
.scanner-overlay .scanner-header h3 { font-size: 1.05rem; font-weight: 700; }
.scanner-overlay .scanner-close {
    background: rgba(255,255,255,0.15);
    border: none;
    color: #fff;
    font-size: 1.3rem;
    cursor: pointer;
    padding: 8px 12px;
    border-radius: 8px;
}
#scanner-container { flex: 1; position: relative; overflow: hidden; }
#scanner-container video { width: 100%; height: 100%; object-fit: cover; }
.scanner-status {
    background: rgba(0,0,0,0.8);
    color: #fff;
    padding: 14px;
    text-align: center;
    font-size: 0.9rem;
    font-weight: 500;
}

/* ========== RECEIPT ========== */
.receipt-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.6);
    z-index: 200;
    overflow-y: auto;
    padding: 16px;
    -webkit-overflow-scrolling: touch;
}
.receipt-content {
    background: #fff;
    max-width: 340px;
    margin: 0 auto;
    overflow: hidden;
    box-shadow: 0 8px 32px rgba(0,0,0,0.4);
    /* Torn paper edge effect at bottom */
    border-radius: 0;
    position: relative;
}
.receipt-paper {
    padding: 28px 20px 24px;
    font-family: 'Segoe UI', 'Roboto', 'Noto Sans', Arial, sans-serif;
    font-size: 0.82rem;
    line-height: 1.5;
    color: #1a1a1a;
    background: #fefefe;
}

/* Receipt header */
.rcpt-header { text-align: center; margin-bottom: 4px; }
.rcpt-logo { max-width: 120px; max-height: 100px; margin-bottom: 8px; display: inline-block; }
.rcpt-shop-name { font-size: 1.3rem; font-weight: 900; letter-spacing: 1px; margin-bottom: 2px; }
.rcpt-info { font-size: 0.78rem; color: #444; }

/* Dividers - thermal receipt style */
.rcpt-divider {
    text-align: center;
    font-size: 0.82rem;
    color: #888;
    margin: 6px 0;
    letter-spacing: -0.5px;
    overflow: hidden;
    white-space: nowrap;
}

/* Receipt metadata */
.rcpt-meta { text-align: center; font-size: 0.78rem; color: #444; line-height: 1.6; }

/* Item rows with dot leaders */
.rcpt-row {
    display: flex;
    align-items: baseline;
    padding: 1px 0;
    font-size: 0.82rem;
}
.rcpt-row > span:first-child { white-space: nowrap; flex-shrink: 0; }
.rcpt-row > span:last-child { white-space: nowrap; flex-shrink: 0; font-weight: 600; }
.rcpt-dots {
    flex: 1;
    border-bottom: 1px dotted #bbb;
    margin: 0 4px;
    min-width: 10px;
    height: 0.7em;
}
.rcpt-sub { font-size: 0.72rem; color: #888; }

/* Total line */
.rcpt-total {
    display: flex;
    justify-content: space-between;
    font-size: 1.25rem;
    font-weight: 900;
    padding: 4px 0;
    letter-spacing: 0.5px;
}

/* Footer */
.rcpt-footer {
    text-align: center;
    margin-top: 12px;
    font-weight: 700;
    font-size: 0.9rem;
    letter-spacing: 0.5px;
}

.receipt-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    padding: 16px;
    background: #f1f5f9;
}
.receipt-actions .btn { font-size: 0.88rem; padding: 12px; }

/* ========== ADMIN/PRODUCT LIST ========== */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}
.page-header h2 { font-size: 1.2rem; font-weight: 700; }

.product-list-item {
    background: #fff;
    border-radius: 14px;
    padding: 14px;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    transition: box-shadow 0.15s, transform 0.1s;
    border: 1px solid #e2e8f0;
    box-shadow: 0 1px 4px rgba(0,0,0,0.03);
}
.product-list-item:active { box-shadow: 0 2px 12px rgba(0,0,0,0.08); transform: scale(0.99); }
.product-list-item .pl-img {
    width: 50px;
    height: 50px;
    background: linear-gradient(135deg, #f1f5f9, #e2e8f0);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    color: #94a3b8;
    overflow: hidden;
    flex-shrink: 0;
}
.product-list-item .pl-img img { width: 100%; height: 100%; object-fit: cover; }
.product-list-item .pl-info { flex: 1; min-width: 0; }
.product-list-item .pl-name { font-weight: 600; font-size: 0.95rem; color: #1e293b; }
.product-list-item .pl-meta { font-size: 0.75rem; color: #94a3b8; margin-top: 2px; }
.product-list-item .pl-price { font-weight: 700; color: #3b82f6; font-size: 1rem; }
.product-list-item .pl-stock { font-size: 0.78rem; }
.stock-low { color: #ef4444; font-weight: 700; }
.stock-ok { color: #22c55e; }

/* Add to cart button on product list */
.product-list-item .pl-add-btn {
    background: linear-gradient(135deg, #22c55e, #16a34a);
    color: #fff;
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 12px;
    font-size: 1.4rem;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    box-shadow: 0 2px 8px rgba(22,163,74,0.25);
    transition: transform 0.1s;
}
.product-list-item .pl-add-btn:active { transform: scale(0.9); }

/* ========== SALES HISTORY ========== */
.sale-list-item {
    background: #fff;
    border-radius: 14px;
    padding: 14px 16px;
    margin-bottom: 10px;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: box-shadow 0.15s;
    border: 1px solid #e2e8f0;
    box-shadow: 0 1px 4px rgba(0,0,0,0.03);
}
.sale-list-item:active { box-shadow: 0 2px 12px rgba(0,0,0,0.08); }
.sale-list-item .sl-info { flex: 1; }
.sale-list-item .sl-receipt { font-weight: 700; font-size: 0.95rem; color: #1e293b; }
.sale-list-item .sl-date { font-size: 0.78rem; color: #94a3b8; margin-top: 2px; }
.sale-list-item .sl-total { font-weight: 800; font-size: 1.1rem; color: #1e293b; }
.sale-list-item .sl-method {
    font-size: 0.68rem;
    background: #eff6ff;
    color: #3b82f6;
    padding: 3px 10px;
    border-radius: 10px;
    text-transform: uppercase;
    font-weight: 700;
    margin-top: 4px;
    display: inline-block;
}

.filter-bar {
    display: flex;
    gap: 6px;
    margin-bottom: 14px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 4px;
}
.filter-bar::-webkit-scrollbar { display: none; }
.filter-btn {
    padding: 8px 16px;
    border: 2px solid #e2e8f0;
    border-radius: 20px;
    background: #fff;
    font-size: 0.82rem;
    font-weight: 600;
    white-space: nowrap;
    cursor: pointer;
    transition: all 0.2s;
    color: #64748b;
}
.filter-btn.active { background: #3b82f6; color: #fff; border-color: #3b82f6; }

/* ========== SETTINGS ========== */
.settings-group {
    background: #fff;
    border-radius: 16px;
    padding: 18px;
    margin-bottom: 14px;
    border: 1px solid #e2e8f0;
}
.settings-group h3 {
    font-size: 0.88rem;
    margin-bottom: 14px;
    color: #64748b;
    border-bottom: 1px solid #f1f5f9;
    padding-bottom: 8px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* ========== MODAL ========== */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 200;
    display: flex;
    align-items: flex-end;
    justify-content: center;
}
.modal-content {
    background: #fff;
    border-radius: 20px 20px 0 0;
    width: 100%;
    max-width: 480px;
    max-height: 90vh;
    overflow-y: auto;
    padding: 24px;
    animation: slideUp 0.25s ease-out;
}
@keyframes slideUp {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
}
.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 18px;
}
.modal-header h3 { font-size: 1.15rem; font-weight: 700; }
.modal-close {
    background: #f1f5f9;
    border: none;
    font-size: 1.2rem;
    cursor: pointer;
    color: #64748b;
    width: 36px;
    height: 36px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ========== TOAST ========== */
.toast {
    position: fixed;
    top: 70px;
    left: 50%;
    transform: translateX(-50%);
    background: #1e293b;
    color: #fff;
    padding: 12px 24px;
    border-radius: 12px;
    font-size: 0.9rem;
    font-weight: 600;
    z-index: 500;
    animation: fadeInOut 2.5s ease-in-out;
    white-space: nowrap;
    max-width: 90%;
    text-align: center;
    box-shadow: 0 4px 16px rgba(0,0,0,0.3);
}
.toast.error { background: linear-gradient(135deg, #ef4444, #dc2626); }
.toast.success { background: linear-gradient(135deg, #22c55e, #16a34a); }
@keyframes fadeInOut {
    0% { opacity: 0; transform: translateX(-50%) translateY(-10px); }
    15% { opacity: 1; transform: translateX(-50%) translateY(0); }
    80% { opacity: 1; }
    100% { opacity: 0; }
}

/* ========== LOADING ========== */
.loading { text-align: center; padding: 32px; color: #94a3b8; }
.spinner {
    display: inline-block;
    width: 28px; height: 28px;
    border: 3px solid #e2e8f0;
    border-top-color: #3b82f6;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ========== TOGGLE SWITCH ========== */
.toggle-switch {
    display: flex;
    align-items: center;
    gap: 10px;
}
.toggle-switch input[type="checkbox"] {
    width: 48px;
    height: 26px;
    appearance: none;
    -webkit-appearance: none;
    background: #cbd5e1;
    border-radius: 13px;
    position: relative;
    cursor: pointer;
    transition: background 0.2s;
    flex-shrink: 0;
}
.toggle-switch input[type="checkbox"]::after {
    content: '';
    position: absolute;
    width: 22px; height: 22px;
    background: #fff;
    border-radius: 50%;
    top: 2px; left: 2px;
    transition: transform 0.2s;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}
.toggle-switch input[type="checkbox"]:checked { background: #3b82f6; }
.toggle-switch input[type="checkbox"]:checked::after { transform: translateX(22px); }

/* ========== QUICK ADD GRID (Product buttons for fast adding) ========== */
.quick-products {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin-bottom: 14px;
}
.quick-product-btn {
    background: #fff;
    border: 2px solid #e2e8f0;
    border-radius: 14px;
    padding: 12px 6px;
    text-align: center;
    cursor: pointer;
    transition: all 0.15s;
}
.quick-product-btn:active { background: #eff6ff; border-color: #3b82f6; transform: scale(0.96); }
.quick-product-btn .qp-name { font-size: 0.78rem; font-weight: 600; color: #1e293b; margin-bottom: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.quick-product-btn .qp-price { font-size: 0.82rem; font-weight: 700; color: #3b82f6; }

/* ========== EXPORT BUTTONS ========== */
.export-bar {
    display: flex;
    gap: 6px;
    margin-bottom: 14px;
    flex-wrap: wrap;
}
.export-btn {
    padding: 8px 14px;
    border: 2px solid #e2e8f0;
    border-radius: 10px;
    background: #fff;
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    color: #475569;
    transition: all 0.2s;
}
.export-btn:hover { border-color: #3b82f6; color: #2563eb; }
.export-btn:active { background: #eff6ff; }

/* ========== RESPONSIVE ========== */

/* Phones (default) - max-width 480px already handled by base styles */

/* Small tablets / large phones (481px - 768px) */
@media (min-width: 481px) {
    .app-container {
        max-width: 600px;
        border-left: 1px solid #e2e8f0;
        border-right: 1px solid #e2e8f0;
        min-height: 100vh;
        background: #f5f6fa;
    }
    .bottom-nav { max-width: 600px; left: 50%; transform: translateX(-50%); }
    .quick-products { grid-template-columns: repeat(4, 1fr); }
    .receipt-content { max-width: 380px; }
}

/* Tablets (769px - 1024px) */
@media (min-width: 769px) {
    .app-container {
        max-width: 760px;
        padding-left: 8px;
        padding-right: 8px;
    }
    .bottom-nav {
        max-width: 760px;
    }
    .top-bar { padding: 16px 24px; }
    .top-bar h1 { font-size: 1.4rem; }
    .screen { padding: 20px; }
    .quick-products { grid-template-columns: repeat(5, 1fr); gap: 10px; }
    .quick-product-btn { padding: 16px 8px; }
    .quick-product-btn .qp-name { font-size: 0.85rem; }
    .quick-product-btn .qp-price { font-size: 0.9rem; }
    .search-bar input { font-size: 1.1rem; padding: 16px 18px; }
    .cart-section { padding: 20px; }
    .cart-item .item-name { font-size: 1rem; }
    .cart-totals .total-row.grand-total { font-size: 1.5rem; }
    .product-list-item { padding: 16px; }
    .product-list-item .pl-name { font-size: 1.05rem; }
    .sale-list-item { padding: 16px 20px; }
    .sale-list-item .sl-receipt { font-size: 1.05rem; }
    .sale-list-item .sl-total { font-size: 1.2rem; }
    .settings-group { padding: 22px; }
    .filter-bar { gap: 8px; }
    .filter-btn { padding: 10px 20px; font-size: 0.88rem; }
    .receipt-content { max-width: 400px; }
    .modal-content { max-width: 600px; border-radius: 20px; }
    .login-screen .login-box { max-width: 420px; padding: 48px 36px; }
    .payment-methods { gap: 10px; }
    .payment-method-btn { padding: 16px 12px; font-size: 0.9rem; }
    .export-bar { gap: 8px; }
    .export-btn { padding: 10px 18px; font-size: 0.85rem; }
}

/* Desktop / large tablets (1025px+) */
@media (min-width: 1025px) {
    .app-container {
        max-width: 900px;
    }
    .bottom-nav {
        max-width: 900px;
    }
    .bottom-nav button { font-size: 0.78rem; padding: 6px 20px; }
    .bottom-nav button .nav-icon { font-size: 1.5rem; }
    .top-bar { padding: 18px 32px; }
    .top-bar h1 { font-size: 1.5rem; }
    .screen { padding: 24px; }
    .quick-products { grid-template-columns: repeat(6, 1fr); gap: 12px; }
    .quick-product-btn { padding: 18px 10px; border-radius: 16px; }
    .quick-product-btn .qp-name { font-size: 0.9rem; }
    .quick-product-btn .qp-price { font-size: 0.95rem; }
    .search-bar input { font-size: 1.15rem; padding: 18px 20px; }
    .cart-section { padding: 24px; border-radius: 18px; }
    .cart-item .item-name { font-size: 1.05rem; }
    .cart-totals .total-row { font-size: 1rem; }
    .cart-totals .total-row.grand-total { font-size: 1.6rem; }
    .product-list-item { padding: 18px; border-radius: 16px; }
    .sale-list-item { padding: 18px 24px; border-radius: 16px; }
    .settings-group { padding: 24px; border-radius: 18px; }
    .filter-btn { padding: 10px 24px; font-size: 0.9rem; }
    .receipt-content { max-width: 440px; }
    .modal-content { max-width: 640px; }
    .login-screen .login-box { max-width: 460px; padding: 52px 44px; }
    .form-group input, .form-group select, .form-group textarea { padding: 15px 16px; font-size: 1.05rem; }
    .btn { padding: 16px 24px; font-size: 1.05rem; }
    .btn-lg { padding: 20px 28px; font-size: 1.2rem; }
}
