/* ─── FUSION MARKETS (FFX) Dashboard — sidebar layout ─── */
:root {
  --bg:     #080d1a;
  --bg2:    #0d1426;
  --sidebar:#090f1f;
  --card:   #111829;
  --card2:  #151e30;
  --line:   #1e2a45;
  --text:   #dde4f5;
  --muted:  #7484a8;
  --brand:  #c8a84b;   /* gold */
  --brand2: #1a3a6c;   /* deep navy */
  --accent: #4f8cff;
  --ok:     #2ecc8f;
  --warn:   #f5b84a;
  --bad:    #ff5d6c;
  --radius: 12px;
  --shadow: 0 8px 32px rgba(0,0,0,.45);
  --sidebar-w: 240px;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.55 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  min-height: 100vh;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
code {
  font-family: ui-monospace, 'SFMono-Regular', Menlo, monospace;
  font-size: .82em;
  background: #050a14;
  padding: 2px 6px;
  border-radius: 6px;
  border: 1px solid var(--line);
}
.hidden { display: none !important; }
img { max-width: 100%; }

/* ─── APP SHELL ─── */
.app-shell {
  display: flex;
  min-height: 100vh;
}
.tab { display: none; }
.tab.active { display: block; }

/* ─── SIDEBAR ─── */
.sidebar {
  width: var(--sidebar-w);
  height: 100vh;
  height: 100dvh;
  background: var(--sidebar);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0;
  z-index: 30;
  transition: transform .25s ease;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 16px 16px;
  border-bottom: 1px solid var(--line);
  color: inherit;
}
.sidebar-brand:hover { text-decoration: none; }
.sidebar-logo {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  overflow: hidden;
  flex-shrink: 0;
  background: linear-gradient(135deg, var(--brand2), #0f2750);
  display: grid;
  place-items: center;
}
.sidebar-logo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 10px;
}
.sidebar-brand-text strong {
  display: block;
  font-size: .95rem;
  font-weight: 700;
  color: var(--brand);
  letter-spacing: .02em;
}
.sidebar-brand-text small {
  font-size: .68rem;
  color: var(--muted);
  display: block;
  margin-top: 1px;
}

.sidebar-nav {
  flex: 1;
  padding: 12px 0;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--line) transparent;
}

.nav-section {
  padding: 8px 14px 4px;
  font-size: .66rem;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--muted);
  font-weight: 600;
}
.nav-section:not(:first-child) {
  margin-top: 8px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 14px;
  color: var(--muted);
  cursor: pointer;
  border-radius: 0;
  transition: background .15s, color .15s;
  font-size: .87rem;
  font-weight: 500;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  position: relative;
  user-select: none;
}
.nav-item:hover { color: var(--text); background: rgba(255,255,255,.04); text-decoration: none; }
.nav-item:focus-visible, .btn:focus-visible, #btnMenu:focus-visible, .chip:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}
.nav-item.active {
  color: var(--brand);
  background: rgba(200, 168, 75, .08);
}
.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: var(--brand);
  border-radius: 0 2px 2px 0;
}
.nav-item .nav-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  opacity: .85;
}

.sidebar-footer {
  padding: 14px 16px calc(14px + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid var(--line);
}
.side-wallet {
  margin-bottom: 12px;
  padding: 10px 12px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  font-size: .78rem;
  overflow-wrap: anywhere;
}
.side-wallet .badges { margin: 8px 0 0; }
.sync-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: .77rem;
  color: var(--muted);
}
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); flex-shrink: 0; }
.dot.ok { background: var(--ok); box-shadow: 0 0 6px var(--ok); }
.dot.busy { background: var(--warn); animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: .3; } }

/* ─── TOPBAR ─── */
.topbar {
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  background: rgba(8,13,26,.9);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 20;
  flex-shrink: 0;
}
.topbar-left {
  display: flex;
  align-items: center;
  gap: 12px;
}
.topbar-mark { display: none; border-radius: 7px; }
.page-title { margin: 0; }
#btnMenu {
  display: none;
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  padding: 6px;
  border-radius: 8px;
  line-height: 1;
}
#btnMenu:hover { color: var(--text); }

.page-title {
  font-size: .92rem;
  font-weight: 600;
  color: var(--text);
}
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.wallet-chip {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 7px 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  font-size: .82rem;
  color: var(--muted);
  background: var(--card);
}
.wallet-chip .wc-addr { color: var(--text); font-family: ui-monospace, monospace; font-size: .78rem; }

.viewbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 20px;
  background: #1e1400;
  border-bottom: 1px solid #4a3d12;
  font-size: .83rem;
  flex-shrink: 0;
}

/* ─── MAIN CONTENT ─── */
.main-wrap {
  margin-left: var(--sidebar-w);
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
}
.content {
  flex: 1;
  padding: 20px 24px 40px;
  max-width: 1120px;
  width: 100%;
}

/* ─── SIDEBAR OVERLAY (mobile) ─── */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.6);
  z-index: 29;
}

/* ─── GATE ─── */
.gate {
  text-align: center;
  max-width: 540px;
  margin: 60px auto;
  padding: 40px 32px;
}
.gate-logo {
  display: block;
  width: min(260px, 72%);
  height: auto;
  border-radius: 14px;
  margin: 0 auto 22px;
}
.gate h2 { font-size: 1.4rem; margin: 0 0 8px; }
.gate p { color: var(--muted); margin: 0 0 24px; font-size: .9rem; line-height: 1.6; }

/* ─── CARDS / GRID ─── */
.grid { display: grid; gap: 14px; }
.g2 { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.g3 { grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }
.g4 { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
}
.card h2, .card h3 { margin: 0 0 12px; }
.card h3 { font-size: .95rem; color: #c8d4f0; font-weight: 600; }
.sub { color: var(--muted); font-size: .83rem; line-height: 1.5; }

/* ─── STATS ─── */
.stat .label { color: var(--muted); font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; }
.stat .value { font-size: 1.45rem; font-weight: 700; margin-top: 3px; font-variant-numeric: tabular-nums; }
.stat .note { color: var(--muted); font-size: .76rem; margin-top: 3px; }
.value.pos, .pos { color: var(--ok); }
.neg { color: var(--bad); }

/* ─── BADGES ─── */
.badges { display: flex; gap: 6px; flex-wrap: wrap; margin: 6px 0; }
.badge {
  font-size: .7rem;
  padding: 3px 9px;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--muted);
  font-weight: 500;
}
.badge.ok   { color: var(--ok);   border-color: #1d5c46; background: rgba(46,204,143,.07); }
.badge.warn { color: var(--warn); border-color: #6b5217; background: rgba(245,184,74,.07); }
.badge.bad  { color: var(--bad);  border-color: #6b2530; background: rgba(255,93,108,.07); }
.badge.brand{ color: var(--brand);border-color: #5a460d; background: rgba(200,168,75,.08); }

/* ─── PROGRESS ─── */
.progress {
  height: 8px;
  background: #0a0f1e;
  border-radius: 999px;
  overflow: hidden;
  border: 1px solid var(--line);
}
.progress > i {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--brand2), var(--brand));
  width: 0;
  transition: width .4s ease;
}

/* ─── BUTTONS ─── */
.btn {
  background: #172040;
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 9px 16px;
  cursor: pointer;
  font: inherit;
  font-size: .85rem;
  font-weight: 600;
  transition: border-color .15s, background .15s;
  white-space: nowrap;
}
.btn:hover { border-color: #3a508a; background: #1d2a50; }
.btn:disabled { opacity: .4; cursor: not-allowed; }
.btn-primary {
  background: linear-gradient(135deg, var(--brand2), #0f3875);
  border: 1px solid var(--brand);
  color: var(--brand);
}
.btn-primary:hover { background: linear-gradient(135deg, #1e4a8a, #153d80); }
.btn-danger { background: #3a1620; border-color: #6b2530; color: #ffb3bb; }
.btn-ghost { background: transparent; }
.btn-sm { padding: 5px 10px; font-size: .78rem; }

label {
  display: block;
  font-size: .77rem;
  color: var(--muted);
  margin: 10px 0 4px;
  font-weight: 500;
}
input, select {
  width: 100%;
  background: #050a14;
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 9px 12px;
  font: inherit;
  font-size: .88rem;
  transition: border-color .15s;
}
input:focus, select:focus {
  outline: 2px solid rgba(79,140,255,.4);
  outline-offset: 0;
  border-color: #34508f;
}
.row { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.row > input { flex: 1; min-width: 180px; }
.inline { display: flex; gap: 8px; align-items: center; }
.inline input { flex: 1; }
.max { font-size: .72rem; color: var(--brand); cursor: pointer; float: right; }

/* ─── TABLES ─── */
table { width: 100%; border-collapse: collapse; font-size: .85rem; }
th, td {
  text-align: left;
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
th { color: var(--muted); font-weight: 600; font-size: .72rem; text-transform: uppercase; letter-spacing: .04em; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: rgba(255,255,255,.02); }
.tablewrap { overflow-x: auto; border-radius: 8px; }
.addr { font-family: ui-monospace, Menlo, monospace; font-size: .82em; }

/* ─── HINTS ─── */
.hint {
  background: #0a1528;
  border: 1px solid #1c3060;
  border-radius: 9px;
  padding: 10px 14px;
  font-size: .83rem;
  color: #a8bce0;
  margin: 10px 0;
  line-height: 1.5;
}
.hint.warn { background: #1e1800; border-color: #4a3d12; color: #e8c97a; }
.hint.bad  { background: #1e0a10; border-color: #5a2230; color: #ffb3bb; }

/* ─── TREE ─── */
.tree ul { list-style: none; margin: 0; padding-left: 18px; border-left: 1px dashed var(--line); }
.tree li { margin: 4px 0; }

/* ─── TOASTS ─── */
.toasts {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  display: grid;
  gap: 8px;
  z-index: 100;
  width: min(92vw, 440px);
  pointer-events: none;
}
.toast {
  background: #172040;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 11px 16px;
  box-shadow: var(--shadow);
  font-size: .86rem;
  pointer-events: all;
  animation: slideUp .2s ease;
}
@keyframes slideUp { from { opacity: 0; transform: translateY(8px); } }
.toast.ok  { border-color: #1d5c46; background: #0d2a1e; color: #6fffc0; }
.toast.err { border-color: #6b2530; background: #2a0d13; color: #ffb3bb; }

/* ─── FOOTER ─── */
.foot {
  text-align: center;
  color: var(--muted);
  font-size: .74rem;
  padding: 20px 24px;
  border-top: 1px solid var(--line);
}

details { margin-top: 10px; }
summary { cursor: pointer; color: var(--muted); font-size: .85rem; }
summary:hover { color: var(--text); }

.fieldset {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 14px;
  margin-top: 12px;
}
.fieldset > legend {
  color: var(--muted);
  font-size: .76rem;
  padding: 0 8px;
  font-weight: 600;
}

.chips { display: flex; gap: 6px; flex-wrap: wrap; margin: 10px 0; }
.chip {
  padding: 6px 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font: inherit;
  font-size: .8rem;
  transition: all .15s;
}
.chip:hover { color: var(--text); border-color: #34437a; }
.chip.active { background: #172040; color: var(--text); border-color: var(--brand); }

fieldset.fieldset { min-width: 0; }

/* ─── MOBILE RESPONSIVE ─── */
@media (max-width: 960px) {
  #btnMenu { display: flex; }
  .topbar-mark { display: block; }

  .sidebar { transform: translateX(-100%); }
  body.nav-open { overflow: hidden; }
  body.nav-open .sidebar {
    transform: translateX(0);
    box-shadow: 4px 0 32px rgba(0,0,0,.6);
  }
  body.nav-open .sidebar-overlay { display: block; }

  .main-wrap { margin-left: 0; }
  .content { padding: 14px 14px 40px; }
  .stat .value { font-size: 1.2rem; }
  th, td { padding: 7px 8px; }
  .g2, .g3, .g4 { grid-template-columns: 1fr; }
}

@media (max-width: 400px) {
  .topbar { padding: 0 12px; }
  .page-title { font-size: .85rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
}

/* Disconnect button */
.btn-block { display: block; width: 100%; margin-top: 10px; }
@media (max-width: 600px) { #btnDisconnect { display: none !important; } }  /* on phones use the sidebar button */

/* Wallet picker (open in wallet dApp browser) */
.wp-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.7); z-index: 200; display: grid; place-items: center; padding: 16px; }
.wp-box { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; width: min(440px, 100%); max-height: 92vh; overflow: auto; box-shadow: var(--shadow); }
.wp-box h3 { margin: 0 0 6px; font-size: 1.05rem; color: var(--brand); }
.wp-list { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 12px; }
.wp-item { display: block; text-align: center; text-decoration: none; padding: 12px 8px; }
.wp-item:hover { text-decoration: none; border-color: var(--brand); }

/* ─── Wallet address display (overview): short by default, eye = full, click = copy ─── */
.wallet-display { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.wallet-address-short {
  cursor: pointer;
  color: var(--brand);
  font-weight: 600;
  font-size: .9rem;
  letter-spacing: .02em;
  transition: background .15s, color .15s;
}
.wallet-address-short:hover { background: rgba(200,168,75,.1); }
.wallet-address-short.wallet-full { font-size: .78rem; letter-spacing: 0; overflow-wrap: anywhere; }
.wallet-address-short:focus-visible, .wallet-toggle-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.wallet-toggle-btn {
  width: 30px; height: 30px;
  display: inline-grid; place-items: center;
  border-radius: 8px;
  background: rgba(200,168,75,.08);
  border: 1px solid rgba(200,168,75,.3);
  color: var(--brand);
  cursor: pointer;
  transition: background .15s, border-color .15s;
}
.wallet-toggle-btn:hover { background: rgba(200,168,75,.18); border-color: rgba(200,168,75,.5); }
.wallet-toggle-btn.active { background: rgba(200,168,75,.28); }
