:root {
  color-scheme: light;
  --bg: #f3f4f6;
  --surface: rgba(255, 255, 255, 0.86);
  --surface-solid: #ffffff;
  --muted: #64748b;
  --text: #0f172a;
  --line: rgba(148, 163, 184, 0.28);
  --brand: #4f46e5;
  --brand-2: #0284c7;
  --good: #059669;
  --bad: #dc2626;
  --warn: #d97706;
  --shadow: 0 14px 32px rgba(15, 23, 42, 0.07);
}

body.dark {
  color-scheme: dark;
  --bg: #0b111a;
  --surface: rgba(18, 24, 33, 0.9);
  --surface-solid: #121821;
  --muted: #94a3b8;
  --text: #dbe4ee;
  --line: rgba(71, 85, 105, 0.7);
  --brand: #818cf8;
  --brand-2: #38bdf8;
  --shadow: 0 16px 34px rgba(0, 0, 0, 0.32);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 10px;
}

body.dark ::-webkit-scrollbar-thumb {
  background: #475569;
}

.app-shell {
  display: flex;
  height: 100vh;
  min-width: 0;
}

.sidebar {
  width: 264px;
  flex: 0 0 264px;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--line);
  background: rgba(241, 245, 249, 0.78);
  backdrop-filter: blur(22px);
}

body.dark .sidebar {
  background: rgba(15, 23, 34, 0.86);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 22px 20px;
  border-bottom: 1px solid var(--line);
}

.brand-mark {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  color: white;
  font-weight: 900;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  box-shadow: 0 10px 24px rgba(79, 70, 229, 0.24);
}

.brand-title {
  font-size: 18px;
  font-weight: 900;
  letter-spacing: 0;
}

.brand-subtitle {
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.nav-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 18px 14px;
  overflow-y: auto;
  min-height: 0;
}

.nav-button {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 42px;
  padding: 10px 12px;
  color: var(--muted);
  background: transparent;
  border: 1px solid transparent;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 800;
  text-align: left;
  transition: 0.18s ease;
}

.nav-button:hover {
  color: var(--text);
  background: rgba(226, 232, 240, 0.58);
}

body.dark .nav-button:hover {
  background: rgba(51, 65, 85, 0.42);
}

.nav-button.active {
  color: var(--brand);
  background: var(--surface-solid);
  border-color: var(--line);
  box-shadow: 0 4px 16px rgba(15, 23, 42, 0.05);
}

body.dark .nav-button.active {
  background: rgba(30, 41, 59, 0.9);
}

.nav-icon {
  width: 22px;
  text-align: center;
}

.sidebar-footer {
  margin-top: auto;
  padding: 16px;
  border-top: 1px solid var(--line);
  display: grid;
  gap: 10px;
}

.version-pill,
.status-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  padding: 8px 12px;
  border-radius: 999px;
  color: var(--muted);
  background: var(--surface-solid);
  border: 1px solid var(--line);
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 18px 24px;
  background: var(--surface);
  backdrop-filter: blur(22px);
  border-bottom: 1px solid var(--line);
}

.eyebrow {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  margin-top: 4px;
  font-size: 24px;
  font-weight: 900;
}

h2 {
  font-size: 16px;
  font-weight: 900;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.asset-switch {
  display: inline-flex;
  gap: 4px;
  padding: 4px;
  background: rgba(226, 232, 240, 0.72);
  border: 1px solid var(--line);
  border-radius: 8px;
}

body.dark .asset-switch {
  background: rgba(30, 41, 59, 0.82);
}

.asset-segment {
  min-height: 34px;
  padding: 7px 12px;
  color: var(--muted);
  background: transparent;
  border: 0;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 900;
  white-space: nowrap;
}

.asset-segment.active {
  color: var(--brand);
  background: var(--surface-solid);
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.06);
}

.view {
  display: none;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 22px;
}

.view.active {
  display: block;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 16px;
}

.stat-card,
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.stat-card {
  min-height: 110px;
  padding: 18px;
}

.stat-label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.stat-card strong {
  display: block;
  margin: 8px 0 4px;
  font-size: 30px;
  font-weight: 900;
}

.stat-card small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.stat-card small.num-up,
.num-up {
  color: var(--good);
}

.stat-card small.num-down,
.num-down {
  color: var(--bad);
}

.crypto-pnl-banner {
  display: grid;
  grid-template-columns: minmax(240px, 0.95fr) minmax(0, 2fr);
  gap: 14px;
  margin: 0 0 16px;
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 6px solid var(--muted);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.crypto-pnl-banner.pnl-profit {
  border-left-color: var(--good);
}

.crypto-pnl-banner.pnl-loss {
  border-left-color: var(--bad);
}

.crypto-pnl-banner.pnl-flat {
  border-left-color: var(--warn);
}

.crypto-config-box:not(.hidden) {
  display: grid;
  gap: 12px;
  margin-top: 14px;
  padding: 12px;
  background: var(--surface-solid);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.crypto-config-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.crypto-mode-toggle {
  flex: 0 0 auto;
}

.segment.danger.active {
  color: var(--bad);
}

.crypto-config-status {
  min-width: 0;
  padding: 7px 10px;
  color: var(--muted);
  background: rgba(148, 163, 184, 0.12);
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 12px;
  font-weight: 900;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.crypto-config-status.is-ready {
  color: var(--good);
  border-color: rgba(22, 163, 74, 0.28);
  background: rgba(22, 163, 74, 0.08);
}

.crypto-config-status.is-blocked,
.crypto-config-status.is-live:not(.is-ready) {
  color: var(--bad);
  border-color: rgba(220, 38, 38, 0.28);
  background: rgba(220, 38, 38, 0.08);
}

.crypto-config-grid {
  margin-top: 0;
}

.crypto-config-grid label {
  min-width: 0;
}

.crypto-config-help {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  line-height: 1.45;
}

.crypto-advanced-config {
  display: grid;
  gap: 10px;
}

.crypto-advanced-config summary {
  width: max-content;
  color: var(--muted);
  cursor: pointer;
  font-size: 12px;
  font-weight: 900;
}

.crypto-pnl-main,
.crypto-pnl-detail > div {
  min-width: 0;
  background: var(--surface-solid);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.crypto-pnl-main {
  display: grid;
  align-content: center;
  padding: 18px;
}

.crypto-pnl-detail {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.crypto-pnl-detail > div {
  padding: 12px;
}

.crypto-pnl-banner span,
.crypto-pnl-banner small {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  line-height: 1.35;
}

.crypto-pnl-banner strong {
  display: block;
  margin: 6px 0 4px;
  color: var(--text);
  overflow-wrap: anywhere;
  font-size: 18px;
  font-weight: 900;
}

.crypto-pnl-main strong {
  font-size: 34px;
  line-height: 1.1;
}

.pnl-profit,
.crypto-pnl-banner .pnl-profit {
  color: var(--good);
  font-weight: 900;
}

.pnl-loss,
.crypto-pnl-banner .pnl-loss {
  color: var(--bad);
  font-weight: 900;
}

.pnl-flat,
.crypto-pnl-banner .pnl-flat {
  color: var(--warn);
  font-weight: 900;
}

.panel-grid {
  display: grid;
  gap: 16px;
}

.panel-grid.two {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.panel {
  padding: 18px;
  min-width: 0;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.inline-form,
.query-row,
.button-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.button-row.wrap {
  flex-wrap: wrap;
}

.input {
  width: 100%;
  min-height: 40px;
  padding: 10px 12px;
  color: var(--text);
  background: var(--surface-solid);
  border: 1px solid var(--line);
  border-radius: 8px;
  outline: none;
}

.input:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.12);
}

.input.big {
  min-height: 48px;
  font-size: 16px;
}

.primary-button,
.ghost-button,
.text-button {
  min-height: 40px;
  padding: 10px 14px;
  border-radius: 8px;
  border: 1px solid transparent;
  font-size: 14px;
  font-weight: 900;
  white-space: nowrap;
  transition: 0.18s ease;
}

.primary-button {
  color: white;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  box-shadow: 0 10px 20px rgba(79, 70, 229, 0.16);
}

.primary-button:hover {
  filter: brightness(0.98);
  transform: translateY(-1px);
}

.primary-button:disabled,
.primary-button[disabled] {
  cursor: not-allowed;
  opacity: 0.58;
  transform: none;
}

.primary-button.is-busy,
.primary-button.is-active {
  border-color: rgba(22, 163, 74, 0.3);
  box-shadow: 0 0 0 3px rgba(22, 163, 74, 0.1);
}

.primary-button.secondary,
.ghost-button {
  color: var(--text);
  background: var(--surface-solid);
  border-color: var(--line);
  box-shadow: none;
}

.primary-button.danger {
  color: var(--bad);
}

.primary-button.full {
  width: 100%;
}

.text-button {
  min-height: 32px;
  padding: 6px 10px;
  color: var(--brand);
  background: transparent;
}

.hint-line,
.muted {
  margin-top: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.result-area {
  margin-top: 14px;
  min-height: 140px;
  max-height: 420px;
  overflow: auto;
  padding: 12px;
  background: rgba(248, 250, 252, 0.72);
  border: 1px solid var(--line);
  border-radius: 8px;
}

body.dark .result-area {
  background: rgba(15, 23, 42, 0.72);
}

.result-area.tall {
  max-height: calc(100vh - 280px);
}

body[data-asset-mode="crypto"] .view.active {
  display: flex;
  flex-direction: column;
}

body[data-asset-mode="crypto"] .trader-stats,
body[data-asset-mode="crypto"] #cryptoPnlStrip,
body[data-asset-mode="crypto"] #traderControlPanel,
body[data-asset-mode="crypto"] #traderTradePanel,
body[data-asset-mode="crypto"] #traderLogPanel {
  display: none !important;
}

body[data-asset-mode="crypto"] .trader-layout,
body[data-asset-mode="crypto"] .panel-grid.two {
  display: contents;
}

body[data-asset-mode="crypto"] #traderPositionPanel {
  order: 1;
  margin-bottom: 16px;
}

body[data-asset-mode="crypto"] #traderDecisionPanel {
  order: 2;
}

body[data-asset-mode="crypto"] #fundGuidancePanel,
body[data-asset-mode="crypto"] #fundTradeRoutePanel {
  order: 3;
}

body[data-asset-mode="crypto"] #traderPositionResult,
body[data-asset-mode="crypto"] #traderDecisionResult {
  min-height: 0;
  max-height: none;
  overflow: visible;
  padding: 0;
  background: transparent;
  border: 0;
}

body[data-asset-mode="crypto"] #traderDecisionResult {
  margin-top: 10px;
}

.crypto-ai-control-slot:not(.hidden) {
  display: grid;
  gap: 10px;
  margin-bottom: 10px;
}

body[data-asset-mode="crypto"] .trader-control-stack {
  display: grid;
  gap: 10px;
}

body[data-asset-mode="crypto"] .trader-control-stack > .button-row {
  padding: 10px;
  background: var(--surface-solid);
  border: 1px solid var(--line);
  border-radius: 8px;
}

body[data-asset-mode="crypto"] .crypto-config-box:not(.hidden) {
  margin-top: 0;
  padding: 10px;
}

body[data-asset-mode="crypto"] .crypto-config-grid {
  margin: 10px 0 0;
}

body[data-asset-mode="crypto"] .ai-policy-grid {
  display: none;
}

body[data-asset-mode="crypto"] .ai-policy-reason,
body[data-asset-mode="crypto"] #traderError {
  display: none;
}

.crypto-holdings-panel,
.crypto-ai-summary {
  display: grid;
  gap: 12px;
}

.crypto-holding-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.crypto-summary-metric,
.crypto-agent-pill,
.crypto-ai-thesis,
.crypto-support-list > div,
.crypto-decision-row,
.crypto-activity-list > div,
.crypto-position-row,
.crypto-holding-note,
.crypto-compact-section {
  min-width: 0;
  background: var(--surface-solid);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.crypto-summary-metric {
  display: grid;
  gap: 5px;
  padding: 12px;
}

.crypto-summary-metric span,
.crypto-summary-metric small,
.crypto-position-row span,
.crypto-position-row small,
.crypto-agent-pill span,
.crypto-agent-pill small,
.crypto-ai-thesis span,
.crypto-ai-thesis small,
.crypto-section-head span,
.crypto-activity-list span,
.crypto-activity-list small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  line-height: 1.35;
}

.crypto-summary-metric strong {
  color: var(--text);
  font-size: 22px;
  font-weight: 900;
  line-height: 1.15;
  overflow-wrap: anywhere;
}

.crypto-summary-metric strong.pnl-profit,
.crypto-position-pnl strong.pnl-profit,
.crypto-position-pnl small.pnl-profit {
  color: var(--good);
}

.crypto-summary-metric strong.pnl-loss,
.crypto-position-pnl strong.pnl-loss,
.crypto-position-pnl small.pnl-loss {
  color: var(--bad);
}

.crypto-summary-metric strong.pnl-flat,
.crypto-position-pnl strong.pnl-flat,
.crypto-position-pnl small.pnl-flat {
  color: var(--warn);
}

.crypto-position-list {
  display: grid;
  gap: 8px;
}

.crypto-position-row {
  display: grid;
  grid-template-columns: minmax(170px, 1.2fr) repeat(4, minmax(120px, 1fr));
  gap: 10px;
  align-items: center;
  padding: 12px;
}

.crypto-position-row > div {
  display: grid;
  gap: 4px;
}

.crypto-position-row strong {
  font-size: 14px;
  font-weight: 900;
  overflow-wrap: anywhere;
}

.crypto-position-identity strong {
  font-size: 16px;
}

.crypto-position-pnl {
  text-align: right;
}

.crypto-holding-note {
  padding: 10px 12px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  line-height: 1.45;
}

.position-empty.compact,
.empty-state.compact {
  padding: 12px;
}

.crypto-ai-status-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.crypto-agent-pill {
  display: grid;
  gap: 5px;
  padding: 10px 12px;
  border-left: 4px solid var(--line);
}

.crypto-agent-pill.status-running,
.crypto-agent-pill.is-running {
  border-left-color: var(--warn);
}

.crypto-agent-pill.status-ok,
.crypto-agent-pill.status-ready {
  border-left-color: var(--good);
}

.crypto-agent-pill.status-error,
.crypto-agent-pill.status-timeout {
  border-left-color: var(--bad);
}

.crypto-agent-pill strong {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  font-weight: 900;
}

.crypto-ai-thesis {
  display: grid;
  gap: 6px;
  padding: 12px;
}

.crypto-ai-thesis strong {
  font-size: 16px;
  font-weight: 900;
  line-height: 1.45;
}

.crypto-ai-thesis p {
  margin: 0;
  color: var(--text);
  font-size: 13px;
  font-weight: 800;
  line-height: 1.45;
}

.crypto-support-list,
.crypto-decision-list,
.crypto-activity-list {
  display: grid;
  gap: 8px;
}

.crypto-support-list {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.crypto-support-list > div {
  display: grid;
  gap: 4px;
  padding: 10px;
}

.crypto-support-list strong {
  font-size: 12px;
  font-weight: 900;
}

.crypto-support-list span {
  font-size: 12px;
  font-weight: 800;
  line-height: 1.45;
}

.crypto-compact-section {
  display: grid;
  gap: 8px;
  padding: 10px;
}

.crypto-compact-section.muted-section {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.crypto-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.crypto-section-head strong {
  font-size: 13px;
  font-weight: 900;
}

.crypto-decision-row {
  display: grid;
  grid-template-columns: minmax(120px, 0.8fr) minmax(130px, 0.8fr) minmax(0, 2fr);
  gap: 10px;
  align-items: center;
  padding: 10px;
}

.crypto-decision-row > div {
  display: grid;
  gap: 3px;
}

.crypto-decision-row strong,
.crypto-activity-list strong {
  font-size: 13px;
  font-weight: 900;
}

.crypto-decision-row span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.crypto-decision-row p {
  margin: 0;
  color: var(--text);
  font-size: 12px;
  font-weight: 800;
  line-height: 1.45;
}

.crypto-activity-list > div {
  display: grid;
  grid-template-columns: 110px minmax(120px, 0.7fr) minmax(0, 1.6fr);
  gap: 8px;
  align-items: center;
  padding: 9px 10px;
}

.crypto-activity-list > div.is-degraded {
  border-color: rgba(217, 119, 6, 0.28);
  background: rgba(217, 119, 6, 0.08);
}

.crypto-activity-list > div.is-degraded strong {
  color: var(--warn);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.data-table th,
.data-table td {
  padding: 9px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

.data-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  color: var(--muted);
  background: var(--surface-solid);
  font-size: 12px;
  font-weight: 900;
}

.crypto-trade-table td,
.crypto-decision-table td,
.crypto-position-table td {
  white-space: nowrap;
}

.crypto-trade-table td:last-child,
.crypto-decision-table td:last-child {
  min-width: 220px;
  white-space: normal;
}

.crypto-position-table strong {
  font-size: 13px;
}

.mono-cell {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-variant-numeric: tabular-nums;
}

.num-up {
  color: var(--good);
  font-weight: 900;
}

.num-down {
  color: var(--bad);
  font-weight: 900;
}

.table-note {
  margin-top: 10px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.json-block {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  line-height: 1.55;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 12px;
}

.form-grid.compact {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

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

.trader-layout {
  grid-template-columns: minmax(0, 1.2fr) minmax(360px, 0.8fr);
  margin-bottom: 16px;
}

.ai-policy-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
  margin-top: 14px;
}

.ai-policy-grid div {
  padding: 12px;
  background: var(--surface-solid);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.ai-policy-grid span,
.ai-policy-grid strong {
  display: block;
}

.ai-policy-grid span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.ai-policy-grid strong {
  margin-top: 6px;
  font-size: 13px;
  line-height: 1.35;
}

.ai-policy-reason {
  margin-top: 10px;
  padding: 10px 12px;
  color: var(--muted);
  background: var(--surface-solid);
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 12px;
  font-weight: 800;
  line-height: 1.45;
}

.trader-log-panel {
  margin-top: 16px;
}

.ai-runtime-note {
  margin-bottom: 12px;
  padding: 10px 12px;
  color: var(--muted);
  background: var(--surface-solid);
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 12px;
  font-weight: 800;
  line-height: 1.45;
  word-break: break-word;
}

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

.crypto-ai-agent-grid {
  margin-bottom: 10px;
}

.engine-card {
  position: relative;
  display: grid;
  gap: 10px;
  padding: 14px;
  background: var(--surface-solid);
  border: 1px solid var(--line);
  border-left: 4px solid var(--muted);
  border-radius: 8px;
  overflow: hidden;
}

.engine-card.status-running,
.engine-card.is-running {
  border-color: rgba(217, 119, 6, 0.5);
  border-left-color: var(--warn);
  box-shadow: 0 0 0 3px rgba(217, 119, 6, 0.12);
}

.engine-card.is-running::before {
  content: none;
}

.engine-card.status-configured {
  border-left-color: var(--good);
}

.engine-card.status-not_configured {
  border-left-color: var(--warn);
}

.engine-card.status-optional {
  border-left-color: var(--brand-2);
}

.engine-card.status-clean {
  border-left-color: var(--good);
}

.engine-card.status-dirty,
.engine-card.status-ahead_or_behind {
  border-left-color: var(--warn);
}

.engine-card.status-not_cloned,
.engine-card.status-unknown {
  border-left-color: var(--bad);
}

.engine-card.health-healthy {
  border-left-color: var(--good);
}

.engine-card.health-unhealthy {
  border-left-color: var(--bad);
}

.engine-card.health-not_configured,
.engine-card.health-unknown {
  border-left-color: var(--warn);
}

.engine-card-head,
.engine-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.engine-card-head strong {
  font-size: 14px;
  font-weight: 900;
}

.engine-card-head span,
.engine-meta span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.engine-card.is-running .engine-card-head span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--warn);
}

.run-dot {
  width: 8px;
  height: 8px;
  display: inline-block;
  background: var(--warn);
  border-radius: 999px;
  box-shadow: 0 0 0 3px rgba(217, 119, 6, 0.14);
}

.agent-progress {
  height: 4px;
  overflow: hidden;
  background: rgba(217, 119, 6, 0.14);
  border-radius: 999px;
}

.agent-progress span {
  display: block;
  width: 100%;
  height: 100%;
  background: var(--warn);
  border-radius: 999px;
}

.engine-card p,
.engine-card small {
  margin: 0;
  color: var(--text);
  font-size: 13px;
  font-weight: 800;
  line-height: 1.5;
}

.engine-card small {
  color: var(--muted);
}

.research-support-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 10px;
}

.research-section-title {
  margin-top: 12px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.research-signal-grid {
  display: grid;
  gap: 10px;
  margin-top: 10px;
}

.research-support-item,
.research-signal-item {
  display: grid;
  gap: 6px;
  min-width: 0;
  padding: 10px;
  background: var(--surface-solid);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.research-support-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.research-support-head strong,
.research-support-head span {
  font-size: 12px;
  font-weight: 900;
}

.research-support-head span,
.research-support-item small {
  color: var(--muted);
}

.research-support-item p,
.research-support-item ul,
.research-signal-item p {
  margin: 0;
}

.research-support-item p,
.research-support-item li,
.research-counter,
.research-signal-item p,
.research-signal-item span {
  color: var(--text);
  font-size: 12px;
  font-weight: 800;
  line-height: 1.45;
}

.research-support-item ul {
  display: grid;
  gap: 3px;
  padding-left: 16px;
}

.research-counter {
  color: var(--bad);
}

.research-signal-item strong {
  color: var(--brand);
  font-size: 12px;
  font-weight: 900;
}

.research-signal-item small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  line-height: 1.45;
}

.engine-meta a {
  min-width: 0;
  overflow: hidden;
  color: var(--brand);
  font-size: 12px;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bridge-strip,
.bridge-summary,
.bridge-detail-grid {
  display: grid;
  gap: 8px;
}

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

.bridge-strip span,
.bridge-summary-item,
.bridge-detail-grid div {
  min-width: 0;
  padding: 8px 10px;
  background: rgba(241, 245, 249, 0.72);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

body.dark .bridge-strip span,
body.dark .bridge-summary-item,
body.dark .bridge-detail-grid div {
  background: rgba(15, 23, 42, 0.62);
}

.bridge-summary {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-top: 12px;
}

.bridge-summary-item {
  display: grid;
  gap: 4px;
  border-left: 4px solid var(--warn);
}

.bridge-summary-item.health-healthy {
  border-left-color: var(--good);
}

.bridge-summary-item.health-unhealthy {
  border-left-color: var(--bad);
}

.bridge-summary-item span,
.bridge-summary-item strong,
.bridge-summary-item small,
.bridge-detail-grid b,
.bridge-detail-grid span {
  display: block;
}

.bridge-summary-item strong {
  color: var(--text);
  font-size: 15px;
}

.bridge-summary-item small {
  line-height: 1.45;
}

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

.bridge-detail-grid div {
  display: grid;
  gap: 4px;
}

.bridge-detail-grid b {
  color: var(--text);
}

.sidecar-total-strip,
.sidecar-policy-box,
.sidecar-workflow,
.sidecar-files {
  display: grid;
  gap: 8px;
}

.sidecar-total-strip {
  grid-template-columns: repeat(5, minmax(0, 1fr));
  margin-bottom: 12px;
}

.sidecar-total-strip.compact {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-top: 12px;
}

.sidecar-total-strip span,
.sidecar-policy-box span,
.sidecar-files span,
.workflow-step {
  min-width: 0;
  padding: 8px 10px;
  overflow-wrap: anywhere;
  color: var(--muted);
  background: rgba(241, 245, 249, 0.72);
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 12px;
  font-weight: 900;
  line-height: 1.4;
}

body.dark .sidecar-total-strip span,
body.dark .sidecar-policy-box span,
body.dark .sidecar-files span,
body.dark .workflow-step {
  background: rgba(15, 23, 42, 0.62);
}

.sidecar-total-strip strong {
  color: var(--text);
}

.sidecar-grid {
  margin-bottom: 12px;
}

.sidecar-policy-box {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-top: 12px;
}

.sidecar-workflow {
  margin-top: 14px;
}

.sidecar-workflow h3 {
  margin: 0;
  color: var(--text);
  font-size: 14px;
  font-weight: 900;
}

.workflow-step {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr);
  align-items: start;
}

.workflow-step strong {
  display: inline-grid;
  width: 22px;
  height: 22px;
  place-items: center;
  color: white;
  background: var(--brand);
  border-radius: 999px;
  font-size: 12px;
}

.sidecar-files {
  grid-template-columns: 1fr;
}

.sidecar-files b {
  color: var(--text);
  font-size: 12px;
}

.sidecar-diff-report {
  display: grid;
  gap: 12px;
  margin-top: 14px;
}

.command-list code {
  display: block;
  padding: 7px 9px;
  overflow-wrap: anywhere;
  color: var(--text);
  background: rgba(15, 23, 42, 0.06);
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 11px;
  font-weight: 800;
}

body.dark .command-list code {
  background: rgba(255, 255, 255, 0.06);
}

.crypto-guardrails {
  margin-top: 12px;
}

.log-stream {
  display: grid;
  gap: 8px;
}

.log-item {
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--brand-2);
  border-radius: 8px;
  background: var(--surface-solid);
}

.log-item.level-warn {
  border-left-color: var(--warn);
}

.log-item.level-error {
  border-left-color: var(--bad);
}

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

.log-time,
.log-source {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.log-source {
  padding: 2px 7px;
  color: var(--brand);
  background: rgba(79, 70, 229, 0.08);
  border-radius: 999px;
}

.log-main strong {
  min-width: 0;
  overflow: hidden;
  color: var(--text);
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.log-meta {
  margin-top: 5px;
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 11px;
  line-height: 1.45;
  word-break: break-word;
}

.equity-chart {
  min-height: 244px;
}

.fund-import-box {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.fund-guidance-panel {
  margin-bottom: 16px;
}

.fund-guidance-result {
  display: grid;
  gap: 14px;
}

.guidance-hero {
  display: grid;
  gap: 8px;
  padding: 16px;
  background: var(--surface-solid);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.guidance-hero span {
  width: max-content;
  padding: 4px 10px;
  color: white;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  border-radius: 999px;
  font-size: 12px;
  font-weight: 900;
}

.guidance-hero strong {
  font-size: 20px;
  line-height: 1.35;
}

.guidance-essay {
  padding: 14px 16px;
  color: var(--text);
  background: var(--surface-solid);
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 14px;
  font-weight: 800;
  line-height: 1.65;
}

.current-holdings {
  padding: 14px 16px;
  background: var(--surface-solid);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.current-holdings.empty {
  border-style: dashed;
}

.holding-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.holding-head h3 {
  margin: 0;
  font-size: 14px;
}

.holding-head span {
  color: var(--brand);
  font-size: 12px;
  font-weight: 900;
}

.current-holdings p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  line-height: 1.55;
}

.holding-list {
  display: grid;
  gap: 8px;
}

.holding-row {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) 90px 120px 100px;
  gap: 10px;
  align-items: center;
  padding: 9px 10px;
  background: rgba(148, 163, 184, 0.08);
  border-radius: 8px;
}

.holding-row span,
.holding-row em,
.holding-row small {
  color: var(--muted);
  font-size: 12px;
  font-style: normal;
  font-weight: 900;
}

.position-empty {
  display: grid;
  gap: 8px;
  padding: 16px;
  background: rgba(217, 119, 6, 0.08);
  border: 1px dashed rgba(217, 119, 6, 0.45);
  border-radius: 8px;
}

.position-empty strong {
  color: var(--warn);
  font-size: 16px;
  font-weight: 900;
}

.position-empty span {
  color: var(--text);
  font-size: 13px;
  font-weight: 800;
  line-height: 1.6;
}

.holding-summary-card {
  display: grid;
  gap: 5px;
  margin-bottom: 10px;
  padding: 14px;
  background: rgba(79, 70, 229, 0.08);
  border: 1px solid rgba(79, 70, 229, 0.18);
  border-radius: 8px;
}

.holding-summary-card span,
.holding-summary-card small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.holding-summary-card strong {
  color: var(--text);
  font-size: 22px;
  font-weight: 900;
}

.holding-table {
  display: grid;
  gap: 8px;
}

.holding-table-row {
  display: grid;
  grid-template-columns: minmax(160px, 1fr) 110px 90px;
  gap: 10px;
  align-items: center;
  padding: 11px 12px;
  background: var(--surface-solid);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.holding-table-row div {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.holding-table-row strong,
.holding-table-row span,
.holding-table-row em,
.holding-table-row small {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.holding-table-row strong {
  color: var(--text);
  font-size: 13px;
  font-weight: 900;
}

.holding-table-row span,
.holding-table-row em,
.holding-table-row small {
  color: var(--muted);
  font-size: 12px;
  font-style: normal;
  font-weight: 900;
}

.guidance-section h3 {
  margin: 0 0 10px;
  font-size: 14px;
}

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

.sector-chip,
.action-item {
  padding: 12px;
  background: var(--surface-solid);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.sector-chip {
  display: grid;
  gap: 6px;
}

.sector-chip span {
  color: var(--brand);
  font-size: 12px;
  font-weight: 900;
}

.sector-chip small,
.action-item small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.45;
}

.action-list {
  display: grid;
  gap: 10px;
}

.action-item {
  display: grid;
  grid-template-columns: 56px minmax(0, 1fr);
  gap: 12px;
  align-items: start;
}

.action-badge {
  display: grid;
  place-items: center;
  min-height: 36px;
  color: white;
  background: var(--muted);
  border-radius: 8px;
  font-size: 15px;
  font-weight: 900;
}

.action-BUY .action-badge {
  background: var(--bad);
}

.action-SELL .action-badge {
  background: var(--good);
}

.action-SKIP .action-badge {
  background: var(--muted);
}

.action-item strong,
.action-item span {
  display: block;
}

.action-item span {
  margin: 4px 0;
  color: var(--text);
  font-size: 13px;
  font-weight: 900;
}

.guidance-notes {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.guidance-notes span {
  padding: 6px 10px;
  color: var(--muted);
  background: var(--surface-solid);
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
}

.segmented {
  display: inline-flex;
  gap: 4px;
  padding: 4px;
  background: rgba(226, 232, 240, 0.7);
  border: 1px solid var(--line);
  border-radius: 8px;
}

body.dark .segmented {
  background: rgba(30, 41, 59, 0.82);
}

.segment {
  min-height: 32px;
  padding: 6px 10px;
  color: var(--muted);
  background: transparent;
  border: 0;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 900;
}

.segment.active {
  color: var(--brand);
  background: var(--surface-solid);
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.06);
}

.switch-row,
.check-strip label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.check-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 2px 0 14px;
}

.chart-wrap {
  margin-top: 14px;
  padding: 12px;
  background: var(--surface-solid);
  border: 1px solid var(--line);
  border-radius: 8px;
}

canvas {
  display: block;
  width: 100%;
}

.tool-console {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  gap: 14px;
  min-height: calc(100vh - 210px);
}

.tool-list,
.resource-list,
.prompt-list {
  display: grid;
  align-content: start;
  gap: 8px;
  max-height: calc(100vh - 220px);
  overflow: auto;
}

.tool-item,
.resource-item,
.prompt-item {
  padding: 12px;
  background: var(--surface-solid);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.tool-item,
.resource-item,
.prompt-item {
  cursor: pointer;
  text-align: left;
}

.tool-item.active,
.prompt-item.active {
  border-color: var(--brand);
  box-shadow: inset 3px 0 0 var(--brand);
}

.tool-item strong,
.resource-item strong,
.prompt-item strong {
  display: block;
  font-size: 13px;
}

.tool-item small,
.resource-item small,
.prompt-item small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.tool-detail {
  min-width: 0;
}

.tool-search {
  max-width: 260px;
}

.tool-meta {
  margin-bottom: 12px;
  color: var(--muted);
  line-height: 1.55;
}

.template-box {
  display: grid;
  gap: 10px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.template-box label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.dynamic-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 12px;
}

.dynamic-form label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.prompt-form {
  margin-top: 12px;
}

.empty-state,
.loading,
.error {
  color: var(--muted);
  font-weight: 800;
  padding: 16px;
}

.error {
  color: var(--bad);
}

.hidden {
  display: none !important;
}

.login-page {
  overflow: auto;
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 24px;
}

.login-shell {
  width: min(420px, 100%);
}

.login-panel {
  display: grid;
  gap: 22px;
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-solid);
  box-shadow: var(--shadow);
}

.login-brand {
  padding: 0;
}

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

.login-form label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 900;
}

.login-message {
  min-height: 20px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.login-message.error {
  color: var(--bad);
}

@media (max-width: 1100px) {
  body {
    overflow: auto;
  }

  .app-shell {
    height: auto;
    min-height: 100vh;
    flex-direction: column;
  }

  .sidebar {
    width: 100%;
    flex: 0 0 auto;
  }

  .nav-list {
    flex-direction: row;
    overflow-x: auto;
  }

  .nav-button {
    width: auto;
    white-space: nowrap;
  }

  .sidebar-footer {
    display: none;
  }

  .topbar,
  .panel-head,
  .top-actions,
  .query-row,
  .inline-form {
    align-items: stretch;
    flex-direction: column;
  }

  .stat-grid,
  .panel-grid.two,
  .form-grid,
  .form-grid.compact,
  .ai-policy-grid,
  .crypto-pnl-banner,
  .crypto-pnl-detail,
  .crypto-holding-summary,
  .crypto-position-row,
  .crypto-ai-status-row,
  .crypto-support-list,
  .crypto-decision-row,
  .crypto-activity-list > div,
  .engine-grid,
  .bridge-strip,
  .bridge-summary,
  .bridge-detail-grid,
  .tool-console,
  .dynamic-form {
    grid-template-columns: 1fr;
  }

  .crypto-config-top {
    align-items: stretch;
    flex-direction: column;
  }

  .crypto-mode-toggle {
    width: 100%;
  }

  .crypto-mode-toggle .segment {
    flex: 1 1 0;
  }

  .view {
    overflow: visible;
    padding: 14px;
  }
}
