/* Clariro Command Center — Components */

.app {
  display: grid;
  grid-template-columns: 212px 1fr;
  grid-template-rows: 44px 1fr;
  height: 100vh;
  min-height: 640px;
}

/* ─── Top bar ───────────────────────────────────────── */
.topbar {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 0;
  border-bottom: 1px solid var(--br-0);
  background: var(--bg-1);
  padding: 0 14px 0 0;
  font-size: 13px;
}
@media (max-width: 1400px) { .kbar { min-width: 200px; } }
@media (max-width: 1200px) { .kbar { min-width: 140px; } .topbar-ctx { display: none; } }
@media (max-width: 900px)  { .email-label { display: none; } }

/* Inline identity (broker selector + email + salir) — replaces the old
   fixed-position chip that overlapped the search input. */
.identity-inline {
  display: inline-flex; align-items: center; gap: 10px;
  padding: 4px 10px 4px 10px;
  border: 1px solid var(--br-0);
  border-radius: 999px;
  background: var(--bg-2);
  font-size: 12px;
  max-width: 100%;
}
.identity-inline .live-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--fg-3);
}
.identity-inline .live-dot.on {
  background: var(--up);
  box-shadow: 0 0 6px var(--up);
}
.identity-inline .broker-select {
  background: transparent;
  color: var(--fg-0);
  border: none;
  outline: none;
  font: inherit;
  cursor: pointer;
  padding: 2px 4px;
  max-width: 180px;
}
.identity-inline .email-label {
  color: var(--fg-3);
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.identity-inline .btn.small.ghost { padding: 2px 8px; font-size: 11px; }
.topbar .brand {
  width: 212px;
  padding: 0 14px;
  display: flex; align-items: center; gap: 8px;
  border-right: 1px solid var(--br-0);
  height: 100%;
  font-weight: 600;
  letter-spacing: -0.01em;
}
.brand-mark {
  width: 18px; height: 18px;
  border-radius: 3px;
  background: var(--accent);
  display: grid; place-items: center;
  color: var(--bg-0);
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  font-weight: 700;
}
.brand-name { font-size: 13px; }
.brand-name .sub { color: var(--fg-2); font-weight: 400; margin-left: 6px; }

.topbar-ctx {
  display: flex; align-items: center; gap: 20px;
  padding-left: 14px;
  color: var(--fg-2);
  font-size: 12px;
}
.topbar-ctx > div { white-space: nowrap; flex-shrink: 0; display: inline-flex; align-items: baseline; }
.topbar-ctx .k { color: var(--fg-3); margin-right: 6px; text-transform: uppercase; font-size: 10.5px; letter-spacing: 0.04em; }
.topbar-ctx .v { color: var(--fg-0); font-variant-numeric: tabular-nums; font-family: 'JetBrains Mono', monospace; font-size: 12px; }
.topbar-spacer { flex: 1; }
.topbar-right { display: flex; align-items: center; gap: 8px; }

.kbar {
  display: flex; align-items: center; gap: 10px;
  padding: 5px 10px 5px 12px;
  background: var(--bg-2);
  border: 1px solid var(--br-0);
  border-radius: 5px;
  color: var(--fg-2);
  min-width: 280px;
  font-size: 12px;
}
.kbar:hover { border-color: var(--br-1); color: var(--fg-1); }
.kbar .kbd {
  margin-left: auto;
  font-family: 'JetBrains Mono', monospace;
  font-size: 10.5px;
  color: var(--fg-3);
  padding: 1px 5px;
  border: 1px solid var(--br-0);
  border-radius: 3px;
  background: var(--bg-1);
}

.pending-badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 8px;
  background: var(--human-bg);
  border: 1px solid var(--human);
  color: var(--human);
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}
.pending-badge .dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--human);
  animation: pulseDot 2s ease-in-out infinite;
}

.icon-btn {
  width: 28px; height: 28px;
  display: grid; place-items: center;
  border-radius: 4px;
  color: var(--fg-2);
}
.icon-btn:hover { background: var(--bg-2); color: var(--fg-0); }
.icon-btn.active { background: var(--bg-3); color: var(--fg-0); }

.user-chip {
  display: flex; align-items: center; gap: 8px;
  padding: 3px 4px 3px 10px;
  border-radius: 5px;
  font-size: 12px;
}
.user-chip:hover { background: var(--bg-2); }
.user-chip .avatar {
  width: 22px; height: 22px;
  border-radius: 4px;
  background: oklch(0.52 0.14 45);
  display: grid; place-items: center;
  color: white; font-size: 10.5px; font-weight: 600;
}

/* ─── Sidebar ───────────────────────────────────────── */
.sidebar {
  border-right: 1px solid var(--br-0);
  background: var(--bg-1);
  display: flex; flex-direction: column;
  overflow: hidden;
}
.side-sec { padding: 14px 10px 6px; }
.side-sec .title {
  font-size: 10px; font-weight: 600;
  color: var(--fg-3);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 0 8px 8px;
}
.side-item {
  width: 100%;
  display: flex; align-items: center; gap: 10px;
  padding: 6px 8px;
  border-radius: 4px;
  color: var(--fg-1);
  font-size: 13px;
  text-align: left;
  position: relative;
}
.side-item:hover { background: var(--bg-2); color: var(--fg-0); }
.side-item.active { background: var(--bg-3); color: var(--fg-0); }
.side-item.active::before {
  content: ''; position: absolute; left: -10px; top: 6px; bottom: 6px;
  width: 2px; background: var(--accent); border-radius: 1px;
}
.side-item .ikn { width: 14px; height: 14px; color: var(--fg-2); flex-shrink: 0; }
.side-item.active .ikn { color: var(--accent); }
.side-item .kbd {
  margin-left: auto;
  font-family: 'JetBrains Mono', monospace;
  font-size: 10.5px;
  color: var(--fg-3);
  white-space: nowrap;
  letter-spacing: 0.02em;
}
.side-item .count {
  margin-left: auto;
  font-family: 'JetBrains Mono', monospace;
  font-size: 10.5px;
  background: var(--bg-3);
  color: var(--fg-2);
  padding: 1px 6px;
  border-radius: 8px;
  min-width: 18px; text-align: center;
}
.side-item .count.human { background: var(--human-bg); color: var(--human); border: 1px solid var(--human); }

.side-footer {
  margin-top: auto;
  padding: 10px 14px;
  border-top: 1px solid var(--br-0);
  display: flex; align-items: center; gap: 10px;
  font-size: 11px;
  color: var(--fg-2);
}
.side-footer .status-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--up);
  animation: pulseDot 2.5s ease-in-out infinite;
}

/* ─── Main ─────────────────────────────────────────── */
.main {
  overflow: auto;
  background: var(--bg-0);
  position: relative;
}
.page-head {
  display: flex; align-items: flex-end; justify-content: space-between;
  padding: 18px 22px 14px;
  border-bottom: 1px solid var(--br-0);
  background: var(--bg-0);
  position: sticky; top: 0; z-index: 4;
}
.page-title { font-size: 18px; font-weight: 600; letter-spacing: -0.01em; }
.page-sub { font-size: 12px; color: var(--fg-2); margin-top: 3px; }
.page-actions { display: flex; align-items: center; gap: 6px; }

.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 10px;
  border-radius: 4px;
  background: var(--bg-2);
  border: 1px solid var(--br-0);
  color: var(--fg-0);
  font-size: 12px;
  font-weight: 500;
}
.btn:hover { background: var(--bg-3); border-color: var(--br-1); }
.btn.primary { background: var(--accent); color: oklch(0.15 0 0); border-color: var(--accent); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.ghost { background: transparent; }
.btn.ghost:hover { background: var(--bg-2); }
.btn.danger { background: var(--down-bg); border-color: var(--down-dim); color: var(--down); }
.btn.small { padding: 3px 7px; font-size: 11px; }
.btn .kbd {
  font-family: 'JetBrains Mono', monospace; font-size: 10.5px;
  color: var(--fg-3);
  padding: 0 4px;
  border: 1px solid var(--br-0);
  border-radius: 2px;
}

/* ─── Hero cards (Cockpit) ─────────────────────────── */
.hero-grid {
  display: grid; grid-template-columns: repeat(4, 1fr);
  gap: 1px;
  background: var(--br-0);
  border-bottom: 1px solid var(--br-0);
}
.hero {
  background: var(--bg-1);
  padding: 18px 22px 20px;
  display: flex; flex-direction: column; gap: 8px;
  position: relative;
}
.hero .label {
  font-size: 11px; color: var(--fg-2);
  text-transform: uppercase; letter-spacing: 0.05em;
  display: flex; align-items: center; gap: 6px;
}
.hero .value {
  font-family: 'JetBrains Mono', monospace;
  font-variant-numeric: tabular-nums;
  font-size: 28px;
  font-weight: 500;
  letter-spacing: -0.01em;
  line-height: 1.1;
}
.hero .value .unit { font-size: 15px; color: var(--fg-2); margin-left: 4px; font-weight: 400; }
.hero .meta {
  display: flex; align-items: center; gap: 10px;
  font-size: 11.5px;
  color: var(--fg-2);
  margin-top: auto;
}
.hero .delta {
  display: inline-flex; align-items: center; gap: 3px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
}
.hero .spark {
  position: absolute; right: 16px; top: 18px;
  width: 88px; height: 28px; opacity: 0.6;
}

/* ─── Cockpit layout ──────────────────────────────── */
.cockpit {
  display: grid;
  grid-template-columns: 1fr 360px;
  gap: 1px;
  background: var(--br-0);
}
.cockpit-main {
  background: var(--bg-0);
  padding: 18px 22px;
  display: flex; flex-direction: column; gap: 18px;
}
.cockpit-side {
  background: var(--bg-1);
  border-left: 1px solid var(--br-0);
  display: flex; flex-direction: column;
}

/* Pending stack */
.panel {
  background: var(--bg-1);
  border: 1px solid var(--br-0);
  border-radius: 6px;
}
.panel-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 14px;
  border-bottom: 1px solid var(--br-0);
}
.panel-head .left { display: flex; align-items: center; gap: 10px; }
.panel-head .title {
  font-size: 12px; font-weight: 600;
  letter-spacing: 0.04em; text-transform: uppercase;
  color: var(--fg-1);
  white-space: nowrap;
}
.panel-head .sub { font-size: 11.5px; color: var(--fg-2); white-space: nowrap; }
.panel-head .right { display: flex; align-items: center; gap: 6px; }
.panel-body { padding: 0; }

.pending-item {
  padding: 14px 16px;
  border-bottom: 1px solid var(--br-0);
  display: grid; grid-template-columns: auto 1fr auto; gap: 14px;
  align-items: flex-start;
}
.pending-item:last-child { border-bottom: none; }
.pending-kind {
  padding: 3px 7px;
  border-radius: 3px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.05em;
}
.pending-kind.BUY { background: var(--up-bg); color: var(--up); }
.pending-kind.SELL { background: var(--down-bg); color: var(--down); }

/* Live pending — agent is actively awaiting confirmation. Pulse + dot so
   the user can distinguish between "awaiting now" and "historical journal". */
.pending-item.live { background: linear-gradient(90deg, var(--warn-bg) 0%, transparent 8%); }
.pending-item.live .pending-kind::before {
  content: '';
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--warn);
  margin-right: 5px;
  vertical-align: middle;
  animation: cc-pulse 1.2s ease-in-out infinite;
}
@keyframes cc-pulse {
  0%, 100% { opacity: 1; box-shadow: 0 0 0 0 var(--warn); }
  50% { opacity: 0.55; box-shadow: 0 0 0 3px transparent; }
}
.pending-body { min-width: 0; }
.pending-head-row {
  display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap;
}
.pending-head-row > * { white-space: nowrap; }
.pending-tick { font-size: 15px; font-weight: 600; letter-spacing: -0.01em; }
.pending-amt { font-family: 'JetBrains Mono', monospace; font-size: 12.5px; color: var(--fg-1); white-space: nowrap; }
.pending-broker { font-size: 11px; color: var(--fg-2); text-transform: uppercase; letter-spacing: 0.04em; white-space: nowrap; }
.pending-conf { margin-left: auto; font-family: 'JetBrains Mono', monospace; font-size: 11.5px; color: var(--fg-2); white-space: nowrap; }
.pending-conf b { color: var(--ai); font-weight: 600; }
.pending-reason { font-size: 12.5px; color: var(--fg-1); margin-top: 6px; line-height: 1.5; }

.rationale-grid {
  display: grid;
  grid-template-columns: 76px 1fr;
  gap: 5px 12px;
  margin-top: 10px;
  font-size: 11.5px;
}
.rationale-grid .k {
  color: var(--fg-3);
  text-transform: uppercase; letter-spacing: 0.04em;
  font-size: 10px; font-weight: 600;
  padding-top: 2px;
  white-space: nowrap;
}
.rationale-grid .v { color: var(--fg-1); line-height: 1.5; }
.rationale-grid .v.alt { color: var(--ai); }
.rationale-grid .v.devil { color: var(--warn); }

.gate-chips { display: flex; gap: 4px; margin-top: 10px; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
.gate-chips::-webkit-scrollbar { display: none; }
.gate-chip {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 3px;
  background: var(--bg-2);
  border: 1px solid var(--br-0);
  color: var(--fg-2);
  display: inline-flex; align-items: center; gap: 4px;
  white-space: nowrap;
  flex-shrink: 0;
}
.gate-chip.pass { border-color: var(--up-dim); color: var(--up); }
.gate-chip.fail { border-color: var(--down-dim); color: var(--down); background: var(--down-bg); }
.gate-chip.warn { border-color: var(--warn); color: var(--warn); background: var(--warn-bg); }

.pending-actions {
  display: flex; flex-direction: column; gap: 6px;
  padding-top: 2px;
}
.pending-expiry {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10.5px;
  color: var(--fg-3);
  text-align: right;
  margin-top: 6px;
}

/* Alerts */
.alert-row {
  display: grid;
  grid-template-columns: 4px auto 1fr auto auto;
  gap: 10px;
  align-items: center;
  padding: 10px 14px;
  border-bottom: 1px solid var(--br-0);
  font-size: 12.5px;
}
.alert-row:last-child { border-bottom: none; }
.alert-row .sev {
  width: 3px; height: 22px; border-radius: 2px;
}
.alert-row.HIGH .sev { background: var(--down); }
.alert-row.MEDIUM .sev { background: var(--warn); }
.alert-row.LOW .sev { background: var(--ai); }
.alert-tag {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10.5px;
  padding: 2px 7px;
  border-radius: 3px;
  background: var(--bg-2);
  color: var(--fg-2);
  letter-spacing: 0.04em;
  font-weight: 600;
}
.alert-msg { color: var(--fg-1); }
.alert-msg b { color: var(--fg-0); font-weight: 500; }
.alert-ts { font-family: 'JetBrains Mono', monospace; font-size: 11px; color: var(--fg-3); }
.alert-actions { display: flex; gap: 4px; }

/* Signal feed */
.signal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 14px 10px;
  border-bottom: 1px solid var(--br-0);
  font-size: 12px;
}
.signal-head .title {
  font-size: 12px; font-weight: 600;
  letter-spacing: 0.04em; text-transform: uppercase;
  color: var(--fg-1);
  white-space: nowrap;
}
.signal-head .live { white-space: nowrap; }
.signal-head .live {
  display: inline-flex; align-items: center; gap: 5px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 10.5px;
  color: var(--up);
}
.signal-head .live .dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--up);
  animation: pulseDot 1.8s ease-in-out infinite;
}
.signal-filter-row { display: flex; gap: 4px; padding: 8px 14px; border-bottom: 1px solid var(--br-0); flex-wrap: wrap; }
.filter-chip {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 10px;
  border: 1px solid var(--br-0);
  color: var(--fg-2);
  background: transparent;
}
.filter-chip.on { background: var(--bg-3); color: var(--fg-0); border-color: var(--br-1); }
.filter-chip:hover { color: var(--fg-0); }

.signal-list { flex: 1; overflow-y: auto; }
.signal-row {
  display: grid;
  grid-template-columns: 56px auto 1fr;
  gap: 10px;
  padding: 8px 14px;
  border-bottom: 1px solid var(--br-0);
  font-size: 12px;
  align-items: flex-start;
}
.signal-row:hover { background: var(--bg-2); }
.signal-row .t { font-family: 'JetBrains Mono', monospace; font-size: 10.5px; color: var(--fg-3); padding-top: 2px; }
.signal-row .src-tag {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  padding: 1px 5px;
  border-radius: 3px;
  background: var(--bg-3);
  color: var(--fg-2);
  letter-spacing: 0.02em;
  align-self: flex-start;
  margin-top: 1px;
  white-space: nowrap;
}
.signal-row.sev-HIGH .src-tag { background: var(--down-bg); color: var(--down); }
.signal-row.sev-MEDIUM .src-tag { background: var(--warn-bg); color: var(--warn); }
.signal-row .msg { color: var(--fg-1); line-height: 1.4; }
.signal-row .msg .tick {
  font-family: 'JetBrains Mono', monospace;
  font-weight: 600;
  color: var(--fg-0);
  margin-right: 4px;
}

/* Table */
.tbl-wrap { border: 1px solid var(--br-0); border-radius: 6px; overflow: hidden; background: var(--bg-1); }
.tbl { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.tbl thead th {
  font-size: 10.5px;
  font-weight: 600;
  color: var(--fg-3);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  text-align: left;
  padding: 10px 12px;
  background: var(--bg-1);
  border-bottom: 1px solid var(--br-0);
  position: sticky; top: 0;
  white-space: nowrap;
}
.tbl thead th.r { text-align: right; }
.tbl tbody td {
  padding: 0 12px;
  height: 44px;
  border-bottom: 1px solid var(--br-0);
  vertical-align: middle;
  white-space: nowrap;
}
.tbl tbody tr:hover { background: var(--bg-2); }
.tbl tbody tr.expanded { background: var(--bg-2); }
.tbl tbody tr:last-child td { border-bottom: none; }
.tbl td.r, .tbl th.r { text-align: right; }
.tbl td.mono, .tbl th.mono { font-family: 'JetBrains Mono', monospace; font-variant-numeric: tabular-nums; }

.tick-cell {
  display: flex; align-items: center; gap: 8px;
}
.tick-cell .ticker { font-weight: 600; font-size: 13px; letter-spacing: -0.01em; }
.tick-cell .note { font-size: 10.5px; color: var(--fg-3); }

.broker-tag {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 3px;
  background: var(--bg-3);
  color: var(--fg-2);
  border: 1px solid var(--br-0);
}
.broker-tag.IOL { color: oklch(0.78 0.12 55); border-color: oklch(0.50 0.08 55); }
.broker-tag.Balanz { color: oklch(0.78 0.12 195); border-color: oklch(0.50 0.08 195); }
.broker-tag.Binance { color: oklch(0.80 0.13 85); border-color: oklch(0.52 0.08 85); }

.tier-pill {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  font-weight: 700;
  width: 18px; height: 18px;
  display: inline-grid; place-items: center;
  border-radius: 3px;
}
.tier-pill.H { background: var(--up-bg); color: var(--up); }
.tier-pill.M { background: var(--warn-bg); color: var(--warn); }
.tier-pill.L { background: var(--down-bg); color: var(--down); }

.factor-tag {
  font-size: 10.5px;
  color: var(--fg-2);
  padding: 2px 7px;
  border: 1px solid var(--br-0);
  border-radius: 10px;
  background: transparent;
}

.row-expand-btn {
  width: 18px; height: 18px; border-radius: 3px;
  display: grid; place-items: center;
  color: var(--fg-3);
}
.row-expand-btn:hover { background: var(--bg-3); color: var(--fg-0); }
.row-expand-btn.open { color: var(--fg-0); transform: rotate(90deg); }

.sell-btn {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  padding: 3px 10px;
  border-radius: 3px;
  background: var(--bg-3);
  color: var(--fg-1);
  border: 1px solid var(--br-0);
}
.sell-btn:hover { background: var(--down-bg); color: var(--down); border-color: var(--down-dim); }

.expanded-stop {
  padding: 16px 20px 20px;
  background: var(--bg-1);
  border-top: 1px solid var(--br-1);
  display: grid;
  grid-template-columns: 1fr 1fr 320px;
  gap: 24px;
}

.stop-meter {
  display: flex; flex-direction: column; gap: 8px;
}
.stop-meter .hdr { font-size: 10.5px; color: var(--fg-3); text-transform: uppercase; letter-spacing: 0.05em; font-weight: 600; }
.stop-bar {
  position: relative; height: 6px; background: var(--bg-3); border-radius: 3px;
  margin: 10px 0 8px;
}
.stop-bar .range {
  position: absolute; top: 0; bottom: 0;
  background: linear-gradient(to right, var(--down-bg), transparent 30%, transparent 70%, var(--up-bg));
  left: 0; right: 0; border-radius: 3px;
}
.stop-bar .marker {
  position: absolute; top: -4px; width: 2px; height: 14px;
  transform: translateX(-1px);
}
.stop-bar .marker.sl { background: var(--down); }
.stop-bar .marker.tp { background: var(--up); }
.stop-bar .marker.px { background: var(--fg-0); height: 18px; top: -6px; box-shadow: 0 0 0 2px var(--bg-1); }
.stop-bar .marker.trail { background: var(--warn); }
.stop-bar .marker.trail::after {
  content: ''; position: absolute; top: 3px; left: 2px;
  width: 6px; height: 6px; border-radius: 50%; background: var(--warn);
  animation: pulseDot 1.4s ease-in-out infinite;
}
.stop-ticks {
  display: grid; grid-template-columns: 1fr 1fr 1fr; font-size: 10.5px;
  color: var(--fg-3); font-family: 'JetBrains Mono', monospace;
}
.stop-ticks > div:nth-child(2) { text-align: center; }
.stop-ticks > div:nth-child(3) { text-align: right; }

.state-pill {
  display: inline-flex; align-items: center; gap: 6px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 10.5px; font-weight: 600;
  padding: 3px 8px;
  border-radius: 3px;
  letter-spacing: 0.04em;
  white-space: nowrap;
}
.state-pill .dot { width: 5px; height: 5px; border-radius: 50%; }
.state-pill.WATCHING            { background: var(--bg-3); color: var(--fg-1); }
.state-pill.WATCHING .dot       { background: var(--fg-2); }
.state-pill.SL_ARMED            { background: var(--down-bg); color: var(--down); }
.state-pill.SL_ARMED .dot       { background: var(--down); animation: pulseDot 1.4s ease-in-out infinite; }
.state-pill.TP_REACHED          { background: var(--up-bg); color: var(--up); }
.state-pill.TP_REACHED .dot     { background: var(--up); animation: pulseDot 1.4s ease-in-out infinite; }
.state-pill.TRIGGERED_PENDING_CONFIRM { background: var(--human-bg); color: var(--human); }
.state-pill.TRIGGERED_PENDING_CONFIRM .dot { background: var(--human); animation: pulseDot 1.2s ease-in-out infinite; }

.mode-toggle {
  display: inline-flex;
  border: 1px solid var(--br-0);
  border-radius: 4px;
  overflow: hidden;
  font-family: 'JetBrains Mono', monospace;
  font-size: 10.5px;
}
.mode-toggle button {
  padding: 3px 9px;
  color: var(--fg-2);
  background: var(--bg-2);
}
.mode-toggle button.on {
  background: var(--ai-bg);
  color: var(--ai);
}
.mode-toggle button.on.MANUAL {
  background: var(--human-bg);
  color: var(--human);
}

.timeline {
  display: flex; gap: 3px; align-items: flex-end; height: 34px;
}
.timeline .tick {
  flex: 1; background: var(--bg-3); border-radius: 2px;
  min-height: 4px;
}
.timeline .tick.W { background: var(--bg-3); }
.timeline .tick.SLA { background: var(--down-dim); }
.timeline .tick.TPR { background: var(--up-dim); }
.timeline .tick.TPC { background: var(--human); }

/* Concentration heat-bar (stops page) */
.heat-bar {
  display: flex; gap: 2px; margin-top: 4px;
}
.heat-bar .cell {
  flex: 1;
  height: 22px;
  background: var(--bg-3);
  border-radius: 2px;
  position: relative;
}
.heat-bar .cell[data-v="1"] { background: oklch(0.36 0.03 250); }
.heat-bar .cell[data-v="2"] { background: oklch(0.42 0.05 240); }
.heat-bar .cell[data-v="3"] { background: oklch(0.50 0.10 50); }
.heat-bar .cell[data-v="4"] { background: var(--down-dim); }
.heat-bar .cell[data-v="5"] { background: var(--down); }

/* Decisions / Journal */
.journal {
  display: grid;
  grid-template-columns: 1fr 540px;
  gap: 1px;
  background: var(--br-0);
  min-height: calc(100vh - 44px - 65px);
}
.journal-list {
  background: var(--bg-0);
  overflow-y: auto;
}
.journal-list .filter-row { padding: 10px 20px; display: flex; gap: 6px; border-bottom: 1px solid var(--br-0); background: var(--bg-1); }
.journal-row {
  display: grid;
  grid-template-columns: 64px auto 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 12px 20px;
  border-bottom: 1px solid var(--br-0);
  cursor: pointer;
  position: relative;
}
.journal-row:hover { background: var(--bg-1); }
.journal-row.selected { background: var(--bg-2); }
.journal-row.selected::before {
  content: ''; position: absolute; left: 0; top: 0; bottom: 0;
  width: 2px; background: var(--accent);
}
.journal-row .t { font-family: 'JetBrains Mono', monospace; font-size: 11px; color: var(--fg-3); }
.journal-row .kind {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10.5px; font-weight: 700;
  padding: 3px 8px; border-radius: 3px;
  letter-spacing: 0.04em;
  white-space: nowrap;
}
.journal-row .kind.PROPOSE_BUY  { background: var(--human-bg); color: var(--human); }
.journal-row .kind.PROPOSE_SELL { background: var(--human-bg); color: var(--human); }
.journal-row .kind.EXECUTE_BUY  { background: var(--up-bg); color: var(--up); }
.journal-row .kind.EXECUTE_SELL { background: var(--down-bg); color: var(--down); }
.journal-row .kind.BLOCK        { background: var(--down-bg); color: var(--down); }
.journal-row .kind.SKIP         { background: var(--bg-3); color: var(--fg-2); }
.journal-row .summary { min-width: 0; overflow: hidden; }
.journal-row .summary .tick-line { display: flex; align-items: baseline; gap: 10px; }
.journal-row .summary .ticker { font-size: 13.5px; font-weight: 600; }
.journal-row .summary .sources { font-size: 10.5px; color: var(--fg-3); font-family: 'JetBrains Mono', monospace; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.journal-row .summary .tick-line { display: flex; align-items: baseline; gap: 10px; min-width: 0; }
.journal-row .summary .tick-line .ticker { flex-shrink: 0; }
.journal-row .summary .verdict { font-size: 12px; color: var(--fg-1); margin-top: 3px; }
.journal-row .gate-dots { display: flex; gap: 3px; }
.gate-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--bg-3);
}
.gate-dot.pass { background: var(--up); }
.gate-dot.fail { background: var(--down); }

.journal-detail {
  background: var(--bg-1);
  border-left: 1px solid var(--br-0);
  overflow-y: auto;
  padding: 22px 24px 40px;
}
.jd-head { display: flex; align-items: baseline; gap: 14px; margin-bottom: 4px; flex-wrap: wrap; }
.jd-head > * { white-space: nowrap; }
.jd-head .tick { font-size: 22px; font-weight: 600; letter-spacing: -0.01em; }
.jd-head .id { font-family: 'JetBrains Mono', monospace; font-size: 11px; color: var(--fg-3); margin-left: auto; }
.jd-sub { font-size: 12px; color: var(--fg-2); margin-bottom: 22px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.jd-section { margin-bottom: 22px; }
.jd-section .h {
  font-size: 10.5px;
  font-weight: 600; color: var(--fg-3);
  text-transform: uppercase; letter-spacing: 0.06em;
  margin-bottom: 10px;
  display: flex; align-items: baseline; gap: 10px;
  white-space: nowrap;
}
.jd-section .h > * { white-space: nowrap; }
.jd-section .h .n { color: var(--fg-2); font-family: 'JetBrains Mono', monospace; }

.gate-pipeline {
  display: flex; flex-direction: column;
  border: 1px solid var(--br-0);
  border-radius: 5px;
  overflow: hidden;
}
.gate-step {
  display: grid;
  grid-template-columns: 24px 140px 1fr;
  gap: 10px;
  align-items: center;
  padding: 10px 14px;
  border-bottom: 1px solid var(--br-0);
  font-size: 12px;
}
.gate-step:last-child { border-bottom: none; }
.gate-step .icon {
  width: 18px; height: 18px;
  border-radius: 3px;
  display: grid; place-items: center;
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px; font-weight: 700;
}
.gate-step.pass .icon { background: var(--up-bg); color: var(--up); }
.gate-step.fail .icon { background: var(--down-bg); color: var(--down); }
.gate-step .name { font-weight: 500; font-size: 12.5px; }
.gate-step .msg { color: var(--fg-2); font-size: 12px; }

.layers-list {
  border: 1px solid var(--br-0);
  border-radius: 5px;
  overflow: hidden;
}
.layer-item {
  display: grid;
  grid-template-columns: 80px 1fr;
  gap: 14px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--br-0);
  font-size: 12.5px;
  line-height: 1.5;
}
.layer-item:last-child { border-bottom: none; }
.layer-item .lname {
  font-size: 10.5px;
  color: var(--fg-3);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.layer-item .lname .n { color: var(--accent); font-family: 'JetBrains Mono', monospace; margin-right: 6px; }
.layer-item.alt .lbody { color: var(--ai); }
.layer-item.devil .lbody { color: var(--warn); }

/* Performance page */
.perf-grid {
  display: grid;
  grid-template-columns: 1fr 380px;
  gap: 1px;
  background: var(--br-0);
}
.perf-main { background: var(--bg-0); padding: 18px 22px; display: flex; flex-direction: column; gap: 18px; }
.perf-side { background: var(--bg-1); border-left: 1px solid var(--br-0); padding: 18px 22px; }

.leaderboard-row {
  display: grid;
  grid-template-columns: 24px 1fr 92px 64px 64px 64px 140px;
  align-items: center;
  gap: 14px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--br-0);
  font-size: 12.5px;
}
.leaderboard-row.head {
  font-size: 10.5px; color: var(--fg-3); font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.05em;
  padding: 10px 14px;
}
.leaderboard-row:last-child { border-bottom: none; }
.leaderboard-row:hover:not(.head) { background: var(--bg-2); }
.lb-rank { font-family: 'JetBrains Mono', monospace; color: var(--fg-3); font-size: 11px; }
.lb-src { font-family: 'JetBrains Mono', monospace; font-size: 12.5px; color: var(--fg-0); }
.lb-score {
  font-family: 'JetBrains Mono', monospace;
  font-variant-numeric: tabular-nums;
  font-size: 15px; font-weight: 500;
  display: flex; align-items: center; gap: 8px;
}
.score-bar {
  position: relative;
  width: 46px; height: 4px; background: var(--bg-3); border-radius: 2px;
}
.score-bar .fill { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 2px; }
.score-bar .fill.hi { background: var(--up); }
.score-bar .fill.mid { background: var(--warn); }
.score-bar .fill.lo { background: var(--down); }
.lb-spark { width: 130px; height: 28px; }

/* Modal */
.scrim {
  position: fixed; inset: 0;
  background: oklch(0.1 0 0 / 0.55);
  backdrop-filter: blur(1.5px);
  display: grid; place-items: center;
  z-index: 40;
}
.modal {
  width: 520px; max-width: calc(100vw - 40px);
  background: var(--bg-1);
  border: 1px solid var(--br-1);
  border-radius: 8px;
  box-shadow: var(--shadow-modal);
  overflow: hidden;
}
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px 12px;
  border-bottom: 1px solid var(--br-0);
}
.modal-head .title { font-weight: 600; font-size: 14px; }
.modal-body { padding: 18px; display: flex; flex-direction: column; gap: 14px; }
.modal-foot {
  padding: 12px 18px;
  border-top: 1px solid var(--br-0);
  display: flex; gap: 8px; justify-content: flex-end;
  background: var(--bg-1);
}
.field {
  display: grid;
  grid-template-columns: 100px 1fr;
  gap: 10px;
  align-items: center;
  font-size: 12.5px;
}
.field .lbl { color: var(--fg-2); font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.04em; font-weight: 600; }
.input {
  width: 100%;
  padding: 7px 10px;
  background: var(--bg-0);
  border: 1px solid var(--br-0);
  border-radius: 4px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 13px;
  color: var(--fg-0);
}
.input:focus { outline: 2px solid var(--focus); outline-offset: -1px; border-color: var(--accent); }
.preview-box {
  background: var(--bg-0);
  border: 1px solid var(--br-0);
  border-radius: 5px;
  padding: 12px 14px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 14px;
  font-size: 12.5px;
}
.preview-box .k { color: var(--fg-3); font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em; font-weight: 600; }
.preview-box .v { font-family: 'JetBrains Mono', monospace; text-align: right; }

/* Cmd-K palette */
.palette-scrim {
  position: fixed; inset: 0;
  background: oklch(0.1 0 0 / 0.55);
  backdrop-filter: blur(3px);
  display: grid; justify-items: center; align-items: start;
  padding-top: 15vh;
  z-index: 50;
}
.palette {
  width: 580px; max-width: calc(100vw - 40px);
  background: var(--bg-1);
  border: 1px solid var(--br-2);
  border-radius: 10px;
  box-shadow: var(--shadow-modal);
  overflow: hidden;
  display: flex; flex-direction: column;
  max-height: 60vh;
}
.palette-search {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--br-0);
  font-size: 14px;
}
.palette-search input {
  flex: 1;
  background: transparent; border: none; outline: none;
  font-size: 14px;
}
.palette-list { flex: 1; overflow-y: auto; padding: 6px 0; }
.palette-sec { padding: 6px 16px 3px; font-size: 10.5px; color: var(--fg-3); text-transform: uppercase; letter-spacing: 0.06em; font-weight: 600; }
.palette-item {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 18px;
  font-size: 13px;
  color: var(--fg-1);
}
.palette-item.on { background: var(--bg-3); color: var(--fg-0); }
.palette-item .type { font-family: 'JetBrains Mono', monospace; font-size: 10.5px; color: var(--fg-3); }
.palette-item .shortcut {
  margin-left: auto;
  font-family: 'JetBrains Mono', monospace; font-size: 10.5px; color: var(--fg-3);
}
.palette-foot {
  padding: 8px 18px;
  border-top: 1px solid var(--br-0);
  font-size: 10.5px; color: var(--fg-3);
  display: flex; gap: 16px;
}

/* Empty ghost placeholder for charts (sparklines use svg) */
svg.spark { display: block; }

/* Standalone source tag (outside signal-row context) — reused in Tesis cards. */
.src-tag {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  padding: 1px 5px;
  border-radius: 3px;
  background: var(--bg-3);
  color: var(--fg-2);
  letter-spacing: 0.02em;
  white-space: nowrap;
}

/* Generic card surface — used by Tesis grid; every other screen has a
   domain-specific block (signal-row, kpi-card, tbl-wrap, etc.) so we
   keep this minimal and don't leak into them. */
.card {
  background: var(--bg-1);
  border: 1px solid var(--br-0);
  border-radius: 6px;
}
.card:hover { border-color: var(--br-1); }
