:root {
  font-family: Inter, "PingFang SC", "Microsoft YaHei", "Noto Sans CJK SC", system-ui, sans-serif;
  font-size: 14px;
  font-synthesis: none;
  color-scheme: light;
  color: var(--ink);
  background: var(--canvas);
  --canvas: #f4f6f9;
  --surface: #fff;
  --surface-subtle: #fbfcfe;
  --ink: #1e2a3d;
  --ink-strong: #1b293f;
  --ink-secondary: #273750;
  --muted: #6a778b;
  --line: #e4e9f0;
  --line-subtle: #edf0f4;
  --blue: #2164e8;
  --blue-strong: #1857d4;
  --green: #047a55;
  --red: #c73848;
  --focus: #347af3;
  --control-border: #dce4ee;
  --control-border-hover: #aebed3;
  --primary-bg: var(--blue);
  --primary-hover: var(--blue-strong);
  --radius: 10px;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --canvas: #131617;
  --surface: #1c1f21;
  --surface-subtle: #24292b;
  --ink: #d6dfe3;
  --ink-strong: #edf2f4;
  --ink-secondary: #dce6e9;
  --muted: #a4b2b8;
  --line: #323a3d;
  --line-subtle: #2a3235;
  --blue: #5ec7ba;
  --blue-strong: #80dbcf;
  --green: #75d7a9;
  --red: #f298a2;
  --focus: #77d9cd;
  --control-border: #465155;
  --control-border-hover: #6a797d;
  --primary-bg: #216d65;
  --primary-hover: #28786e;
}

*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; min-width: 320px; font-variant-numeric: tabular-nums; }
button, input, select { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .5; }
button, select, input, [tabindex] { -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
button, select, input { max-width: 100%; }
h1, h2, h3, p, dl, dd { margin: 0; }
a { color: var(--blue-strong); }

.app-header { border-bottom: 1px solid var(--line); background: var(--surface); }
.app-header__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  max-width: 1512px;
  min-height: 62px;
  margin: 0 auto;
  padding: 0 28px;
}
.app-brand { display: inline-flex; align-items: center; gap: 10px; color: var(--ink-strong); font-size: 17px; font-weight: 730; white-space: nowrap; }
.app-brand__icon { display: block; flex: none; border-radius: 8px; }
.app-header__actions { display: flex; align-items: center; justify-content: flex-end; gap: 12px; }
.theme-toggle { gap: 7px; }
.theme-toggle [data-theme-icon="light"],
:root[data-theme="dark"] .theme-toggle [data-theme-icon="dark"] { display: none; }
:root[data-theme="dark"] .theme-toggle [data-theme-icon="light"] { display: block; }

.workspace { max-width: 1512px; margin: 0 auto; padding: 25px 28px calc(36px + env(safe-area-inset-bottom)); }
.panel {
  min-width: 0;
  margin-bottom: 13px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: 0 2px 4px rgb(23 48 82 / 2%);
}
.panel:last-of-type { margin-bottom: 0; }
select, input:not([type=checkbox]):not([type=radio]) {
  min-height: 34px;
  padding: 6px 10px;
  border: 1px solid var(--control-border);
  border-radius: 6px;
  background-color: var(--surface);
  color: var(--ink-secondary);
}
select:hover, input:not([type=checkbox]):not([type=radio]):hover { border-color: var(--control-border-hover); }

.panel-header { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 15px 18px; }
.panel-header h2 { display: flex; align-items: center; gap: 7px; font-size: 15px; font-weight: 720; line-height: 1.25; }
.positive { color: var(--green) !important; }
.negative { color: var(--red) !important; }
.muted { color: var(--muted); }

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  min-height: 35px;
  padding: 0 12px;
  border: 1px solid transparent;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 670;
  line-height: 1.2;
  white-space: nowrap;
  transition: background-color 120ms ease, border-color 120ms ease;
}
.button--small { min-height: 30px; padding: 0 9px; }
.button--secondary { background: var(--surface); border-color: var(--control-border); color: #34445b; }
.button--secondary:hover:not(:disabled) { background: #f2f6fb; border-color: #c9d6e6; }
.button--primary { background: var(--primary-bg); color: #fff; }
.button--primary:hover:not(:disabled) { background: var(--primary-hover); }

.table-scroll { max-width: 100%; overflow-x: auto; scrollbar-color: #abb8cb transparent; scrollbar-width: thin; }
.data-table { width: 100%; border-collapse: collapse; text-align: left; font-size: 12px; white-space: nowrap; }
.data-table th, .data-table td { padding: 10px 10px; vertical-align: middle; }
.data-table th:first-child, .data-table td:first-child { padding-left: 18px; }
.data-table th:last-child, .data-table td:last-child { padding-right: 18px; }
.data-table th {
  background: #f7f9fc;
  border-top: 1px solid var(--line-subtle);
  border-bottom: 1px solid var(--line-subtle);
  color: #5b6b81;
  font-size: 11.5px;
  font-weight: 680;
}
.data-table tbody tr { border-bottom: 1px solid var(--line-subtle); }
.data-table tbody tr:last-child { border-bottom: 0; }
.data-table tbody tr:nth-child(even) { background: #fcfdfe; }
.data-table tbody tr:hover { background: #f6f9fd; }
.position-symbol { color: #253650; font-weight: 720; letter-spacing: .01em; }
.side-tag { display: inline-flex; align-items: center; border-radius: 4px; padding: 2px 5px; font-size: 11px; line-height: 1.3; font-weight: 650; }
.side-tag--short { color: #a72b40; background: #fcecef; }
.side-tag--long { color: #08764f; background: #e8f8ef; }
.empty-state { padding: 24px 18px !important; text-align: center; color: var(--muted); }

.strategies-panel > .panel-header { padding-bottom: 12px; }
.strategy-list {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  padding: 0 16px 14px;
}
.strategy-card {
  position: relative;
  min-width: 0;
  border: 1px solid #e1e8f1;
  border-radius: 8px;
  background: #fbfcfe;
  padding: 14px 13px 12px;
  transition: border-color 140ms ease, background-color 140ms ease;
}
.strategy-card:hover { border-color: #acc5e9; }
.strategy-card.is-selected { border-color: #79a5ed; background: #eef5ff; box-shadow: inset 0 0 0 1px rgb(104 152 234 / 6%); }
.strategy-top { display: flex; align-items: center; gap: 9px; min-width: 0; min-height: 36px; }
.strategy-top > div { min-width: 0; }
.strategy-avatar {
  display: grid;
  place-items: center;
  width: 35px;
  height: 35px;
  flex: none;
  border-radius: 9px;
  background: #dbeaff;
  color: #235ba6;
  font-size: 13px;
  font-weight: 750;
}
.strategy-top .strategy-name {
  display: block;
  min-height: auto;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  font-size: 12px;
  font-weight: 720;
  line-height: 1.35;
  text-align: left;
  white-space: normal;
  overflow-wrap: anywhere;
}
.strategy-name:hover { color: var(--blue-strong); }
.strategy-name::after { position: absolute; inset: 0; border-radius: 8px; content: ""; }
.strategy-name:focus-visible { outline: none; }
.strategy-name:focus-visible::after { outline: 2px solid var(--focus); outline-offset: 2px; }
.exchange-tag { color: #697891; font-size: 10.5px; }
.strategy-metrics { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 5px; margin-top: 13px; }
:is([data-trader-card="eagle"], [data-trader-card="btc-stars"]) .strategy-metrics { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.strategy-metrics > div { min-width: 0; }
.strategy-metrics span, .strategy-metrics dt { display: block; color: var(--muted); font-size: 10px; line-height: 1.2; margin-bottom: 4px; }
.strategy-metrics strong, .strategy-metrics dd { display: block; color: #23344d; font-size: 12px; font-weight: 710; line-height: 1.2; overflow-wrap: anywhere; }

.activity { overflow: hidden; }
.detail-tabs { display: flex; isolation: isolate; overflow-x: auto; border-bottom: 1px solid var(--line); scrollbar-width: thin; }
.detail-tab {
  position: relative;
  flex: none;
  min-height: 43px;
  padding: 0 13px;
  border: 0;
  background: var(--surface);
  color: #62718a;
  font-size: 12px;
  font-weight: 640;
  white-space: nowrap;
}
.detail-tab:first-child { padding-left: 18px; }
.detail-tab[hidden] { display: none; }
.detail-tab:hover { color: var(--blue-strong); background: #f7faff; }
.detail-tab.is-active, .detail-tab[aria-selected=true] { color: var(--blue-strong); font-weight: 720; }
.detail-tab.is-active::after, .detail-tab[aria-selected=true]::after { position: absolute; inset: auto 10px 0; height: 2px; content: ""; background: var(--blue); border-radius: 2px 2px 0 0; }
.detail-tab:focus-visible { z-index: 1; outline-offset: -3px; }
#activity-panel { min-height: 89px; min-width: 0; }
#activity-panel:focus-visible { outline-offset: -3px; }
#activity-panel .data-table th { border-top: 0; }
.source-status { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; padding: 9px 18px; border-bottom: 1px solid var(--line-subtle); font-size: 11px; color: var(--muted); }
.source-status a { color: inherit; text-underline-offset: 2px; }
.holdings-with-promo {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 224px;
  align-items: start;
  gap: 14px;
  padding-right: 14px;
}
.holdings-with-promo__main { min-width: 0; }
.eagle-pnl { font-variant-numeric: tabular-nums; }
.eagle-promo {
  display: grid;
  gap: 10px;
  margin-block: 12px;
  padding: 11px;
  border: 1px solid #e6dcc7;
  border-radius: 8px;
  background: #fffcf5;
}
.eagle-promo__title { color: #71531f; font-size: 12px; font-weight: 700; line-height: 1.4; }
.eagle-promo__scan { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; }
.eagle-promo__caption { display: grid; gap: 4px; font-size: 12px; }
.eagle-promo__caption span { color: var(--muted); font-size: 11px; }
.eagle-promo__qr {
  padding: 3px;
  border: 1px solid #e6dcc7;
  border-radius: 6px;
  background: #fff;
}
.eagle-promo__qr img { display: block; width: 104px; height: 104px; }
.eagle-promo__entry { background: #b32631; color: #fff; text-decoration: none; }
.eagle-promo__entry:hover { background: #991f29; }
.eagle-messages {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 13px;
  margin-block-start: 13px;
}
.eagle-messages[hidden], .eagle-message-panel [hidden] { display: none; }
.eagle-message-panel { display: flex; flex-direction: column; overflow: hidden; margin-bottom: 0; }
.eagle-message-panel__header { align-items: baseline; border-bottom: 1px solid var(--line-subtle); }
.eagle-message-panel__status { color: var(--muted); font-size: 11px; text-align: right; }
.eagle-message-list {
  min-height: 0;
  max-height: 390px;
  overflow: auto;
  margin: 0;
  padding: 0;
  scrollbar-width: thin;
  scrollbar-color: var(--control-border-hover) transparent;
  list-style: none;
  overscroll-behavior: contain;
}
.eagle-message-list:focus-visible { outline-offset: -3px; }
.eagle-message {
  padding: 12px 18px;
  border-bottom: 1px solid var(--line-subtle);
}
.eagle-message:last-child { border-bottom: 0; }
.eagle-message__meta { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px; font-size: 11px; }
.eagle-message__meta strong { color: var(--blue-strong); overflow-wrap: anywhere; }
.eagle-message__meta time { color: var(--muted); }
.eagle-message__text { margin-top: 5px; color: var(--ink-secondary); font-size: 13px; line-height: 1.65; overflow-wrap: anywhere; white-space: pre-wrap; }
.eagle-message__image-button {
  display: block;
  width: fit-content;
  max-width: 100%;
  margin-top: 8px;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: transparent;
  cursor: zoom-in;
}
.eagle-message__image { display: block; max-width: 100%; max-height: 246px; border-radius: 6px; object-fit: contain; }
.eagle-message-panel__footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 47px;
  margin-top: auto;
  padding: 8px 18px;
  border-top: 1px solid var(--line-subtle);
}
.eagle-message-panel__count { color: var(--muted); font-size: 11px; }
.image-preview {
  --preview-gap: 16px;
  position: fixed;
  inset: 0;
  width: min(1100px, calc(100% - 2 * var(--preview-gap)));
  height: min(900px, calc(100vh - 2 * var(--preview-gap)));
  height: min(900px, calc(100dvh - 2 * var(--preview-gap)));
  max-width: none;
  max-height: none;
  overflow: hidden;
  margin: auto;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
}
.image-preview::backdrop { background: rgb(8 10 12 / 74%); }
body:has(.image-preview[open]) { overflow: hidden; }
.image-preview__panel {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  width: 100%;
  height: 100%;
}
.image-preview__toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 16px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
}
.image-preview__toolbar h2 { color: var(--ink-strong); font-size: 14px; line-height: 1.4; }
.image-preview__actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.image-preview__viewport {
  display: flex;
  min-width: 0;
  min-height: 0;
  overflow: auto;
  background: #141719;
  overscroll-behavior: contain;
  scrollbar-color: #657177 transparent;
}
.image-preview__viewport:focus-visible { outline-offset: -3px; }
.image-preview__image { display: block; flex: none; max-width: 100%; max-height: 100%; margin: auto; object-fit: contain; }
.image-preview__viewport.is-zoomed .image-preview__image { max-width: none; max-height: none; }
.image-preview__error { margin: auto; padding: 16px; color: #d8e0e4; text-align: center; }
.image-preview [hidden] { display: none; }
.noscript { padding: 12px 16px; color: var(--muted); }
.workspace-footer {
  position: fixed;
  inset: auto 0 0;
  z-index: 1;
  display: flex;
  justify-content: center;
  padding: 5px 12px calc(7px + env(safe-area-inset-bottom));
  background: var(--canvas);
}
.workspace-footer__visitors { display: flex; align-items: baseline; gap: 8px; color: var(--muted); font-size: 12px; }
.workspace-footer__visitors dd { color: var(--ink-strong); font-weight: 670; }


:root[data-theme="dark"] .panel { box-shadow: 0 2px 4px rgb(0 0 0 / 12%); }
:root[data-theme="dark"] :is(select, input:not([type=checkbox]):not([type=radio]), .button--secondary) {
  background-color: var(--surface-subtle);
  color: var(--ink-secondary);
}
:root[data-theme="dark"] input::placeholder { color: var(--muted); }
:root[data-theme="dark"] .button--secondary:hover:not(:disabled) {
  background-color: #30383b;
  border-color: var(--control-border-hover);
}
:root[data-theme="dark"] :is(.table-scroll, .detail-tabs) { scrollbar-color: #586569 transparent; }
:root[data-theme="dark"] .data-table th { background: #252a2c; color: #b9c6ca; }
:root[data-theme="dark"] .data-table tbody tr:nth-child(even) { background: #202426; }
:root[data-theme="dark"] .data-table tbody tr:hover { background: #272d30; }
:root[data-theme="dark"] .position-symbol { color: var(--ink-strong); }
:root[data-theme="dark"] .side-tag--short { background: #402930; color: var(--red); }
:root[data-theme="dark"] .side-tag--long { background: #213a31; color: var(--green); }

:root[data-theme="dark"] .strategy-card { border-color: var(--line); background: #202426; }
:root[data-theme="dark"] .strategy-card:hover { border-color: #566566; }
:root[data-theme="dark"] .strategy-card.is-selected {
  border-color: #458e83;
  background: #20332f;
  box-shadow: none;
}
:root[data-theme="dark"] .strategy-avatar { background: #27413d; color: #9adfd3; }
:root[data-theme="dark"] .exchange-tag { color: var(--muted); }
:root[data-theme="dark"] .strategy-metrics :is(strong, dd) { color: var(--ink-secondary); }
:root[data-theme="dark"] .detail-tab { color: var(--muted); }
:root[data-theme="dark"] .detail-tab:hover { background: var(--surface-subtle); color: var(--blue-strong); }
:root[data-theme="dark"] .detail-tab[aria-selected="true"] { color: var(--blue-strong); }
:root[data-theme="dark"] .eagle-promo { border-color: #554733; background: #29261f; }
:root[data-theme="dark"] .eagle-promo__title { color: #efcf91; }

@media (max-width: 1130px) {
  .strategy-card .strategy-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; }
}
@media (max-width: 960px) {
  .strategy-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 800px) {
  .app-header__inner { padding-inline: 17px; }
  .workspace { padding-block-start: 20px; padding-inline: 17px; }
}
@media (max-width: 720px) {
  .holdings-with-promo { grid-template-columns: minmax(0, 1fr); gap: 10px; padding-right: 0; }
  .eagle-promo { width: min(calc(100% - 24px), 280px); margin: 0 12px 12px; }
}
@media (max-width: 640px) {
  .strategy-list { grid-template-columns: 1fr; }
  .eagle-messages { grid-template-columns: minmax(0, 1fr); }
  .eagle-message-list { max-height: 310px; }
  .image-preview { --preview-gap: 8px; }
  .image-preview__toolbar { padding: 8px 10px; }
}
@media (max-width: 560px) {
  .app-header__inner { min-height: 53px; gap: 10px; padding-inline: 13px; }
  .app-header__actions { gap: 7px; }
  .theme-toggle { min-height: 34px; padding-inline: 9px; }
  .app-brand { gap: 7px; font-size: 14px; }
  .app-brand__icon { width: 38px; height: 38px; }
  .workspace { padding-block-start: 15px; padding-inline: 11px; }
  .panel-header { align-items: flex-start; padding: 12px; }
  .strategy-list { padding: 0 11px 11px; }
  .strategy-card .strategy-metrics { gap: 10px 12px; }
  .detail-tab { min-height: 40px; }
  #activity-panel .data-table { min-width: 565px; }
}
@media (max-width: 360px) {
  .theme-toggle [data-theme-label] { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; }
}
