/* =====================================================================
   واجهة نظام إدارة الحقول — تصميم مستقل (بدون مكتبات خارجية)، RTL، للجوال أولاً
   ===================================================================== */

:root {
  --brand: #1f7a4d;
  --brand-700: #165c39;
  --brand-900: #0f3d27;
  --brand-50: #e9f5ee;
  --brand-100: #d3ecdd;
  --bg: #f3f6f4;
  --surface: #ffffff;
  --text: #1b2a21;
  --muted: #6a7a70;
  --border: #e2e8e4;
  --border-strong: #cdd7d0;
  --success: #1f9254;
  --danger: #d23f3f;
  --warning: #d99a00;
  --info: #2a83c4;
  --primary: #2f6fd6;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(16, 32, 24, .05), 0 6px 16px rgba(16, 32, 24, .05);
  --shadow-lg: 0 12px 40px rgba(16, 32, 24, .18);
  --sbw: 264px;
  --bottom: 68px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --font: 'Tajawal', 'Segoe UI', 'Noto Sans Arabic', 'Noto Kufi Arabic', Tahoma, 'Geeza Pro', system-ui, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; font-family: var(--font); font-size: 15px; line-height: 1.6;
  color: var(--text); background: var(--bg); -webkit-tap-highlight-color: transparent;
}
a { color: var(--brand); text-decoration: none; }
a:hover { color: var(--brand-700); text-decoration: underline; }
img, svg { vertical-align: middle; }
hr { border: 0; border-top: 1px solid var(--border); margin: .75rem 0; }
code { background: #eef2ef; padding: .1em .35em; border-radius: 5px; font-size: .9em; direction: ltr; unicode-bidi: isolate; }
h1, h2, h3, h4, h5, h6, .h4, .h5, .h6 { margin: 0 0 .5rem; font-weight: 800; line-height: 1.3; }
.h4 { font-size: 1.3rem; } .h5 { font-size: 1.12rem; } .h6 { font-size: 1rem; }
p { margin: 0 0 .75rem; }
ul, ol { padding-inline-start: 1.3rem; margin: 0 0 .75rem; }
small, .small { font-size: .85em; }
textarea { resize: vertical; }
[hidden] { display: none !important; }
.ico { width: 1.15em; height: 1.15em; flex-shrink: 0; }

/* ===================== الشبكة ===================== */
.container, .container-fluid { width: 100%; margin-inline: auto; padding-inline: 1rem; }
.container { max-width: 1140px; }
.row { --gx: 1.5rem; --gy: 0; display: flex; flex-wrap: wrap; margin-inline: calc(var(--gx) * -.5); margin-top: calc(var(--gy) * -1); }
.row > * { flex-shrink: 0; width: 100%; max-width: 100%; padding-inline: calc(var(--gx) * .5); margin-top: var(--gy); }
.g-1 { --gx: .25rem; --gy: .25rem; } .g-2 { --gx: .5rem; --gy: .5rem; } .g-3 { --gx: 1rem; --gy: 1rem; }
.col { flex: 1 0 0%; }
.col-1 { flex: 0 0 auto; width: 8.3333%; } .col-2 { flex: 0 0 auto; width: 16.6667%; } .col-3 { flex: 0 0 auto; width: 25%; }
.col-4 { flex: 0 0 auto; width: 33.3333%; } .col-5 { flex: 0 0 auto; width: 41.6667%; } .col-6 { flex: 0 0 auto; width: 50%; }
.col-7 { flex: 0 0 auto; width: 58.3333%; } .col-8 { flex: 0 0 auto; width: 66.6667%; } .col-9 { flex: 0 0 auto; width: 75%; }
.col-10 { flex: 0 0 auto; width: 83.3333%; } .col-11 { flex: 0 0 auto; width: 91.6667%; } .col-12 { flex: 0 0 auto; width: 100%; }
@media (min-width: 576px) { .col-sm-6 { flex: 0 0 auto; width: 50%; } }
@media (min-width: 768px) {
  .col-md-1 { flex: 0 0 auto; width: 8.3333%; } .col-md-2 { flex: 0 0 auto; width: 16.6667%; } .col-md-3 { flex: 0 0 auto; width: 25%; }
  .col-md-4 { flex: 0 0 auto; width: 33.3333%; } .col-md-5 { flex: 0 0 auto; width: 41.6667%; } .col-md-6 { flex: 0 0 auto; width: 50%; }
  .col-md-7 { flex: 0 0 auto; width: 58.3333%; } .col-md-8 { flex: 0 0 auto; width: 66.6667%; } .col-md-9 { flex: 0 0 auto; width: 75%; }
  .col-md-12 { flex: 0 0 auto; width: 100%; } .col-md-auto { flex: 0 0 auto; width: auto; }
}
@media (min-width: 992px) {
  .col-lg-2 { flex: 0 0 auto; width: 16.6667%; } .col-lg-5 { flex: 0 0 auto; width: 41.6667%; } .col-lg-6 { flex: 0 0 auto; width: 50%; }
  .col-lg-7 { flex: 0 0 auto; width: 58.3333%; } .col-lg-12 { flex: 0 0 auto; width: 100%; }
}
@media (min-width: 1200px) { .col-xl-4 { flex: 0 0 auto; width: 33.3333%; } }

/* ===================== أدوات مساعدة ===================== */
.d-flex { display: flex !important; } .d-inline { display: inline !important; } .d-block { display: block !important; } .d-none { display: none !important; }
.flex-wrap { flex-wrap: wrap; } .flex-column { flex-direction: column; }
.justify-content-between { justify-content: space-between; } .justify-content-center { justify-content: center; }
.align-items-center { align-items: center; } .align-items-end { align-items: flex-end; } .align-items-start { align-items: flex-start; }
.align-self-start { align-self: flex-start; } .align-middle { vertical-align: middle; }
.gap-1 { gap: .25rem; } .gap-2 { gap: .5rem; } .gap-3 { gap: 1rem; }
.w-100 { width: 100% !important; } .h-100 { height: 100% !important; }
.m-0 { margin: 0 !important; } .mb-0 { margin-bottom: 0 !important; } .mb-1 { margin-bottom: .25rem !important; } .mb-2 { margin-bottom: .5rem !important; }
.mb-3 { margin-bottom: 1rem !important; } .mb-4 { margin-bottom: 1.5rem !important; }
.mt-1 { margin-top: .25rem !important; } .mt-2 { margin-top: .5rem !important; } .mt-3 { margin-top: 1rem !important; }
.my-1 { margin-block: .25rem !important; } .my-2 { margin-block: .5rem !important; }
.ms-1 { margin-inline-start: .25rem !important; } .ms-2 { margin-inline-start: .5rem !important; } .ms-auto { margin-inline-start: auto !important; }
.me-1 { margin-inline-end: .25rem !important; } .me-auto { margin-inline-end: auto !important; }
.p-0 { padding: 0 !important; } .p-2 { padding: .5rem !important; } .p-3 { padding: 1rem !important; } .p-4 { padding: 1.5rem !important; }
.py-2 { padding-block: .5rem !important; } .py-3 { padding-block: 1rem !important; } .py-4 { padding-block: 1.5rem !important; } .py-5 { padding-block: 3rem !important; }
.px-3 { padding-inline: 1rem !important; }
.text-center { text-align: center !important; } .text-end { text-align: end !important; } .text-start { text-align: start !important; }
.text-nowrap { white-space: nowrap !important; } .text-uppercase { text-transform: uppercase; }
.text-decoration-none { text-decoration: none !important; } .text-reset { color: inherit !important; }
.text-muted { color: var(--muted) !important; } .text-danger { color: var(--danger) !important; } .text-success { color: var(--success) !important; }
.text-warning { color: #b07c00 !important; } .text-dark { color: var(--text) !important; } .text-info { color: var(--info) !important; }
.fw-bold { font-weight: 700 !important; } .fw-normal { font-weight: 400 !important; }
.fs-4 { font-size: 1.45rem !important; } .fs-5 { font-size: 1.2rem !important; } .fs-6 { font-size: 1rem !important; }
.bg-white { background: #fff !important; } .bg-success { background: var(--success) !important; color: #fff; }
.border { border: 1px solid var(--border) !important; } .border-danger { border-color: #f1b5b5 !important; } .border-warning { border-color: #f3d58a !important; }
.border-start { border-inline-start: 1px solid var(--border) !important; } .border-4 { border-inline-start-width: 4px !important; }
.rounded { border-radius: var(--radius-sm) !important; } .shadow-sm { box-shadow: var(--shadow) !important; }
.opacity-50 { opacity: .55; } .list-unstyled { list-style: none; padding: 0; }
.num { direction: ltr; unicode-bidi: isolate; display: inline-block; white-space: nowrap; font-variant-numeric: tabular-nums; }

/* ===================== البطاقات ===================== */
.card { position: relative; display: flex; flex-direction: column; min-width: 0; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-body { flex: 1 1 auto; padding: 1.1rem; }
.card.card-body { padding: 1.15rem; }
.card-header { padding: .8rem 1.1rem; border-bottom: 1px solid var(--border); font-weight: 700; background: transparent; border-radius: var(--radius) var(--radius) 0 0; }
.card-footer { padding: .7rem 1.1rem; border-top: 1px solid var(--border); background: #fafcfb; border-radius: 0 0 var(--radius) var(--radius); }
.card + .card { margin-top: 0; }
.stat .card-body { padding: .9rem 1rem; }
.stat .label { color: var(--muted); font-size: .82rem; font-weight: 600; }
.stat .value { font-size: 1.35rem; font-weight: 800; margin-top: .15rem; }
.form-narrow { max-width: 900px; }

/* ===================== الأزرار ===================== */
.btn {
  --c: var(--text); display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  padding: .55rem 1.05rem; min-height: 42px; font: inherit; font-weight: 700; font-size: .95rem; line-height: 1.3;
  color: var(--c); background: transparent; border: 1px solid transparent; border-radius: var(--radius-sm);
  cursor: pointer; text-decoration: none !important; white-space: nowrap; user-select: none;
  transition: background .15s, color .15s, border-color .15s, box-shadow .15s, transform .05s;
}
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: 0; box-shadow: 0 0 0 3px rgba(31, 122, 77, .25); }
.btn:disabled, .btn.disabled { opacity: .55; pointer-events: none; }
.btn-sm { padding: .32rem .7rem; min-height: 34px; font-size: .85rem; border-radius: 8px; }
.btn-lg { padding: .8rem 1.4rem; min-height: 52px; font-size: 1.08rem; }
.btn-success { background: var(--brand); color: #fff; }
.btn-success:hover { background: var(--brand-700); color: #fff; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: #2559b0; color: #fff; }
.btn-warning { background: #f2b52c; color: #3a2a00; }
.btn-warning:hover { background: #e0a313; color: #3a2a00; }
.btn-outline-secondary { --c: #3f4f45; border-color: var(--border-strong); background: #fff; }
.btn-outline-secondary:hover { background: #f1f4f2; color: #26332b; }
.btn-outline-success { --c: var(--brand); border-color: #a9d6bb; background: #fff; }
.btn-outline-success:hover { background: var(--brand-50); color: var(--brand-700); }
.btn-outline-primary { --c: var(--primary); border-color: #b5cbf0; background: #fff; }
.btn-outline-primary:hover { background: #eef3fd; }
.btn-outline-danger { --c: var(--danger); border-color: #efb4b4; background: #fff; }
.btn-outline-danger:hover { background: #fdeeee; }
.btn-outline-warning { --c: #9a6b00; border-color: #ecd08b; background: #fff; }
.btn-outline-warning:hover { background: #fff7e3; }
.btn-outline-info { --c: var(--info); border-color: #acd2ee; background: #fff; }
.btn-outline-info:hover { background: #eef6fc; }
.btn-link { --c: var(--brand); padding: 0; min-height: 0; border: 0; font-weight: 600; background: none; }
.btn-link:hover { text-decoration: underline !important; }
.btn-link.text-danger { --c: var(--danger); }
.btn-group { display: flex; width: 100%; }
.btn-group > .btn { flex: 1 1 0; border-radius: 0; margin-inline-start: -1px; }
.btn-group > .btn:first-of-type, .btn-group > .btn-check:first-child + .btn { border-start-start-radius: var(--radius-sm); border-end-start-radius: var(--radius-sm); margin-inline-start: 0; }
.btn-group > .btn:last-child { border-start-end-radius: var(--radius-sm); border-end-end-radius: var(--radius-sm); }
.btn-check { position: absolute; clip: rect(0, 0, 0, 0); pointer-events: none; }
.btn-check:checked + .btn-outline-success { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-check:checked + .btn-outline-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-check:checked + .btn-outline-warning { background: #f2b52c; border-color: #f2b52c; color: #3a2a00; }
.btn-check:checked + .btn-outline-secondary { background: #3f4f45; border-color: #3f4f45; color: #fff; }
.btn-check:focus-visible + .btn { box-shadow: 0 0 0 3px rgba(31, 122, 77, .25); }

/* ===================== النماذج ===================== */
.form-label { display: block; margin-bottom: .35rem; font-weight: 700; font-size: .88rem; color: #34453b; }
.form-control, .form-select {
  display: block; width: 100%; min-height: 44px; padding: .55rem .8rem; font: inherit; font-size: 1rem; line-height: 1.4;
  color: var(--text); background-color: #fff; border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  transition: border-color .15s, box-shadow .15s; appearance: none;
}
.form-control::placeholder { color: #9aa79f; }
.form-control:focus, .form-select:focus { outline: 0; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(31, 122, 77, .14); }
.form-control:disabled, .form-select:disabled, .form-control[readonly] { background: #f3f5f4; }
.form-select {
  padding-inline-end: 2.3rem; cursor: pointer;
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%236a7a70' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'/%3e%3c/svg%3e");
  background-repeat: no-repeat; background-position: left .75rem center; background-size: 14px;
}
.form-control-sm, .form-select-sm { min-height: 38px; padding-block: .35rem; font-size: .92rem; border-radius: 8px; }
.form-select-sm { padding-inline-end: 2rem; }
textarea.form-control { min-height: 70px; }
input[type=date].form-control, input[type=month].form-control { min-width: 0; }
.form-text { font-size: .8rem; color: var(--muted); margin-top: .3rem; }
.form-check { display: flex; align-items: center; gap: .5rem; min-height: 1.6rem; }
.form-check-input { width: 1.25rem; height: 1.25rem; margin: 0; accent-color: var(--brand); flex-shrink: 0; cursor: pointer; }
.form-check-label { cursor: pointer; }
.input-group { display: flex; align-items: stretch; width: 100%; }
.input-group > .form-control, .input-group > .form-select { flex: 1 1 auto; width: 1%; min-width: 0; }
.input-group > * { border-radius: 0 !important; }
.input-group > :first-child { border-start-start-radius: var(--radius-sm) !important; border-end-start-radius: var(--radius-sm) !important; }
.input-group > :last-child { border-start-end-radius: var(--radius-sm) !important; border-end-end-radius: var(--radius-sm) !important; }
.input-group > :not(:first-child) { margin-inline-start: -1px; }
details.more { border: 1px dashed var(--border-strong); border-radius: var(--radius-sm); padding: .2rem .9rem; margin-top: .25rem; }
details.more > summary { cursor: pointer; padding: .5rem 0; font-weight: 700; color: var(--brand); list-style: none; display: flex; align-items: center; gap: .4rem; }
details.more > summary::-webkit-details-marker { display: none; }
details.more > summary::before { content: '+'; display: inline-grid; place-items: center; width: 1.3rem; height: 1.3rem; border-radius: 50%; background: var(--brand-50); font-weight: 800; }
details.more[open] > summary::before { content: '−'; }
details.more[open] { padding-bottom: .9rem; }

/* ===================== الشارات والتنبيهات ===================== */
.badge { display: inline-flex; align-items: center; gap: .25rem; padding: .22em .62em; font-size: .76rem; font-weight: 700; line-height: 1.3; border-radius: 999px; white-space: nowrap; vertical-align: middle; }
.text-bg-success { background: #e1f3e8; color: #15683d; }
.text-bg-danger { background: #fde6e6; color: #b42a2a; }
.text-bg-warning { background: #fff1cc; color: #8a5c00; }
.text-bg-info { background: #e1f0fb; color: #1b6aa3; }
.text-bg-primary { background: #e5edfc; color: #2352ae; }
.text-bg-secondary { background: #edf0ee; color: #4b5a51; }
.text-bg-dark { background: #24312a; color: #fff; }
.text-bg-light { background: #f3f6f4; color: #34453b; }
.alert { position: relative; padding: .8rem 1rem; margin-bottom: 1rem; border: 1px solid transparent; border-radius: 12px; font-size: .95rem; }
.alert ul { margin: 0; }
.alert-success { background: #e8f6ee; border-color: #bfe3cd; color: #145c36; }
.alert-danger { background: #fdecec; border-color: #f4c2c2; color: #942222; }
.alert-warning { background: #fff6dd; border-color: #f2dc9a; color: #6e4b00; }
.alert-info { background: #e8f3fc; border-color: #bcdaf2; color: #17598a; }
.alert-light { background: #f7f9f8; border-color: var(--border); color: #3d4c43; }
.alert-dismissible { padding-inline-end: 2.8rem; }
.btn-close {
  position: absolute; top: .55rem; inset-inline-end: .55rem; width: 1.7rem; height: 1.7rem; border: 0; border-radius: 50%; cursor: pointer; opacity: .55;
  background: transparent url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2.5' stroke-linecap='round'%3e%3cline x1='18' y1='6' x2='6' y2='18'/%3e%3cline x1='6' y1='6' x2='18' y2='18'/%3e%3c/svg%3e") center / 13px no-repeat;
}
.btn-close:hover { opacity: .9; background-color: rgba(0, 0, 0, .05); }
.fade { transition: opacity .2s; }

/* ===================== الجداول ===================== */
.table-responsive { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table { width: 100%; border-collapse: collapse; font-size: .92rem; margin: 0; }
.table th, .table td { padding: .62rem .75rem; text-align: start; vertical-align: middle; border-bottom: 1px solid var(--border); }
.table thead th { background: #f6f8f7; color: #56675d; font-size: .8rem; font-weight: 700; white-space: nowrap; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tfoot th, .table tfoot td { font-weight: 800; background: #f6f8f7; border-top: 1px solid var(--border); border-bottom: 0; }
.table-sm th, .table-sm td { padding: .45rem .6rem; }
.table-hover tbody tr:hover { background: #f6faf7; }
.table-bordered th, .table-bordered td { border: 1px solid var(--border); }
.table-borderless th, .table-borderless td { border: 0; }
.table-light, .table-light > th, .table-light > td, thead.table-light th, tfoot.table-light th, tr.table-light td { background: #f6f8f7; }
tr.cancelled td { color: #a9b3ad; text-decoration: line-through; }
tr.cancelled td .btn, tr.cancelled td form { text-decoration: none; }

/* ===================== القوائم والترقيم والتقدم ===================== */
.list-group { display: flex; flex-direction: column; padding: 0; margin: 0; list-style: none; }
.list-group-item { padding: .7rem 1rem; border-bottom: 1px solid var(--border); }
.list-group-item:last-child { border-bottom: 0; }
.progress { height: .55rem; background: #e8eeea; border-radius: 99px; overflow: hidden; }
.progress-bar { height: 100%; background: var(--brand); border-radius: 99px; }
.pagination { display: flex; flex-wrap: wrap; gap: .3rem; list-style: none; padding: 0; margin: .5rem 0; }
.page-link { display: block; min-width: 2.2rem; padding: .35rem .6rem; text-align: center; border: 1px solid var(--border-strong); border-radius: 8px; background: #fff; color: var(--text); }
.page-item.active .page-link { background: var(--brand); border-color: var(--brand); color: #fff; }
.page-item.disabled .page-link { color: var(--muted); background: transparent; border-color: transparent; }
.dropdown { position: relative; }

/* ===================== الفلاتر ===================== */
.filters { background: #fff; border: 1px solid var(--border); border-radius: var(--radius); padding: .85rem; margin-bottom: 1rem; box-shadow: var(--shadow); }
.filters .form-check { margin-bottom: .45rem; }
.filter-toggle { display: none; }

/* ===================== المستندات والطباعة ===================== */
.doc { max-width: 840px; margin: 0 auto; background: #fff; padding: 2rem; border-radius: var(--radius); border: 1px solid var(--border); }
.doc .doc-head { border-bottom: 3px solid var(--brand); padding-bottom: 1rem; margin-bottom: 1.25rem; }
.doc .sign { margin-top: 3rem; display: flex; justify-content: space-between; }
.doc .sign div { width: 40%; border-top: 1px dashed #999; padding-top: .4rem; text-align: center; color: #666; }
.item-row { background: #fafcfb; }
.border.rounded.item-row { border-radius: 12px !important; }
.field-card .code { font-size: 1.05rem; letter-spacing: .5px; }
.login-box { max-width: 420px; margin: 0 auto; }

/* ===================== هيكل التطبيق ===================== */
.sidebar {
  position: fixed; inset-block: 0; inset-inline-start: 0; width: var(--sbw); z-index: 40;
  display: flex; flex-direction: column; color: #d7eadf;
  background: linear-gradient(180deg, #145236 0%, #0f3d27 100%);
}
.sb-brand { display: flex; align-items: center; gap: .7rem; padding: 1.1rem 1.1rem .8rem; }
.logo { display: grid; place-items: center; width: 42px; height: 42px; border-radius: 12px; background: #fff; color: var(--brand); flex-shrink: 0; }
.logo .ico { width: 26px; height: 26px; }
.sb-farm { font-weight: 800; color: #fff; font-size: 1rem; line-height: 1.25; }
.sb-app { font-size: .76rem; color: #9cc9ae; }
.sb-add { margin: .3rem 1rem .6rem; background: #fff; color: var(--brand-700); border-radius: 12px; min-height: 44px; font-size: .98rem; }
.sb-add:hover { background: var(--brand-50); color: var(--brand-900); }
.sb-nav { flex: 1; overflow-y: auto; padding: .2rem .7rem 1rem; scrollbar-width: thin; }
.sb-group { font-size: .72rem; font-weight: 700; color: #84b799; margin: 1rem .6rem .35rem; letter-spacing: .3px; }
.sb-link { display: flex; align-items: center; gap: .7rem; padding: .55rem .7rem; margin-bottom: 2px; border-radius: 10px; color: #d7eadf; font-weight: 600; font-size: .95rem; }
.sb-link:hover { background: rgba(255, 255, 255, .08); color: #fff; text-decoration: none; }
.sb-link.active { background: rgba(255, 255, 255, .16); color: #fff; box-shadow: inset -3px 0 0 #7fe0a8; }
.sb-link .ico { opacity: .9; }
.sb-foot { padding: .8rem 1rem 1rem; border-top: 1px solid rgba(255, 255, 255, .1); }
.sb-install { width: 100%; margin-bottom: .7rem; background: #7fe0a8; color: #0f3d27; border-radius: 12px; }
.sb-install:hover { background: #a3ecc1; color: #0f3d27; }
.sb-user { display: flex; align-items: center; gap: .6rem; }
.avatar { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 50%; background: var(--brand-50); color: var(--brand-700); font-weight: 800; flex-shrink: 0; }
.sb-user .avatar { background: rgba(255, 255, 255, .15); color: #fff; }
.sb-user .who { flex: 1; min-width: 0; line-height: 1.3; }
.sb-user .who b { display: block; color: #fff; font-size: .9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sb-user .who span { font-size: .75rem; color: #9cc9ae; }
.sb-user a { color: #b9dcc7; display: grid; place-items: center; width: 34px; height: 34px; border-radius: 8px; }
.sb-user a:hover { background: rgba(255, 255, 255, .1); color: #fff; }
.sb-credit { margin-top: .7rem; font-size: .7rem; color: #6fa487; text-align: center; }

.topbar { display: none; }
.shell { margin-inline-start: var(--sbw); min-height: 100vh; padding: 1.4rem 2rem 2rem; }
.bottomnav { display: none; }

/* عنوان الصفحة */
.page-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .75rem; margin-bottom: 1.1rem; }
.page-head h1 { font-size: 1.4rem; margin: 0; }
.page-actions { display: flex; flex-wrap: wrap; gap: .5rem; }

/* الأوراق المنبثقة */
.sheet { position: fixed; inset: 0; z-index: 60; display: none; }
.sheet.open { display: block; }
.sheet-backdrop { position: absolute; inset: 0; background: rgba(10, 25, 17, .45); animation: fadeIn .18s; }
.sheet-panel {
  position: absolute; inset-inline: 0; bottom: 0; max-height: 88vh; overflow-y: auto; background: #fff;
  border-radius: 22px 22px 0 0; padding: .6rem 1.1rem calc(1.2rem + var(--safe-b)); box-shadow: var(--shadow-lg); animation: slideUp .22s ease-out;
}
.sheet-grip { width: 42px; height: 5px; border-radius: 9px; background: #d5ddd8; margin: .3rem auto .8rem; }
.sheet-title { display: flex; align-items: center; justify-content: space-between; font-weight: 800; font-size: 1.05rem; margin-bottom: .8rem; }
.sheet-close { border: 0; background: #f1f4f2; width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; cursor: pointer; color: var(--text); }
@media (min-width: 992px) {
  .sheet-panel { inset: auto; top: 50%; left: 50%; transform: translate(-50%, -50%); width: min(640px, 92vw); border-radius: 20px; padding: 1.2rem 1.4rem 1.4rem; animation: fadeIn .18s; }
  .sheet-grip { display: none; }
}
@keyframes slideUp { from { transform: translateY(40px); opacity: .4; } to { transform: none; opacity: 1; } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

/* شبكة الإجراءات السريعة */
.tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: .7rem; }
@media (min-width: 768px) { .tiles { grid-template-columns: repeat(4, 1fr); } }
@media (min-width: 1200px) { .tiles.wide { grid-template-columns: repeat(6, 1fr); } }
.tile {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .5rem; text-align: center;
  min-height: 98px; padding: .8rem .4rem; background: #fff; border: 1px solid var(--border); border-radius: 16px;
  color: var(--text); font-weight: 700; font-size: .88rem; line-height: 1.3; box-shadow: var(--shadow); transition: transform .1s, box-shadow .15s;
}
.tile:hover { text-decoration: none; color: var(--text); box-shadow: 0 8px 20px rgba(16, 32, 24, .1); transform: translateY(-1px); }
.tile .ti { display: grid; place-items: center; width: 46px; height: 46px; border-radius: 14px; background: var(--brand-50); color: var(--brand); }
.tile .ti .ico { width: 24px; height: 24px; }
.t-green .ti { background: #e1f3e8; color: #17723f; } .t-blue .ti { background: #e5eefc; color: #2b62c4; }
.t-amber .ti { background: #fff1cc; color: #a26b00; } .t-red .ti { background: #fde6e6; color: #c03434; }
.t-teal .ti { background: #dff3f2; color: #137a74; } .t-purple .ti { background: #efe8fb; color: #6b3fc0; }
.t-slate .ti { background: #edf0ee; color: #45544b; }
.sheet .tile { box-shadow: none; background: #f8faf9; }
.menu-group { font-size: .78rem; font-weight: 800; color: var(--muted); margin: 1rem 0 .5rem; }

/* بانر التثبيت */
.install-banner { display: flex; align-items: center; gap: .9rem; padding: .9rem 1rem; margin-bottom: 1rem; border-radius: var(--radius); color: #fff; background: linear-gradient(135deg, #1f7a4d, #2c9b63); box-shadow: var(--shadow); }
.install-banner .ico { width: 30px; height: 30px; }
.install-banner b { display: block; font-size: 1rem; }
.install-banner span { font-size: .84rem; opacity: .9; }
.install-banner .btn { background: #fff; color: var(--brand-700); margin-inline-start: auto; }
.install-banner .x { background: transparent; border: 0; color: #fff; opacity: .7; cursor: pointer; padding: .2rem; }

/* الترحيب ولوحة التحكم */
.hello { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; }
.hello h1 { font-size: 1.45rem; margin: 0; }
.hello .date { color: var(--muted); font-size: .88rem; }
.section-title { display: flex; align-items: center; justify-content: space-between; margin: 1.4rem 0 .7rem; font-weight: 800; font-size: 1.02rem; }
.section-title a { font-size: .85rem; font-weight: 600; }
.kpi { display: flex; flex-direction: row; align-items: center; gap: .75rem; padding: .85rem .9rem; }
.kpi .ki { display: grid; place-items: center; width: 42px; height: 42px; border-radius: 12px; flex-shrink: 0; }
.kpi .ki .ico { width: 22px; height: 22px; }
.kpi .label { color: var(--muted); font-size: .8rem; font-weight: 700; }
.kpi > div { min-width: 0; }
.kpi .value { font-size: 1.2rem; font-weight: 800; line-height: 1.3; }
@media (max-width: 575.98px) { .kpi { padding: .75rem .7rem; gap: .55rem; } .kpi .ki { width: 36px; height: 36px; } .kpi .value { font-size: 1rem; } .kpi .label { font-size: .74rem; } }
.alert-list { display: flex; flex-direction: column; gap: .5rem; }
.alert-item { display: flex; align-items: flex-start; gap: .6rem; padding: .7rem .9rem; border-radius: 12px; background: #fff; border: 1px solid var(--border); font-size: .9rem; }
.alert-item .dot { width: 10px; height: 10px; border-radius: 50%; margin-top: .45rem; flex-shrink: 0; }
.dot-danger { background: var(--danger); } .dot-warning { background: #e7a600; } .dot-info { background: var(--info); }
.cash-strip { display: flex; gap: .6rem; overflow-x: auto; padding-bottom: .2rem; margin-bottom: 1rem; scrollbar-width: none; }
.cash-strip .card { padding: .6rem .9rem; flex-shrink: 0; min-width: 150px; }
.cash-strip .card span { display: block; }

/* تسجيل الدخول */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 1.5rem 1rem; background: radial-gradient(circle at 20% 0%, #d7efe0 0, transparent 45%), radial-gradient(circle at 100% 100%, #e3f1e7 0, transparent 40%), var(--bg); }
.auth { align-content: center; }
.auth > * { width: 100%; max-width: 410px; }
.auth .card { width: 100%; max-width: 410px; border-radius: 22px; }
.auth .logo { width: 64px; height: 64px; border-radius: 18px; background: var(--brand); color: #fff; margin: 0 auto .8rem; }
.auth .logo .ico { width: 36px; height: 36px; }

/* ===================== الجوال ===================== */
@media (max-width: 991.98px) {
  .sidebar { display: none; }
  .shell { margin: 0; padding: .9rem .85rem calc(var(--bottom) + 1.4rem + var(--safe-b)); }
  .topbar {
    display: flex; align-items: center; gap: .6rem; position: sticky; top: 0; z-index: 30; height: 58px; padding: 0 .85rem;
    background: rgba(255, 255, 255, .96); backdrop-filter: blur(8px); border-bottom: 1px solid var(--border);
  }
  .topbar .logo { width: 36px; height: 36px; border-radius: 10px; background: var(--brand); color: #fff; }
  .topbar .logo .ico { width: 22px; height: 22px; }
  .topbar .title { flex: 1; min-width: 0; font-weight: 800; font-size: 1rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .topbar .tb-btn { display: inline-flex; align-items: center; gap: .3rem; height: 38px; padding: 0 .7rem; border-radius: 10px; border: 0; background: var(--brand-50); color: var(--brand-700); font: inherit; font-weight: 700; font-size: .85rem; cursor: pointer; }
  .bottomnav {
    display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; inset-inline: 0; bottom: 0; z-index: 50;
    height: calc(var(--bottom) + var(--safe-b)); padding-bottom: var(--safe-b);
    background: #fff; border-top: 1px solid var(--border); box-shadow: 0 -4px 16px rgba(16, 32, 24, .06);
  }
  .bn-item { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; color: #6f7f75; font-size: .72rem; font-weight: 700; background: none; border: 0; font-family: inherit; cursor: pointer; }
  .bn-item .ico { width: 23px; height: 23px; }
  .bn-item.active { color: var(--brand); }
  .bn-item:hover { text-decoration: none; }
  .bn-add { position: relative; }
  .bn-add .plus { display: grid; place-items: center; width: 56px; height: 56px; margin-top: -26px; border-radius: 50%; background: var(--brand); color: #fff; box-shadow: 0 6px 16px rgba(31, 122, 77, .4); border: 4px solid var(--bg); }
  .bn-add .plus .ico { width: 26px; height: 26px; }
  .page-head { margin-bottom: .9rem; }
  .page-head h1 { font-size: 1.2rem; width: 100%; }
  .page-actions { flex-wrap: nowrap; overflow-x: auto; width: 100%; padding-bottom: 2px; scrollbar-width: none; }
  .page-actions::-webkit-scrollbar { display: none; }
  .form-control, .form-select { font-size: 16px; }
  .card-body, .card.card-body { padding: .95rem; }
  .doc { padding: 1rem; }
  .stat .value { font-size: 1.12rem; }
  .filter-toggle { display: inline-flex; margin-bottom: .7rem; }
  .filters.collapsible:not(.open) { display: none; }
  /* أزرار الحفظ ثابتة أسفل الشاشة */
  .form-actions {
    position: sticky; bottom: calc(var(--bottom) + var(--safe-b)); z-index: 20; margin: 1rem -.95rem -.95rem !important; padding: .7rem .95rem;
    background: rgba(255, 255, 255, .97); border-top: 1px solid var(--border); border-radius: 0 0 var(--radius) var(--radius);
  }
  .form-actions .btn { flex: 1 1 0; }
  /* الجداول كبطاقات */
  .table.cards thead { display: none; }
  .table.cards, .table.cards tbody, .table.cards tfoot, .table.cards tr, .table.cards td, .table.cards th { display: block; width: 100%; }
  .table.cards tr {
    display: grid; grid-template-columns: 1fr 1fr; column-gap: .4rem; row-gap: .1rem;
    background: #fff; border: 1px solid var(--border); border-radius: 14px; margin-bottom: .6rem; padding: .5rem .2rem; box-shadow: var(--shadow);
  }
  .table.cards td, .table.cards th { display: block; min-width: 0; border: 0 !important; padding: .25rem .75rem; text-align: start; background: transparent; overflow-wrap: anywhere; }
  .table.cards td::before, .table.cards th::before { content: attr(data-label); display: block; color: var(--muted); font-size: .74rem; font-weight: 700; line-height: 1.3; }
  .table.cards td:first-child { grid-column: 1 / -1; font-size: 1.02rem; font-weight: 800; padding-top: .35rem; }
  .table.cards td.no-print, .table.cards td[data-label=""], .table.cards th[data-label=""] { grid-column: 1 / -1; }
  .table.cards td.no-print { display: flex; flex-wrap: wrap; gap: .4rem 1rem; padding-top: .45rem; margin-top: .2rem; border-top: 1px dashed var(--border) !important; }
  .table.cards td.no-print:empty, .table.cards td.no-print:not(:has(*)) { display: none; }
  .table.cards td:first-child::before, .table.cards [data-label=""]::before, .table.cards td:not([data-label])::before { display: none; }
  .table.cards td:empty { display: none; }
  .table.cards tfoot tr { background: var(--brand-50); }
  .table.cards tr.table-light { background: #f6f8f7; }
  .card:has(> .table-responsive > .table.cards), .card:has(> .table.cards) { background: transparent; border: 0; box-shadow: none; }
  .card:has(> .table-responsive > .table.cards) > .card-header { padding-inline: .2rem; border: 0; }
}

@media (max-width: 575.98px) {
  .tiles { gap: .55rem; }
  .tile { min-height: 92px; font-size: .82rem; }
}

/* ===================== الطباعة ===================== */
@media print {
  .no-print, .sidebar, .topbar, .bottomnav, .sheet, .btn, .alert, .filters, .filter-toggle, .install-banner, footer { display: none !important; }
  body { background: #fff; }
  .shell { margin: 0; padding: 0; }
  .card { box-shadow: none; }
  .doc { padding: 0; max-width: none; border: 0; }
  a { color: inherit; text-decoration: none; }
  @page { size: A4; margin: 12mm; }
}

/* قائمة ربح الحقول في لوحة التحكم */
.plist .list-group-item { display: flex; align-items: center; gap: .7rem; }
.plist .nm { flex: 1; min-width: 0; }
.plist .nm b { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.plist .nm small { color: var(--muted); }
.plist .pv { text-align: end; font-weight: 800; }
.plist .total { background: var(--brand-50); font-weight: 800; }
.att-table td { padding: .4rem .45rem; }
.att-table .form-select-sm, .att-table .form-control-sm { min-height: 36px; padding-inline: .45rem; }
.att-table .form-select-sm { padding-inline-end: 1.7rem; background-position: left .45rem center; }
