:root {
  --bg: #f4f7fb;
  --card: #ffffff;
  --line: #d6deea;
  --text: #1d2433;
  --muted: #5f6c85;
  --brand: #0f5de2;
  --danger: #b42318;
  --success: #137333;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: radial-gradient(circle at top right, #dfeaff 0%, var(--bg) 45%);
  color: var(--text);
  font-family: "PingFang SC", "Noto Sans SC", "Segoe UI", sans-serif;
}

body.modal-open {
  overflow: hidden;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.logout-btn {
  min-width: 88px;
}

h1 {
  margin: 0;
  font-size: 28px;
}

h2 {
  margin-top: 0;
  font-size: 20px;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.inline-note {
  color: var(--muted);
  font-size: 12px;
}

.inline-select {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
}

.inline-select select {
  min-width: 96px;
  padding: 7px 10px;
  font-size: 13px;
}

p {
  margin: 8px 0 0;
  color: var(--muted);
}

.card {
  margin-top: 16px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px;
  box-shadow: 0 8px 20px rgba(10, 40, 120, 0.06);
}

.card-actions {
  margin-top: 12px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.asset-form {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(3, minmax(150px, 1fr));
  align-items: start;
}

.other-asset-form {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(2, minmax(160px, 1fr));
  align-items: end;
}

.password-form {
  display: grid;
  gap: 12px;
  grid-template-columns: 1fr;
  align-items: start;
}

.asset-form label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 14px;
  color: var(--muted);
}

.other-asset-form label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 14px;
  color: var(--muted);
}

.password-form label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 14px;
  color: var(--muted);
}

.other-asset-form label[hidden] {
  display: none !important;
}

.autocomplete-wrap {
  position: relative;
}

.autocomplete-list {
  position: absolute;
  z-index: 30;
  left: 0;
  right: 0;
  top: calc(100% + 4px);
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.12);
  max-height: 220px;
  overflow: auto;
}

.autocomplete-item {
  padding: 8px 10px;
  cursor: pointer;
  border-bottom: 1px solid #edf2fa;
  font-size: 13px;
}

.autocomplete-item:last-child {
  border-bottom: none;
}

.autocomplete-item:hover,
.autocomplete-item.active {
  background: #eef4ff;
}

.autocomplete-main {
  color: #223556;
  font-weight: 600;
}

.autocomplete-sub {
  color: var(--muted);
  font-size: 12px;
}

.field-hint {
  display: block;
  min-height: 16px;
  font-size: 12px;
  color: var(--muted);
}

.field-hint.error {
  color: var(--danger);
}

input,
select,
button {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 14px;
}

button {
  background: var(--brand);
  color: #fff;
  border: none;
  cursor: pointer;
}

button:hover {
  opacity: 0.92;
}

.ghost-btn {
  background: #f2f5fb;
  color: #2e4163;
  border: 1px solid var(--line);
}

.message {
  min-height: 20px;
  font-size: 13px;
  color: var(--muted);
}

.message.error {
  color: var(--danger);
}

.totals {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

.totals div {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.totals span {
  font-size: 13px;
  color: var(--muted);
}

.totals strong {
  font-size: 24px;
}

.allocation-wrap {
  display: flex;
  gap: 24px;
  align-items: center;
  flex-wrap: wrap;
}

.allocation-grid {
  display: grid;
  gap: 18px;
  grid-template-columns: repeat(2, minmax(280px, 1fr));
}

.allocation-block h3 {
  margin: 0 0 10px;
  font-size: 15px;
  color: #2a3c5a;
}

.allocation-chart {
  width: 210px;
  height: 210px;
  border-radius: 50%;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 700;
  color: #2f3c55;
}

.allocation-chart::before {
  content: "";
  position: absolute;
  width: 110px;
  height: 110px;
  border-radius: 50%;
  background: var(--card);
  z-index: 1;
}

.allocation-chart .center-label {
  position: relative;
  z-index: 2;
}

.allocation-legend {
  flex: 1;
  min-width: 260px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.legend-item {
  display: grid;
  grid-template-columns: 14px auto auto auto;
  gap: 10px;
  justify-content: start;
  align-items: center;
  font-size: 13px;
}

.legend-item .dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.legend-item .name {
  color: var(--text);
}

.legend-item .pct {
  color: #2f6ebf;
  font-weight: 700;
}

.legend-item .value {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.legend-empty {
  color: var(--muted);
  font-size: 13px;
}

.nav-curve {
  width: 100%;
  min-height: 300px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: linear-gradient(180deg, #f8fbff 0%, #ffffff 100%);
  padding: 10px;
}

.nav-curve-legend {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  margin: 0 2px 8px;
  font-size: 12px;
  color: #50627f;
}

.nav-curve-legend .legend-line {
  display: inline-block;
  width: 20px;
  height: 0;
  border-top: 3px solid #206ebf;
  margin-right: 6px;
  vertical-align: middle;
}

.nav-curve-legend .legend-line.total {
  border-top-color: #f39c12;
}

.nav-curve svg {
  width: 100%;
  height: 280px;
  display: block;
}

.nav-point-click {
  fill: transparent;
  cursor: pointer;
}

.nav-point {
  pointer-events: none;
}

.nav-point.nav-series {
  fill: #206ebf;
}

.nav-point.total-series {
  fill: #f39c12;
}

.nav-point.selected {
  stroke: #ffffff;
  stroke-width: 1.6;
}

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

.nav-curve-meta {
  margin-top: 8px;
  color: var(--muted);
  font-size: 12px;
}

.nav-breakdown {
  margin-top: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  overflow: hidden;
}

.nav-breakdown-head,
.nav-breakdown-row {
  display: grid;
  grid-template-columns: minmax(140px, 1.4fr) minmax(110px, 1fr) minmax(120px, auto) 64px;
  gap: 8px;
  align-items: center;
}

.nav-breakdown-head {
  padding: 8px 10px;
  background: #f4f7fd;
  color: #334155;
  font-weight: 700;
}

.nav-breakdown-head span:first-child {
  grid-column: 1 / 3;
}

.nav-breakdown-head span:last-child {
  grid-column: 3 / 5;
  text-align: right;
}

.nav-breakdown-row {
  padding: 8px 10px;
  border-top: 1px solid #eef2f7;
}

.nav-breakdown-name,
.nav-breakdown-meta {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nav-breakdown-name {
  color: #1f2937;
  font-weight: 700;
}

.nav-breakdown-meta,
.nav-breakdown-ratio {
  color: var(--muted);
}

.nav-breakdown-value,
.nav-breakdown-ratio {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.nav-breakdown-value {
  color: #1f2937;
}

.nav-breakdown-empty {
  padding: 10px;
  color: var(--muted);
}

.trade-modal {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(3px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 999;
  opacity: 0;
  transition: opacity 0.22s ease;
}

.trade-modal[hidden] {
  display: none !important;
}

.trade-modal.open {
  opacity: 1;
}

.trade-dialog {
  width: min(860px, 100%);
  max-height: calc(100vh - 40px);
  overflow: auto;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px;
  box-shadow: 0 24px 52px rgba(15, 23, 42, 0.24);
  transform: translateY(18px) scale(0.98);
  transition: transform 0.22s ease;
}

.trade-modal.open .trade-dialog {
  transform: translateY(0) scale(1);
}

.trade-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.trade-head h2 {
  margin: 0;
}

.icon-btn {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: #f4f7fd;
  color: #374b73;
  font-size: 20px;
  line-height: 1;
  padding: 0;
}

.trade-context {
  margin-bottom: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #f8fbff;
  color: #344867;
  font-size: 13px;
}

.trade-form {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(3, minmax(140px, 1fr));
  align-items: end;
}

.trade-form label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 14px;
  color: var(--muted);
}

.field-label-line {
  display: inline-block;
  white-space: nowrap;
}

#trade-currency {
  white-space: nowrap;
}

.trade-actions {
  display: flex;
  gap: 8px;
  grid-column: 1 / -1;
}

.asset-actions {
  display: flex;
  gap: 8px;
  grid-column: 1 / -1;
}

.asset-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.asset-tab-btn {
  background: #eef3ff;
  color: #2c3f62;
  border: 1px solid #d7e1f4;
}

.asset-tab-btn.active {
  background: var(--brand);
  color: #fff;
}

.asset-tab-panel[hidden] {
  display: none !important;
}

.category-summary {
  margin-bottom: 10px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fbff;
  color: #3a4e73;
  font-size: 13px;
  font-weight: 600;
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 1024px;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 10px 8px;
  text-align: left;
  vertical-align: top;
  font-size: 13px;
}

th {
  color: var(--muted);
  font-weight: 600;
}

.group-row td {
  background: #eef4ff;
  color: #264067;
  font-weight: 700;
  border-top: 1px solid var(--line);
}

.group-metrics {
  margin-left: 14px;
  font-weight: 600;
  color: #3a4e73;
}

.group-head-row td {
  background: #f6f9ff;
  color: var(--muted);
  font-weight: 600;
  border-top: 1px solid var(--line);
}

.trade-detail-row td {
  background: #fbfdff;
  padding: 12px 10px;
}

.trade-detail-title {
  margin-bottom: 8px;
  font-size: 12px;
  color: #566483;
}

.trade-detail-table {
  width: 100%;
  border-collapse: collapse;
}

.trade-detail-table th,
.trade-detail-table td {
  border-bottom: 1px dashed #dce3ef;
  font-size: 12px;
  padding: 6px 8px;
}

.trade-detail-table th {
  color: #6a7691;
  font-weight: 600;
}

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

.asset-name-btn {
  border: none;
  background: none;
  color: #1e3154;
  font-size: 15px;
  font-weight: 700;
  padding: 0;
  line-height: 1.2;
  cursor: pointer;
  text-align: left;
}

.asset-name-btn:hover {
  text-decoration: underline;
  opacity: 1;
}

.actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.mini-btn {
  padding: 6px 9px;
  font-size: 12px;
  border-radius: 6px;
}

.mini-btn.secondary {
  background: #2f6ebf;
}

.mini-btn.danger {
  background: var(--danger);
}

.up {
  color: var(--success);
}

.down {
  color: var(--danger);
}

.empty {
  color: var(--muted);
  text-align: center;
  padding: 24px;
}

.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
}

.login-shell {
  width: 100%;
  max-width: 460px;
  padding: 24px;
}

.login-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 22px;
  box-shadow: 0 18px 36px rgba(10, 40, 120, 0.12);
}

.login-card h1 {
  font-size: 30px;
}

.login-form {
  margin-top: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.login-form label {
  color: var(--muted);
  font-size: 14px;
}

@media (max-width: 980px) {
  .asset-form {
    grid-template-columns: 1fr;
  }

  .other-asset-form {
    grid-template-columns: 1fr;
  }

  .trade-form {
    grid-template-columns: 1fr;
  }

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

  .allocation-wrap {
    flex-direction: column;
    align-items: flex-start;
  }

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

  .topbar {
    flex-direction: column;
    align-items: flex-start;
  }

  .section-head {
    flex-direction: column;
    align-items: flex-start;
  }

  .topbar-actions {
    width: 100%;
    flex-wrap: wrap;
  }

  .nav-breakdown-head {
    display: none;
  }

  .nav-breakdown-row {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .nav-breakdown-meta {
    grid-column: 1 / 2;
  }

  .nav-breakdown-value {
    grid-column: 2 / 3;
    grid-row: 1 / 2;
  }

  .nav-breakdown-ratio {
    grid-column: 2 / 3;
  }
}
