/* SPIA Frontend Styles — کپی از panel_bolt_factory_v53.html */

@font-face {
  font-family: 'B Mitra';
  src: url('/assets/fonts/BMitra.ttf') format('truetype');
  font-weight: 400; font-style: normal; font-display: swap;
}
@font-face {
  font-family: 'B Mitra';
  src: url('/assets/fonts/BMitraBd.ttf') format('truetype');
  font-weight: 700; font-style: normal; font-display: swap;
}

:root {
  --brand: #1d9bf0; --brand-d: #1a8cd8; --brand-bg: #e8f5fe;
  --bg: #f7f9fa; --panel: #fff; --ink: #0f1419; --muted: #33414e; --line: #eaedf0; --soft: #f7f9fa;
  --red: #d63341; --red-bg: #fdecef; --green: #17a463; --green-bg: #e7f6ee;
  --orange: #f0871f; --orange-bg: #fdf1e3;
  --r: 14px; --r-s: 9px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'B Mitra', 'Vazirmatn', 'B Nazanin', 'Tahoma', sans-serif;
  background: var(--bg); color: var(--ink);
  font-size: 16px; line-height: 1.7;
  -webkit-font-smoothing: antialiased;
}

button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; font-size: 14px; }
.hidden { display: none !important; }

/* ───── صفحهٔ ورود ───── */
#login {
  position: fixed; inset: 0;
  background: linear-gradient(135deg, #1d9bf0, #0f6fb5);
  display: flex; align-items: center; justify-content: center;
  z-index: 60;
}
.login-card {
  background: #fff; width: 370px; max-width: 90vw;
  padding: 34px 30px; border-radius: 20px;
  box-shadow: 0 20px 50px rgba(0,0,0,.25);
}
.login-card .logo {
  width: 48px; height: 48px; border-radius: 14px;
  background: var(--brand); display: flex; align-items: center; justify-content: center;
  font-weight: 800; color: #fff; font-size: 22px; margin-bottom: 16px;
}
.login-card .logo-img {
  width: 96px; height: 96px; border-radius: 14px; object-fit: contain;
  background: #fff; margin-bottom: 16px; display: block;
}
.brand .logo-img {
  width: 44px; height: 44px; border-radius: 10px; object-fit: contain;
  background: #fff; border: 1px solid var(--line);
}
.login-card h1 { font-size: 20px; font-weight: 800; }
.login-card p { color: var(--muted); font-size: 13px; margin: 4px 0 22px; }

.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.field input {
  width: 100%; padding: 11px 12px; border: 1px solid var(--line);
  border-radius: var(--r-s); background: #fff;
}
.field input:focus { outline: none; border-color: var(--brand); background: #fff; }

.btn {
  background: var(--brand); color: #fff; border: none;
  padding: 9px 18px; border-radius: var(--r-s);
  font-weight: 700; font-size: 14px; line-height: 1.4;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  transition: transform .08s, filter .15s, box-shadow .15s;
  white-space: nowrap;
}
.btn:hover { filter: brightness(1.06); box-shadow: 0 3px 10px rgba(29,155,240,.25); }
.btn:active { transform: scale(.95); box-shadow: 0 0 0 3px rgba(29,155,240,.30); }
.btn:disabled { opacity: .6; cursor: not-allowed; }
.btn.block { width: 100%; }
.btn.ghost {
  background: #fff; color: var(--brand); border: 1px solid var(--brand);
  padding: 7px 14px; font-size: 13px; font-weight: 700;
}
.btn.ghost:hover { background: var(--brand-bg); }
.btn.gray {
  background: var(--soft); color: #33404d; border: 1px solid var(--line);
  padding: 7px 14px; font-size: 13px; font-weight: 600;
}
.btn.gray:hover { border-color: var(--brand); color: var(--brand); }

.hint { font-size: 12px; color: var(--muted); text-align: center; margin-top: 14px; }
.error-msg { font-size: 13px; color: var(--red); background: var(--red-bg); border: 1px solid #fbb6c0; border-radius: var(--r-s); padding: 9px 12px; margin-top: 10px; }

/* ───── چینش اصلی (sidebar + main) ───── */
.layout, .app-layout {
  display: grid; grid-template-columns: 252px 1fr;
  min-height: 100vh;
}
.app-layout > aside.sidebar {
  background: #fff; border-left: 1px solid var(--line);
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column;
}
.main-content { padding: 24px 30px; overflow: auto; }
aside {
  background: #fff; border-left: 1px solid var(--line);
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column;
}
.brand {
  padding: 16px 16px 14px;
  display: flex; flex-direction: column; align-items: flex-start; gap: 8px;
  border-bottom: 1px solid var(--line);
}
.brand .logo {
  width: 36px; height: 36px; border-radius: 10px;
  background: var(--brand); display: flex; align-items: center; justify-content: center;
  font-weight: 800; color: #fff;
}
.brand .btxt b {
  font-size: 14px; font-weight: 800; display: block; line-height: 1.4;
}
.brand .btxt span {
  font-size: 11px; color: var(--muted); display: block;
}
nav { padding: 8px 10px; flex: 1; overflow: auto; }
.nav-label {
  font-size: 11.5px; color: #8a97a3; padding: 12px 10px 4px;
}
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; border-radius: 10px;
  color: #33404d; font-size: 14.5px;
  border: none; background: none; width: 100%; text-align: right;
  transition: background .15s, transform .08s, box-shadow .15s;
}
.nav-item .ic { width: 18px; text-align: center; opacity: .7; }
.nav-item:hover { background: var(--brand-bg); transform: translateX(-3px); }
.nav-item:active { transform: scale(.97); }
.nav-item.active {
  background: var(--brand-bg); color: var(--brand); font-weight: 700;
  box-shadow: inset 3px 0 0 var(--brand);
}
.nav-item.active .ic { opacity: 1; }
.nav-foot {
  padding: 12px 16px; border-top: 1px solid var(--line);
  font-size: 12px; color: var(--green);
}

main { padding: 24px 30px; overflow: auto; }
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 22px;
}
.topbar h2 { font-size: 22px; font-weight: 800; }
.topbar .sub { color: var(--muted); font-size: 13px; }
.user {
  display: flex; align-items: center; gap: 10px; font-size: 13px;
}
.avatar {
  width: 38px; height: 38px; border-radius: 50%;
  background: var(--brand); color: #fff;
  display: flex; align-items: center; justify-content: center; font-weight: 700;
}
.link-btn {
  background: #fff; border: 1px solid var(--line);
  padding: 7px 12px; border-radius: 9px;
  color: var(--muted); font-size: 13px;
}
.link-btn:hover { border-color: var(--red); color: var(--red); }

.panel {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--r); padding: 20px; margin-bottom: 18px;
  overflow-x: auto;
}
.panel h3 { font-size: 16px; font-weight: 800; margin-bottom: 14px; }

.grid { display: grid; gap: 16px; }
.kpis { grid-template-columns: repeat(4, 1fr); }
.kpi {
  background: #fff; border: 1px solid var(--line);
  border-radius: var(--r); padding: 18px;
  border-top: 3px solid var(--brand);
}
.kpi.green { border-top-color: var(--green); }
.kpi.red { border-top-color: var(--red); }
.kpi.orange { border-top-color: var(--orange); }
.kpi .label { font-size: 14px; color: var(--muted); }
.kpi .val { font-size: 24px; font-weight: 800; margin-top: 4px; }
.kpi .unit { font-size: 12px; color: var(--muted); font-weight: 500; }

table { width: 100%; border-collapse: collapse; font-size: 14.5px; }
th, td {
  text-align: right; padding: 10px;
  border-bottom: 1px solid var(--line); vertical-align: middle;
}
th {
  color: var(--brand); font-weight: 700; font-size: 12.5px;
  background: var(--brand-bg);
}
tr:last-child td { border-bottom: none; }

.muted { color: var(--muted); font-size: 14px; }

/* ───── Toast پیام ───── */
#toast {
  position: fixed; bottom: 26px; left: 50%;
  transform: translateX(-50%) translateY(24px);
  background: #1d3a5a; color: #fff;
  padding: 11px 20px; border-radius: 11px;
  opacity: 0; pointer-events: none;
  transition: .28s cubic-bezier(.2,.8,.2,1);
  z-index: 99999; font-size: 13px; font-weight: 700;
  box-shadow: 0 8px 26px rgba(0,0,0,.25);
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
#toast.error { background: var(--red); }
#toast.success { background: var(--green); }

/* ───── فرم ───── */
.form-row {
  display: grid; gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  align-items: end; margin-bottom: 8px;
}
.ff label { display: block; font-size: 12.5px; color: var(--muted); margin-bottom: 5px; }
.ff input, .ff select, .ff textarea {
  width: 100%; padding: 9px 10px;
  border: 1px solid var(--line); border-radius: var(--r-s);
  background: #fff;
}
.ff input:focus, .ff select:focus, .ff textarea:focus {
  outline: none; border-color: var(--brand);
}
.ck {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 13px; background: #fff;
  padding: 7px 11px; border-radius: 9px; border: 1px solid var(--line);
}

/* ───── دکمه‌های کنشِ کوچک ───── */
.ico {
  border: 1px solid var(--line); background: #fff;
  width: 30px; height: 30px; border-radius: 8px;
  color: var(--muted); font-size: 13px; margin-right: 4px;
  cursor: pointer; transition: transform .08s;
}
.ico:hover { border-color: var(--brand); color: var(--brand); }
.ico:active { transform: scale(.85); }
.ico.del:hover { border-color: var(--red); color: var(--red); }

/* ───── pill (برچسب رنگی) ───── */
.pill {
  display: inline-block; padding: 3px 10px; border-radius: 20px;
  font-size: 12px; font-weight: 700;
}
.pill.g { background: var(--green-bg); color: var(--green); }
.pill.r { background: var(--red-bg); color: var(--red); }
.pill.o { background: var(--orange-bg); color: var(--orange); }
.pill.b { background: var(--brand-bg); color: var(--brand); }

/* ───── modal (مودال) ───── */
.appModalOv {
  position: fixed; inset: 0;
  background: rgba(15, 23, 42, .5);
  z-index: 100000;
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
}
.appModalBox {
  background: #fff; border-radius: 14px; padding: 22px;
  max-width: 540px; width: 100%; max-height: 90vh; overflow: auto;
  box-shadow: 0 24px 70px rgba(0, 0, 0, .35);
  animation: ampop .15s ease;
}
@keyframes ampop {
  from { transform: scale(.95); opacity: 0; }
  to   { transform: scale(1); opacity: 1; }
}
.appModalMsg { font-size: 14px; color: #0f172a; line-height: 1.9; margin-bottom: 18px; }
.appModalBtns { display: flex; gap: 8px; justify-content: flex-end; }

/* ───── KPI delta ───── */
.kpi .delta { font-size: 12px; margin-top: 5px; color: var(--muted); }

/* ───── نوار پیشرفت (موجودی مفتول) ───── */
.bar {
  height: 8px; background: var(--soft);
  border-radius: 6px; overflow: hidden;
  min-width: 80px; border: 1px solid var(--line);
}
.bar i { display: block; height: 100%; background: var(--brand); }
.bar i.low { background: var(--red); }
.bar i.g   { background: var(--green); }
.bar i.o   { background: var(--orange); }

/* ───── ناظر هوشمند (aiObserve) ───── */
.ai-row {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 11px 0; border-bottom: 1px solid var(--line);
  font-size: 13.5px;
}
.ai-row:last-child { border-bottom: none; }
.ai-ic {
  width: 26px; height: 26px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; flex-shrink: 0;
}
.ai-ic.a { background: var(--red-bg);    color: var(--red); }
.ai-ic.w { background: var(--orange-bg); color: var(--orange); }
.ai-ic.i { background: var(--brand-bg);  color: var(--brand); }
.ai-ic.g { background: var(--green-bg);  color: var(--green); }

/* ───── دستیار هوشمند (smartInsights) ───── */
.siPanel { background: #fff; }
.siHead {
  display: flex; justify-content: space-between;
  align-items: flex-start; gap: 10px; margin-bottom: 12px;
}
.siTitle { font-size: 16px; font-weight: 800; color: #1d4ed8; }
.siRobot { font-size: 26px; opacity: .5; }
.siGrid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px;
}
.siGroup { display: flex; flex-direction: column; gap: 8px; }
.siGroup-h {
  font-size: 13px; font-weight: 800;
  display: flex; align-items: center; gap: 6px;
  padding-bottom: 4px; border-bottom: 2px solid #f1f5f9;
}
.siCount {
  color: #fff; font-size: 10px; font-weight: 800;
  min-width: 18px; height: 18px; border-radius: 9px;
  display: inline-flex; align-items: center; justify-content: center;
  padding: 0 5px;
}
.siCard {
  border: 1px solid #eef2f7; border-right: 4px solid;
  border-radius: 10px; padding: 9px 11px;
  font-size: 12px; line-height: 1.75;
  transition: transform .12s, box-shadow .12s;
}
.siCard:hover { transform: translateX(-2px); box-shadow: 0 4px 12px rgba(0,0,0,.06); }

/* ───── tabs (برای master و سایر صفحات) ───── */
.tabs { display: flex; gap: 6px; margin-bottom: 16px; flex-wrap: wrap; }
.tab {
  padding: 8px 16px; border-radius: 22px;
  border: 1px solid var(--line); background: #fff;
  color: var(--muted); font-size: 13.5px;
}
.tab.active { background: var(--brand); color: #fff; border-color: var(--brand); }

/* ───── checklist (چندانتخابی مشتری بچ) ───── */
.ck { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; background: #fff; padding: 7px 11px; border-radius: 9px; border: 1px solid var(--line); }
.checklist { display: flex; flex-wrap: wrap; gap: 8px; }

/* ───── کارت بچ تولید (پورت دقیق از v53) ───── */
.batch { border: 1px solid var(--line); border-radius: var(--r); padding: 16px; margin-bottom: 14px; background: #fff; }
.batch-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; flex-wrap: wrap; gap: 8px; }
.steps { display: flex; gap: 6px; margin-bottom: 14px; flex-wrap: wrap; }
.step { flex: 1; min-width: 84px; text-align: center; padding: 9px 6px; border-radius: 9px; background: #fff; font-size: 12px; color: var(--muted); border: 1px solid var(--line); }
.step.done { background: var(--green-bg); color: var(--green); font-weight: 700; }
.step.cur { background: #fff; border-color: var(--brand); color: var(--brand); font-weight: 700; }
.step small { display: block; font-size: 10.5px; font-weight: 500; margin-top: 2px; opacity: .9; }
.stage-panel { background: #fff; border-radius: var(--r-s); padding: 14px; border: 1px solid var(--line); }
.stage-panel h4 { font-size: 14px; margin-bottom: 10px; color: var(--brand); }
.stage-panel.qc { border: 1px solid var(--orange); background: var(--orange-bg); }

/* ───── totbox ───── */
.totbox {
  display: flex; gap: 18px; flex-wrap: wrap;
  background: #fff; border: 1px solid var(--line);
  border-radius: var(--r-s); padding: 12px 16px; margin: 8px 0;
}
.totbox b { font-size: 16px; }

/* ───── تقویم شمسی (Jalali Picker) — کپی از v53 ───── */
#jpicker {
  position: absolute; z-index: 9999;
  background: #fff; border: 1px solid var(--line);
  border-radius: 12px; box-shadow: 0 12px 30px rgba(0,0,0,.16);
  padding: 10px; width: 236px; display: none;
}
.jp-head {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 8px;
}
.jp-head button {
  border: none; background: var(--soft); width: 28px; height: 28px;
  border-radius: 8px; font-size: 16px; color: var(--brand); cursor: pointer;
}
.jp-week {
  display: grid; grid-template-columns: repeat(7,1fr);
  text-align: center; font-size: 11px; color: var(--muted); margin-bottom: 4px;
}
.jp-grid { display: grid; grid-template-columns: repeat(7,1fr); gap: 2px; }
.jp-grid span { text-align: center; padding: 6px 0; font-size: 13px; border-radius: 7px; }
.jp-grid .jd { cursor: pointer; }
.jp-grid .jd:hover { background: var(--brand); color: #fff; }

/* ───── responsive ───── */
@media (max-width: 980px) {
  .layout { grid-template-columns: 200px 1fr; }
  main { padding: 18px 16px; }
}
@media (max-width: 760px) {
  .layout { grid-template-columns: 1fr; min-height: auto; }
  aside {
    position: static; height: auto;
    border-left: none; border-bottom: 1px solid var(--line);
  }
  nav { display: flex; flex-wrap: wrap; gap: 4px; }
  .nav-label { width: 100%; padding: 6px 8px 2px; }
  .nav-item { width: auto; flex: 0 0 auto; font-size: 13px; padding: 7px 10px; }
  main { padding: 14px 12px 64px; overflow: auto; }
  .kpis { grid-template-columns: 1fr 1fr; }
  .topbar h2 { font-size: 18px; }
  body { font-size: 14px; }
}
@media (max-width: 430px) {
  .kpis { grid-template-columns: 1fr; }
  .login-card { padding: 26px 20px; }
}


/* ─── flchip: نخ نامرئی (trace.js) — instruction_25 ─── */
.flchip { display:inline-flex;align-items:center;padding:5px 10px;border-radius:20px;font-size:12px;font-weight:600;white-space:nowrap; }
.flchip.src     { background:#f0f7ff;border:1px solid #1d9bf0;color:#1d4ed8; }
.flchip.wire    { background:#eff6ff;border:1px solid #93c5fd;color:#1e40af; }
.flchip.done    { background:#dcfce7;border:1px solid #16a34a;color:#15803d; }
.flchip.current { background:#dbeafe;border:2px solid #1d9bf0;color:#1d4ed8; }
.flchip.await   { background:#fef3c7;border:1px solid #f59e0b;color:#b45309; }
.flchip.pending { background:#f1f5f9;border:1px solid #e2e8f0;color:#64748b; }
.flchip.final   { background:#dcfce7;border:1px solid #16a34a;color:#15803d; }
.flchip.rej     { background:#fee2e2;border:1px solid #ef4444;color:#b91c1c; }
.flchip.dest    { background:#faf5ff;border:1px solid #a855f7;color:#7e22ce; }
.flarrow        { color:#94a3b8;font-size:14px;padding:0 2px; }
