/* ════════════════════════════════════════════════════════════════════════
   Felicity IDC CRM — design layer
   Loaded after main.css (the purchased theme), so this file wins.

   One calm, corporate system for a sales and operations team that lives in
   this application all day: a dark navy navigation shell, a soft neutral
   workspace, white surfaces, and the company's orange used sparingly — for
   the brand mark, the primary action and the current page. Everything else
   stays neutral so the data is the loudest thing on screen.

   Contents
     0  Typography           7  Buttons              14  Dropdowns / dialogs
     1  Tokens               8  Row actions          15  Dashboard
     2  Base                 9  Badges / status      16  Chat workspace
     3  Sidebar             10  Filter tabs          17  Knowledge pages
     4  Header              11  Forms                18  Auth pages
     5  Page shell          12  Pagination           19  Responsive
     6  Cards / tables      13  Empty / loading      20  Helpers

   Rules of the house
   · Colour comes from a token. No page template should need its own hex.
   · Borders and spacing carry hierarchy; shadows are for things that float
     (menus, dialogs), not for cards sitting on the page.
   · `!important` appears only where main.css or Bootstrap already used it,
     or where a two-class theme rule (`.dark .x`) would otherwise win over
     the single-class rule here. Each case says so.
   ════════════════════════════════════════════════════════════════════════ */

/* ── 0. Typography ─────────────────────────────────────────────────────────
   Montserrat is the project typeface (already fetched once by main.css's
   @import, so no second remote font). The Bangla families after it are the
   ones Windows, macOS and Android ship with, so a customer's Bangla message
   is set in a real Bangla face instead of whatever the browser finds.
   Bootstrap reads --bs-font-sans-serif rather than inheriting, hence the
   variable as well as the element list. Icons are <i> elements and <i> is
   deliberately NOT in that list — adding `i` or `*` turns every glyph into
   its ligature text.
   ──────────────────────────────────────────────────────────────────────── */
:root {
  --fx-font: "Montserrat", "Segoe UI", "Noto Sans Bengali", "Nirmala UI", "Vrinda",
             "Bangla Sangam MN", system-ui, -apple-system, sans-serif;
  --fx-font-mono: ui-monospace, SFMono-Regular, "Cascadia Mono", "Consolas", "Courier New", monospace;

  --bs-font-sans-serif:  var(--fx-font);
  --bs-body-font-family: var(--fx-font);
  --bs-btn-font-family:  var(--fx-font);

  /* Type scale */
  --fx-fs-title:   26px;   /* page title */
  --fx-fs-h2:      17px;   /* section heading */
  --fx-fs-body:    14px;
  --fx-fs-table:   13.5px;
  --fx-fs-label:   12.5px; /* supporting labels */
  --fx-fs-kpi:     30px;
}

body,
h1, h2, h3, h4, h5, h6,
p, span, div, a, li, td, th, label, small, strong, b,
button, input, optgroup, select, textarea,
.btn, .form-control, .form-select, .form-check-label,
.badge, .menu-aside a, .content-title, .card-title,
.modal, .tooltip, .popover, .dropdown-menu, .table {
  font-family: var(--fx-font);
}
code, pre, kbd, samp, .font-monospace { font-family: var(--fx-font-mono); }

/* ── 1. Tokens ─────────────────────────────────────────────────────────── */
:root {
  /* Shell */
  --fx-sidebar-bg:     #111827;
  --fx-sidebar-hover:  #2A3547;
  --fx-sidebar-fg:     #D1D5DB;
  --fx-sidebar-mute:   #9CA3AF;
  --fx-sidebar-line:   rgba(255, 255, 255, .08);
  --fx-sidebar-w:      240px;
  --fx-header-h:       64px;

  /* Workspace — warm cream rather than pure white; long days on a white
     screen tire the eye, and the orange brand sits naturally on linen. */
  --fx-bg:         #F4EFE7;   /* page: linen */
  --fx-surface:    #FDFBF7;   /* cards, header: warm off-white */
  --fx-surface-2:  #F7F2EA;   /* subtle surface: table heads, inset panels */
  --fx-surface-3:  #EFE9DF;   /* raised / hover */
  --fx-border:     #E4DCD0;
  --fx-border-sf:  #ECE5DA;   /* softer hairline inside a card */
  --fx-text:       #1F2430;
  --fx-text-soft:  #5B6270;   /* secondary text  — 5.9:1 on the surface */
  --fx-text-mute:  #626977;   /* tertiary text   — 4.7:1 on the page */

  /* Brand */
  --fx-primary:      #C2410C;  /* action colour — 5.2:1 with white text */
  --fx-primary-dk:   #9A3412;
  --fx-accent:       #F97316;  /* small accents on the dark shell only */
  --fx-tint:         #FBEADB;  /* brand tint for the current item, soft fills */
  --fx-tint-bd:      #F3CDAE;
  --fx-link:         #1D4ED8;
  --fx-ring:         0 0 0 3px rgba(194, 65, 12, .22);

  /* Semantic status: foreground / background / border for each tone */
  --fx-success-fg: #166534; --fx-success-bg: #DCFCE7; --fx-success-bd: #BBF7D0; --fx-success: #16A34A;
  --fx-warning-fg: #92400E; --fx-warning-bg: #FEF3C7; --fx-warning-bd: #FDE68A; --fx-warning: #D97706;
  --fx-danger-fg:  #991B1B; --fx-danger-bg:  #FEE2E2; --fx-danger-bd:  #FECACA; --fx-danger:  #DC2626;
  --fx-info-fg:    #1E40AF; --fx-info-bg:    #DBEAFE; --fx-info-bd:    #BFDBFE; --fx-info:    #2563EB;
  --fx-neutral-fg: #374151; --fx-neutral-bg: #EFE9DF; --fx-neutral-bd: #E4DCD0;
  --fx-brand-fg:   #9A3412; --fx-brand-bg:   #FBEADB; --fx-brand-bd:   #F3CDAE;

  /* Categorical palette — for labelled data series only (chart bars,
     knowledge chunks). Restrained, all readable on white. */
  --fx-cat-1: #C2410C; --fx-cat-2: #0F766E; --fx-cat-3: #1D4ED8; --fx-cat-4: #6D28D9;
  --fx-cat-5: #B45309; --fx-cat-6: #BE185D; --fx-cat-7: #4D7C0F; --fx-cat-8: #475569;

  /* Shape */
  --fx-radius:    12px;   /* cards */
  --fx-radius-sm: 8px;    /* controls */
  --fx-shadow:    none;   /* cards sit flat; borders do the work */
  --fx-shadow-lg: 0 12px 32px rgba(23, 32, 51, .14), 0 2px 6px rgba(23, 32, 51, .08); /* menus, dialogs */

  /* Motion */
  --fx-ease: 150ms ease;

  /* ── Aliases for the previous token names ──
     Templates written before this layer still reference these. They now
     resolve to the new palette, so nothing needs to change at once. */
  --ts-primary:    var(--fx-primary);
  --ts-primary-dk: var(--fx-primary-dk);
  --ts-primary-lt: var(--fx-accent);
  --ts-primary-sf: var(--fx-tint);
  --ts-sidebar-bg: var(--fx-sidebar-bg);
  --ts-sidebar-w:  var(--fx-sidebar-hover);
  --ts-green:      var(--fx-success);
  --ts-yellow:     var(--fx-warning);
  --ts-red:        var(--fx-danger);
}

/* Dark mode is its own palette, not an inversion. The shell darkens one
   step further than the surfaces so the sidebar still reads as the frame. */
html.dark {
  --fx-sidebar-bg:    #0B1220;
  --fx-sidebar-hover: #1F2937;
  --fx-sidebar-fg:    #D1D5DB;
  --fx-sidebar-mute:  #9CA3AF;
  --fx-sidebar-line:  rgba(255, 255, 255, .08);

  --fx-bg:         #0B1220;
  --fx-surface:    #111827;
  --fx-surface-2:  #161F31;
  --fx-surface-3:  #1F2937;
  --fx-border:     rgba(255, 255, 255, .10);
  --fx-border-sf:  rgba(255, 255, 255, .06);
  --fx-text:       #F3F4F6;
  --fx-text-soft:  #B0BAC8;   /* 9:1 on the surface */
  --fx-text-mute:  #8B97A8;   /* 6:1 */

  --fx-primary:    #C2410C;
  --fx-primary-dk: #9A3412;
  --fx-accent:     #FB923C;
  --fx-tint:       rgba(249, 115, 22, .14);
  --fx-tint-bd:    rgba(249, 115, 22, .35);
  --fx-link:       #93C5FD;
  --fx-ring:       0 0 0 3px rgba(251, 146, 60, .30);

  --fx-success-fg: #86EFAC; --fx-success-bg: rgba(34, 197, 94, .14);  --fx-success-bd: rgba(34, 197, 94, .30);
  --fx-warning-fg: #FCD34D; --fx-warning-bg: rgba(245, 158, 11, .14); --fx-warning-bd: rgba(245, 158, 11, .32);
  --fx-danger-fg:  #FCA5A5; --fx-danger-bg:  rgba(239, 68, 68, .14);  --fx-danger-bd:  rgba(239, 68, 68, .32);
  --fx-info-fg:    #93C5FD; --fx-info-bg:    rgba(59, 130, 246, .14); --fx-info-bd:    rgba(59, 130, 246, .32);
  --fx-neutral-fg: #D1D5DB; --fx-neutral-bg: rgba(148, 163, 184, .14); --fx-neutral-bd: rgba(148, 163, 184, .28);
  --fx-brand-fg:   #FDBA74; --fx-brand-bg:   rgba(249, 115, 22, .14); --fx-brand-bd:   rgba(249, 115, 22, .35);

  --fx-cat-1: #FB923C; --fx-cat-2: #5EEAD4; --fx-cat-3: #93C5FD; --fx-cat-4: #C4B5FD;
  --fx-cat-5: #FCD34D; --fx-cat-6: #F9A8D4; --fx-cat-7: #BEF264; --fx-cat-8: #CBD5E1;

  --fx-shadow-lg: 0 12px 32px rgba(0, 0, 0, .55), 0 2px 6px rgba(0, 0, 0, .4);
}

/* ── 2. Base ───────────────────────────────────────────────────────────── */
/* Anti-flash: base.html sets the html class before first paint. */
html       { background: var(--fx-bg); }
html.dark  { color-scheme: dark; }
body {
  background: var(--fx-bg);
  color: var(--fx-text);
  font-size: var(--fx-fs-body);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
/* main.css `.dark { background:#222736 }` is on the html element too. */
html.dark, html.dark body { background: var(--fx-bg); color: var(--fx-text); }

a { color: var(--fx-link); }
a:hover { color: var(--fx-link); }

/* Bootstrap utility colours that templates lean on, mapped to the palette.
   Both files set these with !important, so it is needed here too. */
.text-muted { color: var(--fx-text-mute) !important; }
.text-primary { color: var(--fx-primary) !important; }
.text-success { color: var(--fx-success-fg) !important; }
.text-danger  { color: var(--fx-danger) !important; }
.text-warning { color: var(--fx-warning-fg) !important; }
.text-secondary { color: var(--fx-text-soft) !important; }
html.dark .text-danger { color: var(--fx-danger-fg) !important; }
html.dark .text-dark  { color: var(--fx-text) !important; }
.bg-white { background-color: var(--fx-surface) !important; }
.border, .border-top, .border-bottom, .border-start, .border-end { border-color: var(--fx-border) !important; }
hr { border-color: var(--fx-border); opacity: 1; }
::placeholder { color: var(--fx-text-mute); opacity: 1; }

/* One visible keyboard focus everywhere. */
:focus-visible { outline: 2px solid var(--fx-accent); outline-offset: 2px; }
.btn:focus-visible, .form-control:focus-visible, .form-select:focus-visible,
.page-link:focus-visible, .filter-tab:focus-visible, .menu-link:focus-visible {
  outline: none; box-shadow: var(--fx-ring);
}

/* Ordinary transitions stay short; none at all for people who asked. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ── 3. Sidebar ────────────────────────────────────────────────────────── */
/* main.css: 300px, white, `.dark .navbar-aside` two-class rules. The dark
   overrides below use html.dark to out-rank them; light needs no flag. */
.navbar-aside {
  max-width: var(--fx-sidebar-w);
  background: var(--fx-sidebar-bg);
  border-right: 1px solid var(--fx-sidebar-line);
  box-shadow: none;
  display: flex; flex-direction: column;
}
html.dark .navbar-aside { background: var(--fx-sidebar-bg); border-right-color: var(--fx-sidebar-line); }
.main-wrap { margin-left: var(--fx-sidebar-w); background: var(--fx-bg); }
html.dark .main-wrap, html.dark main { background: var(--fx-bg); }

.navbar-aside .aside-top,
html.dark .navbar-aside .aside-top {
  background: transparent;
  border-bottom: 1px solid var(--fx-sidebar-line);
  padding: 12px 12px 12px 16px;
  min-height: var(--fx-header-h);
  align-items: center;
}

/* The brand. The logo raster has its own near-black background baked in
   (#121314). Rather than let that show as a stray rectangle on the navy,
   it sits on a plate of exactly that colour, with the plate drawn as the
   intended container — the raster itself is never filtered or recoloured. */
.navbar-aside .brand-wrap {
  display: flex; align-items: center; justify-content: flex-start;
  flex: 1 1 auto; min-width: 0; padding: 0; text-decoration: none;
}
.navbar-aside .brand-plate {
  display: inline-flex; align-items: center;
  background: #121314;
  border: 1px solid rgba(255, 255, 255, .08);
  border-radius: var(--fx-radius-sm);
  padding: 6px 10px;
}
.navbar-aside .brand-logo { height: 26px; width: auto; max-width: 150px; display: block; }
.navbar-aside .brand-mini { display: none; }
.navbar-aside .brand-favicon { width: 30px; height: 30px; object-fit: contain; display: block; }
body.aside-mini .navbar-aside .brand-mini {
  display: flex; align-items: center; justify-content: center;
  width: 100%; padding: 4px 0; text-decoration: none;
}
body.aside-mini .navbar-aside .brand-wrap { display: none; }

/* The collapse button carries .btn-icon (the row-action style, which paints a
   white box with !important); on the dark shell it should be a quiet glyph. */
.navbar-aside .btn-aside-minimize,
.navbar-aside .btn-aside-minimize:focus {
  width: 36px; height: 36px; padding: 0 !important;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: var(--fx-radius-sm) !important; background: transparent !important; border: 1px solid transparent !important;
  color: var(--fx-sidebar-mute) !important; transition: background var(--fx-ease), color var(--fx-ease);
}
.navbar-aside .btn-aside-minimize:hover { background: var(--fx-sidebar-hover) !important; color: #fff !important; }
.navbar-aside .btn-aside-minimize i, .navbar-aside .btn-aside-minimize:hover i { color: inherit !important; }

.navbar-aside nav { flex: 1 1 auto; min-height: 0; }
.menu-aside { margin: 10px 12px 16px; }

/* Section labels group the menu by workflow. */
.menu-aside .menu-section {
  list-style: none;
  padding: 16px 12px 6px;
  font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase;
  color: var(--fx-sidebar-mute);
}
.menu-aside .menu-section:first-child { padding-top: 4px; }
body.aside-mini .menu-aside .menu-section {
  padding: 8px 0 0; margin: 8px 8px 0; border-top: 1px solid var(--fx-sidebar-line);
  font-size: 0; height: 9px; overflow: hidden;   /* a divider, not a word */
}

.menu-aside .menu-link,
html.dark .menu-aside .menu-link {
  color: var(--fx-sidebar-fg);
  background: transparent;
  border-radius: var(--fx-radius-sm);
  border-left: 3px solid transparent;
  margin: 1px 0;
  padding: 9px 10px 9px 9px;
  font-size: 13.5px; font-weight: 500;
  min-height: 40px;
  transition: background var(--fx-ease), color var(--fx-ease);
}
.menu-aside .menu-link:hover,
html.dark .menu-aside .menu-link:hover { background: var(--fx-sidebar-hover); color: #fff; }
.menu-aside .menu-link .icon,
.menu-aside .menu-link .material-icons,
html.dark .menu-aside .menu-item .icon {
  color: var(--fx-sidebar-mute);
  font-size: 20px !important;   /* vendor icon css sets 22px on the class */
  margin-right: 10px;
  transition: color var(--fx-ease);
}
.menu-aside .menu-link:hover .icon { color: #fff; }

/* The current page: a quiet fill, a narrow brand accent, brighter text. */
.menu-item.active > .menu-link,
html.dark .menu-aside .menu-item.active .menu-link {
  background: rgba(249, 115, 22, .10);
  color: #fff;
  border-left-color: var(--fx-accent);
  font-weight: 600;
}
.menu-item.active > .menu-link .icon,
html.dark .menu-aside .menu-item.active .icon { color: var(--fx-accent); }

/* Group caret, redrawn as a chevron that turns when open. */
.menu-aside .menu-item.has-submenu > .menu-link:after {
  border: 0; width: 8px; height: 8px; right: 14px; top: 50%; margin: 0;
  transform: translateY(-70%) rotate(45deg);
  border-right: 2px solid var(--fx-sidebar-mute); border-bottom: 2px solid var(--fx-sidebar-mute);
  transition: transform var(--fx-ease);
}
.menu-aside .menu-item.has-submenu.active > .menu-link:after { transform: translateY(-30%) rotate(225deg); }

.menu-aside .submenu,
html.dark .menu-aside .submenu {
  background: transparent;
  border: 0; border-left: 1px solid var(--fx-sidebar-line);
  margin: 2px 0 6px 22px; padding: 2px 0 2px 8px;
}
.menu-aside .submenu a,
html.dark .menu-aside .submenu a {
  color: var(--fx-sidebar-mute);
  font-size: 13px; font-weight: 500;
  padding: 7px 10px; margin: 1px 0;
  display: flex; align-items: center; gap: 8px;
  border-radius: 6px; text-decoration: none;
  transition: background var(--fx-ease), color var(--fx-ease);
}
.menu-aside .submenu a::before { display: none; }
.menu-aside .submenu a:hover, html.dark .menu-aside .submenu a:hover { background: var(--fx-sidebar-hover); color: #fff; }
.menu-aside .submenu a.active, .menu-aside .menu-item.active .submenu a.active { background: rgba(249, 115, 22, .10); color: #fff; }
.submenu, .submenu li { list-style: none; }
.navbar-aside hr { border-color: var(--fx-sidebar-line); margin: 8px 16px; opacity: 1; }

/* Collapsed rail (body.aside-mini, main.css: 80px). */
body.aside-mini .navbar-aside { background: var(--fx-sidebar-bg); }
body.aside-mini .menu-aside { margin: 10px 8px; }
body.aside-mini .menu-aside .menu-link { justify-content: center; padding: 10px 0; border-left-width: 0; }
body.aside-mini .menu-aside .menu-link .icon { margin: 0; }
body.aside-mini .menu-item.active > .menu-link { box-shadow: inset 3px 0 0 var(--fx-accent); }
body.aside-mini .menu-aside .submenu,
html.dark body.aside-mini .menu-aside .submenu {
  background: var(--fx-sidebar-bg); border: 1px solid var(--fx-sidebar-line);
  border-radius: var(--fx-radius-sm); margin-left: 8px; padding: 6px; min-width: 200px;
  box-shadow: var(--fx-shadow-lg);
}

/* ── 4. Header ─────────────────────────────────────────────────────────── */
.main-header,
html.dark .main-header {
  min-height: var(--fx-header-h);
  padding: 0 24px;
  background: var(--fx-surface);
  border-bottom: 1px solid var(--fx-border);
  box-shadow: none;
}
.main-header .col-nav { margin-left: auto; align-items: center; }
.main-header .nav { gap: 4px; align-items: center; }
.main-header .nav-item,
.main-header .nav-item.dropdown { margin: 0; }

/* Header controls: equal 40px targets with a hover surface. These links also
   carry .btn-icon (the table row-action style, which paints a bordered box
   with !important), so the box is undone here rather than in the template. */
.main-header .nav-item > a.nav-link,
.main-header .nav-item > a.nav-link.btn-icon,
.main-header .btn.btn-icon.btn-mobile,
html.dark .main-header .nav-item > a {
  width: 40px !important; height: 40px !important; padding: 0 !important;
  align-items: center; justify-content: center;
  border: 1px solid transparent !important;
  background: transparent !important;
  border-radius: var(--fx-radius-sm) !important;
  color: var(--fx-text-soft) !important;
  transition: background var(--fx-ease), color var(--fx-ease);
}
.main-header .nav-item > a.nav-link:hover,
.main-header .btn.btn-icon.btn-mobile:hover,
html.dark .main-header .nav-link:hover {
  background: var(--fx-surface-3) !important;
  color: var(--fx-text) !important;
  transform: none; box-shadow: none;
}
.main-header .nav-item > a.nav-link { display: inline-flex; }
/* The drawer trigger exists only while the sidebar is a drawer (≤ 991px). */
.main-header .btn.btn-icon.btn-mobile { display: none; margin-right: 6px; }
.main-header .nav-link .material-icons { color: inherit; font-size: 21px !important; }

/* The count on the bell. Same selector as main.css so the 16px circle loses;
   content-box keeps the ring outside the badge's own size. */
.main-header .nav-item > a .badge {
  position: absolute; top: 4px; right: 4px;
  min-width: 16px; width: auto !important; height: 16px !important;
  padding: 0 4px !important; border-radius: 999px !important;
  font-size: 10px !important; font-weight: 600 !important; line-height: 16px !important;
  text-align: center;
  background: var(--fx-primary) !important; color: #fff !important;
  border: 2px solid var(--fx-surface) !important; box-sizing: content-box;
}

/* The theme toggle shows the mode it will switch you TO. */
.theme-icon-sun  { display: none !important; }
html.dark .theme-icon-moon { display: none !important; }
html.dark .theme-icon-sun  { display: inline-block !important; }

.main-header .nav-account { margin-left: 8px !important; padding-left: 12px; border-left: 1px solid var(--fx-border); }
.main-header .nav-item > a.nav-avatar, html.dark .main-header .nav-item > a.nav-avatar {
  display: inline-flex; align-items: center; gap: 4px;
  width: auto !important; height: auto !important; padding: 2px !important;
  border: 0 !important; background: transparent !important; border-radius: 999px !important; text-decoration: none;
}
.main-header .nav-avatar img.img-xs {
  width: 34px !important; height: 34px !important; object-fit: cover;
  border: 1px solid var(--fx-border); background: var(--fx-surface-2);
}
.main-header .nav-avatar:hover img.img-xs { border-color: var(--fx-primary); }
.main-header .nav-avatar::after { color: var(--fx-text-mute); margin-left: 2px; }

.account-menu { min-width: 224px; }
.account-menu .account-head { padding: 8px 12px 6px; }
.account-menu .account-head b { display: block; font-size: 13.5px; font-weight: 600; color: var(--fx-text); }
.account-menu .account-head small { display: block; font-size: 12px; color: var(--fx-text-mute); margin-top: 1px; }
.account-menu .dropdown-item { display: flex; align-items: center; gap: 9px; }
.account-menu .dropdown-item .material-icons { font-size: 18px !important; color: var(--fx-text-mute); }

/* ── 5. Page shell ─────────────────────────────────────────────────────── */
.content-main, html.dark .content-main { padding: 28px 32px 48px; max-width: 1600px; background: transparent; }

.content-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 16px; flex-wrap: wrap; margin-bottom: 24px;
}
.content-header > *:first-child { flex: 1 1 auto; min-width: 0; }
.content-header > *:last-child:not(:first-child) { flex: 0 1 auto; min-width: 0; padding-top: 4px; }
.content-title,
html.dark h2.content-title {
  font-size: var(--fx-fs-title) !important;   /* main.css .card-title sets its own size */
  font-weight: 600 !important;
  letter-spacing: -.01em; line-height: 1.25;
  color: var(--fx-text) !important;
  margin: 0 0 4px !important;
}
.content-header .text-muted, .page-subtitle,
.content-header p.small { font-size: 13.5px; color: var(--fx-text-soft) !important; margin: 0; max-width: 72ch; }

footer.main-footer { color: var(--fx-text-mute); font-size: 12px; }
footer.main-footer .row { align-items: center; }

/* ── 6. Cards and tables ───────────────────────────────────────────────── */
.card, html.dark .card {
  background: var(--fx-surface);
  border: 1px solid var(--fx-border);
  border-radius: var(--fx-radius);
  box-shadow: none;
  color: var(--fx-text);
}
.card-header, html.dark .card-header {
  background: transparent;
  border-bottom: 1px solid var(--fx-border-sf);
  border-radius: var(--fx-radius) var(--fx-radius) 0 0;
  padding: 16px 20px;
  color: var(--fx-text);
}
.card-header h6, .card-header .h6 { font-size: 15px; font-weight: 600; margin: 0; }
.card-title, .card-body, html.dark .card-body { color: var(--fx-text); }
.card-body { padding: 20px; }
.card-body.p-0 > .table-responsive { border-radius: var(--fx-radius); overflow: hidden; }
h6, .h6 { font-weight: 600; }
.card h6.fw-bold, .card .fw-bold { font-weight: 600 !important; }

.table-responsive { overflow-x: auto; }
.table, html.dark .table {
  margin-bottom: 0; --bs-table-bg: transparent;
  color: var(--fx-text); font-size: var(--fx-fs-table); border-color: var(--fx-border-sf);
}
.table > :not(caption) > * > *,
html.dark .table > :not(caption) > * > * {
  background: transparent; color: var(--fx-text);
  border-color: var(--fx-border-sf);
  padding: 12px 14px; vertical-align: middle;
}
.table thead th, .table > thead > tr > th, .table-light th {
  background: var(--fx-surface-2) !important;   /* Bootstrap .table-light sets a var with !important */
  color: var(--fx-text-soft) !important;
  font-size: 12px !important; font-weight: 600 !important;
  letter-spacing: .01em; text-transform: none; white-space: nowrap;
  border-bottom: 1px solid var(--fx-border) !important;
  padding: 11px 14px !important;
}
.table thead th:first-child { border-top-left-radius: var(--fx-radius); }
.table thead th:last-child  { border-top-right-radius: var(--fx-radius); }
.table.table-hover > tbody > tr:hover > * { background: var(--fx-surface-2); --bs-table-accent-bg: transparent; }
.table tbody tr:last-child > * { border-bottom: 0; }
.table td b, .table td strong { font-weight: 600; }
.table td.cell-clip { max-width: 320px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.table td small, .table .text-muted { color: var(--fx-text-mute) !important; }
.table code { font-size: 12px; color: var(--fx-text-soft); background: var(--fx-surface-3); padding: 2px 6px; border-radius: 4px; }
/* Numbers line up on the decimal and read right-aligned. */
.table td.num, .table th.num, .num { text-align: right; font-variant-numeric: tabular-nums; }
.tabular { font-variant-numeric: tabular-nums; }

/* ── 7. Buttons ────────────────────────────────────────────────────────── */
/* Bootstrap 5.3 buttons read --bs-btn-* variables, so each variant is a
   handful of tokens. main.css ships `.btn.btn-primary{padding:10px 40px}`,
   which out-specifies .btn-sm, hence the re-assertion of sizes. */
.btn {
  --bs-btn-border-radius: var(--fx-radius-sm);
  --bs-btn-font-weight: 600;
  --bs-btn-font-size: 14px;
  --bs-btn-padding-y: 9px; --bs-btn-padding-x: 16px;
  --bs-btn-focus-box-shadow: var(--fx-ring);
  border-radius: var(--fx-radius-sm) !important;   /* main.css rounds some variants to 999px */
  font-weight: 600 !important;
  transition: background var(--fx-ease), border-color var(--fx-ease), color var(--fx-ease), box-shadow var(--fx-ease);
  box-shadow: none;
}
.btn.btn-primary, .btn.btn-secondary { padding: 9px 16px !important; font-size: 14px !important; }
.btn.btn-sm { padding: 6px 12px !important; font-size: 13px !important; line-height: 1.4 !important; white-space: nowrap; }
.btn.btn-sm.font-sm { font-size: 12.5px !important; padding: 6px 12px !important; }
.btn.btn-sm i, .btn .material-icons { font-size: 17px !important; vertical-align: -4px; }
.btn.btn-xs { padding: 4px 10px !important; font-size: 12px !important; }

/* An icon that leads a label gets breathing room; an icon-only button none. */
.btn > .material-icons:first-child:not(:last-child) { margin-right: 6px; }
.btn.btn-icon > .material-icons { margin: 0; }

/* Variants. main.css paints these with direct properties (its theme green),
   which beat Bootstrap's variable-driven rules — so the properties are set
   directly here too, at the same specificity, later in the cascade. */
/* Primary: the one orange action on a screen. main.css writes the theme
   green on `.btn.btn-primary` (two classes), so these match that weight. */
.btn.btn-primary, .btn.btn-primary:focus, .btn.btn-primary:disabled, .btn.btn-primary.disabled {
  background-color: var(--fx-primary); border: 1px solid var(--fx-primary); color: #fff;
}
.btn.btn-primary:hover, .btn.btn-primary:active, .btn.btn-primary.active, .btn.btn-primary:first-child:active {
  background-color: var(--fx-primary-dk); border-color: var(--fx-primary-dk); color: #fff;
}
.btn.btn-primary i { color: inherit; }
/* Secondary: white with a border. Both .btn-light and .btn-secondary are
   used in the templates for "the other button"; they look the same.
   main.css sets .btn-light with !important, hence the flag on that one. */
.btn.btn-secondary, .btn.btn-secondary:focus, .btn.btn-outline-secondary, .btn.btn-outline-primary {
  background-color: var(--fx-surface); border: 1px solid var(--fx-border); color: var(--fx-text);
}
.btn.btn-secondary:hover, .btn.btn-outline-secondary:hover, .btn.btn-outline-primary:hover {
  background-color: var(--fx-surface-3); border-color: var(--fx-border); color: var(--fx-text);
}
.btn.btn-light, .btn.btn-light:focus { background: var(--fx-surface) !important; border: 1px solid var(--fx-border) !important; color: var(--fx-text) !important; }
.btn.btn-light:hover, .btn.btn-light:active { background: var(--fx-surface-3) !important; color: var(--fx-text) !important; }
.btn.btn-light i, .btn.btn-light:hover i { color: inherit !important; }
/* Ghost: text only, for tertiary actions in toolbars and card headers. */
.btn.btn-ghost, .btn.btn-ghost:focus {
  background: transparent !important; border-color: transparent !important; color: var(--fx-text-soft) !important;
}
.btn.btn-ghost:hover, .btn.btn-ghost:active { background: var(--fx-surface-3) !important; color: var(--fx-text) !important; }
/* Destructive. */
.btn-danger, .btn-danger:focus { background-color: var(--fx-danger); border-color: var(--fx-danger); color: #fff; }
.btn-danger:hover, .btn-danger:active { background-color: #B91C1C; border-color: #B91C1C; color: #fff; }
.btn-outline-danger { color: var(--fx-danger); border-color: var(--fx-danger-bd); background-color: transparent; }
.btn-outline-danger:hover { background-color: var(--fx-danger); border-color: var(--fx-danger); color: #fff; }
.btn-success, .btn-success:focus { background-color: var(--fx-success); border-color: var(--fx-success); color: #fff; }
.btn-success:hover, .btn-success:active { background-color: #15803D; border-color: #15803D; color: #fff; }
.btn-close { filter: none; }
html.dark .btn-close { filter: invert(1) grayscale(100%) brightness(200%); }

/* ── 8. Row actions (the Action column) ────────────────────────────────── */
.row-actions { display: flex; align-items: center; justify-content: flex-end; gap: 6px; white-space: nowrap; }
.row-actions .dropdown { display: inline-flex; }
.btn-icon {
  --icon-fg: var(--fx-text-soft); --icon-bg: var(--fx-surface); --icon-bd: var(--fx-border);
  width: 34px; height: 34px; padding: 0 !important;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: var(--fx-radius-sm) !important;
  border: 1px solid var(--icon-bd) !important;
  background: var(--icon-bg) !important;
  color: var(--icon-fg) !important;
  line-height: 1; cursor: pointer;
  transition: background var(--fx-ease), color var(--fx-ease), border-color var(--fx-ease);
}
.btn-icon .material-icons { font-size: 18px !important; color: inherit !important; vertical-align: 0; }
.btn-icon:hover { --icon-bg: var(--fx-surface-3); --icon-fg: var(--fx-text); transform: none; box-shadow: none; }
.btn-icon:focus-visible { outline: none; box-shadow: var(--fx-ring); }
.btn-icon.is-primary { --icon-fg: var(--fx-brand-fg); --icon-bd: var(--fx-brand-bd); --icon-bg: var(--fx-brand-bg); }
.btn-icon.is-primary:hover { --icon-fg: #fff; --icon-bg: var(--fx-primary); --icon-bd: var(--fx-primary); }
.btn-icon.is-success { --icon-fg: var(--fx-success-fg); --icon-bd: var(--fx-success-bd); --icon-bg: var(--fx-success-bg); }
.btn-icon.is-success:hover { --icon-fg: #fff; --icon-bg: var(--fx-success); --icon-bd: var(--fx-success); }
.btn-icon.is-danger  { --icon-fg: var(--fx-danger-fg); --icon-bd: var(--fx-danger-bd); --icon-bg: var(--fx-danger-bg); }
.btn-icon.is-danger:hover { --icon-fg: #fff; --icon-bg: var(--fx-danger); --icon-bd: var(--fx-danger); }
.btn-icon.is-warning { --icon-fg: var(--fx-warning-fg); --icon-bd: var(--fx-warning-bd); --icon-bg: var(--fx-warning-bg); }
.btn-icon.is-warning:hover { --icon-fg: #fff; --icon-bg: var(--fx-warning); --icon-bd: var(--fx-warning); }
.btn-icon.has-label { width: auto; padding: 0 12px !important; gap: 6px; font-size: 12.5px; font-weight: 600; }
.row-actions .dropdown .btn-sm { padding: 0 !important; }

/* ── 9. Badges and status ──────────────────────────────────────────────── */
/* One soft treatment for every status label: tinted background, readable
   foreground of the same hue, hairline border. Fully rounded is reserved
   for these and for chips. */
.pill, .lead-pill, .status-pill, .bant-pill, .badge {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 12px !important; font-weight: 600;
  padding: 3px 10px !important; border-radius: 999px !important;
  line-height: 1.5; white-space: nowrap; letter-spacing: 0; text-transform: none;
  border: 1px solid transparent; vertical-align: middle;
}
.badge.rounded-pill { border-radius: 999px !important; }

/* Tone set. Bootstrap's .bg-* are solid neon fills set with !important, so
   these need it too. main.css's .badge-soft-* are plain and lose on order. */
.pill-neutral, .lead-unknown, .badge.bg-secondary, .badge.bg-light, .badge.bg-dark,
.badge-soft-secondary, .badge-closed, .badge-cancelled, .badge-appt-cancelled, .status-pill.intent-count {
  background: var(--fx-neutral-bg) !important; color: var(--fx-neutral-fg) !important; border-color: var(--fx-neutral-bd); }
.pill-info, .lead-cold, .badge.bg-info, .badge-soft-info, .badge-new, .badge-appt-new {
  background: var(--fx-info-bg) !important; color: var(--fx-info-fg) !important; border-color: var(--fx-info-bd); }
.pill-success, .badge.bg-success, .badge-soft-success, .badge-engaging, .badge-appt-confirmed, .bant-high {
  background: var(--fx-success-bg) !important; color: var(--fx-success-fg) !important; border-color: var(--fx-success-bd); }
.pill-warning, .lead-warm, .badge.bg-warning, .badge-soft-warning, .badge-qualifying, .badge-handover, .badge-appt-called, .bant-mid {
  background: var(--fx-warning-bg) !important; color: var(--fx-warning-fg) !important; border-color: var(--fx-warning-bd); }
.pill-danger, .lead-hot, .badge.bg-danger, .badge-soft-danger, .bant-low {
  background: var(--fx-danger-bg) !important; color: var(--fx-danger-fg) !important; border-color: var(--fx-danger-bd); }
.pill-primary, .badge.bg-primary, .badge-soft-primary, .badge-negotiating {
  background: var(--fx-brand-bg) !important; color: var(--fx-brand-fg) !important; border-color: var(--fx-brand-bd); }
.badge.bg-light.text-muted, .badge.bg-secondary.text-muted, .badge.text-dark { color: var(--fx-neutral-fg) !important; }

/* Status is never colour alone: every tone carries a small mark. */
.lead-pill::before, .status-pill::before, .badge-soft-success::before, .badge-soft-warning::before,
.badge-soft-danger::before, .badge-soft-info::before, .badge-soft-secondary::before {
  content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .8; flex: 0 0 auto;
}
.status-pill.intent-count::before { display: none; }

/* Inquiry status <select> — an editable status that reads like a badge. The
   class names are bound by JS in inquiry_list.html; only the look lives here. */
.status-select, .form-select.status-select {
  border-radius: 999px !important; font-weight: 600; font-size: 12px !important;
  cursor: pointer; text-align: center; padding: 4px 26px 4px 12px !important;
  height: auto !important; width: auto; line-height: 1.5;
  border: 1px solid var(--fx-neutral-bd) !important;
  background-color: var(--fx-neutral-bg) !important; color: var(--fx-neutral-fg) !important;
  background-position: right 8px center !important; background-size: 12px !important;
}
.status-select option { background: var(--fx-surface); color: var(--fx-text); font-weight: normal; }
.status-new, .status-site_visit_booked { background-color: var(--fx-info-bg) !important; color: var(--fx-info-fg) !important; border-color: var(--fx-info-bd) !important; }
.status-qualifying, .status-quoted, .status-negotiating { background-color: var(--fx-warning-bg) !important; color: var(--fx-warning-fg) !important; border-color: var(--fx-warning-bd) !important; }
.status-qualified, .status-won { background-color: var(--fx-success-bg) !important; color: var(--fx-success-fg) !important; border-color: var(--fx-success-bd) !important; }
.status-lost { background-color: var(--fx-danger-bg) !important; color: var(--fx-danger-fg) !important; border-color: var(--fx-danger-bd) !important; }
.status-on_hold { background-color: var(--fx-neutral-bg) !important; color: var(--fx-neutral-fg) !important; border-color: var(--fx-neutral-bd) !important; }

/* Team role labels (team_base.html). */
.tm-role { font-size: 12px; font-weight: 600; border-radius: 999px; padding: 3px 10px; white-space: nowrap; border: 1px solid transparent; letter-spacing: 0; text-transform: none; }
.tm-owner   { background: var(--fx-brand-bg); color: var(--fx-brand-fg); border-color: var(--fx-brand-bd); }
.tm-manager { background: var(--fx-success-bg); color: var(--fx-success-fg); border-color: var(--fx-success-bd); }
.tm-agent   { background: var(--fx-neutral-bg); color: var(--fx-neutral-fg); border-color: var(--fx-neutral-bd); }

/* ── 10. Filter tabs ───────────────────────────────────────────────────── */
/* Segmented filters above a list. The current one takes the brand tint and
   a brand border — clearly current, never a saturated block. Several pages
   named their own copies (.kb-tab, .visit-tab, .kx-tab, .tm-tab); they all
   resolve to this. */
.filter-tabs, .lead-tabs, .kb-tabs, .visit-tabs, .kx-tabs { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 18px; }
.filter-tab, .lead-tab, .kb-tab, .visit-tab, .kx-tab {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 7px 14px; border-radius: 999px;
  font-size: 13px; font-weight: 500; text-decoration: none;
  border: 1px solid var(--fx-border); color: var(--fx-text-soft); background: var(--fx-surface);
  transition: background var(--fx-ease), color var(--fx-ease), border-color var(--fx-ease);
  min-height: 36px;
}
.filter-tab:hover, .lead-tab:hover, .kb-tab:hover, .visit-tab:hover, .kx-tab:hover {
  color: var(--fx-text); background: var(--fx-surface-3); border-color: var(--fx-border); transform: none; box-shadow: none;
}
.filter-tab.active, .lead-tab.active, .kb-tab.active, .visit-tab.active, .kx-tab.active,
html.dark .kb-tab.active, html.dark .visit-tab.active {
  background: var(--fx-tint); border-color: var(--fx-tint-bd); color: var(--fx-brand-fg); font-weight: 600; box-shadow: none;
}
.filter-tab .count, .lead-tab .count, .kb-tab .count, .visit-tab .count, .kx-tab .n {
  font-size: 11.5px; font-weight: 600; font-variant-numeric: tabular-nums;
  background: var(--fx-surface-3); color: var(--fx-text-soft);
  padding: 1px 7px; border-radius: 999px; margin-left: 2px; opacity: 1;
}
.filter-tab.active .count, .lead-tab.active .count, .kb-tab.active .count, .visit-tab.active .count, .kx-tab.active .n {
  background: rgba(194, 65, 12, .14); color: var(--fx-brand-fg);
}
.filter-tab .material-icons { font-size: 17px !important; }
/* Lead temperature tabs carry a small tone dot instead of an emoji. */
.lead-tab.tab-hot::before, .lead-tab.tab-warm::before, .lead-tab.tab-cold::before {
  content: ""; width: 8px; height: 8px; border-radius: 50%; flex: 0 0 auto;
}
.lead-tab.tab-hot::before  { background: var(--fx-danger); }
.lead-tab.tab-warm::before { background: var(--fx-warning); }
.lead-tab.tab-cold::before { background: var(--fx-info); }

/* ── 11. Forms ─────────────────────────────────────────────────────────── */
.form-control, .form-select, html.dark .form-control, html.dark .form-select {
  background-color: var(--fx-surface);
  border: 1px solid var(--fx-border);
  border-radius: var(--fx-radius-sm);
  color: var(--fx-text);
  font-size: 14px; height: 40px; padding: 0 12px;
  box-shadow: none;
  transition: border-color var(--fx-ease), box-shadow var(--fx-ease);
}
.form-select { padding-right: 32px; }
textarea.form-control { height: auto; padding: 10px 12px; line-height: 1.55; min-height: 96px; }
.form-control-sm, .form-select-sm { height: 34px; font-size: 13px; }
.form-control:focus, .form-select:focus, html.dark .form-control:focus {
  background-color: var(--fx-surface); border-color: var(--fx-primary); box-shadow: var(--fx-ring); color: var(--fx-text);
}
.form-control::placeholder { color: var(--fx-text-mute); }
.form-control:disabled, .form-select:disabled { background-color: var(--fx-surface-2); color: var(--fx-text-mute); }
.form-label, .field-label { font-size: 13px; font-weight: 600; color: var(--fx-text); margin-bottom: 6px; display: block; }
.form-label .text-danger, .field-label .text-danger { font-weight: 600; }
.form-text, small.text-muted, .form-hint { font-size: 12.5px; color: var(--fx-text-mute); }
.form-check-input { width: 17px; height: 17px; margin-top: .2em; border-color: var(--fx-border); }
.form-check-input:checked { background-color: var(--fx-primary); border-color: var(--fx-primary); }
.form-check-input:focus { border-color: var(--fx-primary); box-shadow: var(--fx-ring); }
input[type=checkbox], input[type=radio] { accent-color: var(--fx-primary); }
.form-range::-webkit-slider-thumb { background: var(--fx-primary); }
.form-range::-moz-range-thumb { background: var(--fx-primary); }
.invalid-feedback, .text-danger.small { font-size: 12.5px; }
.is-invalid, .form-control.is-invalid { border-color: var(--fx-danger) !important; }

/* Toggle switch (settings). Markup: label.switch > input + span.slider */
.switch { position: relative; display: inline-block; width: 44px; height: 24px; flex: 0 0 auto; }
.switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.slider {
  position: absolute; cursor: pointer; inset: 0;
  background: var(--fx-border); border-radius: 24px; transition: background var(--fx-ease);
}
.slider:before {
  content: ""; position: absolute; height: 18px; width: 18px; left: 3px; top: 3px;
  background: var(--fx-surface); border-radius: 50%; transition: transform var(--fx-ease);
  box-shadow: 0 1px 2px rgba(0, 0, 0, .2);
}
html.dark .slider { background: var(--fx-surface-3); }
.switch input:checked + .slider { background: var(--fx-success); }
.switch input:checked + .slider:before { transform: translateX(20px); }
.switch input:focus-visible + .slider { box-shadow: var(--fx-ring); }
.mode-desc { font-size: 13px; color: var(--fx-text-soft); }

/* Search / filter toolbar in a page header or card. main.css forces
   width:100% on every control; inside a toolbar they size to content. */
.toolbar-form { display: flex; flex-wrap: nowrap; gap: 8px; align-items: center; justify-content: flex-end; }
.toolbar-form .form-control, .toolbar-form .form-select { width: auto !important; min-width: 0; margin: 0; }
.toolbar-form input.form-control { flex: 1 1 260px; max-width: 360px; }
.toolbar-form .form-select { flex: 0 0 auto; width: auto !important; min-width: 140px; max-width: 190px; text-overflow: ellipsis; padding-right: 30px; }
.toolbar-form .btn { flex: 0 0 auto; white-space: nowrap; }
@media (max-width: 991.98px) {
  .toolbar-form { flex-wrap: wrap; justify-content: flex-start; }
  .toolbar-form input.form-control { flex: 1 1 100%; max-width: none; }
  .toolbar-form .form-select { flex: 1 1 auto; }
}

/* Every list searches through an input named `q`; one rule gives them all a
   magnifier. .form-control sets `background` with the shorthand, so the
   image is re-declared here with the higher-specificity selector. */
input.form-control[name="q"] {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2364748B' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='M20 20l-3.9-3.9'/%3E%3C/svg%3E") !important;
  background-repeat: no-repeat !important; background-position: 12px center !important; background-size: 16px 16px !important;
  padding-left: 36px !important;
}
html.dark input.form-control[name="q"] {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238B97A8' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='M20 20l-3.9-3.9'/%3E%3C/svg%3E") !important;
}
.search-hint {
  position: absolute; right: 10px; top: 50%; transform: translateY(-50%);
  font-size: 11px; font-weight: 600; line-height: 1; padding: 3px 6px; border-radius: 4px;
  color: var(--fx-text-mute); background: var(--fx-surface-2); border: 1px solid var(--fx-border);
  pointer-events: none; transition: opacity var(--fx-ease);
}

/* Bootstrap alerts, retoned. */
.alert { border-radius: var(--fx-radius-sm); border: 1px solid transparent; font-size: 13.5px; padding: 12px 14px; }
.alert-success { background: var(--fx-success-bg); color: var(--fx-success-fg); border-color: var(--fx-success-bd); }
.alert-warning { background: var(--fx-warning-bg); color: var(--fx-warning-fg); border-color: var(--fx-warning-bd); }
.alert-danger  { background: var(--fx-danger-bg);  color: var(--fx-danger-fg);  border-color: var(--fx-danger-bd); }
.alert-info    { background: var(--fx-info-bg);    color: var(--fx-info-fg);    border-color: var(--fx-info-bd); }
.alert code { color: inherit; background: rgba(0, 0, 0, .06); padding: 1px 5px; border-radius: 4px; }

/* ── 12. Pagination ──────────────────────────────────────────────────── */
.pagination-area { margin-top: 20px; }
.pager-nav { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px; }
.pager-summary { font-size: 13px; color: var(--fx-text-soft); }
.pager-summary b { color: var(--fx-text); font-weight: 600; font-variant-numeric: tabular-nums; }
.pagination {
  gap: 2px; flex-wrap: wrap; align-items: center; padding: 3px;
  border-radius: var(--fx-radius-sm); background: var(--fx-surface); border: 1px solid var(--fx-border); box-shadow: none;
}
.pagination .page-link {
  border: 0 !important; background: transparent !important; color: var(--fx-text-soft) !important;
  border-radius: 6px !important; min-width: 32px; height: 32px;
  display: inline-flex; align-items: center; justify-content: center; padding: 0 10px !important;
  font-size: 13px; font-weight: 600; line-height: 1; font-variant-numeric: tabular-nums;
  box-shadow: none !important; transition: background var(--fx-ease), color var(--fx-ease);
}
/* main.css sets `.pagination-area .page-item .page-link { display:block }`
   with three classes; matched here so the arrow glyph is centred by flex
   rather than sitting at the top of the box. */
.pagination-area .page-item .page-link { display: inline-flex; align-items: center; justify-content: center; line-height: 1; }
.pagination .page-link:hover { background: var(--fx-surface-3) !important; color: var(--fx-text) !important; }
.pagination .page-link:focus-visible { outline: none; box-shadow: var(--fx-ring) !important; }
.pagination .page-item.active .page-link { background: var(--fx-primary) !important; color: #fff !important; }
.pagination .page-item.disabled .page-link { opacity: .35; pointer-events: none; }
.pagination .pager-gap .page-link { min-width: 20px; padding: 0 2px !important; color: var(--fx-text-mute) !important; }
.pagination .pager-gap .page-link:hover { background: transparent !important; }
.pagination .pager-arrow { padding: 0 !important; min-width: 32px; }
.pagination .pager-arrow .material-icons { font-size: 19px !important; color: inherit !important; line-height: 1 !important; display: block; vertical-align: 0; }
.pagination .pager-compact { display: none; }
.pagination .pager-compact .page-link { font-size: 13px; color: var(--fx-text) !important; cursor: default; padding: 0 12px !important; }
.pagination .pager-compact .page-link:hover { background: transparent !important; }
@media (max-width: 575.98px) {
  .pager-nav { justify-content: center; }
  .pager-summary { width: 100%; text-align: center; order: 2; }
  .pagination { order: 1; }
  .pagination .page-item:not(.pager-compact):not(:first-child):not(:last-child) { display: none; }
  .pagination .pager-compact { display: inline-flex; }
}

/* ── 13. Empty, loading and error states ───────────────────────────────── */
.empty-state { padding: 44px 20px; text-align: center; }
.empty-state .material-icons { font-size: 36px !important; color: var(--fx-text-mute); opacity: .7; margin-bottom: 8px; }
.empty-state h6 { font-size: 15px; font-weight: 600; color: var(--fx-text); margin: 4px 0 4px; }
.empty-state p  { font-size: 13.5px; color: var(--fx-text-soft); margin: 0; max-width: 46ch; margin-inline: auto; }
.table .empty-state { padding: 40px 20px; }
.loading-state { padding: 20px; text-align: center; color: var(--fx-text-mute); font-size: 13px; }
.loading-state.is-error, .empty-state.is-error { color: var(--fx-danger-fg); }
.fx-spinner {
  display: inline-block; width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid var(--fx-border); border-top-color: var(--fx-primary); animation: fx-spin .7s linear infinite;
}
@keyframes fx-spin { to { transform: rotate(360deg); } }

/* ── 14. Dropdowns, dialogs, toasts ─────────────────────────────────────── */
.dropdown-menu, html.dark .dropdown-menu {
  background: var(--fx-surface); border: 1px solid var(--fx-border);
  border-radius: var(--fx-radius-sm); box-shadow: var(--fx-shadow-lg); padding: 6px; color: var(--fx-text);
}
.dropdown-item, html.dark .dropdown-menu a {
  border-radius: 6px; font-size: 13.5px; padding: 8px 12px; color: var(--fx-text);
}
.dropdown-item:hover, .dropdown-item:focus, html.dark .dropdown-menu .dropdown-item:hover { background: var(--fx-surface-3); color: var(--fx-text); }
.dropdown-item.text-danger, html.dark .dropdown-menu .dropdown-item.text-danger { color: var(--fx-danger) !important; }
html.dark .dropdown-item.text-danger { color: var(--fx-danger-fg) !important; }
.dropdown-item.text-danger:hover { background: var(--fx-danger-bg); }
.dropdown-divider { border-color: var(--fx-border); opacity: 1; }
.dropdown-header { font-size: 11.5px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--fx-text-mute); }

.modal-content { background: var(--fx-surface); color: var(--fx-text); border: 1px solid var(--fx-border); border-radius: var(--fx-radius); box-shadow: var(--fx-shadow-lg); }
.modal-header, .modal-footer { border-color: var(--fx-border-sf); }
.modal-title { font-size: 16px; font-weight: 600; }

/* The hand-rolled overlays used by the Knowledge Base view, Services
   knowledge, Recheck compare and Teach panels share one look. */
.kb-view-overlay, .skb-overlay, .cmp-overlay, .teach-overlay {
  position: fixed; inset: 0; z-index: 1080; padding: 20px;
  background: rgba(17, 24, 39, .55); display: none; align-items: center; justify-content: center;
}
.kb-view-overlay.open, .skb-overlay.open, .cmp-overlay.open, .teach-overlay.open { display: flex; }
.kb-view-card, .skb-card, .cmp-card, .teach-card {
  background: var(--fx-surface); color: var(--fx-text);
  border: 1px solid var(--fx-border); border-radius: var(--fx-radius); box-shadow: var(--fx-shadow-lg);
}
.kb-view-close, .skb-close, .cmp-close {
  border: 0; background: none; font-size: 20px; line-height: 1; cursor: pointer;
  color: var(--fx-text-mute); width: 32px; height: 32px; border-radius: 6px;
}
.kb-view-close:hover, .skb-close:hover, .cmp-close:hover { color: var(--fx-text); background: var(--fx-surface-3); opacity: 1; }

.tooltip { --bs-tooltip-bg: #111827; --bs-tooltip-color: #fff; --bs-tooltip-border-radius: 6px; font-size: 12px; }
/* SweetAlert2 — confirm dialogs and the flash toasts. The library's defaults
   are oversized next to this interface (a 5em icon, 1.875em titles, its own
   blue); both are brought onto the same tokens, type scale and radii. */
.swal2-container { z-index: 2000 !important; }
.swal2-popup {
  background: var(--fx-surface) !important; color: var(--fx-text) !important;
  border: 1px solid var(--fx-border); border-radius: var(--fx-radius) !important;
  box-shadow: var(--fx-shadow-lg) !important; font-family: var(--fx-font) !important;
  width: min(420px, calc(100vw - 32px)) !important; padding: 24px 24px 20px !important;
}
.swal2-icon { width: 48px !important; height: 48px !important; margin: 4px auto 14px !important; border-width: 2px !important; }
.swal2-icon .swal2-icon-content { font-size: 28px !important; }
.swal2-icon.swal2-warning { border-color: var(--fx-warning) !important; color: var(--fx-warning) !important; }
.swal2-icon.swal2-error { border-color: var(--fx-danger) !important; }
.swal2-icon.swal2-error [class^=swal2-x-mark-line] { background-color: var(--fx-danger) !important; }
.swal2-icon.swal2-success { border-color: var(--fx-success) !important; color: var(--fx-success) !important; }
.swal2-icon.swal2-success [class^=swal2-success-line] { background-color: var(--fx-success) !important; }
.swal2-icon.swal2-success .swal2-success-ring { border-color: var(--fx-success-bd) !important; }
.swal2-icon.swal2-info, .swal2-icon.swal2-question { border-color: var(--fx-info) !important; color: var(--fx-info) !important; }
.swal2-title { font-size: 18px !important; font-weight: 600 !important; color: var(--fx-text) !important; padding: 0 !important; margin: 0 0 6px !important; }
.swal2-html-container { font-size: 14px !important; line-height: 1.55 !important; color: var(--fx-text-soft) !important; margin: 0 !important; padding: 0 4px !important; }
.swal2-actions { margin: 20px 0 0 !important; gap: 8px; }
.swal2-styled { margin: 0 !important; font-family: var(--fx-font) !important; font-size: 14px !important; font-weight: 600 !important; padding: 9px 16px !important; border-radius: var(--fx-radius-sm) !important; box-shadow: none !important; }
.swal2-styled.swal2-confirm { background: var(--fx-primary) !important; color: #fff !important; }
.swal2-styled.swal2-confirm:hover { background: var(--fx-primary-dk) !important; }
.swal2-styled.swal2-cancel { background: var(--fx-surface) !important; color: var(--fx-text) !important; border: 1px solid var(--fx-border) !important; }
.swal2-styled.swal2-cancel:hover { background: var(--fx-surface-3) !important; }
.swal2-styled:focus-visible { box-shadow: var(--fx-ring) !important; }

/* Toasts: a compact card in the corner — one line of text, a small icon, a
   thin progress bar in the tone of the message. Long text wraps; nothing
   scrolls. */
.swal2-toast {
  width: auto !important; max-width: min(400px, calc(100vw - 32px)) !important;
  padding: 10px 14px 10px 12px !important; margin: 12px !important;
  background: var(--fx-surface) !important; color: var(--fx-text) !important;
  border: 1px solid var(--fx-border) !important; border-radius: var(--fx-radius-sm) !important;
  box-shadow: var(--fx-shadow-lg) !important; overflow: hidden !important;
  display: flex !important; align-items: center !important; gap: 10px;
  animation: fx-pop .16s ease-out both;
}
.swal2-toast .swal2-icon { width: 22px !important; height: 22px !important; min-width: 22px !important; margin: 0 !important; border-width: 2px !important; flex: 0 0 auto; }
.swal2-toast .swal2-icon .swal2-icon-content { font-size: 14px !important; font-weight: 700; }
.swal2-toast .swal2-icon.swal2-success .swal2-success-ring { display: none !important; }
.swal2-toast .swal2-icon.swal2-success [class^=swal2-success-line][class$=tip] { top: 11px !important; left: 3px !important; width: 7px !important; }
.swal2-toast .swal2-icon.swal2-success [class^=swal2-success-line][class$=long] { top: 9px !important; right: 3px !important; width: 12px !important; }
.swal2-toast .swal2-title {
  font-size: 13.5px !important; font-weight: 500 !important; line-height: 1.45 !important;
  margin: 0 !important; padding: 0 !important; text-align: left !important; color: var(--fx-text) !important;
  overflow-wrap: anywhere; word-break: break-word; min-width: 0; flex: 1 1 auto;
}
.swal2-toast .swal2-html-container { font-size: 13px !important; margin: 0 !important; padding: 0 !important; text-align: left !important; }
.swal2-toast .swal2-timer-progress-bar { background: var(--fx-primary) !important; height: 2px !important; opacity: .7; }
.swal2-toast.swal2-icon-success .swal2-timer-progress-bar { background: var(--fx-success) !important; }
.swal2-toast.swal2-icon-error .swal2-timer-progress-bar { background: var(--fx-danger) !important; }
.swal2-toast.swal2-icon-warning .swal2-timer-progress-bar { background: var(--fx-warning) !important; }
.swal2-container.swal2-top-end { padding: 8px !important; }
html.dark .swal2-popup, html.dark .swal2-toast { background: var(--fx-surface-3) !important; }

/* Header notification dropdown */
.notif-menu { min-width: 320px; padding: 6px; }
.notif-menu .dropdown-header { padding: 8px 12px 6px; }
.notif-item { display: flex !important; align-items: center; gap: 12px; padding: 10px 12px !important; white-space: normal; }
.notif-icon {
  width: 34px; height: 34px; border-radius: var(--fx-radius-sm); flex: 0 0 auto;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--fx-surface-3); color: var(--fx-text-soft);
}
.notif-icon .material-icons { font-size: 18px !important; }
.notif-body { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.notif-body b { font-size: 13.5px; font-weight: 600; }
.notif-body small { font-size: 12px; color: var(--fx-text-mute); }
.notif-count {
  min-width: 24px; height: 22px; padding: 0 7px; display: inline-flex; align-items: center; justify-content: center;
  border-radius: 11px; font-size: 12px; font-weight: 600; font-variant-numeric: tabular-nums;
  background: var(--fx-surface-3); color: var(--fx-text-soft);
}
.notif-count.has { background: var(--fx-primary); color: #fff; }
.notif-empty { padding: 10px 12px; font-size: 13px; color: var(--fx-text-mute); }

/* ── 15. Dashboard ─────────────────────────────────────────────────────── */
.kpi-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin-bottom: 16px; }
.kpi-card {
  background: var(--fx-surface); border: 1px solid var(--fx-border); border-radius: var(--fx-radius);
  padding: 18px 20px; display: flex; align-items: flex-start; gap: 14px; min-width: 0;
}
.kpi-icon {
  width: 40px; height: 40px; border-radius: var(--fx-radius-sm); flex: 0 0 auto;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--fx-surface-3); color: var(--fx-text-soft);
}
.kpi-icon .material-icons { font-size: 20px !important; }
.kpi-body { min-width: 0; }
.kpi-value { font-size: var(--fx-fs-kpi); font-weight: 600; line-height: 1.1; color: var(--fx-text); font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.kpi-label { font-size: 13px; color: var(--fx-text-soft); margin-top: 4px; }
.kpi-sub   { font-size: 12.5px; color: var(--fx-text-mute); margin-top: 2px; font-variant-numeric: tabular-nums; }

/* Work that needs someone today. */
.attention-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0; }
.attention-item {
  display: flex; align-items: center; gap: 12px; padding: 14px 20px; text-decoration: none; color: inherit;
  border-right: 1px solid var(--fx-border-sf); transition: background var(--fx-ease);
}
.attention-item:last-child { border-right: 0; }
.attention-item:hover { background: var(--fx-surface-2); color: inherit; }
.attention-item .n { font-size: 24px; font-weight: 600; font-variant-numeric: tabular-nums; color: var(--fx-text); min-width: 2ch; line-height: 1; }
.attention-item .n.has { color: var(--fx-primary); }
.attention-item .t { font-size: 13px; font-weight: 600; color: var(--fx-text); }
.attention-item .d { font-size: 12px; color: var(--fx-text-mute); }
.attention-item .go { margin-left: auto; color: var(--fx-text-mute); font-size: 18px !important; }

.dash-card { height: 100%; }
/* Chart.js sizes to its parent; a responsive chart without a fixed-height
   parent grows on every resize pass. */
.chart-box { position: relative; height: 240px; width: 100%; }
.card-header-flex {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 20px; border-bottom: 1px solid var(--fx-border-sf);
}
.section-title { font-size: 15px; font-weight: 600; margin: 0; color: var(--fx-text); display: inline-flex; align-items: center; gap: 8px; }
.card-header-flex .btn-xs { --bs-btn-color: var(--fx-text-soft); }

.progress { height: 6px; border-radius: 3px; background: var(--fx-surface-3); }
.progress-bar { background: var(--fx-primary); border-radius: 3px; }
.ch-bar-label { display: flex; justify-content: space-between; font-size: 13px; color: var(--fx-text-soft); margin-bottom: 6px; }
.ch-bar-label .v { font-variant-numeric: tabular-nums; color: var(--fx-text); }

.fu-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.fu-box { text-align: center; padding: 12px 8px; border-radius: var(--fx-radius-sm); border: 1px solid var(--fx-border); background: var(--fx-surface-2); }
.fu-num { font-size: 22px; font-weight: 600; font-variant-numeric: tabular-nums; color: var(--fx-text); line-height: 1.1; }
.fu-box .l { font-size: 12px; color: var(--fx-text-mute); margin-top: 3px; }
.fu-box.is-pending .fu-num { color: var(--fx-warning-fg); }
.fu-box.is-sent .fu-num { color: var(--fx-success-fg); }

.metric-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 16px; border: 1px solid var(--fx-border); border-radius: var(--fx-radius-sm); background: var(--fx-surface-2); margin-bottom: 14px; }
.metric-row .k { font-size: 12.5px; color: var(--fx-text-soft); }
.metric-row .v { font-size: 26px; font-weight: 600; font-variant-numeric: tabular-nums; color: var(--fx-text); line-height: 1.1; }
.metric-row .s { font-size: 12px; color: var(--fx-text-mute); }

.intent-row { display: flex; align-items: center; justify-content: space-between; padding: 9px 0; border-bottom: 1px solid var(--fx-border-sf); font-size: 13.5px; color: var(--fx-text); }
.intent-row:last-child { border-bottom: 0; }
.today-appt-row { padding: 12px 20px; border-bottom: 1px solid var(--fx-border-sf); display: flex; align-items: center; gap: 12px; }
.today-appt-row:last-child { border-bottom: 0; }
.time-badge { background: var(--fx-surface-3); color: var(--fx-text-soft); font-size: 12px; font-weight: 600; padding: 3px 8px; border-radius: 6px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.row-title { font-weight: 600; font-size: 13.5px; color: var(--fx-text); }
.row-sub { font-size: 12.5px; color: var(--fx-text-mute); }

/* Legacy helpers still referenced by a few pages. */
.fx-stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; }
.fx-stat-card, .kx-stat { background: var(--fx-surface); border: 1px solid var(--fx-border); border-radius: var(--fx-radius); padding: 16px 18px; }
.fx-stat-card .stat-label { font-size: 12px; font-weight: 600; color: var(--fx-text-mute); }
.fx-stat-card .stat-value { font-size: 24px; font-weight: 600; color: var(--fx-text); line-height: 1.2; font-variant-numeric: tabular-nums; }

/* ── 16. Chat workspace ────────────────────────────────────────────────── */
/* The inbox at /chat/message_list/ (body.chat-page), the conversation modal
   opened from list pages, and the simulator share these tokens so a thread
   looks the same wherever it is read. Incoming messages are white; outgoing
   ones (AI or a colleague) take the brand tint; who spoke is said in words
   in the sender label, not by colour alone. */
:root, html.dark {
  --ch-bg:          var(--fx-bg);
  --ch-sidebar-bg:  var(--fx-surface);
  --ch-sidebar-br:  var(--fx-border);
  --ch-header-bg:   var(--fx-surface);
  --ch-header-br:   var(--fx-border);
  --ch-input-bg:    var(--fx-surface);
  --ch-input-br:    var(--fx-border);
  --ch-input-area:  var(--fx-surface);
  --ch-item-hover:  var(--fx-surface-2);
  --ch-item-active: var(--fx-tint);
  --ch-text:        var(--fx-text);
  --ch-text-sub:    var(--fx-text-soft);
  --ch-text-muted:  var(--fx-text-mute);
  --ch-msg-bg:      var(--fx-bg);
  --ch-bubble-in:   var(--fx-surface);
  --ch-bubble-in-c: var(--fx-text);
  --ch-bubble-out:  var(--fx-tint);
  --ch-bubble-out-bd: var(--fx-tint-bd);
  --ch-bubble-out-c: var(--fx-text);
  --ch-accent:      var(--fx-primary);
  --ch-accent-h:    var(--fx-primary-dk);
  --ch-shadow:      none;
  --ch-scroll:      rgba(100, 116, 139, .35);
}

/* One screen, two scroll regions. The wrapper is the viewport height so the
   composer is always on screen; min-height:0 on every ancestor of a scroll
   pane lets a flex item shrink below its content. main.css ships
   `.dark main { display:block }` (two selectors), so the element is named
   here as well to tie specificity. */
body.chat-page main.main-wrap, html.dark body.chat-page main.main-wrap {
  padding: 0; display: flex; flex-direction: column;
  height: 100vh; height: 100dvh; min-height: 480px; overflow: hidden; background: var(--ch-bg);
}
.chat-container { display: flex; flex: 1 1 auto; min-height: 0; background: var(--ch-bg); }

.contact-sidebar { width: 340px; flex: 0 0 340px; background: var(--ch-sidebar-bg); border-right: 1px solid var(--ch-sidebar-br); display: flex; flex-direction: column; min-height: 0; }
.contact-header { padding: 16px 16px 12px; border-bottom: 1px solid var(--ch-sidebar-br); }
.contact-header h4 { color: var(--ch-text); font-size: 17px; font-weight: 600; margin: 0 0 10px; }
.contact-search {
  width: 100%; height: 38px; padding: 0 12px 0 34px;
  background: var(--ch-input-bg); border: 1px solid var(--ch-input-br); border-radius: var(--fx-radius-sm);
  font-size: 13.5px; color: var(--ch-text); outline: none; transition: border-color var(--fx-ease), box-shadow var(--fx-ease);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2364748B' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='M20 20l-3.9-3.9'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: 11px center; background-size: 15px;
}
.contact-search::placeholder { color: var(--ch-text-muted); }
.contact-search:focus { border-color: var(--ch-accent); box-shadow: var(--fx-ring); }
.contact-list { flex: 1 1 auto; min-height: 0; overflow-y: auto; padding: 6px 8px; }

/* An initial on a disc. The hue is derived from the name by the page's JS
   so a person keeps their colour; saturation is held low here. */
.avatar {
  flex: 0 0 auto; width: 40px; height: 40px; border-radius: 50%;
  display: grid; place-items: center; font-weight: 600; font-size: 14px; color: #fff; user-select: none;
}
.avatar.lg { width: 42px; height: 42px; font-size: 15px; }

.contact-item {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: var(--fx-radius-sm);
  cursor: pointer; position: relative; transition: background var(--fx-ease); min-height: 60px;
}
.contact-item + .contact-item { margin-top: 2px; }
.contact-item:hover  { background: var(--ch-item-hover); }
.contact-item.active { background: var(--ch-item-active); }
.contact-item.active::before {
  content: ""; position: absolute; left: 0; top: 50%; transform: translateY(-50%);
  width: 3px; height: 28px; border-radius: 0 3px 3px 0; background: var(--fx-accent);
}
.contact-body { flex: 1 1 auto; min-width: 0; }
.contact-top { display: flex; align-items: baseline; gap: 8px; }
.contact-name { flex: 1 1 auto; min-width: 0; font-weight: 600; font-size: 14px; color: var(--ch-text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.contact-phone { font-size: 12px; color: var(--ch-text-sub); margin-top: 1px; font-variant-numeric: tabular-nums; }
.contact-last-msg { font-size: 12.5px; color: var(--ch-text-muted); margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.contact-time { flex: 0 0 auto; font-size: 11.5px; color: var(--ch-text-muted); white-space: nowrap; font-variant-numeric: tabular-nums; }

.chat-area { flex: 1 1 auto; min-width: 0; min-height: 0; display: flex; flex-direction: column; background: var(--ch-bg); position: relative; }
.chat-back {
  display: none; position: absolute; top: 12px; left: 12px; z-index: 6;
  width: 40px; height: 40px; align-items: center; justify-content: center; padding: 0;
  border-radius: var(--fx-radius-sm); border: 1px solid var(--ch-header-br); background: var(--ch-header-bg); color: var(--ch-text); cursor: pointer;
}
.chat-header { flex: 0 0 auto; display: flex; align-items: center; gap: 12px; padding: 12px 20px; min-height: 64px; border-bottom: 1px solid var(--ch-header-br); background: var(--ch-header-bg); }
.chat-header-text { min-width: 0; }
.chat-header h5 { margin: 0; font-size: 15px; font-weight: 600; color: var(--ch-text); }
.chat-header p { margin: 2px 0 0; font-size: 12.5px; color: var(--ch-text-sub); font-variant-numeric: tabular-nums; }

.messages-area { flex: 1 1 auto; min-height: 0; padding: 20px 24px; overflow-y: auto; overscroll-behavior: contain; background: var(--ch-msg-bg); }
.message-row { display: flex; margin-bottom: 10px; }
.message-row.left  { justify-content: flex-start; }
.message-row.right { justify-content: flex-end; }
.message-bubble {
  max-width: min(62ch, 72%); padding: 10px 14px; border-radius: 12px;
  border: 1px solid var(--fx-border); word-wrap: break-word; overflow-wrap: anywhere;
}
.message-bubble.contact { background: var(--ch-bubble-in); color: var(--ch-bubble-in-c); border-bottom-left-radius: 4px; }
.message-bubble.ai, .message-bubble.human {
  background: var(--ch-bubble-out); color: var(--ch-bubble-out-c); border-color: var(--ch-bubble-out-bd); border-bottom-right-radius: 4px;
}
.message-bubble.system { background: var(--fx-surface-2); color: var(--fx-text-soft); border-style: dashed; border-bottom-right-radius: 4px; }
.sender-label { font-size: 11px; font-weight: 600; letter-spacing: .02em; text-transform: uppercase; margin-bottom: 4px; color: var(--fx-text-soft); display: flex; align-items: center; gap: 5px; }
.message-bubble.human .sender-label { color: var(--fx-success-fg); }
.message-content { font-size: 14px; line-height: 1.55; white-space: pre-wrap; }
.message-time { font-size: 11px; margin-top: 4px; text-align: right; color: var(--fx-text-mute); font-variant-numeric: tabular-nums; }

/* Day divider. Each day's messages sit in their own .message-day-group;
   the hairline stays where the day begins, while the pill is sticky inside
   its group — it rides at the top of the thread while that day scrolls by
   and is pushed out by the next day's pill, as on the phone. */
.message-day-group + .message-day-group { margin-top: 8px; }
.message-day-rule { height: 1px; margin: 20px 0 0; background: var(--fx-border); opacity: .9; }
.message-day {
  position: sticky; top: 4px; z-index: 2;
  display: flex; justify-content: center;
  margin: -13px 0 14px; pointer-events: none;
}
.message-day span {
  padding: 4px 12px; border-radius: 999px;
  font-size: 11.5px; font-weight: 600; letter-spacing: .02em; text-transform: uppercase;
  color: var(--fx-text-soft); background: var(--fx-surface); border: 1px solid var(--fx-border);
  box-shadow: 0 1px 2px rgba(0, 0, 0, .06);
}
html.dark .message-day span { box-shadow: 0 1px 3px rgba(0, 0, 0, .45); }
.message-bubble img { max-width: 220px; max-height: 220px; border-radius: 8px; display: block; margin-bottom: 6px; object-fit: cover; }
.message-bubble audio, .message-bubble video { max-width: 240px; display: block; margin-bottom: 6px; }
.message-bubble video { border-radius: 8px; }

.chat-teach-btn, .sim-teach {
  margin-top: 6px; font-size: 12px; font-weight: 600; padding: 3px 9px;
  border: 1px solid var(--fx-border); border-radius: 6px; background: var(--fx-surface); color: var(--fx-text-soft);
  cursor: pointer; display: inline-flex; align-items: center; gap: 4px; transition: background var(--fx-ease), color var(--fx-ease);
}
.chat-teach-btn .material-icons, .sim-teach .material-icons { font-size: 14px !important; }
.chat-teach-btn:hover, .sim-teach:hover { background: var(--fx-primary); color: #fff; border-color: var(--fx-primary); }

.message-input-area { flex: 0 0 auto; padding: 12px 20px; background: var(--ch-input-area); border-top: 1px solid var(--ch-header-br); }
.message-input-wrapper { display: flex; gap: 10px; align-items: center; }
.message-input {
  flex: 1; height: 44px; padding: 0 14px; background: var(--ch-input-bg); border: 1px solid var(--ch-input-br);
  border-radius: var(--fx-radius-sm); font-size: 14px; color: var(--ch-text); outline: none; min-width: 0;
  transition: border-color var(--fx-ease), box-shadow var(--fx-ease);
}
.message-input::placeholder { color: var(--ch-text-muted); }
.message-input:focus { border-color: var(--ch-accent); box-shadow: var(--fx-ring); }
.btn-send {
  height: 44px; padding: 0 20px; background: var(--ch-accent); color: #fff; border: none; border-radius: var(--fx-radius-sm);
  cursor: pointer; font-weight: 600; font-size: 14px; transition: background var(--fx-ease); flex: 0 0 auto;
}
.btn-send:hover { background: var(--ch-accent-h); }
.btn-send:disabled { background: var(--fx-surface-3); color: var(--fx-text-mute); cursor: not-allowed; }
.btn-send:focus-visible, .message-input:focus-visible, .contact-item:focus-visible { outline: none; box-shadow: var(--fx-ring); }

.chat-area .empty-state { display: flex; flex-direction: column; align-items: center; justify-content: center; height: 100%; gap: 8px; color: var(--ch-text-muted); font-size: 14px; }
.chat-area .empty-state i { font-size: 40px !important; opacity: .5; }
.typing-bubble { display: inline-flex; align-items: center; gap: 5px; padding: 13px 16px; border-radius: 12px; background: var(--ch-bubble-out); border: 1px solid var(--ch-bubble-out-bd); }
.typing-bubble span { width: 7px; height: 7px; border-radius: 50%; background: var(--fx-primary); opacity: .45; animation: typing-dot 1.2s infinite ease-in-out; }
.typing-bubble span:nth-child(2) { animation-delay: .18s; }
.typing-bubble span:nth-child(3) { animation-delay: .36s; }
@keyframes typing-dot { 0%, 60%, 100% { opacity: .35; transform: translateY(0); } 30% { opacity: 1; transform: translateY(-3px); } }
.contact-list, .messages-area, .chat-thread, .sim-thread { scrollbar-width: thin; scrollbar-color: var(--ch-scroll) transparent; }
.contact-list::-webkit-scrollbar, .messages-area::-webkit-scrollbar { width: 8px; }
.contact-list::-webkit-scrollbar-thumb, .messages-area::-webkit-scrollbar-thumb { background: var(--ch-scroll); border-radius: 8px; border: 2px solid transparent; background-clip: content-box; }

/* Phones: one pane at a time; the thread slides over the list. */
@media (max-width: 767.98px) {
  .chat-container { position: relative; overflow: hidden; }
  .contact-sidebar { width: 100%; flex: 1 1 100%; border-right: 0; }
  .chat-area { position: absolute; inset: 0; z-index: 5; transform: translateX(100%); transition: transform .2s ease-in-out; background: var(--ch-bg); }
  .chat-container.show-thread .chat-area { transform: translateX(0); }
  .chat-back { display: inline-flex; }
  .chat-header { padding-left: 62px; padding-right: 14px; }
  .contact-header { padding: 12px 14px; }
  .messages-area { padding: 14px; }
  .message-bubble { max-width: 86%; }
  .message-input-area { padding: 10px 12px; }
}

/* Conversation modal (partials/chat_modal.html) */
.chat-modal .modal-dialog { max-width: 720px; }
.chat-thread { height: 60vh; max-height: 560px; overflow-y: auto; padding: 18px; background: var(--fx-bg); display: flex; flex-direction: column; gap: 8px; }
.chat-reply { padding: 12px 14px; }
.chat-reply .form-control { flex: 1 1 auto; }
.chat-reply .btn { flex: 0 0 auto; }
.chat-row { display: flex; width: 100%; }
.chat-row.left  { justify-content: flex-start; }
.chat-row.right { justify-content: flex-end; }
.chat-bubble {
  max-width: 76%; padding: 8px 12px; border-radius: 10px; font-size: 14px; line-height: 1.45;
  word-wrap: break-word; overflow-wrap: anywhere; white-space: pre-wrap; position: relative; border: 1px solid var(--fx-border);
}
.chat-row.left .chat-bubble  { background: var(--ch-bubble-in); color: var(--ch-bubble-in-c); border-bottom-left-radius: 4px; }
.chat-row.right .chat-bubble { background: var(--ch-bubble-out); color: var(--ch-bubble-out-c); border-color: var(--ch-bubble-out-bd); border-bottom-right-radius: 4px; }
.chat-row.right .chat-bubble.system { background: var(--fx-surface-2); color: var(--fx-text-soft); border-style: dashed; border-color: var(--fx-border); }
.chat-sender { font-size: 11px; font-weight: 600; color: var(--fx-text-soft); margin-bottom: 2px; text-transform: uppercase; letter-spacing: .02em; }
.chat-bubble.human .chat-sender { color: var(--fx-success-fg); }
.chat-time   { font-size: 11px; color: var(--fx-text-mute); text-align: right; margin-top: 3px; }
.chat-empty, .chat-loading { text-align: center; color: var(--fx-text-mute); padding: 40px 0; font-size: 13.5px; }
.chat-bubble img { max-width: 220px; max-height: 220px; border-radius: 8px; display: block; margin-bottom: 6px; object-fit: cover; }

/* Teach panel */
.teach-card { padding: 20px 22px; width: 100%; max-width: 480px; max-height: 90vh; overflow-y: auto; }
.teach-card h6 { font-weight: 600; margin-bottom: 4px; display: flex; align-items: center; gap: 8px; }
.teach-card h6 .material-icons { font-size: 20px !important; color: var(--fx-primary); }
.teach-card label { font-size: 12.5px; font-weight: 600; margin: 12px 0 4px; display: block; color: var(--fx-text); }
.teach-card .teach-q { background: var(--fx-surface-2); border: 1px solid var(--fx-border-sf); border-radius: var(--fx-radius-sm); padding: 8px 12px; font-size: 13px; color: var(--fx-text-soft); white-space: pre-wrap; }
.teach-status { font-size: 12.5px; margin-top: 8px; }

/* Simulator (a WhatsApp thread rehearsed in the dashboard's own clothes) */
.sim-wrap { max-width: 820px; }
.sim-phone { border: 1px solid var(--fx-border); border-radius: var(--fx-radius); overflow: hidden; background: var(--fx-surface); }
.sim-head { background: var(--fx-surface); color: var(--fx-text); padding: 12px 16px; display: flex; align-items: center; gap: 12px; border-bottom: 1px solid var(--fx-border); }
.sim-head .avatar { width: 38px; height: 38px; border-radius: 50%; background: var(--fx-tint); color: var(--fx-brand-fg); display: flex; align-items: center; justify-content: center; }
.sim-head .avatar .material-icons { font-size: 20px !important; }
.sim-head .meta b { display: block; font-size: 14px; font-weight: 600; }
.sim-head .meta span { font-size: 12px; color: var(--fx-text-mute); }
.sim-head .reset { margin-left: auto; }
.sim-thread { height: 60vh; overflow-y: auto; padding: 18px; background: var(--fx-bg); display: flex; flex-direction: column; gap: 8px; }
.sim-row { display: flex; }
.sim-row.right { justify-content: flex-end; }
.sim-row.left  { justify-content: flex-start; }
.sim-bubble { max-width: 78%; padding: 8px 12px; border-radius: 10px; font-size: 14px; line-height: 1.45; white-space: pre-wrap; word-wrap: break-word; position: relative; border: 1px solid var(--fx-border); }
.sim-row.right .sim-bubble { background: var(--ch-bubble-out); color: var(--ch-bubble-out-c); border-color: var(--ch-bubble-out-bd); border-top-right-radius: 2px; }
.sim-row.left .sim-bubble { background: var(--fx-surface); color: var(--fx-text); border-top-left-radius: 2px; }
.sim-sender { font-size: 11px; font-weight: 600; color: var(--fx-text-soft); margin-bottom: 2px; text-transform: uppercase; letter-spacing: .02em; }
.sim-time { font-size: 11px; color: var(--fx-text-mute); text-align: right; margin-top: 3px; }
.sim-typing .sim-bubble { display: inline-flex; align-items: center; gap: 5px; padding: 12px 16px; }
.sim-typing i { width: 7px; height: 7px; border-radius: 50%; background: var(--fx-text-mute); display: inline-block; animation: sim-blink 1.2s infinite ease-in-out; }
.sim-typing i:nth-child(2) { animation-delay: .18s; }
.sim-typing i:nth-child(3) { animation-delay: .36s; }
@keyframes sim-blink { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }
.sim-hint { margin: 10px auto; max-width: 440px; text-align: center; font-size: 12.5px; line-height: 1.5; color: var(--fx-text-soft); background: var(--fx-surface-2); border: 1px solid var(--fx-border-sf); border-radius: var(--fx-radius-sm); padding: 8px 12px; }
.sim-input { display: flex; gap: 10px; padding: 12px 16px; background: var(--fx-surface); border-top: 1px solid var(--fx-border); }
.sim-input input { flex: 1; height: 42px; border: 1px solid var(--fx-border); border-radius: var(--fx-radius-sm); padding: 0 14px; font-size: 14px; outline: none; background: var(--fx-surface); color: var(--fx-text); min-width: 0; }
.sim-input input:focus { border-color: var(--fx-primary); box-shadow: var(--fx-ring); }
.sim-input button { background: var(--fx-primary); color: #fff; border: none; border-radius: var(--fx-radius-sm); padding: 0 20px; height: 42px; font-weight: 600; cursor: pointer; }
.sim-input button:hover { background: var(--fx-primary-dk); }
.sim-input button:disabled { opacity: .5; cursor: not-allowed; }
.sim-note { font-size: 12.5px; color: var(--fx-text-mute); margin: 8px 2px 0; }

/* ── 17. Knowledge pages ───────────────────────────────────────────────── */
/* Explorer chunks: each vector gets a number and a colour from the
   categorical palette, carried as a 3px left rule and a small tag — enough
   to see where one stops and the next begins without painting the page. */
.kx-c-indigo { --kx: var(--fx-cat-3); }
.kx-c-teal   { --kx: var(--fx-cat-2); }
.kx-c-amber  { --kx: var(--fx-cat-5); }
.kx-c-rose   { --kx: var(--fx-cat-6); }
.kx-c-sky    { --kx: var(--fx-cat-3); }
.kx-c-violet { --kx: var(--fx-cat-4); }
.kx-c-lime   { --kx: var(--fx-cat-7); }
.kx-c-orange { --kx: var(--fx-cat-1); }
.kx-top { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin-bottom: 18px; }
.kx-stat .v { font-size: 22px; font-weight: 600; line-height: 1.1; color: var(--fx-text); font-variant-numeric: tabular-nums; }
.kx-stat .v.warn { color: var(--fx-warning-fg); }
.kx-stat .v.bad { color: var(--fx-danger-fg); }
.kx-stat .k { font-size: 12px; font-weight: 500; color: var(--fx-text-mute); margin-top: 3px; }
.kx-tab .dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--fx-warning); margin-left: 4px; vertical-align: middle; }
.kx-chunk { border: 1px solid var(--fx-border); border-left: 3px solid var(--kx); border-radius: var(--fx-radius); background: var(--fx-surface); margin-bottom: 14px; overflow: hidden; }
.kx-head { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; padding: 12px 16px; background: var(--fx-surface-2); border-bottom: 1px solid var(--fx-border-sf); }
.kx-badge { font-size: 11.5px; font-weight: 600; color: var(--kx); background: var(--fx-surface); border: 1px solid var(--kx); border-radius: 999px; padding: 2px 9px; font-variant-numeric: tabular-nums; }
.kx-title { font-weight: 600; font-size: 14.5px; color: var(--fx-text); flex: 1; min-width: 0; }
.kx-meta { font-size: 12px; color: var(--fx-text-mute); white-space: nowrap; }
.kx-body { padding: 14px 18px 16px; }
.kx-body h4 { font-size: 14px; font-weight: 600; margin: 14px 0 6px; color: var(--fx-text); }
.kx-body h4:first-child { margin-top: 0; }
.kx-body h5 { font-size: 13px; font-weight: 600; margin: 12px 0 5px; color: var(--fx-text-soft); }
.kx-body p { font-size: 13.5px; line-height: 1.65; margin: 0 0 8px; color: var(--fx-text); }
.kx-point { display: flex; gap: 9px; font-size: 13.5px; line-height: 1.6; margin-bottom: 5px; color: var(--fx-text); }
.kx-point .b { color: var(--kx); font-weight: 600; flex: 0 0 auto; }
.kx-pair { display: flex; gap: 10px; font-size: 13.5px; margin-bottom: 5px; }
.kx-pair .k { font-weight: 600; color: var(--fx-text-soft); flex: 0 0 34%; }
.kx-pair .v { color: var(--fx-text); }
.kx-table { width: 100%; border-collapse: collapse; margin: 8px 0 10px; font-size: 13px; }
.kx-table td { border: 1px solid var(--fx-border-sf); padding: 6px 10px; color: var(--fx-text); }
.kx-table tr:first-child td { background: var(--fx-surface-2); font-weight: 600; }
.kx-issues { padding: 10px 16px; background: var(--fx-surface-2); border-top: 1px solid var(--fx-border-sf); }
.kx-issue { display: flex; gap: 9px; font-size: 12.5px; margin-bottom: 5px; color: var(--fx-text-soft); }
.kx-issue:last-child { margin-bottom: 0; }
.kx-issue .lab, .lab-bad, .lab-warn, .lab-info { font-weight: 600; font-size: 11px; border-radius: 4px; padding: 1px 7px; flex: 0 0 auto; border: 1px solid transparent; }
.lab-bad  { background: var(--fx-danger-bg);  color: var(--fx-danger-fg);  border-color: var(--fx-danger-bd); }
.lab-warn { background: var(--fx-warning-bg); color: var(--fx-warning-fg); border-color: var(--fx-warning-bd); }
.lab-info { background: var(--fx-info-bg);    color: var(--fx-info-fg);    border-color: var(--fx-info-bd); }
.kx-gap { display: flex; flex-wrap: wrap; gap: 10px; align-items: baseline; padding: 10px 14px; border: 1px solid var(--fx-border); border-radius: var(--fx-radius-sm); margin-bottom: 8px; background: var(--fx-surface); }
.kx-gap.bad  { border-left: 3px solid var(--fx-danger); }
.kx-gap.warn { border-left: 3px solid var(--fx-warning); }
.kx-gap .name { font-weight: 600; font-size: 14px; flex: 0 0 200px; color: var(--fx-text); }
.kx-gap .facts { font-size: 12px; color: var(--fx-text-mute); flex: 0 0 auto; }
.kx-gap .why { font-size: 12.5px; color: var(--fx-text-soft); flex: 1 1 260px; }
.kx-split { font-size: 12.5px; color: var(--fx-text-soft); padding: 7px 0; border-bottom: 1px solid var(--fx-border-sf); }
.kx-split:last-child { border-bottom: 0; }
.kx-split b { color: var(--fx-text); font-weight: 600; }

/* Knowledge Base list */
.kb-toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 14px; }
.kb-toolbar .kb-search { position: relative; flex: 1 1 260px; max-width: 380px; }
.kb-toolbar .kb-search input { padding-right: 30px; }
.kb-toolbar .kb-search .kb-spinner {
  position: absolute; right: 10px; top: 50%; transform: translateY(-50%);
  width: 14px; height: 14px; border: 2px solid var(--fx-border); border-top-color: var(--fx-primary);
  border-radius: 50%; animation: kb-spin .7s linear infinite; display: none;
}
.kb-toolbar .kb-search.searching .kb-spinner { display: block; }
@keyframes kb-spin { to { transform: translateY(-50%) rotate(360deg); } }
.kb-toolbar .form-select { width: auto; flex: 0 0 auto; }
.kb-result-note { font-size: 13px; color: var(--fx-text-soft); white-space: nowrap; }
.kb-clear { font-size: 13px; white-space: nowrap; }
td .js-kb-view { color: inherit; text-decoration: none; }
td a.js-kb-view.fw-bold:hover { color: var(--fx-primary); }
.kb-view-card { width: min(720px, 100%); max-height: 86vh; display: flex; flex-direction: column; }
.kb-view-head { display: flex; justify-content: space-between; gap: 12px; padding: 16px 20px 10px; }
.kb-view-head h5 { font-weight: 600; margin: 0; font-size: 16px; }
.kb-view-meta { padding: 0 20px 10px; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.kb-view-meta .small { color: var(--fx-text-mute); }
.kb-view-body, .skb-entry .text, .imp-content, .cmp-col .text, .cp-sample {
  background: var(--fx-surface-2); border: 1px solid var(--fx-border-sf); border-radius: var(--fx-radius-sm);
  font-size: 13.5px; line-height: 1.55; color: var(--fx-text);
}
.kb-view-body { margin: 0 20px 14px; padding: 14px; overflow-y: auto; white-space: pre-wrap; }
.kb-view-foot { display: flex; gap: 8px; padding: 0 20px 18px; }

/* Services → knowledge modal */
.svc-kb-btn {
  display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 12px; border-radius: var(--fx-radius-sm);
  font-size: 12.5px; font-weight: 600; border: 1px solid var(--fx-border); background: var(--fx-surface); color: var(--fx-text-soft);
  cursor: pointer; transition: background var(--fx-ease), color var(--fx-ease), border-color var(--fx-ease); white-space: nowrap;
}
.svc-kb-btn .material-icons { font-size: 16px !important; }
.svc-kb-btn:hover { background: var(--fx-surface-3); color: var(--fx-text); }
.svc-kb-btn .n { background: var(--fx-tint); color: var(--fx-brand-fg); border-radius: 999px; padding: 0 7px; font-size: 11.5px; line-height: 18px; font-variant-numeric: tabular-nums; }
.svc-kb-btn.empty .n { background: var(--fx-surface-3); color: var(--fx-text-mute); }
.svc-contact { font-size: 12.5px; line-height: 1.5; white-space: nowrap; }
.svc-contact span { color: var(--fx-text-mute); }
.skb-card { width: min(760px, 100%); max-height: 88vh; display: flex; flex-direction: column; }
.skb-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 16px 20px 10px; }
.skb-head h5 { font-weight: 600; margin: 0; font-size: 16px; }
.skb-body { padding: 0 20px; overflow-y: auto; }
.skb-entry { border: 1px solid var(--fx-border); border-radius: var(--fx-radius-sm); padding: 12px 14px; margin-bottom: 10px; }
.skb-entry .skb-title { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; font-weight: 600; font-size: 13.5px; }
.skb-entry .text { margin-top: 8px; padding: 10px 12px; font-size: 13px; color: var(--fx-text-soft); white-space: pre-wrap; max-height: 96px; overflow: hidden; position: relative; cursor: pointer; }
.skb-entry .text.open { max-height: none; }
.skb-entry .text:not(.open)::after, .imp-content:not(.open)::after {
  position: absolute; bottom: 0; left: 0; right: 0; text-align: center; font-size: 11px; padding: 12px 0 3px; color: var(--fx-text-mute);
  background: linear-gradient(transparent, var(--fx-surface-2) 70%);
}
.skb-entry .text:not(.open)::after { content: "▼ আরো"; }
.skb-empty { text-align: center; padding: 34px 16px; color: var(--fx-text-mute); font-size: 13.5px; }
.skb-foot { display: flex; gap: 8px; padding: 12px 20px 18px; flex-wrap: wrap; }

/* Upload */
.kb-drop { border: 2px dashed var(--fx-border); border-radius: var(--fx-radius); padding: 40px 24px; text-align: center; cursor: pointer; transition: border-color var(--fx-ease), background var(--fx-ease); background: var(--fx-surface-2); }
.kb-drop:hover, .kb-drop.dragover { border-color: var(--fx-primary); background: var(--fx-tint); }
.kb-drop .kb-drop-icon { margin-bottom: 6px; color: var(--fx-text-mute); }
.kb-drop .kb-drop-icon .material-icons { font-size: 36px !important; }
.kb-drop h6 { font-weight: 600; margin-bottom: 4px; }
.kb-drop p { font-size: 13px; color: var(--fx-text-soft); margin: 0; }
.kb-drop input[type=file] { display: none; }
.kb-file-chip { display: none; margin-top: 14px; padding: 6px 14px; border-radius: 999px; background: var(--fx-tint); color: var(--fx-brand-fg); border: 1px solid var(--fx-tint-bd); font-size: 13px; font-weight: 600; }
.kb-file-chip.show { display: inline-block; }
.kb-upload-note { font-size: 13px; color: var(--fx-text-soft); }
.kb-upload-note li { margin-bottom: 3px; }

/* Recheck report */
.aud-summary { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 18px; align-items: center; }
.aud-history { font-size: 13px; margin-left: auto; }
.aud-section h5 { font-weight: 600; font-size: 15px; margin: 22px 0 10px; }
.aud-item { border: 1px solid var(--fx-border); border-left-width: 3px; border-radius: var(--fx-radius-sm); padding: 12px 14px; margin-bottom: 10px; background: var(--fx-surface); font-size: 13.5px; transition: opacity var(--fx-ease); }
.aud-item.dup  { border-left-color: var(--fx-danger); }
.aud-item.conf { border-left-color: var(--fx-danger); background: var(--fx-danger-bg); }
.aud-item.junk { border-left-color: var(--fx-warning); }
.aud-item.sugg { border-left-color: var(--fx-info); }
.aud-item.resolved { opacity: .5; }
.aud-item.resolved .aud-main { text-decoration: line-through; }
.aud-item .note { color: var(--fx-text-soft); font-size: 12.5px; margin-top: 4px; }
.aud-item a { font-weight: 600; }
.aud-score { font-size: 12px; color: var(--fx-text-mute); }
.aud-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; align-items: center; }
.aud-actions .btn { padding: 3px 10px !important; font-size: 12px !important; }
.aud-done { font-size: 12px; margin-left: auto; display: flex; align-items: center; gap: 5px; color: var(--fx-text-mute); }
.aud-clean { text-align: center; padding: 48px 20px; border: 1px solid var(--fx-success-bd); background: var(--fx-success-bg); color: var(--fx-success-fg); border-radius: var(--fx-radius); margin-top: 16px; }
.aud-clean .big .material-icons { font-size: 40px !important; }
.cmp-card { width: min(1100px, 100%); max-height: 88vh; display: flex; flex-direction: column; }
.cmp-head { display: flex; justify-content: space-between; padding: 14px 18px 8px; }
.cmp-head h6 { font-weight: 600; margin: 0; }
.cmp-body { display: flex; gap: 12px; padding: 0 18px 16px; overflow: auto; }
.cmp-col { flex: 1 1 0; min-width: 0; }
.cmp-col h6 { font-size: 13.5px; font-weight: 600; margin-bottom: 6px; }
.cmp-col .badges { margin-bottom: 6px; display: flex; gap: 4px; flex-wrap: wrap; }
.cmp-col .text { padding: 10px 12px; font-size: 13px; white-space: pre-wrap; max-height: 56vh; overflow-y: auto; }
.cmp-col .btn { margin-top: 8px; }

/* Import review */
.imp-summary { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.imp-chunk { border: 1px solid var(--fx-border); border-radius: var(--fx-radius-sm); padding: 14px 16px; margin-bottom: 12px; transition: opacity var(--fx-ease); background: var(--fx-surface); }
.imp-chunk.excluded { opacity: .5; }
.imp-chunk.is-junk { border-left: 3px solid var(--fx-warning); }
.imp-chunk.is-dup  { border-left: 3px solid var(--fx-danger); }
.imp-head { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 8px; }
.imp-head .form-check-input { transform: scale(1.2); margin-right: 2px; }
.imp-head input[type=text] { flex: 1 1 280px; font-weight: 600; }
.imp-head .form-select { width: auto; }
.imp-flags { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; font-size: 12px; }
.imp-content { font-size: 13px; color: var(--fx-text-soft); white-space: pre-wrap; max-height: 110px; overflow: hidden; position: relative; cursor: pointer; padding: 10px 12px; }
.imp-content.open { max-height: none; }
.imp-content:not(.open)::after { content: "▼ পুরোটা দেখতে click করুন"; }
.imp-actions { position: sticky; bottom: 0; background: var(--fx-surface); padding: 12px 0; display: flex; gap: 10px; align-items: center; border-top: 1px solid var(--fx-border-sf); }
.imp-count { font-size: 13px; color: var(--fx-text-soft); }

/* Cloud pricing */
.cp-example { overflow: hidden; }
.cp-example > summary { list-style: none; cursor: pointer; user-select: none; display: block; }
.cp-example > summary::-webkit-details-marker { display: none; }
.cp-example > summary:focus-visible { outline: none; box-shadow: var(--fx-ring); }
.cp-example .cp-example-caret { font-size: 20px !important; color: var(--fx-text-mute); transition: transform var(--fx-ease); }
.cp-example[open] .cp-example-caret { transform: rotate(90deg); }
.cp-example:not([open]) > summary { border-bottom: 0; }
.cp-example .cp-sample { max-width: 560px; }
.cp-rate { font-weight: 600; white-space: nowrap; font-variant-numeric: tabular-nums; }
.cp-sample { padding: 14px 16px; font-size: 13px; line-height: 1.7; }
.cp-sample .tot { font-weight: 600; border-top: 1px dashed var(--fx-border); margin-top: 8px; padding-top: 8px; }
.cp-req { font-size: 11.5px; font-weight: 600; }

/* Site visits */
.visit-date { font-weight: 600; }
.visit-upcoming { color: var(--fx-success-fg); }
.visit-past { color: var(--fx-text-mute); }

/* Inquiry inline editing */
.editable-name { cursor: pointer; padding: 2px 6px; border-radius: 6px; transition: background var(--fx-ease); }
.editable-name:hover { background: var(--fx-tint); }
.editable-name .material-icons { opacity: 0; transition: opacity var(--fx-ease); font-size: 14px !important; vertical-align: middle; color: var(--fx-text-mute); margin-left: 4px; }
.editable-name:hover .material-icons { opacity: 1; }
.edit-name-input { border: 1px solid var(--fx-primary); box-shadow: var(--fx-ring); border-radius: 6px; padding: 2px 8px; font-weight: 600; font-size: inherit; outline: none; width: 100%; min-width: 140px; background: var(--fx-surface); color: var(--fx-text); }

/* Permission grid (role form) */
.pm-table { width: 100%; border-collapse: collapse; }
.pm-table thead th { position: sticky; top: 0; z-index: 2; background: var(--fx-surface-2); color: var(--fx-text-soft); font-size: 12px; font-weight: 600; padding: 11px 12px; border-bottom: 1px solid var(--fx-border); }
.pm-table thead th.v { text-align: center; width: 84px; }
.pm-table td { padding: 9px 12px; border-bottom: 1px solid var(--fx-border-sf); }
.pm-table td.v { text-align: center; }
.pm-table tbody tr:hover { background: var(--fx-surface-2); }
.pm-mod { font-weight: 600; font-size: 13.5px; color: var(--fx-text); }
.pm-hint { font-size: 12px; color: var(--fx-text-mute); }
.pm-table input[type=checkbox] { width: 17px; height: 17px; accent-color: var(--fx-primary); cursor: pointer; }
.pm-legend { display: flex; flex-wrap: wrap; gap: 16px; font-size: 12.5px; color: var(--fx-text-soft); margin-bottom: 12px; }
.pm-legend b { color: var(--fx-text); font-weight: 600; }
.pm-bulk { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }

/* Role cards */
.rl-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 14px; }
.rl-card { background: var(--fx-surface); border: 1px solid var(--fx-border); border-radius: var(--fx-radius); padding: 16px 18px; display: flex; flex-direction: column; gap: 10px; }
.rl-top { display: flex; align-items: flex-start; gap: 10px; }
.rl-name { font-size: 15.5px; font-weight: 600; color: var(--fx-text); flex: 1; }
.rl-desc { font-size: 13px; color: var(--fx-text-soft); margin: -4px 0 0; }
.rl-members { font-size: 12px; font-weight: 600; color: var(--fx-brand-fg); background: var(--fx-tint); border-radius: 999px; padding: 3px 10px; white-space: nowrap; }
.rl-none { font-size: 13px; color: var(--fx-text-mute); font-style: italic; }
.rl-foot { display: flex; gap: 8px; margin-top: auto; padding-top: 8px; border-top: 1px solid var(--fx-border-sf); }
.rl-sys { font-size: 11px; font-weight: 600; background: var(--fx-surface-3); color: var(--fx-text-mute); border-radius: 5px; padding: 2px 7px; }

/* Team */
.tm-chip { display: inline-block; font-size: 12px; font-weight: 500; background: var(--fx-surface-2); border: 1px solid var(--fx-border-sf); color: var(--fx-text-soft); border-radius: 6px; padding: 2px 8px; margin: 2px 3px 2px 0; }
.tm-avatar { width: 34px; height: 34px; border-radius: 50%; flex: 0 0 auto; display: grid; place-items: center; font-weight: 600; font-size: 13px; background: var(--fx-tint); color: var(--fx-brand-fg); }
.tm-person { display: flex; align-items: center; gap: 11px; }
.tm-person .nm { font-weight: 600; color: var(--fx-text); }
.tm-person .un { font-size: 12px; color: var(--fx-text-mute); }

/* Activity log */
.al-act { font-size: 11.5px; font-weight: 600; border-radius: 999px; padding: 3px 9px; white-space: nowrap; border: 1px solid transparent; }
.al-create { background: var(--fx-success-bg); color: var(--fx-success-fg); border-color: var(--fx-success-bd); }
.al-update { background: var(--fx-info-bg);    color: var(--fx-info-fg);    border-color: var(--fx-info-bd); }
.al-delete { background: var(--fx-danger-bg);  color: var(--fx-danger-fg);  border-color: var(--fx-danger-bd); }
.al-login, .al-logout, .al-other { background: var(--fx-neutral-bg); color: var(--fx-neutral-fg); border-color: var(--fx-neutral-bd); }
.al-login_failed { background: var(--fx-warning-bg); color: var(--fx-warning-fg); border-color: var(--fx-warning-bd); }
.al-who { font-weight: 600; color: var(--fx-text); }
.al-path { font-size: 12px; color: var(--fx-text-mute); }
.al-refused td { background: var(--fx-warning-bg) !important; }
.al-when { white-space: nowrap; font-variant-numeric: tabular-nums; }

/* AI Lab (extends the shell) */
.lab-grid { display: grid; grid-template-columns: 380px minmax(0, 1fr); gap: 20px; align-items: start; }
.lab-control .card-body { display: flex; flex-direction: column; gap: 16px; }
.lab-label { font-size: 12.5px; font-weight: 600; color: var(--fx-text); margin-bottom: 6px; display: flex; align-items: center; gap: 6px; }
.lab-label .material-icons { font-size: 16px !important; color: var(--fx-text-mute); }
.lab-textarea { font-family: var(--fx-font-mono); font-size: 13px; line-height: 1.6; min-height: 160px; resize: vertical; }
.lab-out { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.reply-body { padding: 18px 20px; font-size: 15px; line-height: 1.75; color: var(--fx-text); white-space: pre-wrap; overflow-wrap: anywhere; }
.exec-time { font-size: 12px; font-weight: 600; color: var(--fx-text-soft); background: var(--fx-surface-3); padding: 3px 10px; border-radius: 999px; font-variant-numeric: tabular-nums; }
.meta-strip { padding: 12px 20px; display: flex; flex-wrap: wrap; gap: 8px; border-top: 1px solid var(--fx-border-sf); }
.meta-pill { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 500; padding: 4px 10px; border-radius: 999px; background: var(--fx-surface-3); color: var(--fx-text); border: 1px solid var(--fx-border-sf); }
.meta-pill .k { color: var(--fx-text-mute); font-weight: 500; }
.meta-pill .material-icons { font-size: 15px !important; color: var(--fx-text-mute); }
.intake-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 8px; }
.intake-field { background: var(--fx-surface-2); border: 1px solid var(--fx-border-sf); border-radius: var(--fx-radius-sm); padding: 8px 12px; }
.intake-field .label { font-size: 11.5px; color: var(--fx-text-mute); }
.intake-field .val { font-size: 13.5px; color: var(--fx-text); margin-top: 2px; font-weight: 600; }
.intake-field .val.missing { color: var(--fx-danger-fg); font-style: italic; font-weight: 500; }
.debug-toggle {
  width: 100%; background: var(--fx-surface); border: 1px solid var(--fx-border); color: var(--fx-text-soft);
  border-radius: var(--fx-radius-sm); padding: 10px 14px; font-size: 13.5px; font-weight: 600; cursor: pointer;
  display: flex; align-items: center; justify-content: space-between; transition: background var(--fx-ease), color var(--fx-ease);
}
.debug-toggle:hover { background: var(--fx-surface-2); color: var(--fx-text); }
.debug-toggle .material-icons { font-size: 18px !important; transition: transform var(--fx-ease); }
.debug-toggle span { display: inline-flex; align-items: center; gap: 8px; }
.debug-content { display: none; margin-top: 6px; background: #0B1220; border: 1px solid var(--fx-border); border-radius: var(--fx-radius-sm); overflow: hidden; }
.debug-content.open { display: block; }
.debug-content pre { padding: 14px 16px; margin: 0; font-size: 12.5px; line-height: 1.6; color: #CBD5E1; font-family: var(--fx-font-mono); white-space: pre-wrap; word-break: break-word; max-height: 420px; overflow: auto; }
.debug-section { display: flex; flex-direction: column; gap: 8px; }
@media (max-width: 991.98px) { .lab-grid { grid-template-columns: 1fr; } }

/* ── 18. Auth pages ────────────────────────────────────────────────────── */
/* login.html and the admin login load this file without main.css, so these
   rules are self-contained (no Bootstrap classes assumed). */
body.fx-auth {
  margin: 0; min-height: 100vh; min-height: 100dvh; padding: 24px;
  display: flex; align-items: center; justify-content: center;
  background: var(--fx-sidebar-bg); color: var(--fx-text); font-family: var(--fx-font);
}
.fx-auth * { box-sizing: border-box; }
.fx-auth-card {
  width: min(880px, 100%); display: grid; grid-template-columns: 1fr 1fr;
  background: var(--fx-surface); border-radius: 16px; overflow: hidden;
  border: 1px solid rgba(255, 255, 255, .08);
}
.fx-auth-brand {
  background: var(--fx-sidebar-hover); color: #fff; padding: 40px 40px 32px;
  display: flex; flex-direction: column; gap: 18px; border-right: 1px solid rgba(255, 255, 255, .06);
}
.fx-auth-brand .brand-plate { display: inline-flex; align-self: flex-start; background: #121314; border: 1px solid rgba(255,255,255,.08); border-radius: var(--fx-radius-sm); padding: 8px 12px; }
.fx-auth-brand .brand-plate img { height: 28px; width: auto; display: block; }
.fx-auth-brand h1 { margin: 8px 0 0; font-size: 24px; font-weight: 600; line-height: 1.3; letter-spacing: -.01em; }
.fx-auth-brand .sub { margin: 0; font-size: 14px; line-height: 1.6; color: #B0BAC8; max-width: 34ch; }
.fx-auth-features { list-style: none; padding: 0; margin: 4px 0 0; display: grid; gap: 10px; }
.fx-auth-features li { display: flex; align-items: center; gap: 10px; font-size: 13.5px; color: #D1D5DB; }
.fx-auth-features li::before {
  content: ""; flex: 0 0 auto; width: 8px; height: 8px; border-radius: 50%; background: var(--fx-accent);
}
.fx-auth-brand .foot { margin-top: auto; font-size: 12px; color: #9CA3AF; }
.fx-auth-form { padding: 40px; display: flex; flex-direction: column; justify-content: center; }
.fx-auth-form h2 { margin: 0 0 4px; font-size: 22px; font-weight: 600; color: var(--fx-text); }
.fx-auth-form .lead { margin: 0 0 24px; font-size: 14px; color: var(--fx-text-soft); }
.fx-auth-form .field-label { display: block; font-size: 13px; font-weight: 600; color: var(--fx-text); margin-bottom: 6px; }
.fx-field { position: relative; margin-bottom: 16px; }
.fx-field > svg {
  position: absolute; left: 13px; top: 50%; transform: translateY(-50%); width: 18px; height: 18px;
  stroke: var(--fx-text-mute); fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; pointer-events: none;
}
.fx-field:focus-within > svg { stroke: var(--fx-primary); }
.fx-field input {
  width: 100%; height: 46px; padding: 0 14px 0 40px; border: 1px solid var(--fx-border); border-radius: var(--fx-radius-sm);
  font-size: 15px; font-family: inherit; color: var(--fx-text); background: var(--fx-surface); outline: none;
  transition: border-color var(--fx-ease), box-shadow var(--fx-ease);
}
.fx-field input::placeholder { color: var(--fx-text-mute); }
.fx-field input:focus { border-color: var(--fx-primary); box-shadow: var(--fx-ring); }
.fx-field.has-toggle input { padding-right: 46px; }
.fx-field .toggle-password, .toggle-eye {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%); width: 34px; height: 34px;
  display: grid; place-items: center; cursor: pointer; background: none; border: 0; border-radius: 6px; color: var(--fx-text-mute);
  transition: background var(--fx-ease), color var(--fx-ease);
}
.fx-field .toggle-password:hover, .toggle-eye:hover { background: var(--fx-surface-3); color: var(--fx-text); }
.fx-field .toggle-password svg { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.fx-auth-options { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 20px; font-size: 13.5px; }
.fx-auth-options label { display: flex; align-items: center; gap: 8px; color: var(--fx-text-soft); cursor: pointer; user-select: none; }
.fx-auth-options input[type=checkbox] { width: 16px; height: 16px; accent-color: var(--fx-primary); cursor: pointer; }
.caps-hint { font-size: 12px; font-weight: 600; color: var(--fx-warning-fg); background: var(--fx-warning-bg); border: 1px solid var(--fx-warning-bd); border-radius: 999px; padding: 3px 10px; display: none; }
.caps-hint.on { display: inline-block; }
.fx-btn-primary {
  width: 100%; height: 46px; background: var(--fx-primary); border: none; border-radius: var(--fx-radius-sm); color: #fff;
  font-family: inherit; font-size: 15px; font-weight: 600; cursor: pointer; transition: background var(--fx-ease);
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
}
.fx-btn-primary:hover { background: var(--fx-primary-dk); }
.fx-btn-primary:focus-visible { outline: none; box-shadow: var(--fx-ring); }
.fx-auth-alert {
  background: var(--fx-danger-bg); border: 1px solid var(--fx-danger-bd); border-radius: var(--fx-radius-sm);
  padding: 10px 12px; margin-bottom: 18px; display: flex; align-items: center; gap: 10px; font-size: 13.5px; font-weight: 500; color: var(--fx-danger-fg);
}
.fx-auth-alert svg { flex-shrink: 0; width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.fx-auth-foot { margin: 20px 0 0; text-align: center; font-size: 12.5px; color: var(--fx-text-mute); }
@media (max-width: 860px) {
  body.fx-auth { padding: 16px; }
  .fx-auth-card { grid-template-columns: 1fr; width: min(440px, 100%); }
  .fx-auth-brand { padding: 24px 24px 20px; gap: 10px; border-right: 0; border-bottom: 1px solid rgba(255,255,255,.06); }
  .fx-auth-brand h1 { font-size: 19px; }
  .fx-auth-features, .fx-auth-brand .foot { display: none; }
  .fx-auth-form { padding: 28px 24px 30px; }
}

/* Change password (inside the shell) */
.pw-card { max-width: 520px; }
.pw-card .input-wrap { position: relative; }
.pw-card .toggle-eye { font-size: 18px; }
.pw-card .pw-input { padding-right: 44px; }

/* ── 19. Responsive ────────────────────────────────────────────────────── */
/* Breakpoints follow Bootstrap so the grid classes and these rules agree:
     ≥1200 desktop — 240px sidebar · 992–1199 laptop — same, tighter padding
     768–991 tablet — sidebar becomes a drawer · <768 phone — single column,
     tables become labelled cards below 576 (see base.html). */
html, body { max-width: 100%; }
.content-main, .card, .table-responsive { min-width: 0; }
img, video, canvas, svg { max-width: 100%; height: auto; }

@media (max-width: 1400px) {
  .kpi-grid, .attention-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .attention-item:nth-child(2) { border-right: 0; }
  .attention-item:nth-child(-n+2) { border-bottom: 1px solid var(--fx-border-sf); }
}
@media (max-width: 1199.98px) {
  .main-wrap { margin-left: var(--fx-sidebar-w); }   /* main.css narrows to 220px here */
  .navbar-aside { max-width: var(--fx-sidebar-w); }
  .content-main, html.dark .content-main { padding: 24px 24px 40px; }
  .table td.cell-clip { max-width: 200px; }
}

/* Tablet and below: the sidebar is a drawer. main.css only did this under
   768px; the switch is at 992px here so an iPad keeps its width. */
@media (max-width: 991.98px) {
  .main-wrap, body.aside-mini .main-wrap { margin-left: 0 !important; }
  .navbar-aside, body.aside-mini .navbar-aside {
    position: fixed !important; top: 0; left: 0; height: 100%;
    z-index: 1200 !important; max-width: 300px !important; width: 84% !important;
    transform: translateX(-100%); transition: transform .2s ease-in-out; overflow-y: auto;
  }
  .navbar-aside.show { transform: translateX(0); }
  .btn-mobile { display: inline-flex !important; }
  .screen-overlay { z-index: 1100 !important; background: rgba(17, 24, 39, .55); }
  body.offcanvas-active { overflow: hidden; }
  .main-header { min-height: 60px; padding-left: 12px; padding-right: 12px; }
  .main-header .col-nav { order: 0 !important; width: auto !important; margin-bottom: 0 !important; margin-left: auto !important; }
  .content-main, html.dark .content-main { padding: 20px 20px 36px; }
}

@media (max-width: 767.98px) {
  .content-main, html.dark .content-main { padding: 16px 16px 32px; }
  .content-title { font-size: 21px !important; }
  .content-header { align-items: stretch; gap: 12px; margin-bottom: 16px; }
  .content-header .toolbar-form, .content-header .toolbar-form .form-control { width: 100%; }
  .content-header > *:last-child:not(:first-child) { display: flex; flex-wrap: wrap; gap: 8px; width: 100%; padding-top: 0; }
  .content-header .btn { flex: 1 1 auto; justify-content: center; }
  .card-body { padding: 16px; }
  .kpi-grid { gap: 12px; }
  .kpi-card { padding: 14px 16px; }
  .kpi-value { font-size: 26px; }
  .attention-grid { grid-template-columns: 1fr; }
  .card-header-flex .hint { display: none; }
  .chart-box { height: 200px; }
  .attention-item { border-right: 0; border-bottom: 1px solid var(--fx-border-sf); min-height: 56px; }
  .attention-item:last-child { border-bottom: 0; }
  .btn-icon { width: 40px; height: 40px; }
  .btn-icon .material-icons { font-size: 20px !important; }
  .btn, .btn.btn-sm, .filter-tab { min-height: 40px; }
  .form-control, .form-select { height: 44px; font-size: 16px; }   /* 16px stops iOS zooming on focus */
  textarea.form-control { height: auto; }
  .pagination .page-link { min-width: 40px; height: 40px; }
  .menu-aside .menu-link { min-height: 44px; }
  .submenu a { min-height: 40px; }
}
@media (max-width: 575.98px) {
  .row-actions { justify-content: flex-start; }
  .filter-tab, .lead-tab, .kb-tab, .visit-tab { font-size: 12.5px; padding: 6px 12px; }
  .content-header .btn { flex: 1 1 100%; }
  .content-header .btn.btn-light { flex: 1 1 calc(50% - 4px); }
}

/* Wide tables: horizontal scroll with the first column pinned on tablets,
   labelled cards on phones (data-title attributes are filled by base.html). */
@media all and (max-width: 480px) {
  .table-responsive table thead { display: table-header-group; }
  .table-responsive table td { display: table-cell; width: auto; text-align: inherit; }
  .table-responsive table td::before { content: none; }
}
@media (max-width: 991.98px) {
  .table-responsive { overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: thin; }
  .table-responsive > .table { min-width: 620px; }
  .table-responsive > .table > thead > tr > th:first-child,
  .table-responsive > .table > tbody > tr > td:first-child {
    position: sticky; left: 0; z-index: 2; max-width: 44vw;
    background: var(--fx-surface) !important; box-shadow: 1px 0 0 var(--fx-border-sf);
  }
  .table-responsive > .table > thead > tr > th:first-child { z-index: 3; background: var(--fx-surface-2) !important; }
  .table.table-hover > tbody > tr:hover > td:first-child { background: var(--fx-surface-2) !important; }
}
@media (max-width: 575.98px) {
  .table-responsive.fx-stack-wrap { overflow-x: visible; }
  .table-responsive > .table.fx-stack { min-width: 0; }
  .table-responsive > .table.fx-stack,
  .table-responsive > .table.fx-stack > tbody,
  .table-responsive > .table.fx-stack > tbody > tr,
  .table-responsive > .table.fx-stack > tbody > tr > td { display: block; width: 100%; }
  .table-responsive > .table.fx-stack > thead { display: none; }
  .table-responsive > .table.fx-stack > tbody > tr {
    background: var(--fx-surface); border: 1px solid var(--fx-border); border-radius: var(--fx-radius-sm); margin-bottom: 10px; overflow: hidden;
  }
  .table-responsive > .table.fx-stack > tbody > tr > td {
    display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; text-align: right;
    padding: 9px 13px !important; border: 0 !important; border-bottom: 1px solid var(--fx-border-sf) !important;
    max-width: none; position: static; box-shadow: none; white-space: normal;
  }
  .table-responsive > .table.fx-stack > tbody > tr > td:last-child { border-bottom: 0 !important; }
  .table-responsive > .table.fx-stack > tbody > tr > td::before {
    content: attr(data-title); flex: 0 0 38%; text-align: left; font-size: 11.5px; font-weight: 600;
    color: var(--fx-text-mute); padding-top: 2px;
  }
  .table-responsive > .table.fx-stack > tbody > tr > td.fx-cell-first { background: var(--fx-surface-2); font-size: 14px; text-align: left; }
  .table-responsive > .table.fx-stack > tbody > tr > td.fx-cell-first::before { display: none; }
  .table-responsive > .table.fx-stack > tbody > tr > td.fx-cell-actions { justify-content: flex-end; }
  .table-responsive > .table.fx-stack > tbody > tr > td.fx-cell-actions::before { display: none; }
  .table-responsive > .table.fx-stack .row-actions { justify-content: flex-end; width: 100%; }
  .table-responsive > .table.fx-stack > tbody > tr > td.fx-cell-full { display: block; text-align: center; }
  .table-responsive > .table.fx-stack > tbody > tr > td.fx-cell-full::before { display: none; }
  .table-responsive > .table.fx-stack td.cell-clip { max-width: none; white-space: normal; overflow: visible; text-overflow: clip; }
}

/* ── 20. Helpers ───────────────────────────────────────────────────────── */
.text-soft { color: var(--fx-text-soft) !important; }
.hint { font-size: 12.5px; color: var(--fx-text-mute); }
.nowrap { white-space: nowrap; }
.mono { font-family: var(--fx-font-mono); font-size: 12.5px; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.icon-inline { font-size: 16px !important; vertical-align: -3px; }

/* ── 21. Responsive tables (fx-table.js) ───────────────────────────────────
   Opted-in tables (table[data-fx-table]) shed their lowest-priority columns
   into a detail row beneath each record when the container is too narrow.
   The expander is a real button at the start of the row; the detail row is
   a quiet surface with aligned label/value pairs. A table using this never
   also becomes phone cards — one strategy per table.
   ─────────────────────────────────────────────────────────────────────── */
.fx-col-hidden { display: none !important; }
.table .fx-rt-th, .table .fx-rt-cell { width: 36px; padding-left: 8px !important; padding-right: 0 !important; }
.fx-rt-toggle {
  width: 28px; height: 28px; padding: 0; display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--fx-border); border-radius: 6px; background: var(--fx-surface); color: var(--fx-text-soft);
  cursor: pointer; transition: background var(--fx-ease), color var(--fx-ease), border-color var(--fx-ease);
}
.fx-rt-toggle .material-icons { font-size: 18px !important; transition: transform var(--fx-ease); }
.fx-rt-toggle:hover { background: var(--fx-surface-3); color: var(--fx-text); }
.fx-rt-toggle:focus-visible { outline: none; box-shadow: var(--fx-ring); }
.fx-rt-toggle[aria-expanded="true"] { background: var(--fx-tint); border-color: var(--fx-tint-bd); color: var(--fx-brand-fg); }
.fx-rt-toggle[aria-expanded="true"] .material-icons { transform: rotate(90deg); }
.table > tbody > tr.fx-rt-open > * { border-bottom-color: transparent !important; background: var(--fx-surface-2); }
.table > tbody > tr.fx-rt-detail > td {
  background: var(--fx-surface-2) !important;
  padding: 8px 16px 14px 48px !important;
  border-top: 0 !important;
  border-bottom: 1px solid var(--fx-border) !important;
}
.fx-rt-dl { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px 28px; margin: 0; }
.fx-rt-item { display: grid; grid-template-columns: minmax(96px, 150px) minmax(0, 1fr); gap: 2px 12px; font-size: 13px; align-items: start; }
.fx-rt-item dt { color: var(--fx-text-mute); font-weight: 500; margin: 0; padding-top: 1px; }
.fx-rt-item dd { color: var(--fx-text); margin: 0; overflow-wrap: anywhere; min-width: 0; }
.fx-rt-item dd .badge, .fx-rt-item dd .lead-pill { vertical-align: baseline; }
@media (max-width: 767.98px) {
  .fx-rt-dl { grid-template-columns: 1fr; }
  .table > tbody > tr.fx-rt-detail > td { padding-left: 14px !important; }
}
/* Fallback and mobile: no forced minimum width and no pinned first column
   for a table that manages its own columns. */
.table-responsive.fx-rt-wrap > .table { min-width: 0 !important; }
@media (max-width: 991.98px) {
  .table-responsive.fx-rt-wrap > .table > thead > tr > th:first-child,
  .table-responsive.fx-rt-wrap > .table > tbody > tr > td:first-child { position: static; max-width: none; box-shadow: none; }
}
/* Long text in a row: a two-line preview; the whole value lives in the
   detail row (data-detail-always) — never behind a hover alone. */
.fx-preview {
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden; max-width: 34ch; line-height: 1.45; white-space: normal;
}
.table td .fx-preview { color: var(--fx-text-soft); font-size: 13px; }

/* ── 22. Laptop density ─────────────────────────────────────────────────
   On 1280–1536px laptops the shell is unchanged but the workspace gives
   more of its width to the data: tighter gutters, tighter rows, less air
   between the heading, the filters and the table. Type sizes stay put. */
.table > :not(caption) > * > *, html.dark .table > :not(caption) > * > * { padding: 9px 12px; }
.table thead th, .table > thead > tr > th, .table-light th { padding: 9px 12px !important; }
.table .row-actions .btn-icon { width: 32px; height: 32px; }
.table td.sub, .table .row-sub { font-size: 12.5px; }
.content-header { margin-bottom: 16px; }
.filter-tabs, .lead-tabs { margin-bottom: 12px; }
.card > .card-body > form.toolbar-form, .card > .card-body > .kb-toolbar, .card > .card-body > .d-flex.mb-3 { margin-bottom: 12px !important; }
@media (min-width: 992px) and (max-width: 1599.98px) {
  .content-main, html.dark .content-main { padding: 20px 24px 40px; }
  .content-header { margin-bottom: 14px; gap: 12px; }
  .content-header .page-subtitle, .content-header .text-muted { font-size: 13px; }
  .card-body { padding: 16px; }
  .card-header, html.dark .card-header { padding: 12px 16px; }
  .kpi-card { padding: 14px 16px; }
}
/* Collapsed sidebar: a 72px rail (main.css uses 80). The preference is
   remembered in localStorage and applied before first paint (base.html). */
body.aside-mini .navbar-aside { max-width: 72px; }
body.aside-mini .main-wrap { margin-left: 72px; }
@media (max-width: 991.98px) { body.aside-mini .main-wrap { margin-left: 0 !important; } }

/* Field-name chips (contact import): wrap instead of overflowing. */
.fx-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.fx-chip {
  display: inline-flex; align-items: center; gap: 8px; padding: 5px 10px;
  border: 1px solid var(--fx-border); border-radius: var(--fx-radius-sm); background: var(--fx-surface-2);
}
.fx-chip code { font-size: 12.5px; color: var(--fx-text); background: transparent; padding: 0; }
.fx-chip small { font-size: 11px; color: var(--fx-text-mute); }
.fx-chip.is-required { border-color: var(--fx-tint-bd); background: var(--fx-tint); }
.fx-chip.is-required small { color: var(--fx-brand-fg); font-weight: 600; }

/* Row-action buttons keep a compact square, except the one or two that
   carry a label. A long-text detail item takes the whole detail width. */
.table .row-actions .btn-icon.has-label { width: auto; }
.fx-rt-item.is-wide, .fx-rt-dl > .fx-rt-item:only-child { grid-column: 1 / -1; }
.fx-rt-item.is-wide { grid-template-columns: minmax(96px, 150px) minmax(0, 1fr); }


/* ── Knowledge Explorer: long chunks fold ─────────────────────────────────
   A chunk shows its first ~12 lines and a "Show all" control; the page used
   to be twelve thousand pixels tall. One control expands every chunk. */
.kx-toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: space-between; margin: 0 0 12px; }
.kx-toolbar .hint { flex: 1 1 auto; }
.kx-chunk .kx-body.is-clamped { max-height: 280px; overflow: hidden; position: relative; }
.kx-chunk .kx-body.is-clamped::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 56px;
  background: linear-gradient(transparent, var(--fx-surface));
}
.kx-more { display: flex; justify-content: center; padding: 6px 0 10px; }
.kx-chunk .kx-head .btn-icon { margin-left: auto; }
.kx-chunk .kx-meta { font-variant-numeric: tabular-nums; }
.kx-gap { align-items: center; }
.kx-gap .facts { font-variant-numeric: tabular-nums; }
.kx-gap-state { width: 8px; height: 8px; border-radius: 50%; flex: 0 0 auto; background: var(--fx-success); }
.kx-gap.warn .kx-gap-state { background: var(--fx-warning); }
.kx-gap.bad  .kx-gap-state { background: var(--fx-danger); }

/* Team: the members toolbar reads like every other list toolbar. */
.tm-toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 12px; }
.tm-toolbar .tm-count { font-size: 13px; color: var(--fx-text-soft); margin-right: auto; }
.tm-toolbar .tm-count b { color: var(--fx-text); font-weight: 600; }
.tm-status { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; }
.tm-status::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--fx-success); }
.tm-status.is-off::before { background: var(--fx-text-mute); }


/* ── 23. Motion ───────────────────────────────────────────────────────────
   Restraint is the point: one short entrance for the page, a soft settle
   for menus and detail rows, and colours that ease when the theme changes.
   Nothing bounces, nothing floats, nothing loops. */
@keyframes fx-rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes fx-pop  { from { opacity: 0; transform: translateY(-4px) scale(.985); } to { opacity: 1; transform: none; } }
@keyframes fx-fade { from { opacity: 0; } to { opacity: 1; } }

.content-main { animation: fx-rise .26s cubic-bezier(.2, .7, .2, 1) both; }
.dropdown-menu.show { animation: fx-pop .16s ease-out both; transform-origin: top right; }
.modal.fade .modal-dialog { transition: transform .18s ease-out, opacity .18s ease-out; }
.fx-rt-detail > td > .fx-rt-dl { animation: fx-fade .18s ease-out both; }
.kb-view-overlay.open .kb-view-card, .skb-overlay.open .skb-card,
.cmp-overlay.open .cmp-card, .teach-overlay.open .teach-card { animation: fx-pop .18s ease-out both; }

/* The theme switch eases instead of snapping. */
body, .main-wrap, .navbar-aside, .main-header, .card, .table > :not(caption) > * > *,
.form-control, .form-select, .dropdown-menu, .btn-icon, .filter-tab, .kpi-card, .attention-item {
  transition-property: background-color, border-color, color, box-shadow;
  transition-duration: .18s; transition-timing-function: ease;
}

/* Interactive rows and links answer the pointer, gently. */
.table.table-hover > tbody > tr { transition: background-color .12s ease; }
.menu-aside .menu-link .icon { transition: color var(--fx-ease), transform .18s ease; }
.menu-aside .menu-link:hover .icon { transform: translateX(1px); }
.btn-primary:active, .fx-btn-primary:active { transform: translateY(1px); }
.fx-rt-toggle:active { transform: scale(.94); }
a.filter-tab:active { transform: scale(.98); }

@media (prefers-reduced-motion: reduce) {
  .content-main, .dropdown-menu.show, .fx-rt-detail > td > .fx-rt-dl,
  .kb-view-overlay.open .kb-view-card, .skb-overlay.open .skb-card,
  .cmp-overlay.open .cmp-card, .teach-overlay.open .teach-card { animation: none; }
}
