/* =====================================================================
   مركز عمليات الراقي الحديث — Design system
   Same family as Cashbox (tokens, IBM Plex Sans Arabic, Lucide), wider
   and calmer: moderate type scale, one accent colour, generous spacing.
   ===================================================================== */

:root {
  /* surfaces */
  --bg: #f6f8fc;
  --surface: #ffffff;
  --surface-2: #f9fbff;
  --surface-3: #f3f5fa;
  --line: #e6eaf2;
  --line-strong: #d9dfea;
  /* text */
  --ink: #182033;
  --ink-2: #3a4459;
  --muted: #7b8498;
  --muted-2: #a2a9b8;
  /* brand */
  --primary: #5267db;
  --primary-2: #4256c5;
  --primary-soft: #eef1ff;
  --primary-line: #dfe4ff;
  --accent: #149b98;
  --accent-soft: #eaf8f7;
  /* status */
  --success: #1f9d72;   --success-soft: #ecfaf5;  --success-line: #d3f0e4;
  --danger: #d25667;    --danger-soft: #fff1f3;   --danger-line: #f6d8de;
  --warning: #b47a1f;   --warning-soft: #fff8e8;  --warning-line: #f4e4bf;
  --info: #3f7fd1;      --info-soft: #eef5ff;     --info-line: #d6e6fb;
  --violet: #7a55c7;    --violet-soft: #f4effd;   --violet-line: #e5dbf8;
  --slate: #4f6577;     --slate-soft: #eef2f5;    --slate-line: #dde4ea;
  /* shape */
  --radius-xs: 8px;
  --radius-sm: 11px;
  --radius: 14px;
  --radius-lg: 20px;
  --shadow-xs: 0 1px 2px rgba(24, 32, 51, .04);
  --shadow-sm: 0 7px 22px rgba(40, 54, 91, .06);
  --shadow: 0 16px 44px rgba(40, 54, 91, .08);
  --shadow-lg: 0 30px 90px rgba(32, 43, 70, .22);
  --focus: 0 0 0 3px rgba(82, 103, 219, .16);
  --sidebar-w: 272px;
  --ease: cubic-bezier(.2, .7, .2, 1);
  color-scheme: light;
}

/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
html, body { margin: 0; background: var(--bg); color: var(--ink); }
body {
  font-family: 'IBM Plex Sans Arabic', Tahoma, 'Segoe UI', sans-serif;
  font-size: 14px;
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-2); }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
img { max-width: 100%; }
svg.lucide, [data-lucide] { width: 18px; height: 18px; stroke-width: 1.8; flex: 0 0 auto; }
h1, h2, h3, h4 { margin: 0; line-height: 1.35; font-weight: 600; }
p { margin: 0; }
hr { border: 0; border-top: 1px solid var(--line); margin: 18px 0; }
:focus-visible { outline: none; box-shadow: var(--focus); border-radius: var(--radius-xs); }
::selection { background: #dfe4ff; }
.num, .amount { font-variant-numeric: tabular-nums; direction: ltr; unicode-bidi: isolate; display: inline-block; }
.ltr { direction: ltr; unicode-bidi: isolate; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.nowrap { white-space: nowrap; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
[hidden] { display: none !important; }

/* ---------- app shell ---------- */
.shell { min-height: 100vh; }
.sidebar {
  position: fixed; inset: 0 0 0 auto; width: var(--sidebar-w);
  background: var(--surface); border-left: 1px solid var(--line);
  display: flex; flex-direction: column; z-index: 40;
  box-shadow: -8px 0 30px rgba(34, 49, 84, .03);
}
.sidebar-brand {
  display: flex; align-items: center; gap: 11px;
  padding: 18px 18px 16px; border-bottom: 1px solid var(--line); min-height: 76px;
}
.brand-mark {
  width: 40px; height: 40px; border-radius: 12px; flex: 0 0 40px;
  display: grid; place-items: center; overflow: hidden;
  background: linear-gradient(145deg, var(--primary), #7b8ef0); color: #fff;
  font-weight: 700; font-size: 17px; box-shadow: 0 8px 18px rgba(82, 103, 219, .22);
}
.brand-mark img { width: 100%; height: 100%; object-fit: cover; background: #fff; }
.brand-text { min-width: 0; }
.brand-text strong { display: block; font-size: 14.5px; line-height: 1.35; }
.brand-text span { display: block; font-size: 11px; color: var(--muted); margin-top: 1px; }
.brand-logo-wide { display: block; max-width: 100%; max-height: 46px; object-fit: contain; }

.sidebar-nav { flex: 1; overflow-y: auto; padding: 12px 12px 18px; scrollbar-width: thin; }
.nav-group { margin-top: 14px; }
.nav-group:first-child { margin-top: 2px; }
.nav-group-title { font-size: 11px; font-weight: 600; color: var(--muted-2); padding: 0 10px 6px; letter-spacing: .2px; }
.nav-link {
  display: flex; align-items: center; gap: 10px; padding: 7px 8px; margin: 2px 0;
  border-radius: 12px; color: #5f6b82; border: 1px solid transparent;
  transition: background .16s var(--ease), color .16s var(--ease), transform .16s var(--ease);
}
.nav-link:hover { background: #f6f8fe; color: var(--ink); }
.nav-link .nav-icon {
  width: 32px; height: 32px; border-radius: 10px; flex: 0 0 32px;
  display: grid; place-items: center; background: var(--surface-3); border: 1px solid var(--line);
  box-shadow: inset 0 1px #fff;
}
.nav-link .nav-icon svg { width: 17px; height: 17px; }
.nav-link .nav-label { flex: 1; font-size: 13.5px; }
.nav-link.is-active { background: var(--primary-soft); border-color: var(--primary-line); color: var(--primary); font-weight: 600; }
.nav-link.is-active .nav-icon { background: #fff; border-color: var(--primary-line); color: var(--primary); }
.nav-count { font-size: 11px; font-weight: 600; min-width: 22px; height: 20px; padding: 0 6px; border-radius: 20px; display: grid; place-items: center; background: var(--warning-soft); color: var(--warning); border: 1px solid var(--warning-line); }

.sidebar-foot { border-top: 1px solid var(--line); padding: 12px; }
.user-card { display: flex; align-items: center; gap: 10px; padding: 9px; border-radius: 14px; background: var(--surface-2); border: 1px solid var(--line); }
.avatar { width: 36px; height: 36px; border-radius: 11px; flex: 0 0 36px; display: grid; place-items: center; background: var(--primary-soft); color: var(--primary); font-weight: 600; font-size: 13px; }
.user-meta { flex: 1; min-width: 0; }
.user-meta b, .user-meta small { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-meta b { font-size: 13px; font-weight: 600; }
.user-meta small { font-size: 11px; color: var(--muted); }

.main { margin-right: var(--sidebar-w); min-width: 0; }
.topbar {
  position: sticky; top: 0; z-index: 30; height: 60px;
  display: flex; align-items: center; gap: 12px; padding: 0 28px;
  background: rgba(246, 248, 252, .86); backdrop-filter: saturate(160%) blur(10px);
  border-bottom: 1px solid transparent; transition: border-color .2s;
}
.topbar.is-scrolled { border-bottom-color: var(--line); }
.topbar-spacer { flex: 1; }
.menu-toggle { display: none; }
.company-chip { display: inline-flex; align-items: center; gap: 7px; height: 36px; padding: 0 12px; border-radius: 30px; background: var(--surface); border: 1px solid var(--line); font-size: 12.5px; color: var(--ink-2); box-shadow: var(--shadow-xs); }
.company-chip svg { width: 15px; height: 15px; color: var(--accent); }
.company-chip select { border: 0; background: transparent; outline: none; padding: 0; font-size: 12.5px; cursor: pointer; }
.topbar-date { font-size: 12.5px; color: var(--muted); }

.content { padding: 8px 28px 48px; max-width: 1440px; }

/* ---------- page header ---------- */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin: 6px 0 20px; flex-wrap: wrap; }
.page-head h1 { font-size: 21px; letter-spacing: -.1px; }
.page-head .subtitle { color: var(--muted); font-size: 13px; margin-top: 3px; }
.breadcrumb { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.breadcrumb a { color: var(--muted); }
.breadcrumb a:hover { color: var(--primary); }
.breadcrumb svg { width: 13px; height: 13px; transform: scaleX(-1); }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 40px; padding: 0 15px; border-radius: var(--radius-sm); border: 1px solid transparent;
  font-size: 13.5px; font-weight: 500; white-space: nowrap; text-decoration: none; line-height: 1;
  transition: background .16s var(--ease), border-color .16s var(--ease), box-shadow .16s var(--ease), transform .1s;
}
.btn svg { width: 17px; height: 17px; }
.btn:active { transform: translateY(1px); }
.btn:disabled, .btn.is-disabled { opacity: .55; cursor: not-allowed; pointer-events: none; }
.btn-primary { background: linear-gradient(135deg, var(--primary), #6578e5); color: #fff; box-shadow: 0 8px 20px rgba(82, 103, 219, .2); }
.btn-primary:hover { background: linear-gradient(135deg, var(--primary-2), #5569d7); color: #fff; }
.btn-ghost { background: var(--surface); border-color: var(--line); color: var(--ink-2); box-shadow: var(--shadow-xs); }
.btn-ghost:hover { background: var(--surface-2); border-color: var(--line-strong); color: var(--ink); }
.btn-soft { background: var(--primary-soft); color: var(--primary); border-color: var(--primary-line); }
.btn-soft:hover { background: #e5e9ff; color: var(--primary-2); }
.btn-success { background: linear-gradient(135deg, #1f9d72, #2bb385); color: #fff; box-shadow: 0 8px 20px rgba(31, 157, 114, .2); }
.btn-success:hover { color: #fff; filter: brightness(.96); }
.btn-danger { background: var(--danger-soft); color: var(--danger); border-color: var(--danger-line); }
.btn-danger:hover { background: #ffe6ea; color: #b8404f; }
.btn-danger-solid { background: linear-gradient(135deg, #cf5d6c, #db7080); color: #fff; }
.btn-danger-solid:hover { color: #fff; filter: brightness(.96); }
.btn-plain { background: transparent; color: var(--ink-2); }
.btn-plain:hover { background: var(--surface-3); }
.btn-sm { height: 32px; padding: 0 11px; font-size: 12.5px; border-radius: 9px; }
.btn-sm svg { width: 15px; height: 15px; }
.btn-icon { width: 40px; padding: 0; }
.btn-icon.btn-sm { width: 32px; }
.btn .spinner { width: 15px; height: 15px; border-width: 2px; }
.btn.is-loading { pointer-events: none; opacity: .8; }

/* ---------- cards ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); }
.card + .card { margin-top: 16px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.card-head h2 { font-size: 15.5px; }
.card-head .hint { color: var(--muted); font-size: 12px; margin-top: 2px; }
.card-head-title { display: flex; align-items: center; gap: 11px; }
.card-icon { width: 36px; height: 36px; border-radius: 11px; display: grid; place-items: center; background: var(--primary-soft); color: var(--primary); border: 1px solid var(--primary-line); }
.card-icon svg { width: 18px; height: 18px; }
.card-body { padding: 20px; }
.card-body.tight { padding: 14px 16px; }
.card-foot { padding: 14px 20px; border-top: 1px solid var(--line); display: flex; gap: 8px; align-items: center; justify-content: space-between; flex-wrap: wrap; background: var(--surface-2); border-radius: 0 0 var(--radius-lg) var(--radius-lg); }

.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-main { grid-template-columns: minmax(0, 1fr) 340px; align-items: start; }
.stack { display: grid; gap: 16px; grid-template-columns: minmax(0, 1fr); }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row-between { display: flex; gap: 10px; align-items: center; justify-content: space-between; flex-wrap: wrap; }

/* ---------- KPI ---------- */
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 18px; }
.kpi { position: relative; overflow: hidden; background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: 16px 18px; box-shadow: var(--shadow-sm); }
.kpi::after { content: ""; position: absolute; width: 74px; height: 74px; border-radius: 50%; left: -26px; top: -30px; background: #f4f6ff; }
.kpi-top { display: flex; align-items: center; justify-content: space-between; position: relative; z-index: 1; }
.kpi-label { font-size: 12.5px; color: var(--muted); }
.kpi-icon { width: 34px; height: 34px; border-radius: 11px; display: grid; place-items: center; background: var(--surface-3); border: 1px solid var(--line); color: var(--primary); }
.kpi-icon svg { width: 17px; height: 17px; }
.kpi-icon.success { background: var(--success-soft); color: var(--success); border-color: var(--success-line); }
.kpi-icon.danger { background: var(--danger-soft); color: var(--danger); border-color: var(--danger-line); }
.kpi-icon.warning { background: var(--warning-soft); color: var(--warning); border-color: var(--warning-line); }
.kpi-icon.accent { background: var(--accent-soft); color: var(--accent); border-color: #d5f0ee; }
.kpi-value { font-size: 23px; font-weight: 600; margin-top: 10px; font-variant-numeric: tabular-nums; position: relative; z-index: 1; }
.kpi-value small { font-size: 12px; color: var(--muted); font-weight: 400; margin-inline-start: 3px; }
.kpi-foot { font-size: 12px; color: var(--muted); margin-top: 2px; position: relative; z-index: 1; }
.kpi.is-main { background: linear-gradient(145deg, #f7f8ff, #eef2ff); border-color: var(--primary-line); }
.kpi.is-main .kpi-value { color: #293969; }

/* ---------- badges ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 5px; height: 24px; padding: 0 9px;
  border-radius: 30px; font-size: 11.5px; font-weight: 500; white-space: nowrap; border: 1px solid;
}
.badge svg { width: 13px; height: 13px; }
.badge-neutral { background: var(--surface-3); color: #5d6880; border-color: var(--line); }
.badge-muted { background: #f5f6f8; color: #8b93a3; border-color: #e7e9ee; }
.badge-success { background: var(--success-soft); color: var(--success); border-color: var(--success-line); }
.badge-danger { background: var(--danger-soft); color: var(--danger); border-color: var(--danger-line); }
.badge-warning { background: var(--warning-soft); color: var(--warning); border-color: var(--warning-line); }
.badge-info { background: var(--info-soft); color: var(--info); border-color: var(--info-line); }
.badge-violet { background: var(--violet-soft); color: var(--violet); border-color: var(--violet-line); }
.badge-slate { background: var(--slate-soft); color: var(--slate); border-color: var(--slate-line); }
.badge-primary { background: var(--primary-soft); color: var(--primary); border-color: var(--primary-line); }
.tag { display: inline-flex; align-items: center; gap: 4px; font-size: 11.5px; color: var(--muted); background: var(--surface-3); border-radius: 6px; padding: 1px 7px; }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13.5px; }
.table th {
  position: sticky; top: 0; background: #f8f9fd; color: #667188; font-weight: 500; font-size: 12.5px;
  text-align: right; padding: 11px 14px; border-bottom: 1px solid var(--line); white-space: nowrap;
}
.table td { padding: 12px 14px; border-bottom: 1px solid #eef1f5; vertical-align: middle; }
.table tbody tr { transition: background .12s; }
.table tbody tr:hover td { background: #fbfcff; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tr.is-link { cursor: pointer; }
.table td small, .table .sub { display: block; color: var(--muted); font-size: 12px; margin-top: 1px; }
.table .col-num { text-align: left; white-space: nowrap; }
.table .col-actions { text-align: left; white-space: nowrap; width: 1%; }
.table .col-check { width: 1%; }
.table tfoot td { background: var(--surface-2); font-weight: 600; border-top: 1px solid var(--line); border-bottom: 0; }
.table .is-muted td { color: var(--muted-2); }
.table .row-total td { background: #f8f9fd; font-weight: 600; }
.doc-no { font-weight: 600; color: var(--ink); direction: ltr; unicode-bidi: isolate; }
.dr { color: var(--ink); }
.cr { color: var(--ink); }
.neg { color: var(--danger); }

/* ---------- forms ---------- */
.form-grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 14px 16px; }
.col-12 { grid-column: span 12; } .col-9 { grid-column: span 9; } .col-8 { grid-column: span 8; } .col-6 { grid-column: span 6; }
.col-4 { grid-column: span 4; } .col-3 { grid-column: span 3; } .col-2 { grid-column: span 2; }
.col-7 { grid-column: span 7; } .col-5 { grid-column: span 5; }
.field { display: grid; gap: 6px; align-content: start; min-width: 0; }
.field > label, .label { font-size: 12.5px; color: #5b667c; font-weight: 500; }
.field .req { color: var(--danger); margin-inline-start: 2px; }
.input, .select, .textarea {
  width: 100%; height: 42px; padding: 0 12px; border-radius: var(--radius-sm);
  border: 1px solid #dfe4ed; background: #fbfcff; color: var(--ink); outline: none;
  transition: border-color .15s, box-shadow .15s, background .15s;
}
.textarea { height: auto; min-height: 84px; padding: 10px 12px; line-height: 1.7; resize: vertical; }
.select { appearance: none; padding-left: 34px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%237b8498' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m4 6 4 4 4-4'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: left 11px center; }
.input:hover, .select:hover, .textarea:hover { border-color: #ccd3e1; }
.input:focus, .select:focus, .textarea:focus { border-color: #b9c3f8; box-shadow: var(--focus); background: #fff; }
.input[readonly] { background: var(--surface-3); color: var(--ink-2); }
.input.num-input { text-align: left; direction: ltr; font-variant-numeric: tabular-nums; }
.input-sm { height: 36px; font-size: 13px; padding: 0 10px; border-radius: 9px; }
.field-hint { font-size: 11.5px; color: var(--muted); }
.input-group { position: relative; }
.input-group > svg { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; color: var(--muted-2); pointer-events: none; }
.input-group > .input { padding-right: 38px; }
.check { display: inline-flex; align-items: center; gap: 9px; cursor: pointer; font-size: 13.5px; user-select: none; }
.check input { width: 18px; height: 18px; accent-color: var(--primary); margin: 0; }
.switch { position: relative; display: inline-flex; align-items: center; gap: 10px; cursor: pointer; font-size: 13.5px; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch .track { width: 40px; height: 23px; border-radius: 30px; background: #d8dee8; position: relative; transition: background .2s var(--ease); flex: 0 0 40px; }
.switch .track::before { content: ""; position: absolute; width: 17px; height: 17px; top: 3px; right: 3px; border-radius: 50%; background: #fff; box-shadow: 0 2px 5px rgba(0, 0, 0, .15); transition: transform .2s var(--ease); }
.switch input:checked + .track { background: var(--primary); }
.switch input:checked + .track::before { transform: translateX(-17px); }
.switch input:focus-visible + .track { box-shadow: var(--focus); }
.fieldset { border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.fieldset-title { font-size: 13px; font-weight: 600; margin-bottom: 12px; display: flex; align-items: center; gap: 8px; color: var(--ink-2); }
.fieldset-title svg { width: 16px; height: 16px; color: var(--primary); }

.segmented { display: inline-flex; background: var(--surface-3); border: 1px solid var(--line); border-radius: 12px; padding: 3px; gap: 2px; }
.segmented a, .segmented button { border: 0; background: transparent; padding: 6px 13px; border-radius: 9px; font-size: 12.5px; color: var(--muted); }
.segmented .is-active { background: #fff; color: var(--ink); box-shadow: var(--shadow-xs); font-weight: 500; }

/* ---------- filters ---------- */
.filters { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; padding: 14px 16px; border-bottom: 1px solid var(--line); background: var(--surface-2); border-radius: var(--radius-lg) var(--radius-lg) 0 0; }
.filters .field { gap: 4px; }
.filters .field > label { font-size: 11.5px; }
.filters .input, .filters .select { height: 38px; font-size: 13px; }
.filters .grow { flex: 1; min-width: 200px; }
.filters .w-sm { width: 150px; }
.filters .w-md { width: 190px; }

/* ---------- empty / loading ---------- */
.empty { text-align: center; padding: 48px 20px; color: var(--muted); }
.empty-icon { width: 56px; height: 56px; margin: 0 auto 14px; border-radius: 18px; display: grid; place-items: center; background: var(--surface-3); border: 1px solid var(--line); color: var(--muted-2); }
.empty-icon svg { width: 26px; height: 26px; }
.empty h3 { font-size: 15px; color: var(--ink-2); margin-bottom: 4px; }
.empty p { font-size: 13px; max-width: 420px; margin: 0 auto; }
.empty .btn { margin-top: 16px; }
.spinner { width: 18px; height: 18px; border: 2px solid rgba(255, 255, 255, .45); border-top-color: #fff; border-radius: 50%; animation: spin .7s linear infinite; display: inline-block; }
.spinner.dark { border-color: rgba(82, 103, 219, .2); border-top-color: var(--primary); }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- alerts / notices ---------- */
.notice { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: var(--radius); border: 1px solid; font-size: 13px; }
.notice svg { width: 18px; height: 18px; margin-top: 1px; }
.notice-info { background: var(--info-soft); border-color: var(--info-line); color: #2f5f9e; }
.notice-warning { background: var(--warning-soft); border-color: var(--warning-line); color: #8a5d14; }
.notice-danger { background: var(--danger-soft); border-color: var(--danger-line); color: #a94454; }
.notice-success { background: var(--success-soft); border-color: var(--success-line); color: #17775a; }

/* ---------- toasts ---------- */
.toasts { position: fixed; left: 22px; bottom: 22px; z-index: 300; display: grid; gap: 10px; width: min(420px, calc(100vw - 44px)); }
.toast {
  display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: 14px;
  background: #273149; color: #fff; box-shadow: 0 16px 40px rgba(27, 37, 60, .24); font-size: 13.5px; line-height: 1.6;
  animation: toastIn .22s var(--ease);
}
.toast svg { width: 18px; height: 18px; margin-top: 2px; }
.toast-success { background: #197b5c; }
.toast-error { background: #a94051; }
.toast .toast-close { margin-inline-start: auto; background: transparent; border: 0; color: rgba(255, 255, 255, .7); padding: 0; display: grid; }
.toast.is-leaving { animation: toastOut .2s ease-in forwards; }
@keyframes toastIn { from { transform: translateY(10px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes toastOut { to { transform: translateY(8px); opacity: 0; } }

/* ---------- modal ---------- */
.modal { position: fixed; inset: 0; z-index: 200; display: none; align-items: center; justify-content: center; padding: 20px; background: rgba(33, 42, 64, .3); backdrop-filter: blur(6px); }
.modal.is-open { display: flex; animation: fadeIn .16s ease-out; }
.modal-box { width: min(640px, 100%); max-height: calc(100vh - 40px); overflow: auto; background: var(--surface); border-radius: 22px; box-shadow: var(--shadow-lg); animation: pop .2s var(--ease); display: flex; flex-direction: column; }
.modal-box.wide { width: min(880px, 100%); }
.modal-box.narrow { width: min(460px, 100%); }
.modal-head { display: flex; align-items: center; gap: 12px; padding: 20px 22px 14px; }
.modal-head h2 { font-size: 17px; }
.modal-head p { color: var(--muted); font-size: 12.5px; margin-top: 2px; }
.modal-head .card-icon { width: 42px; height: 42px; border-radius: 13px; }
.modal-close { margin-inline-start: auto; width: 36px; height: 36px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface-2); display: grid; place-items: center; color: var(--muted); }
.modal-close:hover { color: var(--ink); background: var(--surface-3); }
.modal-body { padding: 6px 22px 18px; }
.modal-foot { display: flex; gap: 8px; justify-content: flex-start; padding: 14px 22px; border-top: 1px solid var(--line); background: var(--surface-2); border-radius: 0 0 22px 22px; margin-top: auto; }
@keyframes pop { from { transform: translateY(12px) scale(.985); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

/* ---------- dropdown ---------- */
.dropdown { position: relative; display: inline-block; }
.dropdown-menu { position: absolute; top: calc(100% + 6px); left: 0; min-width: 210px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); padding: 6px; z-index: 60; display: none; }
.dropdown.is-open .dropdown-menu { display: block; animation: pop .14s var(--ease); }
.dropdown-menu.up { top: auto; bottom: calc(100% + 6px); }
.dropdown-item { display: flex; width: 100%; align-items: center; gap: 9px; padding: 9px 10px; border-radius: 9px; font-size: 13px; color: var(--ink-2); background: transparent; border: 0; text-align: right; }
.dropdown-item:hover { background: var(--surface-3); color: var(--ink); }
.dropdown-item svg { width: 16px; height: 16px; color: var(--muted); }
.dropdown-item.danger, .dropdown-item.danger svg { color: var(--danger); }
.dropdown-sep { height: 1px; background: var(--line); margin: 5px 4px; }

/* ---------- tree ---------- */
.tree-row td:first-child { padding-right: calc(14px + var(--depth, 0) * 22px); }
.tree-toggle { width: 22px; height: 22px; border: 0; background: transparent; display: inline-grid; place-items: center; color: var(--muted); border-radius: 6px; vertical-align: middle; margin-left: 4px; }
.tree-toggle:hover { background: var(--surface-3); color: var(--ink); }
.tree-toggle svg { width: 15px; height: 15px; transition: transform .15s; }
.tree-row.is-collapsed .tree-toggle svg { transform: rotate(90deg); }
.tree-spacer { display: inline-block; width: 26px; }
.tree-code { font-variant-numeric: tabular-nums; color: var(--muted); font-size: 12.5px; direction: ltr; unicode-bidi: isolate; margin-left: 8px; }
.tree-row.is-group > td:first-child .tree-name { font-weight: 600; }
.tree-row[data-hidden="1"] { display: none; }
.hide-inactive tr[data-inactive="1"] { display: none; }
.tree-row.is-inactive td { background: #fbfbfc; }
.tree-row.is-inactive .tree-name, .tree-row.is-inactive .tree-code, .tree-row.is-inactive .num { color: var(--muted-2); }
.tree-row.is-focused td { animation: focusFlash 2.4s var(--ease); }
@keyframes focusFlash { 0%, 35% { background: var(--primary-soft); } 100% { background: transparent; } }
.link-plain { background: none; border: 0; padding: 0; color: inherit; font: inherit; cursor: pointer; text-align: right; }
.link-plain:hover { color: var(--primary); }
.policy-dot { display: inline-grid; place-items: center; width: 20px; height: 20px; border-radius: 6px; background: var(--surface-3); color: var(--muted); vertical-align: middle; margin-inline-start: 2px; }
.policy-dot svg { width: 12px; height: 12px; }
.row-actions { display: inline-flex; gap: 2px; opacity: 0; transition: opacity .15s var(--ease); }
tr:hover .row-actions, tr:focus-within .row-actions { opacity: 1; }
@media (hover: none) { .row-actions { opacity: 1; } }

/* ---------- picker (searchable select) ---------- */
/* mobile number: country (flag + dial code) + national number — always LTR like the number itself */
.phone-field { position: relative; display: grid; gap: 6px; }
.phone-group { display: flex; direction: ltr; border: 1px solid #dfe4ed; border-radius: var(--radius-sm); background: #fbfcff; transition: border-color .15s, box-shadow .15s; }
.phone-group:hover { border-color: #ccd3e1; }
.phone-group:focus-within { border-color: #b9c3f8; box-shadow: var(--focus); background: #fff; }
.phone-cc { display: inline-flex; align-items: center; gap: 7px; flex: 0 0 auto; height: 40px; padding: 0 10px 0 12px; border: 0; border-right: 1px solid #e6eaf2; background: var(--surface-2); border-radius: var(--radius-sm) 0 0 var(--radius-sm); color: var(--ink); font-weight: 600; font-size: 13.5px; font-variant-numeric: tabular-nums; cursor: pointer; }
.phone-cc:hover { background: var(--surface-3); }
.phone-cc svg { width: 14px; height: 14px; color: var(--muted); }
.phone-flag, .phone-opt img { border-radius: 3px; box-shadow: 0 0 0 1px rgba(15, 23, 42, .08); object-fit: cover; flex: 0 0 auto; }
.phone-group .phone-num { flex: 1 1 auto; min-width: 0; height: 40px; border: 0; background: transparent; box-shadow: none; font-size: 15px; letter-spacing: .3px; font-variant-numeric: tabular-nums; text-align: left; }
.phone-group .phone-num:focus { box-shadow: none; background: transparent; }
.phone-field.is-invalid .phone-group { border-color: #f0b4b4; background: #fffafa; }
.phone-status { font-size: 12px; min-height: 0; }
.phone-field.is-valid .phone-status { color: var(--success, #12805c); }
.phone-field.is-invalid .phone-status { color: var(--danger); }
.phone-menu { position: absolute; top: 48px; left: 0; width: min(320px, 100%); background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); padding: 6px; z-index: 80; display: none; }
.phone-field.is-open .phone-menu { display: grid; gap: 6px; animation: pop .14s var(--ease); }
.phone-options { max-height: 260px; overflow: auto; display: grid; gap: 2px; }
.phone-opt { display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px; border: 0; border-radius: 8px; background: transparent; font-size: 13px; color: var(--ink-2); text-align: right; cursor: pointer; }
.phone-opt .po-dial { margin-inline-start: auto; direction: ltr; color: var(--muted); font-variant-numeric: tabular-nums; }
.phone-opt:hover, .phone-opt.is-active { background: var(--primary-soft); color: var(--primary-2); }

.picker { position: relative; }
.picker-input { cursor: text; }
.picker-list { position: absolute; top: calc(100% + 4px); right: 0; left: 0; min-width: 260px; max-height: 280px; overflow: auto; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); z-index: 80; padding: 5px; display: none; }
.picker.is-open .picker-list { display: block; }
.picker-option { padding: 8px 10px; border-radius: 8px; cursor: pointer; font-size: 13px; display: flex; gap: 8px; align-items: baseline; }
.picker-option .po-code { color: var(--muted); font-size: 12px; direction: ltr; unicode-bidi: isolate; min-width: 44px; }
.picker-option .po-meta { margin-inline-start: auto; color: var(--muted-2); font-size: 11.5px; }
.picker-option.is-active, .picker-option:hover { background: var(--primary-soft); color: var(--primary-2); }
.picker-empty { padding: 10px; color: var(--muted); font-size: 12.5px; text-align: center; }
.picker-clear { position: absolute; left: 6px; top: 50%; transform: translateY(-50%); width: 26px; height: 26px; border: 0; background: transparent; color: var(--muted-2); display: none; place-items: center; border-radius: 7px; }
.picker.has-value .picker-clear { display: grid; }
.picker-clear:hover { background: var(--surface-3); color: var(--ink); }
.picker-clear svg { width: 14px; height: 14px; }

/* ---------- line editor ---------- */
.lines { width: 100%; border-collapse: separate; border-spacing: 0; }
.lines th { font-size: 12px; color: var(--muted); font-weight: 500; text-align: right; padding: 0 6px 8px; white-space: nowrap; }
.lines td { padding: 4px 4px; vertical-align: top; }
.lines .line-no { width: 30px; text-align: center; color: var(--muted-2); font-size: 12px; padding-top: 13px; }
.lines .line-del { width: 40px; }
.lines .w-amount { width: 140px; }
.lines .w-cc { width: 210px; }
.lines .w-party { width: 190px; }
.lines tfoot td { padding-top: 12px; }
.lines-total { display: flex; gap: 14px; justify-content: flex-end; flex-wrap: wrap; align-items: center; font-size: 13px; }
.lines-total .tot { background: var(--surface-3); border: 1px solid var(--line); border-radius: 10px; padding: 7px 12px; }
.lines-total .tot b { font-variant-numeric: tabular-nums; margin-inline-start: 6px; }
.balance-ok { color: var(--success); }
.balance-bad { color: var(--danger); }

/* ---------- payment voucher form (pv) ---------- */
.pv { max-width: 1080px; }
.pv-card { padding: 20px 22px; display: grid; gap: 16px; }
.pv-card > * { min-width: 0; }
.pv-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 210px), 1fr)); gap: 14px 16px; align-items: start; }
.pv-grid > * { min-width: 0; }
.pv-grid[hidden], .pv-grid > [hidden] { display: none; }
.pv-wide { grid-column: span 2; }
.pv-mode { border: 0; margin: 0; padding: 0; min-width: 0; display: grid; gap: 16px; }
.pv-mode[hidden] { display: none; }
.pv-type { display: inline-grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 4px; background: var(--surface-3); border: 1px solid var(--line); border-radius: 14px; width: min(100%, 360px); }
.pv-type-opt { position: relative; cursor: pointer; }
.pv-type-opt input { position: absolute; opacity: 0; pointer-events: none; }
.pv-type-opt span { display: flex; align-items: center; justify-content: center; gap: 7px; height: 38px; border-radius: 10px; font-size: 13.5px; color: var(--muted); transition: background .18s var(--ease), color .18s var(--ease), box-shadow .18s var(--ease); }
.pv-type-opt span svg { width: 16px; height: 16px; }
.pv-type-opt input:checked + span { background: #fff; color: var(--primary); font-weight: 600; box-shadow: var(--shadow-xs), 0 0 0 1px var(--primary-line); }
.pv-type-opt input:focus-visible + span { box-shadow: var(--focus); }
.pv-seg { display: flex; flex-wrap: wrap; width: 100%; }
.pv-seg label { position: relative; cursor: pointer; flex: 1 1 auto; }
.pv-seg input { position: absolute; opacity: 0; pointer-events: none; }
.pv-seg span { display: block; text-align: center; padding: 7px 10px; border-radius: 9px; font-size: 12.5px; color: var(--muted); white-space: nowrap; transition: background .15s, color .15s; }
.pv-seg input:checked + span { background: #fff; color: var(--ink); font-weight: 500; box-shadow: var(--shadow-xs); }
.pv-seg input:focus-visible + span { box-shadow: var(--focus); }
.pv-hint { display: flex; gap: 8px; align-items: flex-start; font-size: 12px; color: var(--muted); line-height: 1.8; }
.pv-hint svg { width: 15px; height: 15px; margin-top: 3px; flex: 0 0 auto; }
/* رصيد الموظف عند اختياره في سند الصرف */
.pv-emp-bal { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 8px; padding: 8px 12px; border-radius: var(--radius-sm); border: 1px solid var(--line); background: var(--surface-2); font-size: 13px; }
.pv-emp-bal span { color: var(--muted); }
.pv-emp-bal b { font-size: 15px; font-weight: 700; }
.pv-emp-bal em { font-style: normal; font-size: 12px; font-weight: 600; padding: 1px 9px; border-radius: 999px; }
.pv-emp-bal a { margin-inline-start: auto; font-size: 12px; }
.pv-emp-bal.is-credit { background: var(--success-soft); border-color: var(--success-line); } .pv-emp-bal.is-credit b, .pv-emp-bal.is-credit em { color: var(--success); } .pv-emp-bal.is-credit em { background: #fff; }
.pv-emp-bal.is-debit { background: var(--danger-soft); border-color: var(--danger-line); } .pv-emp-bal.is-debit b, .pv-emp-bal.is-debit em { color: var(--danger); } .pv-emp-bal.is-debit em { background: #fff; }
.pv-emp-bal.is-zero em { background: var(--surface-3); color: var(--muted); }
.input-suffix { position: relative; }
.input-suffix .input { padding-left: 42px; }
.input-suffix span { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); font-size: 12px; color: var(--muted); pointer-events: none; }
.is-invalid, .is-invalid.input { border-color: var(--danger) !important; box-shadow: 0 0 0 3px rgba(210, 86, 103, .14) !important; }
.pv-more { display: flex; gap: 18px; flex-wrap: wrap; }
.pv-toggle { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--primary); }
.pv-toggle svg { width: 15px; height: 15px; }
.pv-actions { position: sticky; bottom: 0; z-index: 20; margin-top: 14px; padding: 12px 0 calc(12px + env(safe-area-inset-bottom)); background: linear-gradient(to top, var(--bg) 70%, rgba(246, 248, 252, 0)); }
.pv-actions-inner { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 10px 12px; box-shadow: var(--shadow-sm); max-width: 1080px; }
.pv-sum { font-variant-numeric: tabular-nums; }

.dist { border-top: 1px solid var(--line); padding-top: 16px; display: grid; gap: 10px; min-width: 0; }
.dist-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.dist-head h2 { font-size: 15px; }
.dist-head p { font-size: 12px; color: var(--muted); margin-top: 2px; }
.dist-cols, .dist-row { display: grid; grid-template-columns: minmax(0, 2.2fr) minmax(0, 1.5fr) minmax(110px, .8fr) 36px; gap: 8px; align-items: start; }
.dist-cols { font-size: 12px; color: var(--muted); padding: 0 2px; }
.dist-rows { display: grid; gap: 8px; }
.dist-row { padding: 8px; border: 1px solid transparent; border-radius: 12px; transition: border-color .15s, background .15s; animation: fadeIn .18s ease-out; }
.dist-row:hover, .dist-row:focus-within { background: var(--surface-2); border-color: var(--line); }
.dist-cell { min-width: 0; }
.dist-label { display: none; font-size: 11.5px; color: var(--muted); margin-bottom: 4px; }
.dist-del { display: flex; justify-content: center; padding-top: 2px; }
.dist-party { grid-column: 1 / -2; min-width: 0; }
.dist-party[hidden] { display: none; }
.dist-off { display: none; height: 36px; align-items: center; font-size: 12px; color: var(--muted-2); padding-inline: 4px; }
.dist-cc.is-off .picker { display: none; }
.dist-cc.is-off .dist-off { display: flex; }
.dist-cc.is-required .picker-input, .dist-party.is-required .picker-input { border-color: #e4cf9c; background: #fffdf7; }
.dist-cc.is-required .dist-label::after, .dist-party.is-required .dist-label::after { content: " *"; color: var(--danger); }
.dist-totals { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; padding-top: 6px; }
.dist-totals > div { display: flex; gap: 8px; align-items: baseline; padding: 7px 12px; border-radius: 10px; background: var(--surface-3); border: 1px solid var(--line); font-size: 12.5px; color: var(--muted); }
.dist-totals b { color: var(--ink); font-size: 14px; }
.dist-totals .is-ok { background: var(--success-soft); border-color: var(--success-line); }
.dist-totals .is-ok b { color: var(--success); }
.dist-totals .is-off { background: var(--warning-soft); border-color: var(--warning-line); }
.dist-totals .is-off b { color: var(--warning); }
.picker-list { min-width: min(260px, calc(100vw - 40px)); }

@media (max-width: 760px) {
  .pv-card { padding: 16px; }
  .pv-wide { grid-column: auto; }
  .dist-cols { display: none; }
  .dist-row { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 36px; background: var(--surface-2); border-color: var(--line); padding: 10px; }
  .dist-account { grid-column: 1 / -1; }
  .dist-cc { grid-column: 1 / 2; }
  .dist-amount { grid-column: 2 / 3; }
  .dist-del { grid-column: 3 / 4; padding-top: 22px; }
  .dist-party { grid-column: 1 / -1; }
  .dist-label { display: block; }
  .dist-totals { justify-content: stretch; }
  .dist-totals > div { flex: 1 1 140px; justify-content: space-between; }
  .pv-actions-inner .btn-primary, .pv-actions-inner .btn-ghost:not(.btn-icon) { flex: 1 1 auto; }
  .pv-sum { display: none; }
}

/* ---------- detail / definition list ---------- */
.dl { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 14px 22px; }
.dl div { min-width: 0; }
.dl dt { font-size: 12px; color: var(--muted); margin-bottom: 3px; }
.dl dd { margin: 0; font-size: 14px; font-weight: 500; overflow-wrap: anywhere; }
.doc-hero { display: flex; gap: 18px; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.doc-hero .amount-big { font-size: 26px; font-weight: 600; font-variant-numeric: tabular-nums; }
.doc-hero .amount-big small { font-size: 13px; color: var(--muted); font-weight: 400; }

.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { position: relative; padding: 0 22px 16px 0; font-size: 13px; }
.timeline li::before { content: ""; position: absolute; right: 5px; top: 7px; width: 9px; height: 9px; border-radius: 50%; background: var(--primary); box-shadow: 0 0 0 4px var(--primary-soft); }
.timeline li::after { content: ""; position: absolute; right: 9px; top: 18px; bottom: 0; width: 1px; background: var(--line); }
.timeline li:last-child::after { display: none; }
.timeline .t-meta { color: var(--muted); font-size: 12px; }

.attach-list { display: grid; gap: 8px; }
.attach-item { display: flex; align-items: center; gap: 10px; padding: 9px 11px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-2); }
.attach-item .file-ic { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; background: #fff; border: 1px solid var(--line); color: var(--primary); }
.attach-item .file-ic svg { width: 17px; height: 17px; }
.attach-item .file-meta { flex: 1; min-width: 0; }
.attach-item .file-meta b { display: block; font-size: 13px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.attach-item .file-meta small { color: var(--muted); font-size: 11.5px; }
.dropzone { display: flex; align-items: center; justify-content: center; gap: 10px; padding: 14px; border: 1.5px dashed var(--line-strong); border-radius: 12px; color: var(--muted); font-size: 13px; cursor: pointer; transition: border-color .15s, background .15s; background: var(--surface-2); }
.dropzone:hover, .dropzone.is-over { border-color: var(--primary); background: var(--primary-soft); color: var(--primary); }

/* ---------- bars (simple charts) ---------- */
.bar-list { display: grid; gap: 12px; }
.bar-item .bar-head { display: flex; justify-content: space-between; gap: 10px; font-size: 13px; margin-bottom: 5px; }
.bar-track { height: 8px; border-radius: 10px; background: var(--surface-3); overflow: hidden; }
.bar-fill { height: 100%; border-radius: 10px; background: linear-gradient(90deg, #7b8ef0, var(--primary)); transform-origin: right; animation: grow .6s var(--ease); }
@keyframes grow { from { transform: scaleX(0); } to { transform: scaleX(1); } }

/* ---------- pagination ---------- */
.pager { display: flex; gap: 6px; align-items: center; justify-content: space-between; padding: 12px 16px; border-top: 1px solid var(--line); font-size: 12.5px; color: var(--muted); flex-wrap: wrap; }
.pager-links { display: flex; gap: 4px; }
.pager a, .pager span.cur { min-width: 32px; height: 32px; padding: 0 8px; display: grid; place-items: center; border-radius: 9px; border: 1px solid var(--line); background: #fff; color: var(--ink-2); font-size: 12.5px; }
.pager span.cur { background: var(--primary-soft); color: var(--primary); border-color: var(--primary-line); font-weight: 600; }
.pager a:hover { border-color: var(--line-strong); }

/* ---------- permission matrix ---------- */
.perm-group { border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.perm-group + .perm-group { margin-top: 12px; }
.perm-group-head { display: flex; align-items: center; justify-content: space-between; padding: 10px 14px; background: var(--surface-2); border-bottom: 1px solid var(--line); font-weight: 600; font-size: 13px; }
.perm-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 8px 16px; padding: 12px 14px; }
.perm-grid .check { font-size: 13px; }
.perm-sensitive { color: var(--warning); font-size: 11px; }

/* ---------- branding upload ---------- */
.brand-slot { display: flex; gap: 16px; align-items: center; padding: 16px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface-2); }
.brand-preview { display: grid; place-items: center; background: #fff; border: 1px dashed var(--line-strong); border-radius: 14px; color: var(--muted-2); overflow: hidden; flex: 0 0 auto; }
.brand-preview.square { width: 76px; height: 76px; }
.brand-preview.wide { width: 220px; height: 76px; }
.brand-preview img { max-width: 100%; max-height: 100%; object-fit: contain; }
.brand-info { flex: 1; min-width: 0; }
.brand-info b { display: block; font-size: 13.5px; }
.brand-info small { display: block; color: var(--muted); font-size: 12px; margin: 2px 0 10px; }

/* ---------- auth pages ---------- */
.auth-body { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: radial-gradient(circle at 12% 15%, #eef1ff 0, transparent 30%), radial-gradient(circle at 88% 82%, #eaf8f7 0, transparent 28%), #f8f9fd; }
.auth-shell { width: min(980px, 100%); display: grid; grid-template-columns: 1fr 1fr; background: #fff; border: 1px solid var(--line); border-radius: 26px; overflow: hidden; box-shadow: 0 28px 80px rgba(36, 49, 82, .12); }
.auth-shell.single { grid-template-columns: 1fr; width: min(620px, 100%); }
.auth-info { position: relative; overflow: hidden; padding: 42px; background: linear-gradient(145deg, #fbfcff, #f0f3ff); display: flex; flex-direction: column; justify-content: center; }
.auth-info::before, .auth-info::after { content: ""; position: absolute; border-radius: 50%; }
.auth-info::before { width: 240px; height: 240px; background: #dfe5ff; left: -100px; top: -95px; opacity: .55; }
.auth-info::after { width: 180px; height: 180px; background: #d9f2ef; right: -80px; bottom: -70px; opacity: .55; }
.auth-info > * { position: relative; z-index: 1; }
.auth-logo { display: flex; align-items: center; gap: 12px; margin-bottom: 34px; }
.auth-logo .brand-mark { width: 48px; height: 48px; flex-basis: 48px; border-radius: 14px; font-size: 20px; }
.auth-logo img.wide { max-height: 54px; max-width: 240px; object-fit: contain; }
.auth-info h1 { font-size: 26px; line-height: 1.5; margin-bottom: 10px; }
.auth-info p { color: var(--muted); line-height: 1.9; font-size: 13.5px; }
.auth-features { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 20px; }
.auth-features span { display: inline-flex; align-items: center; gap: 6px; background: #fff; border: 1px solid var(--line); border-radius: 30px; padding: 6px 11px; font-size: 12px; color: #5f6980; }
.auth-features svg { width: 14px; height: 14px; color: var(--primary); }
.auth-card { padding: 42px; display: flex; flex-direction: column; justify-content: center; }
.auth-card h2 { font-size: 22px; }
.auth-card .lead { color: var(--muted); font-size: 13px; margin: 4px 0 24px; }
.auth-form { display: grid; gap: 14px; }
.auth-form .input { height: 46px; }
.password-wrap { position: relative; }
.password-wrap .input { padding-left: 44px; }
.password-toggle { position: absolute; left: 6px; top: 50%; transform: translateY(-50%); width: 34px; height: 34px; border: 0; background: transparent; color: var(--muted); border-radius: 9px; display: grid; place-items: center; }
.password-toggle:hover { background: var(--surface-3); }
.auth-foot { margin-top: 22px; font-size: 11.5px; color: var(--muted-2); text-align: center; }

/* ---------- print document ---------- */
.print-page { background: #fff; color: #111; max-width: 820px; margin: 24px auto; padding: 36px 40px; border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow-sm); }
.print-head { display: flex; justify-content: space-between; align-items: center; gap: 20px; padding-bottom: 18px; border-bottom: 2px solid #1b2440; }
.print-head img { max-height: 64px; max-width: 220px; object-fit: contain; }
.print-title { text-align: center; margin: 20px 0 16px; }
.print-title h1 { font-size: 22px; }
.print-title .no { font-size: 13px; color: #555; margin-top: 4px; direction: ltr; }
.print-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 24px; margin-bottom: 16px; font-size: 13.5px; }
.print-grid div { border-bottom: 1px dotted #bbb; padding: 6px 0; }
.print-grid span { color: #666; margin-left: 6px; }
.print-amount { border: 1.5px solid #1b2440; border-radius: 10px; padding: 12px 16px; display: flex; justify-content: space-between; gap: 16px; align-items: center; margin: 14px 0; }
.print-amount b { font-size: 20px; direction: ltr; }
.print-table { width: 100%; border-collapse: collapse; font-size: 12.5px; margin-top: 8px; }
.print-table th, .print-table td { border: 1px solid #ccc; padding: 7px 9px; text-align: right; }
.print-table th { background: #f3f4f7; }
.signatures { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; margin-top: 50px; text-align: center; font-size: 13px; }
.signatures div { border-top: 1px solid #333; padding-top: 8px; }
.print-toolbar { max-width: 820px; margin: 18px auto 0; display: flex; gap: 8px; justify-content: flex-start; }

/* ---------- misc ---------- */
.divider-label { display: flex; align-items: center; gap: 10px; font-size: 12px; color: var(--muted); margin: 18px 0 12px; }
.divider-label::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.kbd { font-family: ui-monospace, Menlo, monospace; font-size: 11px; padding: 1px 6px; border-radius: 5px; border: 1px solid var(--line); background: var(--surface-2); color: var(--muted); }
.json { direction: ltr; text-align: left; white-space: pre-wrap; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px; padding: 12px; max-height: 360px; overflow: auto; margin: 0; }
.diff-table td { vertical-align: top; }
.diff-old { color: var(--danger); text-decoration: line-through; text-decoration-color: rgba(210, 86, 103, .4); }
.diff-new { color: var(--success); }
.quick-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.quick-action { display: flex; align-items: center; gap: 10px; padding: 12px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface-2); color: var(--ink-2); font-size: 13px; transition: border-color .15s, background .15s, transform .15s; }
.quick-action:hover { border-color: var(--primary-line); background: var(--primary-soft); color: var(--primary); transform: translateY(-1px); }
.quick-action .qa-icon { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; background: #fff; border: 1px solid var(--line); color: var(--primary); }
.quick-action .qa-icon svg { width: 17px; height: 17px; }
.list-plain { list-style: none; margin: 0; padding: 0; }
.list-plain li { display: flex; align-items: center; gap: 10px; padding: 11px 0; border-bottom: 1px solid #eef1f5; }
.list-plain li:last-child { border-bottom: 0; }
.mini-ic { width: 32px; height: 32px; border-radius: 10px; display: grid; place-items: center; background: var(--surface-3); border: 1px solid var(--line); color: var(--muted); flex: 0 0 32px; }
.mini-ic svg { width: 16px; height: 16px; }
.overlay { display: none; }

/* ---------- responsive ---------- */
@media (max-width: 1280px) {
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-main { grid-template-columns: minmax(0, 1fr); }
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 980px) {
  .sidebar { transform: translateX(100%); transition: transform .24s var(--ease); box-shadow: none; }
  .shell.nav-open .sidebar { transform: none; box-shadow: var(--shadow-lg); }
  .shell.nav-open .overlay { display: block; position: fixed; inset: 0; background: rgba(33, 42, 64, .3); z-index: 35; backdrop-filter: blur(2px); }
  .main { margin-right: 0; }
  .menu-toggle { display: inline-flex; }
  .topbar, .content { padding-left: 16px; padding-right: 16px; }
  .topbar-date { display: none; }
  .grid-2, .grid-3 { grid-template-columns: minmax(0, 1fr); }
  .col-9, .col-8, .col-7, .col-6, .col-5, .col-4, .col-3, .col-2 { grid-column: span 12; }
  .auth-shell { grid-template-columns: 1fr; }
  .auth-info { display: none; }
}
@media (max-width: 640px) {
  .hide-sm { display: none !important; }
  .show-sm { display: inline !important; }
  body { font-size: 14px; }
  .kpis, .grid-4 { grid-template-columns: minmax(0, 1fr); }
  .page-head { align-items: flex-start; }
  .page-head h1 { font-size: 19px; }
  .page-actions { width: 100%; }
  .page-actions .btn { flex: 1; }
  .card-body { padding: 16px; }
  .card-head { padding: 14px 16px; }
  .modal { padding: 0; align-items: flex-end; }
  .modal-box, .modal-box.wide, .modal-box.narrow { width: 100%; max-height: 92vh; border-radius: 22px 22px 0 0; }
  .modal-foot { border-radius: 0; }
  .filters .w-sm, .filters .w-md, .filters .grow { width: 100%; min-width: 0; flex: 1 1 100%; }
  .auth-card { padding: 28px 22px; }
  .quick-actions { grid-template-columns: minmax(0, 1fr); }
  .brand-slot { flex-direction: column; align-items: flex-start; }
  .print-page { margin: 0; border: 0; border-radius: 0; padding: 18px; }
  .print-grid { grid-template-columns: 1fr; }
  .toasts { left: 12px; right: 12px; bottom: 12px; width: auto; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
@media print {
  body { background: #fff; }
  .sidebar, .topbar, .page-actions, .filters, .no-print, .toasts, .print-toolbar, .pager, .overlay { display: none !important; }
  .main { margin: 0 !important; }
  .content { padding: 0 !important; max-width: none; }
  .card { box-shadow: none; border: 0; border-radius: 0; }
  .card-head { padding: 0 0 10px; }
  .table th { position: static; background: #f3f4f7 !important; }
  .table td, .table th { padding: 6px 8px; font-size: 11.5px; }
  /* الجدول كاملًا داخل الورقة: لا شريط تمرير ولا أعمدة مقصوصة (الرصيد في كشف الحساب) */
  .table-wrap { overflow: visible !important; }
  .table .truncate { white-space: normal; overflow: visible; max-width: none !important; }
  .table-print-fit td, .table-print-fit th { padding: 4px 5px; font-size: 10px; }
  .table-print-fit .doc-no, .table-print-fit .nowrap, .table-print-fit .col-num { white-space: nowrap; }
  .print-page { margin: 0; border: 0; box-shadow: none; padding: 0; max-width: none; }
  .badge { border: 0; padding: 0; }
  a { color: inherit; }
}

/* ---------- employees: avatar, balance, profile ---------- */
.emp-avatar { position: relative; display: inline-grid; place-items: center; flex: 0 0 auto; border-radius: 50%; overflow: hidden; background: var(--primary-soft); color: var(--primary); }
.emp-avatar svg { width: 56%; height: 56%; }
.emp-avatar img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; background: var(--surface-3); }
.emp-avatar-sm { width: 36px; height: 36px; }
.emp-avatar-md { width: 52px; height: 52px; }
.emp-avatar-lg { width: 92px; height: 92px; box-shadow: 0 0 0 4px var(--surface), 0 0 0 5px var(--line); }
.emp-avatar-print { width: 74px; height: 74px; border: 1px solid #cfd3db; background: #f3f4f7; color: #9aa1af; }
.emp-cell { display: flex; align-items: center; gap: 10px; min-width: 0; }
.emp-cell a { color: var(--ink); font-weight: 500; }
.emp-cell small { display: block; color: var(--muted); direction: ltr; text-align: right; font-size: 11.5px; }

.emp-hero { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
.emp-hero-main { flex: 1 1 260px; min-width: 0; }
.emp-hero h1 { font-size: 22px; line-height: 1.35; }
.emp-hero-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; color: var(--muted); font-size: 13px; margin-top: 4px; }
.emp-hero-meta .ltr { direction: ltr; }
.emp-hero-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

.bal-final { display: flex; align-items: center; justify-content: space-between; gap: 12px 20px; flex-wrap: wrap; padding: 16px 20px; border-radius: 16px; border: 1px solid var(--line); background: var(--surface-2); }
.bal-final .bal-label { color: var(--muted); font-size: 13px; }
.bal-final .bal-amount { font-size: 24px; font-weight: 600; letter-spacing: -.2px; }
.bal-final .bal-amount small { font-size: 13px; font-weight: 400; color: var(--muted); }
.bal-final .bal-kind { font-size: 15px; font-weight: 600; margin-inline-start: 6px; }
.bal-final.is-credit { background: var(--success-soft); border-color: var(--success-line); }
.bal-final.is-credit .bal-kind { color: var(--success); }
.bal-final.is-debit { background: var(--danger-soft); border-color: var(--danger-line); }
.bal-final.is-debit .bal-kind { color: var(--danger); }
.bal-final.is-zero .bal-kind { color: var(--muted); }
.bal-hint { color: var(--muted); font-size: 12px; line-height: 1.8; }
.bal-mini { display: flex; flex-direction: column; gap: 2px; }
.bal-mini .num { font-size: 20px; font-weight: 600; }

.status-card { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.status-card .status-text { flex: 1 1 220px; min-width: 0; font-size: 13px; color: var(--ink-2); line-height: 1.8; }
.choice-list { display: grid; gap: 8px; }
.choice { display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; border: 1px solid var(--line); border-radius: 13px; cursor: pointer; transition: border-color .15s, background .15s; }
.choice:hover { border-color: var(--line-strong); }
.choice input { margin-top: 3px; accent-color: var(--primary); }
.choice b { display: block; font-weight: 600; font-size: 13.5px; }
.choice span { color: var(--muted); font-size: 12px; }
.choice:has(input:checked) { border-color: var(--primary-line); background: var(--primary-soft); }

.photo-field { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.photo-field .photo-actions { display: flex; flex-direction: column; gap: 6px; }
.photo-field input[type=file] { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }

/* A4 report documents */
.print-page.a4 { max-width: 900px; }
.print-emp { display: flex; align-items: center; gap: 14px; margin: 16px 0 10px; }
.print-emp .who b { font-size: 16px; display: block; }
.print-emp .who span { color: #555; font-size: 12.5px; }
.print-bal { border: 1.5px solid #1b2440; border-radius: 10px; padding: 12px 16px; display: flex; justify-content: space-between; align-items: center; margin-top: 14px; font-size: 15px; }
.print-bal b { font-size: 18px; }
.print-bal bdi { white-space: nowrap; }
@media (max-width: 600px) { .print-bal { flex-direction: column; align-items: flex-start; gap: 4px; } }
.print-bal-split { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 6px 18px; padding: 8px 16px 0; font-size: 13px; color: #444; }
.print-bal-split b { color: #111; }

/* WhatsApp notification card / list */
.wa-card { border-color: #bfe8cf; }
.wa-card .card-icon, .wa-icon { background: #e7f8ee; color: #128c4b; }
.wa-msg { white-space: pre-wrap; background: #f3faf6; border: 1px solid #d9f0e2; border-radius: 12px; padding: 12px 14px; font-size: 13px; line-height: 1.8; color: var(--ink-2); max-height: 260px; overflow: auto; }
.btn-whatsapp { background: #1fa855; border-color: #1fa855; color: #fff; }
.btn-whatsapp:hover { background: #178f47; border-color: #178f47; color: #fff; }
.btn-whatsapp svg { color: #fff; }
.wa-row-msg { white-space: pre-wrap; font-size: 12.5px; color: var(--muted); max-width: 520px; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.print-table td.n, .print-table th.n { text-align: left; direction: ltr; white-space: nowrap; }
.print-table tfoot td { font-weight: 600; background: #f7f8fa; }
.print-stamp { display: inline-block; border: 2px solid #b8404f; color: #b8404f; border-radius: 8px; padding: 4px 14px; font-weight: 700; font-size: 14px; }
.print-meta { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; font-size: 11.5px; color: #666; margin-top: 6px; }
@media print {
  .print-page.a4 { max-width: none; }
  .emp-avatar img { print-color-adjust: exact; -webkit-print-color-adjust: exact; }
}
.show-sm { display: none; }

/* ---------- Saudi Riyal symbol (see amount() / sar_symbol()) ---------- */
.sar-sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.money { display: inline-flex; align-items: baseline; gap: .2em; direction: ltr; unicode-bidi: isolate; white-space: nowrap; font-variant-numeric: tabular-nums; }
.money .num { display: inline; }
.sar { display: inline-block; flex: none; width: .78em; height: .87em; vertical-align: -.06em; fill: currentColor; overflow: visible; align-self: center; }
.money .sar { position: relative; top: -.02em; }

/* ---------- journal lines: wide account column ---------- */
.je-lines-head { flex-wrap: wrap; gap: 10px; }
.je-tools { flex-wrap: wrap; gap: 6px; }
.je-lines { table-layout: fixed; min-width: 0; }
.je-lines col.c-no { width: 30px; }
.je-lines col.c-del { width: 40px; }
.je-lines col.c-amt { width: 112px; }
.je-lines col.c-cc { width: 13.5%; }
.je-lines col.c-party { width: 12%; }
.je-lines col.c-desc { width: 18%; }
.je-lines td { padding: 5px 4px; }
.je-lines .input { height: 42px; font-size: 13.5px; padding: 0 11px; }
.je-lines .line-no { padding-top: 15px; }
.je-lines .picker-input { text-overflow: ellipsis; }
.acc-cell { display: flex; gap: 4px; align-items: center; min-width: 0; }
.acc-cell .picker { flex: 1 1 auto; min-width: 0; }
.acc-cell .picker-list { min-width: min(420px, calc(100vw - 40px)); }
.acc-browse { width: 38px; height: 42px; flex: 0 0 38px; color: var(--muted); }
.acc-browse:hover { color: var(--primary); background: var(--primary-soft); }
.je-suggest { display: inline-flex; gap: 6px; align-items: center; font-size: 12.5px; color: var(--muted); margin-inline-end: auto; cursor: pointer; }
.je-suggest input { accent-color: var(--primary); }
.lines-total .money { margin-inline-start: 6px; }
@media (max-width: 1180px) {
  .je-lines, .je-lines tbody { display: block; }
  .je-lines colgroup, .je-lines thead { display: none; }
  .je-lines tr.line { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 40px; gap: 8px; padding: 12px; margin-bottom: 10px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface-2); position: relative; }
  .je-lines tr.line > td { display: block; padding: 0; min-width: 0; }
  .je-lines tr.line > td.line-no { position: absolute; top: -9px; inset-inline-start: 12px; width: auto; padding: 0 7px; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; font-size: 11px; line-height: 17px; }
  .je-lines tr.line > td:nth-child(2) { grid-column: 1 / -1; }                 /* account */
  .je-lines tr.line > td:nth-child(3) { grid-column: 1 / 2; }                  /* cost center */
  .je-lines tr.line > td:nth-child(4) { grid-column: 2 / -1; }                 /* party */
  .je-lines tr.line > td:nth-child(5) { grid-column: 1 / -1; }                 /* description */
  .je-lines tr.line > td:nth-child(6) { grid-column: 1 / 2; }                  /* debit */
  .je-lines tr.line > td:nth-child(7) { grid-column: 2 / 3; }                  /* credit */
  .je-lines tr.line > td.line-del { grid-column: 3 / 4; width: auto; }
  .je-lines tr.line > td:nth-child(6)::before { content: "مدين"; }
  .je-lines tr.line > td:nth-child(7)::before { content: "دائن"; }
  .je-lines tr.line > td:nth-child(6)::before, .je-lines tr.line > td:nth-child(7)::before { display: block; font-size: 11.5px; color: var(--muted); margin-bottom: 3px; }
  .je-lines tr.line > td.line-del { align-self: end; }
}

/* ---------- account browser (journal) ---------- */
.ab-box { width: min(1040px, 100%); height: min(86vh, 880px); max-height: none; }
.ab-toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; padding: 0 22px 14px; border-bottom: 1px solid var(--line); }
.ab-toolbar .input-group { flex: 1 1 280px; }
.ab-toolbar .input { height: 46px; font-size: 14.5px; }
.ab-tree { flex: 1 1 auto; overflow: auto; padding: 10px 14px; overscroll-behavior: contain; }
.ab-row { display: flex; align-items: center; gap: 10px; min-height: 42px; padding: 6px 10px; padding-inline-start: calc(10px + var(--d, 0) * 24px); border-radius: 11px; cursor: pointer; user-select: none; }
.ab-row:hover { background: var(--surface-2); }
.ab-row.is-selected { background: var(--primary-soft); }
.ab-row.is-selected .ab-name { color: var(--primary-2); }
.ab-row.is-group .ab-name { font-weight: 600; }
.ab-row.is-locked:not(.is-group) { cursor: not-allowed; opacity: .6; }
.ab-row.is-hit .ab-name { text-decoration: underline; text-decoration-color: var(--primary-line); text-underline-offset: 4px; }
.ab-toggle, .ab-toggle-pad { width: 26px; height: 26px; flex: 0 0 26px; }
.ab-toggle { border: 0; background: transparent; border-radius: 8px; display: grid; place-items: center; color: var(--muted); }
.ab-toggle:hover { background: var(--surface-3); color: var(--ink); }
.ab-toggle svg { width: 16px; height: 16px; transition: transform .15s var(--ease); }
.ab-row[aria-expanded="true"] > .ab-toggle svg { transform: rotate(-90deg); }
.ab-check { width: 18px; height: 18px; flex: 0 0 18px; accent-color: var(--primary); cursor: pointer; }
.ab-lock { width: 18px; flex: 0 0 18px; display: grid; place-items: center; color: var(--muted-2); }
.ab-lock svg { width: 15px; height: 15px; }
.ab-code { direction: ltr; unicode-bidi: isolate; color: var(--muted); font-size: 12.5px; min-width: 56px; font-variant-numeric: tabular-nums; }
.ab-name { font-size: 14px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ab-meta { margin-inline-start: auto; color: var(--muted-2); font-size: 11.5px; white-space: nowrap; }
.ab-foot { align-items: center; flex-wrap: wrap; }
.ab-count { font-variant-numeric: tabular-nums; }
.ab-hint { margin-inline-start: auto; display: inline-flex; gap: 5px; align-items: center; }
.ab-hint svg { width: 13px; height: 13px; }
button.choice { width: 100%; text-align: start; background: var(--surface); font: inherit; color: inherit; align-items: center; }
button.choice > svg { width: 20px; height: 20px; flex: 0 0 20px; color: var(--primary); }
button.choice:hover { border-color: var(--primary-line); background: var(--primary-soft); }
@media (max-width: 640px) {
  .ab-box { height: 92vh; }
  .ab-meta, .ab-hint { display: none; }
}
.table td.nowrap, .table th.nowrap { white-space: nowrap; }

/* ---------- payment vouchers: list, timeline, filters ---------- */
.pvl-filters { padding: 14px 16px; display: grid; gap: 12px; margin-bottom: 16px; }
.pvl-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.pvl-search { flex: 1 1 260px; min-width: 0; }
.pvl-dates { display: flex; align-items: center; gap: 6px; flex: 0 1 auto; flex-wrap: wrap; }
.pvl-dates .input { width: 150px; }
.seg { display: inline-flex; padding: 3px; gap: 2px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-2); }
.seg-opt { position: relative; }
.seg-opt input { position: absolute; opacity: 0; pointer-events: none; }
.seg-opt span { display: inline-block; padding: 7px 13px; border-radius: 9px; font-size: 13px; color: var(--muted); cursor: pointer; white-space: nowrap; }
.seg-opt input:checked + span { background: var(--surface); color: var(--ink); font-weight: 600; box-shadow: var(--shadow-xs); }
.seg-opt input:focus-visible + span { outline: 2px solid var(--focus); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); color: var(--ink-2); font-size: 12.5px; text-decoration: none; }
.chip:hover { border-color: var(--line-strong); }
.chip.is-active { background: var(--primary-soft); border-color: var(--primary-line); color: var(--primary-2); font-weight: 600; }
.chip-count { min-width: 20px; padding: 0 6px; border-radius: 999px; background: var(--surface-3); color: var(--muted); font-size: 11px; text-align: center; font-variant-numeric: tabular-nums; }
.chip.is-active .chip-count { background: var(--surface); color: var(--primary-2); }
.select-sm { height: 34px; font-size: 12.5px; padding: 0 28px 0 10px; }
.pvl-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 0 2px 10px; flex-wrap: wrap; }
.pvl-title { font-size: 15px; font-weight: 600; }
.pvl { display: grid; gap: 10px; }
.pvl-item { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1.35fr) auto; gap: 12px 22px; align-items: center; padding: 14px 18px; background: var(--surface); border: 1px solid var(--line); border-radius: 18px; transition: border-color .15s, box-shadow .15s; }
.pvl-item:hover { border-color: var(--line-strong); box-shadow: var(--shadow-sm); }
.pvl-item.is-reversed { opacity: .72; }
.pvl-who { display: flex; gap: 12px; align-items: center; min-width: 0; }
.pvl-icon { width: 52px; height: 52px; flex: 0 0 52px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-3); color: var(--muted); }
.pvl-icon svg { width: 22px; height: 22px; }
.pvl-text { min-width: 0; display: grid; gap: 2px; }
.pvl-line1 { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.pvl-type { font-size: 11px; color: var(--muted); border: 1px solid var(--line); border-radius: 999px; padding: 1px 8px; }
.pvl-name { color: var(--ink); font-weight: 600; font-size: 14.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pvl-desc { color: var(--muted); font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pvl-mid { min-width: 0; display: grid; gap: 8px; }
.pvl-facts { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 12px; color: var(--muted); }
.pvl-facts span { display: inline-flex; align-items: center; gap: 5px; min-width: 0; }
.pvl-facts svg { width: 13px; height: 13px; flex: 0 0 13px; }
.pvl-side { display: grid; justify-items: end; gap: 6px; }
.pvl-amount { font-size: 18px; font-weight: 600; }
.pvl-actions { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.pvl-more { display: flex; justify-content: center; margin-top: 16px; }
.pvl-pager { margin-top: 14px; padding: 0 4px; display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 10px; }
.pv-notice { margin-bottom: 14px; }
.pv-tl-card { margin-bottom: 16px; }
.pv-tl-card .card-body { padding: 18px 22px 14px; }

/* horizontal progress line */
.tl { list-style: none; display: flex; align-items: flex-start; margin: 0; padding: 0; counter-reset: none; }
.tl-step { position: relative; flex: 1 1 0; min-width: 0; display: grid; justify-items: center; gap: 4px; text-align: center; }
.tl-step + .tl-step::before { content: ""; position: absolute; top: 12px; inset-inline-end: 50%; width: 100%; height: 2px; background: var(--line); z-index: 0; }
.tl-step.is-done + .tl-step::before, .tl-step.is-done + .tl-step.is-current::before, .tl-step.is-done + .tl-step.is-failed::before { background: var(--success); }
.tl-dot { position: relative; z-index: 1; width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; background: var(--surface); border: 2px solid var(--line-strong); color: var(--muted-2); }
.tl-dot svg { width: 14px; height: 14px; }
.tl-step.is-done .tl-dot { background: var(--success); border-color: var(--success); color: #fff; }
.tl-step.is-failed .tl-dot { background: var(--danger); border-color: var(--danger); color: #fff; }
.tl-step.is-current .tl-dot { border-color: var(--warning); background: var(--warning-soft); animation: tlPulse 1.8s ease-out infinite; }
.tl-core { width: 9px; height: 9px; border-radius: 50%; background: var(--warning); }
.tl-label { font-size: 12.5px; color: var(--ink-2); font-weight: 500; line-height: 1.4; }
.tl-step.is-todo .tl-label { color: var(--muted-2); font-weight: 400; }
.tl-step.is-current .tl-label { color: #8a5d14; font-weight: 600; }
.tl-step.is-failed .tl-label { color: var(--danger); font-weight: 600; }
.tl-sub { font-size: 11px; color: var(--muted); }
.tl-step.is-current .tl-sub { color: #8a5d14; }
.tl-at { font-size: 10.5px; color: var(--muted-2); }
.tl.is-compact .tl-dot { width: 20px; height: 20px; }
.tl.is-compact .tl-dot svg { width: 11px; height: 11px; }
.tl.is-compact .tl-core { width: 7px; height: 7px; }
.tl.is-compact .tl-step + .tl-step::before { top: 9px; }
.tl.is-compact .tl-label { font-size: 11px; }
.tl.is-compact .tl-sub { font-size: 10.5px; }
@keyframes tlPulse { 0% { box-shadow: 0 0 0 0 rgba(214, 150, 46, .45); } 70% { box-shadow: 0 0 0 8px rgba(214, 150, 46, 0); } 100% { box-shadow: 0 0 0 0 rgba(214, 150, 46, 0); } }
@media (prefers-reduced-motion: reduce) { .tl-step.is-current .tl-dot { animation: none; } }
.print-copy { display: block; width: max-content; margin: -8px auto 12px; padding: 3px 14px; border: 1.5px solid #1b2440; border-radius: 999px; font-size: 12.5px; font-weight: 700; }

@media (max-width: 1100px) {
  .pvl-item { grid-template-columns: minmax(0, 1fr) auto; }
  .pvl-mid { grid-column: 1 / -1; order: 3; }
}
@media (max-width: 640px) {
  .pvl-item { grid-template-columns: minmax(0, 1fr); padding: 14px; }
  .pvl-side { justify-items: start; grid-template-columns: auto auto; align-items: center; justify-content: space-between; }
  .pvl-actions { grid-column: 1 / -1; justify-content: flex-start; }
  .pvl-dates { flex: 1 1 100%; }
  .pvl-dates .input { flex: 1 1 0; width: auto; min-width: 0; }
  .seg { flex: 1 1 100%; }
  .seg-opt { flex: 1 1 0; }
  .seg-opt span { display: block; text-align: center; padding: 7px 6px; }
  .tl-label { font-size: 11px; }
}

/* ---- custody settlement (v1.9.0): six-column expense rows + open custodies + cash returned ---- */
.cst .dist-cols, .cst .dist-row { grid-template-columns: minmax(0, 2fr) minmax(0, 1.3fr) minmax(0, 1.6fr) minmax(0, 1fr) minmax(100px, .8fr) 36px; }
.cst-open { border: 1px solid var(--line); border-radius: 14px; padding: 12px; background: var(--surface-2); display: grid; gap: 10px; }
.cst-open[hidden] { display: none; }
.cst-open-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; font-size: 13px; color: var(--muted); }
.cst-open-head > span { display: inline-flex; align-items: center; gap: 6px; }
.cst-open-head svg { width: 16px; height: 16px; }
.cst-open-head b { font-size: 18px; color: var(--ink); }
.cst-return { border-top: 1px solid var(--line); padding-top: 14px; display: grid; gap: 10px; }
.cst-return [hidden] { display: none; }
@media (max-width: 760px) {
  .cst .dist-row { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 36px; }
  .cst .dist-desc { grid-column: 1 / -1; }
  .cst .dist-ref { grid-column: 1 / 2; }
  .cst .dist-amount { grid-column: 2 / 3; }
  .cst .dist-del { grid-column: 3 / 4; grid-row: 1; }
  .cst .dist-account, .cst .dist-cc { grid-column: 1 / 3; }
}

/* ---------- مكتبة الراقي (library) ---------- */
.lib-kpi { display: block; color: inherit; text-decoration: none; transition: transform .15s var(--ease), box-shadow .15s var(--ease); }
.lib-kpi:hover { transform: translateY(-2px); box-shadow: 0 8px 22px rgba(24, 32, 51, .08); color: inherit; }
.t-danger { color: var(--danger); } .t-warning { color: var(--warning); } .t-success { color: var(--success); } .t-neutral { color: var(--muted); }
.lib-chip { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 500; padding: 3px 9px; border-radius: 30px; color: var(--gc, var(--primary)); background: var(--gs, var(--primary-soft)); }
.lib-chip svg { width: 13px; height: 13px; }
.lib-chip a { color: inherit; }
.lib-section-head { display: flex; align-items: center; justify-content: space-between; margin: 24px 0 12px; }
.lib-section-head h2 { font-size: 16px; }

.lib-alerts { list-style: none; margin: 0; padding: 6px 0; }
.lib-alerts li { display: flex; align-items: center; gap: 12px; padding: 10px 20px; border-inline-start: 3px solid transparent; }
.lib-alerts li + li { border-top: 1px solid var(--line); }
.lib-alerts li.is-expired { border-inline-start-color: var(--danger); }
.lib-alerts li.is-expiring { border-inline-start-color: var(--warning); }
.lib-alert-icon { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; flex: 0 0 34px; }
.lib-alert-icon svg { width: 17px; height: 17px; }
.is-expired .lib-alert-icon { background: var(--danger-soft); color: var(--danger); }
.is-expiring .lib-alert-icon { background: var(--warning-soft); color: var(--warning); }
.lib-alert-main { flex: 1; min-width: 0; color: var(--ink); }
.lib-alert-main b { display: block; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lib-alert-main small { color: var(--muted); font-size: 12px; }
.lib-alert-days { font-size: 12.5px; font-weight: 600; white-space: nowrap; }
.is-expired .lib-alert-days { color: var(--danger); } .is-expiring .lib-alert-days { color: var(--warning); }
.lib-recent { display: flex; gap: 10px; align-items: center; padding: 7px 0; color: var(--ink); }
.lib-recent svg { width: 16px; height: 16px; color: var(--muted); flex: 0 0 16px; }
.lib-recent b { display: block; font-weight: 500; font-size: 13px; }
.lib-recent small { color: var(--muted); font-size: 11.5px; }

.lib-groups { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; }
.lib-group { position: relative; background: var(--surface); border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow-sm); overflow: hidden; transition: transform .15s var(--ease), box-shadow .15s var(--ease); }
.lib-group::before { content: ""; position: absolute; inset: 0 0 auto 0; height: 4px; background: var(--gc); }
.lib-group:hover { transform: translateY(-2px); box-shadow: 0 10px 26px rgba(24, 32, 51, .08); }
.lib-group-link { display: flex; flex-direction: column; gap: 4px; padding: 18px; color: var(--ink); min-height: 150px; }
.lib-group-link:hover { color: var(--ink); }
.lib-group-icon { width: 42px; height: 42px; border-radius: 13px; display: grid; place-items: center; background: var(--gs); color: var(--gc); margin-bottom: 6px; }
.lib-group-icon svg { width: 21px; height: 21px; }
.lib-group-name { font-weight: 600; font-size: 15px; }
.lib-group-count { color: var(--muted); font-size: 12.5px; }
.lib-group-desc { color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lib-group-bar { display: flex; height: 6px; border-radius: 6px; background: var(--surface-3); overflow: hidden; margin-top: auto; }
.lib-group-bar i { display: block; height: 100%; }
.b-expired { background: var(--danger); } .b-expiring { background: #e0a84a; } .b-valid { background: var(--success); }
.lib-group-meta { display: flex; gap: 10px; font-size: 11.5px; min-height: 16px; }
.lib-group-tools { position: absolute; top: 10px; left: 10px; display: flex; gap: 2px; opacity: 0; transition: opacity .15s; }
.lib-group:hover .lib-group-tools, .lib-group:focus-within .lib-group-tools { opacity: 1; }
.lib-group-add { display: grid; place-items: center; align-content: center; gap: 6px; min-height: 150px; border-style: dashed; color: var(--muted); cursor: pointer; font: inherit; }
.lib-group-add::before { display: none; }
.lib-group-add svg { width: 24px; height: 24px; }
.lib-group-add:hover { color: var(--primary); border-color: var(--primary-line); }

.lib-toolbar { padding-bottom: 12px; margin-bottom: 16px; }
.lib-chips { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; padding: 0 20px; }
.lib-chips-end { margin-inline-start: auto; display: flex; gap: 8px; align-items: center; }
.lib-filter { display: inline-flex; align-items: center; gap: 5px; height: 30px; padding: 0 12px; border-radius: 30px; border: 1px solid var(--line); background: var(--surface); color: var(--ink-2); font: inherit; font-size: 12.5px; cursor: pointer; white-space: nowrap; }
.lib-filter svg { width: 14px; height: 14px; }
.lib-filter:hover { border-color: #d5dbe7; color: var(--ink); }
.lib-filter.is-active { background: var(--primary-soft); border-color: var(--primary-line); color: var(--primary); font-weight: 500; }
.lib-filter.t-danger.is-active { background: var(--danger-soft); border-color: var(--danger-line); color: var(--danger); }
.lib-filter.t-warning.is-active { background: var(--warning-soft); border-color: var(--warning-line); color: var(--warning); }
.lib-filter.t-success.is-active { background: var(--success-soft); border-color: var(--success-line); color: var(--success); }
.lib-view { margin: 0; }
.lib-view a { padding: 0 9px; }
.lib-view svg { width: 15px; height: 15px; }

.lib-docs { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; }
.lib-doc { display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; overflow: hidden; box-shadow: var(--shadow-sm); transition: transform .15s var(--ease), box-shadow .15s var(--ease); }
.lib-doc:hover { transform: translateY(-2px); box-shadow: 0 10px 26px rgba(24, 32, 51, .08); }
.lib-doc.is-expired { border-color: var(--danger-line); }
.lib-doc.is-expiring { border-color: var(--warning-line); }
.lib-doc-thumb { position: relative; display: block; height: 140px; background: linear-gradient(160deg, var(--gs), var(--surface-2)); overflow: hidden; }
.lib-doc-thumb img { width: 100%; height: 100%; object-fit: cover; object-position: top; }
.lib-doc-ph { position: absolute; inset: 0; display: grid; place-items: center; align-content: center; gap: 4px; color: var(--gc); }
.lib-doc-ph svg { width: 40px; height: 40px; stroke-width: 1.4; }
.lib-doc-ph b { font-size: 11px; letter-spacing: .08em; opacity: .75; }
.lib-doc-status { position: absolute; top: 10px; right: 10px; box-shadow: 0 2px 8px rgba(0, 0, 0, .08); }
.lib-doc-files { position: absolute; bottom: 8px; left: 10px; display: inline-flex; gap: 3px; align-items: center; font-size: 11px; background: rgba(255, 255, 255, .9); padding: 2px 7px; border-radius: 20px; color: var(--ink-2); }
.lib-doc-files svg { width: 12px; height: 12px; }
.lib-doc-body { padding: 12px 14px 4px; display: grid; gap: 5px; justify-items: start; min-width: 0; }
.lib-doc-body h3 { font-size: 14.5px; font-weight: 600; line-height: 1.45; margin: 0; }
.lib-doc-body h3 a { color: var(--ink); }
.lib-doc-body p { margin: 0; max-width: 100%; }
.lib-doc-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 10px 10px 14px; margin-top: auto; }
.lib-doc-exp { display: grid; font-size: 12px; color: var(--muted); }
.lib-doc-exp b { font-weight: 600; color: var(--ink-2); }
.is-expired .lib-doc-exp b { color: var(--danger); } .is-expiring .lib-doc-exp b { color: var(--warning); } .is-valid .lib-doc-exp b { color: var(--success); }

.lib-viewer { overflow: hidden; }
.lib-viewer-tabs { display: flex; gap: 6px; padding: 10px 12px; border-bottom: 1px solid var(--line); overflow-x: auto; }
.lib-viewer-frame { height: min(78vh, 900px); background: #eef1f6; display: grid; place-items: center; }
.lib-viewer-frame iframe { width: 100%; height: 100%; border: 0; background: #fff; }
.lib-viewer-frame img { max-width: 100%; max-height: 100%; object-fit: contain; }
.lib-status-card { display: flex; gap: 16px; align-items: center; padding: 18px; }
.lib-status-days { font-size: 19px; font-weight: 600; margin: 6px 0 2px; }
.lib-status-card.is-expired .lib-status-days { color: var(--danger); } .lib-status-card.is-expiring .lib-status-days { color: var(--warning); } .lib-status-card.is-valid .lib-status-days { color: var(--success); }
.lib-ring { --c: var(--success); width: 64px; height: 64px; flex: 0 0 64px; border-radius: 50%; display: grid; place-items: center; background: conic-gradient(var(--c) calc(var(--p) * 1%), var(--surface-3) 0); }
.lib-ring span { width: 50px; height: 50px; border-radius: 50%; background: var(--surface); display: grid; place-items: center; color: var(--c); }
.lib-ring svg { width: 22px; height: 22px; }
.is-expired .lib-ring { --c: var(--danger); } .is-expiring .lib-ring { --c: #d79a36; } .is-none .lib-ring { --c: var(--slate); }
.lib-files { display: grid; gap: 6px; }
.lib-files > a, .lib-file-row > a, .lib-file-pick { display: flex; align-items: center; gap: 8px; min-width: 0; padding: 8px 10px; border: 1px solid var(--line); border-radius: 10px; color: var(--ink); font-size: 13px; }
.lib-files svg { width: 16px; height: 16px; flex: 0 0 16px; color: var(--muted); }
.lib-file-row { display: flex; align-items: center; gap: 4px; }
.lib-file-row > a { flex: 1; }
.lib-file-row small, .lib-file-pick small { margin-inline-start: auto; color: var(--muted); font-size: 11px; white-space: nowrap; }
.lib-file-pick { cursor: pointer; }
.lib-file-pick:has(input:checked) { border-color: var(--success); background: #f1fbf5; }
.lib-file-pick.is-disabled { opacity: .55; cursor: not-allowed; }
.lib-shares { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.lib-shares li { display: flex; gap: 8px; align-items: flex-start; font-size: 13px; }
.lib-shares small { display: block; color: var(--muted); font-size: 11.5px; }

.lib-drop { position: relative; display: grid; justify-items: center; gap: 4px; padding: 22px 14px; border: 2px dashed var(--line); border-radius: 14px; background: var(--surface-2); text-align: center; cursor: pointer; transition: border-color .15s, background .15s; }
.lib-drop input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.lib-drop > svg { width: 30px; height: 30px; color: var(--primary); }
.lib-drop b { font-weight: 500; font-size: 13.5px; }
.lib-drop small { color: var(--muted); font-size: 12px; }
.lib-drop.is-over, .lib-drop:hover { border-color: var(--primary); background: var(--primary-soft); }
.lib-drop.has-files { border-style: solid; border-color: var(--success-line); background: var(--success-soft); }
.lib-drop ul { list-style: none; margin: 6px 0 0; padding: 0; font-size: 12px; color: var(--success); }
.lib-alert-pick { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.lib-cal { position: relative; }
.lib-cal input { position: absolute; opacity: 0; pointer-events: none; }
[data-points] .lib-filter.is-active::before { content: "✓"; font-weight: 700; }
.lib-points { display: inline-flex; flex-wrap: wrap; gap: 4px; }
.lib-points span { font-size: 11.5px; padding: 1px 8px; border-radius: 20px; background: var(--surface-2, #f1f4f8); color: var(--ink-2); }
.lib-points span.is-hit { background: var(--warning-soft); color: var(--warning); font-weight: 600; }
.lib-points span.is-past { text-decoration: line-through; opacity: .55; }
.lib-hijri { display: block; font-size: 11.5px; color: var(--ink-3, #7a869a); }
.lib-swatches { display: flex; flex-wrap: wrap; gap: 8px; }
.lib-swatch, .lib-icon-opt { position: relative; }
.lib-swatch input, .lib-icon-opt input { position: absolute; opacity: 0; pointer-events: none; }
.lib-swatch span { display: block; width: 28px; height: 28px; border-radius: 50%; background: var(--c); cursor: pointer; box-shadow: 0 0 0 2px var(--surface), 0 0 0 3px transparent; transition: box-shadow .15s; }
.lib-swatch input:checked + span { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--ink-2); }
.lib-icons { display: flex; flex-wrap: wrap; gap: 6px; }
.lib-icon-opt span { width: 38px; height: 38px; display: grid; place-items: center; border-radius: 10px; border: 1px solid var(--line); cursor: pointer; color: var(--ink-2); }
.lib-icon-opt span svg { width: 18px; height: 18px; }
.lib-icon-opt input:checked + span { border-color: var(--primary); background: var(--primary-soft); color: var(--primary); }

/* payment cards */
.pc-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 18px; }
.pc-item { background: var(--surface); border: 1px solid var(--line); border-radius: 20px; padding: 14px; box-shadow: var(--shadow-sm); display: grid; gap: 10px; min-width: 0; }
.pc-item.is-off { opacity: .6; }
.pc-face { position: relative; aspect-ratio: 1.586; border-radius: 16px; padding: 18px 20px; color: #fff; display: flex; flex-direction: column; overflow: hidden; box-shadow: 0 12px 28px rgba(20, 28, 50, .22); direction: ltr; }
.pc-face::after { content: ""; position: absolute; width: 240px; height: 240px; border-radius: 50%; right: -90px; top: -110px; background: rgba(255, 255, 255, .08); }
.pc-top { display: flex; justify-content: space-between; gap: 8px; position: relative; z-index: 1; }
.pc-label { font-weight: 600; font-size: 14px; direction: rtl; }
.pc-bank { font-size: 12px; opacity: .85; direction: rtl; }
.pc-chip { width: 40px; height: 30px; border-radius: 6px; margin-top: 14px; background: linear-gradient(135deg, #e9d18f, #b8913f); position: relative; z-index: 1; }
.pc-number { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 20px; letter-spacing: .08em; margin-top: auto; position: relative; z-index: 1; white-space: nowrap; }
.pc-bottom { display: flex; gap: 18px; align-items: flex-end; margin-top: 10px; position: relative; z-index: 1; }
.pc-bottom small { display: block; font-size: 9.5px; opacity: .7; text-transform: uppercase; }
.pc-bottom b { font-weight: 500; font-size: 13px; font-family: ui-monospace, Menlo, Consolas, monospace; }
.pc-holder { max-width: 150px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: block; text-transform: uppercase; }
.pc-brand { margin-inline-start: auto; font-weight: 800; font-style: italic; font-size: 18px; letter-spacing: .02em; }
.pc-mastercard { font-style: normal; font-weight: 600; font-size: 14px; }
.pc-mada { font-style: normal; font-size: 17px; }
.pc-meta { display: flex; gap: 6px; align-items: center; min-width: 0; }
.pc-actions { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.pc-mono { font-family: ui-monospace, Menlo, Consolas, monospace; letter-spacing: .06em; }

@media (max-width: 640px) {
  .lib-docs { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .lib-doc-thumb { height: 110px; }
  .lib-groups { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .lib-group-link { min-height: 130px; padding: 14px; }
  .lib-group-tools { opacity: 1; }
  .lib-chips { padding: 0 14px; }
  .lib-chips-end { margin-inline-start: 0; width: 100%; justify-content: space-between; }
  .lib-alerts li { padding: 10px 14px; }
  .lib-viewer-frame { height: 60vh; }
  .pc-grid { grid-template-columns: minmax(0, 1fr); }
  .pc-face { padding: 14px 16px; }
  .pc-number { font-size: 17px; }
}

/* =====================================================================
   Theme v3 (1.10.8): «أزرق ثلاثي الأبعاد».
   Soft raised surfaces on a cool blue background, one blue accent,
   a floating sidebar with drop-down sections (folds to icons, remembered
   per browser) and the screen search in the top bar.
   ===================================================================== */
:root {
  --bg: #e9eefa;
  --surface: #f3f6fd;
  --surface-2: #f6f8fe;
  --surface-3: #e8edf9;
  --line: #dfe6f5;
  --line-strong: #cfd8ee;
  --ink: #141c3a;
  --ink-2: #33406a;
  --muted: #7d88aa;
  --muted-2: #a3acc8;
  --primary: #2f5bff;
  --primary-2: #2447e6;
  --primary-soft: #e3eaff;
  --primary-line: #cfdbff;
  --raise: 9px 9px 22px rgba(118, 138, 196, .22), -8px -8px 20px rgba(255, 255, 255, .95);
  --raise-sm: 5px 5px 12px rgba(118, 138, 196, .2), -5px -5px 12px rgba(255, 255, 255, .9);
  --press: inset 3px 3px 8px rgba(118, 138, 196, .22), inset -3px -3px 8px rgba(255, 255, 255, .9);
  --shadow-xs: var(--raise-sm);
  --shadow-sm: var(--raise);
  --shadow: 0 24px 60px rgba(40, 60, 140, .16);
  --focus: 0 0 0 4px rgba(47, 91, 255, .16);
  --blue-grad: linear-gradient(135deg, #4a74ff, #2447e6);
  --side-w: 268px;
  --side-gap: 16px;
  --sidebar-w: calc(var(--side-w) + var(--side-gap) * 2);
}
.shell { --sidebar-w: calc(var(--side-w) + var(--side-gap) * 2); }
.shell.nav-folded { --side-w: 84px; }
html, body { background: var(--bg); }
::selection { background: #cfdbff; }

/* soft 3D orbs behind everything */
body::before, body::after { content: ""; position: fixed; z-index: -1; border-radius: 50%; pointer-events: none; }
body::before { width: 520px; height: 520px; left: -180px; top: -200px; background: radial-gradient(circle at 35% 30%, #fff 0, #c5d4ff 45%, rgba(197, 212, 255, 0) 70%); animation: orbFloat 16s ease-in-out infinite; }
body::after { width: 380px; height: 380px; left: 38%; bottom: -220px; background: radial-gradient(circle at 35% 30%, #fff 0, #d3ddff 45%, rgba(211, 221, 255, 0) 70%); animation: orbFloat 18s ease-in-out -6s infinite; }
@keyframes orbFloat { 0%, 100% { transform: translate(0, 0); } 50% { transform: translate(20px, -24px); } }
.shell { position: relative; z-index: 0; }

/* ---------- sidebar ---------- */
.sidebar {
  position: fixed; top: var(--side-gap); bottom: var(--side-gap); right: var(--side-gap); left: auto; inset-inline-start: auto;
  width: var(--side-w); display: flex; flex-direction: column; z-index: 40; overflow: hidden;
  background: #eef2fc; border: 1px solid rgba(255, 255, 255, .9); border-radius: 26px;
  box-shadow: 12px 12px 30px rgba(118, 138, 196, .28), -10px -10px 26px rgba(255, 255, 255, .9);
  transition: width .32s var(--ease), transform .3s var(--ease);
}
.side-top { display: flex; align-items: center; gap: 11px; padding: 18px 16px 10px; }
.side-logo { width: 44px; height: 44px; flex: 0 0 44px; border-radius: 14px; display: grid; place-items: center; overflow: hidden; color: #fff; font-weight: 700; font-size: 19px; background: var(--blue-grad); box-shadow: 0 10px 22px rgba(47, 91, 255, .35), inset 0 1px 0 rgba(255, 255, 255, .4); transition: transform .2s var(--ease); }
.side-logo:hover { transform: scale(1.05); color: #fff; }
.side-logo img { width: 100%; height: 100%; object-fit: contain; background: #fff; }
.side-who { flex: 1; min-width: 0; }
.side-who small { display: block; font-size: 11px; color: var(--muted); line-height: 1.3; }
.side-who b { display: block; font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.side-fold { width: 32px; height: 32px; flex: 0 0 32px; border: 0; border-radius: 10px; display: grid; place-items: center; color: var(--muted); background: #eef2fc; box-shadow: var(--raise-sm); transition: color .2s, box-shadow .2s; }
.side-fold:hover { color: var(--primary); }
.side-fold:active { box-shadow: var(--press); }
.side-fold svg { width: 16px; height: 16px; transition: transform .32s var(--ease); }
.side-label { font-size: 10.5px; font-weight: 600; letter-spacing: .4px; color: var(--muted-2); padding: 10px 22px 6px; white-space: nowrap; }
.side-nav { flex: 1; overflow-y: auto; overflow-x: hidden; padding: 4px 12px 12px; scrollbar-width: none; }
.side-nav::-webkit-scrollbar { display: none; }
.side-sec { margin-bottom: 3px; }
.side-btn { position: relative; width: 100%; display: flex; align-items: center; gap: 12px; height: 44px; padding: 0 12px; border: 0; border-radius: 14px; background: transparent; color: var(--ink-2); text-align: right; transition: background .2s var(--ease), color .2s var(--ease), box-shadow .2s var(--ease); }
.side-btn > svg:first-child { width: 20px; height: 20px; flex: 0 0 20px; stroke-width: 1.7; }
.side-text { flex: 1; min-width: 0; font-size: 14px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.side-chev { width: 16px !important; height: 16px !important; color: var(--muted-2); transition: transform .3s var(--ease); }
.side-btn:hover { background: #e4eafa; color: var(--ink); }
.side-sec.is-open > .side-btn .side-chev { transform: rotate(-180deg); }
.side-sec.has-active > .side-btn { color: var(--primary); }
.side-btn.is-solo.is-active { background: var(--blue-grad); color: #fff; box-shadow: 0 10px 22px rgba(47, 91, 255, .32), inset 0 1px 0 rgba(255, 255, 255, .35); }
.side-badge { min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px; display: grid; place-items: center; font-size: 11px; font-weight: 600; color: #fff; background: var(--blue-grad); box-shadow: 0 4px 10px rgba(47, 91, 255, .3); }
.side-badge.is-green { background: linear-gradient(135deg, #34c38f, #12985f); box-shadow: 0 4px 10px rgba(18, 152, 95, .3); }
.side-sub { display: grid; grid-template-rows: 0fr; transition: grid-template-rows .32s var(--ease); }
.side-sec.is-open > .side-sub { grid-template-rows: 1fr; }
.side-sub-in { overflow: hidden; }
.side-grp { font-size: 10.5px; font-weight: 600; color: var(--muted-2); padding: 8px 46px 2px 0; }
.side-tree { position: relative; margin-right: 22px; padding: 2px 0 6px; }
.side-tree::before { content: ""; position: absolute; right: 0; top: 0; bottom: 24px; width: 1.5px; border-radius: 2px; background: rgba(47, 91, 255, .22); }
.side-leaf { position: relative; display: flex; align-items: center; gap: 8px; height: 36px; margin: 1px 0; padding: 0 22px 0 10px; border-radius: 11px; font-size: 13.5px; color: var(--muted); white-space: nowrap; transition: background .2s var(--ease), color .2s var(--ease), padding .2s var(--ease); }
.side-leaf > span:first-child { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.side-leaf::before { content: ""; position: absolute; right: 0; top: 50%; width: 14px; height: 12px; margin-top: -12px; border-bottom: 1.5px solid rgba(47, 91, 255, .22); border-right: 1.5px solid rgba(47, 91, 255, .22); border-bottom-right-radius: 9px; transform: translateX(1.5px); }
.side-leaf:hover { color: var(--ink); background: #e4eafa; padding-right: 26px; }
.side-leaf.is-active { color: #fff; font-weight: 600; background: var(--blue-grad); box-shadow: 0 8px 18px rgba(47, 91, 255, .3), inset 0 1px 0 rgba(255, 255, 255, .35); }
.side-leaf.is-active::after { content: ""; position: absolute; right: -4px; top: 50%; width: 8px; height: 8px; margin-top: -4px; border-radius: 50%; background: var(--primary-2); box-shadow: 0 0 0 3px #eef2fc; }
.side-leaf.is-active .side-badge { background: rgba(255, 255, 255, .25); box-shadow: none; }
.side-foot { margin: 6px 12px 12px; padding: 6px; border-radius: 18px; background: #eef2fc; box-shadow: var(--press); }
.side-foot a, .side-foot button { width: 100%; display: flex; align-items: center; gap: 12px; height: 40px; padding: 0 12px; border: 0; border-radius: 12px; background: transparent; color: var(--muted); font-size: 13.5px; text-align: right; white-space: nowrap; transition: color .2s, background .2s; }
.side-foot a:hover, .side-foot button:hover { color: var(--ink); background: #e4eafa; }
.side-foot button:hover { color: var(--danger); }
.side-foot svg { width: 18px; height: 18px; flex: 0 0 18px; }
.side-foot form { margin: 0; }

/* folded: icons only, labels as tooltips */
.shell.nav-folded .side-who, .shell.nav-folded .side-text, .shell.nav-folded .side-chev, .shell.nav-folded .side-label { display: none; }
.shell.nav-folded .side-top { flex-direction: column; padding: 16px 0 10px; }
.shell.nav-folded .side-fold svg { transform: rotate(180deg); }
.shell.nav-folded .side-sub { grid-template-rows: 0fr !important; }
.shell.nav-folded .side-btn, .shell.nav-folded .side-foot a, .shell.nav-folded .side-foot button { width: 52px; margin: 0 auto; padding: 0; justify-content: center; }
.shell.nav-folded .side-sec.has-active > .side-btn { background: var(--blue-grad); color: #fff; box-shadow: 0 10px 22px rgba(47, 91, 255, .32); }
.shell.nav-folded .side-btn .side-badge { position: absolute; top: 5px; left: 5px; min-width: 9px; width: 9px; height: 9px; padding: 0; font-size: 0; }
.shell.nav-folded .side-foot { margin: 6px 10px 12px; }
.shell.nav-folded .sidebar { overflow: visible; }
.shell.nav-folded .side-nav { overflow: visible; }
.shell.nav-folded [data-tip]:hover::after { content: attr(data-tip); position: absolute; right: calc(100% + 12px); top: 50%; transform: translateY(-50%); z-index: 80; padding: 5px 10px; border-radius: 8px; background: var(--ink); color: #fff; font-size: 12px; font-weight: 500; white-space: nowrap; pointer-events: none; }
.side-foot a, .side-foot button { position: relative; }

/* ---------- main area ---------- */
.main { margin-right: var(--sidebar-w); transition: margin-right .32s var(--ease); }
.topbar { height: 76px; padding: 0 28px 0 28px; background: transparent; backdrop-filter: none; border: 0; }
.topbar.is-scrolled { background: rgba(233, 238, 250, .82); backdrop-filter: saturate(160%) blur(12px); }
.topbar .menu-toggle { display: none; }
.company-chip { height: 44px; padding: 0 14px; border-radius: 14px; border: 1px solid rgba(255, 255, 255, .9); background: var(--surface); box-shadow: var(--raise-sm); }
.company-chip svg { color: var(--primary); }
.topbar-date { height: 44px; display: inline-flex; align-items: center; padding: 0 14px; border-radius: 14px; background: var(--surface); box-shadow: var(--raise-sm); font-size: 12.5px; color: var(--muted); }
.content { animation: contentIn .3s var(--ease); }
@keyframes contentIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* screen search */
.cmd { position: relative; flex: 0 1 480px; min-width: 0; }
.cmd .cmd-ic { position: absolute; right: 15px; top: 50%; transform: translateY(-50%); width: 18px; height: 18px; color: var(--muted); pointer-events: none; z-index: 1; }
.cmd-input { width: 100%; height: 46px; border-radius: 15px; border: 1px solid rgba(255, 255, 255, .9); background: var(--surface); padding: 0 44px 0 76px; font-size: 13.5px; box-shadow: var(--press); outline: none; transition: box-shadow .2s; }
.cmd-input::placeholder { color: var(--muted-2); }
.cmd-input:focus { box-shadow: var(--press), var(--focus); }
.cmd-input::-webkit-search-cancel-button { display: none; }
.cmd-kbd { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); font: 600 10.5px/1 'IBM Plex Sans Arabic', sans-serif; color: var(--muted); background: #e4eafa; border-radius: 7px; padding: 5px 7px; direction: ltr; pointer-events: none; }
.cmd-list { position: absolute; top: calc(100% + 8px); right: 0; left: 0; max-height: min(420px, 70vh); overflow-y: auto; background: #f6f8fe; border: 1px solid #fff; border-radius: 18px; box-shadow: 0 24px 60px rgba(40, 60, 140, .2); padding: 6px; z-index: 70; animation: pop .16s var(--ease); }
.cmd-item { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 12px; color: var(--ink); cursor: pointer; }
.cmd-item:hover { color: var(--ink); }
.cmd-item-ic { width: 32px; height: 32px; border-radius: 10px; display: grid; place-items: center; background: #e8edf9; color: var(--muted); flex: 0 0 32px; }
.cmd-item-ic svg { width: 16px; height: 16px; }
.cmd-item b { font-weight: 500; font-size: 13.5px; flex: 1; min-width: 0; }
.cmd-item b mark { background: transparent; color: var(--primary); font-weight: 700; }
.cmd-item small { font-size: 11px; color: var(--muted); white-space: nowrap; }
.cmd-item.is-sel { background: var(--primary-soft); }
.cmd-item.is-sel .cmd-item-ic { background: var(--blue-grad); color: #fff; }
.cmd-empty { padding: 14px; text-align: center; color: var(--muted); font-size: 13px; }

/* ---------- raised surfaces & controls ---------- */
.card, .kpi { background: var(--surface); border: 1px solid rgba(255, 255, 255, .9); box-shadow: var(--raise); }
.card { border-radius: 22px; }
.card-head { border-bottom-color: var(--line); }
.card-foot { background: #eef2fc; border-top-color: var(--line); border-radius: 0 0 22px 22px; }
.card-icon { background: #eef2fc; border: 0; box-shadow: var(--raise-sm); color: var(--primary); }
.kpi { border-radius: 22px; transition: transform .25s var(--ease); }
.kpi:hover { transform: translateY(-3px); }
.kpi::after { background: rgba(47, 91, 255, .06); }
.btn { border-radius: 13px; transition: transform .18s var(--ease), box-shadow .18s var(--ease), background .18s, color .18s; }
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--blue-grad); box-shadow: 0 10px 22px rgba(47, 91, 255, .32), inset 0 1px 0 rgba(255, 255, 255, .35); }
.btn-primary:hover { background: linear-gradient(135deg, #3f69ff, #1f40d6); box-shadow: 0 14px 28px rgba(47, 91, 255, .38), inset 0 1px 0 rgba(255, 255, 255, .35); }
.btn-ghost { background: var(--surface); border-color: rgba(255, 255, 255, .9); box-shadow: var(--raise-sm); }
.btn-ghost:hover { background: var(--surface-2); border-color: #fff; }
.btn-soft { background: var(--primary-soft); border-color: var(--primary-line); }
.input, .select, .textarea, select.input, input.input { background: #f6f8fe; }
.table thead th { background: #eef2fc; }

/* ---------- dashboard ---------- */
.dash-hero { display: flex; align-items: flex-end; gap: 14px; flex-wrap: wrap; margin: 4px 0 22px; }
.dash-hero h1 { font-size: 26px; font-weight: 700; letter-spacing: -.3px; }
.dash-hero p { color: var(--muted); font-size: 13.5px; margin-top: 4px; }
.dash-hero .grow { flex: 1; }
.dash-kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 18px; margin-bottom: 18px; }
.dkpi { position: relative; overflow: hidden; padding: 20px; border-radius: 22px; background: var(--surface); border: 1px solid rgba(255, 255, 255, .9); box-shadow: var(--raise); color: var(--ink); transition: transform .25s var(--ease); }
a.dkpi:hover { transform: translateY(-3px); color: var(--ink); }
.dkpi-ic { width: 48px; height: 48px; border-radius: 15px; display: grid; place-items: center; color: #fff; box-shadow: 0 10px 20px rgba(20, 30, 70, .16), inset 0 1px 0 rgba(255, 255, 255, .4); }
.dkpi-ic svg { width: 22px; height: 22px; }
.dkpi-ic.blue { background: linear-gradient(135deg, #4a74ff, #2447e6); }
.dkpi-ic.red { background: linear-gradient(135deg, #ff8a6b, #e8503a); }
.dkpi-ic.green { background: linear-gradient(135deg, #34c38f, #12985f); }
.dkpi-ic.amber { background: linear-gradient(135deg, #ffc046, #f39a00); }
.dkpi small { display: block; color: var(--muted); font-size: 12.5px; margin-top: 14px; }
.dkpi b { display: block; font-size: 23px; font-weight: 700; margin-top: 2px; letter-spacing: -.3px; }
.dkpi .dkpi-foot { font-size: 11.5px; color: var(--muted-2); margin-top: 2px; }
.dkpi .shape { position: absolute; left: -34px; bottom: -44px; width: 124px; height: 124px; border-radius: 50%; opacity: .1; }
.dash-grid { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 18px; margin-bottom: 18px; }
.dash-card { padding: 20px; }
.dash-card h3 { display: flex; align-items: center; gap: 9px; font-size: 15px; font-weight: 600; }
.dash-card h3 svg { color: var(--primary); }
.dash-card h3 small { margin-right: auto; color: var(--muted); font-size: 12px; font-weight: 400; }
.dchart { display: flex; align-items: flex-end; gap: 14px; height: 210px; margin-top: 18px; padding: 0 4px; }
.dchart-col { flex: 1; height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 8px; min-width: 0; }
.dchart-bar { position: relative; width: 100%; max-width: 36px; min-height: 4px; border-radius: 11px 11px 6px 6px; background: linear-gradient(180deg, #c3cde6, #aab6d6); box-shadow: 0 8px 16px rgba(40, 60, 140, .12), inset 0 1px 0 rgba(255, 255, 255, .5); transform-origin: bottom; animation: barGrow .8s var(--ease) both; }
.dchart-bar.is-cur { background: var(--blue-grad); box-shadow: 0 10px 20px rgba(47, 91, 255, .3), inset 0 1px 0 rgba(255, 255, 255, .45); }
.dchart-bar:hover::after { content: attr(data-v); position: absolute; bottom: calc(100% + 6px); left: 50%; transform: translateX(-50%); padding: 3px 8px; border-radius: 7px; background: var(--ink); color: #fff; font-size: 11px; white-space: nowrap; direction: ltr; z-index: 2; }
.dchart-col span { font-size: 11px; color: var(--muted); white-space: nowrap; }
@keyframes barGrow { from { transform: scaleY(0); } }
.dquick { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 16px; }
.dq { display: flex; flex-direction: column; align-items: flex-start; gap: 9px; padding: 14px; border-radius: 18px; background: var(--surface); box-shadow: var(--raise-sm); color: var(--ink); transition: transform .2s var(--ease), box-shadow .2s var(--ease); }
.dq:hover { transform: translateY(-3px); color: var(--ink); box-shadow: 8px 8px 18px rgba(118, 138, 196, .26), -6px -6px 16px rgba(255, 255, 255, .95); }
.dq-ic { width: 40px; height: 40px; border-radius: 13px; display: grid; place-items: center; background: var(--primary-soft); color: var(--primary); transition: background .2s, color .2s; }
.dq:hover .dq-ic { background: var(--blue-grad); color: #fff; }
.dq-ic svg { width: 19px; height: 19px; }
.dq b { font-size: 13.5px; font-weight: 600; }
.dq small { font-size: 11.5px; color: var(--muted); margin-top: -6px; }
.drows { margin-top: 10px; }
.drow { display: flex; align-items: center; gap: 12px; padding: 11px 4px; border-bottom: 1px solid var(--line); color: var(--ink); border-radius: 12px; transition: background .18s; }
.drow:last-child { border-bottom: 0; }
a.drow:hover { background: #eef2fc; color: var(--ink); }
.drow-ic { width: 38px; height: 38px; flex: 0 0 38px; border-radius: 12px; display: grid; place-items: center; background: var(--primary-soft); color: var(--primary); font-weight: 600; font-size: 13px; }
.drow-ic svg { width: 17px; height: 17px; }
.drow-ic.red { background: var(--danger-soft); color: var(--danger); }
.drow-ic.amber { background: var(--warning-soft); color: var(--warning); }
.drow-t { flex: 1; min-width: 0; }
.drow-t b { display: block; font-size: 13.5px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.drow-t small { display: block; font-size: 11.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.drow-amt { font-weight: 600; font-size: 13.5px; white-space: nowrap; }
.dash-empty { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 28px 10px; color: var(--muted); font-size: 13px; text-align: center; }
.dash-empty svg { width: 28px; height: 28px; color: var(--muted-2); }
.dcc { margin-top: 14px; display: flex; flex-direction: column; gap: 12px; }
.dcc-head { display: flex; justify-content: space-between; gap: 10px; font-size: 13px; margin-bottom: 6px; }
.dcc-track { height: 9px; border-radius: 9px; background: #e4eafa; box-shadow: var(--press); overflow: hidden; }
.dcc-fill { height: 100%; border-radius: 9px; background: var(--blue-grad); animation: fillIn .8s var(--ease) both; transform-origin: right; }
@keyframes fillIn { from { transform: scaleX(0); } }

@media (max-width: 1280px) {
  .dash-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dash-grid { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 980px) {
  .shell.nav-folded { --side-w: 268px; }
  .sidebar { top: 12px; bottom: 12px; right: 12px; transform: translateX(calc(100% + 24px)); }
  .shell.nav-open .sidebar { transform: none; }
  .shell.nav-open .overlay { background: rgba(20, 30, 60, .28); backdrop-filter: blur(3px); }
  .side-fold { display: none; }
  .main { margin-right: 0; }
  .topbar { height: auto; flex-wrap: wrap; padding: 12px 16px 6px; gap: 10px; }
  .topbar .menu-toggle { display: inline-flex; width: 46px; height: 46px; border-radius: 14px; background: var(--surface); box-shadow: var(--raise-sm); border-color: #fff; }
  .cmd { order: 5; flex: 1 1 100%; }
  .cmd-kbd { display: none; }
  .cmd-input { padding-left: 14px; }
  .company-chip { height: 46px; }
  .topbar-date { display: none; }
  .dash-hero h1 { font-size: 21px; }
  .dchart { gap: 6px; height: 170px; }
}
@media (max-width: 640px) {
  .dash-kpis { gap: 12px; }
  .dkpi { padding: 16px; }
  .dkpi b { font-size: 18px; }
  .dkpi-ic { width: 42px; height: 42px; }
  .dquick { gap: 10px; }
  .dash-hero .btn { flex: 1; }
}
@media print {
  body::before, body::after { display: none; }
  .main { margin-right: 0; }
}

/* بطاقات الدفع: القلب إلى الخلف (شريط ذهبي)، وشعارات الشبكات */
.pc-flip { perspective: 1400px; cursor: pointer; border-radius: 16px; outline-offset: 4px; -webkit-tap-highlight-color: transparent; }
.pc-inner { position: relative; aspect-ratio: 1.586; transform-style: preserve-3d; transition: transform .75s cubic-bezier(.3, .7, .2, 1); }
.pc-flip.is-flipped .pc-inner { transform: rotateY(180deg); }
.pc-flip:hover .pc-inner { box-shadow: none; }
.pc-inner > .pc-face, .pc-inner > .pc-back { position: absolute; inset: 0; aspect-ratio: auto; -webkit-backface-visibility: hidden; backface-visibility: hidden; }
.pc-back { transform: rotateY(180deg); border-radius: 16px; overflow: hidden; color: #fff; direction: ltr; display: flex; flex-direction: column; box-shadow: 0 12px 28px rgba(20, 28, 50, .22); }
.pc-back::after { content: ""; position: absolute; width: 240px; height: 240px; border-radius: 50%; left: -100px; bottom: -130px; background: rgba(255, 255, 255, .07); }
.pc-stripe { position: relative; overflow: hidden; margin-top: 8%; height: 19%; flex: none; background: linear-gradient(180deg, #7d5a1c 0%, #c9a046 18%, #f4d98a 40%, #fff3c4 50%, #e2bb5c 64%, #a57b2a 86%, #6f4f17 100%); box-shadow: inset 0 1px 0 rgba(255, 255, 255, .35), inset 0 -1px 0 rgba(0, 0, 0, .25), 0 2px 6px rgba(0, 0, 0, .25); }
.pc-stripe::after { content: ""; position: absolute; top: 0; bottom: 0; width: 35%; left: -40%; background: linear-gradient(100deg, transparent, rgba(255, 255, 255, .55), transparent); transform: skewX(-20deg); }
.pc-flip.is-flipped .pc-stripe::after { animation: pc-shine 1.1s ease-out .45s 1 both; }
@keyframes pc-shine { to { left: 120%; } }
.pc-sign { position: relative; z-index: 1; display: flex; align-items: center; gap: 10px; margin: 6% 20px 0; }
.pc-sign-strip { flex: 1; min-width: 0; height: 32px; border-radius: 4px; display: flex; align-items: center; padding: 0 10px; overflow: hidden; color: #3a3a3a; font: italic 600 13px "Segoe Script", "Brush Script MT", cursive; white-space: nowrap; background: repeating-linear-gradient(-45deg, #f7f5ef 0 6px, #ebe6d8 6px 12px); }
.pc-cvv-tag { flex: none; min-width: 54px; background: #fff; color: #15171c; border-radius: 4px; padding: 2px 8px; text-align: center; line-height: 1.2; }
.pc-cvv-tag small { display: block; font-size: 8.5px; opacity: .6; }
.pc-cvv-tag b { font: 600 14px ui-monospace, Menlo, Consolas, monospace; letter-spacing: .08em; }
.pc-fine { position: relative; z-index: 1; margin: 5% 20px 0; font-size: 9.5px; line-height: 1.55; opacity: .72; direction: rtl; text-align: right; }
.pc-back-foot { position: relative; z-index: 1; margin-top: auto; padding: 0 20px 14px; display: flex; align-items: center; gap: 8px; }
.pc-back-label { direction: rtl; font-size: 12px; font-weight: 600; opacity: .85; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.pc-marks { margin-inline-start: auto; display: flex; align-items: center; gap: 9px; flex: none; }
.pcm { display: inline-flex; align-items: center; }
.pcm svg { display: block; width: auto; }
.pcm-mada { background: rgba(255, 255, 255, .94); color: #1d2a3a; border-radius: 6px; padding: 3px 6px; }
.pcm-mada svg { height: 20px; }
.pcm-visa { color: #fff; }
.pcm-visa svg { height: 20px; filter: drop-shadow(0 1px 1px rgba(0, 0, 0, .25)); }
.pcm-mc svg { height: 26px; }
.pcm-amex { font: 800 12px Arial, sans-serif; border: 1.5px solid currentColor; padding: 2px 5px; border-radius: 4px; }
@media (max-width: 640px) { .pc-sign, .pc-fine { margin-inline: 16px; } .pc-back-foot { padding: 0 16px 12px; } .pcm-mada svg { height: 17px; } .pcm-mc svg { height: 22px; } .pcm-visa svg { height: 17px; } }
@media (prefers-reduced-motion: reduce) { .pc-inner { transition: none; } .pc-flip.is-flipped .pc-stripe::after { animation: none; } }
.pc-mid { display: flex; align-items: center; margin-top: 14px; position: relative; z-index: 1; }
.pc-mid .pc-chip { margin-top: 0; }
.pc-mid .pc-marks { gap: 8px; }

/* =====================================================================
   التقارير: ترويسة موحدة (شعار عريض + بيانات الشركة + شريط ملوّن)
   وتنسيق طباعة احترافي لكل التقارير — بخط النظام نفسه.
   ===================================================================== */
.rpt-head { display: none; font-family: inherit; color: #182033; margin-bottom: 14px; }
.rpt-head.rpt-screen { display: block; }
.rpt-brand { display: flex; align-items: center; justify-content: space-between; gap: 18px; padding-bottom: 12px; border-bottom: 3px solid #5267db; position: relative; }
.rpt-brand::after { content: ""; position: absolute; inset-inline-end: 0; bottom: -3px; width: 28%; height: 3px; background: #149b98; }
.rpt-logo img { display: block; height: 66px; max-width: 250px; object-fit: contain; object-position: right center; }
.rpt-co { text-align: left; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.rpt-co b { font-size: 17px; font-weight: 700; color: #1b2440; }
.rpt-co .ltr { direction: ltr; font-size: 11.5px; color: #5267db; font-weight: 600; letter-spacing: .3px; }
.rpt-co small { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 2px 12px; font-size: 11px; color: #5b6478; }
.rpt-co small i { font-style: normal; }
.rpt-band { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-top: 12px; padding: 11px 16px; border-radius: 10px; color: #fff;
  background: linear-gradient(135deg, #5267db 0%, #4256c5 62%, #3a4fb8 100%); }
.rpt-title { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; min-width: 0; }
.rpt-title h1 { font-size: 19px; font-weight: 700; color: #fff; margin: 0; line-height: 1.4; }
.rpt-no { font-size: 12.5px; background: rgba(255,255,255,.18); border: 1px solid rgba(255,255,255,.35); border-radius: 999px; padding: 1px 10px; }
.rpt-printed { font-size: 10.5px; line-height: 1.6; color: rgba(255,255,255,.85); text-align: left; white-space: nowrap; }
.rpt-meta { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 0; margin: 10px 0 0; border: 1px solid #dfe4ff; border-radius: 10px; overflow: hidden; background: #f7f8ff; }
.rpt-meta div { padding: 6px 12px; border-inline-start: 1px solid #dfe4ff; min-width: 0; }
.rpt-meta div:first-child { border-inline-start: 0; }
.rpt-meta dt { font-size: 10px; color: #7b8498; margin: 0; }
.rpt-meta dd { font-size: 12.5px; font-weight: 600; color: #1b2440; margin: 1px 0 0; }
.rpt-meta bdi, .rpt-printed bdi, .rpt-no bdi { white-space: nowrap; }

/* ملخص الأرصدة أعلى الكشف (شاشة + طباعة) */
.rpt-sum { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.rpt-sum > div { border: 1px solid var(--line); border-radius: 12px; padding: 9px 13px; background: var(--surface-2); border-top: 3px solid var(--slate); min-width: 0; }
.rpt-sum > div > span { display: block; font-size: 11.5px; color: var(--muted); }
.rpt-sum b { display: block; font-size: 16px; font-weight: 700; margin-top: 2px; }
.rpt-sum small { font-size: 11px; color: var(--muted); font-weight: 500; }
.rpt-sum .s-dr { border-top-color: var(--info); }   .rpt-sum .s-dr b { color: var(--info); }
.rpt-sum .s-cr { border-top-color: var(--accent); } .rpt-sum .s-cr b { color: var(--accent); }
.rpt-sum .s-bal { border-top-color: var(--primary); background: var(--primary-soft); } .rpt-sum .s-bal b { color: var(--primary-2); }
@media (max-width: 760px) { .rpt-sum { grid-template-columns: repeat(2, minmax(0, 1fr)); padding: 12px; } }
.dc-tag { display: inline-block; font-size: 10px; font-weight: 600; padding: 0 6px; border-radius: 6px; margin-inline-start: 4px; vertical-align: 1px; }
.dc-tag.dr { color: #3f7fd1; background: #eef5ff; }
.dc-tag.cr { color: #149b98; background: #eaf8f7; }

/* صفحات الطباعة المستقلة (كشف الموظف، الأرصدة…) بنفس الهوية */
.print-table thead th { background: #5267db; color: #fff; border-color: #4a5fd0; font-weight: 600; }
.print-table tbody tr:nth-child(even) td { background: #f7f8fe; }
.print-table tfoot td { background: #eef1ff; color: #1b2440; border-top: 2px solid #5267db; }
.print-bal { border-color: #5267db; background: #f4f6ff; }
.print-bal b { color: #4256c5; }

@page { size: A4; margin: 13mm 11mm 15mm;
  @bottom-center { content: "صفحة " counter(page) " من " counter(pages); font-family: "IBM Plex Sans Arabic", Tahoma, sans-serif; font-size: 9pt; color: #7b8498; } }

@media print {
  * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .rpt-head { display: block; break-inside: avoid; }
  body:has(.rpt-head) .page-head, body:has(.rpt-head) .breadcrumb { display: none !important; }
  .content > .card, .content .grid > .card { padding: 0; }
  .grid-main { display: block !important; }
  .grid-main > .card + .card { margin-top: 16px; }
  .rpt-sum { padding: 0 0 12px; border: 0; gap: 8px; break-inside: avoid; }
  .rpt-sum > div { padding: 7px 10px; border-radius: 9px; }
  .rpt-sum b { font-size: 13.5px; }

  /* الجداول */
  .table { width: 100% !important; min-width: 0 !important; border-collapse: separate; border-spacing: 0; border: 1px solid #d9def0; border-radius: 9px; overflow: hidden; }
  .table thead { display: table-header-group; }
  .table tfoot { display: table-row-group; }
  .table tr { break-inside: avoid; }
  .table th { background: #5267db !important; color: #fff !important; font-weight: 600; font-size: 10.5px; padding: 7px 7px; border: 0; border-inline-start: 1px solid rgba(255,255,255,.18); white-space: nowrap; }
  .table thead tr + tr th { background: #6f81e2 !important; }
  .table td { padding: 5.5px 7px; font-size: 10.5px; border: 0; border-top: 1px solid #e6e9f3; border-inline-start: 1px solid #eef0f6; color: #182033; }
  .table th:first-child, .table td:first-child { border-inline-start: 0; }
  .table tbody tr:nth-child(even) td { background: #f8f9fe; }
  .table .row-total td { background: #eef1ff !important; color: #1b2440; font-weight: 700; }
  .table tfoot td { background: #1b2440 !important; color: #fff !important; font-weight: 700; font-size: 11px; border-top: 0; padding: 7px; }
  .table .col-num, .table td.col-num .num { white-space: nowrap; }
  .table .tree-code { color: #5267db; }
  .table .doc-no { color: #4256c5 !important; font-weight: 600; }
  .table .muted, .table .small { color: #4b5468; }
  .table .neg { color: #c23b4f !important; }
  .table-print-fit td, .table-print-fit th { padding: 5px 5px; font-size: 10px; }
  .table th.tb-acc { width: 33%; }
  .grid-main > .card:has(> .empty), .grid-main > .card:has(> .card-body > .empty) { display: none !important; }
  .bar-track { background: #eef1ff !important; }
  .bar-fill { background: #5267db !important; }
  .table td:has(> .bar-track), .table th:last-child:empty { width: 14% !important; }
  .print-page .rpt-head { margin-bottom: 16px; }
  .print-page > .print-head, .print-page > .print-title { break-inside: avoid; }
}
@media print {
  html, body, .shell, .main, .content { background: #fff !important; background-image: none !important; }
  .card, .table-wrap, .table, .rpt-sum > div { box-shadow: none !important; }
  .rpt-sum { grid-template-columns: repeat(4, minmax(0, 1fr)) !important; }
}
