/* ============================================================
   نظام إدارة العمليات المالية — الإصدار 2
   توكينات دلالية، وضع ليلي، خصائص منطقية تعمل مع RTL وLTR
   ============================================================ */

:root {
  color-scheme: light;

  /* الأسطح */
  --surface-page: #f4f6f5;
  --surface-card: #ffffff;
  --surface-raised: #ffffff;
  --surface-sunken: #eceef0;
  --surface-hover: #f0f3f1;
  --surface-selected: #e4efe9;

  /* النص */
  --text-strong: #16211c;
  --text-body: #2c3a33;
  --text-muted: #55655c;      /* نسبة تباين 5.4:1 على البطاقة */
  --text-inverse: #ffffff;

  /* الحدود */
  --border-subtle: #dde3df;
  --border-strong: #c2ccc6;
  --border-focus: #1f6f4a;

  /* الدلالات */
  --brand: #1f6f4a;
  --brand-strong: #17573a;
  --brand-soft: #e4efe9;
  --positive: #1a7a4c;
  --positive-soft: #e3f2e9;
  --negative: #a4262c;
  --negative-soft: #fbe9ea;
  --warning: #8a5a00;
  --warning-soft: #fdf1dc;
  --info: #1f5d8f;
  --info-soft: #e6eff7;
  --pending: #7a5c00;
  --pending-soft: #fdf3d8;

  /* القياسات */
  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 14px;
  --shadow-sm: 0 1px 2px rgba(20, 32, 26, .07);
  --shadow: 0 2px 8px rgba(20, 32, 26, .09);
  --shadow-lg: 0 12px 32px rgba(20, 32, 26, .16);

  --step-1: 4px;
  --step-2: 8px;
  --step-3: 12px;
  --step-4: 16px;
  --step-5: 24px;
  --step-6: 32px;
  --step-7: 48px;

  --font-ui: "Segoe UI", "Noto Sans Arabic", "Dubai", "Tahoma", "Arial", system-ui, sans-serif;
  --font-numeric: "Segoe UI", "Noto Sans", system-ui, sans-serif;

  --nav-width: 236px;
  --header-height: 60px;
}

[data-theme="dark"] {
  color-scheme: dark;
  --surface-page: #121815;
  --surface-card: #1a221e;
  --surface-raised: #212b26;
  --surface-sunken: #0e1310;
  --surface-hover: #253029;
  --surface-selected: #1f3a2c;
  --text-strong: #f0f4f1;
  --text-body: #d6ded9;
  --text-muted: #9aa8a0;
  --text-inverse: #121815;
  --border-subtle: #2c3830;
  --border-strong: #3d4c43;
  --border-focus: #5cc08c;
  --brand: #4fae7c;
  --brand-strong: #6bc294;
  --brand-soft: #1f3a2c;
  --positive: #58bd86;
  --positive-soft: #1b3527;
  --negative: #e8848a;
  --negative-soft: #3a1f21;
  --warning: #d9a541;
  --warning-soft: #362a12;
  --info: #6aaede;
  --info-soft: #16293a;
  --pending: #d4b04a;
  --pending-soft: #332a12;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
  --shadow: 0 2px 10px rgba(0, 0, 0, .45);
  --shadow-lg: 0 14px 36px rgba(0, 0, 0, .6);
}

/* ------------------------------ الأساس ------------------------------ */

*, *::before, *::after { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: var(--font-ui);
  font-size: 15px;
  line-height: 1.55;
  color: var(--text-body);
  background: var(--surface-page);
  -webkit-text-size-adjust: 100%;
}

/* كل الأرقام جدولية: الأعمدة المالية تتراصف رأسيًا */
input, table, .amount, .metric-value, .tabular { font-variant-numeric: tabular-nums; }

h1, h2, h3, h4 { margin: 0; color: var(--text-strong); font-weight: 650; line-height: 1.3; }
h1 { font-size: 1.4rem; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; }
p { margin: 0 0 var(--step-3); }

a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

:focus-visible {
  outline: 2px solid var(--border-focus);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}
:focus:not(:focus-visible) { outline: none; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/*
 * خاصية hidden تعني display:none، لكن أصناف مثل .grid و.field و.alert
 * تفرض display بأولوية أعلى فتُلغيها. هذا السطر يعيد لها معناها،
 * وبدونه لا يختفي أي عنصر يُخفى برمجيًا.
 */
[hidden] { display: none !important; }

.visually-hidden {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ------------------------------ التخطيط ------------------------------ */

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

.sidebar {
  background: var(--surface-card);
  border-inline-end: 1px solid var(--border-subtle);
  display: flex; flex-direction: column;
  position: sticky; inset-block-start: 0; height: 100vh;
  overflow-y: auto;
}

.brand {
  padding: var(--step-4);
  border-block-end: 1px solid var(--border-subtle);
  display: flex; align-items: center; gap: var(--step-3);
}
.brand-mark {
  width: 34px; height: 34px; flex: none;
  border-radius: 9px; background: var(--brand); color: #fff;
  display: grid; place-items: center; font-weight: 700; font-size: .95rem;
}
.brand-text { min-width: 0; }
.brand-title { font-weight: 650; color: var(--text-strong); font-size: .95rem; }
.brand-version { font-size: .72rem; color: var(--text-muted); }

.nav { padding: var(--step-2); flex: 1; }
.nav-group-label {
  padding: var(--step-3) var(--step-3) var(--step-1);
  font-size: .7rem; font-weight: 650; letter-spacing: .04em;
  color: var(--text-muted); text-transform: uppercase;
}
.nav-item {
  display: flex; align-items: center; gap: var(--step-3);
  width: 100%; padding: 9px var(--step-3);
  border: 0; border-radius: var(--radius-sm); background: none;
  font: inherit; color: var(--text-body); text-align: start; cursor: pointer;
}
.nav-item:hover { background: var(--surface-hover); }
.nav-item[aria-current="page"] {
  background: var(--surface-selected); color: var(--brand-strong); font-weight: 600;
}
.nav-icon { flex: none; width: 18px; text-align: center; opacity: .8; }
.nav-badge {
  margin-inline-start: auto; min-width: 22px; padding: 1px 6px;
  border-radius: 999px; background: var(--pending-soft); color: var(--pending);
  font-size: .72rem; font-weight: 700; text-align: center;
}

.sidebar-footer { padding: var(--step-3); border-block-start: 1px solid var(--border-subtle); }

.main { min-width: 0; display: flex; flex-direction: column; }

.topbar {
  height: var(--header-height); flex: none;
  padding-inline: var(--step-5);
  display: flex; align-items: center; gap: var(--step-4);
  background: var(--surface-card);
  border-block-end: 1px solid var(--border-subtle);
  position: sticky; inset-block-start: 0; z-index: 20;
}
.topbar-title { flex: 1; min-width: 0; }
.topbar-title h1 { font-size: 1.15rem; }
.topbar-title .subtitle { font-size: .8rem; color: var(--text-muted); }

.content { padding: var(--step-5); flex: 1; }
.stack { display: flex; flex-direction: column; gap: var(--step-4); }
.row { display: flex; align-items: center; gap: var(--step-3); flex-wrap: wrap; }
.row-end { margin-inline-start: auto; }

@media (max-width: 900px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; inset-block: 0; inset-inline-start: 0; z-index: 60;
    width: var(--nav-width); transform: translateX(100%);
    transition: transform .18s ease; box-shadow: var(--shadow-lg);
  }
  [dir="ltr"] .sidebar { transform: translateX(-100%); }
  .sidebar.is-open { transform: none; }
  .content { padding: var(--step-3); }
  .topbar { padding-inline: var(--step-3); }
}
.menu-toggle { display: none; }
@media (max-width: 900px) { .menu-toggle { display: inline-flex; } }

.scrim {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(10, 18, 14, .45); backdrop-filter: blur(1px);
}

/* ------------------------------ البطاقات ------------------------------ */

.card {
  background: var(--surface-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.card-header {
  padding: var(--step-4);
  border-block-end: 1px solid var(--border-subtle);
  display: flex; align-items: center; gap: var(--step-3); flex-wrap: wrap;
}
.card-header h2, .card-header h3 { margin-inline-end: auto; }
.card-body { padding: var(--step-4); }
.card-body.is-flush { padding: 0; }
.card-footer {
  padding: var(--step-3) var(--step-4);
  border-block-start: 1px solid var(--border-subtle);
  background: var(--surface-sunken);
  border-end-start-radius: var(--radius); border-end-end-radius: var(--radius);
}

.grid { display: grid; gap: var(--step-4); }
.grid-metrics { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.grid-form { grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); }

.metric { padding: var(--step-4); }
.metric-label { font-size: .8rem; color: var(--text-muted); margin-block-end: var(--step-1); }
.metric-value { font-size: 1.5rem; font-weight: 650; color: var(--text-strong); }
.metric-value .currency { font-size: .8rem; font-weight: 500; color: var(--text-muted); margin-inline-start: 4px; }
.metric-note { font-size: .78rem; color: var(--text-muted); margin-block-start: var(--step-1); }
.metric.is-accent { border-inline-start: 3px solid var(--brand); }
.metric.is-pending { border-inline-start: 3px solid var(--pending); }
.metric.is-negative { border-inline-start: 3px solid var(--negative); }

/* ------------------------------ الأزرار ------------------------------ */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 36px; padding: 0 var(--step-4);
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  background: var(--surface-raised); color: var(--text-body);
  font: inherit; font-weight: 550; cursor: pointer;
  transition: background .12s ease, border-color .12s ease;
  white-space: nowrap;
}
.btn:hover:not(:disabled) { background: var(--surface-hover); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--brand-strong); border-color: var(--brand-strong); }
.btn-danger { background: var(--negative); border-color: var(--negative); color: #fff; }
.btn-danger:hover:not(:disabled) { filter: brightness(.92); }
.btn-quiet { border-color: transparent; background: none; }
.btn-quiet:hover:not(:disabled) { background: var(--surface-hover); }
.btn-sm { min-height: 28px; padding: 0 10px; font-size: .82rem; }
.btn-icon { min-width: 36px; padding: 0; }
.btn-block { width: 100%; }
.btn-group { display: inline-flex; gap: var(--step-2); flex-wrap: wrap; }

/* ------------------------------ النماذج ------------------------------ */

.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field > label { font-size: .82rem; font-weight: 550; color: var(--text-body); }
.field .required { color: var(--negative); margin-inline-start: 2px; }
.field .hint { font-size: .74rem; color: var(--text-muted); }
.field .error { font-size: .76rem; color: var(--negative); font-weight: 550; }
.field.is-invalid input, .field.is-invalid select, .field.is-invalid textarea { border-color: var(--negative); }
.field.is-valid input { border-color: var(--positive); }

input, select, textarea {
  min-height: 36px; padding: 6px 10px;
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  background: var(--surface-raised); color: var(--text-body);
  font: inherit; width: 100%;
}
textarea { min-height: 76px; resize: vertical; line-height: 1.5; }
input:disabled, select:disabled, textarea:disabled { background: var(--surface-sunken); color: var(--text-muted); }
input::placeholder, textarea::placeholder { color: var(--text-muted); opacity: .8; }
input[type="checkbox"], input[type="radio"] { width: auto; min-height: 0; accent-color: var(--brand); }

.input-money { text-align: end; font-variant-numeric: tabular-nums; }
/*
 * القيم الرمزية: بصمة، آيبان، رقم حساب، رقم عملية.
 * تُعزل اتجاهيًا لأن مجموعة أرقام خالصة داخل فقرة عربية قد تتزحزح بخوارزمية
 * الاتجاه، فيقرأ المستخدم ترتيبًا غير المخزَّن ويرسله للمطور. العزل يضمن أن
 * ما يُعرض هو ما هو محفوظ حرفًا بحرف.
 */
.input-code,
.fingerprint-value,
td.code, .code {
  font-family: var(--font-numeric);
  letter-spacing: .06em;
  direction: ltr;
  unicode-bidi: isolate;
  text-align: start;
}

.checkbox-row { display: flex; align-items: center; gap: var(--step-2); font-size: .88rem; }
.checkbox-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: var(--step-2); }

/* أقسام النموذج القابلة للطي — تحل مشكلة النموذج الطويل في عمود واحد */
.section {
  border: 1px solid var(--border-subtle); border-radius: var(--radius);
  background: var(--surface-card); overflow: hidden;
}
.section + .section { margin-block-start: var(--step-3); }
.section > summary {
  padding: var(--step-3) var(--step-4);
  display: flex; align-items: center; gap: var(--step-3);
  font-weight: 600; color: var(--text-strong); cursor: pointer;
  background: var(--surface-sunken);
  list-style: none;
}
.section > summary::-webkit-details-marker { display: none; }
.section > summary::after {
  content: "▾"; margin-inline-start: auto; color: var(--text-muted);
  transition: transform .15s ease;
}
.section[open] > summary::after { transform: rotate(180deg); }
.section > summary .section-note { font-weight: 400; font-size: .78rem; color: var(--text-muted); }
.section-body { padding: var(--step-4); }

/* ------------------------------ الجداول ------------------------------ */

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .88rem; }
thead th {
  position: sticky; inset-block-start: 0; z-index: 2;
  padding: 10px var(--step-3);
  background: var(--surface-sunken); color: var(--text-strong);
  font-weight: 650; font-size: .8rem; text-align: start;
  border-block-end: 1px solid var(--border-strong);
  white-space: nowrap;
}
thead th.is-sortable { cursor: pointer; user-select: none; }
thead th.is-sortable:hover { background: var(--surface-hover); }
thead th .sort-mark { color: var(--brand); margin-inline-start: 4px; }
tbody td {
  padding: 9px var(--step-3);
  border-block-end: 1px solid var(--border-subtle);
  vertical-align: middle;
}
tbody tr:hover { background: var(--surface-hover); }
tbody tr.is-clickable { cursor: pointer; }
tfoot td {
  padding: 10px var(--step-3); font-weight: 650;
  background: var(--surface-sunken); border-block-start: 1px solid var(--border-strong);
}
td.numeric, th.numeric { text-align: end; font-variant-numeric: tabular-nums; white-space: nowrap; }
td.actions { white-space: nowrap; text-align: end; }
.table-empty { padding: var(--step-7) var(--step-4); text-align: center; color: var(--text-muted); }
.table-empty .empty-title { font-weight: 600; color: var(--text-body); margin-block-end: var(--step-1); }

/* المبلغ السالب باللون والأقواس معًا — لا يعتمد على اللون وحده */
.amount { font-variant-numeric: tabular-nums; white-space: nowrap; }
.amount.is-negative { color: var(--negative); }
.amount.is-positive { color: var(--positive); }
.amount .unit { font-size: .78em; color: var(--text-muted); margin-inline-start: 3px; }

/* ------------------------------ الشرائح ------------------------------ */

.chip {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 9px; border-radius: 999px;
  font-size: .76rem; font-weight: 600; white-space: nowrap;
  border: 1px solid transparent;
}
.chip::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.chip-pending { background: var(--pending-soft); color: var(--pending); }
.chip-approved { background: var(--positive-soft); color: var(--positive); }
.chip-rejected { background: var(--negative-soft); color: var(--negative); }
.chip-neutral { background: var(--surface-sunken); color: var(--text-muted); }
.chip-info { background: var(--info-soft); color: var(--info); }
.chip-warning { background: var(--warning-soft); color: var(--warning); }
.chip-plain::before { display: none; }

/* ------------------------------ التنبيهات ------------------------------ */

.alert {
  padding: var(--step-3) var(--step-4); border-radius: var(--radius);
  border: 1px solid var(--border-subtle); border-inline-start-width: 3px;
  display: flex; gap: var(--step-3); align-items: flex-start;
  font-size: .88rem;
}
.alert-title { font-weight: 650; margin-block-end: 2px; }
.alert-info { background: var(--info-soft); border-inline-start-color: var(--info); color: var(--text-body); }
.alert-warning { background: var(--warning-soft); border-inline-start-color: var(--warning); }
.alert-danger { background: var(--negative-soft); border-inline-start-color: var(--negative); }
.alert-success { background: var(--positive-soft); border-inline-start-color: var(--positive); }
.alert-body { flex: 1; min-width: 0; }

.toast-region {
  position: fixed; inset-block-end: var(--step-4); inset-inline-start: var(--step-4);
  z-index: 200; display: flex; flex-direction: column; gap: var(--step-2);
  max-width: min(420px, calc(100vw - 32px));
}
.toast {
  padding: var(--step-3) var(--step-4); border-radius: var(--radius);
  background: var(--surface-card); border: 1px solid var(--border-subtle);
  border-inline-start: 3px solid var(--brand);
  box-shadow: var(--shadow-lg); font-size: .88rem;
  display: flex; gap: var(--step-3); align-items: flex-start;
  animation: toast-in .16s ease;
}
.toast.is-error { border-inline-start-color: var(--negative); }
.toast.is-success { border-inline-start-color: var(--positive); }
.toast-text { flex: 1; min-width: 0; white-space: pre-line; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ------------------------------ الحوارات ------------------------------ */

dialog.modal {
  padding: 0; border: 0; border-radius: var(--radius-lg);
  background: var(--surface-card); color: var(--text-body);
  box-shadow: var(--shadow-lg);
  width: min(760px, calc(100vw - 32px));
  max-height: calc(100vh - 48px);
}
dialog.modal.is-wide { width: min(1040px, calc(100vw - 32px)); }
dialog.modal.is-narrow { width: min(480px, calc(100vw - 32px)); }
dialog.modal::backdrop { background: rgba(10, 18, 14, .5); }
.modal-header {
  padding: var(--step-4); border-block-end: 1px solid var(--border-subtle);
  display: flex; align-items: center; gap: var(--step-3);
  position: sticky; inset-block-start: 0; background: var(--surface-card); z-index: 2;
}
.modal-header h2 { margin-inline-end: auto; font-size: 1.05rem; }
.modal-body { padding: var(--step-4); overflow-y: auto; max-height: calc(100vh - 190px); }
.modal-footer {
  padding: var(--step-3) var(--step-4); border-block-start: 1px solid var(--border-subtle);
  display: flex; gap: var(--step-2); justify-content: flex-end;
  background: var(--surface-sunken); position: sticky; inset-block-end: 0;
}

/* ------------------------------ الترقيم ------------------------------ */

.pager {
  display: flex; align-items: center; gap: var(--step-3); flex-wrap: wrap;
  padding: var(--step-3) var(--step-4);
  border-block-start: 1px solid var(--border-subtle);
  font-size: .84rem; color: var(--text-muted);
}
.pager-info { margin-inline-end: auto; }
.pager-info strong { color: var(--text-body); }

/* ------------------------------ التسجيل والاعتماد ------------------------------ */

.gate {
  min-height: 100vh; display: grid; place-items: center;
  padding: var(--step-4);
  background: linear-gradient(160deg, var(--surface-page), var(--surface-sunken));
}
.gate-card {
  width: min(560px, 100%);
  background: var(--surface-card); border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg); box-shadow: var(--shadow);
  overflow: hidden;
}
.gate-head { padding: var(--step-5) var(--step-5) var(--step-3); text-align: center; }
.gate-head .brand-mark { margin: 0 auto var(--step-3); width: 46px; height: 46px; font-size: 1.1rem; }
.gate-head h1 { font-size: 1.25rem; }
.gate-head p { color: var(--text-muted); font-size: .88rem; margin-block-start: var(--step-2); }
.gate-body { padding: 0 var(--step-5) var(--step-5); display: flex; flex-direction: column; gap: var(--step-3); }

.fingerprint {
  padding: var(--step-3) var(--step-4);
  background: var(--surface-sunken); border: 1px dashed var(--border-strong);
  border-radius: var(--radius); text-align: center;
}
.fingerprint-label { font-size: .76rem; color: var(--text-muted); margin-block-end: var(--step-1); }
.fingerprint-value {
  font-family: var(--font-numeric); font-size: 1.05rem; font-weight: 700;
  letter-spacing: .1em; color: var(--text-strong); word-break: break-all;
  font-variant-numeric: tabular-nums;
  direction: ltr;
  unicode-bidi: isolate;
  text-align: center;
}
.license-box {
  font-family: ui-monospace, "Cascadia Mono", Consolas, monospace;
  font-size: .74rem; line-height: 1.5; min-height: 150px; direction: ltr; text-align: left;
}

/* ------------------------------ الرسوم ------------------------------ */

.chart { display: block; width: 100%; height: auto; }
.chart-bar { fill: var(--brand); }
.chart-bar.is-alt { fill: var(--info); }
.chart-bar:hover { fill: var(--brand-strong); }
.chart-line { fill: none; stroke: var(--brand); stroke-width: 2; stroke-linejoin: round; }
.chart-area { fill: var(--brand-soft); opacity: .7; }
.chart-grid { stroke: var(--border-subtle); stroke-width: 1; }
.chart-axis { stroke: var(--border-strong); stroke-width: 1; }
.chart-label { fill: var(--text-muted); font-size: 10px; font-family: var(--font-ui); }
.chart-value { fill: var(--text-strong); font-size: 10px; font-weight: 600; font-variant-numeric: tabular-nums; }
.chart-legend { display: flex; gap: var(--step-4); flex-wrap: wrap; font-size: .78rem; color: var(--text-muted); }
.chart-legend span { display: inline-flex; align-items: center; gap: 5px; }
.chart-legend i { width: 10px; height: 10px; border-radius: 2px; display: inline-block; }

/* ------------------------------ متفرقات ------------------------------ */

.spinner {
  width: 18px; height: 18px; flex: none;
  border: 2px solid var(--border-strong); border-top-color: var(--brand);
  border-radius: 50%; animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading { display: flex; align-items: center; gap: var(--step-3); padding: var(--step-6); color: var(--text-muted); justify-content: center; }

.definition-list { display: grid; grid-template-columns: auto 1fr; gap: var(--step-2) var(--step-4); font-size: .88rem; }
.definition-list dt { color: var(--text-muted); }
.definition-list dd { margin: 0; color: var(--text-body); }

.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li {
  padding: var(--step-2) 0 var(--step-2) 0;
  padding-inline-start: var(--step-4);
  border-inline-start: 2px solid var(--border-subtle);
  position: relative; font-size: .85rem;
}
.timeline li::before {
  content: ""; position: absolute; inset-inline-start: -5px; inset-block-start: 14px;
  width: 8px; height: 8px; border-radius: 50%; background: var(--border-strong);
}
.timeline li.is-approve::before { background: var(--positive); }
.timeline li.is-reject::before { background: var(--negative); }
.timeline .time { color: var(--text-muted); font-size: .78rem; }

.filter-bar {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: var(--step-3); padding: var(--step-4);
  border-block-end: 1px solid var(--border-subtle);
}
.filter-bar .field-wide { grid-column: span 2; }
@media (max-width: 640px) { .filter-bar .field-wide { grid-column: auto; } }

.amount-range { display: grid; grid-template-columns: 1fr auto 1fr; gap: 6px; align-items: center; }
.amount-range .dash { color: var(--text-muted); font-size: .8rem; }

.tabs { display: flex; gap: var(--step-1); border-block-end: 1px solid var(--border-subtle); overflow-x: auto; }
.tab {
  padding: 9px var(--step-4); border: 0; background: none; font: inherit;
  color: var(--text-muted); cursor: pointer; white-space: nowrap;
  border-block-end: 2px solid transparent; margin-block-end: -1px;
}
.tab[aria-selected="true"] { color: var(--brand-strong); font-weight: 600; border-block-end-color: var(--brand); }
.tab:hover { color: var(--text-body); }

.attachment-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: var(--step-2); }
.attachment {
  display: flex; align-items: center; gap: var(--step-3);
  padding: var(--step-2) var(--step-3);
  border: 1px solid var(--border-subtle); border-radius: var(--radius-sm);
  background: var(--surface-sunken); font-size: .85rem;
}
.attachment .name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.attachment .size { color: var(--text-muted); font-size: .78rem; }

.approve-actions { display: flex; gap: var(--step-2); }
.blocked-reason { font-size: .78rem; color: var(--warning); }

/* ------------------------------ الطباعة ------------------------------ */

@media print {
  @page { size: A4 landscape; margin: 14mm 12mm 16mm; }

  :root {
    --surface-page: #fff; --surface-card: #fff; --surface-sunken: #fff;
    --text-body: #000; --text-strong: #000; --text-muted: #333;
    --border-subtle: #999; --border-strong: #555;
  }
  body { background: #fff; font-size: 10.5pt; }

  .sidebar, .topbar, .toast-region, .pager, .filter-bar,
  .btn, .no-print, dialog.modal, .scrim { display: none !important; }

  .app-shell { display: block; }
  .content { padding: 0; }
  .card { border: 1px solid #999; box-shadow: none; break-inside: avoid; }

  /* ترويسة الطباعة: تظهر في الورق فقط */
  .print-header { display: block !important; margin-block-end: 8mm; text-align: center; }
  .print-header h1 { font-size: 15pt; }
  .print-header .meta { font-size: 9pt; color: #333; margin-block-start: 2mm; }

  /* ترويسة الجدول تتكرر في كل صفحة */
  thead { display: table-header-group; }
  tfoot { display: table-footer-group; }
  tr, .metric, .section { break-inside: avoid; }
  thead th { background: #eee !important; color: #000 !important; border-block-end: 1pt solid #555; }

  .amount.is-negative { color: #000; font-weight: 700; }
  a[href]::after { content: ""; }
  .grid-metrics { grid-template-columns: repeat(4, 1fr); }
}

.print-header { display: none; }
