/* ============================================================
   نظام مجموعة باسم — corp.ihdathiyat.com
   الهوية البصرية مستمدة من ihdathiyat.com — الإصدار 0.3.0
   ============================================================ */
:root {
  --red:        #C9302C;
  --red-dark:   #A62723;
  --red-bg:     #FBECEB;
  --red-bd:     #F2C7C5;

  --charcoal:   #1E1F24;
  --charcoal-2: #26272E;
  --charcoal-3: #2E2F37;

  --bg:         #F5F5F6;
  --card:       #FFFFFF;
  --surface:    #FAFAFB;
  --border:     #E7E7EA;
  --border-2:   #CFCFD4;

  --ink:        #17181C;
  --text:       #3A3B41;
  --muted:      #71727A;
  --hint:       #9C9DA5;

  --green:      #1E8E5A; --green-bg: #E9F6EF; --green-bd: #BCE5CF;
  --amber:      #C77414; --amber-bg: #FCF3E4; --amber-bd: #F2D9AC;
  --blue:       #2563EB; --blue-bg:  #EAF1FE; --blue-bd:  #C3D8FB;

  --sidebar-w:  262px;
  --radius:     10px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }

body {
  font-family: 'IBM Plex Sans Arabic', Tahoma, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14.5px;
  line-height: 1.6;
  min-height: 100vh;
}

a { color: inherit; text-decoration: none; }
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible {
  outline: 2px solid var(--red);
  outline-offset: 2px;
}

/* ============ الهيكل العام ============ */
.app { display: flex; min-height: 100vh; }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.content { padding: 22px 26px 40px; flex: 1; }

/* ============ القائمة الجانبية ============ */
.sidebar {
  width: var(--sidebar-w);
  background: var(--charcoal);
  color: #E7E7EA;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.sb-brand {
  display: flex; align-items: center; gap: 12px;
  padding: 20px 18px;
  border-bottom: 1px solid rgba(255,255,255,.07);
}

.sb-mark {
  width: 42px; height: 42px;
  background: var(--red);
  color: #fff;
  border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
  font-family: 'Cairo', sans-serif;
  font-weight: 800; font-size: 21px;
  flex-shrink: 0;
}

.sb-name { font-family: 'Cairo', sans-serif; font-weight: 700; font-size: 16px; color: #fff; }
.sb-sub  { font-size: 10.5px; color: #8B8C94; direction: ltr; text-align: right; }

.sb-nav { flex: 1; padding: 12px 10px; }

.sb-item {
  display: flex; align-items: center; gap: 11px;
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 13.5px;
  color: #BBBCC3;
  margin-bottom: 2px;
  cursor: pointer;
  transition: background .12s, color .12s;
  position: relative;
}

.sb-item svg { width: 18px; height: 18px; flex-shrink: 0; }
.sb-item span { flex: 1; }
.sb-item:hover { background: rgba(255,255,255,.05); color: #fff; }

.sb-item.active {
  background: rgba(201,48,44,.16);
  color: #fff;
  font-weight: 600;
}
.sb-item.active::before {
  content: '';
  position: absolute;
  right: -10px; top: 8px; bottom: 8px;
  width: 3px;
  background: var(--red);
  border-radius: 3px;
}

.sb-item.soon { cursor: default; color: #6E6F78; }
.sb-item.soon:hover { background: transparent; color: #6E6F78; }
.sb-item.soon em {
  font-style: normal;
  font-size: 10px;
  background: rgba(255,255,255,.08);
  color: #9C9DA5;
  padding: 1px 7px;
  border-radius: 999px;
}

.sb-foot {
  padding: 13px 18px;
  border-top: 1px solid rgba(255,255,255,.07);
  font-size: 11px;
  color: #7B7C84;
}

/* ============ الشريط العلوي ============ */
.topbar {
  background: var(--card);
  border-bottom: 1px solid var(--border);
  border-top: 3px solid var(--red);
  padding: 0 26px;
  height: 62px;
  display: flex;
  align-items: center;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 20;
}

.menu-btn {
  display: none;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  width: 38px; height: 38px;
  align-items: center; justify-content: center;
  color: var(--text);
  cursor: pointer;
}

.tb-title {
  font-family: 'Cairo', sans-serif;
  font-weight: 700;
  font-size: 17px;
  color: var(--ink);
  flex: 1;
}

.tb-left { display: flex; align-items: center; gap: 14px; }
.tb-date { font-size: 12.5px; color: var(--muted); }

.tb-user {
  display: flex; align-items: center; gap: 9px;
  padding: 4px 8px; margin: -4px -8px;
  border-radius: 9px;
  transition: background .12s;
}
.tb-user:hover { background: var(--surface); }

.tb-avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--charcoal);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-family: 'Cairo', sans-serif;
  font-weight: 700; font-size: 12px;
}

.tb-uname { display: block; font-size: 13px; font-weight: 600; color: var(--ink); line-height: 1.25; }
.tb-urole { display: block; font-size: 11px; color: var(--red); font-weight: 600; }

.tb-logout {
  width: 36px; height: 36px;
  border: 1px solid var(--border);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  color: var(--muted);
  transition: all .12s;
}
.tb-logout:hover { background: var(--red-bg); color: var(--red); border-color: var(--red-bd); }

/* ============ رسائل الفلاش ============ */
.flash { padding: 11px 26px; font-size: 13.5px; font-weight: 500; }
.flash-success { background: var(--green-bg); color: var(--green); border-bottom: 1px solid var(--green-bd); }
.flash-error   { background: var(--red-bg);   color: var(--red);   border-bottom: 1px solid var(--red-bd); }
.flash-info    { background: var(--blue-bg);  color: var(--blue);  border-bottom: 1px solid var(--blue-bd); }

/* ============ البطاقات والمؤشرات ============ */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 20px;
}

.kpi {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  position: relative;
  overflow: hidden;
}
.kpi::before {
  content: '';
  position: absolute;
  top: 0; right: 0;
  width: 4px; height: 100%;
  background: var(--charcoal);
}
.kpi.red::before   { background: var(--red); }
.kpi.amber::before { background: var(--amber); }
.kpi.green::before { background: var(--green); }
.kpi.blue::before  { background: var(--blue); }

.kpi-label { font-size: 12.5px; color: var(--muted); margin-bottom: 8px; }
.kpi-value {
  font-family: 'Cairo', sans-serif;
  font-weight: 800;
  font-size: 27px;
  color: var(--ink);
  line-height: 1.1;
}
.kpi.red .kpi-value   { color: var(--red); }
.kpi.amber .kpi-value { color: var(--amber); }
.kpi.green .kpi-value { color: var(--green); }
.kpi-hint { font-size: 11.5px; color: var(--hint); margin-top: 4px; }

/* ============ الأقسام والبطاقات العامة ============ */
.panel {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 20px;
  overflow: hidden;
}

.panel-head {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.panel-title {
  font-family: 'Cairo', sans-serif;
  font-weight: 700;
  font-size: 15px;
  color: var(--ink);
  display: flex;
  align-items: center;
  gap: 9px;
  flex-wrap: wrap;
}
.panel-title svg { width: 17px; height: 17px; color: var(--red); }

.panel-badge {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  padding: 2px 11px;
  border-radius: 999px;
}

.panel-body { padding: 16px 18px; }

/* ============ قائمة التنبيهات ============ */
.alert-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 18px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.alert-row:last-child { border-bottom: none; }

.alert-dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }
.alert-row.expired  .alert-dot { background: var(--red); }
.alert-row.critical .alert-dot { background: var(--amber); }
.alert-row.soon     .alert-dot { background: var(--blue); }

.alert-main { flex: 1; min-width: 200px; }
.alert-title { font-weight: 600; font-size: 13.5px; color: var(--ink); }
.alert-who   { font-size: 12px; color: var(--muted); margin-top: 1px; }

.alert-date {
  font-family: 'Cairo', sans-serif;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--muted);
}

.alert-badge {
  font-size: 11.5px;
  font-weight: 600;
  padding: 3px 11px;
  border-radius: 999px;
  white-space: nowrap;
}
.alert-row.expired  .alert-badge { background: var(--red-bg);   color: var(--red); }
.alert-row.critical .alert-badge { background: var(--amber-bg); color: var(--amber); }
.alert-row.soon     .alert-badge { background: var(--blue-bg);  color: var(--blue); }

/* ============ شبكة الأقسام ============ */
.mod-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 13px;
}

.mod-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  gap: 13px;
  align-items: flex-start;
  transition: border-color .12s, transform .12s;
}
a.mod-card:hover { border-color: var(--red); transform: translateY(-2px); }

.mod-icon {
  width: 40px; height: 40px;
  border-radius: 9px;
  background: var(--red-bg);
  color: var(--red);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.mod-icon svg { width: 19px; height: 19px; }
.mod-card.off .mod-icon { background: var(--surface); color: var(--hint); }

.mod-title { font-family: 'Cairo', sans-serif; font-weight: 700; font-size: 14px; color: var(--ink); }
.mod-card.off .mod-title { color: var(--muted); }
.mod-desc { font-size: 12px; color: var(--muted); margin-top: 2px; line-height: 1.5; }

.mod-state {
  display: inline-block;
  margin-top: 7px;
  font-size: 10.5px;
  font-weight: 700;
  padding: 2px 9px;
  border-radius: 999px;
}
.mod-state.on  { background: var(--green-bg); color: var(--green); }
.mod-state.off { background: var(--surface); color: var(--hint); border: 1px solid var(--border); }

/* ============ سجل النشاط المختصر ============ */
.act-row {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px 18px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  flex-wrap: wrap;
}
.act-row:last-child { border-bottom: none; }

.act-badge {
  font-size: 11px;
  font-weight: 700;
  padding: 2px 10px;
  border-radius: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--muted);
  white-space: nowrap;
}
.act-badge.login  { background: var(--green-bg); color: var(--green); border-color: var(--green-bd); }
.act-badge.create { background: var(--blue-bg);  color: var(--blue);  border-color: var(--blue-bd); }
.act-badge.delete { background: var(--red-bg);   color: var(--red);   border-color: var(--red-bd); }

.act-desc { flex: 1; color: var(--text); min-width: 160px; }
.act-user { font-size: 12px; color: var(--muted); }
.act-time { font-size: 11.5px; color: var(--hint); font-family: 'Cairo', sans-serif; }

.empty {
  padding: 34px 18px;
  text-align: center;
  color: var(--hint);
  font-size: 13.5px;
  line-height: 2;
}

/* ============ الأزرار والنماذج ============ */
.btn {
  font-family: 'Cairo', sans-serif;
  font-weight: 700;
  font-size: 13.5px;
  border: 1px solid var(--border-2);
  background: var(--card);
  color: var(--ink);
  padding: 9px 18px;
  border-radius: 8px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  transition: all .12s;
  white-space: nowrap;
}
.btn:hover { background: var(--surface); }

.btn-primary { background: var(--red); border-color: var(--red); color: #fff; }
.btn-primary:hover { background: var(--red-dark); }
.btn-primary:disabled { background: var(--hint); border-color: var(--hint); cursor: not-allowed; }

.btn-ghost { border-color: transparent; background: transparent; color: var(--muted); }
.btn-ghost:hover { background: var(--surface); color: var(--ink); }

.btn-sm { padding: 5px 12px; font-size: 12px; border-radius: 7px; }

.btn-danger { color: var(--red); border-color: var(--red-bd); background: var(--card); }
.btn-danger:hover { background: var(--red-bg); }

input, select, textarea {
  font-family: 'IBM Plex Sans Arabic', Tahoma, sans-serif;
  font-size: 14px;
  border: 1px solid var(--border-2);
  border-radius: 8px;
  padding: 10px 13px;
  background: var(--card);
  color: var(--ink);
  width: 100%;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--red);
  box-shadow: 0 0 0 3px rgba(201,48,44,.12);
}
input[type="checkbox"] { width: auto; }
input[type="file"] { padding: 8px; background: var(--surface); }

/* ============ شريط الإجراءات والفلاتر ============ */
.page-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}
.page-actions .grow { flex: 1; min-width: 260px; }
.page-actions input, .page-actions select { width: auto; padding: 8px 12px; font-size: 13.5px; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.filters input[name="q"] { min-width: 190px; }

.chips { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.chip-f {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 4px 14px;
  font-size: 12.5px;
  color: var(--muted);
}
.chip-f b { font-family: 'Cairo'; color: var(--ink); }
.chip-f.c-red b { color: var(--red); }
.chip-f.c-amber b { color: var(--amber); }
.chip-f.c-green b { color: var(--green); }

/* ============ بطاقات المنشآت ============ */
.ent-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 13px;
}

.ent-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  display: block;
  transition: border-color .12s, transform .12s;
}
a.ent-card:hover { border-color: var(--red); transform: translateY(-2px); }

.ent-name {
  font-family: 'Cairo', sans-serif;
  font-weight: 700;
  font-size: 14.5px;
  color: var(--ink);
  line-height: 1.5;
}

.ent-num {
  font-family: 'Cairo', sans-serif;
  font-size: 13px;
  color: var(--muted);
  direction: ltr;
  text-align: right;
  margin-top: 2px;
}

.tagrow { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 9px; }
.tag2 {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 10px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--muted);
}
.tag2.t-ok  { background: var(--green-bg); border-color: var(--green-bd); color: var(--green); }
.tag2.t-off { background: var(--red-bg);   border-color: var(--red-bd);   color: var(--red); }
.tag2.t-cat { background: var(--blue-bg);  border-color: var(--blue-bd);  color: var(--blue); }

.ent-stats {
  display: flex;
  gap: 12px;
  margin-top: 11px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
  font-size: 12px;
  color: var(--muted);
  flex-wrap: wrap;
}
.ent-stats .st-red { color: var(--red); font-weight: 700; }
.ent-stats .st-ok  { color: var(--green); }

.ent-add {
  border-style: dashed;
  border-color: var(--border-2);
  background: var(--surface);
  text-align: center;
}
.ent-add:hover { border-color: var(--red); background: var(--card); }
.ent-add-plus {
  font-family: 'Cairo';
  font-size: 30px;
  font-weight: 800;
  color: var(--red);
  line-height: 1;
  margin-bottom: 6px;
}

/* ============ النماذج ============ */
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px 16px;
}
.field label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
  margin-bottom: 6px;
}
.field .req { color: var(--red); }
.f-full { grid-column: 1 / -1; }
.form-actions { display: flex; gap: 10px; margin-top: 18px; }
.hint { font-size: 12px; color: var(--hint); margin-top: 6px; line-height: 1.7; }
.hint-inline { font-size: 11.5px; color: var(--hint); font-weight: 400; }

/* ============ الجداول ============ */
.table-wrap { overflow-x: auto; }
table.dt { width: 100%; border-collapse: collapse; min-width: 680px; }
table.dt thead th {
  background: var(--surface);
  font-family: 'Cairo', sans-serif;
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  text-align: right;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
table.dt tbody td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--border);
  font-size: 13.5px;
  vertical-align: middle;
}
table.dt tbody tr:last-child td { border-bottom: none; }
table.dt tbody tr:hover td { background: var(--surface); }
table.dt td.strong { font-weight: 600; color: var(--ink); display: block; }
table.dt .strong { font-weight: 600; color: var(--ink); }
table.dt .sub { display: block; font-size: 12px; color: var(--muted); margin-top: 1px; }
table.dt td.mono { font-family: 'Cairo', sans-serif; direction: ltr; text-align: right; }
table.dt th.c, table.dt td.c { text-align: center; }

/* ============ الشارات ============ */
.badge {
  display: inline-block;
  font-size: 11.5px;
  font-weight: 700;
  padding: 3px 12px;
  border-radius: 999px;
  white-space: nowrap;
}
.b-red   { background: var(--red-bg);   color: var(--red); }
.b-amber { background: var(--amber-bg); color: var(--amber); }
.b-blue  { background: var(--blue-bg);  color: var(--blue); }
.b-green { background: var(--green-bg); color: var(--green); }
.b-gray  { background: var(--surface);  color: var(--muted); border: 1px solid var(--border); }

/* ============ الرفع الذكي ============ */
.file-row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.file-row input[type="file"] { flex: 1; min-width: 220px; width: auto; }

.ai-status { margin-top: 10px; font-size: 13px; line-height: 1.8; }
.ai-status .ai-ok   { color: var(--green); font-weight: 600; }
.ai-status .ai-err  { color: var(--red); font-weight: 600; }
.ai-status .ai-warn { color: var(--amber); font-weight: 600; }
.ai-status .ai-wait { color: var(--blue); font-weight: 600; }
.ai-status .ai-wait::before {
  content: '';
  display: inline-block;
  width: 12px; height: 12px;
  border: 2px solid var(--blue);
  border-top-color: transparent;
  border-radius: 50%;
  margin-left: 7px;
  vertical-align: -2px;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.suggest {
  margin-top: 12px;
  background: var(--amber-bg);
  border: 1px solid var(--amber-bd);
  border-radius: 9px;
  padding: 12px 15px;
  font-size: 13px;
  color: #7A4A0E;
  line-height: 1.9;
}
.suggest .s-check { display: flex; align-items: center; gap: 8px; font-weight: 600; margin-top: 6px; cursor: pointer; }

.note {
  border-radius: 9px;
  padding: 11px 15px;
  font-size: 13px;
  margin-bottom: 13px;
  line-height: 1.8;
}
.note-amber { background: var(--amber-bg); border: 1px solid var(--amber-bd); color: #7A4A0E; }

/* ============ صفحة المعلومات ============ */
.info-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}
.info-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 14px;
}
.i-label { display: block; font-size: 11.5px; color: var(--hint); margin-bottom: 2px; }
.i-value {
  display: block;
  font-family: 'Cairo', sans-serif;
  font-weight: 700;
  font-size: 13.5px;
  color: var(--ink);
  direction: ltr;
  text-align: right;
  word-break: break-all;
}

.bank-add { display: flex; gap: 9px; flex-wrap: wrap; }
.bank-add input { flex: 1; min-width: 160px; width: auto; }

/* ============ صفحة تسجيل الدخول ============ */
.login-page {
  background: var(--charcoal);
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.login-card {
  background: var(--card);
  border-radius: 14px;
  width: 100%;
  max-width: 420px;
  overflow: hidden;
  border-top: 4px solid var(--red);
}

.login-head { text-align: center; padding: 34px 30px 10px; }

.login-mark {
  width: 58px; height: 58px;
  background: var(--red);
  color: #fff;
  border-radius: 13px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: 'Cairo', sans-serif;
  font-weight: 800;
  font-size: 28px;
  margin-bottom: 14px;
}

.login-head h1 { font-family: 'Cairo', sans-serif; font-size: 21px; font-weight: 800; color: var(--ink); }
.login-head p  { font-size: 13px; color: var(--muted); margin-top: 4px; }

.login-card form { padding: 22px 30px 8px; }
.login-card label { display: block; font-size: 13px; font-weight: 600; color: var(--ink); margin-bottom: 15px; }
.login-card label input { margin-top: 6px; }

.login-card form > button {
  width: 100%;
  font-family: 'Cairo', sans-serif;
  font-weight: 700;
  font-size: 15px;
  background: var(--red);
  color: #fff;
  border: none;
  border-radius: 9px;
  padding: 13px;
  cursor: pointer;
  transition: background .12s;
  margin-top: 4px;
}
.login-card form > button:hover { background: var(--red-dark); }

.login-err {
  margin: 18px 30px 0;
  background: var(--red-bg);
  border: 1px solid var(--red-bd);
  color: var(--red);
  font-size: 13px;
  font-weight: 600;
  padding: 10px 14px;
  border-radius: 8px;
  text-align: center;
}

.login-foot {
  text-align: center;
  padding: 16px 30px 26px;
  font-size: 11.5px;
  color: var(--hint);
  direction: ltr;
}

/* ============ التجاوب ============ */
.nav-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(23,24,28,.5);
  z-index: 40;
}

@media (max-width: 920px) {
  .menu-btn { display: flex; }
  .sidebar {
    position: fixed;
    top: 0; bottom: 0; right: 0;
    z-index: 50;
    transform: translateX(100%);
    transition: transform .22s ease;
    height: 100dvh;
  }
  body.nav-open .sidebar { transform: none; }
  body.nav-open .nav-overlay { display: block; }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .mod-grid, .ent-grid { grid-template-columns: 1fr 1fr; }
  .info-grid { grid-template-columns: 1fr 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .content { padding: 16px 14px 32px; }
  .topbar { padding: 0 14px; }
  .tb-date, .tb-uinfo { display: none; }
}

@media (max-width: 560px) {
  .mod-grid, .ent-grid, .info-grid { grid-template-columns: 1fr; }
  .kpi-grid { grid-template-columns: 1fr 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

/* ============ المرحلة 4 — الدفعات والمديونيات ============ */
.pay-layout {
  display: grid;
  grid-template-columns: 1fr 350px;
  gap: 16px;
  align-items: start;
}

.calc-box {
  background: var(--charcoal);
  color: #E7E7EA;
  border-radius: var(--radius);
  padding: 18px;
  position: sticky;
  top: 78px;
}
.calc-box h3 {
  font-family: 'Cairo', sans-serif;
  font-size: 14px;
  color: #fff;
  margin-bottom: 12px;
  display: flex;
  gap: 8px;
  align-items: center;
}
.calc-box h3 svg { color: var(--red); }

.calc-row {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 7px 0;
  font-size: 13px;
  color: #C9CAD1;
  border-bottom: 1px dashed rgba(255,255,255,.12);
}
.calc-row b { font-family: 'Cairo', sans-serif; color: #fff; direction: ltr; }
.calc-row.minus b { color: #F5A9A6; }
.calc-row.total {
  border-bottom: none;
  margin-top: 6px;
  padding-top: 12px;
  border-top: 2px solid var(--red);
  font-size: 14px;
  color: #fff;
}
.calc-row.total b { font-size: 21px; color: #7ED8A8; }
.calc-row.total.neg b { color: #F5A9A6; }

.ded-row { display: flex; align-items: center; gap: 10px; margin-bottom: 9px; }
.ded-row label { flex: 1; font-size: 13px; font-weight: 600; color: var(--ink); margin: 0; }
.ded-row input { width: 150px; direction: ltr; text-align: left; padding: 8px 11px; }

.bal-hint { font-size: 12px; color: var(--muted); margin-top: 5px; line-height: 1.8; }
.bal-hint b { color: var(--red); font-family: 'Cairo', sans-serif; }

.money { font-family: 'Cairo', sans-serif; direction: ltr; unicode-bidi: embed; }
.money-neg { color: var(--red); }
.money-pos { color: var(--green); }

table.breakdown td:first-child { color: var(--muted); width: 45%; }
table.breakdown td:last-child {
  font-family: 'Cairo', sans-serif;
  font-weight: 700;
  color: var(--ink);
  direction: ltr;
  text-align: right;
}
tr.bk-total td { background: var(--red-bg) !important; font-size: 15px; font-weight: 800; }
tr.bk-total td:last-child { color: var(--red); font-size: 18px; }

@media (max-width: 920px) {
  .pay-layout { grid-template-columns: 1fr; }
  .calc-box { position: static; }
}
