/* Pishonserv AI CRM — Admin Portal Styles */

/* ══ Auth Screen — split layout ══════════════════════════════════════════════ */
#login-screen {
  min-height: 100vh;
  display: flex;
  background: var(--ps-bg);
  overflow: hidden;
}

/* ── Left: cinematic branded panel ─────────────────────── */
.auth-left {
  width: 52%;
  min-height: 100vh;
  background: linear-gradient(148deg, #0b1640 0%, #1a237e 42%, #283593 72%, #1565c0 100%);
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 64px 60px;
  overflow: hidden;
  flex-shrink: 0;
}
/* Background image slideshow */
.auth-bg-slides {
  position: absolute;
  inset: 0;
  z-index: 0;
}
.auth-bg-slide {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center;
  opacity: 0;
  transition: opacity 1.8s ease-in-out;
}
.auth-bg-slide.active { opacity: 1; }
.auth-slide-1 { background-image: url('/static/images/auth_bg_1.jpg'); }
.auth-slide-2 { background-image: url('/static/images/auth_bg_2.jpg'); }

/* Dark gradient overlay keeps text readable over any image */
.auth-bg-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(148deg,
    rgba(11,22,64,0.86)  0%,
    rgba(26,35,126,0.80) 42%,
    rgba(21,101,192,0.76) 100%);
  z-index: 1;
}
/* Grid pattern sits on top of overlay */
.auth-left::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(255,255,255,0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.03) 1px, transparent 1px);
  background-size: 44px 44px;
  pointer-events: none;
  z-index: 2;
}
.auth-orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(72px);
  pointer-events: none;
  z-index: 3;
}
.auth-orb-1 {
  width: 380px; height: 380px;
  background: radial-gradient(circle, rgba(124,77,255,0.55), transparent 70%);
  top: -110px; right: -70px;
  animation: orbFloat1 9s ease-in-out infinite;
}
.auth-orb-2 {
  width: 280px; height: 280px;
  background: radial-gradient(circle, rgba(0,176,255,0.4), transparent 70%);
  bottom: 60px; left: -60px;
  animation: orbFloat2 11s ease-in-out infinite;
}
.auth-orb-3 {
  width: 200px; height: 200px;
  background: radial-gradient(circle, rgba(255,215,64,0.28), transparent 70%);
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  animation: orbFloat3 13s ease-in-out infinite;
}
@keyframes orbFloat1 {
  0%,100% { transform: translate(0,0); }
  40%     { transform: translate(22px,-32px); }
  70%     { transform: translate(-14px,18px); }
}
@keyframes orbFloat2 {
  0%,100% { transform: translate(0,0); }
  35%     { transform: translate(-18px,24px); }
  65%     { transform: translate(14px,-20px); }
}
@keyframes orbFloat3 {
  0%,100% { transform: translate(-50%,-50%); }
  40%     { transform: translate(calc(-50% + 16px),calc(-50% - 22px)); }
  70%     { transform: translate(calc(-50% - 12px),calc(-50% + 16px)); }
}
.auth-left-inner {
  position: relative;
  z-index: 4;
  animation: authFadeUp 0.8s ease both;
}
.auth-brand-mark {
  width: 60px; height: 60px;
  background: linear-gradient(135deg,rgba(255,255,255,0.18),rgba(255,255,255,0.07));
  border: 1px solid rgba(255,255,255,0.22);
  border-radius: 16px;
  display: flex; align-items: center; justify-content: center;
  font-size: 24px; font-weight: 800; color: #fff;
  margin-bottom: 28px;
  letter-spacing: -1px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.28), inset 0 1px 0 rgba(255,255,255,0.15);
}
.auth-headline {
  font-size: 2.4rem; font-weight: 800; color: #fff;
  line-height: 1.12; margin-bottom: 10px; letter-spacing: -0.6px;
}
.auth-tagline {
  font-size: 0.95rem; color: rgba(255,255,255,0.58);
  margin-bottom: 36px; line-height: 1.6;
}
.auth-feat-list {
  list-style: none; padding: 0; margin: 0;
  display: flex; flex-direction: column; gap: 14px;
}
.auth-feat-list li {
  display: flex; align-items: center; gap: 12px;
  color: rgba(255,255,255,0.78); font-size: 0.88rem; font-weight: 500;
  animation: authFadeUp 0.7s ease both;
}
.auth-feat-list li:nth-child(1) { animation-delay: 0.08s; }
.auth-feat-list li:nth-child(2) { animation-delay: 0.16s; }
.auth-feat-list li:nth-child(3) { animation-delay: 0.24s; }
.auth-feat-list li:nth-child(4) { animation-delay: 0.32s; }
.auth-feat-icon {
  width: 34px; height: 34px; flex-shrink: 0;
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.14);
  border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
}
.auth-left-footer {
  position: absolute; bottom: 28px; left: 60px;
  font-size: 0.72rem; color: rgba(255,255,255,0.28);
  z-index: 4; letter-spacing: 0.3px;
}

/* ── Right: form panel ──────────────────────────────────── */
.auth-right {
  flex: 1; min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  background: var(--ps-surface);
  padding: 48px 52px;
  overflow-y: auto;
}
.auth-form-wrap {
  width: 100%; max-width: 360px;
  animation: authFadeUp 0.6s 0.12s ease both;
}
.auth-form-logo {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 36px;
}
.auth-logo-mark {
  width: 38px; height: 38px; flex-shrink: 0;
  background: linear-gradient(135deg, var(--ps-primary), var(--ps-gold));
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 15px; font-weight: 800; color: #fff; letter-spacing: -0.5px;
}
.auth-form-logo span {
  font-size: 0.95rem; font-weight: 700; color: var(--ps-text);
}
.auth-form-head { margin-bottom: 22px; }
.auth-heading {
  font-size: 1.65rem; font-weight: 800; color: var(--ps-text);
  margin-bottom: 5px; letter-spacing: -0.4px; line-height: 1.15;
}
.auth-subheading {
  font-size: 0.84rem; color: var(--ps-text-muted); line-height: 1.5;
}
.auth-footer-note {
  text-align: center; margin-top: 28px;
  font-size: 0.72rem; color: var(--ps-text-light);
}
.auth-portal-switch {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
  margin-top: 18px;
}
.auth-portal-switch a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  padding: 7px 8px;
  border: 1px solid var(--ps-border);
  border-radius: var(--ps-radius);
  background: var(--ps-surface-2);
  color: var(--ps-text-muted);
  font-size: 0.72rem;
  font-weight: 700;
  line-height: 1.2;
  text-align: center;
  text-decoration: none;
}
.auth-portal-switch a:hover,
.auth-portal-switch a.active {
  border-color: var(--ps-primary-light);
  color: var(--ps-primary);
  background: rgba(57, 73, 171, 0.08);
}

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

/* Login error banner */
.login-error {
  background: var(--ps-danger-bg);
  color: var(--ps-danger);
  border-radius: var(--ps-radius);
  padding: 10px 14px;
  font-size: 0.85rem;
  margin-bottom: 16px;
  display: none;
}
.login-error.visible { display: block; }

/* ── Mobile: cinematic stacked layout ────────────────────── */
@media (max-width: 768px) {
  #login-screen { flex-direction: column; min-height: 100vh; }

  /* Cinematic hero banner — tall enough to feel immersive */
  .auth-left {
    width: 100%;
    min-height: auto;
    height: 280px;
    padding: 0;
    justify-content: center;
    align-items: center;
    flex-shrink: 0;
  }
  .auth-left-inner {
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 0;
    padding: 0 28px;
  }
  .auth-brand-mark {
    width: 58px; height: 58px;
    font-size: 21px; border-radius: 16px;
    margin-bottom: 14px; flex-shrink: 0;
  }
  .auth-headline {
    font-size: 1.65rem;
    margin-bottom: 7px;
    text-align: center;
  }
  .auth-tagline {
    font-size: 0.79rem;
    margin-bottom: 0;
    text-align: center;
    max-width: 260px;
  }
  .auth-feat-list  { display: none; }
  .auth-left-footer { display: none; }
  .auth-orb-3 { display: none; }
  .auth-orb-1 { width: 230px; height: 230px; top: -75px; right: -55px; }
  .auth-orb-2 { width: 190px; height: 190px; bottom: -55px; left: -45px; }

  /* Frosted-glass divider between hero and form */
  .auth-left::after {
    content: '';
    position: absolute;
    bottom: 0; left: 0; right: 0;
    height: 60px;
    background: linear-gradient(to bottom, transparent, var(--ps-surface));
    z-index: 5;
    pointer-events: none;
  }

  /* Form panel — full width, scrollable */
  .auth-right {
    width: 100%;
    flex: 1;
    min-height: auto;
    padding: 32px 24px 64px;
    align-items: stretch;
    justify-content: flex-start;
    background: var(--ps-surface);
    overflow-y: auto;
  }
  .auth-form-wrap {
    max-width: 100%;
    animation: none;
    width: 100%;
  }
  .auth-portal-switch { grid-template-columns: 1fr; }
  .auth-form-logo { margin-bottom: 24px; }
  .auth-heading { font-size: 1.5rem; }
  .auth-subheading { font-size: 0.83rem; }
}

/* ── Small phones (≤ 375px) ─────────────────────────────── */
@media (max-width: 375px) {
  .auth-left { height: 240px; }
  .auth-brand-mark { width: 50px; height: 50px; font-size: 18px; }
  .auth-headline { font-size: 1.4rem; }
  .auth-right { padding: 24px 18px 56px; }
}

/* ── App Shell ──────────────────────────────────────────── */
#app-shell {
  display: grid;
  grid-template-columns: var(--ps-sidebar-width) 1fr;
  height: 100vh;
  overflow: hidden;
}

/* ── Sidebar ────────────────────────────────────────────── */
#sidebar {
  background: var(--ps-sidebar-bg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 0;
  z-index: 100;
  box-shadow: 2px 0 12px rgba(0,0,0,0.18);
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 18px 20px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  flex-shrink: 0;
}
.brand-mark {
  width: 36px;
  height: 36px;
  background: linear-gradient(135deg, var(--ps-gold-dark), var(--ps-gold));
  border-radius: var(--ps-radius);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 14px;
  color: #fff;
  flex-shrink: 0;
  letter-spacing: -0.5px;
}
.brand-text {
  flex: 1;
  overflow: hidden;
}
.brand-text strong {
  display: block;
  color: #fff;
  font-size: 0.9rem;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.brand-text span {
  font-size: 0.7rem;
  color: var(--ps-sidebar-muted);
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 12px 0;
  scrollbar-width: none;
}
.sidebar-nav::-webkit-scrollbar { display: none; }

.nav-group-label {
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ps-sidebar-muted);
  padding: 16px 20px 6px;
}

.nav-dropdown {
  margin: 2px 0;
}

.nav-group-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  min-height: 36px;
  padding: 10px 18px 8px 20px;
  border: 0;
  background: transparent;
  color: var(--ps-sidebar-muted);
  cursor: pointer;
  font-family: var(--ps-font);
  font-size: 0.65rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  line-height: 1.2;
  text-align: left;
  text-transform: uppercase;
  transition: color var(--ps-transition), background var(--ps-transition);
}

.nav-group-toggle:hover {
  color: #fff;
  background: rgba(255,255,255,0.04);
}

.nav-group-toggle-text {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nav-group-chevron {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  opacity: 0.75;
  transition: transform var(--ps-transition), opacity var(--ps-transition);
}

.nav-dropdown.open .nav-group-chevron {
  transform: rotate(90deg);
  opacity: 1;
}

.nav-dropdown-body {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows 0.22s ease;
}

.nav-dropdown.open .nav-dropdown-body {
  grid-template-rows: 1fr;
}

.nav-dropdown-body-inner {
  overflow: hidden;
}

.nav-dropdown .nav-item {
  padding-left: 24px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 20px;
  color: var(--ps-sidebar-text);
  cursor: pointer;
  border-radius: 0;
  transition: background var(--ps-transition);
  font-size: 0.875rem;
  font-weight: 500;
  position: relative;
  user-select: none;
  text-decoration: none;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
}
.nav-item:hover { background: var(--ps-sidebar-hover); text-decoration: none; color: #fff; }
.nav-item.active {
  background: var(--ps-sidebar-active);
  color: #fff;
}
.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: var(--ps-gold);
  border-radius: 0 2px 2px 0;
}
.nav-item .nav-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  opacity: 0.8;
}
.nav-item.active .nav-icon { opacity: 1; }

.sidebar-footer {
  padding: 14px 16px;
  border-top: 1px solid rgba(255,255,255,0.08);
  flex-shrink: 0;
}
.user-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  border-radius: var(--ps-radius);
  cursor: pointer;
  transition: background var(--ps-transition);
}
.user-card:hover { background: var(--ps-sidebar-hover); }
.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: var(--ps-radius-full);
  background: linear-gradient(135deg, var(--ps-gold-dark), var(--ps-gold));
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 12px;
  color: #fff;
  flex-shrink: 0;
}
.user-info { flex: 1; overflow: hidden; }
.user-info strong {
  display: block;
  color: #fff;
  font-size: 0.82rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.user-info small {
  color: var(--ps-sidebar-muted);
  font-size: 0.68rem;
  text-transform: capitalize;
}

/* ── Main wrap ──────────────────────────────────────────── */
#main-wrap {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 0;
  background: var(--ps-bg);
}

/* ── Topbar ─────────────────────────────────────────────── */
#topbar {
  height: var(--ps-topbar-height);
  background: var(--ps-surface);
  border-bottom: 1px solid var(--ps-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  flex-shrink: 0;
  box-shadow: var(--ps-shadow-xs);
}
.topbar-left { display: flex; align-items: center; gap: 16px; }
#page-title { font-size: 1.05rem; font-weight: 700; color: var(--ps-text); }
.breadcrumb { font-size: 0.78rem; color: var(--ps-text-muted); }

.topbar-right { display: flex; align-items: center; gap: 10px; }

/* ── Theme segmented control ─────────────────────────────── */
.theme-switcher {
  display: flex;
  align-items: center;
  background: var(--ps-surface-2);
  border: 1px solid var(--ps-border);
  border-radius: var(--ps-radius);
  padding: 3px;
  gap: 2px;
  flex-shrink: 0;
}
.theme-sw-btn {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: calc(var(--ps-radius) - 2px);
  border: none;
  background: transparent;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--ps-text-muted);
  cursor: pointer;
  white-space: nowrap;
  font-family: var(--ps-font);
  transition: background 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
  line-height: 1;
}
.theme-sw-btn.active {
  background: var(--ps-surface);
  color: var(--ps-text);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.10);
}
/* Sun button active — warm amber */
.theme-sw-btn[data-theme="light"].active {
  background: #fef3c7;
  color: #b45309;
  box-shadow: 0 1px 4px rgba(180, 83, 9, 0.18);
}
/* Moon button active — cool indigo */
.theme-sw-btn[data-theme="dark"].active {
  background: #312e81;
  color: #c7d2fe;
  box-shadow: 0 1px 4px rgba(99, 102, 241, 0.35);
}
.theme-sw-btn:hover:not(.active) { color: var(--ps-text); }

#logout-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: var(--ps-radius);
  border: 1px solid var(--ps-border);
  background: var(--ps-surface-2);
  color: var(--ps-text-muted);
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 500;
  font-family: var(--ps-font);
  transition: all var(--ps-transition);
}
#logout-btn:hover { background: var(--ps-danger-bg); color: var(--ps-danger); border-color: var(--ps-danger); }

/* ── Content Area ───────────────────────────────────────── */
#content-area {
  flex: 1;
  overflow-y: auto;
  min-height: 0;
  padding: 28px 28px 40px;
}

.content-section {
  display: none;
  opacity: 0;
  animation: sectionFadeIn 0.4s ease both;
}
.content-section.active {
  display: block;
  opacity: 1;
}

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

/* ── Section Headers ────────────────────────────────────── */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  gap: 16px;
  flex-wrap: wrap;
}
.section-header h2 {
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--ps-text);
}
.section-header-actions { display: flex; gap: 10px; flex-wrap: wrap; }

/* ── Stats Grid ─────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}
.stat-card {
  background: var(--ps-surface);
  border-radius: var(--ps-radius-lg);
  padding: 20px 20px 18px;
  box-shadow: var(--ps-shadow-sm);
  border: 1px solid var(--ps-border);
  border-left: 4px solid var(--ps-border);
  display: flex;
  flex-direction: column;
  gap: 6px;
  transition: box-shadow var(--ps-transition), transform var(--ps-transition);
  position: relative;
  overflow: hidden;
}
.stat-card::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(255,255,255,0.025) 0%, transparent 60%);
  pointer-events: none;
}
.stat-card:hover {
  box-shadow: var(--ps-shadow);
  transform: translateY(-2px);
}
.stat-card.primary  { border-left-color: var(--ps-primary-light); }
.stat-card.success  { border-left-color: var(--ps-success); }
.stat-card.danger   { border-left-color: var(--ps-danger); }
.stat-card.info     { border-left-color: var(--ps-info); }
.stat-card.gold     { border-left-color: var(--ps-gold-dark); }

.stat-label { font-size: 0.72rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.07em; color: var(--ps-text-muted); }
.stat-value { font-size: 2.35rem; font-weight: 900; color: var(--ps-text); line-height: 1; letter-spacing: -1px; margin: 2px 0; }
.stat-sub   { font-size: 0.76rem; color: var(--ps-text-light); }
.stat-card.primary .stat-value { color: var(--ps-primary-light); }
.stat-card.gold    .stat-value { color: var(--ps-gold-dark); }
.stat-card.success .stat-value { color: var(--ps-success); }
.stat-card.danger  .stat-value { color: var(--ps-danger); }
.stat-card.info    .stat-value { color: var(--ps-info); }

/* ── Dashboard greeting banner ───────────────────────────── */
.dash-greeting {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 24px;
}
.dash-greeting-text h2 {
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--ps-text);
  margin: 0 0 3px;
}
.dash-greeting-text p {
  font-size: 0.84rem;
  color: var(--ps-text-muted);
  margin: 0;
}

/* ── Onboarding / Get Started banner ─────────────────────── */
.onboarding-banner {
  background: linear-gradient(135deg, var(--ps-primary) 0%, #1565c0 60%, #283593 100%);
  border-radius: var(--ps-radius-lg);
  padding: 22px 28px;
  margin-bottom: 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  box-shadow: 0 4px 20px rgba(21,101,192,0.35);
}
.onboarding-banner-content h3 {
  font-size: 1.05rem;
  font-weight: 800;
  color: #fff;
  margin: 0 0 6px;
}
.onboarding-banner-content p {
  font-size: 0.83rem;
  color: rgba(255,255,255,0.78);
  margin: 0;
}
.onboarding-steps {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 14px;
}
.onboarding-step {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 0.8rem;
  color: rgba(255,255,255,0.9);
  background: rgba(255,255,255,0.12);
  border-radius: 20px;
  padding: 5px 12px;
  cursor: pointer;
  border: 1px solid rgba(255,255,255,0.18);
  transition: background 0.18s;
}
.onboarding-step:hover { background: rgba(255,255,255,0.22); }
.onboarding-step svg { flex-shrink: 0; opacity: 0.9; }
.onboarding-banner-dismiss {
  background: rgba(255,255,255,0.15);
  border: 1px solid rgba(255,255,255,0.25);
  color: rgba(255,255,255,0.85);
  border-radius: var(--ps-radius);
  padding: 7px 16px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.18s;
}
.onboarding-banner-dismiss:hover { background: rgba(255,255,255,0.25); }

/* ── Cards / Panels ─────────────────────────────────────── */
.panel {
  background: var(--ps-surface);
  border-radius: var(--ps-radius-lg);
  border: 1px solid var(--ps-border);
  box-shadow: var(--ps-shadow-sm);
  overflow: hidden;
}
.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--ps-border);
}
.panel-header h3 { font-size: 0.95rem; font-weight: 700; }
.panel-body { padding: 20px; }
.panel-body.no-pad { padding: 0; }

/* ── Tables ─────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}
thead th {
  background: var(--ps-surface-2);
  color: var(--ps-text-muted);
  font-weight: 600;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 10px 16px;
  text-align: left;
  border-bottom: 1px solid var(--ps-border);
  white-space: nowrap;
}
tbody tr { border-bottom: 1px solid var(--ps-border); transition: background var(--ps-transition); }
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: var(--ps-surface-2); }
tbody td { padding: 12px 16px; color: var(--ps-text); vertical-align: middle; }
.td-muted { color: var(--ps-text-muted); font-size: 0.8rem; }
.td-nowrap { white-space: nowrap; }
.table-empty {
  text-align: center;
  padding: 48px 16px;
  color: var(--ps-text-muted);
}
.table-empty .empty-icon { font-size: 2.5rem; margin-bottom: 12px; }
.table-empty p { font-size: 0.9rem; }

/* ── Badges / Status ────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 9px;
  border-radius: var(--ps-radius-full);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  white-space: nowrap;
}
.badge-success  { background: var(--ps-success-bg); color: var(--ps-success); }
.badge-warning  { background: var(--ps-warning-bg); color: var(--ps-warning); }
.badge-danger   { background: var(--ps-danger-bg);  color: var(--ps-danger); }
.badge-info     { background: var(--ps-info-bg);    color: var(--ps-info); }
.badge-neutral  { background: var(--ps-surface-2);  color: var(--ps-text-muted); border: 1px solid var(--ps-border); }
.badge-primary  { background: #e8eaf6; color: var(--ps-primary); }

/* ── Buttons ────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 16px;
  border-radius: var(--ps-radius);
  font-weight: 600;
  font-size: 0.85rem;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all var(--ps-transition);
  white-space: nowrap;
  line-height: 1.4;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary {
  background: var(--ps-primary);
  color: #fff;
  border-color: var(--ps-primary);
}
.btn-primary:hover { background: var(--ps-primary-light); border-color: var(--ps-primary-light); }
.btn-gold {
  background: var(--ps-gold);
  color: #fff;
  border-color: var(--ps-gold);
}
.btn-gold:hover { background: var(--ps-gold-dark); border-color: var(--ps-gold-dark); }
.btn-outline {
  background: transparent;
  color: var(--ps-primary);
  border-color: var(--ps-primary);
}
.btn-outline:hover { background: var(--ps-primary); color: #fff; }
.btn-ghost {
  background: var(--ps-surface-2);
  color: var(--ps-text-muted);
  border-color: var(--ps-border);
}
.btn-ghost:hover { background: var(--ps-border); color: var(--ps-text); }
.btn-danger {
  background: var(--ps-danger);
  color: #fff;
  border-color: var(--ps-danger);
}
.btn-danger:hover { background: #a31515; }
.btn-sm { padding: 5px 11px; font-size: 0.78rem; }
.btn-icon { padding: 7px; gap: 0; }

/* ── Forms ──────────────────────────────────────────────── */
.form-grid {
  display: grid;
  gap: 16px;
}
.form-grid-2 { grid-template-columns: 1fr 1fr; }
.form-grid-3 { grid-template-columns: 1fr 1fr 1fr; }
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-group label { font-size: 0.82rem; font-weight: 600; color: var(--ps-text); }

/* ── Form section labels ─────────────────────────────────── */
.form-section-label {
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--ps-text-muted);
  padding: 4px 0 2px;
  border-bottom: 1px solid var(--ps-border);
  margin-top: 4px;
}
.form-control {
  padding: 9px 13px;
  border: 1px solid var(--ps-border);
  border-radius: var(--ps-radius);
  background: var(--ps-surface);
  color: var(--ps-text);
  font-size: 0.875rem;
  transition: border-color var(--ps-transition), box-shadow var(--ps-transition);
  width: 100%;
}
.form-control:focus {
  outline: none;
  border-color: var(--ps-primary-light);
  box-shadow: 0 0 0 3px rgba(57,73,171,0.12);
}
.form-control::placeholder { color: var(--ps-text-light); }
textarea.form-control { min-height: 100px; resize: vertical; }
select.form-control { cursor: pointer; }
.form-hint { font-size: 0.75rem; color: var(--ps-text-muted); }
.form-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  padding-top: 8px;
}

/* ── Modal ──────────────────────────────────────────────── */
#modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  backdrop-filter: blur(2px);
}
#modal-overlay[hidden] { display: none; }

.modal-box {
  background: var(--ps-surface);
  border-radius: var(--ps-radius-xl);
  box-shadow: var(--ps-shadow-xl);
  width: 100%;
  max-width: 600px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.modal-box.modal-lg { max-width: 820px; }
.modal-box.modal-sm { max-width: 420px; }

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 24px;
  border-bottom: 1px solid var(--ps-border);
  flex-shrink: 0;
}
.modal-header h3 { font-size: 1rem; font-weight: 700; }
.modal-close {
  width: 30px; height: 30px;
  border: none; background: none;
  cursor: pointer;
  color: var(--ps-text-muted);
  border-radius: var(--ps-radius);
  display: flex; align-items: center; justify-content: center;
  font-size: 20px;
  transition: background var(--ps-transition);
}
.modal-close:hover { background: var(--ps-surface-2); color: var(--ps-text); }

.modal-body {
  padding: 24px;
  overflow-y: auto;
  flex: 1;
}
.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--ps-border);
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  flex-shrink: 0;
}

/* ── Toast ──────────────────────────────────────────────── */
#toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}
.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 18px;
  border-radius: var(--ps-radius-lg);
  box-shadow: var(--ps-shadow-lg);
  font-size: 0.875rem;
  font-weight: 500;
  pointer-events: all;
  animation: toastIn 0.25s ease;
  max-width: 380px;
  border-left: 4px solid;
}
.toast-success { background: var(--ps-surface); border-color: var(--ps-success); color: var(--ps-text); }
.toast-error   { background: var(--ps-surface); border-color: var(--ps-danger);  color: var(--ps-text); }
.toast-warning { background: var(--ps-surface); border-color: var(--ps-warning); color: var(--ps-text); }
.toast-info    { background: var(--ps-surface); border-color: var(--ps-info);    color: var(--ps-text); }
.toast-icon { font-size: 1.1rem; flex-shrink: 0; }
.toast-msg { flex: 1; }
@keyframes toastIn {
  from { opacity: 0; transform: translateX(30px); }
  to   { opacity: 1; transform: translateX(0); }
}

/* ── Toolbar ────────────────────────────────────────────── */
.toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.toolbar-left { display: flex; align-items: center; gap: 10px; flex: 1; }
.toolbar-right { display: flex; align-items: center; gap: 10px; }
.search-input {
  padding: 8px 14px 8px 36px;
  border: 1px solid var(--ps-border);
  border-radius: var(--ps-radius-full);
  background: var(--ps-surface);
  color: var(--ps-text);
  font-size: 0.85rem;
  width: 220px;
  transition: all var(--ps-transition);
}
.search-input:focus { outline: none; border-color: var(--ps-primary-light); width: 280px; box-shadow: 0 0 0 3px rgba(57,73,171,0.1); }
.search-wrap { position: relative; }
.search-icon {
  position: absolute;
  left: 11px; top: 50%;
  transform: translateY(-50%);
  color: var(--ps-text-light);
  font-size: 14px;
  pointer-events: none;
}

/* ── Status indicators ──────────────────────────────────── */
.status-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}
.status-dot.green  { background: var(--ps-success); box-shadow: 0 0 0 2px var(--ps-success-bg); }
.status-dot.red    { background: var(--ps-danger);  box-shadow: 0 0 0 2px var(--ps-danger-bg); }
.status-dot.yellow { background: var(--ps-warning); box-shadow: 0 0 0 2px var(--ps-warning-bg); }
.status-dot.grey   { background: var(--ps-text-light); }

/* ── Integration cards ──────────────────────────────────── */
.integration-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
}
.integration-card {
  background: var(--ps-surface);
  border: 1px solid var(--ps-border);
  border-radius: var(--ps-radius-lg);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  box-shadow: var(--ps-shadow-sm);
}
.integration-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.integration-name { font-weight: 700; font-size: 0.95rem; }
.integration-detail { font-size: 0.78rem; color: var(--ps-text-muted); }

/* ── Location Intelligence ───────────────────────────────── */
.loc-intel-stats {
  gap: 14px !important;
  margin-bottom: 20px !important;
}
.loc-intel-stats .stat-card {
  margin: 0;
  border-radius: var(--ps-radius-lg);
}

.loc-intel-actions {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  margin-bottom: 16px;
}
.loc-intel-actions .panel {
  margin: 0;
  border-radius: var(--ps-radius-lg);
}
.loc-action-card {
  background: var(--ps-surface);
  border: 1px solid var(--ps-border);
  border-radius: var(--ps-radius-lg);
  padding: 16px 18px;
  display: flex;
  align-items: flex-start;
  gap: 14px;
  box-shadow: var(--ps-shadow-sm);
}
.loc-action-icon {
  width: 42px;
  height: 42px;
  border-radius: var(--ps-radius);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.loc-action-icon.info    { background: var(--ps-info-bg);    color: var(--ps-info); }
.loc-action-icon.warning { background: var(--ps-warning-bg); color: var(--ps-warning); }
.loc-action-icon.success { background: var(--ps-success-bg); color: var(--ps-success); }
.loc-action-body { flex: 1; min-width: 0; }
.loc-action-title { font-size: 0.88rem; font-weight: 700; color: var(--ps-text); margin-bottom: 4px; }
.loc-action-desc  { font-size: 0.78rem; color: var(--ps-text-muted); line-height: 1.5; }
.loc-action-card .btn { margin-top: 12px; white-space: nowrap; flex-shrink: 0; align-self: flex-end; }

.loc-intel-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}
/* 4-panel breakdown: column gap only, no row gap — panels in same row flush together */
.loc-intel-breakdown {
  gap: 14px !important;
  margin-top: 0;
}
.loc-intel-actions + .loc-intel-breakdown { margin-top: 0; }
.loc-intel-breakdown .panel {
  border-radius: var(--ps-radius-lg);
  border: 1px solid var(--ps-border);
  margin: 0;
}

.loc-intel-segments {
  margin-top: 20px !important;
  border-radius: var(--ps-radius-lg);
}

/* Empty table hint row */
.td-empty-hint {
  text-align: center;
  padding: 24px 16px !important;
  color: var(--ps-text-muted);
  font-size: 0.82rem;
  font-style: italic;
}

/* Location segments chips */
.loc-segments-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 16px 20px;
}
.loc-segment-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  background: var(--ps-surface-2);
  border: 1px solid var(--ps-border);
  border-radius: var(--ps-radius-full);
  font-size: 0.8rem;
  cursor: default;
  transition: border-color var(--ps-transition);
}
.loc-segment-chip:hover { border-color: var(--ps-primary); }
.loc-segment-chip.loc-segment-empty { opacity: 0.45; }
.loc-segment-name { font-weight: 600; color: var(--ps-text); }
.loc-segment-count {
  background: var(--ps-primary);
  color: #fff;
  border-radius: var(--ps-radius-full);
  font-size: 0.68rem;
  font-weight: 700;
  padding: 1px 7px;
  min-width: 20px;
  text-align: center;
}
.loc-segment-chip.loc-segment-empty .loc-segment-count { background: var(--ps-border); color: var(--ps-text-muted); }

@media (max-width: 900px) {
  .loc-intel-actions { grid-template-columns: 1fr; }
  .loc-intel-grid-2  { grid-template-columns: 1fr; }
}

/* ── Campaign report ────────────────────────────────────── */
.report-stats {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  gap: 10px;
  margin-bottom: 20px;
}
.report-stat {
  background: var(--ps-surface-2);
  border: 1px solid var(--ps-border);
  border-radius: var(--ps-radius);
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.report-stat-val {
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--ps-text);
  line-height: 1;
}
.report-stat-label {
  font-size: 0.72rem;
  color: var(--ps-text-muted);
  font-weight: 500;
}
.report-stat-success .report-stat-val { color: var(--ps-success); }
.report-stat-info    .report-stat-val { color: var(--ps-primary); }
.report-stat-warning .report-stat-val { color: var(--ps-warning); }
.report-stat-danger  .report-stat-val { color: var(--ps-danger); }
.report-bars { margin-top: 4px; }

/* ── Plain text preview pane ─────────────────────────────── */
.txt-preview-pre {
  margin: 0;
  padding: 18px 20px;
  font-family: var(--ps-font-mono);
  font-size: 0.82rem;
  line-height: 1.7;
  color: var(--ps-text);
  background: var(--ps-surface-2);
  white-space: pre-wrap;
  word-break: break-word;
  min-height: 120px;
  max-height: 340px;
  overflow-y: auto;
}
.report-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--ps-border);
}
.report-row:last-child { border-bottom: none; }
.report-label { flex: 1; font-size: 0.85rem; color: var(--ps-text-muted); text-transform: capitalize; }
.report-bar-wrap { flex: 2; background: var(--ps-border); border-radius: var(--ps-radius-full); height: 6px; overflow: hidden; }
.report-bar { height: 100%; border-radius: var(--ps-radius-full); background: var(--ps-primary); transition: width 0.5s ease; }
.report-val { font-size: 0.85rem; font-weight: 700; color: var(--ps-text); min-width: 40px; text-align: right; }

/* ── AI Discovery & SEO Readiness ───────────────────────── */
.ai-disc-banner {
  border-radius: var(--ps-radius-lg);
  padding: 20px 24px;
  margin-bottom: 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  border: 1px solid;
}
.ai-disc-banner.ready    { background: var(--ps-success-bg); border-color: var(--ps-success); }
.ai-disc-banner.not-ready{ background: var(--ps-warning-bg); border-color: var(--ps-warning); }
.ai-disc-banner-inner { display: flex; align-items: center; gap: 16px; flex: 1; }
.ai-disc-banner-icon {
  width: 46px; height: 46px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.ai-disc-banner.ready     .ai-disc-banner-icon { background: var(--ps-success); color: #fff; }
.ai-disc-banner.not-ready .ai-disc-banner-icon { background: var(--ps-warning); color: #fff; }
.ai-disc-banner-text h3 { font-size: 1rem; font-weight: 700; margin: 0 0 3px; }
.ai-disc-banner.ready     .ai-disc-banner-text h3 { color: var(--ps-success); }
.ai-disc-banner.not-ready .ai-disc-banner-text h3 { color: var(--ps-warning); }
.ai-disc-banner-text p { font-size: 0.82rem; color: var(--ps-text-muted); margin: 0; line-height: 1.5; }
.ai-disc-score-pill {
  display: flex; align-items: center; gap: 8px;
  padding: 9px 20px;
  border-radius: var(--ps-radius-full);
  font-weight: 800; font-size: 1.1rem;
  white-space: nowrap;
}
.ai-disc-banner.ready     .ai-disc-score-pill { background: var(--ps-success); color: #fff; }
.ai-disc-banner.not-ready .ai-disc-score-pill { background: var(--ps-warning); color: #fff; }

/* Checklist */
.ai-disc-checklist-item {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--ps-border);
}
.ai-disc-checklist-item:last-child { border-bottom: none; }
.ai-disc-check-icon {
  width: 28px; height: 28px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  margin-top: 1px;
}
.ai-disc-check-icon.pass  { background: var(--ps-success-bg); color: var(--ps-success); }
.ai-disc-check-icon.fail  { background: var(--ps-warning-bg); color: var(--ps-warning); }
.ai-disc-check-title  { font-size: 0.87rem; font-weight: 600; color: var(--ps-text); line-height: 1.4; }
.ai-disc-check-detail { font-size: 0.78rem; color: var(--ps-text-muted); margin-top: 2px; line-height: 1.45; }
.ai-disc-check-action {
  font-size: 0.77rem; color: var(--ps-warning); font-weight: 600;
  margin-top: 5px; display: flex; align-items: center; gap: 5px;
}

/* Agent Tools */
.ai-disc-tool-card {
  padding: 14px 0;
  border-bottom: 1px solid var(--ps-border);
}
.ai-disc-tool-card:last-of-type { border-bottom: none; padding-bottom: 0; }
.ai-disc-tool-name  { font-weight: 700; font-size: 0.88rem; color: var(--ps-text); margin-bottom: 3px; }
.ai-disc-tool-desc  { font-size: 0.79rem; color: var(--ps-text-muted); margin-bottom: 8px; line-height: 1.45; }
.ai-disc-endpoint {
  display: flex; align-items: center; gap: 8px;
  background: var(--ps-surface-2);
  border: 1px solid var(--ps-border);
  border-radius: var(--ps-radius);
  padding: 7px 10px 7px 12px;
}
.ai-disc-endpoint code {
  font-size: 0.72rem; color: var(--ps-primary-light);
  word-break: break-all; flex: 1;
  font-family: 'Courier New', Courier, monospace;
}
.ai-disc-copy-btn {
  background: none; border: none; cursor: pointer;
  color: var(--ps-text-muted); padding: 3px;
  display: flex; border-radius: 4px; flex-shrink: 0;
  transition: color 0.15s;
}
.ai-disc-copy-btn:hover { color: var(--ps-primary); }

/* AI Constraints box */
.ai-disc-rules {
  background: var(--ps-surface-2);
  border-radius: var(--ps-radius);
  border: 1px solid var(--ps-border);
  padding: 14px; margin-top: 16px;
}
.ai-disc-rules-title {
  font-size: 0.72rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.07em;
  color: var(--ps-text-muted); margin-bottom: 10px;
}
.ai-disc-rule-item {
  display: flex; align-items: flex-start; gap: 8px;
  font-size: 0.78rem; color: var(--ps-text-muted); padding: 3px 0;
}
.ai-disc-rule-dot {
  width: 5px; height: 5px; border-radius: 50%;
  background: var(--ps-danger); flex-shrink: 0; margin-top: 6px;
}

/* Two-column responsive grid */
.ai-disc-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 28px;
  margin-bottom: 32px;
}
@media (max-width: 768px) {
  .ai-disc-grid-2 { grid-template-columns: 1fr; }
  .ai-disc-banner { flex-direction: column; align-items: flex-start; }
  .ai-disc-score-pill { align-self: stretch; justify-content: center; }
}

/* ── Tabs ───────────────────────────────────────────────── */
.tabs {
  display: flex;
  gap: 2px;
  border-bottom: 2px solid var(--ps-border);
  margin-bottom: 20px;
}
.tab {
  padding: 9px 18px;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--ps-text-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: all var(--ps-transition);
  background: none;
  border-top: none;
  border-left: none;
  border-right: none;
}
.tab:hover { color: var(--ps-text); }
.tab.active { color: var(--ps-primary); border-bottom-color: var(--ps-primary); }

/* ── Conversation view ──────────────────────────────────── */
/* ── Conversations full-height layout ───────────────────────── */
/* Make the conversations section fill the content area height */
#section-conversations.active {
  height: calc(100vh - var(--ps-topbar-height) - 68px);
  display: flex;
  flex-direction: column;
}
.conversation-layout {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 320px 1fr;
  background: var(--ps-surface);
  border: 1px solid var(--ps-border);
  border-radius: var(--ps-radius-lg);
  overflow: hidden;
  box-shadow: var(--ps-shadow-sm);
}


/* Message thread (right panel) */
.message-thread {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
}

/* Thread header — canonical, single definition */
.message-thread-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--ps-border);
  background: var(--ps-surface);
  flex-shrink: 0;
  min-height: 66px;
}

/* Message list area */
.message-list {
  flex: 1;
  overflow-y: auto;
  padding: 24px 20px 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

/* Message bubbles */
.message-bubble {
  max-width: 68%;
  padding: 10px 14px 6px;
  border-radius: var(--ps-radius-lg);
  font-size: 0.875rem;
  line-height: 1.55;
  position: relative;
}
.message-bubble.inbound {
  background: var(--ps-surface-2);
  border: 1px solid var(--ps-border);
  border-radius: 4px var(--ps-radius-lg) var(--ps-radius-lg) var(--ps-radius-lg);
  align-self: flex-start;
  color: var(--ps-text);
}
.message-bubble.outbound {
  background: var(--ps-primary);
  color: #fff;
  border-radius: var(--ps-radius-lg) 4px var(--ps-radius-lg) var(--ps-radius-lg);
  align-self: flex-end;
}
.message-time {
  font-size: 0.64rem;
  margin-top: 4px;
  display: block;
  text-align: right;
}
.message-bubble.inbound  .message-time { color: var(--ps-text-light); }
.message-bubble.outbound .message-time { color: rgba(255,255,255,0.65); }

/* Consecutive bubbles spacing */
.bubble-wrap + .bubble-wrap { margin-top: 2px; }
.bubble-wrap-out + .bubble-wrap-in,
.bubble-wrap-in  + .bubble-wrap-out { margin-top: 14px; }

/* Legacy message-input-row (kept for messages section compatibility) */
.message-input-row { padding: 14px 20px; border-top: 1px solid var(--ps-border); display: flex; gap: 10px; }
.message-input-row .form-control { flex: 1; }

/* ── HTML preview pane (Create Campaign) ─────────────────── */
.field-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0;
}
.field-label-row label { margin-bottom: 0; }
.btn-preview-toggle {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--ps-primary);
  background: rgba(57,73,171,0.07);
  border: 1px solid rgba(57,73,171,0.2);
  border-radius: var(--ps-radius);
  cursor: pointer;
  transition: all var(--ps-transition);
  font-family: var(--ps-font);
  white-space: nowrap;
}
.btn-preview-toggle:hover { background: rgba(57,73,171,0.14); }
#html-preview-pane {
  border: 1px solid var(--ps-border);
  border-radius: var(--ps-radius);
  margin-top: 8px;
  overflow: hidden;
  background: #fff;
}
.preview-pane-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 12px;
  background: var(--ps-surface-2);
  border-bottom: 1px solid var(--ps-border);
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--ps-text-muted);
}
.preview-pane-close {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 0.78rem;
  color: var(--ps-text-muted);
  padding: 2px 6px;
  border-radius: var(--ps-radius);
  font-family: var(--ps-font);
  transition: background var(--ps-transition);
}
.preview-pane-close:hover { background: var(--ps-border); color: var(--ps-text); }
#html-preview-iframe,
#tpl-html-preview-iframe {
  width: 100%;
  height: 600px;
  border: none;
  display: block;
  background: #fff;
}

/* ── Campaign row delete button ──────────────────────────── */
.btn-delete-row {
  color: var(--ps-danger);
  opacity: 0.6;
  transition: opacity var(--ps-transition), background var(--ps-transition);
}
.btn-delete-row:hover { opacity: 1; background: rgba(198,40,40,0.08); }
.td-actions { display: flex; align-items: center; gap: 4px; }

/* ── Template editor ────────────────────────────────────── */
.template-preview {
  border: 1px solid var(--ps-border);
  border-radius: var(--ps-radius);
  min-height: 200px;
  padding: 16px;
  background: #fff;
  font-size: 0.875rem;
  color: #1a1f36;
}
.template-vars {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}
.var-chip {
  background: #e8eaf6;
  color: var(--ps-primary);
  padding: 3px 8px;
  border-radius: var(--ps-radius-full);
  font-size: 0.75rem;
  font-family: var(--ps-font-mono);
  cursor: pointer;
  border: 1px solid rgba(57,73,171,0.2);
  transition: background var(--ps-transition);
}
.var-chip:hover { background: #c5cae9; }

/* ── Loading spinners ───────────────────────────────────── */
.spinner {
  width: 20px; height: 20px;
  border: 2px solid var(--ps-border);
  border-top-color: var(--ps-primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  display: inline-block;
}
.spinner-lg { width: 40px; height: 40px; border-width: 3px; }
@keyframes spin { to { transform: rotate(360deg); } }

.loading-center {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 60px;
  color: var(--ps-text-muted);
  gap: 12px;
  flex-direction: column;
}

/* ── Pagination ─────────────────────────────────────────── */
.pagination {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 16px 20px;
  border-top: 1px solid var(--ps-border);
  justify-content: center;
}
.page-info { font-size: 0.82rem; color: var(--ps-text-muted); }

/* ── Segment rules builder ──────────────────────────────── */
#rules-container {
  border: 1px solid var(--ps-border);
  border-radius: var(--ps-radius);
  padding: 10px 12px;
  background: var(--ps-surface-2);
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 48px;
}
#rules-container:empty::before {
  content: 'No rules yet — click "+ Add Rule" below';
  font-size: 0.82rem;
  color: var(--ps-text-muted);
  padding: 4px 0;
}
.rule-row {
  display: grid;
  grid-template-columns: 1.6fr 1fr 1.8fr 32px;
  gap: 8px;
  align-items: center;
  background: var(--ps-surface);
  border: 1px solid var(--ps-border);
  border-radius: var(--ps-radius);
  padding: 8px 10px;
}
.rule-row .form-control {
  font-size: 0.85rem;
  height: 34px;
  padding: 4px 8px;
}
.rule-add-btn {
  margin-top: 10px !important;
  font-size: 0.83rem;
  border-style: dashed !important;
}
.rule-remove {
  width: 28px; height: 28px;
  border: 1px solid var(--ps-border);
  border-radius: var(--ps-radius);
  background: transparent;
  color: var(--ps-danger);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 17px;
  line-height: 1;
  transition: background var(--ps-transition), color var(--ps-transition);
  flex-shrink: 0;
}
.rule-remove:hover { background: var(--ps-danger-bg); border-color: var(--ps-danger); }
.form-label-bold { font-weight: 600; }

/* ── Hamburger button ───────────────────────────────────── */
#hamburger-btn {
  display: none;
  width: 36px; height: 36px;
  border-radius: var(--ps-radius);
  border: 1px solid var(--ps-border);
  background: var(--ps-surface-2);
  cursor: pointer;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 5px;
  padding: 9px 8px;
  transition: background var(--ps-transition);
  flex-shrink: 0;
}
#hamburger-btn:hover { background: var(--ps-border); }
#hamburger-btn span {
  display: block;
  height: 2px;
  background: var(--ps-text);
  border-radius: 2px;
  width: 100%;
  transition: transform 0.25s ease, opacity 0.2s ease, width 0.2s ease;
  transform-origin: center;
}
#hamburger-btn.is-open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
#hamburger-btn.is-open span:nth-child(2) { opacity: 0; transform: scaleX(0); }
#hamburger-btn.is-open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* ── Sidebar overlay (mobile) ───────────────────────────── */
#sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  z-index: 199;
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  cursor: pointer;
}
#sidebar-overlay.active { display: block; }

/* ── Logout confirmation modal ──────────────────────────── */
.logout-confirm-body {
  text-align: center;
  padding: 8px 0 8px;
}
.logout-icon-wrap {
  width: 60px; height: 60px;
  border-radius: 50%;
  background: var(--ps-danger-bg);
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 18px;
}
.logout-confirm-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--ps-text);
  margin-bottom: 8px;
}
.logout-confirm-sub {
  font-size: 0.86rem;
  color: var(--ps-text-muted);
  margin-bottom: 28px;
  line-height: 1.55;
}
.logout-confirm-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
}
.logout-confirm-actions .btn { min-width: 110px; }
.btn-danger { background: var(--ps-danger); color: #fff; border: 1px solid var(--ps-danger); }
.btn-danger:hover { background: #b71c1c; border-color: #b71c1c; }

/* ── Responsive ─────────────────────────────────────────── */

/* ── Desktop: define the 2-column grid ─────────────── */
#app-shell {
  grid-template-columns: var(--ps-sidebar-width) 1fr;
}

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

/* ── Tablet / Mobile ────────────────────────────────── */
@media (max-width: 768px) {
  /* Full-width single column — sidebar becomes overlay */
  #app-shell { grid-template-columns: 1fr; }

  /* Sidebar: slide-in overlay from left */
  #sidebar {
    position: fixed;
    top: 0; bottom: 0; left: 0;
    width: 270px;
    transform: translateX(-100%);
    transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 200;
    overflow-y: auto;
    overflow-x: hidden;
    min-height: 0;
  }
  #sidebar.sidebar-open {
    transform: translateX(0);
    box-shadow: 8px 0 32px rgba(0, 0, 0, 0.4);
  }

  /* Hamburger visible on mobile only */
  #hamburger-btn { display: flex; }

  /* Topbar: compact, prevent overflow */
  #topbar { padding: 0 14px; gap: 8px; }
  .topbar-left { flex: 1; min-width: 0; gap: 10px; }
  #page-title {
    flex: 1;
    min-width: 0;
    font-size: 0.95rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .topbar-right { gap: 8px; flex-shrink: 0; }

  /* Content area: comfortable mobile padding */
  #content-area { padding: 16px 14px 40px; }

  /* Tables scroll horizontally */
  .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  table { min-width: 540px; }

  /* Stats: 2 columns on mobile */
  .stats-grid { grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 20px; }
  .stat-card { padding: 14px 16px; gap: 5px; }
  .stat-value { font-size: 1.85rem; letter-spacing: -0.5px; }
  .stat-label { font-size: 0.66rem; }
  .stat-icon  { width: 30px; height: 30px; border-radius: 8px; margin-bottom: 4px; }

  /* Quick actions: 2 columns */
  .quick-actions { grid-template-columns: 1fr 1fr; gap: 10px; }
  .quick-action-card { padding: 16px 14px; gap: 6px; }
  .qa-icon { width: 36px; height: 36px; margin-bottom: 2px; }
  .qa-label { font-size: 0.82rem; }
  .qa-sub { font-size: 0.7rem; }

  /* Form grids collapse to single column */
  .form-grid-2 { grid-template-columns: 1fr; }
  .form-grid-3 { grid-template-columns: 1fr; }

  /* Section headers: stack vertically */
  .section-header { flex-direction: column; align-items: flex-start; gap: 10px; }
  .section-header-actions { width: 100%; flex-wrap: wrap; }
  .section-header h2 { font-size: 1.1rem; }

  /* Panels tighter */
  .panel-header { padding: 12px 14px; }
  .panel-body { padding: 14px; }

  /* Conversation: single pane on mobile */
  #section-conversations.active { height: calc(100vh - var(--ps-topbar-height) - 44px); }
  .conversation-layout { grid-template-columns: 1fr; }
  .convo-list-panel { display: none; }

  /* Toolbar wraps */
  .toolbar { flex-wrap: wrap; gap: 8px; }
  .search-input { width: 100%; }

  /* Modal fills screen on mobile */
  .modal-box { max-width: calc(100vw - 24px); margin: 12px; }

  /* Prevent iOS auto-zoom on inputs */
  input, select, textarea { font-size: 16px; }

  /* Smaller quick-actions title */
  .quick-actions-title { font-size: 0.8rem; margin-bottom: 10px; }
  .quick-actions-row { margin-bottom: 20px; }
}

/* ── Small phones ────────────────────────────────────── */
@media (max-width: 480px) {
  /* Stats: single column on tiny screens */
  .stats-grid { grid-template-columns: 1fr; }
  .stat-value { font-size: 1.8rem; }

  /* Quick actions: single column */
  .quick-actions { grid-template-columns: 1fr; }

  /* Topbar: icon-only logout, compact theme switcher */
  #logout-btn span { display: none; }
  #logout-btn { padding: 7px 10px; }
  .theme-sw-btn { padding: 4px 7px; font-size: 0.7rem; gap: 4px; }
  .topbar-right { gap: 6px; }

  /* Template grid: single column */
  .template-grid { grid-template-columns: 1fr; }

  /* Content: tighter horizontal padding */
  #content-area { padding: 12px 10px 32px; }
}

/* ── Stat card icons ─────────────────────────────────────── */
.stat-icon {
  width: 36px; height: 36px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  background: var(--ps-bg);
  color: var(--ps-text-light);
  margin-bottom: 6px;
  flex-shrink: 0;
}
.stat-card.primary .stat-icon { background: rgba(57,73,171,0.12); color: var(--ps-primary-light); }
.stat-card.success .stat-icon { background: var(--ps-success-bg);  color: var(--ps-success); }
.stat-card.danger  .stat-icon { background: var(--ps-danger-bg);   color: var(--ps-danger); }
.stat-card.info    .stat-icon { background: var(--ps-info-bg);     color: var(--ps-info); }
.stat-card.gold    .stat-icon { background: rgba(200,168,75,0.12); color: var(--ps-gold-dark); }

/* ── Quick actions row ───────────────────────────────────── */
.quick-actions-row {
  margin-bottom: 28px;
}
.quick-actions-title {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--ps-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 14px;
}
.quick-actions {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
}
.quick-action-card {
  background: var(--ps-surface);
  border: 1px solid var(--ps-border);
  border-radius: var(--ps-radius-lg);
  padding: 20px 16px;
  cursor: pointer;
  text-align: left;
  transition: box-shadow var(--ps-transition), border-color var(--ps-transition), transform var(--ps-transition);
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-family: var(--ps-font);
  box-shadow: var(--ps-shadow-sm);
}
.quick-action-card:hover {
  box-shadow: var(--ps-shadow);
  border-color: var(--ps-border-hover);
  transform: translateY(-2px);
}
.qa-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--ps-radius);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 4px;
}
.qa-icon-primary { background: #e8eaf6; color: var(--ps-primary); }
.qa-icon-success { background: var(--ps-success-bg); color: var(--ps-success); }
.qa-icon-gold    { background: #fdf6e3; color: var(--ps-gold-dark); }
.qa-icon-info    { background: var(--ps-info-bg); color: var(--ps-info); }
[data-theme="dark"] .qa-icon-primary { background: rgba(57,73,171,0.2); }
[data-theme="dark"] .qa-icon-gold    { background: rgba(200,168,75,0.15); }
.qa-label {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--ps-text);
}
.qa-sub {
  font-size: 0.75rem;
  color: var(--ps-text-muted);
}

@media (max-width: 900px) {
  .quick-actions { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 480px) {
  .quick-actions { grid-template-columns: 1fr; }
}

/* ── Rate values (open/click rates) ─────────────────────── */
.rate-val { font-weight: 600; font-size: 0.82rem; }
.rate-high { color: var(--ps-success); }
.rate-mid  { color: var(--ps-warning); }
.rate-low  { color: var(--ps-text-muted); }

/* ── Contact avatar cell ─────────────────────────────────── */
.contact-name-cell {
  display: flex;
  align-items: center;
  gap: 10px;
}
.contact-avatar {
  width: 32px;
  height: 32px;
  border-radius: var(--ps-radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.72rem;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}
.contact-name {
  font-weight: 600;
  font-size: 0.875rem;
  white-space: nowrap;
}

/* ── Filter tabs ─────────────────────────────────────────── */
.filter-tabs {
  display: flex;
  gap: 2px;
  background: var(--ps-surface-2);
  border: 1px solid var(--ps-border);
  border-radius: var(--ps-radius);
  padding: 3px;
}
.filter-tab {
  padding: 5px 14px;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--ps-text-muted);
  background: none;
  border: none;
  border-radius: calc(var(--ps-radius) - 2px);
  cursor: pointer;
  transition: all var(--ps-transition);
  font-family: var(--ps-font);
  white-space: nowrap;
}
.filter-tab:hover { color: var(--ps-text); background: var(--ps-border); }
.filter-tab.active {
  background: var(--ps-surface);
  color: var(--ps-primary);
  box-shadow: var(--ps-shadow-xs);
}
.tab-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 17px;
  height: 15px;
  padding: 0 4px;
  border-radius: 8px;
  font-size: 0.67rem;
  font-weight: 700;
  margin-left: 4px;
  vertical-align: 1px;
  background: var(--ps-text-muted);
  color: #fff;
  opacity: 0.75;
}
.filter-tab.active .tab-count {
  background: var(--ps-primary);
  opacity: 1;
}

/* ── Template card grid ──────────────────────────────────── */
.template-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 18px;
  padding: 4px;
}
.template-card {
  background: var(--ps-surface);
  border: 1px solid var(--ps-border);
  border-radius: var(--ps-radius-lg);
  box-shadow: var(--ps-shadow-sm);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: box-shadow var(--ps-transition), border-color var(--ps-transition);
}
.template-card:hover {
  box-shadow: var(--ps-shadow);
  border-color: var(--ps-border-hover);
}
.template-card-top {
  padding: 18px;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 8px;
  border-bottom: 1px solid var(--ps-border);
}
.template-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}
.template-name {
  font-weight: 700;
  font-size: 0.92rem;
  color: var(--ps-text);
  flex: 1;
}
.template-subject {
  font-size: 0.82rem;
  color: var(--ps-text-muted);
  font-style: italic;
}
.template-preview-text {
  font-size: 0.78rem;
  color: var(--ps-text-light);
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.template-card-footer {
  padding: 12px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  background: var(--ps-surface-2);
}
.template-updated {
  font-size: 0.72rem;
  color: var(--ps-text-light);
}
.template-card-actions { display: flex; gap: 6px; }

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

/* ── Segment rule chips ──────────────────────────────────── */
.rule-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  align-items: center;
}
.rule-chip {
  background: #e8eaf6;
  color: var(--ps-primary);
  padding: 2px 8px;
  border-radius: var(--ps-radius-full);
  font-size: 0.72rem;
  font-weight: 600;
  border: 1px solid rgba(57,73,171,0.15);
}
.rule-chip-more {
  background: var(--ps-surface-2);
  color: var(--ps-text-muted);
  border-color: var(--ps-border);
}
[data-theme="dark"] .rule-chip { background: rgba(57,73,171,0.2); border-color: rgba(57,73,171,0.3); }

/* ── Suppression summary bar ─────────────────────────────── */
.suppression-summary {
  padding: 14px 20px;
  border-bottom: 1px solid var(--ps-border);
  background: var(--ps-surface-2);
}
.suppression-count-row {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}
.suppression-total {
  font-size: 0.875rem;
  color: var(--ps-text);
}
.suppression-breakdown {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}
.suppression-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 0.78rem;
}

/* ── Integration card updates ────────────────────────────── */
.integration-card {
  transition: box-shadow var(--ps-transition), border-color var(--ps-transition);
}
.integration-card:hover {
  box-shadow: var(--ps-shadow);
  border-color: var(--ps-border-hover);
}
.integration-icon {
  color: var(--ps-text-muted);
  opacity: 0.7;
}

/* ── Account info grid (settings page) ──────────────────── */
.account-info-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 20px;
}
.account-info-item { display: flex; flex-direction: column; gap: 5px; }
.account-info-label {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ps-text-muted);
}
.account-info-value {
  font-size: 0.88rem;
  color: var(--ps-text);
  font-weight: 500;
}

/* ── Conversation layout ─────────────────────────────────── */
.convo-list-panel {
  border-right: 1px solid var(--ps-border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--ps-surface-2);
}
.convo-list-header {
  padding: 12px 12px 0;
  border-bottom: 1px solid var(--ps-border);
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: var(--ps-surface-2);
}
/* Search + compose-button row */
.convo-search-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.convo-search-row .search-wrap { height: 34px; }
/* The channel filter tabs sit inside the existing .filter-tabs/.filter-tab system */
#convo-channel-tabs {
  margin-bottom: 0;
  border-radius: var(--ps-radius) var(--ps-radius) 0 0;
}
.convo-list { flex: 1; overflow-y: auto; background: var(--ps-surface-2); }

/* Conversation list items */
.convo-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 13px 14px;
  border-bottom: 1px solid var(--ps-border);
  cursor: pointer;
  transition: background var(--ps-transition);
  background: var(--ps-surface);
}
.convo-item:hover { background: var(--ps-surface-2); }
.convo-item.active {
  background: rgba(57,73,171,0.08);
  border-left: 3px solid var(--ps-primary);
  padding-left: 11px;
}
[data-theme="dark"] .convo-item.active { background: rgba(57,73,171,0.2); }
.convo-item.unread .convo-name { font-weight: 700; }
.convo-item.unread .convo-preview { color: var(--ps-text); font-weight: 500; }

.convo-avatar {
  width: 38px;
  height: 38px;
  border-radius: var(--ps-radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.72rem;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}
.convo-info { flex: 1; min-width: 0; }
.convo-meta {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 6px;
  margin-bottom: 3px;
}
.convo-name {
  font-weight: 600;
  font-size: 0.875rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  color: var(--ps-text);
}
.convo-time { font-size: 0.67rem; color: var(--ps-text-light); flex-shrink: 0; white-space: nowrap; }
.convo-preview-row {
  display: flex;
  align-items: center;
  gap: 5px;
  overflow: hidden;
}
.convo-channel-icon {
  flex-shrink: 0;
  opacity: 0.5;
  display: flex;
  align-items: center;
}
.convo-preview {
  font-size: 0.78rem;
  color: var(--ps-text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}
.convo-unread {
  background: var(--ps-primary);
  color: #fff;
  border-radius: var(--ps-radius-full);
  font-size: 0.65rem;
  font-weight: 700;
  padding: 1px 6px;
  flex-shrink: 0;
}
.convo-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px 16px;
  gap: 10px;
  color: var(--ps-text-muted);
  font-size: 0.84rem;
  text-align: center;
}

/* Thread placeholder (right panel, nothing selected) */
.thread-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  gap: 10px;
  color: var(--ps-text-muted);
  text-align: center;
  padding: 40px;
}
.thread-placeholder-icon {
  width: 68px;
  height: 68px;
  border-radius: var(--ps-radius-full);
  background: var(--ps-surface-2);
  border: 1px solid var(--ps-border);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--ps-text-muted);
  margin-bottom: 6px;
}
.thread-placeholder strong {
  font-size: 1rem;
  font-weight: 700;
  color: var(--ps-text);
  display: block;
}
.thread-placeholder span {
  font-size: 0.84rem;
  color: var(--ps-text-muted);
  max-width: 260px;
  line-height: 1.5;
  display: block;
}
.thread-contact-avatar {
  width: 40px;
  height: 40px;
  border-radius: var(--ps-radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}
.thread-contact-info { flex: 1; min-width: 0; }
.thread-contact-name {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--ps-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.thread-meta { display: flex; gap: 6px; align-items: center; margin-top: 4px; }
.thread-header-actions { display: flex; gap: 4px; flex-shrink: 0; }

/* Message bubbles */
.bubble-wrap { display: flex; flex-direction: column; }
.bubble-wrap-out { align-items: flex-end; }
.bubble-wrap-in  { align-items: flex-start; }
.bubble-body { word-break: break-word; line-height: 1.5; }

/* Empty message list */
.thread-empty-msgs {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  gap: 10px;
  color: var(--ps-text-muted);
  font-size: 0.84rem;
  text-align: center;
  padding: 40px;
}

/* Reply box */
.reply-box {
  padding: 12px 16px;
  border-top: 1px solid var(--ps-border);
  display: flex;
  gap: 8px;
  align-items: flex-end;
  flex-shrink: 0;
  background: var(--ps-surface);
}
.reply-textarea {
  flex: 1;
  resize: none;
  min-height: 42px;
  max-height: 120px;
  line-height: 1.5;
  padding: 10px 13px;
  font-size: 0.875rem;
}
.reply-send-btn {
  width: 42px;
  height: 42px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

/* ── Form group label/input spacing (ensure consistent) ──── */
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-group label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--ps-text);
  display: flex;
  align-items: center;
  gap: 4px;
}
.form-group .form-hint {
  font-size: 0.72rem;
  color: var(--ps-text-light);
  font-weight: 400;
}

/* ══ Pipelines — Kanban Board ═══════════════════════════════════════════════ */
.pipeline-selector-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
}
.pipeline-selector-select {
  background: var(--ps-surface);
  border: 1px solid var(--ps-border);
  border-radius: var(--ps-radius);
  padding: 6px 12px;
  font-size: .9rem;
  font-weight: 600;
  color: var(--ps-text);
  cursor: pointer;
  min-width: 180px;
}

.kanban-board {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  padding: 4px 0 24px;
  align-items: flex-start;
  min-height: calc(100vh - 180px);
  -webkit-overflow-scrolling: touch;
  scroll-snap-type: x mandatory;
}
.kanban-col {
  flex: 0 0 256px;
  min-width: 256px;
  background: var(--ps-surface);
  border: 1px solid var(--ps-border);
  border-radius: var(--ps-radius-lg);
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 200px);
  scroll-snap-align: start;
}
.kanban-col-hdr {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 11px 13px;
  border-bottom: 1px solid var(--ps-border);
  flex-shrink: 0;
}
.kanban-col-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex-shrink: 0;
}
.kanban-col-name {
  font-weight: 600;
  font-size: .84rem;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.kanban-col-count {
  font-size: .73rem;
  font-weight: 600;
  background: var(--ps-surface-2);
  border-radius: var(--ps-radius-full);
  padding: 1px 7px;
  color: var(--ps-text-muted);
  flex-shrink: 0;
}
.kanban-col-val {
  font-size: .7rem;
  color: var(--ps-text-light);
  flex-shrink: 0;
}
.kanban-cards {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
  min-height: 160px;
  display: flex;
  flex-direction: column;
  gap: 7px;
  min-height: 60px;
  transition: background .12s;
}
.kanban-cards.drag-over {
  background: color-mix(in srgb, var(--ps-primary-light) 8%, transparent);
  outline: 2px dashed var(--ps-primary-light);
  outline-offset: -4px;
  border-radius: var(--ps-radius);
}
.kanban-drop-hint {
  display: none;
  text-align: center;
  padding: 12px;
  font-size: .76rem;
  color: var(--ps-text-light);
  pointer-events: none;
}
.kanban-cards.drag-over .kanban-drop-hint { display: block; }

.kanban-card {
  background: var(--ps-surface-2);
  border: 1px solid var(--ps-border);
  border-radius: var(--ps-radius);
  padding: 10px 11px;
  cursor: pointer;
  transition: box-shadow .14s, transform .1s, opacity .14s;
  user-select: none;
}
.kanban-card:hover {
  box-shadow: var(--ps-shadow);
  transform: translateY(-1px);
}
.kanban-card.dragging {
  opacity: .45;
  transform: rotate(1.5deg) scale(.96);
  box-shadow: var(--ps-shadow-lg);
}
.kanban-card.deal-won  { border-left: 3px solid var(--ps-success); opacity: .72; }
.kanban-card.deal-lost { border-left: 3px solid var(--ps-danger);  opacity: .6;  }

.deal-title {
  font-weight: 600;
  font-size: .84rem;
  line-height: 1.35;
  margin-bottom: 4px;
}
.deal-val {
  font-size: .79rem;
  color: var(--ps-primary-light);
  font-weight: 700;
  margin-bottom: 4px;
}
.deal-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.deal-cd {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: .71rem;
  color: var(--ps-text-muted);
}

.kanban-add-deal {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  width: 100%;
  padding: 7px 12px;
  background: none;
  border: none;
  border-top: 1px solid var(--ps-border);
  color: var(--ps-text-muted);
  font-size: .79rem;
  cursor: pointer;
  transition: color .13s, background .13s;
  flex-shrink: 0;
}
.kanban-add-deal:hover {
  color: var(--ps-primary-light);
  background: var(--ps-surface-2);
}

.kanban-add-stage {
  flex: 0 0 180px;
  display: flex;
  align-items: flex-start;
  padding-top: 4px;
}
.kanban-add-stage-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 16px;
  background: none;
  border: 2px dashed var(--ps-border);
  border-radius: var(--ps-radius-lg);
  color: var(--ps-text-muted);
  font-size: .84rem;
  cursor: pointer;
  transition: border-color .13s, color .13s;
  white-space: nowrap;
}
.kanban-add-stage-btn:hover {
  border-color: var(--ps-primary-light);
  color: var(--ps-primary-light);
}

/* Deal detail modal */
.deal-detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}
@media (max-width: 640px) {
  .deal-detail-grid { grid-template-columns: 1fr; }
}
.deal-detail-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 8px 0;
  border-bottom: 1px solid var(--ps-border);
  font-size: .86rem;
  gap: 12px;
}
.deal-detail-lbl { color: var(--ps-text-muted); flex-shrink: 0; }

.deal-activity-title {
  font-weight: 600;
  font-size: .84rem;
  margin-bottom: 10px;
}
.deal-activity-list {
  display: flex;
  flex-direction: column;
  gap: 7px;
  max-height: 150px;
  overflow-y: auto;
  margin-bottom: 10px;
}
.deal-activity-item {
  background: var(--ps-surface-2);
  border-radius: var(--ps-radius);
  padding: 8px 10px;
  font-size: .81rem;
}
.deal-activity-type  { font-weight: 600; }
.deal-activity-note  { color: var(--ps-text-muted); margin-top: 2px; }
.deal-activity-date  { color: var(--ps-text-light); font-size: .73rem; margin-top: 2px; }
.deal-add-activity   { padding-top: 8px; border-top: 1px solid var(--ps-border); }

/* Pipeline report modal */
.report-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: 10px;
  margin-bottom: 4px;
}
.report-stat {
  background: var(--ps-surface-2);
  border-radius: var(--ps-radius);
  padding: 13px 12px;
  text-align: center;
}
.report-stat-val {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--ps-text);
  line-height: 1;
}
.report-stat-lbl {
  font-size: .72rem;
  color: var(--ps-text-muted);
  margin-top: 5px;
}

/* Stage rows in create-pipeline modal */
.stage-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.stage-row {
  display: flex;
  align-items: center;
  gap: 7px;
}
.stage-color-input {
  width: 40px !important;
  height: 36px !important;
  padding: 2px 4px !important;
  cursor: pointer;
  flex-shrink: 0;
  border-radius: var(--ps-radius-sm) !important;
}

/* ══ Send Plans ══════════════════════════════════════════════════════════════ */
.sp-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 14px;
  padding: 16px;
}
.sp-card {
  background: var(--ps-surface);
  border: 1px solid var(--ps-border);
  border-radius: var(--ps-radius-lg);
  padding: 16px;
  cursor: pointer;
  transition: box-shadow .14s, transform .1s;
  display: flex;
  flex-direction: column;
  gap: 0;
}
.sp-card:hover {
  box-shadow: var(--ps-shadow);
  transform: translateY(-1px);
}
.sp-card-hdr {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 12px;
  gap: 8px;
}
.sp-card-name {
  font-weight: 700;
  font-size: .92rem;
  line-height: 1.3;
}
.sp-prog-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}
.sp-prog-bar {
  flex: 1;
  height: 5px;
  background: var(--ps-surface-2);
  border-radius: var(--ps-radius-full);
  overflow: hidden;
}
.sp-prog-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--ps-primary-light) 0%, var(--ps-gold) 100%);
  border-radius: var(--ps-radius-full);
  transition: width .4s ease;
  min-width: 4px;
}
.sp-prog-pct {
  font-size: .76rem;
  font-weight: 700;
  color: var(--ps-text-muted);
  min-width: 34px;
  text-align: right;
}
.sp-card-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  font-size: .79rem;
  color: var(--ps-text-muted);
  margin-bottom: 12px;
}
.sp-card-footer {
  display: flex;
  gap: 8px;
  align-items: center;
  padding-top: 10px;
  border-top: 1px solid var(--ps-border);
  margin-top: auto;
}

/* ══ Contact Profile — 360° view ════════════════════════════════════════════ */
.profile-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
@media (max-width: 768px) {
  .profile-grid { grid-template-columns: 1fr; }
}
.profile-col {
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.profile-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 9px 0;
  border-bottom: 1px solid var(--ps-border);
  font-size: .85rem;
}
.profile-row:last-child { border-bottom: none; }
.profile-lbl {
  font-size: .76rem;
  font-weight: 600;
  color: var(--ps-text-muted);
  min-width: 110px;
  flex-shrink: 0;
  padding-top: 1px;
}
.profile-val {
  color: var(--ps-text);
  word-break: break-word;
}
.profile-header {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 20px;
}
.profile-avatar-lg {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1.1rem;
  color: #fff;
  flex-shrink: 0;
}
.ai-score-ring {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 54px;
  height: 54px;
  border-radius: 50%;
  border: 3px solid var(--ps-primary);
  font-weight: 800;
  font-size: 1rem;
  color: var(--ps-primary);
  flex-shrink: 0;
}
.intent-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: .74rem;
  font-weight: 600;
  background: var(--ps-primary-light, #eef0fd);
  color: var(--ps-primary);
}

/* ══ Workflow Builder UI ════════════════════════════════════════════════════ */
.workflow-builder-intro {
  text-align: center;
  padding: 40px 20px;
  color: var(--ps-text-muted);
}
.workflow-builder-intro svg {
  margin-bottom: 14px;
  color: var(--ps-primary);
}
.wf-quick-trigger {
  display: flex;
  gap: 10px;
  align-items: flex-end;
  flex-wrap: wrap;
  margin-bottom: 20px;
  padding: 16px;
  background: var(--ps-surface-2);
  border-radius: var(--ps-radius);
}
.wf-quick-trigger .form-group { margin-bottom: 0; min-width: 160px; }

/* Send plan detail stats */
.sp-detail-stats {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(95px, 1fr));
  gap: 9px;
  margin-bottom: 4px;
}
.sp-stat {
  background: var(--ps-surface-2);
  border-radius: var(--ps-radius);
  padding: 10px 11px;
  text-align: center;
}
.sp-stat-val {
  font-size: 1.1rem;
  font-weight: 700;
  line-height: 1.1;
}
.sp-stat-lbl {
  font-size: .7rem;
  color: var(--ps-text-muted);
  margin-top: 3px;
}

/* ══ Contact Profile — 360° View ════════════════════════════════════════════ */
.cp-header-bar {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 20px;
  background: var(--ps-surface);
  border: 1px solid var(--ps-border);
  border-radius: var(--ps-radius);
  margin-bottom: 0;
  flex-wrap: wrap;
}
.cp-header-info {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
  min-width: 0;
}
.cp-name {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cp-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  font-size: .78rem;
  color: var(--ps-text-muted);
  margin-top: 2px;
}
.cp-meta span + span::before {
  content: '·';
  margin-right: 8px;
}
.cp-header-badges {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}
.cp-score-chip {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 6px 12px;
  border-radius: var(--ps-radius);
  min-width: 52px;
  line-height: 1.15;
}
.cp-header-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

/* Tabs */
.cp-tabs {
  display: flex;
  gap: 0;
  border-bottom: 2px solid var(--ps-border);
  margin: 16px 0 0;
  overflow-x: auto;
}
.cp-tab-btn {
  padding: 9px 18px;
  font-size: .84rem;
  font-weight: 600;
  color: var(--ps-text-muted);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  cursor: pointer;
  white-space: nowrap;
  transition: color .15s, border-color .15s;
}
.cp-tab-btn:hover { color: var(--ps-text); }
.cp-tab-btn.active {
  color: var(--ps-primary);
  border-bottom-color: var(--ps-primary);
}
#cp-tab-content {
  margin-top: 16px;
}

/* Overview grid */
.cp-overview-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
@media (max-width: 760px) {
  .cp-overview-grid { grid-template-columns: 1fr; }
  .cp-header-bar { flex-direction: column; align-items: flex-start; }
}

/* AI stats row */
.cp-ai-stats {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}
.cp-ai-stat { flex: 1; min-width: 80px; text-align: center; }
.cp-ai-stat-val { font-size: 1.6rem; font-weight: 800; line-height: 1.1; }
.cp-ai-stat-lbl { font-size: .7rem; color: var(--ps-text-muted); margin-top: 3px; }

/* Timeline */
.cp-timeline {
  padding: 8px 20px;
}
.cp-timeline-item {
  display: flex;
  gap: 14px;
  padding: 12px 0;
  border-bottom: 1px solid var(--ps-border);
  position: relative;
}
.cp-timeline-item:last-child { border-bottom: none; }
.cp-timeline-dot {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 1px;
}
.cp-timeline-content { flex: 1; min-width: 0; }
.cp-timeline-title {
  font-size: .87rem;
  font-weight: 600;
  color: var(--ps-text);
  line-height: 1.3;
}
.cp-timeline-detail {
  font-size: .8rem;
  color: var(--ps-text-muted);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cp-timeline-time {
  font-size: .73rem;
  color: var(--ps-text-light, var(--ps-text-muted));
  margin-top: 4px;
}

/* ══ Workflow Section ══════════════════════════════════════════════════════ */
.workflow-builder-intro { text-align: left; padding: 0; }

/* ══ Analytics & Reports ════════════════════════════════════════════════════ */
.analytics-kpi-row {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 14px;
  margin-bottom: 16px;
}
.analytics-kpi-card {
  background: var(--ps-surface);
  border: 1px solid var(--ps-border);
  border-radius: var(--ps-radius);
  padding: 18px 16px 14px;
}
.analytics-kpi-val {
  font-size: 1.7rem;
  font-weight: 800;
  color: var(--ps-primary);
  line-height: 1.1;
}
.analytics-kpi-lbl {
  font-size: .78rem;
  font-weight: 600;
  color: var(--ps-text);
  margin-top: 4px;
}
.analytics-kpi-sub {
  font-size: .72rem;
  color: var(--ps-text-muted);
  margin-top: 2px;
}

.analytics-2col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
@media (max-width: 800px) { .analytics-2col { grid-template-columns: 1fr; } }

/* Lead score tiles */
.analytics-score-row {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 10px;
}
.analytics-score-tile {
  text-align: center;
  padding: 16px 10px;
  border-radius: var(--ps-radius);
  border: 1px solid var(--ps-border);
  background: var(--ps-surface-2, var(--ps-surface));
}
.analytics-score-val {
  font-size: 1.8rem;
  font-weight: 800;
  line-height: 1;
}
.analytics-score-lbl {
  font-size: .72rem;
  color: var(--ps-text-muted);
  margin-top: 5px;
}

/* Funnel bars */
.analytics-funnel-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}
.analytics-funnel-lbl {
  font-size: .78rem;
  text-transform: capitalize;
  width: 160px;
  flex-shrink: 0;
  color: var(--ps-text);
}
.analytics-funnel-track {
  flex: 1;
  height: 8px;
  background: var(--ps-surface-2, #f1f5f9);
  border-radius: 4px;
  overflow: hidden;
}
.analytics-funnel-fill {
  height: 100%;
  background: var(--ps-primary);
  border-radius: 4px;
  transition: width .4s ease;
  min-width: 2px;
}
.analytics-funnel-num {
  font-size: .78rem;
  font-weight: 600;
  min-width: 38px;
  text-align: right;
  color: var(--ps-text-muted);
}

/* ═══════════════════════════════════════════════════════════════
 * NOTIFICATION BELL
 * ═══════════════════════════════════════════════════════════════ */
.notif-bell-wrap { position: relative; }
.notif-bell-btn {
  position: relative;
  display: flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; border-radius: var(--ps-radius);
  background: none; border: 1px solid var(--ps-border);
  color: var(--ps-text-muted); cursor: pointer;
  transition: background .15s, color .15s;
}
.notif-bell-btn:hover { background: var(--ps-surface-2); color: var(--ps-text); }
.notif-badge {
  position: absolute; top: -4px; right: -4px;
  background: var(--ps-danger); color: #fff;
  font-size: .6rem; font-weight: 700;
  min-width: 16px; height: 16px;
  border-radius: var(--ps-radius-full);
  display: flex; align-items: center; justify-content: center;
  padding: 0 3px; border: 2px solid var(--ps-surface);
}
.notif-panel {
  position: absolute; top: calc(100% + 8px); right: 0;
  width: 360px; max-height: 480px;
  background: var(--ps-surface); border: 1px solid var(--ps-border);
  border-radius: var(--ps-radius-lg); box-shadow: var(--ps-shadow-lg);
  z-index: 9000; display: flex; flex-direction: column; overflow: hidden;
}
.notif-panel-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px; border-bottom: 1px solid var(--ps-border); flex-shrink: 0;
}
.notif-panel-title { font-weight: 700; font-size: .9rem; }
.notif-mark-all {
  background: none; border: none; cursor: pointer;
  color: var(--ps-primary-light); font-size: .78rem;
  font-family: var(--ps-font); font-weight: 500;
}
.notif-mark-all:hover { text-decoration: underline; }
.notif-panel-body { flex: 1; overflow-y: auto; }
.notif-empty { padding: 32px 16px; text-align: center; color: var(--ps-text-muted); font-size: .875rem; }
.notif-item {
  display: flex; gap: 10px; padding: 12px 16px;
  border-bottom: 1px solid var(--ps-border);
  cursor: pointer; transition: background .12s;
}
.notif-item:hover { background: var(--ps-surface-2); }
.notif-unread { background: var(--ps-primary-light, #eef0fd) !important; }
[data-theme="dark"] .notif-unread { background: rgba(79,70,229,.12) !important; }
.notif-item-icon {
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--ps-surface-2); display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; color: var(--ps-primary);
}
.notif-icon-lead_assigned { background: #e8f5e9; color: #2e7d32; }
.notif-icon-sla_breach { background: #ffebee; color: #c62828; }
.notif-icon-deal_won { background: #e8f5e9; color: #2e7d32; }
.notif-icon-approval_request { background: #fff8e1; color: #f57f17; }
.notif-icon-commission_approved { background: #e8f5e9; color: #2e7d32; }
[data-theme="dark"] .notif-icon-lead_assigned { background: #1b3a1c; }
[data-theme="dark"] .notif-icon-sla_breach { background: #3a1010; }
[data-theme="dark"] .notif-icon-deal_won { background: #1b3a1c; }
[data-theme="dark"] .notif-icon-approval_request { background: #3a2a00; }
.notif-item-body { flex: 1; min-width: 0; }
.notif-item-title { font-weight: 600; font-size: .83rem; color: var(--ps-text); }
.notif-item-text { font-size: .78rem; color: var(--ps-text-muted); margin-top: 2px; }
.notif-item-time { font-size: .72rem; color: var(--ps-text-light); margin-top: 4px; }
.notif-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ps-primary); flex-shrink: 0; align-self: center; }

/* Nav badge (approvals count) */
.nav-badge {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 18px; height: 18px; padding: 0 4px;
  background: var(--ps-danger); color: #fff;
  font-size: .65rem; font-weight: 700;
  border-radius: var(--ps-radius-full); margin-left: auto;
}

/* ═══════════════════════════════════════════════════════════════
 * APPROVALS CENTER
 * ═══════════════════════════════════════════════════════════════ */
.approval-summary-row {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 12px; margin-bottom: 20px;
}
.approval-summary-row .kpi-card { text-align: center; }
.kpi-val.kpi-warning { color: var(--ps-warning); }
.kpi-val.kpi-success { color: var(--ps-success); }
.kpi-val.kpi-danger  { color: var(--ps-danger); }
.filter-bar { display: flex; gap: 6px; flex-wrap: wrap; }
.filter-btn {
  padding: 6px 14px; border-radius: var(--ps-radius-full);
  border: 1px solid var(--ps-border); background: var(--ps-surface);
  color: var(--ps-text-muted); font-size: .82rem; font-weight: 500; cursor: pointer;
  transition: all .15s;
}
.filter-btn:hover { border-color: var(--ps-primary-light); color: var(--ps-primary); }
.filter-btn.active {
  background: var(--ps-primary); color: #fff; border-color: var(--ps-primary);
}
.btn-xs { padding: 4px 10px; font-size: .76rem; border-radius: 6px; }
.btn-success { background: var(--ps-success); color: #fff; }
.btn-success:hover { opacity: .88; }

/* ═══════════════════════════════════════════════════════════════
 * STAFF MANAGEMENT
 * ═══════════════════════════════════════════════════════════════ */
.sm-attendance-bar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px; background: var(--ps-surface);
  border: 1px solid var(--ps-border); border-radius: var(--ps-radius-lg);
  margin-bottom: 16px;
}

/* ═══════════════════════════════════════════════════════════════
 * COMMISSIONS
 * ═══════════════════════════════════════════════════════════════ */
.commission-total-bar {
  padding: 10px 14px; background: var(--ps-surface-2);
  border: 1px solid var(--ps-border); border-radius: var(--ps-radius);
  font-size: .875rem; margin-bottom: 12px;
}

/* ═══════════════════════════════════════════════════════════════
 * SLA RULES
 * ═══════════════════════════════════════════════════════════════ */
.sla-explainer {
  margin-bottom: 20px; padding: 14px 16px;
  background: var(--ps-surface); border: 1px solid var(--ps-border);
  border-radius: var(--ps-radius-lg);
}
.sla-flow { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.sla-flow-step {
  padding: 8px 14px; border-radius: var(--ps-radius-full);
  font-size: .82rem; font-weight: 600;
}
.sla-step-trigger  { background: var(--ps-primary-light, #eef0fd); color: var(--ps-primary); }
.sla-step-check    { background: var(--ps-warning-bg); color: var(--ps-warning); }
.sla-step-action   { background: var(--ps-success-bg); color: var(--ps-success); }
.sla-flow-arrow    { color: var(--ps-text-muted); font-size: 1.1rem; }

.sla-rules-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; margin-bottom: 20px; }
.sla-rule-card {
  background: var(--ps-surface); border: 1px solid var(--ps-border);
  border-radius: var(--ps-radius-lg); padding: 16px;
  transition: box-shadow .15s;
}
.sla-rule-card:hover { box-shadow: var(--ps-shadow); }
.sla-rule-inactive { opacity: .55; }
.sla-rule-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; margin-bottom: 12px; }
.sla-rule-name { font-weight: 700; font-size: .9rem; }
.sla-rule-body { display: flex; flex-direction: column; gap: 6px; }
.sla-rule-threshold { display: flex; align-items: center; gap: 6px; font-size: .875rem; color: var(--ps-text-muted); }
.sla-rule-action { font-size: .82rem; font-weight: 600; color: var(--ps-primary); padding-left: 20px; }
.sla-rule-filter { font-size: .76rem; color: var(--ps-text-light); padding-left: 20px; }
.sla-empty-state {
  padding: 28px 20px; background: var(--ps-surface); border: 1px dashed var(--ps-border);
  border-radius: var(--ps-radius-lg); color: var(--ps-text-muted); font-size: .875rem;
}

/* ═══════════════════════════════════════════════════════════════
 * VISUAL WORKFLOW BUILDER
 * ═══════════════════════════════════════════════════════════════ */
.wfb-empty {
  text-align: center; padding: 56px 24px;
  display: flex; flex-direction: column; align-items: center; gap: 16px;
}
.wfb-empty p { color: var(--ps-text-muted); }
.wfb-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }
.wfb-card {
  background: var(--ps-surface); border: 1px solid var(--ps-border);
  border-radius: var(--ps-radius-lg); padding: 18px;
  display: flex; flex-direction: column; gap: 10px;
  transition: box-shadow .15s;
}
.wfb-card:hover { box-shadow: var(--ps-shadow); }
.wfb-card-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.wfb-card-name { font-weight: 700; font-size: .92rem; }
.wfb-card-trigger {
  display: flex; align-items: center; gap: 6px;
  font-size: .78rem; color: var(--ps-text-muted); font-weight: 500;
}
.wfb-card-meta { display: flex; gap: 14px; font-size: .76rem; color: var(--ps-text-light); }
.wfb-card-actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 4px; }

/* Editor */
.wfb-editor-header {
  display: flex; align-items: center; gap: 16px;
  margin-bottom: 20px; padding-bottom: 16px; border-bottom: 1px solid var(--ps-border);
}
.wfb-editor-title { flex: 1; font-weight: 700; font-size: 1.05rem; }
.wfb-trigger-box {
  padding: 14px 18px; background: var(--ps-primary);
  border-radius: var(--ps-radius-lg); color: #fff; margin-bottom: 4px;
}
.wfb-trigger-label { font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; opacity: .7; }
.wfb-trigger-value { font-size: .95rem; font-weight: 700; display: flex; align-items: center; gap: 6px; margin-top: 4px; }
.wfb-trigger-filter { font-size: .76rem; opacity: .75; margin-top: 4px; }
.wfb-trigger-filter code { background: rgba(255,255,255,.15); padding: 1px 5px; border-radius: 4px; }

.wfb-steps { display: flex; flex-direction: column; margin-top: 4px; }
.wfb-step-empty {
  padding: 28px; text-align: center;
  border: 2px dashed var(--ps-border); border-radius: var(--ps-radius-lg);
  color: var(--ps-text-muted); font-size: .875rem;
}
.wfb-step {
  display: flex; align-items: flex-start; gap: 12px;
  background: var(--ps-surface); border: 1px solid var(--ps-border);
  border-radius: var(--ps-radius-lg); padding: 14px 16px;
}
.wfb-step-condition { border-left: 3px solid var(--ps-warning); }
.wfb-step-action    { border-left: 3px solid var(--ps-primary); }
.wfb-step-order {
  width: 26px; height: 26px; border-radius: 50%;
  background: var(--ps-surface-2); border: 1px solid var(--ps-border);
  display: flex; align-items: center; justify-content: center;
  font-size: .75rem; font-weight: 700; color: var(--ps-text-muted); flex-shrink: 0;
}
.wfb-step-body { flex: 1; min-width: 0; }
.wfb-step-type-badge {
  display: inline-block; font-size: .65rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .07em;
  padding: 1px 6px; border-radius: 4px; margin-bottom: 4px;
  background: var(--ps-surface-2); color: var(--ps-text-muted);
}
.wfb-step-condition .wfb-step-type-badge { background: var(--ps-warning-bg); color: var(--ps-warning); }
.wfb-step-action    .wfb-step-type-badge { background: var(--ps-primary-light, #eef0fd); color: var(--ps-primary); }
.wfb-step-label { font-size: .875rem; font-weight: 600; color: var(--ps-text); }
.wfb-step-config { font-size: .72rem; color: var(--ps-text-light); margin-top: 4px; font-family: monospace; }
.wfb-step-actions { display: flex; gap: 6px; flex-shrink: 0; align-self: center; }
.wfb-step-connector { display: flex; flex-direction: column; align-items: center; padding: 4px 0; }
.wfb-connector-line { width: 1px; height: 14px; background: var(--ps-border); }
.wfb-connector-arrow { font-size: .75rem; color: var(--ps-text-light); }

/* ══ Campaign Queue ══════════════════════════════════════════════════════════ */
.cq-list { display: flex; flex-direction: column; gap: 14px; }
.cq-card {
  background: var(--ps-surface);
  border: 1px solid var(--ps-border);
  border-radius: var(--ps-radius-lg);
  padding: 0;
  overflow: hidden;
}
.cq-card-hdr {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px; border-bottom: 1px solid var(--ps-border);
  background: var(--ps-surface-2);
}
.cq-card-title { font-size: .95rem; }
.cq-campaign-preview {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 8px 20px; padding: 14px 18px;
  border-bottom: 1px solid var(--ps-border);
}
.cq-preview-row { display: flex; flex-direction: column; gap: 2px; }
.cq-preview-lbl { font-size: .72rem; font-weight: 600; color: var(--ps-text-muted); text-transform: uppercase; letter-spacing: .04em; }
.cq-notes {
  padding: 10px 18px; font-size: .82rem; color: var(--ps-text-muted);
  border-bottom: 1px solid var(--ps-border);
  background: var(--ps-surface-2);
}
.cq-rejected {
  padding: 10px 18px; font-size: .82rem;
  color: var(--ps-danger); background: var(--ps-danger-bg);
  border-bottom: 1px solid var(--ps-border);
}
.cq-card-footer {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 18px; gap: 10px;
}

/* ══ Backup Center ═══════════════════════════════════════════════════════════ */
.backup-info-bar {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 16px; margin-bottom: 20px;
  background: var(--ps-surface-2); border: 1px solid var(--ps-border);
  border-radius: var(--ps-radius); font-size: .82rem; color: var(--ps-text-muted);
}

/* ══ API Key Management ══════════════════════════════════════════════════════ */
.apikey-info-bar {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 16px; margin-bottom: 20px;
  background: var(--ps-warning-bg); border: 1px solid var(--ps-border);
  border-radius: var(--ps-radius); font-size: .82rem; color: var(--ps-warning);
}
.apikey-info-bar code {
  background: rgba(0,0,0,.08); padding: 1px 5px;
  border-radius: 4px; font-family: monospace; font-size: .78rem;
}
.td-mono { font-family: 'Courier New', Courier, monospace; }

/* ══ Audit Logs ══════════════════════════════════════════════════════════════ */

/* ══ Contact Deduplication ═══════════════════════════════════════════════════ */
.dedup-info {
  padding: 12px 16px; margin-bottom: 20px;
  background: var(--ps-surface-2); border: 1px solid var(--ps-border);
  border-radius: var(--ps-radius); font-size: .84rem; color: var(--ps-text-muted);
}
.dedup-summary {
  font-size: .875rem; color: var(--ps-text-muted);
}
.dedup-groups { display: flex; flex-direction: column; gap: 16px; }
.dedup-group {
  background: var(--ps-surface); border: 1px solid var(--ps-border);
  border-radius: var(--ps-radius-lg); overflow: hidden;
}
.dedup-group-hdr {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px; background: var(--ps-surface-2);
  border-bottom: 1px solid var(--ps-border);
  font-size: .875rem; font-weight: 600;
}
.dedup-contacts { padding: 4px 0; }
.dedup-contact-row {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--ps-border);
  transition: background .12s;
}
.dedup-contact-row:last-child { border-bottom: none; }
.dedup-contact-row:hover { background: var(--ps-surface-2); }

/* ══ Stat Row (reused across sections) ══════════════════════════════════════ */
.stat-row { display: flex; gap: 12px; flex-wrap: wrap; }
.stat-card {
  flex: 1; min-width: 100px;
  background: var(--ps-surface); border: 1px solid var(--ps-border);
  border-radius: var(--ps-radius-lg); padding: 14px 18px;
  text-align: center;
}
.stat-card-val { font-size: 1.6rem; font-weight: 800; line-height: 1.1; }
.stat-card-lbl { font-size: .72rem; color: var(--ps-text-muted); margin-top: 4px; text-transform: uppercase; letter-spacing: .04em; }

/* ══ Misc shared ═════════════════════════════════════════════════════════════ */
.btn-warning { background: var(--ps-warning); color: #fff; }
.btn-warning:hover { filter: brightness(1.08); }
.btn-danger  { background: var(--ps-danger);  color: #fff; }
.btn-danger:hover  { filter: brightness(1.08); }
.nav-badge {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 18px; height: 18px; padding: 0 4px;
  border-radius: 9px; background: var(--ps-danger); color: #fff;
  font-size: .65rem; font-weight: 700; margin-left: auto;
}

/* ══ Pishi AI Assistant Widget ═══════════════════════════════════════════════ */

/* Floating trigger button */
#pishi-btn {
  position: fixed; bottom: 24px; right: 24px; z-index: 8888;
  width: 54px; height: 54px; border-radius: 50%;
  background: linear-gradient(135deg, var(--ps-primary), var(--ps-primary-light));
  color: #fff; border: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 20px rgba(26,35,126,.45);
  transition: transform .18s, box-shadow .18s;
}
#pishi-btn:hover { transform: scale(1.08); box-shadow: 0 6px 28px rgba(26,35,126,.55); }
#pishi-btn-badge {
  position: absolute; top: 2px; right: 2px;
  background: var(--ps-danger); color: #fff;
  border-radius: 9px; min-width: 16px; height: 16px; padding: 0 3px;
  font-size: .6rem; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}

/* Chat panel */
#pishi-panel {
  position: fixed; bottom: 88px; right: 24px; z-index: 8887;
  width: 380px; max-height: 600px;
  background: var(--ps-surface);
  border: 1px solid var(--ps-border);
  border-radius: var(--ps-radius-xl);
  box-shadow: 0 12px 40px rgba(0,0,0,.18);
  display: flex; flex-direction: column; overflow: hidden;
  animation: pishiSlideIn .22s cubic-bezier(.34,1.4,.64,1) both;
}
@keyframes pishiSlideIn {
  from { opacity:0; transform:translateY(20px) scale(.95); }
  to   { opacity:1; transform:translateY(0) scale(1); }
}
@media (max-width: 480px) {
  #pishi-panel { right: 8px; left: 8px; width: auto; bottom: 80px; }
  #pishi-btn   { right: 16px; bottom: 16px; }
}

/* Header */
.pishi-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 14px;
  background: linear-gradient(135deg, var(--ps-primary-dark), var(--ps-primary));
  flex-shrink: 0;
}
.pishi-header-info { display: flex; align-items: center; gap: 10px; }
.pishi-avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: rgba(255,255,255,.18);
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.pishi-name   { font-size: .875rem; font-weight: 700; color: #fff; }
.pishi-status { font-size: .68rem; color: rgba(255,255,255,.6); }
.pishi-hdr-btn {
  width: 28px; height: 28px; border-radius: 6px;
  background: rgba(255,255,255,.12); border: none; cursor: pointer; color: rgba(255,255,255,.8);
  display: flex; align-items: center; justify-content: center;
  transition: background .14s;
}
.pishi-hdr-btn:hover { background: rgba(255,255,255,.22); }

/* Messages area */
.pishi-msgs {
  flex: 1; overflow-y: auto; padding: 14px 12px; display: flex;
  flex-direction: column; gap: 12px; min-height: 0;
  background: var(--ps-surface-2);
}
.pishi-msgs::-webkit-scrollbar { width: 4px; }
.pishi-msgs::-webkit-scrollbar-track { background: transparent; }
.pishi-msgs::-webkit-scrollbar-thumb { background: var(--ps-border); border-radius: 4px; }

/* Individual message */
.pishi-msg { display: flex; gap: 8px; align-items: flex-end; }
.pishi-msg-user { flex-direction: row-reverse; }
.pishi-msg-avatar {
  width: 24px; height: 24px; border-radius: 50%; flex-shrink: 0;
  background: linear-gradient(135deg, var(--ps-primary), var(--ps-primary-light));
  display: flex; align-items: center; justify-content: center;
}
.pishi-msg-bubble {
  max-width: 82%; padding: 9px 12px;
  border-radius: 14px;
  background: var(--ps-surface);
  border: 1px solid var(--ps-border);
  box-shadow: var(--ps-shadow-xs);
}
.pishi-msg-user .pishi-msg-bubble {
  background: var(--ps-primary);
  border-color: var(--ps-primary);
  color: #fff;
  border-radius: 14px 14px 4px 14px;
}
.pishi-msg-bot .pishi-msg-bubble { border-radius: 14px 14px 14px 4px; }
.pishi-msg-text { font-size: .84rem; line-height: 1.5; }
.pishi-msg-user .pishi-msg-text { color: #fff; }
.pishi-msg-time {
  font-size: .62rem; color: var(--ps-text-light); margin-top: 4px; text-align: right;
}
.pishi-msg-user .pishi-msg-time { color: rgba(255,255,255,.55); }

/* Typing indicator dots */
.pishi-typing-dots {
  display: flex; gap: 4px; padding: 2px 4px;
}
.pishi-typing-dots span {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--ps-text-light);
  animation: pishiDot 1.2s ease-in-out infinite;
}
.pishi-typing-dots span:nth-child(2) { animation-delay: .2s; }
.pishi-typing-dots span:nth-child(3) { animation-delay: .4s; }
@keyframes pishiDot {
  0%,60%,100% { transform: translateY(0); opacity: .4; }
  30%          { transform: translateY(-5px); opacity: 1; }
}

/* Quick prompt chips */
.pishi-quick {
  display: flex; flex-wrap: wrap; gap: 6px;
  padding: 10px 12px; background: var(--ps-surface-2);
  border-top: 1px solid var(--ps-border); flex-shrink: 0;
}
.pishi-quick-btn {
  padding: 5px 10px; border-radius: 20px; font-size: .72rem; font-weight: 500;
  background: var(--ps-surface); border: 1px solid var(--ps-border);
  cursor: pointer; color: var(--ps-text-muted); white-space: nowrap;
  transition: all .14s; font-family: var(--ps-font);
}
.pishi-quick-btn:hover { background: var(--ps-primary); color: #fff; border-color: var(--ps-primary); }

/* Input bar */
.pishi-input-bar {
  display: flex; align-items: flex-end; gap: 8px;
  padding: 10px 12px; border-top: 1px solid var(--ps-border);
  background: var(--ps-surface); flex-shrink: 0;
}
.pishi-input {
  flex: 1; resize: none; border: 1px solid var(--ps-border);
  border-radius: 10px; padding: 8px 12px;
  font-size: .84rem; font-family: var(--ps-font);
  color: var(--ps-text); background: var(--ps-surface-2);
  outline: none; line-height: 1.45; min-height: 36px; max-height: 120px;
  transition: border-color .14s;
}
.pishi-input:focus { border-color: var(--ps-primary-light); }
.pishi-input::placeholder { color: var(--ps-text-light); }
.pishi-send-btn {
  width: 36px; height: 36px; border-radius: 10px; flex-shrink: 0;
  background: var(--ps-primary); color: #fff; border: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background .14s; align-self: flex-end;
}
.pishi-send-btn:hover:not(:disabled) { background: var(--ps-primary-light); }
.pishi-send-btn:disabled { opacity: .5; cursor: not-allowed; }

/* Footer */
.pishi-footer {
  padding: 5px 12px; font-size: .6rem; color: var(--ps-text-light);
  text-align: center; background: var(--ps-surface); border-top: 1px solid var(--ps-border);
  flex-shrink: 0;
}

/* Health card (inside messages) */
.pishi-health-card {
  margin-top: 4px; background: var(--ps-surface);
  border: 1px solid var(--ps-border); border-radius: 10px;
  padding: 10px 12px; font-size: .78rem;
  box-shadow: var(--ps-shadow-xs);
}
.pishi-health-title {
  font-weight: 700; font-size: .72rem; color: var(--ps-text-muted);
  text-transform: uppercase; letter-spacing: .05em; margin-bottom: 6px;
  display: flex; align-items: center; gap: 5px;
}
.pishi-health-row {
  display: flex; justify-content: space-between;
  padding: 3px 0; color: var(--ps-text);
}
.pishi-health-divider { height: 1px; background: var(--ps-border); margin: 6px 0; }
.pishi-ok   { color: var(--ps-success); font-weight: 600; }
.pishi-warn { color: var(--ps-warning); font-weight: 600; }
.pishi-err  { color: var(--ps-danger);  font-weight: 600; }

/* ── Real Estate / Generic form helpers ──────────────────────────────────── */
.field-label {
  display: block; font-size: .8rem; font-weight: 600;
  color: var(--ps-text-muted); margin-bottom: 5px;
}
.field-input {
  width: 100%; padding: 8px 12px;
  border: 1.5px solid var(--ps-border); border-radius: 6px;
  font-size: .9rem; background: var(--ps-surface); color: var(--ps-text);
  outline: none; transition: border .18s;
}
.field-input:focus { border-color: var(--ps-primary-light); }
.field-input[type="datetime-local"] { padding: 7px 10px; }
textarea.field-input { resize: vertical; min-height: 60px; }
select.field-input { cursor: pointer; }

/* Panel card used inside sections */
.section-panel {
  background: var(--ps-surface); border: 1px solid var(--ps-border);
  border-radius: var(--ps-radius-lg); box-shadow: var(--ps-shadow-xs);
}

/* Stat row (real estate dashboard) */
.stat-row {
  display: flex; flex-wrap: wrap; gap: 14px; margin-bottom: 24px;
}
.stat-card {
  flex: 1; min-width: 110px; background: var(--ps-surface);
  border: 1px solid var(--ps-border); border-radius: var(--ps-radius-lg);
  padding: 16px 20px; box-shadow: var(--ps-shadow-xs);
}
.stat-card-val { font-size: 1.8rem; font-weight: 800; color: var(--ps-primary); }
.stat-card-lbl { font-size: .75rem; color: var(--ps-text-muted); margin-top: 3px; }
.badge {
  display: inline-block; padding: 2px 9px; border-radius: 20px;
  font-size: .75rem; font-weight: 600; white-space: nowrap;
}

/* ── Inbox Simulator Strip (Create Campaign preview text) ──────────────── */
.inbox-sim-strip {
  display: flex; align-items: center; gap: 12px;
  background: var(--ps-surface);
  border: 1.5px solid var(--ps-border);
  border-radius: 8px;
  padding: 10px 16px;
  margin-top: 8px;
  box-shadow: var(--ps-shadow-xs);
  min-height: 52px;
}
.inbox-sim-avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: linear-gradient(135deg, var(--ps-primary) 0%, var(--ps-primary-light) 100%);
  color: #fff; font-weight: 700; font-size: 14px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.inbox-sim-content { flex: 1; min-width: 0; }
.inbox-sim-toprow {
  display: flex; justify-content: space-between; align-items: baseline;
  margin-bottom: 2px;
}
.inbox-sim-from { font-weight: 600; font-size: .82rem; color: var(--ps-text); }
.inbox-sim-time { font-size: .75rem; color: var(--ps-text-muted); }
.inbox-sim-body { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.inbox-sim-subject { font-size: .82rem; font-weight: 600; color: var(--ps-text); }
.inbox-sim-preheader { font-size: .82rem; color: var(--ps-text-muted); font-weight: 400; }

/* ── Campaign / Form info box ───────────────────────────────────────────── */
.form-info-box {
  display: flex; align-items: flex-start; gap: 8px;
  background: color-mix(in srgb, var(--ps-primary) 8%, transparent);
  border: 1px solid color-mix(in srgb, var(--ps-primary) 20%, transparent);
  border-radius: 7px; padding: 10px 14px;
  font-size: .83rem; color: var(--ps-text); line-height: 1.5;
}
.form-info-box svg { margin-top: 2px; color: var(--ps-primary); }

/* ── Pipeline section: fill content height ───────────────────────────────── */
#section-pipelines.active {
  display: flex;
  flex-direction: column;
}
#section-pipelines .kanban-board {
  flex: 1 1 auto;
}

/* ── Pipeline / Kanban improvements ─────────────────────────────────────── */
.kanban-board {
  padding-bottom: 12px;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
}
.kanban-col {
  scroll-snap-align: start;
}
.pipeline-selector-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  flex: 1;
}
.pipeline-selector-wrap select {
  min-width: 0;
  max-width: 280px;
  font-weight: 600;
}
@media (max-width: 768px) {
  #section-pipelines.active { min-height: 0; }

  /* ── Vertical stage layout on mobile ─── */
  .kanban-board {
    flex-direction: column;
    overflow-x: hidden;
    overflow-y: visible;
    scroll-snap-type: none;
    -webkit-overflow-scrolling: auto;
    min-height: 0;
    gap: 12px;
    padding-bottom: 24px;
  }
  .kanban-col {
    flex: none;
    width: 100%;
    min-width: 0;
    max-width: none;
    max-height: none;       /* let cards expand fully */
    scroll-snap-align: none;
  }
  .kanban-cards {
    max-height: none;       /* no scroll clipping — show all cards */
    overflow-y: visible;
  }
  .kanban-col-hdr { padding: 10px 14px; }
  .kanban-add-deal { padding: 8px 14px; font-size: .82rem; }

  /* Pipeline section header stays compact in one row */
  .pipeline-selector-wrap { flex: 1; min-width: 0; }
  .pipeline-selector-wrap select { max-width: none; width: 100%; font-size: .85rem; }
  #section-pipelines .section-header {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
  }
  #section-pipelines .section-header-actions { flex-wrap: nowrap; gap: 5px; flex-shrink: 0; }
  #section-pipelines .section-header-actions .btn { font-size: .76rem; padding: 5px 8px; }

  /* Add-stage button full width */
  .kanban-add-stage { width: 100%; }
  .kanban-add-stage-btn { width: 100%; justify-content: center; }
}
@media (max-width: 480px) {
  .pipeline-selector-wrap select { font-size: .8rem; }
  .kanban-board { gap: 10px; }
}

/* ── Campaign status action buttons ────────────────────────────────────── */
.btn-success {
  background: var(--ps-success);
  color: #fff;
  border: none;
}
.btn-success:hover { background: #2e7d32; }
