/* کامپوننت‌های فشرده و تمیز به سبک M-agenty */
.card, .glass {
  background: var(--surface-1);
  border: 1px solid var(--stroke);
  border-radius: 11px;
  padding: 12px 14px;
}
.p0 { padding: 0 !important; overflow: hidden; }
.card-h { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; gap: 8px; flex-wrap: wrap; }
.ttl { display: flex; align-items: center; gap: 7px; font-weight: 700; font-size: 13px; color: #fff; }
.ttl svg { color: var(--accent); }
.page-h { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.page-h h2 { font-size: 17px; font-weight: 800; color: #fff; }

.grid { display: grid; gap: 10px; margin-bottom: 10px; }
.g-2 { grid-template-columns: 1fr 1fr; }
.g-3 { grid-template-columns: repeat(3, 1fr); }
.g-4 { grid-template-columns: repeat(4, 1fr); }
.g-2-1 { grid-template-columns: 2fr 1fr; }
.g-auto { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }

.row { display: flex; align-items: center; }
.gap { gap: 8px; }
.gap-s { gap: 5px; }
.between { justify-content: space-between; }
.center { justify-content: center; }
.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.muted { color: var(--muted); }
.small { font-size: 11.5px; }
.ellipsis { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.link { color: var(--accent); cursor: pointer; font-size: 12px; font-weight: 600; background: none; border: 0; }
.mt { margin-top: 10px; }

/* دکمه‌ها و قرص‌های نوار بالا دقیقاً مثل + Task و Claude Sonnet 5 در M-agenty */
.btn, .pill-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 11px;
  border-radius: 99px;
  border: 1px solid rgba(255,255,255,0.1);
  background: var(--surface-2);
  color: var(--text);
  cursor: pointer;
  font-weight: 600;
  font-size: 12px;
  transition: .15s;
  white-space: nowrap;
}
.btn:hover, .pill-btn:hover { background: var(--surface-3); border-color: rgba(255,255,255,0.18); }
.btn.primary, .btn.ai {
  background: #10b981;
  color: #04130d;
  border-color: #10b981;
  font-weight: 700;
}
.btn.primary:hover, .btn.ai:hover { background: #34d399; }
.btn.danger { color: #f87171; border-color: rgba(239,68,68,0.3); }
.btn.sm { padding: 4px 9px; font-size: 11.5px; border-radius: 7px; }

.icon-btn {
  width: 28px;
  height: 28px;
  border-radius: 7px;
  display: grid;
  place-items: center;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: .12s;
  flex-shrink: 0;
}
.icon-btn:hover { background: var(--surface-2); color: #fff; border-color: var(--stroke); }
.icon-btn.on { background: var(--accent-soft); color: var(--accent); border-color: rgba(16,185,129,0.35); }

.tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 10.5px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 99px;
  background: rgba(255,255,255,0.06);
  color: var(--muted);
}
.tag.green { background: rgba(16,185,129,0.15); color: #34d399; }
.tag.orange { background: rgba(245,158,11,0.15); color: #fbbf24; }
.tag.red { background: rgba(239,68,68,0.15); color: #f87171; }
.tag.blue { background: rgba(56,189,248,0.15); color: #38bdf8; }

.av {
  display: inline-grid;
  place-items: center;
  border-radius: 50%;
  color: #06150f;
  font-weight: 800;
  background: #10b981;
  flex-shrink: 0;
}
.dot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; flex-shrink: 0; }
.bar { height: 5px; border-radius: 99px; background: rgba(255,255,255,0.07); overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--accent); }

.inp {
  width: 100%;
  padding: 7px 11px;
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,0.1);
  background: #141418;
  color: var(--text);
  outline: none;
  font-size: 12.5px;
}
.inp:focus { border-color: var(--accent); }
.field { margin-bottom: 10px; }
.field label { display: block; font-size: 11.5px; color: var(--muted); margin-bottom: 4px; font-weight: 600; }

/* ============================================================================
   محیط چت مستقیم به سبک M-agenty (تصاویر ۲، ۳ و ۴ ارسالی کاربر)
   ============================================================================ */
.maus-stage {
  display: flex;
  flex: 1 1 auto;
  height: calc(100vh - 46px);
  min-height: 0;
  width: 100%;
  overflow: hidden;
}
.maus-chat-pane {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
  min-width: 0;
  background: var(--base);
}
.maus-messages {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto !important;
  padding: 18px 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.maus-thread-center {
  width: 100%;
  max-width: 720px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.maus-date-sep {
  text-align: center;
  font-size: 11px;
  color: var(--faint);
  margin: 4px 0;
}

/* چیپ‌های اجرای ابزار دقیقاً مثل ✓ ToolSearch و ✓ mcp__ogb__ask_user در تصویر ۳ */
.maus-tool-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  align-self: flex-start;
  padding: 4px 11px;
  border-radius: 99px;
  background: #121316;
  border: 1px solid rgba(255,255,255,0.08);
  font-family: ui-monospace, Menlo, monospace;
  font-size: 11.5px;
  color: #a1a1aa;
  direction: ltr;
}
.maus-tool-chip i { color: #10b981; font-style: normal; font-weight: 800; }

/* حباب پیام بات و کاربر در M-agenty */
.maus-bubble {
  background: #141417;
  border: 1px solid rgba(255,255,255,0.07);
  border-radius: 14px;
  padding: 13px 16px;
  line-height: 1.85;
  font-size: 13px;
  color: #e4e4e7;
  max-width: 92%;
  align-self: flex-start;
}
.maus-bubble.user {
  align-self: flex-end;
  background: #232329;
  border-color: rgba(255,255,255,0.1);
  color: #fff;
  max-width: 78%;
}
.maus-bubble h1, .maus-bubble h2, .maus-bubble h3 { font-size: 14px; font-weight: 800; color: #fff; margin: 6px 0 4px; }
.maus-bubble p { margin-bottom: 6px; }
.maus-bubble p:last-child { margin-bottom: 0; }
.maus-bubble code { background: #202026; padding: 1px 6px; border-radius: 5px; font-family: ui-monospace, monospace; font-size: 12px; direction: ltr; display: inline-block; }

/* کارت تعاملی گزینه‌ای A / B / C / D دقیقاً مثل تصویر ۳ و ۴ M-agenty */
.maus-qcard {
  background: #141417;
  border: 1px solid rgba(255,255,255,0.09);
  border-radius: 14px;
  padding: 14px 16px;
  width: 100%;
}
.maus-qcard h4 { font-size: 13.5px; font-weight: 700; color: #fff; margin-bottom: 2px; }
.maus-qcard .q-sub { font-size: 12px; color: var(--muted); margin-bottom: 10px; }
.maus-qopt {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-top: 1px solid rgba(255,255,255,0.05);
  cursor: pointer;
  transition: background .12s;
  border-radius: 7px;
  font-size: 12.5px;
  color: #e4e4e7;
}
.maus-qopt:hover { background: rgba(255,255,255,0.05); color: #fff; }
.maus-qopt kbd {
  width: 22px;
  height: 22px;
  border-radius: 6px;
  background: #222228;
  border: 1px solid rgba(255,255,255,0.08);
  display: grid;
  place-items: center;
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  flex-shrink: 0;
}

/* کادر تایپ کپسولی پایین صفحه دقیقاً مثل "+ Message Atlas" در M-agenty */
.maus-composer-bar {
  padding: 8px 24px 14px;
  background: var(--base);
  flex-shrink: 0;
}
.maus-pill-input {
  max-width: 720px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 8px;
  background: #16161a;
  border: 1px solid rgba(255,255,255,0.09);
  border-radius: 99px;
  padding: 7px 14px;
}
.maus-pill-input:focus-within { border-color: rgba(16,185,129,0.5); background: #19191e; }
.maus-pill-input input {
  flex: 1;
  background: none;
  border: 0;
  outline: none;
  font-size: 13px;
  color: #fff;
}

/* پنل کشویی سمت چپ (Computer / Context Drawer) دقیقاً مثل تصویر ۳ M-agenty (به‌صورت پیش‌فرض بسته تا صفحه خلوت باشد) */
.maus-drawer {
  width: 310px;
  flex-shrink: 0;
  height: 100%;
  background: #0c0c0e;
  border-inline-start: 1px solid var(--stroke);
  display: none;
  flex-direction: column;
  overflow-y: auto;
  padding: 12px;
  gap: 10px;
}
.maus-drawer.open { display: flex; }

/* ============================================================================
   جدول‌ها، کانبان، تقویم و مودال‌های دو ستونه (مثل تصویر ۷ M-agenty Settings)
   ============================================================================ */
.kanban {
  display: grid;
  grid-template-columns: repeat(4, minmax(220px, 1fr));
  gap: 10px;
  overflow-x: auto;
  padding-bottom: 6px;
}
.col {
  background: #101013;
  border: 1px solid var(--stroke);
  border-radius: 11px;
  padding: 8px;
  min-height: 300px;
}
.col-h { display: flex; align-items: center; gap: 6px; font-weight: 700; padding: 2px 4px 8px; font-size: 12.5px; }
.col-h em { font-style: normal; font-size: 10.5px; color: var(--muted); background: var(--surface-2); padding: 1px 7px; border-radius: 99px; }
.col-h .icon-btn { margin-inline-start: auto; }
.col-b { display: flex; flex-direction: column; gap: 7px; }
.tcard {
  background: var(--surface-2);
  border: 1px solid var(--stroke);
  border-radius: 9px;
  padding: 9px 10px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.tcard:hover { border-color: rgba(16,185,129,0.4); }
.tcard .tt { font-weight: 700; font-size: 12.5px; line-height: 1.5; }
.tcard .pj { display: flex; gap: 5px; align-items: center; font-size: 11px; color: var(--muted); }

.tbl { width: 100%; border-collapse: collapse; }
.tbl th { text-align: right; font-size: 11.5px; color: var(--muted); font-weight: 600; padding: 8px 10px; border-bottom: 1px solid var(--line); }
.tbl td { padding: 8px 10px; border-bottom: 1px solid var(--line); font-size: 12.5px; }
.tbl tbody tr:hover { background: rgba(255,255,255,0.03); }
.chk { width: 18px; height: 18px; border-radius: 5px; border: 1.5px solid var(--faint); display: inline-grid; place-items: center; cursor: pointer; }
.chk.on { background: var(--green); border-color: var(--green); color: #05140e; }

.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 5px; }
.wd { text-align: center; font-size: 11px; color: var(--muted); font-weight: 700; padding: 4px; }
.cd { min-height: 74px; border-radius: 8px; background: var(--surface-1); border: 1px solid var(--stroke); padding: 5px; cursor: pointer; display: flex; flex-direction: column; gap: 2px; }
.cd:hover { border-color: rgba(16,185,129,0.45); background: var(--surface-2); }
.cd.today { border-color: var(--accent); }
.cd.today .dn { background: var(--accent); color: #05140e; border-radius: 5px; padding: 0 5px; }
.dn { font-weight: 700; font-size: 11.5px; align-self: flex-start; }
.ev { font-size: 10px; padding: 1px 5px; border-radius: 4px; background: var(--accent-soft); color: #34d399; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.prow { display: flex; align-items: center; gap: 8px; padding: 7px 0; border-bottom: 1px solid var(--line); }
.prow:last-child { border: 0; }
.empty { text-align: center; color: var(--faint); padding: 24px 10px; font-size: 12px; }

#modalWrap .overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(0, 0, 0, 0.72);
  backdrop-filter: blur(4px);
  display: grid;
  place-items: center;
  padding: 16px;
}
.modal {
  width: min(560px, 100%);
  max-height: 86vh;
  overflow-y: auto;
  border-radius: 14px;
  padding: 18px;
  background: #141418 !important;
  border: 1px solid rgba(255,255,255,0.1);
  box-shadow: 0 24px 60px rgba(0,0,0,0.85);
}
.modal.wide { width: min(740px, 100%); }
.m-h { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.m-h h3 { display: flex; gap: 7px; align-items: center; font-size: 14.5px; font-weight: 800; color: #fff; }
.m-f { display: flex; justify-content: flex-end; gap: 7px; margin-top: 14px; padding-top: 10px; border-top: 1px solid var(--line); }

#pal { position: fixed; inset: 0; z-index: 220; display: none; place-items: start center; padding-top: 12vh; background: rgba(0,0,0,0.65); }
#pal.on { display: grid; }
.pal-box { width: min(560px, 92vw); border-radius: 14px; overflow: hidden; background: #141418 !important; border: 1px solid rgba(255,255,255,0.1); }
.pal-in { display: flex; align-items: center; gap: 8px; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.pal-in input { flex: 1; border: 0; background: none; outline: none; font-size: 13.5px; color: #fff; }
.pal-list { max-height: 48vh; overflow-y: auto; padding: 6px; }
.pi { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; cursor: pointer; font-size: 12.5px; }
.pi:hover { background: var(--accent); color: #05140e; }
.pi em { margin-inline-start: auto; font-style: normal; font-size: 10.5px; opacity: .7; }

#toasts { position: fixed; bottom: 18px; left: 18px; z-index: 300; display: flex; flex-direction: column; gap: 6px; pointer-events: none; }
.toast { display: flex; gap: 8px; align-items: center; padding: 8px 14px; border-radius: 9px; font-weight: 600; font-size: 12px; background: #1c1c22; border: 1px solid rgba(255,255,255,0.1); color: #fff; box-shadow: 0 10px 24px rgba(0,0,0,0.6); }

#login { position: fixed; inset: 0; z-index: 350; display: grid; place-items: center; padding: 16px; background: #070707; }
#login.off { display: none; }
.lg { width: min(380px, 100%); border-radius: 16px; padding: 24px; background: #121215; border: 1px solid rgba(255,255,255,0.08); }
.lg h2 { text-align: center; font-size: 18px; font-weight: 800; color: #fff; }
.lg .err { color: var(--red); font-size: 11.5px; min-height: 18px; text-align: center; margin-bottom: 6px; }

/* بوم گراف فلو (Automations / n8n) */
.n8n-canvas {
  background-color: #09090b;
  background-image: radial-gradient(rgba(255, 255, 255, 0.07) 1px, transparent 1px);
  background-size: 20px 20px;
  border: 1px solid var(--stroke);
  border-radius: 12px;
  padding: 18px;
  overflow-x: auto;
}
.n8n-flow-grid { display: flex; flex-direction: column; align-items: center; gap: 10px; min-width: 680px; }
.n8n-node {
  width: 260px;
  background: #141418;
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 10px;
  padding: 10px 12px;
}
.n8n-node.completed { border-color: #10b981; }
.n8n-node.waiting_approval { border-color: #f59e0b; }
.n8n-node .n-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 4px; font-weight: 700; font-size: 12px; color: #fff; }
.n8n-node .n-sub { font-size: 11px; color: var(--muted); line-height: 1.5; }
.n8n-gate { background: rgba(245, 158, 11, 0.1); border: 1px dashed rgba(245, 158, 11, 0.45); color: #fbbf24; padding: 3px 12px; border-radius: 99px; font-size: 11px; font-weight: 600; }
.n8n-connector { width: 1.5px; height: 12px; background: rgba(16, 185, 129, 0.4); }

.chat { display: grid; grid-template-columns: 240px 1fr; height: calc(100vh - 80px); }
.chat-list { border-inline-end: 1px solid var(--line); overflow-y: auto; padding: 8px; }
.ci { display: flex; gap: 8px; align-items: center; padding: 8px; border-radius: 8px; cursor: pointer; }
.ci:hover, .ci.on { background: var(--surface-2); }
.cav { width: 32px; height: 32px; border-radius: 8px; display: grid; place-items: center; color: var(--accent); background: var(--accent-soft); flex-shrink: 0; }
.chat-main { display: flex; flex-direction: column; min-height: 0; }
.chat-main header { display: flex; align-items: center; gap: 8px; padding: 8px 12px; border-bottom: 1px solid var(--line); }
.msgs { flex: 1; overflow-y: auto; padding: 12px; display: flex; flex-direction: column; gap: 8px; }
.msg { display: flex; gap: 8px; max-width: 78%; align-items: flex-end; }
.bub { background: var(--surface-2); border: 1px solid var(--stroke); padding: 8px 12px; border-radius: 12px; font-size: 12.5px; line-height: 1.7; }
.msg.me { align-self: flex-end; }
.msg.me .bub { background: var(--accent-soft); border-color: rgba(16,185,129,0.3); }
.composer { display: flex; gap: 8px; align-items: center; padding: 8px 12px; border-top: 1px solid var(--line); }
.composer input { flex: 1; padding: 7px 12px; border-radius: 99px; border: 1px solid var(--stroke); background: var(--surface-2); outline: none; }

.split { display: grid; grid-template-columns: 280px 1fr; gap: 10px; height: calc(100vh - 95px); }
.split > .card { overflow-y: auto; }
.li { padding: 8px 10px; border-radius: 8px; cursor: pointer; display: flex; gap: 8px; margin-bottom: 3px; }
.li:hover, .li.on { background: var(--surface-2); }
.vault { display: grid; grid-template-columns: 220px minmax(0,1fr) 200px; gap: 10px; height: calc(100vh - 95px); }
.vault > .card { overflow-y: auto; }
.di { display: flex; align-items: center; gap: 6px; padding: 6px 8px; border-radius: 7px; cursor: pointer; font-size: 12px; }
.di:hover, .di.on { background: var(--surface-2); }
.md-ed { min-height: 48vh; font-family: ui-monospace, monospace; line-height: 1.8; font-size: 12.5px; }


/* استایل آواتارهای متحرک SVG ایجنت‌ها از gallery.html */
.ag-svg-av svg {
  width: 100% !important;
  height: 100% !important;
  display: block;
}
.avatar-picker-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(92px, 1fr));
  gap: 8px;
  max-height: 210px;
  overflow-y: auto;
  padding: 6px;
  background: #0e0e11;
  border: 1px solid var(--stroke);
  border-radius: 10px;
}
.av-pick-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 8px 4px;
  border-radius: 9px;
  border: 1.5px solid transparent;
  background: var(--surface-2);
  cursor: pointer;
  text-align: center;
  font-size: 10.5px;
  color: var(--muted);
  transition: .12s;
}
.av-pick-item:hover { background: var(--surface-3); color: #fff; }
.av-pick-item.on { border-color: var(--accent); background: var(--accent-soft); color: #fff; font-weight: 700; }

/* بوم دیداری تعاملی فلو و اتوماسیون */
.wf-studio {
  display: grid;
  grid-template-columns: 230px minmax(0, 1fr) 310px;
  gap: 12px;
  height: calc(100vh - 76px);
  min-height: 520px;
}
.wf-panel {
  background: var(--surface-1);
  border: 1px solid var(--stroke);
  border-radius: 12px;
  padding: 12px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.wf-board {
  background-color: #09090b;
  background-image: radial-gradient(rgba(255, 255, 255, 0.07) 1px, transparent 1px);
  background-size: 20px 20px;
  border: 1px solid var(--stroke);
  border-radius: 12px;
  padding: 20px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}
.wf-node-card {
  width: min(460px, 96%);
  background: #141418;
  border: 1.5px solid rgba(255,255,255,0.09);
  border-radius: 12px;
  padding: 11px 14px;
  cursor: pointer;
  transition: .15s;
}
.wf-node-card:hover { border-color: rgba(16,185,129,0.45); }
.wf-node-card.selected { border-color: #10b981; box-shadow: 0 0 0 2px rgba(16,185,129,0.22); background: #181a20; }
.wf-node-card.completed { border-inline-start: 4px solid #10b981; }
.wf-node-card.waiting_approval { border-inline-start: 4px solid #f59e0b; }
