/* ===================================================================
   Bifunder — design system
   Brand green (matches the original site's default theme), near-black
   dark surfaces, tight/data-dense layout in the style of a real trading
   platform rather than a marketing template.
   =================================================================== */
:root {
  --bg: #050706;
  --bg-elevated: #0c0f0d;
  --surface: #111412;
  --surface-2: #191d1b;
  --border: #232823;
  --text: #eef2ef;
  --text-muted: #8a9690;
  --text-faint: #57625c;

  --green: #32D74B;
  --green-2: #30D158;
  --green-dark: #248A3D;
  --green-wash: rgba(50, 215, 75, .12);

  --success: #32D74B;
  --success-bg: rgba(50, 215, 75, .12);
  --danger: #FF453A;
  --danger-bg: rgba(255, 69, 58, .12);
  --warning: #FF9F0A;
  --warning-bg: rgba(255, 159, 10, .12);
  --info: #0A84FF;
  --info-bg: rgba(10, 132, 255, .12);

  --radius: 10px;
  --radius-sm: 7px;
  --shadow: 0 12px 32px rgba(0, 0, 0, .45);
  --sidebar-w: 236px;
  --topbar-h: 60px;
}

* { box-sizing: border-box; }
html, body { padding: 0; margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 14.5px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }
h1, h2, h3, h4 { line-height: 1.2; margin: 0 0 .5em; font-weight: 700; letter-spacing: -.015em; }
p { margin: 0 0 1em; color: var(--text-muted); }
.muted { color: var(--text-muted); }
.small { font-size: 12.5px; }
.nums { font-variant-numeric: tabular-nums; }
.container { max-width: 1180px; margin: 0 auto; padding: 0 24px; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 10px 18px; border-radius: var(--radius-sm); font-weight: 600; font-size: 13.5px;
  border: 1px solid transparent; cursor: pointer; transition: filter .12s, background .12s, border-color .12s;
  white-space: nowrap;
}
.btn:active { filter: brightness(.92); }
.btn-primary { background: var(--green); color: #04150a; }
.btn-primary:hover { background: var(--green-2); }
.btn-outline { background: transparent; border-color: var(--border); color: var(--text); }
.btn-outline:hover { border-color: var(--green); color: var(--green); }
.btn-ghost { background: transparent; color: var(--text-muted); }
.btn-ghost:hover { color: var(--text); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { filter: brightness(1.08); }
.btn-sm { padding: 7px 13px; font-size: 12.5px; }
.btn-xs { padding: 5px 10px; font-size: 12px; border-radius: 6px; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }

/* ---------- forms ---------- */
.form-group { margin-bottom: 16px; }
label { display: block; font-size: 12.5px; font-weight: 600; margin-bottom: 6px; color: var(--text-muted); }
input, select, textarea {
  width: 100%; padding: 10px 13px; border-radius: var(--radius-sm); border: 1px solid var(--border);
  background: var(--surface-2); color: var(--text); font-size: 13.5px; font-family: inherit;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--green); }
input::placeholder { color: var(--text-faint); }
.field-hint { font-size: 12px; color: var(--text-faint); margin-top: 6px; }
.field-error { font-size: 12px; color: var(--danger); margin-top: 6px; }
.input-row { display: flex; gap: 12px; }
.input-row > * { flex: 1; }

/* ---------- cards ---------- */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 22px;
}
.card + .card { margin-top: 18px; }
.card-title { font-size: 14px; font-weight: 700; margin-bottom: 15px; display: flex; align-items: center; justify-content: space-between; }

/* ---------- flash ---------- */
.flash-wrap { margin: 18px 0; display: flex; flex-direction: column; gap: 9px; }
.flash { padding: 11px 15px; border-radius: var(--radius-sm); font-size: 13.5px; font-weight: 500; }
.flash-success { background: var(--success-bg); color: var(--success); }
.flash-error { background: var(--danger-bg); color: var(--danger); }
.flash-info { background: var(--info-bg); color: var(--info); }
.flash-warning { background: var(--warning-bg); color: var(--warning); }

/* Same look as .flash-*, but deliberately NOT a .flash — app.js
   auto-removes every .flash element 6 seconds after page load (meant for
   one-time server messages), which would silently delete a persistent,
   JS-driven alert (insufficient-fee warning on Send, deposit-create error
   on Deposit) before most users even finish interacting with the page. */
.alert-box { padding: 11px 15px; border-radius: var(--radius-sm); font-size: 13.5px; font-weight: 500; }
.alert-box-warning { background: var(--warning-bg); color: var(--warning); }
.alert-box-error { background: var(--danger-bg); color: var(--danger); }
.alert-box-info { background: var(--info-bg); color: var(--info); }

/* ---------- badges ---------- */
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 9px; border-radius: 5px; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .03em; }
.badge-success { background: var(--success-bg); color: var(--success); }
.badge-danger { background: var(--danger-bg); color: var(--danger); }
.badge-warning { background: var(--warning-bg); color: var(--warning); }
.badge-muted { background: var(--surface-2); color: var(--text-muted); }
.badge-info { background: var(--info-bg); color: var(--info); }

/* ---------- table ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th { text-align: left; color: var(--text-faint); font-size: 11px; text-transform: uppercase; letter-spacing: .04em; padding: 9px 13px; border-bottom: 1px solid var(--border); }
td { padding: 12px 13px; border-bottom: 1px solid var(--border); font-variant-numeric: tabular-nums; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--surface-2); }
.table-empty { text-align: center; color: var(--text-faint); padding: 36px; font-size: 13.5px; }
.row-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.row-actions form { display: inline-block; }

/* ---------- coin icons ---------- */
.coin-img { border-radius: 50%; object-fit: contain; background: #fff; padding: 2px; flex-shrink: 0; }
.coin-badge { border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; color: #fff; font-weight: 800; font-size: 11px; flex-shrink: 0; }

/* ===================================================================
   Marketing site chrome
   =================================================================== */
.brand { display: inline-flex; align-items: center; gap: 9px; font-weight: 800; font-size: 17px; }
.brand-mark {
  width: 28px; height: 28px; border-radius: 8px; background: var(--green);
  display: inline-flex; align-items: center; justify-content: center; color: #04150a; font-size: 14px; font-weight: 900;
}
.brand-dot { color: var(--green); }

.top-nav { position: sticky; top: 0; z-index: 20; background: rgba(5,7,6,.92); backdrop-filter: blur(10px); border-bottom: 1px solid var(--border); }
.nav-inner { display: flex; align-items: center; justify-content: space-between; height: 66px; }
.main-links { display: flex; gap: 26px; font-size: 13.5px; font-weight: 600; color: var(--text-muted); }
.main-links a:hover { color: var(--text); }
.nav-cta { display: flex; align-items: center; gap: 10px; }
.nav-toggle { display: none; flex-direction: column; gap: 4px; background: none; border: none; cursor: pointer; padding: 8px; }
.nav-toggle span { width: 20px; height: 2px; background: var(--text); }

.main-wrap { min-height: 60vh; }

.site-footer { border-top: 1px solid var(--border); margin-top: 72px; padding: 48px 0 26px; }
.footer-grid { display: grid; grid-template-columns: 2fr 1fr 1fr 1fr; gap: 30px; }
.footer-grid h4 { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--text-faint); margin-bottom: 12px; }
.footer-grid a { display: block; color: var(--text-muted); font-size: 13.5px; margin-bottom: 9px; }
.footer-grid a:hover { color: var(--green); }
.footer-brand { margin-bottom: 10px; }
.footer-bottom { margin-top: 36px; padding-top: 22px; border-top: 1px solid var(--border); }

/* ---------- hero: asymmetric, not a centered gradient template ---------- */
.hero { padding: 64px 0 40px; }
.hero-grid { display: grid; grid-template-columns: 1.1fr .9fr; gap: 48px; align-items: center; }
.hero h1 { font-size: clamp(30px, 4vw, 46px); margin: 0 0 18px; }
.hero .lead { max-width: 480px; font-size: 16px; margin-bottom: 28px; }
.hero-cta { display: flex; gap: 12px; margin-bottom: 36px; }
.hero-stats { display: flex; gap: 36px; }
.hero-stat b { display: block; font-size: 22px; font-variant-numeric: tabular-nums; }

/* live-look ticker card that stands in for a product screenshot */
.ticker-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.ticker-card-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; border-bottom: 1px solid var(--border); }
.ticker-card-head .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 3px var(--green-wash); }
.ticker-row { display: flex; align-items: center; gap: 11px; padding: 12px 18px; border-bottom: 1px solid var(--border); }
.ticker-row:last-child { border-bottom: none; }
.ticker-row .sym { font-weight: 700; flex: 1; }
.ticker-row .px { font-variant-numeric: tabular-nums; }
.ticker-row .chg { font-variant-numeric: tabular-nums; font-size: 12.5px; min-width: 64px; text-align: right; }

.section { padding: 60px 0; }
.section-head { max-width: 560px; margin: 0 0 36px; }
.section-head.center { margin: 0 auto 36px; text-align: center; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 18px; }
.feature-card { padding: 24px; }
.feature-icon { width: 34px; height: 34px; color: var(--green); margin-bottom: 14px; }
.feature-icon svg { width: 100%; height: 100%; fill: none; stroke: currentColor; stroke-width: 1.6; }

.auth-wrap { max-width: 400px; margin: 56px auto; }
.auth-wrap .card { padding: 28px; }
.auth-head { margin-bottom: 22px; }
.auth-foot { text-align: center; margin-top: 18px; font-size: 13.5px; color: var(--text-muted); }
.legal-content { max-width: 720px; margin: 0 auto; padding: 56px 0; }
.legal-content h2 { margin-top: 30px; }

/* ===================================================================
   App shell (dashboard + admin)
   =================================================================== */
body.page-dashboard, body.page-admin { background: var(--bg); }
.sidebar {
  position: fixed; top: 0; left: 0; bottom: 0; width: var(--sidebar-w);
  background: var(--bg-elevated); border-right: 1px solid var(--border);
  padding: 18px 12px; overflow-y: auto; z-index: 30;
}
.sidebar-brand { padding: 6px 8px 18px; }
.sidebar-tag { font-size: 10.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--text-faint); padding: 0 8px 10px; }
.sidebar-nav { display: flex; flex-direction: column; gap: 1px; }
.sidebar-nav a { display: flex; align-items: center; gap: 11px; padding: 9px 10px; border-radius: 7px; color: var(--text-muted); font-size: 13.5px; font-weight: 600; }
.sidebar-nav a svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.8; flex-shrink: 0; }
.sidebar-nav a:hover { background: var(--surface); color: var(--text); }
.sidebar-nav a.active { background: var(--green-wash); color: var(--green); }
.sidebar-divider { height: 1px; background: var(--border); margin: 10px 4px; }

.app-shell { margin-left: var(--sidebar-w); min-height: 100vh; }
.app-topbar {
  height: var(--topbar-h); display: flex; align-items: center; justify-content: flex-end; gap: 14px;
  padding: 0 26px; border-bottom: 1px solid var(--border); position: sticky; top: 0; background: rgba(5,7,6,.92);
  backdrop-filter: blur(10px); z-index: 10;
}
.topbar-spacer { flex: 1; }
.topbar-actions { display: flex; align-items: center; gap: 13px; }
.topbar-user { display: flex; align-items: center; gap: 8px; }
.avatar-dot { width: 28px; height: 28px; border-radius: 50%; background: var(--green); color: #04150a; display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 12px; }
.topbar-email { font-size: 12.5px; color: var(--text-muted); }
.sidebar-toggle { display: none; flex-direction: column; justify-content: center; align-items: center; gap: 4px; background: none; border: none; cursor: pointer; width: 44px; height: 44px; margin: 0 -10px 0 0; padding: 0; }
.sidebar-toggle span { width: 20px; height: 2px; background: var(--text); }
.app-main { padding: 26px; max-width: 1280px; }
.app-main .flash-wrap { margin: 0 0 18px; }

.page-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 22px; flex-wrap: wrap; gap: 12px; }
.page-head h1 { font-size: 21px; margin: 0; }

/* stat tiles */
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 22px; }
.stat-tile { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; }
.stat-tile .stat-label { font-size: 11px; color: var(--text-faint); text-transform: uppercase; letter-spacing: .04em; margin-bottom: 7px; }
.stat-tile .stat-value { font-size: 21px; font-weight: 800; font-variant-numeric: tabular-nums; }
.stat-tile .stat-sub { font-size: 12px; margin-top: 5px; }
.stat-up { color: var(--success); }
.stat-down { color: var(--danger); }

/* balances grid */
.balance-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 14px; }
.balance-item { background: var(--surface-2); border-radius: var(--radius-sm); padding: 14px; display: flex; align-items: center; gap: 11px; }
.coin-icon { width: 32px; height: 32px; border-radius: 50%; background: var(--surface); display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 11px; color: var(--green); flex-shrink: 0; }
.coin-amt { font-weight: 700; font-variant-numeric: tabular-nums; }
.coin-usd { font-size: 12px; color: var(--text-faint); font-variant-numeric: tabular-nums; }

/* choices (crypto/plan pickers) */
.choice-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; margin-bottom: 18px; }
.choice {
  border: 1.5px solid var(--border); border-radius: var(--radius-sm); padding: 12px; cursor: pointer;
  display: flex; align-items: center; gap: 9px; background: var(--surface-2); transition: border-color .12s;
  font: inherit; color: inherit; text-align: left; width: 100%;
}
.choice:hover { border-color: var(--green); }
.choice.selected { border-color: var(--green); background: var(--green-wash); }
.choice input { display: none; }

/* quick amount pills */
.quick-pills { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.pill { padding: 4px 10px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface-2); color: var(--text-muted); font-size: 11.5px; font-weight: 600; cursor: pointer; }
.pill:hover { border-color: var(--green); color: var(--text); }
.pill.selected { border-color: var(--green); background: var(--green-wash); color: var(--green); }

/* compact form-group variant (amount field + pills) */
.form-group-tight { margin-bottom: 14px; }
.form-group-tight input { padding: 8px 12px; font-size: 13px; }

/* order summary — a compact receipt-style strip, not a big card */
.order-summary { background: var(--surface-2); border-radius: var(--radius-sm); padding: 4px 14px; margin: 14px 0; }
.order-summary-compact .order-row { padding: 5px 0; font-size: 12.5px; }
.order-row { display: flex; justify-content: space-between; align-items: baseline; padding: 6px 0; font-size: 13.5px; }
.order-row span { color: var(--text-muted); }
.order-row.total { border-top: 1px solid var(--border); margin-top: 2px; padding-top: 8px; padding-bottom: 8px; font-size: 13.5px; }
.order-row.total span { color: var(--text); font-weight: 600; }

/* card brand badge */
.card-brand-icon { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); font-size: 11px; font-weight: 800; letter-spacing: .03em; color: var(--text-faint); pointer-events: none; }
.card-brand-icon.known { color: var(--green); }

/* processing progress bar */
.progress-track { width: 100%; max-width: 280px; height: 4px; border-radius: 2px; background: var(--border); overflow: hidden; margin-top: 6px; }
.progress-fill { height: 100%; width: 0; background: var(--green); transition: width .25s linear; }

/* deposit address box */
.address-box { background: var(--surface-2); border: 1px dashed var(--border); border-radius: var(--radius-sm); padding: 16px; text-align: center; }
.address-value { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px; word-break: break-all; margin: 11px 0; padding: 11px; background: var(--bg-elevated); border-radius: 7px; }
.qr-box { display: flex; justify-content: center; margin: 14px 0; }
.qr-box img, .qr-box canvas { background: #fff; padding: 10px; border-radius: 8px; }
.status-pill { display: inline-flex; align-items: center; gap: 6px; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--warning); animation: pulse 1.4s infinite; }
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:.3} }

/* processing / success states (buy flow) */
.result-box { text-align: center; padding: 44px 22px; }
.result-icon { width: 62px; height: 62px; border-radius: 50%; display: flex; align-items: center; justify-content: center; margin: 0 auto 18px; }
.result-icon.success { background: var(--success-bg); color: var(--success); }
.result-icon svg { width: 30px; height: 30px; }
.spinner { width: 36px; height: 36px; border: 3px solid var(--border); border-top-color: var(--green); border-radius: 50%; margin: 0 auto 18px; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* chat widget */
.chat-window { display: flex; flex-direction: column; height: 460px; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.chat-messages { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 10px; background: var(--bg-elevated); }
.chat-msg { max-width: 75%; padding: 9px 13px; border-radius: 12px; font-size: 13.5px; }
.chat-msg.user { align-self: flex-end; background: var(--green); color: #04150a; border-bottom-right-radius: 4px; }
.chat-msg.admin, .chat-msg.ai { align-self: flex-start; background: var(--surface-2); border-bottom-left-radius: 4px; }
.chat-msg .chat-meta { display: block; font-size: 10px; opacity: .7; margin-top: 4px; }
.chat-input-row { display: flex; gap: 10px; padding: 13px; border-top: 1px solid var(--border); }
.chat-input-row input { flex: 1; }

/* ---------- admin: balance master/detail ---------- */
.balance-manager { display: grid; grid-template-columns: 300px 1fr; gap: 18px; align-items: start; }
.balance-user-list { padding: 0; overflow: hidden; }
.balance-user-list .card-title { padding: 16px 18px 0; margin-bottom: 10px; }
.user-list-scroll { max-height: 640px; overflow-y: auto; }
.user-list-item { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 18px; border-top: 1px solid var(--border); }
.user-list-item:first-child { border-top: none; }
.user-list-item:hover { background: var(--surface-2); }
.user-list-item.active { background: var(--green-wash); border-left: 2px solid var(--green); }
.user-list-name { font-weight: 600; font-size: 13px; }
.user-list-value { font-size: 12.5px; color: var(--text-muted); font-variant-numeric: tabular-nums; flex-shrink: 0; }
.balance-detail-head { display: flex; align-items: center; justify-content: space-between; padding-bottom: 16px; margin-bottom: 16px; border-bottom: 1px solid var(--border); }
.balance-detail-total { text-align: right; }
.asset-row { display: flex; align-items: center; gap: 16px; padding: 14px 0; border-bottom: 1px solid var(--border); }
.asset-row:last-child { border-bottom: none; }
.asset-row-info { display: flex; align-items: center; gap: 10px; width: 130px; flex-shrink: 0; }
.asset-row-balance { width: 150px; flex-shrink: 0; }
.asset-row-form { display: flex; flex-wrap: wrap; gap: 8px; flex: 1; }
.asset-row-form select { max-width: 110px; }
.asset-row-form input { max-width: 140px; }
.asset-row-form .adj-wallet { max-width: none; flex: 1 1 100%; }

/* responsive */
@media (max-width: 960px) {
  .hero-grid { grid-template-columns: 1fr; }
  .grid-3, .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .footer-grid { grid-template-columns: 1fr 1fr; }
  .balance-manager { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  .sidebar { transform: translateX(-100%); transition: transform .2s; box-shadow: var(--shadow); }
  body.sidebar-open .sidebar { transform: translateX(0); }
  .app-shell { margin-left: 0; }
  .sidebar-toggle { display: flex; }
  .topbar-email { display: none; }
}
@media (max-width: 720px) {
  .main-links, .nav-cta { display: none; }
  .nav-toggle { display: flex; }
  .grid-3, .grid-4, .stat-grid { grid-template-columns: 1fr 1fr; }
  .footer-grid { grid-template-columns: 1fr; }
  .input-row { flex-direction: column; }
  .asset-row { flex-wrap: wrap; }
  .asset-row-form { width: 100%; }

  /* Mobile nav dropdown — tapping .nav-toggle adds body.menu-open (see
     app.js's generic data-toggle-class handler); these are the rules that
     actually reveal it. Without them the class toggles but nothing visible
     ever happens, which is exactly the bug this fixes. */
  body.menu-open .nav-inner { flex-wrap: wrap; height: auto; min-height: 66px; }
  body.menu-open .top-nav { box-shadow: var(--shadow); }
  body.menu-open .main-links {
    display: flex; flex-direction: column; width: 100%; order: 3; gap: 2px;
    margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--border);
  }
  body.menu-open .main-links a { padding: 10px 4px; }
  body.menu-open .nav-cta {
    display: flex; flex-direction: column; align-items: stretch; width: 100%; order: 4;
    gap: 8px; padding-bottom: 14px;
  }
}
