/* PA Brain console.

   Dark to match the hub's chrome, since this renders inside a mother-portal
   iframe on a gray-950 page and a white document would read as a broken frame.
   No framework: this file is served by the brain's own FastAPI, and adding a
   Node build step to a Python service to obtain four hundred lines of CSS is a
   deployment liability, not a convenience.

   The accent is violet (#c084fc). Deliberately not indigo #6366f1 (revenue-alpha
   and mission-control already share it) and not emerald #10b981 (expense-manager
   and midgard-alpha share it) — every tile in the hub is supposed to be
   distinguishable at a glance. See krobin93/mother-portal#82. */

:root {
  --bg: #0b0b10;
  --panel: #14141c;
  --panel-2: #1b1b26;
  --line: #2a2a38;
  --text: #e7e7ef;
  --muted: #9a9aae;
  --accent: #c084fc;
  --accent-dim: #a855f7;
  --ok: #4ade80;
  --warn: #fbbf24;
  --bad: #f87171;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ── header ─────────────────────────────────────────────────────────────── */

.bar {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 16px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}
.bar h1 { font-size: 15px; margin: 0; font-weight: 650; letter-spacing: .2px; }
.pills { display: flex; gap: 8px; flex-wrap: wrap; }
.pill {
  font-size: 12px; padding: 2px 10px; border-radius: 999px;
  background: var(--panel-2); border: 1px solid var(--line); color: var(--muted);
}
.pill.ok   { color: var(--ok);   border-color: rgba(74,222,128,.35); }
.pill.bad  { color: var(--bad);  border-color: rgba(248,113,113,.35); }
.pill.warn { color: var(--warn); border-color: rgba(251,191,36,.35); }
.bar .ghost { margin-left: auto; }

/* ── banner ─────────────────────────────────────────────────────────────── */

.banner {
  padding: 10px 16px;
  background: rgba(248,113,113,.1);
  border-bottom: 1px solid rgba(248,113,113,.35);
  color: #fecaca;
  font-size: 13px;
}

/* ── tabs ───────────────────────────────────────────────────────────────── */

.tabs {
  display: flex; gap: 4px; padding: 8px 12px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}
.tab {
  background: transparent; border: 1px solid transparent; color: var(--muted);
  padding: 5px 12px; border-radius: 8px; cursor: pointer; font: inherit; font-size: 13px;
}
.tab:hover { color: var(--text); background: var(--panel-2); }
.tab[aria-selected="true"] {
  color: var(--text); background: var(--panel-2); border-color: var(--line);
  box-shadow: inset 0 -2px 0 var(--accent);
}

main { padding: 16px; max-width: 1100px; margin: 0 auto; }

/* ── generic controls ───────────────────────────────────────────────────── */

button, input, select, textarea {
  font: inherit;
  color: var(--text);
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 6px 10px;
}
textarea { resize: vertical; }
button {
  background: var(--accent-dim); border-color: var(--accent-dim);
  color: #12021c; font-weight: 600; cursor: pointer;
}
button:hover { background: var(--accent); border-color: var(--accent); }
button:disabled { opacity: .5; cursor: not-allowed; }
button.ghost {
  background: transparent; border-color: var(--line); color: var(--muted); font-weight: 500;
}
button.ghost:hover { color: var(--text); background: var(--panel-2); }
button.danger { background: transparent; border-color: rgba(248,113,113,.4); color: #fca5a5; }
button.danger:hover { background: rgba(248,113,113,.12); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.muted { color: var(--muted); }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }

/* ── chat ───────────────────────────────────────────────────────────────── */

.log {
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px;
  padding: 12px; height: 55vh; overflow-y: auto; display: flex; flex-direction: column; gap: 10px;
}
.msg { max-width: 78%; padding: 8px 12px; border-radius: 12px; white-space: pre-wrap; word-wrap: break-word; }
.msg.user { align-self: flex-end; background: var(--accent-dim); color: #12021c; }
.msg.pa   { align-self: flex-start; background: var(--panel-2); border: 1px solid var(--line); }
.msg .who { display: block; font-size: 11px; opacity: .7; margin-bottom: 2px; }
.composer { display: flex; gap: 8px; margin-top: 10px; }
.composer textarea { flex: 1; }
.composer textarea:disabled { opacity: .5; cursor: not-allowed; }
/* Why the composer below it is dead, and what fixes it (#1769). */
.note {
  margin-top: 10px; padding: 8px 10px; font-size: 13px; line-height: 1.45;
  border: 1px solid rgba(251,191,36,.35); border-left-width: 3px; border-radius: 8px;
  background: var(--panel-2); color: var(--warn);
}

/* ── lists ──────────────────────────────────────────────────────────────── */

.row-form { display: flex; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; }
.row-form input:not([type=number]) { flex: 1; min-width: 140px; }
.row-form input[type=number] { width: 72px; }

.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px;
  padding: 10px 12px; margin-bottom: 8px;
}
.card .head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.card .title { font-weight: 600; }
.card .actions { margin-left: auto; display: flex; gap: 6px; }
.card .body { color: var(--muted); margin-top: 4px; }

.badge {
  font-size: 11px; padding: 1px 8px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--panel-2); color: var(--muted);
}
.badge.running   { color: var(--accent); border-color: rgba(192,132,252,.4); }
.badge.done      { color: var(--ok);   border-color: rgba(74,222,128,.35); }
.badge.escalated { color: var(--warn); border-color: rgba(251,191,36,.4); }
.badge.failed,
.badge.cancelled { color: var(--bad);  border-color: rgba(248,113,113,.35); }

.split { display: grid; grid-template-columns: minmax(220px, 340px) 1fr; gap: 12px; }
@media (max-width: 720px) { .split { grid-template-columns: 1fr; } }
.list { max-height: 62vh; overflow-y: auto; }
.list .card { cursor: pointer; }
.list .card[aria-current="true"] { border-color: var(--accent); }
.detail {
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px;
  padding: 12px; max-height: 62vh; overflow-y: auto;
}
.events { margin: 8px 0 0; padding: 0; list-style: none; }
.events li { border-top: 1px solid var(--line); padding: 6px 0; }
.events li:first-child { border-top: 0; }
