:root{
  --ink:#1B2430;
  --ink-soft:#5B6672;
  --bg:#F5F8F9;
  --panel:#FFFFFF;
  --line:#E1E7EA;

  --zone-dirty:#B3413A;
  --zone-dirty-bg:#FBEBE9;
  --zone-wash:#2E6E9E;
  --zone-wash-bg:#EAF1F7;
  --zone-sterile:#177A63;
  --zone-sterile-bg:#E7F5F0;
  --zone-ready:#0B4F5C;
  --zone-ready-bg:#E4EFF0;
  --zone-delivered:#5B6672;
  --zone-delivered-bg:#EEF1F2;

  --brand:#0B4F5C;
  --brand-dark:#08363F;
  --amber:#C97A1E;
  --amber-bg:#FBF1E3;

  --radius:10px;
  --shadow:0 1px 2px rgba(15,30,35,.06), 0 6px 20px -8px rgba(15,30,35,.12);
}
*{box-sizing:border-box;}
html,body{margin:0;padding:0;}
body{
  background:var(--bg);
  color:var(--ink);
  font-family:'Tajawal','IBM Plex Sans Arabic',sans-serif;
  min-height:100vh;
}
h1,h2,h3,.display{font-family:'Cairo','Tajawal',sans-serif;}
.mono, .code, .batch-id{font-family:'IBM Plex Sans Arabic',monospace; letter-spacing:.3px;}

/* ---------- layout ---------- */
.app{display:flex; min-height:100vh;}
.sidebar{
  width:250px; flex:none;
  background:var(--brand-dark);
  color:#fff;
  padding:22px 16px;
  display:flex; flex-direction:column; gap:4px;
  position:sticky; top:0; height:100vh;
}
.brand{
  display:flex; align-items:center; gap:10px;
  padding:0 6px 20px 6px;
  border-bottom:1px solid rgba(255,255,255,.12);
  margin-bottom:16px;
}
.brand .mark{
  width:36px; height:36px; border-radius:9px;
  background:linear-gradient(135deg, var(--zone-sterile), var(--zone-wash));
  display:flex; align-items:center; justify-content:center;
  font-family:'Cairo',sans-serif; font-weight:800; color:#fff; font-size:15px;
  flex:none;
}
.brand .txt{line-height:1.25;}
.brand .txt b{font-family:'Cairo',sans-serif; font-size:14.5px; display:block;}
.brand .txt span{font-size:11px; color:rgba(255,255,255,.6);}

.nav-item{
  display:flex; align-items:center; gap:10px;
  padding:10px 12px; border-radius:8px; cursor:pointer;
  color:rgba(255,255,255,.75); font-size:14px; font-weight:500;
  border:1px solid transparent;
  transition:background .15s;
}
.nav-item .ic{width:18px; text-align:center; font-size:15px; flex:none;}
.nav-item:hover{background:rgba(255,255,255,.06); color:#fff;}
.nav-item.active{background:rgba(255,255,255,.12); color:#fff; border-color:rgba(255,255,255,.1);}
.nav-sep{height:1px; background:rgba(255,255,255,.1); margin:10px 6px;}
.nav-label{font-size:10.5px; color:rgba(255,255,255,.4); padding:8px 12px 2px; text-transform:uppercase; letter-spacing:.6px;}

.side-foot{margin-top:auto; padding-top:14px; border-top:1px solid rgba(255,255,255,.1); font-size:11px; color:rgba(255,255,255,.45);}

.main{flex:1; min-width:0; padding:26px 30px 60px; max-width:1400px;}
.topbar{display:flex; align-items:center; justify-content:space-between; margin-bottom:22px; gap:14px; flex-wrap:wrap;}
.topbar h1{font-size:21px; margin:0 0 3px; font-weight:800;}
.topbar .sub{color:var(--ink-soft); font-size:13px;}
.top-actions{display:flex; gap:8px;}

/* ---------- buttons / inputs ---------- */
button{font-family:inherit; cursor:pointer;}
.btn{
  border:1px solid var(--line); background:#fff; color:var(--ink);
  padding:9px 15px; border-radius:8px; font-size:13.5px; font-weight:600;
  display:inline-flex; align-items:center; gap:7px;
}
.btn:hover{border-color:#c7d0d4;}
.btn.primary{background:var(--brand); border-color:var(--brand); color:#fff;}
.btn.primary:hover{background:var(--brand-dark);}
.btn.sm{padding:6px 10px; font-size:12.5px; border-radius:7px;}
.btn.ghost{background:transparent; border-color:transparent; color:var(--ink-soft);}
.btn.danger{color:#B3413A; border-color:#f0d3d0;}
.btn.danger:hover{background:var(--zone-dirty-bg);}
.btn:disabled{opacity:.4; cursor:not-allowed;}

label{font-size:12.5px; font-weight:600; color:var(--ink-soft); display:block; margin-bottom:5px;}
input[type=text], input[type=number], input[type=date], input[type=time], input[type=datetime-local], select, textarea{
  width:100%; padding:9px 11px; border-radius:8px; border:1px solid var(--line);
  font-family:inherit; font-size:13.5px; background:#fff; color:var(--ink);
}
input:focus, select:focus, textarea:focus{outline:2px solid var(--zone-wash); outline-offset:1px; border-color:transparent;}
.field{margin-bottom:14px;}
.grid2{display:grid; grid-template-columns:1fr 1fr; gap:14px;}
.grid3{display:grid; grid-template-columns:1fr 1fr 1fr; gap:14px;}
@media (max-width:720px){.grid2,.grid3{grid-template-columns:1fr;}}

.card{background:var(--panel); border:1px solid var(--line); border-radius:var(--radius); box-shadow:var(--shadow);}
.card .card-h{padding:16px 18px; border-bottom:1px solid var(--line); display:flex; align-items:center; justify-content:space-between;}
.card .card-h h3{margin:0; font-size:15px; font-weight:700;}
.card .card-b{padding:18px;}

/* ---------- stat cards ---------- */
.stats{display:grid; grid-template-columns:repeat(6,1fr); gap:12px; margin-bottom:22px;}
@media (max-width:1100px){.stats{grid-template-columns:repeat(3,1fr);}}
@media (max-width:640px){.stats{grid-template-columns:repeat(2,1fr);}}
.stat{
  background:#fff; border:1px solid var(--line); border-radius:var(--radius);
  padding:15px 16px; box-shadow:var(--shadow);
  border-top:3px solid var(--line);
}
.stat b{display:block; font-size:26px; font-family:'Cairo',sans-serif; font-weight:800;}
.stat span{font-size:12px; color:var(--ink-soft); font-weight:600;}
.stat.dirty{border-top-color:var(--zone-dirty);}
.stat.wash{border-top-color:var(--zone-wash);}
.stat.sterile{border-top-color:var(--zone-sterile);}
.stat.ready{border-top-color:var(--zone-ready);}
.stat.delivered{border-top-color:var(--zone-delivered);}

/* ---------- pipeline / corridor signature ---------- */
.corridor{
  display:grid; grid-template-columns:repeat(5,1fr); gap:0; margin-bottom:22px;
  border-radius:var(--radius); overflow:hidden; box-shadow:var(--shadow);
}
.corridor .zone{
  padding:13px 14px; position:relative; color:#fff; font-family:'Cairo',sans-serif;
}
.corridor .zone .n{font-size:11px; opacity:.85; font-weight:600;}
.corridor .zone .t{font-size:13.5px; font-weight:800; margin-top:2px;}
.corridor .zone::after{
  content:""; position:absolute; top:0; bottom:0; left:-11px; width:22px;
  background:inherit; transform:skewX(-18deg); z-index:1;
}
.corridor .zone:first-child::after{display:none;}
.corridor .zone > *{position:relative; z-index:2;}
.corridor .z1{background:var(--zone-dirty);}
.corridor .z2{background:var(--zone-wash);}
.corridor .z3{background:var(--zone-sterile);}
.corridor .z4{background:var(--zone-ready);}
.corridor .z5{background:var(--zone-delivered);}

/* ---------- kanban ---------- */
.board{display:grid; grid-template-columns:repeat(7,1fr); gap:10px; align-items:start;}
@media (max-width:1400px){.board{grid-template-columns:repeat(4,1fr);}}
@media (max-width:1024px){.board{grid-template-columns:repeat(3,1fr);}}
@media (max-width:720px){.board{grid-template-columns:1fr 1fr;}}
.col{background:#fff; border:1px solid var(--line); border-radius:var(--radius); overflow:hidden; box-shadow:var(--shadow); min-height:120px;}
.col-h{padding:11px 13px; font-family:'Cairo',sans-serif; font-weight:800; font-size:13px; color:#fff; display:flex; justify-content:space-between; align-items:center;}
.col-h .cnt{background:rgba(255,255,255,.25); border-radius:20px; padding:1px 9px; font-size:11.5px;}
.col.c1 .col-h{background:var(--zone-dirty);}
.col.c2 .col-h{background:var(--zone-wash);}
.col.c3 .col-h{background:var(--zone-sterile);}
.col.c4 .col-h{background:var(--zone-ready);}
.col.c5 .col-h{background:var(--zone-delivered);}
.col-b{padding:9px; display:flex; flex-direction:column; gap:8px; min-height:60px;}
.col-empty{padding:16px 8px; text-align:center; color:#9aa5ab; font-size:12px;}

.b-card{
  border:1px solid var(--line); border-radius:9px; padding:10px 11px; background:#FCFDFD;
}
.b-card .id{font-size:11px; color:var(--ink-soft); font-weight:700;}
.b-card .name{font-size:13.5px; font-weight:700; margin:2px 0 4px;}
.b-card .meta{font-size:11.5px; color:var(--ink-soft); line-height:1.6;}
.b-card .meta i{font-style:normal; color:var(--ink);}
.b-card .actions{margin-top:8px; display:flex; gap:6px; flex-wrap:wrap;}

/* ---------- badges ---------- */
.badge{display:inline-flex; align-items:center; gap:5px; padding:3px 9px; border-radius:20px; font-size:11.5px; font-weight:700;}
.badge.dirty{background:var(--zone-dirty-bg); color:var(--zone-dirty);}
.badge.wash{background:var(--zone-wash-bg); color:var(--zone-wash);}
.badge.sterile{background:var(--zone-sterile-bg); color:var(--zone-sterile);}
.badge.ready{background:var(--zone-ready-bg); color:var(--zone-ready);}
.badge.delivered{background:var(--zone-delivered-bg); color:var(--zone-delivered);}
.badge.warn{background:var(--amber-bg); color:var(--amber);}

/* ---------- table ---------- */
table{width:100%; border-collapse:collapse; font-size:13px;}
th{text-align:right; padding:9px 10px; background:#F0F4F5; color:var(--ink-soft); font-size:11.5px; font-weight:700; border-bottom:1px solid var(--line); white-space:nowrap;}
td{padding:9px 10px; border-bottom:1px solid var(--line); white-space:nowrap;}
tr:hover td{background:#FAFCFC;}
.table-wrap{overflow-x:auto; border-radius:var(--radius); border:1px solid var(--line);}
.table-wrap table{border:none;}
.table-wrap .card-h{border-radius:0;}

/* ---------- modal ---------- */
.overlay{position:fixed; inset:0; background:rgba(15,25,30,.45); display:none; align-items:flex-start; justify-content:center; padding:40px 16px; z-index:50; overflow:auto;}
.overlay.show{display:flex;}
.modal{background:#fff; border-radius:14px; width:100%; max-width:560px; box-shadow:0 20px 60px rgba(0,0,0,.25); overflow:hidden;}
.modal-h{padding:16px 20px; border-bottom:1px solid var(--line); display:flex; justify-content:space-between; align-items:center;}
.modal-h h3{margin:0; font-size:16px; font-weight:800;}
.modal-b{padding:20px; max-height:70vh; overflow:auto;}
.modal-f{padding:14px 20px; border-top:1px solid var(--line); display:flex; justify-content:flex-end; gap:8px;}
.close-x{background:none; border:none; font-size:18px; color:var(--ink-soft); cursor:pointer;}

/* ---------- toast ---------- */
#toast{position:fixed; bottom:22px; left:50%; transform:translateX(-50%) translateY(20px); background:var(--brand-dark); color:#fff; padding:11px 20px; border-radius:9px; font-size:13.5px; font-weight:600; opacity:0; transition:.25s; z-index:100; box-shadow:0 10px 30px rgba(0,0,0,.25);}
#toast.show{opacity:1; transform:translateX(-50%) translateY(0);}

/* ---------- sticker ---------- */
.sticker-wrap{display:flex; gap:22px; flex-wrap:wrap; align-items:flex-start;}
.sticker{
  width:60mm; min-height:40mm; background:#fff; border:1.5px solid var(--ink); border-radius:6px;
  padding:10px 12px; position:relative; overflow:hidden; box-sizing:border-box;
}
.sticker .hazard{
  position:absolute; top:0; right:0; width:60px; height:14px;
  background:repeating-linear-gradient(45deg, var(--zone-sterile), var(--zone-sterile) 6px, #fff 6px, #fff 12px);
}
.sticker .hd{font-family:'Cairo',sans-serif; font-weight:800; font-size:12.5px; color:var(--brand); border-bottom:1.5px solid var(--ink); padding-bottom:5px; margin-bottom:6px; display:flex; justify-content:space-between;}
.sticker .row{display:flex; justify-content:space-between; font-size:11px; padding:2px 0; border-bottom:1px dashed #dfe4e6;}
.sticker .row b{font-weight:700;}
.sticker .row span.v{font-family:'IBM Plex Sans Arabic',monospace; font-weight:600;}
.sticker .bcode{margin-top:7px; height:30px; display:flex; align-items:stretch; gap:1px;}
.sticker .bcode i{flex:none; background:var(--ink); display:block;}
.sticker .bid{text-align:center; font-family:'IBM Plex Sans Arabic',monospace; font-size:11px; letter-spacing:2px; margin-top:2px;}
.sticker .exp{margin-top:6px; background:var(--amber-bg); color:var(--amber); font-size:10.5px; font-weight:700; padding:3px 6px; border-radius:5px; text-align:center;}

@media print{
  body.printing-sticker *{visibility:hidden;}
  body.printing-sticker #printArea, body.printing-sticker #printArea *{visibility:visible;}
  body.printing-sticker #printArea{position:absolute; top:0; right:0; left:0; padding:0; margin:0;}

  body.printing-report *{visibility:hidden;}
  body.printing-report #printArea2, body.printing-report #printArea2 *{visibility:visible;}
  body.printing-report #printArea2{position:absolute; top:0; right:0; left:0; padding:0; margin:0;}

  body:not(.printing-report):not(.printing-sticker) *{visibility:hidden;}
  body:not(.printing-report):not(.printing-sticker) #printArea,
  body:not(.printing-report):not(.printing-sticker) #printArea *{visibility:visible;}

  .sidebar, .topbar, .no-print{display:none !important;}
}

.empty-state{padding:40px 20px; text-align:center; color:var(--ink-soft);}
.empty-state .ic{font-size:30px; margin-bottom:8px;}
.pill-tabs{display:flex; gap:6px; margin-bottom:16px; flex-wrap:wrap;}
.pill-tabs button{border:1px solid var(--line); background:#fff; padding:7px 14px; border-radius:20px; font-size:12.5px; font-weight:600; color:var(--ink-soft);}
.pill-tabs button.active{background:var(--brand); color:#fff; border-color:var(--brand);}
.search-row{display:flex; gap:10px; margin-bottom:14px; flex-wrap:wrap;}
.search-row input, .search-row select{max-width:220px;}
.hint{font-size:11.5px; color:var(--ink-soft); margin-top:4px;}
.list-item{display:flex; justify-content:space-between; align-items:center; padding:9px 4px; border-bottom:1px solid var(--line); font-size:13.5px;}
.list-item:last-child{border-bottom:none;}
.chip-del{color:#B3413A; font-size:12px; cursor:pointer; font-weight:600;}
.section{display:none;}
.section.active{display:block;}

/* ---------- login ---------- */
#loginScreen{position:fixed; inset:0; background:linear-gradient(160deg, var(--brand-dark), #0e5a68 60%, var(--zone-sterile)); display:flex; align-items:center; justify-content:center; z-index:200; padding:16px;}
.login-card{background:#fff; width:100%; max-width:380px; border-radius:16px; padding:30px 28px; box-shadow:0 30px 80px rgba(0,0,0,.35);}
.login-card .mark{width:52px; height:52px; border-radius:13px; background:linear-gradient(135deg, var(--zone-sterile), var(--zone-wash)); display:flex; align-items:center; justify-content:center; color:#fff; font-family:'Cairo',sans-serif; font-weight:800; margin:0 auto 14px;}
.login-card h2{text-align:center; font-size:18px; margin:0 0 2px;}
.login-card .sub{text-align:center; color:var(--ink-soft); font-size:12.5px; margin-bottom:20px;}
.login-err{background:var(--zone-dirty-bg); color:var(--zone-dirty); font-size:12.5px; font-weight:700; padding:8px 10px; border-radius:8px; margin-bottom:12px; display:none;}
.login-err.show{display:block;}
.login-card .btn.primary{width:100%; justify-content:center; padding:10px; margin-top:6px;}
.login-hint{margin-top:16px; padding-top:14px; border-top:1px dashed var(--line); font-size:11px; color:var(--ink-soft); line-height:1.7;}

/* ---------- user badge / roles ---------- */
.user-badge{display:flex; align-items:center; gap:9px; padding:10px 6px; margin-bottom:6px;}
.user-badge .av{width:32px; height:32px; border-radius:50%; background:rgba(255,255,255,.15); display:flex; align-items:center; justify-content:center; font-family:'Cairo',sans-serif; font-weight:800; font-size:13px; flex:none;}
.user-badge .ut b{display:block; font-size:13px;}
.user-badge .ut span{font-size:10.5px; color:rgba(255,255,255,.55);}
.logout-btn{width:100%; text-align:center; background:rgba(255,255,255,.08); border:1px solid rgba(255,255,255,.14); color:rgba(255,255,255,.8); padding:8px; border-radius:8px; font-size:12px; font-weight:700; margin-top:8px;}
.logout-btn:hover{background:rgba(255,255,255,.14); color:#fff;}
.role-tag{font-size:10px; font-weight:800; padding:1px 7px; border-radius:20px;}
.role-tag.admin{background:var(--amber-bg); color:var(--amber);}
.role-tag.staff{background:var(--zone-wash-bg); color:var(--zone-wash);}
.app{display:none;}
.app.ready{display:flex;}

/* ---------- logo ---------- */
.brand .mark img{width:100%; height:100%; object-fit:contain; border-radius:9px;}
.login-card .mark img{width:100%; height:100%; object-fit:contain; border-radius:13px;}
.sticker .hd img{height:22px; object-fit:contain;}
.load-screen{position:fixed; inset:0; background:var(--bg); display:flex; align-items:center; justify-content:center; z-index:150; color:var(--ink-soft); font-weight:700;}
#logoPreview{width:64px; height:64px; border:1px dashed var(--line); border-radius:10px; display:flex; align-items:center; justify-content:center; overflow:hidden; background:#fafcfc;}
#logoPreview img{width:100%; height:100%; object-fit:contain;}

/* ---------- permission checkboxes ---------- */
.perm-grid{display:flex; flex-direction:column; gap:7px; margin-top:4px;}
.perm-chk{display:flex; align-items:center; gap:8px; font-size:13px; font-weight:600; color:var(--ink); cursor:pointer;}
.perm-chk input{width:16px; height:16px; accent-color:var(--brand); cursor:pointer;}
.job-tag{font-size:10.5px; color:var(--ink-soft); background:#F0F4F5; padding:1px 8px; border-radius:20px; font-weight:600;}
.perm-tags{display:flex; gap:4px; flex-wrap:wrap; margin-top:4px;}
.perm-tag{font-size:10px; background:var(--zone-wash-bg); color:var(--zone-wash); padding:1px 7px; border-radius:20px; font-weight:700;}

/* ---------- rejected zone + composition list ---------- */
:root{ --zone-rejected:#7A3B33; --zone-rejected-bg:#F4E7E5; }
.badge.rejected{background:var(--zone-rejected-bg); color:var(--zone-rejected);}
.stat.rejected{border-top-color:var(--zone-rejected);}
.col.c6 .col-h{background:var(--zone-rejected);}

/* ---------- used stage (تم الاستخدام) ---------- */
:root{ --zone-used:#5B5B6B; --zone-used-bg:#ECECF1; }
.badge.used{background:var(--zone-used-bg); color:var(--zone-used);}
.stat.used{border-top-color:var(--zone-used);}
.col.c7 .col-h{background:var(--zone-used);}
.comp-row{display:flex; justify-content:space-between; align-items:center; padding:6px 9px; background:#F7F9FA; border-radius:7px; margin-bottom:5px; font-size:12.5px;}
.comp-row .del{color:var(--zone-dirty); cursor:pointer; font-weight:700; font-size:12px;}
.type-tag{font-size:10px; background:#EFEAFB; color:#6B4FA0; padding:1px 7px; border-radius:20px; font-weight:700;}

/* ---------- alerts banner (تنبيهات) ---------- */
#alertsBanner{display:flex; flex-direction:column; gap:8px; margin-bottom:18px;}
#alertsBanner:empty{display:none;}
.alert-line{padding:11px 15px; border-radius:10px; font-size:13.5px; font-weight:600; line-height:1.7; border:1px solid transparent;}
.alert-line.danger{background:#FBEBE9; color:#B3413A; border-color:#F1C9C4;}
.alert-line.warn{background:#FBF1E3; color:#9A6512; border-color:#F0DDBB;}

/* ---------- maintenance status pills ---------- */
.mstat{font-size:10.5px; padding:1px 8px; border-radius:20px; font-weight:700;}
.mstat.ok{background:var(--zone-ready-bg,#E7F5F0); color:var(--zone-ready,#177A63);}
.mstat.due{background:#FBF1E3; color:#9A6512;}
.mstat.over{background:#FBEBE9; color:#B3413A;}
.bio-pass{color:#177A63; font-weight:700;}
.bio-fail{color:#B3413A; font-weight:700;}
.bio-pending{color:#9A6512; font-weight:700;}
