:root {
  color-scheme: light;
  --bg: #f4f6f3;
  --panel: #ffffff;
  --panel-muted: #f0f4f2;
  --line: #d6dfdc;
  --line-strong: #b7c5c0;
  --text: #15201d;
  --muted: #53615d;
  --subtle: #77837f;
  --accent: #146b5d;
  --accent-hover: #0d3d36;
  --accent-2: #2d5a8f;
  --danger: #b42318;
  --success: #147253;
  --focus: #2f5f96;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 14px;
  -webkit-text-size-adjust: 100%;
}

body::before {
  content: "";
  position: fixed;
  inset: 0 0 auto;
  height: 160px;
  background: #eaf0ec;
  border-bottom: 1px solid rgba(214, 223, 220, 0.65);
  pointer-events: none;
  z-index: -1;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 16px 24px;
  border-bottom: 1px solid var(--line);
  background: rgba(251, 252, 251, 0.95);
  backdrop-filter: blur(12px);
}

h1 {
  margin: 0 0 4px;
  font-size: 22px;
  font-weight: 760;
  line-height: 1.2;
}

p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.actions,
.add-form {
  display: flex;
  align-items: center;
  gap: 10px;
}

.portal {
  display: grid;
  grid-template-columns: minmax(360px, 1.25fr) minmax(220px, 0.62fr) minmax(220px, 0.62fr);
  gap: 14px;
  padding: 18px 24px 0;
}

.hero-portal {
  align-items: stretch;
}

.portal-main {
  min-height: 176px;
  padding: 20px;
  border: 1px solid #9fc8bf;
  border-radius: 8px;
  background: #e8f3ef;
  box-shadow: 0 1px 2px rgba(21, 32, 29, 0.06);
}

.portal-main span {
  display: block;
  margin-bottom: 8px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 850;
  letter-spacing: 0.04em;
}

.portal-main h2 {
  margin: 0;
  color: var(--text);
  font-size: 26px;
  line-height: 1.22;
}

.portal-main p {
  max-width: 58rem;
  margin-top: 10px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.6;
}

.portal-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 16px;
}

.portal-button {
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  padding: 0 14px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  text-decoration: none;
  font-size: 14px;
  font-weight: 800;
}

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

.portal-button:hover {
  border-color: var(--accent);
}

.portal-button.primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

.portal-card,
.portal-note {
  min-height: 124px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 1px 2px rgba(21, 32, 29, 0.05);
}

.portal-card {
  display: block;
  color: var(--text);
  text-decoration: none;
}

.portal-card:hover {
  border-color: var(--line-strong);
  background: #fbfcfb;
}

.portal-card.primary {
  border-color: #9fc8bf;
  background: #f2faf7;
}

.portal-card span {
  display: block;
  margin-bottom: 8px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.04em;
}

.portal-card strong,
.portal-note b {
  display: block;
  color: var(--text);
  font-size: 18px;
  line-height: 1.25;
}

.portal-card p,
.portal-note p {
  margin-top: 8px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

.portal-note {
  background: rgba(240, 244, 242, 0.86);
}

.nav-link {
  height: 36px;
  display: inline-flex;
  align-items: center;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--text);
  text-decoration: none;
  font-size: 13px;
  font-weight: 700;
}

.nav-link:hover {
  border-color: var(--line-strong);
  background: #f8faf9;
}

label {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
  font-size: 13px;
  font-weight: 650;
}

input,
select,
button {
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  font: inherit;
}

input,
select {
  padding: 0 10px;
}

input::placeholder {
  color: #66756f;
}

input:focus-visible,
select:focus-visible,
button:focus-visible,
.line-toggle:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

button {
  padding: 0 14px;
  border-color: var(--accent);
  background: var(--accent);
  color: white;
  cursor: pointer;
  font-weight: 650;
}

button:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

button:disabled {
  cursor: wait;
  opacity: 0.65;
}

.layout {
  display: grid;
  grid-template-columns: 296px 1fr;
  min-height: calc(100vh - 73px);
  margin-top: 16px;
}

.sidebar {
  padding: 16px;
  border-right: 1px solid var(--line);
  background: rgba(240, 244, 242, 0.86);
}

.add-form {
  align-items: stretch;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 14px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.chain-note {
  margin: -4px 0 14px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.market {
  color: var(--accent-2);
  font-size: 12px;
  font-weight: 750;
}

.content {
  min-width: 0;
  padding: 16px 18px 28px;
}

.status {
  min-height: 20px;
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 13px;
}

.chart-wrap {
  position: relative;
  width: 100%;
  height: 440px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 1px 2px rgba(21, 32, 29, 0.05);
  overflow: hidden;
}

.chart-tooltip {
  position: absolute;
  z-index: 2;
  max-width: 300px;
  padding: 10px 12px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 4px 12px rgba(23, 32, 30, 0.12);
  color: var(--text);
  font-size: 12px;
  line-height: 1.55;
  pointer-events: none;
}

.tooltip-title {
  margin-bottom: 3px;
  font-size: 13px;
  font-weight: 750;
}

.tooltip-muted {
  color: var(--muted);
}

canvas {
  display: block;
  width: 100%;
  height: 100%;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.table-wrap {
  max-height: 520px;
  margin-top: 14px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

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

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f0f4f2;
  color: var(--text);
  font-weight: 720;
}

tbody tr:hover td {
  background: #f7faf9;
}

.section-row td {
  position: sticky;
  top: 36px;
  z-index: 1;
  padding: 8px 10px;
  border-top: 1px solid var(--line-strong);
  border-bottom: 1px solid var(--line);
  background: #e6f0ee;
  color: var(--accent-hover);
  font-weight: 760;
  text-align: left;
}

th:nth-child(1),
th:nth-child(2),
th:nth-child(3),
th:nth-child(4),
th:nth-child(5),
th:nth-child(6),
td:nth-child(1),
td:nth-child(2),
td:nth-child(3),
td:nth-child(4),
td:nth-child(5),
td:nth-child(6) {
  text-align: left;
}

.line-toggle {
  width: 16px;
  height: 16px;
  vertical-align: middle;
}

.positive {
  color: var(--danger);
  font-weight: 750;
}

.negative {
  color: var(--success);
  font-weight: 750;
}

@media (max-width: 860px) {
  body {
    font-size: 13px;
  }

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

  .topbar {
    gap: 14px;
    padding: 14px 16px;
  }

  h1 {
    font-size: 24px;
  }

  p {
    max-width: 34rem;
    font-size: 13px;
    line-height: 1.45;
  }

  label {
    gap: 6px;
    font-size: 13px;
  }

  input,
  select,
  button {
    height: 34px;
  }

  .layout {
    grid-template-columns: 1fr;
    min-height: 0;
    margin-top: 12px;
  }

  .portal {
    grid-template-columns: 1fr;
    padding: 14px 16px 0;
  }

  .portal-main h2 {
    font-size: 22px;
  }

  .portal-button {
    width: 100%;
    justify-content: center;
  }

  .sidebar {
    padding: 12px 14px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .add-form {
    padding: 10px;
  }

  .content {
    padding: 12px 14px 22px;
  }

  .chart-wrap {
    height: 320px;
  }

  .table-wrap {
    max-height: 460px;
  }
}

@media (max-width: 520px) {
  .topbar {
    position: static;
  }

  h1 {
    font-size: 22px;
  }

  .chart-wrap {
    height: 300px;
  }

  th,
  td {
    padding: 8px 9px;
  }
}
