/* ==========================================================================
   Real Estate CRM Premium Dark CSS
   Aesthetics: Obsidian Black, Emerald & Gold Accents, Glassmorphism
   ========================================================================== */

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

:root {
  /* Color Palette */
  --bg-darkest: #06080c;
  --bg-main: #0b0f17;
  --bg-card: rgba(18, 24, 38, 0.65);
  --bg-card-hover: rgba(26, 34, 54, 0.85);
  --border-color: rgba(255, 255, 255, 0.08);
  --border-focus: rgba(16, 185, 129, 0.5);
  
  --primary-emerald: #10b981;
  --primary-emerald-hover: #059669;
  --primary-emerald-glow: rgba(16, 185, 129, 0.25);
  
  --accent-gold: #f59e0b;
  --accent-gold-hover: #d97706;
  --accent-gold-glow: rgba(245, 158, 11, 0.2);
  
  --text-main: #f3f4f6;
  --text-secondary: #9ca3af;
  --text-muted: #6b7280;
  --text-white: #ffffff;
  
  --danger: #ef4444;
  --danger-hover: #dc2626;
  --danger-glow: rgba(239, 68, 68, 0.2);
  
  --success: #10b981;
  --info: #3b82f6;
  
  /* Glassmorphism & Shadow */
  --glass-blur: blur(20px);
  --shadow-lg: 0 20px 40px -15px rgba(0, 0, 0, 0.7);
  --shadow-sm: 0 4px 12px rgba(0, 0, 0, 0.5);
  --shadow-glow-emerald: 0 0 25px rgba(16, 185, 129, 0.15);
  --shadow-glow-gold: 0 0 25px rgba(245, 158, 11, 0.15);
  --shadow-glow-blue: 0 0 25px rgba(59, 130, 246, 0.15);
  
  /* Transitions */
  --transition-fast: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-normal: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ==========================================================================
   Reset & Base Styles
   ========================================================================== */

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  overflow-x: hidden;
  max-width: 100%;
}

body {
  font-family: 'Plus Jakarta Sans', sans-serif;
  background-color: var(--bg-darkest);
  color: var(--text-main);
  min-height: 100vh;
  line-height: 1.5;
  letter-spacing: -0.01em;
  opacity: 0; /* Hidden initially to prevent layout flash during auth check */
  transition: opacity var(--transition-fast) ease-in-out;
}

body.auth-verified, body.allow-unauth {
  opacity: 1;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: var(--bg-darkest);
}
::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.2);
}

/* ==========================================================================
   Background Glow Orbs
   ========================================================================== */

.ambient-bg {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: -10;
  overflow: hidden;
  pointer-events: none;
  background: radial-gradient(circle at 10% 20%, rgba(11, 15, 23, 1) 0%, rgba(6, 8, 12, 1) 100%);
}

.ambient-orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(150px);
  opacity: 0.12;
}

.orb-1 {
  top: -10%;
  right: 10%;
  width: 500px;
  height: 500px;
  background: var(--primary-emerald);
  animation: floatOrb 20s infinite alternate;
}

.orb-2 {
  bottom: -20%;
  left: -10%;
  width: 600px;
  height: 600px;
  background: var(--accent-gold);
  animation: floatOrb 25s infinite alternate-reverse;
}

@keyframes floatOrb {
  0% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(50px, -30px) scale(1.1); }
  100% { transform: translate(-20px, 40px) scale(0.95); }
}

/* ==========================================================================
   Authentication - Login Layout
   ========================================================================== */

.login-container {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 20px;
}

.login-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  backdrop-filter: var(--glass-blur);
  border-radius: 24px;
  width: 100%;
  max-width: 460px;
  padding: 48px;
  box-shadow: var(--shadow-lg), var(--shadow-glow-emerald);
  transition: transform var(--transition-normal), border-color var(--transition-normal);
  animation: cardFadeIn 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

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

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

.logo-icon {
  width: 52px;
  height: 52px;
  background: linear-gradient(135deg, var(--primary-emerald), var(--accent-gold));
  border-radius: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--bg-darkest);
  font-size: 24px;
  font-weight: 800;
  margin-bottom: 16px;
  box-shadow: 0 8px 20px rgba(16, 185, 129, 0.3);
}

.login-logo h1 {
  font-family: 'Outfit', sans-serif;
  font-size: 26px;
  font-weight: 700;
  color: var(--text-white);
  letter-spacing: -0.02em;
}

.login-logo p {
  color: var(--text-secondary);
  font-size: 14px;
  margin-top: 6px;
}

/* Forms */
.form-group {
  margin-bottom: 22px;
  position: relative;
}

.form-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-main);
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.input-wrapper {
  position: relative;
}

.input-icon {
  position: absolute;
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 18px;
}

.form-input {
  width: 100%;
  background: rgba(10, 12, 20, 0.5);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 14px 16px 14px 46px;
  color: var(--text-white);
  font-size: 15px;
  font-family: inherit;
  transition: all var(--transition-fast);
}

.form-input:focus {
  outline: none;
  border-color: var(--primary-emerald);
  background: rgba(10, 12, 20, 0.8);
  box-shadow: 0 0 0 4px var(--primary-emerald-glow);
}

.password-toggle {
  position: absolute;
  right: 16px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  cursor: pointer;
  background: none;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color var(--transition-fast);
}

.password-toggle:hover {
  color: var(--text-main);
}

/* Button & Alert Styles */
.btn {
  width: 100%;
  font-family: inherit;
  font-size: 15px;
  font-weight: 600;
  padding: 14px 20px;
  border-radius: 12px;
  border: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all var(--transition-fast);
  text-decoration: none;
  /* Global mobile button constraints */
  min-width: 0;
  max-width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  box-sizing: border-box;
}

.btn-primary {
  background: var(--primary-emerald);
  color: var(--bg-darkest);
  box-shadow: 0 4px 12px var(--primary-emerald-glow);
}

.btn-primary:hover {
  background: var(--primary-emerald-hover);
  transform: translateY(-1px);
  box-shadow: 0 6px 16px var(--primary-emerald-glow);
}

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

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

.btn-danger:hover {
  background: var(--danger-hover);
  box-shadow: 0 4px 12px var(--danger-glow);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-main);
  border: 1px solid var(--border-color);
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.12);
  color: var(--text-white);
}

.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  pointer-events: none;
}

.btn-spinner {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(0, 0, 0, 0.1);
  border-top-color: currentColor;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  display: none;
}

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

.btn.loading .btn-spinner {
  display: inline-block;
}

.btn.loading .btn-text {
  display: none;
}

.alert {
  padding: 12px 16px;
  border-radius: 12px;
  font-size: 14px;
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1px solid transparent;
  animation: alertFadeIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

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

.alert-danger {
  background: rgba(239, 68, 68, 0.1);
  border-color: rgba(239, 68, 68, 0.2);
  color: #f87171;
}

.alert-success {
  background: rgba(16, 185, 129, 0.1);
  border-color: rgba(16, 185, 129, 0.2);
  color: #34d399;
}

/* Seed Accounts Demo Tooltip */
.seed-accounts {
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--border-color);
}

.seed-title {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 10px;
  letter-spacing: 0.05em;
}

.seed-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.seed-box {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border-color);
  padding: 10px;
  border-radius: 8px;
  font-size: 11px;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.seed-box:hover {
  background: rgba(16, 185, 129, 0.04);
  border-color: rgba(16, 185, 129, 0.2);
}

.seed-box span {
  display: block;
  font-weight: 600;
  color: var(--text-secondary);
}

.seed-box strong {
  display: block;
  font-family: monospace;
  color: var(--text-main);
  margin-top: 2px;
  font-size: 11px;
}

/* ==========================================================================
   Dashboard Layout (CRM Master)
   ========================================================================== */

.crm-wrapper {
  display: flex;
  min-height: 100vh;
  position: relative;
  overflow-x: hidden;
  width: 100%;
}

/* Sidebar Styling */
.crm-sidebar {
  width: 280px;
  background: rgba(9, 13, 22, 0.8);
  backdrop-filter: var(--glass-blur);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  height: 100vh;
  position: fixed;
  left: 0;
  top: 0;
  z-index: 100;
  transition: transform var(--transition-normal);
}

.sidebar-header {
  padding: 30px 24px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid var(--border-color);
}

.sidebar-logo {
  font-family: 'Outfit', sans-serif;
  font-size: 20px;
  font-weight: 700;
  color: var(--text-white);
  letter-spacing: -0.02em;
  background: linear-gradient(135deg, var(--primary-emerald), var(--accent-gold));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.sidebar-nav {
  padding: 24px 16px;
  flex-grow: 1;
}

.nav-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  margin-bottom: 12px;
  margin-left: 8px;
  letter-spacing: 0.05em;
}

.nav-list {
  list-style: none;
}

.nav-item {
  margin-bottom: 6px;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-radius: 10px;
  color: var(--text-secondary);
  text-decoration: none;
  font-weight: 500;
  font-size: 14px;
  transition: all var(--transition-fast);
}

.nav-link i {
  font-size: 18px;
}

.nav-link:hover, .nav-item.active .nav-link {
  background: linear-gradient(90deg, rgba(16, 185, 129, 0.1) 0%, rgba(16, 185, 129, 0.01) 100%);
  color: var(--text-white);
  box-shadow: inset 3px 0 0 var(--primary-emerald);
}

.sidebar-footer {
  padding: 20px 24px;
  border-top: 1px solid var(--border-color);
  background: rgba(5, 7, 12, 0.4);
}

.sidebar-profile {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.profile-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary-emerald-hover), var(--accent-gold-hover));
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-white);
  font-family: 'Outfit', sans-serif;
  font-weight: 700;
  font-size: 16px;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
}

.profile-info {
  overflow: hidden;
}

.profile-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-white);
  white-space: nowrap;
  text-overflow: ellipsis;
  overflow: hidden;
}

.profile-role {
  font-size: 11px;
  color: var(--text-muted);
}

/* Main Dashboard Wrapper */
.crm-content {
  flex-grow: 0;
  margin-left: 280px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  width: calc(100% - 280px);
  min-width: 0;
}

/* Header Styling */
.crm-header {
  width: 100%;
  max-width: 100%;
  height: 64px;
  background: rgba(9, 13, 22, 0.4);
  backdrop-filter: var(--glass-blur);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 40px;
  position: sticky;
  top: 0;
  z-index: 90;
  gap: 12px;
}

.mobile-nav-toggle {
  display: none;
  background: none;
  border: none;
  color: var(--text-white);
  font-size: 24px;
  cursor: pointer;
}

.header-title h2 {
  font-family: 'Outfit', sans-serif;
  font-size: 22px;
  font-weight: 700;
  color: var(--text-white);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 20px;
}

.btn-logout {
  background: rgba(239, 68, 68, 0.08);
  border: 1px solid rgba(239, 68, 68, 0.2);
  color: #f87171;
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.btn-logout:hover {
  background: var(--danger);
  color: var(--text-white);
  box-shadow: 0 4px 12px var(--danger-glow);
}

/* Body Content Area */
.crm-body {
  padding: 40px;
  flex-grow: 1;
  min-width: 0;
  overflow-x: hidden;
}

/* Stats Cards Grid */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

.stats-grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 24px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  padding: 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: transform var(--transition-normal), border-color var(--transition-normal), box-shadow var(--transition-normal), background-color var(--transition-normal);
  min-width: 0;
}

.stat-card-gold {
  border-color: rgba(245, 158, 11, 0.15);
}

.stat-card-emerald {
  border-color: rgba(16, 185, 129, 0.15);
}

.stat-card-blue {
  border-color: rgba(59, 130, 246, 0.15);
}

.stat-card:hover {
  background: var(--bg-card-hover);
  border-color: rgba(255, 255, 255, 0.2);
  transform: translateY(-3px);
  box-shadow: var(--shadow-sm);
}

.stat-card-gold:hover {
  border-color: rgba(245, 158, 11, 0.4);
  box-shadow: var(--shadow-glow-gold);
}

.stat-card-emerald:hover {
  border-color: rgba(16, 185, 129, 0.4);
  box-shadow: var(--shadow-glow-emerald);
}

.stat-card-blue:hover {
  border-color: rgba(59, 130, 246, 0.4);
  box-shadow: var(--shadow-glow-blue);
}

.stat-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.stat-val {
  font-family: 'Outfit', sans-serif;
  font-size: 22px;
  font-weight: 800;
  color: var(--text-white);
  margin-top: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.stat-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}

.icon-emerald {
  background: rgba(16, 185, 129, 0.1);
  color: var(--primary-emerald);
}

.icon-gold {
  background: rgba(245, 158, 11, 0.1);
  color: var(--accent-gold);
}

.icon-blue {
  background: rgba(59, 130, 246, 0.1);
  color: var(--info);
}

/* ==========================================================================
   Tables & Lists Layout
   ========================================================================== */

.panel-card {
  background: var(--bg-card);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 20px;
  padding: 24px;
  margin-bottom: 24px;
  backdrop-filter: var(--glass-blur);
  box-shadow: var(--shadow-sm);
  transition: border-color var(--transition-normal), box-shadow var(--transition-normal);
  min-width: 0;
  overflow: hidden;
}

.panel-card:hover {
  border-color: rgba(255, 255, 255, 0.12);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.7);
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  padding-bottom: 16px;
}

.panel-title {
  font-family: 'Outfit', sans-serif;
  font-size: 16px;
  font-weight: 700;
  color: var(--text-white);
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

/* User Management Add Button */
.btn-sm {
  padding: 8px 16px;
  font-size: 13px;
  border-radius: 8px;
  min-width: 0;
  max-width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex-shrink: 0;
}

/* Section actions — default: side by side */
.section-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

/* Table Design */
.table-responsive {
  width: 100%;
  overflow-x: auto;
  border-radius: 8px;
  -webkit-overflow-scrolling: touch;
}

/* ===================================
   TABLE → CARD CONVERSION
   (Applied via class="card-on-mobile")
   on the <table> element)
   =================================== */
.card-on-mobile {
  /* Desktop: normal table */
}

.crm-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}

.crm-table th {
  padding: 10px 16px;
  border-bottom: 1px solid var(--border-color);
  color: var(--text-muted);
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  background: rgba(255, 255, 255, 0.01);
  white-space: nowrap;
}

.crm-table tbody tr {
  transition: background-color var(--transition-fast);
}

.crm-table td {
  padding: 12px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  font-size: 13px;
  color: var(--text-main);
  vertical-align: middle;
  transition: border-left var(--transition-fast), background-color var(--transition-fast);
  border-left: 3px solid transparent;
  white-space: nowrap;
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.crm-table tbody tr:hover td {
  background: rgba(255, 255, 255, 0.02);
}

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

.crm-table tr:last-child td {
  border-bottom: none;
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.badge-admin {
  background: rgba(245, 158, 11, 0.1);
  color: var(--accent-gold);
  border: 1px solid rgba(245, 158, 11, 0.2);
}

.badge-agent {
  background: rgba(16, 185, 129, 0.1);
  color: var(--primary-emerald);
  border: 1px solid rgba(16, 185, 129, 0.2);
}

.btn-icon-danger {
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.2);
  color: #ef4444;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--transition-fast);
}

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

/* ==========================================================================
   Modals & User Creation Forms
   ========================================================================== */

.modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-normal);
  overflow-y: auto;
  padding: 40px 20px;
}

.modal-backdrop.show {
  opacity: 1;
  pointer-events: auto;
}

.modal-card {
  background: #0d121f;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 24px;
  width: 100%;
  max-width: 500px;
  padding: 36px;
  box-shadow: var(--shadow-lg), 0 0 40px rgba(16, 185, 129, 0.1);
  transform: translateY(30px);
  transition: transform var(--transition-normal);
  margin: auto;
}

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

.modal-title {
  font-family: 'Outfit', sans-serif;
  font-size: 20px;
  font-weight: 700;
  color: var(--text-white);
  margin-bottom: 24px;
}

.modal-actions {
  display: flex;
  gap: 12px;
  margin-top: 10px;
}

/* ==========================================================================
   Premium Widgets & Features
   ========================================================================== */

/* Agent specific components */
.dashboard-flex-grid {
  display: grid;
  grid-template-columns: 3fr 2fr;
  gap: 24px;
}

.dashboard-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}

@media (max-width: 1024px) {
  .dashboard-flex-grid, .dashboard-grid-2 {
    grid-template-columns: 1fr;
  }
}

/* Floating WhatsApp link */
.btn-whatsapp {
  background: #25d366;
  color: #fff;
  border-radius: 8px;
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 600;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: background var(--transition-fast);
}

.btn-whatsapp:hover {
  background: #128c7e;
  box-shadow: 0 4px 10px rgba(37, 211, 102, 0.2);
}

/* Interactive Mortgage Calculator */
.calc-container {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.calc-row {
  display: flex;
  flex-direction: column;
}

.calc-labels {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.calc-labels span:last-child {
  color: var(--text-white);
  font-family: monospace;
  font-size: 14px;
}

/* Sliders */
.calc-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 3px;
  outline: none;
  transition: background var(--transition-fast);
}

.calc-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--primary-emerald);
  cursor: pointer;
  box-shadow: 0 0 10px var(--primary-emerald);
  transition: transform var(--transition-fast), background var(--transition-fast);
}

.calc-slider::-webkit-slider-thumb:hover {
  transform: scale(1.2);
  background: var(--text-white);
}

.calc-slider-gold::-webkit-slider-thumb {
  background: var(--accent-gold);
  box-shadow: 0 0 10px var(--accent-gold);
}

.calc-slider-gold::-webkit-slider-thumb:hover {
  background: var(--text-white);
}

/* Results Display Pane */
.calc-results {
  background: rgba(16, 185, 129, 0.05);
  border: 1px dashed rgba(16, 185, 129, 0.2);
  border-radius: 12px;
  padding: 20px;
  text-align: center;
  margin-top: 12px;
}

.calc-results-val {
  font-family: 'Outfit', sans-serif;
  font-size: 28px;
  font-weight: 800;
  color: var(--primary-emerald);
}

.calc-results-lbl {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 4px;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

/* ==========================================================================
   Responsive Utilities
   ========================================================================== */

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

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

/* ============================================================
   MOBILE-FIRST: ≤768px
   ============================================================ */
@media (max-width: 768px) {

  /* ── Layout ── */
  .crm-sidebar {
    transform: translateX(-100%);
  }
  .crm-sidebar.active {
    transform: translateX(0);
  }
  .crm-content {
    margin-left: 0;
    width: 100%;
  }
  .crm-header {
    padding: 0 16px;
    height: 56px;
    gap: 8px;
  }
  .crm-body {
    padding: 16px;
    overflow-x: hidden;
  }
  .mobile-nav-toggle {
    display: block;
  }

  /* ── Header title ── */
  .header-title h2 {
    font-size: 15px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 140px;
  }

  /* ── Header Actions: ICON-ONLY, max 44px ── */
  .header-actions {
    gap: 6px;
    flex-shrink: 0;
  }
  .header-actions .btn,
  .header-actions .btn-sm,
  .header-actions .btn-logout,
  .header-actions button {
    width: 40px;
    height: 40px;
    min-width: 40px;
    max-width: 44px;
    padding: 0;
    border-radius: 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
  }
  /* Hide text spans in header buttons */
  .header-actions .btn-text-label,
  .header-actions span:not(.btn-spinner) {
    display: none !important;
  }

  /* ── Section header & section actions ── */
  .page-section-header,
  .panel-header {
    flex-wrap: wrap;
    gap: 8px;
    align-items: flex-start;
  }
  .page-section-title {
    font-size: 14px;
    flex: 1 1 auto;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
  }
  .section-actions {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 8px;
  }
  .section-actions .btn,
  .section-actions .btn-sm {
    width: 100%;
    justify-content: center;
  }
  /* Panel header action buttons: full-width on mobile */
  .panel-header .btn-sm,
  .panel-header button.btn {
    width: 100%;
    order: 2;
    flex: 0 0 100%;
  }
  .panel-title {
    font-size: 13px;
    flex: 1 1 auto;
    order: 1;
  }
  /* Prevent panel-header from overflowing */
  .panel-header {
    flex-wrap: wrap;
  }

  /* ── Stats grid ── */
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    margin-bottom: 14px;
  }
  .stats-grid-3 {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  /* ── Stat cards compact ── */
  .stat-card {
    padding: 12px;
    border-radius: 12px;
  }
  .stat-label {
    font-size: 9px;
  }
  .stat-val {
    font-size: 16px;
    margin-top: 2px;
  }
  .stat-icon {
    width: 32px;
    height: 32px;
    font-size: 14px;
    border-radius: 8px;
  }

  /* ── Panel cards ── */
  .panel-card {
    padding: 14px;
    border-radius: 12px;
    margin-bottom: 14px;
  }
  .panel-header {
    margin-bottom: 12px;
    padding-bottom: 10px;
  }

  /* ── Buttons ── */
  .btn-sm {
    padding: 7px 12px;
    font-size: 12px;
  }
  .btn-logout {
    padding: 6px 10px;
    font-size: 12px;
    min-width: 0;
    max-width: 100%;
    white-space: nowrap;
  }

  /* ── Modals ── */
  .login-card {
    padding: 24px 20px;
  }
  .modal-card {
    padding: 18px;
    width: calc(100% - 16px);
    border-radius: 16px;
  }
  .modal-actions {
    flex-direction: column;
    gap: 8px;
  }
  .modal-actions .btn {
    width: 100%;
    justify-content: center;
  }

  /* ============================================================
     TABLE → CARD CONVERSION at ≤768px
     Uses data-label attributes on <td> for labels
     ============================================================ */
  .card-on-mobile thead {
    display: none !important;
  }
  .card-on-mobile,
  .card-on-mobile tbody {
    display: block;
    width: 100%;
  }
  .card-on-mobile tbody tr {
    display: block;
    background: rgba(255, 255, 255, 0.025);
    border: 1px solid rgba(255, 255, 255, 0.07);
    border-radius: 12px;
    margin-bottom: 10px;
    padding: 10px 12px;
    overflow: hidden;
  }
  .card-on-mobile tbody tr:last-child {
    margin-bottom: 0;
  }
  .card-on-mobile tbody td {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
    font-size: 12px;
    white-space: normal;
    max-width: 100%;
    overflow: visible;
    text-overflow: unset;
    border-left: none;
    gap: 8px;
  }
  .card-on-mobile tbody td:last-child {
    border-bottom: none;
  }
  /* Label from data-label attribute */
  .card-on-mobile tbody td[data-label]::before {
    content: attr(data-label);
    font-size: 9px;
    font-weight: 800;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    flex-shrink: 0;
    white-space: nowrap;
    min-width: 72px;
  }
  /* Right-align values */
  .card-on-mobile tbody td > * {
    text-align: right;
    max-width: 60%;
  }
  /* Action cells — center buttons */
  .card-on-mobile tbody td:last-child[data-label="Actions"],
  .card-on-mobile tbody td.td-actions-cell {
    justify-content: flex-end;
    padding-top: 8px;
  }
  .card-on-mobile tbody td.td-actions-cell::before {
    display: none;
  }
  .card-on-mobile .td-actions {
    justify-content: flex-end;
  }
  /* Remove .table-responsive horizontal scroll for card tables */
  .table-responsive:has(.card-on-mobile) {
    overflow-x: visible;
  }
}

/* ============================================================
   Extra Small: ≤480px
   ============================================================ */
@media (max-width: 480px) {
  .crm-body {
    padding: 12px;
  }
  .crm-header {
    padding: 0 12px;
  }
  .stats-grid {
    gap: 8px;
  }
  .stat-card {
    padding: 10px;
  }
  .stat-val {
    font-size: 15px;
  }
  .stat-label {
    font-size: 8px;
  }
  .panel-card {
    padding: 12px;
  }
  .card-on-mobile tbody td[data-label]::before {
    min-width: 60px;
    font-size: 8px;
  }
}
