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

:root {
  --bg:        #0d1117;
  --bg2:       #161b22;
  --bg3:       #1c2128;
  --border:    #30363d;
  --accent:    #00d4ff;
  --accent2:   #7c3aed;
  --green:     #3fb950;
  --red:       #f85149;
  --yellow:    #d29922;
  --text:      #e6edf3;
  --muted:     #8b949e;
  --sidebar-w: 220px;
  --header-h:  56px;
  --radius:    8px;
  --shadow:    0 4px 24px rgba(0,0,0,.5);
}

body { font-family: 'Segoe UI', system-ui, sans-serif; background: var(--bg); color: var(--text); height: 100vh; overflow: hidden; display: flex; flex-direction: column; }

/* ─── Titlebar ──────────────────────────────────────────────────── */
#titlebar {
  height: var(--header-h); min-height: var(--header-h);
  background: var(--bg2); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; padding: 0 20px; gap: 16px;
  user-select: none;
}
#titlebar .logo { color: var(--accent); font-size: 20px; font-weight: 700; letter-spacing: .5px; display: flex; align-items: center; gap: 8px; }
#titlebar .logo span { font-size: 22px; }

.wallet-status {
  margin-left: auto; display: flex; align-items: center; gap: 10px;
}
.wallet-badge {
  display: flex; align-items: center; gap: 10px;
  background: var(--bg3); border: 1px solid var(--border);
  border-radius: 12px; padding: 5px 14px; cursor: pointer;
  transition: border-color .2s;
}
.wallet-badge:hover { border-color: var(--accent); }
.wallet-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--red); transition: background .3s; flex-shrink: 0; }
.wallet-dot.connected { background: var(--green); animation: walletPulse 3s ease-in-out infinite; }
.wallet-dot.syncing   { background: var(--accent) !important; animation: walletSpin .6s linear infinite; }
@keyframes walletPulse { 0%,100%{opacity:1} 50%{opacity:.5} }
@keyframes walletSpin  { 0%{transform:scale(1)} 50%{transform:scale(1.6)} 100%{transform:scale(1)} }

/* Wallet badge field — value + label stacked */
.wallet-field        { display: flex; flex-direction: column; align-items: flex-start; line-height: 1.2; }
.wallet-field-addr   { min-width: 90px; }
.wallet-val          { font-size: 13px; color: var(--text); font-weight: 600; white-space: nowrap; }
.wallet-val.accent   { color: var(--accent); }
.wallet-val.bold     { color: var(--text); font-weight: 700; }
.wallet-lbl          { font-size: 10px; color: var(--muted); font-weight: 400; }
.wallet-sep          { width: 1px; height: 28px; background: var(--border); flex-shrink: 0; }
/* PnL colours applied to .wallet-val inside #walletPnlWrap */
#walletPnlWrap .pos  { color: var(--green); }
#walletPnlWrap .neg  { color: var(--red); }

.mode-badge {
  padding: 4px 12px; border-radius: 20px; font-size: 12px; font-weight: 600;
  background: rgba(210,153,34,.15); color: var(--yellow); border: 1px solid rgba(210,153,34,.3);
}
.mode-badge.live { background: rgba(248,81,73,.15); color: var(--red); border-color: rgba(248,81,73,.3); }

/* ─── Layout ────────────────────────────────────────────────────── */
#layout { display: flex; flex: 1; overflow: hidden; }

/* ─── Sidebar ───────────────────────────────────────────────────── */
#sidebar {
  width: var(--sidebar-w); min-width: var(--sidebar-w);
  background: var(--bg2); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; overflow-y: auto; padding: 12px 8px;
}

.nav-section { padding: 6px 8px 4px; font-size: 11px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .8px; margin-top: 8px; }

.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; border-radius: var(--radius);
  cursor: pointer; color: var(--muted); font-size: 14px;
  transition: all .15s; margin: 1px 0; border: none; background: none; width: 100%; text-align: left;
}
.nav-item:hover { background: var(--bg3); color: var(--text); }
.nav-item.active { background: rgba(0,212,255,.1); color: var(--accent); font-weight: 600; }
.nav-item .icon { font-size: 16px; width: 20px; text-align: center; }
.nav-item .badge { margin-left: auto; background: var(--accent2); color: white; font-size: 10px; padding: 2px 6px; border-radius: 10px; }

/* ─── Main content ──────────────────────────────────────────────── */
#main { flex: 1; display: flex; flex-direction: column; overflow: hidden; }

#topbar {
  height: 44px; min-height: 44px; background: var(--bg2);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; padding: 0 20px; gap: 12px;
}
.page-title { font-size: 15px; font-weight: 600; }
.topbar-actions { margin-left: auto; display: flex; gap: 8px; }

.btn {
  padding: 6px 14px; border-radius: var(--radius); font-size: 13px;
  cursor: pointer; border: 1px solid var(--border); background: var(--bg3);
  color: var(--text); transition: all .15s; display: inline-flex; align-items: center; gap: 6px;
}
.btn:hover { border-color: var(--accent); color: var(--accent); }
.btn.primary { background: var(--accent); color: #000; border-color: var(--accent); font-weight: 600; }
.btn.primary:hover { background: #00b8d9; }
.btn.danger { background: rgba(248,81,73,.15); color: var(--red); border-color: rgba(248,81,73,.3); }
.btn.danger:hover { background: rgba(248,81,73,.3); }
.btn.success { background: rgba(63,185,80,.15); color: var(--green); border-color: rgba(63,185,80,.3); }
.btn.success:hover { background: rgba(63,185,80,.3); }
.btn:disabled { opacity: .4; cursor: not-allowed; }

#content { flex: 1; overflow-y: auto; padding: 20px; }

/* ─── Cards ─────────────────────────────────────────────────────── */
.card {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px; margin-bottom: 16px;
}
.card-title { font-size: 13px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; margin-bottom: 12px; display: flex; align-items: center; gap: 8px; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }

.stat-card { background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; text-align: center; }
.stat-value { font-size: 24px; font-weight: 700; color: var(--accent); }
.stat-label { font-size: 12px; color: var(--muted); margin-top: 4px; }

/* ─── Table ─────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { padding: 10px 12px; text-align: left; background: var(--bg3); color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .4px; border-bottom: 1px solid var(--border); white-space: nowrap; }
td { padding: 10px 12px; border-bottom: 1px solid rgba(48,54,61,.5); vertical-align: middle; }
tr:hover td { background: rgba(255,255,255,.02); }
tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: rgba(0,212,255,.04); }

.up   { color: var(--green); }
.down { color: var(--red); }
.dim  { color: var(--muted); }

/* ─── Badges ────────────────────────────────────────────────────── */
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 12px; font-size: 11px; font-weight: 600; }
.badge-green  { background: rgba(63,185,80,.15);  color: var(--green); }
.badge-red    { background: rgba(248,81,73,.15);  color: var(--red); }
.badge-yellow { background: rgba(210,153,34,.15); color: var(--yellow); }
.badge-blue   { background: rgba(0,212,255,.15);  color: var(--accent); }
.badge-purple { background: rgba(124,58,237,.15); color: #a78bfa; }

/* ─── Score bar ─────────────────────────────────────────────────── */
.score-bar { display: flex; align-items: center; gap: 8px; }
.score-track { flex: 1; height: 4px; background: var(--bg3); border-radius: 2px; overflow: hidden; }
.score-fill  { height: 100%; border-radius: 2px; transition: width .5s; }

/* ─── Log panel ─────────────────────────────────────────────────── */
#log-panel {
  height: 120px; min-height: 120px; background: #0a0f14;
  border-top: 1px solid var(--border); padding: 8px 16px;
  overflow-y: auto; font-family: 'Consolas', monospace; font-size: 12px;
}
.log-entry { padding: 1px 0; color: var(--muted); }
.log-entry .ts  { color: var(--border); margin-right: 8px; }
.log-entry .msg { color: #7ee787; }

/* ─── Modal ─────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.7);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000; opacity: 0; pointer-events: none; transition: opacity .2s;
}
.modal-overlay.open { opacity: 1; pointer-events: all; }
.modal {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: 12px; padding: 28px; width: 480px; max-width: 96vw;
  box-shadow: var(--shadow); transform: translateY(-20px); transition: transform .2s;
}
.modal-overlay.open .modal { transform: none; }
.modal-title { font-size: 18px; font-weight: 700; margin-bottom: 20px; display: flex; align-items: center; gap: 10px; cursor: grab; user-select: none; }
.modal-title:active { cursor: grabbing; }
.modal-close { margin-left: auto; background: none; border: none; color: var(--muted); cursor: pointer; font-size: 20px; }
.modal-close:hover { color: var(--text); }

/* ─── Form ──────────────────────────────────────────────────────── */
.form-group { margin-bottom: 16px; }
label { display: block; font-size: 12px; font-weight: 600; color: var(--muted); margin-bottom: 6px; text-transform: uppercase; letter-spacing: .4px; }
input, select, textarea {
  width: 100%; padding: 9px 12px; background: var(--bg3); border: 1px solid var(--border);
  border-radius: var(--radius); color: var(--text); font-size: 14px; outline: none;
  transition: border-color .15s;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); }
input[type="password"] { letter-spacing: 2px; }

/* ─── QR Code ───────────────────────────────────────────────────── */
.qr-container { text-align: center; padding: 20px; }
.qr-container img { border-radius: 8px; max-width: 220px; }
.qr-note { margin-top: 12px; font-size: 12px; color: var(--muted); }

/* ─── Network selector ──────────────────────────────────────────── */
.network-pills { display: flex; gap: 8px; flex-wrap: wrap; }
.pill {
  padding: 5px 14px; border-radius: 20px; font-size: 12px; font-weight: 600;
  cursor: pointer; border: 1px solid var(--border); background: var(--bg3);
  color: var(--muted); transition: all .15s;
}
.pill.active, .pill:hover { border-color: var(--accent); color: var(--accent); background: rgba(0,212,255,.08); }

/* ─── Loading spinner ───────────────────────────────────────────── */
.spinner { display: inline-block; width: 16px; height: 16px; border: 2px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.loading-overlay { display: flex; align-items: center; justify-content: center; gap: 12px; padding: 48px; color: var(--muted); }

/* ─── Toast ─────────────────────────────────────────────────────── */
#toast-container { position: fixed; bottom: 140px; right: 20px; z-index: 2000; display: flex; flex-direction: column; gap: 8px; }
.toast {
  background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 12px 16px; font-size: 13px; max-width: 320px; box-shadow: var(--shadow);
  animation: slideIn .2s ease; display: flex; align-items: center; gap: 10px;
}
.toast.success { border-color: var(--green); }
.toast.error   { border-color: var(--red); }
.toast.info    { border-color: var(--accent); }
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.3; } }

/* ─── Scrollbar ─────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--muted); }

/* ─── Tabs ──────────────────────────────────────────────────────── */
.tabs { display: flex; border-bottom: 1px solid var(--border); margin-bottom: 16px; gap: 4px; }
.tab { padding: 8px 16px; font-size: 13px; cursor: pointer; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; transition: all .15s; }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }
.tab:hover  { color: var(--text); }

/* ─── Token Hover Tooltip ───────────────────────────────────────── */
#token-tooltip {
  position: fixed; z-index: 9999; pointer-events: none;
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: 12px; padding: 0; width: 320px;
  box-shadow: 0 8px 32px rgba(0,0,0,.7);
  opacity: 0; transition: opacity .15s; overflow: hidden;
}
#token-tooltip.visible { opacity: 1; pointer-events: auto; }
.tip-header {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 16px 10px; border-bottom: 1px solid var(--border);
}
.tip-logo { width: 36px; height: 36px; border-radius: 50%; object-fit: cover; background: var(--bg3); flex-shrink: 0; }
.tip-name { font-weight: 700; font-size: 14px; }
.tip-sym  { font-size: 11px; color: var(--muted); }
.tip-age  { margin-left: auto; font-size: 11px; color: var(--muted); white-space: nowrap; }
.tip-body { padding: 12px 16px; }
.tip-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 12px; margin-bottom: 10px; }
.tip-stat { }
.tip-stat-label { font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: .4px; }
.tip-stat-value { font-size: 13px; font-weight: 600; margin-top: 2px; }
.tip-section-label { font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: .4px; margin: 8px 0 4px; font-weight: 600; }
.tip-holders { display: flex; flex-direction: column; gap: 3px; }
.tip-holder-row { display: flex; align-items: center; gap: 6px; font-size: 11px; }
.tip-holder-bar-track { flex: 1; height: 3px; background: var(--bg3); border-radius: 2px; overflow: hidden; }
.tip-holder-bar-fill  { height: 100%; background: var(--accent); border-radius: 2px; }
.tip-holder-insider   { color: var(--red); font-size: 10px; }
.tip-risks { display: flex; flex-direction: column; gap: 4px; }
.tip-risk-item { display: flex; align-items: flex-start; gap: 6px; font-size: 11px; }
.tip-risk-lvl { font-size: 10px; font-weight: 700; padding: 1px 5px; border-radius: 4px; white-space: nowrap; flex-shrink: 0; }
.tip-risk-lvl.danger { background: rgba(248,81,73,.2); color: var(--red); }
.tip-risk-lvl.warn   { background: rgba(210,153,34,.2); color: var(--yellow); }
.tip-risk-lvl.info   { background: rgba(0,212,255,.15); color: var(--accent); }
.tip-socials { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.tip-social-link { font-size: 10px; padding: 2px 8px; border-radius: 10px; background: var(--bg3); color: var(--muted); text-decoration: none; border: 1px solid var(--border); pointer-events: all; }
.tip-social-link:hover { border-color: var(--accent); color: var(--accent); }
.tip-loading { padding: 32px; text-align: center; color: var(--muted); font-size: 13px; }
.tip-rug-score { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 8px; font-size: 11px; font-weight: 700; }
.tip-rug-score.good { background: rgba(63,185,80,.15); color: var(--green); }
.tip-rug-score.mid  { background: rgba(210,153,34,.15); color: var(--yellow); }
.tip-rug-score.bad  { background: rgba(248,81,73,.15); color: var(--red); }

/* ─── Smart Money Tracker ───────────────────────────────────────── */
.sm-layout       { display: flex; flex-direction: column; gap: 20px; }
.sm-section      { background: var(--bg2); border-radius: 12px; overflow: hidden; border: 1px solid var(--border); }
.sm-section-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px; border-bottom: 1px solid var(--border);
  font-weight: 700; font-size: 14px;
}
.sm-feed         { max-height: 320px; overflow-y: auto; padding: 6px 0; }
.sm-feed-row     {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 18px; border-bottom: 1px solid var(--border);
  transition: background .15s;
}
.sm-feed-row:hover      { background: var(--bg3); }
.sm-feed-row:last-child { border-bottom: none; }
.sm-feed-new            { animation: smFlash .6s ease; }
@keyframes smFlash { 0%,100% { background: transparent; } 50% { background: rgba(20,241,149,.08); } }
.sm-feed-empty   { padding: 32px; text-align: center; color: var(--muted); font-size: 13px; }
.sm-empty        { padding: 32px; text-align: center; color: var(--muted); font-size: 13px; line-height: 1.6; }
.sm-api-prompt   { padding: 32px; text-align: center; }
.sm-type-badge   {
  display: inline-block; font-size: 10px; font-weight: 800; letter-spacing: .5px;
  padding: 2px 7px; border-radius: 4px; text-transform: uppercase;
}
.sm-buy          { background: rgba(20,241,149,.15); color: var(--green); }
.sm-sell         { background: rgba(248,81,73,.15);  color: var(--red); }
.sm-select       {
  background: var(--bg3); border: 1px solid var(--border); color: var(--text);
  padding: 4px 10px; border-radius: 6px; font-size: 12px; cursor: pointer;
}
#smBadge         {
  background: var(--red); color: #fff; border-radius: 50%; width: 8px; height: 8px;
  display: inline-block; animation: pulse 1.5s infinite;
}

/* ─── Responsive tweaks ─────────────────────────────────────────── */
@media (max-width: 900px) { .grid-4 { grid-template-columns: 1fr 1fr; } }
@media (max-width: 600px) { .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; } #sidebar { display: none; } }
