:root {
  color-scheme: light;
  --ink: #172018;
  --muted: #637064;
  --line: #d7ded6;
  --paper: #f8faf6;
  --panel: #ffffff;
  --green: #1d7f4f;
  --red: #c74343;
  --teal: #127482;
  --gold: #b98216;
  --shadow: 0 18px 50px rgba(23, 32, 24, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  font-family: Inter, "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  color: var(--ink);
  background:
    linear-gradient(180deg, rgba(29, 127, 79, 0.08), transparent 280px),
    var(--paper);
}

button,
input {
  font: inherit;
}

.app-shell {
  width: min(1440px, calc(100% - clamp(20px, 4vw, 56px)));
  margin: 0 auto;
  padding: clamp(16px, 3vw, 34px) 0 clamp(28px, 5vw, 52px);
}

.intro {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr));
  gap: clamp(16px, 3vw, 28px);
  align-items: end;
  padding: clamp(18px, 4vw, 34px) 0 clamp(16px, 3vw, 24px);
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--green);
  font-weight: 700;
}

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

h1 {
  max-width: 760px;
  margin-bottom: 12px;
  font-size: clamp(2rem, 6vw, 4.8rem);
  line-height: 1.02;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 4px;
  font-size: 1.08rem;
}

.intro-copy {
  max-width: 720px;
  margin-bottom: 0;
  color: var(--muted);
  font-size: 1.05rem;
  line-height: 1.7;
}

.market-strip {
  display: grid;
  gap: 4px;
  min-width: min(100%, 170px);
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.72);
}

.market-strip span,
.metric-card span {
  color: var(--muted);
  font-size: 0.86rem;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 190px), 1fr));
  gap: 14px;
  margin-bottom: 16px;
}

.metric-card,
.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.metric-card {
  display: grid;
  gap: 8px;
  padding: 18px;
}

.metric-card strong {
  font-size: clamp(1.25rem, 3vw, 1.85rem);
}

.workspace {
  display: grid;
  grid-template-columns: minmax(min(100%, 300px), 0.34fr) minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.panel {
  padding: 18px;
}

.panel-heading {
  margin-bottom: 16px;
}

.heading-row {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: start;
  flex-wrap: wrap;
}

.panel-heading p {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.5;
}

.form-panel {
  display: grid;
  gap: 14px;
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 0.9rem;
}

input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 11px 12px;
  color: var(--ink);
  background: #fbfcfa;
}

input:focus {
  outline: 3px solid rgba(18, 116, 130, 0.16);
  border-color: var(--teal);
}

.file-import {
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 11px 12px;
  color: var(--green);
  background: #fbfcfa;
  cursor: pointer;
}

.file-import input {
  margin-top: 8px;
  border: 0;
  padding: 0;
  background: transparent;
}

.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 140px), 1fr));
  gap: 12px;
}

button {
  min-height: 44px;
  border: 1px solid var(--green);
  border-radius: 8px;
  padding: 10px 14px;
  color: white;
  background: var(--green);
  cursor: pointer;
}

.secondary-button {
  color: var(--green);
  background: white;
}

.compact-button {
  min-height: 36px;
  white-space: nowrap;
}

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

table {
  width: 100%;
  border-collapse: collapse;
  table-layout: auto;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 12px 8px;
  text-align: left;
  vertical-align: middle;
  overflow-wrap: anywhere;
}

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

.fund-name {
  display: grid;
  gap: 3px;
  min-width: min(100%, 220px);
}

.fund-name small {
  color: var(--muted);
}

.inline-edit {
  width: 100%;
  border-color: transparent;
  padding: 4px 2px;
  background: transparent;
}

.inline-edit:hover,
.inline-edit:focus {
  border-color: var(--line);
  background: #fbfcfa;
}

.inline-edit.name-inline {
  min-width: 0;
  color: var(--ink);
  font-weight: 700;
}

.cost-cell {
  display: grid;
  gap: 4px;
  min-width: min(100%, 118px);
}

.cost-check {
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.35;
}

.cost-check.is-large-gap {
  color: var(--red);
  font-weight: 700;
}

.warning-text {
  color: var(--gold) !important;
}

.gain {
  color: var(--red);
  font-weight: 700;
}

.loss {
  color: var(--green);
  font-weight: 700;
}

.delete-button {
  min-height: 34px;
  border-color: transparent;
  padding: 6px 10px;
  color: var(--muted);
  background: transparent;
}

.row-actions {
  display: flex;
  gap: 6px;
  justify-content: flex-end;
  flex-wrap: wrap;
}

.row-actions button {
  min-height: 34px;
  padding: 6px 10px;
}

.table-input {
  min-width: min(100%, 96px);
  padding: 8px 9px;
}

.table-input.name-input {
  min-width: min(100%, 190px);
}

.empty-state {
  margin: 16px 0 0;
  color: var(--muted);
}

.insight-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 320px), 1fr));
  gap: 16px;
  margin-top: 16px;
}

.bar-list {
  display: grid;
  gap: 12px;
}

.bar-item {
  display: grid;
  gap: 7px;
}

.bar-meta {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  font-size: 0.92rem;
}

.bar-track {
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: #e8eee7;
}

.bar-fill {
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--teal), var(--gold));
}

.disclaimer {
  margin-top: 16px;
  border-left: 4px solid var(--gold);
  padding: 14px 16px;
  color: var(--muted);
  line-height: 1.7;
  background: rgba(255, 255, 255, 0.68);
}

.disclaimer strong {
  color: var(--ink);
}

@media (max-width: 860px) {
  .intro,
  .workspace {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 700px) {
  .app-shell {
    width: min(100% - 20px, 1440px);
    padding-top: 14px;
  }

  .heading-row {
    display: flex;
    align-items: stretch;
  }

  .panel,
  .metric-card {
    padding: 14px;
  }

  table,
  thead,
  tbody,
  tr,
  th,
  td {
    display: block;
  }

  thead {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
  }

  tr {
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 10px;
    background: #fbfcfa;
  }

  tr + tr {
    margin-top: 12px;
  }

  td {
    display: grid;
    grid-template-columns: minmax(96px, 0.42fr) minmax(0, 1fr);
    gap: 12px;
    align-items: start;
    border-bottom: 0;
    padding: 8px 0;
  }

  td::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: 0.82rem;
    font-weight: 600;
  }

  td:first-child {
    grid-template-columns: 1fr;
  }

  td:first-child::before {
    display: none;
  }

  .row-actions {
    justify-content: flex-start;
  }
}
