@font-face {
  font-family: 'Vazirmatn';
  src: url('assets/fonts/Vazirmatn-Variable.woff2') format('woff2-variations'), url('assets/fonts/Vazirmatn-Variable.woff2') format('woff2');
  font-weight: 100 900;
  font-display: swap;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; margin: 0; }
body {
  font-family: 'Vazirmatn', Tahoma, 'Segoe UI', sans-serif;
  background: #f4f5f7;
  color: #1f2430;
  direction: rtl;
  display: flex;
  flex-direction: column;
  padding-top: env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
}

.topbar {
  display: flex; align-items: center; gap: 10px;
  background: #1f2937; color: #fff; padding: 12px 16px; font-weight: bold; font-size: 16px;
}
.logo-sm { width: 30px; height: 30px; border-radius: 8px; object-fit: cover; }
.sync-dot { width: 10px; height: 10px; border-radius: 50%; background: #6b7280; margin-inline-start: auto; }
.sync-dot.ok { background: #22c55e; }
.sync-dot.err { background: #ef4444; }

#content { flex: 1; overflow-y: auto; padding: 12px; padding-bottom: 90px; }
.tab { display: none; }
.tab.active { display: block; }

.toolbar { display: flex; gap: 8px; margin-bottom: 10px; }
.toolbar input, .toolbar select, #posSearch { padding: 10px; border-radius: 8px; border: 1px solid #d1d5db; font-size: 14px; }
.toolbar input { flex: 1; }
#posSearch { width: 100%; margin-bottom: 10px; }

.order-card { background: #fff; border-radius: 10px; padding: 12px; margin-bottom: 10px; box-shadow: 0 1px 3px rgba(0,0,0,.06); }
.order-card .row1 { display: flex; justify-content: space-between; font-weight: bold; }
.order-card .row2 { display: flex; justify-content: space-between; font-size: 13px; color: #555; margin-top: 4px; }
.status-badge { padding: 3px 8px; border-radius: 12px; font-size: 11px; color: #fff; }
.dealer-badge { display: inline-block; padding: 2px 7px; border-radius: 10px; font-size: 10px; font-weight: bold; color: #fff; background: #16a34a; vertical-align: middle; }
.status-pending { background: #f59e0b; }
.status-processing { background: #3b82f6; }
.status-on-hold { background: #a855f7; }
.status-completed { background: #22c55e; }
.status-cancelled { background: #6b7280; }
.status-refunded { background: #ef4444; }
.status-failed { background: #dc2626; }

.cart-tab { padding-bottom: 12px; }
.cart-empty-hint { text-align: center; color: #9ca3af; font-size: 13px; padding: 50px 20px; line-height: 1.8; }
.scan-cart-btn { width: 100%; background: #2563eb; color: #fff; border: none; border-radius: 9px; padding: 13px; font-size: 14.5px; font-family: inherit; margin-bottom: 12px; }

.bottom-nav {
  display: flex; background: #fff; border-top: 1px solid #e5e7eb;
  position: fixed; bottom: 0; left: 0; right: 0; padding-bottom: env(safe-area-inset-bottom);
}
.nav-btn { flex: 1; border: none; background: none; padding: 8px 0; font-size: 12px; color: #6b7280; }
.nav-btn.active { color: #2563eb; font-weight: bold; }

.primary-btn { background: #2563eb; color: #fff; border: none; padding: 12px; border-radius: 8px; font-size: 15px; width: 100%; margin-top: 8px; }
button { cursor: pointer; }

.settings-form { display: flex; flex-direction: column; gap: 8px; background: #fff; padding: 14px; border-radius: 10px; }
.settings-form h3 { margin: 10px 0 2px; border-top: 1px solid #eee; padding-top: 10px; }
.settings-form input[type=text], .settings-form input[type=password], .settings-form input[type=number] {
  padding: 10px; border-radius: 8px; border: 1px solid #d1d5db;
}
#testConnResult, #saveResult { font-size: 12px; }
.field-hint { font-size: 12px; color: #6b7280; background: #eef1ff; border: 1px solid #d7defc; border-radius: 9px; padding: 10px 12px; line-height: 1.9; }

/* کاربران سایت (مشتری‌ها) */
.customer-card { background: #fff; border-radius: 10px; padding: 14px; margin-bottom: 10px; box-shadow: 0 1px 3px rgba(0,0,0,.06); }
.customer-card-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; padding-bottom: 8px; border-bottom: 1px solid #eee; }
.customer-phone { font-weight: 700; font-size: 14px; }
.customer-save-result { font-size: 12px; color: #6b7280; margin-top: 4px; }

.modal { position: fixed; inset: 0; background: rgba(0,0,0,.5); display: flex; align-items: flex-end; z-index: 50; }
.modal.hidden { display: none; }
.modal-box { background: #fff; border-radius: 16px 16px 0 0; padding: 18px; width: 100%; max-height: 85vh; overflow-y: auto; position: relative; }
.close-btn { position: absolute; top: 10px; left: 14px; border: none; background: none; font-size: 18px; z-index: 5; }

/* سبد فروش - چیدمان موبایل */
.cart-items-list { margin: 4px 0 2px; }
.cart-item { background: #f8f9fb; border-radius: 10px; padding: 10px 12px; margin-bottom: 8px; }
.cart-item-name { font-size: 13.5px; font-weight: 600; margin-bottom: 10px; line-height: 1.5; }
.cart-item-controls { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.qty-ctrl { display: flex; align-items: center; gap: 10px; }
.qty-ctrl button { border: none; background: #e5e7eb; width: 34px; height: 34px; border-radius: 8px; font-size: 17px; }
.qty-value { min-width: 18px; text-align: center; font-weight: 700; font-size: 14px; }

.cart-section { border-top: 1px solid #eee; padding-top: 12px; margin-top: 10px; }
.cart-section-title { font-size: 12px; font-weight: 700; color: #6b7280; margin-bottom: 10px; }
.cart-field { margin-bottom: 12px; }
.cart-field:last-child { margin-bottom: 0; }
.cart-field label { display: block; font-size: 12.5px; color: #6b7280; margin-bottom: 5px; }
.cart-field input, .cart-field select { width: 100%; padding: 11px 12px; border-radius: 9px; border: 1px solid #d1d5db; font-family: inherit; font-size: 14px; background: #fff; color: inherit; }
#shippingMethodCustom { margin-top: 8px; }
.cart-field-row { display: flex; gap: 8px; }
.cart-field-row input { flex: 1; }
.cart-field-row button { padding: 0 16px; border-radius: 9px; border: 1px solid #d1d5db; background: #fff; font-size: 13.5px; }
.cart-field-inline-check { display: flex; flex-direction: column; gap: 10px; background: #f8f9fb; padding: 12px; border-radius: 10px; }

.cart-footer { position: sticky; bottom: 0; background: #fff; padding: 12px 0 calc(12px + env(safe-area-inset-bottom)); margin-top: 12px; border-top: 1px solid #eee; }
.cart-total { font-size: 17px; font-weight: bold; margin-bottom: 6px; text-align: left; }

#toastHost { position: fixed; bottom: 78px; left: 12px; right: 12px; z-index: 100; display: flex; flex-direction: column; gap: 6px; pointer-events: none; }
.toast { background: #111827; color: #fff; padding: 10px 14px; border-radius: 8px; font-size: 13px; text-align: center; }

.hidden { display: none !important; }

/* ورود */
.login-screen {
  position: fixed; inset: 0; background: linear-gradient(160deg, #171c2c 0%, #0f1320 100%);
  display: flex; align-items: center; justify-content: center; z-index: 500;
  padding: 20px; padding-top: calc(20px + env(safe-area-inset-top)); padding-bottom: calc(20px + env(safe-area-inset-bottom));
}
.login-box {
  background: #fff; border-radius: 20px; padding: 30px 24px; width: 100%; max-width: 360px;
  box-shadow: 0 8px 24px rgba(0,0,0,.25); display: flex; flex-direction: column; align-items: center; gap: 4px;
}
.login-logo { width: 60px; height: 60px; border-radius: 16px; margin-bottom: 6px; box-shadow: 0 4px 14px rgba(244,200,0,.25); }
.login-box h2 { margin: 0 0 16px; font-size: 16px; }
#loginForm { width: 100%; display: flex; flex-direction: column; gap: 8px; }
#loginForm label { font-size: 12.5px; color: #6b7280; }
#loginForm input[type=text], #loginForm input[type=password] { padding: 10px; border-radius: 8px; border: 1px solid #d1d5db; font-family: inherit; font-size: 14px; }
#loginForm .primary-btn { margin-top: 10px; }
.login-error { color: #dc2626; font-size: 12.5px; min-height: 16px; text-align: center; }
.remember-row { display: flex; align-items: center; gap: 6px; font-size: 12.5px; color: #6b7280; margin: 2px 0 0; cursor: pointer; }
.remember-row input { margin: 0; }
.login-hint { font-size: 11px; color: #9ca3af; text-align: center; margin-top: 8px; line-height: 1.7; }

/* کاربران */
.user-card { background: #fff; border-radius: 10px; padding: 12px; margin-bottom: 10px; box-shadow: 0 1px 3px rgba(0,0,0,.06); display: flex; justify-content: space-between; align-items: center; }
.user-card .role-tag { display: inline-block; margin-top: 4px; font-size: 10.5px; background: #eef1ff; color: #3a54d6; padding: 2px 8px; border-radius: 10px; }
.user-card .user-actions button { border: 1px solid #d1d5db; background: #fff; padding: 6px 10px; border-radius: 7px; font-size: 12px; margin-inline-start: 4px; }
.user-card .user-actions button.danger { color: #dc2626; border-color: #fca5a5; }

/* POS - جستجو و اسکن */
.pos-search-row { display: flex; gap: 8px; margin-bottom: 10px; }
.pos-search-row input { flex: 1; padding: 11px 12px; border-radius: 9px; border: 1px solid #d1d5db; font-size: 14px; font-family: inherit; background: #fff; }
.pos-search-row button { background: #2563eb; color: #fff; border: none; border-radius: 9px; padding: 0 18px; font-size: 18px; flex-shrink: 0; }

/* تب جستجوی محصول */
.lookup-results-list { margin-top: 4px; }

/* سبد فروش - قیمت همکار / تخفیف */
.dealer-toggle { display: flex; align-items: center; gap: 8px; font-size: 13.5px; font-weight: 600; }
.dealer-toggle input { margin: 0; width: 18px; height: 18px; }
#dealerMarkupPercent { width: 100%; padding: 10px; border-radius: 9px; border: 1px solid #d1d5db; font-family: inherit; font-size: 14px; }
.cart-price-input { width: 108px; padding: 8px; border-radius: 8px; border: 1px solid #d1d5db; text-align: left; font-size: 13px; }
.cart-price-input.overridden { border-color: #2563eb; background: #eff6ff; }
.price-reset-btn { border: none; background: none; color: #6b7280; font-size: 16px; padding: 4px 6px; }
.coupon-result { font-size: 12px; color: #6b7280; min-height: 16px; margin-top: 6px; }
.coupon-result.ok { color: #16a34a; }
.coupon-result.err { color: #dc2626; }
.cart-item-row-price { display: flex; align-items: center; gap: 4px; }

/* مودال اسکن */
#scanVideo { width: 100%; border-radius: 10px; background: #000; margin: 10px 0; max-height: 280px; object-fit: cover; }
.scan-result { text-align: center; font-size: 13px; color: #6b7280; }

/* اقلام سفارش داخل جزئیات سفارش - تعداد/قیمت/جمع کاملاً از هم جدا */
.order-line-item { background: #f8f9fb; border-radius: 10px; padding: 10px 12px; margin-bottom: 8px; }
.order-line-name { font-size: 13.5px; font-weight: 600; margin-bottom: 3px; }
.order-line-sku { font-size: 11px; color: #888; margin-bottom: 6px; }
.order-line-meta { display: flex; flex-wrap: wrap; gap: 10px; font-size: 12px; color: #444; border-top: 1px dashed #d9dce3; padding-top: 6px; }
.order-line-meta b { color: #111; font-weight: 600; }

/* وضعیت سفارش داخل جزئیات سفارش */
.order-status-field { margin: 16px 0 10px; }
.order-status-field label { display: block; font-size: 12.5px; color: #6b7280; margin-bottom: 5px; }
.order-status-select { width: 100%; padding: 11px 12px; border-radius: 9px; border: 1px solid #d1d5db; font-family: inherit; font-size: 14px; background: #fff; color: inherit; }
.status-update-result { font-size: 12.5px; color: #16a34a; margin-top: 8px; text-align: center; min-height: 16px; }

/* تب جستجوی محصول */
.lookup-product-card { background: #fff; border-radius: 10px; padding: 12px; margin-bottom: 10px; box-shadow: 0 1px 3px rgba(0,0,0,.06); }
.lookup-product-card h4 { margin: 0 0 4px; font-size: 14px; }
.lookup-product-card .sku { color: #888; font-size: 11px; margin-bottom: 8px; }
.variation-row { display: flex; justify-content: space-between; align-items: center; padding: 8px 0; border-bottom: 1px solid #eee; font-size: 12.5px; gap: 6px; }
.variation-row .v-info { flex: 1; }
.variation-row button { border: 1px solid #d1d5db; background: #fff; padding: 6px 10px; border-radius: 7px; font-size: 12px; white-space: nowrap; }
.stock-ok { color: #16a34a; }
.stock-low { color: #f59e0b; }

.price-edit-row { padding: 10px 0; border-bottom: 1px solid #eee; }
.price-edit-row:last-child { border-bottom: none; }
.price-edit-fields { display: flex; gap: 8px; margin: 8px 0; }
.price-edit-fields label { flex: 1; font-size: 11px; color: #666; display: flex; flex-direction: column; gap: 3px; }
.price-edit-fields input { padding: 7px 8px; border: 1px solid #d1d5db; border-radius: 7px; font-size: 13px; width: 100%; box-sizing: border-box; }
.stock-out { color: #dc2626; }

/* تقویم شمسی قابل‌انتخاب (برای فیلدهای تاریخ تب تحلیل فروش) */
.jdp-popup {
  display: none; width: 260px; max-width: 90vw; background: #fff; border: 1px solid #e5e7eb;
  border-radius: 12px; box-shadow: 0 12px 30px rgba(20,25,50,.25); padding: 10px; font-size: 13px; z-index: 9999;
}
.jdp-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.jdp-nav { background: #eef1ff; border: none; border-radius: 6px; width: 28px; height: 28px; font-size: 16px; cursor: pointer; color: #2563eb; }
.jdp-title { font-weight: 700; }
.jdp-weekdays { display: grid; grid-template-columns: repeat(7, 1fr); text-align: center; color: #6b7280; font-size: 11.5px; margin-bottom: 4px; }
.jdp-days { display: grid; grid-template-columns: repeat(7, 1fr); gap: 3px; }
.jdp-day { border: none; background: transparent; border-radius: 6px; padding: 7px 0; cursor: pointer; font-size: 12.5px; font-family: inherit; }
.jdp-day:hover { background: #eef1ff; }
.jdp-today-day { border: 1px solid #2563eb; }
.jdp-selected { background: #2563eb; color: #fff; }
.jdp-empty { visibility: hidden; }
.jdp-footer { display: flex; justify-content: space-between; margin-top: 8px; border-top: 1px solid #eee; padding-top: 8px; }
.jdp-footer button { background: transparent; border: none; color: #2563eb; font-size: 12.5px; cursor: pointer; font-family: inherit; }

/* عکس کوچک محصول در نتایج جستجو (تب جستجوی کالا و تب تغییر قیمت) */
.lookup-card-head { display: flex; align-items: flex-start; gap: 10px; }
.lookup-card-title { flex: 1; min-width: 0; }
.product-thumb {
  width: 48px; height: 48px; flex-shrink: 0; object-fit: cover;
  border-radius: 8px; border: 1px solid #e5e7eb; background: #f3f4f8;
}
.product-thumb-empty { display: flex; align-items: center; justify-content: center; font-size: 18px; opacity: .35; }

/* دکمه‌ی کپی لینک محصول در نتایج جستجو */
.copy-link-btn {
  margin-top: 5px;
  padding: 5px 12px;
  font-size: 12px;
  font-family: inherit;
  border: 1px solid #e5e7eb;
  border-radius: 7px;
  background: #f7f8fb;
  color: #444;
}
.copy-link-btn:active { background: #eef1ff; border-color: #c7d0ff; }
