/* منظومة روافد العطاء — الهوية: أخضر وذهبي من شعار روافد */
:root {
  --ink: #1F2A1B; --ink-2: #3E4A38; --muted: #6B7564; --faint: #A3AB9A;
  --brand: #3F6430; --brand-deep: #2F4E24; --action: #557A2E; --brand-soft: #F1F5E9; --brand-line: #D6E1C4;
  --bg: #F7F5EE; --surface: #FFFFFF; --surface-2: #FBFAF5; --line: #E6E3D8; --line-strong: #D2CEBF;
  --ok: #0E8A5F; --ok-soft: #E4F5EE; --warn: #B45309; --warn-soft: #FDF1E2; --danger: #C62828; --danger-soft: #FDECEC;
  --violet: #8A6526; --violet-soft: #FAF3E3;
  --radius: 10px; --radius-lg: 14px;
  --shadow-sm: 0 1px 2px rgba(35,45,25,.06);
  --shadow-pop: 0 16px 48px rgba(35,45,25,.18);
  --font: 'IBM Plex Sans Arabic', Tahoma, sans-serif;
  --font-head: 'Noto Kufi Arabic', 'IBM Plex Sans Arabic', Tahoma, sans-serif;
  font-family: var(--font);
  /* أسماء قديمة ما زالت مستخدمة في بعض القوالب */
  --primary: var(--brand); --primary-soft: var(--brand-soft); --text: var(--ink); --border: var(--line); --border-strong: var(--line-strong);
  --accent: var(--warn); --accent-soft: var(--warn-soft); --info: var(--action); --info-soft: var(--brand-soft);
}
* { box-sizing: border-box; }
html { overflow-x: clip; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font-size: 14px; line-height: 1.55; }
a { color: var(--action); text-decoration: none; }
a:hover { color: var(--brand-deep); }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--action); outline-offset: 2px; }
h1, h2, h3, h4 { font-family: var(--font-head); color: var(--ink); letter-spacing: 0; }
.num, .money { font-variant-numeric: tabular-nums; direction: ltr; unicode-bidi: plaintext; white-space: nowrap; }
.pos { color: var(--ok); } .neg { color: var(--danger); } .muted { color: var(--muted); }

/* ═════════ الإطار ═════════ */
.layout { display: grid; grid-template-columns: 248px 1fr; min-height: 100vh; }
.sidebar { background: var(--surface); border-inline-start: 1px solid var(--line); padding: 16px 12px 24px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.brand { display: flex; gap: 11px; align-items: center; padding: 4px 8px 16px; margin-bottom: 6px; border-bottom: 1px solid var(--line); color: var(--ink); }
.brand b { display: block; white-space: nowrap; font-family: var(--font-head); font-size: 14px; font-weight: 700; line-height: 1.35; color: var(--ink); }
.brand small { font-size: 11.5px; color: var(--muted); }
.nav-group { font-size: 12px; color: var(--faint); padding: 16px 12px 6px; font-weight: 500; }
.nav a { position: relative; display: flex; align-items: center; gap: 11px; color: var(--ink-2); padding: 8px 12px; border-radius: 8px; margin: 1px 0; font-weight: 500; }
.nav a svg { width: 18px; height: 18px; flex: none; color: var(--faint); }
.nav a:hover { background: var(--surface-2); color: var(--ink); }
.nav a:hover svg { color: var(--ink-2); }
.nav a.active { background: var(--brand-soft); color: var(--brand); }
.nav a.active svg { color: var(--brand); }
.nav a.active::before { content: ''; position: absolute; inset-inline-start: -12px; top: 8px; bottom: 8px; width: 3px; border-radius: 3px; background: var(--brand); }
.nav-count[hidden] { display: none; }
.nav-count { margin-inline-start: auto; background: var(--danger); color: #fff; font-size: 11px; font-weight: 700; min-width: 20px; height: 20px; border-radius: 10px; display: grid; place-items: center; padding: 0 6px; }
.main { min-width: 0; }
.topbar { display: flex; align-items: center; gap: 16px; padding: 10px 28px; background: rgba(255,255,255,.92); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
.who { display: flex; align-items: center; gap: 10px; margin-inline-start: auto; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--brand); color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 13px; flex: none; }
.who-text { display: flex; flex-direction: column; line-height: 1.25; }
.who-text b { font-size: 13px; } .who-text small { font-size: 11.5px; color: var(--muted); }
.menu-btn { display: none; }
.content { padding: 26px 28px 64px; max-width: 1420px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.page-head h1 { font-size: 21px; margin: 0; font-weight: 700; line-height: 1.4; }
.page-head .sub { color: var(--muted); font-size: 13px; margin-top: 3px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ═════════ الأزرار ═════════ */
.btn { display: inline-flex; align-items: center; gap: 7px; border: 1px solid var(--line-strong); background: var(--surface); padding: 7px 14px; border-radius: 8px; cursor: pointer; white-space: nowrap; font-weight: 500; color: var(--ink-2); }
.btn:hover { background: var(--surface-2); border-color: var(--faint); color: var(--ink); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-deep); border-color: var(--brand-deep); }
.btn.accent { background: var(--action); border-color: var(--action); color: #fff; }
.btn.accent:hover { background: var(--brand); }
.btn.danger { color: var(--danger); border-color: #EFC2C2; }
.btn.danger:hover { background: var(--danger-soft); }
.btn.sm { padding: 4px 10px; font-size: 13px; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.icon-btn { border: none; background: none; cursor: pointer; padding: 5px 6px; border-radius: 6px; color: var(--faint); display: inline-grid; place-items: center; }
.icon-btn:hover { background: var(--surface-2); color: var(--ink); }
.icon-btn.del:hover { color: var(--danger); background: var(--danger-soft); }

/* ═════════ البطاقات ═════════ */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); }
.card-head { display: flex; align-items: center; justify-content: space-between; padding: 13px 18px; border-bottom: 1px solid var(--line); gap: 8px; }
.card-head h3 { margin: 0; font-size: 14.5px; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.card-body { padding: 18px; }
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, minmax(0,1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0,1fr)); }

/* مؤشرات: أيقونة ملوّنة + قيمة */
.kpis { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; margin-bottom: 18px; }
.kpi { padding: 16px 18px; display: grid; grid-template-columns: 1fr auto; grid-template-areas: "label ic" "value ic" "hint hint"; column-gap: 12px; }
.kpi .label { grid-area: label; color: var(--muted); font-size: 13px; }
.kpi .value { grid-area: value; white-space: nowrap; font-size: 22px; font-weight: 700; margin-top: 2px; color: var(--ink); }
.kpi .value small { font-size: 12px; font-weight: 500; }
.kpi .hint { grid-area: hint; font-size: 12.5px; color: var(--muted); margin-top: 8px; padding-top: 8px; border-top: 1px dashed var(--line); }
.kpi .ic { grid-area: ic; width: 40px; height: 40px; border-radius: 10px; display: grid; place-items: center; background: var(--brand-soft); color: var(--brand); }
.kpi.ok .ic { background: var(--ok-soft); color: var(--ok); } .kpi.warn .ic { background: var(--warn-soft); color: var(--warn); }
.kpi.danger .ic { background: var(--danger-soft); color: var(--danger); } .kpi.violet .ic { background: var(--violet-soft); color: var(--violet); }

/* ═════════ الجداول ═════════ */
table.t { width: 100%; border-collapse: collapse; }
.t th { text-align: right; font-weight: 600; font-size: 12.5px; color: var(--muted); background: var(--surface-2); padding: 10px 14px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.t td { padding: 10px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.t tbody tr:last-child td { border-bottom: none; }
.t tbody tr:hover { background: #FBFBF6; }
.t tr.click { cursor: pointer; }
.t tfoot td { font-weight: 700; background: var(--surface-2); border-top: 1px solid var(--line); }
.t .end { text-align: left; }
.table-wrap { overflow-x: auto; }
.empty { padding: 44px 20px; text-align: center; color: var(--muted); }

.badge { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 6px; font-size: 12px; font-weight: 600; background: #F0EEE6; color: var(--ink-2); white-space: nowrap; }
.badge.ok { background: var(--ok-soft); color: var(--ok); } .badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.danger { background: var(--danger-soft); color: var(--danger); } .badge.info, .badge.primary { background: var(--brand-soft); color: var(--brand); }
.badge.accent { background: var(--violet-soft); color: var(--violet); }

.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 16px; flex-wrap: wrap; }
.tabs a, .tabs button { padding: 9px 14px; color: var(--muted); border: none; background: none; cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; font-weight: 500; }
.tabs a:hover { color: var(--ink); }
.tabs .on { color: var(--brand); border-bottom-color: var(--brand); font-weight: 600; }
.toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.search { min-width: 260px; }

/* ═════════ النماذج ═════════ */
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 14px 16px; }
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field.wide { grid-column: 1 / -1; }
.field label { font-size: 12.5px; color: var(--ink-2); font-weight: 500; }
.field label .req { color: var(--danger); }
input, select, textarea { border: 1px solid var(--line-strong); background: #fff; border-radius: 8px; padding: 8px 11px; min-width: 0; width: 100%; transition: border-color .12s, box-shadow .12s; }
input:hover, select:hover, textarea:hover { border-color: var(--faint); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--action); box-shadow: 0 0 0 3px rgba(85,122,46,.14); }
input[readonly], select:disabled { background: var(--surface-2); color: var(--muted); }
textarea { min-height: 70px; resize: vertical; }
input[type=number] { direction: ltr; text-align: right; }
.items-table input, .items-table select { padding: 6px 9px; }
.items-table td { padding: 6px; }
.items-table .w-qty { width: 110px; } .items-table .w-price { width: 120px; } .items-table .w-unit { width: 90px; }
.items-table .w-code { width: 80px; } .items-table .w-name { min-width: 220px; } .items-table .w-total { width: 140px; }
.totals { display: grid; grid-template-columns: auto auto; gap: 7px 28px; justify-content: end; align-items: center; padding: 16px 18px; }
.totals .lbl { color: var(--muted); }
.totals .grand { font-size: 19px; font-weight: 700; color: var(--brand); }
.words { padding: 11px 16px; background: var(--brand-soft); border: 1px solid var(--brand-line); border-radius: 8px; color: var(--brand-deep); margin: 0 18px 16px; }
.doc-side { display: flex; flex-direction: column; gap: 16px; }
.doc-layout { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 16px; align-items: start; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 7px 12px; margin: 0; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; text-align: left; }

/* ═════════ النوافذ ═════════ */
.modal-bg { position: fixed; inset: 0; background: rgba(35,45,25,.42); display: flex; align-items: flex-start; justify-content: center; padding: 6vh 16px; z-index: 50; overflow-y: auto; animation: fade .15s; }
.modal { background: var(--surface); border-radius: var(--radius-lg); width: 100%; max-width: 720px; box-shadow: var(--shadow-pop); animation: pop .18s ease-out; }
.modal.sm { max-width: 460px; } .modal.xl { max-width: 1000px; }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 15px 20px; border-bottom: 1px solid var(--line); }
.modal-head h3 { margin: 0; font-size: 16px; }
.modal-body { padding: 20px; }
.modal-foot { display: flex; gap: 8px; padding: 13px 20px; border-top: 1px solid var(--line); background: var(--surface-2); border-radius: 0 0 var(--radius-lg) var(--radius-lg); }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.98); } }
#toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); z-index: 100; display: flex; flex-direction: column; gap: 8px; }
.toast { background: var(--ink); color: #fff; padding: 10px 18px; border-radius: 9px; box-shadow: var(--shadow-pop); animation: pop .2s; }
.toast.err { background: var(--danger); }

/* ═════════ الشعار ═════════ */
.logo-mark { flex: none; display: block; }
.paper .band .co { display: flex; align-items: center; gap: 10px; }

/* ═════════ تسجيل الدخول: لوحة كحلية + نموذج ═════════ */
.login { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(380px, 1fr); background: var(--surface); }
.login-art { position: relative; overflow: hidden; background: linear-gradient(90deg, #2F4E24 0%, #648938 53%, #335326 100%); color: #fff; padding: 48px; display: flex; flex-direction: column; justify-content: space-between; gap: 32px; }
.login-art h2 { position: relative; color: #fff; font-size: 30px; line-height: 1.65; margin: 0; max-width: 460px; font-weight: 700; }
.login-art p { position: relative; color: #F3F1E4; max-width: 420px; margin: 12px 0 0; }
.login-form { display: grid; place-items: center; padding: 32px 24px; }
.login-form form { width: 100%; max-width: 360px; }
.login-form h1 { font-size: 22px; margin: 0 0 6px; }
.login-form p { color: var(--muted); margin: 0 0 24px; }
.login-form .field { margin-bottom: 14px; }
.login-form .btn { width: 100%; justify-content: center; padding: 11px; margin-top: 6px; }
.login-form .hint { font-size: 12.5px; color: var(--muted); margin-top: 18px; text-align: center; }

/* ═════════ شاشة الافتتاح ═════════ */
#splash { position: fixed; inset: 0; z-index: 1000; display: grid; place-items: center; overflow: hidden; cursor: pointer;
  background: linear-gradient(90deg, #2F4E24 0%, #648938 53%, #335326 100%); transition: opacity .5s ease; }
#splash.out { opacity: 0; pointer-events: none; }
.sp-inner { position: relative; display: flex; flex-direction: column; align-items: center; text-align: center; color: #fff; padding: 16px; }
.sp-bar { width: 180px; height: 3px; border-radius: 3px; background: rgba(255,255,255,.15); margin-top: 30px; overflow: hidden; animation: sp-up .4s ease-out 1.5s both; }
.sp-bar i { display: block; height: 100%; background: #D8B266; transform-origin: right; animation: sp-load 1s ease-in-out 1.6s both; }
.sp-skip { position: absolute; bottom: 24px; color: rgba(255,255,255,.4); font-size: 12px; }
@keyframes sp-in { from { opacity: 0; transform: scale(.7); } }
@keyframes sp-wipe { to { clip-path: inset(0 0 0 0); } }
@keyframes sp-draw { to { stroke-dashoffset: 0; } }
@keyframes sp-up { from { opacity: 0; transform: translateY(10px); } }
@keyframes sp-load { from { transform: scaleX(0); } }
@media (prefers-reduced-motion: reduce) { #splash *, #splash, .modal, .modal-bg { animation-duration: .01s !important; animation-delay: 0s !important; } }

/* ═════════ تغيير كلمة المرور الإجباري ═════════ */
.force-pw { min-height: 100vh; display: grid; place-items: center; padding: 16px; background: var(--bg); }
.force-pw .card { width: 100%; max-width: 420px; padding: 28px; }
.force-pw h1 { font-size: 19px; margin: 14px 0 6px; }
.force-pw p { color: var(--muted); margin: 0 0 20px; }
.force-pw .field { margin-bottom: 12px; }
.force-pw .btn { width: 100%; justify-content: center; padding: 10px; }

/* ═════════ رسم بياني ═════════ */
.bars { display: flex; align-items: flex-end; gap: 14px; height: 190px; padding: 10px 4px 0; }
.bars .col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; justify-content: flex-end; }
.bars .stack { display: flex; gap: 3px; align-items: flex-end; height: 100%; width: 100%; justify-content: center; border-bottom: 1px solid var(--line); }
.bars .bar { width: 30%; max-width: 16px; border-radius: 4px 4px 0 0; min-height: 2px; }
.bars .m { font-size: 12px; color: var(--muted); }
.legend { display: flex; gap: 14px; font-size: 12.5px; color: var(--muted); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-inline-end: 5px; vertical-align: -1px; }
.c-sales { background: var(--brand); } .c-purch { background: #D8B266; } .c-exp { background: #8A8F7E; }

.acct-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; margin-bottom: 18px; }
.acct { padding: 18px; cursor: pointer; transition: border-color .12s; }
.acct:hover { border-color: var(--action); }
.acct .value { font-size: 21px; font-weight: 700; margin: 6px 0 2px; }
.list-mini { margin: 0; padding: 0; list-style: none; }
.list-mini li { display: flex; justify-content: space-between; gap: 10px; padding: 10px 18px; border-bottom: 1px solid var(--line); align-items: center; }
.list-mini li:last-child { border-bottom: none; }

/* ═════════ البحث الشامل ═════════ */
.gsearch { position: relative; flex: 1; max-width: 480px; display: flex; align-items: center; gap: 8px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 9px; padding: 0 12px; color: var(--faint); }
.gsearch:focus-within { border-color: var(--action); background: #fff; box-shadow: 0 0 0 3px rgba(85,122,46,.12); }
.gsearch input, .gsearch input:focus { border: none; background: transparent; padding: 8px 0; box-shadow: none; }
.gres { display: none; position: absolute; top: calc(100% + 6px); inset-inline: 0; background: #fff; border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow-pop); max-height: 420px; overflow-y: auto; z-index: 30; }
.gres.on { display: block; }
.gres a { display: flex; gap: 8px; align-items: center; padding: 10px 12px; color: var(--ink); border-bottom: 1px solid var(--line); }
.gres a:hover { background: var(--brand-soft); }

/* ═════════ المرفقات ═════════ */
.dropzone { border: 1.5px dashed var(--line-strong); border-radius: 10px; padding: 18px; text-align: center; color: var(--muted); cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 4px; background: var(--surface-2); transition: .12s; }
.dropzone:hover, .dropzone.over { border-color: var(--action); background: var(--brand-soft); color: var(--brand); }
.dropzone.busy { opacity: .6; pointer-events: none; }
.dropzone.busy::after { content: 'جارٍ الرفع…'; font-weight: 600; color: var(--brand); }
.att-up { display: flex; flex-direction: column; gap: 8px; border-top: 1px solid var(--line); }
.att-list li { padding: 9px 14px; }
.att-open { display: flex; align-items: center; gap: 10px; background: none; border: none; cursor: pointer; text-align: right; padding: 0; min-width: 0; flex: 1; }
.att-open span { display: flex; flex-direction: column; min-width: 0; }
.att-open b { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 200px; font-weight: 500; }
.att-open:hover b { color: var(--action); }
.thumb { object-fit: cover; border-radius: 6px; border: 1px solid var(--line); display: block; flex: none; }
.fthumb { display: grid; place-items: center; border-radius: 6px; font-size: 10px; font-weight: 700; background: #F0EEE6; color: var(--muted); flex: none; }
.fthumb.pdf { background: var(--danger-soft); color: var(--danger); } .fthumb.xls { background: var(--ok-soft); color: var(--ok); } .fthumb.doc { background: var(--brand-soft); color: var(--brand); }

/* ═════════ المهام ═════════ */
.task-board { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; align-items: start; }
.task-col { background: #EFECE2; border-radius: var(--radius-lg); padding: 10px; min-height: 120px; }
.task-col > h4 { margin: 4px 6px 10px; font-size: 13.5px; display: flex; justify-content: space-between; color: var(--ink-2); }
.task { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; margin-bottom: 8px; cursor: pointer; border-inline-start: 3px solid var(--line-strong); }
.task:hover { border-color: var(--brand-line); }
.task.p-high { border-inline-start-color: var(--warn); } .task.p-urgent { border-inline-start-color: var(--danger); } .task.p-low { border-inline-start-color: var(--faint); } .task.p-normal { border-inline-start-color: var(--action); }
.task b { display: block; font-weight: 600; margin-bottom: 6px; }
.task .meta { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; font-size: 12px; color: var(--muted); }
.task .late { color: var(--danger); font-weight: 600; }
.task-col .empty { padding: 18px 8px; font-size: 13px; }
.thread { display: flex; flex-direction: column; gap: 10px; margin: 14px 0; }
.thread .msg { background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; padding: 9px 12px; }
.thread .msg small { color: var(--muted); display: block; margin-bottom: 2px; }

#curs input[data-k=name] { min-width: 120px; }

/* مصفوفة الصلاحيات */
.perm-table td, .perm-table th { padding: 7px 10px; }
.perm-table .seg { display: inline-flex; border: 1px solid var(--line-strong); border-radius: 8px; overflow: hidden; }
.perm-table .seg label { padding: 4px 11px; cursor: pointer; font-size: 12.5px; border-inline-start: 1px solid var(--line-strong); }
.perm-table .seg label:first-child { border-inline-start: none; }
.perm-table .seg input { display: none; }
.perm-table .seg label:has(input:checked) { background: var(--brand); color: #fff; }
.perm-table .seg label.none:has(input:checked) { background: #99A08E; }
.perm-table tr.changed td:first-child { color: var(--action); font-weight: 600; }

/* ═════════ الطباعة ═════════ */
.print-toolbar { display: flex; gap: 8px; margin-bottom: 14px; }
.paper { background: #fff; max-width: 820px; margin: 0 auto; padding: 30px 34px; border: 1px solid var(--line); border-radius: 4px; font-size: 13px; }
.paper .band { background: #F1F5E9; border-bottom: 3px solid var(--brand); display: flex; justify-content: space-between; align-items: center; padding: 12px 18px; }
.paper .band h2 { margin: 0; font-size: 25px; color: var(--brand-deep); }
.paper .band .co { font-size: 16px; font-weight: 700; text-align: left; font-family: var(--font-head); color: var(--ink); }
.paper .info { display: grid; grid-template-columns: 1fr 1fr; gap: 5px 30px; padding: 16px 4px; }
.paper .info div { display: flex; gap: 10px; } .paper .info b { min-width: 90px; color: var(--ink-2); }
.paper table { width: 100%; border-collapse: collapse; }
.paper th, .paper td { border: 1px solid #C5C6B6; padding: 6px 8px; }
.paper th { background: #F1F5E9; color: var(--ink); }
.paper .foot { margin-top: 18px; border-top: 2px solid var(--line); padding-top: 10px; display: flex; justify-content: space-between; color: var(--ink-2); }
.paper .sign { display: flex; justify-content: space-between; margin-top: 40px; color: var(--ink-2); }

@media print {
  .sidebar, .topbar, .no-print, .print-toolbar { display: none !important; }
  .layout { display: block; } .content { padding: 0; max-width: none; }
  body { background: #fff; } .paper { border: none; padding: 0; max-width: none; }
  .card { box-shadow: none; border-color: #bbb; }
  * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  @page { size: A4; margin: 10mm; }
}
@media screen and (max-width: 1100px) { .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); } .doc-layout { grid-template-columns: 1fr; } .task-board { grid-template-columns: 1fr; } }
@media screen and (max-width: 900px) { .login { grid-template-columns: 1fr; } .login-art { padding: 28px 24px; } .login-art h2 { font-size: 22px; } }
@media screen and (max-width: 860px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { position: fixed; inset: 0 0 0 auto; width: 270px; z-index: 40; transform: translateX(100%); visibility: hidden; transition: transform .2s, visibility .2s; }
  body.nav-open .sidebar { transform: none; visibility: visible; box-shadow: var(--shadow-pop); }
  .menu-btn { display: inline-flex; }
  .content, .topbar { padding-left: 16px; padding-right: 16px; }
  .g2, .g3 { grid-template-columns: 1fr; }
  .kpis { grid-template-columns: 1fr; }
  .search { min-width: 0; flex: 1; }
  .who-text { display: none; }
  .gsearch { max-width: none; }
  .paper { padding: 14px; } .paper .info { grid-template-columns: 1fr; }
}

/* ═════════ ختم الشركة ═════════ */
.sign-stamp { position: relative; }
.stamp-slot { position: absolute; left: 50%; bottom: -14px; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; pointer-events: none; }
.stamp-slot .stamp-svg { transform: rotate(-7deg); }
.stamp-slot small { color: var(--muted); opacity: .7; font-size: 9px; letter-spacing: 1px; margin-top: 2px; }
.stamp-svg { display: block; mix-blend-mode: multiply; }
.no-stamp .stamp-slot { display: none; }
.paper .sign { margin-top: 150px; padding-bottom: 40px; }
.sign-stamp { min-width: 190px; text-align: center; }
.switch { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; color: var(--ink-2); margin-inline-start: 6px; user-select: none; }
.switch input { display: none; }
.switch span { width: 34px; height: 20px; border-radius: 10px; background: var(--line-strong); position: relative; transition: background .15s; }
.switch span::after { content: ''; position: absolute; top: 2px; inset-inline-start: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.2); transition: inset-inline-start .15s; }
.switch input:checked + span { background: var(--brand); }
.switch input:checked + span::after { inset-inline-start: 16px; }

/* ═════════ القائمة الجانبية المنسدلة ═════════ */
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-head { width: 100%; display: flex; align-items: center; gap: 11px; padding: 9px 12px; border: none; background: none; border-radius: 8px; cursor: pointer; color: var(--ink-2); font-weight: 500; text-align: right; }
.nav-head svg:first-child { width: 18px; height: 18px; flex: none; color: var(--faint); }
.nav-head:hover { background: var(--surface-2); color: var(--ink); }
.nav-head .chev { margin-inline-start: auto; color: var(--faint); transition: transform .22s ease; }
.nav-sec.open > .nav-head .chev { transform: rotate(180deg); }
.nav-sec.has-active > .nav-head, .nav-sec.has-active > .nav-head svg:first-child { color: var(--brand); }
.nav-sub { display: grid; grid-template-rows: 0fr; transition: grid-template-rows .24s ease; }
.nav-sec.open > .nav-sub { grid-template-rows: 1fr; }
.nav-sub-in { overflow: hidden; }
.nav-sub-in a { margin-inline-start: 21px; padding: 7px 14px; font-size: 13.5px; border-radius: 8px 0 0 8px; border-inline-start: 1px solid var(--line); }
.nav-sub-in a:first-child { margin-top: 2px; } .nav-sub-in a:last-child { margin-bottom: 6px; }
.nav-sub-in a.active { border-inline-start-color: var(--brand); }
.nav-sub-in a.active::before { display: none; }
@media (prefers-reduced-motion: reduce) { .nav-sub, .nav-head .chev { transition: none; } }

/* جدول البنود: عرض أدنى حتى لا تضيق خانات الكمية والسعر */
.items-table { min-width: 880px; }
.items-table .w-qty input, .items-table .w-price input { min-width: 96px; }
@media screen and (max-width: 1360px) { .doc-layout { grid-template-columns: 1fr; } .doc-side { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); align-items: start; } }

/* ═════════ المستندات المطبوعة (فاتورة، سند، إذن تسليم، كشف) ═════════ */
.lockup { display: flex; align-items: center; gap: 12px; }
.lockup b { display: block; font-family: var(--font-head); font-weight: 700; font-size: 17px; line-height: 1.3; white-space: nowrap; }
.lockup small { display: block; direction: ltr; text-align: right; font-size: 9.5px; letter-spacing: 2.4px; font-weight: 600; color: var(--muted); white-space: nowrap; }
.doc { --d-ink: #1F2A1B; --d-brand: #3F6430; --d-line: #E0DFD2; --d-soft: #F5F7EE; --d-mute: #6B7564;
  position: relative; overflow: hidden; background: #fff; max-width: 840px; min-height: 1080px; margin: 0 auto 30px; padding: 36px 40px 24px;
  border: 1px solid var(--line); border-radius: 6px; box-shadow: 0 8px 30px rgba(35,45,25,.08); font-size: 12.5px; color: var(--d-ink); display: flex; flex-direction: column; }
.doc::before { content: ''; position: absolute; inset: 0 0 auto 0; height: 6px; background: linear-gradient(90deg, #2F4E24, var(--d-brand) 60%, #D8B266); }
.doc > * { position: relative; }
.doc-wm { position: absolute !important; width: 420px; height: 420px; left: 50%; top: 52%; transform: translate(-50%, -50%); fill: var(--d-brand); opacity: .035; pointer-events: none; }
.doc i { font-style: normal; color: #98A08D; font-size: .78em; font-weight: 500; letter-spacing: .4px; margin-inline-start: 5px; direction: ltr; unicode-bidi: isolate; }
.doc-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; padding-bottom: 18px; border-bottom: 2px solid var(--d-brand); }
.doc-co { display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
.doc-co b { display: block; font: 700 19px/1.35 var(--font-head); color: var(--d-ink); }
.doc-co .en { display: block; direction: ltr; text-align: right; font-size: 9px; letter-spacing: 1.8px; font-weight: 600; color: var(--d-mute); margin-top: 2px; }
.doc-co .t { display: block; font-size: 11.5px; color: var(--d-mute); margin-top: 4px; }
.doc-title { text-align: left; flex: none; }
.doc-title h2 { margin: 0; font: 700 25px/1.3 var(--font-head); color: var(--d-brand); }
.doc-title .en { display: block; direction: ltr; letter-spacing: 3.5px; font-size: 10.5px; font-weight: 600; color: var(--d-mute); }
.doc-title .no { display: inline-block; margin-top: 10px; padding: 4px 12px; border-radius: 6px; background: var(--d-soft); border: 1px solid var(--d-line); font-weight: 700; font-size: 13px; direction: ltr; font-variant-numeric: tabular-nums; }
.doc-badge { display: block; width: max-content; margin: 8px 0 0 auto; padding: 3px 10px; border-radius: 5px; font-size: 11px; font-weight: 700; border: 1.5px solid; }
.doc-badge.ok { color: #0E7A55; border-color: #0E7A55; background: #E9F7F0; } .doc-badge.warn { color: #A34D06; border-color: #D98A3D; background: #FDF3E7; }
.doc-blocks { display: grid; grid-template-columns: 1.15fr 1fr; gap: 14px; margin: 22px 0 18px; }
.doc-box { border: 1px solid var(--d-line); border-radius: 8px; overflow: hidden; background: #fff; }
.doc-box h4 { margin: 0; display: flex; justify-content: space-between; align-items: center; padding: 7px 12px; font: 700 11.5px var(--font); color: var(--d-brand); background: var(--d-soft); border-bottom: 1px solid var(--d-line); }
.doc-box h4 i { letter-spacing: 1.4px; font-size: 9px; }
.doc-box .in { padding: 11px 13px; }
.party-name { font: 700 15px/1.4 var(--font-head); margin-bottom: 6px; }
.kvs { display: grid; grid-template-columns: auto 1fr; gap: 5px 14px; margin: 0; }
.kvs dt { color: var(--d-mute); white-space: nowrap; } .kvs dd { margin: 0; font-weight: 600; text-align: left; }
table.items { width: 100%; border-collapse: separate; border-spacing: 0; border: 1px solid var(--d-line); border-radius: 8px; overflow: hidden; background: #fff; }
.items th { background: var(--d-brand); color: #fff; font-weight: 600; font-size: 11.5px; padding: 8px 10px; text-align: right; vertical-align: bottom; line-height: 1.3; }
.items th i { display: block; color: #CBD9AE; margin: 1px 0 0; font-size: 9px; }
.items td { padding: 8px 10px; border-top: 1px solid #ECE9DF; }
.items tbody tr:nth-child(even) td { background: #FBFBF6; }
.items .n { text-align: left; font-variant-numeric: tabular-nums; direction: ltr; white-space: nowrap; }
.items tfoot td { background: var(--d-soft); font-weight: 700; border-top: 1.5px solid var(--d-line); }
.doc-sum { display: grid; grid-template-columns: 1fr 290px; gap: 16px; margin-top: 16px; align-items: start; }
.words-box { border: 1px dashed #D5DFC0; background: #FBFBF6; border-radius: 8px; padding: 10px 13px; line-height: 1.7; }
.words-box b { display: block; color: var(--d-brand); font-size: 11.5px; }
.tot { border: 1px solid var(--d-line); border-radius: 8px; overflow: hidden; }
.tot > div { display: flex; justify-content: space-between; align-items: center; padding: 7px 13px; border-top: 1px solid #F0EEE6; }
.tot > div:first-child { border-top: none; }
.tot small { display: block; color: #98A08D; font-size: 9px; letter-spacing: .5px; direction: ltr; text-align: right; }
.tot .net { background: var(--d-brand); color: #fff; font-weight: 700; font-size: 14.5px; border-top: none; }
.tot .net small { color: #CBD9AE; }
.tot .due { background: #F1F5E9; font-weight: 700; color: #2F4E24; }
.acct-strip { display: grid; grid-template-columns: repeat(3, 1fr); margin-top: 14px; border: 1px solid var(--d-line); border-radius: 8px; overflow: hidden; }
.acct-strip > div { padding: 8px 13px; border-inline-start: 1px solid var(--d-line); }
.acct-strip > div:first-child { border-inline-start: none; }
.acct-strip small { display: block; color: var(--d-mute); font-size: 10.5px; margin-bottom: 2px; }
.doc-notes { margin-top: 12px; font-size: 11.5px; color: #3E4A38; line-height: 1.7; }
.voucher-amount { display: flex; align-items: baseline; gap: 14px; margin: 6px 0 14px; padding: 16px 20px; border-radius: 10px; background: var(--d-soft); border: 1px solid var(--d-line); }
.voucher-amount span { color: var(--d-mute); font-weight: 600; }
.voucher-amount b { font-size: 30px; color: var(--d-brand); font-weight: 700; }
.voucher-amount em { font-style: normal; color: var(--d-ink); font-weight: 600; }
.doc-sign { display: grid; grid-template-columns: repeat(var(--n, 3), 1fr); gap: 34px; margin-top: auto; padding-top: 160px; }
.doc-sign > div { position: relative; border-top: 1px solid #A5AA98; padding-top: 7px; text-align: center; font-weight: 600; color: #3E4A38; }
.doc-sign > div small { display: block; font-weight: 500; color: #98A08D; direction: ltr; font-size: 9.5px; letter-spacing: .5px; }
.doc-sign .stamp-slot { bottom: 42px; }
.doc-foot { margin-top: 20px; padding-top: 10px; border-top: 1px solid var(--d-line); display: flex; justify-content: space-between; gap: 10px 18px; flex-wrap: wrap; font-size: 10.5px; color: var(--d-mute); }
@media print {
  .doc { box-shadow: none; border: none; border-radius: 0; max-width: none; margin: 0; padding: 0 0 4mm; min-height: 268mm; }
  .doc-sign, .doc-sum, .acct-strip, .words-box, .voucher-amount { break-inside: avoid; page-break-inside: avoid; }
  .items tr { break-inside: avoid; } .items thead { display: table-header-group; } .items tfoot { display: table-row-group; }
  .stamp-slot, .stamp-svg { visibility: visible !important; }
  .no-stamp .stamp-slot { display: none !important; }
  .doc-wm { opacity: .03; }
  html, body, .main, .content, #view { background: #fff !important; }
  .doc { min-height: 0; padding-top: 4.5mm; font-size: 12px; }
  .doc-head { padding-bottom: 10px; }
  .doc-blocks { margin: 11px 0 10px; }
  .doc-box .in { padding: 8px 12px; }
  .items th { padding: 5px 9px; } .items td { padding: 5px 9px; }
  .doc-sum { margin-top: 10px; }
  .items td { padding: 4px 9px; }
  
  .doc-sign { padding-top: 92px; }
  .doc-sign .stamp-slot, .doc-sign .stamp-slot[data-plain] { bottom: 30px; }
  .doc-sign .stamp-svg { width: 110px; height: 110px; }
  .doc-foot { margin-top: 16px; padding-top: 8px; break-before: avoid; }
}
@media screen and (max-width: 760px) {
  .doc { padding: 22px 16px; min-height: 0; }
  .doc-head { flex-direction: column; } .doc-title { text-align: right; } .doc-badge { margin-inline-start: 0; }
  .doc-blocks, .doc-sum, .acct-strip { grid-template-columns: 1fr; }
  .acct-strip > div { border-inline-start: none; border-top: 1px solid var(--d-line); } .acct-strip > div:first-child { border-top: none; }
  .table-wrap-doc, table.items { display: block; overflow-x: auto; }
  .doc-sign { gap: 14px; padding-top: 90px; }
}
.doc-sign .stamp-slot[data-plain] { bottom: 42px; }

.doc-sum .acct-strip { margin-top: 12px; }
.doc-sum .acct-strip small { font-size: 9.5px; }

.stamp-slot .stamp-code { display: none; }
.doc-verify:empty { display: none; }

/* ═════════ هوية روافد: الشعار الأصلي ═════════ */
:root { --gold: #B98E4A; --gold-light: #D8B266; }
.brand { justify-content: center; padding: 6px 8px 14px; }
.brand-lockup { display: block; width: 196px; max-width: 100%; height: auto; }
.nav a.active::before { background: var(--gold); }
.doc-lockup { display: block; height: 78px; width: auto; }
.doc-co .t { margin: 0; }
.login-art { align-items: center; justify-content: center; text-align: center; gap: 34px; }
.art-band, .sp-band { position: absolute; inset: 0 0 auto 0; height: 14px; background: linear-gradient(90deg, #A07631, #D8B266 43%, #B98E4A); }
.art-logo { position: relative; display: block; width: min(330px, 70%); height: auto; }
.art-text { position: relative; }
.login-art h2, .login-art p { margin-inline: auto; }
.sp-mark { display: block; width: 190px; height: auto; clip-path: inset(0 0 100% 0); animation: sp-wipe 1.05s cubic-bezier(.6,0,.2,1) .2s forwards; }
.sp-word { display: block; width: 290px; height: auto; margin-top: 26px; animation: sp-up .6s ease-out 1.15s both; }
.sp-bar i { background: #D8B266; }
@media screen and (max-width:900px) { .art-logo { width: 190px; } }
@media print { .doc-lockup { height: 56px; } .doc-co { gap: 5px; } }

/* لا تتمدد الصفحة أفقياً على الشاشات الصغيرة: الجداول العريضة تُمرَّر داخل بطاقتها */
.doc-layout > .grid { grid-template-columns: minmax(0, 1fr); }
.print-toolbar { flex-wrap: wrap; align-items: center; }
@media screen and (max-width:1360px) { .doc-layout { grid-template-columns: minmax(0, 1fr); } }
@media screen and (max-width:860px) {
  .g2, .g3 { grid-template-columns: minmax(0, 1fr); }
  .card-body:has(#curs) { overflow-x: auto; }
  .doc-side { grid-template-columns: minmax(0, 1fr); }
}


/* ═════════ الأجهزة: حاسوب، آيباد، هاتف ═════════ */
.nav-scrim, .tabbar, .top-mark { display: none; }
@media (pointer: coarse) {
  .btn { min-height: 42px; }
  .btn.sm { min-height: 36px; }
  .icon-btn { min-width: 40px; min-height: 40px; }
  .nav a, .nav-head { padding-top: 11px; padding-bottom: 11px; }
  .perm-table .seg label { padding: 8px 12px; }
}
/* آيباد عمودي وما دونه: قائمة منزلقة مع خلفية معتمة */
@media screen and (max-width: 860px) {
  .nav-scrim { display: block; position: fixed; inset: 0; z-index: 35; background: rgba(35,45,25,.42); opacity: 0; pointer-events: none; transition: opacity .2s; }
  body.nav-open .nav-scrim { opacity: 1; pointer-events: auto; }
  .sidebar { width: 288px; padding-bottom: calc(24px + env(safe-area-inset-bottom)); }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
/* الهاتف: تجربة تشبه التطبيق */
@media screen and (max-width: 640px) {
  html, body { font-size: 15px; }
  input, select, textarea { font-size: 16px; }
  .menu-btn { display: none; }
  .top-mark { display: block; flex: none; }
  .topbar { padding: calc(8px + env(safe-area-inset-top)) 12px 8px; gap: 10px; }
  .gsearch input::placeholder { color: var(--faint); }
  .who .avatar { display: none; }
  .content { padding: 16px 12px calc(92px + env(safe-area-inset-bottom)); }
  .page-head { align-items: stretch; flex-direction: column; margin-bottom: 14px; }
  .page-head h1 { font-size: 19px; }
  .page-head .actions, .print-toolbar { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin-inline: -12px; padding-inline: 12px; padding-bottom: 2px; }
  .page-head .actions::-webkit-scrollbar, .print-toolbar::-webkit-scrollbar, .tabs::-webkit-scrollbar { display: none; }
  .page-head .actions .btn, .print-toolbar .btn { flex: none; }
  .print-toolbar > .muted { display: none; }
  .tabs { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
  .tabs a { flex: none; white-space: nowrap; }
  .toolbar { gap: 6px; }
  .toolbar .search { min-width: 0; flex: 1 1 100%; }
  .card-body { padding: 14px; }
  .card-head { padding: 12px 14px; }
  .list-mini li { padding: 10px 14px; flex-wrap: wrap; }

  .kpis { gap: 10px; }
  .kpi { padding: 12px; display: block; }
  .kpi .ic { display: none; }
  .kpi .label { font-size: 12px; }
  .kpi .value { font-size: 16.5px; white-space: normal; }
  .kpi .hint { font-size: 11.5px; }

  /* شريط التنقل السفلي */
  .tabbar { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; position: fixed; inset: auto 0 0 0; z-index: 30; background: rgba(255,255,255,.96); backdrop-filter: blur(10px); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
  .tabbar a, .tabbar button { position: relative; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 2px 7px; border: 0; background: none; color: var(--muted); font-size: 11px; font-weight: 500; cursor: pointer; }
  .tabbar a.active { color: var(--brand); font-weight: 700; }
  .tabbar a.active::before { content: ''; position: absolute; top: 0; inset-inline: 28%; height: 3px; border-radius: 0 0 3px 3px; background: var(--gold); }
  .tabbar em { position: absolute; top: 4px; inset-inline-start: calc(50% + 6px); min-width: 17px; height: 17px; padding: 0 4px; border-radius: 9px; background: var(--danger); color: #fff; font: 700 10.5px/17px var(--font); text-align: center; }
  .tabbar em[hidden] { display: none; }

  /* الجداول بطاقات */
  table.t.cards, .t.cards tbody, .t.cards tfoot { display: block; }
  .t.cards thead { display: none; }
  .t.cards tbody tr { display: block; border: 1px solid var(--line); border-radius: 12px; margin: 10px 12px; background: #fff; overflow: hidden; }
  .t.cards tbody tr:hover { background: #fff; }
  .t.cards tbody tr:active { background: var(--surface-2); }
  .t.cards td { display: flex; justify-content: space-between; align-items: center; gap: 14px; text-align: left; padding: 8px 12px; border-bottom: 1px solid var(--line); min-width: 0; overflow-wrap: anywhere; }
  .t.cards td:last-child { border-bottom: none; }
  .t.cards td::before { content: attr(data-label); flex: none; color: var(--muted); font-size: 12.5px; }
  .t.cards td[data-label=""]::before { display: none; }
  .t.cards td[data-label=""] { justify-content: flex-end; }
  .t.cards td:empty { display: none; }
  .t.cards tfoot tr { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 6px 14px; padding: 10px 14px; background: var(--surface-2); }
  .t.cards tfoot td { display: block; padding: 0; border: 0; background: none; }
  .t.cards tfoot td:empty { display: none; }
  .t.cards .actions { justify-content: flex-end; }

  /* بنود المستندات بطاقات */
  .items-table, .items-table tbody, .items-table tr { display: block; min-width: 0; }
  .items-table thead { display: none; }
  .items-table tr { position: relative; border: 1px solid var(--line); border-radius: 12px; margin: 10px 12px; padding: 6px 0; }
  .items-table tr:hover { background: none; }
  .items-table td, .items-table .w-qty, .items-table .w-price, .items-table .w-unit, .items-table .w-code, .items-table .w-name, .items-table .w-total { display: flex; align-items: center; gap: 12px; width: auto; min-width: 0; padding: 5px 12px; border: 0; }
  .items-table td::before { content: attr(data-label); flex: 0 0 96px; color: var(--muted); font-size: 12.5px; }
  .items-table .w-qty input, .items-table .w-price input { min-width: 0; }
  .items-table td.w-rm { position: absolute; top: 2px; inset-inline-end: 2px; padding: 0; width: auto !important; }
  .items-table td.w-rm::before { display: none; }
  .totals { justify-content: stretch; grid-template-columns: 1fr auto; }

  /* النوافذ من الأسفل */
  .modal-bg { padding: 0; align-items: flex-end; }
  .modal, .modal.sm, .modal.xl { max-width: none; max-height: 92dvh; display: flex; flex-direction: column; border-radius: 18px 18px 0 0; }
  .modal-body { overflow-y: auto; flex: 1; padding: 16px; }
  .modal-foot { border-radius: 0; flex-wrap: wrap; padding-bottom: calc(12px + env(safe-area-inset-bottom)); }
  .modal-foot .btn { flex: 1 1 auto; justify-content: center; }
  .perm-table td, .perm-table th { padding: 6px 4px; }
  .perm-table th:last-child, .perm-table td:last-child { display: none; }
  .perm-table .seg label { padding: 7px 7px; font-size: 12px; }
  #toast { bottom: calc(76px + env(safe-area-inset-bottom)); width: calc(100% - 32px); }
  .toast { text-align: center; }

  .task-board { display: flex; overflow-x: auto; scroll-snap-type: x mandatory; gap: 10px; margin-inline: -12px; padding-inline: 12px; scrollbar-width: none; }
  .task-col { flex: 0 0 84%; scroll-snap-align: center; }
  .bars { gap: 6px; }
  .legend { flex-wrap: wrap; gap: 8px; }
  .card-head { flex-wrap: wrap; }
  .search { min-width: 0; }
  .login-art { padding: 26px 20px 22px; gap: 14px; }
  .art-logo { width: 132px; }
  .art-text { display: none; }
  .login-form { place-items: start center; padding: 26px 18px; }
  .doc-side { grid-template-columns: minmax(0, 1fr); }
  .form-grid { grid-template-columns: minmax(0, 1fr); }
  table.items { display: table; min-width: 620px; }
  .doc { overflow-x: auto; }
  .doc-lockup { height: 56px; }
}


/* إصلاحات العرض وتبسيط الهاتف */
.grid:not(.g2):not(.g3) { grid-template-columns: minmax(0, 1fr); }
.card-body:has(#curs) { overflow-x: auto; }
html { -webkit-tap-highlight-color: transparent; }
a, button, .btn, .t tr.click { touch-action: manipulation; }
@media screen and (max-width: 640px) {
  .page-head { flex-wrap: nowrap; }
  .page-head > * { min-width: 0; }
  .page-head .sub { display: none; }
  #xls { display: none; }
  #view { animation: view-in .16s ease-out; }
  .btn:active, .tabbar a:active, .tabbar button:active, .t.cards tbody tr:active { transform: scale(.985); }
  .t.cards tbody tr { padding: 6px 0; margin: 8px 10px; transition: transform .1s; }
  .t.cards td { padding: 4px 13px; border-bottom: 0; font-size: 14.5px; }
  .t.cards td.m-hide { display: none; }
  .t.cards td.m-title { font-size: 15.5px; padding-block: 6px; }
  .t.cards td.m-title::before { display: none; }
  .t.cards td.m-title { justify-content: flex-start; }
  .t.cards td::before { font-size: 13px; }
  .t.cards .badge { font-size: 12px; }
  .card:has(> #tbl) > .card-body { padding: 10px 10px 0; }
  .card:has(> #tbl) { background: transparent; border: 0; box-shadow: none; }
  .card:has(> #tbl) .t.cards tbody tr { margin-inline: 0; }
  .card:has(> #tbl) .t.cards tfoot tr { border-radius: 12px; border: 1px solid var(--line); margin-top: 8px; }
  .toolbar { margin-bottom: 4px; }
}
@keyframes view-in { from { opacity: .4; transform: translateY(4px); } }
@media (prefers-reduced-motion: reduce) { #view { animation: none !important; } }


/* ═════════ مساعد روافد ═════════ */
.ag-fab { position: fixed; inset-inline-end: 22px; bottom: 22px; z-index: 28; width: 58px; height: 58px; border: 0; border-radius: 50%; cursor: pointer; display: grid; place-items: center; background: linear-gradient(135deg, #3F6430, #2F4E24); box-shadow: 0 8px 24px rgba(35,45,25,.32); transition: transform .18s; }
.ag-fab:hover { transform: scale(1.05); }
.ag-scrim { position: fixed; inset: 0; z-index: 44; background: rgba(35,45,25,.32); opacity: 0; pointer-events: none; transition: opacity .22s; }
.ag-panel { position: fixed; inset-block: 0; inset-inline-start: 0; z-index: 45; width: min(420px, 100%); display: flex; flex-direction: column; background: var(--bg); box-shadow: var(--shadow-pop); transform: translateX(104%); visibility: hidden; transition: transform .26s cubic-bezier(.2,.8,.2,1), visibility .26s; }
body.ag-open .ag-panel { transform: none; visibility: visible; }
body.ag-open .ag-scrim { opacity: 1; pointer-events: auto; }
.ag-panel header { display: flex; align-items: center; gap: 10px; padding: calc(12px + env(safe-area-inset-top)) 14px 12px; color: #fff; background: linear-gradient(90deg, #2F4E24, #557A2E); }
.ag-panel header div { flex: 1; line-height: 1.3; }
.ag-panel header b { display: block; font-family: var(--font-head); font-size: 15px; }
.ag-panel header small { color: #F3F1E4; font-size: 12px; }
.ag-panel header .icon-btn { color: #fff; }
.ag-panel header .icon-btn:hover { background: rgba(255,255,255,.14); color: #fff; }
.ag-log { flex: 1; overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 10px; overscroll-behavior: contain; }
.ag-msg { max-width: 88%; padding: 10px 13px; border-radius: 14px; line-height: 1.7; overflow-wrap: anywhere; animation: pop .16s ease-out; }
.ag-msg.bot { align-self: flex-start; background: #fff; border: 1px solid var(--line); border-start-start-radius: 4px; }
.ag-msg.user { align-self: flex-end; background: var(--brand); color: #fff; border-start-end-radius: 4px; }
.ag-msg.err { color: var(--danger); background: var(--danger-soft); border-color: #EFC2C2; }
.ag-msg.typing { display: flex; gap: 5px; padding: 14px; }
.ag-msg.typing i { width: 7px; height: 7px; border-radius: 50%; background: var(--faint); animation: ag-dot 1s infinite; }
.ag-msg.typing i:nth-child(2) { animation-delay: .15s; } .ag-msg.typing i:nth-child(3) { animation-delay: .3s; }
@keyframes ag-dot { 40% { transform: translateY(-5px); opacity: .55; } }
.ag-msg.confirm { align-self: stretch; max-width: none; background: #fff; border: 1.5px solid var(--gold); }
.ag-c-title { display: block; color: var(--brand-deep); margin-bottom: 6px; }
.ag-msg.confirm dl { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; margin: 0 0 10px; }
.ag-msg.confirm dt { color: var(--muted); font-size: 13px; } .ag-msg.confirm dd { margin: 0; font-weight: 500; }
.ag-c-btns { display: flex; gap: 8px; }
.ag-c-btns .btn { flex: 1; justify-content: center; }
.ag-chips { display: flex; flex-wrap: wrap; gap: 7px; }
.ag-chips button { border: 1px solid var(--brand-line); background: var(--brand-soft); color: var(--brand-deep); border-radius: 16px; padding: 7px 12px; cursor: pointer; font-size: 13px; }
.ag-form { display: flex; gap: 8px; align-items: flex-end; padding: 10px 12px calc(10px + env(safe-area-inset-bottom)); background: #fff; border-top: 1px solid var(--line); }
.ag-form textarea { min-height: 42px; max-height: 110px; resize: none; line-height: 1.5; }
.ag-form .btn { min-height: 42px; }
@media screen and (max-width: 640px) {
  .ag-fab { width: 50px; height: 50px; inset-inline-end: 12px; bottom: calc(70px + env(safe-area-inset-bottom)); }
  .ag-panel { width: 100%; height: 100dvh; inset-block: auto 0; transform: translateY(104%); }
  .ag-msg { max-width: 92%; }
}
@media print { .ag-fab, .ag-panel, .ag-scrim { display: none !important; } }
@media (prefers-reduced-motion: reduce) { .ag-panel, .ag-scrim, .ag-fab { transition: none; } }
