:root {
  --bg: #eef1f5; --panel: #ffffff; --ink: #2c3e50; --muted: #7f8c8d;
  --primary: #2980b9; --success: #27ae60; --danger: #e74c3c; --secondary: #8e44ad;
  --border: #dfe4ea; --head: #2c3e50; --shadow: 0 2px 10px rgba(0,0,0,.08);
  --radius: 10px;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: Tahoma, "Segoe UI", system-ui, sans-serif;
  background: var(--bg); color: var(--ink); direction: rtl;
  font-size: 14px; line-height: 1.6;
}
h1,h2,h3,h4 { margin: 0 0 .4em; }
button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; font-size: 14px; }

/* ---------- صفحه ورود ---------- */
.screen-auth { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 20px; }
.screen-auth #app { width: 100%; max-width: 420px; }
.auth-card {
  background: var(--panel); border-radius: 16px; box-shadow: var(--shadow);
  padding: 34px 28px; text-align: center;
}
.auth-logo { font-size: 46px; }
.auth-card h1 { font-size: 20px; color: var(--head); }
.auth-sub { color: var(--muted); margin: 0 0 18px; }
.auth-card form { text-align: right; }
.auth-card label { display: block; margin: 14px 0 5px; font-weight: bold; font-size: 13px; }
.auth-card input {
  width: 100%; padding: 11px 12px; border: 1px solid var(--border);
  border-radius: 8px; background: #fbfcfd;
}
.auth-card input:focus { outline: none; border-color: var(--primary); }
.auth-note, .auth-warn { font-size: 12px; margin-top: 16px; }
.auth-note { color: var(--muted); }
.auth-warn { color: #c0392b; background: #fdecea; padding: 8px 10px; border-radius: 8px; }

/* ---------- چیدمان اصلی ---------- */
.topbar {
  background: var(--head); color: #fff; padding: 14px 18px;
  display: flex; align-items: center; justify-content: space-between;
  position: sticky; top: 0; z-index: 20;
}
.brand { font-weight: bold; font-size: 15px; }
.hamburger { display: none; background: transparent; border: none; color: #fff; font-size: 22px; }
.layout { display: flex; align-items: flex-start; }
.sidebar {
  width: 250px; flex-shrink: 0; padding: 14px; height: calc(100vh - 50px);
  overflow-y: auto; position: sticky; top: 50px;
}
.content { flex: 1; padding: 18px; min-width: 0; }
.card { background: var(--panel); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px; margin-bottom: 12px; }
.user-card { text-align: center; }
.user-name { font-weight: bold; }
.user-role { color: var(--muted); margin-bottom: 8px; }
.user-card .btn { margin: 3px 2px; }
.stats-card h4 { color: var(--head); }
.stat-line { padding: 2px 0; font-size: 13px; border-bottom: 1px dashed #eee; }
.side-nav { display: flex; flex-direction: column; gap: 6px; }
.nav-btn {
  text-align: right; padding: 11px 13px; border: 1px solid var(--border);
  background: var(--panel); border-radius: 8px; font-size: 14px; color: var(--ink);
  transition: .15s;
}
.nav-btn:hover { background: #f4f7fb; }
.nav-btn.active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* ---------- سربرگ تب و ابزار ---------- */
.tab-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; flex-wrap: wrap; gap: 8px; }
.tab-head h2 { color: var(--head); font-size: 19px; }
.tab-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.toolbar { margin-bottom: 12px; }
.search { width: 100%; max-width: 380px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px; }
.info-banner { background: #fff3cd; color: #856404; padding: 10px 14px; border-radius: 8px; margin-bottom: 12px; }
.filter-card { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; }

/* ---------- جدول ---------- */
.table-wrap { overflow-x: auto; background: var(--panel); border-radius: var(--radius); box-shadow: var(--shadow); }
table.grid { width: 100%; border-collapse: collapse; min-width: 640px; }
table.grid th, table.grid td { padding: 10px 12px; text-align: center; border-bottom: 1px solid var(--border); white-space: nowrap; }
table.grid thead th { background: #f4f7fb; color: var(--head); font-size: 13px; position: sticky; top: 0; }
table.grid tbody tr:hover { background: #f9fbfd; }
.grid-compact th, .grid-compact td { padding: 5px 8px; }
.grid-compact input { width: 90px; padding: 5px; text-align: center; border: 1px solid var(--border); border-radius: 6px; }
.empty { color: var(--muted); padding: 24px; }
.actions { display: flex; gap: 4px; justify-content: center; }
.mini { border: 1px solid var(--border); background: #fff; border-radius: 6px; padding: 4px 7px; font-size: 14px; }
.mini:hover { background: #eef4fb; }
.mini.danger:hover { background: #fdecea; border-color: var(--danger); }

.badge { padding: 3px 9px; border-radius: 20px; font-size: 12px; white-space: nowrap; }
.b-Pending { background: #fef5e7; color: #b9770e; }
.b-Partial { background: #fdebd0; color: #ca6f1e; }
.b-InProduction { background: #eaf2f8; color: #2471a3; }
.b-Completed { background: #eafaf1; color: #1e8449; }
.b-InProgress { background: #eaf2f8; color: #2471a3; }

/* ---------- دکمه‌ها ---------- */
.btn { border: none; border-radius: 8px; padding: 9px 15px; color: #fff; font-size: 14px; }
.btn:hover { filter: brightness(1.06); }
.btn:disabled { opacity: .6; cursor: default; }
.btn-primary { background: var(--primary); }
.btn-success { background: var(--success); }
.btn-danger { background: var(--danger); }
.btn-secondary { background: var(--secondary); }
.btn-muted { background: #95a5a6; }
.btn-block { width: 100%; margin-top: 16px; }
.btn-sm { padding: 6px 10px; font-size: 12px; }
.btn-xs { padding: 4px 8px; font-size: 12px; background: var(--primary); }
.btn-row { display: flex; gap: 10px; margin-top: 8px; flex-wrap: wrap; }

/* ---------- مودال ---------- */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.45);
  display: flex; align-items: flex-start; justify-content: center; padding: 24px 14px;
  z-index: 50; overflow-y: auto;
}
.modal { background: var(--panel); border-radius: 14px; width: 100%; max-width: 520px; box-shadow: 0 10px 40px rgba(0,0,0,.3); }
.modal-wide { max-width: 860px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; border-bottom: 1px solid var(--border); }
.modal-head h3 { color: var(--head); font-size: 17px; }
.modal-x { border: none; background: transparent; font-size: 18px; color: var(--muted); }
.modal-body { padding: 18px; }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 16px; }
.fg { display: flex; flex-direction: column; }
.fg-full { grid-column: 1 / -1; }
.fg label { font-weight: bold; font-size: 13px; margin-bottom: 5px; }
.fg input, .fg select, .fg textarea {
  padding: 9px 11px; border: 1px solid var(--border); border-radius: 8px; background: #fbfcfd;
}
.fg input:focus, .fg select:focus, .fg textarea:focus { outline: none; border-color: var(--primary); }
.fg input[readonly] { background: #eef1f5; color: var(--muted); }
.hint { color: #c0392b; font-size: 11px; margin-top: 3px; }

.el-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.el-cell { display: flex; align-items: center; gap: 6px; background: #f7f9fb; padding: 5px 8px; border-radius: 6px; }
.el-cell label { flex: 1; font-size: 12px; margin: 0; font-weight: normal; }
.el-cell input { width: 80px; padding: 5px; border: 1px solid var(--border); border-radius: 6px; }
.el-cell .unit { color: var(--muted); font-size: 11px; }
.analysis-row { display: flex; align-items: center; gap: 14px; flex-direction: row; }
.result-tag { font-size: 15px; }
.result-tag.ok { color: var(--success); }
.result-tag.notok { color: var(--danger); }

.confirm-msg { font-size: 15px; margin-bottom: 8px; }
.ship-info { background: #f7f9fb; padding: 10px 12px; border-radius: 8px; margin-bottom: 14px; }

/* ---------- جزئیات ---------- */
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 16px; margin-bottom: 12px; }
.detail h4 { color: var(--head); margin-top: 16px; border-top: 1px solid var(--border); padding-top: 10px; }
.mini-list { margin: 0; padding-right: 18px; }
.mini-list li { padding: 2px 0; }
.pre { white-space: pre-wrap; background: #f7f9fb; padding: 10px; border-radius: 8px; }
.detail-block { background: #f7f9fb; padding: 10px; border-radius: 8px; margin-bottom: 8px; font-size: 13px; }
.muted { color: var(--muted); }
.report-stats { display: flex; flex-wrap: wrap; gap: 10px 20px; background: #f7f9fb; padding: 12px 16px; border-radius: 10px; margin-bottom: 14px; }
.report-stats .ok { color: var(--success); }
.report-stats .notok { color: var(--danger); }

.loading, .err-box { padding: 30px; text-align: center; color: var(--muted); }
.err-box { color: var(--danger); }

/* ---------- Toast ---------- */
#toasts { position: fixed; bottom: 18px; left: 18px; z-index: 100; display: flex; flex-direction: column; gap: 8px; }
.toast {
  background: #34495e; color: #fff; padding: 12px 16px; border-radius: 8px; box-shadow: var(--shadow);
  opacity: 0; transform: translateY(10px); transition: .3s; max-width: 340px; font-size: 13px;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast-success { background: var(--success); }
.toast-error { background: var(--danger); }
.toast-info { background: #34495e; }

/* ---------- واکنش‌گرا ---------- */
@media (max-width: 860px) {
  .hamburger { display: block; }
  .sidebar {
    position: fixed; top: 50px; right: 0; height: calc(100vh - 50px); z-index: 30;
    transform: translateX(100%); transition: .25s; background: var(--bg); box-shadow: -4px 0 16px rgba(0,0,0,.12);
  }
  .sidebar.open { transform: translateX(0); }
  .form-grid { grid-template-columns: 1fr; }
  .el-grid { grid-template-columns: 1fr; }
  .brand { font-size: 12px; }
}
