/* مظهر لوحات التحكم بأسلوب CoreUI: شريط جانبي داكن، شريط علوي، بطاقات إحصاء ملوّنة، جداول نظيفة.
   طبقة شكل فقط فوق panel.css — تُحمَّل بعده ولا تغيّر أي منطق. */
:root{
  --bg:#1b1e29;--card:#222733;--ink:#e3e8f0;--muted:#8f98aa;--line:#323a4b;--thead:#262c3a;--hover:#2a3040;--field:#1b1e29;
  --deep:#212631;--deep2:#2b3141;--side-ink:#aab3c5;--on-deep:#fff;
  --pri:#5856d6;--pri2:#4b49c0;--info:#3399ff;--amber:#f9b115;--red:#e55353;--green:#2eb85c;--blue:#6ea8ff;
  --btn-bg:#5856d6;--btn-ink:#fff;--bar:#5856d6;
  --t-bg:#323a4b;--t-ink:#c9d1e0;--t-trial-bg:rgba(51,153,255,.16);--t-trial-ink:#7fbcff;--t-ok-bg:rgba(46,184,92,.16);--t-ok-ink:#5fd68a;--t-warn-bg:rgba(249,177,21,.16);--t-warn-ink:#f9c84f;--t-bad-bg:rgba(229,83,83,.16);--t-bad-ink:#f58b8b;
  --alert-warn-bg:rgba(249,177,21,.1);--alert-warn-bd:rgba(249,177,21,.5);--alert-err-bg:rgba(229,83,83,.1);--alert-ok-bg:rgba(46,184,92,.1);--alert-ok-bd:rgba(46,184,92,.5);
  --r:8px;--shadow:0 1px 2px rgba(0,0,0,.25);--topbg:#222733;
}
:root[data-theme=light]{
  --bg:#f3f4f7;--card:#fff;--ink:#3c4b64;--muted:#7c8799;--line:#dde1e8;--thead:#f6f7fa;--hover:#f3f5f9;--field:#fff;
  --pri:#5856d6;--info:#3399ff;--amber:#f9b115;--red:#e55353;--green:#2eb85c;--blue:#4a56c8;
  --btn-bg:#5856d6;--btn-ink:#fff;--bar:#5856d6;
  --t-bg:#e7eaf0;--t-ink:#4a566c;--t-trial-bg:#dcecff;--t-trial-ink:#1d5fae;--t-ok-bg:#d9f3e2;--t-ok-ink:#1b7a3d;--t-warn-bg:#fdefc7;--t-warn-ink:#8a5f00;--t-bad-bg:#fbdcdc;--t-bad-ink:#a02a2a;
  --alert-warn-bg:#fff6dc;--alert-warn-bd:#e8c55c;--alert-err-bg:#fdecec;--alert-ok-bg:#e3f6ea;--alert-ok-bd:#8fd2a8;--shadow:0 1px 3px rgba(60,75,100,.12);--topbg:#fff;
}
body{font-size:14.5px;line-height:1.65;background:var(--bg)}
a{color:var(--blue)}
:focus-visible{outline:2px solid var(--pri);outline-offset:2px}
h1{font-size:1.45rem;font-weight:600} h3{font-weight:600}

/* ---- الهيكل ---- */
.app{grid-template-columns:260px 1fr;transition:grid-template-columns .2s}
html.sb-min .app{grid-template-columns:68px 1fr}
.side{background:var(--deep);border-inline-end:0;padding:0 12px;display:flex;flex-direction:column;color:var(--side-ink);overflow:auto}
.side .brand{padding:0;height:64px;display:grid;place-items:center;border-bottom:1px solid rgba(255,255,255,.07);flex:none;text-align:center;margin:0 -12px 8px}
.side .brandimg{height:36px;background:none;padding:0;margin:0}
.side a{gap:12px;padding:10px 12px;border-radius:6px;margin:0 0 2px;font-size:.95rem;font-weight:500;color:var(--side-ink);position:relative}
.side a:hover{background:rgba(255,255,255,.06);color:#fff}
.side a.on{background:rgba(255,255,255,.1);color:#fff;font-weight:600}
.side a.on::before{content:"";position:absolute;inset-inline-start:-12px;top:8px;bottom:8px;width:3px;border-radius:3px;background:var(--pri)}
.side a .ico{width:20px;height:20px;flex:none;stroke:currentColor;fill:none;stroke-width:1.7;stroke-linecap:round;stroke-linejoin:round;opacity:.85}
.side a.on .ico{opacity:1;stroke:#a6a4ff}
.side .navtitle{font-size:.72rem;font-weight:700;letter-spacing:.04em;color:#6f7a90;padding:16px 12px 6px;text-transform:uppercase;white-space:nowrap}
.side .sep{display:none}
.side .badge{background:var(--info);font-size:.68rem;font-weight:700;padding:1px 8px;line-height:1.5;color:#fff}
.side .side-foot{flex:none;border-top:1px solid rgba(255,255,255,.07);padding:10px 14px;display:flex;justify-content:flex-start;position:sticky;bottom:0;background:var(--deep);margin:auto -12px 0}
.side .me,.side .theme-btn,.side #out,.side a[href="#/me"]{display:none}
.side .side-foot button{background:none;border:0;color:var(--side-ink);cursor:pointer;width:34px;height:34px;border-radius:6px;display:grid;place-items:center}
.side .side-foot button:hover{background:rgba(255,255,255,.08);color:#fff}
.side .side-foot svg{width:18px;height:18px;stroke:currentColor;fill:none;stroke-width:1.8;stroke-linecap:round;stroke-linejoin:round;transition:transform .2s}
html.sb-min .side-foot svg{transform:scaleX(-1)}
html.sb-min .side .lbl,html.sb-min .side .navtitle,html.sb-min .side .badge{display:none}
html.sb-min .side a{justify-content:center;padding:11px 0}
html.sb-min .side{padding:0 8px}html.sb-min .side .brand{margin:0 -8px 8px}html.sb-min .side .side-foot{margin:auto -8px 0}
html.sb-min .side .side-foot{justify-content:center}
.main{padding:0 0 0;display:flex;flex-direction:column;min-height:100vh;min-width:0}
.main>#view,.main>.head,.main>.crumbs,.main>.shellfoot{margin-inline:28px}
.main>#view{flex:1;padding-bottom:30px}
.main>.head{display:none}

/* ---- الشريط العلوي ---- */
.tbar{position:sticky;top:0;z-index:35;display:flex;align-items:center;gap:12px;height:58px;padding:0 20px;background:var(--topbg);border-bottom:1px solid var(--line);margin:0!important}
.tb-btn{background:none;border:0;color:var(--muted);width:38px;height:38px;border-radius:8px;display:inline-grid;place-items:center;cursor:pointer;position:relative;font:inherit;text-decoration:none}
.tb-btn:hover{background:var(--hover);color:var(--ink)}
.tb-btn svg{width:20px;height:20px;stroke:currentColor;fill:none;stroke-width:1.8;stroke-linecap:round;stroke-linejoin:round}
.tb-btn .dot{position:absolute;top:5px;inset-inline-end:4px;min-width:17px;height:17px;border-radius:9px;background:var(--red);color:#fff;font:700 .66rem/17px var(--f);text-align:center;padding:0 4px}
.tb-search{position:relative;flex:0 1 330px}
.tb-search .box{display:flex;align-items:center;gap:8px;height:38px;padding:0 12px;border:1px solid var(--line);border-radius:8px;background:var(--bg);color:var(--muted)}
.tb-search .box:focus-within{border-color:var(--pri);box-shadow:0 0 0 3px rgba(88,86,214,.22)}
.tb-search svg{width:18px;height:18px;stroke:currentColor;fill:none;stroke-width:1.8;stroke-linecap:round;flex:none}
.tb-search input{border:0;background:none;padding:0;height:100%;box-shadow:none;color:var(--ink);font-size:.92rem}
.tb-search input:focus{border:0;outline:none}
.tb-search kbd{font:600 .7rem var(--f);border:1px solid var(--line);border-radius:5px;padding:1px 6px;color:var(--muted);direction:ltr;white-space:nowrap}
.tb-results{position:absolute;top:44px;inset-inline:0;background:var(--card);border:1px solid var(--line);border-radius:8px;box-shadow:0 12px 30px rgba(0,0,0,.35);padding:6px;z-index:50}
.tb-results a{display:block;padding:8px 10px;border-radius:6px;color:var(--ink);text-decoration:none;font-size:.92rem}
.tb-results a:hover,.tb-results a.sel{background:var(--hover)}
.tb-results .none{padding:10px;color:var(--muted);font-size:.88rem}
.tb-sp{flex:1}
.tb-sep{width:1px;height:24px;background:var(--line);margin:0 4px}
.tb-user{position:relative}
.tb-av{width:36px;height:36px;border-radius:50%;background:linear-gradient(135deg,#5856d6,#3399ff);color:#fff;font-weight:700;display:grid;place-items:center;border:0;cursor:pointer;font:700 .95rem var(--f)}
.tb-menu{position:absolute;top:46px;inset-inline-end:0;min-width:220px;background:var(--card);border:1px solid var(--line);border-radius:10px;box-shadow:0 14px 34px rgba(0,0,0,.4);padding:6px;z-index:50}
.tb-menu .who{padding:10px 12px 8px;border-bottom:1px solid var(--line);margin-bottom:4px}
.tb-menu .who b{display:block}.tb-menu .who span{color:var(--muted);font-size:.84rem}
.tb-menu button,.tb-menu a{display:flex;width:100%;align-items:center;gap:10px;background:none;border:0;color:var(--ink);padding:9px 12px;border-radius:6px;font:inherit;cursor:pointer;text-decoration:none;text-align:start}
.tb-menu button:hover,.tb-menu a:hover{background:var(--hover)}
.tb-menu .out{color:var(--t-bad-ink)}
.crumbs{display:flex;gap:8px;align-items:center;padding:16px 0 4px;color:var(--muted);font-size:.9rem}
.crumbs a{color:var(--blue);text-decoration:underline;text-underline-offset:3px}
.crumbs i{font-style:normal;opacity:.6}
.shellfoot{display:flex;justify-content:space-between;gap:10px;flex-wrap:wrap;border-top:1px solid var(--line);padding:16px 0 20px;color:var(--muted);font-size:.86rem;margin-top:10px}
.shellfoot a{color:var(--blue);text-decoration:none}

/* ---- العناوين والبطاقات ---- */
.head{margin:14px 0 16px}
.card{border-radius:var(--r);box-shadow:var(--shadow);padding:18px 20px}
.card>h3:first-child{font-size:1.08rem;margin-bottom:14px}
.grid{gap:18px}

/* بطاقات الإحصاء الملوّنة */
.kpi{position:relative;overflow:hidden;color:#fff;border:0;min-height:148px;padding:16px 18px 70px;display:flex;flex-direction:column;box-shadow:none;background:var(--pri)}
.kpi .v{order:1;font:600 1.75rem/1.25 var(--f);color:#fff}
.kpi .l{order:2;color:rgba(255,255,255,.9);font-size:.95rem}
.kpi .s{order:3;color:rgba(255,255,255,.78);font-size:.82rem;margin-top:2px}
.kpi::after{content:"";position:absolute;inset-inline:0;bottom:0;height:58px;background-repeat:no-repeat;background-size:100% 100%;opacity:.55;pointer-events:none}
.grid>.kpi:nth-child(4n+1){background:#5856d6}.grid>.kpi:nth-child(4n+2){background:#3399ff}.grid>.kpi:nth-child(4n+3){background:#f9b115}.grid>.kpi:nth-child(4n){background:#e55353}
.grid>.kpi:nth-child(4n+1)::after{background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 200 58' preserveAspectRatio='none'%3E%3Cpolyline fill='none' stroke='white' stroke-width='1.6' vector-effect='non-scaling-stroke' points='6,34 28,38 52,22 78,10 100,16 124,38 148,34 172,40 196,44'/%3E%3Cg fill='none' stroke='white' stroke-width='1.4' vector-effect='non-scaling-stroke'%3E%3Ccircle cx='6' cy='34' r='2.5'/%3E%3Ccircle cx='52' cy='22' r='2.5'/%3E%3Ccircle cx='78' cy='10' r='2.5'/%3E%3Ccircle cx='124' cy='38' r='2.5'/%3E%3Ccircle cx='172' cy='40' r='2.5'/%3E%3C/g%3E%3C/svg%3E")}
.grid>.kpi:nth-child(4n+2)::after{background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 200 58' preserveAspectRatio='none'%3E%3Cpolyline fill='none' stroke='white' stroke-width='1.6' vector-effect='non-scaling-stroke' points='6,44 30,30 56,40 84,26 110,12 140,26 166,22 194,38'/%3E%3C/svg%3E")}
.grid>.kpi:nth-child(4n+3)::after{background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 200 58' preserveAspectRatio='none'%3E%3Cpath d='M0,24 C30,8 50,30 80,22 C110,14 130,34 160,46 C180,52 190,48 200,40 L200,58 L0,58Z' fill='white' fill-opacity='.55'/%3E%3C/svg%3E")}
.grid>.kpi:nth-child(4n)::after{background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 200 58' preserveAspectRatio='none'%3E%3Cg fill='white' fill-opacity='.6'%3E%3Crect x='4' y='24' width='9' height='34'/%3E%3Crect x='20' y='14' width='9' height='44'/%3E%3Crect x='36' y='30' width='9' height='28'/%3E%3Crect x='52' y='38' width='9' height='20'/%3E%3Crect x='68' y='20' width='9' height='38'/%3E%3Crect x='84' y='8' width='9' height='50'/%3E%3Crect x='100' y='26' width='9' height='32'/%3E%3Crect x='116' y='34' width='9' height='24'/%3E%3Crect x='132' y='4' width='9' height='54'/%3E%3Crect x='148' y='22' width='9' height='36'/%3E%3Crect x='164' y='12' width='9' height='46'/%3E%3Crect x='180' y='28' width='9' height='30'/%3E%3C/g%3E%3C/svg%3E")}

/* ---- الأزرار والنماذج ---- */
.btn{border-radius:6px;background:var(--pri);border-color:var(--pri);color:#fff;font-weight:600;padding:8px 16px;transition:background .15s,border-color .15s}
.btn:hover{filter:none;background:var(--pri2);border-color:var(--pri2)}
a.btn{color:#fff}
.btn.ghost,a.btn.ghost{background:transparent;color:var(--ink);border-color:var(--line)}
.btn.ghost:hover{background:var(--hover);border-color:var(--muted)}
.btn.red{background:var(--red);border-color:var(--red)} .btn.green{background:var(--green);border-color:var(--green);color:#fff}
.btn.sm{padding:4px 11px;border-radius:6px}
input,select,textarea{border-radius:6px;border:1px solid var(--line);background:var(--field)}
input:focus,select:focus,textarea:focus{border-color:var(--pri);box-shadow:0 0 0 3px rgba(88,86,214,.22)}
input[type=checkbox],input[type=radio]{accent-color:var(--pri)}
label{font-weight:600;color:var(--ink)}
.tabs{border-bottom:1px solid var(--line);gap:2px}
.tabs button{border-bottom:2px solid transparent;margin-bottom:-1px;padding:10px 16px}
.tabs button.on{border-color:var(--pri);color:var(--ink)}
.tag{border-radius:6px;padding:2px 10px;font-weight:600;font-size:.78rem}

/* ---- الجداول ---- */
.tablewrap{border-radius:var(--r);box-shadow:var(--shadow)}
th{background:var(--thead);color:var(--ink);font-weight:700;font-size:.84rem;border-bottom:1px solid var(--line);padding:11px 12px}
td{padding:11px 12px}
tbody tr:last-child td{border-bottom:0}
tr.click:hover td,tbody tr:hover td{background:var(--hover)}

/* ---- مخططات وشرائط ---- */
.bar i{background:linear-gradient(90deg,var(--pri),var(--info));height:10px;border-radius:99px}
.alert{border-radius:8px}
.modal{border-radius:12px;box-shadow:0 20px 50px rgba(0,0,0,.5)}
.modal-bg{background:rgba(10,12,20,.62);backdrop-filter:blur(2px)}
.toast{border-radius:8px}
.auth .box{border-radius:14px;box-shadow:0 20px 50px -20px rgba(0,0,0,.6)}
.status-card{background:linear-gradient(135deg,#5856d6,#3b3aa8);border:0}
.plan-opt.on{box-shadow:0 0 0 3px rgba(88,86,214,.3);border-color:var(--pri)}
.empty{color:var(--muted)}

@media(max-width:900px){
  .app{grid-template-columns:1fr}
  html.sb-min .app{grid-template-columns:1fr}
  .side{position:fixed;inset:0 0 0 auto;width:262px;z-index:60;transform:translateX(100%);transition:transform .2s;height:100%}
  .side.open{transform:none;box-shadow:-10px 0 40px rgba(0,0,0,.5)}
  html.sb-min .side .lbl,html.sb-min .side .navtitle{display:inline}
  html.sb-min .side a{justify-content:flex-start;padding:10px 12px}
  .main>#view,.main>.head,.main>.crumbs,.main>.shellfoot{margin-inline:14px}
  .tbar{padding:0 10px;gap:6px}.tb-search{flex:1 1 auto}.tb-search kbd{display:none}
  .side-foot{display:none!important}
}
@media(prefers-reduced-motion:reduce){*{transition:none!important}}
