:root {
  color-scheme: light;
  --bg: #f5f4f8; --paper: #fff; --text: #231b34; --muted: #645b73;
  --line: #e7e1ef; --accent: #5526a5; --deep: #281544; --wash: #f1eafb;
  font: 15px/1.55 -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg); color: var(--text);
}
* { box-sizing: border-box; }
body { margin: 0; }
[hidden] { display: none !important; }
.brand, nav, .page-head, .section-head, .actions { display: flex; align-items: center; }
.page-head, .section-head { justify-content: space-between; gap: 16px; }
.brand { gap: 12px; }
.brand b { font-size: 1.1rem; letter-spacing: .015em; }
.brand small { display: block; color: #d3c4e8; font-size: .73rem; }
.mark { display: grid; place-items: center; background: #a77bec; color: #201032; border-radius: 12px; width: 39px; height: 39px; font-weight: 800; }
nav, .actions { gap: 12px; }
nav a { color: #e7dbf6; text-decoration: none; padding: 8px 4px; }
h1, h2, h3, p { margin: 0; }
h1 { font-size: clamp(1.9rem, 5vw, 3rem); letter-spacing: -.04em; line-height: 1.15; }
h2 { font-size: 1.22rem; }
h3 { font-size: 1rem; }
p, small { color: var(--muted); }
.page-head p { margin-top: 8px; }
.label, .count { display: inline-block; border-radius: 99px; padding: 3px 10px; color: #4e258a; background: var(--wash); font-size: .78rem; white-space: nowrap; }
.label { margin-bottom: 8px; }
.count:empty { display: none; }
button, input, select { font: inherit; color: inherit; border: 1px solid #d9d0e4; border-radius: 9px; background: var(--paper); padding: 8px 11px; min-height: 42px; }
input, select { width: 100%; }
button, summary { cursor: pointer; }
button:disabled { opacity: .52; cursor: default; }
:focus-visible { outline: 2px solid #8b51d6; outline-offset: 3px; }
.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.overview { display: grid; grid-template-columns: 1.35fr 1fr 1fr; gap: 13px; margin-block: 24px 19px; }
.overview article, .panel { background: var(--paper); border: 1px solid var(--line); border-radius: 17px; min-width: 0; }
.overview article { padding: 19px; }
.overview .total { background: var(--deep); color: #fff; border-color: var(--deep); }
.total p, .total small { color: #e5d6f6; }
.overview strong { display: block; margin-block: 5px; font-size: clamp(1.12rem, 3.1vw, 1.95rem); font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.panel { padding: 18px 22px; margin-top: 15px; }
.section-head p { font-size: .86rem; margin-top: 4px; }
.filters { display: grid; grid-template-columns: 1fr minmax(135px, 230px); gap: 12px; margin-block: 16px 8px; }
label { display: grid; gap: 4px; font-size: .86rem; color: #514660; min-width: 0; }
.rows { margin-top: 9px; }
.rows > * { border-top: 1px solid var(--line); }
.empty { padding: 12px 0; }
.position summary, .cash-row, .history-row { display: grid; align-items: center; gap: 13px; padding: 12px 1px; grid-template-columns: minmax(0, 1fr) minmax(0, .65fr) minmax(0, .7fr); }
.position summary { list-style: none; }
.position summary::-webkit-details-marker { display:none; }
.position summary::before { content: "+"; color: var(--accent); position: absolute; }
.position[open] summary::before { content: "−"; }
.position summary > :first-child { padding-left: 17px; }
.rows b, .rows small { display: block; overflow-wrap: anywhere; }
.rows strong { overflow-wrap: anywhere; }
.numeric { text-align: right; font-variant-numeric: tabular-nums; }
.position ul { margin: 0 0 12px 17px; padding: 9px 12px; list-style: none; background: #f7f4fb; border-radius: 8px; }
.position li { display: flex; justify-content: space-between; gap: 12px; padding-block: 4px; }
.setup-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(245px, 100%), 1fr)); gap: 15px; margin-top: 14px; }
form { display: grid; gap: 11px; align-content: start; }
form > button { justify-self: start; }
.setup-grid form { background: #faf8fd; border-radius: 12px; padding: 12px; }
#setup-status, #rate-list { margin-top: 8px; font-size: .85rem; }
dialog { border: 1px solid var(--line); border-radius: 16px; width: min(540px, calc(100% - 24px)); color: var(--text); padding: 22px; max-height: 90dvh; }
dialog::backdrop { background: #1c102a95; }
.fields { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
@media (max-width: 620px) {
  nav { gap: 6px; font-size: .83rem; }
  .page-head { align-items: start; }
  .actions { gap: 5px; }
  .actions button { padding-inline: 8px; white-space: nowrap; }
  .overview { grid-template-columns: 1fr 1fr; gap: 8px; }
  .overview .total { grid-column: 1 / -1; }
  .overview article, .panel { padding: 13px; }
  .setup-grid { grid-template-columns: 1fr; }
  .position summary, .cash-row, .history-row { gap: 6px; font-size: .86rem; }
}

/* Workspace navigation and page layout */
.app-layout { display: grid; grid-template-columns: 222px minmax(0, 1fr); min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; display: flex; flex-direction: column;
  height: 100dvh; padding: 25px 15px 18px; background: #1c122a; color: #f4edff;
}
.sidebar .brand { padding: 2px 9px 24px; color: inherit; text-decoration: none; }
.menu { flex: 1; display: flex; flex-direction: column; align-items: stretch; gap: 5px; }
.menu a {
  color: #e0d3f2; padding: 10px 12px; border-radius: 9px;
  border-inline-start: 3px solid transparent; font-size: .94rem; font-weight: 550;
}
.menu a[aria-current="page"] { background: #392353; color: #fff; border-inline-start-color: #b791fc; }
.menu a:hover { background: #322144; }
.menu a[data-nav="settings"] { margin-top: auto; }
.workspace { width: min(1184px, 100%); margin-inline: auto; padding: 0 32px 52px; }
.workspace-bar {
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  min-height: 69px; border-bottom: 1px solid var(--line); margin-bottom: 27px;
}
.workspace-bar p, .workspace-bar .actions { font-size: .83rem; }
.workspace-bar .label { margin-bottom: 0; }
.workspace-bar button { min-height: 34px; padding-block: 4px; white-space: nowrap; }
.screen .page-head { margin-bottom: 20px; }
.screen .page-head p { font-size: .9rem; }
.screen > .panel { margin-top: 15px; }
.screen .overview { margin-top: 0; }
.screen .overview article { min-height: 119px; }
#holdings .section-head p { max-width: 50ch; }
#cash { display: grid; gap: 10px; }
.account-card { border: 1px solid var(--line); border-radius: 12px; padding: 11px 13px; }
.account-card header { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: center; gap: 10px; }
.account-card ul { list-style: none; padding: 0; margin: 9px 0 0; }
.account-card li { border-top: 1px solid var(--line); }
.cash-row { grid-template-columns: minmax(0, 1fr) minmax(0, .95fr) auto; }
.cash-row button { min-height: 34px; padding-block: 4px; font-size: .83rem; }
.balance-preview { color: #4c286f; background: var(--wash); border-radius: 8px; padding: 8px 10px; font-size: .86rem; }
#movement-status:empty { display: none; }
.data-actions { flex-wrap: wrap; margin-top: 11px; }
.button {
  display: inline-flex; align-items: center; min-height: 42px; padding: 8px 11px;
  border: 1px solid #d9d0e4; border-radius: 9px; color: inherit; text-decoration: none;
}
.button:hover, button:not(.primary):hover { background: var(--wash); }
@media (max-width: 720px) {
  .app-layout { display: block; }
  .sidebar { position: relative; height: auto; padding: 12px 12px 8px; }
  .sidebar .brand { padding: 0 3px 9px; }
  .sidebar .mark { width: 34px; height: 34px; border-radius: 9px; }
  .menu { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 3px; }
  .menu a { padding: 7px 2px; text-align: center; white-space: nowrap; border-inline-start: 0; border-bottom: 2px solid transparent; font-size: .85rem; }
  .menu a[aria-current="page"] { border-bottom-color: #b791fc; }
  .menu a[data-nav="settings"] { margin-top: 0; }
  .workspace { padding: 0 12px 36px; }
  .workspace-bar { min-height: 57px; margin-bottom: 17px; }
  .workspace-bar .actions { gap: 5px; }
  .workspace-bar .label { padding-inline: 7px; }
  .screen .page-head { margin-bottom: 14px; }
  .screen .page-head > button { white-space: nowrap; }
  .screen .overview article { min-height: 0; }
  .setup-grid { grid-template-columns: 1fr; }
}

.overview article .usd-amount {
  display: block; color: var(--muted); font-weight: 550; font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}
.overview .total .usd-amount { color: #ece1fb; }
.overview article small { display: block; margin-top: 6px; }
.fx-status { margin: -7px 0 19px; font-size: .81rem; line-height: 1.6; }

.import-form { margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--line); }
.import-form > label { max-width: 460px; }
.import-form .data-actions { margin-top: 0; }
.import-form .data-actions a { color: var(--accent); }
#opening-status:empty { display: none; }
