/* Meta Ads Dashboard — Apple-glass Design System */

:root {
  /* BASE — pure black Apple HIG */
  --bg-base: #000000;
  --bg-elevated: #0c0c0f;
  --bg-overlay: #141418;

  /* GLASS */
  --glass-surface: rgba(255, 255, 255, 0.03);
  --glass-surface-hover: rgba(255, 255, 255, 0.05);
  --glass-surface-active: rgba(255, 255, 255, 0.08);
  --glass-border: rgba(255, 255, 255, 0.06);
  --glass-border-hover: rgba(255, 255, 255, 0.12);

  /* ACCENT — monochrome white-on-dark, Apple HIG primary */
  --accent: #ffffff;
  --accent-light: #ededf0;
  --accent-dark: #dcdce0;
  --accent-gradient: #ffffff;
  --accent-glow: rgba(255, 255, 255, 0.08);
  --accent-ink: #0a0a0c;

  /* Reserved: Meta-brand blue (only for Meta login SVG and OAuth buttons) */
  --meta-brand-1: #0081fb;
  --meta-brand-2: #0064e0;

  /* Graphite tile for logo/avatar backgrounds (matches login page) */
  --logo-tile: linear-gradient(145deg, #252528 0%, #141417 60%, #0a0a0c 100%);

  /* SEMANTIC */
  --success: #10b981;
  --success-glow: rgba(16, 185, 129, 0.22);
  --warning: #f59e0b;
  --warning-glow: rgba(245, 158, 11, 0.22);
  --danger: #ef4444;
  --danger-glow: rgba(239, 68, 68, 0.22);
  --info: #06b6d4;
  --info-glow: rgba(6, 182, 212, 0.22);
  --meta-blue: #0668e1;

  /* SPEND TIERS */
  --spend-zero: #4b5563;
  --spend-low: #3b82f6;
  --spend-mid: #10b981;
  --spend-high: #f59e0b;
  --spend-critical: #d4af37;

  /* TEXT */
  --text-primary: #f3f4f6;
  --text-secondary: #d1d5db;
  --text-muted: #9ca3af;
  --text-dim: #6b7280;

  /* RADIUS */
  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 16px;
  --r-xl: 20px;

  /* TRANSITIONS */
  --ease: cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
  font-family: 'Inter', 'SF Pro Display', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg-base);
  color: var(--text-primary);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-size: clamp(14px, 1vw, 15px);
  line-height: 1.55;
  letter-spacing: -0.2px;
  overflow-x: hidden;
}

a { color: var(--accent-light); text-decoration: none; transition: color 0.15s var(--ease); }
a:hover { color: var(--accent); }

/* Apple-inspired subtle dark backdrop — matches login page */
.bg-grid {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(1200px 700px at 20% -10%, rgba(60, 60, 68, 0.35), transparent 60%),
    radial-gradient(900px 600px at 85% 15%, rgba(40, 40, 48, 0.3), transparent 65%),
    radial-gradient(1000px 800px at 50% 110%, rgba(30, 30, 38, 0.4), transparent 65%),
    linear-gradient(180deg, #000 0%, #07070a 50%, #000 100%);
}

/* GLASS FOUNDATION */
.glass {
  background: var(--glass-surface);
  border: 1px solid var(--glass-border);
  backdrop-filter: blur(24px) saturate(150%);
  -webkit-backdrop-filter: blur(24px) saturate(150%);
  border-radius: var(--r-lg);
}
.glass-elevated {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(24px) saturate(150%);
  -webkit-backdrop-filter: blur(24px) saturate(150%);
}
.glass-accent {
  border: 1px solid rgba(108, 92, 231, 0.35);
  box-shadow: 0 0 24px var(--accent-glow);
}

/* TYPOGRAPHY */
h1, .text-xl { font-size: clamp(22px, 2.6vw, 32px); font-weight: 700; letter-spacing: -0.8px; line-height: 1.15; }
h2, .text-lg { font-size: clamp(17px, 2vw, 22px); font-weight: 600; letter-spacing: -0.4px; line-height: 1.3; }
h3, .text-md { font-size: clamp(15px, 1.5vw, 17px); font-weight: 600; line-height: 1.4; }
.text-sm { font-size: 13px; }
.text-xs {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.8px;
}
.mono { font-family: 'JetBrains Mono', 'SF Mono', 'Fira Code', monospace; font-size: 12px; letter-spacing: 0; }
.truncate { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 280px; }
.text-muted { color: var(--text-muted); }
.text-dim { color: var(--text-dim); }

/* NAV */
.nav {
  position: sticky;
  top: 0;
  z-index: 50;
  padding: 12px 28px;
  display: flex;
  align-items: center;
  gap: 20px;
  background: rgba(5, 5, 16, 0.72);
  backdrop-filter: blur(24px) saturate(160%);
  -webkit-backdrop-filter: blur(24px) saturate(160%);
  border-bottom: 1px solid var(--glass-border);
}
.nav-brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 15px;
  color: var(--text-primary);
  letter-spacing: -0.3px;
}
.nav-logo {
  width: 30px;
  height: 30px;
  border-radius: 9px;
  background: var(--logo-tile);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08), 0 2px 8px rgba(0, 0, 0, 0.4);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  font-weight: 700;
  color: white;
  box-shadow: 0 6px 20px var(--accent-glow);
}
.nav-links {
  display: flex;
  gap: 2px;
  margin-left: 16px;
  position: relative;
  isolation: isolate;
}
.nav-link, .nav-pill {
  padding: 8px 14px;
  border-radius: var(--r-sm);
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 500;
  background: transparent;
  border: none;
  cursor: pointer;
  position: relative;
  z-index: 1;
  transition: color 0.2s var(--ease);
}
.nav-link:hover, .nav-pill:hover { color: var(--text-primary); }
.nav-link.active, .nav-pill.active {
  color: var(--text-primary);
}
.nav-indicator {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  width: 0;
  border-radius: var(--r-sm);
  background: var(--glass-surface-active);
  border: 1px solid var(--glass-border);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06);
  backdrop-filter: blur(18px) saturate(140%);
  -webkit-backdrop-filter: blur(18px) saturate(140%);
  opacity: 0;
  pointer-events: none;
  z-index: 0;
  transform: translate3d(0, 0, 0);
  transition:
    transform 360ms cubic-bezier(0.32, 0.72, 0, 1),
    width 360ms cubic-bezier(0.32, 0.72, 0, 1),
    opacity 200ms ease-out;
  will-change: transform, width;
}
.nav-indicator.is-visible { opacity: 1; }
.nav-indicator.no-transition { transition: none; }
@media (prefers-reduced-motion: reduce) {
  .nav-indicator { transition: opacity 120ms linear; }
}
.nav-spacer { flex: 1; }
.nav-right { display: inline-flex; align-items: center; gap: 8px; }
.nav-logout-form { margin: 0; display: inline; }
.nav-logout {
  color: var(--text-muted); font-size: 13px; padding: 6px 10px; border-radius: 6px;
  background: transparent; border: 0; cursor: pointer; font-family: inherit;
}
.nav-logout:hover { background: var(--glass-surface); color: var(--danger); }
.account-menu-form { margin: 0; }
.account-menu-item-button {
  width: 100%; background: transparent; border: 0; cursor: pointer;
  font: inherit; color: inherit; text-align: left;
}

/* ACCOUNT SWITCHER DROPDOWN */
.account-switcher {
  position: relative;
  display: inline-block;
}
.account-chip {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 6px 12px 6px 6px;
  background: var(--glass-surface);
  border: 1px solid var(--glass-border);
  border-radius: 100px;
  font-size: 13px;
  color: var(--text-primary);
  cursor: pointer;
  transition: background 0.15s var(--ease);
}
.account-chip:hover { background: var(--glass-surface-hover); border-color: var(--glass-border-hover); }
.account-chip .avatar {
  width: 26px;
  height: 26px;
  border-radius: 8px;
  background: var(--logo-tile);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 700;
  color: #f5f5f7;
  letter-spacing: 0.3px;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.08);
}
.account-chip .caret { opacity: 0.5; width: 12px; height: 12px; }
.account-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 260px;
  padding: 8px;
  background: rgba(12, 12, 15, 0.96);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: var(--r-md);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(24px) saturate(150%);
  -webkit-backdrop-filter: blur(24px) saturate(150%);
  display: none;
  z-index: 60;
}
.account-menu.open { display: block; animation: menuFadeIn 0.15s var(--ease); }
.account-menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--r-sm);
  color: var(--text-secondary);
  font-size: 13px;
  cursor: pointer;
  transition: background 0.12s;
}
.account-menu-item:hover { background: var(--glass-surface-hover); color: var(--text-primary); }
.account-menu-item.active { background: var(--glass-surface-active); color: var(--text-primary); }
.account-menu-item .avatar {
  width: 24px; height: 24px; border-radius: 7px;
  background: var(--logo-tile);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 10px; font-weight: 700; color: #f5f5f7;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.08);
}
.account-menu-sep { height: 1px; background: var(--glass-border); margin: 6px 0; }
.account-menu-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px; height: 22px;
  border-radius: 6px;
  color: var(--text-muted);
  opacity: 0.6;
  transition: background 0.12s, opacity 0.12s, color 0.12s;
}
.account-menu-link:hover { background: var(--glass-surface-hover); color: var(--text-primary); opacity: 1; }
.account-menu-link [data-icon] { width: 13px; height: 13px; }

/* Profile-pic <img> rendered with the same shape as the .avatar chip */
.avatar-img {
  object-fit: cover;
  background: var(--logo-tile);
  display: inline-block;
  vertical-align: middle;
}
.account-chip .avatar-img { width: 26px; height: 26px; border-radius: 8px; box-shadow: inset 0 1px 0 rgba(255,255,255,0.08); }
.account-menu-item .avatar-img { width: 24px; height: 24px; border-radius: 7px; box-shadow: inset 0 1px 0 rgba(255,255,255,0.08); }

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

/* CONTAINER + PAGE HEADER */
.container {
  position: relative;
  z-index: 1;
  max-width: 1440px;
  margin: 0 auto;
  padding: 28px;
}
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
}
.page-title { font-size: clamp(22px, 2.4vw, 28px); font-weight: 700; letter-spacing: -0.6px; }
.page-subtitle { color: var(--text-muted); font-size: 14px; margin-top: 4px; }

/* SECTION DIVIDER */
.section-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 32px 0 16px 0;
}
.section-divider::before, .section-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--glass-border);
}
.section-label {
  padding: 5px 12px;
  background: var(--glass-surface);
  border: 1px solid var(--glass-border);
  border-radius: 100px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-muted);
}

/* CARDS GRID */
.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
  margin-bottom: 24px;
}
.cards-container {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
  gap: 20px;
}

/* STAT CARDS */
.card {
  padding: 18px;
  border-radius: var(--r-md);
  background: var(--glass-surface);
  border: 1px solid var(--glass-border);
  backdrop-filter: blur(20px) saturate(150%);
  -webkit-backdrop-filter: blur(20px) saturate(150%);
  transition: transform 0.2s var(--ease), border-color 0.2s var(--ease), box-shadow 0.2s var(--ease);
}
.card:hover {
  transform: translateY(-1px);
  border-color: var(--glass-border-hover);
  box-shadow: 0 8px 28px var(--accent-glow);
}
.card-label { color: var(--text-muted); font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.8px; margin-bottom: 6px; }
.card-value { font-size: 26px; font-weight: 700; letter-spacing: -0.8px; color: var(--text-primary); font-feature-settings: "tnum"; }
.card-link { display: block; color: inherit; }
.card-link:hover .card-value { color: #ffffff; }

/* PAGE CARD */
.card-page {
  position: relative;
  padding: 20px;
  border-radius: var(--r-lg);
  background: var(--glass-surface);
  border: 1px solid var(--glass-border);
  backdrop-filter: blur(24px) saturate(150%);
  -webkit-backdrop-filter: blur(24px) saturate(150%);
  transition: all 0.25s var(--ease);
}
.card-page:hover {
  background: var(--glass-surface-hover);
  border-color: var(--glass-border-hover);
  transform: translateY(-2px);
  box-shadow: 0 12px 48px var(--accent-glow);
}
.card-page-header {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 14px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--glass-border);
}
.card-page-avatar {
  width: 56px; height: 56px;
  border-radius: 14px;
  background: var(--glass-surface-hover);
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px; font-weight: 700;
  background-size: cover; background-position: center;
  color: var(--text-muted);
}
.card-page-meta { flex: 1; min-width: 0; }
.card-page-name { font-size: 15px; font-weight: 700; color: var(--text-primary); margin-bottom: 3px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-page-category { font-size: 12px; color: var(--text-muted); margin-bottom: 6px; }
.card-page-badges { display: inline-flex; gap: 6px; align-items: center; }
.card-page-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 14px;
}
.stat-item {
  padding: 10px;
  border-radius: var(--r-sm);
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--glass-border);
  text-align: center;
}
.stat-value { font-size: 16px; font-weight: 700; color: #f5f5f7; display: block; margin-bottom: 2px; font-feature-settings: "tnum"; }
.stat-label { font-size: 10px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.6px; }

.card-page-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.card-page-nested {
  margin-top: 14px; padding-top: 14px;
  border-top: 1px solid var(--glass-border);
}
.nested-label {
  font-size: 10px; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 0.8px;
  margin-bottom: 10px; font-weight: 600;
}
.nested-list { display: flex; flex-direction: column; gap: 6px; }
.nested-item {
  padding: 8px 10px;
  border-radius: var(--r-sm);
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--glass-border);
  display: flex; align-items: center; justify-content: space-between;
  font-size: 12px;
  gap: 10px;
}
.nested-item-icon { display: inline-flex; align-items: center; gap: 6px; color: var(--text-secondary); min-width: 0; flex: 1; }
.nested-item-icon span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* AD ACCOUNT CARD */
.card-account {
  padding: 18px;
  border-radius: var(--r-lg);
  background: var(--glass-surface);
  border: 1px solid var(--glass-border);
  backdrop-filter: blur(20px) saturate(150%);
  -webkit-backdrop-filter: blur(20px) saturate(150%);
  transition: all 0.25s var(--ease);
}
.card-account:hover {
  transform: translateY(-1px);
  border-color: var(--glass-border-hover);
  box-shadow: 0 8px 32px var(--accent-glow);
}
.card-account-header {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--glass-border);
}
.account-title { font-weight: 600; font-size: 14px; color: var(--text-primary); overflow: hidden; text-overflow: ellipsis; }
.card-account-meta {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 12px; font-size: 12px;
}
.account-currency { color: var(--text-muted); font-weight: 600; }
.period-select {
  background: var(--glass-surface-hover);
  border: 1px solid var(--glass-border);
  color: var(--text-primary);
  padding: 5px 10px;
  border-radius: var(--r-sm);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
  transition: border-color 0.15s;
}
.period-select:hover { border-color: var(--glass-border-hover); }
.period-select:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

.spend-section { }
.spend-label { font-size: 10px; color: var(--text-muted); margin-bottom: 4px; text-transform: uppercase; letter-spacing: 0.6px; font-weight: 600; }
.spend-amount { font-size: 22px; font-weight: 700; color: var(--text-primary); margin-bottom: 10px; letter-spacing: -0.5px; font-feature-settings: "tnum"; }
.spend-bar {
  height: 8px;
  border-radius: 100px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--glass-border);
  overflow: hidden;
}
.spend-fill {
  height: 100%;
  border-radius: 100px;
  transition: width 0.6s var(--ease), background 0.3s;
}
.spend-fill.tier-zero { background: var(--spend-zero); }
.spend-fill.tier-low { background: linear-gradient(90deg, var(--spend-low), var(--info)); }
.spend-fill.tier-mid { background: linear-gradient(90deg, var(--spend-mid), #34d399); }
.spend-fill.tier-high { background: linear-gradient(90deg, var(--spend-high), #fbbf24); box-shadow: 0 0 8px rgba(245, 158, 11, 0.3); }
.spend-fill.tier-critical { background: linear-gradient(90deg, var(--spend-critical), #f59e0b); box-shadow: 0 0 12px rgba(212, 175, 55, 0.45); }
.spend-meta { font-size: 11px; color: var(--text-muted); margin-top: 6px; }

/* BUTTONS — Apple HIG: flat, minimal, high-contrast */
.btn, .btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 18px;
  background: #ffffff;
  color: #0a0a0c;
  border: none;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  letter-spacing: -0.1px;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.1s ease;
  text-decoration: none;
}
.btn:hover, .btn-primary:hover { background: #ededf0; color: #0a0a0c; }
.btn:active, .btn-primary:active { background: #dcdce0; transform: scale(0.99); }
.btn:disabled, .btn-primary:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }

.btn-secondary, .btn-glass {
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-primary);
  border: 1px solid var(--glass-border);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}
.btn-secondary:hover, .btn-glass:hover {
  background: rgba(255, 255, 255, 0.07);
  border-color: var(--glass-border-hover);
  color: var(--text-primary);
}
.btn-secondary:active, .btn-glass:active { transform: scale(0.99); }

.btn-danger {
  background: transparent;
  color: var(--danger);
  border: 1px solid rgba(239, 68, 68, 0.25);
}
.btn-danger:hover {
  background: rgba(239, 68, 68, 0.08);
  border-color: rgba(239, 68, 68, 0.4);
  color: var(--danger);
}

.btn-meta { background: var(--meta-brand-2); color: white; }
.btn-meta:hover { background: #0559c4; color: white; }

.btn-sm { padding: 7px 12px; font-size: 12px; border-radius: 8px; }
.btn-lg { padding: 12px 22px; font-size: 15px; border-radius: 12px; }
.btn-icon { padding: 8px; width: 36px; height: 36px; }

/* BADGES */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  border-radius: 100px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
}
.badge-active { background: var(--success-glow); color: var(--success); border: 1px solid rgba(16, 185, 129, 0.3); }
.badge-disabled, .badge-danger { background: var(--danger-glow); color: var(--danger); border: 1px solid rgba(239, 68, 68, 0.3); }
.badge-pending, .badge-warning { background: var(--warning-glow); color: var(--warning); border: 1px solid rgba(245, 158, 11, 0.3); }
.badge-neutral { background: var(--glass-surface-hover); color: var(--text-muted); border: 1px solid var(--glass-border); }
.badge-info { background: var(--info-glow); color: var(--info); border: 1px solid rgba(6, 182, 212, 0.3); }

.chip-ig {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  background: linear-gradient(135deg, #833ab4, #fd1d1d);
  border-radius: 100px;
  font-size: 10px;
  font-weight: 700;
  color: white;
}

/* INPUTS */
.input, input[type="text"], input[type="password"], input[type="email"], input[type="url"], input[type="number"], input[type="datetime-local"], textarea, select {
  width: 100%;
  padding: 11px 14px;
  background: rgba(8, 8, 24, 0.6);
  border: 1px solid var(--glass-border);
  border-radius: var(--r-sm);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 14px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.input:focus, input:focus, textarea:focus, select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}
textarea { resize: vertical; min-height: 90px; font-family: inherit; }
select { appearance: none; background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 20 20' fill='none' stroke='%239ca3af' stroke-width='2'%3E%3Cpolyline points='6 8 10 12 14 8'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 14px center; padding-right: 36px; }

/* PANEL */
.panel {
  background: var(--glass-surface);
  border: 1px solid var(--glass-border);
  border-radius: var(--r-lg);
  backdrop-filter: blur(20px) saturate(150%);
  -webkit-backdrop-filter: blur(20px) saturate(150%);
  margin-bottom: 20px;
  overflow: hidden;
}
.panel-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--glass-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.panel-title { font-size: 14px; font-weight: 600; letter-spacing: -0.2px; }
.panel-body { padding: 0; }
.panel-body.padded { padding: 20px; }
.empty-state { padding: 48px 20px; text-align: center; color: var(--text-muted); font-size: 13px; }

/* TABLES */
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.table th {
  text-align: left;
  padding: 11px 20px;
  font-weight: 600;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-muted);
  border-bottom: 1px solid var(--glass-border);
  background: rgba(255, 255, 255, 0.015);
}
.table td {
  padding: 12px 20px;
  border-bottom: 1px solid var(--glass-border);
  vertical-align: middle;
}
.table tr:last-child td { border-bottom: none; }
.table tr:hover td { background: var(--glass-surface-hover); }

/* FORM HELPERS */
.form-row { margin-bottom: 16px; }
.form-label {
  display: block;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  margin-bottom: 6px;
}
.form-help { font-size: 11px; color: var(--text-muted); margin-top: 5px; }
.form-actions { display: flex; gap: 10px; margin-top: 22px; }

/* TOKEN BOX */
.token-box {
  position: relative;
  padding: 16px;
  border-radius: var(--r-md);
  background: rgba(8, 8, 24, 0.6);
  border: 1px solid var(--glass-border);
  display: flex;
  align-items: center;
  gap: 12px;
}
.token-content { flex: 1; overflow: hidden; }
.token-label { font-size: 10px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.8px; margin-bottom: 6px; font-weight: 700; }
.token-text {
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  color: var(--accent-light);
  word-break: break-all;
  line-height: 1.5;
  user-select: all;
}
.token-text.masked { filter: blur(6px); transition: filter 0.2s; cursor: pointer; }
.token-text.masked:hover { filter: blur(3px); }
.token-copy {
  flex-shrink: 0;
  padding: 8px 14px;
  background: #ffffff;
  color: var(--accent-ink);
  border: none;
  border-radius: var(--r-sm);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.1s ease, box-shadow 0.15s ease, color 0.15s ease;
  font-family: inherit;
  white-space: nowrap;
}
.token-copy:hover { background: #ededf0; transform: translateY(-1px); box-shadow: 0 6px 16px rgba(0, 0, 0, 0.4); }
.token-copy:active { background: #dcdce0; transform: scale(0.99); }
.token-copy.copied { background: var(--success); color: #052e1f; }

/* TOASTS */
.toast-container {
  position: fixed;
  top: 80px;
  right: 24px;
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: 440px;
}
.toast, .flash {
  padding: 12px 16px;
  border-radius: var(--r-md);
  font-size: 13px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 12px;
  background: rgba(15, 15, 32, 0.92);
  border: 1px solid var(--glass-border);
  backdrop-filter: blur(24px) saturate(150%);
  -webkit-backdrop-filter: blur(24px) saturate(150%);
  animation: toastSlideIn 0.3s var(--ease) forwards;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.3);
  min-width: 260px;
}
.toast-success, .flash-success { background: rgba(16, 185, 129, 0.12); border-color: rgba(16, 185, 129, 0.4); color: var(--success); }
.toast-error, .flash-error { background: rgba(239, 68, 68, 0.12); border-color: rgba(239, 68, 68, 0.4); color: var(--danger); }
.toast-info, .flash-info { background: rgba(6, 182, 212, 0.12); border-color: rgba(6, 182, 212, 0.4); color: var(--info); }
.toast-exit { animation: toastSlideOut 0.3s var(--ease) forwards; }
.flash-container { position: fixed; top: 80px; right: 24px; z-index: 100; display: flex; flex-direction: column; gap: 10px; }

/* LOGIN */
.login-container {
  position: relative;
  z-index: 1;
  max-width: 420px;
  margin: 80px auto;
  padding: 28px;
  animation: fadeInUp 0.4s var(--ease);
}
.login-card {
  padding: 36px;
  border-radius: var(--r-xl);
  background: var(--glass-surface);
  border: 1px solid var(--glass-border-hover);
  backdrop-filter: blur(24px) saturate(180%);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.45);
}
.login-logo {
  width: 60px; height: 60px;
  border-radius: 16px;
  background: var(--logo-tile);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 26px; font-weight: 700; color: var(--text-primary);
  margin-bottom: 18px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.06);
}
.login-title { font-size: 22px; font-weight: 700; margin-bottom: 6px; letter-spacing: -0.5px; }
.login-subtitle { color: var(--text-muted); font-size: 14px; margin-bottom: 22px; }

/* ICONS */
.icon { display: inline-block; width: 18px; height: 18px; vertical-align: middle; flex-shrink: 0; }
.icon-sm { width: 14px; height: 14px; }
.icon-xs { width: 12px; height: 12px; }
.icon-lg { width: 22px; height: 22px; }

/* ANIMATIONS */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes cardStaggerIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes toastSlideIn {
  from { opacity: 0; transform: translateX(380px); }
  to { opacity: 1; transform: translateX(0); }
}
@keyframes toastSlideOut {
  from { opacity: 1; transform: translateX(0); }
  to { opacity: 0; transform: translateX(380px); }
}
@keyframes countUp {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.stagger-in { animation: cardStaggerIn 0.5s var(--ease) backwards; }
.stagger-in:nth-child(1) { animation-delay: 0ms; }
.stagger-in:nth-child(2) { animation-delay: 50ms; }
.stagger-in:nth-child(3) { animation-delay: 100ms; }
.stagger-in:nth-child(4) { animation-delay: 150ms; }
.stagger-in:nth-child(5) { animation-delay: 200ms; }
.stagger-in:nth-child(6) { animation-delay: 250ms; }
.stagger-in:nth-child(7) { animation-delay: 300ms; }
.stagger-in:nth-child(8) { animation-delay: 350ms; }
.stagger-in:nth-child(9) { animation-delay: 400ms; }
.stagger-in:nth-child(10) { animation-delay: 450ms; }
.stagger-in:nth-child(n+11) { animation-delay: 500ms; }

/* UTILITIES */
.flex { display: flex; }
.flex-1 { flex: 1; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-sm { gap: 8px; }
.gap-md { gap: 12px; }
.gap-lg { gap: 20px; }
.mt-sm { margin-top: 8px; }
.mt-md { margin-top: 16px; }
.mt-lg { margin-top: 24px; }
.mb-sm { margin-bottom: 8px; }
.mb-md { margin-bottom: 16px; }
.mb-lg { margin-bottom: 24px; }
.hidden { display: none !important; }
.text-center { text-align: center; }
.text-right { text-align: right; }
.w-full { width: 100%; }
.pointer { cursor: pointer; }

/* TWO-COL LAYOUT */
.two-col { display: grid; grid-template-columns: 1fr 360px; gap: 24px; }
@media (max-width: 900px) {
  .two-col { grid-template-columns: 1fr; }
  .container { padding: 18px; }
  .nav { padding: 10px 16px; gap: 12px; }
  .nav-links { display: none; }
}

/* FOOTER */
.footer {
  text-align: center;
  padding: 24px;
  font-size: 12px;
  color: var(--text-muted);
}

/* LOADER */
.spinner {
  display: inline-block;
  width: 16px; height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.1);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* DROP ZONE */
.dropzone {
  border: 2px dashed var(--glass-border-hover);
  border-radius: var(--r-md);
  padding: 32px;
  text-align: center;
  color: var(--text-muted);
  transition: all 0.2s var(--ease);
  background: rgba(255, 255, 255, 0.02);
  cursor: pointer;
}
.dropzone:hover, .dropzone.dragover {
  border-color: var(--accent);
  background: rgba(108, 92, 231, 0.05);
  color: var(--text-primary);
}
.dropzone img { max-width: 100%; max-height: 240px; border-radius: var(--r-sm); }

/* MODAL */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  animation: fadeInUp 0.2s var(--ease);
}
.modal-backdrop[hidden] { display: none; }
.modal {
  position: relative;
  max-width: 560px;
  width: 92%;
  max-height: 90vh;
  overflow-y: auto;
  padding: 28px;
  background: rgba(15, 15, 32, 0.95);
  border: 1px solid var(--glass-border-hover);
  border-radius: var(--r-xl);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
}
.modal-close {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-muted);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  transition: background 0.12s, color 0.12s, border-color 0.12s;
}
.modal-close:hover { background: var(--glass-surface-hover); color: var(--text-primary); border-color: var(--glass-border); }
.modal-title { font-size: 20px; font-weight: 700; letter-spacing: -0.4px; margin: 0 0 8px; color: var(--text-primary); }
.modal-sub { font-size: 13px; color: var(--text-muted); margin: 0 0 20px; line-height: 1.55; }
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 22px;
  padding-top: 18px;
  border-top: 1px solid var(--glass-border);
}
.modal-actions .btn-primary { display: inline-flex; align-items: center; gap: 8px; }

.add-account-section { margin: 16px 0; }
.add-account-section-head {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 8px;
}
.add-account-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.add-account-list li {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 8px;
  background: rgba(255,255,255,0.025);
  border: 1px solid var(--glass-border);
}
.add-account-list li [data-icon] {
  width: 16px; height: 16px;
  color: var(--text-secondary);
  flex-shrink: 0;
}
.add-account-list li > div {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  font-size: 13px;
}
.add-account-list li b { color: var(--text-primary); font-weight: 600; font-size: 13px; }
.add-account-perms {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}
.perm-pill {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  padding: 3px 9px;
  border-radius: 6px;
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--glass-border);
  color: var(--text-secondary);
}

/* TOOL CARD (docs page) */
.tool-card {
  padding: 18px;
  border-radius: var(--r-md);
  background: var(--glass-surface);
  border: 1px solid var(--glass-border);
  margin-bottom: 12px;
  transition: border-color 0.15s;
}
.tool-card:hover { border-color: var(--glass-border-hover); }
.tool-name { font-family: 'JetBrains Mono', monospace; font-size: 14px; font-weight: 700; color: #f5f5f7; margin-bottom: 6px; }
.tool-sig { font-family: 'JetBrains Mono', monospace; font-size: 11px; color: var(--text-secondary); background: rgba(8, 8, 24, 0.5); padding: 8px 10px; border-radius: 6px; margin-bottom: 8px; overflow-x: auto; white-space: pre; }
.tool-desc { font-size: 13px; color: var(--text-secondary); line-height: 1.5; }

/* DOCS SIDEBAR */
.docs-layout { display: grid; grid-template-columns: 240px 1fr; gap: 24px; }
.docs-sidebar {
  position: sticky;
  top: 80px;
  align-self: start;
  max-height: calc(100vh - 100px);
  overflow-y: auto;
  padding: 16px;
  background: var(--glass-surface);
  border: 1px solid var(--glass-border);
  border-radius: var(--r-md);
}
.docs-sidebar-link {
  display: block;
  padding: 6px 10px;
  color: var(--text-muted);
  font-size: 13px;
  border-radius: var(--r-sm);
  margin-bottom: 2px;
}
.docs-sidebar-link:hover { background: var(--glass-surface-hover); color: var(--text-primary); }
.docs-sidebar-link.active { background: var(--glass-surface-active); color: #ffffff; }
@media (max-width: 900px) { .docs-layout { grid-template-columns: 1fr; } .docs-sidebar { position: static; max-height: none; } }

/* CHEVRON toggle */
.chevron { transition: transform 0.3s var(--ease); display: inline-block; }
.chevron.open { transform: rotate(180deg); }

/* DATA TABLE (sortable + filterable) */
.data-table {
  font-size: 13px;
}
.data-table th.sortable {
  cursor: pointer;
  user-select: none;
  position: relative;
  padding-right: 24px;
}
.data-table th.sortable:hover { color: var(--text-primary); }
.data-table th.sortable::after {
  content: "↕";
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  opacity: 0.3;
  font-size: 10px;
}
.data-table th.sortable.sort-asc::after  { content: "↑"; opacity: 1; color: var(--text-primary); }
.data-table th.sortable.sort-desc::after { content: "↓"; opacity: 1; color: var(--text-primary); }

.filter-input {
  font-size: 13px;
  padding: 8px 14px !important;
  width: 220px;
}

.table-avatar {
  display: inline-flex;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: var(--logo-tile);
  background-size: cover !important;
  background-position: center !important;
  flex-shrink: 0;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  color: #f5f5f7;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.05);
}

.spend-bar-inline {
  display: inline-block;
  vertical-align: middle;
  width: 80px;
  height: 6px;
  border-radius: 100px;
  background: rgba(255, 255, 255, 0.05);
  overflow: hidden;
}
.spend-fill-inline {
  display: block;
  height: 100%;
  border-radius: 100px;
  transition: width 0.4s var(--ease);
}
.spend-fill-inline.tier-zero { background: var(--spend-zero); }
.spend-fill-inline.tier-low { background: linear-gradient(90deg, var(--spend-low), var(--info)); }
.spend-fill-inline.tier-mid { background: linear-gradient(90deg, var(--spend-mid), #34d399); }
.spend-fill-inline.tier-high { background: linear-gradient(90deg, var(--spend-high), #fbbf24); }
.spend-fill-inline.tier-critical { background: linear-gradient(90deg, var(--spend-critical), #f59e0b); }

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

/* Fix hover popover z-index issue reported by agent test */
.card-page, .card-account { overflow: visible !important; z-index: 1; transition: z-index 0s linear 0.15s; }
.card-page:hover, .card-account:hover { z-index: 10; transition: z-index 0s linear 0s; }

/* CARD HOVER DETAIL POPOVER — Apple-style, 200ms fade-in delay */
.card-page, .card-account { position: relative; }
.card-detail-popover {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  z-index: 20;
  padding: 14px 16px;
  background: rgba(10, 10, 14, 0.96);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 14px;
  backdrop-filter: blur(32px) saturate(180%);
  -webkit-backdrop-filter: blur(32px) saturate(180%);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-4px);
  transition: opacity 0.15s ease 0s, transform 0.18s ease 0s, visibility 0s linear 0.15s;
  pointer-events: none;
}
.card-page:hover .card-detail-popover,
.card-account:hover .card-detail-popover {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
  transition: opacity 0.18s ease 0.2s, transform 0.2s ease 0.2s, visibility 0s linear 0s;
  pointer-events: auto;
}
.popover-title {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-muted);
  margin-bottom: 10px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--glass-border);
}
.popover-table { width: 100%; font-size: 12px; }
.popover-table td {
  padding: 4px 0;
  vertical-align: top;
}
.popover-table td:first-child {
  color: var(--text-muted);
  text-transform: uppercase;
  font-size: 10px;
  letter-spacing: 0.5px;
  font-weight: 600;
  width: 40%;
  padding-right: 10px;
}
.popover-table td:last-child {
  color: var(--text-primary);
  font-family: 'JetBrains Mono', monospace;
  word-break: break-all;
  font-size: 11px;
}
.popover-table tr + tr td { border-top: 1px solid rgba(255, 255, 255, 0.03); padding-top: 6px; margin-top: 2px; }

/* ─────────────────────────────────────────────
   COMPACT TABLES — tighter density for list views
   Apply by adding `.table-compact` on the <table>.
   ───────────────────────────────────────────── */
.table.table-compact { font-size: 12px; }
.table.table-compact th { padding: 8px 14px; font-size: 9.5px; letter-spacing: 0.7px; }
.table.table-compact td { padding: 7px 14px; }
.table.table-compact .table-avatar { width: 22px; height: 22px; border-radius: 6px; font-size: 10px; }
.table.table-compact .badge { font-size: 9.5px; padding: 2px 7px; }
.table.table-compact .btn-sm { padding: 4px 10px; font-size: 11px; }
.table.table-compact .gap-sm { gap: 6px; }
.table.table-compact .spend-bar-inline { width: 56px; height: 5px; }
.table.table-compact .chip-ig { font-size: 10px; padding: 2px 6px; }

/* Row link — makes name cell an anchor that looks native, with ↗ external-link icon */
.cell-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--text-primary);
  font-weight: 700;
  transition: color 0.12s var(--ease);
}
.cell-link:hover { color: var(--accent); }
.cell-link::after {
  content: "↗";
  font-size: 10px;
  color: var(--text-dim);
  transition: color 0.12s var(--ease), transform 0.15s var(--ease);
}
.cell-link:hover::after { color: var(--accent); transform: translate(1px, -1px); }
.cell-link-muted { color: var(--text-secondary); font-weight: 500; }
.cell-link-muted::after { font-size: 9px; opacity: 0.6; }

/* Compact icon-only link used in row Actions cells (open-on-Facebook, billing, etc.) */
.row-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px; height: 28px;
  border-radius: 7px;
  color: var(--text-muted);
  background: transparent;
  border: 1px solid transparent;
  opacity: 0.65;
  transition: background 0.12s var(--ease), border-color 0.12s var(--ease), opacity 0.12s var(--ease), color 0.12s var(--ease), transform 0.12s var(--ease);
}
.row-link:hover {
  background: var(--glass-surface-hover);
  border-color: var(--glass-border);
  color: var(--text-primary);
  opacity: 1;
  transform: translateY(-1px);
}
.row-link [data-icon] { width: 13px; height: 13px; display: inline-flex; }

/* Wrap chip-ig in <a> tag: strip underline, preserve chip styling, add hover lift */
a.chip-ig { text-decoration: none; transition: transform 0.15s var(--ease), box-shadow 0.15s var(--ease); }
a.chip-ig:hover { transform: translateY(-1px); box-shadow: 0 4px 12px rgba(228, 64, 95, 0.25); }

/* ─────────────────────────────────────────────
   GDRIVE PICKER — modal grid + model picture frame
   ───────────────────────────────────────────── */
.modal-lg { max-width: 880px !important; }
.gdrive-toolbar { display: flex; gap: 10px; align-items: center; margin-bottom: 16px; }
.gdrive-toolbar .input { flex: 1; }
.gdrive-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 12px;
  max-height: 60vh;
  overflow-y: auto;
  padding-right: 4px;
}
.gdrive-empty {
  grid-column: 1 / -1;
  padding: 40px 20px;
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
  line-height: 1.6;
}
.gdrive-tile {
  text-align: left;
  background: var(--glass-surface);
  border: 1px solid var(--glass-border);
  border-radius: var(--r-md);
  padding: 8px;
  cursor: pointer;
  transition: background 0.15s var(--ease), border-color 0.15s var(--ease), transform 0.12s var(--ease);
  font-family: inherit;
  color: inherit;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}
.gdrive-tile:hover { background: var(--glass-surface-hover); border-color: var(--glass-border-hover); transform: translateY(-2px); }
.gdrive-tile.selecting { border-color: var(--success); box-shadow: 0 0 0 3px var(--success-glow); }
.gdrive-tile-img {
  width: 100%; aspect-ratio: 1 / 1;
  border-radius: var(--r-sm);
  background: var(--logo-tile);
  background-size: cover;
  background-position: center;
}
.gdrive-tile-name { font-size: 11px; font-weight: 600; color: var(--text-primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.gdrive-tile-meta { font-size: 10px; color: var(--text-muted); font-family: 'JetBrains Mono', monospace; letter-spacing: 0.2px; }

.model-pic-row { display: flex; gap: 16px; align-items: center; }
.model-pic-frame {
  width: 96px; height: 96px;
  border-radius: var(--r-md);
  overflow: hidden;
  background: var(--logo-tile);
  border: 1px solid var(--glass-border);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.05);
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
}
.model-pic-frame img { width: 100%; height: 100%; object-fit: cover; display: block; }
.model-pic-fallback { font-size: 36px; font-weight: 700; color: rgba(255, 255, 255, 0.5); letter-spacing: -1px; }
.model-pic-actions { flex: 1; display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
.model-pic-actions .form-help { margin: 0; }

/* "+ Connect IG" pill — neutral dashed outline until hovered, then warms into
   the IG gradient to signal "this becomes a link to connect Instagram".
   Used in pages list when no IG is linked to a Page. */
.chip-connect-ig {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  border-radius: 100px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.2px;
  border: 1px dashed var(--glass-border-hover);
  background: rgba(255, 255, 255, 0.02);
  color: var(--text-muted);
  text-decoration: none;
  cursor: pointer;
  transition:
    background 0.18s var(--ease),
    border-color 0.18s var(--ease),
    color 0.18s var(--ease),
    transform 0.12s var(--ease),
    box-shadow 0.18s var(--ease);
}
.chip-connect-ig:hover {
  background: linear-gradient(135deg, #833ab4, #fd1d1d);
  border-color: transparent;
  color: #ffffff;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(228, 64, 95, 0.35);
}

/* Health badge system — colored dot in row + pill in detail/banner */
.health-trigger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px; height: 28px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 7px;
  cursor: pointer;
  transition: background 0.12s var(--ease), border-color 0.12s var(--ease), transform 0.12s var(--ease);
}
.health-trigger:hover { background: var(--glass-surface-hover); border-color: var(--glass-border); transform: scale(1.05); }
.health-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.3) inset;
}
.health-dot.ok       { background: #22c55e; box-shadow: 0 0 0 1px rgba(0,0,0,0.3) inset, 0 0 8px rgba(34,197,94,0.5); }
.health-dot.warn     { background: #eab308; box-shadow: 0 0 0 1px rgba(0,0,0,0.3) inset, 0 0 8px rgba(234,179,8,0.5); }
.health-dot.critical { background: #ef4444; box-shadow: 0 0 0 1px rgba(0,0,0,0.3) inset, 0 0 8px rgba(239,68,68,0.5); }
.health-dot.unknown  { background: #6b7280; box-shadow: 0 0 0 1px rgba(0,0,0,0.3) inset; }
.health-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.2px;
  border: 1px solid var(--glass-border);
}
.health-pill::before {
  content: "";
  width: 7px; height: 7px;
  border-radius: 50%;
  display: inline-block;
}
.health-pill.ok       { background: rgba(34,197,94,0.10);  color: #4ade80; border-color: rgba(34,197,94,0.30); }
.health-pill.ok::before       { background: #22c55e; }
.health-pill.warn     { background: rgba(234,179,8,0.10); color: #facc15; border-color: rgba(234,179,8,0.30); }
.health-pill.warn::before     { background: #eab308; }
.health-pill.critical { background: rgba(239,68,68,0.10); color: #f87171; border-color: rgba(239,68,68,0.30); }
.health-pill.critical::before { background: #ef4444; }
.health-pill.unknown  { background: rgba(107,114,128,0.08); color: var(--text-muted); border-color: var(--glass-border); }
.health-pill.unknown::before  { background: #6b7280; }

.health-summary-banner {
  margin: 10px 0 18px;
  padding: 12px 16px;
  border-radius: var(--r-md);
  background: rgba(255,255,255,0.025);
  border: 1px solid var(--glass-border);
}

/* Inline expand row revealed when a health-trigger is clicked */
.health-detail-row td {
  background: rgba(255,255,255,0.02);
  border-top: 1px solid var(--glass-border) !important;
  padding: 14px 18px !important;
}
.health-detail-row.is-open td { animation: healthSlideDown 200ms var(--ease); }
@keyframes healthSlideDown {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}
.health-detail { display: flex; flex-direction: column; gap: 10px; }
.health-reasons {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.health-reasons li {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  color: var(--text-secondary);
  padding: 6px 10px;
  border-radius: 7px;
  background: rgba(0,0,0,0.2);
}
.health-reasons li [data-icon] { width: 14px; height: 14px; color: var(--text-muted); flex-shrink: 0; }

/* "Unhealthy only" filter button — show as toggled when active */
#filter-unhealthy.is-active {
  background: var(--glass-surface-active);
  border-color: var(--glass-border-hover);
  color: var(--text-primary);
}

/* Dashboard health-summary tiles */
.health-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 14px;
  margin-bottom: 14px;
}
.health-tile {
  padding: 16px;
  border-radius: var(--r-md);
  background: rgba(255,255,255,0.025);
  border: 1px solid var(--glass-border);
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: background 0.15s var(--ease), border-color 0.15s var(--ease);
}
.health-tile:hover { background: rgba(255,255,255,0.04); border-color: var(--glass-border-hover); }
.health-tile-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.health-tile-name { font-size: 13px; font-weight: 600; color: var(--text-primary); letter-spacing: -0.2px; }
.health-tile-counts {
  display: flex;
  gap: 16px;
  font-size: 13px;
  color: var(--text-secondary);
}
.health-tile-counts span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: 'JetBrains Mono', monospace;
  font-weight: 600;
}
.health-tile-link {
  align-self: flex-start;
  font-size: 12px;
  color: var(--text-muted);
  padding: 4px 8px;
  border-radius: 6px;
  transition: background 0.12s, color 0.12s;
}
.health-tile-link:hover { background: var(--glass-surface-hover); color: var(--text-primary); }

/* Per-connected-account summary cards (rendered when ≥2 accounts are linked) */
.account-summaries {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 12px;
  margin: 18px 0 26px;
}
.account-summary-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 14px 16px;
  border-radius: var(--r-md);
  background: rgba(255,255,255,0.025);
  border: 1px solid var(--glass-border);
  transition: background 0.15s var(--ease), border-color 0.15s var(--ease), transform 0.15s var(--ease);
}
.account-summary-card:hover { background: rgba(255,255,255,0.05); border-color: var(--glass-border-hover); transform: translateY(-1px); }
.account-summary-card.active { background: rgba(0, 129, 251, 0.08); border-color: rgba(0, 129, 251, 0.30); }
.account-summary-head { display: flex; align-items: center; gap: 12px; min-width: 0; }
.account-summary-avatar {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  object-fit: cover;
  background: var(--logo-tile);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.08);
  flex-shrink: 0;
}
.account-summary-avatar-fallback {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 12px;
  color: #f5f5f7;
  letter-spacing: 0.4px;
}
.account-summary-name-block { min-width: 0; }
.account-summary-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: -0.2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.account-summary-counts { margin-top: 3px; }
.account-summary-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }

/* Cards-connected badge — for Ad Accounts "Cards" column */
.cards-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 8px;
  border-radius: var(--r-sm);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--glass-border);
  font-size: 11px;
  font-family: 'JetBrains Mono', monospace;
  color: var(--text-secondary);
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.cards-badge-icon { font-size: 12px; opacity: 0.7; }
.cards-badge-none {
  color: var(--text-dim);
  font-style: italic;
  background: transparent;
  border-color: transparent;
  padding-left: 0;
}

/* ─────────────────────────────────────────────
   COLLAPSIBLE SECTION — hover-expand (Apple-style)
   Pattern:
     <details class="collapse-section" [open]>
       <summary class="collapse-head">…</summary>
       <div class="collapse-body">…</div>
     </details>
   Opens on hover with a short delay; pins open on click (native <details>).
   ───────────────────────────────────────────── */
/* Apple-spring easings */
:root {
  --spring-out: cubic-bezier(0.32, 0.72, 0, 1);
  --spring-in:  cubic-bezier(0.5, 0, 0.75, 0);
}

.collapse-section {
  border: 1px solid var(--glass-border);
  border-radius: var(--r-lg);
  background: var(--glass-surface);
  backdrop-filter: blur(20px) saturate(150%);
  -webkit-backdrop-filter: blur(20px) saturate(150%);
  margin-bottom: 12px;
  overflow: hidden;
  will-change: background-color, border-color, box-shadow;
  transition:
    border-color 0.32s var(--spring-out),
    background-color 0.32s var(--spring-out),
    box-shadow 0.4s var(--spring-out);
}
.collapse-section:hover {
  border-color: var(--glass-border-hover);
  background: var(--glass-surface-hover);
  box-shadow: 0 14px 38px rgba(0, 0, 0, 0.32);
}
.collapse-section[open] {
  background: var(--glass-surface-hover);
  border-color: var(--glass-border-hover);
}
.collapse-head {
  list-style: none;
  padding: 14px 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  user-select: none;
  transition: background-color 0.25s var(--spring-out);
}
.collapse-head::-webkit-details-marker { display: none; }
.collapse-head::marker { content: ""; }
.collapse-head-left {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  flex: 1;
}
.collapse-title {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: -0.1px;
  color: var(--text-primary);
}
.collapse-subtle {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 500;
}
.collapse-caret {
  font-size: 10px;
  color: var(--text-muted);
  flex-shrink: 0;
  display: inline-block;
  transition: transform 0.42s var(--spring-out), color 0.2s linear;
  will-change: transform;
}
.collapse-section[open] .collapse-caret { transform: rotate(180deg); color: var(--text-primary); }

/* Smooth height transition. We toggle .is-open via JS in lockstep with the
   native [open] attribute, then animate max-height + opacity on the body.
   This avoids the abrupt snap that <details> normally has. */
.collapse-body {
  padding: 0 18px;
  max-height: 0;
  opacity: 0;
  overflow: hidden;
  transform: translateY(-4px);
  transition:
    max-height 0.45s var(--spring-out),
    opacity 0.32s var(--spring-out) 0.05s,
    padding-top 0.35s var(--spring-out),
    padding-bottom 0.35s var(--spring-out),
    transform 0.4s var(--spring-out);
  will-change: max-height, opacity, transform;
}
.collapse-section.is-open .collapse-body {
  max-height: 1600px;
  opacity: 1;
  padding-top: 4px;
  padding-bottom: 18px;
  transform: translateY(0);
}

/* Subtle peek when closed and hovered — head brightens without opening */
.collapse-section:not([open]):hover .collapse-head {
  background-color: var(--glass-surface-active);
}

/* ─────────────────────────────────────────────
   HERO CARD — central glass card for the Overview page
   Houses the MCP token front-and-center
   ───────────────────────────────────────────── */
.hero-card {
  position: relative;
  padding: 28px 32px;
  margin: 0 auto 22px;
  background: linear-gradient(180deg, rgba(255,255,255,0.04) 0%, rgba(255,255,255,0.015) 100%);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 20px;
  backdrop-filter: blur(40px) saturate(180%);
  -webkit-backdrop-filter: blur(40px) saturate(180%);
  box-shadow:
    0 20px 60px rgba(0, 0, 0, 0.4),
    inset 0 1px 0 rgba(255, 255, 255, 0.08);
  overflow: hidden;
}
.hero-card::before {
  content: "";
  position: absolute;
  top: -40%;
  left: 50%;
  transform: translateX(-50%);
  width: 120%;
  height: 80%;
  background: radial-gradient(ellipse, rgba(255,255,255,0.07) 0%, transparent 60%);
  pointer-events: none;
}
.hero-card-eyebrow {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: var(--text-muted);
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.hero-card-eyebrow .status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 8px var(--success-glow);
}
.hero-card-eyebrow .status-dot.off {
  background: var(--text-dim);
  box-shadow: none;
}
.hero-card-title {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.6px;
  margin-bottom: 6px;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 12px;
}
.hero-avatar {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  object-fit: cover;
  background: var(--logo-tile);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.08), 0 4px 12px rgba(0,0,0,0.3);
}
.hero-profile-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px; height: 26px;
  border-radius: 7px;
  color: var(--text-muted);
  opacity: 0.55;
  transition: background 0.15s var(--ease), opacity 0.15s var(--ease), color 0.15s var(--ease);
}
.hero-profile-link:hover { background: var(--glass-surface-hover); color: var(--text-primary); opacity: 1; }
.hero-profile-link [data-icon] { width: 14px; height: 14px; }
.hero-card-sub {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 22px;
  line-height: 1.5;
}
.hero-card .token-box {
  background: rgba(0, 0, 0, 0.35);
  padding: 14px 16px;
}
.hero-card-token-row + .hero-card-token-row { margin-top: 10px; }
.hero-card-actions {
  display: flex;
  gap: 10px;
  margin-top: 20px;
  flex-wrap: wrap;
}

/* ─────────────────────────────────────────────
   API RATE-LIMITS PANEL — colored progress bars
   ───────────────────────────────────────────── */
.rl-panel { display: grid; gap: 14px; }
.rl-row {
  display: grid;
  grid-template-columns: minmax(160px, 1.2fr) 1fr auto;
  align-items: center;
  gap: 14px;
  padding: 6px 0;
}
.rl-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-secondary);
  font-weight: 600;
  min-width: 0;
}
.rl-label .rl-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.rl-tier-pill {
  font-size: 9px;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  padding: 1px 6px;
  border-radius: 999px;
  border: 1px solid var(--glass-border);
  color: var(--text-muted);
  font-weight: 700;
}
.rl-bar {
  position: relative;
  height: 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--glass-border);
  overflow: hidden;
}
.rl-fill {
  position: absolute;
  inset: 0 auto 0 0;
  border-radius: inherit;
  width: 0%;
  background: linear-gradient(90deg, var(--success), #34d399);
  box-shadow: 0 0 12px rgba(16, 185, 129, 0.45);
  transition: width 0.9s var(--spring-out), background 0.4s var(--spring-out), box-shadow 0.4s var(--spring-out);
}
.rl-fill.warn {
  background: linear-gradient(90deg, #fbbf24, var(--warning));
  box-shadow: 0 0 12px rgba(245, 158, 11, 0.45);
}
.rl-fill.crit {
  background: linear-gradient(90deg, var(--danger), #fb7185);
  box-shadow: 0 0 14px rgba(239, 68, 68, 0.55);
  animation: rlPulse 1.6s ease-in-out infinite;
}
@keyframes rlPulse {
  0%, 100% { box-shadow: 0 0 14px rgba(239, 68, 68, 0.55); }
  50%      { box-shadow: 0 0 22px rgba(239, 68, 68, 0.85); }
}
.rl-pct {
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-primary);
  min-width: 42px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.rl-pct.warn { color: var(--warning); }
.rl-pct.crit { color: var(--danger); }
.rl-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 4px;
}
.rl-meta b { color: var(--text-secondary); font-weight: 600; }
.rl-divider {
  border-top: 1px solid var(--glass-border);
  margin: 6px 0 2px;
  padding-top: 12px;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-muted);
  font-weight: 700;
}
.rl-empty { color: var(--text-muted); font-size: 12px; padding: 8px 0; }

/* ─────────────────────────────────────────────
   PAGE EDITOR — profile picture upload card
   ───────────────────────────────────────────── */
.pic-panel { overflow: visible; }
.pic-panel .panel-header { gap: 10px; }
.pic-status {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 0.3px;
  transition: color 0.2s var(--ease);
}
.pic-status.ok      { color: var(--success); }
.pic-status.err     { color: var(--danger); }
.pic-status.pending { color: var(--info); }

.pic-dropzone {
  display: block;
  position: relative;
  cursor: pointer;
  outline: none;
  margin-bottom: 16px;
}
.pic-frame {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  border-radius: 22px;
  overflow: hidden;
  background: var(--logo-tile);
  border: 1px solid var(--glass-border);
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.05);
  transition:
    border-color 0.25s var(--spring-out, cubic-bezier(0.32, 0.72, 0, 1)),
    transform 0.25s var(--spring-out, cubic-bezier(0.32, 0.72, 0, 1)),
    box-shadow 0.3s var(--spring-out, cubic-bezier(0.32, 0.72, 0, 1));
}
.pic-frame img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: filter 0.25s var(--ease), transform 0.45s var(--spring-out, cubic-bezier(0.32, 0.72, 0, 1));
}
.pic-fallback-letter {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: clamp(64px, 10vw, 112px);
  font-weight: 700;
  color: rgba(255, 255, 255, 0.5);
  letter-spacing: -2px;
}
.pic-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: linear-gradient(180deg, rgba(0,0,0,0.0) 0%, rgba(0,0,0,0.6) 100%);
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.5px;
  opacity: 0;
  transition: opacity 0.25s var(--ease);
  pointer-events: none;
  text-align: center;
  padding: 20px;
}
.pic-overlay [data-icon] {
  width: 28px;
  height: 28px;
  opacity: 0.95;
}
.pic-overlay-text { line-height: 1.4; }

.pic-dropzone:hover .pic-frame { transform: translateY(-2px); border-color: var(--glass-border-hover); box-shadow: 0 18px 48px rgba(0, 0, 0, 0.5), 0 0 0 4px rgba(255, 255, 255, 0.04); }
.pic-dropzone:hover .pic-frame img { filter: brightness(0.55); transform: scale(1.04); }
.pic-dropzone:hover .pic-overlay { opacity: 1; }
.pic-dropzone:focus-visible .pic-frame { border-color: var(--accent-light); box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.18); }
.pic-dropzone.drag .pic-frame { border-color: var(--success); transform: scale(1.02); box-shadow: 0 0 0 4px var(--success-glow), 0 18px 48px rgba(0, 0, 0, 0.5); }
.pic-dropzone.drag .pic-frame img { filter: brightness(0.4); }
.pic-dropzone.drag .pic-overlay { opacity: 1; background: linear-gradient(180deg, rgba(16, 185, 129, 0.4) 0%, rgba(16, 185, 129, 0.7) 100%); }
.pic-dropzone.uploading .pic-frame img { filter: brightness(0.5) blur(1px); }
.pic-dropzone.uploading .pic-frame::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: 0;
  width: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--accent-light), var(--success));
  animation: picProgress 1.2s ease-in-out infinite;
}
@keyframes picProgress {
  0%   { width: 0%;   left: 0; }
  50%  { width: 60%;  left: 20%; }
  100% { width: 0%;   left: 100%; }
}

.pic-meta {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin: 4px 0 14px;
  padding: 10px 12px;
  background: var(--glass-surface);
  border: 1px solid var(--glass-border);
  border-radius: var(--r-md);
}
.pic-meta-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 12px;
  padding: 4px 0;
}
.pic-meta-row + .pic-meta-row { border-top: 1px solid rgba(255, 255, 255, 0.04); }
.pic-meta-row span { color: var(--text-muted); text-transform: uppercase; font-size: 9.5px; letter-spacing: 0.7px; font-weight: 700; }
.pic-meta-row strong { color: var(--text-primary); font-weight: 600; }

.pic-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

/* Optional URL fallback toggle */
.pic-fallback {
  margin: 6px 0 14px;
  padding: 10px 12px;
  background: var(--glass-surface);
  border: 1px solid var(--glass-border);
  border-radius: var(--r-md);
}
.pic-fallback summary {
  cursor: pointer;
  font-size: 11px;
  color: var(--text-muted);
  letter-spacing: 0.3px;
  user-select: none;
  list-style: none;
}
.pic-fallback summary::-webkit-details-marker { display: none; }
.pic-fallback summary::before { content: "+ "; font-weight: 700; color: var(--text-dim); }
.pic-fallback[open] summary::before { content: "− "; }

/* ─────────────────────────────────────────────
   DATA FRESHNESS PANEL — what's cached + when
   ───────────────────────────────────────────── */
.freshness-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}
.fresh-row {
  display: grid;
  grid-template-columns: 200px 1fr auto auto;
  align-items: center;
  gap: 14px;
  padding: 10px 14px;
  background: var(--glass-surface);
  border: 1px solid var(--glass-border);
  border-radius: var(--r-md);
  transition: background-color 0.2s var(--ease), border-color 0.2s var(--ease);
}
.fresh-row:hover { background: var(--glass-surface-hover); border-color: var(--glass-border-hover); }
.fresh-row-name {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
}
.fresh-row-name .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
  background: var(--success);
  box-shadow: 0 0 8px var(--success-glow);
}
.fresh-row-name .dot.stale { background: var(--warning); box-shadow: 0 0 8px var(--warning-glow); }
.fresh-row-name .dot.expired { background: var(--danger); box-shadow: 0 0 8px var(--danger-glow); }
.fresh-row-name .dot.empty { background: var(--text-dim); box-shadow: none; }

.fresh-row-detail {
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.5;
  font-family: 'JetBrains Mono', monospace;
  letter-spacing: 0.2px;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.fresh-row-detail b { color: var(--text-secondary); font-weight: 600; }

.fresh-row-age {
  font-size: 11px;
  color: var(--text-muted);
  font-family: 'JetBrains Mono', monospace;
  letter-spacing: 0.2px;
  white-space: nowrap;
  min-width: 90px;
  text-align: right;
}
.fresh-row-age.warn { color: var(--warning); }
.fresh-row-age.crit { color: var(--danger); }

.fresh-row-action {
  flex-shrink: 0;
}

/* Mini stats strip that sits under the hero card — replaces the bulky cards-grid */
.stats-strip {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}
.stats-strip .stat-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-radius: 999px;
  background: var(--glass-surface);
  border: 1px solid var(--glass-border);
  font-size: 12px;
  color: var(--text-secondary);
  transition: background 0.15s var(--ease), border-color 0.15s var(--ease), transform 0.12s var(--ease);
}
a.stat-pill { text-decoration: none; color: var(--text-secondary); }
.stat-pill:hover {
  background: var(--glass-surface-hover);
  border-color: var(--glass-border-hover);
  transform: translateY(-1px);
  color: var(--text-primary);
}
.stat-pill-val {
  font-weight: 700;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
}
.stat-pill-lbl {
  text-transform: uppercase;
  font-size: 10px;
  letter-spacing: 0.6px;
  color: var(--text-muted);
}

/* ---------------------------------------------------------------- */
/* Funnels feature                                                   */
/* ---------------------------------------------------------------- */

/* Funnels guide panel */
.guide-panel summary { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.guide-panel summary::-webkit-details-marker { display: none; }
.guide-panel[open] summary { border-bottom: 1px solid var(--border); }
.guide-panel ol { margin: 0; padding-left: 20px; line-height: 1.7; }
.guide-panel li { margin-bottom: 6px; }
.guide-panel .funnel-stage-name { font-weight: 600; color: var(--text); }

/* Funnels list — drag handle + drag states */
.drag-handle { cursor: grab; color: var(--text-muted); user-select: none; width: 24px; }
.drag-handle:active { cursor: grabbing; }
#funnels-table tr.dragging { opacity: 0.4; }
#funnels-table tr.drop-target { box-shadow: inset 0 2px 0 var(--accent); }

/* Funnel detail — stage timeline */
.stage-timeline { display: flex; gap: 8px; align-items: stretch; flex-wrap: wrap; }
.stage-card { flex: 1 1 140px; min-width: 140px; padding: 14px 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--glass-surface-hover); display: flex; flex-direction: column; gap: 6px; }
.stage-card .stage-label { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; }
.stage-card .stage-event { font-family: 'JetBrains Mono', monospace; font-size: 12px; color: var(--text); }
.stage-card .stage-count { font-size: 22px; font-weight: 600; color: var(--text); }
.stage-arrow { display: flex; align-items: center; color: var(--text-muted); font-size: 20px; }
@media (max-width: 720px) { .stage-arrow { display: none; } }

/* Test output box */
#test-output, #emq-output { background: var(--glass-surface-hover); border: 1px solid var(--border); border-radius: 8px; padding: 12px; font-size: 12px; }
#test-output:empty, #emq-output:empty { display: none; }

/* Payment page */
.pay-card { max-width: 480px; margin: 80px auto; }
.pay-summary { display: flex; justify-content: space-between; padding: 14px 20px; border-bottom: 1px solid var(--border); }
.pay-amount { font-size: 28px; font-weight: 600; }
#payment-element { padding: 20px; min-height: 220px; }
#pay-button { width: 100%; }

/* Funnel detail — Launch checklist */
.checklist-progress { display: flex; align-items: center; gap: 12px; padding: 14px 20px 12px; }
.checklist-progress-bar { flex: 1; height: 6px; background: var(--glass-surface-hover); border-radius: 3px; overflow: hidden; }
.checklist-progress-fill { height: 100%; background: var(--success); transition: width 0.3s var(--ease); }
.checklist-progress-text { font-size: 12px; color: var(--text-muted); font-variant-numeric: tabular-nums; min-width: 60px; text-align: right; }

.checklist-row { display: flex; align-items: flex-start; gap: 14px; padding: 14px 20px; border-bottom: 1px solid var(--border); }
.checklist-row:last-of-type { border-bottom: none; }
.checklist-row.is-done { opacity: 0.55; }
.checklist-row.is-done .checklist-title { text-decoration: line-through; }
.checklist-row.is-active { background: rgba(0, 129, 251, 0.04); border-left: 2px solid var(--accent, #0081FB); }

.checklist-check { width: 22px; height: 22px; flex-shrink: 0; border: 1.5px solid var(--border); border-radius: 6px; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; background: transparent; transition: all 0.15s var(--ease); padding: 0; margin-top: 2px; }
.checklist-check:hover { border-color: var(--accent, #0081FB); }
.checklist-check.is-checked { background: var(--success); border-color: var(--success); color: white; }
.checklist-check svg, .checklist-check::before { display: none; }
.checklist-check.is-checked::before { content: '✓'; font-size: 14px; font-weight: 700; display: inline-block; line-height: 1; }

.checklist-content { flex: 1; min-width: 0; }
.checklist-num { display: inline-flex; align-items: center; justify-content: center; width: 22px; height: 22px; border-radius: 50%; background: var(--glass-surface-hover); color: var(--text-muted); font-size: 11px; font-weight: 600; margin-right: 8px; }
.checklist-row.is-done .checklist-num { background: var(--success); color: white; }
.checklist-title { font-size: 13px; font-weight: 600; color: var(--text); display: inline; }
.checklist-desc { font-size: 12px; color: var(--text-muted); margin-top: 6px; line-height: 1.5; }

.checklist-actions { display: flex; gap: 6px; flex-shrink: 0; align-self: center; flex-wrap: wrap; justify-content: flex-end; }

.checklist-footer { padding: 12px 20px; display: flex; justify-content: space-between; align-items: center; font-size: 11px; color: var(--text-muted); border-top: 1px solid var(--border); }
.checklist-footer button { background: none; border: none; color: var(--accent, #0081FB); font-size: 11px; cursor: pointer; padding: 0; font-family: inherit; }
.checklist-footer button:hover { text-decoration: underline; }

.checklist-url-box { display: block; background: var(--glass-surface-hover); border: 1px solid var(--border); border-radius: 8px; padding: 12px; font-family: 'JetBrains Mono', monospace; font-size: 11px; color: var(--text); word-break: break-all; margin-top: 8px; cursor: pointer; line-height: 1.5; }
.checklist-url-box:hover { border-color: var(--accent, #0081FB); }

/* Funnel detail — Connection status panel */
.status-ribbon { display: flex; gap: 14px; padding-bottom: 14px; border-bottom: 1px solid var(--border); margin-bottom: 14px; flex-wrap: wrap; }
.status-ribbon-item { display: inline-flex; align-items: center; gap: 6px; font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; }
.status-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: var(--text-muted); transition: background 0.3s, box-shadow 0.3s; flex-shrink: 0; }
.status-dot-ok { background: var(--success); box-shadow: 0 0 6px rgba(16, 185, 129, 0.4); }
.status-dot-warn { background: var(--warning); box-shadow: 0 0 6px rgba(245, 158, 11, 0.4); }
.status-dot-error { background: var(--danger); box-shadow: 0 0 6px rgba(239, 68, 68, 0.4); }
.status-dot-info { background: var(--text-muted); }
.status-dot-pulse { animation: statusPulse 0.6s ease-out 2; }
@keyframes statusPulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.4); } }

.status-table { width: 100%; }
.status-table td { padding: 8px 12px; border-bottom: 1px solid var(--border); font-size: 12px; }
.status-table tr:last-child td { border-bottom: none; }
.status-cell-dot { width: 24px; }
.status-cell-label { width: 180px; color: var(--text-muted); }
.status-cell-detail { color: var(--text); font-size: 12px; }

.status-footer { display: flex; justify-content: space-between; align-items: center; margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--border); }

/* Funnel detail — Live walkthrough panel */
.walkthrough-progress-bar { height: 4px; background: var(--glass-surface-hover); border-radius: 2px; overflow: hidden; margin: 12px 0 18px; }
.walkthrough-progress-fill { height: 100%; background: var(--success); width: 0%; transition: width 0.4s var(--ease); }

.walkthrough-step { display: flex; gap: 14px; padding: 16px 0; border-bottom: 1px solid var(--border); }
.walkthrough-step:last-child { border-bottom: none; }
.walkthrough-status { width: 24px; height: 24px; border-radius: 50%; border: 2px solid var(--border); flex-shrink: 0; display: inline-flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 700; transition: all 0.3s; background: transparent; }
.walkthrough-step[data-state="watching"] .walkthrough-status { border-color: var(--warning); background: rgba(245, 158, 11, 0.15); animation: walkthroughPulse 1.2s infinite; }
.walkthrough-step[data-state="watching"] .walkthrough-status::after { content: '⏵'; color: var(--warning); }
.walkthrough-step[data-state="detected"] .walkthrough-status { border-color: var(--success); background: var(--success); color: white; }
.walkthrough-step[data-state="detected"] .walkthrough-status::after { content: '✓'; }
.walkthrough-step[data-state="timeout"] .walkthrough-status { border-color: var(--danger); background: rgba(239, 68, 68, 0.15); }
.walkthrough-step[data-state="timeout"] .walkthrough-status::after { content: '✕'; color: var(--danger); }

@keyframes walkthroughPulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.4); } 50% { box-shadow: 0 0 0 8px rgba(245, 158, 11, 0); } }

.walkthrough-content { flex: 1; min-width: 0; }
.walkthrough-title { font-size: 13px; font-weight: 600; color: var(--text); margin-bottom: 4px; }
.walkthrough-actions { margin-top: 8px; }
.walkthrough-result { margin-top: 6px; font-size: 11px; }
.walkthrough-step[data-state="detected"] .walkthrough-result { color: var(--success); }
.walkthrough-step[data-state="timeout"] .walkthrough-result { color: var(--danger); }

.walkthrough-footer { display: flex; justify-content: space-between; align-items: center; margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--glass-border); }

/* ---------------------------------------------------------------------- */
/* Funnel flow visualization (full diagram on detail page)                */
/* ---------------------------------------------------------------------- */
.funnel-flow {
  display: flex; flex-direction: column; gap: 10px;
  position: relative;
  transition: box-shadow 0.25s var(--ease), border-color 0.25s var(--ease);
  border: 1px solid transparent; border-radius: 10px;
  padding: 0;
}
.funnel-flow.is-testing {
  border-color: rgba(6, 182, 212, 0.45);
  box-shadow: 0 0 24px rgba(6, 182, 212, 0.18);
}
.funnel-flow-header {
  display: flex; align-items: center; justify-content: space-between;
  gap: 8px; min-height: 22px;
}
.funnel-flow-title {
  font-size: 12px; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 0.6px; font-weight: 600;
}
.funnel-flow-mode-badge {
  display: inline-block; min-height: 18px;
  font-size: 11px; font-weight: 600; color: var(--info);
  padding: 2px 8px; border-radius: 999px;
  background: var(--info-glow); border: 1px solid rgba(6, 182, 212, 0.35);
  opacity: 0; transition: opacity 0.2s var(--ease);
}
.funnel-flow.is-testing .funnel-flow-mode-badge { opacity: 1; }

.funnel-flow-body { display: flex; flex-direction: column; }
.funnel-flow-stages { display: flex; flex-direction: column; gap: 4px; }

/* One stage row: [bar] [meta]. Bar is its own column with a max width
   so a 1-event stage doesn't stretch full-width and look fake. */
.funnel-stage {
  position: relative;
  display: flex; align-items: center; gap: 14px;
  padding: 10px 12px; border-radius: 10px;
  background: var(--glass-surface);
  border: 1px solid var(--glass-border);
  transition: background 0.2s var(--ease), border-color 0.2s var(--ease), box-shadow 0.2s var(--ease);
}
.funnel-stage:hover {
  background: var(--glass-surface-hover);
  border-color: var(--glass-border-hover);
}
.funnel-stage-bar {
  flex: 0 0 38%;
  max-width: 38%;
  height: 18px;
  background: var(--glass-surface-active);
  border-radius: 4px;
  overflow: hidden;
  position: relative;
}
.funnel-stage-bar-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.5s var(--ease), background 0.2s var(--ease), opacity 0.2s var(--ease);
  background: linear-gradient(90deg, rgba(255,255,255,0.18), rgba(255,255,255,0.08));
}
.funnel-stage.is-ok    .funnel-stage-bar-fill { background: linear-gradient(90deg, var(--success), rgba(16,185,129,0.5)); }
.funnel-stage.is-warn  .funnel-stage-bar-fill { background: linear-gradient(90deg, var(--warning), rgba(245,158,11,0.5)); }
.funnel-stage.is-error .funnel-stage-bar-fill { background: linear-gradient(90deg, var(--danger),  rgba(239,68,68,0.5)); }
.funnel-stage.is-neutral .funnel-stage-bar-fill { background: linear-gradient(90deg, rgba(255,255,255,0.18), rgba(255,255,255,0.06)); }

.funnel-stage-meta { flex: 1; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.funnel-stage-line1 { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.funnel-stage-count { font-size: 18px; font-weight: 700; color: var(--text-primary); font-variant-numeric: tabular-nums; }
.funnel-stage-title { font-size: 13px; color: var(--text-secondary); font-weight: 500; }
.funnel-stage-value { font-size: 12px; color: var(--text-muted); }
.funnel-stage-line2 { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-size: 11px; color: var(--text-muted); }
.funnel-stage-event { font-size: 11px; color: var(--text-secondary); }
.funnel-stage-sep { color: var(--text-dim); }
.funnel-stage-fired { font-size: 11px; }
.funnel-stage.is-ok    .funnel-stage-capi { color: var(--success); }
.funnel-stage.is-warn  .funnel-stage-capi { color: var(--warning); }
.funnel-stage.is-error .funnel-stage-capi { color: var(--danger); }
.funnel-stage-capi-empty { color: var(--text-dim); font-style: italic; }

/* Drop-off row between stages */
.funnel-dropoff {
  display: flex; align-items: center; gap: 10px;
  padding: 2px 12px 2px 14px; margin-left: 24px;
  font-size: 11px; color: var(--text-muted);
  height: 18px;
}
.funnel-dropoff-arrow { color: var(--text-dim); font-size: 14px; line-height: 1; }
.funnel-dropoff-text { white-space: nowrap; }
.funnel-dropoff-pct { color: var(--warning); font-weight: 600; }

/* Live + test pulses */
@keyframes funnel-pulse {
  0%   { box-shadow: 0 0 0 0   rgba(6, 182, 212, 0.55); }
  60%  { box-shadow: 0 0 0 12px rgba(6, 182, 212, 0); }
  100% { box-shadow: 0 0 0 0   rgba(6, 182, 212, 0); }
}
@keyframes funnel-flash-ok {
  0%   { background: rgba(16, 185, 129, 0.18); }
  100% { background: var(--glass-surface); }
}
@keyframes funnel-flash-fail {
  0%   { background: rgba(239, 68, 68, 0.20); }
  100% { background: var(--glass-surface); }
}
.funnel-stage.is-pulsing { animation: funnel-pulse 1.4s var(--ease) 1; border-color: rgba(6, 182, 212, 0.55); }
.funnel-stage.is-flash-ok { animation: funnel-flash-ok 1.6s var(--ease) 1; border-color: rgba(16, 185, 129, 0.55); }
.funnel-stage.is-flash-fail { animation: funnel-flash-fail 1.6s var(--ease) 1; border-color: rgba(239, 68, 68, 0.55); }
.funnel-stage.is-live::after {
  content: ''; position: absolute; top: 10px; right: 10px;
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--info);
  box-shadow: 0 0 8px var(--info-glow);
}

/* Summary line under the stages */
.funnel-flow-summary {
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px;
  padding: 8px 12px; border-radius: 10px;
  background: var(--glass-surface);
  border: 1px solid var(--glass-border);
  font-size: 12px; color: var(--text-secondary);
}
.funnel-flow-summary-item { white-space: nowrap; }
.funnel-flow-summary-sep { color: var(--text-dim); }

/* Trace cards (test mode) */
.funnel-flow-traces { display: flex; flex-direction: column; gap: 6px; }
.funnel-flow-traces:empty { display: none; }
.funnel-trace-card {
  border-radius: 8px; border: 1px solid var(--glass-border);
  background: var(--glass-surface); padding: 8px 10px;
  font-size: 12px;
}
.funnel-trace-card.is-ok   { border-color: rgba(16, 185, 129, 0.40); }
.funnel-trace-card.is-fail { border-color: rgba(239, 68, 68, 0.40); }
.funnel-trace-head {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  margin-bottom: 4px;
}
.funnel-trace-when { font-size: 11px; color: var(--text-muted); }
.funnel-trace-stage { font-weight: 600; color: var(--text-secondary); }
.funnel-trace-event { font-size: 11px; color: var(--text-muted); }
.funnel-trace-body { display: flex; flex-direction: column; gap: 4px; }
.funnel-trace-kv { display: inline-flex; gap: 6px; align-items: baseline; font-size: 11px; }
.funnel-trace-key { color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.4px; font-size: 10px; }
.funnel-trace-val { color: var(--text-secondary); word-break: break-all; }
.funnel-trace-response {
  font-size: 11px; color: var(--text-muted); background: var(--bg-elevated);
  padding: 6px 8px; border-radius: 6px; border: 1px solid var(--glass-border);
  max-height: 160px; overflow: auto; white-space: pre-wrap;
}
.funnel-trace-link { font-size: 11px; color: var(--info); }

/* Responsive: collapse bar to top, meta below, on narrow screens */
@media (max-width: 720px) {
  .funnel-stage { flex-direction: column; align-items: stretch; gap: 8px; }
  .funnel-stage-bar { flex: 0 0 18px; max-width: 100%; width: 100%; }
}

/* ---------------------------------------------------------------------- */
/* Mini funnel sparkline (one cell per row on funnels list)               */
/* ---------------------------------------------------------------------- */
.mini-funnel { display: inline-block; min-width: 180px; max-width: 220px; }
.mini-funnel-empty { color: var(--text-dim); }
.mini-funnel-bars { display: flex; gap: 4px; align-items: flex-end; height: 32px; }
.mini-funnel-col {
  flex: 1; display: flex; flex-direction: column; gap: 2px;
  min-width: 0; align-items: stretch;
}
.mini-funnel-bar {
  height: 16px; border-radius: 3px;
  background: linear-gradient(90deg, rgba(255,255,255,0.18), rgba(255,255,255,0.06));
  transition: width 0.4s var(--ease);
  min-width: 2px;
}
.mini-funnel-col.is-ok    .mini-funnel-bar { background: linear-gradient(90deg, var(--success), rgba(16,185,129,0.5)); }
.mini-funnel-col.is-warn  .mini-funnel-bar { background: linear-gradient(90deg, var(--warning), rgba(245,158,11,0.5)); }
.mini-funnel-col.is-error .mini-funnel-bar { background: linear-gradient(90deg, var(--danger),  rgba(239,68,68,0.5)); }
.mini-funnel-num {
  font-size: 10px; color: var(--text-muted); font-variant-numeric: tabular-nums;
  text-align: left; line-height: 1.2;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* ---------------------------------------------------------------------- */
/* Sessions dashboard                                                     */
/* ---------------------------------------------------------------------- */

/* Branded ✓✓✓ three-dot status indicator */
.branded-dots {
  display: inline-flex; gap: 3px; align-items: center;
}
.branded-dot {
  width: 8px; height: 8px; border-radius: 50%;
  display: inline-block;
}
.branded-dot.is-on  { background: var(--success); box-shadow: 0 0 4px var(--success-glow); }
.branded-dot.is-off { background: var(--glass-surface-active); border: 1px solid var(--glass-border); }

/* Live-pulse dot — cyan when the session has fired anything in last 60s */
.session-pulse-dot {
  display: inline-block;
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--glass-surface-active);
  vertical-align: middle;
  transition: background 0.3s var(--ease);
}
.session-pulse-dot.is-live {
  background: var(--info);
  box-shadow: 0 0 8px var(--info-glow);
  animation: session-pulse 1.6s ease-in-out infinite;
}
@keyframes session-pulse {
  0%, 100% { opacity: 1;   transform: scale(1); }
  50%      { opacity: 0.55; transform: scale(1.35); }
}

/* Move-to-model select inside the actions cell */
.session-move-select {
  background: var(--glass-surface);
  border: 1px solid var(--glass-border);
  color: var(--text-secondary);
  border-radius: 6px;
}
.session-move-select:hover { border-color: var(--glass-border-hover); }

/* The edit-session modal uses existing .modal / .modal-backdrop /
   .modal-title / .modal-sub / .modal-actions styles — no overrides needed. */
