/* Design tokens taken from jup.ag (dark theme) */
:root {
  --bg: #090d10;
  --card: #10161e;
  --card-2: #151e28;
  --input: #19242e;
  --border: #1e2a36;
  --border-strong: #253446;
  --fg: #e8edf3;
  --muted: #90a1b9;
  --muted-2: #67778e;
  --primary: #c7f284;
  --primary-ink: #0c1418;
  --primary-soft: rgba(199, 242, 132, 0.1);
  --primary-line: rgba(199, 242, 132, 0.28);
  --danger: #ff7a90;
  --radius: 16px;
  --sidebar: 224px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 72px; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}
h1, h2 { margin: 0; letter-spacing: -0.01em; }
h1 { font-size: 20px; font-weight: 600; }
h2 { font-size: 18px; font-weight: 600; }
a { color: inherit; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
[hidden] { display: none !important; }

/* Layout */
.app { display: flex; min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; align-self: flex-start;
  width: var(--sidebar); height: 100vh; flex: none;
  border-right: 1px solid var(--border);
  padding: 16px 12px;
  display: flex; flex-direction: column; gap: 24px;
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; padding: 4px 8px; }
.brand-mark {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--primary-soft); color: var(--primary);
  display: grid; place-items: center; font-size: 15px;
}
.brand-name { font-weight: 700; font-size: 15px; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-label { font-size: 11px; color: var(--muted-2); padding: 0 12px 6px; text-transform: uppercase; letter-spacing: 0.06em; }
.nav-link {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; border-radius: 12px;
  text-decoration: none; color: var(--muted); font-weight: 500;
}
.nav-link:hover { background: var(--card-2); color: var(--fg); }
.nav-link.is-active { background: var(--primary-soft); color: var(--primary); }
.sidebar-foot {
  margin-top: auto; display: flex; align-items: center; gap: 8px;
  font-size: 12px; color: var(--muted); padding: 0 12px;
}
.live-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted-2); flex: none; }
.live-dot.is-live { background: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }

.main { flex: 1; min-width: 0; }
.topbar { display: none; }
.page { max-width: 1040px; margin: 0 auto; padding: 24px 24px 48px; display: flex; flex-direction: column; gap: 40px; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; margin-bottom: 14px; flex-wrap: wrap; }
.section-head p { margin: 0; }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

/* Calculator */
.calc { padding: 20px; }
.calc-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 18px; }
.calc-head p { margin: 4px 0 0; }
.calc-body { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.calc-results { min-width: 0; }
.big-input { width: 100%; }
.calc-inputs { display: flex; flex-direction: column; gap: 12px; }
.panel {
  background: var(--card-2);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px;
  display: flex; flex-direction: column; gap: 12px;
}
.panel-label { font-size: 12px; font-weight: 600; color: var(--muted); display: flex; align-items: center; gap: 8px; }
.tag {
  font-size: 10px; font-weight: 700; padding: 1px 7px; border-radius: 999px;
  background: var(--primary-soft); color: var(--primary);
}
.tag-b { background: rgba(140, 180, 255, 0.12); color: #9cc0ff; }
.row-inputs { display: flex; gap: 10px; align-items: center; }
.amount-wrap {
  flex: 1; min-width: 0; display: flex; align-items: baseline; justify-content: flex-end; gap: 4px; cursor: text;
}
.amt-prefix { font-size: 28px; font-weight: 600; color: var(--muted); letter-spacing: -0.02em; }
.amt-suffix { font-size: 16px; font-weight: 600; color: var(--muted); margin-left: 2px; }
.amount-wrap .big-input { flex: 0 1 auto; width: 4ch; max-width: 100%; }
.big-input {
  flex: 1; min-width: 0; text-align: right;
  background: transparent; border: 0; outline: 0;
  font-size: 28px; font-weight: 600; letter-spacing: -0.02em;
  padding: 0;
}
.big-input::placeholder { color: var(--muted-2); }
.panel-sub { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.panel-sub .muted { text-align: right; }
.unit { display: inline-flex; background: var(--input); border-radius: 999px; padding: 2px; }
.unit-btn { border: 0; background: transparent; padding: 4px 12px; border-radius: 999px; font-size: 12px; font-weight: 600; color: var(--muted); }
.unit-btn.is-on { background: var(--border-strong); color: var(--fg); }
.quick { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  border: 1px solid var(--border-strong); background: transparent;
  border-radius: 999px; padding: 5px 12px; font-size: 12px; font-weight: 600; color: var(--muted);
}
.chip:hover { color: var(--fg); border-color: var(--muted-2); }
.chip.is-on { background: var(--primary-soft); border-color: var(--primary-line); color: var(--primary); }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }

.rate-row, .opt { display: flex; align-items: center; justify-content: space-between; gap: 12px; font-size: 13px; color: var(--muted); }
.rate-field {
  display: inline-flex; align-items: center; gap: 4px;
  background: var(--input); border: 1px solid transparent; border-radius: 10px; padding: 6px 10px;
}
.rate-field:focus-within, .opt > input:focus { border-color: var(--primary-line); }
.rate-field input, .opt > input {
  width: 70px; text-align: right; background: transparent; border: 0; outline: 0; font-weight: 600; color: var(--fg);
}
.opt > input { background: var(--input); border-radius: 10px; padding: 6px 10px; border: 1px solid transparent; width: 96px; }
.pct { color: var(--muted); font-weight: 600; }
.opts { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.opts .opt { flex-direction: column; align-items: stretch; gap: 6px; }
.opts .opt .rate-field { justify-content: flex-end; }
.opts .opt > input { width: 100%; text-align: right; }
.opts .opt .rate-field input { width: 100%; }
.same-amount { flex: 1; text-align: right; }
.same-value { font-size: 20px; font-weight: 600; letter-spacing: -0.01em; }

/* Dropdown */
.dd { position: relative; flex: none; }
.dd-btn {
  display: flex; align-items: center; gap: 8px;
  background: var(--input); border: 1px solid var(--border-strong);
  border-radius: 999px; padding: 6px 10px 6px 6px; font-weight: 600; font-size: 14px;
}
.dd-btn:hover { border-color: var(--muted-2); }
.dd-btn .chev { color: var(--muted); }
.dd-list {
  position: absolute; z-index: 20; top: calc(100% + 6px); left: 0; min-width: 240px;
  background: var(--card-2); border: 1px solid var(--border-strong); border-radius: 14px;
  padding: 6px; box-shadow: 0 16px 40px rgba(0, 0, 0, 0.5);
}
.dd-item {
  width: 100%; display: flex; align-items: center; gap: 10px; text-align: left;
  border: 0; background: transparent; padding: 8px; border-radius: 10px;
}
.dd-item:hover, .dd-item.is-on { background: var(--input); }
.dd-item .sym { font-weight: 600; }
.dd-item .nm { color: var(--muted); font-size: 12px; }
.dd-item .rt { margin-left: auto; color: var(--primary); font-weight: 600; font-size: 12px; }

.logo {
  width: 28px; height: 28px; border-radius: 50%; flex: none; object-fit: cover;
  background: var(--border-strong);
}
.logo-fallback {
  width: 28px; height: 28px; border-radius: 50%; flex: none;
  display: grid; place-items: center; font-weight: 700; font-size: 12px;
  background: var(--border-strong); color: var(--primary);
}

/* Switch */
.switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; user-select: none; flex: none; }
.switch-row { justify-content: space-between; width: 100%; font-size: 13px; color: var(--muted); }
.switch-label { font-weight: 600; font-size: 13px; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch-track { width: 40px; height: 22px; border-radius: 999px; background: var(--border-strong); position: relative; transition: background 0.15s; flex: none; }
.switch-thumb { position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: var(--fg); transition: transform 0.15s, background 0.15s; }
.switch input:checked + .switch-track { background: var(--primary); }
.switch input:checked + .switch-track .switch-thumb { transform: translateX(18px); background: var(--primary-ink); }
.switch input:focus-visible + .switch-track { outline: 2px solid var(--primary-line); outline-offset: 2px; }

/* Results */
.calc-results { display: flex; flex-direction: column; gap: 12px; }
.res-grid { display: grid; gap: 12px; grid-template-columns: 1fr; }
.res-grid.two { grid-template-columns: 1fr 1fr; }
.res {
  background: var(--card-2); border: 1px solid var(--border); border-radius: 14px; padding: 14px;
  display: flex; flex-direction: column; gap: 12px; min-width: 0;
}
.res-head { display: flex; align-items: center; gap: 8px; font-weight: 600; }
.res-head .logo, .res-head .logo-fallback { width: 24px; height: 24px; }
.res-top { display: flex; align-items: center; justify-content: space-between; gap: 12px 16px; flex-wrap: wrap; }
.res .btn-buy {
  flex: none; margin-left: auto;
  background: #fff; color: var(--primary-ink);
  font-size: 14px; font-weight: 700; padding: 11px 24px; border-radius: 999px;
}
.res .btn-buy:hover { background: #e2e8f0; color: var(--primary-ink); }
.res-top .res-main { flex: 1 1 auto; min-width: 0; }
.res-actions { display: flex; gap: 8px; margin-left: auto; flex-wrap: wrap; }
.res .res-actions .btn-buy { margin-left: 0; }
.res .btn-stake, .tbl .btn-solid {
  background: var(--primary); color: var(--primary-ink);
  font-size: 14px; font-weight: 700; padding: 11px 24px; border-radius: 999px;
  text-decoration: none; display: inline-block; text-align: center;
}
.res .btn-stake:hover, .tbl .btn-solid:hover { background: #d6f79f; color: var(--primary-ink); }
.cell-actions { display: inline-flex; gap: 8px; }
.tbl .btn-solid { padding: 8px 16px; font-size: 13px; }
.res-main .lbl { color: var(--muted); font-size: 12px; }
.res-main .val { font-size: 26px; font-weight: 700; letter-spacing: -0.02em; color: var(--primary); line-height: 1.15; }
.res-main .sub { color: var(--muted); font-size: 13px; }
.kv { display: flex; flex-direction: column; }
.kv-row { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-top: 1px solid var(--border); font-size: 13px; }
.kv-row .k { color: var(--muted); }
.kv-row .v { font-weight: 600; text-align: right; }
.kv-row .v small { display: block; color: var(--muted); font-weight: 500; font-size: 11px; }
.warn {
  font-size: 12px; color: #ffd58a; background: rgba(255, 213, 138, 0.08);
  border: 1px solid rgba(255, 213, 138, 0.22); border-radius: 10px; padding: 8px 10px;
}
.verdict {
  position: relative; overflow: hidden; min-height: 170px;
  border: 1px solid var(--primary-line);
  background: linear-gradient(135deg, rgba(199, 242, 132, 0.16), rgba(199, 242, 132, 0.05));
  border-radius: 16px; padding: 24px 28px;
  display: flex; align-items: center;
}
.verdict-body { position: relative; z-index: 1; display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.verdict.has-img .verdict-body { padding-right: 250px; }
.verdict-kicker { font-size: 12px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--primary); }
.verdict-title { font-size: 30px; font-weight: 700; letter-spacing: -0.02em; line-height: 1.15; }
.verdict-sub { font-size: 16px; color: var(--muted); }
.verdict b { color: var(--primary); }
.verdict-img { position: absolute; right: 8px; bottom: -6px; height: 168px; width: auto; pointer-events: none; }
.pos { color: var(--primary); }
.neg { color: var(--danger); }
.empty { color: var(--muted); padding: 24px; text-align: center; }

/* Table */
.table-card { overflow-x: auto; }
.tbl { width: 100%; border-collapse: collapse; }
.tbl th, .tbl td { padding: 14px 8px; text-align: right; white-space: nowrap; }
.tbl th:first-child, .tbl td:first-child { padding-left: 16px; }
.tbl th:last-child, .tbl td:last-child { padding-right: 16px; }
.tbl th.left, .tbl td.left { text-align: left; }
.tbl thead th {
  font-size: 12px; font-weight: 600; color: var(--muted); border-bottom: 1px solid var(--border);
  cursor: pointer; user-select: none;
}
.tbl thead th.nosort { cursor: default; }
.tbl thead th:hover:not(.nosort) { color: var(--fg); }
.tbl thead th.sorted { color: var(--primary); }
.tbl thead th .arr { display: inline-block; margin-left: 4px; width: 8px; }
.tbl tbody tr { border-top: 1px solid var(--border); cursor: pointer; }
.tbl tbody tr:first-child { border-top: 0; }
.tbl tbody tr:hover { background: var(--card-2); }
.tbl tbody tr.is-picked { background: var(--primary-soft); }
.cell-token { display: flex; align-items: center; gap: 12px; }
.cell-token .nm { font-weight: 600; }
.cell-token .sy { color: var(--muted); font-size: 12px; }
.apy-cell { font-weight: 700; color: var(--primary); }
.apy-cell small { display: block; font-weight: 500; color: var(--muted); font-size: 11px; }
.staked-cell small { display: block; color: var(--muted); font-size: 11px; }
.dash { color: var(--muted-2); }
.btn {
  border: 0; border-radius: 999px; padding: 8px 16px; font-weight: 600; font-size: 13px;
  background: var(--primary-soft); color: var(--primary);
}
.btn:hover { background: var(--primary); color: var(--primary-ink); }
.btn-wide { background: var(--primary); color: var(--primary-ink); }
.info {
  display: inline-grid; place-items: center; width: 14px; height: 14px; margin-left: 4px;
  border-radius: 50%; border: 1px solid var(--muted-2); color: var(--muted); font-size: 9px; font-weight: 700; cursor: help;
  vertical-align: 1px;
}

/* Rules */
.rules-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.rule { padding: 18px; display: flex; flex-direction: column; gap: 14px; }
.rule-head { display: flex; align-items: center; gap: 12px; }
.rule-head .prod { color: var(--muted); font-size: 12px; }
.rule-head .nm { font-weight: 600; font-size: 16px; }
.rule-head > div:nth-child(2) { min-width: 0; }
.rule-head .ext {
  margin-left: auto; white-space: nowrap; flex: none; display: inline-flex; align-items: center; gap: 6px;
  color: var(--primary); text-decoration: none; font-weight: 600; font-size: 12px;
  background: var(--primary-soft); padding: 6px 12px; border-radius: 999px;
}
.rule dl { margin: 0; display: grid; gap: 0; }
.rule dl > div { padding: 9px 0; border-top: 1px solid var(--border); display: grid; grid-template-columns: 110px 1fr; gap: 12px; font-size: 13px; }
.rule dt { color: var(--muted); }
.rule dd { margin: 0; }
.rule ul { margin: 0; padding-left: 18px; color: var(--muted); font-size: 13px; display: grid; gap: 4px; }

.foot { text-align: center; }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px);
  background: var(--card-2); border: 1px solid var(--border-strong); border-radius: 999px;
  padding: 10px 18px; font-weight: 600; font-size: 13px; opacity: 0; pointer-events: none;
  transition: opacity 0.2s, transform 0.2s; z-index: 50;
}
.toast.is-on { opacity: 1; transform: translate(-50%, 0); }

/* Compare mode: inputs side by side on top, results full width below */
.calc-body.is-compare { grid-template-columns: minmax(0, 1fr); }
.calc-body.is-compare .calc-inputs { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 12px; }
.calc-inputs > * { min-width: 0; }
.row-inputs > * { min-width: 0; }
.calc-body.is-compare .panel-duration { grid-column: 1 / -1; }

/* Tablet */
@media (max-width: 1000px) {
  .calc-body { grid-template-columns: minmax(0, 1fr); }
  .rules-grid { grid-template-columns: minmax(0, 1fr); }
}

/* Mobile: sidebar becomes a top bar + bottom tab bar, table becomes cards */
@media (max-width: 800px) {
  .sidebar {
    position: fixed; top: auto; bottom: 0; left: 0; right: 0; width: auto; height: auto;
    z-index: 30; background: rgba(9, 13, 16, 0.94); backdrop-filter: blur(12px);
    border-right: 0; border-top: 1px solid var(--border);
    padding: 6px 8px calc(6px + env(safe-area-inset-bottom)); flex-direction: row;
  }
  .sidebar .brand, .sidebar .nav-label, .sidebar-foot { display: none; }
  .nav { flex-direction: row; width: 100%; justify-content: space-around; }
  .nav-link { flex-direction: column; gap: 3px; font-size: 11px; padding: 6px 12px; }
  .topbar {
    display: flex; align-items: center; justify-content: space-between;
    padding: 10px 16px; position: sticky; top: 0; z-index: 25;
    background: rgba(9, 13, 16, 0.94); backdrop-filter: blur(12px); border-bottom: 1px solid var(--border);
  }
  .topbar-status { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); }
  .page { padding: 16px 16px 96px; gap: 32px; }
  .calc { padding: 14px; }
  .big-input { font-size: 24px; }
  .amt-prefix { font-size: 24px; }
  .res-grid.two { grid-template-columns: 1fr 1fr; gap: 8px; }
  .verdict { padding: 18px 16px; min-height: 120px; }
  .verdict-title { font-size: 22px; }
  .verdict-sub { font-size: 14px; }
  .verdict-img { height: 108px; right: 0; bottom: -4px; }
  .verdict.has-img .verdict-body { padding-right: 130px; }
  .calc-body.is-compare .calc-inputs { grid-template-columns: minmax(0, 1fr); }
  .res { padding: 12px; }
  .res-main .val { font-size: 20px; }

  .tbl thead { display: none; }
  .tbl, .tbl tbody, .tbl tr { display: block; width: 100%; }
  .tbl tbody tr { padding: 14px; display: grid; grid-template-columns: 1fr 1fr; gap: 10px 12px; }
  .tbl td, .tbl td:first-child, .tbl td:last-child { display: block; padding: 0; text-align: left; white-space: normal; }
  .tbl td.left { grid-column: 1 / -1; }
  .tbl td[data-label]::before {
    content: attr(data-label); display: block; color: var(--muted); font-size: 11px; margin-bottom: 2px;
  }
  .tbl td.buy-cell { grid-column: 1 / -1; }
  .tbl td.buy-cell .cell-actions { display: flex; }
  .tbl td.buy-cell .btn { flex: 1; padding: 11px; }
  .rule dl > div { grid-template-columns: 1fr; gap: 2px; }
}

@media (max-width: 560px) {
  .res-grid.two { grid-template-columns: 1fr; }
  .res-actions { width: 100%; flex-wrap: nowrap; }
  .res .res-actions .btn { flex: 1; }
}

@media (max-width: 340px) {
  .opts { grid-template-columns: 1fr; }
}
