/* WODI Brain admin. Light theme throughout: lavender workspace, white sidebar and cards.
   No scripts (CSP): every interaction here is plain links, forms and CSS. */
:root {
  --bg: #f3f6fb; --bg-2: #e8eef8; --panel: #ffffff; --panel-2: #f8fafd;
  --text: #15233f; --muted: #5f6b82; --line: #e2e8f2; --line-2: #d3dcea;
  --brand: #1E428A; --brand-soft: #e8eef8; --button: #1E428A; --button-hover: #17346e; --button-soft: #eaf0f9; --blue: #3b82f6; --blue-soft: #e8f0fe;
  --violet: #8b5cf6; --violet-soft: #f1ebfe; --cyan: #06b6d4; --cyan-soft: #e3f8fb;
  --teal: #10b981; --teal-soft: #e2f7ef; --rose: #ef4565; --rose-soft: #fde8ec;
  --ok: #0f9960; --ok-soft: #e1f6ec; --warn: #b26a00; --warn-soft: #fff2db; --bad: #d92d4b; --bad-soft: #fde7eb;
  --shadow: 0 1px 2px rgba(40, 28, 110, .04), 0 10px 30px rgba(76, 58, 170, .07);
  --shadow-hover: 0 2px 4px rgba(40, 28, 110, .06), 0 18px 40px rgba(76, 58, 170, .14);
  --radius: 18px; --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --side-text: #1b2d52; --side-muted: #7f8aa0;
}
* { box-sizing: border-box; }
html { font-size: 14px; }
body {
  margin: 0; color: var(--text); line-height: 1.5;
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", "Noto Sans Arabic", sans-serif;
  background: radial-gradient(1200px 600px at 85% -10%, color-mix(in srgb, var(--brand) 14%, transparent), transparent 60%),
              radial-gradient(900px 500px at 20% 0%, color-mix(in srgb, var(--blue) 10%, transparent), transparent 60%),
              linear-gradient(180deg, var(--bg-2), var(--bg) 420px);
  background-attachment: fixed; background-color: var(--bg);
}
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.6rem; margin: 0 0 4px; letter-spacing: -0.02em; }
h2 { font-size: 1.12rem; margin: 0 0 12px; letter-spacing: -0.01em; }
h3 { font-size: 0.95rem; margin: 0 0 8px; }
.muted { color: var(--muted); }
.small { font-size: 0.8rem; }
.mono { font-family: var(--mono); font-size: 0.85rem; }
.grow { flex: 1; min-width: 0; }
.ic { width: 18px; height: 18px; flex: none; display: inline-block; vertical-align: middle; }

/* ---------- shell ---------- */
.layout { display: grid; grid-template-columns: 264px minmax(0, 1fr); min-height: 100vh; }
.side {
  position: sticky; top: 0; height: 100vh; overflow-y: auto; padding: 22px 14px; color: var(--side-text);
  display: flex; flex-direction: column;
  background: linear-gradient(180deg, #ffffff 0%, #f8fafd 60%, #eef3fa 100%);
  border-right: 1px solid var(--line); box-shadow: 4px 0 24px rgba(76, 58, 170, .05);
  scrollbar-width: thin; scrollbar-color: var(--line-2) transparent;
}
.side .logo { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; padding: 0 8px 22px; color: var(--text); }
.side .logo:hover { text-decoration: none; }
.side .logo img { width: 200px; height: auto; display: block; }
.side .logo strong { display: block; font-size: 1.3rem; letter-spacing: -0.02em; line-height: 1.2; }
.side .logo small { display: block; font-size: 0.72rem; color: var(--side-muted); padding-left: 4px; }
.side .label { font-size: 0.68rem; text-transform: uppercase; letter-spacing: .1em; color: var(--side-muted); padding: 18px 12px 6px; font-weight: 700; }
.side a.item {
  position: relative; display: flex; align-items: center; gap: 11px; padding: 9px 12px; margin: 2px 0; border-radius: 12px;
  color: var(--side-text); font-weight: 550; border: 1px solid transparent; transition: background .15s ease, color .15s ease;
}
.side a.item .ic { color: color-mix(in srgb, var(--button) 55%, #7f8aa0); }
.side a.item:hover { background: var(--button-soft); color: var(--button); text-decoration: none; }
.side a.item:hover .ic { color: var(--button); }
.side a.item.active {
  color: #fff; font-weight: 650; background: var(--button);
  box-shadow: 0 8px 20px color-mix(in srgb, var(--button) 30%, transparent);
}
.side a.item.active .ic { color: #fff; }
.side a.item .tag { font-size: 0.68rem; color: var(--side-muted); font-weight: 650; padding: 1px 7px; border-radius: 999px; background: var(--panel-2); border: 1px solid var(--line); }
.side a.item.active .tag { color: #fff; background: rgba(255, 255, 255, .2); border-color: transparent; }
.side a.item.tree-item { margin-left: 16px; }
.side a.item.tree-item::before { content: ""; position: absolute; left: -9px; top: 50%; width: 8px; border-top: 1px solid var(--line-2); }
.side .sub { margin: 2px 0 6px 26px; padding-left: 8px; border-left: 1px solid var(--line-2); }
.side .sub a.item { padding: 6px 10px; font-size: 0.92rem; font-weight: 500; }
.side .sub a.item .ic { width: 16px; height: 16px; }
.side .sub a.item.active { background: var(--button-soft); color: var(--button); box-shadow: none; font-weight: 650; }
.side .sub a.item.active .ic { color: var(--button); }
.side a.item.add { color: var(--button); margin-top: 8px; border: 1px dashed color-mix(in srgb, var(--button) 30%, var(--line-2)); }
.side a.item.add .ic { color: var(--button); }
.side-foot { margin-top: auto; padding-top: 22px; }
.me { display: flex; align-items: center; gap: 10px; padding: 10px; border-radius: 14px; background: var(--panel); border: 1px solid var(--line); box-shadow: var(--shadow); }
.me strong { display: block; font-size: 0.9rem; color: var(--text); }
.me small { display: block; color: var(--side-muted); font-size: 0.75rem; }
.me form { margin: 0; }
.icon-button { background: transparent; border: 0; padding: 6px; color: var(--muted); border-radius: 8px; box-shadow: none; }
.icon-button:hover { background: var(--brand-soft); color: var(--brand); box-shadow: none; }
.avatar {
  width: 34px; height: 34px; border-radius: 50%; display: inline-grid; place-items: center; flex: none;
  font-size: 0.78rem; font-weight: 750; color: #fff; background: linear-gradient(135deg, #1E428A, #3b6fd1);
  box-shadow: 0 0 0 2px rgba(255, 255, 255, .7);
}
.avatar.lg { width: 40px; height: 40px; font-size: 0.85rem; box-shadow: 0 0 0 3px var(--panel), 0 4px 14px rgba(90, 60, 255, .3); }
.content { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 5; display: flex; justify-content: space-between; align-items: center; gap: 16px;
  padding: 14px 32px; border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--panel) 72%, transparent); backdrop-filter: blur(14px);
}
.crumbs { display: flex; align-items: center; gap: 14px; min-width: 0; }
.crumb-icon { color: var(--muted); }
.crumb-icon .ic { width: 24px; height: 24px; }
.crumb-title { font-size: 1.25rem; font-weight: 750; letter-spacing: -0.02em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.crumb-title a { color: var(--muted); font-weight: 600; }
.crumb-title .sep { color: var(--line-2); margin: 0 8px; }
.crumb-sub { color: var(--muted); font-size: 0.85rem; }
.top-actions { display: flex; align-items: center; gap: 16px; flex: none; }
.main { padding: 26px 32px 56px; max-width: 1560px; width: 100%; }
.top { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 20px; }
.top form { margin: 0; }
.top > .button { flex: none; white-space: nowrap; }

/* ---------- surfaces ---------- */
.card, .panel {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px 20px; margin-bottom: 18px; box-shadow: var(--shadow);
}
.grid { display: grid; gap: 18px; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); }
.stats { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); margin-bottom: 18px; }
.stat {
  background: linear-gradient(160deg, var(--panel), var(--panel-2)); border: 1px solid var(--line); border-radius: 16px;
  padding: 14px 16px; box-shadow: var(--shadow); position: relative; overflow: hidden;
}
.stat .n { font-size: 1.6rem; font-weight: 780; letter-spacing: -0.02em; }
.stat .l { color: var(--muted); font-size: 0.8rem; font-weight: 600; }
table { width: 100%; border-collapse: separate; border-spacing: 0; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 0.72rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 700; background: var(--panel-2); }
th:first-child { border-top-left-radius: 10px; }
th:last-child { border-top-right-radius: 10px; }
tr:hover td { background: color-mix(in srgb, var(--brand-soft) 45%, transparent); }
tr:last-child td { border-bottom: 0; }
td.text { max-width: 420px; }
.clip { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.clip1 { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.badge { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 0.74rem; font-weight: 650;
  background: var(--brand-soft); color: var(--brand); white-space: nowrap; }
.badge.ok, .badge.grounded, .badge.smalltalk, .badge.executed, .badge.approved, .badge.succeeded, .badge.agent { background: var(--ok-soft); color: var(--ok); }
.badge.warn, .badge.no_knowledge, .badge.uncited, .badge.pending, .badge.proposed, .badge.rate_limited, .badge.over_limit, .badge.awaiting_user { background: var(--warn-soft); color: var(--warn); }
.badge.bad, .badge.blocked, .badge.filtered, .badge.error, .badge.failed, .badge.rejected { background: var(--bad-soft); color: var(--bad); }
.flash { padding: 12px 16px; border-radius: 14px; margin-bottom: 18px; border: 1px solid transparent; font-weight: 550; }
.flash.ok { background: var(--ok-soft); color: var(--ok); border-color: color-mix(in srgb, var(--ok) 25%, transparent); }
.flash.warn { background: var(--warn-soft); color: var(--warn); border-color: color-mix(in srgb, var(--warn) 25%, transparent); }
.flash.error { background: var(--bad-soft); color: var(--bad); border-color: color-mix(in srgb, var(--bad) 25%, transparent); }

/* ---------- forms ---------- */
form.inline { display: inline; }
label { display: block; font-weight: 650; margin: 12px 0 5px; }
label .hint, .hint { font-weight: 400; color: var(--muted); font-size: 0.85rem; }
input[type=text], input[type=number], input[type=password], input[type=search], select, textarea {
  width: 100%; padding: 9px 12px; border: 1px solid var(--line-2); border-radius: 12px;
  background: var(--panel-2); color: var(--text); font: inherit; transition: border-color .15s ease, box-shadow .15s ease;
}
textarea { min-height: 180px; font-family: var(--mono); font-size: 0.85rem; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 4px color-mix(in srgb, var(--brand) 18%, transparent); }
.check { display: inline-flex; gap: 6px; align-items: center; font-weight: 450; margin-right: 16px; }
button, .button {
  display: inline-flex; align-items: center; gap: 8px; padding: 8px 16px; border-radius: 12px; border: 1px solid transparent;
  background: var(--button); color: #fff; font: inherit; font-weight: 650; cursor: pointer;
  box-shadow: 0 6px 18px color-mix(in srgb, var(--button) 30%, transparent); transition: transform .12s ease, box-shadow .12s ease;
}
button:hover, .button:hover { text-decoration: none; transform: translateY(-1px); background: var(--button-hover); box-shadow: 0 10px 24px color-mix(in srgb, var(--button) 38%, transparent); }
button:active, .button:active { transform: translateY(0); }
.button.glow { padding: 10px 18px; }
.button .ic { width: 16px; height: 16px; }
button.secondary, .button.secondary { background: var(--panel); color: var(--button); border-color: color-mix(in srgb, var(--button) 35%, var(--line-2)); box-shadow: none; }
button.secondary:hover, .button.secondary:hover { background: color-mix(in srgb, var(--button) 8%, var(--panel)); }
button.danger:hover { background: var(--bad-soft); }
button.danger { background: var(--panel); border-color: color-mix(in srgb, var(--bad) 40%, transparent); color: var(--bad); box-shadow: none; }
button.small { padding: 4px 10px; font-size: 0.85rem; border-radius: 9px; }
.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: end; margin-bottom: 14px; }
.filters > * { width: auto; }
.pager { display: flex; gap: 12px; align-items: center; margin-top: 14px; }
pre { background: var(--panel-2); border: 1px solid var(--line); border-radius: 12px; padding: 12px; overflow: auto;
  white-space: pre-wrap; word-break: break-word; font-family: var(--mono); font-size: 0.82rem; margin: 0; }
.bubble { white-space: pre-wrap; padding: 14px; border-radius: 16px; border: 1px solid var(--line); background: var(--panel-2); }
.kv { display: grid; grid-template-columns: 160px 1fr; gap: 8px 12px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.spread { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.empty { color: var(--muted); padding: 14px 0; }
.eyebrow { font-size: 0.68rem; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); font-weight: 700; }

/* ---------- sign-in ---------- */
body.signin { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login { width: 100%; max-width: 440px; margin: 0; padding: 0; overflow: hidden; box-shadow: 0 30px 80px rgba(76, 58, 170, .18); }
.login .art { height: 120px; background: url("/admin/static/brain-hero.webp") center / cover no-repeat; }
.login .body { padding: 22px 26px 26px; }
.login .brand { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.login .brand h1 { margin: 0; }
.login .brand img { border-radius: 14px; box-shadow: 0 6px 18px rgba(90, 80, 255, .35); }
.login .brand.wordmark { flex-direction: column; align-items: flex-start; gap: 2px; }
.login .brand.wordmark img { width: 220px; height: auto; border-radius: 0; box-shadow: none; }
.login button { width: 100%; justify-content: center; margin-top: 14px; padding: 10px; }

/* ---------- dashboard ---------- */
.hero {
  position: relative; overflow: hidden; display: flex; justify-content: space-between; align-items: center; gap: 20px;
  min-height: 150px; padding: 26px 30px; margin-bottom: 20px; border-radius: 22px; border: 1px solid var(--line);
  background:
    url("/admin/static/brain-hero.webp") 80% center / auto 150% no-repeat,
    linear-gradient(110deg, var(--panel) 0%, color-mix(in srgb, var(--panel) 85%, var(--brand-soft)) 40%, #cdd8ff 100%);
  box-shadow: var(--shadow);
}
.hero::before { content: ""; position: absolute; inset: 0; background: linear-gradient(90deg, var(--panel) 38%, color-mix(in srgb, var(--panel) 70%, transparent) 55%, transparent 75%); pointer-events: none; }
.hero > * { position: relative; }
.hero h1 { font-size: 2.15rem; display: flex; align-items: center; gap: 12px; margin: 0 0 6px; letter-spacing: -0.03em; }
.hero p { margin: 0; color: var(--muted); font-size: 1.05rem; max-width: 520px; }
.hero-spark .ic { width: 30px; height: 30px; color: var(--brand); fill: color-mix(in srgb, var(--brand) 25%, transparent); }
.hero-pills { display: inline-flex; align-items: center; gap: 10px; padding: 10px 18px; border-radius: 14px; font-weight: 600; font-size: 0.9rem;
  background: color-mix(in srgb, var(--panel) 75%, transparent); border: 1px solid rgba(255, 255, 255, .6); backdrop-filter: blur(10px);
  box-shadow: var(--shadow); align-self: flex-start; }
.hero-pills i { color: var(--brand); font-style: normal; }
.hero-pills .ic { color: var(--brand); }
.dash { display: grid; gap: 20px; grid-template-columns: minmax(0, 1fr) 340px; align-items: start; }
.dash-main { min-width: 0; container-type: inline-size; }
.dash-side .panel { padding: 16px; }
.kpis { display: grid; gap: 16px; grid-template-columns: repeat(4, minmax(0, 1fr)); margin-bottom: 20px; }
.kpi {
  display: flex; align-items: flex-start; gap: 12px; padding: 16px; min-height: 118px; border-radius: var(--radius); border: 1px solid var(--line);
  box-shadow: var(--shadow); position: relative; overflow: hidden; background: var(--panel);
}
.kpi:nth-child(1) { background: linear-gradient(150deg, var(--panel) 45%, var(--blue-soft)); }
.kpi:nth-child(2) { background: linear-gradient(150deg, var(--panel) 45%, var(--violet-soft)); }
.kpi:nth-child(3) { background: linear-gradient(150deg, var(--panel) 45%, var(--teal-soft)); }
.kpi:nth-child(4) { background: linear-gradient(150deg, var(--panel) 45%, var(--cyan-soft)); }
.kpi-text { flex: 1; min-width: 0; }
.kpi-label { color: var(--text); font-size: 0.85rem; font-weight: 650; }
.kpi-value { font-size: 1.85rem; font-weight: 800; letter-spacing: -0.03em; line-height: 1.2; margin: 2px 0; }
.kpi-sub { color: var(--muted); font-size: 0.78rem; }
.kpi .spark { position: absolute; right: 14px; top: 20px; margin: 0; }
.kpi .ring { flex: none; align-self: center; }
.delta { font-weight: 750; }
.delta.up { color: var(--ok); }
.delta.down { color: var(--bad); }
.tile-icon { width: 44px; height: 44px; border-radius: 14px; display: inline-grid; place-items: center; flex: none;
  background: var(--brand-soft); color: var(--brand); }
.tile-icon .ic { width: 22px; height: 22px; }
.tile-icon.sm { width: 34px; height: 34px; border-radius: 11px; }
.tile-icon.sm .ic { width: 18px; height: 18px; }
.tile-icon.blue { background: var(--blue-soft); color: var(--blue); }
.tile-icon.violet { background: var(--violet-soft); color: var(--violet); }
.tile-icon.cyan { background: var(--cyan-soft); color: var(--cyan); }
.tile-icon.teal { background: var(--teal-soft); color: var(--teal); }
.tile-icon.rose { background: var(--rose-soft); color: var(--rose); }
.tile-icon.soft { background: var(--panel-2); color: var(--muted); border: 1px solid var(--line); }
.panel-head { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 12px; margin-bottom: 14px; }
.panel-title { display: flex; align-items: center; gap: 12px; min-width: 0; }
.panel-title h2 { margin: 0; }
.panel-note { margin-top: 10px; }
.segmented { display: inline-flex; padding: 3px; border-radius: 12px; background: var(--panel-2); border: 1px solid var(--line); flex: none; }
.segmented a { padding: 5px 12px; border-radius: 9px; color: var(--muted); font-weight: 600; font-size: 0.85rem; }
.segmented a:hover { text-decoration: none; color: var(--text); }
.segmented a.on { background: var(--button); color: #fff; box-shadow: 0 1px 3px color-mix(in srgb, var(--button) 30%, transparent); }
.perf { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 18px; }
.perf > * { min-width: 0; }
@container (max-width: 820px) { .perf { grid-template-columns: 1fr; } }
.perf-side { border: 1px solid var(--line); border-radius: 16px; padding: 14px; background: var(--panel-2); }
.legend { display: flex; gap: 18px; font-size: 0.82rem; color: var(--muted); margin: 0 0 6px 40px; }
.legend i { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 6px; }
.legend i.blue { background: var(--blue); }
.legend i.violet { background: var(--violet); }
svg.area, svg.columns { width: 100%; height: auto; display: block; overflow: visible; }
.gridline { stroke: var(--line); stroke-width: 1; stroke-dasharray: 3 4; }
.axis { fill: var(--muted); font-size: 11px; }
.area-line { fill: none; stroke-width: 2.6; stroke-linecap: round; }
.area-line.blue { stroke: var(--blue); }
.area-line.violet { stroke: var(--violet); }
.area-fill.blue { fill: color-mix(in srgb, var(--blue) 16%, transparent); }
.area-fill.violet { fill: color-mix(in srgb, var(--violet) 10%, transparent); }
.hit-area { fill: transparent; }
.hit .guide { stroke: var(--line-2); stroke-dasharray: 4 4; opacity: 0; }
.hover-dot { opacity: 0; stroke: var(--panel); stroke-width: 2.5; }
.hover-dot.blue { fill: var(--blue); }
.hover-dot.violet { fill: var(--violet); }
.hit:hover .guide, .hit:hover .hover-dot { opacity: 1; }
.col { transition: opacity .15s ease; }
.col.c0 { fill: var(--blue); }
.col.c1 { fill: var(--violet); }
.col.c2 { fill: var(--cyan); }
.col.c3 { fill: var(--teal); }
.col.c4 { fill: #a5b4fc; }
svg.columns g:hover .col { opacity: .8; }
.status-row, .model-row, .feed-row { display: flex; align-items: center; gap: 12px; padding: 9px 8px; border-radius: 12px; color: var(--text); }
a.status-row:hover, a.model-row:hover, a.feed-row:hover { background: var(--panel-2); text-decoration: none; }
.status-row strong, .feed-row strong { display: block; font-size: 0.92rem; }
.status-row small, .feed-row small { display: block; color: var(--muted); font-size: 0.76rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.model-row { border: 1px solid var(--line); margin-bottom: 8px; background: var(--panel-2); }
.model-row .model-name { color: var(--brand); background: var(--brand-soft); padding: 1px 8px; border-radius: 999px; font-size: 0.76rem; }
.model-row .ic { width: 14px; height: 14px; }
.feed-row .when { color: var(--muted); font-size: 0.76rem; white-space: nowrap; }
.feed-row .ic { width: 16px; height: 16px; }
.feed-row + .feed-row { border-top: 1px solid var(--line); border-radius: 0; }
.pill { font-size: 0.72rem; font-weight: 700; padding: 3px 10px; border-radius: 999px; white-space: nowrap; display: inline-flex; align-items: center; gap: 5px; flex: none; }
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill.ok { background: var(--ok-soft); color: var(--ok); }
.pill.attention { background: var(--warn-soft); color: var(--warn); }
.pill.problem { background: var(--bad-soft); color: var(--bad); }
.tools { display: grid; grid-template-columns: repeat(auto-fill, minmax(88px, 1fr)); gap: 10px; }
.tool { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 10px 6px; border-radius: 14px; border: 1px solid var(--line); background: var(--panel-2); text-align: center; }
.tool-name { font-size: 0.72rem; color: var(--muted); line-height: 1.2; }
.tool strong { font-size: 1rem; }
.dash-bottom { display: grid; gap: 20px; grid-template-columns: repeat(4, minmax(0, 1fr)); margin-top: 2px; }
.dash-bottom .panel { margin-bottom: 0; min-width: 0; }
.all-good { display: flex; align-items: center; gap: 10px; padding: 10px 8px; color: var(--ok); font-weight: 650; }
.section-title { font-size: 1.3rem; margin: 34px 0 4px; }
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; flex: none; background: var(--ok); box-shadow: 0 0 0 4px var(--ok-soft); }
.dot.attention { background: var(--warn); box-shadow: 0 0 0 4px var(--warn-soft); }
.dot.problem { background: var(--bad); box-shadow: 0 0 0 4px var(--bad-soft); }
.branch { margin-top: 20px; }
.branch-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 14px; }
.branch-head h2 { font-size: 1.2rem; margin: 0; }
.branch-head h2 a { color: var(--text); }
.tree-grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(310px, 1fr)); }
.bcard {
  display: flex; flex-direction: column; gap: 12px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px 18px; color: var(--text); box-shadow: var(--shadow); transition: transform .15s ease, box-shadow .15s ease, border-color .15s ease;
}
.bcard:hover { text-decoration: none; transform: translateY(-3px); border-color: color-mix(in srgb, var(--brand) 40%, var(--line)); box-shadow: var(--shadow-hover); }
.bcard.org { background: linear-gradient(150deg, var(--panel) 40%, var(--violet-soft)); }
.bcard-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.bcard-name { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 1rem; }
.bcard-body { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.bcard-body .big { font-size: 1.7rem; font-weight: 800; letter-spacing: -0.03em; line-height: 1.1; }
.bcard-foot { display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; border-top: 1px solid var(--line); padding-top: 10px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { font-size: 0.72rem; font-weight: 650; padding: 2px 9px; border-radius: 999px; background: var(--brand-soft); color: var(--brand); }
.chip.ok { background: var(--ok-soft); color: var(--ok); }
.chip.warn { background: var(--warn-soft); color: var(--warn); }
.chip.bad { background: var(--bad-soft); color: var(--bad); }
.spark { display: block; margin-top: 6px; }
.spark-line { fill: none; stroke: var(--brand); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.spark-area { fill: color-mix(in srgb, var(--brand) 14%, transparent); }
.spark-dot { fill: var(--brand); }
.spark.blue .spark-line { stroke: var(--blue); }
.spark.blue .spark-area { fill: color-mix(in srgb, var(--blue) 14%, transparent); }
.spark.blue .spark-dot { fill: var(--blue); }
.spark-flat { stroke: var(--line-2); stroke-width: 1.5; stroke-dasharray: 3 3; }
.ring-track { fill: none; stroke: var(--line); stroke-width: 5; }
.ring-fill { fill: none; stroke-width: 5; stroke-linecap: round; }
.ring-ok .ring-fill { stroke: var(--violet); }
.ring-warn .ring-fill { stroke: var(--warn); }
.ring-bad .ring-fill { stroke: var(--bad); }
.ring-text { fill: var(--text); font-size: 11px; font-weight: 750; text-anchor: middle; }
.empty-slot { border: 1px dashed var(--line-2); border-radius: var(--radius); padding: 18px; display: flex; align-items: center; justify-content: center; }

/* ---------- people, account, system ---------- */
.split-2 { display: grid; gap: 20px; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); align-items: start; }
.person { display: flex; align-items: center; gap: 12px; }
.person.big h1 { margin: 0; }
.role { display: inline-block; font-size: 0.72rem; font-weight: 700; padding: 2px 10px; border-radius: 999px; }
.role.owner { background: var(--violet-soft); color: var(--violet); }
.role.admin { background: var(--blue-soft); color: var(--blue); }
.role.viewer { background: var(--panel-2); color: var(--muted); border: 1px solid var(--line); }
.role.agent { background: var(--teal-soft); color: var(--teal); }
.roles-grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.roles-grid p { margin: 8px 0 0; }
.role-pick { display: grid; gap: 8px; }
.choice { display: flex; gap: 10px; align-items: flex-start; margin: 0; padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel-2); font-weight: 400; cursor: pointer; }
.choice:has(input:checked) { border-color: var(--brand); background: var(--brand-soft); }
.choice input { margin-top: 3px; accent-color: var(--brand); }
.choice strong { display: block; }
.choice small { display: block; color: var(--muted); }
.access-list { display: flex; flex-direction: column; gap: 4px; max-height: 260px; overflow-y: auto; padding: 8px 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel-2); }
.access-list .check { margin: 0; padding: 3px 0; }
.access-list .check.indent { padding-left: 22px; }
.access-list input, .check input { accent-color: var(--brand); }
.small-button { padding: 4px 12px; font-size: 0.85rem; border-radius: 9px; }
.danger-zone { border-color: color-mix(in srgb, var(--bad) 25%, var(--line)); }
.meter { height: 6px; border-radius: 999px; background: var(--line); overflow: hidden; margin: 8px 0 4px; }
.meter span { display: block; height: 100%; background: linear-gradient(90deg, var(--blue), var(--violet)); border-radius: 999px; }
.alt-signin { margin-top: 18px; border-top: 1px solid var(--line); padding-top: 12px; }
.alt-signin summary { cursor: pointer; color: var(--muted); font-size: 0.88rem; }
.me-link { color: inherit; }
.me-link:hover { text-decoration: none; }
a.avatar:hover { text-decoration: none; }
/* Viewers read only: forms that change something are not shown (the server refuses them too). */
.role-viewer .main form[method=post]:not(.keep) { display: none; }

/* ---------- live chats ---------- */
.pill.ai { background: var(--blue-soft); color: var(--blue); }
.side a.item .count { min-width: 22px; height: 22px; padding: 0 7px; border-radius: 999px; display: inline-grid; place-items: center; font-size: 0.75rem; font-weight: 750; color: #fff; background: var(--rose); }
.chat-panel { padding: 0; overflow: hidden; }
.thread-frame { display: block; width: 100%; height: min(60vh, 560px); border: 0; border-bottom: 1px solid var(--line); background: var(--panel-2); }
.reply { display: flex; gap: 10px; padding: 14px; align-items: flex-end; }
.reply textarea { min-height: 70px; height: 70px; font-family: inherit; font-size: 0.95rem; }
.chat-panel .hint { padding: 0 16px 14px; margin: 0; }
body.thread { background: var(--panel-2); padding: 16px; margin: 0; }
.t-msg { max-width: 78%; margin: 8px 0; padding: 10px 14px; border-radius: 16px; background: var(--panel); border: 1px solid var(--line); box-shadow: 0 1px 2px rgba(40, 28, 110, .05); }
.t-msg.visitor { margin-right: auto; border-bottom-left-radius: 6px; }
.t-msg.ai { margin-left: auto; background: var(--blue-soft); border-color: transparent; border-bottom-right-radius: 6px; }
.t-msg.staff { margin-left: auto; background: linear-gradient(135deg, #1E428A, #2c5bb5); color: #fff; border-color: transparent; border-bottom-right-radius: 6px; }
.t-msg.staff .t-who { color: rgba(255, 255, 255, .8); }
.t-who { font-size: 0.72rem; font-weight: 700; color: var(--muted); margin-bottom: 3px; }
.t-text { white-space: pre-wrap; word-wrap: break-word; }
.t-note { text-align: center; color: var(--muted); font-size: 0.8rem; margin: 14px auto; max-width: 80%; white-space: pre-wrap; }
.t-note span { display: block; font-size: 0.7rem; opacity: .7; }

/* ---------- messenger (live chats) ---------- */
.messenger { display: grid; grid-template-columns: 340px minmax(0, 1fr); height: calc(100vh - 150px); min-height: 520px; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: var(--panel); box-shadow: var(--shadow); }
.chat-list-frame { width: 100%; height: 100%; border: 0; border-right: 1px solid var(--line); background: var(--panel); }
.conversation { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.conversation .thread-frame { flex: 1; height: auto; min-height: 0; }
.conv-head { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--line); background: var(--panel); }
.conv-head strong { display: block; }
.conv-head small { display: block; }
.avatar.customer { background: linear-gradient(135deg, #10b981, #06b6d4); font-size: 0.72rem; }
.switch { display: inline-flex; padding: 3px; border-radius: 12px; background: var(--panel-2); border: 1px solid var(--line); flex: none; }
.switch form { margin: 0; }
.switch button { background: transparent; color: var(--muted); box-shadow: none; padding: 7px 14px; border-radius: 9px; font-weight: 650; }
.switch button:hover { transform: none; box-shadow: none; color: var(--text); background: transparent; }
.switch button.on:hover { background: var(--button-hover); color: #fff; }
.switch button.on { background: var(--button); color: #fff; box-shadow: 0 4px 12px color-mix(in srgb, var(--button) 30%, transparent); }
.switch .ic { width: 16px; height: 16px; }
.conv-banner { display: flex; gap: 8px; align-items: center; padding: 8px 16px; font-size: 0.85rem; }
.conv-banner .ic { width: 16px; height: 16px; flex: none; }
.conv-banner.warn { background: var(--warn-soft); color: var(--warn); }
.conv-banner.ok { background: var(--ok-soft); color: var(--ok); }
.conversation .reply { border-top: 1px solid var(--line); background: var(--panel); }
.conversation .reply textarea { min-height: 46px; height: 46px; border-radius: 22px; padding: 12px 16px; resize: none; }
.conversation .reply button { width: 46px; height: 46px; border-radius: 50%; justify-content: center; padding: 0; font-size: 1.1rem; flex: none; }
.conv-hint { margin: 0; padding: 0 16px 10px; }
.empty-conv { align-items: center; justify-content: center; text-align: center; background: var(--panel-2); }
.empty-conv > div { max-width: 380px; display: flex; flex-direction: column; align-items: center; gap: 8px; }
body.chat-list { margin: 0; background: var(--panel); }
.list-filter { position: sticky; top: 0; display: flex; gap: 4px; padding: 10px; background: var(--panel); border-bottom: 1px solid var(--line); z-index: 1; }
.list-filter a { padding: 5px 12px; border-radius: 999px; color: var(--muted); font-weight: 650; font-size: 0.82rem; }
.list-filter a.on { background: var(--button-soft); color: var(--button); }
.list-filter a:hover { text-decoration: none; }
.list-filter .count { display: inline-block; min-width: 18px; padding: 0 5px; border-radius: 999px; background: var(--rose); color: #fff; font-size: 0.7rem; text-align: center; }
.chat-item { display: flex; gap: 12px; padding: 12px 14px; border-bottom: 1px solid var(--line); color: var(--text); }
.chat-item:hover { background: var(--panel-2); text-decoration: none; }
.chat-item.current { background: var(--brand-soft); }
.chat-item.waiting { box-shadow: inset 3px 0 0 var(--rose); }
.chat-item .avatar { width: 42px; height: 42px; font-size: 0.7rem; box-shadow: none; }
.chat-item .avatar.ai { background: linear-gradient(135deg, #94a3b8, #64748b); }
.chat-item .avatar.waiting { background: linear-gradient(135deg, #fb7185, #ef4565); }
.chat-item .avatar.human { background: linear-gradient(135deg, #10b981, #06b6d4); }
.chat-top { display: flex; justify-content: space-between; gap: 8px; }
.chat-top .when { color: var(--muted); font-size: 0.72rem; white-space: nowrap; }
.chat-preview { display: block; color: var(--muted); font-size: 0.82rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-meta { display: block; margin-top: 4px; }

/* ---------- channels ---------- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin: -4px 0 20px; }
.tabs a { padding: 10px 16px; color: var(--muted); font-weight: 650; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs a:hover { color: var(--text); text-decoration: none; }
.tabs a.on { color: var(--button); border-bottom-color: var(--button); }
.side .sub-label { font-size: 0.64rem; text-transform: uppercase; letter-spacing: .1em; color: var(--side-muted); padding: 10px 10px 2px; font-weight: 700; }
.channel-stat { text-align: right; }
.channel-stat strong { display: block; font-size: 1.6rem; letter-spacing: -0.02em; }
.snippet { background: #17142f; color: #e9e5ff; border: 0; border-radius: 12px; padding: 14px 16px; font-size: 0.85rem; user-select: all; }
.widget-preview { display: block; width: 100%; height: 640px; border: 1px solid var(--line, #e9e3f6); border-radius: 14px; background: #f6f4fb; }
.logo-current { display: flex; align-items: center; gap: 10px; margin: 2px 0 8px; }
.logo-current img { width: 44px; height: 44px; border-radius: 10px; border: 1px solid var(--line); object-fit: contain; background: #fff; }
.form-grid { display: grid; gap: 0 16px; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
textarea.short { min-height: 70px; font-family: inherit; font-size: 0.92rem; }
.key-form { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; margin-top: 16px; padding-top: 12px; border-top: 1px solid var(--line); }
.key-form label { margin-top: 0; }
.steps { padding-left: 20px; line-height: 1.8; }
.steps .snippet { margin: 6px 0; }
.endpoints { display: grid; gap: 6px; margin: 14px 0; }
.endpoints > div { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; padding: 8px 10px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel-2); }
.method { font-size: 0.7rem; font-weight: 800; padding: 2px 8px; border-radius: 6px; background: var(--teal-soft); color: var(--teal); }
.method.get { background: var(--blue-soft); color: var(--blue); }

/* ---------- insights ---------- */
.need { display: flex; gap: 14px; align-items: flex-start; padding: 14px 10px; border-radius: 12px; color: var(--text); }
.need + .need { border-top: 1px solid var(--line); border-radius: 0; }
a.need:hover { background: var(--panel-2); text-decoration: none; }
.need strong { display: block; font-size: 1rem; }
.need small { display: block; color: var(--muted); }
.need small.todo { color: var(--brand); font-weight: 600; margin-top: 2px; }
.priority { font-size: 0.7rem; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; padding: 3px 10px; border-radius: 999px; flex: none; margin-top: 2px; }
.priority.high { background: var(--bad-soft); color: var(--bad); }
.priority.medium { background: var(--warn-soft); color: var(--warn); }
.priority.low { background: var(--panel-2); color: var(--muted); border: 1px solid var(--line); }
.topic { border: 1px solid var(--line); border-radius: 14px; margin: 10px 0; background: var(--panel); }
.topic summary { display: flex; gap: 12px; align-items: center; padding: 12px 14px; cursor: pointer; list-style: none; }
.topic summary::-webkit-details-marker { display: none; }
.topic[open] summary { border-bottom: 1px solid var(--line); }
.topic .chips { margin-top: 4px; }
.topic-count { min-width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; font-weight: 800; background: var(--brand-soft); color: var(--brand); flex: none; }
.examples { margin: 10px 0; padding: 0 16px 0 34px; }
.examples li { margin: 4px 0; }
.topic .row { padding: 0 14px 12px; }
.signal-legend { margin: 6px 0 12px; }

/* ---------- one message (run) ---------- */
.exchange { background: var(--panel-2); display: flex; flex-direction: column; }
.exchange .t-msg { max-width: 82%; }
.cites { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.run-grid { display: grid; gap: 20px; grid-template-columns: minmax(280px, 1fr) minmax(0, 2fr); align-items: start; }
.run-grid .kv { grid-template-columns: 120px 1fr; }
.source-row { display: flex; align-items: center; gap: 12px; padding: 10px 6px; }
.source-row + .source-row { border-top: 1px solid var(--line); }
.source-row strong { display: block; overflow-wrap: anywhere; }
.source-row small { display: block; color: var(--muted); font-size: 0.74rem; overflow-wrap: anywhere; }
.sim { display: flex; align-items: center; gap: 8px; flex: none; width: 130px; }
.sim .meter { flex: 1; margin: 0; }
details.raw summary { display: flex; align-items: baseline; gap: 12px; cursor: pointer; list-style: none; }
details.raw summary::-webkit-details-marker { display: none; }
details.raw summary h2 { margin: 0; }
details.raw[open] summary { margin-bottom: 12px; }
/* Tables never spill out of their card. */
.card, .panel { min-width: 0; }
.card table, .panel table { table-layout: auto; }
td { overflow-wrap: anywhere; }

/* ---------- insights analysis ---------- */
.summary { margin: 0; padding-left: 20px; line-height: 1.8; font-size: 1rem; }
.summary li::marker { color: var(--brand); }
.funnel-step { display: grid; grid-template-columns: 200px 1fr 60px; gap: 10px; align-items: center; margin: 10px 0; }
.funnel-label { color: var(--muted); font-size: 0.85rem; }
.funnel-bar { height: 14px; border-radius: 999px; background: var(--line); overflow: hidden; }
.funnel-bar span { display: block; height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--blue), var(--violet)); }
.funnel-step strong { text-align: right; }
.funnel-gap { border-top: 1px dashed var(--line); margin: 14px 0; }
.topics th:not(:first-child), .topics td:not(:first-child) { white-space: nowrap; width: 1%; }
.topics tr.weak td { background: color-mix(in srgb, var(--bad-soft) 55%, transparent); }
.meter.rate.ok span { background: var(--ok); }
.meter.rate.warn span { background: var(--warn); }
.meter.rate.bad span { background: var(--bad); }
.breakdowns { display: grid; gap: 20px; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.breakdowns .panel { margin-bottom: 0; }
.hbar { display: grid; grid-template-columns: 130px 1fr 80px; gap: 8px; align-items: center; margin: 8px 0; font-size: 0.85rem; }
.hbar-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hbar-track { height: 8px; border-radius: 999px; background: var(--line); overflow: hidden; }
.hbar-track span { display: block; height: 100%; background: var(--brand); border-radius: 999px; }
.hbar-n { text-align: right; color: var(--muted); }
.breakdowns + .panel { margin-top: 20px; }

/* ---------- knowledge connections ---------- */
.kind-pick { display: grid; gap: 8px; }
.connector .flash { margin: 8px 0; }
.tool-pick { margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--line); }
.tool-line { display: flex; align-items: flex-start; gap: 8px; margin: 8px 0; }
.tool-line small { display: block; }
.advanced { margin: 12px 0; }
.advanced summary { cursor: pointer; color: var(--muted); font-size: 0.88rem; }

.key-row { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; }
.key-row label { margin-top: 0; }

.switch-row { display: flex; align-items: center; gap: 12px; padding: 10px 6px; }
.switch-row + .switch-row { border-top: 1px solid var(--line); }
.switch-row.indent { padding-left: 34px; }
.switch-row strong { display: block; }
.switch-row small { display: block; color: var(--muted); }
.switch-row form { margin: 0; }
.side a.item .tag.off { color: var(--bad); background: var(--bad-soft); border-color: transparent; }

/* ---------- learning ---------- */
.memory { border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; margin: 10px 0; background: var(--panel); }
.memory-text { white-space: pre-wrap; margin: 8px 0; padding: 10px 12px; border-radius: 10px; background: var(--panel-2); }
.evidence { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; margin-bottom: 6px; }
.gap-row { display: flex; gap: 10px; align-items: center; padding: 10px 4px; }
.gap-row + .gap-row { border-top: 1px solid var(--line); }
.gap-row strong { display: block; }
.gap-row small { display: block; color: var(--muted); }

/* ---------- responsive ---------- */
@media (max-width: 1600px) {
  .dash-bottom { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 1440px) {
  .dash { grid-template-columns: 1fr; }
  .dash-side { display: grid; gap: 20px; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); align-items: start; }
  .dash-side .panel { margin-bottom: 0; }
}
@media (max-width: 1100px) {
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; }
  .side { position: static; height: auto; }
  .dash-side { grid-template-columns: 1fr; }
  .topbar { padding: 12px 16px; position: static; }
  .top-actions .button { display: none; }
  .main { padding: 16px; }
  .hero { background: linear-gradient(110deg, var(--panel), var(--brand-soft)); padding: 20px; }
  .hero::before { display: none; }
  .hero h1 { font-size: 1.6rem; }
  .hero-pills { display: none; }
  .kpis, .dash-bottom { grid-template-columns: 1fr; }
  .kv { grid-template-columns: 1fr; }
  .split-2 { grid-template-columns: 1fr; }
  .run-grid { grid-template-columns: 1fr; }
  .messenger { grid-template-columns: 1fr; grid-template-rows: 240px minmax(420px, 1fr); height: auto; }
  .chat-list-frame { border-right: 0; border-bottom: 1px solid var(--line); }
  .conv-head { flex-wrap: wrap; }
  .exchange .t-msg { max-width: 100%; }
}

/* ---------- workflow map ---------- */
.flow-panel { overflow-x: auto; }
.flow { display: block; width: 100%; min-width: 900px; height: auto; font-family: inherit; }
.flow .node rect { fill: #fff; stroke: var(--line-2); stroke-width: 1.2; }
.flow a:hover .node rect:first-of-type, .flow a:focus .node rect:first-of-type { stroke: var(--brand, #1E428A); stroke-width: 2; }
.flow .node .stripe { stroke: none; }
.flow .node .title { font-size: 14px; font-weight: 650; fill: var(--text); }
.flow .node .line { font-size: 11.5px; fill: var(--muted); }
.flow .node.off rect:first-of-type { fill: #faf9fd; stroke-dasharray: 5 4; }
.flow .node.off .title, .flow .node.off .line { fill: #a29dba; }
.flow .channel .stripe, .flow-legend .channel { fill: #2f6fe4; background: #2f6fe4; }
.flow .gate .stripe, .flow-legend .gate { fill: #c8356d; background: #c8356d; }
.flow .agent .stripe, .flow-legend .agent { fill: #700299; background: #700299; }
.flow .data .stripe, .flow-legend .data { fill: #0f9b7a; background: #0f9b7a; }
.flow .model .stripe, .flow-legend .model { fill: #8a4fd8; background: #8a4fd8; }
.flow .tool .stripe, .flow-legend .tool { fill: #d98a1c; background: #d98a1c; }
.flow .outside .stripe, .flow-legend .outside { fill: #4b5563; background: #4b5563; }
.flow .background .stripe, .flow-legend .background { fill: #7a7498; background: #7a7498; }
.flow .edge { fill: none; stroke: #cfc7e6; stroke-width: 1.6; }
.flow .edge.busy { stroke: #8a4fd8; stroke-width: 2; stroke-dasharray: 7 6; animation: flow-run 1.2s linear infinite; }
.flow .edge.dashed { stroke-dasharray: 4 5; }
.flow .arrowhead { fill: #b8aed6; }
.flow .edge-label { fill: #fff; stroke: #e4dcf6; }
.flow .edge-text { font-size: 11px; font-weight: 600; fill: #5a3d8a; text-anchor: middle; }
.flow .lane { font-size: 11px; font-weight: 700; letter-spacing: .08em; fill: var(--muted); }
.flow .lane-line { stroke: var(--line); stroke-dasharray: 3 5; }
@keyframes flow-run { to { stroke-dashoffset: -26; } }
@media (prefers-reduced-motion: reduce) { .flow .edge.busy { animation: none; } }
.flow-legend { display: flex; flex-wrap: wrap; gap: 6px 16px; list-style: none; padding: 12px 4px 0; margin: 0; font-size: .82rem; color: var(--muted); }
.flow-legend li { display: flex; align-items: center; gap: 6px; }
.flow-legend .dot { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.flow-legend .sample.off { width: 18px; height: 10px; border: 1.5px dashed #b9b2d1; border-radius: 3px; display: inline-block; }

/* ---------- workflow builder ---------- */
.wf-box-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.wf-parts { display: flex; flex-wrap: wrap; gap: 6px; list-style: none; padding: 0; margin: 4px 0 10px; }
.wf-parts a { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px 4px 4px; border: 1px solid var(--line); border-radius: 999px; background: #fff; font-size: .85rem; }
.wf-parts a:hover { border-color: var(--brand, #1E428A); color: var(--brand, #1E428A); }
.wf-bar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.wf-bar .key-form { margin: 0; }
.wf-bar .hint { flex-basis: 100%; margin: 0; }
.wf-fixed { list-style: none; padding: 0; margin: 0; display: grid; gap: 6px 14px; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.wf-fixed li { display: flex; align-items: baseline; gap: 8px; padding: 6px 10px; border: 1px dashed var(--line-2); border-radius: 10px; color: var(--muted); }
.wf-fixed li .ic { width: 14px; height: 14px; flex: none; position: relative; top: 2px; }
.wf-fixed li strong { color: var(--text); }
.wf-block { position: relative; border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px 10px; margin: 0 0 12px; background: #fff; }
.wf-block header { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }
.wf-block footer { margin-top: 8px; }
.wf-block textarea { min-height: 120px; }
.wf-block.kind-text { border-inline-start: 4px solid #700299; }
.wf-block.kind-model { border-inline-start: 4px solid #8a4fd8; }
.wf-block.kind-agent { border-inline-start: 4px solid #d98a1c; }
.wf-block.kind-worker { border-inline-start: 4px solid #7a7498; }
.wf-block.kind-link { border-inline-start: 4px solid #0f9b7a; }
.wf-delete { position: absolute; top: 12px; inset-inline-end: 14px; }
.wf-add { border: 1px solid var(--line); border-radius: 12px; padding: 8px 14px; margin-bottom: 8px; background: #fff; }
.wf-add summary { cursor: pointer; font-weight: 600; }
.wf-add form { padding-top: 8px; }
.flow .custom .stripe, .flow-legend .custom { fill: #d98a1c; background: #d98a1c; }
.flow .worker .stripe, .flow-legend .worker { fill: #7a7498; background: #7a7498; }
.flow .link .stripe, .flow-legend .link { fill: #0f9b7a; background: #0f9b7a; }
.flow .lock rect { fill: #efeaf9; stroke: #9a93b8; stroke-width: 1.2; }
.flow .lock path { fill: none; stroke: #9a93b8; stroke-width: 1.4; }

/* ---------- live chat panes (live.js swaps their content in place) ---------- */
.live { overflow: hidden; }
.live > iframe { display: block; width: 100%; height: 100%; border: 0; background: transparent; }
.live-body { height: 100%; overflow: auto; }
.live-body.thread { background: var(--panel-2); padding: 16px; }
.live-body.chat-list { background: var(--panel); }

/* ---------- workflow map: a block's info, opened by clicking it (no script: :target) ---------- */
.node-info { display: none; }
.node-info:target { display: block; position: fixed; inset: 0; z-index: 60; }
.node-info-backdrop { position: absolute; inset: 0; background: rgba(27, 24, 56, .45); }
.node-info-card { position: relative; width: min(580px, calc(100% - 32px)); margin: 8vh auto 0; background: #fff; border-radius: 18px; padding: 18px 22px 18px; box-shadow: 0 24px 60px rgba(27, 24, 56, .28); border-inline-start: 5px solid var(--brand, #1E428A); max-height: 84vh; overflow: auto; }
.node-info-card header { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.node-info-card header h2 { margin: 0; flex: 1; font-size: 1.15rem; min-width: 160px; }
.node-info-card .facts { list-style: none; padding: 0; margin: 0 0 10px; display: flex; flex-wrap: wrap; gap: 6px; }
.node-info-card .facts li { background: var(--panel-2); border: 1px solid var(--line); border-radius: 999px; padding: 3px 10px; font-size: .85rem; }
.node-info-card p { margin: 0 0 8px; }
.node-details { display: grid; grid-template-columns: max-content 1fr; gap: 4px 14px; margin: 10px 0; font-size: .9rem; }
.node-details dt { color: var(--muted); }
.node-details dd { margin: 0; }
.node-info-card footer { margin-top: 12px; }
.node-info-card.kind-channel { border-color: #2f6fe4; }
.node-info-card.kind-gate { border-color: #c8356d; }
.node-info-card.kind-data { border-color: #0f9b7a; }
.node-info-card.kind-model { border-color: #8a4fd8; }
.node-info-card.kind-tool, .node-info-card.kind-custom { border-color: #d98a1c; }
.node-info-card.kind-outside { border-color: #4b5563; }
.node-info-card.kind-background, .node-info-card.kind-worker { border-color: #7a7498; }
.node-info-card.kind-link { border-color: #0f9b7a; }
.flow a { text-decoration: none; outline: none; cursor: pointer; }
.flow a text { text-decoration: none; }
.flow a:focus-visible .node rect:first-of-type { stroke: var(--brand, #1E428A); stroke-width: 2; }

/* ---------- AI Builder drawer (no script: :target opens it; a pending proposal keeps it open) ---------- */
.ai-builder { position: fixed; top: 0; inset-inline-end: 0; height: 100vh; width: min(440px, 100%); background: #fff; box-shadow: -18px 0 50px rgba(27, 24, 56, .18); border-inline-start: 1px solid var(--line); padding: 18px 22px 28px; overflow: auto; z-index: 55; transform: translateX(105%); transition: transform .25s ease; }
.ai-builder:target, .ai-builder.pinned { transform: none; }
.ai-builder header { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.ai-builder header h2 { margin: 0; font-size: 1.1rem; display: flex; align-items: center; gap: 8px; }
.ai-builder .ic { width: 18px; height: 18px; color: var(--brand, #1E428A); }
.ai-form textarea { min-height: 120px; width: 100%; }
.ai-running { margin: 6px 0 14px; }
.ai-running p { margin: 10px 0 0; font-size: .92rem; }
.ai-bar { height: 6px; border-radius: 999px; background: var(--panel-2); overflow: hidden; border: 1px solid var(--line); }
.ai-bar span { display: block; width: 35%; height: 100%; border-radius: 999px; background: var(--brand, #1E428A); animation: ai-bar 1.3s ease-in-out infinite; }
@keyframes ai-bar { 0% { transform: translateX(-100%); } 100% { transform: translateX(290%); } }
@media (prefers-reduced-motion: reduce) { .ai-bar span { animation: none; width: 100%; opacity: .5; } }
.node-ask { margin: 12px 0 4px; padding-top: 10px; border-top: 1px solid var(--line); }
.node-ask label { display: block; font-weight: 600; font-size: .9rem; margin-bottom: 4px; }
.node-ask textarea { min-height: 70px; }
.node-ask button { margin-top: 6px; display: inline-flex; align-items: center; gap: 6px; }
.node-ask .ic { width: 15px; height: 15px; }
.ai-proposal h3 { margin: 10px 0 4px; font-size: 1rem; }
.ai-changes { margin: 0 0 8px; padding-inline-start: 18px; font-size: .9rem; }
.ai-changes li { margin: 2px 0; }
.node-body-title { margin: 10px 0 4px; font-size: .9rem; color: var(--muted); }
.node-body { white-space: pre-wrap; background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; font: inherit; font-size: .9rem; max-height: 260px; overflow: auto; margin: 0; }
.flow .node.proposed rect:first-of-type { stroke: #d98a1c; stroke-width: 2.5; }
.flow .node.proposed .stripe { fill: #d98a1c; }
.flow-legend .sample.proposed { width: 18px; height: 10px; border: 2px solid #d98a1c; border-radius: 3px; display: inline-block; }
.node-info-card.kind-text { border-color: #700299; }
@media (max-width: 720px) { .ai-builder { width: 100%; } }

/* ---------- connection sign-in ---------- */
fieldset.signin { border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px 12px; margin: 12px 0; }
fieldset.signin legend { padding: 0 6px; font-weight: 600; font-size: .9rem; }
.kind-pick.compact { display: flex; flex-wrap: wrap; gap: 6px; }
.kind-pick.compact .choice { padding: 6px 10px; }
fieldset.signin .f-none, fieldset.signin .f-login, fieldset.signin .f-token, fieldset.signin .f-oauth, fieldset.signin .f-signed { display: none; }
fieldset.signin:has(input[value="none"]:checked) .f-none,
fieldset.signin:has(input[value="login"]:checked) .f-login,
fieldset.signin:has(input[value="token"]:checked) .f-token,
fieldset.signin:has(input[value="oauth"]:checked) .f-oauth,
fieldset.signin:has(input[value="signed"]:checked) .f-signed { display: block; }

/* ---------- sign in with the company account ---------- */
.sso-button { display: flex; justify-content: center; width: 100%; margin: 6px 0 4px; }
.sso-or { text-align: center; margin: 10px 0 4px; }
