:root {
  --bg: #04080f;
  --panel: rgba(10, 24, 40, 0.72);
  --line: rgba(79, 209, 255, 0.22);
  --cyan: #4fd1ff;
  --cyan-dim: #2a7ea3;
  --text: #d6ecf7;
  --muted: #7b96a8;
  --amber: #ffb547;
  --red: #ff5d6c;
  --green: #4be3a0;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif; }
body {
  min-height: 100vh;
  background:
    radial-gradient(ellipse at 50% 20%, rgba(79, 209, 255, 0.08), transparent 60%),
    repeating-linear-gradient(0deg, rgba(79, 209, 255, 0.025) 0 1px, transparent 1px 40px),
    repeating-linear-gradient(90deg, rgba(79, 209, 255, 0.025) 0 1px, transparent 1px 40px),
    var(--bg);
}
.top { display: flex; justify-content: space-between; align-items: center; padding: 12px 20px; border-bottom: 1px solid var(--line); }
.brand { font-family: var(--mono); letter-spacing: .3em; color: var(--cyan); font-weight: 600; }
.brand span { color: var(--muted); letter-spacing: .15em; font-weight: 400; margin-left: 8px; text-transform: uppercase; font-size: 11px; }
.meta { display: flex; gap: 14px; align-items: center; font-family: var(--mono); font-size: 12px; color: var(--muted); }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; background: var(--green); box-shadow: 0 0 8px var(--green); }
.dot.off { background: var(--red); box-shadow: 0 0 8px var(--red); }

.grid { display: grid; grid-template-columns: minmax(240px, 1fr) minmax(360px, 1.6fr) minmax(260px, 1.1fr); gap: 16px; padding: 16px 20px; }
.col { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: 12px 14px; position: relative; backdrop-filter: blur(4px); min-width: 0; }
.panel::before { content: ""; position: absolute; top: -1px; left: -1px; width: 14px; height: 14px; border-top: 2px solid var(--cyan); border-left: 2px solid var(--cyan); }
.panel h2 { margin: 0 0 10px; font: 600 11px var(--mono); letter-spacing: .18em; text-transform: uppercase; color: var(--cyan); display: flex; gap: 8px; align-items: center; }
.panel h2 small { color: var(--muted); letter-spacing: .1em; font-weight: 400; }
.badge { background: var(--amber); color: #1a1000; border-radius: 10px; padding: 0 7px; font-size: 11px; }
.badge.zero { background: var(--line); color: var(--muted); }

.list, .agents, .log { list-style: none; margin: 0; padding: 0; }
.agents li { display: grid; grid-template-columns: 10px 1fr; gap: 4px 10px; padding: 7px 0; border-bottom: 1px dashed var(--line); }
.agents li:last-child { border-bottom: 0; }
.agents .name { font-weight: 600; text-transform: capitalize; }
.agents .name em { font-style: normal; color: var(--muted); font-weight: 400; font-size: 12px; margin-left: 6px; }
.agents .desc { grid-column: 2; color: var(--muted); font-size: 12px; }
.agents .dot { margin-top: 6px; background: var(--cyan-dim); box-shadow: none; }
.agents .working .dot { background: var(--cyan); box-shadow: 0 0 10px var(--cyan); animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: .35; } }

.list li { padding: 7px 0; border-bottom: 1px dashed var(--line); display: flex; gap: 8px; align-items: center; justify-content: space-between; }
.list li:last-child { border-bottom: 0; }
.list .sub { color: var(--muted); font-size: 12px; }
.tasks li { display: block; }
.tasks .st { font: 11px var(--mono); padding: 0 6px; border-radius: 3px; margin-right: 6px; border: 1px solid var(--line); }
.st.running { color: var(--cyan); border-color: var(--cyan); }
.st.done { color: var(--green); }
.st.failed { color: var(--red); }
.st.queued { color: var(--amber); }

button { font: inherit; cursor: pointer; }
.btn { background: transparent; border: 1px solid var(--cyan-dim); color: var(--cyan); border-radius: 4px; padding: 3px 10px; font-size: 12px; }
.btn:hover { background: rgba(79, 209, 255, .12); }
.btn.ok { border-color: var(--green); color: var(--green); }
.btn.no { border-color: var(--red); color: var(--red); }
.attention li { flex-direction: column; align-items: stretch; }
.attention .actions { display: flex; gap: 8px; }
.attention .who { font: 11px var(--mono); color: var(--amber); }

.reactor-wrap { display: flex; flex-direction: column; align-items: center; }
#reactor { width: min(100%, 320px); height: auto; aspect-ratio: 1; }
.status-line { font: 12px var(--mono); color: var(--cyan); letter-spacing: .2em; text-transform: uppercase; margin-top: -6px; }

.chat { display: flex; flex-direction: column; }
.chat-log { height: 340px; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; padding-right: 4px; }
.msg { max-width: 88%; padding: 8px 12px; border-radius: 6px; white-space: pre-wrap; word-wrap: break-word; }
.msg.user { align-self: flex-end; background: rgba(79, 209, 255, .14); border: 1px solid var(--line); }
.msg.assistant { align-self: flex-start; background: rgba(255, 255, 255, .03); border: 1px solid var(--line); border-left: 2px solid var(--cyan); }
.msg.thinking { color: var(--muted); font-style: italic; }
.chat-form { display: flex; gap: 8px; margin-top: 10px; }
.chat-form input { flex: 1; min-width: 0; background: rgba(0, 0, 0, .35); border: 1px solid var(--line); color: var(--text); border-radius: 4px; padding: 9px 12px; font: inherit; }
.chat-form input:focus { outline: none; border-color: var(--cyan); }
.send { background: var(--cyan); color: #001520; border: 0; border-radius: 4px; padding: 0 16px; font-weight: 600; }
.icon-btn { background: transparent; border: 1px solid var(--line); border-radius: 50%; width: 38px; height: 38px; color: var(--text); flex: none; }
.icon-btn.live { border-color: var(--red); box-shadow: 0 0 12px var(--red); animation: pulse 1s infinite; }
.toggles { display: flex; gap: 16px; flex-wrap: wrap; margin-top: 8px; font-size: 12px; color: var(--muted); }

.report { white-space: pre-wrap; font-size: 13px; max-height: 260px; overflow-y: auto; color: var(--text); }
.report .when { display: block; color: var(--muted); font: 11px var(--mono); margin-bottom: 6px; }
.empty { color: var(--muted); font-style: italic; font-size: 12px; }

.log-panel { grid-column: 1 / -1; }
.log { font: 12px/1.6 var(--mono); max-height: 260px; overflow-y: auto; }
.log li { display: grid; grid-template-columns: 70px 90px 80px 1fr; gap: 10px; }
.log .t { color: var(--muted); }
.log .s { color: var(--cyan); }
.log .k { color: var(--amber); }
.log .m { overflow-wrap: anywhere; }

.toast { position: fixed; bottom: 20px; right: 20px; max-width: 360px; background: #0b2233; border: 1px solid var(--cyan); padding: 10px 14px; border-radius: 6px; opacity: 0; transform: translateY(10px); transition: .25s; pointer-events: none; }
.toast.show { opacity: 1; transform: none; }

@media (max-width: 1100px) {
  .grid { grid-template-columns: 1fr 1fr; }
  .centre { grid-column: 1 / -1; order: -1; }
}
@media (max-width: 700px) {
  .grid { grid-template-columns: 1fr; padding: 12px 16px; }
  .top { padding: 10px 16px; flex-wrap: wrap; gap: 6px; }
  .log li { grid-template-columns: 52px 1fr; }
  .log .k { display: none; }
  .log .m { grid-column: 1 / -1; }
  .chat-log { height: 300px; }
}

/* ---- tabs and feature views ---- */
.tabs { display: flex; gap: 4px; margin: 6px 0 -8px; }
.tab { background: transparent; border: 1px solid var(--line); border-bottom: 0; color: var(--muted); padding: 6px 14px; border-radius: 6px 6px 0 0; font: 600 11px var(--mono); letter-spacing: .15em; text-transform: uppercase; }
.tab.on { color: var(--cyan); background: var(--panel); border-color: var(--cyan-dim); }
[hidden] { display: none !important; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 12px; }
.form-grid h2, .form-grid .wide { grid-column: 1 / -1; }
.form-grid label, .inline-form label { display: flex; flex-direction: column; gap: 3px; font-size: 12px; color: var(--muted); }
.form-grid label:has(input[type=checkbox]) { flex-direction: row; align-items: center; gap: 8px; }
input, select, textarea { background: rgba(0, 0, 0, .35); border: 1px solid var(--line); color: var(--text); border-radius: 4px; padding: 7px 9px; font: inherit; min-width: 0; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--cyan); }
.form-grid .send { padding: 9px; }
.inline-form { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; margin: 10px 0; }
.inline-form .wide { flex-basis: 100%; white-space: pre-wrap; }
.view h2 { margin-top: 14px; }
#iv-log { height: 280px; }
#iv-answer { width: 100%; margin-top: 10px; resize: vertical; }
.iv-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; font-weight: 600; }
.score { font: 600 12px var(--mono); padding: 1px 7px; border-radius: 3px; border: 1px solid var(--line); flex: none; }
.score.hi { color: var(--green); border-color: var(--green); }
.score.mid { color: var(--amber); border-color: var(--amber); }
.score.lo { color: var(--red); border-color: var(--red); }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 10px; }
.card { border: 1px solid var(--line); border-radius: 6px; padding: 10px; }
.card.danger { border-color: var(--red); box-shadow: 0 0 12px rgba(255, 93, 108, .25); }
.card .big { font: 600 20px var(--mono); }
.bar { height: 6px; background: rgba(255, 255, 255, .06); border-radius: 3px; margin: 4px 0 8px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--green); }
.bar.warn > i { background: var(--amber); }
.bar.bad > i { background: var(--red); }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(92px, 1fr)); gap: 8px; margin: 12px 0 6px; }
.stat { border: 1px solid var(--line); border-radius: 4px; padding: 6px 8px; }
.stat b { display: block; font: 600 16px var(--mono); }
.stat span { font-size: 11px; color: var(--muted); }
.equity { width: 100%; height: 60px; }
.equity polyline { fill: none; stroke: var(--cyan); stroke-width: 1.5; vector-effect: non-scaling-stroke; }
.equity line { stroke: var(--line); vector-effect: non-scaling-stroke; }
.log-form summary { cursor: pointer; color: var(--cyan); font: 600 12px var(--mono); letter-spacing: .1em; margin: 6px 0; }
.trades li { flex-direction: column; align-items: stretch; gap: 2px; }
.pos { color: var(--green); }
.neg { color: var(--red); }
.breaks { color: var(--red); font-size: 12px; }
.shorts li { flex-direction: column; align-items: stretch; }
.shorts video { width: 100%; max-height: 360px; background: #000; border-radius: 4px; margin-top: 6px; }
.mono { font-family: var(--mono); font-size: 12px; }
@media (max-width: 700px) { .form-grid { grid-template-columns: 1fr; } }
.sub .bad { color: var(--red); font-weight: 600; } .sub .good { color: var(--green, #3ecf8e); }
a { color: var(--cyan); } a:visited { color: var(--cyan-dim); }
