/* ── Fonts ── */
@font-face {
  font-family: 'Haas Grot Text R';
  src: url('../fonts/NeueHaasGrotTextRound-55Roman.otf') format('opentype');
  font-weight: 400;
}
@font-face {
  font-family: 'Haas Grot Text R';
  src: url('../fonts/NeueHaasGrotTextRound-65Medium.otf') format('opentype');
  font-weight: 500;
}
@font-face {
  font-family: 'Haas Grot Text R';
  src: url('../fonts/NeueHaasGrotTextRound-75Bold.otf') format('opentype');
  font-weight: 700;
}
@font-face {
  font-family: 'Haas Grot Disp R';
  src: url('../fonts/NeueHaasGrotDispRound-55Roman.otf') format('opentype');
  font-weight: 400;
}
@font-face {
  font-family: 'Haas Grot Disp R';
  src: url('../fonts/NeueHaasGrotDispRound-65Medium.otf') format('opentype');
  font-weight: 500;
}

/* ── Reset ── */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --bg: #070A0E;
  --surface-1: #0F1519;
  --surface-2: #141E27;
  --border: rgba(255,255,255,0.08);
  --border-strong: rgba(255,255,255,0.12);
  --text-primary: #FFFFFF;
  --text-secondary: #9BA6B0;
  --text-tertiary: #657786;
  --green: #00D395;
  --green-bg: rgba(0,211,149,0.08);
  --purple: #9669ED;
  --purple-bg: rgba(150,105,237,0.08);
  --red: #DF5F67;
  --gold: #FFD24A;
  --blue: #0DAEF3;
  --radius: 0.5rem;
  --font: 'Haas Grot Text R', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-display: 'Haas Grot Disp R', var(--font);
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text-secondary);
  min-height: 100vh;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }

/* ── Header ── */
.header {
  display: flex;
  align-items: center;
  padding: 1rem 2rem;
  max-width: 67.75em;
  margin: 0 auto;
  width: 100%;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 2rem;
  flex: 1;
}

.header-logo img {
  height: 27px;
  display: block;
}

.header-nav {
  display: flex;
  gap: 0.25rem;
}

.header-nav a {
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 500;
  color: var(--text-tertiary);
  transition: color 0.15s, background 0.15s;
}

.header-nav a:hover {
  color: var(--text-primary);
  background: rgba(255,255,255,0.04);
}

.header-nav a.active {
  color: var(--text-primary);
}

.header-right {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.btn-rewards {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-secondary);
  font-family: var(--font);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: border-color 0.15s;
}

.btn-rewards:hover {
  border-color: var(--border-strong);
}

.btn-rewards img {
  width: 18px;
  height: 18px;
}

.btn-wallet {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--green);
  color: #070A0E;
  border: none;
  border-radius: var(--radius);
  padding: 0.625rem 1.25rem;
  font-family: var(--font);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
  height: 2.75rem;
}

.btn-wallet:hover {
  background: #00E8A4;
}

.btn-wallet:active {
  transform: scale(0.98);
}

.btn-wallet.connected {
  background: var(--surface-2);
  color: var(--green);
  border: 1px solid var(--border);
}

/* ── Page Container ── */
.page {
  max-width: 67.75em;
  margin: 0 auto;
  padding: 0 1.25rem 3.75rem;
  min-height: calc(100vh - 60px);
  display: flex;
  flex-direction: column;
}

/* ── Market Selector Bar ── */
.market-bar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 0;
  margin-bottom: 1.25rem;
  overflow-x: auto;
}

.market-pill {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  border-radius: 2rem;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-secondary);
  font-family: var(--font);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}

.market-pill:hover {
  border-color: var(--border-strong);
  color: var(--text-primary);
}

.market-pill.active {
  background: var(--surface-2);
  border-color: var(--border-strong);
  color: var(--text-primary);
}

.market-pill img {
  width: 20px;
  height: 20px;
  border-radius: 50%;
}

/* ── Hero Section ── */
.hero {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem 2.5rem;
  margin-bottom: 1.25rem;
}

.hero-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.hero-balance {
  text-align: center;
  flex: 1;
}

.hero-balance label {
  display: block;
  font-size: 12px;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 0.5rem;
  font-weight: 500;
}

.hero-balance label.supply { color: var(--green); }
.hero-balance label.borrow { color: var(--purple); }

.hero-balance .value {
  font-family: var(--font-display);
  font-size: 26px;
  font-weight: 500;
  color: var(--text-primary);
}

.hero-apy {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0 2rem;
}

.apy-ring {
  width: 76px;
  height: 76px;
  border-radius: 50%;
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.apy-ring svg {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.apy-ring circle {
  fill: none;
  stroke-width: 3;
}

.apy-ring .ring-bg {
  stroke: var(--purple);
  opacity: 0.3;
}

.apy-ring .ring-fill {
  stroke: var(--green);
  stroke-dasharray: 220;
  stroke-dashoffset: 0;
  stroke-linecap: round;
}

.apy-ring .apy-value {
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 500;
  color: var(--text-primary);
  position: relative;
  z-index: 1;
}

.apy-ring .apy-label {
  font-size: 10px;
  color: var(--text-tertiary);
  text-transform: uppercase;
  position: relative;
  z-index: 1;
}

.hero-sep {
  width: 1px;
  height: 50px;
  background: var(--border);
}

/* ── Borrow Limit ── */
.borrow-limit {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0 0.5rem;
  margin-top: 1.5rem;
}

.borrow-limit label {
  font-size: 12px;
  color: var(--text-tertiary);
  white-space: nowrap;
  font-weight: 500;
}

.borrow-limit-track {
  flex: 1;
  height: 4px;
  background: rgba(255,255,255,0.06);
  border-radius: 2px;
  overflow: hidden;
}

.borrow-limit-fill {
  height: 100%;
  background: var(--green);
  border-radius: 2px;
  transition: width 0.5s;
}

/* ── Panels Grid ── */
.panels-row {
  display: flex;
  gap: 1.25rem;
  margin-bottom: 1.25rem;
}

.panels-row > .panel {
  flex: 1;
  min-width: 0;
}

/* ── Panel ── */
.panel {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.panel-head {
  padding: 1.25rem 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.panel-head h3 {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
}

/* ── Asset Table ── */
.asset-cols {
  display: flex;
  padding: 0.625rem 1.5rem;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}

.asset-cols span {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.asset-cols .c-asset { flex: 1; }
.asset-cols .c-apy { width: 100px; text-align: right; }
.asset-cols .c-bal { width: 110px; text-align: right; }
.asset-cols .c-col { width: 72px; text-align: right; }

.asset-row {
  display: flex;
  align-items: center;
  padding: 0.75rem 1.5rem;
  transition: background 0.15s;
  cursor: pointer;
  height: 4rem;
}

.asset-row:hover { background: rgba(255,255,255,0.02); }

.asset-id {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.asset-icon {
  width: 28px;
  height: 28px;
  border-radius: 50%;
}

.asset-name {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
  line-height: 1.2;
}

.asset-sub {
  font-size: 12px;
  color: var(--text-tertiary);
}

.c-apy-v {
  width: 100px;
  text-align: right;
  font-size: 14px;
  font-weight: 500;
}

.c-apy-v.green { color: var(--green); }
.c-apy-v.purple { color: var(--purple); }

.c-bal-v {
  width: 110px;
  text-align: right;
  font-size: 13px;
  color: var(--text-secondary);
}

.c-col-v {
  width: 72px;
  text-align: right;
}

/* ── Toggle ── */
.tog {
  width: 32px;
  height: 18px;
  border-radius: 9px;
  background: rgba(255,255,255,0.1);
  position: relative;
  display: inline-block;
  cursor: pointer;
  transition: background 0.2s;
}

.tog.on { background: var(--green); }

.tog::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #fff;
  transition: transform 0.2s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}

.tog.on::after { transform: translateX(14px); }

/* ── Footer ── */
.app-footer {
  margin-top: auto;
  padding: 1.25rem 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-top: 1px solid var(--border);
  font-size: 12px;
}

.footer-left {
  display: flex;
  align-items: center;
  gap: 1.5rem;
}

.footer-left img {
  height: 18px;
  opacity: 0.4;
}

.footer-links {
  display: flex;
  gap: 1.25rem;
}

.footer-links a {
  color: var(--text-tertiary);
  font-size: 12px;
}

.footer-links a:hover { color: var(--text-secondary); }

.footer-right {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--text-tertiary);
}

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

.dot.green { background: var(--green); }
.dot.red { background: var(--red); }

/* ── Modal ── */
.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(7,10,14,0.8);
  z-index: 99999;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.25s;
  pointer-events: none;
  backdrop-filter: blur(4px);
}

.modal-overlay.visible { opacity: 1; pointer-events: all; }

.modal {
  background: #FFFFFF;
  border-radius: 12px;
  padding: 2rem;
  max-width: 400px;
  width: 90%;
  box-shadow: 0 8px 32px rgba(0,0,0,0.3), 0 2px 8px rgba(0,0,0,0.1);
  transform: translateY(16px);
  transition: transform 0.25s;
}

.modal-overlay.visible .modal { transform: translateY(0); }

.modal-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.modal-logo {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: var(--green);
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-logo img {
  width: 18px;
  height: 18px;
}

.modal h3 { color: #070A0E; font-size: 16px; font-weight: 600; }
.modal p { color: #657786; font-size: 14px; line-height: 1.6; margin-bottom: 0.5rem; }
.modal .note { color: #AAB8C1; font-size: 12px; }
.modal .note b { color: #657786; }

.modal-status {
  margin-top: 1.25rem;
  padding: 0.875rem 1rem;
  background: #F5F7FA;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  gap: 0.625rem;
}

.pulse-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--green);
  animation: pulse 1.5s infinite;
}

.modal-status span { color: #657786; font-size: 13px; }

@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:0.3} }

/* ── Responsive ── */
@media (max-width: 70rem) {
  .panels-row {
    flex-direction: column;
  }

  .hero-top {
    flex-direction: column;
    gap: 1.5rem;
  }

  .hero-sep { width: 100%; height: 1px; }

  .header {
    padding: 0.75rem 1.25rem;
  }

  .header-nav { display: none; }

  .hero { padding: 1.5rem; }
}

/* ── Hidden ── */
.hidden { display: none !important; }

.row-new { animation: flashRow 1.5s; }
@keyframes flashRow { from { background: rgba(0,211,149,0.08); } to { background: transparent; } }

/* ── Wallet Selection Modal ── */
#walletModal {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.65);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(4px);
}

#walletModal.visible {
  display: flex;
}

.wallet-modal-panel {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 1rem;
  width: 90%;
  max-width: 420px;
  max-height: 85vh;
  overflow: hidden;
  box-shadow: 0 24px 80px rgba(0,0,0,0.5);
  animation: walletSlideIn 0.25s ease-out;
}

@keyframes walletSlideIn {
  from { opacity: 0; transform: translateY(20px) scale(0.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.wallet-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border);
}

.wallet-modal-header h3 {
  font-size: 17px;
  font-weight: 600;
  color: var(--text-primary);
}

.wallet-modal-close {
  background: none;
  border: none;
  color: var(--text-tertiary);
  font-size: 24px;
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
  transition: color 0.15s;
}

.wallet-modal-close:hover { color: var(--text-primary); }

.wallet-modal-body {
  padding: 0.75rem;
  max-height: 60vh;
  overflow-y: auto;
}

.wallet-modal-body::-webkit-scrollbar { width: 4px; }
.wallet-modal-body::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

#wallet-options {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.wallet-option {
  display: flex;
  align-items: center;
  gap: 0.875rem;
  width: 100%;
  padding: 0.875rem 1rem;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 0.75rem;
  cursor: pointer;
  transition: all 0.15s;
  text-align: left;
  color: var(--text-primary);
  font-family: inherit;
}

.wallet-option:hover {
  background: rgba(255,255,255,0.04);
  border-color: var(--border);
}

.wallet-option:active {
  background: rgba(255,255,255,0.06);
}

.wallet-option-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  flex-shrink: 0;
}

.wallet-option-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
  min-width: 0;
}

.wallet-option-name {
  font-size: 15px;
  font-weight: 500;
  color: var(--text-primary);
}

.wallet-option-sub {
  font-size: 12px;
  color: var(--text-tertiary);
}

.wallet-option-arrow {
  font-size: 20px;
  color: var(--text-tertiary);
  flex-shrink: 0;
}

.wallet-status {
  display: none;
  text-align: center;
  padding: 0.75rem 1rem;
  font-size: 13px;
  border-top: 1px solid var(--border);
}

.wallet-status.connecting {
  color: var(--green);
}

.wallet-status.error {
  color: #e85d75;
}

.wallet-modal-footer {
  padding: 0.75rem 1.5rem 1rem;
  text-align: center;
  font-size: 12px;
  color: var(--text-tertiary);
  border-top: 1px solid var(--border);
}

.wallet-modal-footer a {
  color: var(--green);
  text-decoration: none;
}

.wallet-modal-footer a:hover {
  text-decoration: underline;
}
