:root{
  --bg:#F4F5F0; --surface:#FFFFFF; --surface-2:#F8F9F5; --ink:#1A1A1A; --ink-2:#4A4D47; --muted:#7A7F76; --line:#E3E6DD; --line-2:#EDEFE8;
  --side:#FFFFFF; --side-2:#F0F3EA; --side-ink:#1A1A1A; --side-muted:#868B82;
  --sage:#5A7748; --sage-2:#8BA672; --sage-soft:#EEF3E3; --leaf:#B3C77F;
  --rose:#2B2B2B; --rose-2:#B3C77F; --rose-soft:#ECEDE8; --clay:#B2643A;
  --gold:#B88A3E; --gold-soft:#F4EAD6;
  --blue:#4F7397; --blue-soft:#E3ECF4;
  --danger:#B1463E; --danger-soft:#F7E1DE;
  --radius:14px; --radius-s:9px;
  --shadow:0 1px 2px rgba(26,26,26,.04),0 4px 14px rgba(26,26,26,.04);
  --font:"IBM Plex Sans Arabic","Segoe UI",Tahoma,sans-serif; --serif:var(--font);
}
*{box-sizing:border-box}
html,body{margin:0;height:100%}
body{background:var(--bg);color:var(--ink);font:14px/1.5 var(--font);-webkit-font-smoothing:antialiased}
button,input,select,textarea{font:inherit;color:inherit}
a{color:var(--sage)}
.num{font-variant-numeric:tabular-nums;direction:ltr;unicode-bidi:isolate;display:inline-block}
.muted{color:var(--muted)} .small{font-size:12px} .nowrap{white-space:nowrap}
.hidden{display:none!important}

/* ---------- shell ---------- */
.shell{display:grid;grid-template-columns:232px 1fr;height:100vh}
.side{border-inline-end:1px solid var(--line);background:var(--side);color:var(--side-ink);display:flex;flex-direction:column;padding:18px 12px;gap:4px;overflow:auto}
.brand{display:flex;flex-direction:column;align-items:flex-start;gap:7px;padding:8px 12px 20px}
.brand img{width:142px;height:auto;display:block}
.brand small{color:var(--side-muted);font-size:11.5px;letter-spacing:.2px}
.nav-sec{color:var(--side-muted);font-size:11px;padding:12px 12px 4px;letter-spacing:.3px}
.nav a{display:flex;align-items:center;gap:10px;padding:9px 12px;border-radius:10px;color:var(--side-ink);text-decoration:none;font-weight:500}
.nav a svg{width:18px;height:18px;flex:none;opacity:.85}
.nav a:hover{background:var(--side-2)}
.nav a.on{background:var(--ink);color:#fff;box-shadow:0 4px 12px rgba(26,26,26,.16)}
.nav a.on svg{color:var(--leaf);opacity:1}
.nav a .badge{margin-inline-start:auto;background:var(--leaf);color:var(--ink);border-radius:99px;font-size:11px;padding:0 7px;font-weight:700}
.nav a.on .badge{background:var(--leaf);color:var(--ink)}
.avatar{width:34px;height:34px;border-radius:50%;background:var(--sage-2);display:grid;place-items:center;font-weight:700;color:#fff;flex:none}
.icon-btn{background:none;border:0;color:inherit;cursor:pointer;padding:6px;border-radius:8px;display:grid;place-items:center}
.icon-btn:hover{background:rgba(26,26,26,.06)}
.main{overflow:auto;padding:18px 22px;display:flex;flex-direction:column;min-width:0}
.main>*{flex-shrink:0}
.main>.dash{flex:1 1 auto}
.page-head h1{font:700 26px/1.2 var(--serif);margin:0}
.page-head .sub{color:var(--muted);font-size:12.5px}
.demo-banner{background:var(--gold-soft);color:#7a5a20;border:1px solid #EAD9B5;border-radius:10px;padding:6px 12px;font-size:12.5px}

/* ---------- controls ---------- */
.btn{display:inline-flex;align-items:center;gap:6px;border:1px solid var(--line);background:var(--surface);border-radius:10px;padding:7px 14px;cursor:pointer;font-weight:500;white-space:nowrap;text-decoration:none;color:var(--ink)}
.btn:hover{border-color:#CDD2C5;background:#fff}
.btn.primary{background:var(--sage);border-color:var(--sage);color:#fff}
.btn.primary:hover{background:#4C663C}
.btn.rose{background:var(--rose);border-color:var(--rose);color:#fff}
.btn.danger{color:var(--danger);border-color:#E9C4BF}
.btn.sm{padding:4px 10px;font-size:12.5px;border-radius:8px}
.btn:disabled{opacity:.5;cursor:not-allowed}
.seg{display:inline-flex;background:var(--surface);border:1px solid var(--line);border-radius:10px;padding:3px}
.seg button{border:0;background:none;padding:5px 12px;border-radius:7px;cursor:pointer;color:var(--ink-2);font-weight:500}
.seg button.on{background:var(--ink);color:#fff}
input[type=text],input[type=number],input[type=date],input[type=time],input[type=month],input[type=password],input[type=url],input:not([type]),select,textarea{
  border:1px solid var(--line);background:#fff;border-radius:9px;padding:6px 10px;min-width:0;outline:none}
input:focus,select:focus,textarea:focus{border-color:var(--sage-2);box-shadow:0 0 0 3px var(--sage-soft)}
textarea{resize:vertical;width:100%}
label.f{display:flex;flex-direction:column;gap:4px;font-size:12.5px;color:var(--ink-2);font-weight:500}
.form-grid{display:grid;grid-template-columns:repeat(2,1fr);gap:12px}
.form-grid .full{grid-column:1/-1}
.filters{display:flex;gap:8px;align-items:center;flex-wrap:wrap}

/* ---------- cards ---------- */
.card{background:var(--surface);border:1px solid var(--line);border-radius:var(--radius);box-shadow:var(--shadow);display:flex;flex-direction:column;min-height:0;min-width:0}
.card-h{display:flex;align-items:center;gap:8px;padding:11px 14px;border-bottom:1px solid var(--line-2)}
.card-h h3{margin:0;font-size:14.5px;font-weight:700}
.card-h .spacer{flex:1}
.card-b{padding:12px 14px;min-height:0}
.card-b.scroll{overflow:auto}
.card-b.flush{padding:0}

/* ---------- KPI tiles ---------- */
.kpis{display:grid;grid-template-columns:repeat(6,1fr);gap:12px;margin-bottom:12px}
.kpi{background:var(--surface);border:1px solid var(--line);border-radius:var(--radius);padding:12px 14px;position:relative;overflow:hidden;box-shadow:var(--shadow);min-width:0}
.kpi::before{content:"";position:absolute;inset-inline-start:0;top:0;bottom:0;width:4px;background:var(--accent,var(--sage))}
.kpi .lbl{font-size:12.5px;color:var(--ink-2);font-weight:600;display:flex;align-items:center;gap:6px}
.kpi .lbl svg{width:16px;height:16px;color:var(--accent,var(--sage))}
.kpi .val{font-size:24px;font-weight:700;margin:4px 0 2px;line-height:1.2;white-space:nowrap}
.kpi .val small{font-size:12px;font-weight:500;color:var(--muted);margin-inline-start:4px}
.kpi .foot{font-size:11.5px;color:var(--muted);display:flex;gap:6px;flex-wrap:wrap;align-items:center;margin-top:6px}
.delta{font-weight:700;font-size:11.5px;white-space:nowrap}.delta.up{color:var(--sage)}.delta.down{color:var(--danger)}
.bar{height:5px;background:var(--line-2);border-radius:9px;overflow:hidden;margin-top:6px}
.bar i{display:block;height:100%;background:var(--accent,var(--sage));border-radius:9px}

/* ---------- dashboard grid (one screen) ---------- */
.dash{display:grid;gap:12px}
.dash .c-reps{grid-column:span 8}.dash .c-alerts{grid-column:span 4}
.dash .c-map{grid-column:span 4}.dash .c-trend{grid-column:span 4}.dash .c-side{grid-column:span 4;display:flex;flex-direction:column;gap:10px;min-height:0;min-width:0}

/* ---------- tables ---------- */
table.t{width:100%;border-collapse:collapse;font-size:13px}
.t th{position:sticky;top:0;background:var(--surface-2);color:var(--ink-2);font-weight:600;text-align:start;padding:8px 10px;border-bottom:1px solid var(--line);white-space:nowrap;z-index:1;font-size:12.5px}
.t td{padding:7px 10px;border-bottom:1px solid var(--line-2);vertical-align:middle}
.t tr:last-child td{border-bottom:0}
.t tbody tr:hover td{background:#FBF8F2}
.t tfoot td{font-weight:700;background:var(--surface-2);border-top:1px solid var(--line)}
.t td.n,.t th.n{text-align:end}
.t .name{font-weight:600}
.table-wrap{overflow:auto;min-height:0}
.empty{padding:28px;text-align:center;color:var(--muted)}

/* ---------- chips ---------- */
.chip{display:inline-flex;align-items:center;gap:4px;border-radius:99px;padding:1px 9px;font-size:11.5px;font-weight:600;white-space:nowrap;background:var(--line-2);color:var(--ink-2)}
.chip.ok{background:var(--sage-soft);color:#3F6B4B}.chip.warn{background:var(--gold-soft);color:#86621F}.chip.bad{background:var(--danger-soft);color:var(--danger)}
.chip.rose{background:var(--rose-soft);color:var(--ink)}.chip.blue{background:var(--blue-soft);color:var(--blue)}
.dot{width:8px;height:8px;border-radius:50%;display:inline-block;flex:none}

/* ---------- alerts ---------- */
.alerts{list-style:none;margin:0;padding:0}
.alerts li{display:flex;gap:10px;padding:9px 14px;border-bottom:1px solid var(--line-2);align-items:flex-start}
.alerts li:last-child{border-bottom:0}
.alerts li .dot{margin-top:6px}
.alerts li a{color:var(--ink);text-decoration:none;flex:1;font-size:13px}
.alerts li a:hover{text-decoration:underline}
.alerts .ref{font-size:10.5px;color:var(--muted);white-space:nowrap;margin-top:2px}
.sev-high{background:var(--danger)}.sev-med{background:var(--gold)}.sev-low{background:var(--blue)}

/* ---------- charts ---------- */
.chart{width:100%;height:100%;display:block}
.legend{display:flex;gap:14px;font-size:12px;color:var(--ink-2)}
.legend span{display:inline-flex;align-items:center;gap:6px}

/* ---------- entry page ---------- */
.entry{display:grid;grid-template-columns:minmax(0,1fr) 250px;gap:14px;align-items:start}
.entry-head{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:12px}
.sec{margin-top:14px}
.sec .card-h .count{color:var(--muted);font-size:12px}
.rows-t{table-layout:fixed;min-width:780px}
.rows-t input,.rows-t select{width:100%;padding:5px 7px;border-radius:7px}
.rows-t input[type=checkbox]{width:auto}
.rows-t th{white-space:normal;line-height:1.25}
.rows-t td{padding:5px 6px}
.rows-t th{padding:7px 6px}
.rows-t td.del{width:34px}
.rows-t .cust-ok{font-size:11px;margin-top:2px}
.add-row{border:1px dashed var(--line);background:none;border-radius:9px;padding:7px;width:100%;cursor:pointer;color:var(--sage);font-weight:600;margin-top:6px}
.add-row:hover{background:var(--sage-soft)}
.check{list-style:none;margin:0;padding:0}
.check li{display:flex;gap:8px;padding:6px 0;font-size:13px;border-bottom:1px dashed var(--line-2)}
.check li:last-child{border-bottom:0}
.check .ic{width:18px;flex:none;text-align:center;font-weight:700}
.sticky-save{position:sticky;bottom:0;background:linear-gradient(transparent,var(--bg) 30%);padding:14px 0 4px;display:flex;gap:10px;align-items:center;z-index:5}
.dirty{color:var(--gold);font-size:12.5px;font-weight:600}
.plan-box{background:var(--sage-soft);border-radius:10px;padding:10px 12px;font-size:13px;white-space:pre-wrap}
.status-list li{display:flex;justify-content:space-between;align-items:center;padding:7px 0;border-bottom:1px solid var(--line-2);cursor:pointer;font-size:13px}
.status-list{list-style:none;margin:0;padding:0}
.status-list li:hover{color:var(--sage)}
.status-list li.cur{font-weight:700;color:var(--sage)}

/* ---------- modal & toast ---------- */
.modal-bg{position:fixed;inset:0;background:rgba(25,35,30,.38);display:grid;place-items:center;z-index:50;padding:16px}
.modal{background:var(--surface);border-radius:16px;width:min(680px,100%);max-height:90vh;display:flex;flex-direction:column;box-shadow:0 20px 60px rgba(0,0,0,.2)}
.modal-h{padding:14px 18px;border-bottom:1px solid var(--line-2);display:flex;align-items:center}
.modal-h h3{margin:0;font:700 19px var(--serif);flex:1}
.modal-b{padding:16px 18px;overflow:auto}
.modal-f{padding:12px 18px;border-top:1px solid var(--line-2);display:flex;gap:8px;justify-content:flex-start}
#toasts{position:fixed;bottom:18px;left:18px;display:flex;flex-direction:column;gap:8px;z-index:60}
.toast{background:var(--ink);color:#fff;border-radius:10px;padding:10px 16px;box-shadow:0 8px 24px rgba(0,0,0,.2);max-width:420px;font-size:13.5px}
.toast.err{background:var(--danger)}

/* ---------- login ---------- */
.login{min-height:100vh;display:grid;place-items:center;background:radial-gradient(circle at 80% 10%,#E6EED3 0,transparent 42%),radial-gradient(circle at 10% 90%,#E9EEE2 0,transparent 45%),var(--bg)}
.login form{background:var(--surface);border:1px solid var(--line);border-radius:20px;padding:32px;width:min(380px,92vw);display:flex;flex-direction:column;gap:14px;box-shadow:var(--shadow)}
.login .brand{align-items:center;padding:4px 0 8px}
.login .brand img{width:200px}
.login .brand small{color:var(--muted)}
.login h2{margin:0;text-align:center;font:700 20px var(--serif)}
.err-msg{color:var(--danger);font-size:13px;min-height:18px}

/* ---------- misc layouts ---------- */
.grid2{display:grid;grid-template-columns:1fr 1fr;gap:14px}
.grid3{display:grid;grid-template-columns:repeat(3,1fr);gap:14px}
.stack{display:flex;flex-direction:column;gap:14px}
.tabs{display:flex;gap:4px;border-bottom:1px solid var(--line);margin-bottom:12px;flex-wrap:wrap}
.tabs a{padding:8px 14px;text-decoration:none;color:var(--ink-2);border-bottom:2px solid transparent;font-weight:600;font-size:13.5px}
.tabs a.on{color:var(--ink);border-color:var(--sage-2)}
.score{font-weight:700;font-size:15px}
.note{background:var(--surface-2);border:1px solid var(--line);border-radius:10px;padding:10px 12px;font-size:12.5px;color:var(--ink-2)}
.pill-n{background:var(--line-2);border-radius:99px;padding:0 7px;font-size:11px;margin-inline-start:4px}

@media (max-width:1200px){
  .kpis{grid-template-columns:repeat(3,1fr)}
  .dash>*{grid-column:1/-1!important}
  .entry{grid-template-columns:1fr}
}
@media (max-width:820px){
  .shell{grid-template-columns:minmax(0,1fr);height:auto}
  .side,.main{min-width:0}
  .side{flex-direction:row;flex-wrap:nowrap;align-items:center;padding:8px 10px;position:sticky;top:0;z-index:20;overflow:visible}
  .side .brand,.nav-sec{display:none}
  .side .brand,.nav-sec{display:none}
  .side .brand,.nav-sec{display:none}
  .nav{display:flex;flex-wrap:nowrap;gap:2px;overflow-x:auto;flex:1;min-width:0;scrollbar-width:none}
  .nav a{white-space:nowrap;padding:7px 10px}
  .main{padding:14px 16px;overflow:visible}
  .kpis{grid-template-columns:repeat(2,1fr)}
  .entry-head,.form-grid,.grid2,.grid3{grid-template-columns:1fr}
}
@media print{
  .side,.no-print,.sticky-save{display:none!important}
  .shell{display:block;height:auto}.main{overflow:visible;padding:0}
  body{background:#fff}.card{box-shadow:none;break-inside:avoid}
}

/* ---------- v0.3: loading feedback ---------- */
body.busy::before{content:"";position:fixed;top:0;inset-inline:0;height:3px;z-index:200;background:linear-gradient(90deg,transparent,var(--sage-2),transparent) no-repeat;background-size:35% 100%;animation:busy .9s linear infinite}
@keyframes busy{from{background-position:-35% 0}to{background-position:135% 0}}
.main.loading>*{opacity:.5;transition:opacity .15s;pointer-events:none}
/* ---------- v0.3: KPI target row ---------- */
.kpi .tgt{display:flex;align-items:center;gap:8px;margin-top:6px}
.kpi .tgt .bar{flex:1;margin:0}
.kpi .tgt span{font-size:11.5px;font-weight:600;color:var(--ink-2);white-space:nowrap}
.kpi .cmp{color:var(--muted)}
/* ---------- v0.3: account-opening stages ---------- */
.stages{display:grid;grid-template-columns:repeat(3,1fr);gap:8px}
.stage{border:1px solid var(--line);border-radius:10px;padding:10px 6px;text-align:center;text-decoration:none;color:var(--ink);background:var(--surface-2)}
.stage:hover{border-color:var(--sage-2)}
.stage b{display:block;font-size:24px;line-height:1.2}
.stage span{font-size:11.5px;color:var(--ink-2)}
.stage.hot{background:var(--ink);border-color:var(--ink);color:#fff}.stage.hot span{color:#D9DDD3}
.stage-foot{display:flex;justify-content:space-between;gap:8px;font-size:12.5px;color:var(--ink-2);margin-top:12px;padding-top:10px;border-top:1px solid var(--line-2)}
/* v0.3: compact KPI + one-line rep rows so the dashboard fits one screen */
.kpi{padding:10px 12px}
.kpi .val{font-size:22px;margin:2px 0 0}
.kpi .tgt{margin-top:4px}
.kpi .foot{margin-top:4px}
.c-reps td .name{white-space:nowrap}
.c-reps td,.c-reps th{padding-top:7px;padding-bottom:7px}
.c-reps .tp{display:flex;align-items:center;gap:6px}.c-reps .tp .bar{flex:1;margin:0;min-width:40px}
.c-reps td .chip{padding:0 6px}
.c-reps td{white-space:nowrap}
.c-reps td,.c-reps th{padding-inline:8px}

/* ---------- v0.4: quiet scrollbars (no arrow buttons) ---------- */
::-webkit-scrollbar{width:8px;height:8px}
::-webkit-scrollbar-button{display:none;width:0;height:0}
::-webkit-scrollbar-track{background:transparent}
::-webkit-scrollbar-thumb{background:#D3D8CB;border-radius:8px;border:2px solid transparent;background-clip:content-box}
::-webkit-scrollbar-thumb:hover{background:#A9B09E;background-clip:content-box}
@supports (-moz-appearance:none){*{scrollbar-width:thin;scrollbar-color:#D3D8CB transparent}}
/* short screens: tighten so the dashboard still fits without page scroll */
@media (min-width:1201px) and (max-height:760px){
  .main{padding:12px 18px}.page-head{margin-bottom:8px}.page-head h1{font-size:22px}
  .kpis{gap:10px;margin-bottom:10px}.kpi{padding:8px 12px}.kpi .val{font-size:20px}
  .dash{gap:10px}.card-h{padding:8px 12px}
}
/* ---------- v0.4: visits map ---------- */
.c-map{overflow:hidden}
.map-legend{display:flex;flex-wrap:wrap;gap:4px 6px;padding:6px 10px;border-bottom:1px solid var(--line-2);font-size:11.5px;align-items:center;min-height:30px}
.map-legend button{border:1px solid var(--line);background:var(--surface);border-radius:99px;padding:1px 8px;cursor:pointer;display:inline-flex;align-items:center;gap:5px;color:var(--ink)}
.map-legend button:hover{border-color:var(--sage-2)}
.map-legend button.off{opacity:.4;text-decoration:line-through}
.mapbox{flex:1;min-height:150px;position:relative;z-index:0;isolation:isolate;background:var(--surface-2);font-family:var(--font)}
.mapbox .leaflet-tile-pane{filter:saturate(.35) brightness(1.04)}
.mapbox .leaflet-control-attribution{font-size:9px;background:rgba(255,255,255,.75)}
.mapbox .leaflet-bar a{width:24px;height:24px;line-height:24px;color:var(--ink)}
.pin{display:grid;place-items:center;width:26px;height:26px;border-radius:50%;background:var(--c);color:#fff;font:700 12px/1 var(--font);border:2px solid #fff;box-shadow:0 1px 4px rgba(0,0,0,.35);transition:transform .12s}
.pin.sm{width:14px;height:14px}
.pin:hover{transform:scale(1.2)}
.pop{font:13px/1.6 var(--font);min-width:170px}.pop b{font-size:13.5px}.pop a{color:var(--sage);font-weight:600;text-decoration:none}
.leaflet-tooltip{font:12px var(--font)}
.map-empty{position:absolute;inset:auto 0 10px 0;margin:auto;width:max-content;max-width:90%;z-index:500;background:var(--surface);border:1px solid var(--line);border-radius:99px;padding:4px 12px;font-size:12px;color:var(--ink-2);box-shadow:var(--shadow)}
/* ---------- v0.4: right column (aging + account-opening strip) ---------- */
.pipe-strip{display:flex;align-items:center;gap:6px;padding:8px 12px;font-size:12.5px;flex-wrap:wrap}
.pipe-strip a{border:1px solid var(--line);border-radius:99px;padding:2px 10px;text-decoration:none;color:var(--ink);background:var(--surface-2);white-space:nowrap}
.pipe-strip a:hover{border-color:var(--sage-2)}
.pipe-strip a.hot{background:var(--ink);border-color:var(--ink);color:#fff}
@media (max-width:1200px){.c-map{min-height:340px}}
/* v0.4: bottom row taller (map), legend floats over the map */
.c-map{position:relative}
.map-legend{position:absolute;top:50px;inset-inline-start:8px;inset-inline-end:44px;z-index:5;border:0;padding:0;min-height:0;pointer-events:none}
.map-legend>*{pointer-events:auto;background:rgba(255,255,255,.92);box-shadow:0 1px 3px rgba(0,0,0,.15)}
.map-legend>span{border-radius:99px;padding:1px 8px}

/* ---------- v0.5: one-line alerts, forecast strip, conversion ---------- */
.alerts li{align-items:center;padding:6px 12px;gap:8px}
.alerts li .dot{margin-top:0;flex:none}
.alerts li .btn.sm{padding:2px 9px;font-size:11.5px;flex:none}
.fc{display:flex;flex-wrap:wrap;align-items:center;gap:4px 12px;padding:6px 14px;border-bottom:1px solid var(--line-2);font-size:12px;color:var(--ink-2);background:var(--surface-2)}
.fc b{color:var(--ink)}.fc .dot{margin-inline:2px}
.c-reps .lowc{color:var(--clay);font-weight:700}
.fc{flex-wrap:wrap;gap:2px 10px;padding:5px 12px}
.fc>b,.fc>span{white-space:nowrap}
[hidden]{display:none!important}

/* ---------- v0.7: sidebar footer, file picker, invoices ---------- */
.file-btn{display:inline-flex;align-items:center;gap:7px;border:1px dashed var(--line);border-radius:10px;background:var(--surface-2);padding:7px 14px;cursor:pointer;font-size:13px;color:var(--ink-2);max-width:100%}
.file-btn:hover{border-color:var(--sage-2)}
.file-btn.has-file{border-style:solid;border-color:var(--sage-2);color:var(--ink);background:var(--sage-soft)}
.file-btn svg{width:16px;height:16px;flex:none}
.file-btn [data-fname]{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;max-width:260px}
.inv-sum{display:flex;flex-wrap:wrap;gap:6px 18px;align-items:center;padding:9px 14px;border-bottom:1px solid var(--line-2);font-size:13px;background:var(--surface-2)}
td .rg{display:block;font-size:11px;color:var(--muted)}
/* targets table: 5 columns always fit, no horizontal scroll */
.targets-t{table-layout:fixed;width:100%}
.targets-t th:first-child{width:24%}
.targets-t input{width:100%;min-width:0;box-sizing:border-box}
.entry>*{min-width:0} /* grid items may not shrink below content without this; keeps entry tables scrolling inside their own wrap */

/* forecast basis: how many reports the run-rate stands on */
.fc-basis{margin-inline-start:auto;color:var(--muted);font-size:11px}
.fc-basis.weak{color:var(--clay)}
.fc.unreliable>span:not(.fc-basis){opacity:.55}
/* reps performance as cards on phones: key figures labelled, nothing hover-only */
@media (max-width:640px){
  .rep-cards thead{display:none}
  .rep-cards,.rep-cards tbody{display:block}
  .rep-cards tr{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:8px 10px;padding:10px 12px;border-bottom:1px solid var(--line-2)}
  .rep-cards td{display:block;padding:0!important;border:0!important;min-width:0!important;text-align:start;line-height:1.35}
  .rep-cards td[data-l="من الهدف"]{grid-column:1/-1;order:9}
  .rep-cards td:first-child{grid-column:1/-1}
  .rep-cards td:first-child .rg{display:inline!important;margin-inline-start:6px}
  .rep-cards td[data-l]::before{content:attr(data-l);display:block;font-size:11px;color:var(--muted)}
  .rep-cards td[data-sub]:not([data-sub=""])::after{content:attr(data-sub);display:block;font-size:11px;color:var(--muted)}
  .rep-cards td.m-hide{display:none}
  .rep-cards .tp{width:100%}
  .rep-cards td.empty{grid-column:1/-1}
}
/* forecast strip wraps on narrow screens so the report basis stays visible */
@media (max-width:900px){.fc-basis{margin-inline-start:0}}
/* CRM: stage path, follow-up/stall filters, next action, customer follow-ups panel */
.stage-row{display:flex;flex-wrap:wrap;align-items:center;gap:4px;margin:-4px 0 10px;font-size:12.5px}
.stage-row a{padding:4px 10px;border-radius:99px;text-decoration:none;color:var(--ink-2);background:var(--surface);border:1px solid var(--line)}
.stage-row a.on{background:var(--ink);color:var(--surface);border-color:var(--ink)}
.stage-row i{color:var(--muted);font-style:normal}
.crm-bar{display:flex;flex-wrap:wrap;align-items:center;gap:6px;margin-bottom:10px}
.crm-bar a.chip{text-decoration:none;cursor:pointer;font-weight:500}
.crm-bar a.chip.sel{outline:2px solid var(--ink);outline-offset:1px}
.cust-t .stall{font-size:11px;color:var(--clay);margin-top:3px;white-space:nowrap}
.cust-t td.nxt{min-width:170px;max-width:260px}
.cust-t .nx{font-size:12.5px;line-height:1.5}
.fu-box{margin-top:14px;border:1px solid var(--line);border-radius:var(--radius-s);padding:10px 12px;background:var(--surface-2)}
.fu-h{display:flex;align-items:baseline;gap:10px;margin-bottom:8px;flex-wrap:wrap}
.fu-row{display:flex;align-items:center;gap:8px;padding:6px 0;border-bottom:1px dashed var(--line-2);font-size:13px}
.fu-row:last-child{border-bottom:0}
.fu-row .fu-act{flex:1;min-width:0}
.fu-row.done .fu-act{color:var(--muted)}
.fu-add{display:flex;gap:6px;margin-top:8px;flex-wrap:wrap}
.fu-add #fu-act{flex:1;min-width:160px}
@media (max-width:640px){.cust-t td.nxt{min-width:140px}.stage-row,.crm-bar{flex-wrap:nowrap;overflow-x:auto;white-space:nowrap;scrollbar-width:none;padding-bottom:2px}.stage-row a,.crm-bar>*{flex:none}}
/* customers as cards on phones: stage + next action first, actions as a full row */
@media (max-width:640px){
  .cust-t thead{display:none}
  .cust-t,.cust-t tbody{display:block}
  .cust-t tr{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:8px 10px;padding:12px;border-bottom:1px solid var(--line-2)}
  .cust-t td{display:block;padding:0!important;border:0!important;min-width:0!important;max-width:none!important;text-align:start}
  .cust-t td:first-child,.cust-t td.nxt,.cust-t td.acts{grid-column:1/-1}
  .cust-t td.nxt{order:-1;grid-row:2}
  .cust-t td[data-l]::before{content:attr(data-l);display:block;font-size:11px;color:var(--muted)}
  .cust-t td.m-hide{display:none}
  .cust-t td.acts{white-space:normal;display:flex;gap:6px;flex-wrap:wrap}
  .cust-t td.empty{grid-column:1/-1}
}
.btn svg{width:16px;height:16px;flex:none}.btn.sm svg{width:14px;height:14px}

/* ---------- Phase B: manager / data-entry follow-up ---------- */
input[type=email]{border:1px solid var(--line);background:#fff;border-radius:9px;padding:6px 10px;min-width:0;outline:none}
/* notifications bell */
.bell-btn{position:relative;flex:none;display:grid;place-items:center;width:34px;height:34px;border:1px solid var(--line);border-radius:10px;background:#fff;color:var(--ink-2);cursor:pointer}
.bell-btn:hover{background:var(--side-2)}.bell-btn svg{width:18px;height:18px}
.bell-btn[aria-expanded=true]{border-color:var(--ink);color:var(--ink)}
.bell-n{position:absolute;top:-6px;inset-inline-end:-6px;min-width:18px;height:18px;padding:0 5px;border-radius:99px;background:var(--danger);color:#fff;font-size:10.5px;line-height:18px;text-align:center;font-weight:700}
.bell-h{display:flex;align-items:center;gap:6px;padding:9px 12px;border-bottom:1px solid var(--line-2)}
.bell-l{list-style:none;margin:0;padding:0;overflow:auto}
.bell-l li{display:flex;gap:8px;align-items:baseline;padding:8px 12px;border-bottom:1px solid var(--line-2);font-size:12.5px;cursor:pointer;color:var(--ink-2)}
.bell-l li:hover{background:var(--surface-2)}
.bell-l li.unread{color:var(--ink);font-weight:600;background:var(--sage-soft)}
.bell-l li.muted{cursor:default;background:none}
.bell-t{flex:1;min-width:0}.bell-at{font-size:11px;color:var(--muted);font-weight:400;white-space:nowrap}
/* CEO morning digest strip (dashboard) */
.digest{display:flex;flex-wrap:wrap;align-items:center;gap:6px;margin:-4px 0 10px;font-size:12.5px}
.digest>b{font-size:12.5px;margin-inline-end:2px}
.digest .dg-i{border:1px solid var(--line);border-radius:99px;padding:2px 10px;background:var(--surface);color:var(--ink-2);text-decoration:none;white-space:nowrap}
.digest .dg-i:hover{border-color:var(--sage-2)}
/* entry: report state + read-only after review */
.ro-fs{border:0;margin:0;padding:0;min-width:0}
.ro-fs[disabled] .add-row,.ro-fs[disabled] td.del{display:none}
.rpt-state .filters{gap:6px 10px}
.ret-note{margin-top:6px;color:var(--clay);font-weight:600}
/* review queue, approvals waiting time, proposed locations */
.q-t .q-gps{display:inline-flex;gap:4px;flex-wrap:wrap}
.q-t .q-note{max-width:260px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.q-t tr.q-late td:first-child{box-shadow:inset -3px 0 0 var(--danger)}
tr.ap-late td{background:#FBF1EF}
.ap-wait{color:var(--danger);font-weight:600}
.prop-loc{display:flex;flex-wrap:wrap;gap:4px;align-items:center;margin:3px 0}
.prop-loc a.chip{text-decoration:none}
@media (max-width:640px){
  .q-t thead{display:none}
  .q-t,.q-t tbody{display:block}
  .q-t tr{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:8px 10px;padding:12px;border-bottom:1px solid var(--line-2)}
  .q-t td{display:block;padding:0!important;border:0!important;min-width:0!important;text-align:start}
  .q-t td[data-l]::before{content:attr(data-l);display:block;font-size:11px;color:var(--muted)}
  .q-t td.acts{grid-column:1/-1;display:flex;gap:6px;flex-wrap:wrap}
  .q-t td.empty{grid-column:1/-1}
}

/* ---------- confirmation queue, uploads, documents, email-code login ---------- */
.link-btn{background:none;border:0;padding:2px;color:var(--blue);font:500 13px var(--font);cursor:pointer;text-decoration:underline;text-underline-offset:3px;align-self:center}
.link-btn:hover{color:var(--ink)}
.otp-in{letter-spacing:.5em;text-align:center;font-size:20px!important}
.cf-sum{display:flex;gap:8px;flex-wrap:wrap;margin-bottom:12px}
.cf-sum a.chip{text-decoration:none;padding:4px 12px;font-size:12.5px}
.cf-sec .card-h .pill-n{margin-inline-start:0}
.cf-items{max-width:280px}
.cf-t td{vertical-align:top}
.chq-in{display:flex;gap:4px}
.chq-in input{min-width:0}
.chq-in input:first-child{width:110px}
.chq-in input[type=date]{width:130px}
.file-a{font-size:11.5px;white-space:nowrap}
.thumb{display:inline-block;width:52px;height:52px;border-radius:8px;overflow:hidden;border:1px solid var(--line);background:var(--surface-2);vertical-align:middle}
.thumb img{width:100%;height:100%;object-fit:cover;display:block}
.thumb.thumb-f{width:auto;height:auto;min-width:52px;padding:6px 8px;font-size:11.5px;text-decoration:none;text-align:center;color:var(--blue)}
.doc-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(210px,1fr));gap:8px;margin-bottom:8px}
.doc-it{display:flex;gap:8px;align-items:center;border:1px solid var(--line-2);border-radius:var(--radius-s);padding:6px;background:var(--surface)}
.doc-m{display:flex;flex-direction:column;gap:1px;min-width:0;font-size:12px}
.doc-m span{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
#doc-box .fu-add select{width:auto}
tr.row-off td{opacity:.6}
@media (max-width:640px){
  .cf-t thead{display:none}
  .cf-t,.cf-t tbody{display:block}
  .cf-t tr{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:8px 10px;padding:12px;border-bottom:1px solid var(--line-2)}
  .cf-t td{display:block;padding:0!important;border:0!important;min-width:0!important;text-align:start}
  .cf-t td[data-l]::before{content:attr(data-l);display:block;font-size:11px;color:var(--muted)}
  .cf-t td.acts{grid-column:1/-1;display:flex;gap:6px;flex-wrap:wrap}
  .cf-t td.empty{grid-column:1/-1}
}

/* =====================================================================================
   v0.8 — UX pass (owner review, Nov 2026). Rules of this block:
   · nothing is clipped: no ellipsis, no half rows, no content pushed out of its card
   · one account cluster (bell + account menu) at the end of every page header
   · one tile anatomy: label · value · [target bar] · one status line
   · colour only for meaning; numbers tabular and sharing an edge
   ===================================================================================== */
:root{--muted:#6B7067;--side-muted:#6B7067} /* ≥4.5:1 on white and on the page background for 11–12px text */

/* ---------- shell: sidebar is navigation only ---------- */
.side{padding:16px 12px 12px}
.nav a{min-height:36px}
@media (min-width:821px) and (max-height:800px){
  .brand{padding:4px 12px 10px}.nav a{padding:7px 12px}.nav-sec{padding-top:8px}
}

/* ---------- page header: title | page actions | account cluster ---------- */
.page-head{display:grid;grid-template-columns:minmax(260px,1fr) auto auto;align-items:center;gap:8px 14px;margin-bottom:12px;position:relative}
.page-head>div:first-child{min-width:0}
.page-head h1{font-size:24px}
.head-actions{display:flex;flex-wrap:wrap;align-items:center;justify-content:flex-end;gap:8px 10px;min-width:0}
.head-actions:empty{display:none}
.demo-banner{white-space:nowrap}
.util{position:relative;display:flex;align-items:center;gap:8px;z-index:30;align-self:center}
.bell-btn{width:36px;height:36px;border-radius:10px;background:var(--surface)}
.bell-n{top:-4px;inset-inline-end:-4px}
.acct-btn{display:inline-flex;align-items:center;gap:4px;height:36px;padding-block:0;padding-inline:4px 7px;border:1px solid var(--line);border-radius:99px;background:var(--surface);color:var(--ink-2);cursor:pointer}
.acct-btn:hover,.acct-btn[aria-expanded=true]{border-color:#CDD2C5;background:var(--side-2)}
.acct-btn .avatar{width:26px;height:26px;font-size:12.5px}
.acct-btn svg{width:14px;height:14px}
.acct-menu,.bell-panel{position:absolute;top:calc(100% + 8px);inset-inline-end:0;z-index:60;background:var(--surface);border:1px solid var(--line);border-radius:var(--radius);box-shadow:0 12px 32px rgba(26,26,26,.16)}
.acct-menu{width:248px;padding:6px}
.acct-who{display:flex;gap:10px;align-items:center;padding:8px 8px 10px;border-bottom:1px solid var(--line-2);margin-bottom:6px}
.acct-who>div{min-width:0}
.acct-who b{display:block;font-size:13.5px;overflow-wrap:anywhere}
.acct-who div>span{font-size:12px;color:var(--muted)}
.acct-menu a,.acct-menu button{display:flex;align-items:center;gap:8px;width:100%;min-height:36px;padding:6px 8px;border:0;background:none;border-radius:8px;font:inherit;font-size:13px;color:var(--ink);text-decoration:none;cursor:pointer;text-align:start}
.acct-menu a:hover,.acct-menu button:hover{background:var(--side-2)}
.acct-menu svg{width:16px;height:16px;color:var(--ink-2);flex:none}
.bell-panel{width:min(360px,calc(100vw - 32px));max-height:min(460px,70vh);display:flex;flex-direction:column}
.bell-l li{align-items:flex-start;line-height:1.45}
.bell-at{margin-top:1px}
@media (max-width:820px){
  .page-head{grid-template-columns:minmax(0,1fr) auto}
  .page-head .head-actions{grid-column:1/-1;grid-row:2;justify-content:flex-start}
  .page-head .util{grid-column:2;grid-row:1}
}

/* ---------- controls: comfortable targets ---------- */
.btn.sm{min-height:28px;padding:3px 10px}
.icon-btn{min-width:32px;min-height:32px}
.icon-btn svg{width:18px;height:18px}
.rows-t td.del{padding:2px}
.rows-t .icon-btn{min-width:28px;min-height:28px;padding:4px}
.form-grid>*,.entry-head>*,.grid2>*,.grid3>*{min-width:0}
label.f>input:not([type=checkbox]):not([type=radio]),label.f>select,label.f>textarea{width:100%}

/* ---------- stat tiles ---------- */
.kpis{gap:12px;margin-bottom:12px}
.kpi{padding:10px 14px 9px;overflow:visible;display:flex;flex-direction:column}
.kpi::before{display:none}
.kpi .lbl{white-space:nowrap}
.kpi .lbl svg{color:var(--muted);flex:none}
.kpi .val{display:flex;align-items:baseline;gap:5px;font-size:22px;line-height:1.25;margin:1px 0 0}
.kpi .val .num{font-variant-numeric:normal}
.kpi .val small{margin:0}
.kpi .tgt{height:18px;margin-top:4px;gap:8px}
.kpi .tgt .bar{height:6px}
.kpi .tgt span{font-weight:500;color:var(--ink-2)}
.kpi .tgt span b{font-weight:700;color:var(--ink)}
.kpi .tgt.none span{color:var(--muted);font-weight:400}
.kpi .foot{display:flex;flex-wrap:nowrap;justify-content:space-between;align-items:center;gap:8px;height:18px;margin-top:4px;white-space:nowrap}
.bar{height:6px;border-radius:99px}
.bar i{background:var(--accent,var(--sage-2));border-radius:99px}
.delta{font-size:11.5px}.delta.up{color:#3F6B4B}
.st{display:inline-flex;align-items:center;gap:5px}
.st.ok{color:var(--ink-2)}.st.ok .dot{background:var(--sage-2)}
.st.bad{color:var(--danger);font-weight:600}.st.bad .dot{background:var(--danger)}

/* ---------- morning digest: whole parts wrap, text is never cut ---------- */
.digest{gap:6px 8px;margin:0 0 10px}
.digest .dg-t{color:var(--ink-2);white-space:nowrap}
.digest .dg-i{display:inline-flex;align-items:center;gap:6px;min-height:28px;padding:2px 11px;color:var(--ink)}
.digest .dg-i.warn,.digest .dg-i.hot{background:var(--surface);border-color:var(--line);color:var(--ink)}
.digest .dg-i.warn .dot{background:var(--gold)}.digest .dg-i.hot .dot{background:var(--danger)}
.digest .dg-q{color:var(--muted);font-size:12px}
.digest .dg-q::before{content:"·";margin-inline-end:6px}

/* ---------- dashboard: one screen, content-sized first row, flexible second row ---------- */
.main>.dash{flex:1 0 auto}
.dash{grid-template-columns:repeat(12,minmax(0,1fr));grid-template-rows:max-content minmax(min-content,1fr);min-height:0}
/* left: reps (content-sized) over map + trend (flexible). right: alerts (takes the spare height) · aging · pipeline */
.dash .c-reps{grid-column:1/9;grid-row:1}.dash .c-map{grid-column:1/5;grid-row:2}.dash .c-trend{grid-column:5/9;grid-row:2}.dash .c-side{grid-column:9/13;grid-row:1/3}
.c-reps .table-wrap{overflow:visible}
.c-reps td,.c-reps th{padding:6px 8px;height:40px;white-space:nowrap}
.c-reps th{height:36px}
.c-reps tbody tr{cursor:pointer}
.c-reps .name{display:flex;align-items:center;gap:7px}
.c-reps td .rg{display:none}
.c-reps .tp{gap:8px;min-width:104px}
.c-reps .tp .num{min-width:36px;text-align:right;font-size:12.5px}
.c-reps .tp .bar{min-width:48px}
.c-reps .nogps{gap:2px;margin-inline-start:8px;padding:0 6px;font-size:11px}
.c-reps .nogps svg{width:12px;height:12px}
.c-reps.tight .w2,.c-reps.tighter .w2,.c-reps.tighter .w1{display:none}
.c-reps.tightest td,.c-reps.tightest th{padding-inline:5px}
.c-reps.tightest .tp{min-width:72px;gap:6px}.c-reps.tightest .tp .bar{min-width:28px}
.c-reps.tightest .nogps{margin-inline-start:4px;padding:0 4px}
.c-reps.scrollx .table-wrap{overflow-x:auto}
.c-side .c-alerts{flex:1 1 0;min-height:176px}
.c-alerts .al-body{flex:1 1 0;min-height:0;display:flex;flex-direction:column;overflow:hidden}
.alerts li{min-height:40px;padding:6px 14px;gap:10px}
.alerts .al-t{flex:1;min-width:0;white-space:normal;overflow:visible;text-overflow:clip;font-size:13px;line-height:1.4}
.alerts li .btn.sm{min-width:58px;justify-content:center;padding:3px 9px;font-size:12px}
.al-full li{padding-inline:0}
.al-full .ref{display:block;margin-top:1px;font-size:11.5px}
.more-btn{margin-top:auto;flex:none;width:100%;min-height:34px;border:0;border-top:1px solid var(--line-2);background:var(--surface-2);color:#4C663C;font:600 12.5px var(--font);cursor:pointer;border-radius:0 0 var(--radius) var(--radius)}
.more-btn:hover{background:var(--sage-soft)}
.trend-b{flex:1;display:flex;padding:8px;min-height:0}
#trend{flex:1;min-width:0;min-height:120px;position:relative}
#trend>svg{position:absolute;inset:0}
.c-side{gap:12px}
.c-side .c-aging,.c-side .c-pipe{flex:none}
.c-aging .card-b{padding:12px 14px}
.pipe-strip{min-height:44px}
@media (max-width:1200px){
  .dash{grid-template-rows:none;grid-auto-rows:auto}
  .c-reps .table-wrap{overflow-x:auto}
  .dash>*{grid-row:auto!important}
  .dash .c-side{order:2}.dash .c-map{order:3}.dash .c-trend{order:4}
  .c-side .c-alerts{flex:none;min-height:0}.c-alerts .al-body{flex:none}
  .c-trend{min-height:300px}
}

/* ---------- ranked bars (aging): one grid, shared edges ---------- */
.hbars{display:grid;grid-template-columns:max-content minmax(60px,1fr) max-content;gap:10px 12px;align-items:center;font-size:12.5px}
.hbar{display:contents}
.hbar .l{white-space:nowrap;color:var(--ink-2)}
.hbar .track{height:8px;background:var(--line-2);border-radius:99px;overflow:hidden}
.hbar .track i{display:block;height:100%;border-radius:99px}
.hbar .v{text-align:right;font-weight:600}

/* ---------- tables ---------- */
.t td.num,.t th.num{display:table-cell}      /* .num is inline-block for inline numbers; a cell must stay a cell */
.t td.n,.t th.n{text-align:right}            /* digits are LTR: sharing the right edge lines up the units */
.t td{padding:8px 10px}
.t .name{overflow-wrap:normal}
.cust-t td:first-child{min-width:160px}
.cust-t td:nth-child(2),.cust-t td:nth-child(3){white-space:nowrap}
.cust-t td.acts{white-space:normal}.cust-t td.acts .btn{margin-block:2px}
.cust-t td.nxt{min-width:130px}
.cust-t td,.cust-t th{padding-inline:8px}
.cust-t .stall{white-space:normal}
.t td.name,.t td.small.muted{white-space:nowrap}
.nw-t td,.nw-t th{white-space:nowrap}
.reps-grid{grid-template-columns:minmax(0,1fr) minmax(0,1.2fr)}
@media (max-width:1500px){.reps-grid{grid-template-columns:minmax(0,1fr)}}
.wgrid{display:grid;grid-template-columns:repeat(5,minmax(0,1fr));gap:8px;margin-top:4px}
@media (max-width:640px){.wgrid{grid-template-columns:repeat(2,minmax(0,1fr))}}
.t td.nw,.t th.nw{white-space:nowrap}

/* ---------- entry page ---------- */
.sticky-save{background:var(--bg);border-top:1px solid var(--line);padding:10px 0 6px;margin-top:14px;flex-wrap:wrap}
@media (max-width:1500px){
  .entry{grid-template-columns:minmax(0,1fr)}
  .entry>aside.stack{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));align-items:start}
}
@media (max-width:820px){.entry>aside.stack{grid-template-columns:minmax(0,1fr)}}
@media (max-width:640px){.digest{flex-wrap:wrap;overflow:visible}.digest>*{flex:0 1 auto}}

/* ---------- short desktop screens (laptops): tighten so the dashboard still fits one screen ---------- */
@media (min-width:1201px) and (max-height:800px){
  .main{padding:12px 18px}.page-head{margin-bottom:8px}.page-head h1{font-size:22px}
  .digest{margin-bottom:8px}
  .kpis{gap:10px;margin-bottom:10px}.kpi{padding:8px 12px}.kpi .val{font-size:20px}
  .dash{gap:10px}.card-h{padding:7px 12px}
  .c-reps td{height:36px}.c-reps th{height:34px}
  .alerts li{min-height:36px;padding-block:4px}
  .c-side{gap:10px}.c-aging .card-b{padding:9px 14px}.c-aging .hbars{row-gap:7px}
  #trend{min-height:100px}
}
.map-legend button{min-height:24px}
/* scorecards: figures stay in ink; only a shortfall (<70%) is coloured */
.pc{font-weight:600}.pc.low{color:var(--danger)}
/* tablets: tighter cells so tables fit without sideways scrolling */
@media (max-width:820px){
  .t td,.t th{padding-inline:5px}.t{font-size:12.5px}
  .t td.acts{white-space:normal}.t td.acts .btn{margin-block:2px}
  .t td.small.nowrap,.t td.small.muted{white-space:normal}
}
@media (min-width:641px) and (max-width:820px){
  .cust-t th:nth-child(2),.cust-t td:nth-child(2),.cust-t th:nth-child(5),.cust-t td:nth-child(5),.cust-t th:nth-child(9),.cust-t td:nth-child(9){display:none}
  .cust-t td:nth-child(3){white-space:normal}.cust-t td.nxt{min-width:110px}.cust-t td:first-child{min-width:140px}
}
/* very short viewports (a 1366×768 laptop inside a browser window ≈ 650px) */
@media (min-width:1201px) and (max-height:700px){
  .main{padding:8px 18px}.page-head{margin-bottom:6px}.digest{margin-bottom:6px}
  .kpis{margin-bottom:8px}.kpi{padding:6px 12px}
  .dash{gap:8px}.c-side{gap:8px}
  .c-reps td{height:32px;padding-block:3px}.c-reps th{height:30px;padding-block:3px}
  .alerts li{min-height:34px}
  #trend{min-height:84px}
  .side{padding-top:10px}.brand{padding:2px 12px 6px}.nav a{min-height:32px;padding-block:5px}.nav-sec{padding-top:6px;padding-bottom:2px}
}

/* ================= finance workspace ================= */
.fin-kpis{display:grid;grid-template-columns:repeat(4,1fr);gap:12px;margin-bottom:12px}
.fin-tile{display:flex;flex-direction:column;text-decoration:none;color:var(--ink)}
a.fin-tile:hover{border-color:var(--sage-2)}
.fin-tile .lbl .spacer{flex:1}
.fin-tile .foot{min-height:17px}
.fin-def{font-size:11px;color:var(--muted);line-height:1.55;margin-top:6px;border-top:1px dashed var(--line-2);padding-top:5px}
.fin-naval{font-size:16px;font-weight:700;color:var(--muted);margin-top:2px}
.fin-grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(180px,1fr));gap:8px 14px}
.fin-f{display:flex;flex-direction:column;gap:2px;font-size:12.5px;min-width:0}
.fin-f>span{color:var(--muted);font-size:11.5px}
.fin-f>b{font-weight:600;overflow-wrap:anywhere}
.fin-tl{list-style:none;margin:6px 0 0;padding:0;display:flex;flex-direction:column;gap:0}
.fin-tl li{display:flex;gap:10px;align-items:flex-start;position:relative;padding:7px 0 7px;border-bottom:1px dashed var(--line-2)}
.fin-tl li:last-child{border-bottom:0}
.fin-tl .dot{margin-top:5px;background:var(--line);width:9px;height:9px}
.fin-tl .dot.ok{background:var(--sage-2)}.fin-tl .dot.warn{background:var(--gold)}.fin-tl .dot.bad{background:var(--danger)}
.fin-tl .dot.blue{background:var(--blue,#2a78d6)}.fin-tl .dot.rose{background:var(--clay)}
.nh-rows{display:flex;flex-direction:column;gap:0;max-height:260px;overflow:auto;border:1px solid var(--line);border-radius:10px}
.nh-row{display:flex;align-items:center;gap:10px;padding:7px 10px;border-bottom:1px solid var(--line-2);cursor:pointer;font-size:12.5px;color:var(--ink)}
.nh-row:last-child{border-bottom:0}
.nh-row:hover{background:var(--surface-2)}
.nh-row input{width:auto}
.nh-row .name{flex:1;min-width:0;overflow-wrap:anywhere}
.fin-strip .dg-t{color:var(--ink)}
.fin-strip .dg-i{white-space:nowrap}
.fin-filter{display:grid;grid-template-columns:repeat(auto-fit,minmax(145px,1fr));align-items:end;gap:8px 12px;padding:12px;margin-bottom:12px}
.fin-filter>.f,.fin-filter input,.fin-filter select{min-width:0;width:100%}
.fin-filter input[type=checkbox],.fin-choice input[type=checkbox]{width:auto;flex:none}
.fin-filter .chk-line{align-self:center}
.fin-pages{margin-block:10px}
.fin-table td{overflow-wrap:anywhere;vertical-align:middle}
.fin-table th,.fin-table .btn{white-space:nowrap}
.fin-summary{flex-flow:row wrap;gap:10px 24px;padding:12px;margin-bottom:12px}
.fin-summary>div{flex:1 1 150px;max-width:100%;overflow-wrap:anywhere}
.fin-summary>div>b{font-size:12px;color:var(--muted)}
.fin-choice-list{display:grid;align-content:start;gap:5px;max-height:240px;overflow:auto;padding:3px}
.fin-choice{display:flex;gap:8px;align-items:center;padding:6px 8px;border-bottom:1px solid var(--line-2)}
.fin-choice>span:not(.num){flex:1;min-width:0;overflow-wrap:anywhere}
.fin-candidates{padding-inline-start:20px;margin-block:4px}
.fin-candidates li{padding-block:4px;overflow-wrap:anywhere}
.fin-cheque-kpis{margin-bottom:12px}
.fin-stat-grid{display:grid;grid-template-columns:repeat(5,minmax(0,1fr));padding:0 12px 8px;gap:4px 10px}
.fin-stat{border-top:1px solid var(--line-2);display:flex;flex-direction:column;gap:2px;padding:5px 2px;overflow-wrap:anywhere;color:var(--ink);text-decoration:none}
.fin-stat:hover{background:var(--surface-2);text-decoration:underline}
.fin-stat strong{font-size:16px}
.fin-stat small{font-size:11px}
.fin-customer-timeline{padding:12px;margin-top:12px}
.fin-customer-collections td{overflow-wrap:anywhere}
@media (min-width:1050px){.fin-customer-grid{grid-template-columns:minmax(0,1.35fr) minmax(0,1fr)}}
.fin-tl li>div{min-width:0;overflow-wrap:anywhere}
.modal-b [hidden]{display:none}
.file-btn{position:relative;overflow:hidden}
.file-btn input{position:absolute;inset:0;width:100%;height:100%;opacity:0;cursor:pointer}
.file-btn:focus-within{outline:2px solid var(--sage-2);outline-offset:2px}
.modal-err:not(:empty){padding:8px 18px;color:var(--danger);border-top:1px solid var(--line-2);font-size:13px}
@media (max-width:820px){.fin-stat-grid{grid-template-columns:repeat(3,minmax(0,1fr))}}
@media (max-width:500px){.fin-stat-grid{grid-template-columns:repeat(2,minmax(0,1fr))}}
@media (max-width:1200px){.fin-kpis{grid-template-columns:repeat(3,1fr)}}
@media (max-width:820px){.fin-kpis{grid-template-columns:repeat(2,1fr)}}
@media (max-width:640px){
  .fq-t thead,.rec-t thead{display:none}
  .fq-t tr,.rec-t tr{display:grid;grid-template-columns:1fr 1fr;gap:2px 10px;padding:8px 10px;border-bottom:1px solid var(--line-2)}
  .fq-t td,.rec-t td{display:block;border:0;padding:2px 0}
  .fq-t td::before,.rec-t td::before{content:attr(data-l);display:block;font-size:10.5px;color:var(--muted)}
  .fq-t td:not([data-l])::before,.rec-t td:not([data-l])::before{content:none}
  .fq-t td.empty,.rec-t td.empty{grid-column:1/-1}
}

/* ---------- Manager Workspace (ERP-grade organisation; existing tokens only) ----------
   Every rule below is scoped to .shell.mgr, which renderShell sets for the manager only.
   Data entry, finance and the representative app never match these selectors. */

/* Sidebar: six modules; the active one expands to list its pages. One highlight at a time:
   an expanded module shows its name in ink + sage icon, the current page carries the fill and the bar. */
.shell.mgr .nav a.nav-mod{font-weight:600}
.shell.mgr .nav a.nav-mod.on{background:var(--sage-soft);color:#3f5b32;box-shadow:none;position:relative}
.shell.mgr .nav a.nav-mod.on::before{content:"";position:absolute;inset-inline-start:0;top:9px;bottom:9px;width:3px;border-radius:3px;background:var(--sage)}
.shell.mgr .nav a.nav-mod.on svg{color:var(--sage);opacity:1}
.shell.mgr .nav a.nav-mod.on.open{background:none;color:var(--ink)}
.shell.mgr .nav a.nav-mod.on.open:hover{background:var(--side-2)}
.shell.mgr .nav a.nav-mod.on.open::before{display:none}
.shell.mgr .nav-sub{display:flex;flex-direction:column;gap:1px;margin:2px 0 6px;margin-inline-start:21px;padding-inline-start:8px;border-inline-start:1px solid var(--line)}
.shell.mgr .nav-sub a{position:relative;min-height:30px;padding:5px 10px;font-size:12.5px;font-weight:500;color:var(--ink-2);border-radius:8px}
.shell.mgr .nav-sub a.on{color:#3f5b32;font-weight:700;background:var(--sage-soft);box-shadow:none}
.shell.mgr .nav-sub a.on::before{content:"";position:absolute;inset-inline-start:-10px;top:6px;bottom:6px;width:3px;border-radius:3px;background:var(--sage)}

/* Page header: breadcrumbs above the title; module tabs (phones/tablets) below the header */
.shell.mgr .crumbs{display:flex;flex-wrap:wrap;align-items:center;gap:2px 7px;font-size:11.5px;line-height:1.3;color:var(--muted);margin-bottom:1px}
.shell.mgr .crumbs a{color:var(--muted);text-decoration:none}
.shell.mgr .crumbs a:hover{color:var(--sage);text-decoration:underline;text-underline-offset:3px}
.shell.mgr .crumbs [aria-current]{color:var(--ink);font-weight:600}
.shell.mgr .crumbs i{font-style:normal;color:#B8BDB2}
.shell.mgr .sec-tabs{display:flex;gap:3px;background:var(--surface);border:1px solid var(--line);border-radius:10px;padding:3px;margin:-2px 0 12px}
.shell.mgr .sec-tabs a{display:inline-flex;align-items:center;min-height:30px;padding:4px 11px;border-radius:7px;font-size:12.5px;font-weight:600;color:var(--ink-2);text-decoration:none;white-space:nowrap;flex:none}
.shell.mgr .sec-tabs a:hover{background:var(--surface-2)}
.shell.mgr .sec-tabs a.on{background:var(--sage-soft);color:#3d5632}
/* Desktop: the expanded sidebar module already lists these pages, so the tab bar is hidden (keeps the one-screen
   dashboard on one screen); at 820px and below the sidebar becomes a top bar and the tabs take over. */
@media (min-width:821px){.shell.mgr .sec-tabs{display:none}}

/* Stat tiles: the status line may take a second line instead of running out of the tile */
.shell.mgr .kpi .foot{height:auto;min-height:18px;flex-wrap:wrap;row-gap:0;white-space:normal;line-height:1.35}
.shell.mgr .kpi .foot>*{min-width:0}

/* Tables: lighter row actions so the primary action reads first; neutral hover */
.shell.mgr .t td .btn.sm{min-height:26px;padding:2px 10px;font-size:12px}
.shell.mgr .t td .btn.sm:not(.primary):not(.danger):not(.rose){background:var(--surface-2);border-color:var(--line-2)}
.shell.mgr .t td .btn.sm:not(.primary):not(.danger):not(.rose):hover{background:var(--surface);border-color:#CDD2C5}
.shell.mgr .t tbody tr:hover td{background:var(--surface-2)}
/* Filter bars: one control height */
.shell.mgr .main .filters>select,.shell.mgr .main .filters>input:not([type=checkbox]):not([type=radio]),.shell.mgr .main .filters>label>input:not([type=checkbox]):not([type=radio]){min-height:34px}

/* Overview + work queues */
.shell.mgr .ov-grid{display:grid;grid-template-columns:minmax(0,1fr) minmax(0,1.25fr);gap:12px;margin-bottom:12px}
.shell.mgr .ov-grid .card{min-width:0}
.shell.mgr .ov-trend .trend-b{height:230px}
.shell.mgr .ov-trend #ov-trend{height:100%}
.shell.mgr .ov-fin{margin-bottom:12px}
.shell.mgr .ov-fin .card-b{padding:8px 14px}
.shell.mgr .ov-fin .digest{margin:0}
.shell.mgr .ov-links{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:8px;margin-bottom:10px}
.shell.mgr .ov-links a{display:grid;gap:2px;padding:10px 12px;border:1px solid var(--line);border-radius:10px;background:var(--surface-2);color:var(--ink);text-decoration:none}
.shell.mgr .ov-links a:hover{border-color:#B6C6AC}
.shell.mgr .ov-links b{font-size:13px}
.shell.mgr .ov-links small{color:var(--muted);font-size:11.5px}
.shell.mgr .dec-list{display:flex;flex-direction:column}
.shell.mgr .dec-row{display:flex;align-items:center;gap:10px;min-height:48px;padding:6px 14px;border-bottom:1px solid var(--line-2);color:var(--ink);text-decoration:none}
.shell.mgr .dec-row:last-child{border-bottom:0}
.shell.mgr .dec-row:hover{background:var(--surface-2)}
.shell.mgr .dec-s{flex:1;min-width:0;display:grid}
.shell.mgr .dec-s b{font-size:13px;font-weight:600}
.shell.mgr .dec-s small{color:var(--muted);font-size:11.5px;overflow-wrap:anywhere}
.shell.mgr .dec-own{font-size:11px;color:var(--muted)}
.shell.mgr .dec-n{font-size:17px;font-weight:700;min-width:28px;text-align:center}
.shell.mgr .dec-n.zero{color:var(--muted);font-weight:500}
.shell.mgr .dec-go{color:var(--sage);font-size:16px}
.shell.mgr .glyph{width:30px;height:30px;display:grid;place-items:center;border-radius:8px;background:var(--sage-soft);color:#436036;flex:none}
.shell.mgr .glyph svg{width:15px;height:15px}
.shell.mgr .glyph.warn{background:var(--gold-soft);color:#75511D}
.shell.mgr .glyph.bad{background:var(--danger-soft);color:#8A322A}
.shell.mgr .ov-dec .note,.shell.mgr .q-grid+.note{margin:10px 14px 12px}
.shell.mgr .q-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:12px;margin-bottom:12px}
.shell.mgr .q-card .card-h .chip{font-size:11px}

/* Customer record page */
.shell.mgr .rec-grid{display:grid;grid-template-columns:minmax(0,1.7fr) minmax(280px,1fr);gap:12px;align-items:start}
.shell.mgr .rec-grid .stack{display:grid;gap:12px;min-width:0}
.shell.mgr .facts{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:10px 14px;margin:0}
.shell.mgr .facts>div{min-width:0}
.shell.mgr .facts dt{color:var(--muted);font-size:11.5px;margin-bottom:2px}
.shell.mgr .facts dd{margin:0;font-weight:600;overflow-wrap:anywhere}
.shell.mgr .rec-grid .stack:last-child .facts{grid-template-columns:repeat(2,minmax(0,1fr))}
.shell.mgr a.rec-link{color:var(--ink);text-decoration:none;border-bottom:1px dashed #B6C6AC}
.shell.mgr a.rec-link:hover{color:var(--sage)}

/* Map: when the tile service is unreachable, the notice sits at the foot of the map, clear of the floating legend */
.shell.mgr .mapbox>.empty{position:absolute;inset-inline:0;bottom:8px;padding:6px 14px;font-size:12.5px}

@media (max-width:1200px){
  .shell.mgr .ov-grid,.shell.mgr .q-grid,.shell.mgr .rec-grid{grid-template-columns:minmax(0,1fr)}
  .shell.mgr .facts{grid-template-columns:repeat(2,minmax(0,1fr))}
}
@media (max-width:820px){
  /* top bar: modules only; the active module keeps its fill (its pages are in the tab bar below the header) */
  .shell.mgr .nav-sub,.shell.mgr .nav-sec{display:none}
  .shell.mgr .nav a.nav-mod.on::before{display:none}
  .shell.mgr .nav a.nav-mod.on.open{background:var(--sage-soft);color:#3f5b32}
  /* module pages: the top bar + tab bar already say where you are; record pages keep their trail back */
  .shell.mgr .crumbs:not(.rec){display:none}
  .shell.mgr .page-head{margin-bottom:10px}
  .shell.mgr .page-head h1{font-size:21px}
  /* one-line, deliberately scrollable rows instead of wrapping status tabs */
  .shell.mgr .sec-tabs{overflow-x:auto;scrollbar-width:none;margin:0 0 10px}
  .shell.mgr .tabs{flex-wrap:nowrap;overflow-x:auto;scrollbar-width:none;gap:0}
  .shell.mgr .tabs a{flex:none;white-space:nowrap;padding:8px 12px}
  .shell.mgr .ov-links{grid-template-columns:minmax(0,1fr)}
  /* comfortable touch targets */
  .shell.mgr .btn.sm,.shell.mgr .t td .btn.sm{min-height:32px}
}
@media (max-width:640px){
  .shell.mgr .facts,.shell.mgr .rec-grid .stack:last-child .facts{grid-template-columns:repeat(2,minmax(0,1fr))}
  .shell.mgr .main .card-h{flex-wrap:wrap;row-gap:4px}
  .shell.mgr .main .card-h h3{white-space:nowrap}
  .shell.mgr .dec-row{padding:6px 10px}
  /* two tiles per row on phones: labels wrap inside the tile instead of pushing the page sideways */
  .shell.mgr .kpi .lbl{white-space:normal;align-items:flex-start;line-height:1.35}
  /* receivables sets four columns inline; on phones the manager gets two so values are not clipped */
  .shell.mgr .kpis[style*="repeat(4"]{grid-template-columns:repeat(2,minmax(0,1fr))!important}
}

/* language switch: on the sign-in page it sits in the top corner; English text keeps its own capitals (no text-transform) */
.login{position:relative}.login-lang{position:absolute;top:16px;inset-inline-end:16px}
.lang-btn{font-weight:600;white-space:nowrap}

/* ---------- UX cleanup (2026-11-18): four tiles per row, full-width rep table, short headers, simple finance page ---------- */
.kpis{grid-template-columns:repeat(4,minmax(0,1fr))}
.kpi .foot .vs{display:inline-flex;align-items:baseline;gap:4px;white-space:nowrap}
.kpi .foot .vs small{color:var(--muted);font-size:11px}
/* manager follow-up dashboard: rep table on its own full row, then trend · map · aging */
.dash.dash-mgr .c-reps{grid-column:1/-1;grid-row:1}
.dash.dash-mgr .c-trend{grid-column:1/6;grid-row:2}
.dash.dash-mgr .c-map{grid-column:6/10;grid-row:2}
.dash.dash-mgr .c-aging{grid-column:10/13;grid-row:2;align-self:start}
.dash.dash-mgr .c-map .mapbox{min-height:220px}
.c-reps td .name>span{white-space:nowrap}
/* page explanations behind a small (i); Circular 101 references as a short chip */
.info-tip{display:inline-grid;place-items:center;width:18px;height:18px;margin-inline-start:8px;vertical-align:middle;border:1px solid var(--line);border-radius:50%;font:italic 600 11px/1 Georgia,serif;color:var(--muted);cursor:help;background:var(--surface)}
.info-tip:hover,.info-tip:focus-visible{color:var(--ink);border-color:var(--sage-2);outline:none}
.ref-chip{display:inline-block;padding:0 8px;border:1px solid var(--line);border-radius:99px;font-size:11.5px;line-height:19px;color:var(--ink-2);background:var(--surface-2);cursor:help}
/* overview: decisions beside the top alerts */
.shell.mgr .ov-alerts .alerts li{min-height:44px}
/* finance: four headline figures, the cheque path, everything else folded */
.fin-def{display:none}
.fin-head{margin-bottom:12px}
.fin-path{margin-bottom:12px}
.fp-flow{display:flex;align-items:stretch;gap:8px;flex-wrap:wrap}
.fp-step{flex:1 1 140px;display:flex;flex-direction:column;gap:2px;padding:10px 12px;border:1px solid var(--line);border-radius:10px;text-decoration:none;color:var(--ink);background:var(--surface-2)}
.fp-step:hover{border-color:var(--sage-2)}
.fp-step>span{font-size:12.5px;color:var(--ink-2)}
.fp-step>b{font-size:20px}
.fp-step>small{color:var(--muted);font-size:11.5px}
.fp-arrow{align-self:center;font-style:normal;color:var(--muted);font-size:18px}
.fp-side{display:flex;gap:8px;flex-wrap:wrap;margin-top:10px}
.fp-side .chip{text-decoration:none}
.fin-more{margin-bottom:12px}
.fin-more>summary{cursor:pointer;padding:12px 14px;font-weight:600}
.fin-more[open]>summary{border-bottom:1px solid var(--line-2)}
.fin-more>.fin-stat-grid,.fin-more>.fin-kpis{margin:12px 14px}
@media (max-width:1200px){
  .kpis{grid-template-columns:repeat(2,minmax(0,1fr))}
  .dash.dash-mgr>*{grid-column:1/-1!important}
  .dash.dash-mgr .c-reps{order:1}.dash.dash-mgr .c-trend{order:2}.dash.dash-mgr .c-map{order:3}.dash.dash-mgr .c-aging{order:4}
}
@media (max-width:820px){
  .fp-arrow{display:none}
  /* the Overview puts what needs the manager before the figures on a phone */
  .shell.mgr .main>.ov-grid{order:1}.shell.mgr .main>.ov-k{order:2}
}
