*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  /* ── Light theme by default (OpenMine-inspired) ── */
  --bg-base:              #f7f6f2;
  --bg-surface:           #efede7;
  --bg-card:              #ffffff;
  --bg-card-hover:        #f5f4f0;
  --bg-elevated:          #eceae4;
  --bg-btc:               #fff8ee;
  --border:               rgba(0,0,0,0.08);
  --border-md:            rgba(0,0,0,0.14);
  --text-primary:         #1a1a14;
  --text-secondary:       #6b6b5a;
  --text-muted:           #b0ae9e;
  --accent-orange:        #D97757;
  --accent-orange-dim:    rgba(217,119,87,0.10);
  --accent-orange-border: rgba(217,119,87,0.28);
  --accent-red-dim:        rgba(192,57,43,0.09);
  --accent-green:         #16a34a;
  --accent-green-dim:     rgba(22,163,74,0.10);
  --accent-yellow:        #c08000;
  --accent-red:           #c0392b;
  --btc-gold:             #D97757;
  --sidebar-w:            200px;
  --font:                 'DM Sans', sans-serif;
  --mono:                 'DM Mono', monospace;
  /* ── Grid + halo (applied via body::before / body::after) ── */
  --grid-color:           rgba(0,0,0,0.045);
  --chart-bg:             #f5f3ee;
  --chart-bg-border:      rgba(0,0,0,0.09);
  --chart-grid:           rgba(0,0,0,0.06);
  --chart-text:           #aaa89e;
  --chart-tooltip-bg:     #1a1814;
  --halo-color:           rgba(217,119,87,0.07);
}

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

/* ── Grid background (OpenMine-style) ── */
body::before {
  content: '';
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background-image:
    linear-gradient(var(--grid-color) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-color) 1px, transparent 1px);
  background-size: 44px 44px;
}

/* ── Halo orange (top-right ambient glow) ── */
body::after {
  content: '';
  position: fixed; pointer-events: none; z-index: 0;
  width: 520px; height: 360px;
  top: -120px; right: 40px;
  background: radial-gradient(ellipse, var(--halo-color) 0%, transparent 70%);
  filter: blur(60px);
}

/* Ensure all page content sits above the grid/halo */
.topbar, .sidebar, .layout, .network-bar { position: relative; z-index: 1; }

/* ── Topbar ── */
.topbar {
  position: fixed; top: 0; left: 0; right: 0; height: 48px;
  background: var(--bg-base); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 20px 0 0; z-index: 100;
}
.topbar-left { display: flex; align-items: center; height: 100%; }
.logo-wrap {
  width: var(--sidebar-w); display: flex; align-items: center; gap: 8px;
  padding: 0 20px; border-right: 1px solid var(--border); height: 100%;
  text-decoration: none;
}
.logo-icon {
  width: 22px; height: 22px; background: var(--accent-orange); border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 600; color: #000; flex-shrink: 0;
}
.logo-name { font-size: 15px; font-weight: 600; letter-spacing: -0.3px; color: var(--text-primary); }
.topbar-badge {
  margin-left: 12px; font-family: var(--mono); font-size: 9px; font-weight: 500;
  letter-spacing: 0.08em; text-transform: uppercase; color: var(--accent-orange);
  background: var(--accent-orange-dim); border: 1px solid var(--accent-orange-border);
  border-radius: 4px; padding: 2px 7px;
}
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.btn-ghost {
  background: none; border: none; color: var(--text-secondary); font-family: var(--font);
  font-size: 13px; cursor: pointer; padding: 6px 10px; border-radius: 6px;
  transition: color 0.15s, background 0.15s;
}
.btn-ghost:hover { color: var(--text-primary); background: rgba(255,255,255,0.05); }
.btn-primary {
  background: var(--accent-orange); border: none; color: #000; font-family: var(--font);
  font-size: 13px; font-weight: 600; cursor: pointer; padding: 6px 16px;
  border-radius: 7px; transition: opacity 0.15s;
}
.btn-primary:hover { opacity: 0.88; }

/* ── Layout ── */
.layout { display: flex; padding-top: 48px; min-height: 100vh; }

/* ── Sidebar ── */
.sidebar {
  width: var(--sidebar-w); background: var(--bg-base); border-right: 1px solid var(--border);
  position: fixed; top: 48px; bottom: 34px; left: 0;
  display: flex; flex-direction: column; padding: 16px 10px 12px; overflow-y: auto; z-index: 90;
}
.sidebar-top { flex: 1; }
.sidebar-bottom {
  flex-shrink: 0;
  padding-top: 8px;
  border-top: 1px solid var(--border);
  margin-top: 8px;
}
.nav-item {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 7px;
  color: var(--text-secondary); font-size: 13.5px; font-weight: 400; cursor: pointer;
  text-decoration: none; transition: background 0.12s, color 0.12s; margin-bottom: 2px;
}
.nav-item:hover { background: rgba(255,255,255,0.05); color: var(--text-primary); }
.nav-item.active { background: var(--accent-orange-dim); color: var(--accent-orange); font-weight: 500; }
.nav-icon { width: 16px; height: 16px; opacity: 0.7; flex-shrink: 0; display: flex; align-items: center; justify-content: center; }
.nav-item.active .nav-icon { opacity: 1; }
.nav-badge-staff {
  margin-left: auto; font-size: 10px; font-weight: 500;
  color: #7ecfff; background: rgba(126,207,255,0.12); border-radius: 4px; padding: 1px 6px;
}
.sidebar-spacer { display: none; }

/* ── Main ── */
.main { margin-left: var(--sidebar-w); flex: 1; min-width: 0; padding: 28px 32px 80px; }

/* ── Page header ── */
.page-title { font-size: 22px; font-weight: 600; letter-spacing: -0.4px; margin-bottom: 4px; }
.page-subtitle { font-size: 13px; color: var(--text-secondary); margin-bottom: 24px; }
.page-subtitle a { color: var(--accent-orange); text-decoration: none; }
.page-subtitle a:hover { text-decoration: underline; }

/* ── Validation banner ── */
.validation-banner {
  display: inline-flex; align-items: center; gap: 6px;
  background: rgba(247,162,60,0.12); border: 1px solid var(--accent-orange-border);
  border-radius: 6px; padding: 4px 12px; font-size: 11px; font-weight: 500;
  font-family: var(--mono); letter-spacing: 0.06em; color: var(--accent-orange);
  margin-bottom: 18px; text-transform: uppercase;
}
.validation-dot {
  width: 6px; height: 6px; background: var(--accent-orange); border-radius: 50%;
  animation: pulse 2s infinite;
}
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:0.4} }

/* ── Network Bar ── */
.network-bar {
  position: fixed; bottom: 0; left: 0; right: 0; height: 34px;
  background: var(--bg-surface); border-top: 1px solid var(--border);
  display: flex; align-items: center; gap: 24px; padding: 0 20px;
  font-size: 11.5px; color: var(--text-muted); z-index: 100;
}
.net-item { display: flex; align-items: center; gap: 6px; }
.net-label { color: var(--text-muted); }
.net-value { font-family: var(--mono); font-size: 11px; font-weight: 500; color: var(--text-secondary); }
.net-highlight { color: var(--accent-orange); }
.net-right { margin-left: auto; display: flex; align-items: center; gap: 6px; font-size: 11px; color: var(--text-muted); }
.live-dot { width: 5px; height: 5px; background: var(--accent-green); border-radius: 50%; animation: pulse 2s infinite; }

/* ── Section label ── */
.section-label {
  font-size: 9px; font-weight: 600; letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--text-muted); margin-bottom: 8px; display: block;
}

/* ── Empty state ── */
.empty-state {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 80px 20px; text-align: center; color: var(--text-muted);
}
.empty-icon { font-size: 36px; margin-bottom: 16px; opacity: 0.4; }
.empty-title { font-size: 16px; font-weight: 500; color: var(--text-secondary); margin-bottom: 6px; }
.empty-sub { font-size: 13px; color: var(--text-muted); }

/* ── Auth — locked nav items ── */
.nav-locked { opacity: 0.45; }
.nav-locked:hover { opacity: 0.65; }
.nav-lock { margin-left: auto; font-size: 10px; }

/* ── Auth — sidebar user block ── */
.sidebar-user {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 10px 10px; margin-bottom: 2px;
}
.sidebar-avatar {
  width: 28px; height: 28px; border-radius: 8px; flex-shrink: 0;
  background: var(--accent-orange); border: none;
  display: flex; align-items: center; justify-content: center;
  font-size: 10px; font-weight: 700; color: #fff;
}
.sidebar-user-info { min-width: 0; }
.sidebar-user-name { font-size: 12px; font-weight: 500; color: var(--text-primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user-email { font-size: 10px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nav-signout { color: var(--accent-red) !important; font-size: 12.5px !important; border: none; background: none; width: 100%; text-align: left; cursor: pointer; font-family: var(--font); }
.nav-signout:hover { background: rgba(224,80,80,0.08) !important; color: var(--accent-red) !important; }

/* ── Auth — topbar avatar + dropdown ── */
.topbar-user-menu { position: relative; }
.topbar-avatar-btn {
  display: flex; align-items: center; gap: 7px;
  background: none; border: 1px solid var(--border); border-radius: 8px;
  padding: 5px 10px 5px 6px; cursor: pointer; color: var(--text-primary);
  font-family: var(--font); transition: border-color 0.15s, background 0.15s;
}
.topbar-avatar-btn:hover { border-color: var(--border-md); background: rgba(255,255,255,0.04); }
.topbar-avatar {
  width: 24px; height: 24px; border-radius: 6px;
  background: var(--accent-orange); color: #000;
  display: flex; align-items: center; justify-content: center;
  font-size: 10px; font-weight: 700; flex-shrink: 0;
}
.topbar-user-name { font-size: 13px; font-weight: 500; }
.topbar-chevron { font-size: 9px; color: var(--text-muted); }

.user-dropdown {
  display: none; position: absolute; top: calc(100% + 6px); right: 0;
  width: 200px; background: var(--bg-elevated);
  border: 1px solid var(--border-md); border-radius: 10px;
  overflow: hidden; z-index: 200;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
}
.user-dropdown.open { display: block; animation: fadeIn 0.12s ease; }
@keyframes fadeIn { from{opacity:0;transform:translateY(-4px)} to{opacity:1;transform:translateY(0)} }
.dropdown-header { padding: 12px 14px 10px; border-bottom: 1px solid var(--border); }
.dropdown-name { font-size: 13px; font-weight: 600; color: var(--text-primary); margin-bottom: 2px; }
.dropdown-email { font-size: 11px; color: var(--text-muted); }
.dropdown-item {
  display: block; padding: 9px 14px; font-size: 13px; color: var(--text-secondary);
  text-decoration: none; transition: background 0.1s, color 0.1s;
  cursor: pointer; border: none; background: none; width: 100%; text-align: left;
  font-family: var(--font);
}
.dropdown-item:hover { background: rgba(255,255,255,0.05); color: var(--text-primary); }
.dropdown-divider { height: 1px; background: var(--border); margin: 4px 0; }
.dropdown-signout { color: var(--accent-red) !important; }
.dropdown-signout:hover { background: rgba(224,80,80,0.08) !important; }

/* ── Hamburger button (mobile only) ── */
.hamburger {
  display: none;
  background: none; border: none; cursor: pointer;
  padding: 10px; color: var(--text-secondary);
  flex-direction: column; gap: 5px; align-items: center; justify-content: center;
}
.hamburger span {
  display: block; width: 18px; height: 2px;
  background: currentColor; border-radius: 2px;
  transition: transform 0.2s, opacity 0.2s;
}

/* ── Sidebar overlay (mobile) ── */
.sidebar-overlay {
  display: none;
  position: fixed; inset: 0; background: rgba(0,0,0,0.6);
  z-index: 89; backdrop-filter: blur(2px);
}
.sidebar-overlay.open { display: block; }

/* ── Mobile breakpoint ── */
@media (max-width: 768px) {

  /* Topbar */
  .topbar { padding: 0 12px 0 0; }
  .logo-wrap { width: auto; border-right: none; padding: 0 12px; }
  .topbar-badge { display: none; }
  .hamburger { display: flex; }
  .btn-ghost { display: none; }
  .btn-ghost.topbar-signin { display: inline-flex; }
  .btn-primary.topbar-getstarted { display: none; }
  .btn-primary { font-size: 12px; padding: 6px 12px; }
  .topbar-user-name { display: none; }
  .topbar-chevron { display: none; }

  /* Sidebar — hidden off-canvas by default */
  .sidebar {
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    z-index: 200;
    bottom: 0;
    box-shadow: 4px 0 24px rgba(0,0,0,0.5);
  }
  .sidebar.open { transform: translateX(0); }

  /* Main — full width, no left margin */
  .main {
    margin-left: 0;
    padding: 20px 16px 70px;
  }

  /* Page header */
  .page-title { font-size: 19px; }
  .page-subtitle { font-size: 12px; }

  /* Network bar — simplified on mobile */
  .network-bar {
    gap: 12px;
    padding: 0 12px;
    font-size: 10.5px;
    overflow-x: auto;
    scrollbar-width: none;
  }
  .network-bar::-webkit-scrollbar { display: none; }
  .net-right { display: none; }

  /* M6-B fix: minimum touch target sizes (44px) */
  #theme-toggle-btn {
    min-height: 44px !important;
    min-width: 44px !important;
    padding: 10px !important;
  }
  .hamburger {
    min-height: 44px;
    min-width: 44px;
    padding: 10px;
  }
  .tab-btn, .status-filter, button[onclick*="setFilter"] {
    min-height: 36px;
    padding-top: 7px !important;
    padding-bottom: 7px !important;
  }
  .btn-primary, .btn-ghost {
    min-height: 40px;
    padding-top: 8px !important;
    padding-bottom: 8px !important;
  }

  /* M9-A fix: withdrawal and copy buttons touch targets */
  .btn-sm {
    min-height: 40px !important;
    padding-top: 9px !important;
    padding-bottom: 9px !important;
  }

  /* M9-B fix: sidebar nav minimum font size */
  .nav-item {
    font-size: 13px !important;
    min-height: 36px !important;
  }
}

/* ── Light theme (same as :root — light is now the default) ── */
/* Kept for backward compat: .light-theme class = same as default */
.light-theme {
  --bg-base:              #f7f6f2;
  --bg-surface:           #efede7;
  --bg-card:              #ffffff;
  --bg-card-hover:        #f5f4f0;
  --bg-elevated:          #eceae4;
  --bg-btc:               #fff8ee;
  --border:               rgba(0,0,0,0.08);
  --border-md:            rgba(0,0,0,0.14);
  --text-primary:         #1a1a14;
  --text-secondary:       #6b6b5a;
  --text-muted:           #b0ae9e;
  --accent-orange:        #D97757;
  --accent-orange-dim:    rgba(217,119,87,0.10);
  --accent-orange-border: rgba(217,119,87,0.28);
  --accent-red-dim:        rgba(192,57,43,0.09);
  --accent-green:         #16a34a;
  --accent-green-dim:     rgba(22,163,74,0.10);
  --accent-yellow:        #c08000;
  --accent-red:           #c0392b;
  --btc-gold:             #D97757;
  --grid-color:           rgba(0,0,0,0.045);
  --chart-bg:             #f5f3ee;
  --chart-bg-border:      rgba(0,0,0,0.09);
  --chart-grid:           rgba(0,0,0,0.06);
  --chart-text:           #aaa89e;
  --chart-tooltip-bg:     #1a1814;
  --halo-color:           rgba(217,119,87,0.07);
}

/* ── Dark theme ── */
.dark-theme {
  --bg-base:              #0d0d0f;
  --bg-surface:           #141417;
  --bg-card:              #1a1a1e;
  --bg-card-hover:        #1f1f24;
  --bg-elevated:          #222228;
  --bg-btc:               #1e1a0e;
  --border:               rgba(255,255,255,0.07);
  --border-md:            rgba(255,255,255,0.11);
  --text-primary:         #f0efeb;
  --text-secondary:       #8a8a8f;
  --text-muted:           #555560;
  --accent-orange:        #f7a23c;
  --accent-orange-dim:    rgba(247,162,60,0.15);
  --accent-orange-border: rgba(247,162,60,0.3);
  --accent-green:         #3ecf72;
  --accent-green-dim:     rgba(62,207,114,0.12);
  --accent-yellow:        #f0c040;
  --accent-red:           #e05050;
  --btc-gold:             #f7a23c;
  --grid-color:           rgba(255,255,255,0.028);
  --chart-bg:             #141210;
  --chart-bg-border:      rgba(255,255,255,0.07);
  --chart-grid:           rgba(255,255,255,0.055);
  --chart-text:           #66665e;
  --chart-tooltip-bg:     #1a1714;
  --halo-color:           rgba(247,162,60,0.06);
}

/* BTC estimate info icon ── */
.btc-info-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 14px; height: 14px; border-radius: 50%;
  font-size: 11px; color: var(--text-muted);
  cursor: pointer; vertical-align: middle;
  margin-left: 4px; transition: color 0.15s;
  font-style: normal; line-height: 1;
}
.btc-info-icon:hover { color: var(--accent-orange); }


/* ── M15 — Miner Images ─────────────────────────────────── */

/* Variables dark (défaut) */
:root {
  --miner-glow:             drop-shadow(0 0 28px rgba(247,162,60,0.45))
                            drop-shadow(0 8px 20px rgba(0,0,0,0.65));
  --miner-glow-hover:       drop-shadow(0 0 44px rgba(247,162,60,0.65))
                            drop-shadow(0 12px 28px rgba(0,0,0,0.75));
  --miner-img-bg:           radial-gradient(ellipse at 50% 62%, rgba(247,162,60,0.12) 0%, transparent 68%);
  --miner-reflection-opacity: 0.20;
}

/* Variables light */
.light-theme {
  --miner-glow:             drop-shadow(0 4px 18px rgba(0,0,0,0.15))
                            drop-shadow(0 1px 4px rgba(0,0,0,0.08));
  --miner-glow-hover:       drop-shadow(0 6px 26px rgba(0,0,0,0.22))
                            drop-shadow(0 2px 8px rgba(0,0,0,0.11));
  --miner-img-bg:           radial-gradient(ellipse at 50% 62%, rgba(217,119,87,0.07) 0%, transparent 68%);
  --miner-reflection-opacity: 0.10;
}

/* ── Grand format (listing card, auction card) ── */
.card-img-zone {
  position: relative;
  height: 200px;
  background: var(--bg-elevated);
  overflow: hidden;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  border-radius: 12px 12px 0 0;
}

@media (max-width: 480px) {
  .card-img-zone { height: 130px; }
  .miner-img-reflection { display: none; }
}
.card-img-zone::before {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--miner-img-bg);
  pointer-events: none;
  transition: opacity 0.3s;
}
.card-img-zone::after {
  content: '';
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 32px;
  background: linear-gradient(to top, var(--bg-elevated), transparent);
  pointer-events: none;
  z-index: 2;
}
.card-img-inner {
  position: relative;
  z-index: 1;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding-bottom: 10px;
}
.miner-img-main {
  max-width: 80%;
  max-height: 84%;
  object-fit: contain;
  filter: var(--miner-glow);
  transform: rotate(-4deg);
  transform-origin: center bottom;
  transition: filter 0.3s, transform 0.3s;
}
.miner-img-reflection {
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%) scaleY(-1) rotate(-4deg);
  transform-origin: center top;
  max-width: 80%;
  max-height: 26%;
  object-fit: contain;
  opacity: var(--miner-reflection-opacity);
  -webkit-mask-image: linear-gradient(to bottom, transparent 0%, black 100%);
  mask-image: linear-gradient(to bottom, transparent 0%, black 100%);
  pointer-events: none;
  z-index: 1;
  filter: blur(0.5px);
}
.miner-img-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  height: 100%;
  color: var(--text-muted);
  opacity: 0.4;
  font-size: 12px;
  font-family: var(--mono);
}

/* ── Petit format — thumbnail 48×48 (contracts, my-auctions, my-bids) ── */
.miner-thumb {
  width: 48px;
  height: 48px;
  flex-shrink: 0;
  border-radius: 8px;
  background: var(--bg-elevated);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}
.miner-thumb::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at 50% 60%, rgba(247,162,60,0.14) 0%, transparent 70%);
  pointer-events: none;
}
.miner-thumb img {
  max-width: 86%;
  max-height: 86%;
  object-fit: contain;
  filter: var(--miner-glow);
  transform: rotate(-4deg);
  position: relative;
  z-index: 1;
}
.miner-thumb-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  opacity: 0.35;
}

/* ── Miner image vars override for dark theme ── */
.dark-theme {
  --miner-glow:             drop-shadow(0 0 28px rgba(247,162,60,0.45))
                            drop-shadow(0 8px 20px rgba(0,0,0,0.65));
  --miner-glow-hover:       drop-shadow(0 0 44px rgba(247,162,60,0.65))
                            drop-shadow(0 12px 28px rgba(0,0,0,0.75));
  --miner-img-bg:           radial-gradient(ellipse at 50% 62%, rgba(247,162,60,0.12) 0%, transparent 68%);
  --miner-reflection-opacity: 0.20;
}
