/* ============================================
   xTraderLab-mini — Premium Dark Theme
   Inspired by TraderLab production design
   ============================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800;900&display=swap');

:root {
  /* === Backgrounds === */
  --bg-primary:    hsl(215, 28%, 7%);    /* #0d1117  — body */
  --bg-secondary:  hsl(222, 20%, 9%);    /* #141822  — page-header */
  --bg-card:       hsl(222, 22%, 11%);   /* #161c2b  — cards base */
  --bg-input:      hsl(220, 20%, 14%);   /* #1c2333  — inputs */
  --bg-hover:      hsl(220, 20%, 16%);   /* #212b3b  — row hover */
  --bg-sidebar:    hsl(214, 16%, 6%);    /* #0e1016  — sidebar (TraderLab exact) */

  /* === Text === */
  --text-primary:   hsl(210, 40%, 98%);  /* #f8fafc */
  --text-secondary: hsl(215, 16%, 60%);  /* #8b97aa */
  --text-muted:     hsl(215, 13%, 38%);  /* #556070 */

  /* === Accent palette (TraderLab-aligned) === */
  --accent-green:  hsl(160, 64%, 52%);   /* #2ab05b — profits */
  --accent-blue:   hsl(221, 83%, 53%);   /* #3b82f6 — primary */
  --accent-cyan:   hsl(198, 92%, 48%);   /* #0ea5e9 — links / WS */
  --accent-purple: hsl(271, 81%, 66%);   /* #a855f7 */
  --accent-yellow: hsl(43,  96%, 56%);   /* #f59e0b */
  --accent-red:    hsl(352, 89%, 72%);   /* #f28b8b — losses */
  --accent-orange: hsl(25, 100%, 60%);   /* #ff6a1a */

  /* === Card gradient tones (TraderLab dark card effect) === */
  --grad-cyan:   rgba(14,  165, 233, 1);
  --grad-purple: rgba(168,  85, 247, 1);
  --grad-blue:   rgba( 59, 130, 246, 1);
  --grad-green:  rgba( 16, 185, 129, 1);

  /* === Borders === */
  --border-color: rgba(14, 165, 233, 0.12);
  --border-light: rgba(14, 165, 233, 0.25);

  /* === Sizing === */
  --sidebar-width: 240px;
  --radius:    8px;
  --radius-lg: 12px;
}

/* ============================================
   Reset & Base
   ============================================ */

*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

/* Prevent horizontal page scroll globally */
html {
  overflow-x: hidden;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.5;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--accent-cyan);
  text-decoration: none;
  transition: color 0.15s;
}

a:hover { color: var(--accent-blue); }

/* ============================================
   Layout
   ============================================ */

.app-container {
  display: flex;
  min-height: 100vh;
}

/* ===== Sidebar ===== */
.sidebar {
  width: var(--sidebar-width);
  background: var(--bg-sidebar);
  border-right: 1px solid rgba(255,255,255,0.05);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
}

.sidebar-logo {
  padding: 18px 20px;
  border-bottom: 1px solid rgba(255,255,255,0.05);
  display: flex;
  align-items: center;
  gap: 12px;
}

.sidebar-logo h1 {
  font-size: 15px;
  font-weight: 700;
  color: var(--accent-green);
  letter-spacing: 1.5px;
  text-transform: uppercase;
}

.sidebar-logo small {
  font-size: 10px;
  color: var(--text-muted);
  display: block;
  letter-spacing: 0.5px;
}

.sidebar-nav {
  flex: 1;
  padding: 8px 0;
  overflow-y: auto;
}

.nav-label {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1.5px;
  padding: 16px 20px 6px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 20px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s;
  border-left: 2px solid transparent;
  font-size: 13.5px;
  font-weight: 400;
  margin: 1px 0;
}

.nav-item:hover {
  background: rgba(255,255,255,0.04);
  color: var(--text-primary);
}

.nav-item.active {
  background: rgba(42, 176, 91, 0.08);
  color: var(--accent-green);
  border-left-color: var(--accent-green);
  font-weight: 500;
}

.nav-item svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  opacity: 0.8;
}

.nav-item.active svg { opacity: 1; }

/* ===== Main Content ===== */
.main-content {
  margin-left: var(--sidebar-width);
  flex: 1;
  min-height: 100vh;
  min-width: 0; /* critical: prevents flex item from overflowing viewport */
}

.page-header {
  padding: 20px 28px;
  border-bottom: 1px solid rgba(255,255,255,0.05);
  background: var(--bg-secondary);
}

.page-header h2 {
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -0.3px;
}

.page-header p {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 3px;
}

.page-content {
  padding: 24px 28px;
}

/* ============================================
   Tech Card — Premium gradient card
   (mirrors TraderLab .dark .tech-card)
   ============================================ */

.tech-card {
  position: relative;
  background: linear-gradient(135deg,
    rgba(14,  165, 233, 0.04),
    rgba(168,  85, 247, 0.03),
    rgba( 59, 130, 246, 0.03) 70%,
    rgba( 16, 185, 129, 0.03));
  border: 1px solid rgba(14, 165, 233, 0.15);
  border-radius: var(--radius-lg);
  backdrop-filter: blur(8px);
  overflow: hidden;
  transition: all 0.3s;
}

/* Top gradient line */
.tech-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 1px;
  background: linear-gradient(90deg,
    transparent 0%,
    rgba(14,  165, 233, 0.45) 20%,
    rgba(168,  85, 247, 0.45) 50%,
    rgba(14,  165, 233, 0.45) 80%,
    transparent 100%);
}

/* Bottom gradient line */
.tech-card::after {
  content: '';
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 1px;
  background: linear-gradient(90deg,
    transparent 0%,
    rgba(16, 185, 129, 0.25) 30%,
    rgba(59, 130, 246, 0.25) 70%,
    transparent 100%);
}

.tech-card:hover {
  border-color: rgba(14, 165, 233, 0.28);
  transform: translateY(-1px);
  box-shadow:
    0 8px 24px rgba(0,0,0,0.3),
    0 0 0 1px rgba(14, 165, 233, 0.08);
}

/* ============================================
   Stats Cards
   ============================================ */

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: linear-gradient(135deg,
    rgba(14,  165, 233, 0.04),
    rgba(168,  85, 247, 0.03),
    rgba( 59, 130, 246, 0.03) 70%,
    rgba( 16, 185, 129, 0.03));
  border: 1px solid rgba(14, 165, 233, 0.14);
  border-radius: var(--radius-lg);
  padding: 20px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  position: relative;
  overflow: hidden;
  transition: all 0.3s;
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 1px;
  background: linear-gradient(90deg,
    transparent 0%,
    rgba(14,  165, 233, 0.5) 20%,
    rgba(168,  85, 247, 0.5) 50%,
    rgba(14,  165, 233, 0.5) 80%,
    transparent 100%);
}

.stat-card:hover {
  border-color: rgba(14, 165, 233, 0.28);
  transform: translateY(-1px);
  box-shadow: 0 8px 24px rgba(0,0,0,0.25);
}

.stat-card .stat-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 10px;
}

.stat-card .stat-value {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.5px;
}

.stat-card .stat-sub {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
}

.stat-icon {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}

.stat-icon.green  { background: rgba(42,  176,  91, 0.15); color: var(--accent-green); }
.stat-icon.blue   { background: rgba(59,  130, 246, 0.15); color: var(--accent-blue); }
.stat-icon.purple { background: rgba(168,  85, 247, 0.15); color: var(--accent-purple); }
.stat-icon.yellow { background: rgba(245, 158,  11, 0.15); color: var(--accent-yellow); }
.stat-icon.cyan   { background: rgba(14,  165, 233, 0.15); color: var(--accent-cyan); }
.stat-icon.red    { background: rgba(242, 139, 139, 0.15); color: var(--accent-red); }

/* ============================================
   Chart / Section Container
   ============================================ */

.chart-container {
  background: linear-gradient(135deg,
    rgba(14,  165, 233, 0.03),
    rgba(168,  85, 247, 0.025),
    rgba( 59, 130, 246, 0.025) 70%,
    rgba( 16, 185, 129, 0.025));
  border: 1px solid rgba(14, 165, 233, 0.13);
  border-radius: var(--radius-lg);
  padding: 20px;
  margin-bottom: 20px;
  position: relative;
  overflow: hidden;
}

.chart-container::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 1px;
  background: linear-gradient(90deg,
    transparent 0%,
    rgba(14,  165, 233, 0.4) 20%,
    rgba(168,  85, 247, 0.4) 50%,
    rgba(14,  165, 233, 0.4) 80%,
    transparent 100%);
}

.chart-container h3 {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.2px;
  margin-bottom: 16px;
}

/* ============================================
   Data Table
   ============================================ */

.table-container {
  background: linear-gradient(135deg,
    rgba(14,  165, 233, 0.03),
    rgba(168,  85, 247, 0.025),
    rgba( 59, 130, 246, 0.025) 70%,
    rgba( 16, 185, 129, 0.025));
  border: 1px solid rgba(14, 165, 233, 0.13);
  border-radius: var(--radius-lg);
  overflow: hidden;
  position: relative;
}

.table-container::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 1px;
  background: linear-gradient(90deg,
    transparent 0%,
    rgba(14,  165, 233, 0.4) 20%,
    rgba(168,  85, 247, 0.4) 50%,
    rgba(14,  165, 233, 0.4) 80%,
    transparent 100%);
  z-index: 1;
}

.table-header {
  padding: 16px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid rgba(255,255,255,0.05);
}

.table-header h3 {
  font-size: 15px;
  font-weight: 600;
}

.search-input {
  background: var(--bg-input);
  border: 1px solid rgba(14, 165, 233, 0.15);
  border-radius: 8px;
  padding: 8px 12px 8px 36px;
  color: var(--text-primary);
  font-family: 'Inter', sans-serif;
  font-size: 13px;
  width: 260px;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.search-input:focus {
  border-color: rgba(14, 165, 233, 0.4);
  box-shadow: 0 0 0 3px rgba(14, 165, 233, 0.08);
}

.search-input::placeholder { color: var(--text-muted); }

/* Horizontal scrollable wrapper for tables */
.table-scroll-wrapper {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch; /* smooth inertia on iOS */
  width: 100%;
}

table {
  width: 100%;
  border-collapse: collapse;
}

thead th {
  text-align: left;
  padding: 11px 16px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.7px;
  border-bottom: 1px solid rgba(255,255,255,0.05);
  white-space: nowrap;
}

tbody td {
  padding: 12px 16px;
  font-size: 13px;
  border-bottom: 1px solid rgba(255,255,255,0.03);
  white-space: nowrap;
}

tbody tr {
  transition: background 0.15s;
}

tbody tr:hover {
  background: rgba(14, 165, 233, 0.04);
}

tbody tr:last-child td { border-bottom: none; }

/* ============================================
   Status Indicators
   ============================================ */

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  display: inline-block;
  margin-right: 6px;
  flex-shrink: 0;
}

.status-dot.online {
  background: var(--accent-green);
  box-shadow: 0 0 0 2px rgba(42,176,91,0.2), 0 0 8px rgba(42,176,91,0.5);
  animation: pulse-dot 2.5s ease-in-out infinite;
}

.status-dot.offline {
  background: var(--text-muted);
}

.status-dot.slow {
  background: var(--accent-yellow);
  box-shadow: 0 0 6px rgba(245,158,11,0.4);
}

@keyframes pulse-dot {
  0%, 100% { box-shadow: 0 0 0 2px rgba(42,176,91,0.2), 0 0 6px rgba(42,176,91,0.4); }
  50%       { box-shadow: 0 0 0 4px rgba(42,176,91,0.1), 0 0 12px rgba(42,176,91,0.6); }
}

/* ============================================
   Badges — Pill style (TraderLab)
   ============================================ */

.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 10px;
  border-radius: 9999px;
  font-size: 11px;
  font-weight: 600;
  border: 1px solid transparent;
  letter-spacing: 0.3px;
}

.badge.green  {
  background: rgba(42,  176,  91, 0.12);
  color: var(--accent-green);
  border-color: rgba(42, 176, 91, 0.2);
}
.badge.blue   {
  background: rgba(59,  130, 246, 0.12);
  color: var(--accent-blue);
  border-color: rgba(59, 130, 246, 0.2);
}
.badge.cyan   {
  background: rgba(14,  165, 233, 0.12);
  color: var(--accent-cyan);
  border-color: rgba(14, 165, 233, 0.2);
}
.badge.red    {
  background: rgba(242, 139, 139, 0.12);
  color: var(--accent-red);
  border-color: rgba(242, 139, 139, 0.2);
}
.badge.yellow {
  background: rgba(245, 158,  11, 0.12);
  color: var(--accent-yellow);
  border-color: rgba(245, 158, 11, 0.2);
}
.badge.purple {
  background: rgba(168,  85, 247, 0.12);
  color: var(--accent-purple);
  border-color: rgba(168, 85, 247, 0.2);
}

/* ============================================
   Buttons
   ============================================ */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  font-family: 'Inter', sans-serif;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.2s;
  letter-spacing: -0.1px;
}

.btn-primary {
  background: var(--accent-blue);
  color: #fff;
  box-shadow: 0 2px 8px rgba(59, 130, 246, 0.3);
}

.btn-primary:hover {
  background: hsl(221, 83%, 46%);
  box-shadow: 0 4px 16px rgba(59, 130, 246, 0.4);
  transform: translateY(-1px);
}

.btn-danger {
  background: rgba(242, 139, 139, 0.1);
  color: var(--accent-red);
  border-color: rgba(242, 139, 139, 0.2);
}

.btn-danger:hover {
  background: rgba(242, 139, 139, 0.18);
  border-color: rgba(242, 139, 139, 0.35);
}

.btn-outline {
  background: transparent;
  color: var(--text-secondary);
  border-color: rgba(14, 165, 233, 0.2);
}

.btn-outline:hover {
  background: rgba(14, 165, 233, 0.06);
  color: var(--text-primary);
  border-color: rgba(14, 165, 233, 0.35);
}

.btn-sm {
  padding: 4px 10px;
  font-size: 12px;
}

/* ============================================
   Tabs
   ============================================ */

.tabs {
  display: flex;
  gap: 2px;
  margin-bottom: 20px;
  background: rgba(0,0,0,0.25);
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: var(--radius);
  padding: 3px;
  width: fit-content;
}

.tab {
  padding: 7px 16px;
  font-size: 13px;
  font-weight: 400;
  color: var(--text-secondary);
  cursor: pointer;
  border-radius: 6px;
  transition: all 0.2s;
}

.tab:hover { color: var(--text-primary); }

.tab.active {
  background: rgba(14, 165, 233, 0.1);
  color: var(--accent-cyan);
  font-weight: 500;
  border: 1px solid rgba(14, 165, 233, 0.2);
}

/* ============================================
   Connection Status
   ============================================ */

.connection-indicator {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-muted);
}

.connection-indicator.connected { color: var(--accent-green); }

.connection-indicator .pulse {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent-green);
  animation: pulse-soft 2s ease-in-out infinite;
}

@keyframes pulse-soft {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.5; }
}

/* ============================================
   Toast Notifications
   ============================================ */

.toast-container {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  background: hsl(222, 22%, 13%);
  border: 1px solid rgba(14, 165, 233, 0.2);
  border-radius: var(--radius-lg);
  padding: 12px 16px;
  font-size: 13px;
  min-width: 290px;
  animation: slideIn 0.3s ease;
  display: flex;
  align-items: center;
  gap: 10px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.4);
}

.toast.success { border-left: 3px solid var(--accent-green); }
.toast.error   { border-left: 3px solid var(--accent-red); }
.toast.info    { border-left: 3px solid var(--accent-cyan); }

@keyframes slideIn {
  from { transform: translateX(110%); opacity: 0; }
  to   { transform: translateX(0);    opacity: 1; }
}

/* ============================================
   Profit / Loss colors
   ============================================ */

.positive { color: var(--accent-green); font-weight: 600; }
.negative { color: var(--accent-red);   font-weight: 600; }

/* ============================================
   Utilities
   ============================================ */

.text-green  { color: var(--accent-green); }
.text-red    { color: var(--accent-red); }
.text-blue   { color: var(--accent-blue); }
.text-cyan   { color: var(--accent-cyan); }
.text-yellow { color: var(--accent-yellow); }
.text-purple { color: var(--accent-purple); }
.text-muted  { color: var(--text-muted); }

.flex            { display: flex; }
.items-center    { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2  { gap: 8px; }
.gap-4  { gap: 16px; }
.mt-4   { margin-top: 16px; }
.mb-4   { margin-bottom: 16px; }

.hidden { display: none !important; }

/* Numbers / monetary values */
.mono {
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.3px;
}

/* ============================================
   Glow animation (status / real-time indicator)
   ============================================ */

@keyframes glow {
  0%, 100% {
    box-shadow: 0 0 6px rgba(59, 130, 246, 0.15),
                0 0 12px rgba(59, 130, 246, 0.08);
  }
  50% {
    box-shadow: 0 0 10px rgba(59, 130, 246, 0.3),
                0 0 20px rgba(59, 130, 246, 0.15);
  }
}

.glow-blue { animation: glow 3s ease-in-out infinite alternate; }

/* ============================================
   Scrollbar
   ============================================ */

::-webkit-scrollbar       { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: rgba(14, 165, 233, 0.2);
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover { background: rgba(14, 165, 233, 0.4); }

/* ============================================
   Responsive Layout
   ============================================ */

/* --- Hamburger Button (mobile only, hidden by default) --- */
.hamburger-btn {
  display: none;
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 200;
  background: var(--bg-card);
  border: 1px solid rgba(14, 165, 233, 0.2);
  border-radius: var(--radius);
  padding: 7px;
  cursor: pointer;
  color: var(--text-secondary);
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
  line-height: 0;
}
.hamburger-btn:hover {
  color: var(--text-primary);
  border-color: rgba(14, 165, 233, 0.35);
}

/* --- Sidebar Overlay (mobile) --- */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  z-index: 95;
  backdrop-filter: blur(2px);
}
.sidebar-overlay.active { display: block; }

/* --- 2-column grid layout helper (replaces inline style) --- */
.grid-2col {
  grid-template-columns: repeat(2, 1fr) !important;
}

/* ===== 1280px — Large laptop / tight desktop ===== */
@media (max-width: 1280px) {
  .page-content { padding: 20px; }
  .page-header  { padding: 16px 20px; }
  .stats-grid   { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
}

/* ===== 1024px — Tablet / small laptop: icon-only sidebar ===== */
@media (max-width: 1024px) {
  .sidebar {
    width: 64px;
    overflow: hidden;
    transition: width 0.3s ease;
  }
  .main-content { margin-left: 64px; }

  /* Sidebar content adjustments */
  .sidebar-logo        { padding: 16px 0; justify-content: center; }
  .sidebar-logo-text   { display: none; }
  .nav-label           { display: none; }
  .nav-item            { padding: 12px 0; justify-content: center; gap: 0; }
  .nav-item svg        { width: 20px; height: 20px; }
  .nav-text            { display: none; }

  /* WS status: keep dot, hide label */
  #ws-status           { justify-content: center; }
  #ws-status .nav-text { display: none; }

  .stats-grid { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
  .grid-2col  { grid-template-columns: repeat(2, 1fr) !important; }
  .page-content { padding: 16px; }
  .page-header  { padding: 14px 16px; }
}

/* ===== 768px — Mobile: off-canvas sidebar + hamburger ===== */
@media (max-width: 768px) {
  /* Sidebar becomes off-canvas */
  .sidebar {
    width: 240px;
    transform: translateX(-100%);
    transition: transform 0.3s ease;
    overflow: hidden;
  }
  .sidebar.open { transform: translateX(0); }

  /* Restore full sidebar when open on mobile */
  .sidebar.open .sidebar-logo        { padding: 18px 20px; justify-content: flex-start; }
  .sidebar.open .sidebar-logo-text   { display: block; }
  .sidebar.open .nav-label           { display: block; }
  .sidebar.open .nav-item            { padding: 10px 20px; justify-content: flex-start; gap: 10px; }
  .sidebar.open .nav-item svg        { width: 16px; height: 16px; }
  .sidebar.open .nav-text            { display: inline; }
  .sidebar.open #ws-status           { justify-content: flex-start; }
  .sidebar.open #ws-status .nav-text { display: inline; }

  .main-content  { margin-left: 0; }
  .hamburger-btn { display: flex; }

  /* Layout spacing with room for hamburger button */
  .page-content { padding: 14px; }
  .page-header  { padding: 14px 16px 14px 52px; }

  /* Grids */
  .stats-grid { grid-template-columns: 1fr 1fr; gap: 12px; }
  .grid-2col  { grid-template-columns: 1fr !important; }

  /* Table header: wrap search below title */
  .table-header {
    flex-wrap: wrap;
    gap: 10px;
    align-items: stretch;
  }
  .search-input { width: 100%; max-width: 100%; }

  .stat-card .stat-value { font-size: 22px; }
}

/* ===== 480px — Small mobile ===== */
@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr; gap: 10px; }
  .stat-card  { padding: 14px; }
  .stat-card .stat-value { font-size: 20px; }
}

/* ============================================
   Auth Page — Login / Register / Reset
   Inspired by TraderLab production design
   ============================================ */

.auth-page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background-color: #111827;
  position: relative;
  overflow: hidden;
  padding: 16px;
}

/* Background image layer */
.auth-bg-image {
  position: absolute;
  inset: 0;
  background-image: url('https://images.unsplash.com/photo-1611974789855-9c2a0a7236a3?w=1920&q=80');
  background-size: cover;
  background-position: center;
  opacity: 0.25;
  z-index: 0;
}

/* Gradient overlay */
.auth-bg-gradient {
  position: absolute;
  inset: 0;
  background: linear-gradient(
    to bottom right,
    rgb(8 28 16 / 89%) 0%,
    rgb(17 24 39 / 74%) 50%,
    rgb(55 31 31 / 43%) 100%
  );
  z-index: 1;
}

/* Content above background */
.auth-content {
  position: relative;
  z-index: 2;
  width: 100%;
  max-width: 440px;
}

/* Logo area */
.auth-logo {
  text-align: center;
  margin-bottom: 28px;
}

.auth-logo img {
  height: 80px;
  margin: 0 auto 12px;
  display: block;
}

.auth-logo h1 {
  font-size: 28px;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0 0 4px;
  letter-spacing: -0.5px;
}

.auth-logo h1 span {
  color: var(--accent-green);
}

.auth-logo p {
  color: #D1D5DB;
  font-size: 14px;
  margin: 0;
}

/* Card */
.auth-card {
  background: rgba(31, 41, 55, 0.9);
  backdrop-filter: blur(4px);
  border: 1px solid #374151;
  border-radius: 12px;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
  overflow: hidden;
}

/* Tabs */
.auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  background: rgba(55, 65, 81, 0.5);
}

.auth-tab {
  padding: 12px 16px;
  font-size: 14px;
  font-weight: 500;
  color: #D1D5DB;
  background: transparent;
  border: none;
  cursor: pointer;
  transition: all 0.2s;
  text-align: center;
}

.auth-tab:hover {
  color: #fff;
}

.auth-tab.active {
  background: #16A34A;
  color: #fff;
}

/* Form */
.auth-form {
  padding: 24px;
}

.auth-form-title {
  font-size: 22px;
  font-weight: 600;
  color: #fff;
  text-align: center;
  margin: 0 0 4px;
}

.auth-form-desc {
  color: #D1D5DB;
  text-align: center;
  font-size: 14px;
  margin: 0 0 20px;
}

.auth-field {
  margin-bottom: 16px;
}

.auth-field label {
  display: block;
  color: #E5E7EB;
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 6px;
}

.auth-field input {
  width: 100%;
  padding: 10px 12px;
  background: rgba(55, 65, 81, 0.5);
  border: 1px solid #4B5563;
  border-radius: 6px;
  color: #fff;
  font-size: 14px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.2s;
  box-sizing: border-box;
}

.auth-field input::placeholder {
  color: #9CA3AF;
}

.auth-field input:focus {
  border-color: #10B981;
  box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.15);
}

.auth-field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.auth-field-password {
  position: relative;
}

.auth-field-password input {
  padding-right: 40px;
}

.auth-toggle-pw {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: #9CA3AF;
  cursor: pointer;
  padding: 4px;
  font-size: 18px;
  line-height: 1;
}

.auth-toggle-pw:hover {
  color: #E5E7EB;
}

/* Submit button */
.auth-submit {
  width: 100%;
  padding: 10px 16px;
  background: #16A34A;
  color: #fff;
  border: none;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 20px;
}

.auth-submit:hover {
  background: #15803D;
}

.auth-submit:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* Spinner */
.auth-spinner {
  width: 16px;
  height: 16px;
  border: 2px solid transparent;
  border-bottom-color: #fff;
  border-radius: 50%;
  animation: spin 1s linear infinite;
  display: inline-block;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Forgot password link */
.auth-forgot {
  background: none;
  border: none;
  color: #9CA3AF;
  font-size: 13px;
  cursor: pointer;
  padding: 0;
  margin-top: 12px;
  display: block;
  text-align: center;
  width: 100%;
  font-family: inherit;
}

.auth-forgot:hover {
  color: #E5E7EB;
}

/* Alert messages */
.auth-alert {
  padding: 12px 14px;
  border-radius: 6px;
  font-size: 13px;
  margin-bottom: 16px;
}

.auth-alert-error {
  background: rgba(127, 29, 29, 0.5);
  border: 1px solid #b91c1c;
  color: #fecaca;
}

.auth-alert-success {
  background: rgba(120, 53, 15, 0.5);
  border: 1px solid #d97706;
  color: #fef3c7;
}

.auth-alert-info {
  background: rgba(30, 58, 138, 0.3);
  border: 1px solid #3b82f6;
  color: #bfdbfe;
}

/* Validation hints */
.auth-validation {
  font-size: 12px;
  color: #fcd34d;
  margin-top: 4px;
}

.auth-validation.error {
  color: #f87171;
}

/* Back button */
.auth-back {
  background: none;
  border: 1px solid #4B5563;
  color: #D1D5DB;
  padding: 8px 16px;
  border-radius: 6px;
  font-size: 13px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 12px;
  width: 100%;
  justify-content: center;
  font-family: inherit;
  transition: background 0.2s;
}

.auth-back:hover {
  background: rgba(55, 65, 81, 0.5);
}

/* Footer */
.auth-footer {
  text-align: center;
  margin-top: 20px;
  color: #6B7280;
  font-size: 12px;
}

.auth-footer a {
  color: var(--accent-cyan);
  text-decoration: none;
}

/* Success state */
.auth-success {
  text-align: center;
  padding: 32px 24px;
}

.auth-success-icon {
  width: 64px;
  height: 64px;
  margin: 0 auto 16px;
  background: rgba(22, 163, 74, 0.2);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
}

.auth-success h3 {
  color: #fff;
  font-size: 20px;
  margin: 0 0 8px;
}

.auth-success p {
  color: #D1D5DB;
  font-size: 14px;
  margin: 0 0 4px;
}

.auth-success .text-muted {
  color: #9CA3AF;
  font-size: 12px;
}

/* ============================================
   User Profile in Sidebar
   ============================================ */

.sidebar-user-profile {
  display: flex;
  align-items: center;
  gap: 10px;
}

.user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 600;
  color: #fff;
  flex-shrink: 0;
}

.user-info {
  flex: 1;
  min-width: 0;
  overflow: hidden;
}

.user-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-email {
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Role badges — color per role (inspired by TraderLab) */
.role-badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-top: 2px;
}

.role-badge.admin {
  background: rgba(239, 68, 68, 0.2);
  color: #f87171;
  border: 1px solid rgba(239, 68, 68, 0.3);
}

.role-badge.manager {
  background: rgba(14, 165, 233, 0.2);
  color: #38bdf8;
  border: 1px solid rgba(14, 165, 233, 0.3);
}

.role-badge.supervisor {
  background: rgba(168, 85, 247, 0.2);
  color: #c084fc;
  border: 1px solid rgba(168, 85, 247, 0.3);
}

.role-badge.trader_gestor {
  background: rgba(16, 185, 129, 0.2);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.role-badge.trader_aluno {
  background: rgba(16, 185, 129, 0.15);
  color: #6ee7b7;
  border: 1px solid rgba(16, 185, 129, 0.2);
}

.role-badge.investidor {
  background: rgba(168, 85, 247, 0.15);
  color: #d8b4fe;
  border: 1px solid rgba(168, 85, 247, 0.2);
}

/* Logout button */
.btn-logout {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  font-size: 16px;
  line-height: 1;
  flex-shrink: 0;
  transition: color 0.2s;
}

.btn-logout:hover {
  color: #f87171;
}

/* Icon button (edit, delete, etc.) */
.btn-icon {
  background: none;
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  cursor: pointer;
  padding: 6px;
  border-radius: 6px;
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
}

.btn-icon:hover {
  color: var(--accent-cyan);
  border-color: var(--accent-cyan);
  background: rgba(14, 165, 233, 0.1);
}

/* Select input (for modals) */
.auth-select {
  width: 100%;
  padding: 10px 12px;
  background: rgba(55, 65, 81, 0.5);
  border: 1px solid #4B5563;
  border-radius: 6px;
  color: #fff;
  font-size: 14px;
  font-family: inherit;
  outline: none;
  cursor: pointer;
  appearance: auto;
}

.auth-select:focus {
  border-color: #10B981;
}

/* ============================================
   Modal
   ============================================ */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(2px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  width: 100%;
  max-width: 520px;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 24px;
  border-bottom: 1px solid var(--border-color);
}

.modal-header h3 {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0;
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 24px;
  cursor: pointer;
  padding: 0;
  line-height: 1;
}

.modal-close:hover {
  color: var(--text-primary);
}

.modal-body {
  padding: 24px;
}

/* Modal scrollbar */
.modal-card::-webkit-scrollbar { width: 4px; }
.modal-card::-webkit-scrollbar-track { background: transparent; }
.modal-card::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 4px;
}
