:root {
  --bg: #f5f7fb;
  --surface: #ffffff;
  --fg: #0f172a;
  --muted: #64748b;
  --faint: #94a3b8;
  --border: #e6e9f0;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-soft: #eff4ff;
  --green: #10b981;
  --green-dark: #047857;
  --green-soft: #ecfdf5;
  --amber: #f59e0b;
  --amber-soft: #fef6e0;
  --rose: #e11d48;
  --rose-soft: #fff1f3;
  --violet: #7c3aed;
  --violet-soft: #f3eeff;
  --cyan: #0891b2;
  --cyan-soft: #e9f8fb;
  --navy: #0b1220;
  --navy-2: #131c2e;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .05), 0 6px 20px rgba(15, 23, 42, .05);
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--fg); font: 14px/1.5 Inter, ui-sans-serif, system-ui, sans-serif; }
a { color: inherit; text-decoration: none; }
h1, h2, h3, h4, p { margin: 0; }
button { font: inherit; cursor: pointer; }
svg { width: 18px; height: 18px; flex: none; }
input, textarea, select { font: inherit; color: inherit; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
[hidden] { display: none !important; }

/* Shell */
.shell { display: flex; min-height: 100vh; }
.sidebar {
  width: 240px; flex: none; background: var(--navy); color: #cbd5e1;
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; padding: 18px 12px;
}
.brand { display: flex; align-items: center; gap: 10px; color: #fff; font-size: 15px; padding: 4px 8px 18px; }
.brand b { font-weight: 750; }
.brand-mark { width: 32px; height: 32px; border-radius: 9px; background: linear-gradient(135deg, #2563eb, #10b981); display: grid; place-items: center; color: #fff; }
.side-nav { display: flex; flex-direction: column; gap: 2px; }
.side-nav a { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 8px; font-weight: 550; color: #b8c2d3; }
.side-nav a:hover { background: rgba(255,255,255,.06); color: #fff; }
.side-nav a.active { background: rgba(37,99,235,.25); color: #fff; }
.side-nav a.active svg { color: #93c5fd; }
.nav-badge { margin-left: auto; background: var(--amber); color: var(--navy); border-radius: 999px; font-size: 11px; font-weight: 700; padding: 1px 7px; }
.side-foot { margin-top: auto; display: flex; flex-direction: column; gap: 10px; font-size: 12px; color: #7d8aa3; padding: 0 8px; }
.side-foot a:hover { color: #fff; }
.engine-pill { display: flex; align-items: center; gap: 8px; background: var(--navy-2); border: 1px solid rgba(255,255,255,.08); border-radius: 10px; padding: 8px 10px; color: #e2e8f0; font-weight: 600; }
.engine-pill .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--amber); box-shadow: 0 0 0 3px rgba(245,158,11,.2); }
.engine-pill .dot.on { background: var(--green); box-shadow: 0 0 0 3px rgba(16,185,129,.2); }
.side-link { color: #b8c2d3; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 12px; padding: 12px 28px; background: rgba(245,247,251,.9); backdrop-filter: blur(8px); border-bottom: 1px solid var(--border); }
.crumbs { font-weight: 650; display: flex; gap: 8px; align-items: center; min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.crumbs a { color: var(--muted); font-weight: 550; }
.crumbs a:hover { color: var(--fg); }
.top-actions { margin-left: auto; display: flex; gap: 8px; }
.view { padding: 28px; max-width: 1280px; width: 100%; outline: none; }
.icon-btn { background: none; border: 0; padding: 6px; border-radius: 8px; color: inherit; display: inline-grid; place-items: center; }
.icon-btn:hover { background: rgba(15,23,42,.06); }
.menu { display: none; }

@media (max-width: 900px) {
  .sidebar { position: fixed; left: 0; top: 0; z-index: 40; transform: translateX(-100%); transition: transform .2s; box-shadow: 0 0 40px rgba(0,0,0,.3); }
  .sidebar.open { transform: none; }
  .menu { display: inline-grid; }
  .topbar { padding: 10px 16px; }
  .view { padding: 18px 16px; }
  .hide-sm { display: none; }
}

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 0; border-radius: 9px; padding: 9px 14px; font-weight: 600; font-size: 14px; white-space: nowrap; }
.btn svg { width: 16px; height: 16px; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-primary:disabled { opacity: .5; cursor: not-allowed; }
.btn-green { background: var(--green); color: #fff; }
.btn-green:hover { background: var(--green-dark); }
.btn-danger { background: var(--rose-soft); color: var(--rose); }
.btn-outline { background: var(--surface); box-shadow: inset 0 0 0 1px var(--border); color: var(--fg); }
.btn-outline:hover { box-shadow: inset 0 0 0 1px #cbd2df; }
.btn-ghost { background: transparent; color: var(--muted); }
.btn-ghost:hover { color: var(--fg); background: rgba(15,23,42,.05); }
.btn-sm { padding: 6px 10px; font-size: 13px; }

/* Generic */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.card-head h3 { font-size: 15px; }
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 22px; }
.page-head h1 { font-size: 26px; letter-spacing: -.02em; }
.page-head p { color: var(--muted); margin-top: 4px; max-width: 680px; }
.grid { display: grid; gap: 16px; }
.cols-2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.cols-3 { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.split { display: grid; gap: 18px; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 1100px) { .split { grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); } .split.wide-left { grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); } }
.pill { display: inline-flex; align-items: center; gap: 5px; border-radius: 999px; padding: 2px 9px; font-size: 12px; font-weight: 650; white-space: nowrap; }
.pill svg { width: 12px; height: 12px; }
.st-running { background: var(--primary-soft); color: var(--primary); }
.st-awaiting { background: var(--amber-soft); color: #92400e; }
.st-completed { background: var(--green-soft); color: var(--green-dark); }
.st-rejected, .st-failed { background: var(--rose-soft); color: var(--rose); }
.tag { display: inline-block; font-size: 11px; font-weight: 650; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); }
.empty { text-align: center; padding: 40px 16px; color: var(--muted); }
.empty .btn { margin-top: 14px; }
.kv { display: grid; grid-template-columns: minmax(110px, 38%) 1fr; gap: 0; font-size: 13px; }
.kv > div { padding: 7px 0; border-bottom: 1px solid var(--border); overflow-wrap: anywhere; }
.kv > div:nth-child(odd) { color: var(--muted); padding-right: 12px; }
.kv > div:nth-child(even) { font-weight: 550; }
.kv > div:nth-last-child(-n+2) { border-bottom: 0; }

/* Colored agent icon chips */
.ico { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; flex: none; background: var(--primary-soft); color: var(--primary); }
.ico svg { width: 18px; height: 18px; }
.ico.sm { width: 26px; height: 26px; border-radius: 7px; }
.ico.sm svg { width: 14px; height: 14px; }
.ico.lg { width: 44px; height: 44px; border-radius: 12px; }
.c-blue { background: var(--primary-soft); color: var(--primary); }
.c-violet { background: var(--violet-soft); color: var(--violet); }
.c-cyan { background: var(--cyan-soft); color: var(--cyan); }
.c-amber { background: var(--amber-soft); color: #b45309; }
.c-green { background: var(--green-soft); color: var(--green-dark); }
.c-rose { background: var(--rose-soft); color: var(--rose); }
.c-slate { background: #f1f4f8; color: #475569; }

/* Dashboard */
.hero-card { background: radial-gradient(800px 260px at 85% -20%, rgba(16,185,129,.35), transparent 60%), radial-gradient(700px 300px at 0% 120%, rgba(37,99,235,.55), transparent 60%), var(--navy); color: #fff; border-radius: 16px; padding: 26px; display: grid; gap: 18px; margin-bottom: 18px; }
@media (min-width: 900px) { .hero-card { grid-template-columns: 1.2fr 1fr; align-items: center; } }
.hero-card h1 { font-size: 26px; letter-spacing: -.02em; }
.hero-card p { color: #b8c2d3; margin-top: 6px; }
.hero-card .actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.hero-card .btn-outline { background: rgba(255,255,255,.08); color: #fff; box-shadow: inset 0 0 0 1px rgba(255,255,255,.2); }
.orbit { position: relative; height: 190px; }
.orbit svg.lines { position: absolute; inset: 0; width: 100%; height: 100%; }
.orbit .node { position: absolute; transform: translate(-50%, -50%); display: flex; align-items: center; gap: 6px; background: rgba(255,255,255,.08); border: 1px solid rgba(255,255,255,.16); border-radius: 999px; padding: 5px 10px 5px 6px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.orbit .node .ico { width: 22px; height: 22px; border-radius: 6px; }
.orbit .node .ico svg { width: 12px; height: 12px; }
.orbit .core { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); width: 86px; height: 86px; border-radius: 50%; background: radial-gradient(circle at 30% 30%, #3b82f6, #1d4ed8); display: grid; place-items: center; text-align: center; font-size: 11px; font-weight: 700; box-shadow: 0 0 0 8px rgba(59,130,246,.15), 0 0 40px rgba(59,130,246,.5); }
.orbit .core svg { width: 22px; height: 22px; display: block; margin: 0 auto 2px; }
.kpis { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); margin-bottom: 18px; }
.kpi .label { color: var(--muted); font-size: 13px; display: flex; align-items: center; gap: 6px; }
.kpi .label svg { width: 14px; height: 14px; }
.kpi .value { font-size: 26px; font-weight: 750; letter-spacing: -.02em; margin-top: 4px; }
.kpi .sub { font-size: 12px; color: var(--muted); }
.bars { display: grid; gap: 10px; }
.bar-row { display: grid; grid-template-columns: 150px 1fr 40px; gap: 10px; align-items: center; font-size: 13px; }
.bar-row .track { height: 8px; background: #eef1f6; border-radius: 999px; overflow: hidden; }
.bar-row .fill { height: 100%; border-radius: 999px; background: var(--primary); }
.bar-row span:last-child { text-align: right; font-weight: 650; }

/* Tables */
.table-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 600; padding: 8px 10px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.tbl td { padding: 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl tbody tr { cursor: pointer; }
.tbl tbody tr:hover { background: #f8fafc; }
.wf-cell { display: flex; align-items: center; gap: 10px; min-width: 200px; }
.wf-cell b { display: block; }

/* Workflow cards */
.wf-card { display: flex; flex-direction: column; gap: 12px; }
.wf-card .top { display: flex; gap: 12px; align-items: flex-start; }
.wf-card h3 { font-size: 16px; }
.wf-card p { color: var(--muted); font-size: 13px; }
.chain { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; }
.chain .ico { width: 24px; height: 24px; border-radius: 7px; }
.chain .ico svg { width: 13px; height: 13px; }
.chain .arrow { color: var(--faint); font-size: 11px; }
.wf-card .foot { margin-top: auto; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.wf-card .meta { font-size: 12px; color: var(--muted); flex-basis: 100%; }
.wf-card .foot .btn:first-of-type { margin-left: auto; }
.custom-cta { border: 2px dashed #cdd5e3; background: transparent; box-shadow: none; justify-content: center; text-align: center; align-items: center; }

/* Run setup */
.samples { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0 12px; }
.chip { border: 1px solid var(--border); background: var(--surface); border-radius: 999px; padding: 6px 12px; font-size: 13px; font-weight: 550; }
.chip:hover { border-color: #c7d2e5; }
.chip.active { background: var(--primary); border-color: var(--primary); color: #fff; }
textarea.input, input.input, select.input { width: 100%; border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; background: var(--surface); }
textarea.input { min-height: 260px; resize: vertical; font: 13px/1.55 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
textarea.doc { font: 14px/1.6 Inter, sans-serif; min-height: 360px; }
.input:focus { outline: 2px solid rgba(37,99,235,.35); border-color: var(--primary); }
.dropline { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-top: 10px; font-size: 13px; color: var(--muted); }
.drop-target.over { outline: 2px dashed var(--primary); outline-offset: 4px; border-radius: 12px; }
label.field { display: block; font-size: 13px; font-weight: 600; margin-bottom: 12px; }
label.field > span { display: block; margin-bottom: 6px; }
label.field .hint { font-weight: 400; color: var(--muted); font-size: 12px; margin-top: 4px; display: block; }

/* Pipeline (run view) */
.pipeline { position: relative; display: grid; gap: 10px; }
.p-step { position: relative; display: grid; grid-template-columns: 40px 1fr auto; gap: 12px; align-items: start; padding: 12px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); transition: border-color .2s, box-shadow .2s, background .2s; }
.p-step:not(:last-child)::after { content: ""; position: absolute; left: 31px; bottom: -11px; width: 2px; height: 10px; background: var(--border); }
.p-step .ico { width: 40px; height: 40px; }
.p-step b { display: block; font-size: 14px; }
.p-step .role { color: var(--muted); font-size: 12px; }
.p-step .log { margin-top: 6px; font-size: 13px; overflow-wrap: anywhere; }
.p-step .state { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--faint); white-space: nowrap; display: flex; flex-direction: column; align-items: flex-end; gap: 2px; }
.p-step .state em { font-style: normal; font-weight: 500; text-transform: none; letter-spacing: 0; color: var(--faint); }
.p-step.queued { opacity: .6; }
.p-step.running { border-color: rgba(37,99,235,.5); box-shadow: 0 0 0 4px rgba(37,99,235,.08); }
.p-step.running .ico { animation: pulse 1.1s infinite; }
.p-step.running .state { color: var(--primary); }
.p-step.done .state { color: var(--green-dark); }
.p-step.warn .state { color: #b45309; }
.p-step.skipped .state { color: var(--faint); }
.p-step.waiting { border-color: var(--amber); background: #fffbf1; box-shadow: 0 0 0 4px rgba(245,158,11,.1); }
.p-step.waiting .state { color: #b45309; }
.p-step.error { border-color: #fecdd3; background: #fff8f9; }
.p-step.error .state { color: var(--rose); }
@keyframes pulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(37,99,235,.35); } 50% { box-shadow: 0 0 0 7px rgba(37,99,235,0); } }
.typing::after { content: "▍"; animation: blink 1s steps(2) infinite; margin-left: 2px; color: var(--primary); }
@keyframes blink { 50% { opacity: 0; } }
.orchestrator-bar { display: flex; align-items: center; gap: 12px; background: var(--navy); color: #fff; border-radius: 12px; padding: 12px 14px; margin-bottom: 10px; }
.orchestrator-bar .ico { background: var(--primary); color: #fff; }
.orchestrator-bar p { color: #94a3b8; font-size: 12px; }
.orchestrator-bar .prog { margin-left: auto; text-align: right; font-size: 12px; color: #cbd5e1; }
.progress { height: 6px; width: 120px; background: rgba(255,255,255,.12); border-radius: 999px; overflow: hidden; margin-top: 4px; }
.progress span { display: block; height: 100%; background: linear-gradient(90deg, #3b82f6, #10b981); transition: width .3s; }

.approval-box { border: 2px solid var(--amber); background: #fffcf3; }
.approval-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.approval-actions input { flex: 1; min-width: 180px; }
pre.doc { margin: 0; white-space: pre-wrap; font: 14px/1.6 Inter, sans-serif; background: #fbfcfe; border: 1px solid var(--border); border-radius: 10px; padding: 16px; max-height: 560px; overflow: auto; }
.audit { list-style: none; padding: 0; margin: 0; font-size: 13px; }
.audit li { display: flex; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--border); }
.audit li:last-child { border-bottom: 0; }
.audit time { color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
details.input-peek summary { cursor: pointer; font-weight: 600; }
details.input-peek pre { white-space: pre-wrap; font: 12px/1.5 ui-monospace, Menlo, Consolas, monospace; background: #f8fafc; border-radius: 8px; padding: 12px; max-height: 260px; overflow: auto; margin: 10px 0 0; }

/* Filters */
.filters { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.filters .input { width: auto; min-width: 160px; padding: 8px 10px; }
.seg { display: inline-flex; background: #eef1f6; border-radius: 9px; padding: 3px; }
.seg button { border: 0; background: transparent; padding: 6px 12px; border-radius: 7px; font-weight: 600; font-size: 13px; color: var(--muted); }
.seg button.active { background: var(--surface); color: var(--fg); box-shadow: var(--shadow); }

/* Builder */
.builder { display: grid; gap: 18px; }
@media (min-width: 1100px) { .builder { grid-template-columns: minmax(0, 1fr) 300px; align-items: start; } }
.b-step { border: 1px solid var(--border); border-radius: 12px; background: var(--surface); margin-bottom: 10px; }
.b-step-head { display: flex; align-items: center; gap: 10px; padding: 10px 12px; cursor: pointer; }
.b-step-head b { display: block; }
.b-step-head .tools { margin-left: auto; display: flex; gap: 2px; }
.b-step-body { padding: 4px 14px 14px 58px; }
@media (max-width: 640px) { .b-step-body { padding-left: 14px; } }
.b-step-body textarea.input { min-height: 90px; }
.b-num { font-size: 11px; font-weight: 700; color: var(--faint); width: 18px; text-align: center; }
.palette { position: sticky; top: 76px; }
.palette button { display: flex; width: 100%; text-align: left; gap: 10px; align-items: center; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 8px 10px; margin-bottom: 8px; }
.palette button:hover { border-color: var(--primary); }
.palette button b { display: block; font-size: 13px; }
.palette button span.d { font-size: 12px; color: var(--muted); line-height: 1.35; }
.gen-box { background: linear-gradient(135deg, #eef4ff, #ecfdf5); border: 1px solid #d6e3ff; }
.gen-box textarea.input { min-height: 80px; font: 14px/1.5 Inter, sans-serif; }
.gen-examples { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.gen-examples button { border: 1px dashed #b9c7e6; background: rgba(255,255,255,.7); border-radius: 999px; padding: 4px 10px; font-size: 12px; }

/* Agents & integrations */
.int-group { margin-bottom: 22px; }
.int-group h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin-bottom: 10px; }
.int-card { display: flex; align-items: center; gap: 12px; }
.int-card .txt { flex: 1; min-width: 0; }
.int-card .txt b { display: block; }
.int-logo { width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center; font-weight: 800; font-size: 14px; color: #fff; flex: none; }
.switch { position: relative; width: 40px; height: 22px; border-radius: 999px; background: #d4dae5; border: 0; flex: none; transition: background .15s; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform .15s; box-shadow: 0 1px 2px rgba(0,0,0,.2); }
.switch.on { background: var(--green); }
.switch.on::after { transform: translateX(18px); }
.notice { background: var(--primary-soft); border: 1px solid #d6e3ff; border-radius: 10px; padding: 12px 14px; font-size: 13px; margin-bottom: 18px; }
.notice.warn { background: var(--amber-soft); border-color: #fde9b0; }

/* Toast */
.toast { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); background: var(--navy); color: #fff; padding: 10px 16px; border-radius: 10px; font-weight: 600; opacity: 0; pointer-events: none; transition: all .2s; z-index: 60; max-width: calc(100% - 32px); }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
