:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --panel: #ffffff;
  --ink: #1f252c;
  --muted: #6c7480;
  --line: #22344d;
  --soft-line: #8fa1b8;
  --brand-blue: #0d315f;
  --brand-black: #101820;
  --red: #d73f3f;
  --green: #17886b;
  --amber: #b7791f;
  --focus: #2563eb;
  --shadow: 0 12px 34px rgba(31, 37, 44, 0.08);
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  min-height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Microsoft YaHei", "PingFang SC", "Segoe UI", Arial, sans-serif;
  font-size: 14px;
  letter-spacing: 0;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.login-view {
  display: grid;
  place-items: center;
  position: relative;
  min-height: 100vh;
  padding: 18px 18px 56px;
}

.login-view[hidden],
.app-shell[hidden] {
  display: none;
}

.login-panel {
  display: grid;
  gap: 14px;
  width: min(380px, 100%);
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.login-panel h1 {
  margin: 0;
  font-size: 24px;
}

.login-panel p {
  margin: 6px 0 0;
  color: var(--muted);
}

.login-panel label {
  display: grid;
  gap: 6px;
  color: var(--muted);
}

.login-panel input {
  width: 100%;
  height: 38px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
}

.login-panel button {
  height: 38px;
  border: 0;
  border-radius: 6px;
  background: var(--ink);
  color: #fff;
  font-weight: 700;
}

.login-message {
  min-height: 18px;
  color: var(--muted);
}

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

.login-version {
  text-align: center;
  color: var(--muted);
  font-size: 12px;
}

.logout-button {
  position: fixed;
  z-index: 20;
  top: 12px;
  right: 12px;
  height: 32px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  box-shadow: 0 8px 20px rgba(31, 37, 44, 0.08);
}

.app-shell {
  display: grid;
  gap: 12px;
  width: min(1440px, 100%);
  min-height: 100vh;
  margin: 0 auto;
  padding: 16px;
}

.site-icp-footer {
  align-self: end;
  padding: 10px 16px 2px;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}

.login-icp-footer {
  position: absolute;
  right: 0;
  bottom: 12px;
  left: 0;
}

.site-icp-footer a {
  color: inherit;
  text-decoration: none;
}

.site-icp-footer a:hover,
.site-icp-footer a:focus-visible {
  color: var(--brand-blue);
  text-decoration: underline;
}

.workspace-view {
  display: grid;
  gap: 12px;
}

.workspace-view[hidden],
.home-view[hidden] {
  display: none;
}

.home-view {
  display: grid;
  align-content: start;
  gap: 20px;
  position: relative;
  isolation: isolate;
  min-height: calc(100vh - 32px);
}

.home-view::before,
.home-view::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
}

.home-view::before {
  background: url("/assets/home-background.jpg") center 48% / cover no-repeat;
}

.home-view::after {
  background: rgba(244, 248, 247, 0.2);
}

.home-view > * {
  position: relative;
  z-index: 1;
}

.home-head {
  display: flex;
  align-items: center;
  gap: 14px;
  width: fit-content;
  padding: 12px 18px;
  border: 1px solid rgba(34, 52, 77, 0.5);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.82);
  box-shadow: 0 12px 34px rgba(10, 24, 32, 0.16);
  backdrop-filter: blur(10px) saturate(1.08);
}

.home-head h1 {
  font-size: 28px;
}

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

.module-card {
  display: grid;
  gap: 10px;
  position: relative;
  overflow: hidden;
  min-height: 150px;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--ink);
  text-decoration: none;
  text-align: left;
  box-shadow: var(--shadow);
}

.home-view .module-card {
  background: rgba(255, 255, 255, 0.82);
  box-shadow: 0 14px 36px rgba(10, 24, 32, 0.18);
  backdrop-filter: blur(10px) saturate(1.08);
}

.app-shell:has(.home-view:not([hidden])) .logout-button {
  background: rgba(255, 255, 255, 0.84);
  backdrop-filter: blur(10px) saturate(1.08);
}

.home-view .module-card::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
  background-image: url("/assets/zc-logo.png");
  background-repeat: no-repeat;
  background-position: right 34px center;
  background-size: 112px auto;
  filter: blur(3px);
  opacity: 0.16;
  transform: scale(1.04);
  pointer-events: none;
}

.home-view .module-card > * {
  position: relative;
  z-index: 1;
}

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

#strategyShowcaseView {
  align-content: start;
  gap: 4px;
  margin-top: -4px;
}

.showcase-picker {
  display: grid;
  grid-template-columns: 1fr;
  align-items: start;
  gap: 3px;
}

#strategyShowcaseView .showcase-picker-card {
  grid-template-columns: 190px minmax(0, 1fr);
  align-items: center;
  align-content: center;
  min-height: 50px;
  height: auto;
  padding: 11px 14px;
  gap: 12px;
  border-radius: 6px;
  box-shadow: none;
}

.showcase-picker-card.is-active {
  border-color: var(--focus);
  background: #f5f8ff;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12), var(--shadow);
}

.showcase-picker .showcase-picker-card strong {
  font-size: 17px;
  line-height: 1.3;
}

.showcase-picker .showcase-picker-card span {
  font-size: 13px;
  line-height: 1.45;
}

.showcase-select-head {
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  padding: 0;
}

.showcase-select-head > div {
  display: flex;
  align-items: center;
  gap: 12px;
}

.showcase-select-head h1 {
  margin: 0;
  font-size: 18px;
}

#strategyShowcaseView .showcase-select-head {
  padding: 2px 0 4px;
}

#strategyShowcaseView .showcase-select-head > div {
  gap: 10px;
  min-height: 40px;
}

#strategyShowcaseView .showcase-select-head .back-home {
  height: 34px;
}

#strategyShowcaseView .showcase-select-head h1 {
  margin: 0;
  font-size: 24px;
  line-height: 1.2;
}

.app-shell.is-showcase-select .logout-button {
  position: absolute;
  top: 18px;
  right: 16px;
  height: 34px;
  box-shadow: none;
}

.showcase-empty-state {
  min-height: 96px;
}

.fixed-showcase-panel[hidden],
.showcase-empty-state[hidden] {
  display: none;
}

:is(#strategySelectView, #marketAnalysisView).strategy-select-view {
  width: min(1320px, 100%);
  margin: 0 auto;
  align-content: start;
}

:is(#strategySelectView, #marketAnalysisView) .strategy-select-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

:is(#strategySelectView, #marketAnalysisView) .strategy-select-head > div {
  display: grid;
  grid-template-columns: auto auto minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  width: 100%;
}

:is(#strategySelectView, #marketAnalysisView) .strategy-select-head h1 {
  margin: 0;
  font-size: 20px;
  line-height: 1.2;
  white-space: nowrap;
}

:is(#strategySelectView, #marketAnalysisView) .strategy-select-head p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

:is(#strategySelectView, #marketAnalysisView) .strategy-select-head .back-home {
  width: 64px;
  height: 32px;
}

:is(#strategySelectView, #marketAnalysisView) .strategy-picker-card {
  grid-template-columns: minmax(0, 1fr) auto;
  column-gap: 18px;
  row-gap: 6px;
  align-items: center;
  min-height: 92px;
  padding: 16px 18px;
}

:is(#strategySelectView, #marketAnalysisView) .strategy-picker-card::after {
  content: "进入";
  grid-column: 2;
  grid-row: 1 / span 2;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 58px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #ffffff;
  color: var(--ink);
  font-size: 13px;
  font-weight: 700;
}

:is(#strategySelectView, #marketAnalysisView) .strategy-picker-card strong {
  grid-column: 1;
  font-size: 19px;
  line-height: 1.25;
}

:is(#strategySelectView, #marketAnalysisView) .strategy-picker-card span {
  grid-column: 1;
  font-size: 14px;
  line-height: 1.45;
}

#marketAnalysisView .market-analysis-card::after {
  grid-row: 1 / span 3;
}

#marketAnalysisView .market-analysis-card .report-data-date {
  display: inline-flex;
  align-items: center;
  width: max-content;
  padding: 4px 8px;
  border: 1px solid rgba(13, 49, 95, 0.2);
  border-radius: 999px;
  background: #f3f7fc;
  color: var(--brand-blue);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.2;
}

.module-card:hover,
.module-card:focus {
  border-color: var(--focus);
  outline: none;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12), var(--shadow);
}

.module-card strong {
  font-size: 22px;
}

.module-card span {
  color: var(--muted);
  line-height: 1.7;
}

.home-strategy-showcase {
  display: grid;
  gap: 12px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.home-strategy-head,
.mini-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.home-strategy-head h2 {
  margin: 4px 0 0;
  font-size: 22px;
}

.home-strategy-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.home-strategy-tags span {
  padding: 6px 10px;
  border: 1px solid var(--soft-line);
  border-radius: 6px;
  background: #fbfcfd;
  color: var(--ink);
  font-size: 12px;
}

.home-strategy-rule {
  margin: 0;
  color: var(--muted);
  line-height: 1.7;
}

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

.home-strategy-summary > div {
  display: grid;
  gap: 6px;
  padding: 12px;
  border: 1px solid var(--soft-line);
  border-radius: 6px;
  background: #fbfcfd;
}

.home-strategy-summary strong {
  font-size: 18px;
}

.home-strategy-chart {
  position: relative;
  height: 300px;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: #fff;
}

.home-strategy-chart canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.home-strategy-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr);
  gap: 12px;
}

.home-next-plan-grid {
  display: grid;
  gap: 12px;
}

.home-mini-panel {
  display: grid;
  gap: 10px;
  min-width: 0;
}

.home-next-plan {
  display: grid;
  gap: 12px;
  padding-top: 4px;
}

.compact-table {
  max-height: 260px;
  overflow: auto;
  box-shadow: none;
}

.compact-table table {
  min-width: 620px;
}

.reason-cell {
  max-width: 360px;
  white-space: normal;
  line-height: 1.6;
}

.topbar,
.quote-strip,
.table-wrap,
.backtest-panel,
.strategy-head,
.strategy-rule,
.strategy-controls,
.strategy-summary {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.topbar {
  position: relative;
  z-index: 2;
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(280px, 420px) auto;
  align-items: end;
  gap: 16px;
  padding: 14px;
}

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

.brand-mark {
  width: 46px;
  height: 46px;
  display: block;
  border-radius: 50%;
  object-fit: contain;
  background: #ffffff;
  box-shadow: 0 0 0 1px var(--line);
}

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

p {
  margin: 4px 0 0;
  color: var(--muted);
}

.search-box {
  position: relative;
}

.search-box label {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 12px;
}

.search-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 44px;
  gap: 8px;
}

.search-row input {
  width: 100%;
  min-width: 0;
  height: 40px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fbfcfd;
  color: var(--ink);
  outline: none;
}

.search-row input:focus {
  border-color: var(--focus);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.14);
}

input,
select {
  width: 100%;
  min-width: 0;
  height: 38px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fbfcfd;
  color: var(--ink);
  outline: none;
}

input:focus,
select:focus {
  border-color: var(--focus);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.14);
}

.search-row button,
.range-button {
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #ffffff;
  color: var(--ink);
}

.search-row button:hover,
.range-button:hover {
  border-color: #aeb7c3;
}

.search-results {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  max-height: 320px;
  overflow: auto;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.result-item {
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  width: 100%;
  min-height: 44px;
  padding: 8px 10px;
  border: 0;
  border-bottom: 1px solid var(--soft-line);
  border-radius: 0;
  background: #ffffff;
  text-align: left;
}

.result-item:hover,
.result-item:focus {
  background: #f3f6fa;
  outline: none;
}

.result-item:last-child {
  border-bottom: 0;
}

.result-code,
.tag {
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.result-name {
  min-width: 0;
  overflow: hidden;
  color: var(--ink);
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

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

.range-box {
  display: grid;
  grid-template-columns: repeat(5, 52px);
  gap: 8px;
}

.range-button.is-active {
  border-color: #24313d;
  background: #24313d;
  color: #ffffff;
}

.quote-strip {
  display: grid;
  grid-template-columns: 1.6fr repeat(3, minmax(110px, 0.8fr)) minmax(220px, 1.4fr);
  gap: 12px;
  padding: 14px;
}

.quote-strip > div {
  min-width: 0;
}

.muted {
  display: block;
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 12px;
}

.quote-strip strong {
  font-size: 18px;
  line-height: 1.2;
}

#industryPath {
  display: block;
  overflow: hidden;
  font-size: 15px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tag {
  margin-left: 8px;
}

.up {
  color: var(--red);
}

.down {
  color: var(--green);
}

.chart-area {
  position: relative;
  height: clamp(560px, 62vh, 720px);
  min-height: 560px;
  overflow: hidden;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

#klineCanvas {
  display: block;
  width: 100%;
  height: 100%;
}

.crosshair-info {
  position: absolute;
  top: 12px;
  left: 12px;
  display: grid;
  gap: 4px;
  max-width: calc(100% - 24px);
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.94);
  color: var(--ink);
  box-shadow: 0 8px 22px rgba(31, 37, 44, 0.1);
  white-space: normal;
}

.empty-state {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 18px;
}

.empty-state[hidden],
.crosshair-info[hidden] {
  display: none;
}

.table-wrap {
  overflow: auto;
  max-height: 240px;
}

.backtest-panel {
  display: grid;
  gap: 14px;
  padding: 14px;
}

.backtest-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 180px;
  gap: 14px;
  align-items: end;
}

.backtest-head h2 {
  margin: 0;
  font-size: 18px;
}

.capital-box label,
.order-form label {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 12px;
}

.order-form {
  display: grid;
  grid-template-columns: minmax(150px, 1.2fr) 150px 130px 120px 170px 110px 145px 110px;
  gap: 10px;
  align-items: end;
}

.order-form button {
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #24313d;
  color: #ffffff;
}

.order-form button:first-of-type {
  background: #ffffff;
  color: var(--ink);
}

.backtest-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(120px, 1fr));
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--soft-line);
  border-radius: 8px;
  background: #fbfcfd;
}

.backtest-summary strong {
  font-size: 18px;
}

.price-preview {
  min-height: 38px;
  padding: 0 10px;
  border: 1px solid var(--soft-line);
  border-radius: 6px;
  background: #fbfcfd;
}

.price-preview .muted {
  margin-bottom: 2px;
}

#btPricePreview {
  display: block;
  overflow: hidden;
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.affordable-shares {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  font-size: 12px;
}

.backtest-chart {
  position: relative;
  height: 320px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

#equityCanvas {
  display: block;
  width: 100%;
  height: 100%;
}

.backtest-message {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--muted);
}

.backtest-message[hidden] {
  display: none;
}

.backtest-orders {
  max-height: 220px;
  box-shadow: none;
}

.remove-order {
  height: 30px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #ffffff;
  color: var(--ink);
}

.strategy-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  align-items: end;
  padding: 16px;
}

.strategy-head h1 {
  margin-top: 10px;
}

.strategy-head button,
.back-home {
  height: 38px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #24313d;
  color: #ffffff;
}

.back-home {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 72px;
  padding: 0;
  background: #ffffff;
  color: var(--ink);
  text-decoration: none;
}

.strategy-head-actions {
  display: flex;
  gap: 8px;
  justify-content: end;
}

.data-update-panel {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  align-items: center;
  gap: 8px;
  max-width: 520px;
}

.data-update-panel button {
  min-width: 120px;
}

.data-update-spinner {
  width: 16px;
  height: 16px;
  border: 2px solid #d9dee5;
  border-top-color: var(--focus);
  border-radius: 50%;
  animation: data-update-spin 0.8s linear infinite;
}

.data-update-spinner[hidden] {
  display: none;
}

@keyframes data-update-spin {
  to {
    transform: rotate(360deg);
  }
}

.data-update-panel .muted {
  font-size: 12px;
}

.retail-observer-days {
  display: grid;
  gap: 12px;
}

.retail-observer-day {
  border-top: 1px solid var(--line);
  padding-top: 12px;
}

.retail-observer-day:first-child {
  border-top: 0;
  padding-top: 0;
}

.retail-observer-day-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.retail-observer-stock {
  border: 0;
  background: transparent;
  color: var(--focus);
  cursor: pointer;
  font-weight: 700;
  padding: 0;
  text-align: left;
}

.retail-observer-stock:hover {
  text-decoration: underline;
}

.institution-observer-stock {
  border: 0;
  background: transparent;
  color: #c63742;
  cursor: pointer;
  font-weight: 700;
  padding: 0;
  text-align: left;
}

.institution-observer-stock:hover {
  text-decoration: underline;
}

.observer-group-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin: 10px 0 6px;
  color: var(--muted);
  font-size: 12px;
}

.observer-group-head:first-of-type {
  margin-top: 0;
}

.strategy-rule {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  padding: 14px;
}

.strategy-rule > div {
  min-width: 0;
  padding-right: 8px;
}

.strategy-rule strong {
  display: block;
  margin-bottom: 6px;
  font-size: 16px;
}

.strategy-rule p {
  line-height: 1.6;
}

.strategy-controls {
  display: grid;
  grid-template-columns: minmax(210px, 1fr) minmax(130px, 180px) minmax(140px, 220px);
  gap: 10px;
  padding: 14px;
}

.rolling-controls {
  grid-template-columns: minmax(118px, 0.7fr) minmax(108px, 0.6fr) minmax(210px, 1fr) minmax(260px, 1.25fr);
  align-items: end;
}

.rolling-controls > div:nth-child(1) {
  order: 1;
}

.rolling-controls > div:nth-child(2) {
  order: 2;
}

.rolling-controls .profit-mode-control {
  order: 3;
}

.rolling-controls .profit-pair-control {
  order: 4;
}

.strategy-hidden-control {
  display: none;
}

.strategy-controls label,
.profit-mode-control legend {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 12px;
}

.profit-mode-control {
  min-width: 0;
  height: 38px;
  display: flex;
  gap: 8px;
  align-items: center;
  margin: 0;
  padding: 0;
  border: 0;
}

.profit-mode-control legend {
  float: left;
  width: 100%;
}

.profit-mode-control label {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 32px;
  margin: 0;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #ffffff;
  color: var(--ink);
  white-space: nowrap;
}

.profit-mode-control input {
  width: auto;
  margin: 0;
}

.rolling-switch-row {
  order: 5;
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.strategy-controls .rolling-switch-control {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-width: 180px;
  height: 38px;
  margin-bottom: 0;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #ffffff;
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.strategy-controls .rolling-switch-control input {
  width: auto;
  margin: 0;
}

.rolling-switch-help {
  flex-basis: 100%;
  margin: -2px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.profit-pair-control {
  display: grid;
  grid-template-columns: repeat(2, minmax(110px, 1fr));
  gap: 8px;
}

.profit-pair-control .is-disabled label {
  color: #aab4bf;
}

.profit-pair-control input:disabled {
  background: #f2f4f6;
  color: #aab4bf;
}

.trade-date-picker {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 58px;
  gap: 8px;
}

.trade-date-picker input[readonly] {
  cursor: pointer;
  background: #fbfcfd;
}

.calendar-toggle {
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #ffffff;
  color: var(--ink);
}

.trade-calendar {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  z-index: 5;
  width: 292px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.trade-calendar[hidden] {
  display: none;
}

.trade-calendar-head,
.trade-calendar-weekdays,
.trade-calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}

.trade-calendar-head {
  grid-template-columns: 34px 1fr 34px;
  align-items: center;
  margin-bottom: 8px;
}

.trade-calendar-head strong {
  text-align: center;
}

.trade-calendar-year-row {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  gap: 8px;
  align-items: center;
  margin-bottom: 8px;
}

.trade-calendar-year-row label {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.trade-calendar-year-row select {
  height: 32px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #ffffff;
  color: var(--ink);
}

.trade-calendar-head button,
.calendar-day {
  height: 32px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #ffffff;
  color: var(--ink);
}

.trade-calendar-head button:disabled {
  cursor: not-allowed;
  opacity: 0.42;
}

.trade-calendar-weekdays {
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}

.calendar-empty {
  height: 32px;
}

.calendar-day:hover:not(:disabled) {
  border-color: var(--focus);
}

.calendar-day.is-active {
  border-color: #24313d;
  background: #24313d;
  color: #ffffff;
}

.calendar-day.is-disabled {
  cursor: not-allowed;
  background: #eef1f4;
  color: #a5adb8;
  text-decoration: line-through;
}

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

.strategy-summary strong {
  font-size: 18px;
}

.summary-action-button {
  width: fit-content;
  margin-top: 8px;
  padding: 5px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #ffffff;
  color: var(--ink);
  font-size: 12px;
}

.summary-action-button:disabled {
  cursor: not-allowed;
  color: var(--muted);
  background: #eef1f4;
}

.strategy-note {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 10px 14px;
  border: 1px solid var(--soft-line);
  border-radius: 8px;
  background: #fbfcfd;
  color: var(--muted);
}

.strategy-note strong {
  color: var(--ink);
}

.strategy-table {
  max-height: 360px;
}

.trade-detail-table {
  max-height: 420px;
}

.strategy-industry-detail,
.strategy-stock-detail,
.rolling-chart-panel {
  display: grid;
  gap: 10px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.strategy-detail-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 12px;
}

.strategy-detail-head strong {
  font-size: 18px;
}

.strategy-industry-chart {
  position: relative;
  height: 260px;
  overflow: hidden;
  border: 1px solid var(--soft-line);
  border-radius: 8px;
  background: #ffffff;
}

.rolling-chart {
  position: relative;
  height: 360px;
  overflow: hidden;
  border: 1px solid var(--soft-line);
  border-radius: 8px;
  background: #ffffff;
}

.rolling-progress {
  display: grid;
  grid-template-columns: minmax(140px, 1fr) auto;
  gap: 10px;
  align-items: center;
  color: var(--muted);
  font-size: 12px;
}

.rolling-progress[hidden] {
  display: none;
}

.rolling-progress-track {
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: #e8edf2;
}

#rollingProgressBar {
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: #2563eb;
  transition: width 0.25s ease;
}

.sell-reason-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding-top: 10px;
}

.sell-reason-summary span {
  display: inline-flex;
  gap: 6px;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #ffffff;
  color: var(--muted);
  font-size: 12px;
}

.sell-reason-summary strong {
  color: var(--ink);
}

.table-headline {
  padding: 10px 12px;
}

#rollingEquityCanvas {
  display: block;
  width: 100%;
  height: 100%;
}

#strategyIndustryCanvas {
  display: block;
  width: 100%;
  height: 100%;
}

.strategy-industry-bars {
  max-height: 220px;
  box-shadow: none;
}

.strategy-return-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(120px, 1fr));
  gap: 10px;
  padding: 10px;
  border: 1px solid var(--soft-line);
  border-radius: 8px;
  background: #fbfcfd;
}

.strategy-return-strip strong {
  font-size: 17px;
}

.strategy-signal-charts {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 12px;
}

.strategy-signal-charts > div {
  min-width: 0;
  height: 300px;
  overflow: hidden;
  border: 1px solid var(--soft-line);
  border-radius: 8px;
  background: #ffffff;
}

.mini-chart-title {
  height: 30px;
  padding: 8px 10px 0;
  color: var(--muted);
  font-size: 12px;
}

#strategyStockCanvas,
#strategyStockIndustryCanvas,
#rollingStockCanvas,
#rollingStockIndustryCanvas {
  display: block;
  width: 100%;
  height: calc(100% - 30px);
}

.industry-link {
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--ink);
  font-weight: 700;
}

.industry-link:hover,
.industry-link:focus {
  color: var(--focus);
  outline: none;
}

.industry-link.is-active {
  color: var(--focus);
}

.is-muted-row {
  background: #fbfcfd;
  color: var(--muted);
}

.reject-reason {
  display: inline-block;
  margin-left: 8px;
  color: var(--amber);
  font-size: 12px;
}

.stock-link {
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--ink);
  font-weight: 700;
}

.stock-link span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 400;
}

#rollingRecordRows tr {
  cursor: help;
}

#rollingRecordRows tr:hover {
  background: #f6f8fb;
}

.rebalance-tooltip {
  position: fixed;
  z-index: 20;
  padding: 7px 9px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.96);
  color: var(--ink);
  box-shadow: 0 8px 22px rgba(31, 37, 44, 0.12);
  font-size: 12px;
  pointer-events: none;
  white-space: nowrap;
}

.rebalance-tooltip[hidden] {
  display: none;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 680px;
}

th,
td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--soft-line);
  text-align: right;
  white-space: nowrap;
}

th:first-child,
td:first-child {
  text-align: left;
}

th {
  position: sticky;
  top: 0;
  background: #fbfcfd;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

@media (max-width: 860px) {
  .app-shell {
    grid-template-rows: auto auto auto auto;
    padding: 10px;
  }

  .topbar {
    grid-template-columns: 1fr;
    align-items: stretch;
  }

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

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

  .backtest-head,
  .backtest-summary,
  .order-form,
  .strategy-rule,
  .strategy-controls,
  .strategy-summary,
  .strategy-return-strip,
  .home-strategy-summary,
  .home-strategy-grid,
  .module-grid,
  .strategy-picker-grid {
    grid-template-columns: 1fr 1fr;
  }

  .rolling-switch-row {
    grid-column: 1 / -1;
  }
}

@media (max-width: 520px) {
  .quote-strip {
    grid-template-columns: 1fr;
  }

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

  h1 {
    font-size: 18px;
  }

  .chart-area {
    height: 520px;
    min-height: 500px;
  }

  .backtest-head,
  .backtest-summary,
  .order-form,
  .strategy-head,
  .strategy-rule,
  .strategy-controls,
  .strategy-summary,
  .strategy-return-strip,
  .home-strategy-summary,
  .home-strategy-grid,
  .module-grid,
  .strategy-picker-grid {
    grid-template-columns: 1fr;
  }

  .showcase-picker-card {
    grid-template-columns: 1fr;
    align-items: start;
  }
}
