:root {
  color-scheme: light dark;
  --page: #f9f9f9; --surface: #ffffff; --text: #191919; --muted: #666666;
  --grid: #e7e7e7; --axis: #c2c2c2; --border: rgba(11,11,11,.10); --bad: #dc3c3d;
  --s1: #257de0; --s2: #f47230; --s3: #00b894; --s4: #f2a600;
  --s5: #ee7fac; --s6: #008a17; --s7: #6a4ce2; --s8: #ec4647;
  --good: #0aac23; --good-text: #006c10; --critical: #dc3c3d; --none: #a8a8a8;
  /* One hue, near zero recedes into the surface. */
  --h1: #cce3fd; --h2: #9dc8f7; --h3: #6aabf1; --h4: #338ced; --h5: #1b64be;
}
@media (prefers-color-scheme: dark) {
  :root {
    --page: #0b0b0b; --surface: #191919; --text: #efefef; --muted: #9c9c9c;
    --grid: #303030; --axis: #474747; --border: rgba(255,255,255,.10);
    --s1: #338ced; --s2: #e76624; --s3: #00a888; --s4: #d28e05;
    --s5: #e24d8b; --s6: #0aac23; --s7: #9887ef; --s8: #eb6263;
    --none: #6b6b6b; --good-text: #53c556;
    --h1: #0e3d7e; --h2: #1757ac; --h3: #2370cd; --h4: #519ced; --h5: #9dc8f7;
  }
}
* { box-sizing: border-box; }
/* Dashboard rules are scoped to .app: the chat widget injects page-wide base
   styles, which must neither undo ours nor be restyled by them. */
.app { font: 14px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif; }
body { margin: 0; background: var(--page); color: var(--text); font: 14px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif; }
main.app { max-width: 1200px; margin: 0 auto; padding: 24px 16px 48px; }
.app h1 { font-size: 22px; font-weight: 700; margin: 0; }
.app h2 { font-size: 15px; font-weight: 700; margin: 0 0 8px; }
.app p { margin: 4px 0; }
.muted { color: var(--muted); }
.app header, .head, .actions, .filters, .legend { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; }
.app header, .head { justify-content: space-between; }
.filters { margin: 16px 0; }
.tabs { display: flex; gap: 4px; margin-top: 16px; border-bottom: 1px solid var(--grid); }
.app .tabs button { border: 0; border-bottom: 3px solid transparent; border-radius: 0; background: transparent; color: var(--muted); padding: 8px 16px; font-weight: 600; }
.app .tabs button:hover { color: var(--text); }
.app .tabs button[aria-selected="true"] { color: var(--text); border-bottom-color: var(--s1); }
.filters label, .head label { color: var(--muted); }
.app select, .app button, .app input { font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: 6px; padding: 5px 10px; max-width: 260px; }
.app button { cursor: pointer; }
.tiles { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
@media (max-width: 700px) { .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.tile, .card { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 14px 16px; }
.tile b { display: block; font-size: 26px; font-weight: 600; }
.tile { border-top: 3px solid var(--accent); background: linear-gradient(180deg, color-mix(in srgb, var(--accent) 14%, var(--surface)), var(--surface) 70%); }
.tile span::before { content: ""; display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); margin-right: 6px; }
.t1 { --accent: var(--s1); } .t2 { --accent: var(--s2); } .t3 { --accent: var(--s3); } .t4 { --accent: var(--s4); }
.t5 { --accent: var(--s5); } .t6 { --accent: var(--s6); } .t7 { --accent: var(--s7); } .t8 { --accent: var(--s8); }
.card { margin-top: 16px; position: relative; }
.scroll { overflow-x: auto; max-height: 460px; overflow-y: auto; }
.app table { width: 100%; border-collapse: collapse; }
.app th, .app td { text-align: left; padding: 6px 10px; border-bottom: 1px solid var(--grid); vertical-align: top; }
.app th { color: var(--muted); font-weight: 500; position: sticky; top: 0; background: var(--surface); }
.app td.n, .app th.n { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.app tr.link { cursor: pointer; }
.app tr.link:hover, .app tr.selected { background: var(--grid); }
.app td.detail { white-space: pre-wrap; overflow-wrap: anywhere; max-width: 520px; font-family: ui-monospace, Menlo, monospace; font-size: 12px; }
.bad { color: var(--bad); }
.swatch { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 6px; }
.legend { margin: 6px 0 10px; font-size: 12px; color: var(--muted); }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 440px), 1fr)); gap: 0 16px; }
.grid2 > .card { min-width: 0; }
.viz svg, .multiples svg, .donut svg { display: block; width: 100%; height: auto; }
.viz text, .multiples text, .donut text { fill: var(--muted); font-size: 11px; }
.grid { stroke: var(--grid); }
.axis { stroke: var(--axis); }
.hit { fill: transparent; }
.hit:hover, .hit:focus { fill: var(--grid); fill-opacity: .35; outline: none; }
.multiples { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr)); gap: 16px; }
.multiples h3 { margin: 4px 0; font-size: 13px; font-weight: 600; }
.donut { display: flex; flex-wrap: wrap; gap: 20px; align-items: center; }
.donut svg { width: 190px; flex: none; }
.donut path { stroke: var(--surface); stroke-width: 2; }
.donut text.total { fill: var(--text); font-size: 24px; font-weight: 600; }
.donut ul { list-style: none; margin: 0; padding: 0; flex: 1; min-width: 200px; }
.donut li { display: flex; align-items: center; padding: 5px 0; border-bottom: 1px solid var(--grid); }
.donut li span:nth-child(2) { flex: 1; overflow-wrap: anywhere; }
.donut li b { font-weight: 600; font-variant-numeric: tabular-nums; margin-left: 12px; }
.hrow { display: grid; grid-template-columns: minmax(70px, 130px) 1fr 64px; gap: 10px; align-items: center; padding: 5px 4px; border-radius: 6px; }
.hrow:hover, .hrow:focus-visible { background: var(--grid); outline: none; }
.hrow .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hrow .value { text-align: right; font-variant-numeric: tabular-nums; }
.track { display: flex; gap: 2px; height: 16px; }
.track i { display: block; min-width: 2px; }
.track i:last-child { border-radius: 0 4px 4px 0; }
.heat rect:hover, .heat rect:focus { stroke: var(--text); stroke-width: 1.5; outline: none; }
.scale { display: flex; gap: 3px; align-items: center; justify-content: flex-end; font-size: 12px; margin-top: 6px; }
.scale .swatch { margin: 0; width: 14px; height: 14px; }
.tip { position: fixed; z-index: 20; pointer-events: none; background: var(--surface); border: 1px solid var(--axis); border-radius: 6px; padding: 8px 10px; font-size: 12px; width: max-content; max-width: min(320px, calc(100vw - 16px)); box-shadow: 0 4px 16px rgba(0,0,0,.18); }
.app button.danger { color: var(--bad); }
.profile { position: relative; }
.app #profile-button { display: flex; align-items: center; gap: 8px; padding: 4px 10px 4px 5px; border-radius: 999px; }
.avatar { display: grid; place-items: center; width: 26px; height: 26px; border-radius: 50%; background: var(--s1); color: #fff; font-weight: 700; font-size: 13px; }
.menu { position: absolute; right: 0; top: calc(100% + 6px); z-index: 10; min-width: 200px; display: flex; flex-direction: column; padding: 6px; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; box-shadow: 0 8px 28px rgba(0,0,0,.22); }
.app .menu button { border: 0; background: transparent; text-align: left; padding: 8px 10px; max-width: none; white-space: nowrap; }
.app .menu button:hover, .app .menu button:focus-visible { background: var(--grid); }
.app dialog { width: min(640px, calc(100vw - 32px)); max-height: calc(100vh - 48px); padding: 20px 22px; background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: 12px; box-shadow: 0 16px 48px rgba(0,0,0,.35); }
.app dialog::backdrop { background: rgba(0,0,0,.55); }
.app dialog .head { flex-wrap: nowrap; }
.app dialog .head h2 { margin: 0; }
.app #close-account { border: 0; background: transparent; color: var(--muted); }
.app dialog .stack input, .app dialog .stack .password { width: 100%; max-width: none; }
.app dialog .stack label { align-self: stretch; }
#agents .actions { flex-wrap: nowrap; gap: 8px; }
#agents button { white-space: nowrap; }
.app button:disabled { opacity: .5; cursor: default; }
.issued code { font-family: ui-monospace, Menlo, monospace; font-size: 12px; overflow-wrap: anywhere; white-space: pre-wrap; user-select: all; }
[hidden] { display: none !important; }
main.app.login { max-width: 360px; padding-top: 12vh; }
.login form { display: flex; flex-direction: column; gap: 12px; padding: 24px; }
.login label, .stack label { display: flex; flex-direction: column; gap: 4px; color: var(--muted); }
.login input, .login button { max-width: none; width: 100%; padding: 8px 10px; }
.app button.primary { background: var(--s1); border-color: var(--s1); color: #fff; }
.forms { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 24px; }
.stack { display: flex; flex-direction: column; gap: 10px; align-items: flex-start; }
.stack input { width: 260px; }
#accounts .actions { flex-wrap: nowrap; gap: 8px; }
#accounts button { white-space: nowrap; }
.password { position: relative; display: flex; }
.password input { width: 100%; padding-right: 40px; }
.stack .password { width: 260px; }
.password button.eye { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); width: 30px; height: 28px; padding: 3px 5px; border: 0; background: transparent; color: var(--muted); }
.password button.eye:hover, .password button.eye:focus-visible, .password button.eye[aria-pressed="true"] { color: var(--text); }
.eye svg { display: block; width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
/* The slash marks "hidden"; the open eye means the password is showing. */
.eye[aria-pressed="true"] .slash { display: none; }
.app footer { margin-top: 24px; font-size: 12px; }
/* Popups: forms, confirmations and the links shown once. */
.app dialog h2 { margin: 0 0 8px; overflow-wrap: anywhere; }
.app dialog form.stack, .app dialog .stack { align-items: stretch; }
.app #ask-message { white-space: pre-line; margin-bottom: 12px; }
.app #ask-message:empty, .app #ask-error:empty, .app #agent-message:empty, #ask-fields:empty { display: none; }
.app dialog fieldset { border: 1px solid var(--border); border-radius: 8px; margin: 0; padding: 8px 12px; display: flex; flex-direction: column; gap: 6px; }
.app dialog legend { color: var(--muted); padding: 0 4px; }
.app dialog .stack label.check { flex-direction: row; align-items: center; gap: 8px; color: var(--text); }
.app dialog .stack label.check input { width: auto; }
.buttons { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }
.app .buttons button { width: auto; padding: 7px 16px; }
.app button.primary.danger { background: var(--critical); border-color: var(--critical); color: #fff; }
.copy { display: flex; flex-wrap: wrap; gap: 8px; align-items: flex-start; }
.copy code { flex: 1 1 100%; padding: 8px 10px; background: var(--page); border: 1px solid var(--border); border-radius: 6px; }
/* A lit green dot marks an agent heard from just now. */
.online { display: inline-flex; align-items: center; gap: 7px; color: var(--good-text); font-weight: 600; white-space: nowrap; }
.online::before { content: ""; width: 10px; height: 10px; border-radius: 50%; background: var(--good); box-shadow: 0 0 0 3px color-mix(in srgb, var(--good) 25%, transparent), 0 0 8px var(--good); animation: pulse 2s ease-in-out infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 5px color-mix(in srgb, var(--good) 10%, transparent), 0 0 12px var(--good); } }
@media (prefers-reduced-motion: reduce) { .online::before { animation: none; } }
.tile:hover, .tile:focus-visible { border-color: var(--accent); outline: none; }
