/* ==========================================================
   شاشة السكان في الإعدادات: تصميم موحّد (الويب والأندرويد)
   يُحمَّل آخرًا ليتغلب على طبقات التنسيق السابقة
   ========================================================== */
:is(#appView,#residentsMasterModal) .set-res-list{display:grid;gap:12px;margin-top:6px;}
:is(#appView,#residentsMasterModal) .set-res-list .set-res-acc{border:1px solid #dbe6e0;border-radius:16px;background:#ffffff;overflow:hidden;box-shadow:0 1px 2px rgba(8,34,32,.04);transition:box-shadow .2s,border-color .2s;}
:is(#appView,#residentsMasterModal) .set-res-list .set-res-acc.open{border-color:#b9d6c9;box-shadow:0 10px 26px -18px rgba(8,34,32,.45);}
:is(#appView,#residentsMasterModal) .set-res-list .set-res-acc.set-res-new{border-color:#2b7a4b;box-shadow:0 0 0 3px rgba(43,122,75,.22);}
:is(#appView,#residentsMasterModal) .set-res-list .set-res-head{all:unset;box-sizing:border-box;display:flex;align-items:center;gap:12px;width:100%;padding:14px 16px;cursor:pointer;-webkit-tap-highlight-color:transparent;}
:is(#appView,#residentsMasterModal) .set-res-list .set-res-head:hover{background:#f7fbf9;}
:is(#appView,#residentsMasterModal) .set-res-list .set-res-head:focus-visible{outline:3px solid #b8862f;outline-offset:-3px;border-radius:16px;}
:is(#appView,#residentsMasterModal) .set-res-list .set-res-n{flex:0 0 32px;width:32px;height:32px;border-radius:50%;display:grid;place-items:center;background:#1c6a60;color:#fff;font-size:13px;font-weight:800;}
:is(#appView,#residentsMasterModal) .set-res-list .srh-main{flex:1 1 auto;min-width:0;display:flex;flex-direction:column;gap:3px;text-align:start;}
:is(#appView,#residentsMasterModal) .set-res-list .srh-name{font-size:16px;font-weight:800;color:#10201b;line-height:1.5;overflow-wrap:anywhere;}
:is(#appView,#residentsMasterModal) .set-res-list .srh-name i{color:#6b7b74;font-style:normal;}
:is(#appView,#residentsMasterModal) .set-res-list .srh-sub{font-size:13px;font-weight:600;color:#4a5a53;line-height:1.7;}
:is(#appView,#residentsMasterModal) .set-res-list .srh-ph{direction:ltr;unicode-bidi:isolate;color:#1c6a60;}
:is(#appView,#residentsMasterModal) .set-res-list .srh-noph{color:#a3361f;}
:is(#appView,#residentsMasterModal) .set-res-list .srh-fee{color:#8f6519;}
:is(#appView,#residentsMasterModal) .set-res-list .srh-start{color:#1c6a60;}
:is(#appView,#residentsMasterModal) .set-res-list .srh-chev{flex:0 0 30px;height:30px;border-radius:9px;background:#eef5f1;position:relative;}
:is(#appView,#residentsMasterModal) .set-res-list .srh-chev::before{content:"";position:absolute;left:50%;top:50%;width:8px;height:8px;border:solid #1c6a60;border-width:0 2.5px 2.5px 0;transform:translate(-50%,-70%) rotate(45deg);}
:is(#appView,#residentsMasterModal) .set-res-list .set-res-acc.open .srh-chev::before{transform:translate(-50%,-30%) rotate(-135deg);}

/* الجسم المفتوح */
:is(#appView,#residentsMasterModal) .set-res-list .rs-body{display:none;border-top:1px solid #e6ece8;padding:16px;background:#fbfdfc;}
:is(#appView,#residentsMasterModal) .set-res-list .set-res-acc.open>.rs-body{display:block;}

/* أقسام داخل البطاقة */
:is(#appView,#residentsMasterModal) .rs-sec+.rs-sec{margin-top:18px;padding-top:18px;border-top:1px dashed #dbe6e0;}
:is(#appView,#residentsMasterModal) .rs-sec-t{display:flex;align-items:baseline;gap:8px;flex-wrap:wrap;margin:0 0 12px;font-size:14px;font-weight:800;color:#1c6a60;}
:is(#appView,#residentsMasterModal) .rs-sec-t em{font-style:normal;font-size:12px;font-weight:600;color:#6b7b74;}

/* الشبكة والحقول */
:is(#appView,#residentsMasterModal) .rs-grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(170px,1fr));gap:12px 14px;}
:is(#appView,#residentsMasterModal) .rs-f{display:flex;flex-direction:column;gap:6px;min-width:0;margin:0;}
:is(#appView,#residentsMasterModal) .rs-f>span{font-size:13px;font-weight:700;color:#3d4f48;line-height:1.4;}
:is(#appView,#residentsMasterModal) .rs-f input,:is(#appView,#residentsMasterModal) .rs-f select{display:block;width:100%;height:44px;box-sizing:border-box;margin:0;padding:0 12px;border:1.5px solid #cdd9d2;border-radius:12px;background:#ffffff;color:#10201b;font:inherit;font-size:15px;font-weight:600;appearance:auto;-webkit-appearance:auto;}
:is(#appView,#residentsMasterModal) .rs-f input::placeholder{color:#8a9a93;font-weight:500;}
:is(#appView,#residentsMasterModal) .rs-f input:focus,:is(#appView,#residentsMasterModal) .rs-f select:focus{outline:0;border-color:#1c6a60;box-shadow:0 0 0 3px rgba(28,106,96,.16);}
:is(#appView,#residentsMasterModal) .rs-span2{grid-column:span 2;}
:is(#appView,#residentsMasterModal) .rs-req{color:#a3361f;}
:is(#appView,#residentsMasterModal) .rs-hint{margin:10px 0 0;font-size:12px;line-height:1.6;color:#6b7b74;}

/* أزرار أسفل البطاقة */
:is(#appView,#residentsMasterModal) .rs-foot{display:flex;justify-content:space-between;align-items:center;gap:10px;flex-wrap:wrap;margin-top:18px;padding-top:14px;border-top:1px solid #e6ece8;}
:is(#appView,#residentsMasterModal) .rs-btn{display:inline-flex;align-items:center;justify-content:center;gap:8px;min-height:40px;padding:0 16px;border-radius:12px;border:1.5px solid transparent;font:inherit;font-size:14px;font-weight:700;cursor:pointer;-webkit-tap-highlight-color:transparent;}
:is(#appView,#residentsMasterModal) .rs-btn svg{width:18px;height:18px;flex:0 0 18px;}
:is(#appView,#residentsMasterModal) .rs-wa{background:#1f8a4c;color:#ffffff;}
:is(#appView,#residentsMasterModal) .rs-wa:hover{background:#197540;}
:is(#appView,#residentsMasterModal) .rs-del{background:#ffffff;color:#a3361f;border-color:#e6c2b9;}
:is(#appView,#residentsMasterModal) .rs-del:hover{background:#fdf3f0;}
:is(#appView,#residentsMasterModal) .rs-primary{background:#1c6a60;color:#ffffff;}
:is(#appView,#residentsMasterModal) .rs-primary:hover{background:#17574e;}
:is(#appView,#residentsMasterModal) .rs-ghost{background:#ffffff;color:#3d4f48;border-color:#cdd9d2;}
:is(#appView,#residentsMasterModal) .rs-ghost:hover{background:#f4f8f6;}

/* نموذج الإضافة */
:is(#appView,#residentsMasterModal) .set-add-form{background:#fbfdfc;border:1px solid #dbe6e0;border-radius:16px;padding:16px;margin:0 0 14px;}
:is(#appView,#residentsMasterModal) .set-add-form.hidden{display:none!important;}
:is(#appView,#residentsMasterModal) .set-add-form .rs-sec:first-child .rs-sec-t{margin-top:0;}
:is(#appView,#residentsMasterModal) .set-add-form .rs-foot{justify-content:flex-end;}
:is(#appView,#residentsMasterModal) .set-res-toolbar{display:flex;justify-content:flex-start;margin:0 0 12px;}

/* الجوال */
@media (max-width:560px){
  :is(#appView,#residentsMasterModal) .set-res-list .rs-body{padding:14px;}
  :is(#appView,#residentsMasterModal) .rs-grid{grid-template-columns:repeat(2,minmax(0,1fr));gap:10px;}
  :is(#appView,#residentsMasterModal) .rs-span2{grid-column:1/-1;}
  :is(#appView,#residentsMasterModal) .rs-f input,:is(#appView,#residentsMasterModal) .rs-f select{height:46px;font-size:16px;}
  :is(#appView,#residentsMasterModal) .rs-foot .rs-btn{flex:1 1 calc(50% - 10px);}
  :is(#appView,#residentsMasterModal) .set-add-form .rs-foot .rs-btn{flex:1 1 calc(50% - 10px);}
}

/* الوضع الليلي */
html[data-theme="dark"] :is(#appView,#residentsMasterModal) .set-res-list .set-res-acc{background:#13211e;border-color:#2f4842;}
html[data-theme="dark"] :is(#appView,#residentsMasterModal) .set-res-list .set-res-acc.open{border-color:#3d6258;}
html[data-theme="dark"] :is(#appView,#residentsMasterModal) .set-res-list .set-res-head:hover{background:#172723;}
html[data-theme="dark"] :is(#appView,#residentsMasterModal) .set-res-list .srh-name{color:#eef6f2;}
html[data-theme="dark"] :is(#appView,#residentsMasterModal) .set-res-list .srh-sub{color:#b9cbc4;}
html[data-theme="dark"] :is(#appView,#residentsMasterModal) .set-res-list .srh-ph{color:#7fd0bf;}
html[data-theme="dark"] :is(#appView,#residentsMasterModal) .set-res-list .srh-start{color:#7fd0bf;}
html[data-theme="dark"] :is(#appView,#residentsMasterModal) .set-res-list .srh-fee{color:#e0b860;}
html[data-theme="dark"] :is(#appView,#residentsMasterModal) .set-res-list .srh-noph{color:#f19a88;}
html[data-theme="dark"] :is(#appView,#residentsMasterModal) .set-res-list .srh-chev{background:#1d3530;}
html[data-theme="dark"] :is(#appView,#residentsMasterModal) .set-res-list .srh-chev::before{border-color:#c7e0d6;}
html[data-theme="dark"] :is(#appView,#residentsMasterModal) .set-res-list .set-res-n{background:#2f7f72;}
html[data-theme="dark"] :is(#appView,#residentsMasterModal) .set-res-list .rs-body,html[data-theme="dark"] :is(#appView,#residentsMasterModal) .set-add-form{background:#101d1a;border-color:#2f4842;}
html[data-theme="dark"] :is(#appView,#residentsMasterModal) .rs-sec+.rs-sec,html[data-theme="dark"] :is(#appView,#residentsMasterModal) .rs-foot{border-color:#2f4842;}
html[data-theme="dark"] :is(#appView,#residentsMasterModal) .rs-sec-t{color:#7fd0bf;}
html[data-theme="dark"] :is(#appView,#residentsMasterModal) .rs-sec-t em,html[data-theme="dark"] :is(#appView,#residentsMasterModal) .rs-hint{color:#9fb5ad;}
html[data-theme="dark"] :is(#appView,#residentsMasterModal) .rs-f>span{color:#cfe0d9;}
html[data-theme="dark"] :is(#appView,#residentsMasterModal) .rs-f input,html[data-theme="dark"] :is(#appView,#residentsMasterModal) .rs-f select{background:#0f1c19;border-color:#3a5751;color:#eef6f2;}
html[data-theme="dark"] :is(#appView,#residentsMasterModal) .rs-f input:focus,html[data-theme="dark"] :is(#appView,#residentsMasterModal) .rs-f select:focus{border-color:#7fd0bf;box-shadow:0 0 0 3px rgba(127,208,191,.18);}
html[data-theme="dark"] :is(#appView,#residentsMasterModal) .rs-del{background:#13211e;color:#f19a88;border-color:#6a3a31;}
html[data-theme="dark"] :is(#appView,#residentsMasterModal) .rs-ghost{background:#13211e;color:#cfe0d9;border-color:#3a5751;}
html[data-theme="dark"] :is(#appView,#residentsMasterModal) .rs-primary{background:#2f7f72;}

/* شاشة بيانات السكان المنفصلة (من الإعدادات) */
#residentsMasterModal .modal-box.res-master-box{max-width:980px!important;width:min(96vw,980px)!important;max-height:92vh;overflow:auto;}
.res-master-head{display:flex;justify-content:space-between;align-items:flex-start;gap:12px;margin-bottom:12px;}
.res-master-head h2{margin:0 0 4px;}
.res-master-head p{margin:0;color:#64748b;font-size:13px;line-height:1.6;}
.res-term-cell{font-size:12px;color:#475569;white-space:nowrap;}
.res-master-head>button{white-space:nowrap;flex:0 0 auto;min-height:40px;padding:0 16px;}
@media (max-width:560px){
  #residentsMasterModal .modal-box.res-master-box{width:96vw!important;padding:14px!important;}
  .res-master-head h2{font-size:18px;}
}
:is(#appView,#residentsMasterModal) input[data-sf="phone"]{direction:ltr;text-align:right;letter-spacing:.3px;}
