:root {
  color-scheme: light;
  --bg: #f3f5f1;
  --surface: #ffffff;
  --surface-muted: #eef2ea;
  --text: #17201b;
  --muted: #687268;
  --line: #dce3d9;
  --accent: #0d6b57;
  --accent-2: #b84f32;
  --accent-3: #315f9a;
  --good: #0b7a4b;
  --bad: #b83d31;
  --warning: #af7a12;
  --shadow: 0 18px 45px rgba(22, 32, 27, 0.1);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(135deg, rgba(13, 107, 87, 0.08), transparent 34%),
    linear-gradient(315deg, rgba(184, 79, 50, 0.08), transparent 30%),
    var(--bg);
  color: var(--text);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    "Microsoft YaHei", sans-serif;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

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

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 28px;
  padding: 28px 22px;
  border-right: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.78);
  backdrop-filter: blur(18px);
}

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

.brand-mark {
  display: grid;
  width: 48px;
  height: 48px;
  place-items: center;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-weight: 800;
}

.brand h1,
.brand p,
.section-head h3,
.section-head p,
.topbar h2,
.eyebrow {
  margin: 0;
}

.brand h1 {
  font-size: 20px;
  line-height: 1.1;
}

.brand p,
.section-head p,
.eyebrow,
.panel-label,
.metric-card span,
.fund-meta,
.history-row small,
.holding-strip,
.trade-item span,
.form-hint {
  color: var(--muted);
}

.brand p {
  margin-top: 4px;
  font-size: 13px;
}

.nav-list {
  display: grid;
  gap: 8px;
}

.nav-item,
.segment,
.icon-button,
.action-button,
.close-button {
  border: 1px solid transparent;
  background: transparent;
  color: var(--text);
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 42px;
  padding: 8px 10px;
  border-radius: 8px;
  text-align: left;
}

.nav-icon,
.icon-button,
.close-button {
  display: grid;
  place-items: center;
}

.nav-icon {
  width: 24px;
  height: 24px;
  border-radius: 6px;
  background: var(--surface-muted);
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
}

.nav-item.active {
  border-color: rgba(13, 107, 87, 0.16);
  background: #e7f1ed;
  color: var(--accent);
  font-weight: 700;
}

.side-panel {
  margin-top: auto;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.panel-label {
  font-size: 13px;
}

.temperature {
  margin-top: 8px;
  font-size: 36px;
  font-weight: 800;
  line-height: 1;
}

.temperature small {
  color: var(--muted);
  font-size: 15px;
  font-weight: 600;
}

.temperature-bar {
  height: 8px;
  margin-top: 14px;
  overflow: hidden;
  border-radius: 99px;
  background: var(--surface-muted);
}

.temperature-bar span {
  display: block;
  width: 40%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
}

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

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

.eyebrow {
  font-size: 13px;
  font-weight: 700;
}

.topbar h2 {
  margin-top: 4px;
  font-size: 34px;
  letter-spacing: 0;
}

.toolbar,
.segmented-control,
.fund-actions,
.score-row,
.risk-row,
.date-field {
  display: flex;
  align-items: center;
}

.toolbar {
  gap: 10px;
}

.date-field {
  gap: 8px;
  min-height: 42px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.date-field input {
  width: 142px;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
}

.icon-button,
.close-button {
  width: 42px;
  height: 42px;
  border-radius: 8px;
  border-color: var(--line);
  background: var(--surface);
  font-weight: 800;
}

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

.metric-card,
.fund-card,
.history-list-wrap,
.history-detail,
.position-panel,
.trade-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.86);
  box-shadow: 0 10px 28px rgba(22, 32, 27, 0.05);
}

.metric-card {
  padding: 16px;
}

.metric-card span {
  display: block;
  font-size: 13px;
}

.metric-card strong {
  display: block;
  margin-top: 8px;
  font-size: 25px;
}

.content-view {
  display: none;
}

.content-view.active {
  display: block;
}

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

.section-head.compact {
  margin-bottom: 12px;
}

.section-head h3 {
  font-size: 20px;
}

.section-head p {
  margin-top: 5px;
  font-size: 13px;
}

.segmented-control {
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.segment {
  min-width: 54px;
  min-height: 32px;
  border-radius: 6px;
  color: var(--muted);
  font-weight: 700;
}

.segment.active {
  background: var(--accent);
  color: #fff;
}

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

.fund-card {
  display: grid;
  gap: 14px;
  padding: 18px;
}

.fund-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.fund-name {
  margin: 0;
  font-size: 18px;
  line-height: 1.35;
}

.fund-code {
  display: inline-flex;
  margin-top: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.score-pill {
  min-width: 64px;
  padding: 8px 10px;
  border-radius: 8px;
  background: #e7f1ed;
  color: var(--accent);
  text-align: center;
  font-weight: 800;
}

.score-pill span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.fund-meta {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  font-size: 12px;
}

.fund-meta strong {
  display: block;
  margin-top: 3px;
  color: var(--text);
  font-size: 15px;
}

.trend {
  height: 66px;
  overflow: hidden;
  border-radius: 8px;
  background: linear-gradient(180deg, #f7faf6, #edf3eb);
}

.trend svg {
  width: 100%;
  height: 100%;
}

.recommendation-copy {
  margin: 0;
  color: #334139;
  font-size: 14px;
  line-height: 1.7;
}

.risk-row,
.score-row {
  justify-content: space-between;
  gap: 10px;
}

.risk-tag {
  padding: 5px 8px;
  border-radius: 999px;
  background: var(--surface-muted);
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.risk-tag.low {
  background: #dff1e8;
  color: var(--good);
}

.risk-tag.medium {
  background: #fff0d2;
  color: var(--warning);
}

.risk-tag.high {
  background: #f8ded9;
  color: var(--bad);
}

.advice-tag {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 4px 9px;
  border-radius: 999px;
  background: var(--surface-muted);
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.advice-tag.buy {
  background: #dff1e8;
  color: var(--good);
}

.advice-tag.hold {
  background: #e2ecfb;
  color: var(--accent-3);
}

.advice-tag.sell {
  background: #f8ded9;
  color: var(--bad);
}

.advice-tag.watch {
  background: #fff0d2;
  color: var(--warning);
}

.holding-strip {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  background: #f7faf6;
  font-size: 13px;
  font-weight: 700;
}

.fund-actions {
  gap: 8px;
}

.action-button {
  min-height: 36px;
  padding: 0 12px;
  border-radius: 8px;
  border-color: var(--line);
  background: var(--surface);
  color: var(--text);
  font-weight: 800;
}

.action-button.primary {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

.action-button.buy {
  border-color: rgba(11, 122, 75, 0.3);
  background: #eef8f3;
  color: var(--good);
}

.action-button.sell {
  border-color: rgba(184, 61, 49, 0.25);
  background: #fff1ef;
  color: var(--bad);
}

.action-button.wide {
  width: 100%;
  min-height: 44px;
}

.portfolio-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(320px, 0.65fr);
  gap: 14px;
}

.position-panel,
.trade-panel {
  padding: 18px;
}

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

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

.trade-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.trade-item strong,
.trade-item span {
  display: block;
}

.trade-item span {
  margin-top: 4px;
  font-size: 12px;
}

.trade-item b {
  white-space: nowrap;
}

.trade-item b.buy {
  color: var(--good);
}

.trade-item b.sell {
  color: var(--bad);
}

.history-layout {
  display: grid;
  grid-template-columns: minmax(240px, 320px) minmax(0, 1fr);
  gap: 14px;
}

.history-list-wrap,
.history-detail {
  padding: 18px;
}

.history-list {
  display: grid;
  gap: 8px;
}

.history-row {
  width: 100%;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  text-align: left;
}

.history-row.active {
  border-color: rgba(13, 107, 87, 0.35);
  background: #e7f1ed;
}

.history-row strong,
.history-row small {
  display: block;
}

.history-row small {
  margin-top: 4px;
}

.mini-chart {
  height: 210px;
  margin-bottom: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(180deg, #ffffff, #f4f7f1);
}

.mini-chart svg {
  width: 100%;
  height: 100%;
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
  font-size: 14px;
}

th,
td {
  padding: 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  white-space: nowrap;
}

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

tr:last-child td {
  border-bottom: 0;
}

.up {
  color: var(--good);
  font-weight: 800;
}

.down {
  color: var(--bad);
  font-weight: 800;
}

.empty-state {
  padding: 26px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.55);
  color: var(--muted);
  text-align: center;
}

.fund-dialog {
  width: min(720px, calc(100vw - 28px));
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.trade-dialog {
  width: min(560px, calc(100vw - 28px));
}

.fund-dialog::backdrop {
  background: rgba(10, 16, 14, 0.38);
  backdrop-filter: blur(3px);
}

.close-button {
  position: absolute;
  top: 14px;
  right: 14px;
}

.dialog-body {
  display: grid;
  gap: 18px;
  padding: 14px;
}

.dialog-title {
  padding-right: 44px;
}

.dialog-title h3 {
  margin: 0;
  font-size: 26px;
}

.dialog-title p {
  margin: 6px 0 0;
  color: var(--muted);
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}

.detail-cell {
  padding: 12px;
  border-radius: 8px;
  background: var(--surface-muted);
}

.detail-cell span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.detail-cell strong {
  display: block;
  margin-top: 4px;
  font-size: 17px;
}

.rationale-list {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.rationale-list li {
  padding: 10px 12px;
  border-left: 3px solid var(--accent);
  background: #f5f8f3;
  color: #334139;
  line-height: 1.55;
}

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

.form-grid label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.form-grid input {
  width: 100%;
  min-height: 42px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  outline: 0;
  color: var(--text);
}

.form-grid input:focus {
  border-color: rgba(13, 107, 87, 0.55);
  box-shadow: 0 0 0 3px rgba(13, 107, 87, 0.12);
}

.form-hint {
  margin: 0;
  padding: 10px 12px;
  border-radius: 8px;
  background: #f7faf6;
  font-size: 13px;
  line-height: 1.6;
}

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

  .sidebar {
    position: sticky;
    top: 0;
    z-index: 4;
    flex-direction: row;
    align-items: center;
    padding: 14px;
    overflow-x: auto;
  }

  .nav-list {
    display: flex;
  }

  .side-panel {
    display: none;
  }

  .workspace {
    padding: 20px;
  }

  .metrics-grid,
  .fund-grid,
  .portfolio-layout {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 720px) {
  .topbar,
  .section-head {
    align-items: stretch;
    flex-direction: column;
  }

  .toolbar {
    justify-content: space-between;
  }

  .topbar h2 {
    font-size: 28px;
  }

  .metrics-grid,
  .fund-grid,
  .history-layout,
  .detail-grid,
  .portfolio-layout,
  .form-grid {
    grid-template-columns: 1fr;
  }

  .fund-meta {
    grid-template-columns: 1fr;
  }

  .sidebar {
    gap: 14px;
  }

  .brand p {
    display: none;
  }
}
