:root {
  color-scheme: light;
  --bg: #edf1ef;
  --bg-deep: #dce4df;
  --surface: rgba(251, 253, 248, 0.92);
  --surface-solid: #fbfdf8;
  --surface-2: #f1f5f0;
  --surface-3: #e3ebe6;
  --ink: #16211d;
  --muted: #66736c;
  --muted-2: #82908a;
  --line: #ccd8d1;
  --line-strong: #aab9b1;
  --accent: #007f73;
  --accent-strong: #005d56;
  --accent-ghost: rgba(0, 127, 115, 0.14);
  --accent-2: #c84f61;
  --accent-3: #285dc6;
  --accent-4: #a87513;
  --positive: #0b8f5f;
  --negative: #cf4557;
  --neutral: #6a7480;
  --shadow: 0 18px 48px rgba(22, 33, 29, 0.1);
  --shadow-soft: 0 8px 20px rgba(22, 33, 29, 0.07);
  --chart-text: #16211d;
  --chart-muted: #66736c;
  --chart-line: rgba(22, 33, 29, 0.16);
  --chart-accent: #007f73;
  --chart-accent-fill: rgba(0, 127, 115, 0.2);
  --chart-highlight-fill: #fbfdf8;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #101514;
  --bg-deep: #090d0c;
  --surface: rgba(25, 32, 29, 0.92);
  --surface-solid: #19201d;
  --surface-2: #202923;
  --surface-3: #28352f;
  --ink: #eef6f1;
  --muted: #a1b0a9;
  --muted-2: #77877f;
  --line: #34433c;
  --line-strong: #52645b;
  --accent: #38d3bd;
  --accent-strong: #71ead8;
  --accent-ghost: rgba(56, 211, 189, 0.16);
  --accent-2: #ff7185;
  --accent-3: #87afff;
  --accent-4: #f3bf57;
  --positive: #5be09e;
  --negative: #ff7185;
  --neutral: #9ca9b5;
  --shadow: 0 18px 54px rgba(0, 0, 0, 0.34);
  --shadow-soft: 0 10px 26px rgba(0, 0, 0, 0.22);
  --chart-text: #eef6f1;
  --chart-muted: #a1b0a9;
  --chart-line: rgba(238, 246, 241, 0.15);
  --chart-accent: #38d3bd;
  --chart-accent-fill: rgba(56, 211, 189, 0.18);
  --chart-highlight-fill: #19201d;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--bg);
}

body {
  margin: 0;
  min-width: 320px;
  background:
    linear-gradient(180deg, var(--surface-2) 0, var(--bg) 280px, var(--bg-deep) 100%),
    repeating-linear-gradient(90deg, rgba(102, 115, 108, 0.08) 0, rgba(102, 115, 108, 0.08) 1px, transparent 1px, transparent 84px),
    repeating-linear-gradient(0deg, rgba(102, 115, 108, 0.055) 0, rgba(102, 115, 108, 0.055) 1px, transparent 1px, transparent 84px);
  color: var(--ink);
  font-family: Aptos, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0;
}

body::before {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    linear-gradient(125deg, transparent 0 45%, rgba(0, 127, 115, 0.08) 45% 45.35%, transparent 45.35% 100%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.38), transparent 36%);
  content: "";
}

:root[data-theme="dark"] body::before {
  background:
    linear-gradient(125deg, transparent 0 45%, rgba(56, 211, 189, 0.1) 45% 45.35%, transparent 45.35% 100%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.035), transparent 38%);
}

button,
input,
select {
  font: inherit;
  letter-spacing: 0;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
}

button,
input,
select,
label {
  -webkit-tap-highlight-color: transparent;
}

:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--accent) 45%, transparent);
  outline-offset: 2px;
}

.app-shell {
  width: min(1500px, calc(100% - 36px));
  margin: 0 auto;
  padding: 26px 0 46px;
}

.topbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 18px;
  align-items: start;
  margin-bottom: 16px;
}

.brand-block {
  min-width: 0;
  padding-top: 2px;
}

.brand-block h1,
.panel h2,
.positions-section h2 {
  margin: 0;
  color: var(--ink);
  letter-spacing: 0;
}

.brand-block h1 {
  font-family: "Aptos Display", Aptos, "Microsoft YaHei", sans-serif;
  font-size: 42px;
  font-weight: 780;
  line-height: 1.04;
}

.eyebrow {
  margin: 0 0 7px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 850;
  letter-spacing: 0;
  text-transform: uppercase;
}

.meta-line {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  margin-top: 10px;
  color: var(--muted);
  font-size: 14px;
}

.top-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
  min-width: 0;
  max-width: 820px;
}

.theme-switch {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
  max-width: 100%;
  min-height: 50px;
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: color-mix(in srgb, var(--surface-solid) 82%, transparent);
  box-shadow: var(--shadow-soft);
}

.theme-choice {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 38px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  padding: 0 11px;
  font-size: 13px;
  font-weight: 850;
  white-space: nowrap;
}

.theme-choice[aria-pressed="true"] {
  background: var(--ink);
  color: var(--surface-solid);
  box-shadow: 0 7px 16px rgba(0, 0, 0, 0.14);
}

.theme-dot {
  width: 11px;
  height: 11px;
  border: 1px solid currentColor;
  border-radius: 50%;
}

.theme-dot.light {
  background: #f7f2da;
}

.theme-dot.dark {
  background: #111816;
}

.upload-zone {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  max-width: 100%;
  min-height: 50px;
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: color-mix(in srgb, var(--surface-solid) 86%, transparent);
  box-shadow: var(--shadow-soft);
}

.upload-zone.is-dragging {
  border-color: var(--accent);
  background: var(--accent-ghost);
}

.upload-zone input[type="file"] {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.account-select {
  min-height: 38px;
  max-width: 260px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface-solid);
  color: var(--ink);
  padding: 0 10px;
}

.upload-button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 38px;
  padding: 0 13px;
  border-radius: 7px;
  background: var(--accent);
  color: #ffffff;
  cursor: pointer;
  font-size: 14px;
  font-weight: 850;
  white-space: nowrap;
}

.upload-button:hover {
  background: var(--accent-strong);
}

.button-mark {
  display: inline-grid;
  place-items: center;
  min-width: 31px;
  height: 22px;
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.18);
  color: inherit;
  font-size: 11px;
  font-weight: 900;
}

.file-status,
.panel-pill {
  display: inline-flex;
  align-items: center;
  align-self: center;
  min-height: 28px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: color-mix(in srgb, var(--surface-solid) 62%, transparent);
  color: var(--muted);
  font-size: 12px;
  font-weight: 760;
  white-space: nowrap;
}

.dashboard-stack {
  display: grid;
  gap: 14px;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 12px;
}

.kpi-card,
.panel {
  position: relative;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.kpi-card::before,
.panel::before {
  position: absolute;
  inset: 0 0 auto;
  height: 3px;
  background: linear-gradient(90deg, var(--accent), var(--accent-3), var(--accent-4));
  content: "";
}

.kpi-card:nth-child(2)::before {
  background: var(--accent-3);
}

.kpi-card:nth-child(3)::before {
  background: var(--accent-4);
}

.kpi-card:nth-child(4)::before {
  background: var(--positive);
}

.kpi-card:nth-child(5)::before {
  background: var(--muted-2);
}

.kpi-card:nth-child(6)::before {
  background: var(--accent-2);
}

.kpi-card {
  min-height: 126px;
  padding: 17px;
}

.kpi-label {
  display: block;
  margin-bottom: 12px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 850;
}

.kpi-card strong {
  display: block;
  min-width: 0;
  overflow-wrap: anywhere;
  color: var(--ink);
  font-size: 28px;
  font-weight: 820;
  line-height: 1.08;
}

.kpi-card small {
  display: block;
  margin-top: 9px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.positive {
  color: var(--positive);
}

.negative {
  color: var(--negative);
}

.neutral {
  color: var(--neutral);
}

.top-chart-section,
.dashboard-grid {
  display: grid;
  gap: 14px;
  align-items: stretch;
}

.top-chart-section {
  grid-template-columns: minmax(0, 1fr);
}

.dashboard-grid {
  grid-template-columns: minmax(320px, 0.85fr) minmax(520px, 1.45fr);
}

.panel {
  min-width: 0;
  padding: 18px;
}

.panel-header,
.table-toolbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 15px;
}

.panel h2,
.positions-section h2 {
  font-size: 21px;
  font-weight: 760;
  line-height: 1.18;
}

.asset-curve-panel {
  min-height: 424px;
}

.allocation-layout {
  display: grid;
  grid-template-columns: minmax(210px, 0.9fr) minmax(190px, 1fr);
  gap: 16px;
  align-items: center;
}

.allocation-panel,
.performance-panel {
  height: 100%;
}

canvas {
  display: block;
  width: 100%;
  max-width: 100%;
  height: 260px;
}

#allocationChart {
  height: 286px;
}

#portfolioChart {
  height: 254px;
}

.legend-list,
.stack-list,
.mover-list,
.bridge-list,
.recent-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.legend-list {
  display: grid;
  gap: 7px;
}

.legend-row {
  display: grid;
  grid-template-columns: 13px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 38px;
  border: 1px solid transparent;
  border-radius: 7px;
  background: transparent;
  color: inherit;
  padding: 0 8px;
  text-align: left;
}

.legend-row:hover,
.legend-row:focus-visible {
  border-color: var(--line);
  background: var(--surface-2);
}

.swatch {
  width: 13px;
  height: 13px;
  border-radius: 4px;
}

.legend-name,
.position-symbol,
.recent-symbol {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 850;
}

.legend-value {
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.bridge-list {
  display: grid;
  gap: 11px;
}

.bridge-row,
.stack-row,
.mover-row {
  display: grid;
  gap: 7px;
}

.bridge-meta,
.stack-meta,
.mover-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: var(--muted);
  font-size: 13px;
}

.stack-meta strong,
.mover-title {
  color: var(--ink);
}

.bridge-bar,
.stack-bar,
.mover-bar {
  height: 9px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--surface-3);
}

.bridge-bar span,
.stack-bar span,
.mover-bar span {
  display: block;
  width: max(4px, var(--bar-width));
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), var(--accent-3));
}

.bridge-row.is-negative .bridge-bar span,
.stack-row.is-negative .stack-bar span,
.mover-row.is-negative .mover-bar span {
  background: linear-gradient(90deg, var(--accent-2), var(--negative));
}

.bridge-row.is-start .bridge-bar span,
.bridge-row.is-end .bridge-bar span {
  background: var(--accent-4);
}

.performance-layout {
  display: grid;
  grid-template-columns: minmax(220px, 0.9fr) minmax(320px, 1.1fr);
  gap: 18px;
  align-items: start;
}

.performance-layout > div {
  min-width: 0;
}

.panel-subtitle {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
}

.stack-list,
.mover-list {
  display: grid;
  gap: 12px;
  align-content: start;
}

.mover-list {
  max-height: 300px;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding-right: 6px;
  scrollbar-gutter: stable;
}

.mover-list::-webkit-scrollbar,
.table-wrap::-webkit-scrollbar {
  width: 9px;
  height: 9px;
}

.mover-list::-webkit-scrollbar-track,
.table-wrap::-webkit-scrollbar-track {
  background: var(--surface-2);
  border-radius: 999px;
}

.mover-list::-webkit-scrollbar-thumb,
.table-wrap::-webkit-scrollbar-thumb {
  border-radius: 999px;
  background: color-mix(in srgb, var(--muted) 48%, transparent);
}

.mover-row {
  width: 100%;
  min-width: 0;
  padding: 0 0 11px;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: transparent;
  color: inherit;
  text-align: left;
}

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

.mover-row:hover .mover-title,
.group-toggle:hover .position-symbol,
.legend-row:hover .legend-name {
  color: var(--accent);
}

.mover-title {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 850;
}

.mover-submeta {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 8px 12px;
  color: var(--muted);
  font-size: 12px;
}

.mover-submeta span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  overflow-wrap: anywhere;
  white-space: normal;
}

.empty-note {
  min-height: 42px;
  display: grid;
  align-items: center;
  color: var(--muted);
  font-size: 13px;
}

.positions-section,
.trade-section,
.return-calendar-section {
  margin-top: 0;
}

.trade-table {
  min-width: 1080px;
}

.control-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
  min-width: 0;
}

.date-filter {
  display: inline-grid;
  grid-template-columns: auto minmax(132px, 1fr);
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
}

.control-row select,
.control-row input,
.curve-controls input,
.composer-bar input,
.page-size-control select,
.page-jump input,
.calendar-period-select {
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface-solid);
  color: var(--ink);
}

.control-row select,
.control-row input {
  min-height: 38px;
  min-width: 0;
  max-width: 190px;
  padding: 0 10px;
}

.control-button,
.mini-action,
.page-button,
.range-button,
.curve-controls button,
.calendar-tab {
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface-solid);
  color: var(--ink);
  font-weight: 850;
  white-space: nowrap;
}

.control-button {
  min-height: 38px;
  padding: 0 12px;
  font-size: 13px;
}

.control-button:hover,
.mini-action:hover,
.page-button:hover:not(:disabled),
.range-button:hover,
.curve-controls button:hover {
  border-color: var(--line-strong);
  background: var(--surface-2);
}

.control-button.is-active,
.range-button.is-active,
.curve-controls button {
  border-color: var(--accent);
  background: var(--ink);
  color: var(--surface-solid);
}

.control-button.secondary {
  color: var(--muted);
}

.control-button:disabled,
.page-button:disabled {
  opacity: 0.45;
}

.composer-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin: -2px 0 12px;
  padding: 10px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: var(--surface-2);
}

.composer-bar[hidden] {
  display: none;
}

.composer-bar input {
  min-height: 38px;
  min-width: 190px;
  padding: 0 10px;
}

.date-filter input {
  width: 142px;
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: color-mix(in srgb, var(--surface-solid) 76%, transparent);
}

.table-pagination {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 12px;
}

.page-size-control,
.page-controls,
.page-jump {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.page-size-control,
.page-jump {
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
}

.page-size-control select,
.page-jump input,
.page-button {
  min-height: 34px;
  padding: 0 10px;
}

.page-jump input {
  width: 72px;
  text-align: center;
}

.page-button {
  color: var(--muted);
  font-size: 12px;
}

table {
  width: 100%;
  min-width: 860px;
  border-collapse: collapse;
  font-size: 13px;
}

th,
td {
  padding: 12px 11px;
  border-bottom: 1px solid var(--line);
  text-align: right;
  vertical-align: middle;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
  text-transform: uppercase;
}

td:first-child,
th:first-child {
  text-align: left;
}

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

tbody tr:hover td {
  background: color-mix(in srgb, var(--accent-ghost) 45%, transparent);
}

.position-name {
  display: grid;
  gap: 3px;
  min-width: 190px;
}

.position-cell,
.position-group-main.has-selection {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 9px;
}

.position-group-main {
  min-width: 0;
}

.position-group-cell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
}

.position-select {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
}

.position-desc {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--muted);
  font-size: 12px;
}

.side-pill {
  display: inline-flex;
  justify-content: center;
  min-width: 58px;
  padding: 4px 8px;
  border: 1px solid color-mix(in srgb, var(--accent) 22%, transparent);
  border-radius: 999px;
  background: var(--accent-ghost);
  color: var(--accent);
  font-size: 12px;
  font-weight: 850;
}

.side-pill.short {
  border-color: color-mix(in srgb, var(--negative) 24%, transparent);
  background: color-mix(in srgb, var(--negative) 13%, transparent);
  color: var(--negative);
}

.side-pill.combo {
  border-color: color-mix(in srgb, var(--accent-3) 24%, transparent);
  background: color-mix(in srgb, var(--accent-3) 13%, transparent);
  color: var(--accent-3);
}

.group-row td {
  background: color-mix(in srgb, var(--surface-2) 82%, transparent);
  font-weight: 760;
}

.group-toggle {
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  width: 100%;
  border: 0;
  background: transparent;
  color: inherit;
  padding: 0;
  text-align: left;
}

.toggle-mark {
  display: inline-grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--surface-solid);
  color: var(--accent);
  font-size: 15px;
  font-weight: 900;
  line-height: 1;
}

.mini-action {
  min-height: 28px;
  padding: 0 8px;
  color: var(--muted);
  font-size: 12px;
}

.detail-row td {
  background: color-mix(in srgb, var(--surface-solid) 70%, transparent);
}

.detail-indent {
  padding-left: 32px;
}

.lower-grid {
  display: grid;
  grid-template-columns: minmax(320px, 1fr) minmax(320px, 1fr);
  gap: 14px;
  margin-top: 14px;
}

.curve-header {
  align-items: center;
}

.range-controls {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: flex-end;
}

.range-button,
.curve-controls button {
  min-height: 32px;
  padding: 0 10px;
  color: var(--muted);
  font-size: 12px;
}

.range-button.is-active,
.curve-controls button {
  color: var(--surface-solid);
}

.curve-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: end;
  margin-bottom: 12px;
}

.curve-controls label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
}

.curve-controls input {
  min-height: 34px;
  padding: 0 9px;
}

.curve-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 12px;
}

.curve-stats div {
  min-width: 0;
  border-top: 1px solid var(--line);
  background: color-mix(in srgb, var(--surface-2) 78%, transparent);
  padding: 10px;
}

.curve-stats span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
}

.curve-stats strong {
  display: block;
  margin-top: 5px;
  overflow-wrap: anywhere;
  font-size: 18px;
  font-weight: 820;
}

.chart-shell {
  position: relative;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--surface-solid) 78%, transparent), color-mix(in srgb, var(--surface-2) 80%, transparent));
  padding: 8px;
}

.chart-tooltip {
  position: absolute;
  z-index: 3;
  min-width: 170px;
  padding: 10px 11px;
  border: 1px solid color-mix(in srgb, var(--accent) 30%, var(--line));
  border-radius: 8px;
  background: color-mix(in srgb, var(--ink) 92%, transparent);
  color: var(--surface-solid);
  font-size: 12px;
  line-height: 1.45;
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, -112%);
  transition:
    opacity 120ms ease,
    transform 120ms ease;
}

.chart-tooltip.is-visible {
  opacity: 1;
  transform: translate(-50%, -118%);
}

.chart-tooltip strong {
  display: block;
  font-size: 15px;
}

.source-note {
  margin: 9px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.return-calendar-section .panel-header {
  margin-bottom: 12px;
}

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

.calendar-period-select {
  min-width: 150px;
  min-height: 36px;
  border-color: transparent;
  background: transparent;
  padding: 0 28px 0 0;
  font-size: 21px;
  font-weight: 760;
}

.calendar-tabs {
  display: inline-flex;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
}

.calendar-tab {
  min-width: 64px;
  min-height: 32px;
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 0 18px;
  font-size: 15px;
}

.calendar-tab.is-active {
  background: var(--surface-solid);
  color: var(--ink);
  box-shadow: var(--shadow-soft);
}

.calendar-summary {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 18px;
  align-items: end;
  margin-bottom: 12px;
}

.calendar-summary div {
  min-width: 0;
}

.calendar-summary div:last-child {
  justify-self: end;
  text-align: right;
}

.calendar-summary span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  font-weight: 850;
}

.calendar-summary strong {
  display: block;
  margin-top: 6px;
  overflow-wrap: anywhere;
  color: var(--ink);
  font-size: 30px;
  font-weight: 820;
  line-height: 1;
}

.calendar-board {
  display: grid;
  min-height: 610px;
  overflow: visible;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  contain: layout paint style;
}

.calendar-view {
  grid-area: 1 / 1;
  display: flex;
  flex-direction: column;
  min-height: 610px;
  min-width: 0;
  contain: layout paint style;
}

.calendar-view[data-calendar-hidden="true"] {
  visibility: hidden;
  pointer-events: none;
}

.calendar-weekdays {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  color: var(--muted-2);
  border-bottom: 1px solid var(--line);
  padding-bottom: 8px;
  font-size: 13px;
  font-weight: 760;
  text-align: center;
}

.calendar-month-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  grid-auto-rows: minmax(62px, auto);
}

.calendar-day-cell,
.calendar-year-cell {
  min-width: 0;
  display: grid;
  align-content: start;
  justify-items: center;
  gap: 4px;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: transparent;
  color: inherit;
  padding: 9px 4px 8px;
  font-variant-numeric: tabular-nums;
  text-align: center;
}

.calendar-day-cell {
  min-height: 62px;
}

.calendar-day-cell.is-blank {
  min-height: 62px;
}

.calendar-day-cell.is-blank,
.calendar-day-cell.is-future,
.calendar-year-cell.is-future {
  color: var(--muted-2);
}

.calendar-date-number {
  display: block;
  color: var(--ink);
  font-size: 18px;
  font-weight: 650;
  line-height: 1.08;
}

.calendar-cell-gain,
.calendar-cell-rate {
  display: block;
  color: var(--neutral);
  font-size: 12px;
  line-height: 1.12;
}

.calendar-cell-rate {
  margin-top: -2px;
}

.calendar-futu .positive {
  color: var(--positive);
}

.calendar-futu .negative {
  color: var(--negative);
}

.calendar-futu .neutral {
  color: var(--neutral);
}

.calendar-year-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  grid-auto-rows: minmax(82px, 1fr);
  margin-top: 2px;
}

.calendar-year-cell {
  min-height: 82px;
}

.calendar-gain-chart {
  display: grid;
  grid-template-columns: 58px minmax(0, 1fr);
  gap: 12px;
  margin-top: 18px;
}

.calendar-chart-scale {
  height: 142px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  color: var(--muted);
  font-size: 12px;
}

.calendar-chart-plot {
  position: relative;
  display: grid;
  grid-template-columns: repeat(var(--chart-columns, 12), minmax(0, 1fr));
  height: 142px;
  background:
    linear-gradient(to bottom, transparent calc(25% - 1px), var(--line) calc(25% - 1px), var(--line) 25%, transparent 25%),
    linear-gradient(to bottom, transparent calc(50% - 1px), var(--line-strong) calc(50% - 1px), var(--line-strong) 50%, transparent 50%),
    linear-gradient(to bottom, transparent calc(75% - 1px), var(--line) calc(75% - 1px), var(--line) 75%, transparent 75%);
}

.calendar-chart-slot {
  position: relative;
  min-width: 0;
  border: 0;
  background: transparent;
  padding: 0;
}

.calendar-chart-bar {
  position: absolute;
  left: 50%;
  display: block;
  width: 9px;
  min-height: 0;
  border-radius: 999px;
  transform: translateX(-50%);
}

.calendar-chart-bar.positive {
  bottom: 50%;
  height: var(--bar-height);
  background: var(--positive);
}

.calendar-chart-bar.negative {
  top: 50%;
  height: var(--bar-height);
  background: var(--negative);
}

.calendar-chart-bar.neutral {
  display: none;
}

.calendar-footnote {
  max-width: 920px;
  margin: auto auto 0;
  padding-top: 18px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
  text-align: center;
}

.calendar-day-cell:not(.is-blank):not(.is-future),
.calendar-year-cell:not(.is-future),
.calendar-chart-slot:not(.is-empty) {
  cursor: pointer;
}

.calendar-day-cell.is-active,
.calendar-year-cell.is-active {
  background: var(--accent-ghost);
  outline: 1px solid color-mix(in srgb, var(--accent) 36%, transparent);
  outline-offset: -1px;
}

.calendar-day-cell.is-active .calendar-date-number,
.calendar-year-cell.is-active .calendar-date-number {
  color: var(--accent);
  font-weight: 850;
}

.calendar-chart-slot.is-active::after {
  position: absolute;
  inset: 8px 50% 8px auto;
  width: 1px;
  background: color-mix(in srgb, var(--ink) 22%, transparent);
  content: "";
}

.calendar-chart-slot.is-active .calendar-chart-bar {
  width: 13px;
  outline: 4px solid var(--accent-ghost);
}

.calendar-empty {
  min-height: 112px;
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 13px;
}

.recent-list {
  display: grid;
  gap: 10px;
}

.recent-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  min-height: 46px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}

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

.recent-meta {
  display: flex;
  gap: 10px;
  color: var(--muted);
  font-size: 12px;
}

.recent-value {
  text-align: right;
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 20;
  max-width: min(420px, calc(100vw - 40px));
  padding: 13px 15px;
  border: 1px solid color-mix(in srgb, var(--accent) 35%, var(--line));
  border-radius: 8px;
  background: var(--ink);
  color: var(--surface-solid);
  box-shadow: var(--shadow);
  transform: translateY(18px);
  opacity: 0;
  pointer-events: none;
  transition:
    opacity 180ms ease,
    transform 180ms ease;
}

.toast.is-visible {
  transform: translateY(0);
  opacity: 1;
}

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

  .top-actions {
    justify-content: flex-start;
    width: 100%;
    max-width: none;
  }

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

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

  .allocation-panel {
    grid-row: auto;
  }

  .performance-panel {
    grid-column: span 2;
  }
}

@media (max-width: 900px) {
  .app-shell {
    width: min(100% - 24px, 760px);
    padding-top: 18px;
  }

  .brand-block h1 {
    font-size: 31px;
  }

  .top-actions,
  .upload-zone,
  .table-toolbar,
  .panel-header {
    align-items: stretch;
    flex-direction: column;
  }

  .theme-switch {
    width: 100%;
  }

  .theme-choice {
    flex: 1 1 0;
    justify-content: center;
  }

  .upload-zone,
  .control-row,
  .range-controls {
    justify-content: flex-start;
  }

  .kpi-grid,
  .top-chart-section,
  .dashboard-grid,
  .lower-grid,
  .allocation-layout,
  .performance-layout {
    grid-template-columns: 1fr;
  }

  .performance-panel {
    grid-column: auto;
  }

  .control-row select,
  .control-row input,
  .control-row .control-button,
  .account-select {
    width: 100%;
    min-width: 0;
    max-width: none;
    flex: 1 1 150px;
  }

  .composer-bar input,
  .composer-bar .control-button {
    flex: 1 1 180px;
  }

  .date-filter {
    flex: 1 1 220px;
    grid-template-columns: auto minmax(0, 1fr);
  }

  .date-filter input {
    width: 100%;
  }

  .table-pagination,
  .page-controls {
    width: 100%;
  }

  .table-pagination,
  .page-controls,
  .page-size-control {
    justify-content: space-between;
  }

  canvas,
  #allocationChart {
    height: 230px;
  }

  #portfolioChart {
    height: 260px;
  }

  .curve-stats {
    grid-template-columns: 1fr;
  }

  .calendar-toolbar {
    align-items: stretch;
    flex-direction: column;
    gap: 12px;
  }

  .calendar-period-select {
    width: 100%;
    font-size: 22px;
  }

  .calendar-tabs {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: 100%;
  }

  .calendar-tab {
    min-width: 0;
    font-size: 16px;
  }

  .calendar-summary {
    grid-template-columns: 1fr;
  }

  .calendar-summary div:last-child {
    justify-self: start;
    text-align: left;
  }

  .calendar-summary strong {
    font-size: 28px;
  }

  .calendar-board,
  .calendar-view {
    min-height: 590px;
  }

  .calendar-weekdays {
    font-size: 14px;
  }

  .calendar-day-cell,
  .calendar-year-cell {
    min-height: 62px;
    padding: 8px 3px 7px;
  }

  .calendar-date-number {
    font-size: 17px;
  }

  .calendar-cell-gain,
  .calendar-cell-rate {
    font-size: 11px;
  }

  .calendar-year-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    grid-auto-rows: minmax(70px, 1fr);
  }

  .calendar-gain-chart {
    grid-template-columns: 48px minmax(0, 1fr);
    gap: 10px;
  }

  .calendar-chart-scale,
  .calendar-chart-plot {
    height: 126px;
    font-size: 14px;
  }

  .calendar-chart-bar {
    width: 6px;
  }

  .calendar-chart-slot.is-active .calendar-chart-bar {
    width: 9px;
  }

  .calendar-footnote {
    font-size: 15px;
  }
}

@media (max-width: 560px) {
  .app-shell {
    width: min(100% - 18px, 520px);
  }

  .panel,
  .kpi-card {
    padding: 15px;
  }

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

  .brand-block h1 {
    font-size: 29px;
  }

  .upload-zone {
    align-items: stretch;
  }

  .upload-button,
  .file-status {
    justify-content: center;
  }
}
