/* Growave CRM — new section shell (light theme), styled toward the design mockups.
   Scoped to pages using the `crm` layout; legacy pages are unaffected. */

:root {
  --crm-sidebar-w: 232px;
  --crm-bg: #f7f8fa;
  --crm-surface: #ffffff;
  --crm-border: #e9eaee;
  --crm-text: #1a1f29;
  --crm-text-muted: #8a909c;
  --crm-hover: #f2f3f5;
  --crm-active: #eef0f3;
  --crm-logo: #f5c518;
}

body.crm-app {
  margin: 0;
  background: var(--crm-bg);
  color: var(--crm-text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 14px;
}

/* Sidebar */
.crm-sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: var(--crm-sidebar-w);
  height: 100vh;
  background: var(--crm-surface);
  border-right: 1px solid var(--crm-border);
  display: flex;
  flex-direction: column;
  padding: 14px 12px;
  box-sizing: border-box;
}

.crm-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 8px 16px;
  text-decoration: none;
  color: var(--crm-text);
}
.crm-brand:hover { text-decoration: none; color: var(--crm-text); }

.crm-brand__logo {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 7px;
  background: var(--crm-logo);
  color: #1a1f29;
  font-weight: 700;
  font-size: 13px;
}
.crm-brand__name { font-weight: 700; letter-spacing: .2px; }

/* Nav */
.crm-nav { display: flex; flex-direction: column; gap: 1px; flex: 1; }

.crm-nav__label {
  text-transform: uppercase;
  font-size: 11px;
  letter-spacing: .6px;
  color: var(--crm-text-muted);
  padding: 14px 10px 6px;
}

.crm-nav__item {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 8px 10px;
  border-radius: 8px;
  color: #4b515c;
  text-decoration: none;
  font-weight: 500;
}
.crm-nav__item:hover { background: var(--crm-hover); color: var(--crm-text); text-decoration: none; }
.crm-nav__item.is-active { background: var(--crm-active); color: var(--crm-text); font-weight: 600; }

.crm-nav__icon { width: 18px; text-align: center; font-size: 15px; }

.crm-nav__item.is-disabled { color: #c2c6cf; cursor: default; }
.crm-nav__item.is-disabled:hover { background: transparent; color: #c2c6cf; }

.crm-nav__soon {
  margin-left: auto;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .4px;
  color: #c2c6cf;
  border: 1px solid #e9eaee;
  border-radius: 6px;
  padding: 1px 5px;
}

/* Nav group with a submenu (e.g. Agencies → Referrals / Payouts). Mantle-style: sub-items reveal
   only while you're inside the section (server adds .is-open on .crm-navgroup). No arrow, no JS. */
.crm-navgroup { display: flex; flex-direction: column; gap: 1px; }
.crm-nav__sub {
  display: flex;
  flex-direction: column;
  gap: 1px;
  overflow: hidden;
  max-height: 0;
}
.crm-navgroup.is-open .crm-nav__sub { max-height: 240px; }
/* Sub-items keep their icon; a small extra left indent shows they're nested under the parent. */
.crm-nav__item--sub { padding-left: 22px; }

/* Sidebar footer */
.crm-sidebar__footer { border-top: 1px solid var(--crm-border); padding-top: 8px; margin-top: 8px; }

.crm-user { display: flex; align-items: center; gap: 10px; padding: 8px 10px 2px; }
.crm-user__avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--crm-active);
  color: var(--crm-text-muted);
}
.crm-user__name { font-weight: 600; font-size: 13px; }
.crm-user__org { color: var(--crm-text-muted); font-size: 12px; }

/* Main content */
.crm-main {
  margin-left: var(--crm-sidebar-w);
  padding: 22px;
  box-sizing: border-box;
}

.crm-card {
  background: var(--crm-surface);
  border: 1px solid var(--crm-border);
  border-radius: 12px;
  padding: 22px;
  margin-bottom: 16px;
}

/* Page header (title + search) */
.crm-page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}
.crm-page-head h1 { font-size: 22px; font-weight: 700; margin: 0; }

.crm-search { position: relative; }
.crm-search__icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--crm-text-muted);
}
.crm-search input {
  width: 300px;
  max-width: 100%;
  padding: 9px 32px 9px 34px;
  border: 1px solid var(--crm-border);
  border-radius: 9px;
  font-size: 14px;
  outline: none;
}
.crm-search input:focus { border-color: #c7cad1; }
.crm-search__reset {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--crm-text-muted);
}

.crm-filterbar {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 16px;
}
.crm-filterbar__search input { width: 100%; }
/* Agencies list: breathing room between the stat strip and the search/filter bar */
.crm-summary + .crm-filterbar { margin-top: 18px; }

/* Mantle-style filter pills */
.crm-fpills {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}
.crm-fpill { position: relative; }
.crm-fpill__btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border: 1px solid var(--crm-border);
  border-radius: 999px;
  background: #fff;
  font-size: 13px;
  color: var(--crm-text-muted);
  cursor: pointer;
  white-space: nowrap;
  list-style: none;
  user-select: none;
}
.crm-fpill__btn::-webkit-details-marker { display: none; }
.crm-fpill__btn:hover { border-color: #c7cad1; }
.crm-fpill__plus { font-weight: 600; }
.crm-fpill__caret { font-size: 12px; transition: transform .15s; }
.crm-fpill[open] > .crm-fpill__btn { border-color: #c7cad1; }
.crm-fpill[open] > .crm-fpill__btn .crm-fpill__caret { transform: rotate(180deg); }
.crm-fpill.is-active > .crm-fpill__btn {
  background: var(--crm-active);
  border-color: #c2c6cf;
  color: var(--crm-text);
  font-weight: 500;
}
.crm-fpill__count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--crm-text);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  line-height: 1;
}

.crm-fpop {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  z-index: 30;
  min-width: 200px;
  padding: 10px;
  background: #fff;
  border: 1px solid var(--crm-border);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .12);
}
.crm-fpop--wide { min-width: 240px; }
/* Sort pill sits at the far right of the pills row, so its popup opens leftwards */
.crm-fpill--sort { margin-left: auto; }
.crm-fpop--right { left: auto; right: 0; }
.crm-fsort {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 8px;
  border-radius: 6px;
  font-size: 14px;
  color: var(--crm-text);
  text-decoration: none;
  white-space: nowrap;
}
.crm-fsort:hover { background: #f7f8fa; color: var(--crm-text); text-decoration: none; }
.crm-fsort.is-on { font-weight: 500; }
.crm-fsort__tick { visibility: hidden; font-size: 11px; color: var(--crm-text-muted); }
.crm-fsort.is-on .crm-fsort__tick { visibility: visible; }
.crm-fpop__title {
  font-size: 12px;
  color: var(--crm-text-muted);
  margin-bottom: 6px;
}
.crm-fpop__opt {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 4px;
  font-size: 14px;
  cursor: pointer;
}
.crm-fpop__opt:hover { background: #f7f8fa; border-radius: 6px; }
.crm-fpop__field { display: block; margin-bottom: 10px; }
.crm-fpop__field:last-child { margin-bottom: 0; }
.crm-fpop__field select { width: 100%; }
.crm-fpop__range {
  display: flex;
  align-items: center;
  gap: 6px;
}
.crm-fpop__range input { width: 84px; }
.crm-fpop__dash { color: var(--crm-text-muted); }
.crm-fpop__foot {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 10px;
}
.crm-fpop__clear { background: none; border: 0; cursor: pointer; padding: 0; }

/* Multi-select checkbox filter pill (Mantle-style: header + scrollable single-column list + footer) */
.crm-cf { width: 260px; padding: 0; overflow: hidden; }
.crm-cf__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px 10px;
  border-bottom: 1px solid var(--crm-border);
}
.crm-cf__title { font-size: 14px; font-weight: 600; color: var(--crm-text); }
.crm-cf__x {
  background: none;
  border: 0;
  cursor: pointer;
  padding: 0 2px;
  font-size: 20px;
  line-height: 1;
  color: var(--crm-text-muted);
}
.crm-cf__x:hover { color: var(--crm-text); }
.crm-cf__list { max-height: 320px; overflow-y: auto; padding: 6px; }
.crm-cf__item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  font-size: 14px;
  color: var(--crm-text);
  cursor: pointer;
  border-radius: 8px;
}
.crm-cf__item:hover { background: #f7f8fa; }
.crm-cf__item input {
  flex: 0 0 auto;
  width: 16px;
  height: 16px;
  accent-color: #f5a623;
  cursor: pointer;
}
.crm-cf__item span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.crm-cf__foot {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-top: 1px solid var(--crm-border);
}
.crm-cf__clear { background: none; border: 0; cursor: pointer; padding: 0; }

.crm-fpill-reset {
  display: inline-flex;
  align-items: center;
  color: var(--crm-text-muted);
  padding: 6px;
}
.crm-fpill-reset:hover { color: #d23f3f; }

.crm-list-meta {
  color: var(--crm-text-muted);
  font-size: 13px;
  margin-bottom: 12px;
}

.crm-link {
  color: var(--crm-link, #2f6df6);
  text-decoration: none;
  font-size: 13px;
}
.crm-link:hover { text-decoration: underline; }

/* Table */
.crm-table-wrap { overflow-x: auto; }
.crm-table { width: 100%; border-collapse: collapse; }
.crm-table th {
  text-align: left;
  text-transform: uppercase;
  font-size: 11px;
  letter-spacing: .5px;
  font-weight: 600;
  color: var(--crm-text-muted);
  padding: 0 10px 10px;
  border-bottom: 1px solid var(--crm-border);
  white-space: nowrap;
}
.crm-table td {
  padding: 12px 10px;
  border-bottom: 1px solid var(--crm-border);
  vertical-align: middle;
}
.crm-table tbody tr:hover { background: var(--crm-bg); }

.crm-name { display: inline-flex; align-items: center; gap: 11px; text-decoration: none; }
.crm-name:hover { text-decoration: none; }
.crm-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--crm-active);
  color: #6b7280;
  font-weight: 700;
  flex-shrink: 0;
}
.crm-name__text { display: flex; flex-direction: column; line-height: 1.3; }
.crm-name__title { font-weight: 600; color: #b45309; }
.crm-name:hover .crm-name__title { color: #92400e; }
.crm-name__sub { color: var(--crm-text-muted); font-size: 12px; overflow-wrap: break-word; word-break: break-word; }

.crm-muted { color: var(--crm-text-muted); }

/* Status badges */
.crm-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 600;
  background: #f0f1f3;
  color: #6b7280;
}
.crm-badge--active, .crm-badge--installed, .crm-badge--transaction, .crm-badge--subscribed { background: #e7f6ec; color: #1f9d57; }
.crm-badge--losing, .crm-badge--pending, .crm-badge--usage, .crm-badge--canceled { background: #fdf1e7; color: #c77700; }
.crm-badge--unavailable, .crm-badge--cancelled, .crm-badge--lost { background: #fdecec; color: #d14343; }
.crm-badge--free, .crm-badge--disabled { background: #eef1f4; color: #5f6b7a; }

/* Agency country — click-to-edit cell in the Agencies list. The control is a real <button> (keyboard
   reachable), styled to read as a table value rather than a form button. */
/* Anchors the open editor below, and keeps a floor under the column so emptying the cell cannot make
   the table reflow either. */
.crm-country-cell { white-space: nowrap; position: relative; min-width: 64px; }
.crm-country {
  display: inline-block;
  min-width: 34px;
  padding: 3px 8px;
  border: 1px solid transparent;
  border-radius: 8px;
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.5;
  text-align: center;
  color: var(--crm-text);
  background: #f0f1f3;
  cursor: pointer;
}
.crm-country:hover { border-color: var(--crm-border); background: var(--crm-hover); }
.crm-country:focus-visible { outline: 2px solid var(--crm-text); outline-offset: 1px; }
/* Guessed, not yet confirmed by a partner manager (shown with a trailing "?") */
.crm-country.is-guess { background: #fdf1e7; color: #c77700; }
.crm-country--empty { background: transparent; color: #c2c6cf; font-weight: 500; }
/* Floats over the neighbouring cells instead of widening its own: a 190px control in a 40px column
   would otherwise re-lay-out every row while a manager works the queue. width:auto undoes the 100%
   .crm-input gives it, which here would resolve against the narrow cell. */
.crm-country-select {
  position: absolute;
  top: 50%;
  left: 0;
  transform: translateY(-50%);
  z-index: 5;
  width: auto;
  min-width: 190px;
  padding: 4px 6px;
  font-size: 13px;
}

/* Pagination */
.crm-pagination { display: flex; gap: 6px; margin-top: 18px; }
.crm-page {
  display: inline-flex;
  align-items: center;
  padding: 6px 11px;
  border: 1px solid var(--crm-border);
  border-radius: 8px;
  color: var(--crm-text);
  text-decoration: none;
  font-size: 13px;
}
.crm-page:hover { background: var(--crm-hover); text-decoration: none; }
.crm-page.is-current { background: var(--crm-text); color: #fff; border-color: var(--crm-text); }
.crm-page.is-disabled { color: #c2c6cf; pointer-events: none; }
.crm-page.is-gap { border-color: transparent; background: transparent; pointer-events: none; padding-left: 4px; padding-right: 4px; }

.crm-empty {
  padding: 28px;
  text-align: center;
  color: var(--crm-text-muted);
}

/* Profile */
.crm-profile-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding-bottom: 18px;
  margin-bottom: 22px;
  border-bottom: 1px solid var(--crm-border);
}
.crm-profile-head__main { display: flex; align-items: center; gap: 12px; }
.crm-profile-head__actions { display: flex; align-items: center; gap: 8px; flex: 0 0 auto; }
.crm-profile-head h1 { font-size: 22px; font-weight: 700; margin: 0; }

.crm-back {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 9px;
  border: 1px solid var(--crm-border);
  background: var(--crm-surface);
  color: var(--crm-text);
  text-decoration: none;
  flex-shrink: 0;
}
.crm-back:hover { background: var(--crm-hover); text-decoration: none; }

.crm-quick-links { display: flex; gap: 8px; flex-wrap: wrap; }
.crm-qlink {
  display: inline-flex;
  align-items: center;
  padding: 7px 12px;
  border: 1px solid var(--crm-border);
  border-radius: 8px;
  color: var(--crm-text);
  text-decoration: none;
  font-size: 13px;
  background: var(--crm-surface);
}
.crm-qlink:hover { background: var(--crm-hover); text-decoration: none; }

/* Developer Tools dropdown (CSS-only via <details>) */
.crm-dropdown { position: relative; display: inline-block; }
.crm-dropdown > summary {
  list-style: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.crm-dropdown > summary::-webkit-details-marker { display: none; }
.crm-dropdown__menu {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  z-index: 50;
  min-width: 200px;
  background: var(--crm-surface);
  border: 1px solid var(--crm-border);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .1);
  padding: 6px;
}
.crm-dropdown__item {
  display: block;
  padding: 8px 12px;
  border-radius: 7px;
  color: var(--crm-text);
  text-decoration: none;
  font-size: 13px;
}
.crm-dropdown__item:hover { background: var(--crm-hover); text-decoration: none; }

.crm-card__title { font-size: 15px; font-weight: 700; margin-bottom: 14px; }
/* Rounded amount whose exact value (with cents) sits in the title tooltip */
.crm-amount-hint { border-bottom: 1px dotted var(--crm-text-muted); cursor: help; }

/* Metric cards row (top of the Details tab) */
.crm-metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}
.crm-metric {
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: var(--crm-surface);
  border: 1px solid var(--crm-border);
  border-radius: 12px;
  padding: 16px 18px;
}
.crm-metric__label { font-size: 12px; color: var(--crm-text-muted); }
.crm-metric__value { font-size: 20px; font-weight: 700; }
.crm-metric--risk {
  background: #fdf3f2;
  border-color: #f3c9c4;
}
.crm-metric--risk .crm-metric__value { color: #c0392b; }
.crm-metric--ok .crm-metric__value { color: #1f9d57; }

/* Profile tabs (CSS-only, left rail like the mockup) */
.crm-tabs { display: flex; align-items: flex-start; gap: 18px; }
.crm-tab-radio { position: absolute; opacity: 0; pointer-events: none; }

.crm-tabs__nav {
  flex: 0 0 240px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  position: sticky;
  top: 22px;
}
.crm-tab {
  display: flex;
  align-items: flex-start;
  gap: 11px;
  padding: 12px 13px;
  border-radius: 11px;
  color: #4b515c;
  cursor: pointer;
  user-select: none;
  border: 1px solid var(--crm-border);
  background: var(--crm-surface);
}
.crm-tab:hover { border-color: #c7cad1; }
.crm-tab__icon { width: 16px; text-align: center; color: var(--crm-text-muted); margin-top: 2px; }
.crm-tab__text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.crm-tab__title { font-size: 14px; font-weight: 600; }
.crm-tab__sub {
  font-size: 12px;
  font-weight: 400;
  color: var(--crm-text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.crm-tabs__body { flex: 1 1 auto; min-width: 0; }
.crm-tab-panel { display: none; }

/* Active panel + active tab highlight (one selector pair per tab) */
#ptab-details:checked ~ .crm-tabs__body .crm-tab-panel--details,
#ptab-people:checked  ~ .crm-tabs__body .crm-tab-panel--people,
#ptab-agency:checked  ~ .crm-tabs__body .crm-tab-panel--agency,
#ptab-tickets:checked ~ .crm-tabs__body .crm-tab-panel--tickets,
#ptab-sales:checked   ~ .crm-tabs__body .crm-tab-panel--sales,
#ptab-tx:checked      ~ .crm-tabs__body .crm-tab-panel--tx { display: block; }

#ptab-details:checked ~ .crm-tabs__nav label[for="ptab-details"],
#ptab-people:checked  ~ .crm-tabs__nav label[for="ptab-people"],
#ptab-agency:checked  ~ .crm-tabs__nav label[for="ptab-agency"],
#ptab-tickets:checked ~ .crm-tabs__nav label[for="ptab-tickets"],
#ptab-sales:checked   ~ .crm-tabs__nav label[for="ptab-sales"],
#ptab-tx:checked      ~ .crm-tabs__nav label[for="ptab-tx"] {
  background: #fdf6da;
  border-color: #f3e4a6;
  color: var(--crm-text);
}
#ptab-details:checked ~ .crm-tabs__nav label[for="ptab-details"] .crm-tab__title,
#ptab-people:checked  ~ .crm-tabs__nav label[for="ptab-people"] .crm-tab__title,
#ptab-agency:checked  ~ .crm-tabs__nav label[for="ptab-agency"] .crm-tab__title,
#ptab-tickets:checked ~ .crm-tabs__nav label[for="ptab-tickets"] .crm-tab__title,
#ptab-sales:checked   ~ .crm-tabs__nav label[for="ptab-sales"] .crm-tab__title,
#ptab-tx:checked      ~ .crm-tabs__nav label[for="ptab-tx"] .crm-tab__title { font-weight: 600; }
#ptab-details:checked ~ .crm-tabs__nav label[for="ptab-details"] .crm-tab__icon,
#ptab-people:checked  ~ .crm-tabs__nav label[for="ptab-people"] .crm-tab__icon,
#ptab-agency:checked  ~ .crm-tabs__nav label[for="ptab-agency"] .crm-tab__icon,
#ptab-tickets:checked ~ .crm-tabs__nav label[for="ptab-tickets"] .crm-tab__icon,
#ptab-sales:checked   ~ .crm-tabs__nav label[for="ptab-sales"] .crm-tab__icon,
#ptab-tx:checked      ~ .crm-tabs__nav label[for="ptab-tx"] .crm-tab__icon { color: #c8920a; }

/* Agency profile tabs (same mechanism as ptab-*, distinct ids) */
#atab-referrals:checked   ~ .crm-tabs__body .crm-tab-panel--referrals,
#atab-commissions:checked ~ .crm-tabs__body .crm-tab-panel--commissions,
#atab-payouts:checked     ~ .crm-tabs__body .crm-tab-panel--payouts { display: block; }

#atab-referrals:checked   ~ .crm-tabs__nav label[for="atab-referrals"],
#atab-commissions:checked ~ .crm-tabs__nav label[for="atab-commissions"],
#atab-payouts:checked     ~ .crm-tabs__nav label[for="atab-payouts"] {
  background: #fdf6da;
  border-color: #f3e4a6;
  color: var(--crm-text);
}
#atab-referrals:checked   ~ .crm-tabs__nav label[for="atab-referrals"] .crm-tab__title,
#atab-commissions:checked ~ .crm-tabs__nav label[for="atab-commissions"] .crm-tab__title,
#atab-payouts:checked     ~ .crm-tabs__nav label[for="atab-payouts"] .crm-tab__title { font-weight: 600; }
#atab-referrals:checked   ~ .crm-tabs__nav label[for="atab-referrals"] .crm-tab__icon,
#atab-commissions:checked ~ .crm-tabs__nav label[for="atab-commissions"] .crm-tab__icon,
#atab-payouts:checked     ~ .crm-tabs__nav label[for="atab-payouts"] .crm-tab__icon { color: #c8920a; }

@media (max-width: 768px) {
  .crm-tabs { flex-direction: column; }
  .crm-tabs__nav {
    flex: 0 0 auto;          /* reset desktop flex-basis (was 230px → became height in column) */
    flex-direction: row;
    flex-wrap: nowrap;
    align-items: center;
    overflow-x: auto;
    width: 100%;
    position: static;
    gap: 6px;
    padding-bottom: 4px;
    margin-bottom: 12px;
  }
  .crm-tab {
    white-space: nowrap;
    flex: 0 0 auto;
    border: 1px solid var(--crm-border);
  }
  .crm-tabs__body { width: 100%; }

  .crm-page-head { flex-direction: column; align-items: stretch; }
  .crm-filterbar__search input { width: 100%; }
  .crm-fpop { left: 0; right: auto; max-width: calc(100vw - 48px); }
  .crm-fpill--more .crm-fpop { left: 0; }
  .crm-fpill--sort { margin-left: 0; }
}

/* Agency profile: main column + info rail, tabs across the top. Scoped to .crm-aprofile /
   .crm-tabs--top so the shared .crm-tabs layout (also used by the customer profile) stays untouched. */
.crm-aprofile {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 18px;
  align-items: start;
}
.crm-aprofile__main { min-width: 0; }
.crm-aprofile__rail {
  display: flex;
  flex-direction: column;
  gap: 14px;
  position: sticky;
  top: 22px;
}
/* Long partner/company URLs must wrap inside the narrow rail, not overflow the card. */
.crm-aprofile__rail .crm-cust__url {
  display: inline-block;
  max-width: 100%;
  overflow-wrap: anywhere;
  word-break: break-word;
}
/* Rail management forms (owner / status / commission override): a bold, darker section title with
   a regular field label under it — undoing Bootstrap's label{font-weight:bold} bleed that made the
   field labels heavier than their headings. Controls stack full-width in the narrow column. */
.crm-aprofile__rail .crm-subsection__title { font-weight: 600; color: var(--crm-text); }
.crm-aprofile__rail .crm-field > span { font-weight: 400; }
.crm-aprofile__rail .crm-form { flex-direction: column; align-items: stretch; gap: 10px; }
.crm-aprofile__rail .crm-field select,
.crm-aprofile__rail .crm-field .crm-input { max-width: none; width: 100%; min-width: 0; }
.crm-aprofile__rail .crm-form > .crm-btn { margin-top: 4px; align-self: flex-start; }
.crm-tabs--top { flex-direction: column; }
.crm-tabs--top .crm-tabs__nav {
  flex: 0 0 auto;
  flex-direction: row;
  flex-wrap: wrap;
  align-items: center;
  width: 100%;
  position: static;
  gap: 8px;
  margin-bottom: 14px;
}
.crm-tabs--top .crm-tab { flex: 0 0 auto; white-space: nowrap; min-width: 168px; }
.crm-tabs--top .crm-tabs__body { width: 100%; }
@media (max-width: 900px) {
  .crm-aprofile { grid-template-columns: minmax(0, 1fr); }
  .crm-aprofile__rail { position: static; }
}

.crm-details {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px 24px;
}
.crm-detail { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.crm-detail__k { color: var(--crm-text-muted); font-size: 12px; }
.crm-detail__v { font-weight: 500; overflow-wrap: break-word; word-break: break-word; }

/* Inline "copy to clipboard" control (referral link, etc.) */
.crm-copy { display: inline-flex; align-items: flex-start; gap: 6px; max-width: 100%; }
.crm-copy__text { overflow-wrap: anywhere; word-break: break-word; }
.crm-copy__btn {
  flex: 0 0 auto;
  border: 1px solid var(--crm-border);
  background: var(--crm-surface);
  border-radius: 6px;
  padding: 3px 7px;
  cursor: pointer;
  color: var(--crm-text-muted);
  line-height: 1;
}
.crm-copy__btn:hover { color: var(--crm-text); border-color: #c7cad1; }
.crm-copy__btn.is-copied { color: #1a7f37; border-color: #1a7f37; }

/* Payout status pill (pending/processing/paid/cancelled) — its own class so it never collides with
   the agency status badge (which also has a "pending" variant). */
.crm-pstatus { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 500; white-space: nowrap; }
.crm-pstatus--pending    { background: #fff4e5; color: #8a5a00; }
.crm-pstatus--processing { background: #e7f0ff; color: #1b4fa0; }
.crm-pstatus--paid       { background: #e6f4ea; color: #1a7f37; }
.crm-pstatus--cancelled  { background: #f0f1f3; color: #8a909c; }
.crm-pstatus--approved   { background: #e6f4ea; color: #1a7f37; }
.crm-pstatus--rejected   { background: #fde8e8; color: #a32020; }

/* Payout row actions — Heymantle-style split button: [Mark as paid][▾] + dropdown menu.
   The menu is position:fixed (positioned by filters.js on open) so the scrollable table container
   never clips it. */
.crm-splitbtn { display: inline-flex; align-items: center; }
.crm-splitbtn form { display: inline-flex; margin: 0; }
.crm-splitbtn__main {
  display: inline-flex; align-items: center;
  height: 32px; padding: 0 12px;
  border: 0; cursor: pointer;
  background: var(--crm-text); color: #fff;
  font-size: 13px; font-weight: 600;
  border-radius: 8px 0 0 8px;
}
.crm-splitbtn__menu { position: relative; display: inline-flex; }
.crm-splitbtn__menu > summary { list-style: none; }
.crm-splitbtn__menu > summary::-webkit-details-marker { display: none; }
.crm-splitbtn__caret {
  display: inline-flex; align-items: center; justify-content: center;
  height: 32px; width: 30px;
  cursor: pointer;
  background: var(--crm-text); color: #fff;
  font-size: 12px;
  border-left: 1px solid rgba(255, 255, 255, .18);
  border-radius: 0 8px 8px 0;
}
.crm-splitbtn__menu[open] > .crm-splitbtn__caret i { transform: rotate(180deg); }
.crm-splitbtn__pop {
  position: fixed; z-index: 40;
  min-width: 180px; padding: 6px;
  background: #fff; border: 1px solid var(--crm-border);
  border-radius: 10px; box-shadow: 0 8px 24px rgba(0, 0, 0, .12);
}
.crm-splitbtn__pop form { display: block; margin: 0; }
.crm-menu-item {
  display: block; width: 100%; text-align: left;
  border: 0; background: none; cursor: pointer;
  padding: 8px 10px; border-radius: 6px;
  font-size: 13px; color: var(--crm-text);
}
.crm-menu-item:hover { background: var(--crm-hover); }
.crm-menu-item--danger { color: #c02b2b; }
.crm-menu-item--danger:hover { background: #fdecec; }

/* Highlight row (Plan / Churn / Agency / App review) */
.crm-hilites {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}
.crm-hilite {
  background: var(--crm-surface);
  border: 1px solid var(--crm-border);
  border-radius: 12px;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.crm-hilite__label { font-size: 12px; color: var(--crm-text-muted); }
.crm-hilite__main { font-size: 15px; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.crm-hilite__sub { font-size: 12px; color: var(--crm-text-muted); }
.crm-hilite__act { cursor: pointer; }

.crm-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--crm-text-muted); display: inline-block; flex: 0 0 auto; }
.crm-dot--ok { background: #1f9d57; }
.crm-dot--risk { background: #d14343; }
.crm-dot--muted { background: #c7cad1; }
.crm-stars { color: #f5a623; font-size: 13px; letter-spacing: 1px; white-space: nowrap; }
.crm-stars--btn { cursor: pointer; }

/* CSS-only modal (hidden checkbox toggles it) — used by the App review details */
.crm-modal-toggle { position: absolute; width: 0; height: 0; opacity: 0; pointer-events: none; }
/* Wraps a checkbox+label+modal trio so the `:checked ~ .crm-modal` sibling selector can't leak into
   a different toggle's modal when more than one such trio sits on the same page (e.g. Holidays'
   "Add holiday" and "Manage countries") — CSS sibling combinators never cross this boundary. Does
   not affect the modal's own fixed positioning/layout. */
.crm-modal-scope { display: inline-block; }
.crm-modal {
  display: none;
  position: fixed;
  top: 0; right: 0; bottom: 0; left: 0;
  z-index: 100;
  align-items: center;
  justify-content: center;
}
.crm-modal-toggle:checked ~ .crm-modal { display: flex; }
.crm-modal__backdrop { position: absolute; top: 0; right: 0; bottom: 0; left: 0; background: rgba(0, 0, 0, .4); cursor: pointer; }
.crm-modal__box {
  position: relative;
  z-index: 1;
  width: 520px;
  max-width: calc(100vw - 32px);
  background: var(--crm-surface);
  border: 1px solid var(--crm-border);
  border-radius: 14px;
  box-shadow: 0 16px 48px rgba(0, 0, 0, .2);
  overflow: hidden;
}
.crm-modal__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 15px 18px;
  border-bottom: 1px solid var(--crm-border);
  font-size: 15px;
  font-weight: 700;
}
.crm-modal__x { cursor: pointer; font-size: 20px; line-height: 1; color: var(--crm-text-muted); padding: 0 4px; }
.crm-modal__x:hover { color: var(--crm-text); }
.crm-modal__body { padding: 18px; }
.crm-modal__foot { display: flex; justify-content: flex-end; padding: 14px 18px; border-top: 1px solid var(--crm-border); }
.crm-review__title { font-size: 16px; font-weight: 700; }
.crm-review__date { font-size: 12px; color: var(--crm-text-muted); margin: 2px 0 8px; }
.crm-review__body { margin-top: 12px; line-height: 1.5; white-space: pre-wrap; overflow-wrap: break-word; }

/* Combined summary card: metric strip + highlight row share ONE card; cells go
   borderless/transparent so they read as columns, not separate cards. */
.crm-summary .crm-metrics {
  margin-bottom: 0;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 14px 10px;
}
.crm-summary .crm-metric {
  flex-direction: row;
  align-items: center;
  gap: 10px;
  padding: 2px;
  border: 0;
  background: transparent;
  border-radius: 0;
}
.crm-metric__ico {
  width: 30px;
  height: 30px;
  flex: 0 0 auto;
  border-radius: 8px;
  background: #f2f3f5;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--crm-text-muted);
  font-size: 13px;
}
.crm-metric__text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.crm-summary .crm-metric__label { font-size: 12px; }
.crm-summary .crm-metric__value { font-size: 15px; line-height: 1.3; white-space: nowrap; }
.crm-summary__sep { height: 1px; background: var(--crm-border); margin: 16px 0; }
.crm-summary .crm-hilites { margin-bottom: 0; }
.crm-summary .crm-hilite {
  padding: 2px;
  border: 0;
  background: transparent;
  border-radius: 0;
}

/* Customer details card header (shop name + external URL) */
.crm-cust__head { margin-bottom: 16px; }
.crm-cust__name { font-size: 18px; font-weight: 700; }
.crm-cust__url { font-size: 13px; color: var(--crm-text-muted); text-decoration: none; }
.crm-cust__url:hover { color: var(--crm-text); text-decoration: underline; }
.crm-cust__url i { font-size: 11px; }

/* Sub-sections inside a card (Tags / Notes placeholders) */
.crm-subsection { margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--crm-border); }
.crm-subsection__title { font-size: 11px; text-transform: uppercase; letter-spacing: .4px; color: var(--crm-text-muted); margin-bottom: 8px; }
.crm-tags { display: flex; flex-direction: column; align-items: stretch; gap: 8px; }
.crm-subsection .crm-tags__input { width: 100%; max-width: none; box-sizing: border-box; }

.crm-inline-form { margin: 0; }
.crm-select { width: 100%; max-width: 280px; }
/* Inline Industry picker inside a detail cell: reads like the other plain-text values
   (no heavy box), border only on hover/focus so the row stays visually aligned. */
.crm-detail .crm-select {
  border-color: transparent;
  background: transparent;
  padding: 1px 4px;
  margin-left: -4px;
  max-width: 100%;
  font-size: 14px;
  font-weight: 500;
  color: var(--crm-text);
  cursor: pointer;
}
.crm-detail .crm-select:hover,
.crm-detail .crm-select:focus { border-color: var(--crm-border); background: var(--crm-surface); }

.crm-notes-form { margin: 0; }
.crm-subsection .crm-notes {
  width: 100%;
  max-width: none;          /* beat .crm-input's 240px cap (defined later in file) */
  box-sizing: border-box;
  resize: vertical;
  min-height: 72px;
  font-family: inherit;
}
.crm-notes-foot { margin-top: 8px; }

.crm-empty--sm { padding: 22px; text-align: center; color: var(--crm-text-muted); }

/* Growave plan name highlighted in the left-rail summary */
.crm-tab__plan { color: #c8920a; font-weight: 600; }

.crm-chip {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 600;
  background: var(--crm-active);
  color: #4b515c;
}
.crm-chip--muted { background: #eef0f2; color: #8a9099; }
.crm-row--deleted { opacity: .55; }

/* Inline write actions (assign / remove account owner) */
.crm-alert {
  background: #fdecec;
  color: #d14343;
  border: 1px solid #f5c6c6;
  border-radius: 8px;
  padding: 9px 12px;
  margin-bottom: 14px;
  font-size: 13px;
}

.crm-cell-action { text-align: right; white-space: nowrap; }
.crm-cell-action form { display: inline; margin: 0; }

/* Deals: per-stage summary + filter row */
.crm-stage-summary {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  margin-bottom: 16px;
  padding-bottom: 4px;
}
.crm-stage-card {
  flex: 0 0 auto;
  min-width: 130px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 10px 14px;
  background: var(--crm-surface);
  border: 1px solid var(--crm-border);
  border-radius: 10px;
  text-decoration: none;
  color: var(--crm-text);
}
.crm-stage-card:hover { border-color: #c7cad1; text-decoration: none; color: var(--crm-text); }
.crm-stage-card__label { font-size: 12px; color: var(--crm-text-muted); }
.crm-stage-card__meta { font-size: 15px; font-weight: 600; }

.crm-deal-filters {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
}
.crm-deal-filters .crm-input { max-width: 170px; }

/* Deal detail page */
.crm-deal-head {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 18px;
}
.crm-deal-head h1 { font-size: 22px; font-weight: 700; margin: 0; }
.crm-deal-back {
  display: inline-flex;
  width: 32px;
  height: 32px;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--crm-border);
  border-radius: 8px;
  color: var(--crm-text);
}
.crm-deal-back:hover { background: var(--crm-hover); color: var(--crm-text); text-decoration: none; }
.crm-deal-head__edit { margin-left: auto; }

.crm-deal-grid {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 16px;
  align-items: start;
}
.crm-deal-side, .crm-deal-main { display: flex; flex-direction: column; gap: 12px; }
/* Cards in the deal columns are spaced by the flex gap only — drop the default
   card margin so the blocks don't get ~32px of double spacing between them. */
.crm-deal-side > .crm-card, .crm-deal-main > .crm-card { margin-bottom: 0; }

.crm-card__title--row { display: flex; align-items: center; justify-content: space-between; }
.crm-note { padding: 8px 0; border-bottom: 1px solid var(--crm-border); }
.crm-note__body { font-size: 14px; white-space: pre-wrap; overflow-wrap: break-word; word-break: break-word; }
.crm-note__meta { font-size: 12px; color: var(--crm-text-muted); margin-top: 3px; }
.crm-note-form { margin-top: 10px; display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
.crm-note-form textarea { width: 100%; max-width: none; resize: vertical; }

.crm-owner-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid var(--crm-border);
}
.crm-owner-row form { margin: 0; }
.crm-assign-form { margin-top: 10px; display: flex; gap: 8px; }
.crm-assign-form .crm-input { flex: 1; }
.crm-icon-btn {
  border: none;
  background: none;
  cursor: pointer;
  color: var(--crm-text-muted);
  font-size: 18px;
  line-height: 1;
  padding: 0 4px;
}
.crm-icon-btn:hover { color: #d23f3f; }

/* Timeline — shared design for BOTH the customer profile and the deal view:
   one continuous vertical spine with dots, bordered cards, hover actions. */
.crm-ctl { position: relative; }
.crm-ctl::before {
  content: '';
  position: absolute;
  left: 5px;
  top: 0;
  bottom: 0;
  width: 2px;
  background: var(--crm-border);
}
.crm-ctl-date { font-size: 12px; color: var(--crm-text-muted); margin: 16px 0 8px; padding-left: 24px; font-weight: 600; }
.crm-ctl-item { position: relative; display: flex; align-items: flex-start; padding-bottom: 8px; }
.crm-ctl-dot {
  position: relative;
  z-index: 1;
  flex: 0 0 auto;
  width: 12px;
  height: 12px;
  margin: 8px 12px 0 0;
  border-radius: 50%;
  background: var(--crm-logo);
  box-shadow: 0 0 0 3px var(--crm-surface);
}
.crm-ctl-card {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--crm-border);
  border-radius: 10px;
  background: var(--crm-surface);
}
.crm-ctl-card:hover { background: var(--crm-bg); }
.crm-ctl-body { flex: 1 1 auto; min-width: 0; }
.crm-ctl-text { font-size: 14px; color: var(--crm-text); }
.crm-ctl-actions {
  flex: 0 0 auto;
  display: flex;
  gap: 2px;
  opacity: 0;
  transition: opacity .12s ease;
}
.crm-ctl-card:hover .crm-ctl-actions,
.crm-ctl-item:focus-within .crm-ctl-actions { opacity: 1; }
.crm-ctl-act {
  border: 0;
  background: transparent;
  cursor: pointer;
  color: var(--crm-text-muted);
  padding: 3px 7px;
  border-radius: 6px;
  font-size: 13px;
  line-height: 1;
}
.crm-ctl-act:hover { background: var(--crm-hover); color: var(--crm-text); }
.crm-ctl-act--danger:hover { background: #fbeceb; color: #d23f3f; }

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

/* Stacked form (edit deal) */
.crm-stack { display: flex; flex-direction: column; gap: 14px; }
.crm-stack__field { display: flex; flex-direction: column; gap: 5px; font-weight: 400 !important; }
.crm-stack__field > span { font-size: 13px; color: var(--crm-text-muted); font-weight: 400; }
.crm-stack__field .crm-input { max-width: 320px; }
.crm-stack__field textarea.crm-input { max-width: none; width: 100%; }
/* Edit-agency modal: name/PayPal inputs span the full modal width (override the 320px stack cap). */
#edit-agency-modal .crm-stack__field .crm-input { max-width: none; }

.crm-btn-danger {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border: 1px solid #e3b7b3;
  border-radius: 9px;
  background: #fdecec;
  color: #c0392b;
  font-size: 14px;
  cursor: pointer;
}
.crm-btn-danger:hover { background: #f9dede; }

/* Deals board (kanban) */
.crm-kanban {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  padding-bottom: 8px;
  align-items: flex-start;
}
.crm-kanban__col {
  flex: 0 0 300px;
  min-width: 0; /* let the fixed 300px basis hold; otherwise a long URL's min-content stretches the column */
  background: var(--crm-bg);
  border: 2px dashed var(--crm-border);
  border-radius: 6px;
  padding: 10px;
}
.crm-kanban__col.is-over { border-color: var(--crm-logo); background: #fffdf3; }
.crm-kanban__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  padding: 2px 4px 10px;
}
.crm-kanban__title { font-weight: 600; font-size: 16px; }
.crm-kanban__meta { font-size: 12px; color: var(--crm-text-muted); white-space: nowrap; }
.crm-kanban__body {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 40px;
  /* Fixed-height, independently scrollable column — lazy load fires per stage. */
  max-height: calc(100vh - 250px);
  overflow-y: auto;
  padding-right: 4px;
}
.crm-kanban__card {
  background: var(--crm-surface);
  border: 0;
  border-radius: 6px;
  padding: 10px;
  cursor: grab;
  line-height: 1.5;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.08), 0 1px 2px rgba(15, 23, 42, 0.04);
}
.crm-kanban__card.is-dragging { opacity: .5; }
.crm-kanban__company { font-weight: 600; color: var(--crm-text); }
.crm-kanban__company:hover { text-decoration: underline; color: var(--crm-text); }
.crm-kanban__amount { font-weight: 700; margin: 6px 0 4px; }
.crm-kanban__sub { font-size: 12px; color: var(--crm-text-muted); }
/* "Acquired" / "Owner" lines — normal black text, semi-bold label */
.crm-kanban__field { font-size: 12px; color: var(--crm-text); }
.crm-kanban__flabel { font-weight: 600; }
.crm-kanban__sentinel { height: 1px; }
.crm-kanban__foot { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 8px; }

/* Follow-up next-action badge (board card + deals table) */
.crm-due {
  display: inline-block;
  font-size: 11px;
  line-height: 1;
  padding: 3px 7px;
  border-radius: 999px;
  white-space: nowrap;
  border: 1px solid transparent;
}
.crm-due--overdue  { background: #fdecea; color: #b3261e; border-color: #f6c9c4; }
.crm-due--today    { background: #fff4e0; color: #9a6700; border-color: #f3dca0; }
.crm-due--upcoming { background: #eef6ee; color: #2e7d32; border-color: #cfe6cf; }
.crm-due--open     { background: var(--crm-bg); color: var(--crm-text-muted); border-color: var(--crm-border); }
.crm-due--none     { color: var(--crm-text-muted); border: 1px dashed var(--crm-border); }

/* "Needs attention" reason chips */
.crm-reason {
  display: inline-block;
  font-size: 11px;
  line-height: 1;
  padding: 3px 7px;
  border-radius: 999px;
  margin: 0 4px 4px 0;
  border: 1px solid transparent;
}
.crm-reason--overdue { background: #fdecea; color: #b3261e; border-color: #f6c9c4; }
.crm-reason--stale   { background: #fff4e0; color: #9a6700; border-color: #f3dca0; }
.crm-reason--none    { background: var(--crm-bg); color: var(--crm-text-muted); border-color: var(--crm-border); }

/* Follow-up tasks (deal page) */
.crm-task { display: flex; gap: 8px; align-items: flex-start; padding: 6px 0; border-bottom: 1px solid var(--crm-border); }
.crm-task:last-of-type { border-bottom: 0; }
.crm-task__check {
  width: 18px; height: 18px; flex: 0 0 18px;
  border: 1.5px solid var(--crm-border); border-radius: 50%;
  background: var(--crm-surface); cursor: pointer;
  margin-top: 2px; padding: 0; line-height: 1; font-size: 11px; color: #2e7d32;
}
.crm-task__check:hover { border-color: #2e7d32; }
.crm-task__check.is-done { border-color: #2e7d32; background: #eef6ee; }
.crm-task__body { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.crm-task__title { font-size: 14px; overflow-wrap: break-word; word-break: break-word; }
.crm-task--done .crm-task__title { color: var(--crm-text-muted); text-decoration: line-through; }
.crm-task-done-head { font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--crm-text-muted); margin: 10px 0 4px; }
/* Long unbroken strings (URLs) must not stretch the fixed-width card —
   clip each line to one row with an ellipsis (Mantle-style). */
.crm-kanban__company,
.crm-kanban__card .crm-name__sub {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Add-deal modal */
.crm-head-left { display: flex; align-items: center; gap: 14px; }
.crm-modal {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 1000;
}
.crm-modal.is-open { display: block; }
.crm-modal__backdrop { position: absolute; inset: 0; background: rgba(20, 24, 32, .45); }
.crm-modal__panel {
  position: relative;
  max-width: 680px;
  margin: 40px auto;
  max-height: calc(100vh - 80px);
  display: flex;
  flex-direction: column;
  background: var(--crm-surface);
  border-radius: 14px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, .3);
}
.crm-modal__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--crm-border);
}
.crm-modal__head h2 { font-size: 18px; font-weight: 700; margin: 0; }
.crm-modal__x { border: none; background: none; font-size: 22px; line-height: 1; cursor: pointer; color: var(--crm-text-muted); }
.crm-modal__body { padding: 18px 20px; overflow-y: auto; }
.crm-modal__section { font-weight: 500; margin: 16px 0 8px; }
.crm-modal__foot {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--crm-border);
}
.crm-modal__foot--split { justify-content: space-between; align-items: center; }
.crm-modal__foot-right { display: flex; gap: 10px; order: 1; }
.crm-modal__foot-archive { order: 0; }

.crm-grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 16px; }
.crm-amount { display: flex; align-items: center; gap: 6px; }
.crm-amount .crm-input { flex: 1; }
.crm-amount__sign { color: var(--crm-text-muted); }
.crm-amount__cur {
  font-size: 12px;
  color: var(--crm-text-muted);
  border: 1px solid var(--crm-border);
  border-radius: 6px;
  padding: 4px 8px;
}
.crm-add-row {
  display: block;
  width: 100%;
  text-align: center;
  border: 1px dashed var(--crm-border);
  background: none;
  border-radius: 9px;
  padding: 9px;
  font-size: 13px;
  color: var(--crm-text-muted);
  cursor: pointer;
  margin-top: 8px;
}
.crm-add-row:hover { border-color: #c7cad1; color: var(--crm-text); }
.crm-contact-row { display: flex; gap: 8px; align-items: center; margin-top: 8px; }
.crm-contact-row .crm-input { flex: 1; }
.crm-ac {
  position: fixed;
  z-index: 1200;
  background: #fff;
  border: 1px solid var(--crm-border);
  border-radius: 8px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.12);
  max-height: 240px;
  overflow-y: auto;
}
.crm-ac__item { padding: 7px 10px; cursor: pointer; font-size: 13px; }
.crm-ac__item:hover { background: var(--crm-bg-subtle, #f4f5f7); }
.crm-ac__email { display: block; color: var(--crm-text); }
.crm-ac__meta { display: block; color: var(--crm-text-muted); font-size: 12px; }
.crm-btn-light {
  padding: 8px 16px;
  border: 1px solid var(--crm-border);
  border-radius: 9px;
  background: #fff;
  cursor: pointer;
  font-size: 14px;
}
.crm-btn-light:hover { background: var(--crm-hover); }

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

.crm-link-danger {
  background: none;
  border: 0;
  padding: 0;
  color: #d14343;
  font-size: 13px;
  cursor: pointer;
}
.crm-link-danger:hover { text-decoration: underline; }

.crm-owner-form {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--crm-border);
}
.crm-owner-form select {
  padding: 8px 10px;
  border: 1px solid var(--crm-border);
  border-radius: 8px;
  font-size: 13px;
  background: var(--crm-surface);
  outline: none;
  min-width: 180px;
}
.crm-owner-form select:focus { border-color: #c7cad1; }

.crm-btn {
  padding: 8px 16px;
  border: 0;
  border-radius: 8px;
  background: var(--crm-text);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.crm-btn:hover { background: #000; }
.crm-btn--sm { padding: 5px 12px; }

.crm-input {
  padding: 7px 10px;
  border: 1px solid var(--crm-border);
  border-radius: 8px;
  font-size: 13px;
  outline: none;
  background: var(--crm-surface);
  width: 100%;
  box-sizing: border-box;
  max-width: 240px;
}
.crm-input:focus { border-color: #c7cad1; }

.crm-check {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: #4b515c;
}

/* Toggle switch (CSS-only knob via the checkbox-hack, same trick as .crm-modal-toggle/.crm-nav-toggle) */
.crm-switch { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--crm-text); cursor: pointer; user-select: none; }
.crm-switch input { position: absolute; width: 0; height: 0; opacity: 0; }
.crm-switch__track { position: relative; width: 34px; height: 20px; border-radius: 999px; background: var(--crm-border); transition: background .15s; flex-shrink: 0; }
.crm-switch__track::after { content: ''; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0, 0, 0, .2); transition: transform .15s; }
.crm-switch input:checked ~ .crm-switch__track { background: var(--crm-text); }
.crm-switch input:checked ~ .crm-switch__track::after { transform: translateX(14px); }
/* Bare control (no label above) inside a .crm-form row — offset to the fields' input baseline like
   .crm-form > .crm-btn does, and pushed to the far right of the row via the flex auto-margin. */
.crm-form > .crm-switch { margin-top: 20px; margin-left: auto; }

/* Labeled inline form (label above field) */
.crm-form {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 12px;
  margin-top: 12px;
}
/* Bare controls (no label above) sit at the same line as labelled fields'
   inputs: offset = label line-height (16px) + field gap (4px). */
.crm-form > .crm-or,
.crm-form > .crm-field-sep,
.crm-form > .crm-btn { margin-top: 20px; }
.crm-field { display: flex; flex-direction: column; gap: 4px; }
.crm-field > span { font-size: 11px; text-transform: uppercase; letter-spacing: .4px; color: var(--crm-text-muted); white-space: nowrap; line-height: 16px; }
.crm-field select {
  height: 38px;
  padding: 0 10px;
  border: 1px solid var(--crm-border);
  border-radius: 8px;
  font-size: 13px;
  background: var(--crm-surface);
  outline: none;
  min-width: 160px;
  box-sizing: border-box;
}
.crm-field select:focus { border-color: #c7cad1; }

/* Uniform control height so the row lines up cleanly */
.crm-form .crm-input,
.crm-form .crm-field select,
.crm-form .crm-btn {
  height: 38px;
  box-sizing: border-box;
}
.crm-form .crm-input { padding-top: 0; padding-bottom: 0; }

.crm-field-sep,
.crm-or {
  display: flex;
  align-items: center;
  height: 38px;
  color: var(--crm-text-muted);
  font-size: 12px;
}
.crm-or { font-weight: 600; }

/* Sub-navigation (tabs) */
.crm-subnav { display: flex; gap: 6px; margin-bottom: 18px; }
.crm-subnav__item {
  padding: 7px 14px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  color: #4b515c;
  text-decoration: none;
}
.crm-subnav__item:hover { background: var(--crm-hover); text-decoration: none; }
.crm-subnav__item.is-active { background: var(--crm-text); color: #fff; }

/* Per-user totals row */
.crm-totals { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 16px; }
.crm-total {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 10px 14px;
  border: 1px solid var(--crm-border);
  border-radius: 10px;
  min-width: 120px;
}
.crm-total__name { font-size: 12px; color: var(--crm-text-muted); }
.crm-total__val { font-size: 17px; font-weight: 700; }

@media (max-width: 768px) {
  .crm-owner-form select { min-width: 0; flex: 1 1 100%; }
}

/* Mobile off-canvas toggle (CSS-only) — hidden on desktop */
.crm-nav-toggle { display: none; }
.crm-burger { display: none; }
.crm-nav-overlay { display: none; }

@media (max-width: 768px) {
  .crm-burger {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    position: fixed;
    top: 10px;
    left: 10px;
    z-index: 1002;
    width: 40px;
    height: 40px;
    background: var(--crm-surface);
    border: 1px solid var(--crm-border);
    border-radius: 8px;
    color: var(--crm-text);
    cursor: pointer;
  }

  .crm-sidebar {
    transform: translateX(-100%);
    transition: transform .2s ease;
    z-index: 1001;
    box-shadow: 0 0 24px rgba(0, 0, 0, .12);
  }

  .crm-nav-toggle:checked ~ .crm-sidebar { transform: translateX(0); }

  .crm-nav-toggle:checked ~ .crm-nav-overlay {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .35);
    z-index: 1000;
  }

  .crm-main {
    margin-left: 0;
    padding: 64px 14px 14px;
  }
}

/* OOF (Out-of-Office) module, phase 1 — type badge (separate from .crm-pstatus so it never collides
   with a payout/agency status of the same name), and the two-block dashboard layout. */
.crm-oofbadge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 500; white-space: nowrap; }
.crm-oofbadge--dayoff          { background: #e7f0ff; color: #1b4fa0; }
.crm-oofbadge--sick            { background: #fde8e8; color: #a32020; }
.crm-oofbadge--vacation        { background: #e6f4ea; color: #1a7f37; }
.crm-oofbadge--vacation_unpaid { background: #f0f1f3; color: #5a6068; }

.crm-oof-section { margin-bottom: 28px; }
.crm-oof-section h2 { font-size: 16px; font-weight: 600; margin: 0 0 10px; }
.crm-oof-approvals { display: flex; gap: 6px; flex-wrap: wrap; }
.crm-oof-approvals span { font-size: 11px; color: var(--crm-text-muted); }
.crm-oof-row-actions { display: flex; gap: 6px; align-items: center; }

.crm-oof-quickform { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; margin-bottom: 24px; }

.crm-oof-actions { display: flex; gap: 10px; flex-wrap: wrap; }

/* "Upcoming Holidays" section on the OOF page — the staff-count <details>/<summary> (no JS) expands
   to the full name list on click when there are more than a few people. */
.crm-holiday-staff summary { cursor: pointer; color: var(--crm-text); font-weight: 500; }
.crm-holiday-staff summary::-webkit-details-marker { display: none; }
.crm-holiday-staff[open] summary { margin-bottom: 6px; }

/* Personal vacation/sick summary at the top of the OOF page — two <details> side by side, each
   expanding (click, no JS) into its own approved-history table for the current year. */
.crm-oof-mysummary { display: flex; gap: 24px; flex-wrap: wrap; margin-bottom: 20px; padding: 12px 16px; background: var(--crm-surface); border: 1px solid var(--crm-border); border-radius: 10px; }
.crm-oof-mysummary .crm-holiday-staff { flex: 1; min-width: 220px; }

/* Settings → Two-factor authentication card. Three states in one card: off / awaiting the
   confirmation code / on, so the page never needs a second screen. */
.crm-set__head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.crm-set__head .crm-card__title { margin-bottom: 4px; }
.crm-set__sub { font-size: 13px; color: var(--crm-text-muted); max-width: 620px; }

.crm-set__row { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-top: 16px; }
.crm-set__state { display: flex; align-items: center; gap: 10px; font-size: 13px; }
.crm-set__state-ico { font-size: 15px; color: #1a7f37; }
.crm-set__state-ico.is-off { color: var(--crm-text-muted); }
.crm-set__acts { display: flex; gap: 8px; flex-wrap: wrap; }

.crm-set__done {
  display: flex; align-items: center; gap: 8px;
  margin-top: 14px; padding: 9px 12px;
  background: #edf7ef; color: #1a7f37; border: 1px solid #cfe8d5;
  border-radius: 8px; font-size: 13px;
}
.crm-set__hint { margin-top: 12px; font-size: 12px; color: var(--crm-text-muted); }
.crm-set__hint--warn { color: #8a5a00; }
.crm-set__hint i { margin-right: 4px; }

/* Setup: QR beside the numbered steps, wrapping under it on a narrow screen. */
.crm-set__setup { display: flex; align-items: flex-start; gap: 28px; flex-wrap: wrap; margin-top: 18px; }
.crm-set__qr {
  flex: 0 0 auto; padding: 10px; line-height: 0;
  background: #fff; border: 1px solid var(--crm-border); border-radius: 10px;
}
.crm-set__qr svg { display: block; width: 176px; height: 176px; }

.crm-set__steps { flex: 1 1 320px; min-width: 280px; display: flex; flex-direction: column; gap: 16px; }
.crm-set__step { display: flex; align-items: flex-start; gap: 10px; }
.crm-set__num {
  flex: 0 0 auto; width: 20px; height: 20px; margin-top: 1px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 50%; background: var(--crm-active);
  font-size: 11px; font-weight: 700; color: #4b515c;
}
.crm-set__step-body { min-width: 0; }
.crm-set__step-t { font-size: 13px; font-weight: 600; margin-bottom: 2px; }

.crm-set__keyrow { align-items: center; margin-top: 8px; }
.crm-set__key {
  display: inline-block; padding: 7px 11px;
  background: var(--crm-hover); border: 1px solid var(--crm-border); border-radius: 8px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 14px; letter-spacing: 1.5px; color: var(--crm-text);
}

.crm-set__confirm { display: flex; align-items: center; gap: 10px; margin-top: 8px; }
.crm-set__code {
  max-width: 128px; height: 38px; box-sizing: border-box;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 16px; letter-spacing: 4px; text-indent: 4px; text-align: center;
}
.crm-set__cancel {
  margin-top: 18px; padding: 0; border: 0; background: none;
  color: var(--crm-text-muted); font-size: 12px; cursor: pointer;
}
.crm-set__cancel:hover { color: var(--crm-text); text-decoration: underline; }

/* Signed-out screens (sign in + the 2FA code step). Same light shell as the rest of the new
   CRM, minus the sidebar — one centred card. */
body.crm-auth-page {
  min-height: 100vh; box-sizing: border-box; padding: 24px;
  display: flex; align-items: center; justify-content: center;
}
.crm-auth { width: 100%; max-width: 380px; }
.crm-auth__brand {
  display: flex; align-items: center; justify-content: center; gap: 9px;
  margin-bottom: 18px; font-size: 14px; font-weight: 700;
}
.crm-auth__logo {
  width: 26px; height: 26px; border-radius: 7px;
  background: var(--crm-logo); color: #1a1f29;
  display: inline-flex; align-items: center; justify-content: center; font-weight: 800;
}
.crm-auth__card {
  background: var(--crm-surface); border: 1px solid var(--crm-border);
  border-radius: 12px; padding: 26px 24px;
}
.crm-auth__title { font-size: 18px; font-weight: 700; margin: 0 0 4px; }
.crm-auth__sub { font-size: 13px; color: var(--crm-text-muted); margin: 0 0 18px; }
.crm-auth__form { display: flex; flex-direction: column; gap: 14px; }
.crm-auth__label {
  display: block; margin-bottom: 5px;
  font-size: 11px; text-transform: uppercase; letter-spacing: .4px; color: var(--crm-text-muted);
}
.crm-auth__input { width: 100%; max-width: none; height: 38px; }
.crm-auth__submit { width: 100%; height: 38px; }
.crm-auth__code {
  width: 100%; max-width: none; height: 46px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 20px; letter-spacing: 8px; text-indent: 8px; text-align: center;
}
.crm-auth__links {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  margin-top: 16px; font-size: 12px;
}
.crm-auth__links a { color: var(--crm-text-muted); text-decoration: none; }
.crm-auth__links a:hover { color: var(--crm-text); text-decoration: underline; }
.crm-auth__hint { color: var(--crm-text-muted); }
.crm-set__team { margin-top: 14px; }
.crm-set__team .crm-table td { vertical-align: middle; }

/* Settings section index — one row per screen, Mantle-style. */
.crm-setnav { padding: 6px; }
.crm-setnav__item {
  display: flex; align-items: center; gap: 14px;
  padding: 14px 16px; border-radius: 10px;
  color: var(--crm-text); text-decoration: none;
}
.crm-setnav__item + .crm-setnav__item { box-shadow: 0 -1px 0 var(--crm-border); }
.crm-setnav__item:hover { background: var(--crm-hover); text-decoration: none; color: var(--crm-text); box-shadow: none; }
.crm-setnav__item:hover + .crm-setnav__item { box-shadow: none; }
.crm-setnav__ico {
  flex: 0 0 auto; width: 34px; height: 34px; border-radius: 9px;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--crm-active); color: #4b515c; font-size: 15px;
}
.crm-setnav__body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.crm-setnav__t { font-size: 14px; font-weight: 600; }
.crm-setnav__d { font-size: 12px; color: var(--crm-text-muted); }
.crm-setnav__chev { color: var(--crm-text-muted); font-size: 16px; }

/* Signed-in-as row with the way out */
.crm-setacc { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.crm-setacc__who { display: flex; align-items: center; gap: 12px; }
.crm-setacc__name { display: block; font-size: 14px; font-weight: 600; }
.crm-setacc__mail { display: block; font-size: 12px; color: var(--crm-text-muted); }
.crm-setacc .crm-btn-light { text-decoration: none; }

/* Log out next to the user in the sidebar */
.crm-user__meta { flex: 1; min-width: 0; }
.crm-user__name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.crm-user__out {
  flex: 0 0 auto; padding: 6px; border-radius: 7px;
  color: var(--crm-text-muted); font-size: 14px; line-height: 1;
}
.crm-user__out:hover { background: var(--crm-hover); color: var(--crm-text); text-decoration: none; }

/* "You have to do this" banner at the top of the 2FA card — the reason people were sent here. */
.crm-set__req {
  display: flex; align-items: flex-start; gap: 10px;
  margin-top: 16px; padding: 12px 14px;
  background: #fff8e8; border: 1px solid #f2ddb0; border-radius: 8px;
  font-size: 13px; color: #6b4e00; line-height: 1.45;
}
.crm-set__req i { margin-top: 2px; font-size: 14px; }

/* Action sits next to the sentence it belongs to, instead of at the far edge of a wide card. */
.crm-set__cta { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; margin-top: 16px; }
.crm-btn--lg { padding: 11px 22px; font-size: 14px; }

/* Password form on the security screen — inputs a touch wider than the default filter controls. */
.crm-set__pwd .crm-input { max-width: 260px; }

/* Attention dot on the Settings item — something in that section needs the owner's action. */
.crm-nav__dot { width: 7px; height: 7px; border-radius: 50%; background: #e0a100; margin-left: auto; flex: 0 0 auto; }

/* Folded password form: a quiet control until it is actually needed. */
.crm-set__fold { margin-top: 14px; }
.crm-set__foldbtn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 8px 16px; border: 1px solid var(--crm-border); border-radius: 8px;
  background: var(--crm-surface); color: var(--crm-text);
  font-size: 13px; font-weight: 600; cursor: pointer; list-style: none;
}
.crm-set__foldbtn::-webkit-details-marker { display: none; }
.crm-set__foldbtn:hover { background: var(--crm-hover); }
.crm-set__fold[open] > .crm-set__foldbtn { margin-bottom: 6px; }
