:root,
html[data-theme="peach"] {
  --bg-top: #ffdab9;
  --bg-bottom: #ffcba4;
  --peach-top: var(--bg-top);
  --peach-bottom: var(--bg-bottom);
  --ink: #2c2c2c;
  --ink-muted: rgba(44, 44, 44, 0.66);
  --ink-soft: rgba(44, 44, 44, 0.46);
  --positive: #7a8b5e;
  --negative: #c27a5e;
  --glass: rgba(255, 255, 255, 0.42);
  --glass-border: rgba(255, 255, 255, 0.55);
  --shadow: 0 18px 50px rgba(120, 78, 48, 0.12);
  --row-hover: rgba(255, 255, 255, 0.22);
  --row-border: rgba(44, 44, 44, 0.06);
  --btn-solid-bg: var(--ink);
  --btn-solid-fg: #fff;
  --btn-solid-border: var(--ink);
  --radius-lg: 22px;
  --radius-pill: 999px;
}

html[data-theme="green"] {
  --bg-top: #3a5549;
  --bg-bottom: #324b42;
  --peach-top: var(--bg-top);
  --peach-bottom: var(--bg-bottom);
  --ink: #eef2ea;
  --ink-muted: rgba(238, 242, 234, 0.72);
  --ink-soft: rgba(238, 242, 234, 0.48);
  --positive: #b8d4a0;
  --negative: #e0a090;
  --glass: rgba(255, 255, 255, 0.1);
  --glass-border: rgba(255, 255, 255, 0.16);
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.28);
  --row-hover: rgba(255, 255, 255, 0.08);
  --row-border: rgba(255, 255, 255, 0.1);
  --btn-solid-bg: #eef2ea;
  --btn-solid-fg: #324b42;
  --btn-solid-border: #eef2ea;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: "Outfit", system-ui, sans-serif;
  color: var(--ink);
  background: linear-gradient(180deg, var(--bg-top) 0%, var(--bg-bottom) 100%);
  background-attachment: fixed;
}

.page {
  max-width: 980px;
  margin: 0 auto;
  padding: 28px 24px 40px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.glass {
  background: var(--glass);
  border: 1px solid var(--glass-border);
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

/* Header */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 56px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: var(--ink);
}

.brand-icon {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: var(--ink);
  color: #fff;
  display: grid;
  place-items: center;
}

.brand-icon svg {
  width: 18px;
  height: 18px;
}

.brand-name {
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.header-auth {
  display: flex;
  align-items: center;
  gap: 10px;
}

.theme-picker {
  position: relative;
}

.btn-icon {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  padding: 0;
  border: 1px solid rgba(44, 44, 44, 0.14);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.28);
  color: var(--ink);
  cursor: pointer;
  transition: transform 0.15s ease, background 0.15s ease;
}

html[data-theme="green"] .btn-icon {
  border-color: rgba(255, 255, 255, 0.16);
  background: rgba(255, 255, 255, 0.08);
}

.btn-icon:hover {
  transform: translateY(-1px);
  background: rgba(255, 255, 255, 0.38);
}

.btn-icon svg {
  width: 18px;
  height: 18px;
}

.theme-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 168px;
  padding: 8px;
  border-radius: 16px;
  background: var(--glass);
  border: 1px solid var(--glass-border);
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  z-index: 20;
}

.theme-option {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 12px;
  border: none;
  border-radius: 12px;
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: 0.9rem;
  cursor: pointer;
  text-align: left;
}

.theme-option:hover,
.theme-option.active {
  background: var(--row-hover);
}

.theme-swatch {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 1px solid rgba(44, 44, 44, 0.12);
  flex-shrink: 0;
}

.theme-swatch-peach {
  background: linear-gradient(180deg, #ffdab9, #ffcba4);
}

.theme-swatch-green {
  background: #324b42;
}

.btn {
  font: inherit;
  cursor: pointer;
  border-radius: var(--radius-pill);
  padding: 10px 22px;
  transition: transform 0.15s ease, opacity 0.15s ease;
}

.btn:hover {
  transform: translateY(-1px);
}

.btn-sm {
  padding: 8px 16px;
  font-size: 0.9rem;
}

.btn-block {
  width: 100%;
}

.btn-outline {
  border: 1px solid var(--ink);
  background: transparent;
  color: var(--ink);
}

.btn-solid {
  border: 1px solid var(--btn-solid-border);
  background: var(--btn-solid-bg);
  color: var(--btn-solid-fg);
}

/* Summary */
.main {
  flex: 1;
}

.summary {
  margin-bottom: 28px;
}

.summary-label {
  margin: 0 0 10px;
  font-size: 0.72rem;
  letter-spacing: 0.14em;
  color: var(--ink-muted);
  font-weight: 500;
}

.summary-row {
  display: flex;
  align-items: baseline;
  gap: 16px;
  flex-wrap: wrap;
}

.summary-value {
  margin: 0;
  font-size: clamp(2.4rem, 6vw, 3.4rem);
  font-weight: 600;
  letter-spacing: -0.03em;
  line-height: 1;
}

.summary-change {
  font-size: 1rem;
  font-weight: 500;
}

.positive {
  color: var(--positive);
}

.negative {
  color: var(--negative);
}

.wallet-chip {
  display: inline-block;
  margin: 14px 0 0;
  padding: 6px 14px;
  border-radius: var(--radius-pill);
  border: 1px solid rgba(44, 44, 44, 0.18);
  background: rgba(255, 255, 255, 0.25);
  font-size: 0.85rem;
}

.wallet-chip .mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.82rem;
  word-break: break-all;
}

.user-label {
  font-size: 0.88rem;
  color: var(--ink-muted);
  line-height: 1;
}

.protocol-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}

.protocol-tab {
  border: 1px solid rgba(255, 255, 255, 0.45);
  background: rgba(255, 255, 255, 0.28);
  color: var(--ink-muted);
  border-radius: var(--radius-pill);
  padding: 6px 14px;
  font: inherit;
  font-size: 0.82rem;
  cursor: pointer;
}

.protocol-tab.active {
  background: rgba(44, 44, 44, 0.08);
  color: var(--ink);
  border-color: rgba(44, 44, 44, 0.12);
}

/* Positions table */
.positions-card {
  border-radius: var(--radius-lg);
  padding: 18px 22px 10px;
}

.table-meta-row {
  display: grid;
  grid-template-columns: 2fr 1.1fr 0.7fr 1.15fr 0.75fr 1fr;
  gap: 16px;
  padding: 0 8px 10px;
}

.table-refreshed {
  grid-column: 5;
  justify-self: end;
  font-size: 0.68rem;
  letter-spacing: 0.12em;
  color: var(--ink-soft);
  font-weight: 500;
  white-space: nowrap;
}

.table-head,
.position-row {
  display: grid;
  grid-template-columns: 2fr 1.1fr 0.7fr 1.15fr 0.75fr 1fr;
  gap: 16px;
  align-items: center;
}

.table-head {
  padding: 0 8px 14px;
  font-size: 0.68rem;
  letter-spacing: 0.12em;
  color: var(--ink-soft);
  font-weight: 500;
}

.active-for {
  margin: 0;
  font-size: 0.78rem;
  line-height: 1.35;
  color: var(--ink-muted);
  font-weight: 400;
}

.active-for.muted {
  color: var(--ink-muted);
}

.apy-main {
  margin: 0;
  font-size: 0.92rem;
  font-weight: 500;
}

.apy-main.muted {
  color: var(--ink-muted);
}

.positions-section-label {
  padding: 18px 8px 10px;
  font-size: 0.68rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-soft);
  font-weight: 500;
}

.positions-section-label:first-child {
  padding-top: 4px;
}

.trend-main {
  margin: 0;
  font-size: 0.92rem;
  font-weight: 500;
}

.trend-main.muted {
  color: var(--ink-muted);
  font-size: 0.82rem;
}

.position-group {
  border-top: 1px solid var(--row-border);
}

.position-group:first-child {
  border-top: none;
}

.position-row {
  padding: 16px 8px;
}

.position-row-clickable {
  cursor: pointer;
  border-radius: 14px;
  transition: background 0.15s ease;
}

.position-row-clickable:hover,
.position-row-clickable.is-expanded {
  background: var(--row-hover);
}

.position-flows-panel {
  margin: 0 8px 12px 58px;
  padding: 12px 14px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.28);
  border: 1px solid rgba(255, 255, 255, 0.45);
}

.flows-panel-hint {
  margin: 0;
  font-size: 0.82rem;
  color: var(--ink-muted);
}

.flows-subtable {
  display: grid;
  gap: 0;
}

.flows-subtable-head,
.flows-subtable-row {
  display: grid;
  grid-template-columns: 1.1fr 1.2fr 0.9fr 1.4fr;
  gap: 12px;
  align-items: center;
}

.flows-subtable-head {
  padding-bottom: 10px;
  margin-bottom: 4px;
  border-bottom: 1px solid rgba(44, 44, 44, 0.06);
  font-size: 0.68rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.flows-subtable-row {
  padding: 10px 0;
  border-top: 1px solid rgba(44, 44, 44, 0.05);
}

.flows-subtable-row:first-of-type {
  border-top: none;
}

.flow-action {
  margin: 0;
  font-size: 0.9rem;
  font-weight: 600;
  text-transform: capitalize;
}

.flow-when {
  margin: 0;
  font-size: 0.78rem;
  color: var(--ink-muted);
}

.flow-tx-link {
  font-size: 0.82rem;
  color: var(--ink-muted);
  text-decoration: none;
}

.flow-tx-link:hover {
  color: var(--ink);
  text-decoration: underline;
}

.flow-amount {
  margin: 0;
  font-size: 0.88rem;
  line-height: 1.35;
}

.asset-cell {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.asset-icon {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.55);
  flex-shrink: 0;
  overflow: hidden;
}

.asset-icon .protocol-logo {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.asset-icon.protocol-fluid,
.asset-icon.protocol-fluid-lending {
  background: #fff;
}

.asset-icon.protocol-sky {
  background: #fff;
}

.asset-icon.protocol-morpho {
  background: #fff;
}

.asset-icon.protocol-aave {
  background: rgba(255, 255, 255, 0.55);
}

.asset-icon.protocol-default {
  background: rgba(255, 255, 255, 0.55);
}

.asset-name {
  margin: 0;
  font-size: 0.98rem;
  font-weight: 600;
}

.asset-amount {
  margin: 2px 0 0;
  font-size: 0.82rem;
  color: var(--ink-muted);
}

.value-main {
  margin: 0;
  font-weight: 600;
}

.value-sub {
  margin: 2px 0 0;
  font-size: 0.82rem;
  color: var(--ink-muted);
}

.sparkline {
  width: 100%;
  max-width: 92px;
  height: 28px;
}

.sparkline path {
  fill: none;
  stroke: rgba(44, 44, 44, 0.28);
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.pnl-main {
  margin: 0;
  font-weight: 600;
}

.pnl-sub {
  margin: 2px 0 0;
  font-size: 0.82rem;
}

/* Test bar */
.test-bar {
  margin-top: 22px;
  border-radius: var(--radius-lg);
  padding: 16px 18px;
}

.test-bar label {
  display: block;
  font-size: 0.72rem;
  letter-spacing: 0.12em;
  color: var(--ink-muted);
  margin-bottom: 10px;
}

.test-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.test-row input {
  flex: 1;
  min-width: 220px;
  border: 1px solid rgba(44, 44, 44, 0.15);
  border-radius: var(--radius-pill);
  padding: 10px 16px;
  font: inherit;
  background: rgba(255, 255, 255, 0.45);
  color: var(--ink);
}

.test-row input:focus {
  outline: 2px solid rgba(44, 44, 44, 0.12);
}

.test-hint {
  margin: 10px 0 0;
  font-size: 0.82rem;
  color: var(--ink-muted);
}

/* Footer */
.footer {
  margin-top: 48px;
  text-align: center;
}

.footer-desc {
  margin: 0 0 10px;
  max-width: 520px;
  margin-inline: auto;
  font-size: 0.78rem;
  line-height: 1.55;
  color: var(--ink-soft);
}

.footer-meta {
  margin: 0;
  font-size: 0.78rem;
  color: var(--ink-soft);
}

.loading-hint {
  margin: 24px 0 32px;
  text-align: center;
  color: var(--ink-muted);
  font-size: 0.92rem;
}

/* Modal */
.modal-backdrop[hidden] {
  display: none !important;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(44, 44, 44, 0.18);
  display: grid;
  place-items: center;
  padding: 20px;
  z-index: 100;
}

.modal {
  width: min(420px, 100%);
  border-radius: var(--radius-lg);
  padding: 28px 24px 22px;
  position: relative;
}

.modal-close {
  position: absolute;
  top: 12px;
  right: 14px;
  border: none;
  background: none;
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  color: var(--ink-muted);
}

.modal h2 {
  margin: 0 0 6px;
  font-size: 1.35rem;
}

.modal-sub {
  margin: 0 0 18px;
  color: var(--ink-muted);
  font-size: 0.92rem;
}

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

.modal-form label {
  display: grid;
  gap: 6px;
  font-size: 0.85rem;
  color: var(--ink-muted);
}

.modal-form input {
  border: 1px solid rgba(44, 44, 44, 0.15);
  border-radius: 14px;
  padding: 11px 14px;
  font: inherit;
  background: rgba(255, 255, 255, 0.5);
}

.modal-note {
  margin: 14px 0 0;
  font-size: 0.78rem;
  color: var(--ink-soft);
  text-align: center;
}

.modal-error {
  margin: 0;
  font-size: 0.85rem;
  color: var(--negative);
}

@media (max-width: 760px) {
  .table-head {
    display: none;
  }

  .position-row {
    grid-template-columns: 1fr;
    gap: 10px;
    padding: 18px 8px;
  }

  .position-flows-panel {
    margin-left: 8px;
  }

  .flows-subtable-head {
    display: none;
  }

  .flows-subtable-row {
    grid-template-columns: 1fr;
    gap: 4px;
    padding: 12px 0;
  }

  .sparkline-wrap {
    max-width: 140px;
  }
}
