/* ─── Root & Reset ────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:        #060810;
  --surface:   #0d1120;
  --surface2:  #141928;
  --border:    #1e2840;
  --accent:    #f59e0b;
  --accent2:   #fbbf24;
  --green:     #10b981;
  --red:       #ef4444;
  --amber:     #f59e0b;
  --blue:      #3b82f6;
  --text:      #e2e8f0;
  --text-muted:#64748b;
  --text-dim:  #94a3b8;
  --font:      'Inter', sans-serif;
  --mono:      'JetBrains Mono', monospace;
  --radius:    12px;
  --radius-sm: 8px;
}

html, body { height: 100%; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

/* ─── Header ─────────────────────────────────────────────────────────────── */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(12px);
}
.header-left { display: flex; align-items: center; gap: 10px; }
.logo {
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: var(--accent);
}
.project-badge {
  font-family: var(--mono);
  font-size: 0.65rem;
  color: var(--text-muted);
  background: var(--bg);
  border: 1px solid var(--border);
  padding: 2px 8px;
  border-radius: 4px;
}
.header-right { display: flex; align-items: center; gap: 10px; }
.connection-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--text-muted);
  transition: background 0.4s;
}
.connection-dot.connected    { background: var(--green); box-shadow: 0 0 6px var(--green); }
.connection-dot.disconnected { background: var(--red); }
.last-updated { font-size: 0.7rem; color: var(--text-muted); font-family: var(--mono); }
.logout-btn {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 1rem;
  padding: 4px 8px;
  border-radius: 6px;
  transition: color 0.2s;
}
.logout-btn:hover { color: var(--red); }

/* ─── Nav Tabs ────────────────────────────────────────────────────────────── */
.dash-nav {
  display: flex;
  align-items: center;
  gap: 0;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 16px;
}
.nav-tab {
  display: inline-flex;
  align-items: center;
  padding: 10px 18px;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  text-decoration: none;
  border-bottom: 2px solid transparent;
  transition: color 0.2s, border-color 0.2s;
  margin-bottom: -1px;
}
.nav-tab:hover  { color: var(--text); }
.nav-tab.active { color: var(--accent); border-bottom-color: var(--accent); }

/* ─── Status Bar ──────────────────────────────────────────────────────────── */
.status-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  scrollbar-width: none;
}
.status-bar::-webkit-scrollbar { display: none; }
.status-bar-label {
  font-size: 0.6rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  color: var(--text-muted);
  white-space: nowrap;
}
.pod-pills { display: flex; gap: 8px; }
.pod-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 4px 10px;
  font-size: 0.72rem;
  font-weight: 500;
  white-space: nowrap;
  transition: all 0.3s;
}
.pod-pill.running { border-color: var(--green); }
.pod-pill.warning { border-color: var(--amber); }
.pod-pill.error   { border-color: var(--red); }
.pod-pill .dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--text-muted);
  flex-shrink: 0;
}
.pod-pill.running .dot { background: var(--green); box-shadow: 0 0 4px var(--green); }
.pod-pill.warning .dot { background: var(--amber); }
.pod-pill.error   .dot { background: var(--red); box-shadow: 0 0 4px var(--red); animation: pulse-red 1.5s infinite; }
.pod-pill .restarts {
  font-family: var(--mono);
  font-size: 0.6rem;
  color: var(--text-muted);
}
.skeleton {
  background: linear-gradient(90deg, var(--surface2) 25%, var(--border) 50%, var(--surface2) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  width: 80px; height: 28px;
  border-radius: 20px;
  border: none !important;
}
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }
@keyframes pulse-red { 0%, 100% { opacity: 1; } 50% { opacity: 0.5; } }

/* ─── Grid Layout ─────────────────────────────────────────────────────────── */
.grid {
  display: grid;
  gap: 12px;
  padding: 12px;
  grid-template-columns: 1fr;
  grid-template-areas:
    "signals"
    "decisions"
    "approvals"
    "trades"
    "research"
    "topics"
    "llm"
    "resources"
    "datasources";
}

  @media (min-width: 768px) {
  .grid {
    grid-template-columns: 1fr 1fr;
    grid-template-areas:
      "signals   decisions"
      "approvals trades"
      "research  research"
      "topics    llm"
      "resources resources"
      "datasources datasources";
  }
}

@media (min-width: 1200px) {
  .grid {
    grid-template-columns: 1fr 1fr 1fr;
    grid-template-areas:
      "signals   decisions  approvals"
      "trades    research   research"
      "topics    llm        resources"
      "datasources datasources datasources";
  }
}

.card-signals    { grid-area: signals; }
.card-decisions  { grid-area: decisions; }
.card-approvals  { grid-area: approvals; }
.card-trades     { grid-area: trades; }
.card-research   { grid-area: research; }
.card-topics     { grid-area: topics; }
.card-llm        { grid-area: llm; }
.card-resources  { grid-area: resources; }
.card-datasources { grid-area: datasources; }

/* ─── Cards ──────────────────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px 10px;
  border-bottom: 1px solid var(--border);
}
.card-title {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  color: var(--text-dim);
}
.card-badge {
  font-size: 0.62rem;
  font-family: var(--mono);
  color: var(--accent);
  background: rgba(245, 158, 11, 0.1);
  border: 1px solid rgba(245, 158, 11, 0.25);
  padding: 2px 7px;
  border-radius: 4px;
}
.paper-badge { color: var(--blue); background: rgba(59,130,246,0.1); border-color: rgba(59,130,246,0.25); }

/* ─── Feed ────────────────────────────────────────────────────────────────── */
.feed {
  flex: 1;
  overflow-y: auto;
  max-height: 320px;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
  padding: 4px 0;
}
.feed-empty {
  padding: 20px 14px;
  font-size: 0.75rem;
  color: var(--text-muted);
  font-style: italic;
  text-align: center;
}
.feed-item {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  animation: fadeInDown 0.3s ease;
}
.feed-item:last-child { border-bottom: none; }
@keyframes fadeInDown {
  from { opacity: 0; transform: translateY(-8px); }
  to   { opacity: 1; transform: translateY(0); }
}
.feed-item-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}
.feed-time {
  font-family: var(--mono);
  font-size: 0.6rem;
  color: var(--text-muted);
  flex-shrink: 0;
}
.feed-asset {
  font-weight: 600;
  font-size: 0.8rem;
}
.signal-tag {
  font-size: 0.62rem;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 4px;
  letter-spacing: 0.06em;
  margin-left: auto;
}
.tag-strong-buy  { background: rgba(16,185,129,0.2); color: #10b981; border: 1px solid rgba(16,185,129,0.3); }
.tag-buy         { background: rgba(16,185,129,0.1); color: #34d399; border: 1px solid rgba(16,185,129,0.2); }
.tag-neutral     { background: rgba(100,116,139,0.15); color: #94a3b8; border: 1px solid rgba(100,116,139,0.2); }
.tag-sell        { background: rgba(239,68,68,0.1); color: #f87171; border: 1px solid rgba(239,68,68,0.2); }
.tag-strong-sell { background: rgba(239,68,68,0.2); color: #ef4444; border: 1px solid rgba(239,68,68,0.3); }
.tag-approved    { background: rgba(16,185,129,0.2); color: #10b981; border: 1px solid rgba(16,185,129,0.3); }
.tag-rejected    { background: rgba(239,68,68,0.2); color: #ef4444; border: 1px solid rgba(239,68,68,0.3); }
.feed-reasoning {
  font-size: 0.73rem;
  color: var(--text-dim);
  line-height: 1.4;
}
.feed-meta {
  display: flex;
  gap: 10px;
  margin-top: 4px;
  font-family: var(--mono);
  font-size: 0.65rem;
  color: var(--text-muted);
}
.conf-bar {
  height: 2px;
  background: var(--border);
  border-radius: 2px;
  margin-top: 6px;
  overflow: hidden;
}
.conf-fill {
  height: 100%;
  border-radius: 2px;
  background: var(--green);
  transition: width 0.5s ease;
}

/* ─── P&L Summary ─────────────────────────────────────────────────────────── */
.pnl-summary {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border);
}
.pnl-item {
  flex: 1;
  padding: 10px 12px;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.pnl-item:last-child { border-right: none; }
.pnl-label { font-size: 0.62rem; color: var(--text-muted); letter-spacing: 0.05em; }
.pnl-value { font-size: 0.9rem; font-weight: 600; font-family: var(--mono); }

/* ─── Research ────────────────────────────────────────────────────────────── */
.research-summary {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  min-height: 80px;
}
.summary-placeholder {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-style: italic;
}
.summary-text {
  font-size: 0.78rem;
  color: var(--text-dim);
  line-height: 1.6;
  white-space: pre-wrap;
}
.summary-text strong { color: var(--accent); }
.summary-meta {
  font-family: var(--mono);
  font-size: 0.6rem;
  color: var(--text-muted);
  margin-top: 8px;
}
.summarise-btn {
  margin: 10px 14px;
  padding: 8px 14px;
  background: rgba(245,158,11,0.1);
  border: 1px solid rgba(245,158,11,0.3);
  border-radius: var(--radius-sm);
  color: var(--accent);
  font-family: var(--font);
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  text-align: center;
}
.summarise-btn:hover { background: rgba(245,158,11,0.2); transform: translateY(-1px); }
.summarise-btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

/* ─── Topics ──────────────────────────────────────────────────────────────── */
.topic-list { padding: 8px 14px; display: flex; flex-direction: column; gap: 6px; }
.topic-row  {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.73rem;
  gap: 8px;
}
.topic-name { font-family: var(--mono); color: var(--text-dim); flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topic-count {
  font-family: var(--mono);
  font-size: 0.68rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 4px;
  background: var(--surface2);
  color: var(--text-muted);
  min-width: 40px;
  text-align: center;
}
.topic-count.backlogged { background: rgba(239,68,68,0.15); color: var(--red); }

/* ─── LLM ──────────────────────────────────────────────────────────────────── */
.llm-models { padding: 8px 14px; display: flex; flex-direction: column; gap: 6px; }
.llm-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.73rem;
  padding: 6px 8px;
  border-radius: 6px;
  background: var(--surface2);
}
.llm-name { font-family: var(--mono); color: var(--text); }
.llm-tag  { font-size: 0.62rem; color: var(--accent); font-weight: 500; }

/* ─── Resources ───────────────────────────────────────────────────────────── */
.resource-list { padding: 8px 14px; display: flex; flex-direction: column; gap: 8px; }
.resource-row  { font-size: 0.73rem; }
.resource-header {
  display: flex;
  justify-content: space-between;
  margin-bottom: 4px;
}
.resource-name  { color: var(--text); font-weight: 500; }
.resource-val   { font-family: var(--mono); color: var(--text-muted); font-size: 0.68rem; }
.resource-bar   { height: 4px; background: var(--border); border-radius: 2px; overflow: hidden; }
.resource-fill  {
  height: 100%;
  border-radius: 2px;
  background: linear-gradient(90deg, var(--accent), var(--green));
  transition: width 0.8s ease;
}

/* ─── Data Intake Table ──────────────────────────────────────────────────────── */
.ds-table { padding: 4px 0; overflow-y: auto; max-height: 340px; scrollbar-width: thin; scrollbar-color: var(--border) transparent; }
.ds-group-label {
  font-size: 0.58rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  color: var(--text-muted);
  padding: 8px 14px 4px;
  text-transform: uppercase;
  border-top: 1px solid var(--border);
}
.ds-group-label:first-child { border-top: none; }
.ds-row {
  display: grid;
  grid-template-columns: 80px 1fr 62px 52px 62px;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-bottom: 1px solid rgba(30,40,64,0.5);
  font-size: 0.7rem;
  transition: background 0.15s;
}
.ds-row:hover { background: var(--surface2); }
.ds-agent  { font-weight: 600; color: var(--accent); white-space: nowrap; }
.ds-source { color: var(--text-dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ds-freq   { font-family: var(--mono); color: var(--text-muted); text-align: right; }
.ds-calls  { font-family: var(--mono); color: var(--text-muted); text-align: right; }
.ds-live   {
  font-family: var(--mono);
  font-size: 0.65rem;
  font-weight: 600;
  text-align: right;
  color: var(--green);
}
.ds-live.na { color: var(--text-muted); font-weight: 400; }
.ds-type-badge {
  display: inline-block;
  font-size: 0.55rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  padding: 1px 5px;
  border-radius: 3px;
  margin-right: 4px;
  vertical-align: middle;
  text-transform: uppercase;
}
.ds-type-llm        { background: rgba(139,92,246,0.18); color: #c4b5fd; }
.ds-type-prices     { background: rgba(16,185,129,0.15); color: #34d399; }
.ds-type-dex        { background: rgba(59,130,246,0.15); color: #60a5fa; }
.ds-type-onchain    { background: rgba(245,158,11,0.15); color: #fbbf24; }
.ds-type-research   { background: rgba(236,72,153,0.15); color: #f472b6; }
.ds-type-web-search { background: rgba(14,165,233,0.15); color: #38bdf8; }
.ds-type-sentiment  { background: rgba(100,116,139,0.15); color: #94a3b8; }
.ds-header {
  display: grid;
  grid-template-columns: 80px 1fr 62px 52px 62px;
  gap: 6px;
  padding: 5px 14px;
  font-size: 0.58rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  text-transform: uppercase;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  position: sticky;
  top: 0;
  z-index: 1;
}

/* ─── Toast ───────────────────────────────────────────────────────────────── */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 999;
}
.toast {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 0.75rem;
  color: var(--text);
  animation: slideIn 0.3s ease, fadeOut 0.5s 3s forwards;
  max-width: 280px;
}
@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to   { transform: translateX(0); opacity: 1; }
}
@keyframes fadeOut { to { opacity: 0; transform: translateY(8px); } }
