/* ============================================================
   TECHFLY.CLOUD — Global Stylesheet
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@400;600;700;800&family=Inter:ital,opsz,wght@0,14..32,100..900;1,14..32,100..900&display=swap');

/* ── RESET ── */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; font-size: 16px; }
img { max-width: 100%; display: block; }
a { text-decoration: none; color: inherit; }
ul { list-style: none; }
button { cursor: pointer; border: none; background: none; font: inherit; }

/* ── TOKENS REDESIGNED ── */
:root {
  --bg:        #ffffff;
  --bg2:       #f9fafb;
  --bg3:       #f3f4f6;
  --surface:   #ffffff;
  --surface2:  #f8fafc;
  --accent:    #5e4e99;
  --accent2:   #7c6fd1;
  --accent3:   #a397e5;
  --glow:      rgba(94, 78, 153, 0.25);
  --border:    rgba(94, 78, 153, 0.1);
  --border2:   rgba(94, 78, 153, 0.22);
  --glow:      rgba(79,70,229,0.12);
  --glow2:     rgba(79,70,229,0.06);
  --radius:    24px;
  --radius-sm: 14px;
  --ff-head:   'Outfit', sans-serif;
  --ff-body:   'Inter', sans-serif;
  --transition: 0.4s cubic-bezier(0.2, 0.8, 0.2, 1);
  --text:      #0f172a;
  --muted:     #64748b;
}

/* ── BASE ── */
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--ff-body);
  font-weight: 400;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* ── BACKGROUND LAYERS ── */
.bg-orbs {
  position: fixed; inset: 0; pointer-events: none; z-index: 0;
  overflow: hidden;
}
.bg-orbs::before {
  content: '';
  position: absolute; top: -20%; left: -15%;
  width: 80vw; height: 80vw;
  background: radial-gradient(circle, rgba(79,70,229,0.06) 0%, transparent 60%);
  animation: orbFloat 12s ease-in-out infinite alternate;
}
.bg-orbs::after {
  content: '';
  position: absolute; bottom: -20%; right: -15%;
  width: 70vw; height: 70vw;
  background: radial-gradient(circle, rgba(99,102,241,0.04) 0%, transparent 60%);
  animation: orbFloat 15s ease-in-out 3s infinite alternate-reverse;
}
@keyframes orbFloat {
  from { transform: translate(0,0) scale(1); }
  to   { transform: translate(2%,3%) scale(1.05); }
}

.grid-tex {
  position: fixed; inset: 0; pointer-events: none; z-index: 0;
  background-image:
    linear-gradient(rgba(79,70,229,0.02) 1px, transparent 1px),
    linear-gradient(90deg, rgba(79,70,229,0.02) 1px, transparent 1px);
  background-size: 80px 80px;
}

/* ── LAYOUT ── */
.wrapper {
  position: relative; z-index: 1;
  max-width: 1160px;
  margin: 0 auto;
  padding: 0 24px;
}

section { padding: 100px 0; }

/* ── NAVBAR ── */
.navbar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 100;
  padding: 0 24px;
  transition: background 0.4s, backdrop-filter 0.4s, border-color 0.4s;
}
.navbar.scrolled {
  background: rgba(255,255,255,0.85);
  backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
}
.nav-inner {
  max-width: 1160px; margin: 0 auto;
  display: flex; align-items: center; justify-content: space-between;
  height: 72px;
}
.nav-logo img { height: 38px; width: auto; }
.nav-logo .logo-fallback {
  font-family: var(--ff-head); font-weight: 800; font-size: 24px;
  background: linear-gradient(90deg, #1a1a1a, var(--accent));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}
.nav-links {
  display: flex; align-items: center; gap: 36px;
}
.nav-links a {
  font-size: 14px; font-weight: 500; color: var(--muted);
  letter-spacing: 0.3px; transition: color 0.25s;
  position: relative;
}
.nav-links a::after {
  content: ''; position: absolute; bottom: -4px; left: 0; right: 0; height: 1px;
  background: var(--accent2); transform: scaleX(0); transform-origin: left;
  transition: transform 0.3s;
}
.nav-links a:hover, .nav-links a.active { color: var(--text); }
.nav-links a:hover::after, .nav-links a.active::after { transform: scaleX(1); }
.nav-cta {
  padding: 10px 22px; border-radius: 30px;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  color: #fff !important; font-weight: 600; font-size: 14px;
  box-shadow: 0 4px 20px var(--glow);
  transition: var(--transition) !important;
}
.nav-cta:hover { box-shadow: 0 8px 32px rgba(124,92,252,0.55) !important; transform: translateY(-2px); }
.nav-cta::after { display: none !important; }

.nav-cta-outline {
  padding: 10px 22px; border-radius: 30px;
  background: transparent; border: 1.5px solid var(--accent);
  color: var(--accent) !important; font-weight: 600; font-size: 14px;
  transition: var(--transition) !important;
}
.nav-cta-outline:hover { background: var(--accent); color: #fff !important; transform: translateY(-2px); }
.nav-cta-outline::after { display: none !important; }

/* Hamburger */
.hamburger { display: none; flex-direction: column; gap: 5px; padding: 4px; }
.hamburger span { display: block; width: 26px; height: 3px; background: #000; border-radius: 3px; transition: 0.3s; }

/* Mobile nav */
.mobile-nav {
  display: none; position: fixed; inset: 0; z-index: 999;
  background: rgba(7,7,16,0.98); backdrop-filter: blur(20px);
  flex-direction: column; align-items: center; justify-content: center; gap: 32px;
}
.mobile-nav.open { display: flex; }
.mobile-nav a { font-family: var(--ff-head); font-size: 28px; font-weight: 700; color: #fff !important; transition: color 0.2s; }
.mobile-nav a:hover, .mobile-nav a.active { color: #fff; }
.mobile-nav .nav-cta-outline { color: #fff !important; border: 1.5px solid rgba(255,255,255,0.4) !important; }
.mobile-nav .close-btn { position: absolute; top: 24px; right: 24px; font-size: 28px; color: #fff; background: none; border: none; cursor: pointer; }

/* ── SECTION LABELS ── */
.section-eyebrow {
  display: inline-flex; align-items: center; gap: 8px;
  background: rgba(124,92,252,0.08);
  border: 1px solid var(--border);
  border-radius: 30px; padding: 6px 16px;
  font-size: 11px; font-weight: 600; letter-spacing: 2px;
  text-transform: uppercase; color: var(--accent2);
  margin-bottom: 20px;
}

/* ── HEADINGS ── */
.section-title {
  font-family: var(--ff-head); font-weight: 800;
  font-size: clamp(32px, 5vw, 52px);
  line-height: 1.1; letter-spacing: -1.5px;
  margin-bottom: 16px;
}
.section-title em {
  font-style: normal;
  background: linear-gradient(120deg, var(--accent) 0%, var(--accent2) 60%, var(--accent3) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}
.section-sub {
  font-size: 17px; color: var(--muted); line-height: 1.7;
  font-weight: 300; max-width: 560px;
}

/* ── BUTTONS ── */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 14px 28px; border-radius: 30px;
  font-family: var(--ff-body); font-size: 15px; font-weight: 600;
  transition: var(--transition); letter-spacing: 0.2px;
  position: relative; overflow: hidden;
}
.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  color: #fff; box-shadow: 0 6px 24px var(--glow);
}
.btn-primary:hover { box-shadow: 0 12px 40px rgba(124,92,252,0.6); transform: translateY(-3px); }
.btn-outline {
  background: transparent; border: 1px solid var(--border2);
  color: var(--text);
}
.btn-outline:hover { background: var(--glow2); border-color: var(--accent); transform: translateY(-2px); }

/* ── CARDS ── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px;
  transition: var(--transition);
  position: relative; overflow: hidden;
}
.card:hover {
  border-color: var(--border2);
  box-shadow: 0 24px 60px rgba(0,0,0,0.4), 0 0 40px var(--glow2);
  transform: translateY(-6px);
}

/* ── TICKER ── */
.ticker-wrap {
  overflow: hidden; border-top: 1px solid var(--border); border-bottom: 1px solid var(--border);
  padding: 14px 0; background: var(--bg2);
}
.ticker-track {
  display: flex; gap: 0; width: max-content;
  animation: ticker 30s linear infinite;
}
.ticker-track:hover { animation-play-state: paused; }
.ticker-item {
  display: inline-flex; align-items: center; gap: 16px;
  padding: 0 28px; font-size: 13px; font-weight: 600;
  letter-spacing: 2px; text-transform: uppercase; color: var(--muted);
  white-space: nowrap;
}
.ticker-item span { color: var(--accent); font-size: 18px; }
@keyframes ticker {
  from { transform: translateX(0); }
  to   { transform: translateX(-50%); }
}

/* ── DIVIDER ── */
.divider { height: 1px; background: var(--border); margin: 0; }

/* ── FEAT ICON ── */
.feat-icon {
  flex-shrink: 0; width: 20px; height: 20px; border-radius: 50%;
  background: rgba(124,92,252,0.15); border: 1px solid var(--border2);
  display: flex; align-items: center; justify-content: center;
}
.feat-icon svg { width: 10px; height: 10px; fill: none; stroke: var(--accent2); stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; }

/* ── FOOTER ── */
footer {
  background: var(--bg2); border-top: 1px solid var(--border);
  padding: 64px 24px 32px; position: relative; z-index: 1;
}
.footer-inner {
  max-width: 1160px; margin: 0 auto;
  display: grid; grid-template-columns: 2fr 1fr 1fr 1fr; gap: 48px;
  padding-bottom: 48px; border-bottom: 1px solid var(--border);
}
.footer-brand p { font-size: 14px; color: var(--muted); margin-top: 14px; line-height: 1.7; max-width: 280px; }
.footer-col h4 { font-family: var(--ff-head); font-size: 13px; font-weight: 700; letter-spacing: 1.5px; text-transform: uppercase; color: var(--text); margin-bottom: 16px; }
.footer-col a { display: block; font-size: 14px; color: var(--muted); margin-bottom: 10px; transition: color 0.2s; }
.footer-col a:hover { color: var(--accent2); }
.footer-bottom {
  max-width: 1160px; margin: 28px auto 0;
  display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px;
  font-size: 13px; color: var(--muted);
}
.footer-bottom a { color: var(--muted); transition: color 0.2s; }
.footer-bottom a:hover { color: var(--accent2); }
.social-links { display: flex; gap: 14px; }
.social-link {
  width: 44px; height: 44px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 18px; transition: var(--transition);
  box-shadow: 0 4px 14px rgba(0,0,0,0.12);
}
.social-link:hover { transform: translateY(-4px); box-shadow: 0 8px 24px rgba(0,0,0,0.18); }
.social-link.wa  { background: linear-gradient(135deg, #25d366, #128c7e); }
.social-link.mail { background: linear-gradient(135deg, var(--accent), var(--accent2)); }
.social-link.ph  { background: linear-gradient(135deg, #3b82f6, #6366f1); }

/* ── WA FLOAT ── */
.wa-float {
  position: fixed; bottom: 28px; right: 28px; z-index: 200;
  width: 56px; height: 56px; border-radius: 50%;
  background: #25D366; box-shadow: 0 6px 24px rgba(37,211,102,0.4);
  display: flex; align-items: center; justify-content: center;
  transition: var(--transition);
}
.wa-float:hover { transform: scale(1.1); box-shadow: 0 10px 32px rgba(37,211,102,0.6); }
.wa-float svg { width: 28px; height: 28px; fill: #fff; }

/* ── ANIMATIONS ── */
@keyframes fadeUp   { from { opacity:0; transform:translateY(28px); } to { opacity:1; transform:translateY(0); } }
@keyframes fadeDown { from { opacity:0; transform:translateY(-16px); } to { opacity:1; transform:translateY(0); } }
@keyframes fadeIn   { from { opacity:0; } to { opacity:1; } }
@keyframes scaleIn  { from { opacity:0; transform:scale(0.92); } to { opacity:1; transform:scale(1); } }

.anim-up   { animation: fadeUp   0.7s ease both; }
.anim-down { animation: fadeDown 0.6s ease both; }
.anim-in   { animation: fadeIn   0.8s ease both; }

/* ── RESPONSIVE ── */
@media (max-width: 1024px) {
  .footer-inner { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 900px) {
  .nav-links { display: none; }
  .hamburger { display: flex; }
  .navbar { background: rgba(255,255,255,0.95); backdrop-filter: blur(10px); border-bottom: 1px solid var(--border); }
  .section-title { font-size: 36px; }
  section { padding: 60px 0; }
  .footer-inner { gap: 32px; }
}

@media (max-width: 600px) {
  .navbar { padding: 0 16px; }
  .nav-inner { height: 64px; }
  .nav-logo img { height: 32px; }
  .wrapper { padding: 0 20px; }
  .section-title { font-size: 32px; letter-spacing: -1px; }
  .section-sub { font-size: 15px; }
  .footer-inner { grid-template-columns: 1fr; }
  .footer-bottom { flex-direction: column; align-items: center; text-align: center; gap: 16px; }
  .social-links { justify-content: center; width: 100%; }
  .btn { width: 100%; justify-content: center; }
  .numbers-grid { grid-template-columns: 1fr 1fr !important; gap: 20px !important; }
}


/* ===== CRM STYLES ===== */
/*
   Used by the CRM inside admin.html. Tokens are namespaced (--crm-*) because
   admin.html redefines --accent / --border / --text for its legacy blue theme;
   the CRM always uses TechFly brand values. Headings: Manrope, body: Inter,
   numbers: JetBrains Mono (fonts loaded in admin.html). Corners max 4px.
*/
:root {
  --crm-primary:       #5E4E99;
  --crm-primary-light: #8B7DD9;
  --crm-primary-tint:  #EEEBF7;
  --crm-surface-dark:  #2A2A37;
  --crm-bg:            #F5F4FA;
  --crm-surface:       #FFFFFF;
  --crm-text:          #2A2A37;
  --crm-muted:         #6E6E80;
  --crm-line:          #EBECEC;
  --crm-radius:        4px;
  --crm-ff-head:       'Manrope', 'Inter', sans-serif;
  --crm-ff-body:       'Inter', sans-serif;
  --crm-ff-mono:       'JetBrains Mono', ui-monospace, 'SFMono-Regular', Consolas, monospace;
}

/* Elements toggled with the [hidden] attribute must stay hidden even when a
   CRM class gives them a display value */
.crm-subnav[hidden],
.crm-section[hidden] { display: none !important; }

/* ── Sidebar group (admin.html) ── */
.crm-nav-toggle {
  width: 100%;
  text-align: left;
  font-family: inherit;
}
.crm-nav-caret {
  width: 16px !important; height: 16px !important;
  margin-left: auto;
  transition: transform 0.2s ease;
}
.crm-nav-toggle[aria-expanded="true"] .crm-nav-caret { transform: rotate(180deg); }
.crm-nav-group--current > .crm-nav-toggle { color: var(--crm-primary); }

.crm-subnav {
  display: flex; flex-direction: column; gap: 2px;
  margin: 4px 0 8px 25px;          /* aligns with the parent icon's centre */
  padding-left: 12px;
  border-left: 1px solid var(--crm-line);
}
.crm-subnav .crm-subnav-link {
  padding: 7px 12px;
  border-radius: var(--crm-radius);
  font-size: 13px; font-weight: 500;
  color: var(--crm-muted);
}
.crm-subnav .crm-subnav-link::after { display: none; }   /* suppress public-nav underline from .nav-links a */
.crm-subnav .crm-subnav-link:hover { color: var(--crm-text); background: var(--crm-bg); }
.crm-subnav .crm-subnav-link.active {
  color: var(--crm-primary); background: var(--crm-primary-tint);
  font-weight: 600;
}
.crm-subnav-link:focus-visible,
.crm-nav-toggle:focus-visible { outline: 2px solid var(--crm-primary-light); outline-offset: 1px; }

/* ── Section container ── */
.crm-section {
  display: flex; flex-direction: column; gap: 20px;
  padding: 0;                       /* override global `section { padding: 100px 0 }` */
  font-family: var(--crm-ff-body);
  color: var(--crm-text);
}

.crm-section-header {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 16px; flex-wrap: wrap;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--crm-line);
}
.crm-eyebrow {
  font-size: 11px; font-weight: 600; letter-spacing: 1.2px;
  text-transform: uppercase; color: var(--crm-primary-light);
  margin-bottom: 4px;
}
.crm-section-title {
  font-family: var(--crm-ff-head);
  font-size: 22px; font-weight: 800; letter-spacing: -0.3px;
  color: var(--crm-text); line-height: 1.2;
}
.crm-section-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* ── Card ── */
.crm-card {
  background: var(--crm-surface);
  border: 1px solid var(--crm-line);
  border-radius: var(--crm-radius);
  padding: 20px;
}
.crm-card-title {
  font-family: var(--crm-ff-head);
  font-size: 15px; font-weight: 700; color: var(--crm-text);
  margin-bottom: 12px;
}
.crm-stat {
  font-family: var(--crm-ff-mono);
  font-size: 26px; font-weight: 600; letter-spacing: -0.5px;
  color: var(--crm-text);
  font-variant-numeric: tabular-nums;
}
.crm-stat-label { font-size: 12px; font-weight: 500; color: var(--crm-muted); }

/* ── Table ── */
.crm-table-wrap {
  width: 100%; overflow-x: auto;
  background: var(--crm-surface);
  border: 1px solid var(--crm-line);
  border-radius: var(--crm-radius);
}
.crm-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.crm-table th {
  padding: 10px 14px;
  text-align: left; white-space: nowrap;
  font-size: 11px; font-weight: 600; letter-spacing: 0.6px; text-transform: uppercase;
  color: var(--crm-muted);
  background: var(--crm-bg);
  border-bottom: 1px solid var(--crm-line);
}
.crm-table td {
  padding: 12px 14px;
  color: var(--crm-text);
  border-bottom: 1px solid var(--crm-line);
  vertical-align: middle;
}
.crm-table tbody tr:last-child td { border-bottom: none; }
.crm-table tbody tr:hover { background: #FAFAFD; }
.crm-table .crm-num {
  font-family: var(--crm-ff-mono);
  font-variant-numeric: tabular-nums;
  text-align: right; white-space: nowrap;
}

/* ── Stage badges (crm_deals.stage) ── */
.crm-stage-badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 8px;
  border-radius: var(--crm-radius);
  border: 1px solid transparent;
  font-size: 11px; font-weight: 600; line-height: 1.4;
  white-space: nowrap;
}
.crm-stage-badge::before {
  content: ''; width: 6px; height: 6px; border-radius: 1px;
  background: currentColor; flex-shrink: 0;
}
.crm-stage-badge--new           { background: #F2F2F5; color: #55556A; border-color: #E4E4EA; }
.crm-stage-badge--contacted     { background: #EAF1FB; color: #2F5E9E; border-color: #D3E2F6; }
.crm-stage-badge--qualified     { background: #F1EEFB; color: #6A5BB8; border-color: #E0DAF5; }
.crm-stage-badge--proposal_sent { background: #E9E5F5; color: #5E4E99; border-color: #D5CEEC; }
.crm-stage-badge--negotiation   { background: #FDF3E3; color: #9A5B0B; border-color: #F6E1BC; }
.crm-stage-badge--won           { background: #E8F5EE; color: #1E7A4C; border-color: #CBE9D8; }
.crm-stage-badge--lost          { background: #FBECEC; color: #A93636; border-color: #F3D2D2; }

/* ── Empty state ── */
.crm-empty-state {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 8px;
  min-height: 220px;
  padding: 40px 24px;
  text-align: center;
  background: var(--crm-surface);
  border: 1px dashed #D9D6E8;
  border-radius: var(--crm-radius);
}
.crm-empty-title {
  font-family: var(--crm-ff-head);
  font-size: 15px; font-weight: 700; color: var(--crm-text);
}
.crm-empty-text { font-size: 13px; color: var(--crm-muted); max-width: 420px; }

@media (max-width: 768px) {
  .crm-section { gap: 16px; }
  .crm-section-header { align-items: flex-start; flex-direction: column; }
  .crm-section-title { font-size: 19px; }
  .crm-section-actions { width: 100%; }
  .crm-card { padding: 16px; }
  .crm-table th, .crm-table td { padding: 10px; }
  .crm-empty-state { min-height: 160px; padding: 32px 16px; }
}

/* ── Shared CRM components (Phase 2+) ── */
:root {
  --crm-danger:      #DC2626;
  --crm-danger-tint: #FDECEC;
  --crm-success:     #16A34A;
  --crm-whatsapp:    #1DA851;
}

/* Anything hidden via the [hidden] attribute inside CRM UI stays hidden,
   even when its class sets a display value */
#crm [hidden], .crm-panel [hidden] { display: none !important; }

.crm-sr-only {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.crm-muted { color: var(--crm-muted); }
.crm-nowrap { white-space: nowrap; }
.crm-prewrap { white-space: pre-wrap; }
.crm-spacer { flex: 1; }
html.crm-no-scroll { overflow: hidden; }

/* Buttons */
.crm-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 36px; padding: 8px 14px;
  border: 1px solid transparent; border-radius: var(--crm-radius);
  font-family: var(--crm-ff-body); font-size: 13px; font-weight: 600; line-height: 1.2;
  white-space: nowrap; cursor: pointer; text-decoration: none;
  transition: background-color 0.15s, border-color 0.15s, color 0.15s;
}
.crm-btn:focus-visible { outline: 2px solid var(--crm-primary-light); outline-offset: 2px; }
.crm-btn:disabled, .crm-btn.is-disabled { opacity: 0.5; cursor: not-allowed; pointer-events: none; }
.crm-btn--sm { min-height: 28px; padding: 4px 10px; font-size: 12px; }
.crm-btn--primary { background: var(--crm-primary); color: #fff; }
.crm-btn--primary:hover { background: #4F4185; }
.crm-btn--ghost { background: var(--crm-surface); color: var(--crm-text); border-color: var(--crm-line); }
.crm-btn--ghost:hover { border-color: #D3D0E3; background: var(--crm-bg); }
.crm-btn--danger { background: var(--crm-danger); color: #fff; }
.crm-btn--danger:hover { background: #B91C1C; }
.crm-btn--danger-ghost { background: var(--crm-surface); color: var(--crm-danger); border-color: var(--crm-line); }
.crm-btn--danger-ghost:hover { background: var(--crm-danger-tint); border-color: #F5C2C2; }
.crm-btn--whatsapp { background: var(--crm-whatsapp); color: #fff; }
.crm-btn--whatsapp:hover { background: #178A43; }

.crm-icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; border-radius: var(--crm-radius); color: var(--crm-muted);
}
.crm-icon-btn:hover { background: var(--crm-bg); color: var(--crm-text); }
.crm-icon-btn:focus-visible { outline: 2px solid var(--crm-primary-light); }
.crm-icon-btn svg { width: 18px; height: 18px; }

/* Form controls */
.crm-field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.crm-label { font-size: 12px; font-weight: 600; color: var(--crm-text); }
.crm-required { color: var(--crm-danger); }
.crm-input, .crm-select, .crm-textarea {
  width: 100%; min-height: 38px; padding: 8px 10px;
  font-family: var(--crm-ff-body); font-size: 14px; color: var(--crm-text);
  background: var(--crm-surface);
  border: 1px solid #DCDCE3; border-radius: var(--crm-radius);
  outline: none; transition: border-color 0.15s, box-shadow 0.15s;
}
.crm-textarea { resize: vertical; min-height: 96px; line-height: 1.5; }
.crm-select { cursor: pointer; }
.crm-input:focus, .crm-select:focus, .crm-textarea:focus {
  border-color: var(--crm-primary); box-shadow: 0 0 0 3px rgba(94, 78, 153, 0.15);
}
.crm-input[aria-invalid="true"] { border-color: var(--crm-danger); }
.crm-input[aria-invalid="true"]:focus { box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.15); }
.crm-field-error { font-size: 12px; color: var(--crm-danger); }
.crm-field-hint { font-size: 12px; color: var(--crm-muted); }
.crm-field-hint--accent { color: var(--crm-primary); font-weight: 600; }
.crm-form-error {
  padding: 10px 12px; font-size: 13px; color: var(--crm-danger);
  background: var(--crm-danger-tint); border: 1px solid #F5C2C2; border-radius: var(--crm-radius);
}
.crm-form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.crm-input-group { display: flex; }
.crm-input-group .crm-input-group-code {
  flex: 0 0 104px; width: 104px; border-right: none; border-radius: var(--crm-radius) 0 0 var(--crm-radius);
  background: var(--crm-bg);
}
.crm-input-group .crm-input { border-radius: 0 var(--crm-radius) var(--crm-radius) 0; }
.crm-check { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--crm-text); cursor: pointer; }
.crm-check input { width: 16px; height: 16px; accent-color: var(--crm-primary); }

/* Combobox */
.crm-combobox { position: relative; }
.crm-combobox-list {
  position: absolute; top: 64px; left: 0; right: 0; z-index: 5;
  max-height: 240px; overflow-y: auto;
  background: var(--crm-surface); border: 1px solid #DCDCE3; border-radius: var(--crm-radius);
  box-shadow: 0 8px 24px rgba(42, 42, 55, 0.12);
}
.crm-combobox-option { padding: 9px 12px; font-size: 13px; cursor: pointer; border-bottom: 1px solid var(--crm-line); }
.crm-combobox-option:last-child { border-bottom: none; }
.crm-combobox-option:hover, .crm-combobox-option[aria-selected="true"] { background: var(--crm-primary-tint); }
.crm-combobox-option--create { color: var(--crm-primary); font-weight: 500; }

/* Filters */
.crm-filters {
  display: grid; grid-template-columns: minmax(200px, 2fr) repeat(2, minmax(140px, 1fr)) auto;
  gap: 12px; align-items: end; margin-bottom: 16px;
}

/* Avatar, badge, tags, links */
.crm-avatar {
  display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0;
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--crm-primary); color: #fff;
  font-family: var(--crm-ff-head); font-size: 13px; font-weight: 700;
}
.crm-avatar--lg { width: 64px; height: 64px; font-size: 26px; }
.crm-badge {
  display: inline-block; padding: 2px 8px;
  font-size: 11px; font-weight: 600; white-space: nowrap;
  color: var(--crm-primary); background: var(--crm-primary-tint);
  border: 1px solid #DDD7F1; border-radius: var(--crm-radius);
}
.crm-tags { display: flex; flex-wrap: wrap; gap: 6px; list-style: none; }
.crm-tag {
  padding: 2px 8px; font-size: 12px; color: var(--crm-text);
  background: var(--crm-bg); border: 1px solid var(--crm-line); border-radius: var(--crm-radius);
}
.crm-link { color: var(--crm-primary); }
.crm-link:hover { text-decoration: underline; }
.crm-link-strong { font-weight: 600; color: var(--crm-text); }
.crm-link-strong:hover { color: var(--crm-primary); text-decoration: underline; }
.crm-wa-link { display: inline-flex; align-items: center; gap: 6px; color: var(--crm-text); white-space: nowrap; font-family: var(--crm-ff-mono); font-size: 12px; }
.crm-wa-link:hover { color: var(--crm-whatsapp); }
.crm-wa-icon { width: 14px; height: 14px; color: var(--crm-whatsapp); flex-shrink: 0; }
.crm-back-link { display: inline-block; margin-bottom: 12px; font-size: 13px; font-weight: 600; color: var(--crm-muted); }
.crm-back-link:hover { color: var(--crm-primary); }

/* Table extras */
.crm-table-message { padding: 32px 14px !important; text-align: center; color: var(--crm-muted); }
.crm-cell-avatar { width: 48px; }
.crm-cell-name { white-space: nowrap; }
.crm-cell-name .crm-cell-sub { display: block; font-size: 12px; color: var(--crm-muted); }
.crm-cell-email { max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.crm-cell-actions { width: 1%; }
.crm-row-actions { display: flex; gap: 4px; justify-content: flex-end; }
.crm-btn--icon { min-height: 30px; width: 30px; padding: 0; }
.crm-btn--icon svg { width: 15px; height: 15px; }
.crm-btn--icon .crm-btn-text { display: none; }   /* label shown on mobile cards; aria-label covers desktop */
.crm-table--compact th, .crm-table--compact td { padding-left: 10px; padding-right: 10px; }
.crm-table--compact th { white-space: normal; }   /* long headers wrap before the table needs to scroll */
.crm-table time { font-size: 12px; }

/* Pagination */
.crm-pagination {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  margin-top: 12px;
}
.crm-pagination-info { font-size: 12px; color: var(--crm-muted); }
.crm-pagination-controls { display: flex; align-items: center; gap: 8px; }
.crm-pagination-page { font-family: var(--crm-ff-mono); font-size: 12px; color: var(--crm-muted); }

/* Hero empty state */
.crm-empty-state--hero { min-height: 320px; gap: 12px; }
.crm-empty-icon { width: 56px; height: 56px; color: var(--crm-primary-light); margin-bottom: 4px; }
.crm-empty-state--hero .crm-empty-title { font-size: 18px; }
.crm-empty-state .crm-btn { margin-top: 8px; }

/* Detail view */
.crm-detail { display: flex; flex-direction: column; gap: 16px; }
.crm-detail-header { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.crm-detail-heading { flex: 1; min-width: 180px; }
.crm-detail-name { font-family: var(--crm-ff-head); font-size: 24px; font-weight: 800; color: var(--crm-text); line-height: 1.2; }
.crm-detail-role { font-size: 14px; color: var(--crm-muted); margin-top: 4px; }
.crm-detail-actions { display: flex; gap: 8px; }
.crm-contact-bar { display: flex; gap: 8px; flex-wrap: wrap; }
.crm-contact-bar .crm-btn { min-width: 110px; }

.crm-tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--crm-line); overflow-x: auto; }
.crm-tab {
  padding: 10px 14px; margin-bottom: -1px;
  font-size: 13px; font-weight: 600; color: var(--crm-muted);
  border-bottom: 2px solid transparent; white-space: nowrap;
}
.crm-tab:hover { color: var(--crm-text); }
.crm-tab[aria-selected="true"] { color: var(--crm-primary); border-bottom-color: var(--crm-primary); }
.crm-tab:focus-visible { outline: 2px solid var(--crm-primary-light); outline-offset: -2px; }
.crm-tabpanel-footer { margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--crm-line); }

.crm-dl { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 32px; }
.crm-dl-row { display: grid; grid-template-columns: 130px 1fr; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--crm-line); font-size: 14px; }
.crm-dl-row--wide { grid-column: 1 / -1; }
.crm-dl dt { font-size: 12px; font-weight: 600; color: var(--crm-muted); padding-top: 2px; }
.crm-dl dd { color: var(--crm-text); min-width: 0; overflow-wrap: anywhere; }

/* Side panel (slide-in from the right) */
.crm-panel-backdrop {
  position: fixed; inset: 0; z-index: 1100;
  background: rgba(42, 42, 55, 0.45);
  opacity: 0; visibility: hidden;
  transition: opacity 0.2s ease, visibility 0s linear 0.2s;
}
.crm-panel-backdrop.is-open { opacity: 1; visibility: visible; transition: opacity 0.2s ease; }
.crm-panel {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 1101;
  width: 480px; max-width: 100vw;
  display: flex; flex-direction: column;
  background: var(--crm-surface); border-left: 1px solid var(--crm-line);
  box-shadow: -12px 0 32px rgba(42, 42, 55, 0.12);
  font-family: var(--crm-ff-body); color: var(--crm-text);
  transform: translateX(100%); visibility: hidden;
  transition: transform 0.25s ease, visibility 0s linear 0.25s;
}
.crm-panel.is-open { transform: translateX(0); visibility: visible; transition: transform 0.25s ease; }
.crm-panel-header {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 16px 20px; border-bottom: 1px solid var(--crm-line);
}
.crm-panel-title { font-family: var(--crm-ff-head); font-size: 18px; font-weight: 800; }
.crm-panel-body { flex: 1; overflow-y: auto; padding: 20px; display: flex; flex-direction: column; gap: 16px; }
.crm-panel-footer {
  display: flex; align-items: center; gap: 8px;
  padding: 14px 20px; border-top: 1px solid var(--crm-line); background: var(--crm-bg);
}

/* Confirmation dialog */
.crm-dialog {
  width: min(420px, calc(100vw - 32px)); padding: 24px; margin: auto;
  border: 1px solid var(--crm-line); border-radius: var(--crm-radius);
  box-shadow: 0 20px 48px rgba(42, 42, 55, 0.2);
  font-family: var(--crm-ff-body); color: var(--crm-text);
}
.crm-dialog::backdrop { background: rgba(42, 42, 55, 0.5); }
.crm-dialog-title { font-family: var(--crm-ff-head); font-size: 18px; font-weight: 800; margin-bottom: 8px; }
.crm-dialog-text { font-size: 14px; color: var(--crm-muted); line-height: 1.5; }
.crm-dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 24px; }

/* Toasts (bottom-right) */
.crm-toasts {
  position: fixed; right: 20px; bottom: 20px; z-index: 1200;
  display: flex; flex-direction: column; align-items: flex-end; gap: 8px;
  pointer-events: none;
}
.crm-toast {
  max-width: min(380px, calc(100vw - 40px)); padding: 12px 16px;
  font-family: var(--crm-ff-body); font-size: 13px; font-weight: 500; color: #fff;
  border-radius: var(--crm-radius); box-shadow: 0 8px 24px rgba(42, 42, 55, 0.18);
  opacity: 0; transform: translateY(8px);
  transition: opacity 0.2s ease, transform 0.2s ease;
}
.crm-toast.is-visible { opacity: 1; transform: none; }
.crm-toast--success { background: var(--crm-success); }
.crm-toast--error { background: var(--crm-danger); }

@media (prefers-reduced-motion: reduce) {
  .crm-panel, .crm-panel-backdrop, .crm-toast { transition: none !important; }
}

@media (max-width: 1100px) {
  .crm-filters { grid-template-columns: 1fr 1fr; }
  .crm-filters-search { grid-column: 1 / -1; }
  .crm-dl { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
  .crm-filters { grid-template-columns: 1fr; }
  .crm-filters-clear { justify-self: start; }
  .crm-section-actions .crm-btn { width: 100%; }

  /* Table becomes stacked cards: each row is a card, cells show their column label */
  .crm-table--stack thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .crm-table--stack, .crm-table--stack tbody, .crm-table--stack tr, .crm-table--stack td { display: block; width: 100%; }
  .crm-table--stack tr { position: relative; padding: 12px 12px 12px 60px; border-bottom: 1px solid var(--crm-line); }
  .crm-table--stack tbody tr:last-child { border-bottom: none; }
  .crm-table--stack td { padding: 3px 0 !important; border: none !important; max-width: none; }
  .crm-table--stack td[data-label]::before {
    content: attr(data-label); display: inline-block; width: 110px;
    font-size: 11px; font-weight: 600; color: var(--crm-muted); text-transform: uppercase; letter-spacing: 0.4px;
  }
  .crm-table--stack .crm-cell-avatar { position: absolute; left: 12px; top: 12px; width: auto; }
  .crm-table--stack .crm-cell-name::before { display: none !important; }
  .crm-table--stack .crm-cell-name { font-size: 15px; padding-bottom: 6px !important; }
  .crm-table--stack .crm-cell-actions { width: 100%; padding-top: 10px !important; }
  .crm-table--stack .crm-row-actions { justify-content: flex-start; gap: 6px; }
  .crm-table--stack .crm-btn--icon { width: auto; padding: 4px 10px; }
  .crm-table--stack .crm-btn--icon .crm-btn-text { display: inline; font-size: 12px; }
  .crm-table--stack .crm-table-message { padding: 24px 12px !important; }
  .crm-table--stack tr:has(.crm-table-message) { padding-left: 12px; }

  .crm-panel { width: 100vw; border-left: none; }
  .crm-form-row { grid-template-columns: 1fr; }
  .crm-detail-name { font-size: 20px; }
  .crm-avatar--lg { width: 52px; height: 52px; font-size: 22px; }
  .crm-detail-actions { width: 100%; }
  .crm-detail-actions .crm-btn, .crm-contact-bar .crm-btn { flex: 1; }
  .crm-dl-row { grid-template-columns: 1fr; gap: 2px; }
  .crm-toasts { left: 16px; right: 16px; bottom: 16px; align-items: stretch; }
  .crm-toast { max-width: none; }
}

/* ── Clients (Phase 3) ── */
.crm-dialog [hidden] { display: none !important; }
.crm-mono { font-family: var(--crm-ff-mono); font-size: 13px; }
.crm-input--mono { font-family: var(--crm-ff-mono); letter-spacing: 0.5px; text-transform: uppercase; }
.crm-input--mono::placeholder { text-transform: none; letter-spacing: 0; }
.crm-results-info { font-size: 12px; color: var(--crm-muted); margin-bottom: 12px; }
.crm-badge--muted { color: var(--crm-muted); background: var(--crm-bg); border-color: var(--crm-line); font-weight: 500; }

/* Header with pills between title and actions */
.crm-section-header--wrap { align-items: center; }
.crm-section-header--wrap > div:first-child { margin-right: auto; }

/* Status pills (segmented filter — sharp corners, not rounded pills) */
.crm-pills { display: flex; flex-wrap: wrap; gap: 0; border: 1px solid var(--crm-line); border-radius: var(--crm-radius); background: var(--crm-surface); overflow: hidden; }
.crm-pills--hidden { display: none !important; }
.crm-pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 12px; font-size: 12px; font-weight: 600; color: var(--crm-muted);
  border-right: 1px solid var(--crm-line); white-space: nowrap;
}
.crm-pill:last-child { border-right: none; }
.crm-pill:hover { color: var(--crm-text); background: var(--crm-bg); }
.crm-pill[aria-pressed="true"] { color: #fff; background: var(--crm-primary); }
.crm-pill:focus-visible { outline: 2px solid var(--crm-primary-light); outline-offset: -2px; }
.crm-pill-count { font-family: var(--crm-ff-mono); font-size: 11px; font-weight: 500; opacity: 0.75; }
.crm-pill-count:empty { display: none; }

.crm-filters--clients { grid-template-columns: minmax(220px, 2fr) minmax(180px, 1fr) auto; }

/* Status badges (crm_clients.status) */
.crm-status-badge {
  display: inline-flex; align-items: center; gap: 5px; padding: 2px 8px;
  font-size: 11px; font-weight: 600; line-height: 1.5; white-space: nowrap; vertical-align: middle;
  border: 1px solid transparent; border-radius: var(--crm-radius);
}
.crm-status-badge::before { content: ''; width: 6px; height: 6px; border-radius: 1px; background: currentColor; }
.crm-status-badge--lead     { background: #F2F2F5; color: #55556A; border-color: #E4E4EA; }
.crm-status-badge--prospect { background: #EAF1FB; color: #2F5E9E; border-color: #D3E2F6; }
.crm-status-badge--active   { background: #E8F5EE; color: #1E7A4C; border-color: #CBE9D8; }
.crm-status-badge--paused   { background: #FDF3E3; color: #9A5B0B; border-color: #F6E1BC; }
.crm-status-badge--churned  { background: #FBECEC; color: #A93636; border-color: #F3D2D2; }

/* Logo tile */
.crm-logo {
  display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0;
  width: 44px; height: 44px; overflow: hidden;
  background: var(--crm-surface); border: 1px solid var(--crm-line); border-radius: var(--crm-radius);
}
.crm-logo img { width: 100%; height: 100%; object-fit: contain; }
.crm-logo--initial {
  background: var(--crm-primary-tint); color: var(--crm-primary); border-color: #DDD7F1;
  font-family: var(--crm-ff-head); font-size: 18px; font-weight: 800;
}
.crm-logo--lg { width: 72px; height: 72px; }
.crm-logo--lg.crm-logo--initial { font-size: 28px; }

/* Card grid */
.crm-card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; list-style: none; }
.crm-client-card {
  display: flex; flex-direction: column; gap: 14px; height: 100%;
  padding: 18px; color: var(--crm-text);
  background: var(--crm-surface); border: 1px solid var(--crm-line); border-radius: var(--crm-radius);
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}
.crm-client-card:hover {
  transform: translateY(-2px);
  border-color: var(--crm-primary-light);
  box-shadow: 0 8px 20px rgba(94, 78, 153, 0.12), inset 3px 0 0 var(--crm-primary);
}
.crm-client-card:focus-visible { outline: 2px solid var(--crm-primary); outline-offset: 2px; }
.crm-client-card-top { display: flex; gap: 12px; align-items: flex-start; }
.crm-client-card-title { min-width: 0; flex: 1; }
.crm-client-card-name {
  font-family: var(--crm-ff-head); font-size: 15px; font-weight: 800; line-height: 1.3;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.crm-client-card-badges { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.crm-client-stats {
  display: grid; grid-template-columns: 1fr 1fr 1.6fr;
  border-top: 1px solid var(--crm-line); border-bottom: 1px solid var(--crm-line);
}
.crm-client-stats > div { padding: 10px 0; }
.crm-client-stats > div + div { padding-left: 12px; border-left: 1px solid var(--crm-line); }
.crm-client-stats dt { font-size: 11px; font-weight: 600; color: var(--crm-muted); text-transform: uppercase; letter-spacing: 0.4px; }
.crm-client-stats dd { font-family: var(--crm-ff-mono); font-size: 15px; font-weight: 600; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.crm-client-card-foot { display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; font-size: 12px; color: var(--crm-muted); margin-top: auto; }

/* Client detail hero (dark) */
.crm-client-hero {
  display: flex; flex-direction: column; gap: 20px;
  padding: 24px; color: #fff;
  background: var(--crm-surface-dark); border-radius: var(--crm-radius);
}
.crm-client-hero-top { display: flex; align-items: center; gap: 16px; }
.crm-client-hero .crm-logo { border-color: transparent; }
.crm-client-hero-name { font-family: var(--crm-ff-head); font-size: 24px; font-weight: 800; line-height: 1.2; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.crm-client-hero-meta { font-size: 13px; color: #B9B7C9; margin-top: 4px; }
.crm-hero-stats { display: grid; grid-template-columns: repeat(4, 1fr); border-top: 1px solid rgba(255,255,255,0.12); border-bottom: 1px solid rgba(255,255,255,0.12); }
.crm-hero-stats > div { padding: 14px 0; }
.crm-hero-stats > div + div { padding-left: 20px; border-left: 1px solid rgba(255,255,255,0.12); }
.crm-hero-stats dt { font-size: 11px; font-weight: 600; letter-spacing: 0.6px; text-transform: uppercase; color: #B9B7C9; }
.crm-hero-stats dd { font-family: var(--crm-ff-mono); font-size: 22px; font-weight: 600; margin-top: 4px; white-space: nowrap; }
.crm-hero-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.crm-btn--on-dark { background: transparent; color: #fff; border-color: rgba(255,255,255,0.28); }
.crm-btn--on-dark:hover { background: rgba(255,255,255,0.08); border-color: rgba(255,255,255,0.5); }
.crm-btn--on-dark:disabled { opacity: 0.45; }
.crm-btn--on-dark-solid { background: #fff; color: var(--crm-surface-dark); margin-left: auto; }
.crm-btn--on-dark-solid:hover { background: var(--crm-primary-tint); }

.crm-tab-count { font-family: var(--crm-ff-mono); font-size: 11px; color: var(--crm-muted); margin-left: 2px; }
.crm-tabpanel-toolbar { display: flex; justify-content: flex-end; margin-bottom: 12px; }
.crm-tabpanel-footer--split { display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; }

/* Simple linked list (client → contacts) */
.crm-list { list-style: none; background: var(--crm-surface); border: 1px solid var(--crm-line); border-radius: var(--crm-radius); }
.crm-list > li + li { border-top: 1px solid var(--crm-line); }
.crm-list-item { display: flex; align-items: center; gap: 12px; padding: 12px 16px; color: var(--crm-text); }
.crm-list-item:hover { background: #FAFAFD; }
.crm-list-item:hover .crm-list-title { color: var(--crm-primary); }
.crm-list-main { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.crm-list-title { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-weight: 600; font-size: 14px; }
.crm-list-sub { font-size: 12px; color: var(--crm-muted); }
.crm-list-aside { font-size: 12px; color: var(--crm-muted); text-align: right; }

/* Client form */
.crm-fieldset { border: none; padding: 0; margin: 0; min-width: 0; }
.crm-fieldset legend { margin-bottom: 8px; padding: 0; }
.crm-check-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 16px; }
.crm-logo-upload { display: flex; align-items: center; gap: 16px; }
.crm-logo-upload-actions { display: flex; flex-direction: column; gap: 6px; }
.crm-logo-upload-buttons { display: flex; gap: 8px; }
.crm-file-input:focus-visible + label { outline: 2px solid var(--crm-primary-light); outline-offset: 2px; }

@media (max-width: 1100px) {
  .crm-hero-stats { grid-template-columns: repeat(2, 1fr); }
  .crm-hero-stats > div:nth-child(3) { padding-left: 0; border-left: none; }
  .crm-hero-stats > div:nth-child(n+3) { border-top: 1px solid rgba(255,255,255,0.12); }
}

@media (max-width: 768px) {
  .crm-section-header--wrap { align-items: stretch; }
  .crm-pills { overflow-x: auto; flex-wrap: nowrap; width: 100%; }
  .crm-pill { flex: 1 0 auto; justify-content: center; }
  .crm-filters--clients { grid-template-columns: 1fr; }
  .crm-card-grid { grid-template-columns: 1fr; }
  .crm-client-hero { padding: 18px; }
  .crm-client-hero-name { font-size: 20px; }
  .crm-hero-stats dd { font-size: 18px; }
  .crm-hero-actions .crm-btn { flex: 1 1 calc(50% - 4px); }
  .crm-btn--on-dark-solid { margin-left: 0; }
  .crm-list-item { flex-wrap: wrap; }
  .crm-list-aside { width: 100%; text-align: left; padding-left: 44px; }
  .crm-tabpanel-toolbar .crm-btn { width: 100%; }
}

/* ── Pipeline (Phase 4) ── */

/* Stage badges aligned to the pipeline colours (text darkened for contrast) */
.crm-stage-badge--new           { background: #F3F4F6; color: #4B5563; border-color: #E5E7EB; }
.crm-stage-badge--contacted     { background: #EFF6FF; color: #1D4ED8; border-color: #DBEAFE; }
.crm-stage-badge--qualified     { background: #ECFEFF; color: #0E7490; border-color: #CFFAFE; }
.crm-stage-badge--proposal_sent { background: #FFFBEB; color: #B45309; border-color: #FDE68A; }
.crm-stage-badge--negotiation   { background: #FFF7ED; color: #C2410C; border-color: #FED7AA; }
.crm-stage-badge--won           { background: #F0FDF4; color: #15803D; border-color: #BBF7D0; }
.crm-stage-badge--lost          { background: #FEF2F2; color: #B91C1C; border-color: #FECACA; }

.crm-btn--success { background: var(--crm-success); color: #fff; }
.crm-btn--success:hover { background: #15803D; }
.crm-avatar--xs { width: 24px; height: 24px; font-size: 11px; }
.crm-overdue-badge {
  display: inline-block; padding: 1px 6px; font-size: 11px; font-weight: 600;
  color: #B91C1C; background: #FEF2F2; border: 1px solid #FECACA; border-radius: var(--crm-radius);
}

/* Summary bar */
.crm-summary {
  display: grid; grid-template-columns: repeat(5, minmax(0, 1fr));
  background: var(--crm-surface); border: 1px solid var(--crm-line); border-radius: var(--crm-radius);
}
.crm-summary > div { padding: 14px 18px; min-width: 0; }
.crm-summary > div + div { border-left: 1px solid var(--crm-line); }
.crm-summary dt { font-size: 11px; font-weight: 600; letter-spacing: 0.5px; text-transform: uppercase; color: var(--crm-muted); }
.crm-summary dd { font-family: var(--crm-ff-mono); font-size: 20px; font-weight: 600; color: var(--crm-text); margin-top: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.crm-summary-hint { text-transform: none; letter-spacing: 0; font-weight: 500; }
.crm-summary-sub { display: block; font-family: var(--crm-ff-body); font-size: 11px; font-weight: 500; color: var(--crm-muted); margin-top: 2px; }

.crm-empty-hint {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  padding: 12px 16px; font-size: 13px;
  background: var(--crm-primary-tint); border: 1px solid #DDD7F1; border-radius: var(--crm-radius);
}

/* Board */
.crm-board {
  display: flex; gap: 12px; align-items: stretch;
  overflow-x: auto; padding-bottom: 8px;
  scroll-snap-type: x proximity;
}
.crm-column {
  flex: 1 0 300px; min-width: 300px; max-width: 360px;
  display: flex; flex-direction: column;
  padding: 0;                       /* override global `section { padding: 100px 0 }` */
  background: #F1F0F6; border: 1px solid var(--crm-line); border-top: 3px solid var(--stage-color);
  border-radius: var(--crm-radius);
  scroll-snap-align: start;
  transition: background-color 0.15s, outline-color 0.15s;
}
.crm-column-header {
  display: flex; align-items: baseline; justify-content: space-between; gap: 8px;
  padding: 10px 12px; border-bottom: 1px solid var(--crm-line);
}
.crm-column-title { font-family: var(--crm-ff-head); font-size: 13px; font-weight: 800; color: var(--crm-text); display: flex; align-items: center; gap: 6px; }
.crm-column-count {
  font-family: var(--crm-ff-mono); font-size: 11px; font-weight: 600; color: #fff;
  background: var(--stage-color); padding: 0 6px; border-radius: 2px; line-height: 18px;
}
.crm-column-total { font-family: var(--crm-ff-mono); font-size: 12px; color: var(--crm-muted); white-space: nowrap; }
.crm-column-list {
  display: flex; flex-direction: column; gap: 8px;
  padding: 10px; min-height: 120px;
  max-height: calc(100vh - 360px); overflow-y: auto;
}
.crm-column-empty { padding: 24px 0; text-align: center; font-size: 12px; color: var(--crm-muted); }
.crm-column.is-drop-target {
  background: var(--crm-primary-tint);
  outline: 2px dashed var(--crm-primary); outline-offset: -2px;
}
.crm-board.is-dragging .crm-column:not(.is-drop-target) .crm-column-list { opacity: 0.85; }
.crm-board-tip { font-size: 12px; color: var(--crm-muted); }

/* Deal card */
.crm-deal-card {
  display: flex; flex-direction: column; gap: 6px;
  padding: 12px; cursor: grab; user-select: none;
  background: var(--crm-surface); border: 1px solid var(--crm-line); border-radius: var(--crm-radius);
  box-shadow: 0 1px 2px rgba(42, 42, 55, 0.06);
  transition: box-shadow 0.15s, transform 0.15s, border-color 0.15s, opacity 0.15s;
}
.crm-deal-card:hover { border-color: #D3D0E3; box-shadow: 0 4px 12px rgba(42, 42, 55, 0.08); }
.crm-deal-card:focus-visible { outline: 2px solid var(--crm-primary); outline-offset: 2px; }
.crm-deal-card:active { cursor: grabbing; }
.crm-deal-card.is-dragging {
  transform: scale(1.03); opacity: 0.6;
  border-color: var(--crm-primary-light);
  box-shadow: 0 0 0 3px rgba(139, 125, 217, 0.35), 0 10px 24px rgba(94, 78, 153, 0.25);
}
.crm-deal-card.is-overdue { border-left: 3px solid var(--crm-danger); }
.crm-deal-card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.crm-deal-title { font-weight: 700; font-size: 14px; line-height: 1.35; color: var(--crm-text); overflow-wrap: anywhere; }
.crm-deal-client { font-size: 12px; color: var(--crm-muted); }
.crm-deal-meta { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; font-size: 12px; }
.crm-deal-close { color: var(--crm-muted); }
.crm-deal-close.is-overdue { color: var(--crm-danger); font-weight: 600; }
.crm-deal-value { font-family: var(--crm-ff-mono); font-weight: 600; font-size: 13px; color: var(--crm-text); white-space: nowrap; margin-left: auto; }
.crm-deal-foot { display: flex; gap: 6px; align-items: center; }
.crm-days-badge {
  font-family: var(--crm-ff-mono); font-size: 11px; color: var(--crm-muted);
  background: var(--crm-bg); border: 1px solid var(--crm-line); border-radius: 2px; padding: 0 6px; line-height: 18px;
}

/* Range input (probability) */
.crm-range { width: 100%; accent-color: var(--crm-primary); }
.crm-range-value { font-family: var(--crm-ff-mono); font-weight: 600; color: var(--crm-primary); margin-left: 6px; }

/* Deal drawer — sits under the add/edit panels so "Edit all details" opens on top */
.crm-drawer { width: 500px; z-index: 1091; }
#dealDrawerBackdrop { z-index: 1090; }
.crm-drawer-header { padding: 16px 20px; border-bottom: 1px solid var(--crm-line); display: flex; flex-direction: column; gap: 10px; transition: box-shadow 0.3s; }
.crm-drawer-title-row { display: flex; align-items: center; gap: 8px; }
.crm-inline-title {
  flex: 1; min-width: 0; padding: 4px 6px; margin-left: -6px;
  font-family: var(--crm-ff-head); font-size: 20px; font-weight: 800; color: var(--crm-text);
  background: transparent; border: 1px solid transparent; border-radius: var(--crm-radius); outline: none;
}
.crm-inline-title:hover { border-color: var(--crm-line); }
.crm-inline-title:focus { border-color: var(--crm-primary); background: #fff; box-shadow: 0 0 0 3px rgba(94, 78, 153, 0.15); }
.crm-drawer-sub { font-size: 13px; color: var(--crm-muted); display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.crm-drawer-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 12px; }
.crm-drawer-status { min-height: 16px; font-size: 12px; color: var(--crm-success); }
.crm-drawer-body { flex: 1; overflow-y: auto; padding: 0 20px 20px; }
.crm-drawer-body .crm-tabs { position: sticky; top: 0; background: var(--crm-surface); z-index: 1; margin-bottom: 12px; }
.crm-dl--single { grid-template-columns: 1fr; }
.crm-textarea--tall { min-height: 280px; margin-top: 6px; }
.crm-drawer.is-won .crm-drawer-header { box-shadow: inset 4px 0 0 var(--crm-success); }
.crm-drawer.is-lost .crm-drawer-header { box-shadow: inset 4px 0 0 var(--crm-danger); }
.crm-drawer.is-celebrating .crm-drawer-header { animation: crmWonPulse 1.4s ease; }
@keyframes crmWonPulse {
  0%   { background: var(--crm-surface); }
  25%  { background: #DCFCE7; }
  100% { background: var(--crm-surface); }
}

/* Confetti (Mark as Won) */
.crm-confetti { position: absolute; inset: 0; overflow: hidden; pointer-events: none; z-index: 5; }
.crm-confetti i {
  position: absolute; top: -12px; width: 8px; height: 12px; border-radius: 1px; opacity: 0;
  animation: crmConfetti 1.6s cubic-bezier(0.2, 0.6, 0.4, 1) forwards;
}
@keyframes crmConfetti {
  0%   { opacity: 1; transform: translate(0, 0) rotate(0); }
  100% { opacity: 0; transform: translate(var(--drift), 70vh) rotate(var(--spin)); }
}

/* Timeline (deal activities) */
.crm-timeline { list-style: none; border-left: 2px solid var(--crm-line); margin-left: 6px; }
.crm-timeline-item { position: relative; padding: 0 0 16px 16px; display: flex; flex-direction: column; gap: 2px; }
.crm-timeline-item::before {
  content: ''; position: absolute; left: -6px; top: 4px; width: 10px; height: 10px;
  background: var(--crm-primary); border: 2px solid var(--crm-surface); border-radius: 2px;
}
.crm-timeline-subject { font-size: 14px; font-weight: 600; }
.crm-timeline-desc { font-size: 13px; color: var(--crm-text); }
.crm-timeline-meta { font-size: 12px; color: var(--crm-muted); }

/* Clickable list rows (deals on client / contact pages) */
.crm-list-item--button { width: 100%; text-align: left; font: inherit; }
.crm-dialog-field { margin-top: 14px; }

@media (max-width: 1100px) {
  .crm-summary { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .crm-summary > div:nth-child(4) { border-left: none; }
  .crm-summary > div:nth-child(n+4) { border-top: 1px solid var(--crm-line); }
}

@media (max-width: 768px) {
  .crm-summary { grid-template-columns: 1fr 1fr; }
  .crm-summary > div { border-left: none !important; border-top: 1px solid var(--crm-line); }
  .crm-summary > div:nth-child(-n+2) { border-top: none; }
  .crm-summary > div:nth-child(even) { border-left: 1px solid var(--crm-line) !important; }
  .crm-summary dd { font-size: 17px; }
  .crm-board { scroll-snap-type: x mandatory; }
  .crm-column { flex-basis: 85%; min-width: 260px; }
  .crm-column-list { max-height: none; }
  .crm-drawer { width: 100vw; }
  .crm-drawer-fields { grid-template-columns: 1fr; }
}

/* ── Activities & Tasks (Phase 5) ── */
/* The public site styles every <section> with 100px padding; CRM sections never want it */
#crm section { padding: 0; }
.crm-bell [hidden] { display: none !important; }

.crm-link-btn {
  padding: 0; font: inherit; font-size: 12px; font-weight: 600; color: var(--crm-primary);
  background: none; border: none; cursor: pointer;
}
.crm-link-btn:hover { text-decoration: underline; }
.crm-link-btn:focus-visible { outline: 2px solid var(--crm-primary-light); outline-offset: 2px; }
.crm-link-btn--danger { color: var(--crm-danger); }
.crm-show-more { align-self: center; }
.crm-timeline-empty { padding: 20px 0; font-size: 13px; color: var(--crm-muted); }
.crm-tab-hint { margin: -4px 0 12px; }
.crm-field--inline { flex-direction: row; align-items: center; gap: 8px; }
.crm-field--inline .crm-select { width: auto; min-width: 160px; }

/* Related chips */
.crm-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.crm-chip {
  display: inline-flex; align-items: center; gap: 4px; max-width: 100%;
  padding: 2px 8px; font: inherit; font-size: 12px; font-weight: 500; color: var(--crm-text);
  background: var(--crm-bg); border: 1px solid var(--crm-line); border-radius: var(--crm-radius);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: pointer;
}
.crm-chip:hover { border-color: var(--crm-primary-light); color: var(--crm-primary); }
.crm-chip:focus-visible { outline: 2px solid var(--crm-primary-light); outline-offset: 1px; }
.crm-chip--missing { color: var(--crm-muted); font-style: italic; cursor: default; }

/* Segmented radios (Related to) */
.crm-segmented { display: inline-flex; border: 1px solid #DCDCE3; border-radius: var(--crm-radius); overflow: hidden; margin-bottom: 8px; }
.crm-segmented label { position: relative; cursor: pointer; }
.crm-segmented input { position: absolute; opacity: 0; pointer-events: none; }
.crm-segmented span { display: block; padding: 6px 12px; font-size: 12px; font-weight: 600; color: var(--crm-muted); border-right: 1px solid #DCDCE3; }
.crm-segmented label:last-child span { border-right: none; }
.crm-segmented input:checked + span { background: var(--crm-primary); color: #fff; }
.crm-segmented input:focus-visible + span { outline: 2px solid var(--crm-primary-light); outline-offset: -2px; }

/* Activity timeline */
.crm-filters--activities { grid-template-columns: repeat(4, minmax(140px, 1fr)) auto; }
.crm-activity-group + .crm-activity-group { margin-top: 20px; }
.crm-activity-group-title {
  font-family: var(--crm-ff-head); font-size: 12px; font-weight: 800; letter-spacing: 0.6px;
  text-transform: uppercase; color: var(--crm-text); margin-bottom: 10px;
}
.crm-activity-list { list-style: none; position: relative; }
.crm-activity-list::before { content: ''; position: absolute; left: 17px; top: 8px; bottom: 8px; width: 1px; background: var(--crm-line); }
.crm-activity { position: relative; display: flex; gap: 12px; padding-bottom: 14px; }
.crm-activity-icon {
  flex-shrink: 0; width: 36px; height: 36px; z-index: 1;
  display: flex; align-items: center; justify-content: center; font-size: 17px;
  background: var(--crm-surface); border: 1px solid var(--crm-line); border-radius: var(--crm-radius);
}
.crm-activity--status_change .crm-activity-icon { background: var(--crm-bg); font-size: 14px; }
.crm-activity-body {
  flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px;
  padding: 10px 14px; background: var(--crm-surface); border: 1px solid var(--crm-line); border-radius: var(--crm-radius);
}
.crm-activity--status_change .crm-activity-body { background: transparent; border-style: dashed; }
.crm-activity-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.crm-activity-type { font-size: 11px; font-weight: 700; letter-spacing: 0.5px; text-transform: uppercase; color: var(--crm-muted); }
.crm-activity-subject { font-size: 14px; font-weight: 700; color: var(--crm-text); overflow-wrap: anywhere; }
.crm-activity-desc { font-size: 13px; color: var(--crm-text); white-space: pre-wrap; overflow-wrap: anywhere; }
.crm-activity-desc.is-clamped { display: -webkit-box; -webkit-line-clamp: 2; line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.crm-activity-body > .crm-link-btn { align-self: flex-start; }
.crm-activity-meta { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--crm-muted); }

.crm-outcome-badge { padding: 1px 7px; font-size: 11px; font-weight: 600; border: 1px solid transparent; border-radius: var(--crm-radius); }
.crm-outcome-badge--positive  { background: #F0FDF4; color: #15803D; border-color: #BBF7D0; }
.crm-outcome-badge--neutral   { background: #F3F4F6; color: #4B5563; border-color: #E5E7EB; }
.crm-outcome-badge--negative  { background: #FEF2F2; color: #B91C1C; border-color: #FECACA; }
.crm-outcome-badge--no_answer { background: #FFFBEB; color: #B45309; border-color: #FDE68A; }
.crm-outcome-badge--scheduled { background: #EFF6FF; color: #1D4ED8; border-color: #DBEAFE; }
.crm-outcome-badge--completed { background: var(--crm-primary-tint); color: var(--crm-primary); border-color: #DDD7F1; }

/* Tasks */
.crm-task-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.crm-switch { display: inline-flex; align-items: center; gap: 10px; font-size: 13px; cursor: pointer; position: relative; }
.crm-switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.crm-switch-track { width: 34px; height: 18px; background: #D4D3DD; border-radius: 2px; position: relative; transition: background 0.15s; flex-shrink: 0; }
.crm-switch-track::after { content: ''; position: absolute; top: 2px; left: 2px; width: 14px; height: 14px; background: #fff; border-radius: 1px; transition: transform 0.15s; }
.crm-switch input:checked + .crm-switch-track { background: var(--crm-primary); }
.crm-switch input:checked + .crm-switch-track::after { transform: translateX(16px); }
.crm-switch input:focus-visible + .crm-switch-track { outline: 2px solid var(--crm-primary-light); outline-offset: 2px; }

.crm-task-sections { display: flex; flex-direction: column; gap: 18px; }
.crm-task-section { --section-color: #6B7280; }
.crm-task-section--overdue { --section-color: var(--crm-danger); }
.crm-task-section--today { --section-color: var(--crm-primary); }
.crm-task-section--upcoming, .crm-task-section--later { --section-color: #6B7280; }
.crm-task-section--completed { --section-color: var(--crm-success); }
.crm-task-section-title {
  display: flex; align-items: center; gap: 8px; margin-bottom: 8px; padding-left: 10px;
  border-left: 3px solid var(--section-color);
  font-family: var(--crm-ff-head); font-size: 14px; font-weight: 800; color: var(--section-color);
}
details.crm-task-section > summary { cursor: pointer; list-style: none; }
details.crm-task-section > summary::-webkit-details-marker { display: none; }
details.crm-task-section > summary::after { content: '▸'; font-size: 11px; color: var(--crm-muted); }
details.crm-task-section[open] > summary::after { content: '▾'; }
.crm-task-section-count {
  font-family: var(--crm-ff-mono); font-size: 11px; font-weight: 600; color: #fff;
  background: var(--section-color); padding: 0 6px; line-height: 18px; border-radius: 2px;
}
.crm-task-none { font-size: 13px; color: var(--crm-muted); padding: 4px 13px; }

.crm-task-list { list-style: none; background: var(--crm-surface); border: 1px solid var(--crm-line); border-radius: var(--crm-radius); }
.crm-task-list:empty { display: none; }
.crm-task {
  display: grid; grid-template-columns: auto auto minmax(0, 1fr) auto auto; align-items: start; gap: 10px;
  padding: 12px 14px; transition: background-color 0.3s;
}
.crm-task + .crm-task { border-top: 1px solid var(--crm-line); }
.crm-task.is-overdue { box-shadow: inset 3px 0 0 var(--crm-danger); }
.crm-task.is-highlighted { background: var(--crm-primary-tint); }
.crm-task-check { width: 18px; height: 18px; margin-top: 2px; accent-color: var(--crm-primary); cursor: pointer; }
.crm-priority-dot { width: 10px; height: 10px; margin-top: 6px; border-radius: 50%; display: inline-block; flex-shrink: 0; }
.crm-priority-dot--urgent { background: #DC2626; }
.crm-priority-dot--high   { background: #D97706; }
.crm-priority-dot--medium { background: #3B82F6; }
.crm-priority-dot--low    { background: #9CA3AF; }
.crm-task-main { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.crm-task-title { font-size: 14px; font-weight: 600; color: var(--crm-text); overflow-wrap: anywhere; }
.crm-task.is-done .crm-task-title { text-decoration: line-through; color: var(--crm-muted); }
.crm-task-meta { font-size: 12px; }
.crm-task-due { color: var(--crm-text); font-weight: 500; }
.crm-task-due.is-overdue { color: var(--crm-danger); font-weight: 600; }
.crm-task-desc { font-size: 12px; color: var(--crm-muted); overflow-wrap: anywhere; }
.crm-task-assignee { margin-top: 1px; }
.crm-task-actions { display: flex; gap: 10px; padding-top: 3px; white-space: nowrap; }

.crm-quick-dates { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 14px; }

/* Notification bell */
.crm-bell { position: relative; display: inline-flex; }
.crm-bell-btn { position: relative; display: inline-flex; padding: 0; color: inherit; background: none; border: none; cursor: pointer; }
.crm-bell-btn:focus-visible { outline: 2px solid var(--crm-primary-light); outline-offset: 3px; border-radius: 2px; }
.crm-bell-dot {
  position: absolute; top: -1px; right: -1px; width: 9px; height: 9px;
  background: var(--crm-danger); border: 2px solid #fff; border-radius: 50%;
}
.crm-bell-menu {
  position: absolute; top: calc(100% + 10px); right: -8px; z-index: 1050;
  width: 320px; max-width: calc(100vw - 32px); padding: 8px 0;
  background: var(--crm-surface); border: 1px solid var(--crm-line); border-radius: var(--crm-radius);
  box-shadow: 0 12px 32px rgba(42, 42, 55, 0.16); font-family: var(--crm-ff-body);
}
.crm-bell-heading { padding: 6px 14px 8px; font-size: 11px; font-weight: 700; letter-spacing: 0.6px; text-transform: uppercase; color: var(--crm-muted); }
.crm-bell-list { list-style: none; max-height: 320px; overflow-y: auto; }
.crm-bell-item { display: flex; gap: 10px; padding: 8px 14px; color: var(--crm-text); }
.crm-bell-item:hover, .crm-bell-item:focus-visible { background: var(--crm-bg); outline: none; }
.crm-bell-item .crm-priority-dot { margin-top: 5px; }
.crm-bell-item-main { display: flex; flex-direction: column; min-width: 0; }
.crm-bell-item-title { font-size: 13px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.crm-bell-item-due { font-size: 12px; color: var(--crm-muted); }
.crm-bell-item-due.is-overdue { color: var(--crm-danger); font-weight: 600; }
.crm-bell-more { padding: 4px 14px; font-size: 12px; color: var(--crm-muted); }
.crm-bell-empty { padding: 8px 14px 12px; font-size: 13px; color: var(--crm-muted); }
.crm-bell-all { display: block; padding: 10px 14px 4px; margin-top: 4px; border-top: 1px solid var(--crm-line); font-size: 13px; font-weight: 600; color: var(--crm-primary); }

@media (max-width: 1100px) {
  .crm-filters--activities { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 768px) {
  .crm-filters--activities { grid-template-columns: 1fr 1fr; }
  .crm-filters--activities .crm-filters-clear { grid-column: 1 / -1; }
  .crm-activity-list::before { left: 15px; }
  .crm-activity-icon { width: 32px; height: 32px; font-size: 15px; }
  .crm-task { grid-template-columns: auto auto minmax(0, 1fr) auto; }
  .crm-task-actions { grid-column: 3 / -1; padding-top: 0; }
  .crm-segmented { display: flex; }
  .crm-segmented label { flex: 1; text-align: center; }
  .crm-bell-menu { position: fixed; top: 72px; right: 16px; left: 16px; width: auto; max-width: none; }
}

/* ── Communications (Phase 6) ── */
:root {
  --crm-wa-green: #25D366;
  --crm-email-blue: #2563EB;
}
.crm-btn--whatsapp { background: var(--crm-wa-green); color: #0B3D20; }
.crm-btn--whatsapp:hover { background: #1EBE5A; }
.crm-btn--email { background: var(--crm-email-blue); color: #fff; }
.crm-btn--email:hover { background: #1D4ED8; }
.crm-field-warning {
  font-size: 12px; color: #92400E; background: #FFFBEB;
  border: 1px solid #FDE68A; border-radius: var(--crm-radius); padding: 6px 10px;
}
.crm-field-warning.is-error { color: #991B1B; background: #FEF2F2; border-color: #FECACA; }
.crm-outcome-badge--interested { background: #ECFEFF; color: #0E7490; border-color: #A5F3FC; }
.crm-direction { font-size: 11px; font-weight: 600; color: var(--crm-muted); }
.crm-direction--received { color: #0E7490; }
.crm-empty-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.crm-dialog--wide { width: min(520px, calc(100vw - 32px)); }

/* Legacy Settings page → templates link */
.crm-settings-link {
  display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap;
  margin-top: 40px; padding-top: 28px; border-top: 1px solid #EBECEC; font-family: var(--crm-ff-body);
}
.crm-settings-link h3 { font-family: var(--crm-ff-head); font-size: 16px; font-weight: 800; color: var(--crm-text); margin-bottom: 4px; }
.crm-settings-link p { font-size: 13px; color: var(--crm-muted); max-width: 520px; }

/* Message previews */
.crm-msg-preview {
  min-height: 120px; padding: 14px; overflow-wrap: anywhere;
  background: #EFEAE2; border: 1px solid var(--crm-line); border-radius: var(--crm-radius);
}
.crm-wa-bubble {
  max-width: 92%; padding: 8px 10px; font-size: 13px; line-height: 1.5; color: #111B21;
  background: #D9FDD3; border-radius: var(--crm-radius); box-shadow: 0 1px 1px rgba(0, 0, 0, 0.08);
}
.crm-email-preview { background: #fff; border: 1px solid var(--crm-line); border-radius: var(--crm-radius); font-size: 13px; }
.crm-email-preview-subject { padding: 8px 12px; border-bottom: 1px solid var(--crm-line); font-weight: 600; }
.crm-email-preview-body { padding: 10px 12px; line-height: 1.55; }
.crm-var-missing { background: #FEF3C7; color: #92400E; padding: 0 2px; border-radius: 2px; font-family: var(--crm-ff-mono); font-size: 0.92em; }

/* Variables */
.crm-var-buttons { display: flex; flex-wrap: wrap; gap: 4px; }
.crm-var-chip {
  display: inline-block; padding: 1px 6px; font-family: var(--crm-ff-mono); font-size: 11px;
  color: var(--crm-primary); background: var(--crm-primary-tint); border: 1px solid #DDD7F1; border-radius: 2px;
}
.crm-var-chip.is-unknown { color: #92400E; background: #FFFBEB; border-color: #FDE68A; }
.crm-var-chip--btn { cursor: pointer; }
.crm-var-chip--btn:hover { background: #E2DCF4; }
.crm-var-chip--btn:focus-visible { outline: 2px solid var(--crm-primary-light); outline-offset: 1px; }

/* Templates admin */
.crm-template-groups { display: flex; flex-direction: column; gap: 20px; }
.crm-template-group-title { font-family: var(--crm-ff-head); font-size: 14px; font-weight: 800; margin-bottom: 8px; }
.crm-template-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; padding: 12px 16px; }
.crm-template-row-main { display: flex; flex-direction: column; gap: 4px; min-width: 0; flex: 1; }
.crm-template-snippet {
  font-size: 13px; color: var(--crm-muted); white-space: pre-line;
  display: -webkit-box; -webkit-line-clamp: 2; line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}

/* Quick message */
.crm-quick-msg { display: flex; flex-direction: column; gap: 14px; }
.crm-quick-msg-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.crm-quick-msg-head .crm-field { flex: 1; min-width: 240px; max-width: 420px; }
.crm-quick-msg-manage { font-size: 13px; font-weight: 600; }
.crm-quick-msg-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; }
.crm-quick-msg-edit { display: flex; flex-direction: column; gap: 12px; }
.crm-quick-msg-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.crm-template-picker { position: relative; }
.crm-template-btn { text-align: left; }
.crm-template-pop {
  position: absolute; top: calc(100% + 4px); left: 0; z-index: 20;
  display: grid; grid-template-columns: 260px 300px;
  background: var(--crm-surface); border: 1px solid #DCDCE3; border-radius: var(--crm-radius);
  box-shadow: 0 12px 32px rgba(42, 42, 55, 0.16);
}
.crm-template-list { position: relative; /* offsetTop of options is measured from the list */ list-style: none; max-height: 320px; overflow-y: auto; padding: 4px 0; border-right: 1px solid var(--crm-line); outline: none; }
.crm-template-list:focus-visible { box-shadow: inset 0 0 0 2px var(--crm-primary-light); }
.crm-template-option { padding: 8px 12px; font-size: 13px; cursor: pointer; }
.crm-template-option[aria-selected="true"] { background: var(--crm-primary-tint); }
.crm-template-option.is-current { font-weight: 700; }
.crm-template-empty { padding: 8px 12px; font-size: 12px; color: var(--crm-muted); }
.crm-template-hover { padding: 12px; background: #F7F5F0; font-size: 13px; max-height: 320px; overflow-y: auto; }
.crm-template-hover-title { font-weight: 700; margin-bottom: 8px; }

/* Communications view */
.crm-filters--comms { grid-template-columns: repeat(5, minmax(120px, 1fr)) auto; }
.crm-comms-report { display: flex; flex-direction: column; gap: 12px; }
.crm-segmented--wide { flex-wrap: wrap; }
.crm-direction--outbound { color: #5E4E99; }
.crm-direction--inbound { color: #15803D; }
.crm-report-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.crm-report-head .crm-card-title { margin: 0; }
.crm-report-stats { display: flex; gap: 24px; }
.crm-report-stats dt { font-size: 11px; font-weight: 600; letter-spacing: 0.5px; text-transform: uppercase; color: var(--crm-muted); }
.crm-report-stats dd { font-family: var(--crm-ff-mono); font-size: 20px; font-weight: 600; }
.crm-report-list { list-style: none; border-top: 1px solid var(--crm-line); }
.crm-report-row { display: grid; grid-template-columns: auto minmax(0, 1fr) auto auto; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--crm-line); font-size: 13px; }
.crm-report-name { font-weight: 600; }
.crm-report-breakdown { color: var(--crm-muted); font-size: 12px; }
.crm-report-total { font-family: var(--crm-ff-mono); font-weight: 600; min-width: 28px; text-align: right; }

@media (max-width: 1100px) {
  .crm-filters--comms { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .crm-quick-msg-grid { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
  .crm-filters--comms { grid-template-columns: 1fr 1fr; }
  .crm-filters--comms .crm-filters-clear { grid-column: 1 / -1; }
  .crm-template-pop { position: static; grid-template-columns: 1fr; margin-top: 4px; }
  .crm-template-list { border-right: none; border-bottom: 1px solid var(--crm-line); }
  .crm-quick-msg-actions .crm-btn { flex: 1; }
  .crm-report-row { grid-template-columns: auto minmax(0, 1fr) auto; }
  .crm-report-breakdown { grid-column: 2 / -1; grid-row: 2; }
  .crm-template-row { flex-direction: column; gap: 8px; }
}

/* ── Dashboard (Phase 7) ── */
.crm-filter-banner {
  padding: 8px 12px; font-size: 13px;
  background: var(--crm-primary-tint); border: 1px solid #DDD7F1; border-radius: var(--crm-radius);
}
.crm-swatch { display: inline-block; width: 8px; height: 8px; border-radius: 2px; background: var(--swatch); flex-shrink: 0; }
.crm-scroll-x { overflow-x: auto; }

.crm-dash-header { align-items: flex-end; }
.crm-dash-range-label { font-size: 12px; color: var(--crm-muted); margin-top: 4px; }
.crm-dash-controls { align-items: flex-end; }
.crm-dash-custom { display: flex; align-items: center; gap: 6px; }
.crm-dash-custom .crm-input { width: 150px; }

/* KPI tiles */
.crm-kpis { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px; }
.crm-kpi {
  display: flex; flex-direction: column; gap: 4px; min-width: 0;
  padding: 16px; background: var(--crm-surface); border: 1px solid var(--crm-line); border-radius: var(--crm-radius);
}
.crm-kpi-label { font-size: 12px; font-weight: 600; color: var(--crm-muted); }
.crm-kpi-value { font-family: var(--crm-ff-mono); font-size: 30px; font-weight: 600; line-height: 1.1; color: var(--crm-text); letter-spacing: -0.5px; }
.crm-kpi-sub { font-size: 12px; color: var(--crm-text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.crm-kpi-delta { font-size: 12px; font-weight: 600; }
.crm-kpi-delta.is-good { color: #15803D; }
.crm-kpi-delta.is-bad { color: #B91C1C; }
.crm-kpi-delta.is-neutral { color: var(--crm-muted); }
.crm-kpi-delta .crm-muted { font-weight: 400; }
.crm-kpi-spark { margin-top: auto; padding-top: 6px; }
.crm-sparkline { display: block; width: 100%; max-width: 160px; height: 36px; overflow: visible; }
.crm-spark-base { stroke: var(--crm-line); stroke-width: 1; }
.crm-spark-line { fill: none; stroke: var(--crm-primary-light); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.crm-spark-dot { fill: var(--crm-primary); stroke: #fff; stroke-width: 1.5; }
.crm-spark-hit { fill: transparent; }
.crm-spark-hit:hover { fill: rgba(94, 78, 153, 0.08); }

/* Cards grid */
.crm-dash-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.crm-dash-card { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.crm-dash-card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.crm-dash-card-head .crm-card-title { margin: 0; }
.crm-dash-card-sub { font-size: 12px; color: var(--crm-muted); }
.crm-dash-more { font-size: 13px; font-weight: 600; }
.crm-dash-list { list-style: none; }
.crm-dash-list > li + li { border-top: 1px solid var(--crm-line); }
.crm-dash-row {
  display: flex; justify-content: space-between; gap: 12px; width: 100%; padding: 9px 4px;
  font: inherit; text-align: left; color: var(--crm-text); background: none; border: none; cursor: pointer;
}
.crm-dash-row:hover { background: var(--crm-bg); }
.crm-dash-row:focus-visible { outline: 2px solid var(--crm-primary-light); outline-offset: -2px; }
.crm-dash-row-main, .crm-dash-row-aside { display: flex; flex-direction: column; min-width: 0; }
.crm-dash-row-aside { align-items: flex-end; text-align: right; white-space: nowrap; }
.crm-dash-row-title { font-size: 14px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.crm-dash-row-sub { font-size: 12px; color: var(--crm-muted); }
.crm-dash-overdue { font-size: 13px; margin-top: 8px; }

/* Funnel */
.crm-funnel { list-style: none; display: flex; flex-direction: column; gap: 6px; }
.crm-funnel-row {
  display: grid; grid-template-columns: 120px minmax(0, 1fr) 110px; align-items: center; gap: 10px;
  padding: 4px; color: var(--crm-text); border-radius: var(--crm-radius);
}
.crm-funnel-row:hover { background: var(--crm-bg); }
.crm-funnel-row:focus-visible { outline: 2px solid var(--crm-primary-light); }
.crm-funnel-label { display: flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 600; white-space: nowrap; }
.crm-funnel-track { display: flex; justify-content: center; height: 22px; background: var(--crm-bg); border-radius: 2px; }
.crm-funnel-bar { display: block; height: 100%; background: var(--crm-primary-light); border-radius: 2px; }
.crm-funnel-row:hover .crm-funnel-bar { background: var(--crm-primary); }
.crm-funnel-nums { font-size: 13px; text-align: right; white-space: nowrap; }
.crm-funnel-nums b { font-family: var(--crm-ff-mono); font-weight: 600; }
.crm-funnel-lost { font-size: 13px; margin-top: 4px; }

/* Heatmap */
.crm-heatmap { display: block; }
.crm-heat-label { font-size: 10px; fill: var(--crm-muted); font-family: var(--crm-ff-body); }
.crm-heatmap rect:hover { stroke: var(--crm-text); stroke-width: 1; }
.crm-heat-legend { display: flex; align-items: center; gap: 3px; margin-top: 8px; font-size: 11px; color: var(--crm-muted); }
.crm-heat-legend i { width: 12px; height: 12px; border-radius: 2px; }
.crm-heat-legend i:first-of-type { margin-left: 4px; }
.crm-heat-legend i:last-of-type { margin-right: 4px; }
.crm-heat-table { margin-top: 8px; font-size: 12px; }
.crm-heat-table summary { cursor: pointer; color: var(--crm-primary); font-weight: 600; }
.crm-heat-table .crm-table { margin-top: 6px; }

/* Leaderboard */
.crm-leader-row { display: grid; grid-template-columns: 22px auto minmax(0, 1fr) auto auto; align-items: center; gap: 10px; padding: 8px 0; }
.crm-leader-rank { font-family: var(--crm-ff-mono); font-size: 13px; font-weight: 600; color: var(--crm-muted); text-align: center; }
.crm-leader-main { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.crm-leader-name { font-size: 14px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.crm-leader-bar { display: block; height: 4px; background: var(--crm-bg); border-radius: 2px; }
.crm-leader-bar span { display: block; height: 100%; background: var(--crm-primary-light); border-radius: 2px; }
.crm-leader-count { font-size: 13px; white-space: nowrap; }
.crm-leader-count b { font-family: var(--crm-ff-mono); }
.crm-leader-tags { display: flex; align-items: center; gap: 6px; }
.crm-leader-rate { font-family: var(--crm-ff-mono); font-size: 12px; color: #5E4E99; background: #F5F4FA; border: 1px solid #DDD8F0; padding: 1px 6px; border-radius: 2px; white-space: nowrap; }
.crm-leader-won { font-size: 12px; font-weight: 600; color: #15803D; background: #F0FDF4; border: 1px solid #BBF7D0; padding: 1px 6px; border-radius: 2px; white-space: nowrap; }

/* Compact task list + recent activities */
.crm-task-list--compact .crm-task { padding: 10px 8px; }
.crm-recent-row { display: flex; gap: 10px; padding: 8px 0; }
.crm-recent-icon { width: 28px; height: 28px; flex-shrink: 0; display: flex; align-items: center; justify-content: center; font-size: 14px; background: var(--crm-bg); border-radius: var(--crm-radius); }
.crm-recent-main { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.crm-recent-subject { font-size: 13px; font-weight: 600; overflow-wrap: anywhere; }
.crm-recent-meta { font-size: 12px; color: var(--crm-muted); }

/* Chart tooltip */
.crm-chart-tip {
  position: fixed; z-index: 1300; pointer-events: none; max-width: 240px;
  padding: 6px 8px; font-size: 12px; font-weight: 500; color: #fff;
  background: var(--crm-surface-dark); border-radius: var(--crm-radius); box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2);
}

@media (max-width: 1200px) {
  .crm-kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 1100px) {
  .crm-dash-grid { grid-template-columns: 1fr; }
}
@media (max-width: 768px) {
  .crm-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .crm-kpi { padding: 12px; }
  .crm-kpi-value { font-size: 24px; }
  .crm-dash-controls { width: 100%; }
  .crm-dash-controls .crm-field--inline { flex: 1 1 100%; }
  .crm-dash-controls .crm-field--inline .crm-select { flex: 1; }
  .crm-dash-controls .crm-btn { flex: 1; }
  .crm-dash-custom { flex: 1 1 100%; }
  .crm-dash-custom .crm-input { flex: 1; width: auto; min-width: 0; }
  .crm-funnel-row { grid-template-columns: 96px minmax(0, 1fr) 84px; gap: 6px; }
  .crm-leader-row { grid-template-columns: 18px auto minmax(0, 1fr) auto; }
  .crm-leader-tags { grid-column: 3 / -1; justify-self: start; }
}

/* PDF export (window.print) — only while exporting the dashboard */
@media print {
  body.crm-print-dashboard { display: block !important; background: #fff; }
  body.crm-print-dashboard .sidebar,
  body.crm-print-dashboard .header-bar,
  body.crm-print-dashboard .admin-sidebar-backdrop,
  body.crm-print-dashboard .crm-dash-controls,
  body.crm-print-dashboard .crm-toasts,
  body.crm-print-dashboard .crm-panel,
  body.crm-print-dashboard .crm-panel-backdrop,
  body.crm-print-dashboard .crm-chart-tip,
  body.crm-print-dashboard .crm-heat-table,
  body.crm-print-dashboard .crm-task-actions,
  body.crm-print-dashboard .crm-task-check,
  body.crm-print-dashboard .section-view:not(#crm),
  body.crm-print-dashboard [data-crm-panel]:not([data-crm-panel="dashboard"]) { display: none !important; }
  body.crm-print-dashboard .main-content { margin: 0 !important; padding: 0 !important; }
  body.crm-print-dashboard .crm-kpis { grid-template-columns: repeat(5, minmax(0, 1fr)); }
  body.crm-print-dashboard .crm-dash-grid { grid-template-columns: 1fr 1fr; }
  body.crm-print-dashboard .crm-dash-card, body.crm-print-dashboard .crm-kpi { break-inside: avoid; }
  body.crm-print-dashboard * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}

/* ── Automation, import/export, search & polish (Phase 8) ── */
.crm-stack { display: flex; flex-direction: column; gap: 8px; }
.crm-kbd {
  display: inline-block; min-width: 20px; padding: 1px 5px; font-family: var(--crm-ff-mono); font-size: 11px; line-height: 16px;
  text-align: center; color: var(--crm-text); background: var(--crm-bg); border: 1px solid #DCDCE3; border-bottom-width: 2px; border-radius: 3px;
}
.crm-dialog--xl { width: min(860px, calc(100vw - 32px)); max-height: calc(100vh - 48px); padding: 0; }

/* Skeleton loaders (shimmer; static when reduced motion is preferred) */
.crm-skeleton {
  display: block; background: linear-gradient(90deg, #ECEBF2 0%, #F6F5FA 50%, #ECEBF2 100%);
  background-size: 200% 100%; border-radius: 2px; animation: crmShimmer 1.4s ease-in-out infinite;
}
.crm-skeleton--line { height: 12px; margin: 6px 0; }
.crm-skeleton--box { width: 44px; height: 44px; flex-shrink: 0; }
.crm-skeleton-block { display: flex; flex-direction: column; gap: 4px; padding: 8px 0; }
.crm-skeleton-block--board { min-height: 240px; }
.crm-skeleton-card { display: flex; gap: 12px; padding: 18px; background: var(--crm-surface); border: 1px solid var(--crm-line); border-radius: var(--crm-radius); }
.crm-skeleton-card .crm-skeleton-block { flex: 1; padding: 0; }
.crm-skeleton-row td { padding: 14px; }
@keyframes crmShimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }
@media (prefers-reduced-motion: reduce) { .crm-skeleton { animation: none; } }

/* Selection + bulk bar */
.crm-cell-select { width: 36px; }
.crm-row-check { width: 16px; height: 16px; accent-color: var(--crm-primary); cursor: pointer; }
.crm-table tbody tr.is-selected { background: var(--crm-primary-tint); }
.crm-select-all-hint { font-size: 13px; text-align: center; padding: 8px; background: var(--crm-primary-tint); border: 1px solid #DDD7F1; border-radius: var(--crm-radius); margin-top: 8px; }
.crm-list-toolbar { display: flex; align-items: center; gap: 16px; margin-bottom: 12px; }
.crm-list-toolbar .crm-results-info { margin: 0; }
.crm-client-cell { position: relative; }
.crm-client-cell .crm-card-check { position: absolute; top: 12px; right: 12px; z-index: 2; }
.crm-client-cell.is-selected .crm-client-card { border-color: var(--crm-primary); box-shadow: inset 0 0 0 1px var(--crm-primary); }
.crm-client-cell .crm-client-card { padding-right: 40px; }
.crm-bulk-bar {
  position: fixed; left: 50%; bottom: 20px; z-index: 1050; transform: translateX(-50%);
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap; justify-content: center;
  max-width: calc(100vw - 32px); padding: 10px 14px; color: #fff;
  background: var(--crm-surface-dark); border-radius: var(--crm-radius); box-shadow: 0 12px 32px rgba(42, 42, 55, 0.28);
  font-family: var(--crm-ff-body);
}
.crm-bulk-count { font-size: 13px; white-space: nowrap; }
.crm-bulk-actions { display: flex; gap: 6px; flex-wrap: wrap; }
body.crm-has-bulk-bar .crm-toasts { bottom: 84px; }

.crm-column-more { margin: 4px auto 0; }
.crm-task-more { padding: 10px 14px; text-align: center; }
.crm-tabpanel-toolbar--split { justify-content: space-between; align-items: flex-start; gap: 16px; }
.crm-tabpanel-toolbar--split .crm-field-hint { max-width: 560px; }
.crm-settings-link-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* Import wizard */
.crm-import { display: flex; flex-direction: column; max-height: calc(100vh - 48px); }
.crm-import-head { padding: 20px 24px 12px; border-bottom: 1px solid var(--crm-line); }
.crm-import-body { padding: 16px 24px; overflow-y: auto; flex: 1; }
.crm-import > .crm-dialog-actions { margin: 0; padding: 14px 24px; border-top: 1px solid var(--crm-line); background: var(--crm-bg); }
.crm-steps { display: flex; gap: 6px; list-style: none; counter-reset: step; margin-top: 10px; flex-wrap: wrap; }
.crm-steps li {
  counter-increment: step; font-size: 12px; font-weight: 600; color: var(--crm-muted);
  padding: 4px 10px; border: 1px solid var(--crm-line); border-radius: var(--crm-radius); background: var(--crm-surface);
}
.crm-steps li::before { content: counter(step) ". "; font-family: var(--crm-ff-mono); }
.crm-steps li.is-current { color: #fff; background: var(--crm-primary); border-color: var(--crm-primary); }
.crm-steps li.is-done { color: var(--crm-success); border-color: #BBF7D0; background: #F0FDF4; }
.crm-dropzone {
  display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 40px 16px; text-align: center; cursor: pointer;
  border: 2px dashed #D9D6E8; border-radius: var(--crm-radius); background: var(--crm-bg); font-size: 13px; color: var(--crm-muted);
}
.crm-dropzone strong { font-size: 15px; color: var(--crm-primary); }
.crm-dropzone:hover, .crm-dropzone.is-over { border-color: var(--crm-primary); background: var(--crm-primary-tint); }
.crm-file-input:focus-visible + .crm-dropzone, .crm-dropzone:focus-within { outline: 2px solid var(--crm-primary-light); }
.crm-import-h { font-family: var(--crm-ff-head); font-size: 14px; font-weight: 800; margin: 16px 0 8px; }
.crm-import-sample { max-width: 280px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; }
.crm-import-summary { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); border: 1px solid var(--crm-line); border-radius: var(--crm-radius); margin-bottom: 16px; }
.crm-import-summary > div { padding: 12px 14px; }
.crm-import-summary > div + div { border-left: 1px solid var(--crm-line); }
.crm-import-summary dt { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.4px; color: var(--crm-muted); }
.crm-import-summary dd { font-family: var(--crm-ff-mono); font-size: 22px; font-weight: 600; }
.crm-import-summary dd.is-bad { color: var(--crm-danger); }
.crm-import-issues { max-height: 260px; overflow-y: auto; }
.crm-import-tag { font-size: 11px; font-weight: 700; text-transform: uppercase; padding: 1px 6px; border-radius: 2px; }
.crm-import-tag--error { color: #B91C1C; background: #FEF2F2; }
.crm-import-tag--duplicate { color: #1D4ED8; background: #EFF6FF; }
.crm-import-tag--warning { color: #B45309; background: #FFFBEB; }
.crm-import-ok { color: var(--crm-success); font-weight: 600; margin-top: 12px; }
.crm-progress { height: 10px; background: var(--crm-bg); border: 1px solid var(--crm-line); border-radius: 2px; overflow: hidden; margin: 24px 0 12px; }
.crm-progress span { display: block; height: 100%; width: 0; background: var(--crm-primary); transition: width 0.3s ease; }
.crm-import-result { font-size: 14px; font-weight: 600; }

/* Settings */
.crm-prefs { display: flex; flex-direction: column; gap: 16px; max-width: 640px; }
.crm-rule-row { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 14px; padding: 14px 16px; }
.crm-rule-row.is-off .crm-rule-main { opacity: 0.55; }
.crm-rule-main { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.crm-rule-meta { font-size: 11px; color: var(--crm-muted); }
.crm-rule-block { padding: 12px; border: 1px solid var(--crm-line); border-radius: var(--crm-radius); display: flex; flex-direction: column; gap: 10px; }
.crm-rule-legend { padding: 0 4px; font-family: var(--crm-ff-head); font-size: 12px; font-weight: 800; letter-spacing: 0.6px; text-transform: uppercase; color: var(--crm-primary); }
.crm-rule-preview { padding: 10px 12px; font-size: 13px; background: var(--crm-primary-tint); border: 1px solid #DDD7F1; border-radius: var(--crm-radius); }
.crm-filters--audit { grid-template-columns: repeat(2, minmax(160px, 240px)); }

/* Notifications in the bell */
.crm-bell-heading--row { display: flex; justify-content: space-between; align-items: center; }
.crm-notif { position: relative; }
.crm-notif-dot { width: 8px; height: 8px; margin-top: 5px; border-radius: 50%; background: transparent; flex-shrink: 0; }
.crm-notif.is-unread .crm-notif-dot { background: var(--crm-primary); }
.crm-notif.is-unread .crm-bell-item-title { font-weight: 700; }
.crm-notif-body { font-size: 12px; color: var(--crm-text); }

/* Global search */
.crm-search-trigger {
  display: inline-flex; align-items: center; gap: 8px; min-width: 260px; height: 36px; padding: 0 10px; margin-left: auto; margin-right: 20px;
  font: inherit; font-size: 13px; color: var(--crm-muted); background: #fff; border: 1px solid #EBECEC; border-radius: 4px; cursor: pointer;
}
.crm-search-trigger svg { width: 16px; height: 16px; }
.crm-search-trigger:hover { border-color: #D3D0E3; color: var(--crm-text); }
.crm-search-trigger:focus-visible { outline: 2px solid var(--crm-primary-light); outline-offset: 2px; }
.crm-search-trigger .crm-kbd { margin-left: auto; }
#sidebarSearch { cursor: pointer; }
.crm-search-dialog { width: min(640px, calc(100vw - 32px)); padding: 0; margin-top: 10vh; }
.crm-search-box { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--crm-line); }
.crm-search-box svg { width: 18px; height: 18px; color: var(--crm-muted); flex-shrink: 0; }
.crm-search-input { flex: 1; min-width: 0; border: none; outline: none; font: inherit; font-size: 16px; color: var(--crm-text); background: transparent; }
.crm-search-results { list-style: none; max-height: 50vh; overflow-y: auto; padding: 6px 0; }
.crm-search-group { padding: 8px 16px 4px; font-size: 11px; font-weight: 700; letter-spacing: 0.6px; text-transform: uppercase; color: var(--crm-muted); }
.crm-search-option { display: flex; gap: 10px; align-items: center; padding: 8px 16px; cursor: pointer; }
.crm-search-option[aria-selected="true"] { background: var(--crm-primary-tint); }
.crm-search-icon { width: 24px; text-align: center; flex-shrink: 0; }
.crm-search-main { display: flex; flex-direction: column; min-width: 0; }
.crm-search-title { font-size: 14px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.crm-search-sub { font-size: 12px; color: var(--crm-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.crm-search-option mark { background: #FEF3C7; color: inherit; padding: 0 1px; border-radius: 2px; }
.crm-search-empty { padding: 20px 16px; font-size: 13px; color: var(--crm-muted); }
.crm-search-foot { padding: 8px 16px; font-size: 12px; color: var(--crm-muted); border-top: 1px solid var(--crm-line); background: var(--crm-bg); }

.crm-shortcuts { display: flex; flex-direction: column; gap: 10px; margin: 12px 0; }
.crm-shortcuts > div { display: grid; grid-template-columns: 170px 1fr; gap: 12px; align-items: center; font-size: 13px; }

/* Offline */
.crm-offline-banner {
  position: fixed; top: 0; left: 50%; transform: translateX(-50%); z-index: 1250;
  padding: 8px 16px; font-family: var(--crm-ff-body); font-size: 13px; font-weight: 600; color: #92400E;
  background: #FFFBEB; border: 1px solid #FDE68A; border-top: none; border-radius: 0 0 4px 4px; box-shadow: 0 6px 16px rgba(0, 0, 0, 0.08);
}

@media (max-width: 1100px) {
  .crm-search-trigger { min-width: 0; }
  .crm-search-trigger-text, .crm-search-trigger .crm-kbd { display: none; }
}

@media (max-width: 768px) {
  /* Pipeline: columns stack vertically on phones */
  .crm-board { flex-direction: column; overflow-x: visible; scroll-snap-type: none; }
  .crm-column { flex: 0 0 auto; width: 100%; max-width: none; min-width: 0; }
  .crm-column-list { max-height: none; min-height: 0; }
  .crm-column-empty { padding: 10px 0; }

  .crm-search-trigger { margin-right: 4px; width: 36px; justify-content: center; padding: 0; }
  .crm-search-dialog { margin-top: 0; width: 100vw; max-width: 100vw; height: 100dvh; max-height: 100dvh; border-radius: 0; }
  .crm-search-results { max-height: calc(100dvh - 120px); }
  .crm-dialog--xl { width: 100vw; max-width: 100vw; height: 100dvh; max-height: 100dvh; border-radius: 0; margin: 0; }
  .crm-import { max-height: 100dvh; height: 100%; }
  .crm-import-summary { grid-template-columns: 1fr 1fr; }
  .crm-import-summary > div:nth-child(3) { border-left: none; }
  .crm-import-summary > div:nth-child(n+3) { border-top: 1px solid var(--crm-line); }
  .crm-bulk-bar { left: 8px; right: 8px; transform: none; bottom: 8px; max-width: none; }
  .crm-rule-row { grid-template-columns: auto minmax(0, 1fr); }
  .crm-rule-row .crm-task-actions { grid-column: 2; }
  .crm-filters--audit { grid-template-columns: 1fr 1fr; }
  .crm-shortcuts > div { grid-template-columns: 1fr; gap: 2px; }
  .crm-list-toolbar { flex-wrap: wrap; gap: 8px; }
}

/* Elements outside #crm that set display must still honour [hidden] */
.crm-bulk-bar[hidden], .crm-offline-banner[hidden], .crm-chart-tip[hidden] { display: none !important; }
.crm-bulk-count { flex-shrink: 0; }
/* The public site pads every <section>; CRM dialogs and panels never want it */
.crm-dialog section, .crm-panel section { padding: 0; }
