/* ============================================================
   TBS CRM — Premium Design System v2.0
   Font: Inter (Google Fonts)
   ============================================================ */

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

/* ── Design Tokens ─────────────────────────────────────────── */
:root {
  /* Sidebar palette */
  --sb-bg:        #06091a;
  --sb-surface:   #0d1226;
  --sb-border:    rgba(99,102,241,0.15);
  --sb-text:      #94a3c8;
  --sb-text-hover:#e2e8f8;
  --sb-active-bg: rgba(99,102,241,0.18);
  --sb-active-border: #6366f1;
  --sb-width:     260px;

  /* Brand / accent */
  --indigo:       #6366f1;
  --violet:       #8b5cf6;
  --accent-grad:  linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
  --accent-glow:  0 0 24px rgba(99,102,241,0.35);

  /* Content area */
  --bg:           #f1f5fb;
  --surface:      #ffffff;
  --surface-2:    #f8faff;
  --border:       #e2e8f3;
  --text:         #0f172a;
  --text-2:       #334155;
  --muted:        #64748b;

  /* Semantic colors */
  --green:        #10b981;
  --green-bg:     #d1fae5;
  --yellow:       #f59e0b;
  --yellow-bg:    #fef3c7;
  --red:          #ef4444;
  --red-bg:       #fee2e2;
  --blue:         #3b82f6;
  --blue-bg:      #dbeafe;
  --purple:       #8b5cf6;
  --purple-bg:    #ede9fe;
  --teal:         #14b8a6;
  --teal-bg:      #ccfbf1;

  /* Shadows */
  --shadow-xs:    0 1px 3px rgba(15,23,42,0.06), 0 1px 2px rgba(15,23,42,0.04);
  --shadow-sm:    0 4px 12px rgba(15,23,42,0.07), 0 1px 3px rgba(15,23,42,0.04);
  --shadow-md:    0 8px 24px rgba(15,23,42,0.10), 0 2px 6px rgba(15,23,42,0.06);
  --shadow-lg:    0 20px 48px rgba(15,23,42,0.14), 0 4px 12px rgba(15,23,42,0.07);
  --shadow-glow:  0 8px 32px rgba(99,102,241,0.22);

  /* Spacing & shape */
  --radius-sm:    8px;
  --radius:       14px;
  --radius-lg:    20px;
  --radius-xl:    28px;
}

/* ── Reset & Base ───────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

/* ── Utility ────────────────────────────────────────────────── */
.container  { width: min(1280px, 96%); margin: 0 auto; }
.section    { padding: 20px 0 48px; }
.row        { display: flex; gap: 12px; }
.between    { justify-content: space-between; }
.center     { align-items: center; }
.flex-wrap  { flex-wrap: wrap; }
.flex-1     { flex: 1; }
.text-muted { color: var(--muted); }
.text-sm    { font-size: 12px; }
.fw-600     { font-weight: 600; }
.fw-700     { font-weight: 700; }
.mt-0       { margin-top: 0 !important; }
.mb-0       { margin-bottom: 0 !important; }
.mb-16      { margin-bottom: 16px; }

/* ── Keyframes ──────────────────────────────────────────────── */
@keyframes fadeSlideIn {
  from { opacity: 0; transform: translateY(18px); }
  to   { opacity: 1; transform: translateY(0); }
}

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

@keyframes shimmer {
  0%   { background-position: -200% center; }
  100% { background-position: 200% center; }
}

@keyframes pulse-ring {
  0%   { transform: scale(1); opacity: 1; }
  70%  { transform: scale(1.8); opacity: 0; }
  100% { transform: scale(1.8); opacity: 0; }
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

@keyframes ripple-anim {
  to { transform: scale(4); opacity: 0; }
}

@keyframes alertIn {
  from { opacity: 0; transform: translateY(-16px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes sidebarSlideIn {
  from { transform: translateX(-100%); }
  to   { transform: translateX(0); }
}

@keyframes gradientShift {
  0%   { background-position: 0% 50%; }
  50%  { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

/* ── Sidebar ────────────────────────────────────────────────── */
.app-shell .sidebar {
  width: var(--sb-width);
  height: 100vh;
  position: fixed;
  top: 0; left: 0;
  z-index: 120;
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  background: linear-gradient(180deg, var(--sb-bg) 0%, var(--sb-surface) 100%);
  border-right: 1px solid var(--sb-border);
  scrollbar-width: thin;
  scrollbar-color: rgba(99,102,241,0.2) transparent;
}

.app-shell .sidebar::-webkit-scrollbar { width: 3px; }
.app-shell .sidebar::-webkit-scrollbar-thumb { background: rgba(99,102,241,0.25); border-radius: 99px; }

/* Brand / Logo area */
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 22px 18px 16px;
  border-bottom: 1px solid var(--sb-border);
  text-decoration: none;
  flex-shrink: 0;
}

.brand-icon {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: var(--accent-grad);
  display: grid;
  place-items: center;
  font-size: 18px;
  flex-shrink: 0;
  box-shadow: var(--accent-glow);
}

.brand-text { flex: 1; overflow: hidden; }
.brand-text strong {
  display: block;
  font-size: 13px;
  font-weight: 800;
  color: #fff;
  letter-spacing: 0.5px;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.brand-text span {
  font-size: 10px;
  color: var(--sb-text);
  letter-spacing: 0.8px;
  text-transform: uppercase;
}

/* Sidebar nav */
.sidebar-nav { flex: 1; padding: 12px 0; }

.menu { list-style: none; padding: 0 10px; margin: 0; }

.menu-section-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: rgba(148,163,200,0.45);
  padding: 16px 14px 6px;
  pointer-events: none;
}

.menu li { margin: 2px 0; }

.menu li > a,
.menu-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: 10px;
  text-decoration: none;
  color: var(--sb-text);
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.18s ease, color 0.18s ease, padding-left 0.18s ease;
  border-left: 3px solid transparent;
  position: relative;
  overflow: hidden;
  width: 100%;
  background: transparent;
  border-top: none;
  border-right: none;
  border-bottom: none;
  text-align: left;
}

.menu li > a:hover,
.menu-toggle:hover {
  background: rgba(99,102,241,0.10);
  color: var(--sb-text-hover);
  border-left-color: rgba(99,102,241,0.4);
  padding-left: 17px;
}

.menu li.active > a,
.menu-group.open > .menu-toggle {
  background: var(--sb-active-bg);
  color: #fff;
  border-left-color: var(--sb-active-border);
  font-weight: 600;
}

.menu li.active > a { box-shadow: inset 0 0 20px rgba(99,102,241,0.08); }

/* Menu icon */
.menu-icon {
  width: 20px;
  height: 20px;
  display: grid;
  place-items: center;
  font-size: 16px;
  flex-shrink: 0;
  opacity: 0.8;
}

.menu li.active .menu-icon,
.menu-group.open .menu-toggle .menu-icon { opacity: 1; }

/* Caret */
.caret {
  margin-left: auto;
  font-size: 11px;
  opacity: 0.6;
  transition: transform 0.2s ease;
  flex-shrink: 0;
}
.menu-group.open .caret { transform: rotate(90deg); opacity: 1; }

/* Submenu */
.submenu {
  list-style: none;
  padding: 4px 0 4px 14px;
  margin: 0;
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.28s cubic-bezier(0.4,0,0.2,1);
}
.menu-group.open .submenu { max-height: 600px; }

.submenu li { margin: 1px 0; }

.submenu li a {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 8px;
  color: rgba(148,163,200,0.8);
  font-size: 13px;
  text-decoration: none;
  transition: background 0.15s, color 0.15s;
  position: relative;
}

.submenu li a::before {
  content: '';
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: rgba(99,102,241,0.4);
  flex-shrink: 0;
  transition: background 0.15s;
}

.submenu li a:hover,
.submenu li.active a {
  background: rgba(99,102,241,0.12);
  color: #c4c9f8;
}
.submenu li a:hover::before,
.submenu li.active a::before { background: var(--indigo); }

/* Sidebar bottom user card */
.sidebar-user {
  border-top: 1px solid var(--sb-border);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.sidebar-user .user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: var(--accent-grad);
  display: grid;
  place-items: center;
  font-size: 13px;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
  box-shadow: var(--accent-glow);
}

.sidebar-user .user-info { flex: 1; overflow: hidden; }
.sidebar-user .user-info .uname {
  font-size: 13px;
  font-weight: 600;
  color: #e2e8f0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sidebar-user .user-info .urole {
  font-size: 10px;
  color: var(--sb-text);
  text-transform: capitalize;
}

.sidebar-user .logout-btn {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  color: var(--sb-text);
  text-decoration: none;
  transition: background 0.15s, color 0.15s;
  font-size: 16px;
  flex-shrink: 0;
}
.sidebar-user .logout-btn:hover { background: rgba(239,68,68,0.15); color: #ef4444; }

/* ── Main Wrap ──────────────────────────────────────────────── */
.main-wrap {
  margin-left: var(--sb-width);
  min-height: 100vh;
  padding: 12px 16px 16px;
  animation: fadeSlideIn 0.35s ease both;
}

/* ── Topbar ─────────────────────────────────────────────────── */
.topbar {
  position: sticky;
  top: 8px;
  z-index: 90;
  margin-bottom: 20px;
  background: rgba(255,255,255,0.88);
  backdrop-filter: blur(16px) saturate(180%);
  -webkit-backdrop-filter: blur(16px) saturate(180%);
  border: 1px solid rgba(226,232,240,0.8);
  border-radius: 16px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.2s;
}

.topbar.scrolled { box-shadow: var(--shadow-md); }

.topbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 16px;
}

.topbar-left { display: flex; align-items: center; gap: 12px; }
.topbar-right { display: flex; align-items: center; gap: 8px; }

/* Sidebar toggle button */
.sidebar-toggle {
  display: none;
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: var(--accent-grad);
  border: none;
  color: #fff;
  cursor: pointer;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  font-weight: 700;
  flex-shrink: 0;
  box-shadow: var(--shadow-glow);
  transition: filter 0.15s;
  line-height: 1;
  padding: 0;
}
.sidebar-toggle:hover { filter: brightness(1.1); }

/* ── Profile Dropdown ───────────────────────────────────────── */
.profile-dropdown {
  position: fixed;
  top: 66px;
  right: 16px;
  width: 300px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  z-index: 200;
  opacity: 0;
  transform: translateY(-12px) scale(0.97);
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  overflow: hidden;
}

.profile-dropdown.open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

/* Dropdown header */
.pd-header {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 20px 18px 16px;
  background: linear-gradient(135deg, rgba(99,102,241,0.06), rgba(139,92,246,0.06));
}

.pd-avatar {
  width: 52px;
  height: 52px;
  border-radius: 14px;
  background: var(--accent-grad);
  display: grid;
  place-items: center;
  font-size: 20px;
  font-weight: 800;
  color: #fff;
  flex-shrink: 0;
  box-shadow: var(--accent-glow);
  letter-spacing: -0.5px;
}

.pd-info { flex: 1; overflow: hidden; }

.pd-name {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pd-email {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pd-role-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
}

.pd-divider {
  height: 1px;
  background: var(--border);
}

/* Dropdown links */
.pd-links {
  list-style: none;
  padding: 8px 0;
  margin: 0;
}

.pd-links li a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 18px;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--text-2);
  text-decoration: none;
  transition: background 0.14s, color 0.14s;
}

.pd-links li a:hover {
  background: rgba(99,102,241,0.06);
  color: var(--indigo);
}

.pd-link-icon {
  font-size: 18px;
  width: 22px;
  text-align: center;
  flex-shrink: 0;
}

.pd-links li.pd-danger a {
  color: var(--red);
}

.pd-links li.pd-danger a:hover {
  background: rgba(239,68,68,0.07);
  color: #dc2626;
}

.pd-footer {
  border-top: 1px solid var(--border);
  padding: 10px 18px;
  font-size: 11px;
  color: var(--muted);
  background: var(--surface-2);
  text-align: center;
}

/* ── Notification Badge on Bell ─────────────────────────────── */
.notif-badge {
  position: absolute;
  top: -5px;
  right: -5px;
  min-width: 18px;
  height: 18px;
  padding: 0 4px;
  border-radius: 999px;
  background: var(--red);
  color: #fff;
  font-size: 10px;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid #fff;
  line-height: 1;
  letter-spacing: -0.3px;
  animation: pulse-ring 2s ease-out infinite;
}

/* ── Notification Dropdown ──────────────────────────────────── */
.notif-dropdown {
  position: fixed;
  top: 66px;
  right: 16px;
  width: 360px;
  max-height: 520px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  z-index: 201;
  opacity: 0;
  transform: translateY(-14px) scale(0.97);
  pointer-events: none;
  transition: opacity 0.22s ease, transform 0.22s ease;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.notif-dropdown.open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

/* Dropdown header */
.nd-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(135deg, rgba(99,102,241,0.05), rgba(139,92,246,0.05));
  flex-shrink: 0;
}

.nd-header-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

.nd-title-icon { font-size: 18px; }

.nd-header h4 {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  margin: 0;
}

.nd-count-pill {
  font-size: 11px;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 999px;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  color: #fff;
}

.nd-count-zero {
  background: var(--border);
  color: var(--muted);
}

/* Notification list */
.nd-list {
  list-style: none;
  padding: 6px 0;
  margin: 0;
  overflow-y: auto;
  flex: 1;
  scrollbar-width: thin;
  scrollbar-color: rgba(99,102,241,0.2) transparent;
}

.nd-list::-webkit-scrollbar { width: 4px; }
.nd-list::-webkit-scrollbar-thumb { background: rgba(99,102,241,0.2); border-radius: 99px; }

.nd-item {
  animation: fadeSlideIn 0.3s ease both;
}

.nd-item a {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 16px;
  text-decoration: none;
  transition: background 0.14s;
  border-left: 3px solid transparent;
}

.nd-item a:hover { background: rgba(99,102,241,0.04); }

/* Type border colors */
.nd-type-success a { border-left-color: var(--green); }
.nd-type-warning a { border-left-color: var(--yellow); }
.nd-type-danger  a { border-left-color: var(--red); }
.nd-type-info    a { border-left-color: var(--blue); }

/* Icon wraps */
.nd-icon-wrap {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  font-size: 18px;
  flex-shrink: 0;
}

.nd-icon-success { background: var(--green-bg); }
.nd-icon-warning { background: var(--yellow-bg); }
.nd-icon-danger  { background: var(--red-bg); }
.nd-icon-info    { background: var(--blue-bg); }

/* Content */
.nd-content { flex: 1; min-width: 0; }

.nd-item-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.3;
  margin-bottom: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.nd-item-desc {
  font-size: 11.5px;
  color: var(--muted);
  line-height: 1.4;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Time badge */
.nd-time-badge {
  font-size: 10px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
  white-space: nowrap;
  flex-shrink: 0;
  align-self: flex-start;
  margin-top: 2px;
}

.nd-time-success { background: var(--green-bg); color: #065f46; }
.nd-time-warning { background: var(--yellow-bg); color: #92400e; }
.nd-time-danger  { background: var(--red-bg); color: #991b1b; }
.nd-time-info    { background: var(--blue-bg); color: #1e40af; }

/* Empty state */
.nd-empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 36px 20px;
  text-align: center;
}

.nd-empty-icon { font-size: 40px; margin-bottom: 10px; }
.nd-empty-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  margin: 0 0 4px;
}
.nd-empty-sub { font-size: 12px; color: var(--muted); margin: 0; }

/* Footer */
.nd-footer {
  border-top: 1px solid var(--border);
  padding: 10px 18px;
  text-align: center;
  background: var(--surface-2);
  flex-shrink: 0;
}

.nd-footer-link {
  font-size: 12px;
  font-weight: 600;
  color: var(--indigo);
  text-decoration: none;
  transition: color 0.15s;
}

.nd-footer-link:hover { color: var(--violet); }

/* Notification backdrop */
.nd-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 200;
}
.nd-backdrop.active { display: block; }

/* On mobile: wider notification panel */
@media (max-width: 900px) {
  .notif-dropdown {
    width: calc(100vw - 20px);
    right: 10px;
    top: 60px;
  }
}

/* Dropdown backdrop */
.pd-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 199;
}

.pd-backdrop.active { display: block; }

/* Notif-btn as clickable button */
.notif-btn {
  position: relative;
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 18px;
  transition: background 0.15s, border-color 0.15s, box-shadow 0.15s;
  color: var(--text-2);
  flex-shrink: 0;
  padding: 0;
}
.notif-btn:hover,
.notif-btn.active {
  background: #eef2ff;
  border-color: var(--indigo);
  box-shadow: 0 0 0 3px rgba(99,102,241,0.12);
}

.notif-dot {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--red);
  border: 2px solid #fff;
}
.notif-dot::before {
  content: '';
  position: absolute;
  top: -3px; left: -3px; right: -3px; bottom: -3px;
  border-radius: 50%;
  background: var(--red);
  animation: pulse-ring 1.8s ease-out infinite;
}

/* Page title */
.topbar-title {
  display: flex;
  flex-direction: column;
}
.topbar-title h4 {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.2;
  margin: 0;
}
.topbar-breadcrumb {
  font-size: 11px;
  color: var(--muted);
}

/* Mobile brand */
.mobile-brand {
  font-size: 15px;
  font-weight: 800;
  color: var(--text);
  display: none;
  letter-spacing: -0.3px;
}

/* Notification button */
.notif-btn {
  position: relative;
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  display: grid;
  place-items: center;
  cursor: pointer;
  font-size: 16px;
  transition: background 0.15s, border-color 0.15s;
  text-decoration: none;
  color: var(--text-2);
}
.notif-btn:hover { background: #eef2ff; border-color: var(--indigo); }

.notif-dot {
  position: absolute;
  top: 7px;
  right: 7px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--red);
  border: 2px solid #fff;
}
.notif-dot::before {
  content: '';
  position: absolute;
  top: -2px; left: -2px; right: -2px; bottom: -2px;
  border-radius: 50%;
  background: var(--red);
  animation: pulse-ring 1.8s ease-out infinite;
}

/* User pill */
.user-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 12px 5px 6px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.user-pill:hover { border-color: var(--indigo); background: #eef2ff; }

.avatar-pill {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--accent-grad);
  display: grid;
  place-items: center;
  font-size: 11px;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}

.user-pill-name {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-2);
  line-height: 1.1;
}
.user-pill-role {
  font-size: 10px;
  color: var(--muted);
  text-transform: capitalize;
}

/* ── Headings ───────────────────────────────────────────────── */
h1 { font-size: 22px; font-weight: 800; color: var(--text); margin-bottom: 18px; letter-spacing: -0.3px; }
h2 { font-size: 16px; font-weight: 700; color: var(--text); margin-bottom: 12px; }
h3 { font-size: 14px; font-weight: 600; color: var(--text-2); }

/* ── Cards ──────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-xs);
  padding: 20px;
  margin-bottom: 20px;
  transition: box-shadow 0.2s ease, transform 0.2s ease;
  animation: fadeSlideIn 0.4s ease both;
}

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

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

.card-header h2, .card-header h3 { margin: 0; }

/* ── KPI Cards ──────────────────────────────────────────────── */
.grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin-bottom: 20px; }

.kpi {
  position: relative;
  overflow: hidden;
  padding: 20px 20px 18px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-xs);
  transition: box-shadow 0.2s ease, transform 0.2s ease;
  animation: fadeSlideIn 0.4s ease both;
  text-decoration: none;
  display: block;
}

.kpi:hover {
  box-shadow: var(--shadow-glow);
  transform: translateY(-3px);
  border-color: rgba(99,102,241,0.3);
}

.kpi::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: var(--accent-grad);
}

.kpi-icon {
  position: absolute;
  top: 16px; right: 16px;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: linear-gradient(135deg, rgba(99,102,241,0.12), rgba(139,92,246,0.12));
  display: grid;
  place-items: center;
  font-size: 20px;
}

.kpi h3 {
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  margin: 0 0 8px;
}

.kpi p {
  font-size: 28px;
  font-weight: 800;
  color: var(--text);
  line-height: 1;
  margin: 0;
  letter-spacing: -0.5px;
}

.kpi .kpi-sub {
  font-size: 11px;
  color: var(--muted);
  margin-top: 6px;
}

/* KPI color variants */
.kpi.kpi-green::before { background: linear-gradient(135deg, #10b981, #34d399); }
.kpi.kpi-green .kpi-icon { background: rgba(16,185,129,0.1); }
.kpi.kpi-green p { color: #065f46; }

.kpi.kpi-yellow::before { background: linear-gradient(135deg, #f59e0b, #fbbf24); }
.kpi.kpi-yellow .kpi-icon { background: rgba(245,158,11,0.1); }

.kpi.kpi-red::before { background: linear-gradient(135deg, #ef4444, #f87171); }
.kpi.kpi-red .kpi-icon { background: rgba(239,68,68,0.1); }

.kpi.kpi-teal::before { background: linear-gradient(135deg, #14b8a6, #2dd4bf); }
.kpi.kpi-teal .kpi-icon { background: rgba(20,184,166,0.1); }

/* ── Grid Layout Helpers ────────────────────────────────────── */
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.grid-5 { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 16px; }

/* ── Forms ──────────────────────────────────────────────────── */
.form-group { margin-bottom: 16px; }

label {
  display: block;
  margin-bottom: 6px;
  font-weight: 600;
  font-size: 12px;
  color: var(--text-2);
  letter-spacing: 0.2px;
}

input, select, textarea {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font: 14px 'Inter', sans-serif;
  background: var(--surface);
  color: var(--text);
  transition: border-color 0.15s, box-shadow 0.15s;
  outline: none;
}

input:focus, select:focus, textarea:focus {
  border-color: var(--indigo);
  box-shadow: 0 0 0 3px rgba(99,102,241,0.14);
}

input::placeholder, textarea::placeholder { color: #94a3b8; }
textarea { min-height: 90px; resize: vertical; }
select { cursor: pointer; }

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }

/* ── Buttons ────────────────────────────────────────────────── */
button, .btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  font: 600 13px 'Inter', sans-serif;
  cursor: pointer;
  transition: filter 0.15s, transform 0.1s, box-shadow 0.15s;
  border: none;
  position: relative;
  overflow: hidden;
  text-decoration: none;
  white-space: nowrap;
}

button[type="submit"], .btn-primary, button:not([class]) {
  background: var(--accent-grad);
  color: #fff;
  box-shadow: 0 4px 14px rgba(99,102,241,0.3);
}

button[type="submit"]:hover, .btn-primary:hover, button:not([class]):hover {
  filter: brightness(1.08);
  box-shadow: 0 6px 20px rgba(99,102,241,0.4);
  transform: translateY(-1px);
}

button[type="submit"]:active, .btn-primary:active { transform: translateY(0); }

.btn-secondary {
  background: var(--surface-2);
  color: var(--text-2);
  border: 1.5px solid var(--border);
  box-shadow: var(--shadow-xs);
}

.btn-secondary:hover { border-color: var(--indigo); color: var(--indigo); background: #eef2ff; }

.btn-danger {
  background: linear-gradient(135deg, #ef4444, #dc2626);
  color: #fff;
  box-shadow: 0 4px 14px rgba(239,68,68,0.3);
}

.btn-danger:hover { filter: brightness(1.08); box-shadow: 0 6px 20px rgba(239,68,68,0.4); }

.btn-success {
  background: linear-gradient(135deg, #10b981, #059669);
  color: #fff;
  box-shadow: 0 4px 14px rgba(16,185,129,0.3);
}

.btn-warning {
  background: linear-gradient(135deg, #f59e0b, #d97706);
  color: #fff;
}

.btn-sm { padding: 6px 12px; font-size: 12px; border-radius: 7px; }
.btn-xs { padding: 4px 9px; font-size: 11px; border-radius: 6px; }
.btn-icon { padding: 8px; min-width: 36px; }

/* Ripple */
.ripple-effect {
  position: absolute;
  border-radius: 50%;
  background: rgba(255,255,255,0.35);
  transform: scale(0);
  animation: ripple-anim 0.6s linear;
  pointer-events: none;
}

/* ── Links ──────────────────────────────────────────────────── */
a { color: var(--indigo); transition: color 0.15s; }
a:hover { color: var(--violet); }

/* ── Tables ─────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; border-radius: var(--radius); border: 1px solid var(--border); }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}

thead { position: sticky; top: 0; z-index: 2; }

th {
  background: var(--surface-2);
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.7px;
  padding: 11px 14px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  color: var(--text-2);
  vertical-align: middle;
}

tbody tr { transition: background 0.12s; }
tbody tr:hover { background: rgba(99,102,241,0.03); }
tbody tr:last-child td { border-bottom: none; }

.table-action-row { display: flex; align-items: center; gap: 6px; }

/* ── Badges / Status Pills ──────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  line-height: 1.4;
  white-space: nowrap;
}

.badge-default  { background: #e2e8f0;       color: #475569; }
.badge-paid     { background: var(--green-bg); color: #065f46; }
.badge-unpaid   { background: var(--red-bg);   color: #991b1b; }
.badge-partial  { background: var(--yellow-bg);color: #92400e; }
.badge-pending  { background: var(--yellow-bg);color: #92400e; }
.badge-approved { background: var(--green-bg); color: #065f46; }
.badge-rejected { background: var(--red-bg);   color: #991b1b; }
.badge-active   { background: var(--blue-bg);  color: #1e40af; }
.badge-inactive { background: #f1f5f9;         color: #64748b; }
.badge-info     { background: var(--blue-bg);  color: #1e40af; }
.badge-purple   { background: var(--purple-bg);color: #5b21b6; }
.badge-teal     { background: var(--teal-bg);  color: #0f766e; }

/* ── Alerts / Flash ─────────────────────────────────────────── */
.alert {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 13px 16px;
  border-radius: var(--radius-sm);
  margin-bottom: 16px;
  font-size: 13px;
  font-weight: 500;
  animation: alertIn 0.3s ease both;
  border-left: 4px solid;
}

.alert.success {
  background: var(--green-bg);
  color: #065f46;
  border-left-color: var(--green);
}

.alert.error {
  background: var(--red-bg);
  color: #991b1b;
  border-left-color: var(--red);
}

.alert.warning {
  background: var(--yellow-bg);
  color: #92400e;
  border-left-color: var(--yellow);
}

.alert.info {
  background: var(--blue-bg);
  color: #1e40af;
  border-left-color: var(--blue);
}

.alert-icon { font-size: 16px; flex-shrink: 0; margin-top: 1px; }

/* ── Login Page ─────────────────────────────────────────────── */
.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, #0a0f1e 0%, #111827 50%, #0d1226 100%);
  padding: 20px;
}

.login-card {
  background: rgba(255,255,255,0.97);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  padding: 40px 36px;
  width: min(440px, 100%);
  animation: fadeSlideIn 0.4s ease both;
}

.login-logo {
  text-align: center;
  margin-bottom: 28px;
}

.login-logo-icon {
  width: 56px;
  height: 56px;
  border-radius: 16px;
  background: var(--accent-grad);
  display: grid;
  place-items: center;
  font-size: 26px;
  margin: 0 auto 12px;
  box-shadow: var(--accent-glow);
}

.login-logo h2 {
  font-size: 20px;
  font-weight: 800;
  color: var(--text);
  margin: 0 0 4px;
}

.login-logo p { font-size: 13px; color: var(--muted); margin: 0; }

/* ── Nav Tab Links ──────────────────────────────────────────── */
.nav {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}

.nav > a {
  text-decoration: none;
  color: var(--muted);
  background: var(--surface-2);
  border: 1px solid var(--border);
  padding: 7px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  transition: all 0.15s;
}

.nav > a:hover, .nav > a.active {
  color: var(--indigo);
  background: #eef2ff;
  border-color: rgba(99,102,241,0.3);
}

/* ── Progress Bars ──────────────────────────────────────────── */
.progress-bar {
  height: 6px;
  background: var(--border);
  border-radius: 99px;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  background: var(--accent-grad);
  border-radius: 99px;
  transition: width 1s cubic-bezier(0.4,0,0.2,1);
}

/* ── Kanban Board ───────────────────────────────────────────── */
.kanban-board { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 14px; }

.kanban-col {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  min-height: 240px;
  overflow: hidden;
}

.kanban-head {
  padding: 12px 14px;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 8px;
}

.kanban-count {
  margin-left: auto;
  background: var(--border);
  border-radius: 99px;
  padding: 2px 8px;
  font-size: 11px;
  color: var(--muted);
}

.kanban-dropzone { min-height: 180px; padding: 10px; display: grid; gap: 10px; align-content: start; }
.kanban-dropzone.drag-over { background: rgba(99,102,241,0.06); }

.task-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 4px solid #94a3b8;
  border-radius: var(--radius-sm);
  padding: 12px;
  cursor: grab;
  transition: box-shadow 0.15s, transform 0.15s;
  box-shadow: var(--shadow-xs);
}

.task-card:hover { box-shadow: var(--shadow-sm); transform: translateY(-1px); }
.task-card.dragging { opacity: 0.5; transform: rotate(2deg); }

.task-title { font-weight: 700; font-size: 13px; margin-bottom: 5px; }
.task-meta  { font-size: 11px; color: var(--muted); margin-top: 3px; }

.task-remark {
  margin-top: 7px;
  font-size: 12px;
  color: var(--text-2);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 8px;
  line-height: 1.4;
}

.task-actions { margin-top: 9px; display: flex; gap: 8px; flex-wrap: wrap; }

.task-card.priority-low    { border-left-color: var(--green); }
.task-card.priority-medium { border-left-color: var(--blue); }
.task-card.priority-high   { border-left-color: var(--yellow); }
.task-card.priority-urgent { border-left-color: var(--red); background: #fff8f8; }

/* ── Stat Summary Row ───────────────────────────────────────── */
.stat-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0,1fr));
  gap: 12px;
  margin-bottom: 20px;
}

.stat-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  text-align: center;
  box-shadow: var(--shadow-xs);
}

.stat-box .stat-num {
  font-size: 24px;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -0.5px;
}

.stat-box .stat-label {
  font-size: 11px;
  color: var(--muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-top: 3px;
}

/* ── Revenue Chart Bars ─────────────────────────────────────── */
.chart-bar {
  border-radius: 8px 8px 0 0 !important;
  background: var(--accent-grad) !important;
  transition: filter 0.15s !important;
}
.chart-bar:hover { filter: brightness(1.12) !important; }

/* ── Activity Feed ──────────────────────────────────────────── */
.activity-list { list-style: none; padding: 0; margin: 0; }

.activity-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}

.activity-item:last-child { border-bottom: none; }

.activity-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--indigo);
  flex-shrink: 0;
  margin-top: 6px;
}

.activity-text { font-size: 13px; color: var(--text-2); flex: 1; }
.activity-time { font-size: 11px; color: var(--muted); white-space: nowrap; }

/* ── Pagination ─────────────────────────────────────────────── */
.pagination {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
  margin-top: 16px;
}

.page-btn {
  min-width: 34px;
  height: 34px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  font-size: 13px;
  font-weight: 600;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-2);
  cursor: pointer;
  text-decoration: none;
  transition: all 0.15s;
}

.page-btn:hover { border-color: var(--indigo); color: var(--indigo); background: #eef2ff; }
.page-btn.active { background: var(--accent-grad); color: #fff; border-color: transparent; box-shadow: 0 4px 12px rgba(99,102,241,0.3); }

/* ── Search & Filter Bar ────────────────────────────────────── */
.search-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.search-input-wrap {
  position: relative;
  flex: 1;
  min-width: 200px;
}

.search-input-wrap input { padding-left: 38px; }

.search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  font-size: 15px;
  pointer-events: none;
}

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

/* ── Typography helpers ─────────────────────────────────────── */
.section-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--muted);
  margin-bottom: 12px;
}

/* ── Loading Spinner ────────────────────────────────────────── */
.spinner {
  width: 20px;
  height: 20px;
  border: 2.5px solid var(--border);
  border-top-color: var(--indigo);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

/* ── Empty State ────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--muted);
}
.empty-state .empty-icon { font-size: 40px; margin-bottom: 12px; }
.empty-state p { font-size: 13px; margin: 0; }

/* ── Tooltip ────────────────────────────────────────────────── */
[data-tooltip] { position: relative; cursor: default; }
[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  background: #0f172a;
  color: #fff;
  font-size: 11px;
  padding: 5px 9px;
  border-radius: 6px;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s;
  z-index: 9999;
}
[data-tooltip]:hover::after { opacity: 1; }

/* ── Overview Panels (Dashboard) ────────────────────────────── */
.overview-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-xs);
  margin-bottom: 20px;
}

.overview-panel-header {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--surface-2);
}

.overview-panel-header h3 { margin: 0; font-size: 13px; font-weight: 700; }

.overview-panel-body { padding: 18px; }

/* ── Glass Card ─────────────────────────────────────────────── */
.glass {
  background: rgba(255,255,255,0.7);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(255,255,255,0.3);
}

/* ── Responsive ─────────────────────────────────────────────── */
@media (max-width: 1180px) {
  .grid   { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .grid-4 { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .grid-5 { grid-template-columns: repeat(3, minmax(0,1fr)); }
  .kanban-board { grid-template-columns: repeat(2, minmax(0,1fr)); }
}

@media (max-width: 900px) {
  :root { --sb-width: 0px; }

  .app-shell .sidebar {
    width: 280px;
    transform: translateX(-100%);
    transition: transform 0.28s cubic-bezier(0.4,0,0.2,1);
    z-index: 999;
    position: fixed;
  }

  .app-shell .sidebar.open,
  .app-shell .sidebar.active,
  body.sidebar-open .sidebar {
    transform: translateX(0) !important;
    box-shadow: 8px 0 48px rgba(6,9,26,0.55);
  }

  .main-wrap { margin-left: 0; padding: 10px 12px 12px; }

  .sidebar-toggle { display: flex !important; }

  .user-pill .user-pill-name,
  .user-pill .user-pill-role { display: none; }

  .mobile-brand { display: block; }
  .topbar-title h4 { display: none; }

  /* Profile dropdown on mobile full-width */
  .profile-dropdown {
    width: calc(100vw - 24px);
    right: 12px;
    top: 60px;
  }
}

@media (max-width: 768px) {
  .form-grid { grid-template-columns: 1fr; }
  .grid-2, .grid-3, .grid-4, .grid-5 { grid-template-columns: 1fr; }
  .kanban-board { grid-template-columns: 1fr; }
  .stat-row { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .topbar-breadcrumb { display: none; }
}

@media (max-width: 500px) {
  .grid, .stat-row { grid-template-columns: 1fr; }
  .topbar-inner { padding: 8px 12px; }
  .login-card { padding: 28px 22px; }
  h1 { font-size: 19px; }
}

/* ── Sidebar Overlay (mobile) ───────────────────────────────── */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(6,9,26,0.6);
  z-index: 998;
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
}

body.sidebar-open .sidebar-overlay { display: block; }

/* ════════════════════════════════════════════════════════════
   PHASE 1 — GLOBAL COMPONENT SYSTEM
   Affects every module page automatically
   ════════════════════════════════════════════════════════════ */

/* ── Page Header (title + action button row) ────────────────── */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}

.page-header h1 { margin: 0; }

.page-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

/* ── Avatar Initials ────────────────────────────────────────── */
.avatar-initials {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: var(--accent-grad);
  color: #fff;
  font-size: 12px;
  font-weight: 800;
  flex-shrink: 0;
  letter-spacing: -0.3px;
}

.avatar-initials.av-green  { background: linear-gradient(135deg, #10b981, #059669); }
.avatar-initials.av-yellow { background: linear-gradient(135deg, #f59e0b, #d97706); }
.avatar-initials.av-red    { background: linear-gradient(135deg, #ef4444, #dc2626); }
.avatar-initials.av-teal   { background: linear-gradient(135deg, #14b8a6, #0d9488); }
.avatar-initials.av-blue   { background: linear-gradient(135deg, #3b82f6, #2563eb); }

.avatar-cell {
  display: flex;
  align-items: center;
  gap: 10px;
}
.avatar-cell .name-text {
  font-weight: 600;
  color: var(--text);
  font-size: 13px;
}
.avatar-cell .sub-text {
  font-size: 11px;
  color: var(--muted);
}

/* ── Extended Badge System ──────────────────────────────────── */
/* Role badges */
.badge-admin    { background: rgba(99,102,241,0.12);  color: #4338ca; }
.badge-manager  { background: rgba(139,92,246,0.12);  color: #6d28d9; }
.badge-staff    { background: rgba(59,130,246,0.12);  color: #1d4ed8; }
.badge-agent    { background: rgba(20,184,166,0.12);  color: #0f766e; }
.badge-customer { background: rgba(245,158,11,0.12);  color: #b45309; }

/* Priority badges */
.badge-urgent  { background: rgba(239,68,68,0.12);   color: #b91c1c; }
.badge-high    { background: rgba(245,158,11,0.12);  color: #b45309; }
.badge-medium  { background: rgba(59,130,246,0.12);  color: #1d4ed8; }
.badge-low     { background: rgba(16,185,129,0.12);  color: #065f46; }

/* Payment/status extras */
.badge-open      { background: rgba(59,130,246,0.12);  color: #1d4ed8; }
.badge-closed    { background: #f1f5f9;                color: #64748b; }
.badge-resolved  { background: rgba(16,185,129,0.12);  color: #065f46; }
.badge-new       { background: rgba(139,92,246,0.12);  color: #6d28d9; }
.badge-converted { background: rgba(16,185,129,0.12);  color: #065f46; }
.badge-cancelled { background: rgba(239,68,68,0.12);   color: #b91c1c; }

/* Badge with dot indicator */
.badge-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}

/* ── Currency / Amount Pill ─────────────────────────────────── */
.currency-pill {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-weight: 700;
  font-size: 13px;
  color: var(--text);
  background: var(--surface-2);
  padding: 3px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  white-space: nowrap;
}

.currency-pill.pill-green  { background: var(--green-bg);  color: #065f46; border-color: rgba(16,185,129,0.2); }
.currency-pill.pill-red    { background: var(--red-bg);    color: #991b1b; border-color: rgba(239,68,68,0.2); }
.currency-pill.pill-yellow { background: var(--yellow-bg); color: #92400e; border-color: rgba(245,158,11,0.2); }

/* Credit / Debit coloring in ledger */
.amount-credit { color: #059669; font-weight: 700; }
.amount-debit  { color: #dc2626; font-weight: 700; }

/* ── Action Button System ───────────────────────────────────── */
.action-group {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-wrap: wrap;
}

.btn-edit {
  background: rgba(59,130,246,0.1);
  color: #1d4ed8;
  border: 1px solid rgba(59,130,246,0.2);
  padding: 5px 12px;
  border-radius: 7px;
  font-size: 12px;
  font-weight: 600;
  transition: background 0.14s, border-color 0.14s, transform 0.1s;
}
.btn-edit:hover {
  background: rgba(59,130,246,0.18);
  border-color: rgba(59,130,246,0.4);
  transform: translateY(-1px);
  color: #1d4ed8;
}

.btn-delete {
  background: rgba(239,68,68,0.1);
  color: #b91c1c;
  border: 1px solid rgba(239,68,68,0.2);
  padding: 5px 12px;
  border-radius: 7px;
  font-size: 12px;
  font-weight: 600;
  transition: background 0.14s, border-color 0.14s, transform 0.1s;
}
.btn-delete:hover {
  background: rgba(239,68,68,0.18);
  border-color: rgba(239,68,68,0.4);
  transform: translateY(-1px);
  color: #b91c1c;
}

.btn-activate {
  background: rgba(16,185,129,0.1);
  color: #065f46;
  border: 1px solid rgba(16,185,129,0.2);
  padding: 5px 12px;
  border-radius: 7px;
  font-size: 12px;
  font-weight: 600;
  transition: background 0.14s, border-color 0.14s, transform 0.1s;
}
.btn-activate:hover { background: rgba(16,185,129,0.18); border-color: rgba(16,185,129,0.4); color: #065f46; transform: translateY(-1px); }

.btn-deactivate {
  background: rgba(245,158,11,0.1);
  color: #92400e;
  border: 1px solid rgba(245,158,11,0.2);
  padding: 5px 12px;
  border-radius: 7px;
  font-size: 12px;
  font-weight: 600;
  transition: background 0.14s, border-color 0.14s, transform 0.1s;
}
.btn-deactivate:hover { background: rgba(245,158,11,0.18); border-color: rgba(245,158,11,0.4); color: #92400e; transform: translateY(-1px); }

.btn-approve {
  background: rgba(16,185,129,0.1);
  color: #065f46;
  border: 1px solid rgba(16,185,129,0.25);
  padding: 5px 12px;
  border-radius: 7px;
  font-size: 12px;
  font-weight: 600;
  transition: background 0.14s, transform 0.1s;
}
.btn-approve:hover { background: rgba(16,185,129,0.2); transform: translateY(-1px); color: #065f46; }

.btn-reject {
  background: rgba(239,68,68,0.1);
  color: #b91c1c;
  border: 1px solid rgba(239,68,68,0.25);
  padding: 5px 12px;
  border-radius: 7px;
  font-size: 12px;
  font-weight: 600;
  transition: background 0.14s, transform 0.1s;
}
.btn-reject:hover { background: rgba(239,68,68,0.2); transform: translateY(-1px); color: #b91c1c; }

.btn-view {
  background: rgba(99,102,241,0.1);
  color: var(--indigo);
  border: 1px solid rgba(99,102,241,0.2);
  padding: 5px 12px;
  border-radius: 7px;
  font-size: 12px;
  font-weight: 600;
  text-decoration: none;
  transition: background 0.14s, transform 0.1s;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.btn-view:hover { background: rgba(99,102,241,0.18); transform: translateY(-1px); color: var(--indigo); }

/* ── Enhanced Table ─────────────────────────────────────────── */
.data-table-wrap {
  overflow-x: auto;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-xs);
  background: var(--surface);
}

.data-table-wrap table {
  border: none;
}

.data-table-wrap .card-header {
  padding: 14px 18px;
  margin-bottom: 0;
  border-bottom: 1px solid var(--border);
}

tbody tr.selected-row { background: rgba(99,102,241,0.06) !important; }

tbody tr:nth-child(even) { background: rgba(248,250,255,0.6); }
tbody tr:nth-child(even):hover { background: rgba(99,102,241,0.04); }

.td-muted { color: var(--muted); font-size: 12px; }

.td-nowrap { white-space: nowrap; }

.col-id { width: 52px; color: var(--muted); font-size: 12px; font-weight: 600; }
.col-actions { width: 180px; }

/* ── Info Row (key: value pairs in cards) ───────────────────── */
.info-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 9px 0;
  border-bottom: 1px solid var(--border);
  gap: 12px;
  font-size: 13px;
}
.info-row:last-child { border-bottom: none; }
.info-row .info-label { color: var(--muted); font-weight: 500; flex-shrink: 0; }
.info-row .info-value { font-weight: 600; color: var(--text); text-align: right; }

/* ── Timeline / Activity List ───────────────────────────────── */
.timeline { list-style: none; padding: 0; margin: 0; position: relative; }
.timeline::before {
  content: '';
  position: absolute;
  left: 15px;
  top: 0;
  bottom: 0;
  width: 2px;
  background: linear-gradient(180deg, var(--indigo) 0%, transparent 100%);
  opacity: 0.2;
}

.timeline-item {
  display: flex;
  gap: 14px;
  padding: 8px 0 8px 6px;
  position: relative;
}

.timeline-dot {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--accent-grad);
  flex-shrink: 0;
  display: grid;
  place-items: center;
  font-size: 9px;
  color: #fff;
  font-weight: 800;
  box-shadow: 0 0 0 3px rgba(99,102,241,0.15);
  z-index: 1;
}

.timeline-dot.dot-green  { background: linear-gradient(135deg,#10b981,#059669); box-shadow: 0 0 0 3px rgba(16,185,129,0.15); }
.timeline-dot.dot-yellow { background: linear-gradient(135deg,#f59e0b,#d97706); box-shadow: 0 0 0 3px rgba(245,158,11,0.15); }
.timeline-dot.dot-red    { background: linear-gradient(135deg,#ef4444,#dc2626); box-shadow: 0 0 0 3px rgba(239,68,68,0.15); }

.timeline-body { flex: 1; padding-top: 1px; }
.timeline-body .tl-text { font-size: 13px; color: var(--text-2); line-height: 1.4; }
.timeline-body .tl-time { font-size: 11px; color: var(--muted); margin-top: 2px; }

/* ── Quick Link Button Grid ─────────────────────────────────── */
.quick-links-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 10px;
}

.quick-link-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 14px 10px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-decoration: none;
  color: var(--text-2);
  font-size: 12px;
  font-weight: 600;
  transition: background 0.15s, border-color 0.15s, transform 0.15s, box-shadow 0.15s;
  cursor: pointer;
  text-align: center;
}

.quick-link-btn:hover {
  background: #eef2ff;
  border-color: rgba(99,102,241,0.3);
  color: var(--indigo);
  transform: translateY(-2px);
  box-shadow: var(--shadow-sm);
}

.quick-link-icon { font-size: 24px; }

/* ── Toggle Switch ──────────────────────────────────────────── */
.toggle-switch {
  position: relative;
  display: inline-block;
  width: 42px;
  height: 24px;
  flex-shrink: 0;
}

.toggle-switch input { opacity: 0; width: 0; height: 0; }

.toggle-track {
  position: absolute;
  cursor: pointer;
  top: 0; left: 0; right: 0; bottom: 0;
  background: #cbd5e1;
  border-radius: 99px;
  transition: background 0.2s;
}

.toggle-track::before {
  content: '';
  position: absolute;
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.2s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.toggle-switch input:checked + .toggle-track { background: var(--indigo); }
.toggle-switch input:checked + .toggle-track::before { transform: translateX(18px); }

/* Permission table toggle styling */
.perm-table th { font-size: 10px; text-align: center; }
.perm-table td:first-child { font-weight: 600; color: var(--text); }
.perm-table td { text-align: center; }
.perm-group-header td {
  background: linear-gradient(135deg, rgba(99,102,241,0.06), rgba(139,92,246,0.04));
  font-weight: 700;
  color: var(--indigo);
  font-size: 12px;
  letter-spacing: 0.5px;
  text-align: left;
  padding: 10px 14px;
  border-top: 2px solid rgba(99,102,241,0.15);
}

/* ── Card Accent Variants ───────────────────────────────────── */
.card-accent-green  { border-top: 3px solid var(--green)  !important; }
.card-accent-yellow { border-top: 3px solid var(--yellow) !important; }
.card-accent-red    { border-top: 3px solid var(--red)    !important; }
.card-accent-blue   { border-top: 3px solid var(--blue)   !important; }
.card-accent-indigo { border-top: 3px solid var(--indigo) !important; }
.card-accent-violet { border-top: 3px solid var(--violet) !important; }
.card-accent-teal   { border-top: 3px solid var(--teal)   !important; }

/* ── Staff Summary Row ──────────────────────────────────────── */
.person-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.person-row:last-child { border-bottom: none; }
.person-row .person-body { flex: 1; }
.person-row .person-name { font-size: 13px; font-weight: 600; color: var(--text); }
.person-row .person-sub  { font-size: 11px; color: var(--muted); margin-top: 1px; }
.person-row .person-value { font-weight: 700; color: var(--text); font-size: 13px; text-align: right; }

/* ── Due Date Coloring ──────────────────────────────────────── */
.due-overdue { color: #dc2626; font-weight: 600; }
.due-today   { color: #d97706; font-weight: 600; }
.due-soon    { color: #2563eb; font-weight: 600; }
.due-ok      { color: #059669; font-weight: 600; }

/* ── Filter Tabs (pill style) ───────────────────────────────── */
.filter-tabs {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.filter-tab {
  padding: 6px 14px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--muted);
  text-decoration: none;
  cursor: pointer;
  transition: all 0.15s;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.filter-tab:hover { background: #eef2ff; border-color: rgba(99,102,241,0.3); color: var(--indigo); }
.filter-tab.active { background: var(--accent-grad); color: #fff; border-color: transparent; box-shadow: 0 3px 10px rgba(99,102,241,0.25); }
.filter-tab .tab-count {
  background: rgba(255,255,255,0.25);
  border-radius: 99px;
  padding: 1px 6px;
  font-size: 10px;
}

/* ── Responsive additions ───────────────────────────────────── */
@media (max-width: 768px) {
  .quick-links-grid { grid-template-columns: repeat(3, 1fr); }
  .col-actions { width: auto; }
  .action-group { flex-direction: column; align-items: flex-start; }
  .page-header { flex-direction: column; align-items: flex-start; }
}

@media (max-width: 500px) {
  .filter-tabs { gap: 4px; }
  .filter-tab { font-size: 11px; padding: 5px 10px; }
  .quick-links-grid { grid-template-columns: repeat(2, 1fr); }
}

/* ================================================================
   PHASE 3 — Leads / Clients / Invoices helpers
   ================================================================ */

/* Pagination */
.pagination { display: flex; flex-wrap: wrap; gap: 6px; margin: 16px 0; }
.page-btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 36px; height: 36px; padding: 0 10px;
  border-radius: 8px; font-size: 13px; font-weight: 600; text-decoration: none;
  background: var(--card-bg); border: 1px solid var(--border);
  color: var(--text); transition: all .18s ease;
}
.page-btn:hover { background: var(--indigo-soft); color: var(--indigo); border-color: var(--indigo); }
.page-btn.active { background: var(--indigo); color: #fff; border-color: var(--indigo); }

/* Due-date follow-up helpers */
.due-overdue { color: #ef4444; font-weight: 700; }
.due-today   { color: #f59e0b; font-weight: 700; }
.due-soon    { color: #6366f1; font-weight: 600; }
.due-ok      { color: var(--muted); }

/* Missing badge variants */
.badge-paid        { background: #d1fae5; color: #065f46; }
.badge-partial      { background: #fef3c7; color: #92400e; }
.badge-unpaid       { background: #fee2e2; color: #991b1b; }
.badge-converted    { background: #d1fae5; color: #065f46; }
.badge-cancelled    { background: #f1f5f9; color: #475569; }
.badge-open         { background: #dbeafe; color: #1e40af; }
.badge-approved     { background: #d1fae5; color: #065f46; }
.badge-resolved     { background: #d1fae5; color: #065f46; }
.badge-closed       { background: #f1f5f9; color: #475569; }
.badge-purple       { background: #ede9fe; color: #6d28d9; }
.badge-default      { background: var(--card-bg); color: var(--muted); border: 1px solid var(--border); }

/* Currency pill color variants */
.pill-yellow { background: #fef3c7; color: #92400e; }

/* Small button variant */
.btn-sm { padding: 5px 14px !important; font-size: 12px !important; border-radius: 7px !important; }

/* btn-primary inline */
.btn-primary {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 8px 16px; background: var(--indigo); color: #fff;
  border: none; border-radius: 8px; font-size: 13px; font-weight: 600;
  cursor: pointer; text-decoration: none; transition: background .18s ease;
}
.btn-primary:hover { background: #4338ca; }

/* btn-secondary inline */
.btn-secondary {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 8px 16px; background: var(--card-bg); color: var(--muted);
  border: 1px solid var(--border); border-radius: 8px; font-size: 13px; font-weight: 600;
  cursor: pointer; text-decoration: none; transition: all .18s ease;
}
.btn-secondary:hover { background: var(--bg); color: var(--text); }

/* Search input wrap */
.search-input-wrap { position: relative; }
.search-input-wrap .search-icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); font-size: 14px; pointer-events: none; }

/* Card accent — teal */
.card-accent-teal  { border-top: 3px solid #14b8a6; }
/* CSS var for indigo (ensure available) */
:root { --indigo-soft: #eef2ff; }

/* btn-approve */
.btn-approve {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 5px 10px; background: #d1fae5; color: #065f46;
  border: 1px solid #a7f3d0; border-radius: 6px; font-size: 12px; font-weight: 600;
  cursor: pointer; text-decoration: none; transition: all .15s ease;
}
.btn-approve:hover { background: #a7f3d0; }

/* btn-reject */
.btn-reject {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 5px 10px; background: #fee2e2; color: #991b1b;
  border: 1px solid #fecaca; border-radius: 6px; font-size: 12px; font-weight: 600;
  cursor: pointer; transition: all .15s ease;
}
.btn-reject:hover { background: #fecaca; }

/* btn-view */
.btn-view {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 5px 10px; background: #f1f5f9; color: #475569;
  border: 1px solid #e2e8f0; border-radius: 6px; font-size: 12px; font-weight: 600;
  cursor: pointer; text-decoration: none; transition: all .15s ease;
}
.btn-view:hover { background: #e2e8f0; }

/* Sub-text helper in avatar-cell */
.sub-text { font-size: 11px; color: var(--muted); margin-top: 1px; }

/* name-text helper */
.name-text { font-size: 13px; font-weight: 600; color: var(--text); }


/* ============================================================
   WhatsApp Module — Premium Styles
   ============================================================ */

/* ── WhatsApp Design Tokens ─────────────────────────────────── */
:root {
  --wa-green: #25D366;
  --wa-green-dark: #128C7E;
  --wa-green-darker: #075E54;
  --wa-green-bg: rgba(37,211,102,0.08);
  --wa-green-bg2: rgba(37,211,102,0.15);
  --wa-chat-bg: #ECE5DD;
  --wa-chat-header: #075E54;
  --wa-bubble-out: #DCF8C6;
  --wa-bubble-in: #fff;
  --wa-teal: #128C7E;
}

/* ── WhatsApp KPI Cards ─────────────────────────────────────── */
.wa-kpi { border-top: 3px solid var(--wa-green) !important; }
.wa-kpi .kpi-icon { background: var(--wa-green-bg2); }
.wa-kpi-green { border-top-color: var(--wa-green) !important; }
.wa-kpi-green .kpi-icon { color: var(--wa-green); }
.wa-kpi-teal { border-top-color: var(--wa-teal) !important; }
.wa-kpi-teal .kpi-icon { color: var(--wa-teal); }
.wa-kpi-gold { border-top-color: #f59e0b !important; }
.wa-kpi-gold .kpi-icon { color: #f59e0b; }

/* ── WhatsApp Tabs ──────────────────────────────────────────── */
.wa-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 5px;
  box-shadow: var(--shadow-xs);
  overflow-x: auto;
}

.wa-tab {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 18px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  text-decoration: none;
  transition: all 0.2s ease;
  white-space: nowrap;
  cursor: pointer;
}

.wa-tab:hover {
  background: var(--wa-green-bg);
  color: var(--wa-green-dark);
}

.wa-tab-active {
  background: linear-gradient(135deg, var(--wa-green), var(--wa-green-dark)) !important;
  color: #fff !important;
  box-shadow: 0 4px 16px rgba(37,211,102,0.3);
}

.wa-tab-icon { font-size: 15px; }

.wa-tab-count {
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 700;
  background: rgba(255,255,255,0.2);
}

.wa-tab-active .wa-tab-count { background: rgba(255,255,255,0.3); }

/* ── Compose Layout ─────────────────────────────────────────── */
.wa-compose-wrap {
  display: grid;
  grid-template-columns: 1fr 380px;
  gap: 20px;
  align-items: start;
}

.wa-compose-panel {
  animation: fadeSlideIn 0.35s ease both;
}

.wa-preview-panel {
  animation: fadeSlideIn 0.4s ease both;
  position: sticky;
  top: 80px;
}

/* ── WhatsApp Fields ────────────────────────────────────────── */
.wa-field {
  margin-bottom: 16px;
  padding: 0 18px;
}

.wa-field:first-of-type { margin-top: 16px; }

.wa-field label {
  display: block;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-2);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.wa-field input,
.wa-field select,
.wa-field textarea,
.wa-compose-input {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  font-size: 13px;
  font-family: inherit;
  color: var(--text);
  background: var(--surface-2);
  transition: border-color 0.2s, box-shadow 0.2s;
}

.wa-field input:focus,
.wa-field select:focus,
.wa-field textarea:focus,
.wa-compose-input:focus {
  outline: none;
  border-color: var(--wa-green);
  box-shadow: 0 0 0 3px rgba(37,211,102,0.12);
}

.wa-field textarea { resize: vertical; min-height: 100px; }

.wa-field-help {
  font-size: 11px;
  color: var(--muted);
  margin-top: 4px;
  line-height: 1.4;
}

.wa-phone-row {
  display: flex;
  align-items: center;
  gap: 0;
}

.wa-country-code {
  padding: 10px 14px;
  background: var(--wa-green-bg2);
  color: var(--wa-green-dark);
  font-weight: 700;
  font-size: 13px;
  border: 1.5px solid var(--border);
  border-right: none;
  border-radius: 10px 0 0 10px;
  flex-shrink: 0;
}

.wa-phone-row input {
  border-radius: 0 10px 10px 0 !important;
}

.wa-char-count {
  font-size: 11px;
  color: var(--muted);
  text-align: right;
  margin-top: 4px;
}

/* ── Contact Search ─────────────────────────────────────────── */
.wa-search-wrap { position: relative; }

.wa-search-input {
  width: 100%;
  padding: 10px 14px 10px 36px;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  font-size: 13px;
  font-family: inherit;
  color: var(--text);
  background: var(--surface-2) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cline x1='21' y1='21' x2='16.65' y2='16.65'/%3E%3C/svg%3E") no-repeat 12px center;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.wa-search-input:focus {
  outline: none;
  border-color: var(--wa-green);
  box-shadow: 0 0 0 3px rgba(37,211,102,0.12);
}

.wa-search-results {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow-md);
  z-index: 50;
  max-height: 280px;
  overflow-y: auto;
  margin-top: 4px;
}

.wa-search-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  cursor: pointer;
  transition: background 0.15s;
}

.wa-search-item:hover { background: var(--wa-green-bg); }

.wa-search-item-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--wa-green), var(--wa-green-dark));
  color: #fff;
  font-weight: 700;
  font-size: 14px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.wa-search-item-info { flex: 1; min-width: 0; }
.wa-search-item-name { font-size: 13px; font-weight: 600; color: var(--text); }
.wa-search-item-phone { font-size: 11px; color: var(--muted); }
.wa-search-item-type {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--wa-green-dark);
  background: var(--wa-green-bg2);
  padding: 2px 8px;
  border-radius: 999px;
  flex-shrink: 0;
}

.wa-search-empty {
  padding: 20px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
}

/* ── Selected Contact Card ──────────────────────────────────── */
.wa-contact-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: var(--wa-green-bg);
  border: 1.5px solid rgba(37,211,102,0.25);
  border-radius: 12px;
}

.wa-contact-avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--wa-green), var(--wa-green-dark));
  color: #fff;
  font-weight: 800;
  font-size: 16px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.wa-contact-info { flex: 1; }
.wa-contact-name { font-size: 14px; font-weight: 700; color: var(--text); }
.wa-contact-phone { font-size: 12px; color: var(--muted); margin-top: 1px; }
.wa-contact-type { font-size: 10px; font-weight: 700; color: var(--wa-green-dark); margin-top: 2px; }

.wa-contact-remove {
  width: 28px;
  height: 28px;
  border: none;
  background: rgba(239,68,68,0.1);
  color: #ef4444;
  border-radius: 50%;
  font-size: 14px;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: all 0.15s;
  flex-shrink: 0;
}
.wa-contact-remove:hover { background: rgba(239,68,68,0.2); }

/* ── Action Buttons ─────────────────────────────────────────── */
.wa-actions {
  display: flex;
  gap: 8px;
  padding: 16px 18px;
  flex-wrap: wrap;
}

.wa-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 20px;
  border: none;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.2s ease;
  text-decoration: none;
}

.wa-btn-send {
  background: linear-gradient(135deg, var(--wa-green), var(--wa-green-dark));
  color: #fff;
  box-shadow: 0 4px 16px rgba(37,211,102,0.3);
}
.wa-btn-send:hover { box-shadow: 0 6px 24px rgba(37,211,102,0.4); transform: translateY(-1px); }
.wa-btn-send:disabled { opacity: 0.6; cursor: not-allowed; transform: none; }

.wa-btn-preview {
  background: var(--surface-2);
  color: var(--text-2);
  border: 1.5px solid var(--border);
}
.wa-btn-preview:hover { border-color: var(--wa-green); color: var(--wa-green-dark); }

.wa-btn-wame {
  background: var(--wa-green-bg2);
  color: var(--wa-green-dark);
  border: 1.5px solid rgba(37,211,102,0.25);
}
.wa-btn-wame:hover { background: rgba(37,211,102,0.25); }

.wa-btn-filter {
  background: var(--surface-2);
  color: var(--text-2);
  border: 1.5px solid var(--border);
  padding: 8px 16px;
}
.wa-btn-filter:hover { border-color: var(--wa-green); }

.wa-btn-icon { font-size: 15px; }

/* ── Phone Mockup (Preview) ─────────────────────────────────── */
.wa-phone-mockup {
  border-radius: 18px;
  overflow: hidden;
  border: 2px solid #e2e8f0;
  margin: 16px 0 0;
  box-shadow: var(--shadow-sm);
}

.wa-phone-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: var(--wa-chat-header);
  color: #fff;
}

.wa-phone-header-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(255,255,255,0.2);
  display: grid;
  place-items: center;
  font-size: 16px;
  flex-shrink: 0;
}

.wa-phone-header-name { font-size: 14px; font-weight: 600; }
.wa-phone-header-status { font-size: 11px; opacity: 0.8; }

.wa-chat-body {
  background: var(--wa-chat-bg);
  background-image: url("data:image/svg+xml,%3Csvg width='80' height='80' viewBox='0 0 80 80' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='%23d4cfc4' fill-opacity='0.3'%3E%3Ccircle cx='10' cy='10' r='2'/%3E%3Ccircle cx='50' cy='30' r='1.5'/%3E%3Ccircle cx='30' cy='60' r='1'/%3E%3Ccircle cx='70' cy='70' r='2'/%3E%3C/g%3E%3C/svg%3E");
  padding: 12px;
  min-height: 200px;
}

.wa-chat-date {
  text-align: center;
  margin-bottom: 12px;
}

.wa-chat-date::after {
  content: attr(data-date, 'Today');
}

.wa-chat-date {
  font-size: 11px;
  color: #fff;
  background: rgba(0,0,0,0.15);
  padding: 3px 12px;
  border-radius: 8px;
  display: inline-block;
  font-weight: 500;
}

.wa-chat-bubble {
  max-width: 85%;
  padding: 8px 12px;
  border-radius: 12px;
  position: relative;
  margin-bottom: 4px;
  word-wrap: break-word;
}

.wa-chat-outgoing {
  background: var(--wa-bubble-out);
  margin-left: auto;
  border-top-right-radius: 4px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.1);
}

.wa-bubble-text {
  font-size: 13px;
  color: #303030;
  line-height: 1.45;
  white-space: pre-wrap;
}

.wa-bubble-time {
  font-size: 10px;
  color: rgba(0,0,0,0.4);
  text-align: right;
  margin-top: 4px;
}

@keyframes waBubblePop {
  0% { transform: scale(0.95); opacity: 0.7; }
  50% { transform: scale(1.02); }
  100% { transform: scale(1); opacity: 1; }
}

.wa-bubble-animate {
  animation: waBubblePop 0.4s ease both;
}

/* ── Log Filters ────────────────────────────────────────────── */
.wa-log-filters {
  display: flex;
  gap: 8px;
  padding: 12px 18px;
  flex-wrap: wrap;
  align-items: center;
  border-bottom: 1px solid var(--border);
}

.wa-filter-input {
  flex: 1;
  min-width: 200px;
  padding: 8px 12px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-size: 12px;
  font-family: inherit;
}

.wa-filter-select {
  padding: 8px 12px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-size: 12px;
  font-family: inherit;
  background: var(--surface);
  min-width: 120px;
}

.wa-filter-date {
  padding: 8px 10px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-size: 12px;
  font-family: inherit;
  min-width: 130px;
}

/* ── Status Pills ───────────────────────────────────────────── */
.wa-status-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
}

.wa-status-sent { background: #d1fae5; color: #065f46; }
.wa-status-delivered { background: #dbeafe; color: #1e40af; }
.wa-status-read { background: #dbeafe; color: #1e40af; }
.wa-status-failed { background: #fee2e2; color: #991b1b; }
.wa-status-queued { background: #fef3c7; color: #92400e; }

.wa-type-badge {
  background: var(--wa-green-bg2);
  color: var(--wa-green-dark);
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
}

/* ── Badge Mode ─────────────────────────────────────────────── */
.wa-badge-mode {
  background: var(--wa-green-bg2) !important;
  color: var(--wa-green-dark) !important;
  font-weight: 700 !important;
  padding: 5px 14px !important;
  border-radius: 999px !important;
  font-size: 12px !important;
}

/* ── Pagination ─────────────────────────────────────────────── */
.wa-pagination {
  display: flex;
  gap: 4px;
  justify-content: center;
  padding: 16px;
}

.wa-page-btn {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  font-size: 12px;
  font-weight: 600;
  color: var(--text-2);
  text-decoration: none;
  transition: all 0.15s;
}

.wa-page-btn:hover { border-color: var(--wa-green); color: var(--wa-green-dark); }

.wa-page-active {
  background: linear-gradient(135deg, var(--wa-green), var(--wa-green-dark)) !important;
  color: #fff !important;
  border-color: transparent !important;
}

/* ── Campaign Cards ─────────────────────────────────────────── */
.wa-campaign-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 16px;
  padding: 16px 18px;
}

.wa-campaign-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  transition: box-shadow 0.2s;
}

.wa-campaign-card:hover { box-shadow: var(--shadow-sm); }

.wa-campaign-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.wa-campaign-header h3 {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
}

.wa-campaign-status {
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
}

.wa-campaign-body {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 14px;
}

.wa-campaign-stat {
  text-align: center;
  padding: 8px;
  background: var(--surface-2);
  border-radius: 8px;
}

.wa-campaign-label {
  font-size: 10px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.4px;
  display: block;
}

.wa-campaign-value {
  font-size: 22px;
  font-weight: 800;
  color: var(--text);
  display: block;
  margin-top: 2px;
}

.wa-campaign-progress {
  height: 5px;
  background: var(--surface-2);
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: 12px;
}

.wa-campaign-bar {
  height: 100%;
  border-radius: 999px;
  transition: width 0.5s ease;
}

.wa-campaign-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* ── Recent Messages Mini List ──────────────────────────────── */
.wa-recent-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}
.wa-recent-item:last-child { border-bottom: none; }

.wa-recent-icon {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 10px;
  font-weight: 700;
  flex-shrink: 0;
}

.wa-recent-icon.wa-status-sent { background: #d1fae5; color: #065f46; }
.wa-recent-icon.wa-status-failed { background: #fee2e2; color: #991b1b; }

.wa-recent-body { flex: 1; min-width: 0; }
.wa-recent-phone { font-size: 12px; font-weight: 600; color: var(--text); }
.wa-recent-msg { font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wa-recent-time { font-size: 10px; color: var(--muted); flex-shrink: 0; }

.wa-empty-mini {
  padding: 16px;
  text-align: center;
  color: var(--muted);
  font-size: 12px;
}

/* ── Settings Layout ────────────────────────────────────────── */
.wa-settings-wrap {
  display: grid;
  grid-template-columns: 1fr 360px;
  gap: 20px;
  align-items: start;
}

.wa-settings-section {
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
}

.wa-settings-section:last-of-type { border-bottom: none; }

.wa-settings-section h3 {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 14px;
}

/* ── Help Card ──────────────────────────────────────────────── */
.wa-help-card {
  position: sticky;
  top: 80px;
}

.wa-help-card h3 {
  font-size: 15px;
  font-weight: 700;
  margin: 0 0 16px;
  padding: 0 18px;
}

.wa-help-steps { padding: 0 18px 18px; }

.wa-help-step {
  display: flex;
  gap: 12px;
  margin-bottom: 16px;
  align-items: flex-start;
}

.wa-help-step:last-child { margin-bottom: 0; }

.wa-help-step-num {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--wa-green), var(--wa-green-dark));
  color: #fff;
  font-weight: 800;
  font-size: 13px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.wa-help-step strong {
  display: block;
  font-size: 13px;
  color: var(--text);
  margin-bottom: 2px;
}

.wa-help-step p {
  font-size: 12px;
  color: var(--muted);
  margin: 0;
  line-height: 1.4;
}

.wa-help-step code {
  background: var(--wa-green-bg2);
  color: var(--wa-green-dark);
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 11px;
}

/* ── WhatsApp Modal ─────────────────────────────────────────── */
.wa-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  backdrop-filter: blur(4px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeSlideIn 0.2s ease;
}

.wa-modal {
  width: min(520px, 94vw);
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  animation: fadeSlideIn 0.3s ease;
}

.wa-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  background: linear-gradient(135deg, var(--wa-green), var(--wa-green-dark));
  color: #fff;
}

.wa-modal-header h3 { margin: 0; font-size: 16px; font-weight: 700; }

.wa-modal-close {
  width: 32px;
  height: 32px;
  border: none;
  background: rgba(255,255,255,0.2);
  color: #fff;
  border-radius: 50%;
  font-size: 16px;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: background 0.15s;
}
.wa-modal-close:hover { background: rgba(255,255,255,0.3); }

.wa-modal-body { padding: 20px; }

.wa-modal-contact { margin-bottom: 16px; }

.wa-modal-footer {
  display: flex;
  gap: 8px;
  padding: 12px 20px 20px;
}

/* ── Toast Notification ─────────────────────────────────────── */
.wa-toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  padding: 12px 20px;
  border-radius: 12px;
  font-size: 13px;
  font-weight: 600;
  font-family: 'Inter', sans-serif;
  z-index: 2000;
  transform: translateY(20px);
  opacity: 0;
  transition: all 0.3s ease;
  box-shadow: var(--shadow-md);
}

.wa-toast-show { transform: translateY(0); opacity: 1; }

.wa-toast-success {
  background: linear-gradient(135deg, var(--wa-green), var(--wa-green-dark));
  color: #fff;
}

.wa-toast-error {
  background: linear-gradient(135deg, #ef4444, #dc2626);
  color: #fff;
}

/* ── Quick-Send WhatsApp Button (for tables) ────────────────── */
.wa-quick-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  background: var(--wa-green-bg2);
  color: var(--wa-green-dark);
  border: 1px solid rgba(37,211,102,0.25);
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.wa-quick-btn:hover {
  background: var(--wa-green);
  color: #fff;
  border-color: var(--wa-green);
  box-shadow: 0 2px 8px rgba(37,211,102,0.3);
}

/* ── Responsive ─────────────────────────────────────────────── */
@media (max-width: 960px) {
  .wa-compose-wrap {
    grid-template-columns: 1fr;
  }
  .wa-preview-panel {
    position: static;
  }
  .wa-settings-wrap {
    grid-template-columns: 1fr;
  }
  .wa-help-card {
    position: static;
  }
  .wa-campaign-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .wa-tabs { flex-wrap: wrap; }
  .wa-log-filters { flex-direction: column; }
  .wa-filter-input { min-width: 100%; }
  .wa-actions { flex-direction: column; }
  .wa-actions .wa-btn { width: 100%; justify-content: center; }
}

