/* ==========================================================================
   MASONS BORSASI — PREMIUM DARK EXCHANGE DESIGN SYSTEM
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@300;400;500;600;700;800&family=JetBrains+Mono:wght@400;500;600;700&display=swap');

:root {
  /* Design Tokens: Typography */
  --font-sans: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;

  /* Theme Backgrounds — Deep Obsidian */
  --bg-page: #08090d;
  --bg-body-gradient: radial-gradient(ellipse at 15% 5%, rgba(212, 175, 55, 0.06) 0%, transparent 50%),
                      radial-gradient(ellipse at 85% 90%, rgba(212, 175, 55, 0.03) 0%, transparent 50%),
                      #0c0d12;
                      
  --surface-card: #12141a;
  --surface-card-hover: #191b23;
  --surface-subtle: #0f1016;
  
  /* Primary & Brand Colors — Royal Gold */
  --brand-primary: #d4af37;
  --brand-primary-hover: #c9a226;
  --brand-gradient: linear-gradient(135deg, #d4af37 0%, #b8962e 50%, #a6872a 100%);
  --brand-gradient-hover: linear-gradient(135deg, #c9a226 0%, #a6872a 100%);
  --brand-light: rgba(212, 175, 55, 0.12);
  --brand-light-text: #e8c84a;
  
  /* Accent Colors */
  --accent-success: #22c55e;
  --accent-success-bg: rgba(34, 197, 94, 0.12);
  --accent-success-text: #4ade80;
  
  --accent-warning: #f59e0b;
  --accent-warning-bg: rgba(245, 158, 11, 0.12);
  --accent-warning-text: #fbbf24;
  
  --accent-danger: #ef4444;
  --accent-danger-bg: rgba(239, 68, 68, 0.12);
  --accent-danger-text: #f87171;
  
  --accent-info: #3b82f6;
  --accent-info-bg: rgba(59, 130, 246, 0.12);
  --accent-info-text: #60a5fa;
  
  /* Text Colors — Warm Neutrals */
  --text-main: #e8e6e1;
  --text-secondary: #a8a39b;
  --text-muted: #6b6760;
  --text-inverse: #0c0d12;
  
  /* Borders & Shadows */
  --border-color: rgba(255, 255, 255, 0.06);
  --border-focus: #d4af37;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 20px -2px rgba(0, 0, 0, 0.5), 0 2px 8px -2px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 20px 50px -10px rgba(0, 0, 0, 0.6), 0 10px 20px -5px rgba(0, 0, 0, 0.3);
  --shadow-glow: 0 0 25px rgba(212, 175, 55, 0.15);
  --shadow-gold: 0 4px 20px rgba(212, 175, 55, 0.2);
  
  /* Transitions */
  --transition-fast: 0.15s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-normal: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
  font-family: var(--font-sans);
  background: var(--bg-body-gradient);
  background-attachment: fixed;
  color: var(--text-main);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Helpers */
.hidden { display: none !important; }
.mt-auto { margin-top: auto; }
.p-4 { padding: 1.5rem; }

/* Main App Layout Grid */
#app-screen {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* ==========================================================================
   SIDEBAR COMPONENT
   ========================================================================== */
.sidebar {
  width: 280px;
  min-width: 280px;
  background: #090a0e;
  padding: 1.75rem 1.25rem;
  display: flex;
  flex-direction: column;
  border-right: 1px solid rgba(212, 175, 55, 0.08);
  box-shadow: 8px 0 40px rgba(0, 0, 0, 0.5);
  z-index: 20;
  position: relative;
}

/* Subtle gold line at top of sidebar */
.sidebar::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, #d4af37, transparent);
  opacity: 0.6;
}

.sidebar .logo {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding-bottom: 1.25rem;
  border-bottom: 1px solid rgba(212, 175, 55, 0.1);
}

.sidebar .logo h1 {
  color: #d4af37;
  font-size: 1.35rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  text-shadow: 0 0 20px rgba(212, 175, 55, 0.2);
}

.sidebar .logo span {
  background: var(--brand-gradient);
  color: #0c0d12;
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  padding: 0.25rem 0.55rem;
  border-radius: 6px;
  letter-spacing: 0.6px;
}

.user-info {
  margin: 1.25rem 0;
  padding: 0.9rem 1.1rem;
  background: rgba(212, 175, 55, 0.04);
  border-radius: 12px;
  border: 1px solid rgba(212, 175, 55, 0.08);
}

.user-info p {
  color: #e8e6e1;
  font-weight: 600;
  font-size: 0.92rem;
}

/* Sidebar Navigation Links */
nav { flex: 1; overflow-y: auto; margin-top: 0.5rem; }
nav ul { list-style: none; }
nav ul li { margin-bottom: 0.4rem; }

nav ul li a {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  padding: 0.75rem 1rem;
  color: #6b6760;
  text-decoration: none;
  border-radius: 10px;
  font-weight: 500;
  font-size: 0.88rem;
  transition: var(--transition-fast);
  position: relative;
}

nav ul li a:hover {
  background: rgba(212, 175, 55, 0.06);
  color: #d4af37;
  transform: translateX(3px);
}

nav ul li a.active {
  background: var(--brand-gradient);
  color: #0c0d12;
  font-weight: 700;
  box-shadow: var(--shadow-gold);
}

#logout-btn {
  background: rgba(239, 68, 68, 0.08);
  color: #f87171;
  border: 1px solid rgba(239, 68, 68, 0.15);
  padding: 0.75rem 1rem;
  border-radius: 10px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition-fast);
}

#logout-btn:hover {
  background: rgba(239, 68, 68, 0.15);
  color: #fca5a5;
}

/* ==========================================================================
   MAIN CONTENT AREA
   ========================================================================== */
.main-content {
  flex: 1;
  padding: 2.25rem 2.75rem;
  overflow-y: auto;
  background: var(--bg-body-gradient);
}

/* Custom scrollbar for dark theme */
.main-content::-webkit-scrollbar { width: 6px; }
.main-content::-webkit-scrollbar-track { background: transparent; }
.main-content::-webkit-scrollbar-thumb { background: rgba(212, 175, 55, 0.2); border-radius: 3px; }
.main-content::-webkit-scrollbar-thumb:hover { background: rgba(212, 175, 55, 0.35); }

.view-header {
  margin-bottom: 1.75rem;
}

.view-header h2 {
  font-size: 1.65rem;
  font-weight: 800;
  color: var(--text-main);
  letter-spacing: -0.03em;
}

.view-header p {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-top: 0.25rem;
}

/* Glass Panels & Content Cards */
.glass-panel {
  background: var(--surface-card);
  border-radius: 16px;
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-md);
  transition: var(--transition-normal);
}

.glass-panel:hover {
  box-shadow: var(--shadow-lg);
  border-color: rgba(212, 175, 55, 0.08);
}

/* ==========================================================================
   FORM CONTROLS & BUTTONS
   ========================================================================== */
.input-group {
  margin-bottom: 1.1rem;
  display: flex;
  flex-direction: column;
  width: 100%;
}

.input-group label {
  margin-bottom: 0.45rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
}

/* Fixed 44px Height Standard for Inputs and Dropdowns */
input[type="text"],
input[type="email"],
input[type="password"],
input[type="datetime-local"],
select {
  width: 100%;
  height: 44px !important;
  min-height: 44px !important;
  padding: 0 1rem !important;
  border-radius: 10px !important;
  border: 1px solid rgba(255, 255, 255, 0.08) !important;
  background: #191b23 !important;
  font-family: var(--font-sans) !important;
  font-size: 0.9rem !important;
  color: var(--text-main) !important;
  outline: none !important;
  transition: var(--transition-fast) !important;
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.2) !important;
}

/* Custom Uniform Dropdown Arrow */
select {
  appearance: none !important;
  -webkit-appearance: none !important;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%23d4af37'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'%3E%3C/path%3E%3C/svg%3E") !important;
  background-repeat: no-repeat !important;
  background-position: right 0.85rem center !important;
  background-size: 1.1rem !important;
  padding-right: 2.5rem !important;
}

textarea {
  width: 100%;
  padding: 0.8rem 1rem !important;
  border-radius: 10px !important;
  border: 1px solid rgba(255, 255, 255, 0.08) !important;
  background: #191b23 !important;
  font-family: var(--font-sans) !important;
  font-size: 0.9rem !important;
  color: var(--text-main) !important;
  outline: none !important;
  transition: var(--transition-fast) !important;
  resize: vertical;
}

input:focus, select:focus, textarea:focus {
  border-color: var(--brand-primary) !important;
  box-shadow: 0 0 0 3px rgba(212, 175, 55, 0.12), inset 0 1px 3px rgba(0, 0, 0, 0.2) !important;
}

input::placeholder, textarea::placeholder {
  color: var(--text-muted) !important;
}

/* Button System Standards */
button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  height: 44px !important;
  padding: 0 1.4rem !important;
  border-radius: 10px !important;
  border: none !important;
  font-weight: 600 !important;
  font-family: var(--font-sans) !important;
  font-size: 0.9rem !important;
  cursor: pointer !important;
  transition: var(--transition-fast) !important;
  white-space: nowrap !important;
}

.btn-primary {
  background: var(--brand-gradient) !important;
  color: #0c0d12 !important;
  box-shadow: var(--shadow-gold) !important;
}

.btn-primary:hover {
  background: var(--brand-gradient-hover) !important;
  transform: translateY(-1.5px) !important;
  box-shadow: 0 6px 25px rgba(212, 175, 55, 0.35) !important;
}

.btn-primary:active {
  transform: translateY(0) !important;
}

.btn-secondary {
  background: #191b23 !important;
  color: var(--text-secondary) !important;
  border: 1px solid rgba(255, 255, 255, 0.08) !important;
  box-shadow: var(--shadow-sm) !important;
}

.btn-secondary:hover {
  background: #1e2029 !important;
  border-color: rgba(212, 175, 55, 0.15) !important;
  color: var(--text-main) !important;
}

.btn-sm {
  height: 36px !important;
  padding: 0 0.85rem !important;
  font-size: 0.82rem !important;
  border-radius: 8px !important;
}

/* ==========================================================================
   TABLES & BADGES
   ========================================================================== */
.table-container {
  background: var(--surface-card);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  overflow-x: auto;
  box-shadow: var(--shadow-md);
  width: 100%;
}

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

th {
  background: #0f1016;
  padding: 0.9rem 1.25rem;
  text-align: left;
  font-weight: 700;
  font-size: 0.78rem;
  color: #d4af37;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  border-bottom: 1px solid rgba(212, 175, 55, 0.1);
}

td {
  padding: 1rem 1.25rem;
  font-size: 0.88rem;
  color: var(--text-main);
  border-bottom: 1px solid var(--border-color);
  vertical-align: middle;
}

tr:last-child td { border-bottom: none; }
tr:hover td { background: rgba(212, 175, 55, 0.03); }

.td-actions {
  white-space: nowrap !important;
}

/* Badges & Status Chips */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.25rem 0.65rem;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 700;
  background: var(--brand-light);
  color: var(--brand-light-text);
  letter-spacing: 0.3px;
}

.status {
  display: inline-flex;
  align-items: center;
  padding: 0.3rem 0.75rem;
  border-radius: 20px;
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.3px;
}

.status.yeni { background: var(--brand-light); color: var(--brand-light-text); }
.status.cevapladi, .status.ulasildi { background: var(--accent-success-bg); color: var(--accent-success-text); }
.status.cevaplamadi, .status.acmadi { background: var(--accent-danger-bg); color: var(--accent-danger-text); }
.status.mesgul { background: var(--accent-warning-bg); color: var(--accent-warning-text); }
.status.ilgilenmiyor { background: rgba(255, 255, 255, 0.06); color: var(--text-muted); }
.status.fakir { background: rgba(255, 255, 255, 0.04); color: var(--text-muted); }
.status.randevu { background: rgba(168, 85, 247, 0.12); color: #c084fc; }
.status.cekim_yapildi, .status.bakiye_geldi { background: var(--accent-success-bg); color: var(--accent-success-text); }
.status.cuzdan_gonderildi { background: var(--accent-info-bg); color: var(--accent-info-text); }

/* ==========================================================================
   MODAL SYSTEM
   ========================================================================== */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 1.5rem;
  animation: fadeIn 0.2s ease-out;
}

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

.modal-content {
  background: #14161d;
  border-radius: 20px;
  box-shadow: 0 25px 80px -15px rgba(0, 0, 0, 0.7), 0 0 40px rgba(212, 175, 55, 0.05);
  border: 1px solid rgba(212, 175, 55, 0.1);
  width: 100%;
  max-width: 620px;
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: slideUp 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  padding: 1.8rem 2.2rem;
}

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

.modal-content h3 {
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--text-main);
  margin-bottom: 1.25rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid rgba(212, 175, 55, 0.1);
}

.modal-content > form,
.modal-content > div:not(.modal-actions),
.modal-body-custom {
  flex: 1;
  overflow-y: auto;
  padding-right: 0.4rem;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.8rem;
  margin-top: 1.5rem;
  padding-top: 1.2rem;
  border-top: 1px solid var(--border-color);
  flex-shrink: 0;
}

/* Large Editor Modals */
#admin-wallet-detail-modal .modal-content,
#template-editor-modal .modal-content {
  max-width: 1100px !important;
  width: 90vw !important;
  height: 86vh !important;
}

/* 90% Viewport Popup for Custom Email Modal */
#custom-email-modal .modal-content {
  max-width: 90vw !important;
  width: 90vw !important;
  height: 90vh !important;
  max-height: 90vh !important;
}

#custom-email-modal-grid {
  display: grid;
  grid-template-columns: 35% 65%;
  gap: 1.5rem;
  flex: 1;
  min-height: 0;
  margin-top: 1rem;
  overflow: hidden;
}

/* Medium Action Modals */
#wallet-modal .modal-content {
  max-width: 780px !important;
  width: 85vw !important;
}

/* Small Form Modals */
#edit-customer-modal .modal-content,
#add-user-modal .modal-content,
#status-modal .modal-content {
  max-width: 540px !important;
}

/* Secret Inputs & Card Rows Inside Modals */
.secret-row-item {
  background: #191b23;
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 0.8rem 1rem;
  margin-bottom: 0.8rem;
}

.secret-row-input-wrap {
  display: flex;
  gap: 0.6rem;
  margin-top: 0.4rem;
}

.secret-row-input-wrap input {
  font-family: var(--font-mono);
  font-size: 0.88rem;
  background: #12141a;
  font-weight: 600;
}

/* ==========================================================================
   LOGIN SCREEN — PREMIUM DARK EXCHANGE
   ========================================================================== */
#login-screen {
  position: fixed;
  top: 0; left: 0; width: 100vw; height: 100vh;
  background: radial-gradient(ellipse at 50% 20%, rgba(212, 175, 55, 0.08) 0%, #08090d 60%, #050507 100%);
  display: flex; align-items: center; justify-content: center;
  z-index: 9999;
  padding: 1.5rem;
  overflow: hidden;
}

/* Animated gold particles effect */
#login-screen::before {
  content: '';
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: 
    radial-gradient(2px 2px at 20% 30%, rgba(212, 175, 55, 0.3), transparent),
    radial-gradient(2px 2px at 60% 20%, rgba(212, 175, 55, 0.2), transparent),
    radial-gradient(2px 2px at 80% 60%, rgba(212, 175, 55, 0.15), transparent),
    radial-gradient(2px 2px at 40% 80%, rgba(212, 175, 55, 0.2), transparent),
    radial-gradient(2px 2px at 70% 45%, rgba(212, 175, 55, 0.25), transparent);
  animation: particleFloat 25s linear infinite;
  pointer-events: none;
}

@keyframes particleFloat {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

#login-screen.hidden {
  display: none !important;
}

.login-card {
  background: rgba(18, 20, 26, 0.95);
  padding: 3rem 2.5rem;
  border-radius: 24px;
  box-shadow: 0 25px 80px rgba(0, 0, 0, 0.6), 0 0 60px rgba(212, 175, 55, 0.05);
  width: 100%;
  max-width: 420px;
  border: 1px solid rgba(212, 175, 55, 0.12);
  text-align: left;
  position: relative;
  backdrop-filter: blur(20px);
}

/* Gold accent line on login card */
.login-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 60%;
  height: 2px;
  background: linear-gradient(90deg, transparent, #d4af37, transparent);
}

.login-header {
  text-align: center;
  margin-bottom: 2rem;
}

.login-brand {
  font-size: 1.75rem;
  font-weight: 900;
  background: linear-gradient(135deg, #d4af37, #f0d060, #d4af37);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: -0.5px;
  margin-bottom: 0.3rem;
}

.login-subtitle {
  font-size: 0.88rem;
  color: #6b6760;
  font-weight: 500;
}

.login-card .input-group {
  margin-bottom: 1.2rem;
}

.login-card .input-group label {
  display: block;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-secondary);
  margin-bottom: 0.4rem;
}

.login-card input[type="text"],
.login-card input[type="password"] {
  width: 100%;
  padding: 0.85rem 1rem;
  border-radius: 10px;
  border: 1.5px solid rgba(255, 255, 255, 0.08);
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-main);
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  background: #191b23;
}

.login-card input[type="text"]:focus,
.login-card input[type="password"]:focus {
  border-color: #d4af37;
  background: #1e2029;
  box-shadow: 0 0 0 3px rgba(212, 175, 55, 0.12);
}

.login-btn {
  width: 100%;
  padding: 0.95rem;
  font-size: 1rem;
  font-weight: 700;
  background: var(--brand-gradient);
  border: none;
  border-radius: 10px;
  color: #0c0d12;
  cursor: pointer;
  margin-top: 0.8rem;
  box-shadow: var(--shadow-gold);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  letter-spacing: 0.3px;
}

.login-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 30px rgba(212, 175, 55, 0.35);
}

.login-error-box {
  margin-top: 1.2rem;
  padding: 0.75rem 1rem;
  background: var(--accent-danger-bg);
  border: 1px solid rgba(239, 68, 68, 0.2);
  color: var(--accent-danger-text);
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 600;
  text-align: center;
}

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

.toast {
  pointer-events: auto; min-width: 320px; padding: 14px 22px; border-radius: 14px;
  background: #14161d; color: #e8e6e1; font-weight: 600; font-size: 0.9rem;
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.5), 0 0 20px rgba(212, 175, 55, 0.08);
  display: flex; align-items: center; gap: 12px;
  border: 1px solid rgba(212, 175, 55, 0.1);
  animation: toastIn 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.btn-crm-filter-pill {
  transition: all 0.15s ease !important;
}

.btn-crm-filter-pill.active {
  background: var(--brand-gradient) !important;
  color: #0c0d12 !important;
  border-color: transparent !important;
  font-weight: 700 !important;
  box-shadow: var(--shadow-gold) !important;
}

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

/* ==========================================================================
   DASHBOARD STAT CARDS — PREMIUM GOLD ACCENTS
   ========================================================================== */
.stat-card {
  background: var(--surface-card);
  border: 1px solid var(--border-color);
  border-radius: 14px;
  padding: 1.25rem;
  transition: var(--transition-normal);
}

.stat-card:hover {
  border-color: rgba(212, 175, 55, 0.12);
  box-shadow: var(--shadow-glow);
}

.stat-card .stat-value {
  font-size: 1.8rem;
  font-weight: 800;
  color: #d4af37;
}

::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(212, 175, 55, 0.15); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(212, 175, 55, 0.3); }

/* ==========================================================================
   MOBILE HAMBURGER BUTTON
   ========================================================================== */
#mobile-menu-toggle {
  display: none;
  position: fixed;
  top: 1rem;
  left: 1rem;
  z-index: 1100;
  width: 44px;
  height: 44px !important;
  padding: 0 !important;
  background: rgba(18, 20, 26, 0.95) !important;
  border: 1px solid rgba(212, 175, 55, 0.2) !important;
  border-radius: 10px !important;
  color: #d4af37 !important;
  font-size: 1.3rem;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(0,0,0,0.5);
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  transition: background 0.2s ease;
}

#mobile-menu-toggle span {
  display: block;
  width: 20px;
  height: 2px;
  background: #d4af37;
  border-radius: 2px;
  transition: all 0.3s ease;
}

#mobile-menu-toggle.open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
#mobile-menu-toggle.open span:nth-child(2) { opacity: 0; }
#mobile-menu-toggle.open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* Sidebar overlay for mobile */
#sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(4px);
  z-index: 999;
}

/* ==========================================================================
   DASHBOARD GRID RESPONSIVENESS
   ========================================================================== */
.dash-grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1.2rem; }
.dash-grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0.9rem; }

/* ==========================================================================
   TABLE IMPROVEMENTS — HORIZONTAL SCROLL + MIN-WIDTH
   ========================================================================== */
.table-container {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.table-container table {
  min-width: 700px;
}

/* Tighter table cells on smaller screens */
@media (max-width: 900px) {
  th { padding: 0.7rem 0.75rem; font-size: 0.72rem; }
  td { padding: 0.7rem 0.75rem; font-size: 0.82rem; }
}

/* ==========================================================================
   TABLET — 1024px and below
   ========================================================================== */
@media (max-width: 1024px) {
  .sidebar {
    width: 240px;
    min-width: 240px;
    padding: 1.25rem 0.9rem;
  }

  .main-content {
    padding: 1.5rem 1.5rem;
  }

  .dash-grid-3 {
    grid-template-columns: repeat(2, 1fr) !important;
  }

  .dash-grid-4 {
    grid-template-columns: repeat(2, 1fr) !important;
  }

  #live-crypto-rates-list {
    grid-template-columns: repeat(2, 1fr) !important;
  }
}

/* ==========================================================================
   MOBILE — 768px and below
   ========================================================================== */
@media (max-width: 768px) {

  /* Show hamburger */
  #mobile-menu-toggle {
    display: flex !important;
  }

  /* App layout: stack vertically */
  #app-screen {
    flex-direction: column;
    height: auto;
    min-height: 100vh;
    overflow: visible;
  }

  /* Sidebar: off-canvas slide-in */
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    width: 280px !important;
    min-width: 280px !important;
    transform: translateX(-100%);
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    z-index: 1000;
    overflow-y: auto;
  }

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

  #sidebar-overlay.active {
    display: block;
  }

  /* Main content: full width with top padding for hamburger */
  .main-content {
    width: 100%;
    padding: 1rem 0.9rem;
    padding-top: 4rem; /* space for hamburger */
    overflow-y: auto;
    height: auto;
    min-height: 100vh;
  }

  /* View header */
  .view-header {
    margin-bottom: 1.2rem;
  }
  .view-header h2 { font-size: 1.25rem !important; }
  .view-header p { font-size: 0.82rem !important; }

  /* Single column grids */
  .dash-grid-3,
  .dash-grid-4 {
    grid-template-columns: 1fr !important;
    gap: 0.75rem !important;
  }

  /* Crypto rates: 2 cols on mobile */
  #live-crypto-rates-list {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 0.6rem !important;
  }

  /* Tables: horizontal scroll, no text shrink */
  .table-container {
    border-radius: 12px;
    margin: 0 -0.05rem;
  }

  .table-container table {
    min-width: 640px;
  }

  /* Table action buttons: compact */
  .td-actions .btn-sm {
    padding: 0.25rem 0.5rem !important;
    font-size: 0.72rem !important;
    height: 30px !important;
  }

  /* CRM filter pills: wrap nicely */
  .btn-crm-filter-pill {
    font-size: 0.72rem !important;
    padding: 0.25rem 0.6rem !important;
    height: 32px !important;
  }

  /* Modals: full-screen on mobile */
  .modal {
    padding: 0;
    align-items: flex-end;
  }

  .modal-content {
    max-width: 100vw !important;
    width: 100vw !important;
    max-height: 92vh !important;
    border-radius: 20px 20px 0 0 !important;
    padding: 1.25rem 1.1rem !important;
    overflow-y: auto;
  }

  /* Edit user modal grid: 1 column */
  #edit-user-modal .modal-content > div[style*="grid-template-columns:1fr 1fr"] {
    grid-template-columns: 1fr !important;
  }

  /* Modal actions: stack buttons */
  .modal-actions {
    flex-direction: column-reverse;
    gap: 0.6rem;
  }

  .modal-actions button {
    width: 100%;
  }

  /* View header action buttons */
  .view-header {
    flex-direction: column !important;
    align-items: flex-start !important;
    gap: 0.75rem !important;
  }

  .view-header > div:last-child,
  .view-header > button {
    width: 100%;
  }

  /* Login card: full width */
  .login-card {
    padding: 2rem 1.4rem;
    max-width: 100%;
    border-radius: 16px;
  }

  .login-brand { font-size: 1.5rem; }

  /* Distribution page: single column */
  #view-distribute .dash-grid-3 {
    grid-template-columns: 1fr !important;
  }

  /* CRM search bar: stacked */
  #view-crm .glass-panel > div[style*="flex"],
  #view-crm .glass-panel > div[style*="gap:0.8rem"] {
    flex-direction: column !important;
    gap: 0.6rem !important;
  }

  /* Import view: full width textarea */
  #import-raw-text { font-size: 0.82rem !important; }

  /* Agent stat cards: 2-col on mobile */
  #view-call .dash-grid-4 {
    grid-template-columns: repeat(2, 1fr) !important;
  }

  /* Earnings / wallet tables */
  #earnings-table, #admin-wallets-table {
    min-width: 600px;
  }

  /* Toast: full-width bottom */
  #toast-container {
    top: auto;
    bottom: 1rem;
    right: 0.75rem;
    left: 0.75rem;
  }

  .toast {
    min-width: unset;
    width: 100%;
  }

  /* Stat mini cards */
  .stat-mini-card {
    padding: 0.5rem 0.75rem !important;
    font-size: 0.82rem !important;
  }

  /* Staff stats table */
  #staff-stats-table {
    min-width: 900px;
  }

  /* Template grid in custom email */
  #custom-email-modal-grid {
    grid-template-columns: 1fr !important;
    overflow-y: auto;
  }
}

/* ==========================================================================
   SMALL PHONES — 480px and below
   ========================================================================== */
@media (max-width: 480px) {
  .main-content {
    padding: 0.75rem 0.65rem;
    padding-top: 4rem;
  }

  .view-header h2 { font-size: 1.1rem !important; }

  /* Agent stat cards: 1 column on very small screens */
  #view-call .dash-grid-4 {
    grid-template-columns: 1fr 1fr !important;
  }

  th { font-size: 0.68rem !important; padding: 0.6rem 0.5rem !important; }
  td { font-size: 0.78rem !important; padding: 0.6rem 0.5rem !important; }

  .badge { font-size: 0.68rem; padding: 0.2rem 0.5rem; }
  .status { font-size: 0.68rem; padding: 0.2rem 0.5rem; }

  button {
    font-size: 0.82rem !important;
  }

  .login-card {
    padding: 1.5rem 1.1rem;
  }

  .modal-content {
    padding: 1rem 0.85rem !important;
  }

  /* Crypto rates: 1 column on tiny phones */
  #live-crypto-rates-list {
    grid-template-columns: 1fr !important;
  }
}

/* ==========================================================================
   PRINT / DESKTOP MIN-WIDTH GUARD
   ========================================================================== */
@media (min-width: 1280px) {
  .main-content {
    padding: 2.25rem 2.75rem;
  }
}

/* ==========================================================================
   CRM TABLE — RESPONSIVE COLUMN HIDING & TABLE SIZING FIX
   ========================================================================== */

/* Base: remove forced min-width from table containers so they fit the screen */
.table-container {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  width: 100%;
}

/* CRM table: give columns sensible widths */
#crm-table { table-layout: auto; width: 100%; }
#crm-table td, #crm-table th { white-space: nowrap; }
#crm-table td:nth-child(6), #crm-table th:nth-child(6) { white-space: normal; max-width: 180px; } /* notes */
#crm-table td:nth-child(2), #crm-table th:nth-child(2) { max-width: 180px; } /* name */

/* Users table */
#users-table { table-layout: auto; width: 100%; }
#users-table td, #users-table th { white-space: nowrap; }

/* History table */
#history-table { table-layout: auto; width: 100%; }

/* Staff stats: always scrollable */
#staff-stats-table { min-width: 860px; }

/* Login logs table */
#login-logs-table { table-layout: auto; width: 100%; }

/* Wallets table */
#admin-wallets-table { min-width: 680px; }

/* ==========================================================================
   CRM TABLE COLUMN HIDING ON DIFFERENT BREAKPOINTS
   ========================================================================== */

/* Hide TC column on screens ≤ 1100px */
@media (max-width: 1100px) {
  .crm-col-tc { display: none !important; }
}

/* Hide notes column on screens ≤ 900px */
@media (max-width: 900px) {
  .crm-col-notes { display: none !important; }
}

/* Hide assigned agent column on screens ≤ 700px */
@media (max-width: 700px) {
  .crm-col-agent { display: none !important; }
}

/* On mobile (≤768px): CRM action buttons become icon-only */
@media (max-width: 768px) {
  #crm-table { min-width: unset; }
  #crm-table td, #crm-table th { white-space: nowrap; padding: 0.55rem 0.5rem; font-size: 0.78rem; }
  #crm-table .btn-xs { padding: 0.25rem 0.45rem !important; font-size: 0.72rem !important; height: 28px !important; }

  /* Users & other tables */
  #users-table { min-width: 560px; }
  #history-table { min-width: 560px; }
  #login-logs-table { min-width: 520px; }
}

/* Bulk toolbar on mobile */
@media (max-width: 768px) {
  #crm-bulk-toolbar {
    flex-direction: column !important;
    align-items: flex-start !important;
  }
  #crm-bulk-toolbar > div:last-child {
    width: 100%;
  }
  #crm-bulk-toolbar button {
    flex: 1;
  }
}

/* ==========================================================================
   GENERAL TABLE SIZING FIX — FIT SCREEN WITHOUT OVERFLOW
   ========================================================================== */
.table-container {
  /* Ensure container never exceeds its parent */
  max-width: 100%;
  box-sizing: border-box;
}

/* Action column: don't let it push other content */
.td-actions, #crm-table td:last-child, #users-table td:last-child {
  white-space: nowrap;
  min-width: 0;
}

/* Prevent long text from breaking layouts */
table td {
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 240px;
}

table th {
  white-space: nowrap;
}

/* ==========================================================================
   IMPROVED FADEINDDOWN ANIMATION (for bulk toolbar)
   ========================================================================== */
@keyframes fadeInDown {
  from { opacity: 0; transform: translateY(-8px); }
  to   { opacity: 1; transform: translateY(0); }
}
