/* The portal's look, from the prototype docs/portal-mix-2-workbench.html.
   The top bar and status bar stay navy in both themes. Light or dark
   follows the browser until the top-bar switch is used (theme.js). */
@font-face { font-family: "Outfit"; font-weight: 300 600; font-display: swap; src: url("fonts/outfit-latin.woff2") format("woff2"); }
@font-face { font-family: "JetBrains Mono"; font-weight: 400 500; font-display: swap; src: url("fonts/jetbrains-mono-latin.woff2") format("woff2"); }

:root {
  --bg: #ffffff; --panel: #ffffff; --well: #f4f5f1; --band: #f4f6f1; --hover: #eef1e8; --sel: #eef4d8;
  --ink: #0d1520; --muted: #5b6672; --faint: #8a949d; --rule: #e2e5df; --line: #c4cacf;
  --accent: #b9d334; --accent-ink: #4f6a00; --accent-tint: #eff5d6; --on-accent: #0d1520;
  --blue: #1f5f93; --blue-tint: #e6eef6;
  --warn: #9a5800; --warn-tint: #fbf1e2; --crit: #b3261e; --crit-tint: #fbebe9;
  --nav-bg: #0a0f16; --nav-ink: #e7ebef; --nav-muted: #8d99a6; --nav-rule: #222c38; --nav-hover: #141c26;
  --scrim: rgba(7, 11, 17, .45);
  --shadow: 0 16px 48px rgba(13, 21, 32, .18), 0 0 0 1px rgba(13, 21, 32, .08);
  --r: 3px;
  --sans: "Outfit", "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, Arial, sans-serif;
  --mono: "JetBrains Mono", "Cascadia Code", "SF Mono", ui-monospace, Menlo, Consolas, monospace;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #0b0f14; --panel: #0f141b; --well: #0b0f14; --band: #131a22; --hover: #161e28; --sel: #18210f;
  --ink: #e2e7ec; --muted: #8a96a3; --faint: #5d6976; --rule: #1e2731; --line: #334050;
  --accent-ink: #c4dc4c; --accent-tint: #1c2513; --on-accent: #0b0f14;
  --blue: #6aa6d6; --blue-tint: #132637;
  --warn: #e3a256; --warn-tint: #2a1f12; --crit: #ef7a6e; --crit-tint: #2e1716;
  --nav-bg: #070a0e; --nav-rule: #1a222c; --nav-hover: #121a23;
  --scrim: rgba(0, 0, 0, .6); --shadow: 0 16px 48px rgba(0, 0, 0, .6), 0 0 0 1px #334050;
  color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b0f14; --panel: #0f141b; --well: #0b0f14; --band: #131a22; --hover: #161e28; --sel: #18210f;
    --ink: #e2e7ec; --muted: #8a96a3; --faint: #5d6976; --rule: #1e2731; --line: #334050;
    --accent-ink: #c4dc4c; --accent-tint: #1c2513; --on-accent: #0b0f14;
    --blue: #6aa6d6; --blue-tint: #132637;
    --warn: #e3a256; --warn-tint: #2a1f12; --crit: #ef7a6e; --crit-tint: #2e1716;
    --nav-bg: #070a0e; --nav-rule: #1a222c; --nav-hover: #121a23;
    --scrim: rgba(0, 0, 0, .6); --shadow: 0 16px 48px rgba(0, 0, 0, .6), 0 0 0 1px #334050;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--ink); font: 400 13px/1.45 var(--sans); -webkit-font-smoothing: antialiased; overflow: hidden; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: inherit; text-decoration: none; }
b { font-weight: 500; }
.mono, code, kbd { font-family: var(--mono); }
.muted { color: var(--muted); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

/* ---------- Shell ---------- */
.shell { display: grid; grid-template-rows: 48px minmax(0, 1fr) 26px; grid-template-areas: "top" "work" "status"; height: 100vh; height: 100dvh; }
.shell > * { min-width: 0; min-height: 0; }

/* ---------- Top bar ---------- */
header.top { grid-area: top; background: var(--nav-bg); color: var(--nav-ink); display: flex; align-items: center; gap: 10px; padding: 0 14px; border-bottom: 1px solid var(--nav-rule); }
.brand { display: flex; align-items: center; gap: 9px; font-weight: 500; font-size: 14px; letter-spacing: .01em; white-space: nowrap; }
.brand svg { fill: var(--accent); flex: none; }
.brand small { color: var(--nav-muted); font-weight: 300; font-size: 13px; }
.views { display: flex; align-self: stretch; margin-left: 10px; }
.views a { border-top: 2px solid transparent; border-bottom: 2px solid transparent; color: var(--nav-muted); padding: 0 11px; font-size: 13.5px; display: inline-flex; align-items: center; white-space: nowrap; }
.views a:hover { color: var(--nav-ink); }
.views a.on { color: var(--nav-ink); border-bottom-color: var(--accent); }
.spacer { flex: 1; }
.user { display: inline-flex; align-items: center; gap: 8px; height: 30px; border: 1px solid var(--nav-rule); border-radius: var(--r); padding: 0 10px; white-space: nowrap; color: var(--nav-muted); }
.user b { color: var(--nav-ink); }
.tctl { height: 30px; border: 1px solid var(--nav-rule); background: transparent; color: var(--nav-ink); border-radius: var(--r); padding: 0 10px; display: inline-flex; align-items: center; gap: 6px; cursor: pointer; white-space: nowrap; }
.tctl:hover { border-color: var(--nav-muted); }
.tctl.icon { width: 30px; padding: 0; justify-content: center; }

/* ---------- Work area: the agent list and the selected agent ---------- */
main.work { grid-area: work; display: grid; grid-template-columns: 300px minmax(0, 1fr); min-height: 0; }
.pane { min-height: 0; min-width: 0; overflow: auto; }
#p-list { background: var(--well); border-right: 1px solid var(--rule); }
#p-detail { background: var(--panel); }
.mswitch { display: none; }

/* Agent mini-cards */
.lhead { position: sticky; top: 0; z-index: 2; display: flex; align-items: center; gap: 6px; padding: 10px 12px; background: var(--well); border-bottom: 1px solid var(--rule); }
.lhead input { flex: 1; min-width: 0; height: 30px; border: 1px solid var(--line); background: var(--panel); border-radius: var(--r); padding: 0 9px; }
.group { padding: 14px 14px 6px; font-size: 10.5px; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); font-weight: 500; display: flex; justify-content: space-between; }
.cards { display: flex; flex-direction: column; gap: 8px; padding: 0 12px; }
.groups { padding-bottom: 16px; }
.mc { display: grid; grid-template-columns: 34px minmax(0, 1fr); gap: 1px 10px; align-items: center; width: 100%; padding: 10px 12px 11px; background: var(--panel); border: 1px solid var(--rule); border-top: 3px solid var(--rule); border-radius: var(--r); }
.mc > span { display: block; min-width: 0; }
.mc > .tile { display: grid; }
.mc:hover { border-left-color: var(--line); border-right-color: var(--line); border-bottom-color: var(--line); }
.mc.running { border-top-color: var(--accent); }
.mc.paused, .mc.not-ready { border-top-color: var(--warn); }
.mc.not-deployed { border-top-style: dashed; border-top-color: var(--line); }
.mc.on { background: var(--sel); box-shadow: 0 0 0 1px var(--ink); }
.mc .tile { width: 34px; height: 34px; font-size: 12px; grid-row: 1 / span 2; }
.mc .nm { display: flex !important; align-items: baseline; gap: 8px; }
.mc .nm b { font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mc .own { color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mc .bar { grid-column: 1 / -1; margin-top: 10px; }
.mc .mfoot { grid-column: 1 / -1; display: flex !important; justify-content: space-between; gap: 8px; font-family: var(--mono); font-size: 11px; color: var(--muted); margin-top: 6px; }
.st { margin-left: auto; font-family: var(--mono); font-size: 10px; text-transform: uppercase; letter-spacing: .05em; white-space: nowrap; color: var(--muted); }
.st.running { color: var(--accent-ink); } .st.paused, .st.not-ready { color: var(--warn); } .st.not-deployed { color: var(--crit); }
.empty { padding: 18px 28px; color: var(--muted); }
.groups .empty { padding: 14px; }

.tile { display: grid; place-items: center; flex: none; background: var(--nav-bg); color: var(--accent); border: 1px solid var(--nav-rule); border-radius: var(--r); font-weight: 500; letter-spacing: .02em; }
.mc.not-deployed .tile, .hero.not-deployed .tile { color: var(--nav-muted); }

.bar { display: block; height: 4px; background: var(--rule); position: relative; }
.bar i { position: absolute; inset: 0 auto 0 0; background: var(--accent); }
.bar.hot i { background: var(--warn); }
.bar .pace { position: absolute; top: -4px; width: 1px; height: 13px; background: var(--muted); }

.status { display: inline-flex; align-items: center; gap: 7px; white-space: nowrap; color: var(--ink); }
.status::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--line); flex: none; }
.status.running::before { background: var(--accent); box-shadow: 0 0 0 3px var(--accent-tint); }
.status.paused::before, .status.not-ready::before { background: var(--warn); }
.status.not-deployed::before { background: transparent; border: 1px dashed var(--muted); }

/* ---------- Agent header ---------- */
.hero { padding: 22px 28px 20px; display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 14px 24px; border-bottom: 1px solid var(--rule); }
.h-id { display: flex; gap: 16px; align-items: flex-start; min-width: 0; }
.h-id .tile { width: 52px; height: 52px; font-size: 17px; }
.eyebrow { font-family: var(--mono); font-size: 11px; color: var(--faint); overflow-wrap: anywhere; }
.hero h1 { margin: 2px 0 6px; font-weight: 300; font-size: 34px; line-height: 1.1; letter-spacing: -.01em; }
.sline { display: flex; flex-wrap: wrap; gap: 4px 14px; color: var(--muted); font-size: 13px; align-items: center; }
.h-row { grid-column: 1 / -1; display: grid; grid-template-columns: minmax(240px, 420px) minmax(0, 1fr); gap: 32px; align-items: end; }
.spend .num { display: flex; align-items: baseline; gap: 8px; }
.spend .num b { font-weight: 300; font-size: 36px; line-height: 1; }
.spend .num span { color: var(--muted); font-size: 14px; }
.spend .num em { margin-left: auto; font-style: normal; font-family: var(--mono); font-size: 11px; color: var(--muted); }
.spend .bar { margin-top: 12px; height: 5px; }
.bl { display: flex; justify-content: space-between; gap: 10px; font-family: var(--mono); font-size: 11px; color: var(--muted); margin-top: 7px; }
.hkv { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); border-left: 1px solid var(--rule); }
.hkv > div { padding: 0 16px; border-right: 1px solid var(--rule); min-width: 0; }
.hkv > div:last-child { border-right: 0; }
.hkv label { display: block; font-size: 10.5px; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); }
.hkv .v { font-size: 20px; font-weight: 300; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.banner { padding: 9px 12px; border-left: 3px solid var(--warn); background: var(--warn-tint); font-size: 13px; }
.banner.crit { border-left-color: var(--crit); background: var(--crit-tint); }
.banner.info { border-left-color: var(--blue); background: var(--blue-tint); }
.tb > .banner { margin: 14px 28px 0; }
.hero > .banner { grid-column: 1 / -1; }
.sline .mine { color: var(--accent-ink); }
.h-acts { display: flex; flex-direction: column; align-items: flex-end; gap: 8px; }
.h-acts .why { font-size: 12px; color: var(--muted); max-width: 260px; text-align: right; }

/* Pause and resume */
.kill { display: inline-flex; border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; flex: none; background: var(--panel); }
.kill a, .kill button { border: 0; background: transparent; padding: 0 12px; height: 36px; display: inline-flex; align-items: center; gap: 7px; font-size: 14px; color: var(--ink); white-space: nowrap; }
.kill a:hover { background: var(--band); }
.kill .go { color: var(--accent-ink); }
.kill button:disabled { color: var(--muted); opacity: .5; cursor: not-allowed; }
.scrim { position: fixed; inset: 0; background: var(--scrim); z-index: 50; display: flex; align-items: flex-start; justify-content: center; padding: 11vh 16px 16px; }
.dlg { width: min(560px, 100%); background: var(--panel); border: 1px solid var(--line); box-shadow: var(--shadow); border-radius: var(--r); max-height: 80vh; display: flex; flex-direction: column; }
.dlg h2 { margin: 0; padding: 16px 18px 12px; font-size: 19px; font-weight: 400; }
.dlg .body { padding: 0 18px 14px; overflow: auto; }
.dlg .foot { padding: 10px 18px; border-top: 1px solid var(--rule); display: flex; justify-content: flex-end; gap: 8px; background: var(--band); flex-wrap: wrap; }
.dlg p { margin: 0 0 10px; color: var(--muted); }
.dlg label.f { display: block; font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 12px 0 5px; }
.dlg textarea { width: 100%; min-height: 60px; resize: vertical; padding: 7px 9px; border: 1px solid var(--line); background: var(--bg); border-radius: var(--r); }
.steps { list-style: none; padding: 0; margin: 0; font-size: 13px; }
.steps li { padding: 4px 0 4px 22px; position: relative; }
.steps li::before { content: ""; position: absolute; left: 2px; top: 10px; width: 8px; height: 8px; border: 1px solid var(--line); border-radius: 50%; }

/* ---------- Tabs ---------- */
.tabs { position: sticky; top: 0; z-index: 3; display: flex; align-items: stretch; padding: 0 28px; background: var(--panel); border-bottom: 1px solid var(--rule); }
.tabs a { padding: 11px 0 10px; margin-right: 26px; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; font-size: 14px; display: inline-flex; gap: 8px; align-items: baseline; white-space: nowrap; }
.tabs a:hover { color: var(--ink); }
.tabs a.on { color: var(--ink); border-bottom-color: var(--accent); }
.tabs .c { font-family: var(--mono); font-size: 11px; color: var(--faint); }
.tabs .r { margin-left: auto; align-self: center; font-size: 12px; color: var(--muted); white-space: nowrap; }
.tb { padding-bottom: 28px; }

.sech { display: flex; align-items: center; gap: 10px; padding: 14px 28px 8px; font-size: 10.5px; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); font-weight: 500; }
.sech .r { margin-left: auto; text-transform: none; letter-spacing: 0; font-weight: 400; font-size: 12px; display: flex; gap: 8px; align-items: center; }
.sech.wrap { flex-wrap: wrap; row-gap: 6px; }
.sech.gap { padding-top: 22px; }
#trace { scroll-margin-top: 44px; }
.note { padding: 8px 28px 0; color: var(--muted); font-size: 12px; }
.note .cm { margin: 0 3px 0 6px; vertical-align: -1px; }
.note .cm:first-child { margin-left: 0; }
.empty-note { padding: 8px 28px 0; color: var(--muted); font-size: 13px; }
.problem { padding: 8px 28px 0; color: var(--crit); font-size: 13px; }

table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-weight: 500; font-size: 10px; text-transform: uppercase; letter-spacing: .08em; color: var(--faint); padding: 5px 8px; border-bottom: 1px solid var(--rule); white-space: nowrap; }
td { padding: 7px 8px; border-bottom: 1px solid var(--rule); vertical-align: middle; }
th:first-child, td:first-child { padding-left: 28px; }
th:last-child, td:last-child { padding-right: 28px; }
td.m { font-family: var(--mono); font-size: 12px; }
.tools td.c, .tools th.c { text-align: center; width: 34px; padding-left: 2px; padding-right: 2px; }
.tools .tn { font-family: var(--mono); font-size: 12px; }
.tools .td { display: block; font-size: 12px; color: var(--muted); margin-top: 1px; }
.tools .src { color: var(--muted); font-size: 12px; white-space: nowrap; }
.cm { display: inline-block; width: 9px; height: 9px; }
.cm.read { background: var(--ink); opacity: .55; }
.cm.output { background: var(--blue); }
.cm.write { background: var(--warn); }
.cm.local { border: 1px dashed var(--muted); }
.cm.none { width: 9px; height: 1px; background: var(--rule); vertical-align: middle; }

/* Egress */
.modes { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; margin: 0 28px; }
.modes > span { padding: 9px 12px; border-right: 1px solid var(--line); display: block; font-size: 13.5px; color: var(--muted); }
.modes > span:last-child { border-right: 0; }
.modes small { display: block; color: var(--muted); font-size: 12px; line-height: 1.35; margin-top: 1px; }
.modes > span.on { background: var(--ink); color: var(--bg); }
.modes > span.on small { color: inherit; opacity: .7; }
.hosts td.h { font-family: var(--mono); font-size: 12px; overflow-wrap: anywhere; }
.hosts td.n { text-align: right; font-family: var(--mono); font-size: 12px; width: 70px; }
.hbar { width: 34%; }
.hbar i { display: block; height: 4px; background: var(--accent); }
.blocked td { font-size: 12px; }
.blocked td.t { font-family: var(--mono); font-size: 11.5px; color: var(--muted); width: 150px; white-space: nowrap; }
.blocked td.u { font-family: var(--mono); color: var(--crit); overflow-wrap: anywhere; }
.blocked td.w { color: var(--muted); }

/* Budget */
.bgrid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr); gap: 36px; padding: 4px 28px 0; }
.lbl { font-size: 10.5px; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); font-weight: 500; margin: 10px 0 8px; }
.bnum { display: flex; align-items: baseline; gap: 8px; }
.bnum b { font-weight: 300; font-size: 30px; line-height: 1; }
.bnum span { color: var(--muted); font-size: 13px; }
.bar.big { height: 6px; margin-top: 12px; }
.chart { display: block; width: 100%; height: auto; color: var(--muted); }
.chart .b { fill: var(--accent); opacity: .75; }
.chart .b.today { fill: var(--accent-ink); opacity: 1; }
.chart .b.hot { fill: var(--warn); opacity: .8; }
.chart .cap { stroke: var(--muted); stroke-dasharray: 4 4; }
.chart .base { stroke: currentColor; opacity: .35; }
.chart text { fill: currentColor; font-family: var(--sans); font-size: 11px; }

.idgrid { display: grid; grid-template-columns: 150px minmax(0, 1fr); gap: 6px 14px; padding: 4px 28px 0; margin: 0; font-size: 13px; }
.idgrid dt { color: var(--muted); }
.idgrid dd { margin: 0; font-family: var(--mono); font-size: 12px; overflow-wrap: anywhere; padding-top: 1px; }
.bgrid .idgrid { padding: 16px 0 0; grid-template-columns: 120px minmax(0, 1fr); }

/* ---------- Buttons and filters ---------- */
.sbtn { height: 22px; padding: 0 8px; border: 1px solid var(--line); background: var(--panel); font-size: 11.5px; border-radius: 2px; cursor: pointer; display: inline-flex; align-items: center; gap: 5px; white-space: nowrap; }
.sbtn:hover { border-color: var(--muted); }
.sbtn.on { background: var(--ink); color: var(--panel); border-color: var(--ink); }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 2px; overflow: hidden; }
.seg a, .seg button { border: 0; background: transparent; padding: 2px 8px; font-size: 11.5px; cursor: pointer; color: var(--muted); }
.seg a + a, .seg button + button { border-left: 1px solid var(--line); }
.seg a.on, .seg button.on { background: var(--ink); color: var(--panel); }
.btn { height: 30px; padding: 0 12px; border: 1px solid var(--line); background: var(--panel); border-radius: var(--r); cursor: pointer; display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; font-size: 13px; }
.btn:hover { border-color: var(--ink); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); font-weight: 500; }
.trl { margin-left: 8px; padding: 0; border-bottom: 1px solid var(--accent); color: var(--accent-ink); font-family: var(--mono); font-size: 10.5px; vertical-align: 1px; }
.trl:hover { color: var(--ink); }

/* ---------- Pages: Live events, Scheduled briefs, Audit log, sign-in ---------- */
.view { grid-area: work; display: flex; flex-direction: column; min-height: 0; background: var(--panel); }
.vhead { display: flex; align-items: flex-end; gap: 10px 18px; flex-wrap: wrap; padding: 20px 28px 14px; border-bottom: 1px solid var(--rule); }
.vhead h1 { margin: 0; font-weight: 300; font-size: 30px; line-height: 1.1; display: flex; align-items: center; gap: 14px; }
.vhead .sub { color: var(--muted); font-size: 13px; margin-top: 5px; max-width: 760px; }
.vctl { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 9px 28px; border-bottom: 1px solid var(--rule); background: var(--band); }
.vctl input[type=search], .vctl select { height: 24px; border: 1px solid var(--line); background: var(--panel); border-radius: 2px; padding: 0 8px; font-size: 12.5px; }
.vctl input[type=search] { width: 230px; }
.vctl .cnt { margin-left: auto; font-family: var(--mono); font-size: 11px; color: var(--muted); white-space: nowrap; }
.vbody { flex: 1; min-height: 0; overflow: auto; }
.live { display: inline-flex; align-items: center; gap: 6px; font-family: var(--mono); font-size: 10.5px; color: var(--accent-ink); letter-spacing: .06em; }
.live i { width: 7px; height: 7px; background: var(--accent); display: inline-block; }

.evwrap { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(0, 1fr) 300px; }
.evlist { overflow: auto; min-height: 0; position: relative; }
.evh, .ev { display: grid; grid-template-columns: 76px 124px 64px 70px minmax(0, 1fr) 70px; grid-template-areas: "t a k v m x"; gap: 0 12px; padding: 6px 28px; align-items: baseline; }
.evh { position: sticky; top: 0; z-index: 2; background: var(--panel); border-bottom: 1px solid var(--rule); font-size: 10px; text-transform: uppercase; letter-spacing: .08em; color: var(--faint); font-weight: 500; padding-top: 8px; }
.ev { border-bottom: 1px solid var(--rule); font-size: 13px; }
.ev:hover { background: var(--hover); }
.ev .t { grid-area: t; font-family: var(--mono); font-size: 11px; color: var(--faint); }
.ev .a { grid-area: a; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ev .k { grid-area: k; font-family: var(--mono); font-size: 10.5px; letter-spacing: .04em; color: var(--muted); text-transform: uppercase; }
.ev .k.egress { color: var(--accent-ink); } .ev .k.portal { color: var(--warn); }
.ev .v { grid-area: v; font-family: var(--mono); font-size: 10.5px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.ev .m { grid-area: m; min-width: 0; overflow-wrap: anywhere; }
.ev .m code { color: var(--muted); font-size: 11.5px; }
.ev .x { grid-area: x; text-align: right; }
.ev .x .trl { margin-left: 0; }
.ev.deny { background: var(--crit-tint); }
.ev.deny .v, .ev.deny .m code { color: var(--crit); }

.evsum { border-left: 1px solid var(--rule); background: var(--well); overflow: auto; padding: 16px 18px 20px; min-height: 0; }
.evsum h3 { margin: 0 0 10px; font-size: 10.5px; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); font-weight: 500; display: flex; justify-content: space-between; }
.evsum h3 span { text-transform: none; letter-spacing: 0; font-weight: 400; font-family: var(--mono); font-size: 11px; color: var(--faint); }
.sumtot { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 12px; margin-bottom: 18px; }
.sumtot label { display: block; font-size: 10.5px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); white-space: nowrap; }
.sumtot .v { font-size: 22px; font-weight: 300; }
.sumtot .v.bad { color: var(--crit); }
.sumrow { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 5px 10px; align-items: baseline; width: 100%; padding: 8px 0; border: 0; border-top: 1px solid var(--rule); background: transparent; text-align: left; cursor: pointer; font-size: 13px; }
.sumrow:hover b { text-decoration: underline; }
.sumrow.on b { color: var(--accent-ink); }
.sumrow .bar { grid-column: 1 / -1; height: 3px; }
.sumrow .n { font-family: var(--mono); font-size: 11px; color: var(--muted); }
.sumrow .d { font-family: var(--mono); font-size: 11px; color: var(--crit); min-width: 52px; text-align: right; }
.sumrow .d.zero { color: var(--faint); }
.sumnote { font-size: 12px; color: var(--muted); margin: 14px 0 0; }

.aulist { flex: 1; min-height: 0; overflow: auto; }
.auh, .au { display: grid; grid-template-columns: 150px 130px 210px 130px minmax(0, 1fr); grid-template-areas: "t w a g d"; gap: 0 14px; padding: 7px 28px; align-items: baseline; }
.auh { position: sticky; top: 0; z-index: 2; background: var(--panel); border-bottom: 1px solid var(--rule); font-size: 10px; text-transform: uppercase; letter-spacing: .08em; color: var(--faint); font-weight: 500; }
.au { border-bottom: 1px solid var(--rule); font-size: 13px; }
.au:hover { background: var(--hover); }
.au .t { grid-area: t; font-family: var(--mono); font-size: 11.5px; color: var(--muted); white-space: nowrap; }
.au .w { grid-area: w; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.au .a { grid-area: a; font-weight: 500; }
.au .g { grid-area: g; font-family: var(--mono); font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.au .d { grid-area: d; min-width: 0; overflow-wrap: anywhere; color: var(--muted); }
.au.k-refused .a { color: var(--crit); }

.signin { padding: 18px 28px; max-width: 520px; }
.signin p { color: var(--muted); margin: 0 0 14px; }
.roles { display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; margin-bottom: 14px; }
.roles label { display: flex; gap: 10px; align-items: center; padding: 9px 12px; border-bottom: 1px solid var(--line); cursor: pointer; font-size: 13.5px; }
.roles label:last-child { border-bottom: 0; }
.roles label:has(input:checked) { background: var(--sel); }
.roles small { color: var(--muted); margin-left: auto; font-size: 12px; }
label.team { display: block; font-size: 13px; color: var(--muted); margin-bottom: 5px; }
input.team { display: block; width: 100%; height: 32px; padding: 0 9px; border: 1px solid var(--line); background: var(--bg); border-radius: var(--r); margin-bottom: 14px; }

/* ---------- Status bar ---------- */
footer.sbar { grid-area: status; background: var(--nav-bg); color: #c9d1d9; display: flex; align-items: stretch; font-family: var(--mono); font-size: 11px; border-top: 1px solid var(--nav-rule); overflow: hidden; white-space: nowrap; }
footer.sbar > * { display: flex; align-items: center; gap: 6px; padding: 0 10px; border-right: 1px solid var(--nav-rule); }
footer.sbar a:hover { background: var(--nav-hover); }
footer.sbar .muted { color: var(--nav-muted); }
footer.sbar .dot { width: 7px; height: 7px; background: var(--accent); display: inline-block; }
footer.sbar .grow { flex: 1; border-right: 0; }
footer.sbar .d { color: #ef7a6e; }
footer.sbar .z { color: var(--nav-muted); }
footer.sbar .end { border-right: 0; border-left: 1px solid var(--nav-rule); }

/* ---------- Traces ---------- */
.tabs .c.bad { color: var(--crit); }
.tsrc { font-family: var(--mono); font-size: 11px; color: var(--faint); }
.tstats { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); margin: 0 28px; border: 1px solid var(--rule); border-radius: var(--r); }
.tstats > div { padding: 9px 14px 10px; border-right: 1px solid var(--rule); min-width: 0; }
.tstats > div:last-child { border-right: 0; }
.tstats label { display: block; font-size: 10.5px; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tstats .v { font-size: 20px; font-weight: 300; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.runs tbody tr:hover td { background: var(--hover); }
.runs tr.on td, .runs tr.on:hover td { background: var(--sel); }
.runs tr.on td:first-child { box-shadow: inset 3px 0 0 var(--accent); }
.runs td { font-size: 12.5px; }
.runs td.t { font-family: var(--mono); font-size: 11.5px; color: var(--muted); white-space: nowrap; width: 150px; }
.runs td.t a:hover { color: var(--ink); text-decoration: underline; }
.runs td.n { text-align: right; font-family: var(--mono); font-size: 12px; white-space: nowrap; }
.runs th.n { text-align: right; }
.runs .who { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.runs .pm { display: none; font-family: var(--mono); font-size: 11px; color: var(--muted); margin-top: 1px; }
.tk { display: inline-block; font-family: var(--mono); font-size: 10px; letter-spacing: .04em; color: var(--ink); border: 1px solid var(--line); padding: 0 4px; margin-right: 7px; border-radius: 2px; line-height: 15px; vertical-align: 1px; }
.tk.cron { color: var(--blue); border-color: var(--blue); }
.rs { font-family: var(--mono); font-size: 10.5px; text-transform: uppercase; letter-spacing: .05em; white-space: nowrap; }
.rs::before { content: ""; display: inline-block; width: 6px; height: 6px; margin-right: 6px; vertical-align: 1px; background: currentColor; }
.rs.ok { color: var(--accent-ink); } .rs.error { color: var(--warn); } .rs.denied { color: var(--crit); }

.trace { display: grid; grid-template-columns: minmax(0, 1fr) 340px; margin: 0 28px; border: 1px solid var(--rule); border-radius: var(--r); }
.wf { min-width: 0; }
.wf-row { display: grid; grid-template-columns: minmax(0, 320px) minmax(0, 1fr) 64px; align-items: center; width: 100%; min-height: 27px; border-bottom: 1px solid var(--rule); font-size: 12px; }
.wf-row:last-child { border-bottom: 0; }
a.wf-row:hover { background: var(--hover); }
.wf-row.on { background: var(--sel); box-shadow: inset 3px 0 0 var(--accent); }
.wf-row.error .wf-n b { color: var(--warn); }
.wf-head { background: var(--band); min-height: 24px; }
.wf-head .wf-n, .wf-head .wf-d { font-size: 10px; text-transform: uppercase; letter-spacing: .08em; color: var(--faint); }
.wf-n { display: flex; align-items: center; gap: 7px; min-width: 0; padding: 4px 8px 4px calc(12px + var(--d, 0) * 14px); white-space: nowrap; }
.wf-n b { font-family: var(--mono); font-size: 11.5px; font-weight: 400; overflow: hidden; text-overflow: ellipsis; min-width: 0; flex: 0 1 auto; }
.wf-n small { color: var(--faint); font-size: 11px; overflow: hidden; text-overflow: ellipsis; min-width: 0; flex: 0 3 auto; }
.wf-t { position: relative; height: 27px; margin: 0 8px; background-image: repeating-linear-gradient(to right, var(--rule) 0 1px, transparent 1px var(--g, 20%)); }
.wf-head .wf-t { height: 24px; background: none; }
.wf-b { position: absolute; top: 9px; height: 9px; min-width: 2px; border-radius: 1px; }
.wf-tick { position: absolute; top: 5px; font-family: var(--mono); font-size: 10px; color: var(--faint); transform: translateX(-50%); white-space: nowrap; }
.wf-tick.first { transform: none; }
.wf-tick.last { transform: translateX(-100%); }
.wf-d { font-family: var(--mono); font-size: 11px; color: var(--muted); text-align: right; padding-right: 10px; white-space: nowrap; }
.sw { display: inline-block; width: 8px; height: 8px; flex: none; border-radius: 1px; }
.k-root, .k-other { background: var(--line); }
.k-llm { background: var(--accent); }
.k-read { background: color-mix(in srgb, var(--ink) 55%, transparent); }
.k-output { background: var(--blue); }
.k-write { background: var(--warn); }
.k-local { background: transparent; border: 1px dashed var(--muted); }
.k-http { background: transparent; box-shadow: inset 0 0 0 1.5px var(--muted); }
.k-error { background: repeating-linear-gradient(45deg, var(--warn) 0 2px, transparent 2px 4px); box-shadow: inset 0 0 0 1px var(--warn); }
.wf-leg { display: flex; flex-wrap: wrap; gap: 4px 14px; padding: 8px 28px 0; font-size: 12px; color: var(--muted); }
.wf-leg span { display: inline-flex; align-items: center; gap: 6px; }

.sd { border-left: 1px solid var(--rule); padding: 12px 14px 14px; min-width: 0; }
.sd-h { display: flex; align-items: center; gap: 8px; min-width: 0; }
.sd-h b { font-family: var(--mono); font-size: 13px; font-weight: 500; overflow-wrap: anywhere; min-width: 0; }
.sd-m { color: var(--muted); font-size: 12px; margin: 4px 0 10px; display: flex; flex-wrap: wrap; gap: 2px 10px; }
.kv { display: grid; grid-template-columns: fit-content(60%) minmax(0, 1fr); gap: 3px 10px; margin: 0; font-family: var(--mono); font-size: 11px; }
.kv dt { color: var(--muted); overflow-wrap: anywhere; }
.kv dd { margin: 0; overflow-wrap: anywhere; }

@media (max-width: 1180px) {
  .trace { grid-template-columns: minmax(0, 1fr); }
  .sd { border-left: 0; border-top: 1px solid var(--rule); }
  .h-row { grid-template-columns: minmax(0, 1fr); gap: 18px; }
  .hkv { border-left: 0; }
  .hkv > div:first-child { padding-left: 0; }
  .brand small { display: none; }
  .evwrap { grid-template-columns: minmax(0, 1fr) 250px; }
  .evh, .ev { grid-template-columns: 70px 110px 60px 64px minmax(0, 1fr) 64px; gap: 0 10px; }
  .auh, .au { grid-template-columns: 140px 110px 180px 110px minmax(0, 1fr); }
}

/* ---------- Phone: the agent list and the agent are separate screens ---------- */
@media (max-width: 760px) {
  .shell { grid-template-rows: 48px minmax(0, 1fr) 26px; }
  header.top { gap: 6px; padding: 0 10px; }
  .brand small, .bname, .user { display: none; }
  .views { margin-left: 0; overflow-x: auto; }
  .views a { padding: 0 7px; font-size: 12.5px; }
  main.work { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr); }
  .mswitch { display: flex; border-bottom: 1px solid var(--rule); background: var(--band); }
  .mswitch a { flex: 1; text-align: center; padding: 9px 0; font-size: 13px; color: var(--muted); border-bottom: 2px solid transparent; }
  .mswitch a.on { color: var(--ink); border-bottom-color: var(--accent); font-weight: 500; }
  .pane { display: none; }
  #p-list { border-right: 0; }
  .work.m-list #p-list, .work.m-detail #p-detail { display: block; }
  .vhead { padding: 14px 16px 10px; }
  .vhead h1 { font-size: 24px; }
  .vctl { padding: 8px 16px; }
  .vctl input[type=search] { flex: 1 1 100%; width: auto; }
  .vctl .cnt { margin-left: 0; }
  .evwrap { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr); }
  .evsum { order: -1; border-left: 0; border-bottom: 1px solid var(--rule); padding: 10px 16px; }
  .evsum .sumrows, .evsum .sumnote { display: none; }
  .sumtot { grid-template-columns: repeat(4, minmax(0, 1fr)); margin-bottom: 0; gap: 6px; }
  .sumtot label { font-size: 9.5px; letter-spacing: .04em; overflow: hidden; text-overflow: ellipsis; }
  .sumtot .v { font-size: 18px; }
  .evh, .auh { display: none; }
  .ev { grid-template-columns: 58px minmax(0, 1fr) auto; grid-template-areas: "t a k" ". m x"; gap: 2px 10px; padding: 7px 16px; }
  .ev .v { display: none; }
  .empty { padding: 16px; }
  .au { grid-template-columns: 64px minmax(0, 1fr) auto; grid-template-areas: "t a g" "t w w" "t d d"; gap: 2px 10px; padding: 8px 16px; }
  .au .t { white-space: normal; }
  .hero { padding: 16px; gap: 12px; grid-template-columns: minmax(0, 1fr); }
  .h-acts { align-items: flex-start; }
  .h-acts .why { text-align: left; }
  .h-id { gap: 12px; }
  .h-id .tile { width: 44px; height: 44px; font-size: 15px; }
  .hero h1 { font-size: 28px; }
  .spend .num b { font-size: 30px; }
  .hkv { grid-template-columns: repeat(2, minmax(0, 1fr)); row-gap: 12px; }
  .hkv > div { padding: 0 12px 0 0; border-right: 0; }
  .tabs { padding: 0 16px; overflow-x: auto; }
  .tabs a { margin-right: 16px; }
  .tabs .c:not(.bad) { display: none; }
  .tabs .r { display: none; }
  .sech { padding: 14px 16px 8px; }
  .note, .empty-note, .problem { padding-left: 16px; padding-right: 16px; }
  .tb > .banner { margin: 14px 16px 0; }
  th:first-child, td:first-child { padding-left: 16px; }
  th:last-child, td:last-child { padding-right: 16px; }
  .tools .src { display: none; }
  .modes { grid-template-columns: minmax(0, 1fr); margin: 0 16px; }
  .modes > span { border-right: 0; border-bottom: 1px solid var(--line); }
  .modes > span:last-child { border-bottom: 0; }
  .hbar { width: 22%; }
  .bgrid { grid-template-columns: minmax(0, 1fr); gap: 8px; padding: 4px 16px 0; }
  .idgrid { padding: 4px 16px 0; grid-template-columns: 112px minmax(0, 1fr); }
  footer.sbar .hide-m { display: none; }
  .tstats { grid-template-columns: repeat(3, minmax(0, 1fr)); margin: 0 16px; }
  .tstats > div { padding: 8px 10px; border-right: 0; }
  .tstats > div:nth-child(n+4) { border-top: 1px solid var(--rule); }
  .tstats .v { font-size: 18px; }
  .runs .hm { display: none; }
  .runs .pm { display: block; }
  .runs td.t { width: 64px; white-space: normal; }
  .runs .who { white-space: normal; }
  .trace { margin: 0 16px; }
  .wf-row { grid-template-columns: minmax(0, 1fr) 58px; }
  .wf-n { padding-left: calc(10px + var(--d, 0) * 12px); }
  .wf-t { grid-column: 1 / -1; grid-row: 2; height: 12px; margin: 0 10px 6px; }
  .wf-b { top: 2px; height: 8px; }
  .wf-head .wf-t { height: 16px; margin-bottom: 4px; }
  .wf-tick { top: 1px; }
  .wf-leg { padding: 8px 16px 0; }
  .signin { padding: 14px 16px; }
}
