:root {
  color-scheme: light;
  --ink: #13223d;
  --subtle: #586b82;
  --brand: #1558cc;
  --brand-soft: #eaf2ff;
  --surface: #fff;
  --border: #dce5f0;
  --page: #f2f5fa;
  --gain: #a92742;
  --loss: #087363;
  --radius: 16px;
  font-family: Inter, "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  font-size: 16px;
  font-synthesis: none;
}
*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; background: var(--page); color: var(--ink); }
button, input { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; opacity: .52; }
a { color: inherit; text-decoration: none; }
button:focus-visible, a:focus-visible, summary:focus-visible, input:focus-visible { outline: 3px solid #427cf1; outline-offset: 2px; }
h1, h2, p { margin: 0; }
[hidden] { display: none !important; }
.sr-only { position: absolute; height: 1px; width: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.site-header { color: #fff; background: #101f3a; border-bottom: 1px solid #243858; }
.header-inner { max-width: 1512px; margin: auto; padding: 15px 34px; display: flex; justify-content: space-between; align-items: center; gap: 14px; }
.brand { font-weight: 750; font-size: 1.05rem; letter-spacing: .01em; display: inline-flex; align-items: center; gap: 11px; }
.brand-mark { display: grid; place-items: center; width: 37px; height: 37px; background: #2669ea; border-radius: 11px; font-size: 1.2rem; box-shadow: inset 0 0 0 1px #6295f3; }
.brand-caption { color: #b9caea; font-weight: 500; margin-left: 11px; font-size: .9rem; }
.coverage { display: flex; align-items: center; gap: 9px; color: #d0def6; font-size: .875rem; font-variant-numeric: tabular-nums; }
.coverage-dot { width: 8px; height: 8px; border-radius: 50%; background: #f4bd59; flex: 0 0 8px; }
.coverage.ready .coverage-dot { background: #61d5b5; }
.layout { max-width: 1512px; padding: 28px 34px 44px; margin: auto; }
.intro { display: flex; justify-content: space-between; align-items: end; gap: 16px; margin-bottom: 24px; }
.intro h1 { font-size: clamp(1.9rem, 3.1vw, 2.75rem); letter-spacing: -.035em; font-weight: 750; line-height: 1.17; }
.intro p { margin-top: 9px; color: var(--subtle); }
.periods { display: flex; gap: 6px; flex-wrap: wrap; }
.periods span, .ma-chip { background: var(--brand-soft); border: 1px solid #d1e2ff; color: #234fa0; padding: 4px 8px; border-radius: 6px; font-size: .8rem; font-weight: 650; font-variant-numeric: tabular-nums; }
.workspace { display: grid; grid-template-columns: minmax(280px, 320px) minmax(0, 1fr); align-items: start; gap: 20px; }
.panel, .metric { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); box-shadow: 0 2px 7px #17345b06; min-width: 0; }
.parameters { padding: 20px; position: sticky; top: 14px; }
.panel-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
h2 { font-size: 1.08rem; letter-spacing: .005em; font-weight: 700; }
.text-button { border: 0; color: var(--brand); background: transparent; padding: 2px 0; font-size: .875rem; }
fieldset { border: 0; margin: 16px 0 0; padding: 0; min-width: 0; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 13px 10px; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; color: #354860; font-size: .875rem; font-weight: 620; }
.field input { min-width: 0; width: 100%; padding: 8px; height: 38px; border: 1px solid #cbd8e8; border-radius: 7px; background: #fbfdff; color: var(--ink); font-size: .9rem; font-variant-numeric: tabular-nums; }
.field input[type="date"] { padding: 6px; }
.input-unit { position: relative; display: block; }
.input-unit input { padding-right: 36px; appearance: textfield; }
.input-unit input[name="commission"] { padding-right: 48px; }
.input-unit input::-webkit-inner-spin-button, .input-unit input::-webkit-outer-spin-button { appearance: none; }
.input-unit span { position: absolute; inset: 0 7px 0 auto; pointer-events: none; display: grid; place-items: center; color: var(--subtle); font-size: .75rem; font-weight: 500; }
.form-hint, .status, .method p { font-size: .84rem; color: var(--subtle); line-height: 1.55; }
.form-hint { margin: 11px 0 14px; }
.advanced { border-top: 1px solid var(--border); padding-top: 13px; margin-bottom: 16px; }
.advanced summary, .method summary { cursor: pointer; color: #29405d; font-size: .9rem; font-weight: 650; }
.advanced .form-grid { margin-top: 13px; }
.primary-button { width: 100%; min-height: 42px; border: 0; border-radius: 8px; color: #fff; background: var(--brand); font-weight: 690; }
.primary-button:not(:disabled):hover { background: #104bb5; }
.status { margin-top: 9px; min-height: 1.4em; }
.status.error { color: #a3243b; }
.method { margin-top: 17px; padding-top: 13px; border-top: 1px solid var(--border); }
.method p { margin-top: 10px; }
.results { min-width: 0; display: grid; gap: 16px; }
.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.metric { padding: 15px; }
.metric h2 { font-size: .875rem; color: #49617b; }
.metric-number { letter-spacing: -.035em; font-size: clamp(1.3rem, 2.15vw, 2.15rem); font-weight: 750; line-height: 1.16; margin-top: 9px; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.metric p { color: var(--subtle); font-size: .8rem; margin-top: 7px; line-height: 1.4; }
.gain { color: var(--gain); }
.loss { color: var(--loss); }
.chart-panel { padding: 18px 18px 12px; }
.chart-heading p { color: var(--subtle); font-size: .875rem; margin-top: 5px; }
.segmented { display: inline-flex; flex-wrap: nowrap; gap: 3px; background: #edf2f8; border: 1px solid #e0e8f1; border-radius: 8px; padding: 3px; }
.segmented button { border: 0; border-radius: 5px; background: transparent; color: #425b76; font-size: .85rem; font-weight: 630; padding: 5px 10px; white-space: nowrap; }
.segmented button[aria-pressed="true"] { color: #164ba8; background: #fff; box-shadow: 0 1px 3px #18375a15; }
.chart { position: relative; height: 287px; margin-top: 10px; min-width: 0; }
.chart canvas { width: 100%; height: 100%; display: block; }
.chart-empty { position: absolute; inset: 0; display: grid; place-items: center; color: var(--subtle); }
.chart-tooltip { position: absolute; pointer-events: none; z-index: 2; color: #fff; background: #10213d; border: 1px solid #405474; border-radius: 7px; padding: 8px 10px; font-size: .8rem; font-variant-numeric: tabular-nums; white-space: nowrap; }
.secondary-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; min-width: 0; }
.compact-panel, .records-panel { padding: 18px; }
.compact-panel h2 { margin-bottom: 12px; }
.table-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .875rem; font-variant-numeric: tabular-nums; }
th, td { border-bottom: 1px solid #e7edf5; padding: 9px 7px; white-space: nowrap; text-align: right; }
thead { color: #425971; background: #f5f8fc; }
th { font-weight: 650; }
td:first-child, th:first-child { text-align: left; }
tbody tr:last-child td { border-bottom: 0; }
.records-heading { margin-bottom: 13px; }
.records-panel th:nth-child(2), .records-panel td:nth-child(2) { text-align: left; }
.records-panel td { vertical-align: middle; }
.code { color: var(--subtle); font-size: .8rem; display: block; margin-top: 3px; }
.row-button { background: var(--brand-soft); color: #204a99; border: 0; border-radius: 5px; padding: 4px 8px; font-size: .82rem; }
.row-detail td { text-align: left; white-space: normal; background: #f6f9fd; }
.row-averages { display: flex; flex-wrap: wrap; gap: 6px; padding: 4px 0; align-items: center; }
.ma-chip.below { background: #edf1f6; color: #4d627d; border-color: #e1e8f0; }
.distribution { display: grid; gap: 7px; }
.distribution-row { display: grid; grid-template-columns: 4.7rem 1fr 5.2rem; align-items: center; column-gap: 7px; color: #3c526d; font-size: .81rem; font-variant-numeric: tabular-nums; }
.distribution-row > :last-child { text-align: right; }
.track { height: 8px; background: #edf3fb; border-radius: 10px; overflow: hidden; }
.track > span { height: 100%; display: block; background: #3775db; border-radius: inherit; }
.empty { text-align: center; padding: 23px 0; color: var(--subtle); font-size: .9rem; }
.pager { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 12px; color: var(--subtle); font-size: .85rem; }
.pager div { display: flex; gap: 6px; }
.pager button { border: 1px solid #cbd8e8; border-radius: 6px; background: #fff; color: var(--ink); padding: 4px 8px; font-size: .85rem; }
@media(max-width:1100px) {
  .layout,.header-inner { padding-left: 20px; padding-right: 20px; }
  .workspace { grid-template-columns: minmax(258px, 280px) minmax(0, 1fr); gap: 13px; }
  .parameters,.compact-panel,.records-panel,.chart-panel { padding: 14px; }
  .metric { padding: 12px; }
}
@media(max-width:860px) {
  .workspace { grid-template-columns: minmax(0,1fr); }
  .parameters { position: static; }
  .form-grid { grid-template-columns: repeat(3,minmax(0,1fr)); }
  .metric-number { font-size: clamp(1.28rem,3.4vw,2rem); }
}
@media(max-width:530px) {
  .layout,.header-inner { padding-left: 12px; padding-right: 12px; }
  .intro { flex-direction: column; align-items: flex-start; }
  .brand-caption { display: none; }
  .coverage { font-size: .78rem; }
  .form-grid,.metric-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .secondary-grid { grid-template-columns: minmax(0,1fr); }
  .chart { height: 225px; }
  .metric-number { font-size: clamp(1.3rem, 6vw, 1.9rem); }
}
