:root {
  color-scheme: light;
  --bg: #f5f7f8;
  --panel: #ffffff;
  --panel-soft: #eef4f1;
  --text: #17211d;
  --muted: #69746f;
  --line: #dfe7e2;
  --green: #00a870;
  --green-dark: #007f5a;
  --gold: #d39a22;
  --blue: #3178c6;
  --ink: #24312c;
  --red: #c94949;
  --shadow: 0 18px 45px rgba(18, 41, 32, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, "Segoe UI", "Microsoft YaHei", Arial, sans-serif;
}

button,
input {
  font: inherit;
}

.app-shell {
  display: grid;
  grid-template-columns: 236px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  background: #12251f;
  color: #f8fffb;
  padding: 24px 18px;
  display: flex;
  flex-direction: column;
  gap: 32px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  background: var(--green);
  color: white;
  border-radius: 8px;
  font-weight: 800;
}

.brand strong,
.brand span {
  display: block;
}

.brand span:last-child {
  color: #9db5ad;
  font-size: 13px;
  margin-top: 2px;
}

.tabs {
  display: grid;
  gap: 8px;
}

.tab {
  width: 100%;
  border: 0;
  border-radius: 8px;
  padding: 12px;
  color: #cce0d8;
  background: transparent;
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  text-align: left;
}

.tab:hover,
.tab.active {
  color: white;
  background: rgba(255, 255, 255, 0.1);
}

.tab span:first-child {
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
}

.workspace {
  padding: 28px;
  min-width: 0;
}

.topbar,
.section-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 18px;
  margin-bottom: 22px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--green-dark);
  font-size: 13px;
  font-weight: 700;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: 30px;
}

h2 {
  margin-bottom: 0;
  font-size: 22px;
}

h3 {
  font-size: 17px;
}

.actions {
  display: flex;
  align-items: end;
  gap: 12px;
}

.total-input {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
}

input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  color: var(--text);
  background: white;
  outline: none;
}

input:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(0, 168, 112, 0.12);
}

.total-input input {
  width: 180px;
}

.icon-button {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  color: var(--text);
  min-height: 42px;
  padding: 0 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
}

.icon-button.primary {
  border-color: var(--green);
  background: var(--green);
  color: white;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(450px, 1fr));
  gap: 18px;
  margin-bottom: 18px;
}

.donut-panel,
.metric,
.asset-card,
.pool-card,
.rules-card,
.rule-strip,
.holdings-panel,
.snapshot-card,
.pending-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.donut-panel {
  min-height: 320px;
  padding: 22px;
  display: flex;
  justify-content: center;
  align-items: center;
}

.donut-panel > div:last-child {
  display: none;
}

.donut-wrap {
  position: relative;
  width: 180px;
  height: 180px;
}

.donut-wrap.labeled {
  width: 360px;
  height: 300px;
}

.pie-svg {
  width: 360px;
  height: 300px;
  display: block;
  overflow: visible;
}

.pie-slice {
  stroke: white;
  stroke-width: 2;
}

.pie-label-line {
  stroke: #8b9892;
  stroke-width: 1;
  fill: none;
}

.pie-label-text {
  fill: var(--text);
  font-size: 11px;
  font-weight: 700;
}

.pie-label-sub {
  fill: var(--muted);
  font-size: 10px;
}

.donut {
  width: 180px;
  height: 180px;
  border-radius: 50%;
  background: conic-gradient(var(--green) 0deg, var(--line) 0deg);
}

.donut::after {
  content: "";
  position: absolute;
  inset: 34px;
  background: white;
  border-radius: 50%;
}

.donut-center {
  position: absolute;
  left: 130px;
  top: 100px;
  width: 100px;
  height: 100px;
  display: grid;
  place-content: center;
  text-align: center;
  background: white;
  border-radius: 50%;
  pointer-events: none;
}

.donut-center span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.donut-center strong {
  font-size: 20px;
  margin-top: 4px;
}

.donut-title {
  margin-bottom: 12px;
}

.legend {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 9px;
  max-height: none;
  overflow: visible;
}

.legend-row {
  display: grid;
  grid-template-columns: 14px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  color: var(--muted);
  font-size: 13px;
}

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

.legend-row strong {
  color: var(--text);
  grid-column: 2;
  font-size: 13px;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.metric {
  padding: 18px;
  min-height: 112px;
  display: grid;
  align-content: space-between;
}

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

.metric strong {
  font-size: 22px;
}

.asset-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(220px, 1fr));
  gap: 14px;
}

.asset-card,
.pool-card,
.rules-card {
  padding: 16px;
}

.asset-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 14px;
}

.asset-head h3 {
  margin-bottom: 4px;
}

.asset-role,
.instrument,
.rules-card li,
.rule-strip span {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

.pct-pill {
  border-radius: 999px;
  padding: 4px 8px;
  color: white;
  font-size: 12px;
  font-weight: 800;
  flex: 0 0 auto;
}

.progress-track {
  height: 10px;
  border-radius: 999px;
  background: #e8efeb;
  overflow: hidden;
  margin: 14px 0;
}

.progress-track.slim {
  height: 7px;
  margin: 8px 0;
}

.progress-bar {
  height: 100%;
  border-radius: inherit;
}

.dca-box,
.review-box {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  margin: 12px 0;
  background: #fbfdfc;
}

.dca-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
  font-size: 13px;
}

.dca-head span {
  color: var(--green-dark);
  font-weight: 800;
}

.dca-grid {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.review-box {
  display: grid;
  gap: 4px;
}

.review-box strong {
  color: var(--red);
  font-size: 13px;
}

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

.asset-stats {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin-bottom: 12px;
}

.stat {
  background: var(--panel-soft);
  border-radius: 8px;
  padding: 10px;
}

.stat span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 4px;
}

.stat strong {
  font-size: 15px;
}

.amount-row {
  display: grid;
  gap: 7px;
  margin-top: 12px;
}

.amount-row label,
.pool-card label {
  color: var(--muted);
  font-size: 12px;
}

.warning {
  color: var(--red);
}

.ok {
  color: var(--green-dark);
}

.pool-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(210px, 1fr));
  gap: 14px;
}

.pool-card {
  display: grid;
  gap: 12px;
}

.pool-card h3 {
  margin-bottom: 0;
}

.pool-card p {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
  margin-bottom: 0;
}

.rule-strip {
  margin-top: 16px;
  padding: 16px;
  display: flex;
  gap: 12px;
  align-items: flex-start;
}

.rules-layout {
  display: grid;
  grid-template-columns: minmax(300px, 0.9fr) minmax(320px, 1.1fr);
  gap: 16px;
}

.timeline {
  display: grid;
  gap: 12px;
}

.timeline-item {
  display: grid;
  grid-template-columns: 56px minmax(0, 1fr);
  gap: 12px;
  align-items: start;
}

.timeline-badge {
  width: 56px;
  height: 36px;
  display: grid;
  place-items: center;
  background: var(--panel-soft);
  color: var(--green-dark);
  border-radius: 8px;
  font-weight: 800;
}

.timeline-item p {
  margin: 7px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.rules-card ul {
  margin: 0;
  padding-left: 18px;
}

.inline-section {
  margin-top: 26px;
}

.snapshot-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(180px, 1fr));
  gap: 14px;
  margin-bottom: 14px;
}

.pending-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(220px, 1fr));
  gap: 14px;
}

.pending-card {
  padding: 16px;
  display: grid;
  gap: 12px;
}

.pending-card h3 {
  margin-bottom: 2px;
}

.pending-card p {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.pending-value {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 10px;
  border-radius: 8px;
  background: var(--panel-soft);
}

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

.pending-value strong {
  font-size: 15px;
}

.snapshot-card {
  padding: 16px;
  min-height: 96px;
  display: grid;
  align-content: space-between;
}

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

.snapshot-card strong {
  font-size: 21px;
}

.holdings-panel {
  padding: 16px;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 12px;
}

.panel-head h3 {
  margin-bottom: 0;
}

.panel-head span {
  color: var(--muted);
  font-size: 13px;
  text-align: right;
}

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

.holding-row {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) 110px 120px 120px minmax(120px, 0.7fr) 40px;
  gap: 12px;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdfc;
}

.holding-main strong,
.holding-cell strong {
  display: block;
}

.holding-main span,
.holding-cell span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-top: 3px;
}

.map-pill {
  display: inline-flex;
  min-height: 28px;
  align-items: center;
  border-radius: 999px;
  padding: 0 10px;
  color: var(--green-dark);
  background: var(--panel-soft);
  font-size: 12px;
  font-weight: 700;
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  background: #12251f;
  color: white;
  border-radius: 8px;
  padding: 12px 14px;
  opacity: 0;
  transform: translateY(12px);
  transition: 0.2s ease;
  pointer-events: none;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

@media (max-width: 1180px) {
  .summary-grid {
    grid-template-columns: 1fr;
  }

  .asset-grid {
    grid-template-columns: repeat(2, minmax(220px, 1fr));
  }

  .pool-grid {
    grid-template-columns: repeat(2, minmax(220px, 1fr));
  }

  .snapshot-grid,
  .pending-grid {
    grid-template-columns: repeat(2, minmax(220px, 1fr));
  }

  .holding-row {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 860px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: sticky;
    top: 0;
    z-index: 2;
    padding: 14px;
    gap: 14px;
  }

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

  .tab {
    justify-content: center;
  }

  .workspace {
    padding: 18px;
  }

  .topbar,
  .section-title,
  .actions {
    align-items: stretch;
    flex-direction: column;
  }

  .total-input input {
    width: 100%;
  }

  .summary-grid,
  .donut-panel,
  .rules-layout {
    grid-template-columns: 1fr;
  }

  .donut-wrap {
    margin: 0 auto;
  }

  .donut-wrap.labeled,
  .pie-svg {
    width: 320px;
    height: 280px;
  }

  .donut-center {
    left: 110px;
    top: 90px;
  }
}

@media (max-width: 560px) {
  .asset-grid,
  .pool-grid,
  .metrics,
  .snapshot-grid,
  .pending-grid {
    grid-template-columns: 1fr;
  }

  .holding-row {
    grid-template-columns: 1fr;
  }

  h1 {
    font-size: 25px;
  }

  .tab span:last-child {
    display: none;
  }
}

/* ========================================
   高级模态弹窗与表单样式 (手动录入持仓)
   ======================================== */
.modal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(18, 37, 31, 0.45);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.modal.active {
  display: flex;
  opacity: 1;
}

.modal-content {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  width: 480px;
  max-width: 95vw;
  padding: 24px;
  box-shadow: 0 20px 45px rgba(18, 41, 32, 0.15);
  transform: translateY(15px);
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal.active .modal-content {
  transform: translateY(0);
}

.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 6px;
  font-weight: 600;
}

.form-row {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
  margin-bottom: 16px;
}

select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  color: var(--text);
  background: white;
  outline: none;
  appearance: none;
  background-image: url("data:image/svg+xml;charset=UTF-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2369746f' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 16px;
}

select:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(0, 168, 112, 0.12);
}

.btn-group {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 24px;
}

.delete-holding-btn {
  background: transparent;
  border: none;
  color: var(--red);
  font-size: 16px;
  cursor: pointer;
  padding: 6px;
  display: grid;
  place-items: center;
  border-radius: 6px;
  transition: background 0.2s, color 0.2s;
}

.delete-holding-btn:hover {
  background: rgba(201, 73, 73, 0.08);
  color: #b03535;
}

.edit-holding-btn {
  background: transparent;
  border: none;
  color: var(--blue);
  font-size: 16px;
  cursor: pointer;
  padding: 6px;
  display: grid;
  place-items: center;
  border-radius: 6px;
  transition: background 0.2s, color 0.2s;
}

.edit-holding-btn:hover {
  background: rgba(49, 120, 198, 0.08);
  color: #215ea3;
}

/* ========================================
   自定义汇率输入框样式
   ======================================== */
input.fx-input {
  width: 120px;
  font-size: 22px;
  font-weight: 800;
  background: transparent !important;
  border: none !important;
  border-bottom: 1px dashed var(--line) !important;
  border-radius: 0 !important;
  padding: 2px 0 !important;
  color: var(--text) !important;
  outline: none !important;
  margin-top: 4px;
}

input.fx-input:focus {
  border-bottom: 2px solid var(--green) !important;
  box-shadow: none !important;
}

