/* FinPilot Live — terminal aesthetic (vibe C: dense neon data terminal).
   Pure presentation layer: no WebSocket logic, data flow, or content lives here. */
:root {
  --bg: #000000;
  --panel: #0a0a0c;
  --grid: #1e1e24;
  --text: #f2f2f0;
  --muted: #7d7d85;
  --amber: #ff9e2c;
  --amber-dim: rgba(255, 158, 44, 0.14);
  --up: #2bff88;
  --down: #ff5252;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --sans: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --dot-info: #6f6f78;
  --dot-warning: var(--amber);
  --dot-critical: var(--down);
  --critical: var(--down);
  --gold: var(--amber);
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  min-height: 100vh;
  /* faint scanline texture for the terminal feel */
  background-image: repeating-linear-gradient(
    to bottom,
    transparent 0px, transparent 3px,
    rgba(255, 255, 255, 0.012) 3px, rgba(255, 255, 255, 0.012) 4px
  );
}

/* ---------- header / ticker bar ---------- */
.topbar {
  border-bottom: 1px solid var(--grid);
  background: linear-gradient(to bottom, #0d0d10, #000);
  padding: 14px 24px 18px;
  position: sticky;
  top: 0;
  z-index: 5;
}
.brand { display: flex; align-items: center; gap: 12px; max-width: 1560px; margin: 0 auto; }
.brand h1 {
  margin: 0;
  font-family: var(--mono);
  font-weight: 700;
  font-size: 19px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.brand h1::after {
  content: " ▮";
  color: var(--amber);
  animation: blink 1.1s steps(1) infinite;
}
@keyframes blink { 50% { opacity: 0; } }
.brand p {
  margin: 3px 0 0;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.06em;
}
.pulse { width: 9px; height: 9px; border-radius: 50%; background: var(--up); flex-shrink: 0;
  box-shadow: 0 0 8px rgba(43, 255, 136, 0.9); animation: pulse 1.6s infinite; }
@keyframes pulse {
  70% { box-shadow: 0 0 0 8px rgba(43, 255, 136, 0); }
  100% { box-shadow: 0 0 0 0 rgba(43, 255, 136, 0); }
}

/* ---------- hero metrics: dense quote-monitor strip ---------- */
.metrics {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 1px;
  background: var(--grid);
  border: 1px solid var(--grid);
  margin: 16px auto 0;
  max-width: 1560px;
}
@media (max-width: 1100px) { .metrics { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 640px) { .metrics { grid-template-columns: repeat(2, 1fr); } }
.metric { background: var(--panel); padding: 12px 16px 14px; min-width: 0; }
.metric label {
  display: block;
  font-family: var(--mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.2em;
  color: var(--muted);
  margin-bottom: 6px;
  white-space: nowrap;
}
.metric b {
  font-family: var(--mono);
  font-weight: 700;
  font-size: 26px;
  line-height: 1.1;
  letter-spacing: 0;
  font-variant-numeric: tabular-nums;
  color: var(--amber);
  transition: text-shadow 0.5s ease;
}
.metric.flash b { text-shadow: 0 0 18px rgba(255, 158, 44, 0.8); }
.metric.alert b { color: var(--down); }

/* ---------- layout ---------- */
.layout {
  display: grid;
  grid-template-columns: 1.5fr 1fr;
  gap: 1px;
  background: var(--grid);
  border-left: 1px solid var(--grid);
  border-right: 1px solid var(--grid);
  border-bottom: 1px solid var(--grid);
  max-width: 1560px;
  margin: 0 auto;
  /* stretch to fill the viewport so no blank void sits under the panels */
  min-height: calc(100vh - 235px);
  align-items: stretch;
}
@media (max-width: 950px) { .layout { grid-template-columns: 1fr; } }
.feed-col, .manager-col {
  background: var(--bg);
  padding: 20px 22px 24px;
  min-width: 0;
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.col-head {
  /* fixed header band so left and right panels start at the exact same level */
  min-height: 62px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}
.col-head h2 {
  margin: 0;
  font-family: var(--mono);
  font-weight: 700;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.24em;
  color: var(--text);
}
.col-head h2::before { content: "▸ "; color: var(--amber); }
.hint { color: var(--muted); font-size: 12px; font-family: var(--mono); display: block; margin: 6px 0 0; }

/* ---------- agent feed: terminal blotter ---------- */
.feed {
  display: flex; flex-direction: column;
  margin-top: 16px;
  /* fill the stretched column instead of leaving a fixed empty box */
  flex: 1;
  min-height: 120px;
  overflow-y: auto;
  border-top: 1px solid var(--grid);
}
.card {
  padding: 10px 4px;
  border-bottom: 1px solid var(--grid);
  animation: rise 0.35s ease both;
}
@keyframes rise {
  from { opacity: 0; transform: translateY(10px); background: var(--amber-dim); }
  to { opacity: 1; transform: none; background: transparent; }
}
.card-head { display: flex; align-items: center; gap: 8px; font-family: var(--mono); }
.card-head::before {
  content: "";
  width: 7px; height: 7px;
  flex-shrink: 0;
  background: var(--dot-info);
}
.card.warning .card-head::before { background: var(--dot-warning); box-shadow: 0 0 6px rgba(255,158,44,.8); }
.card.critical .card-head::before { background: var(--dot-critical); box-shadow: 0 0 6px rgba(255,82,82,.8); }
.card-head .agent { font-size: 11px; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase; }
.badge { font-size: 10px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted); }
.card.warning .badge { color: var(--amber); }
.card.critical .badge { color: var(--down); }
.card-head time { margin-left: auto; color: var(--muted); font-size: 11px; }
.card p {
  margin: 8px 0 0;
  font-size: 13.5px;
  line-height: 1.55;
  color: #e8e8e6;
}
.nums {
  margin-top: 8px;
  font-size: 11px;
  color: var(--muted);
  font-family: var(--mono);
  word-break: break-word;
  line-height: 1.6;
}
.review-tag {
  display: inline-block;
  font-size: 10px;
  font-family: var(--mono);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--amber);
  border: 1px solid rgba(255, 158, 44, 0.4);
  padding: 3px 10px;
  margin-top: 10px;
}

/* ---------- finance manager: focus panel ---------- */
.manager-card { position: relative; }
.mgr-head {
  display: flex;
  gap: 12px;
  align-items: center;
  /* same fixed band as the feed header — both columns level */
  min-height: 62px;
}
.mgr-avatar { font-size: 22px; }
.mgr-head h2 {
  margin: 0;
  font-family: var(--mono);
  font-weight: 700;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.24em;
}
.mgr-head h2::before { content: "▸ "; color: var(--amber); }
.mgr-head p { margin: 6px 0 0; color: var(--muted); font-size: 12px; font-family: var(--mono); }
.synth-list {
  margin: 16px 0 20px;
  display: flex;
  flex-direction: column;
  border-top: 1px solid var(--grid);
  /* grow with the stretched column so no gap opens under the panel */
  flex: 1;
  min-height: 0;
  overflow-y: auto;
}
.synth {
  font-size: 14px;
  line-height: 1.6;
  color: #f5f5f3;
  padding: 12px 4px 12px 14px;
  border-bottom: 1px solid var(--grid);
  border-left: 2px solid var(--amber);
  animation: rise 0.35s ease both;
}
.synth time { display: block; font-family: var(--mono); color: var(--muted); font-size: 11px; margin-top: 6px; }
.empty { color: var(--muted); font-size: 12px; font-family: var(--mono); padding: 12px 4px; }

/* amber block CTA */
.cta {
  display: inline-block;
  padding: 12px 28px;
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #000;
  background: var(--amber);
  border: none;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.cta:hover { transform: translateY(-1px); box-shadow: 0 0 22px rgba(255, 158, 44, 0.45); }
.cta:disabled { opacity: 0.5; cursor: wait; transform: none; box-shadow: none; }

.reco { margin-top: 20px; border-top: 1px solid var(--grid); padding-top: 16px; }
.reco.hidden { display: none; }
.cash-compare { display: flex; gap: 12px; margin-bottom: 16px; }
.cash-box { flex: 1; background: var(--panel); border: 1px solid var(--grid); padding: 10px 14px; }
.cash-box label { font-family: var(--mono); font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.18em; }
.cash-box b { display: block; font-family: var(--mono); font-weight: 700; font-size: 22px; margin-top: 4px; font-variant-numeric: tabular-nums; }
.cash-box.after { border-color: rgba(255, 158, 44, 0.5); }
.cash-box.after b { color: var(--up); }
.reco-item {
  font-family: var(--mono);
  font-size: 12.5px;
  line-height: 1.65;
  padding: 10px 4px;
  border-bottom: 1px solid var(--grid);
  color: #e8e8e6;
}
.reco-item:last-child { border-bottom: none; }
.reco-item .impact { color: var(--up); font-weight: 700; }

.rule-card {
  margin-top: 20px;
  border: 1px dashed #3a3a42;
  padding: 12px 14px;
  font-size: 12px;
  font-family: var(--mono);
  line-height: 1.7;
  color: var(--muted);
}
.rule-card b { color: var(--text); }

/* ---------- 4-agent squad roster + snapshot badges (append-only) ---------- */
.squad {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1px;
  background: var(--grid);
  border: 1px solid var(--grid);
  margin-top: 16px;
}
@media (max-width: 1100px) { .squad { grid-template-columns: repeat(2, 1fr); } }
.squad-item {
  background: var(--panel);
  padding: 9px 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.squad-dot { width: 7px; height: 7px; border-radius: 50%; background: #6f6f78; flex-shrink: 0; }
.squad-item.watching .squad-dot { background: var(--up); box-shadow: 0 0 6px rgba(43,255,136,.7); }
.squad-item.info .squad-dot { background: #6f6f78; }
.squad-item.warning .squad-dot { background: var(--amber); box-shadow: 0 0 6px rgba(255,158,44,.8); }
.squad-item.critical .squad-dot { background: var(--down); box-shadow: 0 0 6px rgba(255,82,82,.8); }
.squad-item.synthesis .squad-dot { background: var(--amber); box-shadow: 0 0 6px rgba(255,158,44,.8); }
.squad-name {
  font-family: var(--mono);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.squad-sub { margin-left: auto; font-family: var(--mono); font-size: 10px; color: var(--muted); white-space: nowrap; }
.badge.snap-badge {
  border: 1px dashed #3a3a42;
  padding: 1px 8px;
  color: var(--muted);
}
.card.snap { border-bottom-style: dashed; }
.synth.snap { border-left-style: dashed; }
.feed::-webkit-scrollbar, .synth-list::-webkit-scrollbar, .chat-list::-webkit-scrollbar { width: 8px; }
.feed::-webkit-scrollbar-thumb, .synth-list::-webkit-scrollbar-thumb { background: #2a2a31; }
.feed::-webkit-scrollbar-track, .synth-list::-webkit-scrollbar-track { background: transparent; }

/* ---------- Ask Finance chat (append-only; existing rules untouched) ---------- */
.chat-card { margin-top: 20px; border-top: 1px solid var(--grid); padding-top: 16px; }
.chat-head h2 {
  margin: 0;
  font-family: var(--mono);
  font-weight: 700;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.24em;
}
.chat-head h2::before { content: "▸ "; color: var(--amber); }
.chat-head p { margin: 4px 0 0; color: var(--muted); font-size: 12px; font-family: var(--mono); }
.chat-list {
  display: flex; flex-direction: column; gap: 10px;
  margin: 14px 0;
  max-height: 260px;
  overflow-y: auto;
}
.chat-msg {
  font-size: 13px;
  line-height: 1.6;
  padding: 9px 12px;
  max-width: 100%;
  animation: rise 0.3s ease both;
}
.chat-msg.user {
  font-family: var(--mono);
  color: var(--amber);
  border-right: 2px solid var(--amber);
  text-align: right;
}
.chat-msg.bot { color: #e8e8e6; background: var(--panel); border: 1px solid var(--grid); }
.chat-msg.thinking { color: var(--muted); font-family: var(--mono); font-size: 12px; }
.chat-sources { display: block; margin-top: 6px; font-family: var(--mono); font-size: 10.5px; color: var(--muted); }
.chat-input-row { display: flex; gap: 8px; }
.chat-input-row input {
  flex: 1; min-width: 0;
  background: var(--panel);
  border: 1px solid var(--grid);
  color: var(--text);
  font-family: var(--mono);
  font-size: 13px;
  padding: 11px 14px;
  outline: none;
}
.chat-input-row input:focus { border-color: rgba(255, 158, 44, 0.6); }
.chat-input-row input::placeholder { color: var(--muted); }
.cta.chat-cta { padding: 11px 22px; font-size: 12px; }
