:root{
  --bg:#0a0e14; --bg2:#0e131b; --sidebar:#0c111a;
  --card:#141b25; --card2:#171f2b; --line:rgba(255,255,255,.07); --line2:rgba(255,255,255,.05);
  --tx:#e8eef6; --muted:#8a97a8; --muted2:#5f6b7c;
  --blue:#3b82f6; --blueD:#2563eb; --green:#22c55e; --gold:#eab308; --red:#ef4444;
  --purple:#a855f7; --cyan:#06b6d4; --teal:#14b8a6; --orange:#f59e0b;
}
*{box-sizing:border-box;margin:0;padding:0}
html,body{background:var(--bg);color:var(--tx);font-family:'Cairo',-apple-system,'Segoe UI',Tahoma,sans-serif;font-size:14px}
::-webkit-scrollbar{width:9px;height:9px}
::-webkit-scrollbar-thumb{background:#1e2733;border-radius:9px}
::-webkit-scrollbar-track{background:transparent}
a{color:inherit;text-decoration:none}
.app{display:flex;direction:ltr;min-height:100vh}

/* ---------- SIDEBAR ---------- */
.sidebar{direction:rtl;width:250px;flex:0 0 250px;background:var(--sidebar);border-inline-end:1px solid var(--line);
  display:flex;flex-direction:column;padding:22px 16px;position:sticky;top:0;height:100vh}
.brand{display:flex;align-items:center;gap:10px;padding:0 6px 20px;border-bottom:1px solid var(--line2);margin-bottom:18px}
.brand .logo{font-weight:800;font-size:26px;letter-spacing:.5px}
.brand .logo b{color:#fff}
.brand .badge{background:var(--blue);color:#fff;font-size:11px;font-weight:700;padding:3px 7px;border-radius:6px;letter-spacing:1px}
.profile{display:flex;align-items:center;gap:11px;padding:8px 6px 18px;border-bottom:1px solid var(--line2);margin-bottom:14px}
.profile img{width:44px;height:44px;border-radius:12px;object-fit:cover}
.profile .nm{font-weight:700;font-size:14px}
.profile .rl{color:var(--muted);font-size:12px;margin-top:2px}
.nav{display:flex;flex-direction:column;gap:3px;flex:1;overflow:auto}
.nav a{display:flex;align-items:center;gap:12px;padding:11px 12px;border-radius:11px;color:var(--muted);font-weight:600;font-size:14px;transition:.15s;cursor:pointer}
.nav a svg{width:19px;height:19px;flex:0 0 19px;stroke:currentColor;fill:none;stroke-width:1.8}
.nav a:hover{background:#131a24;color:var(--tx)}
.nav a.active{background:var(--blue);color:#fff;box-shadow:0 6px 18px -6px rgba(59,130,246,.7)}
.side-foot{margin-top:14px;padding-top:14px;border-top:1px solid var(--line2)}
.btn-refresh{width:100%;display:flex;align-items:center;justify-content:center;gap:8px;background:#131a24;border:1px solid var(--line);
  color:var(--tx);font-family:inherit;font-weight:600;padding:11px;border-radius:11px;cursor:pointer;font-size:13px}
.btn-refresh:hover{background:#182130}
.updated{display:flex;align-items:center;gap:7px;color:var(--muted);font-size:12px;margin-top:11px;padding:0 4px}
.dot{width:8px;height:8px;border-radius:50%;background:var(--green);box-shadow:0 0 8px var(--green)}

/* ---------- MAIN ---------- */
.main{direction:rtl;flex:1;padding:22px 26px 26px;min-width:0}
.topbar{display:flex;direction:ltr;align-items:flex-start;justify-content:space-between;gap:16px;margin-bottom:22px}
.greet{direction:rtl}
.greet h1{font-size:25px;font-weight:800}
.greet p{color:var(--muted);font-size:14px;margin-top:5px}
.greet .date{color:var(--muted2);font-size:12.5px;margin-top:7px;display:flex;align-items:center;gap:6px}
.top-actions{display:flex;align-items:center;gap:12px}
.datepick{display:flex;align-items:center;gap:9px;background:var(--card);border:1px solid var(--line);padding:11px 15px;border-radius:12px;font-weight:600;font-size:13px}
.iconbtn{position:relative;width:42px;height:42px;border-radius:12px;background:var(--card);border:1px solid var(--line);display:flex;align-items:center;justify-content:center;cursor:pointer;color:var(--muted)}
.iconbtn:hover{color:var(--tx);background:var(--card2)}
.iconbtn svg{width:19px;height:19px;stroke:currentColor;fill:none;stroke-width:1.8}
.iconbtn .n{position:absolute;top:-5px;right:-5px;background:var(--red);color:#fff;font-size:10px;font-weight:700;min-width:17px;height:17px;border-radius:9px;display:flex;align-items:center;justify-content:center;padding:0 4px}

/* KPI ROW */
.kpis{display:grid;direction:ltr;grid-template-columns:repeat(5,1fr);gap:16px;margin-bottom:18px}
.kpis.k4{grid-template-columns:repeat(4,1fr)}
.kpi{background:var(--card);direction:rtl;border:1px solid var(--line);border-radius:16px;padding:16px 17px}
.kpi .h{display:flex;align-items:center;gap:10px;color:var(--muted);font-size:13px;font-weight:600}
.kpi .ic{width:34px;height:34px;border-radius:10px;display:flex;align-items:center;justify-content:center;font-size:16px}
.kpi .val{display:flex;align-items:baseline;gap:9px;margin:12px 0 3px}
.kpi .val .num{font-size:27px;font-weight:800}
.kpi .val .chg{font-size:13px;font-weight:700}
.kpi .sub{color:var(--muted2);font-size:12px}
.kpi .spark{margin-top:8px}
.up{color:var(--green)} .down{color:var(--red)}

/* LAYOUT */
.grid{display:grid;direction:ltr;grid-template-columns:minmax(0,2.35fr) minmax(300px,1fr);gap:16px}
.leftcol{display:grid;direction:ltr;grid-template-columns:1.32fr 1fr;grid-auto-rows:min-content;gap:16px;min-width:0}
.rightcol{display:flex;direction:rtl;flex-direction:column;gap:16px;min-width:0}
.g2{display:grid;grid-template-columns:1fr 1fr;gap:16px}
.g3{display:grid;grid-template-columns:1fr 1fr 1fr;gap:16px}
.g23{display:grid;grid-template-columns:minmax(0,1.6fr) minmax(0,1fr);gap:16px}
.card{background:var(--card);direction:rtl;border:1px solid var(--line);border-radius:16px;padding:18px}
.card.pad0{padding:0}
.card-h{display:flex;align-items:center;justify-content:space-between;margin-bottom:16px}
.card-h .t{font-size:15.5px;font-weight:700}
.pill{background:var(--card2);border:1px solid var(--line);color:var(--muted);font-size:12px;font-weight:600;padding:7px 12px;border-radius:9px;display:flex;align-items:center;gap:6px;cursor:pointer}
.legend-dot{width:9px;height:9px;border-radius:50%;display:inline-block}
.mb16{margin-bottom:16px}

/* chart legends */
.linelegend{display:flex;gap:18px;margin-bottom:6px}
.linelegend span{display:flex;align-items:center;gap:7px;color:var(--muted);font-size:12.5px;font-weight:600}

/* donut */
.donut-wrap{display:flex;align-items:center;gap:16px}
.donut-legend{flex:1;display:flex;flex-direction:column;gap:11px}
.donut-legend .row{display:flex;align-items:center;gap:9px;font-size:12.5px}
.donut-legend .row .nm{color:var(--muted);flex:1}
.donut-legend .row .pc{color:var(--tx);font-weight:700;width:34px;text-align:left}
.donut-legend .row .am{color:var(--muted2);font-weight:600;width:42px;text-align:left}

/* right panels / lists */
.panel-h{display:flex;align-items:center;gap:8px;font-size:15px;font-weight:700;margin-bottom:14px}
.panel-h .cnt{background:var(--red);color:#fff;font-size:11px;font-weight:700;width:20px;height:20px;border-radius:50%;display:flex;align-items:center;justify-content:center}
.plist{display:flex;flex-direction:column;gap:4px}
.pitem{display:flex;align-items:center;gap:12px;padding:11px 8px;border-radius:11px;cursor:pointer;transition:.15s}
.pitem:hover{background:var(--card2)}
.pitem .badge{width:34px;height:34px;flex:0 0 34px;border-radius:10px;display:flex;align-items:center;justify-content:center;font-size:15px}
.pitem .tx{flex:1;min-width:0}
.pitem .tx .l1{font-size:13px;font-weight:600;line-height:1.45}
.pitem .tx .l2{font-size:11.5px;color:var(--muted2);margin-top:2px}
.pitem .chev{color:var(--muted2);font-size:16px}
.pitem .num{width:26px;height:26px;flex:0 0 26px;border-radius:8px;background:var(--card2);display:flex;align-items:center;justify-content:center;font-weight:700;font-size:12px;color:var(--muted)}
.btn-exec{background:transparent;border:1px solid var(--green);color:var(--green);font-family:inherit;font-weight:700;font-size:12px;padding:6px 13px;border-radius:8px;cursor:pointer;white-space:nowrap;transition:.15s}
.btn-exec:hover{background:var(--green);color:#06210f}
.btn-exec.done{background:#0f2a19;border-color:#0f2a19;color:var(--green);cursor:default}
.viewall{text-align:center;color:var(--blue);font-weight:600;font-size:13px;padding:12px 0 2px;cursor:pointer}

/* table */
.tbl{width:100%;border-collapse:collapse}
.tbl th{color:var(--muted2);font-weight:600;font-size:12px;text-align:right;padding:8px 6px;border-bottom:1px solid var(--line2)}
.tbl td{padding:11px 6px;border-bottom:1px solid var(--line2);font-size:13px;font-weight:600}
.tbl td.n{text-align:left;color:var(--muted)}
.tbl tr:last-child td{border-bottom:none}
.tbl .camp{display:flex;align-items:center;gap:9px}
.tbl .roas{font-weight:800}
.arrow{font-size:11px}

/* funnel */
.funnel-wrap{display:flex;align-items:center;gap:6px}
.funnel-labels{flex:1;display:flex;flex-direction:column;justify-content:space-between;height:236px;padding:6px 0}
.funnel-labels .fl{display:flex;align-items:center;justify-content:space-between;font-size:13px}
.funnel-labels .fl .v{font-weight:800}
.funnel-labels .fl .k{color:var(--muted)}
.funnel-foot{text-align:center;color:var(--muted);font-size:12.5px;margin-top:12px;border-top:1px solid var(--line2);padding-top:12px}
.funnel-foot b{color:var(--tx)}

/* ---- reusable page components ---- */
.prog{height:8px;border-radius:6px;background:var(--card2);overflow:hidden}
.prog>i{display:block;height:100%;border-radius:6px;background:var(--blue)}
.hbars{display:flex;flex-direction:column;gap:14px}
.hbar .top{display:flex;justify-content:space-between;font-size:13px;font-weight:600;margin-bottom:7px}
.hbar .top .v{color:var(--muted)}
.tag{font-size:11px;font-weight:700;padding:4px 10px;border-radius:7px;display:inline-flex;align-items:center;gap:5px}
.tag.green{background:rgba(34,197,94,.14);color:var(--green)}
.tag.red{background:rgba(239,68,68,.14);color:var(--red)}
.tag.gold{background:rgba(234,179,8,.14);color:var(--gold)}
.tag.blue{background:rgba(59,130,246,.14);color:var(--blue)}
.tag.purple{background:rgba(168,85,247,.14);color:var(--purple)}
.tag.gray{background:var(--card2);color:var(--muted)}
.mini{background:var(--card2);border:1px solid var(--line2);border-radius:12px;padding:14px}
.mini .k{color:var(--muted);font-size:12.5px;font-weight:600}
.mini .v{font-size:22px;font-weight:800;margin-top:6px}
.barchart{display:flex;align-items:flex-end;gap:10px;height:170px;padding-top:10px}
.barchart .b{flex:1;display:flex;flex-direction:column;align-items:center;gap:8px;height:100%;justify-content:flex-end}
.barchart .b i{width:70%;border-radius:6px 6px 0 0;display:block}
.barchart .b span{font-size:11px;color:var(--muted2)}
.rowlist{display:flex;flex-direction:column}
.rowlist .r{display:flex;align-items:center;gap:12px;padding:12px 4px;border-bottom:1px solid var(--line2)}
.rowlist .r:last-child{border-bottom:none}
.rowlist .r .av{width:36px;height:36px;flex:0 0 36px;border-radius:10px;background:var(--card2);display:flex;align-items:center;justify-content:center;font-weight:700;color:var(--muted)}
.rowlist .r .g{flex:1;min-width:0}
.rowlist .r .g .l1{font-size:13.5px;font-weight:700}
.rowlist .r .g .l2{font-size:12px;color:var(--muted2);margin-top:2px}
.gauge-wrap{display:flex;flex-direction:column;align-items:center;justify-content:center;gap:6px;padding:6px 0}
.placeholder{display:flex;flex-direction:column;align-items:center;justify-content:center;gap:14px;min-height:60vh;text-align:center;color:var(--muted)}
.placeholder .big{font-size:52px}
.placeholder h2{color:var(--tx);font-size:22px;font-weight:800}
.placeholder .tag{margin-top:4px}

/* AI bar */
.aibar{margin-top:16px;background:linear-gradient(90deg,#141b28,#131a26);border:1px solid var(--line);border-radius:16px;
  padding:16px 20px;display:flex;align-items:center;gap:18px}
.aibar .bot{width:54px;height:54px;flex:0 0 54px;border-radius:14px;background:linear-gradient(135deg,#1e2a3d,#16202e);display:flex;align-items:center;justify-content:center;font-size:26px}
.aibar .msg{flex:1;font-size:14.5px;font-weight:600;line-height:1.6}
.aibar .msg b{color:var(--blue)}
.btn-ai{background:var(--blue);color:#fff;border:none;font-family:inherit;font-weight:700;font-size:13.5px;padding:12px 20px;border-radius:11px;cursor:pointer;white-space:nowrap}
.btn-ai:hover{background:var(--blueD)}

@media(max-width:1250px){.grid{grid-template-columns:1fr}.kpis,.kpis.k4{grid-template-columns:repeat(3,1fr)}.g3{grid-template-columns:1fr 1fr}}
@media(max-width:820px){.sidebar{display:none}.kpis,.kpis.k4{grid-template-columns:1fr 1fr}.leftcol,.g2,.g23,.g3{grid-template-columns:1fr}}
