@import url('https://cdn.jsdelivr.net/gh/rastikerdar/vazirmatn@v33.003/Vazirmatn-font-face.css');
*{box-sizing:border-box;}
body{margin:0;font-family:'Vazirmatn',Tahoma,Arial,sans-serif;background:#f3f5f8;color:#222;}
a{text-decoration:none;color:inherit;}

.layout{display:flex;min-height:100vh;}
.sidebar{width:230px;background:#1f2937;color:#fff;display:flex;flex-direction:column;padding:18px 0;flex-shrink:0;}
.sidebar .brand{padding:0 14px 14px;border-bottom:1px solid #374151;margin-bottom:10px;}
.sidebar .brand-title{padding:0 4px 12px;font-size:16px;font-weight:bold;}
.sidebar nav{flex:1;display:flex;flex-direction:column;gap:2px;overflow-y:auto;overflow-x:hidden;}
.sidebar nav a{display:flex;align-items:center;gap:5px;padding:12px 18px;color:#cbd5e1;font-size:14px;border-right:3px solid transparent;}
.sidebar nav a:hover{background:#2a3548;color:#fff;}
.sidebar nav a.active{background:#2a3548;color:#fff;border-right-color:#3b82f6;}
.user-box{padding:14px 18px;border-top:1px solid #374151;font-size:13px;display:flex;justify-content:space-between;align-items:center;}
.user-box a{color:#f87171;}

.content{flex:1;min-width:0;width:calc(100% - 230px);padding:88px 24px 24px;max-width:1200px;}

.alert{padding:12px 16px;border-radius:8px;margin-bottom:18px;font-size:14px;}
.alert-success{background:#dcfce7;color:#166534;}
.alert-error{background:#fee2e2;color:#991b1b;}
.alert-warning{background:#fef9c3;color:#854d0e;}

.cards{display:grid;grid-template-columns:repeat(auto-fit,minmax(190px,1fr));gap:16px;margin-bottom:24px;}
.card{background:#fff;border-radius:12px;padding:18px;box-shadow:0 1px 3px rgba(0,0,0,.08);}
.card .num{font-size:26px;font-weight:bold;color:#1f2937;}
.card .label{color:#6b7280;font-size:13px;margin-top:4px;}
.card.warn .num{color:#dc2626;}

h1,h2,h3{color:#1f2937;}
.page-title{display:flex;justify-content:space-between;align-items:center;margin-bottom:18px;}

table{width:100%;border-collapse:collapse;background:#fff;border-radius:10px;overflow:hidden;box-shadow:0 1px 3px rgba(0,0,0,.08);}
th,td{padding:10px 12px;text-align:right;font-size:13.5px;border-bottom:1px solid #eef0f3;}
th{background:#f9fafb;color:#374151;font-weight:600;}
tr:hover td{background:#fafbfc;}

.badge{display:inline-block;padding:3px 10px;border-radius:20px;font-size:12px;font-weight:600;}
.badge-in{background:#dcfce7;color:#166534;}
.badge-out{background:#fee2e2;color:#991b1b;}
.badge-loan_out{background:#fef3c7;color:#92400e;}
.badge-loan_return{background:#dbeafe;color:#1e40af;}
.badge-adjust{background:#ede9fe;color:#5b21b6;}
.badge-order_deduct{background:#fce7f3;color:#9d174d;}
.badge-delivery_record{background:#f0fdf4;color:#166534;}
.badge-stock_sync{background:#e0f2fe;color:#075985;}

.btn{display:inline-block;padding:9px 18px;border-radius:8px;border:none;cursor:pointer;font-size:14px;font-family:inherit;}
.btn-primary{background:#2563eb;color:#fff;}
.btn-primary:hover{background:#1d4ed8;}
.btn-success{background:#16a34a;color:#fff;}
.btn-danger{background:#dc2626;color:#fff;}
.btn-secondary{background:#e5e7eb;color:#374151;}
.btn-sm{padding:5px 12px;font-size:12px;}

form.box, .panel{background:#fff;padding:22px;border-radius:12px;box-shadow:0 1px 3px rgba(0,0,0,.08);max-width:600px;}
label{display:block;margin:14px 0 6px;font-size:13.5px;color:#444;}
input[type=text],input[type=number],input[type=search],input[type=password],input[type=date],select,textarea{
  width:100%;padding:10px;border:1px solid #ddd;border-radius:7px;font-family:inherit;font-size:14px;
}
.filters{display:flex;gap:10px;flex-wrap:wrap;margin-bottom:16px;background:#fff;padding:14px;border-radius:10px;}
.filters > div{flex:1;min-width:140px;}
.filters label{margin-top:0;}

.tabs{display:flex;gap:6px;margin-bottom:16px;}
.tabs a{padding:8px 16px;border-radius:8px;background:#fff;font-size:13.5px;color:#444;}
.tabs a.active{background:#2563eb;color:#fff;}

.text-muted{color:#9ca3af;}
.text-success{color:#166534;font-weight:600;}
.status-processing{background:#dbeafe;color:#1e40af;}
.status-completed{background:#dcfce7;color:#166534;}
.status-on-hold{background:#fef3c7;color:#92400e;}
.status-cancelled{background:#e5e7eb;color:#374151;}
.status-refunded{background:#ede9fe;color:#5b21b6;}
.status-failed{background:#fee2e2;color:#991b1b;}
.flex{display:flex;gap:10px;align-items:center;}
.mt{margin-top:16px;}
.right{float:left;}
.pagination{display:flex;gap:6px;margin-top:14px;}
.pagination a,.pagination span{padding:6px 12px;background:#fff;border-radius:6px;font-size:13px;}
.pagination .active{background:#2563eb;color:#fff;}

/* ===== تقویم شمسی ===== */
.jdp-popup{background:#fff;border-radius:10px;box-shadow:0 6px 24px rgba(0,0,0,.18);padding:10px;width:240px;z-index:9999;font-size:13px;}
.jdp-head{display:flex;justify-content:space-between;align-items:center;margin-bottom:8px;font-weight:600;}
.jdp-nav{background:#f1f5f9;border:none;border-radius:6px;width:26px;height:26px;cursor:pointer;font-size:14px;}
.jdp-week{display:grid;grid-template-columns:repeat(7,1fr);text-align:center;color:#9ca3af;margin-bottom:4px;}
.jdp-days{display:grid;grid-template-columns:repeat(7,1fr);gap:2px;}
.jdp-day{text-align:center;padding:6px 0;border-radius:6px;cursor:pointer;}
.jdp-day:hover{background:#2563eb;color:#fff;}
.jdp-foot{text-align:center;margin-top:8px;}
.jdp-today{background:#eef2ff;color:#2563eb;border:none;border-radius:6px;padding:5px 14px;cursor:pointer;font-size:12px;}

/* ===== همبرگری و ریسپانسیو ===== */
.hamburger{
  display:none;
  flex-direction:column;
  justify-content:center;
  align-items:center;
  gap:5px;
  background:transparent;
  border:none;
  cursor:pointer;
  padding:6px;
  width:40px;
  height:40px;
}
.hamburger span{
  display:block;
  width:24px;
  height:2px;
  background:#fff;
  border-radius:2px;
  transition:all .25s ease;
}
.hamburger.open span:nth-child(1){transform:translateY(7px) rotate(45deg);}
.hamburger.open span:nth-child(2){opacity:0;}
.hamburger.open span:nth-child(3){transform:translateY(-7px) rotate(-45deg);}

.topbar{display:grid;grid-template-columns:minmax(220px,1fr) auto minmax(220px,1fr);grid-template-areas:'user license start';align-items:center;gap:16px;background:#fff;color:#1f2937;padding:10px 22px;position:fixed;top:0;right:230px;left:0;min-height:64px;z-index:1000;border-bottom:1px solid #e5e7eb;box-shadow:0 2px 10px rgba(15,23,42,.06)}
.topbar-start{grid-area:start;display:flex;align-items:center;gap:10px;min-width:0}.topbar-title{font-size:15px;font-weight:700;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.topbar-license{grid-area:license;display:flex;align-items:center;justify-content:center;gap:8px;font-size:13px;white-space:nowrap}.topbar-user{grid-area:user;display:flex;align-items:center;justify-content:flex-end;gap:9px;min-width:0}.topbar-user-text{display:grid;line-height:1.45;text-align:left}.topbar-user-text strong{font-size:13px;white-space:nowrap}.topbar-user-text small{font-size:11px;color:#64748b}.topbar-logout{color:#dc2626;border:1px solid #fecaca;background:#fff1f2;border-radius:7px;padding:6px 10px;font-size:12px}.license-pill{padding:5px 9px;border-radius:999px;background:#e2e8f0;color:#334155;font-weight:700}.license-active{background:#dcfce7;color:#166534}.license-expired,.license-suspended{background:#fee2e2;color:#991b1b}.license-scheduled{background:#fef3c7;color:#854d0e}.license-unlimited{background:#e0e7ff;color:#3730a3}
.sidebar-overlay{display:none;position:fixed;inset:0;background:rgba(0,0,0,.4);z-index:1001;}

@media (max-width: 900px){
  .layout{flex-direction:column;}
  .topbar{
    grid-template-columns:auto minmax(0,1fr);grid-template-areas:'user start' 'license license';gap:5px 10px;
    background:#1f2937;color:#fff;padding:7px 12px;right:0;min-height:82px;z-index:1001;
  }
  .topbar-title{font-size:13px;font-weight:bold;}.topbar-license{font-size:11px;justify-content:flex-start;width:100%;overflow-x:auto}.topbar-license-separator{display:none}.topbar-user-text{display:none}.topbar-logout{padding:5px 8px}.license-pill{padding:3px 7px}
  .hamburger{display:flex;}
  .sidebar{
    position:fixed;top:0;right:-260px;height:100%;width:240px;z-index:1002;
    transition:right .25s ease;box-shadow:2px 0 12px rgba(0,0,0,.2);
    overflow-y:auto;overflow-x:hidden;-webkit-overflow-scrolling:touch;
  }
  .sidebar nav{flex:0 0 auto;padding-bottom:12px;}
  .sidebar.open{right:0;}
  .sidebar-overlay.open{display:block;}
  .content{width:100%;padding:98px 14px 14px;max-width:100%;}
  .cards{grid-template-columns:repeat(auto-fit,minmax(140px,1fr));gap:10px;}
  table{display:block;overflow-x:auto;white-space:nowrap;}
  .filters{flex-direction:column;}
  .filters > div{width:100%;}
  form.box,.panel{max-width:100%;padding:16px;}
  .page-title{flex-direction:column;align-items:flex-start;gap:10px;}
  .tabs{overflow-x:auto;flex-wrap:nowrap;}
}
@media (max-width: 480px){
  .card .num{font-size:20px;}
  .btn{padding:8px 12px;font-size:13px;}
}

/* ===== منوی تودرتو و راهنمای هر صفحه ===== */
.sidebar-menu-group{display:block}.sidebar-group-toggle{width:100%;border:0;border-right:3px solid transparent;background:transparent;color:#cbd5e1;padding:12px 14px 12px 12px;font:700 13.5px 'Vazirmatn',Tahoma,sans-serif;cursor:pointer;display:flex;align-items:center;justify-content:space-between;text-align:right}.sidebar-group-toggle:hover,.sidebar-menu-group.active>.sidebar-group-toggle{background:#273449;color:#fff}.sidebar-menu-group.active>.sidebar-group-toggle{border-right-color:#3b82f6}.sidebar-group-label,.sidebar-group-side{display:flex;align-items:center;gap:7px}.sidebar-chevron{font-size:16px;transition:transform .18s}.sidebar-menu-group.open .sidebar-chevron{transform:rotate(180deg)}.sidebar-submenu{display:none;background:#182231;padding:3px 0}.sidebar-menu-group.open .sidebar-submenu{display:block}.sidebar-submenu a{padding:9px 27px 9px 12px!important;font-size:12.5px!important;border-right-width:2px!important}.sidebar-submenu .menu-action-badge,.sidebar nav>a .menu-action-badge{margin-right:auto}.sidebar-group-badge{padding:1px 7px;font-size:10px}
.topbar-help{border:1px solid #bfdbfe;background:#eff6ff;color:#1d4ed8;border-radius:7px;padding:6px 10px;font:700 12px 'Vazirmatn',Tahoma,sans-serif;cursor:pointer;white-space:nowrap}.page-help-modal{display:none;position:fixed;inset:0;z-index:5000;align-items:center;justify-content:center;padding:18px}.page-help-modal.open{display:flex}.page-help-backdrop{position:absolute;inset:0;border:0;background:rgba(15,23,42,.62)}.page-help-dialog{position:relative;width:min(820px,96vw);max-height:88vh;overflow:auto;background:#fff;border-radius:14px;box-shadow:0 22px 70px rgba(0,0,0,.3)}.page-help-dialog>header{position:sticky;top:0;z-index:1;background:#fff;display:flex;justify-content:space-between;align-items:center;padding:15px 18px;border-bottom:1px solid #e5e7eb}.page-help-dialog>header h2{margin:0;font-size:19px}.page-help-dialog>header button{border:0;background:#f1f5f9;border-radius:50%;font-size:22px;width:36px;height:36px;cursor:pointer}.page-help-dialog>footer{padding:12px 18px;border-top:1px solid #e5e7eb}.managed-rich-content{padding:20px;line-height:2;overflow-wrap:anywhere}.managed-rich-content img,.managed-rich-content video{max-width:100%;height:auto;border-radius:9px}.managed-rich-content audio{width:100%;max-width:600px}.managed-rich-content table{display:table;white-space:normal}.managed-rich-content a{color:#2563eb;text-decoration:underline}
@media(max-width:900px){.topbar-help{padding:5px 7px;font-size:11px}.sidebar-group-toggle{min-height:44px}.sidebar-submenu a{min-height:42px}.page-help-modal{padding:8px}.page-help-dialog{max-height:94vh}}

/* ===== جستجوی زنده محصول (Autocomplete) ===== */
.ac-wrap{position:relative;}
.ac-results{position:absolute;top:100%;right:0;left:0;background:#fff;border-radius:8px;box-shadow:0 6px 20px rgba(0,0,0,.15);max-height:280px;overflow-y:auto;z-index:50;margin-top:4px;display:none;}
.ac-results.show{display:block;}
.ac-item{padding:10px 12px;cursor:pointer;border-bottom:1px solid #f1f5f9;font-size:13.5px;}
.ac-item:hover{background:#f3f4f6;}
.ac-item .muted{color:#9ca3af;font-size:12px;}

/* ===== نوار پیشرفت ===== */
.progress-wrap{background:#eef0f3;border-radius:20px;height:22px;overflow:hidden;margin:14px 0;}
.progress-bar{background:linear-gradient(90deg,#2563eb,#3b82f6);height:100%;width:0%;transition:width .3s;display:flex;align-items:center;justify-content:center;color:#fff;font-size:12px;}
.sync-log{background:#0f172a;color:#a3e635;font-family:monospace;font-size:12px;border-radius:8px;padding:10px;max-height:180px;overflow-y:auto;margin-top:10px;}

/* ===== برچسب مرحله و وضعیت ===== */
.stage-badge{display:inline-block;padding:4px 12px;border-radius:20px;font-size:12px;background:#e0e7ff;color:#3730a3;}
.status-publish{background:#dcfce7;color:#166534;}
.status-draft{background:#fef3c7;color:#92400e;}
.status-pending{background:#fee2e2;color:#991b1b;}
.status-private{background:#e5e7eb;color:#374151;}

/* ===== بنر نصب PWA ===== */
#pwaInstallBanner{
  position:fixed;bottom:0;right:0;left:0;
  background:#1f2937;color:#fff;
  padding:14px 16px;
  z-index:9999;
  box-shadow:0 -4px 20px rgba(0,0,0,.3);
  animation:slideUp .35s ease;
}
@keyframes slideUp{from{transform:translateY(100%)}to{transform:translateY(0)}}
.pwa-banner-inner{
  display:flex;align-items:center;gap:12px;max-width:560px;margin:0 auto;
}
.pwa-icon{width:48px;height:48px;border-radius:12px;flex-shrink:0;}
.pwa-text{flex:1;display:flex;flex-direction:column;gap:2px;}
.pwa-text strong{font-size:14px;}
.pwa-text span{font-size:12px;color:#94a3b8;}
.pwa-btns{display:flex;gap:8px;flex-shrink:0;}
.pwa-btn-yes{
  padding:9px 18px;background:#3b82f6;color:#fff;
  border:none;border-radius:8px;font-size:13px;cursor:pointer;
  font-family:inherit;white-space:nowrap;
}
.pwa-btn-yes:hover{background:#2563eb;}
.pwa-btn-no{
  padding:9px 14px;background:transparent;color:#94a3b8;
  border:1px solid #374151;border-radius:8px;font-size:13px;cursor:pointer;
  font-family:inherit;white-space:nowrap;
}
.pwa-btn-no:hover{color:#fff;border-color:#6b7280;}
@media(max-width:480px){
  .pwa-banner-inner{flex-wrap:wrap;}
  .pwa-btns{width:100%;justify-content:flex-end;}
}

/* ===== یادآوری کارها/یادداشت‌ها ===== */
#taskReminderToast{
  position:fixed;bottom:20px;left:20px;z-index:9999;max-width:340px;
  animation:taskToastIn .25s ease-out;
}
@keyframes taskToastIn{from{opacity:0;transform:translateY(15px)}to{opacity:1;transform:translateY(0)}}
.task-toast-inner{
  background:#1f2937;color:#f3f4f6;border-radius:12px;padding:16px;
  box-shadow:0 10px 30px rgba(0,0,0,.35);border:1px solid #374151;
}
.task-toast-head{font-weight:700;margin-bottom:8px;font-size:14px;}
.task-toast-list{max-height:160px;overflow-y:auto;font-size:13px;color:#d1d5db;margin-bottom:12px;}
.task-toast-item{padding:4px 0;border-bottom:1px solid #374151;}
.task-toast-item:last-child{border-bottom:none;}
.task-toast-btns{display:flex;gap:8px;justify-content:flex-end;}
@media(max-width:480px){
  #taskReminderToast{left:10px;right:10px;bottom:10px;max-width:none;}
}

/* ===== Notification Bell & Panel ===== */
.notif-bell, .notif-bell-desk {
  position:relative;background:transparent;border:none;cursor:pointer;
  font-size:20px;padding:4px 8px;border-radius:8px;color:#fff;line-height:1;
}
.notif-bell:hover,.notif-bell-desk:hover{background:rgba(255,255,255,.15);}
.notif-bell-desk{font-size:18px;padding:3px 6px;}
.notif-badge{
  background:#dc2626;color:#fff;border-radius:10px;font-size:10px;
  padding:1px 5px;font-weight:700;vertical-align:super;
}
#notifPanelBox{
  position:fixed;top:60px;left:14px;width:300px;background:#fff;border-radius:12px;
  box-shadow:0 8px 30px rgba(0,0,0,.18);padding:16px;z-index:1600;max-height:400px;overflow-y:auto;
}
.notif-item{
  padding:10px 0;border-bottom:1px solid #f3f4f6;cursor:pointer;
}
.notif-item:hover{background:#f9fafb;}
.notif-item:last-child{border:none;}
.notif-title{font-size:13.5px;font-weight:600;color:#1f2937;}
.notif-msg{font-size:12px;color:#6b7280;margin-top:2px;}
.notif-time{font-size:11px;color:#9ca3af;margin-top:3px;}
.notif-toast{
  background:#1f2937;color:#fff;padding:13px 16px;border-radius:10px;
  box-shadow:0 4px 20px rgba(0,0,0,.3);font-family:Tahoma,sans-serif;
  font-size:13.5px;border-right:4px solid #3b82f6;direction:rtl;
  opacity:0;transform:translateX(-20px);transition:all .3s ease;
}
.notif-toast.show{opacity:1;transform:translateX(0);}

/* ===== دکمه برگشت موبایل ===== */
#mobileBackBtn {
  display: none;
  position: fixed;
  bottom: 22px;
  right: 50%;
  transform: translateX(50%);
  z-index: 1200;
  background: #1f2937;
  color: #fff;
  border: none;
  border-radius: 28px;
  padding: 12px 28px;
  font-size: 16px;
  font-family: inherit;
  cursor: pointer;
  box-shadow: 0 4px 18px rgba(0,0,0,.28);
  display: none;
  align-items: center;
  gap: 8px;
  transition: background .15s, transform .1s;
  -webkit-tap-highlight-color: transparent;
}
#mobileBackBtn:active { background: #374151; transform: translateX(50%) scale(.96); }
@media (max-width: 900px) {
  #mobileBackBtn { display: flex; }
  .content { padding-bottom: 72px; } /* فضا برای دکمه */
}
@media (min-width: 901px) {
  #mobileBackBtn { display: none !important; }
}
