:root {
  --bg: #070a0d;
  --bg-raised: #0b1015;
  --panel: #0d1319;
  --panel-strong: #111921;
  --panel-hover: #121c25;
  --line: #1d2934;
  --line-strong: #2a3947;
  --text: #edf3f8;
  --text-soft: #b8c4ce;
  --muted: #748493;
  --faint: #4f5e6b;
  --green: #42dc8b;
  --green-soft: rgba(66, 220, 139, .12);
  --red: #ff6675;
  --red-soft: rgba(255, 102, 117, .11);
  --amber: #f4bc5d;
  --amber-soft: rgba(244, 188, 93, .12);
  --cyan: #62c7ff;
  --cyan-soft: rgba(98, 199, 255, .11);
  --shadow: 0 28px 80px rgba(0, 0, 0, .52);
  --mono: "SFMono-Regular", "Cascadia Code", "Roboto Mono", Consolas, monospace;
  --sans: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  color-scheme: dark;
  background: var(--bg);
}

body {
  min-height: 100vh;
  margin: 0;
  overflow-x: hidden;
  color: var(--text);
  font-family: var(--sans);
  background:
    radial-gradient(circle at 22% -12%, rgba(60, 129, 168, .14), transparent 31rem),
    linear-gradient(180deg, #080c10 0, var(--bg) 26rem);
}

body::before {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  content: "";
  opacity: .16;
  background-image:
    linear-gradient(rgba(255, 255, 255, .018) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, .014) 1px, transparent 1px);
  background-size: 36px 36px;
  mask-image: linear-gradient(to bottom, black, transparent 80%);
}

button,
input {
  font: inherit;
}

button {
  color: inherit;
}

button,
[role="button"] {
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible,
input:focus-visible,
[tabindex]:focus-visible {
  outline: 2px solid var(--cyan);
  outline-offset: 2px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: fixed;
  top: 10px;
  left: 10px;
  z-index: 100;
  padding: 10px 14px;
  color: #06120c;
  font-weight: 800;
  text-decoration: none;
  background: var(--green);
  border-radius: 6px;
  transform: translateY(-150%);
}

.skip-link:focus {
  transform: translateY(0);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 76px;
  padding: 12px clamp(18px, 3vw, 44px);
  background: rgba(7, 10, 13, .9);
  border-bottom: 1px solid rgba(42, 57, 71, .72);
  backdrop-filter: blur(18px);
}

.brand-block,
.topbar-actions {
  display: flex;
  align-items: center;
}

.brand-block {
  gap: 13px;
}

.brand-mark {
  display: flex;
  align-items: flex-end;
  gap: 3px;
  width: 31px;
  height: 31px;
  padding: 6px;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  background: linear-gradient(145deg, #16212a, #0a0f14);
  box-shadow: inset 0 1px rgba(255, 255, 255, .04);
}

.brand-mark span {
  flex: 1;
  background: var(--green);
  border-radius: 1px 1px 0 0;
  box-shadow: 0 0 8px rgba(66, 220, 139, .28);
}

.brand-mark span:nth-child(1) { height: 36%; opacity: .58; }
.brand-mark span:nth-child(2) { height: 68%; opacity: .78; }
.brand-mark span:nth-child(3) { height: 100%; }

.eyebrow {
  margin: 0 0 3px;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .14em;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

.brand-block h1 {
  margin: 0;
  font-size: 19px;
  font-weight: 700;
  letter-spacing: -.02em;
}

.topbar-actions {
  gap: 12px;
}

.feed-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 32px;
  padding: 0 11px;
  color: var(--green);
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .12em;
  background: var(--green-soft);
  border: 1px solid rgba(66, 220, 139, .22);
  border-radius: 999px;
}

.feed-dot {
  width: 7px;
  height: 7px;
  background: currentColor;
  border-radius: 50%;
  box-shadow: 0 0 0 4px rgba(66, 220, 139, .1), 0 0 10px currentColor;
}

.feed-badge.is-delayed {
  color: var(--amber);
  background: var(--amber-soft);
  border-color: rgba(244, 188, 93, .24);
}

.feed-badge.is-error {
  color: var(--red);
  background: var(--red-soft);
  border-color: rgba(255, 102, 117, .24);
}

.feed-badge.is-loading {
  color: var(--muted);
  background: rgba(116, 132, 147, .08);
  border-color: var(--line);
}

.feed-badge.is-loading .feed-dot {
  animation: breathe 1.4s ease-in-out infinite;
}

.desk-clock {
  min-width: 88px;
  text-align: right;
}

.desk-clock span,
.desk-clock small {
  display: block;
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
}

.desk-clock span {
  color: var(--text-soft);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: .04em;
}

.desk-clock small {
  margin-top: 2px;
  color: var(--faint);
  font-size: 8px;
  font-weight: 700;
  letter-spacing: .12em;
}

.icon-button {
  display: inline-grid;
  place-items: center;
  width: 36px;
  height: 36px;
  padding: 0;
  color: var(--muted);
  cursor: pointer;
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 7px;
  transition: color .16s ease, background .16s ease, border-color .16s ease;
}

.icon-button:hover {
  color: var(--text);
  background: var(--panel-hover);
  border-color: var(--line-strong);
}

.icon-button svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.7;
}

.icon-button.is-spinning svg {
  animation: spin .9s linear infinite;
}

main {
  width: min(1880px, 100%);
  padding: 25px clamp(18px, 3vw, 44px) 56px;
  margin: 0 auto;
}

.metric-strip {
  display: grid;
  grid-template-columns: 1.05fr repeat(3, 1fr) 1.14fr;
  overflow: hidden;
  background: rgba(13, 19, 25, .68);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: 0 18px 54px rgba(0, 0, 0, .15);
}

.metric {
  position: relative;
  min-height: 116px;
  padding: 20px 22px;
  border-right: 1px solid var(--line);
}

.metric:last-child {
  border-right: 0;
}

.metric::after {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  height: 2px;
  content: "";
  opacity: 0;
  background: var(--cyan);
  transition: opacity .2s ease;
}

.metric-primary::after,
.metric-total::after {
  opacity: .65;
}

.metric p {
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .02em;
}

.metric strong {
  display: block;
  margin-bottom: 8px;
  font-family: var(--mono);
  font-size: clamp(22px, 2vw, 30px);
  font-weight: 650;
  font-variant-numeric: tabular-nums;
  letter-spacing: -.045em;
}

.metric span {
  display: block;
  overflow: hidden;
  color: var(--faint);
  font-size: 10px;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.money-positive { color: var(--green) !important; }
.money-negative { color: var(--red) !important; }
.money-neutral { color: var(--text-soft) !important; }
.money-unknown { color: var(--faint) !important; }

.source-rail {
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: 48px;
  padding: 8px 3px;
}

.session-label {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  flex: 0 0 auto;
  color: var(--text-soft);
  font-family: var(--mono);
  font-size: 9px;
  font-weight: 750;
  letter-spacing: .09em;
}

.session-pulse {
  width: 5px;
  height: 5px;
  background: var(--cyan);
  border-radius: 50%;
}

.source-list {
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
}

.source-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 8px;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 8px;
  font-weight: 700;
  letter-spacing: .05em;
  white-space: nowrap;
  background: rgba(13, 19, 25, .72);
  border: 1px solid var(--line);
  border-radius: 4px;
}

.source-chip::before {
  width: 5px;
  height: 5px;
  content: "";
  background: var(--green);
  border-radius: 50%;
}

.source-chip.is-stale {
  color: var(--amber);
  border-color: rgba(244, 188, 93, .2);
}

.source-chip.is-stale::before {
  background: var(--amber);
}

.source-chip.is-error {
  color: var(--red);
  border-color: rgba(255, 102, 117, .2);
}

.source-chip.is-error::before {
  background: var(--red);
}

.source-chip.is-loading::before {
  background: var(--faint);
}

.last-updated {
  margin: 0 0 0 auto;
  color: var(--faint);
  font-family: var(--mono);
  font-size: 9px;
  white-space: nowrap;
}

.desk-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 326px;
  gap: 14px;
  align-items: start;
}

.board-panel,
.tape-panel {
  overflow: hidden;
  background: rgba(13, 19, 25, .82);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: 0 18px 54px rgba(0, 0, 0, .16);
}

.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  min-height: 82px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
}

.panel-heading h2 {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -.015em;
}

.panel-heading > div > p:last-child:not(.eyebrow) {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 11px;
}

.search-control {
  display: flex;
  align-items: center;
  width: 210px;
  height: 36px;
  color: var(--faint);
  background: #090e13;
  border: 1px solid var(--line);
  border-radius: 6px;
  transition: border-color .16s ease, box-shadow .16s ease;
}

.search-control:focus-within {
  border-color: rgba(98, 199, 255, .54);
  box-shadow: 0 0 0 3px rgba(98, 199, 255, .08);
}

.search-control svg {
  flex: 0 0 auto;
  width: 15px;
  height: 15px;
  margin-left: 10px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-width: 1.8;
}

.search-control input {
  width: 100%;
  height: 100%;
  min-width: 0;
  padding: 0 10px 0 8px;
  color: var(--text);
  background: transparent;
  border: 0;
  outline: 0;
}

.search-control input::placeholder {
  color: var(--faint);
}

.inline-alert {
  margin: 12px 16px 0;
  padding: 10px 12px;
  color: #ffd3d8;
  font-size: 11px;
  line-height: 1.45;
  background: var(--red-soft);
  border: 1px solid rgba(255, 102, 117, .22);
  border-radius: 6px;
}

.table-shell {
  overflow-x: auto;
}

.bot-table {
  width: 100%;
  min-width: 1060px;
  border-spacing: 0;
  border-collapse: collapse;
  table-layout: fixed;
}

.bot-table th:nth-child(1) { width: 17%; }
.bot-table th:nth-child(2) { width: 11%; }
.bot-table th:nth-child(3) { width: 9%; }
.bot-table th:nth-child(4) { width: 12%; }
.bot-table th:nth-child(5) { width: 15%; }
.bot-table th:nth-child(6),
.bot-table th:nth-child(7),
.bot-table th:nth-child(8) { width: 9%; }
.bot-table th:nth-child(9) { width: 9%; }

.bot-table th {
  height: 34px;
  padding: 0 12px;
  color: var(--faint);
  font-family: var(--mono);
  font-size: 8px;
  font-weight: 750;
  letter-spacing: .08em;
  text-align: left;
  text-transform: uppercase;
  background: #0a0f14;
  border-bottom: 1px solid var(--line);
}

.bot-table th.number,
.bot-table td.number {
  text-align: right;
}

.bot-table td {
  height: 66px;
  padding: 9px 12px;
  vertical-align: middle;
  border-bottom: 1px solid rgba(29, 41, 52, .74);
}

.bot-table tbody tr {
  background: transparent;
  transition: background .14s ease;
}

.bot-table tbody tr:last-child td {
  border-bottom: 0;
}

.bot-table tbody tr:not(.loading-row):hover {
  background: var(--panel-hover);
}

.bot-table tbody tr.has-position {
  background: linear-gradient(90deg, rgba(66, 220, 139, .035), transparent 62%);
}

.bot-table tbody tr.has-attention {
  background: linear-gradient(90deg, rgba(255, 102, 117, .04), transparent 62%);
}

.bot-name-button {
  display: block;
  max-width: 100%;
  padding: 0;
  overflow: hidden;
  color: var(--text);
  font-size: 12px;
  font-weight: 680;
  text-align: left;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: pointer;
  background: transparent;
  border: 0;
}

.bot-name-button:hover {
  color: var(--cyan);
}

.cell-sub {
  display: block;
  max-width: 100%;
  margin-top: 5px;
  overflow: hidden;
  color: var(--faint);
  font-family: var(--mono);
  font-size: 8.5px;
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.state-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 22px;
  padding: 0 7px;
  color: var(--text-soft);
  font-family: var(--mono);
  font-size: 8px;
  font-weight: 800;
  letter-spacing: .06em;
  background: rgba(184, 196, 206, .07);
  border: 1px solid var(--line);
  border-radius: 4px;
  white-space: nowrap;
}

.state-badge::before {
  width: 5px;
  height: 5px;
  content: "";
  background: currentColor;
  border-radius: 50%;
}

.state-badge.live {
  color: var(--green);
  background: var(--green-soft);
  border-color: rgba(66, 220, 139, .2);
}

.state-badge.warning {
  color: var(--amber);
  background: var(--amber-soft);
  border-color: rgba(244, 188, 93, .2);
}

.state-badge.danger {
  color: var(--red);
  background: var(--red-soft);
  border-color: rgba(255, 102, 117, .2);
}

.market-symbol {
  display: block;
  color: var(--text-soft);
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 700;
}

.position-main,
.action-main {
  display: block;
  overflow: hidden;
  color: var(--text-soft);
  font-size: 10px;
  font-weight: 650;
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.position-main.long {
  color: var(--green);
}

.position-main.short {
  color: var(--red);
}

.pnl-value {
  color: var(--text-soft);
  font-family: var(--mono);
  font-size: 10.5px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: -.02em;
  white-space: nowrap;
}

.backtest-button,
.primary-button,
.secondary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  padding: 0 12px;
  font-size: 10px;
  font-weight: 750;
  cursor: pointer;
  border-radius: 5px;
  transition: color .14s ease, background .14s ease, border-color .14s ease, transform .14s ease;
}

.backtest-button {
  width: 100%;
  color: var(--cyan);
  background: var(--cyan-soft);
  border: 1px solid rgba(98, 199, 255, .2);
}

.backtest-button:hover,
.primary-button:hover {
  color: #041017;
  background: var(--cyan);
  border-color: var(--cyan);
}

.backtest-button:active,
.primary-button:active,
.secondary-button:active {
  transform: translateY(1px);
}

.primary-button {
  color: var(--cyan);
  background: var(--cyan-soft);
  border: 1px solid rgba(98, 199, 255, .26);
}

.secondary-button {
  color: var(--text-soft);
  background: transparent;
  border: 1px solid var(--line-strong);
}

.secondary-button:hover {
  color: var(--text);
  background: var(--panel-hover);
}

.loading-row td {
  padding: 25px 18px;
}

.loading-line {
  display: grid;
  grid-template-columns: 1.4fr 1fr 2fr;
  gap: 16px;
}

.loading-line span {
  height: 9px;
  background: linear-gradient(90deg, #131c24 25%, #1b2731 45%, #131c24 65%);
  background-size: 300% 100%;
  border-radius: 999px;
  animation: shimmer 1.5s linear infinite;
}

.bot-card-list {
  display: none;
}

.empty-state {
  padding: 56px 22px 64px;
  text-align: center;
}

.empty-state h3 {
  margin: 18px 0 8px;
  font-size: 15px;
}

.empty-state p {
  max-width: 390px;
  margin: 0 auto;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.55;
}

.empty-radar {
  position: relative;
  width: 48px;
  height: 48px;
  margin: 0 auto;
  border: 1px solid var(--line-strong);
  border-radius: 50%;
}

.empty-radar::before,
.empty-radar::after {
  position: absolute;
  inset: 8px;
  content: "";
  border: 1px solid var(--line);
  border-radius: 50%;
}

.empty-radar::after {
  inset: 21px;
  background: var(--cyan);
  border: 0;
}

.empty-radar span {
  position: absolute;
  top: 23px;
  left: 23px;
  width: 20px;
  height: 1px;
  background: linear-gradient(90deg, var(--cyan), transparent);
  transform-origin: left;
  animation: radar 2s linear infinite;
}

.tape-panel {
  position: sticky;
  top: 90px;
  max-height: calc(100vh - 112px);
}

.tape-heading {
  min-height: 82px;
}

.count-badge {
  flex: 0 0 auto;
  padding: 5px 7px;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 8px;
  font-weight: 700;
  background: #090e13;
  border: 1px solid var(--line);
  border-radius: 4px;
}

.event-tape {
  max-height: calc(100vh - 196px);
  padding: 0;
  margin: 0;
  overflow-y: auto;
  list-style: none;
  scrollbar-color: var(--line-strong) transparent;
}

.event-item {
  position: relative;
  display: grid;
  grid-template-columns: 86px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  min-height: 72px;
  padding: 12px 14px;
  border-bottom: 1px solid rgba(29, 41, 52, .74);
}

.event-item:last-child {
  border-bottom: 0;
}

.event-item::before {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 2px;
  content: "";
  background: var(--line);
}

.event-item.type-position::before { background: var(--green); }
.event-item.type-order::before { background: var(--amber); }
.event-item.type-fill::before { background: var(--cyan); }

.event-time {
  display: flex;
  flex-direction: column;
  gap: 3px;
  color: var(--faint);
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
}

.event-time span {
  color: var(--text-soft);
  font-size: 9px;
  font-weight: 700;
}

.event-time small {
  color: var(--faint);
  font-size: 7px;
  letter-spacing: .04em;
  text-transform: uppercase;
}

.event-copy {
  min-width: 0;
}

.event-copy strong,
.event-copy span,
.event-copy small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.event-copy strong {
  color: var(--text-soft);
  font-size: 10px;
  font-weight: 680;
}

.event-copy span {
  margin-top: 4px;
  color: var(--faint);
  font-size: 9px;
}

.event-copy small {
  margin-top: 4px;
  color: var(--cyan);
  font-family: var(--mono);
  font-size: 7px;
}

.event-pnl {
  font-family: var(--mono);
  font-size: 9px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.tape-loading,
.tape-empty {
  padding: 32px 18px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.5;
  text-align: center;
}

.drawer-scrim {
  position: fixed;
  inset: 0;
  z-index: 39;
  background: rgba(2, 5, 7, .62);
  backdrop-filter: blur(2px);
}

.detail-drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 40;
  display: flex;
  flex-direction: column;
  width: min(560px, 100vw);
  overflow: hidden;
  visibility: hidden;
  background: #0b1117;
  border-left: 1px solid var(--line-strong);
  box-shadow: var(--shadow);
  transform: translateX(102%);
  transition: transform .24s cubic-bezier(.2, .72, .2, 1), visibility .24s;
}

.detail-drawer.is-open {
  visibility: visible;
  transform: translateX(0);
}

.drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  min-height: 83px;
  padding: 16px 20px;
  background: rgba(13, 19, 25, .9);
  border-bottom: 1px solid var(--line);
}

.drawer-header h2 {
  margin: 0;
  font-size: 18px;
  font-weight: 720;
  letter-spacing: -.025em;
}

.drawer-content {
  flex: 1;
  padding: 20px;
  overflow-y: auto;
  scrollbar-color: var(--line-strong) transparent;
}

.drawer-state-line {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding-bottom: 18px;
}

.drawer-meta {
  color: var(--muted);
  font-family: var(--mono);
  font-size: 9px;
}

.drawer-section {
  padding: 18px 0;
  border-top: 1px solid var(--line);
}

.drawer-section:first-of-type {
  border-top: 0;
}

.drawer-section-title {
  margin: 0 0 12px;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 9px;
  font-weight: 750;
  letter-spacing: .1em;
  text-transform: uppercase;
}

.detail-grid,
.backtest-metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.detail-cell,
.backtest-metric {
  min-width: 0;
  padding: 12px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 6px;
}

.detail-cell span,
.backtest-metric span {
  display: block;
  margin-bottom: 7px;
  overflow: hidden;
  color: var(--faint);
  font-size: 9px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.detail-cell strong,
.backtest-metric strong {
  display: block;
  overflow: hidden;
  color: var(--text-soft);
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.detail-note,
.backtest-disclosure {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.55;
}

.detail-warning {
  padding: 10px 11px;
  margin: 0 0 14px;
  color: #ffd3d8;
  font-size: 10px;
  line-height: 1.5;
  background: var(--red-soft);
  border: 1px solid rgba(255, 102, 117, .2);
  border-radius: 6px;
}

.drawer-actions {
  display: flex;
  gap: 8px;
  padding-top: 18px;
}

.drawer-actions .primary-button {
  flex: 1;
}

.backtest-banner {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px;
  margin-bottom: 16px;
  background: var(--amber-soft);
  border: 1px solid rgba(244, 188, 93, .2);
  border-radius: 6px;
}

.backtest-banner svg {
  flex: 0 0 auto;
  width: 16px;
  height: 16px;
  color: var(--amber);
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.7;
}

.backtest-banner strong,
.backtest-banner span {
  display: block;
}

.backtest-banner strong {
  color: var(--amber);
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: .1em;
}

.backtest-banner span {
  margin-top: 4px;
  color: #c7a86f;
  font-size: 9px;
  line-height: 1.45;
}

.backtest-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  padding: 12px;
  margin-bottom: 16px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 7px;
}

.range-group {
  display: inline-flex;
  gap: 3px;
  padding: 3px;
  background: #080c10;
  border: 1px solid var(--line);
  border-radius: 5px;
}

.range-button {
  min-width: 38px;
  height: 28px;
  padding: 0 8px;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 8px;
  font-weight: 750;
  cursor: pointer;
  background: transparent;
  border: 0;
  border-radius: 3px;
}

.range-button:hover {
  color: var(--text);
}

.range-button.is-active {
  color: #071017;
  background: var(--cyan);
}

.check-control {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 9px;
  cursor: pointer;
}

.check-control input {
  width: 14px;
  height: 14px;
  accent-color: var(--cyan);
}

.run-button {
  margin-left: auto;
}

.backtest-status {
  display: inline-flex;
  align-items: center;
  min-height: 23px;
  padding: 0 8px;
  margin-bottom: 10px;
  color: var(--text-soft);
  font-family: var(--mono);
  font-size: 8px;
  font-weight: 800;
  letter-spacing: .07em;
  background: rgba(184, 196, 206, .07);
  border: 1px solid var(--line);
  border-radius: 4px;
  text-transform: uppercase;
}

.backtest-status.available {
  color: var(--green);
  background: var(--green-soft);
  border-color: rgba(66, 220, 139, .2);
}

.backtest-status.partial,
.backtest-status.needs-data {
  color: var(--amber);
  background: var(--amber-soft);
  border-color: rgba(244, 188, 93, .2);
}

.backtest-kind {
  margin: 0 0 16px;
  color: var(--text-soft);
  font-size: 12px;
  font-weight: 650;
}

.backtest-chart {
  height: 102px;
  padding: 12px 8px 4px;
  margin-top: 10px;
  background: #090e13;
  border: 1px solid var(--line);
  border-radius: 6px;
}

.backtest-chart svg {
  width: 100%;
  height: 100%;
  overflow: visible;
}

.backtest-chart .zero-line {
  stroke: var(--line-strong);
  stroke-dasharray: 3 4;
}

.backtest-chart .equity-line {
  fill: none;
  stroke: var(--cyan);
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
  vector-effect: non-scaling-stroke;
}

.notes-list {
  padding: 0;
  margin: 0;
  list-style: none;
}

.notes-list li {
  position: relative;
  padding: 8px 0 8px 16px;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.5;
  border-bottom: 1px solid rgba(29, 41, 52, .62);
}

.notes-list li:last-child {
  border-bottom: 0;
}

.notes-list li::before {
  position: absolute;
  top: 14px;
  left: 2px;
  width: 4px;
  height: 4px;
  content: "";
  background: var(--amber);
  border-radius: 50%;
}

.backtest-table-shell {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 6px;
}

.backtest-table {
  width: 100%;
  min-width: 710px;
  border-spacing: 0;
  border-collapse: collapse;
}

.backtest-table th,
.backtest-table td {
  padding: 8px 9px;
  font-family: var(--mono);
  font-size: 8px;
  text-align: left;
  border-bottom: 1px solid var(--line);
}

.backtest-table th {
  color: var(--faint);
  font-weight: 750;
  letter-spacing: .06em;
  background: #090e13;
}

.backtest-table td {
  color: var(--text-soft);
  font-variant-numeric: tabular-nums;
}

.backtest-table th:nth-child(1),
.backtest-table th:nth-child(2),
.backtest-table td:nth-child(1),
.backtest-table td:nth-child(2) {
  min-width: 130px;
}

.trade-moment {
  display: flex;
  flex-direction: column;
  gap: 3px;
  color: var(--text-soft);
  white-space: nowrap;
}

.trade-moment small {
  color: var(--faint);
  font-size: 7px;
}

.trade-moment.is-unknown {
  color: var(--faint);
  white-space: normal;
}

.drawer-section-title-row {
  display: flex;
  gap: 12px;
  align-items: baseline;
  justify-content: space-between;
}

.drawer-section-title-row > span {
  color: var(--faint);
  font-family: var(--mono);
  font-size: 8px;
  letter-spacing: .04em;
}

.backtest-table tr:last-child td {
  border-bottom: 0;
}

.backtest-table th:last-child,
.backtest-table td:last-child {
  text-align: right;
}

.drawer-loading {
  display: grid;
  place-items: center;
  min-height: 360px;
  color: var(--muted);
  text-align: center;
}

.loader-ring {
  width: 32px;
  height: 32px;
  margin: 0 auto 14px;
  border: 2px solid var(--line);
  border-top-color: var(--cyan);
  border-radius: 50%;
  animation: spin .9s linear infinite;
}

.drawer-loading strong,
.drawer-loading span {
  display: block;
}

.drawer-loading strong {
  color: var(--text-soft);
  font-size: 12px;
}

.drawer-loading span {
  max-width: 330px;
  margin-top: 6px;
  font-size: 10px;
  line-height: 1.5;
}

.drawer-error {
  padding: 16px;
  color: #ffd3d8;
  font-size: 11px;
  line-height: 1.55;
  background: var(--red-soft);
  border: 1px solid rgba(255, 102, 117, .22);
  border-radius: 7px;
}

.toast-region {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 60;
  display: grid;
  gap: 8px;
  width: min(340px, calc(100vw - 36px));
}

.toast {
  padding: 12px 14px;
  color: var(--text-soft);
  font-size: 10px;
  line-height: 1.45;
  background: #111a22;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  box-shadow: 0 15px 40px rgba(0, 0, 0, .4);
  animation: toast-in .2s ease both;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

@keyframes shimmer {
  to { background-position: -300% 0; }
}

@keyframes breathe {
  50% { opacity: .32; }
}

@keyframes radar {
  to { transform: rotate(360deg); }
}

@keyframes toast-in {
  from { opacity: 0; transform: translateY(8px); }
}

@media (max-width: 1280px) {
  .desk-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .tape-panel {
    position: static;
    max-height: none;
  }

  .event-tape {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    max-height: 360px;
  }

  .event-item {
    border-right: 1px solid rgba(29, 41, 52, .74);
  }
}

@media (max-width: 980px) {
  .metric-strip {
    grid-template-columns: repeat(3, 1fr);
  }

  .metric {
    border-bottom: 1px solid var(--line);
  }

  .metric:nth-child(3) {
    border-right: 0;
  }

  .metric:nth-child(4),
  .metric:nth-child(5) {
    border-bottom: 0;
  }

  .source-rail {
    flex-wrap: wrap;
    gap: 8px 12px;
    padding: 11px 3px;
  }

  .last-updated {
    width: 100%;
    margin-left: 0;
  }
}

@media (max-width: 760px) {
  .topbar {
    min-height: 66px;
    padding: 10px 14px;
  }

  .brand-block .eyebrow,
  .desk-clock {
    display: none;
  }

  .brand-block h1 {
    font-size: 16px;
  }

  .feed-badge {
    min-height: 30px;
    padding-inline: 9px;
    font-size: 9px;
  }

  main {
    padding: 16px 12px 40px;
  }

  .metric-strip {
    grid-template-columns: repeat(2, 1fr);
  }

  .metric {
    min-height: 102px;
    padding: 16px;
  }

  .metric:nth-child(2),
  .metric:nth-child(4) {
    border-right: 0;
  }

  .metric:nth-child(3) {
    border-right: 1px solid var(--line);
  }

  .metric:nth-child(4) {
    border-bottom: 1px solid var(--line);
  }

  .metric:nth-child(5) {
    grid-column: 1 / -1;
    border-right: 0;
  }

  .metric strong {
    font-size: 23px;
  }

  .source-list {
    width: 100%;
    overflow-x: auto;
    padding-bottom: 2px;
  }

  .panel-heading {
    align-items: flex-start;
    min-height: auto;
    padding: 15px;
  }

  .board-panel > .panel-heading {
    flex-direction: column;
  }

  .search-control {
    width: 100%;
  }

  .table-shell {
    display: none;
  }

  .bot-card-list {
    display: grid;
  }

  .bot-card {
    min-width: 0;
    padding: 15px;
    overflow: hidden;
    border-bottom: 1px solid var(--line);
  }

  .bot-card:last-child {
    border-bottom: 0;
  }

  .bot-card-header,
  .bot-card-state,
  .bot-card-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
  }

  .bot-card-header .bot-name-button {
    font-size: 13px;
  }

  .bot-card-header > div {
    min-width: 0;
  }

  .bot-card-state {
    margin-top: 12px;
  }

  .mobile-position {
    color: var(--text-soft);
    font-family: var(--mono);
    font-size: 9px;
    font-weight: 700;
  }

  .mobile-pnl-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 7px;
    margin-top: 13px;
  }

  .mobile-pnl {
    min-width: 0;
    padding: 9px;
    background: #090e13;
    border: 1px solid var(--line);
    border-radius: 5px;
  }

  .mobile-pnl span,
  .mobile-pnl strong {
    display: block;
  }

  .mobile-pnl span {
    margin-bottom: 5px;
    color: var(--faint);
    font-size: 8px;
  }

  .mobile-pnl strong {
    overflow: hidden;
    font-family: var(--mono);
    font-size: 10px;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .bot-card-actions {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 82px;
    margin-top: 12px;
  }

  .mobile-action {
    min-width: 0;
    overflow: hidden;
    color: var(--muted);
    font-size: 9px;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .bot-card-actions .backtest-button {
    width: 82px;
    min-height: 38px;
  }

  .event-tape {
    display: block;
    max-height: 430px;
  }

  .event-item {
    border-right: 0;
  }

  .drawer-content {
    padding: 16px;
  }

  .detail-grid,
  .backtest-metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .backtest-controls {
    align-items: flex-start;
  }

  .run-button {
    width: 100%;
    margin-left: 0;
  }
}

@media (max-width: 430px) {
  .topbar-actions {
    gap: 8px;
  }

  .topbar-actions > .icon-button {
    display: none;
  }

  .brand-mark {
    width: 28px;
    height: 28px;
  }

  .metric {
    padding: 14px;
  }

  .metric span {
    font-size: 9px;
  }

  .panel-heading h2 {
    font-size: 15px;
  }

  .detail-grid,
  .backtest-metrics {
    grid-template-columns: 1fr 1fr;
  }

  .drawer-header {
    min-height: 72px;
    padding: 13px 16px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}
