/* ==========================================================================
   META ADS + TELEGRAM TRACKER - PREMIUM DESIGN SYSTEM
   Theme: Midnight Glassmorphism & Cyberpunk Sapphire
   ========================================================================== */

:root {
  --bg-primary: #07090e;
  --bg-secondary: #0d121f;
  --bg-card: rgba(16, 24, 40, 0.7);
  --bg-card-hover: rgba(22, 33, 56, 0.85);
  --bg-card-border: rgba(255, 255, 255, 0.08);
  --bg-input: rgba(11, 17, 32, 0.8);

  --accent-blue: #3b82f6;
  --accent-cyan: #06b6d4;
  --accent-purple: #8b5cf6;
  --accent-emerald: #10b981;
  --accent-amber: #f59e0b;
  --accent-rose: #f43f5e;
  --accent-indigo: #6366f1;

  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-dark: #64748b;

  --glow-blue: 0 0 25px rgba(59, 130, 246, 0.25);
  --glow-emerald: 0 0 25px rgba(16, 185, 129, 0.25);
  --glow-rose: 0 0 25px rgba(244, 63, 94, 0.25);

  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-xl: 28px;

  --transition-fast: 0.15s ease;
  --transition-normal: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
  font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background-color: var(--bg-primary);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  overflow-x: hidden;
  line-height: 1.5;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: var(--bg-primary);
}
::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.3);
}

/* ==========================================================================
   APP LAYOUT (SIDEBAR + MAIN CONTENT)
   ========================================================================== */

.app-layout {
  display: flex;
  width: 100vw;
  min-height: 100vh;
  position: relative;
}

/* Sidebar */
.sidebar {
  width: 270px;
  background: var(--bg-secondary);
  border-right: 1px solid var(--bg-card-border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  position: sticky;
  top: 0;
  height: 100vh;
  z-index: 50;
}

.brand-section {
  padding: 24px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid var(--bg-card-border);
}

.brand-logo {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: linear-gradient(135deg, #0284c7, #2563eb, #7c3aed);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  color: #fff;
  box-shadow: 0 4px 15px rgba(37, 99, 235, 0.4);
}

.brand-text h2 {
  font-size: 1.05rem;
  font-weight: 800;
  letter-spacing: -0.01em;
  background: linear-gradient(135deg, #fff 0%, #cbd5e1 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.brand-text span {
  font-size: 0.72rem;
  color: var(--accent-cyan);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.nav-menu {
  padding: 20px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
  overflow-y: auto;
}

.nav-category {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-dark);
  font-weight: 800;
  padding: 12px 14px 4px 14px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
  border: 1px solid transparent;
}

.nav-item i {
  font-size: 1.05rem;
  width: 20px;
  text-align: center;
}

.nav-item:hover {
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-main);
  transform: translateX(2px);
}

.nav-item.active {
  background: linear-gradient(90deg, rgba(37, 99, 235, 0.18) 0%, rgba(37, 99, 235, 0.05) 100%);
  border-color: rgba(59, 130, 246, 0.3);
  color: #60a5fa;
  font-weight: 700;
  box-shadow: inset 3px 0 0 #3b82f6;
}

.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--bg-card-border);
  background: rgba(0, 0, 0, 0.2);
}

.status-badge {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: rgba(16, 185, 129, 0.08);
  border: 1px solid rgba(16, 185, 129, 0.2);
  border-radius: var(--radius-sm);
  font-size: 0.78rem;
  font-weight: 700;
  color: #34d399;
}

.dot-pulse {
  width: 8px;
  height: 8px;
  background: #10b981;
  border-radius: 50%;
  box-shadow: 0 0 10px #10b981;
  animation: pulse-ring 2s infinite;
}

@keyframes pulse-ring {
  0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7); }
  70% { transform: scale(1); box-shadow: 0 0 0 8px rgba(16, 185, 129, 0); }
  100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

/* Main Content Area */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: radial-gradient(circle at 50% 0%, rgba(37, 99, 235, 0.08) 0%, rgba(7, 9, 14, 0) 50%);
}

/* Header */
.top-header {
  height: 72px;
  border-bottom: 1px solid var(--bg-card-border);
  background: rgba(13, 18, 31, 0.85);
  backdrop-filter: blur(16px);
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 32px;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 18px;
}

.page-title {
  font-size: 1.25rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

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

.filter-pills {
  display: flex;
  background: rgba(255, 255, 255, 0.04);
  padding: 4px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--bg-card-border);
}

.filter-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 0.78rem;
  font-weight: 700;
  padding: 6px 14px;
  border-radius: 6px;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.filter-btn:hover {
  color: var(--text-main);
}

.filter-btn.active {
  background: var(--accent-blue);
  color: #fff;
  box-shadow: 0 2px 10px rgba(59, 130, 246, 0.4);
}

.content-body {
  padding: 32px;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 28px;
}

/* View Sections */
.view-section {
  display: none;
  flex-direction: column;
  gap: 28px;
  animation: fadeIn 0.25s ease-out;
}

.view-section.active {
  display: flex;
}

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

/* ==========================================================================
   CARDS & METRIC WIDGETS
   ========================================================================== */

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 18px;
}

.metric-card {
  background: var(--bg-card);
  backdrop-filter: blur(14px);
  border: 1px solid var(--bg-card-border);
  border-radius: var(--radius-md);
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  position: relative;
  overflow: hidden;
  transition: all var(--transition-normal);
}

.metric-card:hover {
  transform: translateY(-2px);
  border-color: rgba(255, 255, 255, 0.15);
  box-shadow: 0 12px 30px -10px rgba(0, 0, 0, 0.5);
}

.metric-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 3px;
  background: linear-gradient(90deg, var(--card-accent, #3b82f6), transparent);
}

.metric-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

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

.metric-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.04);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  color: var(--card-accent, #3b82f6);
}

.metric-value {
  font-size: 1.85rem;
  font-weight: 800;
  color: var(--text-main);
  letter-spacing: -0.02em;
}

.metric-sub {
  font-size: 0.78rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 6px;
}

.metric-sub b {
  color: var(--accent-emerald);
}

/* ==========================================================================
   VISUAL FUNNEL FLOW COMPONENT
   ========================================================================== */

.funnel-card {
  background: var(--bg-card);
  backdrop-filter: blur(14px);
  border: 1px solid var(--bg-card-border);
  border-radius: var(--radius-lg);
  padding: 28px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.card-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.card-title {
  font-size: 1.15rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  gap: 10px;
}

.funnel-pipeline {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  position: relative;
}

.funnel-step {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--bg-card-border);
  border-radius: var(--radius-md);
  padding: 18px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  position: relative;
  transition: all var(--transition-fast);
}

.funnel-step:hover {
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(59, 130, 246, 0.4);
}

.step-badge {
  font-size: 0.72rem;
  font-weight: 800;
  color: var(--accent-cyan);
  text-transform: uppercase;
}

.step-name {
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--text-main);
}

.step-count {
  font-size: 1.6rem;
  font-weight: 900;
  color: #fff;
  letter-spacing: -0.02em;
}

.step-bar-wrap {
  width: 100%;
  height: 6px;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 4px;
  overflow: hidden;
  margin-top: 4px;
}

.step-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #38bdf8, #2563eb);
  border-radius: 4px;
  transition: width 0.6s ease;
}

.step-dropoff {
  font-size: 0.72rem;
  color: #f87171;
  font-weight: 700;
  margin-top: 4px;
}

/* ==========================================================================
   DATA TABLES
   ========================================================================== */

.table-card {
  background: var(--bg-card);
  backdrop-filter: blur(14px);
  border: 1px solid var(--bg-card-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.table-header-bar {
  padding: 20px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--bg-card-border);
  flex-wrap: wrap;
  gap: 14px;
}

.table-search-box {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg-input);
  border: 1px solid var(--bg-card-border);
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  width: 320px;
}

.table-search-box input {
  background: transparent;
  border: none;
  outline: none;
  color: var(--text-main);
  font-size: 0.85rem;
  width: 100%;
}

.table-search-box i {
  color: var(--text-dark);
}

.table-responsive {
  width: 100%;
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.86rem;
}

th {
  background: rgba(255, 255, 255, 0.02);
  color: var(--text-muted);
  font-weight: 700;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 14px 20px;
  border-bottom: 1px solid var(--bg-card-border);
}

td {
  padding: 16px 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  color: var(--text-main);
  vertical-align: middle;
}

tr:hover td {
  background: rgba(255, 255, 255, 0.02);
}

/* Status Badges */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 100px;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.pill-green {
  background: rgba(16, 185, 129, 0.15);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.pill-blue {
  background: rgba(59, 130, 246, 0.15);
  color: #60a5fa;
  border: 1px solid rgba(59, 130, 246, 0.3);
}

.pill-yellow {
  background: rgba(245, 158, 11, 0.15);
  color: #fbbf24;
  border: 1px solid rgba(245, 158, 11, 0.3);
}

.pill-red {
  background: rgba(244, 63, 94, 0.15);
  color: #fb7185;
  border: 1px solid rgba(244, 63, 94, 0.3);
}

.pill-gray {
  background: rgba(148, 163, 184, 0.1);
  color: #94a3b8;
  border: 1px solid rgba(148, 163, 184, 0.2);
}

/* ==========================================================================
   BUTTONS & FORMS
   ========================================================================== */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  font-size: 0.86rem;
  font-weight: 700;
  cursor: pointer;
  border: none;
  transition: all var(--transition-fast);
  text-decoration: none;
}

.btn-primary {
  background: linear-gradient(135deg, #0284c7, #2563eb);
  color: #fff;
  box-shadow: 0 4px 15px rgba(37, 99, 235, 0.35);
}

.btn-primary:hover {
  background: linear-gradient(135deg, #0ea5e9, #3b82f6);
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(37, 99, 235, 0.45);
}

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

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

.btn-success {
  background: #10b981;
  color: #fff;
}

.btn-danger {
  background: rgba(244, 63, 94, 0.2);
  color: #f43f5e;
  border: 1px solid rgba(244, 63, 94, 0.3);
}

.btn-danger:hover {
  background: #f43f5e;
  color: #fff;
}

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

/* Form Styles */
.form-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 20px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.form-group.full {
  grid-column: 1 / -1;
}

.form-label {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-muted);
}

.form-input, .form-textarea, .form-select {
  background: var(--bg-input);
  border: 1px solid var(--bg-card-border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  color: var(--text-main);
  font-family: inherit;
  font-size: 0.9rem;
  outline: none;
  transition: border-color var(--transition-fast);
}

.form-input:focus, .form-textarea:focus, .form-select:focus {
  border-color: var(--accent-blue);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

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

.form-hint {
  font-size: 0.75rem;
  color: var(--text-dark);
}

/* ==========================================================================
   MODAL WINDOW
   ========================================================================== */

.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(8px);
  z-index: 100;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-overlay.active {
  display: flex;
  animation: fadeIn 0.2s ease-out;
}

.modal-dialog {
  background: #0f1629;
  border: 1px solid var(--bg-card-border);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 680px;
  max-height: 90vh;
  height: auto;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 25px 60px -15px rgba(0, 0, 0, 0.8);
}

.modal-dialog form {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  flex: 1;
  min-height: 0;
  max-height: calc(90vh - 65px);
}

.modal-header {
  padding: 18px 24px;
  border-bottom: 1px solid var(--bg-card-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
  background: #0d1424;
}

.modal-title {
  font-size: 1.15rem;
  font-weight: 800;
}

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

.modal-body {
  padding: 24px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  display: flex;
  flex-direction: column;
  gap: 18px;
  flex: 1;
  min-height: 0;
}

.modal-body::-webkit-scrollbar {
  width: 6px;
}
.modal-body::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.02);
}
.modal-body::-webkit-scrollbar-thumb {
  background: rgba(14, 165, 233, 0.35);
  border-radius: 4px;
}

.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--bg-card-border);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  background: #0a0f1d;
  flex-shrink: 0;
  position: relative;
  z-index: 5;
}

/* ==========================================================================
   USER JOURNEY TIMELINE
   ========================================================================== */

.timeline {
  display: flex;
  flex-direction: column;
  gap: 18px;
  position: relative;
  padding-left: 28px;
}

.timeline::before {
  content: '';
  position: absolute;
  top: 10px;
  bottom: 10px;
  left: 8px;
  width: 2px;
  background: rgba(255, 255, 255, 0.1);
}

.timeline-item {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.timeline-dot {
  position: absolute;
  left: -28px;
  top: 2px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #0f172a;
  border: 2px solid var(--accent-blue);
  display: flex;
  align-items: center;
  justify-content: center;
}

.timeline-dot.green {
  border-color: #10b981;
}

.timeline-time {
  font-size: 0.72rem;
  color: var(--text-dark);
}

.timeline-title {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--text-main);
}

.timeline-desc {
  font-size: 0.82rem;
  color: var(--text-muted);
  background: rgba(255, 255, 255, 0.02);
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(255, 255, 255, 0.04);
}

/* Toast Notifications */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.toast {
  background: #1e293b;
  border: 1px solid var(--bg-card-border);
  color: #fff;
  padding: 12px 20px;
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 10px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
  animation: slideUp 0.25s ease-out;
}

.toast.success {
  border-color: rgba(16, 185, 129, 0.5);
  background: #064e3b;
}

.toast.error {
  border-color: rgba(244, 63, 94, 0.5);
  background: #881337;
}

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

/* ==========================================================================
   MOBILE-FIRST & RESPONSIVE DESIGN SYSTEM
   ========================================================================== */

.mobile-toggle-btn {
  display: none;
  width: 42px;
  height: 42px;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--bg-card-border);
  color: #fff;
  cursor: pointer;
  font-size: 1.15rem;
  transition: all 0.2s ease;
  flex-shrink: 0;
  -webkit-tap-highlight-color: transparent;
}

.mobile-toggle-btn:hover, .mobile-toggle-btn:active {
  background: rgba(14, 165, 233, 0.15);
  border-color: #38bdf8;
  color: #38bdf8;
}

.sidebar-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(5, 7, 13, 0.75);
  backdrop-filter: blur(5px);
  z-index: 85;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.sidebar-backdrop.open {
  opacity: 1;
  pointer-events: auto;
}

#btnToggleLoginPass:hover {
  color: #38bdf8 !important;
}

#login_password:focus {
  border-color: #38bdf8 !important;
  box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.2), 0 0 20px rgba(56, 189, 248, 0.15) !important;
}

/* Tablet & Mobile Screens */
@media (max-width: 992px) {
  .mobile-toggle-btn {
    display: flex;
  }

  .app-layout {
    position: relative;
    overflow-x: hidden;
  }

  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 285px;
    height: 100vh;
    z-index: 95;
    transform: translateX(-100%);
    transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 10px 0 40px rgba(0, 0, 0, 0.85);
    background: #0d121f;
  }

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

  .top-header {
    padding: 12px 18px;
    height: auto;
    flex-wrap: wrap;
    gap: 12px;
  }

  .header-left {
    gap: 12px;
  }

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

  .header-right {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    overflow-x: auto;
    padding-bottom: 4px;
    gap: 8px;
    -webkit-overflow-scrolling: touch;
  }

  .filter-pills {
    flex-shrink: 0;
  }

  .header-right .btn {
    white-space: nowrap;
    flex-shrink: 0;
  }

  .content-body {
    padding: 16px;
    gap: 20px;
  }

  .metrics-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
  }

  .funnel-pipeline {
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
  }

  /* Two columns grids collapse to 1 */
  div[style*="grid-template-columns: 1.2fr 1.8fr"],
  div[style*="grid-template-columns: 1fr 1fr"],
  div[style*="grid-template-columns:1fr 1fr"] {
    grid-template-columns: 1fr !important;
  }

  .form-grid {
    grid-template-columns: 1fr !important;
  }

  .form-group.full {
    grid-column: span 1 !important;
  }

  /* Modals on mobile: fluid viewport fit */
  .modal-dialog {
    width: calc(100vw - 24px) !important;
    max-width: 100% !important;
    margin: 12px auto !important;
    max-height: 92vh;
    border-radius: 18px !important;
    overflow-y: auto;
  }

  /* iOS font zoom prevention */
  .form-input, .form-select, .form-textarea {
    font-size: 16px !important;
  }

  /* Touch-friendly buttons */
  .btn {
    min-height: 42px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }
}

/* Small Phones */
@media (max-width: 580px) {
  .metrics-grid {
    grid-template-columns: 1fr;
  }

  .funnel-pipeline {
    grid-template-columns: 1fr;
  }

  .metric-value {
    font-size: 1.6rem;
  }

  .top-header {
    padding: 10px 14px;
  }

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

  .filter-pills {
    width: 100%;
    display: flex;
    justify-content: space-between;
  }

  .filter-btn {
    flex: 1;
    text-align: center;
    padding: 6px 6px;
    font-size: 0.72rem;
  }

  .header-right {
    flex-wrap: wrap;
  }

  .card-title-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }

  .table-header-bar {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }

  .table-header-bar button, .table-header-bar a {
    width: 100%;
    justify-content: center;
  }
}
