:root {
  --bg: #f3f4f1;
  --surface: #ffffff;
  --surface-muted: #f7f8f5;
  --ink: #171a18;
  --ink-soft: #545b56;
  --ink-faint: #858c87;
  --line: #dfe3de;
  --line-strong: #cbd1cb;
  --red: #c83e43;
  --red-soft: #f9e7e6;
  --green: #16835a;
  --green-soft: #e3f2eb;
  --amber: #a56c12;
  --amber-soft: #f7eedb;
  --charcoal: #171b19;
  --charcoal-soft: #232825;
  --shadow: 0 10px 30px rgba(23, 26, 24, 0.08);
  --header-height: 68px;
}

* {
  box-sizing: border-box;
  letter-spacing: 0;
}

html {
  min-width: 320px;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
}

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

button {
  cursor: pointer;
}

button:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 3px solid rgba(22, 131, 90, 0.2);
  outline-offset: 2px;
}

[hidden] {
  display: none !important;
}

.login-screen {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 32px 20px;
  background-color: #ecefeb;
  background-image:
    linear-gradient(rgba(23, 26, 24, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(23, 26, 24, 0.035) 1px, transparent 1px);
  background-size: 32px 32px;
}

.login-panel {
  width: min(430px, 100%);
  padding: 34px;
  border: 1px solid var(--line-strong);
  border-top: 4px solid var(--ink);
  border-radius: 6px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.login-brand,
.header-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  display: grid;
  width: 42px;
  height: 42px;
  flex: 0 0 42px;
  place-items: center;
  border-radius: 4px;
  background: var(--ink);
  color: #fff;
  font-family: Georgia, "Songti SC", serif;
  font-size: 22px;
  font-weight: 700;
}

.brand-mark.small {
  width: 34px;
  height: 34px;
  flex-basis: 34px;
  font-size: 18px;
}

.login-brand strong,
.header-brand strong {
  display: block;
  font-size: 15px;
}

.login-brand span,
.header-brand span {
  display: block;
  margin-top: 2px;
  color: var(--ink-faint);
  font-size: 11px;
}

.login-copy {
  margin: 52px 0 28px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--green);
  font-size: 11px;
  font-weight: 750;
  text-transform: uppercase;
}

.login-copy h1,
.view-heading h1 {
  margin: 0;
  font-family: Georgia, "Songti SC", serif;
  font-size: 30px;
  line-height: 1.25;
}

.login-copy > p:last-child {
  margin: 10px 0 0;
  color: var(--ink-soft);
  line-height: 1.7;
}

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

.login-form label,
.date-control,
.select-control {
  display: grid;
  gap: 7px;
}

.login-form label > span,
.date-control > span,
.select-control > span {
  color: var(--ink-soft);
  font-size: 12px;
  font-weight: 650;
}

.login-form input,
.date-control input,
.select-control select {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  background: var(--surface);
  padding: 0 12px;
  transition: border-color 160ms ease, box-shadow 160ms ease;
}

.login-form input:hover,
.date-control input:hover,
.select-control select:hover {
  border-color: var(--ink-faint);
}

.login-form input:focus,
.date-control input:focus,
.select-control select:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(22, 131, 90, 0.1);
  outline: 0;
}

.primary-button,
.secondary-button,
.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
}

.primary-button {
  min-height: 46px;
  justify-content: space-between;
  margin-top: 4px;
  border-radius: 4px;
  background: var(--ink);
  color: #fff;
  padding: 0 16px;
  font-weight: 700;
  transition: background 160ms ease, transform 160ms ease;
}

.primary-button:hover {
  background: #303531;
}

.primary-button:active,
.secondary-button:active,
.icon-button:active {
  transform: translateY(1px);
}

.primary-button:disabled {
  cursor: wait;
  opacity: 0.7;
}

.form-error {
  margin: -4px 0 0;
  border-left: 3px solid var(--red);
  background: var(--red-soft);
  color: #9d2d31;
  padding: 9px 11px;
  font-size: 13px;
  line-height: 1.5;
}

.login-foot {
  margin: 22px 0 0;
  color: var(--ink-faint);
  font-size: 11px;
  text-align: center;
}

.app-shell {
  min-height: 100vh;
}

.app-header {
  position: sticky;
  z-index: 40;
  top: 0;
  display: grid;
  grid-template-columns: auto minmax(500px, 1fr) auto;
  align-items: center;
  min-height: var(--header-height);
  border-bottom: 1px solid #2d322f;
  background: var(--charcoal);
  color: #fff;
  padding: 0 22px;
}

.header-brand {
  min-width: 190px;
}

.header-brand .brand-mark {
  background: #f0f2ee;
  color: var(--ink);
}

.header-brand span {
  color: #8f9892;
}

.primary-nav {
  display: flex;
  align-items: stretch;
  justify-content: center;
  align-self: stretch;
  gap: 2px;
}

.nav-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 96px;
  border: 0;
  background: transparent;
  color: #aeb6b0;
  padding: 0 13px;
  font-size: 13px;
  font-weight: 650;
  white-space: nowrap;
}

.nav-item::after {
  position: absolute;
  right: 13px;
  bottom: 0;
  left: 13px;
  height: 3px;
  background: transparent;
  content: "";
}

.nav-item:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.04);
}

.nav-item.is-active {
  color: #fff;
}

.nav-item.is-active::after {
  background: #e44c50;
}

.nav-glyph {
  display: grid;
  width: 21px;
  height: 21px;
  place-items: center;
  border: 1px solid #4a514d;
  border-radius: 3px;
  color: #d6dbd7;
  font-size: 11px;
}

.header-meta {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  min-width: 318px;
  gap: 18px;
}

.trade-meta,
.sync-meta {
  display: grid;
  grid-template-columns: auto auto;
  align-items: center;
  gap: 2px 8px;
  font-size: 12px;
}

.trade-meta span,
.sync-meta time {
  color: #8f9892;
  font-size: 10px;
}

.trade-meta strong {
  grid-row: 2;
  grid-column: 1 / -1;
  color: #eef1ef;
  font-size: 13px;
}

.sync-meta time {
  grid-row: 2;
  grid-column: 2;
}

.sync-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #d69d35;
  box-shadow: 0 0 0 3px rgba(214, 157, 53, 0.13);
}

.sync-dot.is-online {
  background: #38b77e;
  box-shadow: 0 0 0 3px rgba(56, 183, 126, 0.13);
}

.sync-dot.is-stale,
.sync-dot.is-offline {
  background: #df5a5e;
  box-shadow: 0 0 0 3px rgba(223, 90, 94, 0.13);
}

.icon-button {
  width: 36px;
  height: 36px;
  flex: 0 0 36px;
  border: 1px solid #3a403c;
  border-radius: 4px;
  background: transparent;
  color: #c6ccc7;
  font-size: 18px;
}

.icon-button:hover {
  border-color: #59615c;
  background: rgba(255, 255, 255, 0.05);
  color: #fff;
}

.workspace {
  width: 100%;
}

.view {
  width: min(1560px, 100%);
  min-height: calc(100vh - var(--header-height));
  margin: 0 auto;
  padding: 30px clamp(18px, 3vw, 42px) 48px;
}

.view.bubble-view {
  width: 100%;
  height: calc(100vh - var(--header-height));
  min-height: 650px;
  background: var(--charcoal);
  color: #fff;
  padding: 22px 26px 26px;
}

.view-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 24px;
}

.view-subtitle {
  margin: 7px 0 0;
  color: var(--ink-soft);
  line-height: 1.5;
}

.heading-actions {
  display: flex;
  align-items: flex-end;
  justify-content: flex-end;
  gap: 10px;
}

.date-control {
  width: 154px;
}

.select-control {
  width: 198px;
}

.date-control input,
.select-control select {
  min-height: 36px;
  padding: 0 9px;
  font-size: 13px;
}

.secondary-button {
  min-height: 36px;
  gap: 7px;
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  background: var(--surface);
  padding: 0 12px;
  color: var(--ink-soft);
  font-size: 13px;
  font-weight: 650;
}

.secondary-button:hover {
  border-color: var(--ink-faint);
  color: var(--ink);
}

.secondary-button.is-loading,
.icon-button.is-loading {
  pointer-events: none;
  opacity: 0.65;
}

.secondary-button.is-loading::first-letter,
.icon-button.is-loading::first-letter {
  animation: spin 700ms linear infinite;
}

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

.segmented {
  display: inline-flex;
  min-height: 36px;
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  background: var(--surface);
  padding: 3px;
}

.segmented button {
  min-width: 60px;
  border: 0;
  border-radius: 3px;
  background: transparent;
  color: var(--ink-soft);
  padding: 0 10px;
  font-size: 12px;
  font-weight: 650;
}

.segmented button:hover {
  color: var(--ink);
}

.segmented button.is-active {
  background: var(--ink);
  color: #fff;
}

.metric-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-bottom: 22px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
}

.metric-cell {
  position: relative;
  min-height: 110px;
  padding: 20px 22px;
}

.metric-cell + .metric-cell {
  border-left: 1px solid var(--line);
}

.metric-cell > span {
  display: block;
  margin-bottom: 9px;
  color: var(--ink-soft);
  font-size: 12px;
  font-weight: 650;
}

.metric-cell strong {
  display: inline-block;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 29px;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.metric-cell > small {
  display: inline-block;
  margin-left: 8px;
  color: var(--ink-faint);
  font-size: 11px;
}

.metric-strip.compact .metric-cell {
  min-height: 96px;
  padding-top: 18px;
  padding-bottom: 18px;
}

.positive-text {
  color: var(--red) !important;
}

.negative-text {
  color: var(--green) !important;
}

.neutral-text {
  color: var(--ink-soft) !important;
}

.data-section {
  border-top: 2px solid var(--ink);
  background: var(--surface);
}

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 68px;
  border-bottom: 1px solid var(--line);
  padding: 12px 18px;
}

.section-heading h2,
.ranking-head h2,
.market-days-head h2 {
  margin: 0;
  font-size: 15px;
}

.section-heading p {
  margin: 4px 0 0;
  color: var(--ink-faint);
  font-size: 11px;
}

.count-badge {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-muted);
  color: var(--ink-soft);
  padding: 4px 9px;
  font-size: 11px;
}

.strategy-shell {
  background: var(--surface);
}

.strategy-groups {
  display: grid;
}

.strategy-accordion {
  min-width: 0;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}

.strategy-accordion:last-child {
  border-bottom: 0;
}

.strategy-accordion.is-degraded {
  border-left: 3px solid var(--amber);
}

.strategy-accordion > summary {
  display: grid;
  grid-template-columns: 20px minmax(220px, 1fr) minmax(260px, auto) auto;
  align-items: center;
  min-height: 72px;
  gap: 12px;
  padding: 11px 18px;
  cursor: pointer;
  list-style: none;
}

.strategy-accordion > summary::-webkit-details-marker {
  display: none;
}

.strategy-accordion > summary:hover {
  background: var(--surface-muted);
}

.strategy-accordion > summary:focus-visible {
  outline: 3px solid rgba(22, 131, 90, 0.2);
  outline-offset: -3px;
}

.accordion-chevron {
  color: var(--ink-faint);
  font-size: 23px;
  line-height: 1;
  transform: rotate(0deg);
  transition: transform 150ms ease;
}

.strategy-accordion[open] .accordion-chevron {
  transform: rotate(90deg);
}

.strategy-label {
  min-width: 0;
}

.strategy-label strong,
.strategy-label span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.strategy-label strong {
  font-size: 14px;
}

.strategy-label span {
  margin-top: 5px;
  color: var(--ink-faint);
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 10px;
}

.strategy-summary-metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(66px, 1fr));
  min-width: 260px;
}

.strategy-summary-metrics > span {
  display: grid;
  gap: 3px;
  border-left: 1px solid var(--line);
  padding: 0 13px;
}

.strategy-summary-metrics small {
  color: var(--ink-faint);
  font-size: 9px;
  font-weight: 650;
}

.strategy-summary-metrics strong {
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}

.strategy-accordion-body {
  border-top: 1px solid var(--line);
  background: #fbfcfa;
}

.strategy-stock-table {
  min-width: 980px;
}

.strategy-stock-table th {
  background: #f2f4f1;
}

.strategy-note {
  margin: 0;
  border-top: 1px solid var(--line);
  color: var(--ink-soft);
  padding: 11px 18px;
  font-size: 11px;
  line-height: 1.6;
}

.history-strategy-shell {
  background: var(--bg);
}

.history-date-groups {
  display: grid;
  gap: 14px;
  padding: 14px 0 0;
}

.history-date-group {
  border: 1px solid var(--line);
  border-top: 0;
  background: var(--surface);
}

.history-date-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 64px;
  border-top: 3px solid var(--ink);
  border-bottom: 1px solid var(--line);
  padding: 10px 18px;
}

.history-date-label time,
.history-date-label span {
  display: block;
}

.history-date-label time {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 18px;
  font-weight: 700;
}

.history-date-label div span,
.history-date-label > span {
  margin-top: 4px;
  color: var(--ink-faint);
  font-size: 10px;
}

.table-shell {
  position: relative;
  overflow-x: auto;
}

.data-table {
  width: 100%;
  min-width: 850px;
  border-collapse: collapse;
  font-size: 13px;
  text-align: left;
}

.data-table th {
  height: 42px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-muted);
  color: var(--ink-soft);
  padding: 0 16px;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}

.data-table td {
  height: 60px;
  border-bottom: 1px solid #ecefeb;
  padding: 8px 16px;
  vertical-align: middle;
}

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

.data-table tbody tr:hover {
  background: #fafbf9;
}

.entity-cell strong,
.entity-cell span {
  display: block;
}

.entity-cell strong {
  max-width: 260px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.entity-cell span {
  max-width: 260px;
  margin-top: 4px;
  overflow: hidden;
  color: var(--ink-faint);
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.num-cell {
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  white-space: nowrap;
}

.tag {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border: 1px solid var(--line);
  border-radius: 3px;
  background: var(--surface-muted);
  color: var(--ink-soft);
  padding: 2px 7px;
  font-size: 11px;
  font-weight: 650;
  white-space: nowrap;
}

.tag.buy,
.tag.active {
  border-color: #f0c8c6;
  background: var(--red-soft);
  color: #a52f34;
}

.tag.sell,
.tag.done {
  border-color: #bfe0cf;
  background: var(--green-soft);
  color: #116844;
}

.tag.wait {
  border-color: #ebd7ad;
  background: var(--amber-soft);
  color: #82540d;
}

.empty-state {
  display: grid;
  min-height: 280px;
  place-items: center;
  align-content: center;
  color: var(--ink-soft);
  text-align: center;
}

.empty-symbol {
  margin-bottom: 12px;
  color: var(--line-strong);
  font-size: 34px;
}

.empty-state strong {
  font-size: 14px;
}

.empty-state p {
  margin: 7px 0 0;
  color: var(--ink-faint);
  font-size: 12px;
}

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

.ranking-column {
  min-width: 0;
  border: 1px solid var(--line);
  border-top: 3px solid var(--ink);
  border-radius: 5px;
  background: var(--surface);
}

.ranking-column.positive {
  border-top-color: var(--red);
}

.ranking-column.negative {
  border-top-color: var(--green);
}

.ranking-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 56px;
  border-bottom: 1px solid var(--line);
  padding: 0 14px;
}

.ranking-head > div {
  display: flex;
  align-items: center;
  gap: 8px;
}

.ranking-head small {
  color: var(--ink-faint);
  font-size: 10px;
}

.rank-indicator {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
}

.ranking-column.positive .rank-indicator {
  color: var(--red);
}

.ranking-column.negative .rank-indicator {
  color: var(--green);
}

.ranking-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.ranking-list li {
  border-bottom: 1px solid #ecefeb;
}

.ranking-list li:last-child {
  border-bottom: 0;
}

.ranking-row {
  display: grid;
  grid-template-columns: 25px minmax(0, 1fr) auto 12px;
  align-items: center;
  width: 100%;
  min-height: 48px;
  border: 0;
  background: transparent;
  color: inherit;
  padding: 7px 11px 7px 13px;
  text-align: left;
}

.ranking-row:hover {
  background: var(--surface-muted);
}

.ranking-row:focus-visible {
  position: relative;
  outline: 3px solid rgba(22, 131, 90, 0.2);
  outline-offset: -3px;
}

.rank-number {
  color: var(--ink-faint);
  font-family: Georgia, serif;
  font-size: 12px;
}

.ranking-list li:nth-child(-n+3) .rank-number {
  color: var(--ink);
  font-weight: 800;
}

.rank-name {
  min-width: 0;
  overflow: hidden;
  padding-right: 8px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rank-value {
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 11px;
  font-weight: 750;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.rank-open {
  color: var(--line-strong);
  font-size: 17px;
  text-align: right;
}

.ranking-row:hover .rank-open {
  color: var(--ink-soft);
}

.mini-empty {
  padding: 28px 12px;
  color: var(--ink-faint);
  font-size: 12px;
  text-align: center;
}

.bubble-heading {
  margin-bottom: 16px;
}

.bubble-heading .eyebrow {
  color: #65c69a;
}

.bubble-heading h1 {
  color: #f5f7f5;
  font-size: 25px;
}

.bubble-heading .view-subtitle {
  color: #8e9892;
}

.segmented.dark {
  border-color: #3c433f;
  background: #202522;
}

.segmented.dark button {
  color: #aeb6b1;
}

.segmented.dark button.is-active {
  background: #e8ece9;
  color: var(--ink);
}

.date-control.dark > span {
  color: #8e9892;
}

.date-control.dark input {
  border-color: #3c433f;
  background: #202522;
  color: #e5e9e6;
  color-scheme: dark;
}

.dark-button {
  border-color: #3c433f;
  background: #202522;
  color: #c6cec8;
}

.bubble-stage {
  position: relative;
  height: calc(100% - 92px);
  min-height: 500px;
  overflow: hidden;
  border: 1px solid #343a36;
  border-radius: 5px;
  background: #111513;
}

.bubble-stage:fullscreen {
  width: 100vw;
  height: 100vh;
  min-height: 100vh;
  border: 0;
  border-radius: 0;
}

#bubble-canvas {
  display: block;
  width: 100%;
  height: 100%;
  cursor: crosshair;
}

.bubble-axis {
  position: absolute;
  left: 18px;
  display: flex;
  align-items: baseline;
  gap: 9px;
  pointer-events: none;
}

.bubble-axis.top {
  top: 15px;
  color: #ed7477;
}

.bubble-axis.bottom {
  bottom: 15px;
  color: #48ba87;
}

.bubble-axis strong {
  font-size: 13px;
}

.bubble-axis span {
  color: #68716c;
  font-size: 10px;
}

.bubble-tooltip {
  position: absolute;
  z-index: 3;
  min-width: 150px;
  pointer-events: none;
  border: 1px solid #4a524d;
  border-radius: 4px;
  background: rgba(23, 27, 25, 0.96);
  box-shadow: 0 8px 26px rgba(0, 0, 0, 0.28);
  color: #f3f5f3;
  padding: 10px 12px;
  font-size: 12px;
}

.bubble-tooltip strong,
.bubble-tooltip span {
  display: block;
}

.bubble-tooltip span {
  margin-top: 4px;
  color: #a9b1ac;
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 11px;
}

.bubble-empty {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  gap: 8px;
  color: #a9b1ac;
  text-align: center;
}

.bubble-empty span {
  color: #626b66;
  font-size: 12px;
}

.market-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 250px;
  align-items: start;
  gap: 18px;
}

.market-main {
  min-width: 0;
}

.checkpoint-panel {
  margin-bottom: 12px;
  border-top: 3px solid var(--ink);
  background: var(--surface);
}

.checkpoint-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 58px;
  border-bottom: 1px solid var(--line);
  padding: 10px 16px;
}

.checkpoint-heading h2 {
  margin: 0;
  font-size: 15px;
}

.checkpoint-heading p {
  margin: 4px 0 0;
  color: var(--ink-faint);
  font-size: 10px;
}

.checkpoint-list {
  display: flex;
  overflow-x: auto;
  padding: 8px;
  scrollbar-width: thin;
}

.checkpoint-button {
  display: grid;
  min-width: 148px;
  min-height: 70px;
  border: 0;
  border-left: 1px solid var(--line);
  background: transparent;
  color: var(--ink-soft);
  padding: 8px 13px;
  text-align: left;
}

.checkpoint-button:first-child {
  border-left: 0;
}

.checkpoint-button:hover {
  background: var(--surface-muted);
}

.checkpoint-button.is-active {
  background: #faf4f3;
  box-shadow: inset 0 -3px var(--red);
  color: var(--ink);
}

.checkpoint-button span,
.checkpoint-button strong,
.checkpoint-button small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.checkpoint-button span {
  color: var(--ink-faint);
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 10px;
}

.checkpoint-button strong {
  margin-top: 3px;
  font-size: 12px;
}

.checkpoint-button small {
  margin-top: 3px;
  color: var(--ink-faint);
  font-size: 9px;
}

.checkpoint-empty {
  border-top: 1px solid var(--line);
  color: var(--ink-faint);
  padding: 11px 16px;
  font-size: 11px;
}

.regime-hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 188px;
  border-top: 3px solid var(--ink);
  background: var(--surface);
  padding: 28px 32px;
}

.regime-copy {
  min-width: 0;
  max-width: 760px;
}

.regime-copy > span {
  color: var(--ink-soft);
  font-size: 12px;
  font-weight: 650;
}

.regime-copy h2 {
  margin: 9px 0 10px;
  font-family: Georgia, "Songti SC", serif;
  font-size: 32px;
}

.regime-copy p {
  margin: 0;
  color: var(--ink-soft);
  line-height: 1.75;
}

.score-ring {
  --score: 0;
  position: relative;
  display: grid;
  width: 104px;
  height: 104px;
  flex: 0 0 104px;
  margin-left: 30px;
  place-content: center;
  border-radius: 50%;
  background: conic-gradient(var(--red) calc(var(--score) * 1%), #e6e9e5 0);
  text-align: center;
}

.score-ring[data-score="0"] { --score: 0; }
.score-ring[data-score="5"] { --score: 5; }
.score-ring[data-score="10"] { --score: 10; }
.score-ring[data-score="15"] { --score: 15; }
.score-ring[data-score="20"] { --score: 20; }
.score-ring[data-score="25"] { --score: 25; }
.score-ring[data-score="30"] { --score: 30; }
.score-ring[data-score="35"] { --score: 35; }
.score-ring[data-score="40"] { --score: 40; }
.score-ring[data-score="45"] { --score: 45; }
.score-ring[data-score="50"] { --score: 50; }
.score-ring[data-score="55"] { --score: 55; }
.score-ring[data-score="60"] { --score: 60; }
.score-ring[data-score="65"] { --score: 65; }
.score-ring[data-score="70"] { --score: 70; }
.score-ring[data-score="75"] { --score: 75; }
.score-ring[data-score="80"] { --score: 80; }
.score-ring[data-score="85"] { --score: 85; }
.score-ring[data-score="90"] { --score: 90; }
.score-ring[data-score="95"] { --score: 95; }
.score-ring[data-score="100"] { --score: 100; }

.score-ring::after {
  position: absolute;
  inset: 8px;
  border-radius: 50%;
  background: var(--surface);
  content: "";
}

.score-ring strong,
.score-ring span {
  position: relative;
  z-index: 1;
  display: block;
}

.score-ring strong {
  font-family: Georgia, serif;
  font-size: 27px;
}

.score-ring span {
  margin-top: 2px;
  color: var(--ink-faint);
  font-size: 10px;
}

.market-kpis {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-top: 12px;
  border: 1px solid var(--line);
  background: var(--surface);
}

.market-kpis article {
  min-width: 0;
  min-height: 94px;
  padding: 16px 18px;
}

.market-kpis article + article {
  border-left: 1px solid var(--line);
}

.market-kpis span,
.market-kpis strong,
.market-kpis small {
  display: block;
}

.market-kpis span {
  color: var(--ink-soft);
  font-size: 11px;
  font-weight: 650;
}

.market-kpis strong {
  margin-top: 8px;
  overflow: hidden;
  font-size: 18px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.market-kpis small {
  margin-top: 4px;
  overflow: hidden;
  color: var(--ink-faint);
  font-size: 10px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

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

.analysis-block {
  min-height: 180px;
  border-top: 2px solid var(--line-strong);
  background: var(--surface);
  padding: 20px;
}

.analysis-title {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}

.analysis-title h3 {
  margin: 0;
  font-size: 14px;
}

.analysis-code {
  color: var(--ink-faint);
  font-family: Georgia, serif;
  font-size: 11px;
}

.rich-copy {
  color: var(--ink-soft);
  font-size: 13px;
  line-height: 1.75;
}

.rich-copy p {
  margin: 0 0 8px;
}

.rich-copy ul {
  margin: 0;
  padding-left: 18px;
}

.rich-copy li + li {
  margin-top: 6px;
}

.market-days {
  position: sticky;
  top: calc(var(--header-height) + 22px);
  border-top: 3px solid var(--ink);
  background: var(--surface);
}

.market-days-head {
  min-height: 58px;
  border-bottom: 1px solid var(--line);
  padding: 11px 14px;
}

.market-days-head span {
  display: block;
  margin-top: 3px;
  color: var(--ink-faint);
  font-size: 10px;
}

.day-list {
  padding: 6px 0;
}

.day-button {
  display: grid;
  grid-template-columns: 38px 1fr auto;
  align-items: center;
  width: 100%;
  min-height: 52px;
  border: 0;
  border-left: 3px solid transparent;
  background: transparent;
  color: var(--ink-soft);
  padding: 5px 12px 5px 9px;
  text-align: left;
}

.day-button:hover {
  background: var(--surface-muted);
}

.day-button.is-active {
  border-left-color: var(--red);
  background: #faf4f3;
  color: var(--ink);
}

.day-week {
  color: var(--ink-faint);
  font-size: 10px;
}

.day-date strong,
.day-date span {
  display: block;
}

.day-date strong {
  font-size: 12px;
}

.day-date span {
  margin-top: 2px;
  color: var(--ink-faint);
  font-size: 9px;
}

.day-arrow {
  color: var(--line-strong);
}

body.drawer-open {
  overflow: hidden;
}

.drawer-layer {
  position: fixed;
  z-index: 80;
  inset: 0;
}

.drawer-backdrop {
  position: absolute;
  inset: 0;
  width: 100%;
  border: 0;
  background: rgba(17, 21, 19, 0.48);
  cursor: default;
}

.entity-drawer {
  position: absolute;
  z-index: 1;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(720px, 92vw);
  overflow-y: auto;
  border-left: 1px solid #303632;
  background: var(--bg);
  box-shadow: -16px 0 48px rgba(16, 19, 17, 0.18);
  outline: 0;
}

.drawer-header {
  position: sticky;
  z-index: 2;
  top: 0;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  min-height: 118px;
  border-bottom: 1px solid #303632;
  background: var(--charcoal);
  color: #f3f5f3;
  padding: 24px 26px 20px;
}

.drawer-header h2 {
  margin: 0;
  font-family: Georgia, "Songti SC", serif;
  font-size: 25px;
}

.drawer-header p:last-child {
  margin: 7px 0 0;
  color: #909993;
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 10px;
}

.drawer-close {
  display: grid;
  width: 34px;
  height: 34px;
  flex: 0 0 34px;
  place-items: center;
  border: 1px solid #434b46;
  border-radius: 4px;
  background: transparent;
  color: #c9cfcb;
  font-size: 22px;
  line-height: 1;
}

.drawer-close:hover {
  border-color: #68716c;
  color: #fff;
}

.drawer-state {
  display: grid;
  min-height: calc(100vh - 118px);
  place-content: center;
  justify-items: center;
  color: var(--ink-soft);
  padding: 32px;
  text-align: center;
}

.drawer-state strong {
  margin-top: 14px;
  font-size: 14px;
}

.drawer-state p {
  margin: 7px 0 0;
  color: var(--ink-faint);
  font-size: 11px;
}

.drawer-loader {
  width: 24px;
  height: 24px;
  border: 2px solid var(--line);
  border-top-color: var(--green);
  border-radius: 50%;
  animation: spin 800ms linear infinite;
}

.drawer-content {
  padding: 18px;
}

.drawer-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  border: 1px solid var(--line);
  background: var(--surface);
}

.drawer-summary article {
  min-width: 0;
  min-height: 76px;
  padding: 14px;
}

.drawer-summary article + article {
  border-left: 1px solid var(--line);
}

.drawer-summary span,
.drawer-summary strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.drawer-summary span {
  color: var(--ink-faint);
  font-size: 9px;
}

.drawer-summary strong {
  margin-top: 8px;
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 14px;
}

.drawer-section {
  margin-top: 14px;
  border-top: 2px solid var(--ink);
  background: var(--surface);
}

.drawer-section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 54px;
  border-bottom: 1px solid var(--line);
  padding: 10px 14px;
}

.drawer-section-heading h3 {
  margin: 0;
  font-size: 14px;
}

.drawer-section-heading span {
  color: var(--ink-faint);
  font-size: 10px;
}

.drawer-section-note {
  margin: 0;
  border-bottom: 1px solid var(--line);
  background: var(--surface-muted);
  color: var(--ink-soft);
  padding: 9px 14px;
  font-size: 10px;
  line-height: 1.6;
}

.detail-timeline {
  min-height: 120px;
  padding: 12px 14px;
}

.timeline-chart {
  display: block;
  width: 100%;
  height: 146px;
  overflow: visible;
  background-image: linear-gradient(var(--line) 1px, transparent 1px);
  background-size: 100% 36.5px;
}

.timeline-zero {
  stroke: var(--line-strong);
  stroke-dasharray: 4 5;
  stroke-width: 1;
}

.timeline-caption {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 10px;
  color: var(--ink-faint);
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 9px;
}

.timeline-caption strong {
  color: var(--ink-soft);
  font-family: inherit;
  font-size: 9px;
}

.timeline-caption span:last-child {
  text-align: right;
}

.drawer-table {
  min-width: 540px;
}

.drawer-table td,
.drawer-table th {
  padding-right: 12px;
  padding-left: 12px;
}

.drawer-inline-empty {
  display: grid;
  min-height: 120px;
  place-items: center;
  color: var(--ink-faint);
  padding: 18px;
  font-size: 11px;
  text-align: center;
}

.toast {
  position: fixed;
  z-index: 100;
  right: 20px;
  bottom: 20px;
  max-width: min(380px, calc(100vw - 40px));
  border: 1px solid #343a36;
  border-radius: 4px;
  background: var(--charcoal);
  box-shadow: var(--shadow);
  color: #f2f4f2;
  padding: 11px 14px;
  font-size: 12px;
  line-height: 1.5;
}

@media (max-width: 1240px) {
  .app-header {
    grid-template-columns: auto 1fr auto;
    padding: 0 14px;
  }

  .header-brand {
    min-width: 150px;
  }

  .header-brand > div,
  .nav-item > span:last-child,
  .trade-meta {
    display: none;
  }

  .primary-nav {
    justify-content: flex-start;
  }

  .nav-item {
    min-width: 54px;
    justify-content: center;
    padding: 0 8px;
  }

  .nav-item::after {
    right: 8px;
    left: 8px;
  }

  .header-meta {
    min-width: 190px;
  }

  .ranking-grid {
    grid-template-columns: repeat(2, minmax(240px, 1fr));
  }
}

@media (max-width: 900px) {
  :root {
    --header-height: 60px;
  }

  .app-header {
    grid-template-columns: auto 1fr auto;
    min-height: var(--header-height);
  }

  .header-brand {
    min-width: auto;
  }

  .primary-nav {
    overflow-x: auto;
    scrollbar-width: none;
  }

  .primary-nav::-webkit-scrollbar {
    display: none;
  }

  .header-meta {
    min-width: auto;
    gap: 8px;
  }

  .sync-meta {
    display: flex;
  }

  .sync-meta time {
    display: none;
  }

  .view-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .heading-actions {
    width: 100%;
    justify-content: flex-start;
    overflow-x: auto;
    padding-bottom: 2px;
  }

  .date-control,
  .select-control {
    flex: 0 0 auto;
  }

  .strategy-accordion > summary {
    grid-template-columns: 20px minmax(0, 1fr) auto;
  }

  .strategy-accordion > summary > .tag {
    grid-row: 1;
    grid-column: 3;
  }

  .strategy-summary-metrics {
    grid-row: 2;
    grid-column: 2 / 4;
    min-width: 0;
  }

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

  .metric-cell:nth-child(3),
  .metric-cell:nth-child(4),
  .market-kpis article:nth-child(3),
  .market-kpis article:nth-child(4) {
    border-top: 1px solid var(--line);
  }

  .metric-cell:nth-child(3),
  .market-kpis article:nth-child(3) {
    border-left: 0;
  }

  .market-layout {
    grid-template-columns: 1fr;
  }

  .market-days {
    position: static;
    grid-row: 1;
  }

  .day-list {
    display: flex;
    overflow-x: auto;
    padding: 6px;
  }

  .day-button {
    grid-template-columns: 1fr;
    width: 118px;
    min-width: 118px;
    border-left: 0;
    border-bottom: 3px solid transparent;
    padding: 9px;
  }

  .day-button.is-active {
    border-bottom-color: var(--red);
  }

  .day-week,
  .day-arrow {
    display: none;
  }
}

@media (max-width: 640px) {
  .login-screen {
    place-items: start center;
    padding: 20px 12px;
  }

  .login-panel {
    margin-top: 6vh;
    padding: 26px 22px;
  }

  .login-copy {
    margin-top: 40px;
  }

  .login-copy h1,
  .view-heading h1 {
    font-size: 25px;
  }

  .app-header {
    position: sticky;
    grid-template-columns: auto 1fr auto;
    padding: 0 9px;
  }

  .header-brand .brand-mark {
    width: 32px;
    height: 32px;
    flex-basis: 32px;
  }

  .nav-item {
    min-width: 46px;
    padding: 0 5px;
  }

  .nav-glyph {
    width: 24px;
    height: 24px;
  }

  .sync-meta {
    display: none;
  }

  .header-meta .icon-button {
    width: 32px;
    height: 32px;
    flex-basis: 32px;
  }

  .view {
    padding: 22px 12px 34px;
  }

  .view.bubble-view {
    min-height: calc(100svh - var(--header-height));
    height: calc(100svh - var(--header-height));
    padding: 15px 10px 12px;
  }

  .view-heading {
    gap: 17px;
    margin-bottom: 18px;
  }

  .heading-actions {
    flex-wrap: nowrap;
  }

  .date-control {
    min-width: 142px;
  }

  .select-control {
    min-width: 184px;
  }

  .refresh-button span {
    display: none;
  }

  .metric-cell {
    min-height: 94px;
    padding: 16px 14px;
  }

  .metric-cell strong {
    font-size: 24px;
  }

  .metric-cell > small {
    display: block;
    margin: 5px 0 0;
  }

  .strategy-accordion > summary {
    gap: 9px;
    min-height: 92px;
    padding: 10px 12px;
  }

  .strategy-summary-metrics {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .strategy-summary-metrics > span {
    padding: 0 7px;
  }

  .history-date-label {
    align-items: flex-start;
    padding: 10px 12px;
  }

  .history-date-label > span {
    max-width: 90px;
    text-align: right;
  }

  .ranking-grid {
    grid-template-columns: 1fr;
  }

  .bubble-heading {
    margin-bottom: 12px;
  }

  .bubble-heading > div:first-child .view-subtitle {
    display: none;
  }

  .bubble-stage {
    height: calc(100% - 135px);
    min-height: 380px;
  }

  .regime-hero {
    align-items: flex-start;
    min-height: 170px;
    padding: 22px 18px;
  }

  .regime-copy h2 {
    font-size: 26px;
  }

  .score-ring {
    width: 78px;
    height: 78px;
    flex-basis: 78px;
    margin-left: 14px;
  }

  .score-ring strong {
    font-size: 21px;
  }

  .market-kpis article {
    min-height: 88px;
    padding: 14px;
  }

  .analysis-grid {
    grid-template-columns: 1fr;
  }

  .checkpoint-button {
    min-width: 132px;
  }

  .entity-drawer {
    width: 100%;
  }

  .drawer-header {
    min-height: 106px;
    padding: 18px 16px;
  }

  .drawer-content {
    padding: 12px;
  }

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

  .drawer-summary article:nth-child(3),
  .drawer-summary article:nth-child(4) {
    border-top: 1px solid var(--line);
  }

  .drawer-summary article:nth-child(3) {
    border-left: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}
