/* =====================================================================
   NovaTrade — Design tokens & core theme
   Palette: navy trading terminal (same as the admin panel), blue brand accent.
   Wallet tiers echo the metal motif — Demo=silver, Wallet 2=bronze,
   Live=gold — so the "which wallet am I on" read is immediate.
   Type: Space Grotesk (display) + Inter (body) + JetBrains Mono (data)
   ===================================================================== */

:root {
  --bg-primary: #050d20;
  --bg-surface: #0a1733;
  --bg-surface-2: #0e1f43;
  --bg-surface-3: #142a57;
  --border-subtle: #183056;
  --border-strong: #21407a;
  --text-primary: #e9effd;
  --text-secondary: #8da2cc;
  --text-muted: #5f76a3;

  --brand: #2f6bff;
  --brand-rgb: 47, 107, 255;
  --brand-dim: #2457d6;
  --brand-light: #6c95ff;
  --brand-glow: rgba(47, 107, 255, 0.35);

  --silver: #b8c4dd;
  --silver-dim: rgba(184, 196, 221, 0.14);
  --bronze: #ffa31a;
  --bronze-dim: rgba(255, 163, 26, 0.16);

  --up: #1fc98a;
  --up-rgb: 31, 201, 138;
  --up-dim: rgba(31, 201, 138, 0.14);
  --down: #ff4d6a;
  --down-rgb: 255, 77, 106;
  --down-dim: rgba(255, 77, 106, 0.14);
  --warn: #ffa31a;

  --font-display: 'Space Grotesk', 'Inter', sans-serif;
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'JetBrains Mono', 'SFMono-Regular', Menlo, monospace;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --shadow-card: 0 4px 24px rgba(1, 6, 20, 0.5);
}

* { box-sizing: border-box; }

html, body {
  background: var(--bg-primary);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 15px;
  min-height: 100%;
}

h1, h2, h3, h4, h5, .font-display {
  font-family: var(--font-display);
  letter-spacing: -0.01em;
}

.mono, .price, .balance-figure, .ticker-item, table td.num {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

a { color: var(--brand-text); text-decoration: none; }
a:hover { color: var(--brand-light); }
html[data-theme="light"] a:hover { color: var(--brand-dim); }

::selection { background: var(--brand-glow); }

/* Focus visibility (accessibility floor) */
a:focus-visible, button:focus-visible, input:focus-visible,
select:focus-visible, textarea:focus-visible, .btn:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition-duration: 0.001ms !important; }
}

/* ---------------------------------------------------------------------
   Layout shell
   --------------------------------------------------------------------- */
.app-shell { display: flex; min-height: 100vh; min-height: 100dvh; }

.sidebar {
  width: 76px;
  background: var(--bg-surface);
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 20px 0;
  gap: 6px;
  position: sticky;
  top: 0;
  height: 100vh;
  height: 100dvh;
  flex-shrink: 0;
}

.sidebar .brand-mark {
  width: 40px; height: 40px;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, var(--brand), var(--brand-dim));
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-family: var(--font-display); font-weight: 700; font-size: 18px;
  margin-bottom: 18px;
}

.sidebar .nav-icon {
  width: 46px; height: 46px;
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  color: var(--text-secondary);
  transition: background 0.15s, color 0.15s;
  position: relative;
}
.sidebar .nav-icon:hover { background: var(--bg-surface-2); color: var(--text-primary); }
.sidebar .nav-icon.active { background: var(--bg-surface-2); color: var(--brand-text); }
.sidebar .nav-icon.active::before {
  content: ''; position: absolute; left: -20px; top: 50%; transform: translateY(-50%);
  width: 3px; height: 20px; background: var(--brand); border-radius: 3px;
}
.sidebar .nav-icon .badge-dot {
  position: absolute; top: 6px; right: 6px; width: 8px; height: 8px;
  background: var(--down); border-radius: 50%; border: 2px solid var(--bg-surface);
  animation: badge-pulse 1.6s ease-in-out infinite;
}

@keyframes badge-pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.35); }
}

.main-area { flex: 1; min-width: 0; display: flex; flex-direction: column; }

/* The page content area between the topbar and the footer. This has to
   be an explicit flex column (not just a Bootstrap flex-grow-1 item) or
   .trade-workspace below it has no real height to fill, and the
   TradingView chart ends up sized ambiguously. */
.page-main { display: flex; flex-direction: column; flex: 1; min-height: 0; }

.topbar {
  height: 60px;
  border-bottom: 1px solid var(--border-subtle);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 20px;
  background: var(--bg-primary);
  position: sticky; top: 0; z-index: 20;
}

.wallet-toggle {
  display: flex; background: var(--bg-surface); border-radius: 999px; padding: 3px; gap: 2px;
  border: 1px solid var(--border-subtle);
}
.wallet-toggle button {
  border: none; background: transparent; color: var(--text-secondary);
  padding: 7px 14px; border-radius: 999px; font-size: 12.5px; font-weight: 600;
  font-family: var(--font-display); white-space: nowrap;
  transition: background 0.15s, color 0.15s;
}
.wallet-toggle button.active.demo { background: var(--bg-surface-3); color: var(--silver); }
.wallet-toggle button.active.demo2 { background: var(--bronze-dim); color: var(--bronze); }

.balance-figure { font-size: 15px; font-weight: 600; }

/* ---------------------------------------------------------------------
   Signature element: live ticker tape
   --------------------------------------------------------------------- */
.ticker-tape {
  overflow: hidden;
  white-space: nowrap;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-subtle);
  padding: 9px 0;
  position: relative;
}
.ticker-tape::before, .ticker-tape::after {
  content: ''; position: absolute; top: 0; bottom: 0; width: 60px; z-index: 2; pointer-events: none;
}
.ticker-tape::before { left: 0; background: linear-gradient(90deg, var(--bg-surface), transparent); }
.ticker-tape::after { right: 0; background: linear-gradient(270deg, var(--bg-surface), transparent); }

.ticker-track {
  display: inline-flex;
  animation: ticker-scroll 32s linear infinite;
}
.ticker-tape:hover .ticker-track { animation-play-state: paused; }

@keyframes ticker-scroll {
  from { transform: translateX(0); }
  to { transform: translateX(-50%); }
}

.ticker-item {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 0 22px; font-size: 13px; border-right: 1px solid var(--border-subtle);
}
.ticker-item .sym { color: var(--text-secondary); font-weight: 600; }
.ticker-item .chg.up { color: var(--up-text); border-radius: 4px; animation: price-flash-up 0.8s ease; }
.ticker-item .chg.down { color: var(--down-text); border-radius: 4px; animation: price-flash-down 0.8s ease; }

@keyframes price-flash-up {
  0% { background: rgba(var(--up-rgb), 0.35); }
  100% { background: transparent; }
}
@keyframes price-flash-down {
  0% { background: rgba(var(--down-rgb), 0.35); }
  100% { background: transparent; }
}

/* ---------------------------------------------------------------------
   Trading workspace
   --------------------------------------------------------------------- */
.trade-workspace { display: flex; flex: 1; min-height: 0; }

.chart-pane { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.chart-header {
  display: flex; align-items: center; gap: 16px; padding: 12px 18px;
  border-bottom: 1px solid var(--border-subtle);
  position: relative;
}
.asset-picker-btn {
  display: flex; align-items: center; gap: 10px;
  background: var(--bg-surface); border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md); padding: 8px 14px; color: var(--text-primary);
}
.asset-picker-btn .payout-chip {
  background: var(--up-dim); color: var(--up-text); font-size: 12px; font-weight: 700;
  padding: 2px 9px; border-radius: 999px; font-family: var(--font-mono);
}
.asset-picker-btn .cfd-chip {
  background: var(--bg-surface-3, rgba(128,128,128,.18)); color: var(--text-secondary); font-size: 10.5px; font-weight: 700;
  padding: 2px 7px; border-radius: 5px; letter-spacing: .04em; cursor: help;
}
.chart-canvas-wrap { flex: 1; min-height: 390px; position: relative; }
.chart-canvas-wrap #tv_chart_container { display: block; width: 100%; height: 100%; }

/* Asset picker: a small dropdown on desktop, a full-height slide-in
   sheet on mobile/tablet — see the media query at the bottom of this
   file. Same markup and JS (trade-sheets.js) drive both. */
.asset-sheet {
  display: none;
  position: absolute; top: calc(100% + 8px); left: 18px;
  width: 300px; max-height: 420px; overflow-y: auto;
  background: var(--bg-surface-2); border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md); z-index: 45; padding: 10px;
  box-shadow: var(--shadow-card);
}
.asset-sheet.open { display: block; }

.sheet-grip {
  display: none;
  width: 36px; height: 4px; border-radius: 2px;
  background: var(--border-strong);
  margin: 4px auto 0;
}

.asset-sheet-header {
  display: none; align-items: center; justify-content: space-between;
  padding: 4px 4px 12px; font-family: var(--font-display); font-weight: 700;
  border-bottom: 1px solid var(--border-subtle); margin-bottom: 10px;
}
.asset-sheet .sheet-close {
  background: none; border: none; color: var(--text-secondary); font-size: 22px; line-height: 1;
}
.asset-group-label {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-muted);
  font-weight: 700; padding: 10px 8px 6px;
}
.asset-option {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 10px; border-radius: var(--radius-sm); color: var(--text-primary);
}
.asset-option:hover { background: var(--bg-surface-3); color: var(--text-primary); }
.asset-option.active { background: rgba(var(--brand-rgb), 0.14); }
.asset-option .opt-payout { color: var(--up-text); font-family: var(--font-mono); font-size: 12.5px; font-weight: 700; }
.fav-star {
  background: none; border: none; padding: 0 2px; font-size: 15px; line-height: 1;
  color: var(--border-strong); cursor: pointer;
}
.fav-star.active { color: var(--brand-text); }

.sheet-backdrop {
  display: none;
  position: fixed; inset: 0; background: rgba(0,0,0,0.55); z-index: 63;
}
.sheet-backdrop.open { display: block; }

.trade-panel {
  width: 320px; flex-shrink: 0;
  background: linear-gradient(180deg, var(--bg-surface), var(--bg-surface-2));
  border-left: 1px solid var(--border-subtle);
  padding: 12px;
  display: flex; flex-direction: column; gap: 9px;
  overflow-y: auto;
}

.trade-panel label.field-label {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em;
  color: var(--text-muted); font-weight: 600; margin-bottom: 6px; display: block;
}
.panel-card {
  background: var(--bg-surface-2); border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md); padding: 9px 11px;
}
.panel-card .field-label { margin-bottom: 5px; }

.amount-input-wrap {
  display: flex; align-items: center; background: var(--bg-surface-2);
  border: 1px solid var(--border-subtle); border-radius: var(--radius-md); overflow: hidden;
}
.amount-input-wrap span { padding: 0 10px; color: var(--text-secondary); font-family: var(--font-mono); }
.amount-input-wrap input {
  flex: 1; background: transparent; border: none; color: var(--text-primary);
  padding: 9px 10px 9px 0; font-family: var(--font-mono); font-size: 14.5px; font-weight: 600;
}
.amount-input-wrap input:focus { outline: none; }
.amount-quick { display: flex; gap: 5px; margin-top: 6px; }
.amount-quick button {
  flex: 1; background: var(--bg-surface-2); border: 1px solid var(--border-subtle);
  color: var(--text-secondary); border-radius: var(--radius-sm); padding: 5px 0; font-size: 11.5px;
}
.amount-quick button:hover { border-color: var(--brand); color: var(--text-primary); }

.duration-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px; }
.duration-grid button {
  background: var(--bg-surface-2); border: 1px solid var(--border-subtle);
  color: var(--text-secondary); border-radius: var(--radius-sm); padding: 8px 0; font-size: 12.5px; font-weight: 600;
}
.duration-grid button.active { border-color: var(--brand); color: var(--text-primary); background: rgba(var(--brand-rgb), 0.12); }

.trade-panel-header {
  display: none;
  font-family: var(--font-display); font-weight: 700; font-size: 14px;
  color: var(--text-primary); padding: 0 2px;
}

.payout-preview {
  background: linear-gradient(135deg, var(--bg-surface-2), var(--bg-surface-3));
  border-radius: var(--radius-md); padding: 10px 12px;
  display: flex; justify-content: space-between; align-items: baseline;
  border: 1px solid var(--brand-glow);
}
.payout-preview .amt { font-family: var(--font-mono); font-size: 16px; font-weight: 700; color: var(--up-text); }

/* Buy/Sell: a centered pair of outlined pill buttons (not two stacked
   solid blocks) — border + tinted text in the direction's color, filling
   in with a soft tint on press/hover instead of a flat block of color. */
.direction-row { display: flex; justify-content: center; gap: 10px; }
.btn-direction {
  display: flex; align-items: center; justify-content: center; flex: 1 1 0; max-width: 220px;
  border: 1.5px solid; border-radius: 999px; background: transparent;
  padding: 11px 0; font-family: var(--font-display); font-weight: 700; font-size: 14px;
  letter-spacing: 0.01em; transition: transform 0.08s, background-color 0.15s, box-shadow 0.15s; gap: 5px;
}
.btn-direction:active { transform: scale(0.98); }
.btn-up { border-color: var(--up); color: var(--up-text); }
.btn-up:hover { background: var(--up-dim); box-shadow: 0 6px 20px rgba(var(--up-rgb), 0.18); }
.btn-up:active { background: var(--up-dim); }
.btn-down { border-color: var(--down); color: var(--down-text); }
.btn-down:hover { background: var(--down-dim); box-shadow: 0 6px 20px rgba(var(--down-rgb), 0.18); }
.btn-down:active { background: var(--down-dim); }

/* Brief highlight on the BUY/SELL button the user tapped on the Market
   page, after landing here with that direction already in mind. */
.btn-direction.pulse-hint { animation: btn-pulse-hint 0.8s ease 2; }
@keyframes btn-pulse-hint {
  0% { box-shadow: 0 0 0 0 rgba(var(--up-rgb), 0.45); }
  70% { box-shadow: 0 0 0 10px rgba(var(--up-rgb), 0); }
  100% { box-shadow: 0 0 0 0 rgba(var(--up-rgb), 0); }
}
.btn-down.pulse-hint { animation-name: btn-pulse-hint-down; }
@keyframes btn-pulse-hint-down {
  0% { box-shadow: 0 0 0 0 rgba(var(--down-rgb), 0.45); }
  70% { box-shadow: 0 0 0 10px rgba(var(--down-rgb), 0); }
  100% { box-shadow: 0 0 0 0 rgba(var(--down-rgb), 0); }
}

/* ---------------------------------------------------------------------
   Cards, tables, badges (shared across user + admin)
   --------------------------------------------------------------------- */
.card-surface {
  background: var(--bg-surface); border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-card);
  overflow-x: auto; /* wide tables (e.g. admin trade settlement) scroll
                        horizontally on narrow screens instead of
                        squeezing every column unreadably thin */
}

.table-nova {
  width: 100%; border-collapse: collapse; font-size: 13.5px;
}
@media (max-width: 767px) {
  .table-nova { min-width: 640px; }
}
.table-nova th {
  text-align: left; color: var(--text-muted); font-weight: 600; text-transform: uppercase;
  font-size: 11px; letter-spacing: 0.05em; padding: 10px 14px; border-bottom: 1px solid var(--border-subtle);
}
.table-nova td { padding: 12px 14px; border-bottom: 1px solid var(--border-subtle); vertical-align: middle; }
.table-nova tbody tr:hover { background: var(--bg-surface-2); }

.badge-status {
  display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px; border-radius: 999px;
  font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.03em;
}
.badge-won { background: var(--up-dim); color: var(--up-text); }
.badge-lost { background: var(--down-dim); color: var(--down-text); }
.badge-active { background: rgba(var(--brand-rgb), 0.14); color: var(--brand-text); }
.badge-pending { background: rgba(255,180,84,0.14); color: var(--warn-text); }
.badge-silver { background: rgba(184,184,184,0.14); color: var(--silver); }
.badge-bronze { background: var(--bronze-dim); color: var(--bronze); }

.btn-nova {
  font-family: var(--font-display); font-weight: 600; border-radius: var(--radius-sm);
  padding: 9px 18px; border: 1px solid transparent; font-size: 13.5px;
}
.btn-nova-primary { background: var(--brand); color: #fff; }
.btn-nova-primary:hover { background: var(--brand-dim); color: #fff; }
.btn-nova-outline { background: transparent; border-color: var(--border-strong); color: var(--text-primary); }
.btn-nova-outline:hover { border-color: var(--brand); color: var(--brand-text); }
.btn-nova-win { background: var(--up); color: #071a15; }
.btn-nova-lose { background: var(--down); color: #290812; }

.form-control-nova {
  background: var(--bg-surface-2); border: 1px solid var(--border-subtle); color: var(--text-primary);
  border-radius: var(--radius-sm); padding: 10px 12px; width: 100%;
}
.form-control-nova:focus { outline: none; border-color: var(--brand); background: var(--bg-surface-3); }

.stat-card {
  background: var(--bg-surface); border: 1px solid var(--border-subtle); border-radius: var(--radius-lg);
  padding: 18px 20px;
}
.stat-card .stat-label { color: var(--text-muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0.05em; }
.stat-card .stat-value { font-family: var(--font-display); font-size: 26px; font-weight: 700; margin-top: 6px; }

.wallet-pnl-row {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  background: var(--bg-surface-2); border: 1px solid var(--border-subtle); border-radius: 10px;
  padding: 8px 10px;
}
.wallet-pnl-label {
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--text-muted);
}
.wallet-pnl-value { font-family: var(--font-mono); font-weight: 700; font-size: 14px; color: var(--text-muted); }
.wallet-pnl-value.up { color: var(--up-text); }
.wallet-pnl-value.down { color: var(--down-text); }
.wallet-pnl-filter {
  margin-left: auto; background: var(--bg-surface-3); color: var(--text-primary); border: 1px solid var(--border-subtle);
  border-radius: 8px; font-size: 12px; padding: 4px 8px;
}

/* ---------------------------------------------------------------------
   Auth pages
   --------------------------------------------------------------------- */
.auth-shell {
  min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: radial-gradient(circle at 20% 20%, rgba(var(--brand-rgb), 0.12), transparent 45%), var(--bg-primary);
  padding: 24px;
}
.auth-card { width: 100%; max-width: 400px; padding: 34px 32px; }
.auth-card .brand-row { display: flex; align-items: center; gap: 10px; margin-bottom: 26px; }

/* Countdown ring on active trade cards */
.trade-mini {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 10px 12px; background: var(--bg-surface-2); border-radius: var(--radius-sm); margin-bottom: 8px;
  border: 1px solid var(--border-subtle);
}
.trade-mini .countdown { font-family: var(--font-mono); font-size: 12.5px; color: var(--warn-text); }
.countdown-bar {
  width: 100%; height: 3px; background: var(--bg-surface-3); border-radius: 2px;
  overflow: hidden; margin-top: 4px;
}
.countdown-bar-fill {
  height: 100%; width: 100%; background: var(--brand); border-radius: 2px;
  transition: width 1s linear;
}

.flash-alert {
  border-radius: var(--radius-md); padding: 12px 16px; margin-bottom: 16px; font-size: 14px;
  border: 1px solid transparent;
}
.flash-success { background: var(--up-dim); color: var(--up-text); border-color: rgba(var(--up-rgb), 0.3); }
.flash-error { background: var(--down-dim); color: var(--down-text); border-color: rgba(var(--down-rgb), 0.3); }

.demo-warning-banner {
  background: var(--down-dim); color: var(--down-text); border: 1px solid rgba(var(--down-rgb), 0.4);
  border-radius: var(--radius-md); padding: 10px 16px; margin: 12px 16px 0;
  font-size: 13px; font-weight: 700; letter-spacing: 0.02em; text-align: center;
}
.demo-warning-banner i { margin-right: 6px; }

/* Rises from behind the trade buttons and fades away above them — never sits
   in front of them, not even for the first frame: z-index is kept BELOW the
   mobile quick-trade dock (60) and bottom nav (70), so wherever the toast's
   path overlaps that row, those buttons are drawn on top of it, not under it. */
.trade-toast {
  position: fixed; left: 50%; bottom: 24px; z-index: 40;
  transform: translate(-50%, 0); opacity: 0;
  background: var(--bg-surface-3); color: var(--text-primary);
  border: 1px solid var(--brand); border-radius: 999px;
  padding: 10px 20px; font-size: 13px; font-weight: 600; white-space: nowrap;
  box-shadow: var(--shadow-card);
  pointer-events: none;
}
.trade-toast.show { animation: tradeToastRiseFade 2s ease-out forwards; }
@keyframes tradeToastRiseFade {
  0%   { transform: translate(-50%, 0);      opacity: 0; }
  12%  { transform: translate(-50%, -18px);  opacity: 1; }
  65%  { transform: translate(-50%, -92px);  opacity: 1; }
  100% { transform: translate(-50%, -156px); opacity: 0; }
}
@media (max-width: 991px) {
  /* Starts level with the quick-trade dock (bottom: 62px there) so it begins
     visually hidden behind it, then clears above the dock's top edge well
     before the animation ends. */
  .trade-toast { bottom: calc(62px + env(safe-area-inset-bottom, 0px)); }
}

/* ---------------------------------------------------------------------
   Mobile bottom tab bar — replaces the sidebar entirely on small
   screens. Deliberately plain links + a native <details>/<summary> for
   the overflow sheet, so it needs zero JavaScript to open, close, or
   navigate. Nothing here can be "broken" by a script failing to load.
   --------------------------------------------------------------------- */
.bottom-nav {
  display: none;
  position: fixed; left: 12px; right: 12px; bottom: calc(10px + env(safe-area-inset-bottom, 0px)); z-index: 70;
  background: var(--glass-bg);
  backdrop-filter: blur(18px) saturate(1.4);
  -webkit-backdrop-filter: blur(18px) saturate(1.4);
  border: 1px solid var(--glass-border);
  border-radius: 22px;
  padding: 6px;
  box-shadow: var(--shadow-card);
  /* Forces the browser to composite this on its own GPU layer — without
     this, iOS Safari in particular can visually detach fixed elements
     from the viewport mid-scroll (they lag, flicker, or briefly vanish). */
  -webkit-transform: translate3d(0, 0, 0);
  transform: translate3d(0, 0, 0);
  will-change: transform;
}
.nav-pill {
  position: absolute; top: 6px; bottom: 6px; left: 6px;
  background: var(--brand-glow); border: 1px solid var(--brand);
  border-radius: 16px; z-index: 0;
  transition: left 0.38s cubic-bezier(.34, 1.56, .64, 1), width 0.38s cubic-bezier(.34, 1.56, .64, 1);
  pointer-events: none;
}
.bottom-nav-item {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px; padding: 6px 2px; color: var(--text-secondary); font-size: 10.5px; font-weight: 600;
  border-radius: var(--radius-sm); position: relative; z-index: 1; list-style: none; cursor: pointer;
  /* Reset so <button>/<summary>-based items look identical to the <a>-based
     ones. iOS Safari in particular keeps a white/light default button
     background unless this is forced off explicitly — !important here is
     deliberate, this rule must always win over any built-in browser
     button styling, not just the usual stylesheet cascade. */
  background: none !important; background-color: transparent !important;
  border: none !important; box-shadow: none !important; outline: none !important;
  margin: 0; text-decoration: none; text-align: center; width: auto;
  font-family: var(--font-body); -webkit-appearance: none; appearance: none;
}
.bottom-nav-item:focus, .bottom-nav-item:active {
  background: none !important; box-shadow: none !important;
}
.bottom-nav-item::-webkit-details-marker { display: none; }
.bottom-nav-item i { font-size: 21px; line-height: 1; }
.bottom-nav-item.active { color: var(--brand-text); }
.bottom-nav-item .badge-dot {
  position: absolute; top: 2px; right: 26%; width: 7px; height: 7px;
  background: var(--down); border-radius: 50%; border: 2px solid var(--bg-surface);
  animation: badge-pulse 1.6s ease-in-out infinite;
}

.bottom-nav-more { flex: 1; display: flex; position: relative; z-index: 1; }
.bottom-nav-more > summary { flex: 1; }
.bottom-nav-more[open] > summary { color: var(--brand-text); }
.bottom-sheet {
  position: fixed; left: 10px; right: 10px; bottom: 78px; z-index: 71;
  background: var(--bg-surface-2); border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg); padding: 8px;
  box-shadow: var(--shadow-up);
}
.bottom-sheet a {
  display: flex; align-items: center; gap: 12px; padding: 12px 14px;
  border-radius: var(--radius-sm); color: var(--text-primary); font-size: 14.5px; font-weight: 500;
}
.bottom-sheet a:active, .bottom-sheet a:hover { background: var(--bg-surface-3); }
.bottom-sheet a i { width: 20px; text-align: center; color: var(--text-secondary); font-size: 17px; }
.bottom-sheet .sheet-divider { height: 1px; background: var(--border-subtle); margin: 6px 4px; }

@media (max-width: 991px) {
  .chart-header { flex-wrap: wrap; gap: 10px; }
  .wallet-toggle button { padding: 6px 9px; font-size: 11.5px; }

  /* Chart takes the full-width "page" on mobile; the trading form and
     asset list move into full-height slide-in sheets (opened from this
     page's own bottom nav — Chart / Assets / Trade / History) instead
     of competing for vertical space with the chart. Active Trades stays
     in normal scroll flow directly under the chart — no sheet needed
     to see what's currently running. */
  .page-main { display: block; padding-bottom: 78px; }
  .trade-workspace { flex-direction: column; flex: none; }
  .chart-pane { flex: none; }
  .chart-canvas-wrap { flex: none; height: 370px; min-height: 370px; }

  .asset-sheet {
    position: fixed; top: 0; left: 0; bottom: 0; height: 100vh; height: 100dvh; width: 300px;
    max-height: none;
    transform: translateX(-100%); transition: transform 0.25s ease;
    border-radius: 0; z-index: 65; display: block;
    padding-bottom: calc(96px + env(safe-area-inset-bottom, 0px));
  }
  .asset-sheet.open { transform: translateX(0); }
  .asset-sheet-header { display: flex; }
  .sheet-grip { display: block; }

  /* Trade panel: a bottom sheet (slides up), not a right-side drawer —
     sized to its own content (max-height as a safety cap, not a fixed
     full-screen height), so it doesn't need to scroll internally on a
     normal phone. */
  /* bottom is offset to clear the floating bottom-nav pill (fixed, ~76px tall footprint
     including its own gap from the viewport edge) instead of sitting at bottom:0 — the sheet
     used to extend UNDERNEATH the nav (lower z-index), so its last line of text and part of
     the Buy/Sell row were visually covered by the nav pill rendering on top of it. */
  .trade-panel {
    position: fixed; left: 0; right: 0; top: auto;
    bottom: calc(76px + env(safe-area-inset-bottom, 0px)); height: auto;
    max-height: calc(86vh - 76px); max-height: calc(86dvh - 76px); width: auto;
    transform: translateY(calc(100% + 76px + env(safe-area-inset-bottom, 0px))); transition: transform 0.25s ease; z-index: 65;
    border-left: none; border-top: 1px solid var(--border-subtle);
    border-radius: 18px;
    padding-bottom: 14px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.35);
  }
  .trade-panel.open { transform: translateY(0); }
  .trade-panel-header { display: block; text-align: center; }

  /* Sidebar is replaced by the site-wide bottom tab bar on every page
     except this one, which shows its own Chart/Assets/Trade/History bar. */
  .sidebar { display: none; }
  .bottom-nav { display: flex; }
}

@media (max-width: 480px) {
  .chart-canvas-wrap { height: 310px; min-height: 310px; }
  .asset-sheet { width: 260px; }
}

/* Tablet: keep the sidebar and inline trade panel (there's room), but
   still switch to the fixed chart height and stacked chart/trade-panel
   only below 991px per above — between 992-1199px nothing changes here,
   the desktop layout already fits comfortably. */
@media (min-width: 992px) and (max-width: 1199px) {
  .trade-panel { width: 300px; }
}

.onboard-overlay { position: fixed; inset: 0; z-index: 3000; transition: opacity .25s ease; }
.onboard-overlay.is-leaving { opacity: 0; }
.onboard-spot {
  position: fixed; border-radius: 12px; pointer-events: none;
  box-shadow: 0 0 0 2px var(--brand), 0 0 0 9999px rgba(8, 8, 10, 0.72);
  transition: top .32s cubic-bezier(.4,0,.2,1), left .32s cubic-bezier(.4,0,.2,1), width .32s cubic-bezier(.4,0,.2,1), height .32s cubic-bezier(.4,0,.2,1), opacity .2s;
}
.onboard-card {
  position: fixed; box-sizing: border-box;
  background: var(--bg-surface); color: var(--text-primary);
  border: 1px solid var(--border-subtle); border-top: 3px solid var(--brand); border-radius: 14px;
  padding: 18px 18px 14px; box-shadow: var(--shadow-pop, 0 18px 50px rgba(0,0,0,.45));
  opacity: 0; transform: translateY(8px); transition: opacity .22s ease, transform .22s ease, top .32s cubic-bezier(.4,0,.2,1), left .32s cubic-bezier(.4,0,.2,1);
}
.onboard-card.is-in { opacity: 1; transform: none; }
.onboard-head { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; }
.onboard-ico {
  flex: 0 0 auto; width: 38px; height: 38px; border-radius: 10px; display: flex; align-items: center; justify-content: center;
  background: var(--brand-glow); color: var(--brand-text); font-size: 18px;
}
.onboard-title { font-family: var(--font-display); font-weight: 700; font-size: 16px; line-height: 1.25; color: var(--text-primary); }
.onboard-text { font-size: 13.5px; line-height: 1.55; color: var(--text-secondary); margin-bottom: 16px; }
.onboard-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.onboard-dots { display: flex; gap: 5px; align-items: center; flex-wrap: wrap; }
.onboard-dots span { width: 6px; height: 6px; border-radius: 50%; background: var(--border-strong, var(--border-subtle)); transition: all .2s; }
.onboard-dots span.done { background: var(--brand-dim, var(--brand)); opacity: .6; }
.onboard-dots span.on { width: 18px; border-radius: 4px; background: var(--brand); }
.onboard-btns { display: flex; gap: 8px; flex: 0 0 auto; }
.onboard-btns button { border: none; border-radius: 9px; padding: 8px 16px; font-size: 13px; font-weight: 600; cursor: pointer; transition: filter .15s, background .15s; }
.onboard-back { background: var(--bg-surface-2); color: var(--text-secondary); border: 1px solid var(--border-subtle) !important; }
.onboard-back:hover { color: var(--text-primary); }
.onboard-next { background: var(--brand); color: #fff; }
.onboard-next:hover { filter: brightness(1.08); }
.onboard-btns button:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
html.onboard-active { overflow: hidden; }
@media (prefers-reduced-motion: reduce) { .onboard-spot, .onboard-card, .onboard-overlay { transition: none; } }


/* =====================================================================
   Light / dark switch
   ===================================================================== */
html, body { transition: background-color .2s ease, color .2s ease; }
html[data-theme="light"] .text-secondary { color: var(--text-secondary) !important; }
html[data-theme="light"] #novaSplash { background: #eef2fa !important; }
html[data-theme="light"] .btn-up, html[data-theme="light"] .btn-down { box-shadow: 0 6px 16px rgba(60,45,10,0.18); }

.theme-toggle {
  width: 36px; height: 36px; border-radius: 50%; flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--bg-surface-2); border: 1px solid var(--border-subtle); color: var(--text-primary);
  cursor: pointer; transition: background-color .15s, border-color .15s;
}
.theme-toggle:hover { border-color: var(--brand); }
.theme-toggle:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.theme-toggle .theme-ico-moon { display: none; }
html[data-theme="light"] .theme-toggle .theme-ico-sun { display: none; }
html[data-theme="light"] .theme-toggle .theme-ico-moon { display: inline; }
.theme-toggle-fixed { position: fixed; top: calc(14px + env(safe-area-inset-top, 0px)); right: 14px; z-index: 50; }

/* =====================================================================
   Admin popups: simple, congrats, alert, offer, task
   ===================================================================== */
.nova-pop-overlay {
  position: fixed; inset: 0; z-index: 300; background: var(--overlay);
  display: flex; align-items: center; justify-content: center; padding: 20px;
  animation: novaPopFade .18s ease-out;
}
.nova-pop {
  --pop-accent: var(--text-secondary);
  --pop-tint: var(--bg-surface-3);
  --pop-text: var(--text-primary);
  position: relative; overflow: hidden; width: 100%; max-width: 380px; text-align: center;
  background: var(--bg-surface); border: 1px solid var(--border-subtle); border-radius: 20px;
  padding: 30px 26px 24px; color: var(--text-primary); box-shadow: var(--shadow-pop);
  animation: novaPopIn .22s cubic-bezier(.2,.9,.3,1.2);
}
.nova-pop::before { content: ""; position: absolute; left: 0; right: 0; top: 0; height: 5px; background: var(--pop-accent); }
.nova-pop--congrats { --pop-accent: var(--brand); --pop-tint: var(--brand-glow); --pop-text: var(--brand-text); }
.nova-pop--alert    { --pop-accent: var(--down); --pop-tint: var(--down-dim); --pop-text: var(--down-text); }
.nova-pop--offer    { --pop-accent: var(--up);   --pop-tint: var(--up-dim);   --pop-text: var(--up-text); }
.nova-pop--task     { --pop-accent: var(--info); --pop-tint: var(--info-dim); --pop-text: var(--info-text); }
.nova-pop-badge {
  width: 64px; height: 64px; margin: 0 auto 16px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center; font-size: 28px;
  background: var(--pop-tint); color: var(--pop-text);
}
.nova-pop-title { font-family: var(--font-display); font-weight: 700; font-size: 19px; line-height: 1.25; margin-bottom: 8px; overflow-wrap: anywhere; }
.nova-pop-text { color: var(--text-secondary); font-size: 14.5px; line-height: 1.55; white-space: pre-wrap; overflow-wrap: anywhere; margin-bottom: 20px; max-height: 40vh; overflow-y: auto; }
.nova-pop-btn {
  width: 100%; border: none; border-radius: var(--radius-md); padding: 12px 16px; font-weight: 700; font-size: 14.5px;
  background: var(--pop-accent); color: #fff; cursor: pointer; transition: filter .15s, transform .08s;
}
.nova-pop--congrats .nova-pop-btn { color: #1d1b17; }
.nova-pop--offer .nova-pop-btn { color: #06190f; }
.nova-pop-btn:hover { filter: brightness(1.07); }
.nova-pop-btn:active { transform: scale(.985); }
.nova-pop-btn:focus-visible { outline: 3px solid var(--brand-glow); outline-offset: 2px; }
.nova-pop--alert .nova-pop-badge { animation: novaPopPulse 1.6s ease-in-out infinite; }
.nova-pop-sparks { position: absolute; inset: 0; pointer-events: none; }
.nova-pop-sparks i { position: absolute; top: -10px; width: 7px; height: 11px; border-radius: 2px; opacity: 0; animation: novaConfetti 2.6s ease-in infinite; }
.nova-pop-sparks i:nth-child(odd) { background: var(--brand); }
.nova-pop-sparks i:nth-child(even) { background: var(--up); }
.nova-pop-sparks i:nth-child(3n) { background: var(--info); }
.nova-pop-sparks i:nth-child(1) { left: 8%;  animation-delay: 0s; }
.nova-pop-sparks i:nth-child(2) { left: 19%; animation-delay: .5s; }
.nova-pop-sparks i:nth-child(3) { left: 30%; animation-delay: .2s; }
.nova-pop-sparks i:nth-child(4) { left: 41%; animation-delay: .9s; }
.nova-pop-sparks i:nth-child(5) { left: 52%; animation-delay: .35s; }
.nova-pop-sparks i:nth-child(6) { left: 63%; animation-delay: 1.1s; }
.nova-pop-sparks i:nth-child(7) { left: 74%; animation-delay: .15s; }
.nova-pop-sparks i:nth-child(8) { left: 84%; animation-delay: .7s; }
.nova-pop-sparks i:nth-child(9) { left: 92%; animation-delay: 1.3s; }
.nova-pop-sparks i:nth-child(10) { left: 14%; animation-delay: 1.5s; }
@keyframes novaConfetti { 0% { transform: translateY(0) rotate(0); opacity: 0; } 12% { opacity: 1; } 100% { transform: translateY(240px) rotate(300deg); opacity: 0; } }
@keyframes novaPopIn { from { transform: translateY(14px) scale(.96); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes novaPopFade { from { opacity: 0; } to { opacity: 1; } }
@keyframes novaPopPulse { 0%,100% { box-shadow: 0 0 0 0 var(--down-dim); } 50% { box-shadow: 0 0 0 10px transparent; } }
@media (prefers-reduced-motion: reduce) {
  .nova-pop, .nova-pop-overlay, .nova-pop-sparks i, .nova-pop--alert .nova-pop-badge { animation: none; }
  .nova-pop-sparks { display: none; }
}

/* Style picker in the admin send forms */
.pop-style-picker { display: flex; flex-wrap: wrap; gap: 8px; }
.pop-style-opt { cursor: pointer; margin: 0; }
.pop-style-opt input { position: absolute; opacity: 0; pointer-events: none; }
.pop-style-opt span {
  display: inline-flex; align-items: center; gap: 7px; padding: 8px 13px; border-radius: 999px; font-size: 13px; font-weight: 600;
  background: var(--bg-surface-2); border: 1px solid var(--border-subtle); color: var(--text-secondary);
  transition: border-color .15s, background-color .15s, color .15s;
}
.pop-style-opt:hover span { border-color: var(--border-strong); }
.pop-style-opt input:checked + span { color: var(--text-primary); border-color: var(--pop-c); background: var(--pop-bg); }
.pop-style-opt input:focus-visible + span { outline: 2px solid var(--brand); outline-offset: 2px; }
.pop-style-opt--info     { --pop-c: var(--text-secondary); --pop-bg: var(--bg-surface-3); }
.pop-style-opt--congrats { --pop-c: var(--brand); --pop-bg: var(--brand-glow); }
.pop-style-opt--alert    { --pop-c: var(--down);  --pop-bg: var(--down-dim); }
.pop-style-opt--offer    { --pop-c: var(--up);    --pop-bg: var(--up-dim); }
.pop-style-opt--task     { --pop-c: var(--info);  --pop-bg: var(--info-dim); }

/* Optional separate light-mode logo (Admin > Theme): show the dark-theme logo in dark, the light one in light. */
.site-logo--light { display: none; }
html[data-theme="light"] .site-logo--dark { display: none; }
html[data-theme="light"] .site-logo--light { display: inline-block; }

/* ---------------------------------------------------------------------
   Auth mascots (login / register / reset pages)
   --------------------------------------------------------------------- */
.nm-stage { --nm-slate: #3b4150; --nm-cream: #ece3cf; --nm-green: #2fbf71; --nm-ink: #141414;
  container-type: inline-size; position: relative; width: 100%; max-width: 300px; aspect-ratio: 1 / .78; margin: 0 auto 6px; pointer-events: none; user-select: none; }
html[data-theme="light"] .nm-stage { --nm-slate: #2c303b; --nm-cream: #e6d9b8; --nm-green: #25a862; }
.nm-char { position: absolute; bottom: 0; animation: nmBob 5s ease-in-out infinite; }
.nm-body { position: absolute; inset: 0; background: var(--nm-c); transform-origin: 50% 100%; }
.nm-face { position: absolute; left: 0; right: 0; }
.nm-char--slate { left: 30%; width: 25%; height: 86%; z-index: 1; --nm-c: var(--nm-slate); }
.nm-char--slate .nm-body { border-radius: 4cqw 4cqw 0 0; } .nm-char--slate .nm-face { top: 11%; }
.nm-char--gold { left: 6%; width: 28%; height: 60%; z-index: 2; --nm-c: var(--brand, #d4a017); animation-delay: -1.2s; }
.nm-char--gold .nm-body { border-radius: 4cqw 4cqw 0 0; } .nm-char--gold .nm-face { top: 16%; }
.nm-char--cream { left: 52%; width: 24%; height: 50%; z-index: 3; --nm-c: var(--nm-cream); animation-delay: -2.4s; }
.nm-char--cream .nm-body { border-radius: 12cqw 12cqw 0 0; } .nm-char--cream .nm-face { top: 22%; }
.nm-char--green { left: 68%; width: 32%; height: 38%; z-index: 4; --nm-c: var(--nm-green); animation-delay: -3.3s; }
.nm-char--green .nm-body { border-radius: 16cqw 16cqw 0 0; } .nm-char--green .nm-face { top: 26%; }
.nm-eyes { display: flex; justify-content: center; gap: 22%; }
.nm-ew { position: relative; }
.nm-eye { position: relative; width: 5.4cqw; height: 5.4cqw; background: #fff; border-radius: 50%; overflow: hidden; box-shadow: inset 0 0 0 .25cqw rgba(0,0,0,.08); }
.nm-pupil { position: absolute; left: 50%; top: 50%; width: 2.5cqw; height: 2.5cqw; margin: -1.25cqw 0 0 -1.25cqw; border-radius: 50%; background: var(--nm-ink); transition: transform .12s ease-out; }
.nm-lid { position: absolute; inset: -1px; background: var(--nm-c); transform: scaleY(0); transform-origin: 50% 0; transition: transform .18s ease; }
.nm-brow { position: absolute; width: 5.4cqw; height: .8cqw; border-radius: 1cqw; background: var(--nm-ink); opacity: .75; top: -1.9cqw; transition: transform .25s ease; }
.nm-mouth { margin: 2.6cqw auto 0; width: 3.8cqw; height: 1.7cqw; border-bottom: .7cqw solid var(--nm-ink); border-radius: 0 0 4cqw 4cqw; opacity: .8; transition: all .25s ease; }
.nm-stage[data-state="hidden"] .nm-lid { transform: scaleY(1); }
.nm-stage[data-state="error"] .nm-ew:first-child .nm-brow { transform: rotate(-18deg); }
.nm-stage[data-state="error"] .nm-ew:last-child .nm-brow { transform: rotate(18deg); }
.nm-stage[data-state="error"] .nm-mouth { border-bottom: 0; border-top: .7cqw solid var(--nm-ink); border-radius: 4cqw 4cqw 0 0; margin-top: 3.4cqw; }
.nm-stage[data-state="success"] .nm-mouth { width: 5.4cqw; height: 2.8cqw; background: var(--nm-ink); border: 0; border-radius: 0 0 6cqw 6cqw; }
.nm-stage.nm-blink .nm-lid { animation: nmBlink .22s ease; }
@keyframes nmBlink { 0%, 100% { transform: scaleY(0); } 45% { transform: scaleY(1); } }
@keyframes nmBob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-.8cqw); } }
.nm-stage[data-state="error"] .nm-body { animation: nmShake .55s cubic-bezier(.36,.07,.19,.97) both; }
.nm-stage[data-state="error"] .nm-face { animation: nmShakeFace .55s cubic-bezier(.36,.07,.19,.97) both; }
@keyframes nmShake { 0%, 100% { transform: translateX(0) skewX(0); } 15% { transform: translateX(-1.6cqw) skewX(-3deg); } 30% { transform: translateX(1.4cqw) skewX(3deg); } 45% { transform: translateX(-1.1cqw) skewX(-2deg); } 60% { transform: translateX(.9cqw) skewX(2deg); } 80% { transform: translateX(-.4cqw); } }
@keyframes nmShakeFace { 0%, 100% { transform: translateX(0); } 15% { transform: translateX(-2.2cqw); } 30% { transform: translateX(2cqw); } 45% { transform: translateX(-1.5cqw); } 60% { transform: translateX(1.2cqw); } 80% { transform: translateX(-.5cqw); } }
.nm-stage[data-state="success"] .nm-char { animation: nmHop .7s cubic-bezier(.3,.7,.4,1) both; }
.nm-stage[data-state="success"] .nm-char--gold { animation-delay: .05s; } .nm-stage[data-state="success"] .nm-char--cream { animation-delay: .12s; } .nm-stage[data-state="success"] .nm-char--green { animation-delay: .19s; }
@keyframes nmHop { 0% { transform: translateY(0); } 35% { transform: translateY(-5cqw); } 60% { transform: translateY(0); } 78% { transform: translateY(-1.6cqw); } 100% { transform: translateY(0); } }
@media (prefers-reduced-motion: reduce) { .nm-char, .nm-stage[data-state] .nm-char, .nm-stage[data-state] .nm-body, .nm-stage[data-state] .nm-face, .nm-stage.nm-blink .nm-lid { animation: none !important; } .nm-pupil, .nm-lid, .nm-brow, .nm-mouth { transition: none; } }
@media (max-height: 640px) { .nm-stage { max-width: 210px; } }

/* show / hide password button added by auth-mascots.js */
.nm-pw { position: relative; }
.nm-pw > input { padding-right: 44px !important; }
.nm-pw-btn { position: absolute; right: 5px; top: 5px; height: calc(100% - 10px); max-height: 40px; width: 38px; padding: 0; border: 0; border-radius: 8px; background: transparent; color: var(--text-secondary); font-size: 16px; display: inline-flex; align-items: center; justify-content: center; cursor: pointer; }
.nm-pw-btn:hover { color: var(--text-primary); background: var(--bg-surface-2); }
.nm-pw-btn:focus-visible { outline: 2px solid var(--brand); }

/* ---------- coin mascot (gold / silver / crypto) ---------- */
.nmc { --c1: #fff3c4; --c2: #d9a620; --c3: #7d5a0c; --rim1: #f1cd55; --rim2: #94690d; --engrave: #6b4a07; --ink: #2a1d03; --glow: rgba(var(--brand-rgb), .30); --glint: rgba(255,255,255,.65); --ring: rgba(var(--brand-rgb), .0);
  container-type: inline-size; position: relative; width: min(100%, 230px); aspect-ratio: 1; perspective: 1000px; pointer-events: none; user-select: none; }
.nmc[data-skin="silver"] { --c1: #ffffff; --c2: #c5cbd5; --c3: #646b78; --rim1: #f1f3f6; --rim2: #858c98; --engrave: #4a515d; --ink: #1b1f27; --glow: rgba(190,198,212,.28); }
.nmc[data-skin="crypto"] { --c1: #444958; --c2: #232632; --c3: #0b0d12; --rim1: #ffb04a; --rim2: #b25408; --engrave: #ff9a2e; --ink: #ffb04a; --glow: rgba(255,154,46,.38); --glint: rgba(255,210,160,.30); }
.nmc-glow { position: absolute; inset: 8%; border-radius: 50%; background: var(--glow); filter: blur(8cqw); }
.nmc-pulse { position: absolute; inset: 0; border-radius: 50%; opacity: 0; border: .6cqw solid transparent; }
.nmc-wrap { position: absolute; inset: 0; }
.nmc-tilt { position: absolute; inset: 0; transform-style: preserve-3d; transform: rotateX(var(--rx, 0deg)) rotateY(var(--ry, 0deg)); transition: transform .2s ease-out; animation: nmcFloat 7s ease-in-out infinite; }
.nmc-face0 { position: absolute; inset: 0; border-radius: 50%; overflow: hidden;
  background: conic-gradient(from 210deg at 50% 50%, var(--c2), var(--c1) 14%, var(--c2) 30%, var(--c3) 52%, var(--c2) 70%, var(--c1) 84%, var(--c2));
  box-shadow: 0 3cqw 6cqw rgba(0,0,0,.38), inset 0 0 0 .6cqw var(--rim2), inset 0 0 0 1.2cqw var(--rim1); }
.nmc-field { position: absolute; inset: 9.5%; border-radius: 50%;
  background: radial-gradient(circle at 34% 28%, var(--c1), var(--c2) 58%, var(--c3) 130%);
  box-shadow: inset 0 .4cqw 1cqw rgba(255,255,255,.35), inset 0 -.6cqw 1.2cqw rgba(0,0,0,.28), 0 0 0 .4cqw var(--c3); }
.nmc-rim { position: absolute; inset: 1.2cqw; border-radius: 50%;
  background: repeating-conic-gradient(rgba(0,0,0,.20) 0 .7deg, transparent .7deg 4deg);
  -webkit-mask: radial-gradient(circle, transparent 0 86.5%, #000 87%); mask: radial-gradient(circle, transparent 0 86.5%, #000 87%); }
.nmc-text { position: absolute; inset: 0; width: 100%; height: 100%; }
.nmc-text text { font-family: var(--font-display); font-weight: 700; font-size: 6px; letter-spacing: 0; fill: var(--engrave); opacity: .9; }
.nmc-shine { position: absolute; inset: 0; border-radius: 50%;
  background: linear-gradient(115deg, transparent 38%, var(--glint) 49%, transparent 60%); background-size: 260% 100%; background-position: 160% 0; animation: nmcShine 6.5s ease-in-out infinite; mix-blend-mode: soft-light; }
.nmc-emblem { position: absolute; left: 0; right: 0; top: 20%; text-align: center; font-family: var(--font-display); font-weight: 700; font-size: 8.4cqw; line-height: 1; letter-spacing: .02em; color: var(--engrave);
  text-shadow: 0 .3cqw 0 rgba(255,255,255,.32), 0 -.2cqw 0 rgba(0,0,0,.22); }
.nmc-emblem small { display: block; margin-top: 1cqw; font-size: 2.6cqw; letter-spacing: .32em; font-weight: 600; opacity: .85; }
.nmc[data-skin="crypto"] .nmc-emblem { text-shadow: 0 0 2.2cqw rgba(255,154,46,.75); }
.nmc-face { position: absolute; left: 0; right: 0; top: 47%; }
.nmc-eyes { display: flex; justify-content: center; gap: 11cqw; }
.nmc-ew { position: relative; }
.nmc-eye { position: relative; width: 5cqw; height: 9.4cqw; transform-origin: 50% 50%; transition: transform .2s ease; }
.nmc-pupil { position: absolute; inset: 0; border-radius: 3cqw; background: var(--ink); transition: transform .12s ease-out; box-shadow: inset .5cqw .6cqw 0 rgba(255,255,255,.14), 0 .4cqw .8cqw rgba(0,0,0,.25); }
.nmc[data-skin="crypto"] .nmc-pupil { box-shadow: 0 0 2.4cqw rgba(255,176,74,.85), inset 0 0 .8cqw rgba(255,255,255,.55); }
.nmc-mouth { margin: 5.6cqw auto 0; width: 9cqw; height: 3cqw; border-bottom: 1cqw solid var(--ink); border-radius: 0 0 9cqw 9cqw; opacity: .9; transition: all .25s ease; }
.nmc[data-skin="crypto"] .nmc-mouth { box-shadow: 0 .8cqw 2cqw -.6cqw rgba(255,176,74,.7); }
.nmc-foot { position: absolute; left: 0; right: 0; bottom: 17%; text-align: center; font-family: var(--font-display); font-weight: 600; font-size: 2.7cqw; letter-spacing: .3em; color: var(--engrave); opacity: .85; text-indent: .3em; }

.nmc[data-state="hidden"] .nmc-eye { transform: scaleY(.1) scaleX(1.5); }
.nmc[data-state="error"] .nmc-mouth { border-bottom: 0; border-top: 1cqw solid var(--ink); border-radius: 9cqw 9cqw 0 0; margin-top: 7.4cqw; }
.nmc[data-state="success"] .nmc-mouth { width: 13cqw; height: 5.4cqw; border-bottom-width: 1.1cqw; }
.nmc.nm-blink .nmc-eye { animation: nmcBlink .22s ease; }
.nmc[data-state="error"] .nmc-wrap { animation: nmcShake .6s cubic-bezier(.36,.07,.19,.97) both; }
.nmc[data-state="success"] .nmc-wrap { animation: nmcFlip 1.1s cubic-bezier(.3,.7,.3,1) both; }
.nmc[data-state="error"] .nmc-pulse { border-color: rgba(var(--down-rgb), .85); animation: nmcRing 1s ease-out both; }
.nmc[data-state="success"] .nmc-pulse { border-color: rgba(var(--up-rgb), .85); animation: nmcRing 1.1s ease-out both; }
@keyframes nmcBlink { 0%, 100% { transform: scaleY(1); } 45% { transform: scaleY(.08); } }
@keyframes nmcFloat { 0%, 100% { translate: 0 0; } 50% { translate: 0 -1.4cqw; } }
@keyframes nmcShine { 0%, 50% { background-position: 160% 0; } 100% { background-position: -60% 0; } }
@keyframes nmcShake { 0%, 100% { transform: translateX(0) rotate(0); } 15% { transform: translateX(-3.4cqw) rotate(-5deg); } 30% { transform: translateX(3cqw) rotate(4deg); } 45% { transform: translateX(-2.4cqw) rotate(-3deg); } 60% { transform: translateX(1.8cqw) rotate(2deg); } 80% { transform: translateX(-.8cqw); } }
@keyframes nmcFlip { 0% { transform: translateY(0) rotateY(0); } 45% { transform: translateY(-6cqw) rotateY(360deg); } 100% { transform: translateY(0) rotateY(720deg); } }
@keyframes nmcRing { 0% { opacity: .9; transform: scale(1); } 100% { opacity: 0; transform: scale(1.22); } }

.nm-stage.nmc { aspect-ratio: 1; max-width: 230px; margin-bottom: 14px; }
@media (max-width: 480px) { .nm-stage.nmc { max-width: 176px; margin-bottom: 10px; } }
@media (max-height: 640px) { .nm-stage.nmc { max-width: 140px; margin-bottom: 8px; } }
@media (prefers-reduced-motion: reduce) { .nmc *, .nmc[data-state] .nmc-wrap, .nmc[data-state] .nmc-pulse, .nmc.nm-blink .nmc-eye { animation: none !important; } .nmc-pupil, .nmc-eye, .nmc-mouth, .nmc-tilt { transition: none; } }

/* ---------------------------------------------------------------------
   Leaderboard
   --------------------------------------------------------------------- */
.lb-page { max-width: 880px; margin: 0 auto; }
.lb-controls { display: flex; flex-wrap: wrap; gap: 10px; justify-content: space-between; }
.lb-seg { display: inline-flex; gap: 4px; padding: 4px; background: var(--bg-surface); border: 1px solid var(--border-subtle); border-radius: 12px; }
.lb-seg a { padding: 7px 14px; border-radius: 9px; font-size: 13.5px; font-weight: 600; color: var(--text-secondary); text-decoration: none; }
.lb-seg a:hover { color: var(--text-primary); }
.lb-seg a.on { background: var(--brand); color: #fff; }
.lb-empty-ico { width: 54px; height: 54px; margin: 0 auto 12px; border-radius: 50%; display: grid; place-items: center; font-size: 24px; background: var(--brand-glow); color: var(--brand-text); }
.lb-podium { display: grid; grid-template-columns: 1fr 1.12fr 1fr; gap: 12px; align-items: end; margin-bottom: 16px; }
.lb-pod { background: var(--bg-surface); border: 1px solid var(--border-subtle); border-radius: 16px; padding: 16px 10px; text-align: center; min-width: 0; }
.lb-pod.r1 { padding-block: 22px; border-color: var(--brand); background: linear-gradient(180deg, var(--brand-glow), var(--bg-surface)); }
.lb-pod.is-me { box-shadow: 0 0 0 2px var(--brand); }
.lb-medal { width: 32px; height: 32px; border-radius: 50%; margin: 0 auto 10px; display: grid; place-items: center; font-family: var(--font-display); font-weight: 700; font-size: 14px; color: #2a1d03; }
.r1 .lb-medal { background: linear-gradient(135deg, #fff1b8, #d4a017); }
.r2 .lb-medal { background: linear-gradient(135deg, #ffffff, #aab0bb); }
.r3 .lb-medal { background: linear-gradient(135deg, #f0c9a0, #b06a2c); }
.lb-av { width: 50px; height: 50px; border-radius: 50%; margin: 0 auto 8px; display: grid; place-items: center; font-family: var(--font-display); font-weight: 700; font-size: 17px; background: var(--bg-surface-2); border: 2px solid var(--border-subtle); color: var(--text-primary); }
.lb-av.sm { width: 34px; height: 34px; margin: 0; font-size: 12.5px; flex: none; border-width: 1px; }
.r1 .lb-av { width: 60px; height: 60px; border-color: var(--brand); font-size: 20px; }
.lb-nm { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lb-you { color: var(--brand-text); font-weight: 600; font-size: .85em; }
.lb-pf { font-family: var(--font-mono); font-weight: 600; color: var(--up-text); margin-top: 2px; font-variant-numeric: tabular-nums; }
.lb-mt { font-size: 12px; color: var(--text-secondary); margin-top: 2px; }
.lb-table { background: var(--bg-surface); border: 1px solid var(--border-subtle); border-radius: 16px; overflow: hidden; }
.lb-tr { display: grid; grid-template-columns: 44px minmax(0, 1.6fr) .7fr .7fr 1fr; gap: 10px; align-items: center; padding: 12px 16px; border-top: 1px solid var(--border-subtle); }
.lb-tr:first-child { border-top: 0; }
.lb-tr.lb-hd { font-size: 11.5px; color: var(--text-secondary); font-weight: 600; letter-spacing: .05em; text-transform: uppercase; background: var(--bg-surface-2); }
.lb-tr .lb-rk { font-family: var(--font-mono); font-weight: 600; color: var(--text-secondary); }
.lb-who { display: flex; align-items: center; gap: 10px; min-width: 0; }
.lb-who span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 500; }
.lb-tr .num { font-family: var(--font-mono); font-variant-numeric: tabular-nums; text-align: right; }
.lb-tr .num.pos { color: var(--up-text); font-weight: 600; }
.lb-tr .num.neg { color: var(--down-text); font-weight: 600; }
.lb-tr.is-me { background: var(--brand-glow); box-shadow: inset 3px 0 0 var(--brand); }
.lb-gap { text-align: center; color: var(--text-secondary); padding: 2px 0; border-top: 1px solid var(--border-subtle); }
@media (max-width: 560px) {
  .lb-tr { grid-template-columns: 32px minmax(0, 1.5fr) 1fr; padding: 11px 12px; }
  .lb-hide-sm { display: none; }
  .lb-podium { gap: 8px; } .lb-pod { padding-inline: 6px; }
  .lb-av { width: 42px; height: 42px; font-size: 15px; } .r1 .lb-av { width: 50px; height: 50px; }
  .lb-seg a { padding: 7px 11px; font-size: 13px; }
}

/* ---------------------------------------------------------------------
   P&L share dialog (history page)
   --------------------------------------------------------------------- */
.btn-share { border: 1px solid var(--border-subtle); background: var(--bg-surface-2); color: var(--text-secondary); width: 34px; height: 34px; border-radius: 9px; cursor: pointer; display: inline-grid; place-items: center; }
.btn-share:hover { color: var(--brand-text); border-color: var(--brand); }
.btn-share:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.shr-overlay { position: fixed; inset: 0; z-index: 3500; background: rgba(8, 8, 10, .72); display: flex; align-items: center; justify-content: center; padding: 16px; overflow-y: auto; }
.shr-overlay[hidden] { display: none; }
.shr-dialog { position: relative; width: 100%; max-width: 820px; background: var(--bg-surface); border: 1px solid var(--border-subtle); border-radius: 18px; padding: 22px; display: grid; grid-template-columns: minmax(0, 340px) minmax(0, 1fr); gap: 24px; box-shadow: var(--shadow-pop); margin: auto; }
.shr-close { position: absolute; top: 10px; right: 10px; width: 34px; height: 34px; border-radius: 10px; border: 0; background: var(--bg-surface-2); color: var(--text-secondary); cursor: pointer; z-index: 2; }
.shr-close:hover { color: var(--text-primary); }
.shr-preview canvas { width: 100%; height: auto; display: block; border-radius: 16px; box-shadow: 0 14px 40px rgba(0,0,0,.35); aspect-ratio: 4 / 5; background: var(--bg-surface-2); }
.shr-panel { min-width: 0; padding-top: 6px; }
.shr-lab { font-size: 12px; font-weight: 600; letter-spacing: .05em; text-transform: uppercase; color: var(--text-secondary); margin-bottom: 7px; }
.shr-seg { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }
.shr-seg button { border: 1.5px solid var(--border-subtle); background: var(--bg-surface-2); color: var(--text-secondary); padding: 8px 16px; border-radius: 10px; font-size: 13.5px; font-weight: 600; cursor: pointer; }
.shr-seg button[aria-pressed="true"] { border-color: var(--brand); color: var(--text-primary); background: var(--brand-glow); }
.shr-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 11px 0; border-top: 1px solid var(--border-subtle); margin: 0; cursor: pointer; }
.shr-row[hidden] { display: none; }
.shr-row small { display: block; color: var(--text-secondary); font-size: 12.5px; }
.shr-row input { width: 20px; height: 20px; accent-color: var(--brand); flex: none; }
.shr-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 16px; }
.shr-msg { min-height: 20px; margin-top: 10px; font-size: 13px; color: var(--text-secondary); }
html.shr-lock { overflow: hidden; }
@media (max-width: 720px) {
  .shr-dialog { grid-template-columns: minmax(0, 1fr); padding: 16px; gap: 16px; }
  .shr-preview { max-width: 300px; margin: 8px auto 0; }
}

/* Login page: practice (demo) entry */
.demo-entry { margin-top: 18px; }
.demo-or { display: flex; align-items: center; gap: 12px; color: var(--text-muted); font-size: 12px; margin-bottom: 12px; }
.demo-or::before, .demo-or::after { content: ""; flex: 1; height: 1px; background: var(--border-subtle); }

/* ---------------------------------------------------------------------
   Market overview page — asset list with live prices + quick Buy/Sell
   (landing page after login: see MarketController / routes "/market")
   --------------------------------------------------------------------- */
.market-group-label {
  display: flex; align-items: center; gap: 7px; font-size: 12px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .06em; color: var(--text-secondary);
  margin: 18px 2px 8px;
}
.market-group-label:first-of-type { margin-top: 2px; }
.market-list { padding: 2px 0; }
.market-row.ticker-item {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 11px 14px; border-right: 0; border-bottom: 1px solid var(--border-subtle);
  font-size: inherit; white-space: normal; text-decoration: none; color: inherit;
}
.market-row.ticker-item:last-child { border-bottom: 0; }
.mk-id { display: flex; align-items: center; gap: 10px; min-width: 0; flex: 1 1 auto; }
.mk-badge {
  flex: none; width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center;
  background: var(--bg-surface-2); border: 1px solid var(--border-subtle);
  font-family: var(--font-display); font-weight: 800; font-size: 14px; color: var(--brand-light);
}
.mk-text { min-width: 0; display: flex; flex-direction: column; gap: 1px; }
/* Shrunk (asset name/%/price were getting cut off on narrower screens) so all
   three always fit and show in full instead of being clipped. */
.mk-name { font-weight: 700; font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mk-sub { font-size: 10px; color: var(--text-muted); text-transform: uppercase; letter-spacing: .04em; }
/* Price on top, % change stacked directly underneath it (tiny) — replaces the old
   name / % / price three-across layout: now it's just name on the left and this
   price+% column on the right. */
.mk-price-col {
  flex: none; display: flex; flex-direction: column; align-items: flex-end; gap: 1px;
  min-width: 64px; padding: 0 6px;
}
.mk-chg {
  font-family: var(--font-mono); font-weight: 700; font-size: 9.5px;
  text-align: right; color: var(--text-muted); line-height: 1.1;
}
.mk-chg.up { color: var(--up-text); }
.mk-chg.down { color: var(--down-text); }
.mk-price {
  font-family: var(--font-mono); font-weight: 700; font-size: 12.5px;
  text-align: right; line-height: 1.1;
}
.mk-actions { flex: none; display: flex; gap: 6px; }
.mk-chart {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-width: 76px;
  padding: 7px 14px; border-radius: 999px; border: 1.5px solid var(--brand); background: transparent;
  font-family: var(--font-display); font-weight: 700; font-size: 12px; letter-spacing: .02em;
  text-decoration: none; color: var(--brand-text, var(--brand)); transition: background-color .15s, transform .08s;
}
.mk-chart:hover { background: var(--brand-dim, rgba(47,107,255,.14)); }
.mk-chart:active { transform: scale(0.96); }
.market-group-status {
  font-size: 10px; font-weight: 700; color: var(--text-muted); background: var(--bg-surface-2);
  border: 1px solid var(--border-subtle); border-radius: 999px; padding: 2px 8px; margin-left: 6px;
  text-transform: none; letter-spacing: 0;
}
.market-group-status.is-open { color: var(--up-text); border-color: var(--up-text); background: transparent; }
.market-group-status.is-closed { color: var(--down-text); border-color: var(--down-text); background: transparent; }
@media (max-width: 480px) {
  .mk-badge { width: 30px; height: 30px; font-size: 11.5px; }
  .mk-name { font-size: 11.5px; }
  .mk-sub { font-size: 9.5px; }
  .mk-price-col { min-width: 52px; }
  .mk-chg { font-size: 9px; }
  .mk-price { font-size: 11.5px; }
  .mk-chart { min-width: 0; padding: 6px 10px; font-size: 11px; }
  .market-row.ticker-item { padding: 9px 10px; gap: 7px; }
}
