/* ============================================================
   ClientsHub App — Bootstrap 5 companion
   Depends on: vendor/bootstrap.min.css, vendor/fontawesome, tokens.css
   Theme comes from tokens.css; this file maps those tokens onto
   Bootstrap's CSS variables so BS components inherit the brand.
   ============================================================ */

/* ---------- 1. Theme bridge: tokens.css -> Bootstrap vars ---------- */
:root {
  --bs-body-bg: var(--ch-bg);
  --bs-body-color: var(--ch-text);
  --bs-body-font-family: var(--ch-font-sans);
  --bs-border-color: var(--ch-border);
  --bs-secondary-color: var(--ch-muted);
  --bs-emphasis-color: var(--ch-text);
  --bs-link-color: var(--ch-brand);
  --bs-link-hover-color: var(--ch-brand-strong);
  --bs-primary: var(--ch-brand);
  --bs-primary-rgb: 11, 140, 177;
  --bs-border-radius: var(--ch-radius-sm);
  --bs-border-radius-lg: var(--ch-radius);

  --app-sidebar-w: 264px;
  --app-navbar-h: 60px;
  --app-bottomnav-h: 62px;
  --app-page-overlay: rgba(246, 248, 252, .84);
}

[data-bs-theme="dark"] {
  --bs-body-bg: var(--ch-bg);
  --bs-body-color: var(--ch-text);
  --bs-tertiary-bg: var(--ch-surface-soft);
  --bs-secondary-bg: var(--ch-surface-soft);
  --bs-border-color: var(--ch-border);
  --bs-emphasis-color: var(--ch-text);
  --app-page-overlay: rgba(8, 13, 20, .84);
}

/* min-height (not height): a fixed 100% would cap the body box at the viewport,
   which breaks `position: sticky` on long pages like the admin console. */
html, body { min-height: 100%; }
body {
  font-family: var(--ch-font-sans);
  background-color: var(--ch-bg);
  background-image:
    linear-gradient(var(--app-page-overlay), var(--app-page-overlay)),
    url("/faded_gallery-OfdOEdGYiuk-unsplash.webp");
  background-size: cover;
  background-position: center;
  background-attachment: fixed;
  color: var(--ch-text);
  -webkit-font-smoothing: antialiased;
}

@media (max-width: 767.98px) {
  body { background-attachment: scroll; }
}

/* ---------- 2. Buttons ---------- */
.btn { --bs-btn-font-weight: 600; }
.btn-primary {
  --bs-btn-bg: var(--ch-brand);
  --bs-btn-border-color: var(--ch-brand);
  --bs-btn-color: #fff;
  --bs-btn-hover-bg: var(--ch-brand-strong);
  --bs-btn-hover-border-color: var(--ch-brand-strong);
  --bs-btn-hover-color: #fff;
  --bs-btn-active-bg: #065a74;
  --bs-btn-active-border-color: #065a74;
  --bs-btn-disabled-bg: var(--ch-brand);
  --bs-btn-disabled-border-color: var(--ch-brand);
}
.btn-outline-primary {
  --bs-btn-color: var(--ch-brand);
  --bs-btn-border-color: var(--ch-brand);
  --bs-btn-hover-bg: var(--ch-brand);
  --bs-btn-hover-border-color: var(--ch-brand);
  --bs-btn-hover-color: #fff;
}
.btn-outline-secondary {
  --bs-btn-color: var(--ch-text);
  --bs-btn-border-color: var(--ch-border);
  --bs-btn-hover-bg: var(--ch-hover);
  --bs-btn-hover-border-color: var(--ch-brand);
  --bs-btn-hover-color: var(--ch-text);
  --bs-btn-active-bg: var(--ch-brand);
  --bs-btn-active-border-color: var(--ch-brand);
  --bs-btn-active-color: #fff;
}
.btn:focus-visible { box-shadow: 0 0 0 .2rem rgba(11, 140, 177, .35); }

/* Form submission loading state (set by onSubmit / setFormLoading in app.js) */
.is-submitting { position: relative; }
.is-submitting::after {
  content: "";
  position: absolute; top: 0; left: 0; height: 3px; width: 32%;
  border-radius: 0 3px 3px 0;
  background: var(--ch-brand);
  box-shadow: 0 0 8px rgba(11, 140, 177, .5);
  animation: ch-loadbar 1.1s infinite ease-in-out;
  z-index: 6;
}
.modal-content.is-submitting { overflow: hidden; }
@keyframes ch-loadbar {
  0% { left: -32%; }
  55% { left: 100%; }
  100% { left: 100%; }
}
/* Muted while processing: dimmed and non-interactive (belt-and-braces with inert). */
form[aria-busy="true"] {
  opacity: .55;
  pointer-events: none;
  transition: opacity .15s ease;
}

/* Icon-only buttons in the navbar */
.btn-icon,
.btn-icon-wide {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .5rem;
  height: 38px;
  padding: 0 .6rem;
  border: 1px solid transparent;
  border-radius: var(--ch-radius-sm);
  background: transparent;
  color: var(--ch-text);
}
.btn-icon { width: 38px; padding: 0; }
.btn-icon:hover,
.btn-icon-wide:hover { background: var(--ch-surface-soft); }
.btn-icon-wide::after { margin-left: .15rem; }

/* ---------- 2b. Boot loading overlay ---------- */
.app-loading {
  position: fixed;
  inset: 0;
  z-index: 3000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--ch-bg);
  transition: opacity .35s ease;
}
.app-loading.is-hidden { opacity: 0; pointer-events: none; }
.app-loading-inner { display: grid; place-items: center; gap: 1rem; text-align: center; }
.app-loading-text { color: var(--ch-muted); font-size: .9rem; }
.app-spinner {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 3px solid var(--ch-border);
  border-top-color: var(--ch-brand);
  animation: app-spin .8s linear infinite;
}
@keyframes app-spin { to { transform: rotate(360deg); } }

/* ---------- 3. Top navbar ---------- */
.app-navbar {
  height: var(--app-navbar-h);
  background: var(--ch-surface);
  border-bottom: 1px solid var(--ch-border);
  padding: 0 .75rem;
  z-index: 1030;
}
.app-logo { height: 30px; width: auto; }
.app-brand { font-weight: 800; font-size: 1.05rem; letter-spacing: -.01em; }
.app-company-select { width: auto; max-width: 190px; }
.app-lang-select { width: auto; min-width: 68px; }
.app-account-menu { min-width: 260px; }
.company-logo-mark,
.company-logo-preview {
  width: 34px;
  height: 34px;
  flex: 0 0 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  border: 1px solid var(--ch-border);
  border-radius: 9px;
  background: var(--ch-surface-soft);
  color: var(--ch-muted);
  text-decoration: none;
}
.company-logo-mark:visited { color: var(--ch-muted); }
.company-logo-mark.has-company-website { cursor: pointer; }
.company-logo-mark.has-company-website:hover {
  border-color: var(--ch-brand);
  box-shadow: 0 0 0 2px rgba(var(--bs-primary-rgb), .16);
}
.company-logo-mark.has-company-website:focus-visible {
  outline: 2px solid var(--ch-brand);
  outline-offset: 2px;
}
.company-logo-mark img,
.company-logo-preview img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
}
.company-logo-mark.has-company-logo,
.company-logo-preview.has-company-logo { background: #fff; }
.company-logo-mark-mobile {
  width: 36px;
  height: 36px;
  flex-basis: 36px;
}
.company-logo-upload {
  display: flex;
  align-items: center;
  gap: .75rem;
}
.company-logo-upload .form-control { min-width: 0; }
.company-logo-preview {
  width: 48px;
  height: 48px;
  flex-basis: 48px;
  border-radius: 12px;
  font-size: 1.1rem;
}
@media (max-width: 575.98px) {
  .app-navbar { padding-inline: .35rem; }
  .app-navbar > .container-fluid { --bs-gutter-x: .5rem; }
  .app-navbar .container-fluid { gap: .25rem !important; }
  .app-navbar .app-lang-select { min-width: 56px; width: 56px; }
  .app-navbar .btn-icon { width: 34px; }
  body.logged-out .company-logo-mark-mobile { display: none; }
}
/* ---------- 4. Layout ---------- */
.app-layout {
  display: flex;
  align-items: flex-start;
  min-height: calc(100vh - var(--app-navbar-h));
}
.app-main {
  flex: 1 1 auto;
  min-width: 0;
  padding: 1.5rem;
  padding-bottom: calc(var(--app-bottomnav-h) + 1.5rem);
}
@media (min-width: 992px) {
  .app-main { padding-bottom: 2rem; }
}
@media (max-width: 575.98px) {
  .app-main { padding: 1rem; padding-bottom: calc(var(--app-bottomnav-h) + 1rem); }
}

/* ---------- 5. Sidebar ---------- */
.app-sidebar {
  background: var(--ch-surface);
  border-right: 1px solid var(--ch-border);
}
@media (min-width: 992px) {
  .app-sidebar {
    flex: 0 0 var(--app-sidebar-w);
    width: var(--app-sidebar-w);
    position: sticky;
    top: var(--app-navbar-h);
    height: calc(100vh - var(--app-navbar-h));
  }
  .app-sidebar-body { display: flex; flex-direction: column; height: 100%; padding: .75rem; }
}
.app-sidebar-body { padding: .75rem; overflow-y: auto; }
.app-nav { display: flex; flex-direction: column; gap: .25rem; }

.app-nav-link {
  display: flex;
  align-items: center;
  gap: .75rem;
  width: 100%;
  padding: .6rem .7rem;
  border: 0;
  border-radius: var(--ch-radius-sm);
  background: transparent;
  color: var(--ch-text);
  text-align: left;
  transition: background .15s, color .15s;
}
.app-nav-link > i { font-size: 1rem; width: 20px; text-align: center; color: var(--ch-muted); }
.app-nav-text { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.app-nav-text strong { font-size: .9rem; font-weight: 650; }
.app-nav-text small { font-size: .72rem; color: var(--ch-muted); }
.app-nav-link:hover { background: var(--ch-surface-soft); }
.app-nav-link.active { background: transparent; box-shadow: none; }
.app-nav-link.active > i,
.app-nav-link.active .app-nav-text strong { color: var(--ch-brand); }

/* ---------- 6. Mobile bottom nav ---------- */
.app-bottomnav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: var(--app-bottomnav-h);
  display: flex;
  background: var(--ch-surface);
  border-top: 1px solid var(--ch-border);
  z-index: 1035;
  padding-bottom: env(safe-area-inset-bottom);
}
.bottomnav-link {
  flex: 1 1 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: .2rem;
  border: 0;
  background: transparent;
  color: var(--ch-muted);
  font-size: .68rem;
  font-weight: 600;
  padding: .35rem .1rem;
  min-width: 0;
}
.bottomnav-link i { font-size: 1.05rem; }
.bottomnav-link span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bottomnav-link.active { color: var(--ch-brand); }
.bottomnav-link.active i { transform: translateY(-1px); }

/* ---------- 7. Views (fixes the broken view switching) ---------- */
.app-view { display: none; }
.app-view.active { display: block; animation: viewIn .18s ease-out; }
@keyframes viewIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

.view-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1.25rem;
}
.view-title { font-size: 1.4rem; font-weight: 800; margin: 0; letter-spacing: -.02em; }
.view-title > i { color: var(--ch-brand); }
.view-sub { color: var(--ch-muted); font-size: .875rem; margin: .25rem 0 0; }
.view-actions { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }

.group-title { font-size: .95rem; font-weight: 750; margin: 0 0 .25rem; }
.group-title > i { color: var(--ch-brand); }
.group-sub { color: var(--ch-muted); font-size: .8rem; margin: 0 0 .75rem; }

.score-chip {
  display: flex; align-items: center; gap: .5rem;
  background: var(--ch-surface); border: 1px solid var(--ch-border);
  border-radius: 999px; padding: .35rem .9rem;
}
.score-chip span { font-size: .75rem; color: var(--ch-muted); font-weight: 600; }
.score-chip strong { font-size: 1rem; color: var(--ch-brand); }

/* ---------- 8. Tabs ---------- */
.app-tabs { border-bottom: 1px solid var(--ch-border); margin-bottom: 1rem; flex-wrap: nowrap; overflow-x: auto; }
.app-tabs::-webkit-scrollbar { height: 0; }
.nav-tabs {
  --bs-nav-tabs-border-color: var(--ch-border);
  --bs-nav-tabs-link-active-bg: transparent;
  --bs-nav-tabs-link-active-color: var(--ch-brand);
  --bs-nav-tabs-link-active-border-color: transparent transparent var(--ch-brand);
  --bs-nav-link-color: var(--ch-muted);
  --bs-nav-link-hover-color: var(--ch-text);
  --bs-nav-tabs-link-hover-border-color: transparent;
}
.nav-tabs .nav-link {
  border-width: 0 0 2px;
  border-radius: 0;
  font-weight: 650;
  font-size: .875rem;
  padding: .6rem .9rem;
  white-space: nowrap;
}
.nav-tabs .nav-link.active { border-bottom-width: 2px; }

/* Segmented control (auth modal) */
.app-segmented { background: var(--ch-surface-soft); border-radius: 999px; padding: .25rem; gap: .25rem; }
.app-segmented .nav-link {
  border-radius: 999px; font-weight: 650; font-size: .875rem;
  color: var(--ch-muted); padding: .45rem .75rem;
}
.app-segmented .nav-link.active { background: var(--ch-brand); color: #fff; }

/* ---------- 8b. Modals ---------- */
.modal-content {
  background: var(--ch-surface);
  color: var(--ch-text);
  border: 1px solid var(--ch-border);
  border-radius: var(--ch-radius-lg);
}
.modal-header, .modal-footer { border-color: var(--ch-border) !important; }
.modal-footer { background: var(--ch-surface-soft); }
.modal-title { font-weight: 700; font-size: 1.05rem; }
.modal-header .btn-close, .offcanvas-header .btn-close { --bs-btn-close-color: var(--ch-text); }
[data-bs-theme="dark"] .btn-close { filter: invert(1) grayscale(1) brightness(1.6); }

/* ---------- 9. Cards ---------- */
.card {
  --bs-card-bg: var(--ch-surface);
  --bs-card-border-color: var(--ch-border);
  --bs-card-border-radius: var(--ch-radius);
  --bs-card-cap-bg: transparent;
  box-shadow: 0 1px 2px rgba(0,0,0,.04);
  margin-bottom: 1rem;
}
.card:last-child { margin-bottom: 0; }
.card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  padding: 1rem 1.15rem;
  border-bottom: 1px solid var(--ch-border-soft);
}
.card-header.pb-0 { border-bottom: 0; }
.card-title { font-size: 1rem; font-weight: 700; margin: 0; }
.card-sub { color: var(--ch-muted); font-size: .8rem; margin: .2rem 0 0; }
.card-body { padding: 1.15rem; }
.card-header-tabs { margin-bottom: -1rem; border-bottom: 0; }

/* Toolbar strip inside a card */
.card-toolbar {
  display: flex;
  align-items: center;
  gap: .75rem;
  flex-wrap: wrap;
  padding: .75rem 1.15rem;
  background: var(--ch-surface-soft);
  border-bottom: 1px solid var(--ch-border-soft);
}
.import-file { max-width: 260px; }
.toolbar-divider { width: 1px; height: 24px; background: var(--ch-border); }
.filter-group { display: grid; gap: .45rem; }
.filter-label { font-size: .75rem; font-weight: 700; color: var(--ch-muted); text-transform: uppercase; letter-spacing: .04em; }
.client-filter.active { background: var(--ch-brand); border-color: var(--ch-brand); color: #fff; }
.client-filter-toggle { position: relative; }
.client-filter-toggle.filters-active { color: var(--ch-brand); border-color: var(--ch-brand); background: var(--ch-hover); }
.client-filter-count {
  position: absolute; top: -6px; right: -6px;
  min-width: 17px; height: 17px; padding: 0 4px;
  border-radius: 999px; background: var(--ch-brand); color: #fff;
  font-size: .62rem; font-weight: 800; line-height: 17px;
}
.client-filter-menu { min-width: min(360px, calc(100vw - 2rem)); }
.client-filter-menu .filter-group + .filter-group { margin-top: 1rem; }
.client-filter-menu .btn-group > .btn { flex: 1 1 auto; }

/* ---------- 10. KPI cards ---------- */
.kpi-card {
  height: 100%;
  background: var(--ch-surface);
  border: 1px solid var(--ch-border);
  border-radius: var(--ch-radius);
  padding: .9rem 1rem;
  display: flex;
  flex-direction: column;
  gap: .15rem;
  position: relative;
}
.kpi-card > span:first-child {
  font-size: .7rem;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--ch-muted);
  font-weight: 700;
}
.kpi-card strong { font-size: 1.6rem; font-weight: 800; line-height: 1.15; letter-spacing: -.02em; }
.kpi-card small { font-size: .72rem; color: var(--ch-muted); }
.kpi-card.kpi-sm strong { font-size: 1.25rem; }
.kpi-card.kpi-accent { border-left: 3px solid var(--ch-brand); }
.kpi-card.kpi-revenue strong { color: var(--ch-brand); }
.kpi-card.kpi-success strong { color: var(--ch-success); }
.kpi-card.kpi-warning strong { color: var(--ch-warning); }
.kpi-card.kpi-danger strong { color: var(--ch-danger); }
[data-bs-theme="dark"] .kpi-card.kpi-success strong { color: var(--ch-green); }
[data-bs-theme="dark"] .kpi-card.kpi-warning strong { color: var(--ch-gold); }
@media (max-width: 575.98px) { .kpi-card strong { font-size: 1.3rem; } }

/* ---------- 11. Client mix + funnel ---------- */
.client-mix { display: flex; align-items: center; gap: .75rem; }
.recurring-counter-wrap {
  position: relative;
  display: inline-grid;
  margin-right: 18px;
}
.client-visual-card {
  position: relative;
  text-align: center;
  padding: .5rem 1rem;
  border-radius: var(--ch-radius);
  min-width: 104px;
}
.client-visual-card span { font-size: .68rem; text-transform: uppercase; letter-spacing: .05em; font-weight: 700; }
.client-visual-card strong { font-size: 1.5rem; font-weight: 800; display: block; line-height: 1.1; }
.client-visual-card.recurring-count {
  overflow: hidden;
  isolation: isolate;
  background: linear-gradient(135deg, #f7d66d 0%, var(--ch-gold) 55%, #9b650d 100%);
  border: 1px solid rgba(255, 226, 128, .68);
  color: #211500;
  box-shadow: 0 8px 24px rgba(216, 166, 44, .28), 0 0 18px rgba(255, 214, 90, .16);
}
.client-visual-card.recurring-count::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
  border-radius: inherit;
  background: linear-gradient(115deg, transparent 38%, rgba(255, 255, 255, .72) 50%, transparent 62%);
  transform: translateX(-125%);
  animation: recurringGoldGlow 4.8s ease-in-out infinite;
  pointer-events: none;
}
.client-visual-card.recurring-count span,
.client-visual-card.recurring-count strong {
  position: relative;
  z-index: 1;
}
.client-visual-card.one-time-count { background: var(--ch-surface-soft); border: 1px solid var(--ch-border); }
.recurring-trophy {
  position: absolute;
  right: -22px;
  top: 50%;
  z-index: 2;
  width: 48px;
  height: 48px;
  object-fit: contain;
  transform: translateY(-50%) rotate(15deg);
  transform-origin: center;
  filter: drop-shadow(0 6px 10px rgba(68, 38, 2, .38));
  pointer-events: none;
}

@keyframes recurringGoldGlow {
  0%, 55% { transform: translateX(-125%); }
  82%, 100% { transform: translateX(125%); }
}

@media (prefers-reduced-motion: reduce) {
  .client-visual-card.recurring-count::before { animation: none; }
}

.funnel-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: .75rem; }

/* ---------- 12. Tables ---------- */
.table {
  --bs-table-bg: transparent;
  --bs-table-color: var(--ch-text);
  --bs-table-border-color: var(--ch-border-soft);
  --bs-table-hover-bg: var(--ch-hover);
  --bs-table-hover-color: var(--ch-text);
  font-size: .875rem;
  margin-bottom: 0;
}
.table > thead th {
  font-size: .7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--ch-muted);
  background: var(--ch-surface-soft);
  border-bottom: 1px solid var(--ch-border);
  white-space: nowrap;
  padding: .6rem .9rem;
}
.table > tbody td { padding: .7rem .9rem; vertical-align: middle; }
.table > tbody tr:last-child td { border-bottom: 0; }
.table .sub { display: block; color: var(--ch-muted); font-size: .75rem; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table-empty { padding: 2rem 1rem; text-align: center; color: var(--ch-muted); font-size: .85rem; }
.table-responsive { border-radius: 0 0 var(--ch-radius) var(--ch-radius); }

/* Row action buttons — `position: relative` anchors the kebab menu below. */
.row-actions {
  position: relative;
  display: inline-flex;
  gap: .25rem;
  justify-content: flex-end;
  align-items: center;
}
.row-actions .btn { --bs-btn-padding-x: .5rem; --bs-btn-padding-y: .2rem; --bs-btn-font-size: .78rem; }
.kebab-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 30px; height: 30px;
  border: 1px solid transparent;
  border-radius: var(--ch-radius-sm);
  background: transparent;
  color: var(--ch-muted);
  font-size: .85rem;
  cursor: pointer;
}
.kebab-btn:hover { background: var(--ch-surface-soft); border-color: var(--ch-border); color: var(--ch-text); }

/* Status badges */
.badge { font-weight: 700; font-size: .68rem; padding: .3rem .5rem; border-radius: 999px; }
.badge-soft { background: var(--ch-surface-soft); color: var(--ch-muted); border: 1px solid var(--ch-border); }
.badge-brand { background: rgba(11,140,177,.14); color: var(--ch-brand); }
.badge-success { background: rgba(57,217,138,.16); color: var(--ch-success); }
.badge-warning { background: rgba(183,121,0,.16); color: var(--ch-warning); }
.badge-danger { background: rgba(229,72,77,.14); color: var(--ch-danger); }
.badge-info { background: rgba(34,195,220,.14); color: var(--ch-cyan); }
[data-bs-theme="dark"] .badge-success { color: var(--ch-green); }
[data-bs-theme="dark"] .badge-warning { color: var(--ch-gold); }

/* Compact billing and health chips in the client renewal list. */
.client-name-line {
  display: flex;
  align-items: center;
  gap: .4rem;
  min-width: 0;
}
.client-flag {
  width: 20px;
  height: 15px;
  flex: 0 0 20px;
  display: block;
  border: 1px solid rgba(255, 255, 255, .16);
  border-radius: 2px;
  object-fit: cover;
  box-shadow: 0 1px 2px rgba(0, 0, 0, .18);
}
.client-chip-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: .3rem;
  margin-top: .3rem;
}
.client-type-chip,
.client-health-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: fit-content;
  min-height: 20px;
  padding: .16rem .45rem;
  border: 1px solid var(--ch-border);
  border-radius: 999px;
  font-size: .66rem;
  font-weight: 750;
  line-height: 1.1;
  white-space: nowrap;
}
.client-type-neutral {
  background: var(--ch-surface-soft);
  color: var(--ch-muted);
}
.client-type-recurring {
  border-color: rgba(216, 166, 44, .48);
  background: rgba(216, 166, 44, .15);
  color: var(--ch-warning);
}
.client-health-chip.status-success {
  border-color: rgba(57, 217, 138, .42);
  background: rgba(57, 217, 138, .14);
  color: var(--ch-success);
}
.client-health-chip.status-warning {
  border-color: rgba(216, 166, 44, .48);
  background: rgba(216, 166, 44, .15);
  color: var(--ch-warning);
}
.client-health-chip.status-danger {
  border-color: rgba(229, 72, 77, .45);
  background: rgba(229, 72, 77, .13);
  color: var(--ch-danger);
}
[data-bs-theme="dark"] .client-type-recurring,
[data-bs-theme="dark"] .client-health-chip.status-warning { color: var(--ch-gold); }
[data-bs-theme="dark"] .client-health-chip.status-success { color: var(--ch-green); }

/* Health dots */
.health-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: .35rem; }
.health-green { background: var(--ch-green); }
.health-yellow { background: var(--ch-gold); }
.health-red { background: var(--ch-danger); }

/* Contact channel icons */
.contact-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 30px; height: 30px; margin-right: .24rem;
  border-radius: 50%;
  background: rgba(14, 165, 233, .12);
  border: 1px solid rgba(14, 165, 233, .42);
  color: #38bdf8;
  font-size: .72rem;
  text-decoration: none;
  transition: transform .15s ease, filter .15s ease, background-color .15s ease;
}
.contact-icon svg { width: 17px; height: 17px; flex: 0 0 17px; }
.contact-icon[data-kind="email"] {
  background: rgba(56, 189, 248, .14);
  border-color: rgba(56, 189, 248, .5);
  color: #38bdf8;
}
.contact-icon[data-kind="phone"] {
  background: rgba(250, 204, 21, .13);
  border-color: rgba(250, 204, 21, .46);
  color: #facc15;
}
.contact-icon[data-kind="whatsapp"] {
  background: rgba(37, 211, 102, .14);
  border-color: rgba(37, 211, 102, .5);
  color: #25d366;
}
.contact-icon[data-kind="facebook"],
.contact-icon[data-kind="messenger"] {
  background: rgba(24, 119, 242, .14);
  border-color: rgba(69, 150, 255, .5);
  color: #4596ff;
}
.contact-icon[data-kind="linkedin"] {
  background: rgba(10, 102, 194, .16);
  border-color: rgba(64, 153, 242, .48);
  color: #4099f2;
}
.contact-icon[data-kind="instagram"] {
  background: rgba(225, 48, 108, .14);
  border-color: rgba(244, 114, 182, .48);
  color: #f472b6;
}
.contact-icon[data-kind="website"] {
  background: rgba(167, 139, 250, .14);
  border-color: rgba(167, 139, 250, .48);
  color: #a78bfa;
}
.contact-icon:hover,
.contact-icon:focus-visible {
  background: currentColor;
  filter: brightness(1.12);
  outline: none;
  transform: translateY(-1px);
}
.contact-icon:hover svg,
.contact-icon:focus-visible svg { color: #07131a; }

/* ---------- 13. DataTables in Bootstrap skin ---------- */
.dataTables_wrapper { padding: .85rem 1.15rem 1rem; }
.dataTables_wrapper .dataTables_filter { float: right; }
.dataTables_wrapper .dataTables_length { float: left; }
.dataTables_wrapper .dataTables_filter input,
.dataTables_wrapper .dataTables_length select {
  border: 1px solid var(--ch-border);
  border-radius: var(--ch-radius-sm);
  background: var(--ch-surface);
  color: var(--ch-text);
  padding: .3rem .55rem;
  margin-left: .4rem;
}
.dataTables_wrapper .dataTables_filter input:focus,
.dataTables_wrapper .dataTables_length select:focus { outline: 2px solid var(--ch-brand); outline-offset: 1px; }
.dataTables_wrapper .dataTables_info,
.dataTables_wrapper .dataTables_length,
.dataTables_wrapper .dataTables_filter { color: var(--ch-muted); font-size: .8rem; }
.dataTables_wrapper .dataTables_paginate .paginate_button {
  border-radius: var(--ch-radius-sm) !important;
  border: 1px solid transparent !important;
  color: var(--ch-text) !important;
  font-size: .8rem;
  padding: .3rem .6rem !important;
  margin-left: .15rem;
}
.dataTables_wrapper .dataTables_paginate .paginate_button:hover {
  background: var(--ch-hover) !important;
  border-color: var(--ch-border) !important;
  color: var(--ch-text) !important;
}
.dataTables_wrapper .dataTables_paginate .paginate_button.current,
.dataTables_wrapper .dataTables_paginate .paginate_button.current:hover {
  background: var(--ch-brand) !important;
  border-color: var(--ch-brand) !important;
  color: #fff !important;
}
table.dataTable > thead > tr > th { border-bottom: 1px solid var(--ch-border) !important; }
table.dataTable.no-footer { border-bottom: 0 !important; }

/* ---------- 14. Forms ---------- */
.form-label { font-size: .8rem; font-weight: 650; margin-bottom: .3rem; color: var(--ch-text); }
.form-control, .form-select {
  background: var(--ch-surface);
  border-color: var(--ch-border);
  color: var(--ch-text);
  font-size: .875rem;
}
.form-control:focus, .form-select:focus {
  background: var(--ch-surface);
  color: var(--ch-text);
  border-color: var(--ch-brand);
  box-shadow: 0 0 0 .2rem rgba(11, 140, 177, .18);
}
.form-control::placeholder { color: var(--ch-muted); opacity: .7; }
.input-group-text { background: var(--ch-surface-soft); border-color: var(--ch-border); color: var(--ch-muted); }
.form-text { font-size: .74rem; color: var(--ch-muted); }
.form-check-input:checked { background-color: var(--ch-brand); border-color: var(--ch-brand); }
.form-check-input:focus { border-color: var(--ch-brand); box-shadow: 0 0 0 .2rem rgba(11,140,177,.18); }
.req { color: var(--ch-muted); font-size: .75rem; font-weight: 400; }

.form-section-title {
  font-size: .75rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--ch-muted);
  margin: .5rem 0 0;
  padding-bottom: .4rem;
  border-bottom: 1px solid var(--ch-border-soft);
}
.form-section-title > i { color: var(--ch-brand); }
.form-actions {
  display: flex; justify-content: flex-end; gap: .5rem;
  padding-top: .75rem; margin-top: .5rem;
  border-top: 1px solid var(--ch-border-soft);
}
@media (max-width: 575.98px) { .form-actions .btn { width: 100%; } }

/* ---------- 15. Auth dialog (<dialog>, kept for showModal()) ---------- */
/* ---------- Auth Guard Blur ---------- */
body.auth-blur .app-navbar,
body.auth-blur .app-layout {
  filter: blur(8px) grayscale(20%);
  pointer-events: none;
  user-select: none;
}

.auth-dialog {
  width: min(460px, calc(100vw - 2rem));
  max-height: calc(100vh - 2rem);
  padding: 0;
  border: 1px solid var(--ch-border);
  border-radius: var(--ch-radius-lg);
  background: var(--ch-surface);
  color: var(--ch-text);
  box-shadow: var(--ch-shadow-lg);
  overflow: hidden;
}
.auth-dialog::backdrop { background: rgba(3, 8, 12, .6); backdrop-filter: blur(4px); }
.auth-dialog-inner { display: flex; flex-direction: column; max-height: calc(100vh - 2rem); }
.auth-dialog-header {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem;
  padding: 1.25rem 1.25rem .5rem;
}
.auth-dialog-body { padding: .5rem 1.25rem 1.5rem; overflow-y: auto; }
.signup-account-types {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: .55rem;
}
.signup-account-type {
  position: relative;
  cursor: pointer;
}
.signup-account-type > input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}
.signup-account-type > span {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: .15rem .5rem;
  height: 100%;
  padding: .75rem;
  border: 1px solid var(--ch-border);
  border-radius: var(--ch-radius-sm);
  background: var(--ch-surface-soft);
  transition: border-color .15s ease, box-shadow .15s ease, background .15s ease;
}
.signup-account-type i {
  grid-row: span 2;
  margin-top: .12rem;
  color: var(--ch-brand);
}
.signup-account-type strong {
  font-size: .82rem;
}
.signup-account-type small {
  color: var(--ch-text-muted);
  font-size: .68rem;
  line-height: 1.35;
}
.signup-account-type > input:checked + span {
  border-color: var(--ch-brand);
  background: rgba(var(--bs-primary-rgb), .08);
  box-shadow: 0 0 0 2px rgba(var(--bs-primary-rgb), .12);
}
.signup-account-type > input:focus-visible + span {
  outline: 2px solid var(--ch-brand);
  outline-offset: 2px;
}
@media (max-width: 575.98px) {
  .signup-account-types { grid-template-columns: 1fr; }
}

/* ---------- 16. Onboarding ---------- */
.company-onboarding {
  display: flex; align-items: center; justify-content: center;
  min-height: calc(100vh - var(--app-navbar-h));
  padding: 1.5rem;
}
.company-onboarding-card { max-width: 720px; width: 100%; box-shadow: var(--ch-shadow-lg); }
.auth-kicker { color: var(--ch-brand); font-size: .72rem; text-transform: uppercase; letter-spacing: .08em; font-weight: 800; }
.onboarding-steps { padding-left: 1.1rem; color: var(--ch-muted); }
.onboarding-steps li { margin-bottom: .2rem; }

/* ---------- 17. Settings offcanvas ---------- */
.app-settings-offcanvas { width: 420px !important; max-width: 92vw; background: var(--ch-surface); }
.accordion {
  --bs-accordion-bg: transparent;
  --bs-accordion-border-color: var(--ch-border);
  --bs-accordion-btn-color: var(--ch-text);
  --bs-accordion-active-color: var(--ch-brand);
  --bs-accordion-active-bg: var(--ch-hover);
  --bs-accordion-btn-focus-box-shadow: 0 0 0 .2rem rgba(11,140,177,.18);
  --bs-accordion-color: var(--ch-text);
}
.accordion-button { font-weight: 650; font-size: .9rem; }
.accordion-button:not(.collapsed) { box-shadow: none; }
.offcanvas { background: var(--ch-surface); color: var(--ch-text); }

/* ---------- 18. Reports / due list ---------- */
.report-box {
  background: var(--ch-surface-soft);
  border: 1px solid var(--ch-border);
  border-radius: var(--ch-radius-sm);
  padding: 1rem;
  font-family: var(--ch-font-mono);
  font-size: .78rem;
  color: var(--ch-text);
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 460px;
  overflow-y: auto;
}
.due-list { display: flex; flex-direction: column; gap: .5rem; }
.due-list:empty::after { content: "Nothing due right now."; color: var(--ch-muted); font-size: .85rem; }

/* ---------- 19. Kebab menus (rendered by app.js) ---------- */
/* Positioned `fixed` by js/ui.js (coordinates set inline) so the table's
   horizontal scroll container cannot clip it. */
.kebab-menu {
  position: fixed;
  background: var(--ch-elevated);
  border: 1px solid var(--ch-border);
  border-radius: var(--ch-radius-sm);
  box-shadow: var(--ch-shadow-lg);
  padding: .3rem 0;
  z-index: 1080;
  min-width: 180px;
  text-align: left;
}
.kebab-menu.hidden { display: none; }
.kebab-item {
  display: flex; align-items: center; gap: .5rem;
  width: 100%; padding: .45rem .75rem;
  text-align: left; border: 0; background: none;
  color: var(--ch-text); font-size: .82rem; white-space: nowrap;
}
.kebab-item:hover { background: var(--ch-hover); }
.kebab-item.danger { color: var(--ch-danger); }
.kebab-item > i { width: 14px; text-align: center; color: var(--ch-muted); }
.kebab-item.danger > i { color: var(--ch-danger); }

/* ---------- 19b. Client / lead profile ---------- */
.profile-offcanvas { width: 760px !important; max-width: 100vw; background: var(--ch-bg); }
.profile-hero {
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem; flex-wrap: wrap;
  padding: 1rem 1.15rem;
  background: var(--ch-surface);
  border-bottom: 1px solid var(--ch-border);
}
.profile-chips { display: flex; gap: .4rem; flex-wrap: wrap; align-items: center; }
.profile-actions { display: flex; gap: .4rem; flex-wrap: wrap; }
.profile-content { padding: 1.15rem; }
.profile-group + .profile-group { margin-top: 1.25rem; }
.profile-fields {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: .1rem .75rem; margin: .6rem 0 0;
}
.profile-field { padding: .45rem 0; border-bottom: 1px dashed var(--ch-border-soft); min-width: 0; }
.profile-field-long { grid-column: 1 / -1; }
.profile-field dt { font-size: .7rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--ch-muted); }
.profile-field dd { margin: .15rem 0 0; font-size: .875rem; word-break: break-word; white-space: pre-wrap; }
.profile-note-block {
  background: var(--ch-surface-soft); border: 1px solid var(--ch-border);
  border-radius: var(--ch-radius-sm); padding: .85rem 1rem; margin-bottom: 1rem;
  font-size: .875rem; white-space: pre-wrap;
}

/* Interaction timeline */
.timeline { list-style: none; margin: 0; padding: .25rem 0 0 0; }
.timeline-item { position: relative; display: flex; gap: .75rem; padding: 0 0 1.1rem; }
.timeline-item::before {
  content: ""; position: absolute; left: 13px; top: 30px; bottom: 0;
  width: 1px; background: var(--ch-border);
}
.timeline-item:last-child::before { display: none; }
.timeline-dot {
  flex: 0 0 auto; width: 28px; height: 28px; border-radius: 50%;
  display: inline-grid; place-content: center;
  background: var(--ch-surface-soft); border: 1px solid var(--ch-border);
  color: var(--ch-muted); font-size: .7rem;
}
.timeline-sent .timeline-dot { border-color: var(--ch-brand); color: var(--ch-brand); }
.timeline-note .timeline-dot { border-color: var(--ch-cyan); color: var(--ch-cyan); }
.timeline-body { min-width: 0; flex: 1; }
.timeline-head { display: flex; align-items: center; gap: .4rem; flex-wrap: wrap; font-size: .875rem; }
.timeline-date { color: var(--ch-muted); font-size: .75rem; margin-left: auto; }
.timeline-text { margin: .2rem 0 0; font-size: .85rem; color: var(--ch-muted); white-space: pre-wrap; word-break: break-word; }

/* SweetAlert2 controls used by the interaction form */
.swal2-select, .swal2-textarea {
  width: 100%; margin: .25rem 0 0;
  background: var(--ch-surface); color: var(--ch-text);
  border: 1px solid var(--ch-border); border-radius: var(--ch-radius-sm);
  padding: .5rem .6rem; font-size: .9rem; font-family: inherit;
}
.swal2-textarea { min-height: 88px; resize: vertical; }
.swal-form-check {
  display: flex; align-items: center; gap: .4rem;
  margin-top: .5rem; font-size: .82rem; color: var(--ch-muted);
}

/* ---------- 20. Contextual help ---------- */
.help-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 15px; height: 15px; margin-left: .35rem;
  padding: 0; border: 1px solid var(--ch-border);
  border-radius: 50%; background: transparent;
  color: var(--ch-muted); font-size: .6rem; font-weight: 800;
  line-height: 1; cursor: help; vertical-align: middle;
}
.help-btn:hover,
.help-btn:focus-visible,
.help-btn[aria-expanded="true"] {
  background: var(--ch-brand); border-color: var(--ch-brand); color: #fff;
  outline: none; box-shadow: 0 0 0 .18rem rgba(11, 140, 177, .22);
}
#helpPopover {
  position: fixed;
  background: var(--ch-elevated);
  border: 1px solid var(--ch-border);
  border-radius: var(--ch-radius);
  box-shadow: var(--ch-shadow-lg);
  padding: .7rem .9rem;
  font-size: .8rem;
  color: var(--ch-text);
  max-width: 320px;
  z-index: 1080;
}

/* ---------- 21. SweetAlert2 theming ---------- */
.swal2-popup {
  background: var(--ch-surface);
  color: var(--ch-text);
  border: 1px solid var(--ch-border);
  border-radius: var(--ch-radius-lg);
  font-family: var(--ch-font-sans);
}
.swal2-title { color: var(--ch-text); font-size: 1.15rem; font-weight: 750; }
.swal2-html-container { color: var(--ch-muted); font-size: .9rem; }
.swal2-input, .swal2-textarea {
  background: var(--ch-surface);
  color: var(--ch-text);
  border: 1px solid var(--ch-border);
  border-radius: var(--ch-radius-sm);
  font-size: .9rem;
  box-shadow: none;
}
.swal2-input:focus, .swal2-textarea:focus { border-color: var(--ch-brand); box-shadow: 0 0 0 .2rem rgba(11,140,177,.18); }
.swal2-styled.swal2-confirm {
  background: var(--ch-brand) !important;
  border-radius: var(--ch-radius-sm) !important;
  font-weight: 650;
}
.swal2-styled.swal2-confirm:focus { box-shadow: 0 0 0 .2rem rgba(11,140,177,.35) !important; }
/* Destructive confirmations remain red instead of using the brand colour. */
.swal2-styled.swal2-confirm.swal2-danger { background: var(--ch-danger) !important; color: #fff !important; }
.swal2-styled.swal2-confirm.swal2-danger:focus { box-shadow: 0 0 0 .2rem rgba(229, 72, 77, .35) !important; }
.swal2-styled.swal2-deny { background: var(--ch-danger) !important; border-radius: var(--ch-radius-sm) !important; }
.swal2-styled.swal2-cancel {
  background: transparent !important;
  border: 1px solid var(--ch-border) !important;
  color: var(--ch-text) !important;
  border-radius: var(--ch-radius-sm) !important;
}
/* Multi-field SweetAlert2 forms (e.g. "mark bonus as sent") */
.swal-form { text-align: left; padding: 0 .5rem; }
.swal-form-label {
  display: block;
  font-size: .74rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--ch-muted);
  margin: .6rem 0 0;
}
.swal-form .swal2-input { margin: .25rem 0 0; width: 100%; }
.swal-form-hint { margin: 0 0 .5rem; font-weight: 700; color: var(--ch-text); }
.swal-form-optional { color: var(--ch-muted); font-weight: 400; text-transform: none; letter-spacing: 0; }

.swal2-toast {
  background: var(--ch-elevated) !important;
  color: var(--ch-text) !important;
  border: 1px solid var(--ch-border) !important;
  box-shadow: var(--ch-shadow) !important;
}
.swal2-toast .swal2-title { color: var(--ch-text); font-size: .85rem; font-weight: 600; }
.swal2-container { z-index: 2000; }

/* Semantic toast colours: green = success, red = error/requirement,
   amber = warning, cyan = info. */
.swal2-toast.ch-toast { border-left-width: 4px !important; border-left-style: solid !important; }
.ch-toast-success { border-left-color: var(--ch-success) !important; }
.ch-toast-error { border-left-color: var(--ch-danger) !important; }
.ch-toast-warning { border-left-color: var(--ch-warning) !important; }
.ch-toast-info { border-left-color: var(--ch-cyan) !important; }
[data-bs-theme="dark"] .ch-toast-success { border-left-color: var(--ch-green) !important; }
[data-bs-theme="dark"] .ch-toast-warning { border-left-color: var(--ch-gold) !important; }

.ch-toast-success .swal2-timer-progress-bar { background: var(--ch-success); }
.ch-toast-error .swal2-timer-progress-bar { background: var(--ch-danger); }
.ch-toast-warning .swal2-timer-progress-bar { background: var(--ch-warning); }
.ch-toast-info .swal2-timer-progress-bar { background: var(--ch-cyan); }
.swal2-timer-progress-bar { background: var(--ch-brand); }

/* ---------- 22. Utilities ---------- */
.min-w-0 { min-width: 0; }
[hidden] { display: none !important; }

/* ---------- 23. Kanban Board ---------- */
.kanban-board {
  display: flex;
  gap: 1rem;
  overflow-x: auto;
  min-height: 400px;
  padding-bottom: 1rem;
}
.kanban-column {
  flex: 0 0 280px;
  background: var(--ch-bg);
  border-radius: var(--ch-radius);
  border: 1px solid var(--ch-border);
  display: flex;
  flex-direction: column;
  max-height: 600px;
}
.kanban-header {
  padding: 0.75rem 1rem;
  font-weight: 600;
  border-bottom: 1px solid var(--ch-border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--ch-elevated);
  border-top-left-radius: var(--ch-radius);
  border-top-right-radius: var(--ch-radius);
}
.kanban-header .badge {
  font-size: 0.75rem;
}
.kanban-cards {
  padding: 0.5rem;
  overflow-y: auto;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  min-height: 50px;
}
.kanban-cards.drag-over {
  background: rgba(var(--bs-primary-rgb), 0.05);
}
.kanban-card {
  background: var(--ch-elevated);
  border: 1px solid var(--ch-border);
  border-radius: var(--ch-radius);
  padding: 0.75rem;
  cursor: grab;
  box-shadow: 0 1px 2px rgba(0,0,0,0.05);
  transition: transform 0.1s, box-shadow 0.1s;
}
.kanban-card:active {
  cursor: grabbing;
}
.kanban-card.dragging {
  opacity: 0.5;
}
.kanban-card-title {
  font-weight: 600;
  font-size: 0.9rem;
  margin-bottom: 0.25rem;
}
.kanban-card-meta {
  font-size: 0.8rem;
  color: var(--ch-text-muted);
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}
.kanban-card-amount {
  font-weight: 600;
  color: var(--ch-text);
}

/* Service selection pills used when a client buys multiple services. */
.service-pill-grid {
  display: flex;
  flex-wrap: wrap;
  gap: .35rem;
}
.service-pill {
  display: inline-flex;
  flex: 0 0 auto;
  margin: 0;
  cursor: pointer;
}
.service-pill input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}
.service-pill-body {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  width: fit-content;
  max-width: 100%;
  min-height: 0;
  padding: .32rem .65rem;
  border: 1px solid var(--ch-border);
  border-radius: 999px;
  background: var(--ch-surface);
  transition: border-color .15s ease, box-shadow .15s ease, background .15s ease, transform .15s ease;
}
.service-pill-body strong {
  font-size: .82rem;
  font-weight: 600;
  color: var(--ch-text);
  white-space: nowrap;
}
.service-pill-body small {
  font-size: .72rem;
  color: var(--ch-text-muted);
  line-height: 1.2;
  white-space: nowrap;
}
.service-pill input:checked + .service-pill-body {
  border-color: var(--ch-brand);
  box-shadow: 0 0 0 1px rgba(var(--bs-primary-rgb), .25);
  background: rgba(var(--bs-primary-rgb), .08);
}
.service-pill:hover .service-pill-body {
  transform: translateY(-1px);
}

.client-service-details {
  display: grid;
  gap: .75rem;
}
.client-service-row {
  padding: .75rem;
  border: 1px solid var(--ch-border);
  border-radius: var(--ch-radius-sm);
  background: rgba(var(--bs-primary-rgb), .025);
}
.client-service-row-heading {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: .35rem .65rem;
  margin-bottom: .65rem;
}
.client-service-row-heading strong {
  font-size: .9rem;
}
.client-service-row-heading span {
  color: var(--ch-text-muted);
  font-size: .72rem;
}
.client-service-state {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  padding: .15rem .42rem;
  border: 1px solid var(--ch-border);
  border-radius: 999px;
  color: var(--ch-text);
  font-size: .68rem;
  line-height: 1.15;
}
.client-service-chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: .35rem;
  margin-bottom: .7rem;
}
.client-service-money-chip {
  display: inline-flex;
  align-items: baseline;
  gap: .35rem;
  padding: .2rem .5rem;
  border: 1px solid var(--ch-border);
  border-radius: 999px;
  background: rgba(var(--bs-primary-rgb), .06);
  color: var(--ch-text);
  font-size: .72rem;
  line-height: 1.1;
}
.client-service-money-chip span {
  color: var(--ch-text-muted);
  font-size: .68rem;
}
.client-service-money-chip strong {
  font-size: .75rem;
}
.client-service-static {
  display: inline-flex;
  min-height: 38px;
  align-items: center;
  width: 100%;
  padding: .45rem .65rem;
  border: 1px solid var(--ch-border);
  border-radius: var(--ch-radius-sm);
  background: rgba(var(--bs-primary-rgb), .03);
  color: var(--ch-text);
  font-size: .85rem;
}
.client-service-row-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(130px, 1fr));
  gap: .55rem;
}
.client-service-row-grid label {
  min-width: 0;
}
.client-service-row-grid label > span {
  display: block;
  margin: 0 0 .24rem;
  color: var(--ch-text-muted);
  font-size: .68rem;
  font-weight: 700;
}
.client-service-notes {
  grid-column: span 2;
}
.client-service-state-active {
  border-color: rgba(57, 217, 138, .35);
  background: rgba(57, 217, 138, .1);
}
.client-service-state-stopped,
.client-service-state-expired,
.client-service-state-cancelled {
  color: var(--ch-text-muted);
  text-decoration: line-through;
}
@media (max-width: 991.98px) {
  .client-service-row-grid { grid-template-columns: repeat(2, minmax(130px, 1fr)); }
}
@media (max-width: 575.98px) {
  .client-service-row-grid { grid-template-columns: 1fr; }
  .client-service-notes { grid-column: auto; }
}

.affiliate-directory {
  width: min(1180px, calc(100% - 2rem));
  margin: 0 auto;
  padding: clamp(2rem, 6vw, 5rem) 0;
}
.affiliate-hero {
  max-width: 760px;
  margin-bottom: 2rem;
}
.affiliate-hero h1 {
  margin-bottom: .75rem;
  font-size: clamp(2rem, 5vw, 3.75rem);
  line-height: 1.02;
}
.affiliate-hero > p:last-child {
  color: var(--ch-text-muted);
  font-size: 1.05rem;
}
.affiliate-company-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 360px), 1fr));
  gap: 1rem;
  margin-top: 1rem;
}
.affiliate-company-card {
  padding: 1.1rem;
  border: 1px solid var(--ch-border);
  border-radius: var(--ch-radius);
  background: var(--ch-surface);
  box-shadow: var(--ch-shadow-soft);
}
.affiliate-company-heading {
  display: flex;
  align-items: center;
  gap: .75rem;
  margin-bottom: 1rem;
}
.affiliate-company-logo {
  display: inline-flex;
  flex: 0 0 auto;
  border-radius: 12px;
  text-decoration: none;
}
.affiliate-company-logo:hover .company-logo-preview {
  border-color: var(--ch-brand);
  box-shadow: 0 0 0 2px rgba(var(--bs-primary-rgb), .16);
}
.affiliate-company-logo:focus-visible {
  outline: 2px solid var(--ch-brand);
  outline-offset: 2px;
}
.affiliate-company-heading h2 {
  margin: 0 0 .15rem;
  font-size: 1.1rem;
}
.affiliate-company-heading p {
  margin: 0;
  color: var(--ch-text-muted);
  font-size: .78rem;
}
.affiliate-services-dropdown {
  border: 1px solid var(--ch-border);
  border-radius: var(--ch-radius-sm);
  background: var(--ch-surface-soft);
}
.affiliate-services-dropdown > summary {
  display: flex;
  align-items: center;
  gap: .55rem;
  min-height: 42px;
  padding: .6rem .7rem;
  cursor: pointer;
  list-style: none;
  color: var(--ch-text);
  font-size: .78rem;
  font-weight: 700;
}
.affiliate-services-dropdown > summary::-webkit-details-marker { display: none; }
.affiliate-services-dropdown > summary > span:first-child {
  display: inline-flex;
  align-items: center;
  gap: .45rem;
  min-width: 0;
}
.affiliate-services-dropdown > summary > span:first-child i { color: var(--ch-brand); }
.affiliate-services-dropdown > summary:focus-visible {
  outline: 2px solid var(--ch-brand);
  outline-offset: 2px;
  border-radius: var(--ch-radius-sm);
}
.affiliate-service-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.55rem;
  height: 1.35rem;
  margin-left: auto;
  padding-inline: .4rem;
  border-radius: 999px;
  background: rgba(var(--bs-primary-rgb), .12);
  color: var(--ch-brand);
  font-size: .68rem;
}
.affiliate-services-chevron {
  color: var(--ch-text-muted);
  font-size: .68rem;
  transition: transform .18s ease;
}
.affiliate-services-dropdown[open] .affiliate-services-chevron { transform: rotate(180deg); }
.affiliate-services-panel {
  max-height: 300px;
  overflow-y: auto;
  padding: 0 .6rem .6rem;
  border-top: 1px solid var(--ch-border-soft);
}
.affiliate-services-panel .affiliate-offer-list { padding-top: .6rem; }
.affiliate-services-panel > .text-muted { padding: .65rem .1rem .05rem; }
.affiliate-offer-list {
  display: grid;
  gap: .5rem;
}
.affiliate-offer {
  display: grid;
  grid-template-columns: minmax(120px, 1fr) auto auto;
  align-items: center;
  gap: .4rem;
  padding: .55rem;
  border: 1px solid var(--ch-border);
  border-radius: var(--ch-radius-sm);
}
.affiliate-offer > div {
  display: grid;
  min-width: 0;
}
.affiliate-offer > div strong,
.affiliate-offer > div small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.affiliate-offer > div small {
  color: var(--ch-text-muted);
  font-size: .68rem;
}
.affiliate-rate {
  display: inline-flex;
  width: fit-content;
  padding: .18rem .42rem;
  border-radius: 999px;
  font-size: .66rem;
  font-weight: 700;
  white-space: nowrap;
}
.affiliate-rate-once {
  background: rgba(var(--bs-primary-rgb), .11);
  color: var(--ch-brand);
}
.affiliate-rate-recurring {
  background: rgba(216, 166, 44, .15);
  color: var(--ch-warning);
}
.affiliate-success {
  display: grid;
  justify-items: center;
  gap: .75rem;
  padding: 1rem;
  text-align: center;
}
.affiliate-success > i {
  color: var(--ch-success);
  font-size: 2.4rem;
}
@media (max-width: 575.98px) {
  .affiliate-offer { grid-template-columns: 1fr auto; }
  .affiliate-offer > div { grid-column: 1 / -1; }
}

/* Tiny accordion-style explainer rows used in menus. */
.company-accordion-button {
  width: 100%;
  display: flex;
  align-items: center;
  gap: .35rem;
  padding: .5rem .75rem;
  border: 0;
  background: transparent;
  color: var(--ch-text);
  box-shadow: none;
}
.company-accordion-button::after {
  display: none;
}
.company-accordion-button:hover,
.company-accordion-button:not(.collapsed) {
  background: transparent;
  color: var(--ch-text);
  box-shadow: none;
}
