/* Omniblock — Black & White CRT Terminal */
:root {
  --bg-base:        #000000;
  --bg-card:        #080808;
  --bg-hover:       #111111;
  --border:         #2a2a2a;
  --border-bright:  #555555;
  --text-primary:   #e8e8e8;
  --text-secondary: #666666;
  --text-dim:       #333333;
  --accent:         #ffffff;
  --accent-green:   #ccffcc;
  --accent-red:     #ffcccc;
  --accent-amber:   #fff0cc;
  --accent-blue:    #ccddff;
  --glow:           0 0 8px rgba(255,255,255,0.4);
  --glow-md:        0 0 16px rgba(255,255,255,0.25);
  --font: "JetBrains Mono", "Fira Code", "Courier New", Courier, monospace;
  --mono: "JetBrains Mono", "Fira Code", "Courier New", Courier, monospace;
}

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

/* ── Body + scanlines ─────────────────────────────────────────────────────── */
body {
  background: var(--bg-base);
  color: var(--text-primary);
  font-family: var(--font);
  font-size: 13px;
  min-height: 100vh;
  overflow-x: hidden;
}

body::after {
  content: '';
  position: fixed;
  inset: 0;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 3px,
    rgba(0,0,0,0.08) 3px,
    rgba(0,0,0,0.08) 4px
  );
  pointer-events: none;
  z-index: 9000;
}

/* ── Topbar ───────────────────────────────────────────────────────────────── */
.topbar {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0 1rem;
  height: 48px;
  background: var(--bg-base);
  border-bottom: 1px solid var(--border-bright);
  position: sticky;
  top: 0;
  z-index: 100;
}

.topbar__logo {
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: var(--accent);
  text-shadow: var(--glow);
  white-space: nowrap;
  text-transform: uppercase;
  cursor: pointer;
  user-select: none;
  transition: text-shadow 0.15s, opacity 0.15s;
}
.topbar__logo:hover { text-shadow: var(--glow-md); opacity: 0.85; }

.topbar__nav {
  display: flex;
  gap: 0;
  flex: 1;
  overflow: hidden;
}

.topbar__right {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 11px;
  color: var(--text-secondary);
  white-space: nowrap;
  margin-left: auto;
}

/* ── Nav buttons ──────────────────────────────────────────────────────────── */
.nav-btn {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 0 0.75rem;
  height: 48px;
  font-size: 11px;
  font-family: var(--font);
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  transition: color 0.1s, border-color 0.1s;
}
.nav-btn:hover { color: var(--text-primary); border-bottom-color: var(--border-bright); }
.nav-btn.active { color: var(--accent); border-bottom-color: var(--accent); text-shadow: var(--glow); }

/* ── Hamburger (mobile only) ──────────────────────────────────────────────── */
.nav-hamburger {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  background: none;
  border: 1px solid var(--border-bright);
  border-radius: 4px;
  padding: 6px 8px;
  cursor: pointer;
  margin-left: auto;
  flex-shrink: 0;
}
.nav-hamburger span {
  display: block;
  width: 18px;
  height: 1px;
  background: var(--text-primary);
  transition: transform 0.2s, opacity 0.2s;
}
.nav-hamburger.open span:nth-child(1) { transform: translateY(6px) rotate(45deg); }
.nav-hamburger.open span:nth-child(2) { opacity: 0; }
.nav-hamburger.open span:nth-child(3) { transform: translateY(-6px) rotate(-45deg); }

/* ── Mobile nav drawer ────────────────────────────────────────────────────── */
.nav-drawer {
  display: none;
  position: fixed;
  top: 48px;
  left: 0;
  right: 0;
  background: var(--bg-base);
  border-bottom: 1px solid var(--border-bright);
  z-index: 101;
  flex-direction: column;
  padding: 0.5rem 0;
  max-height: calc(100vh - 48px);
  overflow-y: auto;
}
.nav-drawer.open { display: flex; animation: drawerIn 0.15s ease forwards; }
.nav-drawer .nav-btn {
  height: 44px;
  text-align: left;
  padding: 0 1.5rem;
  border-bottom: none;
  border-left: 2px solid transparent;
  width: 100%;
}
.nav-drawer .nav-btn.active {
  border-left-color: var(--accent);
  border-bottom: none;
  background: var(--bg-hover);
}
.nav-drawer-footer {
  display: flex;
  align-items: center;
  padding: 0.75rem 1.5rem;
  border-top: 1px solid var(--border);
  margin-top: auto;
}

/* ── WebSocket status dot ─────────────────────────────────────────────────── */
.status-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}
.status-dot--connected    { background: var(--accent); box-shadow: var(--glow); }
.status-dot--disconnected { background: var(--text-dim); }
.status-dot--error        { background: var(--accent-red); }

/* ── Layout ───────────────────────────────────────────────────────────────── */
.layout { padding: 1rem; max-width: 1400px; margin: 0 auto; }
.view { display: none; }
.view.active { display: block; }

/* ── Cards / terminal windows ─────────────────────────────────────────────── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 0;
  padding: 1.25rem;
  margin-bottom: 1rem;
  position: relative;
}
.card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 1px;
  background: var(--border-bright);
  opacity: 0.5;
}
.card h2 {
  font-size: 10px;
  margin-bottom: 1rem;
  color: var(--text-secondary);
  font-weight: 700;
  letter-spacing: 0.15em;
  text-transform: uppercase;
}

/* ── Two-column layout ────────────────────────────────────────────────────── */
.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

/* ── Price grid ───────────────────────────────────────────────────────────── */
.prices-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 0.5rem;
  margin-bottom: 1rem;
}
.price-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  padding: 0.75rem;
  cursor: default;
  transition: border-color 0.15s, transform 0.12s, box-shadow 0.12s;
}
.price-card:hover { border-color: var(--border-bright); transform: translateY(-2px); box-shadow: 0 4px 12px rgba(0,0,0,0.4); }
.price-card__symbol {
  font-size: 10px;
  color: var(--text-secondary);
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}
.price-card__price  {
  font-size: 1.2rem;
  font-family: var(--mono);
  font-weight: 700;
  margin: 0.2rem 0;
  color: var(--accent);
}
.price-card__change { font-size: 11px; font-family: var(--mono); }
.price-card__change--up   { color: var(--accent-green); }
.price-card__change--down { color: var(--accent-red); }

/* ── Chart ────────────────────────────────────────────────────────────────── */
.chart-canvas { width: 100%; height: 300px; display: block; }

/* ── Forms ────────────────────────────────────────────────────────────────── */
.form { display: flex; flex-direction: column; gap: 0.6rem; }
.form--inline { flex-direction: row; align-items: center; flex-wrap: wrap; }
.form label {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  font-size: 10px;
  color: var(--text-secondary);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.form--inline label { flex-direction: row; align-items: center; text-transform: none; }

input, select, textarea {
  background: var(--bg-base);
  border: 1px solid var(--border);
  border-radius: 0;
  color: var(--text-primary);
  padding: 0.5rem 0.6rem;
  font-size: 12px;
  font-family: var(--font);
  outline: none;
  transition: border-color 0.1s;
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--border-bright);
  box-shadow: 0 0 0 1px var(--border-bright);
}
select { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%23666'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 0.6rem center; padding-right: 1.8rem; }

.hidden { display: none !important; }

/* ── Buttons ──────────────────────────────────────────────────────────────── */
.btn {
  border: 1px solid var(--border-bright);
  border-radius: 0;
  cursor: pointer;
  font-size: 11px;
  font-family: var(--font);
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 0.5rem 1rem;
  transition: background 0.1s, color 0.1s, box-shadow 0.1s, transform 0.1s, opacity 0.1s;
  white-space: nowrap;
  background: transparent;
  color: var(--text-primary);
}
.btn:hover:not(:disabled) {
  background: var(--bg-hover);
  box-shadow: var(--glow-md);
}
.btn:disabled { opacity: 0.35; cursor: not-allowed; }
.btn--primary { background: var(--accent); color: var(--bg-base); border-color: var(--accent); }
.btn--primary:hover:not(:disabled) { background: #cccccc; color: var(--bg-base); box-shadow: var(--glow); }
.btn--accent  { background: transparent; border-color: var(--text-primary); color: var(--text-primary); }
.btn--ghost   { background: transparent; border-color: var(--border); color: var(--text-secondary); }
.btn--ghost:hover:not(:disabled) { border-color: var(--border-bright); color: var(--text-primary); box-shadow: none; }
.btn--danger  { border-color: var(--accent-red); color: var(--accent-red); background: transparent; }
.btn--danger:hover:not(:disabled) { background: rgba(255,100,100,0.1); }
.btn--sm      { padding: 0.3rem 0.6rem; font-size: 10px; }

/* ── Chat ─────────────────────────────────────────────────────────────────── */
.chat-messages {
  max-height: 300px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 1rem;
  padding-right: 0.25rem;
  border: 1px solid var(--border);
  padding: 0.75rem;
  background: var(--bg-base);
}
.chat-msg {
  padding: 0.4rem 0.6rem;
  max-width: 85%;
  font-size: 12px;
  line-height: 1.6;
  border: 1px solid var(--border);
}
.chat-msg--user {
  align-self: flex-end;
  border-color: var(--border-bright);
  color: var(--accent);
}
.chat-msg--ai {
  align-self: flex-start;
  background: var(--bg-hover);
  color: var(--text-primary);
}

/* ── Signal card ──────────────────────────────────────────────────────────── */
.signal-card {
  margin-top: 1rem;
  padding: 1rem;
  border: 1px solid var(--border);
  background: var(--bg-base);
}
.signal-card--bullish { border-color: var(--border-bright); }
.signal-card--bearish { border-color: var(--border-bright); }
.signal-card--neutral { border-color: var(--border); }
.signal-card--alert   { border-color: var(--border-bright); }
.signal-card__type    { font-weight: 700; text-transform: uppercase; font-size: 10px; letter-spacing: 0.12em; color: var(--accent); text-shadow: var(--glow); }
.signal-card__confidence { font-size: 11px; color: var(--text-secondary); margin: 0.2rem 0; }
.signal-card__rationale  { font-size: 12px; line-height: 1.6; }

/* ── Code / pre ───────────────────────────────────────────────────────────── */
.code-block {
  background: var(--bg-base);
  border: 1px solid var(--border);
  padding: 0.75rem;
  font-family: var(--mono);
  font-size: 11px;
  overflow-x: auto;
  white-space: pre-wrap;
  color: var(--text-primary);
  margin-top: 0.75rem;
  max-height: 280px;
  overflow-y: auto;
  line-height: 1.5;
}

/* ── Result messages ──────────────────────────────────────────────────────── */
.result { margin-top: 0.6rem; font-size: 11px; letter-spacing: 0.04em; }
.result--success { color: var(--accent-green); }
.result--error   { color: var(--accent-red); }

/* ── Scrollbar ────────────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-bright); border-radius: 0; }

/* ── Data table ───────────────────────────────────────────────────────────── */
.data-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.data-table th {
  text-align: left;
  padding: 0.4rem 0.6rem;
  color: var(--text-secondary);
  font-weight: 700;
  border-bottom: 1px solid var(--border-bright);
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}
.data-table td {
  padding: 0.5rem 0.6rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.data-table tbody tr:hover { background: var(--bg-hover); }
.data-table tbody tr:last-child td { border-bottom: none; }

/* Table horizontal scroll on mobile */
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* ── Filter bar ───────────────────────────────────────────────────────────── */
.filter-bar {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  margin-bottom: 0.75rem;
  flex-wrap: wrap;
}
.filter-bar input, .filter-bar select { max-width: 180px; flex: 1; min-width: 80px; }

/* ── Divider ──────────────────────────────────────────────────────────────── */
.divider { border: none; border-top: 1px solid var(--border); margin: 1rem 0; }
.key-display {
  display: block;
  font-family: var(--mono);
  font-size: 11px;
  background: var(--bg-base);
  border: 1px solid var(--border-bright);
  padding: 0.75rem;
  word-break: break-all;
  user-select: all;
  margin-top: 0.5rem;
  line-height: 1.5;
}

/* ── Utility ──────────────────────────────────────────────────────────────── */
.monospace    { font-family: var(--mono); }
.text-green   { color: var(--accent-green); }
.text-red     { color: var(--accent-red); }
.text-secondary { color: var(--text-secondary); }

/* ── Badge ────────────────────────────────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: 0.1rem 0.4rem;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  border: 1px solid var(--border);
  color: var(--text-secondary);
  background: transparent;
}
.badge--red   { border-color: var(--accent-red); color: var(--accent-red); }
.badge--green { border-color: var(--accent-green); color: var(--accent-green); }
.badge--blue  { border-color: var(--accent-blue); color: var(--accent-blue); }

/* ── Event badges ─────────────────────────────────────────────────────────── */
.event-badge {
  display: inline-block;
  padding: 0.1rem 0.4rem;
  font-size: 10px;
  font-weight: 700;
  border: 1px solid var(--border);
  letter-spacing: 0.04em;
}
.event-badge--warn    { border-color: var(--accent-amber); color: var(--accent-amber); }
.event-badge--info    { border-color: var(--accent-blue); color: var(--accent-blue); }
.event-badge--neutral { border-color: var(--border); color: var(--text-secondary); }

/* ── Info rows ────────────────────────────────────────────────────────────── */
.info-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.5rem;
  padding: 0.4rem 0;
  border-bottom: 1px solid var(--border);
  font-size: 12px;
}
.info-row:last-child { border-bottom: none; }
.info-row > span:first-child { color: var(--text-secondary); }
.info-rows { margin-bottom: 0.75rem; }
.info-key { color: var(--text-secondary); font-family: var(--mono); flex-shrink: 0; font-size: 11px; }
.info-val { font-family: var(--mono); text-align: right; word-break: break-all; font-size: 11px; }

/* ── Checkbox ─────────────────────────────────────────────────────────────── */
.checkbox-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 12px;
  color: var(--text-secondary);
  cursor: pointer;
}
.checkbox-label input[type="checkbox"] {
  width: 14px;
  height: 14px;
  accent-color: var(--accent);
  flex-shrink: 0;
}

/* ── Conditional order row ────────────────────────────────────────────────── */
.cond-order-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border);
  font-size: 12px;
  flex-wrap: wrap;
}
.cond-order-row:last-child { border-bottom: none; }

/* ── Portfolio card ───────────────────────────────────────────────────────── */
.portfolio-card {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 0.75rem;
  background: var(--bg-base);
  border: 1px solid var(--border);
  margin-bottom: 0.4rem;
}
.portfolio-card__name { font-weight: 700; flex: 1; font-size: 12px; }
.portfolio-card__meta { font-size: 11px; color: var(--text-secondary); }

/* ── P&L ──────────────────────────────────────────────────────────────────── */
.pnl-row {
  display: flex;
  justify-content: space-between;
  padding: 0.4rem 0;
  border-bottom: 1px solid var(--border);
  font-size: 12px;
}
.pnl-row--total {
  font-weight: 700;
  font-size: 13px;
  border-top: 1px solid var(--border-bright);
  border-bottom: none;
  margin-top: 0.2rem;
  padding-top: 0.6rem;
}
.pnl-positions { margin-top: 0.75rem; }
.position-row {
  display: flex;
  gap: 1rem;
  font-size: 11px;
  font-family: var(--mono);
  padding: 0.3rem 0;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.position-row:last-child { border-bottom: none; }

/* ── Agent layout ─────────────────────────────────────────────────────────── */
.agent-layout {
  display: grid;
  grid-template-columns: 240px 1fr 280px;
  gap: 0.75rem;
  overflow: hidden;
}
.agent-panel {
  background: var(--bg-card);
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.agent-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.6rem 0.75rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.agent-panel-header h2 {
  font-size: 10px;
  font-weight: 700;
  color: var(--text-secondary);
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
.agent-node-list { flex: 1; overflow-y: auto; padding: 0.4rem; }
.agent-graph { flex: 1; width: 100%; height: 100%; display: block; }
.memory-group { margin-bottom: 0.4rem; }
.memory-group-title {
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-dim);
  padding: 0.3rem 0.4rem 0.15rem;
}
.memory-node-item {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.35rem 0.4rem;
  cursor: pointer;
  transition: background 0.1s;
}
.memory-node-item:hover, .memory-node-item:focus { background: var(--bg-hover); outline: none; }
.node-label {
  flex: 1;
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.node-type-dot { width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0; }
.node-type-pair        { background: #888; }
.node-type-strategy    { background: #aaa; }
.node-type-trade       { background: #666; }
.node-type-signal      { background: #bbb; }
.node-type-observation { background: #555; }

.agent-inspector { overflow-y: auto; padding: 0.75rem; }
.inspector-placeholder { display: flex; align-items: center; justify-content: center; height: 100%; }
.inspector-header {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-bottom: 0.6rem;
  flex-wrap: wrap;
}
.inspector-header h3 { font-size: 13px; font-weight: 700; flex: 1; }
.inspector-neighbors { display: flex; flex-wrap: wrap; gap: 0.3rem; margin-bottom: 0.6rem; }
.memory-body {
  font-family: var(--mono);
  font-size: 11px;
  line-height: 1.6;
  background: var(--bg-base);
  border: 1px solid var(--border);
  padding: 0.6rem;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 40vh;
  overflow-y: auto;
}
.memory-body-edit {
  font-family: var(--mono);
  font-size: 11px;
  line-height: 1.6;
  background: var(--bg-base);
  border: 1px solid var(--border-bright);
  padding: 0.6rem;
  width: 100%;
  min-height: 180px;
  color: var(--text-primary);
  resize: vertical;
}
.inspector-actions { display: flex; gap: 0.4rem; margin-top: 0.4rem; }
.agent-activity { overflow-y: auto; padding: 0; }
.activity-controls { padding: 0.6rem 0.75rem; border-bottom: 1px solid var(--border); }
.activity-section { padding: 0.6rem 0.75rem; border-bottom: 1px solid var(--border); }
.activity-section h3 {
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-secondary);
  margin-bottom: 0.4rem;
}

/* ── Chips ────────────────────────────────────────────────────────────────── */
.chip {
  display: inline-flex;
  flex-direction: column;
  align-items: flex-start;
  background: var(--bg-hover);
  border: 1px solid var(--border);
  padding: 0.2rem 0.4rem;
  font-size: 11px;
  cursor: pointer;
  transition: border-color 0.1s;
  gap: 1px;
}
.chip:hover { border-color: var(--border-bright); }
.chip-rel { font-size: 9px; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.05em; }
.chip--pair        { border-left: 2px solid #888; }
.chip--strategy    { border-left: 2px solid #aaa; }
.chip--trade       { border-left: 2px solid #666; }
.chip--signal      { border-left: 2px solid #bbb; }
.chip--observation { border-left: 2px solid #555; }

/* ── Action cards ─────────────────────────────────────────────────────────── */
.action-card {
  background: var(--bg-base);
  border: 1px solid var(--border);
  padding: 0.5rem 0.6rem;
  margin-bottom: 0.4rem;
  font-size: 11px;
}
.action-card-header { display: flex; align-items: center; gap: 0.3rem; margin-bottom: 0.3rem; flex-wrap: wrap; }
.action-expiry { margin-left: auto; color: var(--text-secondary); font-size: 10px; font-family: var(--mono); }
.action-reasoning { color: var(--text-secondary); font-style: italic; margin-bottom: 0.3rem; font-size: 11px; }
.action-payload {
  font-family: var(--mono);
  font-size: 10px;
  background: var(--bg-card);
  padding: 0.3rem;
  max-height: 70px;
  overflow-y: auto;
  margin-bottom: 0.35rem;
  white-space: pre-wrap;
  word-break: break-all;
  border: 1px solid var(--border);
}
.action-btns { display: flex; gap: 0.3rem; }

/* ── Audit log ────────────────────────────────────────────────────────────── */
.audit-row {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.2rem 0;
  font-size: 11px;
  border-bottom: 1px solid var(--border);
}
.audit-row:last-child { border-bottom: none; }
.audit-type { flex: 1; font-family: var(--mono); }
.audit-ts { color: var(--text-secondary); font-size: 10px; font-family: var(--mono); }

/* ── Agent badges ─────────────────────────────────────────────────────────── */
.badge--action     { border-color: #888; color: #aaa; }
.badge--type       { font-weight: 700; }
.badge--pair       { border-color: #888; color: #aaa; }
.badge--strategy   { border-color: #999; color: #bbb; }
.badge--trade      { border-color: #666; color: #888; }
.badge--signal     { border-color: #aaa; color: #ccc; }
.badge--observation{ border-color: #555; color: #777; }
.badge--ok         { border-color: var(--accent-green); color: var(--accent-green); }
.badge--danger     { border-color: var(--accent-red); color: var(--accent-red); }

/* ── Form select / label ──────────────────────────────────────────────────── */
.form-select {
  width: 100%;
  background: var(--bg-base);
  border: 1px solid var(--border);
  color: var(--text-primary);
  font-size: 12px;
  font-family: var(--font);
  padding: 0.4rem 0.5rem;
  margin-top: 0.2rem;
}
.form-label { display: flex; flex-direction: column; font-size: 10px; color: var(--text-secondary); letter-spacing: 0.06em; text-transform: uppercase; }

/* ── Empty / loading states ───────────────────────────────────────────────── */
.empty-state { color: var(--text-secondary); font-size: 11px; text-align: center; padding: 1rem 0; letter-spacing: 0.05em; }
.loading { color: var(--text-secondary); font-style: italic; font-size: 11px; }

/* ── Security sections ────────────────────────────────────────────────────── */
.connections-list .cond-order-row { font-size: 11px; }

/* ── Cursor blink on logo ─────────────────────────────────────────────────── */
.topbar__logo::after {
  content: '_';
  animation: blink 1.2s step-end infinite;
  opacity: 1;
  margin-left: 1px;
}
@keyframes blink { 0%, 100% { opacity: 1; } 50% { opacity: 0; } }

/* ── Tablet (portrait / small laptop) ────────────────────────────────────── */
@media (max-width: 1024px) and (min-width: 769px) {
  .two-col { grid-template-columns: 1fr; }
  .agent-layout { grid-template-columns: 1fr 1.4fr; grid-template-rows: auto auto; }
  .agent-activity { grid-column: 1 / -1; }
}

/* ── Intermediate nav breakpoint ─────────────────────────────────────────── */
/* At ≤900px the 7 nav buttons + logo + status row can no longer fit in the
   topbar. Switch to hamburger before buttons are silently clipped.           */
@media (max-width: 900px) {
  .topbar__nav   { display: none; }
  .topbar__right { display: none; }
  .nav-hamburger { display: flex; }
}

/* ── Mobile / responsive ──────────────────────────────────────────────────── */
@media (max-width: 768px) {
  /* Nav: hide desktop bar, show hamburger */
  .topbar__nav { display: none; }
  .topbar__right { display: none; }
  .nav-hamburger { display: flex; }

  /* Layout padding */
  .layout { padding: 0.75rem; }

  /* Single column everywhere */
  .two-col { grid-template-columns: 1fr; }
  .prices-grid { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 0.4rem; }

  /* Agent: single column stack */
  .agent-layout {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto auto;
    height: auto;
    overflow: visible;
  }
  /* Agent panels: tiered heights so 3 stacked panels don't total 150vh */
  .agent-panel        { max-height: 40vh; }
  .agent-sidebar      { max-height: 28vh; }  /* Memory — lowest priority on mobile */
  .agent-inspector    { max-height: 38vh; }
  .agent-activity     { max-height: 44vh; }  /* Controls/actions — highest priority */
  .agent-panel-header { padding: 0.4rem 0.6rem; }
  .activity-controls  { padding: 0.4rem 0.6rem; }
  .activity-section   { padding: 0.4rem 0.6rem; }

  /* Code blocks: prevent overflow inside narrow cards */
  .code-block { max-width: 100%; overflow-x: auto; }

  /* Scrollable tables: enforce min-width so columns stay legible */
  .table-scroll .data-table { min-width: 480px; }

  /* Touch targets */
  .btn { min-height: 40px; padding: 0.5rem 0.9rem; }
  .btn--sm { min-height: 34px; }
  input, select { min-height: 40px; font-size: 16px; /* prevent iOS zoom */ }

  /* Chart shorter on mobile */
  .chart-canvas { height: 220px; }

  /* Chat shorter */
  .chat-messages { max-height: 220px; }

  /* Inline forms wrap on mobile */
  .form--inline { flex-wrap: wrap; }
  .form--inline input { min-width: 120px; flex: 1; }
  .filter-bar { flex-wrap: wrap; gap: 0.5rem; }

  /* Filter bar wraps naturally */
  .filter-bar input, .filter-bar select { max-width: 100%; }

  /* Card padding reduce */
  .card { padding: 0.9rem; }

  /* Table scroll */
  .data-table { font-size: 11px; }
  .data-table th, .data-table td { padding: 0.4rem 0.4rem; }
}

@media (max-width: 480px) {
  .topbar__logo { font-size: 0.85rem; }
  .prices-grid { grid-template-columns: 1fr 1fr; }
  .price-card__price { font-size: 1rem; }
  .pnl-overview-grid { grid-template-columns: 1fr; }
  .code-block { font-size: 10px; word-break: break-all; }
}

/* ── Nav separator ────────────────────────────────────────────────────────── */
.nav-sep {
  display: inline-block;
  width: 1px;
  height: 18px;
  background: var(--border-bright);
  align-self: center;
  margin: 0 0.3rem;
  opacity: 0.4;
  flex-shrink: 0;
}

/* ── Agent status bar ─────────────────────────────────────────────────────── */
.agent-statusbar {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0 1rem;
  height: 26px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  font-size: 10px;
  font-family: var(--mono);
  letter-spacing: 0.06em;
  position: sticky;
  top: 48px;
  z-index: 99;
  flex-shrink: 0;
}
.agent-statusbar__label   { color: var(--text-dim); font-weight: 700; }
.agent-statusbar__mode    { color: var(--accent); text-shadow: var(--glow); text-transform: uppercase; }
.agent-statusbar__sep     { color: var(--text-dim); }
.agent-statusbar__pending { color: var(--text-secondary); }
.agent-statusbar__pending--active { color: var(--accent-amber); }
.agent-statusbar__jump    { margin-left: auto; }
/* Adjust agent layout height to account for status bar */
.agent-layout { height: calc(100vh - 76px); }

/* ── Floating AI chat widget ──────────────────────────────────────────────── */
.chat-widget {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  width: 320px;
  max-height: 480px;
  background: var(--bg-card);
  border: 1px solid var(--border-bright);
  display: flex;
  flex-direction: column;
  z-index: 200;
  transition: max-height 0.2s ease;
}
.chat-widget--collapsed {
  max-height: 38px;
  overflow: hidden;
}
.chat-widget__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.35rem 0.75rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  cursor: pointer;
  height: 38px;
}
.chat-widget__title {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: var(--text-secondary);
}
.chat-widget__cost {
  font-size: 9px;
  color: var(--text-dim);
  font-family: var(--mono);
}
.chat-widget .chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 0.6rem;
  background: transparent;
  border: none;
  max-height: none;
  margin: 0;
}
.chat-widget__form {
  display: flex;
  gap: 0.4rem;
  flex-shrink: 0;
  padding: 0.4rem 0.5rem;
  border-top: 1px solid var(--border);
  flex-wrap: nowrap;
}
.chat-widget__form input { flex: 1; min-width: 0; }

/* FAB */
.chat-fab {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  width: 44px;
  height: 44px;
  background: var(--bg-card);
  border: 1px solid var(--border-bright);
  color: var(--accent);
  font-size: 18px;
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 201;
  text-shadow: var(--glow);
}
.chat-fab--visible { display: flex; }

/* ── P&L overview (dashboard + portfolio) ─────────────────────────────────── */
.pnl-overview-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.75rem;
}
.pnl-stat {
  background: var(--bg-base);
  border: 1px solid var(--border);
  padding: 0.75rem;
}
.pnl-stat__label { font-size: 10px; color: var(--text-secondary); letter-spacing: 0.08em; text-transform: uppercase; margin-bottom: 0.3rem; }
.pnl-stat__value { font-size: 1.1rem; font-family: var(--mono); font-weight: 700; }
.pnl-stat__sub   { font-size: 10px; color: var(--text-secondary); margin-top: 0.2rem; font-family: var(--mono); }

/* Platform costs detail table */
.costs-table { width: 100%; border-collapse: collapse; font-size: 12px; margin-top: 0.5rem; }
.costs-table th { text-align: left; padding: 0.35rem 0.5rem; color: var(--text-secondary); font-size: 10px; letter-spacing: 0.08em; text-transform: uppercase; border-bottom: 1px solid var(--border-bright); }
.costs-table td { padding: 0.4rem 0.5rem; border-bottom: 1px solid var(--border); font-family: var(--mono); font-size: 11px; }
.costs-table tr:last-child td { border-bottom: none; }

/* ── Mobile additions ─────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .agent-statusbar { font-size: 9px; padding: 0 0.6rem; gap: 0.4rem; }
  .agent-statusbar__jump { display: none; }
  .chat-widget { width: calc(100vw - 2rem); right: 1rem; bottom: 1rem; }
  .chat-fab { bottom: 1rem; right: 1rem; }
  .pnl-overview-grid { grid-template-columns: 1fr 1fr; }
}

/* ── Animations ───────────────────────────────────────────────────────────── */

/* View fade-in on activation */
@keyframes viewIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}
.view.active { animation: viewIn 0.18s ease forwards; }

/* Chat widget slide up on open */
@keyframes slideUp {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}
.chat-widget:not(.chat-widget--collapsed) {
  animation: slideUp 0.18s ease forwards;
}


/* FAB pulse when chat has unread */
@keyframes fabPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255,255,255,0.3); }
  50%       { box-shadow: 0 0 0 6px rgba(255,255,255,0); }
}
.chat-fab--visible { animation: fabPulse 2s ease infinite; }

/* Status bar pending count pulse when > 0 */
@keyframes pendingGlow {
  0%, 100% { text-shadow: none; }
  50%       { text-shadow: 0 0 8px var(--accent-amber); }
}
.agent-statusbar__pending--active { animation: pendingGlow 2s ease infinite; }

/* Nav button active indicator slide in */
.nav-btn { position: relative; overflow: hidden; }
.nav-btn::after {
  content: '';
  position: absolute;
  bottom: 0; left: 50%;
  width: 0; height: 2px;
  background: var(--accent);
  transition: width 0.15s ease, left 0.15s ease;
}
.nav-btn.active::after { width: 100%; left: 0; }

/* Price card flash on value update */
@keyframes priceFlash {
  0%   { background: var(--bg-hover); }
  100% { background: var(--bg-card); }
}
.price-card--updated { animation: priceFlash 0.6s ease forwards; }

/* Card entrance on first render */
@keyframes cardIn {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}
.card { animation: cardIn 0.2s ease both; }

/* Button press feedback */
.btn:active:not(:disabled) { transform: scale(0.97); }

/* Smooth scrollbar thumb */
::-webkit-scrollbar-thumb { transition: background 0.2s; }
::-webkit-scrollbar-thumb:hover { background: var(--border-bright); }

/* ── Nav drawer slide ─────────────────────────────────────────────────────── */
@keyframes drawerIn {
  from { opacity: 0; transform: translateY(-8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── WS status dot — connecting state ────────────────────────────────────── */
@keyframes dotPing {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.25; }
}
.status-dot--connecting { background: var(--accent-amber); animation: dotPing 0.8s ease infinite; }

/* ── Button loading state ────────────────────────────────────────────────── */
@keyframes btnDots {
  0%, 80%, 100% { opacity: 0.2; }
  40%           { opacity: 1; }
}
.btn--loading {
  pointer-events: none;
  position: relative;
  color: transparent !important;
}
.btn--loading::after {
  content: '· · ·';
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-primary);
  animation: btnDots 1.2s ease infinite;
}
.btn--primary.btn--loading::after { color: var(--bg-base); }

/* ── Result message entrance ─────────────────────────────────────────────── */
@keyframes resultIn {
  from { opacity: 0; transform: translateX(-6px); }
  to   { opacity: 1; transform: translateX(0); }
}
.result--animate { animation: resultIn 0.15s ease forwards; }

/* ── Chat message entrance ───────────────────────────────────────────────── */
@keyframes msgIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
.chat-msg { animation: msgIn 0.18s ease forwards; }

/* ── Action card entrance & exit ─────────────────────────────────────────── */
@keyframes actionIn {
  from { opacity: 0; transform: translateX(-10px); }
  to   { opacity: 1; transform: translateX(0); }
}
@keyframes actionOut {
  from { opacity: 1; transform: translateX(0);    max-height: 200px; }
  to   { opacity: 0; transform: translateX(16px); max-height: 0; margin-bottom: 0; padding: 0; overflow: hidden; }
}
.action-card           { animation: actionIn  0.2s ease both; }
.action-card--removing { animation: actionOut 0.2s ease forwards; overflow: hidden; }

/* ── Table row staggered entrance ────────────────────────────────────────── */
@keyframes rowIn {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}
tbody tr {
  animation: rowIn 0.15s ease both;
  animation-delay: calc(var(--row-i, 0) * 30ms);
}

/* ── Audit row entrance ───────────────────────────────────────────────────── */
.audit-row {
  animation: rowIn 0.15s ease both;
  animation-delay: calc(var(--row-i, 0) * 20ms);
}

/* ── Signal card entrance ────────────────────────────────────────────────── */
.signal-card { animation: cardIn 0.2s ease forwards; }

/* ── Signal confidence bar ───────────────────────────────────────────────── */
.confidence-bar {
  height: 3px;
  background: var(--border);
  margin-top: 0.6rem;
  overflow: hidden;
}
.confidence-bar__fill {
  height: 100%;
  background: var(--accent);
  width: 0;
  transition: width 0.7s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ── Skeleton shimmer ────────────────────────────────────────────────────── */
@keyframes shimmer {
  0%   { background-position: -200% 0; }
  100% { background-position:  200% 0; }
}
.skeleton {
  background: linear-gradient(90deg, var(--bg-card) 25%, var(--bg-hover) 50%, var(--bg-card) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s linear infinite;
  color: transparent !important;
  pointer-events: none;
  user-select: none;
  border-color: var(--border) !important;
}

/* ── Price card staggered initial entrance ───────────────────────────────── */
.price-card:nth-child(1) { animation-delay: 0s; }
.price-card:nth-child(2) { animation-delay: 0.06s; }
.price-card:nth-child(3) { animation-delay: 0.12s; }
.price-card:nth-child(4) { animation-delay: 0.18s; }
.price-card:nth-child(n+5) { animation-delay: 0.24s; }

/* ══════════════════════════════════════════════════════════════════════════
   BOOT SCREEN
   ══════════════════════════════════════════════════════════════════════════ */

#boot-screen {
  position: fixed;
  inset: 0;
  background: var(--bg-base);
  z-index: 10000;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1.25rem;
  /* CRT scanlines on the boot screen itself */
  background-image: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 3px,
    rgba(0,0,0,0.12) 3px,
    rgba(0,0,0,0.12) 4px
  );
}

/* ── Boot logo letters ───────────────────────────────────────────────────── */
.boot-logo {
  display: flex;
  align-items: flex-end;
  gap: clamp(0.04em, 0.5vw, 0.12em);
}

@keyframes bootLetterIn {
  0%   { opacity: 0; transform: translateY(24px) scaleY(1.2); filter: blur(10px); }
  60%  { opacity: 1; transform: translateY(-3px) scaleY(0.97); filter: blur(0); }
  100% { opacity: 1; transform: translateY(0)   scaleY(1);    filter: blur(0); }
}

.boot-logo span {
  display: inline-block;
  font-size: clamp(2.5rem, 10vw, 5.5rem);
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--accent);
  text-shadow: var(--glow-md);
  opacity: 0;
  animation: bootLetterIn 0.45s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

/* Each letter offset 90ms from the previous */
.boot-logo span:nth-child(1) { animation-delay: 0.10s; }
.boot-logo span:nth-child(2) { animation-delay: 0.19s; }
.boot-logo span:nth-child(3) { animation-delay: 0.28s; }
.boot-logo span:nth-child(4) { animation-delay: 0.37s; }
.boot-logo span:nth-child(5) { animation-delay: 0.46s; }
.boot-logo span:nth-child(6) { animation-delay: 0.55s; }
.boot-logo span:nth-child(7) { animation-delay: 0.64s; }
.boot-logo span:nth-child(8) { animation-delay: 0.73s; }
.boot-logo span:nth-child(9) { animation-delay: 0.82s; }

/* ── Boot subtitle ───────────────────────────────────────────────────────── */
@keyframes bootSubIn {
  from { opacity: 0; letter-spacing: 0.6em; }
  to   { opacity: 1; letter-spacing: 0.35em; }
}
.boot-sub {
  font-size: clamp(9px, 1.8vw, 11px);
  letter-spacing: 0.35em;
  color: var(--text-secondary);
  text-transform: uppercase;
  opacity: 0;
  animation: bootSubIn 0.5s ease forwards;
  animation-delay: 1.35s;
}

/* ── Boot progress bar ───────────────────────────────────────────────────── */
.boot-bar {
  width: clamp(160px, 40vw, 280px);
  height: 1px;
  background: var(--border);
  overflow: hidden;
  opacity: 0;
  animation: bootSubIn 0.3s ease forwards;
  animation-delay: 1.45s;
}
@keyframes bootBarFill {
  from { width: 0; }
  to   { width: 100%; }
}
.boot-bar__fill {
  height: 100%;
  background: var(--accent);
  box-shadow: var(--glow);
  width: 0;
  animation: bootBarFill 0.55s ease forwards;
  animation-delay: 1.5s;
}

/* ── Boot exit ───────────────────────────────────────────────────────────── */
@keyframes bootExit {
  0%   { opacity: 1; transform: scale(1); }
  30%  { opacity: 1; transform: scale(1.01); }
  100% { opacity: 0; transform: scale(0.98); }
}
#boot-screen.boot--exit {
  animation: bootExit 0.45s ease forwards;
  pointer-events: none;
}
