/* =====================================================================
   SSBAPP — الوضع الليلي (شاشة فقط)
   المستندات (سند القبض والتقارير وملفات PDF) تبقى بيضاء دائمًا.
   ===================================================================== */
@media screen{

html[data-theme="dark"]{
  color-scheme:dark;
  --ink:#e8efeb;--ink-2:#c9d5cf;--muted-ink:#93a39d;
  --paper:#0b1513;--paper-2:#0f1c19;
  --surface:#13211e;--surface-2:#182925;
  --hair:#253a35;--hair-2:#2f4842;
  --pine-50:#15302b;--pine-100:#1a3a34;--pine-200:#8fc4b6;
  --brass-100:#2e2614;--brass-200:#d9bd85;--brass-700:#d9b56b;
  --ok:#4cc38a;--ok-100:#163527;--ok-50:#12271f;
  --bad:#ef8a73;--bad-100:#3a1d17;--bad-50:#2a1612;
  --warn:#e2a54a;--warn-100:#33260f;
  --plum:#b6a2ea;--plum-100:#2a2340;
  --sky:#7fb6dd;--sky-100:#162a39;--sky-50:#121f2a;
  --shadow-sm:0 1px 2px rgba(0,0,0,.35);
  --shadow:0 10px 28px -14px rgba(0,0,0,.7);
  /* البطاقات والجداول */
  --c-prev:#c4b4f0;--c-prev-bg:#221d36;--c-prev-bd:#3f3566;
  --c-pay:#7fd6a3;--c-pay-bg:#13301f;--c-pay-bd:#2a6143;
  --c-other:#8fc3ea;--c-other-bg:#13283a;--c-other-bd:#2c5373;
  --c-exp:#f29a85;--c-exp-bg:#3a1c16;--c-exp-bd:#6e3428;
  --c-exp-alt:#2a1814;--c-exp-alt2:#22140f;
  --c-total:#e9c77e;--c-total-bg:#33280f;--c-total-bd:#6b5420;
  --c-info:#7fd0bf;--c-info-bg:#15302b;--c-info-bd:#2c5a51;
  --paid-bg:var(--c-pay-bg);--paid-ink:var(--c-pay);
  --unpaid-bg:var(--c-exp-bg);--unpaid-ink:#f6a896;
  --other-bg:var(--c-other-bg);--other-ink:var(--c-other);
  --sum-bg:var(--c-total-bg);--sum-ink:var(--c-total);
  --tone-blue:var(--c-exp-alt);--tone-green:var(--c-exp-alt2);
  --bg:var(--paper);--card:var(--surface);--line:var(--hair);
}

/* ---------- المستندات تبقى بالألوان الفاتحة (مهم لملفات PDF) ---------- */
html[data-theme="dark"] :is(#reportRoot,#receiptPrintArea,#receiptRecordViewArea,#residentReceiptsContent,#printHost,
  .report-root,.report-year,.report-print-physical-page,.report-pdf-flow-host,.report-pdf-flow-frame,.pdf-native-preview-host,.pdf-fixed-paper,
  .receipt-document,.receipt-paper,.resident-receipt-capture-host,#userGuideFrame){
  color-scheme:light;color:#0f172a;
  --ink:#16231f;--ink-2:#2c3b36;--muted-ink:#6b7570;
  --paper:#f3efe6;--paper-2:#ebe5d8;--surface:#fffdf9;--surface-2:#f8f5ee;--hair:#e5ded0;--hair-2:#d5ccb9;
  --pine-50:#f0f7f3;--pine-100:#e1efe9;--pine-200:#c7e0d6;
  --brass-100:#f7ecd5;--brass-200:#ecd6a8;--brass-700:#8f6519;
  --ok:#2b7a4b;--ok-100:#e2f1e7;--ok-50:#f1f8f3;--bad:#b0412d;--bad-100:#f8e3dd;--bad-50:#fcf2ef;
  --warn:#b0731a;--warn-100:#faedd6;--plum:#5d4a8a;--plum-100:#ebe6f4;--sky:#2b6890;--sky-100:#e1edf5;--sky-50:#f1f6fa;
  --c-prev:#5b4691;--c-prev-bg:#ece6f7;--c-prev-bd:#bfb0e0;--c-pay:#1f6e3d;--c-pay-bg:#d3ecdc;--c-pay-bd:#8fc9a5;
  --c-other:#215d86;--c-other-bg:#dbe9f5;--c-other-bd:#9cc0dd;--c-exp:#a3361f;--c-exp-bg:#f8dcd3;--c-exp-bd:#e39e8b;
  --c-exp-alt:#fbe9e3;--c-exp-alt2:#fff6f2;--c-total:#7a5410;--c-total-bg:#f5e5c1;--c-total-bd:#d9b56b;
  --c-info:#155049;--c-info-bg:#e1efe9;--c-info-bd:#a9cfc1;
  --paid-bg:#d3ecdc;--paid-ink:#1f6e3d;--unpaid-bg:#f8dcd3;--unpaid-ink:#7f1d1d;--other-bg:#dbe9f5;--other-ink:#215d86;
  --sum-bg:#f5e5c1;--sum-ink:#7a5410;--tone-blue:#fbe9e3;--tone-green:#fff6f2;
  --bg:#f3efe6;--card:#fffdf9;--line:#e5ded0;
}
html[data-theme="dark"] #reportRoot{background:#fff!important;}

/* ---------- الخلفية والأسطح ---------- */
html[data-theme="dark"] #appView,html[data-theme="dark"] .app-shell,html[data-theme="dark"] .main{background:var(--paper)!important;color:var(--ink);}
html[data-theme="dark"] .modal-box{color:var(--ink);}
html[data-theme="dark"] body{background:radial-gradient(900px 500px at 100% 0%,rgba(28,106,96,.18),transparent 60%),var(--paper)!important;}
html[data-theme="dark"] .main-head{background:rgba(19,33,30,.92)!important;border-color:var(--hair)!important;}
html[data-theme="dark"] .main-head .head-title h1,html[data-theme="dark"] #viewTitle{color:var(--ink)!important;}
html[data-theme="dark"] .main-head .vt-year{background:#2e2614;border-color:#5b4a22;color:#e9c77e;}
html[data-theme="dark"] .year-box{background:var(--surface-2)!important;border-color:var(--hair)!important;}
html[data-theme="dark"] .year-box select,html[data-theme="dark"] .main-head .year-box select{background-color:#0f1c19!important;color:var(--ink)!important;border-color:var(--hair-2)!important;}
@media (max-width:980px){html[data-theme="dark"] .main-head .year-box select{background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23c9d5cf' stroke-width='2.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E")!important;}}
html[data-theme="dark"] .year-box button.success{background:var(--ok-100)!important;color:var(--ok)!important;border-color:#2a6143!important;}
html[data-theme="dark"] .year-box button.danger{background:var(--bad-50)!important;color:var(--bad)!important;border-color:#6e3428!important;}
html[data-theme="dark"] .view-tabs{background:var(--surface-2)!important;border-color:var(--hair)!important;}
html[data-theme="dark"] .view-tabs .nav-item{color:var(--ink-2)!important;}
html[data-theme="dark"] .view-tabs .nav-item.active{background:var(--surface)!important;color:var(--ink)!important;}
html[data-theme="dark"] .main .app-status-footer{color:var(--muted-ink)!important;border-color:var(--hair-2)!important;}
html[data-theme="dark"] .main .app-status-footer b{color:var(--ink-2)!important;}

html[data-theme="dark"] .main .section,html[data-theme="dark"] .smart-dashboard,html[data-theme="dark"] .ssb-chart-card,html[data-theme="dark"] .quick-link,
html[data-theme="dark"] .expense-form{background:var(--surface)!important;border-color:var(--hair)!important;color:var(--ink);box-shadow:var(--shadow-sm)!important;}
html[data-theme="dark"] .main .section h2,html[data-theme="dark"] .main .section h3,html[data-theme="dark"] .panel-head h3,html[data-theme="dark"] .panel-title h3,
html[data-theme="dark"] .smart-dashboard h2,html[data-theme="dark"] .quick-link b{color:var(--ink)!important;}
html[data-theme="dark"] .panel-head p,html[data-theme="dark"] .quick-link span{color:var(--muted-ink)!important;}
html[data-theme="dark"] .legend .lg{background:var(--surface-2)!important;border-color:var(--hair-2)!important;color:var(--ink-2)!important;}
html[data-theme="dark"] .smart-metric{background:var(--surface-2)!important;border-color:var(--hair)!important;}
html[data-theme="dark"] .smart-metric span,html[data-theme="dark"] .smart-metric small{color:var(--muted-ink)!important;}
html[data-theme="dark"] .smart-metric b{color:var(--ink)!important;}
html[data-theme="dark"] .smart-dashboard-year{background:var(--pine-200)!important;color:#fff!important;}
html[data-theme="dark"] .smart-alert{background:var(--surface-2)!important;border-color:var(--hair-2)!important;color:var(--ink-2)!important;}
html[data-theme="dark"] .smart-alert.warn{background:#2e2410!important;border-color:#5b4a22!important;color:#ecd29b!important;}
html[data-theme="dark"] .smart-alert.good{background:#12271f!important;border-color:#2a6143!important;color:#a9e2c2!important;}

/* البطاقات المالية */
html[data-theme="dark"] .main .cards .card.c-bal{background:radial-gradient(240px 120px at 0% 0%,rgba(184,134,47,.25),transparent 70%),linear-gradient(140deg,#1c6a60,#0b2b28)!important;border-color:#2c5a51!important;}

/* ---------- الجداول في التطبيق ---------- */
html[data-theme="dark"] :is(#paymentsWrap,#expensesWrap) table{background:var(--surface)!important;border-color:#2f4842!important;}
html[data-theme="dark"] :is(#paymentsWrap,#expensesWrap) td{border-color:#2f4842!important;color:var(--ink);}
html[data-theme="dark"] :is(#paymentsWrap,#expensesWrap) th{border-color:#2f4842!important;}
html[data-theme="dark"] :is(#paymentsWrap,#expensesWrap) input,html[data-theme="dark"] :is(#paymentsWrap,#expensesWrap) select{color:var(--ink)!important;background:transparent!important;border-color:transparent!important;}
html[data-theme="dark"] #paymentsWrap .name-cell{background:#182925!important;}
html[data-theme="dark"] #paymentsWrap .name-cell input{color:var(--ink)!important;}
html[data-theme="dark"] #paymentsWrap .note-cell{background:var(--surface)!important;}
html[data-theme="dark"] #paymentsWrap .pay-cell.month-paid{background:var(--c-pay-bg)!important;}
html[data-theme="dark"] #paymentsWrap .pay-cell.month-paid input{color:var(--c-pay)!important;}
html[data-theme="dark"] #paymentsWrap .pay-cell.month-unpaid{background:var(--c-exp-bg)!important;}
html[data-theme="dark"] #paymentsWrap .pay-cell.month-unpaid input{color:#f6a896!important;}
html[data-theme="dark"] #paymentsWrap .pay-cell.other-payment-cell{background:var(--c-other-bg)!important;}
html[data-theme="dark"] #paymentsWrap .pay-cell.other-payment-cell input{color:var(--c-other)!important;}
html[data-theme="dark"] #paymentsWrap .sum-cell{background:var(--c-total-bg)!important;color:var(--c-total)!important;}
html[data-theme="dark"] #paymentsWrap .month-total-row td{background:#2a2410!important;color:#e9c77e!important;}
html[data-theme="dark"] #paymentsWrap .month-total-row td:first-child{background:#0b2b28!important;color:#fff!important;}
html[data-theme="dark"] #paymentsWrap .resident-account-btn{background:#2e2614!important;color:#e9c77e!important;border-color:#5b4a22!important;}
html[data-theme="dark"] #expensesWrap tr td{background:transparent;}
html[data-theme="dark"] #expensesWrap .expense-tone-blue td{background:#24150f!important;}
html[data-theme="dark"] #expensesWrap .expense-tone-green td{background:#1b120d!important;}
html[data-theme="dark"] #expensesWrap .expense-total-row td,html[data-theme="dark"] #expensesWrap tfoot td{background:#2a2410!important;color:#e9c77e!important;}
html[data-theme="dark"] :is(#paymentsWrap,#expensesWrap) input[type="date"]{color-scheme:dark;}

/* ---------- الحقول العامة في التطبيق والنوافذ ---------- */
html[data-theme="dark"] :is(.main,.modal-box,#loginView) :is(input:not([type=checkbox]):not([type=radio]):not([type=file]),select,textarea):not(#paymentsWrap *):not(#expensesWrap *):not(#reportRoot *){
  background-color:#0f1c19!important;color:var(--ink)!important;border-color:var(--hair-2)!important;
}
html[data-theme="dark"] :is(input,textarea)::placeholder{color:#6f817a!important;}

/* ---------- النوافذ ---------- */
html[data-theme="dark"] .modal{background:rgba(2,8,7,.72)!important;}
html[data-theme="dark"] .modal-box,html[data-theme="dark"] #receiptModal .modal-box,html[data-theme="dark"] #receiptRecordViewModal .modal-box,
html[data-theme="dark"] #reportsModal .modal-box,html[data-theme="dark"] #residentReceiptsModal .modal-box{background:var(--surface)!important;border-color:var(--hair)!important;}
html[data-theme="dark"] .modal-box :is(.receipt-form,.form-grid,.profile-section,.backup-card,.backup-section,.resident-receipts-toolbar,.resident-receipts-filter-row,.resident-receipts-summary,.users-stats,.system-health-summary>*,.monitor-card,.subscription-plan,.plan-card,.backup-status-box,.backup-list,.receipts-ledger-filters){
  background:var(--surface-2)!important;border-color:var(--hair)!important;color:var(--ink-2)!important;
}
html[data-theme="dark"] .modal button.purple,html[data-theme="dark"] .modal button.secondary,html[data-theme="dark"] .modal button.teal,
html[data-theme="dark"] .modal #previewReceiptBtn,html[data-theme="dark"] .modal #refreshUsersBtn,html[data-theme="dark"] .modal #refreshReceiptsLedgerBtn{
  background:var(--surface-2)!important;color:var(--ink)!important;border-color:var(--hair-2)!important;
}
html[data-theme="dark"] .modal button.danger{background:var(--bad-50)!important;color:var(--bad)!important;border-color:#6e3428!important;}
html[data-theme="dark"] #reportsModal .actions{background:var(--surface-2)!important;border-color:var(--hair)!important;}
html[data-theme="dark"] #reportsModal .actions>select{background-color:#0f1c19!important;color:var(--ink)!important;border-color:var(--hair-2)!important;}
html[data-theme="dark"] .receipts-ledger-table-wrap,html[data-theme="dark"] .monitor-table-wrap{background:var(--surface)!important;border-color:var(--hair)!important;}

/* ---------- البحث والرسم ---------- */
html[data-theme="dark"] .ssb-search{background:var(--surface)!important;border-color:var(--hair-2)!important;}
html[data-theme="dark"] .main .ssb-search input#residentSearchInput{background:transparent!important;border:0!important;}
html[data-theme="dark"] .ssb-search-count{background:#15302b;color:#9fd8c6;}
html[data-theme="dark"] .ssb-chart-head h3,html[data-theme="dark"] .ssb-chart-tip b{color:var(--ink)!important;}
html[data-theme="dark"] .side-brand small,html[data-theme="dark"] .al-sub{color:#a9c9bf!important;}
html[data-theme="dark"] .smart-dashboard-year{background:#1c6a60!important;}
html[data-theme="dark"] .ssb-chart-body .hit.on{fill:rgba(255,255,255,.05);}

/* ---------- شاشة الدخول ---------- */
html[data-theme="dark"] #loginView{background:radial-gradient(900px 500px at 100% 0%,rgba(28,106,96,.25),transparent 60%),#0b1513!important;}
html[data-theme="dark"] .login-split,html[data-theme="dark"] .login-split .login-card{background:var(--surface)!important;border-color:var(--hair)!important;}
html[data-theme="dark"] .login-split .login-card h1{color:var(--ink)!important;}
html[data-theme="dark"] .login-lead,html[data-theme="dark"] .login-label,html[data-theme="dark"] .login-version{color:var(--muted-ink)!important;}
html[data-theme="dark"] .remember-login-row{background:var(--surface-2)!important;border-color:var(--hair)!important;color:var(--ink-2)!important;}

/* ---------- عناصر أخرى ---------- */
html[data-theme="dark"] .toast{background:#1d302b!important;color:var(--ink)!important;border-color:var(--hair-2)!important;}
html[data-theme="dark"] ::-webkit-scrollbar-thumb{background:#2f4842;}


/* نصوص النوافذ (خارج مناطق المستندات) */
html[data-theme="dark"] .modal-box :is(label,p,small,span,li,h3,h4,h5,b,strong,div.label,.muted):not(#reportRoot *):not(#receiptPrintArea *):not(#receiptRecordViewArea *):not(#residentReceiptsContent *):not(button *):not(.whatsapp-btn):not(.plan-badge){color:var(--ink-2)!important;}
html[data-theme="dark"] .modal-box :is(h3,h4,b,strong):not(#reportRoot *):not(#receiptPrintArea *):not(#receiptRecordViewArea *):not(#residentReceiptsContent *):not(button *){color:var(--ink)!important;}
html[data-theme="dark"] .modal-box :is(.system-health-summary>*,.monitor-stat,.monitor-card,.smart-metric,.health-card,.users-stat,.stat-card,[class*="-card"]):not(#reportRoot *):not(#receiptPrintArea *):not(#receiptRecordViewArea *):not(#residentReceiptsContent *):not(.receipt-paper){background:var(--surface-2)!important;border-color:var(--hair)!important;}
html[data-theme="dark"] .modal button.warning{background:#33260f!important;color:#ecd29b!important;border-color:#5b4a22!important;}
html[data-theme="dark"] .modal-box input[type=file]{color-scheme:dark;color:var(--ink-2)!important;background:#0f1c19!important;border-color:var(--hair-2)!important;}

} /* end @media screen */

@media screen{
html[data-theme="dark"] #residentAccountModal .modal-box,html[data-theme="dark"] .resident-account-box{background:var(--surface)!important;}
html[data-theme="dark"] .resident-account-head,html[data-theme="dark"] .resident-account-section,html[data-theme="dark"] .resident-account-note,
html[data-theme="dark"] .resident-account-cards>*,html[data-theme="dark"] .resident-month-grid>*{background:var(--surface-2)!important;border-color:var(--hair)!important;color:var(--ink-2)!important;}
html[data-theme="dark"] #residentAccountName{color:var(--ink)!important;}
html[data-theme="dark"] .resident-history-table td{background:var(--surface)!important;color:var(--ink)!important;border-color:var(--hair-2)!important;}
}
