:root{--bg:#0f1419;--panel:#1a2129;--panel2:#212a34;--line:#2c3743;--text:#e6edf3;--muted:#8b98a5;--accent:#d4a53f;--green:#3fb970;--red:#e5534b;--blue:#4f9cf0;--purple:#a78bfa;font-size:15px}
*{box-sizing:border-box;margin:0}
body{background:var(--bg);color:var(--text);font-family:-apple-system,'Segoe UI',Roboto,sans-serif;display:flex;min-height:100vh}
a{color:var(--blue);text-decoration:none}
nav{width:210px;background:var(--panel);border-right:1px solid var(--line);padding:18px 0;flex-shrink:0;position:sticky;top:0;height:100vh}
nav .brand{padding:0 18px 16px;font-weight:700;color:var(--accent);font-size:1.05rem;border-bottom:1px solid var(--line);margin-bottom:10px}
nav a{display:block;padding:9px 18px;color:var(--muted)}
nav a:hover,nav a.active{color:var(--text);background:var(--panel2)}
nav .badge{background:var(--red);color:#fff;border-radius:9px;padding:1px 7px;font-size:.75rem;margin-left:6px}
main{flex:1;padding:26px 32px;max-width:1200px}
h1{font-size:1.35rem;margin-bottom:16px}h2{font-size:1.05rem;margin:20px 0 10px;color:var(--muted)}
.cards{display:grid;grid-template-columns:repeat(auto-fit,minmax(180px,1fr));gap:12px;margin-bottom:20px}
.card{background:var(--panel);border:1px solid var(--line);border-radius:10px;padding:14px 16px}
.card .v{font-size:1.45rem;font-weight:700;margin-top:4px}
.card .l{color:var(--muted);font-size:.82rem;text-transform:uppercase;letter-spacing:.04em}
table{width:100%;border-collapse:collapse;background:var(--panel);border:1px solid var(--line);border-radius:10px;overflow:hidden}
th,td{padding:9px 12px;text-align:left;border-bottom:1px solid var(--line);font-size:.9rem}
th{color:var(--muted);font-weight:600;font-size:.78rem;text-transform:uppercase;background:var(--panel2)}
tr:last-child td{border-bottom:none}
tr:hover td{background:var(--panel2)}
.pill{display:inline-block;padding:2px 9px;border-radius:20px;font-size:.78rem;background:var(--panel2);border:1px solid var(--line)}
.pill.New{color:var(--blue)}.pill.Won,.pill.won,.pill.parsed{color:var(--green)}
/* Lead statuses, one vocabulary across portals: untouched -> muted,
   opened but unanswered -> amber (needs the broker), answered -> green,
   missed call -> red. */
.pill.replied,.pill.answered{color:var(--green)}
.pill.not-opened{color:var(--muted)}
.pill.opened{color:var(--accent)}
.pill.missed{color:var(--red);border-color:var(--red)}
.pill.sent,.pill.delivered{color:var(--muted)}.pill.read{color:var(--accent)}
.pill.Lost,.pill.lost,.pill.needs_review{color:var(--red)}
/* Call outcomes. Missed is a call to return, not a dead lead — amber, not red. */
.pill.Answered{color:var(--green)}
.pill.Missed{color:var(--accent);border-color:var(--accent)}
.stagesub{display:block;font-size:.7rem;margin-top:2px}
.pill.pending,.pill.queued_no_api{color:var(--accent)}
form.inline{display:inline}
input,select,textarea{background:var(--panel2);color:var(--text);border:1px solid var(--line);border-radius:7px;padding:7px 10px;font-size:.9rem;font-family:inherit}
input:focus,select:focus,textarea:focus{outline:1px solid var(--accent)}
button,.btn{background:var(--accent);color:#161207;border:none;border-radius:7px;padding:8px 14px;font-weight:600;cursor:pointer;font-size:.88rem}
button.ghost,.btn.ghost{background:var(--panel2);color:var(--text);border:1px solid var(--line)}
.panel{background:var(--panel);border:1px solid var(--line);border-radius:10px;padding:16px;margin-bottom:16px}
.grid2{display:grid;grid-template-columns:1fr 1fr;gap:16px}
.formrow{display:flex;gap:10px;flex-wrap:wrap;margin-bottom:10px}
.formrow label{display:flex;flex-direction:column;gap:4px;font-size:.8rem;color:var(--muted)}
.warn{background:#3a2f18;border:1px solid var(--accent);color:#f0d48a;padding:10px 14px;border-radius:8px;margin-bottom:14px;font-size:.88rem}
.ok{color:var(--green)}.bad{color:var(--red)}.muted{color:var(--muted)}
/* Monthly leads + commission (dashboard). Bars stack channels bottom-up and are
   scaled to the busiest month; commission is text, since AED and lead counts
   don't share an axis. */
.months{display:flex;gap:34px;align-items:flex-end;margin:18px 0 4px;overflow-x:auto;padding-bottom:4px}
/* One group per month = leads bar + deals bar, capped so a two-month chart
   reads as bars rather than slabs. */
.mgroup{flex:0 1 300px;display:flex;flex-direction:column;align-items:center;
        border-top:0;padding:0 4px}
.mbars{display:flex;gap:14px;align-items:flex-end;width:100%;justify-content:center}
.mcol{flex:1 1 auto;max-width:86px;display:flex;flex-direction:column;align-items:center;justify-content:flex-end}
.mtotal{font-size:1.35rem;font-weight:700;height:30px;line-height:30px}
.mtotal.dim{color:var(--muted);font-weight:400}
/* No track background: the bar's height IS the number, and an empty track
   behind a short month reads as a full bar. */
.mstack{height:200px;width:100%;display:flex;flex-direction:column-reverse;
        justify-content:flex-start;border-radius:5px 5px 0 0;overflow:hidden}
/* Counts sit inside their segment; the palette is light, so the text is dark. */
.mstack .seg{width:100%;min-height:3px;display:flex;align-items:center;justify-content:center}
.mstack .seg span{font-size:.85rem;font-weight:700;color:#161207;opacity:.85}
.seg.wa{background:var(--blue)}
.seg.call{background:var(--green)}
.seg.other{background:var(--muted)}
.seg.rent{background:var(--accent)}
.seg.sale{background:var(--purple)}
.mcap{font-size:.68rem;color:var(--muted);margin-top:6px;text-transform:uppercase;letter-spacing:.04em;
  /* Columns in a group align on their bottom edge, so a caption that wraps to
     two lines ("Property Finder") would push its bar higher than a one-line
     neighbour ("Bayut"). Two lines are reserved for every caption, which keeps
     every bar in the group on one baseline. */
  height:2.1em;line-height:1.05;text-align:center;display:flex;
  align-items:flex-start;justify-content:center}
.mlabel{font-size:.92rem;margin-top:10px;white-space:nowrap;font-weight:700}
.mgci{font-size:.95rem;margin-top:4px;text-align:center;white-space:nowrap;font-weight:600}
.mgci.zero{color:var(--muted);font-size:.75rem;font-weight:400}
/* Commission-by-month chart (deals page + broker page). Single bar per month;
   the darker inner block is the broker's own share of that month's GCI. */
.cchart .mgroup{flex:0 1 190px}
.cchart .mcol,.cchart .cbar{max-width:none}
.cchart .mstack{height:150px;width:100%;max-width:78px;margin:0 auto}
.cchart .mtotal{font-size:1rem}
.seg.gci{background:var(--green);position:relative;display:block}
.seg.gci .inner{position:absolute;bottom:0;left:0;width:100%;background:#2b7d4d;
                border-top:1px solid rgba(255,255,255,.25)}
.sw.gci{background:var(--green)}.sw.share{background:#2b7d4d}
/* Leads-per-broker chart on the leads page (same geometry as .cchart). */
.cchart .mlabel a{color:inherit;text-decoration:none}
.cchart .mlabel a:hover{text-decoration:underline}
/* Month heading above a grouped deals table. */
.monthhead{display:flex;align-items:baseline;gap:10px;flex-wrap:wrap;
           color:var(--text);margin:22px 0 8px}
.monthhead .muted{font-size:.78rem;font-weight:400}
.monthhead.sub{font-size:.92rem;margin:16px 0 6px}
.mmix{display:flex;gap:10px;margin-top:4px;font-size:.72rem;color:var(--muted)}
.mmix .k{white-space:nowrap}
/* Swatch colours only — the shared `.legend` / `.legend i` rules below (also
   used by Reports) provide the layout and the swatch box itself. */
.sw.wa{background:var(--blue)}.sw.call{background:var(--green)}.sw.other{background:var(--muted)}
.sw.rent{background:var(--accent)}.sw.sale{background:var(--purple)}
.legend b{color:var(--text);font-weight:600}
.msg{border-left:3px solid var(--line);padding:8px 12px;margin-bottom:8px;background:var(--panel2);border-radius:0 8px 8px 0;font-size:.88rem}
.msg.inbound{border-color:var(--green)}.msg.outbound{border-color:var(--blue)}
.msg .meta{color:var(--muted);font-size:.75rem;margin-top:3px}
.login-wrap{margin:auto;width:340px}
.topbar{display:flex;justify-content:space-between;align-items:center;margin-bottom:16px;gap:10px;flex-wrap:wrap}
.intg{display:flex;gap:8px;flex-wrap:wrap;margin-bottom:16px}
.intg .pill{font-size:.75rem}
.legend{display:flex;gap:14px;flex-wrap:wrap;margin-bottom:10px;font-size:.8rem;color:var(--muted)}
.legend-col{flex-direction:column;gap:6px}
.legend i{display:inline-block;width:10px;height:10px;border-radius:3px;margin-right:6px;vertical-align:-1px}
.hbar-row{display:flex;align-items:center;gap:10px;margin-bottom:7px}
.hbar-label{width:110px;font-size:.85rem;text-align:right;flex-shrink:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.hbar-track{flex:1 1 120px;display:flex;gap:2px;height:14px;min-width:120px}
.hbar-track i{display:block;height:100%;border-radius:0 4px 4px 0;min-width:0;flex-shrink:0}
.hbar-track i:first-child{border-radius:4px}
.hbar-val{min-width:70px;font-size:.78rem;color:var(--muted);flex-shrink:0;white-space:nowrap}
.grid2{grid-template-columns:repeat(auto-fit,minmax(320px,1fr))}
.vbars{display:flex;gap:14px;align-items:flex-end;height:150px;padding-top:18px}
.vbar{flex:1;display:flex;flex-direction:column;align-items:center;justify-content:flex-end;height:100%}
.vbar i{width:60%;max-width:38px;background:#3987e5;border-radius:4px 4px 0 0;min-height:2px}
.vbar-val{font-size:.7rem;color:var(--muted);margin-bottom:3px}
.vbar-label{font-size:.72rem;color:var(--muted);margin-top:5px}
.donut-wrap{display:flex;gap:20px;align-items:center}
.donut{width:140px;height:140px;flex-shrink:0;transform:rotate(0deg)}
.hbar-row:hover .hbar-track i,.vbar:hover i{filter:brightness(1.25)}

/* Leads by area x month x portal. Wide by nature — it grows two columns per
   month — so it scrolls inside its own box rather than stretching the page. */
.tablewrap{overflow-x:auto;border:1px solid var(--line);border-radius:10px}
.areatable{margin:0;white-space:nowrap}
.areatable th.mhead{text-align:center;border-left:1px solid var(--line)}
.areatable th.sub{font-size:.7rem;color:var(--muted);text-align:right;font-weight:400}
.areatable td{text-align:right}
.areatable td:first-child,.areatable th:first-child{text-align:left;position:sticky;left:0;
  background:var(--panel)}
.areatable .tot{border-left:1px solid var(--line);font-weight:600}
.areatable .footrow td{border-top:1px solid var(--line);font-weight:700}

/* ---- Reporting: responsiveness, matrix, queue ---------------------------
   The rate bar is always full width: its segments are shares of that broker's
   OWN leads, so lengths compare across brokers no matter the volume. Volume is
   carried by the printed lead count, never by the bar. */
.rbar{display:flex;width:100%;min-width:120px;height:13px;gap:1px;border-radius:4px;overflow:hidden;
  background:var(--panel2)}
.rbar i{display:block;height:100%;min-width:0}
.rpt td,.rpt th{white-space:nowrap}
.rpt td.num{text-align:right;font-variant-numeric:tabular-nums}
.rpt th.w40{width:34%}
.rpt .strong{font-weight:700}
.rpt tr.total td{border-top:2px solid var(--line);font-weight:700;background:var(--panel2)}
.rpt tr.total:hover td{background:var(--panel2)}
.pill.strong{color:var(--green);border-color:var(--green)}
.pill.needs-attention{color:var(--red);border-color:var(--red)}
.pill.watch{color:var(--accent);border-color:var(--accent)}
.pill.ok{color:var(--muted)}
.small{font-size:.78rem}
p.muted.small{margin-top:8px}
.scroll-x{overflow-x:auto}

/* Heatmap. Shading carries the rate; the number is printed too, because a
   colour alone is unreadable for anyone who cannot separate these greens. */
.matrix td.heat{text-align:right;font-variant-numeric:tabular-nums}
.matrix td.heat.thin{background:var(--panel2)}
.matrix th.rot{font-size:.68rem;line-height:1.2;white-space:normal;max-width:78px;vertical-align:bottom}
.matrix td:first-child,.matrix th:first-child{position:sticky;left:0;background:var(--panel);z-index:1}

/* Queue rows: the age is the point, so it leads and is colour-coded. */
.age{font-variant-numeric:tabular-nums;font-weight:600}
.age.hot{color:var(--red)}
.age.warm{color:var(--accent)}
.qcount{font-size:1.5rem;font-weight:700}
.qcard{display:block;padding:12px 14px;border:1px solid var(--line);border-radius:10px;background:var(--panel)}
.qcard:hover{background:var(--panel2)}
.qcard .l{color:var(--muted);font-size:.78rem;text-transform:uppercase;letter-spacing:.04em}
.subnav{display:flex;gap:6px;flex-wrap:wrap;margin:-4px 0 16px}
.subnav a{padding:5px 11px;border:1px solid var(--line);border-radius:20px;font-size:.82rem;color:var(--muted)}
.subnav a:hover{color:var(--text);background:var(--panel2)}
.subnav a.on{color:var(--text);background:var(--panel2);border-color:var(--muted)}
.action{display:flex;gap:12px;align-items:flex-start;padding:11px 4px;border-bottom:1px solid var(--line)}
.action:last-child{border-bottom:0}
.action .n{flex-shrink:0;width:22px;height:22px;border-radius:50%;background:var(--panel2);
  border:1px solid var(--line);color:var(--accent);font-size:.78rem;font-weight:700;
  display:flex;align-items:center;justify-content:center}

/* Communities-by-demand: a table, not a bar list. The bar is a ranking cue
   inside its own cell and is scaled to the busiest community, so the numbers
   in the columns beside it are what is actually read. */
.areademand td:first-child{white-space:nowrap;max-width:none}
.areademand .rbar{display:inline-flex;min-width:2px;vertical-align:middle;height:12px}

/* Sidebar groups. <details> gives a click-to-expand section with no JS; the
   summary is styled as a nav row and carries its own disclosure caret because
   the native marker sits badly against the left padding. */
nav .navgroup summary{display:flex;align-items:center;justify-content:space-between;
  padding:9px 18px;color:var(--muted);cursor:pointer;list-style:none;user-select:none}
nav .navgroup summary::-webkit-details-marker{display:none}
nav .navgroup summary::after{content:"›";transform:rotate(90deg);transition:transform .15s;
  font-size:1rem;line-height:1;opacity:.7}
nav .navgroup[open] summary::after{transform:rotate(-90deg)}
nav .navgroup summary:hover{color:var(--text);background:var(--panel2)}
nav .navgroup a.sub{padding-left:32px;font-size:.88rem}
nav .navgroup a.sub.active{color:var(--text);background:var(--panel2);
  box-shadow:inset 2px 0 0 var(--accent)}
nav a.active{color:var(--text);background:var(--panel2);box-shadow:inset 2px 0 0 var(--accent)}

/* Listing enquiry popup. Pure CSS via :target — this codebase has no
   JavaScript and this feature did not justify introducing any. The panel is
   hidden until its id is the URL fragment; the backdrop is itself a link back
   to #enquired, so clicking outside closes it AND returns to the table. */
.modal{display:none}
.modal:target{display:flex;position:fixed;inset:0;z-index:50;align-items:center;
  justify-content:center;padding:24px}
.modal-back{position:absolute;inset:0;background:rgba(0,0,0,.62)}
.modal-card{position:relative;z-index:1;width:min(880px,100%);max-height:82vh;
  display:flex;flex-direction:column;background:var(--panel);
  border:1px solid var(--line);border-radius:12px;
  box-shadow:0 18px 48px rgba(0,0,0,.55)}
.modal-head{display:flex;align-items:flex-start;justify-content:space-between;gap:16px;
  padding:14px 16px;border-bottom:1px solid var(--line)}
.modal-x{font-size:1.5rem;line-height:1;color:var(--muted);padding:0 4px}
.modal-x:hover{color:var(--text)}
.modal-body{overflow:auto;padding:12px 16px 16px}
.modal-body table{border:0}
.rowlink{color:var(--text)}
.rowlink:hover{color:var(--blue);text-decoration:underline}
/* Section headings inside a form panel (Portal accounts, CRM login). */
form h3.sub{font-size:.8rem;text-transform:uppercase;letter-spacing:.04em;color:var(--muted);margin:14px 0 4px}

/* Visually hidden but still submittable: used for the default-submit
   twin in forms that carry a second, non-submitting action button. */
.vh{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap;border:0}
