/* ==============================================================================
   THINK GROW MEDIA (TGM) REPORTING STUDIO - LUXURY AGENCY DESIGN SYSTEM
   Brand Colors: Crimson Red (#DA0D0A), Flame (#FF1A44), Obsidian (#070311/#0E0620),
   Gold (#FFCD57), Electric Violet (#C10FFF), Emerald (#10B981)
   Fully Responsive Across Mobile, Tablet, Laptop, and Large Displays
   ============================================================================== */

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

:root {
  /* Think Grow Media Core Brand Colors */
  --tgm-crimson: #da0d0a;
  --tgm-crimson-dark: #b50b08;
  --tgm-crimson-deep: #8e0806;
  --tgm-flame: #ff1a44;
  --tgm-flame-light: #ff4d6d;
  
  /* Midnight Obsidian Palette */
  --bg-primary: #070311;
  --bg-secondary: #0e0620;
  --bg-card: rgba(18, 9, 36, 0.78);
  --bg-card-hover: rgba(28, 14, 54, 0.90);
  --bg-card-active: #1d0e3a;
  --bg-input: rgba(13, 6, 28, 0.88);
  
  /* Specular & Glass Borders with TGM Accent Glow */
  --border-color: rgba(255, 255, 255, 0.08);
  --border-color-hover: rgba(218, 13, 10, 0.45);
  --border-glow: rgba(218, 13, 10, 0.35);
  --border-specular: inset 0 1px 0 0 rgba(255, 255, 255, 0.12);

  /* High Contrast Typography */
  --text-primary: #ffffff;
  --text-secondary: #cbd5e1;
  --text-muted: #808b9e;
  --text-dim: #546073;
  
  /* Curated Vibrant Brand Accents */
  --accent-red: #da0d0a;
  --accent-red-light: #ff3b5c;
  --accent-red-glow: rgba(218, 13, 10, 0.45);
  
  --accent-flame: #ff1a44;
  --accent-flame-light: #ff4d6d;
  --accent-flame-glow: rgba(255, 26, 68, 0.4);
  
  --accent-gold: #ffcd57;
  --accent-gold-light: #ffe08a;
  --accent-gold-glow: rgba(255, 205, 87, 0.35);
  
  --accent-violet: #c10fff;
  --accent-violet-light: #d946ef;
  --accent-violet-glow: rgba(193, 15, 255, 0.35);
  
  --accent-emerald: #10b981;
  --accent-emerald-light: #34d399;
  --accent-emerald-glow: rgba(16, 185, 129, 0.3);
  
  --accent-cyan: #06b6d4;
  --accent-cyan-light: #38bdf8;
  --accent-cyan-glow: rgba(6, 182, 212, 0.3);
  
  --accent-indigo: #6366f1;
  --accent-indigo-light: #818cf8;
  --accent-indigo-glow: rgba(99, 102, 241, 0.35);

  /* Ad Platform Official Palette */
  --color-meta: #0081fb;
  --color-google: #4285f4;
  --color-linkedin: #0a66c2;
  --color-tiktok: #fe2c55;
  --color-snapchat: #fffc00;

  /* Typography Stacks */
  --font-display: 'Outfit', 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-sans: 'Inter', 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;

  /* Radii & Shadows */
  --radius-xs: 6px;
  --radius-sm: 10px;
  --radius-md: 14px;
  --radius-lg: 18px;
  --radius-xl: 24px;
  
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.35);
  --shadow-card: 0 10px 30px -10px rgba(0, 0, 0, 0.65), inset 0 1px 0 0 rgba(255, 255, 255, 0.08);
  --shadow-card-hover: 0 20px 40px -15px rgba(0, 0, 0, 0.85), 0 0 25px rgba(218, 13, 10, 0.18), inset 0 1px 0 0 rgba(255, 255, 255, 0.15);
  --shadow-glow: 0 0 25px -5px var(--accent-red-glow);
  
  --transition: all 0.22s cubic-bezier(0.16, 1, 0.3, 1);
  --transition-smooth: all 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

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

html {
  color-scheme: dark;
  scroll-behavior: smooth;
  font-size: 16px;
}

body {
  font-family: var(--font-sans);
  background-color: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  background-image: 
    radial-gradient(at 0% 0%, rgba(218, 13, 10, 0.14) 0px, transparent 55%),
    radial-gradient(at 100% 0%, rgba(193, 15, 255, 0.09) 0px, transparent 50%),
    radial-gradient(at 50% 100%, rgba(255, 26, 68, 0.08) 0px, transparent 50%),
    radial-gradient(rgba(255, 255, 255, 0.04) 1px, transparent 1px);
  background-size: 100% 100%, 100% 100%, 100% 100%, 32px 32px;
  background-attachment: fixed;
  overflow-x: hidden;
}

/* Luxury Think Grow Media Scrollbar */
::-webkit-scrollbar {
  width: 7px;
  height: 7px;
}
::-webkit-scrollbar-track {
  background: var(--bg-primary);
}
::-webkit-scrollbar-thumb {
  background: rgba(218, 13, 10, 0.35);
  border-radius: 10px;
}
::-webkit-scrollbar-thumb:hover {
  background: rgba(218, 13, 10, 0.65);
}

/* Selection */
::selection {
  background: rgba(218, 13, 10, 0.4);
  color: #ffffff;
}

/* ==============================================================================
   TOP HEADER & NAVIGATION - 2-TIER ARCHITECTURE
   Guarantees Brand, Status, Client Select & Sync Button Never Cut Off
   ============================================================================== */
.app-header {
  position: sticky;
  top: 0;
  z-index: 60;
  background: rgba(10, 5, 24, 0.94);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border-bottom: 1px solid var(--border-color);
  padding: 0.85rem 2rem 0.65rem 2rem;
  transition: var(--transition);
}

.header-container {
  max-width: 1680px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

/* Header Main Row: Brand (left) & Controls (right) */
.header-main-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.25rem;
  width: 100%;
}

/* Brand Identity */
.brand {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  text-decoration: none;
  flex-shrink: 0;
}

.brand-logo-container {
  width: 44px;
  height: 44px;
  border-radius: 11px;
  background: linear-gradient(135deg, rgba(218, 13, 10, 0.22), rgba(17, 7, 41, 0.9));
  border: 1px solid rgba(218, 13, 10, 0.45);
  box-shadow: 0 0 18px -2px rgba(218, 13, 10, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 5px;
  transition: var(--transition);
  flex-shrink: 0;
}

.brand-logo-container:hover {
  transform: scale(1.05);
  border-color: var(--tgm-crimson);
  box-shadow: 0 0 26px rgba(218, 13, 10, 0.75);
}

.brand-logo-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  filter: drop-shadow(0 2px 5px rgba(0, 0, 0, 0.5));
}

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

.brand-title-wrap h1 {
  font-family: var(--font-display);
  font-size: 1.3rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  background: linear-gradient(135deg, #ffffff 40%, #e2e8f0 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  line-height: 1.2;
}

.brand-badge {
  font-family: var(--font-mono);
  font-size: 0.62rem;
  font-weight: 700;
  padding: 0.16rem 0.52rem;
  border-radius: 5px;
  background: linear-gradient(135deg, rgba(218, 13, 10, 0.28), rgba(255, 26, 68, 0.16));
  border: 1px solid rgba(218, 13, 10, 0.55);
  color: var(--tgm-flame-light);
  letter-spacing: 0.05em;
  -webkit-text-fill-color: var(--tgm-flame-light);
  white-space: nowrap;
}

.brand-text p {
  font-size: 0.74rem;
  color: var(--text-muted);
  font-weight: 500;
  margin-top: 1px;
}

/* Header Controls */
.header-controls {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  flex-shrink: 0;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.38rem 0.85rem;
  border-radius: 20px;
  font-size: 0.74rem;
  font-weight: 600;
  background: rgba(16, 185, 129, 0.12);
  border: 1px solid rgba(16, 185, 129, 0.3);
  color: #34d399;
  white-space: nowrap;
  flex-shrink: 0;
}

.pulse-radar {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #10b981;
  position: relative;
  box-shadow: 0 0 8px #10b981;
}

.pulse-radar::after {
  content: '';
  position: absolute;
  top: -3px;
  left: -3px;
  right: -3px;
  bottom: -3px;
  border-radius: 50%;
  border: 1px solid #10b981;
  animation: radarPing 1.8s cubic-bezier(0, 0, 0.2, 1) infinite;
}

@keyframes radarPing {
  0% { transform: scale(1); opacity: 0.8; }
  100% { transform: scale(2.8); opacity: 0; }
}

.client-select-wrap {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: rgba(18, 9, 38, 0.85);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 0.38rem 0.75rem;
  transition: var(--transition);
  flex-shrink: 0;
}

.client-select-wrap:hover {
  border-color: var(--border-color-hover);
  background: rgba(28, 14, 54, 0.95);
}

.client-avatar-dot {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--tgm-crimson), var(--tgm-flame));
  display: grid;
  place-items: center;
  font-size: 0.62rem;
  font-weight: 700;
  color: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.25);
  box-shadow: 0 0 8px rgba(218, 13, 10, 0.5);
  flex-shrink: 0;
}

.client-select-wrap label {
  font-size: 0.72rem;
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

.select-client {
  background: transparent;
  border: none;
  color: #ffffff;
  font-size: 0.82rem;
  font-weight: 600;
  outline: none;
  cursor: pointer;
  padding-right: 0.35rem;
  font-family: inherit;
  min-width: 140px;
}

.select-client option {
  background: #0e0620;
  color: #ffffff;
  padding: 8px;
}

#btn-open-sync-modal {
  white-space: nowrap;
  flex-shrink: 0;
}

/* Header Navigation Bar Row */
.header-nav-row {
  display: flex;
  align-items: center;
  width: 100%;
}

.nav-tabs {
  display: flex;
  align-items: center;
  background: rgba(14, 7, 32, 0.75);
  padding: 0.28rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  gap: 0.25rem;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.5);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.nav-tabs::-webkit-scrollbar {
  height: 3px;
}

.nav-tab-btn {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  padding: 0.48rem 1.05rem;
  border-radius: 8px;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  transition: var(--transition);
  position: relative;
  letter-spacing: -0.01em;
  white-space: nowrap;
  flex-shrink: 0;
}

.nav-tab-btn:hover {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.06);
}

.nav-tab-btn.active {
  color: #ffffff;
  background: linear-gradient(135deg, rgba(218, 13, 10, 0.35), rgba(181, 11, 8, 0.45));
  border: 1px solid rgba(218, 13, 10, 0.65);
  box-shadow: 0 4px 14px -2px rgba(218, 13, 10, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

.nav-tab-btn svg {
  width: 15px;
  height: 15px;
  opacity: 0.85;
}
.nav-tab-btn.active svg {
  opacity: 1;
  color: var(--tgm-flame-light);
}

/* ==============================================================================
   BUTTON SYSTEM (Think Grow Media Crimson Palette)
   ============================================================================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.54rem 1.2rem;
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  transition: var(--transition);
  text-decoration: none;
  font-family: inherit;
  letter-spacing: -0.01em;
  user-select: none;
}

.btn-primary {
  background: linear-gradient(135deg, var(--tgm-crimson) 0%, var(--tgm-crimson-dark) 50%, var(--tgm-crimson-deep) 100%);
  color: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.18);
  box-shadow: 0 4px 18px -2px rgba(218, 13, 10, 0.55), inset 0 1px 0 rgba(255, 255, 255, 0.25);
}

.btn-primary:hover {
  transform: translateY(-1px);
  background: linear-gradient(135deg, var(--tgm-flame) 0%, var(--tgm-crimson) 50%, var(--tgm-crimson-dark) 100%);
  box-shadow: 0 6px 26px -2px rgba(218, 13, 10, 0.75), inset 0 1px 0 rgba(255, 255, 255, 0.35);
}

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

.btn-secondary {
  background: rgba(22, 11, 46, 0.75);
  color: #ffffff;
  border: 1px solid var(--border-color);
  box-shadow: inset 0 1px 0 0 rgba(255, 255, 255, 0.08);
}

.btn-secondary:hover {
  background: rgba(34, 18, 68, 0.9);
  border-color: var(--border-color-hover);
  color: #ffffff;
}

.btn-success {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  color: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.18);
  box-shadow: 0 4px 16px -2px rgba(16, 185, 129, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.25);
}
.btn-success:hover {
  background: linear-gradient(135deg, #34d399 0%, #10b981 100%);
  box-shadow: 0 6px 22px -2px rgba(16, 185, 129, 0.7);
}

.btn-outline {
  background: transparent;
  border-color: var(--border-color);
  color: var(--text-secondary);
}
.btn-outline:hover {
  color: #ffffff;
  border-color: var(--border-color-hover);
  background: rgba(255, 255, 255, 0.05);
}

.btn-sm {
  padding: 0.38rem 0.75rem;
  font-size: 0.76rem;
  border-radius: var(--radius-xs);
}

/* ==============================================================================
   MAIN CONTENT & LAYOUT
   ============================================================================== */
.main-content {
  max-width: 1680px;
  margin: 0 auto;
  padding: 1.75rem 2rem 4rem 2rem;
}

.tab-pane {
  display: none;
  animation: pageFadeIn 0.28s cubic-bezier(0.16, 1, 0.3, 1);
}

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

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

/* Page Title Bar */
.page-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.75rem;
  flex-wrap: wrap;
  gap: 1.25rem;
  padding-bottom: 1.25rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.page-title-row h2 {
  font-family: var(--font-display);
  font-size: 1.6rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  background: linear-gradient(135deg, #ffffff 30%, #cbd5e1 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.page-title-row p {
  color: var(--text-secondary);
  font-size: 0.85rem;
  margin-top: 0.25rem;
}

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

/* Timeframe Segmented Control */
.timeframe-toggle {
  display: flex;
  background: rgba(14, 7, 32, 0.85);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 3px;
  gap: 3px;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.4);
}

.btn-tf {
  background: transparent;
  border: none;
  border-radius: 7px;
  padding: 6px 15px;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  color: var(--text-muted);
  transition: var(--transition);
}

.btn-tf:hover {
  color: #ffffff;
}

.btn-tf.active {
  background: linear-gradient(135deg, var(--tgm-crimson), var(--tgm-crimson-dark));
  color: #ffffff;
  box-shadow: 0 2px 10px rgba(218, 13, 10, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.25);
}

/* ==============================================================================
   TIER 1 & TIER 2 KPI SCORECARDS
   ============================================================================== */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1.15rem;
  margin-bottom: 1.75rem;
}

.kpi-card {
  background: var(--bg-card);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.25rem 1.35rem;
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow-card);
  transition: var(--transition-smooth);
}

.kpi-card:hover {
  transform: translateY(-3px);
  border-color: var(--border-color-hover);
  box-shadow: var(--shadow-card-hover);
}

/* Ambient glow accent top rim */
.kpi-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--card-accent, var(--tgm-crimson)), transparent);
  opacity: 0.95;
}

/* Ambient radial glow bloom on card */
.kpi-card::after {
  content: '';
  position: absolute;
  top: -40px;
  right: -40px;
  width: 100px;
  height: 100px;
  border-radius: 50%;
  background: var(--card-accent, var(--tgm-crimson));
  opacity: 0.12;
  filter: blur(30px);
  pointer-events: none;
}

.kpi-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.75rem;
}

.kpi-label {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}

.kpi-icon-wrap {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  display: grid;
  place-items: center;
  font-size: 0.95rem;
  color: var(--card-accent, var(--tgm-flame-light));
  transition: var(--transition);
}

.kpi-card:hover .kpi-icon-wrap {
  transform: scale(1.1);
  background: rgba(255, 255, 255, 0.08);
}

.kpi-value {
  font-family: var(--font-display);
  font-size: 1.85rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: #ffffff;
  margin-bottom: 0.35rem;
  font-variant-numeric: tabular-nums lining-nums;
  font-feature-settings: 'tnum' 1, 'lnum' 1;
  line-height: 1.15;
}

.kpi-sub {
  font-size: 0.75rem;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-weight: 500;
}

.kpi-sub.positive {
  color: var(--accent-emerald-light);
}

.kpi-badge-chip {
  font-size: 0.68rem;
  font-weight: 700;
  padding: 0.15rem 0.45rem;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--text-muted);
}

/* Mini Progress Bar for Funnel Rates */
.kpi-progress-bar {
  width: 100%;
  height: 4px;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 2px;
  margin-top: 0.5rem;
  overflow: hidden;
  position: relative;
}

.kpi-progress-fill {
  height: 100%;
  border-radius: 2px;
  background: linear-gradient(90deg, var(--card-accent, var(--tgm-crimson)), var(--tgm-flame));
}

/* ==============================================================================
   CHARTS & GRAPHS
   ============================================================================== */
.charts-grid {
  display: grid;
  grid-template-columns: 2.2fr 1fr;
  gap: 1.35rem;
  margin-bottom: 1.75rem;
}

.card {
  background: var(--bg-card);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.35rem;
  box-shadow: var(--shadow-card);
  transition: var(--transition);
}

.card:hover {
  border-color: var(--border-color-hover);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
}

.card-title {
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 0.55rem;
  letter-spacing: -0.02em;
  color: #ffffff;
}

.card-badge {
  font-size: 0.7rem;
  padding: 0.22rem 0.65rem;
  border-radius: 20px;
  background: rgba(218, 13, 10, 0.15);
  border: 1px solid rgba(218, 13, 10, 0.35);
  color: var(--tgm-flame-light);
  font-weight: 600;
  letter-spacing: 0.02em;
}

.chart-wrapper {
  position: relative;
  height: 330px;
  width: 100%;
}

/* ==============================================================================
   DATA TABLES (Platform Matrix & Nomenclature)
   ============================================================================== */
.table-card {
  background: var(--bg-card);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: var(--shadow-card);
  margin-bottom: 1.75rem;
  transition: var(--transition);
}

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

table.data-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  text-align: left;
  font-size: 0.83rem;
}

table.data-table th {
  background: rgba(14, 7, 32, 0.95);
  backdrop-filter: blur(12px);
  padding: 0.9rem 1.15rem;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border-color);
  white-space: nowrap;
}

table.data-table td {
  padding: 0.9rem 1.15rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums lining-nums;
  font-feature-settings: 'tnum' 1, 'lnum' 1;
  white-space: nowrap;
  transition: background 0.15s ease;
}

table.data-table tr:hover td {
  background: rgba(255, 255, 255, 0.03);
  color: #ffffff;
}

/* ROAS Quality Badges */
.badge-roas {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  font-weight: 700;
  padding: 0.2rem 0.55rem;
  border-radius: 6px;
  font-size: 0.78rem;
  font-variant-numeric: tabular-nums;
}

.badge-roas.tier-high {
  background: rgba(16, 185, 129, 0.15);
  border: 1px solid rgba(16, 185, 129, 0.35);
  color: #34d399;
  box-shadow: 0 0 10px rgba(16, 185, 129, 0.15);
}

.badge-roas.tier-mid {
  background: rgba(255, 205, 87, 0.15);
  border: 1px solid rgba(255, 205, 87, 0.35);
  color: #ffcd57;
}

.badge-roas.tier-low {
  background: rgba(218, 13, 10, 0.15);
  border: 1px solid rgba(218, 13, 10, 0.35);
  color: #ff4d6d;
}

/* Rate Pill with Micro Meter */
.rate-cell {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 65px;
}

.rate-micro-bar {
  width: 100%;
  height: 3px;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 2px;
  overflow: hidden;
}

.rate-micro-fill {
  height: 100%;
  border-radius: 2px;
  background: var(--tgm-crimson);
}

/* Platform Brand Pills */
.platform-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 700;
  padding: 0.28rem 0.75rem;
  border-radius: 20px;
  font-size: 0.75rem;
  color: #ffffff;
  letter-spacing: -0.01em;
}

.platform-pill.meta { 
  background: rgba(0, 129, 251, 0.15); 
  color: #60a5fa; 
  border: 1px solid rgba(0, 129, 251, 0.35); 
}
.platform-pill.google { 
  background: rgba(66, 133, 244, 0.15); 
  color: #93c5fd; 
  border: 1px solid rgba(66, 133, 244, 0.35); 
}
.platform-pill.linkedin { 
  background: rgba(10, 102, 194, 0.15); 
  color: #38bdf8; 
  border: 1px solid rgba(10, 102, 194, 0.35); 
}
.platform-pill.tiktok { 
  background: rgba(254, 44, 85, 0.15); 
  color: #fda4af; 
  border: 1px solid rgba(254, 44, 85, 0.35); 
}
.platform-pill.snapchat { 
  background: rgba(255, 252, 0, 0.12); 
  color: #fef08a; 
  border: 1px solid rgba(255, 252, 0, 0.3); 
}

/* ==============================================================================
   WEEKLY NOMENCLATURE FILTER PILLS
   ============================================================================== */
.nomen-pills-bar {
  display: flex;
  gap: 0.45rem;
  padding: 0.75rem 1.35rem 1rem 1.35rem;
  overflow-x: auto;
  border-bottom: 1px solid var(--border-color);
  background: rgba(11, 5, 25, 0.45);
  -webkit-overflow-scrolling: touch;
}

.nomen-pills-bar::-webkit-scrollbar {
  height: 4px;
}

.btn-nomen {
  background: rgba(22, 11, 46, 0.65);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  border-radius: 20px;
  padding: 0.4rem 0.95rem;
  font-size: 0.74rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: var(--transition);
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  letter-spacing: 0.02em;
}

.btn-nomen:hover {
  background: rgba(34, 18, 68, 0.9);
  color: #ffffff;
  border-color: var(--border-color-hover);
}

.btn-nomen.active {
  background: linear-gradient(135deg, var(--tgm-crimson) 0%, var(--tgm-crimson-dark) 100%);
  color: #ffffff;
  border-color: rgba(255, 255, 255, 0.35);
  box-shadow: 0 4px 16px -2px rgba(218, 13, 10, 0.55), inset 0 1px 0 rgba(255, 255, 255, 0.25);
}

/* Table Quick Search */
.table-search-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1.35rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  gap: 1rem;
}

.search-input-wrap {
  position: relative;
  max-width: 360px;
  width: 100%;
}

.search-input-wrap svg {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  width: 14px;
  height: 14px;
}

.search-input-wrap input {
  width: 100%;
  background: rgba(14, 7, 32, 0.85);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 0.45rem 0.75rem 0.45rem 2.1rem;
  font-size: 0.78rem;
  color: #ffffff;
  outline: none;
  transition: var(--transition);
  font-family: inherit;
}

.search-input-wrap input:focus {
  border-color: var(--tgm-crimson);
  box-shadow: 0 0 0 3px rgba(218, 13, 10, 0.25);
}

/* ==============================================================================
   CONNECTORS & WAREHOUSE CONFIG CARDS
   ============================================================================== */
.connectors-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
  gap: 1.35rem;
}

.connector-card {
  background: var(--bg-card);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.5rem;
  box-shadow: var(--shadow-card);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  transition: var(--transition);
}

.connector-card:hover {
  border-color: var(--border-color-hover);
  transform: translateY(-2px);
  box-shadow: var(--shadow-card-hover);
}

.connector-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
}

.connector-brand {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.connector-brand-icon {
  width: 42px;
  height: 42px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  font-size: 1.25rem;
  font-weight: 700;
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.15);
}

.connector-brand-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.05rem;
  color: #ffffff;
}

.connector-brand-desc {
  font-size: 0.74rem;
  color: var(--text-muted);
}

/* Form Elements */
.form-group {
  margin-bottom: 0.95rem;
}

.form-group label {
  display: block;
  font-size: 0.74rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 0.35rem;
}

.form-input, .form-select, .form-textarea {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 0.62rem 0.85rem;
  color: #ffffff;
  font-size: 0.82rem;
  font-family: inherit;
  outline: none;
  transition: var(--transition);
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.3);
}

.form-input:focus, .form-select:focus, .form-textarea:focus {
  border-color: var(--tgm-crimson);
  box-shadow: 0 0 0 3px rgba(218, 13, 10, 0.25);
}

.form-textarea {
  resize: vertical;
  min-height: 85px;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  line-height: 1.5;
}

.switch-wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 0;
  border-top: 1px solid var(--border-color);
  margin-top: 0.85rem;
}

.switch-label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-secondary);
}

/* ==============================================================================
   MODALS
   ============================================================================== */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(4, 1, 10, 0.85);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 1.25rem;
}

.modal-overlay.active {
  display: flex !important;
}

.modal-card {
  background: #0f0722;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 640px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.9), inset 0 1px 0 rgba(255, 255, 255, 0.15);
  animation: modalScale 0.22s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes modalScale {
  from { opacity: 0; transform: scale(0.95) translateY(10px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.35rem 1.75rem;
  border-bottom: 1px solid var(--border-color);
}

.modal-header h3 {
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 700;
  color: #ffffff;
}

.modal-close {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1.35rem;
  cursor: pointer;
  transition: var(--transition);
}
.modal-close:hover { color: #ffffff; }

.modal-body {
  padding: 1.75rem;
}

.modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.75rem;
  padding: 1.25rem 1.75rem;
  border-top: 1px solid var(--border-color);
}

/* Code Preview Box */
.code-box {
  background: #090314;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-sm);
  padding: 1rem;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: #38bdf8;
  overflow-x: auto;
  position: relative;
  white-space: pre-wrap;
  line-height: 1.6;
}

.copy-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: var(--text-secondary);
  font-size: 0.72rem;
  padding: 0.25rem 0.55rem;
  border-radius: 4px;
  cursor: pointer;
  transition: var(--transition);
}
.copy-btn:hover { background: rgba(255, 255, 255, 0.18); color: #ffffff; }

/* Looker Embed Frame */
.looker-embed-frame {
  width: 100%;
  height: 680px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background: var(--bg-card);
}

/* Toast System */
#toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.toast {
  background: #140a2c;
  border: 1px solid rgba(255, 255, 255, 0.14);
  padding: 0.9rem 1.35rem;
  border-radius: var(--radius-sm);
  box-shadow: 0 15px 35px rgba(0, 0, 0, 0.7);
  color: #ffffff;
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 300px;
  animation: toastSlideIn 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.toast.success { border-left: 4px solid var(--accent-emerald); }
.toast.error { border-left: 4px solid var(--tgm-crimson); }
.toast.info { border-left: 4px solid var(--accent-cyan); }

@keyframes toastSlideIn {
  from { opacity: 0; transform: translateX(25px); }
  to { opacity: 1; transform: translateX(0); }
}

/* ==============================================================================
   RESPONSIVE DESIGN BREAKPOINTS
   Laptops (1280px), Tablets (1024px, 768px), Mobile (480px, 360px)
   ============================================================================== */

/* --- Breakpoint 1: Standard Laptops & Medium Desktops (<= 1280px) --- */
@media (max-width: 1280px) {
  .app-header {
    padding: 0.75rem 1.5rem;
  }
  .main-content {
    padding: 1.5rem 1.5rem 3.5rem 1.5rem;
  }
  .charts-grid {
    grid-template-columns: 1.8fr 1fr;
    gap: 1.15rem;
  }
  .kpi-grid {
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
  }
}

/* --- Breakpoint 2: Large Tablets & Small Laptops (<= 1024px) --- */
@media (max-width: 1024px) {
  .header-main-row {
    flex-wrap: wrap;
    gap: 0.85rem;
  }
  
  .charts-grid {
    grid-template-columns: 1fr;
  }
  
  .kpi-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  /* Sticky First Column on Mobile/Tablet so User Knows Which Platform / Dimension They Are Viewing */
  table.data-table th:first-child,
  table.data-table td:first-child {
    position: sticky;
    left: 0;
    z-index: 5;
    background: #0f0722;
    box-shadow: 3px 0 8px -2px rgba(0, 0, 0, 0.75);
  }
  table.data-table th:first-child {
    background: #150930;
    z-index: 6;
  }
}

/* --- Breakpoint 3: Standard Mobile & Portrait Tablets (<= 768px) --- */
@media (max-width: 768px) {
  .app-header {
    padding: 0.75rem 1rem 0.6rem 1rem;
  }

  .header-container {
    gap: 0.65rem;
  }

  .header-main-row {
    flex-direction: column;
    align-items: stretch;
    gap: 0.75rem;
  }

  .brand {
    gap: 0.75rem;
  }

  .brand-logo-container {
    width: 38px;
    height: 38px;
    border-radius: 9px;
  }

  .brand-title-wrap h1 {
    font-size: 1.15rem;
  }

  .brand-badge {
    font-size: 0.58rem;
    padding: 0.12rem 0.45rem;
  }

  .brand-text p {
    font-size: 0.68rem;
  }

  .header-controls {
    width: 100%;
    justify-content: space-between;
    gap: 0.5rem;
    flex-wrap: wrap;
  }

  .client-select-wrap {
    flex: 1;
    min-width: 140px;
  }

  .select-client {
    width: 100%;
  }

  .status-pill {
    padding: 0.28rem 0.6rem;
    font-size: 0.68rem;
  }

  #btn-open-sync-modal {
    padding: 0.45rem 0.85rem;
    font-size: 0.76rem;
  }

  .nav-tabs {
    padding: 0.25rem;
    gap: 0.2rem;
  }

  .nav-tab-btn {
    padding: 0.42rem 0.7rem;
    font-size: 0.76rem;
    gap: 0.35rem;
  }

  .main-content {
    padding: 1.15rem 1rem 3rem 1rem;
  }

  .page-title-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 1rem;
    margin-bottom: 1.25rem;
    padding-bottom: 1rem;
  }

  .page-title-row h2 {
    font-size: 1.35rem;
  }

  .actions-row {
    width: 100%;
  }

  .timeframe-toggle {
    width: 100%;
  }

  .btn-tf {
    flex: 1;
    text-align: center;
    padding: 7px 10px;
    font-size: 0.76rem;
  }

  .kpi-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
  }

  .kpi-card {
    padding: 0.95rem;
  }

  .kpi-value {
    font-size: 1.4rem;
  }

  .kpi-label {
    font-size: 0.66rem;
  }

  .kpi-icon-wrap {
    width: 28px;
    height: 28px;
    font-size: 0.82rem;
  }

  .chart-wrapper {
    height: 270px;
  }

  .table-card {
    margin-bottom: 1.25rem;
  }

  .table-search-row {
    flex-direction: column;
    align-items: stretch;
    gap: 0.6rem;
    padding: 0.75rem 1rem;
  }

  .search-input-wrap {
    max-width: 100%;
  }

  .nomen-pills-bar {
    padding: 0.65rem 1rem;
  }

  .btn-nomen {
    padding: 0.35rem 0.75rem;
    font-size: 0.7rem;
  }

  .connectors-grid {
    grid-template-columns: 1fr;
  }

  .modal-overlay {
    padding: 0.75rem;
  }

  .modal-card {
    max-width: 100%;
    max-height: 94vh;
  }

  .modal-header, .modal-body, .modal-footer {
    padding: 1.15rem;
  }

  #toast-container {
    bottom: 16px;
    right: 16px;
    left: 16px;
  }

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

/* --- Breakpoint 4: Compact Smartphones (<= 480px) --- */
@media (max-width: 480px) {
  .app-header {
    padding: 0.55rem 0.75rem;
  }

  .brand-text p {
    display: none; /* Hide subtitle on tiny screens for ultra-compact luxury feel */
  }

  .main-content {
    padding: 0.9rem 0.65rem 2.5rem 0.65rem;
  }

  .kpi-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.55rem;
  }

  .kpi-card {
    padding: 0.8rem;
  }

  .kpi-value {
    font-size: 1.25rem;
  }

  .kpi-sub {
    font-size: 0.68rem;
  }

  .card {
    padding: 1rem;
  }

  .chart-wrapper {
    height: 240px;
  }

  table.data-table th, 
  table.data-table td {
    padding: 0.7rem 0.85rem;
    font-size: 0.76rem;
  }
}

/* ==============================================================================
   DATE SCOPE PRESETS & FILTER PANEL STYLES
   ============================================================================== */
.preset-pills-wrap {
  display: flex;
  background: rgba(14, 7, 32, 0.85);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 3px;
  gap: 3px;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.4);
  flex-wrap: wrap;
}

.btn-preset-date {
  background: transparent;
  border: none;
  border-radius: 7px;
  padding: 6px 13px;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  color: var(--text-muted);
  transition: var(--transition);
  white-space: nowrap;
}

.btn-preset-date:hover {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.08);
}

.btn-preset-date.active {
  background: linear-gradient(135deg, var(--tgm-crimson), var(--tgm-crimson-dark));
  color: #ffffff;
  box-shadow: 0 2px 10px rgba(218, 13, 10, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.25);
}

.date-picker-input {
  background: rgba(10, 4, 22, 0.9) !important;
  border: 1px solid var(--border-color) !important;
  color: #ffffff !important;
  border-radius: 6px !important;
}

.date-picker-input::-webkit-calendar-picker-indicator {
  filter: invert(0.85) sepia(1) hue-rotate(320deg) brightness(1.2);
  cursor: pointer;
}

.active-date-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 5px 12px;
  border-radius: 9999px;
  background: rgba(56, 189, 248, 0.12);
  border: 1px solid rgba(56, 189, 248, 0.35);
  font-size: 0.78rem;
  color: #38bdf8;
  font-weight: 500;
  white-space: nowrap;
}

@media (max-width: 992px) {
  .date-filter-panel > div {
    flex-direction: column;
    align-items: flex-start !important;
  }
}

