:root {
  color-scheme: dark;
  font-family: "Segoe UI", sans-serif;
  background: #111418;
  color: #edf1f7;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  --surface: #1b2027;
  --surface-raised: #20252d;
  --border: #2b323b;
  --muted: #9ca8ba;
  --accent: #5b9cff;
  --accent-dark: #1c2b43;
  --accent-border: #3d5d8a;
  --accent-hover: #294a73;
  --accent-glow: rgb(91 156 255 / 14%);
  --positive: #34d399;
  --positive-dark: #173a32;
  --positive-border: #2f8062;
  --negative: #ff6078;
  --warning: #fbbf24;
}

.market-symbol {
  color: var(--accent);
  font-weight: 700;
}

.trade-action-buy {
  color: var(--positive);
  font-weight: 700;
}

.trade-action-sell {
  color: var(--negative);
  font-weight: 700;
}

.trade-position-breakdown {
  display: grid;
  gap: 3px;
  min-width: 190px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.4;
}

.trade-position-breakdown span {
  white-space: nowrap;
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  background: #111418;
}

a {
  color: inherit;
}

.site-header,
.site-footer {
  border-bottom: 1px solid var(--border);
  background: rgb(17 20 24 / 88%);
}

.site-header {
  position: sticky;
  z-index: 10;
  top: 0;
  backdrop-filter: blur(14px);
}

.header-inner,
.footer-inner,
.page-shell {
  width: min(1120px, calc(100% - 40px));
  margin-inline: auto;
}

.header-inner {
  display: flex;
  min-height: 76px;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  text-decoration: none;
  font-weight: 700;
  letter-spacing: -0.03em;
}

.brand-mark {
  display: block;
  width: 34px;
  height: 34px;
  flex: 0 0 34px;
  border: 1px solid var(--accent-border);
  border-radius: 9px;
  background: var(--accent-dark);
  object-fit: cover;
  box-shadow:
    0 0 0 1px rgb(91 156 255 / 16%),
    0 0 14px rgb(91 156 255 / 40%),
    0 0 26px rgb(91 156 255 / 20%);
}

.paper-mode-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 8px;
  border: 1px solid #9c7435;
  border-radius: 999px;
  color: var(--warning);
  font-size: 9px;
  font-weight: 750;
  letter-spacing: 0.06em;
  line-height: 1;
  white-space: nowrap;
}

.paper-mode-badge::before {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--warning);
  box-shadow: 0 0 8px rgb(251 191 36 / 55%);
  content: "";
}

.primary-nav {
  display: flex;
  align-items: center;
  justify-content: flex-end;
}

.nav-dropdown {
  position: relative;
}

.nav-trigger {
  display: inline-flex;
  min-height: 40px;
  align-items: center;
  gap: 10px;
  padding: 9px 11px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: #eef4f1;
  cursor: pointer;
  font: inherit;
  font-size: 13px;
  list-style: none;
}

.nav-trigger::-webkit-details-marker {
  display: none;
}

.nav-trigger::after {
  width: 7px;
  height: 7px;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  content: "";
  transform: translateY(-2px) rotate(45deg);
  transition: transform 150ms ease;
}

.nav-dropdown[open] > .nav-trigger::after {
  transform: translateY(2px) rotate(225deg);
}

.nav-trigger:hover,
.nav-dropdown[open] > .nav-trigger {
  border-color: var(--accent-border);
  background: var(--surface-raised);
  box-shadow: 0 0 16px rgb(91 156 255 / 12%);
}

.nav-menu {
  position: absolute;
  z-index: 2;
  top: calc(100% + 9px);
  right: 0;
  display: grid;
  min-width: 220px;
  gap: 3px;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: 0 16px 38px rgb(0 0 0 / 40%);
}

.nav-menu-divider {
  display: block;
  margin: 3px 4px;
  border-top: 1px solid var(--border);
}

.primary-nav .nav-menu a {
  padding: 10px 11px;
  border-radius: 8px;
  color: var(--muted);
  font-size: 13px;
  text-decoration: none;
  transition: background-color 140ms ease, color 140ms ease, box-shadow 140ms ease;
}

.primary-nav .nav-menu a:hover,
.primary-nav .nav-menu a[aria-current="page"] {
  background: var(--surface-raised);
  color: #f3fbf6;
}

.primary-nav .nav-menu a:hover {
  box-shadow: inset 0 0 0 1px var(--accent-border), 0 0 18px rgb(91 156 255 / 15%);
}

.primary-nav .nav-menu [hidden] {
  display: none;
}

.page-shell {
  min-height: calc(100vh - 146px);
  padding-block: 68px 88px;
}

.eyebrow {
  margin: 0 0 12px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

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

h1 {
  max-width: 760px;
  margin-bottom: 17px;
  font-size: clamp(36px, 6vw, 62px);
  letter-spacing: -0.055em;
  line-height: 1.04;
}

h2 {
  margin-bottom: 9px;
  font-size: 18px;
  letter-spacing: -0.025em;
}

.page-description,
.card-description {
  color: var(--muted);
  line-height: 1.7;
}

.page-description {
  max-width: 650px;
  margin-bottom: 30px;
  font-size: 16px;
}

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

.placeholder-card,
.intro-card {
  border: 1px solid var(--border);
  border-radius: 16px;
  background: linear-gradient(145deg, var(--surface-raised), var(--surface));
}

.placeholder-card,
.intro-card {
  padding: clamp(22px, 4vw, 34px);
}

.placeholder-card {
  max-width: 760px;
}

.card-description {
  margin-bottom: 0;
  font-size: 14px;
}

.intro-card {
  max-width: 760px;
  margin-top: 34px;
}

.button-link {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  margin-top: 23px;
  padding: 0 17px;
  border: 1px solid var(--accent-border);
  border-radius: 9px;
  background: var(--accent);
  color: #f3f7ff;
  font-size: 14px;
  font-weight: 700;
  text-decoration: none;
}

.button-link:hover {
  background: #74adff;
}

.auth-pending body {
  visibility: hidden;
}

.auth-card {
  width: min(100%, 480px);
  padding: clamp(22px, 4vw, 34px);
  border: 1px solid var(--border);
  border-radius: 16px;
  background: linear-gradient(145deg, var(--surface-raised), var(--surface));
}

.auth-card form {
  display: grid;
  gap: 12px;
}

.auth-card form[hidden] {
  display: none;
}

.auth-card label {
  margin-top: 5px;
  color: #dce3ee;
  font-size: 13px;
  font-weight: 600;
}

.auth-card input {
  width: 100%;
  min-height: 45px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #141a24;
  color: #edf1f7;
  font: inherit;
}

.auth-card input:focus-visible,
.nav-action:focus-visible,
.nav-trigger:focus-visible,
.button-link:focus-visible,
a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

.auth-card form .button-link {
  width: 100%;
  margin-top: 7px;
  cursor: pointer;
}

.auth-card button:disabled,
.nav-action:disabled {
  cursor: wait;
  opacity: 0.65;
}

[data-auth-message]:empty {
  display: none;
}

[data-auth-message] {
  margin: 18px 0 0;
  color: var(--accent);
  font-size: 13px;
  line-height: 1.6;
}

[data-auth-message][data-state="error"] {
  color: #ffaaa1;
}

.auth-links {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 12px;
  margin-top: 18px;
  font-size: 13px;
}

.auth-links a {
  color: var(--accent);
}

.account-email {
  max-width: 180px;
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nav-action {
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: #eef4f1;
  cursor: pointer;
  font: inherit;
  font-size: 12px;
}

.nav-action:hover {
  border-color: var(--accent-border);
}

.nav-menu .account-email {
  max-width: 260px;
  padding: 9px 11px;
}

.nav-menu .nav-action {
  width: 100%;
  margin-top: 2px;
  text-align: left;
}

.site-footer {
  border-top: 1px solid var(--border);
  border-bottom: 0;
}

.footer-inner {
  display: flex;
  min-height: 70px;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  color: var(--muted);
  font-size: 12px;
}

.footer-inner p {
  margin: 0;
}

@media (max-width: 760px) {
  .header-inner {
    min-height: 68px;
    gap: 12px;
    padding-block: 8px;
  }

  .brand {
    gap: 6px;
    font-size: 14px;
  }

  .paper-mode-badge {
    gap: 4px;
    padding: 4px 5px;
    font-size: 8px;
  }

  .primary-nav {
    flex-shrink: 0;
  }

  .page-shell {
    padding-block: 48px 64px;
  }

  .footer-inner {
    align-items: flex-start;
    flex-direction: column;
    justify-content: center;
    padding-block: 16px;
  }
}

.dashboard-shell {
  padding-block: 16px 64px;
}

.section-heading,
.panel-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.dashboard-updated,
.dashboard-muted,
.metric-detail {
  color: var(--muted);
  font-size: 12px;
}

.realtime-status {
  margin: 10px 0;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
}

.realtime-status[hidden] {
  display: none;
}

.dashboard-section,
.dashboard-grid,
.chart-panel {
  margin-top: 20px;
}

.section-heading {
  align-items: flex-end;
  margin-bottom: 12px;
}

.section-heading h2 {
  margin-bottom: 0;
}

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

.dashboard-extra-metrics {
  margin-top: 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
}

.dashboard-extra-metrics > summary {
  display: flex;
  min-height: 42px;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 13px;
  color: var(--accent);
  cursor: pointer;
  font-size: 13px;
  font-weight: 650;
  list-style: none;
}

.dashboard-extra-metrics > summary::-webkit-details-marker,
.history-filter-toggle::-webkit-details-marker {
  display: none;
}

.dashboard-extra-metrics > summary::after {
  content: "+";
  font-size: 18px;
  line-height: 1;
}

.dashboard-extra-metrics[open] > summary::after {
  content: "−";
}

.dashboard-extra-metrics > .dashboard-metrics {
  margin: 0 12px 12px;
}

.dashboard-extra-metrics > summary:focus-visible,
.history-filter-toggle:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.dashboard-list-panel > .panel-heading {
  cursor: pointer;
  list-style: none;
}

.dashboard-list-panel > .panel-heading::-webkit-details-marker {
  display: none;
}

.dashboard-list-panel > .panel-heading::after {
  width: 8px;
  height: 8px;
  flex: 0 0 8px;
  border-right: 1.5px solid var(--muted);
  border-bottom: 1.5px solid var(--muted);
  content: "";
  transform: translateY(-2px) rotate(45deg);
  transition: border-color 150ms ease, filter 150ms ease, transform 150ms ease;
}

.dashboard-list-panel[open] > .panel-heading::after {
  border-color: var(--accent);
  filter: drop-shadow(0 0 5px rgb(91 156 255 / 70%));
  transform: translateY(2px) rotate(225deg);
}

.dashboard-list-panel > .panel-heading:hover::after {
  border-color: var(--accent);
  filter: drop-shadow(0 0 5px rgb(91 156 255 / 70%));
}

.dashboard-list-panel > .panel-heading:focus-visible {
  border-radius: 4px;
  outline: 2px solid var(--accent);
  outline-offset: 4px;
}

.dashboard-list-panel:not([open]) > .panel-heading {
  margin-bottom: 0;
}

.dashboard-list-panel-actions {
  display: flex;
  justify-content: flex-end;
  margin: -2px 0 8px;
}

.metric-card,
.dashboard-panel {
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: linear-gradient(145deg, var(--surface-raised), var(--surface));
  box-shadow: 0 10px 28px rgb(0 0 0 / 18%), 0 0 20px rgb(91 156 255 / 5%);
}

.metric-card {
  display: flex;
  min-height: 100px;
  flex-direction: column;
  justify-content: space-between;
  gap: 14px;
  padding: 14px;
}

.metric-card-primary {
  border-color: var(--accent-border);
  border-top: 3px solid var(--accent);
  background: linear-gradient(145deg, #202c3d, #1a202b);
}

.metric-card dt {
  position: relative;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.metric-label {
  flex: 1 1 auto;
}

.kpi-info-trigger {
  display: inline-grid;
  width: 23px;
  height: 23px;
  flex: 0 0 23px;
  place-items: center;
  margin: -4px -4px 0 0;
  padding: 0;
  border: 1px solid #6d7785;
  border-radius: 50%;
  background: var(--surface-raised);
  color: var(--muted);
  font: inherit;
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
}

.kpi-info-trigger:hover,
.kpi-info-trigger[aria-expanded="true"] {
  background: #303741;
}

.kpi-info-trigger:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

.kpi-info-popover {
  position: absolute;
  z-index: 5;
  top: calc(100% + 8px);
  left: 0;
  width: min(280px, calc(100vw - 48px));
  padding: 12px;
  border: 1px solid var(--accent-border);
  border-radius: 10px;
  background: #171d27;
  box-shadow: 0 12px 30px rgb(0 0 0 / 40%);
  color: #e3e9f2;
  font-size: 12px;
  font-weight: 400;
  line-height: 1.55;
  overflow-wrap: anywhere;
}

.kpi-info-popover[hidden] {
  display: none;
}

.metric-card:nth-child(2n) .kpi-info-popover {
  right: 0;
  left: auto;
}

.metric-card dd {
  margin: 0;
  overflow-wrap: anywhere;
  font-size: clamp(18px, 5vw, 25px);
  font-weight: 700;
  letter-spacing: -0.035em;
}

.metric-card[data-value-tone="positive"] {
  border-top: 3px solid var(--positive);
}

.metric-card[data-value-tone="negative"] {
  border-top: 3px solid var(--negative);
}

[data-value-tone="positive"] {
  color: var(--positive) !important;
  text-shadow: 0 0 12px rgb(52 211 153 / 18%);
}

[data-value-tone="negative"] {
  color: var(--negative) !important;
  text-shadow: 0 0 12px rgb(255 96 120 / 18%);
}

[data-value-tone="warning"] {
  color: var(--warning) !important;
}

.metric-detail {
  display: block;
  margin-top: 3px;
  font-weight: 400;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 14px;
}

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

.activity-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 138px), 1fr));
  gap: 12px 18px;
  margin: 0;
  padding: 12px 16px;
  border: 1px solid var(--positive-border);
  border-radius: 12px;
  background: linear-gradient(105deg, #193a31, var(--positive-dark) 58%, #193a31);
  box-shadow: 0 0 22px rgb(52 211 153 / 8%);
}

.activity-strip > div {
  display: grid;
  min-width: 0;
  gap: 4px;
}

.activity-strip dt {
  color: var(--positive);
  font-size: 10px;
  font-weight: 650;
  letter-spacing: 0.045em;
  text-transform: uppercase;
}

.activity-strip dd {
  margin: 0;
  color: #dce5f2;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.dashboard-panel {
  padding: 18px;
}

.panel-heading {
  align-items: center;
  margin-bottom: 10px;
}

.panel-heading .eyebrow {
  margin-bottom: 6px;
}

.panel-heading h2 {
  margin-bottom: 0;
}

.dashboard-panel-count {
  color: var(--muted);
  font-size: 0.85em;
  font-weight: 500;
  white-space: nowrap;
}

.trade-history-dashboard-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.dashboard-link {
  color: var(--accent);
  font-size: 12px;
  font-weight: 650;
  text-decoration: none;
}

.dashboard-link:hover {
  text-decoration: underline;
}

.status-pill {
  display: inline-flex;
  min-height: 28px;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  padding: 4px 9px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: #141a24;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.status-pill[data-state="active"],
.status-pill[data-state="analyzing"],
.status-pill[data-state="normal"] {
  border-color: var(--positive-border);
  background: var(--positive-dark);
  color: var(--positive);
}

.status-pill[data-state="paused"] {
  border-color: #9c7435;
  background: #392f1c;
  color: var(--warning);
}

.status-pill[data-state="emergency_stop"],
.status-pill[data-state="error"] {
  border-color: #8d3e51;
  background: #351e29;
  color: #ff9aab;
}

.status-pill[data-state="stopped"],
.status-pill[data-state="idle"] {
  color: #d3ddd7;
}

.status-pill[data-state="online"] {
  border-color: var(--positive-border);
  background: var(--positive-dark);
  color: var(--positive);
}

.status-pill[data-state="offline"] {
  border-color: #8d3e51;
  background: #351e29;
  color: #ff9aab;
}

.archive-health-panel {
  margin-top: 14px;
}

.archive-health-metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 170px), 1fr));
  gap: 10px;
  margin: 0;
}

.archive-health-metrics > div {
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #141a24;
}

.archive-health-metrics dt {
  color: var(--muted);
  font-size: 12px;
}

.archive-health-metrics dd {
  display: flex;
  min-height: 28px;
  align-items: center;
  gap: 9px;
  margin: 8px 0 0;
  font-weight: 650;
  overflow-wrap: anywhere;
}

.archive-health-metrics meter {
  width: min(100%, 110px);
  height: 8px;
  accent-color: var(--accent);
}

.agent-brain {
  position: relative;
  margin-top: 16px;
  overflow: hidden;
  background: transparent;
}

.agent-brain-stage {
  display: grid;
  width: min(100%, 90vh);
  aspect-ratio: 1;
  margin: 0 auto;
  place-items: center;
  overflow: hidden;
  background: radial-gradient(ellipse at center, #20252d 0%, #171c23 66%, #111418 100%);
  box-shadow:
    inset 0 0 52px rgb(255 255 255 / 3%),
    0 0 34px rgb(91 156 255 / 8%);
}

.agent-circuit-art {
  display: block;
  width: 100%;
  height: 100%;
}

.circuit-board-image {
  display: block;
  width: 100%;
  height: 100%;
  filter: saturate(1.1);
  opacity: 0.62;
}

.circuit-chip-analyzing-glow {
  opacity: 0.18;
  pointer-events: none;
  stroke: var(--accent);
  transition: opacity 450ms ease;
}

.agent-brain[data-state="analyzing"] .circuit-chip-analyzing-glow {
  opacity: 0.58;
  filter: drop-shadow(0 0 14px rgb(91 156 255 / 45%));
}

.circuit-flow {
  display: none;
}

.agent-brain[data-state="active"] .circuit-flow--active,
.agent-brain[data-state="analyzing"] .circuit-flow--analyzing,
.agent-brain[data-state="idle"] .circuit-flow--idle,
.agent-brain[data-state="error"] .circuit-flow--error {
  display: inline;
}

.circuit-neuron-halo {
  filter: url("#circuit-neuron-glow") drop-shadow(0 0 18px #7cb7ff) drop-shadow(0 0 40px rgb(91 156 255 / 96%));
  opacity: 1;
}

.circuit-neuron-core {
  fill: #ffffff;
  stroke: #9bc7ff;
  stroke-width: 1.5;
}

.circuit-neuron--analyzing .circuit-neuron-halo {
  filter: url("#circuit-neuron-glow") drop-shadow(0 0 24px #c5e1ff) drop-shadow(0 0 48px rgb(91 156 255 / 100%));
  opacity: 1;
}

.circuit-neuron--idle .circuit-neuron-halo {
  opacity: 0.55;
}

.circuit-neuron--error .circuit-neuron-halo {
  filter: url("#circuit-neuron-glow") drop-shadow(0 0 18px #ff6478) drop-shadow(0 0 36px rgb(255 100 120 / 94%));
}

.circuit-neuron--error .circuit-neuron-core {
  stroke: #ff6478;
}

.agent-status-monitor {
  display: flex;
  min-height: 74px;
  margin-top: 8px;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 12px 18px;
  border-top: 1px solid var(--accent-border);
  background: linear-gradient(90deg, rgb(20 24 30 / 96%), rgb(28 33 41 / 80%));
}

.agent-status-title {
  margin: 0;
  color: #9dc5ff;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.agent-status-description {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.agent-status-wave {
  display: flex;
  min-width: 120px;
  height: 34px;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
}

.agent-status-wave span {
  width: 4px;
  height: 28px;
  flex: 0 0 4px;
  border-radius: 999px;
  background: #54c9ff;
  opacity: 0.35;
  transform: scaleY(0.2);
  transform-origin: center;
}

.agent-status-wave span:nth-child(4n + 1) {
  --signal-peak: 0.55;
}

.agent-status-wave span:nth-child(4n + 2) {
  --signal-peak: 0.82;
}

.agent-status-wave span:nth-child(4n + 3) {
  --signal-peak: 1;
}

.agent-status-wave span:nth-child(4n) {
  --signal-peak: 0.68;
}

.agent-brain[data-state="active"] + .agent-status-monitor .agent-status-wave span {
  animation: agent-status-pulse 1.1s ease-in-out infinite;
}

.agent-brain[data-state="analyzing"] + .agent-status-monitor .agent-status-wave span {
  animation: agent-status-pulse 0.62s ease-in-out infinite;
  background: #a8d0ff;
  box-shadow: 0 0 10px rgb(91 156 255 / 65%);
}

.agent-brain[data-state="error"] + .agent-status-monitor .agent-status-wave span {
  animation: agent-status-pulse 1.2s ease-in-out infinite;
  background: #ff6570;
}

.agent-status-wave span:nth-child(3n + 1) {
  animation-delay: -0.36s;
}

.agent-status-wave span:nth-child(3n + 2) {
  animation-delay: -0.18s;
}

@keyframes agent-status-pulse {
  0%,
  100% {
    opacity: 0.35;
    transform: scaleY(0.2);
  }

  50% {
    opacity: 0.95;
    transform: scaleY(var(--signal-peak, 0.85));
  }
}

.agent-brain-fallback {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  margin: 0;
  padding: 24px;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}

.agent-brain-fallback[hidden] {
  display: none;
}

.agent-brain[data-visualization="ready"] .agent-brain-fallback {
  display: none !important;
}

.chart-frame {
  position: relative;
  min-height: 220px;
  height: 260px;
  margin-top: 14px;
}

.chart-frame canvas {
  width: 100% !important;
  height: 100% !important;
}

.dashboard-empty {
  margin: 0;
  padding: 16px 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.dashboard-list {
  display: grid;
  gap: 0;
  margin: 6px 0 0;
  padding: 0;
  list-style: none;
}

.dashboard-list[data-scrollable="true"] {
  max-height: var(--dashboard-list-max-height, 200px);
  overflow-y: auto;
  overscroll-behavior: contain;
}

.dashboard-list[hidden],
.chart-frame canvas[hidden],
.dashboard-error[hidden],
.dashboard-retry[hidden],
.dashboard-updated[hidden],
.dashboard-empty[hidden] {
  display: none;
}

.dashboard-list li {
  display: grid;
  gap: 4px;
  padding: 12px 0;
  border-top: 1px solid var(--border);
}

.dashboard-row-primary {
  overflow-wrap: anywhere;
  color: #edf1f7;
  font-size: 13px;
  font-weight: 650;
}

.dashboard-row-secondary {
  overflow-wrap: anywhere;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.5;
}

.dashboard-list[data-dashboard-list="trades"] .dashboard-row-secondary {
  white-space: pre-line;
}

.dashboard-list[data-dashboard-list="position-ai-status"] {
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr));
  gap: 12px;
}

.dashboard-list[data-dashboard-list="position-ai-status"][data-scrollable="true"] {
  grid-template-columns: 1fr;
  max-height: var(--dashboard-list-max-height, 520px);
}

.dashboard-list[data-dashboard-list="position-ai-status"] li {
  align-content: start;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface-raised);
}

.position-ai-status-symbol {
  margin: 0;
  overflow-wrap: anywhere;
  color: #edf1f7;
  font-size: 14px;
  font-weight: 700;
}

.position-ai-status-details {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 170px), 1fr));
  gap: 10px 12px;
  margin: 0;
}

.position-ai-status-commentary {
  grid-column: 1 / -1;
}

.position-ai-status-field {
  min-width: 0;
}

.position-ai-status-field dt {
  margin-bottom: 3px;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.4;
}

.position-ai-status-field dd {
  margin: 0;
  overflow-wrap: anywhere;
  color: #edf1f7;
  font-size: 12px;
  line-height: 1.45;
}

.position-ai-status-commentary dd {
  font-size: 13px;
}

.position-ai-status-field dd[data-value-tone="positive"] {
  color: var(--positive);
}

.position-ai-status-field dd[data-value-tone="negative"] {
  color: var(--negative);
}

.shadow-exit-panel {
  display: grid;
  gap: 12px;
  margin-top: 16px;
  padding: 18px;
}

.shadow-exit-disclaimer,
.shadow-exit-status {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
}

.shadow-exit-legend {
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
}

.shadow-exit-legend-heading {
  margin: 0;
  color: #edf1f7;
  font-size: 12px;
  font-weight: 700;
}

.shadow-exit-legend-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr));
  gap: 7px 18px;
  margin: 8px 0 0;
  padding-left: 18px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.55;
}

.shadow-exit-legend-list strong {
  color: #edf1f7;
}

.shadow-exit-status[data-state="unavailable"] {
  color: var(--negative);
}

.shadow-exit-position-list,
.shadow-exit-rule-list {
  display: grid;
  gap: 12px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.shadow-exit-position {
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface-raised);
}

.shadow-exit-position-summary {
  display: flex;
  min-height: 48px;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  cursor: pointer;
  list-style: none;
}

.shadow-exit-position-summary::-webkit-details-marker {
  display: none;
}

.shadow-exit-position-summary::after {
  flex: 0 0 auto;
  color: var(--muted);
  content: "+";
  font-size: 20px;
  line-height: 1;
}

.shadow-exit-position[open] > .shadow-exit-position-summary::after {
  content: "−";
}

.shadow-exit-position-summary:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -3px;
  border-radius: 10px;
}

.shadow-exit-position-heading,
.shadow-exit-rule-heading {
  margin: 0;
  overflow-wrap: anywhere;
  color: #edf1f7;
  font-size: 14px;
  font-weight: 700;
}

.shadow-exit-position-details,
.shadow-exit-rule-details {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 180px), 1fr));
  gap: 9px 14px;
  margin: 0;
  padding: 12px 14px 0;
}

.shadow-exit-field {
  min-width: 0;
}

.shadow-exit-field dt {
  margin-bottom: 3px;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.4;
}

.shadow-exit-field dd {
  margin: 0;
  overflow-wrap: anywhere;
  color: #edf1f7;
  font-size: 12px;
  line-height: 1.5;
}

.shadow-exit-field dd[data-value-tone="positive"] {
  color: var(--positive);
}

.shadow-exit-field dd[data-value-tone="negative"] {
  color: var(--negative);
}

.shadow-exit-rule-list {
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 240px), 1fr));
  margin: 12px 14px 14px;
}

.shadow-exit-rule {
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
}

.shadow-exit-rule-heading {
  font-size: 13px;
}

.shadow-exit-rule-parameters,
.shadow-exit-rule-version {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.5;
}

.dashboard-error {
  margin-top: 14px;
  padding: 13px 15px;
  border: 1px solid #8d3e51;
  border-radius: 10px;
  background: #351e29;
  color: #ff9aab;
  font-size: 13px;
  line-height: 1.5;
}

.dashboard-retry {
  min-height: 40px;
  margin-top: 10px;
  padding: 0 14px;
  border: 1px solid #8d3e51;
  border-radius: 8px;
  background: #291a23;
  color: #ffb1bd;
  cursor: pointer;
  font: inherit;
  font-size: 13px;
}

.dashboard-retry:disabled {
  cursor: wait;
  opacity: 0.65;
}

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

.history-panel {
  margin-top: 20px;
}

.history-heading {
  margin-bottom: 18px;
}

.history-filters {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-items: end;
  gap: 12px;
  margin: 0;
  padding: 0 12px 12px;
}

.history-filter-disclosure {
  margin-bottom: 18px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
}

.history-filter-toggle {
  display: flex;
  min-height: 42px;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  color: var(--accent);
  cursor: pointer;
  font-size: 13px;
  font-weight: 650;
  list-style: none;
}

.history-filter-toggle::after {
  content: "+";
  font-size: 18px;
  line-height: 1;
}

.history-filter-disclosure[open] .history-filter-toggle::after {
  content: "−";
}

.history-filters label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

.history-filters input,
.history-filters select,
.history-search-button,
.history-page-button {
  min-width: 0;
  min-height: 42px;
  padding: 8px 11px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #141a24;
  color: #edf1f7;
  font: inherit;
  font-size: 13px;
}

.history-filters input:focus,
.history-filters select:focus,
.history-search-button:focus-visible,
.history-page-button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.history-filters option[value="buy"] {
  color: var(--positive);
}

.history-filters option[value="sell"] {
  color: var(--negative);
}

.history-search-button,
.history-page-button {
  border-color: var(--accent-border);
  background: var(--accent-dark);
  color: var(--accent);
  cursor: pointer;
  font-weight: 650;
}

.history-search-button:hover,
.history-page-button:not(:disabled):hover {
  background: #294a73;
}

.history-page-button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.history-result-count {
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 12px;
}

.history-table-wrap {
  max-width: 100%;
  max-height: min(60vh, 640px);
  overflow: auto;
  overscroll-behavior: contain;
  border: 1px solid var(--border);
  border-radius: 10px;
  scrollbar-gutter: stable;
}

.history-table {
  width: 100%;
  min-width: 1180px;
  border-collapse: collapse;
  font-size: 12px;
  text-align: left;
}

.history-table th,
.history-table td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.history-table th {
  background: var(--surface-raised);
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.history-table thead th {
  position: sticky;
  z-index: 1;
  top: 0;
}

.history-table td {
  color: #e2e8f1;
}

.history-table tbody tr[data-trade-side="buy"] td:nth-child(3),
.history-table tbody tr[data-trade-side="buy"] td:nth-child(4) {
  color: var(--positive);
  font-weight: 650;
}

.history-table tbody tr[data-trade-side="sell"] td:nth-child(3),
.history-table tbody tr[data-trade-side="sell"] td:nth-child(4) {
  color: var(--negative);
  font-weight: 650;
}

.history-table td.trade-value-cell {
  white-space: normal;
}

.history-table td.trade-position-cell {
  min-width: 210px;
  white-space: normal;
}

.trade-value-breakdown {
  display: grid;
  gap: 3px;
  min-width: 155px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.4;
}

.trade-value-breakdown span {
  white-space: nowrap;
}

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

.history-pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin-top: 16px;
  color: var(--muted);
  font-size: 12px;
}

.history-page-button {
  min-width: 92px;
}

.dashboard-admin-actions[hidden],
.admin-action-output[hidden] {
  display: none;
}

.admin-action-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.admin-action-button {
  min-height: 44px;
  padding: 0 15px;
  border: 1px solid var(--accent-border);
  border-radius: 8px;
  background: var(--accent-dark);
  color: #e3e9f2;
  cursor: pointer;
  font: inherit;
  font-size: 13px;
  font-weight: 650;
}

.admin-action-button:hover:not(:disabled) {
  background: var(--accent-hover);
}

.admin-action-button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

.admin-action-button:disabled {
  cursor: wait;
  opacity: 0.65;
}

.admin-action-output {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

.admin-action-status {
  margin: 0 0 8px;
  color: #e3e9f2;
  font-size: 13px;
  font-weight: 650;
}

.admin-action-status[data-state="error"] {
  color: #ffaaa1;
}

.admin-action-status[data-state="success"] {
  color: var(--accent);
}

.admin-action-summary {
  max-height: 260px;
  overflow: auto;
  margin: 10px 0 0;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #141a24;
  color: #e3e9f2;
  font-size: 12px;
  line-height: 1.5;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

@media (min-width: 560px) {
  .dashboard-metrics {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
  }

  .metric-card:nth-child(2n) .kpi-info-popover {
    right: auto;
    left: 0;
  }

  .metric-card:nth-child(3n) .kpi-info-popover {
    right: 0;
    left: auto;
  }

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

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

  .metric-card {
    padding: 16px;
  }

  .dashboard-panel {
    padding: 22px;
  }

}

@media (min-width: 900px) {
  .agent-brain-stage {
    width: min(100%, 440px);
  }

  .dashboard-metrics {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 14px;
  }

  .metric-card:nth-child(3n) .kpi-info-popover {
    right: auto;
    left: 0;
  }

  .metric-card:nth-child(4n) .kpi-info-popover {
    right: 0;
    left: auto;
  }

  .history-filters {
    grid-template-columns: minmax(160px, 1.4fr) repeat(3, minmax(130px, 1fr)) auto;
  }

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

  .chart-frame {
    height: 320px;
  }
}

@media (max-width: 559px) {
  .agent-status-monitor {
    gap: 12px;
    padding: 12px;
  }

  .agent-status-wave {
    min-width: 88px;
    gap: 3px;
  }

  .agent-status-wave span {
    width: 3px;
    flex-basis: 3px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .circuit-flow {
    display: none !important;
  }

  .circuit-chip-analyzing-glow {
    transition: none;
  }

  .agent-status-wave span {
    animation: none !important;
    opacity: 0.7;
    transform: scaleY(0.55);
  }
}

.scanner-panel {
  padding: clamp(18px, 3vw, 28px);
  border: 1px solid var(--border);
  border-radius: 16px;
  background: linear-gradient(145deg, var(--surface-raised), var(--surface));
}

.scanner-toolbar,
.scanner-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.scanner-toolbar {
  margin-bottom: 20px;
}

.scanner-toolbar .card-description {
  max-width: 650px;
  margin-top: 6px;
}

.secondary-button,
.scanner-timeframes button {
  min-height: 40px;
  padding: 0 13px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: #eef4f1;
  cursor: pointer;
  font: inherit;
  font-size: 13px;
}

.secondary-button:hover,
.scanner-timeframes button:hover {
  border-color: var(--accent-border);
  background: var(--surface-raised);
}

.scanner-timeframes {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.scanner-timeframes button[aria-pressed="true"] {
  border-color: var(--accent-border);
  background: var(--accent-dark);
  color: var(--accent);
}

.scanner-timeframes button:focus-visible,
.secondary-button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

.scanner-controls [data-scanner-status] {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  text-align: right;
}

.scanner-controls [data-scanner-status][data-state="error"] {
  color: #ffaaa1;
}

.scanner-rankings {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr));
  gap: 14px;
  margin-top: 18px;
}

.scanner-ranking {
  min-width: 0;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: rgb(17 20 24 / 65%);
}

.scanner-ranking h3 {
  margin: 0;
  color: #e2e8f1;
  font-size: 14px;
}

.scanner-ranking ol {
  display: grid;
  gap: 0;
  margin: 6px 0 0;
  padding-left: 24px;
}

.scanner-ranking ol[hidden] {
  display: none;
}

.scanner-ranking li {
  padding: 11px 0 11px 4px;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 12px;
}

.scanner-ranking .dashboard-row-primary {
  color: #eef4f1;
}

.scanner-ranking-wide {
  grid-column: 1 / -1;
}

.scanner-market-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 180px), 1fr));
  gap: 8px;
  max-height: 360px;
  overflow: auto;
  margin: 0;
  padding: 0;
  list-style: none;
}

.scanner-market-list:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

.scanner-market-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-width: 0;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: rgb(17 20 24 / 65%);
  font-size: 12px;
}

.scanner-market-priority {
  color: var(--muted);
  white-space: nowrap;
}

.text-link {
  color: var(--accent);
  font-size: 13px;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

@media (max-width: 560px) {
  .scanner-toolbar,
  .scanner-controls {
    align-items: stretch;
    flex-direction: column;
  }

  .scanner-controls [data-scanner-status] {
    text-align: left;
  }
}

.export-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 320px), 1fr));
  gap: 16px;
}

.export-card {
  display: flex;
  min-width: 0;
  flex-direction: column;
  align-items: flex-start;
  gap: 12px;
  padding: 20px;
  border-color: rgb(61 93 138 / 82%);
  box-shadow: 0 12px 32px rgb(0 0 0 / 24%), 0 0 26px rgb(91 156 255 / 8%);
}

.export-card h2,
.export-card .eyebrow,
.export-card .card-description {
  margin-bottom: 0;
}

.export-card .card-description {
  width: calc(100% + 40px);
  margin: 0 -20px 2px;
  padding: 0 20px 14px;
  border-bottom: 1px solid var(--border);
}

.export-filter {
  display: grid;
  width: 100%;
  gap: 7px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

.export-filter select {
  width: 100%;
  min-height: 42px;
  padding: 8px 11px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #141a24;
  color: #edf1f7;
  font: inherit;
  font-size: 13px;
}

.export-filter select:focus-visible,
.export-card button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.export-card [data-export-download] {
  border-color: #303a4a;
  background: #15191f;
  color: #e3e9f2;
  box-shadow: inset 0 1px 0 rgb(255 255 255 / 3%);
}

.export-card [data-export-download]:hover:not(:disabled) {
  border-color: var(--accent-border);
  background: var(--surface-raised);
  box-shadow: 0 0 18px rgb(91 156 255 / 15%);
}

.export-record-count,
.export-status {
  min-height: 18px;
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.export-status[data-state="error"] {
  color: #ffaaa1;
}

.export-status[data-state="success"] {
  color: var(--accent);
}

.analytics-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 18px 0;
}

.analytics-toolbar p {
  margin: 0;
}

.analytics-metrics {
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 180px), 1fr));
}

.analytics-chart-grid {
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 380px), 1fr));
}

.analytics-period-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr));
  gap: 14px;
  margin-top: 14px;
}

.analytics-table-grid {
  gap: 14px;
}

.analytics-table {
  min-width: 580px;
}

.analytics-insight {
  padding: 14px 16px;
  border: 1px solid var(--accent-border);
  border-radius: 10px;
  background: #1c2b43;
  color: #e3e9f2;
}

.analytics-insight strong {
  color: var(--accent);
}

.recommendation-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 360px), 1fr));
  gap: 14px;
  margin-top: 16px;
}

.recommendation-grid > .dashboard-panel {
  min-width: 0;
  padding: 20px;
}

.recommendation-grid h2 {
  margin-bottom: 14px;
}

.recommendation-list {
  display: grid;
  gap: 12px;
}

.recommendation-card {
  min-width: 0;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: rgb(255 255 255 / 3%);
}

.recommendation-card h3 {
  margin: 0 0 8px;
  font-size: 15px;
}

.recommendation-reason {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.recommendation-details {
  display: grid;
  gap: 9px;
  margin: 14px 0 0;
}

.recommendation-details > div {
  display: grid;
  grid-template-columns: minmax(100px, 0.7fr) minmax(0, 1fr);
  gap: 12px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}

.recommendation-details dt {
  color: var(--muted);
  font-size: 12px;
}

.recommendation-details dd {
  min-width: 0;
  margin: 0;
  color: #e3e9f2;
  font-size: 12px;
  overflow-wrap: anywhere;
}

.analytics-data-quality {
  margin-top: 20px;
  padding: 12px 14px;
  border: 1px solid #8a653d;
  border-radius: 10px;
  background: rgb(138 101 61 / 14%);
  color: #f0c992;
}

.export-card .dashboard-empty {
  margin: 0;
}

.export-card button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}
