/* ============================================================
   کارخانه‌یار — استایل اصلی
   طراحی و ساخت: مهندس بیره‌وهـر معروفی
   ============================================================ */
@font-face {
  font-family: 'Vazirmatn';
  src: url('../fonts/Vazirmatn-Regular.woff2') format('woff2');
  font-weight: 400; font-display: swap;
}
@font-face {
  font-family: 'Vazirmatn';
  src: url('../fonts/Vazirmatn-Medium.woff2') format('woff2');
  font-weight: 500; font-display: swap;
}
@font-face {
  font-family: 'Vazirmatn';
  src: url('../fonts/Vazirmatn-Bold.woff2') format('woff2');
  font-weight: 700; font-display: swap;
}

:root {
  --bg: #eef1f7;
  --card: #ffffff;
  --ink: #1e293b;
  --muted: #64748b;
  --line: #e2e8f0;
  --brand: #4f46e5;
  --brand-2: #7c3aed;
  --ok: #059669;
  --ok-bg: #ecfdf5;
  --warn: #d97706;
  --warn-bg: #fffbeb;
  --bad: #dc2626;
  --bad-bg: #fef2f2;
  --info: #0284c7;
  --info-bg: #f0f9ff;
  --radius: 14px;
  --shadow: 0 1px 3px rgba(15, 23, 42, .07), 0 8px 24px rgba(15, 23, 42, .05);
  --font: 'Vazirmatn', 'Tahoma', 'Segoe UI', sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink);
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
}
button { font-family: var(--font); cursor: pointer; }
input, select, textarea { font-family: var(--font); font-size: .95rem; }
a { color: var(--brand); }

::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 9px; }
::-webkit-scrollbar-track { background: transparent; }

/* ---------- آیکون ---------- */
.ic { width: 20px; height: 20px; fill: currentColor; flex: none; vertical-align: middle; }
.ic.sm { width: 16px; height: 16px; }
.ic.lg { width: 28px; height: 28px; }

/* ---------- دکمه‌ها ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  background: #fff; color: var(--ink);
  border: 1px solid var(--line); border-radius: 10px;
  padding: 9px 16px; font-size: .9rem; font-weight: 500;
  transition: all .15s; white-space: nowrap;
}
.btn:hover { border-color: #cbd5e1; background: #f8fafc; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: linear-gradient(135deg, var(--brand), var(--brand-2)); color: #fff; border: none; box-shadow: 0 4px 14px rgba(79, 70, 229, .35); }
.btn-primary:hover { filter: brightness(1.07); background: linear-gradient(135deg, var(--brand), var(--brand-2)); }
.btn-danger { background: var(--bad-bg); color: var(--bad); border-color: #fecaca; }
.btn-danger:hover { background: #fee2e2; border-color: #fca5a5; }
.btn-ok { background: var(--ok-bg); color: var(--ok); border-color: #a7f3d0; }
.btn-ok:hover { background: #d1fae5; }
.btn-warn { background: var(--warn-bg); color: var(--warn); border-color: #fde68a; }
.btn-warn:hover { background: #fef3c7; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn-ghost:hover { background: #f1f5f9; color: var(--ink); }
.btn-sm { padding: 5px 10px; font-size: .82rem; border-radius: 8px; }
.btn-block { width: 100%; justify-content: center; padding: 12px; }
.btn-light { background: rgba(255,255,255,.92); color: var(--ink); border: none; }

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 38px; height: 38px; border-radius: 10px;
  border: 1px solid var(--line); background: #fff; color: var(--muted);
  transition: all .15s;
}
.icon-btn:hover { color: var(--brand); border-color: #c7d2fe; background: #eef2ff; }
.icon-btn:disabled { opacity: .4; cursor: not-allowed; }

.chip-btn {
  display: inline-flex; align-items: center; gap: 6px;
  border: 1px solid var(--line); background: #fff; color: var(--muted);
  border-radius: 999px; padding: 6px 13px; font-size: .82rem; font-weight: 500;
  transition: all .15s;
}
.chip-btn:hover { color: var(--ok); border-color: #a7f3d0; background: var(--ok-bg); }
.chip-btn.off { color: var(--bad); background: var(--bad-bg); border-color: #fecaca; }

.spin {
  width: 15px; height: 15px; border: 2px solid rgba(255,255,255,.35);
  border-top-color: #fff; border-radius: 50%;
  display: inline-block; animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- فرم‌ها ---------- */
.frow { margin-bottom: 14px; }
.flabel { display: block; font-size: .84rem; font-weight: 600; color: #475569; margin-bottom: 6px; }
.req { color: var(--bad); }
.fhint { font-size: .75rem; color: var(--muted); margin-top: 4px; }
input, select, textarea {
  width: 100%; padding: 9px 12px;
  border: 1.5px solid var(--line); border-radius: 10px;
  background: #fff; color: var(--ink); outline: none;
  transition: border .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--brand); box-shadow: 0 0 0 3px rgba(79, 70, 229, .13);
}
textarea { resize: vertical; }
.fform { padding-top: 4px; }
.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 0; cursor: pointer; font-size: .9rem; font-weight: 500; }
.switch-row input { display: none; }
.sw { width: 46px; height: 26px; border-radius: 999px; background: #cbd5e1; position: relative; transition: background .2s; flex: none; }
.sw::after { content: ''; position: absolute; width: 20px; height: 20px; border-radius: 50%; background: #fff; top: 3px; right: 3px; transition: all .2s; box-shadow: 0 1px 3px rgba(0,0,0,.25); }
.switch-row input:checked + .sw { background: var(--ok); }
.switch-row input:checked + .sw::after { right: 23px; }

.imgpick { display: flex; align-items: center; gap: 10px; }
.imgpick .ip-img { width: 64px; height: 64px; border-radius: 12px; object-fit: cover; border: 1px solid var(--line); background: #f8fafc; }

/* ---------- توست ---------- */
.toast-wrap { position: fixed; bottom: 18px; left: 18px; z-index: 2000; display: flex; flex-direction: column; gap: 8px; }
.toast {
  display: flex; align-items: center; gap: 10px;
  background: #1e293b; color: #fff; padding: 11px 16px; border-radius: 12px;
  box-shadow: 0 10px 30px rgba(0,0,0,.25); font-size: .86rem; max-width: 340px;
  animation: toastIn .25s ease;
  border-right: 4px solid var(--info);
}
.toast-ok { border-right-color: var(--ok); }
.toast-bad { border-right-color: var(--bad); }
.toast-warn { border-right-color: var(--warn); }
.toast.out { opacity: 0; transform: translateY(8px); transition: all .35s; }
@keyframes toastIn { from { opacity: 0; transform: translateY(12px); } }

/* ---------- مودال ---------- */
.modal-overlay {
  position: fixed; inset: 0; z-index: 1500;
  background: rgba(15, 23, 42, .55); backdrop-filter: blur(3px);
  display: flex; align-items: center; justify-content: center; padding: 18px;
  animation: fadeIn .18s ease;
}
.modal-overlay.closing { opacity: 0; transition: opacity .18s; }
@keyframes fadeIn { from { opacity: 0; } }
.modal {
  background: var(--card); border-radius: 18px; width: 100%;
  max-height: 92vh; display: flex; flex-direction: column;
  box-shadow: 0 25px 60px rgba(2, 6, 23, .35);
  animation: modalIn .22s cubic-bezier(.2, .9, .3, 1.2);
}
@keyframes modalIn { from { opacity: 0; transform: translateY(18px) scale(.97); } }
.modal-s { max-width: 430px; }
.modal-m { max-width: 640px; }
.modal-l { max-width: 900px; }
.modal-xl { max-width: 1180px; }
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; border-bottom: 1px solid var(--line);
}
.modal-title { font-size: 1.02rem; font-weight: 700; }
.modal-body { padding: 18px 20px; overflow-y: auto; }
.modal-foot { padding: 13px 20px; border-top: 1px solid var(--line); display: flex; gap: 8px; justify-content: flex-start; }
.confirm-msg { font-size: .95rem; padding: 6px 0; }
.resolve-options { display: flex; flex-direction: column; gap: 8px; margin-top: 14px; }

/* ---------- جدول ---------- */
.tbl-wrap { width: 100%; }
.scroll-x { overflow-x: auto; }
.tbl { width: 100%; border-collapse: collapse; font-size: .87rem; }
.tbl th {
  text-align: right; padding: 10px 12px; background: #f8fafc;
  color: #475569; font-size: .8rem; font-weight: 700; white-space: nowrap;
  border-bottom: 2px solid var(--line);
}
.tbl td { padding: 9px 12px; border-bottom: 1px solid #f1f5f9; vertical-align: middle; }
.tbl tbody tr { transition: background .12s; }
.tbl tbody tr:hover { background: #f8fafc; }
.tbl .num { text-align: left; font-variant-numeric: tabular-nums; direction: ltr; }
.tbl .empty-cell { text-align: center; color: var(--muted); padding: 34px; font-size: .9rem; }
.row-warn td { background: #fffbeb; }
.row-bad td { background: #fef2f2; }
.row-ok td { background: #f0fdf4; }
.row-actions { display: flex; gap: 5px; flex-wrap: wrap; }

/* صفحه‌بندی */
.pager { display: flex; align-items: center; justify-content: space-between; padding: 12px 4px 2px; gap: 10px; flex-wrap: wrap; }
.pager-info { font-size: .8rem; color: var(--muted); }
.pager-btns { display: flex; align-items: center; gap: 6px; }
.pager-cur { font-size: .82rem; color: #475569; font-weight: 600; min-width: 60px; text-align: center; }

/* ---------- نشان‌ها ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 10px; border-radius: 999px; font-size: .75rem; font-weight: 600; white-space: nowrap;
}
.badge-gray { background: #f1f5f9; color: #475569; }
.badge-primary { background: #eef2ff; color: var(--brand); }
.badge-ok { background: var(--ok-bg); color: var(--ok); }
.badge-warn { background: var(--warn-bg); color: var(--warn); }
.badge-bad { background: var(--bad-bg); color: var(--bad); }
.badge-info { background: var(--info-bg); color: var(--info); }
.badge-violet { background: #f5f3ff; color: #7c3aed; }
.badge-pink { background: #fdf2f8; color: #db2777; }

/* ---------- سربرگ صفحه ---------- */
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; margin-bottom: 18px; flex-wrap: wrap; }
.page-title { font-size: 1.35rem; font-weight: 800; }
.page-sub { color: var(--muted); font-size: .85rem; margin-top: 2px; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- کارت‌ها ---------- */
.card {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 18px; margin-bottom: 16px;
}
.card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; gap: 10px; flex-wrap: wrap; }
.card-title { font-size: .98rem; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.card-title .tic { color: var(--brand); }

/* ---------- شاخص‌ها ---------- */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 15px; display: flex; align-items: center; gap: 13px;
}
.kpi-ic { width: 46px; height: 46px; border-radius: 13px; display: flex; align-items: center; justify-content: center; flex: none; }
.kpi-v { font-size: 1.2rem; font-weight: 800; line-height: 1.3; }
.kpi-l { font-size: .78rem; color: var(--muted); }

/* ---------- تب‌ها ---------- */
.tabs { display: flex; gap: 6px; border-bottom: 2px solid var(--line); margin-bottom: 16px; overflow-x: auto; }
.tab {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 9px 16px; border: none; background: transparent;
  font-size: .88rem; font-weight: 600; color: var(--muted);
  border-bottom: 3px solid transparent; margin-bottom: -2px; white-space: nowrap;
  transition: all .15s;
}
.tab:hover { color: var(--ink); }
.tab.active { color: var(--brand); border-bottom-color: var(--brand); }
.tab.active .ic { fill: var(--brand); }

/* ---------- جستجو و فیلتر ---------- */
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.toolbar .grow { flex: 1; min-width: 180px; }
.search-box { position: relative; }
.search-box .ic { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); width: 17px; height: 17px; }
.search-box input { padding-right: 38px; }
.sel-sm { width: auto; min-width: 150px; padding: 8px 10px; }

/* ---------- پوسته ---------- */
.shell { display: flex; min-height: 100vh; }
.sidebar {
  width: 258px; flex: none; background: linear-gradient(180deg, #1e1b4b 0%, #312e81 45%, #4f46e5 100%);
  color: #e0e7ff; display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
}
.side-brand { display: flex; align-items: center; gap: 12px; padding: 18px 16px 14px; }
.brand-logo {
  width: 52px; height: 52px; border-radius: 15px; flex: none;
  background: linear-gradient(135deg, #f59e0b, #ef4444);
  color: #fff; display: flex; align-items: center; justify-content: center;
  box-shadow: 0 6px 18px rgba(245, 158, 11, .45);
}
.brand-logo .ic { width: 30px; height: 30px; }
.brand-logo.sm { width: 42px; height: 42px; border-radius: 12px; }
.brand-logo.sm .ic { width: 24px; height: 24px; }
.side-brand-name { font-weight: 800; font-size: 1.05rem; color: #fff; }
.side-brand-sub { font-size: .7rem; color: #a5b4fc; letter-spacing: .5px; }

.side-nav { flex: 1; overflow-y: auto; padding: 6px 10px 12px; display: flex; flex-direction: column; gap: 3px; }
.side-item {
  display: flex; align-items: center; gap: 11px; width: 100%;
  background: transparent; border: none; border-radius: 11px;
  color: #c7d2fe; padding: 9px 10px; font-size: .88rem; font-weight: 500;
  text-align: right; transition: all .15s;
}
.side-item:hover { background: rgba(255, 255, 255, .09); color: #fff; }
.side-item.active { background: #fff; color: var(--ink); font-weight: 700; box-shadow: 0 4px 14px rgba(0,0,0,.25); }
.side-ic {
  width: 34px; height: 34px; border-radius: 9px; flex: none;
  display: flex; align-items: center; justify-content: center;
  background: color-mix(in srgb, var(--c) 22%, transparent);
  color: var(--c);
}
.side-item.active .side-ic { background: color-mix(in srgb, var(--c) 16%, white); }
.side-ic .ic { width: 18px; height: 18px; }

.side-foot { padding: 12px 14px; border-top: 1px solid rgba(255,255,255,.12); }
.side-credit { font-size: .72rem; color: #a5b4fc; line-height: 1.7; display: flex; align-items: flex-start; gap: 6px; }
.side-credit .ic { width: 14px; height: 14px; margin-top: 3px; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 100;
  display: flex; align-items: center; gap: 12px;
  background: rgba(255, 255, 255, .88); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
  padding: 10px 22px;
}
.top-title { font-weight: 800; font-size: 1.02rem; flex: 1; }
.top-actions { display: flex; gap: 8px; align-items: center; }
.menu-btn { display: none; }

.offline-banner {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  background: linear-gradient(90deg, #7f1d1d, #dc2626); color: #fff;
  padding: 10px 22px; font-size: .84rem;
}
.offline-banner .ic { width: 18px; height: 18px; }

.content { padding: 22px; max-width: 1500px; width: 100%; margin: 0 auto; }
.page-loading { display: flex; justify-content: center; padding: 70px; }
.page-loading .spin { width: 34px; height: 34px; border-width: 3px; border-color: #c7d2fe; border-top-color: var(--brand); }

.denied {
  text-align: center; padding: 80px 20px; color: var(--muted);
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
}
.denied .ic { width: 56px; height: 56px; fill: #cbd5e1; }
.denied h2 { color: var(--ink); margin: 12px 0 6px; }
.denied .btn { margin-top: 18px; }

/* ---------- صفحه لاگین ---------- */
.login-page { display: flex; min-height: 100vh; }
.login-brand {
  flex: 1; background: linear-gradient(160deg, #1e1b4b 0%, #312e81 45%, #6d28d9 100%);
  color: #fff; display: flex; flex-direction: column; justify-content: center;
  padding: 50px; position: relative; overflow: hidden;
}
.login-brand::before {
  content: ''; position: absolute; width: 420px; height: 420px; border-radius: 50%;
  background: radial-gradient(circle, rgba(255,255,255,.12), transparent 70%);
  top: -120px; left: -120px;
}
.login-brand::after {
  content: ''; position: absolute; width: 300px; height: 300px; border-radius: 50%;
  background: radial-gradient(circle, rgba(245,158,11,.22), transparent 70%);
  bottom: -80px; right: -60px;
}
.login-brand h1 { font-size: 2.4rem; font-weight: 800; margin: 18px 0 6px; }
.login-brand p { color: #c7d2fe; font-size: .95rem; }
.brand-feats { margin-top: 28px; display: grid; gap: 10px; max-width: 300px; }
.brand-feats span { display: flex; align-items: center; gap: 10px; color: #e0e7ff; font-size: .87rem; }
.brand-feats .ic { fill: #fbbf24; width: 18px; height: 18px; }
.brand-credit { position: absolute; bottom: 22px; right: 50px; font-size: .78rem; color: #a5b4fc; }

.login-form-side { width: 460px; flex: none; display: flex; flex-direction: column; justify-content: center; align-items: center; padding: 34px; background: var(--bg); }
.login-card { background: var(--card); border-radius: 20px; box-shadow: var(--shadow); padding: 32px; width: 100%; max-width: 400px; }
.login-card h2 { display: flex; align-items: center; gap: 9px; font-size: 1.15rem; margin-bottom: 20px; }
.login-card h2 .ic { fill: var(--brand); }
.login-hint { font-size: .74rem; color: var(--muted); margin-top: 12px; text-align: center; }
.login-foot { font-size: .72rem; color: var(--muted); margin-top: 18px; }

.demo-box { margin-top: 22px; border-top: 1px dashed var(--line); padding-top: 16px; }
.demo-title { font-size: .8rem; font-weight: 600; color: #475569; margin-bottom: 10px; text-align: center; }
.demo-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 7px; }
.demo-user {
  border: 1px solid var(--line); background: #fff; border-radius: 11px;
  padding: 8px 4px; font-size: .72rem; font-weight: 600; color: #475569;
  display: flex; flex-direction: column; align-items: center; gap: 5px; transition: all .15s;
}
.demo-user:hover { border-color: var(--dc); color: var(--dc); transform: translateY(-2px); box-shadow: var(--shadow); }
.demo-avatar {
  width: 30px; height: 30px; border-radius: 50%; background: color-mix(in srgb, var(--dc) 16%, white);
  color: var(--dc); display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: .85rem;
}

/* ---------- داشبورد ---------- */
.welcome-card {
  background: linear-gradient(120deg, #4f46e5, #7c3aed);
  color: #fff; border-radius: var(--radius); padding: 24px 26px;
  display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap;
  box-shadow: 0 10px 30px rgba(79, 70, 229, .35); margin-bottom: 16px;
}
.welcome-card h2 { font-size: 1.3rem; font-weight: 800; }
.welcome-card p { color: #e0e7ff; font-size: .86rem; margin-top: 3px; }
.welcome-date { background: rgba(255,255,255,.15); border-radius: 12px; padding: 10px 16px; font-size: .85rem; font-weight: 600; }

.feed-item { display: flex; gap: 11px; padding: 9px 4px; border-bottom: 1px dashed var(--line); font-size: .85rem; }
.feed-item:last-child { border-bottom: none; }
.feed-dot { width: 9px; height: 9px; border-radius: 50%; margin-top: 8px; flex: none; }
.feed-time { color: var(--muted); font-size: .72rem; white-space: nowrap; }

/* ---------- پیش‌فاکتور ---------- */
.pf-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.pf-totals { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin-top: 14px; }
.pf-total {
  background: #f8fafc; border: 1px solid var(--line); border-radius: 12px;
  padding: 10px 13px; text-align: center;
}
.pf-total .t-l { font-size: .72rem; color: var(--muted); }
.pf-total .t-v { font-weight: 800; font-size: 1rem; margin-top: 2px; }
.pf-total.grand { background: linear-gradient(135deg, var(--brand), var(--brand-2)); color: #fff; border: none; }
.pf-total.grand .t-l { color: #e0e7ff; }
.pf-item-row { display: grid; grid-template-columns: 2.2fr 1fr 1fr .9fr 1.1fr 1.1fr 0.6fr; gap: 8px; align-items: center; margin-bottom: 8px; }
.pf-item-row .btn { justify-content: center; }

/* ---------- وظایف ---------- */
.task-card {
  border: 1px solid var(--line); border-radius: 13px; padding: 13px 15px;
  background: #fff; transition: all .15s; display: flex; flex-direction: column; gap: 7px;
}
.task-card:hover { box-shadow: var(--shadow); border-color: #c7d2fe; }
.task-title { font-weight: 700; font-size: .9rem; }
.task-meta { display: flex; gap: 12px; flex-wrap: wrap; font-size: .74rem; color: var(--muted); }
.task-meta span { display: inline-flex; align-items: center; gap: 4px; }
.msg-bubble { border: 1px solid var(--line); border-radius: 12px; padding: 9px 13px; margin-bottom: 8px; font-size: .86rem; background: #f8fafc; }
.msg-bubble.mine { background: #eef2ff; border-color: #c7d2fe; }
.msg-meta { font-size: .7rem; color: var(--muted); margin-top: 4px; display: flex; gap: 8px; align-items: center; }

/* ---------- آزمایشگاه ---------- */
.chart-box { background: #fff; border: 1px solid var(--line); border-radius: 13px; padding: 14px; }
.chart-box svg { width: 100%; height: auto; }
.legend { display: flex; gap: 16px; font-size: .76rem; color: var(--muted); margin-top: 8px; flex-wrap: wrap; }
.legend i { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-left: 5px; vertical-align: -1px; }

/* ---------- تنظیمات ---------- */
.settings-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 16px; }
.set-card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; }
.set-card h3 { display: flex; align-items: center; gap: 8px; font-size: .95rem; margin-bottom: 14px; color: #334155; }
.set-card h3 .ic { fill: var(--brand); }
.access-matrix { width: 100%; border-collapse: collapse; font-size: .78rem; }
.access-matrix th { padding: 7px 5px; text-align: center; background: #f8fafc; border: 1px solid var(--line); white-space: nowrap; }
.access-matrix td { padding: 6px 5px; text-align: center; border: 1px solid var(--line); }
.access-matrix td:first-child { text-align: right; font-weight: 600; white-space: nowrap; }
.access-matrix input { width: 16px; height: 16px; accent-color: var(--brand); }

/* ---------- پروفایل ---------- */
.profile-head { display: flex; align-items: center; gap: 14px; margin-bottom: 16px; }
.profile-avatar {
  width: 64px; height: 64px; border-radius: 50%; background: linear-gradient(135deg, var(--brand), var(--brand-2));
  color: #fff; display: flex; align-items: center; justify-content: center;
  font-size: 1.6rem; font-weight: 800; overflow: hidden; flex: none;
}
.profile-avatar img { width: 100%; height: 100%; object-fit: cover; }
.profile-name { font-weight: 800; font-size: 1.05rem; }
.profile-role { margin-top: 4px; }

/* ---------- متفرقه ---------- */
.empty { text-align: center; padding: 40px 10px; color: var(--muted); }
.empty-ic { width: 60px; height: 60px; margin: 0 auto 12px; background: #f1f5f9; border-radius: 50%; display: flex; align-items: center; justify-content: center; }
.empty-ic .ic { width: 28px; height: 28px; fill: #94a3b8; }

.stock-qty { font-weight: 700; }
.stock-neg { color: var(--bad); font-weight: 800; }
.stock-pos { color: var(--ok); }

.pri-badge {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 30px; height: 30px; border-radius: 9px;
  background: linear-gradient(135deg, #f59e0b, #f97316); color: #fff;
  font-weight: 800; font-size: .82rem; box-shadow: 0 3px 8px rgba(245,158,11,.4);
}

.mini-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 12px; }
.plan-row { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; margin-bottom: 8px; background: #fff; }
.plan-row .grow { flex: 1; min-width: 0; }

/* ---------- ریسپانسیو ---------- */
.mobile-fab { display: none; }
@media (max-width: 1024px) {
  .sidebar {
    position: fixed; right: 0; top: 0; z-index: 900;
    transform: translateX(105%); transition: transform .25s ease; box-shadow: 0 0 60px rgba(0,0,0,.35);
  }
  body.sidebar-open .sidebar { transform: translateX(0); }
  .menu-btn { display: inline-flex; }
  .mobile-fab {
    display: flex; position: fixed; bottom: 18px; right: 18px; z-index: 850;
    width: 54px; height: 54px; border-radius: 50%; border: none;
    background: linear-gradient(135deg, var(--brand), var(--brand-2)); color: #fff;
    align-items: center; justify-content: center; box-shadow: 0 8px 24px rgba(79,70,229,.45);
  }
  .login-page { flex-direction: column; }
  .login-brand { padding: 34px 26px; align-items: center; text-align: center; }
  .login-brand h1 { font-size: 1.8rem; }
  .brand-feats { display: none; }
  .brand-credit { position: static; margin-top: 16px; }
  .login-form-side { width: 100%; padding: 26px 16px; }
}
@media (max-width: 640px) {
  html { font-size: 14px; }
  .content { padding: 14px 12px; }
  .topbar { padding: 9px 12px; }
  .chip-btn span { display: none; }
  .pf-grid { grid-template-columns: 1fr; }
  .pf-item-row { grid-template-columns: 1fr 1fr; }
  .demo-grid { grid-template-columns: repeat(4, 1fr); }
  .kpis { grid-template-columns: repeat(2, 1fr); }
  .modal { max-height: 96vh; }
  .page-head { flex-direction: column; }
}

/* ---------- تکمیلی ---------- */
.muted-sm { font-size: .74rem; color: var(--muted); font-weight: 400; }
.num { direction: ltr; font-variant-numeric: tabular-nums; text-align: left; }

.usr-cell { display: flex; align-items: center; gap: 9px; }
.usr-av {
  width: 36px; height: 36px; border-radius: 50%; flex: none;
  background: linear-gradient(135deg, #6366f1, #a855f7); color: #fff;
  display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: .9rem;
  overflow: hidden;
}
.usr-av.sm { width: 28px; height: 28px; font-size: .75rem; }
.usr-av img { width: 100%; height: 100%; object-fit: cover; }
.usr-un { font-size: .72rem; color: var(--muted); direction: ltr; text-align: right; }

.color-chip { display: inline-block; width: 14px; height: 14px; border-radius: 4px; border: 1px solid #cbd5e1; vertical-align: -2px; margin-left: 5px; }

.op-note {
  display: flex; align-items: flex-start; gap: 8px;
  background: var(--info-bg); color: #075985; border: 1px solid #bae6fd;
  border-radius: 11px; padding: 9px 13px; font-size: .8rem; margin-bottom: 12px;
}
.op-note .ic { fill: var(--info); width: 17px; height: 17px; margin-top: 2px; flex: none; }

.op-form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 0 14px; }

.access-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 7px; }
.access-item {
  display: flex; align-items: center; gap: 8px; padding: 7px 9px;
  border: 1.5px solid var(--line); border-radius: 10px; cursor: pointer; font-size: .8rem; font-weight: 500;
  transition: all .12s; user-select: none;
}
.access-item:hover { border-color: #c7d2fe; }
.access-item input { width: 16px; height: 16px; accent-color: var(--brand); flex: none; }
.acc-ic {
  width: 26px; height: 26px; border-radius: 8px; flex: none;
  display: flex; align-items: center; justify-content: center;
  background: color-mix(in srgb, var(--c) 18%, transparent); color: var(--c);
}
.acc-ic .ic { width: 15px; height: 15px; }

.cell-wrap { display: flex; align-items: center; gap: 4px; }
.cell-input { padding: 6px 8px; min-width: 92px; text-align: left; direction: ltr; font-size: .82rem; }
.cell-paste {
  border: none; background: #eef2ff; color: var(--brand); width: 26px; height: 26px;
  border-radius: 7px; display: inline-flex; align-items: center; justify-content: center; flex: none;
  transition: all .12s;
}
.cell-paste:hover { background: var(--brand); color: #fff; }
.cell-paste .ic { width: 14px; height: 14px; }
.paste-hint {
  display: flex; align-items: flex-start; gap: 8px;
  background: #fffbeb; border: 1px solid #fde68a; color: #92400e;
  border-radius: 11px; padding: 8px 13px; font-size: .78rem; margin-bottom: 12px;
}
.paste-hint .ic { fill: var(--warn); width: 16px; height: 16px; margin-top: 2px; flex: none; }

code { background: #f1f5f9; border-radius: 6px; padding: 1px 7px; font-size: .8rem; direction: ltr; display: inline-block; }

/* ---------- جدول دسترسی کاربران (مشاهده/ویرایش/محدوده) ---------- */
.acc-table { display: flex; flex-direction: column; gap: 5px; margin: 8px 0; }
.acc-row {
  display: grid; grid-template-columns: 1.7fr .6fr .6fr 1.1fr; gap: 8px; align-items: center;
  padding: 5px 9px; border: 1.5px solid var(--line); border-radius: 10px; background: #fff;
}
.acc-row.acc-head { background: #f8fafc; font-weight: 700; font-size: .74rem; color: #475569; border-color: var(--line); }
.acc-name { display: flex; align-items: center; gap: 7px; font-size: .8rem; font-weight: 600; min-width: 0; }
.acc-name .acc-ic { width: 24px; height: 24px; border-radius: 7px; flex: none; display: flex; align-items: center; justify-content: center; background: color-mix(in srgb, var(--c) 18%, transparent); color: var(--c); }
.acc-name .acc-ic .ic { width: 14px; height: 14px; }
.acc-row select { padding: 5px 6px; font-size: .74rem; width: 100%; }
.acc-row input[type=checkbox] { width: 17px; height: 17px; accent-color: var(--brand); }

/* ---------- انتخاب رنگ ---------- */
.color-pick-row { display: flex; align-items: center; gap: 10px; }
input[type=color] { width: 58px; height: 40px; padding: 2px; border: 1.5px solid var(--line); border-radius: 9px; background: #fff; cursor: pointer; }
.color-preview { width: 36px; height: 36px; border-radius: 9px; border: 1px solid var(--line); flex: none; }

/* ---------- ماتریس دسترسی نقش‌ها (تنظیمات) ---------- */
.access-matrix select { width: auto; min-width: 86px; padding: 4px 6px; font-size: .72rem; }

.ver-badge {
  font-size: .68rem; font-weight: 700; color: var(--brand);
  background: #eef2ff; border: 1px solid #c7d2fe; border-radius: 999px;
  padding: 2px 9px; white-space: nowrap;
}

/* ---------- سلکت جستجو‌دار (ss) ---------- */
.ss { position: relative; min-width: 170px; }
.ss-input { width: 100%; cursor: text; }
.ss-list {
  position: absolute; top: calc(100% + 4px); right: 0; left: 0; z-index: 1200;
  background: #fff; border: 1.5px solid var(--line); border-radius: 11px;
  box-shadow: 0 12px 32px rgba(15,23,42,.16); max-height: 240px; overflow-y: auto; padding: 5px;
}
.ss-opt {
  display: block; width: 100%; text-align: right; border: none; background: transparent;
  padding: 8px 11px; border-radius: 8px; font-size: .83rem; color: var(--ink); cursor: pointer;
}
.ss-opt:hover { background: #eef2ff; color: var(--brand); }
.ss-opt.sel { background: #eef2ff; color: var(--brand); font-weight: 700; }
.ss-empty { padding: 10px; text-align: center; color: var(--muted); font-size: .78rem; }
.ss-host { min-width: 170px; }

/* ---------- تقویم شمسی ---------- */
.jdate { position: relative; display: inline-block; min-width: 170px; }
.jdate-input { cursor: pointer; background: #fff; }
.jdate-pop {
  position: absolute; top: calc(100% + 4px); right: 0; z-index: 1200;
  background: #fff; border: 1.5px solid var(--line); border-radius: 13px;
  box-shadow: 0 14px 36px rgba(15,23,42,.18); padding: 10px; width: 248px;
}
.jd-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 7px; }
.jd-title { font-weight: 800; font-size: .88rem; color: #334155; }
.jd-nav {
  width: 28px; height: 28px; border-radius: 8px; border: 1px solid var(--line);
  background: #fff; color: var(--muted); display: inline-flex; align-items: center; justify-content: center;
}
.jd-nav:hover { color: var(--brand); border-color: #c7d2fe; background: #eef2ff; }
.jd-nav .ic { width: 16px; height: 16px; }
.jd-week { display: grid; grid-template-columns: repeat(7, 1fr); text-align: center; margin-bottom: 4px; }
.jd-week span { font-size: .68rem; font-weight: 700; color: var(--muted); padding: 4px 0; }
.jd-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.jd-day {
  border: none; background: transparent; border-radius: 8px; padding: 6px 0;
  font-size: .78rem; color: var(--ink); cursor: pointer;
}
.jd-day:hover { background: #eef2ff; color: var(--brand); }
.jd-day.sel { background: var(--brand); color: #fff; font-weight: 700; }
.jd-foot { display: flex; gap: 6px; margin-top: 8px; }
.jd-act {
  flex: 1; border: 1px solid var(--line); background: #f8fafc; border-radius: 8px;
  padding: 5px 0; font-size: .72rem; color: #475569; cursor: pointer;
}
.jd-act:hover { border-color: #c7d2fe; color: var(--brand); }

/* ---------- انتخاب نوع عملیات (ورود/خروج) ---------- */
.dir-picker { display: flex; gap: 8px; }
.dir-opt {
  flex: 1; display: flex; align-items: center; justify-content: center; gap: 7px;
  border: 2px solid var(--line); border-radius: 11px; padding: 10px 8px; cursor: pointer;
  font-size: .84rem; font-weight: 600; color: var(--muted); background: #fff; transition: all .15s; user-select: none;
}
.dir-opt input { display: none; }
.dir-opt .ic { width: 18px; height: 18px; }
.dir-opt.in:hover { border-color: #a7f3d0; background: var(--ok-bg); color: var(--ok); }
.dir-opt.out:hover { border-color: #fecaca; background: var(--bad-bg); color: var(--bad); }
.dir-opt.in:has(input:checked) { border-color: var(--ok); background: var(--ok-bg); color: var(--ok); box-shadow: 0 3px 10px rgba(5,150,105,.18); }
.dir-opt.out:has(input:checked) { border-color: var(--bad); background: var(--bad-bg); color: var(--bad); box-shadow: 0 3px 10px rgba(220,38,38,.15); }

/* ---------- نوتیفیکیشن ---------- */
.notif-btn { position: relative; }
.notif-badge {
  position: absolute; top: -6px; left: -6px;
  min-width: 19px; height: 19px; border-radius: 999px;
  background: #ef4444; color: #fff; font-size: .66rem; font-weight: 800;
  display: inline-flex; align-items: center; justify-content: center;
  padding: 0 5px; border: 2px solid #fff; line-height: 1;
}
.notif-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border: 1px solid var(--line); border-radius: 11px;
  margin-bottom: 7px; background: #fff; transition: all .12s;
}
.notif-item:hover { border-color: #c7d2fe; box-shadow: var(--shadow); }
.notif-item.unread { background: #eef2ff; border-color: #c7d2fe; }
.notif-dot { width: 9px; height: 9px; border-radius: 50%; background: #cbd5e1; flex: none; }
.notif-item.unread .notif-dot { background: #ef4444; }

/* ---------- تایم‌لاین بازه زمانی وظایف ---------- */
.task-timeline {
  border: 1px solid var(--line); border-radius: 13px; padding: 13px 15px; margin-top: 12px;
  background: #f8fafc;
}
.tl-row { display: flex; align-items: flex-start; flex-wrap: wrap; gap: 0; }
.tl-step { display: flex; flex-direction: column; align-items: center; text-align: center; min-width: 84px; }
.tl-dot {
  width: 13px; height: 13px; border-radius: 50%; background: var(--brand);
  border: 3px solid #c7d2fe; margin: 0 auto 5px; flex: none;
}
.tl-label { font-size: .72rem; font-weight: 700; color: #475569; }
.tl-time { font-size: .68rem; color: var(--muted); direction: ltr; }
.tl-line { flex: 1; min-width: 26px; height: 2px; background: #c7d2fe; margin-top: 5px; }

/* ---------- صفحه ورود (لاگین) ---------- */
.login-page {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh; padding: 24px 16px;
  background: linear-gradient(160deg, #1e1b4b 0%, #312e81 45%, #6d28d9 100%);
  background-attachment: fixed;
}
.login-wrap { width: 100%; max-width: 440px; }
.login-card {
  background: #fff; border-radius: 22px; padding: 30px 30px 20px;
  box-shadow: 0 30px 70px rgba(2, 6, 23, .45);
  animation: loginIn .4s cubic-bezier(.2, .9, .3, 1.1);
}
@keyframes loginIn { from { opacity: 0; transform: translateY(18px) scale(.97); } }
.login-company { text-align: center; margin-bottom: 16px; }
.login-logo-box { display: flex; justify-content: center; margin-bottom: 10px; }
.login-logo-img {
  max-width: 120px; max-height: 120px; object-fit: contain;
  border-radius: 16px; border: 1px solid var(--line); padding: 4px; background: #fff;
}
.brand-logo.lg { width: 84px; height: 84px; border-radius: 20px; }
.brand-logo.lg .ic { width: 46px; height: 46px; }
.login-company-name { font-size: 1.3rem; font-weight: 800; color: #1e293b; line-height: 1.5; }
.login-company-sub { font-size: .76rem; color: var(--muted); margin-top: 2px; }
.login-conn-row { display: flex; align-items: center; justify-content: center; gap: 8px; margin-bottom: 16px; }
.login-conn-row .chip-btn { background: var(--ok-bg); color: var(--ok); border-color: #a7f3d0; }
.login-conn-row .chip-btn.off { background: var(--bad-bg); color: var(--bad); border-color: #fecaca; }
.login-brand-line {
  display: flex; align-items: center; justify-content: center; gap: 7px;
  margin-top: 18px; padding-top: 14px; border-top: 1px dashed var(--line);
  font-size: .82rem; font-weight: 700; color: #4c1d95;
}
.login-brand-line .ic { fill: #7c3aed; width: 17px; height: 17px; }
.login-foot { text-align: center; margin-top: 14px; font-size: .8rem; color: #e0e7ff; font-weight: 500; }
.demo-box2 { margin-top: 18px; }
.demo-box2 .demo-title { color: #c7d2fe; }
.demo-box2 .demo-user { background: rgba(255,255,255,.07); border-color: rgba(255,255,255,.15); color: #e0e7ff; }
.demo-box2 .demo-user:hover { border-color: var(--dc); color: #fff; }

/* ---------- نشان وضعیت سرور ---------- */
.srv-chip.ok { background: var(--ok-bg); color: var(--ok); border-color: #a7f3d0; }
.srv-chip.down { background: var(--bad-bg); color: var(--bad); border-color: #fecaca; }
.srv-chip.demo { background: #f1f5f9; color: #64748b; border-color: var(--line); }
.srv-chip .ic { width: 15px; height: 15px; }

/* ---------- عناصر پنهان (مهم!) ----------
   اگر کلاسی display:flex داشته باشد، attribute «hidden» را بی‌اثر می‌کند
   و بنر آفلاین/دکمه همگام‌سازی همیشه نمایش داده می‌شوند.
   این قانون تضمین می‌کند hidden همیشه برنده است. */
[hidden] { display: none !important; }
