/* ================================================================
   BLACKSMS — Enterprise Design System v2.0
   Premium SaaS UI | Clean · Modern · Professional
   ================================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

/* ================================================================
   RESET & BASE
   ================================================================ */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 15px;
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

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

a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }
button { cursor: pointer; border: none; background: none; font-family: inherit; }
input, textarea, select { font-family: inherit; }
ul { list-style: none; }

/* ================================================================
   DESIGN TOKENS
   ================================================================ */
:root {
  /* Brand */
  --accent:        #E50914;
  --accent-hover:  #C5000B;
  --accent-light:  #FFF1F2;
  --accent-border: rgba(229, 9, 20, 0.2);

  /* Sidebar */
  --sidebar-bg:           #111111;
  --sidebar-border:       rgba(255,255,255,0.06);
  --sidebar-text:         #9CA3AF;
  --sidebar-text-hover:   #F3F4F6;
  --sidebar-active-bg:    rgba(229,9,20,0.12);
  --sidebar-active-text:  #E50914;
  --sidebar-hover-bg:     rgba(255,255,255,0.05);
  --sidebar-w:            240px;
  --sidebar-group-color:  #4B5563;

  /* App Shell */
  --header-h: 52px;

  /* Backgrounds */
  --bg:        #F7F8FA;
  --surface:   #FFFFFF;
  --surface-2: #F9FAFB;

  /* Text */
  --text-primary:   #111827;
  --text-secondary: #4B5563;
  --text-muted:     #6B7280;

  /* Borders */
  --border:       #E5E7EB;
  --border-light: #F3F4F6;

  /* Status */
  --success:        #16A34A;
  --success-light:  #F0FDF4;
  --success-border: #BBF7D0;
  --warning:        #F59E0B;
  --warning-light:  #FFFBEB;
  --warning-border: #FDE68A;
  --danger:         #DC2626;
  --danger-light:   #FEF2F2;
  --danger-border:  #FECACA;
  --info:           #2563EB;
  --info-light:     #EFF6FF;
  --info-border:    #BFDBFE;

  /* Radius */
  --radius-xs: 4px;
  --radius-sm: 6px;
  --radius:    8px;
  --radius-lg: 12px;
  --radius-xl: 16px;

  /* Shadows */
  --shadow-xs: 0 1px 2px rgba(0,0,0,0.05);
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.06);
  --shadow:    0 1px 8px rgba(0,0,0,0.08);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.10);

  /* Transitions */
  --transition: 0.15s ease;
  --transition-md: 0.25s ease;
}

/* Dark Theme Tokens Override & Comprehensive Dark Mode Rules */
[data-theme="dark"] {
  --bg:        #0B0F17;
  --surface:   #131924;
  --surface-2: #1A2232;

  --text-primary:   #F9FAFB;
  --text-secondary: #9CA3AF;
  --text-muted:     #6B7280;

  --border:       #232D3F;
  --border-light: #1E293B;

  --accent-light:  rgba(229, 9, 20, 0.15);
  --accent-border: rgba(229, 9, 20, 0.35);

  --success-light:  rgba(22, 163, 74, 0.18);
  --success-border: rgba(22, 163, 74, 0.35);
  --danger-light:   rgba(220, 38, 38, 0.18);
  --danger-border:  rgba(220, 38, 38, 0.35);
  --warning-light:  rgba(245, 158, 11, 0.18);
  --warning-border: rgba(245, 158, 11, 0.35);
  --info-light:     rgba(37, 99, 235, 0.18);
  --info-border:    rgba(37, 99, 235, 0.35);

  --shadow-xs: 0 1px 2px rgba(0,0,0,0.4);
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.5);
  --shadow:    0 2px 10px rgba(0,0,0,0.6);
  --shadow-md: 0 4px 20px rgba(0,0,0,0.7);
}

/* Force Dark Mode element styles */
[data-theme="dark"] body {
  background: var(--bg) !important;
  color: var(--text-primary) !important;
}

[data-theme="dark"] .card,
[data-theme="dark"] .stat-card,
[data-theme="dark"] .kpi-card,
[data-theme="dark"] .rate-card,
[data-theme="dark"] .account-grid,
[data-theme="dark"] .contact-option,
[data-theme="dark"] .contact-summary {
  background: var(--surface) !important;
  border-color: var(--border) !important;
  color: var(--text-primary) !important;
}

[data-theme="dark"] .card-header {
  border-bottom-color: var(--border) !important;
  color: var(--text-primary) !important;
}

[data-theme="dark"] .form-input,
[data-theme="dark"] .form-select,
[data-theme="dark"] .form-textarea,
[data-theme="dark"] .form-control,
[data-theme="dark"] input[type="text"],
[data-theme="dark"] input[type="email"],
[data-theme="dark"] input[type="number"],
[data-theme="dark"] input[type="tel"],
[data-theme="dark"] input[type="password"],
[data-theme="dark"] select,
[data-theme="dark"] textarea {
  background: var(--surface-2) !important;
  color: var(--text-primary) !important;
  border-color: var(--border) !important;
}

[data-theme="dark"] select option {
  background: #131924 !important;
  color: #F9FAFB !important;
}

[data-theme="dark"] table,
[data-theme="dark"] .table-wrap {
  background: var(--surface) !important;
  border-color: var(--border) !important;
}

[data-theme="dark"] thead tr,
[data-theme="dark"] th {
  background: var(--surface-2) !important;
  color: var(--text-secondary) !important;
  border-bottom-color: var(--border) !important;
}

[data-theme="dark"] td {
  color: var(--text-primary) !important;
  border-color: var(--border-light) !important;
}

[data-theme="dark"] tbody tr:hover {
  background: var(--surface-2) !important;
}

/* Alert Boxes text contrast */
[data-theme="dark"] .alert-success { background: var(--success-light) !important; color: #4ADE80 !important; border-color: var(--success-border) !important; }
[data-theme="dark"] .alert-error,
[data-theme="dark"] .alert-danger  { background: var(--danger-light) !important; color: #FCA5A5 !important; border-color: var(--danger-border) !important; }
[data-theme="dark"] .alert-info    { background: var(--info-light) !important; color: #93C5FD !important; border-color: var(--info-border) !important; }
[data-theme="dark"] .alert-warn,
[data-theme="dark"] .alert-warning { background: var(--warning-light) !important; color: #FDE047 !important; border-color: var(--warning-border) !important; }

/* Badges text contrast */
[data-theme="dark"] .badge-green,
[data-theme="dark"] .badge-success { background: rgba(22, 163, 74, 0.2) !important; color: #4ADE80 !important; }
[data-theme="dark"] .badge-red,
[data-theme="dark"] .badge-danger  { background: rgba(220, 38, 38, 0.2) !important; color: #FCA5A5 !important; }
[data-theme="dark"] .badge-blue,
[data-theme="dark"] .badge-info    { background: rgba(37, 99, 235, 0.2) !important; color: #93C5FD !important; }
[data-theme="dark"] .badge-amber,
[data-theme="dark"] .badge-warning { background: rgba(245, 158, 11, 0.2) !important; color: #FDE047 !important; }
[data-theme="dark"] .badge-purple  { background: rgba(147, 51, 234, 0.2) !important; color: #C084FC !important; }
[data-theme="dark"] .badge-gray    { background: var(--surface-2) !important; color: var(--text-secondary) !important; border: 1px solid var(--border) !important; }

/* Buttons in Dark Mode */
[data-theme="dark"] .btn-secondary,
[data-theme="dark"] .btn-gray {
  background: var(--surface-2) !important;
  color: var(--text-primary) !important;
  border: 1px solid var(--border) !important;
}

[data-theme="dark"] .btn-secondary:hover,
[data-theme="dark"] .btn-gray:hover {
  background: var(--border) !important;
}

/* Modals & Overlays */
[data-theme="dark"] #tgModal {
  background: var(--surface) !important;
  color: var(--text-primary) !important;
}

[data-theme="dark"] #tgModal .tg-step-text {
  color: var(--text-secondary) !important;
}

/* Rate Card Icons background adjustment */
[data-theme="dark"] .rate-card-icon {
  opacity: 0.9;
}

/* Page titles and text overrides */
[data-theme="dark"] .page-title,
[data-theme="dark"] h1, [data-theme="dark"] h2, [data-theme="dark"] h3,
[data-theme="dark"] h4, [data-theme="dark"] h5, [data-theme="dark"] h6 {
  color: var(--text-primary) !important;
}

[data-theme="dark"] .page-subtitle,
[data-theme="dark"] .rate-name,
[data-theme="dark"] .kpi-label,
[data-theme="dark"] .info-field .label {
  color: var(--text-secondary) !important;
}

/* Icon circles in Dark Mode: Dark surface instead of bright white */
[data-theme="dark"] .rate-card-icon,
[data-theme="dark"] .qa-list-icon,
[data-theme="dark"] .stat-icon {
  background: var(--surface-2) !important;
  border: 1px solid var(--border) !important;
}

/* Balance chip & sidebar buttons in Dark Mode */
[data-theme="dark"] .balance-chip {
  background: rgba(229, 9, 20, 0.18) !important;
  border: 1px solid rgba(229, 9, 20, 0.35) !important;
  color: #F9FAFB !important;
}

[data-theme="dark"] .sidebar-tg {
  background: rgba(0, 136, 204, 0.15) !important;
  color: #38bdf8 !important;
  border: 1px solid rgba(0, 136, 204, 0.3) !important;
}

[data-theme="dark"] .sidebar-hire {
  background: var(--accent-light) !important;
  color: var(--accent) !important;
  border: 1px solid var(--accent-border) !important;
}

/* Mobile Bottom Navigation Dock */
.mobile-bottom-dock {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 60px;
  background: var(--surface);
  border-top: 1px solid var(--border);
  z-index: 999;
  justify-content: space-around;
  align-items: center;
  box-shadow: 0 -4px 16px rgba(0,0,0,0.08);
}

.dock-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  color: var(--text-muted);
  font-size: .6875rem;
  font-weight: 500;
  text-decoration: none;
  flex: 1;
  height: 100%;
  transition: color var(--transition);
}

.dock-item i {
  font-size: 1.1rem;
}

.dock-item:hover, .dock-item.active {
  color: var(--accent);
}

@media (max-width: 768px) {
  .mobile-bottom-dock {
    display: flex;
  }
  .page-content {
    padding-bottom: 76px !important;
  }
}

/* Toast Notification Component */
.copy-toast,
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: #0F172A;
  color: #F8FAFC;
  padding: 12px 20px;
  border-radius: var(--radius-lg);
  font-size: .875rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 10px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.3);
  border: 1px solid rgba(255,255,255,0.12);
  z-index: 999999;
  opacity: 0;
  transform: translateY(12px) scale(0.96);
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  pointer-events: none;
}

[data-theme="dark"] .copy-toast,
[data-theme="dark"] .toast {
  background: #1E293B;
  color: #F8FAFC;
  border-color: #334155;
}

.copy-toast.show,
.toast.show {
  opacity: 1;
  transform: translateY(0) scale(1);
}

.copy-toast-icon,
.toast i {
  color: #22C55E;
  font-size: 1.1rem;
}

/* ================================================================
   LAYOUT UTILITIES
   ================================================================ */
.container {
  width: 100%;
  max-width: 1140px;
  margin: 0 auto;
  padding: 0 20px;
}

.flex         { display: flex; }
.flex-col     { flex-direction: column; }
.items-center { align-items: center; }
.items-start  { align-items: flex-start; }
.justify-between { justify-content: space-between; }
.justify-center  { justify-content: center; }
.justify-end     { justify-content: flex-end; }
.flex-1       { flex: 1; }
.flex-wrap    { flex-wrap: wrap; }
.gap-2  { gap: 8px; }
.gap-3  { gap: 12px; }
.gap-4  { gap: 16px; }
.gap-6  { gap: 24px; }
.gap-8  { gap: 32px; }
.grid   { display: grid; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.w-full { width: 100%; }
.min-h-screen { min-height: 100vh; }
.hidden       { display: none !important; }
.relative     { position: relative; }
.sticky       { position: sticky; }

/* ================================================================
   SPACING UTILITIES
   ================================================================ */
.mt-1 { margin-top: 4px }   .mb-1 { margin-bottom: 4px }
.mt-2 { margin-top: 8px }   .mb-2 { margin-bottom: 8px }
.mt-3 { margin-top: 12px }  .mb-3 { margin-bottom: 12px }
.mt-4 { margin-top: 16px }  .mb-4 { margin-bottom: 16px }
.mt-5 { margin-top: 20px }  .mb-5 { margin-bottom: 20px }
.mt-6 { margin-top: 24px }  .mb-6 { margin-bottom: 24px }
.mt-8 { margin-top: 32px }  .mb-8 { margin-bottom: 32px }
.mr-1 { margin-right: 4px }  .ml-1 { margin-left: 4px }
.mr-2 { margin-right: 8px }  .ml-2 { margin-left: 8px }
.mr-3 { margin-right: 12px } .ml-3 { margin-left: 12px }

.p-3  { padding: 12px }
.p-4  { padding: 16px }
.p-5  { padding: 20px }
.p-6  { padding: 24px }
.px-3 { padding-left: 12px; padding-right: 12px }
.px-4 { padding-left: 16px; padding-right: 16px }
.px-5 { padding-left: 20px; padding-right: 20px }
.py-2 { padding-top: 8px;  padding-bottom: 8px }
.py-3 { padding-top: 12px; padding-bottom: 12px }
.py-4 { padding-top: 16px; padding-bottom: 16px }

.space-y-2 > * + * { margin-top: 8px }
.space-y-3 > * + * { margin-top: 12px }
.space-y-4 > * + * { margin-top: 16px }
.space-y-6 > * + * { margin-top: 24px }

/* ================================================================
   TYPOGRAPHY UTILITIES
   ================================================================ */
.text-xs   { font-size: .75rem }
.text-sm   { font-size: .875rem }
.text-base { font-size: 1rem }
.text-lg   { font-size: 1.125rem }
.text-xl   { font-size: 1.25rem }
.text-2xl  { font-size: 1.5rem }
.text-3xl  { font-size: 1.875rem }

.font-normal  { font-weight: 400 }
.font-medium  { font-weight: 500 }
.font-semibold { font-weight: 600 }
.font-bold    { font-weight: 700 }

.text-center { text-align: center }
.text-right  { text-align: right }
.uppercase   { text-transform: uppercase }
.tracking-wide { letter-spacing: .05em }
.leading-tight { line-height: 1.25 }
.break-all   { word-break: break-all }
.font-mono   { font-family: 'Courier New', Consolas, monospace }
.truncate    { overflow: hidden; text-overflow: ellipsis; white-space: nowrap }

/* Color utilities */
.text-primary   { color: var(--text-primary) }
.text-secondary { color: var(--text-secondary) }
.text-muted     { color: var(--text-muted) }
.text-white     { color: #fff }
.text-accent    { color: var(--accent) }
.text-success   { color: var(--success) }
.text-warning   { color: var(--warning) }
.text-danger    { color: var(--danger) }
.text-info      { color: var(--info) }

/* ================================================================
   CARDS
   ================================================================ */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-light);
  font-weight: 600;
  font-size: .9375rem;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-primary);
}

.card-header i {
  color: var(--accent);
  font-size: .9rem;
}

.card-body {
  padding: 20px;
}

.card-footer {
  padding: 12px 20px;
  border-top: 1px solid var(--border-light);
  background: var(--surface-2);
  font-size: .825rem;
  color: var(--text-secondary);
}

/* ================================================================
   KPI / STAT CARDS
   ================================================================ */
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  display: flex;
  align-items: flex-start;
  gap: 14px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--transition);
}

.stat-card:hover {
  box-shadow: var(--shadow);
}

.stat-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  flex-shrink: 0;
}

/* Keep legacy icon color classes */
.stat-icon.red    { background: var(--accent-light); color: var(--accent); }
.stat-icon.green  { background: var(--success-light); color: var(--success); }
.stat-icon.blue   { background: var(--info-light); color: var(--info); }
.stat-icon.amber  { background: var(--warning-light); color: var(--warning); }

.stat-label {
  font-size: .75rem;
  font-weight: 500;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: .04em;
  margin-bottom: 4px;
}

.stat-value {
  font-size: 1.375rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.2;
}

.stat-sub {
  font-size: .75rem;
  color: var(--text-muted);
  margin-top: 4px;
}

/* ================================================================
   INFO FIELDS
   ================================================================ */
.info-field {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
}

.info-field .label {
  font-size: .72rem;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .04em;
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  gap: 5px;
}

.info-field .label i {
  color: var(--text-muted);
  font-size: .65rem;
}

.info-field .value {
  font-size: .9375rem;
  font-weight: 600;
  color: var(--text-primary);
}

/* ================================================================
   BUTTONS
   ================================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 10px 18px;
  border-radius: var(--radius);
  font-size: .875rem;
  font-weight: 600;
  transition: all var(--transition);
  cursor: pointer;
  border: none;
  text-decoration: none;
  white-space: nowrap;
  line-height: 1;
}

.btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.btn-brand,
.btn-primary {
  background: var(--accent);
  color: #fff;
}
.btn-brand:hover,
.btn-primary:hover {
  background: var(--accent-hover);
  color: #fff;
}

.btn-outline,
.btn-secondary {
  background: transparent;
  color: var(--text-primary);
  border: 1.5px solid var(--border);
}
.btn-outline:hover,
.btn-secondary:hover {
  background: var(--surface-2);
  border-color: #D1D5DB;
}

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

.btn-success {
  background: var(--success);
  color: #fff;
}
.btn-success:hover { background: #15803D; color: #fff; }

.btn-danger {
  background: var(--danger);
  color: #fff;
}
.btn-danger:hover { background: #B91C1C; color: #fff; }

.btn-dark {
  background: #111827;
  color: #fff;
}
.btn-dark:hover { background: #1F2937; color: #fff; }

.btn-sm  { padding: 7px 13px; font-size: .8125rem; }
.btn-lg  { padding: 13px 24px; font-size: .9375rem; }
.btn-full { width: 100%; }

.btn-icon {
  padding: 9px;
  border-radius: var(--radius);
  aspect-ratio: 1;
}

/* Legacy aliases */
.btn-outline-brand {
  border: 1.5px solid var(--accent);
  color: var(--accent);
  background: transparent;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 9px 17px;
  border-radius: var(--radius);
  font-size: .875rem;
  font-weight: 600;
  transition: all var(--transition);
  cursor: pointer;
  text-decoration: none;
}
.btn-outline-brand:hover { background: var(--accent); color: #fff; }

.btn-gray { background: #F3F4F6; color: #374151; }
.btn-gray:hover { background: #E5E7EB; }

/* ================================================================
   FORMS
   ================================================================ */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-label {
  font-size: .875rem;
  font-weight: 500;
  color: var(--text-primary);
}

.form-label .required {
  color: var(--accent);
  margin-left: 2px;
}

.form-input,
.form-select,
.form-textarea,
.form-control {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  font-size: .875rem;
  font-weight: 400;
  color: var(--text-primary);
  background: var(--surface);
  transition: border-color var(--transition), box-shadow var(--transition);
  line-height: 1.5;
  height: 42px;
}

.form-textarea,
textarea.form-control {
  height: auto;
  min-height: 100px;
  resize: vertical;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus,
.form-control:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(229,9,20,0.08);
}

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

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

.form-help {
  font-size: .75rem;
  color: var(--text-muted);
}

.form-error {
  font-size: .75rem;
  color: var(--danger);
  display: flex;
  align-items: center;
  gap: 4px;
}

/* Input with icon */
.input-wrap { position: relative; }
.input-wrap .form-input { padding-left: 38px; }

.input-wrap .input-icon {
  position: absolute;
  left: 13px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
  font-size: .875rem;
}

.input-wrap .input-toggle {
  position: absolute;
  right: 13px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  cursor: pointer;
  font-size: .875rem;
}

/* Legacy alias */
.form-input-no-icon { padding-left: 14px !important; }

/* ================================================================
   ALERTS
   ================================================================ */
.alert {
  padding: 13px 16px;
  border-radius: var(--radius);
  font-size: .875rem;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  border: 1px solid;
}

.alert i { margin-top: 1px; flex-shrink: 0; }

.alert-success {
  background: var(--success-light);
  color: #166534;
  border-color: var(--success-border);
}

.alert-error,
.alert-danger {
  background: var(--danger-light);
  color: #991B1B;
  border-color: var(--danger-border);
}

.alert-info {
  background: var(--info-light);
  color: #1E40AF;
  border-color: var(--info-border);
}

.alert-warn,
.alert-warning {
  background: var(--warning-light);
  color: #92400E;
  border-color: var(--warning-border);
}

/* ================================================================
   BADGES
   ================================================================ */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: 20px;
  font-size: .72rem;
  font-weight: 600;
  white-space: nowrap;
}

.badge-green,
.badge-success { background: var(--success-light); color: #166534; }
.badge-red,
.badge-danger  { background: var(--danger-light);  color: #991B1B; }
.badge-blue,
.badge-info    { background: var(--info-light);    color: #1E40AF; }
.badge-amber,
.badge-warning { background: var(--warning-light); color: #92400E; }
.badge-gray    { background: #F3F4F6; color: #374151; }
.badge-accent  { background: var(--accent-light);  color: var(--accent); }

/* Status dot */
.status-dot {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: .825rem;
  font-weight: 500;
}

.status-dot::before {
  content: '';
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
  display: inline-block;
  flex-shrink: 0;
}

.status-dot.success { color: var(--success); }
.status-dot.danger  { color: var(--danger); }
.status-dot.warning { color: var(--warning); }
.status-dot.info    { color: var(--info); }
.status-dot.gray    { color: var(--text-muted); }

/* ================================================================
   TABLES
   ================================================================ */
.table-wrap,
.table-responsive {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
}

table,
.table {
  width: 100%;
  border-collapse: collapse;
  min-width: 560px;
  font-size: .875rem;
}

thead tr {
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
}

th {
  padding: 11px 16px;
  text-align: left;
  font-size: .72rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: .06em;
  white-space: nowrap;
}

td {
  padding: 12px 16px;
  font-size: .875rem;
  color: var(--text-primary);
  border-top: 1px solid var(--border-light);
  white-space: nowrap;
}

tbody tr:hover { background: var(--surface-2); }

tbody tr:last-child td { border-bottom: none; }

/* ================================================================
   PAGINATION
   ================================================================ */
.pagination {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  justify-content: center;
  margin-top: 20px;
}

.page-btn {
  padding: 7px 13px;
  border-radius: var(--radius);
  font-size: .8125rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
  background: var(--surface);
  color: var(--text-secondary);
  border: 1px solid var(--border);
}

.page-btn:hover { background: var(--surface-2); }
.page-btn.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.page-btn:disabled { opacity: .4; cursor: default; }

/* ================================================================
   TOAST NOTIFICATIONS
   ================================================================ */
.toast {
  position: fixed;
  top: 72px;
  right: 20px;
  min-width: 280px;
  max-width: 380px;
  background: #1F2937;
  color: #fff;
  padding: 13px 16px;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  font-size: .875rem;
  opacity: 0;
  transform: translateX(20px);
  transition: opacity var(--transition-md), transform var(--transition-md);
  z-index: 9999;
  pointer-events: none;
  display: flex;
  align-items: center;
  gap: 10px;
}

.toast.show {
  opacity: 1;
  transform: translateX(0);
  pointer-events: auto;
}

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

/* ================================================================
   MODAL
   ================================================================ */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 900;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  transition: opacity var(--transition-md);
}

.modal-backdrop.open { opacity: 1; }

.modal {
  background: var(--surface);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-md);
  width: 100%;
  max-width: 480px;
  overflow: hidden;
  transform: translateY(16px);
  transition: transform var(--transition-md);
}

.modal-backdrop.open .modal { transform: translateY(0); }

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

.modal-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
}

.modal-close {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
  font-size: .875rem;
}

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

.modal-body { padding: 20px; }

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

/* ================================================================
   CODE BLOCK
   ================================================================ */
.code-block {
  background: #1E1E2E;
  color: #CDD6F4;
  padding: 16px 18px;
  border-radius: var(--radius);
  overflow-x: auto;
  font-size: .8rem;
  line-height: 1.7;
  font-family: 'Courier New', Consolas, monospace;
  position: relative;
}

.code-block pre { white-space: pre-wrap; word-break: break-all; }

.code-copy-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  background: rgba(255,255,255,0.1);
  border: none;
  color: #aaa;
  padding: 5px 9px;
  border-radius: var(--radius-sm);
  font-size: .72rem;
  cursor: pointer;
  transition: background var(--transition);
}

.code-copy-btn:hover { background: rgba(255,255,255,0.2); color: #fff; }

/* ================================================================
   SKELETON LOADERS
   ================================================================ */
@keyframes shimmer {
  0%   { background-position: -400px 0; }
  100% { background-position: 400px 0; }
}

.skeleton {
  background: linear-gradient(90deg, #F3F4F6 25%, #E5E7EB 50%, #F3F4F6 75%);
  background-size: 800px 100%;
  animation: shimmer 1.5s infinite linear;
  border-radius: var(--radius-sm);
}

.skeleton-text  { height: 14px; margin-bottom: 8px; }
.skeleton-title { height: 20px; width: 50%; margin-bottom: 12px; }
.skeleton-card  { height: 80px; border-radius: var(--radius-lg); }

/* ================================================================
   EMPTY STATES
   ================================================================ */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px 24px;
  text-align: center;
  color: var(--text-muted);
}

.empty-state-icon {
  font-size: 2.5rem;
  margin-bottom: 16px;
  opacity: 0.4;
}

.empty-state-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.empty-state-text {
  font-size: .875rem;
  color: var(--text-muted);
  max-width: 320px;
  line-height: 1.6;
  margin-bottom: 20px;
}

/* ================================================================
   QUICK ACTION CARDS
   ================================================================ */
.qa-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.qa-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-radius: var(--radius);
  background: var(--surface-2);
  border: 1px solid var(--border);
  text-decoration: none;
  color: var(--text-primary);
  font-size: .8125rem;
  font-weight: 500;
  transition: all var(--transition);
  cursor: pointer;
}

.qa-card:hover {
  background: var(--surface);
  border-color: #D1D5DB;
  box-shadow: var(--shadow-sm);
  color: var(--text-primary);
}

.qa-icon {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .875rem;
  flex-shrink: 0;
}

.qa-label {
  font-size: .8125rem;
  font-weight: 500;
  color: var(--text-primary);
  line-height: 1.2;
}

.qa-card-hire {
  border-style: dashed !important;
  border-color: var(--accent-border) !important;
  background: var(--accent-light) !important;
}

.qa-card-hire .qa-label { color: var(--accent); }

/* ================================================================
   PAGE HEADER
   ================================================================ */
.page-header {
  margin-bottom: 24px;
}

.page-title {
  font-size: 1.375rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.3;
}

.page-subtitle {
  font-size: .875rem;
  color: var(--text-secondary);
  margin-top: 4px;
}

.page-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 24px;
}

/* ================================================================
   SECTION HEADER
   ================================================================ */
.section-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 12px;
}

/* ================================================================
   ACTION LINK (legacy)
   ================================================================ */
.action-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-radius: var(--radius);
  font-weight: 500;
  font-size: .875rem;
  transition: all var(--transition);
  background: var(--surface-2);
  color: var(--text-primary);
  text-decoration: none;
  border: 1px solid var(--border);
}

.action-link:hover {
  background: var(--accent-light);
  color: var(--accent);
  border-color: var(--accent-border);
}

.action-link i { color: var(--accent); width: 18px; text-align: center; }
.action-link .chevron { margin-left: auto; font-size: .7rem; color: var(--text-muted); }

/* ================================================================
   SPONSOR BANNER
   ================================================================ */
.sponsor-banner {
  margin-top: 24px;
  text-align: center;
}

.sponsor-banner .sponsor-label {
  font-size: .68rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .08em;
  margin-bottom: 8px;
}

.sponsor-banner a { display: inline-block; max-width: 100%; }

.sponsor-banner img {
  width: 100%;
  max-width: 468px;
  height: auto;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  display: block;
  margin: 0 auto;
  opacity: .9;
  transition: opacity var(--transition);
}

.sponsor-banner img:hover { opacity: 1; }

/* ================================================================
   APP SHELL — SIDEBAR
   ================================================================ */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  z-index: 1010;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transform: translateX(-100%);
  transition: transform var(--transition-md);
}

.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 2px; }

.sidebar.open { transform: translateX(0); }

/* Brand */
.sidebar-brand {
  padding: 0 16px;
  height: var(--header-h);
  display: flex;
  align-items: center;
  border-bottom: 1px solid var(--sidebar-border);
  flex-shrink: 0;
}

.sidebar-logo-link {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
}

.sidebar-logo-link img {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  object-fit: cover;
  border: 1.5px solid var(--accent);
  flex-shrink: 0;
}

.sidebar-brand-text {
  font-size: 1rem;
  font-weight: 800;
  letter-spacing: -0.01em;
}

.brand-black { color: var(--text-primary); }
.sidebar .brand-black,
.auth-top .brand-black { color: #FFFFFF !important; }
.brand-red   { color: var(--accent); }

/* User info in sidebar */
.sidebar-user {
  padding: 14px 16px;
  border-bottom: 1px solid var(--sidebar-border);
  flex-shrink: 0;
}

.sidebar-user .name {
  color: #F3F4F6;
  font-weight: 600;
  font-size: .875rem;
  margin-bottom: 2px;
}

.sidebar-user .bal {
  color: var(--accent);
  font-size: .75rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 4px;
}

/* Nav */
.sidebar-nav {
  flex: 1;
  min-height: 0;
  padding: 8px 10px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

/* Nav Groups */
.sidebar-group {
  margin-bottom: 4px;
}

.sidebar-group-label {
  display: block;
  font-size: .65rem;
  font-weight: 600;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--sidebar-group-color);
  padding: 12px 6px 6px;
}

/* Nav Items */
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: var(--radius);
  color: var(--sidebar-text);
  font-size: .8375rem;
  font-weight: 500;
  text-decoration: none;
  transition: all var(--transition);
  margin-bottom: 1px;
}

.nav-item i {
  width: 18px;
  text-align: center;
  font-size: .875rem;
  flex-shrink: 0;
}

.nav-item:hover {
  background: var(--sidebar-hover-bg);
  color: var(--sidebar-text-hover);
}

.nav-item.active {
  background: var(--sidebar-active-bg);
  color: var(--sidebar-active-text);
}

.nav-item.active i {
  color: var(--sidebar-active-text);
}

.nav-divider {
  border: none;
  border-top: 1px solid var(--sidebar-border);
  margin: 8px 0;
}

.nav-item.danger { color: #F87171; }
.nav-item.danger:hover { background: rgba(220,38,38,0.12); color: #F87171; }

/* Sidebar Bottom */
.sidebar-bottom {
  padding: 10px 10px calc(14px + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid var(--sidebar-border);
  flex-shrink: 0;
  background: var(--sidebar-bg);
  margin-top: auto;
}

.sidebar-tg {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  background: rgba(0, 136, 204, 0.12);
  border: 1px solid rgba(0, 136, 204, 0.22);
  border-radius: var(--radius);
  color: #5bc8f5;
  font-size: .8125rem;
  font-weight: 500;
  text-decoration: none;
  transition: background var(--transition);
  margin-bottom: 4px;
}

.sidebar-tg:hover { background: rgba(0,136,204,0.2); }

.sidebar-hire {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: var(--radius);
  color: var(--sidebar-text);
  font-size: .8125rem;
  font-weight: 500;
  text-decoration: none;
  transition: all var(--transition);
  margin-bottom: 4px;
}

.sidebar-hire:hover {
  background: var(--sidebar-hover-bg);
  color: var(--sidebar-text-hover);
}

/* Close button (mobile only) */
.close-btn {
  color: #6B7280;
  font-size: 1rem;
  cursor: pointer;
  padding: 6px;
  border-radius: var(--radius-sm);
  transition: all var(--transition);
  margin-left: auto;
}

.close-btn:hover { background: rgba(255,255,255,0.08); color: #fff; }

/* ================================================================
   APP SHELL — HEADER
   ================================================================ */
.app-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 200;
  background: var(--sidebar-bg);
  height: var(--header-h);
  display: flex;
  align-items: center;
  padding: 0 16px;
  justify-content: space-between;
  box-shadow: 0 1px 0 var(--sidebar-border);
}

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

.app-logo img {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  object-fit: cover;
  border: 1.5px solid var(--accent);
}

.app-logo span {
  font-weight: 800;
  font-size: 1rem;
  letter-spacing: -0.01em;
}

.app-header-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* Balance chip */
.balance-chip {
  background: rgba(229,9,20,0.12);
  border: 1px solid rgba(229,9,20,0.22);
  color: #fff;
  padding: 5px 11px;
  border-radius: 20px;
  font-size: .775rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 5px;
}

.balance-chip i { color: var(--accent); font-size: .75rem; }

/* Menu/hamburger button */
.menu-btn {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius);
  color: #9CA3AF;
  font-size: 1.1rem;
  transition: all var(--transition);
  cursor: pointer;
}

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

/* ================================================================
   APP SHELL — OVERLAY
   ================================================================ */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.55);
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-md);
}

.overlay.open {
  opacity: 1;
  pointer-events: all;
}

/* ================================================================
   APP SHELL — MAIN CONTENT
   ================================================================ */
.main-content {
  padding-top: calc(var(--header-h) + 8px);
  padding-bottom: 48px;
  min-height: 100vh;
}

.page-content {
  padding: 24px 20px;
  max-width: 1140px;
  margin: 0 auto;
}

/* ================================================================
   APP SHELL — FOOTER
   ================================================================ */
.app-footer {
  position: relative;
  margin-top: 32px;
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 14px 20px;
  text-align: center;
  font-size: .775rem;
  color: var(--text-muted);
}

/* ================================================================
   DESKTOP — PERSISTENT SIDEBAR
   ================================================================ */
@media (min-width: 768px) {

  /* Sidebar always visible */
  .sidebar {
    transform: translateX(0) !important;
    border-right: 1px solid var(--sidebar-border);
    box-shadow: none;
  }

  /* No overlay on desktop */
  .overlay { display: none !important; }

  /* Hide hamburger / close / Telegram header btn */
  #menu-btn,
  .close-btn,
  .tg-header-btn { display: none !important; }

  /* Header: white top-bar, starts after sidebar */
  .app-header {
    left: var(--sidebar-w);
    height: var(--header-h);
    background: #fff;
    border-bottom: 1px solid var(--border);
    box-shadow: none;
    padding: 0 20px;
  }

  /* Hide logo from top header — sidebar has branding */
  .app-header .app-logo { display: none !important; }

  /* Header right side on white background */
  .app-header .app-header-right { margin-left: auto; gap: 12px; }

  /* Balance chip: light on white header */
  .app-header .balance-chip {
    background: var(--accent-light);
    border: 1px solid var(--accent-border);
    color: var(--text-primary);
    font-weight: 700;
  }

  .app-header .balance-chip i { color: var(--accent); }

  /* Sidebar brand: same height as header */
  .sidebar-brand {
    height: var(--header-h);
    border-bottom: 1px solid var(--sidebar-border);
  }

  /* Main content: offset for sidebar + header */
  .main-content {
    margin-left: var(--sidebar-w);
    padding-top: calc(var(--header-h) + 8px);
  }
}

/* ================================================================
   MOBILE — RESPONSIVE
   ================================================================ */
@media (max-width: 767px) {
  .page-content { padding: 16px 14px; }

  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }

  .qa-grid { grid-template-columns: repeat(2, 1fr); }

  .main-content { padding-top: calc(var(--header-h) + 8px); }

  .page-title { font-size: 1.125rem; }

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

  .card-header { padding: 14px 16px; }
  .card-body   { padding: 16px; }
  .modal { max-width: 100%; }
}

@media (max-width: 480px) {
  .qa-grid { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .btn-full-xs { width: 100%; }
}

/* ================================================================
   STATS GRID (Dashboard)
   ================================================================ */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 20px;
}

@media (max-width: 900px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
}

/* Rates mini row */
.rates-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}

.rate-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 9px 14px;
  font-size: .8125rem;
}

.rate-chip .rate-label {
  color: var(--text-secondary);
  font-weight: 500;
}

.rate-chip .rate-val {
  font-weight: 700;
  color: var(--text-primary);
}

.rate-chip i {
  color: var(--text-muted);
  font-size: .8rem;
}

/* ================================================================
   DASHBOARD TWO-COLUMN
   ================================================================ */
.dash-two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  align-items: stretch;
}

.dash-two-col .card {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.dash-two-col .card-body {
  flex: 1;
}

@media (max-width: 768px) {
  .dash-two-col { grid-template-columns: 1fr; }
}

/* Account Grid */
.account-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

@media (max-width: 480px) {
  .account-grid { grid-template-columns: 1fr; gap: 8px; }
}

/* ================================================================
   MISC HELPERS
   ================================================================ */

/* Divider */
hr.divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 20px 0;
}

/* Copy button feedback */
.copy-btn {
  font-size: .75rem;
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition);
  display: inline-flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
}

.copy-btn:hover { background: var(--surface); }
.copy-btn.copied { background: var(--success-light); color: var(--success); border-color: var(--success-border); }

/* Loading spinner */
.spinner {
  width: 18px;
  height: 18px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .6s linear infinite;
  display: inline-block;
}

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

/* Overlay for full page loading */
.page-loading {
  position: fixed;
  inset: 0;
  background: rgba(255,255,255,.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9000;
}

/* Masked secret */
.secret-mask {
  font-family: 'Courier New', monospace;
  font-size: .875rem;
  letter-spacing: .12em;
  color: var(--text-muted);
}

/* Tab System */
.tabs {
  display: flex;
  gap: 2px;
  border-bottom: 2px solid var(--border);
  margin-bottom: 20px;
}

.tab-btn {
  padding: 9px 16px;
  font-size: .875rem;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: all var(--transition);
  white-space: nowrap;
}

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

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

.tab-pane { display: none; }
.tab-pane.active { display: block; }

/* Tooltip */
[data-tooltip] { position: relative; }
[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  background: #1F2937;
  color: #fff;
  padding: 5px 9px;
  border-radius: var(--radius-sm);
  font-size: .72rem;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity var(--transition);
  z-index: 100;
}
[data-tooltip]:hover::after { opacity: 1; }

/* ================================================================
   LEGACY COMPAT — keep old class names working
   ================================================================ */

/* Old brand colors mapped to new tokens */
:root {
  --brand: var(--accent);
  --brand-dark: var(--accent-hover);
  --brand-light: var(--accent-light);
  --dark: #111111;
  --dark2: #1F2937;
  --dark3: #374151;
  --gray: var(--text-secondary);
  --gray-light: var(--surface-2);
  --white: #ffffff;
  --error: var(--danger);
  --warn: var(--warning);
  --radius: 8px;
  --shadow-md: var(--shadow-md);
  --transition: 0.15s ease;
}

/* nav#navbar for public pages (header.php) */
nav#navbar {
  background: #fff !important;
  border-bottom: 2px solid var(--border) !important;
  box-shadow: var(--shadow-sm) !important;
}

nav#navbar a.nav-link { color:#333; text-decoration:none; padding:10px 0; display:inline-flex; align-items:center; gap:4px; }
nav#navbar a.nav-link:hover { color: var(--accent); }
nav#navbar span.nav-underline { background: var(--accent); }

/* Public nav dropdown */
.nav-dropdown { position:relative; display:inline-block; padding:10px 0; }
.nav-dropdown-menu {
  position:absolute; top:100%; left:50%;
  transform: translateX(-50%) translateY(8px);
  background:#fff !important;
  min-width:220px;
  box-shadow: var(--shadow-md) !important;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  opacity:0; visibility:hidden;
  transition: all var(--transition);
  z-index:99999 !important;
  padding:6px 0;
}
.nav-dropdown:hover .nav-dropdown-menu {
  opacity:1; visibility:visible;
  transform: translateX(-50%) translateY(0);
}
.nav-dropdown-item {
  display:flex; align-items:center; gap:8px;
  padding:10px 16px; color:#333;
  font-size:.875rem; font-weight:500;
  text-decoration:none; transition:all var(--transition);
}
.nav-dropdown-item:hover { background: var(--accent-light); color: var(--accent); }

/* Public mobile menu */
#mobile-menu { background:#fff; max-height:80vh; overflow-y:auto; }
#mobile-menu a { color:#333; text-decoration:none; }
#mobile-menu a:hover { color: var(--accent); background: var(--accent-light); }
#mobile-menu i { color: var(--accent) !important; }
#mobile-menu-button { color:#333; }

.mobile-dropdown-header {
  display:flex; align-items:center; justify-content:space-between;
  width:100%; padding:12px 16px; font-weight:500; color:#333;
  border-radius: var(--radius); cursor:pointer;
  transition: background var(--transition);
}
.mobile-dropdown-header:hover { background: var(--accent-light); }
.mobile-submenu { display:none; padding-left:16px; margin-top:4px; margin-bottom:8px; border-left:2px solid var(--border); }
.mobile-submenu.open { display:block; }
.mobile-submenu-item { display:flex; align-items:center; gap:8px; padding:10px 16px; font-size:.9rem; color:#555; border-radius: var(--radius-sm); text-decoration:none; }
.mobile-submenu-item:hover { color:var(--accent); background:var(--accent-light); }

/* Public site header buttons */
.bsms-topbar { background: #141414; }
.btn-brand { background:var(--accent); color:#fff; border-radius:var(--radius); padding:8px 18px; font-weight:600; text-decoration:none; display:inline-flex; align-items:center; gap:6px; transition:background var(--transition); font-size:.875rem; }
.btn-brand:hover { background:var(--accent-hover); color:#fff; }
.btn-brand { background:var(--accent); color:#fff; border-radius:var(--radius); padding:8px 18px; font-weight:600; text-decoration:none; display:inline-flex; align-items:center; gap:6px; transition:background var(--transition); font-size:.875rem; }
.btn-brand:hover { background:var(--accent-hover); color:#fff; }
.btn-outline-brand { border:1.5px solid var(--accent); color:var(--accent); border-radius:var(--radius); padding:7px 17px; font-weight:600; text-decoration:none; display:inline-flex; align-items:center; gap:6px; transition:all var(--transition); font-size:.875rem; }
.btn-outline-brand:hover { background:var(--accent); color:#fff; }

/* ================================================================
   AUTH PAGES — Login / Register / Verify
   ================================================================ */
:root {
  --auth-primary-red: #E50914;
}

.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #F7F8FA;
  padding: 20px;
}

.auth-card {
  width: 100%;
  max-width: 960px;
  background: #fff;
  border-radius: 20px;
  box-shadow: 0 4px 40px rgba(0,0,0,0.10);
  overflow: hidden;
  display: flex;
  min-height: 560px;
}

/* Left panel */
.auth-top {
  flex: 0 0 380px;
  background: #111111;
  padding: 40px 36px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  position: relative;
  overflow: hidden;
}

.auth-top::before {
  content: '';
  position: absolute;
  top: -80px;
  right: -80px;
  width: 260px;
  height: 260px;
  border-radius: 50%;
  background: rgba(229,9,20,0.08);
  pointer-events: none;
}

.auth-top::after {
  content: '';
  position: absolute;
  bottom: -60px;
  left: -60px;
  width: 200px;
  height: 200px;
  border-radius: 50%;
  background: rgba(229,9,20,0.06);
  pointer-events: none;
}

.auth-logo-wrap {
  margin-bottom: 18px;
}

.auth-logo {
  width: 52px;
  height: 52px;
  border-radius: 12px;
  object-fit: cover;
  border: 2px solid var(--accent);
}

.auth-title {
  font-size: 2rem;
  font-weight: 800;
  color: #fff;
  letter-spacing: -0.02em;
  margin-bottom: 6px;
}

.auth-title .brand-red { color: var(--accent); }

.auth-sub {
  font-size: .8125rem;
  color: #6B7280;
  font-weight: 500;
  margin-bottom: 32px;
  text-transform: uppercase;
  letter-spacing: .08em;
}

/* Feature items in left panel */
.auth-features {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.auth-feature-item {
  display: flex;
  align-items: flex-start;
  gap: 13px;
}

.auth-feature-icon {
  width: 36px;
  height: 36px;
  background: rgba(229,9,20,0.12);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent);
  font-size: .875rem;
  flex-shrink: 0;
  margin-top: 2px;
}

.auth-feature-item strong {
  display: block;
  color: #F3F4F6;
  font-size: .875rem;
  font-weight: 600;
  margin-bottom: 2px;
}

.auth-feature-sub {
  color: #6B7280;
  font-size: .775rem;
  line-height: 1.5;
}

/* Right panel */
.auth-right {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  overflow-y: auto;
}

.auth-body {
  padding: 44px 40px 32px;
  flex: 1;
}

.auth-form-header {
  margin-bottom: 28px;
}

.auth-form-header h2 {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 6px;
}

.auth-form-header p {
  font-size: .875rem;
  color: var(--text-secondary);
}

.auth-footer {
  padding: 16px 40px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  font-size: .775rem;
  color: var(--text-muted);
}

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

.auth-footer-links a {
  color: var(--text-muted);
  font-size: .775rem;
  text-decoration: none;
  transition: color var(--transition);
}

.auth-footer-links a:hover { color: var(--accent); }

/* OTP verify / step screens */
.auth-otp-box {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin: 20px 0;
}

.auth-otp-box input {
  width: 48px;
  height: 52px;
  text-align: center;
  font-size: 1.25rem;
  font-weight: 700;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
  color: var(--text-primary);
  transition: border-color var(--transition);
}

.auth-otp-box input:focus {
  border-color: var(--accent);
  outline: none;
  background: #fff;
}

/* Step indicator */
.auth-steps {
  display: flex;
  gap: 6px;
  margin-bottom: 28px;
  justify-content: center;
}

.auth-step-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--border);
  transition: all var(--transition);
}

.auth-step-dot.active {
  background: var(--accent);
  width: 24px;
  border-radius: 4px;
}

/* Responsive auth */
@media (max-width: 768px) {
  .auth-card {
    flex-direction: column;
    max-width: 100%;
    min-height: auto;
  }

  .auth-top {
    flex: none;
    padding: 28px 24px;
  }

  .auth-features { display: none; }

  .auth-body { padding: 28px 24px 20px; }

  .auth-footer { padding: 14px 24px; }
}

@media (max-width: 480px) {
  .auth-page {
    padding: 0;
    align-items: stretch;
    background: #fff;
  }

  .auth-card {
    border-radius: 0;
    box-shadow: none;
    min-height: 100vh;
    max-width: 100%;
    width: 100%;
  }

  .auth-top {
    padding: 24px 20px 20px;
  }

  .auth-body {
    padding: 24px 20px 16px;
  }

  .auth-footer {
    padding: 12px 20px;
  }

  .auth-otp-box input {
    width: 42px;
    height: 46px;
    font-size: 1rem;
  }
}