/* ============================================================
   Litora CSS v0.7 — Rial-native, complete
   ARCHITECTURE: body ثابت — #app اسکرول‌کننده
   ============================================================ */

:root,[data-theme="blue"]{--primary:#1e40af;--primary-dark:#1e3a8a;--primary-light:#3b82f6;--success:#16a34a;--danger:#dc2626;--warning:#d97706;--bg:#f1f5f9;--card:#fff;--border:#e2e8f0;--text:#0f172a;--muted:#64748b;--radius:12px;--hdr-h:60px;--sb-h:34px;--top-h:94px}
[data-theme="green"]{--primary:#059669;--primary-dark:#047857;--primary-light:#10b981}
[data-theme="purple"]{--primary:#7c3aed;--primary-dark:#6d28d9;--primary-light:#a78bfa}
[data-theme="orange"]{--primary:#ea580c;--primary-dark:#c2410c;--primary-light:#fb923c}
[data-theme="rose"]{--primary:#e11d48;--primary-dark:#be123c;--primary-light:#fb7185}
[data-theme="teal"]{--primary:#0d9488;--primary-dark:#0f766e;--primary-light:#2dd4bf}
[data-theme="indigo"]{--primary:#4f46e5;--primary-dark:#4338ca;--primary-light:#818cf8}
[data-theme="amber"]{--primary:#d97706;--primary-dark:#b45309;--primary-light:#f59e0b}
[data-theme="cyan"]{--primary:#0891b2;--primary-dark:#0e7490;--primary-light:#22d3ee}
[data-theme="slate"]{--primary:#475569;--primary-dark:#334155;--primary-light:#94a3b8}
[data-theme="dark"]{--primary:#3b82f6;--primary-dark:#1e40af;--primary-light:#60a5fa;--success:#22c55e;--danger:#ef4444;--warning:#f59e0b;--bg:#0f172a;--card:#1e293b;--border:#334155;--text:#f1f5f9;--muted:#94a3b8}
[data-theme="dark"] input,[data-theme="dark"] select,[data-theme="dark"] textarea{background:#0f172a;color:#f1f5f9;border-color:#334155}
[data-theme="dark"] .bottom-nav{background:#1e293b}
[data-theme="dark"] .product-card{background:#1e293b}
[data-theme="dark"] .stat-box{background:#1e293b}
[data-theme="dark"] .modal{background:#1e293b;color:#f1f5f9}
[data-theme="dark"] .invoice-print{background:#fff;color:#000}
[data-theme="dark"] .btn-secondary{background:#334155;color:#f1f5f9}
[data-theme="dark"] .backup-opt{background:#0f172a}
[data-theme="dark"] .customer-row{background:#1e293b}
[data-theme="dark"] .sticky-toolbar{background:#0f172a}
[data-theme="dark"] .driver-controls-sticky{background:#0f172a}

/* ============================================================
   ROOT — بدون اسکرول، بدون overflow-x
   ============================================================ */
*{box-sizing:border-box;-webkit-tap-highlight-color:transparent}
html{
  height:100%;
  margin:0;
  padding:0;
  overflow:hidden;
  background:var(--bg);
}
body{
  margin:0;
  padding:0;
  height:100%;
  overflow:hidden;
  font-family:'Vazirmatn',system-ui,sans-serif;
  background:var(--bg);
  color:var(--text);
  overscroll-behavior:none;
  -webkit-text-size-adjust:100%;
}

/* ============================================================
   #app — تنها اسکرول‌کننده
   ============================================================ */
#app{
  height:100vh;
  height:100dvh;
  width:100%;
  max-width:100%;
  overflow-y:auto;
  overflow-x:hidden;
  -webkit-overflow-scrolling:touch;
  overscroll-behavior-y:contain;
  touch-action:pan-y;
  position:relative;
  background:var(--bg);
}

/* ============================================================
   Form elements
   ============================================================ */
button,input,select,textarea{font-family:inherit;font-size:1rem}
input,select,textarea{width:100%;padding:10px 12px;border:1px solid var(--border);border-radius:8px;background:var(--card);color:var(--text)}
input:focus,select:focus,textarea:focus{outline:none;border-color:var(--primary);box-shadow:0 0 0 3px rgba(59,130,246,.15)}
button{cursor:pointer}

.btn{display:inline-flex;align-items:center;justify-content:center;gap:6px;padding:10px 16px;border-radius:8px;border:none;background:var(--primary);color:#fff;font-weight:500}
.btn:active{opacity:.8}
.btn-secondary{background:#e2e8f0;color:var(--text)}
.btn-success{background:var(--success)}
.btn-danger{background:var(--danger)}
.btn-warning{background:var(--warning)}
.btn-block{width:100%}
.btn-sm{padding:6px 10px;font-size:.85rem}

/* ============================================================
   HEADER (sticky)
   ============================================================ */
.top-sticky-wrap{
  position:sticky;
  top:0;
  z-index:100;
  background:var(--primary);
  box-shadow:0 2px 6px rgba(0,0,0,.08);
}
.header{background:var(--primary);color:#fff;padding:0 16px;display:flex;align-items:center;gap:12px;height:var(--hdr-h)}
.header h1{font-size:1.05rem;margin:0;flex:1;font-weight:600;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.header .back,.header .icon-btn{background:rgba(255,255,255,.15);border:none;color:#fff;width:36px;height:36px;border-radius:50%;display:flex;align-items:center;justify-content:center;font-size:1.2rem;text-decoration:none;flex-shrink:0}
.header-logo{width:32px;height:32px;border-radius:9px;object-fit:cover;background:#fff;flex:0 0 auto}

/* ============================================================
   CONTAINER
   ============================================================ */
.container{
  padding:12px;
  padding-bottom:96px;
  max-width:720px;
  margin:0 auto;
}

/* ============================================================
   STICKY TOOLBARS
   ============================================================ */
.sticky-toolbar,.persistent-toolbar{
  position:sticky;
  top:var(--top-h);
  z-index:95;
  background:var(--bg);
  padding:8px 0 10px;
  margin:0 0 8px;
  border-bottom:1px solid var(--border);
  box-shadow:0 6px 12px -10px rgba(15,23,42,.5);
}

.driver-controls-sticky{
  position:sticky;
  top:var(--top-h);
  z-index:98;
  background:var(--bg);
  margin:-12px -12px 8px;
  padding:8px 12px 10px;
  border-bottom:1px solid var(--border);
  box-shadow:0 6px 12px -10px rgba(15,23,42,.5);
}
.driver-controls-sticky .tabs{position:static;box-shadow:none;background:var(--card);margin:0}
.driver-controls-sticky .driver-toolbar{position:static;padding:8px 0 0;margin:0;background:transparent;box-shadow:none}
.driver-toolbar{background:transparent;padding:0}

.profit-tabs{
  display:flex;
  gap:4px;
  padding:4px;
  background:var(--card);
  border-radius:10px;
  margin-bottom:10px;
  border:1px solid var(--border);
  position:sticky;
  top:var(--top-h);
  z-index:93;
}
.profit-tabs button{flex:1;padding:9px 6px;border:none;background:transparent;font-family:inherit;font-size:.82rem;font-weight:700;color:var(--muted);border-radius:8px;cursor:pointer}
.profit-tabs button.active{background:var(--primary);color:#fff}
.profit-controls{
  position:sticky;
  top:var(--top-h);
  z-index:94;
  padding:12px;
  border:1px solid rgba(20,184,166,.22);
  background:var(--card);
  margin:0 0 12px;
  border-radius:var(--radius);
}

/* ============================================================
   TABS
   ============================================================ */
.tabs{display:flex;gap:4px;background:var(--card);border-radius:8px;padding:4px}
.tabs button{flex:1;padding:8px 4px;border:none;background:transparent;border-radius:6px;font-weight:500;color:var(--muted);font-family:inherit;font-size:.8rem;white-space:nowrap}
.tabs button.active{background:var(--primary);color:#fff}

/* ============================================================
   SEARCH BAR
   ============================================================ */
.search-bar{display:flex;gap:8px;align-items:center}
.search-bar select{width:auto;min-width:110px;flex-shrink:0}
.search-input-wrap{position:relative;flex:1;display:flex}
.search-input-wrap input{padding-left:38px}
.search-clear{position:absolute;left:6px;top:50%;transform:translateY(-50%);background:transparent;border:none;color:var(--muted);font-size:1.05rem;padding:4px 10px;cursor:pointer;display:none;line-height:1}
.search-input-wrap.has-text .search-clear{display:block}
.toolbar-count{font-size:.72rem;color:var(--muted);padding:6px 2px 0;text-align:right;font-weight:600}
.date-quick{display:flex;gap:4px;flex-wrap:wrap;margin-top:6px}
.date-quick button{padding:5px 10px;border:1px solid var(--border);background:var(--card);color:var(--text);border-radius:8px;font-family:inherit;font-size:.75rem;cursor:pointer;font-weight:500}
.date-quick button.active{background:var(--primary);color:#fff;border-color:var(--primary)}
.driver-filters{display:flex;gap:6px;align-items:center;flex-wrap:wrap;margin-top:8px}
.driver-filters select,.driver-filters button{width:auto;padding:6px 10px;font-size:.82rem}

/* ============================================================
   CARD & core components
   ============================================================ */
.card{background:var(--card);border-radius:var(--radius);padding:14px;margin-bottom:10px;box-shadow:0 1px 3px rgba(0,0,0,.06)}
.card-title{font-weight:600;margin-bottom:6px}
.card-sub{color:var(--muted);font-size:.85rem}
.empty{text-align:center;padding:40px 20px;color:var(--muted)}
.empty .emoji{font-size:3rem;display:block;margin-bottom:10px}
.fab{position:fixed;bottom:90px;left:16px;width:56px;height:56px;border-radius:50%;background:var(--primary);color:#fff;border:none;font-size:1.8rem;box-shadow:0 4px 12px rgba(30,64,175,.4);z-index:150}

/* ============================================================
   CUSTOMER ROW
   ============================================================ */
.customer-row{position:relative;display:flex;background:var(--card);border-radius:var(--radius);margin-bottom:10px;box-shadow:0 1px 3px rgba(0,0,0,.06);overflow:hidden;border-right:4px solid var(--primary)}
.customer-row .cr-info{flex:1;min-width:0;padding:12px 14px;cursor:pointer;display:flex;flex-direction:column;justify-content:center;gap:3px}
.customer-row .cr-shop{font-weight:600;font-size:.98rem;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.customer-row .cr-sub{color:var(--muted);font-size:.8rem;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.customer-row .cr-days{color:var(--muted);font-size:.72rem;margin-top:2px}
.cr-days.warn{color:var(--warning)}
.cr-days.fresh{color:var(--success)}
.cr-days.none{color:var(--danger)}
.customer-row .cr-actions{display:flex;flex-shrink:0}
.customer-row .cr-btn{display:flex;flex-direction:column;align-items:center;justify-content:center;gap:4px;padding:0 14px;border:none;font-size:.7rem;font-weight:600;color:#fff;cursor:pointer;min-width:72px;line-height:1.1}
.customer-row .cr-btn .ic{font-size:1.5rem}
.cr-btn.cr-invoice{background:var(--primary)}
.cr-btn.cr-menu{background:#64748b;min-width:54px}

/* ============================================================
   MODAL
   ============================================================ */
.modal-overlay{position:fixed;inset:0;background:rgba(0,0,0,.5);display:flex;align-items:flex-end;z-index:300}
.modal-overlay.center{align-items:center;justify-content:center;padding:16px}
.modal-overlay.wide .modal{max-width:840px}
.modal-overlay.fullscreen{padding:0;align-items:stretch}
.modal-overlay.fullscreen .modal{max-width:100%;width:100%;height:100vh;max-height:100vh;border-radius:0;display:flex;flex-direction:column;padding:0}
.modal{background:var(--card);width:100%;max-width:520px;border-radius:16px 16px 0 0;max-height:92vh;overflow-y:auto;padding:16px;color:var(--text)}
.modal-overlay.center .modal{border-radius:16px}
.modal-title{font-size:1.05rem;font-weight:600;margin-bottom:12px}
.form-group{margin-bottom:12px}
.form-group label{display:block;margin-bottom:4px;font-size:.88rem;color:var(--muted)}
.form-actions{display:flex;gap:8px;margin-top:16px}

/* ============================================================
   STATS
   ============================================================ */
.stats-grid{display:grid;grid-template-columns:1fr 1fr;gap:10px}
.stat-box{background:var(--card);border-radius:var(--radius);padding:14px;text-align:center;box-shadow:0 1px 3px rgba(0,0,0,.06)}
.stat-box .val{font-size:1.35rem;font-weight:700;color:var(--primary);word-break:break-word}
.stat-box .lbl{color:var(--muted);font-size:.8rem;margin-top:4px}

/* ============================================================
   PRODUCT GRID
   ============================================================ */
.product-grid{display:grid;grid-template-columns:repeat(2,1fr);gap:10px}
.product-card{background:var(--card);border-radius:var(--radius);overflow:hidden;box-shadow:0 1px 3px rgba(0,0,0,.06)}
.product-card img{width:100%;height:100px;object-fit:cover;background:#f1f5f9;display:block}
.product-card .info{padding:10px}
.product-card .info h4{margin:0 0 4px;font-size:.95rem}
.product-card .info .price{color:var(--success);font-weight:600;font-size:.9rem;margin:4px 0}

/* ============================================================
   INVOICE ITEM ROW
   ============================================================ */
.invoice-item{display:flex;gap:6px;align-items:center;padding:8px;background:rgba(0,0,0,.03);border-radius:8px;margin-bottom:8px;flex-wrap:wrap}
.invoice-item .name{flex:1;font-size:.9rem;min-width:120px}
.invoice-item .qty{width:56px;padding:6px 4px;text-align:center}
.invoice-item .price-input{width:100px;padding:6px 6px;text-align:center;font-weight:600;color:var(--primary)}
.invoice-item .line-total{min-width:80px;text-align:left;font-size:.82rem;font-weight:600}
.invoice-item .item-disc-row{width:100%;display:flex;gap:6px;margin-top:4px;padding-top:4px;border-top:1px dashed var(--border);align-items:center}
.invoice-item .item-disc-row input{flex:1;padding:5px 8px;font-size:.82rem}

/* ============================================================
   v0.7 — price version selector
   ============================================================ */
.price-version-select{
  width:100%;
  padding:4px 6px;
  font-size:.75rem;
  border:1px solid var(--border);
  border-radius:6px;
  background:var(--card);
  color:var(--text);
  font-family:inherit;
  cursor:pointer;
  margin-top:4px;
}
.price-version-select:focus{outline:none;border-color:var(--primary);box-shadow:0 0 0 2px rgba(59,130,246,.15)}
.price-version-select option{padding:4px}

/* ============================================================
   TOAST
   ============================================================ */
.toast{position:fixed;bottom:100px;left:50%;transform:translateX(-50%);background:#0f172a;color:#fff;padding:10px 20px;border-radius:8px;z-index:500;font-size:.9rem;box-shadow:0 4px 12px rgba(0,0,0,.2);max-width:90vw;text-align:center}

/* ============================================================
   BADGES
   ============================================================ */
.badge{display:inline-block;padding:2px 8px;border-radius:999px;font-size:.72rem;font-weight:500}
.badge-pending{background:#fef3c7;color:#92400e}
.badge-delivered{background:#dbeafe;color:#1e40af}
.badge-paid{background:#dcfce7;color:#166534}
.badge-returned{background:#fee2e2;color:#991b1b}

/* ============================================================
   BOTTOM NAV
   ============================================================ */
.bottom-nav{position:fixed;bottom:0;left:0;right:0;background:var(--card);border-top:1px solid var(--border);display:flex;z-index:200;padding-bottom:env(safe-area-inset-bottom);overflow-x:auto}
.bottom-nav a{flex:1;min-width:50px;padding:6px 2px;text-align:center;color:var(--muted);text-decoration:none;font-size:.62rem;display:flex;flex-direction:column;align-items:center;gap:2px;white-space:nowrap}
.bottom-nav a.active{color:var(--primary)}
.bottom-nav a .icon{font-size:1.15rem}

/* ============================================================
   INVOICE PRINT
   ============================================================ */
.invoice-print{background:#fff;padding:20px;color:#000;border-radius:8px}
.invoice-header{display:flex;justify-content:space-between;align-items:center;border-bottom:3px solid #1e40af;padding-bottom:12px;margin-bottom:14px;gap:10px;flex-wrap:wrap}
.invoice-logo{width:52px;height:52px;background:#1e40af;color:#fff;border-radius:10px;display:flex;align-items:center;justify-content:center;font-size:1.6rem;flex-shrink:0}
.invoice-title{font-size:1.15rem;font-weight:700;color:#1e40af;margin:0}
.invoice-meta{font-size:.78rem;color:#64748b;margin-top:2px}
.invoice-parties{display:grid;grid-template-columns:1fr 1fr;gap:10px;margin-bottom:12px}
.invoice-party{border:1px solid #cbd5e1;border-radius:8px;padding:10px;background:#f8fafc}
.invoice-party .lbl{font-size:.72rem;color:#64748b;margin-bottom:6px;font-weight:700}
.invoice-party .line{font-size:.85rem;margin-bottom:3px;line-height:1.5}
.invoice-print table{width:100%;border-collapse:collapse;margin:12px 0}
.invoice-print th,.invoice-print td{border:1px solid #cbd5e1;padding:7px 8px;text-align:center;font-size:.82rem}
.invoice-print th{background:#e0e7ff;color:#1e3a8a;font-weight:700}
.invoice-print td.r{text-align:right}
.invoice-print .pcode{font-weight:700;color:#1e40af;font-size:.75rem}
.invoice-totals{margin-top:12px;margin-inline-start:auto;width:100%;max-width:340px}
.invoice-totals .row{display:flex;justify-content:space-between;padding:6px 10px;font-size:.85rem;border-bottom:1px dashed #e2e8f0}
.invoice-totals .row.grand{background:#eff6ff;border:1px solid #bfdbfe;border-radius:6px;margin-top:6px;font-weight:700;color:#1e40af;font-size:.95rem;padding:8px 10px}
.invoice-payments{margin-top:14px;padding:10px;background:#f0f9ff;border:1px solid #bae6fd;border-radius:8px}
.invoice-payments .pay-title{font-weight:700;color:#0369a1;margin-bottom:8px;font-size:.9rem}
.invoice-payments table{margin:0}
.invoice-payments th{background:#bae6fd;color:#075985}
.invoice-footer{margin-top:18px;padding-top:10px;border-top:1px solid #e2e8f0;display:flex;justify-content:space-between;font-size:.72rem;color:#64748b;flex-wrap:wrap;gap:8px}
.signature-area{display:grid;grid-template-columns:1fr 1fr;gap:20px;margin-top:24px;font-size:.8rem;color:#64748b}
.signature-box{text-align:center}
.signature-box .line{border-top:1px solid #94a3b8;margin-top:36px;padding-top:4px}
.invoice-table-wrap{width:100%;overflow:hidden;border:1px solid #cbd5e1;border-radius:8px;margin:12px 0}
.invoice-print .invoice-table{table-layout:fixed;width:100%;margin:0;border-collapse:collapse}
.invoice-table .inv-col-row{width:6%}
.invoice-table .inv-col-code{width:9%}
.invoice-table .inv-col-product{width:auto}
.invoice-table .inv-col-unit{width:8%}
.invoice-table .inv-col-qty{width:8%}
.invoice-table .inv-col-price{width:17%}
.invoice-table .inv-col-discount{width:12%}
.invoice-table .inv-col-total{width:18%}
.invoice-table th,.invoice-table td{overflow-wrap:anywhere;word-break:break-word}
.invoice-mobile-meta{display:none}

/* ============================================================
   PRODUCT PICKER
   ============================================================ */
.product-pick-row{display:flex;align-items:center;justify-content:space-between;padding:10px 8px;border-bottom:1px solid var(--border);gap:8px}
.product-pick-row .pp-info{flex:1;min-width:0}
.product-pick-row .pp-name{font-weight:500;font-size:.92rem}
.product-pick-row .pp-meta{color:var(--muted);font-size:.75rem;margin-top:2px}
.product-pick-row .pp-controls{display:flex;align-items:center;gap:6px;flex-shrink:0}
.product-pick-row .pp-btn{width:34px;height:34px;border-radius:50%;border:none;background:var(--primary);color:#fff;font-size:1.2rem;font-weight:600;display:flex;align-items:center;justify-content:center;line-height:1;padding:0}
.product-pick-row .pp-minus{background:#94a3b8}
.product-pick-row .pp-qty{width:56px;text-align:center;padding:6px 4px;font-weight:700;font-size:.95rem}
.product-pick-row.pp-selected{background:rgba(59,130,246,.1)}
.pp-header{padding:12px;border-bottom:1px solid var(--border);background:var(--card);display:flex;gap:8px;align-items:center;flex-shrink:0;flex-wrap:wrap}
.pp-body{flex:1;overflow-y:auto;padding:0 12px}
.pp-footer{padding:12px;border-top:1px solid var(--border);background:var(--card);display:flex;gap:8px;flex-shrink:0}
.pp-title{font-weight:600;font-size:1rem;margin-bottom:8px;padding:12px 12px 0}
.pp-header .search-input-wrap{flex:1;min-width:180px}
.pp-header select{width:auto;max-width:130px;padding:8px;font-size:.75rem}
.pp-price-mode{width:100%;margin-top:5px;padding:5px 7px;font-size:.72rem;border:1px solid var(--border);border-radius:6px;background:var(--card);color:var(--text)}

/* ============================================================
   SETTINGS
   ============================================================ */
.settings-section{background:var(--card);border-radius:12px;margin-bottom:10px;border:1px solid var(--border);overflow:hidden}
.settings-section-header{padding:14px;display:flex;justify-content:space-between;align-items:center;cursor:pointer;font-weight:700;font-size:.95rem;user-select:none}
.settings-section-header .ss-icon{width:34px;height:34px;border-radius:10px;background:rgba(30,64,175,.1);color:var(--primary);display:flex;align-items:center;justify-content:center;font-size:1.1rem;margin-inline-end:10px;flex-shrink:0}
.settings-section-header .ss-arrow{transition:transform .3s;color:var(--muted)}
.settings-section.open .settings-section-header .ss-arrow{transform:rotate(180deg)}
.settings-section-body{max-height:0;overflow:hidden;transition:max-height .35s ease}
.settings-section.open .settings-section-body{max-height:2500px;padding:0 14px 14px}
.settings-item{display:flex;justify-content:space-between;align-items:center;padding:12px 0;border-bottom:1px solid var(--border);gap:8px}
.settings-item:last-child{border-bottom:none}
.settings-item .si-label{font-size:.92rem}
.settings-item .si-sub{color:var(--muted);font-size:.75rem;margin-top:2px}
.file-input-wrap{position:relative;overflow:hidden;display:inline-block;width:100%}
.file-input-wrap input[type=file]{position:absolute;left:0;top:0;opacity:0;width:100%;height:100%;cursor:pointer}
.backup-opt{display:flex;align-items:center;gap:8px;padding:8px 10px;background:rgba(0,0,0,.03);border-radius:8px;cursor:pointer;font-size:.9rem}
.backup-opt input[type=checkbox]{width:auto;margin:0;padding:0;transform:scale(1.3);accent-color:var(--primary)}

/* ============================================================
   v0.7 — settings code tags (template variables)
   ============================================================ */
.settings-section-body code{
  background:rgba(59,130,246,.08);
  color:var(--primary);
  padding:1px 4px;
  border-radius:4px;
  font-size:.7rem;
  font-family:ui-monospace,SFMono-Regular,Consolas,monospace;
  direction:ltr;
  display:inline-block;
  margin:1px 0;
}

/* ============================================================
   JALALI PICKER
   ============================================================ */
.jalali-picker{display:flex;gap:5px;direction:rtl;align-items:stretch}
.jalali-picker select{flex:1;padding:9px 6px;text-align:center;font-size:.92rem;appearance:none;-webkit-appearance:none;background:var(--card) url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'><path fill='%2364748b' d='M2 4l4 4 4-4z'/></svg>") no-repeat left 8px center;padding-left:26px;font-family:inherit}
.range-quick-wrap{display:flex;gap:6px;flex-wrap:wrap;margin-top:10px}

/* ============================================================
   PRICE BLOCKS (قدیم / جدید در فرم محصول)
   ============================================================ */
.price-block{border:1px solid var(--border);border-radius:10px;padding:10px 12px;margin-top:8px;background:rgba(0,0,0,.02)}
.price-block.old{border-color:#fed7aa;background:#fff7ed}
.price-block.new{border-color:#bbf7d0;background:#f0fdf4}
.price-block .pb-head{display:flex;justify-content:space-between;align-items:center;font-weight:700;font-size:.82rem;margin-bottom:6px}
.price-block.old .pb-head{color:#b45309}
.price-block.new .pb-head{color:#166534}

/* ============================================================
   VIEW SWITCH (قدیم / جدید)
   ============================================================ */
.view-switch{display:inline-grid;grid-template-columns:1fr 1fr;gap:4px;padding:3px;background:var(--bg);border:1px solid var(--border);border-radius:10px;width:100%;margin-bottom:8px}
.view-switch button{padding:7px 10px;border:none;background:transparent;font-family:inherit;font-size:.78rem;font-weight:700;color:var(--muted);border-radius:8px;cursor:pointer}
.view-switch button.active{background:var(--primary);color:#fff;box-shadow:0 1px 3px rgba(30,64,175,.35)}
.view-switch.old-active button.active{background:#b45309}
.view-switch.new-active button.active{background:#166534}

/* ============================================================
   PROFIT LISTS
   ============================================================ */
.profit-list-item{background:var(--card);border-radius:10px;padding:12px;margin-bottom:8px;border:1px solid var(--border);cursor:pointer;transition:border-color .15s}
.profit-list-item:hover{border-color:var(--primary)}
.profit-list-item .pli-top{display:flex;justify-content:space-between;align-items:center;gap:8px;flex-wrap:wrap}
.profit-list-item .pli-shop{font-weight:700;font-size:.92rem}
.profit-list-item .pli-meta{font-size:.72rem;color:var(--muted);margin-top:2px}
.profit-list-item .pli-profit{font-weight:800;color:#166534;font-size:.95rem}
.profit-list-item.negative .pli-profit{color:#dc2626}
.profit-list-item .pli-expand{max-height:0;overflow:hidden;transition:max-height .25s ease}
.profit-list-item.open .pli-expand{max-height:800px;margin-top:10px;padding-top:10px;border-top:1px dashed var(--border)}
.profit-items-table{width:100%;border-collapse:collapse;font-size:.75rem}
.profit-items-table th,.profit-items-table td{padding:5px 6px;border-bottom:1px solid var(--border);text-align:center}
.profit-items-table th{background:rgba(30,64,175,.06);color:#1e3a8a;font-weight:700}
.profit-items-table td.r{text-align:right}
.profit-summary-strip{display:grid;grid-template-columns:repeat(3,1fr);gap:6px;margin-top:10px}
.profit-summary-strip .ps-box{padding:6px 4px;border-radius:8px;text-align:center;background:rgba(30,64,175,.06)}
.profit-summary-strip .ps-box .ps-v{font-size:.85rem;font-weight:700;color:#1e3a8a}
.profit-summary-strip .ps-box .ps-l{font-size:.65rem;color:var(--muted);margin-top:2px}

/* ============================================================
   PROFIT PANEL
   ============================================================ */
.profit-page{padding-bottom:96px}
.profit-intro{background:linear-gradient(135deg,#0f766e,#14b8a6);color:#fff;border-radius:16px;padding:16px;display:flex;align-items:center;gap:12px;margin-bottom:12px;box-shadow:0 10px 22px -16px #0f766e}
.profit-intro-icon{width:46px;height:46px;border-radius:14px;background:rgba(255,255,255,.2);display:flex;align-items:center;justify-content:center;font-size:1.8rem;font-weight:800;flex-shrink:0}
.profit-intro h2{margin:0 0 4px;font-size:1.05rem}
.profit-intro p{margin:0;font-size:.78rem;line-height:1.7;opacity:.94}
.profit-discount-controls{display:grid;grid-template-columns:1fr 1fr;gap:8px}
.profit-parser-hint{font-size:.76rem;line-height:1.7;background:#f0fdfa;color:#115e59;border-radius:8px;padding:8px;min-height:32px}
.profit-highlight{background:linear-gradient(135deg,#1e3a8a,#2563eb);color:#fff;border-radius:14px;padding:14px;display:grid;grid-template-columns:1fr 1fr;gap:10px;margin:12px 0;box-shadow:0 10px 20px -16px #1e40af}
.profit-highlight span{display:block;font-size:.72rem;opacity:.82}
.profit-highlight b{display:block;font-size:1rem;margin-top:3px;line-height:1.6}
.profit-highlight small{display:block;font-size:.68rem;opacity:.84;margin-top:3px}
.profit-highlight-value{text-align:left}
.profit-table-wrap{overflow-x:auto;border:1px solid var(--border);border-radius:12px;background:var(--card);box-shadow:0 1px 3px rgba(0,0,0,.06)}
.profit-table{width:100%;border-collapse:collapse;min-width:430px}
.profit-table th,.profit-table td{padding:10px 8px;border-bottom:1px solid var(--border);font-size:.78rem;text-align:center;white-space:nowrap}
.profit-table th{background:#eff6ff;color:#1e3a8a;font-size:.75rem}
.profit-table td:first-child{text-align:right;font-weight:650;white-space:normal}
.profit-table tr:last-child td{border-bottom:0}
.profit-discount-row{background:#fff7ed}
.profit-customer-row{background:#f0fdf4}
.profit-own-row{background:#eff6ff}
.profit-number{font-weight:700;color:#0f172a}
.profit-number.accent{color:#c2410c}
.profit-number.success{color:#15803d}
.profit-number.primary{color:#1d4ed8}
.profit-number.negative{color:#dc2626}
.profit-na{color:var(--muted);font-size:.72rem}
.profit-notes{font-size:.75rem;color:var(--muted);line-height:1.8;padding:10px 4px 0}
.profit-notes b{color:var(--text)}

/* ============================================================
   TEMPLATE PREVIEW & CARDS
   ============================================================ */
.tpl-preview{direction:rtl;white-space:pre-wrap;word-break:normal;margin:8px 0 0;background:#0f172a;color:#f8fafc;border-radius:10px;padding:12px;font-family:ui-monospace,SFMono-Regular,Consolas,monospace;font-size:.72rem;line-height:1.85;text-align:right;max-height:280px;overflow:auto}
.tpl-preview .tpl-blank{color:#475569}
.tpl-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(150px,1fr));gap:8px;margin-top:8px}
.tpl-card{border:2px solid var(--border);border-radius:10px;padding:10px;cursor:pointer;background:var(--card);transition:border-color .15s}
.tpl-card:hover{border-color:var(--primary)}
.tpl-card.active{border-color:var(--primary);background:rgba(59,130,246,.08)}
.tpl-card .tpl-name{font-weight:700;font-size:.85rem;color:var(--text)}
.tpl-card .tpl-desc{font-size:.7rem;color:var(--muted);margin-top:3px;line-height:1.4}
.thermal-text-preview{direction:rtl;white-space:pre-wrap;overflow:auto;max-height:55vh;word-break:normal;margin:0;background:#0f172a;color:#f8fafc;border-radius:10px;padding:12px;font-family:ui-monospace,SFMono-Regular,Consolas,monospace;font-size:.74rem;line-height:1.8;text-align:right}

/* ============================================================
   STATUS BAR
   ============================================================ */
.status-bar{background:var(--card);border-bottom:1px solid var(--border);padding:0 10px;display:flex;gap:6px;align-items:center;font-size:.72rem;color:var(--muted);height:var(--sb-h);overflow-x:auto;flex-wrap:nowrap;scrollbar-width:none}
.status-bar::-webkit-scrollbar{display:none}
.status-bar .sb-item{padding:3px 8px;border-radius:6px;background:rgba(0,0,0,.05);white-space:nowrap;font-weight:500;flex-shrink:0}
.status-bar .sb-online{background:#dcfce7;color:#166534}
.status-bar .sb-offline{background:#fee2e2;color:#991b1b}
.status-bar .sb-syncing{background:#fef3c7;color:#92400e}
.status-bar .sb-btn{padding:4px 8px;border-radius:6px;border:1px solid var(--border);background:var(--card);color:var(--text);cursor:pointer;font-family:inherit;font-size:.72rem;font-weight:500;flex-shrink:0}
.status-bar .sb-btn:first-of-type{margin-inline-start:auto}
[data-theme="dark"] .status-bar{background:#1e293b;border-color:#334155}
[data-theme="dark"] .status-bar .sb-item{background:rgba(255,255,255,.08)}
[data-theme="dark"] .status-bar .sb-btn{background:#0f172a;border-color:#334155;color:#f1f5f9}

/* ============================================================
   ACTION SHEET
   ============================================================ */
.action-sheet{position:fixed;inset:0;background:rgba(0,0,0,.5);z-index:400;display:flex;align-items:flex-end}
.action-sheet .sheet{background:var(--card);width:100%;border-radius:16px 16px 0 0;padding:16px;max-height:80vh;overflow-y:auto;color:var(--text)}
.action-sheet .sheet-header{display:flex;justify-content:space-between;align-items:center;padding-bottom:12px;border-bottom:1px solid var(--border);margin-bottom:12px}
.action-sheet .sheet-title{font-weight:600;font-size:1rem}
.action-grid{display:grid;grid-template-columns:repeat(3,1fr);gap:10px}
.action-item{display:flex;flex-direction:column;align-items:center;justify-content:center;gap:6px;padding:14px 6px;border-radius:12px;background:rgba(0,0,0,.03);border:none;color:var(--text);cursor:pointer;font-size:.78rem;font-weight:500;font-family:inherit}
.action-item .ic{font-size:1.6rem;line-height:1}

/* ============================================================
   STATEMENT
   ============================================================ */
.stmt-wrap{overflow-x:auto;border-radius:8px;border:1px solid #cbd5e1}
.stmt-table{width:100%;border-collapse:collapse;font-size:.82rem;direction:rtl;background:#fff;color:#000}
.stmt-table th,.stmt-table td{border:1px solid #cbd5e1;padding:7px 6px;text-align:center;white-space:nowrap}
.stmt-table th{background:#1e40af;color:#fff;font-weight:600;font-size:.78rem}
.stmt-table tbody tr:nth-child(even){background:#f8fafc}
.stmt-table td.debit{color:#dc2626;font-weight:600}
.stmt-table td.credit{color:#16a34a;font-weight:600}
.stmt-table td.balance{font-weight:700;background:#f1f5f9}
.stmt-table td.desc{text-align:right;padding-right:10px;white-space:normal;min-width:180px;max-width:280px}
.stmt-table tr.final-row{background:#dbeafe;font-weight:700}
.stmt-table tr.final-row td{font-size:.88rem;border-top:2px solid #1e40af}
.stmt-summary{display:grid;grid-template-columns:repeat(3,1fr);gap:8px;margin:12px 0}
.stmt-summary .box{padding:10px;border-radius:8px;text-align:center;color:#fff}
.stmt-summary .box .v{font-size:1.1rem;font-weight:700}
.stmt-summary .box .l{font-size:.72rem;opacity:.9;margin-top:2px}

/* ============================================================
   DISCOUNT CONTROLS
   ============================================================ */
.discount-grid{display:grid;grid-template-columns:1fr 1fr;gap:8px}
.discount-grid .lbl{text-align:center;font-size:.72rem;color:var(--muted);margin-top:2px}
.disc-mode-toggle{display:grid;grid-template-columns:1fr 1fr 1fr;gap:6px;margin-bottom:10px}
.disc-mode-toggle button{padding:8px 4px;border:2px solid var(--border);background:var(--card);border-radius:8px;font-family:inherit;font-size:.78rem;font-weight:600;color:var(--muted);cursor:pointer}
.disc-mode-toggle button.active{border-color:var(--primary);background:rgba(59,130,246,.1);color:var(--primary)}

/* ============================================================
   RETURN ACCORDION
   ============================================================ */
.return-accordion{background:var(--card);border-radius:var(--radius);margin-bottom:10px;overflow:hidden;box-shadow:0 1px 3px rgba(0,0,0,.06)}
.return-accordion .ra-header{padding:14px;display:flex;justify-content:space-between;align-items:center;cursor:pointer;font-weight:600}
.return-accordion .ra-body{max-height:0;overflow:hidden;transition:max-height .3s ease;padding:0 14px}
.return-accordion.open .ra-body{max-height:2000px;padding:0 14px 14px}
.return-accordion .ra-header .arrow{transition:transform .3s}
.return-accordion.open .ra-header .arrow{transform:rotate(180deg)}

/* ============================================================
   PAYMENT ROW
   ============================================================ */
.mp-row{display:flex;gap:6px;align-items:center;padding:8px;background:rgba(0,0,0,.03);border-radius:8px;margin-bottom:6px;flex-direction:column;align-items:stretch}
.mp-row .mp-inner{display:flex;gap:6px;align-items:center;width:100%}
.mp-row select{flex:1;padding:6px 8px;font-size:.85rem}
.mp-row input[type=number]{width:130px;padding:6px 8px;font-size:.85rem;text-align:center}
.mp-row input[type=text]{flex:1;padding:6px 8px;font-size:.82rem;margin-top:4px}
.mp-remaining{background:linear-gradient(135deg,var(--primary),var(--primary-dark));color:#fff;padding:12px;border-radius:10px;text-align:center;margin:10px 0}
.mp-remaining .mpr-lbl{font-size:.78rem;opacity:.9}
.mp-remaining .mpr-val{font-size:1.4rem;font-weight:700;margin-top:4px}
.mp-remaining .mpr-sub{font-size:.78rem;opacity:.85;margin-top:4px}

/* ============================================================
   CODE TAG & PENDING DOT
   ============================================================ */
.code-tag{display:inline-block;background:rgba(59,130,246,.12);color:var(--primary);padding:2px 6px;border-radius:4px;font-size:.72rem;font-weight:700;margin:1px 2px 1px 0}
.pending-dot{display:inline-block;width:10px;height:10px;border-radius:50%;background:#16a34a;margin-inline-end:4px;vertical-align:middle}

/* ============================================================
   WAREHOUSE
   ============================================================ */
.warehouse-summary{display:grid;grid-template-columns:repeat(2,1fr);gap:8px;margin-bottom:10px}
.warehouse-table{width:100%;border-collapse:collapse;font-size:.85rem}
.warehouse-table th,.warehouse-table td{border:1px solid var(--border);padding:8px;text-align:center}
.warehouse-table th{background:rgba(59,130,246,.1);color:var(--primary);font-weight:700}
.warehouse-table td.code{font-weight:700;color:var(--primary)}
.warehouse-table td.qty{font-weight:700;color:var(--success)}

/* ============================================================
   PAY METHOD BADGES
   ============================================================ */
.pay-method-badge{display:inline-flex;align-items:center;gap:4px;padding:3px 8px;border-radius:999px;font-size:.75rem;font-weight:600}
.pay-pos{background:#dbeafe;color:#1e40af}
.pay-cash{background:#dcfce7;color:#166534}
.pay-check{background:#fef3c7;color:#92400e}
.pay-credit{background:#fee2e2;color:#991b1b}

/* ============================================================
   PROFIT INVOICE TABLE (modal)
   ============================================================ */
.profit-invoice-table{max-height:60vh}
.profit-invoice-total{margin-top:10px;padding:10px;border-radius:8px;background:#eff6ff;color:#1e3a8a;text-align:left;font-size:.88rem}
.profit-invoice-total b{font-size:1rem}

/* ============================================================
   LOGIN
   ============================================================ */
.login-screen{position:fixed;inset:0;background:linear-gradient(135deg,var(--primary),var(--primary-dark));display:flex;align-items:center;justify-content:center;padding:24px;z-index:1000;direction:rtl}
.login-card{background:#fff;border-radius:20px;padding:32px 24px;width:100%;max-width:380px;box-shadow:0 20px 60px rgba(0,0,0,.3);text-align:center}
.login-logo{width:72px;height:72px;background:linear-gradient(135deg,var(--primary),var(--primary-light));border-radius:20px;display:flex;align-items:center;justify-content:center;font-size:2rem;margin:0 auto 16px;color:#fff}
.login-card h1{font-size:1.2rem;color:#0f172a;margin:0 0 6px}
.login-card p{color:#64748b;font-size:.85rem;margin:0 0 20px}
.login-card input{width:100%;padding:14px 16px;border:2px solid #e2e8f0;border-radius:12px;font-size:1rem;text-align:center;letter-spacing:4px;font-weight:600;color:#0f172a;background:#fff;font-family:inherit}
.login-card button{width:100%;padding:14px;border:none;border-radius:12px;background:linear-gradient(135deg,var(--primary),var(--primary-dark));color:#fff;font-size:1rem;font-weight:700;margin-top:12px;cursor:pointer;font-family:inherit}
.login-error{color:#dc2626;font-size:.82rem;margin-top:10px;min-height:18px}

/* ============================================================
   CUSTOM DATE MODE
   ============================================================ */
.cdate-mode{display:grid;grid-template-columns:1fr 1fr;gap:6px;margin-bottom:12px}
.cdate-mode button{padding:9px;border:2px solid var(--border);background:var(--card);border-radius:8px;font-family:inherit;font-size:.82rem;font-weight:600;color:var(--muted);cursor:pointer}
.cdate-mode button.active{border-color:var(--primary);background:rgba(59,130,246,.1);color:var(--primary)}

/* ============================================================
   MAP
   ============================================================ */
#map-fullscreen-wrap{position:fixed;inset:0;background:#e5e7eb;overflow:hidden;z-index:90}
#map{width:100%;height:100%;z-index:1}
.map-search-overlay{
  position:absolute;
  top:8px;
  left:8px;
  right:8px;
  z-index:20;
  display:flex;
  flex-direction:column;
  gap:5px;
  padding-top:env(safe-area-inset-top);
  pointer-events:none;
}
.map-search-overlay>*{pointer-events:auto}
.map-search-box{
  background:rgba(255,255,255,.98);
  border-radius:11px;
  box-shadow:0 4px 14px rgba(0,0,0,.15);
  padding:2px;
  display:flex;
  position:relative;
  border:1px solid rgba(30,64,175,.1);
}
.map-search-box input{
  border:none !important;
  box-shadow:none !important;
  background:transparent !important;
  padding:10px 40px 10px 12px !important;
  border-radius:11px;
  color:#0f172a;
  font-size:.88rem;
  width:100%;
}
.map-search-box .search-clear{
  position:absolute;
  right:6px;
  left:auto;
  top:50%;
  transform:translateY(-50%);
  color:#64748b;
  font-size:1rem;
  padding:6px 10px;
}
.map-filter-bar{
  background:rgba(255,255,255,.97);
  border-radius:11px;
  box-shadow:0 4px 14px rgba(0,0,0,.14);
  padding:5px;
  display:grid;
  grid-template-columns:repeat(4, 1fr);
  gap:4px;
  border:1px solid rgba(30,64,175,.1);
  backdrop-filter:blur(12px);
}
.map-filter-bar button{
  padding:6px 4px;
  border:1px solid #e2e8f0;
  background:#fff;
  color:#0f172a;
  border-radius:8px;
  font-family:inherit;
  font-size:.7rem;
  font-weight:700;
  cursor:pointer;
  min-width:0;
  white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis;
  transition:transform .12s;
  line-height:1.4;
}
.map-filter-bar button:active{transform:scale(.95)}
.map-filter-bar button.smart{background:linear-gradient(135deg,#7c3aed,#4f46e5);color:#fff;border:none}
.map-filter-bar button.danger{background:#dc2626;color:#fff;border-color:#dc2626}
.map-filter-bar button.success{background:#16a34a;color:#fff;border-color:#16a34a}
.map-filter-bar .info-badge{
  grid-column:1/-1;
  font-size:.66rem;
  color:#64748b;
  text-align:center;
  padding:3px 0 1px;
  border-top:1px solid #eef2f7;
  margin-top:1px;
  white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis;
}
.map-filter-bar .map-live-dot{
  grid-column:1/-1;
  justify-content:center;
  margin:1px 0 0;
  padding:3px 6px;
  background:#f0fdf4;
  box-shadow:none;
  border:1px solid #bbf7d0;
  font-size:.64rem;
  border-radius:7px;
  display:flex;
  align-items:center;
  gap:6px;
  color:#16a34a;
  font-weight:600;
}
.map-live-dot .pulse{width:8px;height:8px;background:#16a34a;border-radius:50%;animation:pulse 1.5s infinite}
@keyframes pulse{0%{opacity:1;transform:scale(1)}50%{opacity:.5;transform:scale(1.3)}100%{opacity:1;transform:scale(1)}}
#map-controls{
  position:absolute;
  right:8px;
  top:calc(8px + env(safe-area-inset-top));
  z-index:26;
  display:flex;
  flex-direction:column;
  gap:5px;
  pointer-events:auto;
}
#map-controls button{
  width:38px;
  height:38px;
  border-radius:10px;
  background:rgba(255,255,255,.97);
  color:#0f172a;
  border:1px solid rgba(15,23,42,.08);
  box-shadow:0 3px 9px rgba(0,0,0,.15);
  font-size:1rem;
  font-weight:800;
  cursor:pointer;
  font-family:inherit;
  display:flex;
  align-items:center;
  justify-content:center;
  line-height:1;
  padding:0;
  transition:transform .12s;
}
#map-controls button:active{transform:scale(.94)}
#map-controls button.active{background:#1e40af;color:#fff;border-color:#1e40af}
.map-customer-marker{width:22px;height:22px;border-radius:50%;background:#1e40af;border:3px solid #fff;box-shadow:0 2px 7px rgba(15,23,42,.35)}
.map-customer-marker.pending{background:#16a34a}
.map-order-marker{
  width:32px;
  height:32px;
  border-radius:50%;
  display:flex;
  align-items:center;
  justify-content:center;
  background:linear-gradient(135deg,#f97316,#ea580c);
  color:#fff;
  border:3px solid #fff;
  box-shadow:0 4px 11px rgba(234,88,12,.55);
  font-family:Vazirmatn,sans-serif;
  font-size:.9rem;
  font-weight:900;
}
.map-route-info{
  position:absolute;
  bottom:calc(78px + env(safe-area-inset-bottom));
  left:8px;
  right:8px;
  z-index:22;
  background:#fff;
  border-radius:11px;
  box-shadow:0 6px 20px rgba(0,0,0,.2);
  padding:12px;
  display:none;
  color:#0f172a;
  max-height:45vh;
  overflow-y:auto;
  border:1px solid rgba(124,58,237,.18);
}
.map-route-info .mri-title{font-weight:700;font-size:.88rem;margin-bottom:6px;color:#4c1d95}
.map-route-info .mri-sub{font-size:.78rem;color:#64748b;margin-bottom:8px;line-height:1.6}
.map-route-info .mri-actions{display:flex;gap:6px;flex-wrap:wrap;margin-top:6px}
.map-route-info .mri-actions button{flex:1;padding:8px;border:none;border-radius:8px;font-family:inherit;font-size:.78rem;font-weight:600;cursor:pointer;min-height:36px}
.map-search-results{background:#fff;border-radius:11px;box-shadow:0 6px 20px rgba(0,0,0,.18);max-height:50vh;overflow-y:auto;display:none;color:#0f172a}
.map-search-results .msr-item{padding:10px 14px;border-bottom:1px solid #e2e8f0;cursor:pointer;font-size:.85rem}
.map-search-results .msr-name{font-weight:700;color:#0f172a}
.map-search-results .msr-sub{color:#64748b;font-size:.75rem;margin-top:2px}
.map-search-results .msr-empty{padding:16px;text-align:center;color:#64748b;font-size:.85rem}
.route-manager{max-height:48vh;overflow-y:auto;padding:2px 0}
.route-item{display:flex;justify-content:space-between;align-items:center;gap:8px;padding:9px 10px;border:1px solid var(--border);border-radius:9px;margin-bottom:5px;background:var(--card)}
.route-item.active{border-color:#7c3aed;background:rgba(124,58,237,.06)}
.route-item .ri-info{flex:1;min-width:0}
.route-item .ri-name{font-weight:700;font-size:.85rem;color:var(--text)}
.route-item .ri-meta{font-size:.68rem;color:var(--muted);margin-top:1px}
.route-item .ri-actions{display:flex;gap:3px;flex-shrink:0}
.route-item .ri-actions button{width:30px;height:30px;padding:0;border-radius:7px;font-size:.85rem;border:none;cursor:pointer;font-family:inherit}
#loc-picker-map{width:100%;height:55vh;border-radius:8px;overflow:hidden}

/* ============================================================
   DARK THEME OVERRIDES
   ============================================================ */
[data-theme="dark"] .persistent-toolbar,[data-theme="dark"] .driver-controls-sticky,[data-theme="dark"] .sticky-toolbar{background:#0f172a;border-color:#334155}
[data-theme="dark"] .profit-controls{background:var(--card)}
[data-theme="dark"] .profit-parser-hint{background:#134e4a;color:#ccfbf1}
[data-theme="dark"] .profit-table th{background:#172554;color:#dbeafe}
[data-theme="dark"] .profit-discount-row{background:#431407}
[data-theme="dark"] .profit-customer-row{background:#052e16}
[data-theme="dark"] .profit-own-row{background:#172554}
[data-theme="dark"] .profit-number{color:#f8fafc}
[data-theme="dark"] .profit-tabs{background:#1e293b;border-color:#334155}
[data-theme="dark"] .profit-controls{background:#1e293b;border-color:#334155}
[data-theme="dark"] .settings-section-body code{background:rgba(96,165,250,.15);color:#93c5fd}
[data-theme="dark"] .price-version-select{background:#0f172a;color:#f1f5f9;border-color:#334155}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width:520px){
  .invoice-print{padding:12px;border-radius:6px}
  .invoice-header{padding-bottom:8px;margin-bottom:9px;border-width:2px}
  .invoice-logo{width:38px;height:38px;border-radius:9px;font-size:1.2rem}
  .invoice-title{font-size:.98rem}
  .invoice-parties{grid-template-columns:1fr;gap:6px;margin-bottom:8px}
  .invoice-party{padding:7px}
  .invoice-party .line{font-size:.76rem}
  .invoice-table .inv-col-code,.invoice-table .inv-col-unit,.invoice-table .inv-col-discount{display:none}
  .invoice-table .inv-col-row{width:8%}
  .invoice-table .inv-col-product{width:39%}
  .invoice-table .inv-col-qty{width:13%}
  .invoice-table .inv-col-price{width:19%}
  .invoice-table .inv-col-total{width:21%}
  .invoice-print th,.invoice-print td{padding:5px 3px;font-size:.65rem;line-height:1.45}
  .invoice-print td.r{text-align:right}
  .invoice-mobile-meta{display:block;color:#64748b;font-size:.6rem;font-weight:400;margin-top:2px}
  .invoice-totals{max-width:100%;margin-top:9px}
  .invoice-totals .row{font-size:.75rem;padding:5px 6px}
  .invoice-totals .row.grand{font-size:.82rem}
  .invoice-payments{padding:7px;margin-top:8px}
  .signature-area{display:none}
  .invoice-footer{font-size:.62rem;margin-top:10px;padding-top:7px}
  .profit-highlight{grid-template-columns:1fr}
  .profit-highlight-value{text-align:right}
  .map-search-overlay #map-controls{position:absolute}
}

/* ============================================================
   THERMAL EXPORT
   ============================================================ */
.thermal-invoice{padding:12px!important;font-size:.78rem}
.thermal-invoice .invoice-logo,.thermal-invoice .signature-area{display:none}
.thermal-invoice .invoice-header{border-width:2px;padding-bottom:7px;margin-bottom:7px}
.thermal-invoice .invoice-parties{gap:6px;margin-bottom:8px}
.thermal-invoice .invoice-party{padding:7px}
.thermal-invoice .invoice-party .line{font-size:.72rem}
.thermal-invoice .inv-col-code,.thermal-invoice .inv-col-unit,.thermal-invoice .inv-col-discount{display:none}
.thermal-invoice .invoice-mobile-meta{display:block;color:#64748b;font-size:.65rem;font-weight:400;margin-top:2px}
.thermal-invoice .invoice-table .inv-col-row{width:8%}
.thermal-invoice .invoice-table .inv-col-product{width:39%}
.thermal-invoice .invoice-table .inv-col-qty{width:13%}
.thermal-invoice .invoice-table .inv-col-price{width:19%}
.thermal-invoice .invoice-table .inv-col-total{width:21%}
.thermal-invoice .invoice-print th,.thermal-invoice .invoice-print td,.thermal-invoice th,.thermal-invoice td{padding:5px 3px;font-size:.68rem;line-height:1.45;word-break:break-word}
.thermal-invoice .invoice-totals{max-width:100%;margin-top:8px}
.thermal-invoice .invoice-totals .row{font-size:.75rem;padding:5px 6px}
.thermal-invoice .invoice-footer{font-size:.62rem;margin-top:10px;padding-top:7px}

#invoice-print-area.export-invoice{background:#fff!important;color:#000!important;padding:24px!important;font-family:'Vazirmatn',sans-serif}
#invoice-print-area.export-invoice .invoice-table th,
#invoice-print-area.export-invoice .invoice-table td{padding:9px 8px;font-size:.82rem;line-height:1.5;word-break:break-word;white-space:normal}
#invoice-print-area.export-invoice .invoice-table .inv-col-product{min-width:180px;max-width:280px}
#invoice-print-area.export-invoice .invoice-table-wrap{max-height:none!important;overflow:visible!important;border:1px solid #cbd5e1}
#invoice-print-area.export-invoice .invoice-table{width:100%!important;min-width:0!important;table-layout:fixed!important}
#invoice-print-area.export-invoice .invoice-table .inv-col-code,
#invoice-print-area.export-invoice .invoice-table .inv-col-unit,
#invoice-print-area.export-invoice .invoice-table .inv-col-discount{display:table-cell!important}
#invoice-print-area.export-invoice .invoice-table thead th{position:static!important}

/* Litora 0.9.9 map stability: stable backing surface during Android resize/orientation. */
#map-fullscreen-wrap, #map, #litora-persistent-map-wrap { background-color:#e5e7eb; }
#map { min-height:100%; touch-action:none; overscroll-behavior:contain; }
.leaflet-container { background:#e5e7eb; -webkit-tap-highlight-color:transparent; }
.leaflet-tile { will-change:auto !important; }
.pay-card{background:#cffafe;color:#0e7490}
