/* ═══════════════════════════════════════════════════════════
   مدفوعات — style.css  (clean rebuild)
   NO service worker, NO animation on page-load, NO inline style manipulation
   ═══════════════════════════════════════════════════════════ */

/* ── Google Fonts ── */
@import url('https://fonts.googleapis.com/css2?family=Cairo:wght@300;400;500;600;700;800&family=Inter:wght@300;400;500;600;700&display=swap');

/* ── CSS Variables ── */
:root {
  --primary:       #2563eb;
  --primary-dark:  #1d4ed8;
  --primary-light: #dbeafe;
  --success:       #10b981;
  --success-light: #d1fae5;
  --warning:       #f59e0b;
  --warning-light: #fef3c7;
  --danger:        #ef4444;
  --danger-light:  #fee2e2;
  --info:          #06b6d4;
  --info-light:    #cffafe;
  --gray-50:       #f8fafc;
  --gray-100:      #f1f5f9;
  --gray-200:      #e2e8f0;
  --gray-300:      #cbd5e1;
  --gray-400:      #94a3b8;
  --gray-500:      #64748b;
  --gray-600:      #475569;
  --gray-700:      #334155;
  --gray-800:      #1e293b;
  --gray-900:      #0f172a;
  --sidebar-w:     260px;
  --topbar-h:      60px;
  --radius:        10px;
  --radius-sm:     6px;
  --shadow-sm:     0 1px 3px rgba(0,0,0,.08);
  --shadow:        0 4px 12px rgba(0,0,0,.1);
  --shadow-lg:     0 10px 30px rgba(0,0,0,.15);
  --font-ar:       'Cairo', sans-serif;
  --font-en:       'Inter', sans-serif;
}

/* ── CRITICAL: Disable ALL transitions during page init ── */
html.no-trans *,
html.no-trans *::before,
html.no-trans *::after {
  transition: none !important;
  animation:  none !important;
}

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; }
body {
  font-family: var(--font-ar);
  background: var(--gray-50);
  color: var(--gray-800);
  line-height: 1.6;
  direction: rtl;
  text-align: right;
}
html[dir="ltr"] body {
  font-family: var(--font-en);
  direction: ltr;
  text-align: left;
}
a { color: inherit; text-decoration: none; }
ul, ol { list-style: none; }
img { max-width: 100%; }
button { cursor: pointer; font-family: inherit; }
input, select, textarea { font-family: inherit; }

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--gray-100); }
::-webkit-scrollbar-thumb { background: var(--gray-300); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--gray-400); }

/* ═══════════════════════════════════
   LAYOUT
   ═══════════════════════════════════ */
#appWrapper {
  display: flex;
  min-height: 100vh;
}

/* ── Sidebar ── */
#sidebar {
  position: fixed;
  top: 0; right: 0;
  width: var(--sidebar-w);
  height: 100vh;
  background: var(--gray-900);
  display: flex;
  flex-direction: column;
  z-index: 200;
  overflow-y: auto;
  overflow-x: hidden;
}
html[dir="ltr"] #sidebar { right: auto; left: 0; }

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 20px;
  border-bottom: 1px solid rgba(255,255,255,.08);
  flex-shrink: 0;
}
.sidebar-logo img {
  width: 40px; height: 40px;
  border-radius: 8px;
  object-fit: contain;
}
.sidebar-logo .logo-text {
  color: #fff;
  font-size: 1.2rem;
  font-weight: 700;
}
.sidebar-logo .logo-sub {
  color: var(--gray-400);
  font-size: .72rem;
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 20px;
  border-bottom: 1px solid rgba(255,255,255,.06);
  flex-shrink: 0;
}
.sidebar-user .avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--success));
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 700; font-size: .9rem;
  flex-shrink: 0;
}
.sidebar-user .uinfo { overflow: hidden; }
.sidebar-user .uname { color: #fff; font-size: .85rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user .urole { color: var(--gray-400); font-size: .72rem; }

#navList {
  flex: 1;
  padding: 10px 0;
  overflow-y: auto;
}
.nav-section {
  padding: 8px 20px 4px;
  font-size: .65rem;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--gray-500);
  font-weight: 600;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 20px;
  color: var(--gray-400);
  font-size: .87rem;
  font-weight: 500;
  cursor: pointer;
  border-right: 3px solid transparent;
}
html[dir="ltr"] .nav-item { border-right: none; border-left: 3px solid transparent; }
.nav-item i { width: 18px; text-align: center; font-size: .9rem; }
.nav-item:hover { background: rgba(255,255,255,.05); color: #fff; }
.nav-item.active {
  background: rgba(37,99,235,.18);
  color: #fff;
  border-right-color: var(--primary);
}
html[dir="ltr"] .nav-item.active { border-left-color: var(--primary); border-right-color: transparent; }

.sidebar-footer {
  padding: 14px 20px;
  border-top: 1px solid rgba(255,255,255,.06);
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.sidebar-footer .btn-lang {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 12px;
  background: rgba(255,255,255,.06);
  border: none;
  border-radius: var(--radius-sm);
  color: var(--gray-300);
  font-size: .8rem;
  width: 100%;
}
.sidebar-footer .btn-lang:hover { background: rgba(255,255,255,.1); color: #fff; }
.sidebar-footer .btn-logout {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 12px;
  background: rgba(239,68,68,.15);
  border: none;
  border-radius: var(--radius-sm);
  color: #fca5a5;
  font-size: .8rem;
  width: 100%;
}
.sidebar-footer .btn-logout:hover { background: rgba(239,68,68,.25); }

/* ── Topbar ── */
#topbar {
  position: fixed;
  top: 0; left: 0; right: var(--sidebar-w);
  height: var(--topbar-h);
  background: #fff;
  border-bottom: 1px solid var(--gray-200);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 24px;
  z-index: 100;
}
html[dir="ltr"] #topbar { left: var(--sidebar-w); right: 0; }

#topbar .page-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--gray-800);
}
#topbar .topbar-actions {
  display: flex; align-items: center; gap: 10px;
}
#menuToggle {
  display: none;
  background: none; border: none;
  font-size: 1.2rem;
  color: var(--gray-600);
  padding: 6px;
}

/* ── Main Content ── */
#mainContent {
  margin-right: var(--sidebar-w);
  margin-top: var(--topbar-h);
  flex: 1;
  min-height: calc(100vh - var(--topbar-h));
  padding: 24px;
  overflow-x: hidden;
}
html[dir="ltr"] #mainContent { margin-right: 0; margin-left: var(--sidebar-w); }

/* ── Sidebar Overlay (mobile) ── */
#sidebarOverlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 199;
}

/* ═══════════════════════════════════
   PAGES
   ═══════════════════════════════════ */
.page { display: none; }
.page.active { display: block; }

/* ═══════════════════════════════════
   COMPONENTS
   ═══════════════════════════════════ */

/* Cards */
.card {
  background: #fff;
  border-radius: var(--radius);
  border: 1px solid var(--gray-200);
  box-shadow: var(--shadow-sm);
}
.card-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--gray-100);
}
.card-header h3 { font-size: .95rem; font-weight: 700; color: var(--gray-800); }
.card-body { padding: 20px; }

/* Stat Cards */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.stat-card {
  background: #fff;
  border-radius: var(--radius);
  border: 1px solid var(--gray-200);
  padding: 18px 20px;
  display: flex; align-items: center; gap: 14px;
}
.stat-icon {
  width: 46px; height: 46px;
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.1rem;
  flex-shrink: 0;
}
.stat-icon.blue   { background: var(--primary-light); color: var(--primary); }
.stat-icon.green  { background: var(--success-light); color: var(--success); }
.stat-icon.orange { background: var(--warning-light); color: var(--warning); }
.stat-icon.red    { background: var(--danger-light);  color: var(--danger); }
.stat-icon.cyan   { background: var(--info-light);    color: var(--info); }
.stat-info .label { font-size: .75rem; color: var(--gray-500); font-weight: 500; }
.stat-info .value { font-size: 1.3rem; font-weight: 700; color: var(--gray-800); line-height: 1.2; }
.stat-info .sub   { font-size: .72rem; color: var(--gray-400); }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 9px 18px;
  border-radius: var(--radius-sm);
  border: none;
  font-size: .85rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  font-family: inherit;
}
.btn-sm { padding: 6px 13px; font-size: .8rem; }
.btn-xs { padding: 4px 9px; font-size: .75rem; }
.btn-lg { padding: 11px 24px; font-size: .95rem; }
.btn-primary  { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-success  { background: var(--success); color: #fff; }
.btn-success:hover { background: #059669; }
.btn-warning  { background: var(--warning); color: #fff; }
.btn-warning:hover { background: #d97706; }
.btn-danger   { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #dc2626; }
.btn-outline  { background: transparent; border: 1px solid var(--gray-300); color: var(--gray-700); }
.btn-outline:hover { background: var(--gray-100); }
.btn-ghost    { background: var(--gray-100); color: var(--gray-700); }
.btn-ghost:hover { background: var(--gray-200); }
.btn-icon     { padding: 7px; width: 34px; height: 34px; justify-content: center; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* Forms */
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: .82rem; font-weight: 600; color: var(--gray-700); margin-bottom: 5px; }
.form-control {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--gray-300);
  border-radius: var(--radius-sm);
  font-size: .87rem;
  font-family: inherit;
  color: var(--gray-800);
  background: #fff;
  outline: none;
}
.form-control:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,.12); }
.form-control::placeholder { color: var(--gray-400); }
select.form-control { cursor: pointer; }
textarea.form-control { resize: vertical; min-height: 80px; }

.form-row {
  display: grid;
  gap: 14px;
  grid-template-columns: 1fr 1fr;
}
.form-row-3 {
  display: grid;
  gap: 14px;
  grid-template-columns: 1fr 1fr 1fr;
}

/* Badges */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 8px;
  border-radius: 20px;
  font-size: .72rem;
  font-weight: 600;
}
.badge-success  { background: var(--success-light); color: #065f46; }
.badge-warning  { background: var(--warning-light); color: #92400e; }
.badge-danger   { background: var(--danger-light);  color: #991b1b; }
.badge-primary  { background: var(--primary-light); color: #1e40af; }
.badge-gray     { background: var(--gray-100);      color: var(--gray-600); }
.badge-info     { background: var(--info-light);    color: #155e75; }

/* Tables */
.table-wrap { overflow-x: auto; }
table.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .84rem;
}
.data-table th {
  background: var(--gray-50);
  padding: 10px 14px;
  font-weight: 700;
  color: var(--gray-600);
  font-size: .78rem;
  text-transform: uppercase;
  letter-spacing: .04em;
  border-bottom: 2px solid var(--gray-200);
  white-space: nowrap;
}
.data-table td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--gray-100);
  color: var(--gray-700);
  vertical-align: middle;
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: var(--gray-50); }

/* Modals */
.modal-backdrop {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,.55);
  z-index: 300;
  align-items: center; justify-content: center;
  padding: 16px;
}
.modal-backdrop.open { display: flex; }
.modal-box {
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  width: 100%; max-width: 560px;
  max-height: 90vh;
  display: flex; flex-direction: column;
  overflow: hidden;
}
.modal-box.modal-lg { max-width: 800px; }
.modal-box.modal-xl { max-width: 1000px; }
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--gray-100);
  flex-shrink: 0;
}
.modal-header h3 { font-size: 1rem; font-weight: 700; }
.modal-close {
  background: none; border: none;
  font-size: 1.1rem; color: var(--gray-400);
  padding: 4px; line-height: 1;
}
.modal-close:hover { color: var(--gray-700); }
.modal-body {
  padding: 20px;
  overflow-y: auto;
  flex: 1;
}
.modal-footer {
  padding: 14px 20px;
  border-top: 1px solid var(--gray-100);
  display: flex; gap: 10px; justify-content: flex-end;
  flex-shrink: 0;
}

/* Alerts / Toasts */
#toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(80px);
  background: var(--gray-900);
  color: #fff;
  padding: 12px 20px;
  border-radius: 24px;
  font-size: .87rem;
  font-weight: 500;
  z-index: 9999;
  opacity: 0;
  pointer-events: none;
  white-space: nowrap;
  box-shadow: var(--shadow-lg);
  max-width: calc(100vw - 32px);
}
#toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
/* use CSS transition only for toast (not part of page layout) */
#toast { transition: all .3s ease; }
#toast.success { background: var(--success); }
#toast.error   { background: var(--danger); }
#toast.warning { background: var(--warning); }

/* Tabs / Filter Tabs */
.filter-tabs {
  display: flex; gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.ftab {
  padding: 6px 14px;
  border-radius: 20px;
  border: 1px solid var(--gray-200);
  background: #fff;
  font-size: .8rem;
  font-weight: 600;
  color: var(--gray-500);
  cursor: pointer;
}
.ftab:hover { border-color: var(--primary); color: var(--primary); }
.ftab.active { background: var(--primary); border-color: var(--primary); color: #fff; }

/* Search */
.search-bar {
  position: relative;
  flex: 1;
  min-width: 200px;
  max-width: 320px;
}
.search-bar i {
  position: absolute;
  top: 50%; transform: translateY(-50%);
  right: 10px;
  color: var(--gray-400);
  font-size: .85rem;
  pointer-events: none;
}
html[dir="ltr"] .search-bar i { right: auto; left: 10px; }
.search-bar input {
  width: 100%;
  padding: 8px 32px 8px 12px;
  border: 1px solid var(--gray-200);
  border-radius: 20px;
  font-size: .83rem;
  font-family: inherit;
  outline: none;
  background: var(--gray-50);
}
html[dir="ltr"] .search-bar input { padding: 8px 12px 8px 32px; }
.search-bar input:focus { border-color: var(--primary); background: #fff; }

/* Page header row */
.page-header {
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 12px;
  margin-bottom: 20px;
}
.page-header h2 { font-size: 1.15rem; font-weight: 800; color: var(--gray-800); }

/* Empty state */
.empty-state {
  text-align: center;
  padding: 48px 20px;
  color: var(--gray-400);
}
.empty-state i { font-size: 2.5rem; margin-bottom: 12px; display: block; }
.empty-state p { font-size: .9rem; }

/* ═══════════════════════════════════
   GPS STRIP
   ═══════════════════════════════════ */
.gps-strip {
  display: flex; align-items: center; gap: 10px;
  flex-wrap: wrap;
  padding: 12px 16px;
  background: linear-gradient(135deg, #eff6ff, #ecfdf5);
  border: 1px solid #bfdbfe;
  border-radius: var(--radius-sm);
  margin-bottom: 18px;
}
.gps-strip .gps-icon { color: var(--primary); font-size: 1.1rem; }
.gps-strip .gps-info { flex: 1; min-width: 180px; }
.gps-strip .gps-status { font-size: .83rem; font-weight: 600; color: var(--gray-700); }
.gps-strip .gps-coords { font-size: .75rem; color: var(--gray-500); direction: ltr; text-align: left; }
.gps-strip .gps-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ═══════════════════════════════════
   INVOICE FORM
   ═══════════════════════════════════ */
.inv-form-card {
  background: #fff;
  border-radius: var(--radius);
  border: 1px solid var(--gray-200);
  overflow: hidden;
}
.inv-form-section {
  padding: 18px 20px;
  border-bottom: 1px solid var(--gray-100);
}
.inv-form-section:last-child { border-bottom: none; }
.inv-form-section h4 {
  font-size: .85rem;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 14px;
  display: flex; align-items: center; gap: 8px;
}

/* Products table inside invoice form */
.products-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .83rem;
  margin-bottom: 10px;
}
.products-table th {
  background: var(--gray-50);
  padding: 8px 10px;
  font-size: .75rem;
  font-weight: 700;
  color: var(--gray-600);
  border-bottom: 1px solid var(--gray-200);
}
.products-table td {
  padding: 6px 6px;
  border-bottom: 1px solid var(--gray-100);
  vertical-align: middle;
}
.products-table input[type="text"],
.products-table input[type="number"],
.products-table select {
  width: 100%;
  padding: 6px 8px;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-sm);
  font-size: .8rem;
  font-family: inherit;
  outline: none;
  background: #fff;
  min-width: 60px;
}
.products-table input:focus, .products-table select:focus { border-color: var(--primary); }
.products-table .del-row {
  background: none; border: none;
  color: var(--danger); font-size: .85rem; padding: 4px;
}
.products-table .del-row:hover { color: #dc2626; }

/* Totals */
.inv-totals {
  background: var(--gray-50);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
}
.inv-totals .tot-row {
  display: flex; justify-content: space-between;
  padding: 4px 0;
  font-size: .85rem;
  color: var(--gray-600);
  border-bottom: 1px solid var(--gray-200);
}
.inv-totals .tot-row:last-child { border-bottom: none; }
.inv-totals .tot-row.grand {
  font-weight: 800;
  font-size: 1rem;
  color: var(--gray-900);
  padding-top: 8px;
}

/* ═══════════════════════════════════
   INVOICE PREVIEW / PRINT  (Professional A4)
   ═══════════════════════════════════ */

/* Container shown in modal */
.inv-preview {
  direction: rtl;
  font-family: var(--font-ar);
}

/* The A4 document itself */
.inv-doc {
  background: #fff;
  padding: 28px 32px;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  max-width: 820px;
  margin: 0 auto;
  font-size: .85rem;
  line-height: 1.6;
  color: var(--gray-800);
}

/* ── Header ── */
.inv-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 20px;
  gap: 16px;
}
.inv-header-co {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  flex: 1;
}
.inv-co-logo {
  width: 68px; height: 68px;
  object-fit: contain; border-radius: 10px;
  flex-shrink: 0;
}
.inv-co-logo-text {
  width: 68px; height: 68px;
  background: linear-gradient(135deg, var(--primary), var(--success));
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 1.8rem; font-weight: 900;
  flex-shrink: 0;
}
.inv-co-name {
  font-size: 1.25rem; font-weight: 900;
  color: var(--gray-900); margin-bottom: 3px;
}
.inv-co-meta {
  font-size: .76rem; color: var(--gray-500);
  line-height: 1.8;
}
.inv-vat-reg {
  margin-top: 6px;
  display: inline-flex; align-items: center; flex-wrap: wrap;
  gap: 5px;
  background: #fffbeb; border: 1px solid #fde68a;
  border-radius: 6px; padding: 4px 10px;
  font-size: .75rem; color: #92400e;
}
.inv-vat-reg i { color: #d97706; }
.inv-vat-reg strong { direction: ltr; font-weight: 800; }
.inv-vat-stmt {
  font-weight: 700; color: #b45309;
  border-right: 1.5px solid #fcd34d;
  padding-right: 8px;
  margin-right: 4px;
}
/* Badge box on the right */
.inv-header-badge { flex-shrink: 0; text-align: center; }
.inv-badge-box {
  background: var(--primary);
  color: #fff;
  border-radius: 12px;
  padding: 14px 22px;
  min-width: 160px;
}
.inv-badge-title {
  font-size: .72rem; font-weight: 700;
  letter-spacing: .06em; opacity: .85;
  text-transform: uppercase;
}
.inv-badge-num {
  font-size: 1.35rem; font-weight: 900;
  direction: ltr; margin: 4px 0;
}
.inv-badge-date { font-size: .75rem; opacity: .85; }
.inv-type-return {
  display: inline-block;
  margin-top: 6px;
  background: #ef4444; color: #fff;
  font-size: .7rem; font-weight: 800;
  padding: 2px 10px; border-radius: 20px;
}
.inv-status-pill {
  display: inline-block;
  margin-top: 5px;
  color: #fff; font-size: .7rem; font-weight: 700;
  padding: 2px 10px; border-radius: 20px;
}

/* ── Divider ── */
.inv-divider {
  height: 3px;
  background: linear-gradient(to left, var(--primary), var(--success));
  border-radius: 2px;
  margin-bottom: 18px;
}

/* ── Parties ── */
.inv-parties {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-bottom: 18px;
}
.inv-party-box {
  border: 1px solid var(--gray-200);
  border-radius: 8px;
  padding: 12px 14px;
  font-size: .8rem;
}
.inv-party-label {
  font-size: .68rem; font-weight: 800;
  text-transform: uppercase; letter-spacing: .08em;
  color: var(--gray-400); margin-bottom: 5px;
}
.inv-party-co { border-top: 3px solid var(--primary); }
.inv-party-cust { border-top: 3px solid var(--success); }
.inv-party-name {
  font-size: .97rem; font-weight: 800;
  color: var(--gray-900); margin-bottom: 4px;
}
.inv-party-line {
  color: var(--gray-600); line-height: 1.7; font-size: .78rem;
}
.inv-notes-line { color: var(--gray-500); font-style: italic; }

/* ── Items Table ── */
.inv-items-table {
  width: 100%; border-collapse: collapse;
  font-size: .82rem; margin-bottom: 18px;
}
.inv-items-table thead tr {
  background: linear-gradient(135deg, #1e293b, #334155);
  color: #fff;
}
.inv-items-table th {
  padding: 9px 12px;
  font-weight: 700; font-size: .75rem;
  text-align: inherit;
}
.inv-items-table td {
  padding: 9px 12px;
  border-bottom: 1px solid var(--gray-100);
}
.inv-items-table tbody tr:nth-child(even) td { background: var(--gray-50); }
.inv-items-table tbody tr:last-child td { border-bottom: 2px solid var(--gray-200); }
.inv-items-table .tc { text-align: center; }
.inv-items-table .num { direction: ltr; }
.inv-items-table .fw { font-weight: 700; color: var(--gray-900); }

/* ── Bottom section (totals + footer) ── */
.inv-bottom {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 20px;
  margin-bottom: 14px;
}
.inv-bottom-left {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.inv-thankyou {
  font-size: .82rem; color: var(--gray-600);
  padding: 8px 12px;
  background: var(--gray-50);
  border-radius: 6px;
  font-weight: 600;
}
.inv-footer-contact {
  display: flex; flex-wrap: wrap; gap: 12px;
  font-size: .75rem; color: var(--gray-500);
  direction: ltr;
}
.inv-footer-contact i { margin-left: 4px; color: var(--primary); font-size: .7rem; }

/* ── Totals column ── */
.inv-totals-col {
  min-width: 240px;
  border: 1px solid var(--gray-200);
  border-radius: 8px;
  overflow: hidden;
}
.inv-tot-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 7px 14px;
  font-size: .82rem;
  color: var(--gray-600);
  border-bottom: 1px solid var(--gray-100);
}
.inv-tot-row .num { direction: ltr; font-weight: 600; }
.inv-tot-vat {
  background: #fffbeb;
  color: #92400e; font-weight: 600;
}
.inv-tot-grand {
  background: var(--primary);
  color: #fff; font-weight: 800; font-size: .9rem;
  border-bottom: none;
}
.inv-tot-grand .num { color: #fff; font-weight: 900; font-size: 1rem; }
.inv-tot-paid  { background: #f0fdf4; color: #065f46; }
.inv-tot-remain { background: #fff1f2; color: #9f1239; font-weight: 700; }

/* ── GPS Block ── */
.inv-gps-block {
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  border-radius: 6px;
  padding: 9px 12px;
  font-size: .78rem;
  color: var(--gray-700);
  display: flex; align-items: center; gap: 10px;
  flex-wrap: wrap;
}
.inv-gps-block i { color: var(--primary); }
.inv-gps-block a { color: var(--primary); font-weight: 600; }

/* ── Compliance strip ── */
.inv-compliance-strip {
  margin-top: 12px;
  background: #fffbeb;
  border: 1.5px solid #fde68a;
  border-radius: 6px;
  padding: 8px 14px;
  font-size: .77rem;
  color: #92400e;
  display: flex; align-items: center; flex-wrap: wrap; gap: 6px;
  font-weight: 600;
}
.inv-compliance-strip i { color: #d97706; }
.inv-compliance-strip strong { direction: ltr; font-weight: 800; }

/* ═══════════════════════════════════
   DASHBOARD CHART
   ═══════════════════════════════════ */
.chart-container {
  position: relative;
  height: 260px;
}

/* ═══════════════════════════════════
   CUSTOMER CARDS
   ═══════════════════════════════════ */
.customers-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
}
.customer-card {
  background: #fff;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 18px;
  cursor: pointer;
}
.customer-card:hover { box-shadow: var(--shadow); border-color: var(--primary); }
.customer-card .cc-name { font-weight: 700; font-size: .95rem; margin-bottom: 4px; }
.customer-card .cc-city { font-size: .78rem; color: var(--gray-500); margin-bottom: 10px; }
.customer-card .cc-stats {
  display: grid; grid-template-columns: 1fr 1fr 1fr;
  gap: 8px; text-align: center;
}
.customer-card .cc-stat-val { font-size: .88rem; font-weight: 700; color: var(--primary); }
.customer-card .cc-stat-lbl { font-size: .68rem; color: var(--gray-400); }

/* ═══════════════════════════════════
   AUTOCOMPLETE (seller)
   ═══════════════════════════════════ */
.ac-wrap { position: relative; }
.ac-dropdown {
  display: none;
  position: absolute;
  top: 100%; right: 0; left: 0;
  background: #fff;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  z-index: 50;
  max-height: 200px;
  overflow-y: auto;
}
html[dir="ltr"] .ac-dropdown { right: 0; left: 0; }
.ac-dropdown.open { display: block; }
.ac-item {
  padding: 9px 12px;
  font-size: .84rem;
  cursor: pointer;
  border-bottom: 1px solid var(--gray-50);
}
.ac-item:hover { background: var(--primary-light); }

/* ── Product autocomplete (inside invoice table) ── */
.prod-ac-wrap { position: relative; }
.prod-ac-dd {
  display: none;
  position: absolute;
  top: 100%; right: 0; left: 0;
  background: #fff;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  z-index: 60;
  max-height: 220px;
  overflow-y: auto;
  min-width: 220px;
}
.prod-ac-item {
  padding: 8px 12px;
  font-size: .82rem;
  cursor: pointer;
  border-bottom: 1px solid var(--gray-50);
  white-space: nowrap;
  overflow: hidden;
}
.prod-ac-item:hover { background: var(--primary-light); color: var(--primary); }

/* ═══════════════════════════════════
   PROFIT/LOSS PAGE
   ═══════════════════════════════════ */
.pl-summary {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}
.pl-card {
  border-radius: var(--radius);
  padding: 16px 18px;
  text-align: center;
}
.pl-card.revenue { background: var(--success-light); border: 1px solid #a7f3d0; }
.pl-card.expense { background: var(--danger-light);  border: 1px solid #fca5a5; }
.pl-card.profit  { background: var(--primary-light); border: 1px solid #93c5fd; }
.pl-card.margin  { background: var(--warning-light); border: 1px solid #fcd34d; }
.pl-card .pl-val { font-size: 1.3rem; font-weight: 800; }
.pl-card .pl-lbl { font-size: .75rem; font-weight: 600; color: var(--gray-600); margin-top: 2px; }

/* ═══════════════════════════════════
   TRIAL BANNER & PLAN LOCK
   ═══════════════════════════════════ */
#trialBanner {
  position: sticky;
  top: var(--topbar-h);
  z-index: 90;
  margin-right: var(--sidebar-w);
}
html[dir="ltr"] #trialBanner { margin-right: 0; margin-left: var(--sidebar-w); }

.trial-banner-strip {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 20px;
  font-size: .82rem;
  font-weight: 600;
  flex-wrap: wrap;
  background: linear-gradient(135deg, rgba(16,185,129,.12), rgba(37,99,235,.12));
  border-bottom: 1px solid rgba(16,185,129,.25);
  color: #065f46;
}
.trial-banner-strip i { color: #10b981; flex-shrink: 0; }
.trial-banner-strip.warn {
  background: linear-gradient(135deg, rgba(245,158,11,.12), rgba(239,68,68,.08));
  border-color: rgba(245,158,11,.3);
  color: #92400e;
}
.trial-banner-strip.warn i { color: #f59e0b; }
.trial-banner-strip.urgent {
  background: linear-gradient(135deg, rgba(239,68,68,.12), rgba(239,68,68,.06));
  border-color: rgba(239,68,68,.3);
  color: #9f1239;
}
.trial-banner-strip.urgent i { color: #ef4444; }
.trial-banner-strip.expired {
  background: linear-gradient(135deg, rgba(239,68,68,.15), rgba(239,68,68,.05));
  border-color: rgba(239,68,68,.4);
  color: #9f1239;
}
.trial-banner-strip > span { flex: 1; }
.trial-limits-mini {
  display: flex; gap: 14px; flex-wrap: wrap;
}
.trial-limit-item {
  font-size: .75rem; display: flex; flex-direction: column; gap: 3px;
}
.trial-mini-bar {
  height: 4px; width: 80px;
  background: rgba(0,0,0,.1); border-radius: 2px; overflow: hidden;
}
.trial-upgrade-btn {
  display: inline-flex; align-items: center; gap: 5px;
  background: var(--primary); color: #fff;
  padding: 5px 14px; border-radius: 6px;
  font-size: .78rem; font-weight: 700;
  text-decoration: none; flex-shrink: 0;
  transition: opacity .2s;
}
.trial-upgrade-btn:hover { opacity: .85; }

/* ── Plan Lock Screen ── */
.plan-lock-screen {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  min-height: 60vh; text-align: center; padding: 40px 20px;
}
.plan-lock-icon { font-size: 3.5rem; margin-bottom: 16px; }
.plan-lock-title { font-size: 1.4rem; font-weight: 800; color: var(--gray-800); margin-bottom: 10px; }
.plan-lock-sub { font-size: .9rem; color: var(--gray-500); max-width: 420px; margin-bottom: 28px; line-height: 1.7; }
.plan-lock-features {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 10px; margin-bottom: 28px; max-width: 380px;
}
.plf-item {
  background: var(--gray-100); border-radius: 8px;
  padding: 10px 14px; font-size: .82rem; font-weight: 600;
  color: var(--gray-700); display: flex; align-items: center; gap: 8px;
}
.plf-item i { color: var(--primary); width: 16px; text-align: center; }
.plan-lock-btn {
  display: inline-flex; align-items: center; gap: 8px;
  background: linear-gradient(135deg, var(--primary), var(--success));
  color: #fff; padding: 13px 32px; border-radius: 12px;
  font-size: 1rem; font-weight: 800; text-decoration: none;
  transition: opacity .2s, transform .2s;
}
.plan-lock-btn:hover { opacity: .9; transform: translateY(-2px); }

@media (max-width: 900px) {
  #trialBanner { margin-right: 0; margin-left: 0; }
}

/* ═══════════════════════════════════
   PRINT STYLES  — A4 Professional
   ═══════════════════════════════════ */
#printRoot { display: none; }

@media print {
  /* Force exact color rendering */
  * {
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }

  /* Hide everything except print root */
  body > *:not(#printRoot) { display: none !important; }

  /* A4 page setup */
  @page {
    size: A4 portrait;
    margin: 14mm 12mm 14mm 12mm;
  }

  #printRoot {
    display: block !important;
    margin: 0; padding: 0;
    background: #fff;
  }

  /* Reset doc container for print — no border/shadow */
  #printRoot .inv-doc {
    border: none !important;
    box-shadow: none !important;
    border-radius: 0 !important;
    padding: 0 !important;
    max-width: 100% !important;
    font-size: 11pt !important;
  }

  /* Keep colored backgrounds */
  #printRoot .inv-badge-box,
  #printRoot .inv-tot-grand {
    background: #1e40af !important;
    color: #fff !important;
  }
  #printRoot .inv-items-table thead tr {
    background: #1e293b !important;
    color: #fff !important;
  }

  /* Divider */
  #printRoot .inv-divider {
    background: #1d4ed8 !important;
    -webkit-print-color-adjust: exact !important;
  }

  /* Ensure alternating row colors print */
  #printRoot .inv-items-table tbody tr:nth-child(even) td {
    background: #f8fafc !important;
  }

  /* VAT reg background */
  #printRoot .inv-vat-reg,
  #printRoot .inv-compliance-strip {
    background: #fffbeb !important;
    border-color: #fde68a !important;
  }

  /* Party box border tops */
  #printRoot .inv-party-co   { border-top-color: #2563eb !important; }
  #printRoot .inv-party-cust { border-top-color: #10b981 !important; }

  /* GPS block bg */
  #printRoot .inv-gps-block { background: #eff6ff !important; border-color: #bfdbfe !important; }

  /* Totals special rows */
  #printRoot .inv-tot-vat    { background: #fffbeb !important; }
  #printRoot .inv-tot-paid   { background: #f0fdf4 !important; }
  #printRoot .inv-tot-remain { background: #fff1f2 !important; }

  /* Hide elements not needed in print */
  .no-print { display: none !important; }

  /* Avoid page breaks inside key sections */
  .inv-items-table  { page-break-inside: avoid; }
  .inv-totals-col   { page-break-inside: avoid; }
  .inv-compliance-strip { page-break-inside: avoid; }
  .inv-parties      { page-break-inside: avoid; }
}

/* ═══════════════════════════════════
   RESPONSIVE
   ═══════════════════════════════════ */
@media (max-width: 900px) {
  #sidebar {
    transform: translateX(100%);
  }
  html[dir="ltr"] #sidebar {
    transform: translateX(-100%);
  }
  #sidebar.open {
    transform: translateX(0);
  }
  #topbar {
    right: 0; left: 0;
  }
  html[dir="ltr"] #topbar {
    left: 0; right: 0;
  }
  #mainContent {
    margin-right: 0; margin-left: 0;
  }
  #menuToggle { display: flex; }
}

@media (max-width: 600px) {
  #mainContent { padding: 14px; }
  .form-row, .form-row-3 { grid-template-columns: 1fr; }
  .page-header { flex-direction: column; align-items: flex-start; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .modal-box { max-width: 100%; margin: 0; border-radius: var(--radius) var(--radius) 0 0; align-self: flex-end; max-height: 95vh; }
  .modal-backdrop { align-items: flex-end; padding: 0; }
}

/* ═══════════════════════════════════
   UTILITY
   ═══════════════════════════════════ */
.flex { display: flex; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.mt-4 { margin-top: 16px; }
.mb-2 { margin-bottom: 8px; }
.mb-3 { margin-bottom: 12px; }
.mb-4 { margin-bottom: 16px; }
.text-sm { font-size: .8rem; }
.text-xs { font-size: .72rem; }
.text-muted { color: var(--gray-500); }
.text-primary { color: var(--primary); }
.text-success { color: var(--success); }
.text-danger  { color: var(--danger); }
.text-warning { color: var(--warning); }
.fw-bold { font-weight: 700; }
.d-none { display: none !important; }
.w-full { width: 100%; }
.text-center { text-align: center; }
.text-end { text-align: left; }
html[dir="ltr"] .text-end { text-align: right; }
.num { direction: ltr; display: inline-block; }

/* Stock Picker cards hover */
.stock-pick-card:not(.out-of-stock):hover {
  border-color: var(--primary) !important;
  box-shadow: var(--shadow);
  transform: translateY(-1px);
}

/* VAT row highlight */
#totVatRow {
  background: #fffbeb;
  border-radius: 4px;
}

/* Spinner */
.spinner {
  width: 28px; height: 28px;
  border: 3px solid var(--gray-200);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Loading overlay */
.loading-overlay {
  position: fixed; inset: 0;
  background: #fff;
  display: flex; align-items: center; justify-content: center;
  z-index: 9999;
  flex-direction: column; gap: 14px;
}
.loading-overlay.hidden { display: none; }
