:root {
  color-scheme: dark;
  --bg: #0f1010;
  --surface: #161818;
  --surface-2: #1d201f;
  --surface-3: #242827;
  --border: rgba(221, 229, 224, 0.12);
  --border-strong: rgba(221, 229, 224, 0.22);
  --text: #e0e7e3;
  --muted: #8f9b96;
  --faint: #66716c;
  --green: #25b989;
  --red: #d65f56;
  --amber: #d8a84f;
  --blue: #53b7e8;
  --purple: #a98adf;
  --shadow: 0 18px 44px rgba(0, 0, 0, 0.28);
  --right-rail-width: 340px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  min-width: 320px;
  height: 100%;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
}

button,
input {
  font: inherit;
}

button {
  color: inherit;
}

.app-shell {
  height: 100vh;
  min-height: 640px;
  display: grid;
  grid-template-rows: auto 1fr;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.035), transparent 24%),
    var(--bg);
}

.topbar {
  position: relative;
  z-index: 20;
  display: grid;
  grid-template-columns: minmax(220px, 280px) minmax(420px, 1fr) minmax(210px, 260px);
  align-items: center;
  gap: 16px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  background: rgba(15, 16, 16, 0.94);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand-mark {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border: 1px solid var(--border-strong);
  background: #20231f;
  color: var(--amber);
  font-weight: 800;
}

.brand-title,
.symbol-name {
  font-weight: 760;
  letter-spacing: 0;
}

.brand-subtitle,
.symbol-meta,
.muted {
  color: var(--muted);
  font-size: 12px;
}

.top-controls {
  display: grid;
  grid-template-columns: minmax(220px, 420px) auto;
  justify-content: center;
  gap: 12px;
  min-width: 0;
}

.asset-picker {
  position: relative;
  min-width: 0;
}

.asset-trigger {
  width: 100%;
  height: 40px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 0 12px;
  border: 1px solid var(--border);
  background: var(--surface);
  cursor: pointer;
  text-align: left;
}

.asset-trigger:hover,
.asset-trigger[aria-expanded="true"] {
  border-color: var(--border-strong);
  background: var(--surface-2);
}

.asset-trigger span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text);
}

.asset-trigger strong {
  color: var(--amber);
  font-variant-numeric: tabular-nums;
}

.asset-menu {
  position: absolute;
  top: 46px;
  left: 0;
  width: min(720px, calc(100vw - 32px));
  max-height: min(650px, calc(100vh - 88px));
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 10px;
  padding: 10px;
  border: 1px solid var(--border-strong);
  background: rgba(18, 20, 20, 0.98);
  box-shadow: var(--shadow);
  z-index: 40;
}

.asset-groups {
  min-height: 0;
  overflow: auto;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  padding-right: 2px;
}

.asset-group {
  min-width: 0;
  display: grid;
  align-content: start;
  gap: 6px;
}

.asset-group-title {
  padding: 0 2px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 740;
  letter-spacing: 0;
}

.asset-empty {
  min-height: 52px;
  display: grid;
  place-items: center;
  border: 1px dashed rgba(221, 229, 224, 0.12);
  color: var(--faint);
  font-size: 12px;
}

.asset-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 36px;
  align-items: stretch;
  gap: 6px;
}

.asset-select {
  min-width: 0;
  min-height: 52px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border: 1px solid transparent;
  background: transparent;
  cursor: pointer;
  text-align: left;
}

.asset-row:hover .asset-select {
  background: var(--surface-2);
}

.asset-row.active .asset-select {
  border-color: rgba(216, 168, 79, 0.48);
  background: rgba(216, 168, 79, 0.10);
}

.asset-row-main,
.asset-row-quote {
  min-width: 0;
  display: grid;
  gap: 3px;
}

.asset-row-main strong,
.asset-row-quote strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

.asset-row-main small,
.asset-row-quote small {
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 11px;
}

.asset-row-quote {
  text-align: right;
}

.asset-row-quote.up strong,
.asset-row-quote.up small {
  color: var(--green);
}

.asset-row-quote.down strong,
.asset-row-quote.down small {
  color: var(--red);
}

.fav-button {
  min-width: 36px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--faint);
  cursor: pointer;
}

.fav-button:hover,
.fav-button.active {
  border-color: rgba(216, 168, 79, 0.5);
  color: var(--amber);
  background: rgba(216, 168, 79, 0.10);
}

.search-box {
  min-width: 0;
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 8px;
  height: 40px;
  padding: 0 12px;
  border: 1px solid var(--border);
  background: var(--surface);
}

.search-box span {
  color: var(--faint);
  font-size: 11px;
  text-transform: uppercase;
}

.search-box input {
  width: 100%;
  min-width: 0;
  border: 0;
  outline: 0;
  color: var(--text);
  background: transparent;
}

.timeframe-bar {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--border);
  background: var(--surface);
}

.timeframe-bar button,
.reset-chart-button {
  height: 30px;
  min-width: 42px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.timeframe-bar button:hover,
.reset-chart-button:hover {
  color: var(--text);
  border-color: var(--border-strong);
  background: var(--surface-2);
}

.timeframe-bar button.active {
  color: #111313;
  background: var(--amber);
}

.system-status {
  justify-self: end;
  width: min(240px, 100%);
  min-width: 0;
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
}

.system-status-main {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.system-status-label {
  min-width: 0;
  color: var(--text);
}

.status-dot {
  flex: 0 0 auto;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--faint);
}

.system-status.ok .status-dot {
  background: var(--green);
}

.system-status.loading .status-dot {
  background: var(--amber);
}

.system-status.error .status-dot {
  background: var(--red);
}

.system-status-cache {
  min-width: 0;
  display: grid;
  gap: 4px;
}

.system-status-cache-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-width: 0;
  font-size: 11px;
  color: var(--muted);
}

.system-status-cache-row strong {
  color: var(--text);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.system-status-cache-state {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cache-progress-track {
  position: relative;
  height: 6px;
  overflow: hidden;
  border: 1px solid rgba(221, 229, 224, 0.12);
  background: rgba(255, 255, 255, 0.06);
}

.cache-progress-fill {
  display: block;
  height: 100%;
  background: var(--blue);
  transition: width 180ms ease;
}

.system-status-cache.ok .cache-progress-fill {
  background: var(--green);
}

.system-status-cache.loading .cache-progress-fill {
  background: var(--blue);
}

.system-status-cache.warn .cache-progress-fill {
  background: var(--amber);
}

.system-status-cache.error .cache-progress-fill {
  background: var(--red);
}

.terminal-layout {
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(520px, 1fr) 8px minmax(280px, var(--right-rail-width));
  gap: 8px;
  padding: 12px;
}

.rail-resizer {
  min-height: 0;
  width: 8px;
  cursor: col-resize;
  border: 1px solid transparent;
  background: linear-gradient(180deg, transparent, rgba(216, 168, 79, 0.2), transparent);
  position: relative;
  z-index: 6;
}

.rail-resizer::before {
  content: "";
  position: absolute;
  top: 16px;
  bottom: 16px;
  left: 50%;
  width: 2px;
  transform: translateX(-50%);
  background: rgba(216, 168, 79, 0.38);
}

.rail-resizer:hover,
.rail-resizer.dragging {
  border-color: rgba(216, 168, 79, 0.35);
  background: rgba(216, 168, 79, 0.24);
}

.rail-resizer:hover::before,
.rail-resizer.dragging::before {
  background: rgba(216, 168, 79, 0.78);
}

.right-rail,
.chart-workspace,
.panel {
  min-height: 0;
  min-width: 0;
  border: 1px solid var(--border);
  background: rgba(22, 24, 24, 0.92);
  box-shadow: var(--shadow);
}

.rail-head,
.panel-title,
.chart-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
  border-bottom: 1px solid var(--border);
}

.section-title,
.panel-title span:first-child {
  font-size: 13px;
  font-weight: 730;
}

.panel-title span:last-child {
  color: var(--muted);
  font-size: 12px;
}

.panel-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
}

.panel-collapse-button {
  min-height: 26px;
  padding: 0 8px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--muted);
  font-size: 12px;
  cursor: pointer;
}

.panel-collapse-button:hover {
  color: var(--text);
  border-color: rgba(216, 168, 79, 0.42);
}

.instrument-list {
  min-height: 0;
  overflow: auto;
  padding: 8px;
}

.instrument-item {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px;
  border: 1px solid transparent;
  background: transparent;
  cursor: pointer;
  text-align: left;
}

.instrument-item:hover {
  background: var(--surface-2);
}

.instrument-item.active {
  border-color: rgba(216, 168, 79, 0.48);
  background: rgba(216, 168, 79, 0.10);
}

.instrument-item span {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.instrument-item strong {
  font-size: 13px;
}

.instrument-item small {
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.instrument-item em {
  color: var(--faint);
  font-size: 11px;
  font-style: normal;
}

.chart-workspace {
  display: grid;
  grid-template-rows: auto minmax(340px, 1fr);
  overflow: hidden;
}

.chart-header {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) minmax(250px, auto) auto;
  align-items: center;
  min-height: 58px;
}

.symbol-block {
  min-width: 0;
}

.ohlc-strip {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px 12px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  font-size: 12px;
}

.chart-stage {
  position: relative;
  min-height: 0;
  min-width: 0;
  overflow: hidden;
  background: #101111;
}

.chart,
.overlay-canvas {
  position: absolute;
  inset: 0;
}

.overlay-canvas {
  pointer-events: none;
  z-index: 2;
}

.reset-chart-button {
  position: absolute;
  z-index: 3;
  border-color: var(--border);
  background: rgba(29, 32, 31, 0.92);
}

.reset-chart-button {
  right: 14px;
  top: 14px;
}

.chart-message {
  position: absolute;
  z-index: 4;
  inset: auto 18px 18px 18px;
  padding: 12px;
  border: 1px solid rgba(214, 95, 86, 0.45);
  background: rgba(69, 26, 24, 0.9);
  color: #ffd5d1;
}

.hidden {
  display: none !important;
}

.indicator-menu {
  justify-self: end;
  display: flex;
  align-items: center;
  gap: 8px;
}

.indicator-dropdown {
  position: relative;
}

.indicator-trigger {
  height: 34px;
  min-width: 112px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}

.indicator-trigger:hover {
  border-color: var(--border-strong);
  background: var(--surface-2);
}

.indicator-popover {
  position: absolute;
  top: 40px;
  right: 0;
  width: 280px;
  max-height: 420px;
  overflow: auto;
  display: grid;
  gap: 6px;
  padding: 8px;
  border: 1px solid var(--border-strong);
  background: rgba(18, 20, 20, 0.98);
  box-shadow: var(--shadow);
  z-index: 12;
}

.indicator-empty {
  min-height: 42px;
  display: grid;
  place-items: center;
  border: 1px dashed rgba(221, 229, 224, 0.14);
  color: var(--muted);
  font-size: 12px;
}

.indicator-toggle {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  min-height: 34px;
  padding: 0 10px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  cursor: pointer;
}

.indicator-toggle span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.indicator-toggle input {
  accent-color: var(--amber);
}

.right-rail {
  display: block;
  overflow: auto;
}

.right-rail .panel {
  border-width: 0 0 1px 0;
  box-shadow: none;
  background: transparent;
}

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

.market-summary-wrap {
  padding: 12px;
}

.market-summary-row {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  flex-wrap: nowrap;
  gap: 0;
  min-height: 56px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-left: 3px solid rgba(216, 168, 79, 0.42);
  background: var(--surface-2);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.02);
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: thin;
}

.market-panel.collapsed .market-summary-wrap {
  display: none;
}

.trend-section-panel.collapsed .trend-panel {
  display: none;
}

.ai-section-panel.collapsed .ai-stack {
  display: none;
}

.market-stat {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: fit-content;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
  flex: 0 0 auto;
  padding: 2px 0;
}

.market-stat + .market-stat {
  margin-left: 14px;
  padding-left: 14px;
  border-left: 1px solid rgba(221, 229, 224, 0.1);
}

.market-label {
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.market-label::after {
  content: "：";
  color: var(--faint);
}

.market-value {
  color: var(--text);
  font-size: 16px;
  font-weight: 760;
}

.market-value.up {
  color: var(--green);
}

.market-value.down {
  color: var(--red);
}

.metric-box {
  min-height: 58px;
  display: grid;
  align-content: center;
  gap: 4px;
  padding: 10px;
  border: 1px solid var(--border);
  background: var(--surface-2);
}

.metric-box span,
.status-row span,
.level-item span {
  color: var(--muted);
  font-size: 12px;
}

.metric-box strong,
.status-row strong,
.level-item strong {
  font-weight: 720;
  font-variant-numeric: tabular-nums;
}

.metric-box.up strong,
.level-item.support strong {
  color: var(--green);
}

.metric-box.down strong,
.level-item.resistance strong {
  color: var(--red);
}

.metric-box.warn strong {
  color: var(--amber);
}

.level-list,
.status-list {
  display: grid;
  gap: 6px;
  padding: 0 12px 12px;
}

.level-item,
.status-row {
  min-height: 34px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid rgba(221, 229, 224, 0.08);
}

.ai-stack {
  display: grid;
  gap: 8px;
  padding: 12px;
}

.trend-panel {
  display: grid;
  gap: 8px;
  padding: 12px;
}

.trend-card {
  display: grid;
  gap: 8px;
  padding: 12px;
  border: 1px solid var(--border);
  border-left: 3px solid var(--border-strong);
  background: var(--surface-2);
  min-width: 0;
}

.trend-card.bullish {
  border-left-color: var(--green);
}

.trend-card.bearish {
  border-left-color: var(--red);
}

.trend-card.state-warning {
  border-left-color: var(--amber);
}

.trend-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-width: 0;
}

.trend-card-title {
  min-width: 0;
}

.trend-card-head strong {
  font-size: 16px;
  min-width: 0;
}

.trend-card-head span {
  flex: 0 1 auto;
  max-width: 58%;
  padding: 3px 7px;
  border: 1px solid rgba(221, 229, 224, 0.12);
  color: var(--muted);
  font-size: 12px;
  text-align: right;
  overflow-wrap: anywhere;
}

.trend-state.bullish {
  color: var(--green);
  border-color: rgba(24, 194, 143, 0.35);
  background: rgba(24, 194, 143, 0.08);
}

.trend-state.bearish {
  color: var(--red);
  border-color: rgba(255, 107, 107, 0.35);
  background: rgba(255, 107, 107, 0.08);
}

.trend-state.warning {
  color: var(--amber);
  border-color: rgba(216, 168, 79, 0.35);
  background: rgba(216, 168, 79, 0.08);
}

.trend-state-stack,
.trend-flag-list {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.trend-surface-risk {
  margin-top: 8px;
}

.trend-inline-label {
  color: var(--muted);
  font-size: 11px;
}

.trend-mini-chip {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 2px 7px;
  border: 1px solid rgba(221, 229, 224, 0.12);
  background: rgba(15, 16, 16, 0.3);
  color: var(--muted);
  font-size: 11px;
  line-height: 1.3;
  overflow-wrap: anywhere;
}

.trend-mini-chip.bullish {
  color: var(--green);
  border-color: rgba(24, 194, 143, 0.28);
  background: rgba(24, 194, 143, 0.08);
}

.trend-mini-chip.bearish {
  color: var(--red);
  border-color: rgba(255, 107, 107, 0.28);
  background: rgba(255, 107, 107, 0.08);
}

.trend-mini-chip.warning {
  color: var(--amber);
  border-color: rgba(216, 168, 79, 0.32);
  background: rgba(216, 168, 79, 0.08);
}

.trend-mini-chip.stable {
  color: var(--blue);
  border-color: rgba(83, 183, 232, 0.32);
  background: rgba(83, 183, 232, 0.08);
}

.trend-mini-chip.watch {
  color: var(--purple);
  border-color: rgba(169, 138, 223, 0.32);
  background: rgba(169, 138, 223, 0.08);
}

.trend-metrics-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-width: 0;
}

.trend-metric-chip {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  padding: 5px 8px;
  border: 1px solid rgba(221, 229, 224, 0.08);
  background: rgba(15, 16, 16, 0.18);
  min-width: 0;
}

.trend-metric-chip span {
  color: var(--muted);
  font-size: 11px;
}

.trend-metric-chip b {
  font-size: 12px;
  font-weight: 600;
}

.trend-metric-chip.bullish {
  border-color: rgba(24, 194, 143, 0.18);
  color: var(--green);
}

.trend-metric-chip.bearish {
  border-color: rgba(255, 107, 107, 0.18);
  color: var(--red);
}

.trend-metric-chip.warning {
  border-color: rgba(216, 168, 79, 0.2);
  color: var(--amber);
}

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

.trend-signal-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.trend-action-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 8px;
  margin-top: 2px;
}

.trend-action-grid.double {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.trend-action-summary {
  display: grid;
  gap: 6px;
  padding: 9px 10px;
  border: 1px solid rgba(221, 229, 224, 0.08);
  background: rgba(15, 16, 16, 0.18);
  min-width: 0;
}

.trend-action-summary.bullish {
  border-color: rgba(24, 194, 143, 0.18);
}

.trend-action-summary.bearish {
  border-color: rgba(255, 107, 107, 0.18);
}

.trend-action-summary.warning {
  border-color: rgba(216, 168, 79, 0.2);
}

.trend-action-summary-head,
.trend-action-summary-main {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-width: 0;
}

.trend-action-summary-head {
  flex-wrap: wrap;
  row-gap: 4px;
}

.trend-action-summary-main {
  flex-wrap: wrap;
}

.trend-action-summary-label {
  color: var(--muted);
  font-size: 11px;
  white-space: nowrap;
}

.trend-action-summary-status {
  font-size: 15px;
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}

.trend-action-summary-status.bullish {
  color: var(--green);
}

.trend-action-summary-status.bearish {
  color: var(--red);
}

.trend-action-summary-status.warning {
  color: var(--amber);
}

.trend-action-summary-badge {
  flex: 0 1 auto;
  max-width: 60%;
  padding: 3px 7px;
  border: 1px solid rgba(221, 229, 224, 0.12);
  color: var(--muted);
  font-size: 11px;
  text-align: right;
  overflow-wrap: anywhere;
}

.trend-action-summary-badge.bullish {
  color: var(--green);
  border-color: rgba(24, 194, 143, 0.3);
  background: rgba(24, 194, 143, 0.08);
}

.trend-action-summary-badge.bearish {
  color: var(--red);
  border-color: rgba(255, 107, 107, 0.3);
  background: rgba(255, 107, 107, 0.08);
}

.trend-action-summary-badge.warning {
  color: var(--amber);
  border-color: rgba(216, 168, 79, 0.3);
  background: rgba(216, 168, 79, 0.08);
}

.trend-action-summary-meta {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.trend-action-notes {
  display: grid;
  gap: 8px;
}

.trend-action-note {
  display: grid;
  gap: 4px;
}

.trend-action-note-label {
  color: var(--muted);
  font-size: 11px;
}

.trend-detail-signal-grid {
  margin-top: 2px;
}

.trend-signal {
  display: grid;
  gap: 6px;
  padding: 8px;
  border: 1px solid rgba(221, 229, 224, 0.08);
  background: rgba(15, 16, 16, 0.22);
  min-width: 0;
}

.trend-signal.bullish {
  border-color: rgba(24, 194, 143, 0.18);
}

.trend-signal.bearish {
  border-color: rgba(255, 107, 107, 0.18);
}

.trend-signal.warning {
  border-color: rgba(216, 168, 79, 0.2);
}

.trend-signal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-width: 0;
}

.trend-signal-headline {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  flex-wrap: wrap;
}

.trend-signal-label {
  color: var(--muted);
  font-size: 11px;
}

.trend-signal-pill {
  display: inline-flex;
  align-items: center;
  min-height: 20px;
  padding: 1px 6px;
  border: 1px solid rgba(221, 229, 224, 0.12);
  background: rgba(15, 16, 16, 0.32);
  color: var(--muted);
  font-size: 10px;
  line-height: 1.2;
}

.trend-signal-pill.stable {
  color: var(--blue);
  border-color: rgba(83, 183, 232, 0.32);
  background: rgba(83, 183, 232, 0.08);
}

.trend-signal-pill.watch {
  color: var(--purple);
  border-color: rgba(169, 138, 223, 0.32);
  background: rgba(169, 138, 223, 0.08);
}

.trend-signal-pill.warning {
  color: var(--amber);
  border-color: rgba(216, 168, 79, 0.32);
  background: rgba(216, 168, 79, 0.08);
}

.trend-signal-badge {
  flex: 0 1 auto;
  max-width: 60%;
  padding: 3px 7px;
  border: 1px solid rgba(221, 229, 224, 0.12);
  color: var(--muted);
  font-size: 12px;
  text-align: right;
  overflow-wrap: anywhere;
}

.trend-signal-badge.bullish {
  color: var(--green);
  border-color: rgba(24, 194, 143, 0.35);
  background: rgba(24, 194, 143, 0.08);
}

.trend-signal-badge.bearish {
  color: var(--red);
  border-color: rgba(255, 107, 107, 0.35);
  background: rgba(255, 107, 107, 0.08);
}

.trend-signal-badge.warning {
  color: var(--amber);
  border-color: rgba(216, 168, 79, 0.35);
  background: rgba(216, 168, 79, 0.08);
}

.trend-signal-status {
  font-size: 14px;
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}

.trend-signal-status.bullish {
  color: var(--green);
}

.trend-signal-status.bearish {
  color: var(--red);
}

.trend-signal-status.warning {
  color: var(--amber);
}

.trend-signal-meta {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.trend-chase {
  display: grid;
  gap: 8px;
  padding: 8px;
  border: 1px solid rgba(221, 229, 224, 0.08);
  background: rgba(15, 16, 16, 0.22);
  min-width: 0;
}

.trend-chase.bullish {
  border-color: rgba(24, 194, 143, 0.18);
}

.trend-chase.bearish {
  border-color: rgba(255, 107, 107, 0.18);
}

.trend-chase.warning {
  border-color: rgba(216, 168, 79, 0.2);
}

.trend-chase-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-width: 0;
}

.trend-chase-label {
  color: var(--muted);
  font-size: 11px;
}

.trend-chase-badge {
  flex: 0 1 auto;
  max-width: 58%;
  padding: 3px 7px;
  border: 1px solid rgba(221, 229, 224, 0.12);
  color: var(--muted);
  font-size: 12px;
  text-align: right;
  overflow-wrap: anywhere;
}

.trend-chase-badge.bullish {
  color: var(--green);
  border-color: rgba(24, 194, 143, 0.35);
  background: rgba(24, 194, 143, 0.08);
}

.trend-chase-badge.bearish {
  color: var(--red);
  border-color: rgba(255, 107, 107, 0.35);
  background: rgba(255, 107, 107, 0.08);
}

.trend-chase-badge.warning {
  color: var(--amber);
  border-color: rgba(216, 168, 79, 0.35);
  background: rgba(216, 168, 79, 0.08);
}

.trend-chase-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.trend-chase-reason {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.trend-history-note {
  margin: -2px 0 0;
  color: var(--faint);
  font-size: 11px;
  line-height: 1.4;
}

.trend-cell {
  display: grid;
  gap: 3px;
  padding: 8px;
  border: 1px solid rgba(221, 229, 224, 0.08);
  background: rgba(15, 16, 16, 0.35);
  min-width: 0;
}

.trend-cell span {
  color: var(--muted);
  font-size: 11px;
}

.trend-cell b {
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}

.trend-cell.score.bullish b {
  color: var(--green);
}

.trend-cell.score.bearish b {
  color: var(--red);
}

.trend-details {
  min-width: 0;
}

.trend-details summary {
  width: fit-content;
  padding: 5px 8px;
  border: 1px solid rgba(221, 229, 224, 0.12);
  background: rgba(15, 16, 16, 0.35);
  color: var(--muted);
  cursor: pointer;
  font-size: 12px;
  user-select: none;
}

.trend-details summary:hover {
  border-color: rgba(216, 168, 79, 0.38);
  color: var(--text);
}

.trend-details-body {
  display: grid;
  gap: 8px;
  margin-top: 8px;
}

.trend-detail-section {
  display: grid;
  gap: 8px;
}

.trend-detail-head {
  color: var(--muted);
  font-size: 11px;
}

.trend-confluence-details {
  display: grid;
  gap: 6px;
}

.trend-confluence-detail {
  display: grid;
  gap: 4px;
  padding: 8px;
  border: 1px solid rgba(221, 229, 224, 0.08);
  background: rgba(15, 16, 16, 0.22);
}

.trend-confluence-detail.bullish {
  border-color: rgba(24, 194, 143, 0.16);
}

.trend-confluence-detail.bearish {
  border-color: rgba(255, 107, 107, 0.16);
}

.trend-confluence-detail.warning {
  border-color: rgba(216, 168, 79, 0.18);
}

.trend-confluence-detail-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.trend-confluence-detail-label {
  color: var(--muted);
  font-size: 11px;
}

.trend-confluence-detail-text {
  margin: 0;
  font-size: 12px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.trend-detail-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.trend-focus-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.trend-focus-card {
  display: grid;
  gap: 4px;
  padding: 8px;
  border: 1px solid rgba(221, 229, 224, 0.08);
  background: rgba(15, 16, 16, 0.22);
  min-width: 0;
}

.trend-focus-card.bullish {
  border-color: rgba(24, 194, 143, 0.18);
}

.trend-focus-card.bearish {
  border-color: rgba(255, 107, 107, 0.18);
}

.trend-focus-label {
  color: var(--muted);
  font-size: 11px;
}

.trend-focus-value {
  font-size: 12px;
  font-weight: 600;
  line-height: 1.4;
  overflow-wrap: anywhere;
}

.trend-focus-card.bullish .trend-focus-value {
  color: var(--green);
}

.trend-focus-card.bearish .trend-focus-value {
  color: var(--red);
}

.trend-evidence {
  display: grid;
  gap: 5px;
}

.trend-evidence-row {
  min-height: 28px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  padding: 5px 7px;
  border: 1px solid rgba(221, 229, 224, 0.08);
  background: rgba(15, 16, 16, 0.22);
  font-size: 12px;
}

.trend-evidence-row span {
  min-width: 0;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.trend-evidence-row b {
  font-variant-numeric: tabular-nums;
}

.trend-evidence-row.bullish b {
  color: var(--green);
}

.trend-evidence-row.bearish b {
  color: var(--red);
}

.ai-plan {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--border);
  border-left: 3px solid var(--border-strong);
  background: var(--surface-2);
  min-width: 0;
}

.ai-plan.bullish {
  border-left-color: var(--green);
}

.ai-plan.bearish {
  border-left-color: var(--red);
}

.ai-plan.neutral {
  border-left-color: var(--amber);
}

.ai-plan.reserved {
  border-left-color: var(--faint);
}

.ai-plan-head,
.ai-confidence,
.ai-path-top,
.ai-plan-submeta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.ai-plan-head span,
.ai-plan p,
.ai-confidence,
.ai-path-top span,
.ai-plan-submeta {
  color: var(--muted);
  font-size: 12px;
}

.ai-plan-head strong {
  min-width: 0;
  overflow-wrap: anywhere;
}

.ai-plan-title {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 8px;
}

.ai-plan-title strong {
  flex: 0 1 auto;
}

.ai-scope-badge,
.ai-direction,
.ai-plan-submeta span {
  width: fit-content;
  max-width: 100%;
  padding: 2px 6px;
  border: 1px solid rgba(221, 229, 224, 0.12);
  background: rgba(15, 16, 16, 0.28);
  overflow-wrap: anywhere;
}

.ai-scope-badge {
  flex: 0 0 auto;
  white-space: nowrap;
}

.ai-direction {
  flex: 0 0 auto;
  font-weight: 720;
}

.ai-direction.bullish {
  color: var(--green);
  border-color: rgba(37, 185, 137, 0.32);
  background: rgba(37, 185, 137, 0.08);
}

.ai-direction.bearish {
  color: var(--red);
  border-color: rgba(214, 95, 86, 0.34);
  background: rgba(214, 95, 86, 0.08);
}

.ai-direction.neutral {
  color: var(--amber);
  border-color: rgba(216, 168, 79, 0.32);
  background: rgba(216, 168, 79, 0.08);
}

.ai-direction.reserved {
  color: var(--faint);
}

.ai-plan-submeta {
  justify-content: flex-start;
  flex-wrap: wrap;
}

.ai-plan-submeta span {
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.ai-head-price {
  color: var(--text) !important;
  font-size: 12px !important;
  font-weight: 640;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.ai-plan p {
  margin: 0;
  line-height: 1.45;
}

.ai-confidence b {
  color: var(--text);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.ai-level-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
}

.ai-level-cell {
  display: grid;
  gap: 3px;
  min-width: 0;
  padding: 7px;
  border: 1px solid rgba(221, 229, 224, 0.08);
  background: rgba(15, 16, 16, 0.32);
}

.ai-level-cell span {
  color: var(--muted);
  font-size: 11px;
}

.ai-level-cell b {
  overflow-wrap: anywhere;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.ai-paths {
  display: grid;
  gap: 7px;
}

.ai-path-row {
  display: grid;
  gap: 5px;
  min-width: 0;
  padding: 8px;
  border: 1px solid rgba(221, 229, 224, 0.08);
  background: rgba(15, 16, 16, 0.24);
}

.ai-path-row.empty {
  color: var(--muted);
  font-size: 12px;
}

.ai-path-title {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.ai-path-side {
  flex: 0 0 auto;
  min-width: 22px;
  padding: 2px 5px;
  border: 1px solid rgba(221, 229, 224, 0.12);
  background: rgba(221, 229, 224, 0.04);
  font-size: 11px !important;
  line-height: 1.15;
  text-align: center;
  font-weight: 760;
}

.ai-path-side.bullish {
  color: var(--green);
  border-color: rgba(37, 185, 137, 0.34);
  background: rgba(37, 185, 137, 0.08);
}

.ai-path-side.bearish {
  color: var(--red);
  border-color: rgba(214, 95, 86, 0.34);
  background: rgba(214, 95, 86, 0.08);
}

.ai-path-side.neutral {
  color: var(--amber);
  border-color: rgba(216, 168, 79, 0.28);
  background: rgba(216, 168, 79, 0.07);
}

.ai-path-row strong {
  font-size: 12px;
  min-width: 0;
  overflow-wrap: anywhere;
  font-variant-numeric: tabular-nums;
}

.ai-path-line {
  overflow-wrap: anywhere;
  color: var(--text);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  line-height: 1.45;
}

.ai-detail-actions {
  display: flex;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 8px;
  min-width: 0;
}

.ai-details {
  min-width: 0;
}

.ai-detail-actions .ai-details[open] {
  flex-basis: 100%;
}

.ai-details summary {
  width: fit-content;
  padding: 5px 8px;
  border: 1px solid rgba(221, 229, 224, 0.12);
  background: rgba(15, 16, 16, 0.35);
  color: var(--muted);
  cursor: pointer;
  font-size: 12px;
  user-select: none;
}

.ai-details summary:hover {
  border-color: rgba(216, 168, 79, 0.38);
  color: var(--text);
}

.ai-details-body {
  display: grid;
  gap: 8px;
  margin-top: 8px;
}

.ai-detail-block {
  display: grid;
  gap: 5px;
  min-width: 0;
  padding: 8px;
  border: 1px solid rgba(221, 229, 224, 0.08);
  background: rgba(15, 16, 16, 0.24);
}

.ai-detail-block b {
  color: var(--text);
  font-size: 12px;
  overflow-wrap: anywhere;
}

.ai-detail-block p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.ai-detail-block p span {
  color: var(--faint);
}

.ai-news-list {
  display: grid;
  gap: 6px;
  margin-top: 8px;
}

.ai-news-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: start;
  gap: 8px;
  min-width: 0;
  padding: 7px 8px;
  border: 1px solid rgba(221, 229, 224, 0.08);
  background: rgba(15, 16, 16, 0.24);
}

.ai-news-impact {
  min-width: 38px;
  padding: 2px 6px;
  border: 1px solid rgba(221, 229, 224, 0.12);
  font-size: 11px;
  text-align: center;
  font-weight: 720;
}

.ai-news-impact.bullish {
  color: var(--green);
  border-color: rgba(37, 185, 137, 0.32);
  background: rgba(37, 185, 137, 0.08);
}

.ai-news-impact.bearish {
  color: var(--red);
  border-color: rgba(214, 95, 86, 0.34);
  background: rgba(214, 95, 86, 0.08);
}

.ai-news-impact.neutral {
  color: var(--muted);
  background: rgba(221, 229, 224, 0.04);
}

.ai-news-title {
  min-width: 0;
  color: var(--text);
  font-size: 12px;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.ai-news-time {
  justify-self: end;
  color: var(--faint);
  font-size: 11px;
  line-height: 1.35;
  text-align: right;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.empty-note {
  padding: 12px;
  border: 1px solid var(--border);
  color: var(--muted);
  background: var(--surface-2);
  font-size: 12px;
}

.ai-bias {
  width: fit-content;
  padding: 3px 7px;
  border: 1px solid rgba(83, 183, 232, 0.34);
  color: var(--blue);
  background: rgba(83, 183, 232, 0.09);
  font-size: 12px;
}

@media (max-width: 900px) {
  html {
    height: auto;
    overflow: auto;
  }

  body {
    height: auto;
    overflow: auto;
  }

  .app-shell {
    min-height: 100vh;
    height: auto;
    grid-template-rows: auto 1fr;
  }

  .topbar,
  .terminal-layout {
    grid-template-columns: 1fr;
  }

  .rail-resizer {
    display: none;
  }

  .top-controls {
    grid-template-columns: 1fr;
  }

  .system-status {
    justify-self: start;
  }

  .terminal-layout {
    min-height: auto;
  }

  .right-rail {
    max-height: none;
    overflow: visible;
  }

  .asset-menu {
    position: fixed;
    top: 72px;
    left: 8px;
    right: 8px;
    width: auto;
    max-height: calc(100vh - 88px);
  }

  .asset-groups {
    grid-template-columns: 1fr;
  }

  .chart-workspace {
    min-height: 620px;
  }
}

@media (max-width: 640px) {
  .app-shell {
    min-height: 100vh;
  }

  .topbar,
  .terminal-layout {
    padding: 8px;
  }

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

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

  .chart-header,
  .rail-head,
  .panel-title {
    align-items: flex-start;
  }

  .chart-header {
    grid-template-columns: 1fr;
  }

  .ohlc-strip {
    justify-content: flex-start;
  }

  .indicator-menu,
  .indicator-dropdown,
  .indicator-trigger,
  .indicator-popover {
    width: 100%;
  }

  .indicator-menu {
    align-items: stretch;
  }

  .indicator-dropdown {
    min-width: 0;
    flex: 1;
  }

  .indicator-popover {
    left: 0;
    right: auto;
  }

  .trend-grid,
  .trend-detail-grid,
  .trend-signal-grid,
  .trend-focus-grid {
    grid-template-columns: 1fr;
  }

  .trend-action-grid.double {
    grid-template-columns: 1fr;
  }
}
