* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --brown: #482916;
  --brown-dark: #321b10;
  --gold: #d99a32;
  --gold-light: #f4c66f;
  --cream: #f7eee4;
  --panel: #fffaf5;
  --text: #211710;
  --muted: #8d7a69;
  --line: #eadfd3;
  --sidebar-w: 168px;
  --sidebar-collapsed-w: 64px;
}

html,
body {
  max-width: 100%;
  min-height: 100%;
  overflow-x: hidden;
}

body {
  min-height: 100dvh;
  background: #f5eadd;
  color: var(--text);
  font-family: "Cairo", Tahoma, Arial, sans-serif;
}

button,
input,
select {
  font: inherit;
}

.dashboard {
  min-height: 100dvh;
  width: 100%;
}

/* القائمة الجانبية */
.sidebar {
  position: fixed;
  z-index: 15;
  top: 0;
  right: 0;
  width: var(--sidebar-w);
  height: 100dvh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  color: #fff;
  background: linear-gradient(160deg, #482918, #321b10 75%);
  border-radius: 0 0 0 36px;
  box-shadow: -5px 0 18px #5b321b25;
  padding: 14px 9px 14px;
  transition: width 0.25s ease, padding 0.25s ease, border-radius 0.25s ease;
}

.sidebar-top-bar {
  display: flex;
  justify-content: flex-end;
  position: relative;
  z-index: 3;
  margin-bottom: 4px;
}

.sidebar-toggle {
  width: 28px;
  height: 28px;
  border-radius: 9px;
  border: 1px solid #f0bd5b44;
  background: #ffffff14;
  color: #f4c66f;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.2s ease;
}

.sidebar-toggle:hover {
  background: #ffffff28;
}

.sidebar-toggle svg {
  width: 16px;
  height: 16px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2.3;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: transform 0.25s ease;
}

.brand {
  text-align: center;
  position: relative;
  z-index: 2;
}

.brand-mark {
  color: #f0bd5b;
  font-size: 38px;
  line-height: 1;
  text-shadow: 0 2px 8px #d99a3266;
}

.brand h2 {
  font-size: 17px;
  font-weight: 900;
  margin-top: 3px;
  color: #fff8ee;
  white-space: nowrap;
}

.brand span {
  display: block;
  color: #e6c68b;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.navigation {
  display: grid;
  gap: 5px;
  margin-top: 18px;
  position: relative;
  z-index: 2;
  flex: 1;
  align-content: start;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 38px;
  padding: 6px 10px;
  color: #f8eee5;
  text-decoration: none;
  font-size: 12.5px;
  font-weight: 700;
  border-radius: 13px;
  white-space: nowrap;
  overflow: hidden;
  transition: 0.2s ease;
}

.nav-link:hover {
  background: #ffffff17;
}

.nav-link.active {
  color: #2d190e;
  background: linear-gradient(110deg, #f7cb75, #d8942c);
  box-shadow: 0 4px 12px #d99a3240;
}

.nav-icon {
  width: 20px;
  height: 20px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.nav-icon svg {
  width: 18px;
  height: 18px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.sidebar-wave {
  position: absolute;
  width: 240px;
  height: 175px;
  right: -54px;
  bottom: -45px;
  border-top: 11px solid #c4872e;
  border-radius: 50% 0 0 0;
  transform: rotate(-19deg);
  opacity: 0.42;
  pointer-events: none;
  z-index: 1;
}

.sidebar-wave::after {
  content: "";
  position: absolute;
  width: 260px;
  height: 120px;
  top: 18px;
  right: -15px;
  border-top: 7px solid #e9b24e;
  border-radius: 50%;
}

.version {
  position: relative;
  z-index: 2;
  margin-top: 8px;
  text-align: center;
  color: #c8b4a2;
  font-size: 11px;
}

/* حالة طي القائمة الجانبية */
.dashboard.sidebar-collapsed .sidebar {
  width: var(--sidebar-collapsed-w);
  padding-inline: 8px;
  border-radius: 0 0 0 24px;
}

.dashboard.sidebar-collapsed .sidebar-top-bar {
  justify-content: center;
}

.dashboard.sidebar-collapsed .sidebar-toggle svg {
  transform: rotate(180deg);
}

.dashboard.sidebar-collapsed .brand-mark {
  font-size: 30px;
}

.dashboard.sidebar-collapsed .brand h2,
.dashboard.sidebar-collapsed .brand span,
.dashboard.sidebar-collapsed .nav-text,
.dashboard.sidebar-collapsed .version {
  display: none;
}

.dashboard.sidebar-collapsed .nav-link {
  justify-content: center;
  padding: 8px;
}

.dashboard.sidebar-collapsed .main-content {
  margin-right: var(--sidebar-collapsed-w);
}

/* المحتوى الرئيسي */
.main-content {
  margin-right: var(--sidebar-w);
  padding: 0 20px 30px;
  max-width: 1800px;
  min-height: 100dvh;
  transition: margin-right 0.25s ease, background-color 0.2s ease;
}

.main-content.white-bg {
  background-color: #ffffff;
}

/* الشريط العلوي */
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  min-height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  border-bottom: 1px solid #eadfd3;
  margin: 0 -20px 15px;
  padding: 7px 22px;
  background: #fbf4edeb;
  backdrop-filter: blur(6px);
}

.page-title {
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}

.page-title h1 {
  font-size: clamp(17px, 1.45vw, 22px);
  font-weight: 900;
}

.title-bars {
  display: flex;
  align-items: end;
  gap: 3px;
  height: 22px;
}

.title-bars i {
  display: block;
  width: 5px;
  border-radius: 2.5px;
  background: #8b5429;
}

.title-bars i:nth-child(1) {
  height: 11px;
}

.title-bars i:nth-child(2) {
  height: 16px;
}

.title-bars i:nth-child(3) {
  height: 22px;
}

.search-box {
  width: min(360px, 34%);
  height: 40px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 14px;
  border: 1px solid #e9dbcc;
  border-radius: 22px;
  background: #fffaf5;
  box-shadow: 0 2px 7px #5a32130f;
}

.search-box input {
  width: 100%;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
  font-size: 12.5px;
}

.search-box span {
  font-size: 22px;
  transform: rotate(-20deg);
  color: #6a4d37;
}

.user-area {
  display: flex;
  align-items: center;
  gap: 11px;
  white-space: nowrap;
}

.notification {
  position: relative;
  border: 0;
  background: none;
  width: 34px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--brown);
  cursor: pointer;
  border-radius: 50%;
}

.notification svg {
  width: 21px;
  height: 21px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2.1;
}

.notification b {
  position: absolute;
  top: 1px;
  right: 1px;
  min-width: 17px;
  height: 17px;
  padding: 0 4px;
  display: grid;
  place-items: center;
  color: white;
  background: #df2222;
  border-radius: 50%;
  font: 700 10px Arial;
  border: 1.5px solid #fbf4ed;
}

.top-divider {
  height: 28px;
  width: 1px;
  background: #cbb9a8;
}

.avatar {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  border: 2px solid #e7b863;
  background: linear-gradient(145deg, #59351f, #321b10);
  color: #f7cb75;
}

.avatar svg {
  width: 22px;
  height: 22px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.9;
}

.welcome {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 13px;
  cursor: pointer;
}

.welcome strong {
  font-weight: 800;
  color: var(--text);
}

/* بطاقات ولوحات الرئيسية */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
  direction: ltr;
}

.stat-card,
.panel {
  background: var(--panel);
  border: 1px solid #eee2d7;
  border-radius: 22px;
  box-shadow: 0 4px 10px #5c32151b;
}

.stat-card {
  position: relative;
  min-height: 170px;
  overflow: hidden;
  display: flex;
  gap: 10px;
  padding: 16px 12px 44px;
  direction: rtl;
}

.stat-icon {
  flex: 0 0 48px;
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  border-radius: 16px;
  color: #fff8e9;
  font-size: 22px;
}

.stat-icon.brown {
  background: linear-gradient(145deg, #775033, #3b2113);
}

.stat-icon.gold {
  background: linear-gradient(145deg, #f3c66c, #b97719);
}

.stat-info {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  text-align: right;
  margin-right: auto;
}

.stat-info strong {
  font: 800 clamp(20px, 1.9vw, 30px)/1.25 "Cairo", sans-serif;
}

.stat-info span {
  font-size: 13px;
  font-weight: 800;
  color: #5a4332;
}

.stat-info em {
  margin-top: 6px;
  color: #237746;
  font-size: 14px;
  font-style: normal;
  font-weight: 800;
}

.sparkline {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 42px;
}

.sparkline path {
  fill: none;
  stroke: #6b4127;
  stroke-width: 3;
}

.sparkline.gold-line path {
  stroke: #d69a39;
}

.bottom-stats-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin-top: 16px;
}

.panel {
  padding: 18px 20px;
}

.panel-heading {
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid #f0e6dc;
  padding-bottom: 10px;
}

.panel-heading h2 {
  font-size: 18px;
  font-weight: 900;
}

.heading-icon {
  color: #d99a32;
  font-size: 24px;
}

.other-cases-list {
  display: grid;
  gap: 10px;
  margin-top: 16px;
}

.case-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #f6efe7;
  border: 1px solid #ece0d3;
  padding: 12px 16px;
  border-radius: 14px;
}

.case-label {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 15px;
  font-weight: 800;
}

.case-badge {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  font-size: 16px;
}

.badge-blue {
  background: #e6effa;
  color: #3b7ddd;
}

.badge-red {
  background: #fbe9e9;
  color: #d94a4a;
}

.badge-green {
  background: #e6f6ed;
  color: #289a5c;
}

.badge-orange {
  background: #fdf0e1;
  color: #d9822b;
}

.badge-purple {
  background: #f0eafb;
  color: #7952b3;
}

.case-count {
  font-size: 17px;
  font-weight: 900;
  color: var(--brown);
}

.aid-section-title {
  color: #c88824;
  font-size: 14px;
  font-weight: 800;
  margin-top: 14px;
  padding-bottom: 6px;
  border-bottom: 1px dashed #e6d7c6;
}

.aid-list {
  display: grid;
  gap: 8px;
  margin-top: 8px;
}

.aid-row {
  display: flex;
  justify-content: space-between;
  font-size: 14px;
  font-weight: 700;
}

.aid-row strong {
  font-size: 15px;
  font-weight: 900;
  color: var(--brown);
}

.regions-wrapper {
  display: flex;
  align-items: center;
  justify-content: space-around;
  min-height: 290px;
}

.region-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}

.region-ring {
  width: 124px;
  height: 124px;
  border-radius: 50%;
  background: conic-gradient(#d99a32 var(--pct, 0%), #e4e7ec 0);
  display: grid;
  place-items: center;
  position: relative;
}

.region-ring::before {
  content: "";
  position: absolute;
  inset: 15px;
  border-radius: 50%;
  background: var(--panel);
}

.region-ring span {
  position: relative;
  z-index: 1;
  font-size: 20px;
  font-weight: 900;
}

/* الجداول والأزرار المشتركة */
.beneficiaries-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 14px;
}

.beneficiaries-info {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  font-size: 14px;
  font-weight: 700;
  color: var(--muted);
}

.beneficiaries-info span {
  background: #f5ece3;
  color: var(--brown);
  padding: 4px 12px;
  border-radius: 12px;
  font-weight: 800;
  border: 1px solid #e6d7c6;
}

.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: linear-gradient(135deg, #59351f, #321b10);
  color: #f7cb75;
  border: 0;
  padding: 9px 18px;
  border-radius: 14px;
  font-size: 13.5px;
  font-weight: 800;
  cursor: pointer;
}

.table-card {
  background: var(--panel);
  border: 1px solid #e5d5c3;
  border-radius: 16px;
  overflow: hidden;
}

.table-scroll {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.beneficiaries-table {
  width: 100%;
  border-collapse: collapse;
  white-space: nowrap;
  text-align: center;
}

.beneficiaries-table thead th {
  background: #efe2d3;
  color: var(--brown-dark);
  font-size: 13.5px;
  font-weight: 900;
  padding: 14px 16px;
  border-left: 1px solid #e2d1be;
  border-bottom: 2px solid var(--gold);
}

.beneficiaries-table tbody tr:nth-child(even) {
  background: var(--cream);
}

.beneficiaries-table tbody td {
  padding: 10px 14px;
  font-size: 13.5px;
  font-weight: 600;
  border-bottom: 1px solid #eadfd3;
  border-left: 1px solid #efe4d8;
  vertical-align: middle;
}

.empty-row td {
  padding: 46px 20px !important;
  color: var(--muted);
  font-size: 14.5px;
  font-weight: 700;
}

.doc-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 10px;
  font-size: 12px;
  font-weight: 800;
  background: #efe2d3;
  color: var(--brown-dark);
}

.doc-badge.empty {
  background: #f6efe7;
  color: #a39282;
}

/* صورة مصغرة للمستمسك داخل الجدول */
.table-doc-thumb {
  width: 48px;
  height: 34px;
  object-fit: cover;
  border-radius: 8px;
  border: 1.5px solid var(--gold);
  cursor: pointer;
  display: inline-block;
  vertical-align: middle;
  background: #fff;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.table-doc-thumb:hover {
  transform: scale(1.12);
  box-shadow: 0 3px 10px rgba(72, 41, 22, 0.25);
}

/* أيقونة موقع السكن في الجدول */
.location-pin-btn {
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: #e6f6ed;
  color: #1f7a48;
  border: 1px solid #bce3cd;
  text-decoration: none;
  transition: 0.15s ease;
}

.location-pin-btn:hover {
  background: #237746;
  color: #fff;
  transform: translateY(-1px);
}

.location-pin-btn svg {
  width: 18px;
  height: 18px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* زر العين لعرض التفاصيل الكاملة */
.view-details-btn {
  background: #e6effa;
  color: #2b6cb0;
  border: 1px solid #bfd7f2;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  cursor: pointer;
  display: inline-grid;
  place-items: center;
  transition: 0.15s ease;
}

.view-details-btn:hover {
  background: #2b6cb0;
  color: #fff;
  transform: translateY(-1px);
}

.view-details-btn svg {
  width: 18px;
  height: 18px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2.1;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.edit-row-btn {
  background: #fdf3e1;
  color: #b97719;
  border: 1px solid #ebd1a4;
  width: 32px;
  height: 32px;
  border-radius: 10px;
  cursor: pointer;
  display: inline-grid;
  place-items: center;
  transition: 0.15s ease;
}

.edit-row-btn:hover {
  background: #d99a32;
  color: #fff;
}

.delete-row-btn {
  background: #fbe9e9;
  color: #c93232;
  border: 1px solid #f2c6c6;
  width: 32px;
  height: 32px;
  border-radius: 10px;
  cursor: pointer;
  display: inline-grid;
  place-items: center;
  transition: 0.15s ease;
}

.delete-row-btn:hover {
  background: #df2222;
  color: #fff;
}

/* الإشعار العلوي والنافذة المنبثقة */
.toast-banner {
  position: fixed;
  top: 16px;
  left: 50%;
  transform: translateX(-50%) translateY(-120%);
  z-index: 300;
  background: linear-gradient(135deg, #482916, #321b10);
  color: #f7cb75;
  border: 1.5px solid #d99a32;
  padding: 11px 22px;
  border-radius: 16px;
  font-size: 14px;
  font-weight: 800;
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: calc(100vw - 24px);
  opacity: 0;
  pointer-events: none;
  transition: 0.18s ease;
}

.toast-banner.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

.toast-check {
  width: 22px;
  height: 22px;
  flex-shrink: 0;
  border-radius: 50%;
  background: #237746;
  color: #fff;
  display: grid;
  place-items: center;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(33, 23, 16, 0.55);
  backdrop-filter: blur(3px);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 12px;
}

.modal-overlay.open {
  display: flex;
}

.modal-box {
  width: min(1050px, 100%);
  max-height: 92dvh;
  background: var(--panel);
  border: 1px solid #e2d1be;
  border-radius: 22px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.modal-header {
  background: #efe2d3;
  border-bottom: 2px solid var(--gold);
  padding: 13px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.modal-header h3 {
  font-size: 17px;
  font-weight: 900;
}

.modal-close {
  background: #fffaf5;
  border: 1px solid #dec8b0;
  width: 34px;
  height: 34px;
  flex-shrink: 0;
  border-radius: 10px;
  cursor: pointer;
  display: grid;
  place-items: center;
}

.modal-body {
  padding: 16px 18px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  display: grid;
  gap: 16px;
}

.form-group-box {
  background: #fdf7f0;
  border: 1px solid #eadfd3;
  border-radius: 16px;
  padding: 14px;
}

.form-group-title {
  font-size: 14.5px;
  font-weight: 900;
  color: var(--brown);
  margin-bottom: 12px;
  padding-bottom: 6px;
  border-bottom: 1px dashed #dec8b0;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-width: 0;
}

.field label {
  font-size: 12.5px;
  font-weight: 800;
  color: #4a3525;
}

.field input,
.field select {
  width: 100%;
  height: 40px;
  padding: 0 11px;
  border: 1px solid #dec8b0;
  border-radius: 11px;
  background: #fff;
  font-size: 13.5px;
}

.modal-footer {
  background: #f5ece3;
  border-top: 1px solid #e2d1be;
  padding: 12px 18px;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.btn-cancel {
  background: #fffaf5;
  color: var(--brown);
  border: 1px solid #d8c3ac;
  padding: 8px 18px;
  border-radius: 12px;
  font-weight: 800;
  cursor: pointer;
}

.hidden-field {
  display: none !important;
}

/* بطاقات عرض التفاصيل الكاملة للطالب */
.details-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.detail-card {
  background: #fff;
  border: 1px solid #e6d7c6;
  border-radius: 11px;
  padding: 8px 12px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.detail-card span {
  font-size: 11.5px;
  font-weight: 700;
  color: var(--muted);
}

.detail-card strong {
  font-size: 13.5px;
  font-weight: 800;
  color: var(--brown-dark);
  word-break: break-word;
}

.detail-docs-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.detail-doc-item {
  background: #fff;
  border: 1px solid #e6d7c6;
  border-radius: 12px;
  padding: 10px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.detail-doc-item span {
  font-size: 12px;
  font-weight: 800;
  color: var(--brown);
}

.detail-doc-item img {
  width: 100%;
  height: 110px;
  object-fit: cover;
  border-radius: 8px;
  border: 1.5px solid var(--gold);
  cursor: pointer;
}

/* حقل رابط الموقع مع أيقونة الخريطة */
.input-with-btn {
  display: flex;
  align-items: center;
  gap: 6px;
}

.input-with-btn input {
  flex: 1;
  min-width: 0;
}

.btn-map-picker {
  width: 40px;
  height: 40px;
  flex-shrink: 0;
  border-radius: 11px;
  border: 1px solid #bce3cd;
  background: #e6f6ed;
  color: #1f7a48;
  display: inline-grid;
  place-items: center;
  cursor: pointer;
  transition: 0.15s ease;
}

.btn-map-picker:hover {
  background: #237746;
  color: #fff;
}

.btn-map-picker svg {
  width: 19px;
  height: 19px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* أزرار رفع المستمسكات (الاستوديو + الكاميرا) */
.doc-upload-box {
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: #fff;
  border: 1px solid #dec8b0;
  border-radius: 12px;
  padding: 8px 10px;
}

.doc-actions {
  display: flex;
  gap: 6px;
}

.btn-doc {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  height: 34px;
  border-radius: 9px;
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
  border: 1px solid #dec8b0;
  transition: 0.15s ease;
}

.btn-gallery {
  background: #f6efe7;
  color: var(--brown-dark);
}

.btn-gallery:hover {
  background: #eadccf;
}

.btn-camera {
  background: linear-gradient(135deg, #59351f, #321b10);
  color: #f7cb75;
  border-color: #482916;
}

.btn-camera:hover {
  opacity: 0.92;
}

.doc-preview-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  min-height: 28px;
}

.doc-preview-row img {
  width: 44px;
  height: 30px;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid var(--gold);
}

.btn-clear-doc {
  background: #fbe9e9;
  color: #c93232;
  border: 0;
  border-radius: 6px;
  padding: 3px 8px;
  font-size: 11px;
  font-weight: 800;
  cursor: pointer;
}

/* نافذة الكاميرا الحية وعكس الكاميرا */
.camera-modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 250;
  background: rgba(20, 13, 9, 0.85);
  backdrop-filter: blur(4px);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 12px;
  width: 100vw;
  height: 100dvh;
}

.camera-modal-overlay.open {
  display: flex;
}

.camera-box {
  width: 100%;
  max-width: 480px;
  max-height: calc(100dvh - 24px);
  min-width: 0;
  background: var(--panel);
  border: 2px solid var(--gold);
  border-radius: 20px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.45);
}

.camera-header {
  background: #efe2d3;
  padding: 10px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  border-bottom: 1px solid #dec8b0;
  flex-shrink: 0;
}

.camera-header h4 {
  font-size: 14.5px;
  font-weight: 900;
  color: var(--brown-dark);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.camera-viewport {
  position: relative;
  background: #140d09;
  width: 100%;
  min-width: 0;
  height: min(56dvh, 360px);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.camera-viewport video {
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.2s ease;
}

.camera-viewport video.mirrored {
  transform: scaleX(-1);
}

.camera-controls {
  padding: 12px 14px;
  background: #f5ece3;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
  flex-shrink: 0;
}

.camera-controls .btn-flip-cam,
.camera-controls .btn-primary {
  flex: 1 1 135px;
  min-height: 40px;
  padding: 8px 12px;
  font-size: 13px;
  white-space: nowrap;
}

.btn-flip-cam {
  background: #fffaf5;
  color: var(--brown-dark);
  border: 1px solid #c8a265;
  border-radius: 12px;
  font-weight: 800;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.btn-flip-cam:hover {
  background: #efe2d3;
}

/* نافذة الخريطة التفاعلية */
.map-picker-overlay {
  position: fixed;
  inset: 0;
  z-index: 270;
  background: rgba(20, 13, 9, 0.82);
  backdrop-filter: blur(4px);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 12px;
}

.map-picker-overlay.open {
  display: flex;
}

.map-picker-box {
  width: min(680px, 100%);
  max-height: 90dvh;
  background: var(--panel);
  border: 2px solid var(--gold);
  border-radius: 20px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: 0 14px 36px rgba(0, 0, 0, 0.5);
}

.map-picker-header {
  background: #efe2d3;
  padding: 11px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border-bottom: 1px solid #dec8b0;
}

.map-picker-header h4 {
  font-size: 15px;
  font-weight: 900;
  color: var(--brown-dark);
}

.map-picker-hint {
  background: #fdf7f0;
  padding: 7px 14px;
  font-size: 12.5px;
  font-weight: 700;
  color: var(--brown);
  border-bottom: 1px solid #eadfd3;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
}

#leaflet-map-container {
  width: 100%;
  height: min(55dvh, 380px);
  z-index: 1;
}

.map-picker-footer {
  background: #f5ece3;
  padding: 11px 16px;
  border-top: 1px solid #dec8b0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.map-coords-text {
  font-size: 12px;
  font-weight: 800;
  color: var(--muted);
  direction: ltr;
}

.btn-my-location {
  background: #fffaf5;
  color: var(--brown-dark);
  border: 1px solid #c8a265;
  padding: 7px 13px;
  border-radius: 10px;
  font-size: 12.5px;
  font-weight: 800;
  cursor: pointer;
}

.btn-my-location:hover {
  background: #efe2d3;
}

/* نافذة تكبير الصورة (Lightbox) */
.image-viewer-overlay {
  position: fixed;
  inset: 0;
  z-index: 280;
  background: rgba(20, 13, 9, 0.85);
  backdrop-filter: blur(4px);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.image-viewer-overlay.open {
  display: flex;
}

.image-viewer-box {
  width: min(680px, 100%);
  max-height: 90dvh;
  background: var(--panel);
  border: 2px solid var(--gold);
  border-radius: 20px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: 0 14px 36px rgba(0, 0, 0, 0.5);
}

.image-viewer-header {
  background: #efe2d3;
  padding: 11px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border-bottom: 1px solid #dec8b0;
}

.image-viewer-header h4 {
  font-size: 15px;
  font-weight: 900;
  color: var(--brown-dark);
}

.btn-hide-image {
  background: #fbe9e9;
  color: #c93232;
  border: 1px solid #f2c6c6;
  padding: 5px 14px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.btn-hide-image:hover {
  background: #df2222;
  color: #fff;
}

.image-viewer-body {
  padding: 14px;
  background: #140d09;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: auto;
}

.image-viewer-body img {
  max-width: 100%;
  max-height: 74dvh;
  border-radius: 10px;
  object-fit: contain;
}

/* شارة نسبة التخفيض الخضراء مع علامة صح في جدول الطلبة */
#students-tbody tr:not(.empty-row) td:nth-child(6) {
  text-align: center;
}

#students-tbody tr:not(.empty-row) td:nth-child(6),
#students-tbody tr:not(.empty-row) td:nth-child(6) * {
  color: #15803d !important;
  font-weight: 900 !important;
  font-size: 14px;
}

#students-tbody tr:not(.empty-row) td:nth-child(6)::before {
  content: "✓";
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 21px;
  height: 21px;
  margin-left: 7px;
  background: linear-gradient(135deg, #22c55e, #15803d);
  color: #ffffff !important;
  border-radius: 50%;
  font-size: 12px;
  font-weight: 900;
  box-shadow: 0 2px 6px rgba(21, 128, 61, 0.35);
  vertical-align: middle;
}

/* تجاوب الآيباد والتابلت */
@media (max-width: 1150px) {
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
    direction: rtl;
  }

  .bottom-stats-grid {
    grid-template-columns: 1fr;
  }

  .form-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .search-box {
    width: min(300px, 40%);
  }
}

@media (max-width: 900px) {
  .details-grid,
  .detail-docs-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

/* تجاوب جميع الموبايلات (بما فيها الشاشات الصغيرة، الكبيرة، ووضع الدوران الأفقي) */
@media (max-width: 820px), (max-height: 500px) and (orientation: landscape) {
  .dashboard .sidebar {
    position: sticky !important;
    top: 0 !important;
    right: 0 !important;
    left: 0 !important;
    z-index: 25 !important;
    width: 100% !important;
    max-width: 100vw !important;
    height: auto !important;
    min-height: 0 !important;
    max-height: none !important;
    border-radius: 0 0 18px 18px !important;
    padding: 8px 10px !important;
    overflow: visible !important;
  }

  .sidebar-top-bar,
  .brand,
  .sidebar-wave,
  .version {
    display: none !important;
  }

  .dashboard .sidebar .navigation,
  .dashboard.sidebar-collapsed .sidebar .navigation {
    display: flex !important;
    flex-direction: row !important;
    align-items: center !important;
    justify-content: flex-start !important;
    flex: none !important;
    width: 100% !important;
    max-height: none !important;
    gap: 6px !important;
    margin: 0 !important;
    padding-bottom: 2px !important;
    overflow-x: auto !important;
    overflow-y: hidden !important;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }

  .dashboard .sidebar .navigation::-webkit-scrollbar {
    display: none;
  }

  .dashboard .sidebar .nav-link,
  .dashboard.sidebar-collapsed .sidebar .nav-link {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: flex-start !important;
    flex: 0 0 auto !important;
    width: auto !important;
    min-height: 34px !important;
    padding: 6px 12px !important;
    font-size: 12px !important;
    white-space: nowrap !important;
  }

  .dashboard .sidebar .nav-text,
  .dashboard.sidebar-collapsed .sidebar .nav-text {
    display: inline !important;
  }

  .dashboard .main-content,
  .dashboard.sidebar-collapsed .main-content {
    margin-right: 0 !important;
    width: 100% !important;
    max-width: 100vw !important;
    min-width: 0 !important;
    padding: 0 12px 24px !important;
  }

  .topbar {
    flex-wrap: wrap;
    margin: 0 -12px 12px;
    padding: 8px 12px;
    gap: 8px;
  }

  .page-title {
    order: 1;
  }

  .user-area {
    order: 2;
    gap: 7px;
  }

  .welcome strong,
  .top-divider {
    display: none;
  }

  .search-box {
    order: 3;
    width: 100%;
    max-width: 100%;
    height: 38px;
  }

  .beneficiaries-toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .beneficiaries-toolbar .btn-primary {
    width: 100%;
  }

  .modal-overlay {
    padding: 8px;
  }

  .modal-box {
    max-height: 94dvh;
    border-radius: 18px;
  }

  .modal-header {
    padding: 11px 14px;
  }

  .modal-header h3 {
    font-size: 15.5px;
  }

  .modal-body {
    padding: 12px;
    gap: 12px;
  }

  .form-group-box {
    padding: 11px;
  }

  .form-grid,
  .details-grid,
  .detail-docs-grid {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .modal-footer {
    padding: 10px 14px;
  }

  .modal-footer .btn-cancel,
  .modal-footer .btn-primary {
    flex: 1;
  }

  .camera-modal-overlay {
    padding: 8px;
  }

  .camera-box {
    border-radius: 16px;
  }

  .camera-viewport {
    height: min(52dvh, 300px);
  }
}

@media (max-width: 600px) {
  .stats-grid {
    grid-template-columns: 1fr;
  }
}
