:root {
  color-scheme: dark;
  --bg: #0d0d0f; --fg: #e6e6e1; --muted: #8b8b85; --line: #26262b; --card: #151518;
  --online: #2ea043; --stale: #d29922; --offline: #57575e; --pending: #3b82f6; --revoked: #f04438;
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 14px; color: var(--fg); background: var(--bg);
}
body { margin: 0; background: var(--bg); }
header { display: flex; align-items: baseline; gap: 1rem; padding: 1rem 1.5rem; border-bottom: 1px solid var(--line); background: var(--card); }
header h1 { font-size: 1.1rem; margin: 0; }
header a { color: var(--muted); text-decoration: none; }
header a:hover { color: var(--fg); }
/* The API, from the page that consumes it: the route table and the
   client every interface is built on. */
header nav.api { margin-left: auto; display: flex; flex-wrap: wrap; gap: .25rem 1rem; font-size: .85rem; }
main { padding: 1rem 1.5rem; max-width: 1200px; }
section { margin-bottom: 1.5rem; }
h2 { font-size: 1rem; margin: 0 0 .5rem; }
h3 { font-size: .95rem; margin: 0 0 .4rem; }
table { border-collapse: collapse; width: 100%; background: var(--card); }
th, td { text-align: left; padding: .35rem .6rem; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-weight: 600; color: var(--muted); font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; }
td.num { text-align: right; font-variant-numeric: tabular-nums; }
code, pre { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .85rem; }
pre { background: var(--card); border: 1px solid var(--line); padding: .6rem; overflow: auto; max-height: 24rem; margin: 0; }
.badge { display: inline-block; padding: .05rem .45rem; border-radius: .6rem; font-size: .75rem; color: #fff; background: var(--offline); }
.badge.online { background: var(--online); }
.badge.stale { background: var(--stale); color: #17170f; }
.badge.pending { background: var(--pending); }
.badge.revoked { background: var(--revoked); }
.muted { color: var(--muted); }
.row { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; }
input[type=text], input[type=password] { padding: .3rem .5rem; border: 1px solid var(--line); border-radius: .3rem; font: inherit; background: var(--card); color: var(--fg); }
input[type=text]::placeholder, input[type=password]::placeholder { color: var(--muted); }
/* The account: the login card, the header's name and "Log out", a token shown once. */
.login { max-width: 40rem; }
.login input[type=password] { width: min(100%, 30rem); }
header .user { display: flex; gap: .5rem; align-items: baseline; }
pre.token { user-select: all; white-space: pre-wrap; word-break: break-all; margin: .4rem 0; }
button { padding: .3rem .7rem; border: 1px solid var(--line); border-radius: .3rem; background: var(--card); color: var(--fg); font: inherit; cursor: pointer; }
button:hover { border-color: var(--muted); }
.node { border: 1px solid var(--line); border-radius: .4rem; background: var(--card); padding: .8rem 1rem; margin-bottom: 1rem; }
.node > .row { margin-bottom: .5rem; }
details summary { cursor: pointer; color: var(--muted); margin-top: .5rem; }
#feed { display: inline-block; width: .6rem; height: .6rem; border-radius: 50%; background: var(--offline); }
#feed.live { background: var(--online); }
ul.events { list-style: none; padding: 0; margin: 0; }
ul.events li { padding: .2rem 0; border-bottom: 1px solid var(--line); }
.node details.apps h4, .node details.trees h4 { margin: .8rem 0 .3rem; font-weight: 500; }
.node details.apps table, .node details.trees table { margin-bottom: .5rem; }
/* The folded tree: monospace so the guides line up, the guides dimmed
   like `3pm ls --tree` draws them. */
td.tree { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .85rem; white-space: pre; }
td.tree .guide { color: var(--muted); }
.detached { color: var(--stale); }
a.procs { color: var(--muted); text-decoration: none; font-size: .85rem; }
a.procs:hover { color: var(--fg); }
.label { display: inline-block; padding: 0 .35rem; margin-left: .25rem; border-radius: .3rem; background: var(--bg); border: 1px solid var(--line); font-size: .75rem; }

button.small { padding: .1rem .45rem; font-size: .8rem; }
button:disabled { opacity: .5; cursor: not-allowed; }
button.danger:hover { border-color: var(--revoked); color: var(--revoked); }
td.buttons { white-space: nowrap; }

/* Remote actions: a row under each app of the process table (repainted
   only when the declarations move), the results in the `#calls` dialog. */
tr.app-actions td { padding: .15rem .6rem .35rem 2.4rem; background: var(--bg); border-bottom: 1px solid var(--line); }
.actions { display: flex; flex-wrap: wrap; gap: .3rem; align-items: center; }
.actions > .muted { font-size: .75rem; text-transform: uppercase; letter-spacing: .03em; margin-right: .3rem; }
.node p.no-token { margin: .3rem 0 0; font-size: .85rem; }
dialog#calls { width: min(96vw, 900px); max-height: 85vh; padding: .8rem 1rem; border: 1px solid var(--line); border-radius: .4rem; background: var(--card); color: var(--fg); }
dialog#calls::backdrop { background: rgba(0, 0, 0, .6); }
dialog#calls .calls-out { margin-top: .5rem; }
dialog#calls .calls-out:empty::after { content: "No call yet."; color: var(--muted); }
.actions .src { display: inline-flex; gap: .3rem; align-items: center; }
.countdown { margin-left: .4rem; color: var(--stale); font-variant-numeric: tabular-nums; }
.call details.json summary { margin-top: .2rem; font-size: .8rem; }
.actions input.params { font: inherit; padding: .25rem .4rem; border: 1px solid var(--line); border-radius: .3rem; background: var(--bg); color: var(--fg); }
.call { border-left: 2px solid var(--line); padding: .2rem 0 .2rem .6rem; margin: .4rem 0; }
.call pre { max-height: 14rem; overflow: auto; margin: .2rem 0; }
.call .live { margin: .3rem 0; font-size: .85rem; }
.call .live button.watch { margin-left: .4rem; }
.call .live .preview img { display: block; margin-top: .4rem; max-width: 100%; max-height: 18rem; border: 1px solid var(--line); background: #000; }
.call .ok { color: var(--online); }
.err { color: var(--revoked); }
.badge.replied { background: var(--online); }
.badge.sent, .badge.acked { background: var(--stale); color: #17170f; }
.badge.lost, .badge.unacked, .badge.refused { background: var(--revoked); }

/* The node's fleet grant: a badge per scope in the table, the Access
   panel in its card. */
.badge.scope { background: var(--accent, #4b5563); font-size: .7rem; }
.grants { margin-top: .15rem; display: flex; gap: .2rem; flex-wrap: wrap; }
details.access .scopes { display: flex; flex-direction: column; gap: .2rem; margin: .4rem 0; }
details.access label.scope { display: flex; align-items: center; gap: .4rem; }
details.access textarea.callers { display: block; width: 100%; box-sizing: border-box; font-family: ui-monospace, monospace; font-size: .8rem; margin-top: .2rem; }
details.access .callers-label { display: block; margin: .5rem 0; }

/* The "Live JSON" dialog: a toolbar, then the document filling the rest. */
dialog#inspect { width: min(96vw, 1100px); height: 90vh; padding: .8rem 1rem; border: 1px solid var(--line); border-radius: .4rem; background: var(--card); color: var(--fg); display: none; flex-direction: column; gap: .5rem; }
dialog#inspect[open] { display: flex; }
dialog#inspect::backdrop { background: rgba(0, 0, 0, .6); }
dialog#inspect select { font: inherit; padding: .25rem .4rem; border: 1px solid var(--line); border-radius: .3rem; background: var(--bg); color: var(--fg); max-width: 40vw; }
dialog#inspect pre { flex: 1; max-height: none; min-height: 0; background: var(--bg); }
dialog#inspect button.stop.stopped { border-color: var(--stale); color: var(--stale); }
/* The tree (json-formatter-js, its own stylesheet injected): the
   dashboard's monospace and size, keys and folds a little softer. */
dialog#inspect .tree { flex: 1; min-height: 0; overflow: auto; background: var(--bg); border: 1px solid var(--line); padding: .6rem; }
dialog#inspect .tree .json-formatter-row { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .85rem; line-height: 1.35; }
dialog#inspect .tree .json-formatter-dark.json-formatter-row .json-formatter-key { color: #7cc4ff; }
dialog#inspect .tree .json-formatter-dark.json-formatter-row .json-formatter-string { color: #9ad78a; }
dialog#inspect .tree .json-formatter-dark.json-formatter-row .json-formatter-number { color: #f0c674; }
dialog#inspect .tree .json-formatter-dark.json-formatter-row .json-formatter-boolean { color: #ff8a8a; }
dialog#inspect .tree .json-formatter-dark.json-formatter-row .json-formatter-null { color: var(--muted); }
dialog#inspect .tree .json-formatter-dark.json-formatter-row .json-formatter-constructor-name { color: var(--muted); }
dialog#inspect .tree .json-formatter-dark.json-formatter-row .json-formatter-toggler { opacity: .8; }
dialog#inspect .tree .json-formatter-dark.json-formatter-row > a > .json-formatter-preview-text { color: var(--muted); }
/* A search hit: its key on an amber ground. */
dialog#inspect .tree .json-formatter-row.hit > a > .json-formatter-key,
dialog#inspect .tree .json-formatter-row.hit > span > .json-formatter-key { background: rgba(240, 198, 116, .25); border-radius: .2rem; padding: 0 .2rem; color: #f0c674; }

/* The long lists (events, metric keys) fold behind their title, closed
   by default, a filter box inside. */
details.fold > summary { list-style: none; cursor: pointer; margin: 0; }
details.fold > summary::-webkit-details-marker { display: none; }
details.fold > summary h2 { display: inline; }
details.fold > summary h2::before { content: "▸ "; color: var(--muted); font-size: .8rem; }
details.fold[open] > summary h2::before { content: "▾ "; }
details.fold > p { margin-top: .5rem; }
input.filter { width: min(100%, 36rem); }

/* The SDK guide: one fold per topic, code the reader can copy — a
   `pre.language-*` coloured by highlight.js (its theme linked by the
   page), on the dashboard's own background. */
#guide pre.hljs, #guide pre[class*="language-"] { background: var(--bg); color: var(--fg); }
#guide details { border: 1px solid var(--line); border-radius: .4rem; background: var(--card); padding: .2rem .8rem .5rem; margin-bottom: .6rem; }
#guide details summary { font-weight: 500; color: var(--fg); margin: .3rem 0; }
#guide details summary .muted { font-weight: 400; margin-left: .4rem; }
#guide h4 { margin: .8rem 0 .3rem; font-weight: 500; }
#guide p { margin: .3rem 0; }
#guide ul { margin: .3rem 0; padding-left: 1.2rem; }
#guide pre { margin: .3rem 0; max-height: none; }
#guide table { margin: .3rem 0; }
#guide .fill { color: var(--online); }
