@import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;500;600;700&family=Inter:wght@400;500;600;700&display=swap');

:root {
  --page: #0a0a0c;
  --panel: #101013;
  --panel-2: #15151a;
  --raised: #1a1a20;
  --line: #232329;
  --ink: #f4f4f6;
  --dim: #7e808a;
  --dimmer: #5a5c64;
  --teal: #2fd8a8;
  --teal-ink: #05130e;
  --teal-dim: #175744;
  --red: #ff5f6d;
  --red-bg: #2a1418;
  --paper: #f4f5f2;
  --paper-ink: #0c0d0c;
  --mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;
  --sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  --sb: env(safe-area-inset-bottom, 0px);
  --st: env(safe-area-inset-top, 0px);
}
* { box-sizing: border-box; margin: 0; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
body {
  background: var(--page);
  color: var(--ink);
  font: 14px/1.5 var(--sans);
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}
@media (prefers-reduced-motion: reduce) { *, *::before { animation-duration: .01ms !important; transition-duration: .01ms !important; } }

/* ── gate ─────────────────────────────────────────────────────── */
#gate { display: flex; align-items: center; justify-content: center; height: 100dvh; padding: 24px; }
#gate[hidden] { display: none; }
.gate-box { width: 100%; max-width: 340px; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 26px; display: flex; flex-direction: column; gap: 12px; }
.gate-box .brand { margin-bottom: 4px; }
#gate input { background: var(--panel-2); border: 1px solid var(--line); color: var(--ink); border-radius: 8px; padding: 11px 13px; font: 13px var(--mono); }
#gate input:focus { outline: none; border-color: var(--teal); }

/* ── brand ────────────────────────────────────────────────────── */
.brand, .side-brand { display: flex; align-items: center; gap: 9px; }
.brand-mark {
  width: 17px; height: 17px; flex: none; position: relative;
  background: conic-gradient(from 45deg, var(--teal), #1a9c78 55%, var(--teal));
  clip-path: polygon(50% 0, 100% 50%, 50% 100%, 0 50%);
}
.brand-word { font: 700 14px/1 var(--sans); letter-spacing: .16em; text-transform: uppercase; }

/* ── shell layout ─────────────────────────────────────────────── */
#shell { display: grid; grid-template-columns: 232px 1fr; height: 100dvh; }
#shell[hidden] { display: none; }

#sidebar {
  background: var(--panel); border-right: 1px solid var(--line);
  display: flex; flex-direction: column; padding: 18px 14px 14px;
  overflow-y: auto;
}
.side-brand { padding: 0 6px 20px; }
.side-nav { display: flex; flex-direction: column; gap: 2px; }
.nav-item {
  display: flex; align-items: center; gap: 10px; width: 100%;
  background: none; border: none; color: var(--dim);
  font: 500 13px/1 var(--sans); padding: 10px 10px; border-radius: 8px;
  cursor: pointer; text-align: left; transition: background .15s, color .15s;
}
.nav-item svg { width: 17px; height: 17px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; }
.nav-item:hover { color: var(--ink); background: var(--panel-2); }
.nav-item.active { background: var(--raised); color: var(--ink); box-shadow: inset 2px 0 0 var(--teal); }

/* guardrails card */
.guardrails { margin-top: auto; background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px; padding: 12px; }
.gr-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 11px; }
.gr-title { display: flex; align-items: center; gap: 6px; font: 600 11px/1 var(--sans); }
.gr-title .ico { width: 13px; height: 13px; fill: none; stroke: var(--teal); stroke-width: 1.7; }
.gr-row { display: flex; justify-content: space-between; font: 10px/1 var(--mono); color: var(--dim); margin-bottom: 6px; }
.gr-val { color: var(--ink); }
.gr-note { font: 9.5px/1.45 var(--sans); color: var(--dimmer); margin-top: 9px; }

/* striped progress bar — from the reference */
.bar-striped { height: 6px; border-radius: 3px; background: var(--raised); overflow: hidden; }
.bar-striped > i {
  display: block; height: 100%;
  background-image: repeating-linear-gradient(45deg, var(--teal) 0 4px, #1fae86 4px 8px);
}

/* ── main ─────────────────────────────────────────────────────── */
#main { display: flex; flex-direction: column; overflow: hidden; }
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(11px + var(--st)) 22px 11px; border-bottom: 1px solid var(--line); flex: none;
}
.crumbs { font: 11px/1 var(--mono); letter-spacing: .04em; display: flex; gap: 7px; align-items: center; }
.crumbs .sep { color: var(--dimmer); }
.top-right { display: flex; align-items: center; gap: 12px; }
.conn { display: flex; align-items: center; gap: 6px; font: 10px/1 var(--mono); text-transform: uppercase; letter-spacing: .08em; color: var(--dim); }
.dot { width: 6px; height: 6px; border-radius: 50%; background: var(--dimmer); }
.dot.on { background: var(--teal); box-shadow: 0 0 7px 1px rgba(47,216,168,.5); }
.avatar-chip { width: 28px; height: 28px; border-radius: 8px; background: var(--raised); border: 1px solid var(--line); display: grid; place-items: center; font-size: 14px; }

.views { flex: 1; overflow-y: auto; padding: 22px 22px 40px; }
.view { display: none; }
.view.active { display: block; }
.page-head { margin-bottom: 18px; }
.page-head h1 { font: 600 22px/1.2 var(--sans); letter-spacing: -.01em; }
.dim { color: var(--dim); }
.sm { font-size: 12px; }

/* ── stat cards row ───────────────────────────────────────────── */
.stat-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 12px; }
.stat {
  background: linear-gradient(150deg, var(--panel-2), var(--panel) 70%);
  border: 1px solid var(--line); border-radius: 11px; padding: 14px 15px 12px;
}
.stat-l { font: 10px/1 var(--mono); letter-spacing: .12em; text-transform: uppercase; color: var(--dim); }
.stat-v { font: 600 21px/1.25 var(--mono); margin-top: 9px; letter-spacing: -.01em; }
.stat-f { display: flex; align-items: center; justify-content: space-between; margin-top: 11px; padding-top: 9px; border-top: 1px solid var(--line); font: 10px/1 var(--mono); color: var(--dim); }
.stat-f .up { color: var(--teal); }
.stat-f .down { color: var(--red); }
.arrow-box { width: 17px; height: 17px; border: 1px solid var(--line); border-radius: 4px; display: grid; place-items: center; color: var(--dim); font-size: 9px; }

/* ── panels ───────────────────────────────────────────────────── */
.grid-2 { display: grid; grid-template-columns: 1.62fr 1fr; gap: 12px; margin-bottom: 12px; align-items: start; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 11px; overflow: hidden; }
.panel-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; padding: 15px 16px 12px; }
.panel-title { font: 600 14px/1.2 var(--sans); }
.panel-sub { font: 11px/1.4 var(--sans); color: var(--dim); margin-top: 3px; }
.panel-body { padding: 0 16px 16px; }
.seg { display: flex; gap: 2px; background: var(--panel-2); border: 1px solid var(--line); border-radius: 20px; padding: 2px; flex: none; }
.seg span { font: 10px/1 var(--mono); padding: 5px 9px; border-radius: 20px; color: var(--dim); }
.seg span.on { background: var(--ink); color: var(--page); font-weight: 600; }

/* ── dot-matrix column chart — the signature element ──────────── */
.chart { display: flex; gap: 14px; padding: 4px 16px 14px; }
.chart-y { display: flex; flex-direction: column; justify-content: space-between; font: 9.5px/1 var(--mono); color: var(--dimmer); padding: 2px 0 18px; flex: none; }
.chart-cols { flex: 1; display: flex; align-items: flex-end; gap: 3px; height: 172px; }
.ccol { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; gap: 3px; align-items: center; height: 100%; }
/* dots only where there's data — empty cells stay invisible, like the reference */
.ccol i { width: 100%; height: 3.5px; border-radius: .5px; background: #fff; }
.ccol i.lo { background: transparent; }
.ccol b { font: 9px/1 var(--mono); color: var(--dimmer); font-weight: 400; margin-top: 9px; }

/* ── white contrast card (Market Regime equivalent) ───────────── */
.panel.paper { background: var(--paper); color: var(--paper-ink); border-color: transparent; }
.panel.paper .panel-sub, .panel.paper .dim { color: #6b6f6a; }
.paper-big { font: 600 30px/1 var(--mono); letter-spacing: -.02em; }
.paper-big small { font-size: 15px; color: #6b6f6a; font-weight: 500; }
/* uniform-height level meter, dark = filled, light = remainder (as in the reference) */
.eq { display: flex; gap: 2px; height: 24px; margin: 15px 0 6px; }
.eq i { flex: 1; background: var(--paper-ink); border-radius: .5px; height: 100%; }
.eq i.off { background: #d2d5d0; }
.prow { display: flex; align-items: center; justify-content: space-between; padding: 8px 0; border-top: 1px solid rgba(12,13,12,.09); font-size: 12.5px; }
.prow:first-of-type { border-top: none; }
.prow .l { display: flex; align-items: center; gap: 8px; }
.prow .v { font: 500 12.5px var(--mono); }
.swatch { width: 3px; height: 13px; border-radius: 2px; flex: none; }
.btn-dark { width: 100%; background: var(--paper-ink); color: var(--paper); border: none; border-radius: 8px; padding: 11px; font: 600 11.5px/1 var(--sans); letter-spacing: .02em; cursor: pointer; margin-top: 12px; }

/* ── table rows (Open Positions equivalent) ───────────────────── */
.trow { display: flex; align-items: center; gap: 12px; padding: 11px 16px; border-top: 1px solid var(--line); }
.trow:hover { background: var(--panel-2); }
.tok { width: 30px; height: 30px; border-radius: 50%; flex: none; display: grid; place-items: center; font: 700 11px var(--mono); color: #08100d; }
.tmain { flex: 1; min-width: 0; }
.tname { font: 600 12.5px/1.3 var(--sans); display: flex; align-items: center; gap: 7px; }
.tmeta { font: 10px/1.4 var(--mono); color: var(--dim); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tval { text-align: right; flex: none; }
.tval .k { font: 9px/1 var(--mono); letter-spacing: .08em; text-transform: uppercase; color: var(--dimmer); }
.tval .n { font: 600 12px/1 var(--mono); margin-top: 4px; }
.tval .n.up { color: var(--teal); }
.tval .n.down { color: var(--red); }
.tacts { display: flex; gap: 6px; flex: none; }
.btn-ghost, .btn-danger {
  font: 500 10.5px/1 var(--sans); padding: 7px 11px; border-radius: 6px; cursor: pointer;
  border: 1px solid var(--line); background: var(--raised); color: var(--ink);
}
.btn-danger { background: var(--red-bg); border-color: #43202a; color: var(--red); }
.btn-primary { background: var(--teal); color: var(--teal-ink); border: none; border-radius: 8px; padding: 10px 15px; font: 600 12px/1 var(--sans); cursor: pointer; }

/* ── agent cards (Active AI Agents equivalent) ────────────────── */
.acard { background: var(--panel-2); border: 1px solid var(--line); border-radius: 9px; padding: 12px; margin: 0 16px 10px; }
.ahead { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.aname { font: 600 12.5px/1.2 var(--sans); display: flex; align-items: center; gap: 7px; }
.asub { font: 10px/1 var(--mono); color: var(--dim); margin-top: 4px; }
.atot { text-align: right; font: 9px/1 var(--mono); color: var(--dimmer); text-transform: uppercase; letter-spacing: .07em; }
.atot b { display: block; font: 600 13px/1 var(--mono); color: var(--teal); margin-top: 4px; letter-spacing: 0; }
.astats { display: flex; gap: 16px; margin: 12px 0 9px; }
.astat { font: 9px/1 var(--mono); color: var(--dimmer); text-transform: uppercase; letter-spacing: .06em; }
.astat b { display: block; font: 600 12px/1 var(--mono); color: var(--ink); margin-bottom: 4px; letter-spacing: 0; text-transform: none; }

/* ── pills ────────────────────────────────────────────────────── */
.pill { display: inline-flex; align-items: center; gap: 5px; font: 600 8.5px/1 var(--mono); letter-spacing: .09em; text-transform: uppercase; border-radius: 20px; padding: 4px 8px; }
.pill::before { content: ""; width: 4px; height: 4px; border-radius: 50%; background: currentColor; }
.pill.ok { background: rgba(47,216,168,.12); color: var(--teal); }
.pill.off { background: var(--raised); color: var(--dim); }
.pill.warn { background: rgba(255,95,109,.12); color: var(--red); }

/* ── chat ─────────────────────────────────────────────────────── */
.chat-panel { display: flex; flex-direction: column; height: calc(100dvh - 210px); min-height: 340px; }
#chat-log { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 10px; }
.msg { max-width: 74%; padding: 10px 13px; border-radius: 12px; font-size: 13.5px; line-height: 1.55; white-space: pre-wrap; word-wrap: break-word; }
.msg.user { align-self: flex-end; background: var(--teal); color: var(--teal-ink); font-weight: 500; border-bottom-right-radius: 3px; }
.msg.agent { background: var(--panel-2); border: 1px solid var(--line); border-bottom-left-radius: 3px; }
.msg.pending { color: var(--dim); font-style: italic; }
.msg-row { display: flex; gap: 9px; align-items: flex-end; align-self: flex-start; max-width: 82%; }
.bot { width: 26px; height: 26px; border-radius: 7px; flex: none; background: var(--raised); border: 1px solid var(--line); display: grid; place-items: center; font-size: 13px; }
.bot.think { animation: bp 1.1s ease-in-out infinite; }
@keyframes bp { 0%,100% { opacity: .7 } 50% { opacity: 1; transform: scale(1.08) } }
.chat-bar { display: flex; gap: 9px; padding: 12px 14px calc(12px + var(--sb)); border-top: 1px solid var(--line); flex: none; }
.chat-bar textarea { flex: 1; resize: none; background: var(--panel-2); border: 1px solid var(--line); color: var(--ink); border-radius: 10px; padding: 11px 13px; font: 13.5px var(--sans); max-height: 110px; min-height: 44px; }
.chat-bar textarea:focus { outline: none; border-color: var(--teal); }
.chat-bar textarea::placeholder { color: var(--dimmer); }
.chat-bar button { width: 44px; height: 44px; flex: none; border: none; border-radius: 10px; background: var(--teal); cursor: pointer; display: grid; place-items: center; }
.chat-bar button svg { width: 17px; height: 17px; fill: none; stroke: var(--teal-ink); stroke-width: 2.2; stroke-linecap: round; }
.chat-bar button:disabled { opacity: .4 }

/* ── misc ─────────────────────────────────────────────────────── */
.add-row { display: flex; gap: 9px; padding: 0 16px 16px; flex-wrap: wrap; }
.add-row input { background: var(--panel-2); border: 1px solid var(--line); color: var(--ink); border-radius: 8px; padding: 11px 12px; font: 13px var(--sans); min-height: 44px; }
.add-row input[type=text] { flex: 1; min-width: 180px; }
.add-row input[type=date] { font-family: var(--mono); font-size: 12px; }
.add-row input::-webkit-calendar-picker-indicator { filter: invert(.7); }
.add-row input:focus { outline: none; border-color: var(--teal); }
.empty { padding: 16px; font: 11.5px var(--mono); color: var(--dimmer); }
.check { width: 20px; height: 20px; border: 1.5px solid var(--dim); border-radius: 50%; flex: none; cursor: pointer; position: relative; display: grid; place-items: center; }
.check::after { content: ""; position: absolute; inset: -10px; }
.check.done { background: var(--teal); border-color: var(--teal); }
.set-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 13px 16px; border-top: 1px solid var(--line); font-size: 13px; }
.set-row:first-child { border-top: none; }
.set-v { font: 12px var(--mono); color: var(--dim); }
.switch { width: 42px; height: 24px; border-radius: 13px; background: var(--raised); border: 1px solid var(--line); position: relative; cursor: pointer; flex: none; }
.switch::after { content: ""; position: absolute; top: 2px; left: 2px; width: 18px; height: 18px; border-radius: 50%; background: var(--dim); transition: transform .16s, background .16s; }
.switch.on { background: var(--teal-dim); border-color: var(--teal); }
.switch.on::after { transform: translateX(18px); background: var(--teal); }
.lrow { display: flex; gap: 12px; padding: 10px 16px; border-top: 1px solid var(--line); align-items: baseline; }
.lrow:first-child { border-top: none; }
.lkind { font: 9px/1.6 var(--mono); letter-spacing: .07em; text-transform: uppercase; color: var(--dimmer); width: 78px; flex: none; }
.ltext { flex: 1; font-size: 12.5px; word-break: break-word; }
.ltime { font: 10px var(--mono); color: var(--dimmer); flex: none; }

#mobnav { display: none; }

/* ── responsive ───────────────────────────────────────────────── */
@media (max-width: 900px) {
  .stat-row { grid-template-columns: 1fr 1fr; }
  .grid-2 { grid-template-columns: 1fr; }
}
@media (max-width: 720px) {
  #shell { grid-template-columns: 1fr; }
  #sidebar { display: none; }
  .views { padding: 16px 14px calc(80px + var(--sb)); }
  .topbar { padding: calc(10px + var(--st)) 14px 10px; }
  .page-head h1 { font-size: 19px; }
  .chart { padding: 4px 12px 12px; }
  .chat-panel { height: calc(100dvh - 250px); }
  .trow { flex-wrap: wrap; }
  .tval { text-align: left; }
  #mobnav {
    display: flex; position: fixed; bottom: 0; left: 0; right: 0; z-index: 20;
    background: var(--panel); border-top: 1px solid var(--line);
    padding-bottom: var(--sb);
  }
  #mobnav button {
    flex: 1; background: none; border: none; color: var(--dim); cursor: pointer;
    display: flex; flex-direction: column; align-items: center; gap: 4px;
    padding: 9px 0 7px; font: 8.5px/1 var(--mono); letter-spacing: .05em; text-transform: uppercase;
  }
  #mobnav button svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; }
  #mobnav button.active { color: var(--teal); }
}
