/* assets/css/style.css — نظام التنسيق الموحد (خطوط محلية — بدون CDN) */

:root {
  --primary-color: #2563eb;
  --primary-dark: #1d4ed8;
  --secondary-color: #0ea5e9;
  --bg-color: #f1f5f9;
  --sidebar-bg: #ffffff;
  --text-color: #1e293b;
  --text-light: #64748b;
  --border-color: #e2e8f0;
  --white-color: #fff;
  --danger-color: #dc2626;
  --success-color: #16a34a;
  --warning-color: #d97706;
  --info-color: #0891b2;
  --shadow: 0 4px 14px rgba(15, 23, 42, 0.08);
  --radius: 10px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: Tahoma, 'Segoe UI', 'Arabic Typesetting', Arial, sans-serif;
  direction: rtl;
  background-color: var(--bg-color);
  color: var(--text-color);
  line-height: 1.6;
}

.app-container { display: flex; min-height: 100vh; }

.sidebar {
  width: 260px;
  background: var(--sidebar-bg);
  border-left: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  box-shadow: 2px 0 12px rgba(0,0,0,.04);
  overflow: hidden;
  flex-shrink: 0;
}

.sidebar-header {
  padding: 16px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}
.sidebar-brand {
  display: flex; align-items: center; gap: 12px;
  text-decoration: none; color: inherit;
  min-width: 0; flex: 1;
}
.sidebar-brand:hover { color: var(--primary-color); }
.sidebar-logo {
  width: 48px; height: 48px; object-fit: contain;
  border-radius: 10px; background: #f8fafc;
  border: 1px solid var(--border-color); padding: 4px; flex-shrink: 0;
}
.sidebar-logo-placeholder {
  width: 48px; height: 48px; border-radius: 10px;
  background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
  color: #fff; display: flex; align-items: center; justify-content: center;
  font-size: 1.25rem; flex-shrink: 0;
}
.sidebar-brand-text h3 {
  font-size: .95rem; margin: 0; line-height: 1.3;
  color: var(--text-color); font-weight: 800;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.sidebar-header a { text-decoration: none; }

.app-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 20px;
  padding-top: max(10px, env(safe-area-inset-top));
  background: var(--white-color);
  border-bottom: 1px solid var(--border-color);
  gap: 12px;
  flex-wrap: wrap;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.04);
  position: sticky; top: 0; z-index: 200;
}
.header-start { display: flex; align-items: center; gap: 12px; min-width: 0; }
.header-user {
  display: flex; align-items: center; gap: 12px; flex-shrink: 0;
}
.header-user-meta {
  display: flex; flex-direction: column; align-items: flex-end; gap: 2px;
}
.header-user-name { font-weight: 700; font-size: .92rem; color: var(--text-color); }
.user-role-badge {
  background: #eff6ff; color: var(--primary-color);
  padding: 2px 10px; border-radius: 20px;
  font-size: 11px; font-weight: 700;
}
.btn-logout {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 14px; border-radius: 8px;
  background: #fff; color: var(--danger-color);
  border: 1px solid #fecaca; text-decoration: none;
  font-weight: 700; font-size: 13px;
  transition: all .2s;
}
.btn-logout:hover {
  background: var(--danger-color); color: #fff; border-color: var(--danger-color);
  transform: translateY(-1px);
}

.company-logo-placeholder {
  display: inline-flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
  color: #fff; font-weight: 800; border-radius: 8px;
  width: 48px; height: 48px; font-size: 1.1rem;
}
.company-logo-placeholder.large {
  flex-direction: column; width: 160px; height: 100px;
  font-size: 2rem; gap: 6px; border-radius: var(--radius);
}
.company-logo-placeholder.large span { font-size: .75rem; font-weight: 600; opacity: .9; }

.settings-logo-section { margin-bottom: 8px; }
.settings-logo-box {
  display: flex; flex-wrap: wrap; gap: 24px; align-items: flex-start;
  padding: 20px; background: #f8fafc; border-radius: var(--radius);
  border: 1px solid var(--border-color);
}
.settings-logo-preview {
  flex: 0 0 auto; min-width: 160px;
  display: flex; align-items: center; justify-content: center;
  padding: 16px; background: #fff; border-radius: var(--radius);
  border: 1px dashed var(--border-color);
}
.settings-logo-preview img { max-width: 180px; max-height: 90px; object-fit: contain; }
.settings-logo-form { flex: 1; min-width: 260px; }

.login-brand {
  display: flex; align-items: center; gap: 14px; text-align: right;
}
.login-logo {
  max-width: 72px; max-height: 72px; object-fit: contain;
  background: rgba(255,255,255,.15); border-radius: 12px; padding: 6px;
}
.login-logo-placeholder {
  width: 64px; height: 64px; border-radius: 12px;
  background: rgba(255,255,255,.2);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.75rem; flex-shrink: 0;
}
.login-card-header h2 { margin-bottom: .25rem; font-size: 1.35rem; }
.login-card-header p { opacity: .92; font-size: .9rem; }


.sidebar-nav ul { list-style: none; padding: 16px 0; }
.sidebar-nav a {
  display: flex; align-items: center;
  padding: 11px 20px;
  color: var(--text-light);
  text-decoration: none;
  transition: all .2s;
  margin: 2px 10px;
  border-radius: 8px;
  font-weight: 600;
}
.sidebar-nav a:hover, .sidebar-nav a.active {
  background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
  color: var(--white-color);
}
.sidebar-nav a i { margin-left: 12px; width: 20px; text-align: center; }
.nav-separator { margin: 10px 20px; border-top: 1px solid var(--border-color); }

.main-content { flex: 1; display: flex; flex-direction: column; min-width: 0; }

.content-wrapper { padding: 24px; flex: 1; max-width: 1600px; width: 100%; margin: 0 auto; }

.card {
  background: var(--white-color);
  border-radius: var(--radius);
  padding: 0;
  box-shadow: var(--shadow);
  margin-bottom: 20px;
  border: 1px solid var(--border-color);
  overflow: hidden;
}
.card > .card-header, .card-header {
  display: flex; justify-content: space-between; align-items: center;
  flex-wrap: wrap; gap: 12px;
  padding: 18px 22px;
  margin-bottom: 0;
  border-bottom: 1px solid var(--border-color);
  background: #fafbfc;
}
.card-header h3, .card-header h4 { margin: 0; font-size: 1.1rem; font-weight: 800; display: flex; align-items: center; gap: 8px; }
.card-header h3 i, .card-header h4 i { color: var(--primary-color); font-size: 1rem; }
.card-header-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.card-body { padding: 22px; }
.card + .card { margin-top: 0; }

/* أزرار */
.btn {
  padding: 9px 18px;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  transition: all .2s;
  line-height: 1.4;
}
.btn:hover { transform: translateY(-1px); filter: brightness(.96); }
.btn-primary { background: var(--primary-color); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); color: #fff; }
.btn-secondary { background: #64748b; color: #fff; }
.btn-success, .btn-outline-success { border: 1px solid var(--success-color); }
.btn-success { background: var(--success-color); color: #fff; }
.btn-outline-success { background: #fff; color: var(--success-color); }
.btn-danger { background: var(--danger-color); color: #fff; }
.btn-info { background: var(--info-color); color: #fff; }
.btn-warning { background: var(--warning-color); color: #fff; }
.btn-outline-secondary { background: #fff; color: #64748b; border: 1px solid #cbd5e1; }
.btn-outline-primary { background: #fff; color: var(--primary-color); border: 1px solid var(--primary-color); }
.btn-outline-danger { background: #fff; color: var(--danger-color); border: 1px solid var(--danger-color); }
.btn-sm { padding: 5px 10px; font-size: 12px; border-radius: 6px; }
.btn-lg { padding: 12px 28px; font-size: 16px; }

.btn-action {
  padding: 7px 10px;
  border-radius: 6px;
  text-decoration: none;
  font-size: 13px;
  margin: 0 2px;
  color: #fff;
  display: inline-flex;
  align-items: center;
  transition: transform .15s;
}
.btn-action:hover { transform: scale(1.05); color: #fff; }
.btn-edit, .btn-warning.btn-action { background: #f59e0b; }
.btn-delete { background: var(--danger-color); }
.btn-view { background: var(--primary-color); }
.btn-info.btn-action { background: var(--info-color); }

/* تنبيهات */
.alert { padding: 14px 18px; border-radius: 8px; margin-bottom: 16px; border: 1px solid transparent; }
.alert-danger { color: #991b1b; background: #fef2f2; border-color: #fecaca; }
.alert-success { color: #166534; background: #f0fdf4; border-color: #bbf7d0; }
.alert-info { color: #0c4a6e; background: #f0f9ff; border-color: #bae6fd; }
.alert-warning { color: #92400e; background: #fffbeb; border-color: #fde68a; }
.alert ul { margin: 0; padding-right: 18px; }

/* جداول */
.table { width: 100%; border-collapse: collapse; margin-top: 8px; }
.table th, .table td { padding: 12px 14px; text-align: right; border-bottom: 1px solid var(--border-color); vertical-align: middle; }
.table th { background: #f8fafc; font-weight: 700; color: #475569; font-size: 13px; }
.table tbody tr:hover { background: #f8fafc; }
.table-striped tbody tr:nth-child(even) { background: #fafbfc; }
.table-hover tbody tr:hover { background: #f1f5f9; }
.table-light th { background: #f1f5f9; }

/* نماذج */
.form-group { margin-bottom: 16px; }
.form-group label, .form-label { display: block; margin-bottom: 6px; font-weight: 600; font-size: 14px; }
.form-control, .form-select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  font-family: inherit;
  font-size: 14px;
  transition: border-color .2s, box-shadow .2s;
}
.form-control:focus, .form-select:focus {
  border-color: var(--primary-color);
  outline: none;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, .15);
}
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; }
.form-footer { margin-top: 24px; padding-top: 20px; border-top: 1px solid var(--border-color); text-align: left; }
.required, .text-danger { color: var(--danger-color); }

/* بحث */
.search-form-container { margin-bottom: 20px; padding-bottom: 16px; border-bottom: 1px solid var(--border-color); }
.form-inline { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.form-inline .form-control { flex: 1; min-width: 180px; }

.global-search-container { flex-grow: 1; max-width: 520px; }
.global-search-container form { display: flex; position: relative; }
.global-search-input {
  width: 100%; padding: 10px 42px 10px 14px;
  border-radius: 24px; border: 1px solid var(--border-color);
  background: var(--bg-color);
}
.global-search-input:focus {
  background: #fff; border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(37,99,235,.12); outline: none;
}
.global-search-btn {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  background: none; border: none; color: var(--text-light); cursor: pointer; padding: 8px;
}

/* حالات */
.status-badge {
  padding: 5px 12px; border-radius: 20px;
  color: #fff; font-size: 11px; font-weight: 700;
  display: inline-block;
}
.status-paid, .status-cash { background: var(--success-color); }
.status-unpaid, .status-credit { background: var(--danger-color); }
.status-partially_paid { background: var(--warning-color); }
.status-overdue { background: #ea580c; }
.status-cancelled { background: #64748b; }
.status-pending { background: var(--warning-color); }

/* ملخص الفاتورة */
.invoice-summary-box {
  padding: 20px;
  background: #f8fafc;
  border-radius: var(--radius);
  border: 1px solid var(--border-color);
}
.summary-row, .summary-row-input {
  display: flex; justify-content: space-between; align-items: center;
  padding: 8px 0; font-size: 1rem;
}
.summary-row-input input.form-control { width: 120px; text-align: center; font-weight: 700; }
.summary-row.total { font-weight: 800; font-size: 1.35rem; color: var(--primary-color); border-top: 2px solid var(--border-color); margin-top: 8px; padding-top: 12px; }

/* بطاقات معلومات */
.info-widget {
  display: flex; align-items: center;
  padding: 1.25rem 1.5rem;
  border-radius: var(--radius);
  color: #fff;
  box-shadow: var(--shadow);
  gap: 1rem;
}
.info-widget-icon { font-size: 2.5rem; opacity: .85; }
.info-widget-label { font-size: .9rem; opacity: .92; }
.info-widget-amount { font-size: 1.75rem; font-weight: 800; }
.fund-balance-widget, .receivables-widget, .payables-widget, .sales-widget {
  display: flex; align-items: center;
  padding: 1.25rem 1.5rem; border-radius: var(--radius);
  color: #fff; box-shadow: var(--shadow); gap: 1rem;
}
.fund-balance-widget { background: linear-gradient(135deg, #2563eb, #0ea5e9); }
.receivables-widget, .sales-widget { background: linear-gradient(135deg, #16a34a, #22c55e); }
.payables-widget { background: linear-gradient(135deg, #dc2626, #f87171); }

/* تقارير */
.reports-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 20px;
  margin-top: 16px;
}
.report-item {
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 22px;
  text-align: center;
  display: flex; flex-direction: column;
  background: #fff;
  transition: box-shadow .2s, transform .2s;
}
.report-item:hover { box-shadow: var(--shadow); transform: translateY(-2px); }
.report-item i { font-size: 2.5rem; color: var(--primary-color); margin-bottom: 12px; }
.report-item p { color: var(--text-light); font-size: .9rem; flex-grow: 1; }
.report-item a { margin-top: 14px; }

.app-footer {
  text-align: center; padding: 16px;
  background: var(--white-color);
  border-top: 1px solid var(--border-color);
  color: var(--text-light); font-size: 13px;
}
.app-footer a { color: var(--primary-color); text-decoration: none; font-weight: 600; }

/* Choices.js RTL */
.choices__inner { border-radius: 8px !important; min-height: 42px !important; }
.choices__list--dropdown .choices__item { direction: rtl; text-align: right; }

@media (max-width: 768px) {
  .btn-logout span { display: none; }
}

/* ─── قائمة جانبية وشريط علوي (موبايل/تابلت) ─── */
.sidebar-toggle,
.sidebar-close {
  display: none;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  border: 1px solid var(--border-color);
  border-radius: 10px;
  background: #fff;
  color: var(--text-color);
  cursor: pointer;
  flex-shrink: 0;
  transition: background .2s, border-color .2s, color .2s;
}
.sidebar-toggle:hover,
.sidebar-close:hover {
  background: #eff6ff;
  border-color: #bfdbfe;
  color: var(--primary-color);
}
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  z-index: 1040;
  backdrop-filter: blur(2px);
}
.sidebar-overlay.is-visible { display: block; }
body.sidebar-open { overflow: hidden; }

.sidebar { overflow: hidden; }
.sidebar-nav { flex: 1; overflow-y: auto; overflow-x: hidden; -webkit-overflow-scrolling: touch; }

@media (max-width: 991.98px) {
  .invoice-items-table .th-product,
  .invoice-items-table .th-qty,
  .invoice-items-table .th-price,
  .invoice-items-table .th-total,
  .invoice-items-table .th-action {
    width: auto;
    min-width: 88px;
  }
  .summary-row-input input.form-control { width: 100%; max-width: 140px; }
  .input-w-xs { width: 100% !important; max-width: none; }

  .sidebar-toggle { display: inline-flex; }

  .sidebar {
    position: fixed;
    top: 0;
    right: 0;
    width: min(300px, 88vw);
    height: 100vh;
    height: 100dvh;
    z-index: 1050;
    transform: translateX(100%);
    transition: transform .28s ease;
    box-shadow: -8px 0 24px rgba(15, 23, 42, 0.18);
    padding-bottom: env(safe-area-inset-bottom);
  }
  .sidebar.is-open { transform: translateX(0); }
  .sidebar-close { display: inline-flex; }

  .app-container { flex-direction: column; }
  .main-content { width: 100%; min-height: 100vh; min-height: 100dvh; }

  .app-header {
    padding-inline: 12px;
    gap: 10px;
  }
  .header-start {
    flex: 1 1 auto;
    min-width: 0;
    max-width: calc(100% - 120px);
  }
  .header-title h1 {
    font-size: 1rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .global-search-container {
    order: 3;
    flex: 1 1 100%;
    max-width: none;
    width: 100%;
  }
  .header-user-meta { display: none; }
  .header-user { margin-right: auto; }

  .content-wrapper { padding: 14px 12px; }

  .card-header:not(.statement-page-header) {
    flex-direction: column;
    align-items: stretch !important;
  }
  .card-header-actions,
  .card-header:not(.statement-page-header) .btn-group,
  .card-header:not(.statement-page-header) > .btn {
    width: 100%;
  }
  .card-header-actions .btn,
  .card-header:not(.statement-page-header) .btn-group .btn,
  .card-header:not(.statement-page-header) > .btn {
    justify-content: center;
  }
  .card-body { padding: 16px; }

  .dashboard-stats {
    grid-template-columns: 1fr;
    gap: 12px;
  }
  .charts-container {
    grid-template-columns: 1fr;
  }
  .chart-card .card-body { min-height: 260px; }

  .quick-actions { flex-direction: column; }
  .quick-action-btn { min-width: 0; width: 100%; }

  .cashbox-summary,
  .cashbox-summary-grid {
    grid-template-columns: 1fr;
  }

  .form-inline {
    flex-direction: column;
    align-items: stretch;
  }
  .form-inline .form-control,
  .form-inline .btn {
    width: 100%;
  }

  .filter-form .form-row,
  .filter-grid {
    grid-template-columns: 1fr;
  }

  .form-row { grid-template-columns: 1fr; }

  .page-toolbar,
  .form-footer,
  .form-group-buttons {
    flex-direction: column;
    align-items: stretch;
  }
  .page-toolbar .btn,
  .form-footer .btn,
  .form-group-buttons .btn {
    width: 100%;
    justify-content: center;
  }

  .reports-list { grid-template-columns: 1fr; }

  .statement-header {
    flex-direction: column;
    align-items: stretch;
  }
  .statement-header .btn-group {
    display: flex;
    flex-direction: column;
    width: 100%;
  }
  .statement-header .btn { width: 100%; }

  .steps { flex-direction: column; }


  .btn,
  .sidebar-nav a,
  .btn-action,
  .global-search-btn {
    min-height: 44px;
  }
  .btn-action {
    width: 40px;
    height: 40px;
  }

  .form-control,
  .form-select,
  .global-search-input {
    font-size: 16px;
  }

  .table { font-size: .88rem; }
  .table th,
  .table td {
    padding: .55rem .45rem;
    vertical-align: middle;
  }

  .card-body > table,
  .content-wrapper > table {
    display: block;
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .login-card { max-width: 100%; }
  .login-brand { flex-direction: column; text-align: center; }
  .settings-logo-box { flex-direction: column; }
  .settings-logo-form { min-width: 0; width: 100%; }

  .app-footer {
    padding-bottom: max(16px, env(safe-area-inset-bottom));
    font-size: 12px;
    line-height: 1.7;
  }
}

@media (min-width: 992px) {
  .sidebar-toggle,
  .sidebar-close,
  .sidebar-overlay { display: none !important; }
  .sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    height: 100dvh;
  }
}

@media (min-width: 576px) and (max-width: 991.98px) {
  .dashboard-stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (min-width: 1200px) {
  .content-wrapper { padding: 28px 32px; }
}

@media (max-width: 575.98px) {
  .stat-card {
    padding: 14px;
  }
  .stat-card-icon {
    width: 48px;
    height: 48px;
    font-size: 18px;
    margin-left: 12px;
  }
  .stat-card-info p { font-size: 1.15rem; }
  .info-widget-amount,
  .cashbox-summary .summary-card p {
    font-size: 1.35rem;
  }
  .card-header h3,
  .card-header h4 {
    font-size: 1rem;
  }
  .nav-pills.card-header-pills {
    flex-direction: column;
    width: 100%;
  }
  .nav-pills.card-header-pills .nav-link {
    text-align: center;
  }
}

@media (max-width: 380px) {
  .header-title h1 { max-width: 140px; }
  .btn-logout {
    padding: 8px 10px;
  }
}

/* ─── Sidebar extras ─── */
.sidebar-business-type {
  display: block;
  color: var(--text-light);
  padding: 0 20px 8px;
  font-size: 11px;
}
.footer-heart { color: #e74c3c; vertical-align: middle; }

/* ─── Dashboard ─── */
.dashboard-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 20px;
  margin-bottom: 28px;
}
.stat-card {
  background: var(--white-color);
  border-radius: var(--radius);
  padding: 20px;
  display: flex;
  align-items: center;
  box-shadow: var(--shadow);
  border: 1px solid var(--border-color);
  transition: transform .2s, box-shadow .2s;
}
.stat-card:hover { transform: translateY(-2px); box-shadow: 0 8px 20px rgba(15,23,42,.1); }
.stat-card-icon {
  width: 56px; height: 56px; border-radius: 50%;
  display: flex; justify-content: center; align-items: center;
  color: #fff; font-size: 22px; margin-left: 16px; flex-shrink: 0;
}
.stat-icon-green { background: linear-gradient(135deg, #16a34a, #22c55e); }
.stat-icon-blue { background: linear-gradient(135deg, #2563eb, #0ea5e9); }
.stat-icon-red { background: linear-gradient(135deg, #dc2626, #f87171); }
.stat-icon-orange { background: linear-gradient(135deg, #d97706, #fbbf24); }
.stat-icon-teal { background: linear-gradient(135deg, #0d9488, #2dd4bf); }
.stat-icon-purple { background: linear-gradient(135deg, #7c3aed, #a78bfa); }
.stat-card-info h4 { margin: 0; color: var(--text-light); font-size: 14px; font-weight: 600; }
.stat-card-info p { margin: 4px 0 0; font-size: 1.35rem; font-weight: 800; }

.quick-actions { display: flex; gap: 14px; flex-wrap: wrap; }
.quick-action-btn {
  flex: 1; min-width: 140px; padding: 18px 14px;
  background: var(--bg-color); border-radius: var(--radius);
  text-align: center; text-decoration: none; color: var(--text-color);
  border: 1px solid var(--border-color);
  transition: transform .2s, box-shadow .2s, border-color .2s;
  font-weight: 600;
}
.quick-action-btn:hover {
  transform: translateY(-3px); box-shadow: var(--shadow);
  border-color: var(--primary-color); color: var(--primary-color);
}
.quick-action-btn i { font-size: 1.5rem; display: block; margin-bottom: 8px; color: var(--primary-color); }

.charts-container {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
  gap: 20px;
  margin-bottom: 28px;
}
.chart-card .card-body { min-height: 320px; position: relative; }

/* ─── جداول وإجراءات ─── */
.table-responsive { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table-empty, .text-center.text-muted { text-align: center !important; color: var(--text-light) !important; padding: 28px 16px !important; }
.actions-cell { white-space: nowrap; }
.btn-group-actions { display: inline-flex; align-items: center; gap: 4px; flex-wrap: nowrap; }

.low-stock { background-color: #fffbeb !important; }
.out-of-stock { background-color: #fef2f2 !important; color: #991b1b !important; }

.status-accepted { background: var(--success-color); }
.status-rejected { background: var(--danger-color); }

.card.shadow-sm { box-shadow: var(--shadow); }

/* ─── ملخصات وتقارير ─── */
.cashbox-summary, .cashbox-summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 18px;
  margin: 16px 0;
}
.cashbox-summary .summary-card {
  padding: 22px;
  border-radius: var(--radius);
  color: #fff;
  box-shadow: var(--shadow);
}
.cashbox-summary .summary-card h4 { font-size: .95rem; opacity: .92; margin-bottom: 8px; font-weight: 600; }
.cashbox-summary .summary-card p { font-size: 1.75rem; font-weight: 800; margin: 0; }
.cash-in { background: linear-gradient(135deg, #16a34a, #22c55e); }
.cash-out { background: linear-gradient(135deg, #dc2626, #ef4444); }
.balance.positive { background: linear-gradient(135deg, #2563eb, #0ea5e9); }

.filter-form .form-row,
.filter-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
  align-items: end;
}
.form-group-buttons { display: flex; gap: 10px; flex-wrap: wrap; }

.report-header { text-align: center; margin: 24px 0; }
.report-header h4 { font-size: 1.1rem; color: var(--text-color); }

.report-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 14px;
  margin-bottom: 24px;
  text-align: center;
}
.report-summary .summary-item {
  padding: 16px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  background: #fafbfc;
}
.report-summary .summary-item span { display: block; color: var(--text-light); margin-bottom: 6px; font-size: .88rem; }
.report-summary .summary-item strong { font-size: 1.35rem; font-weight: 800; }
.report-summary .summary-item.profit strong,
.summary-item.net-profit strong { color: var(--success-color); }
.report-summary .summary-item.expense strong,
.summary-item.expense strong { color: var(--danger-color); }

/* ─── عرض المستندات (فواتير، سندات، مرتجعات) ─── */
.invoice-view-container { max-width: 960px; margin: 0 auto; }
.invoice-actions, .expense-actions, .document-actions {
  display: flex; justify-content: space-between; align-items: center;
  flex-wrap: wrap; gap: 12px;
  margin-bottom: 20px; padding: 16px 20px;
  background: var(--white-color); border-radius: var(--radius);
  box-shadow: var(--shadow); border: 1px solid var(--border-color);
}
.invoice-actions h3, .document-actions h3 { margin: 0; font-size: 1.1rem; }
.invoice-actions .btn-group-actions, .document-actions .btn-group-actions { display: flex; gap: 8px; }

.invoice-box, .expense-box, .document-box {
  background: var(--white-color);
  padding: 32px;
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow);
  border-radius: var(--radius);
  max-width: 820px;
  margin: 0 auto;
}
.invoice-box header h1, .document-box header h1 {
  text-align: center; margin-bottom: 24px; font-size: 1.5rem;
}
.invoice-box header .row,
.invoice-box footer .row,
.document-box .row {
  display: flex; justify-content: space-between; flex-wrap: wrap; gap: 16px;
  margin-bottom: 20px;
}
.invoice-meta { text-align: left; }
.items-table { width: 100%; border-collapse: collapse; margin-top: 24px; }
.items-table th, .items-table td {
  padding: 11px 12px; border-bottom: 1px solid var(--border-color); text-align: right;
}
.items-table th { background: #f8fafc; font-weight: 700; }
.invoice-summary { margin-top: 32px; border-top: 2px solid #334155; padding-top: 20px; }
.invoice-summary .totals table { width: 100%; }
.invoice-summary .totals td { padding: 6px 0; }
.invoice-summary .totals td:last-child { text-align: left; font-weight: 700; }
.total-row td { font-size: 1.2rem; color: var(--primary-color); font-weight: 800; }
.details-table { width: 100%; }
.details-table td { padding: 12px; border-bottom: 1px solid var(--border-color); }
.amount-negative { color: var(--danger-color); font-weight: 700; font-size: 1.15rem; }

/* ─── صفحات النماذج (فواتير، مشتريات) ─── */
.invoice-form-widgets {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}
.fund-balance-icon, .payables-icon, .receivables-icon, .info-widget-icon { font-size: 2.5rem; margin-left: 1rem; opacity: .85; }
.fund-balance-label, .payables-label, .receivables-label, .info-widget-label { font-size: .92rem; opacity: .9; }
.fund-balance-amount, .payables-amount, .receivables-amount, .info-widget-amount { font-size: 1.75rem; font-weight: 800; }
#barcode-search:focus { border-color: var(--primary-color); box-shadow: 0 0 0 3px rgba(37,99,235,.15); }

.invoice-summary-alt {
  width: 100%; max-width: 420px; margin-top: 24px; margin-right: auto;
  padding: 18px; background: #f8fafc; border-radius: var(--radius);
  border: 1px solid var(--border-color);
}
.summary-item, .summary-item-input {
  display: flex; justify-content: space-between; align-items: center; padding: 8px 0;
}
.summary-item-input input { width: 110px; text-align: center; font-weight: 700; }
.summary-item.total { font-weight: 800; font-size: 1.15rem; border-top: 2px solid var(--border-color); margin-top: 8px; padding-top: 10px; }

/* ─── بحث شامل ─── */
.results-list { display: flex; flex-direction: column; gap: 10px; margin-top: 10px; }
.result-item {
  display: block; padding: 14px 16px; background: #f8fafc;
  border-radius: 8px; text-decoration: none; color: var(--text-color);
  border: 1px solid var(--border-color);
  transition: background .2s, border-color .2s;
}
.result-item:hover { background: #eff6ff; border-color: var(--primary-color); }
.result-item strong { display: block; margin-bottom: 4px; }
.result-item small { color: var(--text-light); }
.card-body hr { border: none; border-top: 1px solid var(--border-color); margin: 22px 0; }
.card-body h4 { margin-bottom: 10px; padding-bottom: 10px; border-bottom: 1px solid var(--border-color); }
.card-body h4 i { margin-left: 8px; color: var(--primary-color); }

/* ─── تسجيل الدخول والإعداد ─── */
.login-page {
  font-family: Tahoma, 'Segoe UI', 'Arabic Typesetting', Arial, sans-serif;
  background: linear-gradient(135deg, #eff6ff 0%, #f1f5f9 50%, #e0f2fe 100%);
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh; padding: 20px;
}
.login-card {
  width: 100%; max-width: 420px;
  border: none; box-shadow: 0 12px 40px rgba(15,23,42,.12);
  border-radius: var(--radius); overflow: hidden;
}
.login-card-header {
  background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
  color: #fff; padding: 1.75rem; text-align: center;
}
.login-card-header h2 { margin-bottom: .35rem; font-weight: 800; }

.setup-page {
  background: var(--bg-color);
  font-family: Tahoma, 'Segoe UI', 'Arabic Typesetting', Arial, sans-serif;
  min-height: 100vh; padding: 24px 16px;
}
.setup-wrap { max-width: 860px; margin: 0 auto; }
.type-card {
  border: 2px solid var(--border-color); border-radius: var(--radius);
  padding: 18px; cursor: pointer; transition: .2s; height: 100%;
  background: #fff;
}
.type-card:hover, .type-card.selected {
  border-color: var(--primary-color); background: #eff6ff;
}
.type-card input { display: none; }
.steps { display: flex; gap: 8px; margin-bottom: 24px; }
.steps span {
  flex: 1; text-align: center; padding: 10px 8px;
  border-radius: 8px; background: #e2e8f0; font-size: .88rem; font-weight: 600;
}
.steps span.active { background: var(--primary-color); color: #fff; }

/* ─── طباعة ─── */
@media print {
  .sidebar, .sidebar-toggle, .sidebar-close, .sidebar-overlay, .app-header, .app-footer, .no-print, .search-form-container, .btn, form.no-print { display: none !important; }
  body, .app-container, .main-content, .content-wrapper { background: #fff !important; padding: 0 !important; margin: 0 !important; }
  .card { box-shadow: none !important; border: none !important; }
  .invoice-box, .document-box, .expense-box { box-shadow: none; border: none; max-width: 100%; padding: 0; }
}

/* ─── Bootstrap RTL tweaks ─── */
.input-group-text { background: #f8fafc; border-color: var(--border-color); }
.btn-close { float: left; }
.header-title h1 { font-size: 1.25rem; margin: 0; font-weight: 700; color: var(--text-color); }
.card-header .btn { flex-shrink: 0; }
.text-end { text-align: end !important; }

/* ─── طباعة نسخ متعددة للفواتير ─── */
@media print {
  body > *:not(#print-container) { display: none !important; }
  #print-container, #print-container * { visibility: visible !important; }
  .invoice-box-copy {
    page-break-after: always;
    position: relative;
    width: 210mm;
    height: 297mm;
    padding: 1.5cm;
    box-sizing: border-box;
    overflow: hidden !important;
  }
  .invoice-box-copy:last-child { page-break-after: avoid; }
}

/* ─── كشوف الحساب ─── */
.statement-page { padding: 0; overflow: hidden; }

.statement-page-header {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 18px 22px;
  background: #fafbfc;
  border-bottom: 1px solid var(--border-color);
}

.statement-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.statement-title {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--primary-color);
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.statement-title span {
  overflow: hidden;
  text-overflow: ellipsis;
}

.statement-toolbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.statement-toolbar-actions .btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  width: auto;
}

.statement-filter-form {
  display: grid;
  grid-template-columns: minmax(160px, 1fr) minmax(160px, 1fr) auto;
  gap: 12px;
  align-items: end;
  padding: 14px 16px;
  background: #fff;
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
}

.statement-filter-field .form-label {
  margin-bottom: 6px;
  font-size: .88rem;
  font-weight: 600;
  color: var(--text-light);
}

.statement-filter-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: nowrap;
}

.statement-filter-actions .btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  width: auto;
}

.statement-page .card-body { padding: 22px; }

.statement-table thead th {
  font-size: .88rem;
  white-space: nowrap;
}

.statement-header {
  display: flex; justify-content: space-between; align-items: center;
  flex-wrap: wrap; gap: 12px; margin-bottom: 1.25rem;
}

.statement-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  margin-top: 24px;
  padding-top: 24px;
  border-top: 1px solid var(--border-color);
}

.statement-summary .summary-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 1.1rem 1.25rem;
  border-radius: var(--radius);
  background: #f8fafc;
  border: 1px solid var(--border-color);
  color: var(--text-color);
  min-height: 92px;
}

.statement-summary .summary-card i {
  font-size: 1.6rem;
  flex-shrink: 0;
  margin: 0;
}

.statement-summary .summary-card small {
  color: var(--text-light);
  display: block;
  margin-bottom: 4px;
  line-height: 1.4;
}

.statement-summary .summary-card strong {
  font-size: 1.2rem;
  font-weight: 800;
  color: var(--text-color);
  word-break: break-word;
}

.statement-summary .summary-card-balance {
  background: #eff6ff;
  border-color: rgba(37, 99, 235, .28);
}

@media (max-width: 991.98px) {
  .statement-filter-form {
    grid-template-columns: 1fr 1fr;
  }
  .statement-filter-actions {
    grid-column: 1 / -1;
    justify-content: stretch;
  }
  .statement-filter-actions .btn {
    flex: 1;
    justify-content: center;
  }
  .statement-summary {
    grid-template-columns: 1fr;
  }
  .statement-toolbar-actions {
    width: 100%;
  }
  .statement-toolbar-actions .btn {
    flex: 1;
    justify-content: center;
  }
}

@media (max-width: 575.98px) {
  .statement-filter-form {
    grid-template-columns: 1fr;
  }
  .statement-page-header { padding: 14px; }
  .statement-page .card-body { padding: 14px; }
}
.debit-card { background: linear-gradient(135deg, #dc2626, #f87171); color: #fff; border: none; }
.credit-card { background: linear-gradient(135deg, #16a34a, #22c55e); color: #fff; border: none; }
.balance-card { background: linear-gradient(135deg, #2563eb, #0ea5e9); color: #fff; border: none; }
.debit-card i, .credit-card i, .balance-card i { color: #fff !important; opacity: .85; }

.transactions-table { font-size: .92rem; }
.transactions-table thead { background: #f8fafc; border-bottom: 2px solid var(--border-color); }
.transactions-table td { vertical-align: middle; }
.opening-balance-row { background: #f1f5f9; font-style: italic; }

.badge.bg-success-soft {
  background: rgba(22, 163, 74, .12);
  color: #15803d;
  font-size: .85em;
  padding: .45em .7em;
  border-radius: 6px;
  font-weight: 700;
}
.badge.bg-danger-soft {
  background: rgba(220, 38, 38, .12);
  color: #b91c1c;
  font-size: .85em;
  padding: .45em .7em;
  border-radius: 6px;
  font-weight: 700;
}

.print-header { display: none; text-align: center; margin-bottom: 1.5rem; }
@media print {
  body * { visibility: hidden; }
  .no-print { display: none !important; }
  #statement-card, #statement-card *,
  .statement-page, .statement-page * { visibility: visible; }
  #statement-card, .statement-page {
    position: absolute; left: 0; top: 0; width: 100%;
    border: none !important; box-shadow: none !important;
    padding: 0; margin: 0;
  }
  .print-header { display: block; }
  .statement-summary .summary-card,
  .debit-card, .credit-card, .balance-card {
    color: #000 !important;
    background: #f8fafc !important;
    border: 1px solid #ccc !important;
    box-shadow: none !important;
  }
}

/* ─── أدوات عامة ─── */
.is-hidden { display: none !important; }
.form-page { max-width: 780px; }
.form-text { font-size: .85rem; color: var(--text-light); margin-top: 4px; }
.form-footer {
  margin-top: 24px; padding-top: 20px;
  border-top: 1px solid var(--border-color);
  display: flex; gap: 10px; flex-wrap: wrap;
}
.page-toolbar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
}
.input-w-xs { width: 72px !important; max-width: 72px; display: inline-block; }
.invoice-logo, .company-logo { max-height: 80px; width: auto; object-fit: contain; }
.amount-in { color: var(--success-color) !important; font-weight: 700; }
.amount-out { color: var(--danger-color) !important; font-weight: 700; }
.amount-neutral { color: var(--text-light) !important; }

.invoice-items-table .th-product { width: 40%; }
.invoice-items-table .th-qty { width: 12%; }
.invoice-items-table .th-price { width: 15%; }
.invoice-items-table .th-total { width: 18%; }
.invoice-items-table .th-action { width: 10%; }

.sidebar { overflow: hidden; }
.sidebar-nav { flex: 1; overflow-y: auto; overflow-x: hidden; }

.badge { font-weight: 700; padding: .4em .65em; border-radius: 6px; }
.badge.bg-success { background: #dcfce7 !important; color: #166534 !important; }
.badge.bg-danger { background: #fee2e2 !important; color: #991b1b !important; }
.badge.bg-secondary { background: #f1f5f9 !important; color: #475569 !important; }

a { color: var(--primary-color); }
a:hover { color: var(--primary-dark); }
.table a { text-decoration: none; font-weight: 600; }
.table a:hover { text-decoration: underline; }

.card-header.bg-primary,
.card-header.bg-light.text-white,
.card-header.bg-primary.text-white {
  background: #fafbfc !important;
  color: var(--text-color) !important;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
}
.stat-grid .stat-item {
  padding: 14px;
  background: #f8fafc;
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
}
.stat-grid .stat-item strong { display: block; font-size: 1.2rem; margin-top: 4px; }
.stat-grid .stat-item span { font-size: .85rem; color: var(--text-light); }

.mt-section { margin-top: 1.25rem; }

/* ─── PWA ─── */
.pwa-install-overlay {
  position: fixed;
  inset: 0;
  z-index: 3000;
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.pwa-install-overlay.is-hidden { display: none !important; }
body.pwa-modal-open { overflow: hidden; }

.pwa-install-dialog {
  position: relative;
  width: min(440px, 100%);
  background: #fff;
  border-radius: 16px;
  padding: 24px;
  box-shadow: 0 20px 50px rgba(15, 23, 42, 0.25);
  animation: pwaSlideIn .28s ease;
}
@keyframes pwaSlideIn {
  from { opacity: 0; transform: translateY(12px) scale(.98); }
  to { opacity: 1; transform: none; }
}
.pwa-install-close {
  position: absolute;
  top: 10px;
  left: 12px;
  border: none;
  background: transparent;
  font-size: 1.75rem;
  line-height: 1;
  color: var(--text-light);
  cursor: pointer;
}
.pwa-install-brand {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 14px;
}
.pwa-install-app-icon {
  border-radius: 18%;
  box-shadow: var(--shadow);
  flex-shrink: 0;
}
.pwa-install-brand h4 {
  margin: 0 0 4px;
  font-size: 1.15rem;
  font-weight: 800;
}
.pwa-install-subtitle {
  margin: 0;
  color: var(--text-light);
  font-size: .88rem;
}
.pwa-install-message {
  margin: 0 0 12px;
  color: var(--text-color);
  line-height: 1.6;
}
.pwa-install-steps {
  margin: 0 0 16px;
  padding-right: 20px;
  color: var(--text-color);
  font-size: .92rem;
  line-height: 1.7;
}
.pwa-install-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}
.pwa-install-actions .btn {
  flex: 1;
  min-width: 120px;
  justify-content: center;
}

.pwa-install-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 12px 16px;
  margin-bottom: 16px;
  border-radius: var(--radius);
  background: linear-gradient(135deg, #eff6ff, #dbeafe);
  border: 1px solid #bfdbfe;
}
.pwa-install-text {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  color: var(--text-color);
}
.pwa-install-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}
.pwa-install-actions #pwaInstallDismiss {
  min-width: 36px;
  padding-inline: 10px;
  font-size: 1.2rem;
  line-height: 1;
}

.settings-pwa-section { margin-top: 8px; }
.pwa-icon-preview-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: flex-end;
  padding: 16px;
  background: #f8fafc;
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
}
.pwa-icon-preview-item {
  text-align: center;
}
.pwa-icon-preview-item img {
  display: block;
  margin: 0 auto 6px;
  border-radius: 18%;
  box-shadow: var(--shadow);
  background: #fff;
}
.pwa-icon-preview-item small {
  color: var(--text-light);
  font-size: .78rem;
}
.pwa-settings-form .form-control-color {
  height: 42px;
  padding: 4px;
}

@media (max-width: 575.98px) {
  .pwa-install-banner {
    flex-direction: column;
    align-items: stretch;
  }
  .pwa-install-actions {
    width: 100%;
  }
  .pwa-install-actions .btn {
    flex: 1;
  }
}

