:root {
  --bg: #0a0e13;
  --surface: #121820;
  --surface2: #1a2330;
  --border: #2a3647;
  --text: #e8eef5;
  --muted: #8fa3bc;
  --accent: #6366f1;
  --ok: #34d399;
  --err: #f87171;
  --warn: #fbbf24;
}

* { box-sizing: border-box; }

html {
  height: 100%;
}

body {
  margin: 0;
  font-family: "Vazirmatn", sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  min-height: 100dvh;
}

body.admin-login {
  overflow: hidden;
}

body.admin-authed {
  overflow: hidden; /* اسکرول فقط داخل main — نه body */
  height: 100vh;
  height: 100dvh;
  max-height: 100dvh;
}

body.admin-authed #loginScreen {
  display: none !important;
}

.login-screen {
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 1rem;
}

body.admin-authed .login-screen {
  display: none !important;
}

.login-card {
  width: min(380px, 100%);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 1.5rem;
  display: grid;
  gap: 0.75rem;
}

.login-card h1 { margin: 0; font-size: 1.25rem; }
.login-card p { margin: 0; color: var(--muted); font-size: 0.9rem; }

input, select {
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 10px;
  padding: 0.65rem 0.75rem;
  font: inherit;
}

.btn {
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 10px;
  padding: 0.55rem 0.9rem;
  cursor: pointer;
  font: inherit;
}

.btn.ghost {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
}

.btn.danger {
  background: rgba(248, 113, 113, 0.15);
  border: 1px solid rgba(248, 113, 113, 0.35);
  color: var(--err);
}

.error { color: var(--err); font-size: 0.85rem; }

.app-screen {
  --admin-content: 1120px;
  --admin-circuit: 1480px;
  display: none;
  width: 100%;
  max-width: none;
  margin: 0;
  padding: 0;
  /* ارتفاع ثابت روی viewport تا اسکرول فقط داخل main باشد */
  height: 100%;
  max-height: 100dvh;
  min-height: 0;
  flex-direction: column;
  overflow: hidden;
  background:
    radial-gradient(1200px 480px at 50% -10%, rgba(99, 102, 241, 0.12), transparent 55%),
    var(--bg);
}

.app-screen:not([hidden]) {
  display: flex;
}

body.admin-authed .app-screen:not([hidden]) {
  height: 100%;
  max-height: 100dvh;
}

.app-screen > .topbar {
  flex-shrink: 0;
  width: 100%;
  padding: 0.85rem 1.25rem;
  margin: 0;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.app-screen > .tabs {
  flex-shrink: 0;
  width: 100%;
  padding: 0.5rem 1.25rem 0;
  margin: 0;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  gap: 0.3rem;
  overflow-x: auto;
  overflow-y: hidden;
  flex-wrap: nowrap;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
}

.app-screen > .tabs .tab {
  flex: 0 0 auto;
  white-space: nowrap;
}

/* منبع واحد اسکرول صفحهٔ ادمین */
.app-screen > main {
  flex: 1 1 auto;
  min-height: 0;
  width: 100%;
  overflow-x: hidden;
  overflow-y: scroll !important;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  padding: 1.25rem 1.25rem 2.5rem;
  touch-action: pan-y;
}

/* همهٔ تب‌ها وسط صفحه */
.app-screen > main > .panel.active {
  box-sizing: border-box;
  width: 100%;
  max-width: var(--admin-content);
  margin-left: auto;
  margin-right: auto;
  display: block;
  min-height: min-content;
  padding-bottom: 1rem;
}

.app-screen > main.main-cp-circuit > #control-plane.panel.active {
  max-width: var(--admin-circuit);
}

.app-screen > main > .panel.active > .card,
.app-screen > main > .panel.active > .stats,
.app-screen > main > .panel.active > .filters,
.app-screen > main > .panel.active > .table-wrap,
.app-screen > main > .panel.active > .pager {
  width: 100%;
}

/* Voice Studio باید کامل اسکرول شود */
#voice-studio.panel.active {
  display: block;
  min-height: min-content;
}

#voiceStudioRoot,
.voice-studio {
  overflow: visible;
  max-height: none;
  min-height: 0;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 0;
}

.topbar h1 { margin: 0; font-size: 1.3rem; }
.sub { margin: 0.25rem 0 0; color: var(--muted); font-size: 0.85rem; }
.topbar-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; }

.tabs {
  display: flex;
  gap: 0.35rem;
  margin-bottom: 0;
  flex-wrap: wrap;
}

.tab {
  background: transparent;
  border: 1px solid transparent;
  color: var(--muted);
  border-radius: 10px;
  padding: 0.5rem 0.85rem;
  cursor: pointer;
  font: inherit;
}

.tab.active {
  background: var(--surface2);
  border-color: var(--border);
  color: var(--text);
}

.panel { display: none; }
.panel.active { display: block; }

/* تب‌های عادی همیشه با محتوای کامل اسکرول شوند */
#dashboard.panel.active,
#logs.panel.active,
#health.panel.active,
#users.panel.active,
#services.panel.active,
#learning.panel.active,
#settings.panel.active {
  overflow: visible;
  max-height: none;
}

.stats {
  display: grid;
  gap: 0.75rem;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  margin-bottom: 1rem;
}

.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 0.9rem 1rem;
}

.stat .label { color: var(--muted); font-size: 0.78rem; }
.stat .value { font-size: 1.45rem; font-weight: 700; margin-top: 0.25rem; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1rem;
}

.card h3 { margin: 0 0 0.75rem; font-size: 0.95rem; color: var(--muted); }

.btn-row { display: flex; gap: 0.5rem; flex-wrap: wrap; margin-top: 0.65rem; }
.tts-status-list { margin: 0.5rem 0; padding-right: 1.1rem; font-size: 0.85rem; color: var(--muted); }
.tts-status-list code { font-size: 0.78rem; }
.tts-admin-player { width: 100%; margin-top: 0.5rem; }
.card .hint { font-size: 0.78rem; color: var(--muted); margin: 0.35rem 0 0; }

.filters {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 0.75rem;
}

.filters select, .filters input { width: auto; min-width: 140px; flex: 1; }

.table-wrap {
  overflow: auto;
  max-height: min(62vh, 720px);
  border: 1px solid var(--border);
  border-radius: 12px;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  scrollbar-width: thin;
}

table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
th, td { padding: 0.65rem 0.55rem; border-bottom: 1px solid var(--border); text-align: right; }
th { color: var(--muted); background: var(--surface2); position: sticky; top: 0; }

.tag {
  display: inline-block;
  padding: 0.15rem 0.45rem;
  border-radius: 999px;
  font-size: 0.72rem;
  border: 1px solid var(--border);
}

.tag.ok { color: var(--ok); border-color: rgba(52, 211, 153, 0.35); }
.tag.error { color: var(--err); border-color: rgba(248, 113, 113, 0.35); }
.tag.chat { color: #93c5fd; }
.tag.stt { color: #f9a8d4; }
.tag.audio { color: #67e8f9; }

.health-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 0.75rem;
}

.health-card {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.85rem 1rem;
}

.health-card .zone {
  font-size: 0.75rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.health-card .name {
  font-weight: 600;
  margin: 0.25rem 0;
}

.health-card .status-ok { color: var(--ok); }
.health-card .status-err { color: var(--err); }
.health-card .status-skip { color: var(--muted); }

.pager {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  margin-top: 0.75rem;
}

.mono {
  font-family: ui-monospace, monospace;
  font-size: 0.82rem;
  white-space: pre-wrap;
  word-break: break-word;
  direction: ltr;
  text-align: left;
}

.detail-pre {
  max-height: 65vh;
  overflow: auto;
  margin: 0;
  padding: 0.75rem;
  background: var(--surface2);
  border-radius: 10px;
}

dialog {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 16px;
  width: min(900px, 95vw);
  padding: 0;
}

dialog header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem;
  border-bottom: 1px solid var(--border);
}

dialog form { margin: 0; }
dialog h3 { margin: 0; }
#detailContent { padding: 1rem; }

.summary-cell {
  max-width: 280px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.arch-forge {
  --arch-bg: #0f172a;
  --arch-scroll-track: #1e293b;
  --arch-scroll-thumb: #475569;
  --arch-scroll-thumb-hover: #64748b;
  --arch-panel: #1e293b;
  --arch-tertiary: #334155;
  --arch-line: #334155;
  --arch-text: #f8fafc;
  --arch-muted: #94a3b8;
  --arch-true: #22c55e;
  --arch-true-glow: rgba(34, 197, 94, 0.5);
  --arch-false: #ef4444;
  --arch-accent: #3b82f6;
  --arch-purple: #8b5cf6;
  --arch-wire-idle: #475569;
  --arch-wire-active: #22c55e;
  border: 1px solid var(--arch-line);
  border-radius: 14px;
  overflow: hidden;
  background: var(--arch-bg);
}

.arch-map-card { margin-top: 1.25rem; }

.arch-status-bar {
  margin: 0;
  padding: 0.4rem 1rem;
  font-size: 0.75rem;
  background: rgba(59, 130, 246, 0.12);
  color: #93c5fd;
  border-bottom: 1px solid var(--arch-line);
}

.arch-status-bar.ok { background: rgba(34, 197, 94, 0.1); color: #86efac; }
.arch-status-bar.err { background: rgba(239, 68, 68, 0.12); color: #fca5a5; }

/* Header */
.arch-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
  padding: 0.85rem 1rem;
  background: var(--arch-panel);
  border-bottom: 1px solid var(--arch-line);
}

.arch-logo {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  min-width: 140px;
}

.arch-logo-icon { font-size: 1.4rem; }

.arch-logo-text {
  font-size: 1rem;
  font-weight: 700;
  background: linear-gradient(135deg, var(--arch-accent), var(--arch-purple));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.arch-logo-sub {
  font-size: 0.65rem;
  color: var(--arch-muted);
}

.arch-cats {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  flex: 1;
  justify-content: center;
}

.arch-cat {
  border: 1px solid var(--arch-line);
  background: var(--arch-bg);
  color: var(--arch-muted);
  font: inherit;
  font-size: 0.78rem;
  padding: 0.4rem 0.75rem;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
}

.arch-cat:hover { border-color: var(--arch-accent); color: var(--arch-text); }
.arch-cat.active {
  background: var(--arch-accent);
  border-color: var(--arch-accent);
  color: #fff;
}

.arch-header-actions {
  display: flex;
  gap: 0.4rem;
  margin-inline-start: auto;
}

.arch-hbtn {
  border: 1px solid var(--arch-line);
  background: var(--arch-tertiary);
  color: var(--arch-text);
  font: inherit;
  font-size: 0.78rem;
  padding: 0.45rem 0.75rem;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
}

.arch-hbtn:hover { background: var(--arch-accent); border-color: var(--arch-accent); }
.arch-hbtn-save:not(:disabled) { background: #059669; border-color: #059669; }
.arch-hbtn:disabled { opacity: 0.45; cursor: not-allowed; }

/* 3-column layout */
.arch-main-layout {
  display: grid;
  grid-template-columns: minmax(200px, 240px) 1fr minmax(220px, 280px);
  min-height: 420px;
}

@media (max-width: 960px) {
  .arch-main-layout { grid-template-columns: 1fr; }
}

/* Sidebars — shell ثابت + بدنهٔ اسکرول جدا */
.arch-sidebar {
  display: flex;
  flex-direction: column;
  min-height: 0;
  max-height: 480px;
  overflow: hidden;
  padding: 0;
  background: var(--arch-panel);
}

.arch-sidebar-start {
  border-inline-end: 1px solid var(--arch-line);
}

.arch-sidebar-end {
  border-inline-start: 1px solid var(--arch-line);
}

.arch-sidebar-scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 1rem;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

.arch-side-title {
  margin: 0 0 0.65rem;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--arch-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.arch-side-divider {
  height: 1px;
  background: var(--arch-line);
  margin: 1rem 0;
}

.arch-preset {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.55rem 0.65rem;
  margin-bottom: 0.4rem;
  background: var(--arch-bg);
  border: 1px solid var(--arch-line);
  border-radius: 8px;
  color: var(--arch-text);
  font: inherit;
  font-size: 0.8rem;
  text-align: start;
  cursor: pointer;
  transition: all 0.2s;
}

.arch-preset:hover { border-color: var(--arch-accent); background: var(--arch-tertiary); }
.arch-preset.active {
  border-color: var(--arch-purple);
  box-shadow: 0 0 16px rgba(139, 92, 246, 0.25);
}

.arch-palette-zone {
  margin-bottom: 0.65rem;
}

.arch-palette-zone-head {
  font-size: 0.65rem;
  font-weight: 700;
  color: var(--z, var(--arch-muted));
  margin-bottom: 0.35rem;
  display: flex;
  gap: 0.35rem;
}

.arch-palette-zone-head em {
  font-style: normal;
  color: var(--arch-muted);
  font-weight: 400;
  margin-inline-start: auto;
}

.arch-palette-node {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.72rem;
  padding: 0.25rem 0.35rem;
  color: var(--arch-text);
  border-radius: 6px;
}

.arch-palette-node i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* Canvas */
.arch-canvas {
  position: relative;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 320px;
  flex: 1;
  min-height: 0;
}

.arch-canvas-viewport {
  flex: 1;
  position: relative;
  overflow: hidden;
  min-height: 0;
  cursor: default;
  background: var(--arch-bg);
  background-image: radial-gradient(circle, var(--arch-tertiary) 1px, transparent 1px);
  background-size: 20px 20px;
}

.arch-canvas-viewport.is-panning,
.arch-canvas-viewport.space-pan {
  cursor: grabbing;
  user-select: none;
}

.arch-canvas-inner {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 1;
  transform-origin: 0 0;
  will-change: transform;
}

.arch-board {
  position: relative;
  min-width: 2400px;
  min-height: 1600px;
  z-index: 2;
}

.arch-track-wrap {
  position: relative;
  z-index: 2;
  width: max-content;
  max-width: 100%;
  margin: 0 auto;
}

.arch-wires {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 1;
  overflow: visible;
}

.arch-wire {
  fill: none;
  stroke-width: 3;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.arch-wire.wire-idle {
  stroke: var(--arch-wire-idle);
  stroke-dasharray: 8 6;
  opacity: 0.75;
}

.arch-wire.wire-active {
  stroke: var(--arch-wire-active);
  stroke-dasharray: 10 10;
  animation: arch-wire-flow 0.55s linear infinite;
}

.arch-wire-glow {
  fill: none;
  stroke: var(--arch-wire-active);
  stroke-width: 8;
  stroke-linecap: round;
  opacity: 0.22;
  filter: blur(2px);
}

@keyframes arch-wire-flow {
  from { stroke-dashoffset: 20; }
  to { stroke-dashoffset: 0; }
}

.arch-wire-badge circle {
  fill: var(--arch-accent);
  stroke: rgba(15, 23, 42, 0.9);
  stroke-width: 1.5;
  opacity: 0.95;
}

.arch-wire-badge text {
  fill: #fff;
  font-size: 8px;
  font-weight: 700;
  font-family: inherit;
  pointer-events: none;
}

.arch-canvas-empty {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--arch-muted);
  font-size: 0.85rem;
  margin: 0;
  z-index: 1;
}

.arch-empty-state {
  position: absolute;
  inset: 0;
  z-index: 4;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  pointer-events: none;
  color: var(--arch-muted);
}

.arch-empty-state.hidden {
  display: none;
}

.arch-empty-icon {
  font-size: 2.5rem;
  opacity: 0.6;
}

.arch-empty-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--arch-text);
}

.arch-empty-desc {
  font-size: 0.78rem;
  max-width: 280px;
  text-align: center;
  line-height: 1.45;
}

.arch-node.selected {
  border-color: var(--arch-purple);
  box-shadow: 0 0 22px rgba(139, 92, 246, 0.45);
}

.arch-node.dragging {
  opacity: 0.88;
  z-index: 1000;
}

.arch-port-dot.connecting {
  animation: arch-port-pulse 0.5s ease infinite;
  border-color: var(--arch-accent);
}

@keyframes arch-pop-in {
  from { transform: scale(0.85); opacity: 0.5; }
  to { transform: scale(1); opacity: 1; }
}

.arch-node-new {
  animation: arch-pop-in 0.28s ease;
}

.arch-track {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 4rem;
  min-width: min-content;
  padding: 0.75rem 0;
  position: relative;
}

/* Circuit nodes */
.arch-node {
  position: absolute;
  flex-shrink: 0;
  display: flex;
  align-items: stretch;
  gap: 0;
  background: var(--arch-panel);
  border: 2px solid var(--arch-line);
  border-radius: 12px;
  padding: 0.5rem 0.25rem;
  min-width: 6.75rem;
  cursor: grab;
  user-select: none;
  touch-action: none;
  z-index: 3;
  isolation: isolate;
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.35);
  transition: border-color 0.2s, box-shadow 0.2s;
}

.arch-node.dragging {
  cursor: grabbing;
  z-index: 20;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.45);
  transition: none;
}

.arch-node-portside {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.2rem;
  padding: 0.1rem 0;
  position: relative;
  z-index: 4;
  min-width: 1.35rem;
}

.arch-node-portside:first-child {
  margin-inline-start: -6px;
}

.arch-node-portside.out {
  flex-direction: column;
  margin-inline-end: -6px;
}

.arch-port-label {
  font-size: 0.52rem;
  font-weight: 600;
  color: var(--arch-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  user-select: none;
  opacity: 0.85;
}

.arch-port-dot {
  width: 13px;
  height: 13px;
  padding: 0;
  border-radius: 50%;
  background: var(--arch-bg);
  border: 3px solid var(--arch-wire-idle);
  flex-shrink: 0;
  cursor: pointer;
  position: relative;
  z-index: 5;
  transition: transform 0.2s ease, background 0.2s, border-color 0.2s, box-shadow 0.2s;
}

.arch-port-dot:hover {
  transform: scale(1.3);
  border-color: var(--arch-accent);
}

.arch-port-dot.active {
  background: var(--arch-true);
  border-color: var(--arch-true);
  box-shadow: 0 0 10px var(--arch-true-glow);
}

.arch-port-dot.pulse {
  animation: arch-port-pulse 0.5s ease infinite;
}

@keyframes arch-port-pulse {
  0%, 100% { transform: scale(1); box-shadow: 0 0 6px var(--arch-true-glow); }
  50% { transform: scale(1.35); box-shadow: 0 0 14px var(--arch-true-glow); }
}

.arch-node.is-lit,
.arch-node.is-sim {
  border-color: var(--node-c, var(--arch-accent));
  box-shadow: 0 0 20px var(--node-g, rgba(59,130,246,0.35));
}

.arch-node-body {
  text-align: center;
  padding: 0.15rem 0.35rem;
  position: relative;
}

.arch-node-dot {
  position: absolute;
  top: 0;
  left: 0;
  width: 7px;
  height: 7px;
  border-radius: 50%;
}

.arch-node-dot.dot-up { background: var(--arch-true); box-shadow: 0 0 6px var(--arch-true-glow); }
.arch-node-dot.dot-down { background: var(--arch-false); }
.arch-node-dot.dot-planned { background: #64748b; }
.arch-node-dot.dot-unknown { background: #475569; }
.arch-node-dot.dot-none { display: none; }

.arch-node-name {
  display: block;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--arch-text);
}

.arch-node-sub {
  display: block;
  font-size: 0.62rem;
  color: var(--arch-muted);
}

.arch-node-zone {
  display: block;
  font-size: 0.58rem;
  color: var(--node-c, var(--arch-muted));
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-top: 0.15rem;
}

.arch-panel-section {
  margin-bottom: 1.1rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--arch-line);
}

.arch-panel-section:last-child { border-bottom: none; margin-bottom: 0; }

.arch-panel-title {
  margin: 0 0 0.65rem;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--arch-text);
}

.arch-stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.45rem;
  margin-bottom: 0.65rem;
}

.arch-stats-grid div {
  background: var(--arch-bg);
  border: 1px solid var(--arch-line);
  border-radius: 8px;
  padding: 0.45rem;
  text-align: center;
}

.arch-stats-grid span {
  display: block;
  font-size: 0.62rem;
  color: var(--arch-muted);
}

.arch-stats-grid strong {
  font-size: 1.1rem;
  color: var(--arch-text);
}

.arch-stats-grid strong.ok { color: var(--arch-true); }
.arch-stats-grid strong.err { color: var(--arch-false); }

.arch-flow-desc {
  margin: 0;
  font-size: 0.75rem;
  color: var(--arch-muted);
  line-height: 1.5;
}

.arch-truth-wrap { overflow-x: auto; }

.arch-truth {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.72rem;
}

.arch-truth th,
.arch-truth td {
  padding: 0.35rem 0.4rem;
  border: 1px solid var(--arch-line);
  text-align: start;
}

.arch-truth th {
  background: var(--arch-bg);
  color: var(--arch-muted);
  font-weight: 600;
}

.arch-truth tr.sim-on td {
  background: rgba(34, 197, 94, 0.08);
}

.arch-ctrl-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.45rem 0;
  font-size: 0.82rem;
  color: var(--arch-text);
  cursor: pointer;
}

.arch-toggle {
  width: 48px;
  height: 26px;
  background: var(--arch-false);
  border-radius: 13px;
  position: relative;
  transition: background 0.25s;
  flex-shrink: 0;
}

.arch-toggle.on { background: var(--arch-true); }

.arch-toggle::after {
  content: "";
  position: absolute;
  width: 20px;
  height: 20px;
  background: #fff;
  border-radius: 50%;
  top: 3px;
  left: 3px;
  transition: transform 0.25s;
}

.arch-toggle.on::after { transform: translateX(22px); }

.arch-hint {
  margin: 0;
  font-size: 0.78rem;
  color: var(--arch-muted);
  line-height: 1.55;
}

.arch-hint.err { color: var(--arch-false); }

.arch-save-msg {
  margin: 0.5rem 0 0;
  font-size: 0.78rem;
  text-align: center;
}

.arch-save-msg.ok { color: var(--arch-true); }
.arch-save-msg.err { color: var(--arch-false); }

/* Footer */
.arch-foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.65rem;
  padding: 0.65rem 1rem;
  background: var(--arch-panel);
  border-top: 1px solid var(--arch-line);
}

.arch-chips { display: flex; flex-wrap: wrap; gap: 0.35rem; }

.arch-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.2rem 0.5rem;
  font-size: 0.68rem;
  color: var(--arch-text);
  background: var(--arch-bg);
  border: 1px solid var(--arch-line);
  border-radius: 999px;
}

.arch-chip i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--c);
}

.arch-status-legend {
  display: flex;
  gap: 0.75rem;
  font-size: 0.68rem;
  color: var(--arch-muted);
}

.arch-status-legend span {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
}

.arch-status-legend i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  display: inline-block;
}

.arch-status-legend .dot-up { background: #34d399; }
.arch-status-legend .dot-down { background: #f87171; }
.arch-status-legend .dot-planned { background: #64748b; }

.arch-palette-node i.dot-up { background: #34d399; }
.arch-palette-node i.dot-down { background: #f87171; }
.arch-palette-node i.dot-planned { background: #64748b; }
.arch-palette-node i.dot-unknown { background: #475569; }
.arch-palette-node i.dot-none { display: none; }

/* Circuit دیگر fullscreen/overflow-hidden نیست — با اسکرول main دیده می‌شود */
.panel-arch.active {
  display: block;
  min-height: min-content;
  padding: 0;
  margin: 0;
  overflow: visible;
  height: auto;
  max-height: none;
}

.arch-control-host {
  display: block;
  width: 100%;
  min-height: min-content;
  overflow: visible;
  height: auto;
}

.arch-forge-full {
  display: flex;
  flex-direction: column;
  width: 100%;
  min-height: min(72vh, 820px);
  height: auto;
  overflow: visible;
  border-radius: 14px;
  border: 1px solid var(--arch-line, var(--border));
}

.arch-forge-full > .arch-status-bar,
.arch-forge-full > .arch-header,
.arch-forge-full > .arch-foot {
  flex-shrink: 0;
}

.arch-forge-full .arch-main-layout {
  display: grid;
  min-height: 560px;
  height: auto;
  overflow: visible;
  align-items: stretch;
  grid-template-columns: minmax(220px, 260px) minmax(0, 1fr) minmax(240px, 300px);
  grid-template-rows: auto;
}

.arch-forge-full .arch-canvas {
  min-height: 480px;
  height: 560px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.arch-forge-full .arch-canvas-viewport {
  flex: 1;
  min-height: 0;
}

@media (max-width: 1100px) {
  .arch-forge-full .arch-main-layout {
    grid-template-columns: 1fr;
    min-height: 0;
  }
  .arch-forge-full .arch-canvas {
    height: 420px;
    order: -1;
  }
}

.arch-canvas-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
  padding: 0.4rem 0.75rem;
  font-size: 0.72rem;
  color: var(--arch-muted);
  border-bottom: 1px solid var(--arch-line);
  background: rgba(0, 0, 0, 0.2);
  z-index: 5;
  position: relative;
  flex-shrink: 0;
}

.arch-view-controls {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.arch-vbtn {
  min-width: 1.65rem;
  height: 1.65rem;
  padding: 0 0.35rem;
  border: 1px solid var(--arch-line);
  border-radius: 6px;
  background: var(--arch-panel);
  color: var(--arch-text);
  font-size: 0.85rem;
  cursor: pointer;
  line-height: 1;
}

.arch-vbtn:hover {
  border-color: var(--arch-accent);
  color: var(--arch-accent);
}

.arch-zoom-pct {
  min-width: 2.75rem;
  text-align: center;
  font-variant-numeric: tabular-nums;
  font-size: 0.72rem;
  color: var(--arch-text);
}

.arch-xy-hud {
  font-family: ui-monospace, monospace;
  font-size: 0.68rem;
  color: #93c5fd;
  padding-inline-start: 0.35rem;
  border-inline-start: 1px solid var(--arch-line);
  min-width: 8rem;
}

.arch-forge-full .arch-sidebar {
  max-height: none;
  align-self: stretch;
  overflow: hidden;
}

/* اسکرoll مستقل هر sidebar — فقط روی .arch-sidebar-scroll */
.arch-forge .arch-sidebar-scroll,
.arch-forge .arch-truth-wrap {
  scrollbar-width: thin;
  scrollbar-color: var(--arch-scroll-thumb) var(--arch-scroll-track);
}

.arch-forge .arch-sidebar-scroll::-webkit-scrollbar,
.arch-forge .arch-truth-wrap::-webkit-scrollbar {
  width: 5px;
  height: 5px;
}

.arch-forge .arch-sidebar-scroll::-webkit-scrollbar-track,
.arch-forge .arch-truth-wrap::-webkit-scrollbar-track {
  background: var(--arch-scroll-track);
  border-radius: 4px;
}

.arch-forge .arch-sidebar-scroll::-webkit-scrollbar-thumb,
.arch-forge .arch-truth-wrap::-webkit-scrollbar-thumb {
  background: var(--arch-scroll-thumb);
  border-radius: 4px;
}

.arch-forge .arch-sidebar-scroll::-webkit-scrollbar-thumb:hover,
.arch-forge .arch-truth-wrap::-webkit-scrollbar-thumb:hover {
  background: var(--arch-scroll-thumb-hover);
}

.arch-canvas-hint { opacity: 0.75; font-size: 0.68rem; }

.arch-validate-banner {
  margin: 0;
  padding: 0.45rem 1rem;
  font-size: 0.72rem;
  border-bottom: 1px solid var(--arch-line);
}
.arch-validate-banner.warn {
  background: rgba(251, 191, 36, 0.12);
  color: #fcd34d;
}
.arch-validate-banner.err {
  background: rgba(239, 68, 68, 0.12);
  color: #fca5a5;
}

.arch-side-sticky {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--arch-panel);
  padding-bottom: 0.35rem;
  margin-bottom: 0.25rem;
}

.arch-palette-search {
  width: 100%;
  box-sizing: border-box;
  margin: 0 0 0.5rem;
  padding: 0.4rem 0.55rem;
  border: 1px solid var(--arch-line);
  border-radius: 8px;
  background: var(--arch-bg);
  color: var(--arch-text);
  font: inherit;
  font-size: 0.78rem;
}

.arch-derived-runtime {
  margin: 0 0 0.55rem;
  font-size: 0.72rem;
  color: #93c5fd;
}

.arch-node-op {
  font-size: 0.65rem;
  margin-inline: auto 0.25rem;
  opacity: 0.85;
}
.arch-node-op.doc { opacity: 0.45; }

.arch-gate-item.arch-gate-doc { opacity: 0.72; }
.arch-gate-item.arch-gate-live { border-color: rgba(34, 197, 94, 0.25); }

.arch-check-label {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.75rem;
  color: var(--arch-muted);
  margin-inline-end: 0.25rem;
}

.arch-track.vertical {
  flex-direction: column;
  gap: 2.5rem;
  align-items: center;
}

.arch-track.vertical .arch-node {
  flex-direction: column;
  align-items: center;
  min-width: 5.5rem;
}

.arch-track.vertical .arch-node-portside,
.arch-track.vertical .arch-node-portside.out {
  flex-direction: row;
  gap: 0.35rem;
}

.arch-signal-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  margin-top: 0.35rem;
}

.arch-signal-label {
  font-size: 0.7rem;
  font-weight: 700;
  font-family: monospace;
  color: var(--arch-true);
}

.arch-node.sig-false .arch-signal-label { color: var(--arch-false); }

.arch-toggle-sm {
  width: 36px;
  height: 20px;
  transform: scale(0.85);
}

.arch-toggle-sm::after {
  width: 14px;
  height: 14px;
}

.arch-toggle-sm.on::after { transform: translateX(16px); }

.arch-field {
  display: block;
  font-size: 0.75rem;
  color: var(--arch-muted);
  margin-bottom: 0.5rem;
}

.arch-textarea,
.arch-select,
.arch-step-in {
  width: 100%;
  margin-top: 0.25rem;
  background: var(--arch-bg);
  border: 1px solid var(--arch-line);
  border-radius: 6px;
  color: var(--arch-text);
  font: inherit;
  font-size: 0.78rem;
  padding: 0.35rem 0.45rem;
}

.arch-gate-ref {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  font-size: 0.72rem;
}

.arch-gate-ref div {
  padding: 0.35rem 0.45rem;
  background: var(--arch-bg);
  border-radius: 6px;
  border: 1px solid var(--arch-line);
}

.arch-gate-ref b {
  display: block;
  color: var(--arch-accent);
  margin-bottom: 0.15rem;
}

.arch-gate-ref span { color: var(--arch-muted); }

/* ── نقشه view (تب سرویس‌ها) ── */
.arch-view {
  border: 1px solid var(--arch-line);
  border-radius: 14px;
  overflow: hidden;
  background: var(--arch-bg, #0f172a);
}

.arch-view .arch-tabs {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 0;
  padding: 3px;
  margin: 0.85rem 0.85rem 0;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--arch-line);
  border-radius: 10px;
}

.arch-view .arch-tab {
  border: none;
  background: transparent;
  color: var(--arch-muted, #94a3b8);
  font: inherit;
  font-size: 0.8rem;
  padding: 0.4rem 0.85rem;
  border-radius: 7px;
  cursor: pointer;
}

.arch-view .arch-tab.active {
  background: linear-gradient(135deg, #6366f1, #4f46e5);
  color: #fff;
}

.arch-view .arch-desc {
  margin: 0.5rem 0.85rem 0.75rem;
  font-size: 0.82rem;
  color: var(--arch-muted, #94a3b8);
}

.arch-flow-seg {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin: 0 0.85rem 0.65rem;
}

.arch-flow-btn {
  border: 1px solid var(--arch-line, #334155);
  background: rgba(0, 0, 0, 0.2);
  color: var(--arch-text, #f8fafc);
  font: inherit;
  font-size: 0.72rem;
  padding: 0.3rem 0.6rem;
  border-radius: 999px;
  cursor: pointer;
}

.arch-flow-btn.active {
  border-color: #8b5cf6;
  background: rgba(139, 92, 246, 0.2);
}

.arch-view-layout {
  display: grid;
  grid-template-columns: 1fr minmax(200px, 240px);
  gap: 0.85rem;
  padding: 0 0.85rem 0.85rem;
}

@media (max-width: 900px) {
  .arch-view-layout { grid-template-columns: 1fr; }
}

.arch-view-main { display: flex; flex-direction: column; gap: 0.75rem; }

.arch-pipeline-wrap {
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--arch-line, #334155);
  border-radius: 12px;
  padding: 1rem 0.75rem;
  overflow-x: auto;
}

.arch-pipeline-empty {
  margin: 0;
  text-align: center;
  color: var(--arch-muted);
  font-size: 0.82rem;
  padding: 1rem;
}

.arch-pipeline-track {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 0;
  min-width: min-content;
}

.arch-connector {
  flex-shrink: 0;
  width: 2.5rem;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

.arch-connector-line {
  width: 100%;
  height: 2px;
  background: linear-gradient(90deg, #6366f1, #818cf8);
  box-shadow: 0 0 8px rgba(99, 102, 241, 0.4);
}

.arch-connector-num {
  position: absolute;
  width: 1.25rem;
  height: 1.25rem;
  display: grid;
  place-items: center;
  background: #6366f1;
  color: #fff;
  font-size: 0.6rem;
  font-weight: 700;
  border-radius: 50%;
}

.arch-card {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 5rem;
  padding: 0.55rem 0.5rem;
  background: rgba(15, 23, 42, 0.9);
  border: 1px solid var(--arch-line, #334155);
  border-radius: 10px;
  position: relative;
}

.arch-card.is-active {
  border-color: var(--card-c, #6366f1);
  box-shadow: 0 0 16px var(--card-g, rgba(99, 102, 241, 0.35));
}

.arch-card-dot {
  position: absolute;
  top: 5px;
  left: 5px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
}

.arch-card-dot.dot-up { background: #34d399; }
.arch-card-dot.dot-down { background: #f87171; }
.arch-card-dot.dot-planned { background: #64748b; }
.arch-card-dot.dot-unknown { background: #475569; }
.arch-card-dot.dot-none { display: none; }

.arch-card-name {
  font-size: 0.76rem;
  font-weight: 700;
  color: #f8fafc;
}

.arch-card-sub {
  font-size: 0.62rem;
  color: #94a3b8;
}

.arch-card-zone {
  font-size: 0.58rem;
  color: var(--card-c, #94a3b8);
  text-transform: uppercase;
}

.arch-zones {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.55rem;
}

@media (max-width: 640px) {
  .arch-zones { grid-template-columns: repeat(2, 1fr); }
}

.arch-zone {
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--arch-line, #334155);
  border-radius: 10px;
  padding: 0.5rem 0.6rem;
  opacity: 0.55;
}

.arch-zone.is-live {
  opacity: 1;
  box-shadow: inset 0 0 0 1px var(--zone-c), 0 0 12px var(--zone-g);
}

.arch-zone-head {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.62rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--zone-c);
  margin-bottom: 0.35rem;
  padding-bottom: 0.25rem;
  border-bottom: 1px solid var(--arch-line, #334155);
}

.arch-zone-head em {
  font-style: normal;
  color: #94a3b8;
  margin-inline-start: auto;
  font-weight: 400;
  text-transform: none;
}

.arch-zone-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--zone-c);
}

.arch-zone-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
}

.arch-mini {
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
  padding: 0.15rem 0.35rem;
  background: rgba(0, 0, 0, 0.25);
  border-radius: 5px;
  font-size: 0.65rem;
  color: #f8fafc;
}

.arch-mini.is-off { opacity: 0.35; }
.arch-mini i { width: 5px; height: 5px; border-radius: 50%; }
.arch-mini i.dot-up { background: #34d399; }
.arch-mini i.dot-down { background: #f87171; }
.arch-mini i.dot-planned { background: #64748b; }

.arch-view-side {
  border: 1px solid var(--arch-line, #334155);
  border-radius: 12px;
  padding: 0;
  background: rgba(0, 0, 0, 0.2);
  max-height: 420px;
  overflow: hidden;
}

.arch-view-side .arch-sidebar-scroll {
  padding: 0.85rem;
}

.arch-view-side h4 {
  margin: 0 0 0.65rem;
  font-size: 0.85rem;
}

.arch-steps {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.arch-steps li {
  display: flex;
  gap: 0.5rem;
  font-size: 0.78rem;
  align-items: flex-start;
}

.arch-steps li b {
  width: 1.25rem;
  height: 1.25rem;
  display: grid;
  place-items: center;
  background: #6366f1;
  color: #fff;
  font-size: 0.65rem;
  border-radius: 50%;
  flex-shrink: 0;
}

.arch-runtime-mini {
  margin-top: 0.75rem;
  padding-top: 0.65rem;
  border-top: 1px solid var(--arch-line, #334155);
  font-size: 0.72rem;
  color: #94a3b8;
}

.arch-runtime-mini p { margin: 0.25rem 0; }

.arch-view .arch-foot {
  margin: 0;
  border-radius: 0;
  border: none;
  border-top: 1px solid var(--arch-line, #334155);
}

@media (max-width: 960px) {
  .arch-forge-full .arch-main-layout {
    grid-template-columns: 1fr;
  }
  .arch-control-host {
    min-height: 70vh;
  }
}

.arch-palette-hint {
  margin: 0 0 0.65rem;
  font-size: 0.68rem;
  color: var(--arch-muted);
}

.arch-gate-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.55rem 0.65rem;
  margin-bottom: 0.4rem;
  background: var(--arch-bg);
  border: 2px solid var(--arch-line);
  border-radius: 12px;
  color: var(--arch-text);
  font: inherit;
  text-align: start;
  cursor: grab;
  transition: all 0.2s;
}

.arch-gate-item:hover {
  border-color: var(--arch-accent);
  transform: translateX(-4px);
}

.arch-gate-item:active { cursor: grabbing; }

.arch-gate-symbol {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  font-size: 0.65rem;
  font-weight: 700;
  color: #fff;
  background: var(--gc, var(--arch-accent));
  flex-shrink: 0;
}

.arch-gate-info { flex: 1; min-width: 0; }

.arch-gate-name {
  display: block;
  font-size: 0.82rem;
  font-weight: 600;
}

.arch-gate-desc {
  display: block;
  font-size: 0.68rem;
  color: var(--arch-muted);
}

.arch-gate-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.arch-gate-dot.dot-up { background: var(--arch-true); }
.arch-gate-dot.dot-down { background: var(--arch-false); }
.arch-gate-dot.dot-planned { background: #64748b; }
.arch-gate-dot.dot-unknown { background: #475569; }
.arch-gate-dot.dot-none { display: none; }

.arch-node-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  margin-bottom: 0.2rem;
}

.arch-node-del {
  border: none;
  background: transparent;
  color: var(--arch-muted);
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  padding: 0 0.15rem;
  border-radius: 4px;
}

.arch-node-del:hover {
  background: var(--arch-false);
  color: #fff;
}

.arch-node.dragging {
  opacity: 0.75;
  z-index: 10;
}

.arch-runtime-box {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  font-size: 0.75rem;
}

.arch-runtime-box div {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.4rem 0.5rem;
  background: var(--arch-bg);
  border: 1px solid var(--arch-line);
  border-radius: 8px;
}

.arch-runtime-box span { color: var(--arch-muted); }
.arch-runtime-box strong { color: var(--arch-text); font-size: 0.72rem; }

.arch-shortcuts {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.72rem;
  color: var(--arch-muted);
}

.arch-shortcuts kbd {
  background: var(--arch-bg);
  border: 1px solid var(--arch-line);
  border-radius: 4px;
  padding: 0.1rem 0.35rem;
  font-size: 0.65rem;
  margin-inline-end: 0.25rem;
}


/* TruthForge gate palette */

/* --- Model settings panel (Admin) --- */
.model-settings-host {
  margin-top: 1rem;
}

.model-settings-panel {
  display: grid;
  gap: 1rem;
}

.model-settings-toolbar {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  padding: 1rem 1.25rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
}

.model-settings-toolbar h3 {
  margin: 0 0 0.25rem;
}

.model-settings-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.model-settings-status {
  padding: 0.65rem 1rem;
  border-radius: 10px;
  font-size: 0.9rem;
}

.model-settings-status.ok {
  background: rgba(52, 211, 153, 0.12);
  color: var(--ok);
  border: 1px solid rgba(52, 211, 153, 0.35);
}

.model-settings-status.err {
  background: rgba(248, 113, 113, 0.12);
  color: var(--err);
  border: 1px solid rgba(248, 113, 113, 0.35);
}

.model-sections-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1rem;
}

.model-section-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1rem 1.1rem;
  display: grid;
  gap: 0.65rem;
}

.model-section-moa {
  grid-column: 1 / -1;
}

.model-section-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
}

.model-section-head h4 {
  margin: 0;
  font-size: 0.95rem;
}

.model-toggle {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.85rem;
  color: var(--muted);
}

.model-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 0.75rem;
}

.model-grid label,
.model-section-card > label {
  display: grid;
  gap: 0.35rem;
  font-size: 0.82rem;
  color: var(--muted);
}

.model-check {
  display: flex !important;
  flex-direction: row;
  align-items: center;
  gap: 0.5rem;
}

.model-agent-row {
  display: grid;
  grid-template-columns: auto 1fr 2fr;
  gap: 0.5rem;
  align-items: center;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border);
}

.model-test-row {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.75rem;
  flex-wrap: wrap;
}

.model-test-row input {
  flex: 1;
  min-width: 200px;
}

.model-test-result {
  margin-top: 0.5rem;
  max-height: 240px;
  overflow: auto;
  font-size: 0.75rem;
  background: var(--surface2);
  padding: 0.75rem;
  border-radius: 10px;
}

.model-routing-card h4 {
  margin: 0 0 0.75rem;
}

.model-env-details {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.75rem 1rem;
}

.model-env-details summary {
  cursor: pointer;
  color: var(--muted);
  font-size: 0.85rem;
}

.arch-model-layer {
  display: grid;
  gap: 0.35rem;
  font-size: 0.82rem;
}

.arch-model-row {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.35rem 0;
  border-bottom: 1px solid var(--border);
}

.arch-model-row code {
  font-size: 0.75rem;
  color: var(--accent);
  word-break: break-all;
}

.arch-model-moa-status {
  padding: 0.45rem 0.6rem;
  border-radius: 8px;
  font-size: 0.78rem;
  margin-bottom: 0.35rem;
}

.arch-model-moa-status.on {
  background: rgba(52, 211, 153, 0.12);
  color: var(--ok);
  border: 1px solid rgba(52, 211, 153, 0.3);
}

.arch-model-moa-status.off {
  background: rgba(143, 163, 188, 0.1);
  color: var(--muted);
  border: 1px solid var(--border);
}

/* ─── Harmony Control Plane ─── */
.harmony-hub {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  width: 100%;
  max-width: none;
  margin: 0;
  box-sizing: border-box;
}

.harm-header {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
}

.harm-title {
  margin: 0;
  font-size: 1.35rem;
  background: linear-gradient(90deg, #a5b4fc, #34d399);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.harm-sub { margin: 0.25rem 0 0; color: var(--muted); font-size: 0.88rem; }

.harm-header-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; }

.harm-status {
  padding: 0.55rem 0.75rem;
  border-radius: 10px;
  font-size: 0.84rem;
  background: rgba(99, 102, 241, 0.1);
  border: 1px solid rgba(99, 102, 241, 0.25);
}

.harm-status--ok { border-color: rgba(52, 211, 153, 0.4); background: rgba(52, 211, 153, 0.08); }
.harm-status--warn { border-color: rgba(251, 191, 36, 0.4); background: rgba(251, 191, 36, 0.08); }
.harm-status--err { border-color: rgba(248, 113, 113, 0.4); background: rgba(248, 113, 113, 0.08); }

.harm-section h3 { margin: 0 0 0.35rem; font-size: 1rem; }

.harm-profiles {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 0.75rem;
  margin-top: 0.75rem;
}

.harm-profile {
  display: flex;
  gap: 0.75rem;
  align-items: flex-start;
  padding: 0.85rem;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: rgba(15, 23, 42, 0.5);
  transition: border-color 0.15s, box-shadow 0.15s;
}

.harm-profile:hover { border-color: rgba(129, 140, 248, 0.45); }

.harm-profile--active {
  border-color: rgba(52, 211, 153, 0.55);
  box-shadow: 0 0 0 1px rgba(52, 211, 153, 0.15);
}

.harm-profile-icon { font-size: 1.6rem; line-height: 1; flex-shrink: 0; }

.harm-profile-body { flex: 1; min-width: 0; }

.harm-profile-body h4 { margin: 0 0 0.25rem; font-size: 0.95rem; }

.harm-profile-body p { margin: 0 0 0.4rem; font-size: 0.8rem; color: var(--muted); line-height: 1.45; }

.harm-profile-meta { display: flex; flex-wrap: wrap; gap: 0.35rem; align-items: center; }

.harm-profile-meta code { font-size: 0.72rem; }

.harm-tag {
  font-size: 0.68rem;
  padding: 0.12rem 0.4rem;
  border-radius: 999px;
  background: rgba(99, 102, 241, 0.15);
  color: #c7d2fe;
}

.harm-active-badge {
  font-size: 0.68rem;
  padding: 0.1rem 0.35rem;
  border-radius: 6px;
  background: rgba(52, 211, 153, 0.2);
  color: var(--ok);
  font-weight: 600;
}

.harm-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

@media (max-width: 900px) {
  .harm-grid { grid-template-columns: 1fr; }
}

.harm-card {
  padding: 1rem;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: rgba(15, 23, 42, 0.35);
}

.harm-zones {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.harm-zone {
  padding: 0.55rem 0.65rem;
  border-radius: 10px;
  border: 1px solid color-mix(in srgb, var(--zone-color) 40%, transparent);
  background: color-mix(in srgb, var(--zone-color) 8%, transparent);
}

.harm-zone-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.35rem;
}

.harm-zone-label { font-weight: 600; font-size: 0.82rem; }

.harm-zone-stats { font-size: 0.72rem; color: var(--muted); }

.harm-zone-svcs {
  margin: 0;
  padding: 0;
  list-style: none;
  font-size: 0.72rem;
  color: var(--muted);
}

.harm-zone-svcs li { padding: 0.15rem 0; display: flex; align-items: center; gap: 0.3rem; }

.harm-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
  display: inline-block;
}

.harm-dot--up { background: var(--ok); }
.harm-dot--down { background: var(--err); }
.harm-dot--planned { background: #64748b; }
.harm-dot--unknown { background: #475569; }

.harm-flow-list { display: flex; flex-direction: column; gap: 0.35rem; margin-top: 0.5rem; }

.harm-flow-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.45rem 0.55rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  font-size: 0.82rem;
}

.harm-flow-row--default { border-color: rgba(52, 211, 153, 0.4); }

.harm-flow-meta { font-size: 0.72rem; color: var(--muted); margin-top: 0.15rem; }

.harm-flow-default {
  font-size: 0.65rem;
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
  background: rgba(52, 211, 153, 0.2);
  color: var(--ok);
}

.harm-table { font-size: 0.82rem; }

.harm-zone--click {
  width: 100%;
  text-align: inherit;
  cursor: pointer;
  font: inherit;
  color: inherit;
  transition: transform 0.12s, box-shadow 0.12s;
}

.harm-zone--click:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
}

.harm-zone-cta {
  display: block;
  margin-top: 0.35rem;
  font-size: 0.68rem;
  color: var(--zone-color, #a5b4fc);
  opacity: 0.85;
}

.harm-save-profile {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 0.5rem;
  margin-top: 0.65rem;
  align-items: end;
}

@media (max-width: 700px) {
  .harm-save-profile { grid-template-columns: 1fr; }
}

.harm-save-profile input {
  font: inherit;
  padding: 0.45rem 0.55rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.2);
  color: inherit;
}

/* Layer drawer */
.layer-drawer-root {
  position: fixed;
  inset: 0;
  z-index: 15000;
}

.layer-drawer-root[hidden] { display: none; }

.layer-drawer-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(2, 6, 23, 0.65);
}

.layer-drawer {
  position: absolute;
  top: 0;
  left: 0;
  width: min(420px, 100vw);
  height: 100%;
  background: #0f172a;
  border-inline-end: 1px solid rgba(99, 102, 241, 0.35);
  display: flex;
  flex-direction: column;
  box-shadow: 8px 0 40px rgba(0, 0, 0, 0.45);
  animation: layerSlideIn 0.2s ease;
}

@keyframes layerSlideIn {
  from { transform: translateX(-100%); }
  to { transform: translateX(0); }
}

[dir="rtl"] .layer-drawer {
  left: auto;
  right: 0;
  border-inline-end: none;
  border-inline-start: 1px solid rgba(99, 102, 241, 0.35);
  animation-name: layerSlideInRtl;
}

@keyframes layerSlideInRtl {
  from { transform: translateX(100%); }
  to { transform: translateX(0); }
}

.layer-drawer-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 1rem 1.1rem;
  border-bottom: 1px solid var(--border);
}

.layer-drawer-kicker {
  margin: 0 0 0.2rem;
  font-size: 0.72rem;
  color: #a5b4fc;
}

.layer-drawer-head h3 { margin: 0; font-size: 1.05rem; }

.layer-drawer-body {
  flex: 1;
  overflow-y: auto;
  padding: 1rem 1.1rem;
}

.layer-drawer-foot {
  padding: 0.75rem 1.1rem;
  border-top: 1px solid var(--border);
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

.layer-drawer-foot-actions {
  margin-inline-start: auto;
  display: flex;
  gap: 0.5rem;
}

.layer-field {
  display: block;
  margin-bottom: 0.75rem;
  font-size: 0.84rem;
}

.layer-field select,
.layer-field input,
.layer-field textarea {
  display: block;
  width: 100%;
  margin-top: 0.25rem;
  font: inherit;
  padding: 0.4rem 0.5rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.25);
  color: inherit;
}

.layer-check {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  margin-bottom: 0.55rem;
  font-size: 0.84rem;
}

.layer-details {
  margin: 0.65rem 0;
  padding: 0.55rem;
  border: 1px solid var(--border);
  border-radius: 10px;
}

.layer-details summary {
  cursor: pointer;
  font-weight: 600;
  font-size: 0.88rem;
}

.layer-balance {
  display: grid;
  gap: 0.35rem;
  margin-bottom: 0.75rem;
  font-size: 0.78rem;
}

.layer-balance input[type="range"] { width: 100%; }

.layer-agent-row {
  display: grid;
  gap: 0.35rem;
  margin-bottom: 0.5rem;
  padding: 0.45rem;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.2);
  font-size: 0.8rem;
}

.layer-svc-list ul {
  margin: 0.35rem 0 0;
  padding: 0;
  list-style: none;
  font-size: 0.75rem;
  color: var(--muted);
}

.layer-test-msg { font-size: 0.78rem; flex: 1; }
.layer-test-msg.ok { color: var(--ok); }
.layer-test-msg.err { color: var(--err); }

.harm-zone-pill {
  display: inline-block;
  padding: 0.15rem 0.45rem;
  border-radius: 6px;
  font-size: 0.72rem;
  font-weight: 600;
}

/* ─── Shared admin links ─── */
.btn-link {
  background: none;
  border: none;
  padding: 0;
  font: inherit;
  color: #a5b4fc;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.btn-link:hover { color: #c4b5fd; }

.layer-studio-link { margin: 0 0 0.65rem; font-size: 0.84rem; }

/* ─── Voice Studio ─── */
.voice-studio {
  display: flex;
  flex-direction: column;
  gap: 1.1rem;
  width: 100%;
  max-width: none;
  overflow: visible;
  padding-bottom: 2.5rem;
  box-sizing: border-box;
}

.studio-hero {
  position: relative;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: flex-end;
  gap: 1rem;
  padding: 1.35rem 1.5rem;
  border-radius: 16px;
  overflow: hidden;
  border: 1px solid rgba(244, 114, 182, 0.28);
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.14), rgba(244, 114, 182, 0.1));
}

.studio-hero-glow {
  position: absolute;
  inset: -40% auto auto -20%;
  width: 55%;
  height: 140%;
  background: radial-gradient(circle, rgba(244, 114, 182, 0.22), transparent 65%);
  pointer-events: none;
}

.studio-hero-bars {
  position: absolute;
  inset: auto 1rem 0.75rem auto;
  display: flex;
  align-items: flex-end;
  gap: 3px;
  height: 2.5rem;
  opacity: 0.35;
  pointer-events: none;
}

.studio-hero-bars span {
  display: block;
  width: 4px;
  border-radius: 2px;
  background: linear-gradient(180deg, #f472b6, #818cf8);
  animation: studio-bar 1.2s ease-in-out infinite;
  animation-delay: calc(var(--i) * 0.08s);
  height: calc(20% + (var(--i) * 5%) % 80%);
}

@keyframes studio-bar {
  0%, 100% { transform: scaleY(0.45); opacity: 0.5; }
  50% { transform: scaleY(1); opacity: 1; }
}

.studio-hero-text { position: relative; z-index: 1; }

.studio-kicker {
  margin: 0 0 0.15rem;
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #f9a8d4;
}

.studio-hero h2 {
  margin: 0;
  font-size: 1.45rem;
  background: linear-gradient(90deg, #f9a8d4, #a5b4fc);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.studio-lead { margin: 0.35rem 0 0; color: var(--muted); font-size: 0.88rem; }

.studio-hero-actions {
  position: relative;
  z-index: 1;
  display: flex;
  gap: 0.5rem;
}

.studio-status {
  padding: 0.5rem 0.75rem;
  border-radius: 10px;
  font-size: 0.84rem;
  background: rgba(244, 114, 182, 0.08);
  border: 1px solid rgba(244, 114, 182, 0.22);
}

.studio-status--ok { border-color: rgba(52, 211, 153, 0.4); background: rgba(52, 211, 153, 0.08); }
.studio-status--warn { border-color: rgba(251, 191, 36, 0.4); background: rgba(251, 191, 36, 0.08); }
.studio-status--err { border-color: rgba(248, 113, 113, 0.4); background: rgba(248, 113, 113, 0.08); }
.studio-status--busy { opacity: 0.85; }

.studio-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 1rem;
}

.studio-engine-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 0.75rem;
}

.studio-card-fx--primary {
  max-width: 42rem;
  border-color: rgba(129, 140, 248, 0.4);
  background: rgba(15, 23, 42, 0.55);
}

.studio-card-fx--primary .voice-fx-section {
  border-top: none;
  padding-top: 0;
  margin-top: 0;
}

.studio-card {
  padding: 1rem 1.1rem;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.18);
}

.studio-card h3 { margin: 0 0 0.25rem; font-size: 1rem; }
.studio-card .sub { margin: 0 0 0.75rem; font-size: 0.82rem; color: var(--muted); }

.studio-card-tts { border-color: rgba(129, 140, 248, 0.35); }
.studio-card-fx { border-color: rgba(244, 114, 182, 0.35); }

.studio-field {
  display: block;
  margin-bottom: 0.65rem;
  font-size: 0.84rem;
}

.studio-field input,
.studio-field select,
.studio-field textarea {
  display: block;
  width: 100%;
  margin-top: 0.25rem;
  font: inherit;
  padding: 0.4rem 0.5rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.25);
  color: inherit;
}

.studio-creds-list {
  margin: 0.5rem 0;
  padding: 0;
  list-style: none;
  font-size: 0.78rem;
  color: var(--muted);
}

.studio-btn-row { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 0.5rem; }

.studio-presets {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.studio-preset {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.15rem;
  padding: 0.65rem 0.4rem;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.2);
  cursor: pointer;
  font: inherit;
  color: inherit;
  transition: border-color 0.15s, transform 0.15s;
}

.studio-preset:hover { border-color: rgba(244, 114, 182, 0.5); transform: translateY(-1px); }

.studio-preset--active {
  border-color: rgba(244, 114, 182, 0.75);
  background: rgba(244, 114, 182, 0.12);
  box-shadow: 0 0 0 1px rgba(244, 114, 182, 0.25);
}

.studio-preset-label { font-weight: 600; font-size: 0.88rem; }
.studio-preset-id { font-size: 0.68rem; color: var(--muted); font-family: ui-monospace, monospace; }

.studio-check {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  margin-bottom: 0.45rem;
  font-size: 0.84rem;
}

.studio-player {
  width: 100%;
  margin-top: 0.35rem;
}

.studio-active-speaker {
  margin: 0 0 0.75rem;
  padding: 0.65rem 0.85rem;
  border-radius: 12px;
  border: 1px solid rgba(244, 114, 182, 0.4);
  background: rgba(244, 114, 182, 0.1);
  font-size: 0.9rem;
}

.studio-active-speaker strong {
  color: #f9a8d4;
}

.studio-active-speaker code {
  font-size: 0.75rem;
  color: var(--muted);
}

.studio-footnote {
  margin: 0;
  font-size: 0.8rem;
  color: var(--muted);
  padding-bottom: 2rem;
}

.studio-inline-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.25rem;
}

.studio-inline-row input { flex: 1 1 12rem; }

.studio-health-card {
  margin: 0.5rem 0 0.75rem;
  padding: 0.65rem 0.75rem;
  border-radius: 10px;
  border: 1px solid rgba(52, 211, 153, 0.25);
  background: rgba(52, 211, 153, 0.06);
  font-size: 0.78rem;
}

.studio-health-card:has(.studio-health-val:first-child) {
  border-color: rgba(248, 113, 113, 0.35);
  background: rgba(248, 113, 113, 0.08);
}

.studio-health-row {
  display: grid;
  grid-template-columns: minmax(5rem, auto) 1fr;
  gap: 0.35rem 0.65rem;
  align-items: baseline;
  margin-bottom: 0.35rem;
}

.studio-health-row:last-of-type { margin-bottom: 0.15rem; }

.studio-health-label {
  font-size: 0.68rem;
  color: var(--muted);
  font-weight: 600;
}

.studio-health-val {
  grid-column: 1 / -1;
  font-size: 0.8rem;
}

.studio-health-row code {
  font-size: 0.72rem;
  word-break: break-all;
}

.studio-catalog-meta {
  margin: 0 0 0.65rem;
  font-size: 0.78rem;
  color: var(--muted);
}

.studio-details {
  margin: 0.5rem 0 0.65rem;
  padding: 0.55rem 0.65rem;
  border: 1px dashed var(--border);
  border-radius: 10px;
}

.studio-details summary {
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 600;
  color: #a5b4fc;
}

.studio-card-fx .studio-card h3 { margin-top: 0; }

.studio-card select {
  display: block;
  width: 100%;
  margin-top: 0.25rem;
  font: inherit;
  padding: 0.45rem 0.5rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.25);
  color: inherit;
}

.studio-card select option { background: #0e1218; }

.harm-voice-strip {
  padding: 0.65rem 0.85rem;
  border-radius: 12px;
  border: 1px solid rgba(244, 114, 182, 0.28);
  background: linear-gradient(90deg, rgba(244, 114, 182, 0.08), rgba(99, 102, 241, 0.08));
}

.harm-voice-strip-inner {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.86rem;
}

.harm-voice-strip-inner .sub {
  display: block;
  margin-top: 0.2rem;
  font-size: 0.78rem;
  color: var(--muted);
}

/* ─── Admin Control Plane (ADM-01) ─── */
.control-plane {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  min-height: min-content;
  width: 100%;
}

.cp-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  flex-wrap: wrap;
  padding: 0.15rem 0.1rem;
}

.cp-title {
  margin: 0;
  font-size: 1.25rem;
}

.cp-sub {
  margin: 0.3rem 0 0;
  color: var(--muted);
  font-size: 0.85rem;
}

.cp-subnav {
  display: flex;
  flex-wrap: nowrap;
  gap: 0.35rem;
  padding: 0.35rem 0.15rem 0.55rem;
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  position: sticky;
  top: 0;
  z-index: 5;
  background: color-mix(in srgb, var(--bg) 88%, var(--surface));
  backdrop-filter: blur(8px);
}

.cp-subtab {
  font: inherit;
  cursor: pointer;
  padding: 0.45rem 0.85rem;
  border-radius: 999px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  flex: 0 0 auto;
  white-space: nowrap;
}

.cp-subtab:hover {
  color: inherit;
  background: rgba(255, 255, 255, 0.04);
}

.cp-subtab.active {
  color: inherit;
  border-color: color-mix(in srgb, var(--accent) 45%, var(--border));
  background: rgba(99, 102, 241, 0.16);
}

.cp-status {
  min-height: 1.1rem;
  font-size: 0.82rem;
  color: var(--muted);
}

.cp-status--err {
  color: #f87171;
}

.cp-panes {
  min-height: 0;
  overflow: visible;
  position: relative;
}

/* فقط pane فعال — مخفی‌سازی قطعی حتی اگر mount کلاس را عوض کند */
.cp-panes > [data-pane] {
  display: none !important;
}

.cp-panes > [data-pane].active:not([hidden]) {
  display: block !important;
  min-height: min-content;
  overflow: visible;
  padding-bottom: 1rem;
}

/* ماژول‌های flex داخل pane فعال */
.cp-panes > [data-pane].active.harmony-hub:not([hidden]),
.cp-panes > [data-pane].active.voice-studio:not([hidden]),
.cp-panes > [data-pane].active.arch-forge:not([hidden]) {
  display: flex !important;
  flex-direction: column;
}

.cp-pane {
  display: none;
}

.cp-pane.active {
  display: block;
  min-height: min-content;
  overflow: visible;
  padding-bottom: 1rem;
}

/* زیرمنوهای غیر-circuit همیشه با ارتفاع محتوا اسکرول شوند */
.control-plane:not(.cp--circuit) .cp-pane.active {
  max-height: none;
  overflow: visible;
}

.control-plane.cp--circuit {
  height: auto;
  min-height: min-content;
  gap: 0.75rem;
  overflow: visible;
}

.control-plane.cp--circuit .cp-header,
.control-plane.cp--circuit .cp-subnav,
.control-plane.cp--circuit .cp-status {
  flex-shrink: 0;
}

.control-plane.cp--circuit .cp-panes {
  flex: none;
  min-height: min-content;
  overflow: visible;
  height: auto;
}

.control-plane.cp--circuit .cp-pane[data-pane="circuit"].active {
  height: auto;
  min-height: min-content;
  overflow: visible;
  padding-bottom: 1rem;
}

.cp-overview {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.cp-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 0.65rem;
}

.cp-card {
  padding: 0.75rem 0.85rem;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.18);
}

.cp-card h4 {
  margin: 0 0 0.35rem;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--muted);
}

.cp-card p {
  margin: 0;
  font-size: 0.95rem;
  word-break: break-word;
}

.cp-card .sub {
  display: inline;
  margin: 0;
  font-size: 0.75rem;
  color: var(--muted);
}

.cp-ssot h3 {
  margin-top: 0;
}

.cp-quick {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

#control-plane.panel.active {
  display: block;
  width: 100%;
  min-height: min-content;
  overflow: visible !important;
  height: auto !important;
  max-height: none !important;
}

#controlPlaneRoot,
#controlPlaneRoot .control-plane {
  width: 100%;
  max-width: none;
  min-height: min-content;
  height: auto !important;
  overflow: visible !important;
}

#controlPlaneRoot .voice-studio,
#controlPlaneRoot .harmony-hub,
#controlPlaneRoot .model-settings-host,
#controlPlaneRoot .cp-overview,
#controlPlaneRoot .cp-pane.active {
  width: 100%;
  overflow: visible !important;
  max-height: none !important;
  min-height: min-content;
  height: auto;
}

/* اسکرول نرم برای main و جداول */
.app-screen > main,
.table-wrap,
.cp-subnav,
.app-screen > .tabs {
  scrollbar-color: #475569 transparent;
}

.app-screen > main::-webkit-scrollbar,
.table-wrap::-webkit-scrollbar {
  width: 12px;
  height: 12px;
}

.app-screen > main::-webkit-scrollbar-track {
  background: rgba(15, 23, 42, 0.6);
}

.app-screen > main::-webkit-scrollbar-thumb,
.table-wrap::-webkit-scrollbar-thumb {
  background: #64748b;
  border-radius: 999px;
  border: 2px solid transparent;
  background-clip: padding-box;
}

.app-screen > main::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
  background-clip: padding-box;
}

#learning.panel.active .card + .card {
  margin-top: 0;
}

.pager {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.cp-drift {
  margin: 0.5rem 0 0;
  color: #fbbf24;
  font-size: 0.82rem;
}

.btn-row.settings-hub-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

/* Safety: هیچ لایهٔ CP نباید اسکرول main را قطع کند */
body.admin-authed .app-screen > main {
  overflow-y: scroll !important;
  overflow-x: hidden !important;
  flex: 1 1 auto !important;
  min-height: 0 !important;
}

body.admin-authed #control-plane,
body.admin-authed #controlPlaneRoot,
body.admin-authed .control-plane,
body.admin-authed .cp-panes,
body.admin-authed .cp-pane,
body.admin-authed .harmony-hub,
body.admin-authed .voice-studio,
body.admin-authed .arch-control-host,
body.admin-authed .arch-forge-full {
  max-height: none;
}

body.admin-authed .arch-forge-full {
  overflow: visible;
}

/* ========== Mind OS Monitor ========== */
.cp-card--mind {
  border-color: rgba(56, 189, 248, 0.35);
  background: linear-gradient(145deg, rgba(14, 30, 48, 0.9), rgba(10, 16, 28, 0.95));
}
.mind-monitor {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  padding: 0.25rem 0 1.5rem;
  color: #e2e8f0;
}
.mind-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  flex-wrap: wrap;
}
.mind-title {
  margin: 0 0 0.25rem;
  font-size: 1.15rem;
}
.mind-sub {
  margin: 0;
  color: var(--muted, #94a3b8);
  font-size: 0.85rem;
  max-width: 42rem;
}
.mind-kpis {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(6.5rem, 1fr));
  gap: 0.55rem;
}
.mind-kpi {
  border: 1px solid rgba(148, 163, 184, 0.2);
  border-radius: 12px;
  padding: 0.65rem 0.75rem;
  background: rgba(15, 23, 42, 0.65);
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}
.mind-kpi-val {
  font-size: 1.25rem;
  font-weight: 650;
  letter-spacing: -0.02em;
}
.mind-kpi-label {
  font-size: 0.72rem;
  color: var(--muted, #94a3b8);
}
.mind-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.85rem;
}
@media (max-width: 960px) {
  .mind-grid { grid-template-columns: 1fr; }
}
.mind-card {
  border: 1px solid rgba(148, 163, 184, 0.18);
  border-radius: 14px;
  padding: 0.9rem 1rem;
  background: rgba(10, 14, 22, 0.72);
}
.mind-card--wide { grid-column: 1 / -1; }
.mind-card h4 {
  margin: 0 0 0.65rem;
  font-size: 0.92rem;
}
.mind-card h5 {
  margin: 0 0 0.45rem;
  font-size: 0.8rem;
  color: #7dd3fc;
  display: flex;
  gap: 0.4rem;
  align-items: baseline;
}
.mind-card h5 small {
  color: var(--muted, #94a3b8);
  font-weight: 500;
}
.mind-channel-list {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}
.mind-channel {
  text-align: right;
  border: 1px solid rgba(148, 163, 184, 0.2);
  border-radius: 10px;
  padding: 0.55rem 0.7rem;
  background: transparent;
  color: inherit;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}
.mind-channel strong { font-size: 0.88rem; }
.mind-channel span { font-size: 0.75rem; color: var(--muted, #94a3b8); }
.mind-channel:hover { border-color: rgba(56, 189, 248, 0.45); }
.mind-channel.active {
  border-color: rgba(52, 211, 153, 0.55);
  background: rgba(6, 78, 59, 0.25);
}
.mind-loop-track {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
}
.mind-loop-step {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  border-radius: 999px;
  padding: 0.3rem 0.65rem;
  background: rgba(30, 41, 59, 0.9);
  font-size: 0.78rem;
}
.mind-loop-num {
  width: 1.15rem;
  height: 1.15rem;
  border-radius: 50%;
  display: inline-grid;
  place-items: center;
  background: rgba(56, 189, 248, 0.25);
  font-size: 0.68rem;
}
.mind-loop-arrow { color: var(--muted, #94a3b8); }
.mind-loop-meta {
  margin: 0.75rem 0 0;
  font-size: 0.8rem;
  color: var(--muted, #94a3b8);
}
.mind-caps-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.55rem;
  flex-wrap: wrap;
}
.mind-hint { font-size: 0.75rem; color: var(--muted, #94a3b8); }
.mind-zone-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(16rem, 1fr));
  gap: 0.75rem;
}
.mind-cap-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  max-height: 18rem;
  overflow: auto;
}
.mind-cap {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 0.25rem 0.4rem;
  padding: 0.4rem 0.5rem;
  border-radius: 8px;
  border: 1px solid rgba(148, 163, 184, 0.12);
  background: rgba(15, 23, 42, 0.55);
  font-size: 0.72rem;
}
.mind-cap code {
  grid-column: 1 / -1;
  font-size: 0.68rem;
  color: #bae6fd;
  word-break: break-all;
}
.mind-cap-meta {
  grid-column: 1;
  color: #cbd5e1;
}
.mind-pill {
  border-radius: 999px;
  padding: 0.1rem 0.45rem;
  background: rgba(51, 65, 85, 0.8);
  font-size: 0.65rem;
}
.mind-pill--risk { background: rgba(56, 189, 248, 0.18); color: #7dd3fc; }
.mind-cap--ok { border-color: rgba(52, 211, 153, 0.35); }
.mind-cap--bad { border-color: rgba(248, 113, 113, 0.4); }
.mind-cap--muted { opacity: 0.7; }
.mind-cap--warn { border-color: rgba(251, 191, 36, 0.35); }
.mind-cap-more { font-size: 0.75rem; color: var(--muted, #94a3b8); padding: 0.25rem; }
.mind-prop-table-wrap { overflow: auto; }
.mind-prop-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8rem;
}
.mind-prop-table th,
.mind-prop-table td {
  text-align: right;
  padding: 0.45rem 0.5rem;
  border-bottom: 1px solid rgba(148, 163, 184, 0.12);
}
.mind-prop-actions { white-space: nowrap; }
.mind-empty { color: var(--muted, #94a3b8); text-align: center !important; }
.mind-foot {
  margin: 0;
  font-size: 0.78rem;
  color: var(--muted, #94a3b8);
}
.btn.small {
  font-size: 0.72rem;
  padding: 0.2rem 0.45rem;
}
.mind-head-actions { display: flex; gap: 0.6rem; align-items: center; flex-wrap: wrap; }
.mind-auto { font-size: 0.78rem; color: var(--muted, #94a3b8); display: inline-flex; gap: 0.35rem; align-items: center; cursor: pointer; }
.mind-cap--cortex, .mind-cap--ok.mind-cap--cortex { border-color: rgba(167, 139, 250, 0.35); }

.mind-explore-form {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: flex-end;
  margin: 0.75rem 0;
}
.mind-explore-field {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-size: 0.78rem;
  color: var(--muted, #94a3b8);
  min-width: 12rem;
}
.mind-explore-field select,
.mind-explore-field input[type="text"] {
  background: var(--surface2, #151b24);
  border: 1px solid var(--border, rgba(148, 163, 184, 0.2));
  color: var(--text, #f1f5f9);
  border-radius: 8px;
  padding: 0.45rem 0.6rem;
  font: inherit;
}
.mind-explore-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}
.mind-explore-preview {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  margin: 0.5rem 0 0.75rem;
  color: var(--muted, #94a3b8);
  font-size: 0.78rem;
}
.mind-explore-orb {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  border: 1px solid #fff;
  background: radial-gradient(circle at 35% 30%, rgba(56, 189, 248, 0.28), rgba(15, 23, 42, 0.72) 62%);
  flex-shrink: 0;
}
.mind-explore-active {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.35rem;
  font-size: 0.8rem;
}
.mind-explore-active code { color: #7dd3fc; }
.mind-explore-msg {
  margin: 0.5rem 0 0;
  font-size: 0.78rem;
  color: var(--muted, #94a3b8);
}
.mind-exp-metrics { font-size: 0.75rem; white-space: nowrap; }
