:root {
  --ink: #1d1d1f;
  --muted: #6e6e73;
  --subtle: #86868b;
  --line: #d2d2d7;
  --line-soft: #e8e8ed;
  --surface: #ffffff;
  --surface-soft: #f5f5f7;
  --surface-warm: #fbfbfd;
  --accent: #0071e3;
  --accent-soft: #e8f2ff;
  --success: #0b7f5f;
  --warning: #b54708;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.06);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--ink);
  background: var(--surface-soft);
}

button,
input,
select {
  font: inherit;
}

.app-shell {
  width: min(1180px, calc(100% - 40px));
  margin: 0 auto;
  padding: 22px 0 72px;
}

.hero {
  display: grid;
  gap: 56px;
  min-height: 320px;
  padding: 28px;
  border-radius: 8px;
  color: var(--ink);
  background: var(--surface);
}

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

.brand-row img {
  width: min(180px, 44vw);
  height: auto;
}

.brand-row p,
.brand-row strong {
  display: block;
  margin: 0;
}

.brand-row p {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.35;
  font-weight: 600;
}

.brand-row strong {
  margin-top: 3px;
  color: var(--ink);
  font-size: 15px;
  line-height: 1.35;
  font-weight: 700;
}

.hero-copy {
  max-width: 760px;
  align-self: end;
}

.hero h1 {
  margin: 0;
  font-size: clamp(54px, 7vw, 88px);
  line-height: 1.02;
  letter-spacing: 0;
  font-weight: 800;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
  font-weight: 700;
}

.fund-tabs,
.data-grid,
.workspace-grid,
.table-grid,
.result-grid {
  display: grid;
  gap: 12px;
}

.fund-tabs {
  grid-template-columns: repeat(3, 1fr);
  margin-top: 18px;
}

.fund-option {
  display: grid;
  gap: 8px;
  min-width: 0;
}

.fund-tab {
  width: 100%;
  min-height: 96px;
  padding: 18px;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  color: var(--ink);
  background: var(--surface);
  text-align: left;
  font-size: 21px;
  line-height: 1.25;
  font-weight: 760;
  cursor: pointer;
}

.fund-tab span {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.2;
  font-weight: 700;
}

.fund-tab:hover,
.fund-tab:focus-visible {
  border-color: #b9b9c0;
}

.fund-tab.is-active {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.fund-tab.is-active span {
  color: var(--accent);
}

.fund-source-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 8px 12px;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  color: var(--accent);
  background: var(--surface);
  text-align: center;
  text-decoration: none;
  font-size: 14px;
  line-height: 1.25;
  font-weight: 650;
}

.fund-source-link:hover,
.fund-source-link:focus-visible {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.data-grid {
  grid-template-columns: repeat(3, 1fr);
  margin-top: 18px;
}

.data-card,
.result-card,
.table-card,
.control-panel,
.rule-panel,
.chart-panel,
.notice {
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: var(--surface);
}

.data-card {
  min-height: 108px;
  padding: 18px;
}

.data-card span,
.result-card span {
  display: block;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.35;
  font-weight: 700;
}

.data-card strong,
.result-card strong {
  display: block;
  margin-top: 10px;
  color: var(--ink);
  font-size: clamp(26px, 2.8vw, 38px);
  line-height: 1.08;
  font-weight: 800;
}

.data-card strong.date-value,
.result-card strong.date-value {
  font-size: clamp(20px, 2vw, 28px);
}

.workspace-grid {
  grid-template-columns: minmax(340px, 0.85fr) 1.15fr;
  margin-top: 18px;
}

.control-panel,
.rule-panel,
.chart-panel,
.notice,
.simulation-panel {
  padding: 24px;
}

.simulation-panel {
  margin-top: 18px;
  border-radius: 8px;
  background: transparent;
}

.section-heading h2,
.table-card h3,
.notice h2 {
  margin: 0;
  color: var(--ink);
  line-height: 1.16;
  letter-spacing: 0;
  font-weight: 780;
}

.section-heading h2 {
  font-size: clamp(28px, 3vw, 42px);
}

.field {
  display: block;
  margin-top: 18px;
}

.field span,
.fixed-rule span {
  display: block;
  margin-bottom: 7px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.35;
  font-weight: 700;
}

.field div,
.fixed-rule strong {
  display: grid;
  align-items: center;
  min-height: 54px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-warm);
}

.field div {
  grid-template-columns: auto 1fr auto;
}

.field div.select-only {
  grid-template-columns: 1fr;
}

.field b {
  padding: 0 14px;
  color: var(--muted);
  font-size: 17px;
  font-weight: 700;
}

.field input,
.field select {
  width: 100%;
  min-width: 0;
  border: 0;
  outline: none;
  padding: 10px 10px;
  color: var(--ink);
  background: transparent;
  font-size: 28px;
  font-weight: 760;
  text-align: right;
}

.field select {
  appearance: none;
  cursor: pointer;
}

.field div.select-only select {
  text-align: left;
  padding-left: 14px;
}

.allocation-grid,
.settings-grid {
  display: grid;
  gap: 10px;
}

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

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

.field--small div,
.fixed-rule strong {
  min-height: 54px;
}

.field--small input,
.field--small select,
.fixed-rule strong {
  font-size: 24px;
}

.fixed-rule {
  display: grid;
  align-content: end;
  margin-top: 18px;
}

.fixed-rule strong {
  padding: 0 14px;
}

.helper-text {
  margin: 16px 0 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.6;
  font-weight: 600;
}

.helper-text.is-warning {
  color: var(--warning);
}

.rule-chips {
  display: grid;
  gap: 0;
  margin: 18px 0 0;
  padding: 0;
  border-top: 1px solid var(--line-soft);
  list-style: none;
}

.rule-chips li {
  display: grid;
  grid-template-columns: minmax(112px, 0.36fr) 1fr;
  gap: 16px;
  padding: 14px 0;
  border-bottom: 1px solid var(--line-soft);
}

.rule-chips strong,
.rule-chips span {
  display: block;
}

.rule-chips strong {
  color: var(--ink);
  font-size: 15px;
  line-height: 1.35;
  font-weight: 760;
}

.rule-chips span {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.45;
  font-weight: 600;
}

.panel-note {
  max-width: 900px;
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.65;
  font-weight: 600;
}

.result-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-top: 18px;
}

.result-card {
  min-height: 108px;
  padding: 18px;
}

.result-card--fee {
  background: #f7fbff;
}

.result-card--fee strong {
  color: var(--accent);
}

.result-card--secondary {
  background: var(--surface-warm);
}

.result-card--secondary strong {
  font-size: clamp(21px, 2vw, 28px);
}

.table-grid {
  grid-template-columns: 1fr;
  margin-top: 14px;
}

.table-card {
  padding: 18px;
}

.table-card--wide {
  grid-column: 1 / -1;
}

.table-card h3 {
  margin-bottom: 12px;
  font-size: 22px;
}

.table-scroll {
  overflow-x: auto;
}

.table-scroll--sticky {
  max-height: min(68vh, 680px);
  overflow: auto;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
}

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

.transaction-table {
  min-width: 1060px;
}

th,
td {
  padding: 12px 10px;
  border-bottom: 1px solid var(--line-soft);
  text-align: right;
  font-size: 15px;
  line-height: 1.35;
  font-weight: 600;
  white-space: nowrap;
}

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

th {
  color: var(--muted);
  background: var(--surface-warm);
  font-weight: 760;
}

.table-scroll--sticky th {
  position: sticky;
  top: 0;
  z-index: 2;
  box-shadow: 0 1px 0 var(--line-soft);
}

td {
  color: var(--ink);
  background: var(--surface);
}

.transaction-row--even td {
  background: #ffffff;
}

.transaction-row--odd td {
  background: #f7f7f8;
}

.transaction-row--first td {
  border-top: 1px solid #d2d2d7;
}

.transaction-row td:first-child {
  color: var(--ink);
  font-weight: 760;
}

.chart-panel {
  margin-top: 18px;
}

#navChart,
#portfolioChart {
  display: block;
  width: 100%;
  height: 360px;
  margin-top: 16px;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: var(--surface);
}

.notice {
  margin-top: 18px;
}

.notice h2 {
  font-size: 24px;
}

.notice p {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.75;
  font-weight: 600;
}

@media (max-width: 980px) {
  .app-shell {
    width: min(100% - 28px, 760px);
  }

  .hero {
    gap: 44px;
    min-height: 280px;
  }

  .fund-tabs,
  .data-grid,
  .workspace-grid,
  .allocation-grid,
  .settings-grid {
    grid-template-columns: 1fr;
  }

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

@media (max-width: 620px) {
  .app-shell {
    width: calc(100% - 24px);
    padding-top: 12px;
  }

  .hero,
  .control-panel,
  .rule-panel,
  .simulation-panel,
  .chart-panel,
  .notice {
    padding: 18px;
  }

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

  .brand-row img {
    width: min(170px, 64vw);
  }

  .hero h1 {
    font-size: 46px;
  }

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

  .rule-chips li {
    grid-template-columns: 1fr;
    gap: 4px;
  }

  #navChart,
  #portfolioChart {
    height: 320px;
  }
}
