/* Metrics, Integrations and Ask Chief. Classes prefixed .mx- and .chief-. */

/* ---------- shared ---------- */
.mx-ico { width: 28px; height: 28px; flex: none; border-radius: 6px; display: inline-grid; place-items: center; color: #fff; font-size: 13px; }
.mx-ico svg { width: 16px; height: 16px; }
.mx-ico.sm { width: 22px; height: 22px; border-radius: 5px; }
.mx-ico.sm svg { width: 13px; height: 13px; }
.mx-ico.lg { width: 40px; height: 40px; border-radius: 8px; }
.mx-ico.lg svg { width: 22px; height: 22px; }
.mx-spin { display: inline-block; width: 12px; height: 12px; border: 2px solid rgba(255, 255, 255, .45); border-top-color: #fff; border-radius: 50%; animation: spin .8s linear infinite; }
.mx-spin.dark { border-color: rgba(43, 109, 233, .25); border-top-color: var(--primary); }
.mx-sec { margin-top: 16px; }
.mx-val { font-variant-numeric: tabular-nums; }
.mx-check-ic { width: 20px; height: 20px; flex: none; border-radius: 50%; display: grid; place-items: center; color: #fff; background: var(--success); font-size: 11px; font-weight: 700; }
.mx-check-ic.big { width: 30px; height: 30px; font-size: 16px; }

/* ---------- library ---------- */
.mx-recipes { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.mx-recipe { display: flex; flex-direction: column; gap: 8px; padding: 12px 14px; border-radius: var(--radius-lg); background: var(--fill-2); border: 1px solid #f0f0f0; }
.mx-recipe-blurb { flex: 1; }
.mx-recipe .btn { align-self: flex-start; }
.mx-bigval { text-align: right; margin-right: 8px; line-height: 1.2; }
.mx-bigval b { font-size: 22px; font-weight: 600; font-variant-numeric: tabular-nums; }

/* ---------- assistant ---------- */
.mx-assist { border: 1px solid #9d7bf0; border-radius: var(--radius-lg); padding: 14px 16px; margin-bottom: 18px; background: linear-gradient(180deg, #faf7ff 0%, #fff 100%); }
.mx-assist.compact { margin-bottom: 12px; }
.mx-assist-head { display: flex; align-items: center; gap: 8px; color: #5b2bd1; margin-bottom: 6px; }
.mx-assist-head b { font-weight: 600; }
.mx-spark { color: #7c4dff; }
.mx-builds { font-size: 12px; color: #6a3fd8; font-weight: 500; }
.mx-assist-sub { font-size: 12px; color: var(--text-2); margin-bottom: 10px; }
.mx-assist-row { display: flex; margin: 8px 0; }
.mx-assist-row .input { border-radius: var(--radius) 0 0 var(--radius); height: 34px; }
.mx-build-btn { border-radius: 0 var(--radius) var(--radius) 0; height: 34px; min-width: 92px; }
.mx-build-btn:disabled { background: linear-gradient(135deg, #a79ff7, #d9a3e4); color: #fff; }
.mx-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.mx-chip { border: 1px solid #7c4dff; color: #4a1fb8; background: #fff; border-radius: 4px; font-size: 12px; padding: 1px 7px; cursor: pointer; }
.mx-chip:hover:not(:disabled) { background: #f4efff; }
.mx-chip:disabled { opacity: .5; cursor: not-allowed; }
.mx-line { display: flex; gap: 10px; align-items: baseline; padding: 4px 0; font-size: 13px; }
.mx-who { flex: none; font-size: 12px; padding: 0 6px; border-radius: 4px; background: var(--fill); color: var(--text-2); }
.mx-who.assistant { background: #f4efff; color: #5b2bd1; }
.mx-shimmer { padding: 6px 14px 4px; }
.mx-shimmer-t { color: #5b2bd1; font-weight: 500; font-size: 13px; margin-bottom: 8px; }
.mx-shimmer i { display: block; height: 6px; border-radius: 3px; margin: 6px 0; background: linear-gradient(90deg, #f1ecff 0%, #e2d8ff 40%, #f1ecff 80%); background-size: 200% 100%; animation: mx-sh 1.3s linear infinite; }
@keyframes mx-sh { from { background-position: 200% 0; } to { background-position: -200% 0; } }
.mx-card { margin-top: 12px; border: 1px solid #91caff; background: #eef6ff; border-radius: var(--radius-lg); padding: 12px 16px; }
.mx-card.warn { border-color: #ffd591; background: var(--warning-soft); }
.mx-card-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 6px; }
.mx-card-head b { font-size: 15px; font-weight: 500; }
.mx-card-head .x { margin-left: auto; }
.mx-card-body { padding-left: 30px; display: flex; flex-direction: column; gap: 6px; }
.mx-info-dot { flex: none; width: 22px; height: 22px; border-radius: 50%; background: var(--primary); color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 12px; font-family: Georgia, serif; }
.mx-req { display: flex; gap: 6px; flex-wrap: wrap; }
.mx-runs-k { font-size: 11px; color: var(--text-3); margin-top: 2px; }
.mx-runs { font: 12px var(--mono); color: var(--text); word-break: break-all; white-space: pre-wrap; }
.mx-check { display: flex; align-items: flex-start; gap: 10px; margin-top: 8px; padding: 9px 12px; border-radius: var(--radius); background: var(--success-soft); border: 1px solid #b7eb8f; }
.mx-check > div { flex: 1; min-width: 0; }
.mx-check-t { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 2px; }
.mx-assist.compact .mx-card-head { flex-wrap: nowrap; }
.mx-assist.compact .mx-card-head b { white-space: nowrap; }
.mx-assist.compact .mx-card-body { padding-left: 0; }
.mx-check.close { background: var(--warning-soft); border-color: #ffd591; }
.mx-check.close .mx-check-ic { background: var(--warning); }

/* ---------- builder ---------- */
.mx-form { display: grid; grid-template-columns: 2fr 1fr 1fr 2fr; gap: 0 12px; }
.mx-form .field { margin-bottom: 8px; }
.mx-form .field > label { font-size: 12px; color: var(--text-2); }
.mx-measured { display: flex; align-items: center; gap: 10px; }
.mx-steps { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.mx-canvas-grid { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 12px; align-items: start; }
.mx-canvas { position: relative; height: 340px; overflow: auto; border: 1px solid var(--border); border-radius: var(--radius-lg); background-color: #f5f6f8; background-image: radial-gradient(#dfe3ea 1px, transparent 1px); background-size: 16px 16px; }
.mx-canvas-inner { position: relative; min-width: 100%; min-height: 100%; }
.mx-wires { position: absolute; left: 0; top: 0; pointer-events: none; }
.mx-wire { fill: none; stroke: #2b6de9; stroke-width: 1.6; }
.mx-wire-hit { fill: none; stroke: transparent; stroke-width: 12; pointer-events: stroke; cursor: pointer; }
.mx-wire-hit:hover + .mx-wire, .mx-wire-hit:hover { stroke: rgba(255, 77, 79, .35); }
.mx-node { position: absolute; width: 176px; height: 70px; padding: 8px 10px; background: #fff; border: 1px solid var(--border-2); border-radius: 4px; box-shadow: var(--shadow-sm); user-select: none; cursor: pointer; touch-action: none; }
.mx-node.drag { cursor: grab; }
.mx-node.drag:active { cursor: grabbing; }
.mx-node.sel { border: 2px solid var(--primary); padding: 7px 9px; box-shadow: 0 0 0 3px rgba(43, 109, 233, .12); }
.mx-node-type { font-size: 10px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; }
.mx-node-name { font-size: 13px; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mx-node-detail { font-size: 11px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mx-node.t-http .mx-node-type { color: #1677ff; }
.mx-node.t-http.sel { border-color: #1677ff; }
.mx-node.t-transform .mx-node-type { color: #389e0d; }
.mx-node.t-output .mx-node-type { color: #8c8c8c; }
.mx-node.t-tool .mx-node-type { color: #722ed1; }
.mx-node.t-sql .mx-node-type { color: #531dab; }
.mx-node.t-status_map .mx-node-type { color: #d46b08; }
.mx-dot { position: absolute; top: 29px; width: 11px; height: 11px; border-radius: 50%; background: #fff; border: 2px solid #2b6de9; cursor: crosshair; }
.mx-dot.in { left: -6px; border-color: #bfbfbf; }
.mx-dot.out { right: -6px; }
.mx-dot.on, .mx-dot:hover { background: #2b6de9; }
.mx-inspector { min-height: 200px; }
.mx-inspector .card-head { min-height: 40px; padding: 0 14px; }
.mx-inspector .card-head h3 { font-size: 14px; }
.mx-inspector .card-body { padding: 12px 14px; }
.mx-inspector .field { margin-bottom: 12px; }
.mx-inspector .empty { padding: 28px 12px; }
.mx-inspector textarea.mono { font-family: var(--mono); font-size: 12px; }
.mx-hint { font-size: 12px; color: var(--text-2); margin-bottom: 12px; }
.mx-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 16px; }
.mx-actions .small { flex: 1; min-width: 220px; }
.mx-preview .card-head { min-height: 42px; }
.mx-success { display: flex; gap: 14px; align-items: flex-start; padding: 16px 20px; background: var(--success-soft); border: 1px solid #b7eb8f; border-radius: var(--radius-lg); }
.mx-success-v { font-size: 16px; margin-bottom: 4px; }
.mx-step-out { border: 1px solid #f0f0f0; border-radius: var(--radius); padding: 10px 12px; margin-bottom: 8px; background: #fff; }
.mx-step-out .seg { margin: 6px 0; }
.mx-fields { display: flex; flex-direction: column; }
.mx-field { display: flex; gap: 10px; align-items: center; padding: 3px 6px; border-radius: 4px; font-size: 12px; }
.mx-field.click { cursor: pointer; }
.mx-field.click:hover { background: var(--primary-soft); }
.mx-field.click .mx-fk { color: var(--primary); }
.mx-fk { font-family: var(--mono); min-width: 190px; color: var(--text-2); }
.mx-ft { font-size: 10px; padding: 0 5px; border-radius: 3px; background: var(--fill); color: var(--text-2); }
.mx-ft.number { background: var(--success-soft); color: var(--success-text); }
.mx-ft.list { background: #e6f4ff; color: #0958d9; }
.mx-fv { font-family: var(--mono); color: var(--text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mx-raw { margin: 6px 0 0; padding: 10px; background: var(--fill-2); border-radius: var(--radius); font: 12px var(--mono); max-height: 240px; overflow: auto; }
.mx-plus { display: inline-grid; place-items: center; width: 16px; height: 16px; border: 1px solid var(--border-2); border-radius: 3px; font-size: 12px; line-height: 1; color: var(--text-2); }
.mx-run-step { padding: 4px 0 6px 28px; }
.mx-run-step .mono { color: var(--text-2); margin-top: 2px; word-break: break-all; }

/* ---------- pickers ---------- */
.mx-pick-list { max-height: 380px; overflow-y: auto; border: 1px solid var(--border); border-radius: var(--radius-lg); }
.mx-pick-row { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-bottom: 1px solid #f0f0f0; cursor: pointer; }
.mx-pick-row:last-child { border-bottom: 0; }
.mx-pick-row:hover { background: var(--fill-2); }
.mx-pick-row.on { background: var(--primary-soft); }
.mx-pick-row.new b { color: #5b2bd1; }
.mx-pick-save { margin-top: 4px; padding: 12px; border: 1px solid var(--border); border-radius: var(--radius-lg); }

/* ---------- integrations ---------- */
.mx-ints { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 16px; }
.mx-int { display: flex; flex-direction: column; }
.mx-int-head { display: flex; gap: 12px; align-items: center; padding: 16px 18px 10px; }
.mx-int-body { padding: 0 18px 8px; display: flex; flex-direction: column; gap: 8px; }
.mx-int-list { display: flex; flex-direction: column; gap: 4px; }
.mx-int-foot { margin-top: auto; display: flex; gap: 8px; justify-content: flex-end; padding: 10px 18px; border-top: 1px solid #f0f0f0; }
.mx-tools { border: 1px solid #f0f0f0; border-radius: var(--radius); }
.mx-tool-row { display: grid; grid-template-columns: 1fr auto auto auto auto; gap: 8px; align-items: center; padding: 6px 10px; border-bottom: 1px solid #f5f5f5; }
.mx-tool-row:last-child { border-bottom: 0; }
.mx-oauth { display: flex; flex-direction: column; align-items: center; gap: 8px; text-align: center; padding: 18px 8px 8px; }
.mx-oauth-logos { display: flex; align-items: center; gap: 14px; margin-bottom: 8px; }
.mx-oauth-logos .logo { width: 40px; height: 40px; }
.mx-oauth-dots { display: flex; gap: 4px; color: var(--text-3); }
.mx-oauth-dots i { width: 6px; height: 6px; border-radius: 50%; background: var(--primary); animation: chief-b 1s infinite; }
.mx-oauth-dots i:nth-child(2) { animation-delay: .15s; }
.mx-oauth-dots i:nth-child(3) { animation-delay: .3s; }

/* ---------- Ask Chief ---------- */
.page.chief-page { max-width: none; padding: 16px 20px 16px; }
.chief-layout { display: grid; grid-template-columns: 250px minmax(0, 1fr); height: calc(100vh - 56px - 32px); }
.chief-rail { display: flex; flex-direction: column; gap: 10px; padding-right: 16px; border-right: 1px solid var(--border); min-height: 0; }
.chief-rail .btn { height: 34px; }
.chief-list { display: flex; flex-direction: column; gap: 2px; overflow-y: auto; }
.chief-item { display: block; padding: 8px 12px; border-radius: var(--radius); color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 14px; }
.chief-item:hover { background: var(--fill); color: var(--text); }
.chief-item.on { background: var(--primary-soft); color: var(--primary); }
.chief-main { display: flex; flex-direction: column; min-height: 0; min-width: 0; }
.chief-thread { flex: 1; overflow-y: auto; padding: 8px 20px; }
.chief-col { max-width: 820px; margin: 0 auto; display: flex; flex-direction: column; gap: 14px; padding: 16px 0; }
.chief-msg.user { display: flex; justify-content: flex-end; }
.chief-bubble { max-width: 80%; background: var(--primary-soft); padding: 8px 14px; border-radius: 10px; white-space: pre-wrap; }
.chief-msg.assistant { line-height: 1.65; }
.chief-md p { margin: 0 0 10px; }
.chief-md p:last-child { margin-bottom: 0; }
.chief-md ul { margin: 0 0 10px; padding-left: 22px; list-style: none; }
.chief-md li { margin-bottom: 6px; position: relative; }
.chief-link { color: var(--primary); }
.chief-proposal { margin-top: 12px; padding: 14px 16px; border-left: 3px solid #d63384; background: var(--fill); border-radius: 0 var(--radius) var(--radius) 0; }
.chief-proposal .strong { margin-bottom: 4px; }
.chief-proposal.approved { border-left-color: var(--success); }
.chief-proposal.declined, .chief-proposal.withdrawn { border-left-color: var(--text-4); opacity: .85; }
.chief-working { display: inline-flex; align-items: center; gap: 10px; color: var(--text-3); }
.chief-dots { display: inline-flex; gap: 4px; }
.chief-dots i { width: 6px; height: 6px; border-radius: 50%; background: #9d7bf0; animation: chief-b 1s infinite; }
.chief-dots i:nth-child(2) { animation-delay: .15s; }
.chief-dots i:nth-child(3) { animation-delay: .3s; }
@keyframes chief-b { 0%, 80%, 100% { opacity: .3; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-3px); } }
.chief-empty { max-width: 640px; margin: 12vh auto 0; display: flex; flex-direction: column; align-items: center; gap: 10px; text-align: center; }
.chief-empty h2 { font-size: 24px; }
.chief-orb { width: 56px; height: 56px; border-radius: 50%; display: grid; place-items: center; color: #fff; background: linear-gradient(135deg, #6a5cff, #c03fd4); }
.chief-sugg { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-top: 8px; }
.chief-chip { border: 1px solid var(--border-2); background: #fff; border-radius: 999px; padding: 6px 14px; cursor: pointer; color: var(--text); font-size: 13px; }
.chief-chip:hover { border-color: var(--primary); color: var(--primary); }
.chief-composer { border-top: 1px solid var(--border); padding: 12px 20px 0; }
.chief-composer > * { max-width: 820px; margin-left: auto; margin-right: auto; }
.chief-input { display: flex; align-items: flex-end; gap: 8px; border: 1px solid var(--border-2); border-radius: var(--radius-lg); padding: 8px 10px; background: #fff; }
.chief-input:focus-within { border-color: var(--primary); box-shadow: 0 0 0 2px rgba(5, 145, 255, .1); }
.chief-input textarea { flex: 1; border: 0; outline: 0; resize: none; min-height: 28px; max-height: 160px; padding: 4px 6px; box-shadow: none; background: transparent; }
.chief-input textarea:focus { box-shadow: none; }
.chief-plus, .chief-send { width: 30px; height: 30px; flex: none; border: 0; border-radius: var(--radius); background: transparent; cursor: pointer; display: grid; place-items: center; color: var(--text-2); }
.chief-plus:hover { background: var(--fill); }
.chief-send { border: 1px solid var(--border-2); background: var(--fill-2); color: var(--primary); }
.chief-send:disabled { color: var(--text-4); cursor: not-allowed; }
.chief-plus svg, .chief-send svg { width: 16px; height: 16px; }
.chief-foot { text-align: center; font-size: 12px; color: var(--text-3); padding: 8px 0 2px; }

@media (max-width: 900px) {
  .mx-form { grid-template-columns: 1fr 1fr; }
  .mx-canvas-grid { grid-template-columns: 1fr; }
  .mx-recipes { grid-template-columns: 1fr; }
  .chief-layout { grid-template-columns: 1fr; height: auto; }
  .chief-rail { border-right: 0; padding-right: 0; }
  .chief-thread { min-height: 50vh; }
}
