:root {
  --bg: #0b0f11;
  --surface: rgba(18, 25, 29, 0.7);
  --surface-solid: #12191d;
  --ink: #e2e8f0;
  --muted: #94a3b8;
  --accent: #10b981;
  --accent-up: #10b981;
  --accent-down: #f43f5e;
  --accent-2: #38bdf8;
  --line: rgba(226, 232, 240, 0.1);
  --glass: rgba(15, 23, 26, 0.6);
  --shadow: 0 12px 40px rgba(0, 0, 0, 0.4);
  --glow: 0 0 15px rgba(16, 185, 129, 0.2);
  --warning: #f59e0b;
  --success: #10b981;
  --error: #f43f5e;
  --info: #38bdf8;
}

* {
  box-sizing: border-box;
}

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

/* Layout Structure */
body {
  margin: 0;
  padding: 0;
  display: flex;
  min-height: 100vh;
  font-family: "Space Grotesk", "Segoe UI", sans-serif;
  color: var(--ink);
  background: 
    radial-gradient(circle at 0% 0%, rgba(16, 185, 129, 0.05) 0%, transparent 50%),
    radial-gradient(circle at 100% 100%, rgba(56, 189, 248, 0.05) 0%, transparent 50%),
    #0b0f11;
  line-height: 1.5;
}

.sidebar {
  width: 240px;
  background: var(--surface-solid);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  height: 100vh;
  position: sticky;
  top: 0;
  z-index: 50;
}

.sidebar-brand {
  padding: 32px 24px;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: 2px;
}

.sidebar-menu {
  flex: 1;
  padding: 0 12px;
}

.menu-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  border-radius: 12px;
  font-weight: 500;
  transition: all 0.2s;
  text-align: left;
}

.menu-item:hover {
  background: rgba(255, 255, 255, 0.05);
  color: #fff;
}

.menu-item.active {
  background: rgba(16, 185, 129, 0.1);
  color: var(--accent);
  font-weight: 700;
}

.menu-item .icon {
  font-size: 1.2rem;
}

.sidebar-footer {
  padding: 20px 12px;
  border-top: 1px solid var(--line);
}

.menu-item.logout {
  color: var(--accent-down);
}

.main-content {
  flex: 1;
  padding: 32px;
  max-width: 1400px;
  margin: 0 auto;
}

.view-section {
  display: block;
  animation: fadeIn 0.3s ease-out;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.container-grid {
  display: grid;
  gap: 20px;
  grid-template-columns: 1fr; /* Fallback */
}

.dashboard-layout {
  grid-template-columns: 1fr 380px;
  align-items: start;
}

.right-col {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

#tv-chart {
  width: 100%;
  height: 500px;
  background: var(--surface);
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--line);
  transform: translateZ(0);
}

/* KYC Styles */
.kyc-badge-wrap {
  display: flex;
  align-items: center;
}

.kyc-badge {
  padding: 4px 12px;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
}

.kyc-badge.unverified {
  background: rgba(244, 63, 94, 0.1);
  color: var(--accent-down);
  border: 1px solid var(--accent-down);
}

.kyc-badge.verified {
  background: rgba(16, 185, 129, 0.1);
  color: var(--accent);
  border: 1px solid var(--accent);
}

.kyc-badge.warning {
  border: 1px solid var(--warning);
}

.header-auth-btns {
  display: flex;
  gap: 10px;
  margin-left: 15px;
}

.mini-btn {
  width: auto;
  padding: 6px 14px;
  font-size: 0.8rem;
  border-radius: 8px;
  background: var(--accent);
  color: var(--bg);
  font-weight: 700;
  transition: all 0.2s;
}

.mini-btn.secondary {
  background: rgba(255, 255, 255, 0.05);
  color: #fff;
  border: 1px solid var(--line);
}

.mini-btn:hover {
  transform: translateY(-2px);
  filter: brightness(1.2);
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

.pair-selector select {
  background: var(--surface-solid);
  border: 1px solid var(--line);
  color: #fff;
  padding: 0.5rem 1.5rem 0.5rem 1rem;
  border-radius: 8px;
  font-family: inherit;
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.2s;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='%2394a3b8' viewBox='0 0 16 16'%3E%3Cpath d='M7.247 11.14 2.451 5.658C2.185 5.355 2.403 5 2.808 5h10.384c.405 0 .623.355.357.658l-4.796 5.482a.5.5 0 0 1-.748 0z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  color-scheme: dark;
}

.pair-selector select:hover {
  border-color: var(--accent);
  box-shadow: 0 0 10px rgba(16, 185, 129, 0.1);
}


.total-value {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--emerald);
  text-shadow: 0 0 10px rgba(16, 185, 129, 0.3);
}

.wallet-action-btn {
  background: rgba(16, 185, 129, 0.1);
  color: var(--emerald);
  border: 1px solid var(--emerald);
  padding: 0.3rem 0.8rem;
  border-radius: 6px;
  font-size: 0.8rem;
  cursor: pointer;
  transition: background 0.2s;
}

.wallet-action-btn:hover {
  background: var(--emerald);
  color: var(--bg-dark);
}

.kyc-lock-message {
  background: rgba(245, 158, 11, 0.1);
  border: 1px solid var(--warning);
  color: var(--warning);
  padding: 1rem;
  border-radius: 12px;
  margin-bottom: 1rem;
  font-size: 0.9rem;
  line-height: 1.5;
}

.mini-title {
  font-size: 0.85rem;
  color: var(--muted);
  text-transform: uppercase;
  margin-bottom: 8px;
}

h1, h2, h3 {
  margin: 0 0 12px;
  letter-spacing: -0.02em;
}

h1 { font-size: 1.5rem; font-weight: 700; color: #fff; }
h2 { font-size: 1.1rem; font-weight: 600; color: var(--muted); }

.meta {
  color: var(--muted);
  font-size: 0.85rem;
  margin-bottom: 20px;
}
.meta a { color: var(--accent); text-decoration: none; }

.grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

label {
  display: block;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  margin-bottom: 6px;
}

input, select {
  width: 100%;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.03);
  padding: 12px;
  font: inherit;
  color: #fff;
  transition: border-color 0.2s, box-shadow 0.2s;
  color-scheme: dark;
}

input:focus, select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: var(--glow);
}

select option {
  background-color: var(--surface-solid);
  color: #fff;
}

button {
  width: 100%;
  border-radius: 12px;
  border: none;
  padding: 12px 20px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  background: var(--accent);
  color: #0b0f11;
}
button.secondary { background: var(--accent-2); }
button:hover {
  transform: translateY(-2px);
  filter: brightness(1.1);
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.2);
}
button:active { transform: translateY(0); }

/* Stats Card */
.stats-card {
  display: flex;
  justify-content: space-between;
  margin-bottom: 20px;
  gap: 12px;
}
.stat-item {
  flex: 1;
  background: rgba(255, 255, 255, 0.02);
  padding: 12px;
  border-radius: 16px;
  border: 1px solid var(--line);
}
.stat-label { font-size: 0.7rem; color: var(--muted); text-transform: uppercase; margin-bottom: 4px; }
.stat-value { font-size: 1.15rem; font-weight: 700; font-variant-numeric: tabular-nums; color: #fff; }
.stat-value.up { color: var(--accent-up); text-shadow: 0 0 10px rgba(16, 185, 129, 0.3); }
.stat-value.down { color: var(--accent-down); text-shadow: 0 0 10px rgba(244, 63, 94, 0.3); }

/* Tradingview Container */
#tv-chart {
  height: 420px;
  border-radius: 12px;
  overflow: hidden;
  margin-bottom: 20px;
  border: 1px solid var(--line);
}

/* Tables */
.table-wrap {
  overflow: auto;
  max-height: 400px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.1);
}
table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
th {
  text-align: left;
  padding: 12px 8px;
  font-size: 0.7rem;
  text-transform: uppercase;
  color: var(--muted);
  position: sticky;
  top: 0;
  background: var(--surface-solid);
  z-index: 5;
}
td { padding: 8px; font-variant-numeric: tabular-nums; border-bottom: 1px solid var(--line); }

.price-up { color: var(--accent-up); font-weight: 600; }
.price-down { color: var(--accent-down); font-weight: 600; }
.muted { color: var(--muted); }

.sell-row { background: rgba(244, 63, 94, 0.02); }
.buy-row { background: rgba(16, 185, 129, 0.02); }

/* Header */
.trader-header {
  grid-column: 1 / -1;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 24px;
  background: var(--surface);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  border: 1px solid var(--line);
  border-radius: 999px;
  margin-bottom: 10px;
  box-shadow: 0 0 20px rgba(16, 185, 129, 0.05);
  transform: translateZ(0);
}
.user-badge {
  background: var(--accent);
  color: #0b0f11;
  padding: 4px 16px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 0.85rem;
}
.balance-ticker { display: flex; gap: 24px; }
.balance-item { font-size: 0.95rem; font-weight: 600; color: #fff; }
.balance-item span { color: var(--muted); font-size: 0.75rem; margin-left: 4px; font-weight: 400; }

.logout-btn {
  width: auto;
  padding: 6px 18px;
  background: rgba(244, 63, 94, 0.1);
  color: var(--accent-down);
  border: 1px solid rgba(244, 63, 94, 0.2);
}
.logout-btn:hover { background: var(--accent-down); color: #fff; }

/* Auth */
.auth-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  display: grid;
  place-items: center;
  z-index: 100;
}
.auth-card {
  width: min(420px, 92vw);
  background: var(--surface-solid);
  border: 1px solid var(--line);
  border-radius: 24px;
  padding: 32px;
  box-shadow: 0 0 60px rgba(0, 0, 0, 0.5);
}
.auth-tabs { 
  display: flex; 
  gap: 12px; 
  margin-bottom: 24px; 
  border-bottom: 1px solid var(--line); 
  padding-bottom: 12px; 
  position: relative;
}

.auth-close-btn {
  position: absolute;
  right: 0;
  top: -4px;
  background: none;
  border: none;
  color: var(--muted);
  font-size: 1.2rem;
  cursor: pointer;
  width: auto;
  padding: 4px;
  transition: color 0.2s;
}

.auth-close-btn:hover {
  color: var(--accent-down);
}
.auth-tab { background: none; border: none; color: var(--muted); cursor: pointer; font-weight: 600; width: auto; padding: 0 8px; }
.auth-tab.active { color: var(--accent); border-bottom: 2px solid var(--accent); border-radius: 0; }
.password-wrapper { position: relative; display: flex; align-items: center; }
.password-wrapper input { padding-right: 44px; }
.toggle-password { position: absolute; right: 12px; background: none; border: none; color: var(--muted); cursor: pointer; width: auto; }

.hidden { display: none !important; }
.mt-10 { margin-top: 10px; }
.mt-14 { margin-top: 14px; }
.grid-full { grid-column: 1 / -1; }
.flex-end { display: flex; justify-content: flex-end; }

@media (max-width: 1000px) {
  .container { grid-template-columns: 1fr; }
  .stats-card { flex-wrap: wrap; }
  .stat-item { flex: 1 1 40%; }
}

/* Toast System */
.toast-container {
  position: fixed;
  top: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  z-index: 200;
}

.toast {
  padding: 16px 24px;
  border-radius: 12px;
  background: var(--surface-solid);
  border: 1px solid var(--line);
  color: #fff;
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 300px;
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  animation: slideIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: hidden;
}

.toast.success { border-left: 4px solid var(--success); }
.toast.error { border-left: 4px solid var(--error); }
.toast.info { border-left: 4px solid var(--info); }
.toast.warning { border-left: 4px solid var(--warning); }

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

/* Strength Meter */
.strength-meter {
  margin-top: 8px;
  background: rgba(255, 255, 255, 0.05);
  height: 6px;
  border-radius: 3px;
  position: relative;
  overflow: hidden;
}

.strength-bar {
  height: 100%;
  width: 0%;
  transition: all 0.3s ease;
}

.strength-text {
  position: absolute;
  right: 0;
  top: -20px;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
}

.strength-bar.weak { background: var(--error); width: 25%; }
.strength-bar.fair { background: var(--warning); width: 50%; }
.strength-bar.good { background: var(--info); width: 75%; }
.strength-bar.strong { background: var(--success); width: 100%; }

/* Market List */
.market-list-wrap {
  max-height: 540px;
  overflow-y: auto;
  padding-right: 8px;
}

.my-trades-panel-header {
  margin-top: 20px;
}

.my-trades-wrap {
  max-height: 480px;
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 8px;
  overflow-y: auto;
}

.text-green {
  color: var(--success);
}

.text-red {
  color: var(--error);
}

.align-right {
  text-align: right;
}

.empty-state {
  text-align: center;
  opacity: 0.5;
  padding: 20px;
}

.market-list-wrap::-webkit-scrollbar {
  width: 6px;
}

.market-list-wrap::-webkit-scrollbar-thumb {
  background: var(--line);
  border-radius: 10px;
}

.market-list-wrap::-webkit-scrollbar-track {
  background: transparent;
}

.mini-btn-icon {
  width: auto;
  padding: 4px 8px;
  background: none;
  font-size: 1.1rem;
  filter: grayscale(1);
  opacity: 0.6;
}

.mini-btn-icon:hover {
  transform: rotate(90deg);
  filter: grayscale(0);
  opacity: 1;
}

.trade-btn-sm {
  padding: 4px 12px;
  font-size: 0.75rem;
  border-radius: 6px;
  width: auto;
}

/* Admin Dashboard Specifics */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.metric-card {
  background: var(--surface);
  border: 1px solid var(--line);
  padding: 20px;
  border-radius: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: transform 0.2s, box-shadow 0.2s;
  transform: translateZ(0); /* GPU acceleration */
}

.metric-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
  border-color: var(--accent);
}

.metric-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.metric-value {
  font-size: 1.75rem;
  font-weight: 700;
  color: #fff;
  font-variant-numeric: tabular-nums;
}

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

.auto-refresh-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  color: var(--muted);
  cursor: pointer;
  margin: 0;
  text-transform: none;
}

.auto-refresh-check {
  width: 16px;
  height: 16px;
  cursor: pointer;
}

.pager {
  display: flex;
  gap: 8px;
  margin: 16px 0;
  align-items: center;
}

.pager button {
  width: auto;
  padding: 6px 12px;
  font-size: 0.8rem;
  background: var(--surface-solid);
  border: 1px solid var(--line);
  color: var(--muted);
}

.pager button:hover:not(:disabled) {
  background: var(--accent);
  color: #0b0f11;
  border-color: var(--accent);
}

.pager .active-page {
  background: var(--accent);
  color: #0b0f11;
  border-color: var(--accent);
  font-weight: 700;
}

/* Admin Utilities */
.section-title {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 24px;
  color: #fff;
  border-left: 4px solid var(--accent);
  padding-left: 16px;
}

.mini-input, .mini-select {
  padding: 6px 12px !important;
  font-size: 0.85rem !important;
  height: auto !important;
  width: auto !important;
}

.w-100 { width: 100% !important; }
.space-between { justify-content: space-between; }
.scroll-box {
  background: rgba(0,0,0,0.2);
  border: 1px solid var(--line);
  padding: 12px;
  border-radius: 8px;
  overflow-y: auto;
  color: var(--accent);
  font-family: 'Space Mono', monospace;
}

.hidden { display: none !important; }

.pager {
  background: rgba(255,255,255,0.02);
  padding: 8px;
  border-radius: 8px;
  border: 1px solid var(--line);
  margin-bottom: 12px;
}

.small { font-size: 0.8rem; }

.pager-info {
  font-size: 0.85rem;
  color: var(--muted);
  flex: 1;
  text-align: center;
}

.pager-info strong {
  color: var(--accent);
}

/* New Refinement Classes */
.admin-auth-brand {
  padding: 0 0 20px 0;
  text-align: center;
}

.admin-header-flush {
  border-radius: 0 !important;
  margin: 0 !important;
  border: none !important;
  border-bottom: 1px solid var(--line) !important;
  padding: 15px 32px !important;
}

.admin-auth-status {
  margin-left: 15px;
}

.refresh-box {
  background: rgba(255, 255, 255, 0.05);
  padding: 5px 15px;
  border-radius: 8px;
}

.select-ghost {
  background: transparent !important;
  border: none !important;
  color: var(--muted) !important;
  font-size: 0.8rem !important;
  width: auto !important;
  padding-right: 25px !important; /* adjust for chevron */
}

.external-link-btn {
  text-decoration: none;
  display: flex !important;
  align-items: center;
  justify-content: center;
}

.admin-log-pre {
  height: 200px;
  font-size: 0.75rem;
}

.lookup-result-pre {
  height: 120px;
  font-size: 0.7rem;
}

.flex-1 {
  flex: 1;
}

.font-bold { font-weight: 700; }
.mb-4 { margin-bottom: 4px !important; }
.mb-10 { margin-bottom: 10px !important; }
.mt-0 { margin-top: 0 !important; }
.mt-10 { margin-top: 10px !important; }
.mt-14 { margin-top: 14px !important; }
.orderbook-row {
  position: relative;
  display: flex;
  justify-content: space-between;
  padding: 4px 8px;
  font-size: 0.85rem;
  z-index: 1;
}

.depth-bar {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: -1;
  transition: width 0.3s ease;
  opacity: 0.15;
}

.depth-bar.bid { background: var(--accent-up); }
.depth-bar.ask { background: var(--accent-down); }
/* Mobile Navigation Styles */
.hamburger-btn {
  display: none;
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 100;
  width: 44px;
  height: 44px;
  border-radius: 10px;
  background: var(--accent);
  color: #0b0f11;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  align-items: center;
  justify-content: center;
}

.mobile-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0,0,0,0.7);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
  z-index: 45;
}

/* Media Queries */
@media (max-width: 992px) {
  body {
    flex-direction: column;
  }

  .sidebar {
    position: fixed;
    left: -240px;
    top: 0;
    transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 20px 0 40px rgba(0,0,0,0.5);
  }

  .sidebar.open {
    left: 0;
  }

  .sidebar.open + .mobile-overlay {
    display: block;
  }

  .hamburger-btn {
    display: flex;
  }

  .main-content {
    padding: 70px 16px 24px;
  }

  .dashboard-layout {
    grid-template-columns: 1fr;
  }

  .stat-item {
    padding: 10px;
  }

  .stat-value {
    font-size: 1rem;
  }

  .trader-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }

  .pair-selector select {
    width: 100%;
  }

  #tv-chart {
    height: 350px;
  }
}

@media (max-width: 576px) {
  h1 { font-size: 1.25rem; }
  
  .stats-card {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }

  .grid {
    grid-template-columns: 1fr;
  }

  .auth-card {
    padding: 24px 16px;
    width: 95%;
  }

  .sidebar-brand {
    padding: 24px 16px;
    font-size: 1.2rem;
  }

  .panel {
    padding: 16px !important;
  }

  .price-ticker {
    font-size: 1.5rem;
  }
}
