/* ===== أساسيات ===== */
* { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --primary: #1e40af;          /* أزرق Access كلاسيك */
  --primary-dark: #1e3a8a;
  --primary-light: #3b82f6;
  --accent: #f59e0b;
  --danger: #dc2626;
  --success: #10b981;
  --bg: #f1f5f9;
  --surface: #ffffff;
  --text: #0f172a;
  --muted: #64748b;
  --border: #cbd5e1;
  --shadow: 0 2px 8px rgba(15, 23, 42, .08);
  --shadow-lg: 0 12px 32px rgba(15, 23, 42, .15);
  --radius: 10px;
  --radius-sm: 8px;
  --titlebar-h: 32px;
  --menubar-h: 38px;
  --status-h: 26px;
}
html, body {
  height: 100%; font-family: 'Cairo', Tahoma, Arial, sans-serif;
  background: var(--bg); color: var(--text); font-size: 14px;
}
a { text-decoration: none; color: inherit; }
button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, select, textarea { font-family: inherit; }
.hidden { display: none !important; }

/* ===================================
   شاشة الترحيب (تطابق الواجهة الأصلية)
   =================================== */
.splash {
  position: fixed; inset: 0;
  background:
    linear-gradient(135deg, rgba(30,64,175,.85), rgba(30,58,138,.92)),
    url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='100' height='100'><circle cx='50' cy='50' r='40' fill='none' stroke='%23ffffff15' stroke-width='1'/></svg>");
  display: flex; align-items: center; justify-content: center;
  z-index: 1000; overflow: auto;
}
.splash-card {
  background: #fff; border-radius: 18px;
  padding: 40px 50px; width: 100%; max-width: 560px;
  box-shadow: 0 30px 70px rgba(0,0,0,.35);
  text-align: center;
}
.bism {
  background: linear-gradient(135deg, var(--danger), #b91c1c);
  color: #fff; padding: 10px 30px; border-radius: 8px;
  font-size: 20px; font-weight: 700; display: inline-block;
  margin-bottom: 22px; letter-spacing: 1px;
}
.splash-title-box {
  background: #fde2e2; border: 1px solid #fca5a5;
  padding: 18px; border-radius: 12px; margin: 0 auto 18px;
  max-width: 280px;
}
.splash-title-box h1 {
  color: var(--primary); font-size: 32px; font-weight: 800;
  letter-spacing: 1px;
}
.splash-title-box .year {
  font-size: 28px; font-weight: 800; color: var(--primary-dark);
  margin-top: 4px;
}
.about-btn {
  background: var(--primary); color: #fff;
  padding: 10px 36px; border-radius: 8px;
  font-weight: 700; font-size: 15px; margin-bottom: 24px;
  transition: background .15s;
}
.about-btn:hover { background: var(--primary-dark); }

.login-form { margin-bottom: 18px; }
.login-form input {
  width: 240px; padding: 11px 14px; border: 2px solid var(--border);
  border-radius: 8px; font-size: 15px; outline: none; text-align: center;
  transition: border .15s;
}
.login-form input:focus { border-color: var(--primary); }

.splash-actions {
  display: grid; grid-template-columns: 1fr 1.4fr 1fr;
  gap: 14px; align-items: start; margin-top: 8px;
}
.backup-stack { display: flex; flex-direction: column; gap: 8px; }

.btn-classic {
  background: linear-gradient(180deg, #f8fafc, #e2e8f0);
  border: 1px solid #94a3b8; border-radius: 8px;
  padding: 10px 16px; font-weight: 700; font-size: 13px;
  color: var(--text); transition: all .12s;
  box-shadow: inset 0 1px 0 #fff;
}
.btn-classic:hover { background: linear-gradient(180deg, #fff, #f1f5f9); border-color: var(--primary); }
.btn-classic:active { transform: translateY(1px); }
.btn-classic.primary { background: linear-gradient(180deg, #3b82f6, var(--primary)); color: #fff; border-color: var(--primary-dark); }
.btn-classic.primary:hover { background: linear-gradient(180deg, var(--primary-light), var(--primary-dark)); }
.btn-classic.danger { color: var(--danger); font-weight: 800; }

@media (max-width: 600px) {
  .splash-card { padding: 26px 20px; }
  .splash-actions { grid-template-columns: 1fr; }
}

/* ===================================
   التطبيق الرئيسي
   =================================== */
.app { display: flex; flex-direction: column; min-height: 100vh; }
.app.single-screen-mode .menubar { display: none; }
.app.single-screen-mode .content { padding-top: 12px; }

/* شريط العنوان */
.title-bar {
  height: var(--titlebar-h);
  background: linear-gradient(180deg, #2563eb, var(--primary), var(--primary-dark));
  color: #fff; display: flex; align-items: center;
  padding: 0 14px; flex-shrink: 0;
}
.title-bar.small { height: 30px; }
.title-text { flex: 1; font-weight: 700; font-size: 14px; }
.window-ctrls { display: flex; gap: 4px; }
.wc {
  width: 28px; height: 22px; display: inline-flex;
  align-items: center; justify-content: center;
  background: rgba(255,255,255,.12); border-radius: 4px;
  font-size: 12px; cursor: pointer; user-select: none;
  transition: background .12s;
}
.wc:hover { background: rgba(255,255,255,.25); }
.wc.x:hover { background: var(--danger); }

/* شريط القوائم الأفقي (Access style modern) */
.menubar {
  height: var(--menubar-h);
  background: linear-gradient(180deg, #fff, #e2e8f0);
  border-bottom: 1px solid #94a3b8;
  display: flex; align-items: stretch;
  padding: 0 6px; gap: 2px; flex-shrink: 0;
  position: sticky; top: 0; z-index: 90;
  box-shadow: 0 2px 6px rgba(0,0,0,.06);
}
.menu-item {
  position: relative; display: flex; align-items: center;
  padding: 0 18px; cursor: pointer; font-weight: 700;
  font-size: 14px; color: var(--text);
  transition: background .12s;
  border-radius: 6px 6px 0 0; margin: 2px 0;
}
.menu-item:hover, .menu-item.open {
  background: var(--primary); color: #fff;
}
.menu-item .menu-label::before {
  content: '▾'; margin-left: 6px; font-size: 10px; opacity: .7;
}
.menu-item.exit { color: var(--danger); }
.menu-item.exit:hover { background: var(--danger); color: #fff; }
.menu-item.exit .menu-label::before { content: ''; margin: 0; }

.dropdown {
  position: absolute; top: 100%; right: 0; min-width: 240px;
  background: #fff; border: 1px solid #94a3b8;
  border-radius: 0 0 8px 8px;
  box-shadow: 0 12px 24px rgba(0,0,0,.18);
  padding: 6px; display: none; z-index: 100;
}
.menu-item.open .dropdown { display: block; }
.dropdown a {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px; border-radius: 6px;
  color: var(--text); font-weight: 600; font-size: 13px;
  transition: all .12s;
}
.dropdown a i { font-size: 16px; color: var(--primary); }
.dropdown a:hover { background: var(--primary); color: #fff; }
.dropdown a:hover i { color: #fff; }

.menu-spacer { flex: 1; }
.menu-home {
  display: flex; align-items: center; padding: 0 14px;
  color: var(--primary); font-size: 18px;
  border-radius: 6px; margin: 4px 2px;
}
.menu-home:hover { background: var(--primary); color: #fff; }
.menu-clock {
  display: flex; align-items: center; padding: 0 14px;
  font-weight: 700; color: var(--muted); font-size: 13px;
  font-variant-numeric: tabular-nums;
}

/* المحتوى */
.content { flex: 1; min-width: 0; padding: 18px; overflow-x: auto; }

/* شريط الحالة */
.statusbar {
  height: var(--status-h);
  background: linear-gradient(180deg, #f1f5f9, #cbd5e1);
  border-top: 1px solid #94a3b8;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 14px; font-size: 12px; color: var(--muted);
  font-weight: 600; flex-shrink: 0;
}
.statusbar span { display: inline-flex; align-items: center; gap: 6px; }

/* ===== الكروت ===== */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 18px; margin-bottom: 16px;
}
.card-header {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; margin-bottom: 16px; flex-wrap: wrap;
  padding-bottom: 12px; border-bottom: 1px solid var(--border);
}
.card-header-actions {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
}
.card-header-note {
  padding: 10px 14px;
  border-radius: 10px;
  background: linear-gradient(180deg, #dbeafe, #bfdbfe);
  border: 1px solid #93c5fd;
  color: var(--primary-dark);
  font-weight: 800;
}
.card-title {
  font-weight: 800; font-size: 16px;
  display: flex; align-items: center; gap: 10px;
  color: var(--primary-dark);
}
.card-title i { color: var(--primary); font-size: 20px; }

.grid { display: grid; gap: 14px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 900px) { .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; } }

/* ===== النماذج (نمط مطابق للأصل) ===== */
.form-row { display: grid; gap: 12px; grid-template-columns: repeat(2, 1fr); }
.form-row.cols-3 { grid-template-columns: repeat(3, 1fr); }
.form-row.cols-4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 720px) { .form-row, .form-row.cols-3, .form-row.cols-4 { grid-template-columns: 1fr; } }

.field { display: flex; flex-direction: column; gap: 5px; }

/* الحقل بنمط Access (label أزرق على يمين الحقل) */
.field-inline {
  display: flex; align-items: stretch; gap: 0; margin-bottom: 10px;
}
.field-inline label {
  background: #dbeafe; border: 1px solid #93c5fd;
  color: var(--primary-dark); font-weight: 700;
  padding: 9px 16px; min-width: 110px; text-align: center;
  border-radius: 6px 0 0 6px; font-size: 14px;
  display: flex; align-items: center; justify-content: center;
}
.field-inline input, .field-inline select, .field-inline textarea {
  flex: 1; padding: 9px 12px; border: 1px solid var(--border);
  border-right: none; border-radius: 0 6px 6px 0;
  font-size: 14px; outline: none; background: #fff;
}
.field-inline input:focus, .field-inline select:focus, .field-inline textarea:focus { border-color: var(--primary); }

.field label { font-size: 13px; font-weight: 700; color: var(--primary-dark); }
.field input, .field select, .field textarea {
  padding: 9px 12px; border: 1px solid var(--border); border-radius: 6px;
  font-size: 14px; outline: none; background: #fff;
  transition: border .12s;
}
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(30,64,175,.08); }
.field textarea { resize: vertical; min-height: 70px; }

.form-actions { display: flex; gap: 10px; margin-top: 16px; flex-wrap: wrap; }

/* ===== أزرار ===== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 9px 18px; border-radius: 6px; font-size: 14px;
  font-weight: 700; transition: all .12s; white-space: nowrap;
  border: 1px solid transparent;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--primary); color: #fff; border-color: var(--primary-dark); }
.btn-primary:hover { background: var(--primary-dark); }
.btn-accent { background: var(--accent); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-success { background: var(--success); color: #fff; }
.btn-soft {
  background: linear-gradient(180deg, #f8fafc, #e2e8f0);
  border-color: #94a3b8; color: var(--text); font-size: 13px;
}
.btn-soft:hover { background: linear-gradient(180deg, #fff, #f1f5f9); border-color: var(--primary); color: var(--primary); }
.btn-block { width: 100%; }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-exit {
  background: linear-gradient(180deg, #fee2e2, #fecaca);
  border: 1px solid #f87171; color: var(--danger); font-weight: 800;
  padding: 8px 24px; border-radius: 6px;
}

/* ===== الجداول (مطابقة لجدول Access) ===== */
.table-wrap {
  overflow: auto; border: 1px solid #94a3b8; border-radius: 6px;
  max-height: 520px;
}
table.table { width: 100%; border-collapse: collapse; font-size: 13.5px; background: #fff; }
.table th {
  background: linear-gradient(180deg, #2563eb, var(--primary));
  color: #fff; font-weight: 700;
  text-align: center; padding: 8px 10px;
  border: 1px solid var(--primary-dark);
  font-size: 13px; position: sticky; top: 0; z-index: 2;
}
.table td {
  padding: 7px 10px; border: 1px solid #cbd5e1; text-align: center;
}
.table tbody tr:nth-child(even) { background: #f8fafc; }
.table tbody tr:hover { background: #dbeafe; }
.table tbody tr.selected { background: #1e40af; color: #fff; }
.table tbody tr.selected td { color: #fff; }
.table .actions { display: flex; gap: 4px; justify-content: center; }
.table .empty { text-align: center; padding: 30px; color: var(--muted); }
.table tfoot td {
  background: #f1f5f9; font-weight: 800;
  border-top: 2px solid var(--primary);
}

.badge {
  display: inline-block; padding: 2px 10px; border-radius: 999px;
  font-size: 12px; font-weight: 700;
}
.badge-success { background: rgba(16,185,129,.15); color: #047857; }
.badge-danger  { background: rgba(220,38,38,.15); color: #991b1b; }
.badge-warn    { background: rgba(245,158,11,.18); color: #92400e; }

/* ===== شريط بحث ===== */
.searchbar { position: relative; flex: 1; max-width: 360px; }
.searchbar input {
  width: 100%; padding: 9px 36px 9px 12px;
  border: 1px solid var(--border); border-radius: 6px;
  font-size: 14px; outline: none; background: #fff;
}
.searchbar input:focus { border-color: var(--primary); }
.searchbar i {
  position: absolute; left: 11px; top: 50%; transform: translateY(-50%);
  color: var(--muted);
}

/* لوحة المعلومات */
.stat-card {
  display: flex; align-items: center; gap: 14px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px 18px;
  box-shadow: var(--shadow);
}
.stat-card .icon {
  width: 48px; height: 48px; border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px; color: #fff;
}
.stat-card .icon.bg1 { background: linear-gradient(135deg,#1e40af,#3b82f6); }
.stat-card .icon.bg2 { background: linear-gradient(135deg,#f59e0b,#fbbf24); }
.stat-card .icon.bg3 { background: linear-gradient(135deg,#10b981,#34d399); }
.stat-card .icon.bg4 { background: linear-gradient(135deg,#dc2626,#f87171); }
.stat-card .label { color: var(--muted); font-size: 12.5px; font-weight: 600; }
.stat-card .value { font-size: 20px; font-weight: 800; }

/* نافذة منبثقة */
.modal { position: fixed; inset: 0; z-index: 200; display: flex; align-items: center; justify-content: center; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(15, 23, 42, .55); backdrop-filter: blur(2px); }
.modal-card {
  position: relative; background: #fff; border-radius: var(--radius);
  width: 100%; max-width: 760px; max-height: 92vh; overflow: hidden;
  box-shadow: var(--shadow-lg); display: flex; flex-direction: column;
  animation: modalIn .18s ease-out;
}
@keyframes modalIn { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }
.modal-body { padding: 20px; overflow-y: auto; }

/* إشعار */
.toast {
  position: fixed; bottom: 40px; left: 50%; transform: translateX(-50%) translateY(40px);
  background: var(--text); color: #fff; padding: 11px 22px; border-radius: 999px;
  font-weight: 700; box-shadow: var(--shadow-lg); opacity: 0; pointer-events: none;
  transition: all .2s; z-index: 300; font-size: 13.5px;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }

/* تحميل */
.loader {
  display: flex; align-items: center; justify-content: center;
  padding: 40px; color: var(--muted); gap: 10px;
}
.spinner {
  width: 22px; height: 22px; border: 3px solid var(--border);
  border-top-color: var(--primary); border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* رأس كشف الحساب */
.statement-header {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px;
  margin-bottom: 14px;
}
.statement-header .info {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 50px;
  background: #dbeafe;
  padding: 7px 10px;
  border-radius: 6px;
  border-right: 3px solid var(--primary);
}
.statement-header .info .l { font-size: 11px; color: var(--muted); font-weight: 600; }
.statement-header .info .v { font-weight: 800; font-size: 13px; line-height: 1.35; color: var(--primary-dark); }
.statement-status-line {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 12px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #f8fafc;
}
.statement-status-label {
  color: var(--primary-dark);
  font-weight: 800;
}
.statement-status-meta {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.review-type-select,
.review-status-select {
  min-height: 38px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  font-family: inherit;
}
.review-summary-strip {
  display: flex;
  gap: 18px;
  flex-wrap: wrap;
  margin-bottom: 12px;
  padding: 10px 12px;
  border-radius: 8px;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  color: var(--primary-dark);
  font-weight: 700;
}
.review-table td {
  vertical-align: middle;
}
.review-status-cell {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
}

.totals-row {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-top: 14px;
}
.total-pill {
  background: linear-gradient(180deg, #f8fafc, #fff);
  border: 1px solid var(--border); border-radius: 6px;
  padding: 12px; text-align: center;
}
.total-pill .l { font-size: 12px; color: var(--muted); font-weight: 700; }
.total-pill .v { font-size: 19px; font-weight: 800; color: var(--primary); margin-top: 3px; }
.total-pill.due .v { color: var(--danger); }
@media (max-width: 800px) {
  .statement-header, .totals-row { grid-template-columns: repeat(2, 1fr); }
}

body.show-print { zoom: 1 !important; }

.legacy-print-doc {
  direction: rtl;
  background: #fff;
  color: #0f172a;
  min-height: 100%;
  padding: 8mm 10mm 10mm;
}
.legacy-print-head {
  display: grid;
  grid-template-columns: 100px 1fr 100px;
  gap: 10px;
  align-items: center;
  border-top: 4px double var(--primary-dark);
  border-bottom: 4px double var(--primary-dark);
  padding: 10px 0 12px;
  margin-bottom: 10px;
}
.legacy-decor {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  color: var(--primary-dark);
  font-size: 28px;
  font-weight: 800;
}
.legacy-logo-box {
  min-height: 84px;
}
.legacy-logo {
  width: 78px;
  height: 78px;
  object-fit: contain;
}
.legacy-decor small {
  display: block;
  margin-top: 4px;
  font-size: 10px;
  color: var(--muted);
}
.legacy-head-center { text-align: center; }
.legacy-shop-name {
  font-size: 20px;
  font-weight: 800;
  line-height: 1.6;
}
.legacy-shop-subtitle {
  font-size: 12px;
  color: var(--muted);
  font-weight: 700;
}
.legacy-report-name {
  margin-top: 6px;
  font-size: 18px;
  font-weight: 800;
  color: var(--primary-dark);
}
.legacy-head-meta {
  display: inline-flex;
  justify-content: center;
  gap: 16px;
  flex-wrap: wrap;
  margin-top: 5px;
  font-size: 10px;
  color: var(--muted);
  font-weight: 700;
}
.legacy-meta-strip {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}
.legacy-meta-stack {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.legacy-stamp {
  min-width: 110px;
  padding: 6px 10px;
  background: #eff6ff;
  border: 1px solid #93c5fd;
  border-right: 4px solid var(--primary);
}
.legacy-stamp-label {
  font-size: 11px;
  color: var(--muted);
  font-weight: 700;
}
.legacy-stamp-value {
  font-size: 15px;
  color: var(--primary-dark);
  font-weight: 800;
}
.legacy-summary-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
  margin-bottom: 10px;
}
.legacy-summary-item {
  display: flex;
  min-height: 44px;
  background: #eff6ff;
  border: 1px solid #93c5fd;
  overflow: hidden;
  break-inside: avoid;
  page-break-inside: avoid;
}
.legacy-summary-label {
  flex: 0 0 100px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #dbeafe;
  color: var(--primary-dark);
  font-weight: 800;
  border-left: 1px solid #93c5fd;
  padding: 5px 8px;
  font-size: 12px;
}
.legacy-summary-value {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 5px 8px;
  font-size: 14px;
  line-height: 1.35;
  font-weight: 800;
}
.legacy-report-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
  font-size: 11px;
}
.legacy-report-table th,
.legacy-report-table td {
  border: 1px solid var(--primary-dark);
  padding: 5px 4px;
  text-align: center;
  vertical-align: middle;
  word-break: break-word;
}
.legacy-report-table th {
  background: var(--primary) !important;
  color: #fff;
  font-weight: 800;
  -webkit-print-color-adjust: exact;
  print-color-adjust: exact;
}
.legacy-report-table .name-cell {
  font-weight: 800;
}
.legacy-report-table .empty {
  padding: 18px 8px;
}
.legacy-report-section {
  margin-top: 12px;
  break-inside: avoid;
  page-break-inside: avoid;
}
.legacy-section-title {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 130px;
  margin-bottom: 5px;
  padding: 5px 12px;
  background: #dbeafe;
  border: 1px solid #93c5fd;
  color: var(--primary-dark);
  font-size: 12px;
  font-weight: 800;
}
.legacy-report-table-secondary {
  font-size: 10.5px;
}
.legacy-totals-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin-top: 10px;
}
.legacy-total-box {
  padding: 8px 10px;
  text-align: center;
  background: #eff6ff;
  border: 1px solid #93c5fd;
  break-inside: avoid;
  page-break-inside: avoid;
}
.legacy-total-box .label {
  font-size: 11px;
  color: var(--muted);
  font-weight: 700;
}
.legacy-total-box .value {
  margin-top: 3px;
  font-size: 18px;
  color: var(--primary-dark);
  font-weight: 800;
}
.legacy-total-box.due .value {
  color: var(--danger);
}
.legacy-print-footer {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 12px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
  font-size: 11px;
  color: var(--muted);
}
.legacy-compact .legacy-report-table {
  font-size: 12px;
}
.legacy-compact .legacy-summary-grid,
.legacy-compact .legacy-totals-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

/* الطباعة */
@media print {
  body * { visibility: hidden !important; }
  body.show-print { zoom: 1 !important; }
  body.show-print .print-overlay,
  body.show-print .print-overlay * { visibility: visible !important; }
  body.show-print .print-overlay .no-print,
  body.show-print .print-overlay .no-print * { visibility: hidden !important; }
  .print-overlay { position: absolute !important; inset: 0; background: #fff !important; padding: 0 !important; overflow: visible !important; }
  .print-toolbar { display: none !important; }
  .print-page { width: auto !important; min-width: 0 !important; zoom: 1 !important; padding: 0 !important; margin: 0 !important; box-shadow: none !important; border: none !important; max-width: 100% !important; }
  .print-doc { box-shadow: none !important; border: none !important; padding: 10mm !important; }
  .legacy-print-doc { padding: 0 !important; }
  .legacy-print-head { grid-template-columns: 100px 1fr 100px !important; }
  .legacy-summary-grid { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; }
  .legacy-totals-grid { grid-template-columns: repeat(4, minmax(0, 1fr)) !important; }
  .legacy-compact .legacy-summary-grid,
  .legacy-compact .legacy-totals-grid { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; }
  .legacy-summary-item { flex-direction: row !important; }
  .legacy-summary-label { flex: 0 0 100px !important; border-left: 1px solid #93c5fd !important; border-bottom: 0 !important; }
  .legacy-print-footer { flex-direction: row !important; }
  .print-body .totals-row { grid-template-columns: repeat(4, minmax(0, 1fr)) !important; }
  .print-body .grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; }
  .legacy-report-table,
  .print-body .table { page-break-inside: auto; }
  .legacy-report-table tr,
  .print-body .table tr { break-inside: avoid; page-break-inside: avoid; }
  @page { size: A4; margin: 10mm; }
}

/* ===== Autocomplete ===== */
.ac-panel { position: fixed; z-index: 500; background: #fff; border: 1px solid var(--primary); border-radius: 6px; box-shadow: 0 10px 24px rgba(0,0,0,.18); max-height: 280px; overflow-y: auto; display: none; }
.ac-panel.open { display: block; }
.ac-item { padding: 9px 12px; cursor: pointer; display: flex; justify-content: space-between; gap: 10px; border-bottom: 1px solid #f1f5f9; }
.ac-item:last-child { border-bottom: none; }
.ac-item:hover, .ac-item.active { background: var(--primary); color: #fff; }
.ac-item .ac-l { font-weight: 700; }
.ac-item .ac-s { color: var(--muted); font-size: 12px; }
.ac-item:hover .ac-s, .ac-item.active .ac-s { color: rgba(255,255,255,.85); }
.ac-empty { padding: 14px; text-align: center; color: var(--muted); font-size: 13px; }

/* ===== Print Preview Overlay ===== */
.print-overlay { position: fixed; inset: 0; background: #475569; z-index: 400; display: flex; flex-direction: column; overflow: auto; padding: 0; }
.print-toolbar { background: linear-gradient(180deg, var(--primary), var(--primary-dark)); color: #fff; padding: 10px 16px; display: flex; align-items: center; justify-content: space-between; position: sticky; top: 0; z-index: 10; box-shadow: 0 4px 10px rgba(0,0,0,.3); }
.pt-title { font-weight: 800; font-size: 16px; display: flex; align-items: center; gap: 8px; }
.pt-actions { display: flex; gap: 8px; }
.print-page { background: #fff; width: 210mm; min-width: 210mm; max-width: none; margin: 20px auto; min-height: 290mm; box-shadow: 0 10px 40px rgba(0,0,0,.4); padding: 0; flex: 0 0 auto; zoom: var(--print-preview-zoom, 1); }
.print-page.print-page-raw { width: 210mm; min-width: 210mm; max-width: none; }
.print-doc { padding: 14mm; font-family: 'Cairo', sans-serif; color: #0f172a; }
.print-header { display: grid; grid-template-columns: 70px 1fr 180px; gap: 14px; align-items: center; border-bottom: 3px double var(--primary); padding-bottom: 12px; margin-bottom: 16px; }
.ph-logo { width: 60px; height: 60px; border-radius: 50%; background: linear-gradient(135deg, var(--primary), var(--primary-light)); color: #fff; display: flex; align-items: center; justify-content: center; font-size: 28px; }
.ph-titles h1 { font-size: 22px; color: var(--primary-dark); font-weight: 800; }
.ph-titles h2 { font-size: 16px; color: var(--muted); font-weight: 700; margin-top: 4px; }
.ph-meta { text-align: left; font-size: 12.5px; color: var(--text); line-height: 1.7; }
.ph-meta b { color: var(--primary-dark); }
.print-body { font-size: 12.5px; }
.print-body .table-wrap { overflow: visible; max-height: none; }
.print-body .table { table-layout: fixed; font-size: 11px; }
.print-body .table th,
.print-body .table td { white-space: normal; word-break: break-word; }
.print-body .table th { background: var(--primary) !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
.print-body .table tbody tr:nth-child(even) { background: #f8fafc !important; -webkit-print-color-adjust: exact; }
.print-footer { margin-top: 18px; padding-top: 10px; border-top: 1px solid var(--border); display: flex; justify-content: space-between; font-size: 11px; color: var(--muted); }

@media (max-width: 800px) {
  .print-overlay { align-items: flex-start; }
  .print-page { margin: 12px; }
  .print-overlay .legacy-print-head { grid-template-columns: 100px 1fr 100px; }
  .print-overlay .legacy-summary-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .print-overlay .legacy-totals-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .print-overlay .legacy-compact .legacy-summary-grid,
  .print-overlay .legacy-compact .legacy-totals-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .print-overlay .legacy-summary-item { flex-direction: row; }
  .print-overlay .legacy-summary-label { flex: 0 0 100px; border-left: 1px solid #93c5fd; border-bottom: 0; }
  .print-overlay .legacy-print-footer { flex-direction: row; }
  .print-overlay .print-body .totals-row { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .print-overlay .print-body .grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  body:not(.show-print) .legacy-print-head { grid-template-columns: 1fr; }
  .statement-status-line,
  .review-status-cell { justify-content: flex-start; }
  body:not(.show-print) .legacy-meta-strip { flex-direction: column; align-items: stretch; }
  body:not(.show-print) .legacy-summary-grid,
  body:not(.show-print) .legacy-totals-grid { grid-template-columns: 1fr; }
  body:not(.show-print) .legacy-summary-item { flex-direction: column; }
  body:not(.show-print) .legacy-summary-label { flex-basis: auto; border-left: none; border-bottom: 1px solid #93c5fd; }
  body:not(.show-print) .legacy-print-footer { flex-direction: column; }
}



/* ==========================================================
   ????? ?????? (Mobile Mode) � ??? ????? ???? ???????
   ========================================================== */
body.mobile-mode { background: linear-gradient(135deg,#1e3a8a,#0f172a); padding: 12px 0; }
body.mobile-mode .app {
  max-width: 480px;
  margin: 0 auto;
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 20px 60px rgba(0,0,0,.6), 0 0 0 8px #111 inset, 0 0 0 10px #333;
}
body.mobile-mode .title-bar { font-size: 12px; }
body.mobile-mode .menubar {
  flex-wrap: wrap; gap: 4px; padding: 4px 6px; font-size: 12px;
}
body.mobile-mode .menubar .menu-item { padding: 4px 8px; font-size: 12px; }
body.mobile-mode .menubar .menu-clock { display:none; }
body.mobile-mode .menubar .menu-spacer { display:none; }
body.mobile-mode .content { padding: 10px; }
body.mobile-mode .card { padding: 12px; margin-bottom: 10px; }
body.mobile-mode .grid-2,
body.mobile-mode .grid-3,
body.mobile-mode .grid-4 { grid-template-columns: 1fr; }
body.mobile-mode .card-header { flex-direction: column; align-items: stretch; gap: 8px; }
body.mobile-mode .field-inline { flex-direction: column; align-items: stretch; }
body.mobile-mode .field-inline label { width: auto; margin-bottom: 4px; }
body.mobile-mode .table { font-size: 12px; }
body.mobile-mode .table th, body.mobile-mode .table td { padding: 6px 4px; }
body.mobile-mode .form-actions { flex-wrap: wrap; }
body.mobile-mode .form-actions .btn { flex: 1 1 45%; }
body.mobile-mode .statusbar { font-size: 11px; }

/* ?? ?????? (??????) */
.btn-success {
  background: linear-gradient(180deg,#25D366,#128C7E);
  color: #fff; border-color: #075E54;
}
.btn-success:hover { background: linear-gradient(180deg,#128C7E,#075E54); }

/* ????? ???? ?????? ????? ???????? */
.table-wrap:focus { outline: 2px solid var(--primary, #1e40af); outline-offset: -2px; }

/* === ???? ????????: ?? ???? ???? ?????? ????? ??? ?? ?????? ??????? === */
.trx-row-table { font-size: .98rem; }
.trx-row-table th, .trx-row-table td { padding: 8px 10px; white-space: nowrap; }
.trx-row-table thead th { background: #d1d5db; color: #111827; font-weight: 800; border: 1px solid #6b7280; }
.trx-row-table tbody td { border: 1px solid var(--border); }
.trx-row-table tbody tr:hover { background: #f8fafc; }
.trx-row-table tbody tr.selected { background: #e2e8f0 !important; outline: 2px solid #111827; }

.trx-latest-preview {
  margin-bottom: 12px;
}
.trx-preview-title {
  margin-bottom: 8px;
  color: #111827;
  font-weight: 800;
  font-size: 1rem;
}
.trx-latest-preview .table-wrap {
  max-height: none;
}
.trx-row-table-compact tbody td {
  border-top: 1px solid var(--border);
}
.trx-row-table-compact .empty {
  text-align: center;
}
.trx-editable-row {
  cursor: pointer;
}
.trx-editable-row:hover {
  background: #dbeafe !important;
}

/* === Excel-style transaction input row === */
.trx-entry-meta {
  display: grid;
  grid-template-columns: 240px minmax(320px, 1.15fr) minmax(380px, 1fr);
  gap: 12px 14px;
  align-items: stretch;
  margin-bottom: 12px;
}
.trx-entry-meta-stack {
  grid-template-columns: 1fr;
  max-width: 760px;
}
.trx-entry-meta-stack .trx-meta-field {
  flex-direction: row;
  align-items: stretch;
  gap: 12px;
}
.trx-entry-meta-stack .trx-meta-label {
  flex: 0 0 170px;
  min-width: 170px;
  min-height: 60px;
}
.trx-entry-meta-stack .trx-meta-control,
.trx-entry-meta-stack .trx-meta-field > input {
  flex: 1;
  min-width: 0;
}
.trx-meta-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 10px;
  background: linear-gradient(180deg, #eff6ff, #dbeafe);
  border: 1px solid #93c5fd;
  border-radius: 10px;
}
.trx-meta-label {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 8px 14px;
  background: linear-gradient(180deg, #3b82f6, var(--primary));
  color: #fff;
  border: 1px solid var(--primary-dark);
  border-radius: 8px;
  font-weight: 800;
  font-size: 1rem;
}
.trx-meta-control,
.trx-meta-field > input {
  min-height: 54px;
}
.trx-meta-field input {
  width: 100%;
  min-height: 54px;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  font-size: 1.08rem;
  font-weight: 700;
  outline: none;
}
.trx-meta-field input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(59, 130, 246, .18);
}
.trx-meta-date input {
  min-height: 60px;
  font-size: 1.2rem;
  font-weight: 800;
  text-align: center;
  color: #111827;
}
.trx-meta-grower input {
  min-height: 60px;
  font-size: 1.12rem;
  color: #111827;
}
.trx-cust-card { display:grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap:6px 10px; margin-top:10px; padding:8px; background:#dbeafe; border:2px solid #93c5fd; border-radius:6px; }
.trx-cust-card .row { display:flex; align-items:center; gap:6px; }
.trx-cust-card .lbl { background:#fde68a; padding:4px 8px; font-weight:800; color:#78350f; border:1px solid #b45309; border-radius:4px; min-width:60px; text-align:center; font-size:.85rem; }
.trx-cust-card .row input { flex:1; padding:5px 8px; border:1px solid #93c5fd; border-radius:4px; background:#fff; font-weight:700; }

.trx-input-table { font-size:1rem; }
.trx-input-table thead th { background:#d1d5db; color:#111827; font-weight:800; border:1px solid #6b7280; padding:8px 6px; text-align:center; white-space:nowrap; }
.trx-input-table tbody td { padding:2px; border:1px solid var(--border); background:#fff; }
.trx-input-table tbody td input { width:100%; min-height:42px; padding:8px 6px; border:1px solid transparent; border-radius:3px; background:transparent; font-weight:700; font-size:1.05rem; text-align:center; outline:none; }
.trx-input-table tbody td input:focus { background:#fff; border-color:#111827; box-shadow: 0 0 0 2px rgba(17,24,39,.14); }
.trx-input-table tbody td input.total-cell, .trx-input-table input.total-cell { background:#fff !important; font-weight:800; color:#111827; }
.trx-input-table tfoot td { background:#fff; color:#111827; padding:8px; border:1px solid #111827; }
.trx-sums-cell { text-align:left; background:#fff; color:#111827; font-weight:800; }

@media (max-width: 1180px) {
  .trx-entry-meta { grid-template-columns: 1fr; }
  .trx-cust-card { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 680px) {
  .card-header-actions {
    width: 100%;
  }
  .card-header-actions .searchbar,
  .card-header-actions > div:not(.btn-exit) {
    width: 100%;
  }
  .trx-entry-meta-stack .trx-meta-field {
    flex-direction: column;
    align-items: stretch;
  }
  .trx-entry-meta-stack .trx-meta-label {
    flex-basis: auto;
    min-width: 0;
    width: 100%;
  }
}

@media (max-width: 560px) {
  .trx-cust-card { grid-template-columns: 1fr; }
}
