/* ==========================================================================
   Al Quds Foundry ERP — Design System
   هوية القدس للمسبوكات: برتقالي الصهر + فحمي صناعي + خامة ورقية دافئة
   ========================================================================== */

:root{
  /* --- Brand --- */
  --brand:          #E85D1F;   /* برتقالي الشعار */
  --brand-600:      #D24E15;
  --brand-700:      #B5410F;
  --brand-300:      #F4A578;
  --brand-100:      #FCE7D8;
  --brand-50:       #FDF3EC;
  --molten:         linear-gradient(135deg,#FB8332 0%,#E85D1F 45%,#C13F0C 100%);
  --molten-soft:    linear-gradient(135deg,#FFF0E6 0%,#FDE0CC 100%);

  /* --- Ink / Industrial --- */
  --ink:            #1B1C1E;   /* فحمي الشعار */
  --ink-800:        #26282B;
  --ink-700:        #34373B;
  --ink-500:        #5C616A;
  --ink-400:        #858B95;
  --ink-300:        #AEB3BC;

  /* --- Surfaces (paper-warm) --- */
  --bg:             #F6F4F1;   /* خلفية ورقية دافئة */
  --surface:        #FFFFFF;
  --surface-2:      #FAF8F5;
  --line:           #ECE7E1;
  --line-strong:    #DDD6CE;

  /* --- Status --- */
  --ok:             #1FA971;
  --ok-bg:          #E5F6EE;
  --warn:           #E0A100;
  --warn-bg:        #FBF1D6;
  --danger:         #DD4B3E;
  --danger-bg:      #FBE7E5;
  --info:           #2F77C8;
  --info-bg:        #E6F0FB;
  --purple:         #7A5AF0;
  --purple-bg:      #EEEAFD;

  /* --- Shape & motion --- */
  --r-sm:8px; --r:14px; --r-lg:20px; --r-xl:26px;
  --sh-sm: 0 1px 2px rgba(27,28,30,.06), 0 1px 3px rgba(27,28,30,.04);
  --sh:    0 4px 12px rgba(27,28,30,.06), 0 2px 4px rgba(27,28,30,.04);
  --sh-lg: 0 18px 40px rgba(27,28,30,.10), 0 6px 14px rgba(27,28,30,.06);
  --sh-brand: 0 10px 24px rgba(232,93,31,.32);
  --ease: cubic-bezier(.4,0,.2,1);

  --sidebar-w: 268px;
  --topbar-h: 68px;
}

*{box-sizing:border-box; margin:0; padding:0}
html,body{height:100%}
body{
  font-family:"Tajawal","Cairo","Segoe UI",Tahoma,sans-serif;
  background:var(--bg);
  color:var(--ink);
  line-height:1.6;
  -webkit-font-smoothing:antialiased;
  font-size:14.5px;
}
[dir="ltr"] body{font-family:"Inter","Segoe UI",sans-serif}
a{color:inherit; text-decoration:none}
button{font-family:inherit; cursor:pointer; border:none; background:none}
img{max-width:100%; display:block}
svg{width:18px; height:18px; flex-shrink:0}  /* حجم افتراضي للأيقونات؛ القواعد الأخص تتجاوزه */
::selection{background:var(--brand-100); color:var(--brand-700)}

/* scrollbars */
*::-webkit-scrollbar{width:10px; height:10px}
*::-webkit-scrollbar-thumb{background:var(--line-strong); border-radius:20px; border:2px solid var(--bg)}
*::-webkit-scrollbar-thumb:hover{background:var(--ink-300)}

/* ==========================================================================
   LOGIN
   ========================================================================== */
.auth{
  min-height:100vh; display:grid; grid-template-columns:1.05fr .95fr;
}
.auth__brandside{
  position:relative; overflow:hidden;
  background:
    radial-gradient(900px 600px at 80% -10%, rgba(251,131,50,.25), transparent 60%),
    linear-gradient(160deg,#202225 0%,#161719 100%);
  color:#fff; display:flex; flex-direction:column; justify-content:space-between;
  padding:48px 52px;
}
.auth__brandside::after{ /* molten glow bottom */
  content:""; position:absolute; inset:auto -10% -30% -10%; height:55%;
  background:radial-gradient(closest-side, rgba(232,93,31,.55), transparent 70%);
  filter:blur(40px); opacity:.7;
}
.auth__logo{display:flex; align-items:center; gap:14px; z-index:2}
.auth__logo img{height:64px; filter:drop-shadow(0 4px 14px rgba(0,0,0,.4))}
.auth__hero{z-index:2}
.auth__hero h1{font-size:38px; font-weight:800; line-height:1.25; letter-spacing:-.5px}
.auth__hero h1 span{color:var(--brand-300)}
.auth__hero p{color:#C9CDD4; margin-top:16px; font-size:16px; max-width:440px}
.auth__chips{display:flex; flex-wrap:wrap; gap:10px; margin-top:26px; z-index:2}
.auth__chip{
  background:rgba(255,255,255,.07); border:1px solid rgba(255,255,255,.12);
  padding:8px 14px; border-radius:30px; font-size:13px; color:#E7E9EC; backdrop-filter:blur(6px);
}
.auth__foot{color:#8A8F98; font-size:13px; z-index:2}

.auth__formside{display:flex; align-items:center; justify-content:center; padding:40px; background:var(--surface)}
.login-card{width:100%; max-width:380px}
.login-card h2{font-size:26px; font-weight:800}
.login-card .sub{color:var(--ink-500); margin:8px 0 30px}
.field{margin-bottom:18px}
.field label{display:block; font-size:13.5px; font-weight:600; margin-bottom:8px; color:var(--ink-700)}
.field .inp{position:relative}
.field input{
  width:100%; padding:13px 44px 13px 16px; border:1.5px solid var(--line-strong);
  border-radius:var(--r); font-size:15px; background:var(--surface-2); transition:.18s var(--ease);
}
.field input:focus{outline:none; border-color:var(--brand); background:#fff; box-shadow:0 0 0 4px var(--brand-50)}
.field .ic{position:absolute; inset-inline-start:14px; top:50%; transform:translateY(-50%); color:var(--ink-400)}
.btn-primary{
  width:100%; padding:14px; border-radius:var(--r); color:#fff; font-weight:700; font-size:15.5px;
  background:var(--molten); box-shadow:var(--sh-brand); transition:.2s var(--ease);
}
.btn-primary:hover{transform:translateY(-1px); filter:brightness(1.04)}
.btn-primary:active{transform:translateY(0)}
.login-row{display:flex; justify-content:space-between; align-items:center; font-size:13px; color:var(--ink-500); margin:-4px 0 22px}
.login-row a{color:var(--brand-600); font-weight:600}

/* ==========================================================================
   APP SHELL
   ========================================================================== */
.app{display:none; min-height:100vh}
.app.is-on{display:block}

/* Sidebar (RTL → right) */
.sidebar{
  position:fixed; inset-block:0; inset-inline-start:0; width:var(--sidebar-w);
  background:linear-gradient(180deg,#1F2123 0%,#171819 100%); color:#D7DADF;
  display:flex; flex-direction:column; z-index:40; transition:transform .3s var(--ease);
}
.sidebar__brand{
  height:var(--topbar-h); display:flex; align-items:center; gap:12px; padding:0 22px;
  border-bottom:1px solid rgba(255,255,255,.06);
}
.sidebar__brand img{height:38px}
.sidebar__brand .nm{font-weight:800; color:#fff; font-size:15px; line-height:1.2}
.sidebar__brand .nm small{display:block; color:var(--brand-300); font-weight:600; font-size:11px}
.nav{flex:1; overflow-y:auto; padding:6px 10px 16px}
.nav__sec{color:#71757C; font-size:10px; font-weight:700; letter-spacing:.5px; padding:10px 12px 3px; text-transform:uppercase}
.nav__item{
  display:flex; align-items:center; gap:9px; padding:7px 12px; border-radius:9px;
  color:#C2C6CC; font-size:13px; font-weight:600; margin-bottom:1px; transition:.16s var(--ease);
  position:relative;
}
.nav__item svg{width:16px; height:16px; flex-shrink:0; opacity:.85}
.nav__item:hover{background:rgba(255,255,255,.06); color:#fff}
.nav__item.active{background:var(--molten); color:#fff; box-shadow:var(--sh-brand)}
.nav__item.active svg{opacity:1}
.nav__item .badge-n{
  margin-inline-start:auto; background:rgba(255,255,255,.16); color:#fff; font-size:10px;
  font-weight:700; min-width:20px; height:20px; border-radius:10px; display:grid; place-items:center; padding:0 5px;
}
.nav__item.active .badge-n{background:rgba(0,0,0,.22)}

/* Topbar */
.topbar{
  position:fixed; inset-block-start:0; inset-inline-start:var(--sidebar-w); inset-inline-end:0;
  height:var(--topbar-h); background:rgba(255,255,255,.85); backdrop-filter:blur(12px);
  border-bottom:1px solid var(--line); display:flex; align-items:center; gap:16px; padding:0 26px; z-index:30;
}
.topbar__title{font-weight:800; font-size:18px}
.topbar__title small{display:block; font-weight:500; font-size:12px; color:var(--ink-400)}
.search{
  margin-inline-start:auto; position:relative; width:320px; max-width:38vw;
}
.search input{
  width:100%; padding:10px 40px 10px 14px; border:1.5px solid var(--line-strong); border-radius:30px;
  background:var(--surface-2); font-size:14px; transition:.18s var(--ease);
}
.search input:focus{outline:none; border-color:var(--brand); background:#fff; box-shadow:0 0 0 4px var(--brand-50)}
.search .ic{position:absolute; inset-inline-start:14px; top:50%; transform:translateY(-50%); color:var(--ink-400)}
.icon-btn{
  width:42px; height:42px; border-radius:12px; display:grid; place-items:center; color:var(--ink-700);
  background:var(--surface-2); border:1px solid var(--line); transition:.16s var(--ease); position:relative;
}
.icon-btn:hover{background:var(--brand-50); color:var(--brand-600); border-color:var(--brand-100)}
.icon-btn .dot{position:absolute; top:9px; inset-inline-end:9px; width:8px; height:8px; background:var(--danger); border-radius:50%; border:2px solid #fff}
.lang-btn{font-weight:700; font-size:13px; gap:6px; display:flex; align-items:center; width:auto; padding:0 14px}
.user-chip{display:flex; align-items:center; gap:10px; padding:5px 6px 5px 12px; border-radius:30px; background:var(--surface-2); border:1px solid var(--line)}
.user-chip .av{width:34px; height:34px; border-radius:50%; background:var(--molten); color:#fff; display:grid; place-items:center; font-weight:800; font-size:14px}
.user-chip .nm{font-size:13.5px; font-weight:700; line-height:1.1}
.user-chip .nm small{display:block; font-weight:500; color:var(--ink-400); font-size:11.5px}

/* Main */
.main{margin-inline-start:var(--sidebar-w); padding-block-start:var(--topbar-h)}
.page{padding:26px 30px 60px; max-width:1500px; margin:0 auto}
.page-head{display:flex; align-items:flex-end; justify-content:space-between; gap:16px; margin-bottom:22px; flex-wrap:wrap}
.page-head h1{font-size:23px; font-weight:800}
.page-head p{color:var(--ink-500); font-size:14px; margin-top:3px}
.head-actions{display:flex; gap:10px; flex-wrap:wrap}

/* Buttons */
.btn{display:inline-flex; align-items:center; gap:8px; padding:10px 16px; border-radius:12px; font-weight:700; font-size:13.5px; transition:.16s var(--ease); border:1.5px solid transparent}
.btn svg{width:18px; height:18px}
.btn.primary{background:var(--molten); color:#fff; box-shadow:var(--sh-brand)}
.btn.primary:hover{transform:translateY(-1px); filter:brightness(1.04)}
.btn.ghost{background:var(--surface); color:var(--ink-700); border-color:var(--line-strong)}
.btn.ghost:hover{border-color:var(--brand-300); color:var(--brand-600); background:var(--brand-50)}
.btn.soft{background:var(--brand-50); color:var(--brand-700)}
.btn.soft:hover{background:var(--brand-100)}
.btn.sm{padding:7px 12px; font-size:12.5px; border-radius:10px}

/* ==========================================================================
   CARDS / KPI
   ========================================================================== */
.grid{display:grid; gap:18px}
.kpis{grid-template-columns:repeat(4,1fr)}
.kpi{
  background:var(--surface); border:1px solid var(--line); border-radius:var(--r-lg); padding:20px;
  box-shadow:var(--sh-sm); position:relative; overflow:hidden; transition:.2s var(--ease);
}
.kpi:hover{box-shadow:var(--sh); transform:translateY(-2px)}
.kpi .ic{
  width:46px; height:46px; border-radius:13px; display:grid; place-items:center; margin-bottom:14px;
}
.kpi .ic svg{width:23px; height:23px}
.kpi .val{font-size:30px; font-weight:800; line-height:1; letter-spacing:-1px}
.kpi .lbl{color:var(--ink-500); font-size:13.5px; margin-top:7px; font-weight:600}
.kpi .trend{position:absolute; top:20px; inset-inline-end:20px; font-size:12px; font-weight:700; padding:3px 9px; border-radius:20px}
.kpi .trend.up{background:var(--ok-bg); color:var(--ok)}
.kpi .trend.down{background:var(--danger-bg); color:var(--danger)}
.ic.b{background:var(--brand-50); color:var(--brand-600)}
.ic.g{background:var(--ok-bg); color:var(--ok)}
.ic.w{background:var(--warn-bg); color:var(--warn)}
.ic.d{background:var(--danger-bg); color:var(--danger)}
.ic.i{background:var(--info-bg); color:var(--info)}
.ic.p{background:var(--purple-bg); color:var(--purple)}
.ic.mute{background:#EEF0F2; color:var(--ink-500)}

.card{background:var(--surface); border:1px solid var(--line); border-radius:var(--r-lg); box-shadow:var(--sh-sm)}
.card__head{display:flex; align-items:center; justify-content:space-between; padding:18px 22px; border-bottom:1px solid var(--line)}
.card__head h3{font-size:16px; font-weight:800}
.card__head .more{color:var(--brand-600); font-size:13px; font-weight:700}
.card__body{padding:22px}

/* Pipeline (foundry flow) */
.pipeline{display:flex; align-items:stretch; gap:0; flex-wrap:wrap}
.pstage{flex:1; min-width:120px; position:relative; padding:6px}
.pstage__inner{
  background:var(--surface-2); border:1px solid var(--line); border-radius:var(--r); padding:16px 14px; text-align:center; height:100%;
  transition:.2s var(--ease);
}
.pstage:hover .pstage__inner{border-color:var(--brand-300); background:var(--brand-50)}
.pstage .pico{width:40px; height:40px; border-radius:12px; display:grid; place-items:center; margin:0 auto 10px; background:#fff; box-shadow:var(--sh-sm)}
.pstage .pico svg{width:22px;height:22px}
.pstage .pcount{font-size:24px; font-weight:800}
.pstage .pname{font-size:12.5px; color:var(--ink-500); font-weight:700; margin-top:2px}
.pstage .parrow{position:absolute; inset-inline-start:-10px; top:50%; transform:translateY(-50%); color:var(--line-strong); z-index:2}
[dir="rtl"] .pstage .parrow{transform:translateY(-50%) scaleX(-1)}

/* ==========================================================================
   TABLE
   ========================================================================== */
.toolbar{display:flex; gap:10px; align-items:center; flex-wrap:wrap; margin-bottom:16px}
.toolbar .search{margin:0; width:280px}
.select, .toolbar input[type=date]{
  padding:9px 13px; border:1.5px solid var(--line-strong); border-radius:11px; background:var(--surface);
  font-family:inherit; font-size:13.5px; color:var(--ink-700);
}
.select:focus, .toolbar input:focus{outline:none; border-color:var(--brand)}
.tablewrap{overflow:auto; border-radius:var(--r-lg)}
table{width:100%; border-collapse:collapse; background:var(--surface); font-size:13.8px}
thead th{
  background:var(--surface-2); text-align:start; padding:14px 16px; font-weight:700; color:var(--ink-500);
  font-size:12.5px; white-space:nowrap; border-bottom:1px solid var(--line-strong); position:sticky; top:0;
}
tbody td{padding:13px 16px; border-bottom:1px solid var(--line); vertical-align:middle}
tbody tr{transition:.12s var(--ease)}
tbody tr:hover{background:var(--brand-50)}
tbody tr:last-child td{border-bottom:none}
.cell-strong{font-weight:700}
.cell-code{font-family:"Consolas",monospace; font-weight:700; color:var(--brand-700); background:var(--brand-50); padding:3px 8px; border-radius:7px; font-size:12.5px}
.cell-mini{color:var(--ink-400); font-size:12px}
.thumb{width:42px; height:42px; border-radius:10px; object-fit:cover; background:var(--surface-2); border:1px solid var(--line); display:grid; place-items:center; color:var(--ink-300)}
.av-sm{width:32px; height:32px; border-radius:50%; background:var(--molten); color:#fff; display:inline-grid; place-items:center; font-weight:700; font-size:12px}
.cust-cell{display:flex; align-items:center; gap:10px}

/* Badges */
.badge{display:inline-flex; align-items:center; gap:6px; padding:4px 11px; border-radius:30px; font-size:12px; font-weight:700; white-space:nowrap}
.badge::before{content:""; width:7px; height:7px; border-radius:50%; background:currentColor}
.b-new{background:var(--info-bg); color:var(--info)}
.b-info{background:var(--info-bg); color:var(--info)}
.b-prog{background:var(--brand-50); color:var(--brand-600)}
.b-ok{background:var(--ok-bg); color:var(--ok)}
.b-warn{background:var(--warn-bg); color:var(--warn)}
.b-danger{background:var(--danger-bg); color:var(--danger)}
.b-mute{background:#EEF0F2; color:var(--ink-500)}
.b-purple{background:var(--purple-bg); color:var(--purple)}
.b-hot{background:#FDEBE6; color:#E0431E}

.t-actions{display:flex; gap:6px}
.t-actions .ib{width:32px; height:32px; border-radius:9px; display:grid; place-items:center; background:var(--surface-2); border:1px solid var(--line); color:var(--ink-500); transition:.14s var(--ease)}
.t-actions .ib:hover{color:var(--brand-600); border-color:var(--brand-200); background:var(--brand-50)}
.t-actions .ib.danger:hover{color:var(--danger); background:var(--danger-bg)}
.t-actions .ib svg{width:16px; height:16px}

/* Progress bars in cells */
.qbar{display:flex; align-items:center; gap:9px; min-width:140px}
.qbar .track{flex:1; height:7px; background:var(--line); border-radius:10px; overflow:hidden}
.qbar .fill{height:100%; border-radius:10px; background:var(--molten)}
.qbar .pct{font-size:12px; font-weight:700; color:var(--ink-500); min-width:34px}

/* pagination */
.pager{display:flex; align-items:center; justify-content:space-between; padding:14px 4px 0; color:var(--ink-500); font-size:13px}
.pager .pages{display:flex; gap:6px}
.pager .pg{width:34px; height:34px; border-radius:9px; display:grid; place-items:center; border:1px solid var(--line-strong); background:var(--surface); font-weight:700; font-size:13px; cursor:pointer; transition:.15s var(--ease)}
.pager .pg:hover{border-color:var(--brand-300); color:var(--brand-600)}
.pager .pg.active{background:var(--molten); color:#fff; border-color:transparent; cursor:default}
.pager .pg.disabled{opacity:.4; pointer-events:none; cursor:default}

/* Activity feed */
.feed{display:flex; flex-direction:column; gap:2px}
.feed__item{display:flex; gap:13px; padding:12px 4px; position:relative}
.feed__item:not(:last-child)::after{content:""; position:absolute; inset-inline-start:18px; top:42px; bottom:-2px; width:2px; background:var(--line)}
.feed__dot{width:38px; height:38px; border-radius:11px; display:grid; place-items:center; flex-shrink:0; z-index:2}
.feed__dot svg{width:18px; height:18px}
.feed__c .tt{font-weight:700; font-size:13.8px}
.feed__c .mt{color:var(--ink-400); font-size:12px; margin-top:2px}

/* Alerts list */
.alert-i{display:flex; gap:12px; align-items:center; padding:13px 14px; border-radius:13px; background:var(--surface-2); border:1px solid var(--line); margin-bottom:10px}
.alert-i .ai{width:38px; height:38px; border-radius:11px; display:grid; place-items:center; flex-shrink:0}
.alert-i .ac{flex:1}
.alert-i .ac .tt{font-weight:700; font-size:13.5px}
.alert-i .ac .mt{color:var(--ink-400); font-size:12px}

/* Order detail pipeline track */
.flow{display:flex; gap:0; margin:6px 0 8px}
.flow__step{flex:1; text-align:center; position:relative}
.flow__step .node{width:44px; height:44px; border-radius:50%; display:grid; place-items:center; margin:0 auto; background:var(--surface); border:2.5px solid var(--line-strong); color:var(--ink-300); position:relative; z-index:2; transition:.2s}
.flow__step .node svg{width:20px;height:20px}
.flow__step .lbl{font-size:12.5px; font-weight:700; margin-top:8px; color:var(--ink-400)}
.flow__step .sub{font-size:11px; color:var(--ink-300)}
.flow__step::before{content:""; position:absolute; top:22px; inset-inline-end:50%; inset-inline-start:-50%; height:3px; background:var(--line-strong); z-index:1}
.flow__step:first-child::before{display:none}
.flow__step.done .node{background:var(--ok); border-color:var(--ok); color:#fff}
.flow__step.done .lbl{color:var(--ink-700)}
.flow__step.done::before{background:var(--ok)}
.flow__step.active .node{background:var(--molten); border-color:transparent; color:#fff; box-shadow:var(--sh-brand); transform:scale(1.08)}
.flow__step.active .lbl{color:var(--brand-700)}
.flow__step.active::before{background:linear-gradient(90deg,var(--ok),var(--brand))}

.two-col{display:grid; grid-template-columns:1.6fr 1fr; gap:18px}
.three-col{display:grid; grid-template-columns:repeat(3,1fr); gap:18px}
.info-row{display:flex; justify-content:space-between; padding:11px 0; border-bottom:1px dashed var(--line)}
.info-row:last-child{border-bottom:none}
.info-row .k{color:var(--ink-500); font-size:13.5px}
.info-row .v{font-weight:700; font-size:13.5px}

/* Empty / placeholder pages */
.soon{text-align:center; padding:70px 20px}
.soon .si{width:84px; height:84px; border-radius:24px; background:var(--molten-soft); color:var(--brand-600); display:grid; place-items:center; margin:0 auto 20px}
.soon .si svg{width:40px; height:40px}
.soon h2{font-size:20px; font-weight:800}
.soon p{color:var(--ink-500); max-width:420px; margin:10px auto 0}

/* Toast */
.toast{
  position:fixed; inset-block-end:26px; inset-inline-start:26px; background:var(--ink); color:#fff;
  padding:14px 20px; border-radius:14px; box-shadow:var(--sh-lg); display:flex; align-items:center; gap:12px;
  font-weight:600; font-size:14px; transform:translateY(140%); transition:.35s var(--ease); z-index:90;
}
.toast.show{transform:translateY(0)}
.toast .ti{width:30px;height:30px;border-radius:9px;background:var(--molten);display:grid;place-items:center}

/* sidebar toggle (mobile) */
.menu-btn{display:none}
.scrim{display:none}

/* ==========================================================================
   RESPONSIVE
   ========================================================================== */
@media (max-width:1100px){
  .kpis{grid-template-columns:repeat(2,1fr)}
  .two-col,.three-col{grid-template-columns:1fr}
}
@media (max-width:860px){
  .auth{grid-template-columns:1fr}
  .auth__brandside{display:none}
  :root{--sidebar-w:0px}
  .sidebar{transform:translateX(-110%); width:268px; box-shadow:var(--sh-lg)}
  [dir="rtl"] .sidebar{transform:translateX(110%)}
  .sidebar.open{transform:translateX(0)}
  .topbar{inset-inline:0}
  .main{margin-inline-start:0}
  .menu-btn{display:grid}
  .search{display:none}
  .scrim.show{display:block; position:fixed; inset:0; background:rgba(0,0,0,.4); z-index:35}
  .page{padding:18px 16px 50px}
}
@media (max-width:560px){
  .kpis{grid-template-columns:1fr}
  .user-chip .nm{display:none}
}
