:root {
  --ink: #18221d;
  --muted: #657069;
  --line: #d9dfda;
  --paper: #ffffff;
  --canvas: #f3f5f2;
  --green: #176b4d;
  --green-soft: #e7f2ec;
  --red: #b74339;
  --red-soft: #faece9;
  --gold: #a97925;
  --blue: #39718f;
  --shadow: 0 10px 28px rgba(31, 48, 39, 0.07);
}

* { box-sizing: border-box; }
html { background: var(--canvas); }
body {
  margin: 0;
  color: var(--ink);
  background: var(--canvas);
  font-family: "Segoe UI", "Microsoft YaHei UI", "Microsoft YaHei", sans-serif;
  font-size: 14px;
  line-height: 1.5;
  letter-spacing: 0;
}
button, input, select { font: inherit; letter-spacing: 0; }
button { cursor: pointer; }

.app-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 68px;
  padding: 10px max(24px, calc((100vw - 1480px) / 2));
  color: #f7fbf8;
  background: #172a22;
  border-bottom: 1px solid #294338;
}
.brand-block, .header-actions, .recommendation-band, .recommendation-metrics,
.section-heading, .transaction-tools, .status-chip { display: flex; align-items: center; }
.brand-block { gap: 12px; }
.brand-block h1 { margin: 0; font-size: 20px; line-height: 1.2; font-weight: 680; }
.brand-block p { margin: 3px 0 0; color: #aebdb5; font-size: 12px; }
.brand-mark {
  display: flex;
  align-items: flex-end;
  gap: 3px;
  width: 31px;
  height: 31px;
  padding: 6px;
  border: 1px solid #426052;
  background: #20382e;
}
.brand-mark span { width: 4px; background: #9fcaad; }
.brand-mark span:nth-child(1) { height: 8px; }
.brand-mark span:nth-child(2) { height: 17px; }
.brand-mark span:nth-child(3) { height: 12px; }
.header-actions { gap: 9px; }
.date-control { display: flex; align-items: center; gap: 8px; color: #aebdb5; font-size: 12px; }
.date-control input {
  width: 136px;
  color: #fff;
  color-scheme: dark;
  background: #20382e;
  border-color: #426052;
}
.status-chip { gap: 7px; min-width: 88px; padding: 7px 10px; color: #c7d4cd; font-size: 12px; border: 1px solid #426052; }
#status-dot { width: 7px; height: 7px; border-radius: 50%; background: #d49b3d; box-shadow: 0 0 0 3px rgba(212, 155, 61, .13); }
#status-dot.ready { background: #79c493; }
#status-dot.error { background: #e27b70; }

main { max-width: 1480px; margin: 0 auto; padding: 18px 24px 34px; }
.control-strip {
  display: grid;
  grid-template-columns: minmax(230px, 1fr) 160px 118px 150px auto;
  gap: 16px;
  align-items: end;
  padding: 13px 16px;
  background: var(--paper);
  border: 1px solid var(--line);
}
.control-strip label { display: grid; gap: 5px; color: var(--muted); font-size: 11px; font-weight: 600; }
.control-copy { display: grid; gap: 3px; }
.control-copy strong { font-size: 14px; font-weight: 650; }
input, select {
  width: 100%;
  height: 36px;
  padding: 7px 10px;
  color: var(--ink);
  background: #fff;
  border: 1px solid #cdd5cf;
  border-radius: 3px;
  outline: none;
}
input:focus, select:focus { border-color: var(--green); box-shadow: 0 0 0 2px rgba(23, 107, 77, .11); }
.input-suffix { position: relative; }
.input-suffix input { padding-right: 34px; }
.input-suffix b { position: absolute; right: 10px; top: 9px; color: var(--muted); font-size: 11px; }
.primary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  height: 36px;
  padding: 0 15px;
  color: #fff;
  background: var(--green);
  border: 1px solid var(--green);
  border-radius: 3px;
  font-weight: 650;
}
.primary-button:hover { background: #12583f; }
.primary-button svg, .icon-button svg, .recommendation-icon svg { width: 16px; height: 16px; stroke-width: 1.8; }
.icon-button {
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  width: 36px;
  height: 36px;
  padding: 0;
  color: #e6eee9;
  background: #20382e;
  border: 1px solid #426052;
  border-radius: 3px;
}
.icon-button:hover { background: #29483a; }
.icon-button.compact { width: 34px; height: 34px; color: var(--ink); background: #fff; border-color: var(--line); }

.market-band {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  margin-top: 14px;
  background: var(--paper);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}
.market-band article { min-width: 0; padding: 17px 18px; border-right: 1px solid var(--line); }
.market-band article:last-child { border-right: 0; }
.market-band span, .recommendation-metrics span { display: block; color: var(--muted); font-size: 11px; font-weight: 600; }
.market-band strong { display: block; margin-top: 6px; font-size: 24px; line-height: 1.15; font-variant-numeric: tabular-nums; }
.market-band small { display: block; margin-top: 5px; color: var(--muted); font-size: 11px; }
.signal-summary { background: #eef4f0; }

.recommendation-band {
  gap: 15px;
  margin-top: 14px;
  padding: 17px 19px;
  color: #f6faf7;
  background: #1d3a2e;
  border-left: 4px solid #79b68f;
}
.recommendation-icon { display: grid; place-items: center; width: 38px; height: 38px; color: #a9d3b8; border: 1px solid #426052; }
.recommendation-main { flex: 1; min-width: 0; }
.section-kicker { color: var(--green); font-size: 10px; font-weight: 750; text-transform: uppercase; }
.recommendation-band .section-kicker { color: #9fcaad; }
.recommendation-main h2 { margin: 3px 0 2px; font-size: 18px; font-weight: 680; }
.recommendation-main p { margin: 0; color: #bac8c0; font-size: 12px; }
.recommendation-metrics { gap: 0; align-self: stretch; }
.recommendation-metrics div { min-width: 105px; padding: 2px 16px; border-left: 1px solid #426052; }
.recommendation-metrics span { color: #a9b8b0; }
.recommendation-metrics strong { display: block; margin-top: 4px; font-size: 19px; font-variant-numeric: tabular-nums; }

.workspace { margin-top: 14px; padding: 18px; background: var(--paper); border: 1px solid var(--line); box-shadow: var(--shadow); }
.section-heading { justify-content: space-between; min-height: 40px; margin-bottom: 13px; gap: 16px; }
.section-heading h2 { margin: 2px 0 0; font-size: 17px; line-height: 1.25; font-weight: 680; }
.muted { color: var(--muted); font-size: 11px; }
.table-scroll { overflow: auto; }
table { width: 100%; border-collapse: collapse; white-space: nowrap; font-variant-numeric: tabular-nums; }
th {
  padding: 9px 10px;
  color: var(--muted);
  background: #f4f6f4;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  font-size: 10px;
  font-weight: 700;
  text-align: right;
}
td { padding: 10px; border-bottom: 1px solid #e7ebe8; font-size: 12px; text-align: right; }
th:first-child, td:first-child { text-align: left; }
.strategy-table tbody tr { cursor: pointer; transition: background .14s ease; }
.strategy-table tbody tr:hover { background: #f7faf8; }
.strategy-table tbody tr.selected { background: var(--green-soft); box-shadow: inset 3px 0 0 var(--green); }
.strategy-name { display: grid; gap: 1px; white-space: normal; min-width: 180px; }
.strategy-name strong { font-size: 12px; }
.strategy-name small { color: var(--muted); font-size: 10px; }
.positive { color: var(--red); }
.negative { color: var(--green); }
.action-text { display: inline-block; max-width: 235px; overflow: hidden; text-overflow: ellipsis; vertical-align: middle; }

.analysis-grid { display: grid; grid-template-columns: minmax(0, 1.65fr) minmax(330px, .7fr); gap: 14px; }
.chart-workspace, .signal-workspace { min-width: 0; }
.segmented { display: flex; padding: 2px; background: #eef1ee; border: 1px solid var(--line); }
.segmented button { min-width: 55px; height: 27px; padding: 0 9px; color: var(--muted); background: transparent; border: 0; border-radius: 2px; font-size: 11px; }
.segmented button.active { color: var(--ink); background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .08); font-weight: 650; }
.chart-frame { position: relative; height: 330px; }
.chart-frame canvas { width: 100% !important; height: 100% !important; }
.chart-legend { display: flex; gap: 18px; min-height: 25px; padding-top: 10px; border-top: 1px solid #edf0ed; color: var(--muted); font-size: 11px; }
.legend-item { display: flex; align-items: center; gap: 6px; }
.legend-item i { width: 18px; height: 2px; }
.trend-badge { padding: 5px 8px; color: var(--green); background: var(--green-soft); border: 1px solid #c9dfd2; font-size: 10px; font-weight: 750; }
.trend-badge.off { color: var(--red); background: var(--red-soft); border-color: #edccc7; }
.signal-stack { display: grid; gap: 20px; }
.signal-row { min-width: 0; }
.signal-row > div:first-child { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.signal-row span { color: var(--muted); font-size: 11px; }
.signal-row strong { font-size: 15px; font-variant-numeric: tabular-nums; }
.signal-row small { display: block; margin-top: 7px; color: var(--muted); font-size: 10px; white-space: normal; }
.meter { position: relative; height: 8px; margin-top: 9px; overflow: visible; background: linear-gradient(90deg, #b7d8c2 0 40%, #ecd88d 60%, #eaa59b 100%); }
.meter span { display: block; height: 100%; width: 0; background: rgba(24, 34, 29, .22); border-right: 2px solid var(--ink); transition: width .25s ease; }
.meter i { position: absolute; top: -3px; left: 80%; width: 1px; height: 14px; background: #fff; box-shadow: 0 0 0 1px rgba(24,34,29,.22); }
.price-band { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 8px; margin-top: 9px; padding: 9px; background: #f4f6f4; border: 1px solid var(--line); }
.price-band span:last-child { text-align: right; }
.price-band b { color: var(--blue); font-size: 13px; }

.lower-grid { grid-template-columns: minmax(0, 1.3fr) minmax(360px, .8fr); }
.annual-scroll { max-height: 350px; }
.rules-list { display: grid; }
.rule-item { padding: 11px 0; border-bottom: 1px solid #e6ebe7; }
.rule-item:first-child { padding-top: 1px; }
.rule-item:last-child { border-bottom: 0; }
.rule-item header { display: flex; justify-content: space-between; gap: 8px; }
.rule-item strong { font-size: 12px; }
.rule-item span { color: var(--muted); font-size: 10px; }
.rule-item p { margin: 4px 0 0; color: #49544e; font-size: 11px; }

.transaction-tools { gap: 8px; }
.transaction-tools input { width: 190px; height: 34px; }
.transaction-scroll { max-height: 430px; }
.transaction-scroll thead { position: sticky; top: 0; z-index: 2; }
.table-footer { display: flex; justify-content: space-between; padding-top: 10px; color: var(--muted); font-size: 10px; }
.action-buy { color: var(--red); font-weight: 650; }
.action-sell { color: var(--green); font-weight: 650; }

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 50;
  max-width: min(390px, calc(100vw - 44px));
  padding: 11px 14px;
  color: #fff;
  background: #1f3028;
  border: 1px solid #3d574b;
  box-shadow: 0 12px 30px rgba(0,0,0,.18);
  opacity: 0;
  transform: translateY(8px);
  pointer-events: none;
  transition: .2s ease;
}
.toast.show { opacity: 1; transform: translateY(0); }

@media (max-width: 1050px) {
  .market-band { grid-template-columns: repeat(3, 1fr); }
  .market-band article:nth-child(3) { border-right: 0; }
  .market-band article:nth-child(n+4) { border-top: 1px solid var(--line); }
  .market-band .signal-summary { grid-column: span 2; }
  .analysis-grid, .lower-grid { grid-template-columns: minmax(0, 1fr); }
  .analysis-grid > *, .lower-grid > * { min-width: 0; }
  .signal-workspace { min-height: auto; }
}

@media (max-width: 760px) {
  .app-header { position: static; align-items: flex-start; padding: 12px 15px; }
  .brand-block p { max-width: 180px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .date-control span, .status-chip { display: none; }
  .date-control input { width: 128px; }
  main { padding: 12px; }
  .control-strip { grid-template-columns: 1fr 1fr; gap: 10px; }
  .control-copy { grid-column: 1 / -1; }
  .control-strip label:nth-of-type(1) { grid-column: 1 / -1; }
  .primary-button { align-self: end; }
  .market-band { grid-template-columns: 1fr 1fr; }
  .market-band article:nth-child(n) { border-right: 1px solid var(--line); border-top: 1px solid var(--line); }
  .market-band article:nth-child(odd) { border-right: 0; }
  .market-band article:nth-child(-n+2) { border-top: 0; }
  .market-band .signal-summary { grid-column: 1 / -1; border-right: 0; }
  .market-band strong { font-size: 21px; }
  .recommendation-band { align-items: flex-start; flex-wrap: wrap; }
  .recommendation-icon { display: none; }
  .recommendation-main { flex-basis: 100%; }
  .recommendation-metrics { width: 100%; border-top: 1px solid #426052; padding-top: 10px; }
  .recommendation-metrics div { min-width: 0; flex: 1; padding: 0 8px; }
  .recommendation-metrics div:first-child { border-left: 0; padding-left: 0; }
  .workspace { padding: 14px; }
  .section-heading { align-items: flex-start; }
  .muted { display: none; }
  .chart-frame { height: 270px; }
  .chart-legend { flex-wrap: wrap; gap: 9px 15px; }
  .transaction-tools input { width: 130px; }
}

@media (max-width: 420px) {
  .brand-block h1 { font-size: 17px; }
  .brand-mark { display: none; }
  .header-actions { gap: 5px; }
  .date-control input { width: 118px; }
  .control-strip { grid-template-columns: 1fr 1fr; }
  .market-band article { padding: 14px; }
  .recommendation-metrics strong { font-size: 16px; }
  .segmented button { min-width: 45px; padding: 0 6px; }
  .section-heading h2 { font-size: 15px; }
  .transaction-tools input { display: none; }
}
