:root {
  color-scheme: dark;
  --bg: #0f1115;
  --band: #171b22;
  --panel: #1d222b;
  --panel-strong: #252c36;
  --text: #eef2f7;
  --muted: #9ca8b6;
  --line: #313945;
  --buy: #32d583;
  --sell: #ff6b6b;
  --accent: #5dd4ff;
  --warn: #fdb022;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

abwin-review-app {
  display: block;
  min-height: 100%;
}

abwin-topbar,
abwin-key-data,
abwin-floating-ticks,
abwin-chart-panel,
abwin-agent-columns,
abwin-portfolio-panel,
abwin-fills-list,
abwin-decisions-list {
  display: contents;
}

input,
button,
select {
  font: inherit;
}

.auth-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: var(--bg);
}

.auth-panel {
  width: min(420px, 100%);
  display: grid;
  gap: 16px;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--band);
}

.auth-panel p {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.45;
}

.auth-panel form {
  display: grid;
  gap: 14px;
}

.auth-panel label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
}

.auth-panel input {
  min-height: 42px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  color: var(--text);
}

.auth-error {
  padding: 10px 12px;
  border: 1px solid rgba(255, 107, 107, 0.35);
  border-radius: 6px;
  color: var(--sell);
  background: rgba(255, 107, 107, 0.08);
  font-size: 13px;
  line-height: 1.4;
}

.shell {
  min-height: 100%;
}

.workspace {
  min-width: 0;
  display: grid;
  grid-template-rows: auto auto minmax(360px, 58vh) minmax(260px, 1fr);
}

.topbar,
.run-menu header,
.panel header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.topbar {
  position: relative;
  z-index: 90;
  align-items: flex-start;
  padding: 18px 22px;
  border-bottom: 1px solid var(--line);
  background: var(--band);
}

.topbar > div:first-child {
  min-width: 0;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 22px;
  line-height: 1.2;
}

h2 {
  font-size: 14px;
  line-height: 1.2;
}

#run-subtitle {
  margin-top: 5px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}

.controls {
  min-width: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: flex-start;
  justify-content: flex-end;
}

.control-label {
  display: block;
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.2;
  text-transform: uppercase;
}

.run-picker {
  position: relative;
  width: min(360px, 36vw);
  min-width: 250px;
}

.run-menu-button {
  width: 100%;
  min-height: 44px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 0 10px;
  text-align: left;
}

.run-menu-button::after {
  content: "v";
  color: var(--muted);
  font-size: 12px;
}

.run-button-main {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.run-button-title,
.run-button-meta {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.run-button-title {
  font-size: 12px;
  color: var(--text);
}

.run-button-meta {
  font-size: 11px;
  color: var(--muted);
}

.run-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 120;
  width: min(520px, calc(100vw - 32px));
  max-height: min(620px, calc(100vh - 120px));
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--band);
  box-shadow: 0 18px 42px rgba(0, 0, 0, 0.38);
  overflow: hidden;
}

.run-menu header {
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
}

.summary-stack {
  position: sticky;
  top: 0;
  z-index: 75;
}

.key-data {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 0;
  border-bottom: 1px solid var(--line);
  background: rgba(23, 27, 34, 0.98);
}

.key-data-item {
  min-width: 0;
  padding: 10px 14px;
  border-right: 1px solid var(--line);
}

.key-data-label {
  color: var(--muted);
  font-size: 10px;
  line-height: 1.2;
  text-transform: uppercase;
}

.key-data-value {
  margin-top: 4px;
  color: var(--text);
  font-size: 13px;
  line-height: 1.35;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.key-data-value.positive {
  color: var(--buy);
}

.key-data-value.negative {
  color: var(--sell);
}

.live-status {
  align-self: flex-start;
  margin-top: 18px;
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.topbar-action {
  align-self: flex-start;
  margin-top: 18px;
}

.live-status.connected {
  color: var(--buy);
}

.live-status.reconnecting {
  color: var(--warn);
}

.floating-ticks {
  position: relative;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 10px;
  padding: 8px 14px;
  border-bottom: 1px solid var(--line);
  background: rgba(23, 27, 34, 0.98);
  overflow: hidden;
}

.floating-ticks header {
  display: flex;
  align-items: center;
  flex: 0 0 auto;
  gap: 8px;
}

.floating-ticks header h2 {
  color: var(--text);
  font-size: 11px;
  line-height: 1.2;
  text-transform: uppercase;
}

.floating-ticks header span,
.floating-tick-empty {
  color: var(--muted);
  font-size: 11px;
}

.floating-ticks-title-compact {
  display: none;
}

.floating-ticks-list {
  flex: 1 1 auto;
  min-width: 0;
  display: grid;
  grid-template-columns: repeat(var(--floating-tick-count), minmax(156px, 1fr));
  gap: 6px;
  overflow-x: auto;
  overscroll-behavior-x: contain;
}

.floating-tick-row {
  min-width: 0;
  min-height: 28px;
  display: grid;
  grid-template-columns: minmax(68px, 1fr) 9ch;
  align-items: center;
  gap: 7px;
  padding: 0 8px;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: inherit;
  text-align: left;
  white-space: nowrap;
}

.floating-tick-row:hover,
.floating-tick-row.active {
  background: rgba(93, 212, 255, 0.12);
}

.floating-tick-row:disabled {
  cursor: default;
  opacity: 1;
}

.floating-tick-symbol {
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
}

.floating-tick-price {
  justify-self: end;
  min-width: 9ch;
  text-align: right;
  color: var(--text);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

label {
  min-width: 0;
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
}

select,
button {
  min-height: 34px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
  border-radius: 6px;
}

select {
  min-width: 128px;
  padding: 0 10px;
}

button {
  padding: 0 12px;
  cursor: pointer;
}

.chart-section {
  position: relative;
  z-index: 20;
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  min-height: 360px;
  border-bottom: 1px solid var(--line);
  background: #10141a;
  overflow: visible;
}

.indicator-panel {
  min-width: 0;
  padding: 10px;
  border-right: 1px solid var(--line);
  background: rgba(23, 27, 34, 0.96);
  overflow-y: auto;
}

.indicator-panel-toggle {
  display: none;
}

.indicator-panel-body {
  display: grid;
  gap: 14px;
}

.chart-preferences {
  display: grid;
  gap: 14px;
}

.indicator-group {
  display: grid;
  gap: 7px;
}

.indicator-subgroup {
  display: grid;
  gap: 4px;
}

.indicator-group-control {
  font-weight: 700;
}

.indicator-subgroup-title {
  padding-left: 20px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  line-height: 1.2;
}

.indicator-subitems {
  display: grid;
  gap: 3px;
  padding-left: 20px;
}

.indicator-subitem {
  min-height: 21px;
  color: var(--muted);
  font-size: 11px;
}

.indicator-group-title {
  color: var(--muted);
  font-size: 10px;
  line-height: 1.2;
  text-transform: uppercase;
}

.preference-control {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 24px;
  color: var(--text);
  font-size: 12px;
  text-transform: none;
}

.preference-control input[type="checkbox"] {
  width: 14px;
  height: 14px;
  accent-color: var(--accent);
}

.preference-control input[type="range"] {
  width: 88px;
  accent-color: var(--accent);
}

.preference-control.disabled {
  color: var(--muted);
}

.preference-heading {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.2;
  text-transform: uppercase;
}

.preference-divider {
  width: 1px;
  min-height: 26px;
  background: var(--line);
}

.chart-frame {
  position: relative;
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
}

.chart-canvas {
  position: relative;
  min-width: 0;
  min-height: 0;
}

.chart-host {
  display: block;
  position: relative;
  z-index: 1;
  width: 100%;
  height: 100%;
  overflow: hidden;
  touch-action: pan-y;
}

.visual-indicator-layer {
  position: absolute;
  inset: 0;
  z-index: 28;
  pointer-events: none;
}

.visual-indicator-stack {
  position: absolute;
  top: 0;
  width: 0;
}

.visual-indicator-line {
  position: absolute;
  inset: 0 auto 0 0;
  border-left: 1px solid #9ca8b6;
  opacity: 0.82;
}

.visual-indicator-line.blockers,
.visual-indicator-line.setups {
  border-left-width: 2px;
  opacity: 0.95;
}

.visual-indicator-line.trend,
.visual-indicator-line.momentum {
  opacity: 0.48;
}

.visual-indicator-labels {
  position: absolute;
  left: 5px;
  display: grid;
  gap: 3px;
}

.visual-indicator-labels.blockers {
  top: 34px;
}

.visual-indicator-labels.setups {
  top: 67px;
}

.visual-indicator-labels.trend {
  top: 100px;
}

.visual-indicator-labels.momentum {
  top: 133px;
}

.visual-indicator-label {
  display: inline-flex;
  width: auto;
  max-width: none;
  max-height: 96px;
  padding: 5px 2px;
  border: 1px solid rgba(156, 168, 182, 0.7);
  border-radius: 4px;
  background: rgba(156, 168, 182, 0.18);
  color: var(--text);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.36);
  font-size: 9px;
  font-weight: 700;
  line-height: 1;
  text-orientation: mixed;
  white-space: nowrap;
  text-shadow: 0 1px 1px rgba(0, 0, 0, 0.55);
  writing-mode: vertical-rl;
}

.live-candle-line {
  position: absolute;
  z-index: 35;
  width: 0;
  border-left: 2px solid #fdb022;
  pointer-events: none;
}

.live-candle-line.persisted {
  border-left-color: #9ca8b6;
}

.live-candle-line span {
  position: absolute;
  top: 8px;
  left: 6px;
  padding: 2px 5px;
  border-radius: 4px;
  background: rgba(253, 176, 34, 0.16);
  color: #ffd66e;
  font-size: 10px;
  font-weight: 700;
  line-height: 1;
}

.live-candle-line.persisted span {
  background: rgba(156, 168, 182, 0.16);
  color: #d5dbe3;
}

.chart-legend {
  position: relative;
  z-index: 30;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  max-width: 100%;
  padding: 8px 12px 10px;
  border-top: 1px solid var(--line);
  color: var(--text);
  font-size: 12px;
  line-height: 1.35;
  pointer-events: none;
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 0;
}

.legend-swatch {
  width: 9px;
  height: 9px;
  border-radius: 2px;
}

.empty-state {
  position: absolute;
  inset: 0;
  z-index: 25;
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 14px;
  pointer-events: none;
}

.tooltip {
  position: absolute;
  z-index: 50;
  max-width: 280px;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(23, 27, 34, 0.96);
  color: var(--text);
  font-size: 12px;
  line-height: 1.45;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.24);
  pointer-events: none;
}

.details {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: minmax(260px, 380px) minmax(360px, 1fr) minmax(260px, 420px);
  gap: 0;
  min-height: 0;
}

.details-tabs {
  display: none;
}

.details-tab-panel {
  display: contents;
}

.agent-columns {
  grid-column: 1;
  grid-row: 1;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  min-width: 0;
  min-height: 0;
}

.agent-column {
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  border-right: 1px solid var(--line);
  background: var(--bg);
}

.agent-column-left {
  grid-column: 1;
}

.agent-column-right {
  grid-column: 1;
}

#detail-tabpanel-decisions {
  grid-column: 2;
  grid-row: 1;
  display: block;
  min-width: 0;
  min-height: 0;
}

#detail-tabpanel-fills {
  grid-column: 3;
  grid-row: 1;
  display: block;
  min-width: 0;
  min-height: 0;
}

#detail-tabpanel-portfolio {
  display: none;
}

.panel {
  min-width: 0;
  min-height: 0;
  background: var(--bg);
  border-right: 1px solid var(--line);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
}

.panel header {
  padding: 13px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--band);
}

.panel header span {
  min-width: 0;
  color: var(--muted);
  font-size: 12px;
  overflow-wrap: anywhere;
}

.event-list,
.decision-list,
.portfolio-list,
.runs-list {
  overflow: auto;
}

.runs-list {
  max-height: min(536px, calc(100vh - 186px));
}

.event-row,
.decision-row,
.run-row {
  border-bottom: 1px solid var(--line);
}

.event-row {
  display: grid;
  grid-template-columns: 64px minmax(0, 1fr);
  gap: 10px;
  padding: 11px 14px;
}

.side-pill {
  width: 48px;
  height: 24px;
  display: grid;
  place-items: center;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}

.side-pill.buy {
  background: rgba(50, 213, 131, 0.16);
  color: var(--buy);
}

.side-pill.sell {
  background: rgba(255, 107, 107, 0.16);
  color: var(--sell);
}

.event-main,
.decision-main,
.run-main {
  min-width: 0;
}

.meta-line,
.reason-line {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.price-line {
  font-size: 13px;
  line-height: 1.4;
  overflow-wrap: anywhere;
}

.pnl-value {
  font-weight: 700;
}

.pnl-value.positive {
  color: var(--buy);
}

.pnl-value.negative {
  color: var(--sell);
}

.portfolio-list {
  padding: 10px;
}

.portfolio-agent {
  margin: 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  overflow: hidden;
}

.portfolio-list .portfolio-agent {
  margin: 0;
}

.portfolio-agent summary {
  min-height: 42px;
  padding: 9px 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  cursor: pointer;
  background: var(--panel-strong);
}

.portfolio-agent-summary-side {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
}

.portfolio-agent-main {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
  overflow-wrap: anywhere;
}

.portfolio-agent-main > span:last-child {
  min-width: 0;
  overflow-wrap: anywhere;
}

.portfolio-equity {
  flex: 0 0 auto;
  font-size: 13px;
  font-weight: 700;
}

.portfolio-equity.positive,
.portfolio-metric strong.positive {
  color: var(--buy);
}

.portfolio-equity.negative,
.portfolio-metric strong.negative {
  color: var(--sell);
}

.portfolio-metrics {
  padding: 10px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.portfolio-metric {
  min-width: 0;
  padding: 8px;
  border-radius: 6px;
  background: var(--bg);
}

.portfolio-metric span,
.portfolio-meta {
  color: var(--muted);
  font-size: 11px;
}

.portfolio-metric strong {
  display: block;
  margin-top: 3px;
  font-size: 13px;
  overflow-wrap: anywhere;
}

.portfolio-meta {
  padding: 0 10px 10px;
}

.portfolio-reserved-allocation {
  padding: 0 10px 10px;
}

.portfolio-subhead {
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.2;
  text-transform: uppercase;
}

.portfolio-allocation-row {
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(70px, 1fr) minmax(72px, 1fr) minmax(66px, auto);
  gap: 8px;
  padding: 7px 8px;
  border: 1px solid rgba(253, 176, 34, 0.22);
  border-radius: 6px;
  background: rgba(253, 176, 34, 0.08);
  color: #fde68a;
  font-size: 12px;
}

.portfolio-allocation-row + .portfolio-allocation-row {
  margin-top: 6px;
}

.portfolio-allocation-row span {
  min-width: 0;
  overflow-wrap: anywhere;
}

.portfolio-assets {
  border-top: 1px solid var(--line);
}

.portfolio-asset {
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(70px, 1fr) minmax(72px, 1fr) minmax(72px, 1fr);
  gap: 8px;
  padding: 8px 10px;
  border-top: 1px solid rgba(156, 168, 182, 0.12);
  color: #cbd5e1;
  font-size: 12px;
}

.portfolio-asset span {
  min-width: 0;
  overflow-wrap: anywhere;
}

.portfolio-asset:first-child {
  border-top: 0;
}

.portfolio-asset.empty {
  display: block;
  color: var(--muted);
}

.decision-row {
  padding: 12px 16px;
}

.decision-row.live-updated {
  animation: decision-live-update 900ms ease-out;
}

.decision-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 6px;
}

.agent-tag {
  max-width: 100%;
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 8px;
  border-radius: 6px;
  background: var(--panel-strong);
  font-size: 12px;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.action-tag {
  min-width: 0;
  color: var(--accent);
  font-size: 12px;
  overflow-wrap: anywhere;
}

.rejected {
  color: var(--warn);
}

.orders {
  margin-top: 8px;
  display: grid;
  gap: 5px;
  color: #cbd5e1;
  font-size: 12px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.orders.diagnostics {
  color: var(--muted);
}

@keyframes decision-live-update {
  0% {
    background: rgba(93, 212, 255, 0);
    opacity: 0;
    transform: translateY(-6px);
  }

  28% {
    background: rgba(93, 212, 255, 0.16);
    opacity: 1;
    transform: translateY(0);
  }

  100% {
    background: rgba(93, 212, 255, 0);
    opacity: 1;
    transform: translateY(0);
  }
}

.run-row {
  width: 100%;
  min-height: 78px;
  padding: 12px 14px;
  border-top: 0;
  border-left: 0;
  border-right: 0;
  border-radius: 0;
  background: transparent;
  color: var(--text);
  text-align: left;
}

.run-row:hover,
.run-row.active {
  background: var(--panel);
}

.run-title {
  font-size: 13px;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.run-main .meta-line {
  margin-top: 6px;
}

.error {
  position: fixed;
  left: 18px;
  bottom: 18px;
  z-index: 240;
  max-width: min(720px, calc(100vw - 36px));
  max-height: min(40vh, 260px);
  padding: 12px 14px;
  border: 1px solid rgba(253, 176, 34, 0.5);
  border-radius: 6px;
  background: #2b2112;
  color: #ffe6a6;
  font-size: 13px;
  line-height: 1.45;
  overflow-y: auto;
  overflow-wrap: anywhere;
  white-space: normal;
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.45);
}

.muted-row {
  padding: 16px;
  color: var(--muted);
  font-size: 13px;
}

@media (max-width: 960px) {
  .run-picker {
    width: 100%;
  }
}

@media (max-width: 720px) {
  .workspace {
    display: block;
  }

  .topbar {
    align-items: stretch;
    flex-direction: column;
    gap: 14px;
    padding: 14px 12px;
  }

  .summary-stack {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    width: 100%;
    position: static;
    z-index: auto;
  }

  h1 {
    font-size: 20px;
  }

  #run-subtitle {
    overflow-wrap: anywhere;
  }

  .controls {
    display: grid;
    grid-template-columns: 1fr;
    gap: 9px;
    width: 100%;
  }

  .run-picker,
  .topbar-action,
  .live-status {
    grid-column: 1 / -1;
  }

  .run-picker {
    min-width: 0;
    width: 100%;
  }

  .run-button-title,
  .run-button-meta {
    white-space: normal;
  }

  .live-status {
    width: 100%;
    margin-top: 0;
    justify-content: center;
    text-align: center;
    white-space: normal;
    overflow-wrap: anywhere;
  }

  .topbar-action {
    width: 100%;
    margin-top: 0;
  }

  .run-menu {
    left: 0;
    right: auto;
    width: 100%;
    max-height: min(520px, calc(100vh - 172px));
  }

  .run-menu header {
    gap: 10px;
  }

  .runs-list {
    max-height: min(438px, calc(100vh - 254px));
  }

  .key-data {
    order: 1;
    position: static;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .key-data-item {
    padding: 9px 10px;
    border-right: 1px solid var(--line);
    border-bottom: 1px solid rgba(156, 168, 182, 0.12);
  }

  .key-data-item:nth-child(2n) {
    border-right: 0;
  }

  .key-data-value {
    white-space: normal;
    overflow-wrap: anywhere;
  }

  .floating-ticks {
    order: 2;
    display: grid;
    align-items: stretch;
    gap: 8px;
    width: 100%;
    padding: 9px 0 10px;
    overflow: visible;
  }

  .floating-ticks header {
    display: none;
  }

  .floating-ticks-title-full {
    display: none;
  }

  .floating-ticks-title-compact {
    display: inline;
  }

  .floating-ticks-list {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 0;
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 6px;
    overflow: hidden;
  }

  .floating-tick-row {
    min-width: 0;
    width: 100%;
    min-height: 46px;
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(9ch, max-content);
    gap: 12px;
    padding: 7px 8px;
    border-bottom: 1px solid var(--line);
    border-radius: 0;
    white-space: normal;
  }

  .floating-tick-row:last-child {
    border-bottom: 0;
  }

  .floating-tick-empty {
    grid-column: 1 / -1;
    padding: 10px;
  }

  .floating-tick-symbol,
  .floating-tick-price {
    min-width: 0;
  }

  .floating-tick-symbol,
  .floating-tick-price {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .floating-tick-price {
    justify-self: end;
  }

  .chart-section {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto minmax(300px, 58vh);
    min-height: 560px;
    overflow: hidden;
  }

  .indicator-panel {
    padding: 8px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    overflow: visible;
  }

  .indicator-panel-toggle {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 34px;
  }

  .indicator-panel-toggle::after {
    content: "^";
    color: var(--muted);
    font-size: 12px;
  }

  .indicator-panel.collapsed .indicator-panel-toggle::after {
    content: "v";
  }

  .indicator-panel.collapsed .indicator-panel-body {
    display: none;
  }

  .indicator-panel-body {
    margin-top: 8px;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
  }

  .chart-preferences {
    grid-template-columns: minmax(0, 1fr);
    gap: 12px;
  }

  .preference-control {
    min-width: 0;
  }

  .preference-divider {
    flex: 0 0 auto;
  }

  .preference-control input[type="range"] {
    width: 68px;
  }

  .chart-legend {
    position: relative;
    order: 2;
    top: auto;
    bottom: auto;
    left: auto;
    z-index: 2;
    max-width: none;
    padding: 8px 10px 0;
    gap: 8px;
  }

  .floating-tick-row {
    min-height: 32px;
    padding: 6px;
  }

  .chart-host {
    order: 3;
    min-height: 300px;
  }

  select {
    min-width: 0;
    width: 100%;
  }

  .details {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto minmax(0, auto);
    min-height: 0;
  }

  .details-tabs {
    position: sticky;
    top: 0;
    z-index: 4;
    grid-column: 1;
    grid-row: 1;
    align-self: start;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
    padding: 8px;
    border-bottom: 1px solid var(--line);
    background: var(--band);
  }

  .details-tab-button {
    min-width: 0;
    min-height: 38px;
    padding: 0 8px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: var(--panel);
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
    text-align: center;
  }

  .details-tab-button.active {
    border-color: rgba(93, 212, 255, 0.52);
    background: var(--panel-strong);
    color: var(--text);
  }

  .details-tab-panel {
    display: none;
    min-width: 0;
  }

  .details-tab-panel.active {
    display: block;
  }

  .agent-columns {
    display: none;
  }

  #detail-tabpanel-portfolio,
  #detail-tabpanel-fills,
  #detail-tabpanel-decisions {
    grid-column: 1;
    grid-row: 2;
    display: none;
    min-width: 0;
  }

  #detail-tabpanel-portfolio.active,
  #detail-tabpanel-fills.active,
  #detail-tabpanel-decisions.active {
    display: block;
  }

  .panel {
    min-height: 300px;
    max-height: none;
    border-right: 0;
  }

  .panel header {
    gap: 10px;
    padding: 12px;
  }

  .event-row {
    grid-template-columns: minmax(0, 1fr);
    gap: 8px;
    padding: 11px 12px;
  }

  .side-pill {
    width: fit-content;
    padding: 0 10px;
  }

  .portfolio-list {
    padding: 8px;
  }

  .portfolio-agent summary {
    align-items: flex-start;
    flex-wrap: wrap;
  }

  .portfolio-agent-main {
    align-items: flex-start;
    flex-wrap: wrap;
  }

  .portfolio-agent-summary-side {
    flex-wrap: wrap;
    justify-content: flex-start;
  }

  .portfolio-metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    padding: 8px;
  }

  .portfolio-asset {
    grid-template-columns: minmax(86px, 1fr) minmax(0, 1fr);
  }

  .portfolio-asset span:first-child {
    grid-row: span 2;
  }

  .decision-row {
    padding: 11px 12px;
  }

  .decision-top {
    align-items: flex-start;
    flex-direction: column;
    gap: 6px;
  }

  .agent-tag {
    white-space: normal;
  }

  .tooltip {
    max-width: calc(100vw - 24px);
  }
}

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

  .key-data-item {
    border-right: 0;
  }

  .chart-section {
    grid-template-rows: auto minmax(280px, 56vh);
  }

  .portfolio-metrics {
    grid-template-columns: minmax(0, 1fr);
  }
}
