/* ==========================================================================
   رسوخ العمرانية — app.css
   المكونات، الجداول، الكانبان، النماذج، الرسوم البيانية، الطباعة
   ========================================================================== */

/* -------------------------------- مساعدات -------------------------------- */
.row { display: flex; align-items: center; gap: 10px; }
.row.between { justify-content: space-between; }
.row.wrap { flex-wrap: wrap; }
.col { display: flex; flex-direction: column; gap: 8px; }
.grid { display: grid; gap: 14px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.g2-1 { grid-template-columns: 2fr 1fr; }
.g1-2 { grid-template-columns: 1fr 2fr; }
.muted { color: var(--muted); }
.tiny { font-size: 11.5px; }
.small { font-size: 12.5px; }
.center { text-align: center; }
.pad { padding: 22px; }
.mt { margin-top: 14px; }
.mt-sm { margin-top: 8px; }
.mb { margin-bottom: 14px; }
.nowrap { white-space: nowrap; }
.num { font-variant-numeric: tabular-nums; letter-spacing: .2px; }
.divider { height: 1px; background: var(--line); margin: 12px 0; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-inline-start: auto; }
.section-head { display: flex; align-items: center; gap: 10px; margin: 20px 0 12px; }
.section-head h2 { font-size: 16px; }
.section-head .page-actions { margin-inline-start: auto; }

/* --------------------------------- أزرار --------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  border: 1px solid transparent; border-radius: 11px;
  padding: 9px 15px; cursor: pointer; font-weight: 600; font-size: 13.5px;
  transition: transform .14s, box-shadow .16s, background .16s, border-color .16s;
  white-space: nowrap;
}
.btn:active { transform: translateY(1px) scale(.99); }
.btn-primary { background: linear-gradient(180deg, var(--brand-2), var(--brand)); color: #fff; box-shadow: 0 6px 16px -10px rgba(11, 107, 69, .9); }
.btn-primary:hover { filter: brightness(1.06); }
.btn-ghost { background: #fff; border-color: var(--line); color: var(--text-2); }
.btn-ghost:hover { background: var(--line-soft); }
.btn-danger { background: #fff; border-color: #f6c9c9; color: var(--danger); }
.btn-danger:hover { background: #fef2f2; }
.btn-gold { background: linear-gradient(180deg, #e0be4a, var(--gold)); color: #2b2100; }
.btn-sm { padding: 6px 11px; font-size: 12.5px; border-radius: 9px; }
.btn-block { width: 100%; }
.btn:disabled { opacity: .55; cursor: not-allowed; }

/* --------------------------------- بطاقات --------------------------------- */
.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden;
}
.card-head {
  display: flex; align-items: center; gap: 8px;
  padding: 13px 16px; border-bottom: 1px solid var(--line-soft); background: #fcfefd;
}
.card-head h3 { font-size: 14.5px; flex: 1; }
.card-body { padding: 16px; }
.card-body.flush { padding: 0; }
.card-foot { padding: 11px 16px; border-top: 1px solid var(--line-soft); background: #fcfefd; font-size: 12.5px; color: var(--muted); }

/* ---------------------------------- KPI ---------------------------------- */
.kpi {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 15px; box-shadow: var(--shadow); position: relative; overflow: hidden;
  display: flex; flex-direction: column; gap: 3px;
}
.kpi[role="button"] { cursor: pointer; transition: transform .16s, box-shadow .16s; }
.kpi[role="button"]:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.kpi::after {
  content: ''; position: absolute; inset-inline-start: 0; top: 0; bottom: 0; width: 4px;
  background: var(--brand); opacity: .9;
}
.kpi-gold::after { background: var(--gold); }
.kpi-info::after { background: var(--info); }
.kpi-violet::after { background: var(--violet); }
.kpi-danger::after { background: var(--danger); }
.kpi-top { display: flex; align-items: center; justify-content: space-between; }
.kpi-ico {
  width: 36px; height: 36px; border-radius: 11px; display: grid; place-items: center;
  background: var(--line-soft); font-size: 17px;
}
.kpi-value { font-size: 22px; letter-spacing: -.4px; font-variant-numeric: tabular-nums; }
.kpi-label { color: var(--muted); font-size: 12.5px; }
.kpi-sub { color: var(--muted-2); font-size: 11.5px; }
.kpi-trend { font-size: 11.5px; font-weight: 700; padding: 2px 7px; border-radius: 20px; }
.kpi-trend.up { color: #15803d; background: #dcfce7; }
.kpi-trend.down { color: #b91c1c; background: #fee2e2; }

/* ---------------------------- شارات وصور رمزية ---------------------------- */
.pill {
  display: inline-flex; align-items: center; gap: 5px;
  background: color-mix(in srgb, var(--pill) 13%, #fff);
  color: color-mix(in srgb, var(--pill) 82%, #000);
  border: 1px solid color-mix(in srgb, var(--pill) 30%, #fff);
  border-radius: 20px; padding: 2px 10px; font-size: 11.5px; font-weight: 600; white-space: nowrap;
}
.pill::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: var(--pill); }
.avatar {
  width: 34px; height: 34px; border-radius: 50%; flex: 0 0 auto;
  background: var(--av, var(--brand)); color: #fff;
  display: grid; place-items: center; font-weight: 700; font-size: 12.5px;
}
.avatar.sm { width: 26px; height: 26px; font-size: 10.5px; }
.tag {
  background: var(--line-soft); border: 1px solid var(--line); color: var(--text-2);
  border-radius: 8px; padding: 2px 8px; font-size: 11.5px; display: inline-block;
}
.tag.gold { background: var(--gold-soft); border-color: #ecd9a0; color: #7a5c00; }
.badge-count {
  background: var(--brand); color: #fff; border-radius: 20px;
  font-size: 11px; padding: 1px 8px; font-weight: 700;
}
.progress-wrap { display: flex; align-items: center; gap: 8px; }
.progress { flex: 1; height: 7px; border-radius: 20px; background: var(--line-soft); overflow: hidden; min-width: 60px; }
.progress i { display: block; height: 100%; border-radius: 20px; transition: width .4s ease; }
.progress-wrap small { color: var(--muted); font-size: 11.5px; min-width: 34px; text-align: end; }

/* --------------------------------- جداول --------------------------------- */
.table-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
table.tbl th {
  text-align: start; font-weight: 700; color: var(--muted); font-size: 12px;
  padding: 10px 12px; background: #fafcfb; border-bottom: 1px solid var(--line);
  white-space: nowrap; position: sticky; top: 0; z-index: 1;
}
table.tbl td { padding: 10px 12px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
table.tbl tbody tr:hover { background: #fafdfb; }
table.tbl tr.clickable { cursor: pointer; }
table.tbl .num { text-align: start; font-variant-numeric: tabular-nums; }
table.tbl td.actions { text-align: end; white-space: nowrap; }
.mini-btn {
  border: 1px solid var(--line); background: #fff; border-radius: 8px;
  width: 29px; height: 29px; cursor: pointer; display: inline-grid; place-items: center;
  font-size: 13px; margin-inline-start: 4px; transition: background .15s;
}
.mini-btn:hover { background: var(--line-soft); }
.mini-btn.danger:hover { background: #fef2f2; border-color: #f6c9c9; }
.cell-main { display: flex; align-items: center; gap: 9px; min-width: 0; }
.cell-main .cm-text { min-width: 0; }
.cell-main b { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 240px; }
.cell-main small { color: var(--muted); font-size: 11.5px; display: block; }

/* ----------------------------- شريط أدوات ----------------------------- */
.toolbar {
  display: flex; align-items: center; gap: 9px; flex-wrap: wrap;
  margin-bottom: 14px;
}
.toolbar .input, .toolbar select {
  padding: 9px 12px; border: 1px solid var(--line); border-radius: 11px; background: #fff;
}
.toolbar .input:focus, .toolbar select:focus { outline: none; border-color: var(--brand-2); box-shadow: 0 0 0 3px rgba(15, 138, 88, .12); }
.toolbar .search-inline { position: relative; flex: 1; min-width: 190px; max-width: 340px; }
.toolbar .search-inline input { width: 100%; padding-inline-start: 34px; }
.toolbar .search-inline span { position: absolute; inset-inline-start: 11px; top: 50%; transform: translateY(-50%); color: var(--muted-2); }
.tabs { display: inline-flex; background: var(--line-soft); border: 1px solid var(--line); border-radius: 12px; padding: 3px; gap: 2px; }
.tab {
  border: 0; background: none; cursor: pointer; padding: 7px 14px; border-radius: 9px;
  font-size: 13px; color: var(--text-2); font-weight: 600;
}
.tab.active { background: #fff; color: var(--brand); box-shadow: var(--shadow); }
.chip-filters { display: flex; gap: 6px; flex-wrap: wrap; }
.chip-filter {
  border: 1px solid var(--line); background: #fff; border-radius: 20px;
  padding: 5px 12px; font-size: 12.5px; cursor: pointer; color: var(--text-2);
}
.chip-filter.active { background: var(--brand); border-color: var(--brand); color: #fff; }

/* --------------------------------- حالات --------------------------------- */
.empty { text-align: center; padding: 44px 20px; color: var(--muted); }
.empty-ico { font-size: 40px; opacity: .7; }
.empty h4 { margin: 8px 0 4px; color: var(--text); }
.empty p { font-size: 13px; margin-bottom: 14px; }

/* --------------------------------- نماذج --------------------------------- */
.form-grid { display: grid; gap: 13px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form-grid.cols-1 { grid-template-columns: 1fr; }
.form-grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field.span-2 { grid-column: span 2; }
.field.span-3 { grid-column: 1 / -1; }
.field-label { font-size: 12.5px; color: var(--text-2); font-weight: 600; }
.field-label .req { color: var(--danger); }
.field input[type="text"], .field input[type="number"], .field input[type="tel"],
.field input[type="email"], .field input[type="date"], .field input[type="time"],
.field select, .field textarea {
  width: 100%; padding: 9px 12px; border: 1px solid var(--line); border-radius: 10px;
  background: #fbfdfc; transition: border-color .16s, box-shadow .16s;
}
.field textarea { resize: vertical; line-height: 1.6; }
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none; border-color: var(--brand-2); background: #fff; box-shadow: 0 0 0 3px rgba(15, 138, 88, .12);
}
.field .hint { color: var(--muted-2); font-size: 11px; }
.field-error { color: var(--danger); font-size: 11px; min-height: 0; }
.field.has-error input, .field.has-error select, .field.has-error textarea { border-color: var(--danger); background: #fff7f7; }
.static-val { padding: 9px 12px; background: var(--line-soft); border-radius: 10px; font-size: 13px; }
.field-switch { justify-content: flex-end; }
.switch { display: inline-flex; align-items: center; gap: 9px; cursor: pointer; }
.switch input { display: none; }
.switch .slider {
  width: 42px; height: 23px; border-radius: 20px; background: #cbd5d1; position: relative; transition: background .2s;
}
.switch .slider::after {
  content: ''; position: absolute; top: 2.5px; inset-inline-start: 3px; width: 18px; height: 18px;
  border-radius: 50%; background: #fff; transition: inset-inline-start .2s;
}
.switch input:checked + .slider { background: var(--brand); }
.switch input:checked + .slider::after { inset-inline-start: 21px; }
.switch b { font-size: 12.5px; color: var(--text-2); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; max-height: 150px; overflow: auto; padding: 3px; }
.chip {
  border: 1px solid var(--line); background: #fbfdfc; border-radius: 20px;
  padding: 4px 11px; font-size: 12px; cursor: pointer; user-select: none;
}
.chip input { display: none; }
.chip.on { background: var(--brand); border-color: var(--brand); color: #fff; }
.form-foot { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; }

/* ------------------------------ نوافذ وتنبيهات ------------------------------ */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 100; background: rgba(7, 42, 30, .5);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 4vh 16px; overflow-y: auto; opacity: 0; transition: opacity .2s;
  backdrop-filter: blur(2px);
}
.modal-backdrop.in { opacity: 1; }
.modal {
  background: #fff; border-radius: var(--radius-lg); width: 100%; max-width: 660px;
  box-shadow: var(--shadow-lg); transform: translateY(14px) scale(.99); transition: transform .22s;
  overflow: hidden; margin-bottom: 4vh;
}
.modal-backdrop.in .modal { transform: none; }
.modal-sm { max-width: 420px; }
.modal-lg { max-width: 780px; }
.modal-xl { max-width: 1020px; }
.modal-head {
  display: flex; align-items: center; gap: 10px; padding: 15px 20px;
  border-bottom: 1px solid var(--line); background: linear-gradient(180deg, #fbfdfc, #fff);
  position: sticky; top: 0; z-index: 2;
}
.modal-head h3 { flex: 1; font-size: 15.5px; }
.modal-body { padding: 18px 20px; max-height: 74vh; overflow-y: auto; }
.modal-foot {
  display: flex; gap: 9px; justify-content: flex-end; padding: 13px 20px;
  border-top: 1px solid var(--line); background: #fcfefd;
}
.confirm-text { font-size: 14px; color: var(--text-2); margin: 0; }

.toasts { position: fixed; inset-block-end: 20px; inset-inline-start: 20px; z-index: 200; display: flex; flex-direction: column; gap: 9px; }
.toast {
  display: flex; align-items: center; gap: 10px;
  background: #fff; border: 1px solid var(--line); border-inline-start: 4px solid var(--brand);
  border-radius: 12px; padding: 11px 15px; box-shadow: var(--shadow-lg);
  min-width: 260px; max-width: 400px; font-size: 13.5px;
  animation: toastIn .26s ease;
}
@keyframes toastIn { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
.toast.out { opacity: 0; transform: translateY(8px); transition: all .3s; }
.toast-success { border-inline-start-color: var(--ok); }
.toast-error { border-inline-start-color: var(--danger); }
.toast-warn { border-inline-start-color: var(--warn); }
.toast-info { border-inline-start-color: var(--info); }

/* -------------------------------- كانبان -------------------------------- */
.kanban { display: flex; gap: 13px; overflow-x: auto; padding-bottom: 12px; align-items: flex-start; }
.kcol {
  flex: 0 0 268px; background: #eef2f7; border: 1px solid var(--line);
  border-radius: var(--radius); display: flex; flex-direction: column; max-height: calc(100vh - 240px);
}
.kcol.drag-over { background: #e2ecf5; border-color: var(--brand-2); box-shadow: inset 0 0 0 2px rgba(15, 138, 88, .2); }
.kcol-head {
  display: flex; align-items: center; gap: 8px; padding: 11px 13px;
  border-bottom: 2px solid var(--line); border-radius: var(--radius) var(--radius) 0 0;
}
.kcol-head .kc-dot { width: 9px; height: 9px; border-radius: 50%; }
.kcol-head b { font-size: 13px; flex: 1; }
.kcol-head .kc-count { background: #fff; border: 1px solid var(--line); border-radius: 20px; font-size: 11px; padding: 0 7px; }
.kcol-head .kc-sum { font-size: 11px; color: var(--muted); }
.kcol-body { padding: 9px; display: flex; flex-direction: column; gap: 8px; overflow-y: auto; min-height: 90px; }
.kcard {
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 11px; cursor: grab; box-shadow: 0 1px 2px rgba(11, 61, 44, .05);
  border-inline-start: 3px solid var(--line);
}
.kcard:hover { box-shadow: var(--shadow); }
.kcard.dragging { opacity: .45; }
.kcard.pri-high { border-inline-start-color: var(--danger); }
.kcard.pri-normal { border-inline-start-color: var(--info); }
.kcard.pri-low { border-inline-start-color: var(--muted-2); }
.kcard-top { display: flex; align-items: flex-start; gap: 8px; }
.kcard-title { font-size: 13.5px; font-weight: 700; flex: 1; line-height: 1.45; }
.kcard-meta { display: flex; flex-direction: column; gap: 3px; margin-top: 7px; color: var(--muted); font-size: 11.5px; }
.kcard-meta span { display: flex; align-items: center; gap: 5px; }
.kcard-foot { display: flex; align-items: center; gap: 7px; margin-top: 9px; padding-top: 8px; border-top: 1px dashed var(--line); }
.kcard-foot .p-num { margin-inline-start: auto; font-weight: 700; font-size: 12.5px; color: var(--brand-dark); }

/* ------------------------------ بطاقات العقار ------------------------------ */
.prop-grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(268px, 1fr)); }
.prop-card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  overflow: hidden; box-shadow: var(--shadow); display: flex; flex-direction: column;
  transition: transform .18s, box-shadow .18s;
}
.prop-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); }
.prop-media {
  height: 108px; position: relative;
  background: linear-gradient(135deg, #122f47, #2a6ba8);
  display: grid; place-items: center; font-size: 40px; color: rgba(255, 255, 255, .9);
}
.prop-media.t-land_res, .prop-media.t-land_com { background: linear-gradient(135deg, #7c5a12, #c9a227); }
.prop-media.t-office, .prop-media.t-shop { background: linear-gradient(135deg, #123c63, #0284c7); }
.prop-media.t-chalet, .prop-media.t-resthouse { background: linear-gradient(135deg, #0d5c56, #0d9488); }
.prop-media.t-building, .prop-media.t-warehouse { background: linear-gradient(135deg, #3f2a63, #7c3aed); }
.prop-badges { position: absolute; top: 9px; inset-inline-start: 9px; display: flex; gap: 6px; flex-wrap: wrap; }
.prop-ref {
  position: absolute; top: 9px; inset-inline-end: 9px;
  background: rgba(0, 0, 0, .42); color: #fff; border-radius: 7px;
  padding: 2px 8px; font-size: 11px; letter-spacing: .4px;
}
.prop-purpose {
  position: absolute; bottom: 0; inset-inline-start: 0;
  background: rgba(255, 255, 255, .94); color: var(--brand-dark);
  border-start-end-radius: 10px; padding: 3px 12px; font-size: 11.5px; font-weight: 700;
}
.prop-body { padding: 13px; display: flex; flex-direction: column; gap: 8px; flex: 1; }
.prop-title { font-size: 14px; font-weight: 700; line-height: 1.5; }
.prop-loc { color: var(--muted); font-size: 12px; display: flex; align-items: center; gap: 5px; }
.prop-specs { display: flex; gap: 10px; flex-wrap: wrap; color: var(--text-2); font-size: 12px; }
.prop-specs span { display: flex; align-items: center; gap: 4px; }
.prop-price { display: flex; align-items: baseline; gap: 8px; margin-top: auto; }
.prop-price b { font-size: 17px; color: var(--brand-dark); font-variant-numeric: tabular-nums; }
.prop-price small { color: var(--muted); font-size: 11.5px; }
.prop-actions { display: flex; gap: 6px; padding: 0 13px 13px; }

/* -------------------------------- الجدول الزمني -------------------------------- */
.timeline { position: relative; padding-inline-start: 20px; }
.timeline::before {
  content: ''; position: absolute; inset-inline-start: 6px; top: 6px; bottom: 6px;
  width: 2px; background: var(--line);
}
.tl-item { position: relative; padding: 0 0 14px; }
.tl-dot {
  position: absolute; inset-inline-start: -20px; top: 4px; width: 14px; height: 14px;
  border-radius: 50%; background: #fff; border: 3px solid var(--brand); box-sizing: border-box;
}
.tl-dot.call { border-color: var(--info); }
.tl-dot.payment { border-color: var(--ok); }
.tl-dot.stage { border-color: var(--gold); }
.tl-dot.note { border-color: var(--muted-2); }
.tl-body { font-size: 13px; }
.tl-time { color: var(--muted-2); font-size: 11.5px; }
.tl-actor { font-weight: 700; color: var(--brand-dark); }

/* ---------------------------- صفوف تفاصيل وصفقات ---------------------------- */
.drow { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-bottom: 1px dashed var(--line-soft); font-size: 13px; }
.drow:last-child { border-bottom: 0; }
.drow > span { color: var(--muted); }
.drow > b { font-weight: 700; text-align: end; }
.stat-line { display: flex; gap: 12px; flex-wrap: wrap; }
.stat-box {
  flex: 1; min-width: 132px; background: #fbfdfc; border: 1px solid var(--line);
  border-radius: var(--radius-sm); padding: 11px 13px;
}
.stat-box small { color: var(--muted); font-size: 11.5px; display: block; }
.stat-box b { font-size: 16px; font-variant-numeric: tabular-nums; }
.stat-box.gold { background: var(--gold-soft); border-color: #ecd9a0; }
.stat-box.green { background: #eef4fa; border-color: #cfe0ef; }
.pay-row { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--line-soft); font-size: 12.5px; }
.pay-row .pay-label { flex: 1; }
.pay-row .pay-amt { font-weight: 700; font-variant-numeric: tabular-nums; }
.pay-paid { color: var(--ok); }
.pay-due { color: var(--warn); }

/* -------------------------------- رسوم بيانية -------------------------------- */
.hbars { display: flex; flex-direction: column; gap: 10px; }
.hbar { display: grid; grid-template-columns: 108px 1fr auto; gap: 10px; align-items: center; font-size: 12.5px; }
.hbar-label { color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hbar-track { background: var(--line-soft); border-radius: 20px; height: 11px; overflow: hidden; }
.hbar-track i { display: block; height: 100%; border-radius: 20px; transition: width .5s ease; }
.hbar-val { font-variant-numeric: tabular-nums; color: var(--text-2); font-size: 12px; }
.chart-line { width: 100%; height: auto; }
.chart-line .grid-line { stroke: var(--line-soft); stroke-width: 1; }
.chart-line .axis-label { fill: var(--muted-2); font-size: 11px; font-family: var(--font); }
.chart-line .dot { fill: #fff; stroke: var(--brand); stroke-width: 2.5; }
.donut-wrap { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.chart-donut { width: 176px; height: 176px; flex: 0 0 auto; }
.donut-total { font-size: 17px; font-weight: 700; fill: var(--text); font-family: var(--font); }
.donut-sub { font-size: 10.5px; fill: var(--muted); font-family: var(--font); }
.donut-legend { flex: 1; min-width: 150px; display: flex; flex-direction: column; gap: 6px; font-size: 12.5px; }
.donut-legend li { display: flex; align-items: center; gap: 8px; }
.donut-legend i { width: 10px; height: 10px; border-radius: 3px; flex: 0 0 10px; }
.donut-legend span { flex: 1; color: var(--text-2); }
.donut-legend b { font-variant-numeric: tabular-nums; }
.funnel { display: flex; flex-direction: column; gap: 9px; }
.funnel-row { display: grid; grid-template-columns: 92px 1fr auto; gap: 10px; align-items: center; font-size: 12.5px; }
.funnel-label { color: var(--text-2); }
.funnel-bar-wrap { background: var(--line-soft); border-radius: 8px; overflow: hidden; }
.funnel-bar {
  color: #fff; font-size: 11.5px; font-weight: 700; padding: 4px 10px;
  border-radius: 8px; min-width: 34px; text-align: center; transition: width .5s ease;
}
.funnel-val { color: var(--muted); font-size: 11.5px; }
.spark { width: 74px; height: 26px; }

/* ------------------------------ تفاصيل إضافية ------------------------------ */
.lead-brief { display: flex; gap: 12px; align-items: center; }
.lead-brief .lb-main { flex: 1; min-width: 0; }
.contact-row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.contact-btn {
  display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line);
  background: #fff; border-radius: 10px; padding: 7px 12px; font-size: 12.5px; cursor: pointer; color: var(--text-2);
}
.contact-btn:hover { background: var(--line-soft); }
.contact-btn.wa { border-color: #bfe6cd; background: #f2fbf5; color: #128c47; }
.msg-preview {
  background: #f2fbf5; border: 1px solid #cbe9da; border-radius: 12px; padding: 13px;
  white-space: pre-wrap; font-size: 13px; line-height: 1.9; max-height: 300px; overflow: auto;
}
.contract-doc, .invoice-doc {
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 26px;
  font-size: 13.5px;
}
.doc-head { display: flex; justify-content: space-between; gap: 20px; border-bottom: 2px solid var(--brand-dark); padding-bottom: 14px; margin-bottom: 16px; }
.doc-head h2 { font-size: 19px; color: var(--brand-dark); }
.doc-head .doc-meta { font-size: 12px; color: var(--muted); text-align: end; }
.doc-logo { display: flex; flex-direction: column; align-items: flex-start; gap: 9px; max-width: 64%; }
.doc-logo-img { display: block; height: 64px; width: auto; max-width: 100%; }
.doc-logo-info b { display: block; font-size: 13px; color: var(--brand-dark); }
.doc-logo-info small { display: block; color: var(--muted); font-size: 11px; line-height: 1.7; }
.doc-logo .dl-mark {
  width: 46px; height: 46px; border-radius: 12px; background: var(--brand-dark); color: var(--gold);
  display: grid; place-items: center; font-size: 22px; font-weight: 800;
}
.doc-logo h2 { font-size: 16px; }
.doc-sec { margin: 16px 0; }
.doc-sec h4 { font-size: 13.5px; color: var(--brand); margin-bottom: 7px; }
.doc-table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.doc-table th, .doc-table td { border: 1px solid var(--line); padding: 7px 10px; text-align: start; }
.doc-table th { background: var(--line-soft); }
.doc-table td.amt, .doc-table th.amt { text-align: end; font-variant-numeric: tabular-nums; }
.doc-sign { display: flex; gap: 30px; margin-top: 34px; }
.doc-sign div { flex: 1; border-top: 1px dashed var(--muted-2); padding-top: 8px; font-size: 12px; color: var(--muted); text-align: center; }
.doc-note { background: var(--gold-soft); border: 1px solid #ecd9a0; border-radius: 10px; padding: 11px 13px; font-size: 12px; }
.doc-foot { margin-top: 18px; border-top: 1px solid var(--line); padding-top: 11px; font-size: 11px; color: var(--muted); text-align: center; }
.doc-qr { text-align: center; }
.doc-qr small { display: block; margin-top: 5px; font-size: 9.5px; color: var(--muted); }
.doc-qr svg { width: 100%; height: auto; }
.qr-box { width: 118px; height: 118px; border: 1px dashed var(--muted-2); border-radius: 10px; display: grid; place-items: center; font-size: 10px; color: var(--muted); padding: 6px; text-align: center; }
/* صندوق بيانات الفاتورة بترميز TLV (يُدرج كرمز QR في الأنظمة المتوافقة) */
.tlv-box { width: 252px; border: 1px dashed var(--muted-2); border-radius: 10px; padding: 10px 11px; background: #fbfdfc; }
.tlv-box b { display: block; font-size: 10.5px; color: var(--brand-dark); margin-bottom: 5px; }
.tlv-box code {
  display: block; font-family: ui-monospace, Consolas, monospace; font-size: 8.5px;
  line-height: 1.6; word-break: break-all; max-height: 130px; overflow: hidden;
  direction: ltr; text-align: left; color: var(--muted);
}
.tlv-box small { display: block; margin-top: 6px; font-size: 9.5px; color: var(--muted-2); }

/* --------------------------------- الطباعة --------------------------------- */
.print-root { display: none; }
@media print {
  @page { size: A4; margin: 12mm; }
  body { background: #fff; }
  .app-shell, .toasts, .modal-backdrop, .scrim { display: none !important; }
  .print-root { display: block !important; }
  .contract-doc, .invoice-doc { border: 0; padding: 0; }
  .no-print { display: none !important; }
}

/* -------------------------------- استجابة -------------------------------- */
@media (max-width: 1180px) {
  .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .g2-1, .g1-2 { grid-template-columns: 1fr; }
}
@media (max-width: 900px) {
  .g2, .g3 { grid-template-columns: 1fr; }
  .form-grid, .form-grid.cols-3 { grid-template-columns: 1fr; }
  .field.span-2, .field.span-3 { grid-column: auto; }
  .modal-body { max-height: 80vh; }
}
@media (max-width: 620px) {
  .g4 { grid-template-columns: 1fr; }
  .kanban { scroll-snap-type: x mandatory; }
  .kcol { flex-basis: 84vw; scroll-snap-align: start; }
  .toasts { inset-inline: 12px; }
  .toast { min-width: auto; }
}

/* ------------------------- لوحة موافقة التتبع (PDPL) ------------------------- */
.consent-bar {
  position: fixed; inset-block-end: 16px; inset-inline: 50%; transform: translate(50%, 140%);
  width: min(760px, calc(100vw - 28px)); z-index: 150;
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow-lg); padding: 14px 16px;
  display: flex; gap: 14px; align-items: center; flex-wrap: wrap;
  transition: transform .32s ease, opacity .32s; opacity: 0;
}
.consent-bar.in { transform: translate(50%, 0); opacity: 1; }
.consent-text { flex: 1; min-width: 240px; }
.consent-text b { font-size: 13.5px; }
.consent-text p { margin: 4px 0 0; font-size: 12px; color: var(--muted); line-height: 1.75; }
.consent-actions { display: flex; gap: 8px; }
@media (max-width: 620px) {
  .consent-bar { inset-inline: 12px; transform: translate(0, 140%); }
  .consent-bar.in { transform: none; }
}
/* ===================== نافذة استيراد العملاء من جدول ===================== */
.imp-steps { display: flex; gap: 8px; margin-bottom: 14px; flex-wrap: wrap; }
.imp-step {
  font-size: 12px; padding: 5px 12px; border-radius: 999px; background: #f1f5f9; color: var(--muted);
  border: 1px solid var(--line); font-weight: 600;
}
.imp-step.active { background: var(--brand); color: #fff; border-color: var(--brand); }
.imp-drop {
  border: 2px dashed var(--line); border-radius: 14px; padding: 26px 16px; text-align: center;
  background: #fbfdfc; transition: border-color .15s, background .15s;
}
.imp-drop.over { border-color: var(--brand); background: #eef4fa; }
.imp-drop b { display: block; margin: 6px 0 3px; font-size: 14px; }
.imp-drop small { display: block; font-size: 11.5px; }
.imp-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 10px; }
.imp-field { display: flex; flex-direction: column; gap: 4px; }
.imp-field > span { font-size: 12px; font-weight: 600; color: var(--text-2); }
.imp-field select {
  padding: 7px 9px; border: 1px solid var(--line); border-radius: 9px; background: #fff; font-size: 12.5px;
  font-family: inherit; color: var(--text);
}
.imp-options { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 10px; margin-top: 12px; }
.imp-mode { margin-top: 12px; padding: 11px 13px; border: 1px solid var(--line); border-radius: 12px; background: #fbfdfc; display: flex; flex-direction: column; gap: 7px; }
.imp-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 9px; margin: 12px 0; }
.imp-stat { border: 1px solid var(--line); border-radius: 11px; padding: 9px; text-align: center; background: #fff; }
.imp-stat b { display: block; font-size: 19px; color: var(--brand-dark); }
.imp-stat span { font-size: 11px; color: var(--muted); }
.imp-stat.ok { border-color: #bfe6cd; background: #f2fbf5; }
.imp-stat.dup { border-color: #ecd9a0; background: #fdf9ee; }
.imp-stat.bad { border-color: #f6c9c9; background: #fff7f7; }
@media (max-width: 700px) { .imp-stats { grid-template-columns: repeat(2, 1fr); } }

/* ===================== المستخدمون وبوابة الدخول ===================== */
body.locked .app-shell, body.locked .sidebar, body.locked .topbar { display: none !important; }
#loginGate {
  position: fixed; inset: 0; z-index: 3000; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(160deg, #0f2438 0%, #122f47 55%, #0a1c2b 100%); padding: 22px; overflow: auto;
}
.login-card {
  background: #fff; border-radius: 18px; padding: 30px 28px; width: 100%; max-width: 420px;
  box-shadow: 0 30px 70px -22px rgba(0, 0, 0, .55); text-align: center;
}
.login-brand { display: flex; justify-content: center; margin-bottom: 12px; }
.login-logo { height: 74px; width: auto; }
.login-card h1 { font-size: 19px; color: var(--brand-dark); margin: 0 0 3px; }
.login-form { text-align: start; margin-top: 16px; }
.login-form .input { width: 100%; }
.login-msg { background: #fff7e6; border: 1px solid #ecd9a0; color: #7a5c00; border-radius: 10px; padding: 8px 11px; font-size: 12px; margin-top: 10px; }
.login-err { background: #fef2f2; border: 1px solid #f6c9c9; color: #b91c1c; border-radius: 10px; padding: 8px 11px; font-size: 12.5px; margin-top: 10px; }
.login-users { margin-top: 16px; padding-top: 14px; border-top: 1px dashed var(--line); }
.user-chip {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  background: rgba(255, 255, 255, .07); border-radius: 11px; padding: 8px 10px; margin-bottom: 9px;
}
.uc-main { display: flex; align-items: center; gap: 8px; min-width: 0; }
.uc-avatar {
  width: 28px; height: 28px; border-radius: 9px; color: #fff; font-weight: 700; font-size: 13px;
  display: flex; align-items: center; justify-content: center; flex: 0 0 28px;
}
.uc-text { min-width: 0; }
.uc-text b { display: block; color: #fff; font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.uc-text small { display: block; color: #9db4c8; font-size: 10.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-chip .mini-btn { background: rgba(255, 255, 255, .12); color: #e9eef5; }
.denied { text-align: center; padding: 34px 18px; }
.denied h3 { margin: 8px 0 6px; }
.dot-color { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-inline-end: 6px; }
.perm-matrix th.center, .perm-matrix td.center { text-align: center; }
.perm-group td { background: #eef3f8; font-weight: 700; color: var(--brand-dark); font-size: 12px; }
.perm-yes { color: #16a34a; font-weight: 700; }
.perm-no { color: #cbd5e1; }
.perm-group-title { font-size: 12.5px; font-weight: 700; color: var(--brand-dark); margin: 14px 0 6px; padding-bottom: 4px; border-bottom: 1px solid var(--line); }
.perm-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 6px; }
.perm-item {
  display: flex; align-items: center; gap: 7px; font-size: 12.5px; padding: 7px 9px; border-radius: 9px;
  border: 1px solid var(--line); cursor: pointer; background: #fff; transition: background .12s, border-color .12s;
}
.perm-item.on { background: #eef4fa; border-color: #cfe0ef; }
.perm-item.custom { border-style: dashed; border-color: var(--brand); }
.perm-item small.tag { font-size: 9.5px; margin-inline-start: auto; }

/* ===================== مرفقات الحجوزات وسندات العربون ===================== */
.att-toolbar { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; margin: 9px 0; }
.att-toolbar .btn { margin: 0; cursor: pointer; }
.att-toolbar select { max-width: 230px; }
.att-drop {
  border: 1.5px dashed #c3d3e2; border-radius: 12px; padding: 13px; text-align: center;
  color: #7d93a8; font-size: 12.5px; background: #f8fbfe; cursor: pointer; transition: .15s;
}
.att-drop.over { border-color: var(--brand); background: #eef5fb; color: var(--brand); }
.att-list { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
.att-card {
  display: flex; align-items: center; gap: 10px; border: 1px solid var(--line);
  border-radius: 12px; padding: 8px; background: #fff;
}
.att-thumb {
  width: 54px; height: 54px; flex: 0 0 54px; border-radius: 9px; overflow: hidden;
  background: #eef3f8; display: flex; align-items: center; justify-content: center;
}
.att-thumb img { width: 100%; height: 100%; object-fit: cover; }
.att-pdf { font-size: 24px; }
.att-meta { flex: 1; min-width: 0; }
.att-meta b { display: block; font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.att-meta small { display: block; color: var(--muted); font-size: 10.5px; margin-bottom: 3px; }
.att-caption { font-size: 11.5px; padding: 3px 7px; height: auto; }
.att-actions { display: flex; gap: 4px; }
.att-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; margin-top: 8px; }
.att-tile { border: 1px solid var(--line); border-radius: 11px; overflow: hidden; background: #fff; position: relative; }
.att-tile-body { height: 108px; background: #eef3f8; display: flex; align-items: center; justify-content: center; }
.att-tile-body img { width: 100%; height: 100%; object-fit: cover; }
.att-tile-foot { padding: 6px 8px 8px; }
.att-tile-foot b { display: block; font-size: 11.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.att-tile-foot small { color: var(--muted); font-size: 10px; }
.att-tile-acts { position: absolute; top: 5px; inset-inline-start: 5px; display: flex; gap: 4px; }
.att-tile-acts .mini-btn { background: rgba(255, 255, 255, .92); }
.att-print-grid { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.att-print-grid figure { margin: 0; width: 118px; }
.att-print-grid img { width: 118px; height: 86px; object-fit: cover; border: 1px solid #ccd6e0; border-radius: 6px; }
.att-print-grid figcaption { font-size: 8.5px; color: #566; text-align: center; margin-top: 2px; }

/* ===================== تطبيق الجوال (PWA) ===================== */
.app-splash {
  position: fixed; inset: 0; z-index: 4000; background: linear-gradient(160deg, #0f2438, #122f47 60%, #0a1c2b);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px;
  transition: opacity .4s ease; opacity: 1;
}
.app-splash.hide { opacity: 0; pointer-events: none; }
.app-splash img { width: min(62vw, 340px); height: auto; }
.app-splash span { color: #b9cbdc; font-size: 13.5px; letter-spacing: .5px; }
.net-pill {
  position: fixed; inset-block-start: 0; inset-inline: 0; z-index: 3500; text-align: center;
  background: #b45309; color: #fff; font-size: 12px; padding: 6px 10px; font-weight: 600;
}
.pwa-steps { margin: 8px 0 0; padding-inline-start: 20px; }
.pwa-steps li { margin-bottom: 7px; font-size: 13px; line-height: 1.7; }
.pwa-kbd {
  display: inline-block; background: #eef3f8; border: 1px solid #cfdcea; border-radius: 5px;
  padding: 0 6px; font-size: 13px; margin-inline: 2px;
}
/* تحسينات الجوال */
@media (max-width: 760px) {
  html, body { -webkit-text-size-adjust: 100%; }
  body.app-body { padding-bottom: env(safe-area-inset-bottom); }
  .toolbar { gap: 6px; }
  .toolbar .input, .toolbar select { min-width: 0; flex: 1 1 130px; }
  .card-head { flex-wrap: wrap; gap: 6px; }
  .tbl { font-size: 12px; }
  .btn { padding: 9px 12px; }
  .att-toolbar select { max-width: none; flex: 1; }
  .perm-grid { grid-template-columns: 1fr; }
  .grid.g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid.g2 { grid-template-columns: 1fr; }
  .modal-card, .ui-modal-card { max-height: 92vh; }
}
@media (display-mode: standalone) {
  .topbar { padding-top: env(safe-area-inset-top); }
}

/* ==========================================================================
   الجوال والآيباد والتابلت — تخطيط تكيّفي وأهداف لمس مريحة
   ========================================================================== */

/* ---------- أجهزة اللمس (جوال/آيباد/تابلت): منع تكبير iOS وأهداف لمس ≥44px ---------- */
@media (pointer: coarse) {
  .input, select, textarea, .field-input { font-size: 16px !important; }   /* أقل من 16px يُسبّب تكبير iOS عند الكتابة */
  .input, select, textarea { min-height: 44px; }
  .btn { min-height: 44px; padding: 11px 16px; }
  .nav-item { min-height: 48px; }
  .mini-btn { width: 38px; height: 38px; }
  .tab, .chip-filter, .chip { min-height: 40px; }
  .contact-btn { min-height: 44px; }
  .att-caption { font-size: 16px !important; }
  /* إبراز قابلية اللمس */
  .clickable:active, .nav-item:active, .btn:active { transform: scale(.985); }
  .tbl tbody tr:active { background: #eef5fb; }
}

/* ---------- أمان الحواف: آيفون/آيباد (نتوء · شريط سفلي) ---------- */
@supports (padding: env(safe-area-inset-bottom)) {
  .sidebar { padding-block-start: env(safe-area-inset-top); }
  .main { padding-inline: max(14px, env(safe-area-inset-right)) max(14px, env(safe-area-inset-left)); }
  .topbar { padding-block-start: env(safe-area-inset-top); }
  body.app-body { padding-block-end: env(safe-area-inset-bottom); }
}

/* ---------- التابلت: 761px – 1180px (آيباد رأسي · تابلت أندرويد) ---------- */
@media (min-width: 761px) and (max-width: 1180px) {
  :root { --sidebar-w: 88px; }
  .nav-item { padding: 13px 0; }
  .nav-ico { font-size: 20px; }
  .grid.g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid.g3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .view { padding: 16px; }
  .toolbar { gap: 8px; flex-wrap: wrap; }
  .toolbar .input, .toolbar select { flex: 1 1 170px; min-width: 140px; }
  /* النوافذ: أوسع وأطول مع تمرير داخلي */
  .modal-card, .ui-modal-card, .modal > div { width: min(92vw, 820px) !important; max-height: 88vh; }
  .form-grid, .grid.form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  /* الجداول: تمرير أفقي واضح مع ظلّ دلالي */
  .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .table-wrap::after {
    content: ''; position: sticky; inset-inline-end: 0; display: block; width: 1px;
  }
  .tbl { font-size: 13px; }
  .tbl th, .tbl td { padding: 9px 10px; }
  .kpi { padding: 12px; }
  .kpi-value { font-size: 21px; }
  /* المرفقات: ثلاثة أعمدة على الآيباد */
  .att-grid { grid-template-columns: repeat(auto-fill, minmax(132px, 1fr)); }
  .perm-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .gal-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
}

/* ---------- الآيباد الأفقي والتابلت العريض: 1181px – 1366px ---------- */
@media (min-width: 1181px) and (max-width: 1366px) {
  :root { --sidebar-w: 210px; }
  .grid.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .tbl { font-size: 13px; }
  .view { padding: 18px 20px; }
}

/* ---------- الآيباد في وضع تقسيم الشاشة (Split View) ---------- */
@media (min-width: 500px) and (max-width: 760px) {
  .sidebar { width: 230px; }
  .grid.g4, .grid.g3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .modal-card, .ui-modal-card { width: 96vw !important; }
  .imp-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* ---------- الآيباد: الطباعة والجداول العريضة ---------- */
@media (min-width: 761px) {
  .view { max-width: 1500px; margin-inline: auto; width: 100%; }
  .table-wrap { scrollbar-width: thin; }
}

/* ---------- الجوال الأفقي: توفير المساحة الرأسية ---------- */
@media (max-width: 900px) and (orientation: landscape) and (max-height: 520px) {
  .topbar { padding-block: 6px; }
  .view { padding: 10px 12px; }
  .kpi { padding: 9px 11px; }
  .sidebar { width: 260px; }
  .app-splash img { width: min(38vw, 240px); }
}

/* ---------- تطبيق مثبّت على تابلت: استغلال العرض ---------- */
@media (display-mode: standalone) and (min-width: 1000px) {
  .view { padding: 20px 24px; }
  .grid.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

/* ---------- التابلت الكبير جداً (سطح مكتب لمسي) ---------- */
@media (min-width: 1600px) {
  .view { max-width: 1680px; }
}

/* ===================== النسخ الاحتياطي التلقائي ===================== */
.switch {
  display: inline-flex; align-items: center; gap: 8px; cursor: pointer; user-select: none;
  background: #eef3f8; border: 1px solid var(--line); border-radius: 11px; padding: 7px 12px;
  font-size: 12.5px; font-weight: 600; color: var(--brand-dark);
}
.switch input { width: 40px; height: 22px; appearance: none; background: #c3d3e2; border-radius: 20px; position: relative; cursor: pointer; transition: background .18s; }
.switch input::after {
  content: ''; position: absolute; inset-block-start: 2px; inset-inline-start: 2px;
  width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: transform .18s;
  box-shadow: 0 1px 3px rgba(0,0,0,.2);
}
.switch input:checked { background: var(--brand); }
.switch input:checked::after { transform: translateX(-18px); }
html[dir="ltr"] .switch input:checked::after { transform: translateX(18px); }
#bk-file, #bk-hours { min-width: 0; }
@media (pointer: coarse) { .switch { min-height: 44px; } .switch input { width: 46px; height: 26px; } .switch input::after { width: 22px; height: 22px; } }

/* ===================== بطاقة موافقة الحجز ===================== */
.approval-card { border: 1px solid var(--line); border-radius: 12px; padding: 11px 13px; margin: 10px 0 4px; background: #f8fbfe; }
.approval-card.pending { border-color: #f0cf8a; background: #fdf9ee; }
.approval-card.rejected { border-color: #f3c2c2; background: #fdf2f2; }
.approval-card.approved { border-color: #b9e3c6; background: #f2fbf5; }
.approval-card .btn { margin: 0; }

/* ===================== مشاركة على واتساب ===================== */
.share-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(78px, 1fr)); gap: 7px; }
.share-img { position: relative; display: block; cursor: pointer; }
.share-img img { width: 100%; height: 66px; object-fit: cover; border-radius: 9px; border: 2px solid transparent; transition: border-color .15s; }
.share-img input { position: absolute; inset-block-start: 4px; inset-inline-start: 4px; width: 18px; height: 18px; accent-color: var(--brand); }
.share-img input:checked + img { border-color: var(--brand); }
.share-img input:not(:checked) + img { opacity: .45; }

/* ===================== صفحات PDF: ترقيم وتكرار الترويسة ===================== */
.table-doc { padding: 0; }
.pdf-page { page-break-after: always; break-after: page; }
.pdf-page:last-child { page-break-after: auto; break-after: auto; }
.pdf-page-head, .pdf-page-foot {
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  font-size: 10.5px; color: #5a6b7d; padding: 3px 2px;
}
.pdf-page-head { border-bottom: 1px solid #dfe7ee; margin-bottom: 6px; }
.pdf-page-foot { border-top: 1px solid #dfe7ee; margin-top: 6px; }
.table-doc .doc-table thead { display: table-header-group; }
.table-doc .doc-table tfoot { display: table-row-group; }
.table-doc .doc-table tbody tr { page-break-inside: avoid; break-inside: avoid; }
.table-doc .doc-header { margin-bottom: 6px; }
.table-doc .doc-sign { margin-top: 8px; }
.doc-meta-line { font-size: 11px; color: #44586b; margin: 4px 0 8px; }
@media print {
  .table-doc .doc-table { font-size: 10.5px; }
  .table-doc .doc-table th, .table-doc .doc-table td { padding: 3.5px 5px; }
  .pdf-page-head, .pdf-page-foot { color: #000; }
}

/* ===================== بوابة قاعدة البيانات ===================== */
.db-gate { position: fixed; inset: 0; z-index: 99999; display: none; align-items: center; justify-content: center;
  padding: 18px; background: radial-gradient(circle at 30% 20%, #12324a 0%, #0a1c2b 70%); overflow: auto; }
.db-gate-card { width: 100%; max-width: 460px; background: #fff; border-radius: 18px; padding: 26px 22px;
  box-shadow: 0 24px 60px rgba(0,0,0,.45); text-align: center; }
.db-gate-logo { font-size: 44px; line-height: 1; margin-bottom: 6px; }
.db-gate-card h1 { font-size: 20px; margin: 4px 0 8px; color: #b91c1c; }
.db-gate-card p { font-size: 13.5px; line-height: 1.7; margin: 0 0 14px; }
.db-gate-form { display: grid; gap: 10px; text-align: start; }
.db-gate-form label { display: grid; gap: 5px; font-size: 12.5px; font-weight: 600; color: #334; }
.db-gate-form .input { font-size: 15px; padding: 11px 12px; border-radius: 10px; }
.db-gate-msg { font-size: 12.5px; min-height: 18px; text-align: center; }
.db-gate-msg.ok { color: #15803d; }
.db-gate-msg.bad { color: #b91c1c; }
.db-gate-help { margin-top: 16px; padding-top: 12px; border-top: 1px dashed #dbe4ec; text-align: start;
  font-size: 12px; color: #556; display: grid; gap: 4px; }
.db-gate-help code { background: #f1f5f9; padding: 4px 7px; border-radius: 6px; font-size: 11.5px; direction: ltr; text-align: left; }
