/* ===========================================
   نظام نقطة البيع — تصميم عصري RTL
   خط: Cairo | اتجاه: يمين لليسار
   =========================================== */

/* ---------- Reset & Base ---------- */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

:root {
    /* الألوان الرئيسية — بنفسجي عصري */
    --primary: #6C3DE0;
    --primary-dark: #5228C8;
    --primary-light: #EDE9FF;
    --primary-glow: rgba(108, 61, 224, 0.18);

    /* ألوان الحالة */
    --success: #10B981;
    --success-light: #D1FAE5;
    --success-dark: #059669;
    --danger: #EF4444;
    --danger-light: #FEE2E2;
    --danger-dark: #DC2626;
    --warning: #F59E0B;
    --warning-light: #FEF3C7;
    --info: #3B82F6;
    --info-light: #DBEAFE;

    /* ألوان محايدة */
    --bg: #F4F3FF;
    --surface: #FFFFFF;
    --surface-2: #FAFAFA;
    --border: #E5E1FF;
    --border-2: #D1D5DB;
    --text: #1E1B4B;
    --text-secondary: #6B7280;
    --text-muted: #9CA3AF;

    /* أحجام */
    --header-h: 60px;
    --nav-h: 64px;
    --radius: 12px;
    --radius-sm: 8px;
    --radius-lg: 20px;
    --radius-xl: 28px;
}

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: 'Cairo', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100dvh;
    overflow-x: hidden;
    direction: rtl;
}

/* ---------- Typography ---------- */
h1, h2, h3, h4 {
    font-weight: 700;
    line-height: 1.3;
}

h1 { font-size: 1.5rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.05rem; }

/* ---------- App Shell ---------- */
#app {
    display: flex;
    flex-direction: column;
    min-height: 100dvh;
}

/* ---------- Header ---------- */
.app-header {
    position: fixed;
    top: 0;
    inset-inline: 0;
    height: var(--header-h);
    background: linear-gradient(135deg, var(--primary) 0%, #9B59E8 100%);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    z-index: 100;
    box-shadow: 0 4px 20px rgba(108, 61, 224, 0.35);
}

.header-brand {
    display: flex;
    align-items: center;
    gap: 10px;
}

.header-logo-icon {
    opacity: 0.95;
}

.header-title {
    font-size: 1.15rem;
    font-weight: 700;
    letter-spacing: -0.2px;
}

.status-badge {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 12px;
    border-radius: 50px;
    font-size: 0.75rem;
    font-weight: 600;
    backdrop-filter: blur(8px);
}

.status-badge.online {
    background: rgba(16, 185, 129, 0.25);
    border: 1px solid rgba(16, 185, 129, 0.5);
    color: #d1fae5;
}

.status-badge.offline {
    background: rgba(239, 68, 68, 0.25);
    border: 1px solid rgba(239, 68, 68, 0.5);
    color: #fee2e2;
}

.status-dot-sm {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: currentColor;
    animation: pulse-dot 2s infinite;
}

@keyframes pulse-dot {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

/* ---------- App Body ---------- */
.app-body {
    flex: 1;
    margin-top: var(--header-h);
    margin-bottom: var(--nav-h);
    padding: 16px;
    overflow-y: auto;
}

/* ---------- Bottom Navigation ---------- */
.bottom-nav {
    position: fixed;
    bottom: 0;
    inset-inline: 0;
    height: var(--nav-h);
    background: var(--surface);
    border-top: 1.5px solid var(--border);
    display: flex;
    z-index: 100;
    box-shadow: 0 -4px 20px rgba(108, 61, 224, 0.1);
}

.bottom-nav .nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    font-size: 0.68rem;
    font-weight: 600;
    color: var(--text-muted);
    cursor: pointer;
    background: none;
    border: none;
    font-family: inherit;
    transition: color 0.2s, transform 0.15s;
    text-decoration: none;
    -webkit-tap-highlight-color: transparent;
    position: relative;
}

.bottom-nav .nav-item .nav-icon {
    transition: transform 0.2s;
}

.bottom-nav .nav-item.active {
    color: var(--primary);
}

.bottom-nav .nav-item.active .nav-icon {
    transform: scale(1.1);
}

.bottom-nav .nav-item.active::before {
    content: '';
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 32px;
    height: 3px;
    background: var(--primary);
    border-radius: 0 0 4px 4px;
}

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 20px;
    font-size: 0.95rem;
    font-weight: 700;
    font-family: inherit;
    border-radius: var(--radius);
    border: none;
    cursor: pointer;
    transition: all 0.2s;
    -webkit-tap-highlight-color: transparent;
    text-decoration: none;
    line-height: 1;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), #9B59E8);
    color: #fff;
    box-shadow: 0 4px 14px rgba(108, 61, 224, 0.35);
}
.btn-primary:active { transform: scale(0.97); opacity: 0.9; }

.btn-success {
    background: linear-gradient(135deg, var(--success), #34D399);
    color: #fff;
    box-shadow: 0 4px 14px rgba(16, 185, 129, 0.3);
}
.btn-success:active { transform: scale(0.97); }

.btn-danger {
    background: linear-gradient(135deg, var(--danger), #F87171);
    color: #fff;
    box-shadow: 0 4px 14px rgba(239, 68, 68, 0.3);
}
.btn-danger:active { transform: scale(0.97); }

.btn-outline {
    background: transparent;
    color: var(--primary);
    border: 2px solid var(--primary);
}
.btn-outline:active { background: var(--primary-light); }

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
    border: none;
}
.btn-ghost:active { background: var(--bg); }

.btn-sm {
    padding: 8px 14px;
    font-size: 0.85rem;
}

.btn-block { width: 100%; }

.btn-icon {
    width: 44px;
    height: 44px;
    padding: 0;
    border-radius: var(--radius-sm);
}

.btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
    transform: none !important;
    box-shadow: none !important;
}

/* ---------- Form Elements ---------- */
.form-group { margin-bottom: 16px; }

.form-label {
    display: block;
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text-secondary);
    margin-bottom: 7px;
}

.form-input {
    width: 100%;
    padding: 12px 14px;
    font-size: 0.95rem;
    font-family: inherit;
    border: 2px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--text);
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
    direction: rtl;
}

.form-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-glow);
}

.form-input::placeholder { color: var(--text-muted); }

.form-select {
    width: 100%;
    padding: 12px 14px;
    padding-left: 36px;
    font-size: 0.95rem;
    font-family: inherit;
    border: 2px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--text);
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%236B7280' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: left 12px center;
    cursor: pointer;
    direction: rtl;
    outline: none;
    transition: border-color 0.2s;
}

.form-select:focus { border-color: var(--primary); }

/* ---------- Cards ---------- */
.card {
    background: var(--surface);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 16px;
    margin-bottom: 12px;
}

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

/* Balance card variants */
.balance-card { padding: 20px; }
.balance-danger { border-color: var(--danger); background: var(--danger-light); }
.balance-success { border-color: var(--success); background: var(--success-light); }
.balance-amount { font-size: 1.1rem; }

/* ---------- List Items ---------- */
.list-item {
    display: flex;
    align-items: center;
    padding: 14px 16px;
    background: var(--surface);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-lg);
    margin-bottom: 8px;
    gap: 12px;
    cursor: pointer;
    transition: all 0.15s;
}

.list-item:active {
    background: var(--primary-light);
    border-color: var(--primary);
    transform: scale(0.99);
}

.item-icon {
    width: 42px;
    height: 42px;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.item-icon--blue  { background: var(--info-light);    color: var(--info); }
.item-icon--purple{ background: var(--primary-light); color: var(--primary); }
.item-icon--green { background: var(--success-light); color: var(--success); }
.item-icon--orange{ background: var(--warning-light); color: var(--warning); }

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

.list-item .item-title {
    font-weight: 700;
    font-size: 0.95rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.list-item .item-sub {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-top: 2px;
    direction: ltr;
    text-align: right;
}

.list-item .item-value {
    font-weight: 800;
    font-size: 1rem;
    white-space: nowrap;
}

/* ---------- Badge ---------- */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    font-size: 0.75rem;
    font-weight: 700;
    border-radius: 50px;
}

.badge-success { background: var(--success-light); color: var(--success-dark); }
.badge-danger  { background: var(--danger-light);  color: var(--danger-dark); }
.badge-warning { background: var(--warning-light); color: var(--warning); }

/* ---------- Login View ---------- */
.login-view {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100dvh;
    padding: 24px;
    background: linear-gradient(160deg, #E9E4FF 0%, #F4F3FF 60%, #EDF9F4 100%);
}

.login-card {
    width: 100%;
    max-width: 340px;
    background: var(--surface);
    border-radius: var(--radius-xl);
    padding: 36px 24px 28px;
    border: 1.5px solid var(--border);
    box-shadow: 0 16px 48px rgba(108, 61, 224, 0.12);
    display: flex;
    flex-direction: column;
    align-items: center;
}

.login-logo {
    width: 72px;
    height: 72px;
    background: linear-gradient(135deg, var(--primary), #9B59E8);
    border-radius: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    margin-bottom: 16px;
    box-shadow: 0 8px 24px rgba(108, 61, 224, 0.35);
}

.login-title {
    font-size: 1.5rem;
    font-weight: 800;
    margin-bottom: 4px;
    color: var(--text);
}

.login-subtitle {
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-bottom: 28px;
    text-align: center;
}

.pin-display {
    display: flex;
    gap: 14px;
    margin-bottom: 28px;
    direction: ltr;
}

.pin-dot {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    border: 2.5px solid var(--border-2);
    background: var(--surface);
    transition: all 0.2s;
}

.pin-dot.filled {
    background: var(--primary);
    border-color: var(--primary);
    box-shadow: 0 0 10px rgba(108, 61, 224, 0.4);
    transform: scale(1.1);
}

.pin-dot.error {
    background: var(--danger);
    border-color: var(--danger);
    animation: shake 0.4s ease;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    20% { transform: translateX(-5px); }
    40% { transform: translateX(5px); }
    60% { transform: translateX(-4px); }
    80% { transform: translateX(4px); }
}

.numpad {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    width: 100%;
}

.numpad-btn {
    height: 62px;
    font-size: 1.5rem;
    font-weight: 700;
    font-family: inherit;
    background: var(--bg);
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
    -webkit-tap-highlight-color: transparent;
}

.numpad-btn:active {
    background: var(--primary-light);
    border-color: var(--primary);
    transform: scale(0.93);
}

.numpad-btn.delete {
    color: var(--danger);
}

.numpad-btn.empty {
    visibility: hidden;
}

/* ---------- POS View ---------- */
.scan-bar {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
    align-items: center;
}

.search-wrap {
    flex: 1;
    position: relative;
}

.search-ic {
    position: absolute;
    right: 13px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    pointer-events: none;
}

.search-wrap .form-input {
    padding-right: 40px;
}

.scan-bar .btn-icon { flex-shrink: 0; }

.scanner-area {
    width: 100%;
    aspect-ratio: 4/3;
    background: #000;
    border: 2px solid var(--border);
    border-radius: var(--radius-lg);
    margin-bottom: 16px;
    overflow: hidden;
    position: relative;
}

.scanner-area video { width: 100%; height: 100%; object-fit: cover; }

/* Cart empty */
.cart-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 48px 16px;
    color: var(--text-muted);
    text-align: center;
}

.cart-empty-icon {
    color: var(--border-2);
    margin-bottom: 12px;
}

.cart-empty-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.cart-empty-sub {
    font-size: 0.82rem;
    color: var(--text-muted);
}

/* Cart items */
.cart-item {
    display: flex;
    align-items: center;
    padding: 12px 14px;
    background: var(--surface);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-lg);
    margin-bottom: 8px;
    gap: 10px;
    transition: all 0.15s;
}

.cart-item:active { background: var(--primary-light); }

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

.cart-item .cart-item-name {
    font-weight: 700;
    font-size: 0.9rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.cart-item .cart-item-price {
    font-size: 0.78rem;
    color: var(--text-secondary);
    margin-top: 2px;
}

.cart-item .cart-item-total {
    font-weight: 800;
    font-size: 0.95rem;
    white-space: nowrap;
    color: var(--primary);
    min-width: 60px;
    text-align: left;
}

.qty-control {
    display: flex;
    align-items: center;
    background: var(--bg);
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

.qty-btn {
    width: 34px;
    height: 34px;
    border: none;
    background: transparent;
    color: var(--primary);
    font-size: 1.2rem;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: inherit;
    -webkit-tap-highlight-color: transparent;
    transition: background 0.15s;
}

.qty-btn:active { background: var(--primary-light); }

.qty-val {
    min-width: 30px;
    text-align: center;
    font-weight: 700;
    font-size: 0.9rem;
    color: var(--text);
}

/* ---------- Checkout Sheet ---------- */
.checkout-sheet {
    position: fixed;
    bottom: var(--nav-h);
    inset-inline: 0;
    background: var(--surface);
    border-top: 1.5px solid var(--border);
    padding: 14px 16px;
    z-index: 90;
    box-shadow: 0 -8px 30px rgba(108, 61, 224, 0.12);
}

.checkout-total {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
}

.checkout-total .total-label {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.checkout-total .total-value {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--primary);
}

.checkout-row {
    display: flex;
    gap: 8px;
    margin-bottom: 10px;
}

.checkout-row .form-select,
.checkout-row .form-input { flex: 1; }

.btn-checkout {
    width: 100%;
    padding: 16px;
    font-size: 1.1rem;
    font-weight: 800;
    font-family: inherit;
    background: linear-gradient(135deg, var(--success), #34D399);
    color: #fff;
    border: none;
    border-radius: var(--radius-lg);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    -webkit-tap-highlight-color: transparent;
    transition: all 0.2s;
    box-shadow: 0 6px 18px rgba(16, 185, 129, 0.35);
}

.btn-checkout:active { transform: scale(0.98); opacity: 0.9; }

.btn-checkout:disabled {
    background: var(--border-2);
    box-shadow: none;
    cursor: not-allowed;
    color: var(--text-muted);
}

/* ---------- Search Bar (standalone) ---------- */
.search-bar {
    position: relative;
    margin-bottom: 16px;
}

.search-bar .form-input {
    padding-right: 42px;
}

.search-icon-abs {
    position: absolute;
    right: 13px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    pointer-events: none;
}

/* ---------- Stats Cards ---------- */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    margin-bottom: 16px;
}

.stat-card {
    background: var(--surface);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 18px 14px;
    text-align: center;
    position: relative;
    overflow: hidden;
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    inset-inline: 0;
    height: 3px;
    border-radius: 0;
}

.stat-blue::before  { background: var(--info); }
.stat-green::before { background: var(--success); }
.stat-orange::before{ background: var(--warning); }
.stat-red::before   { background: var(--danger); }

.stat-card .stat-value {
    font-size: 1.4rem;
    font-weight: 800;
    line-height: 1;
    margin-bottom: 6px;
    color: var(--text);
}

.stat-card .stat-label {
    font-size: 0.72rem;
    color: var(--text-secondary);
    font-weight: 600;
    letter-spacing: 0.3px;
}

/* ---------- Modal ---------- */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(30, 27, 75, 0.55);
    backdrop-filter: blur(4px);
    z-index: 200;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    animation: fadeIn 0.2s ease;
}

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.modal-content {
    background: var(--surface);
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    width: 100%;
    max-width: 480px;
    max-height: 85vh;
    overflow-y: auto;
    padding: 24px 16px 32px;
    animation: slideUp 0.25s ease;
}

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

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
}

.modal-header h2 { font-size: 1.15rem; }

/* ---------- Empty State ---------- */
.empty-state {
    text-align: center;
    padding: 48px 16px;
    color: var(--text-muted);
}

.empty-state .empty-icon {
    color: var(--border-2);
    margin-bottom: 14px;
    display: flex;
    justify-content: center;
}

.empty-state .empty-title {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

/* ---------- Section Header ---------- */
.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 14px;
}

/* ---------- Transaction Item ---------- */
.txn-item {
    display: flex;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
    gap: 12px;
}

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

.txn-icon {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius);
    flex-shrink: 0;
}

.txn-success { background: var(--success-light); color: var(--success); }
.txn-danger  { background: var(--danger-light);  color: var(--danger); }

.txn-item .txn-info { flex: 1; }
.txn-item .txn-amount { font-weight: 800; }
.txn-amount.positive { color: var(--success); }
.txn-amount.negative { color: var(--danger); }

/* ---------- Sync Status ---------- */
.sync-status {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 16px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-lg);
    background: var(--surface);
    margin-bottom: 20px;
}

.sync-indicator {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

.sync-indicator.online  { background: var(--success); box-shadow: 0 0 6px rgba(16,185,129,0.5); }
.sync-indicator.offline { background: var(--danger);  box-shadow: 0 0 6px rgba(239,68,68,0.5); }

.sync-status .sync-text { flex: 1; font-weight: 700; font-size: 0.9rem; }

/* ---------- Sub-header ---------- */
.sub-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
}

.sub-header .back-btn {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    cursor: pointer;
    color: var(--text);
    font-family: inherit;
    -webkit-tap-highlight-color: transparent;
    transition: all 0.15s;
}

.sub-header .back-btn:active {
    background: var(--primary-light);
    border-color: var(--primary);
}

/* ---------- Responsive ---------- */
@media (min-width: 480px) {
    .app-body {
        max-width: 480px;
        margin-left: auto;
        margin-right: auto;
    }
    .checkout-sheet {
        max-width: 480px;
        left: 50%;
        right: auto;
        transform: translateX(-50%);
    }
    .bottom-nav {
        max-width: 480px;
        left: 50%;
        right: auto;
        transform: translateX(-50%);
    }
}

/* ---------- Utilities ---------- */
.text-center  { text-align: center; }
.text-right   { text-align: right; }
.text-muted   { color: var(--text-muted); }
.text-danger  { color: var(--danger); }
.text-success { color: var(--success); }
.font-bold    { font-weight: 700; }
.mt-8   { margin-top: 8px; }
.mt-16  { margin-top: 16px; }
.mb-8   { margin-bottom: 8px; }
.mb-16  { margin-bottom: 16px; }
.flex   { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.hidden { display: none !important; }

/* ---------- Toast ---------- */
.toast {
    position: fixed;
    top: calc(var(--header-h) + 10px);
    left: 50%;
    transform: translateX(-50%);
    padding: 12px 20px;
    border-radius: 50px;
    font-weight: 700;
    font-size: 0.88rem;
    z-index: 300;
    max-width: calc(100% - 32px);
    text-align: center;
    animation: toastIn 0.25s ease, toastOut 0.25s ease 2.3s forwards;
    white-space: nowrap;
    box-shadow: 0 6px 20px rgba(0,0,0,0.15);
}

.toast.success {
    background: var(--success);
    color: #fff;
}

.toast.error {
    background: var(--danger);
    color: #fff;
}

@keyframes toastIn {
    from { opacity: 0; transform: translateX(-50%) translateY(-12px) scale(0.9); }
    to   { opacity: 1; transform: translateX(-50%) translateY(0) scale(1); }
}

@keyframes toastOut {
    from { opacity: 1; }
    to   { opacity: 0; }
}

/* ---------- Spinner ---------- */
.spinner {
    width: 16px;
    height: 16px;
    border: 2.5px solid rgba(255,255,255,0.4);
    border-top-color: currentColor;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
    display: inline-block;
    flex-shrink: 0;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ============ DARK MODE ============ */
body.dark {
    --bg: #0F0E1A;
    --surface: #1A1827;
    --surface-2: #221F33;
    --border: #2D2A45;
    --border-2: #3D3A55;
    --text: #F0EEFF;
    --text-secondary: #A89ED0;
    --text-muted: #6B6390;
    --primary-light: #2D1F5E;
    --primary-glow: rgba(108, 61, 224, 0.25);
    --success-light: #0D2E22;
    --danger-light: #2E0D0D;
    --info-light: #0D1E3A;
    --warning-light: #2E2000;
}
body.dark .numpad-btn { background: var(--surface-2); }
body.dark .form-input, body.dark .form-select { background: var(--surface-2); border-color: var(--border); color: var(--text); }
body.dark .login-card { background: var(--surface); border-color: var(--border); }
body.dark .login-view { background: linear-gradient(160deg, #1A1040 0%, #0F0E1A 60%, #0D2015 100%); }
body.dark .balance-danger { background: var(--danger-light); border-color: var(--danger); }
body.dark .balance-success { background: var(--success-light); border-color: var(--success); }

/* ============ SPLASH SCREEN ============ */
.splash-screen {
    position: fixed;
    inset: 0;
    background: linear-gradient(160deg, var(--primary) 0%, #9B59E8 100%);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 999;
    gap: 16px;
    color: #fff;
}
.splash-logo {
    width: 88px;
    height: 88px;
    background: rgba(255,255,255,0.2);
    border-radius: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1.5px solid rgba(255,255,255,0.3);
    animation: logoPop 0.5s 0.2s ease both;
}
@keyframes logoPop {
    from { transform: scale(0.5) rotate(-10deg); opacity:0; }
    to   { transform: scale(1) rotate(0deg); opacity:1; }
}
.splash-title { font-size: 1.8rem; font-weight: 800; }
.splash-dots { display: flex; gap: 8px; }
.splash-dots span {
    width: 8px; height: 8px; border-radius: 50%;
    background: rgba(255,255,255,0.7);
    animation: dotBounce 1.2s infinite ease;
}
.splash-dots span:nth-child(2) { animation-delay: 0.2s; }
.splash-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes dotBounce {
    0%, 80%, 100% { transform: scale(1); opacity:0.6; }
    40% { transform: scale(1.4); opacity:1; }
}

/* ============ HEADER ADDITIONS ============ */
.header-actions { display: flex; align-items: center; gap: 8px; }
.header-icon-btn {
    width: 36px; height: 36px;
    border-radius: 10px; border: none;
    background: rgba(255,255,255,0.15);
    color: #fff;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer; transition: background 0.2s;
    -webkit-tap-highlight-color: transparent;
}
.header-icon-btn:active { background: rgba(255,255,255,0.3); }

/* ============ LOW STOCK ALERT ============ */
.low-stock-alert {
    display: flex; align-items: center; gap: 8px;
    padding: 10px 14px;
    background: var(--warning-light);
    border: 1.5px solid var(--warning);
    border-radius: var(--radius-lg);
    color: var(--warning);
    font-weight: 700; font-size: 0.85rem;
    margin-bottom: 14px;
}

/* ============ NAV BADGE ============ */
.nav-icon-wrap { position: relative; display: flex; align-items: center; justify-content: center; }
.nav-badge {
    position: absolute; top: -6px; left: -6px;
    min-width: 18px; height: 18px;
    background: var(--danger); color: #fff;
    border-radius: 50px; font-size: 0.65rem; font-weight: 800;
    display: flex; align-items: center; justify-content: center;
    padding: 0 4px; border: 2px solid var(--surface);
}

/* ============ ITEM ACTIONS ============ */
.item-actions { display: flex; gap: 6px; flex-shrink: 0; }
.action-btn {
    width: 34px; height: 34px;
    border-radius: var(--radius-sm); border: 1.5px solid;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer; transition: all 0.15s;
    background: transparent; flex-shrink: 0;
}
.action-edit  { color: var(--info);   border-color: var(--info-light);   background: var(--info-light); }
.action-delete{ color: var(--danger); border-color: var(--danger-light); background: var(--danger-light); }
.action-edit:active  { background: var(--info);   color: #fff; }
.action-delete:active{ background: var(--danger); color: #fff; }

/* ============ SETTINGS TABS ============ */
.settings-tabs {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 6px;
    margin-bottom: 20px;
    background: var(--bg);
    padding: 6px;
    border-radius: var(--radius-lg);
    border: 1.5px solid var(--border);
}
.tab-btn {
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    gap: 3px; padding: 10px 4px;
    border: none; border-radius: var(--radius);
    background: transparent; color: var(--text-muted);
    font-family: inherit; font-size: 0.7rem; font-weight: 700;
    cursor: pointer; transition: all 0.2s;
    -webkit-tap-highlight-color: transparent;
}
.tab-btn.active {
    background: var(--surface); color: var(--primary);
    box-shadow: 0 2px 8px rgba(108, 61, 224, 0.15);
}

/* ============ CHART CONTAINER ============ */
.chart-container {
    background: var(--surface);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 16px;
    margin-bottom: 12px;
    height: 220px;
    position: relative;
}

/* ============ SALES HISTORY ============ */
.sale-hist-item {
    display: flex; align-items: center; gap: 12px;
    padding: 12px 14px;
    background: var(--surface);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-lg);
    margin-bottom: 8px;
}
.sale-hist-icon {
    width: 40px; height: 40px;
    border-radius: var(--radius);
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}
.hist-cash   { background: var(--success-light); color: var(--success); }
.hist-credit { background: var(--info-light);    color: var(--info); }
.sale-hist-info { flex: 1; }
.sale-hist-type { font-weight: 700; font-size: 0.9rem; }
.sale-hist-amount { font-weight: 800; font-size: 1rem; color: var(--primary); white-space: nowrap; }

/* ============ CONFIRM MODAL ============ */
.confirm-modal {
    text-align: center;
    display: flex; flex-direction: column;
    align-items: center;
    padding: 32px 24px !important;
}
.confirm-icon {
    width: 64px; height: 64px;
    background: var(--warning-light); color: var(--warning);
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    margin-bottom: 16px;
}

/* ============ CATEGORIES (Chips) ============ */
.categories-bar {
    display: flex;
    overflow-x: auto;
    gap: 8px;
    padding: 0 4px 12px 4px;
    margin-bottom: 8px;
}
.categories-bar::-webkit-scrollbar { height: 4px; }
.categories-bar::-webkit-scrollbar-thumb { background: var(--border-2); border-radius: 4px; }

.category-chip {
    padding: 6px 14px;
    border-radius: 50px;
    background: var(--surface);
    border: 1.5px solid var(--border);
    color: var(--text-muted);
    font-weight: 700;
    font-size: 0.85rem;
    white-space: nowrap;
    cursor: pointer;
    transition: all 0.2s;
    user-select: none;
}
.category-chip.active {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
    box-shadow: 0 2px 8px var(--primary-glow);
}

/* ============ RETURN BUTTON ============ */
.btn-return {
    padding: 4px 10px;
    background: transparent;
    color: var(--danger);
    border: 1.5px solid var(--danger-light);
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 4px;
    transition: 0.2s;
}
.btn-return:hover { background: var(--danger-light); }
.btn-return:disabled { opacity: 0.5; pointer-events: none; border-color: transparent; }

/* ============ EXPORT BUTTON ============ */
.btn-export {
    background: var(--info-light);
    color: var(--info);
    border: 1.5px solid var(--info);
    gap: 6px;
    margin-top: 16px;
}
.btn-export:hover { background: var(--info); color: #fff; }

/* ============ PURCHASES VIEW ============ */
.purchase-item-row {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr auto;
    gap: 8px;
    margin-bottom: 8px;
    align-items: center;
}
.purchase-item-row input { margin: 0; }
