/* ============================================
   Agilitrade - Dark Fintech Theme
   Agilitest Sandbox 2
   ============================================ */

/* --- CSS Variables (Kraken Pro inspired) --- */
:root {
  --bg-primary: #0e0b16;
  --bg-secondary: #141020;
  --bg-tertiary: #0a0812;
  --bg-card: #1b1529;
  --card-bg: #1b1529;
  --bg-card-hover: #241d35;
  --bg-input: #130f1f;
  --bg-sidebar: #0c0914;

  --text-primary: #e2dff0;
  --text-secondary: #9088a6;
  --text-muted: #5e5578;
  --text-white: #ffffff;

  --color-primary: #7434f3;
  --color-primary-hover: #5b1fdb;
  --color-success: #00c781;
  --color-success-dim: #00c78133;
  --color-danger: #f6465d;
  --color-danger-dim: #f6465d33;
  --color-warning: #f0b90b;
  --color-warning-dim: #f0b90b33;
  --color-accent: #b494e6;
  --color-info: #00b8d4;

  --border-color: #2a2440;
  --border-light: #1e1833;

  --sidebar-width: 240px;
  --sidebar-collapsed: 64px;
  --topbar-height: 72px;

  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;

  --shadow-sm: 0 1px 3px rgba(0,0,0,0.4);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.5);
  --shadow-lg: 0 8px 24px rgba(0,0,0,0.6);

  --font-ui: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', 'Consolas', monospace;

  --transition-fast: 150ms ease;
  --transition-normal: 300ms ease;
  --transition-slow: 500ms ease;

  --glass-bg: rgba(27, 21, 41, 0.6);
  --glass-blur: 10px;
}

/* --- Light Theme --- */
body.light-theme {
  --bg-primary: #f0f2f5;
  --bg-secondary: #ffffff;
  --bg-tertiary: #f0eef5;
  --bg-card: #ffffff;
  --card-bg: #ffffff;
  --bg-card-hover: #f5f3fa;
  --bg-input: #f7f7fa;
  --bg-sidebar: #1b1529;

  --text-primary: #1a1a2e;
  --text-secondary: #5c5a6f;
  --text-muted: #9290a3;
  --text-white: #1a1a2e;

  --color-primary: #7434f3;
  --color-primary-hover: #5b1fdb;
  --color-success: #0fa968;
  --color-success-dim: #0fa96822;
  --color-danger: #e63950;
  --color-danger-dim: #e6395022;
  --color-warning: #d9a200;
  --color-warning-dim: #d9a20022;
  --color-accent: #8b5fd4;
  --color-info: #0097b2;

  --border-color: #ddd8e8;
  --border-light: #ece8f4;

  --shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.1);
  --shadow-lg: 0 8px 24px rgba(0,0,0,0.12);

  --glass-bg: rgba(255, 255, 255, 0.7);
}

body.light-theme .topbar {
  background: #ffffff;
  border-bottom-color: #ddd8e8;
}

body.light-theme .stat-card,
body.light-theme .card {
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}

body.light-theme .search-box input {
  background: #f0eef5;
  border-color: #ddd8e8;
}

body.light-theme .search-box input::placeholder {
  color: #9290a3;
}

body.light-theme .topbar-btn {
  border-color: #ddd8e8;
  color: #5c5a6f;
}

body.light-theme .topbar-btn:hover {
  background: #f5f3fa;
  color: #1a1a2e;
}

body.light-theme .lang-toggle {
  border-color: #ddd8e8;
  color: #5c5a6f;
}

body.light-theme .lang-toggle:hover {
  border-color: #7434f3;
  color: #1a1a2e;
}

body.light-theme .user-dropdown {
  background: #ffffff;
  border-color: #ddd8e8;
  box-shadow: 0 8px 24px rgba(0,0,0,0.12);
}

body.light-theme .dropdown-item:hover {
  background: #f5f3fa;
}

body.light-theme .notification-panel {
  background: #ffffff;
  border-color: #ddd8e8;
}

body.light-theme .toast {
  background: #ffffff;
  border-color: #ddd8e8;
  color: #1a1a2e;
}

body.light-theme .modal-content {
  background: #ffffff;
  border-color: #ddd8e8;
}

body.light-theme .table th {
  background: #f0eef5;
  color: #1a1a2e;
}

body.light-theme .table td {
  border-color: #ece8f4;
}

body.light-theme .table tr:hover td {
  background: #f9f7ff;
}

body.light-theme .chart-container {
  background: #ffffff;
}

body.light-theme .badge {
  color: #1a1a2e;
}

body.light-theme .theme-toggle-btn {
  border-color: #ddd8e8;
  color: #5c5a6f;
}

body.light-theme .theme-toggle-btn:hover {
  background: #f5f3fa;
  color: #1a1a2e;
}

body.light-theme .skeleton {
  background: linear-gradient(90deg, #e8e5f0 25%, #f5f3fa 50%, #e8e5f0 75%);
  background-size: 200% 100%;
}

body.light-theme .insight-skeleton .skeleton-line,
body.light-theme .insight-skeleton .skeleton-block {
  background: #e0dced;
}

body.light-theme .news-iframe-skeleton .skeleton-line {
  background: #e0dced;
}

body.light-theme .form-input,
body.light-theme .form-select {
  background: #f7f7fa;
  border-color: #ddd8e8;
  color: #1a1a2e;
}

body.light-theme .form-label {
  color: #1a1a2e;
}

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

html {
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-ui);
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
}

a {
  color: var(--color-primary);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

/* --- Scrollbar --- */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: var(--bg-primary);
}
::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* ============================================
   Disclaimer Banner (always visible)
   ============================================ */
.disclaimer-banner {
  background: linear-gradient(90deg, #c97d1a, #d4972e);
  color: #fff;
  text-align: center;
  padding: 8px 16px;
  font-size: 0.82rem;
  font-weight: 500;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 10001;
  letter-spacing: 0.2px;
}

.disclaimer-banner strong {
  font-weight: 700;
}

.disclaimer-icon {
  margin-right: 6px;
}

/* Offset everything below the disclaimer */
body {
  padding-top: 34px;
}

/* ============================================
   Sidebar Credentials Info Box
   ============================================ */
.sidebar-credentials {
  margin: 8px;
  padding: 10px 12px;
  background: rgba(116, 52, 243, 0.08);
  border: 1px solid rgba(116, 52, 243, 0.2);
  border-radius: var(--radius-md);
  font-size: 0.75rem;
}

.credentials-title {
  font-weight: 600;
  color: var(--color-primary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-size: 0.65rem;
  margin-bottom: 4px;
}

.credentials-row {
  color: var(--text-secondary);
  margin-bottom: 2px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.credentials-label {
  color: var(--text-muted);
  font-size: 0.7rem;
}

.credentials-row code {
  background: rgba(255,255,255,0.06);
  padding: 1px 5px;
  border-radius: 3px;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--color-success);
}

.credentials-hint {
  color: var(--text-muted);
  font-size: 0.65rem;
  font-style: italic;
  margin-top: 2px;
}

.credentials-divider {
  height: 1px;
  background: rgba(116, 52, 243, 0.15);
  margin: 6px 0;
}

.sidebar.collapsed .sidebar-credentials {
  display: none;
}

/* ============================================
   Cookie Consent Overlay
   ============================================ */
.cookie-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 10002;
  backdrop-filter: blur(4px);
  animation: fadeIn 0.5s ease;
}

.cookie-banner {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  padding: 24px 32px;
  max-width: 600px;
  width: 100%;
}

.cookie-banner h3 {
  margin-bottom: 8px;
  color: var(--text-white);
}

.cookie-banner p {
  color: var(--text-secondary);
  font-size: 0.9rem;
  line-height: 1.5;
}

.cookie-options {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 16px 0;
}

.cookie-check {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 0.9rem;
}

.cookie-check input[type="checkbox"] {
  accent-color: var(--color-primary);
}

.cookie-actions {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-top: 16px;
}

.cookie-link {
  font-size: 0.85rem;
  margin-left: auto;
}

.cookie-details {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border-color);
  font-size: 0.85rem;
  color: var(--text-muted);
  line-height: 1.5;
}

.cookie-details p + p {
  margin-top: 8px;
}

/* ============================================
   Layout - App Shell
   ============================================ */
#app-shell {
  display: flex;
  min-height: 100vh;
}

/* --- Sidebar --- */
.sidebar {
  width: var(--sidebar-width);
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 34px;
  left: 0;
  bottom: 0;
  z-index: 100;
  transition: width var(--transition-normal);
}

.sidebar.collapsed {
  width: var(--sidebar-collapsed);
}

.sidebar.collapsed .sidebar-header {
  flex-direction: column;
  padding: 8px;
  gap: 4px;
}

.sidebar.collapsed .sidebar-header .logo-img {
  height: 22px;
}

.sidebar.collapsed .menu-label,
.sidebar.collapsed .logo-text,
.sidebar.collapsed .sidebar-footer .market-status .status-text,
.sidebar.collapsed .sidebar-version,
.sidebar.collapsed .sidebar-links,
.sidebar.collapsed .menu-badge,
.sidebar.collapsed .menu-section-title {
  display: none;
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px;
  border-bottom: 1px solid var(--border-color);
  min-height: 57px;
}

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

.logo-img {
  height: 28px;
  width: auto;
  filter: brightness(0) invert(1);
  flex-shrink: 0;
}

.logo-text {
  font-weight: 700;
  font-size: 1rem;
  color: var(--text-white);
  white-space: nowrap;
  letter-spacing: 1.5px;
}

.sidebar-toggle {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 1.2rem;
  padding: 4px;
  border-radius: var(--radius-sm);
}

.sidebar-toggle:hover {
  background: var(--bg-card);
  color: var(--text-primary);
}

.sidebar-menu {
  flex: 1;
  padding: 8px;
  overflow-y: auto;
}

.menu-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  transition: all var(--transition-fast);
  text-decoration: none;
  position: relative;
  margin-bottom: 2px;
}

.menu-item:hover {
  background: var(--bg-card);
  color: var(--text-primary);
  text-decoration: none;
}

.menu-item.active {
  background: linear-gradient(135deg, var(--color-primary), var(--color-primary-hover));
  color: var(--text-white, #fff);
  box-shadow: 0 2px 12px rgba(116, 52, 243, 0.35);
}

.menu-item-disabled {
  opacity: 0.4;
  pointer-events: auto;
  cursor: not-allowed;
}
.menu-item-disabled:hover {
  background: transparent;
  color: var(--text-muted);
}

.menu-icon {
  width: 20px;
  text-align: center;
  font-size: 1.1rem;
  flex-shrink: 0;
}

.menu-label {
  font-size: 0.9rem;
  font-weight: 500;
  white-space: nowrap;
}

.menu-badge {
  background: var(--color-danger);
  color: white;
  font-size: 0.7rem;
  padding: 2px 6px;
  border-radius: 10px;
  margin-left: auto;
  font-weight: 600;
}

.menu-divider {
  height: 1px;
  background: var(--border-color);
  margin: 8px 12px;
}

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

.market-status {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.8rem;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--color-success);
  animation: pulse 2s infinite;
}

.status-dot.closed {
  background: var(--color-danger);
  animation: none;
}

.status-text {
  color: var(--text-secondary);
}

.sidebar-links {
  margin: 8px 0 6px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.sidebar-link {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.75rem;
  color: var(--text-muted);
  text-decoration: none;
  padding: 2px 0;
  transition: color var(--transition-fast);
}
.sidebar-link:hover {
  color: var(--accent-color);
}

.sidebar-version {
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-top: 4px;
}

/* --- Main Content --- */
.main-content {
  flex: 1;
  margin-left: var(--sidebar-width);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  transition: margin-left var(--transition-normal);
}

.sidebar.collapsed ~ .main-content {
  margin-left: var(--sidebar-collapsed);
}

/* --- Top Bar --- */
.topbar {
  height: var(--topbar-height);
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 20px;
  position: sticky;
  top: 34px;
  z-index: 50;
}

.topbar-left {
  flex-shrink: 0;
  min-width: 0;
}

.breadcrumb {
  color: var(--text-secondary);
  font-size: 1.15rem;
}

.breadcrumb span {
  color: var(--text-primary);
  font-weight: 600;
}

.topbar-center {
  flex: 1;
  max-width: 450px;
}

.search-box {
  position: relative;
}

.search-box input {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  color: var(--text-primary);
  font-family: var(--font-ui);
  font-size: 1rem;
  transition: border-color var(--transition-fast);
}

.search-box input:focus {
  outline: none;
  border-color: var(--color-primary);
}

.search-box input::placeholder {
  color: var(--text-muted);
}

.search-results {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  margin-top: 4px;
  max-height: 300px;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  z-index: 200;
}

.search-result-item {
  padding: 10px 12px;
  cursor: pointer;
  border-bottom: 1px solid var(--border-light);
  transition: background var(--transition-fast);
}

.search-result-item:hover {
  background: var(--bg-card-hover);
}

.search-result-item.highlighted {
  background: var(--bg-secondary, #1e293b) !important;
  outline: 1px solid var(--primary, #3b82f6);
  outline-offset: -1px;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
  margin-left: auto;
}

.topbar-ticker {
  font-family: var(--font-mono);
  font-size: 0.95rem;
  color: var(--text-secondary);
  display: flex;
  gap: 16px;
  overflow: hidden;
  max-width: 380px;
}

.ticker-item {
  white-space: nowrap;
  display: flex;
  gap: 4px;
}

.ticker-up {
  color: var(--color-success);
}

.ticker-down {
  color: var(--color-danger);
}

/* Theme Toggle */
.theme-toggle-btn {
  background: none;
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.15rem;
  transition: all var(--transition-fast);
}

.theme-toggle-btn:hover {
  background: var(--bg-card);
  color: var(--text-primary);
  border-color: var(--color-primary);
}

/* Language Toggle */
.lang-toggle {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 6px 12px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  cursor: pointer;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-secondary);
  background: transparent;
  transition: all var(--transition-fast);
  user-select: none;
}
.lang-toggle:hover {
  border-color: var(--accent-color);
  color: var(--text-primary);
  background: rgba(108,92,231,0.08);
}
.lang-flag { font-size: 1rem; line-height: 1; }
.lang-code { letter-spacing: 0.5px; }

.topbar-btn {
  background: none;
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  transition: all var(--transition-fast);
}

.topbar-btn:hover {
  background: var(--bg-card);
  color: var(--text-primary);
}

.bell-icon {
  font-size: 1.1rem;
}

.notification-count {
  position: absolute;
  top: -4px;
  right: -4px;
  background: var(--color-danger);
  color: white;
  font-size: 0.65rem;
  min-width: 16px;
  height: 16px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
}

.user-menu {
  position: relative;
}

.user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--color-accent);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 0.8rem;
  font-weight: 600;
  color: white;
}

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

.dropdown-header {
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.dropdown-header strong {
  color: var(--text-white);
  font-size: 0.9rem;
}

.dropdown-header small {
  color: var(--text-muted);
  font-size: 0.8rem;
}

.dropdown-divider {
  height: 1px;
  background: var(--border-color);
}

.dropdown-item {
  display: block;
  padding: 10px 16px;
  color: var(--text-secondary);
  font-size: 0.85rem;
  transition: background var(--transition-fast);
  text-decoration: none;
}

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

.dropdown-item.danger {
  color: var(--color-danger);
}

/* --- Notification Panel --- */
.notification-panel {
  position: fixed;
  top: calc(var(--topbar-height) + 34px);
  right: 0;
  width: 360px;
  max-height: calc(100vh - var(--topbar-height) - 34px);
  background: var(--bg-card);
  border-left: 1px solid var(--border-color);
  box-shadow: var(--shadow-lg);
  z-index: 150;
  overflow-y: auto;
  animation: slideInRight 0.3s ease;
}

.notif-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px;
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  background: var(--bg-card);
}

.notif-header h3 {
  font-size: 1rem;
  color: var(--text-white);
}

.notif-header button {
  background: none;
  border: none;
  color: var(--color-primary);
  cursor: pointer;
  font-size: 0.8rem;
}

.notif-item {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-light);
  transition: background var(--transition-fast);
  cursor: pointer;
}

.notif-item:hover {
  background: var(--bg-card-hover);
}

.notif-item.unread {
  border-left: 3px solid var(--color-primary);
}

.notif-title {
  font-weight: 500;
  margin-bottom: 4px;
  font-size: 0.85rem;
}

.notif-message {
  color: var(--text-secondary);
  font-size: 0.8rem;
  line-height: 1.4;
}

.notif-time {
  color: var(--text-muted);
  font-size: 0.75rem;
  margin-top: 4px;
}

/* --- Page Content --- */
.page-content {
  flex: 1;
  padding: 20px;
  position: relative;
}

/* ============================================
   Loading & Skeletons
   ============================================ */
.loading-overlay {
  position: absolute;
  inset: 0;
  background: var(--bg-primary);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 10;
}

.loading-overlay p {
  color: var(--text-muted);
  margin-top: 12px;
  font-size: 0.9rem;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--border-color);
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

.skeleton-text {
  height: 14px;
  margin-bottom: 8px;
  width: 80%;
}

.skeleton-title {
  height: 20px;
  margin-bottom: 12px;
  width: 60%;
}

.skeleton-card {
  height: 120px;
  border-radius: var(--radius-md);
}

/* ============================================
   Components - Cards
   ============================================ */
.card {
  background: var(--glass-bg);
  backdrop-filter: blur(var(--glass-blur));
  -webkit-backdrop-filter: blur(var(--glass-blur));
  border: 1px solid rgba(116, 52, 243, 0.12);
  border-radius: var(--radius-lg);
  padding: 20px;
  transition: all 300ms cubic-bezier(0.4, 0, 0.2, 1);
}

.card:hover {
  border-color: rgba(116, 52, 243, 0.25);
  box-shadow: 0 8px 32px rgba(116, 52, 243, 0.08);
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.card-title {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-white);
}

.card-subtitle {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.card-body {
  position: relative;
}

/* Stat Cards */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 16px 20px;
}

.stat-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
}

.stat-value {
  font-family: var(--font-mono);
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--text-white);
}

.stat-change {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  margin-top: 4px;
  padding: 2px 6px;
  border-radius: var(--radius-sm);
}

.stat-change.up {
  color: var(--color-success);
  background: var(--color-success-dim);
}

.stat-change.down {
  color: var(--color-danger);
  background: var(--color-danger-dim);
}

/* ============================================
   Components - Tables
   ============================================ */
.table-container {
  overflow-x: auto;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

thead {
  background: var(--bg-secondary);
  position: sticky;
  top: 0;
}

th {
  padding: 12px 16px;
  text-align: left;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  font-size: 0.75rem;
  letter-spacing: 0.5px;
  border-bottom: 1px solid var(--border-color);
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
}

th:hover {
  color: var(--text-primary);
}

th .sort-icon {
  margin-left: 4px;
  opacity: 0.3;
}

th.sorted .sort-icon {
  opacity: 1;
}

td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-light);
  color: var(--text-secondary);
}

tr:hover td {
  background: var(--bg-card-hover);
}

tbody tr:nth-child(even) td {
  background: rgba(27, 21, 41, 0.3);
}

tbody tr:hover td {
  background: var(--bg-card-hover);
  transition: background 200ms cubic-bezier(0.4, 0, 0.2, 1);
}

tbody tr:hover td:first-child {
  border-left: 3px solid var(--color-primary);
}

.table-mono {
  font-family: var(--font-mono);
  font-size: 0.8rem;
}

.table-actions {
  display: flex;
  gap: 4px;
}

.table-pagination {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  border-top: 1px solid var(--border-color);
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.pagination-controls {
  display: flex;
  gap: 4px;
}

.pagination-btn {
  padding: 6px 10px;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.8rem;
}

.pagination-btn:hover {
  background: var(--bg-card-hover);
  color: var(--text-primary);
}

.pagination-btn.active {
  background: var(--color-primary);
  border-color: var(--color-primary);
  color: white;
}

.pagination-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

/* ============================================
   Components - Forms
   ============================================ */
.form-group {
  margin-bottom: 16px;
}

.form-label {
  display: block;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.form-input,
.form-select,
.form-textarea {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  color: var(--text-primary);
  font-family: var(--font-ui);
  font-size: 0.9rem;
  transition: border-color var(--transition-fast);
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(116, 52, 243, 0.15);
}

.form-input::placeholder {
  color: var(--text-muted);
}

.form-input.error {
  border-color: var(--color-danger);
}

.form-error {
  color: var(--color-danger);
  font-size: 0.8rem;
  margin-top: 4px;
}

.form-hint {
  color: var(--text-muted);
  font-size: 0.8rem;
  margin-top: 4px;
}

.form-select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%238a94a6' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
}

.form-textarea {
  min-height: 80px;
  resize: vertical;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.form-inline {
  display: flex;
  gap: 8px;
  align-items: flex-end;
}

/* Custom Range Slider */
.range-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  background: var(--bg-input);
  border-radius: 3px;
  outline: none;
}

.range-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--color-primary);
  cursor: pointer;
}

/* Toggle Switch */
.toggle-switch {
  position: relative;
  width: 44px;
  height: 24px;
  display: inline-block;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: absolute;
  inset: 0;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  cursor: pointer;
  transition: background var(--transition-fast);
}

.toggle-slider::before {
  content: '';
  position: absolute;
  height: 18px;
  width: 18px;
  left: 2px;
  bottom: 2px;
  background: white;
  border-radius: 50%;
  transition: transform var(--transition-fast);
}

.toggle-switch input:checked + .toggle-slider {
  background: var(--color-primary);
  border-color: var(--color-primary);
}

.toggle-switch input:checked + .toggle-slider::before {
  transform: translateX(20px);
}

/* ============================================
   Components - Buttons
   ============================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  font-family: var(--font-ui);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 200ms cubic-bezier(0.4, 0, 0.2, 1);
  white-space: nowrap;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--color-primary);
  color: white;
}

.btn-primary:hover:not(:disabled) {
  background: var(--color-primary-hover);
  transform: translateY(-2px);
  box-shadow: 0 4px 15px rgba(116, 52, 243, 0.4);
}

.btn-success {
  background: var(--color-success);
  color: white;
}

.btn-danger {
  background: var(--color-danger);
  color: white;
}

.btn-success:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 4px 15px rgba(0, 199, 129, 0.3);
}

.btn-danger:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 4px 15px rgba(246, 70, 93, 0.3);
}

.btn-warning {
  background: var(--color-warning);
  color: #000;
}

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

.btn-outline:hover:not(:disabled) {
  background: var(--bg-card);
  color: var(--text-primary);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
}

.btn-ghost:hover:not(:disabled) {
  background: var(--bg-card);
  color: var(--text-primary);
}

.btn-sm {
  padding: 6px 12px;
  font-size: 0.8rem;
}

.btn-lg {
  padding: 14px 28px;
  font-size: 1rem;
}

.btn-icon {
  width: 32px;
  height: 32px;
  padding: 0;
  border-radius: var(--radius-sm);
}

/* ============================================
   Components - Badges & Tags
   ============================================ */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 8px;
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.badge-success {
  background: var(--color-success-dim);
  color: var(--color-success);
}

.badge-danger {
  background: var(--color-danger-dim);
  color: var(--color-danger);
}

.badge-warning {
  background: var(--color-warning-dim);
  color: var(--color-warning);
}

.badge-info {
  background: rgba(0, 184, 212, 0.15);
  color: var(--color-info);
}

.badge-neutral {
  background: rgba(138, 148, 166, 0.15);
  color: var(--text-secondary);
}

/* ============================================
   Components - Modals
   ============================================ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10003;
  backdrop-filter: blur(4px);
  animation: fadeIn 0.2s ease;
}

.modal {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  max-width: 560px;
  width: 90%;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  animation: scaleIn 0.2s ease;
}

.modal-sm {
  max-width: 400px;
}

.modal-lg {
  max-width: 760px;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-color);
}

.modal-header h3 {
  font-size: 1rem;
  color: var(--text-white);
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1.2rem;
  padding: 4px;
}

.modal-body {
  padding: 20px;
  color: var(--text-secondary);
  line-height: 1.6;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 16px 20px;
  border-top: 1px solid var(--border-color);
}

/* ============================================
   Components - Toasts
   ============================================ */
.toast-container {
  position: fixed;
  top: calc(34px + 20px);
  right: 20px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  min-width: 300px;
  max-width: 420px;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: flex-start;
  gap: 10px;
  animation: slideInRight 0.3s ease;
  pointer-events: auto;
}

.toast.success {
  border-left: 3px solid var(--color-success);
}

.toast.error {
  border-left: 3px solid var(--color-danger);
}

.toast.warning {
  border-left: 3px solid var(--color-warning);
}

.toast.info {
  border-left: 3px solid var(--color-info);
}

.toast-icon {
  font-size: 1.1rem;
  flex-shrink: 0;
}

.toast-content {
  flex: 1;
}

.toast-title {
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--text-white);
  margin-bottom: 2px;
}

.toast-message {
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.toast-close {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1rem;
  flex-shrink: 0;
}

.toast-exit {
  animation: slideOutRight 0.3s ease forwards;
}

/* ============================================
   Components - Tabs
   ============================================ */
.tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border-color);
  margin-bottom: 20px;
}

.tab-btn {
  padding: 10px 20px;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-secondary);
  font-family: var(--font-ui);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.tab-btn:hover {
  color: var(--text-primary);
}

.tab-btn.active {
  color: var(--color-primary);
  border-bottom-color: var(--color-primary);
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

/* ============================================
   Components - Charts (placeholder area)
   ============================================ */
.chart-container {
  position: relative;
  height: 300px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  overflow: hidden;
}

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

/* ============================================
   Components - Misc
   ============================================ */

/* Empty state */
.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-muted);
}

.empty-state-icon {
  font-size: 3rem;
  margin-bottom: 12px;
  opacity: 0.5;
}

/* Tooltip */
.tooltip {
  position: relative;
}

.tooltip::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-fast);
  box-shadow: var(--shadow-md);
}

.tooltip:hover::after {
  opacity: 1;
}

/* Divider */
.divider {
  height: 1px;
  background: var(--border-color);
  margin: 20px 0;
}

/* Grid Layouts */
.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.grid-3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 16px;
}

.grid-4 {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
}

/* Flex utilities */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.flex-center { align-items: center; justify-content: center; }
.flex-between { justify-content: space-between; }
.gap-sm { gap: 8px; }
.gap-md { gap: 16px; }

/* Text utilities */
.text-success { color: var(--color-success) !important; }
.text-danger { color: var(--color-danger) !important; }
.text-warning { color: var(--color-warning) !important; }
.text-muted { color: var(--text-muted) !important; }
.text-mono { font-family: var(--font-mono); }
.text-right { text-align: right; }
.text-center { text-align: center; }
.font-bold { font-weight: 600; }

/* Spacing utilities */
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }

/* ============================================
   Login Screen
   ============================================ */
#login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-primary);
  position: relative;
  overflow: hidden;
}

.login-bg-effect {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 20% 50%, rgba(116, 52, 243, 0.08) 0%, transparent 50%),
    radial-gradient(circle at 80% 20%, rgba(180, 148, 230, 0.06) 0%, transparent 50%),
    radial-gradient(circle at 60% 80%, rgba(0, 199, 129, 0.04) 0%, transparent 50%);
}

.login-container {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 580px;
  padding: 0 20px;
}

.login-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xl);
  padding: 40px 40px;
  box-shadow: var(--shadow-lg);
}

.login-logo {
  text-align: center;
  margin-bottom: 32px;
}

.login-logo .logo-icon {
  font-size: 2.5rem;
  display: block;
  margin-bottom: 8px;
}

.login-logo h1 {
  font-size: 1.5rem;
  color: var(--text-white);
}

.login-logo p {
  color: var(--text-muted);
  font-size: 0.85rem;
  margin-top: 4px;
}

.login-form .form-group {
  margin-bottom: 20px;
}

.login-options {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
  font-size: 0.85rem;
}

.login-remember {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text-secondary);
}

.login-forgot {
  color: var(--color-primary);
  font-size: 0.85rem;
}

.login-submit {
  width: 100%;
  padding: 12px;
  font-size: 1rem;
}

.login-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 24px 0;
  color: var(--text-muted);
  font-size: 0.8rem;
}

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

/* 2FA Section */
.twofa-section {
  text-align: center;
}

.twofa-inputs {
  display: flex;
  gap: 8px;
  justify-content: center;
  margin: 20px 0;
}

.twofa-input {
  width: 48px;
  height: 56px;
  text-align: center;
  font-family: var(--font-mono);
  font-size: 1.5rem;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-white);
}

.twofa-input:focus {
  outline: none;
  border-color: var(--color-primary);
}

.twofa-timer {
  color: var(--text-muted);
  font-size: 0.85rem;
  margin-top: 12px;
}

.twofa-resend {
  color: var(--color-primary);
  cursor: pointer;
  background: none;
  border: none;
  font-size: 0.85rem;
}

/* Captcha */
.captcha-container {
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 12px;
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.captcha-checkbox {
  width: 24px;
  height: 24px;
  border: 2px solid var(--border-color);
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all var(--transition-fast);
}

.captcha-checkbox.checked {
  background: var(--color-primary);
  border-color: var(--color-primary);
}

.captcha-checkbox.checked::after {
  content: '✓';
  color: white;
  font-size: 0.8rem;
}

.captcha-label {
  flex: 1;
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.captcha-icon {
  font-size: 1.5rem;
}

/* ============================================
   Animations
   ============================================ */
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes fadeOut {
  from { opacity: 1; }
  to { opacity: 0; }
}

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

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

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

@keyframes scaleIn {
  from { transform: scale(0.95); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

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

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

@keyframes layoutShift {
  0%, 80% { margin-top: 0; }
  85% { margin-top: 40px; }
  90% { margin-top: 0; }
  100% { margin-top: 0; }
}

/* ============================================
   Responsive (trap: breakpoints shift layout)
   ============================================ */
@media (max-width: 1024px) {
  .grid-4 {
    grid-template-columns: repeat(2, 1fr);
  }
  .grid-3 {
    grid-template-columns: 1fr 1fr;
  }
  .topbar-ticker {
    display: none;
  }
}

@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
    z-index: 200;
  }
  .sidebar.mobile-open {
    transform: translateX(0);
  }
  .main-content {
    margin-left: 0 !important;
  }
  .grid-2, .grid-3, .grid-4 {
    grid-template-columns: 1fr;
  }
  .form-row {
    grid-template-columns: 1fr;
  }
  .stat-grid {
    grid-template-columns: 1fr;
  }
  .topbar-center {
    display: none;
  }
}

/* Coinbase-style period selector */
.chart-period-btn {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 200ms cubic-bezier(0.4, 0, 0.2, 1);
}

.chart-period-btn:hover {
  color: var(--text-primary);
  background: rgba(116, 52, 243, 0.1);
}

.chart-period-btn.active {
  color: var(--color-primary);
  background: rgba(116, 52, 243, 0.15);
}

/* Big price display */
#dashboard-big-price {
  padding: 0 4px;
}

/* ============================================
   Account Info (Clipboard Copy)
   ============================================ */
.account-info-grid {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.account-info-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 0.75rem;
  background: var(--bg-input, #130f1f);
  border-radius: 6px;
  border: 1px solid var(--border-color, #2a2440);
}

.account-info-label {
  font-size: 0.78rem;
  color: var(--text-muted, #5e5578);
  min-width: 110px;
  flex-shrink: 0;
  font-weight: 500;
}

.account-info-value {
  flex: 1;
  font-family: var(--font-mono, monospace);
  font-size: 0.85rem;
  color: var(--text-primary, #e2dff0);
  user-select: all;
}

.account-info-value.api-key-masked {
  color: var(--text-secondary, #9088a6);
}

.copy-btn {
  background: rgba(116, 52, 243, 0.15);
  border: 1px solid rgba(116, 52, 243, 0.3);
  color: var(--color-primary, #7434f3);
  padding: 0.35rem 0.5rem;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.15s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  position: relative;
}

.copy-btn:hover {
  background: rgba(116, 52, 243, 0.3);
  border-color: var(--color-primary, #7434f3);
}

.copy-tooltip {
  position: absolute;
  top: -28px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--color-success, #00c781);
  color: #fff;
  font-size: 0.7rem;
  padding: 3px 8px;
  border-radius: 4px;
  white-space: nowrap;
  pointer-events: none;
  animation: tooltipFadeIn 0.2s ease-out;
  z-index: 10;
}

@keyframes tooltipFadeIn {
  0% { opacity: 0; transform: translateX(-50%) translateY(4px); }
  100% { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* ============================================
   Admin Paginated Table
   ============================================ */
.admin-table-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.admin-search-input {
  flex: 1;
  max-width: 320px;
  padding: 0.55rem 0.85rem;
  background: var(--bg-input, #130f1f);
  border: 1px solid var(--border-color, #2a2440);
  border-radius: 6px;
  color: var(--text-primary, #e2dff0);
  font-size: 0.85rem;
  transition: border-color 0.2s;
}

.admin-search-input:focus {
  outline: none;
  border-color: var(--color-primary, #7434f3);
}

.admin-table-wrapper {
  overflow-x: auto;
  border-radius: 8px;
  border: 1px solid var(--border-color, #2a2440);
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.admin-table th {
  background: var(--bg-card, #1b1529);
  padding: 0.7rem 0.85rem;
  text-align: left;
  color: var(--text-secondary, #9088a6);
  font-weight: 600;
  cursor: pointer;
  user-select: none;
  border-bottom: 2px solid var(--border-color, #2a2440);
  white-space: nowrap;
  transition: color 0.15s;
}

.admin-table th:hover {
  color: var(--text-primary, #e2dff0);
}

.admin-table th .sort-icon {
  margin-left: 4px;
  opacity: 0.4;
  font-size: 0.7rem;
}

.admin-table th.sorted .sort-icon {
  opacity: 1;
  color: var(--color-primary, #7434f3);
}

.admin-table td {
  padding: 0.65rem 0.85rem;
  border-bottom: 1px solid var(--border-light, #1e1833);
  color: var(--text-primary, #e2dff0);
}

.admin-table tbody tr {
  transition: background 0.15s;
}

.admin-table tbody tr:hover {
  background: var(--bg-card-hover, #241d35);
}

.admin-table-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 0;
  gap: 1rem;
  flex-wrap: wrap;
  font-size: 0.82rem;
  color: var(--text-secondary, #9088a6);
}

.admin-rows-per-page {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.admin-rows-per-page select {
  background: var(--bg-input, #130f1f);
  border: 1px solid var(--border-color, #2a2440);
  border-radius: 4px;
  color: var(--text-primary, #e2dff0);
  padding: 0.3rem 0.5rem;
  font-size: 0.82rem;
}

.admin-pagination {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.admin-pagination button {
  background: var(--bg-card, #1b1529);
  border: 1px solid var(--border-color, #2a2440);
  color: var(--text-primary, #e2dff0);
  padding: 0.35rem 0.65rem;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.8rem;
  transition: all 0.15s;
  min-width: 32px;
}

.admin-pagination button:hover:not(:disabled) {
  background: rgba(116, 52, 243, 0.15);
  border-color: var(--color-primary, #7434f3);
}

.admin-pagination button.active {
  background: var(--color-primary, #7434f3);
  border-color: var(--color-primary, #7434f3);
  color: #fff;
}

.admin-pagination button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* ============================================
   WYSIWYG Editor
   ============================================ */
.wysiwyg-container {
  border: 1px solid var(--border-color, #2a2440);
  border-radius: 8px;
  overflow: hidden;
  margin-top: 0.5rem;
}

.wysiwyg-toolbar {
  display: flex;
  gap: 2px;
  padding: 0.4rem;
  background: var(--bg-card, #1b1529);
  border-bottom: 1px solid var(--border-color, #2a2440);
}

.wysiwyg-toolbar button {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-secondary, #9088a6);
  padding: 0.3rem 0.6rem;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.85rem;
  transition: all 0.15s;
  font-weight: 600;
}

.wysiwyg-toolbar button:hover {
  background: rgba(116, 52, 243, 0.15);
  color: var(--text-primary, #e2dff0);
}

.wysiwyg-toolbar button.active {
  background: rgba(116, 52, 243, 0.2);
  color: var(--color-primary, #7434f3);
  border-color: rgba(116, 52, 243, 0.3);
}

.wysiwyg-editor {
  min-height: 100px;
  padding: 0.75rem;
  color: var(--text-primary, #e2dff0);
  font-size: 0.9rem;
  line-height: 1.5;
  background: var(--bg-input, #130f1f);
  outline: none;
}

.wysiwyg-editor:focus {
  box-shadow: inset 0 0 0 1px var(--color-primary, #7434f3);
}

.wysiwyg-editor:empty::before {
  content: attr(data-placeholder);
  color: var(--text-muted, #5e5578);
}

/* ============================================
   Lazy Loading Insight Cards
   ============================================ */
.insights-section {
  margin-top: 2rem;
}

.insights-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1rem;
}

.insight-card {
  background: var(--bg-card, #1b1529);
  border-radius: var(--radius-lg, 12px);
  border: 1px solid var(--border-color, #2a2440);
  padding: 1.25rem;
  min-height: 180px;
  position: relative;
  overflow: hidden;
}

.insight-skeleton {
  animation: skeletonPulse 1.5s ease-in-out infinite;
}

.insight-skeleton .skeleton-line {
  height: 12px;
  background: var(--border-color, #2a2440);
  border-radius: 4px;
  margin-bottom: 0.75rem;
}

.insight-skeleton .skeleton-line:first-child {
  width: 60%;
  height: 16px;
}

.insight-skeleton .skeleton-line:nth-child(2) {
  width: 80%;
}

.insight-skeleton .skeleton-line:nth-child(3) {
  width: 45%;
}

.insight-skeleton .skeleton-block {
  height: 80px;
  background: var(--border-color, #2a2440);
  border-radius: 6px;
  margin-top: 0.5rem;
}

@keyframes skeletonPulse {
  0%, 100% { opacity: 0.4; }
  50% { opacity: 0.8; }
}

.insight-card .insight-content {
  animation: insightFadeIn 0.4s ease-out;
}

@keyframes insightFadeIn {
  0% { opacity: 0; transform: translateY(8px); }
  100% { opacity: 1; transform: translateY(0); }
}

.insight-card h4 {
  font-size: 0.85rem;
  color: var(--text-secondary, #9088a6);
  margin-bottom: 0.75rem;
  font-weight: 600;
}

/* CSS Pie chart */
.css-pie {
  width: 100px;
  height: 100px;
  border-radius: 50%;
  margin: 0 auto;
}

/* Mini bar chart */
.mini-bars {
  display: flex;
  align-items: flex-end;
  gap: 4px;
  height: 60px;
}

.mini-bars .bar {
  flex: 1;
  border-radius: 3px 3px 0 0;
  min-width: 12px;
  transition: height 0.3s ease;
}

/* Risk gauge */
.risk-gauge {
  width: 120px;
  height: 60px;
  margin: 0.5rem auto;
  position: relative;
  overflow: hidden;
}

.risk-gauge-arc {
  width: 120px;
  height: 120px;
  border-radius: 50%;
  border: 10px solid var(--border-color, #2a2440);
  clip-path: polygon(0 0, 100% 0, 100% 50%, 0 50%);
}

.risk-gauge-needle {
  position: absolute;
  bottom: 0;
  left: 50%;
  width: 2px;
  height: 50px;
  background: var(--color-danger, #f6465d);
  transform-origin: bottom center;
  transition: transform 0.5s ease;
}

.risk-gauge-label {
  text-align: center;
  font-size: 1.2rem;
  font-weight: 700;
  margin-top: 0.25rem;
}

/* ============================================
   History Context Menu
   ============================================ */
.history-context-menu {
  position: fixed;
  z-index: 10000;
  background: var(--bg-card, #1b1529);
  border: 1px solid var(--border-color, #2a2440);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.6);
  padding: 0.35rem 0;
  min-width: 200px;
  animation: ctxMenuFadeIn 0.15s ease-out;
}

@keyframes ctxMenuFadeIn {
  0% { opacity: 0; transform: scale(0.95); }
  100% { opacity: 1; transform: scale(1); }
}

.history-context-menu .ctx-item {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.55rem 0.85rem;
  color: var(--text-primary, #e2dff0);
  font-size: 0.82rem;
  cursor: pointer;
  transition: background 0.1s;
  white-space: nowrap;
}

.history-context-menu .ctx-item:hover {
  background: rgba(116, 52, 243, 0.15);
}

.history-context-menu .ctx-item .ctx-icon {
  width: 16px;
  text-align: center;
  opacity: 0.7;
}

.history-context-menu .ctx-separator {
  height: 1px;
  background: var(--border-color, #2a2440);
  margin: 0.25rem 0;
}

/* ============================================
   Skip to content (a11y)
   ============================================ */
.skip-to-content {
  position: absolute;
  top: -100px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--color-primary, #7434f3);
  color: #fff;
  padding: 0.75rem 1.5rem;
  border-radius: 0 0 8px 8px;
  z-index: 100000;
  font-size: 0.9rem;
  font-weight: 600;
  text-decoration: none;
  transition: top 0.2s ease;
}

.skip-to-content:focus {
  top: 0;
  outline: 2px solid #fff;
  outline-offset: 2px;
}

/* Focus visible for a11y */
:focus-visible {
  outline: 2px solid var(--color-primary, #7434f3);
  outline-offset: 2px;
}

/* ============================================
   Print (trap: different layout in print)
   ============================================ */
@media print {
  .sidebar, .topbar, .toast-container, .modal-overlay {
    display: none !important;
  }
  .main-content {
    margin-left: 0 !important;
  }
  body {
    background: white;
    color: black;
  }
}

/* ============================================
   Dashboard News iframe Widget
   ============================================ */
.dashboard-news-widget {
  margin-top: 1.5rem;
  padding: 1.25rem;
  background: var(--bg-card, #1b1529);
  border: 1px solid var(--border-color, #2a2440);
  border-radius: 12px;
}

.news-iframe-wrapper {
  border-radius: 8px;
  overflow: hidden;
  min-height: 100px;
}

.news-iframe-skeleton {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 16px;
}

.news-iframe-skeleton .skeleton-line {
  height: 12px;
  background: var(--bg-secondary, #1e293b);
  border-radius: 4px;
  animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse { 0%,100% { opacity: 0.4; } 50% { opacity: 0.8; } }

/* ============================================
   Dashboard Order Feed
   ============================================ */
.dashboard-order-feed {
  margin-top: 1.5rem;
  padding: 1.25rem;
  background: var(--bg-card, #1b1529);
  border: 1px solid var(--border-color, #2a2440);
  border-radius: 12px;
}

@keyframes fadeInOrder {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ============================================
   Profile Drag & Drop Upload
   ============================================ */
.drag-drop-zone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  border: 2px dashed var(--border-color, #2a2440);
  border-radius: 12px;
  background: var(--bg-secondary, #130f20);
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s, border-style 0.2s;
  min-height: 120px;
}

.drag-drop-zone:hover {
  border-color: var(--color-primary, #7434f3);
  background: rgba(116, 52, 243, 0.05);
}

/* TRAP: border changes from dashed to solid during drag */
.drag-drop-zone.drag-active {
  border-style: solid;
  border-color: var(--color-primary, #7434f3);
  background: rgba(116, 52, 243, 0.1);
}

.drag-drop-icon {
  font-size: 2rem;
  margin-bottom: 0.5rem;
}

.drag-drop-text {
  font-size: 0.85rem;
  color: var(--text-primary, #e0e0ff);
  font-weight: 500;
}

.drag-drop-hint {
  font-size: 0.72rem;
  color: var(--text-muted, #64748b);
  margin-top: 0.25rem;
}

.drag-drop-files {
  margin-top: 0.75rem;
}

.drag-drop-file-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.6rem 0.75rem;
  background: var(--bg-secondary, #130f20);
  border: 1px solid var(--border-color, #2a2440);
  border-radius: 8px;
  margin-bottom: 0.5rem;
  font-size: 0.8rem;
}

.file-item-info {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex: 1;
  overflow: hidden;
}

.file-item-name {
  color: var(--text-primary);
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.file-item-size {
  color: var(--text-muted);
  font-size: 0.7rem;
  flex-shrink: 0;
}

.file-item-preview {
  width: 32px;
  height: 32px;
  border-radius: 4px;
  object-fit: cover;
}

.file-item-progress {
  height: 4px;
  background: var(--border-color, #2a2440);
  border-radius: 2px;
  margin-top: 0.4rem;
  overflow: hidden;
}

.file-item-progress-bar {
  height: 100%;
  background: var(--color-primary, #7434f3);
  border-radius: 2px;
  transition: width 0.15s ease;
}

.file-item-remove {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1.1rem;
  padding: 0 0.25rem;
  margin-left: 0.5rem;
}

.file-item-remove:hover {
  color: var(--color-danger, #f6465d);
}
