/* ============================================================================
   EduzPortal — custom-admin.css
   One global stylesheet that turns plain Bootstrap markup into a premium,
   modern SaaS CRM dashboard. Light + dark themes, reusable components, no
   inline styles required in the pages. Drop this in and the app "just looks
   premium".
   ============================================================================ */

/* ---------- Design tokens — Material Design 3, seeded from the brand indigo ----------
   The component vocabulary below (buttons, cards, tabs, nav, fields) follows M3: tonal
   containers instead of tints, on-colors paired with every fill, flat surfaces with tonal
   elevation, pill buttons, 16px cards, 28px dialogs. Type stays Plus Jakarta Sans by the
   user's standing instruction — M3 permits a brand typeface in place of Roboto. */
:root {
  /* SNEATER design language (from the user's claude.ai/design mock): Manrope + Spline Sans Mono,
     indigo #4F46E5 primary, navy #0C1322 sidebar, neutral grey plane, white 14px cards. */
  --brand: #4F46E5;
  --on-brand: #ffffff;
  --brand-600: #4338CA;
  --brand-700: #3730A3;
  --brand-container: #EEF2FF;
  --on-brand-container: #4F46E5;
  --brand-soft: #EEF2FF;
  --brand-glow: rgba(79, 70, 229, .18);

  --ok: #0E9F6E;
  --warn: #F59E0B;
  --danger: #DC2626;
  --info: #0EA5E9;

  --bg: #F4F5F7;
  --surface: #FFFFFF;
  --surface-2: #FAFBFC;
  --sidebar: #0f1f47;
  --sidebar-2: #17305f;
  --sidebar-text: #8FA0B5;
  --sidebar-active: #FFFFFF;

  --text: #111827;
  --heading: #0C1322;
  --text-muted: #6B7280;
  --border: #E7E9EE;
  --ink: #0C1322;

  --inverse-surface: #0C1322;
  --on-inverse: #F1F5F9;

  --radius-xs: 8px;
  --radius-sm: 10px;
  --radius: 14px;
  --radius-lg: 16px;
  --radius-pill: 999px;

  --shadow-sm: 0 1px 2px rgba(16, 24, 40, .04);
  --shadow: 0 4px 10px -2px rgba(16, 24, 40, .08);
  --shadow-lg: 0 12px 28px -6px rgba(16, 24, 40, .16);

  --fs-2xs: .6875rem;
  --fs-xs: .75rem;
  --fs-sm: .8125rem;
  --fs-base: .875rem;
  --fs-md: 1rem;
  --fs-lg: 1.125rem;
  --fs-xl: 1.5rem;

  --sp-1: 4px; --sp-2: 8px; --sp-3: 12px; --sp-4: 16px; --sp-5: 24px; --sp-6: 32px;

  --sidebar-w: 242px;
  --topbar-h: 62px;
  --font: "Manrope", system-ui, sans-serif;
  --font-mono: "Spline Sans Mono", ui-monospace, monospace;

  --glass-1: #FFFFFF;
  --glass-2: #FAFBFC;
  --glass-solid: rgba(255, 255, 255, .92);
}

[data-theme="dark"] {
  --bg: #0A0F1A;
  --surface: #101827;
  --surface-2: #16203304;      /* replaced below */
  --surface-2: #172033;
  --sidebar: #080D16;
  --sidebar-2: #101827;
  --sidebar-text: #8FA0B5;
  --sidebar-active: #FFFFFF;

  --brand: #6366F1;
  --on-brand: #ffffff;
  --brand-600: #818CF8;
  --brand-700: #A5B4FC;
  --brand-container: rgba(99, 102, 241, .18);
  --on-brand-container: #C7D2FE;
  --brand-soft: rgba(99, 102, 241, .16);
  --brand-glow: rgba(99, 102, 241, .16);

  --text: #E5E9F0;
  --heading: #F1F5F9;
  --text-muted: #94A3B8;
  --border: rgba(148, 163, 184, .16);
  --ink: #101827;

  --inverse-surface: #E5E9F0;
  --on-inverse: #111827;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .45);
  --shadow: 0 4px 10px -2px rgba(0, 0, 0, .5);
  --shadow-lg: 0 12px 28px -6px rgba(0, 0, 0, .6);

  --glass-1: #101827;
  --glass-2: #0D1420;
  --glass-solid: rgba(16, 24, 39, .92);
}

* { box-sizing: border-box; }

html {
  scroll-behavior: smooth;
  scrollbar-gutter: stable;
}

body {
  margin: 0;
  font-family: var(--font);
  background:
    radial-gradient(circle at top left, rgba(79, 70, 229, .12), transparent 32%),
    radial-gradient(circle at bottom right, rgba(6, 182, 212, .10), transparent 28%),
    var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

[data-theme="dark"] body {
  background-image: radial-gradient(circle at top left, rgba(99, 102, 241, .16), transparent 30%),
                    radial-gradient(circle at bottom right, rgba(6, 182, 212, .12), transparent 35%);
}

[data-theme="dark"] .content,
[data-theme="dark"] .card,
[data-theme="dark"] .modal-content,
[data-theme="dark"] .dropdown-menu,
[data-theme="dark"] .toast-msg,
[data-theme="dark"] .noti-panel,
[data-theme="dark"] .form-control,
[data-theme="dark"] .form-select,
[data-theme="dark"] .table,
[data-theme="dark"] table.data {
  color: var(--text);
}

/* Bootstrap's own --bs-dropdown-bg stays white regardless of data-theme, so
   every dropdown (Settings menu, table row actions, …) rendered pale text on
   a white panel in dark mode. Give it the app's surface explicitly. */
[data-theme="dark"] .dropdown-menu {
  background: var(--surface);
  border-color: var(--border);
}

[data-theme="dark"] .form-control,
[data-theme="dark"] .form-select {
  background: rgba(255, 255, 255, .04);
  border-color: var(--border);
  color: var(--text);
}

[data-theme="dark"] .form-control::placeholder,
[data-theme="dark"] .form-select::placeholder {
  color: var(--text-muted);
}

[data-theme="dark"] .table thead th,
[data-theme="dark"] table.data thead th {
  color: var(--text-muted);
  background: rgba(255, 255, 255, .04);
}

[data-theme="dark"] .table td,
[data-theme="dark"] .table th,
[data-theme="dark"] table.data td,
[data-theme="dark"] table.data th {
  color: var(--text);
  border-color: var(--border);
}

[data-theme="dark"] .table tbody tr:hover,
[data-theme="dark"] table.data tbody tr:hover {
  background: rgba(99, 102, 241, .16);
}

/* ---------- Scrollbar polish ---------- */
::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, rgba(79, 70, 229, 0.45), rgba(99, 102, 241, 0.72));
  border-radius: var(--radius-pill);
  border: 2px solid transparent;
  background-clip: padding-box;
}

::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(180deg, rgba(79, 70, 229, 0.6), rgba(99, 102, 241, 0.85));
}

* {
  scrollbar-width: thin;
  scrollbar-color: rgba(99, 102, 241, 0.7) transparent;
}

a { text-decoration: none; color: var(--brand); }

/* ============================================================================
   Layout: sidebar + topbar + content
   ============================================================================ */
.app { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  background: var(--surface);
  color: var(--text);
  position: fixed;
  inset: 0 auto 0 0;
  display: flex;
  flex-direction: column;
  z-index: 1030;
  transition: transform .25s ease;
  border-right: 1px solid var(--border);
}

.sidebar__brand {
  height: auto;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 18px 20px;
  color: var(--text);
  font-weight: 800;
  font-size: var(--fs-lg);
  letter-spacing: .2px;
  border-bottom: 1px solid var(--border);
}
.sidebar__brand .logo {
  width: 44px; height: 44px; border-radius: var(--radius-sm);
  background: var(--ink);
  display: grid; place-items: center; color: #fff; font-weight: 800; font-size: var(--fs-lg);
  box-shadow: 0 8px 20px rgba(15, 23, 42, .22);
  flex-shrink: 0;
}
.sidebar__brand small { display: block; font-size: var(--fs-2xs); font-weight: 600; color: var(--text-muted); letter-spacing: .2px; }

.sidebar__nav { padding: 14px 12px; overflow-y: auto; flex: 1; }
.sidebar__nav::-webkit-scrollbar-thumb { background: rgba(100, 116, 139, .3); }
.sidebar__section {
  font-size: var(--fs-2xs); text-transform: uppercase; letter-spacing: .12em;
  color: var(--text-muted); margin: 18px 12px 8px; font-weight: 700;
}
.nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 14px; margin: 3px 0;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-weight: 600; font-size: var(--fs-base);
  transition: background .18s ease, color .18s ease;
  cursor: pointer;
}
.nav-item i { font-size: var(--fs-lg); width: 22px; text-align: center; }
.nav-item:hover { background: var(--brand-soft); color: var(--brand-600); }
.nav-item.active {
  background: var(--ink);
  color: #fff;
  box-shadow: 0 10px 22px rgba(15, 23, 42, .20);
}
.nav-item.active:hover { background: var(--ink); color: #fff; }
.nav-item.active i { color: #fff; }
/* Count badge on a nav item (e.g. Leads · 12) */
.nav-badge { margin-left: auto; background: var(--brand-soft); color: var(--brand-600); font-size: var(--fs-xs); font-weight: 800; padding: 1px 9px; border-radius: var(--radius-pill); }
.nav-item.active .nav-badge { background: rgba(255,255,255,.25); color: #fff; }

.nav-group { display: flex; flex-direction: column; gap: 0; }
.nav-toggle {
  background: none;
  border: none;
  padding: 11px 14px;
  margin: 3px 0;
  width: 100%;
  text-align: left;
  font-weight: 600;
  font-size: var(--fs-base);
  color: var(--text-muted);
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: background .18s ease, color .18s ease;
  display: flex;
  align-items: center;
  gap: 12px;
}
.nav-toggle i:first-child { font-size: var(--fs-lg); width: 22px; text-align: center; }
.nav-toggle:hover {
  background: var(--brand-soft);
  color: var(--brand-600);
}
.nav-toggle i:last-child {
  transition: transform .2s ease;
}
.nav-toggle[aria-expanded="true"] i:last-child {
  transform: rotate(90deg);
}

.nav-submenu {
  display: none;
  flex-direction: column;
  gap: 0;
  padding: 0 0 8px 0;
  margin: 0;
}
.nav-submenu.show {
  display: flex;
}

.nav-subitem {
  display: flex;
  align-items: center;
  padding: 10px 14px 10px 44px;
  margin: 0;
  border-radius: 0 12px 12px 0;
  color: var(--text-muted);
  font-size: var(--fs-base);
  font-weight: 500;
  transition: background .18s ease, color .18s ease;
  cursor: pointer;
  border: none;
  background: none;
  text-decoration: none;
}
.nav-subitem:hover {
  background: var(--brand-soft);
  color: var(--brand-600);
}
.nav-subitem.active {
  background: var(--brand-soft);
  color: var(--brand-600);
  font-weight: 600;
  border-left: 3px solid var(--brand);
  padding-left: 41px;
}

/* ---------- Drag & drop upload zone (media video thumbnail / banner) ---------- */
.dropzone {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  border: 1px solid var(--border); border-left: 3px solid var(--danger);
  border-radius: var(--radius-sm); padding: 10px 12px; background: var(--surface);
  transition: border-color .15s ease, background .15s ease;
}
.dropzone.dragover { border-color: var(--brand); background: var(--brand-soft); }
.dropzone__hint { color: var(--text-muted); font-weight: 700; }
.dropzone__name { color: var(--text); font-weight: 600; font-size: var(--fs-base); }
.dropzone__thumb { width: 46px; height: 46px; object-fit: cover; border-radius: var(--radius-xs); border: 1px solid var(--border); }

/* Sidebar footer — "Settings · Manage workspace" card (PDF look). */
.sidebar__foot { padding: 12px; border-top: 1px solid var(--border); flex: 0 0 auto; }
.settings-card {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 12px; border-radius: var(--radius);
  background: var(--surface-2); border: 1px solid var(--border);
  color: var(--text); cursor: pointer;
  transition: background .18s ease, border-color .18s ease, box-shadow .18s ease;
}
.settings-card:hover { background: var(--brand-soft); border-color: var(--brand); color: var(--text); box-shadow: var(--shadow-sm); }
.settings-card__ic {
  width: 38px; height: 38px; border-radius: var(--radius-sm); flex-shrink: 0;
  display: grid; place-items: center; font-size: var(--fs-lg);
  background: var(--surface); border: 1px solid var(--border); color: var(--text-muted);
}
.settings-card:hover .settings-card__ic { color: var(--brand); border-color: var(--brand); }
.settings-card__txt { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.settings-card__title { font-weight: 700; font-size: var(--fs-base); }
.settings-card__sub { font-size: var(--fs-xs); color: var(--text-muted); }

.main {
  flex: 1;
  margin-left: var(--sidebar-w);
  min-width: 0;
  display: flex;
  flex-direction: column;
  transition: margin-left .25s ease;
}

/* Collapsed (drawer closed) on desktop — hide the sidebar, content fills width.
   Scoped to desktop so it never conflicts with the mobile off-canvas .open state. */
@media (min-width: 769px) {
  .app.sidebar-collapsed .sidebar { transform: translateX(-100%); }
  .app.sidebar-collapsed .main { margin-left: 0; }
}

/* ============================================================================
   Horizontal top navigation (replaces the left sidebar app-wide)
   ============================================================================ */
.app.horizontal-nav .sidebar { display: none; }
.app.horizontal-nav .main { margin-left: 0; }
.app.horizontal-nav .topbar { height: auto; padding: 0; display: block; gap: 0; }

.topnav { display: flex; flex-direction: column; width: 100%; }
.topnav__bar { display: flex; align-items: center; gap: 20px; padding: 12px 24px; }
.topnav__brand { display: flex; align-items: center; gap: 12px; color: var(--text); text-decoration: none; flex-shrink: 0; }
.topnav__brand .logo {
  width: 42px; height: 42px; border-radius: var(--radius-sm); background: var(--ink);
  color: #fff; display: grid; place-items: center; font-weight: 800; font-size: var(--fs-lg);
  box-shadow: 0 8px 20px rgba(15, 23, 42, .22);
}
.topnav__brandtxt { display: flex; flex-direction: column; line-height: 1.05; }
.topnav__name { font-weight: 800; font-size: var(--fs-lg); }
.topnav__tag { font-size: .6rem; font-weight: 700; letter-spacing: .1em; color: var(--text-muted); }
/* "Agent" tag on a lead the branch received from a referral partner. */
.agent-tag {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 1px 7px; border-radius: var(--radius-pill); font-size: var(--fs-2xs); font-weight: 700;
  color: #92400e; background: #fef3c7; border: 1px solid #fcd34d;
}
@media (prefers-color-scheme: dark) {
  .agent-tag { color: #fde68a; background: rgba(251, 191, 36, .14); border-color: rgba(251, 191, 36, .35); }
}
:root[data-theme="dark"] .agent-tag { color: #fde68a; background: rgba(251, 191, 36, .14); border-color: rgba(251, 191, 36, .35); }
:root[data-theme="light"] .agent-tag { color: #92400e; background: #fef3c7; border-color: #fcd34d; }

/* A branch's own uploaded logo in the top bar. Constrained so any aspect ratio sits cleanly. */
.topnav__brand .brand-logo-img { max-height: 44px; max-width: 200px; object-fit: contain; display: block; }
/* "Your Logo" placeholder mark — a dashed, muted version of the brand tile. */
.topnav__brand .logo--ghost {
  background: transparent; color: var(--text-muted);
  border: 1.5px dashed var(--border); box-shadow: none; font-size: var(--fs-lg);
}
.topnav__actions { display: flex; align-items: center; gap: 12px; margin-left: auto; flex-shrink: 0; }
.topnav__user {
  display: flex; align-items: center; gap: 10px; background: none; border: none;
  cursor: pointer; padding: 5px 8px; border-radius: var(--radius-sm); color: var(--text);
  transition: background .15s ease;
}
.topnav__user:hover { background: var(--surface-2); }

.topnav__menu {
  display: flex; flex-wrap: wrap; align-items: center; gap: 2px;
  padding: 2px 16px; border-top: 1px solid var(--border);
}
.topnav__item {
  display: inline-flex; align-items: center; gap: 8px; white-space: nowrap;
  padding: 13px 15px; border-radius: 10px 10px 0 0; font-weight: 600; font-size: var(--fs-base);
  color: var(--text-muted); background: none; border: none; cursor: pointer;
  text-decoration: none; border-bottom: 2px solid transparent;
  transition: color .15s ease, background .15s ease;
}
.topnav__item i:first-child { font-size: var(--fs-md); }
.topnav__item:hover { color: var(--brand-600); }
.topnav__item.active { color: var(--brand-600); border-bottom-color: var(--brand); }
.topnav__group { position: relative; }
/* The dropdown inherited Bootstrap's 1rem, which read a size larger than the nav item that
   opens it. Everything below matches .topnav__item's typography so the menu reads as part of
   the nav rather than as a separate control. */
.topnav__menu .dropdown-menu {
  border-radius: var(--radius-sm); border: 1px solid var(--border); box-shadow: var(--shadow-lg);
  padding: 6px; min-width: 210px; font-size: var(--fs-base);
}
.topnav__menu .dropdown-item {
  display: flex; align-items: center; gap: 8px;
  border-radius: var(--radius-xs); padding: 9px 12px;
  font-size: var(--fs-base); font-weight: 600; line-height: 1.35;
}
.topnav__menu .dropdown-item i { font-size: var(--fs-md); width: 18px; text-align: center; }
.topnav__menu .dropdown-item.active { background: var(--brand-soft); color: var(--brand-600); }

/* Group labels inside the Settings menu ("Accounts", "Universities & Boards"…). */
.topnav__menu .dropdown-header {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 12px 4px; font-size: var(--fs-xs); font-weight: 800;
  letter-spacing: .08em; text-transform: uppercase; color: var(--text-muted);
}
.topnav__menu .dropdown-header i { font-size: var(--fs-base); }

.topbar {
  height: var(--topbar-h);
  background: var(--glass-solid);
  backdrop-filter: blur(18px);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 16px;
  padding: 0 24px;
  position: sticky; top: 0; z-index: 1020;
  box-shadow: 0 6px 24px rgba(15, 23, 42, .04);
}
.topbar__title { font-weight: 700; font-size: var(--fs-md); }
.topbar__spacer { flex: 1; }

.icon-btn {
  width: 40px; height: 40px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--surface);
  color: var(--text-muted); display: grid; place-items: center;
  cursor: pointer; transition: .15s;
}
.icon-btn:hover { color: var(--brand); border-color: var(--brand); background: var(--brand-soft); }

.avatar {
  width: 40px; height: 40px; border-radius: var(--radius-sm);
  background: var(--ink);
  color: #fff; display: grid; place-items: center; font-weight: 700;
}

.content { padding: 28px 24px 44px; max-width: 1520px; margin: 0 auto; width: 100%; }
/* Opt-in for pages that should use the full viewport width instead of the centered 1520px column. */
.content.content-fluid { max-width: none; }
.page-head {
  margin-bottom: 16px;
  padding: 2px 2px 14px;
  border: none;
  border-radius: 0;
  background: none;
  box-shadow: none;
}
/* Breadcrumb above the page title (e.g. "Leads › Academic Leads"). */
.crumb { font-size: var(--fs-sm); color: var(--text-muted); margin-bottom: 6px; display: flex; align-items: center; gap: 6px; }
.crumb a { color: var(--brand-600); font-weight: 600; }
.crumb i { font-size: var(--fs-xs); }
.page-head h1 {
  font-size: var(--fs-xl);
  font-weight: 800;
  margin: 0 0 6px;
  letter-spacing: -.02em;
  position: relative;
  display: inline-block;
}
.page-head h1::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: -8px;
  width: 64px;
  height: 4px;
  border-radius: var(--radius-pill);
  background: linear-gradient(90deg, var(--brand), #22d3ee);
}
.page-head p { color: var(--text-muted); margin: 8px 0 0; font-size: var(--fs-md); }

/* ============================================================================
   Cards
   ============================================================================ */
.card {
  background: linear-gradient(180deg, var(--glass-1), var(--glass-2));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 20px;
  transition: box-shadow .2s ease, transform .2s ease, border-color .2s ease;
}
.card:hover { box-shadow: var(--shadow); transform: translateY(-1px); }
/* Cards that only wrap a table sit flush — the table supplies its own padding. */
.card:has(> .table-wrap:only-child) { padding: 0; overflow: hidden; }
/* Cards using an explicit .card-body / .card-header keep their own padding. */
.card:has(> .card-body) { padding: 0; }
.card-header {
  padding: 16px 20px; border-bottom: 1px solid var(--border);
  font-weight: 700; display: flex; align-items: center; justify-content: space-between;
}
.card-body { padding: 20px; }

/* Stat widgets */
.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow-sm);
  display: flex; flex-direction: column; gap: 14px;
  transition: transform .2s ease, box-shadow .2s ease;
}
.stat:hover { transform: translateY(-3px); box-shadow: var(--shadow); }
.stat__top { display: flex; align-items: flex-start; justify-content: space-between; }
.stat__icon {
  width: 46px; height: 46px; border-radius: var(--radius-sm);
  display: grid; place-items: center; font-size: var(--fs-lg);
  flex-shrink: 0;
}
.stat__icon.b { background: var(--brand-soft); color: var(--brand-600); }
.stat__icon.g { background: rgba(16, 185, 129, .12); color: #059669; }
.stat__icon.o { background: rgba(245, 158, 11, .14); color: #b45309; }
.stat__icon.r { background: rgba(239, 68, 68, .12); color: #dc2626; }
.stat__trend { font-size: var(--fs-xs); font-weight: 800; padding: 3px 9px; border-radius: var(--radius-pill); display: inline-flex; align-items: center; gap: 3px; }
.stat__trend.up { background: rgba(16, 185, 129, .12); color: #059669; }
.stat__trend.flat { background: var(--surface-2); color: var(--text-muted); }
.stat__value { font-size: 2rem; font-weight: 800; line-height: 1; }
.stat__label { color: var(--text-muted); font-size: var(--fs-base); font-weight: 600; margin-top: 5px; }

/* Same card, shrunk. For rows that carry a tile per stream (followups: 5 streams x today/overdue),
   where ten full-size tiles cost a whole screen to say what fits in two rows. */
.stat--sm { padding: 14px 16px; gap: 10px; border-radius: var(--radius-sm); }
.stat--sm .stat__icon { width: 32px; height: 32px; font-size: var(--fs-base); border-radius: 9px; }
.stat--sm .stat__trend { font-size: 10px; padding: 2px 7px; }
.stat--sm .stat__value { font-size: 1.6rem; }
.stat--sm .stat__label { font-size: var(--fs-sm); margin-top: 3px; }
.stat--sm:hover { transform: translateY(-2px); }
/* Laid out in a Bootstrap row/col — stretch to the column so tiles in a row share one height
   whether the label runs to one line or two. */
.stat--sm { height: 100%; }

/* ---------- Topbar search ---------- */
.topbar__search { flex: 1; max-width: 520px; position: relative; }
.topbar__search input {
  width: 100%; height: 44px; border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface-2); color: var(--text); padding: 0 46px 0 42px; font-size: var(--fs-base); font-family: var(--font);
}
.topbar__search input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); background: var(--surface); }
.topbar__search input::placeholder { color: var(--text-muted); }
.topbar__search .tsi { position: absolute; left: 15px; top: 50%; transform: translateY(-50%); color: var(--text-muted); font-size: var(--fs-md); pointer-events: none; }
.topbar__search kbd { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); font-size: var(--fs-2xs); color: var(--text-muted); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-xs); padding: 2px 6px; font-family: var(--font); }

/* ---------- Dashboard bar chart ---------- */
.barchart { display: flex; align-items: flex-end; justify-content: space-between; gap: 10px; height: 230px; padding-top: 20px; }
.barchart .bar { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 8px; height: 100%; justify-content: flex-end; }
.barchart .bar__val { font-size: var(--fs-sm); font-weight: 700; color: var(--brand-600); }
.barchart .bar__fill { width: 100%; max-width: 46px; border-radius: 10px 10px 4px 4px; background: color-mix(in srgb, var(--brand) 22%, transparent); transition: height .4s ease; min-height: 6px; }
.barchart .bar.peak .bar__fill { background: linear-gradient(180deg, var(--brand), var(--brand-600)); }
.barchart .bar__label { font-size: var(--fs-sm); color: var(--text-muted); font-weight: 600; }

/* ---------- Dashboard donut ---------- */
.donut-wrap { display: flex; flex-direction: column; align-items: center; gap: 18px; }
.donut { position: relative; width: 180px; height: 180px; border-radius: 50%; }
.donut__center { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; }
.donut__center b { font-size: 1.7rem; font-weight: 800; line-height: 1; }
.donut__center span { font-size: var(--fs-sm); color: var(--text-muted); }
.legend { width: 100%; display: flex; flex-direction: column; gap: 10px; }
.legend__row { display: flex; align-items: center; gap: 10px; font-size: var(--fs-base); }
.legend__row .swatch { width: 11px; height: 11px; border-radius: 3px; }
.legend__row .legend__val { margin-left: auto; font-weight: 800; }

/* ============================================================================
   Tables
   ============================================================================ */
.table-wrap { overflow-x: auto; }
table.data {
  width: 100%; border-collapse: separate; border-spacing: 0;
  font-size: var(--fs-base);
}
table.data thead th {
  text-align: left; padding: 13px 16px;
  color: var(--text-muted); font-weight: 800; font-size: var(--fs-xs);
  text-transform: uppercase; letter-spacing: .09em;
  background: linear-gradient(180deg, rgba(248,250,252,.98), rgba(241,245,249,.96));
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
table.data tbody td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
  color: var(--text);
}
table.data tbody tr {
  transition: background .15s ease, transform .15s ease;
}
table.data tbody tr:hover {
  background: color-mix(in srgb, var(--brand) 9%, transparent);
}
table.data tbody tr:nth-child(even) {
  background: color-mix(in srgb, var(--brand) 3.5%, transparent);
}
table.data tbody tr.selected {
  background: color-mix(in srgb, var(--brand) 14%, transparent);
}

.table-actions {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.table-actions .icon-btn {
  width: 34px;
  height: 34px;
  border-radius: var(--radius-sm);
  padding: 0;
}

.table-actions .icon-btn:hover {
  transform: translateY(-1px);
}
table.data tbody tr.selected { background: color-mix(in srgb, var(--brand) 14%, transparent); }
table.data tbody tr:last-child td { border-bottom: none; }
.cell-primary { font-weight: 600; }
.cell-sub { color: var(--text-muted); font-size: var(--fs-sm); }

.table-actions {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.table-actions .icon-btn {
  width: 34px;
  height: 34px;
  border-radius: var(--radius-sm);
  padding: 0;
}

.table-actions .icon-btn:hover {
  transform: translateY(-1px);
}

/* ============================================================================
   Badges / status labels
   ============================================================================ */
.badge-soft {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px; border-radius: var(--radius-pill);
  font-size: var(--fs-xs); font-weight: 700; line-height: 1;
}
.badge-soft .dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.badge-b { background: var(--brand-soft); color: var(--brand-600); }
.badge-g { background: rgba(16, 185, 129, .12); color: #059669; }
.badge-o { background: rgba(245, 158, 11, .14); color: #b45309; }
.badge-r { background: rgba(239, 68, 68, .12); color: #dc2626; }
.badge-n { background: rgba(100, 116, 139, .14); color: #475569; }
/* status label whose colour comes from the DB (inline custom prop) */
.status-label {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px; border-radius: var(--radius-pill); font-size: var(--fs-xs); font-weight: 700;
  background: color-mix(in srgb, var(--c, #64748b) 14%, transparent);
  color: var(--c, #64748b);
}
.status-label .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--c, #64748b); }
.country-chip {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px; margin: 2px; border-radius: var(--radius-xs);
  background: var(--surface-2); border: 1px solid var(--border);
  font-size: var(--fs-sm); font-weight: 600;
}

/* ============================================================================
   Buttons / forms  (extend Bootstrap without inline styles)
   ============================================================================ */
.btn { border-radius: var(--radius-pill); font-weight: 700; padding: .62rem 1.1rem; letter-spacing: .01em; }
.btn-brand {
  background: linear-gradient(135deg, var(--brand), #6366f1);
  border-color: var(--brand);
  color: #fff;
  box-shadow: 0 10px 24px rgba(79, 70, 229, .22);
}
.btn-brand:hover {
  background: linear-gradient(135deg, var(--brand-600), var(--brand));
  border-color: var(--brand-600);
  color: #fff;
  transform: translateY(-1px);
}
.btn-ghost {
  background: var(--glass-solid);
  border: 1px solid var(--border);
  color: var(--text);
  box-shadow: var(--shadow-sm);
}
.btn-ghost:hover { border-color: var(--brand); color: var(--brand); background: var(--brand-soft); }

.form-control, .form-select {
  border-radius: var(--radius); border: 1px solid var(--border);
  background: rgba(255,255,255,.94); color: var(--text); padding: .7rem .85rem;
  box-shadow: inset 0 1px 2px rgba(15,23,42,.03);
}
.form-control:focus, .form-select:focus {
  border-color: var(--brand); box-shadow: 0 0 0 4px var(--brand-soft); background: var(--surface);
}
.form-label { font-weight: 600; font-size: var(--fs-base); margin-bottom: 6px; color: var(--text); }

/* Tabs (segmented) */
.tabs {
  display: inline-flex; gap: 4px; padding: 6px;
  background: linear-gradient(180deg, var(--glass-2), var(--glass-1));
  border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm);
  /* A strip can be wider than a phone (Document Settings' four tabs are 551px on a 365px screen).
     Scroll it inside its own pill rather than let it push the whole page sideways. No effect on
     wider screens, where the tabs already fit and no scrollbar appears. */
  max-width: 100%; overflow-x: auto; overflow-y: hidden; scrollbar-width: thin;
}
.tab {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 9px 18px; border-radius: var(--radius-sm); font-weight: 700; font-size: var(--fs-base);
  color: var(--text-muted); cursor: pointer; border: none; background: transparent;
  transition: background .15s ease, color .15s ease, box-shadow .15s ease, transform .15s ease;
  flex: 0 0 auto; white-space: nowrap;   /* never squash a tab to fit — the strip scrolls instead */
}
.tab i { font-size: var(--fs-md); }
.tab:hover:not(.active) { color: var(--text); background: color-mix(in srgb, var(--brand) 8%, transparent); transform: translateY(-1px); }
.tab.active { background: var(--surface); color: var(--brand-600); box-shadow: var(--shadow-sm); }
/* Per-tab count pill. Hidden until it has a number. */
.tab-badge {
  display: none; min-width: 18px; padding: 0 6px; margin-left: 4px;
  border-radius: var(--radius-pill); font-size: var(--fs-xs); font-weight: 800; line-height: 18px; text-align: center;
  background: color-mix(in srgb, var(--brand) 14%, transparent); color: var(--brand-600);
}
.tab-badge:not(:empty) { display: inline-block; }
.tab.active .tab-badge { background: color-mix(in srgb, var(--brand) 22%, transparent); }

/* ============================================================================
   Login
   ============================================================================ */
.auth {
  min-height: 100vh; display: grid; place-items: center; padding: 24px;
  background: radial-gradient(1200px 600px at 10% -10%, #6366f1 0%, transparent 55%),
              radial-gradient(1000px 700px at 110% 110%, #06b6d4 0%, transparent 50%),
              var(--bg);
}
.auth__card {
  width: 100%; max-width: 420px; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg);
  padding: 34px;
}
.auth__brand { display: flex; align-items: center; gap: 14px; margin-bottom: 28px; font-weight: 800; font-size: var(--fs-xl); }
.auth__brand .logo {
  width: 52px; height: 52px; border-radius: var(--radius);
  background: linear-gradient(135deg, var(--brand), #22d3ee);
  display: grid; place-items: center; color: #fff; font-weight: 800; font-size: var(--fs-xl);
  box-shadow: 0 12px 28px rgba(79, 70, 229, .28);
  flex-shrink: 0;
}

/* Utilities */
.muted { color: var(--text-muted); }
.grid-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 18px; }
/* Long labels ("Counselling · Overdue") must wrap inside the narrow tile, never push it wider. */
.stat--sm .stat__label { overflow-wrap: anywhere; }
.grid-2 { display: grid; grid-template-columns: 2fr 1fr; gap: 18px; }
.mt-18 { margin-top: 18px; }
.spinner-wrap { display: grid; place-items: center; padding: 40px; color: var(--text-muted); }
.empty { text-align: center; color: var(--text-muted); padding: 40px 20px; }
.toast-host { position: fixed; top: 18px; right: 18px; z-index: 2000; display: flex; flex-direction: column; gap: 10px; }
.toast-msg {
  background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--brand);
  border-radius: var(--radius-sm); box-shadow: var(--shadow-lg); padding: 12px 16px; min-width: 240px; font-weight: 500;
}
.toast-msg.err { border-left-color: var(--danger); }
.toast-msg.ok { border-left-color: var(--ok); }

/* Connection-lost banner (api.js's auto-retry) — one persistent, centered bar above everything
   (including modals) while the API is unreachable; hides itself the moment a retry gets through. */
.conn-lost-banner {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(12px);
  display: flex; align-items: center; gap: 12px;
  background: var(--surface); border: 1px solid var(--danger); border-radius: var(--radius-pill);
  box-shadow: var(--shadow-lg); padding: 10px 12px 10px 18px;
  z-index: 2500; font-weight: 600; font-size: var(--fs-base);
  opacity: 0; pointer-events: none;
  transition: opacity .18s ease, transform .18s ease;
}
.conn-lost-banner.show { opacity: 1; transform: translateX(-50%) translateY(0); pointer-events: auto; }
.conn-lost-banner i { color: var(--danger); font-size: var(--fs-lg); }
.conn-lost-banner__msg { color: var(--text); white-space: nowrap; }
.conn-lost-banner__count { color: var(--danger); }
.conn-lost-banner__btn { white-space: nowrap; }

/* The drawer toggle is always available (desktop collapse + mobile off-canvas). */
.sidebar__toggle { display: grid; }

/* Floating row-action menu (body-anchored so the table's overflow never clips it). */
.action-menu {
  position: fixed; z-index: 3000; min-width: 172px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); box-shadow: var(--shadow-lg); padding: 6px;
}
.action-menu button {
  display: flex; align-items: center; gap: 10px; width: 100%;
  background: none; border: none; text-align: left; cursor: pointer;
  padding: 9px 12px; border-radius: var(--radius-xs); color: var(--text);
  font-size: var(--fs-base); font-weight: 600;
}
.action-menu button i { font-size: var(--fs-md); width: 18px; text-align: center; }
.action-menu button:hover { background: var(--brand-soft); color: var(--brand-600); }
.action-menu button.danger:hover { background: rgba(239, 68, 68, .12); color: #dc2626; }

/* ---------- User dropdown ---------- */
#userDropdownBtn:hover {
  background: var(--surface-2) !important;
}

.dataTables_wrapper {
  padding: 16px 14px 8px;
}

.dataTables_wrapper .dataTables_length,
.dataTables_wrapper .dataTables_filter {
  margin-bottom: 16px;
}

.dataTables_wrapper .dataTables_length label,
.dataTables_wrapper .dataTables_filter label {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-muted);
  font-weight: 600;
  font-size: var(--fs-base);
}

.dataTables_wrapper .dataTables_length select {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: linear-gradient(180deg, rgba(255,255,255,.95), rgba(248,250,252,.93));
  color: var(--text);
  padding: 0.62rem 0.9rem;
  min-height: 40px;
  font-weight: 600;
  box-shadow: inset 0 1px 2px rgba(15,23,42,.03), var(--shadow-sm);
  cursor: pointer;
  transition: all .15s ease;
}

.dataTables_wrapper .dataTables_length select:hover {
  border-color: var(--brand);
  box-shadow: inset 0 1px 2px rgba(15,23,42,.03), 0 0 0 3px var(--brand-soft);
}

.dataTables_wrapper .dataTables_filter input {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: linear-gradient(180deg, rgba(255,255,255,.95), rgba(248,250,252,.93));
  color: var(--text);
  padding: 0.62rem 1rem;
  min-height: 40px;
  font-weight: 500;
  font-size: var(--fs-base);
  box-shadow: inset 0 1px 2px rgba(15,23,42,.03), var(--shadow-sm);
  transition: all .15s ease;
  min-width: 260px;
}

.dataTables_wrapper .dataTables_filter input::placeholder {
  color: var(--text-muted);
}

.dataTables_wrapper .dataTables_filter input:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: inset 0 1px 2px rgba(15,23,42,.03), 0 0 0 4px var(--brand-soft);
}

.dataTables_wrapper .dataTables_info {
  color: var(--text-muted);
  font-weight: 600;
  font-size: var(--fs-base);
  margin-bottom: 14px;
}

.dataTables_wrapper .dataTables_paginate {
  margin-bottom: 0;
  text-align: right;
}

.dataTables_wrapper .dataTables_paginate .paginate_button {
  border: 1px solid var(--border) !important;
  border-radius: var(--radius-sm) !important;
  background: linear-gradient(180deg, rgba(255,255,255,.96), rgba(248,250,252,.94)) !important;
  color: var(--text) !important;
  margin: 0 3px;
  padding: 0.5rem 0.8rem !important;
  font-weight: 700;
  font-size: var(--fs-base);
  box-shadow: var(--shadow-sm) !important;
  transition: all .15s ease !important;
}

.dataTables_wrapper .dataTables_paginate .paginate_button:hover {
  border-color: var(--brand) !important;
  background: linear-gradient(135deg, var(--brand), #6366f1) !important;
  color: #fff !important;
  transform: translateY(-2px);
  box-shadow: 0 8px 18px rgba(79, 70, 229, .25) !important;
}

.dataTables_wrapper .dataTables_paginate .paginate_button.current {
  background: linear-gradient(135deg, var(--brand), #6366f1) !important;
  border-color: var(--brand) !important;
  color: #fff !important;
  box-shadow: 0 8px 18px rgba(79, 70, 229, .25) !important;
}

.dataTables_wrapper .dataTables_paginate .paginate_button.disabled {
  opacity: 0.4 !important;
  cursor: not-allowed !important;
}

[data-theme="dark"] .dataTables_wrapper .dataTables_filter input,
[data-theme="dark"] .dataTables_wrapper .dataTables_length select {
  background: rgba(255, 255, 255, .08);
  border-color: rgba(255, 255, 255, .15);
  color: var(--text);
  box-shadow: inset 0 1px 2px rgba(0,0,0,.2);
}

[data-theme="dark"] .dataTables_wrapper .dataTables_paginate .paginate_button {
  background: rgba(255, 255, 255, .08) !important;
  border-color: rgba(255, 255, 255, .15) !important;
}
.dropdown-item {
  color: var(--text) !important;
}
.dropdown-item:hover {
  background: var(--brand-soft) !important;
  color: var(--brand) !important;
}
#logoutBtn:hover {
  background: #fef2f2 !important;
  color: var(--danger) !important;
}
[data-theme="dark"] #logoutBtn:hover {
  background: rgba(239, 68, 68, 0.1) !important;
}

/* ---------- SweetAlert2 (themed to match the app) ---------- */
.swal2-container.swal2-backdrop-show { background: rgba(15, 23, 42, .5); }
.swal2-popup.ep-swal {
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border);
  font-family: var(--font);
  padding: 28px 26px 24px;
  width: 32em; max-width: 94vw;
}
.ep-swal .swal2-title { color: var(--text); font-weight: 800; font-size: var(--fs-xl); padding: 6px 0 0; }
.ep-swal .swal2-html-container { color: var(--text-muted); font-size: var(--fs-md); margin-top: 8px; }
.ep-swal .swal2-actions { gap: 10px; margin-top: 22px; width: 100%; }
.ep-swal .swal2-actions .btn { min-width: 120px; padding: .6rem 1.2rem; }
.ep-swal .swal2-input,
.ep-swal .swal2-textarea,
.ep-swal .swal2-select {
  border-radius: var(--radius-sm); border: 1px solid var(--border);
  background: var(--surface); color: var(--text); box-shadow: none;
  font-size: var(--fs-md); margin: 10px 0 0; padding: .6rem .85rem; font-family: var(--font);
}
.ep-swal .swal2-input:focus,
.ep-swal .swal2-textarea:focus {
  border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); outline: none;
}
.ep-swal .swal2-input::placeholder { color: var(--text-muted); }
.ep-swal .swal2-validation-message {
  border-radius: var(--radius-sm); background: color-mix(in srgb, var(--danger) 10%, transparent);
  color: var(--danger); font-weight: 600;
}
.ep-swal .swal2-close { color: var(--text-muted); box-shadow: none !important; }
.ep-swal .swal2-close:hover { color: var(--danger); }
/* Status icons recoloured to the theme palette */
.ep-swal .swal2-icon { border-width: 3px; }
.ep-swal .swal2-icon.swal2-success { border-color: color-mix(in srgb, var(--ok) 40%, transparent); color: var(--ok); }
.ep-swal .swal2-icon.swal2-success .swal2-success-ring { border-color: color-mix(in srgb, var(--ok) 30%, transparent); }
.ep-swal .swal2-icon.swal2-success [class^='swal2-success-line'] { background-color: var(--ok); }
.ep-swal .swal2-icon.swal2-warning { border-color: color-mix(in srgb, var(--warn) 45%, transparent); color: var(--warn); }
.ep-swal .swal2-icon.swal2-error { border-color: color-mix(in srgb, var(--danger) 40%, transparent); color: var(--danger); }
.ep-swal .swal2-icon.swal2-error [class^='swal2-x-mark-line'] { background-color: var(--danger); }
.ep-swal .swal2-icon.swal2-info { border-color: color-mix(in srgb, var(--info) 45%, transparent); color: var(--info); }
.ep-swal .swal2-icon.swal2-question { border-color: color-mix(in srgb, var(--brand) 45%, transparent); color: var(--brand); }

/* ---------- Notifications (bell + dropdown) ---------- */
.noti { position: relative; }
.noti-badge {
  position: absolute; top: -3px; right: -3px; min-width: 18px; height: 18px; padding: 0 5px;
  border-radius: var(--radius-pill); background: var(--danger); color: #fff;
  font-size: var(--fs-2xs); font-weight: 800; line-height: 18px; text-align: center;
  box-shadow: 0 0 0 2px var(--surface); pointer-events: none;
}
.noti-panel {
  position: absolute; top: calc(100% + 12px); right: 0; width: 384px; max-width: 92vw;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow-lg); overflow: hidden; display: none; z-index: 1000;
}
.noti-panel.open { display: block; animation: notiIn .16s ease; }
@keyframes notiIn { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }
.noti-panel__head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 15px 18px; border-bottom: 1px solid var(--border);
}
.noti-panel__title { font-weight: 800; font-size: var(--fs-md); }
.noti-markall {
  border: none; background: transparent; color: var(--text-muted); cursor: pointer;
  width: 34px; height: 34px; border-radius: var(--radius-xs); display: grid; place-items: center; font-size: var(--fs-lg);
}
.noti-markall:hover { background: var(--brand-soft); color: var(--brand); }
.noti-list { max-height: 62vh; overflow-y: auto; }
.noti-item {
  display: flex; align-items: flex-start; gap: 12px; padding: 14px 18px;
  border-bottom: 1px solid var(--border); cursor: pointer; transition: background .12s;
}
.noti-item:last-child { border-bottom: none; }
.noti-item:hover { background: var(--surface-2); }
.noti-item.unread { background: color-mix(in srgb, var(--brand) 6%, transparent); }
.noti-ic {
  width: 44px; height: 44px; border-radius: 50%; flex-shrink: 0;
  display: grid; place-items: center; color: #fff; font-size: var(--fs-lg);
}
.noti-ic.b { background: linear-gradient(135deg, var(--brand), #818cf8); }
.noti-ic.g { background: linear-gradient(135deg, var(--ok), #34d399); }
.noti-ic.o { background: linear-gradient(135deg, var(--warn), #fbbf24); }
.noti-ic.r { background: linear-gradient(135deg, var(--danger), #fb7185); }
.noti-body { flex: 1; min-width: 0; }
.noti-title { font-weight: 700; font-size: var(--fs-base); color: var(--text); }
.noti-msg { color: var(--text-muted); font-size: var(--fs-sm); margin: 2px 0; line-height: 1.35; }
.noti-time { color: var(--text-muted); font-size: var(--fs-xs); font-weight: 500; }
.noti-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--brand); margin-top: 7px; flex-shrink: 0; }
.noti-item:not(.unread) .noti-dot { visibility: hidden; }
.noti-panel__foot { padding: 13px; text-align: center; border-top: 1px solid var(--border); background: var(--surface-2); }
.noti-panel__foot a { font-weight: 700; font-size: var(--fs-base); color: var(--brand); }
.noti-panel__foot a:hover { color: var(--brand-600); }
@media (max-width: 480px) {
  .noti-panel { position: fixed; top: var(--topbar-h); right: 8px; left: 8px; width: auto; }
}

/* ---------- Workflow pipeline ---------- */
/* Flex and grid children default to min-width:auto, so they refuse to shrink below their content's
   min-content width. A wide child (the 10-step .pipeline is 1200px min-content) therefore drags its
   whole card past the viewport on a phone instead of scrolling inside its own overflow-x container.
   Letting these shrink to 0 is what makes overflow-x:auto actually engage. */
.card-body,
.detail-grid > * { min-width: 0; }

.pipeline { display: flex; align-items: flex-start; gap: 0; overflow-x: auto; padding: 8px 0; max-width: 100%; }
.pipe-step { display: flex; flex-direction: column; align-items: center; min-width: 120px; position: relative; text-align: center; }
.pipe-step:not(:last-child)::after {
  content: ""; position: absolute; top: 17px; left: 50%; width: 100%; height: 3px;
  background: var(--border); z-index: 0;
}
.pipe-step.done::after { background: var(--ok); }
.pipe-dot {
  width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center;
  background: var(--surface); border: 3px solid var(--border); color: var(--text-muted);
  font-weight: 700; font-size: var(--fs-base); z-index: 1; position: relative;
}
.pipe-step.done .pipe-dot { background: var(--ok); border-color: var(--ok); color: #fff; }
.pipe-step.current .pipe-dot { border-color: var(--brand); color: var(--brand); box-shadow: 0 0 0 4px var(--brand-soft); }
.pipe-label { margin-top: 8px; font-size: var(--fs-sm); font-weight: 600; max-width: 110px; }
/* A completed step is clickable — it opens a read-only review of what was done there. */
.pipe-step--link { cursor: pointer; }
.pipe-step--link:hover .pipe-dot,
.pipe-step--link:focus-visible .pipe-dot { transform: scale(1.12); box-shadow: 0 0 0 4px var(--ok-soft, rgba(16, 185, 129, .22)); }
.pipe-step--link .pipe-dot { transition: transform .12s ease, box-shadow .12s ease; }
.pipe-step--link:hover .pipe-label { text-decoration: underline; }

/* --- Move-to-step / Status / Note / Advance bar (visa application "Manage" panel) --- */
.advance-bar {
  display: flex; gap: 16px; flex-wrap: wrap; align-items: flex-end;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px;
}
.advance-field { display: flex; flex-direction: column; gap: 6px; min-width: 180px; }
.advance-field--note { flex: 1 1 240px; }
.advance-field .form-label {
  margin-bottom: 0; font-size: var(--fs-xs); letter-spacing: .04em; text-transform: uppercase;
  color: var(--text-muted); font-weight: 700;
}
.advance-field .form-select, .advance-field .form-control { background: var(--surface); }
.advance-btn {
  white-space: nowrap; padding: 11px 22px; border-radius: var(--radius-sm); font-weight: 700;
  display: inline-flex; align-items: center; gap: 8px;
}
.advance-btn i { font-size: .9em; }

/* --- Step document checklist (Document Settings wired to the current pipeline step) --- */
.doc-checklist { border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; background: var(--surface); }
.doc-req-row {
  display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap;
  padding: 10px 0; border-top: 1px solid var(--border);
}
.doc-req-row:first-of-type { border-top: 0; padding-top: 2px; }
.doc-req-info { min-width: 200px; flex: 1; }
.doc-req-name { font-weight: 600; font-size: var(--fs-base); display: flex; align-items: center; flex-wrap: wrap; }
.doc-req-status { flex: 0 0 auto; }
.doc-req-actions { display: flex; align-items: center; gap: 4px; flex: 0 0 auto; }
.pipe-step.current .pipe-label { color: var(--brand-600); }

/* Detail two-column */
.detail-grid { display: grid; grid-template-columns: 320px 1fr; gap: 18px; align-items: start; }
.info-row { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--border); font-size: var(--fs-base); }
.info-row:last-child { border-bottom: none; }
.info-row .k { color: var(--text-muted); }
.info-row .v { font-weight: 600; text-align: right; }
.timeline { position: relative; padding-left: 22px; }
.timeline-item { position: relative; padding: 0 0 16px 14px; border-left: 2px solid var(--border); }
.timeline-item:last-child { border-left-color: transparent; }
.timeline-item::before { content: ""; position: absolute; left: -7px; top: 2px; width: 12px; height: 12px; border-radius: 50%; background: var(--brand); border: 2px solid var(--surface); }
@media (max-width: 992px) { .detail-grid { grid-template-columns: 1fr; } }

/* ============================================================================
   Global component polish — default look for every page (no inline styles)
   ============================================================================ */
/* Modals inherit the app theme automatically */
.modal-content {
  border: 1px solid var(--border); border-radius: var(--radius);
  background: linear-gradient(180deg, var(--glass-1), var(--glass-2));
  color: var(--text); box-shadow: var(--shadow-lg); backdrop-filter: blur(16px);
}
.modal-header, .modal-footer { border-color: var(--border); padding: 18px 22px; }
.modal-title { font-weight: 800; letter-spacing: -.01em; }
.modal-header .btn-close { filter: none; opacity: .8; }
.modal-backdrop.show { backdrop-filter: blur(6px); background: rgba(15, 23, 42, .55); }
[data-theme="dark"] .modal-header .btn-close { filter: invert(1) grayscale(1) brightness(1.6); }

/* Brand-coloured checkboxes / switches */
.form-check-input:checked { background-color: var(--brand); border-color: var(--brand); }
.form-check-input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }

/* Selects get a custom caret so they match text inputs */
select.form-control, .form-select {
  appearance: none; -webkit-appearance: none; -moz-appearance: none;
  background-image: url("data:image/svg+xml;charset=UTF-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 16 16' fill='none' stroke='%2364748b' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 6l4 4 4-4'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right .8rem center; background-size: 15px;
  padding-right: 2.2rem;
}

/* Section bar: a title with an action button on the right, inside a pane */
.section-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.section-bar h2 { font-size: var(--fs-md); font-weight: 800; margin: 0; }
.section-bar .cell-sub { max-width: 640px; }

/* Vertical rhythm so pages don't need inline margins between blocks */
.card + .card { margin-top: 16px; }
.stack > * + * { margin-top: 16px; }
.tabs + * { margin-top: 4px; }

/* Icon buttons line up a touch tighter in action cells */
table.data td .icon-btn { width: 34px; height: 34px; border-radius: var(--radius-sm); }

/* ---------- Responsive ---------- */
@media (max-width: 992px) {
  .grid-stats { grid-template-columns: repeat(2, 1fr); }
  .grid-2 { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
  .dataTables_wrapper {
    padding: 10px 6px 6px;
  }

  .dataTables_wrapper .dataTables_filter {
    float: none;
    width: 100%;
  }

  .dataTables_wrapper .dataTables_filter input {
    width: 100%;
  }

  .dataTables_wrapper .dataTables_length,
  .dataTables_wrapper .dataTables_info,
  .dataTables_wrapper .dataTables_paginate {
    text-align: center;
  }

  .dataTables_wrapper .dataTables_paginate .paginate_button {
    margin: 3px 2px;
  }

  table.data thead {
    display: none;
  }

  table.data tbody tr {
    display: block;
    margin-bottom: 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 10px;
    background: var(--surface);
    box-shadow: var(--shadow-sm);
  }

  table.data tbody td {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
  }

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

  table.data tbody td::before {
    content: attr(data-label);
    color: var(--text-muted);
    font-weight: 600;
    text-transform: uppercase;
    font-size: var(--fs-xs);
    letter-spacing: .06em;
  }
}
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main { margin-left: 0; }
  .sidebar__toggle { display: grid; }
  .grid-stats { grid-template-columns: 1fr 1fr; }
}

/* ============================================================================
   Colleges & Universities — the Add Uni & Programs form
   ============================================================================ */

/* The small "+" that sits inside a field's label and adds a missing dropdown value. */
.linkplus {
  border: 0; background: none; padding: 0 0 0 4px; cursor: pointer;
  color: var(--brand); font-weight: 800; font-size: var(--fs-md); line-height: 1;
}
.linkplus:hover { color: var(--ink, #16224a); }

/* The black "+" that appends another program block, per the design. */
.btn-ink { background: #111827; color: #fff; min-width: 44px; }
.btn-ink:hover { background: #1f2937; color: #fff; }

.program-block { position: relative; }
.program-remove { position: absolute; top: 10px; right: 10px; }

/* Language-score grid: a test per row, its components as labelled cells. */
.score-grid { display: flex; flex-direction: column; gap: 10px; }
.score-row {
  display: grid; grid-template-columns: 110px 1fr; gap: 10px; align-items: stretch;
  border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 8px;
}
.score-test {
  display: flex; flex-direction: column; justify-content: center; align-items: center;
  font-weight: 700; text-align: center; border-right: 1px solid var(--border); padding-right: 8px;
}
.score-cells { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.score-cell { min-width: 0; }
.score-head {
  font-size: var(--fs-sm); font-weight: 600; color: var(--text-muted);
  border-bottom: 1px solid var(--border); padding-bottom: 4px; margin-bottom: 6px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.score-cell .form-control { padding: 6px 8px; }

/* Radio "cards" (Full day / Half day / Custom, Yes / No …). The whole card is the label,
   so the click target is the card rather than the 14px dot. */
.opt-card {
  display: flex; align-items: center; gap: 10px; cursor: pointer; height: 100%;
  border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 14px 16px;
  font-weight: 600; transition: border-color .15s, background .15s;
}
.opt-card:hover { background: var(--surface-2, #fafafa); }
.opt-card input { margin: 0; flex: none; }
.opt-card.checked { border-color: var(--brand, #6366f1); background: rgba(99, 102, 241, .07); }
.opt-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.opt-grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (max-width: 768px) { .opt-grid, .opt-grid.two { grid-template-columns: 1fr; } }

/* ---------- Agreements ---------- */
/* Form on the left, counters + per-country groups on the right. */
.agreement-layout { display: grid; grid-template-columns: minmax(0, 380px) minmax(0, 1fr); gap: 18px; align-items: start; }
@media (max-width: 1100px) { .agreement-layout { grid-template-columns: 1fr; } }

.stat-row { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
@media (max-width: 640px) { .stat-row { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

.stat-tile { text-align: center; }
.stat-tile .icon {
  width: 62px; height: 62px; margin: 0 auto 10px; border-radius: var(--radius);
  display: grid; place-items: center; font-size: var(--fs-xl);
}
.stat-tile .label { font-size: var(--fs-base); color: var(--text-muted, #6b7280); font-weight: 600; }
.stat-tile .value { font-size: var(--fs-xl); font-weight: 800; margin-top: 2px; }

/* One hue per state, used by both the tile and the row badge. */
.tone-total  { background: #e7f6ee; color: #0f7a45; }
.tone-active { background: #e3f4fb; color: #0e7fa8; }
.tone-expired{ background: #fdeaea; color: #c0392b; }
.tone-expiring{ background: #fef6e0; color: #b7791f; }

.country-group + .country-group { margin-top: 14px; }
.country-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  width: 100%; background: none; border: 0; padding: 4px 2px; text-align: left;
}
.country-head .flag { font-size: var(--fs-xl); line-height: 1; }
.country-head .name { font-weight: 700; font-size: var(--fs-md); }
.country-head .count { text-align: right; font-size: var(--fs-sm); color: var(--text-muted, #6b7280); }
.country-head .count b { display: block; font-size: var(--fs-md); color: var(--text, #111); }
.country-head .chev { transition: transform .18s; }
.country-head[aria-expanded="true"] .chev { transform: rotate(180deg); }

/* ---------- Search field (icon inside the input + a clear button) ---------- */
.search-field { position: relative; display: block; }
.search-field > i.bi-search {
  position: absolute; left: 14px; top: 50%; transform: translateY(-50%);
  color: var(--text-muted); font-size: var(--fs-base); pointer-events: none;
}
.search-field .form-control { padding-left: 40px; padding-right: 38px; }
/* The native search "x" is inconsistent across browsers — we render our own. */
.search-field input[type="search"]::-webkit-search-cancel-button { display: none; }
.search-clear {
  position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
  border: 0; background: transparent; color: var(--text-muted);
  width: 26px; height: 26px; border-radius: var(--radius-pill); cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; font-size: var(--fs-xs);
}
.search-clear:hover { background: var(--surface-2); color: var(--text); }

/* ---------- Per-user permission matrix ---------- */
.perm-legend {
  display: flex; align-items: center; gap: 18px; flex-wrap: wrap;
  padding: 10px 14px; margin-bottom: 14px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface-2); font-size: var(--fs-sm); color: var(--text-muted);
}
.perm-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 6px; }
.perm-dot--role { background: var(--text-muted); }
.perm-dot--allow { background: var(--ok); }
.perm-dot--deny { background: var(--danger); }
/* A cell whose state differs from the role gets tinted, so overrides are obvious at a glance. */
.perm-cell { text-align: center; }
.perm-cell.is-allow { background: color-mix(in srgb, var(--ok) 12%, transparent); }
.perm-cell.is-deny { background: color-mix(in srgb, var(--danger) 10%, transparent); }
.perm-mod { font-weight: 700; }
.perm-mod small { display: block; font-weight: 500; color: var(--text-muted); font-size: var(--fs-2xs); }

/* Date-range preset pill ("Last 15 days ▾") that sits with the filter row. */
.range-pill {
  display: inline-flex; align-items: center; gap: 8px;
  border: 1px solid var(--brand, #6366f1); border-radius: var(--radius-pill);
  background: rgba(99, 102, 241, .08); color: var(--brand, #6366f1);
  font-weight: 700; font-size: var(--fs-base); padding: 9px 16px; white-space: nowrap;
}
.range-pill:hover { background: rgba(99, 102, 241, .16); }
.range-pill::after { margin-left: 2px; }
/* When the pill fills a filter-grid cell, centre its label and match the selects' height. */
.range-pill.w-100 { justify-content: center; min-height: 44px; }
#rangeMenu .dropdown-item.active { background: rgba(99, 102, 241, .12); color: var(--brand, #6366f1); font-weight: 600; }

/* The "— / Total Leave Duration" summary strip under the date pickers. */
.duration-strip {
  border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 14px 18px; margin-top: 18px;
}
.duration-strip .val { font-size: var(--fs-lg); font-weight: 800; color: var(--brand, #6366f1); }

/* Eligibility is a short checkbox list, while the score grid carries five columns per test.
   The generic .grid-2 splits 2fr/1fr — the wrong way round here — so this pair has its own. */
.program-panels {
  display: grid;
  grid-template-columns: minmax(0, 0.85fr) minmax(0, 1.65fr);
  gap: 18px;
  align-items: start;
}

@media (max-width: 992px) {
  .program-panels { grid-template-columns: 1fr; }
}

@media (max-width: 900px) {
  .score-row { grid-template-columns: 1fr; }
  .score-test { border-right: 0; border-bottom: 1px solid var(--border); padding: 0 0 6px; }
  .score-cells { grid-template-columns: repeat(2, 1fr); }
}

/* Position number beside a document in the Document Settings requirement list. */
.pos-badge {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 22px; height: 22px; padding: 0 6px; border-radius: var(--radius-xs);
  background: var(--surface-2); border: 1px solid var(--border);
  font-size: var(--fs-sm); font-weight: 700; color: var(--text-muted);
}

/* Multi-pick document list in the Add Documents modal. */
.doc-picklist {
  display: grid; grid-template-columns: 1fr 1fr; gap: 4px 16px;
  max-height: 260px; overflow-y: auto;
  border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px 12px;
}
.doc-pick { display: flex; align-items: center; gap: 8px; padding: 4px 0; cursor: pointer; font-size: var(--fs-base); }
.doc-pick input { width: 16px; height: 16px; }
@media (max-width: 560px) { .doc-picklist { grid-template-columns: 1fr; } }

/* ---------- Daily Material ---------- */
.material-grid {
  display: grid; gap: 16px;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
}
.material-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow-sm);
  display: flex; flex-direction: column; transition: transform .15s ease, box-shadow .15s ease;
}
.material-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
/* Posts are square by design, so reserve the space and never let a stray size shift the grid. */
.material-card__img { width: 100%; aspect-ratio: 1 / 1; object-fit: cover; display: block; background: var(--brand-soft); }
.material-card__body { padding: 14px; display: flex; flex-direction: column; gap: 4px; flex: 1; }
.material-card__body .btn { margin-top: auto; }
.material-card__caption {
  margin: 6px 0 0; font-size: var(--fs-base); color: var(--text-muted);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}

/* ============================================================================
   DataTables — dressed as part of the panel, not as a library
   ----------------------------------------------------------------------------
   DataTables 2.x wraps the table in .dt-container and injects a length select, a
   search box, an info line and paging buttons. Left alone these carry the library's
   own chrome, which reads as unfinished next to the rest of the admin. Everything
   below re-skins those five pieces with the panel's own inputs, ghost buttons and
   header typography — no markup changes, so it applies to every table we mount.
   ============================================================================ */
.dt-container { --dt-row-selected: 99, 91, 255; }

/* --- layout: controls above and below, breathing room around the table --- */
.dt-container .dt-layout-row {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; flex-wrap: wrap;
}
.dt-container .dt-layout-row.dt-layout-table { display: block; }
.dt-container > .dt-layout-row:first-child { margin: 0 0 16px; }
.dt-container > .dt-layout-row:last-child {
  margin: 16px 0 0; padding-top: 14px; border-top: 1px solid var(--border);
}
.dt-container .dt-layout-cell { display: flex; align-items: center; gap: 10px; }
.dt-container .dt-layout-cell.dt-layout-full { flex: 1; }

/* --- length select: a compact pill, label folded into it --- */
.dt-container .dt-length {
  display: inline-flex; align-items: center; gap: 8px;
  color: var(--text-muted); font-size: var(--fs-sm); font-weight: 600;
}
.dt-container .dt-length select {
  appearance: none; -webkit-appearance: none;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 8px 30px 8px 12px; min-width: 74px;
  background: var(--surface) url("data:image/svg+xml;charset=utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='%2364748b'%3E%3Cpath d='M4.5 6.5 8 10l3.5-3.5z'/%3E%3C/svg%3E") no-repeat right 9px center/14px;
  color: var(--text); font-size: var(--fs-base); font-weight: 600; cursor: pointer;
  transition: border-color .15s ease, box-shadow .15s ease;
}

/* --- search: a plain bordered field. An earlier version painted a magnifying-glass icon as a
       background image, but DataTables' own left padding kept overriding ours, so the icon sat on
       top of the placeholder. The icon isn't worth that fight — a clean input reads fine. --- */
.dt-container .dt-search { display: inline-flex; align-items: center; margin-left: auto; }
.dt-container .dt-search label { display: none; }        /* the placeholder carries the meaning */
.dt-container .dt-search input.dt-input,
.dt-container .dt-search input {
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 9px 16px; min-width: 260px; max-width: 100%; margin: 0;
  background: var(--surface-2);
  color: var(--text); font-size: var(--fs-base); font-weight: 500;
  transition: border-color .15s ease, box-shadow .15s ease, background-color .15s ease;
}
.dt-container .dt-search input::placeholder { color: var(--text-muted); font-weight: 500; }
/* Hide WebKit's native search decorations so only our field shows. */
.dt-container .dt-search input::-webkit-search-decoration,
.dt-container .dt-search input::-webkit-search-cancel-button { -webkit-appearance: none; appearance: none; }

.dt-container .dt-search input:focus,
.dt-container .dt-length select:focus {
  outline: none; background-color: var(--surface);
  border-color: var(--brand); box-shadow: 0 0 0 4px var(--brand-glow);
}

/* --- info line: quiet, tabular so the numbers don't jitter while paging --- */
.dt-container .dt-info {
  color: var(--text-muted); font-size: var(--fs-sm); font-weight: 600;
  font-variant-numeric: tabular-nums; padding: 0;
}

/* --- paging: square-ish pills, brand fill on the current page --- */
.dt-container .dt-paging { margin-left: auto; }
.dt-container .dt-paging nav { display: inline-flex; align-items: center; gap: 4px; }
.dt-container .dt-paging .dt-paging-button {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 36px; height: 36px; padding: 0 10px; margin: 0;
  border: 1px solid transparent; border-radius: var(--radius-sm);
  background: transparent; color: var(--text-muted);
  font-size: var(--fs-base); font-weight: 700; font-variant-numeric: tabular-nums;
  cursor: pointer; transition: background .15s ease, color .15s ease, border-color .15s ease;
}
.dt-container .dt-paging .dt-paging-button:hover:not(.disabled):not(.current) {
  background: var(--brand-soft); color: var(--brand-600); border-color: transparent;
}
.dt-container .dt-paging .dt-paging-button:focus-visible {
  outline: none; box-shadow: 0 0 0 4px var(--brand-glow);
}
.dt-container .dt-paging .dt-paging-button.current,
.dt-container .dt-paging .dt-paging-button.current:hover {
  background: var(--brand-600); border-color: var(--brand-600); color: #fff;
  box-shadow: 0 6px 16px var(--brand-glow);
}
.dt-container .dt-paging .dt-paging-button.disabled,
.dt-container .dt-paging .dt-paging-button.disabled:hover {
  color: var(--border); background: transparent; cursor: default; box-shadow: none;
}
.dt-container .dt-paging .dt-paging-button.ellipsis { pointer-events: none; color: var(--text-muted); }

/* --- headers: keep our uppercase caps, swap the library's arrows for a chevron pair --- */
table.data thead th.dt-orderable-asc,
table.data thead th.dt-orderable-desc { cursor: pointer; user-select: none; }
table.data thead th.dt-orderable-asc:hover,
table.data thead th.dt-orderable-desc:hover { color: var(--brand-600); }
table.data thead th.dt-ordering-asc,
table.data thead th.dt-ordering-desc { color: var(--brand-600); }

table.data thead th span.dt-column-order { position: relative; width: 12px; margin-left: 6px; }
table.data thead th span.dt-column-order::before,
table.data thead th span.dt-column-order::after {
  position: absolute; right: 0; line-height: 1;
  font-size: .6rem; opacity: .35; transition: opacity .15s ease;
}
table.data thead th span.dt-column-order::before { content: "B2"; top: -6px; }
table.data thead th span.dt-column-order::after  { content: "BC"; top: 1px; }
table.data thead th.dt-ordering-asc span.dt-column-order::before,
table.data thead th.dt-ordering-desc span.dt-column-order::after { opacity: 1; }

/* The library's own empty state sits inside our table; keep it in the .empty voice. */
table.data td.dt-empty { text-align: center; color: var(--text-muted); padding: 34px 16px; font-weight: 600; }

@media (max-width: 640px) {
  .dt-container .dt-search input { min-width: 0; width: 100%; }
  .dt-container .dt-search { width: 100%; margin-left: 0; }
  .dt-container > .dt-layout-row:first-child { flex-direction: column; align-items: stretch; }
}

/* ============================================================================
   Select2 — made to look exactly like .form-select
   ----------------------------------------------------------------------------
   Select2 hides the native <select> and renders its own markup. Left with its
   stock theme it sits a few pixels off ours and carries the wrong radius, focus
   ring and greys. These rules re-skin the closed control, the dropdown, the
   search field and the highlighted row so a Select2 dropdown is visually
   indistinguishable from a plain one — including in dark mode.
   ============================================================================ */
.select2-container { width: 100% !important; }

/* --- the closed control --- */
.select2-container--default .select2-selection--single {
  height: auto; min-height: 44px; display: flex; align-items: center;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 6px 12px; transition: border-color .15s ease, box-shadow .15s ease;
}
.select2-container--default .select2-selection--single .select2-selection__rendered {
  color: var(--text); font-size: var(--fs-base); font-weight: 500; line-height: 1.5; padding: 0; }
.select2-container--default .select2-selection--single .select2-selection__placeholder { color: var(--text-muted); }
.select2-container--default .select2-selection--single .select2-selection__arrow {
  height: 100%; top: 0; right: 10px; }
.select2-container--default .select2-selection--single .select2-selection__arrow b {
  border-color: var(--text-muted) transparent transparent; border-width: 5px 4px 0; }

.select2-container--default.select2-container--open .select2-selection--single,
.select2-container--default.select2-container--focus .select2-selection--single {
  border-color: var(--brand); box-shadow: 0 0 0 4px var(--brand-glow);
}
.select2-container--default.select2-container--open .select2-selection--single .select2-selection__arrow b {
  border-color: transparent transparent var(--brand-600); border-width: 0 4px 5px;
}
.select2-container--disabled .select2-selection--single { background: var(--surface-2); opacity: .7; }

/* --- multi-select: countries, and anywhere else several values are picked --- */
.select2-container--default .select2-selection--multiple {
  min-height: 44px; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 4px 8px;
}
.select2-container--default .select2-selection--multiple .select2-selection__choice {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--brand-soft); border: 1px solid transparent; border-radius: var(--radius-pill);
  color: var(--brand-600); font-size: var(--fs-sm); font-weight: 600; padding: 4px 12px 4px 6px; margin: 3px 6px 3px 0;
  line-height: 1;
}
.select2-container--default .select2-selection--multiple .select2-selection__choice__remove {
  display: inline-flex; align-items: center; justify-content: center;
  width: 18px; height: 18px; border-radius: 50%; flex: 0 0 auto;
  color: var(--brand-600); font-weight: 700; font-size: var(--fs-base); line-height: 1;
  border: 0; background: transparent; margin: 0; padding: 0; order: 2;
}
.select2-container--default .select2-selection--multiple .select2-selection__choice__remove:hover {
  background: var(--brand-600); color: #fff;
}
/* Flag + name inside a chip / dropdown option (data-flags selects). */
.s2-flag-item { display: inline-flex; align-items: center; gap: 7px; }
.s2-flag-item .cflag { flex: 0 0 auto; }
.select2-selection__choice .s2-flag-item { order: 1; }

/* --- the dropdown --- */
.select2-container--default .select2-dropdown {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg); overflow: hidden; margin-top: 4px;
}
.select2-container--default .select2-search--dropdown { padding: 10px; }
.select2-container--default .select2-search--dropdown .select2-search__field {
  border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 8px 12px;
  background: var(--surface-2); color: var(--text); font-size: var(--fs-base);
}
.select2-container--default .select2-search--dropdown .select2-search__field:focus {
  outline: none; background: var(--surface); border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-glow);
}
.select2-container--default .select2-results__options { max-height: 260px; padding: 0 6px 6px; }
.select2-container--default .select2-results__option {
  border-radius: var(--radius-xs); padding: 9px 12px; color: var(--text); font-size: var(--fs-base); font-weight: 500;
}
.select2-container--default .select2-results__option--highlighted[aria-selected],
.select2-container--default .select2-results__option--highlighted {
  background: var(--brand-soft); color: var(--brand-600);
}
.select2-container--default .select2-results__option[aria-selected="true"],
.select2-container--default .select2-results__option--selected {
  background: var(--brand-600); color: #fff; font-weight: 600;
}
.select2-container--default .select2-results__message { color: var(--text-muted); font-size: var(--fs-base); }

/* A dropdown opened from a modal is parented to it; keep it above the backdrop. */
.modal .select2-container { z-index: 1056; }

/* ============================================================================
   "Today" tiles with something still pending
   ----------------------------------------------------------------------------
   Two cues, both red, both only present when the dashboard adds .stat--alert —
   a zero count must look completely calm.

     ::before  a light that travels around the card's rounded border. It is a
               conic gradient masked down to a 2px ring, and the gradient's start
               angle is animated, so the highlight orbits the card rather than the
               card itself spinning.
     ::after   the card's own beat — a double thump, like a heartbeat, with a red
               glow that expands and fades on each beat.
   ============================================================================ */
@property --orbit {
  syntax: "<angle>";
  inherits: false;
  initial-value: 0deg;
}

.stat--alert {
  position: relative;
  border-color: transparent;
  animation: statHeartbeat 1.8s ease-in-out infinite;
}

/* The travelling border. */
.stat--alert::before {
  content: "";
  position: absolute; inset: 0; border-radius: inherit; pointer-events: none; z-index: 1;
  padding: 2px;                       /* the ring's thickness */
  background: conic-gradient(from var(--orbit),
    color-mix(in srgb, var(--danger) 18%, transparent) 0deg,
    color-mix(in srgb, var(--danger) 18%, transparent) 250deg,
    var(--danger) 320deg,
    #fff 340deg,
    var(--danger) 352deg,
    color-mix(in srgb, var(--danger) 18%, transparent) 360deg);
  /* Punch out the middle so only the border ring is painted. */
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
          mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
          mask-composite: exclude;
  animation: statOrbit 2.2s linear infinite;
}

/* The beat's glow. Separate from the ring so the two never fight. */
.stat--alert::after {
  content: "";
  position: absolute; inset: -1px; border-radius: inherit; pointer-events: none;
  box-shadow: 0 0 0 0 rgba(239, 68, 68, .45);
  animation: statThump 1.8s ease-out infinite;
}

.stat--alert .stat__value { color: var(--danger); }
.stat--alert .stat__trend {
  background: rgba(239, 68, 68, .12); color: #dc2626; font-weight: 700;
}
.stat--alert .stat__icon {
  background: rgba(239, 68, 68, .12); color: #dc2626;
}

/* The beat uses the independent `scale` property, not `transform`, so .stat:hover's
   translateY(-3px) still lifts the tile instead of being overwritten by the animation. */

@keyframes statOrbit  { to { --orbit: 360deg; } }

/* Lub-dub: two quick beats, then a rest — the shape of a real heartbeat. */
@keyframes statHeartbeat {
  0%, 100% { scale: 1; }
  12%      { scale: 1.035; }
  24%      { scale: 1; }
  36%      { scale: 1.022; }
  48%, 99% { scale: 1; }
}
@keyframes statThump {
  0%   { box-shadow: 0 0 0 0 rgba(239, 68, 68, .45); }
  35%  { box-shadow: 0 0 0 10px rgba(239, 68, 68, 0); }
  100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
}

/* Where @property is unsupported the angle cannot animate, so the ring would sit still.
   Give those browsers a plain red border instead of a frozen gradient. */
@supports not (background: conic-gradient(from var(--orbit), red, blue)) {
  .stat--alert::before { background: var(--danger); }
}

/* Respect the OS "reduce motion" setting — keep the red, drop the movement. */
@media (prefers-reduced-motion: reduce) {
  .stat--alert, .stat--alert::before, .stat--alert::after { animation: none; }
  .stat--alert::before { background: var(--danger); }
}

/* Select2 dropdown opened from inside a SweetAlert dialog (the offer-letter picker) — SweetAlert
   sits at z-index 1060+, so the dropdown must clear it. Parented to the popup via dropdownParent. */
.swal2-container .select2-container { z-index: 2000; }
.swal2-popup .select2-container--open .select2-dropdown { z-index: 2001; }
/* Give the two picker selects room and match the dialog's controls. */
.offer-pick .select2-selection--single { min-height: 42px; }

/* ============================================================================
   Flatpickr (datepicker) — dark theme
   Flatpickr ships its own light-only stylesheet and every date input on the
   site uses it, so without this the calendar popup stayed a plain white box
   no matter what app theme was active.
   ============================================================================ */
[data-theme="dark"] .flatpickr-calendar {
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  color: var(--text);
}
[data-theme="dark"] .flatpickr-calendar.arrowTop::before,
[data-theme="dark"] .flatpickr-calendar.arrowTop::after { border-bottom-color: var(--border); }
[data-theme="dark"] .flatpickr-calendar.arrowBottom::before,
[data-theme="dark"] .flatpickr-calendar.arrowBottom::after { border-top-color: var(--border); }
[data-theme="dark"] .flatpickr-months,
[data-theme="dark"] .flatpickr-weekdays {
  background: var(--surface-2);
}
[data-theme="dark"] .flatpickr-month,
[data-theme="dark"] .flatpickr-weekday,
[data-theme="dark"] .flatpickr-current-month .flatpickr-monthDropdown-months {
  color: var(--text);
  fill: var(--text);
}
[data-theme="dark"] .flatpickr-current-month input.cur-year {
  color: var(--text);
  background: transparent;
}
[data-theme="dark"] .flatpickr-current-month .flatpickr-monthDropdown-months {
  background: var(--surface-2);
}
[data-theme="dark"] .flatpickr-prev-month svg,
[data-theme="dark"] .flatpickr-next-month svg {
  fill: var(--text-muted);
}
[data-theme="dark"] .flatpickr-prev-month:hover svg,
[data-theme="dark"] .flatpickr-next-month:hover svg {
  fill: var(--brand);
}
[data-theme="dark"] .flatpickr-day {
  color: var(--text);
}
[data-theme="dark"] .flatpickr-day.flatpickr-disabled,
[data-theme="dark"] .flatpickr-day.flatpickr-disabled:hover,
[data-theme="dark"] .flatpickr-day.prevMonthDay,
[data-theme="dark"] .flatpickr-day.nextMonthDay {
  color: var(--text-muted);
  opacity: .45;
}
[data-theme="dark"] .flatpickr-day:hover,
[data-theme="dark"] .flatpickr-day.today:hover {
  background: var(--brand-soft);
  border-color: var(--brand-soft);
  color: var(--brand-600);
}
[data-theme="dark"] .flatpickr-day.today {
  border-color: var(--brand);
}
[data-theme="dark"] .flatpickr-day.selected,
[data-theme="dark"] .flatpickr-day.selected:hover,
[data-theme="dark"] .flatpickr-day.startRange,
[data-theme="dark"] .flatpickr-day.endRange {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
}
[data-theme="dark"] .flatpickr-time {
  background: var(--surface);
  border-top: 1px solid var(--border);
}
[data-theme="dark"] .flatpickr-time input,
[data-theme="dark"] .flatpickr-time .flatpickr-am-pm {
  color: var(--text);
  background: transparent;
}
[data-theme="dark"] .flatpickr-time input:hover,
[data-theme="dark"] .flatpickr-time .flatpickr-am-pm:hover {
  background: var(--surface-2);
}
[data-theme="dark"] .numInputWrapper span.arrowUp:after { border-bottom-color: var(--text-muted); }
[data-theme="dark"] .numInputWrapper span.arrowDown:after { border-top-color: var(--text-muted); }
[data-theme="dark"] .numInputWrapper:hover { background: var(--surface-2); }

/* ---------- Offer-letter add/edit dialog ---------- */
.offer-modal { padding: 0 0 8px; }
.offer-modal .swal2-html-container { margin: 12px 20px 0; max-height: 70vh; overflow-y: auto; }
.offer-modal .offer-form .form-label { font-weight: 700; font-size: var(--fs-sm); margin-bottom: 4px; }
/* The catalogue picker sits in its own soft panel so it reads as the shortcut, not another field. */
.offer-modal .offer-pick {
  background: var(--brand-soft); border: 1px solid color-mix(in srgb, var(--brand) 22%, transparent);
  border-radius: var(--radius-sm); padding: 12px 14px; margin-bottom: 16px;
}
.offer-modal .offer-pick > .form-label { color: var(--brand-600); font-weight: 800; }

/* ---------- Ctrl+K quick lead search dropdown ---------- */
.qs-results {
  position: absolute; top: calc(100% + 8px); left: 0; right: 0; z-index: 3200;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow-lg); padding: 6px; max-height: 60vh; overflow-y: auto;
}
.qs-empty { padding: 16px; text-align: center; color: var(--text-muted); font-size: var(--fs-base); }
.qs-item {
  display: block; padding: 9px 12px; border-radius: var(--radius-sm); text-decoration: none; color: var(--text);
}
.qs-item:hover { background: var(--brand-soft); }
.qs-item__main { display: flex; align-items: center; gap: 8px; }
.qs-name { font-weight: 700; font-size: var(--fs-base); }
.qs-type {
  font-size: var(--fs-2xs); font-weight: 700; letter-spacing: .04em; text-transform: uppercase;
  color: var(--text-muted); background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius-xs); padding: 1px 6px;
}
.qs-type--conv { color: var(--ok); background: rgba(16,185,129,.1); border-color: transparent; }
.qs-item__sub {
  display: flex; align-items: center; gap: 14px; margin-top: 3px;
  font-size: var(--fs-sm); color: var(--text-muted); flex-wrap: wrap;
}
.qs-item__sub i { margin-right: 3px; }
.qs-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 5px; vertical-align: middle; }
.qs-owner { margin-left: auto; font-weight: 600; }

/* ---------- Lead visit timeline (in the lead detail modal) ---------- */
.lead-visits { margin-top: 18px; border-top: 1px solid var(--border); padding-top: 14px; }
.lead-visits__head {
  display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px;
  font-size: var(--fs-xs); font-weight: 800; letter-spacing: .06em; color: var(--text-muted);
}
.lead-visits__count {
  display: inline-block; min-width: 20px; text-align: center; margin-left: 4px;
  background: var(--brand-soft); color: var(--brand-600); border-radius: var(--radius-pill); padding: 0 7px; font-size: var(--fs-xs);
}
.lead-visits__list { display: flex; flex-direction: column; gap: 10px; }
.visit-item { display: flex; gap: 10px; }
.visit-item__icon {
  flex: none; width: 30px; height: 30px; border-radius: var(--radius-xs); display: grid; place-items: center;
  background: var(--brand-soft); color: var(--brand-600); font-size: var(--fs-base);
}
.visit-item__top { display: flex; align-items: center; gap: 8px; }
.visit-item__type { font-weight: 700; font-size: var(--fs-base); }

/* ---------- Country flag (derived from ISO-2, shown next to any country name) ---------- */
/* Round country flag: a flag-icons background image clipped to a circle. !important because
   flag-icons' own .fi/.fis rules load at runtime (after this file) at equal specificity. */
.cflag {
  display: inline-block !important;
  width: 18px !important; height: 18px !important;
  border-radius: 50% !important;
  background-size: cover !important; background-position: center !important; background-repeat: no-repeat !important;
  margin-right: 6px; vertical-align: -4px; line-height: 1;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .12);
}
.cflag::before { content: "" !important; }   /* flag-icons adds an nbsp spacer — drop it */
/* Inside a country-chip the flag sits a touch tighter / smaller. */
.country-chip .cflag { width: 15px !important; height: 15px !important; margin-right: 5px; vertical-align: -3px; }

/* ---------- Subscription package cards ---------- */
.pkg-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow-sm); display: flex; flex-direction: column; overflow: hidden;
}
.pkg-card--off { opacity: .72; }
.pkg-card__head { padding: 16px 18px; background: var(--brand-soft); border-bottom: 1px solid var(--border); text-align: center; }
.pkg-card__name { font-weight: 800; font-size: var(--fs-md); color: var(--brand-700); letter-spacing: .02em; }
.pkg-card__sub { font-size: var(--fs-sm); color: var(--brand-600); font-weight: 600; margin-top: 2px; }
.pkg-card__body { padding: 16px 18px; display: flex; flex-direction: column; gap: 14px; flex: 1; }
.pkg-feats { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.pkg-feats li { font-size: var(--fs-base); display: flex; align-items: flex-start; gap: 7px; }
.pkg-feats li i { color: var(--ok); font-size: var(--fs-md); margin-top: 1px; }
.pkg-specs { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); }
.pkg-specs td { padding: 5px 0; border-bottom: 1px dashed var(--border); color: var(--text-muted); }
.pkg-specs td.text-end { color: var(--text); font-weight: 700; }
.pkg-card__prices table td.text-end { color: var(--brand-600); }
.pkg-offers { background: rgba(16,185,129,.06); border: 1px solid rgba(16,185,129,.25); border-radius: var(--radius-sm); padding: 10px 12px; }
.pkg-offer { margin-top: 6px; font-size: var(--fs-sm); }
.pkg-offer__code { font-weight: 800; color: var(--ok); letter-spacing: .5px; }
.pkg-card__foot { padding: 12px 16px; border-top: 1px solid var(--border); display: flex; gap: 6px; justify-content: flex-end; }

/* ---------- Subscribe: amounts + pay QR + approvals ---------- */
.sub-amounts { border-top: 1px solid var(--border); padding-top: 10px; }
.sub-amt { display: flex; justify-content: space-between; padding: 4px 0; font-size: var(--fs-base); color: var(--text-muted); }
.sub-amt b { color: var(--text); }
.sub-amt--off b { color: var(--danger); }
.sub-amt--total { border-top: 1px dashed var(--border); margin-top: 4px; padding-top: 8px; font-size: var(--fs-md); }
.sub-amt--total b { color: var(--brand-600); }
.pay-qr { display: flex; justify-content: center; margin: 14px 0; }
.pay-qr img, .pay-qr canvas { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 8px; background: #fff; }
.appr-item {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 12px 14px; margin-bottom: 10px;
}

/* ---------- Package "menus in this plan" checklist ---------- */
.menu-pick {
  border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 8px 10px;
  max-height: 240px; overflow-y: auto; background: var(--surface-2);
}
.menu-pick__section {
  font-size: var(--fs-2xs); font-weight: 800; letter-spacing: .08em; text-transform: uppercase;
  color: var(--text-muted); padding: 8px 4px 4px;
}
.menu-pick__item {
  display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: var(--radius-xs);
  font-size: var(--fs-base); font-weight: 600; cursor: pointer;
}
.menu-pick__item:hover { background: var(--brand-soft); }
.menu-pick__item i { color: var(--brand-600); width: 18px; text-align: center; }
.menu-pick__item input { width: 16px; height: 16px; }

/* Menu checklist: group header + indented sub-menus */
.menu-pick__group { border-bottom: 1px dashed var(--border); padding-bottom: 4px; margin-bottom: 4px; }
.menu-pick__head { font-weight: 800; }
.menu-pick__subs { padding-left: 22px; }
.menu-pick__sub { font-weight: 500; font-size: var(--fs-sm); }
.menu-pick__sub i { color: var(--text-muted); font-size: var(--fs-xs); }

/* Coupon apply feedback in the subscribe dialog */
.coupon-msg { font-size: var(--fs-sm); margin-top: 5px; min-height: 1.1em; }
.coupon-msg--ok { color: var(--ok); font-weight: 600; }
.coupon-msg--err { color: var(--danger); font-weight: 600; }


/* ============================================================================
   Mobile top-nav: hamburger toggles the horizontal menu into a vertical panel
   ============================================================================ */
.topnav__toggle { display: none; background: none; border: 0; color: var(--text); font-size: var(--fs-xl); line-height: 1; cursor: pointer; padding: 2px 6px; }
@media (max-width: 860px) {
  .topnav__bar { gap: 10px; padding: 10px 14px; flex-wrap: wrap; }
  .topbar__search { display: none; }
  .topnav__toggle { display: inline-flex; align-items: center; }
  .topnav__menu { display: none; flex-direction: column; align-items: stretch; gap: 0; padding: 4px 12px 12px; max-height: 74vh; overflow-y: auto; border-top: 1px solid var(--border); }
  .topnav.nav-open .topnav__menu { display: flex; }
  .topnav__menu > .topnav__item, .topnav__group { width: 100%; border-bottom: 1px solid var(--border); }
  .topnav__menu > .topnav__item { padding: 13px 6px; }
  .topnav__group .topnav__item.dropdown-toggle { width: 100%; padding: 13px 6px; text-align: left; display: flex; align-items: center; gap: 8px; }
  .topnav__group .dropdown-menu { position: static !important; display: block !important; transform: none !important; float: none; border: 0; box-shadow: none; background: transparent; padding: 0 0 8px 22px; margin: 0; min-width: 0; }
  .topnav__group .dropdown-toggle::after { margin-left: auto; }
  .topnav__menu .dropdown-item { padding: 9px 6px; }
  .topnav__menu .dropdown-header { padding: 8px 6px 2px; }
}

/* --- Visa type per interested country (lead form) --- */
.vt-panel { border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-2); padding: 10px 12px; }
.vt-panel-head { font-size: var(--fs-xs); font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--text-muted); display: flex; align-items: center; gap: 6px; margin-bottom: 8px; }
.vt-row { display: grid; grid-template-columns: minmax(130px, 38%) 1fr; gap: 10px; align-items: center; padding: 7px 0; }
.vt-row + .vt-row { border-top: 1px solid var(--border); }
.vt-country { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: var(--fs-base); }
.vt-country .cflag { flex: 0 0 auto; }
.vt-select { max-width: 100%; }
.vt-none { font-size: var(--fs-sm); color: var(--text-muted); font-style: italic; }
@media (max-width: 560px) { .vt-row { grid-template-columns: 1fr; gap: 6px; } }


/* ---------- Dashboard: month trend charts + walk-ins ---------- */

/* Two accents, one per chart. Each chart is a single series, so these never sit adjacent
   as categories — but both were validated against the real surfaces (#fff / #0f172a) for
   lightness band, chroma, CVD separation and contrast. The light greens/ambers used
   elsewhere sit under 3:1 on white, so every bar carries a visible value label (the
   contrast relief) rather than relying on the fill alone. */
:root {
  --chart-leads: #6366F1;
  --chart-signup: #10B981;
}
[data-theme="dark"] {
  /* Same two hues re-stepped for the dark surface — #10b981 is too light there (it fails
     the dark lightness band); this is the step that passes. Not an automatic flip. */
  --chart-leads: #818CF8;
  --chart-signup: #34D399;
}

.stat__trend.down { background: rgba(239, 68, 68, .12); color: #dc2626; }

/* An even 50/50 split, unlike the generic .grid-2 (2fr/1fr). A class rather than an inline
   style so the 992px rule above can still collapse it to one column — an inline
   grid-template-columns would outrank the media query and keep both charts side by side on a
   phone, squeezing six months of labels into ~160px until they overlap. */
.grid-2--even { grid-template-columns: 1fr 1fr; }
@media (max-width: 992px) { .grid-2--even { grid-template-columns: 1fr; } }

.trendchart { display: flex; align-items: stretch; justify-content: space-between; gap: 8px;
  height: 168px; padding-top: 18px; }
.trendchart .tbar { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px;
  height: 100%; min-width: 0; }
/* Values are ink, never the series colour — the bar beside them carries the identity. */
.trendchart .tbar__val { flex: 0 0 auto; font-size: var(--fs-xs); font-weight: 700; color: var(--text-muted);
  font-variant-numeric: tabular-nums; }
/* The bar's height is a % of THIS track, not of the whole column — the track is what's left once
   the value and month label have taken their space. The fill must also refuse to flex-shrink:
   as a plain flex item it gets squashed to fit, which silently renders a 432 and a 344 as the
   same height and turns the chart into a lie. */
.trendchart .tbar__track { flex: 1 1 auto; min-height: 0; width: 100%;
  display: flex; align-items: flex-end; justify-content: center; }
.trendchart .tbar__fill { flex: 0 0 auto; width: 100%; max-width: 40px; min-height: 3px;
  border-radius: 6px 6px 3px 3px;
  background: color-mix(in srgb, var(--c) 22%, transparent); transition: height .4s ease; }
.trendchart .tbar__label { flex: 0 0 auto; font-size: var(--fs-xs); color: var(--text-muted); font-weight: 600; }
/* Emphasis: the month being asked about is solid, every other month recedes to the same
   hue at 22%. One hue, no legend needed — the card title names the series. */
.trendchart .tbar.is-now .tbar__fill { background: var(--c); }
.trendchart .tbar.is-now .tbar__val { color: var(--text); font-weight: 800; }
.trendchart .tbar.is-now .tbar__label { color: var(--text); font-weight: 800; }

.walkin-list { display: flex; flex-direction: column; }
.walkin { display: flex; align-items: center; gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--border); }
.walkin:last-child { border-bottom: 0; }
.walkin__time { font-weight: 800; font-size: var(--fs-sm); font-variant-numeric: tabular-nums;
  color: var(--text); flex: 0 0 auto; min-width: 64px; }
.walkin__who { min-width: 0; flex: 1; }
.walkin__meta { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

@media (max-width: 700px) {
  .trendchart { height: 140px; }
  .trendchart .tbar__fill { max-width: 28px; }
}


/* ---------- Dashboard: country demand card ---------- */
.cdem { display: flex; flex-direction: column; }
.cdem__row { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 12px;
  padding: 12px 0; border-bottom: 1px solid var(--border); }
.cdem__row:last-child { border-bottom: 0; }
.cdem__row .cflag { width: 30px !important; height: 30px !important; flex: 0 0 auto; }
.cdem__main { min-width: 0; }
.cdem__name { font-weight: 700; font-size: var(--fs-base); display: flex; align-items: center;
  gap: 6px; flex-wrap: wrap; }
/* One hue, length = magnitude: the honest read for "who is asking for what", and it keeps the
   list scannable without a second axis. Track first so a short bar still reads as a share. */
.cdem__bar { margin-top: 6px; height: 6px; border-radius: 999px; background: var(--surface-2);
  overflow: hidden; }
.cdem__bar > span { display: block; height: 100%; border-radius: 999px;
  background: var(--chart-leads); transition: width .4s ease; }
.cdem__nums { display: flex; align-items: center; gap: 14px; flex: 0 0 auto; }
.cdem__n { text-align: right; }
.cdem__n b { display: block; font-size: 1.05rem; font-weight: 800; line-height: 1.1;
  font-variant-numeric: tabular-nums; color: var(--text); }
.cdem__n span { font-size: var(--fs-xs); color: var(--text-muted); font-weight: 600; }
/* A zero is context, not news — mute it so the eye lands on the counts that matter. */
.cdem__n.is-zero b { color: var(--text-muted); font-weight: 700; }
.cdem__vt { font-size: var(--fs-xs); font-weight: 700; padding: 2px 7px; border-radius: 999px;
  background: var(--brand-soft); color: var(--brand-600); }

/* Segmented Today / This month switch. */
.seg { display: inline-flex; background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius-pill); padding: 3px; gap: 2px; }
.seg button { border: 0; background: transparent; color: var(--text-muted); font-weight: 700;
  font-size: var(--fs-sm); padding: 5px 14px; border-radius: var(--radius-pill); cursor: pointer;
  font-family: inherit; }
.seg button.is-on { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }

@media (max-width: 700px) {
  .cdem__row { grid-template-columns: auto 1fr; }
  .cdem__nums { grid-column: 1 / -1; justify-content: flex-start; gap: 18px; padding-left: 42px; }
  .cdem__n { text-align: left; }
}


/* ---------- Dashboard: pipeline stock bar ---------- */
/* Part-to-whole, horizontal: four states with long names. Every segment is named with its count in
   the legend, so identity never rests on colour alone (and that is the relief for the two hues
   that sit under 3:1 on white). */
.pipe__bar { display: flex; height: 14px; border-radius: 999px; overflow: hidden; gap: 2px;
  background: var(--surface-2); }
.pipe__seg { min-width: 3px; transition: flex-basis .4s ease; }
.pipe__legend { display: flex; gap: 18px; flex-wrap: wrap; margin-top: 14px; }
.pipe__item { display: flex; align-items: center; gap: 8px; }
.pipe__dot { width: 10px; height: 10px; border-radius: 3px; flex: 0 0 auto; }
.pipe__txt b { display: block; font-size: 1.05rem; font-weight: 800; line-height: 1.15;
  font-variant-numeric: tabular-nums; }
.pipe__txt span { font-size: var(--fs-xs); color: var(--text-muted); font-weight: 600; }

@media (max-width: 700px) {
  .pipe__legend { gap: 12px 18px; }
}


/* ---------- Counselling live: popup + corner dock ---------- */
.cl-backdrop { position: fixed; inset: 0; z-index: 1080; display: none; align-items: center;
  justify-content: center; padding: 20px; background: rgba(15, 23, 42, .5); backdrop-filter: blur(2px); }
.cl-backdrop.is-on { display: flex; }
.cl-pop { width: 100%; max-width: 440px; max-height: 90vh; overflow: auto; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg);
  animation: clPop .18s ease-out; }
@keyframes clPop { from { opacity: 0; transform: translateY(8px) scale(.98); } }
/* The lead just landed and someone is waiting — the entrance is quick, not theatrical. */
@media (prefers-reduced-motion: reduce) { .cl-pop { animation: none; } }

.cl-pop__head { display: flex; align-items: center; gap: 10px; padding: 16px 18px;
  border-bottom: 1px solid var(--border); }
.cl-pop__head h3 { margin: 0; font-size: 1.05rem; font-weight: 800; flex: 1; }
.cl-ic { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center;
  background: var(--brand-soft); color: var(--brand-600); flex: 0 0 auto; }
.cl-pop__body { padding: 16px 18px; }
.cl-pop__foot { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap;
  padding: 14px 18px; border-top: 1px solid var(--border); background: var(--surface-2);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg); }

.cl-lead { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.cl-ava { width: 44px; height: 44px; font-size: .95rem; flex: 0 0 auto; }
.cl-name { font-weight: 800; font-size: 1.05rem; }
.cl-rows { display: flex; flex-direction: column; }
.cl-row { display: flex; gap: 12px; justify-content: space-between; padding: 7px 0;
  border-bottom: 1px solid var(--border); font-size: var(--fs-sm); }
.cl-row:last-child { border-bottom: 0; }
.cl-row span { color: var(--text-muted); font-weight: 600; flex: 0 0 auto; }
.cl-row b { text-align: right; min-width: 0; overflow-wrap: anywhere; }

.cl-clock { margin-top: 14px; text-align: center; padding: 14px; border-radius: var(--radius-sm);
  background: var(--brand-soft); }
.cl-clock__t { font-size: 2rem; font-weight: 800; line-height: 1; color: var(--brand-600);
  font-variant-numeric: tabular-nums; }
.cl-clock__l { font-size: var(--fs-xs); color: var(--text-muted); font-weight: 600; margin-top: 4px; }
.cl-notes { display: block; margin-top: 12px; }
.cl-notes > span { display: block; font-size: var(--fs-sm); font-weight: 700; margin-bottom: 5px; }
.cl-notes i { color: var(--text-muted); font-weight: 500; font-style: normal; }
.cl-notes textarea { width: 100%; border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 9px 11px; font-family: inherit; font-size: var(--fs-sm); background: var(--surface);
  color: var(--text); resize: vertical; }

/* The session keeps running while the popup is away — this is the only thing telling them so. */
.cl-dock { position: fixed; right: 18px; bottom: 18px; z-index: 1070; display: none;
  align-items: center; gap: 10px; padding: 10px 16px 10px 12px; border: 1px solid var(--border);
  border-radius: var(--radius-pill); background: var(--surface); box-shadow: var(--shadow-lg);
  cursor: pointer; font-family: inherit; color: inherit; }
.cl-dock.is-on { display: inline-flex; }
.cl-dock:hover { border-color: var(--brand); }
.cl-dock__pulse { width: 9px; height: 9px; border-radius: 50%; background: #10b981; flex: 0 0 auto;
  box-shadow: 0 0 0 0 rgba(16, 185, 129, .6); animation: clPulse 2s infinite; }
@keyframes clPulse { 70% { box-shadow: 0 0 0 9px rgba(16, 185, 129, 0); } 100% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); } }
@media (prefers-reduced-motion: reduce) { .cl-dock__pulse { animation: none; } }
.cl-dock__txt { display: flex; flex-direction: column; align-items: flex-start; line-height: 1.15; min-width: 0; }
.cl-dock__txt b { font-size: var(--fs-base); font-weight: 800; font-variant-numeric: tabular-nums; }
.cl-dock__txt span { font-size: var(--fs-xs); color: var(--text-muted); font-weight: 600;
  max-width: 150px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

@media (max-width: 560px) {
  .cl-dock { right: 12px; bottom: 12px; }
  .cl-pop__foot { justify-content: stretch; }
  .cl-pop__foot .btn { flex: 1 1 auto; justify-content: center; }
}


/* Shown under the staff picker when the chosen counsellor is mid-session. Amber, not red: handing
   them the next lead is a normal thing to do, so this informs the choice rather than forbids it. */
.busy-note { display: flex; align-items: flex-start; gap: 8px; margin-top: 8px; padding: 9px 11px;
  border-radius: var(--radius-sm); background: rgba(245, 158, 11, .12); color: #b45309;
  font-size: var(--fs-sm); font-weight: 600; line-height: 1.4; }
.busy-note i { margin-top: 2px; flex: 0 0 auto; }
[data-theme="dark"] .busy-note { background: rgba(245, 158, 11, .16); color: #fbbf24; }


/* ============================================================================
   Colour & focus polish — driven by a live WCAG contrast audit, not taste.
   ============================================================================ */

/* Links read at 6.3:1 instead of 4.5:1 — same brand family, one step deeper. Dark mode's
   --brand-600 is the LIGHTER step, so the same token is correct in both themes. */
a { color: var(--brand-600); }

/* The green/red badge inks were the only chip texts under AA on their washes (3.66:1) —
   one step deeper fixes them without changing how the chips read. */
.badge-g { color: #047857; }
.badge-r { color: #b91c1c; }
[data-theme="dark"] .badge-g { color: #34d399; }
[data-theme="dark"] .badge-r { color: #f87171; }

/* Text selection carries the brand instead of the browser default blue. */
::selection { background: var(--brand-container); color: var(--on-brand-container); }
[data-theme="dark"] ::selection { background: var(--brand-container); color: var(--on-brand-container); }

/* Keyboard focus is FIRST-CLASS: a visible 2px ring on anything interactive, only for
   keyboard navigation (:focus-visible) so mouse clicks stay clean. */
.btn:focus-visible, .tab:focus-visible, .topnav__item:focus-visible, .icon-btn:focus-visible,
a:focus-visible, .nav-item:focus-visible, .seg button:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
  border-radius: inherit;
}
.form-control:focus-visible, .form-select:focus-visible { outline: none; }  /* fields have the 2px border */


/* --- Avatar tints. Light: 16% wash + the hue's 700 ink (AA on the wash). Dark: same wash
       over the dark card + the hue's 300 ink. Both directions measured. --- */
.avatar--t0 { background: color-mix(in srgb, #635bff 16%, transparent); color: #4338ca; }
.avatar--t1 { background: color-mix(in srgb, #10b981 16%, transparent); color: #047857; }
.avatar--t2 { background: color-mix(in srgb, #f59e0b 16%, transparent); color: #b45309; }
.avatar--t3 { background: color-mix(in srgb, #ef4444 16%, transparent); color: #b91c1c; }
.avatar--t4 { background: color-mix(in srgb, #06b6d4 16%, transparent); color: #0e7490; }
.avatar--t5 { background: color-mix(in srgb, #8b5cf6 16%, transparent); color: #6d28d9; }
[data-theme="dark"] .avatar--t0 { color: #a5b4fc; }
[data-theme="dark"] .avatar--t1 { color: #6ee7b7; }
[data-theme="dark"] .avatar--t2 { color: #fcd34d; }
[data-theme="dark"] .avatar--t3 { color: #fca5a5; }
[data-theme="dark"] .avatar--t4 { color: #67e8f9; }
[data-theme="dark"] .avatar--t5 { color: #c4b5fd; }

/* --- Dark chips: the light-mode inks were reused on dark washes and sank. Re-ink. --- */
[data-theme="dark"] .badge-n { color: #cbd5e1; }
[data-theme="dark"] .badge-o { color: #fcd34d; }
[data-theme="dark"] .badge-b { color: #c4beff; }
[data-theme="dark"] .stat__trend.flat { color: #cbd5e1; }
[data-theme="dark"] .stat__trend.up { color: #34d399; }
[data-theme="dark"] .stat__trend.down { color: #f87171; }
/* Status labels carry an arbitrary per-status colour in --c; in dark, lift whatever it is
   toward white so every status stays readable without retinting each one by hand. */
[data-theme="dark"] .status-label { color: color-mix(in srgb, var(--c) 55%, #fff); }

/* ============================================================================
   SNEATER design language — replicated from the user's design file
   ("SNEATER Dashboard.dc.html"). Appended last on purpose: same-specificity
   rules below override everything above, so the whole app re-skins without
   touching 52 pages' markup. Navy sidebar, white 62px topbar, indigo primary,
   white 14px cards on a grey plane, Manrope + Spline Sans Mono micro-labels.
   ============================================================================ */

body { background: var(--bg); }
[data-theme="dark"] body { background-image: none; }
::-webkit-scrollbar-thumb,
::-webkit-scrollbar-thumb:hover { background: color-mix(in srgb, var(--text-muted) 45%, transparent); border-radius: var(--radius-pill); border: 2px solid transparent; background-clip: padding-box; }
* { scrollbar-color: color-mix(in srgb, var(--text-muted) 45%, transparent) transparent; }
.page-head h1::after { display: none; }

/* Micro-labels: the design marks every overline / column head in mono caps. */
.overline { font-family: var(--font-mono); font-size: 10.5px; font-weight: 600; letter-spacing: .13em; text-transform: uppercase; color: var(--text-muted); }

/* Headings read in Title Case; the wordmark is always caps. */
h1, h2, h3, h4, h5, h6, .modal-title, .swal2-title { text-transform: capitalize; }
.sb-name, .topnav__name { text-transform: uppercase; }

/* --- Sidebar: the navy rail. --- */
.sidebar { background: var(--sidebar); border-right: none; color: #E2E8F0; }
/* Brand mark sits centred in the rail — a branch's uploaded logo, the SNEATER wordmark, or the
   "Your Logo" placeholder — so it reads the same for every branch and every staff member. */
.sidebar__brand { padding: 14px 18px; border-bottom: 1px solid rgba(255, 255, 255, .07); color: #fff; gap: 11px; justify-content: center; text-align: center; }
.sidebar__brand .logo {
  width: 38px; height: 38px; border-radius: 10px; font-size: 17px;
  background: linear-gradient(135deg, #6366F1, #4338CA); box-shadow: none;
}
.sb-name { font-weight: 800; font-size: 17px; letter-spacing: .12em; color: #fff; line-height: 1.2; }
.sb-tag { font-size: .6rem; font-weight: 700; letter-spacing: .1em; color: #8FA0B5; display: block; }
/* A branch logo sits on a white tile so any logo colour survives the navy. */
/* Branch logo sits in a generous full-width white card at the top of the rail (as requested):
   fixed-height tile, logo contained + centred inside whatever its aspect ratio. */
.sidebar__brand .brand-logo-img { box-sizing: border-box; width: 100%; height: 64px; object-fit: contain; background: #fff; border-radius: 12px; padding: 8px 14px; }
.sidebar__brand .logo--ghost { background: transparent; border: 1.5px dashed rgba(255, 255, 255, .25); color: #8FA0B5; }

.sidebar__nav { padding: 6px 12px 18px; }
.sidebar__nav::-webkit-scrollbar-thumb { background: rgba(148, 163, 184, .25); }
.sidebar__section {
  font-family: var(--font-mono); font-size: 10px; font-weight: 600;
  letter-spacing: .16em; color: #475569; margin: 18px 10px 7px; text-transform: uppercase;
}
.nav-item, .nav-toggle {
  border-radius: 9px; padding: 9px 11px; margin: 1px 0;
  color: var(--sidebar-text); font-weight: 600; font-size: 13.5px; gap: 11px;
}
.nav-item i, .nav-toggle i:first-child { font-size: 16px; width: 20px; }
.nav-item:hover, .nav-toggle:hover { background: rgba(255, 255, 255, .06); color: #E2E8F0; }
.nav-item.active, .nav-item.active:hover { background: var(--brand); color: #fff; box-shadow: none; }
[data-theme="dark"] .nav-item.active, [data-theme="dark"] .nav-item.active:hover { background: #4F46E5; }
.nav-item.active i { color: #fff; }
.nav-caret { margin-left: auto; font-size: 12px !important; width: auto !important; transition: transform .18s ease; }
.nav-toggle[aria-expanded="true"] .nav-caret { transform: rotate(90deg); }
.nav-toggle.is-on { color: #E2E8F0; }
.nav-submenu { padding: 2px 0 6px; }
.nav-subitem { color: var(--sidebar-text); border-radius: 8px; padding: 8px 11px 8px 42px; font-size: 13px; font-weight: 600; border: none; }
.nav-subitem:hover { background: rgba(255, 255, 255, .06); color: #E2E8F0; }
.nav-subitem.active { background: rgba(79, 70, 229, .22); color: #C7D2FE; border-left: none; padding-left: 42px; font-weight: 700; }
.nav-badge { background: rgba(255, 255, 255, .08); color: #CBD5E1; font-family: var(--font-mono); font-size: 11px; font-weight: 600; padding: 1px 8px; }
.nav-badge--hot { background: rgba(239, 68, 68, .16); color: #FCA5A5; }
.nav-item.active .nav-badge { background: rgba(255, 255, 255, .22); color: #fff; }

/* Mobile drawer: rail slides over a scrim (transform rules live in the layout section). */
.sb-scrim { position: fixed; inset: 0; background: rgba(12, 19, 34, .5); z-index: 1029; opacity: 0; pointer-events: none; transition: opacity .2s ease; }
.sb-scrim.show { opacity: 1; pointer-events: auto; }
@media (max-width: 768px) { .sidebar.open { box-shadow: 0 0 60px rgba(0, 0, 0, .5); } }

/* --- Topbar: white, 62px, hairline below. --- */
.topbar {
  background: var(--surface);
  backdrop-filter: none; -webkit-backdrop-filter: none;
  border-bottom: 1px solid var(--border);
  box-shadow: none;
  gap: 14px; padding: 0 22px;
}
.tb-toggle {
  width: 36px; height: 36px; border-radius: 9px; flex-shrink: 0;
  border: 1px solid var(--border); background: var(--surface); color: var(--text-muted);
  display: grid; place-items: center; cursor: pointer; font-size: 15px; transition: .15s;
}
.tb-toggle:hover { color: var(--text); background: var(--bg); }
.tb-div { width: 1px; height: 26px; background: var(--border); flex-shrink: 0; }
.topbar__search { max-width: 460px; }
.topbar__search input { height: 38px; border-radius: 10px; background: var(--bg); border-color: transparent; font-size: 13px; }
.topbar__search input:focus { background: var(--surface); border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-glow); }
.topbar__search kbd { font-family: var(--font-mono); font-size: 10px; letter-spacing: .04em; }
.icon-btn { width: 36px; height: 36px; border-radius: 9px; border: 1px solid transparent; background: transparent; color: var(--text-muted); }
.icon-btn:hover { background: var(--bg); color: var(--text); border-color: transparent; }
.topnav__user { padding: 4px 6px; border-radius: 10px; }
.avatar { border-radius: 10px; background: linear-gradient(135deg, #6366F1, #4338CA); }

/* --- Cards: white, 14px, hairline border, whisper shadow — and still. --- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.card:hover { transform: none; box-shadow: var(--shadow-sm); }
.stat { border-radius: var(--radius); border: 1px solid var(--border); box-shadow: var(--shadow-sm); }
.stat:hover { transform: none; box-shadow: var(--shadow-sm); }

/* --- Buttons: 10px corners, not pills. --- */
.btn { border-radius: 10px; font-weight: 700; }
.btn-sm { border-radius: 9px; }
.btn-brand { background: var(--brand); border: none; color: #fff; box-shadow: 0 1px 2px rgba(79, 70, 229, .35); }
.btn-brand:hover, .btn-brand:focus { background: var(--brand-600); color: #fff; transform: none; box-shadow: 0 1px 2px rgba(79, 70, 229, .35); }
[data-theme="dark"] .btn-brand { background: #4F46E5; }
[data-theme="dark"] .btn-brand:hover, [data-theme="dark"] .btn-brand:focus { background: #6366F1; }
.btn-ghost { background: var(--surface); border: 1px solid #DFE3E9; color: #374151; box-shadow: none; }
.btn-ghost:hover, .btn-ghost:focus { background: var(--bg); border-color: #DFE3E9; color: var(--text); transform: none; }
[data-theme="dark"] .btn-ghost { background: transparent; border-color: var(--border); color: var(--text); }
[data-theme="dark"] .btn-ghost:hover, [data-theme="dark"] .btn-ghost:focus { background: rgba(148, 163, 184, .08); color: var(--text); }

/* --- Tabs & segmented switches: grey track, white active pill (the design's toggle). --- */
.tabs { background: var(--bg); border: 1px solid var(--border); border-radius: 10px; padding: 3px; gap: 2px; box-shadow: none; }
.tab { border-radius: 8px; padding: 8px 14px; position: static; }
.tab:hover:not(.active) { transform: none; background: color-mix(in srgb, var(--text) 5%, transparent); color: var(--text); }
.tab.active { background: var(--surface); color: var(--text); box-shadow: 0 1px 2px rgba(16, 24, 40, .10); }
.tab.active::after { display: none; }
[data-theme="dark"] .tab.active { background: var(--surface-2); color: var(--text); }
.seg { background: var(--bg); border: 1px solid var(--border); }
.seg button.is-on { background: var(--surface); color: var(--text); box-shadow: 0 1px 2px rgba(16, 24, 40, .10); }
[data-theme="dark"] .seg button.is-on { background: var(--surface-2); }

/* --- Fields: 9px, hairline, indigo focus ring. --- */
.form-control, .form-select { border-radius: 9px; border: 1px solid var(--border); background: var(--surface); }
.form-control:focus, .form-select:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-glow); background: var(--surface); }

/* --- Dialogs & menus: bordered like cards. !important beats pages' inline 18px. --- */
.modal-content { border-radius: 16px !important; border: 1px solid var(--border) !important; box-shadow: var(--shadow-lg); }
.ep-swal { border-radius: 16px !important; }
.cl-pop { border-radius: 16px; border: 1px solid var(--border); }
.dropdown-menu { border-radius: 12px; border: 1px solid var(--border); box-shadow: var(--shadow-lg); overflow: hidden; }
.toast-msg { background: var(--inverse-surface) !important; color: var(--on-inverse) !important; border: none !important; border-radius: 10px !important; box-shadow: var(--shadow-lg) !important; }

/* --- Tables: mono column heads on a soft band (the design's table voice). --- */
table.data thead th {
  background: var(--surface-2); color: var(--text-muted);
  font-family: var(--font-mono); font-size: 10.5px; font-weight: 600;
  letter-spacing: .12em; text-transform: uppercase;
}
[data-theme="dark"] .table thead th,
[data-theme="dark"] table.data thead th { background: var(--surface-2); color: var(--text-muted); }
table.data tbody tr:hover { background: var(--surface-2); }
[data-theme="dark"] .table tbody tr:hover,
[data-theme="dark"] table.data tbody tr:hover { background: rgba(148, 163, 184, .06); }

/* --- Chips: the design file's exact wash/ink pairs, both themes. --- */
.badge-b { background: #EEF2FF; color: #4F46E5; }
.badge-g { background: #E7F6EF; color: #0B7A50; }
.badge-o { background: #FEF3E2; color: #B45309; }
.badge-r { background: #FDEBEC; color: #B91C1C; }
.badge-n { background: #F4F5F7; color: #6B7280; }
[data-theme="dark"] .badge-b { background: rgba(99, 102, 241, .18); color: #A5B4FC; }
[data-theme="dark"] .badge-g { background: rgba(16, 185, 129, .15); color: #34D399; }
[data-theme="dark"] .badge-o { background: rgba(245, 158, 11, .15); color: #FCD34D; }
[data-theme="dark"] .badge-r { background: rgba(239, 68, 68, .15); color: #FCA5A5; }
[data-theme="dark"] .badge-n { background: rgba(148, 163, 184, .12); color: #CBD5E1; }

/* --- Avatars: rounded-square tiles in the design's tint pairs. --- */
.avatar--t0 { background: #EEF2FF; color: #4F46E5; }
.avatar--t1 { background: #E7F6EF; color: #0B7A50; }
.avatar--t2 { background: #FEF3E2; color: #B45309; }
.avatar--t3 { background: #FDEBEC; color: #B91C1C; }
.avatar--t4 { background: #E0F2FE; color: #0369A1; }
.avatar--t5 { background: #F3E8FF; color: #7E22CE; }
[data-theme="dark"] .avatar--t0 { background: rgba(99, 102, 241, .16); color: #A5B4FC; }
[data-theme="dark"] .avatar--t1 { background: rgba(16, 185, 129, .14); color: #6EE7B7; }
[data-theme="dark"] .avatar--t2 { background: rgba(245, 158, 11, .14); color: #FCD34D; }
[data-theme="dark"] .avatar--t3 { background: rgba(239, 68, 68, .14); color: #FCA5A5; }
[data-theme="dark"] .avatar--t4 { background: rgba(14, 165, 233, .14); color: #67E8F9; }
[data-theme="dark"] .avatar--t5 { background: rgba(139, 92, 246, .14); color: #C4B5FD; }

/* ============================================================================
   Dashboard — the design file's sections
   ============================================================================ */

/* Greeting header: mono date overline + 24px headline. */
.greet-h1 { margin: 2px 0 0; font-size: 24px; font-weight: 800; color: var(--heading); letter-spacing: -.02em; }

/* KPI row: four white cards — overline, delta chip, 32px number, quiet label. */
.kpi-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.kcard { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); padding: 18px 20px; min-width: 0; }
.kcard__top { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.kcard__value { font-size: 32px; font-weight: 800; letter-spacing: -1px; line-height: 1.1; margin: 10px 0 4px; font-variant-numeric: tabular-nums; color: var(--heading); }
.kcard__label { font-size: 12.5px; color: var(--text-muted); font-weight: 600; }
.kdelta { display: inline-flex; align-items: center; gap: 4px; font-size: 11px; font-weight: 800; padding: 3px 9px; border-radius: var(--radius-pill); white-space: nowrap; }
.kdelta.up, .kdelta.live { background: #E7F6EF; color: #0B7A50; }
.kdelta.down { background: #FDEBEC; color: #B91C1C; }
.kdelta.flat { background: var(--bg); color: var(--text-muted); }
[data-theme="dark"] .kdelta.up, [data-theme="dark"] .kdelta.live { background: rgba(16, 185, 129, .15); color: #34D399; }
[data-theme="dark"] .kdelta.down { background: rgba(239, 68, 68, .15); color: #FCA5A5; }
@media (max-width: 900px) { .kpi-row { grid-template-columns: 1fr 1fr; gap: 10px; } .kcard__value { font-size: 26px; } }

/* Follow Ups (7fr) beside Pipeline + Visits (5fr). */
.dgrid { display: grid; grid-template-columns: minmax(340px, 7fr) minmax(300px, 5fr); gap: 16px; align-items: start; }
.dgrid > * { min-width: 0; }
.dgrid__col { display: flex; flex-direction: column; gap: 16px; }
@media (max-width: 1024px) { .dgrid { grid-template-columns: 1fr; } }

/* Follow Ups: a grouped table card — one row per stream, Today/Overdue chips, arrow. */
.fu-card { padding: 0; }
.fu-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 16px 20px 13px; }
.fu-count { background: #FDEBEC; color: #B91C1C; border-radius: var(--radius-pill); font-size: 12px; font-weight: 800; padding: 4px 12px; white-space: nowrap; }
[data-theme="dark"] .fu-count { background: rgba(239, 68, 68, .15); color: #FCA5A5; }
.fu-cols, .fu-row { display: grid; grid-template-columns: minmax(0, 1fr) 76px 92px 26px; gap: 8px; align-items: center; }
.fu-cols { padding: 7px 20px; background: var(--surface-2); border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.fu-cols span { font-family: var(--font-mono); font-size: 10px; font-weight: 600; letter-spacing: .13em; text-transform: uppercase; color: var(--text-muted); }
.fu-row { padding: 11px 20px; border-bottom: 1px solid color-mix(in srgb, var(--border) 60%, transparent); color: var(--text); text-decoration: none; transition: background .12s ease; }
.fu-row:last-child { border-bottom: none; border-radius: 0 0 var(--radius) var(--radius); }
.fu-row:hover { background: var(--surface-2); color: var(--text); }
.fu-row__name { display: flex; align-items: center; gap: 9px; font-size: 13.5px; font-weight: 700; min-width: 0; }
.fu-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.fu-chip { display: inline-flex; justify-content: center; min-width: 36px; padding: 3px 10px; border-radius: var(--radius-pill); font-size: 12px; font-weight: 800; font-variant-numeric: tabular-nums; }
.fu-chip.t { background: #EEF2FF; color: #4F46E5; }
.fu-chip.o { background: #FDEBEC; color: #B91C1C; }
.fu-chip.z { background: var(--bg); color: #9CA3AF; }
[data-theme="dark"] .fu-chip.t { background: rgba(99, 102, 241, .18); color: #A5B4FC; }
[data-theme="dark"] .fu-chip.o { background: rgba(239, 68, 68, .15); color: #FCA5A5; }
[data-theme="dark"] .fu-chip.z { background: rgba(148, 163, 184, .10); color: #7C8BA1; }
.fu-row__arrow { color: var(--text-muted); font-size: 13px; text-align: right; }

/* Pipeline: the dark navy card. */
.pipe-dark { background: #0C1322; border-color: #0C1322; }
.pipe-dark h3 { color: #fff; }
.pipe-dark .cell-sub { color: #8FA0B5; }
.pipe-dark a { color: #A5B4FC; font-weight: 700; font-size: var(--fs-sm); text-decoration: none; }
.pipe-dark a:hover { color: #C7D2FE; }
.pipe-dark .pipe__bar { height: 10px; background: rgba(255, 255, 255, .06); }
.pipe-dark .pipe__legend { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 18px; margin-top: 16px; }
.pipe-dark .pipe__dot { width: 8px; height: 8px; }
.pipe-dark .pipe__txt b { color: #fff; font-size: 15px; }
.pipe-dark .pipe__txt span { color: #8FA0B5; }
[data-theme="dark"] .pipe-dark { border-color: rgba(148, 163, 184, .14); }

/* Visits / live rows: soft banded items (the design's visit list). */
.walkin { background: var(--surface-2); border: 1px solid color-mix(in srgb, var(--border) 55%, transparent); border-radius: 11px; padding: 9px 12px; margin-bottom: 8px; border-bottom-width: 1px; }
.walkin:last-child { margin-bottom: 0; }
.walkin__time { font-family: var(--font-mono); font-size: 11.5px; font-weight: 600; color: var(--text-muted); }
/* Long names truncate instead of stacking letter-by-letter in the narrow column;
   the chips never shrink. */
.walkin__who .cell-primary { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.walkin .badge-soft { flex-shrink: 0; }

/* Trend bars: past months tinted, the current month saturated. */
.trendchart .tbar__fill { background: var(--c-soft, color-mix(in srgb, var(--c) 30%, #fff)); border-radius: 7px 7px 3px 3px; max-width: 46px; }
.trendchart .tbar.is-now .tbar__fill { background: var(--c); }
.trendchart .tbar__val { font-size: 12px; font-weight: 800; color: var(--text-muted); }
.trendchart .tbar.is-now .tbar__val { color: var(--heading); }
.trendchart .tbar__label { color: #9CA3AF; }
.trendchart .tbar.is-now .tbar__label { color: var(--heading); }
[data-theme="dark"] .trendchart .tbar__fill { background: var(--c-soft-dark, color-mix(in srgb, var(--c) 35%, transparent)); }
[data-theme="dark"] .trendchart .tbar.is-now .tbar__fill { background: var(--c); }
[data-theme="dark"] .trendchart .tbar__label { color: #64748B; }

/* Agreements: icon-tile cards. */
.agr { display: flex; flex-direction: column; padding: 18px 20px; text-decoration: none; color: inherit; }
.agr:hover { text-decoration: none; color: inherit; border-color: color-mix(in srgb, var(--text-muted) 30%, var(--border)); }
.agr__top { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 12px; }
.agr__ic { width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center; font-size: 16px; }
.agr__ic.b { background: #EEF2FF; color: #4F46E5; }
.agr__ic.g { background: #E7F6EF; color: #0B7A50; }
.agr__ic.o { background: #FEF3E2; color: #B45309; }
.agr__ic.r { background: #FDEBEC; color: #B91C1C; }
[data-theme="dark"] .agr__ic.b { background: rgba(99, 102, 241, .16); color: #A5B4FC; }
[data-theme="dark"] .agr__ic.g { background: rgba(16, 185, 129, .14); color: #6EE7B7; }
[data-theme="dark"] .agr__ic.o { background: rgba(245, 158, 11, .14); color: #FCD34D; }
[data-theme="dark"] .agr__ic.r { background: rgba(239, 68, 68, .14); color: #FCA5A5; }
.agr__tag { background: var(--bg); color: var(--text-muted); border-radius: var(--radius-pill); padding: 3px 10px; font-size: 11px; font-weight: 700; }
.agr__num { font-size: 28px; font-weight: 800; letter-spacing: -.5px; color: var(--heading); line-height: 1.1; }
.agr__lbl { font-size: 12.5px; color: var(--text-muted); font-weight: 600; margin-top: 2px; }

/* Focus rings for the new controls (keyboard a11y, matches the polish section). */
.tb-toggle:focus-visible, .nav-toggle:focus-visible, .fu-row:focus-visible, .agr:focus-visible {
  outline: 2px solid var(--brand); outline-offset: 2px; border-radius: inherit;
}

/* ============================================================================
   SNEATER mobile — native app feel (phones only). Desktop and tablet are
   UNTOUCHED: every rule here lives inside a phone media query, and the bottom
   tab bar is display:none until the phone breakpoint. Cards already stack,
   charts already collapse to one column, tables get a card view below — this
   layer adds the fixed bottom nav, touch targets, and mobile spacing.
   ============================================================================ */

/* Bottom tab bar — hidden on desktop; a fixed native bar on phones. */
.mobnav { display: none; }

@media (max-width: 768px) {
  .mobnav {
    display: flex;
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 1025;
    background: var(--surface);
    border-top: 1px solid var(--border);
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom, 0px));
    box-shadow: 0 -4px 16px rgba(16, 24, 40, .06);
  }
  .mobnav__item {
    flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: center; gap: 3px;
    padding: 6px 2px; background: none; border: none; cursor: pointer;
    color: var(--text-muted); text-decoration: none; font: inherit;
  }
  .mobnav__ic { position: relative; font-size: 20px; line-height: 1; }
  .mobnav__lbl { font-size: 10.5px; font-weight: 600; white-space: nowrap; max-width: 100%;
    overflow: hidden; text-overflow: ellipsis; }
  .mobnav__item.active, .mobnav__item.active .mobnav__ic { color: var(--brand); }
  [data-theme="dark"] .mobnav__item.active, [data-theme="dark"] .mobnav__item.active .mobnav__ic { color: var(--brand-600); }
  .mobnav__item:active { background: var(--surface-2); }
  .mobnav__dot { position: absolute; top: -2px; right: -7px; width: 8px; height: 8px;
    border-radius: 50%; background: var(--danger); border: 2px solid var(--surface); }

  /* Clear space for the fixed bar; a touch more breathing room at the edges. */
  .content { padding: 16px 14px calc(88px + env(safe-area-inset-bottom, 0px)); }

  /* The desktop rail toggle isn't needed — the bottom bar's "More" opens the drawer. */
  .tb-toggle { display: none; }
  .topbar { padding: 0 14px; gap: 10px; }
  .topbar__search { max-width: none; }

  /* Touch targets — everything comfortably tappable (Apple/Material ~44px). */
  .btn { min-height: 44px; display: inline-flex; align-items: center; justify-content: center; }
  .btn-sm { min-height: 38px; }
  .icon-btn { width: 40px; height: 40px; }
  .seg button, .tab { min-height: 40px; }

  /* Dashboard header: greeting on its own line, the two actions become a full-width
     row of equal thumb-sized buttons. Only matches page-heads built this way. */
  .page-head > .d-flex.gap-2 { width: 100%; }
  .page-head > .d-flex.gap-2 > .btn { flex: 1; }

  /* Recent-leads (and any .data table) become stacked cards; the field name sits on the
     left via data-label, the value on the right — a proper mobile row, not a squeezed table. */
  table.data tbody td { align-items: center; }
  table.data tbody td::before { flex: 0 0 auto; margin-right: 12px; }

  /* Modals hug the screen with a little inset, and never sit under the bar. */
  .modal-dialog { margin: 12px; }
  .modal-body { max-height: 74vh; }
}

/* Small phones: tighten the Follow Ups columns so the stream name keeps room. */
@media (max-width: 480px) {
  .fu-cols, .fu-row { grid-template-columns: minmax(0, 1fr) 56px 66px 18px; gap: 6px;
    padding-left: 14px; padding-right: 14px; }
  .fu-head { padding-left: 14px; padding-right: 14px; }
  .kpi-row { gap: 10px; }
  .kcard { padding: 15px 16px; }
  .greet-h1 { font-size: 21px; }
}

/* ============================================================================
   SNEATER mobile app dashboard — replicates the native mobile app design on
   phones only. Desktop is UNTOUCHED: .mobdash is display:none until ≤768px,
   and on phones the dashboard's other sections are hidden so only this renders.
   Themed for dark AND light via tokens + per-theme overrides.
   ============================================================================ */
.mobdash { display: none; }

@media (max-width: 768px) {
  /* On the dashboard only (it carries #mobDash): show the app tree, hide the desktop one,
     and drop the content padding so the gradient header can bleed to the edges. */
  .content:has(#mobDash) { padding: 0; max-width: none; }
  .content:has(#mobDash) > :not(#mobDash) { display: none !important; }
  .mobdash { display: block; }

  /* Gradient header ------------------------------------------------------ */
  .md-head {
    background: linear-gradient(170deg, #26356b 0%, #16204a 45%, var(--bg) 100%);
    padding: 46px 18px 20px;
  }
  [data-theme="dark"] .md-head { background: linear-gradient(170deg, #1b2a57 0%, #111e46 45%, var(--bg) 100%); }
  .md-head__row { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
  .md-greet-sub { color: rgba(255,255,255,.72); font-size: 13px; font-weight: 500; }
  .md-greet { margin: 3px 0 0; color: #fff; font-size: 26px; font-weight: 800; letter-spacing: -.01em; }
  .md-wave { font-size: 22px; }
  .md-head__actions { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
  .md-bell {
    position: relative; width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center;
    background: rgba(255,255,255,.12); color: #fff; font-size: 18px; text-decoration: none; border: none;
  }
  .md-bell__dot { position: absolute; top: 10px; right: 10px; width: 8px; height: 8px; border-radius: 50%; background: #EF4444; border: 2px solid #22315f; }
  .md-avatar {
    width: 44px; height: 44px; border-radius: 50%; border: none; cursor: pointer;
    background: linear-gradient(135deg, #38BDF8, #2563EB); color: #fff; font-weight: 800; font-size: 15px;
  }

  /* Translucent 3-stat strip -------------------------------------------- */
  .md-strip {
    display: grid; grid-template-columns: repeat(3, 1fr); align-items: center;
    margin-top: 18px; padding: 14px 6px; border-radius: 16px;
    background: rgba(255,255,255,.10); border: 1px solid rgba(255,255,255,.12);
  }
  .md-strip__cell { text-align: center; position: relative; }
  .md-strip__cell + .md-strip__cell::before { content: ""; position: absolute; left: 0; top: 12%; bottom: 12%; width: 1px; background: rgba(255,255,255,.16); }
  .md-strip__cell b { display: block; color: #fff; font-size: 21px; font-weight: 800; line-height: 1.1; }
  .md-strip__cell span { color: rgba(255,255,255,.72); font-size: 12px; font-weight: 500; }

  /* Body ----------------------------------------------------------------- */
  .md-body { padding: 18px 16px calc(104px + env(safe-area-inset-bottom, 0px)); display: flex; flex-direction: column; gap: 16px; }
  .mobdash .md-card, .mobdash .md-kpi, .mobdash .md-target, .mobdash .md-fu, .mobdash .md-lead, .mobdash .md-q {
    background: var(--surface); border: 1px solid var(--border); border-radius: 18px;
  }
  [data-theme="dark"] .mobdash .md-card, [data-theme="dark"] .mobdash .md-kpi, [data-theme="dark"] .mobdash .md-target,
  [data-theme="dark"] .mobdash .md-fu, [data-theme="dark"] .mobdash .md-lead, [data-theme="dark"] .mobdash .md-q { background: #101827; border-color: rgba(148,163,184,.14); }

  /* KPI 2x2 -------------------------------------------------------------- */
  .md-kpis { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
  .md-kpi { padding: 16px; min-width: 0; }
  .md-kpi__top { display: flex; align-items: center; justify-content: space-between; gap: 6px; margin-bottom: 14px; }
  .md-kpi__ic { width: 40px; height: 40px; border-radius: 11px; display: grid; place-items: center; font-size: 18px; }
  .md-kpi__ic.b { background: rgba(99,102,241,.16); color: #818CF8; }
  .md-kpi__ic.g { background: rgba(16,185,129,.16); color: #34D399; }
  .md-kpi__ic.o { background: rgba(245,158,11,.16); color: #FBBF24; }
  .md-kpi__val { font-size: 27px; font-weight: 800; color: var(--heading); letter-spacing: -.5px; line-height: 1.05; }
  .md-kpi__lbl { font-size: 13px; color: var(--text-muted); font-weight: 500; margin-top: 3px; }
  .md-delta { display: inline-flex; align-items: center; gap: 3px; font-size: 12px; font-weight: 700; padding: 3px 8px; border-radius: 999px; white-space: nowrap; }
  .md-delta.up { background: rgba(16,185,129,.16); color: #34D399; }
  .md-delta.down { background: rgba(239,68,68,.16); color: #FCA5A5; }
  .md-delta.flat { background: rgba(148,163,184,.14); color: var(--text-muted); }

  /* Monthly target ring -------------------------------------------------- */
  .md-target { display: flex; align-items: center; gap: 16px; padding: 18px; }
  .md-ring { position: relative; width: 84px; height: 84px; border-radius: 50%; flex-shrink: 0; display: grid; place-items: center;
    background: conic-gradient(var(--brand) calc(var(--pct) * 1%), rgba(148,163,184,.18) 0); }
  .md-ring::before { content: ""; position: absolute; width: 64px; height: 64px; border-radius: 50%; background: var(--surface); }
  [data-theme="dark"] .md-ring::before { background: #101827; }
  .md-ring__mid { position: relative; z-index: 1; text-align: center; line-height: 1; }
  .md-ring__mid b { font-size: 22px; font-weight: 800; color: var(--heading); }
  .md-ring__mid span { font-size: 12px; color: var(--text-muted); }
  .md-target__txt { min-width: 0; }
  .md-target__t { font-size: 15px; font-weight: 800; color: var(--heading); display: flex; align-items: center; gap: 7px; }
  .md-target__t i { color: var(--brand); }
  .md-target__txt p { margin: 4px 0 10px; font-size: 12.5px; color: var(--text-muted); line-height: 1.35; }
  .md-bar { height: 7px; border-radius: 999px; background: rgba(148,163,184,.18); overflow: hidden; }
  .md-bar > span { display: block; height: 100%; border-radius: 999px; background: var(--brand); }

  /* Quick actions -------------------------------------------------------- */
  .md-quick { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
  .md-q { padding: 14px 6px; display: flex; flex-direction: column; align-items: center; gap: 7px; text-decoration: none; }
  .md-q__ic { width: 44px; height: 44px; border-radius: 13px; display: grid; place-items: center; font-size: 20px; }
  .md-q__ic.b { background: rgba(99,102,241,.16); color: #818CF8; }
  .md-q__ic.g { background: rgba(16,185,129,.16); color: #34D399; }
  .md-q__ic.o { background: rgba(245,158,11,.16); color: #FBBF24; }
  .md-q__lbl { font-size: 12px; font-weight: 600; color: var(--text); text-align: center; }

  /* Cards ---------------------------------------------------------------- */
  .md-card { padding: 18px; }
  .md-card__h h3 { margin: 0; font-size: 17px; font-weight: 800; color: var(--heading); }
  .md-card__h p { margin: 2px 0 0; font-size: 12.5px; color: var(--text-muted); }

  /* Leads this week bars ------------------------------------------------- */
  .md-week { display: flex; align-items: flex-end; justify-content: space-between; gap: 8px; height: 150px; margin-top: 16px; }
  .md-week__col { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; gap: 8px; }
  .md-week__bar { width: 60%; max-width: 26px; min-height: 6px; border-radius: 999px;
    background: linear-gradient(180deg, rgba(148,163,184,.5), rgba(148,163,184,.12)); }
  [data-theme="dark"] .md-week__bar { background: linear-gradient(180deg, rgba(148,163,184,.4), rgba(148,163,184,.08)); }
  .md-week__bar.is-now { background: linear-gradient(180deg, #6366F1, #4338CA); }
  .md-week__lbl { font-size: 12px; font-weight: 600; color: var(--text-muted); }
  .md-week__lbl.is-now { color: var(--heading); font-weight: 800; }

  /* Pipeline ------------------------------------------------------------- */
  .md-pipe { display: flex; height: 12px; border-radius: 999px; overflow: hidden; gap: 3px; margin: 16px 0 16px; }
  .md-pipe > span { min-width: 4px; border-radius: 999px; }
  .md-pipe__legend { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 18px; }
  .md-leg { display: flex; align-items: center; gap: 8px; font-size: 14px; }
  .md-leg__dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }
  .md-leg__lbl { color: var(--text); font-weight: 500; }
  .md-leg b { margin-left: auto; color: var(--heading); font-weight: 800; }

  /* Section headers ------------------------------------------------------ */
  .md-sec-h { display: flex; align-items: center; justify-content: space-between; margin: 4px 2px -4px; }
  .md-sec-h h3 { margin: 0; font-size: 18px; font-weight: 800; color: var(--heading); }
  .md-sec-h a { color: var(--brand-600); font-size: 13px; font-weight: 700; text-decoration: none; display: inline-flex; align-items: center; gap: 3px; }
  [data-theme="dark"] .md-sec-h a { color: #A5B4FC; }
  .md-list { display: flex; flex-direction: column; gap: 12px; }

  /* Follow-up card ------------------------------------------------------- */
  .md-fu { display: flex; align-items: center; gap: 12px; padding: 14px; }
  .md-fu__time { flex-shrink: 0; text-align: left; min-width: 58px; padding-right: 10px; border-right: 1px solid var(--border); }
  .md-fu__time b { display: block; font-size: 14px; font-weight: 800; color: var(--heading); }
  .md-fu__time span { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: .04em; }
  .md-fu__ic { width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center; font-size: 18px; flex-shrink: 0; }
  .md-fu__main { min-width: 0; flex: 1; }
  .md-fu__top { display: flex; align-items: center; gap: 8px; }
  .md-fu__name { font-size: 15px; font-weight: 700; color: var(--heading); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .md-fu__sub { font-size: 12.5px; color: var(--text-muted); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .md-chip { font-size: 10.5px; font-weight: 800; padding: 3px 9px; border-radius: 999px; text-transform: uppercase; letter-spacing: .03em; flex-shrink: 0; }
  .md-chip.g { background: rgba(16,185,129,.16); color: #34D399; }
  .md-chip.b { background: rgba(99,102,241,.16); color: #A5B4FC; }
  .md-chip.o { background: rgba(245,158,11,.16); color: #FBBF24; }
  .md-chip.r { background: rgba(239,68,68,.16); color: #FCA5A5; }
  .md-callbtn { width: 44px; height: 44px; border-radius: 13px; display: grid; place-items: center; flex-shrink: 0;
    background: rgba(99,102,241,.16); color: #818CF8; font-size: 18px; text-decoration: none; }

  /* Recent lead card ----------------------------------------------------- */
  .md-lead { display: block; padding: 16px; text-decoration: none; }
  .md-lead__head { display: flex; align-items: center; gap: 12px; }
  .md-lead__av { width: 48px; height: 48px; border-radius: 50%; display: grid; place-items: center; font-weight: 800; font-size: 16px; flex-shrink: 0; }
  .md-lead__id { min-width: 0; flex: 1; }
  .md-lead__name { font-size: 16px; font-weight: 700; color: var(--heading); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .md-lead__meta { font-size: 12.5px; color: var(--text-muted); margin-top: 2px; }
  .md-lead__stage { flex-shrink: 0; }
  .md-lead__foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--border); }
  .md-lead__acts { display: flex; gap: 8px; }
  .md-actbtn { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; font-size: 17px; text-decoration: none; }
  .md-actbtn.wa { background: rgba(16,185,129,.16); color: #34D399; }
  .md-actbtn.tel { background: rgba(99,102,241,.16); color: #818CF8; }

  /* Avatar / follow-up icon tints (reuse the design's tint pairs) -------- */
  .md-lead__av.t0, .md-fu__ic.t0 { background: rgba(99,102,241,.16); color: #A5B4FC; }
  .md-lead__av.t1, .md-fu__ic.t1 { background: rgba(16,185,129,.16); color: #6EE7B7; }
  .md-lead__av.t2, .md-fu__ic.t2 { background: rgba(245,158,11,.16); color: #FCD34D; }
  .md-lead__av.t3, .md-fu__ic.t3 { background: rgba(239,68,68,.16); color: #FCA5A5; }
  .md-lead__av.t4, .md-fu__ic.t4 { background: rgba(14,165,233,.16); color: #67E8F9; }
  .md-lead__av.t5 { background: rgba(139,92,246,.16); color: #C4B5FD; }

  .md-empty { text-align: center; color: var(--text-muted); padding: 26px 16px; background: var(--surface); border: 1px dashed var(--border); border-radius: 18px; }
  [data-theme="dark"] .md-empty { background: #101827; border-color: rgba(148,163,184,.16); }
  .md-empty i { font-size: 1.5rem; display: block; margin-bottom: 6px; opacity: .7; }
  .md-empty p { margin: 0; font-weight: 600; font-size: 13px; }

  /* Definitive off-canvas drawer on phones (higher specificity than the base rule so the
     rail never overlaps content; "More"/toggle slides it in). ---------------------------- */
  .app > .sidebar:not(.open) { transform: translateX(-100%) !important; }
  .app > .main { margin-left: 0 !important; }

  /* ---- App-style bottom nav with a centre FAB ---- */
  .mobnav { padding-top: 8px; }
  .mobnav__fab {
    flex: 0 0 auto; width: 58px; height: 58px; margin: -26px 6px 0; border-radius: 20px;
    background: linear-gradient(135deg, #6366F1, #4338CA); color: #fff; border: none; cursor: pointer;
    display: grid; place-items: center; font-size: 26px; box-shadow: 0 10px 22px rgba(79,70,229,.45);
  }
  .mobnav__fab:active { transform: scale(.94); }
  .mobnav__item.active { position: relative; }
  .mobnav__item.active::after { content: ""; position: absolute; bottom: -1px; width: 5px; height: 5px; border-radius: 50%; background: var(--brand); }
}

/* Mobile account footer in the navy drawer + hide the topbar on the app dashboard. */
.sb-foot { display: none; }
@media (max-width: 768px) {
  body.mobdash-on .topbar { display: none; }
  .sb-foot { display: flex; align-items: center; gap: 10px; margin-top: auto;
    padding: 12px 14px calc(14px + env(safe-area-inset-bottom, 0px)); border-top: 1px solid rgba(255,255,255,.08); }
  .sb-foot__av { width: 38px; height: 38px; border-radius: 50%; flex-shrink: 0; display: grid; place-items: center;
    background: linear-gradient(135deg, #6366F1, #4338CA); color: #fff; font-weight: 800; font-size: 13px; }
  .sb-foot__id { min-width: 0; flex: 1; }
  .sb-foot__name { color: #fff; font-weight: 700; font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .sb-foot__role { color: #8FA0B5; font-size: 11.5px; }
  .sb-foot__out { width: 38px; height: 38px; border-radius: 10px; border: none; flex-shrink: 0; cursor: pointer;
    background: rgba(239, 68, 68, .16); color: #FCA5A5; font-size: 16px; }
}

/* ============================================================================
   Mobile app "Profile" screen — full-screen overlay (bottom nav stays on top).
   Appears only via mobile triggers (Profile tab / dashboard avatar). Dark+light.
   ============================================================================ */
.md-screen {
  position: fixed; inset: 0; z-index: 1024; overflow-y: auto;
  background: var(--bg); opacity: 0; transform: translateY(10px);
  transition: opacity .2s ease, transform .2s ease;
  padding-bottom: calc(90px + env(safe-area-inset-bottom, 0px));
}
.md-screen.show { opacity: 1; transform: none; }
.md-screen__bar { display: flex; align-items: center; justify-content: space-between; padding: 46px 18px 12px; }
.md-screen__bar h1 { margin: 0; font-size: 30px; font-weight: 800; color: var(--heading); }
.md-screen__menu { width: 42px; height: 42px; border-radius: 12px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text-muted); font-size: 18px; display: grid; place-items: center; cursor: pointer; }
[data-theme="dark"] .md-screen__menu { background: #101827; border-color: rgba(148,163,184,.16); }
.md-screen__body { padding: 6px 16px; display: flex; flex-direction: column; gap: 14px; }

/* Profile card */
.mp-card { background: var(--surface); border: 1px solid var(--border); border-radius: 18px; padding: 18px; }
[data-theme="dark"] .mp-card { background: #101827; border-color: rgba(148,163,184,.14); }
.mp-card__top { display: flex; align-items: center; gap: 14px; }
.mp-av { width: 64px; height: 64px; border-radius: 50%; flex-shrink: 0; display: grid; place-items: center;
  background: linear-gradient(135deg, #38BDF8, #2563EB); color: #fff; font-weight: 800; font-size: 20px; }
.mp-id { min-width: 0; flex: 1; }
.mp-name { font-size: 18px; font-weight: 800; color: var(--heading); line-height: 1.15; }
.mp-role { font-size: 13px; font-weight: 700; color: var(--brand-600); margin-top: 2px; }
[data-theme="dark"] .mp-role { color: #A5B4FC; }
.mp-branch { font-size: 12.5px; color: var(--text-muted); margin-top: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mp-edit { width: 40px; height: 40px; border-radius: 11px; flex-shrink: 0; border: 1px solid var(--border);
  background: transparent; color: var(--text-muted); font-size: 16px; cursor: pointer; }
.mp-stats { display: grid; grid-template-columns: repeat(3, 1fr); margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--border); }
.mp-stats > div { text-align: center; position: relative; }
.mp-stats > div + div::before { content: ""; position: absolute; left: 0; top: 8%; bottom: 8%; width: 1px; background: var(--border); }
.mp-stats b { display: block; font-size: 22px; font-weight: 800; color: var(--heading); line-height: 1.1; }
.mp-stats span { font-size: 12.5px; color: var(--text-muted); }

/* Section labels */
.mp-lbl { font-family: var(--font-mono); font-size: 11px; font-weight: 600; letter-spacing: .12em;
  text-transform: uppercase; color: var(--text-muted); margin: 6px 4px -4px; }

/* Appearance toggle */
.mp-appear { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; padding: 8px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 16px; }
[data-theme="dark"] .mp-appear { background: #101827; border-color: rgba(148,163,184,.14); }
.mp-appear__b { display: flex; flex-direction: column; align-items: center; gap: 7px; padding: 14px 4px;
  border-radius: 12px; border: 1.5px solid transparent; background: transparent; color: var(--text-muted); cursor: pointer; font: inherit; }
.mp-appear__b i { font-size: 20px; }
.mp-appear__b span { font-size: 13px; font-weight: 600; }
.mp-appear__b.is-on { background: rgba(99,102,241,.12); border-color: var(--brand); color: var(--brand); }
[data-theme="dark"] .mp-appear__b.is-on { background: rgba(99,102,241,.18); border-color: #6366F1; color: #A5B4FC; }

/* Settings rows */
.mp-list { background: var(--surface); border: 1px solid var(--border); border-radius: 18px; overflow: hidden; }
[data-theme="dark"] .mp-list { background: #101827; border-color: rgba(148,163,184,.14); }
.mp-row { display: flex; align-items: center; gap: 14px; width: 100%; padding: 15px 16px; background: none; border: none;
  cursor: pointer; text-decoration: none; text-align: left; font: inherit; }
.mp-row + .mp-row { border-top: 1px solid var(--border); }
.mp-row__ic { width: 40px; height: 40px; border-radius: 11px; display: grid; place-items: center; font-size: 18px; flex-shrink: 0; }
.mp-row__ic.b { background: rgba(99,102,241,.16); color: #818CF8; }
.mp-row__ic.o { background: rgba(245,158,11,.16); color: #FBBF24; }
.mp-row__ic.n { background: rgba(148,163,184,.14); color: var(--text-muted); }
.mp-row__t { flex: 1; font-size: 15.5px; font-weight: 700; color: var(--heading); }
.mp-row__ch { color: var(--text-muted); font-size: 15px; }

/* Sign out + version */
.mp-signout { display: flex; align-items: center; justify-content: center; gap: 10px; width: 100%; padding: 15px;
  border-radius: 14px; border: 1px solid var(--border); background: var(--surface); color: var(--text); font-size: 15px; font-weight: 700; cursor: pointer; }
[data-theme="dark"] .mp-signout { background: #101827; border-color: rgba(148,163,184,.16); }
.mp-signout:active { background: var(--surface-2); }
.mp-ver { text-align: center; color: var(--text-muted); font-size: 12px; margin-top: 4px; }
