/* =====================================================================
   SSBAPP — طبقة اللمسات الاحترافية: ترويسة التطبيق، التبويبات،
   رؤوس النوافذ، شاشة الدخول بالصورة، وعناوين الأقسام.
   شاشة فقط — لا تؤثر على الطباعة أو ملفات PDF.
   ===================================================================== */
@media screen{

/* ---------- ترويسة التطبيق (تظهر في كل التبويبات) ---------- */
.app-letterhead{
  position:relative;
  display:flex;align-items:center;gap:16px;
  margin:16px 0 0;
  padding:16px 22px 20px;
  border-radius:20px;
  color:#fff;
  background:
    radial-gradient(520px 200px at 0% 0%,rgba(184,134,47,.30),transparent 65%),
    linear-gradient(120deg,var(--pine-700) 0%,var(--pine-900) 55%,var(--pine-950) 100%);
  box-shadow:var(--shadow);
  overflow:hidden;
}
.app-letterhead::before{
  /* نقش نوافذ خفيف في خلفية الترويسة */
  content:"";position:absolute;inset:0;opacity:.07;pointer-events:none;
  background:
    linear-gradient(rgba(255,255,255,.9) 1px,transparent 1px) 0 0/22px 22px,
    linear-gradient(90deg,rgba(255,255,255,.9) 1px,transparent 1px) 0 0/22px 22px;
  -webkit-mask-image:linear-gradient(270deg,transparent 30%,#000);mask-image:linear-gradient(270deg,transparent 30%,#000);
}
.app-letterhead::after{
  content:"";position:absolute;inset-inline:0;bottom:0;height:6px;
  background:
    linear-gradient(#b8862f,#b8862f) left top/38% 4px no-repeat,
    linear-gradient(rgba(236,214,168,.35),rgba(236,214,168,.35)) right top/62% 4px no-repeat;
}
.al-logo{position:relative;flex:0 0 auto;width:62px;height:62px;border-radius:16px;box-shadow:0 10px 22px -10px rgba(0,0,0,.6);}
.al-text{position:relative;min-width:0;flex:1 1 auto;}
.al-name{font-size:24px;font-weight:800;line-height:1.35;color:#fff;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;}
.al-sub{margin-top:2px;font-size:13px;font-weight:500;color:var(--pine-200);}
.al-meta{position:relative;display:flex;flex-direction:column;align-items:flex-end;gap:6px;flex:0 0 auto;}
.al-chip{
  display:inline-flex;align-items:center;gap:7px;
  padding:5px 12px;border-radius:999px;
  background:rgba(255,255,255,.08);border:1px solid rgba(255,255,255,.16);
  font-size:12px;font-weight:700;color:#f3ede0;white-space:nowrap;
}
.al-chip::before{content:"";width:14px;height:14px;background:var(--brass-200);-webkit-mask:var(--ico) center/contain no-repeat;mask:var(--ico) center/contain no-repeat;}
.al-phone{direction:ltr;--ico:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 4h4l2 5-2.5 1.5a11 11 0 0 0 5 5L15 13l5 2v4a2 2 0 0 1-2 2A16 16 0 0 1 3 6a2 2 0 0 1 2-2'/%3E%3C/svg%3E");}
.al-date{--ico:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='3' y='5' width='18' height='16' rx='2'/%3E%3Cpath d='M16 3v4M8 3v4M3 10h18'/%3E%3C/svg%3E");}
.al-chip.hidden{display:none!important;}

/* الشريط العلوي يصبح أخف تحت الترويسة */
.main-head{margin-top:10px;border-radius:16px;margin-inline:0;padding:12px 16px;border:1px solid var(--hair);background:rgba(255,253,249,.88);box-shadow:var(--shadow-sm);top:8px;}
.main-head .head-kicker{display:none;}
.main-head .head-title h1{font-size:21px;margin:0;}

/* ---------- التبويبات ---------- */
.view-tabs{
  display:flex;gap:4px;
  margin:14px 0 0;padding:5px;
  border:1px solid var(--hair);border-radius:15px;
  background:var(--paper-2);
  width:max-content;max-width:100%;overflow-x:auto;
}
.view-tabs .nav-item{
  display:inline-flex;align-items:center;gap:8px;
  padding:9px 18px;border-radius:11px;
  background:transparent;color:var(--muted-ink);border:1px solid transparent;
  box-shadow:none;font-weight:700;font-size:14px;white-space:nowrap;
}
.view-tabs .nav-item::before{width:17px;height:17px;}
.view-tabs .nav-item:hover:not(.active){background:rgba(255,255,255,.6);color:var(--ink-2);filter:none;}
.view-tabs .nav-item.active{
  background:var(--surface);color:var(--pine-900);border-color:var(--hair);
  box-shadow:0 1px 2px rgba(22,35,31,.08),0 4px 12px -6px rgba(22,35,31,.25);
}
.view-tabs .nav-item.active::before{background:var(--brass);}

/* ---------- عناوين الأقسام ووسائل الإيضاح ---------- */
.panel-head{
  display:flex;align-items:flex-end;justify-content:space-between;gap:12px;flex-wrap:wrap;
  margin:-2px 0 14px;padding-bottom:12px;border-bottom:1px solid var(--hair);
}
.panel-head h3,.panel-title h3{
  display:flex;align-items:center;gap:9px;margin:0;font-size:17px;font-weight:800;color:var(--pine-900);
}
.panel-head h3::before,.panel-title h3::before{content:"";width:6px;height:20px;border-radius:3px;background:linear-gradient(180deg,var(--brass),var(--brass-700));}
.panel-head p{margin:5px 0 0;font-size:12.5px;font-weight:500;color:var(--muted-ink);}
.panel-title{margin:20px 0 -4px;}
.legend{display:flex;flex-wrap:wrap;gap:6px;}
.lg{display:inline-flex;align-items:center;gap:6px;padding:4px 10px;border-radius:999px;border:1px solid var(--hair);background:var(--surface);font-size:11.5px;font-weight:700;color:var(--ink-2);}
.lg::before{content:"";width:12px;height:12px;border-radius:4px;box-shadow:inset 0 0 0 1px rgba(0,0,0,.08);}
.lg-paid::before{background:#d5ecdd;}
.lg-unpaid::before{background:#f7ddd5;}
.lg-other::before{background:var(--sky-50);box-shadow:inset 0 0 0 1px #c5dbea;}
.lg-sum::before{background:var(--brass-100);box-shadow:inset 0 0 0 1px var(--brass-200);}
.lg-blue::before{background:#e4eff7;box-shadow:inset 0 0 0 1px #c5dbea;}
.lg-green::before{background:#e3f1ea;box-shadow:inset 0 0 0 1px var(--pine-200);}

/* ---------- بطاقات الملخص: عناوين أوضح ---------- */
.main .cards .card{min-height:98px;}
.main .cards .card b{font-size:23px;}

/* ---------- رؤوس النوافذ بأسلوب الترويسة ---------- */
.modal-box{--mpad:20px;}
.modal-box>h2:first-child{
  position:sticky;top:calc(var(--mpad) * -1);z-index:20;
  display:flex;align-items:center;justify-content:flex-start;gap:12px;
  margin:calc(var(--mpad) * -1) calc(var(--mpad) * -1) 18px;
  padding:14px 20px 16px;
  border:0;border-radius:22px 22px 0 0;
  color:#fff;font-size:19px;text-align:start;
  background:
    radial-gradient(360px 140px at 0% 0%,rgba(184,134,47,.28),transparent 65%),
    linear-gradient(120deg,var(--pine-700),var(--pine-950));
  box-shadow:inset 0 -4px 0 var(--brass);
}
.modal-box>h2:first-child::before{
  content:"";flex:0 0 auto;width:36px;height:36px;border-radius:10px;
  background:url("../img/emblem.png") center/contain no-repeat;
  box-shadow:0 6px 14px -6px rgba(0,0,0,.6);
}
.modal-box>h2:first-child::after{display:none;}
/* نافذة سند القبض/التقارير: خلفية بيضاء نظيفة للمعاينة */
#receiptModal .modal-box,#receiptRecordViewModal .modal-box,#reportsModal .modal-box,#residentReceiptsModal .modal-box{background:var(--surface);}
#receiptPrintArea,#receiptRecordViewArea{margin-top:4px;}
#receiptPrintArea .receipt-paper,#receiptRecordViewArea .receipt-paper{box-shadow:0 18px 40px -22px rgba(22,35,31,.45);}
#reportRoot{border:1px solid var(--hair);border-radius:14px;}

/* ---------- شاشة الدخول: صورة العمارة + ترويسة البطاقة ---------- */
.login-split{min-height:580px;}
.login-brand{
  justify-content:flex-start;
  padding:40px 38px;
  background:
    linear-gradient(180deg,var(--pine-900) 0%,var(--pine-900) 40%,rgba(11,43,40,0) 62%),
    url("../img/login-building.svg") center bottom/auto 62% no-repeat,
    var(--pine-900);
}
.login-brand::after{display:none;}
.login-brand .brand-mark-lg{
  width:64px;height:64px;border-radius:18px;
  background:url("../img/emblem.png") center/contain no-repeat;box-shadow:0 12px 26px -10px rgba(0,0,0,.7);
}
.login-brand h2{font-size:30px;}
.login-brand p{max-width:360px;}
.login-features{margin-top:6px;}
.login-features li{font-size:13.5px;text-shadow:0 1px 8px rgba(0,0,0,.4);}

.login-split .login-card{display:flex;flex-direction:column;justify-content:center;}
.login-split .login-card h1{
  display:flex;align-items:center;gap:12px;
  margin:0 0 6px;padding-bottom:14px;font-size:19px;line-height:1.45;
  background:
    linear-gradient(var(--pine-800),var(--pine-800)) right bottom/62% 3px no-repeat,
    linear-gradient(var(--brass),var(--brass)) left bottom/38% 3px no-repeat;
}
.login-split .login-card h1::before{
  content:"";flex:0 0 auto;width:46px;height:46px;border-radius:13px;
  background:url("../img/emblem.png") center/contain no-repeat;
}
.login-lead{margin-top:10px;}

/* ---------- الجوال ---------- */
@media (max-width:980px){
  .app-letterhead{margin-top:calc(10px + env(safe-area-inset-top));padding:12px 14px 16px;gap:12px;border-radius:18px;}
  .al-logo{width:46px;height:46px;border-radius:13px;}
  .al-name{font-size:18px;}
  .al-sub{font-size:11.5px;}
  .al-meta{display:none;}
  .main-head{top:6px;padding:10px 12px;margin-inline:0;}
  .view-tabs{display:none;}
}
@media (max-width:620px){
  .login-split{min-height:0;}
  .login-brand{min-height:220px;padding:22px;justify-content:flex-end;
    background:
      linear-gradient(0deg,rgba(8,34,32,.92) 0%,rgba(8,34,32,.25) 60%,rgba(8,34,32,.05) 100%),
      url("../img/login-building.svg") center bottom/cover no-repeat,var(--pine-900);}
  .login-brand .brand-mark-lg{display:none;}
  .login-split .login-card h1{font-size:17px;}
  .login-split .login-card h1::before{width:40px;height:40px;}
  .modal-box{--mpad:16px;}
  .modal-box>h2:first-child{font-size:17px;padding:12px 16px 14px;border-radius:18px 18px 0 0;}
  .modal-box>h2:first-child::before{width:30px;height:30px;}
  .panel-head{align-items:flex-start;}
}
} /* end @media screen */

/* Android 15/16 (API 35+): العرض من حافة إلى حافة — نُبعد المحتوى عن شريط الحالة وشريط التنقل.
   على المتصفح قيم env() = 0 فلا يتغير شيء. */
@media screen{
  :root{--sa-top:max(env(safe-area-inset-top,0px),var(--safe-area-inset-top,0px));--sa-bottom:max(env(safe-area-inset-bottom,0px),var(--safe-area-inset-bottom,0px));}
  #loginView{padding-top:calc(24px + var(--sa-top));padding-bottom:calc(24px + var(--sa-bottom));}
  .modal{padding-top:calc(15px + var(--sa-top));padding-bottom:calc(15px + var(--sa-bottom));}
  .toast{bottom:calc(24px + var(--sa-bottom));}
  .biometric-lock-overlay{padding-top:calc(20px + var(--sa-top));padding-bottom:calc(20px + var(--sa-bottom));}
  @media (max-width:980px){
    .main-head{top:calc(6px + var(--sa-top));}
    .bottom-nav{bottom:calc(10px + var(--sa-bottom))!important;}
  }
  @media (max-width:700px){
    #usersModal .modal-box,#systemHealthModal .modal-box,.receipts-ledger-box,.receipt-view-box,.monitor-detail-box,#userGuideModal .user-guide-box{
      padding-top:var(--sa-top)!important;padding-bottom:var(--sa-bottom)!important;
    }
  }
}
