:root {
  --bg: #0a0e14;
  --surface: rgba(27, 34, 45, .9);
  --surface-elevated: #283140;
  --surface-strong: #111722;
  --line: rgba(166, 184, 214, .13);
  --control-line: rgba(166, 184, 214, .32);
  --field-line: rgba(166, 184, 214, .25);
  --text: #edf2f8;
  --muted: #8e9aae;
  --green: #73c8b3;
  --blue: #637cff;
  --amber: #f1b85b;
  --market-up: #ef7182;
  --market-down: #46bd91;
  --trade-buy: #edf2f8;
  --trade-sell: #7ac5af;
  --status-error: #ef7182;
  --status-success: #73c8b3;
  --radius: 14px;
  --font-display: "Geist", "HarmonyOS Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif;
  --font-body: "Geist", "HarmonyOS Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif;
  font-family: var(--font-body);
}

html { background: var(--bg); scroll-behavior: smooth; }

body {
  position: relative;
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
  color: var(--text);
  background:
    radial-gradient(circle at 18% -18%, rgba(83, 109, 253, .15), transparent 32rem),
    radial-gradient(circle at 92% 12%, rgba(115, 200, 179, .09), transparent 26rem),
    linear-gradient(180deg, #090d13 0%, #0b1018 58%, #090d13 100%);
}

body::before {
  position: fixed;
  inset: 0;
  z-index: -1;
  opacity: .035;
  pointer-events: none;
  content: "";
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 160 160' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

.ambient-canvas {
  position: fixed;
  inset: 0;
  z-index: -1;
  overflow: hidden;
  pointer-events: none;
}

.ambient-canvas i {
  position: absolute;
  width: 30rem;
  height: 30rem;
  border-radius: 50%;
  filter: blur(120px);
  opacity: .08;
}

.ambient-canvas i:nth-child(1) { top: -18rem; left: -9rem; background: #536dfd; }
.ambient-canvas i:nth-child(2) { top: 34%; right: -22rem; background: #8c6de8; }
.ambient-canvas i:nth-child(3) { bottom: -24rem; left: 35%; background: #55b9a1; }

button,
input,
select,
textarea { font-family: var(--font-body); }

button {
  min-height: 44px;
  padding: 10px 17px;
  border-radius: 11px;
  color: #071410;
  background: var(--green);
  box-shadow: 0 8px 22px rgba(36, 93, 79, .12);
  transition: transform .35s cubic-bezier(.2,.8,.2,1), background .22s ease, border-color .22s ease, box-shadow .22s ease;
}

button:hover {
  background: #86d7c3;
  box-shadow: 0 11px 28px rgba(36, 93, 79, .2);
  transform: translateY(-1px);
}

.button-secondary,
.icon-button {
  color: var(--text);
  border-color: var(--control-line);
  background: rgba(12, 17, 25, .58);
  box-shadow: none;
  backdrop-filter: blur(14px);
}

.button-secondary:hover,
.icon-button:hover {
  border-color: rgba(184, 199, 224, .5);
  background: rgba(42, 51, 66, .64);
}

input,
select,
textarea {
  border-color: var(--field-line);
  border-radius: 11px;
  background: rgba(11, 16, 24, .78);
  transition: border-color .2s ease, background .2s ease, box-shadow .2s ease;
}

input:focus,
select:focus,
textarea:focus {
  border-color: rgba(99, 124, 255, .76);
  background: #101722;
  box-shadow: 0 0 0 4px rgba(99, 124, 255, .1);
}

h1,
h2,
h3,
.metric strong { font-family: var(--font-display); }

.eyebrow {
  color: #92a1b8;
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 10px;
  letter-spacing: .17em;
}

.login-shell {
  position: relative;
  min-height: 100svh;
  padding: clamp(20px, 5vw, 64px);
}

.login-card {
  width: min(100%, 500px);
  padding: clamp(30px, 5vw, 50px);
  border: 1px solid var(--line);
  border-radius: 22px;
  background: linear-gradient(145deg, rgba(31, 39, 53, .94), rgba(18, 24, 34, .96));
  box-shadow: 0 34px 90px rgba(0, 0, 0, .42);
  backdrop-filter: blur(24px);
}

.login-card h1 {
  font-size: clamp(3rem, 8vw, 5.6rem);
  font-weight: 430;
  line-height: 1;
  letter-spacing: -.055em;
}

.app-shell {
  width: min(1920px, 100%);
  max-width: 100%;
  padding: clamp(20px, 3vw, 48px);
}

.app-header {
  min-height: auto;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 36px;
  margin: 0;
  padding: 20px 0 30px;
}

.hero-copy { max-width: 980px; }

.app-header h1 {
  margin: 0;
  font-size: clamp(3.4rem, 4.6vw, 5.8rem);
  font-weight: 390;
  line-height: 1;
  letter-spacing: -.06em;
}

:lang(zh) .app-header h1 {
  line-height: 1.08;
  letter-spacing: -.055em;
}

.header-copy {
  max-width: 620px;
  margin: 15px 0 0;
  color: #91a4be;
  font-size: 15px;
  line-height: 1.65;
}

.session-tools {
  max-width: none;
  flex-wrap: nowrap;
  padding-bottom: 2px;
}

.session-tools button { white-space: nowrap; }

.role-chip {
  min-height: 34px;
  border-color: rgba(166, 184, 214, .16);
  background: rgba(12, 17, 25, .5);
  backdrop-filter: blur(14px);
}

.finance-tabs {
  position: sticky;
  top: 12px;
  z-index: 40;
  gap: 3px;
  margin: 0 0 26px;
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: rgba(12, 17, 25, .82);
  box-shadow: 0 15px 45px rgba(0, 0, 0, .24);
  backdrop-filter: blur(22px) saturate(135%);
}

.finance-tab {
  min-height: 44px;
  border-radius: 10px;
  color: #8f9aae;
  transition: color .2s ease, background .2s ease, transform .3s ease;
}

.finance-tab:hover {
  color: var(--text);
  background: rgba(255, 255, 255, .04);
  transform: none;
}

.finance-tab[data-tab="overview"] { --tab-shadow: rgba(53, 86, 253, .28); }
.finance-tab[data-tab="entry"] { --tab-shadow: rgba(94, 175, 158, .24); }
.finance-tab[data-tab="holdings"] { --tab-shadow: rgba(212, 201, 78, .2); }
.finance-tab[data-tab="review"] { --tab-shadow: rgba(255, 184, 41, .22); }
.finance-tab[data-tab="planning"] { --tab-shadow: rgba(183, 130, 242, .24); }
.finance-tab[data-tab="records"] { --tab-shadow: rgba(90, 104, 120, .24); }

.finance-tab[data-tab].is-active {
  box-shadow: 0 7px 20px var(--tab-shadow);
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
.finance-tab:focus-visible {
  outline: 2px solid rgba(126, 148, 255, .92);
  outline-offset: 3px;
}

.dashboard { position: relative; }

.summary-grid {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  grid-template-rows: repeat(2, minmax(144px, auto));
  grid-auto-flow: dense;
  gap: 12px;
  margin-bottom: 26px;
}

.metric,
.panel {
  position: relative;
  overflow: clip;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: linear-gradient(145deg, rgba(29, 37, 49, .92), rgba(21, 28, 39, .94));
  box-shadow: inset 0 1px rgba(255, 255, 255, .025), 0 16px 45px rgba(0, 0, 0, .12);
  backdrop-filter: blur(16px);
  transition: transform .45s cubic-bezier(.2,.8,.2,1), border-color .25s ease, box-shadow .25s ease;
}

.metric::after,
.panel::after {
  position: absolute;
  inset: 0;
  opacity: 0;
  pointer-events: none;
  content: "";
  background: radial-gradient(circle at var(--pointer-x, 50%) var(--pointer-y, 50%), rgba(99, 124, 255, .095), transparent 35%);
  transition: opacity .25s ease;
}

.metric:hover,
.panel:hover,
.metric:focus-within,
.panel:focus-within {
  border-color: rgba(99, 124, 255, .3);
  box-shadow: inset 0 1px rgba(255, 255, 255, .035), 0 21px 55px rgba(0, 0, 0, .2);
  transform: translateY(-2px);
}

.metric:hover::after,
.panel:hover::after { opacity: 1; }

.metric {
  min-height: 144px;
  padding: clamp(20px, 2vw, 32px);
}

.metric:not(.metric--wide)::before {
  position: absolute;
  top: 0;
  left: 24px;
  width: 42px;
  height: 2px;
  border-radius: 0 0 999px 999px;
  content: "";
  background: rgba(121, 145, 255, .68);
  box-shadow: 0 0 18px rgba(99, 124, 255, .26);
}

.metric--cash::before { background: rgba(115, 200, 179, .78); }
.metric--pnl::before { background: rgba(239, 113, 130, .78); }

.metric--wide {
  grid-column: 1 / span 6;
  grid-row: 1 / span 2;
  min-height: 300px;
  background:
    radial-gradient(circle at 88% 8%, rgba(99, 124, 255, .14), transparent 32%),
    linear-gradient(145deg, rgba(31, 41, 57, .96), rgba(20, 27, 38, .96));
}

.summary-grid > .metric:nth-child(2) { grid-column: 7 / span 3; grid-row: 1; }
.summary-grid > .metric:nth-child(3) { grid-column: 10 / span 3; grid-row: 1; }
.summary-grid > .metric--cash { grid-column: 7 / span 3; grid-row: 2; }
.summary-grid > .metric--pnl { grid-column: 10 / span 3; grid-row: 2; }

.metric > span {
  color: #8f9db1;
  font-size: 13px;
}

.metric strong {
  font-size: clamp(1.9rem, 3.2vw, 3.6rem);
  font-weight: 420;
  line-height: 1;
  letter-spacing: -.045em;
  font-variant-numeric: tabular-nums lining-nums;
}

.metric--wide > strong {
  margin-block: auto;
  font-size: clamp(3.4rem, 6vw, 7rem);
  font-variant-numeric: tabular-nums;
}

.metric small {
  max-width: 52ch;
  color: #8c99ab;
  line-height: 1.5;
}

.portfolio-account-breakdown {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px 22px;
  margin-top: 20px;
  padding-top: 17px;
}

.overview-grid,
.dashboard-grid { grid-auto-flow: dense; }

.overview-grid {
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 26px;
}

.overview-grid > .panel[aria-labelledby="net-worth-title"] {
  grid-column: 1 / span 8;
  grid-row: 1;
  min-height: 500px;
}

.overview-grid > .panel[aria-labelledby="overview-trades-title"] {
  grid-column: 9 / span 4;
  grid-row: 1;
  min-height: 500px;
}

.overview-grid > .portfolio-allocation {
  grid-column: 1 / -1;
  grid-row: 2;
  min-height: 560px;
}

.panel { padding: clamp(22px, 2.1vw, 34px); }
.panel-header { margin-bottom: clamp(24px, 3vw, 42px); }

.panel-header h2,
.panel > h2,
.panel summary strong {
  font-size: clamp(1.25rem, 1.7vw, 1.85rem);
  font-weight: 470;
  letter-spacing: -.025em;
}

.data-state {
  padding: 6px 10px;
  border-color: rgba(166, 184, 214, .17);
  background: rgba(10, 14, 20, .35);
}

.net-worth-chart { min-height: 340px; }
.net-worth-chart svg { height: 340px; }
.net-worth-chart .net-worth-line {
  fill: none;
  stroke: var(--blue);
  stroke-width: 2.5;
  stroke-linecap: round;
  stroke-linejoin: round;
  filter: drop-shadow(0 0 9px rgba(99, 124, 255, .2));
}

.net-worth-chart .net-worth-area { stroke: none; }

.net-worth-chart .net-worth-grid {
  stroke: rgba(166, 184, 214, .105);
  stroke-width: 1;
  vector-effect: non-scaling-stroke;
}

.net-worth-chart .net-worth-axis-label,
.net-worth-chart .net-worth-current-value {
  fill: #77859a;
  font: 10px "JetBrains Mono", ui-monospace, monospace;
  font-variant-numeric: tabular-nums;
}

.net-worth-chart .net-worth-current-value {
  fill: #aeb9ca;
  font-size: 11px;
}

.net-worth-chart .net-worth-dot {
  fill: #7890ff;
  stroke: #18202c;
  filter: drop-shadow(0 0 5px rgba(99, 124, 255, .55));
}

.overview-trades {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding: 3px 2px 14px;
  scroll-snap-type: x mandatory;
  scrollbar-width: thin;
}

.overview-trade,
.portfolio-overview-trade {
  min-width: 100%;
  min-height: 138px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: space-between;
  padding: 19px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(11, 16, 24, .42);
  scroll-snap-align: start;
  transition: transform .35s ease, background .25s ease;
}

.overview-trade:hover,
.portfolio-overview-trade:hover {
  background: rgba(37, 47, 62, .72);
  transform: translateY(-2px);
}

.activity-carousel-status {
  flex: 0 0 auto;
  min-width: 62px;
  text-align: center;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.portfolio-allocation__plot {
  min-height: 0;
  overflow: hidden;
  border-radius: 14px;
  background:
    radial-gradient(circle at 50% 50%, rgba(99, 124, 255, .055), transparent 50%),
    rgba(11, 16, 24, .36);
}

.portfolio-allocation__cell {
  transition: transform .35s ease;
  transform-origin: center;
}
.portfolio-allocation__cell:hover { transform: scale(1.012); }

.dashboard-grid {
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 30px;
}

.dashboard-grid > .panel { grid-column: span 4; }
.dashboard-grid > .panel--span-2 { grid-column: span 8; }
.dashboard-grid > .panel--span-3 { grid-column: 1 / -1; }

.dashboard-grid > [data-pane="planning"][aria-labelledby="monthly-title"] { grid-column: span 8; }
.dashboard-grid > [data-pane="planning"][aria-labelledby="plan-title"] { grid-column: span 4; }

.table-scroll {
  border: 1px solid rgba(166, 184, 214, .09);
  border-radius: 12px;
  background: rgba(10, 14, 21, .24);
}

th,
td {
  padding: 13px 12px;
  border-color: rgba(166, 184, 214, .085);
}

td { font-variant-numeric: tabular-nums lining-nums; }

thead {
  position: sticky;
  top: 0;
  z-index: 1;
  background: rgba(18, 24, 34, .94);
  backdrop-filter: blur(14px);
}

tbody tr { transition: background .2s ease; }
tbody tr:hover { background: rgba(99, 124, 255, .035); }

.pe-row,
.position-row,
.review-row,
.monthly-row,
.memo-row,
.risk-signal-row,
.activity-row,
.operation-row,
.import-review-row {
  border-color: rgba(166, 184, 214, .11);
  border-radius: 13px;
  background: rgba(11, 16, 24, .32);
}

.panel--action {
  background:
    radial-gradient(circle at 88% 10%, rgba(115, 200, 179, .09), transparent 34%),
    linear-gradient(145deg, rgba(29, 38, 49, .94), rgba(20, 27, 37, .96));
}

dialog {
  width: min(760px, calc(100% - 26px));
  border-color: rgba(166, 184, 214, .17);
  border-radius: 20px;
  background: rgba(22, 29, 40, .97);
  box-shadow: 0 42px 130px rgba(0, 0, 0, .64);
  backdrop-filter: blur(24px);
}

dialog::backdrop { background: rgba(4, 7, 11, .76); backdrop-filter: blur(9px); }
.dialog-card { padding: clamp(22px, 4vw, 40px); }
.form-section { border-radius: 13px; background: rgba(10, 14, 21, .22); }
.trade-total,
.trade-snapshot { border-radius: 13px; background: rgba(10, 14, 21, .56); }

.app-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 36px;
  margin-top: 54px;
  padding: 42px 0 14px;
  border-top: 1px solid var(--line);
}

.app-footer strong {
  display: block;
  font-family: var(--font-display);
  font-size: clamp(1.35rem, 2vw, 2rem);
  font-weight: 470;
}

.app-footer p {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 13px;
}

@media (min-width: 1500px) {
  .portfolio-allocation__body {
    grid-template-columns: minmax(0, 2.2fr) minmax(300px, .8fr);
    gap: 28px;
  }
}

@media (max-width: 1100px) {
  .app-header { align-items: flex-start; flex-direction: column; }
  .session-tools { max-width: none; flex-wrap: wrap; justify-content: flex-start; }

  .summary-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-template-rows: auto;
  }

  .metric--wide,
  .summary-grid > .metric:nth-child(2),
  .summary-grid > .metric:nth-child(3),
  .summary-grid > .metric--cash,
  .summary-grid > .metric--pnl {
    grid-column: auto;
    grid-row: auto;
  }
  .metric--wide { grid-column: 1 / -1; }

  .overview-grid > .panel[aria-labelledby="net-worth-title"],
  .overview-grid > .panel[aria-labelledby="overview-trades-title"],
  .overview-grid > .portfolio-allocation,
  .dashboard-grid > .panel,
  .dashboard-grid > .panel--span-2,
  .dashboard-grid > .panel--span-3,
  .dashboard-grid > .panel[data-pane] {
    grid-column: 1 / -1;
    grid-row: auto;
    min-height: auto;
  }
}

@media (max-width: 680px) {
  .app-shell { padding: 16px 12px 34px; }
  .app-header { padding: 14px 0 24px; gap: 24px; }
  .app-header h1 { font-size: clamp(3.2rem, 17vw, 5rem); }
  .header-copy { margin-top: 10px; font-size: 14px; }

  .session-tools {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
  }
  .session-tools .role-chip { grid-column: 1 / -1; width: 100%; }
  .session-tools button { min-width: 0; padding-inline: 8px; }

  .finance-tabs { top: 7px; margin-bottom: 20px; }
  .finance-tabs {
    scroll-snap-type: x proximity;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }
  .finance-tabs::-webkit-scrollbar { display: none; }
  .finance-tab { min-width: 86px; scroll-snap-align: start; }

  .summary-grid,
  .overview-grid,
  .dashboard-grid { grid-template-columns: 1fr; }

  .metric--wide,
  .summary-grid > .metric:nth-child(2),
  .summary-grid > .metric:nth-child(3),
  .summary-grid > .metric--cash,
  .summary-grid > .metric--pnl,
  .overview-grid > .panel[aria-labelledby="net-worth-title"],
  .overview-grid > .panel[aria-labelledby="overview-trades-title"],
  .overview-grid > .portfolio-allocation,
  .dashboard-grid > .panel,
  .dashboard-grid > .panel--span-2,
  .dashboard-grid > .panel--span-3 { grid-column: auto; }

  .metric--wide { min-height: 244px; }
  .metric--wide > strong { font-size: clamp(3rem, 13vw, 4.5rem); }
  .panel { padding: 20px 15px; }
  .panel-header { margin-bottom: 24px; }
  .net-worth-chart { min-height: 260px; }
  .net-worth-chart svg { height: 260px; }

  .app-footer {
    align-items: stretch;
    flex-direction: column;
    margin-top: 36px;
    padding-top: 30px;
  }
  .app-footer button { width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .metric,
  .panel,
  .overview-trade,
  .portfolio-overview-trade { transform: none !important; }
}
