:root{--bg:#f6f1e8;--panel:#fffdf8;--ink:#1d1914;--muted:#5c564c;--line:rgba(29,25,20,.12);--nav:#1d1914;--nav2:#2a241c;--accent:#8d6a2f;--accent2:#8d6a2f;--good:#1f7a4d;--bad:#b42318;--warn:#9a6700;--shadow:0 12px 32px rgba(29,25,20,.08);--gold:#8d6a2f;--paper:#faf6ef}*{box-sizing:border-box}body{margin:0;font-family:"IBM Plex Sans Arabic",Arial,sans-serif;background:var(--bg);color:var(--ink)}button,input,select,textarea{font:inherit}.app-shell{display:grid;grid-template-columns:272px 1fr;min-height:100vh;direction:ltr}.sidebar{background:linear-gradient(180deg,var(--nav),var(--nav2));color:var(--ink);padding:22px 16px;display:flex;flex-direction:column;position:sticky;top:0;height:100vh;direction:rtl;border-left:1px solid var(--line)}.brand{display:flex;gap:12px;align-items:center;padding:2px 6px 22px;border-bottom:1px solid var(--line)}.brand-mark{width:44px;height:44px;border-radius:12px;background:var(--gold);color:#1a140c;display:grid;place-items:center;font-weight:900;letter-spacing:-1px;font-family:"Cormorant Garamond",serif}.brand em{display:block;font-style:normal;font-size:10px;letter-spacing:.22em;text-transform:uppercase;color:var(--gold);margin-bottom:2px}.brand b{display:block;font-size:14px;font-family:"Cormorant Garamond",serif}.brand span{font-size:11px;color:var(--muted)}.sidebar nav{padding-top:14px;display:flex;flex-direction:column;gap:4px;flex:1;min-height:0;overflow-y:auto}.nav-btn{border:0;background:transparent;color:#d8d0c4;text-align:right;padding:8px 10px;border-radius:10px;cursor:pointer;display:flex;align-items:center;gap:10px;width:100%;font-size:13px}.nav-btn:hover,.nav-btn.active{background:rgba(201,165,106,.12);color:#fff}.nav-btn .ico{width:22px;text-align:center}.sidebar-footer{margin-top:auto;display:grid;gap:10px;color:var(--muted);font-size:11px}.sidebar-footer .ghost{border:1px solid var(--line);background:transparent;color:var(--ink);border-radius:9px;padding:9px;cursor:pointer}main{direction:rtl;min-width:0}main>header{min-height:92px;height:auto;background:rgba(12,11,9,.82);backdrop-filter:blur(18px);border-bottom:1px solid var(--line);display:flex;justify-content:space-between;align-items:center;padding:16px 30px;position:sticky;top:0;z-index:5;gap:16px}main>header h1{margin:0;font-size:28px;font-family:"Cormorant Garamond",serif;font-weight:600;letter-spacing:-.02em}main>header p{margin:5px 0 0;color:var(--muted);font-size:13px}.header-actions{display:flex;gap:10px;align-items:center}.pill{padding:7px 10px;border-radius:999px;background:#eef3ff;color:var(--accent2);font-size:12px;font-weight:700}.primary,.secondary,.danger,.tiny{border:0;border-radius:9px;padding:10px 14px;cursor:pointer}.primary{background:var(--accent);color:#fff}.secondary{background:#eef2f7;color:#243044}.danger{background:#fff0f0;color:var(--bad)}.tiny{padding:6px 9px;font-size:12px}.content{padding:26px 30px}.grid{display:grid;gap:16px}.kpis{grid-template-columns:repeat(5,minmax(0,1fr));direction:rtl}.card{background:var(--panel);border:1px solid var(--line);border-radius:16px;box-shadow:var(--shadow);padding:18px}.kpi .label{font-size:12px;color:var(--muted)}.kpi .value{font-size:23px;font-weight:800;margin-top:10px;letter-spacing:-.5px}.kpi.good .value{color:var(--good)}.kpi.bad .value{color:var(--bad)}.two{grid-template-columns:1.1fr .9fr;margin-top:16px}.section-head{display:flex;justify-content:space-between;align-items:center;margin-bottom:14px}.section-head h3{margin:0;font-size:15px}.muted{color:var(--muted)}table{width:100%;border-collapse:collapse;font-size:13px}th,td{padding:11px 9px;border-bottom:1px solid var(--line);text-align:right;vertical-align:middle}th{font-size:11px;text-transform:uppercase;color:#778195;background:#fafbfc;position:sticky;top:0}tr:last-child td{border-bottom:0}.table-wrap{overflow:auto;max-height:62vh;border:1px solid var(--line);border-radius:12px}.badge{display:inline-flex;padding:4px 8px;border-radius:999px;font-size:11px;font-weight:700;background:#eef2f7;color:#49566b}.badge.income{background:#e9f8f2;color:#087353}.badge.expense{background:#fff0ef;color:#b03c3c}.badge.active{background:#eaf2ff;color:#2257a7}.badge.cancelled{background:#f4f4f5;color:#777}.toolbar{display:flex;gap:10px;margin-bottom:14px;flex-wrap:wrap;align-items:center}.toolbar input,.toolbar select{border:1px solid var(--line);background:#fff;border-radius:9px;padding:9px 10px}.toolbar input{min-width:240px}.form-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:13px}.field{display:grid;gap:6px}.field.full{grid-column:1/-1}.field label{font-size:12px;color:#4b5563;font-weight:700}.field input,.field select,.field textarea{width:100%;border:1px solid #d9dee8;border-radius:9px;padding:10px;background:#fff}.field textarea{min-height:80px;resize:vertical}.form-actions{grid-column:1/-1;display:flex;justify-content:flex-start;gap:10px;margin-top:6px}.modal{position:fixed;inset:0;background:rgba(5,12,25,.55);z-index:20;display:grid;place-items:center;padding:24px;direction:rtl}.modal.hidden{display:none}.modal-card{background:white;width:min(760px,96vw);max-height:90vh;overflow:auto;border-radius:18px;box-shadow:0 30px 80px rgba(0,0,0,.25);padding:24px;position:relative}.close{position:absolute;left:16px;top:13px;border:0;background:#f2f4f7;width:32px;height:32px;border-radius:50%;font-size:22px;cursor:pointer}.modal h2{margin:0 0 18px;font-size:20px}.empty{padding:40px;text-align:center;color:var(--muted)}#toast{position:fixed;bottom:22px;left:22px;z-index:40;display:grid;gap:8px}.toast{background:#101828;color:white;padding:12px 15px;border-radius:10px;box-shadow:var(--shadow);font-size:13px}.account-grid{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:12px}.account-card{border:1px solid var(--line);border-radius:13px;padding:14px;background:#fff}.account-card b{display:block}.account-card .bal{font-size:20px;font-weight:800;margin-top:12px}.account-card small{color:var(--muted)}.spark{height:180px;display:flex;align-items:flex-end;gap:8px;padding-top:16px}.bar{flex:1;min-width:20px;background:#dce7ff;border-radius:6px 6px 0 0;position:relative}.bar.in{background:#b8ebdc}.bar.out{background:#ffd0cc}.bar span{position:absolute;bottom:-20px;font-size:9px;color:var(--muted);right:50%;transform:translateX(50%);white-space:nowrap}.split-bars{display:grid;grid-template-columns:1fr 1fr;gap:5px;align-items:end;height:160px}.row-actions{display:flex;gap:5px}.ltr{direction:ltr;text-align:left}.num{font-variant-numeric:tabular-nums}.report-tabs{display:flex;gap:8px;margin-bottom:14px}.report-tabs button{border:1px solid var(--line);background:#fff;border-radius:9px;padding:8px 12px;cursor:pointer}.report-tabs button.active{background:var(--nav);color:white}.warning{background:#fff7e6;border:1px solid #f2d39a;color:#8a5b06;padding:12px;border-radius:10px;font-size:12px;margin-bottom:14px}@media(max-width:1100px){.kpis{grid-template-columns:repeat(2,1fr)}.two{grid-template-columns:1fr}.account-grid{grid-template-columns:repeat(2,1fr)}}@media(max-width:760px){.app-shell{grid-template-columns:1fr}.sidebar{position:relative;height:auto}.sidebar nav{display:flex;flex-direction:column;overflow:visible}header{position:relative;padding:14px 16px}.content{padding:16px}.kpis{grid-template-columns:1fr}.form-grid{grid-template-columns:1fr}.account-grid{grid-template-columns:1fr}.header-actions .pill{display:none}}
.viewer-mode .primary[onclick*="Form"],.viewer-mode .sidebar-footer .ghost{display:none!important}
.viewer-mode #accessPill{background:#eef2f7;color:#475467}
#accessPill{white-space:nowrap}

.admin-only{display:inline-flex}.viewer-mode .admin-only{display:none!important}.role-checks{display:flex;flex-wrap:wrap;gap:10px;padding:10px;border:1px solid var(--line);border-radius:10px;background:#fafbfc}.role-checks label{display:flex;align-items:center;gap:6px;font-weight:600;color:#344054}.badge.role{margin:2px}.account-card .admin-only{display:block}.viewer-mode .account-card .admin-only{display:none!important}
.custody-kpis{grid-template-columns:repeat(4,minmax(0,1fr));margin-bottom:14px}.custody-kpis .value{font-size:18px}@media(max-width:900px){.custody-kpis{grid-template-columns:repeat(2,1fr)}}

/* v6 cumulative UI fixes */
.role-checks{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:10px;direction:ltr;padding:12px}
.role-checks .role-option{display:flex;align-items:center;gap:8px;min-height:42px;padding:9px 10px;border:1px solid var(--line);border-radius:9px;background:#fff;cursor:pointer;color:#344054;direction:ltr;justify-content:flex-start}
.role-checks .role-option input{width:16px;height:16px;flex:0 0 auto;margin:0}
.role-checks .role-option span{white-space:nowrap;line-height:1}
.account-card{min-width:0;overflow:hidden}
.account-card .bal{font-size:clamp(11px,1.35vw,20px);line-height:1.15;direction:ltr;text-align:center;overflow-wrap:anywhere;word-break:break-word;max-width:100%;font-variant-numeric:tabular-nums}
.account-card .partner-fx-due{display:block;margin-top:8px;text-align:center;color:var(--good);font-weight:700}
.quick-payment-box,.quick-payment-note{grid-column:1/-1;border:1px solid #d7e3ff;background:#f6f9ff;border-radius:11px;padding:12px;display:grid;gap:5px}
.quick-payment-box b,.quick-payment-note b{color:#173f93}
@media(max-width:760px){.role-checks{grid-template-columns:repeat(2,minmax(0,1fr))}}

/* v7 reporting, filtering and analysis */
.entry-type-tabs{display:flex;gap:8px;margin-bottom:12px;flex-wrap:wrap}.entry-type-tabs button{border:1px solid var(--line);background:#fff;color:#334155;border-radius:10px;padding:9px 14px;cursor:pointer}.entry-type-tabs button.active{background:var(--nav);color:#fff;border-color:var(--nav)}
.advanced-filter,.report-filter{margin-bottom:14px}.filter-grid{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:11px}.filter-grid.compact{grid-template-columns:repeat(4,minmax(0,1fr))}.filter-actions{display:flex;gap:8px;margin-top:12px;flex-wrap:wrap}.export-btn{display:inline-flex;align-items:center;text-decoration:none;white-space:nowrap}.check-inline{display:inline-flex;align-items:center;gap:6px;padding:8px 10px;border:1px solid var(--line);border-radius:9px;background:#fff;font-size:12px;color:#475467}.check-inline input{margin:0}
.report-kpis{grid-template-columns:repeat(4,minmax(0,1fr))}.analysis-kpis{grid-template-columns:repeat(4,minmax(0,1fr));margin-bottom:16px}.good-text{color:var(--good)}.bad-text{color:var(--bad)}
.analysis-bars{display:grid;gap:10px}.analysis-bar{display:grid;grid-template-columns:minmax(120px,180px) 1fr minmax(90px,120px);gap:9px;align-items:center;font-size:12px}.analysis-bar-track{height:12px;border-radius:999px;background:#edf0f5;overflow:hidden}.analysis-bar-fill{height:100%;border-radius:999px;background:linear-gradient(90deg,#2463eb,#7398f5)}.analysis-bar b{direction:ltr;text-align:left;font-variant-numeric:tabular-nums}
.report-chart .split-bars{min-height:180px}.report-chart{overflow:hidden}
@media(max-width:1150px){.filter-grid,.filter-grid.compact{grid-template-columns:repeat(2,minmax(0,1fr))}.analysis-kpis,.report-kpis{grid-template-columns:repeat(2,minmax(0,1fr))}}
@media(max-width:760px){.filter-grid,.filter-grid.compact{grid-template-columns:1fr}.analysis-kpis,.report-kpis{grid-template-columns:1fr}.analysis-bar{grid-template-columns:110px 1fr}.analysis-bar b{grid-column:1/-1;text-align:right}}

/* v8 operations + AI */
.ai-answer{background:#f8fafc;border:1px solid #dbe4ef;border-radius:14px;padding:16px;line-height:1.75}
.ai-text{margin:10px 0;white-space:normal}
textarea#ai_question{min-height:120px}

/* v8.2 compact filters + dashboard chart containment */
.compact-filter-card{padding:12px 14px;margin-bottom:14px}
.compact-filter-main{display:grid;grid-template-columns:minmax(220px,1.6fr) repeat(3,minmax(135px,1fr)) auto;gap:10px;align-items:end}
.payments-filter-main{grid-template-columns:minmax(210px,1.5fr) repeat(4,minmax(125px,1fr)) auto}
.compact-filter-main .field{gap:4px}
.compact-filter-main .field label,.filter-grid.dense .field label{font-size:11px}
.compact-filter-main .field input,.compact-filter-main .field select,.filter-grid.dense .field input,.filter-grid.dense .field select{padding:8px 9px;min-height:36px}
.compact-filter-actions{display:flex;gap:6px;align-items:center;padding-bottom:1px}
.compact-filter-actions button{padding:9px 12px;white-space:nowrap}
.more-filters{border-top:1px solid var(--line);margin-top:10px;padding-top:8px}
.more-filters summary{cursor:pointer;list-style:none;color:#344054;font-size:12px;font-weight:800;display:flex;align-items:center;gap:7px;user-select:none}
.more-filters summary::-webkit-details-marker{display:none}
.more-filters summary:before{content:'+';display:inline-grid;place-items:center;width:20px;height:20px;border-radius:6px;background:#eef2f7;color:#475467;font-size:14px}
.more-filters[open] summary:before{content:'−'}
.more-filters .filter-grid{margin-top:10px}
.filter-grid.dense{grid-template-columns:repeat(5,minmax(0,1fr));gap:9px}
.filter-count{display:inline-grid;place-items:center;min-width:20px;height:20px;padding:0 6px;border-radius:999px;background:#e8efff;color:#2456b3;font-size:10px}
.money-cell{white-space:nowrap;font-variant-numeric:tabular-nums}
.monthly-chart{height:150px;display:flex;align-items:flex-end;gap:8px;overflow-x:auto;overflow-y:hidden;padding:6px 2px 24px;contain:layout paint}
.month-group{height:126px;min-width:42px;flex:1 0 42px;display:flex;flex-direction:column;justify-content:flex-end;align-items:center;position:relative}
.bar-pair{height:122px;width:100%;display:flex;align-items:flex-end;justify-content:center;gap:3px}
.month-group .bar{width:min(14px,38%);min-width:7px;flex:0 0 auto;border-radius:5px 5px 0 0;position:static}
.month-group>span{position:absolute;bottom:-20px;right:auto;transform:none;font-size:9px;color:var(--muted);white-space:nowrap}
.chart-legend{display:flex;gap:14px;justify-content:flex-start;margin-top:5px;font-size:10px;color:var(--muted)}
.chart-legend span{display:flex;align-items:center;gap:5px}.chart-legend i{width:9px;height:9px;border-radius:3px;display:inline-block}.legend-in{background:#b8ebdc}.legend-out{background:#ffd0cc}

@media(max-width:1250px){.compact-filter-main,.payments-filter-main{grid-template-columns:repeat(3,minmax(0,1fr))}.compact-filter-main .search-wide{grid-column:span 2}.compact-filter-actions{align-self:end}.filter-grid.dense{grid-template-columns:repeat(3,minmax(0,1fr))}}
@media(max-width:850px){.compact-filter-main,.payments-filter-main{grid-template-columns:1fr 1fr}.compact-filter-main .search-wide{grid-column:1/-1}.compact-filter-actions{grid-column:1/-1}.filter-grid.dense{grid-template-columns:1fr 1fr}}
@media(max-width:560px){.compact-filter-main,.payments-filter-main,.filter-grid.dense{grid-template-columns:1fr}.compact-filter-main .search-wide{grid-column:auto}}

/* v8.3 bulk import + migration */
.import-upload{display:flex;align-items:end;gap:10px;flex-wrap:wrap;margin-top:14px}.import-upload .field{flex:1 1 320px}.import-context{background:#f8fafc;border:1px solid var(--line);border-radius:10px;padding:10px 12px;margin-bottom:14px;font-size:12px;color:#475467}.import-mapping-grid{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:10px;margin:10px 0 4px}.import-stats{grid-template-columns:repeat(4,minmax(0,1fr));margin:12px 0}.import-stats .card{padding:12px}.import-stats .value{font-size:20px}.import-preview,.import-preview-raw{max-height:340px;margin:12px 0}.import-preview table,.import-preview-raw table{font-size:11px}.import-error-row{background:#fff2f1}.import-dup-row{background:#fff8e8}.warn-text{color:#9a6700}.import-global-error{border-color:#f4b4ad;background:#fff2f1;color:#a4332a}.import-commit-bar{display:flex;align-items:center;justify-content:space-between;gap:10px;flex-wrap:wrap;margin:14px 0}.migration-kpis{grid-template-columns:repeat(4,minmax(0,1fr));margin-bottom:16px}.migration-steps{margin:0;padding-right:22px;line-height:2}.migration-steps li{padding-right:4px}
@media(max-width:1050px){.import-mapping-grid{grid-template-columns:repeat(2,minmax(0,1fr))}.import-stats,.migration-kpis{grid-template-columns:repeat(2,minmax(0,1fr))}}
@media(max-width:650px){.import-mapping-grid,.import-stats,.migration-kpis{grid-template-columns:1fr}}


/* v8.3.5 mixed entries import + allocation UI */
.import-preview .import-error-row td{background:rgba(220,38,38,.055)}
.import-preview .import-edited-row td{box-shadow:inset 0 1px 0 rgba(37,99,235,.12),inset 0 -1px 0 rgba(37,99,235,.12)}
.import-preview td:last-child{white-space:nowrap}
.import-row-editor textarea{min-height:86px;resize:vertical}
.import-row-editor .field.full{grid-column:1/-1}

/* v8.4.2 import command center: responsive workspace + bulk edit */
.modal{padding:12px;align-items:center;justify-items:center;overflow:hidden}
.modal-card.modal-wide{width:min(1120px,97vw);max-height:94vh}
.modal-card.modal-import{width:96vw;height:92vh;max-width:1650px;max-height:95vh;min-width:760px;min-height:520px;padding:16px;overflow:hidden;resize:both;font-size:12px}
.modal-card.modal-maximized{width:calc(100vw - 14px)!important;height:calc(100vh - 14px)!important;max-width:none!important;max-height:none!important;min-width:0;min-height:0;resize:none;border-radius:12px}
.modal-import .close{z-index:30;left:12px;top:10px}
.import-workspace-shell{height:100%;display:flex;flex-direction:column;min-height:0;gap:8px}
.import-workspace-scroll{flex:1;min-height:0;overflow:auto;padding:0 2px 8px 2px;overscroll-behavior:contain}
.import-titlebar{display:flex;justify-content:space-between;align-items:flex-start;gap:12px;padding-left:42px;flex:0 0 auto}
.import-titlebar h2{font-size:18px;margin:0 0 6px}.import-titlebar .import-context{margin:0;padding:7px 10px;font-size:11px}
.import-window-actions{display:flex;gap:6px;align-items:center;white-space:nowrap}
.import-mapping-details{border:1px solid var(--line);border-radius:11px;background:#fbfcfe;margin:6px 0 10px;padding:0 10px}
.import-mapping-details summary{cursor:pointer;display:flex;align-items:center;justify-content:space-between;gap:12px;padding:10px 2px;list-style:none}.import-mapping-details summary::-webkit-details-marker{display:none}
.import-mapping-grid{grid-template-columns:repeat(5,minmax(120px,1fr));gap:7px;margin:0 0 8px}.modal-import .field{gap:4px}.modal-import .field label{font-size:10.5px}.modal-import .field input,.modal-import .field select,.modal-import .field textarea{padding:7px 8px;border-radius:8px;font-size:12px;min-height:34px}
.import-result-head{margin:8px 0 5px}.import-result-head h3{font-size:13px}
.modal-import .import-stats{grid-template-columns:repeat(4,minmax(100px,1fr));gap:7px;margin:6px 0 8px}.modal-import .import-stats .card{padding:8px 10px;border-radius:10px}.modal-import .import-stats .value{font-size:17px;margin-top:4px}
.import-command-bar{position:sticky;top:0;z-index:12;background:rgba(255,255,255,.97);backdrop-filter:blur(6px);display:flex;align-items:center;gap:8px;flex-wrap:wrap;border:1px solid var(--line);border-radius:10px;padding:8px 10px;margin:8px 0}
.import-command-bar .primary,.import-command-bar .secondary{padding:7px 10px;font-size:11px}.import-command-bar .muted{font-size:10.5px;flex:1;min-width:220px}
.import-table-zone{position:relative;min-height:240px}
.modal-import .import-preview,.modal-import .import-preview-raw{max-height:48vh;margin:8px 0;border-radius:10px;overflow:auto}
.modal-import .import-preview table,.modal-import .import-preview-raw table{font-size:10.5px;min-width:1180px;table-layout:auto}
.modal-import .import-preview th,.modal-import .import-preview td{padding:7px 6px;vertical-align:top;line-height:1.35;white-space:normal;overflow-wrap:anywhere;word-break:normal}
.modal-import .import-preview th{white-space:nowrap;z-index:3}.modal-import .import-preview .select-col{width:34px;min-width:34px;text-align:center}.modal-import .import-preview .review-col{min-width:180px;max-width:290px}.modal-import .import-preview td:nth-child(7){min-width:120px}.modal-import .import-preview td:nth-child(6){min-width:150px}
.import-bulk-drawer{position:absolute;top:0;right:0;width:min(360px,88%);height:min(620px,calc(100% - 4px));max-height:78vh;background:#fff;border:1px solid #d7deea;border-radius:14px;box-shadow:-18px 20px 45px rgba(15,23,42,.16);z-index:20;transform:translateX(108%);opacity:0;pointer-events:none;transition:.18s ease;display:flex;flex-direction:column;overflow:hidden}
.import-bulk-drawer.open{transform:translateX(0);opacity:1;pointer-events:auto}.import-bulk-head{display:flex;justify-content:space-between;align-items:center;padding:11px 12px;border-bottom:1px solid var(--line);background:#f8fafc;font-size:13px}.import-bulk-scroll{overflow:auto;padding:10px 12px;display:grid;gap:9px}.import-bulk-actions{display:flex;gap:8px;padding:10px 12px;border-top:1px solid var(--line);background:#fff;margin-top:auto}.import-bulk-actions button{flex:1;padding:8px 9px;font-size:11px}.import-match-box{border:1px solid #dbe4f0;background:#f8fbff;border-radius:10px;padding:9px}.import-match-box>label{display:block;font-size:10.5px;font-weight:700;margin-bottom:6px}.import-match-row{display:grid;grid-template-columns:1fr 86px auto;gap:5px}.import-match-row input,.import-match-row select{min-width:0;border:1px solid #d9dee8;border-radius:7px;padding:7px;font-size:11px}.import-bulk-compact{margin:0;gap:7px}.import-rule-box{border:1px solid #dbe4f0;background:#f7fbf7;border-radius:10px;padding:9px;display:grid;gap:8px}.import-rule-row{display:flex;gap:6px;align-items:center;justify-content:space-between;font-size:11px}
.modal-import .import-commit-bar{position:sticky;bottom:0;z-index:15;background:#fff;border-top:1px solid var(--line);padding:9px 2px 0;margin:0;flex:0 0 auto}.modal-import .import-commit-bar .primary{padding:8px 12px;font-size:11px}.modal-import .import-skip-options{font-size:10.5px}
.import-skip-note{font-size:10.5px;padding:8px 10px;margin:8px 0}.modal-import small.muted{font-size:10px;line-height:1.45}
@media(max-width:1100px){.modal-card.modal-import{width:98vw;height:94vh;min-width:0}.import-mapping-grid{grid-template-columns:repeat(3,minmax(120px,1fr))}.modal-import .import-preview{max-height:50vh}}
@media(max-width:760px){.modal{padding:4px}.modal-card.modal-wide,.modal-card.modal-import{width:99vw;height:97vh;max-height:97vh;border-radius:10px;padding:11px;resize:none}.import-titlebar{padding-left:36px}.import-window-actions .secondary{font-size:0}.import-window-actions .secondary:after{content:'⛶';font-size:16px}.import-mapping-grid{grid-template-columns:repeat(2,minmax(110px,1fr))}.modal-import .import-stats{grid-template-columns:repeat(2,1fr)}.import-bulk-drawer{position:fixed;top:8px;right:8px;bottom:8px;height:auto;max-height:none;width:calc(100vw - 16px)}.import-command-bar .muted{display:none}}

/* Grouped sidebar navigation */
.nav-group{display:flex;flex-direction:column;gap:2px;margin-top:6px;padding-top:6px;border-top:1px solid rgba(255,255,255,.07)}
.nav-group-toggle{border:0;background:transparent;color:#8fa0b8;text-align:right;padding:7px 10px;border-radius:8px;cursor:pointer;display:flex;align-items:center;justify-content:space-between;gap:8px;width:100%;font-size:11px;font-weight:800;letter-spacing:.02em}
.nav-group-toggle:hover{background:rgba(255,255,255,.06);color:#d7e0ee}
.nav-group.current .nav-group-toggle{color:#e8eef8}
.nav-group-caret{width:8px;height:8px;border-right:1.5px solid currentColor;border-bottom:1.5px solid currentColor;transform:rotate(45deg);opacity:.75;flex:0 0 auto;margin-left:2px}
.nav-group.open .nav-group-caret{transform:rotate(-45deg);margin-top:3px}
.nav-group-items{display:none;flex-direction:column;gap:2px}
.nav-group.open .nav-group-items{display:flex}
.nav-group .nav-btn{padding:7px 10px 7px 8px}
.sidebar nav::-webkit-scrollbar{width:6px}
.sidebar nav::-webkit-scrollbar-thumb{background:rgba(255,255,255,.16);border-radius:99px}

.hidden{display:none!important}
.login-screen{min-height:100vh;display:grid;place-items:center;background:linear-gradient(180deg,#0c1729,#173f93);padding:24px}
.login-card{width:min(420px,94vw);background:#fff;border-radius:18px;padding:28px 24px;box-shadow:0 24px 60px rgba(0,0,0,.25);display:grid;gap:12px;direction:rtl}
.login-card .brand-mark{width:48px;height:48px;border-radius:12px;background:#0c1729;color:#fff;display:grid;place-items:center;font-weight:900}
.login-card h1{margin:0;font-size:22px}
.login-card p{margin:0 0 6px;color:#667085;font-size:13px}
.login-error{background:#fff0f0;color:#b03c3c;border-radius:10px;padding:10px 12px;font-size:13px}
.staff-head{display:flex;justify-content:space-between;align-items:flex-start;gap:16px;margin-bottom:18px}
.staff-head h3{margin:0 0 6px;font-size:18px}
.staff-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(260px,1fr));gap:14px}
.staff-card{background:#fff;border:1px solid var(--line);border-radius:18px;padding:16px;box-shadow:var(--shadow);display:grid;gap:12px}
.staff-card.is-off{opacity:.62}
.staff-card-top{display:flex;align-items:center;gap:10px}
.staff-avatar{width:40px;height:40px;border-radius:12px;background:#0c1729;color:#fff;display:grid;place-items:center;font-weight:800}
.staff-id{flex:1;min-width:0}
.staff-id b{display:block}
.staff-id span{color:var(--muted);font-size:12px}
.staff-status{font-size:11px;font-weight:800;border-radius:999px;padding:4px 8px}
.staff-status.on{background:#e9f8f2;color:#087353}
.staff-status.off{background:#f4f4f5;color:#667085}
.staff-meta{display:flex;justify-content:space-between;gap:8px;font-size:12px}
.staff-role{background:#eef3ff;color:var(--accent2);font-weight:800;border-radius:999px;padding:4px 9px}
.staff-meter{height:6px;background:#eef2f7;border-radius:99px;overflow:hidden}
.staff-meter i{display:block;height:100%;background:linear-gradient(90deg,#2463eb,#173f93);border-radius:99px}
.staff-card-actions{display:flex;justify-content:flex-start}
.modal-card.modal-user{width:min(920px,96vw);max-height:92vh;padding:0;overflow:hidden}
.user-sheet{display:flex;flex-direction:column;max-height:92vh}
.user-sheet-head{padding:22px 24px 8px}
.user-sheet-head h2{margin:0 0 6px;font-size:22px}
.user-sheet-head p{margin:0;color:var(--muted);font-size:13px}
.user-sheet form{display:flex;flex-direction:column;min-height:0;flex:1}
.user-identity{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:12px;padding:16px 24px}
.user-role-block,.user-perm-block{padding:0 24px 16px}
.user-role-label,.user-perm-title b{display:block;font-size:12px;color:#4b5563;font-weight:800;margin-bottom:8px}
.user-perm-title{display:flex;justify-content:space-between;align-items:end;gap:12px;margin-bottom:10px}
.user-perm-title small{color:var(--muted);font-size:12px}
.job-chips{display:flex;flex-wrap:wrap;gap:8px}
.job-chip{border:1px solid #d9dee8;background:#fff;color:#243044;border-radius:999px;padding:8px 14px;cursor:pointer;font-weight:700;font-size:13px}
.job-chip.active{background:#0c1729;border-color:#0c1729;color:#fff}
.perm-matrix{display:grid;grid-template-columns:1fr 1fr;gap:12px;overflow:visible;padding-bottom:8px;max-height:none}
.perm-panel{border:1px solid var(--line);border-radius:16px;background:#f8fafc;overflow:hidden}
.perm-panel-head{display:flex;justify-content:space-between;align-items:center;padding:11px 13px;background:#fff;border-bottom:1px solid var(--line);cursor:pointer;list-style:none}
.perm-panel-head::-webkit-details-marker{display:none}
.perm-panel-head::marker{content:''}
.perm-panel-head:before{content:'▾';color:var(--gold);font-size:12px;margin-left:8px}
.perm-panel:not([open]) .perm-panel-head:before{content:'▸'}
.perm-panel:not([open]) .perm-panel-head{border-bottom:0}
.perm-panel-head b{display:block;font-size:13px}
.perm-panel-head small{color:var(--muted);font-size:11px}
.perm-all-bar{display:flex;justify-content:flex-end;gap:8px;padding:8px 13px 0;background:#fff}
.perm-all{border:0;background:#eef3ff;color:var(--accent2);border-radius:8px;padding:6px 9px;font-size:11px;font-weight:800;cursor:pointer}
.perm-rows{display:grid}
.perm-row{display:flex;justify-content:space-between;align-items:center;gap:10px;padding:10px 13px;border-top:1px solid #eef2f7}
.perm-row:first-child{border-top:0}
.perm-feature{font-size:13px;font-weight:700;color:#1f2937}
.perm-actions{display:flex;gap:6px;flex-wrap:wrap;justify-content:flex-end}
.perm-switch{display:inline-flex;align-items:center;gap:6px;border:1px solid #d9dee8;background:#fff;border-radius:999px;padding:5px 9px 5px 7px;cursor:pointer;user-select:none}
.perm-switch input{position:absolute;opacity:0;pointer-events:none}
.perm-switch i{width:28px;height:16px;border-radius:99px;background:#d5dbe6;position:relative;display:inline-block;transition:.15s}
.perm-switch i:after{content:'';position:absolute;top:2px;right:2px;width:12px;height:12px;border-radius:50%;background:#fff;transition:.15s}
.perm-switch em{font-style:normal;font-size:11px;font-weight:800;color:#667085}
.perm-switch.is-on{border-color:#c7d7fb;background:#eef3ff}
.perm-switch.is-on i{background:#2463eb}
.perm-switch.is-on i:after{right:14px}
.perm-switch.is-on em{color:#173f93}
.user-sheet-actions{display:flex;justify-content:flex-start;gap:10px;padding:14px 24px 20px;border-top:1px solid var(--line);background:#fff}
@media(max-width:860px){.user-identity,.perm-matrix{grid-template-columns:1fr}.staff-head{flex-direction:column}}

/* Sales workspace */
.lead-kpis{grid-template-columns:repeat(5,minmax(0,1fr));margin-bottom:16px}
.lead-toolbar{display:grid;gap:10px;margin-bottom:16px}
.lead-chip-row,.lead-search-row,.lead-bulk{display:flex;flex-wrap:wrap;gap:8px;align-items:center}
.lead-chip{border:1px solid var(--line);background:#fff;border-radius:999px;padding:7px 12px;cursor:pointer;font-size:12px;font-weight:700;color:#334155}
.lead-chip.active{background:#0c1729;color:#fff;border-color:#0c1729}
.lead-search{min-width:min(320px,100%);border:1px solid var(--line);border-radius:10px;padding:9px 12px;background:#fff}
.lead-bulk{padding:10px 12px;border:1px solid #d7e3ff;background:#f6f9ff;border-radius:12px}
.lead-bulk select{min-width:200px;border:1px solid #d9dee8;border-radius:9px;padding:8px 10px}
.lead-board{display:grid;grid-template-columns:repeat(6,minmax(180px,1fr));gap:10px;overflow-x:auto;padding-bottom:8px}
.lead-col{background:#fff;border:1px solid var(--line);border-radius:16px;min-width:180px;display:flex;flex-direction:column;max-height:68vh}
.lead-col header{display:flex;justify-content:space-between;align-items:center;padding:12px 12px 8px;position:sticky;top:0;background:#fff;border-radius:16px 16px 0 0}
.lead-col header b{font-size:13px}
.lead-col header span{background:#eef2f7;border-radius:999px;padding:2px 7px;font-size:11px;font-weight:800;color:#475467}
.lead-col-body{overflow:auto;padding:0 10px 10px;display:grid;gap:8px}
.lead-card{border:1px solid var(--line);border-radius:12px;padding:11px;background:#fbfcfe;cursor:pointer;display:grid;gap:6px;position:relative}
.lead-card:hover{border-color:#c7d7fb;background:#fff}
.lead-card.is-overdue{border-color:#f2d39a;background:#fffaf0}
.lead-card-top{display:flex;justify-content:space-between;gap:8px;align-items:flex-start}
.lead-card-top b{font-size:13px}
.lead-source{font-size:10px;font-weight:800;color:#2456b3;background:#eef3ff;border-radius:999px;padding:2px 7px}
.lead-phone{font-size:12px;color:#475467}
.lead-card-meta{display:flex;justify-content:space-between;gap:8px;font-size:11px;color:#667085}
.lead-check{position:absolute;top:8px;left:8px}
.empty-leads{text-align:center;padding:36px 20px;display:grid;gap:10px;justify-items:center}
.modal-card.modal-lead{width:min(820px,96vw);max-height:92vh;padding:0;overflow:hidden}
.lead-sheet{display:flex;flex-direction:column;max-height:92vh}
.lead-sheet-head{padding:22px 24px 10px;display:flex;align-items:center;gap:12px}
.lead-sheet-head h2{margin:0 0 4px;font-size:22px}
.lead-sheet-head p{margin:0;color:var(--muted);font-size:13px}
.lead-avatar{width:44px;height:44px;border-radius:12px;background:#0c1729;color:#fff;display:grid;place-items:center;font-weight:800;flex:0 0 auto}
.lead-status{margin-right:auto;border-radius:999px;padding:5px 10px;font-size:11px;font-weight:800;background:#eef2f7}
.lead-status.new{background:#eef3ff;color:#2456b3}
.lead-status.talk{background:#e9f8f2;color:#087353}
.lead-status.quote{background:#fff7e6;color:#8a5b06}
.lead-status.nego{background:#f4e9ff;color:#6d28d9}
.lead-status.won{background:#e9f8f2;color:#087353}
.lead-status.lost{background:#fff0ef;color:#b03c3c}
.lead-sheet-meta{display:grid;grid-template-columns:repeat(4,1fr);gap:10px;padding:0 24px 14px}
.lead-sheet-meta small{display:block;color:var(--muted);font-size:11px;margin-bottom:4px}
.lead-sheet-form,.lead-follow{padding:0 24px;display:grid;gap:12px;overflow:auto}
.lead-sheet-actions{display:flex;flex-wrap:wrap;gap:8px;padding:14px 24px 18px}
.lead-timeline{padding:0 24px 22px;overflow:auto}
.lead-timeline h3{margin:8px 0 10px;font-size:14px}
.lead-event{display:flex;gap:10px;padding:10px 0;border-bottom:1px solid var(--line)}
.lead-event-type{flex:0 0 64px;font-size:11px;font-weight:800;color:#2456b3}
.lead-event small{display:block;color:var(--muted);margin-top:3px}
.lead-import-card{margin-bottom:8px}
.quote-board{grid-template-columns:repeat(5,minmax(180px,1fr))}
.job-board{grid-template-columns:repeat(4,minmax(180px,1fr))}
.assign-board{grid-template-columns:repeat(4,minmax(180px,1fr))}
.assign-board.is-staff{grid-template-columns:repeat(3,minmax(180px,1fr))}
.assign-timer{font-family:ui-monospace,SFMono-Regular,Menlo,Consolas,monospace;font-weight:800;font-size:15px;color:var(--accent2);letter-spacing:.04em}
.assign-card-actions{display:flex;flex-wrap:wrap;gap:6px;margin-top:4px}
.pay-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(240px,1fr));gap:10px;padding:4px 0}
.warning{padding:10px 12px;border-radius:10px;margin:0 0 12px}
.quote-totals{display:grid;grid-template-columns:repeat(5,1fr);gap:10px;margin:14px 0;padding:12px;border:1px solid var(--line);border-radius:12px;background:#f8fafc}
.quote-totals small{display:block;color:var(--muted);font-size:11px;margin-bottom:4px}
.prod-lines{display:grid;gap:10px}
.prod-lines table input,.prod-lines table select{width:100%;border:1px solid var(--line);border-radius:8px;padding:7px 8px;background:#fff}
.job-task{display:flex;align-items:center;gap:10px;padding:10px 12px;border:1px solid var(--line);border-radius:12px;background:#fbfcfe;font-weight:700}
.job-task input{width:18px;height:18px}
@media(max-width:1200px){.lead-kpis{grid-template-columns:repeat(3,1fr)}.lead-board{grid-template-columns:repeat(3,minmax(200px,1fr))}.quote-board,.job-board,.assign-board{grid-template-columns:repeat(2,minmax(200px,1fr))}.lead-sheet-meta,.quote-totals{grid-template-columns:1fr 1fr}}
@media(max-width:760px){.lead-kpis,.lead-board,.quote-board,.job-board,.assign-board,.lead-sheet-meta,.quote-totals{grid-template-columns:1fr}.lead-col{max-height:none}}
.notif-wrap{position:relative;z-index:8}
.notif-bell{position:relative;width:42px;height:42px;border:1px solid var(--line);border-radius:12px;background:#f8fafc;color:var(--accent2);cursor:pointer;display:grid;place-items:center;padding:0}
.notif-bell:hover,.notif-wrap.is-open .notif-bell{background:#eef3ff;border-color:#c9d7f5}
.notif-ico{font-size:16px;line-height:1}
.notif-badge{position:absolute;top:-6px;left:-6px;min-width:18px;height:18px;padding:0 5px;border-radius:999px;background:var(--bad);color:#fff;font-size:10px;font-weight:800;display:grid;place-items:center}
.notif-badge.hidden{display:none}
.notif-panel{position:absolute;top:calc(100% + 10px);left:0;width:min(380px,86vw);max-height:min(70vh,520px);overflow:hidden;display:flex;flex-direction:column;background:#fff;border:1px solid var(--line);border-radius:16px;box-shadow:0 18px 50px rgba(16,24,40,.16)}
.notif-panel.hidden{display:none}
.notif-head{display:flex;justify-content:space-between;align-items:center;gap:10px;padding:12px 14px;border-bottom:1px solid var(--line)}
.notif-head-actions{display:flex;gap:6px;flex-wrap:wrap}
.notif-row{display:grid;grid-template-columns:1fr auto;align-items:stretch;border-bottom:1px solid var(--line)}
.notif-row .notif-item{border-bottom:0}
.notif-snooze{margin:8px 8px 8px 0;align-self:center}
.notif-head b{font-size:14px}
.notif-tabs{display:flex;gap:4px;background:#f1f5f9;border-radius:10px;padding:3px}
.notif-tab{border:0;background:transparent;border-radius:8px;padding:6px 10px;font-size:12px;font-weight:700;color:var(--muted);cursor:pointer}
.notif-tab.active{background:#fff;color:var(--accent2);box-shadow:0 1px 3px rgba(16,24,40,.08)}
.notif-item.is-group{background:#f8fafc}
.notif-list{overflow:auto;max-height:min(58vh,440px)}
.notif-item{width:100%;border:0;border-bottom:1px solid var(--line);background:#fff;text-align:right;padding:13px 16px;cursor:pointer;display:grid;gap:4px;color:inherit}
.notif-item:hover{background:#f8fafc}
.notif-item:last-child{border-bottom:0}
.notif-item b{font-size:13px}
.notif-item span{font-size:12px;color:var(--muted)}
.notif-item small{font-size:11px;color:#94a3b8}
.notif-list .empty{padding:28px 16px}
@media(max-width:760px){.notif-panel{left:auto;right:0}}

.home-hero{display:flex;justify-content:space-between;align-items:center;gap:16px;margin-bottom:10px}
.home-hero h3{margin:0 0 4px;font-size:18px}
.home-backup{margin:0 4px 14px}
.home-queue{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:12px;margin-bottom:16px}
.home-q{border:1px solid var(--line);background:#fff;border-radius:14px;padding:16px;text-align:right;cursor:pointer;display:grid;gap:6px;box-shadow:var(--shadow);color:inherit}
.home-q:hover{border-color:#c9d7f5;background:#f8fbff}
.home-q b{font-size:15px}
.home-q span{font-size:12px;color:var(--muted)}
.home-q.is-warn{background:#fff8eb;border-color:#f2d39a}
.home-q.is-bad{background:#fff4f2;border-color:#f3c4c0}
.home-funnel,.home-week,.home-commission,.home-cash,.home-fx,.home-team,.home-calls,.home-crew,.home-waiting{margin-top:16px}
.home-fx-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:10px}
.home-fx-rate{border:1px solid var(--line,#d9dee8);border-radius:12px;padding:12px 14px;background:var(--card,#f7f8fb)}
.home-fx-rate span{display:block;font-size:12px;color:var(--muted,#667085);margin-bottom:4px}
.home-fx-rate b{display:block;font-size:22px;letter-spacing:.02em}
.home-fx-rate small{display:block;margin-top:4px;color:var(--muted,#667085)}
.home-fx-rate.is-err b{color:var(--bad,#b42318)}
.today-calls,.crew-list{display:grid;gap:8px}
.today-call{border:1px solid var(--line);border-radius:12px;padding:10px 12px;display:flex;flex-wrap:wrap;gap:10px;align-items:center;justify-content:space-between}
.today-call.is-overdue{background:#fff8eb;border-color:#f2d39a}
.today-call-main{border:0;background:none;padding:0;text-align:right;cursor:pointer;color:inherit;display:grid;gap:2px}
.today-call-main small{color:var(--muted)}
.today-call-actions{display:flex;flex-wrap:wrap;gap:6px}
.crew-row{border:1px solid var(--line);background:#fff;border-radius:12px;padding:12px 14px;text-align:right;cursor:pointer;display:grid;gap:4px;color:inherit}
.crew-row:hover{background:#f8fafc}
.crew-row small{color:var(--muted)}
.wait-grid{display:grid;grid-template-columns:1fr 1fr;gap:16px}
.wait-col h4{margin:0 0 10px;font-size:14px}
.wait-row{display:flex;gap:8px;align-items:center;margin-bottom:8px}
.wait-main{flex:1;border:1px solid var(--line);background:#fff;border-radius:10px;padding:10px 12px;text-align:right;cursor:pointer;display:flex;justify-content:space-between;color:inherit}
.wait-row.is-warn .wait-main{background:#fff8eb;border-color:#f2d39a}
.wait-row.is-bad .wait-main{background:#fff4f2;border-color:#f3c4c0}
.job-reschedule{display:flex;flex-wrap:wrap;gap:8px;align-items:center;margin:0 24px 14px}
.job-reschedule b{width:100%;font-size:13px}
.job-reschedule input{border:1px solid var(--line);border-radius:8px;padding:8px 10px}
.call-outcomes{display:flex;flex-wrap:wrap;gap:8px;align-items:center;margin:0 24px 14px}
.call-outcomes b{width:100%;font-size:13px}
.home-cash-kpis{grid-template-columns:repeat(4,minmax(0,1fr));margin:0 0 10px}
.home-banks{display:flex;flex-wrap:wrap;gap:8px;margin:0 0 10px}
.home-banks span{background:var(--card,#f4f6fa);border:1px solid var(--line,#d9dee8);border-radius:10px;padding:6px 10px;font-size:12px}
.home-cash .cash-verdict{font-weight:800}
.home-cash.is-ok .cash-verdict{color:#1f7a4d}
.home-cash.is-short .cash-verdict{color:#b42318}
.week-row.is-deposit{background:#fff8eb;border-color:#f2d39a}
.funnel-bars{display:grid;gap:10px}
.funnel-row{display:grid;grid-template-columns:minmax(110px,160px) 1fr 42px;gap:10px;align-items:center;font-size:12px}
.funnel-track{height:12px;border-radius:999px;background:#edf0f5;overflow:hidden}
.funnel-fill{height:100%;border-radius:999px;background:linear-gradient(90deg,#2463eb,#7398f5)}
.week-list{display:grid;gap:8px}
.week-row{border:1px solid var(--line);background:#fff;border-radius:12px;padding:12px 14px;text-align:right;cursor:pointer;display:grid;grid-template-columns:140px 1fr auto;gap:8px;align-items:center;color:inherit}
.week-row:hover{background:#f8fafc}
.week-row b{font-size:13px}
.week-row span{font-weight:700}
.week-row small{grid-column:2;color:var(--muted)}
.week-row em{font-style:normal;color:var(--muted);font-size:12px}
.job-fin{margin-top:0}
.home-mine,.home-lost{margin-top:16px}
.home-mine-kpis{grid-template-columns:repeat(3,minmax(0,1fr));margin:0}
.funnel-fill.is-lost{background:linear-gradient(90deg,#d94c4c,#f0a0a0)}
.linkish{border:0;background:none;padding:0;color:var(--accent2);font:inherit;cursor:pointer;text-decoration:underline;text-underline-offset:2px}
.crew-picker{display:flex;flex-wrap:wrap;gap:8px;margin:6px 0 8px}
.crew-pick{display:flex;align-items:center;gap:6px;border:1px solid var(--line);border-radius:999px;padding:6px 10px;background:#f8fafc;font-size:12px;cursor:pointer}
.crew-pick:has(input:checked){background:#eef3ff;border-color:#c9d7f5}
.lost-reason-field{display:none}
@media(max-width:760px){.home-mine-kpis,.home-cash-kpis,.home-fx-grid{grid-template-columns:1fr}}
@media(max-width:1100px){.home-queue{grid-template-columns:repeat(2,1fr)}.week-row{grid-template-columns:1fr}.home-cash-kpis{grid-template-columns:repeat(2,1fr)}}
@media(max-width:760px){.home-queue,.funnel-row,.wait-grid{grid-template-columns:1fr}.home-hero{flex-direction:column;align-items:stretch}}

/* Readable studio — light paper, larger type, no overlap */
html{background:var(--bg);color-scheme:light}
body{background:var(--bg);color:var(--ink);font-size:16px;line-height:1.65;letter-spacing:0}
::selection{background:rgba(141,106,47,.22);color:var(--ink)}
.sidebar{color:#f6f1e8;border-left:1px solid rgba(246,241,232,.12)}
.sidebar .brand em{font-size:12px;color:#e0c48a}
.sidebar .brand b{font-size:16px;color:#fffdf8;font-family:"IBM Plex Sans Arabic",sans-serif}
.sidebar .brand span{font-size:13px;color:#c9c2b6}
.nav-btn{color:#efe7da;font-size:15px;padding:10px 12px;min-height:44px}
.nav-btn:hover,.nav-btn.active{background:rgba(224,196,138,.16);color:#fff}
.nav-group-toggle{color:#d4cbbd;letter-spacing:.04em;text-transform:none;font-weight:700;font-size:13px;min-height:40px}
.nav-group-toggle:hover,.nav-group.current .nav-group-toggle{color:#e0c48a;background:rgba(224,196,138,.1)}
.nav-group{border-top-color:rgba(246,241,232,.1)}
.sidebar-footer{font-size:13px;color:#c9c2b6}
.sidebar-footer .ghost{color:#fffdf8;min-height:44px;font-size:15px}
.user-chip{padding:12px;border:1px solid rgba(246,241,232,.14);border-radius:12px;background:rgba(255,253,248,.06)}
.user-chip b{display:block;color:#fffdf8;font-size:15px}
.user-chip span{color:#c9c2b6;font-size:13px}
main>header{min-height:0;background:rgba(255,253,248,.96);color:var(--ink);backdrop-filter:blur(16px);flex-wrap:wrap;align-items:flex-start;padding:16px 24px;gap:12px}
.header-start{display:flex;align-items:flex-start;gap:12px;flex:1 1 260px;min-width:0}
.page-identity{min-width:0;flex:1}
.page-kicker{display:block;font-size:12px;letter-spacing:.08em;text-transform:none;color:var(--gold);margin-bottom:4px;font-weight:700}
main>header h1{font-family:"IBM Plex Sans Arabic",sans-serif;font-size:26px;font-weight:700;line-height:1.25;letter-spacing:0}
main>header p{font-size:15px;line-height:1.45;max-width:42ch}
.header-actions{display:flex;gap:8px;align-items:center;flex-wrap:wrap;flex:0 1 auto}
.nav-toggle{display:none;border:1px solid var(--line);background:#fff;color:var(--ink);width:44px;height:44px;border-radius:12px;cursor:pointer;font-size:20px}
.nav-scrim{position:fixed;inset:0;background:rgba(29,25,20,.4);z-index:8}
.pill{background:#f3ead7;color:#6b4f1f;border:1px solid #e4d4b4;font-size:13px;padding:8px 12px}
.primary,.secondary,.danger,.tiny{min-height:44px;font-size:15px}
.primary{background:var(--gold);color:#fffdf8;font-weight:700}
.primary:hover{filter:brightness(1.05)}
.secondary,.tiny.secondary,a.export-btn.secondary{background:#fff;color:var(--ink);border:1px solid var(--line)}
.danger{background:#fff1ef;color:var(--bad)}
.tiny{min-height:36px;font-size:13px;padding:8px 12px}
.card,.account-card,.staff-card,.lead-col,.lead-card,.login-card{background:var(--panel);border:1px solid var(--line);box-shadow:var(--shadow);color:var(--ink)}
.section-head{flex-wrap:wrap;align-items:flex-start;gap:8px}
.section-head h3,.modal h2,.lead-sheet-head h2,.user-sheet-head h2,.staff-head h3{
  font-family:"IBM Plex Sans Arabic",sans-serif;font-size:18px;font-weight:700;line-height:1.35;margin:0
}
.section-head span,.section-head .muted{flex:1 1 160px;min-width:0}
.kpi .label{font-size:13px}
.kpi .value,.account-card .bal,.money-cell,.num{font-variant-numeric:tabular-nums;font-family:"IBM Plex Mono","IBM Plex Sans Arabic",monospace}
.kpi .value{font-size:22px;word-break:break-word}
table{font-size:14px}
th,td{padding:12px 10px}
th{background:#f3eee4;color:#5c564c;font-size:12px}
.table-wrap{background:#fff;overflow:auto}
.badge{background:#f3eee4;color:#3d3830;font-size:12px}
.badge.income,.staff-status.on,.lead-status.talk,.lead-status.won{background:#e7f6ee;color:#146c43}
.badge.expense,.lead-status.lost,.badge.bad{background:#fdecea;color:#b42318}
.badge.active,.lead-status.new,.lead-source,.staff-role{background:#f3ead7;color:#6b4f1f}
.badge.cancelled,.staff-status.off{background:#f1eee8;color:#5c564c}
.lead-status.quote{background:#fff4d6;color:#7a5b00}
.lead-status.nego{background:#f3ead7;color:#6b4f1f}
.toolbar input,.toolbar select,.lead-search,.field input,.field select,.field textarea,
.prod-lines table input,.prod-lines table select,.job-reschedule input,.import-match-row input,.import-match-row select{
  background:#fff;border:1px solid #d8d0c4;color:var(--ink);font-size:15px;min-height:44px
}
.field label,.user-role-label,.user-perm-title b,.more-filters summary{color:#3d3830;font-size:13px}
.warning{background:#fff7e6;border-color:#f2d39a;color:#7a5b00;font-size:14px}
.modal{background:rgba(29,25,20,.45)}
.modal-card{background:#fffdf8;color:var(--ink);border:1px solid var(--line)}
.close{background:#f3eee4;color:var(--ink)}
.entry-type-tabs button,.report-tabs button,.lead-chip,.job-chip{
  background:#fff;border:1px solid var(--line);color:var(--ink);font-size:14px;min-height:40px
}
.entry-type-tabs button.active,.report-tabs button.active,.lead-chip.active,.job-chip.active{
  background:var(--gold);color:#fffdf8;border-color:var(--gold)
}
.compact-filter-card,.advanced-filter,.report-filter,.lead-bulk,.quick-payment-box,.quick-payment-note,
.quote-totals,.perm-panel,.role-checks,.import-context,.import-command-bar,.ai-answer,.check-inline{
  background:#faf6ef;border-color:var(--line);color:var(--ink)
}
.quick-payment-box b,.quick-payment-note b,.linkish,.lead-event-type,.filter-count{color:var(--gold)}
.more-filters summary:before{background:#f3ead7;color:var(--gold)}
.lead-col header{height:auto!important;min-height:0;background:transparent;border:0;padding:12px;position:sticky;box-shadow:none}
.lead-col header span{background:#f3eee4;color:var(--muted)}
.lead-card{background:#fff}
.lead-card:hover{border-color:#d4b56a;background:#fffdf8}
.lead-card.is-overdue,.today-call.is-overdue,.week-row.is-deposit,.home-q.is-warn,.wait-row.is-warn .wait-main{
  background:#fff8eb;border-color:#f2d39a
}
.home-q.is-bad,.wait-row.is-bad .wait-main{background:#fff4f2;border-color:#f3c4c0}
.lead-phone,.lead-card-meta,.lead-event small{color:var(--muted);font-size:13px}
.lead-sheet-head,.user-sheet-head,.user-sheet-actions{background:#fffdf8}
.lead-avatar,.staff-avatar{background:#f3ead7;color:#6b4f1f;border:1px solid #e4d4b4}
.job-task,.week-row,.crew-row,.wait-main,.today-call,.home-q{
  background:#fff;border:1px solid var(--line);color:inherit
}
.week-row:hover,.crew-row:hover,.home-q:hover,.wait-main:hover{background:#faf6ef;border-color:#d4b56a}
.funnel-track,.staff-meter,.analysis-bar-track{background:#efe8db}
.funnel-fill,.analysis-bar-fill,.staff-meter i{background:linear-gradient(90deg,#8d6a2f,#d4b56a)}
.notif-bell{background:#fff;border:1px solid var(--line);color:var(--gold)}
.notif-bell:hover,.notif-wrap.is-open .notif-bell{background:#f3ead7;border-color:#d4b56a}
.notif-panel{background:#fffdf8;border:1px solid var(--line);box-shadow:var(--shadow)}
.notif-tabs{background:#f3eee4}
.notif-tab.active{background:#fff;color:var(--gold)}
.notif-item{background:#fff;color:var(--ink)}
.notif-item:hover,.notif-item.is-group{background:#faf6ef}
.login-screen{position:relative;background:#1d1914;overflow:hidden;min-height:100vh}
.login-veil{position:absolute;inset:0;background:radial-gradient(800px 400px at 70% 10%,rgba(224,196,138,.18),transparent 55%)}
.login-card{position:relative;z-index:1;background:#fffdf8;border:1px solid #e4d4b4;color:var(--ink);padding:36px 28px}
.login-kicker{font-size:13px;letter-spacing:.18em;text-transform:uppercase;color:var(--gold)}
.login-card h1{font-family:"IBM Plex Sans Arabic",sans-serif;font-size:30px;font-weight:700;margin-top:8px;color:var(--ink)}
.login-card p{color:var(--muted);font-size:16px}
.login-card .brand-mark{background:var(--gold);color:#fffdf8}
.login-error{background:#fdecea;color:#b42318}
.home-layout{display:grid;grid-template-columns:1fr;gap:20px;align-items:start}
.home-layout.home-cols-2{grid-template-columns:1fr 1fr}
.home-layout.home-cols-3{grid-template-columns:1fr 1fr}
.home-col,.card,.page-identity,.header-actions{min-width:0}
.home-col{display:grid;gap:16px}
.home-col-kicker{font-size:13px;letter-spacing:0;text-transform:none;color:var(--gold);font-weight:700}
.block-head{display:flex;align-items:center;flex-wrap:wrap;gap:8px;margin-bottom:10px}
.block-head span{font-size:13px;letter-spacing:0;text-transform:none;color:var(--gold);font-weight:700}
.block-head h3{margin:0;flex:1 1 160px;font-family:"IBM Plex Sans Arabic",sans-serif;font-size:22px;font-weight:700}
.home-queue{display:grid;grid-template-columns:1fr;gap:10px;margin:0}
.home-q,.week-row,.crew-row,.wait-main,.today-call{font-size:15px}
.home-funnel,.home-week,.home-commission,.home-cash,.home-fx,.home-team,.home-calls,.home-crew,.home-waiting,
.home-mine,.home-lost{margin-top:0}
.home-now .home-backup{margin:0 0 14px;font-size:14px}
.home-cash-kpis,.home-mine-kpis{grid-template-columns:repeat(2,minmax(0,1fr))}
.card .card.kpi{background:#faf6ef;box-shadow:none}
.week-row{grid-template-columns:1fr;gap:4px}
.week-row b,.week-row span,.week-row small,.week-row em{grid-column:1}
.funnel-row{grid-template-columns:minmax(0,1fr) minmax(80px,1.4fr) 36px;font-size:14px}
.perm-row,.perm-panel-head,.lead-event,.user-sheet-actions{border-color:var(--line);background:#fff}
.perm-panel-head{list-style:none}
.perm-panel-head::-webkit-details-marker{display:none}
.perm-panel-head::marker{content:''}
.perm-panel-head:before{content:'▾';color:var(--gold);font-size:12px;margin-left:8px}
.perm-panel:not([open]) .perm-panel-head:before{content:'▸'}
.perm-panel:not([open]) .perm-panel-head{border-bottom:0}
.perm-feature{color:var(--ink)}
.perm-switch{background:#fff;border-color:var(--line)}
.perm-switch i{background:#d8d0c4}
.perm-switch.is-on{background:#f3ead7;border-color:var(--gold)}
.perm-switch.is-on i{background:var(--gold)}
.perm-switch.is-on em,.perm-all{color:var(--gold)}
.perm-all{background:#f3ead7}
.role-checks,.role-checks .role-option{background:#fff;color:var(--ink)}
.import-bulk-drawer,.import-bulk-head,.import-bulk-actions,.modal-import .import-commit-bar{background:#fffdf8;border-color:var(--line)}
.import-match-box{background:#faf6ef;border-color:var(--line)}
.import-error-row,.import-global-error{background:#fdecea;color:#b42318}
.import-dup-row{background:#fff8eb}
.good-text{color:var(--good)}.bad-text{color:var(--bad)}.warn-text{color:var(--warn)}
.crew-pick{background:#faf6ef;border-color:var(--line)}
.crew-pick:has(input:checked){background:#f3ead7;border-color:var(--gold)}
.bar.in,.legend-in{background:#7d9d78}.bar.out,.legend-out{background:#c98982}
.home-cash.is-ok .cash-verdict{color:var(--good)}
.home-cash.is-short .cash-verdict{color:var(--bad)}
.viewer-mode #accessPill{background:#f1eee8;color:var(--muted)}
tbody tr:hover td{background:#faf6ef}
a.export-btn.secondary{text-decoration:none}
button:focus-visible,a:focus-visible,input:focus-visible,select:focus-visible,textarea:focus-visible{
  outline:2px solid var(--gold);outline-offset:2px
}
@media(min-width:1400px){
  .home-layout.home-cols-3{grid-template-columns:1.1fr 1fr .9fr}
}
@media(max-width:980px){
  .home-layout,.home-layout.home-cols-2,.home-layout.home-cols-3{grid-template-columns:1fr}
}
@media(max-width:760px){
  .nav-toggle{display:grid;place-items:center}
  .app-shell{grid-template-columns:1fr}
  .sidebar{position:fixed;inset:0 0 0 auto;width:min(320px,88vw);z-index:9;transform:translateX(110%);transition:transform .22s ease;height:100vh}
  body.nav-open .sidebar{transform:translateX(0)}
  main>header{position:sticky;padding:12px 14px}
  .header-actions .pill,#viewerLinksBtn,#pageSub{display:none}
  .home-cash-kpis,.home-mine-kpis,.wait-grid{grid-template-columns:1fr}
}
@media(prefers-reduced-motion:reduce){
  *,*::before,*::after{animation:none!important;transition:none!important}
}

/* User permissions sheet — one obvious scroll, last group reachable */
.modal-card.modal-user{
  width:min(980px,96vw);
  height:92vh;
  max-height:92vh;
  padding:0;
  overflow:hidden;
  display:flex;
  flex-direction:column;
}
.user-sheet{display:flex;flex-direction:column;height:100%;min-height:0}
.user-sheet-head{flex:0 0 auto;padding:16px 24px 8px}
.user-sheet form{display:flex;flex-direction:column;flex:1;min-height:0;overflow:hidden}
.user-sheet-scroll{
  flex:1 1 auto;
  min-height:0;
  overflow-y:scroll;
  overflow-x:hidden;
  padding-bottom:28px;
  -webkit-overflow-scrolling:touch;
  overscroll-behavior:contain;
}
.user-identity,.user-role-block,.user-perm-block,#usrPerms{flex:none;max-height:none;overflow:visible}
.perm-matrix{
  display:grid;
  grid-template-columns:1fr 1fr;
  gap:12px;
  max-height:none;
  overflow:visible;
  padding-bottom:24px;
}
.user-sheet-actions{flex:0 0 auto;background:#fffdf8;padding:12px 24px 16px}
@media(max-width:860px){
  .modal-card.modal-user{max-height:96vh;width:99vw}
  .perm-matrix{grid-template-columns:1fr}
}

/* English / LTR */
.lang-toggle{
  border:1px solid var(--line);
  background:#fff;
  color:var(--ink);
  border-radius:10px;
  min-height:44px;
  padding:8px 14px;
  font-weight:700;
  cursor:pointer;
}
.login-card .lang-toggle{justify-self:start}
html[dir="ltr"] .sidebar{direction:ltr;border-left:0;border-right:1px solid var(--line);text-align:left}
html[dir="ltr"] .nav-btn,html[dir="ltr"] .nav-group-toggle{text-align:left}
html[dir="ltr"] .login-card{direction:ltr}
html[dir="ltr"] .home-q,html[dir="ltr"] .week-row,html[dir="ltr"] .crew-row,
html[dir="ltr"] .wait-main,html[dir="ltr"] .today-call-main,html[dir="ltr"] .notif-item{text-align:left}
html[dir="ltr"] th,html[dir="ltr"] td{text-align:left}
html[dir="ltr"] .field label,html[dir="ltr"] .section-head,html[dir="ltr"] .block-head{text-align:left}
html[dir="ltr"] .lead-status{margin-right:0;margin-left:auto}
html[dir="ltr"] .notif-panel{left:auto;right:0}
@media(max-width:760px){
  html[dir="ltr"] .sidebar{inset:0 auto 0 0;transform:translateX(-110%)}
  html[dir="ltr"] body.nav-open .sidebar{transform:translateX(0)}
}
.integration-grid{grid-template-columns:repeat(3,minmax(0,1fr));margin:0 0 18px;align-items:stretch}
.integration-grid .card{display:flex;flex-direction:column}
.integration-grid .migration-steps{margin:0 0 12px;padding-right:18px;color:var(--muted);font-size:13px;line-height:1.7}
.integration-grid .filter-actions{margin-top:auto}
@media(max-width:1100px){.integration-grid{grid-template-columns:1fr}}
.agree-lines{max-height:280px}.agree-lines input{min-width:0;width:100%}
.field.is-fx-needed label:after{content:' *';color:var(--bad)}
tr.is-collected td{background:#e7f6ee}
tr.is-partial td{background:#fff6e5}
tr.is-overdue td{background:#fdecea}
.hr-policy-body{white-space:pre-wrap;font-family:inherit;font-size:13px;line-height:1.7;margin:0;color:var(--muted)}
.hr-policy-section table{font-size:13px}
#spAmountHint{display:block;margin-top:6px;line-height:1.45}
