:root {
  --bg: #f4f6f8;
  --panel: #ffffff;
  --panel-soft: #f8fafc;
  --line: #d9e1ea;
  --line-strong: #b8c6d4;
  --ink: #17212b;
  --muted: #667789;
  --blue: #1f5d8c;
  --blue-dark: #163b5c;
  --red: #b94a48;
  --loss-blue: #1f5d8c;
  --simulated-card: rgba(204, 204, 204, 0.46);
  --real-card: rgba(198, 226, 255, 0.58);
  --sidebar: #17212b;
  --sidebar-2: #213244;
  --sidebar-text: #dce6f1;
  --shadow: 0 18px 45px rgba(23, 33, 43, 0.08);
  --card-shadow: 12px 12px 24px rgba(23, 33, 43, 0.26);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--ink);
  background: var(--bg);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

button,
input,
select {
  font: inherit;
}

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

.sidebar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: linear-gradient(180deg, var(--sidebar), #101820);
  color: var(--sidebar-text);
  padding: 16px 24px;
  overflow: visible;
  box-shadow: 0 10px 24px rgba(16, 24, 32, 0.16);
}

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

.brand-mark {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border: 1px solid rgba(255, 255, 255, 0.26);
  background: #20384f;
  color: #ffffff;
  font-weight: 700;
}

.brand-title {
  font-size: 20px;
  font-weight: 700;
}

.brand-subtitle {
  margin-top: 2px;
  color: #9fb0c2;
  font-size: 12px;
}

.strategy-nav {
  display: flex;
  align-items: stretch;
  gap: 10px;
  overflow-x: auto;
  padding-bottom: 2px;
}

.nav-section {
  margin-bottom: 0;
}

.nav-section-title {
  width: 190px;
  min-width: 170px;
  min-height: 74px;
  margin: 0;
  border: 1px solid rgba(143, 162, 182, 0.18);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.075);
  color: #dce6f1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 14px 12px;
  text-align: left;
  cursor: pointer;
  box-shadow: 7px 7px 16px rgba(0, 0, 0, 0.14);
  backdrop-filter: blur(8px);
}

.nav-section-title.active,
.nav-section-title[aria-pressed="true"] {
  background: rgba(255, 255, 255, 0.105);
  border-color: rgba(108, 160, 207, 0.38);
}

.nav-section-title:hover {
  background: rgba(255, 255, 255, 0.13);
}

.nav-section-copy {
  min-width: 0;
  display: grid;
  gap: 7px;
}

.nav-section-heading {
  color: #eef5fb;
  font-size: 15px;
  font-weight: 850;
  line-height: 1.15;
}

.nav-section-desc {
  color: rgba(220, 230, 241, 0.72);
  font-size: 12px;
  font-weight: 600;
  line-height: 1.35;
}

.nav-chevron {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  color: rgba(220, 230, 241, 0.76);
  border: 1px solid rgba(220, 230, 241, 0.18);
  background: rgba(0, 0, 0, 0.12);
  font-size: 15px;
  font-weight: 700;
}

.nav-section-items {
  display: grid;
  gap: 0;
}

.nav-section-items.collapsed {
  display: none;
}

.nav-item {
  width: 100%;
  min-height: 42px;
  border: 0;
  border-left: 3px solid transparent;
  background: transparent;
  color: var(--sidebar-text);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 9px 10px;
  text-align: left;
  cursor: pointer;
}

.nav-item:hover {
  background: rgba(255, 255, 255, 0.07);
}

.nav-item.active {
  background: var(--sidebar-2);
  border-left-color: #6ca0cf;
}

.nav-name {
  font-size: 13px;
  font-weight: 600;
}

.status-pill {
  flex: 0 0 auto;
  padding: 3px 7px;
  color: #8fa2b6;
  border: 1px solid rgba(255, 255, 255, 0.12);
  font-size: 11px;
}

.status-pill.simulated {
  color: #33475b;
  background: rgba(204, 204, 204, 0.7);
  border-color: rgba(204, 204, 204, 0.9);
}

.status-pill.real {
  color: #145a45;
  background: rgba(127, 255, 212, 0.72);
  border-color: rgba(70, 190, 150, 0.58);
}

.nav-note {
  flex: 0 0 auto;
  color: #8fa2b6;
  font-size: 11px;
}

.main {
  min-width: 0;
  padding: 24px;
}

.site-disclaimer {
  margin-top: 24px;
  padding: 14px 16px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
}

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 20px;
}

.eyebrow {
  color: var(--blue);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

h1 {
  margin: 4px 0 0;
  font-size: 28px;
  line-height: 1.2;
}

.page-description {
  min-height: 20px;
  margin-top: 7px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.topbar-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
}

.ghost-button,
.primary-button,
.segmented button {
  min-height: 34px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  padding: 6px 12px;
  cursor: pointer;
}

.ghost-button:hover,
.primary-button:hover,
.segmented button:hover {
  border-color: var(--line-strong);
}

.primary-button {
  background: var(--blue-dark);
  border-color: var(--blue-dark);
  color: #ffffff;
  font-weight: 800;
  box-shadow: 7px 7px 16px rgba(23, 33, 43, 0.14);
}

.primary-button:hover {
  background: var(--blue);
  border-color: var(--blue);
}

.ghost-button.back-button {
  background: var(--blue-dark);
  border-color: var(--blue-dark);
  color: #ffffff;
  font-weight: 800;
  box-shadow: 8px 8px 18px rgba(23, 33, 43, 0.16);
}

.ghost-button.back-button:hover {
  background: var(--blue);
  border-color: var(--blue);
}

.segmented {
  display: inline-flex;
  border: 1px solid var(--line);
  background: var(--panel);
}

.segmented button {
  border: 0;
  border-right: 1px solid var(--line);
  background: transparent;
  padding-inline: 10px;
}

.segmented button:last-child {
  border-right: 0;
}

.segmented button.active {
  background: var(--blue-dark);
  color: #ffffff;
}

.labeled-segmented {
  background: rgba(31, 93, 140, 0.05);
  border-color: rgba(31, 93, 140, 0.2);
}

.data-status {
  padding: 8px 11px;
  background: var(--panel-soft);
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
}

.content {
  display: grid;
  gap: 18px;
}

.overview-toolbar {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 10px;
}

.overview-sort {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.overview-sort select {
  min-height: 34px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  padding: 6px 30px 6px 10px;
}

.overview-sort-direction {
  min-width: 58px;
}

.overview-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(180px, 1fr));
  gap: 12px;
}

.strategy-card,
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
}

.strategy-card {
  min-height: 150px;
  padding: 14px;
  border-radius: 14px;
  cursor: pointer;
  backdrop-filter: blur(10px);
  box-shadow: var(--card-shadow);
}

.panel {
  box-shadow: var(--shadow);
}

.strategy-card.placeholder {
  cursor: pointer;
  background: rgba(248, 250, 252, 0.72);
}

.strategy-card.live-card.simulated {
  background: var(--simulated-card);
}

.strategy-card.live-card.real {
  background: var(--real-card);
}

.card-head,
.panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}

.card-title,
.panel-title {
  font-size: 17px;
  font-weight: 750;
}

.card-meta {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(120px, 1fr));
  gap: 12px;
}

.metric {
  background: var(--panel);
  border: 1px solid var(--line);
  padding: 12px;
}

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

.metric-value {
  margin-top: 7px;
  font-size: 22px;
  font-weight: 760;
}

.metric-value.positive {
  color: var(--red);
}

.metric-value.negative {
  color: var(--loss-blue);
}

.card-metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin-top: 16px;
}

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

.mini-value {
  margin-top: 4px;
  font-size: 18px;
  font-weight: 760;
}

.mini-value.primary {
  font-size: 24px;
  line-height: 1.05;
}

.mini-value.positive {
  color: var(--red);
}

.mini-value.negative {
  color: var(--loss-blue);
}

.detail-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(300px, 0.75fr);
  gap: 18px;
}

.rebalance-helper {
  display: grid;
  gap: 14px;
}

.helper-form {
  display: flex;
  align-items: end;
  gap: 12px;
  flex-wrap: wrap;
}

.helper-field {
  display: grid;
  gap: 6px;
  min-width: 240px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.helper-field input,
.rebalance-shares-input {
  min-height: 34px;
  width: 100%;
  border: 1px solid var(--line);
  background: #ffffff;
  color: var(--ink);
  padding: 6px 9px;
}

.rebalance-shares-input {
  width: 120px;
}

.helper-static-cell {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.helper-input-table {
  max-height: 260px;
}

.helper-result {
  display: grid;
  gap: 10px;
}

.combo-allocation-panel {
  overflow: hidden;
}

.combo-allocation-grid {
  display: grid;
  gap: 18px;
  margin-top: 14px;
}

.combo-allocation-block {
  display: grid;
  gap: 12px;
}

.combo-allocation-head {
  color: var(--ink);
  font-size: 13px;
  font-weight: 800;
}

.combo-allocation {
  display: grid;
  grid-template-columns: 150px minmax(0, 1fr);
  align-items: center;
  gap: 16px;
}

.allocation-donut {
  position: relative;
  width: 140px;
  aspect-ratio: 1;
  border-radius: 50%;
  box-shadow: inset 0 0 0 1px rgba(23, 33, 43, 0.08);
}

.allocation-donut::after {
  content: "";
  position: absolute;
  inset: 21px;
  border-radius: 50%;
  background: var(--panel);
  box-shadow: inset 0 0 0 1px var(--line);
}

.allocation-donut-core {
  position: absolute;
  inset: 33px;
  z-index: 1;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-align: center;
}

.allocation-donut-core span,
.allocation-donut-core strong {
  display: block;
  line-height: 1.1;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
}

.allocation-donut-core strong {
  color: var(--ink);
  font-size: 18px;
}

.allocation-list {
  display: grid;
  gap: 10px;
  min-width: 0;
}

.allocation-row {
  display: grid;
  grid-template-columns: minmax(92px, 1.05fr) minmax(64px, 0.8fr) 54px;
  align-items: center;
  gap: 8px;
  min-height: 22px;
  color: var(--ink);
  font-size: 12px;
}

.allocation-label {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
  font-weight: 750;
}

.allocation-label span:last-child {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.allocation-dot {
  flex: 0 0 auto;
  width: 9px;
  height: 9px;
  border-radius: 50%;
}

.allocation-bar-track {
  height: 8px;
  border-radius: 999px;
  background: #e7edf3;
  overflow: hidden;
}

.allocation-bar-fill {
  height: 100%;
  min-width: 0;
  border-radius: inherit;
}

.helper-summary,
.helper-message {
  border: 1px solid rgba(31, 93, 140, 0.18);
  background: rgba(238, 243, 247, 0.68);
  color: #33475b;
  padding: 9px 10px;
  font-size: 12px;
  font-weight: 700;
}

.helper-message.error {
  border-color: rgba(185, 74, 72, 0.25);
  background: rgba(185, 74, 72, 0.08);
  color: #8b3432;
}

.helper-subtitle {
  margin-top: 4px;
  color: #33475b;
  font-size: 13px;
  font-weight: 820;
}

.signal-detail-table {
  max-height: 300px;
}

.panel {
  padding: 16px;
}

.panel + .panel {
  margin-top: 18px;
}

.chart-frame {
  position: relative;
  margin-top: 14px;
  width: 100%;
  height: 340px;
  border: 1px solid var(--line);
  background: #fbfcfe;
}

.chart-frame.small {
  height: 240px;
}

.nav-chart-stack {
  position: relative;
}

.linked-crosshair {
  position: absolute;
  display: none;
  width: 0;
  border-left: 1px dashed rgba(102, 119, 137, 0.7);
  pointer-events: none;
  z-index: 4;
}

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

.chart-frame.lower-indicator-frame {
  height: 160px;
  margin-top: 8px;
}

svg {
  display: block;
  width: 100%;
  height: 100%;
}

.indicator-overlay {
  position: absolute;
  top: 10px;
  left: 10px;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 6px;
}

.indicator-button {
  min-width: 42px;
  min-height: 26px;
  border: 1px solid rgba(31, 93, 140, 0.22);
  background: rgba(255, 255, 255, 0.78);
  color: #33475b;
  font-size: 11px;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 4px 4px 12px rgba(23, 33, 43, 0.1);
  backdrop-filter: blur(8px);
}

.indicator-button:hover {
  border-color: rgba(31, 93, 140, 0.42);
  background: rgba(238, 243, 247, 0.9);
}

.indicator-button.active {
  color: #ffffff;
  background: rgba(31, 93, 140, 0.86);
  border-color: rgba(31, 93, 140, 0.9);
}

.indicator-menu {
  display: none;
  min-width: 92px;
  border: 1px solid rgba(31, 93, 140, 0.18);
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 6px 8px 18px rgba(23, 33, 43, 0.16);
  backdrop-filter: blur(8px);
  overflow: hidden;
}

.indicator-menu.open {
  display: grid;
}

.indicator-option {
  min-height: 28px;
  border: 0;
  border-bottom: 1px solid rgba(184, 198, 212, 0.45);
  background: transparent;
  color: #33475b;
  padding: 5px 10px;
  font-size: 12px;
  font-weight: 700;
  text-align: left;
  cursor: pointer;
}

.indicator-option:last-child {
  border-bottom: 0;
}

.indicator-option:hover,
.indicator-option.active {
  color: #ffffff;
  background: rgba(31, 93, 140, 0.82);
}

.table-wrap {
  margin-top: 14px;
  overflow: auto;
  border: 1px solid var(--line);
  max-height: 360px;
}

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

th {
  position: sticky;
  top: 0;
  background: #eef3f7;
  color: #33475b;
  text-align: left;
  z-index: 1;
}

th,
td {
  padding: 9px 10px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}

td.positive {
  color: var(--red);
  font-weight: 760;
}

td.negative {
  color: var(--loss-blue);
  font-weight: 760;
}

td.holding-alert {
  color: #8b3432;
  background: rgba(185, 74, 72, 0.08);
  font-weight: 760;
}

.heatmap {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 6px;
  margin-top: 14px;
}

.heat-cell {
  min-height: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #ffffff;
  font-size: 11px;
  font-weight: 700;
}

.empty-state {
  padding: 60px 22px;
  text-align: center;
  border: 1px dashed var(--line-strong);
  background: var(--panel-soft);
  color: var(--muted);
}

.empty-state strong {
  display: block;
  margin-bottom: 8px;
  color: var(--ink);
  font-size: 18px;
}

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

@media (max-width: 1100px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
  }

  .detail-layout,
  .metric-grid {
    grid-template-columns: 1fr;
  }

  .combo-allocation {
    grid-template-columns: 1fr;
  }

  .allocation-donut {
    justify-self: center;
  }

  .combo-allocation-grid {
    gap: 22px;
  }
}

@media (max-width: 860px) {
  .overview-grid {
    grid-template-columns: repeat(2, minmax(220px, 1fr));
  }
}

@media (max-width: 640px) {
  .overview-grid {
    grid-template-columns: 1fr;
  }
}
