/* ─────────────────────────────────────────────────────────────────────────────
   BEXEL CRM — Main Stylesheet
   All CSS custom properties defined here in :root.
   No inline styles. No !important. BEM-style class naming.
───────────────────────────────────────────────────────────────────────────── */

:root {
  /* Brand */
  --color-primary:        #FFD100;   /* MTN Yellow */
  --color-primary-dark:   #C9A600;
  --color-primary-light:  #FFF3B0;

  /* Neutrals */
  --color-bg:             #F4F6FA;
  --color-bg-subtle:      #EDF2F7;
  --color-surface:        #FFFFFF;
  --color-border:         #E2E8F0;
  --color-text:           #1A202C;
  --color-text-muted:     #718096;
  --color-text-inverse:   #FFFFFF;

  /* Semantic */
  --color-success:        #38A169;
  --color-success-light:  #C6F6D5;
  --color-warning:        #D69E2E;
  --color-warning-light:  #FEFCBF;
  --color-danger:         #E53E3E;
  --color-danger-light:   #FED7D7;
  --color-info:           #3182CE;
  --color-info-light:     #BEE3F8;

  /* Sidebar */
  --sidebar-bg:           #1A202C;
  --sidebar-text:         #718096;
  --sidebar-text-active:  #FFFFFF;
  --sidebar-item-active:  rgba(255,255,255,0.07);
  --sidebar-item-active-color: #FFFFFF;
  --sidebar-width:        224px;

  /* Typography */
  --font-sans:   'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono:   'JetBrains Mono', 'Fira Code', monospace;
  --text-xs:     0.75rem;
  --text-sm:     0.875rem;
  --text-base:   1rem;
  --text-lg:     1.125rem;
  --text-xl:     1.25rem;
  --text-2xl:    1.5rem;
  --text-3xl:    1.875rem;

  /* Spacing */
  --space-1:  0.25rem;
  --space-2:  0.5rem;
  --space-3:  0.75rem;
  --space-4:  1rem;
  --space-5:  1.25rem;
  --space-6:  1.5rem;
  --space-8:  2rem;
  --space-10: 2.5rem;
  --space-12: 3rem;

  /* Radii */
  --radius-sm:  4px;
  --radius-md:  8px;
  --radius-lg:  12px;
  --radius-xl:  16px;
  --radius-full: 9999px;

  /* Shadows */
  --shadow-sm:  0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md:  0 4px 6px rgba(0,0,0,0.07), 0 2px 4px rgba(0,0,0,0.04);
  --shadow-lg:  0 10px 15px rgba(0,0,0,0.08), 0 4px 6px rgba(0,0,0,0.04);

  /* Transitions */
  --transition: 150ms ease;
}

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

html { font-size: 16px; -webkit-font-smoothing: antialiased; }

body {
  font-family: var(--font-sans);
  font-size: var(--text-base);
  color: var(--color-text);
  background: var(--color-bg);
  line-height: 1.5;
}

a { color: inherit; text-decoration: none; }
ul, ol { list-style: none; }
img { max-width: 100%; display: block; }

/* ── App Layout ────────────────────────────────────────────────────────────── */
.app-layout {
  display: flex;
  min-height: 100vh;
}

.main-content {
  flex: 1;
  margin-left: var(--sidebar-width);
  padding: var(--space-8);
  min-height: 100vh;
  transition: margin-left var(--transition);
}

/* ── Sidebar ───────────────────────────────────────────────────────────────── */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: var(--sidebar-width);
  height: 100vh;
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  z-index: 100;
  overflow-y: auto;
}

.sidebar__logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 14px 14px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  flex-shrink: 0;
}

.sidebar__logo-mark {
  width: 30px;
  height: 30px;
  background: var(--color-primary);
  border-radius: 7px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 14px;
  color: #1A202C;
  letter-spacing: -0.5px;
  flex-shrink: 0;
}

.sidebar__brand {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.sidebar__brand-name {
  font-weight: 700;
  font-size: 12px;
  color: var(--sidebar-text-active);
  letter-spacing: 0.3px;
  line-height: 1.2;
}

.sidebar__brand-sub {
  font-size: 10px;
  color: var(--sidebar-text);
  line-height: 1.2;
}

.sidebar__nav {
  flex: 1;
  padding: 8px 0 8px;
  overflow-y: auto;
}

.sidebar__section-label {
  display: block;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--sidebar-text);
  padding: 14px 14px 4px;
  opacity: 0.5;
}

.sidebar__item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 10px;
  margin: 1px 8px;
  color: var(--sidebar-text);
  font-size: 13px;
  font-weight: 500;
  border-radius: 7px;
  transition: background 0.12s, color 0.12s;
  cursor: pointer;
  border: none;
  background: none;
  width: calc(100% - 16px);
  text-align: left;
  text-decoration: none;
}

.sidebar__item:hover {
  background: var(--sidebar-item-active);
  color: var(--sidebar-text-active);
}

.sidebar__item--active {
  background: rgba(255, 209, 0, 0.13);
  color: var(--color-primary);
}

.sidebar__item-icon {
  width: 16px;
  height: 16px;
  opacity: 0.65;
  flex-shrink: 0;
}

.sidebar__item--active .sidebar__item-icon {
  opacity: 1;
  color: var(--color-primary);
}

.sidebar__item:hover .sidebar__item-icon {
  opacity: 1;
}

.sidebar__footer {
  padding: 10px 12px;
  border-top: 1px solid rgba(255,255,255,0.06);
  flex-shrink: 0;
}

.sidebar__user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 4px;
  border-radius: 7px;
  margin-bottom: 6px;
  transition: background 0.12s;
  cursor: pointer;
}

.sidebar__user:hover {
  background: rgba(255,255,255,0.06);
}

.sidebar__avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--color-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 11px;
  color: #1A202C;
  flex-shrink: 0;
}

.sidebar__user-info {
  overflow: hidden;
  flex: 1;
  min-width: 0;
}

.sidebar__user-name {
  font-size: 12px;
  font-weight: 600;
  color: var(--sidebar-text-active);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.3;
}

.sidebar__user-role {
  font-size: 10px;
  color: var(--sidebar-text);
  text-transform: capitalize;
  line-height: 1.3;
}

.sidebar__user-branch {
  font-size: 10px;
  color: var(--sidebar-text);
  opacity: 0.6;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.3;
}

/* ── Category / quick filter pills ────────────────────────────────────────── */
.filter-pill {
  display: inline-flex;
  align-items: center;
  padding: var(--space-1) var(--space-3);
  border-radius: 999px;
  font-size: var(--text-sm);
  font-weight: 500;
  border: 1px solid var(--color-border);
  background: var(--color-bg);
  color: var(--color-text-muted);
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.filter-pill:hover {
  background: var(--color-bg-subtle);
  color: var(--color-text);
}
.filter-pill--active {
  background: var(--color-primary);
  color: #fff;
  border-color: var(--color-primary);
}

/* ── Pagination ────────────────────────────────────────────────────────────── */
.pagination { display:flex; align-items:center; justify-content:space-between; margin-top:var(--space-4); gap:var(--space-3); flex-wrap:wrap; }
.pagination__info { font-size:var(--text-sm); color:var(--color-text-muted); }
.pagination__pages { display:flex; gap:4px; align-items:center; flex-wrap:wrap; }
.pagination__btn {
  min-width:32px; height:32px; padding:0 var(--space-2);
  border:1px solid var(--color-border); background:#fff;
  border-radius:var(--radius-sm); cursor:pointer;
  font-size:var(--text-sm); color:var(--color-text); transition:background .12s,border-color .12s;
}
.pagination__btn:hover:not([disabled]) { background:var(--color-bg-subtle); border-color:var(--color-primary); }
.pagination__btn--active { background:var(--color-primary); color:#fff; border-color:var(--color-primary); }
.pagination__btn[disabled] { opacity:.4; cursor:not-allowed; }
.pagination__ellipsis { color:var(--color-text-muted); padding:0 2px; font-size:var(--text-sm); }

/* ── Page Header ───────────────────────────────────────────────────────────── */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-8);
  flex-wrap: wrap;
  gap: var(--space-4);
}

.page-header__title {
  font-size: var(--text-2xl);
  font-weight: 700;
  color: var(--color-text);
}

.page-header__subtitle {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  margin-top: var(--space-1);
}

/* ── Cards ─────────────────────────────────────────────────────────────────── */
.card {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--color-border);
  box-shadow: var(--shadow-sm);
  padding: var(--space-6);
}

.card__title {
  font-size: var(--text-base);
  font-weight: 600;
  color: var(--color-text);
  margin-bottom: var(--space-4);
}

.card__subtitle {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  margin-top: calc(var(--space-1) * -1);
  margin-bottom: var(--space-4);
}

/* ── Stat Cards ────────────────────────────────────────────────────────────── */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: var(--space-5);
  margin-bottom: var(--space-8);
}

.stat-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.stat-card__label {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  font-weight: 500;
}

.stat-card__value {
  font-size: var(--text-3xl);
  font-weight: 800;
  color: var(--color-text);
  line-height: 1;
}

.stat-card__change {
  font-size: var(--text-xs);
  font-weight: 500;
}

.stat-card__change--up   { color: var(--color-success); }
.stat-card__change--down { color: var(--color-danger); }

/* ── Tinted Cards ──────────────────────────────────────────────────────────── */
/*
  Usage: <div class="tinted-card tinted-card--blue">
  Modifiers: --blue  --teal  --green  --amber  --red  --purple  --slate
  Each modifier sets a soft background, matching border, and --tc-accent
  custom property that child elements can inherit for accent text/icons.
*/
.tinted-card {
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  border: 1px solid transparent;
}

.tinted-card--blue {
  background: hsl(215, 80%, 96%);
  border-color: hsl(215, 65%, 87%);
  --tc-accent: hsl(215, 65%, 42%);
}
.tinted-card--teal {
  background: hsl(172, 65%, 93%);
  border-color: hsl(172, 50%, 81%);
  --tc-accent: hsl(172, 60%, 30%);
}
.tinted-card--green {
  background: hsl(142, 60%, 93%);
  border-color: hsl(142, 45%, 79%);
  --tc-accent: hsl(142, 55%, 28%);
}
.tinted-card--amber {
  background: hsl(38, 90%, 93%);
  border-color: hsl(38, 70%, 80%);
  --tc-accent: hsl(38, 75%, 38%);
}
.tinted-card--red {
  background: hsl(0, 70%, 95%);
  border-color: hsl(0, 55%, 84%);
  --tc-accent: hsl(0, 60%, 42%);
}
.tinted-card--purple {
  background: hsl(258, 70%, 96%);
  border-color: hsl(258, 55%, 87%);
  --tc-accent: hsl(258, 60%, 48%);
}
.tinted-card--slate {
  background: hsl(215, 20%, 95%);
  border-color: hsl(215, 15%, 86%);
  --tc-accent: hsl(215, 20%, 38%);
}

/* KPI card layout on top of .tinted-card */
.kpi-card {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}
.kpi-card__header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: var(--space-1);
}
.kpi-card__label {
  font-size: var(--text-xs);
  font-weight: 700;
  color: var(--tc-accent, var(--color-text-muted));
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.kpi-card__icon {
  color: var(--tc-accent, var(--color-text-muted));
  opacity: 0.7;
  flex-shrink: 0;
}
.kpi-card__value {
  font-size: 1.9rem;
  font-weight: 800;
  color: var(--color-text);
  line-height: 1;
}
.kpi-card__sub {
  font-size: var(--text-xs);
  font-weight: 500;
  color: var(--color-text-muted);
}
.kpi-card__sub--accent {
  color: var(--tc-accent, var(--color-primary));
}

/* ── Avatar ────────────────────────────────────────────────────────────────── */
/*
  Usage: <div class="avatar avatar--md" data-initials="JD" data-hue="0">
  Sizes:  --sm (28px)  --md (36px)  --lg (44px)
  Hue index 0-5 maps to the palette defined in avatar.js helper.
  Color is applied via JS by setting inline --avatar-bg and --avatar-fg.
*/
.avatar {
  border-radius: 50%;
  background: var(--avatar-bg, hsl(215, 60%, 88%));
  color: var(--avatar-fg, hsl(215, 50%, 35%));
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  flex-shrink: 0;
  user-select: none;
}
.avatar--sm  { width: 28px; height: 28px; font-size: 10px; }
.avatar--md  { width: 36px; height: 36px; font-size: 13px; }
.avatar--lg  { width: 44px; height: 44px; font-size: 16px; }

/* ── Pills ─────────────────────────────────────────────────────────────────── */
/*
  Usage: <span class="pill pill--blue">SIM Card ×2</span>
  Modifiers: --blue  --green  --amber  --red  --purple  --slate
*/
.pill {
  display: inline-flex;
  align-items: center;
  padding: 2px 9px;
  border-radius: var(--radius-full);
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
  line-height: 1.6;
}
.pill--blue   { background: hsl(215, 70%, 92%); color: hsl(215, 60%, 35%); }
.pill--teal   { background: hsl(172, 60%, 90%); color: hsl(172, 55%, 28%); }
.pill--green  { background: hsl(142, 55%, 90%); color: hsl(142, 50%, 28%); }
.pill--amber  { background: hsl(38,  80%, 90%); color: hsl(38,  70%, 34%); }
.pill--red    { background: hsl(0,   65%, 92%); color: hsl(0,   60%, 38%); }
.pill--purple { background: hsl(258, 60%, 93%); color: hsl(258, 55%, 42%); }
.pill--slate  { background: hsl(215, 18%, 92%); color: hsl(215, 18%, 36%); }

/* ── Rank Badges ───────────────────────────────────────────────────────────── */
.rank-badge {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
}
.rank-badge--gold   { background: hsl(45, 95%, 88%);  color: hsl(40, 80%, 35%); }
.rank-badge--silver { background: hsl(210, 15%, 90%); color: hsl(210, 10%, 40%); }
.rank-badge--bronze { background: hsl(25,  70%, 88%); color: hsl(25,  65%, 38%); }
.rank-badge--plain  {
  background: var(--color-border);
  color: var(--color-text-muted);
  font-size: var(--text-xs);
  font-weight: 700;
}

/* ── Feed rows (leaderboard, recent transactions, any list item) ────────────── */
.feed-row {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-3) 0;
  border-bottom: 1px solid var(--color-border);
}
.feed-row:last-child { border-bottom: none; }
.feed-row__body { flex: 1; min-width: 0; }
.feed-row__title {
  font-weight: 600;
  font-size: var(--text-sm);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.feed-row__sub {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  margin-top: 2px;
}
.feed-row__pills {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 5px;
}
.feed-row__meta {
  text-align: right;
  flex-shrink: 0;
}
.feed-row__amount {
  font-weight: 700;
  font-size: var(--text-sm);
}
.feed-row__profit {
  font-size: var(--text-xs);
  color: var(--color-success);
  font-weight: 600;
}
.feed-row__date {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
}

/* ── Buttons ───────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-5);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  font-weight: 600;
  font-family: var(--font-sans);
  cursor: pointer;
  border: none;
  transition: background var(--transition), opacity var(--transition), transform var(--transition);
  white-space: nowrap;
  text-decoration: none;
}

.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn--primary {
  background: var(--color-primary);
  color: var(--color-text);
}
.btn--primary:hover:not(:disabled) { background: var(--color-primary-dark); }

.btn--secondary {
  background: var(--color-surface);
  color: var(--color-text);
  border: 1px solid var(--color-border);
}
.btn--secondary:hover:not(:disabled) { background: var(--color-bg); }

.btn--danger {
  background: var(--color-danger);
  color: #fff;
}
.btn--danger:hover:not(:disabled) { opacity: 0.88; }

.btn--ghost {
  background: transparent;
  color: var(--color-text-muted);
}
.btn--ghost:hover:not(:disabled) { background: var(--color-bg); color: var(--color-text); }

.btn--sm {
  padding: var(--space-1) var(--space-3);
  font-size: var(--text-xs);
}

.btn--lg {
  padding: var(--space-3) var(--space-8);
  font-size: var(--text-base);
}

.btn--full { width: 100%; justify-content: center; }

/* ── Forms ─────────────────────────────────────────────────────────────────── */
.form-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  margin-bottom: var(--space-4);
}

.form-label {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--color-text);
}

.form-label--required::after {
  content: ' *';
  color: var(--color-danger);
}

.form-input,
.form-select,
.form-textarea {
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  font-family: var(--font-sans);
  color: var(--color-text);
  background: var(--color-surface);
  transition: border-color var(--transition), box-shadow var(--transition);
  width: 100%;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px var(--color-primary-light);
}

.form-input--error,
.form-select--error,
.form-textarea--error {
  border-color: var(--color-danger);
}

.form-input--error:focus,
.form-select--error:focus {
  box-shadow: 0 0 0 3px var(--color-danger-light);
}

.form-error {
  font-size: var(--text-xs);
  color: var(--color-danger);
  font-weight: 500;
}

.form-hint {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
}

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

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 0 var(--space-5);
}

/* ── Tables ────────────────────────────────────────────────────────────────── */
.table-wrapper {
  overflow-x: auto;
  border-radius: var(--radius-lg);
  border: 1px solid var(--color-border);
  box-shadow: var(--shadow-sm);
}

.table {
  width: 100%;
  border-collapse: collapse;
  background: var(--color-surface);
  font-size: var(--text-sm);
}

.table th {
  text-align: left;
  padding: var(--space-3) var(--space-4);
  font-size: var(--text-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--color-text-muted);
  background: var(--color-bg);
  border-bottom: 1px solid var(--color-border);
  white-space: nowrap;
}

.table td {
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--color-border);
  color: var(--color-text);
  vertical-align: middle;
}

.table tr:last-child td { border-bottom: none; }

.table tbody tr:hover { background: var(--color-bg); }

/* ── Badges ────────────────────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px var(--space-2);
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  font-weight: 600;
  line-height: 1.5;
}

.badge--success { background: var(--color-success-light); color: var(--color-success); }
.badge--warning { background: var(--color-warning-light); color: var(--color-warning); }
.badge--danger  { background: var(--color-danger-light);  color: var(--color-danger); }
.badge--info    { background: var(--color-info-light);    color: var(--color-info); }
.badge--neutral { background: var(--color-border);        color: var(--color-text-muted); }

/* ── Progress Bar ──────────────────────────────────────────────────────────── */
.progress {
  background: var(--color-border);
  border-radius: var(--radius-full);
  height: 8px;
  overflow: hidden;
}

.progress__bar {
  height: 100%;
  border-radius: var(--radius-full);
  transition: width 0.4s ease;
}

.progress__bar--green  { background: var(--color-success); }
.progress__bar--amber  { background: var(--color-warning); }
.progress__bar--red    { background: var(--color-danger); }

/* ── KPI Card ──────────────────────────────────────────────────────────────── */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: var(--space-5);
}

.kpi-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.kpi-card__name {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--color-text-muted);
}

.kpi-card__values {
  display: flex;
  align-items: baseline;
  gap: var(--space-2);
}

.kpi-card__current {
  font-size: var(--text-2xl);
  font-weight: 800;
  color: var(--color-text);
}

.kpi-card__target {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
}

.kpi-card__percent {
  font-size: var(--text-xs);
  font-weight: 600;
  margin-left: auto;
}

/* ── Search Bar ────────────────────────────────────────────────────────────── */
.search-bar {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex-wrap: wrap;
}

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

.search-input-wrapper__icon {
  position: absolute;
  left: var(--space-3);
  top: 50%;
  transform: translateY(-50%);
  color: var(--color-text-muted);
  pointer-events: none;
}

.search-input-wrapper .form-input {
  padding-left: calc(var(--space-3) + 20px + var(--space-2));
}

/* ── Empty State ───────────────────────────────────────────────────────────── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-12) var(--space-8);
  text-align: center;
  color: var(--color-text-muted);
  gap: var(--space-3);
}

.empty-state__icon { font-size: 2.5rem; opacity: 0.4; }
.empty-state__title { font-size: var(--text-base); font-weight: 600; color: var(--color-text); }
.empty-state__text  { font-size: var(--text-sm); max-width: 360px; }

/* ── Modal ─────────────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-4);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition);
}

.modal-overlay--open {
  opacity: 1;
  pointer-events: all;
}

.modal {
  background: var(--color-surface);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  padding: var(--space-8);
  transform: scale(0.96);
  transition: transform var(--transition);
}

.modal-overlay--open .modal { transform: scale(1); }

.modal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-6);
}

.modal__title {
  font-size: var(--text-xl);
  font-weight: 700;
}

.modal__close {
  background: none;
  border: none;
  font-size: var(--text-xl);
  cursor: pointer;
  color: var(--color-text-muted);
  padding: var(--space-1);
  border-radius: var(--radius-sm);
  transition: color var(--transition);
}
.modal__close:hover { color: var(--color-text); }

.modal__footer {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-3);
  margin-top: var(--space-6);
  padding-top: var(--space-5);
  border-top: 1px solid var(--color-border);
}

/* ── Toast Notifications ───────────────────────────────────────────────────── */
.toast-container {
  position: fixed;
  bottom: var(--space-6);
  right: var(--space-6);
  z-index: 300;
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-5);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  font-weight: 500;
  box-shadow: var(--shadow-md);
  pointer-events: all;
  animation: toastIn 0.25s ease forwards;
  max-width: 380px;
}

.toast--success { background: var(--color-success); color: #fff; }
.toast--danger  { background: var(--color-danger);  color: #fff; }
.toast--info    { background: var(--color-info);    color: #fff; }
.toast--warning { background: var(--color-warning, #b45309); color: #fff; }

/* ── Reconciliation filter bar ────────────────────────────────────────────── */
.recon-filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
  align-items: flex-end;
  background: var(--color-surface);
  padding: var(--space-4);
  border-radius: var(--radius-lg);
  border: 1px solid var(--color-border);
  margin-bottom: var(--space-5);
}
.rfb-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.rfb-label {
  font-size: 10px;
  font-weight: 700;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.rfb-date-pills { display: flex; gap: var(--space-1); flex-wrap: wrap; }
.rfb-select {
  height: 34px;
  min-width: 130px;
  padding: 0 var(--space-3);
  font-size: var(--text-sm);
}
.rfb-date-input {
  height: 34px;
  width: 128px;
  padding: 0 var(--space-2);
  font-size: var(--text-sm);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-bg);
  color: var(--color-text);
}
.rfb-custom-range {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-top: 2px;
}
.rfb-multiselect { position: relative; }
.rfb-ms-trigger {
  height: 34px;
  padding: 0 var(--space-3);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-bg);
  color: var(--color-text);
  font-size: var(--text-sm);
  cursor: pointer;
  white-space: nowrap;
  min-width: 138px;
  text-align: left;
  transition: border-color 0.15s;
}
.rfb-ms-trigger:hover  { border-color: var(--color-primary); }
.rfb-ms-trigger--active { border-color: var(--color-primary); color: var(--color-primary); font-weight: 600; }
.rfb-ms-panel {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-2);
  z-index: 300;
  min-width: 190px;
  box-shadow: 0 4px 16px rgba(0,0,0,.12);
}
.rfb-ms-option {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: 6px var(--space-2);
  cursor: pointer;
  border-radius: var(--radius-sm);
  font-size: var(--text-sm);
}
.rfb-ms-option:hover { background: var(--color-bg); }
.rfb-checkbox-label {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-sm);
  cursor: pointer;
  white-space: nowrap;
  padding-bottom: 2px;
}
.rfb-actions {
  display: flex;
  gap: var(--space-2);
  align-items: flex-end;
  margin-left: auto;
}

/* ── Info Tooltip ──────────────────────────────────────────────────────────── */
.info-tip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px; height: 16px;
  border-radius: 50%;
  background: var(--color-text-muted);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  cursor: default;
  position: relative;
  vertical-align: middle;
  margin-left: 4px;
  flex-shrink: 0;
}
.info-tip::after {
  content: attr(data-tip);
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  background: #1a202c;
  color: #fff;
  font-size: 11px;
  font-weight: 400;
  line-height: 1.45;
  white-space: normal;
  width: max-content;
  max-width: 260px;
  padding: 6px 10px;
  border-radius: 6px;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s;
  z-index: 9999;
  text-align: left;
}
.info-tip:hover::after { opacity: 1; }

@keyframes toastIn {
  from { transform: translateX(100%); opacity: 0; }
  to   { transform: translateX(0);   opacity: 1; }
}

/* ── Auth Page (Login) ─────────────────────────────────────────────────────── */
.auth-page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: var(--color-bg);
  padding: var(--space-6);
}

.auth-card {
  background: var(--color-surface);
  border-radius: var(--radius-xl);
  border: 1px solid var(--color-border);
  box-shadow: var(--shadow-lg);
  padding: var(--space-10) var(--space-8);
  width: 100%;
  max-width: 420px;
}

.auth-card__logo {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-bottom: var(--space-8);
  justify-content: center;
}

.auth-card__logo-mark {
  width: 44px;
  height: 44px;
  background: var(--color-primary);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: var(--text-xl);
}

.auth-card__title {
  font-size: var(--text-2xl);
  font-weight: 700;
  margin-bottom: var(--space-2);
  text-align: center;
}

.auth-card__subtitle {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  text-align: center;
  margin-bottom: var(--space-8);
}

/* ── Line Items (POS form) ─────────────────────────────────────────────────── */
.line-items {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.line-item {
  display: grid;
  grid-template-columns: 1fr 80px 120px 36px;
  gap: var(--space-2);
  align-items: center;
}

.line-item__remove {
  background: none;
  border: none;
  color: var(--color-danger);
  cursor: pointer;
  font-size: var(--text-lg);
  padding: var(--space-1);
  border-radius: var(--radius-sm);
  transition: background var(--transition);
}
.line-item__remove:hover { background: var(--color-danger-light); }

/* ── Skeleton pulse ─────────────────────────────────────────────────────────── */
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.45; }
}

/* ── Responsive ────────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar--open { transform: translateX(0); }
  .main-content { margin-left: 0; padding: var(--space-4); }
  .line-item { grid-template-columns: 1fr 64px 100px 32px; }
}

/* ── Customer Registration Modal ───────────────────────────────────────────── */
.crm-modal {
  max-width: 900px;
  width: 95vw;
}

.crm-modal__body {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-8);
}

.crm-section-label {
  font-size: var(--text-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--color-primary-dark);
  border-bottom: 2px solid var(--color-primary);
  padding-bottom: var(--space-2);
  margin-bottom: var(--space-4);
}

.crm-subscriptions {
  display: flex;
  gap: var(--space-5);
  margin-top: var(--space-5);
}

.crm-checkbox-label {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-sm);
  font-weight: 500;
  cursor: pointer;
}

.crm-enter-hint {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  align-self: center;
}

/* ── Phone field with +234 prefix ──────────────────────────────────────────── */
.phone-field {
  display: flex;
  align-items: stretch;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  overflow: hidden;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.phone-field:focus-within {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px var(--color-primary-light);
}

.phone-field__prefix {
  display: flex;
  align-items: center;
  padding: 0 var(--space-3);
  background: var(--color-bg-subtle);
  border-right: 1px solid var(--color-border);
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--color-text-muted);
  user-select: none;
  white-space: nowrap;
}

.phone-field__input {
  border: none !important;
  border-radius: 0 !important;
  box-shadow: none !important;
  flex: 1;
}

.phone-dup-warn {
  font-size: var(--text-xs);
  color: var(--color-danger);
  margin-top: var(--space-1);
}

/* ── Searchable state dropdown ─────────────────────────────────────────────── */
.state-select {
  position: relative;
}

.state-select__list {
  position: fixed;
  max-height: 200px;
  overflow-y: auto;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  z-index: 9999;
  list-style: none;
  margin: 0;
  padding: var(--space-1) 0;
}

.state-select__item {
  padding: var(--space-2) var(--space-3);
  font-size: var(--text-sm);
  cursor: pointer;
  transition: background var(--transition);
}

.state-select__item:hover {
  background: var(--color-primary-light);
  color: var(--color-text);
}

/* ── Referral chips ────────────────────────────────────────────────────────── */
.chip-group {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-top: var(--space-2);
}

.chip {
  padding: var(--space-1) var(--space-3);
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-full);
  background: var(--color-surface);
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--color-text-muted);
  cursor: pointer;
  transition: all var(--transition);
}

.chip:hover {
  border-color: var(--color-primary);
  color: var(--color-text);
}

.chip--active {
  background: var(--color-primary);
  border-color: var(--color-primary);
  color: var(--color-text);
  font-weight: 600;
}

@media (max-width: 720px) {
  .crm-modal__body { grid-template-columns: 1fr; }
}

/* ── Marketing Hub — Proline-style metric cards ────────────────────────────── */
.mkt-metric-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-4);
  margin-bottom: var(--space-5);
}

.mkt-stat-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
}

.mkt-stat-card__label {
  font-size: var(--text-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--color-text-muted);
  margin-bottom: var(--space-3);
}

.mkt-stat-card__value {
  font-size: 2rem;
  font-weight: 800;
  line-height: 1;
  margin-bottom: var(--space-2);
}

.mkt-stat-card__sub {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
}

/* ── Marketing Hub — channel list sub-status filter ───────────────────────── */
.mkt-ch-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-4);
  flex-wrap: wrap;
  gap: var(--space-2);
}

.mkt-sf-row { display: flex; gap: var(--space-2); flex-wrap: wrap; }

.mkt-sf-btn {
  padding: 4px var(--space-3);
  border: 1px solid var(--color-border);
  border-radius: 999px;
  background: var(--color-surface);
  font-size: var(--text-xs);
  font-weight: 600;
  cursor: pointer;
  color: var(--color-text-muted);
  transition: background var(--transition), color var(--transition), border-color var(--transition);
}

.mkt-sf-btn:hover {
  background: var(--color-bg);
  border-color: var(--color-text-muted);
  color: var(--color-text);
}

.mkt-sf-btn--active {
  background: var(--color-text);
  color: #fff;
  border-color: var(--color-text);
}

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