:root {
  color-scheme: light;
  --bg: #f6f7f3;
  --panel: #ffffff;
  --panel-2: #f0f4f1;
  --ink: #1f2a24;
  --muted: #6a746d;
  --line: #d9ded7;
  --green: #0b8f5a;
  --red: #c23b35;
  --amber: #bd7a18;
  --cyan: #277b89;
  --black: #111814;
  --shadow: 0 12px 30px rgba(20, 32, 25, 0.08);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

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

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

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  min-height: 72px;
  display: grid;
  grid-template-columns: minmax(220px, 300px) auto minmax(260px, 1fr) auto;
  gap: 16px;
  align-items: center;
  padding: 12px 18px;
  border-bottom: 1px solid var(--line);
  background: rgba(246, 247, 243, 0.96);
  position: sticky;
  top: 0;
  z-index: 20;
  backdrop-filter: blur(12px);
}

.view-nav,
.huichun-controls {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
}

.view-nav button,
.huichun-controls button {
  min-height: 32px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  white-space: nowrap;
}

.view-nav button {
  min-width: 74px;
}

.view-nav button.active,
.huichun-controls button.active {
  background: var(--panel);
  color: var(--ink);
  box-shadow: 0 1px 5px rgba(22, 33, 26, 0.08);
}

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

.brand-mark {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: #fff7df;
  overflow: hidden;
  box-shadow: inset 0 0 0 1px rgba(189, 122, 24, 0.28);
}

.brand-mark img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.brand h1,
.panel h2,
.login-box h2 {
  margin: 0;
}

.brand h1 {
  font-size: 19px;
  line-height: 1.2;
}

.brand p,
.panel-head span,
.quote-code,
.toolbar-note,
.risk-note,
.stock-meta,
.rule-sub,
.volume-row span,
.login-box p,
.login-box span {
  color: var(--muted);
}

.brand p {
  margin: 2px 0 0;
  font-size: 12px;
}

.search-wrap {
  min-width: 0;
  position: relative;
  display: flex;
  align-items: center;
  height: 44px;
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: 8px;
  padding: 0 12px;
}

.search-wrap svg {
  width: 18px;
  height: 18px;
  color: var(--muted);
  flex: 0 0 auto;
}

.search-wrap input {
  width: 100%;
  height: 100%;
  border: 0;
  outline: 0;
  padding: 0 10px;
  background: transparent;
  color: var(--ink);
}

.search-results {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% + 6px);
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  border-radius: 8px;
  overflow: hidden;
  z-index: 30;
}

.search-item,
.stock-row {
  width: 100%;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: center;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: transparent;
  color: var(--ink);
  text-align: left;
  padding: 10px 12px;
}

.watch-row {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: stretch;
  border-bottom: 1px solid var(--line);
}

.watch-row:last-child {
  border-bottom: 0;
}

.stock-pick {
  min-width: 0;
  border: 0;
  background: transparent;
  color: var(--ink);
  text-align: left;
  padding: 10px 12px;
}

.stock-pick:hover,
.stock-pick.active {
  background: #eef5ef;
}

.remove-watch {
  width: 38px;
  border: 0;
  border-left: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
}

.remove-watch:hover {
  color: var(--red);
  background: #fbefed;
}

.remove-watch svg {
  width: 15px;
  height: 15px;
}

.search-item:last-child,
.stock-row:last-child {
  border-bottom: 0;
}

.search-item:hover,
.stock-row:hover,
.stock-row.active {
  background: #eef5ef;
}

.loading-line {
  padding: 12px;
  color: var(--muted);
  font-size: 13px;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.icon-button {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--ink);
}

.icon-button:hover {
  border-color: #aeb8b0;
}

.icon-button svg {
  width: 18px;
  height: 18px;
}

.text-button {
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--ink);
  padding: 0 12px;
  font-weight: 700;
}

.text-button svg {
  width: 17px;
  height: 17px;
}

.logout-button {
  padding: 0 10px;
}

.workspace {
  flex: 1;
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr) 330px;
  min-height: 0;
}

.huichun-page {
  width: 100%;
  max-width: 1180px;
  margin: 0 auto;
  padding: 18px;
}

.huichun-hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 0;
  border-bottom: 1px solid var(--line);
}

.huichun-hero h2 {
  margin: 0;
  font-size: 24px;
  line-height: 1.2;
}

.huichun-hero p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.huichun-page-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.date-control {
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--muted);
  padding: 0 10px;
  font-size: 13px;
}

.date-control input {
  height: 30px;
  min-width: 132px;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
}

.huichun-controls {
  width: max-content;
  max-width: 100%;
  margin: 14px 0;
  overflow-x: auto;
}

.huichun-controls button {
  min-width: 86px;
  padding: 0 10px;
}

.huichun-results {
  display: grid;
  gap: 10px;
  padding-bottom: 28px;
}

.huichun-card {
  display: grid;
  grid-template-columns: minmax(150px, 1.2fr) repeat(6, minmax(86px, 0.7fr)) auto;
  gap: 10px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 12px;
}

.huichun-main {
  min-width: 0;
  display: grid;
  gap: 3px;
}

.huichun-main strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 15px;
}

.huichun-main span,
.metric span {
  color: var(--muted);
  font-size: 12px;
}

.metric {
  min-width: 0;
  display: grid;
  gap: 3px;
}

.metric strong {
  font-size: 14px;
  font-variant-numeric: tabular-nums;
}

.signal-badge {
  width: max-content;
  max-width: 100%;
  padding: 5px 8px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 900;
  white-space: nowrap;
}

.signal-badge.waiting {
  background: #edf4ef;
  color: var(--green);
}

.signal-badge.focus {
  background: #eef2fb;
  color: #355c9f;
}

.signal-badge.passed {
  background: #f4efe5;
  color: var(--amber);
}

.signal-badge.alert {
  background: #fdecea;
  color: var(--red);
}

.huichun-detail {
  grid-column: 1 / -1;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.huichun-detail span {
  display: block;
  margin-top: 4px;
  color: #4f5b53;
}

.huichun-actions {
  display: flex;
  gap: 6px;
}

.sidebar,
.inspector {
  min-height: calc(100vh - 72px);
  border-right: 1px solid var(--line);
  overflow: auto;
  background: #fbfcf8;
}

.inspector {
  border-right: 0;
  border-left: 1px solid var(--line);
}

.panel {
  padding: 16px;
  border-bottom: 1px solid var(--line);
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.panel-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.panel h2 {
  font-size: 15px;
  line-height: 1.3;
}

.panel-head span {
  display: block;
  margin-top: 2px;
  font-size: 12px;
}

.stock-list {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: var(--panel);
}

.stock-list.collapsed {
  max-height: 272px;
  overflow: auto;
}

.stock-list.empty {
  display: block;
  padding: 14px;
  color: var(--muted);
  font-size: 13px;
}

.stock-name {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.stock-name strong,
.stock-name span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stock-name strong {
  font-size: 14px;
}

.stock-meta {
  font-size: 12px;
}

.stock-name .stock-detail {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
  white-space: normal;
}

.stock-change {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  font-size: 13px;
}

.strategy-pill {
  align-self: start;
  padding: 3px 6px;
  border-radius: 6px;
  background: #edf4ef;
  color: var(--green);
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.strategy-pill.waiting {
  background: #edf4ef;
  color: var(--green);
}

.strategy-pill.focus {
  background: #eef2fb;
  color: #355c9f;
}

.strategy-pill.passed {
  background: #f4efe5;
  color: var(--amber);
}

.strategy-pill.alert {
  background: #fdecea;
  color: var(--red);
}

.huichun-row {
  align-items: start;
}

.main-panel {
  min-width: 0;
  display: flex;
  flex-direction: column;
  background: var(--panel);
}

.quote-strip {
  min-height: 98px;
  display: grid;
  grid-template-columns: minmax(180px, 280px) 1fr;
  gap: 18px;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
}

.quote-name {
  font-size: 24px;
  font-weight: 800;
  line-height: 1.25;
}

.quote-code {
  margin-top: 4px;
  font-size: 13px;
}

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

.quote-numbers div {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcf9;
}

.quote-numbers span {
  color: var(--muted);
  font-size: 12px;
}

.quote-numbers strong {
  overflow-wrap: anywhere;
  font-size: 16px;
  font-variant-numeric: tabular-nums;
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 20px;
  border-bottom: 1px solid var(--line);
  background: #fbfcf9;
}

.segmented {
  display: flex;
  gap: 2px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
}

.segmented button {
  min-width: 58px;
  min-height: 32px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
}

.segmented button.active {
  background: var(--panel);
  color: var(--ink);
  box-shadow: 0 1px 5px rgba(22, 33, 26, 0.08);
}

.toolbar-note {
  font-size: 12px;
  text-align: right;
}

.chart-shell {
  position: relative;
  min-width: 0;
}

.chart {
  height: clamp(520px, calc(100vh - 220px), 680px);
  flex: 0 0 auto;
}

.chart,
.chart canvas {
  touch-action: pan-y;
}

.chart-status {
  position: absolute;
  top: 12px;
  left: 20px;
  z-index: 3;
  max-width: min(520px, calc(100% - 40px));
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.94);
  color: var(--muted);
  padding: 8px 10px;
  font-size: 12px;
  box-shadow: 0 8px 20px rgba(20, 32, 25, 0.08);
}

.rule-checks,
.volume-checks {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.rule-card,
.volume-row {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 12px;
}

.rule-card {
  display: grid;
  gap: 7px;
}

.rule-top,
.volume-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.rule-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 700;
}

.badge {
  flex: 0 0 auto;
  min-width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  color: #fff;
}

.badge.pass {
  background: var(--green);
}

.badge.warn {
  background: var(--amber);
}

.badge.fail {
  background: var(--red);
}

.rule-value,
.volume-value {
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.rule-sub {
  font-size: 12px;
  line-height: 1.5;
}

.source-rules {
  margin: 0;
  padding: 0 0 0 18px;
  color: #344039;
  font-size: 13px;
  line-height: 1.7;
}

.risk-note {
  margin: 12px 0 0;
  padding-top: 10px;
  border-top: 1px solid var(--line);
  font-size: 12px;
}

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

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

.flat {
  color: var(--muted);
}

.login-overlay {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(246, 247, 243, 0.92);
  z-index: 100;
}

.login-overlay[hidden] {
  display: none;
}

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

.login-icon {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--black);
  color: #fff;
}

.login-box h2 {
  font-size: 22px;
}

.login-box p {
  margin: 0;
  line-height: 1.6;
  font-size: 13px;
}

.login-box input {
  height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  outline: 0;
}

.login-box input:focus {
  border-color: var(--cyan);
}

.login-box button {
  height: 44px;
  border: 0;
  border-radius: 8px;
  background: var(--black);
  color: #fff;
  font-weight: 700;
}

.login-box span {
  min-height: 18px;
  font-size: 12px;
}

@media (max-width: 1180px) {
  .workspace {
    grid-template-columns: 250px minmax(0, 1fr);
  }

  .inspector {
    grid-column: 1 / -1;
    min-height: unset;
    border-left: 0;
    border-top: 1px solid var(--line);
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .inspector .panel {
    border-right: 1px solid var(--line);
  }

  .inspector .panel:last-child {
    border-right: 0;
  }
}

@media (max-width: 820px) {
  .topbar {
    position: static;
    grid-template-columns: 1fr auto;
  }

  .brand {
    grid-column: 1 / -1;
  }

  .view-nav {
    grid-column: 1 / -1;
    width: 100%;
  }

  .view-nav button {
    flex: 1;
  }

  .search-wrap {
    min-width: 0;
  }

  .workspace {
    display: flex;
    flex-direction: column;
  }

  .sidebar,
  .inspector {
    min-height: unset;
    border: 0;
    border-bottom: 1px solid var(--line);
  }

  .sidebar {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .quote-strip {
    grid-template-columns: 1fr;
  }

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

  .toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .segmented {
    overflow-x: auto;
  }

  .toolbar-note {
    text-align: left;
  }

  .chart {
    height: 470px;
  }

  .inspector {
    display: block;
  }

  .huichun-page {
    padding: 12px;
  }

  .huichun-hero {
    align-items: stretch;
    flex-direction: column;
  }

  .huichun-page-actions {
    justify-content: flex-start;
  }

  .date-control {
    width: 100%;
    justify-content: space-between;
  }

  .huichun-card {
    grid-template-columns: 1fr 1fr;
  }

  .huichun-main,
  .huichun-detail {
    grid-column: 1 / -1;
  }

  .huichun-actions {
    grid-column: 1 / -1;
  }
}

@media (max-width: 560px) {
  .topbar {
    padding: 12px;
    gap: 10px;
  }

  .brand h1 {
    font-size: 17px;
  }

  .top-actions {
    justify-content: flex-end;
  }

  .sidebar {
    display: block;
  }

  .panel,
  .quote-strip,
  .toolbar {
    padding-left: 12px;
    padding-right: 12px;
  }

  .quote-name {
    font-size: 21px;
  }

  .quote-numbers {
    grid-template-columns: 1fr;
  }

  .segmented button {
    min-width: 54px;
  }
}
