:root {
  color-scheme: light;
  --bg: #f5f7fb;
  --surface: #ffffff;
  --surface-soft: #f9fafc;
  --text: #152033;
  --muted: #6b7280;
  --line: #dfe5ee;
  --primary: #2563eb;
  --primary-strong: #1746b8;
  --primary-soft: #eaf1ff;
  --success: #0f9f6e;
  --warning: #b7791f;
  --warning-bg: #fff8df;
  --info: #315bb8;
  --info-bg: #eef5ff;
  --danger: #d73b3e;
  --shadow: 0 16px 40px rgba(27, 39, 66, 0.08);
  --radius: 8px;
  --sidebar-width: 286px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(180deg, rgba(37, 99, 235, 0.06), transparent 260px),
    var(--bg);
  color: var(--text);
  font-family: "Tajawal", "Segoe UI", Tahoma, Arial, sans-serif;
  letter-spacing: 0;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 22px;
  padding: 22px 16px;
  background: #101827;
  color: #eef4ff;
  border-left: 1px solid rgba(255, 255, 255, 0.08);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 8px 18px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 8px;
  background: linear-gradient(135deg, #2dd4bf, #2563eb);
  color: #ffffff;
  font-weight: 800;
}

.brand strong {
  display: block;
  font-size: 25px;
  line-height: 1;
}

.brand span,
.db-card span {
  display: block;
  margin-top: 4px;
  color: #aab6cb;
  font-size: 13px;
}

.nav-sections {
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-height: 0;
  overflow-y: auto;
}

.nav-item,
.nav-submenu a {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 42px;
  padding: 10px 12px;
  border: 0;
  border-radius: var(--radius);
  background: transparent;
  color: #dce7f7;
  text-decoration: none;
  transition: background 160ms ease, color 160ms ease, transform 160ms ease;
}

.nav-item:hover,
.nav-submenu a:hover,
.nav-item.is-active {
  background: rgba(37, 99, 235, 0.22);
  color: #ffffff;
}

.nav-item:hover,
.nav-submenu a:hover {
  transform: translateX(-2px);
}

.nav-item svg {
  width: 19px;
  height: 19px;
}

.nav-toggle {
  width: 100%;
  text-align: start;
}

.nav-toggle svg:last-child {
  margin-inline-start: auto;
  width: 16px;
}

.nav-submenu {
  display: grid;
  gap: 3px;
  margin: -2px 30px 6px 0;
}

.nav-submenu a {
  min-height: 34px;
  padding: 7px 12px;
  color: #b9c6d8;
  font-size: 14px;
}

.db-card {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: auto;
  padding: 14px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.06);
}

.db-card svg {
  color: #2dd4bf;
}

.main {
  min-width: 0;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: 72px;
  padding: 12px 28px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(14px);
}

.menu-button {
  display: none;
}

.branch-pill,
.user-chip,
.search-box {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.branch-pill {
  padding: 0 13px;
  color: var(--muted);
  white-space: nowrap;
}

.search-box {
  flex: 1;
  padding: 0 13px;
}

.search-box input {
  width: 100%;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.icon-button,
.text-button,
.primary-button,
.secondary-button,
.ghost-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
}

.icon-button {
  width: 42px;
}

.icon-button svg,
.text-button svg,
.primary-button svg,
.secondary-button svg,
.ghost-button svg,
.quick-actions svg,
.notice svg {
  width: 18px;
  height: 18px;
}

.text-button {
  padding: 0 15px;
  color: var(--primary);
  font-weight: 700;
}

.primary-button,
.secondary-button,
.ghost-button {
  padding: 0 16px;
  font-weight: 700;
}

.primary-button {
  border-color: var(--primary);
  background: var(--primary);
  color: #ffffff;
}

.primary-button:hover {
  background: var(--primary-strong);
}

.secondary-button,
.ghost-button {
  color: var(--primary);
}

.ghost-button {
  border-color: transparent;
  background: var(--primary-soft);
}

.user-chip {
  padding: 0 8px 0 12px;
  font-weight: 700;
  white-space: nowrap;
}

.avatar {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #e8eef7;
  color: #334155;
  font-size: 12px;
}

.page-head,
.alerts-grid,
.metrics-grid,
.quick-actions,
.workspace-grid {
  width: min(1280px, calc(100% - 48px));
  margin-inline: auto;
}

.page-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 22px;
  padding: 36px 0 22px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--primary);
  font-size: 14px;
  font-weight: 800;
}

.page-head h1 {
  margin: 0;
  font-size: 34px;
  line-height: 1.2;
}

.page-head p {
  margin: 8px 0 0;
  color: var(--muted);
}

.head-actions {
  display: flex;
  gap: 10px;
}

.alerts-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.notice {
  position: relative;
  display: flex;
  gap: 12px;
  min-height: 96px;
  padding: 18px 18px 16px 46px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.notice-info {
  background: var(--info-bg);
  color: var(--info);
}

.notice-warning {
  background: var(--warning-bg);
  color: var(--warning);
}

.notice strong {
  color: inherit;
}

.notice p {
  margin: 6px 0 0;
  color: #4b5563;
  line-height: 1.7;
}

.close-notice {
  position: absolute;
  top: 14px;
  left: 14px;
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: currentColor;
}

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
  margin-top: 18px;
}

.metric-card,
.panel,
.quick-actions button {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.metric-card {
  padding: 18px;
}

.metric-label {
  color: var(--muted);
  font-weight: 700;
}

.metric-card strong {
  display: block;
  margin-top: 10px;
  font-size: 29px;
  color: var(--text);
}

.metric-card small {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
  color: var(--muted);
}

.trend-positive {
  color: var(--success) !important;
}

.quick-actions {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 14px;
  margin-top: 18px;
}

.quick-actions button {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 104px;
  border-color: #d9e1ec;
  color: var(--text);
  font-weight: 700;
}

.quick-actions button:hover {
  border-color: var(--primary);
  background: var(--primary-soft);
  color: var(--primary);
}

.workspace-grid {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(280px, 0.9fr);
  gap: 16px;
  margin-top: 18px;
  padding-bottom: 34px;
}

.panel {
  padding: 0;
  overflow: hidden;
}

.panel-large {
  grid-row: span 2;
}

.panel-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 14px;
  padding: 18px;
  border-bottom: 1px solid var(--line);
}

.panel h2 {
  margin: 0;
  font-size: 20px;
}

.panel p {
  margin: 5px 0 0;
  color: var(--muted);
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 720px;
}

th,
td {
  padding: 15px 18px;
  border-bottom: 1px solid var(--line);
  text-align: right;
}

th {
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 14px;
}

td strong {
  display: block;
}

.status {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 4px 10px;
  border-radius: 999px;
  background: #dcfce7;
  color: #08754f;
  font-weight: 800;
  font-size: 13px;
}

.status-paid {
  background: #dcfce7;
  color: #08754f;
}

.status-pending {
  background: #fef3c7;
  color: #9a5b00;
}

.status-draft {
  background: #eaf1ff;
  color: #1d4ed8;
}

.status-void {
  background: #fee2e2;
  color: #b42318;
}

.cash-ring {
  display: grid;
  place-items: center;
  width: 164px;
  height: 164px;
  margin: 24px auto;
  border-radius: 50%;
  background:
    radial-gradient(circle at center, var(--surface) 58%, transparent 59%),
    conic-gradient(var(--success) 0 100%, #e5e7eb 0);
  text-align: center;
}

.cash-ring strong {
  display: block;
  font-size: 31px;
}

.cash-ring span {
  color: var(--muted);
}

.mini-list,
.task-list {
  display: grid;
  gap: 10px;
  padding: 0 18px 18px;
  margin: 0;
}

.mini-list li,
.task-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 42px;
  padding: 10px 12px;
  border-radius: var(--radius);
  background: var(--surface-soft);
  color: var(--muted);
}

.mini-list li {
  list-style: none;
}

.mini-list strong,
.task-item strong {
  color: var(--text);
}

.task-item {
  border: 0;
  width: calc(100% - 36px);
  margin-inline: 18px;
  text-align: start;
}

.screen-view[hidden],
.dashboard-view[hidden] {
  display: none !important;
}

.compact-head {
  align-items: center;
}

.invoice-toolbar,
.invoice-grid,
.invoice-editor {
  width: min(1280px, calc(100% - 48px));
  margin-inline: auto;
}

.invoice-toolbar {
  display: grid;
  grid-template-columns: minmax(280px, 1fr) 190px 170px 170px;
  gap: 12px;
  margin-bottom: 16px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.field {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-weight: 700;
  font-size: 14px;
}

.field input,
.field select,
.line-table input,
.line-table select {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  padding: 0 12px;
  outline: 0;
}

.field input:focus,
.field select:focus,
.line-table input:focus,
.line-table select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.invoice-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(320px, 0.9fr);
  gap: 16px;
  margin-bottom: 16px;
}

.invoice-list-panel table {
  min-width: 820px;
}

.clickable-row {
  cursor: pointer;
}

.clickable-row:hover,
.clickable-row.is-selected {
  background: var(--primary-soft);
}

.invoice-detail-panel {
  align-self: start;
  min-height: 460px;
}

.empty-state {
  display: grid;
  place-items: center;
  gap: 8px;
  min-height: 420px;
  padding: 26px;
  text-align: center;
  color: var(--muted);
}

.empty-state svg {
  width: 38px;
  height: 38px;
  color: var(--primary);
}

.empty-state strong {
  color: var(--text);
  font-size: 18px;
}

.detail-stack {
  display: grid;
  gap: 16px;
  padding: 18px;
}

.detail-total {
  display: grid;
  gap: 6px;
  padding: 18px;
  border-radius: var(--radius);
  background: var(--primary-soft);
  color: var(--primary);
}

.detail-total strong {
  font-size: 30px;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.detail-grid div,
.invoice-totals div {
  display: grid;
  gap: 5px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-soft);
}

.detail-grid span,
.invoice-totals span {
  color: var(--muted);
  font-size: 13px;
}

.line-preview {
  display: grid;
  gap: 10px;
}

.line-preview-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 11px 0;
  border-bottom: 1px solid var(--line);
}

.invoice-editor {
  margin-bottom: 34px;
}

.invoice-form {
  display: grid;
  gap: 18px;
  padding: 18px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
}

.editor-table-head,
.form-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.line-table {
  min-width: 1000px;
}

.line-table th,
.line-table td {
  padding: 10px;
}

.line-table td:nth-child(3),
.line-table td:nth-child(4),
.line-table td:nth-child(5),
.line-table td:nth-child(6),
.line-table td:nth-child(7) {
  width: 118px;
}

.line-table td:last-child {
  width: 58px;
}

.invoice-totals {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.invoice-totals .grand-total {
  border-color: var(--primary);
  background: var(--primary);
  color: #ffffff;
}

.invoice-totals .grand-total span,
.invoice-totals .grand-total strong {
  color: #ffffff;
}

body.is-dark {
  color-scheme: dark;
  --bg: #111827;
  --surface: #182235;
  --surface-soft: #111a2b;
  --text: #eef4ff;
  --muted: #aab6cb;
  --line: #26344d;
  --primary-soft: rgba(37, 99, 235, 0.18);
  --shadow: 0 16px 40px rgba(0, 0, 0, 0.18);
}

body.is-dark .topbar {
  background: rgba(24, 34, 53, 0.9);
}

body.is-dark .notice p {
  color: #d1d5db;
}

body.is-dark .avatar {
  background: #26344d;
  color: #dbeafe;
}

@media (max-width: 1180px) {
  .metrics-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .quick-actions {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .workspace-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 860px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: fixed;
    inset: 0 0 0 auto;
    z-index: 20;
    width: min(320px, 86vw);
    transform: translateX(105%);
    transition: transform 180ms ease;
  }

  body.sidebar-open .sidebar {
    transform: translateX(0);
  }

  .menu-button {
    display: inline-flex;
  }

  .topbar {
    padding: 10px 16px;
    flex-wrap: wrap;
  }

  .search-box {
    order: 5;
    flex-basis: 100%;
  }

  .user-chip span,
  .branch-pill span,
  .text-button {
    display: none;
  }

  .page-head,
  .alerts-grid,
  .metrics-grid,
  .quick-actions,
  .workspace-grid,
  .invoice-toolbar,
  .invoice-grid,
  .invoice-editor {
    width: min(100% - 28px, 1280px);
  }

  .page-head {
    display: grid;
    padding-top: 24px;
  }

  .head-actions {
    width: 100%;
  }

  .head-actions button {
    flex: 1;
  }

  .alerts-grid,
  .metrics-grid,
  .quick-actions,
  .invoice-toolbar,
  .invoice-grid,
  .form-grid,
  .invoice-totals {
    grid-template-columns: 1fr;
  }

  .page-head h1 {
    font-size: 28px;
  }
}

@media (max-width: 520px) {
  .topbar-actions {
    margin-inline-start: auto;
  }

  .metric-card strong {
    font-size: 25px;
  }

  .notice {
    padding-inline-start: 42px;
  }
}

/* =====================================================================
   شاشات المحاسبة والتقارير (accounting.js)
   ===================================================================== */

/* التبويبات */
.tabs {
  display: flex;
  gap: 6px;
  margin: 4px 0 16px;
  border-bottom: 1px solid var(--line);
}
.tabs .tab {
  border: none;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-weight: 600;
  padding: 10px 18px;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.tabs .tab:hover { color: var(--text); }
.tabs .tab.is-active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

/* الجداول */
.data-table { width: 100%; border-collapse: collapse; }
.data-table th,
.data-table td {
  padding: 12px 14px;
  text-align: start;
  border-bottom: 1px solid var(--line);
  font-size: 14px;
}
.data-table thead th {
  color: var(--muted);
  font-weight: 600;
  font-size: 13px;
  background: var(--surface-soft);
}
.data-table tfoot td {
  font-weight: 700;
  background: var(--surface-soft);
  border-top: 2px solid var(--line);
}
.data-table tbody tr:hover { background: var(--surface-soft); }
.muted-cell { padding: 22px; text-align: center; color: var(--muted); }

.acc-code {
  font-family: "Courier New", monospace;
  font-weight: 700;
  color: var(--primary);
  margin-inline-end: 6px;
}
.acc-parent { font-weight: 700; background: var(--surface-soft); }
.ref-chip {
  display: inline-block;
  margin-inline-start: 8px;
  padding: 1px 8px;
  border-radius: 20px;
  background: var(--primary-soft);
  color: var(--primary);
  font-size: 12px;
}

/* تفاصيل القيد */
.j-entry-row { cursor: default; }
.j-detail { padding: 6px 8px 12px; }
.mini-table { width: 100%; border-collapse: collapse; }
.mini-table th,
.mini-table td { padding: 8px 10px; border-bottom: 1px solid var(--line); font-size: 13px; text-align: start; }
.mini-table tfoot td { font-weight: 700; }
.j-detail-actions { margin-top: 12px; }

/* شارة التوازن */
.balance-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border-radius: 20px;
  font-weight: 700;
  font-size: 13px;
}
.balance-badge.is-balanced { background: rgba(15, 159, 110, 0.14); color: var(--success); }
.balance-badge.is-unbalanced { background: rgba(215, 59, 62, 0.12); color: var(--danger); }
.balance-badge i { width: 16px; height: 16px; }

/* تقارير */
.report-table .section-row td {
  font-weight: 700;
  background: var(--primary-soft);
  color: var(--primary);
}
.report-table .subtotal-row td {
  font-weight: 700;
  border-top: 1px solid var(--line);
}
.report-table td:last-child { text-align: start; font-variant-numeric: tabular-nums; }
.report-filters { flex-wrap: wrap; align-items: end; }

/* النافذة المنبثقة (Modal) */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 1000;
}
.modal-card {
  background: var(--surface);
  border-radius: 12px;
  box-shadow: var(--shadow);
  width: 100%;
  max-width: 820px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.modal-head,
.modal-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
}
.modal-foot { border-bottom: none; border-top: 1px solid var(--line); gap: 8px; justify-content: flex-end; }
.modal-head h2 { margin: 0; font-size: 18px; }
.modal-body { padding: 20px; overflow-y: auto; }
.editor-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}
.j-lines input,
.j-lines select { width: 100%; }
.j-lines .jl-debit,
.j-lines .jl-credit { max-width: 120px; }
#jeBalance { margin-top: 14px; }

/* إشعارات Toast */
.mongo-toast-host {
  position: fixed;
  bottom: 24px;
  inset-inline-start: 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 1100;
}
.mongo-toast {
  padding: 12px 18px;
  border-radius: 8px;
  color: #fff;
  font-weight: 600;
  box-shadow: var(--shadow);
  animation: toastIn 0.2s ease;
}
.mongo-toast-success { background: var(--success); }
.mongo-toast-error { background: var(--danger); }
.mongo-toast-info { background: var(--primary); }
@keyframes toastIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* =====================================================================
   بوابة تسجيل الدخول (auth.js)
   ===================================================================== */
body.auth-locked { overflow: hidden; }
.login-overlay {
  position: fixed;
  inset: 0;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-strong) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 2000;
}
.login-card {
  background: var(--surface);
  border-radius: 14px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.28);
  width: 100%;
  max-width: 400px;
  padding: 32px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.login-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; }
.login-brand .brand-mark {
  width: 44px; height: 44px; border-radius: 12px;
  background: var(--primary); color: #fff;
  display: grid; place-items: center; font-weight: 800; font-size: 20px;
}
.login-brand strong { display: block; font-size: 18px; color: var(--text); }
.login-brand span { font-size: 12px; color: var(--muted); }
.login-card h1 { margin: 8px 0 0; font-size: 22px; color: var(--text); }
.login-sub { margin: 0 0 8px; color: var(--muted); font-size: 14px; }
.login-card .field { display: flex; flex-direction: column; gap: 6px; }
.login-card .field span { font-size: 13px; font-weight: 600; color: var(--text); }
.login-card input {
  padding: 11px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
  color: var(--text);
  font: inherit;
}
.login-card input:focus { outline: 2px solid var(--primary); border-color: var(--primary); }
.login-submit { justify-content: center; margin-top: 6px; padding: 12px; font-size: 15px; }
.login-error {
  background: rgba(215, 59, 62, 0.12);
  color: var(--danger);
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
}
.login-hint { margin: 4px 0 0; font-size: 12px; color: var(--muted); text-align: center; }
.login-hint code {
  background: var(--surface-soft);
  padding: 1px 6px;
  border-radius: 4px;
  font-family: "Courier New", monospace;
  color: var(--primary);
}

/* شارة المستخدم + زر الخروج */
.user-chip .user-meta { display: flex; flex-direction: column; line-height: 1.2; }
.user-chip .user-meta small { color: var(--muted); font-size: 11px; }
.logout-btn {
  border: none;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  padding: 6px;
  border-radius: 6px;
  display: inline-flex;
}
.logout-btn:hover { color: var(--danger); background: var(--surface-soft); }

/* =====================================================================
   شاشات البيانات الأساسية (masterdata.js)
   ===================================================================== */
.row-actions { display: flex; gap: 4px; justify-content: flex-end; white-space: nowrap; }
.row-actions .icon-button { padding: 6px; color: var(--muted); }
.row-actions .crud-edit:hover { color: var(--primary); background: var(--surface-soft); }
.row-actions .crud-delete:hover { color: var(--danger); background: var(--surface-soft); }
.crud-search { min-width: 220px; }

.danger-button {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--danger); color: #fff; border: none;
  padding: 9px 16px; border-radius: 8px; font: inherit; font-weight: 600; cursor: pointer;
}
.danger-button:hover { filter: brightness(0.94); }

.confirm-card { max-width: 400px; text-align: center; }
.confirm-card .modal-body { padding: 28px 24px 8px; }
.confirm-card h2 { margin: 8px 0; font-size: 19px; }
.confirm-card p { color: var(--muted); margin: 0; }
.confirm-icon {
  width: 56px; height: 56px; margin: 0 auto 6px;
  border-radius: 50%; background: rgba(215, 59, 62, 0.12);
  display: grid; place-items: center; color: var(--danger);
}
.confirm-icon i { width: 28px; height: 28px; }

/* =====================================================================
   شاشة المالية (finance.js) — بطاقات الخزائن
   ===================================================================== */
.treasury-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 16px;
}
.treasury-card {
  display: grid;
  grid-template-columns: auto 1fr auto;
  grid-template-rows: auto auto;
  align-items: center;
  gap: 4px 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 18px;
  box-shadow: var(--shadow);
}
.treasury-icon {
  grid-row: span 2;
  width: 46px; height: 46px;
  border-radius: 12px;
  background: var(--primary-soft);
  color: var(--primary);
  display: grid; place-items: center;
}
.treasury-icon i { width: 22px; height: 22px; }
.treasury-info { display: flex; flex-direction: column; }
.treasury-name { font-weight: 700; color: var(--text); }
.treasury-balance { grid-column: 2 / 4; font-size: 20px; color: var(--text); font-variant-numeric: tabular-nums; }
.treasury-balance small { font-size: 12px; color: var(--muted); font-weight: 500; }
.treasury-card .status { justify-self: end; }
.treasury-total {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-strong) 100%);
  border: none;
}
.treasury-total .treasury-name,
.treasury-total .treasury-balance { color: #fff; }
.treasury-total .treasury-balance small { color: rgba(255,255,255,0.75); }
.treasury-total .treasury-icon { background: rgba(255,255,255,0.2); color: #fff; }

/* =====================================================================
   شاشة الإعدادات (settings.js)
   ===================================================================== */
.settings-form { max-width: 520px; }
.stacked-form { display: flex; flex-direction: column; gap: 14px; padding: 4px 2px; }
.stacked-form .field { display: flex; flex-direction: column; gap: 6px; }
.stacked-form .field span { font-size: 13px; font-weight: 600; color: var(--text); }
.stacked-form input {
  padding: 10px 14px; border: 1px solid var(--line); border-radius: 8px;
  background: var(--surface-soft); color: var(--text); font: inherit;
}
.stacked-form input:focus { outline: 2px solid var(--primary); border-color: var(--primary); }
.stacked-form .primary-button { align-self: flex-start; margin-top: 4px; }

/* =====================================================================
   شعار Mongo (صورة اللوجو)
   ===================================================================== */
.brand-logo {
  width: 46px;
  height: 46px;
  object-fit: contain;
  flex-shrink: 0;
}
.login-brand { justify-content: center; }
.login-logo {
  width: 110px;
  height: auto;
  max-height: 120px;
  object-fit: contain;
}

/* =====================================================================
   القائمة الجانبية القابلة للطي (أقسام رئيسية + فروع)
   ===================================================================== */
.nav-chevron { transition: transform 150ms ease; }
.nav-toggle[aria-expanded="true"] .nav-chevron { transform: rotate(180deg); }
.nav-submenu a.nav-soon { color: #8a99ae; }
.nav-support { margin-top: 4px; }

/* إصلاح: خاصية hidden يجب أن تخفي القائمة الفرعية رغم display:grid */
.nav-submenu[hidden] { display: none !important; }

/* إخفاء أشرطة التمرير في القائمة الجانبية (مع بقاء التمرير العمودي عند الحاجة) */
.nav-sections {
  overflow-x: hidden;
  scrollbar-width: none;        /* Firefox */
  -ms-overflow-style: none;     /* Edge/IE */
}
.nav-sections::-webkit-scrollbar { width: 0; height: 0; display: none; } /* Chrome/Safari */

/* =====================================================================
   شاشة المصروفات (expenses.js)
   ===================================================================== */
.filters-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: end;
  margin-bottom: 16px;
}
.filters-bar .field { margin: 0; }
.ex-summary { margin-bottom: 16px; max-width: 320px; }
.ex-summary .metric-card strong { font-size: 22px; }
.ex-summary .metric-card small { font-size: 12px; color: var(--muted); font-weight: 500; }
.field-wide { grid-column: 1 / -1; }
.ex-total-preview {
  margin-top: 12px;
  padding: 10px 14px;
  background: var(--surface-soft);
  border-radius: 8px;
  color: var(--text);
}
.ex-total-preview small { color: var(--muted); }
