:root {
  --bg: #020617;
  --bg-alt: #020818;
  --bg-soft: #020b1f;
  --border-soft: rgba(148, 163, 184, 0.2);
  --text: #e5e7eb;
  --muted: #64748b;
  --accent: #38bdf8;
  --accent-soft: rgba(56, 189, 248, 0.2);
  --accent-strong: rgba(56, 189, 248, 0.9);
  --danger: #f97373;
  --success: #22c55e;
  --warning: #facc15;
  --scrollbar: #38bdf8;
}

/* Themes */
body[data-theme="blue"] {
  --accent: #38bdf8;
  --accent-soft: rgba(56, 189, 248, 0.15);
  --accent-strong: rgba(56, 189, 248, 0.9);
}
body[data-theme="purple"] {
  --accent: #a855f7;
  --accent-soft: rgba(168, 85, 247, 0.15);
  --accent-strong: rgba(168, 85, 247, 0.9);
}
body[data-theme="cyan"] {
  --accent: #22d3ee;
  --accent-soft: rgba(34, 211, 238, 0.15);
  --accent-strong: rgba(34, 211, 238, 0.9);
}
body[data-theme="red"] {
  --accent: #f97373;
  --accent-soft: rgba(248, 113, 113, 0.15);
  --accent-strong: rgba(248, 113, 113, 0.9);
}

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

html,
body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  background: radial-gradient(circle at top, #020617 0, #000 55%, #020617 100%);
  color: var(--text);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "SF Pro Text",
    "Segoe UI", sans-serif;
}

body {
  overflow-y: auto;   /* allow vertical scroll */
  overflow-x: hidden; /* keep horizontal clean */
}


.app-shell {
  display: flex;
  flex-direction: column;
  height: 100vh;
}

/* Scrollbars */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: #020617;
}
::-webkit-scrollbar-thumb {
  background: var(--scrollbar);
  border-radius: 999px;
}

/* Top bar */
.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 18px;
  border-bottom: 1px solid var(--border-soft);
  background: linear-gradient(90deg, #020617, #020617dd, #020617);
  box-shadow: 0 0 18px rgba(15, 23, 42, 0.9);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-logo {
  width: 32px;
  height: 32px;
  border-radius: 12px;
  background: radial-gradient(circle at 30% 20%, #e0f2fe, #0ea5e9 40%, #020617 100%);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  color: #020617;
  box-shadow: 0 0 18px var(--accent-strong);
}

.brand-text {
  display: flex;
  flex-direction: column;
}
.brand-title {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.03em;
}
.brand-sub {
  font-size: 11px;
  color: var(--muted);
}

.status-block {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
}

.status-indicator {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
}
.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: #f97373;
  box-shadow: 0 0 10px rgba(248, 113, 113, 0.9);
}
.status-text {
  color: var(--muted);
}
.last-update {
  font-size: 11px;
  color: var(--muted);
}

.top-controls {
  display: flex;
  align-items: center;
  gap: 16px;
}

.theme-select-wrap,
.mode-toggle-wrap {
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 11px;
  color: var(--muted);
}

.theme-select-wrap select,
.mode-toggle-wrap select {
  background: #020617;
  border-radius: 999px;
  border: 1px solid var(--border-soft);
  color: var(--text);
  padding: 3px 10px;
  font-size: 12px;
}

.header-right-mini {
  display: flex;
  align-items: center;
  gap: 16px;
}

/* Fear & Greed */
.fg-widget {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 11px;
}
.fg-label {
  color: var(--muted);
}
.fg-gauge {
  position: relative;
  width: 70px;
  height: 36px;
  border-radius: 999px;
  border: 1px solid var(--border-soft);
  background: radial-gradient(circle at 50% 120%, #0f172a, #020617);
  overflow: hidden;
}
.fg-needle {
  position: absolute;
  bottom: 0;
  left: 50%;
  width: 2px;
  height: 18px;
  background: var(--accent);
  transform-origin: bottom center;
  transform: translateX(-50%) rotate(-90deg);
  box-shadow: 0 0 8px var(--accent-strong);
}
.fg-value {
  position: absolute;
  top: 2px;
  left: 0;
  right: 0;
  text-align: center;
  font-size: 11px;
  color: var(--muted);
}

/* Dominance */
.dom-widget {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 11px;
}
.dom-label {
  color: var(--muted);
}
.dom-ring {
  position: relative;
  width: 70px;
  height: 70px;
}
.dom-ring svg {
  width: 100%;
  height: 100%;
}
.dom-bg {
  fill: none;
  stroke: rgba(15, 23, 42, 0.9);
  stroke-width: 8;
}
.dom-btc,
.dom-eth {
  fill: none;
  stroke-width: 8;
  stroke-linecap: round;
  transform: rotate(-90deg);
  transform-origin: 50% 50%;
  stroke-dasharray: 251.2;
  stroke-dashoffset: 251.2;
}
.dom-btc {
  stroke: #fbbf24;
}
.dom-eth {
  stroke: #6366f1;
}
.dom-values {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  gap: 2px;
}

/* Layout */
.layout {
  flex: 1;
  display: grid;
  grid-template-columns: 1.4fr 1.6fr 1.2fr;
  gap: 10px;
  padding: 10px;
  background: radial-gradient(circle at top, #020617 0, #000 55%, #020617 100%);
}

.left-panel,
.center-panel,
.right-panel {
  border-radius: 16px;
  border: 1px solid var(--border-soft);
  background: radial-gradient(circle at top left, #020617, #020617dd);
  box-shadow: 0 0 24px rgba(15, 23, 42, 0.9);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Left panel */
.table-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border-soft);
  background: linear-gradient(90deg, #020617, #020617dd);
}

.search-wrap input {
  background: #020617;
  border-radius: 999px;
  border: 1px solid var(--border-soft);
  color: var(--text);
  padding: 4px 10px;
  font-size: 12px;
  min-width: 160px;
}

.favorites-filter {
  font-size: 12px;
  color: var(--muted);
}

.column-manager {
  position: relative;
}
.btn-ghost {
  background: transparent;
  border-radius: 999px;
  border: 1px solid var(--border-soft);
  color: var(--text);
  padding: 4px 10px;
  font-size: 12px;
  cursor: pointer;
}
.btn-ghost:hover {
  border-color: var(--accent);
  box-shadow: 0 0 10px var(--accent-soft);
}

.columns-menu {
  position: absolute;
  right: 0;
  top: 110%;
  background: #020617;
  border-radius: 12px;
  border: 1px solid var(--border-soft);
  padding: 8px 10px;
  display: none;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
  z-index: 20;
}
.columns-menu.open {
  display: flex;
}

/* Table */
.table-wrap {
  flex: 1;
  overflow: auto;
}

.price-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.price-table thead {
  background: #020617;
}

.price-table th,
.price-table td {
  padding: 6px 8px;
  border-bottom: 1px solid rgba(15, 23, 42, 0.9);
  white-space: nowrap;
}

.price-table th {
  text-align: left;
  font-weight: 500;
  color: var(--muted);
  position: relative;
}

.sticky-header {
  position: sticky;
  top: 0;
  z-index: 5;
  background: linear-gradient(90deg, #020617, #020617dd);
}

.sortable {
  cursor: pointer;
}
.sortable::after {
  content: "⇅";
  font-size: 10px;
  color: var(--muted);
  margin-left: 4px;
}

.th-fav {
  width: 26px;
}

.symbol {
  font-weight: 600;
  color: var(--text);
}

.col-price,
.col-change,
.col-volume,
.col-high,
.col-low,
.col-volatility,
.col-spark {
  transition: opacity 0.2s ease;
}

.spark-cell {
  width: 100px;
}

.spark-canvas {
  width: 90px;
  height: 26px;
}

/* Favorites */
.fav-toggle {
  cursor: pointer;
  font-size: 14px;
  color: var(--muted);
}
.fav-toggle.active {
  color: #facc15;
  text-shadow: 0 0 8px rgba(250, 204, 21, 0.9);
}

/* Row flashes */
tr.flash-up {
  background: radial-gradient(circle at left, rgba(34, 197, 94, 0.18), transparent);
  box-shadow: inset 0 0 12px rgba(34, 197, 94, 0.4);
  transition: background 0.4s ease, box-shadow 0.4s ease;
}
tr.flash-down {
  background: radial-gradient(circle at left, rgba(248, 113, 113, 0.18), transparent);
  box-shadow: inset 0 0 12px rgba(248, 113, 113, 0.4);
  transition: background 0.4s ease, box-shadow 0.4s ease;
}

/* Change colors */
.change-pos {
  color: var(--success);
}
.change-neg {
  color: var(--danger);
}

/* Volatility pill */
.volatility-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 40px;
  padding: 2px 6px;
  border-radius: 999px;
  font-size: 11px;
  background: rgba(15, 23, 42, 0.9);
}
.vol-low {
  border: 1px solid #22c55e;
  box-shadow: 0 0 8px rgba(34, 197, 94, 0.4);
}
.vol-med {
  border: 1px solid #facc15;
  box-shadow: 0 0 8px rgba(250, 204, 21, 0.4);
}
.vol-high {
  border: 1px solid #f97373;
  box-shadow: 0 0 8px rgba(248, 113, 113, 0.4);
}

/* Pagination */
.pagination-bar {
  padding: 6px 10px;
  border-top: 1px solid var(--border-soft);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font-size: 12px;
}

/* Center panel */
.center-panel {
  padding: 8px 10px;
  gap: 8px;
}

.chart-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.chart-title {
  font-size: 13px;
  font-weight: 600;
}
.chart-controls select {
  background: #020617;
  border-radius: 999px;
  border: 1px solid var(--border-soft);
  color: var(--text);
  padding: 3px 10px;
  font-size: 12px;
}

.chart-area {
  flex: 1;
  border-radius: 12px;
  border: 1px solid var(--border-soft);
  background: radial-gradient(circle at top, #020617, #020617dd);
  overflow: hidden;
  position: relative;
}

.tv-chart {
  width: 100%;
  height: 100%;
}

.tv-grid {
  position: absolute;
  inset: 0;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  grid-template-rows: repeat(2, 1fr);
}
.tv-grid.hidden {
  display: none;
}
.tv-cell {
  border: 1px solid rgba(15, 23, 42, 0.9);
}

.heatmap-section {
  margin-top: 8px;
}
.section-title {
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 4px;
}
.heatmap-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(60px, 1fr));
  gap: 4px;
  max-height: 180px;
  overflow: auto;
}
.heat-tile {
  border-radius: 10px;
  padding: 4px 6px;
  font-size: 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  background: #020617;
  border: 1px solid rgba(15, 23, 42, 0.9);
}
.heat-symbol {
  font-weight: 600;
}
.heat-change-pos {
  color: var(--success);
}
.heat-change-neg {
  color: var(--danger);
}

/* Right panel */
.right-panel {
  padding: 8px 10px;
  gap: 8px;
  overflow: auto;
}

.converter-card,
.pl-card,
.portfolio-card,
.alerts-card,
.system-card {
  border-radius: 12px;
  border: 1px solid var(--border-soft);
  padding: 8px 10px;
  background: radial-gradient(circle at top left, #020617, #020617dd);
  margin-bottom: 8px;
}

.conv-row,
.pl-row,
.alert-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  margin-bottom: 4px;
  font-size: 12px;
}
.conv-row label,
.pl-row label,
.alert-row label {
  color: var(--muted);
  min-width: 70px;
}
.conv-row input,
.pl-row input,
.alert-row input,
.conv-row select,
.pl-row select,
.alert-row select {
  flex: 1;
  background: #020617;
  border-radius: 999px;
  border: 1px solid var(--border-soft);
  color: var(--text);
  padding: 3px 8px;
  font-size: 12px;
}

.conv-result,
.pl-result {
  margin-top: 4px;
  font-size: 12px;
  color: var(--accent);
}

.btn-primary {
  background: var(--accent);
  border-radius: 999px;
  border: none;
  color: #020617;
  padding: 5px 10px;
  font-size: 12px;
  cursor: pointer;
  font-weight: 600;
  box-shadow: 0 0 12px var(--accent-strong);
}
.btn-primary:hover {
  filter: brightness(1.1);
}

.btn-ghost-small {
  background: transparent;
  border-radius: 999px;
  border: 1px solid var(--border-soft);
  color: var(--muted);
  padding: 2px 8px;
  font-size: 11px;
  cursor: pointer;
}
.btn-ghost-small:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.portfolio-list {
  max-height: 140px;
  overflow: auto;
  font-size: 11px;
  margin-top: 4px;
}
.portfolio-row {
  display: flex;
  justify-content: space-between;
  gap: 6px;
  padding: 2px 0;
}
.portfolio-row span {
  white-space: nowrap;
}
.portfolio-total {
  margin-top: 4px;
  font-size: 12px;
  color: var(--accent);
}

.alerts-list {
  max-height: 140px;
  overflow: auto;
  font-size: 11px;
  margin-top: 4px;
}
.alert-row-item {
  display: flex;
  justify-content: space-between;
  gap: 6px;
  padding: 2px 0;
}
.alert-row-item button {
  background: transparent;
  border: none;
  color: var(--danger);
  cursor: pointer;
  font-size: 11px;
}

.system-info {
  margin-top: 6px;
  font-size: 11px;
  color: var(--muted);
}

/* Utility */
.hidden {
  display: none !important;
}

/* Responsive */
@media (max-width: 1200px) {
  .layout {
    grid-template-columns: 1.4fr 1.6fr;
    grid-template-rows: auto 260px;
    grid-template-areas:
      "left center"
      "right right";
  }
  .left-panel {
    grid-area: left;
  }
  .center-panel {
    grid-area: center;
  }
  .right-panel {
    grid-area: right;
  }
}

@media (max-width: 900px) {
  body {
    overflow: auto;
  }
  .layout {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto auto;
  }
}
/* ===== GLOBAL BLUE SCROLLBARS ===== */

* {
  scrollbar-width: thin;
  scrollbar-color: #38bdf8 #020617; /* Firefox */
}

/* Chrome, Edge, Safari */
::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-track {
  background: #020617;
  border-radius: 10px;
}

::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, #38bdf8, #0ea5e9);
  border-radius: 10px;
  box-shadow: 0 0 10px rgba(56, 189, 248, 0.8);
}

::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(180deg, #7dd3fc, #38bdf8);
  box-shadow: 0 0 14px rgba(56, 189, 248, 1);
}

::-webkit-scrollbar-corner {
  background: #020617;
}
/* ===== MOBILE-PERFECT TOP NAV ===== */
.top-nav {
  width: 100%;
  display: flex;
  flex-wrap: wrap;          /* CRITICAL FIX */
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 8px 10px;
  background: #020617;
  border-bottom: 1px solid rgba(148, 163, 184, 0.2);
}

.top-nav a {
  color: #38bdf8;
  text-decoration: none;
  font-size: 14px;
  padding: 6px 10px;
  border-radius: 8px;
  white-space: nowrap;
}

.top-nav a:hover {
  background: rgba(56, 189, 248, 0.15);
  box-shadow: 0 0 10px rgba(56, 189, 248, 0.4);
}

.nav-banner img {
  height: 40px;
  width: auto;
  border-radius: 8px;
  box-shadow: 0 0 12px rgba(56, 189, 248, 0.5);
}

/* Force nav links to wrap on small screens */
.nav-links {
  display: flex;
  flex-wrap: wrap;          /* CRITICAL FIX */
  justify-content: center;
  gap: 8px;
  width: 100%;
}

/* Prevent overflow on very small phones */
@media (max-width: 420px) {
  .nav-banner img {
    height: 32px;
  }
  .top-nav a {
    font-size: 13px;
    padding: 5px 8px;
  }
}
.top-nav {
  position: sticky;
  top: 0;
  z-index: 999;
}
.top-bar {
  display: flex;
  flex-wrap: wrap;              /* allow wrapping on mobile */
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border-soft);
  background: linear-gradient(90deg, #020617, #020617dd, #020617);
  box-shadow: 0 0 18px rgba(15, 23, 42, 0.9);
}
.brand {
  display: flex;
  flex-wrap: wrap;              /* important for small screens */
  align-items: center;
  gap: 8px;
}

.brand-home {
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--border-soft);
  color: var(--accent);
  font-size: 12px;
  text-decoration: none;
  white-space: nowrap;
}
.brand-home:hover {
  border-color: var(--accent);
  box-shadow: 0 0 10px var(--accent-soft);
}

.brand-banner img {
  height: 20px;
  width: 200;
  border-radius: 8px;
  box-shadow: 0 0 12px rgba(56, 189, 248, 0.5);
}

/* Mobile stacking */
@media (max-width: 768px) {
  .top-bar {
    justify-content: center;
  }

  .brand {
    width: 100%;
    justify-content: center;
    text-align: center;
  }

  .status-block,
  .top-controls {
    width: 100%;
    justify-content: center;
  }

  .header-right-mini {
    flex-wrap: wrap;
    justify-content: center;
  }

  .brand-text {
    width: 100%;
  }
}

/* Extra small phones */
@media (max-width: 420px) {
  .brand-banner img {
    height: 26px;
  }
  .brand-title {
    font-size: 13px;
  }
  .brand-sub {
    font-size: 10px;
  }
}
/* FIX: Make top.jpg responsive on mobile */
.brand-banner img {
  max-width: 100%;
  height: auto;
  display: block;
  border-radius: 10px;
  box-shadow: 0 0 12px rgba(56, 189, 248, 0.5);
}

/* On very small screens, reduce height so it never overflows */
@media (max-width: 480px) {
  .brand-banner img {
    width: 100%;
    height: auto;
    max-height: 60px;     /* prevents huge banner */
    object-fit: contain;
  }
}

/* On ultra-small screens (Galaxy Fold, iPhone SE) */
@media (max-width: 360px) {
  .brand-banner img {
    max-height: 48px;
  }
}
.top-bar,
.brand {
  flex-wrap: wrap;
}
/* Dominance widget responsive fix */
.dom-widget {
  flex: 1 1 100%;
  display: flex;
  justify-content: center;
  margin-top: 6px;
}

@media (max-width: 480px) {
  .dom-ring {
    transform: scale(0.8);
  }
}
/* MOBILE NAV FIX — LIVE PRICES TERMINAL */
.navbar, .top-nav, nav {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    max-width: 100%;
    overflow: hidden;
}

.navbar a, .top-nav a, nav a {
    flex: 1 1 auto;
    text-align: center;
    white-space: nowrap;
    padding: 10px 12px;
}

