:root {
  --bg: #f7f7f8; --panel: #ffffff; --panel-2: #f2f2f4; --border: #e4e4e8; --border-strong: #d0d0d7;
  --text: #18181b; --muted: #6b6b76; --faint: #9a9aa4;
  --accent: #4f46e5; --accent-weak: #eef0ff; --accent-text: #fff;
  --danger: #dc2626; --ok: #16a34a;
  --radius: 8px; --shadow: 0 1px 2px rgba(0,0,0,.04), 0 4px 16px rgba(0,0,0,.06);
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111114; --panel: #18181c; --panel-2: #202026; --border: #2a2a31; --border-strong: #3a3a43;
    --text: #ececf0; --muted: #a0a0ab; --faint: #6e6e78;
    --accent: #7c74ff; --accent-weak: #25234a; --accent-text: #fff;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 6px 24px rgba(0,0,0,.35);
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--text); }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
code, .mono { font-family: var(--mono); font-size: 12.5px; }
h1 { font-size: 20px; margin: 0; font-weight: 650; letter-spacing: -.01em; }
h2 { font-size: 15px; margin: 0 0 12px; font-weight: 600; }
h3 { font-size: 13px; margin: 0 0 8px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
p { margin: 0 0 8px; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.small { font-size: 12px; }
.boot { padding: 40px; color: var(--muted); }

/* ---------- shell */
.shell { display: grid; grid-template-columns: 220px 1fr; height: 100vh; transition: grid-template-columns .15s ease; }
.shell.collapsed { grid-template-columns: 52px 1fr; }
.brand-row { display: flex; align-items: center; padding-right: 6px; }
.brand-row .brand { flex: 1; min-width: 0; }
.sidebar-toggle { color: var(--muted); font-size: 14px; padding: 2px 7px; }
.shell.collapsed .brand-row { flex-direction: column; padding: 0 0 4px; }
.shell.collapsed .brand { padding: 14px 0 6px; justify-content: center; }
.shell.collapsed .brand-name, .shell.collapsed .nav a .name, .shell.collapsed .sidebar-foot { display: none; }
.shell.collapsed .nav { padding: 4px 6px; }
.shell.collapsed .nav-section { font-size: 0; padding: 6px 4px; border-top: 1px solid var(--border); margin-top: 6px; }
.shell.collapsed .nav a { justify-content: center; padding: 7px 0; position: relative; }
.shell.collapsed .nav a .count { position: absolute; top: 1px; right: 0; font-size: 9px; padding: 0 4px; line-height: 14px; }
.sidebar { background: var(--panel); border-right: 1px solid var(--border); display: flex; flex-direction: column; min-height: 0; }
.brand { display: flex; align-items: center; gap: 10px; padding: 16px 16px 12px; font-weight: 700; font-size: 15px; }
.brand img { width: 22px; height: 22px; }
.nav { flex: 1; overflow: auto; padding: 4px 8px; }
.nav-section { padding: 14px 8px 6px; font-size: 11px; color: var(--faint); text-transform: uppercase; letter-spacing: .06em; font-weight: 600; }
.nav a { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 6px; color: var(--text); }
.nav a:hover { background: var(--panel-2); text-decoration: none; }
.nav a.active { background: var(--accent-weak); color: var(--accent); font-weight: 550; }
.nav a .icon { width: 18px; text-align: center; flex: none; }
.nav a .name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav a .count { font-size: 11px; background: var(--accent); color: var(--accent-text); border-radius: 10px; padding: 0 6px; font-weight: 600; }
.sidebar-foot { border-top: 1px solid var(--border); padding: 10px 16px; display: flex; justify-content: space-between; align-items: center; font-size: 13px; }
main { overflow: auto; min-width: 0; }
.page { padding: 18px 22px 40px; }
.page.narrow { max-width: 920px; }
.page-head { display: flex; align-items: flex-start; gap: 16px; margin-bottom: 18px; }
.page-head .title { flex: 1; min-width: 0; }
.page-head .title p { margin: 4px 0 0; color: var(--muted); }
.row-flex { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }

/* ---------- controls */
button, .btn { font: inherit; font-weight: 550; border: 1px solid var(--border-strong); background: var(--panel); color: var(--text); padding: 6px 12px; border-radius: 6px; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
button:hover, .btn:hover { background: var(--panel-2); text-decoration: none; }
button.primary, .btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
button.primary:hover { filter: brightness(1.08); }
button.danger { color: var(--danger); }
button.ghost { border-color: transparent; background: transparent; }
button.ghost:hover { background: var(--panel-2); }
button.sm { padding: 3px 8px; font-size: 12px; }
button:disabled { opacity: .5; cursor: default; }
input, select, textarea { font: inherit; color: var(--text); background: var(--panel); border: 1px solid var(--border-strong); border-radius: 6px; padding: 6px 9px; width: 100%; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
input[type=checkbox], input[type=radio] { width: auto; accent-color: var(--accent); }
textarea { resize: vertical; min-height: 64px; }
textarea.code, input.code { font-family: var(--mono); font-size: 12.5px; }
label.field { display: block; margin-bottom: 12px; }
label.field > span { display: block; font-size: 12px; font-weight: 600; color: var(--muted); margin-bottom: 4px; }
label.field > small { display: block; color: var(--faint); font-size: 12px; margin-top: 3px; }
label.check { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0 14px; }

.card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; }
.card + .card { margin-top: 16px; }
.card-head { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.card-head h2 { margin: 0; flex: 1; }

/* ---------- pills & chips */
.pill { display: inline-block; padding: 1px 8px; border-radius: 10px; font-size: 12px; font-weight: 550; white-space: nowrap; background: var(--panel-2); color: var(--muted); border: 1px solid var(--border); }
.pill-gray { background: #f1f1f3; color: #52525b; border-color: #e1e1e5; }
.pill-red { background: #fef2f2; color: #b91c1c; border-color: #fecaca; }
.pill-orange { background: #fff7ed; color: #c2410c; border-color: #fed7aa; }
.pill-amber { background: #fffbeb; color: #a16207; border-color: #fde68a; }
.pill-green { background: #f0fdf4; color: #15803d; border-color: #bbf7d0; }
.pill-teal { background: #f0fdfa; color: #0f766e; border-color: #99f6e4; }
.pill-blue { background: #eff6ff; color: #1d4ed8; border-color: #bfdbfe; }
.pill-purple { background: #faf5ff; color: #7e22ce; border-color: #e9d5ff; }
.pill-pink { background: #fdf2f8; color: #be185d; border-color: #fbcfe8; }
@media (prefers-color-scheme: dark) {
  .pill-gray { background: #27272a; color: #c4c4cc; border-color: #3f3f46; }
  .pill-red { background: #3b1414; color: #fca5a5; border-color: #5f1d1d; }
  .pill-orange { background: #3a1f0d; color: #fdba74; border-color: #5c3214; }
  .pill-amber { background: #3a2c0a; color: #fcd34d; border-color: #5c4510; }
  .pill-green { background: #0f2e1a; color: #86efac; border-color: #1a4a2b; }
  .pill-teal { background: #0c2e2a; color: #5eead4; border-color: #134e48; }
  .pill-blue { background: #102246; color: #93c5fd; border-color: #1e3a6e; }
  .pill-purple { background: #2a1440; color: #d8b4fe; border-color: #44216a; }
  .pill-pink { background: #3a1028; color: #f9a8d4; border-color: #5c1a40; }
}
.chip { display: inline-block; font-family: var(--mono); font-size: 11.5px; padding: 0 6px; border-radius: 4px; background: var(--panel-2); border: 1px solid var(--border); margin: 1px 3px 1px 0; white-space: nowrap; }
.badge { font-size: 11px; border-radius: 9px; padding: 0 6px; background: var(--panel-2); color: var(--muted); font-weight: 600; }
.badge.hot { background: var(--accent); color: var(--accent-text); }
.badge.warn { background: #f59e0b; color: #fff; }

/* ---------- tabs */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin-bottom: 14px; overflow-x: auto; }
.tabs a { padding: 8px 12px; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; display: inline-flex; gap: 6px; align-items: center; white-space: nowrap; font-weight: 550; }
.tabs a:hover { color: var(--text); text-decoration: none; }
.tabs a.active { color: var(--text); border-bottom-color: var(--accent); }

/* ---------- table */
.toolbar { display: flex; gap: 8px; align-items: center; margin-bottom: 10px; }
.toolbar input[type=search] { max-width: 320px; }
.table-wrap { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); overflow: auto; max-height: calc(100vh - 210px); }
table.data { border-collapse: collapse; width: 100%; font-size: 13px; }
table.data th { text-align: left; font-weight: 600; color: var(--muted); font-size: 12px; background: var(--panel-2); border-bottom: 1px solid var(--border); padding: 7px 10px; white-space: nowrap; position: sticky; top: 0; cursor: pointer; user-select: none; z-index: 2; }
table.data th.sorted { color: var(--text); }
table.data td { padding: 7px 10px; border-bottom: 1px solid var(--border); vertical-align: top; max-width: 460px; }
table.data tr:last-child td { border-bottom: 0; }
table.data tbody tr { cursor: pointer; }
table.data tbody tr:hover td { background: var(--panel-2); }
table.data tbody tr.flash td { animation: flash 1.2s ease-out; }
@keyframes flash { from { background: var(--accent-weak); } to { background: transparent; } }
td.num { text-align: right; font-variant-numeric: tabular-nums; }
td .clip { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
td.mono-cell { font-family: var(--mono); font-size: 12px; overflow-wrap: anywhere; }
.empty { padding: 40px; text-align: center; color: var(--muted); }
.empty h2 { color: var(--text); }
.load-more { text-align: center; padding: 10px; }

/* ---------- dashboard cards */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; }
.dcard { display: block; background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; color: var(--text); transition: border-color .15s, box-shadow .15s; }
.dcard:hover { border-color: var(--accent); box-shadow: var(--shadow); text-decoration: none; }
.dcard .top { display: flex; gap: 10px; align-items: center; margin-bottom: 6px; }
.dcard .icon { font-size: 20px; }
.dcard .nm { font-weight: 650; font-size: 15px; flex: 1; }
.dcard p { color: var(--muted); min-height: 20px; }
.qline { display: flex; align-items: center; gap: 8px; font-size: 12.5px; padding: 3px 0; }
.qline .ql { flex: 1; color: var(--muted); }
.dcard.new { display: flex; align-items: center; justify-content: center; border-style: dashed; color: var(--muted); min-height: 140px; font-weight: 550; }

/* template picker */
.tpls { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 10px; margin-bottom: 16px; }
.tpl { border: 1px solid var(--border-strong); border-radius: var(--radius); padding: 12px; cursor: pointer; background: var(--panel); }
.tpl:hover { border-color: var(--accent); }
.tpl.selected { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-weak); }
.tpl .t { font-weight: 650; margin-bottom: 3px; }
.tpl .d { color: var(--muted); font-size: 12.5px; }

/* ---------- drawer & modal */
.overlay { position: fixed; inset: 0; background: rgba(10,10,20,.35); z-index: 20; }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(max(600px, 42vw), 880px, 100vw); background: var(--panel); border-left: 1px solid var(--border); z-index: 21; display: flex; flex-direction: column; box-shadow: var(--shadow); }
.drawer-head { padding: 14px 18px; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 10px; }
.drawer-head .t { flex: 1; min-width: 0; font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.drawer-body { flex: 1; overflow: auto; padding: 16px 18px; }
.drawer-foot { padding: 12px 18px; border-top: 1px solid var(--border); display: flex; gap: 8px; }
.modal { position: fixed; z-index: 31; top: 6vh; left: 50%; transform: translateX(-50%); width: min(760px, 94vw); max-height: 88vh; display: flex; flex-direction: column; background: var(--panel); border-radius: 12px; box-shadow: var(--shadow); border: 1px solid var(--border); }
.modal-overlay { z-index: 30; }
.modal-head { padding: 16px 20px; border-bottom: 1px solid var(--border); display: flex; align-items: center; }
.modal-head h2 { margin: 0; flex: 1; }
.modal-body { padding: 18px 20px; overflow: auto; }
.modal-foot { padding: 12px 20px; border-top: 1px solid var(--border); display: flex; gap: 8px; justify-content: flex-end; }
.banner { padding: 10px 12px; border-radius: 6px; margin-bottom: 14px; font-size: 13px; border: 1px solid var(--border); background: var(--panel-2); }
.banner.info { background: var(--accent-weak); border-color: transparent; }
.banner.warn { background: #fffbeb; border-color: #fde68a; color: #92400e; }
@media (prefers-color-scheme: dark) { .banner.warn { background: #3a2c0a; border-color: #5c4510; color: #fcd34d; } }
.group-box { border: 1px solid var(--border); border-radius: 6px; padding: 12px 12px 0; margin-bottom: 12px; }
.group-box > .gl { font-size: 12px; font-weight: 650; margin-bottom: 8px; }
.links a { display: block; font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* activity */
.feed { list-style: none; margin: 0; padding: 0; }
.feed li { display: flex; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 13px; }
.feed li:last-child { border-bottom: 0; }
.feed .who { font-weight: 600; }
.feed .when { color: var(--faint); font-size: 12px; white-space: nowrap; }
.feed .what { flex: 1; min-width: 0; }
.feed .note { color: var(--muted); margin-top: 2px; white-space: pre-wrap; }
.feed .av { width: 22px; height: 22px; border-radius: 50%; flex: none; display: grid; place-items: center; font-size: 11px; font-weight: 700; color: #fff; background: #71717a; }
.feed .av.agent { background: var(--accent); }
.feed.clickable li { cursor: pointer; }
.feed.clickable li:hover { background: var(--panel-2); }

/* ---------- schema editor */
.fe { border: 1px solid var(--border); border-radius: 6px; margin-bottom: 6px; background: var(--panel); }
.fe-row { display: grid; grid-template-columns: 1.1fr 1.2fr 130px auto; gap: 6px; padding: 6px; align-items: center; }
.fe-row input, .fe-row select { padding: 4px 7px; }
.fe-actions { display: flex; gap: 2px; }
.fe-more { padding: 4px 10px 10px; border-top: 1px dashed var(--border); }
.fe-children { margin: 0 6px 6px 22px; }
.opt-row { display: grid; grid-template-columns: 1fr 110px auto; gap: 6px; margin-bottom: 4px; }
.cond-row { display: grid; grid-template-columns: 1.4fr 130px 1.2fr auto; gap: 6px; margin-bottom: 6px; }
.queue-card { border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; margin-bottom: 12px; }

/* ---------- snippets */
.snip { position: relative; }
.snip pre { padding-right: 96px !important; overflow-wrap: anywhere; word-break: normal; background: var(--panel-2); border: 1px solid var(--border); border-radius: 6px; padding: 10px 12px; margin: 0 0 12px; overflow: auto; font-family: var(--mono); font-size: 12px; white-space: pre-wrap; max-height: 260px; }
.snip button { position: absolute; top: 6px; right: 6px; }
.token { font-family: var(--mono); font-size: 13px; padding: 10px 12px; background: var(--panel-2); border: 1px dashed var(--accent); border-radius: 6px; word-break: break-all; }
.steps { counter-reset: step; }
.step { position: relative; padding-left: 34px; margin-bottom: 18px; }
.step::before { counter-increment: step; content: counter(step); position: absolute; left: 0; top: 0; width: 22px; height: 22px; border-radius: 50%; background: var(--accent); color: #fff; display: grid; place-items: center; font-size: 12px; font-weight: 700; }
.roles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 14px; }
.role { border: 1px solid var(--border-strong); border-radius: var(--radius); padding: 10px; cursor: pointer; }
.role.selected { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-weak); }
.role .t { font-weight: 650; }
.role .d { font-size: 12px; color: var(--muted); }
.instructions { white-space: pre-wrap; background: var(--panel-2); border-radius: 6px; padding: 10px 12px; font-size: 13px; margin-bottom: 12px; border: 1px solid var(--border); }
details > summary { cursor: pointer; color: var(--muted); font-size: 13px; margin-bottom: 8px; }

/* ---------- auth */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.auth .card { width: min(400px, 100%); padding: 28px; }
.auth h1 { margin-bottom: 4px; }
.auth p { color: var(--muted); margin-bottom: 18px; }

#toasts { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); z-index: 50; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast { background: #18181b; color: #fff; padding: 9px 14px; border-radius: 8px; box-shadow: var(--shadow); font-size: 13px; max-width: 560px; }
.toast.error { background: var(--danger); }

@media (max-width: 760px) {
  .shell, .shell.collapsed { grid-template-columns: 1fr; }
  .settings-grid { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .grid2, .grid3, .roles { grid-template-columns: 1fr; }
  .page { padding: 16px; }
}

/* column sizing */
table.data td.mono-cell { min-width: 220px; }
table.data td.text-cell { min-width: 160px; }
table.data td.long-cell { min-width: 260px; }

/* actions column: always visible on the right */
table.data .actions-col { position: sticky; right: 0; background: var(--panel); border-left: 1px solid var(--border); min-width: 150px; width: 1%; max-width: 380px; cursor: default; z-index: 1; }
table.data td.actions-col .act-btns { flex-wrap: nowrap; }
.more-btn { color: var(--muted); }
.menu-pop { position: fixed; z-index: 40; background: var(--panel); border: 1px solid var(--border-strong); border-radius: 8px; box-shadow: var(--shadow); padding: 4px; display: flex; flex-direction: column; min-width: 180px; }
.menu-item { border: 0; background: transparent; justify-content: flex-start; padding: 6px 10px; font-weight: 500; }
.menu-item:hover { background: var(--panel-2); }
table.data th.actions-col { background: var(--panel-2); z-index: 3; }
table.data tbody tr:hover td.actions-col { background: var(--panel-2); }
table.data tr.deciding td:first-child { box-shadow: inset 3px 0 0 #f59e0b; }
.act-btns, .decide-btns { gap: 4px; }
.act-btns button, .decide-btns button { padding: 2px 7px; }
.kind-ico { font-size: 11px; opacity: .75; }
.kind-ico.big { font-size: 16px; opacity: 1; width: 22px; text-align: center; }
.decide-box { min-width: 260px; margin-bottom: 6px; padding: 5px 6px; border-radius: 6px; background: #fffbeb; border: 1px solid #fde68a; }
.decide-q { font-size: 12px; margin-bottom: 4px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.decide-mark { display: inline-grid; place-items: center; width: 16px; height: 16px; border-radius: 50%; background: #f59e0b; color: #fff; font-size: 11px; font-weight: 800; margin-right: 5px; flex: none; }
.badge.decide { background: #f59e0b; color: #fff; }
@media (prefers-color-scheme: dark) { .decide-box { background: #2e2408; border-color: #5c4510; } }
button.danger-fill { background: var(--danger); border-color: var(--danger); }

/* drawer: decisions, actions, jobs */
.decision { border: 1px solid #fde68a; background: #fffbeb; border-radius: var(--radius); padding: 12px; margin-bottom: 14px; }
@media (prefers-color-scheme: dark) { .decision { background: #2a2108; border-color: #5c4510; } }
.decision-head { display: flex; align-items: center; gap: 4px; margin-bottom: 6px; }
.decision-q { white-space: pre-wrap; margin-bottom: 10px; }
.choice-list { display: grid; gap: 6px; }
.choice { display: flex; gap: 10px; align-items: center; background: var(--panel); border: 1px solid var(--border); border-radius: 6px; padding: 8px 10px; }
.choice.rec { border-color: var(--accent); }
.choice-main { flex: 1; min-width: 0; }
.choice-label { font-weight: 600; }
.choice-desc { font-size: 13px; color: var(--muted); white-space: pre-wrap; margin: 2px 0; }
.drawer-actions { margin-bottom: 14px; }
.jobs { margin-bottom: 14px; }
.job { display: flex; gap: 10px; align-items: flex-start; padding: 6px 0; border-bottom: 1px solid var(--border); }
.job:last-child { border-bottom: 0; }
.job-main { flex: 1; min-width: 0; font-size: 13px; }
.job .note { color: var(--muted); white-space: pre-wrap; margin-top: 2px; }

/* settings */
.settings-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; align-items: start; }
@media (max-width: 1150px) { .settings-grid { grid-template-columns: 1fr; } }
.settings-grid .card + .card { margin-top: 0; }
/* A card that stretches to its row's height (e.g. Methodology beside General); its textarea takes the extra space. */
.settings-grid .fill-card { align-self: stretch; display: flex; flex-direction: column; }
.settings-grid .fill-card > textarea { flex: 1 1 auto; min-height: 140px; resize: vertical; }
.settings-grid .span2 { grid-column: 1 / -1; }
.settings-grid .stack { display: grid; gap: 16px; align-content: start; min-width: 0; }
.settings-grid .stack .card + .card { margin-top: 0; }
.action-list { display: grid; gap: 6px; }
.action-item { display: flex; gap: 10px; align-items: center; border: 1px solid var(--border); border-radius: 6px; padding: 8px 10px; cursor: pointer; }
.action-item:hover { border-color: var(--accent); }
.ai-main { flex: 1; min-width: 0; }
.ai-main .faint { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kv-row { display: grid; grid-template-columns: 1fr 1.6fr auto; gap: 6px; margin-bottom: 6px; }
.param-row { display: grid; grid-template-columns: 120px 1fr 110px 1fr auto auto; gap: 6px; margin-bottom: 6px; align-items: center; }
.grid-url { display: grid; grid-template-columns: 110px 1fr; gap: 0 10px; }
.modal.wide { width: min(980px, 96vw); }
.ph-help { margin-bottom: 12px; }
.ph-help code.chip { cursor: pointer; }

/* tutorials */
article.md { padding: 26px 30px; line-height: 1.6; }
article.md h1 { font-size: 24px; margin-bottom: 12px; }
article.md h2.md-h { font-size: 17px; margin: 28px 0 10px; padding-top: 14px; border-top: 1px solid var(--border); }
article.md h3.md-h { font-size: 14px; margin: 18px 0 8px; text-transform: none; letter-spacing: 0; color: var(--text); }
article.md p, article.md li { font-size: 14px; }
article.md ul, article.md ol { padding-left: 22px; margin: 0 0 12px; }
article.md li { margin-bottom: 4px; }
article.md code { background: var(--panel-2); border: 1px solid var(--border); border-radius: 4px; padding: 0 4px; }
article.md .snip pre code, article.md .snip pre { font-size: 12.5px; }
article.md .banner { margin: 12px 0; }
article.md .snip pre { max-height: 560px; }

.tool-switch { gap: 6px; }

.warn-text { color: #d97706; }

/* ---------- overview charts (palette validated for both surfaces; see the dataviz method) */
.viz-card, .viz-preview, .viz-empty-card {
  --s1: #2a78d6; --s2: #eb6834; --s3: #1baf7a; --s4: #eda100; --s5: #e87ba4; --s6: #008300; --viz-other: #9a9aa4;
  --viz-ink: #0b0b0b; --viz-ink-2: #52514e; --viz-muted: #898781; --viz-grid: #e1e0d9; --viz-axis: #c3c2b7;
}
@media (prefers-color-scheme: dark) {
  .viz-card, .viz-preview, .viz-empty-card {
    --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500; --s5: #d55181; --s6: #0ca30c; --viz-other: #6e6e78;
    --viz-ink: #f0efec; --viz-ink-2: #c3c2b7; --viz-muted: #898781; --viz-grid: #2c2c2a; --viz-axis: #383835;
  }
}
.section-head { display: flex; align-items: center; gap: 8px; margin: 4px 0 10px; }
.section-head h2 { margin: 0; }
.charts-section { margin-bottom: 22px; }
.viz-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 14px; grid-auto-flow: dense; }
.viz-grid .card + .card { margin-top: 0; }
.viz-card { padding: 14px 16px; position: relative; min-width: 0; }
.viz-card.wide { grid-column: span 2; }
@media (max-width: 900px) { .viz-card.wide { grid-column: auto; } }
.viz-head { display: flex; align-items: baseline; gap: 8px; margin-bottom: 8px; }
.viz-title { font-weight: 600; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.viz-src { white-space: nowrap; }
.viz-body { position: relative; min-height: 60px; }
.viz-number { font-size: 34px; font-weight: 650; letter-spacing: -.02em; font-variant-numeric: tabular-nums; color: var(--viz-ink); line-height: 1.1; }
.viz-bars { display: grid; gap: 4px; }
.viz-bar-row { display: grid; grid-template-columns: minmax(70px, 34%) 1fr auto; gap: 8px; align-items: center; font-size: 12.5px; outline: none; border-radius: 4px; }
.viz-bar-row:focus-visible { box-shadow: 0 0 0 2px var(--accent); }
.viz-bar-l { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--viz-ink-2); }
.viz-bar-track { height: 14px; display: flex; align-items: center; }
.viz-bar { height: 12px; background: var(--s1); border-radius: 0 4px 4px 0; }
.viz-bar-row:hover .viz-bar { filter: brightness(1.1); }
.viz-bar-v { font-variant-numeric: tabular-nums; color: var(--viz-ink-2); min-width: 2ch; text-align: right; }
.viz-svg { display: block; width: 100%; height: auto; overflow: visible; }
.viz-svg .viz-gl { stroke: var(--viz-grid); stroke-width: 1; }
.viz-svg .viz-axis { stroke: var(--viz-axis); stroke-width: 1; }
.viz-svg .viz-tick { fill: var(--viz-muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.viz-svg .viz-dlabel { fill: var(--viz-ink-2); font-size: 11px; }
.viz-svg .viz-line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.viz-svg .viz-hair { stroke: var(--viz-axis); stroke-width: 1; }
.viz-svg .viz-dot { stroke: var(--panel); stroke-width: 2; }
.viz-legend { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 12px; color: var(--viz-ink-2); margin-bottom: 4px; }
.viz-legend > span { display: inline-flex; align-items: center; gap: 5px; }
.viz-sw { display: inline-block; width: 10px; height: 10px; border-radius: 2px; flex: none; }
.viz-tip { position: absolute; z-index: 5; pointer-events: none; background: var(--panel); border: 1px solid var(--border-strong); border-radius: 6px; box-shadow: var(--shadow); padding: 6px 8px; font-size: 12px; min-width: 110px; display: none; }
.viz-tip-h { color: var(--viz-muted); margin-bottom: 3px; }
.viz-tip-row { display: flex; align-items: center; gap: 5px; white-space: nowrap; }
.viz-tip-row b { font-variant-numeric: tabular-nums; color: var(--viz-ink); }
.viz-tip-l { color: var(--viz-ink-2); }
.viz-empty { color: var(--muted); font-size: 13px; padding: 18px 0; text-align: center; }
.viz-empty-card { text-align: center; padding: 26px; color: var(--muted); }
.viz-table-wrap { margin-top: 8px; max-height: 220px; overflow: auto; }
.viz-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.viz-table th, .viz-table td { text-align: left; padding: 3px 6px; border-bottom: 1px solid var(--border); font-variant-numeric: tabular-nums; }
.viz-preview { border: 1px dashed var(--border-strong); border-radius: var(--radius); padding: 12px; min-height: 120px; position: relative; }

/* ---------- agents */
.agent-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(520px, 1fr)); gap: 12px; align-items: start; }
.agent-card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; min-width: 0; }
.ac-head { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.ac-name { font-size: 14.5px; }
.ac-perms { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; }
.ac-dash + .ac-dash::before { content: '· '; color: var(--faint); }
.runner-settings { margin-top: 10px; padding-top: 10px; border-top: 1px dashed var(--border); }
.rs-meta { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-bottom: 6px; }
.rs-controls { display: grid; grid-template-columns: 1.4fr 1fr 1.3fr auto; gap: 8px; align-items: end; }
.rs-controls label.field { margin: 0; }
.rs-eff td { display: block; padding: 0; border: 0; font-size: 11.5px; }
.scope-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px; }
.scope { display: flex; gap: 8px; align-items: flex-start; border: 1px solid var(--border); border-radius: 6px; padding: 7px 9px; cursor: pointer; }
.scope.on { border-color: var(--accent); background: var(--accent-weak); }
.scope span { display: flex; flex-direction: column; }
.dash-checks { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 4px 12px; max-height: 220px; overflow: auto; }
@media (max-width: 760px) { .agent-list, .scope-grid, .rs-controls { grid-template-columns: 1fr; } }

/* ---------- action results */
article.md.result-md { padding: 0; line-height: 1.55; }
article.md.result-md > :first-child { margin-top: 0; }
article.md.result-md h2.md-h { border-top: 0; padding-top: 0; margin-top: 16px; }
.job-wait { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; margin-bottom: 12px; }
.spinner { width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--border-strong); border-top-color: var(--accent); animation: spin .8s linear infinite; flex: none; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 2.4s; } }
.toast { display: flex; align-items: center; gap: 10px; }
.toast-btn { background: #fff; color: #18181b; border: 0; margin-left: auto; }
.job-answer { margin: 4px 0; }
.job-answer summary { cursor: pointer; color: var(--accent); font-size: 12.5px; }

/* ---------- selection & dashboard actions */
.action-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: -4px 0 10px; padding: 7px 10px; background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); }
.action-bar .sel-count { font-weight: 600; font-size: 13px; }
.action-bar .bar-sep { width: 1px; align-self: stretch; background: var(--border); margin: 0 4px; }
.action-bar .bar-sep:first-child { display: none; }
table.data .sel-col { width: 30px; padding-left: 10px; padding-right: 0; cursor: default; }
table.data .sel-col input { cursor: pointer; margin: 0; }
table.data th.sel-col { position: sticky; left: 0; }
table.data tr.selected td { background: var(--accent-weak); }
.jobs-result { display: grid; gap: 10px; }
.jr-item { border: 1px solid var(--border); border-radius: 6px; padding: 10px 12px; }
.jr-head { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }

/* ---------- on/off switch */
.switch { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; user-select: none; font-size: 12.5px; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch .sw-track { width: 30px; height: 17px; border-radius: 999px; background: var(--border-strong); position: relative; transition: background .15s; flex: none; }
.switch .sw-track::after { content: ''; position: absolute; top: 2px; left: 2px; width: 13px; height: 13px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.25); transition: transform .15s; }
.switch input:checked + .sw-track { background: #16a34a; }
.switch input:checked + .sw-track::after { transform: translateX(13px); }
.switch input:focus-visible + .sw-track { box-shadow: 0 0 0 2px var(--accent); }
.switch.locked { cursor: not-allowed; opacity: .6; }
.switch .sw-text { font-weight: 600; }
.agent-card.off { opacity: .72; }
.agent-card.off .ac-name::after { content: ' · off'; color: var(--muted); font-weight: 500; }

/* ---------- rendered markdown in long-text cells, their hover popover, and the row dialog */
td .md-clip code { font-size: 11.5px; background: var(--panel-2); border-radius: 3px; padding: 0 3px; }
td .md-clip a { overflow-wrap: anywhere; }
.md-pop { position: fixed; z-index: 60; display: none; width: max-content; max-width: min(680px, calc(100vw - 16px)); max-height: min(60vh, 520px); overflow: auto;
  background: var(--panel); color: var(--text); border: 1px solid var(--border-strong); border-radius: var(--radius); box-shadow: var(--shadow); cursor: auto; }
.md-pop article.md, .md-field article.md { padding: 12px 16px; line-height: 1.5; overflow-wrap: anywhere; }
.md-pop article.md p, .md-pop article.md li, .md-field article.md p, .md-field article.md li { font-size: 13px; }
.md-pop article.md p, .md-field article.md p { margin: 0 0 8px; }
.md-pop article.md > :last-child, .md-field article.md > :last-child { margin-bottom: 0; }
.md-pop article.md ul, .md-pop article.md ol, .md-field article.md ul, .md-field article.md ol { margin-bottom: 8px; }
.md-field-box { position: relative; }
.md-field { background: var(--panel-2); border: 1px solid var(--border); border-radius: 6px; max-height: 360px; overflow: auto; }
.md-field-box .md-edit { position: absolute; top: 6px; right: 6px; z-index: 1; background: var(--panel); border-color: var(--border); }
.md-field article.md { padding-right: 64px; }

/* ---------- schedules and hosted agents */
.sched-summary { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; }
.link-btn { background: none; border: 0; padding: 0; color: var(--accent); cursor: pointer; font: inherit; font-size: 12px; }
.link-btn:hover { text-decoration: underline; }
.seg { display: inline-flex; flex-wrap: wrap; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; margin-bottom: 12px; }
.seg button { border: 0; border-radius: 0; background: transparent; padding: 6px 12px; font-size: 13px; }
.seg button + button { border-left: 1px solid var(--border); }
.seg button.on { background: var(--accent-weak); color: var(--accent); font-weight: 600; }
.sched-body { margin-bottom: 12px; }
.sched-body select { width: auto; }
.day-picker .sep { width: 1px; height: 22px; background: var(--border); margin: 0 4px; }
.day-picker .day { min-width: 44px; padding: 4px 8px; font-size: 12.5px; border-radius: 6px; }
.day-picker .day.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.time-chip { display: inline-flex; align-items: center; gap: 2px; }
.time-chip input { width: auto; }
.sched-preview { padding: 10px 12px; border-radius: 8px; background: var(--panel-2); border: 1px solid var(--border); }
.sched-preview .mono { font-family: var(--mono); margin-top: 2px; }
.error-text { color: var(--danger, #b91c1c); }

/* Confirmation text of an action, rendered as markdown (e.g. the reply about to be posted). */
.banner.confirm-md article.md { padding: 0; font-size: 13px; line-height: 1.5; overflow-wrap: anywhere; }
.banner.confirm-md article.md p { margin: 0 0 8px; font-size: 13px; }
.banner.confirm-md article.md > :last-child { margin-bottom: 0; }
.banner.confirm-md .md-quote { margin: 6px 0 0; max-height: 320px; overflow: auto; color: var(--text); }

/* ---------- hosted agents: MCP servers & credentials */
.hosted-lib { gap: 0 24px; }
.lib-list { display: grid; gap: 6px; margin-bottom: 8px; }
.lib-item { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--panel-2); }
.lib-item .spacer, .row-flex .spacer { flex: 1; }
.chip-btn { font-family: var(--mono); font-size: 11.5px; }
