/* =========================================================
   Customer Journey iRawda — Design System
   Minimalist SaaS aesthetic: soft gradients, pastel icon badges,
   floating cards with colour-tinted "illumination" shadows.
   ========================================================= */

:root {
  /* Legacy brand accents (still used for a few status/legacy touches) */
  --navy: #053270;
  --navy-dark: #021E46;
  --royal: #0B4DA2;
  --gold: #FFC60B;
  --gold-soft: #FFE38A;
  --white: #FEFEFE;

  /* Primary gradient identity — blue → purple → pink */
  --grad-a: #2F6FED;
  --grad-b: #8B5CF6;
  --grad-c: #EC4899;
  --hero-gradient: linear-gradient(120deg, var(--grad-a) 0%, var(--grad-b) 55%, var(--grad-c) 100%);
  --primary: #5B5FEF;
  --primary-2: #7C3AED;
  --primary-bg: #EEF0FF;
  --primary-glow: rgba(91, 95, 239, 0.35);

  --bg: #F5F6FA;
  --text: #171A2B;

  /* Semantic surface tokens (light) */
  --surface: #FFFFFF;
  --surface-2: #F8F9FC;
  --surface-3: #F0F1F8;
  --border: #E7E9F2;
  --text-primary: var(--text);
  --text-secondary: #62687C;
  --text-muted: #949AAE;
  --shadow-sm: 0 1px 3px rgba(23, 26, 43, 0.05);
  --shadow-md: 0 8px 24px rgba(23, 26, 43, 0.08);
  --shadow-lg: 0 20px 48px rgba(23, 26, 43, 0.12);
  --shadow-glow: 0 16px 40px -12px var(--primary-glow);

  /* Status colors */
  --ok: #15A26B;
  --ok-bg: #E3F9EE;
  --warn: #D97706;
  --warn-bg: #FFF3DE;
  --danger: #E0392E;
  --danger-bg: #FDEAEA;
  --info: #3B6FE0;
  --info-bg: #E9EFFE;
  --neutral: #62687C;
  --neutral-bg: #EEF0F6;

  /* Pastel icon badge palette (KPI icons, module icons) */
  --badge-blue-bg: #E7EEFF; --badge-blue-fg: #3B6FE0;
  --badge-amber-bg: #FFF1DD; --badge-amber-fg: #D97706;
  --badge-green-bg: #E3F9EC; --badge-green-fg: #16A34A;
  --badge-purple-bg: #F1EAFE; --badge-purple-fg: #7C3AED;
  --badge-red-bg: #FDEAEA; --badge-red-fg: #DC2626;
  --badge-pink-bg: #FCE7F3; --badge-pink-fg: #DB2777;

  /* Sidebar (light, minimalist — matches reference) */
  --sidebar-bg: #FFFFFF;
  --sidebar-border: #EEF0F5;
  --sidebar-text: #4B5468;
  --sidebar-text-muted: #9AA3B8;
  --sidebar-active-bg: linear-gradient(120deg, rgba(59,111,224,0.12), rgba(139,92,246,0.10));
  --sidebar-active-fg: var(--primary);

  /* Layout */
  --sidebar-w: 264px;
  --sidebar-w-collapsed: 84px;
  --topnav-h: 76px;
  --radius-sm: 10px;
  --radius-md: 16px;
  --radius-lg: 22px;
  --gap: 20px;

  /* Type */
  --font-main: 'Inter', 'Public Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --fs-body: 15px;
  --density: 1;
}

[data-density="compact"] {
  --density: 0.8;
}

/* Dark theme */
[data-theme="dark"] {
  --surface: #171A2C;
  --surface-2: #1D2136;
  --surface-3: #262B45;
  --border: #333A57;
  --bg: #0E1020;
  --text-primary: #F2F3FA;
  --text-secondary: #C1C5DA;
  --text-muted: #9297B0;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.35);
  --shadow-md: 0 10px 26px rgba(0,0,0,0.45);
  --shadow-lg: 0 22px 50px rgba(0,0,0,0.55);
  --shadow-glow: 0 18px 44px -12px rgba(139, 92, 246, 0.45);
  --ok-bg: #103826; --ok: #4ADE94;
  --warn-bg: #3A2C08; --warn: #FFC94D;
  --danger-bg: #3B1512; --danger: #FF8A80;
  --info-bg: #202A4E; --info: #8FB0FA;
  --neutral-bg: #232842; --neutral: #B7BCD4;
  --primary-bg: #232242;
  --sidebar-bg: #171A2C;
  --sidebar-border: #262B45;
  --sidebar-text: #C1C5DA;
  --sidebar-text-muted: #797FA0;
  --sidebar-active-bg: linear-gradient(120deg, rgba(59,111,224,0.22), rgba(139,92,246,0.20));
  --sidebar-active-fg: #A8B4FF;
}

[data-contrast="high"] {
  --border: #000;
  --text-secondary: var(--text-primary);
}
[data-theme="dark"][data-contrast="high"] {
  --border: #fff;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}
[data-motion="reduce"] * { animation: none !important; transition: none !important; }

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font-main);
  font-size: var(--fs-body);
  color: var(--text-primary);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; }
button { font-family: inherit; }
img { max-width: 100%; display: block; }

.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}

/* Focus states */
a:focus-visible, button:focus-visible, input:focus-visible,
select:focus-visible, textarea:focus-visible, [tabindex]:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
  border-radius: 6px;
}

/* =========================================================
   App shell
   ========================================================= */
.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100vh;
  transition: grid-template-columns 0.2s ease;
}
.app-shell.sidebar-collapsed { grid-template-columns: var(--sidebar-w-collapsed) 1fr; }

/* ---- Sidebar ---- */
.sidebar {
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  z-index: 40;
  border-right: 1px solid var(--sidebar-border);
}
[data-motion="reduce"] .sidebar { animation: none; }
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 22px 20px;
  border-bottom: 1px solid var(--sidebar-border);
  white-space: nowrap;
  overflow: hidden;
}
.brand-mark {
  width: 40px; height: 40px; flex: 0 0 auto;
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  position: relative;
}
.brand-mark::before {
  content: ''; position: absolute; inset: -8px; border-radius: 16px;
  background: radial-gradient(circle, var(--primary-glow), transparent 70%);
  filter: blur(8px); z-index: -1;
}
.brand-mark img { width: 100%; height: 100%; object-fit: contain; filter: drop-shadow(0 3px 8px var(--primary-glow)); }
.brand-text .brand-title {
  font-weight: 800; font-size: 16px; line-height: 1.2;
  background: var(--hero-gradient);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.brand-text .brand-sub { font-size: 11.5px; color: var(--sidebar-text-muted); letter-spacing: 0.3px; }
.app-shell.sidebar-collapsed .brand-text { display: none; }

.sidebar-nav { flex: 1; overflow-y: auto; padding: 16px 12px; }
.nav-section-label {
  font-size: 10.5px; font-weight: 700; letter-spacing: 0.6px; color: var(--sidebar-text-muted);
  text-transform: uppercase; padding: 14px 14px 6px;
}
.nav-section-label:first-child { padding-top: 4px; }
.app-shell.sidebar-collapsed .nav-section-label { display: none; }
.nav-item {
  display: flex; align-items: center; gap: 13px;
  padding: 10px 14px;
  border-radius: 12px;
  color: var(--sidebar-text);
  text-decoration: none;
  font-size: 14.5px;
  font-weight: 500;
  margin-bottom: 2px;
  cursor: pointer;
  border: 1px solid transparent;
  background: transparent;
  width: 100%;
  text-align: left;
  transition: background 0.18s ease, color 0.18s ease, transform 0.18s ease;
}
.nav-item svg { flex: 0 0 auto; width: 19px; height: 19px; color: var(--sidebar-text-muted); transition: color 0.18s ease; }
.nav-item span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.app-shell.sidebar-collapsed .nav-item span { display: none; }
.app-shell.sidebar-collapsed .nav-item { justify-content: center; }
.nav-item:hover { background: var(--surface-2); color: var(--text-primary); transform: translateX(2px); }
.nav-item:hover svg { color: var(--text-secondary); }
.nav-item.active {
  background: var(--sidebar-active-bg);
  color: var(--sidebar-active-fg);
  font-weight: 700;
}
.nav-item.active svg { color: var(--primary); }
.nav-item .nav-badge {
  margin-left: auto;
  background: var(--danger);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  padding: 1px 7px;
  border-radius: 999px;
}
.app-shell.sidebar-collapsed .nav-badge { display: none; }

.sidebar-footer {
  border-top: 1px solid var(--sidebar-border);
  padding: 16px;
}
.sidebar-user { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.user-avatar {
  width: 38px; height: 38px; border-radius: 50%;
  background: var(--hero-gradient);
  color: #fff; display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 13px; flex: 0 0 auto;
  box-shadow: 0 4px 12px var(--primary-glow);
}
.user-meta { overflow: hidden; }
.user-name { font-size: 13.5px; font-weight: 700; color: var(--text-primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { font-size: 11.5px; color: var(--sidebar-text-muted); }
.app-shell.sidebar-collapsed .user-meta, .app-shell.sidebar-collapsed .sidebar-status-text { display: none; }
.sidebar-status {
  display: flex; align-items: center; gap: 8px;
  font-size: 12px; color: var(--ok);
  margin-bottom: 10px;
}
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: #34D399; box-shadow: 0 0 0 3px rgba(52,211,153,0.2); }
.btn-logout {
  width: 100%; padding: 9px; border-radius: 10px;
  background: var(--surface-2); color: var(--text-primary); border: 1px solid var(--border);
  cursor: pointer; font-size: 13px; font-weight: 600;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  transition: background 0.15s ease, transform 0.15s ease;
}
.btn-logout:hover { background: var(--surface-3); transform: translateY(-1px); }

.sidebar-collapse-btn {
  position: absolute; top: 20px; right: -12px;
  width: 26px; height: 26px; border-radius: 50%;
  background: var(--hero-gradient); color: #fff; border: none; cursor: pointer;
  display: none; align-items: center; justify-content: center; box-shadow: var(--shadow-glow);
  transition: transform 0.2s ease;
}
.sidebar-collapse-btn:hover { transform: scale(1.1); }
@media (min-width: 1025px) { .sidebar-collapse-btn { display: flex; } }

/* Mobile sidebar */
.sidebar-overlay {
  display: none;
  position: fixed; inset: 0; background: rgba(15,17,30,0.45);
  z-index: 39; backdrop-filter: blur(3px);
}
.sidebar-overlay.open { display: block; }

@media (max-width: 1024px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; left: 0; top: 0;
    width: 280px;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar-collapse-btn { display: none; }
}

/* ---- Main column ---- */
.main-col { display: flex; flex-direction: column; min-width: 0; }

/* ---- Top nav ---- */
.topnav {
  height: var(--topnav-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 16px;
  padding: 0 28px;
  position: sticky; top: 0; z-index: 30;
}
.icon-btn {
  width: 40px; height: 40px; border-radius: 12px;
  border: 1px solid var(--border); background: var(--surface-2);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; color: var(--text-secondary); position: relative;
  flex: 0 0 auto;
  transition: background 0.18s ease, transform 0.18s ease, box-shadow 0.18s ease, color 0.18s ease;
}
.icon-btn:hover { background: var(--surface-3); transform: translateY(-2px); box-shadow: var(--shadow-md); color: var(--text-primary); }
.icon-btn svg { width: 18px; height: 18px; }
.hamburger { display: none; }
@media (max-width: 1024px) { .hamburger { display: flex; } }
.mobile-search-btn { display: none; }

.topnav-titles { min-width: 0; }
.topnav-titles .page-title { font-size: 19px; font-weight: 800; line-height: 1.2; letter-spacing: -0.2px; }
.breadcrumb { font-size: 12.5px; color: var(--text-muted); margin-top: 2px; }
.breadcrumb span:not(:last-child)::after { content: '/'; margin: 0 6px; color: var(--text-muted); }

.topnav-search { flex: 1; max-width: 460px; position: relative; }
.topnav-search input {
  width: 100%; padding: 11px 54px 11px 40px;
  border-radius: 999px; border: 1px solid var(--border);
  background: var(--surface-2); color: var(--text-primary); font-size: 14px;
  transition: border-color 0.18s ease, background 0.18s ease;
}
.topnav-search input:focus { background: var(--surface); border-color: var(--primary); }
.topnav-search svg {
  position: absolute; left: 14px; top: 50%; transform: translateY(-50%);
  width: 16px; height: 16px; color: var(--text-muted); pointer-events: none;
}
.topnav-search::after {
  content: '⌘K';
  position: absolute; right: 12px; top: 50%; transform: translateY(-50%);
  font-size: 10.5px; font-weight: 700; color: var(--text-muted);
  background: var(--surface); border: 1px solid var(--border); border-radius: 6px;
  padding: 2px 6px; pointer-events: none;
}
@media (max-width: 700px) { .topnav-search::after { display: none; } }
.search-results {
  position: absolute; top: calc(100% + 8px); left: 0; right: 0;
  background: var(--surface); border: 1px solid var(--border); border-radius: 16px;
  box-shadow: var(--shadow-lg); max-height: 320px; overflow-y: auto; z-index: 50; display: none;
}
.search-results.open { display: block; }
.search-result-item { padding: 10px 14px; cursor: pointer; border-bottom: 1px solid var(--border); }
.search-result-item:last-child { border-bottom: none; }
.search-result-item:hover, .search-result-item.active-result { background: var(--surface-2); }
.search-result-item .sr-name { font-weight: 600; font-size: 13.5px; }
.search-result-item .sr-meta { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.search-empty { padding: 16px; text-align: center; color: var(--text-muted); font-size: 13px; }

.topnav-spacer { flex: 1; }
.topnav-date { font-size: 12.5px; color: var(--text-secondary); white-space: nowrap; }
@media (max-width: 900px) { .topnav-date { display: none; } }

/* Notification dropdown */
.notif-wrap { position: relative; }
.notif-red-dot {
  position: absolute; top: 7px; right: 7px; width: 8px; height: 8px; border-radius: 50%;
  background: var(--danger); box-shadow: 0 0 0 2px var(--surface);
}
.notif-dropdown {
  position: absolute; top: calc(100% + 10px); right: 0; width: 340px; max-width: 90vw;
  background: var(--surface); border: 1px solid var(--border); border-radius: 18px;
  box-shadow: var(--shadow-lg); z-index: 55; display: none; overflow: hidden;
}
.notif-dropdown.open { display: block; }
.notif-dropdown-header { display: flex; justify-content: space-between; align-items: center; padding: 12px 14px; border-bottom: 1px solid var(--border); font-size: 13.5px; font-weight: 700; }
.notif-dropdown-list { max-height: 360px; overflow-y: auto; }
.notif-item { display: flex; gap: 8px; align-items: flex-start; padding: 12px 14px; border-bottom: 1px solid var(--border); cursor: pointer; transition: background 0.15s ease; }
.notif-item:last-child { border-bottom: none; }
.notif-item:hover { background: var(--surface-2); }
.notif-item.unread { background: var(--primary-bg); }
.notif-item-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--primary); margin-top: 6px; flex: 0 0 auto; }
.notif-item-dot.spacer { background: transparent; }
.notif-item-title { font-size: 13px; font-weight: 600; }
.notif-item-sub { font-size: 11.5px; color: var(--text-muted); margin-top: 2px; }

.avatar-btn {
  width: 40px; height: 40px; border-radius: 50%;
  background: var(--hero-gradient);
  color: #fff; border: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 13px;
  box-shadow: 0 4px 14px var(--primary-glow);
  transition: transform 0.18s ease;
}
.avatar-btn:hover { transform: scale(1.06); }
.btn-primary-gold {
  background: var(--hero-gradient);
  background-size: 200% 200%;
  animation: heroGradientShift 8s ease-in-out infinite;
  color: #fff; border: none; font-weight: 700;
  padding: 11px 20px; border-radius: 999px; cursor: pointer;
  display: flex; align-items: center; gap: 8px; font-size: 13.5px;
  box-shadow: var(--shadow-glow);
  white-space: nowrap;
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}
[data-motion="reduce"] .btn-primary-gold { animation: none; }
.btn-primary-gold:hover { transform: translateY(-2px) scale(1.02); box-shadow: 0 22px 46px -10px var(--primary-glow); }
.btn-primary-gold svg { width: 16px; height: 16px; }
@media (max-width: 700px) { .btn-primary-gold span { display: none; } .btn-primary-gold { padding: 11px; } }

/* ---- Content area ---- */
.content {
  flex: 1;
  padding: calc(24px * var(--density)) calc(28px * var(--density));
  max-width: 1600px;
  width: 100%;
  margin: 0 auto;
  transition: max-width 0.2s ease;
}
[data-layout="wide"] .content { max-width: 100%; }
.page { display: none; }
.page.active { display: block; animation: fadeIn 0.25s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: translateY(0); } }

/* =========================================================
   Reusable components
   ========================================================= */

/* Hero banner */
.hero-banner {
  position: relative;
  overflow: hidden;
  border-radius: var(--radius-lg);
  background: var(--hero-gradient);
  background-size: 200% 200%;
  animation: heroGradientShift 14s ease-in-out infinite;
  color: #fff;
  padding: 34px 36px;
  margin-bottom: calc(24px * var(--density));
  box-shadow: var(--shadow-glow);
}
@keyframes heroGradientShift {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}
[data-motion="reduce"] .hero-banner { animation: none; }
.hero-banner::before, .hero-banner::after {
  content: ''; position: absolute; border-radius: 50%;
  filter: blur(50px); opacity: 0.4; pointer-events: none;
  animation: blobPulse 8s ease-in-out infinite;
}
.hero-banner::before { width: 280px; height: 280px; background: #fff; top: -120px; right: -60px; opacity: 0.16; }
.hero-banner::after { width: 200px; height: 200px; background: var(--grad-c); bottom: -90px; left: 15%; opacity: 0.3; animation-delay: 2s; }
@keyframes blobPulse { 0%,100% { transform: scale(1); opacity: 0.3; } 50% { transform: scale(1.15); opacity: 0.45; } }
[data-motion="reduce"] .hero-banner::before, [data-motion="reduce"] .hero-banner::after { animation: none; }
.hero-banner .hero-date { font-size: 11.5px; font-weight: 700; letter-spacing: 0.6px; text-transform: uppercase; color: rgba(255,255,255,0.75); position: relative; margin-bottom: 8px; }
.hero-banner h1 { margin: 0 0 6px; font-size: 26px; font-weight: 800; position: relative; }
.hero-banner p { margin: 0; color: rgba(255,255,255,0.82); font-size: 14.5px; position: relative; max-width: 560px; }
.hero-meta { display: flex; gap: 28px; margin-top: 20px; flex-wrap: wrap; position: relative; }
.hero-meta-item .hm-val { font-size: 20px; font-weight: 800; color: #fff; }
.hero-meta-item .hm-label { font-size: 12px; color: rgba(255,255,255,0.72); }

.hero-banner-flex { display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; flex-wrap: wrap; position: relative; }
.hero-banner-main { flex: 1; min-width: 240px; }
.hero-birthday-widget {
  background: rgba(255,255,255,0.14); border: 1px solid rgba(255,255,255,0.25);
  border-radius: 18px; padding: 16px 22px; cursor: pointer; text-align: center; min-width: 160px;
  backdrop-filter: blur(6px); transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}
.hero-birthday-widget:hover { transform: translateY(-4px); box-shadow: 0 18px 36px rgba(0,0,0,0.2); background: rgba(255,255,255,0.2); }
.hbw-label { font-size: 11.5px; color: rgba(255,255,255,0.85); font-weight: 700; display: flex; align-items: center; gap: 5px; justify-content: center; }
.hbw-label svg { width: 13px; height: 13px; }
.hbw-count { font-size: 30px; font-weight: 800; color: #fff; margin: 4px 0; }
.hbw-hint { font-size: 10.5px; color: rgba(255,255,255,0.7); }

/* Section headers */
.section-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 14px; gap: 12px; flex-wrap: wrap;
}
.section-header h2 { font-size: 16.5px; font-weight: 700; margin: 0; }
.section-header .sub { font-size: 12.5px; color: var(--text-muted); margin-top: 2px; }

/* KPI grid */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: calc(16px * var(--density));
  margin-bottom: calc(24px * var(--density));
}
@media (max-width: 1200px) { .kpi-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 560px) { .kpi-grid { grid-template-columns: 1fr; } }

.kpi-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: calc(20px * var(--density));
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: transform 0.25s ease, box-shadow 0.25s ease;
  position: relative;
  isolation: isolate;
}
.kpi-card::after {
  content: '';
  position: absolute; inset: 0; border-radius: inherit;
  background: radial-gradient(140px circle at 85% 0%, var(--primary-glow), transparent 70%);
  opacity: 0; transition: opacity 0.3s ease; z-index: -1;
}
.kpi-card:hover { transform: translateY(-5px); box-shadow: var(--shadow-glow); }
.kpi-card:hover::after { opacity: 1; }
.kpi-top { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 14px; gap: 10px; }
.kpi-icon {
  width: 38px; height: 38px; border-radius: 12px; flex: 0 0 auto;
  display: flex; align-items: center; justify-content: center;
  background: var(--info-bg); color: var(--info);
  transition: transform 0.25s ease;
}
.kpi-card:hover .kpi-icon { transform: scale(1.1) rotate(-4deg); }
.kpi-icon svg { width: 18px; height: 18px; }
.kpi-icon-blue { background: var(--badge-blue-bg); color: var(--badge-blue-fg); }
.kpi-icon-amber { background: var(--badge-amber-bg); color: var(--badge-amber-fg); }
.kpi-icon-green { background: var(--badge-green-bg); color: var(--badge-green-fg); }
.kpi-icon-purple { background: var(--badge-purple-bg); color: var(--badge-purple-fg); }
.kpi-icon-red { background: var(--badge-red-bg); color: var(--badge-red-fg); }
.kpi-icon-pink { background: var(--badge-pink-bg); color: var(--badge-pink-fg); }
.kpi-delta { font-size: 12px; font-weight: 700; }
.kpi-delta.up { color: var(--ok); }
.kpi-delta.down { color: var(--danger); }
.kpi-value { font-size: 27px; font-weight: 800; line-height: 1.1; margin-bottom: 6px; }
.kpi-label { font-size: 11.5px; font-weight: 700; letter-spacing: 0.4px; text-transform: uppercase; color: var(--text-muted); }

/* Generic card */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  padding: calc(20px * var(--density));
  margin-bottom: calc(20px * var(--density));
  transition: box-shadow 0.25s ease, transform 0.25s ease;
}
.card:hover { box-shadow: var(--shadow-lg); transform: translateY(-2px); }

.grid-2 { display: grid; grid-template-columns: 1.3fr 1fr; gap: calc(20px * var(--density)); }
@media (max-width: 1100px) { .grid-2 { grid-template-columns: 1fr; } }
.grid-3 { display: grid; grid-template-columns: repeat(3,1fr); gap: calc(20px * var(--density)); }
@media (max-width: 1100px) { .grid-3 { grid-template-columns: 1fr; } }

/* Progress rows */
.progress-row { margin-bottom: 14px; }
.progress-row:last-child { margin-bottom: 0; }
.progress-row-top { display: flex; justify-content: space-between; font-size: 13px; margin-bottom: 6px; }
.progress-row-top .pr-label { color: var(--text-secondary); }
.progress-row-top .pr-value { font-weight: 700; }
.progress-track { height: 8px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.progress-fill { height: 100%; border-radius: 999px; background: var(--hero-gradient); }

/* Data source chips */
.source-list { display: flex; flex-direction: column; gap: 10px; }
.source-item {
  display: flex; align-items: center; justify-content: space-between; padding: 10px 12px;
  background: var(--surface-2); border-radius: 10px; border: 1px solid transparent;
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}
.source-item:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); border-color: var(--border); }
.source-item .si-name { font-size: 13px; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.source-dot { width: 8px; height: 8px; border-radius: 50%; }
.source-item .si-count { font-weight: 700; font-size: 14px; }

/* Participant distribution map + ranking */
.map-ranking-layout { display: grid; grid-template-columns: 1.5fr 1fr; gap: 20px; align-items: start; }
@media (max-width: 1000px) { .map-ranking-layout { grid-template-columns: 1fr; } }

.leaflet-map-el {
  height: 440px; width: 100%; border-radius: 16px; overflow: hidden;
  border: 1px solid var(--border); box-shadow: var(--shadow-sm);
  position: relative; z-index: 0; isolation: isolate;
}
@media (max-width: 700px) { .leaflet-map-el { height: 320px; } }

/* Theme the Leaflet chrome (zoom control, attribution) to match the app */
.leaflet-control-zoom a {
  background: var(--surface) !important; color: var(--text-primary) !important; border-color: var(--border) !important;
}
.leaflet-control-zoom a:hover { background: var(--surface-3) !important; }
.leaflet-control-attribution {
  background: rgba(255,255,255,0.75) !important; font-size: 10px !important;
}
[data-theme="dark"] .leaflet-control-attribution { background: rgba(14,27,51,0.75) !important; color: var(--text-secondary) !important; }
[data-theme="dark"] .leaflet-control-attribution a { color: var(--text-secondary) !important; }

/* Tooltip popup shown on hover — small "data popup" per region */
.leaflet-tooltip.map-tooltip-box {
  background: var(--surface); color: var(--text-primary); border: 1px solid var(--border);
  border-radius: 10px; padding: 8px 12px; font-size: 12.5px; box-shadow: var(--shadow-md);
  font-family: var(--font-main);
}
.leaflet-tooltip.map-tooltip-box::before { display: none; }

.ranking-panel { display: flex; flex-direction: column; }
.ranking-panel-title { font-size: 11px; font-weight: 700; letter-spacing: 0.5px; color: var(--text-muted); margin-bottom: 10px; }
.ranking-list { display: flex; flex-direction: column; gap: 14px; max-height: 420px; overflow-y: auto; padding-right: 4px; }
.ranking-row { cursor: pointer; padding: 4px 4px 4px 0; border-radius: 10px; transition: background 0.15s ease; }
.ranking-row:hover { background: var(--surface-2); }
.ranking-row-top { display: flex; align-items: center; gap: 8px; margin-bottom: 5px; }
.ranking-num {
  width: 20px; height: 20px; border-radius: 50%; background: var(--surface-3); color: var(--text-secondary);
  font-size: 11px; font-weight: 700; display: flex; align-items: center; justify-content: center; flex: 0 0 auto;
}
.ranking-name { font-weight: 700; font-size: 13.5px; flex: 1; }
.ranking-val { font-weight: 800; font-size: 13.5px; color: var(--primary); }
.ranking-sub { font-size: 11px; color: var(--text-muted); margin-top: 4px; }

/* Birthday modal rows */
.bday-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 0; border-bottom: 1px solid var(--border);
}
.bday-row:last-child { border-bottom: none; }
.bday-name { font-weight: 700; font-size: 13.5px; }
.bday-sub { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.bday-status { font-size: 11.5px; color: var(--ok); margin-top: 4px; font-weight: 600; }
.bday-action-select { min-width: 190px; }

/* Critical action list */
.action-list { display: flex; flex-direction: column; gap: 10px; }
.action-item {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px; border-radius: 12px; border: 1px solid var(--border); background: var(--surface-2);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.action-item:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); background: var(--surface); }
.action-item .ai-priority {
  width: 6px; align-self: stretch; border-radius: 4px; flex: 0 0 auto;
}
.priority-critical { background: var(--danger); }
.priority-high { background: var(--warn); }
.priority-medium { background: var(--info); }
.priority-low { background: var(--neutral); }
.ai-body { flex: 1; min-width: 0; }
.ai-name { font-weight: 700; font-size: 13.5px; }
.ai-meta { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.ai-badge {
  font-size: 11px; font-weight: 700; padding: 2px 9px; border-radius: 999px; white-space: nowrap;
}
.btn-mini {
  padding: 7px 12px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--surface); font-size: 12.5px; font-weight: 600; cursor: pointer; white-space: nowrap;
}
.btn-mini:hover { background: var(--surface-3); }
.btn-mini.primary { background: var(--primary); color: #fff; border-color: var(--primary); }

/* Badges / status pills */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11.5px; font-weight: 700; padding: 3px 10px; border-radius: 999px; white-space: nowrap;
}
.badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge-ok { color: var(--ok); background: var(--ok-bg); }
.badge-warn { color: var(--warn); background: var(--warn-bg); }
.badge-danger { color: var(--danger); background: var(--danger-bg); }
.badge-info { color: var(--info); background: var(--info-bg); }
.badge-neutral { color: var(--neutral); background: var(--neutral-bg); }

/* Subscription pipeline board */
.sub-pipeline-board { display: flex; gap: 16px; overflow-x: auto; padding-bottom: 6px; }
.sub-pipeline-col {
  flex: 0 0 280px; background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius-md); padding: 14px; display: flex; flex-direction: column; max-height: 640px;
}
.sub-pipeline-col-header { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; padding: 0 2px; }
.sub-pipeline-col-title { font-weight: 700; font-size: 13.5px; flex: 1; }
.sub-pipeline-col-count {
  font-size: 11.5px; font-weight: 700; background: var(--surface-3); color: var(--text-secondary);
  padding: 2px 9px; border-radius: 999px;
}
.sub-pipeline-dot { width: 9px; height: 9px; border-radius: 50%; flex: 0 0 auto; }
.badge-blue-dot { background: var(--badge-blue-fg); }
.badge-amber-dot { background: var(--badge-amber-fg); }
.badge-green-dot { background: var(--badge-green-fg); }
.badge-purple-dot { background: var(--badge-purple-fg); }
.badge-red-dot { background: var(--badge-red-fg); }
.badge-pink-dot { background: var(--badge-pink-fg); }
.sub-pipeline-col-body { display: flex; flex-direction: column; gap: 10px; overflow-y: auto; }

.sub-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px;
  padding: 12px 14px; cursor: pointer; box-shadow: var(--shadow-sm);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.sub-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-glow); }
.sub-card-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.sub-card-name { font-weight: 700; font-size: 13.5px; }
.sub-card-id { font-size: 11.5px; color: var(--text-muted); margin-top: 2px; margin-bottom: 8px; font-family: monospace; }
.sub-card-row { display: flex; justify-content: space-between; font-size: 12px; color: var(--text-secondary); padding: 2px 0; }
.sub-card-ltv { margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--border); font-size: 12.5px; font-weight: 700; color: var(--primary); }

/* Program cards */
.program-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px,1fr)); gap: calc(18px * var(--density)); grid-auto-rows: 1fr; align-items: stretch; }
.program-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md);
  padding: 18px; box-shadow: var(--shadow-sm); cursor: pointer; position: relative; overflow: hidden;
  display: flex; flex-direction: column; height: 100%; transition: transform 0.25s ease, box-shadow 0.25s ease;
  isolation: isolate;
}
.program-card::after {
  content: ''; position: absolute; inset: 0; border-radius: inherit;
  background: radial-gradient(160px circle at 90% 0%, var(--primary-glow), transparent 70%);
  opacity: 0; transition: opacity 0.3s ease; z-index: -1;
}
.program-card:hover { box-shadow: var(--shadow-glow); transform: translateY(-5px); }
.program-card:hover::after { opacity: 1; }
.program-card .pc-band { height: 5px; border-radius: 4px; background: var(--hero-gradient); margin-bottom: 12px; flex: 0 0 auto; }
.program-card .pc-title { margin: 0 0 4px; font-size: 15px; min-height: 40px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.pc-meta { font-size: 12px; color: var(--text-muted); margin-bottom: 12px; flex: 0 0 auto; }
.pc-stats { display: flex; gap: 14px; margin-bottom: 10px; flex: 0 0 auto; }
.pc-stat { text-align: left; }
.pc-stat .val { font-weight: 800; font-size: 16px; }
.pc-stat .lbl { font-size: 11px; color: var(--text-muted); }
.pc-footer { margin-top: auto; padding-top: 6px; }

/* Table */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--surface); }
table.data-table { width: 100%; border-collapse: collapse; min-width: 900px; font-size: 13.5px; }
table.data-table th {
  text-align: left; padding: 12px 14px; background: var(--surface-2);
  font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.4px; color: var(--text-muted);
  border-bottom: 1px solid var(--border); white-space: nowrap; position: sticky; top: 0; cursor: pointer; user-select: none;
}
table.data-table th.sortable:hover { color: var(--text-primary); }
table.data-table td { padding: calc(12px * var(--density)) 14px; border-bottom: 1px solid var(--border); vertical-align: middle; height: 52px; box-sizing: border-box; }
table.data-table tbody tr { transition: background 0.15s ease, box-shadow 0.15s ease; }
table.data-table tbody tr:hover { background: var(--surface-2); box-shadow: inset 3px 0 0 var(--primary), 0 4px 14px var(--primary-glow); position: relative; z-index: 1; }
table.data-table tbody tr:last-child td { border-bottom: none; }
.cell-name { font-weight: 700; }
.cell-sub { font-size: 12px; color: var(--text-muted); }
.row-actions { display: flex; gap: 6px; white-space: nowrap; }
.nowrap-cell { white-space: nowrap; max-width: 220px; overflow: hidden; text-overflow: ellipsis; }
.row-flag-dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--danger); margin-right: 7px; vertical-align: middle; flex: 0 0 auto; }

/* Toolbar */
.toolbar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 14px;
}
.toolbar-search { position: relative; flex: 1; min-width: 200px; max-width: 320px; }
.toolbar-search input { width: 100%; padding: 9px 12px 9px 34px; border-radius: 9px; border: 1px solid var(--border); background: var(--surface); font-size: 13.5px; }
.toolbar-search svg { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); width: 15px; height: 15px; color: var(--text-muted); }

select, .input {
  padding: 9px 12px; border-radius: 9px; border: 1px solid var(--border); background: var(--surface); font-size: 13.5px; color: var(--text-primary);
}
.btn {
  padding: 10px 16px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface);
  cursor: pointer; font-size: 13.5px; font-weight: 600; display: inline-flex; align-items: center; gap: 7px;
  transition: background 0.18s ease, transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}
.btn:hover { background: var(--surface-3); transform: translateY(-1px); box-shadow: var(--shadow-sm); }
.btn svg { width: 15px; height: 15px; }
.btn.btn-blue {
  background: var(--hero-gradient); border-color: transparent; color: #fff;
  box-shadow: 0 6px 18px -6px var(--primary-glow);
}
.btn.btn-blue:hover { transform: translateY(-2px); box-shadow: 0 12px 26px -6px var(--primary-glow); }
.btn.btn-ghost-danger { color: var(--danger); }

.filter-panel {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(160px,1fr)); gap: 10px;
  padding: 14px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface-2); margin-bottom: 14px;
}
.filter-panel label { font-size: 11.5px; color: var(--text-muted); display: block; margin-bottom: 4px; }
.filter-panel select, .filter-panel input { width: 100%; }

.pagination { display: flex; align-items: center; justify-content: space-between; margin-top: 14px; font-size: 13px; color: var(--text-secondary); flex-wrap: wrap; gap: 10px; }
.pagination-controls { display: flex; gap: 6px; }
.page-btn { width: 32px; height: 32px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface); cursor: pointer; font-size: 13px; }
.page-btn.active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* Mobile card replacement for tables — reused by Customers, Orders, Enrollments */
.customer-cards, .record-cards { display: none; flex-direction: column; gap: 12px; }
.customer-card, .record-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 14px; box-shadow: var(--shadow-sm);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.customer-card:hover, .record-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-glow); }
.cc-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.cc-name { font-weight: 700; font-size: 14.5px; }
.cc-sub { font-size: 12.5px; color: var(--text-muted); margin-top: 2px; }
.cc-badges { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; }
.cc-footer { margin-top: 12px; display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
.cc-row { display: flex; justify-content: space-between; gap: 10px; font-size: 12.5px; padding: 3px 0; }
.cc-row .cc-row-k { color: var(--text-muted); }
.cc-row .cc-row-v { font-weight: 600; text-align: right; }

@media (max-width: 900px) {
  .table-wrap.responsive-to-cards { display: none; }
  .customer-cards.responsive-to-cards, .record-cards.responsive-to-cards { display: flex; }
}

/* Drawer / Modal */
.overlay-scrim { position: fixed; inset: 0; background: rgba(2,10,25,0.5); z-index: 60; display: none; }
.overlay-scrim.open { display: block; }
.drawer {
  position: fixed; top: 0; right: 0; height: 100vh; width: 460px; max-width: 100vw;
  background: var(--surface); z-index: 61; box-shadow: var(--shadow-lg);
  transform: translateX(100%); transition: transform 0.25s ease;
  display: flex; flex-direction: column;
}
.drawer.open { transform: translateX(0); }
@media (max-width: 700px) { .drawer { width: 100vw; } }
.drawer-header { padding: 18px 20px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.drawer-header h2 { margin: 0; font-size: 16px; }
.drawer-body { flex: 1; overflow-y: auto; padding: 20px; }
.drawer-footer { padding: 16px 20px; border-top: 1px solid var(--border); display: flex; gap: 10px; flex-wrap: wrap; }

.modal-center-wrap { position: fixed; inset: 0; z-index: 61; display: none; align-items: center; justify-content: center; padding: 20px; }
.modal-center-wrap.open { display: flex; }
.modal-box {
  background: var(--surface); border-radius: var(--radius-lg); width: 560px; max-width: 100%;
  max-height: 90vh; overflow-y: auto; box-shadow: var(--shadow-lg);
}
.modal-header { padding: 20px 22px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; }
.modal-header h2 { margin: 0; font-size: 16.5px; }
.modal-body { padding: 22px; }
.modal-footer { padding: 16px 22px; border-top: 1px solid var(--border); display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 560px) { .form-grid { grid-template-columns: 1fr; } }
.form-field { display: flex; flex-direction: column; gap: 6px; }
.form-field.full { grid-column: 1 / -1; }
.form-field label { font-size: 12.5px; font-weight: 600; color: var(--text-secondary); }
.form-field input, .form-field select, .form-field textarea {
  padding: 10px 12px; border-radius: 9px; border: 1px solid var(--border); background: var(--surface); font-size: 13.5px; color: var(--text-primary);
}
.form-field textarea { resize: vertical; min-height: 70px; }
.form-error { font-size: 12px; color: var(--danger); display: none; }
.form-field.invalid input, .form-field.invalid select { border-color: var(--danger); }
.form-field.invalid .form-error { display: block; }
.field-hint { font-size: 11.5px; color: var(--text-muted); }

.dup-warning {
  background: var(--warn-bg); color: var(--warn); border: 1px solid rgba(161,98,7,0.25);
  border-radius: 10px; padding: 12px 14px; font-size: 13px; margin-bottom: 12px; display: none;
}
.dup-warning.show { display: block; }

/* Profile blocks in drawer */
.profile-row { display: flex; justify-content: space-between; padding: 9px 0; border-bottom: 1px solid var(--border); font-size: 13.5px; gap: 10px; }
.profile-row:last-child { border-bottom: none; }
.profile-row .pr-k { color: var(--text-muted); }
.profile-row .pr-v { font-weight: 600; text-align: right; }

.mini-card { border: 1px solid var(--border); border-radius: 12px; padding: 14px; margin-bottom: 10px; background: var(--surface-2); transition: transform 0.2s ease, box-shadow 0.2s ease; }
.mini-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.mini-card-title { font-weight: 700; font-size: 13.5px; margin-bottom: 8px; display: flex; justify-content: space-between; align-items: center; }

/* Exceptions */
.exception-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px,1fr)); gap: 16px; align-items: stretch; grid-auto-rows: 1fr; }
.exception-card {
  border-radius: var(--radius-md); border: 1px solid var(--border); background: var(--surface); padding: 16px;
  box-shadow: var(--shadow-sm); display: flex; flex-direction: column; height: 100%;
  transition: transform 0.25s ease, box-shadow 0.25s ease;
}
.exception-card:hover { transform: translateY(-5px); box-shadow: var(--shadow-glow); }
.exception-card .ec-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; gap: 8px; }
.exception-card h3 { margin: 0; font-size: 14px; line-height: 1.3; }
.exception-card .ec-count { font-size: 28px; font-weight: 800; margin: 2px 0 10px; }
.ec-detail-row { display: flex; flex-direction: column; gap: 2px; padding: 8px 0; border-top: 1px solid var(--border); font-size: 12.5px; }
.ec-detail-row:first-of-type { border-top: none; }
.ec-detail-label { font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.4px; color: var(--text-muted); font-weight: 700; }
.ec-detail-value { color: var(--text-secondary); line-height: 1.4; }
.ec-meta-row { display: flex; justify-content: space-between; font-size: 11.5px; color: var(--text-muted); margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--border); }

/* Import dropzone */
.dropzone {
  border: 2px dashed var(--border); border-radius: var(--radius-md); padding: 40px 20px;
  text-align: center; background: var(--surface-2); cursor: pointer;
}
.dropzone.dragover { border-color: var(--primary); background: var(--primary-bg); }
.dropzone svg { width: 40px; height: 40px; color: var(--primary); margin-bottom: 10px; }

/* Toasts */
.toast-container { position: fixed; bottom: 20px; right: 20px; z-index: 100; display: flex; flex-direction: column; gap: 10px; }
@media (max-width: 600px) { .toast-container { left: 16px; right: 16px; } }
.toast {
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow-lg);
  padding: 13px 16px; display: flex; align-items: center; gap: 10px; min-width: 260px;
  animation: toastIn 0.2s ease;
}
@keyframes toastIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
.toast .t-icon { width: 22px; height: 22px; border-radius: 50%; display: flex; align-items: center; justify-content: center; flex: 0 0 auto; }
.toast.success .t-icon { background: var(--ok-bg); color: var(--ok); }
.toast.error .t-icon { background: var(--danger-bg); color: var(--danger); }
.toast.info .t-icon { background: var(--info-bg); color: var(--info); }
.toast .t-msg { font-size: 13.5px; font-weight: 600; }

/* Settings */
.settings-grid { display: grid; grid-template-columns: repeat(2,1fr); gap: 16px; }
@media (max-width: 700px) { .settings-grid { grid-template-columns: 1fr; } }
.setting-row { display: flex; align-items: center; justify-content: space-between; padding: 12px 0; border-bottom: 1px solid var(--border); }
.setting-row:last-child { border-bottom: none; }
.option-chip-group { display: flex; gap: 8px; flex-wrap: wrap; }
.option-chip { padding: 7px 13px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); font-size: 12.5px; cursor: pointer; font-weight: 600; }
.option-chip.active { background: var(--primary); border-color: var(--primary); color: #fff; }

.switch { position: relative; width: 44px; height: 24px; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider-toggle {
  position: absolute; cursor: pointer; inset: 0; background: var(--surface-3); border-radius: 999px; transition: 0.2s;
}
.slider-toggle::before { content: ''; position: absolute; height: 18px; width: 18px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: 0.2s; box-shadow: 0 1px 3px rgba(0,0,0,0.3); }
.switch input:checked + .slider-toggle { background: var(--primary); }
.switch input:checked + .slider-toggle::before { transform: translateX(20px); }

.empty-state { text-align: center; padding: 50px 20px; color: var(--text-muted); }
.empty-state svg { width: 46px; height: 46px; margin-bottom: 12px; opacity: 0.6; }
.empty-state h3 { font-size: 15px; color: var(--text-primary); margin-bottom: 4px; }

.demo-tag {
  display: inline-flex; align-items: center; gap: 5px; font-size: 10.5px; font-weight: 700;
  background: var(--badge-amber-bg); color: var(--badge-amber-fg); border: 1px solid rgba(217,119,6,0.3);
  padding: 3px 9px; border-radius: 999px; letter-spacing: 0.3px;
}

.audit-item { display: flex; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--border); }
.audit-item:last-child { border-bottom: none; }
.audit-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--primary); margin-top: 6px; flex: 0 0 auto; }
.audit-text { font-size: 13.5px; }
.audit-meta { font-size: 11.5px; color: var(--text-muted); margin-top: 2px; }

.tab-bar { display: flex; gap: 8px; border-bottom: 1px solid var(--border); margin-bottom: 16px; overflow-x: auto; }
.tab-btn { padding: 10px 4px; margin-right: 18px; border: none; background: none; cursor: pointer; font-size: 13.5px; font-weight: 600; color: var(--text-muted); border-bottom: 2px solid transparent; white-space: nowrap; }
.tab-btn.active { color: var(--primary); border-color: var(--primary); }

::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 999px; }

input::placeholder, textarea::placeholder { color: var(--text-muted); opacity: 1; }
input, textarea, select { color: var(--text-primary); }
select option { color: #172033; background: #fff; }

/* =========================================================
   Mobile & tablet fit-and-finish
   Layout building blocks (sidebar drawer, kpi-grid, grid-2, table→card
   swap, drawer/modal width) already respond above. This section tightens
   remaining spacing, touch targets, and text so every screen size — phone,
   small tablet, large tablet — feels intentionally sized, not just shrunk.
   ========================================================= */

/* Tablet (portrait iPad / small laptop) */
@media (max-width: 1024px) {
  .content { padding: 20px; }
  .program-grid, .exception-grid { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
}

/* Phones (matches the existing 700px breakpoint used elsewhere for icon-only
   buttons, so the topnav's wrapped layout kicks in at the same width those
   buttons already shrink at — no gap where things are half-collapsed) */
@media (max-width: 700px) {
  .topnav {
    height: auto;
    flex-wrap: wrap;
    align-items: center;
    padding: 10px 14px;
    gap: 8px;
    row-gap: 10px;
  }
  .hamburger { order: 1; }
  .topnav-titles { order: 2; flex: 1 1 auto; min-width: 0; overflow: hidden; }
  .topnav-titles .page-title {
    font-size: 15.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  }
  .breadcrumb { display: none; }
  #profileAvatarBtn { order: 3; }

  /* Search is hidden inline by default on phones — a dedicated icon (in the
     icon row below) toggles it open as its own full-width row, so it never
     competes with the page title for space. */
  .topnav-search { display: none; order: 8; flex: 1 1 100%; max-width: none; }
  .topnav-search input { padding: 9px 12px 9px 34px; font-size: 13.5px; }
  .topnav.search-open .topnav-search { display: flex; }

  .topnav-spacer { display: none; }
  .topnav-date { display: none; }
  .notif-wrap { order: 4; }
  #themeToggleBtn { order: 5; }
  #addCustomerTopBtn { order: 6; }
  .mobile-search-btn { display: flex; order: 7; margin-left: auto; }

  .content { padding: 14px; }
  .demo-tag { margin-bottom: 10px; }

  .hero-banner { padding: 22px 18px; }
  .hero-banner h1 { font-size: 19px; }
  .hero-meta { gap: 18px; }
  .hero-birthday-widget { min-width: 0; flex: 1 1 100%; padding: 12px 16px; }

  .kpi-value { font-size: 22px; }
  .card { padding: 16px; }

  .program-grid, .exception-grid { grid-template-columns: 1fr; }
  .map-cluster-grid, .schematic-map { gap: 10px; }
  .leaflet-map-el { height: 280px; border-radius: 12px; }
  .ranking-list { max-height: 320px; }

  .section-header { flex-direction: column; align-items: flex-start; gap: 4px; }
  .toolbar { gap: 8px; }
  .toolbar-search { max-width: none; width: 100%; flex-basis: 100%; }
  .filter-panel { grid-template-columns: 1fr 1fr; }

  /* Comfortable touch targets */
  .icon-btn, .avatar-btn, .notif-red-dot ~ * { min-width: 40px; min-height: 40px; }
  .btn, .btn-mini, .page-btn, .option-chip { min-height: 38px; }
  .nav-item { min-height: 44px; }

  .modal-header, .drawer-header { padding: 14px 16px; }
  .modal-body, .drawer-body { padding: 16px; }
  .modal-footer, .drawer-footer { padding: 12px 16px; flex-direction: column; }
  .modal-footer .btn, .drawer-footer .btn { width: 100%; justify-content: center; }

  .bday-row { flex-direction: column; align-items: flex-start; gap: 8px; }
  .bday-action-select { width: 100%; }

  .settings-grid { gap: 12px; }
  .setting-row { flex-wrap: wrap; gap: 8px; }

  /* Notification dropdown: anchor to viewport, not the (now-wrapped) bell icon,
     so it can never overflow off-screen or get clipped mid-word. */
  .notif-dropdown {
    position: fixed; left: 12px; right: 12px; top: 12px;
    width: auto; max-width: none; max-height: 80vh;
  }
  .notif-dropdown-list { max-height: calc(80vh - 50px); }

  /* Hero banner: shrink the decorative glow blobs so they never wash out the
     title text on narrow cards. */
  .hero-banner::before { width: 140px; height: 140px; top: -60px; right: -40px; }
  .hero-banner::after { width: 100px; height: 100px; bottom: -40px; }
}

/* Very small phones */
@media (max-width: 380px) {
  .hero-meta-item .hm-val { font-size: 17px; }
  .kpi-grid { gap: 10px; }
  .filter-panel { grid-template-columns: 1fr; }
}
