:root {
  color-scheme: dark;
  --bg: #090b10;
  --surface: #111720;
  --surface-2: #171f2a;
  --line: rgba(255, 255, 255, 0.08);
  --text: #f4f7fb;
  --muted: #8b97a8;
  --green: #2ee6a6;
  --blue: #78a8ff;
  --amber: #f5b86b;
  --danger: #ff6b7a;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background:
    radial-gradient(circle at 20% 0%, rgba(46, 230, 166, 0.12), transparent 28rem),
    radial-gradient(circle at 100% 20%, rgba(120, 168, 255, 0.12), transparent 24rem),
    var(--bg);
  color: var(--text);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    "PingFang SC", "Microsoft YaHei", sans-serif;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

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

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 24px 18px;
  border-right: 1px solid var(--line);
  background: rgba(9, 11, 16, 0.76);
  backdrop-filter: blur(20px);
}

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

.brand-mark {
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  border: 1px solid rgba(46, 230, 166, 0.42);
  border-radius: 8px;
  background: linear-gradient(135deg, rgba(46, 230, 166, 0.18), rgba(120, 168, 255, 0.12));
  color: var(--green);
  font-weight: 800;
}

.brand strong,
.brand small {
  display: block;
}

.brand small,
small,
.eyebrow {
  color: var(--muted);
}

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

.nav-list a {
  display: flex;
  gap: 12px;
  align-items: center;
  min-height: 44px;
  padding: 0 12px;
  border: 1px solid transparent;
  border-radius: 8px;
  color: #c7d1dd;
  text-decoration: none;
}

.nav-list a:hover,
.nav-list a.active {
  border-color: rgba(46, 230, 166, 0.24);
  background: rgba(46, 230, 166, 0.1);
  color: var(--text);
}

.nav-icon {
  display: grid;
  width: 24px;
  height: 24px;
  place-items: center;
  color: var(--green);
}

.network-card {
  position: absolute;
  right: 18px;
  bottom: 24px;
  left: 18px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.network-card div {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 14px;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 0 6px rgba(46, 230, 166, 0.12);
}

.workspace {
  padding: 22px;
}

.topbar,
.panel-header,
.market-strip,
.content-grid,
.dashboard-grid {
  display: grid;
  gap: 18px;
}

.topbar {
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  margin-bottom: 18px;
}

.market-strip {
  grid-template-columns: repeat(3, minmax(140px, 1fr));
  gap: 12px;
}

.market-strip > div {
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(17, 23, 32, 0.82);
}

.market-strip strong,
.market-strip small {
  display: block;
}

.market-strip strong {
  margin: 5px 0 3px;
  font-size: 19px;
}

.up {
  color: var(--green);
}

.wallet-button,
.primary-action,
.ghost-button,
.icon-button,
.segmented button,
.token-select {
  border: 0;
  border-radius: 8px;
  color: var(--text);
}

.wallet-button,
.primary-action {
  min-height: 44px;
  padding: 0 18px;
  background: linear-gradient(135deg, var(--green), #8de6ff);
  color: #061016;
  font-weight: 800;
}

.dashboard-grid {
  grid-template-columns: minmax(0, 1.7fr) minmax(340px, 0.8fr);
  align-items: start;
}

.chart-panel,
.swap-card,
.markets-panel,
.pools-panel,
.portfolio-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(17, 23, 32, 0.82);
  box-shadow: 0 24px 90px rgba(0, 0, 0, 0.24);
}

.chart-panel {
  min-height: 538px;
  padding: 22px;
}

.panel-header {
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
}

.panel-header.compact {
  gap: 12px;
}

.eyebrow {
  margin: 0 0 5px;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
h3 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: clamp(30px, 4vw, 52px);
}

h2 {
  font-size: 20px;
}

.segmented {
  display: flex;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #0c1118;
}

.segmented button {
  width: 44px;
  height: 34px;
  background: transparent;
  color: var(--muted);
}

.segmented button.active {
  background: var(--surface-2);
  color: var(--text);
}

.chart-canvas {
  position: relative;
  height: 380px;
  margin-top: 42px;
  overflow: hidden;
}

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

.grid-lines line {
  stroke: rgba(255, 255, 255, 0.08);
}

.area {
  fill: url("#chartFill");
}

.line {
  fill: none;
  stroke: var(--green);
  stroke-width: 5;
  stroke-linecap: round;
}

.chart-marker {
  position: absolute;
  top: 26px;
  right: 22px;
  padding: 12px 14px;
  border: 1px solid rgba(46, 230, 166, 0.24);
  border-radius: 8px;
  background: rgba(9, 11, 16, 0.76);
}

.chart-marker small,
.chart-marker strong {
  display: block;
}

.swap-card,
.markets-panel,
.pools-panel,
.portfolio-panel {
  padding: 18px;
}

.icon-button {
  width: 38px;
  height: 38px;
  background: var(--surface-2);
}

form {
  display: grid;
  gap: 12px;
  margin-top: 18px;
}

.token-input {
  position: relative;
  display: grid;
  gap: 8px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #0c1118;
}

.token-input > span {
  color: var(--muted);
  font-size: 13px;
}

.token-input input {
  width: 100%;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
  font-size: 34px;
  font-weight: 800;
}

.token-select {
  position: absolute;
  top: 16px;
  right: 16px;
  display: flex;
  gap: 8px;
  align-items: center;
  min-height: 36px;
  padding: 0 10px;
  background: var(--surface-2);
}

.token-dot {
  width: 18px;
  height: 18px;
  border-radius: 50%;
}

.eth {
  background: linear-gradient(135deg, #d5ddff, #6d83ff);
}

.usdc {
  background: linear-gradient(135deg, #8de6ff, #2775ca);
}

.arb {
  background: linear-gradient(135deg, #85e5ff, #163a72);
}

.wbtc {
  background: linear-gradient(135deg, #ffd58d, #f7931a);
}

.flip-button {
  justify-self: center;
  width: 42px;
  height: 42px;
  margin: -4px 0;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--surface-2);
  color: var(--green);
  font-size: 21px;
  z-index: 1;
}

.quote-box {
  display: grid;
  gap: 10px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.03);
}

.quote-box div,
.market-row,
.pool-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
}

.quote-box span,
.market-row small,
.pool-row small {
  color: var(--muted);
}

.content-grid {
  grid-template-columns: minmax(0, 1.25fr) minmax(300px, 0.8fr) minmax(280px, 0.75fr);
  margin-top: 18px;
}

.ghost-button {
  min-height: 36px;
  padding: 0 12px;
  background: var(--surface-2);
  color: #d5dde8;
}

.market-table,
.pool-list {
  display: grid;
  gap: 10px;
  margin-top: 16px;
}

.market-row,
.pool-row {
  padding: 13px 0;
  border-bottom: 1px solid var(--line);
}

.market-row:last-child,
.pool-row:last-child {
  border-bottom: 0;
}

.market-main {
  display: flex;
  gap: 10px;
  align-items: center;
}

.pair-dots {
  display: flex;
}

.pair-dots span + span {
  margin-left: -6px;
}

.price-cell {
  text-align: right;
}

.down {
  color: var(--danger);
}

.pill {
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(120, 168, 255, 0.12);
  color: var(--blue);
  font-size: 12px;
  font-weight: 800;
}

.balance-card {
  margin-top: 16px;
  padding: 18px;
  border-radius: 8px;
  background: linear-gradient(135deg, rgba(46, 230, 166, 0.14), rgba(120, 168, 255, 0.12));
}

.balance-card strong,
.balance-card small,
.balance-card span {
  display: block;
}

.balance-card strong {
  margin: 8px 0;
  font-size: 31px;
}

.asset-bars {
  display: flex;
  gap: 6px;
  margin-top: 18px;
}

.asset-bars span {
  display: block;
  width: var(--w);
  height: 12px;
  border-radius: 999px;
  background: var(--c);
}

.token-dialog {
  width: min(420px, calc(100vw - 32px));
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
}

.token-dialog::backdrop {
  background: rgba(0, 0, 0, 0.62);
  backdrop-filter: blur(8px);
}

.dialog-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.token-options {
  display: grid;
  gap: 8px;
}

.token-option {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #0c1118;
  color: var(--text);
  text-align: left;
}

.token-option strong,
.token-option small {
  display: block;
}

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  transform: translateY(24px);
  max-width: 320px;
  padding: 13px 16px;
  border: 1px solid rgba(46, 230, 166, 0.24);
  border-radius: 8px;
  background: rgba(17, 23, 32, 0.96);
  color: var(--text);
  opacity: 0;
  pointer-events: none;
  transition: 180ms ease;
}

.toast.show {
  transform: translateY(0);
  opacity: 1;
}

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

  .sidebar {
    position: static;
    display: flex;
    height: auto;
    gap: 16px;
    align-items: center;
    padding: 14px 16px;
    overflow-x: auto;
  }

  .nav-list {
    display: flex;
    margin-top: 0;
  }

  .network-card {
    position: static;
    min-width: 170px;
    margin-left: auto;
  }

  .dashboard-grid,
  .content-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 720px) {
  .workspace {
    padding: 14px;
  }

  .topbar,
  .market-strip,
  .panel-header {
    grid-template-columns: 1fr;
  }

  .wallet-button {
    width: 100%;
  }

  .sidebar {
    align-items: flex-start;
  }

  .brand small,
  .network-card {
    display: none;
  }

  .nav-list a {
    min-width: 86px;
    justify-content: center;
  }

  .nav-icon {
    display: none;
  }

  .chart-panel {
    min-height: 430px;
    padding: 16px;
  }

  .chart-canvas {
    height: 280px;
    margin-top: 24px;
  }

  .segmented {
    width: 100%;
  }

  .segmented button {
    flex: 1;
    width: auto;
  }

  .token-input input {
    padding-top: 20px;
    font-size: 28px;
  }

  .toast {
    right: 14px;
    left: 14px;
    max-width: none;
  }
}
