/* ============================================================
   TOPORIO — Trading Platform Stylesheet
   Unique design identity: deep space dark + electric violet/cyan
   ============================================================ */

/* ---------- CSS Variables ---------- */
:root {
  --bg-primary:    #090b10;
  --bg-secondary:  #0f1218;
  --bg-card:       #151921;
  --bg-elevated:   #1c2230;
  --bg-input:      #1a1f2e;
  --border:        #252d3d;
  --border-light:  #2e3a4e;
  --border-focus:  #7c5cfc;

  --text-primary:   #e8eaf0;
  --text-secondary: #8b92a5;
  --text-muted:     #525a6e;

  --green:     #00d68f;
  --green-dim: rgba(0, 214, 143, 0.12);
  --red:       #ff4d6a;
  --red-dim:   rgba(255, 77, 106, 0.12);

  /* Primary brand: violet → cyan gradient */
  --accent:       #7c5cfc;
  --accent-light: #9b7fff;
  --accent-dim:   rgba(124, 92, 252, 0.12);
  --accent-hover: #6a4ae0;
  --cyan:         #00d4aa;
  --cyan-dim:     rgba(0, 212, 170, 0.10);
  --gradient:     linear-gradient(135deg, #7c5cfc 0%, #00d4aa 100%);
  --gradient-h:   linear-gradient(90deg, #7c5cfc 0%, #00d4aa 100%);

  --nav-height: 56px;
  --sidebar-width: 340px;
  --radius-sm: 6px;
  --radius:    10px;
  --radius-lg: 14px;

  --transition: 150ms ease;
  --shadow:    0 4px 20px rgba(0, 0, 0, 0.5);
  --shadow-lg: 0 12px 48px rgba(0, 0, 0, 0.7);
  --glow:      0 0 20px rgba(124, 92, 252, 0.15);
}

/* ---------- Reset & Base ---------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  font-size: 14px;
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a { color: var(--accent-light); text-decoration: none; cursor: pointer; }
a:hover { color: var(--accent); }

input, button, select, textarea { font-family: inherit; font-size: inherit; }

input[type=number]::-webkit-outer-spin-button,
input[type=number]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
input[type=number] { -moz-appearance: textfield; appearance: textfield; }

/* ---------- Custom Scrollbar ---------- */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-light); }

/* Utility */
.text-right  { text-align: right; }
.text-center { text-align: center; }
.text-green  { color: var(--green); }
.text-red    { color: var(--red); }
.text-accent { color: var(--accent); }
.text-muted  { color: var(--text-muted); }
.nowrap      { white-space: nowrap; }

/* ============================================================
   TOAST NOTIFICATIONS
   ============================================================ */
#toast-container {
  position: fixed;
  top: 68px;
  right: 16px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  min-width: 280px;
  max-width: 380px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  box-shadow: var(--shadow-lg);
  pointer-events: all;
  animation: slideIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  position: relative;
  overflow: hidden;
  backdrop-filter: blur(12px);
}

.toast::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  border-radius: 0 2px 2px 0;
}

.toast.success::before { background: var(--green); }
.toast.error::before   { background: var(--red); }
.toast.info::before    { background: var(--accent); }
.toast.warning::before { background: #f6a609; }

.toast-icon { font-size: 16px; flex-shrink: 0; margin-top: 1px; }
.toast-content { flex: 1; }
.toast-title   { font-weight: 600; font-size: 13px; color: var(--text-primary); }
.toast-message { font-size: 12px; color: var(--text-secondary); margin-top: 2px; }
.toast-close {
  background: none; border: none; color: var(--text-muted);
  cursor: pointer; font-size: 16px; line-height: 1;
  padding: 0; flex-shrink: 0;
}
.toast-close:hover { color: var(--text-primary); }
.toast.hiding { animation: slideOut 0.25s ease forwards; }

@keyframes slideIn  { from { transform: translateX(110%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
@keyframes slideOut { to   { transform: translateX(110%); opacity: 0; } }

/* ============================================================
   TOP NAVIGATION BAR
   ============================================================ */
#topbar {
  height: var(--nav-height);
  background: rgba(15, 18, 24, 0.85);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  position: sticky;
  top: 0;
  z-index: 100;
  flex-shrink: 0;
}

.nav-left {
  display: flex;
  align-items: center;
  gap: 28px;
}

.logo {
  font-size: 20px;
  font-weight: 800;
  letter-spacing: 0.5px;
  color: var(--text-primary);
  white-space: nowrap;
  position: relative;
}

.logo .accent {
  background: var(--gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.nav-links {
  display: flex;
  gap: 2px;
}

.nav-link {
  color: var(--text-secondary);
  font-weight: 500;
  font-size: 14px;
  padding: 7px 14px;
  border-radius: var(--radius-sm);
  transition: color var(--transition), background var(--transition);
  cursor: pointer;
  white-space: nowrap;
}

.nav-link:hover { color: var(--text-primary); background: var(--bg-elevated); }
.nav-link.active {
  color: var(--accent-light);
  background: var(--accent-dim);
}

/* User Section */
.user-section {
  display: flex;
  align-items: center;
  gap: 14px;
}

/* Notifications */
.notif-wrap { position: relative; }

.notif-bell {
  background: none; border: none; color: var(--text-secondary);
  cursor: pointer; padding: 6px; border-radius: var(--radius-sm);
  transition: all var(--transition); position: relative; display: flex; align-items: center;
}
.notif-bell:hover { color: var(--text-primary); background: var(--bg-elevated); }

.notif-badge {
  position: absolute; top: 2px; right: 2px;
  background: var(--red); color: #fff; font-size: 9px; font-weight: 700;
  min-width: 16px; height: 16px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center; padding: 0 4px;
}

.notif-dropdown {
  display: none; position: absolute; top: calc(100% + 8px); right: 0;
  width: 320px; background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-lg); z-index: 200; overflow: hidden;
}
.notif-wrap:hover .notif-dropdown { display: block; }

.notif-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 14px; border-bottom: 1px solid var(--border);
  font-size: 13px; font-weight: 600; color: var(--text-primary);
}
.notif-clear { background: none; border: none; color: var(--accent-light); font-size: 11px; cursor: pointer; }

.notif-list { max-height: 300px; overflow-y: auto; }
.notif-empty { padding: 24px; text-align: center; color: var(--text-muted); font-size: 12px; }

.notif-item {
  padding: 10px 14px; border-bottom: 1px solid rgba(37,45,61,0.3);
  cursor: pointer; transition: background 0.1s;
}
.notif-item:hover { background: var(--bg-elevated); }
.notif-item:last-child { border-bottom: none; }
.notif-item-title { font-size: 12px; font-weight: 600; color: var(--text-primary); }
.notif-item-body { font-size: 11px; color: var(--text-muted); margin-top: 2px; }
.notif-item-time { font-size: 10px; color: var(--text-muted); margin-top: 4px; }

.balance-info {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  line-height: 1.2;
}

.balance-label {
  font-size: 10px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.6px;
}

.balance-amount {
  font-size: 14px;
  font-weight: 700;
  background: var(--gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.user-avatar-wrap {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}

.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--gradient);
  color: #fff;
  font-weight: 700;
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.username-text {
  font-weight: 500;
  font-size: 13px;
  color: var(--text-primary);
}

.user-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  min-width: 170px;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  z-index: 200;
}

.user-avatar-wrap:hover .user-dropdown { display: block; }

.dropdown-item {
  display: block;
  padding: 10px 16px;
  color: var(--text-secondary);
  font-size: 13px;
  transition: background var(--transition), color var(--transition);
  cursor: pointer;
}

.dropdown-item:hover { background: var(--bg-elevated); color: var(--text-primary); }

.dropdown-divider { border-top: 1px solid var(--border); margin: 4px 0; }

/* Buttons */
.btn-primary {
  background: var(--gradient);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 14px;
  padding: 8px 20px;
  cursor: pointer;
  transition: opacity var(--transition), transform var(--transition);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.btn-primary:hover:not(:disabled) { opacity: 0.9; transform: translateY(-1px); }
.btn-primary:active:not(:disabled) { transform: translateY(0); }
.btn-primary:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-full { width: 100%; justify-content: center; }

/* ============================================================
   VIEW SYSTEM
   ============================================================ */
.view { display: none; flex: 1; }
.view.active { display: flex; flex-direction: column; }

/* ============================================================
   MARKET VIEW
   ============================================================ */
.market-layout {
  display: flex;
  flex: 1;
  max-height: calc(100vh - var(--nav-height) - 28px);
  overflow: hidden;
}

/* ---------- Market Sidebar ---------- */
.market-sidebar {
  width: var(--sidebar-width);
  flex-shrink: 0;
  background: var(--bg-secondary);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.sidebar-search {
  padding: 12px;
  border-bottom: 1px solid var(--border);
  position: relative;
}

.search-icon {
  position: absolute;
  left: 22px;
  top: 50%;
  transform: translateY(-50%);
  width: 14px;
  height: 14px;
  color: var(--text-muted);
  pointer-events: none;
}

#search-input {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  padding: 9px 12px 9px 36px;
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
}

#search-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-dim);
}
#search-input::placeholder { color: var(--text-muted); }

.search-suggestions {
  position: absolute;
  top: 100%;
  left: 12px;
  right: 12px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 0 0 var(--radius-sm) var(--radius-sm);
  box-shadow: var(--shadow-lg);
  z-index: 50;
  max-height: 240px;
  overflow-y: auto;
}

.search-suggestion {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  cursor: pointer;
  transition: background 0.1s;
  font-size: 13px;
}

.search-suggestion:hover { background: var(--bg-elevated); }

.search-suggestion .sg-ticker {
  font-weight: 600;
  color: var(--accent-light);
  min-width: 70px;
}

.search-suggestion .sg-name {
  color: var(--text-secondary);
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.search-suggestion .sg-price {
  color: var(--text-primary);
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}

/* Category Tabs — wrapping grid, all visible */
.category-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 8px 10px;
  flex-shrink: 0;
  border-bottom: 1px solid var(--border);
}

.cat-tab {
  background: none;
  border: 1px solid transparent;
  color: var(--text-secondary);
  font-size: 11px;
  font-weight: 500;
  padding: 4px 10px;
  cursor: pointer;
  border-radius: 20px;
  white-space: nowrap;
  transition: all var(--transition);
}

.cat-tab:hover {
  color: var(--text-primary);
  background: var(--bg-elevated);
  border-color: var(--border);
}

.cat-tab.active {
  color: var(--accent-light);
  background: var(--accent-dim);
  border-color: rgba(124, 92, 252, 0.3);
}

/* Country Filter */
.country-filter {
  padding: 6px 12px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.country-select {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  padding: 6px 10px;
  font-size: 12px;
  outline: none;
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238b92a5' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 30px;
}

.country-select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-dim);
}

.country-select option {
  background: var(--bg-card);
  color: var(--text-primary);
}

/* Sidebar List Header */
.sidebar-list-header {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 8px;
  padding: 8px 14px;
  font-size: 10px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.6px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-primary);
}

.sort-col {
  cursor: pointer;
  user-select: none;
  transition: color var(--transition);
}
.sort-col:hover { color: var(--text-secondary); }
.sort-col.active { color: var(--accent-light); }
.sort-arrow { font-size: 8px; opacity: 0.7; }

/* Person List */
.person-list {
  flex: 1;
  overflow-y: auto;
}

.person-item {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 10px 14px;
  cursor: pointer;
  transition: background var(--transition);
  border-bottom: 1px solid rgba(37, 45, 61, 0.4);
  position: relative;
}

.person-item:hover { background: rgba(21, 25, 33, 0.7); }

.person-item.active {
  background: linear-gradient(90deg, rgba(124,92,252,0.08) 0%, transparent 100%);
}

.person-item.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: var(--gradient);
  border-radius: 0 3px 3px 0;
}

.person-avatar {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: var(--bg-elevated);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 13px;
  color: var(--text-secondary);
  flex-shrink: 0;
  overflow: hidden;
}

.person-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 10px;
}

.person-info { overflow: hidden; min-width: 0; }

.person-ticker {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.person-name {
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 1px;
}

.person-stats { text-align: right; flex-shrink: 0; }

.person-price {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
}

.person-change {
  font-size: 11px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  margin-top: 1px;
}

.person-change.positive { color: var(--green); }
.person-change.negative { color: var(--red); }

/* Price flash animation on update */
.person-price.flash-green { animation: priceFlashGreen 0.8s ease; }
.person-price.flash-red { animation: priceFlashRed 0.8s ease; }

@keyframes priceFlashGreen {
  0% { background: rgba(0, 214, 143, 0.3); }
  100% { background: transparent; }
}
@keyframes priceFlashRed {
  0% { background: rgba(255, 77, 106, 0.3); }
  100% { background: transparent; }
}

/* ---------- Market Main ---------- */
.market-main {
  flex: 1;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overflow-x: hidden;
  background: var(--bg-primary);
}

/* Person Header */
.person-header {
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  padding: 16px 24px;
  flex-shrink: 0;
}

.person-header-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
  gap: 10px;
  color: var(--text-muted);
  text-align: center;
}

.person-header-empty svg {
  width: 40px;
  height: 40px;
  opacity: 0.3;
}

.person-header-empty p {
  font-size: 13px;
  max-width: 260px;
}

.person-header-loaded {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.header-avatar {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: var(--bg-elevated);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 16px;
  color: var(--text-secondary);
  flex-shrink: 0;
  overflow: hidden;
}

.header-avatar img { width: 100%; height: 100%; object-fit: cover; border-radius: 12px; }

.header-info { flex: 1; min-width: 0; }

.header-name {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
}

.header-ticker {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 3px;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.header-badge {
  font-size: 10px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 10px;
  background: var(--accent-dim);
  color: var(--accent-light);
  text-transform: capitalize;
}

.header-badge.sub {
  background: var(--bg-elevated);
  color: var(--text-secondary);
}

/* Metrics Pills */
.header-metrics {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  width: 100%;
  padding-top: 8px;
  border-top: 1px solid var(--border);
  margin-top: 8px;
}

.metric-pill {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  color: var(--text-secondary);
  background: var(--bg-elevated);
  padding: 3px 8px;
  border-radius: 12px;
  font-weight: 500;
}

.metric-icon {
  font-size: 9px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
}

.header-disclaimer {
  width: 100%;
  font-size: 9px;
  color: var(--text-muted);
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px solid var(--border);
  font-style: italic;
}

/* Social Media Links */
.header-socials {
  display: flex;
  gap: 6px;
  margin-top: 6px;
}

.social-link {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  background: var(--bg-elevated);
  color: var(--text-muted);
  transition: all var(--transition);
}

.social-link:hover { color: var(--text-primary); transform: translateY(-1px); }
.social-youtube:hover { color: #ff0000; background: rgba(255,0,0,0.1); }
.social-instagram:hover { color: #e4405f; background: rgba(228,64,95,0.1); }
.social-twitter:hover { color: #fff; background: rgba(255,255,255,0.1); }
.social-tiktok:hover { color: #00f2ea; background: rgba(0,242,234,0.1); }
.social-spotify:hover { color: #1db954; background: rgba(29,185,84,0.1); }

.header-price-block { text-align: right; }

.header-price {
  font-size: 24px;
  font-weight: 700;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
}

.header-change {
  font-size: 13px;
  font-weight: 600;
  margin-top: 2px;
}

.header-stats {
  display: flex;
  gap: 24px;
  margin-top: 10px;
  flex-wrap: wrap;
  width: 100%;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}

.header-stat { display: flex; flex-direction: column; gap: 3px; }

.stat-label {
  font-size: 10px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 500;
}

.stat-value {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
}

/* ---------- Chart ---------- */
#chart-container {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  flex-shrink: 0;
}

.chart-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-secondary);
  flex-shrink: 0;
}

.chart-timeframes {
  display: flex;
  gap: 2px;
}

.tf-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 500;
  padding: 5px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition);
}

.tf-btn:hover { color: var(--text-primary); background: var(--bg-elevated); }
.tf-btn.active { color: var(--accent-light); background: var(--accent-dim); }

.chart-price-info {
  font-size: 12px;
  color: var(--text-secondary);
  display: flex;
  gap: 12px;
  font-variant-numeric: tabular-nums;
}

.chart-price-info span { display: flex; gap: 4px; }
.chart-price-info .label { color: var(--text-muted); font-weight: 500; }

#chart-canvas {
  width: 100%;
  height: 400px;
  transition: opacity 0.2s ease;
}

/* ---------- Trade Panel ---------- */
.trade-panel {
  border-top: 1px solid var(--border);
  background: var(--bg-secondary);
  flex-shrink: 0;
}

.trade-tabs { display: flex; }

.trade-tab {
  flex: 1;
  background: none;
  border: none;
  padding: 12px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  border-bottom: 2px solid transparent;
  color: var(--text-muted);
}

.trade-tab.buy-tab.active  {
  color: var(--green);
  border-bottom-color: var(--green);
  background: var(--green-dim);
}
.trade-tab.sell-tab.active {
  color: var(--red);
  border-bottom-color: var(--red);
  background: var(--red-dim);
}
.trade-tab:hover:not(.active) { color: var(--text-primary); background: var(--bg-elevated); }

/* Order Type Tabs */
.order-type-tabs {
  display: flex;
  gap: 4px;
  background: var(--bg-primary);
  border-radius: var(--radius-sm);
  padding: 3px;
}

.order-type-btn {
  flex: 1;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 500;
  padding: 5px 6px;
  border-radius: 4px;
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
}

.order-type-btn:hover { color: var(--text-primary); }
.order-type-btn.active {
  background: var(--bg-elevated);
  color: var(--accent-light);
}

.trade-body {
  padding: 14px 16px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  align-items: start;
}

.trade-field { display: flex; flex-direction: column; gap: 5px; }
.trade-field label {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 600;
}

.input-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.input-wrap input {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  padding: 9px 50px 9px 12px;
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.input-wrap input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-dim);
}

.input-suffix {
  position: absolute;
  right: 12px;
  font-size: 11px;
  color: var(--text-muted);
  pointer-events: none;
}

.trade-balance {
  font-size: 13px;
  font-weight: 700;
  color: var(--accent-light);
  padding-top: 8px;
}

.quick-qty {
  grid-column: 1 / -1;
  display: flex;
  gap: 6px;
}

.qty-preset {
  flex: 1;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 500;
  padding: 6px;
  cursor: pointer;
  transition: all var(--transition);
}

.qty-preset:hover {
  border-color: var(--accent);
  color: var(--accent-light);
  background: var(--accent-dim);
}

.trade-summary {
  grid-column: 1 / -1;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.summary-row {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text-secondary);
}

.summary-row span:last-child {
  font-weight: 600;
  color: var(--text-primary);
}

#execute-trade-btn, .btn-trade {
  grid-column: 1 / -1;
  padding: 12px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: all var(--transition);
  letter-spacing: 0.3px;
}

.btn-buy { background: var(--green); color: #000; }
.btn-sell { background: var(--red); color: #fff; }
.btn-buy:hover:not(:disabled) { filter: brightness(1.1); box-shadow: 0 4px 16px rgba(0, 214, 143, 0.25); }
.btn-sell:hover:not(:disabled) { filter: brightness(1.1); box-shadow: 0 4px 16px rgba(255, 77, 106, 0.25); }

#execute-trade-btn:disabled, .btn-trade:disabled {
  background: var(--bg-input);
  color: var(--text-muted);
  cursor: not-allowed;
  box-shadow: none;
  filter: none;
}

/* ============================================================
   ORDER BOOK & RECENT TRADES
   ============================================================ */
.orderbook-section {
  border-top: 1px solid var(--border);
  background: var(--bg-secondary);
  max-height: 260px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

.ob-tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.ob-tab {
  flex: 1;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 600;
  padding: 8px;
  cursor: pointer;
  transition: all var(--transition);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.ob-tab:hover { color: var(--text-primary); }
.ob-tab.active { color: var(--accent-light); border-bottom: 2px solid var(--accent); }

.ob-content {
  flex: 1;
  overflow-y: auto;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.ob-header {
  display: grid;
  grid-template-columns: 1fr 1fr;
  padding: 4px 12px;
  font-size: 10px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--bg-secondary);
}

#ob-recent-trades .ob-header {
  grid-template-columns: 1fr 1fr 1fr;
}

.ob-spread {
  padding: 4px 12px;
  text-align: center;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-primary);
  background: var(--bg-primary);
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}

.ob-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  padding: 2px 12px;
  font-size: 12px;
  transition: background 0.1s;
}

.ob-row:hover { background: var(--bg-elevated); }
.ob-row.ask .ob-price { color: var(--red); }
.ob-row.bid .ob-price { color: var(--green); }
.ob-row .ob-qty { text-align: right; color: var(--text-secondary); }

.ob-trade-row {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  padding: 2px 12px;
  font-size: 12px;
}

.ob-trade-row .ob-time { text-align: right; color: var(--text-muted); font-size: 11px; }

/* ============================================================
   COMMENTS SECTION
   ============================================================ */
.comments-section {
  border-top: 1px solid var(--border);
  background: var(--bg-secondary);
  max-height: 300px;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  overflow: hidden;
}

.comments-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.comments-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
}

.comments-count {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  background: var(--bg-elevated);
  padding: 2px 8px;
  border-radius: 10px;
}

.comment-input-wrap {
  display: flex;
  gap: 8px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.comment-input-wrap input {
  flex: 1;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  padding: 8px 12px;
  font-size: 13px;
  outline: none;
}

.comment-input-wrap input:focus { border-color: var(--accent); }
.comment-input-wrap input::placeholder { color: var(--text-muted); }

.btn-comment-submit {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  padding: 8px 16px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity var(--transition);
  white-space: nowrap;
}

.btn-comment-submit:hover { opacity: 0.85; }

.comments-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px 0;
}

.comment-item {
  padding: 8px 16px;
  display: flex;
  gap: 10px;
  transition: background 0.1s;
}

.comment-item:hover { background: rgba(28, 34, 48, 0.3); }

.comment-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--bg-elevated);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-secondary);
  flex-shrink: 0;
}

.comment-body { flex: 1; min-width: 0; }

.comment-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  margin-bottom: 2px;
}

.comment-username { font-weight: 600; color: var(--accent-light); }
.comment-time { color: var(--text-muted); }
.comment-text { font-size: 13px; color: var(--text-primary); line-height: 1.4; word-break: break-word; }

/* ============================================================
   CONTENT PAGES (Portfolio & Leaderboard)
   ============================================================ */
.content-page {
  max-width: 1100px;
  margin: 0 auto;
  padding: 28px 24px 40px;
  width: 100%;
}

.page-header { margin-bottom: 24px; }

.page-title {
  font-size: 24px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.page-subtitle {
  font-size: 13px;
  color: var(--text-secondary);
}

/* Summary Cards */
.portfolio-summary-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin-top: 16px;
}

.summary-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: border-color var(--transition);
}

.summary-card:hover { border-color: var(--border-light); }

.card-label {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.6px;
  font-weight: 600;
}

.card-value {
  font-size: 22px;
  font-weight: 700;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
}

/* Section Block */
.section-block { margin-top: 28px; }

.section-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}

/* ---------- Tables ---------- */
.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-card);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
}

.data-table thead tr { background: var(--bg-secondary); }

.data-table th {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.6px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.data-table td {
  padding: 12px 14px;
  font-size: 13px;
  color: var(--text-primary);
  border-bottom: 1px solid rgba(37, 45, 61, 0.4);
  vertical-align: middle;
}

.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover td { background: rgba(28, 34, 48, 0.5); }

.empty-state {
  text-align: center;
  color: var(--text-muted);
  padding: 40px 20px !important;
  font-size: 14px;
}

/* Side Badge */
.side-badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 20px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.side-badge.buy  { background: var(--green-dim); color: var(--green); }
.side-badge.sell { background: var(--red-dim); color: var(--red); }

/* Trade Action Buttons in Table */
.btn-table-buy, .btn-table-sell {
  font-size: 11px;
  font-weight: 600;
  padding: 4px 12px;
  border: none;
  border-radius: 20px;
  cursor: pointer;
  transition: all var(--transition);
}

.btn-table-buy  { background: var(--green-dim); color: var(--green); }
.btn-table-sell { background: var(--red-dim); color: var(--red); margin-left: 4px; }
.btn-table-buy:hover  { background: var(--green); color: #000; }
.btn-table-sell:hover { background: var(--red); color: #fff; }

/* ============================================================
   LEADERBOARD
   ============================================================ */
.leaderboard-filters {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}

.lb-filter {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 20px;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  padding: 7px 18px;
  cursor: pointer;
  transition: all var(--transition);
}

.lb-filter:hover { color: var(--text-primary); border-color: var(--border-light); }
.lb-filter.active {
  color: var(--accent-light);
  border-color: var(--accent);
  background: var(--accent-dim);
}

/* Rank Badges */
.rank-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  font-weight: 700;
  font-size: 12px;
}

.rank-1 { background: linear-gradient(135deg, #ffd700, #f0b90b); color: #000; box-shadow: 0 0 10px rgba(255, 215, 0, 0.3); }
.rank-2 { background: linear-gradient(135deg, #c0c0c0, #a8b2b8); color: #000; }
.rank-3 { background: linear-gradient(135deg, #cd7f32, #a0522d); color: #fff; }
.rank-other { background: var(--bg-elevated); color: var(--text-secondary); }

/* ============================================================
   AUTH MODAL
   ============================================================ */
.modal {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 1000;
  align-items: center;
  justify-content: center;
}

.modal.open { display: flex; }

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(8px);
}

.modal-box {
  position: relative;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 420px;
  padding: 36px;
  box-shadow: var(--shadow-lg), var(--glow);
  z-index: 1;
  animation: modalIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes modalIn {
  from { transform: scale(0.95) translateY(-10px); opacity: 0; }
  to   { transform: scale(1) translateY(0); opacity: 1; }
}

.modal-close {
  position: absolute;
  top: 16px;
  right: 16px;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 22px;
  cursor: pointer;
  line-height: 1;
  transition: color var(--transition);
  padding: 2px 6px;
  border-radius: var(--radius-sm);
}

.modal-close:hover { color: var(--text-primary); background: var(--bg-elevated); }

.modal-logo {
  font-size: 18px;
  font-weight: 800;
  letter-spacing: 0.5px;
  color: var(--text-primary);
  margin-bottom: 20px;
}

.modal-logo .accent {
  background: var(--gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.modal-title {
  font-size: 22px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.modal-subtitle {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 28px;
}

/* Social Login Buttons */
.social-login-section {
  margin-bottom: 12px;
}

.social-btn {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
  margin-bottom: 8px;
  border: 1px solid var(--border);
}

.social-btn svg, .social-btn img {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.social-btn-google {
  background: #fff;
  color: #333;
  opacity: 0.5;
  cursor: default;
  position: relative;
}
.social-btn-google::after { content: ' (coming soon)'; font-size: 11px; color: #999; }
.social-btn-google:hover { background: #f5f5f5; }

.social-btn-apple {
  background: #000;
  color: #fff;
  border-color: #333;
  opacity: 0.5;
  cursor: default;
  position: relative;
}
.social-btn-apple::after { content: ' (coming soon)'; font-size: 11px; color: #666; }
.social-btn-apple:hover { background: #1a1a1a; }

.auth-divider {
  display: flex;
  align-items: center;
  gap: 14px;
  margin: 20px 0;
  color: var(--text-muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.auth-divider::before,
.auth-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* Form Fields */
.form-field { margin-bottom: 16px; }

.form-field label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.form-field input {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  padding: 11px 14px;
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.form-field input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-dim);
}
.form-field input::placeholder { color: var(--text-muted); }
.form-field input.error { border-color: var(--red); }

.password-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.password-wrap input { padding-right: 44px; }

.toggle-password {
  position: absolute;
  right: 10px;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  display: flex;
  align-items: center;
  transition: color var(--transition);
}

.toggle-password:hover { color: var(--text-primary); }
.toggle-password svg { width: 16px; height: 16px; }

.form-error {
  color: var(--red);
  font-size: 12px;
  margin-bottom: 12px;
  min-height: 16px;
}

.auth-switch {
  text-align: center;
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 20px;
}

/* Button Spinner */
.btn-spinner {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  display: inline-block;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ============================================================
   MOBILE ELEMENTS (hidden on desktop)
   ============================================================ */
.mobile-market-tabs { display: none; }
.mobile-back-btn { display: none; }

/* ============================================================
   LOADING STATES
   ============================================================ */
.loading-spinner-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
}

.loading-spinner {
  width: 24px;
  height: 24px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

.skeleton {
  background: linear-gradient(90deg, var(--bg-card) 25%, var(--bg-elevated) 50%, var(--bg-card) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius-sm);
}

@keyframes shimmer { to { background-position: -200% 0; } }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.4; } }

/* ============================================================
   FOOTER
   ============================================================ */
.site-footer {
  background: var(--bg-secondary);
  border-top: 1px solid var(--border);
  padding: 8px 20px;
  font-size: 11px;
  color: var(--text-muted);
  flex-shrink: 0;
}

.footer-inner {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

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

.footer-logo {
  font-weight: 700;
  font-size: 12px;
  color: var(--text-secondary);
  letter-spacing: 0.5px;
}

.footer-disclaimer {
  color: var(--text-muted);
  font-size: 10px;
}

.footer-links {
  display: flex;
  gap: 16px;
}

.footer-links a {
  color: var(--text-muted);
  font-size: 10px;
  transition: color var(--transition);
}

.footer-links a:hover { color: var(--text-secondary); }

/* ============================================================
   SETTINGS PAGE
   ============================================================ */
.settings-cards {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.settings-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  transition: border-color var(--transition);
}

.settings-card:hover { border-color: var(--border-light); }

.settings-card-header {
  display: flex;
  align-items: center;
  gap: 14px;
  flex: 1;
}

.settings-card-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.settings-card h3 {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 2px;
}

.settings-card p {
  font-size: 12px;
  color: var(--text-muted);
}

.btn-settings {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  padding: 8px 20px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: opacity var(--transition);
  flex-shrink: 0;
}

.btn-settings:hover:not(:disabled) { opacity: 0.85; }
.btn-settings:disabled { opacity: 0.4; cursor: not-allowed; }

.btn-settings-outline {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-secondary);
}

.btn-settings-danger {
  background: var(--red-dim);
  color: var(--red);
  border: 1px solid rgba(255, 77, 106, 0.2);
}

.btn-settings-danger:hover:not(:disabled) { background: var(--red); color: #fff; opacity: 1; }

/* ============================================================
   TREND INDICATOR
   ============================================================ */
.trend-indicator {
  display: inline-flex;
  align-items: center;
  gap: 3px;
}

.trend-indicator::before {
  content: '';
  display: inline-block;
  width: 0; height: 0;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-bottom: 5px solid currentColor;
}

.trend-indicator.down::before {
  border-bottom: none;
  border-top: 5px solid currentColor;
}

/* ============================================================
   RESPONSIVE — Tablet (<=900px)
   ============================================================ */
@media (max-width: 900px) {
  :root { --sidebar-width: 260px; }
  .cat-tab { font-size: 10px; padding: 3px 8px; }

  .nav-links { gap: 0; }
  .nav-link  { padding: 6px 10px; font-size: 13px; }
  .username-text { display: none; }
}

/* ============================================================
   RESPONSIVE — Mobile (<=768px)
   ============================================================ */
@media (max-width: 768px) {
  :root {
    --nav-height: 50px;
    --sidebar-width: 100%;
  }

  #topbar { padding: 0 10px; gap: 8px; }
  .logo { font-size: 16px; }
  .nav-left { gap: 12px; }
  .nav-links { gap: 0; }
  .nav-link { padding: 5px 8px; font-size: 12px; font-weight: 600; }

  .balance-info { display: none !important; }
  .username-text { display: none; }
  .user-section { gap: 8px; }

  .btn-primary { padding: 6px 14px; font-size: 13px; }
  .user-avatar { width: 28px; height: 28px; font-size: 11px; }

  /* Mobile Market Layout: Tabbed */
  .market-layout {
    flex-direction: column;
    height: calc(100vh - var(--nav-height));
    height: calc(100dvh - var(--nav-height));
    overflow: hidden;
  }

  .mobile-market-tabs {
    display: flex !important;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
  }

  .mobile-market-tab {
    flex: 1;
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 600;
    padding: 10px;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: all var(--transition);
  }

  .mobile-market-tab.active {
    color: var(--accent-light);
    border-bottom-color: var(--accent);
  }

  .market-sidebar {
    width: 100%;
    flex: 1;
    border-right: none;
    min-height: 0;
  }

  .market-sidebar.mobile-hidden { display: none; }

  .market-main {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    display: none;
  }

  .market-main.mobile-visible { display: flex; }

  .mobile-back-btn {
    display: flex !important;
    align-items: center;
    gap: 6px;
    background: none;
    border: none;
    color: var(--accent-light);
    font-size: 13px;
    font-weight: 600;
    padding: 10px 16px;
    cursor: pointer;
    border-bottom: 1px solid var(--border);
    width: 100%;
  }

  .mobile-back-btn svg { width: 16px; height: 16px; }

  .sidebar-search { padding: 8px 10px; }

  #search-input {
    padding: 10px 12px 10px 34px;
    font-size: 16px;
  }

  .search-icon { left: 18px; }

  .category-tabs { padding: 6px 8px; }
  .cat-tab { padding: 6px 12px; font-size: 12px; }

  .person-item { padding: 12px; gap: 10px; }
  .person-avatar { width: 32px; height: 32px; font-size: 12px; border-radius: 8px; }
  .person-ticker { font-size: 14px; }
  .person-name { font-size: 11px; }
  .person-price { font-size: 14px; }
  .person-change { font-size: 12px; }
  .sidebar-list-header { padding: 6px 12px; font-size: 10px; }

  .person-header { padding: 12px 16px; }
  .header-avatar { width: 36px; height: 36px; font-size: 14px; border-radius: 10px; }
  .header-name { font-size: 15px; }
  .header-price { font-size: 20px; }
  .header-change { font-size: 12px; }
  .header-stats { gap: 12px; margin-top: 8px; padding-top: 8px; }
  .stat-label { font-size: 9px; }
  .stat-value { font-size: 12px; }

  #chart-container { flex-shrink: 0; }
  #chart-canvas { height: 280px !important; }
  .chart-toolbar { padding: 6px 12px; flex-wrap: wrap; gap: 4px; }
  .tf-btn { padding: 4px 8px; font-size: 11px; }

  .trade-panel { border-top: 1px solid var(--border); margin: 0; border-radius: 0; }
  .trade-tab { padding: 10px; font-size: 14px; }
  .trade-body { padding: 12px; grid-template-columns: 1fr; gap: 10px; }
  .trade-field label { font-size: 12px; }
  #trade-quantity { padding: 12px; font-size: 16px; }
  .input-suffix { font-size: 12px; }
  .quick-qty { grid-column: 1; gap: 6px; }
  .qty-preset { padding: 8px; font-size: 12px; }
  .trade-summary { grid-column: 1; }
  .summary-row { font-size: 12px; padding: 4px 0; }
  #execute-trade-btn { grid-column: 1; padding: 14px; font-size: 15px; }

  .content-page { padding: 12px 10px 32px; }
  .page-title { font-size: 18px; }
  .page-subtitle { font-size: 12px; }
  .portfolio-summary-cards { grid-template-columns: 1fr 1fr; gap: 8px; }
  .summary-card { padding: 12px; }
  .card-label { font-size: 10px; }
  .card-value { font-size: 16px; }

  .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 0 -10px; padding: 0 10px; }
  .data-table { font-size: 12px; min-width: 600px; }
  .data-table th, .data-table td { padding: 8px 6px; white-space: nowrap; }

  .leaderboard-filters { gap: 4px; flex-wrap: wrap; }
  .lb-filter { padding: 6px 14px; font-size: 12px; }

  .modal-box { margin: 12px; padding: 24px 16px; max-height: 90dvh; overflow-y: auto; }
  .modal-logo { font-size: 16px; }
  .modal-title { font-size: 18px; }
  .btn-full { padding: 14px; font-size: 15px; }
  .form-field input { padding: 12px; font-size: 16px; }

  #toast-container { top: calc(var(--nav-height) + 8px); right: 10px; left: 10px; }
  .toast { min-width: auto; max-width: none; }

  .site-footer { padding: 8px 12px; font-size: 10px; }
  .footer-inner { flex-direction: column; text-align: center; gap: 4px; }
  .footer-brand { flex-direction: column; gap: 4px; }
}

/* Extra small (<=400px) */
@media (max-width: 400px) {
  .nav-link { padding: 4px 6px; font-size: 10px; }
  .logo { font-size: 14px; }
  .portfolio-summary-cards { grid-template-columns: 1fr; }
  .header-price { font-size: 16px; }
  .person-header-loaded { flex-direction: column; align-items: flex-start; }
  .header-price-block { text-align: left; }
}
