:root {
  --bg: #0a0a0c;
  --bg-soft: #101014;
  --panel: rgba(255, 255, 255, 0.03);
  --panel-solid: #141418;
  --panel-border: rgba(255, 255, 255, 0.08);
  --text: #f2f2f0;
  --text-dim: #a3a3a0;
  --text-faint: #6f6f6c;
  --accent: #e8e6e3;
  --accent-2: #b8b6b2;
  --accent-3: #8a8a86;
  --green: #7fd6a0;
  --red: #e58a8a;
  --radius: 14px;
  --font: 'Inter', system-ui, -apple-system, sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

/* ---------- Ambient background ---------- */
.bg {
  position: fixed;
  inset: 0;
  z-index: -1;
  overflow: hidden;
  background:
    radial-gradient(900px 600px at 85% -10%, rgba(255, 255, 255, 0.05), transparent 60%),
    radial-gradient(800px 600px at 5% 110%, rgba(255, 255, 255, 0.03), transparent 60%),
    var(--bg);
}
.bg-grid {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(255,255,255,0.02) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.02) 1px, transparent 1px);
  background-size: 64px 64px;
  mask-image: radial-gradient(ellipse 70% 55% at 50% 35%, #000 20%, transparent 75%);
  -webkit-mask-image: radial-gradient(ellipse 70% 55% at 50% 35%, #000 20%, transparent 75%);
}
.bg-glow {
  position: absolute;
  border-radius: 50%;
  filter: blur(120px);
  opacity: 0.35;
}
.bg-glow-1 { width: 480px; height: 480px; background: #ffffff; top: -160px; left: 12%; opacity: 0.05; }
.bg-glow-2 { width: 420px; height: 420px; background: #ffffff; bottom: -140px; right: 6%; opacity: 0.04; }
.bg-glow-3 { display: none; }
#particles { position: absolute; inset: 0; opacity: 0.5; }

/* ---------- Views ---------- */
.view { display: none; }
.view.active { display: block; }

/* ---------- Landing ---------- */
.landing-view { min-height: 100vh; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 26px 40px;
  max-width: 1200px;
  margin: 0 auto;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 600; font-size: 17px; letter-spacing: -0.01em; }
.brand-mark { font-size: 20px; opacity: 0.9; }
.brand-dot { color: var(--text-faint); }
.topnav { display: flex; gap: 30px; align-items: center; }
.topnav a { color: var(--text-dim); text-decoration: none; font-size: 14px; font-weight: 500; transition: color .2s; }
.topnav a:hover { color: var(--text); }
.nav-x {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 14px;
  border: 1px solid var(--panel-border);
  border-radius: 999px;
  background: var(--panel);
  font-size: 13px;
  font-weight: 600;
  transition: border-color .2s, background .2s, color .2s;
}
.nav-x:hover { border-color: rgba(255,255,255,0.2); background: rgba(255,255,255,0.06); color: var(--text); }
.x-icon { opacity: 0.7; }

.hero {
  max-width: 760px;
  margin: 0 auto;
  padding: 96px 24px 48px;
  text-align: center;
  animation: rise 0.9s cubic-bezier(0.22, 1, 0.36, 1) both;
}
@keyframes rise {
  from { opacity: 0; transform: translateY(24px); }
  to { opacity: 1; transform: translateY(0); }
}

.hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 13px;
  border-radius: 999px;
  border: 1px solid var(--panel-border);
  background: var(--panel);
  font-size: 12.5px;
  color: var(--text-dim);
  margin-bottom: 30px;
  letter-spacing: 0.01em;
}
.pulse-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 0 0 rgba(127, 214, 160, 0.5);
  animation: pulse 2.4s infinite;
}
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(127,214,160,0.5); }
  70% { box-shadow: 0 0 0 9px rgba(127,214,160,0); }
  100% { box-shadow: 0 0 0 0 rgba(127,214,160,0); }
}

.hero-title {
  font-size: clamp(36px, 6vw, 62px);
  font-weight: 600;
  line-height: 1.06;
  letter-spacing: -0.03em;
  margin-bottom: 22px;
  color: var(--text);
}
.gradient-text {
  color: var(--text-dim);
  font-weight: 400;
}
.hero-sub {
  font-size: 16.5px;
  color: var(--text-dim);
  max-width: 520px;
  margin: 0 auto 40px;
  line-height: 1.65;
  font-weight: 400;
}

/* Wallet form */
.wallet-form { max-width: 560px; margin: 0 auto; }
.input-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--panel-solid);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  padding: 6px 6px 6px 18px;
  transition: border-color .25s, box-shadow .25s;
}
.input-wrap:focus-within {
  border-color: rgba(255,255,255,0.22);
  box-shadow: 0 0 0 4px rgba(255,255,255,0.04);
}
.input-icon { color: var(--text-faint); font-size: 16px; }
#wallet-input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text);
  font-family: var(--mono);
  font-size: 13.5px;
  padding: 13px 0;
  min-width: 0;
}
#wallet-input::placeholder { color: var(--text-faint); }
.connect-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  cursor: pointer;
  background: var(--text);
  color: #0a0a0c;
  font-weight: 600;
  font-size: 15px;
  width: 44px;
  height: 44px;
  flex-shrink: 0;
  border-radius: 10px;
  transition: transform .15s, opacity .2s;
}
.connect-btn:hover { transform: translateY(-1px); opacity: 0.9; }
.connect-btn:active { transform: translateY(0); }
.connect-btn:disabled { opacity: 0.6; cursor: default; }
.btn-spinner {
  display: none;
  width: 15px; height: 15px;
  border: 2px solid rgba(10,10,12,0.3);
  border-top-color: #0a0a0c;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.connect-btn.loading .btn-spinner { display: inline-block; }
.connect-btn.loading .btn-label { display: none; }

.wallet-error {
  color: var(--red);
  font-size: 13px;
  margin-top: 12px;
  min-height: 18px;
  opacity: 0;
  transition: opacity .2s;
}
.wallet-error.show { opacity: 1; }
.wallet-hint { margin-top: 16px; font-size: 12px; color: var(--text-faint); }
.hint-key {
  font-family: var(--mono);
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--panel-border);
  border-radius: 5px;
  padding: 1px 6px;
  font-size: 11px;
}

/* Example CA chip */
.example-ca {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-top: 18px;
  font-size: 12.5px;
  color: var(--text-faint);
}
.example-label { white-space: nowrap; }
.example-ca-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 999px;
  padding: 6px 14px;
  color: var(--text-dim);
  font-size: 12px;
  cursor: pointer;
  transition: border-color .2s, background .2s, color .2s;
}
.example-ca-btn:hover {
  border-color: rgba(255,255,255,0.2);
  background: rgba(255,255,255,0.06);
  color: var(--text);
}
.example-ca-btn .mono { font-family: var(--mono); font-size: 11.5px; }
.example-copy { color: var(--text-dim); font-weight: 600; }

/* Wallet actions (skip + example) */
.wallet-actions {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  margin-top: 18px;
}
.skip-btn {
  background: transparent;
  border: 1px solid var(--panel-border);
  border-radius: 999px;
  padding: 8px 18px;
  color: var(--text-dim);
  font-size: 12.5px;
  cursor: pointer;
  transition: border-color .2s, color .2s, background .2s;
}
.skip-btn:hover {
  border-color: rgba(255,255,255,0.2);
  color: var(--text);
  background: rgba(255,255,255,0.04);
}
.wallet-actions .example-ca { margin-top: 0; }

/* Hero stats */
.hero-stats {
  display: flex;
  justify-content: center;
  gap: 64px;
  margin-top: 64px;
  flex-wrap: wrap;
}
.stat { text-align: center; }
.stat-num {
  font-size: 30px;
  font-weight: 600;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}
.stat-label { display: block; margin-top: 5px; font-size: 12.5px; color: var(--text-faint); }

/* Sections */
.section { max-width: 1000px; margin: 0 auto; padding: 80px 24px; }
.section-title {
  font-size: 26px;
  font-weight: 600;
  text-align: center;
  margin-bottom: 44px;
  letter-spacing: -0.02em;
}
.section-body { text-align: center; color: var(--text-dim); line-height: 1.7; max-width: 620px; margin: 0 auto; font-size: 15.5px; }

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
}
.card {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  padding: 30px 28px;
  transition: transform .25s, border-color .25s, background .25s;
  animation: fadeUp 0.6s cubic-bezier(0.22, 1, 0.36, 1) both;
}
.card:nth-child(1) { animation-delay: 0.05s; }
.card:nth-child(2) { animation-delay: 0.12s; }
.card:nth-child(3) { animation-delay: 0.19s; }
.card:hover { transform: translateY(-3px); border-color: rgba(255,255,255,0.16); background: rgba(255,255,255,0.05); }
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}
.card-icon { font-size: 13px; margin-bottom: 16px; opacity: 0.6; font-family: var(--mono); letter-spacing: 0.08em; }
.card h3 { font-size: 16px; font-weight: 600; margin-bottom: 8px; }
.card p { color: var(--text-dim); font-size: 14px; line-height: 1.65; }

.faq { max-width: 640px; margin: 0 auto; display: flex; flex-direction: column; gap: 10px; }
.faq details {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  padding: 18px 22px;
  cursor: pointer;
  transition: border-color .2s;
}
.faq details:hover { border-color: rgba(255,255,255,0.14); }
.faq summary { font-weight: 500; font-size: 15px; list-style: none; display: flex; justify-content: space-between; align-items: center; }
.faq summary::after { content: '+'; color: var(--text-faint); font-size: 18px; font-weight: 400; transition: transform .2s; }
.faq details[open] summary::after { transform: rotate(45deg); }
.faq p { margin-top: 12px; color: var(--text-dim); font-size: 14px; line-height: 1.65; }

.footer {
  text-align: center;
  padding: 48px 24px 56px;
  color: var(--text-faint);
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0;
}
.footer-sep { margin: 0 10px; }
.footer-x {
  color: var(--text-dim);
  text-decoration: none;
  font-weight: 500;
  transition: color .2s;
}
.footer-x:hover { color: var(--text); }

/* ---------- Dashboard ---------- */
.dashboard-view { min-height: 100vh; padding-bottom: 40px; }

.dash-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 32px;
  border-bottom: 1px solid var(--panel-border);
  background: rgba(10,10,12,0.7);
  backdrop-filter: blur(12px);
  position: sticky;
  top: 0;
  z-index: 10;
}
.dash-wallet { display: flex; align-items: center; gap: 12px; }
.wallet-avatar {
  width: 38px; height: 38px;
  border-radius: 50%;
  display: grid; place-items: center;
  background: var(--panel-solid);
  border: 1px solid var(--panel-border);
  font-size: 15px;
  color: var(--text);
}
.wallet-meta { display: flex; flex-direction: column; }
.wallet-label { font-size: 11px; color: var(--text-faint); text-transform: uppercase; letter-spacing: 0.06em; }
.wallet-address { font-family: var(--mono); font-size: 13px; color: var(--text-dim); }
.disconnect-btn {
  background: transparent;
  border: 1px solid var(--panel-border);
  color: var(--text-faint);
  width: 30px; height: 30px;
  border-radius: 8px;
  cursor: pointer;
  transition: color .2s, border-color .2s;
}
.disconnect-btn:hover { color: var(--red); border-color: var(--red); }

.dash-grid {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 20px;
  max-width: 1200px;
  margin: 24px auto 0;
  padding: 0 24px;
  align-items: start;
}
@media (max-width: 1080px) {
  .dash-grid { grid-template-columns: 1fr; }
  .positions-panel { order: 2; }
  .chat-panel { order: 1; }
}

.panel {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  overflow: hidden;
  animation: fadeUp 0.6s cubic-bezier(0.22, 1, 0.36, 1) both;
}
.positions-panel { animation-delay: 0.05s; }
.chat-panel { animation-delay: 0.12s; }
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px;
  border-bottom: 1px solid var(--panel-border);
}
.panel-head h3 { font-size: 14px; font-weight: 600; }
.live-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--green);
  font-weight: 500;
}
.live-badge .pulse-dot { width: 6px; height: 6px; }

/* Positions */
.positions-list { padding: 12px; display: flex; flex-direction: column; gap: 10px; max-height: calc(100vh - 180px); overflow-y: auto; }
.position {
  background: rgba(255,255,255,0.02);
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  padding: 12px 14px;
  animation: rise 0.5s ease both;
}
.position-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.position-symbol { font-weight: 600; font-size: 14px; }
.position-pnl { font-family: var(--mono); font-size: 13px; font-weight: 500; }
.pnl-pos { color: var(--green); }
.pnl-neg { color: var(--red); }
.position-meta { display: flex; justify-content: space-between; font-size: 12px; color: var(--text-faint); font-family: var(--mono); }
.position-bar { height: 4px; border-radius: 2px; background: rgba(255,255,255,0.06); margin-top: 10px; overflow: hidden; }
.position-bar-fill { height: 100%; border-radius: 2px; background: var(--text-dim); }

/* Chat */
.chat-panel { display: flex; flex-direction: column; height: calc(100vh - 180px); }
.chat-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--panel-border);
}
.chat-title { display: flex; align-items: center; gap: 12px; }
.chat-avatar {
  width: 38px; height: 38px;
  border-radius: 12px;
  display: grid; place-items: center;
  background: var(--panel-solid);
  border: 1px solid var(--panel-border);
  font-size: 17px;
}
.chat-title h3 { font-size: 15px; font-weight: 600; }
.chat-status { font-size: 12px; color: var(--text-faint); }
.ghost-btn {
  background: transparent;
  border: 1px solid var(--panel-border);
  color: var(--text-faint);
  font-size: 12px;
  padding: 6px 12px;
  border-radius: 8px;
  cursor: pointer;
  transition: color .2s, border-color .2s;
}
.ghost-btn:hover { color: var(--text); border-color: var(--text-faint); }

.chat-log {
  flex: 1;
  overflow-y: auto;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.msg { display: flex; }
.msg.bot { justify-content: flex-start; }
.msg.user { justify-content: flex-end; }
.msg-bubble {
  max-width: 78%;
  padding: 11px 15px;
  border-radius: 14px;
  font-size: 14px;
  line-height: 1.55;
  animation: rise 0.35s ease both;
}
.msg.bot .msg-bubble {
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--panel-border);
  border-bottom-left-radius: 4px;
  font-weight: 500;
}
.msg.user .msg-bubble {
  background: var(--text);
  color: #0a0a0c;
  border-bottom-right-radius: 4px;
  font-weight: 500;
}
.msg-bubble .mono { font-family: var(--mono); font-size: 12.5px; }
.msg-bubble .pos { color: var(--green); font-weight: 600; }
.msg-bubble .neg { color: var(--red); font-weight: 600; }
.msg-bubble strong { font-weight: 700; color: var(--text); }
.msg.user .msg-bubble strong { color: #0a0a0c; }
.msg-bubble code {
  font-family: var(--mono);
  font-size: 12px;
  background: rgba(255,255,255,0.06);
  border: 1px solid var(--panel-border);
  border-radius: 5px;
  padding: 1px 5px;
}
.msg-bubble .md-h2 {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  margin: 8px 0 4px;
}
.msg-bubble .md-h3 {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  margin: 6px 0 3px;
}
.msg-bubble .md-li {
  padding-left: 2px;
  margin: 2px 0;
  color: var(--text-dim);
}
.msg-bubble em { color: var(--text-dim); }
.typing { display: inline-flex; gap: 4px; padding: 4px 2px; }
.typing span {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--text-dim);
  animation: blink 1.2s infinite;
}
.typing span:nth-child(2) { animation-delay: 0.2s; }
.typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes blink { 0%, 80%, 100% { opacity: 0.2; } 40% { opacity: 1; } }

.chat-input-row {
  display: flex;
  gap: 10px;
  padding: 14px;
  border-top: 1px solid var(--panel-border);
}
#chat-input {
  flex: 1;
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  padding: 12px 16px;
  color: var(--text);
  font-size: 14px;
  outline: none;
  transition: border-color .2s;
}
#chat-input:focus { border-color: rgba(255,255,255,0.22); }
.send-btn {
  width: 46px; height: 46px;
  border: none;
  border-radius: 12px;
  background: var(--text);
  color: #0a0a0c;
  font-size: 15px;
  cursor: pointer;
  transition: transform .15s, opacity .2s;
}
.send-btn:hover { transform: translateY(-1px); opacity: 0.9; }
.send-btn:disabled { opacity: 0.4; cursor: default; transform: none; }

/* Skeleton */
.skeleton {
  height: 64px;
  border-radius: 12px;
  background: linear-gradient(90deg, rgba(255,255,255,0.04) 25%, rgba(255,255,255,0.09) 50%, rgba(255,255,255,0.04) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite;
}
@keyframes shimmer { to { background-position: -200% 0; } }

/* Scrollbars */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.12); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.2); }
::-webkit-scrollbar-track { background: transparent; }

/* View transition */
.view-switch {
  animation: viewIn 0.7s cubic-bezier(0.22, 1, 0.36, 1) both;
}
@keyframes viewIn {
  from { opacity: 0; transform: scale(0.985) translateY(10px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

@media (max-width: 640px) {
  .topnav { display: none; }
  .topbar { padding: 18px 20px; }
  .hero { padding-top: 50px; }
  .hero-stats { gap: 30px; }
  .input-wrap { flex-direction: column; padding: 12px; }
  #wallet-input { width: 100%; text-align: center; }
  .connect-btn { width: 100%; }
  .dash-grid { padding: 0 12px; }
  .chat-panel, .positions-list { height: auto; max-height: none; }
  .chat-panel { height: 60vh; }
}

/* ============ ANALYSIS MODAL ============ */
.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}
.modal.open { opacity: 1; pointer-events: auto; }

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(4, 4, 10, 0.72);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

.modal-card {
  position: relative;
  width: min(760px, 100%);
  max-height: min(86vh, 820px);
  display: flex;
  flex-direction: column;
  background: var(--bg-soft);
  border: 1px solid var(--panel-border);
  border-radius: 20px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.6);
  transform: translateY(16px) scale(0.98);
  transition: transform 0.28s cubic-bezier(0.22, 1, 0.36, 1);
  overflow: hidden;
}
.modal.open .modal-card { transform: translateY(0) scale(1); }

.modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 20px 24px;
  border-bottom: 1px solid var(--panel-border);
  background: linear-gradient(180deg, rgba(255,255,255,0.03), transparent);
}
.modal-eyebrow {
  display: block;
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-faint);
  margin-bottom: 4px;
}
.modal-head h3 {
  font-size: 18px;
  font-weight: 600;
  word-break: break-all;
}
.modal-close {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  border-radius: 10px;
  border: 1px solid var(--panel-border);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-dim);
  cursor: pointer;
  font-size: 14px;
  transition: all 0.15s ease;
}
.modal-close:hover { background: rgba(255, 255, 255, 0.1); color: var(--text); }

.modal-body { padding: 20px 24px 24px; overflow-y: auto; }

/* Summary strip */
.modal-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 10px;
  margin-bottom: 18px;
}
.summary-cell {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  padding: 12px 14px;
}
.summary-cell .sc-label {
  font-size: 11px;
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 4px;
}
.summary-cell .sc-value {
  font-family: var(--mono);
  font-size: 16px;
  font-weight: 600;
}
.summary-cell .sc-sub {
  font-size: 11px;
  color: var(--text-faint);
  margin-top: 2px;
}

/* Tabs */
.modal-tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--panel-border);
  padding-bottom: 10px;
}
.modal-tab {
  padding: 7px 14px;
  border-radius: 9px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-dim);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}
.modal-tab:hover { color: var(--text); background: rgba(255, 255, 255, 0.04); }
.modal-tab.active {
  color: var(--text);
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.18);
}

.modal-pane { display: none; }
.modal-pane.active { display: block; animation: paneIn 0.25s ease; }
@keyframes paneIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* Pane content */
.pane-content { display: flex; flex-direction: column; gap: 8px; }

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}
.stat-box {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  padding: 12px 14px;
}
.stat-box .sb-label { font-size: 11px; color: var(--text-faint); text-transform: uppercase; letter-spacing: 0.06em; }
.stat-box .sb-value { font-family: var(--mono); font-size: 15px; font-weight: 600; margin-top: 3px; }

/* Trade / position rows */
.trade-row, .pos-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--panel-border);
}
.trade-row .tr-left, .pos-row .pr-left { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.trade-row .tr-sym, .pos-row .pr-sym { font-weight: 600; font-size: 14px; }
.trade-row .tr-sub, .pos-row .pr-sub { font-size: 11px; color: var(--text-faint); font-family: var(--mono); }
.trade-row .tr-right, .pos-row .pr-right { text-align: right; flex-shrink: 0; }
.trade-row .tr-pnl, .pos-row .pr-pnl { font-family: var(--mono); font-weight: 600; font-size: 14px; }
.trade-row .tr-time, .pos-row .pr-time { font-size: 11px; color: var(--text-faint); }

/* Highlight cards */
.hl-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 10px; }
.hl-card {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  padding: 14px;
}
.hl-card .hl-label { font-size: 11px; color: var(--text-faint); text-transform: uppercase; letter-spacing: 0.06em; }
.hl-card .hl-value { font-family: var(--mono); font-size: 15px; font-weight: 600; margin-top: 4px; }
.hl-card .hl-sub { font-size: 12px; color: var(--text-dim); margin-top: 2px; }

/* Empty / error states */
.pane-empty {
  text-align: center;
  color: var(--text-faint);
  padding: 30px 20px;
  font-size: 13px;
  border: 1px dashed var(--panel-border);
  border-radius: 12px;
}
.pane-error {
  text-align: center;
  color: var(--red);
  padding: 24px 20px;
  font-size: 13px;
  border: 1px solid rgba(248, 113, 113, 0.3);
  background: rgba(248, 113, 113, 0.06);
  border-radius: 12px;
}
.pane-error .pe-title { font-weight: 700; font-size: 14px; margin-bottom: 6px; }

/* Loading spinner in modal */
.modal-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 40px 20px;
  color: var(--text-faint);
  font-size: 13px;
}
.spinner {
  width: 28px;
  height: 28px;
  border: 3px solid rgba(255, 255, 255, 0.12);
  border-top-color: var(--text-dim);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Clickable rows */
.clickable { cursor: pointer; transition: border-color 0.15s ease, background 0.15s ease; }
.clickable:hover { border-color: rgba(255, 255, 255, 0.18); background: rgba(255, 255, 255, 0.04); }

@media (max-width: 640px) {
  .modal { padding: 12px; }
  .modal-card { max-height: 92vh; }
  .modal-body { padding: 16px; }
  .modal-tabs { flex-wrap: wrap; }
}
