/* ═══════════════════════════════════════════
   Dashboard CSS — Aftab | IberLex360
   ═══════════════════════════════════════════ */
/* Imports auth CSS tokens then extends */

/* ── Layout ── */
.dash-layout{display:flex;min-height:100vh;background:var(--bg)}
.dash-main{flex:1;display:flex;flex-direction:column;min-width:0;overflow:hidden}
.dash-content{flex:1;padding:1.5rem;overflow-y:auto}

/* ── Sidebar ── */
.sidebar{width:230px;background:var(--bg2);border-left:1px solid var(--border);
  display:flex;flex-direction:column;flex-shrink:0;transition:transform .3s;z-index:var(--z-side)}
.sidebar-overlay{display:none;position:fixed;inset:0;background:rgba(0,0,0,.5);z-index:var(--z-overlay);
  backdrop-filter:blur(2px)}

.sb-head{padding:1.1rem .9rem;border-bottom:1px solid var(--border);
  display:flex;align-items:center;gap:.75rem}
.sb-logo{width:44px;height:44px;object-fit:contain;background:transparent;flex-shrink:0}
.sb-company{display:flex;flex-direction:column;gap:2px;min-width:0}
.sb-co-name{font-size:var(--fs-base);font-weight:800;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.sb-user{font-size:var(--fs-xs);color:var(--text2);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}

.role-pill{display:inline-block;padding:1px 7px;border-radius:var(--radius-lg);font-size:.62rem;font-weight:700;width:fit-content}
.role-admin  {background:rgba(var(--gold-rgb),.2);color:var(--gold)}
.role-staff  {background:rgba(59,130,246,.2);color:var(--info-text)}
.role-viewer {background:rgba(100,116,139,.2);color:#94a3b8}

.sb-nav{flex:1;padding:.6rem .45rem;overflow-y:auto;display:flex;flex-direction:column;gap:2px}
.sb-footer{padding:.6rem .45rem;border-top:1px solid var(--border);display:flex;flex-direction:column;gap:2px}

.nav-item{display:flex;align-items:center;gap:.65rem;padding:.62rem .8rem;border-radius:var(--radius-sm);
  width:100%;color:var(--text2);font-size:.83rem;font-weight:500;transition:background-color .18s, border-color .18s, color .18s, box-shadow .18s, transform .18s, opacity .18s;cursor:pointer;
  background:none;border:none;text-align:right}
.nav-item:hover{background:var(--bg3);color:var(--text)}
.nav-item.active{background:var(--gold-dim);color:var(--gold);border:1px solid rgba(var(--gold-rgb),.25)}
.nav-item.danger{color:var(--bad-text)}
.nav-item.danger:hover{background:rgba(239,68,68,.1);color:var(--danger)}
.nav-icon{font-size:1rem;flex-shrink:0;width:18px;text-align:center}
.nav-label{flex:1}
/* ── گروه بازشوندهٔ نوار کناری ── */
.nav-group-toggle .nav-caret{font-size:var(--fs-xs);transition:transform .2s;opacity:.7}
.nav-group-toggle.open .nav-caret{transform:rotate(180deg)}
.nav-group-toggle.open{color:var(--text)}
.nav-subgroup{display:none;flex-direction:column;gap:2px;position:relative;z-index:1;
  margin:2px .2rem 2px;padding-right:.5rem;border-right:2px solid var(--gold-dim)}
.nav-subgroup.open{display:flex !important}
.nav-item.nav-sub{font-size:var(--fs-sm);padding:.5rem .7rem;color:var(--text3)}
.nav-item.nav-sub:hover{color:var(--text)}
.nav-item.nav-sub.active{background:var(--gold-dim);color:var(--gold)}
/* ── شمارش + نوع درخواست/اقامتِ منو ── */
.nav-count{margin-inline-start:auto;flex-shrink:0;font-size:.62rem;font-weight:800;color:var(--text3);
  background:rgba(128,128,128,.16);border-radius:999px;min-width:1.15rem;text-align:center;
  padding:.02rem .38rem;font-variant-numeric:tabular-nums}
.nav-subhead{font-size:.64rem;font-weight:800;color:var(--text3);opacity:.65;letter-spacing:.02em;
  padding:.55rem .7rem .2rem}
.nav-cat-toggle{cursor:pointer}
.nav-cat-toggle .nav-caret-sm{flex-shrink:0;margin-inline-start:.3rem;font-size:.58rem;opacity:.6;transition:transform .2s}
.nav-cat-toggle.open .nav-caret-sm{transform:rotate(180deg)}
.nav-catkids{display:none;flex-direction:column;gap:2px;margin-inline-start:.55rem;padding-inline-start:.35rem;
  border-inline-start:1px solid var(--border)}
.nav-catkids.open{display:flex}
.nav-item.nav-leaf{font-size:.76rem;padding:.4rem .7rem;color:var(--text3)}
.nav-item.nav-leaf .nav-icon{font-size:.48rem;opacity:.65}
.nav-count-leaf{background:var(--gold-dim);color:var(--gold)}
.nav-empty-sub{font-size:.68rem;color:var(--text3);opacity:.55;padding:.3rem .7rem}
.nav-divider{height:1px;background:var(--border);margin:.6rem .4rem}
.nav-sub .nav-ext{font-size:var(--fs-xs);opacity:.5;flex-shrink:0}
.nav-item.nav-sub:hover .nav-ext{opacity:.9;color:var(--gold)}
.nav-sub .nav-soon{font-size:.6rem;font-weight:700;color:var(--text3);background:var(--bg3);
  border:1px solid var(--border);border-radius:var(--radius-xs);padding:1px 6px;flex-shrink:0;white-space:nowrap}
.nav-sub .nav-soon.pulse{color:var(--gold);border-color:var(--gold-dim)}
.hamburger{display:none;font-size:1.3rem;color:var(--text2);padding:4px;background:none;border:none;cursor:pointer}

/* ── Topbar ── */
.topbar{padding:.8rem 1.25rem;border-bottom:1px solid var(--border);background:var(--bg2);
  display:flex;align-items:center;gap:.75rem;position:sticky;top:0;z-index:var(--z-bar);flex-shrink:0}
.topbar-title{font-size:1rem;font-weight:700;flex:1;order:1}
.topbar-right{display:flex;align-items:center;gap:.75rem;order:2}
.topbar-tools{order:3}
.tb-cal-btn{width:auto !important;padding:0 .6rem !important;gap:.35rem}
.tb-cal-label{font-size:var(--fs-xs);font-weight:700}
.co-pill{padding:.28rem .75rem;border-radius:var(--radius-lg);font-size:var(--fs-xs);font-weight:700;
  font-family:var(--font-en);background:var(--gold-dim);color:var(--gold);border:1px solid rgba(var(--gold-rgb),.3)}
.co-pill[data-company="aftab"]{background:rgba(139,0,0,.15);color:var(--bad-text);border-color:rgba(139,0,0,.35)}

/* ── Breadcrumb ── */
.breadcrumb{font-size:var(--fs-base);color:var(--text2);margin-bottom:1rem}
.breadcrumb a{color:var(--gold);font-weight:500}
.breadcrumb a:hover{text-decoration:underline}

/* ── Stats Grid ── */
.stats-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(180px,1fr));gap:1rem;margin-bottom:1.5rem}
.stat-card{background:var(--bg2);border:1px solid var(--border);border-radius:var(--radius);
  padding:1.25rem;display:flex;flex-direction:column;gap:.4rem;transition:transform .2s;
  min-height:8.25rem;                 /* 🚀 ارتفاع رزروشده — با لودِ فونت نپرد */
  contain:layout style;               /* تغییرِ داخل کارت، بقیهٔ صفحه را reflow نکند */
}
.stat-card:hover{transform:translateY(-2px)}
.stat-card.accent{border-color:rgba(var(--gold-rgb),.3);background:var(--gold-dim)}
.stat-icon{font-size:1.6rem}
.stat-val{font-size:1.6rem;font-weight:800;color:var(--text);font-family:var(--font-en);
  line-height:1.25;min-height:2rem;font-variant-numeric:tabular-nums}
.stat-label{font-size:var(--fs-sm);color:var(--text2);font-weight:500}
.stat-sub{font-size:var(--fs-xs);color:var(--text3)}

/* ── Panels ── */
.panel{background:var(--bg2);border:1px solid var(--border);border-radius:var(--radius);
  padding:1.25rem;margin-bottom:1rem}
.panel-head{display:flex;align-items:center;justify-content:space-between;margin-bottom:1rem}
.panel-head h3{font-size:var(--fs-md);font-weight:700}
.dash-grid-2{display:grid;grid-template-columns:1fr 1fr;gap:1rem}
.section-card{background:var(--bg2);border:1px solid var(--border);border-radius:var(--radius);
  padding:1.25rem;margin-bottom:1rem}
.section-head{display:flex;align-items:center;justify-content:space-between;margin-bottom:1rem}
.section-head h3{font-size:var(--fs-md);font-weight:700}

/* ── Tables ── */
.table-wrap{overflow-x:auto;border-radius:var(--radius-sm);border:1px solid var(--border)}
.dtable{width:100%;border-collapse:collapse;font-size:var(--fs-base)}
.dtable th{background:var(--bg3);padding:.65rem .9rem;text-align:right;font-weight:700;
  color:var(--text2);font-size:var(--fs-sm);letter-spacing:.03em;white-space:nowrap}
.dtable td{padding:.7rem .9rem;border-bottom:1px solid var(--border);color:var(--text);vertical-align:middle}
.dtable tr:last-child td{border-bottom:none}
.dtable tbody tr:hover{background:var(--bg3)}
.dtable tr.overdue td{color:var(--bad-text)}
.empty-cell{text-align:center;color:var(--text3);padding:2rem!important}
.td-num{color:var(--text3);font-size:var(--fs-sm)}
.td-actions{display:flex;gap:.35rem;align-items:center;white-space:nowrap}
.amount-cell{font-family:var(--font-en);font-weight:600;text-align:right;white-space:nowrap}

/* ── Badges ── */
.status-badge{display:inline-block;padding:2px 8px;border-radius:var(--radius-lg);font-size:var(--fs-xs);font-weight:700}
.status-active    {background:rgba(16,185,129,.15);color:var(--ok-text);border:1px solid rgba(16,185,129,.3)}
.status-completed {background:rgba(59,130,246,.15);color:var(--info-text);border:1px solid rgba(59,130,246,.3)}
.status-cancelled {background:rgba(239,68,68,.15);color:var(--bad-text);border:1px solid rgba(239,68,68,.3)}
.status-pending   {background:rgba(245,158,11,.15);color:var(--warn-text);border:1px solid rgba(245,158,11,.3)}
.status-paid      {background:rgba(16,185,129,.15);color:var(--ok-text)}
.status-overdue   {background:rgba(239,68,68,.15);color:var(--bad-text)}

.method-badge{display:inline-block;padding:2px 8px;border-radius:var(--radius-xs);font-size:var(--fs-xs);font-weight:700;font-family:var(--font-en)}
.method-cash          {background:rgba(16,185,129,.15);color:var(--ok-text)}
.method-revolut       {background:rgba(99,102,241,.2);color:var(--indigo-text)}
.method-bbva          {background:rgba(59,130,246,.2);color:var(--info-text)}
.method-bank_transfer {background:rgba(245,158,11,.15);color:var(--warn-text)}
.method-crypto        {background:rgba(168,85,247,.2);color:var(--purple-text)}

.tx-badge{display:inline-block;padding:2px 8px;border-radius:var(--radius-xs);font-size:var(--fs-xs);font-weight:700}
.tx-deposit   {background:rgba(16,185,129,.15);color:var(--ok-text)}
.tx-withdrawal{background:rgba(239,68,68,.15);color:var(--bad-text)}
.tx-allocation{background:rgba(var(--gold-rgb),.15);color:var(--gold)}
.tx-expense   {background:rgba(239,68,68,.15);color:var(--bad-text)}
.tx-return    {background:rgba(16,185,129,.15);color:var(--ok-text)}

.acc-type-badge{display:inline-block;padding:2px 8px;border-radius:var(--radius-xs);font-size:var(--fs-xs);font-weight:700;font-family:var(--font-en)}
.acc-bank    {background:rgba(59,130,246,.15);color:var(--info-text)}
.acc-cash    {background:rgba(16,185,129,.15);color:var(--ok-text)}
.acc-revolut {background:rgba(99,102,241,.2);color:var(--indigo-text)}
.acc-bbva    {background:rgba(30,64,175,.2);color:var(--info-text)}
.acc-crypto  {background:rgba(168,85,247,.2);color:var(--purple-text)}

.svc-type{display:inline-block;padding:2px 8px;border-radius:var(--radius-xs);font-size:var(--fs-xs);background:var(--bg3);color:var(--text2)}

.office-tag{display:inline-block;padding:2px 8px;border-radius:var(--radius-xs);font-size:var(--fs-xs);font-weight:700;background:var(--bg3);color:var(--text2)}

.status-dot{display:inline-block;width:8px;height:8px;border-radius:50%}
.status-dot.on {background:var(--ok)}
.status-dot.off{background:#64748b}

/* ── Buttons ── */
.btn-primary{background:var(--gold);color:#0a0a0a;border:none;padding:.65rem 1.2rem;
  border-radius:var(--radius-sm);font-size:var(--fs-base);font-weight:700;cursor:pointer;transition:background-color .18s, border-color .18s, color .18s, box-shadow .18s, transform .18s, opacity .18s;
  font-family:var(--font-fa);white-space:nowrap}
.btn-primary:hover{opacity:.9;transform:translateY(-1px)}
.btn-secondary{background:var(--bg3);color:var(--text);border:1px solid var(--border);
  padding:.65rem 1.2rem;border-radius:var(--radius-sm);font-size:var(--fs-base);font-weight:600;cursor:pointer;
  transition:background-color .18s, border-color .18s, color .18s, box-shadow .18s, transform .18s, opacity .18s;font-family:var(--font-fa)}
.btn-secondary:hover{border-color:var(--gold);color:var(--gold)}
.btn-ghost{background:transparent;color:var(--text2);border:1px solid var(--border);
  padding:.65rem 1.2rem;border-radius:var(--radius-sm);font-size:var(--fs-base);cursor:pointer;
  font-family:var(--font-fa);transition:background-color .18s, border-color .18s, color .18s, box-shadow .18s, transform .18s, opacity .18s}
.btn-ghost:hover{background:var(--bg3);color:var(--text)}
.btn-icon{background:none;border:none;cursor:pointer;font-size:1rem;padding:.3rem .4rem;
  border-radius:var(--radius-xs);transition:background .15s}
.btn-icon:hover{background:var(--bg3)}
.btn-icon.danger:hover{background:rgba(239,68,68,.15);color:var(--danger)}
.btn-tiny{background:var(--bg3);border:1px solid var(--border);border-radius:var(--radius-xs);
  padding:.25rem .6rem;font-size:var(--fs-xs);font-weight:600;cursor:pointer;color:var(--text2);
  font-family:var(--font-fa);transition:background-color .15s, border-color .15s, color .15s, box-shadow .15s, transform .15s, opacity .15s}
.btn-tiny:hover{border-color:var(--gold);color:var(--gold)}
.btn-tiny.outline{background:transparent;border-color:rgba(var(--gold-rgb),.4);color:var(--gold)}
.btn-link{background:none;border:none;cursor:pointer;color:var(--gold);font-size:var(--fs-sm);
  font-family:var(--font-fa);padding:.2rem .4rem}
.btn-link:hover{text-decoration:underline}
.btn-link.danger{color:var(--bad-text)}
.mt-8{margin-top:.5rem}

/* ── Toolbar / Search ── */
.toolbar{display:flex;gap:.75rem;align-items:center;justify-content:space-between;margin-bottom:1.25rem;flex-wrap:wrap}
.search-form{display:flex;gap:.4rem}
.search-input{padding:.6rem 1rem;background:var(--bg2);border:1px solid var(--border);border-radius:var(--radius-sm);
  color:var(--text);font-size:var(--fs-base);font-family:var(--font-fa);outline:none;min-width:200px}
.search-input:focus{border-color:var(--gold)}
.filter-form select{padding:.6rem 1rem;background:var(--bg2);border:1px solid var(--border);
  border-radius:var(--radius-sm);color:var(--text);font-size:var(--fs-base);font-family:var(--font-fa);outline:none;cursor:pointer}
.action-row{display:flex;gap:.75rem;align-items:center;margin-bottom:1.25rem;flex-wrap:wrap}

/* ── Modals ── */
.modal-backdrop{display:none;position:fixed;inset:0;z-index:var(--z-modal);
  background:rgba(0,0,0,.6);backdrop-filter:blur(3px);
  align-items:center;justify-content:center;padding:1rem}
/* 🔧 مودال روی موبایل: تمام‌صفحه، بالای هدر و فوتر، با ناحیهٔ امنِ گوشی.
   (مودال با JS به <body> منتقل می‌شود تا از کانتینرِ اسکرول‌شونده آزاد باشد.) */
@media (max-width: 899px){
  .modal-backdrop{
    padding:0;
    align-items:flex-end;          /* از پایین بالا می‌آید — دمِ دستِ انگشت */
    overflow:hidden;
  }
  .modal{
    width:100%;max-width:100%;
    margin:0;
    border-radius:18px 18px 0 0;
    max-height:92dvh;
    overflow-y:auto;
    -webkit-overflow-scrolling:touch;
    padding:1.25rem 1.1rem calc(1.25rem + env(safe-area-inset-bottom));
    animation:modalUp .22s ease;
  }
  .modal-lg{max-width:100%}
  /* دستگیرهٔ بالای شیت */
  .modal::before{
    content:'';display:block;width:38px;height:4px;border-radius:99px;
    background:var(--border);margin:-.35rem auto .8rem;
  }
  /* وقتی مودال باز است، هدر/فوتر پشتِ آن قفل شوند */
  html.modal-open .topbar,
  html.modal-open .pwa-bottombar{z-index:1 !important}
  html.modal-open body{overflow:hidden}
}
@keyframes modalUp{from{opacity:0;transform:translateY(24px)}to{opacity:1;transform:none}}
.modal-backdrop.open{display:flex}
.modal{background:var(--bg2);border:1px solid var(--border);border-radius:var(--radius-lg);
  padding:1.75rem;width:100%;max-width:480px;max-height:90vh;overflow-y:auto;
  box-shadow:0 20px 60px rgba(0,0,0,.5);animation:modalIn .2s ease}
.modal-lg{max-width:620px}
@keyframes modalIn{from{opacity:0;transform:translateY(20px) scale(.96)}to{opacity:1;transform:none}}
.modal-head{display:flex;align-items:center;justify-content:space-between;margin-bottom:1.5rem}
.modal-head h3{font-size:1rem;font-weight:700}
.modal-close{background:none;border:none;font-size:var(--fs-lg);cursor:pointer;color:var(--text2);
  width:32px;height:32px;display:flex;align-items:center;justify-content:center;
  border-radius:50%;transition:background .15s}
.modal-close:hover{background:var(--bg3)}
.modal-form{display:flex;flex-direction:column;gap:0}
.modal-form .field{margin-bottom:.9rem}
.modal-actions{display:flex;gap:.75rem;margin-top:.5rem}
.field{display:flex;flex-direction:column;gap:.3rem}
.field label{font-size:var(--fs-sm);font-weight:600;color:var(--text2)}
.field input,.field select,.field textarea{
  padding:.65rem .9rem;background:var(--bg3);border:1px solid var(--border);
  border-radius:var(--radius-sm);color:var(--text);font-size:var(--fs-base);font-family:var(--font-fa);outline:none;direction:rtl}
.field input:focus,.field select:focus,.field textarea:focus{border-color:var(--gold);box-shadow:0 0 0 3px rgba(var(--gold-rgb),.12)}
.field textarea{resize:vertical}
.form-grid-2{display:grid;grid-template-columns:1fr 1fr;gap:0 .9rem}
.checkbox-group{display:flex;flex-direction:column;gap:.5rem}
.checkbox-label{display:flex;align-items:center;gap:.65rem;cursor:pointer;padding:.65rem .9rem;
  background:var(--bg3);border:1px solid var(--border);border-radius:var(--radius-sm);transition:border-color .15s;font-size:var(--fs-base)}
.checkbox-label:has(input:checked){border-color:var(--gold);background:var(--gold-dim)}
.checkbox-label input[type=checkbox]{width:16px;height:16px;accent-color:var(--gold)}
.inline-form{display:flex;gap:.5rem;flex-wrap:wrap;align-items:center;padding-top:.75rem;
  border-top:1px solid var(--border);margin-top:.75rem}
.inp-sm{padding:.35rem .65rem;background:var(--bg3);border:1px solid var(--border);border-radius:var(--radius-xs);
  color:var(--text);font-size:var(--fs-sm);font-family:var(--font-fa);outline:none;min-width:0;flex:1}
.inp-sm:focus{border-color:var(--gold)}

/* ── Tabs ── */
.tabs-bar{display:flex;gap:.4rem;margin-bottom:1.25rem;background:var(--bg2);
  border:1px solid var(--border);padding:5px;border-radius:var(--radius);flex-wrap:wrap}
.tab-btn{padding:.55rem 1rem;border-radius:var(--radius-sm);font-size:var(--fs-base);font-weight:600;
  color:var(--text2);background:none;border:none;cursor:pointer;transition:background-color .18s, border-color .18s, color .18s, box-shadow .18s, transform .18s, opacity .18s;font-family:var(--font-fa)}
.tab-btn:hover{color:var(--text);background:var(--bg3)}
.tab-btn.active{background:var(--gold);color:#0a0a0a;font-weight:800}
.tab-content{display:none}
.tab-content.active{display:block}

/* ── Cash Management ── */
.cash-holders-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(200px,1fr));gap:1rem;margin-bottom:1rem}
.holder-card{background:var(--bg2);border:1px solid var(--border);border-radius:var(--radius);padding:1.25rem}
.hc-name{font-size:1rem;font-weight:800;margin-bottom:.15rem}
.hc-company{font-size:var(--fs-xs);color:var(--text3);margin-bottom:.75rem}
.hc-balances{display:flex;flex-direction:column;gap:.4rem}
.hc-bal-row{display:flex;align-items:center;justify-content:space-between;gap:.5rem}
.hc-bal-row.neg .hc-amount{color:var(--bad-text)}
.hc-cur{font-size:var(--fs-xs);color:var(--text3);font-family:var(--font-en);width:32px}
.hc-amount{font-size:var(--fs-md);font-weight:700;font-family:var(--font-en)}
.hc-tag{font-size:.62rem;color:var(--danger);background:rgba(239,68,68,.1);padding:1px 5px;border-radius:var(--radius-xs)}
.safe-summary{margin-bottom:1.25rem}
.safe-summary h3{font-size:var(--fs-md);font-weight:700;margin-bottom:.75rem}
.safe-balances{display:flex;flex-wrap:wrap;gap:.75rem}
.safe-bal-card{background:var(--bg2);border:1px solid var(--border);border-radius:var(--radius);
  padding:1rem 1.5rem;text-align:center;min-width:120px}
.safe-bal-card.neg{border-color:rgba(239,68,68,.3);background:rgba(239,68,68,.05)}
.sbc-cur{font-size:var(--fs-sm);font-weight:700;color:var(--text2);font-family:var(--font-en)}
.sbc-amount{font-size:1.4rem;font-weight:800;font-family:var(--font-en);color:var(--gold)}
.safe-bal-card.neg .sbc-amount{color:var(--bad-text)}
.sbc-tag{font-size:.62rem;color:var(--danger)}

/* ── Overview cash/safe ── */
.holder-list{display:flex;flex-direction:column;gap:.6rem}
.holder-row{display:flex;align-items:center;justify-content:space-between;gap:.75rem;
  padding:.6rem .8rem;background:var(--bg3);border-radius:var(--radius-sm)}
.holder-name{font-weight:700;font-size:var(--fs-base);min-width:80px}
.holder-bals{display:flex;flex-wrap:wrap;gap:.4rem}
.bal-chip{padding:2px 8px;border-radius:var(--radius-xs);font-size:var(--fs-xs);font-family:var(--font-en);
  font-weight:600;background:rgba(var(--gold-rgb),.15);color:var(--gold)}
.bal-chip.neg{background:rgba(239,68,68,.15);color:var(--bad-text)}
.safe-row{display:flex;justify-content:space-between;align-items:center;
  padding:.55rem .8rem;background:var(--bg3);border-radius:var(--radius-sm);margin-bottom:.5rem}
.safe-cur{font-size:var(--fs-xs);font-family:var(--font-en);font-weight:700;color:var(--text2)}
.safe-bal{font-size:1rem;font-weight:800;font-family:var(--font-en);color:var(--gold)}
.safe-bal.neg{color:var(--bad-text)}

/* ── Contract Block ── */
.contract-block{border:1px solid var(--border);border-radius:var(--radius);padding:1.1rem;margin-bottom:1rem}
.contract-block:last-child{margin-bottom:0}
.contract-header{display:flex;align-items:flex-start;justify-content:space-between;margin-bottom:.5rem;flex-wrap:wrap;gap:.5rem}
.contract-title-area{display:flex;align-items:center;gap:.5rem;flex-wrap:wrap}
.ct-title{font-weight:700;font-size:var(--fs-md)}
.ct-type{font-size:var(--fs-xs);color:var(--text3);background:var(--bg3);padding:1px 7px;border-radius:var(--radius-xs)}
.contract-amount{font-family:var(--font-en);font-size:var(--fs-md);font-weight:700;color:var(--gold);text-align:left}
.ct-remain{font-size:var(--fs-sm);color:var(--text2);font-weight:400}
.ct-desc{font-size:var(--fs-sm);color:var(--text2);margin-bottom:.5rem}
.ct-dates{font-size:var(--fs-sm);color:var(--text3);margin-bottom:.75rem;display:flex;gap:1rem}
.contract-actions{display:flex;gap:.5rem;margin-top:.75rem;padding-top:.75rem;border-top:1px solid var(--border)}

/* ── Payment Terms ── */
.terms-wrap{margin:.75rem 0}
.terms-wrap h5{font-size:var(--fs-sm);font-weight:700;color:var(--text2);margin-bottom:.5rem}
.terms-list{display:flex;flex-direction:column;gap:.35rem}
.term-row{display:flex;align-items:center;gap:.75rem;padding:.5rem .75rem;border-radius:var(--radius-sm);
  background:var(--bg3);font-size:var(--fs-sm);flex-wrap:wrap}
.term-row.status-paid   {opacity:.6}
.term-row.status-overdue{background:rgba(239,68,68,.08);border:1px solid rgba(239,68,68,.2)}
.term-desc{flex:1;min-width:80px;color:var(--text2)}
.term-amount{font-family:var(--font-en);font-weight:700}
.term-date{color:var(--text3);font-size:var(--fs-xs)}
.term-status{font-size:var(--fs-xs);color:var(--text3)}

/* ── Customer Totals ── */
.totals-row{display:flex;flex-wrap:wrap;gap:.85rem;margin-bottom:1.25rem}
.total-card{background:var(--bg2);border:1px solid var(--border);border-radius:var(--radius);
  padding:1.1rem 1.25rem;min-width:160px;flex:1;
  contain:layout style}
.total-cur{font-size:var(--fs-xs);font-family:var(--font-en);font-weight:800;color:var(--text3);margin-bottom:.3rem}
.total-main{font-size:1.5rem;font-weight:800;font-family:var(--font-en);color:var(--gold);
  line-height:1.3;min-height:2rem;font-variant-numeric:tabular-nums}
.total-sub{font-size:var(--fs-xs);color:var(--text2);margin-bottom:.5rem}
.total-detail{display:flex;gap:.4rem;font-size:var(--fs-sm);margin-bottom:.5rem}
.paid{color:var(--ok-text)}.sep{color:var(--text3)}.owed{color:var(--text2)}
.progress-bar{height:4px;background:var(--bg3);border-radius:2px;overflow:hidden}
.progress-fill{height:100%;background:var(--gold);border-radius:2px;transition:width .4s}

/* ── Expense ── */
.expense-summary{display:grid;grid-template-columns:repeat(3,1fr);gap:1rem;margin-bottom:1.25rem}
.exp-office-card{background:var(--bg2);border:1px solid var(--border);border-radius:var(--radius);padding:1rem}
.eo-title{font-size:var(--fs-base);font-weight:700;margin-bottom:.5rem}
.eo-row{display:flex;justify-content:space-between;font-size:var(--fs-sm);padding:.2rem 0}
.eo-amount{font-family:var(--font-en);font-weight:600;color:var(--gold)}

/* ── Settings ── */
.settings-list{display:flex;flex-direction:column;gap:.5rem}
.settings-row{display:flex;align-items:center;justify-content:space-between;
  padding:.75rem 1rem;background:var(--bg3);border-radius:var(--radius-sm);gap:.75rem}
.sr-main{display:flex;align-items:center;gap:.65rem;flex:1;flex-wrap:wrap}
.sr-badge{font-size:var(--fs-lg);min-width:24px;text-align:center}
.sr-sub{font-size:var(--fs-sm);color:var(--text2)}.sr-sub.en{font-family:var(--font-en)}
.sr-actions{display:flex;align-items:center;gap:.5rem}

/* ── Reports ── */
.reports-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(220px,1fr));gap:1.25rem}
.report-card{background:var(--bg2);border:1px solid var(--border);border-radius:var(--radius-lg);padding:1.5rem;
  display:flex;flex-direction:column;gap:.75rem}
.rc-icon{font-size:2.2rem}
.report-card h3{font-size:var(--fs-md);font-weight:700}
.report-card p{font-size:var(--fs-base);color:var(--text2)}
.rpt-section{background:var(--bg2);border:1px solid var(--border);border-radius:var(--radius);padding:1.1rem;margin-bottom:1rem}
.rpt-section h3{font-size:var(--fs-md);font-weight:700;margin-bottom:.75rem}
.report-header{display:grid;grid-template-columns:1fr 1fr;gap:1.5rem;background:var(--bg2);
  border:1px solid var(--border);border-radius:var(--radius);padding:1.25rem;margin-bottom:1.25rem}
.rh-info h2{font-size:var(--fs-lg);font-weight:800;margin-bottom:.5rem}
.rh-info p{font-size:var(--fs-base);color:var(--text2);margin-bottom:.25rem}
.rh-summary{display:flex;flex-direction:column;gap:.6rem}
.rhs-row{display:flex;gap:.75rem;align-items:flex-start;font-size:var(--fs-base)}
.rhs-row span:first-child{font-family:var(--font-en);font-weight:700;color:var(--text3);width:40px}
.paid-txt{color:var(--ok-text)}.debt-txt{color:var(--bad-text)}
.report-footer{text-align:center;font-size:var(--fs-sm);color:var(--text3);margin-top:1rem;padding-top:1rem;border-top:1px solid var(--border)}
.print-actions{display:flex;gap:.75rem;margin-bottom:1.25rem}

/* ── Date cell ──
   🚀 رفع پرشِ عرضِ ستون‌های تاریخ (۱.۹.۱۱۷): سرور تاریخِ خامِ میلادی می‌فرستد
   (مثلاً 2026-03-01)، بعد applyDates() آن را با تاریخِ فرمت‌شده (مثلاً «۱۰ اسفند ۱۴۰۴»)
   جایگزین می‌کند. چون طولِ متن فرق می‌کند، بدونِ رزروِ عرض، ستونِ جدول می‌پرید.
   راه‌حل: حداقل‌عرض ثابت برای بلندترین حالتِ ممکن، + مخفی‌ماندن تا وقتی JS آماده شود
   (دقیقاً همان الگویِ cal-ready که برای input[type=date] استفاده شده). */
.date-cell{font-family:var(--font-en);font-size:var(--fs-sm);white-space:nowrap;
  display:inline-block;min-width:8.5em;font-variant-numeric:tabular-nums}
html:not(.cal-ready) .date-cell{visibility:hidden}
.date-now{font-size:var(--fs-sm);color:var(--text3)}
/* ── ویجت ساعت و تقویم ──
   🚀 رفع پرشِ بزرگِ صفحه (۱.۹.۱۱۷): ویجتِ ساعت در HTML کاملاً خالی رندر می‌شود و
   clock.js آن را پس از اجرا با innerHTML پر می‌کند — یعنی ارتفاعش از صفر به ارتفاعِ کامل
   می‌پرد و کلِ محتوایِ زیرش را پایین می‌راند. با رزروِ حداقل‌ارتفاع (بسته به اینکه
   ساعتِ آنالوگ فعال است یا نه — کلاسِ cw-analog سمتِ سرور تعیین می‌شود)، این پرش رفع می‌شود. */
.clock-widget{display:flex;flex-direction:row;flex-wrap:wrap;align-items:center;justify-content:center;gap:.5rem .8rem;
  padding:.35rem .7rem;background:var(--bg3);border-radius:var(--radius-sm);border:1px solid var(--border);
  width:max-content;max-width:min(640px,60vw);min-height:2.3rem}
.clock-widget.cw-analog{min-height:5.4rem}
.clocks-wrap{display:flex;gap:.9rem;align-items:center;flex-wrap:wrap}
.clock-block{display:flex;flex-direction:column;gap:2px;align-items:center}
.clock-row{display:flex;align-items:center;gap:.45rem;white-space:nowrap}
.clock-zone{font-size:.66rem;color:var(--text3);font-weight:700}
.clock-time{font-family:'Courier New',monospace;font-size:var(--fs-base);font-weight:700;
  direction:ltr;min-width:64px;text-align:center}
.cal-block{display:flex;flex-direction:row;flex-wrap:wrap;gap:.55rem;align-items:center;
  border-right:1px dashed var(--border);padding-right:.7rem}
.cal-line{font-size:.64rem;color:var(--text2);white-space:nowrap}
.cal-line + .cal-line{border-right:1px solid var(--border);padding-right:.55rem}
.cal-line.en{direction:ltr}
/* ساعت آنالوگ */
svg.analog{width:62px;height:62px}
.analog .aface{fill:var(--bg2);stroke:var(--border);stroke-width:1.5}
.analog .aring{stroke-width:2.5;opacity:.85}
.analog .atick{stroke:var(--text3);stroke-width:1}
.analog .ahour{stroke:var(--text);stroke-width:3;stroke-linecap:round}
.analog .amin{stroke:var(--text);stroke-width:2;stroke-linecap:round}
.analog .asec{stroke:var(--gold);stroke-width:1;stroke-linecap:round}
.analog .acenter{fill:var(--gold)}
.analog .astatus{stroke:var(--bg2);stroke-width:1}
@media (max-width: 768px){.clock-widget{min-width:0;max-width:100%;width:auto}.cal-line{font-size:.58rem}.clock-time{font-size:.74rem;min-width:54px}}

/* ── Misc ── */
.empty-msg{color:var(--text3);font-size:var(--fs-base);padding:.75rem;text-align:center}
.name-link{color:var(--text);font-weight:600}
.name-link:hover{color:var(--gold)}
.small{font-size:.7rem!important}

/* ═══ RESPONSIVE ═══ */
@media (max-width: 1024px){
  .dash-grid-2{grid-template-columns:1fr}
  .expense-summary{grid-template-columns:1fr}
  .report-header{grid-template-columns:1fr}
}
@media (max-width: 768px){
  /* جلوگیری از سرریز افقی صفحه: وگرنه سایدبارِ position:fixed با right:0
     به لبهٔ راستِ نمای چیدمان (بیرون از دید) می‌چسبد و «نمایان نمی‌شود». */
  html,body{overflow-x:hidden}
  .hamburger{display:flex;flex-shrink:0}
  /* تاپ‌بار در موبایل wrap شود تا ساعت/تاریخ و منوی کاربر در یک ردیفِ کامل دیده شوند */
  .topbar{flex-wrap:wrap;row-gap:.5rem}
  .topbar-title{min-width:0;flex:1 1 auto}
  .topbar-right{width:100%;justify-content:flex-start;flex-wrap:wrap;gap:.5rem .6rem}
  /* هدر (تاپ‌بار + ساعت) هنگام اسکرول ثابت بماند: ارتفاعِ لایه قفل، فقط محتوا اسکرول شود.
     این قفل فقط باید مخصوصِ صفحاتِ داشبورد/CRM باشد (که ساختارِ .dash-layout دارند)،
     وگرنه صفحاتِ دیگر مثلِ لندینگ که چنین ظرفِ اسکرولِ داخلی‌ای ندارند، کلاً غیرِقابلِ‌اسکرول می‌شوند. */
  html:has(.dash-layout), body:has(.dash-layout){height:100%;overflow:hidden}
  .dash-layout{height:100vh;height:100dvh;min-height:0;overflow:hidden}
  .dash-main{height:100%;min-height:0;overflow:hidden}
  .topbar{position:sticky;top:0;z-index:var(--z-bar)}
  .dash-content{flex:1 1 auto;min-height:0;overflow-y:auto;-webkit-overflow-scrolling:touch}
  .sidebar{position:fixed;top:0;right:0;height:100%;width:min(86vw,280px);
    transform:translateX(100%);z-index:var(--z-mnav)}
  .sidebar.open{transform:translateX(0)}
  .sidebar-overlay{z-index:calc(var(--z-mnav) - 1)}
  .sidebar-overlay.open{display:block}
  .stats-grid{grid-template-columns:repeat(2,1fr)}
  .totals-row .total-card{min-width:130px}
  .form-grid-2{grid-template-columns:1fr}
  .tabs-bar{flex-wrap:nowrap;overflow-x:auto;-webkit-overflow-scrolling:touch;scrollbar-width:none}
  .tabs-bar::-webkit-scrollbar{display:none}
  .tabs-bar .tab-btn{flex-shrink:0}
  .cash-holders-grid{grid-template-columns:1fr 1fr}
  .modal{padding:1.25rem}
  .topbar-title{font-size:var(--fs-md)}
  .dtable{font-size:var(--fs-sm)}
  .dtable th,.dtable td{padding:.5rem .65rem}
}
@media (max-width: 480px){
  .stats-grid{grid-template-columns:1fr}
  .cash-holders-grid{grid-template-columns:1fr}
  .toolbar{flex-direction:column;align-items:stretch}
  .search-form,.search-input{width:100%}
}

/* ═══ PRINT ═══ */
@media print{
  .sidebar,.topbar,.action-row,.breadcrumb,.btn-primary,.btn-secondary,.btn-ghost,.print-actions{display:none!important}
  .dash-main{margin:0}
  .dash-content{padding:0}
  body{background:#fff;color:#000}
  .panel,.section-card,.rpt-section{border:1px solid #ccc!important;background:#fff!important}
  .dtable th{background:#f5f5f5!important;color:#333!important}
}

/* ─── Light mode adjustments ─── */
[data-theme="light"] .btn-primary{color:#fff}
[data-theme="light"] .tab-btn.active{color:#fff}
[data-theme="light"] .nav-item.active{color:#7a5c00}
[data-theme="light"] .role-admin{color:#7a5c00}
[data-theme="light"] .co-pill{color:#7a5c00}
[data-theme="light"] .total-main,[data-theme="light"] .sbc-amount,[data-theme="light"] .safe-bal{color:#7a5c00}

/* ═══ Customer info bar ═══ */
.cust-info-bar{display:flex;flex-wrap:wrap;gap:.75rem;background:var(--bg2);border:1px solid var(--border);border-radius:var(--radius);padding:1rem 1.25rem;margin-bottom:1.25rem}
.cib-item{display:flex;flex-direction:column;gap:.25rem;min-width:120px;padding-left:1rem;border-left:1px solid var(--border)}
.cib-item:last-child{border-left:none}
.cib-label{font-size:var(--fs-xs);color:var(--text-muted);font-weight:600}
.cib-item span:last-child{font-size:var(--fs-md);font-weight:700}

/* ═══ Form section title ═══ */
.form-section-title{font-size:var(--fs-md);font-weight:700;color:var(--accent);margin:1.25rem 0 .75rem;padding-right:.6rem;border-right:3px solid var(--accent);display:flex;align-items:center;justify-content:space-between;gap:.5rem}

/* ═══ Terms builder (dynamic rows) ═══ */
.terms-builder{display:flex;flex-direction:column;gap:.5rem;margin-bottom:.5rem}
.term-builder-row{display:grid;grid-template-columns:2fr 1.3fr 1.3fr auto;gap:.5rem;align-items:center}
@media (max-width: 768px){.term-builder-row{grid-template-columns:1fr 1fr;gap:.4rem}}

/* ═══ Commission chip ═══ */
.comm-chip{display:inline-block;background:rgba(var(--gold-rgb),.15);color:var(--accent);padding:2px 10px;border-radius:var(--radius-lg);font-size:var(--fs-sm);font-weight:700;white-space:nowrap}

/* ═══ Contract number ═══ */
.ct-num{display:inline-block;background:var(--bg3);color:var(--text-muted);padding:1px 9px;border-radius:var(--radius-xs);font-size:var(--fs-sm);font-weight:700;font-family:'Outfit',monospace;margin-left:.4rem}

/* ═══ Debt amount (red highlight in total cards) ═══ */
.debt-amount{color:#e05260 !important}

/* ═══ Report total row (tfoot) ═══ */
.total-row{background:var(--bg3);border-top:2px solid var(--border)}
.total-row td{padding-top:.85rem;padding-bottom:.85rem}

/* ══════════════ Cash position grid (overview) ══════════════ */
.section-label { font-size:1rem; font-weight:700; margin:1.5rem 0 .75rem; color:var(--text); }
.cash-grid {
  display:grid; grid-template-columns:repeat(auto-fill,minmax(180px,1fr));
  gap:.85rem; margin-bottom:1.5rem;
}
/* ── دو ستونِ مستقل در پیشخوان (ارتفاعشان به هم وابسته نیست) ── */
/* ── نوارِ افقیِ موجودی (صندوق/تنخواه/مدیران/حساب‌ها) بالای پیشخوان ── */
.ov-cash-strip {
  display:grid; grid-template-columns:repeat(auto-fit,minmax(190px,1fr));
  gap:.85rem; margin-bottom:.85rem; align-items:stretch;
}
.ov-cash-strip .cash-card{display:flex;flex-direction:column}
/* ── دو ستون: قراردادها | وضعیت مالی (هم‌ارتفاع) ── */
.ov-cols {
  display:flex; align-items:stretch; gap:.85rem; margin-bottom:1.5rem;
}
.ov-col { min-width:0; display:flex; flex-direction:column; gap:.85rem; }
.ov-col-contracts { flex:1 1 32%; }
.ov-col-fin       { flex:1 1 68%; }
.ov-col > .cash-card{flex:1 1 auto}
/* کارتِ قراردادها: محتوا وسط‌چینِ عمودی تا فضای خالی نماند */
.ov-contracts-card{justify-content:center}
.ov-contracts-card .cash-card-head{align-self:stretch}
/* موجودیِ کارت‌های نوار پایین بچسبد تا ارقام هم‌تراز شوند */
.ov-cash-strip .cash-card .cash-card-head{margin-bottom:auto}
.ov-cash-strip .cash-card .cash-line:first-of-type{margin-top:.6rem}
@media (max-width:640px){
  .ov-cash-strip { grid-template-columns:1fr 1fr; gap:.6rem; margin-bottom:.6rem; }
  .ov-cols { gap:.6rem; }
  .ov-col-contracts, .ov-col-fin { flex:1 1 0; }
}
.cash-card {
  background:var(--bg2); border:1px solid var(--border); border-radius:var(--radius);
  padding:.9rem 1rem; box-shadow:var(--shadow-sm); border-top:3px solid var(--gold);
}
.cash-card.safe   { border-top-color:var(--ok-strong); }
.cash-card.petty  { border-top-color:#ef6c00; }
.cash-card.holder { border-top-color:var(--navy); }
.cash-card.account { border-top-color:#6a1b9a; }
.cash-card-head {
  display:flex; justify-content:space-between; align-items:center;
  font-weight:700; font-size:var(--fs-md); margin-bottom:.6rem;
}
.cash-card-head .link-sm { font-size:var(--fs-lg); text-decoration:none; color:var(--gold); }
.cash-line {
  display:flex; justify-content:space-between; align-items:center;
  padding:.25rem 0; font-size:var(--fs-md); border-top:1px dashed var(--border);
}
.cash-line:first-of-type { border-top:none; }
.cash-line b { font-variant-numeric:tabular-nums; }
.cash-line.neg b { color:var(--bad-strong); }
.cash-line.muted { color:var(--muted); }
.cash-subhead {
  font-size:var(--fs-sm); font-weight:700; color:var(--muted);
  margin:.55rem 0 .1rem; padding-top:.4rem; border-top:1px solid var(--border);
}
.cash-subhead:first-of-type { border-top:none; padding-top:0; margin-top:.2rem; }
.cash-card.receivable .cash-line { border-top:none; padding:.18rem 0; }

/* ══════════════ Term progress (partial payments) ══════════════ */
.term-progress { display:flex; flex-direction:column; gap:3px; min-width:130px; }
.tp-bar { height:7px; background:var(--border); border-radius:var(--radius-xs); overflow:hidden; }
.tp-fill { display:block; height:100%; background:linear-gradient(90deg,var(--ok-strong),var(--ok)); border-radius:var(--radius-xs); transition:width .3s; }
.tp-text { font-size:var(--fs-xs); color:var(--muted); font-variant-numeric:tabular-nums; }
.term-row.status-partial { border-right:3px solid #ef6c00; }
.term-row.status-paid    { border-right:3px solid var(--ok-strong); }
.pay-term-hint {
  background:#fff7e6; color:#8a5a00; border:1px solid #ffd591;
  padding:.5rem .75rem; border-radius:var(--radius-sm); font-size:var(--fs-base); margin-bottom:.75rem;
}
[data-theme="dark"] .pay-term-hint { background:#3a2f1a; color:#ffd591; border-color:#7a5a1a; }
/* ── نرخ تبدیل ارز ── */
.fx-block {
  background: rgba(var(--gold-rgb), .08);
  border: 1px solid rgba(var(--gold-rgb), .35);
  border-radius: var(--radius-sm);
  padding: .6rem .75rem; margin-bottom: .75rem;
}
.fx-preview { font-size: var(--fs-sm); color: var(--muted); line-height: 1.7; }
.fx-preview.ok { color: var(--text); }
.fx-preview.ok b { color: var(--gold); }
.fx-tag { display:block; font-size:var(--fs-xs); color:var(--gold); margin-top:2px; font-weight:600; }
small.hint { display:block; font-size:var(--fs-xs); color:var(--muted); margin-top:3px; }

/* ══════════════ Profit & Loss report ══════════════ */
.pnl-table td { padding:.55rem .9rem; }
.pnl-table .pnl-group td { background:var(--bg3,#f0f0f5); font-weight:700; color:var(--navy); }
[data-theme="dark"] .pnl-table .pnl-group td { background:#1a2240; color:var(--gold); }
.pnl-table .pnl-subtotal td { font-weight:700; border-top:1px solid var(--border); }
.pnl-table .pnl-total td {
  font-weight:800; font-size:1.02rem; border-top:2px solid var(--gold);
  background:#f5fff5; color:#1b5e20;
}
.pnl-table .pnl-total.cash td { background:#fffbe6; color:#7a5a00; }
.pnl-table .pnl-total.neg td { background:#fff0f0; color:#b71c1c; }
[data-theme="dark"] .pnl-table .pnl-total td { background:#13301a; color:#a5d6a7; }
[data-theme="dark"] .pnl-table .pnl-total.cash td { background:#332a10; color:#ffe082; }
[data-theme="dark"] .pnl-table .pnl-total.neg td { background:#3a1414; color:#ef9a9a; }
.pnl-table .paid { color:var(--ok-strong); }

/* ══════════════ Customer report currency rows ══════════════ */
.cur-rows { display:flex; flex-direction:column; gap:.4rem; }
.cur-row {
  display:flex; gap:.6rem; align-items:center; flex-wrap:wrap;
  padding:.35rem .5rem; border-radius:var(--radius-sm); background:var(--bg);
  border:1px solid var(--border);
}
.cur-tag {
  display:inline-block; padding:2px 8px; border-radius:var(--radius-xs);
  background:var(--navy); color:#fff; font-weight:700; font-size:var(--fs-sm);
  font-family:'Outfit',sans-serif; min-width:42px; text-align:center;
}
.cr-item { font-size:var(--fs-base); }
.cr-k { color:var(--muted); font-size:var(--fs-sm); margin-left:3px; }
.cr-item b { font-variant-numeric:tabular-nums; }
.credit-txt { color:var(--ok-strong); }

/* ══════════════ Payer toggle (customer/company) ══════════════ */
.payer-toggle {
  display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; margin-bottom: .85rem;
}
.payer-opt {
  display: flex; align-items: center; gap: .5rem;
  padding: .7rem 1rem; border-radius:var(--radius-sm); cursor: pointer;
  border: 2px solid var(--border); background: var(--bg2);
  font-weight: 600; font-size:var(--fs-md); transition:background-color .15s, border-color .15s, color .15s, box-shadow .15s, transform .15s, opacity .15s;
}
.payer-opt:hover { border-color: var(--gold); }
.payer-opt input[type="radio"] { width: auto; margin: 0; accent-color: var(--gold); }
.payer-opt.active {
  border-color: var(--gold); background: rgba(var(--gold-rgb),.12);
  box-shadow: 0 2px 8px rgba(var(--gold-rgb),.15);
}
@media (max-width: 768px) {
  .payer-toggle { grid-template-columns: 1fr; }
}

/* ══════════════ Backup tab ══════════════ */
.backup-card {
  background:var(--bg2); border:1px solid var(--border); border-radius:var(--radius);
  padding:1.2rem 1.4rem; margin-bottom:1rem; border-right:4px solid var(--gold);
}
.backup-card h4 { margin:0 0 .5rem; font-size:1rem; }
.backup-card .hint { margin:.4rem 0 1rem; line-height:1.9; }
.backup-card .btn-primary, .backup-card .btn-danger {
  display:inline-block; margin-top:.4rem;
}
.backup-card form { margin-top:.3rem; }
.backup-card .field { margin-bottom:.7rem; }
.backup-card.warn { border-right-color:var(--bad-strong); }
.backup-card .badge {
  display:inline-block; padding:2px 8px; border-radius:var(--radius-xs);
  background:var(--navy); color:#fff; font-size:var(--fs-xs); margin-right:6px; margin-left:4px;
  font-family:'Outfit',sans-serif; vertical-align:middle;
}
.warn-txt { color:var(--bad-strong); }
.alert-success {
  background:rgba(46,125,50,.15); color:#1b5e20; padding:.75rem 1rem;
  border-radius:var(--radius-sm); border-right:4px solid var(--ok-strong); margin-bottom:1rem;
}
[data-theme="dark"] .alert-success { color:#a5d6a7; }
.btn-danger {
  background:var(--bad-strong); color:#fff; border:none; padding:.6rem 1.4rem;
  border-radius:var(--radius-sm); font-weight:600; cursor:pointer;
}
.btn-danger:hover { background:#b71c1c; }

/* ══════════════ Form subsection title ══════════════ */
.form-subsection-title {
  font-size:var(--fs-base); font-weight: 700; margin: .6rem 0 .4rem;
  color: var(--gold); display: flex; align-items: center; gap: .4rem;
}

/* ══════════════ Filter form (customers list) ══════════════ */
.filter-form { display:flex; gap:.4rem; flex-wrap:wrap; align-items:center; flex:1; }
.filter-select {
  padding:.45rem .6rem; border:1px solid var(--border); border-radius:var(--radius-sm);
  background:var(--bg2); color:var(--text); font-size:var(--fs-base);
  font-family:'Vazirmatn',sans-serif; min-width:140px;
}
.filter-select:focus { border-color:var(--gold); outline:none; }
.btn-tiny { font-size:var(--fs-sm); padding:.3rem .6rem; }

/* ══════════════ Dashboard contracts/receivable cards ══════════════ */
.cash-card.contracts { border-top-color:#1565c0; }
.cash-card.receivable { border-top-color:#c9a227; }
.cash-card.contracts .cash-card-head,
.cash-card.receivable .cash-card-head { font-size:var(--fs-md); }
.cash-card.contracts b,
.cash-card.receivable b { font-size:var(--fs-lg); }

/* ══════════════ Personnel list ══════════════ */
.hc-meta { font-size:var(--fs-sm); color:var(--muted); margin-top:.4rem; padding-top:.4rem; border-top:1px dashed var(--border); }

/* ══════════════ Expenses page — compact stat cards ══════════════ */
.exp-stats {
  display:grid; grid-template-columns:repeat(auto-fit, minmax(240px, 1fr));
  gap:.75rem; margin-bottom:1rem;
}
.exp-stat-card {
  background:var(--bg2); border:1px solid var(--border); border-radius:var(--radius);
  padding:.75rem 1rem; border-top:3px solid var(--gold);
  display:flex; flex-direction:column; gap:.4rem;
}
.exp-stat-head { font-size:var(--fs-base); font-weight:700; color:var(--text); }
.exp-stat-amounts { display:flex; flex-wrap:wrap; gap:.35rem; }
.exp-stat-chip {
  background:rgba(var(--gold-rgb),.12); color:var(--gold);
  padding:.2rem .55rem; border-radius:var(--radius-xs); font-size:var(--fs-sm); font-weight:600;
  font-family:'Outfit', 'Vazirmatn', sans-serif;
}
.exp-stat-meta { font-size:var(--fs-xs); color:var(--muted); }

/* Checkbox row inside form */
.checkbox-row {
  display:flex; align-items:center; gap:.5rem; cursor:pointer;
  padding:.55rem .8rem; background:rgba(var(--gold-rgb),.08); border-radius:var(--radius-sm);
  border:1px solid var(--border); font-weight:600; font-size:var(--fs-base);
}
.checkbox-row input[type="checkbox"] { width:auto; margin:0; accent-color:var(--gold); }

/* ══════════════ Shareholders / Profit page ══════════════ */
.profit-block { padding:1rem; background:var(--bg2); border-radius:var(--radius-sm); margin-bottom:1.5rem; border-right:4px solid var(--gold); }
.profit-cur { margin:0 0 .5rem; color:var(--gold); font-size:var(--fs-lg); }
.profit-subhead { margin:1rem 0 .5rem; font-size:var(--fs-md); color:var(--text); }
.profit-grid { display:grid; grid-template-columns:1fr; gap:.3rem; margin-bottom:.5rem; }
.pf-row { display:flex; justify-content:space-between; padding:.5rem .8rem; background:var(--bg); border-radius:var(--radius-xs); font-size:var(--fs-md); }
.pf-row.income { border-right:3px solid var(--ok-strong); }
.pf-row.out { border-right:3px solid var(--bad-strong); }
.pf-row.sum { background:rgba(var(--gold-rgb),.1); font-weight:700; }
.pf-row.profit { background:rgba(46,125,50,.15); font-weight:700; color:var(--ok-strong); border-right:3px solid var(--ok-strong); }
[data-theme="dark"] .pf-row.profit { color:#81c784; }
.profit-warn { background:rgba(255,152,0,.12); color:#e65100; padding:.6rem 1rem; border-radius:var(--radius-xs); margin-top:.5rem; border-right:3px solid #ff9800; font-size:var(--fs-md); }
.profit-ok { background:rgba(46,125,50,.1); color:var(--ok-strong); padding:.6rem 1rem; border-radius:var(--radius-xs); margin-top:.5rem; border-right:3px solid var(--ok-strong); font-size:var(--fs-md); }
[data-theme="dark"] .profit-ok { color:#81c784; }
.inline-input { width:80px; padding:.3rem .5rem; border:1px solid var(--border); border-radius:var(--radius-xs); background:var(--bg); color:var(--text); }
.totals-row { background:rgba(var(--gold-rgb),.1); font-weight:700; }
.archived-card { opacity:.7; border-right:4px solid var(--muted); }

/* ══════════════ Date input with Jalali/Gregorian toggle ══════════════ */
.cal-input-wrap {
  display:flex; align-items:stretch; gap:0;
  border:1px solid var(--border); border-radius:var(--radius-sm);
  background:var(--bg); overflow:hidden;
  position:relative;
  min-height:var(--input-h, 42px);   /* هم‌اندازه با input عادی ⇒ بعد از JS نپرد */
}
/* 🚀 رفع قطعیِ پرشِ فیلدِ تاریخ (۱.۹.۱۱۱)
   مشکل: JS بعد از نمایشِ صفحه، input[type=date] را با ساختارِ جدید جایگزین می‌کرد
   و کاربر جهشِ عرض/ارتفاع را می‌دید.
   راه‌حل: فیلدِ خام از همان اول «نامرئی ولی جا‌گرفته» است؛ وقتی JS ساختارِ نهایی را
   ساخت، فقط visible می‌شود — هیچ تغییرِ اندازه‌ای رخ نمی‌دهد. */
input[type="date"]{
  min-height:var(--input-h, 42px);
  width:100%;
  box-sizing:border-box;
}
/* تا آماده‌شدنِ JS: جا اشغال است ولی محتوا دیده نمی‌شود (بدون پرش) */
html:not(.cal-ready) input[type="date"]{ visibility:hidden; }
/* ساختارِ نهایی دقیقاً همان ابعاد را دارد */
.cal-input-wrap{ width:100%; box-sizing:border-box; }
.cal-input-disp {
  flex:1; border:none !important; background:transparent !important;
  padding:.55rem .8rem; color:var(--text); font-family:inherit;
  font-size:var(--fs-md); outline:none; direction:ltr; text-align:start;
  min-width:0;
}
.cal-input-disp:focus { background:rgba(var(--gold-rgb),.05) !important; }
.cal-input-toggle {
  border:none; background:rgba(var(--gold-rgb),.08); color:var(--gold);
  padding:0 .65rem; font-size:var(--fs-sm); font-weight:700;
  cursor:pointer; font-family:inherit; white-space:nowrap;
  transition:background .2s;
}
.cal-input-toggle:hover { background:rgba(var(--gold-rgb),.2); }
.cal-input-native {
  width:0; height:0; padding:0; margin:0; border:none !important;
  background:transparent !important; position:absolute; left:0; top:0;
  opacity:0; pointer-events:none;
}
.cal-input-picker {
  border:none; background:rgba(var(--gold-rgb),.08); cursor:pointer;
  padding:0 .65rem; font-size:1rem;
  border-left:1px solid var(--border); border-right:1px solid var(--border);
  transition:background .2s;
}
.cal-input-picker:hover { background:rgba(var(--gold-rgb),.2); }

/* ── Jalali popup picker ── */
.jp-overlay {
  position:fixed; inset:0; z-index:var(--z-datepick);
  background:transparent; display:none;
}
.jp-overlay.open { display:block; }
/* موبایل: تقویم شمسی وسطِ صفحه (نه چسبیده به فیلد) تا زیر شیتِ مودال نرود */
@media (max-width: 899px){
  .jp-overlay{background:rgba(0,0,0,.45)}
  .jp-overlay.open{display:flex;align-items:center;justify-content:center;padding:1rem}
  .jp-popup{
    position:relative !important;
    top:auto !important;left:auto !important;right:auto !important;bottom:auto !important;
    width:100%;max-width:340px;max-height:85dvh;overflow-y:auto;
  }
}
.jp-popup {
  position:absolute; min-width:280px; z-index:calc(var(--z-datepick) + 1);
  background:var(--bg2); border:1px solid var(--border);
  border-radius:var(--radius-sm); box-shadow:0 4px 20px rgba(0,0,0,.25);
  padding:.7rem; direction:rtl; font-family:'Vazirmatn', sans-serif;
}
.jp-head {
  display:flex; align-items:center; gap:.4rem; justify-content:space-between;
  margin-bottom:.5rem; padding-bottom:.5rem; border-bottom:1px solid var(--border);
}
.jp-nav {
  background:var(--bg); border:1px solid var(--border); color:var(--text);
  padding:.3rem .6rem; border-radius:var(--radius-xs); cursor:pointer; font-size:var(--fs-base);
}
.jp-nav:hover { background:rgba(var(--gold-rgb),.1); }
.jp-month-yr { display:flex; gap:.3rem; align-items:center; }
.jp-month-yr select {
  padding:.3rem .5rem; background:var(--bg); border:1px solid var(--border);
  color:var(--text); border-radius:var(--radius-xs); font-family:inherit; font-size:var(--fs-base);
}
.jp-grid { display:grid; grid-template-columns:repeat(7, 1fr); gap:2px; }
.jp-day-header {
  text-align:center; padding:.3rem 0; font-size:var(--fs-xs);
  color:var(--muted); font-weight:700;
}
.jp-day {
  text-align:center; padding:.4rem 0; cursor:pointer;
  background:transparent; border:1px solid transparent; border-radius:var(--radius-xs);
  color:var(--text); font-size:var(--fs-base); font-family:inherit;
  font-feature-settings:"tnum";
}
.jp-day:hover { background:rgba(var(--gold-rgb),.15); border-color:var(--gold); }
.jp-day.empty { cursor:default; visibility:hidden; }
.jp-day.today { border-color:var(--gold); color:var(--gold); font-weight:700; }
.jp-day.selected { background:var(--gold); color:#fff; }
.jp-footer { display:flex; gap:.4rem; margin-top:.5rem; justify-content:space-between; }
.cal-input-toggle[data-mode="gregorian"] { color:#0d47a1; }
[data-theme="dark"] .cal-input-toggle[data-mode="gregorian"] { color:#90caf9; }

/* ══════════════ Petty Cash Settlement ══════════════ */
.settle-info { padding:1rem; background:rgba(var(--gold-rgb),.08); border-radius:var(--radius-sm); margin-bottom:1rem; }
.settle-options { display:flex; flex-direction:column; gap:.7rem; }
.settle-opt {
  display:flex; gap:.7rem; padding:1rem; background:var(--bg2); border:2px solid var(--border);
  border-radius:var(--radius-sm); cursor:pointer; transition:background-color .2s, border-color .2s, color .2s, box-shadow .2s, transform .2s, opacity .2s; align-items:flex-start;
}
.settle-opt:hover { border-color:var(--gold); }
.settle-opt input[type="radio"]:checked + .opt-body { color:var(--gold); }
.settle-opt input[type="radio"] { margin-top:.3rem; accent-color:var(--gold); }
.opt-body h5 { margin:0 0 .3rem; font-size:var(--fs-md); }
.opt-body p { margin:0; font-size:var(--fs-base); color:var(--muted); line-height:1.5; }
.settle-sub {
  padding:.6rem 1.5rem; background:rgba(var(--gold-rgb),.04);
  border-right:3px solid var(--gold); border-radius:var(--radius-xs); margin-right:1.5rem;
}

/* ══════════════ About + Help pages ══════════════ */
.about-wrap { max-width:900px; margin:0 auto; }
.about-card {
  background:var(--bg2); border:1px solid var(--border); border-radius:var(--radius);
  padding:1.5rem 1.8rem; margin-bottom:1.2rem;
  border-right:4px solid var(--gold);
}
.about-card.warning-card { border-right-color:var(--bad-strong); }
.about-card.author-card { text-align:center; border-right-color:transparent; background:linear-gradient(135deg, rgba(var(--gold-rgb),.1), rgba(13,27,94,.05)); }
.about-h { color:var(--gold); margin:0 0 .7rem; font-size:var(--fs-lg); }
.about-list { padding-right:1.5rem; line-height:1.9; }
.about-list li { margin-bottom:.3rem; }
.author-name { font-size:1.5rem; font-weight:700; color:var(--gold); margin:.4rem 0; }

/* Help section accordions */
.help-sections { display:flex; flex-direction:column; gap:.6rem; max-width:1000px; margin:0 auto; }
.help-section {
  background:var(--bg2); border:1px solid var(--border); border-radius:var(--radius-sm);
  overflow:hidden; transition:border-color .2s;
}
.help-section:hover { border-color:var(--gold); }
.help-section[open] { border-color:var(--gold); }
.help-section summary {
  padding:1rem 1.3rem; cursor:pointer; font-weight:700; font-size:var(--fs-md);
  background:rgba(var(--gold-rgb),.05); user-select:none;
  list-style:none; display:flex; align-items:center; gap:.5rem;
}
.help-section summary::-webkit-details-marker { display:none; }
.help-section summary::after { content:'▼'; margin-right:auto; font-size:var(--fs-xs); opacity:.5; transition:transform .2s; }
.help-section[open] summary::after { transform:rotate(180deg); }
.help-body { padding:1rem 1.5rem; line-height:1.9; }
.help-body ol { padding-right:1.5rem; }
.help-body li { margin-bottom:.4rem; }
.help-body ul { padding-right:1.3rem; margin:.3rem 0; }
.help-body code {
  background:rgba(var(--gold-rgb),.1); color:var(--gold); padding:.1rem .4rem;
  border-radius:var(--radius-xs); font-family:'Outfit', monospace; font-size:var(--fs-base);
}

/* ══════════════ Contract Reconciliation Banner ══════════════ */
.reconcile-banner {
  margin:.7rem 0 1rem; padding:1rem 1.2rem; border-radius:var(--radius-sm);
  border:2px solid;
}
.reconcile-banner.warn-up   { background:rgba(76,175,80,.08); border-color:#4caf50; }
.reconcile-banner.warn-down { background:rgba(255,152,0,.08); border-color:#ff9800; }
.rb-head { display:flex; gap:.8rem; align-items:flex-start; margin-bottom:.7rem; }
.rb-icon { font-size:1.8rem; flex-shrink:0; }
.rb-head h5 { margin:0 0 .3rem; font-size:1rem; }
.rb-head p { margin:0; font-size:var(--fs-base); line-height:1.7; }
.rb-head p.hint { color:var(--muted); margin-top:.3rem; }
.rb-actions { display:flex; flex-wrap:wrap; gap:.4rem; align-items:center; padding-top:.5rem; border-top:1px dashed var(--border); }
.up   { color:var(--ok-strong); font-weight:700; }
.down { color:var(--bad-strong); font-weight:700; }

/* ══════════ Document Number ══════════ */
.doc-no {
  font-family: 'Courier New', monospace; font-size:var(--fs-xs);
  background:rgba(var(--gold-rgb),.12); color:var(--gold);
  padding:.15rem .4rem; border-radius:var(--radius-xs); white-space:nowrap;
  letter-spacing:.5px; direction:ltr; display:inline-block;
}

/* ══════════ Expanded Settings ══════════ */
.settings-form { max-width: 820px; }
.form-section-title { font-size:var(--fs-lg); margin: 0 0 .3rem; color: var(--gold); }
.settings-form .field { margin-bottom: .9rem; }
.settings-form input[type="color"] {
  width: 48px; height: 34px; border: 1px solid var(--border);
  border-radius:var(--radius-xs); cursor: pointer; vertical-align: middle; padding: 2px;
}
.settings-form .inp-sm { width: 120px; margin-right: .5rem; vertical-align: middle; direction: ltr; }
.form-actions { display: flex; gap: .6rem; margin-top: 1rem; flex-wrap: wrap; }

.perm-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: .5rem; margin: .8rem 0; }
.perm-check { display: flex; align-items: center; gap: .5rem; padding: .5rem .7rem;
  background: rgba(255,255,255,.03); border-radius:var(--radius-sm); cursor: pointer; }
.perm-check input { width: 16px; height: 16px; }

.perm-table th, .perm-table td { padding: .35rem .5rem; font-size:var(--fs-base); }
.perm-table input[type="checkbox"] { width: 15px; height: 15px; cursor: pointer; }

/* ── ماتریس دسترسی سفارشی ── */
.cperm-tools{display:flex;gap:.4rem;margin:.4rem 0}
.role-pill.role-custom{background:rgba(139,92,246,.15);color:#a78bfa}
.perm-table th{font-size:var(--fs-xs);white-space:nowrap;padding:.4rem .3rem}
.perm-table td{padding:.4rem .3rem}

/* ── ناحیهٔ خطر (حذف کامل) ── */
.backup-card.danger-zone{border:2px solid var(--danger);background:rgba(239,68,68,.06)}
.backup-card.danger-zone h4{color:var(--danger)}

/* ── فیلد رمز با دکمهٔ نمایش ── */
.pw-wrap{position:relative;display:flex;align-items:center}
.pw-wrap input{flex:1;padding-left:2.2rem}
.pw-eye{position:absolute;left:6px;background:none;border:none;cursor:pointer;font-size:1rem;padding:2px 4px;opacity:.7}
.pw-eye:hover{opacity:1}

/* ── انتخاب محدودهٔ تنظیمات (شخصی/شرکت) ── */
.scope-box{background:var(--bg3);border:1px solid var(--border);border-radius:var(--radius-sm);padding:.6rem .8rem;margin:1rem 0}

/* ── منوی نواری انتخاب شهر (ساعات کاری) ── */
.city-toggle{display:flex;gap:.4rem;margin:.6rem 0 1rem;border-bottom:1px solid var(--border);padding-bottom:.5rem}
.city-btn{padding:.45rem 1.1rem;border-radius:var(--radius-sm);border:1px solid var(--border);
  background:var(--bg3);color:var(--text2);cursor:pointer;font-size:var(--fs-base);font-weight:600;transition:background-color .15s, border-color .15s, color .15s, box-shadow .15s, transform .15s, opacity .15s}
.city-btn:hover{color:var(--text)}
.city-btn.active{background:var(--gold);color:#1a1a2e;border-color:var(--gold)}
.city-panel{animation:fadeIn .2s}

.btn-tiny-danger{color:var(--danger);border-color:rgba(239,68,68,.4)}
.btn-tiny-danger:hover{background:rgba(239,68,68,.1)}

.readonly-field{background:var(--bg3);color:var(--text2);cursor:default;border-style:dashed}

/* ═══════════════════════════════════════════════════════════
   ✨ بازآرایی ظاهری مینیمال و حرفه‌ای — هر دو تم، ریسپانسیو
   (فقط استایل؛ ساختار HTML تغییری نکرده)
   ═══════════════════════════════════════════════════════════ */
:root{ --card-shadow:0 1px 2px rgba(0,0,0,.20),0 2px 8px rgba(0,0,0,.12); --card-radius:16px; }
[data-theme="light"]{ --card-shadow:0 1px 2px rgba(16,24,40,.04),0 6px 18px rgba(16,24,40,.07); }

/* کارت‌های آماری (CRM) — چیدمان ردیفی با چیپ آیکونِ رنگی، مثل داشبوردهای حرفه‌ای */
.stats-grid{gap:.85rem}
.stat-card{flex-direction:row;align-items:center;gap:.85rem;border-radius:var(--card-radius);
  padding:1.05rem 1.15rem;box-shadow:var(--card-shadow);
  transition:transform .18s,box-shadow .18s,border-color .18s}
.stat-card:hover{transform:translateY(-2px);box-shadow:0 10px 26px rgba(0,0,0,.14);
  border-color:color-mix(in srgb,var(--gold) 35%,var(--border))}
.stat-icon{display:flex;align-items:center;justify-content:center;width:46px;height:46px;flex:0 0 46px;
  border-radius:var(--radius);font-size:1.3rem;line-height:1;background:var(--gold-dim)}
.stat-card>div:last-child{display:flex;flex-direction:column;gap:.12rem;min-width:0}
.stat-val{font-size:1.5rem;line-height:1.12}
.stat-label{font-size:.76rem}
/* تنوع رنگِ ملایم چیپ‌ها (تینت کم‌رنگ — مینیمال در هر دو تم) */
.stats-grid .stat-card:nth-child(6n+1) .stat-icon{background:rgba(59,130,246,.15)}
.stats-grid .stat-card:nth-child(6n+2) .stat-icon{background:rgba(16,185,129,.15)}
.stats-grid .stat-card:nth-child(6n+3) .stat-icon{background:rgba(139,92,246,.16)}
.stats-grid .stat-card:nth-child(6n+4) .stat-icon{background:rgba(245,158,11,.17)}
.stats-grid .stat-card:nth-child(6n+5) .stat-icon{background:rgba(20,184,166,.15)}
.stats-grid .stat-card:nth-child(6n+6) .stat-icon{background:rgba(236,72,153,.15)}

/* کارت‌های بخش/پنل — نرم‌تر، گوشهٔ گردتر، سایهٔ ملایم */
.section-card,.panel{border-radius:var(--card-radius);box-shadow:var(--card-shadow)}
.section-head,.panel-head{margin-bottom:1.1rem}
.section-head h3,.panel-head h3{font-size:1rem;letter-spacing:-.01em}

/* کارت‌های پیشخوان مالی و خلاصه‌ها */
.cash-card,.exp-stat-card{border-radius:var(--card-radius);box-shadow:var(--card-shadow)}

/* جدول‌ها — هدرِ تمیز و ردیف‌های نرم */
.table-wrap{border-radius:var(--radius)}
.dtable thead th{font-size:.74rem;font-weight:700;color:var(--text2);
  background:color-mix(in srgb,var(--text) 4%,transparent)}
.dtable tbody tr{transition:background .12s}
.dtable tbody tr:hover{background:var(--gold-dim)}

/* نشانگر روند (افزایش/کاهش) */
.trend-up{color:var(--ok);font-weight:700}
.trend-down{color:var(--bad);font-weight:700}

/* ریسپانسیو: چیپ و عدد کمی فشرده‌تر روی موبایل */
@media (max-width: 768px){
  .stat-card{padding:.85rem .9rem;gap:.65rem}
  .stat-icon{width:40px;height:40px;flex:0 0 40px;font-size:var(--fs-lg);border-radius:var(--radius)}
  .stat-val{font-size:1.3rem}
}

/* فهرست فایل‌های پیوستِ CRM */
.files-list{display:flex;flex-direction:column;gap:.5rem;margin-top:.6rem}
.file-row{display:flex;align-items:center;gap:.6rem;padding:.6rem .8rem;border:1px solid var(--border);
  border-radius:var(--radius);background:var(--bg2)}
.file-ic{font-size:1.2rem;flex-shrink:0}
.file-name{font-weight:600;flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.file-meta{font-size:var(--fs-sm);color:var(--text2);flex-shrink:0}
.file-act{display:flex;gap:.35rem;flex-shrink:0}

/* نشانِ پیگیری کنار منوی CRM */
.nav-item{position:relative}
.nav-badge{display:inline-flex;align-items:center;justify-content:center;min-width:20px;height:20px;
  padding:0 6px;margin-inline-start:auto;border-radius:var(--radius-sm);background:var(--bad);color:#fff;
  font-size:var(--fs-xs);font-weight:800;line-height:1}
.fu-overdue{color:var(--bad)}.fu-today{color:var(--warn)}.fu-soon{color:var(--warn)}

/* ── برد کانبان CRM ── */
.kb-board{display:flex;gap:.7rem;overflow-x:auto;padding:.4rem 0 .8rem;align-items:flex-start;
  -webkit-overflow-scrolling:touch}
.kb-col{flex:0 0 240px;max-width:240px;background:var(--bg2);border:1px solid var(--border);
  border-radius:var(--radius);display:flex;flex-direction:column;max-height:72vh}
.kb-col-head{padding:.6rem .8rem;font-weight:800;font-size:var(--fs-base);border-bottom:1px solid var(--border);
  display:flex;align-items:center;gap:.4rem;position:sticky;top:0}
.kb-count{margin-inline-start:auto;background:var(--border);border-radius:var(--radius-sm);padding:.05rem .5rem;
  font-size:var(--fs-sm);font-weight:700}
.kb-col-body{padding:.5rem;display:flex;flex-direction:column;gap:.5rem;overflow-y:auto}
.kb-col.kb-over{outline:2px dashed var(--gold);outline-offset:-3px}
.kb-card{background:var(--bg);border:1px solid var(--border);border-radius:var(--radius);padding:.55rem .65rem;
  cursor:grab;box-shadow:var(--card-shadow, 0 1px 4px rgba(0,0,0,.12))}
.kb-card.dragging{opacity:.45;cursor:grabbing}
.kb-name{font-weight:700;font-size:.86rem;display:block;color:inherit;text-decoration:none}
.kb-name:hover{color:var(--gold)}
.kb-sub{font-size:var(--fs-xs);color:var(--text2);margin-top:.2rem}
.kb-fu{font-size:var(--fs-xs);color:var(--warn);margin-top:.25rem}
.kb-move{width:100%;margin-top:.4rem;font-size:.74rem;padding:.2rem .3rem;border-radius:var(--radius-sm);
  border:1px solid var(--border);background:var(--bg2);color:inherit}
.kb-empty{color:var(--text3,#777);text-align:center;padding:.8rem 0;font-size:var(--fs-sm)}
@media (max-width: 768px){ .kb-col{flex-basis:200px;max-width:200px} }

/* ── نوار اقدام گروهی CRM ── */
.bulk-bar{display:flex;align-items:center;gap:.6rem;flex-wrap:wrap;margin:.6rem 0;
  padding:.55rem .8rem;border:1px solid var(--gold-dim,var(--border));border-radius:var(--radius);
  background:var(--bg2)}
.bulk-bar select{font-size:var(--fs-sm);padding:.3rem .4rem;border-radius:var(--radius-sm);border:1px solid var(--border);
  background:var(--bg);color:inherit}
.sel-col{width:34px;text-align:center}
.sel-col input{width:16px;height:16px;cursor:pointer}

/* ── لاگ ممیزی CRM ── */
.audit-list{display:flex;flex-direction:column;gap:.45rem;margin-top:.5rem}
.audit-row{padding:.55rem .75rem;border:1px solid var(--border);border-radius:var(--radius);background:var(--bg2);font-size:var(--fs-base)}
.au-meta{font-size:var(--fs-xs);color:var(--text2);margin-top:.25rem}
.au-old{color:var(--bad);text-decoration:line-through;opacity:.85}
.au-new{color:var(--ok);font-weight:700}

/* ════ بستهٔ B — موبایل ════ */
@media (max-width: 768px){
  /* رفع زوم خودکار iOS هنگام فوکوس: فونت فرم‌ها باید ≥16px باشد */
  input, select, textarea, .cal-input-disp{ font-size:16px !important; }
  /* هدف‌های لمسی: دکمه‌های ریزِ جدول‌ها و آیکونی */
  .btn-tiny{ min-height:38px; padding:.5rem .75rem; font-size:var(--fs-base); display:inline-flex; align-items:center; justify-content:center; }
  .btn-icon{ min-height:38px; min-width:38px; display:inline-flex; align-items:center; justify-content:center; }
  .crm-actions{ gap:.45rem; }
  /* چک‌باکس انتخاب گروهی بزرگ‌تر */
  .sel-col input{ width:20px; height:20px; }
  /* منوی انتقال کانبان راحت‌تر لمس شود */
  .kb-move{ min-height:36px; font-size:var(--fs-base); }
  /* مودال‌ها تمام‌عرضِ راحت با لبهٔ امن */
  .modal{ width:calc(100vw - 1.5rem); max-height:88vh; overflow-y:auto; }
}


/* ═══ بستهٔ موبایل: رفع زوم iOS و هدف‌های لمسی ═══ */
@media (max-width: 768px) {
  /* iOS با فونتِ زیر 16px هنگام فوکوس زوم می‌کند */
  input, select, textarea {
    font-size: 16px !important;
  }
  /* هدف‌های لمسی بزرگ‌تر برای دکمه‌های داخل جدول‌ها */
  .btn-tiny {
    min-height: 38px;
    padding: .5rem .75rem;
    font-size:var(--fs-base);
  }
  .btn-icon {
    min-height: 38px;
    min-width: 38px;
    font-size:var(--fs-lg);
    padding: .45rem .5rem;
  }
  .crm-actions, .file-act {
    gap: .5rem;
  }
  .dtable td {
    padding-top: .55rem;
    padding-bottom: .55rem;
  }
}


/* ═══ کلاس‌های کاربردی (utility) — جایگزین استایل‌های inline ═══ */
.u-span{grid-column:1/-1}
.u-minw-120{min-width:120px}
.u-minw-130{min-width:130px}
.u-maxw-110{max-width:110px}
.u-mt-1{margin-top:1rem}
.u-mt-08{margin-top:.8rem}
.u-mt-06{margin-top:.6rem}
.u-mt-05{margin-top:.5rem}
.u-mb-1{margin-bottom:1rem}
.u-m-0{margin:0}
.u-center{text-align:center}

/* ── پیگیری بعدی و رکود مرحله در جدول CRM ── */
.fu-pill{display:inline-block;padding:.18rem .55rem;border-radius:var(--radius-lg);font-size:var(--fs-xs);font-weight:700}
.fu-over{background:rgba(239,68,68,.14);color:var(--bad-text)}
.fu-today{background:rgba(245,158,11,.16);color:var(--warn-text)}
.fu-soon{background:rgba(59,130,246,.12);color:var(--info-text)}
.stage-age{margin-top:.2rem;font-size:var(--fs-xs)}
.stage-age.stale-warn{color:var(--warn-text)}
.stage-age.stale-bad{color:var(--bad-text);font-weight:700}
.kb-age{font-size:var(--fs-xs);color:var(--text2);margin-top:.2rem}
.kb-age.stale-warn{color:var(--warn-text)}
.kb-age.stale-bad{color:var(--bad-text);font-weight:700}

/* ── فید فعالیت تیم (پیشخوان CRM) ── */
.activity-feed{display:flex;flex-direction:column;gap:.45rem}
.feed-row{padding:.55rem .8rem;border:1px solid var(--border);border-radius:var(--radius-sm);background:var(--bg2)}
.feed-main{font-size:var(--fs-sm)}
.feed-text{font-size:var(--fs-sm);color:var(--text2);margin-top:.15rem}
.feed-time{font-size:var(--fs-xs);color:var(--text3);margin-top:.2rem}

/* ── برچسب‌های قابل‌کلیک در جدول CRM ── */
.row-tags{margin-top:.2rem;display:flex;gap:.25rem;flex-wrap:wrap}
.row-tag{font-size:var(--fs-xs);color:var(--gold);background:var(--gold-dim);padding:.08rem .45rem;border-radius:var(--radius-lg);cursor:pointer;white-space:nowrap}
.row-tag:hover{filter:brightness(1.15)}


/* ── دکمه‌های سایدبار (CRM/مالی): button رنگ و فونت را ارث نمی‌برد — صریح تم‌محور ── */
button.nav-item{font-family:inherit;font-size:inherit;color:var(--text2)}
button.nav-item:hover{color:var(--text)}
button.nav-item .nav-label, button.nav-item .nav-icon{color:inherit}
.nav-subgroup .nav-item{color:var(--text2)}
.nav-subgroup .nav-item:hover{color:var(--text)}

/* ── منوی کاربر در سایدبار (یکدست در هر دو سامانه): زیر لوگو و نام شرکت ── */
.sb-head{flex-wrap:wrap}
.sb-head .usermenu{width:100%;margin-top:.6rem;display:block}
.sb-head .usermenu-btn{width:100%;justify-content:flex-start}
.sb-head .usermenu-btn .um-name{max-width:none;flex:1;text-align:right}
.sb-head .usermenu-pop{left:0;right:0;min-width:0}

/* ═══ حالت وب‌اپ آیفون (PWA standalone): فاصله از ناچ و نوار home ═══ */
html.pwa .topbar{padding-top:calc(.8rem + env(safe-area-inset-top))}
html.pwa .sidebar{padding-top:env(safe-area-inset-top)}
html.pwa .dash-content{padding-bottom:calc(1rem + 52px + env(safe-area-inset-bottom))}

/* نوار ابزار پایینی — فقط در حالت وب‌اپ */
.pwa-bottombar{display:none}
/* فقط در حالت وب‌اپ *و* روی صفحهٔ کوچک (موبایل/تبلت) — روی دسکتاپ لازم نیست */
/* نوار پایین فقط روی موبایلِ واقعی (≤۷۶۸). تبلت و دسکتاپ سایدبار دارند. */
@media (min-width: 769px){
  html.pwa .pwa-bottombar{display:none !important}
  html.pwa .dash-main{padding-bottom:0 !important}
}
@media (max-width: 768px){
  html.pwa .pwa-bottombar{
    display:flex;justify-content:space-around;align-items:stretch;gap:.15rem;
    position:fixed;bottom:0;left:0;right:0;z-index:var(--z-bar);
    background:var(--bg2);border-top:1px solid var(--border);
    padding:.2rem .4rem calc(.2rem + env(safe-area-inset-bottom));
  }
}
.pwa-bb-btn{
  flex:1;display:flex;flex-direction:column;align-items:center;gap:1px;
  padding:.2rem .15rem;border:none;background:none;cursor:pointer;
  color:var(--text2);font-family:inherit;border-radius:var(--radius-sm);
  text-decoration:none;min-height:42px;justify-content:center;min-width:0;
}
.pwa-bb-btn .bb-ic{font-size:1.05rem;line-height:1}
.pwa-bb-btn .bb-ic .ic{width:1.05rem;height:1.05rem}
.pwa-bb-btn .bb-lb{font-size:.58rem;line-height:1.1;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;max-width:100%}
.pwa-bb-btn:active{background:var(--bg3);color:var(--gold)}
.pwa-bb-btn.active{color:var(--gold)}

/* ── صفحه‌بند ── */
.pager{display:flex;align-items:center;justify-content:center;gap:.8rem;margin-top:1rem;flex-wrap:wrap}
.pg-btn{padding:.45rem .9rem;border:1px solid var(--border);border-radius:var(--radius-sm);background:var(--bg2);color:var(--text);font-size:var(--fs-sm);text-decoration:none}
.pg-btn:hover{border-color:var(--gold);color:var(--gold)}
.pg-info{font-size:var(--fs-sm);color:var(--text2)}

/* ── قفل افقی سایدبار: هیچ سرریز/اسکرول افقی، برچسب‌های بلند سه‌نقطه ── */
.sidebar{overflow-x:hidden}
.sb-nav{overflow-x:hidden}
.sb-head{min-width:0}
.sidebar .nav-item{min-width:0}
.sidebar .nav-label{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.sb-co-name{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;max-width:100%}
.sb-head .usermenu{min-width:0;max-width:100%}
.sb-head .usermenu-btn{min-width:0;overflow:hidden}
.sb-head .usermenu-btn .um-name{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.sb-head .usermenu-pop{max-width:100%;overflow:hidden}
.usermenu-pop .um-head-sub{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.usermenu-pop .um-head-name{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}

/* نشان نخوانده روی دکمهٔ پیام در نوار پایینی وب‌اپ */
.pwa-bb-btn .bb-ic{position:relative}
.pwa-bb-btn{position:relative}
.bb-dot{display:none;position:absolute;top:4px;left:calc(50% - 18px);min-width:8px;height:8px;border-radius:50%;background:var(--bad);border:1.5px solid var(--bg2);z-index:2}

/* ═══ تور ایمنی ریسپانسیو: همهٔ گریدهای چندستونه در موبایل تک‌ستون ═══ */
@media (max-width: 768px){
  .form-grid-2, .form-grid-3, .field-grid-2, .field-grid-3,
  .alert-grid, .crm-report-grid, .xchg-grid, .summary-grid,
  .shareholders-grid, .expense-summary, .total-card, .two-col, .three-col,
  .detail-grid, .kpi-grid, .stat-cards{
    grid-template-columns: 1fr !important;
  }
  /* نوار ابزار/فیلترها: ستونی و تمام‌عرض */
  .toolbar, .action-row, .filter-bar, .crm-toolbar{ flex-direction: column; align-items: stretch; }
  .toolbar > *, .action-row > *{ width: 100%; }
  /* دکمه‌های کنار هم در موبایل که سرریز می‌کنند */
  .btn-row, .modal-actions{ flex-wrap: wrap; }
  /* جدول‌ها: اسکرول افقی نرم به‌جای شکستن صفحه */
  .table-wrap{ -webkit-overflow-scrolling: touch; }
}
@media (max-width: 480px){
  /* گریدهای دوستونهٔ آماری در گوشی کوچک هم تک‌ستون */
  .stats-grid{ grid-template-columns: 1fr !important; }
}

/* عناصر با min-width ثابت که در گوشی کوچک سرریز می‌کنند */
@media (max-width: 480px){
  /* 📱 ۱.۹.۱۲۰: input هم اضافه شد — فیلدهای لینکِ معرف (id=refLink) inputاند و
     min-widthِ inline داشتند، پس در گوشیِ کوچک سرریز می‌کردند. */
  .filter-select, select[style*="min-width"], input[style*="min-width"], .field[style*="min-width"]{ min-width: 0 !important; width: 100%; }
}

/* 📱 ۱.۹.۱۲۰: منوهای کشوییِ «فاکتور/گزارش» در پروفایل مشتری استایلِ inline دارند
   (min-width:250px; right:0) و روی موبایل از لبهٔ صفحه بیرون می‌زدند. اینجا با اسکوپِ
   موبایل به داخلِ صفحه مهار می‌شوند. !important لازم است چون استایلِ inline اولویت دارد. */
@media (max-width: 768px){
  #cinvMenu, #rptMenu{
    right:auto !important; left:0 !important;
    min-width:0 !important; max-width:calc(100vw - 2rem) !important;
  }
}

/* پنل پروفایل CRM: تب‌ها از ابتدا مخفی (جلوگیری از فلشِ فرم‌ها هنگام لود) */
.panel-tab{display:none}
.panel-tab.active{display:block}
.profile-view:empty{min-height:120px}

/* ── دکمه‌های آیکونی تاپ‌بار (تم + تقویم) — جمع‌وجور سمت چپ ── */
.topbar{display:flex}
.topbar-title{order:1}
.topbar-right{order:2}
.topbar-tools{order:3}
.topbar-tools{display:flex;align-items:center;gap:.4rem;margin-inline-start:.5rem}
.tb-icon-btn{height:38px;min-width:38px;display:inline-flex;align-items:center;justify-content:center;gap:.35rem;
  background:var(--bg3);border:1px solid var(--border);border-radius:var(--radius-sm);
  color:var(--text);cursor:pointer;font-size:1.05rem;line-height:1;padding:0 .6rem;transition:border-color .15s,background .15s}
.tb-icon-btn:hover{border-color:var(--gold);background:var(--gold-dim)}
.tb-icon-btn .ic{width:1.15rem;height:1.15rem}
.tb-cal-label{font-size:var(--fs-xs);font-weight:700}
@media (max-width:768px){
  .topbar-tools{order:3;margin-inline-start:0}
  .tb-icon-btn{height:40px}
}

/* ═══ پنجرهٔ تقویم با تعطیلات ═══ */
.cal-line{cursor:pointer;transition:color .15s}
.cal-line:hover{color:var(--gold)}
.cal-popup-overlay{position:fixed;inset:0;background:rgba(0,0,0,.55);z-index:var(--z-modal);display:flex;align-items:center;justify-content:center;padding:1rem}
.cal-popup{background:var(--bg2);border:1px solid var(--border);border-radius:var(--radius-lg);box-shadow:var(--shadow);width:min(420px,96vw);max-height:90vh;overflow-y:auto;padding:1rem}
.cal-popup-head{display:flex;align-items:center;gap:.5rem;margin-bottom:.8rem}
.cal-popup-title{flex:1;text-align:center;font-weight:700;font-size:var(--fs-md)}
.cal-nav{width:34px;height:34px;border:1px solid var(--border);background:var(--bg3);border-radius:var(--radius-sm);cursor:pointer;color:var(--text);font-size:1.2rem;line-height:1}
.cal-nav:hover{border-color:var(--gold);color:var(--gold)}
.cal-close{width:34px;height:34px;border:none;background:none;cursor:pointer;color:var(--text2);font-size:1rem}
.cal-close:hover{color:var(--bad)}
.cal-grid{display:grid;grid-template-columns:repeat(7,1fr);gap:3px}
.cal-head{text-align:center;font-size:var(--fs-xs);color:var(--text3);font-weight:700;padding:.3rem 0}
.cal-cell{aspect-ratio:1;display:flex;align-items:center;justify-content:center;border-radius:var(--radius-sm);font-size:var(--fs-sm);background:var(--bg3);color:var(--text)}
.cal-cell.empty{background:transparent}
.cal-cell.weekend{background:rgba(245,158,11,.12);color:var(--warn-text)}
.cal-cell.holiday{background:rgba(239,68,68,.16);color:var(--bad-text);font-weight:700}
.cal-cell.today{background:var(--gold);color:#1a1a1a;font-weight:800}
.cal-legend{display:flex;gap:1rem;justify-content:center;margin:.8rem 0;font-size:var(--fs-xs);color:var(--text2);flex-wrap:wrap}
.cal-legend .dot{display:inline-block;width:10px;height:10px;border-radius:3px;vertical-align:-1px;margin-inline-end:3px}
.cal-legend .dot.today{background:var(--gold)}
.cal-legend .dot.holiday{background:var(--bad)}
.cal-legend .dot.weekend{background:var(--warn)}
.cal-holidays{border-top:1px solid var(--border);padding-top:.7rem;font-size:var(--fs-sm)}
.cal-hol-title{font-weight:700;margin-bottom:.4rem;color:var(--text)}
.cal-hol-row{padding:.25rem 0;color:var(--text2)}
.cal-hol-row b{color:var(--bad-text);margin-inline-end:.3rem}
.cal-hol-empty{color:var(--text3);text-align:center;padding:.5rem}

/* منوی خروجی‌ها در پروفایل مشتری */
.doc-menu{display:none;position:absolute;top:calc(100% + 4px);right:0;background:var(--bg2);border:1px solid var(--border);border-radius:var(--radius-sm);box-shadow:var(--shadow);min-width:230px;z-index:var(--z-pop);overflow:hidden}
.doc-menu.open{display:block}
.doc-menu a,.doc-menu button{display:block;width:100%;text-align:right;padding:.6rem .8rem;background:none;border:none;color:var(--text);font-family:inherit;font-size:var(--fs-sm);cursor:pointer;text-decoration:none}
.doc-menu a:hover,.doc-menu button:hover{background:var(--gold-dim);color:var(--gold)}

/* چک‌باکس «فقط در خروجی» زیر فیلدهای اسپانیا */
.out-tick{display:flex;align-items:center;gap:.35rem;margin-top:.3rem;font-size:var(--fs-xs);color:var(--text2);cursor:pointer;font-weight:400}
.out-tick input{width:auto;accent-color:var(--gold);cursor:pointer}

.fam-form-btn{background:var(--gold-dim);color:var(--gold);border:none;border-radius:7px;padding:.25rem .55rem;font-size:.72rem;text-decoration:none;font-family:'Vazirmatn';cursor:pointer}
.fam-row{display:flex;justify-content:space-between;align-items:center;gap:10px;
  padding:.7rem .9rem;background:var(--bg2);border:1px solid var(--border);border-radius:12px;margin-bottom:.6rem}
.fam-row-info{display:flex;align-items:baseline;gap:8px;min-width:0}
.fam-row-name{font-weight:700}
.fam-row-rel{color:var(--muted);font-size:var(--fs-sm)}
.fam-row-actions{display:flex;gap:6px;flex-shrink:0}
.doc-disabled{opacity:.5;cursor:not-allowed !important}
.doc-menu{max-height:min(70vh,520px);overflow-y:auto}
.doc-section-label{padding:.5rem .8rem .3rem;font-size:var(--fs-xs);font-weight:800;color:var(--muted);display:flex;align-items:center;gap:6px;flex-wrap:wrap}
.doc-rt-badge{background:var(--gold-dim);color:var(--gold);padding:.1rem .45rem;border-radius:var(--radius-xs);font-size:.68rem;font-weight:700}
.doc-divider{height:1px;background:var(--border);margin:.3rem 0}
.doc-soon{background:var(--bg3);color:var(--muted);padding:.05rem .35rem;border-radius:var(--radius-xs);font-size:.62rem;margin-inline-start:4px}

/* سوییچ زبان فرم اطلاعات فردی */
.lang-switch{display:flex;align-items:center;gap:.5rem;flex-wrap:wrap;background:var(--bg3);border:1px solid var(--border);border-radius:var(--radius-sm);padding:.5rem .7rem;margin-bottom:1rem}
.ls-label{font-size:var(--fs-sm);font-weight:700;color:var(--text2)}
.ls-btn{padding:.35rem .9rem;border:1px solid var(--border);background:var(--bg2);color:var(--text2);border-radius:var(--radius-sm);cursor:pointer;font-family:inherit;font-size:var(--fs-sm)}
.ls-btn.active{background:var(--gold);color:#1a1a1a;border-color:var(--gold);font-weight:700}
.ls-hint{font-size:var(--fs-xs);color:var(--text3);flex:1;min-width:160px}
@media(max-width:768px){ .ls-hint{flex-basis:100%} }

/* شبکهٔ انتخاب فیلدهای خروجی فرم */
.fx-grid{display:grid;grid-template-columns:1fr 1fr;gap:.45rem .6rem;max-height:52vh;overflow-y:auto;overflow-x:hidden;padding:.4rem .1rem}
.fx-item{display:flex;align-items:center;gap:.5rem;font-size:var(--fs-sm);cursor:pointer;padding:.45rem .6rem;
  border:1px solid var(--border);border-radius:9px;background:var(--bg3);transition:border-color .15s,background .15s;
  min-width:0;box-sizing:border-box}
.fx-item:hover{border-color:var(--gold)}
.fx-item:has(input:checked){border-color:var(--gold);background:var(--gold-dim)}
.fx-item input{width:17px;height:17px;flex:0 0 17px;accent-color:var(--gold);cursor:pointer;margin:0}
.fx-item span{flex:1 1 auto;min-width:0;line-height:1.25;white-space:normal;overflow-wrap:break-word;text-align:right}
@media(max-width:768px){ .fx-grid{grid-template-columns:1fr} }
.fx-actions{display:flex;gap:.5rem;margin:.3rem .1rem .6rem;justify-content:flex-start}
.modal-poa{max-width:480px}
.modal-poa select,.modal-poa input[type=text],.modal-poa input[type=date]{width:100%;box-sizing:border-box}
@media (max-width:768px){
  .modal-poa{max-width:none;width:calc(100vw - 1.5rem)}
  .modal-poa select,.modal-poa input{font-size:16px}
}

/* ═══ ریسپانسیو موبایل — اجزای CRM ═══ */
@media (max-width:768px){
  /* صفحه‌بند فید فعالیت */
  .feed-pager{flex-wrap:wrap;gap:.6rem}
  .fp-btn{flex:1;min-width:90px}
  /* اطلاعات شرکت در تنظیمات CRM */
  .ci-row{grid-template-columns:1fr;gap:.2rem;padding:.5rem .2rem}
  .ci-row .ci-k{font-size:.72rem}
  /* ویرایشگر لیست منابع/نوع‌ها */
  .le-row{grid-template-columns:1fr auto;gap:.4rem}
  .le-row .le-code{grid-column:1/-1}
  /* مودال‌ها تمام‌عرض‌تر */
  .modal{width:calc(100vw - 1.5rem);max-width:none;max-height:88vh}
  .modal-lg{max-width:none}
  /* منوی خروجی‌ها از لبه بیرون نزند */
  .doc-menu{right:auto;left:0;min-width:200px;max-width:calc(100vw - 2rem)}
  /* جدول‌های داشبورد CRM افقی اسکرول شوند */
  .dtable-wrap{overflow-x:auto;-webkit-overflow-scrolling:touch}
  /* گریدهای گزارش تک‌ستونه */
  .summary-grid,.crm-report-grid{grid-template-columns:1fr !important}
  /* همهٔ ورودی‌ها ۱۶px تا iOS زوم نکند */
  .crm-settings input,.crm-settings select,.crm-settings textarea,
  .modal input,.modal select,.modal textarea{font-size:16px}
}
@media (max-width:480px){
  .profile-view{grid-template-columns:1fr}
  .pv-row{grid-template-columns:1fr}
  .pv-row .pv-k{font-size:.7rem;color:var(--text3)}
  .alert-grid{grid-template-columns:1fr}
  .lang-switch{flex-direction:column;align-items:stretch}
  .lang-switch .ls-btn{width:100%}
}

/* ═══════════ ریسپانسیو موبایلِ CRM (جامع) ═══════════ */
@media (max-width: 768px){
  /* جدول‌های CRM داخل کارت: اسکرول افقیِ روان به‌جای بریدن/شکستنِ صفحه */
  .section-card:has(> table.data-table),
  .section-card:has(> .data-table){overflow-x:auto;-webkit-overflow-scrolling:touch}
  .data-table{min-width:560px}
  .crm-table,.dtable{min-width:0}                 /* این‌ها ستون مخفی دارند، اجبار به اسکرول نشود */

  /* جلوگیری از zoomِ خودکارِ iOS هنگام فوکوس روی ورودی‌ها (سایز < 16px) */
  .field input,.field select,.field textarea,
  .modal input:not([type=checkbox]):not([type=radio]),.modal select,.modal textarea,
  .search-input,.note-add input,.note-add textarea,#newCheck{font-size:16px}

  /* نوار بالای پروفایل: اکشن‌ها تمام‌عرض و مرتب */
  .profile-bar{gap:.6rem}
  .profile-actions{width:100%;justify-content:flex-start}
  .profile-actions .btn-secondary,.profile-actions .btn-ghost{flex:0 0 auto}
  .doc-menu{right:auto;left:0}                     /* منوی خروجی‌ها از لبه بیرون نزند */

  /* کارت‌های اطلاعات فقط‌خواندنی: تک‌ستونه و جمع‌وجور */
  .profile-view{grid-template-columns:1fr;gap:.7rem}
  .fin-cards{grid-template-columns:1fr}

  /* مودال‌ها: تمام‌عرض با حاشیهٔ کم */
  .modal{width:calc(100vw - 1.5rem);max-width:calc(100vw - 1.5rem)}

  /* پنل اعلانِ زنگوله: از لبهٔ صفحه بیرون نزند */
  .lead-panel{left:8px;right:8px;width:auto;max-width:none}

  /* نوار اقدام گروهی: wrap و دکمه‌های قابل‌لمس */
  .bulk-bar .btn,.bulk-bar button{flex:0 0 auto}
}
@media (max-width: 480px){
  /* تب‌های پروفایل/لیست: لمسِ راحت‌تر */
  .tabs-bar .tab-btn{padding:.5rem .7rem;font-size:.82rem}
  .profile-id .crm-code{font-size:.95rem}
  /* دکمه‌های اکشن جدول‌ها کوچک‌تر اما قابل‌لمس */
  .crm-table .btn-tiny,.data-table .btn-tiny{padding:.3rem .5rem}
}

/* نشانِ نسخه در پای سایدبار */
.app-ver{margin-top:.5rem;text-align:center;direction:ltr;font-family:'Outfit','Vazirmatn',monospace;line-height:1.5;opacity:.7}
.app-ver .av-num{font-size:.66rem;font-weight:700;color:var(--text2)}
.app-ver .av-build{display:block;font-size:.56rem;color:var(--text3)}
.sidebar.collapsed .app-ver .av-build{display:none}

/* ═══ موبایل: هدرِ مرتب + جدول‌های جمع‌وجورِ پیشخوان (دسکتاپ بی‌تغییر) ═══ */
@media (max-width: 768px){
  .topbar{padding:.55rem .8rem;row-gap:.45rem}
  /* ردیف ۱: منو + عنوان + ابزارها (تقویم/تم) در یک خط */
  .topbar-title{font-size:.95rem;order:1;flex:1 1 auto;min-width:0;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
  .topbar-tools{order:2;margin-inline-start:auto;display:flex;gap:.35rem}
  .tb-icon-btn{padding:.3rem .5rem;font-size:.8rem}
  .tb-cal-label{font-size:.68rem}
  /* ردیف ۲: نشانِ شرکت + ساعت — تمام‌عرض، وسط‌چین و فشرده */
  .topbar-right{order:3;width:100%;justify-content:center;align-items:center;gap:.4rem;flex-wrap:wrap}
  .co-pill{font-size:.66rem;padding:.2rem .6rem}
  /* 📱 ۱.۹.۱۲۰: ساعتِ جمع‌وجورتر تا هدرِ ثابت فضای کمتری از صفحه بگیرد.
     چون از ۱.۹.۱۱۹ بدنه پس از پرشدنِ ساعت آشکار می‌شود، رزروِ ارتفاعِ بزرگ لازم نیست؛
     min-height:auto یعنی ویجت دقیقاً به‌اندازهٔ محتوایش بلند می‌شود (نه بیشتر). */
  .clock-widget{width:100%;padding:.28rem .45rem;gap:.2rem .5rem;border-radius:12px;min-height:auto}
  .clock-widget.cw-analog{min-height:auto}
  .clocks-wrap{gap:.55rem}
  .clock-block{gap:1px}
  .clock-zone{font-size:.58rem}
  .clock-time{font-size:.68rem;min-width:46px}
  .cal-block{padding-right:.5rem;gap:.3rem .45rem}
  .cal-line{font-size:.53rem}
  svg.analog{width:50px;height:50px}
}
/* 📱 ۱.۹.۱۲۰: کاهشِ پدینگِ کناریِ محتوا روی موبایل تا عرضِ مفیدِ صفحه بیشتر شود.
   (پدینگِ پایینِ حالتِ PWA با قانونِ مشخص‌ترِ html.pwa .dash-content حفظ می‌شود.) */
@media (max-width: 768px){
  .dash-content{ padding:1rem; }
}
@media (max-width: 480px){
  .dash-content{ padding:.8rem; }
}
@media (max-width: 640px){
  /* جدول‌های پیشخوان: فشرده تا بدون اسکرولِ افقی جا شوند */
  .panel .dtable{font-size:.76rem}
  .panel .dtable th{font-size:.68rem;padding:.4rem .45rem;white-space:nowrap}
  .panel .dtable td{padding:.45rem .45rem;vertical-align:top}
  .panel .dtable td:first-child{word-break:break-word;overflow-wrap:anywhere;max-width:132px}
  .panel .dtable .amount-cell{white-space:nowrap;font-size:.8rem}
  .panel .dtable .date-cell{white-space:nowrap;font-size:.7rem}
  .panel .dtable .method-badge{font-size:.6rem;padding:.12rem .4rem}
}
@media (max-width: 520px){
  /* در عرض‌های خیلی کم، ستونِ «روش» حذف تا بقیه راحت جا شود */
  .ov-pay th:nth-child(3), .ov-pay td:nth-child(3){display:none}
}

/* لوگوی ریزِ شرکت در هدرِ موبایل (دسکتاپ: مخفی — همان pill می‌ماند) */
.co-logo-sm{display:none}
@media (max-width: 768px){
  .co-pill{display:none}
  .co-logo-sm{display:inline-block;width:30px;height:30px;border-radius:50%;object-fit:cover;
    border:1.5px solid var(--border);background:#fff;box-shadow:0 1px 4px rgba(0,0,0,.12);vertical-align:middle}
  .topbar-tools{align-items:center}
}


/* ═══ 🚀 پایداری چیدمان (۱.۹.۱۰۸) — رفع پرش/فلشِ کادرها هنگام لود ═══
   ریشهٔ مشکل: فونت‌ها با تأخیر می‌رسند و مرورگر همه‌چیز را دوباره اندازه‌گیری می‌کند.
   با رزروِ فضا و اعدادِ هم‌عرض، چیدمان از اولین رندر ثابت می‌ماند. */
.data-table{ table-layout:auto; }
.data-table td, .data-table th{ white-space:nowrap; }
/* اعدادِ هم‌عرض: با تغییر فونت، عرضِ ستون‌ها نمی‌پرد */
.data-table td, .ltr-cell, .amount-cell, .money-input,
.total-main, .stat-val, .n{ font-variant-numeric:tabular-nums; }
/* کارت‌های بخش: تغییرِ داخلی، کلِ صفحه را reflow نکند */
.section-card{ contain:layout style; }
/* پیش از آماده‌شدنِ فونت، پرش را با رزروِ ارتفاعِ ردیف‌ها کم می‌کنیم */
.data-table tbody tr{ height:3rem; }


/* ═══ 🚀 پایداری چیدمان — بخش دوم (۱.۹.۱۱۱) ═══
   هر عنصری که محتوایش پویا تغییر می‌کند باید عرضِ پایدار داشته باشد،
   وگرنه با هر به‌روزرسانی، چیدمانِ اطرافش تکان می‌خورد. */

/* ساعت زنده: هر ثانیه عوض می‌شود ⇒ ارقام هم‌عرض تا هدر نلرزد */
.clock-widget, .clock-widget *{
  font-variant-numeric:tabular-nums;
  font-feature-settings:"tnum";
}
.clock-widget{ contain:layout style; }

/* نوار اعلان: انیمیشنِ جمع‌شدن (به‌جای حذفِ ناگهانی) */
.alert{ contain:layout; }

/* اعدادِ پویا در همهٔ کارت‌ها و جدول‌ها */
.stat-val, .total-main, .total-detail, .amount-cell, .ltr-cell,
.money-input, .badge, .kpi-val, td.n, .n{
  font-variant-numeric:tabular-nums;
  font-feature-settings:"tnum";
}

/* نشانگرِ پیام‌های خوانده‌نشده (هر ۳۰ ثانیه به‌روز می‌شود) */
.unread-badge, .nav-badge{ min-width:1.25rem; text-align:center; contain:layout style; }

/* تصاویر: بدون ابعادِ مشخص باعث پرش می‌شوند */
img{ height:auto; }
.avatar, .logo-img{ flex-shrink:0; }


/* ═══ 📱 لایهٔ تبلت (۷۶۹–۱۰۲۴) — ۱.۹.۱۱۱ ═══
   پیش از این فقط دو حالت داشتیم: موبایل (≤۷۶۸) و دسکتاپ. تبلت دقیقاً
   چیدمانِ دسکتاپ را می‌گرفت و محتوا فشرده/بریده می‌شد. */
@media (min-width: 769px) and (max-width: 1024px){
  /* سایدبار باریک‌تر تا محتوا جا شود */
  .sidebar{ width:190px; }
  .dash-content{ padding:1.1rem; }

  /* گریدها: دو ستون به‌جای سه/چهار */
  .expense-summary{ grid-template-columns:repeat(2,1fr); }
  .stats-grid{ grid-template-columns:repeat(auto-fill,minmax(160px,1fr)); }
  .reports-grid{ grid-template-columns:repeat(auto-fill,minmax(190px,1fr)); }
  .cash-holders-grid{ grid-template-columns:repeat(auto-fill,minmax(180px,1fr)); }
  .form-grid-2{ grid-template-columns:repeat(2,1fr); }

  /* جدول‌های پهن: اسکرول افقی به‌جای شکستنِ چیدمان */
  .section-card:has(> table),
  .section-card:has(> .data-table){ overflow-x:auto; }
  .data-table{ min-width:640px; }

  /* مودال: پهن‌تر از موبایل، جمع‌وجورتر از دسکتاپ */
  .modal{ max-width:min(680px, 92vw); }
  .modal-lg{ max-width:min(860px, 94vw); }

  /* کارت‌ها کمی جمع‌وجورتر */
  .stat-card{ padding:1rem; min-height:7.5rem; }
  .stat-val{ font-size:1.4rem; }
  .total-main{ font-size:1.35rem; }
}

/* تبلتِ عمودی (باریک‌تر): سایدبار کشویی مثل موبایل */
@media (min-width: 769px) and (max-width: 900px){
  .sidebar{ position:fixed; top:0; right:0; height:100%; width:min(60vw,280px);
            transform:translateX(100%); z-index:var(--z-mnav); transition:transform .25s; }
  .sidebar.open{ transform:translateX(0); }
  .dash-main{ margin:0; }
  .menu-toggle{ display:inline-flex !important; }
}


/* رزروِ فضای نوار پایین: محتوا زیرش پنهان نشود و هنگام ظاهرشدن، صفحه نپرد */
@media (max-width: 768px){
  html.pwa .dash-content{
    padding-bottom:calc(4.2rem + env(safe-area-inset-bottom));
  }
}


/* ═══ 🏦 Component نقدی/بانکی — نمایشِ پایدار (۱.۹.۱۱۲) ═══
   مشکل: اگر بلوک داخل یک .field گرید قرار می‌گرفت، فیلدهایش باریک و بریده
   می‌شدند و کاربر نمی‌توانست حساب بانکی را انتخاب کند. */
.htf-block{
  grid-column:1 / -1;      /* همیشه تمام‌عرضِ گرید */
  width:100%;
}
.htf-block .form-grid-2{
  display:grid;
  grid-template-columns:repeat(auto-fit, minmax(180px, 1fr));
  gap:.75rem;
  width:100%;
}
.htf-block .field{ min-width:0; }
.htf-block select,
.htf-block input{
  width:100%;
  min-width:0;
  box-sizing:border-box;
}
.htf-block .htf-hint,
.htf-block .htf-fx-hint{ display:block; margin-top:.25rem; font-size:.72rem; }
@media (max-width: 640px){
  .htf-block .form-grid-2{ grid-template-columns:1fr; }
}

/* ── جستجوی سراسریِ نوار بالا (فقط دسکتاپ/ویندوز) ── */
.gs-wrap{ position:relative; display:flex; align-items:center; }
.gs-ico{ position:absolute; inset-inline-start:10px; font-size:.85rem; opacity:.55; pointer-events:none; }
.gs-input{ width:210px; max-width:34vw; padding:.42rem .9rem; padding-inline-start:1.9rem;
  font-family:inherit; font-size:.85rem; border:1px solid var(--border); border-radius:999px;
  background:var(--bg2); color:var(--text); outline:none; transition:width .18s, border-color .15s; }
.gs-input:focus{ border-color:var(--gold); width:260px; }
.gs-input::placeholder{ color:var(--text3); }
.gs-box{ position:absolute; top:calc(100% + 6px); inset-inline-start:0; width:300px; max-width:80vw;
  z-index:var(--z-modal,2000); background:var(--bg); border:1px solid var(--border); border-radius:12px;
  box-shadow:0 18px 44px -20px rgba(0,0,0,.5); overflow-y:auto; max-height:60vh; }
.gs-item{ display:flex; align-items:center; justify-content:space-between; gap:.6rem; padding:.55rem .8rem;
  text-decoration:none; color:var(--text); border-bottom:1px solid var(--border); }
.gs-item:last-child{ border-bottom:0; }
.gs-item:hover, .gs-item.active{ background:var(--gold-dim); }
.gs-name{ font-size:.85rem; font-weight:600; }
.gs-tag{ font-size:.68rem; color:var(--text3); font-weight:500; white-space:nowrap;
  margin-inline-start:-.35rem; margin-inline-end:auto; opacity:.75; }
.gs-sub{ font-size:.72rem; color:var(--text3); white-space:nowrap; }
/* ۱.۹.۳۰۴ — «علتِ مچ»: وقتی نتیجه به‌خاطرِ نامِ لاتین، عضوِ خانواده یا شمارهٔ
   پرونده پیدا شده، همان‌جا نشان داده می‌شود تا کاربر بداند چرا این ردیف آمده. */
/* ۱.۹.۳۰۸ — برچسبِ حسابِ بانکیِ هر ردیفِ مالی، کنارِ نامِ دریافت‌کننده */
.acct-tag{ display:block; margin-top:.15rem; font-size:.68rem; color:var(--text3);
  white-space:nowrap; direction:ltr; text-align:start; }
.acct-tag.cash{ color:var(--text3); }
.acct-tag.legacy{ color:#b45309; }

.gs-why{ flex:1; min-width:0; font-size:.7rem; color:var(--gold); opacity:.9;
  overflow:hidden; text-overflow:ellipsis; white-space:nowrap; text-align:start; }
.gs-empty{ padding:.7rem .8rem; font-size:.8rem; color:var(--text3); text-align:center; }
@media(max-width:900px){ .gs-wrap{ display:none; } }

/* ── فیلترِ تیک‌زدنیِ اکسل‌مانند (MultiFilter) ── */
.mf{ position:relative; display:inline-block; }
.mf-btn{ display:inline-flex; align-items:center; gap:5px; font-family:inherit; font-size:.8rem;
  padding:.4rem .7rem; border:1px solid var(--border); border-radius:9px; background:var(--bg2);
  color:var(--text); cursor:pointer; white-space:nowrap; }
.mf-btn:hover{ border-color:var(--gold); }
.mf.mf-has .mf-btn{ border-color:var(--gold); color:var(--gold); background:var(--gold-dim); }
.mf-count{ font-weight:800; font-size:.72rem; font-variant-numeric:tabular-nums; }
.mf-caret{ font-size:.6rem; opacity:.6; transition:transform .18s; }
.mf-open .mf-caret{ transform:rotate(180deg); }
.mf-pop{ display:none; position:absolute; top:calc(100% + 5px); inset-inline-start:0; z-index:var(--z-modal,2000);
  width:232px; max-width:80vw; background:var(--bg); border:1px solid var(--border); border-radius:12px;
  box-shadow:0 16px 40px -20px rgba(0,0,0,.5); padding:8px; }
.mf-pop.open{ display:block; }
.mf-search input{ width:100%; box-sizing:border-box; padding:.4rem .6rem; font-family:inherit; font-size:.8rem;
  border:1px solid var(--border); border-radius:8px; background:var(--bg2); color:var(--text); outline:none; }
.mf-search input:focus{ border-color:var(--gold); }
.mf-acts{ display:flex; gap:6px; margin:7px 0; }
.mf-acts button{ flex:1; font-family:inherit; font-size:.7rem; padding:.32rem; border:1px solid var(--border);
  border-radius:7px; background:var(--bg2); color:var(--text2); cursor:pointer; }
.mf-acts button:hover{ border-color:var(--gold); color:var(--gold); }
.mf-list{ max-height:240px; overflow-y:auto; display:flex; flex-direction:column; gap:1px; }
.mf-item{ display:flex; align-items:center; gap:8px; padding:.4rem .5rem; border-radius:7px; cursor:pointer; font-size:.8rem; color:var(--text); }
.mf-item:hover{ background:var(--gold-dim); }
.mf-item input{ accent-color:var(--gold); width:15px; height:15px; flex-shrink:0; cursor:pointer; }
.mf-empty{ padding:.5rem; font-size:.76rem; color:var(--text3); text-align:center; }

/* ── کانبانِ لگالایز (صفحهٔ لگالایز + تبِ پروفایل) ── */
.lg-page{ max-width:1280px; margin-inline:auto; }
.kb{ display:flex; gap:.85rem; overflow-x:auto; padding-bottom:.5rem; align-items:stretch;
  -webkit-overflow-scrolling:touch; scroll-snap-type:x proximity; }
.kb-col{ flex:1 1 230px; min-width:230px; max-width:290px; scroll-snap-align:start;
  display:flex; flex-direction:column; background:var(--bg2); border:1px solid var(--border);
  border-radius:14px; padding:.55rem .55rem .7rem; max-height:min(72vh, 640px); }
.kb-title{ display:flex; align-items:center; justify-content:space-between; gap:.5rem;
  margin:0 0 .55rem; padding:.35rem .45rem; border-radius:9px; background:var(--bg3);
  font-size:.83rem; font-weight:800; color:var(--text); position:sticky; top:0; z-index:2; }
.kb-title .kb-dot{ width:8px; height:8px; border-radius:50%; display:inline-block; margin-inline-end:.4rem; }
.kb-count{ font-size:.7rem; font-weight:800; color:#fff; border-radius:999px; padding:.08rem .5rem; min-width:22px; text-align:center; }
.kb-NEED .kb-count, .kb-NEED .kb-dot{ background:#f59e0b; }
.kb-WAITING .kb-count, .kb-WAITING .kb-dot{ background:#2f6bff; }
.kb-OBTAINED .kb-count, .kb-OBTAINED .kb-dot{ background:#22c55e; }
.kb-LEGAL_DONE .kb-count, .kb-LEGAL_DONE .kb-dot{ background:#3fb950; }
.kb-LEGAL_FAILED .kb-count, .kb-LEGAL_FAILED .kb-dot{ background:#f85149; }
.kb-NEED{ border-top:3px solid #f59e0b; }
.kb-WAITING{ border-top:3px solid #2f6bff; }
.kb-OBTAINED{ border-top:3px solid #22c55e; }
.kb-LEGAL_DONE{ border-top:3px solid #3fb950; }
.kb-LEGAL_FAILED{ border-top:3px solid #f85149; }
.kb-BLS_DONE{ border-top:3px solid #3fb950; }
.kb-BLS_FAILED{ border-top:3px solid #f85149; }
.kb-BLS_DONE .kb-count, .kb-BLS_DONE .kb-dot{ background:#3fb950; }
.kb-BLS_FAILED .kb-count, .kb-BLS_FAILED .kb-dot{ background:#f85149; }
.kb-result{ color:var(--gold); border-inline-start:2px solid var(--gold); padding-inline-start:.5rem; }
.kb-outcome{ display:flex; gap:.4rem; margin:.5rem 0; }
.kb-outcome .btn-tiny{ flex:1; font-weight:700; }
.kb-outcome .btn-tiny.ok{ background:rgba(63,185,80,.15); color:#3fb950; border:1px solid rgba(63,185,80,.35); border-radius:8px; padding:.4rem .6rem; }
.kb-outcome .btn-tiny.danger{ background:rgba(248,81,73,.12); color:#f85149; border:1px solid rgba(248,81,73,.32); border-radius:8px; padding:.4rem .6rem; }
.kb-list{ display:flex; flex-direction:column; gap:.45rem; flex:1; overflow-y:auto; padding-inline-end:2px; }
.kb-card{ background:var(--bg3); border:1px solid var(--border); border-radius:10px;
  padding:.5rem .6rem; transition:border-color .15s, transform .12s; }
.kb-card:hover{ border-color:var(--gold); transform:translateY(-1px); }
.kb-NEED .kb-card{ border-inline-start:3px solid rgba(245,158,11,.55); }
.kb-WAITING .kb-card{ border-inline-start:3px solid rgba(47,107,255,.55); }
.kb-OBTAINED .kb-card{ border-inline-start:3px solid rgba(34,197,94,.55); }
.kb-LEGAL_DONE .kb-card{ border-inline-start:3px solid rgba(63,185,80,.55); }
.kb-LEGAL_FAILED .kb-card{ border-inline-start:3px solid rgba(248,81,73,.55); }
.kb-top{ display:flex; align-items:baseline; justify-content:space-between; gap:.4rem; }
.kb-name{ font-size:.83rem; font-weight:700; color:var(--text); text-decoration:none;
  overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.kb-name:hover{ color:var(--gold); }
.kb-code{ font-size:.66rem; color:var(--text3); font-family:Tahoma,sans-serif; flex:0 0 auto; }
.kb-doc{ font-size:.75rem; color:var(--text2); margin-top:1px;
  display:-webkit-box; -webkit-line-clamp:2; -webkit-box-orient:vertical; overflow:hidden; }
.kb-dates{ display:flex; flex-wrap:wrap; gap:.28rem; margin-top:.4rem; }
.kb-dates span{ font-size:.66rem; color:var(--text2); font-family:Tahoma,sans-serif; direction:ltr;
  background:rgba(128,128,128,.12); border-radius:6px; padding:.1rem .35rem; }
.kb-dates i{ font-style:normal; font-size:.6rem; color:var(--text3); margin-inline-end:3px; font-family:inherit; }
.kb-dates .hot{ background:rgba(212,175,55,.18); color:var(--gold); font-weight:700; }
.kb-notes{ font-size:.7rem; color:var(--text3); margin-top:.35rem; padding-top:.3rem;
  border-top:1px dashed var(--border);
  display:-webkit-box; -webkit-line-clamp:2; -webkit-box-orient:vertical; overflow:hidden; }
.kb-actions{ display:flex; align-items:center; gap:.3rem; margin-top:.45rem; }
.kb-move{ flex:1; min-width:0; padding:2px 5px; border-radius:6px; border:1px solid var(--border);
  background:var(--bg2); color:var(--text2); font-family:inherit; font-size:.68rem; cursor:pointer; }
.kb-move:hover{ color:var(--text); border-color:var(--gold); }
.kb-actions .btn-icon{ padding:2px 5px; font-size:.8rem; opacity:.65; }
.kb-actions .btn-icon:hover{ opacity:1; }
.kb-empty{ text-align:center; color:var(--text3); font-size:.75rem; padding:1.2rem 0;
  border:1px dashed var(--border); border-radius:9px; }
.lg-pick{ position:relative; }
.lg-drop{ position:absolute; z-index:30; inset-inline:0; top:calc(100% + 4px); max-height:240px; overflow:auto;
  background:var(--bg2); border:1px solid var(--border); border-radius:10px; box-shadow:0 8px 24px rgba(0,0,0,.18); }
.lg-drop button{ display:block; width:100%; text-align:right; padding:.45rem .7rem; background:none; border:0;
  color:var(--text); font-family:inherit; font-size:.82rem; cursor:pointer; }
.lg-drop button:hover, .lg-drop button.on{ background:rgba(212,175,55,.14); }
.lg-drop small{ color:var(--text3); font-family:Tahoma,sans-serif; }
.lg-chosen{ margin-top:.4rem; font-size:.8rem; color:#22c55e; font-weight:700; }
@media(max-width:1000px){ .kb{ grid-template-columns:1fr; } .kb-col{ min-height:0; } }

/* ── انتخابِ تک‌مرحله‌ایِ گزارشِ لگالایز ── */
.lgrep-pick{ display:flex; gap:.5rem; flex-wrap:wrap; }
.lgrep-chip{ display:flex; align-items:center; gap:.4rem; padding:.45rem .8rem; border-radius:10px;
  border:1.5px solid var(--border); background:var(--bg2); color:var(--text2);
  font-family:inherit; font-size:.83rem; font-weight:700; cursor:pointer; transition:all .15s; }
.lgrep-chip:hover{ border-color:var(--gold); color:var(--text); }
.lgrep-chip.on{ border-color:var(--gold); background:rgba(212,175,55,.14); color:var(--text); }
.lgrep-chip .kb-dot{ width:8px; height:8px; border-radius:50%; display:inline-block; }
.lgrep-NEED .kb-dot{ background:#f59e0b; }
.lgrep-WAITING .kb-dot{ background:#2f6bff; }
.lgrep-OBTAINED .kb-dot{ background:#22c55e; }
.lgrep-LEGAL_DONE .kb-dot, .lgrep-BLS_DONE .kb-dot{ background:#3fb950; }
.lgrep-LEGAL_FAILED .kb-dot, .lgrep-BLS_FAILED .kb-dot{ background:#f85149; }
.lgrep-WAITING .kb-dot{ background:#2f6bff; }
.lgrep-OBTAINED .kb-dot{ background:#22c55e; }

/* ── پاپ‌آپِ جستجوی موبایل (از دکمهٔ فوترِ وب‌اپ) ── */
.msearch-modal{ position:fixed; inset:0; z-index:var(--z-modal,3000); display:none; }
.msearch-modal.open{ display:block; }
.msearch-backdrop{ position:absolute; inset:0; background:rgba(0,0,0,.45); backdrop-filter:blur(2px); }
/* شیت از پایین، درست بالای نوارِ فوتر باز می‌شود تا دمِ دست باشد */
.msearch-sheet{ position:absolute; inset-inline:0; bottom:calc(60px + env(safe-area-inset-bottom, 0px));
  background:var(--bg2); border-top-left-radius:18px; border-top-right-radius:18px;
  padding:.85rem .8rem 1rem; box-shadow:0 -14px 40px -12px rgba(0,0,0,.55); z-index:1; animation:msRise .2s ease; }
@keyframes msRise{ from{ transform:translateY(20px); opacity:.4; } to{ transform:none; opacity:1; } }
.msearch-bar{ display:flex; align-items:center; gap:.5rem; background:var(--bg3);
  border:1.5px solid var(--border); border-radius:12px; padding:.55rem .7rem; }
.msearch-bar:focus-within{ border-color:var(--gold); }
.msearch-ico{ font-size:1rem; opacity:.7; }
.msearch-input{ flex:1; min-width:0; border:0; background:none; outline:none; color:var(--text);
  font-family:inherit; font-size:1rem; padding:.15rem 0; }
.msearch-close{ border:0; background:none; color:var(--text3); font-size:1.1rem; cursor:pointer; padding:.1rem .3rem; }
/* نتایج بالای کادرِ ورودی باز می‌شوند (چون شیت پایین است) */
.msearch-results{ margin-bottom:.6rem; max-height:52vh; overflow-y:auto; border:1px solid var(--border);
  border-radius:12px; background:var(--bg); display:flex; flex-direction:column-reverse; }
.msearch-results:empty{ display:none; }
.msearch-hint{ margin-top:.55rem; text-align:center; font-size:.78rem; color:var(--text3); }
.msearch-results .gs-item{ padding:.7rem .9rem; }
.msearch-results .gs-name{ font-size:.92rem; }
@media(min-width:901px){ .msearch-modal{ display:none !important; } }

/* ── پنجرهٔ انتخابِ «ثبت در مالی» (CRM) ── */
.lf-pick{ display:flex; gap:.6rem; align-items:flex-start; padding:.7rem .8rem; margin-bottom:.55rem;
  border:1.5px solid var(--border); border-radius:12px; background:var(--bg2); cursor:pointer; transition:all .15s; }
.lf-pick:hover{ border-color:var(--gold); }
.lf-pick.on{ border-color:var(--gold); background:rgba(212,175,55,.10); }
.lf-pick input[type=checkbox]{ accent-color:var(--gold); width:16px; height:16px; margin-top:3px; flex:0 0 auto; }
.lf-pick b{ font-size:.9rem; }
.lf-pick small{ color:var(--text3); font-size:.76rem; }
.lf-inst{ margin:.45rem 0 .3rem; border-top:1px dashed var(--border); padding-top:.4rem; }
.lf-inst-row{ display:flex; align-items:center; justify-content:space-between; gap:.5rem;
  font-size:.78rem; color:var(--text2); padding:.18rem 0; }
.lf-inst-row b{ color:var(--gold); font-family:Tahoma,sans-serif; }
.lf-inst-row .lf-due{ color:var(--text3); font-family:Tahoma,sans-serif; direction:ltr; font-size:.72rem; }
.lf-note{ padding:.75rem .85rem; border-radius:12px; background:rgba(47,107,255,.08);
  border:1px solid rgba(47,107,255,.3); font-size:.83rem; line-height:1.9; color:var(--text2); }

/* ═══ گزارش مالی پرونده (تبِ finreport در پروفایلِ مشتری) ═══ */

/* کارتِ خلاصهٔ ارز */
.fr-money-card{ background:var(--bg2); border:1px solid var(--border); border-radius:var(--radius);
  padding:1.1rem 1.25rem; margin-bottom:1rem; }
.fr-mc-head{ display:flex; align-items:baseline; justify-content:space-between; margin-bottom:.55rem; }
.fr-cur{ font-size:.9rem; font-weight:800; color:var(--gold); letter-spacing:.06em; font-family:var(--font-en); }
.fr-mc-pct{ font-size:.72rem; color:var(--text3); }
.fr-bar{ height:5px; border-radius:99px; background:var(--bg3); overflow:hidden; margin-bottom:1rem; }
.fr-bar span{ display:block; height:100%; border-radius:99px; background:var(--ok,#10b981); transition:width .4s ease; }
.fr-mc-grid{ display:grid; grid-template-columns:repeat(auto-fit,minmax(120px,1fr)); gap:.85rem 1.5rem; }
.fr-mc-lbl{ font-size:.7rem; color:var(--text3); margin-bottom:.25rem; }
.fr-mc-val{ font-size:1.1rem; font-weight:700; font-family:var(--font-en);
  font-variant-numeric:tabular-nums; direction:ltr; text-align:start; }

/* هشدارِ اقلامِ معوق */
.fr-alert{ padding:.65rem .9rem; border-radius:var(--radius-sm); font-size:.82rem; margin-bottom:1rem;
  background:rgba(239,68,68,.09); border:1px solid rgba(239,68,68,.25); color:var(--bad-text); }

/* بلوکِ هر بخش */
.fr-block{ margin-bottom:1rem; }
.fr-block-head{ display:flex; align-items:center; justify-content:space-between;
  font-size:.85rem; font-weight:700; color:var(--text2); margin-bottom:.5rem; padding-inline:.15rem; }
.fr-block-head .fr-n{ font-size:.75rem; color:var(--text3); font-weight:600; font-family:var(--font-en); }
.fr-empty{ text-align:center; color:var(--text3); font-size:.82rem; padding:1.35rem;
  border:1px dashed var(--border); border-radius:var(--radius-sm); }

/* عناصرِ داخلِ جدول */
.fr-type{ display:inline-block; font-size:.7rem; font-weight:700; padding:1px 8px; border-radius:99px;
  background:var(--bg3); color:var(--text2); white-space:nowrap; }
.fr-title{ font-weight:600; }
.fr-sub{ font-size:.7rem; color:var(--text3); direction:ltr; }
.fr-dim{ color:var(--text3); }
.fr-late{ font-size:.68rem; color:var(--bad-text); margin-top:.15rem; }
.fr-row-bad td{ background:rgba(239,68,68,.04); }
#ptab-finreport .dtable td,
#ptab-finreport .dtable th{ font-size:.8rem; }
#ptab-finreport .ltr-cell{ direction:ltr; text-align:start; font-family:var(--font-en);
  font-variant-numeric:tabular-nums; white-space:nowrap; }

/* ═══ صفحهٔ گزارش‌هایِ CRM ═══ */

/* عنوانِ گروهِ گزارش‌ها */
.rep-group-title{ font-size:.95rem; font-weight:800; color:var(--text); margin:1.6rem 0 .7rem;
  display:flex; align-items:center; gap:.5rem; }
.rep-group-title::after{ content:''; flex:1; height:1px; background:var(--border); }

/* نمودارهایِ نواری */
.bar-list{ display:flex; flex-direction:column; gap:.5rem; }
.bar-row{ display:flex; align-items:center; gap:.7rem; }
.bar-label{ flex:0 0 auto; width:9.5rem; font-size:.78rem; color:var(--text2);
  white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.bar-track{ flex:1; height:8px; border-radius:99px; background:var(--bg3); overflow:hidden; min-width:0; }
.bar-fill{ display:block; height:100%; border-radius:99px; background:var(--gold);
  transition:width .45s ease; }
.bar-num{ flex:0 0 auto; min-width:2.2rem; text-align:start; font-size:.8rem; font-weight:700;
  font-family:var(--font-en); font-variant-numeric:tabular-nums; direction:ltr; color:var(--text); }

/* نمودارِ روندِ ماهانه — نوارهایِ عمودی */
.trend-chart{ display:flex; align-items:flex-end; justify-content:space-between; gap:.35rem;
  height:9rem; padding:.6rem .2rem 0; }
.trend-col{ flex:1; display:flex; flex-direction:column; align-items:center; gap:.35rem;
  justify-content:flex-end; height:100%; min-width:0; }
.trend-bar{ width:100%; max-width:2.6rem; border-radius:6px 6px 2px 2px; background:var(--gold);
  min-height:3px; transition:height .45s ease; }
.trend-bar.zero{ background:var(--border); }
.trend-n{ font-size:.72rem; font-weight:700; font-family:var(--font-en);
  font-variant-numeric:tabular-nums; color:var(--text); }
.trend-m{ font-size:.62rem; color:var(--text3); font-family:var(--font-en); white-space:nowrap;
  transform:rotate(-45deg); transform-origin:center; margin-top:.35rem; }

/* پیل‌هایِ انتخابِ گزارش */
.rep-pills{ display:flex; flex-wrap:wrap; gap:.4rem; }
.rep-pill{ font:inherit; cursor:pointer; font-size:.78rem; font-weight:600; padding:.35rem .8rem;
  border-radius:99px; border:1px solid var(--border); background:var(--bg2); color:var(--text2);
  transition:all .15s; white-space:nowrap; }
.rep-pill:hover{ border-color:var(--gold); color:var(--text); }
.rep-pill.active{ background:var(--gold); border-color:var(--gold); color:#fff; }

/* نوارِ ابزارِ خروجی */
.rep-export{ display:flex; gap:.4rem; align-items:center; margin-inline-start:auto; }
.rep-export button{ font:inherit; cursor:pointer; font-size:.75rem; font-weight:600;
  padding:.3rem .7rem; border-radius:8px; border:1px solid var(--border);
  background:var(--bg2); color:var(--text2); }
.rep-export button:hover{ border-color:var(--gold); color:var(--text); }
.rep-sec-head{ display:flex; align-items:center; gap:.5rem; margin-bottom:.6rem; flex-wrap:wrap; }

/* ═══ تبِ آپلود مدارک (گوگل‌درایو) ═══ */
.drv-picks{ display:grid; grid-template-columns:repeat(auto-fill,minmax(150px,1fr)); gap:.35rem .7rem; margin-top:.3rem; }
.drv-pick{ display:flex; align-items:center; gap:.4rem; font-size:.8rem; cursor:pointer;
  padding:.3rem .5rem; border:1px solid var(--border); border-radius:8px; background:var(--bg2);
  transition:border-color .15s, background .15s; }
.drv-pick:hover{ border-color:var(--gold); }
.drv-pick input{ margin:0; flex:0 0 auto; }

/* نوارِ مسیر و ابزارها */
.drv-toolbar{ display:flex; align-items:center; gap:.6rem; flex-wrap:wrap; margin-bottom:.8rem; }
.drv-toolbar .field{ margin:0; }
.drv-path{ display:flex; align-items:center; gap:.5rem; padding:.6rem .85rem; margin-bottom:.9rem;
  border:1px solid var(--border); border-inline-start:3px solid var(--gold);
  border-radius:10px; background:var(--bg2); font-size:.8rem; }
.drv-path .p-txt{ flex:1; min-width:0; direction:ltr; text-align:start; word-break:break-word; color:var(--text2); }
.drv-sec{ margin-bottom:1rem; }
.drv-sec-head{ display:flex; align-items:center; justify-content:space-between; gap:.5rem;
  font-size:.85rem; font-weight:700; color:var(--text2); margin-bottom:.5rem; }
.drv-empty{ text-align:center; color:var(--text3); font-size:.82rem; padding:1.35rem;
  border:1px dashed var(--border); border-radius:var(--radius-sm); }
#ptab-drive .dtable td, #ptab-drive .dtable th{ font-size:.8rem; }
