:root {
  --brand: #E8450A;
  --brand-bg: rgba(232,69,10,0.08);
  --brand-hover: #C93A07;
  --brand-light: #FEF0EA;
  --brand-dim: rgba(232,69,10,0.12);
  --sidebar-w: 230px;
  --topbar-h: 60px;
  --bg: #F7F6F4;
  --surface: #FFFFFF;
  --surface-2: #FAFAF9;
  --border: #EBEBEA;
  --border-mid: #D8D6D1;
  --text: #1C1917;
  --text-2: #44403C;
  --text-3: #78716C;
  --text-4: #A8A29E;
  --green: #16A34A;
  --green-bg: #DCFCE7;
  --red: #DC2626;
  --red-bg: #FEE2E2;
  --amber: #D97706;
  --amber-bg: #FEF3C7;
  --blue: #2563EB;
  --blue-bg: #DBEAFE;
  --r-xs: 6px;
  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 16px;
  --shadow-xs: 0 1px 2px rgba(0,0,0,0.05);
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.07), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.08), 0 1px 3px rgba(0,0,0,0.05);
  --shadow-lg: 0 20px 40px rgba(0,0,0,0.12), 0 4px 12px rgba(0,0,0,0.06);
}

*{box-sizing:border-box;margin:0;padding:0}
canvas{display:block!important;max-width:100%!important}
.chart-wrap{position:relative;width:100%;overflow:hidden}
.chart-h-200{height:200px!important;max-height:200px!important;overflow:hidden}
.chart-h-220{height:220px!important;max-height:220px!important;overflow:hidden}
.chart-h-260{height:260px!important;max-height:260px!important;overflow:hidden}
html{font-size:14px}
body{font-family:'DM Sans',-apple-system,sans-serif;background:var(--bg);color:var(--text);line-height:1.5;-webkit-font-smoothing:antialiased}
a{text-decoration:none;color:inherit}
button{font-family:inherit;cursor:pointer;outline:none}
input,select,textarea{font-family:inherit;outline:none}
img{display:block}
.hidden{display:none!important}

::-webkit-scrollbar{width:4px;height:4px}
::-webkit-scrollbar-track{background:transparent}
::-webkit-scrollbar-thumb{background:var(--border-mid);border-radius:4px}

/* ══ LOGIN ══════════════════════════════════════════ */
.login-page{display:flex;min-height:100vh;background:var(--surface)}

.login-left{
  width:52%;background:#111110;
  padding:48px 56px;
  display:flex;flex-direction:column;
  position:relative;overflow:hidden;
}
.ll-grid{
  position:absolute;inset:0;
  background-image:
    linear-gradient(rgba(255,255,255,0.025) 1px,transparent 1px),
    linear-gradient(90deg,rgba(255,255,255,0.025) 1px,transparent 1px);
  background-size:48px 48px;
}
.ll-glow{
  position:absolute;top:-100px;left:-100px;
  width:500px;height:500px;
  background:radial-gradient(circle,rgba(232,69,10,0.18) 0%,transparent 70%);
  pointer-events:none;
}
.login-brand{display:flex;align-items:center;gap:10px;position:relative;z-index:1;margin-bottom:auto}
.bmark{
  width:38px;height:38px;border-radius:10px;
  background:var(--brand);
  display:flex;align-items:center;justify-content:center;
  font-size:17px;font-weight:700;color:#fff;letter-spacing:-0.5px;
}
.bname{font-size:19px;font-weight:600;color:#fff;letter-spacing:-0.3px}

.login-copy{position:relative;z-index:1;margin-bottom:48px}
.login-copy h1{
  font-size:38px;font-weight:300;color:#fff;
  line-height:1.18;letter-spacing:-0.8px;margin-bottom:18px;
}
.login-copy h1 span{color:var(--brand)}
.login-copy p{font-size:15px;color:rgba(255,255,255,0.42);line-height:1.75;max-width:380px}

.login-stats{display:flex;gap:0;position:relative;z-index:1;border:1px solid rgba(255,255,255,0.08);border-radius:var(--r-md);overflow:hidden}
.lstat{flex:1;padding:18px 20px;border-right:1px solid rgba(255,255,255,0.08)}
.lstat:last-child{border-right:none}
.lstat-n{font-size:28px;font-weight:500;color:var(--brand);font-variant-numeric:tabular-nums;letter-spacing:-0.5px;display:block;margin-bottom:2px}
.lstat-l{font-size:11px;color:rgba(255,255,255,0.35);letter-spacing:0.2px}

.login-right{
  flex:1;display:flex;align-items:center;justify-content:center;
  padding:48px;background:var(--surface);
}
.lform{width:100%;max-width:360px}
.lform-hd{margin-bottom:32px}
.lform-hd h2{font-size:26px;font-weight:500;letter-spacing:-0.5px;margin-bottom:6px}
.lform-hd p{font-size:13px;color:var(--text-3)}

.fg{margin-bottom:14px}
.fg label{display:block;font-size:12px;font-weight:500;color:var(--text-3);margin-bottom:6px;letter-spacing:0.1px}
.finput{
  width:100%;padding:10px 13px;
  border:1.5px solid var(--border);border-radius:var(--r-sm);
  font-size:14px;color:var(--text);background:var(--surface);
  transition:border-color 0.15s,box-shadow 0.15s;
}
.finput:focus{border-color:var(--brand);box-shadow:0 0 0 3px rgba(232,69,10,0.1)}
.frow{display:flex;justify-content:space-between;align-items:center;margin-bottom:20px}
.cbx{display:flex;align-items:center;gap:7px;font-size:13px;color:var(--text-3);cursor:pointer}
.cbx input{accent-color:var(--brand);width:14px;height:14px}
.lnk{font-size:13px;color:var(--brand);font-weight:500}
.divider{display:flex;align-items:center;gap:12px;margin:16px 0}
.divider::before,.divider::after{content:'';flex:1;height:1px;background:var(--border)}
.divider span{font-size:12px;color:var(--text-4)}

/* ══ BUTTONS ════════════════════════════════════════ */
.btn{
  display:inline-flex;align-items:center;gap:6px;
  border-radius:var(--r-sm);font-size:13px;font-weight:500;
  padding:9px 16px;transition:all 0.15s;border:none;
  white-space:nowrap;
}
.btn-p{background:var(--brand);color:#fff}
.btn-p:hover{background:var(--brand-hover);box-shadow:0 4px 12px rgba(232,69,10,0.35)}
.btn-p:active{transform:scale(0.98)}
.btn-o{background:var(--surface);color:var(--text-2);border:1.5px solid var(--border)}
.btn-o:hover{background:var(--bg);border-color:var(--border-mid)}
.btn-full{width:100%;justify-content:center;padding:11px}
.btn-sm{padding:6px 12px;font-size:12px}
.btn-xs{padding:4px 10px;font-size:11px;border-radius:var(--r-xs)}
.ibtn{
  width:34px;height:34px;border-radius:var(--r-sm);
  background:transparent;border:none;
  display:flex;align-items:center;justify-content:center;
  color:var(--text-3);font-size:18px;
  transition:background 0.12s,color 0.12s;cursor:pointer;
}
.ibtn:hover{background:var(--border);color:var(--text)}
.ibtn i{font-size:16px}

/* ══ APP SHELL ══════════════════════════════════════ */
.app{display:flex;min-height:100vh}

/* ══ SIDEBAR ════════════════════════════════════════ */
.sidebar{
  width:var(--sidebar-w);
  background:var(--surface);
  border-right:1.5px solid var(--border);
  display:flex;flex-direction:column;
  position:fixed;top:0;left:0;bottom:0;
  z-index:200;transition:transform 0.25s ease;
}
.sb-top{padding:16px;border-bottom:1.5px solid var(--border)}
.sb-logo{display:flex;align-items:center;gap:9px;margin-bottom:14px}
.sb-logo .bmark{width:30px;height:30px;font-size:14px;border-radius:8px}
.sb-logo .bname{font-size:16px;color:var(--text)}
.sb-client{
  display:flex;align-items:center;gap:9px;
  padding:8px 10px;background:var(--bg);border-radius:var(--r-sm);
  border:1px solid var(--border);font-size:12px;font-weight:500;color:var(--text-2);
  cursor:pointer;
}
.sb-client img{width:22px;height:22px;border-radius:5px;object-fit:cover}
.sb-client i{margin-left:auto;font-size:12px;color:var(--text-4)}

.sb-nav{padding:10px 10px;flex:1;overflow-y:auto}
.sb-section{font-size:10px;font-weight:600;letter-spacing:0.7px;text-transform:uppercase;color:var(--text-4);padding:10px 8px 4px}
.nitem{
  display:flex;align-items:center;gap:9px;
  padding:8px 10px;border-radius:var(--r-sm);
  font-size:13px;color:var(--text-3);
  margin-bottom:1px;cursor:pointer;
  transition:background 0.1s,color 0.1s;
}
.nitem:hover{background:var(--bg);color:var(--text)}
.nitem.active{background:var(--brand-light);color:var(--brand);font-weight:500}
.nitem.active i{color:var(--brand)}
.nitem i{font-size:17px;flex-shrink:0}
.nitem .nlabel{flex:1}
.nbadge{
  padding:1px 7px;border-radius:10px;font-size:10px;font-weight:700;
  background:var(--red-bg);color:var(--red);
}
.nbadge.warn{background:var(--amber-bg);color:var(--amber)}

.sb-foot{padding:12px 14px;border-top:1.5px solid var(--border)}
.sb-user{display:flex;align-items:center;gap:9px}
.uavatar{
  width:32px;height:32px;border-radius:50%;
  background:var(--brand-light);color:var(--brand);
  display:flex;align-items:center;justify-content:center;
  font-size:11px;font-weight:700;flex-shrink:0;
}
.uname{font-size:12px;font-weight:600;display:block;color:var(--text)}
.uemail{font-size:11px;color:var(--text-4);display:block}

/* ══ MAIN ════════════════════════════════════════════ */
.main{margin-left:var(--sidebar-w);flex:1;display:flex;flex-direction:column;min-width:0;min-height:100vh}

/* ══ TOPBAR ══════════════════════════════════════════ */
.topbar{
  height:var(--topbar-h);
  background:var(--surface);
  border-bottom:1.5px solid var(--border);
  display:flex;align-items:center;
  padding:0 20px;gap:14px;
  position:sticky;top:0;z-index:100;
}
.tb-left{display:flex;align-items:center;gap:10px}
.breadcrumb{font-size:13px;color:var(--text-3)}
.tb-center{flex:1;display:flex;justify-content:center}
.apills{display:flex;gap:5px;padding:3px;background:var(--bg);border-radius:20px;border:1px solid var(--border)}
.apill{
  padding:5px 14px;border-radius:16px;font-size:12px;font-weight:500;
  border:none;background:transparent;color:var(--text-3);
  cursor:pointer;transition:all 0.15s;
}
.apill:hover{color:var(--text)}
.apill.active{background:var(--surface);color:var(--brand);box-shadow:var(--shadow-sm)}
.tb-right{display:flex;align-items:center;gap:6px}
.sync-ind{display:flex;align-items:center;gap:6px;font-size:12px;color:var(--text-3);padding:5px 10px;background:var(--bg);border-radius:20px;border:1px solid var(--border)}
.sdot{width:6px;height:6px;border-radius:50%;background:var(--green);animation:blink 2s infinite}
@keyframes blink{0%,100%{opacity:1}50%{opacity:0.3}}
.reload-btn{font-size:12px;color:var(--brand);font-weight:500;display:flex;align-items:center;gap:4px;background:none;border:none;cursor:pointer;padding:5px 8px}
.nbtn{position:relative}
.ndot{position:absolute;top:5px;right:5px;width:7px;height:7px;border-radius:50%;background:var(--brand);border:2px solid var(--surface)}

/* ══ CONTENT ════════════════════════════════════════ */
.pcontent{flex:1;overflow:auto;background:var(--bg);}
.page{display:none;padding:24px 24px 32px;animation:fadeUp 0.2s ease;background:var(--bg);min-height:200px;}
.page.active{display:block}
@keyframes fadeUp{from{opacity:0;transform:translateY(6px)}to{opacity:1;transform:none}}

.phdr{display:flex;align-items:flex-start;justify-content:space-between;margin-bottom:22px;gap:12px}
.phdr-l h1{font-size:22px;font-weight:500;letter-spacing:-0.4px;margin-bottom:3px}
.phdr-l p{font-size:13px;color:var(--text-3)}
.phdr-r{display:flex;gap:8px;flex-shrink:0}

/* ══ CARD ════════════════════════════════════════════ */
.card{
  background:var(--surface);
  border:1.5px solid var(--border);
  border-radius:var(--r-lg);
  padding:18px;
  box-shadow:var(--shadow-xs);
}
.card-hd{display:flex;align-items:center;justify-content:space-between;margin-bottom:14px}
.card-title{font-size:13px;font-weight:600;color:var(--text)}
.card-sub{font-size:12px;color:var(--text-3)}
.card-lnk{font-size:12px;color:var(--brand);font-weight:500}

/* ══ KPI STRIP ═══════════════════════════════════════ */
.kpi-strip{display:grid;grid-template-columns:repeat(6,minmax(0,1fr));gap:12px;margin-bottom:20px}
.kpicard{
  background:var(--surface);border:1.5px solid var(--border);
  border-radius:var(--r-lg);padding:16px;
  display:flex;flex-direction:column;gap:10px;
  box-shadow:var(--shadow-xs);position:relative;overflow:hidden;
}
.kpicard::after{
  content:'';position:absolute;bottom:0;left:0;right:0;height:3px;
  background:var(--brand);opacity:0;transition:opacity 0.15s;
}
.kpicard:hover::after{opacity:1}
.kpi-top{display:flex;align-items:flex-start;justify-content:space-between;gap:8px}
.kpi-icon{
  width:34px;height:34px;border-radius:9px;
  display:flex;align-items:center;justify-content:center;font-size:16px;flex-shrink:0;
}
.kpi-lbl{font-size:11px;color:var(--text-3);letter-spacing:0.1px}
.kpi-val{font-size:22px;font-weight:500;letter-spacing:-0.5px;line-height:1}
.kpi-val sub{font-size:13px;color:var(--text-3);font-weight:400;vertical-align:baseline}
.kpi-delta{font-size:11px;display:flex;align-items:center;gap:3px;font-weight:500}
.delta-up{color:var(--green)}
.delta-dn{color:var(--red)}
.delta-nt{color:var(--text-3)}

/* ══ DASHBOARD GRID ══════════════════════════════════ */
.dg1{display:grid;grid-template-columns:1fr 300px;gap:14px;margin-bottom:14px}
.dg2{display:grid;grid-template-columns:1fr 300px;gap:14px}

/* ══ TABLE ════════════════════════════════════════════ */
.tbl{width:100%;border-collapse:collapse;font-size:13px}
.tbl th{
  text-align:left;font-size:11px;font-weight:600;
  color:var(--text-3);padding:9px 14px;
  border-bottom:1.5px solid var(--border);
  background:var(--surface-2);white-space:nowrap;
}
.tbl td{
  padding:11px 14px;border-bottom:1px solid var(--border);
  color:var(--text);vertical-align:middle;
}
.tbl tr:last-child td{border-bottom:none}
.tbl tr:hover td{background:rgba(232,69,10,0.025);cursor:pointer}
.tbl-wrap{overflow:hidden;border-radius:var(--r-lg);border:1.5px solid var(--border);background:var(--surface)}

/* ══ BADGES ═══════════════════════════════════════════ */
.tag{display:inline-flex;align-items:center;gap:4px;padding:3px 9px;border-radius:20px;font-size:11px;font-weight:600;white-space:nowrap}
.tag-on{background:var(--green-bg);color:#14532D}
.tag-off{background:var(--red-bg);color:#7F1D1D}
.tag-stale{background:var(--amber-bg);color:#78350F}
.tag-closed{background:#F5F5F4;color:#57534E}
.tag-nofeed{background:#EEF2F6;color:#475569;border:1px dashed #CBD5E1}
.tag-admin{background:#EDE9FE;color:#3730A3}
.tag-profit{background:var(--blue-bg);color:#1E3A8A}
.tag-outlet{background:#F0FDF4;color:#14532D}
.tag-on::before,.tag-off::before,.tag-stale::before{content:'';width:5px;height:5px;border-radius:50%}
.tag-on::before{background:var(--green)}
.tag-off::before{background:var(--red)}
.tag-stale::before{background:var(--amber)}

/* ══ SPARK ═══════════════════════════════════════════ */
.spark{display:flex;align-items:flex-end;gap:2px;height:30px}
.sp{width:6px;border-radius:2px 2px 0 0;background:#EDE9E4;transition:background 0.2s}
.sp.hi{background:var(--brand)}

/* ══ RANK ════════════════════════════════════════════ */
.rlist{display:flex;flex-direction:column}
.ritem{display:flex;align-items:center;gap:10px;padding:9px 0;border-bottom:1px solid var(--border)}
.ritem:last-child{border-bottom:none}
.rnum{font-size:11px;font-weight:700;color:var(--text-4);width:16px;flex-shrink:0}
.rname{font-size:13px;color:var(--text);flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.rbar-bg{width:70px;height:3px;background:var(--bg);border-radius:2px;flex-shrink:0}
.rbar-fg{height:3px;border-radius:2px;background:var(--brand)}
.rval{font-size:12px;font-weight:600;color:var(--text);min-width:44px;text-align:right;font-variant-numeric:tabular-nums}

/* ══ ALERT ════════════════════════════════════════════ */
.alist{display:flex;flex-direction:column;gap:6px}
.aitem{
  display:flex;align-items:flex-start;gap:10px;
  padding:10px 12px;border-radius:var(--r-sm);
  background:var(--bg);border:1px solid var(--border);
}
.adot{width:7px;height:7px;border-radius:50%;flex-shrink:0;margin-top:5px}
.atxt{font-size:12px;color:var(--text-2);flex:1;line-height:1.45}
.atime{font-size:11px;color:var(--text-4);flex-shrink:0}

/* ══ FILTER BAR ══════════════════════════════════════ */
.fbar{display:flex;align-items:center;gap:10px;margin-bottom:14px;flex-wrap:wrap}
.sbox{
  display:flex;align-items:center;gap:8px;
  background:var(--surface);border:1.5px solid var(--border);
  border-radius:var(--r-sm);padding:8px 12px;min-width:230px;
}
.sbox:focus-within{border-color:var(--brand)}
.sbox i{font-size:15px;color:var(--text-4)}
.sbox input{border:none;background:transparent;font-size:13px;color:var(--text);width:100%}
.fpills{display:flex;gap:5px;flex-wrap:wrap}
.fpill{
  padding:5px 12px;border-radius:20px;font-size:12px;font-weight:500;
  border:1.5px solid var(--border);background:var(--surface);color:var(--text-3);
  cursor:pointer;transition:all 0.12s;
}
.fpill:hover{border-color:var(--brand);color:var(--brand)}
.fpill.active{background:var(--brand);color:#fff;border-color:var(--brand);box-shadow:0 2px 8px rgba(232,69,10,0.3)}
.mini-sel{
  border:1.5px solid var(--border);border-radius:var(--r-sm);
  padding:5px 10px;font-size:12px;color:var(--text-3);
  background:var(--surface);cursor:pointer;
}

/* ══ OUTLET DETAIL PANEL ═════════════════════════════ */
.detail-panel{
  position:fixed;top:0;right:0;bottom:0;width:820px;
  background:var(--bg);border-left:1.5px solid var(--border);
  overflow-y:auto;z-index:300;
  box-shadow:-8px 0 32px rgba(0,0,0,0.1);
  animation:slideR 0.25s ease;
}
@keyframes slideR{from{transform:translateX(30px);opacity:0}to{transform:none;opacity:1}}
.dp-topbar{
  background:var(--surface);border-bottom:1.5px solid var(--border);
  padding:16px 20px;display:flex;align-items:center;gap:12px;
  position:sticky;top:0;z-index:10;
}
.dp-content{padding:20px}
.dp-kpis{display:grid;grid-template-columns:repeat(4,1fr);gap:10px;margin-bottom:16px}
.dp-kpi{background:var(--surface);border:1.5px solid var(--border);border-radius:var(--r-md);padding:13px 15px}
.dp-kpi .lbl{font-size:11px;color:var(--text-3);margin-bottom:5px}
.dp-kpi .val{font-size:18px;font-weight:500;letter-spacing:-0.3px}
.dp-kpi .d{font-size:11px;margin-top:3px;font-weight:500}
.dp-charts{display:grid;grid-template-columns:1fr 1fr;gap:14px;margin-bottom:14px}

/* ══ AI INSIGHT ══════════════════════════════════════ */
.ai-card{background:var(--surface);border:1.5px solid var(--border);border-radius:var(--r-lg);padding:16px}
.ai-hd{display:flex;align-items:center;gap:10px;padding-bottom:12px;border-bottom:1px solid var(--border);margin-bottom:12px}
.ai-icon{
  width:30px;height:30px;background:var(--brand-light);
  border-radius:8px;display:flex;align-items:center;justify-content:center;
  color:var(--brand);font-size:15px;flex-shrink:0;
}
.ai-title{font-size:13px;font-weight:600;color:var(--text)}
.ai-sub{font-size:11px;color:var(--text-3)}
.irow{display:flex;align-items:flex-start;gap:9px;margin-bottom:10px}
.irow:last-child{margin-bottom:0}
.idot{width:6px;height:6px;border-radius:50%;margin-top:5px;flex-shrink:0}
.itxt{font-size:12px;color:var(--text-2);line-height:1.55}
.itxt strong{font-weight:600;color:var(--text)}

/* ══ ASSETS ══════════════════════════════════════════ */
.agrid{display:grid;grid-template-columns:repeat(auto-fill,minmax(210px,1fr));gap:12px}
.acard{
  background:var(--surface);border:1.5px solid var(--border);
  border-radius:var(--r-lg);padding:18px;
  cursor:pointer;transition:border-color 0.15s,box-shadow 0.15s;
}
.acard:hover{border-color:var(--brand);box-shadow:0 4px 16px rgba(232,69,10,0.12)}
.ac-city{font-size:10px;font-weight:600;letter-spacing:0.5px;color:var(--text-4);text-transform:uppercase;margin-bottom:5px}
.ac-name{font-size:16px;font-weight:600;color:var(--brand);margin-bottom:12px;letter-spacing:-0.2px}
.ac-meta{display:flex;gap:12px;font-size:12px;color:var(--text-3);margin-bottom:12px}
.ac-rev{font-size:18px;font-weight:500;letter-spacing:-0.3px}
.ac-rev sub{font-size:12px;font-weight:400;color:var(--text-3);vertical-align:baseline}

/* ══ ANALYTICS ════════════════════════════════════════ */
.ang{display:grid;grid-template-columns:1fr 290px;gap:14px}
.anlg{grid-column:1}
.anr{grid-column:2}

/* ══ COMPARE ══════════════════════════════════════════ */
.cmp-sels{display:flex;align-items:center;gap:14px;margin-bottom:20px}
.vs{
  padding:6px 16px;background:var(--bg);
  border:1.5px solid var(--border);border-radius:var(--r-sm);
  font-size:12px;font-weight:700;color:var(--text-3);letter-spacing:1px;
}
.cmp-kpis{display:grid;grid-template-columns:1fr 1fr;gap:14px;margin-bottom:14px}
.cmp-grp{background:var(--surface);border:1.5px solid var(--border);border-radius:var(--r-lg);padding:16px}
.cmp-grp h4{font-size:14px;font-weight:600;margin-bottom:12px;padding-bottom:10px;border-bottom:1px solid var(--border)}
.crow{display:flex;justify-content:space-between;padding:7px 0;font-size:13px;border-bottom:1px solid var(--border)}
.crow:last-child{border-bottom:none}
.clbl{color:var(--text-3)}
.cval{font-weight:600}

/* ══ NOTIF ════════════════════════════════════════════ */
.ng{display:grid;grid-template-columns:1fr 1fr;gap:14px}
.email-item{display:flex;align-items:center;gap:10px;padding:9px 0;border-bottom:1px solid var(--border)}
.email-item:last-child{border-bottom:none}
.email-addr{font-size:13px;flex:1}
.asset-email-sec{margin-bottom:16px}
.aes-ttl{font-size:11px;font-weight:700;color:var(--text-3);letter-spacing:0.3px;text-transform:uppercase;margin-bottom:8px}
.aer{display:flex;align-items:center;gap:8px;padding:6px 0;border-bottom:1px solid var(--border)}
.aer:last-child{border-bottom:none}
.aer span{font-size:12px;flex:1;color:var(--text-2)}

/* ══ ROLES ════════════════════════════════════════════ */
.rolegrid{display:grid;grid-template-columns:repeat(auto-fill,minmax(240px,1fr));gap:14px}
.rolecard{background:var(--surface);border:1.5px solid var(--border);border-radius:var(--r-lg);padding:18px}
.rc-name{font-size:16px;font-weight:600;margin-bottom:4px;letter-spacing:-0.2px}
.rc-desc{font-size:12px;color:var(--text-3);margin-bottom:14px;line-height:1.55}
.plist{display:flex;flex-direction:column;gap:5px}
.prow{display:flex;align-items:center;gap:7px;font-size:12px}
.prow i{font-size:13px}
.prow.yes{color:var(--green)}
.prow.no{color:var(--text-4)}

/* ══ MODAL ════════════════════════════════════════════ */
.moverlay{
  position:fixed;inset:0;background:rgba(0,0,0,0.45);
  display:flex;align-items:center;justify-content:center;
  z-index:500;animation:fadeIn 0.15s;backdrop-filter:blur(2px);
}
.modal{
  background:var(--surface);border-radius:var(--r-lg);
  width:580px;max-width:95vw;max-height:90vh;overflow-y:auto;
  box-shadow:var(--shadow-lg);border:1.5px solid var(--border);
}
.mhd{
  display:flex;align-items:center;justify-content:space-between;
  padding:18px 22px 14px;border-bottom:1.5px solid var(--border);
}
.mhd h3{font-size:16px;font-weight:600;letter-spacing:-0.2px}
.mbody{padding:22px;display:flex;flex-direction:column;gap:16px}
.mfoot{padding:14px 22px;border-top:1.5px solid var(--border);display:flex;justify-content:flex-end;gap:8px}
.cbx-grp{display:flex;flex-direction:column;gap:8px}

/* ══ EMAIL TAGS ══════════════════════════════════════ */
.etags{
  display:flex;flex-wrap:wrap;gap:6px;align-items:center;
  padding:8px 10px;border:1.5px solid var(--border);
  border-radius:var(--r-sm);min-height:44px;
  transition:border-color 0.15s;
}
.etags:focus-within{border-color:var(--brand)}
.etag{
  display:flex;align-items:center;gap:5px;
  background:var(--brand-light);color:var(--brand);
  padding:3px 9px;border-radius:16px;font-size:12px;font-weight:500;
}
.etag i{font-size:11px;cursor:pointer;opacity:0.6}
.etag i:hover{opacity:1}
.tinput{border:none;background:transparent;font-size:13px;color:var(--text);min-width:160px}

/* ══ EMAIL PREVIEW ════════════════════════════════════ */
.eprev{border:1.5px solid var(--border);border-radius:var(--r-md);overflow:hidden}
.ep-hd{background:#1C1917;padding:12px 16px;display:flex;justify-content:space-between;align-items:center}
.ep-lbl{font-size:12px;font-weight:700;color:#fff;letter-spacing:0.2px}
.ep-time{font-size:11px;color:rgba(255,255,255,0.4)}
.ep-body{padding:14px;background:var(--surface-2)}
.ep-kpis{display:grid;grid-template-columns:repeat(4,1fr);gap:8px;margin-bottom:12px}
.epk{background:var(--surface);border:1px solid var(--border);border-radius:var(--r-sm);padding:10px;text-align:center}
.epk span{display:block;font-size:16px;font-weight:600;color:var(--brand);letter-spacing:-0.3px}
.epk small{font-size:10px;color:var(--text-3)}
.ept{background:var(--surface);border:1px solid var(--border);border-radius:var(--r-sm);overflow:hidden}
.eptr{display:grid;grid-template-columns:1fr auto auto;gap:10px;padding:8px 12px;border-bottom:1px solid var(--border);font-size:12px;align-items:center}
.eptr:last-child{border-bottom:none}
.eph{background:var(--surface-2);font-size:10px;font-weight:700;color:var(--text-3);letter-spacing:0.3px}

/* ══ TOAST ════════════════════════════════════════════ */
.toast{
  position:fixed;bottom:28px;left:50%;transform:translateX(-50%);
  background:#1C1917;color:#fff;
  padding:11px 22px;border-radius:var(--r-sm);
  font-size:13px;font-weight:500;z-index:1000;
  box-shadow:0 8px 24px rgba(0,0,0,0.2);
  animation:toastUp 0.2s ease;
}
@keyframes toastUp{from{opacity:0;transform:translateX(-50%) translateY(8px)}to{opacity:1;transform:translateX(-50%) translateY(0)}}
@keyframes fadeIn{from{opacity:0}to{opacity:1}}

/* ══ PERF TABLE ══════════════════════════════════════ */
.aperf-item{display:flex;align-items:center;gap:10px;padding:9px 0;border-bottom:1px solid var(--border)}
.aperf-item:last-child{border-bottom:none}
.aperf-name{font-size:12px;flex:1}
.aperf-name small{display:block;color:var(--text-4);font-size:10px}
.aperf-bar-bg{width:80px;height:3px;background:var(--bg);border-radius:2px}
.aperf-bar-fg{height:3px;border-radius:2px;background:var(--brand)}
.aperf-val{font-size:12px;font-weight:600;min-width:52px;text-align:right}

/* ══ RESPONSIVE ══════════════════════════════════════ */
@media(max-width:1200px){
  .kpi-strip{grid-template-columns:repeat(3,1fr)}
  .dg1,.dg2{grid-template-columns:1fr}
  .ang{grid-template-columns:1fr}
  .anlg,.anr{grid-column:1}
  .dp-charts{grid-template-columns:1fr}
}
@media(max-width:900px){
  :root{--sidebar-w:0px}
  .sidebar{transform:translateX(-100%)}
  .sidebar.open{transform:translateX(0);--sidebar-w:230px}
  .main{margin-left:0}
  .kpi-strip{grid-template-columns:repeat(2,1fr)}
  .tb-center{display:none}
  .detail-panel{width:100%}
  .cmp-kpis{grid-template-columns:1fr}
  .ng{grid-template-columns:1fr}
}
@media(max-width:600px){
  .kpi-strip{grid-template-columns:1fr 1fr}
  .dp-kpis{grid-template-columns:1fr 1fr}
  .login-left{display:none}
  .page{padding:16px}
}

/* ══ TOGGLE SWITCH ═══════════════════════════════════ */
.toggle-wrap{position:relative;display:inline-block;width:36px;height:20px}
.toggle-inp{opacity:0;width:0;height:0;position:absolute}
.toggle-lbl{position:absolute;cursor:pointer;inset:0;background:var(--border-mid);border-radius:20px;transition:background 0.2s}
.toggle-lbl::before{content:'';position:absolute;width:14px;height:14px;left:3px;top:3px;background:#fff;border-radius:50%;transition:transform 0.2s}
.toggle-inp:checked + .toggle-lbl{background:var(--brand)}
.toggle-inp:checked + .toggle-lbl::before{transform:translateX(16px)}

/* ══ GLOBAL SEARCH ═══════════════════════════════════ */
.gsearch-wrap{position:relative}
.gsearch-box{display:flex;align-items:center;gap:7px;padding:6px 12px;background:var(--bg);border:1.5px solid var(--border);border-radius:var(--r-sm);cursor:pointer;font-size:12px;color:var(--text-3);min-width:160px;transition:border-color 0.15s}
.gsearch-box:hover{border-color:var(--brand)}
.gsearch-box i{font-size:15px}
.gsearch-dropdown{position:absolute;top:calc(100% + 6px);right:0;width:300px;background:var(--surface);border:1.5px solid var(--border);border-radius:var(--r-md);box-shadow:var(--shadow-lg);z-index:500;overflow:hidden}
.gsd-input-wrap{display:flex;align-items:center;gap:8px;padding:10px 12px;border-bottom:1px solid var(--border)}
.gsd-input-wrap i{font-size:16px;color:var(--text-4)}
.gsd-input-wrap input{border:none;background:transparent;font-size:13px;color:var(--text);width:100%;outline:none}
.gsd-results{max-height:260px;overflow-y:auto}
.gsd-item{padding:10px 14px;font-size:13px;color:var(--text);cursor:pointer;border-bottom:1px solid var(--border);transition:background 0.1s;display:flex;align-items:center;gap:10px}
.gsd-item:last-child{border-bottom:none}
.gsd-item:hover{background:var(--brand-light);color:var(--brand)}
.gsd-item-icon{width:28px;height:28px;border-radius:6px;background:var(--bg);display:flex;align-items:center;justify-content:center;font-size:13px;font-weight:700;color:var(--brand);flex-shrink:0}
.gsd-item-name{font-weight:500}
.gsd-item-asset{font-size:11px;color:var(--text-3);display:block}

/* ══ CLIENT VIEW ══════════════════════════════════════ */
.client-header{background:var(--surface);border-bottom:1.5px solid var(--border);padding:20px 24px 0;margin:-24px -24px 20px}
.client-name-big{font-size:36px;font-weight:300;letter-spacing:-1px;margin-bottom:16px;color:var(--text)}
.client-name-big span{color:var(--brand);font-weight:600}
.client-meta-row{display:flex;align-items:center;gap:10px;padding-bottom:14px}

.outlet-icons{display:flex;flex-wrap:wrap;gap:10px;padding-top:4px}
.outlet-icon-item{width:52px;height:52px;border-radius:50%;background:var(--bg);border:2px solid var(--border);display:flex;align-items:center;justify-content:center;font-size:10px;font-weight:700;color:var(--text-2);cursor:pointer;overflow:hidden;transition:border-color 0.15s;flex-shrink:0}
.outlet-icon-item:hover{border-color:var(--brand)}
.outlet-icon-item img{width:100%;height:100%;object-fit:cover;border-radius:50%}

.client-kpi-strip{display:grid;grid-template-columns:repeat(5,1fr);gap:12px;margin-bottom:14px}
.ckpi{background:var(--surface);border:1.5px solid var(--border);border-radius:var(--r-lg);padding:14px 16px;text-align:center;box-shadow:var(--shadow-xs)}
.ckpi-icon{font-size:20px;color:var(--brand);margin-bottom:6px}
.ckpi-val{font-size:20px;font-weight:500;letter-spacing:-0.5px;font-variant-numeric:tabular-nums}
.ckpi-lbl{font-size:11px;color:var(--text-3);margin-top:3px}

/* ══ DAY-WISE TABLE ═══════════════════════════════════ */
.dw-th{background:#F0EEF8!important;color:#534AB7!important;font-weight:600}

/* ══ OUTLET DETAIL PAGE ═══════════════════════════════ */
.od-topbar{display:flex;align-items:center;gap:12px;margin-bottom:16px;padding-bottom:16px;border-bottom:1.5px solid var(--border)}
.od-outlet-tabs{display:flex;gap:4px;background:var(--bg);border-radius:var(--r-sm);padding:3px;border:1px solid var(--border)}
.od-tab{display:flex;align-items:center;gap:6px;padding:6px 14px;border-radius:var(--r-xs);font-size:12px;font-weight:500;color:var(--text-3);background:transparent;border:none;cursor:pointer;transition:all 0.15s}
.od-tab:hover{color:var(--text)}
.od-tab.active{background:var(--surface);color:var(--brand);box-shadow:var(--shadow-xs)}
.od-tab-content{animation:fadeUp 0.2s ease}

.od-meta-card{margin-bottom:14px;display:flex;align-items:flex-start;justify-content:space-between;gap:24px}
.od-outlet-name{font-size:18px;font-weight:600;letter-spacing:-0.3px;margin-bottom:12px}
.od-meta-grid{display:grid;grid-template-columns:auto 1fr;gap:4px 16px;font-size:13px}
.od-meta-grid .lbl{color:var(--text-3);font-weight:500}
.od-meta-grid .val{color:var(--text)}
.od-meta-right{text-align:right;flex-shrink:0}
.od-meta-info{font-size:12px;color:var(--text-3);line-height:1.9;margin-bottom:12px}
.od-meta-info .status-online{color:var(--green);font-weight:600}
.od-overall{text-align:right}
.od-overall-val{font-size:24px;font-weight:500;letter-spacing:-0.5px;font-variant-numeric:tabular-nums;color:var(--text)}

.od-kpi-strip{display:grid;grid-template-columns:repeat(6,1fr);gap:10px;margin-bottom:14px}
.od-kpi{background:var(--surface);border:1.5px solid var(--border);border-radius:var(--r-md);padding:12px 14px;box-shadow:var(--shadow-xs)}
.od-kpi .lbl{font-size:10px;color:var(--text-3);margin-bottom:5px;display:flex;align-items:center;gap:5px}
.od-kpi .lbl i{font-size:14px;color:var(--brand)}
.od-kpi .val{font-size:16px;font-weight:500;letter-spacing:-0.3px;font-variant-numeric:tabular-nums}
.od-kpi .sub{font-size:11px;color:var(--text-3);margin-top:2px}

.od-metrics-row{display:grid;grid-template-columns:repeat(4,1fr);gap:12px;margin-bottom:14px}
.od-metric{background:var(--surface);border:1.5px solid var(--border);border-radius:var(--r-lg);padding:16px;display:flex;align-items:center;gap:14px}
.od-metric-donut{position:relative;flex-shrink:0}
.od-metric-txt .lbl{font-size:11px;color:var(--text-3);margin-bottom:4px}
.od-metric-txt .val{font-size:18px;font-weight:500;letter-spacing:-0.3px}
.od-metric-txt .sub{font-size:11px;color:var(--text-3);margin-top:2px}

/* ══ REPORTS FORM ═════════════════════════════════════ */
.reports-form{padding:4px 0}
.rf-row{display:grid;grid-template-columns:repeat(3,1fr);gap:14px;margin-bottom:14px}
.rf-group label{display:block;font-size:12px;font-weight:500;color:var(--text-3);margin-bottom:6px}

/* ══ SALES UPLOAD ═════════════════════════════════════ */
.upload-area{border:2px dashed var(--border-mid);border-radius:var(--r-md);padding:48px 24px;text-align:center;margin:8px 0 20px;transition:border-color 0.15s}
.upload-area:hover{border-color:var(--brand);background:var(--brand-light)}
.upload-icon{font-size:48px;color:var(--text-4);margin-bottom:12px}
.upload-icon i{font-size:48px}
.upload-title{font-size:16px;font-weight:500;margin-bottom:6px}
.upload-sub{font-size:13px;color:var(--text-3)}
.upload-formats{font-size:11px;color:var(--text-4);margin-top:12px}
.upload-log-title{font-size:13px;font-weight:600;margin-bottom:10px;padding-top:4px;border-top:1px solid var(--border)}

/* ══ ADD ASSET SIDE PANEL ════════════════════════════ */
.side-panel{position:fixed;top:0;right:0;bottom:0;width:380px;background:var(--surface);border-left:1.5px solid var(--border);z-index:600;display:flex;flex-direction:column;box-shadow:var(--shadow-lg);animation:slideR 0.25s ease}
.panel-overlay{position:fixed;inset:0;background:rgba(0,0,0,0.3);z-index:599;backdrop-filter:blur(1px)}
.sp-hd{display:flex;align-items:center;justify-content:space-between;padding:18px 20px;border-bottom:1.5px solid var(--border)}
.sp-title{font-size:16px;font-weight:600}
.sp-body{flex:1;padding:20px;overflow-y:auto;display:flex;flex-direction:column;gap:14px}
.sp-foot{padding:14px 20px;border-top:1.5px solid var(--border);display:flex;justify-content:flex-end;gap:8px}

/* ══ CHART CONTAINMENT — CRITICAL ════════════════════ */
/* Every chart canvas MUST stay inside its parent box */
.chart-box {
  position: relative !important;
  width: 100% !important;
  overflow: hidden !important;
  /* height is set inline on each chart-box div */
}
.chart-box canvas {
  position: absolute !important;
  top: 0 !important;
  left: 0 !important;
  width: 100% !important;
  height: 100% !important;
  max-width: 100% !important;
  max-height: 100% !important;
}

/* Card overflow protection */
.card { overflow: hidden; }

/* Table overflow — never let tables break out */
.tbl-wrap { overflow-x: auto; overflow-y: visible; max-width: 100%; }
.tbl { table-layout: auto; word-break: break-word; }
.tbl td, .tbl th { overflow: hidden; text-overflow: ellipsis; max-width: 220px; white-space: nowrap; }
.tbl td:first-child, .tbl th:first-child { white-space: nowrap; }

/* Page content never overflows viewport */
.pcontent { overflow-x: hidden; overflow-y: auto; max-width: 100%; }
.page { max-width: 100%; overflow-x: hidden; background: var(--bg); color: var(--text); min-height: 100%; }

/* Grid children don't escape */
.dg1, .dg2, .ang, .kpi-strip, .od-kpi-strip, .client-kpi-strip, .od-metrics-row {
  min-width: 0;
}
.dg1 > *, .dg2 > *, .ang > * { min-width: 0; overflow: hidden; }

/* Daywise table — constrain columns */
#daywise-tbl { table-layout: fixed; width: 100%; }
#daywise-tbl th, #daywise-tbl td {
  overflow: hidden; text-overflow: ellipsis;
  white-space: nowrap; padding: 8px 10px;
}

/* ══ DARK MODE ════════════════════════════════════════ */
body.dark {
  --bg: #0F0F0E;
  --surface: #1C1917;
  --surface-2: #211F1D;
  --border: #2C2A27;
  --border-mid: #3D3A36;
  --text: #F5F4F2;
  --text-2: #D6D3CF;
  --text-3: #A8A29E;
  --text-4: #6B6864;
  --brand-light: #2A1A12;
  --green-bg: #0D2818;
  --red-bg: #2A1010;
  --amber-bg: #2A1D08;
  --blue-bg: #0D1A2A;
}
body.dark .login-right { background: #1C1917; }
body.dark .lform-hd h2 { color: var(--text); }
body.dark .finput { background: var(--surface-2); color: var(--text); border-color: var(--border); }
body.dark .finput:focus { border-color: var(--brand); }
body.dark .sidebar { background: var(--surface); border-color: var(--border); }
body.dark .topbar { background: var(--surface); border-color: var(--border); }
body.dark .card { background: var(--surface); border-color: var(--border); }
body.dark .kpicard { background: var(--surface); border-color: var(--border); }
body.dark .tbl-wrap { background: var(--surface); border-color: var(--border); }
body.dark .tbl th { background: var(--surface-2); color: var(--text-3); }
body.dark .tbl td { color: var(--text); border-color: var(--border); }
body.dark .tbl tr:hover td { background: rgba(232,69,10,0.06); }
body.dark .modal { background: var(--surface); border-color: var(--border); }
body.dark .mhd { border-color: var(--border); }
body.dark .mfoot { border-color: var(--border); }
body.dark .btn-o { background: var(--surface-2); color: var(--text-2); border-color: var(--border); }
body.dark .btn-o:hover { background: var(--border); }
body.dark .apills { background: var(--surface-2); border-color: var(--border); }
body.dark .apill { color: var(--text-3); }
body.dark .apill.active { background: var(--surface); color: var(--brand); }
body.dark .gsearch-box { background: var(--surface-2); border-color: var(--border); color: var(--text-3); }
body.dark .gsearch-dropdown { background: var(--surface); border-color: var(--border); }
body.dark .gsd-item { border-color: var(--border); color: var(--text); }
body.dark .gsd-item:hover { background: var(--brand-light); }
body.dark .sb-client { background: var(--surface-2); border-color: var(--border); }
body.dark .nitem:hover { background: var(--surface-2); }
body.dark .nitem.active { background: var(--brand-light); }
body.dark .aitem { background: var(--surface-2); border-color: var(--border); }
body.dark .alert-item { background: var(--surface-2); }
body.dark .sbox { background: var(--surface); border-color: var(--border); }
body.dark .sbox input { color: var(--text); }
body.dark .fpill { background: var(--surface); border-color: var(--border); color: var(--text-3); }
body.dark .mini-sel { background: var(--surface-2); border-color: var(--border); color: var(--text-3); }
body.dark .acard { background: var(--surface); border-color: var(--border); }
body.dark .rolecard { background: var(--surface); border-color: var(--border); }
body.dark .cmp-grp { background: var(--surface); border-color: var(--border); }
body.dark .dp-kpi { background: var(--surface); border-color: var(--border); }
body.dark .detail-panel { background: var(--bg); border-color: var(--border); }
body.dark .dp-topbar { background: var(--surface); border-color: var(--border); }
body.dark .od-meta-card { background: var(--surface); }
body.dark .od-kpi { background: var(--surface); border-color: var(--border); }
body.dark .od-metric { background: var(--surface); border-color: var(--border); }
body.dark .client-header { background: var(--surface); border-color: var(--border); }
body.dark .ckpi { background: var(--surface); border-color: var(--border); }
body.dark .outlet-icon-item { background: var(--surface-2); border-color: var(--border); }
body.dark .eprev { border-color: var(--border); }
body.dark .ep-body { background: var(--surface-2); }
body.dark .epk { background: var(--surface); border-color: var(--border); }
body.dark .ept { background: var(--surface); border-color: var(--border); }
body.dark .side-panel { background: var(--surface); border-color: var(--border); }
body.dark .sp-hd { border-color: var(--border); }
body.dark .sp-foot { border-color: var(--border); }
body.dark .upload-area { border-color: var(--border-mid); }
body.dark .etags { border-color: var(--border); background: var(--surface-2); }
body.dark .sync-ind { background: var(--surface-2); border-color: var(--border); }
body.dark .od-outlet-tabs { background: var(--surface-2); border-color: var(--border); }
body.dark .od-tab.active { background: var(--surface); }
body.dark .toggle-lbl { background: var(--border-mid); }
body.dark .chat-panel { background: var(--surface); border-color: var(--border); }
body.dark .chat-header { background: var(--surface-2); border-color: var(--border); }
body.dark .chat-bubble.bot-bubble { background: var(--surface-2); border-color: var(--border); color: var(--text); }
body.dark .chat-input-row { background: var(--surface-2); border-color: var(--border); }
body.dark .chat-input { background: transparent; color: var(--text); }
body.dark .chat-sug { background: var(--surface-2); border-color: var(--border); color: var(--text-3); }
body.dark .chat-data-card { background: var(--surface-2); border-color: var(--border); }
body.dark .exp-fmt-card { background: var(--surface-2); border-color: var(--border); color: var(--text-2); }
body.dark .exp-fmt-card:hover { background: var(--brand-light); border-color: var(--brand); }

/* Status badges/tags that hardcode light-mode colors elsewhere in this
   file — without these, they stay bright light-mode chips on a dark page. */
body.dark .tag-closed { background: var(--surface-2); color: var(--text-3); }
body.dark .tag-nofeed { background: var(--surface-2); color: var(--text-3); border-color: var(--border); }
body.dark .dw-th { background: var(--surface-2) !important; color: var(--text-2) !important; }
body.dark .lease-chip.expired { background: var(--red-bg); color: #FCA5A5; }
body.dark .lease-chip.expiring { background: var(--amber-bg); color: #FCD34D; }
body.dark .lease-status-badge.critical { background: var(--red-bg); color: #FCA5A5; }
body.dark .lease-status-badge.expired { background: var(--surface-2); color: var(--text-3); }
body.dark .rs-status.no-contract { background: var(--surface-2); color: var(--text-3); }
body.dark .rs-calc-table .rs-calc-total td { color: #B8B3F5; }
body.dark .hs-anchor   { background: rgba(46,125,50,0.2);  color: #66BB6A; }
body.dark .hs-healthy  { background: rgba(47,158,68,0.2);  color: #69DB7C; }
body.dark .hs-stable   { background: rgba(59,91,219,0.2);  color: #8CA0F5; }
body.dark .hs-watch    { background: rgba(245,159,0,0.2);  color: #FFD43B; }
body.dark .hs-at-risk  { background: rgba(230,81,0,0.2);   color: #FFA94D; }
body.dark .hs-critical { background: rgba(224,49,49,0.2);  color: #FF8787; }

/* Dark mode chart grid + tooltip already handled in JS */

/* ══ CHATBOT ══════════════════════════════════════════ */
.chat-fab {
  position: fixed; bottom: 28px; right: 28px;
  width: 52px; height: 52px;
  background: var(--brand); color: #fff;
  border-radius: 50%; display: flex; align-items: center; justify-content: center;
  font-size: 22px; cursor: pointer; z-index: 400;
  box-shadow: 0 4px 16px rgba(232,69,10,0.4);
  transition: transform 0.2s, box-shadow 0.2s;
}
.chat-fab:hover { transform: scale(1.08); box-shadow: 0 6px 24px rgba(232,69,10,0.5); }

.chat-panel {
  position: fixed; bottom: 92px; right: 28px;
  width: 380px; height: 560px;
  background: var(--surface); border: 1.5px solid var(--border);
  border-radius: var(--r-lg); box-shadow: var(--shadow-lg);
  display: flex; flex-direction: column; z-index: 400;
  animation: fadeUp 0.2s ease;
  overflow: hidden;
}
.chat-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px; border-bottom: 1.5px solid var(--border);
  background: var(--surface-2);
}
.chat-header-left { display: flex; align-items: center; gap: 10px; }
.chat-avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--brand-light); color: var(--brand);
  display: flex; align-items: center; justify-content: center; font-size: 16px;
}
.chat-title { font-size: 13px; font-weight: 600; }
.chat-subtitle { font-size: 11px; color: var(--text-3); }
.chat-messages {
  flex: 1; overflow-y: auto; padding: 14px;
  display: flex; flex-direction: column; gap: 10px;
}
.chat-msg { display: flex; flex-direction: column; }
.chat-msg.user { align-items: flex-end; }
.chat-msg.bot { align-items: flex-start; }
.chat-bubble {
  max-width: 88%; padding: 10px 13px;
  border-radius: 12px; font-size: 13px; line-height: 1.5;
}
.bot-bubble {
  background: var(--bg); border: 1px solid var(--border);
  color: var(--text); border-radius: 4px 12px 12px 12px;
}
.user-bubble {
  background: var(--brand); color: #fff;
  border-radius: 12px 4px 12px 12px;
}
.chat-suggestions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.chat-sug {
  padding: 5px 10px; border-radius: 16px; font-size: 11px; font-weight: 500;
  border: 1px solid var(--border); background: var(--bg); color: var(--text-3);
  cursor: pointer; transition: all 0.12s;
}
.chat-sug:hover { border-color: var(--brand); color: var(--brand); }

.chat-data-card {
  background: var(--bg); border: 1px solid var(--border);
  border-radius: var(--r-sm); padding: 10px 12px; margin-top: 6px;
  font-size: 12px; width: 100%; max-width: 320px;
}
.chat-data-card .cd-title { font-size: 11px; font-weight: 700; color: var(--text-3); margin-bottom: 8px; letter-spacing: 0.3px; text-transform: uppercase; }
.chat-data-row { display: flex; justify-content: space-between; align-items: center; padding: 5px 0; border-bottom: 1px solid var(--border); }
.chat-data-row:last-child { border-bottom: none; }
.chat-data-name { color: var(--text-2); flex: 1; }
.chat-data-val { font-weight: 600; color: var(--text); }
.chat-data-badge { padding: 2px 6px; border-radius: 8px; font-size: 10px; font-weight: 600; }
.chat-typing { display: flex; align-items: center; gap: 4px; padding: 10px 13px; }
.chat-typing span { width: 6px; height: 6px; border-radius: 50%; background: var(--text-4); animation: chatDot 1.2s infinite; }
.chat-typing span:nth-child(2) { animation-delay: 0.2s; }
.chat-typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes chatDot { 0%,60%,100%{transform:none;opacity:0.4} 30%{transform:translateY(-4px);opacity:1} }

.chat-input-row {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 14px; border-top: 1.5px solid var(--border);
  background: var(--surface-2);
}
.chat-input {
  flex: 1; border: none; background: transparent;
  font-size: 13px; color: var(--text); outline: none;
}
.chat-send-btn {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--brand); color: #fff; border: none;
  display: flex; align-items: center; justify-content: center;
  font-size: 15px; cursor: pointer; flex-shrink: 0;
  transition: background 0.15s;
}
.chat-send-btn:hover { background: var(--brand-hover); }

/* ══ EXPORT MODAL GRID ═══════════════════════════════ */
.export-format-grid {
  display: grid; grid-template-columns: repeat(3,1fr); gap: 10px; margin-top: 4px;
}
.exp-fmt-card {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 16px 10px; border: 1.5px solid var(--border);
  border-radius: var(--r-md); cursor: pointer; transition: all 0.15s;
  background: var(--bg);
}
.exp-fmt-card i { font-size: 28px; color: var(--brand); }
.exp-fmt-card span { font-size: 13px; font-weight: 600; }
.exp-fmt-card small { font-size: 10px; color: var(--text-3); text-align: center; }
.exp-fmt-card:hover { border-color: var(--brand); background: var(--brand-light); }
.exp-fmt-card.selected { border-color: var(--brand); background: var(--brand-light); }

/* ══ COLLAPSE SIDEBAR ════════════════════════════════ */
.sidebar.collapsed { transform: translateX(-100%); }
.main.expanded { margin-left: 0; }
.collapse-btn { transition: transform 0.2s; }

/* ══ REPORT ENGINE STYLES ════════════════════════════ */
.rpt-section-hd {
  display: flex; align-items: center; justify-content: space-between;
  padding-bottom: 12px; border-bottom: 1px solid var(--border); margin-bottom: 14px;
}

/* Alert block */
.rpt-alert-block {
  background: var(--amber-bg); border: 1px solid #F59E0B;
  border-radius: var(--r-sm); padding: 10px 14px; margin-bottom: 12px;
}
.rpt-alert-title {
  font-size: 11px; font-weight: 700; color: #92400E;
  margin-bottom: 6px; display: flex; align-items: center; gap: 6px;
  text-transform: uppercase; letter-spacing: 0.4px;
}
.rpt-alert-row {
  display: flex; align-items: center; gap: 8px;
  font-size: 12px; color: #78350F; padding: 3px 0;
  border-bottom: 1px solid rgba(245,158,11,0.2);
}
.rpt-alert-row:last-child { border-bottom: none; }
.rpt-alert-dot {
  width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0;
}
.rpt-alert-dot.red   { background: var(--red); }
.rpt-alert-dot.amber { background: var(--amber); }
.rpt-alert-status {
  margin-left: auto; font-size: 11px; font-weight: 600; color: var(--amber);
}

/* KPI row in report */
.rpt-kpi-row {
  display: grid; grid-template-columns: repeat(4, 1fr);
  gap: 10px; margin-bottom: 14px;
}
.rpt-kpi {
  background: var(--surface); border: 1.5px solid var(--border);
  border-radius: var(--r-sm); padding: 12px 14px;
  border-left: 3px solid var(--brand);
}
.rpt-kpi-lbl {
  font-size: 10px; text-transform: uppercase; letter-spacing: 0.5px;
  color: var(--text-3); margin-bottom: 4px;
}
.rpt-kpi-val { font-size: 16px; font-weight: 600; color: var(--text); }
.rpt-kpi-delta { font-size: 11px; margin-top: 3px; font-weight: 500; }
.rpt-kpi-delta.up { color: var(--green); }
.rpt-kpi-delta.dn { color: var(--red); }

/* Status dots in table */
.rpt-dot {
  display: inline-block; width: 7px; height: 7px;
  border-radius: 50%; margin-right: 5px; flex-shrink: 0;
}
.rpt-dot.green  { background: var(--green); }
.rpt-dot.red    { background: var(--red); }
.rpt-dot.amber  { background: var(--amber); }

/* Report asset selector in form — .rf-row / .rf-group label already
   defined above (line ~644), not repeated here. */

/* Dark mode report */
body.dark .rpt-alert-block { background: rgba(245,158,11,0.1); border-color: rgba(245,158,11,0.3); }
body.dark .rpt-alert-title { color: #FCD34D; }
body.dark .rpt-alert-row   { color: #FDE68A; }
body.dark .rpt-kpi { background: var(--surface-2); border-color: var(--border); }

/* ══ LEASE TRACKER ════════════════════════════════════ */
.lease-alert-strip { display:flex; flex-direction:column; gap:8px; margin-bottom:16px; }
.lease-alert {
  display:flex; align-items:center; flex-wrap:wrap; gap:8px;
  padding:10px 14px; border-radius:var(--r-sm); font-size:13px;
}
.lease-alert i { font-size:16px; flex-shrink:0; }
.lease-alert.red    { background:var(--red-bg);   color:#7F1D1D; border:1px solid #FECACA; }
.lease-alert.amber  { background:var(--amber-bg); color:#78350F; border:1px solid #FDE68A; }
.lease-alert.green  { background:var(--green-bg); color:#14532D; border:1px solid #BBF7D0; }
.lease-chip {
  padding:2px 8px; border-radius:10px; font-size:11px; font-weight:600;
}
.lease-chip.expired  { background:#FEE2E2; color:#991B1B; }
.lease-chip.expiring { background:#FEF3C7; color:#92400E; }
.lease-status-badge {
  display:inline-block; padding:3px 9px; border-radius:10px;
  font-size:11px; font-weight:600;
}
.lease-status-badge.active   { background:var(--green-bg); color:#14532D; }
.lease-status-badge.warning  { background:var(--amber-bg); color:#78350F; }
.lease-status-badge.critical { background:#FEE2E2;         color:#991B1B; }
.lease-status-badge.expired  { background:#F5F5F4;         color:#57534E; }

/* ══ OFFLINE TRACKER ══════════════════════════════════ */
.offline-sum-grid {
  display:grid; grid-template-columns:repeat(4,1fr);
  gap:12px; margin-bottom:16px;
}
.offline-sum-card {
  border-radius:var(--r-lg); padding:16px;
  border:1.5px solid var(--border);
}
.offline-sum-card.red     { background:var(--red-bg);   border-color:#FECACA; }
.offline-sum-card.amber   { background:var(--amber-bg); border-color:#FDE68A; }
.offline-sum-card.blue    { background:var(--blue-bg);  border-color:#BFDBFE; }
.offline-sum-card.neutral { background:var(--bg);       border-color:var(--border); }
.osc-num { font-size:28px; font-weight:600; letter-spacing:-0.5px; }
.offline-sum-card.red   .osc-num { color:var(--red); }
.offline-sum-card.amber .osc-num { color:var(--amber); }
.offline-sum-card.blue  .osc-num { color:var(--blue); }
.osc-lbl { font-size:13px; font-weight:500; margin-top:4px; }
.osc-sub { font-size:11px; color:var(--text-3); margin-top:2px; }

/* Dark mode lease + offline */
body.dark .lease-alert.red    { background:rgba(220,38,38,0.15);  border-color:rgba(220,38,38,0.3); }
body.dark .lease-alert.amber  { background:rgba(217,119,6,0.15);  border-color:rgba(217,119,6,0.3); }
body.dark .lease-alert.green  { background:rgba(22,163,74,0.15);  border-color:rgba(22,163,74,0.3); }
body.dark .offline-sum-card   { background:var(--surface-2); }

/* ══ OUTLETS TABLE — STICKY HEADER ══════════════════ */
/* Height itself is set once, later, by "CORRECT TABLE CONTAINMENT" below —
   this rule only owns border/position so the two don't fight over height. */
#page-outlets .tbl-wrap {
  border: 1.5px solid var(--border);
  border-radius: var(--r-lg);
  position: relative;
}

#page-outlets .tbl thead {
  position: sticky;
  top: 0;
  z-index: 10;
}

#page-outlets .tbl thead th {
  position: sticky;
  top: 0;
  background: var(--surface-2);
  box-shadow: 0 1px 0 var(--border);
  z-index: 10;
}

/* Keep first column sticky horizontally too */
#page-outlets .tbl thead th:first-child,
#page-outlets .tbl tbody td:first-child {
  position: sticky;
  left: 0;
  z-index: 9;
  background: var(--surface);
}
#page-outlets .tbl thead th:first-child {
  background: var(--surface-2);
  z-index: 11;
}

#page-outlets .tbl tbody tr:hover td:first-child {
  background: rgba(232,69,10,0.04);
}

/* Dark mode sticky cells */
body.dark #page-outlets .tbl thead th {
  background: var(--surface-2);
}
body.dark #page-outlets .tbl thead th:first-child {
  background: var(--surface-2);
}
body.dark #page-outlets .tbl tbody td:first-child {
  background: var(--surface);
}
body.dark #page-outlets .tbl tbody tr:hover td:first-child {
  background: rgba(232,69,10,0.06);
}

/* Scrollbar styling for the table */
#page-outlets .tbl-wrap::-webkit-scrollbar { width: 6px; height: 6px; }
#page-outlets .tbl-wrap::-webkit-scrollbar-track { background: var(--bg); }
#page-outlets .tbl-wrap::-webkit-scrollbar-thumb { background: var(--border-mid); border-radius: 3px; }
#page-outlets .tbl-wrap::-webkit-scrollbar-corner { background: var(--bg); }



/* Make table rows uniform height */
#page-outlets .tbl td { 
  padding: 10px 14px; 
  white-space: nowrap;
}
#page-outlets .tbl th {
  white-space: nowrap;
  padding: 10px 14px;
}

/* ══ GLOBAL STICKY HEADERS + CONTAINED TABLE SCROLL ══ */
/* Applied to ALL tbl-wrap instances across the app      */

/* Base rule — every tbl-wrap gets sticky thead */
.tbl-wrap {
  overflow-x: auto;
  overflow-y: auto;
  position: relative;
  border-radius: var(--r-lg);
  border: 1.5px solid var(--border);
}

.tbl thead th {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--surface-2);
  box-shadow: 0 1px 0 var(--border);
  white-space: nowrap;
}

body.dark .tbl thead th {
  background: var(--surface-2);
}

/* ── PAGE-SPECIFIC MAX HEIGHTS ─────────────────────── */


/* Notifications — email log */
#page-notifications .tbl-wrap {
  max-height: 320px;
}

/* Leases page — max-height is set once, later, by "CORRECT TABLE
   CONTAINMENT" below; the value here was a superseded duplicate. */

/* Reports — day-wise breakdown */
#od-tab-reports .tbl-wrap,
#page-outlet-detail .tbl-wrap {
  max-height: 480px;
}

/* Client view — daywise table */
#page-client .tbl-wrap {
  max-height: 480px;
}

/* Upload log */
#upload-log {
  max-height: 280px;
  overflow-y: auto;
}

/* Dashboard mini table — no fixed height, just sticky */
#dash-tbl thead th {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--surface-2);
  box-shadow: 0 1px 0 var(--border);
}
body.dark #dash-tbl thead th {
  background: var(--surface-2);
}

/* Inline report results table */
#rpt-results .tbl-wrap {
  max-height: 500px;
  overflow-y: auto;
  overflow-x: auto;
}

/* ── FIRST COLUMN STICKY (name columns) ────────────── */
#page-users .tbl tbody td:first-child,
#page-leases .tbl tbody td:first-child,
#page-offline .tbl tbody td:first-child {
  position: sticky;
  left: 0;
  background: var(--surface);
  z-index: 5;
}
#page-users .tbl thead th:first-child,
#page-leases .tbl thead th:first-child,
#page-offline .tbl thead th:first-child {
  position: sticky;
  left: 0;
  z-index: 11;
  background: var(--surface-2);
}
body.dark #page-users .tbl tbody td:first-child,
body.dark #page-leases .tbl tbody td:first-child,
body.dark #page-offline .tbl tbody td:first-child {
  background: var(--surface);
}
body.dark #page-users .tbl thead th:first-child,
body.dark #page-leases .tbl thead th:first-child,
body.dark #page-offline .tbl thead th:first-child {
  background: var(--surface-2);
}

/* ── SCROLLBAR CONSISTENCY ─────────────────────────── */
.tbl-wrap::-webkit-scrollbar { width: 6px; height: 6px; }
.tbl-wrap::-webkit-scrollbar-track { background: var(--bg); }
.tbl-wrap::-webkit-scrollbar-thumb { background: var(--border-mid); border-radius: 3px; }
.tbl-wrap::-webkit-scrollbar-corner { background: var(--bg); }







/* ══ CORRECT TABLE CONTAINMENT — ALL PAGES ═══════════ */
/* Approach: fixed max-height on tbl-wrap, page scrolls  */
/* normally. No flex hacks that clip page content.        */

/* Outlets — tall table, most data */
#page-outlets .tbl-wrap {
  max-height: calc(100vh - 230px);
  overflow-y: auto;
  overflow-x: auto;
}

/* Users */
#page-users .tbl-wrap {
  max-height: calc(100vh - 200px);
  overflow-y: auto;
}

/* Leases */
#page-leases .tbl-wrap {
  max-height: calc(100vh - 320px);
  overflow-y: auto;
  overflow-x: auto;
}



/* Notifications email log */
#page-notifications .card .tbl-wrap {
  max-height: 300px;
  overflow-y: auto;
}



/* Client view daywise */
#page-client .card div[style*="overflow-x"] {
  max-height: 480px;
}

/* Outlet detail reports */
#od-tab-reports .card .tbl-wrap {
  max-height: 460px;
  overflow-y: auto;
  overflow-x: auto;
}

/* ══ ROLES + OFFLINE — SAFE RULES ONLY ══════════════ */

/* Roles page — simple, no overflow tricks */
#page-roles {
  background: var(--bg);
}
/* .rolegrid / .rolecard layout is already defined above (line ~455) —
   not repeated here. */

/* Offline tracker — table scroll only, page normal */
#page-offline {
  background: var(--bg);
}
#page-offline .tbl-wrap {
  max-height: 480px;
  overflow-y: auto;
  overflow-x: auto;
}

/* Assets page — normal scroll */
#page-assets {
  background: var(--bg);
}
/* #agrid's actual layout (flex column of city sections) is defined once,
   later, under "ASSETS PAGE — FIXED LAYOUT" — a superseded grid-display
   rule used to live here and was always overridden. */

/* Dark mode explicit backgrounds to prevent black */
body.dark #page-roles,
body.dark #page-offline,
body.dark #page-assets,
body.dark #page-users,
body.dark #page-leases,
body.dark #page-notifications,
body.dark #page-analytics,
body.dark #page-dashboard,
body.dark #page-outlets,
body.dark #page-client,
body.dark #page-outlet-detail {
  background: var(--bg);
  color: var(--text);
}

/* ══ ASSETS PAGE — FIXED LAYOUT ══════════════════════ */
#agrid {
  display: flex;
  flex-direction: column;
  gap: 24px;
}
.asset-city-section {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.asset-city-heading {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-3);
  letter-spacing: 0.2px;
  padding: 0;
  margin: 0;
}
.asset-cards-row {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
}

/* ══ BLACK PAGE FIX — FORCE ALL PAGES VISIBLE ════════ */
/* Belt-and-suspenders: every page gets bg + color */
#page-roles.active,
#page-offline.active,
#page-leases.active,
#page-users.active,
#page-assets.active,
#page-notifications.active,
#page-analytics.active,
#page-dashboard.active,
#page-outlets.active,
#page-client.active,
#page-outlet-detail.active {
  background: var(--bg) !important;
  color: var(--text) !important;
  display: block !important;
}

/* Offline page content visible */
#page-offline .offline-sum-grid {
  display: grid;
  grid-template-columns: repeat(4,1fr);
  gap: 12px;
  margin-bottom: 16px;
}

/* ══ CLIENT PAGE TABS (Overview / Revenue Share) ═════ */
.client-page-tabs {
  display: flex; gap: 4px;
  background: var(--bg); border-radius: var(--r-sm);
  padding: 3px; border: 1px solid var(--border);
}
.client-tab {
  display: flex; align-items: center; gap: 6px;
  padding: 6px 14px; border-radius: var(--r-xs);
  font-size: 12px; font-weight: 500; color: var(--text-3);
  background: transparent; border: none; cursor: pointer;
  transition: all 0.15s;
}
.client-tab:hover { color: var(--text); }
.client-tab.active {
  background: var(--surface); color: var(--brand);
  box-shadow: var(--shadow-xs);
}
.client-tab-content { animation: fadeUp 0.2s ease; }

/* ══ REVENUE SHARE MODULE ════════════════════════════ */

/* Summary strip */
.rs-summary-strip {
  display: grid; grid-template-columns: repeat(5,1fr);
  gap: 12px; margin-bottom: 14px;
}
.rs-kpi {
  background: var(--surface); border: 1.5px solid var(--border);
  border-radius: var(--r-lg); padding: 14px 16px;
  box-shadow: var(--shadow-xs);
}
.rs-kpi-lbl { font-size: 10px; text-transform: uppercase; letter-spacing: 0.5px; color: var(--text-3); margin-bottom: 5px; }
.rs-kpi-val { font-size: 20px; font-weight: 600; letter-spacing: -0.4px; font-variant-numeric: tabular-nums; }
.rs-kpi-sub { font-size: 11px; margin-top: 3px; font-weight: 500; }

/* Alert block */
.rs-alert {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px; border-radius: var(--r-sm);
  margin-bottom: 8px; font-size: 12px;
}
.rs-alert.warn { background: var(--amber-bg); border: 1px solid #F59E0B; color: #78350F; }
.rs-alert.info { background: var(--blue-bg); border: 1px solid #93C5FD; color: #1E3A8A; }
.rs-alert i { font-size: 16px; flex-shrink: 0; }

/* Table status badges */
.rs-status { display: inline-block; padding: 3px 9px; border-radius: 10px; font-size: 11px; font-weight: 600; }
.rs-status.pending   { background: var(--amber-bg); color: #78350F; }
.rs-status.approved  { background: var(--green-bg); color: #14532D; }
.rs-status.overdue   { background: var(--red-bg);   color: #7F1D1D; }
.rs-status.no-contract { background: #F5F5F4; color: #57534E; }

/* Table highlight row */
.rs-total-row td { background: #F0EEF8 !important; font-weight: 700; color: #534AB7; }
.rs-variance-warn td { background: rgba(239,158,39,0.08) !important; }
.rs-variance-err  td { background: rgba(220,38,38,0.06) !important; }

/* Statement detail card */
.rs-statement-card {
  background: var(--surface); border: 1.5px solid var(--brand);
  border-radius: var(--r-lg); padding: 20px; margin-bottom: 14px;
}
.rs-stmt-header {
  display: flex; justify-content: space-between; align-items: flex-start;
  padding-bottom: 14px; border-bottom: 1px solid var(--border); margin-bottom: 14px;
}
.rs-stmt-title { font-size: 16px; font-weight: 600; letter-spacing: -0.2px; }
.rs-stmt-meta  { font-size: 12px; color: var(--text-3); margin-top: 3px; }
.rs-calc-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.rs-calc-table td { padding: 8px 12px; border-bottom: 1px solid var(--border); }
.rs-calc-table .rs-calc-lbl { color: var(--text-3); }
.rs-calc-table .rs-calc-val { text-align: right; font-weight: 500; font-variant-numeric: tabular-nums; }
.rs-calc-table .rs-calc-total td { font-weight: 700; font-size: 14px; background: #F0EEF8; color: #534AB7; }
.rs-slab-table { width: 100%; border-collapse: collapse; font-size: 12px; margin: 10px 0; }
.rs-slab-table th { background: var(--bg); padding: 6px 10px; text-align: left; font-weight: 600; color: var(--text-3); font-size: 11px; }
.rs-slab-table td { padding: 7px 10px; border-bottom: 1px solid var(--border); }
.rs-slab-table .active-slab td { background: rgba(83,74,183,0.06); font-weight: 600; }

/* Contract setup panel */
.rs-contract-section { margin-bottom: 18px; padding-bottom: 14px; border-bottom: 1px solid var(--border); }
.rs-contract-section:last-child { border-bottom: none; }
.rs-section-title { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; color: var(--text-3); margin-bottom: 10px; }
.slab-row { display: grid; grid-template-columns: 1fr 1fr 80px 32px; gap: 8px; align-items: center; margin-bottom: 8px; }
.slab-row input, .slab-row select { padding: 7px 10px; border: 1.5px solid var(--border); border-radius: var(--r-xs); font-size: 12px; color: var(--text); background: var(--surface); width: 100%; }
.slab-row input:focus, .slab-row select:focus { border-color: var(--brand); outline: none; }
.del-slab-btn { width: 28px; height: 28px; border-radius: var(--r-xs); background: var(--red-bg); border: none; color: var(--red); cursor: pointer; display: flex; align-items: center; justify-content: center; font-size: 14px; }
.add-slab-btn { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--brand); background: none; border: none; cursor: pointer; padding: 4px 0; }
.period-row { background: var(--bg); border: 1px solid var(--border); border-radius: var(--r-sm); padding: 12px; margin-bottom: 10px; }
.period-row-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.period-label { font-size: 12px; font-weight: 600; color: var(--text); }

/* Dark mode rev share */
body.dark .rs-alert.warn { background: rgba(217,119,6,0.15); border-color: rgba(217,119,6,0.4); color: #FDE68A; }
body.dark .rs-alert.info { background: rgba(37,99,235,0.15); border-color: rgba(37,99,235,0.4); color: #BFDBFE; }
body.dark .rs-total-row td { background: rgba(83,74,183,0.2) !important; }
body.dark .rs-statement-card { background: var(--surface); }
body.dark .rs-calc-table .rs-calc-total td { background: rgba(83,74,183,0.2); }
body.dark .rs-slab-table th { background: var(--surface-2); }
body.dark .slab-row input, body.dark .slab-row select { background: var(--surface-2); border-color: var(--border); color: var(--text); }
body.dark .period-row { background: var(--surface-2); }
body.dark .client-page-tabs { background: var(--surface-2); }
body.dark .client-tab.active { background: var(--surface); }

/* ══ CLIENT SWITCHER DROPDOWN ═════════════════════════════ */
.client-dropdown {
  margin: 4px 12px; 
  background: var(--surface); border: 1.5px solid var(--border);
  border-radius: var(--r-lg); box-shadow: var(--shadow-lg);
  padding: 8px; z-index: 100;
}
.cd-title { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; color: var(--text-3); padding: 6px 8px 4px; }
.cd-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px; border-radius: var(--r-sm); cursor: pointer;
  transition: background 0.15s;
}
.cd-item:hover { background: var(--bg); }

/* ══ MALL CITY — MALL-SPECIFIC STYLES ═══════════════════ */

/* Floor selector strip */
.floor-selector {
  display: flex; gap: 4px; margin-bottom: 14px;
  background: var(--bg); border-radius: var(--r-sm);
  padding: 3px; border: 1px solid var(--border); width: fit-content;
}
.floor-pill {
  padding: 6px 14px; border-radius: var(--r-xs);
  font-size: 12px; font-weight: 600; color: var(--text-3);
  background: transparent; border: none; cursor: pointer;
  transition: all 0.15s;
}
.floor-pill:hover { color: var(--text); }
.floor-pill.active { background: #3B5BDB; color: #fff; box-shadow: var(--shadow-xs); }

/* Mall KPI strip (8 cards) */
.mall-kstrip { grid-template-columns: repeat(4, 1fr) !important; }
@media (min-width: 1200px) { .mall-kstrip { grid-template-columns: repeat(8, 1fr) !important; } }

/* Floor badge */
.floor-badge {
  display: inline-block; padding: 2px 8px; border-radius: 4px;
  font-size: 11px; font-weight: 700; letter-spacing: 0.3px;
  background: #EDF2FF; color: #3B5BDB;
}

/* Card row for charts */
.card-row { display: flex; gap: 14px; }
.card-row > .card { flex: 1; }

/* Dark mode mall */
body.dark .floor-pill.active { background: #3B5BDB; color: #fff; }
body.dark .floor-badge { background: rgba(59,91,219,0.15); color: #748FFC; }
body.dark .client-dropdown { background: var(--surface); border-color: var(--border); }
body.dark .cd-item:hover { background: var(--surface-2); }

/* ══ MALL CITY — KPI CARDS (kstrip / kcard) ════════════ */
.kstrip {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 14px;
}
@media (min-width: 1200px) {
  .kstrip { grid-template-columns: repeat(8, 1fr); }
}
.kcard {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--r-lg);
  padding: 12px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  box-shadow: var(--shadow-xs);
  min-width: 0;
}
.kcard-icon {
  width: 36px; height: 36px;
  border-radius: var(--r-sm);
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; flex-shrink: 0;
}
.kcard-body {
  display: flex; flex-direction: column;
  min-width: 0; gap: 2px;
}
.kcard-val {
  font-size: 16px; font-weight: 700;
  letter-spacing: -0.3px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.kcard-lbl {
  font-size: 10px; color: var(--text-3);
  text-transform: uppercase; letter-spacing: 0.4px;
  font-weight: 500; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis; max-width: 100%;
}
/* The mall dashboard packs 8 KPIs in a row — tighten so nothing overflows. */
.mall-kstrip .kcard { padding: 10px 11px; gap: 8px; }
.mall-kstrip .kcard-icon { width: 30px; height: 30px; font-size: 15px; }
.mall-kstrip .kcard-val { font-size: 15px; }

/* ══ MALL — STORE DETAIL PAGE ══════════════════════════ */
.store-detail-header {
  display: flex; align-items: flex-start;
  justify-content: space-between;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
}
.store-detail-name { font-size: 22px; font-weight: 700; letter-spacing: -0.4px; }
.store-detail-meta { font-size: 12px; color: var(--text-3); margin-top: 3px; }
.store-kpi-row {
  display: grid; grid-template-columns: repeat(6, 1fr);
  gap: 10px; margin-bottom: 14px;
}
.store-kpi {
  background: var(--surface); border: 1.5px solid var(--border);
  border-radius: var(--r-lg); padding: 12px 14px;
}
.store-kpi-lbl { font-size: 10px; text-transform: uppercase; letter-spacing: 0.4px; color: var(--text-3); margin-bottom: 4px; font-weight: 500; }
.store-kpi-val { font-size: 18px; font-weight: 700; letter-spacing: -0.3px; font-variant-numeric: tabular-nums; }
.store-kpi-sub { font-size: 11px; color: var(--text-3); margin-top: 2px; }
.month-perf-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.month-perf-table th { background: var(--bg); padding: 8px 12px; text-align: left; font-weight: 600; color: var(--text-3); font-size: 11px; text-transform: uppercase; letter-spacing: 0.4px; }
.month-perf-table td { padding: 9px 12px; border-bottom: 1px solid var(--border); }
.month-perf-table .best-month td { background: rgba(47,158,68,0.06); }
.month-perf-table .worst-month td { background: rgba(220,38,38,0.04); }
.cat-peer-card {
  background: var(--bg); border: 1px solid var(--border);
  border-radius: var(--r-sm); padding: 10px 12px;
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 6px;
}
.cat-peer-rank { font-size: 12px; font-weight: 700; color: var(--text-3); width: 24px; }
.cat-peer-name { font-size: 13px; font-weight: 500; flex: 1; }
.cat-peer-bar-wrap { width: 120px; height: 6px; background: var(--border); border-radius: 3px; margin: 0 10px; }
.cat-peer-bar { height: 6px; border-radius: 3px; background: #3B5BDB; }
.cat-peer-val { font-size: 12px; font-weight: 600; font-variant-numeric: tabular-nums; }

/* ══ TENANT HEALTH SCORE ══════════════════════════════════ */
.hs-badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 10px; border-radius: 10px;
  font-size: 11px; font-weight: 700; cursor: pointer;
  transition: opacity 0.15s;
}
.hs-badge:hover { opacity: 0.8; }

.hs-anchor   { background:#E8F5E9; color:#1B5E20; }
.hs-healthy  { background:#D3F9D8; color:#2F9E44; }
.hs-stable   { background:#EDF2FF; color:#3B5BDB; }
.hs-watch    { background:#FFF3BF; color:#F59F00; }
.hs-at-risk  { background:#FFE8D6; color:#E65100; }
.hs-critical { background:#FFE3E3; color:#E03131; }

/* Score bar in table */
.score-bar-wrap { width:50px; height:5px; background:var(--border); border-radius:3px; }
.score-bar      { height:5px; border-radius:3px; transition: width 0.3s ease; }

/* Component mini bars in health table */
.comp-bar-wrap { width:36px; height:4px; background:var(--border); border-radius:2px; display:inline-block; }
.comp-bar      { height:4px; border-radius:2px; }

/* ══ CASH FLOW FORECAST ══════════════════════════════════ */
.cf-scenario-card {
  border-radius: var(--r-lg);
  padding: 16px;
  border: 1.5px solid;
}
.cf-month-label {
  font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.4px;
  color: var(--text-3); margin-bottom: 4px;
}
.cf-total {
  font-size: 22px; font-weight: 800;
  letter-spacing: -0.5px;
  font-variant-numeric: tabular-nums;
}
.cf-confidence-bar {
  height: 5px; border-radius: 3px;
  background: var(--border);
  margin-top: 8px;
}
.cf-confidence-fill {
  height: 5px; border-radius: 3px;
  transition: width 0.4s ease;
}
.cf-assumption {
  font-size: 11px; color: var(--text-3);
  padding: 4px 0;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: flex-start; gap: 6px;
}
.cf-assumption::before {
  content: '→'; flex-shrink: 0; color: var(--brand);
  font-weight: 700;
}
/* Dark mode */
body.dark .cf-scenario-card { background: var(--surface); }

/* ══ CUSTOM MODAL (replaces browser confirm/prompt) ═══════ */
.pmodal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.6);
  z-index: 9999; display: flex; align-items: center; justify-content: center;
  animation: fadeIn 0.15s ease;
}
.pmodal {
  background: var(--surface); border-radius: var(--r-lg);
  box-shadow: 0 20px 60px rgba(0,0,0,0.4);
  width: 420px; max-width: 90vw; overflow: hidden;
  animation: fadeUp 0.2s ease;
}
.pmodal-header {
  padding: 18px 20px 0;
  font-size: 16px; font-weight: 700;
}
.pmodal-body {
  padding: 12px 20px 20px;
  font-size: 13px; color: var(--text-3); line-height: 1.5;
}
.pmodal-body textarea, .pmodal-body input {
  width: 100%; padding: 10px 12px;
  border: 1.5px solid var(--border); border-radius: var(--r-sm);
  font-size: 13px; color: var(--text); background: var(--bg);
  font-family: inherit;
}
/* Only textareas get the tall multi-line box; inputs/selects stay single-line */
.pmodal-body textarea {
  margin-top: 10px; resize: vertical; min-height: 80px;
}
/* Inputs/selects inside a .fg field group are laid out by the grid,
   so they should not carry a standalone top margin or tall min-height */
.pmodal-body .fg input, .pmodal-body .fg select { margin-top: 0; }
.pmodal-body textarea:focus, .pmodal-body input:focus, .pmodal-body select:focus {
  border-color: var(--brand); outline: none;
}
.pmodal-footer {
  padding: 12px 20px; display: flex; justify-content: flex-end; gap: 8px;
  border-top: 1px solid var(--border);
}
.pmodal-store-name {
  font-weight: 700; color: var(--brand);
}

/* Success toast — more visible */
.toast-success {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--green); color: #fff; padding: 12px 24px;
  border-radius: var(--r-sm); font-size: 13px; font-weight: 600;
  box-shadow: 0 8px 30px rgba(0,0,0,0.3); z-index: 10000;
  animation: fadeUp 0.2s ease, fadeOut 0.3s ease 2.5s forwards;
  display: flex; align-items: center; gap: 8px;
}
@keyframes fadeOut { to { opacity:0; transform: translateX(-50%) translateY(10px); } }

/* ══════════════════════════════════════════════════════════
   REVENUE SHARE COMPUTATION — Working Sheet
   In-app printable view + print stylesheet
   ══════════════════════════════════════════════════════════ */

/* Full-screen overlay viewer (screen only) */
.rsc-viewer {
  position: fixed; inset: 0; z-index: 9999;
  background: #F5F5F0; /* paper-tone background so the white sheet pops */
  display: flex; flex-direction: column;
}
.rsc-viewer-bar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 20px; background: #fff;
  border-bottom: 1px solid #E5E5E0;
}
.rsc-viewer-title {
  font-weight: 600; font-size: 14px; color: #1C1917;
}
.rsc-viewer-actions { display: flex; gap: 8px; }
.rsc-viewer-body {
  flex: 1; overflow-y: auto; padding: 24px;
  display: flex; flex-direction: column; align-items: center; gap: 20px;
}
body.dark .rsc-viewer { background: #1C1917; }
body.dark .rsc-viewer-bar { background: #292524; border-bottom-color: #44403C; }
body.dark .rsc-viewer-title { color: #FAFAF9; }

/* The document itself — A4-proportioned, on-screen and print */
.rsc-doc {
  width: 210mm; min-height: 297mm; padding: 18mm 18mm 14mm;
  background: #fff; color: #1C1917;
  font-family: 'DM Sans', sans-serif; font-size: 11pt; line-height: 1.45;
  box-shadow: 0 2px 12px rgba(0,0,0,0.08);
  position: relative; box-sizing: border-box;
}
body.dark .rsc-doc { background: #fff; color: #1C1917; /* always light for print fidelity */ }

/* Letterhead */
.rsc-letterhead {
  display: flex; justify-content: space-between; align-items: flex-start;
  padding-bottom: 12pt; border-bottom: 2px solid #1C1917; margin-bottom: 14pt;
}
.rsc-brand { display: flex; flex-direction: column; gap: 6pt; }
.rsc-brand-text {
  font-weight: 800; font-size: 18pt; letter-spacing: 1.5px;
  color: #1C1917;
}
.rsc-logo { max-height: 40pt; max-width: 140pt; object-fit: contain; }
.rsc-brand-meta {
  font-size: 9pt; line-height: 1.4; color: #44403C;
}
.rsc-brand-meta > div { white-space: nowrap; max-width: 280pt; white-space: normal; }
.rsc-doc-title { text-align: right; }
.rsc-title-main {
  font-weight: 700; font-size: 14pt; color: #1C1917;
  letter-spacing: 0.3px;
}
.rsc-title-sub {
  font-size: 9pt; color: #78716C; text-transform: uppercase;
  letter-spacing: 1px; margin-top: 2pt;
}

/* Reference strip */
.rsc-refstrip {
  display: grid; grid-template-columns: 1.6fr 1.4fr 1.2fr 0.8fr;
  gap: 8pt; padding: 8pt 10pt; margin-bottom: 12pt;
  background: #F5F5F0; border: 1px solid #E5E5E0; border-radius: 3pt;
  font-size: 9pt;
}
.rsc-refstrip > div { display: flex; flex-direction: column; gap: 1pt; }
.rsc-k { font-size: 8pt; text-transform: uppercase; letter-spacing: 0.6px; color: #78716C; font-weight: 600; }
.rsc-v { font-size: 10pt; color: #1C1917; font-weight: 500; }
.rsc-pill {
  display: inline-block; padding: 1pt 8pt; border-radius: 10pt;
  font-size: 8pt; font-weight: 700; letter-spacing: 0.4px;
}
.rsc-pill-draft { background: #FEF3C7; color: #92400E; border: 1px solid #FCD34D; }

/* Warning banner */
.rsc-banner {
  background: #FEF3C7; border: 1px solid #FCD34D; color: #92400E;
  padding: 6pt 10pt; font-size: 9pt; border-radius: 3pt; margin-bottom: 10pt;
}

/* Two-column grid block */
.rsc-grid2 {
  display: grid; grid-template-columns: 1fr 1fr; gap: 10pt; margin-bottom: 10pt;
}
.rsc-block {
  border: 1px solid #E5E5E0; border-radius: 3pt;
  padding: 8pt 10pt; background: #fff;
}
.rsc-block-full { margin-bottom: 10pt; }
.rsc-block-title {
  font-size: 8pt; text-transform: uppercase; letter-spacing: 0.8px;
  color: #78716C; font-weight: 700; margin-bottom: 6pt;
  padding-bottom: 4pt; border-bottom: 1px solid #F0EFEC;
}
.rsc-tenant-name {
  font-size: 13pt; font-weight: 700; color: #1C1917; margin-bottom: 2pt;
}
.rsc-block-row { font-size: 9.5pt; color: #44403C; margin-top: 1pt; }
.rsc-muted { color: #78716C; }

/* POS data block */
.rsc-pos-row {
  display: flex; gap: 28pt; padding: 4pt 0;
}
.rsc-pos-row > div { display: flex; flex-direction: column; gap: 2pt; }
.rsc-big { font-size: 14pt; font-weight: 700; color: #1C1917; }
.rsc-source-note {
  font-size: 8.5pt; color: #78716C; font-style: italic;
  padding-top: 6pt; border-top: 1px solid #F0EFEC; margin-top: 6pt;
}

/* Contract summary inline */
.rsc-contract-summary {
  display: flex; gap: 24pt; flex-wrap: wrap; margin-bottom: 8pt;
  padding-bottom: 6pt; border-bottom: 1px dashed #E5E5E0;
}
.rsc-contract-summary > div { display: flex; flex-direction: column; gap: 1pt; }

/* Slab table */
.rsc-slab-tbl, .rsc-comp-tbl {
  width: 100%; border-collapse: collapse; font-size: 10pt;
}
.rsc-slab-tbl th, .rsc-slab-tbl td,
.rsc-comp-tbl td {
  padding: 5pt 8pt; border-bottom: 1px solid #F0EFEC;
}
.rsc-slab-tbl th {
  background: #F5F5F0; font-weight: 700; font-size: 8.5pt;
  text-transform: uppercase; letter-spacing: 0.5px; color: #44403C;
  text-align: left; border-bottom: 1.5px solid #E5E5E0;
}
.rsc-r { text-align: right; font-variant-numeric: tabular-nums; }
.rsc-slab-active {
  background: #FEF7E6;
}
.rsc-slab-active td { font-weight: 600; }

/* Computation table */
.rsc-comp-tbl tr.rsc-sub td {
  border-top: 1px solid #1C1917; border-bottom: 1px solid #1C1917;
  font-weight: 600;
}
.rsc-comp-tbl tr.rsc-total td {
  border-top: 2px solid #1C1917; border-bottom: 3px double #1C1917;
  font-size: 11.5pt; padding: 8pt; background: #FAF8F2;
}

/* Tally / SAP block */
.rsc-tally-row {
  display: flex; gap: 18pt; padding: 4pt 0;
  font-size: 9.5pt; align-items: center;
}
.rsc-cb {
  width: 11pt; height: 11pt; margin-right: 4pt; vertical-align: middle;
  accent-color: #1C1917;
}
.rsc-inline-field { display: flex; align-items: baseline; gap: 6pt; }
.rsc-blank {
  display: inline-block; border-bottom: 1px solid #44403C;
  min-width: 120pt; height: 12pt;
}
.rsc-blank-short { min-width: 70pt; }
.rsc-notes-block { margin-top: 6pt; }
.rsc-notes-area {
  min-height: 38pt; border: 1px solid #E5E5E0; border-radius: 2pt;
  background: #FAFAF9;
}

/* Signatures */
.rsc-sig-row {
  display: grid; grid-template-columns: 1fr 1fr; gap: 30pt;
  margin-top: 18pt; padding-top: 12pt;
}
.rsc-sig-line {
  border-top: 1px solid #1C1917; margin-bottom: 4pt;
  margin-top: 28pt;
}
.rsc-sig-lbl { font-size: 9pt; font-weight: 600; color: #1C1917; }
.rsc-sig-date { font-size: 9pt; color: #44403C; margin-top: 3pt; }

/* Footer */
.rsc-footer {
  position: absolute; bottom: 10mm; left: 18mm; right: 18mm;
  display: flex; justify-content: space-between;
  padding-top: 6pt; border-top: 1px solid #E5E5E0;
  font-size: 8pt; color: #78716C; letter-spacing: 0.3px;
}

/* Page-break between batched statements */
.rsc-pagebreak {
  width: 100%; height: 0; page-break-after: always;
}

/* ── PRINT STYLES ───────────────────────────────────────── */
@media print {
  /* Hide everything except the viewer */
  body > *:not(.rsc-viewer) { display: none !important; }
  /* Hide the toolbar of the viewer when printing */
  .rsc-viewer-bar { display: none !important; }
  /* Reset viewer chrome — let pages flow naturally */
  .rsc-viewer {
    position: static; background: #fff;
  }
  .rsc-viewer-body {
    overflow: visible; padding: 0; gap: 0;
    display: block;
  }
  /* Document fills the page; remove screen shadow */
  .rsc-doc {
    box-shadow: none; width: 100%; min-height: 0;
    page-break-inside: auto;
  }
  /* Each batched statement on a fresh page */
  .rsc-pagebreak {
    page-break-before: always;
  }
  /* Tighten margins to use page real-estate */
  @page { size: A4; margin: 10mm; }
}

/* Property page — plan view metric toggle */
.prop-metric-btn { background:transparent; border:none; color:var(--text-3); font-size:12px; font-weight:600; padding:5px 11px; border-radius:6px; cursor:pointer; font-family:inherit; }
.prop-metric-btn.active { background:#3B5BDB; color:#fff; }

/* Asset Map (Office) — metric toggle */
.amap-metric-btn { background:transparent; border:none; color:var(--text-3); font-size:12px; font-weight:600; padding:5px 11px; border-radius:6px; cursor:pointer; font-family:inherit; }
.amap-metric-btn.active { background:var(--brand); color:#fff; }

/* Clickable heatmap tiles (Asset Map + Property plan) */
.map-tile { transition: transform .1s ease, box-shadow .1s ease; }
.map-tile:hover { transform: translateY(-2px); box-shadow: 0 4px 12px rgba(0,0,0,0.25); filter: brightness(1.06); }

/* Equal-halves grid for paired tables (Top3/Bottom3) */
.dg-half { display:grid; grid-template-columns:1fr 1fr; gap:14px; }
.dg-half > * { min-width:0; }
@media (max-width: 900px){ .dg-half { grid-template-columns:1fr; } }
