/* ==========================================================================
   AUTOSENDX SaaS DESIGN SYSTEM (Tenant Admin Portal)
   ========================================================================== */

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

:root {
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-heading: 'Plus Jakarta Sans', var(--font-sans);

  /* Primary & Accent Palette */
  --primary: #4f46e5;
  --primary-hover: #4338ca;
  --primary-light: #eef2ff;
  --primary-glow: rgba(79, 70, 229, 0.15);
  
  --secondary: #0ea5e9;
  --secondary-light: #e0f2fe;
  
  --success: #10b981;
  --success-light: #ecfdf5;
  --success-text: #047857;
  
  --warning: #f59e0b;
  --warning-light: #fffbeb;
  --warning-text: #b45309;
  
  --danger: #ef4444;
  --danger-light: #fef2f2;
  --danger-text: #b91c1c;

  --purple: #8b5cf6;
  --purple-light: #f5f3ff;
  
  /* Surfaces & Borders */
  --bg: #f8fafc;
  --surface: #ffffff;
  --surface-raised: #ffffff;
  --border: #e2e8f0;
  --border-focus: #cbd5e1;
  
  /* Typography */
  --text-main: #0f172a;
  --text-muted: #64748b;
  --text-dim: #94a3b8;
  
  /* Shadows & Radius */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-xl: 20px;
  --radius-full: 9999px;
  
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.07), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -4px rgba(0, 0, 0, 0.03);
  --shadow-glow: 0 0 20px rgba(79, 70, 229, 0.12);
  
  --transition: all 0.18s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
  font-family: var(--font-sans);
  background-color: var(--bg);
  color: var(--text-main);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-heading);
  color: var(--text-main);
  font-weight: 700;
  letter-spacing: -0.02em;
}

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

/* ==========================================================================
   NAVIGATION TOPBAR (Floating Glass Design)
   ========================================================================== */
.topnav {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 2rem;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}

.brand-wrap {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.brand-logo {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  color: #ffffff;
  font-weight: 800;
  font-size: 1.1rem;
  border-radius: var(--radius-md);
  box-shadow: 0 4px 10px rgba(79, 70, 229, 0.25);
}

.brand-name {
  font-family: var(--font-heading);
  font-weight: 800;
  font-size: 1.15rem;
  color: var(--text-main);
  letter-spacing: -0.03em;
}

.tenant-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.2rem 0.6rem;
  background: var(--primary-light);
  color: var(--primary);
  font-size: 0.75rem;
  font-weight: 600;
  border-radius: var(--radius-full);
  border: 1px solid rgba(79, 70, 229, 0.2);
}

.navlinks {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.navlinks a {
  padding: 0.5rem 0.9rem;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-muted);
  border-radius: var(--radius-md);
  transition: var(--transition);
}

.navlinks a:hover {
  color: var(--text-main);
  background: rgba(0, 0, 0, 0.04);
}

.navlinks a.active {
  color: var(--primary);
  background: var(--primary-light);
  font-weight: 600;
}

.user-wrap {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.user-profile {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-full);
  background: linear-gradient(135deg, #cbd5e1, #94a3b8);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.85rem;
}

.user-info {
  display: flex;
  flex-direction: column;
}

.user-name {
  font-size: 0.85rem;
  font-weight: 600;
  line-height: 1.2;
}

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

/* ==========================================================================
   LAYOUT & CONTAINERS
   ========================================================================== */
.page {
  flex: 1;
  max-width: 1280px;
  width: 100%;
  margin: 0 auto;
  padding: 2rem 1.5rem 4rem;
}

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.section-heading h1 {
  font-size: 1.75rem;
  font-weight: 800;
}

/* Cards */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: var(--shadow-sm);
  margin-bottom: 1.5rem;
  transition: var(--transition);
}

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

.card h2 {
  font-size: 1.2rem;
  margin-bottom: 0.75rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* ==========================================================================
   HERO STATS & KPI GRID
   ========================================================================== */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1.25rem;
  margin-bottom: 1.5rem;
}

.kpi {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  transition: var(--transition);
}

.kpi:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: rgba(79, 70, 229, 0.3);
}

.kpi::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: var(--primary);
}

.kpi-info::before { background: var(--secondary); }
.kpi-success::before { background: var(--success); }
.kpi-warning::before { background: var(--warning); }
.kpi-pink::before { background: var(--purple); }

.kpi-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.kpi-value {
  font-family: var(--font-heading);
  font-size: 2rem;
  font-weight: 800;
  color: var(--text-main);
  margin: 0.4rem 0 0.2rem;
  line-height: 1.1;
}

.kpi-footer {
  font-size: 0.78rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

/* ==========================================================================
   BUTTONS & INPUTS
   ========================================================================== */
button, .primary, .btn-inline, .btn-ghost, .danger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  font-family: var(--font-sans);
  font-size: 0.875rem;
  font-weight: 600;
  padding: 0.55rem 1.15rem;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  cursor: pointer;
  transition: var(--transition);
  line-height: 1.3;
}

.primary, button.primary {
  background: var(--primary);
  color: #ffffff;
  border-color: var(--primary);
  box-shadow: 0 2px 4px rgba(79, 70, 229, 0.2);
}
.primary:hover, button.primary:hover {
  background: var(--primary-hover);
  color: #ffffff;
  box-shadow: 0 4px 10px rgba(79, 70, 229, 0.3);
}

.btn-ghost {
  background: #ffffff;
  color: var(--text-main);
  border-color: var(--border);
}
.btn-ghost:hover {
  background: #f1f5f9;
  border-color: var(--border-focus);
}

.danger, button.danger {
  background: var(--danger-light);
  color: var(--danger-text);
  border-color: rgba(239, 68, 68, 0.2);
}
.danger:hover, button.danger:hover {
  background: #fee2e2;
}

input[type="text"],
input[type="password"],
input[type="email"],
input[type="number"],
input[type="date"],
input[type="time"],
select,
textarea {
  width: 100%;
  font-family: inherit;
  font-size: 0.9rem;
  padding: 0.6rem 0.85rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  color: var(--text-main);
  transition: var(--transition);
  box-sizing: border-box;
}

input[type="time"] {
  font-weight: 600;
  cursor: pointer;
}

/* Template Auto-Expand Accordion Boxes */
.editor-card-group {
  border: 1.5px solid var(--border);
  border-radius: 12px;
  background: #ffffff;
  padding: 0.85rem 1rem;
  margin-bottom: 0.85rem;
  transition: all 0.22s ease;
  cursor: pointer;
}

.editor-card-group:hover {
  border-color: #cbd5e1;
}

.editor-card-group.expanded {
  border-color: var(--primary);
  background: #fdfcff;
  box-shadow: 0 4px 14px rgba(79, 70, 229, 0.08);
}

.editor-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: 700;
  font-size: 0.85rem;
  color: var(--text-main);
  margin-bottom: 0.4rem;
}

.editor-card-group.expanded .editor-card-header {
  color: var(--primary);
}

.editor-card-group textarea {
  transition: height 0.25s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.2s ease;
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
}

/* ==========================================================================
   DATA TABLES
   ========================================================================== */
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
  text-align: left;
}

th {
  padding: 0.75rem 1rem;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  background: #f8fafc;
  border-bottom: 1px solid var(--border);
}

td {
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

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

tbody tr:hover {
  background: #f8fafc;
}

/* Status Chips & Badges */
.status {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 0.2rem 0.55rem;
  border-radius: var(--radius-full);
  text-transform: capitalize;
}

.status-active, .status-done { background: var(--success-light); color: var(--success-text); }
.status-running { background: var(--primary-light); color: var(--primary); }
.status-scheduled { background: var(--secondary-light); color: #0369a1; }
.status-paused, .status-queued { background: var(--warning-light); color: var(--warning-text); }
.status-error, .status-cancelled { background: var(--danger-light); color: var(--danger-text); }

/* Meter Gauges */
.meter {
  height: 8px;
  background: #e2e8f0;
  border-radius: var(--radius-full);
  overflow: hidden;
  position: relative;
}

.meter-fill {
  height: 100%;
  background: linear-gradient(90deg, #10b981, #3b82f6);
  border-radius: var(--radius-full);
  transition: width 0.4s ease;
}
.meter-fill.warning { background: linear-gradient(90deg, #f59e0b, #ea580c); }
.meter-fill.danger { background: linear-gradient(90deg, #ef4444, #dc2626); }

/* Quota scroll list */
.quota-scroll-list {
  scrollbar-width: thin;
  scrollbar-color: #cbd5e1 transparent;
}
.quota-scroll-list::-webkit-scrollbar {
  width: 5px;
}
.quota-scroll-list::-webkit-scrollbar-track {
  background: transparent;
}
.quota-scroll-list::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 4px;
}
.quota-scroll-list::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}

/* ==========================================================================
   7-DAY VELOCITY ACTIVITY CHART
   ========================================================================== */
.bars {
  display: flex;
  align-items: flex-end;
  gap: 1rem;
  height: 140px;
  padding-top: 1.5rem;
}

.bar-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  height: 100%;
  justify-content: flex-end;
}

.bar {
  width: 100%;
  max-width: 44px;
  background: linear-gradient(180deg, var(--primary), #818cf8);
  border-radius: 6px 6px 0 0;
  min-height: 6px;
  position: relative;
  transition: height 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.bar:hover {
  background: linear-gradient(180deg, #3730a3, var(--primary));
}

.bar-label {
  position: absolute;
  top: -22px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-muted);
}

.bar-date {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-dim);
  margin-top: 0.5rem;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1rem;
}
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1rem; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1.15rem; }

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

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

label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 0.3rem;
}

label.inline {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  cursor: pointer;
  margin-bottom: 0;
}

/* ==========================================================================
   SENDER CARDS & SELECTION MATRIX
   ========================================================================== */
.sender-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 0.85rem;
}

.sender-card {
  background: #ffffff;
  border: 1.5px solid #cbd5e1;
  border-radius: 12px;
  padding: 0.85rem;
  cursor: pointer;
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 145px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
  transition: all 0.18s cubic-bezier(0.4, 0, 0.2, 1);
}

.sender-card:hover {
  border-color: var(--primary);
  background: #f8fafc;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(79, 70, 229, 0.12);
}

.sender-card.selected {
  border-color: var(--primary);
  background: #eef2ff;
  box-shadow: 0 0 0 2px var(--primary), 0 4px 12px rgba(79, 70, 229, 0.15);
}

.sender-cards-compact {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 0.85rem;
}

.sender-card-small {
  background: #ffffff;
  border: 1.5px solid #cbd5e1;
  border-radius: 12px;
  padding: 0.85rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
  transition: all 0.18s cubic-bezier(0.4, 0, 0.2, 1);
}

.sender-card-small:hover {
  border-color: var(--primary);
  box-shadow: 0 4px 12px rgba(79, 70, 229, 0.1);
  transform: translateY(-2px);
}

/* ==========================================================================
   SLIDE-OUT DRAWER / SIDEBAR
   ========================================================================== */
.drawer-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(4px);
  z-index: 9998;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.drawer-backdrop.active {
  opacity: 1;
  pointer-events: auto;
}

.drawer-sidebar {
  position: fixed;
  top: 0;
  right: -520px;
  bottom: 0;
  width: 100%;
  max-width: 480px;
  background: #ffffff;
  box-shadow: -10px 0 35px rgba(0, 0, 0, 0.12);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  transition: right 0.32s cubic-bezier(0.16, 1, 0.3, 1);
}

.drawer-sidebar.active {
  right: 0;
}

.drawer-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #f8fafc;
}

.drawer-body {
  padding: 1.25rem 1.5rem;
  overflow-y: auto;
  flex: 1;
}

.drawer-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border);
  background: #f8fafc;
  display: flex;
  justify-content: flex-end;
}

.flash-success { background: var(--success-light); color: var(--success-text); border: 1px solid #a7f3d0; }
.flash-error, .flash-danger { background: var(--danger-light); color: var(--danger-text); border: 1px solid #fecaca; }
.flash-warning { background: var(--warning-light); color: var(--warning-text); border: 1px solid #fde68a; }
.flash-info { background: var(--secondary-light); color: #0369a1; border: 1px solid #bae6fd; }

.muted { color: var(--text-muted); }
.hidden { display: none !important; }

/* ==========================================================================
   MODERN SAAS LOGIN EXPERIENCE
   ========================================================================== */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at 50% 10%, #e0e7ff 0%, #f8fafc 65%, #f1f5f9 100%);
  padding: 2rem 1rem;
  box-sizing: border-box;
}

.login-card {
  max-width: 440px;
  width: 100%;
  background: #ffffff;
  border: 1.5px solid #e2e8f0;
  border-radius: 18px;
  padding: 2.5rem 2.25rem;
  box-shadow: 0 20px 45px -10px rgba(79, 70, 229, 0.1), 0 0 1px 1px rgba(0, 0, 0, 0.04);
  position: relative;
  overflow: hidden;
  animation: loginFadeIn 0.35s ease-out;
}

.login-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: linear-gradient(90deg, #4f46e5, #06b6d4, #ec4899);
}

@keyframes loginFadeIn {
  from { opacity: 0; transform: translateY(12px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.login-logo {
  width: 52px;
  height: 52px;
  background: linear-gradient(135deg, #4f46e5, #3730a3);
  color: #ffffff;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.6rem;
  margin: 0 auto 1rem;
  box-shadow: 0 8px 18px rgba(79, 70, 229, 0.28);
}

.login-title {
  font-family: 'Plus Jakarta Sans', var(--font-family);
  font-size: 1.5rem;
  font-weight: 800;
  text-align: center;
  color: var(--text-main);
  margin: 0 0 0.35rem 0;
  letter-spacing: -0.02em;
}

.login-subtitle {
  font-size: 0.85rem;
  color: var(--text-muted);
  text-align: center;
  margin: 0 0 1.75rem 0;
}

.login-form .form-group {
  margin-bottom: 1.15rem;
}

.login-form label {
  display: block;
  font-size: 0.82rem;
  font-weight: 600;
  color: #334155;
  margin-bottom: 0.4rem;
}

.login-form input[type="text"],
.login-form input[type="password"],
.login-form select {
  width: 100%;
  padding: 0.7rem 0.9rem;
  border-radius: 10px;
  border: 1.5px solid #cbd5e1;
  font-size: 0.9rem;
  background: #ffffff;
  transition: all 0.2s ease;
  box-sizing: border-box;
}

.login-form input:focus,
.login-form select:focus {
  border-color: var(--primary);
  outline: none;
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.15);
  background: #faf5ff;
}

.login-btn {
  width: 100%;
  padding: 0.8rem;
  border-radius: 10px;
  background: linear-gradient(135deg, #4f46e5, #4338ca);
  color: #ffffff;
  font-size: 0.95rem;
  font-weight: 700;
  border: none;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(79, 70, 229, 0.28);
  transition: all 0.2s ease;
  margin-top: 0.5rem;
}

.login-btn:hover {
  background: linear-gradient(135deg, #4338ca, #3730a3);
  transform: translateY(-1px);
  box-shadow: 0 6px 18px rgba(79, 70, 229, 0.35);
}

.login-footer {
  margin-top: 1.75rem;
  padding-top: 1.25rem;
  border-top: 1px solid #f1f5f9;
  text-align: center;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.login-footer a {
  color: var(--primary);
  font-weight: 600;
  text-decoration: none;
}

.login-footer a:hover {
  text-decoration: underline;
}

/* ==========================================================================
   UNIVERSAL RESPONSIVE SYSTEM (Mobile, Tablet & Desktop)
   ========================================================================== */

/* Visibility Utilities */
.desktop-only {
  display: flex !important;
}
.mobile-only {
  display: none !important;
}

/* Responsive Table Wrappers */
.table-responsive {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  background: var(--surface);
  margin-bottom: 1.5rem;
}
.table-responsive table {
  width: 100%;
  min-width: 600px;
  border-collapse: collapse;
}
.table-responsive table th,
.table-responsive table td {
  white-space: nowrap;
}

/* Dashboard Analytics Grid */
.dashboard-analytics-grid {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 1.5rem;
  align-items: stretch;
}
@media (max-width: 900px) {
  .dashboard-analytics-grid {
    grid-template-columns: 1fr;
    gap: 1rem;
  }
}

/* Mobile Hamburger Toggle Button */
.mobile-menu-toggle {
  display: none;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 4px;
  width: 40px;
  height: 40px;
  padding: 8px;
  background: rgba(241, 245, 249, 0.8);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: var(--transition);
}
.mobile-menu-toggle:hover {
  background: #e2e8f0;
}
.mobile-menu-toggle .menu-bar {
  display: block;
  width: 18px;
  height: 2px;
  background: var(--text-main);
  border-radius: 2px;
  transition: all 0.2s ease;
}

/* Mobile Navigation Drawer */
.mobile-nav-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(15, 23, 42, 0.5);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 9998;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}
.mobile-nav-backdrop.active {
  opacity: 1;
  pointer-events: auto;
}

.mobile-nav-drawer {
  position: fixed;
  top: 0;
  right: -320px;
  bottom: 0;
  width: 82%;
  max-width: 320px;
  background: #ffffff;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  box-shadow: -8px 0 30px rgba(0, 0, 0, 0.15);
  transition: right 0.28s cubic-bezier(0.16, 1, 0.3, 1);
  padding: 1.25rem 1.25rem calc(1.5rem + env(safe-area-inset-bottom, 0px));
}
.mobile-nav-drawer.active {
  right: 0;
}

.mobile-drawer-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
}
.mobile-drawer-close {
  background: none;
  border: none;
  font-size: 1.25rem;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: var(--radius-sm);
}
.mobile-drawer-close:hover {
  background: #f1f5f9;
  color: var(--text-main);
}

.mobile-drawer-user {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1rem 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 1rem;
}

.mobile-drawer-links {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  flex: 1;
  overflow-y: auto;
}
.mobile-drawer-links a {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  border-radius: var(--radius-md);
  color: var(--text-main);
  font-weight: 600;
  font-size: 0.95rem;
  transition: var(--transition);
}
.mobile-drawer-links a:hover,
.mobile-drawer-links a.active {
  background: var(--primary-light);
  color: var(--primary);
}
.mobile-drawer-links a .nav-icon {
  font-size: 1.2rem;
}

.mobile-drawer-footer {
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}
.btn-logout-mobile {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  width: 100%;
  padding: 0.75rem;
  border-radius: var(--radius-md);
  background: #fef2f2;
  color: #dc2626;
  font-weight: 700;
  font-size: 0.9rem;
  text-decoration: none;
  transition: var(--transition);
}
.btn-logout-mobile:hover {
  background: #fee2e2;
}

/* Floating Mobile Bottom Navigation Bar */
.mobile-bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: space-around;
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border-top: 1px solid rgba(226, 232, 240, 0.85);
  box-shadow: 0 -4px 16px rgba(15, 23, 42, 0.06);
  padding: 0.4rem 0.5rem calc(0.4rem + env(safe-area-inset-bottom, 0px)) 0.5rem;
}

.bottom-nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.2rem;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.35rem 0.5rem;
  border-radius: var(--radius-md);
  flex: 1;
  max-width: 80px;
  transition: var(--transition);
}
.bottom-nav-item .bottom-nav-icon {
  font-size: 1.25rem;
  line-height: 1;
  transition: transform 0.15s ease;
}
.bottom-nav-item:hover,
.bottom-nav-item.active {
  color: var(--primary);
}
.bottom-nav-item.active .bottom-nav-icon {
  transform: translateY(-2px);
}
.bottom-nav-item.active .bottom-nav-label {
  font-weight: 800;
}


/* ==========================================================================
   MEDIA QUERY: TABLETS & MOBILE (<= 768px)
   ========================================================================== */
@media (max-width: 768px) {
  .desktop-only {
    display: none !important;
  }
  .mobile-only {
    display: flex !important;
  }
  
  /* Topnav responsive layout */
  .topnav {
    padding: 0.65rem 1rem;
  }
  .brand-name {
    font-size: 1.05rem;
  }
  .tenant-badge {
    padding: 0.15rem 0.5rem;
    font-size: 0.7rem;
    max-width: 140px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  /* Page container: add bottom padding to prevent bottom nav collision */
  .page {
    padding: 1.25rem 1rem calc(5rem + env(safe-area-inset-bottom, 0px)) 1rem;
  }

  .section-heading {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.75rem;
  }
  .section-heading > div:last-child {
    width: 100%;
    display: flex;
    gap: 0.5rem;
  }
  .section-heading > div:last-child a,
  .section-heading > div:last-child button {
    flex: 1;
    text-align: center;
    justify-content: center;
  }

  /* Inputs on mobile: 16px to prevent iOS Safari auto-zoom */
  input[type="text"],
  input[type="password"],
  input[type="email"],
  input[type="number"],
  input[type="date"],
  input[type="time"],
  select,
  textarea {
    font-size: 16px !important;
    padding: 0.65rem 0.85rem;
  }

  /* Touch targets for buttons */
  button, .primary, .btn-ghost, .danger {
    min-height: 42px;
    padding: 0.55rem 1rem;
  }

  /* KPI Grid scales gracefully */
  .kpi-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
  }
  .kpi {
    padding: 1rem;
  }
  .kpi-value {
    font-size: 1.5rem;
  }

  /* Cards responsive padding */
  .card {
    padding: 1.15rem;
    border-radius: var(--radius-md);
    margin-bottom: 1rem;
  }

  /* Login Card full width on mobile */
  .login-card {
    margin: 1.5rem 1rem;
    padding: 1.75rem 1.25rem;
    width: auto;
  }

  /* Compose page mobile optimizations */
  .audience-tab-group {
    width: 100%;
    margin-top: 0.5rem;
  }
  .audience-tab-btn {
    flex: 1;
    min-width: 100px;
    text-align: center;
    font-size: 0.76rem !important;
    padding: 0.4rem 0.5rem !important;
  }
  #sendBtn {
    width: 100%;
    min-height: 48px;
    font-size: 1.05rem;
  }
  #sendSummary {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
  }
}

/* ==========================================================================
   MEDIA QUERY: SMALL SMARTPHONES (<= 480px)
   ========================================================================== */
@media (max-width: 480px) {
  .kpi-grid {
    grid-template-columns: 1fr;
  }
  .grid-2, .grid-3, .grid-4 {
    grid-template-columns: 1fr !important;
  }
  .sender-cards-compact {
    grid-template-columns: 1fr !important;
  }
  .drawer-sidebar {
    max-width: 100% !important;
    width: 100% !important;
  }
  .tenant-badge {
    display: none;
  }
  .section-heading h1 {
    font-size: 1.4rem;
  }
}
