:root {
  color-scheme: light;
  font: 15px/1.55 "Inter", "Microsoft YaHei UI", system-ui, sans-serif;
  color: #1b2925;
  background: #f5f7f3;
  --ink: #1b2925;
  --muted: #51625a;
  --line: #dbe4da;
  --green: #145c44;
  --green-tint: #e7f3eb;
  --amber: #764517;
  --amber-tint: #fff0d8;
  --red: #942b29;
  --blue: #315b81;
  --paper: #fff;
}

*, *::before, *::after { box-sizing: border-box; }
body, h1, h2, h3, p, dl, dd { margin: 0; }
button { -webkit-tap-highlight-color: transparent; }
button:focus-visible, [tabindex]:focus-visible, summary:focus-visible { outline: 2px solid var(--green); outline-offset: 3px; }
[hidden] { display: none !important; }
.shell { max-width: 1140px; margin: auto; padding: 22px 14px calc(24px + env(safe-area-inset-bottom, 0px)); }
.masthead { padding-bottom: 19px; border-bottom: 1px solid var(--line); }
h1 { max-width: 14em; font-size: clamp(1.8rem, 7.8vw, 2.25rem); line-height: 1.16; font-weight: 800; letter-spacing: -.05em; text-wrap: balance; }
.subtitle { margin-top: 5px; color: var(--muted); font-size: .9rem; }
.feed { margin-top: 14px; }
.feed-line { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.feed p { color: var(--muted); font-size: .8rem; font-variant-numeric: tabular-nums; }
#refresh {
  appearance: none; padding: 0 12px; min-height: 44px; border: 1px solid #c9d7cc;
  border-radius: 8px; background: var(--paper); color: var(--green); font: inherit; font-size: .85rem;
  font-weight: 650; cursor: pointer;
}
#refresh:hover { background: var(--green-tint); }
.badge { display: inline-block; padding: 3px 8px; border-radius: 6px; color: var(--muted); background: #eff2ee; font-size: .8rem; font-weight: 650; }
.good { color: var(--green); }
.warn { color: var(--amber); }
.bad { color: var(--red); }
.badge.good { background: var(--green-tint); }
.badge.warn { background: var(--amber-tint); }
.section { margin-top: 23px; }
.account-header { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 6px 9px; padding: 0 2px 11px; }
.account-header h2 { font-size: 1.24rem; line-height: 1.3; }
.account-header p { color: var(--muted); font-size: .8rem; font-variant-numeric: tabular-nums; }
.account-overview { margin: 0 2px 12px; color: var(--muted); font-size: .9rem; }
.account-layout { display: grid; gap: 10px; }
.surface { min-width: 0; padding: 12px 13px; background: var(--paper); border: 1px solid var(--line); border-radius: 13px; }
.surface h3 { margin-bottom: 8px; font-size: .97rem; }
.metric dt { color: var(--muted); font-size: .85rem; }
.metric-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px 8px; }
.metric dd { font-variant-numeric: tabular-nums; font-size: .94rem; font-weight: 650; overflow-wrap: anywhere; }
.metric small { display: block; color: var(--muted); font-size: .75rem; font-weight: 500; }
.funds .metric { padding: 6px 8px; border-radius: 7px; background: #f5f7f4; }
.equity { padding-bottom: 9px; }
.equity dd { font-variant-numeric: tabular-nums; font-weight: 760; font-size: 1.85rem; line-height: 1.2; letter-spacing: -.035em; }
.equity dt { font-size: .84rem; color: var(--muted); }
.money-heading { margin-bottom: 5px; font-size: .85rem; font-weight: 650; }
.trend-header, .trend-summary { display: flex; align-items: center; justify-content: space-between; gap: 8px 12px; flex-wrap: wrap; }
.trend-header h3 { margin: 0; }
.trend-periods { display: flex; gap: 2px; padding: 2px; border-radius: 6px; background: #edf1ee; }
.trend-periods button {
  min-height: 32px; padding: 2px 9px; border: 0; border-radius: 4px; color: #4b5d56;
  background: transparent; cursor: pointer; font-family: inherit; font-size: .77rem; font-weight: 650; line-height: 1.25;
}
.trend-periods button:hover { background: #f9faf9; }
.trend-periods button[aria-pressed="true"] { color: #173c30; background: #fff; box-shadow: 0 0 0 1px #dce6df; }
.trend-summary { align-items: end; margin: 12px 0 8px; font-variant-numeric: tabular-nums; }
.trend-value { font-size: clamp(1.22rem, 2.1vw, 1.68rem); font-weight: 770; line-height: 1.24; letter-spacing: -.035em; }
.trend-move { margin-top: 2px; font-size: .8rem; font-weight: 650; }
.trend-stats { display: flex; flex-wrap: wrap; gap: 4px 13px; }
.trend-stats dt { font-size: .72rem; }
.trend-stats dd { font-size: .81rem; }
.trend-boundary { margin: 8px 0 5px; padding: 5px 8px; border-radius: 6px; color: var(--amber); background: var(--amber-tint); font-size: .82rem; font-weight: 650; }
.keep-together, .trend-boundary time { white-space: nowrap; }
.trend-stage { position: relative; height: clamp(210px, 25vw, 280px); border-radius: 7px; overflow: clip; background: linear-gradient(#fbfcfb, #fff); cursor: crosshair; touch-action: pan-y; }
.trend-stage canvas { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.trend-tooltip {
  position: absolute; display: grid; min-width: 148px; max-width: calc(100% - 16px);
  gap: 2px; padding: 7px 9px; border: 1px solid #d3ded7; border-radius: 6px; background: #fff;
  box-shadow: 0 4px 16px #183c271f; pointer-events: none; font-size: .75rem; font-variant-numeric: tabular-nums; color: var(--muted);
}
.trend-tooltip strong { font-size: .88rem; color: var(--ink); }
.trend-note, .trend-legend { margin-top: 5px; font-size: .73rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.trend-legend span:not(:first-child) { margin-left: 8px; }
.open-mark { color: var(--blue); }
.exit-mark { color: var(--green); }
.boundary-mark { color: var(--amber); }
.detail-note, .holdings p { color: var(--muted); font-size: .84rem; }
.funds .detail-note, .cost-note { margin-top: 6px; }
.holdings p + p { margin-top: 4px; }
.plan-lines { margin: 0; padding-inline-start: 1.2em; font-size: .88rem; overflow-wrap: anywhere; }
.plan-lines li + li { margin-top: 6px; }
.review-feed-header { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0 12px; justify-content: space-between; }
.review-feed-list, .trade-list { margin: 0; padding: 0; list-style: none; }
.review-feed-list { max-height: 17rem; overflow: auto; scrollbar-gutter: stable; }
.review-feed-list li + li, .trade-list li + li { border-top: 1px solid #e7ece8; }
.review-feed-list details, .trade-list li { padding: 8px 0; overflow-wrap: anywhere; font-size: .88rem; }
.review-feed-list details[open] > p { margin: 6px 0 0 14px; }
.review-feed-list summary { padding: 2px 0; color: var(--green); cursor: pointer; }
.review-feed-list time, .trade-list time { font-variant-numeric: tabular-nums; white-space: nowrap; }
.trade-row { display: flex; align-items: baseline; justify-content: space-between; column-gap: 12px; row-gap: 2px; flex-wrap: wrap; }
.trade-row strong { font-weight: 650; }
.trade-net { color: var(--green); font-variant-numeric: tabular-nums; font-weight: 650; }
.trade-net.bad { color: var(--red); }

@media (max-width: 640px) {
  .trend-periods button { min-height: 40px; }
  .review-feed-list { max-height: 17.5rem; }
}
@media (min-width: 960px) {
  .shell { padding-top: 32px; padding-inline: 29px; }
  .masthead { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; padding-bottom: 23px; }
  h1 { max-width: none; font-size: 2.85rem; }
  .feed { flex: none; margin: 0; text-align: right; }
  .feed-line { justify-content: flex-end; }
  .account-layout { grid-template-columns: minmax(0, .85fr) minmax(0, 1.15fr); gap: 13px; }
  .account-layout .trade-records, .account-layout .review-feed { grid-column: 1 / -1; }
  .surface { padding: 15px 16px; }
}
