/*!
 * kp-theme.css - K. Patel Group design layer on top of Tabler 1.5.
 *
 * This file only overrides Tabler tokens and adds the components described in
 * DESIGN.md (v2, workspace layout). Tabler's own CSS is never forked. Loaded
 * last in client/head.html.
 *
 * Sections
 *   1. Tokens (light and dark)
 *   2. Base typography
 *   3. Application shell - layout grid
 *   4. Sidebar
 *   5. Tab strip
 *   6. Toolbar (and the legacy page header alias)
 *   7. Inspector, command palette, Home
 *   8. Surfaces, tables and controls
 *   9. Feedback - the success box
 *  9b. Table, board and card base
 *  9c. Loading
 *  10. Legacy Bootstrap 4 aliases (removed once every page is migrated)
 *      10a. Toolbar button labels
 *      10b. Status pills
 *      10c. Legacy tables
 *      10d. Legacy record pages
 *      10e. Legacy forms and modals
 *      10f. Dashboards (admin and user)
 */

/* ==========================================================================
   1. Tokens
   ========================================================================== */

:root,
[data-bs-theme="light"] {
  /* Brand and status */
  --tblr-primary: #4F46E5;
  --tblr-primary-rgb: 79, 70, 229;
  --tblr-primary-fg: #FFFFFF;
  --tblr-success: #059669;
  --tblr-success-rgb: 5, 150, 105;
  --tblr-warning: #D97706;
  --tblr-warning-rgb: 217, 119, 6;
  --tblr-danger: #DC2626;
  --tblr-danger-rgb: 220, 38, 38;
  --tblr-info: #2563EB;
  --tblr-info-rgb: 37, 99, 235;
  /* Red as TEXT on a grey or tinted surface (an overdue date, a field error,
     a required asterisk): the status red is too light there. */
  --kp-danger-text: #B91C1C;
  /* The outline of a control (input, select, picker, checkbox): 3:1 on a card
     and on a tinted surface, which the hairline border colour is not. */
  --kp-control-border: #868E9C;

  --kp-primary-soft: #EEF2FF;

  /* Module hues - one per sidebar group (DESIGN.md section 1, "Colour").
     Each hue has a soft variant, a 10-12% tint of the hue on the surface, used
     for active nav backgrounds and icon tiles. */
  --kp-hue-mywork: #DB2777;
  --kp-hue-mywork-soft: #FDF2F8;
  --kp-hue-sales: #4F46E5;
  --kp-hue-sales-soft: #EEF2FF;
  --kp-hue-customers: #0F766E;
  --kp-hue-customers-soft: #ECFDF5;
  --kp-hue-planning: #D97706;
  --kp-hue-planning-soft: #FFFBEB;
  --kp-hue-catalogue: #7C3AED;
  --kp-hue-catalogue-soft: #F5F3FF;
  --kp-hue-insights: #0284C7;
  --kp-hue-insights-soft: #F0F9FF;
  --kp-hue-admin: #64748B;
  --kp-hue-admin-soft: #F1F5F9;

  /* Status pills: a soft background and a strong text colour per meaning. */
  --kp-status-success-bg: #ECFDF5;
  --kp-status-success-fg: #047857;
  --kp-status-warning-bg: #FFFBEB;
  --kp-status-warning-fg: #B45309;
  --kp-status-danger-bg: #FEF2F2;
  --kp-status-danger-fg: #B91C1C;
  --kp-status-info-bg: #EFF6FF;
  --kp-status-info-fg: #1D4ED8;
  --kp-status-neutral-bg: #F1F5F9;
  --kp-status-neutral-fg: #475569;
  /* The five swatches with no meaning of their own (imports/api/statusPill.js);
     slate, blue, red, amber and green are the five above. */
  --kp-status-indigo-bg: #EEF2FF;
  --kp-status-indigo-fg: #4338CA;
  --kp-status-violet-bg: #F5F3FF;
  --kp-status-violet-fg: #6D28D9;
  --kp-status-pink-bg: #FDF2F8;
  --kp-status-pink-fg: #BE185D;
  --kp-status-orange-bg: #FFF7ED;
  --kp-status-orange-fg: #C2410C;
  --kp-status-teal-bg: #F0FDFA;
  --kp-status-teal-fg: #0F766E;
  /* The base colour of each swatch: a dot, the edge of the current stage. */
  --kp-swatch-slate: #64748B;
  --kp-swatch-blue: #2563EB;
  --kp-swatch-indigo: #4F46E5;
  --kp-swatch-violet: #7C3AED;
  --kp-swatch-pink: #DB2777;
  --kp-swatch-red: #DC2626;
  --kp-swatch-orange: #EA580C;
  --kp-swatch-amber: #D97706;
  --kp-swatch-green: #059669;
  --kp-swatch-teal: #0F766E;
  /* Chart series, in this order (imports/ui/shell/chartKit.js reads them when a
     chart is drawn). A series that stands for a status takes its swatch above. */
  --kp-chart-1: #4F46E5;
  --kp-chart-2: #0E7490;
  --kp-chart-3: #B45309;
  --kp-chart-4: #BE185D;
  --kp-chart-5: #047857;
  --kp-chart-6: #7C3AED;
  --kp-chart-7: #C2410C;
  --kp-chart-8: #475569;

  /* Surfaces. The background sits a step below white so cards lift off it,
     and the entity wash (`.kp-main`) tints it with the active entity's hue. */
  --tblr-body-bg: #F1F2F5;
  --tblr-bg-surface: #FFFFFF;
  --tblr-bg-surface-secondary: #F5F6F9;
  --tblr-bg-surface-tertiary: #ECEEF2;
  --tblr-border-color: #E1E4EA;
  --tblr-border-color-translucent: #E1E4EA;
  --kp-card-shadow: 0 1px 3px rgba(15, 23, 42, .08), 0 4px 12px rgba(15, 23, 42, .05);
  --kp-card-shadow-hover: 0 2px 6px rgba(15, 23, 42, .10), 0 8px 20px rgba(15, 23, 42, .08);
  --kp-wash-strength: 0%;  /* the page-wide wash stays off: the toolbar band carries the entity colour instead */

  /* Text */
  --tblr-body-color: #111827;
  --tblr-body-color-rgb: 17, 24, 39;
  /* Muted text is read on the tinted greys and the band as well as on white,
     so it is dark enough for all of them (4.9:1 on the darkest). */
  --tblr-secondary: #5F6775;
  --tblr-secondary-rgb: 95, 103, 117;
  --tblr-secondary-color: #5F6775;
  --tblr-muted: #5F6775;
  --tblr-muted-rgb: 95, 103, 117;

  /* Type scale (DESIGN.md "Typography"): the app's only text sizes. Icons,
     chart canvases and the printed sheet keep sizes of their own. */
  --kp-fs-label: 11px;    /* the few small-capital signposts (menu groups), tags */
  --kp-fs-small: 12px;    /* secondary text, hints, chips */
  --kp-fs-body: 13px;     /* body, controls, table cells on every list */
  --kp-fs-card: 15px;     /* card and dialog titles */
  --kp-fs-title: 20px;    /* page and record titles */
  --kp-fs-display: 24px;  /* the Home greeting, the largest KPI figures */
  --kp-fs-read: 14px;     /* help article prose: the one long-reading exception */

  /* Links and link buttons are the primary: no Tabler blue is left. */
  --tblr-link-color: var(--tblr-primary);
  --tblr-link-color-rgb: var(--tblr-primary-rgb);
  --tblr-link-hover-color: var(--tblr-primary);
  --tblr-link-hover-color-rgb: var(--tblr-primary-rgb);

  /* Controls take the app typeface through Tabler's own font token. */
  --tblr-font-sans-serif: "Source Sans 3 Variable", Inter, -apple-system, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, sans-serif;

  /* The sidebar is surface coloured in both themes (DESIGN.md section 2). */
  --kp-sidebar-bg: var(--tblr-bg-surface);
  --kp-sidebar-fg: var(--tblr-body-color);
  --kp-sidebar-muted: var(--tblr-secondary);
  --kp-sidebar-hover: var(--tblr-bg-surface-secondary);
  --kp-sidebar-active: var(--kp-primary-soft);
  --kp-sidebar-active-fg: var(--tblr-primary);

  /* Entity accents (seed defaults; entities.color wins at runtime) */
  --kp-entity-kpcp: #C81E1E;
  --kp-entity-kdi: #1D4ED8;
  --kp-entity-dd: #EA580C;
  --kp-entity-kpi: #0F766E;
  --kp-accent: var(--tblr-primary);

  /* Shell metrics */
  --kp-sidebar-width: 232px;
  --kp-sidebar-rail-width: 64px;
  --kp-tabstrip-height: 40px;
  --kp-toolbar-height: 48px;
  --kp-inspector-width: 340px;
  --kp-page-padding: 20px;

  /* Radius, elevation, motion */
  --tblr-border-radius: 8px;
  --tblr-border-radius-sm: 6px;
  --tblr-border-radius-lg: 8px;
  --kp-radius: 8px;
  --kp-radius-sm: 6px;
  --kp-radius-pill: 999px;
  --kp-shadow-float: 0 8px 24px rgba(15, 23, 42, .12);
  --kp-transition: 150ms ease-out;
  --kp-focus-ring: 0 0 0 2px rgba(var(--tblr-primary-rgb), .4);
}

[data-bs-theme="dark"] {
  --tblr-primary: #818CF8;
  --tblr-primary-rgb: 129, 140, 248;
  --tblr-primary-fg: #0F1117;
  --tblr-success: #34D399;
  --tblr-success-rgb: 52, 211, 153;
  --tblr-warning: #FBBF24;
  --tblr-warning-rgb: 251, 191, 36;
  --tblr-danger: #F87171;
  --tblr-danger-rgb: 248, 113, 113;
  --tblr-danger-fg: #0F1117; /* dark text on the light red, as on the primary */
  --tblr-info: #60A5FA;
  --tblr-info-rgb: 96, 165, 250;
  --kp-danger-text: #FCA5A5;
  --kp-control-border: #70737B;

  --kp-primary-soft: color-mix(in srgb, #818CF8 16%, var(--tblr-bg-surface));

  /* Module hues, lightened for dark surfaces; soft = the hue at 14% over the
     surface so it stays a tint rather than a slab of colour. */
  --kp-hue-mywork: #F472B6;
  --kp-hue-mywork-soft: color-mix(in srgb, #F472B6 14%, var(--tblr-bg-surface));
  --kp-hue-sales: #818CF8;
  --kp-hue-sales-soft: color-mix(in srgb, #818CF8 14%, var(--tblr-bg-surface));
  --kp-hue-customers: #2DD4BF;
  --kp-hue-customers-soft: color-mix(in srgb, #2DD4BF 14%, var(--tblr-bg-surface));
  --kp-hue-planning: #FBBF24;
  --kp-hue-planning-soft: color-mix(in srgb, #FBBF24 14%, var(--tblr-bg-surface));
  --kp-hue-catalogue: #A78BFA;
  --kp-hue-catalogue-soft: color-mix(in srgb, #A78BFA 14%, var(--tblr-bg-surface));
  --kp-hue-insights: #38BDF8;
  --kp-hue-insights-soft: color-mix(in srgb, #38BDF8 14%, var(--tblr-bg-surface));
  --kp-hue-admin: #94A3B8;
  --kp-hue-admin-soft: color-mix(in srgb, #94A3B8 14%, var(--tblr-bg-surface));

  --kp-status-success-bg: color-mix(in srgb, #34D399 14%, var(--tblr-bg-surface));
  --kp-status-success-fg: #6EE7B7;
  --kp-status-warning-bg: color-mix(in srgb, #FBBF24 14%, var(--tblr-bg-surface));
  --kp-status-warning-fg: #FCD34D;
  --kp-status-danger-bg: color-mix(in srgb, #F87171 14%, var(--tblr-bg-surface));
  --kp-status-danger-fg: #FCA5A5;
  --kp-status-info-bg: color-mix(in srgb, #60A5FA 14%, var(--tblr-bg-surface));
  --kp-status-info-fg: #93C5FD;
  --kp-status-neutral-bg: color-mix(in srgb, #94A3B8 14%, var(--tblr-bg-surface));
  --kp-status-neutral-fg: #CBD5E1;
  --kp-status-indigo-bg: color-mix(in srgb, #818CF8 14%, var(--tblr-bg-surface));
  --kp-status-indigo-fg: #C7D2FE;
  --kp-status-violet-bg: color-mix(in srgb, #A78BFA 14%, var(--tblr-bg-surface));
  --kp-status-violet-fg: #DDD6FE;
  --kp-status-pink-bg: color-mix(in srgb, #F472B6 14%, var(--tblr-bg-surface));
  --kp-status-pink-fg: #FBCFE8;
  --kp-status-orange-bg: color-mix(in srgb, #FB923C 14%, var(--tblr-bg-surface));
  --kp-status-orange-fg: #FDBA74;
  --kp-status-teal-bg: color-mix(in srgb, #2DD4BF 14%, var(--tblr-bg-surface));
  --kp-status-teal-fg: #5EEAD4;
  --kp-swatch-slate: #94A3B8;
  --kp-swatch-blue: #60A5FA;
  --kp-swatch-indigo: #818CF8;
  --kp-swatch-violet: #A78BFA;
  --kp-swatch-pink: #F472B6;
  --kp-swatch-red: #F87171;
  --kp-swatch-orange: #FB923C;
  --kp-swatch-amber: #FBBF24;
  --kp-swatch-green: #34D399;
  --kp-swatch-teal: #2DD4BF;
  --kp-chart-1: #818CF8;
  --kp-chart-2: #22D3EE;
  --kp-chart-3: #FBBF24;
  --kp-chart-4: #F472B6;
  --kp-chart-5: #34D399;
  --kp-chart-6: #A78BFA;
  --kp-chart-7: #FB923C;
  --kp-chart-8: #94A3B8;

  /* Neutral greys with no blue cast, in three clear steps (page, card, raised),
     so the entity colour and the status tints read clean on them. */
  --tblr-body-bg: #0F1012;
  --tblr-bg-surface: #1A1B1F;
  --tblr-bg-surface-secondary: #212226;
  --tblr-bg-surface-tertiary: #2A2B30;
  --tblr-border-color: #313339;
  --tblr-border-color-translucent: #313339;
  --kp-card-shadow: none;
  --kp-card-shadow-hover: 0 8px 20px rgba(0, 0, 0, .35);
  --kp-wash-strength: 0%;

  --tblr-body-color: #E6E7EA;
  --tblr-body-color-rgb: 230, 231, 234;
  --tblr-secondary: #A1A3AA;
  --tblr-secondary-rgb: 161, 163, 170;
  --tblr-secondary-color: #A1A3AA;
  --tblr-muted: #A1A3AA;
  --tblr-muted-rgb: 161, 163, 170;

  --kp-sidebar-bg: var(--tblr-bg-surface);
  --kp-sidebar-fg: var(--tblr-body-color);
  --kp-sidebar-muted: var(--tblr-secondary);
  --kp-sidebar-hover: var(--tblr-bg-surface-secondary);
  --kp-sidebar-active: var(--kp-primary-soft);
  --kp-sidebar-active-fg: #C7D2FE;

  --kp-shadow-float: 0 8px 24px rgba(0, 0, 0, .45);

  color-scheme: dark;
}

/* Dark mode: the primary stays light for links and text, but a filled button
   takes a mid-tone with white text (5.9:1), so it never reads as disabled. */
[data-bs-theme="dark"] .btn-primary {
  --tblr-btn-bg: #5753D0;
  --tblr-btn-border-color: #5753D0;
  --tblr-btn-color: #FFFFFF;
  --tblr-btn-hover-bg: #625FDC;
  --tblr-btn-hover-border-color: #625FDC;
  --tblr-btn-hover-color: #FFFFFF;
  --tblr-btn-active-bg: #4C48BF;
  --tblr-btn-active-border-color: #4C48BF;
  --tblr-btn-active-color: #FFFFFF;
  --tblr-btn-disabled-bg: #3A3878;
  --tblr-btn-disabled-border-color: #3A3878;
  --tblr-btn-disabled-color: rgba(255, 255, 255, .6);
}

/* Dark mode: one quiet colour for the menu icons; only the page you are on
   keeps its group hue. Coloured icons on near-black read as a rainbow. */
[data-bs-theme="dark"] .kp-nav-link .kp-nav-icon {
  color: var(--tblr-secondary);
}

[data-bs-theme="dark"] .kp-nav-link.active .kp-nav-icon {
  color: var(--kp-group-hue);
}

/* ==========================================================================
   2. Base typography
   ========================================================================== */

html,
body {
  font-family: var(--tblr-font-sans-serif);
  font-size: var(--kp-fs-body);
  line-height: 1.45;
  background-color: var(--tblr-body-bg);
  color: var(--tblr-body-color);
}

/* Tabler reserves a permanent scrollbar gutter on <html>. Bare layouts (login)
   are fixed to the viewport and never scroll, so the gutter would only show as
   a pale strip down the right edge. */
html:has(> body > .kp-bare) {
  scrollbar-gutter: auto;
}

h1, h2, h3, h4, h5, h6,
.h1, .h2, .h3, .h4, .h5, .h6 {
  font-weight: 700;
  line-height: 1.35;
  letter-spacing: -.01em;
  color: var(--tblr-body-color);
}

/* No heading above 20px anywhere in the app. */
h1, .h1 { font-size: var(--kp-fs-title); letter-spacing: -.02em; }
h2, .h2 { font-size: var(--kp-fs-card); }
h3, .h3 { font-size: var(--kp-fs-card); }
h4, .h4 { font-size: var(--kp-fs-card); }
h5, .h5 { font-size: var(--kp-fs-body); }
h6, .h6 { font-size: var(--kp-fs-body); }

.kp-pretitle,
.page-pretitle {
  text-transform: none;  /* Tabler capitalises these; labels here are sentence case */
  letter-spacing: normal;
  font-size: var(--kp-fs-small);
  font-weight: 600;
  line-height: 1.45;
  color: var(--tblr-secondary);
}

.form-label,
label {
  font-size: var(--kp-fs-small);
  font-weight: 500;
}

/* Numbers read as columns, not words. */
.table td.kp-num,
.table th.kp-num,
.kp-num {
  font-variant-numeric: tabular-nums;
  text-align: right;
}

/* Buttons, fields and pickers are in the page's typeface, not the operating
   system's. */
button,
input,
select,
textarea,
optgroup,
.btn,
.form-control,
.form-select {
  font-family: inherit;
}

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

a:hover {
  text-decoration: underline;
}

/* Red text is the darker danger text token, wherever a page asks for it. */
.text-danger {
  color: var(--kp-danger-text) !important;
}

:focus-visible {
  outline: none;
  box-shadow: var(--kp-focus-ring);
  border-radius: var(--kp-radius-sm);
}

.kp-kbd {
  padding: 1px 5px;
  border: 1px solid var(--tblr-border-color);
  border-radius: 4px;
  background: var(--tblr-bg-surface-secondary);
  color: var(--tblr-secondary);
  font-size: var(--kp-fs-label);
  font-weight: 500;
  line-height: 1.45;
  white-space: nowrap;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition-duration: .001ms !important;
    animation-duration: .001ms !important;
  }
}

/* ==========================================================================
   3. Application shell - layout grid
   ========================================================================== */

/* Sidebar column plus a scrolling workspace: tab strip, then content with the
   inspector beside it. `.kp-shell` sets the sidebar width once; the rail state
   only changes it. */
.kp-shell {
  --kp-current-sidebar-width: var(--kp-sidebar-width);
  min-height: 100vh;
}

.kp-shell.kp-shell-collapsed {
  --kp-current-sidebar-width: var(--kp-sidebar-rail-width);
}

.kp-main {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  margin-left: var(--kp-current-sidebar-width);
  transition: margin-left var(--kp-transition);
  /* The entity wash (DESIGN.md section 1, "Colour"). Only the HUE of the
     entity colour is used: lightness and chroma are pinned in OKLCH, so a
     saturated red and a pale teal land at the same weight, and a grey or
     near-black pick yields almost no wash. Cards stay plain surface, so the
     tint never lowers contrast on content. The wash is mixed in sRGB: mixed in
     OKLCH, the near-grey page colour took the tint's hue even at 0%. */
  --kp-accent-tint: oklch(from var(--kp-accent) 0.62 0.14 h);
  background: color-mix(in srgb, var(--kp-accent-tint) var(--kp-wash-strength), var(--tblr-body-bg));
}

.kp-workspace {
  /* The progress bar pins itself to the top edge of this box. */
  position: relative;
  flex: 1 1 auto;
  display: flex;
  align-items: stretch;
  min-height: 0;
  min-width: 0;
}

.kp-content {
  flex: 1 1 auto;
  min-width: 0;
  padding: 16px var(--kp-page-padding) var(--kp-page-padding);
}

/* Logged out pages render full bleed, without the shell. */
.kp-bare {
  min-height: 100vh;
}

/* Drawer trigger, only below 992px */
.kp-drawer-btn {
  display: none;
  position: fixed;
  top: 8px;
  left: 8px;
  z-index: 1035;
  width: 36px;
  height: 36px;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--tblr-border-color);
  border-radius: var(--kp-radius);
  background: var(--tblr-bg-surface);
  color: var(--tblr-body-color);
  font-size: 18px;
}

@media (max-width: 991.98px) {
  :root { --kp-page-padding: 16px; }

  .kp-main {
    margin-left: 0;
  }

}

/* The app bar of a small screen: menu, entity, search, notifications. In the
   page flow, so nothing floats over the content. */
.kp-mobile-bar {
  display: none;
  flex: 0 0 auto;
  align-items: center;
  gap: 8px;
  height: 48px;
  padding: 0 10px;
  border-bottom: 1px solid var(--tblr-border-color);
  background: var(--tblr-bg-surface);
}

.kp-mobile-bar .kp-drawer-btn {
  position: static;
  display: flex;
  width: 34px;
  height: 34px;
  border: 0;
  background: transparent;
}

.kp-mobile-bar-name {
  min-width: 0;
  overflow: hidden;
  font-size: var(--kp-fs-card);
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.kp-mobile-bar .kp-icon-btn {
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  font-size: 18px;
}

@media (max-width: 991.98px) {
  .kp-mobile-bar {
    display: flex;
  }
}

/* Small screens: a record's title scales with the width and wraps less, and
   the secondary buttons of a record toolbar keep their icon only. */
@media (max-width: 767.98px) {
  .kp-record-toolbar .kp-toolbar-heading {
    font-size: clamp(var(--kp-fs-card), 4.6vw, var(--kp-fs-title));
    line-height: 1.2;
  }

  .kp-record-toolbar .kp-toolbar-actions .btn:not(.btn-primary) {
    padding-left: 9px;
    padding-right: 9px;
    font-size: 0;
  }

  .kp-record-toolbar .kp-toolbar-actions .btn:not(.btn-primary) i {
    margin: 0 !important;
    font-size: 16px;
  }

  /* The filter bar: search takes the row, the chips follow. */
  .kp-toolbar-filters > .kp-chip-search {
    flex: 1 1 100%;
  }

  .kp-toolbar-filters > .kp-chip-search .form-control {
    width: 100%;
  }

  .kp-datechip-menu {
    min-width: 0;
    width: min(290px, calc(100vw - 32px));
  }
}

/* ==========================================================================
   4. Sidebar
   ========================================================================== */

/* The sidebar is a Bootstrap 5 responsive offcanvas (`offcanvas-lg`): a fixed
   column from 992px up, a drawer with a backdrop below it. Bootstrap owns the
   drawer behaviour; everything here is the desktop column plus skinning. */
.kp-sidebar {
  --tblr-offcanvas-width: var(--kp-sidebar-width);
  --tblr-offcanvas-bg: var(--kp-sidebar-bg);
  --tblr-offcanvas-color: var(--kp-sidebar-fg);
  --tblr-offcanvas-border-width: 0;
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: 1020;
  display: flex;
  flex-direction: column;
  width: var(--kp-current-sidebar-width);
  border-right: 1px solid var(--tblr-border-color);
  background-color: var(--kp-sidebar-bg) !important;
  color: var(--kp-sidebar-fg);
  transition: width var(--kp-transition);
}

.kp-sidebar-head {
  flex: 0 0 auto;
  padding: 10px 10px 6px;
}

/* Entity and division switcher chip */
.kp-switcher {
  width: 100%;
}

.kp-switcher-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  height: 40px;
  padding: 0 8px;
  border: 1px solid var(--tblr-border-color);
  border-radius: var(--kp-radius);
  background: var(--tblr-bg-surface-secondary);
  color: var(--tblr-body-color);
  text-align: left;
}

.kp-switcher-btn:hover {
  background: var(--tblr-bg-surface-tertiary);
}

.kp-entity-dot {
  flex: 0 0 8px;
  width: 8px;
  height: 8px;
  border-radius: var(--kp-radius-pill);
  background: var(--kp-accent);
}

/* The switcher carries the entity as a small filled tile with its short code,
   which reads at a glance and survives rail mode where labels are hidden. The
   tile is square for a short code and grows sideways for a longer one, so
   "KPCP" keeps its padding. */
.kp-entity-tile {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 28px;
  height: 28px;
  padding: 0 6px;
  border-radius: 7px;
  background: var(--kp-accent);
  color: #fff;
  font-size: var(--kp-fs-label);
  font-weight: 700;
  letter-spacing: .01em;
  line-height: 1;
  white-space: nowrap;
}

.kp-switcher-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
  line-height: 1.2;
}

.kp-switcher-entity {
  font-size: var(--kp-fs-body);
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.kp-switcher-division {
  font-size: var(--kp-fs-label);
  color: var(--tblr-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.kp-switcher-caret {
  margin-left: auto;
  color: var(--tblr-secondary);
}

.kp-switcher-menu {
  min-width: 240px;
  padding: 6px;
  font-size: var(--kp-fs-body);
}

.kp-switcher-group {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 8px 4px;
  font-size: var(--kp-fs-label);
  font-weight: 600;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--tblr-secondary);
}

.kp-switcher-item {
  display: flex;
  align-items: center;
  gap: 8px;
  border-radius: var(--kp-radius-sm);
  font-size: var(--kp-fs-body);
}

.kp-switcher-item .kp-check {
  margin-left: auto;
  color: var(--tblr-primary);
}

/* Search box: opens the command palette */
.kp-sidebar-search {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
  height: 34px;
  margin: 0 10px 8px;
  padding: 0 8px;
  border: 1px solid var(--tblr-border-color);
  border-radius: var(--kp-radius);
  background: var(--tblr-bg-surface-secondary);
  color: var(--tblr-secondary);
  font-size: var(--kp-fs-body);
}

.kp-sidebar-search:hover {
  background: var(--tblr-bg-surface-tertiary);
  color: var(--tblr-body-color);
}

.kp-sidebar-search .kp-kbd {
  margin-left: auto;
}

.kp-sidebar-nav {
  flex: 1 1 auto;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 4px 8px 12px;
  /* The scrollbar is the app-wide one (section 30). */
}

.kp-nav-group {
  position: relative;
  margin-top: 6px;
}

.kp-nav-group-head {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  height: 28px;
  padding: 0 6px;
  border: 0;
  background: transparent;
  border-radius: var(--kp-radius-sm);
  color: var(--tblr-secondary);
  font-size: var(--kp-fs-label);
  font-weight: 600;
  letter-spacing: .07em;
  text-transform: uppercase;
  white-space: nowrap;
}

.kp-nav-group-head:hover {
  background: var(--kp-sidebar-hover);
  color: var(--tblr-body-color);
}

.kp-nav-group-icon {
  display: none;
  font-size: 18px;
  color: var(--kp-group-hue);
}

/* Each sidebar group owns a hue. The rules below are generic: they only read
   `--kp-group-hue` / `--kp-group-hue-soft`, which the `data-group` selectors
   set. A new module is a new pair here, nothing else. */
.kp-sidebar-nav {
  --kp-group-hue: var(--tblr-primary);
  --kp-group-hue-soft: var(--kp-primary-soft);
}

.kp-nav-group[data-group="mywork"] {
  --kp-group-hue: var(--kp-hue-mywork);
  --kp-group-hue-soft: var(--kp-hue-mywork-soft);
}

.kp-nav-group[data-group="sales"] {
  --kp-group-hue: var(--kp-hue-sales);
  --kp-group-hue-soft: var(--kp-hue-sales-soft);
}

.kp-nav-group[data-group="customers"] {
  --kp-group-hue: var(--kp-hue-customers);
  --kp-group-hue-soft: var(--kp-hue-customers-soft);
}

.kp-nav-group[data-group="planning"] {
  --kp-group-hue: var(--kp-hue-planning);
  --kp-group-hue-soft: var(--kp-hue-planning-soft);
}

.kp-nav-group[data-group="catalogue"] {
  --kp-group-hue: var(--kp-hue-catalogue);
  --kp-group-hue-soft: var(--kp-hue-catalogue-soft);
}

.kp-nav-group[data-group="insights"] {
  --kp-group-hue: var(--kp-hue-insights);
  --kp-group-hue-soft: var(--kp-hue-insights-soft);
}

.kp-nav-group[data-group="administration"],
.kp-nav-group[data-group="admin"] {
  --kp-group-hue: var(--kp-hue-admin);
  --kp-group-hue-soft: var(--kp-hue-admin-soft);
}

.kp-nav-group-label {
  overflow: hidden;
  text-overflow: ellipsis;
}

.kp-nav-caret {
  margin-left: auto;
  font-size: 14px;
  transition: transform var(--kp-transition);
}

.kp-nav-group-collapsed > .kp-nav-group-head .kp-nav-caret,
.kp-nav-subtree-collapsed > .kp-nav-subtree-head .kp-nav-caret {
  transform: rotate(-90deg);
}

.kp-nav-group-collapsed > .kp-nav-list {
  display: none;
}

.kp-nav-list,
.kp-nav-sub {
  list-style: none;
  margin: 0;
  padding: 0;
}

.kp-nav-list-plain {
  margin-top: 2px;
}

/* Help closes the list, set a little apart from the last module group. */
.kp-nav-list-plain.kp-nav-help {
  margin-top: 8px;
}

.kp-flyout-title {
  display: none;
}

.kp-nav-link {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  height: 32px;
  padding: 0 8px;
  border: 0;
  background: transparent;
  border-radius: var(--kp-radius-sm);
  color: var(--kp-sidebar-fg);
  font-size: var(--kp-fs-body);
  font-weight: 500;
  text-align: left;
  white-space: nowrap;
  transition: background var(--kp-transition), color var(--kp-transition);
}

.kp-nav-link:hover {
  background: var(--kp-sidebar-hover);
  color: var(--tblr-body-color);
  text-decoration: none;
}

.kp-nav-link .kp-nav-icon {
  flex: 0 0 18px;
  width: 18px;
  font-size: 18px;
  line-height: 1;
  text-align: center;
  color: var(--kp-group-hue);
}

.kp-nav-link .kp-nav-label {
  overflow: hidden;
  text-overflow: ellipsis;
}

.kp-nav-link.active {
  background: var(--kp-group-hue-soft);
  color: var(--tblr-body-color);
  font-weight: 600;
}

.kp-nav-link.active .kp-nav-icon {
  color: var(--kp-group-hue);
}

/* A 3px bar in the group hue marks the page you are on. */
.kp-nav-link.active::before {
  content: "";
  position: absolute;
  top: 5px;
  bottom: 5px;
  left: 0;
  width: 3px;
  border-radius: 2px;
  background: var(--kp-group-hue);
}

.kp-nav-subtree-collapsed .kp-nav-sub {
  display: none;
}

.kp-nav-sub .kp-nav-link {
  height: 28px;
  padding-left: 36px;
  font-size: var(--kp-fs-small);
  font-weight: 400;
  color: var(--tblr-secondary);
}

.kp-nav-sub .kp-nav-link:hover,
.kp-nav-sub .kp-nav-link.active {
  color: var(--tblr-body-color);
}

.kp-nav-sub .kp-nav-link.active::before {
  left: 20px;
}

/* User footer */
.kp-sidebar-foot {
  flex: 0 0 auto;
  border-top: 1px solid var(--tblr-border-color);
  padding: 6px;
}

.kp-user-row {
  display: flex;
  align-items: center;
  gap: 4px;
}

.kp-user-dropdown {
  flex: 1 1 auto;
  min-width: 0;
}

.kp-user-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 4px 4px;
  border: 0;
  background: transparent;
  border-radius: var(--kp-radius-sm);
  color: var(--tblr-body-color);
  text-align: left;
}

.kp-user-btn:hover {
  background: var(--kp-sidebar-hover);
}

/* The avatar wears a 2px ring in the current entity colour - the one place in
   the footer where the entity is visible. */
.kp-user-avatar {
  flex: 0 0 28px;
  width: 28px;
  height: 28px;
  margin: 2px;
  border-radius: var(--kp-radius-pill);
  object-fit: cover;
  background: var(--tblr-bg-surface-tertiary);
  box-shadow: 0 0 0 2px var(--kp-accent);
}

.kp-user-meta {
  display: flex;
  flex-direction: column;
  min-width: 0;
  line-height: 1.2;
}

.kp-user-name {
  font-size: var(--kp-fs-body);
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.kp-user-role {
  font-size: var(--kp-fs-small);
  color: var(--tblr-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.kp-user-caret {
  margin-left: auto;
  color: var(--tblr-secondary);
}

.kp-user-menu {
  font-size: var(--kp-fs-body);
}

.kp-icon-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  flex: 0 0 28px;
  border: 0;
  background: transparent;
  border-radius: var(--kp-radius-sm);
  color: var(--tblr-secondary);
  font-size: 16px;
}

.kp-icon-btn:hover {
  background: var(--kp-sidebar-hover);
  color: var(--tblr-body-color);
}

.kp-badge-count {
  position: absolute;
  top: -1px;
  right: -2px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: var(--kp-radius-pill);
  background: var(--tblr-danger);
  color: var(--tblr-danger-fg, #fff);
  font-size: var(--kp-fs-label);
  font-weight: 700;
  line-height: 16px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

/* Notifications: the bell dropdown, its rows and the /notifications page.
   The same row anatomy is used in both places, so the tile, the title, the body
   clamp and the meta line are defined once. */
.kp-notif-menu {
  width: 360px;
  max-width: calc(100vw - 32px);
  max-height: 70vh;
  overflow-y: auto;
  padding: 0;
  font-size: var(--kp-fs-body);
}

.kp-notif-head {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 8px 8px 8px 12px;
  border-bottom: 1px solid var(--tblr-border-color);
  background: var(--tblr-bg-surface);
}

.kp-notif-head-title {
  flex: 1 1 auto;
  font-size: var(--kp-fs-small);
  font-weight: 600;
  color: var(--tblr-secondary);
}

.kp-notif-head-btn {
  padding: 2px 6px;
  font-size: var(--kp-fs-small);
  text-decoration: none;
}

.kp-notif-section {
  padding: 8px 12px 4px;
  font-size: var(--kp-fs-label);
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--tblr-secondary);
}

.kp-notif-loading {
  padding: 20px 12px;
  text-align: center;
}

.kp-notif-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.kp-notif-row {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 10px 12px;
  border-bottom: 1px solid var(--tblr-border-color);
  cursor: pointer;
}

.kp-notif-row:hover,
.kp-notif-row:focus-visible {
  background: var(--kp-sidebar-hover);
  outline: none;
}

.kp-notif-tile {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 32px;
  width: 32px;
  height: 32px;
  border-radius: var(--kp-radius-sm);
  background: var(--tblr-bg-surface-secondary);
  color: var(--tblr-secondary);
  font-size: 17px;
}

.kp-notif-tile-action {
  background: rgba(var(--tblr-primary-rgb), .12);
  color: var(--tblr-primary);
}

.kp-notif-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  flex: 1 1 auto;
}

.kp-notif-title {
  font-weight: 600;
  line-height: 1.35;
}

.kp-notif-body {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  color: var(--tblr-secondary);
  font-size: var(--kp-fs-small);
  line-height: 1.45;
}

.kp-notif-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  color: var(--tblr-secondary);
  font-size: var(--kp-fs-small);
}

.kp-notif-meta > * + *::before {
  content: "\00b7";
  margin-right: 6px;
}

.kp-notif-count {
  padding: 0 5px;
  border-radius: var(--kp-radius-pill);
  background: var(--tblr-bg-surface-secondary);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

/* The per row "Mark read" button appears on hover and on keyboard focus. */
.kp-notif-read {
  flex: 0 0 28px;
  opacity: 0;
}

.kp-notif-row:hover .kp-notif-read,
.kp-notif-row:focus-within .kp-notif-read,
.kp-notif-read:focus-visible {
  opacity: 1;
}

.kp-notif-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 24px 12px;
  color: var(--tblr-secondary);
  font-size: var(--kp-fs-small);
  text-align: center;
}

.kp-notif-empty i {
  font-size: 22px;
}

/* The switcher's own "nothing here" line, which is not a notification. */
.kp-menu-empty {
  padding: 16px 12px;
  color: var(--tblr-secondary);
  font-size: var(--kp-fs-small);
  text-align: center;
}

/* The badge pulses once when the unread count rises. */
@keyframes kp-notif-pulse {
  0% { transform: scale(1); }
  50% { transform: scale(1.35); }
  100% { transform: scale(1); }
}

.kp-notif-pulse .kp-badge-count {
  animation: kp-notif-pulse 250ms ease-out 1;
}

@media (prefers-reduced-motion: reduce) {
  .kp-notif-pulse .kp-badge-count { animation: none; }
}

/* The /notifications page: the same rows, roomier, with an unread marker. */
.kp-notifpage-card {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.kp-notif-actor,
.kp-notif-when {
  white-space: nowrap;
}

.kp-notifpage-wrap {
  padding: 0;
}

.kp-notifpage-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.kp-notifpage-row {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 12px 16px;
  border-bottom: 1px solid var(--tblr-border-color);
  cursor: pointer;
}

.kp-notifpage-row:hover,
.kp-notifpage-row:focus-visible {
  background: var(--tblr-bg-surface-secondary);
  outline: none;
}

.kp-notifpage-dot {
  flex: 0 0 8px;
  width: 8px;
  height: 8px;
  margin-top: 12px;
  border-radius: 50%;
  background: transparent;
}

.kp-notifpage-row.is-unread .kp-notifpage-dot {
  background: var(--tblr-primary);
}

.kp-notifpage-row.is-unread .kp-notif-title {
  font-weight: 700;
}

.kp-notifpage-text {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
  flex: 1 1 auto;
}

.kp-notifpage-actions {
  flex: 0 0 auto;
}

.kp-notif-type {
  font-weight: 600;
}

/* The notification preferences table in My account. */
.kp-notifprefs-table td,
.kp-notifprefs-table th {
  vertical-align: middle;
}

.kp-notifprefs-switch {
  margin: 0;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  /* A flex row places the switch itself: Bootstrap's form-switch padding,
     meant for a floated input, only pushed it off its column. */
  padding-left: 0;
}

.kp-notifprefs-switch .form-check-input {
  float: none;
  margin: 0;
}

.kp-sidebar-foot-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 4px;
  padding: 0 2px;
}

.kp-sidebar-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 26px;
  padding: 0 6px;
  border: 0;
  background: transparent;
  border-radius: var(--kp-radius-sm);
  color: var(--tblr-secondary);
  font-size: var(--kp-fs-small);
  white-space: nowrap;
}

.kp-sidebar-toggle:hover {
  background: var(--kp-sidebar-hover);
  color: var(--tblr-body-color);
}

.kp-sidebar-toggle .kp-nav-icon {
  font-size: 16px;
}

.kp-sidebar-version {
  margin-left: auto;
  padding-right: 4px;
  color: var(--tblr-secondary);
  font-size: var(--kp-fs-label);
  white-space: nowrap;
}

/* Rail mode: one icon per group, the pages in a flyout. */
@media (min-width: 992px) {
  .kp-shell-collapsed .kp-sidebar .kp-nav-label,
  .kp-shell-collapsed .kp-sidebar .kp-nav-group-label,
  .kp-shell-collapsed .kp-sidebar .kp-nav-caret,
  .kp-shell-collapsed .kp-sidebar .kp-switcher-text,
  .kp-shell-collapsed .kp-sidebar .kp-switcher-caret,
  .kp-shell-collapsed .kp-sidebar .kp-sidebar-search-label,
  .kp-shell-collapsed .kp-sidebar .kp-sidebar-search .kp-kbd,
  .kp-shell-collapsed .kp-sidebar .kp-user-meta,
  .kp-shell-collapsed .kp-sidebar .kp-user-caret,
  .kp-shell-collapsed .kp-sidebar .kp-sidebar-toggle-label,
  .kp-shell-collapsed .kp-sidebar .kp-sidebar-version {
    display: none;
  }

  .kp-shell-collapsed .kp-sidebar .kp-switcher-btn,
  .kp-shell-collapsed .kp-sidebar .kp-sidebar-search,
  .kp-shell-collapsed .kp-sidebar .kp-nav-link,
  .kp-shell-collapsed .kp-sidebar .kp-nav-group-head,
  .kp-shell-collapsed .kp-sidebar .kp-user-btn,
  .kp-shell-collapsed .kp-sidebar .kp-sidebar-toggle {
    justify-content: center;
    padding-left: 0;
    padding-right: 0;
  }

  .kp-shell-collapsed .kp-sidebar .kp-nav-group-head {
    height: 36px;
    color: var(--tblr-secondary);
  }

  .kp-shell-collapsed .kp-sidebar .kp-nav-group-icon {
    display: inline-block;
  }

  /* In rail mode the entity tile is the switcher. */
  .kp-shell-collapsed .kp-sidebar .kp-switcher-btn {
    height: 36px;
    padding: 0;
    border: 0;
    background: transparent;
  }

  .kp-shell-collapsed .kp-sidebar .kp-switcher-btn:hover {
    background: transparent;
  }

  .kp-shell-collapsed .kp-sidebar .kp-user-row,
  .kp-shell-collapsed .kp-sidebar .kp-sidebar-foot-row {
    flex-direction: column;
  }

  /* The flyout: the group's pages, floating beside the rail.
     `.kp-sidebar-nav` scrolls and clips on both axes, so an absolutely
     positioned panel never showed. The panel is `fixed` instead and its `top`
     comes from the group head's bounding rect, set by `positionFlyout()` in
     menu.js as `--kp-flyout-top` on the group. Opening is JS-driven (hover,
     click and keyboard all go through the same handler) so the coordinates are
     always computed before the panel becomes visible. */
  .kp-shell-collapsed .kp-sidebar .kp-nav-group > .kp-nav-list {
    display: none;
    position: fixed;
    top: var(--kp-flyout-top, 0px);
    left: calc(var(--kp-sidebar-rail-width) - 6px);
    z-index: 1045;
    min-width: 208px;
    max-height: calc(100vh - 16px);
    overflow-y: auto;
    padding: 6px;
    border: 1px solid var(--tblr-border-color);
    border-radius: var(--kp-radius);
    background: var(--tblr-bg-surface);
    box-shadow: var(--kp-shadow-float);
  }

  .kp-shell-collapsed .kp-sidebar .kp-nav-group.kp-flyout-open > .kp-nav-list {
    display: block;
  }

  .kp-shell-collapsed .kp-sidebar .kp-nav-group > .kp-nav-list .kp-nav-label,
  .kp-shell-collapsed .kp-sidebar .kp-nav-group > .kp-nav-list .kp-nav-caret {
    display: inline;
  }

  .kp-shell-collapsed .kp-sidebar .kp-nav-group > .kp-nav-list .kp-nav-link {
    justify-content: flex-start;
    padding-left: 8px;
    padding-right: 8px;
  }

  .kp-shell-collapsed .kp-sidebar .kp-flyout-title {
    display: block;
    padding: 4px 8px 6px;
    font-size: var(--kp-fs-label);
    font-weight: 600;
    letter-spacing: .07em;
    text-transform: uppercase;
    color: var(--tblr-secondary);
  }

  /* A group collapsed in expanded mode still opens its flyout in rail mode:
     the rule above already wins on specificity over
     `.kp-nav-group-collapsed > .kp-nav-list`. */

  /* The group icon reads as active while its flyout is open. */
  .kp-shell-collapsed .kp-sidebar .kp-nav-group.kp-flyout-open > .kp-nav-group-head {
    background: var(--kp-sidebar-hover);
  }

  /* The group holding the page you are on is marked the way a page link is
     (.kp-nav-link.active): tinted, with the 3px bar in the group hue. */
  .kp-shell-collapsed .kp-sidebar .kp-nav-group:has(.kp-nav-link.active) > .kp-nav-group-head {
    position: relative;
    background: var(--kp-group-hue-soft);
  }

  .kp-shell-collapsed .kp-sidebar .kp-nav-group:has(.kp-nav-link.active) > .kp-nav-group-head::before {
    content: "";
    position: absolute;
    top: 7px;
    bottom: 7px;
    left: 0;
    width: 3px;
    border-radius: 2px;
    background: var(--kp-group-hue);
  }
}

/* Below 992px Bootstrap turns the column into a drawer; a rail state left over
   from a wide viewport must not shrink it. */
@media (max-width: 991.98px) {
  .kp-sidebar {
    width: var(--kp-sidebar-width);
  }
}

/* ==========================================================================
   5. Tab strip
   ========================================================================== */

.kp-tabstrip {
  display: flex;
  align-items: stretch;
  gap: 2px;
  height: var(--kp-tabstrip-height);
  padding: 0 8px;
  border-bottom: 1px solid var(--tblr-border-color);
  background: var(--tblr-bg-surface-secondary);
  overflow-x: auto;
  scrollbar-width: none;
}

.kp-tabstrip::-webkit-scrollbar { height: 0; }

.kp-tab {
  display: flex;
  align-items: center;
  align-self: center;
  max-width: 220px;
  height: 28px;
  padding: 0 2px 0 8px;
  border: 1px solid transparent;
  border-radius: var(--kp-radius-sm);
  color: var(--tblr-secondary);
}

.kp-tab:hover {
  background: var(--tblr-bg-surface-tertiary);
  color: var(--tblr-body-color);
}

/* A 2px accent along the top says which tab you are looking at. */
.kp-tab-active {
  border-color: var(--tblr-border-color);
  background: var(--tblr-bg-surface);
  color: var(--tblr-body-color);
  box-shadow: inset 0 2px 0 0 var(--tblr-primary);
}

.kp-tab-active .kp-tab-icon {
  color: var(--tblr-primary);
}

.kp-tab-main {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  max-width: 180px;
  border: 0;
  background: transparent;
  color: inherit;
  font-size: var(--kp-fs-small);
  font-weight: 500;
  padding: 0;
}

.kp-tab-icon {
  flex: 0 0 15px;
  font-size: 15px;
}

.kp-tab-title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.kp-tab-pin {
  font-size: var(--kp-fs-small);
  color: var(--tblr-secondary);
}

/* The tab holds unsaved work (imports/ui/shell/drafts.js): a dot after its
   title, the amber of every "not saved yet" mark. It never shrinks, so a long
   title is cut short before the dot is. */
.kp-tab-unsaved {
  flex: 0 0 7px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--tblr-warning);
}

.kp-tab-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  margin-left: 2px;
  border: 0;
  background: transparent;
  border-radius: 4px;
  color: var(--tblr-secondary);
  font-size: var(--kp-fs-body);
  opacity: 0;
}

.kp-tab:hover .kp-tab-close,
.kp-tab-active .kp-tab-close {
  opacity: 1;
}

.kp-tab-close:hover {
  background: var(--tblr-bg-surface-tertiary);
  color: var(--tblr-body-color);
}

/* Dragging a tab along the strip: it lifts, the others slide out of its way. */
.kp-tab:not(:first-child) {
  cursor: grab;
}

.kp-tab:not(:first-child) .kp-tab-main {
  cursor: inherit;
}

.kp-tab-dragging {
  position: relative;
  z-index: 2;
  border-color: var(--tblr-border-color);
  background: var(--tblr-bg-surface);
  color: var(--tblr-body-color);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.16);
  cursor: grabbing;
}

.kp-tabstrip-sorting {
  cursor: grabbing;
  user-select: none;
  -webkit-user-select: none;
}

.kp-tabstrip-sorting .kp-tab {
  pointer-events: none;
}

.kp-tabstrip-sorting .kp-tab:not(.kp-tab-dragging) {
  transition: transform 140ms ease;
}

@media (prefers-reduced-motion: reduce) {
  .kp-tabstrip-sorting .kp-tab:not(.kp-tab-dragging) {
    transition: none;
  }
}

.kp-tabstrip-hint {
  display: flex;
  align-items: center;
  margin-left: auto;
  padding-left: 8px;
}

.kp-tab-menu {
  position: fixed;
  z-index: 1050;
  min-width: 160px;
  font-size: var(--kp-fs-body);
}

/* ==========================================================================
   6. Toolbar (and the legacy page header alias)
   ========================================================================== */

.kp-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  min-height: var(--kp-toolbar-height);
  margin-bottom: 12px;
}

.kp-toolbar-title {
  display: flex;
  flex-direction: column;
  min-width: 0;
  flex: 1 1 auto;
}

.kp-toolbar-heading {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin: 0;
  font-size: var(--kp-fs-title);
  font-weight: 700;
  letter-spacing: -.02em;
}

.kp-toolbar-count,
.kp-count-pill {
  padding: 1px 7px;
  border-radius: var(--kp-radius-pill);
  background: var(--tblr-bg-surface-tertiary);
  color: var(--tblr-secondary);
  font-size: var(--kp-fs-small);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.kp-toolbar-subtitle {
  margin-top: 2px;
  font-size: var(--kp-fs-small);
  color: var(--tblr-secondary);
}

/* Form progress strip (kpFormProgress): "3 required fields left" / "Ready to save"
   in a form's header, on the subtitle's line. Same size and muted colour as the
   subtitle; the count is a warning pill, "Ready to save" is success text with a
   check. The min-width keeps the line from shifting between the two states. */
.kp-toolbar-title:has(.kp-form-progress) {
  flex-flow: row wrap;
  align-items: baseline;
  column-gap: 12px;
}

.kp-toolbar-title:has(.kp-form-progress) > .kp-pretitle,
.kp-toolbar-title:has(.kp-form-progress) > .kp-toolbar-heading {
  flex: 0 0 100%;
}

.kp-form-progress {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-width: 11.5em;
  margin: 2px 0 0;
  padding: 0;
  border: 0;
  background: transparent;
  font-size: var(--kp-fs-small);
  color: var(--tblr-secondary);
}

button.kp-form-progress {
  cursor: pointer;
  text-align: left;
}

button.kp-form-progress:hover .kp-form-progress-pill {
  text-decoration: underline;
}

.kp-form-progress-pill {
  padding: 1px 8px;
  border-radius: var(--kp-radius-pill);
  background: var(--kp-status-warning-bg);
  color: var(--kp-status-warning-fg);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.kp-form-progress.is-ready {
  color: var(--kp-status-success-fg);
}

.kp-viewswitch {
  display: inline-flex;
  padding: 2px;
  border: 1px solid var(--tblr-border-color);
  border-radius: var(--kp-radius);
  background: var(--tblr-bg-surface-secondary);
}

.kp-viewswitch-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 26px;
  padding: 0 10px;
  border: 0;
  background: transparent;
  border-radius: var(--kp-radius-sm);
  color: var(--tblr-secondary);
  font-size: var(--kp-fs-small);
  font-weight: 500;
}

.kp-viewswitch-btn.active {
  background: var(--tblr-bg-surface);
  color: var(--tblr-body-color);
  box-shadow: 0 1px 2px rgba(15, 23, 42, .08);
}

.kp-toolbar-filters {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

/* "Clear filters" at the end of the filter row, while a filter is set (pageToolbar `filtered`). */
.kp-toolbar-clear {
  padding-inline: 6px;
  white-space: nowrap;
  text-decoration: none;
}

.kp-toolbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
  margin-left: auto;
}

/* On a phone the page's buttons wrap onto a second line rather than running
   off the right edge (a record's toolbar can carry four). */
@media (max-width: 575.98px) {
  .kp-toolbar-actions {
    flex: 1 1 100%;
    flex-wrap: wrap;
  }
}

/* An action that is shown but not yet possible (decisions Q21 and Q23 of
   2026-10-05: "Create sales order" before the customer has accepted). The
   button is greyed and the reason sits beside it; the wrapper carries the same
   reason as its hint, since a disabled button answers no hover of its own.
   The written reason gives way on a narrow window, where the hint remains. */
.kp-disabled-action {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: not-allowed;
}

.kp-disabled-action > .btn {
  pointer-events: none;
}

.kp-disabled-reason {
  font-size: var(--kp-fs-small);
  line-height: 1.35;
  color: var(--tblr-secondary);
  white-space: nowrap;
}

@media (max-width: 1199.98px) {
  .kp-disabled-reason {
    display: none;
  }
}

/* ==========================================================================
   6b. Toolbar band and module tile (DESIGN.md section 1, "Colour")
   --------------------------------------------------------------------------
   One colour job here:
   - the toolbar band, edge to edge under the tab strip, is plain for every
     entity in both themes: a tinted band behind a working toolbar read as a
     warning for the red and orange entities. The entity shows on its tile,
     its chips and its tab edge;
   - the MODULE colour fills the tile before the title (`kpToolbarIcon`), from
     `data-module` on the shell, the same hues the sidebar groups use.
   ========================================================================== */

.kp-shell {
  --kp-module-hue: var(--kp-hue-admin);
  --kp-module-hue-soft: var(--kp-hue-admin-soft);
}
.kp-shell[data-module="mywork"] { --kp-module-hue: var(--kp-hue-mywork); --kp-module-hue-soft: var(--kp-hue-mywork-soft); }
.kp-shell[data-module="sales"] { --kp-module-hue: var(--kp-hue-sales); --kp-module-hue-soft: var(--kp-hue-sales-soft); }
.kp-shell[data-module="customers"] { --kp-module-hue: var(--kp-hue-customers); --kp-module-hue-soft: var(--kp-hue-customers-soft); }
.kp-shell[data-module="planning"] { --kp-module-hue: var(--kp-hue-planning); --kp-module-hue-soft: var(--kp-hue-planning-soft); }
.kp-shell[data-module="catalogue"] { --kp-module-hue: var(--kp-hue-catalogue); --kp-module-hue-soft: var(--kp-hue-catalogue-soft); }
.kp-shell[data-module="insights"] { --kp-module-hue: var(--kp-hue-insights); --kp-module-hue-soft: var(--kp-hue-insights-soft); }

.kp-toolbar-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  align-self: center;
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: var(--kp-module-hue-soft);
  color: var(--kp-module-hue);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--kp-module-hue) 20%, transparent);
  font-size: 20px;
}

/* The band: the page's toolbar pulled out to the edges of the content area and
   up against the tab strip. The 16px is the top padding of `.kp-content`. */
.kp-content .kp-toolbar:not(.kp-print-toolbar) {
  margin: -16px calc(-1 * var(--kp-page-padding)) 16px;
  padding: 10px var(--kp-page-padding);
  background: var(--tblr-bg-surface-secondary);
  border-bottom: 1px solid var(--tblr-border-color);
}

/* Legacy pages wrap themselves in Bootstrap's `.container-fluid`, whose side
   padding put their cards 14px inside the modern pages' edge and kept the band
   off the edges. The content area already has the page padding. */
.kp-content > .container-fluid {
  padding-left: 0;
  padding-right: 0;
}

/* Legacy page-header classes, still used by unmigrated pages. */
.kp-page-header {
  display: flex;
  align-items: flex-end;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.kp-page-header-body { min-width: 0; flex: 1 1 auto; }

.kp-page-title {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin: 0;
  font-size: var(--kp-fs-title);
  font-weight: 700;
  letter-spacing: -.02em;
}

.kp-page-count {
  font-size: var(--kp-fs-body);
  font-weight: 500;
  color: var(--tblr-secondary);
  font-variant-numeric: tabular-nums;
}

.kp-page-subtitle {
  margin: 2px 0 0;
  font-size: var(--kp-fs-small);
  color: var(--tblr-secondary);
}

.kp-page-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
  margin-left: auto;
}

/* ==========================================================================
   7. Inspector, command palette, Home
   ========================================================================== */

.kp-inspector {
  flex: 0 0 var(--kp-inspector-width);
  width: var(--kp-inspector-width);
  border-left: 1px solid var(--tblr-border-color);
  background: var(--tblr-bg-surface);
  overflow-y: auto;
}

.kp-inspector-head {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  height: var(--kp-toolbar-height);
  padding: 0 12px;
  border-bottom: 1px solid var(--tblr-border-color);
  background: var(--tblr-bg-surface);
}

.kp-inspector-title {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: var(--kp-fs-body);
  font-weight: 600;
}

.kp-inspector-head .kp-icon-btn {
  margin-left: auto;
}

.kp-inspector-body {
  padding: 12px;
  font-size: var(--kp-fs-body);
}

/* Below 1200px the inspector overlays the content instead of shrinking it. */
@media (max-width: 1199.98px) {
  .kp-inspector {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    z-index: 1045;
    box-shadow: var(--kp-shadow-float);
  }
}

/* Command palette */
.kp-palette-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1060;
  display: flex;
  justify-content: center;
  padding-top: 12vh;
  background: rgba(15, 23, 42, .4);
}

.kp-palette {
  display: flex;
  flex-direction: column;
  width: min(640px, calc(100vw - 32px));
  max-height: 70vh;
  border: 1px solid var(--tblr-border-color);
  border-radius: var(--kp-radius);
  background: var(--tblr-bg-surface);
  box-shadow: var(--kp-shadow-float);
  overflow: hidden;
}

.kp-palette-input {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--tblr-border-color);
  color: var(--tblr-secondary);
}

.kp-palette-input .form-control {
  border: 0;
  background: transparent;
  box-shadow: none;
  font-size: var(--kp-fs-card);
  padding: 0;
}

.kp-palette-input .form-control:focus {
  box-shadow: none;
}

.kp-palette-results {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 6px;
}

.kp-palette-group + .kp-palette-group {
  margin-top: 6px;
}

.kp-palette-group-label {
  padding: 6px 8px 4px;
  font-size: var(--kp-fs-label);
  font-weight: 600;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--tblr-secondary);
}

.kp-palette-row {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  height: 34px;
  padding: 0 8px;
  border: 0;
  background: transparent;
  border-radius: var(--kp-radius-sm);
  color: var(--tblr-body-color);
  font-size: var(--kp-fs-body);
  text-align: left;
}

.kp-palette-row-active,
.kp-palette-row:hover {
  background: var(--kp-primary-soft);
}

.kp-palette-row-icon {
  flex: 0 0 17px;
  font-size: 17px;
  color: var(--tblr-secondary);
}

.kp-palette-row-label {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.kp-palette-row-meta {
  margin-left: auto;
  padding-left: 12px;
  color: var(--tblr-secondary);
  font-size: var(--kp-fs-small);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 45%;
}

.kp-palette-empty {
  padding: 24px 12px;
  text-align: center;
  color: var(--tblr-secondary);
  font-size: var(--kp-fs-body);
}

.kp-palette-foot {
  display: flex;
  gap: 16px;
  padding: 8px 12px;
  border-top: 1px solid var(--tblr-border-color);
  background: var(--tblr-bg-surface-secondary);
  color: var(--tblr-secondary);
  font-size: var(--kp-fs-label);
}

.kp-palette-spinner {
  flex: 0 0 auto;
  color: var(--tblr-secondary);
}

/* A record row: title, number chip and status on the first line, what it
   belongs to below. Pages and actions keep the one line row. */
.kp-palette-row.kp-palette-record {
  height: auto;
  min-height: 44px;
  padding-top: 5px;
  padding-bottom: 5px;
}

.kp-palette-record-main {
  display: flex;
  flex-direction: column;
  min-width: 0;
  flex: 1 1 auto;
  gap: 1px;
}

.kp-palette-record-line {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.kp-palette-record-sub {
  overflow: hidden;
  color: var(--tblr-secondary);
  font-size: var(--kp-fs-small);
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* A document number or code, next to a search result's title. */
.kp-palette-code {
  flex: 0 0 auto;
  padding: 0 6px;
  border-radius: var(--kp-radius-sm);
  background: var(--tblr-bg-surface-secondary);
  color: var(--tblr-secondary);
  font-family: var(--kp-font-mono, ui-monospace, SFMono-Regular, Menlo, monospace);
  font-size: var(--kp-fs-label);
  line-height: 18px;
  white-space: nowrap;
}

.kp-palette-status {
  flex: 0 0 auto;
  margin-left: auto;
  color: var(--tblr-secondary);
  font-size: var(--kp-fs-small);
  white-space: nowrap;
}

/* The part of a result that matches what was typed. */
mark.kp-hl {
  padding: 0;
  border-radius: 2px;
  background: color-mix(in srgb, #FBBF24 38%, transparent);
  /* Body colour, also where the match sits in a muted line. */
  color: var(--tblr-body-color);
  font-weight: 600;
}

[data-bs-theme="dark"] mark.kp-hl {
  background: color-mix(in srgb, #FBBF24 30%, transparent);
}

/* A document line's product: SAP's three sub groups as filters above the
   product picker (kpProductLine). The filters also show the chosen product's
   values, so no separate grade column is needed. */
.kp-productline {
  display: flex;
  flex-direction: column;
  gap: 6px;
  /* The column that holds it sets the width (at least 420px in the line
     tables), so it never spills into the next cell. */
  min-width: 0;
}

/* The grade is a short code, so its filter takes less room than the two sub
   groups, whose empty labels ("Subgroup 1") must fit. */
.kp-productline-filters {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 1.1fr) minmax(0, .8fr);
  gap: 6px;
}

.kp-productline-filter,
.kp-productline-product {
  min-width: 0;
}

/* In the narrow filters the chosen value gets the room: the search box
   beside it may shrink to nothing and still takes what is left when typing. */
.kp-productline-filter .kp-picker:not(.kp-picker-multi) .kp-picker-single + .kp-picker-search {
  flex-basis: 4px;
  min-width: 4px;
}

.kp-productline-readonly {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.kp-productline-name {
  font-weight: 500;
}

.kp-productline-groups {
  color: var(--tblr-secondary);
  font-size: var(--kp-fs-small);
}

/* Search page (/search/:text). */
.kp-search-page {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
  max-width: 1080px;
}

.kp-search-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 6px 6px 14px;
  border: 1px solid var(--tblr-border-color);
  border-radius: var(--kp-radius);
  background: var(--tblr-bg-surface);
  color: var(--tblr-secondary);
}

.kp-search-bar:focus-within {
  border-color: var(--tblr-primary);
  box-shadow: 0 0 0 3px var(--kp-primary-soft);
}

.kp-search-bar .form-control {
  flex: 1 1 auto;
  min-width: 0;
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
  font-size: var(--kp-fs-card);
}

.kp-search-bar .form-control:focus {
  box-shadow: none;
}

.kp-search-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.kp-search-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 28px;
  padding: 0 10px;
  border: 1px solid var(--tblr-border-color);
  border-radius: var(--kp-radius-pill);
  background: var(--tblr-bg-surface);
  color: var(--tblr-body-color);
  font-size: var(--kp-fs-small);
  white-space: nowrap;
}

.kp-search-chip:hover {
  background: var(--kp-primary-soft);
}

.kp-search-chip.active {
  border-color: var(--tblr-primary);
  background: var(--kp-primary-soft);
  color: var(--tblr-primary);
  font-weight: 600;
}

.kp-search-chip i {
  font-size: 15px;
}

.kp-search-chip-count {
  color: var(--tblr-secondary);
  font-size: var(--kp-fs-small);
  font-weight: 500;
}

.kp-search-group {
  overflow: hidden;
}

.kp-search-group-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--tblr-border-color);
}

.kp-search-group-title {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
}

.kp-search-group-title i {
  color: var(--tblr-secondary);
  font-size: 17px;
}

.kp-search-listlink {
  font-size: var(--kp-fs-small);
  white-space: nowrap;
}

.kp-search-rows {
  margin: 0;
  padding: 0;
  list-style: none;
}

.kp-search-rows li + li {
  border-top: 1px solid var(--tblr-border-color);
}

.kp-search-row {
  display: flex;
  align-items: center;
  gap: 16px;
  width: 100%;
  padding: 9px 14px;
  border: 0;
  background: transparent;
  color: var(--tblr-body-color);
  text-align: left;
}

.kp-search-row:hover,
.kp-search-row:focus-visible {
  background: var(--kp-primary-soft);
  outline: none;
}

.kp-search-row-main {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-width: 0;
  gap: 2px;
}

.kp-search-row-line {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.kp-search-row-title {
  overflow: hidden;
  font-weight: 500;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.kp-search-row-sub {
  overflow: hidden;
  color: var(--tblr-secondary);
  font-size: var(--kp-fs-small);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.kp-search-row-side {
  display: flex;
  flex: 0 0 auto;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
  color: var(--tblr-secondary);
  font-size: var(--kp-fs-small);
  white-space: nowrap;
}

.kp-search-row-money {
  color: var(--tblr-body-color);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.kp-search-row-owner i {
  margin-right: 3px;
}

.kp-search-more {
  display: block;
  width: 100%;
  padding: 8px 14px;
  border: 0;
  border-top: 1px solid var(--tblr-border-color);
  background: var(--tblr-bg-surface-secondary);
  color: var(--tblr-primary);
  font-size: var(--kp-fs-small);
  text-align: left;
}

.kp-search-more:hover {
  text-decoration: underline;
}

.kp-search-tip {
  font-size: var(--kp-fs-small);
}

/* Phone: the side column moves under the title. */
@media (max-width: 575.98px) {
  .kp-search-row {
    flex-direction: column;
    align-items: stretch;
    gap: 4px;
  }

  .kp-search-row-side {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
  }

  .kp-search-bar .btn {
    display: none;
  }

  /* No keyboard on a phone: the shortcut hints only take room. */
  .kp-palette-foot {
    display: none;
  }
}

/* Home tab */

/* Hue helpers: a card or chip sets one and the tile, empty-state circle and
   accents below follow. Colour is applied to small elements only. */
.kp-hue-rose { --kp-card-hue: var(--kp-hue-mywork); --kp-card-hue-soft: var(--kp-hue-mywork-soft); }
.kp-hue-amber { --kp-card-hue: var(--kp-hue-planning); --kp-card-hue-soft: var(--kp-hue-planning-soft); }
.kp-hue-red { --kp-card-hue: var(--tblr-danger); --kp-card-hue-soft: var(--kp-status-danger-bg); }
.kp-hue-indigo { --kp-card-hue: var(--tblr-primary); --kp-card-hue-soft: var(--kp-primary-soft); }
.kp-hue-teal { --kp-card-hue: var(--kp-hue-customers); --kp-card-hue-soft: var(--kp-hue-customers-soft); }
.kp-hue-violet { --kp-card-hue: var(--kp-hue-catalogue); --kp-card-hue-soft: var(--kp-hue-catalogue-soft); }

.kp-tile {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 28px;
  width: 28px;
  height: 28px;
  border-radius: 7px;
  background: var(--kp-card-hue-soft, var(--tblr-bg-surface-secondary));
  color: var(--kp-card-hue, var(--tblr-secondary));
  font-size: 16px;
  line-height: 1;
}

/* Greeting band: the one place the entity colour touches a wide surface, and
   only as a 14% wash that fades into the primary tint. */
.kp-home-hero {
  display: flex;
  align-items: center;
  gap: 20px;
  flex-wrap: wrap;
  margin-bottom: 16px;
  padding: 20px;
  border: 1px solid var(--tblr-border-color);
  border-radius: var(--kp-radius);
  background-image: linear-gradient(
    100deg,
    color-mix(in srgb, var(--kp-accent) 14%, var(--tblr-bg-surface)),
    var(--kp-primary-soft)
  );
}

/* Dark mode: the band is flat; a tint of the entity colour turns murky on
   near-black. */
[data-bs-theme="dark"] .kp-home-hero {
  background-image: none;
  background-color: var(--tblr-bg-surface);
}

.kp-home-hero-main {
  min-width: 0;
  flex: 1 1 260px;
}

.kp-home-hero-title {
  margin: 0;
  font-size: var(--kp-fs-display);
  font-weight: 700;
  letter-spacing: -.02em;
}

.kp-home-hero-meta {
  margin-top: 2px;
  font-size: var(--kp-fs-small);
  color: var(--tblr-secondary);
}

.kp-home-stats {
  display: flex;
  align-items: stretch;
  gap: 8px;
  flex: 0 0 auto;
  flex-wrap: wrap;
  /* On a phone the four tiles wrap inside the banner instead of running off
     the page. */
  max-width: 100%;
}

.kp-stat {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 132px;
  padding: 8px 12px;
  border: 1px solid var(--tblr-border-color);
  border-radius: var(--kp-radius);
  background: var(--tblr-bg-surface);
}

.kp-stat-main {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
  min-width: 0;
}

.kp-stat-value {
  font-size: var(--kp-fs-card);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.kp-stat-label {
  font-size: var(--kp-fs-small);
  color: var(--tblr-secondary);
  white-space: nowrap;
}

/* A count of zero steps back: grey tile, grey figure, so the counts that
   need doing stand out (home.html). */
.kp-stat.is-zero {
  --kp-card-hue: var(--tblr-secondary);
  --kp-card-hue-soft: var(--tblr-bg-surface-secondary);
}

.kp-stat.is-zero .kp-stat-value {
  color: var(--tblr-secondary);
  font-weight: 600;
}

/* The four cards form a 2x2 grid. `stretch` makes both cards in a row the
   height of the taller one, so a card without a button (Approvals) no longer
   stops short of its neighbour. */
.kp-home {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 16px;
  align-items: stretch;
}

/* Two columns from 1200px so the four cards fill a 2x2 grid with no gap. */
@media (min-width: 1200px) {
  .kp-home {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

/* Each card is a column: head at its natural height, body taking the rest, so
   the empty state can centre itself in whatever height the row gives it. */
.kp-home-card {
  display: flex;
  flex-direction: column;
}

/* A My work link (?focus=) lands on its card: a selection ring that fades, so the
   eye finds the card after the scroll. */
.kp-home-card.kp-home-card-flash {
  scroll-margin-top: 12px;
  animation: kp-home-card-flash 1.8s ease-out;
}
@keyframes kp-home-card-flash {
  0%, 40% { box-shadow: 0 0 0 3px var(--tblr-primary); }
  100% { box-shadow: 0 0 0 3px transparent; }
}
@media (prefers-reduced-motion: reduce) {
  .kp-home-card.kp-home-card-flash { animation: none; outline: 2px solid var(--tblr-primary); outline-offset: 2px; }
}

.kp-home-card-head {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 8px 14px;
}

/* A card lists at most twenty rows and scrolls past about eight of them, so one
   long card cannot stretch the row and leave its neighbour a tall empty box. */
.kp-home-card-body {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  padding: 6px;
  max-height: 360px;
  overflow-y: auto;
  overscroll-behavior: contain;
  /* The scrollbar is the app-wide one (section 30). */
}

.kp-home-row {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  flex: 0 0 auto;
  padding: 8px 8px;
  border: 0;
  background: transparent;
  border-radius: var(--kp-radius-sm);
  color: var(--tblr-body-color);
  font-size: var(--kp-fs-body);
  text-align: left;
}

/* Hairlines sit between rows only: never above the first, never below the last,
   and they step out of the way of whichever row is hovered. */
.kp-home-row + .kp-home-row::before {
  content: '';
  position: absolute;
  top: 0;
  left: 8px;
  right: 8px;
  height: 1px;
  background: var(--tblr-border-color);
  opacity: .55;
}

.kp-home-row:hover {
  background: var(--tblr-bg-surface-secondary);
}

.kp-home-row:hover::before,
.kp-home-row:hover + .kp-home-row::before {
  opacity: 0;
}

/* "View all 598", shown only when the card holds more than it lists. */
.kp-home-card-foot {
  flex: 0 0 auto;
  padding: 6px 10px;
  border-top: 1px solid var(--tblr-border-color);
  background: transparent;
}

.kp-home-more {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 6px;
  border: 0;
  border-radius: var(--kp-radius-sm);
  background: transparent;
  color: var(--kp-card-hue, var(--tblr-primary));
  font-size: var(--kp-fs-small);
  font-weight: 500;
}

.kp-home-more:hover {
  background: var(--kp-card-hue-soft, var(--tblr-bg-surface-secondary));
}

.kp-home-more i {
  font-size: 14px;
}

.kp-home-row-main {
  display: flex;
  flex-direction: column;
  min-width: 0;
  flex: 1 1 auto;
}

.kp-home-row-title {
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.kp-home-row-meta {
  color: var(--tblr-secondary);
  font-size: var(--kp-fs-small);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.kp-home-row-side {
  flex: 0 0 auto;
  color: var(--tblr-secondary);
  font-size: var(--kp-fs-small);
  font-variant-numeric: tabular-nums;
}

/* "Nothing here" says so in a small space: the card stays about as tall as a
   few rows would make it, not a big box around one sentence. */
.kp-home-empty {
  display: flex;
  flex: 1 1 auto;
  min-height: 96px;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 12px;
  color: var(--tblr-secondary);
  font-size: var(--kp-fs-small);
  text-align: center;
}

.kp-home-empty i {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: var(--kp-radius-pill);
  background: var(--kp-card-hue-soft, var(--tblr-bg-surface-secondary));
  color: var(--kp-card-hue, var(--tblr-secondary));
  font-size: 17px;
}

/* `dense` lets a half-width card move up beside the one before a wide card. */
.kp-home {
  grid-auto-flow: dense;
}

/* The last of an odd number of half-width cards takes the row (home.js). */
.kp-home-card.kp-home-lone {
  grid-column: 1 / -1;
}

/* Follow-ups, approvals and SAP failures with nothing in them are not drawn
   as cards: one "All clear" line at the foot names them, and a second says
   how to pin a view when there is none (home.js, `allClear`). */
.kp-home-clear {
  padding: 4px 0;
}

.kp-home-clear-line {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 12px;
  padding: 8px 14px;
  color: var(--tblr-secondary);
  font-size: var(--kp-fs-small);
}

.kp-home-clear-line + .kp-home-clear-line {
  border-top: 1px solid var(--tblr-border-color);
}

.kp-home-clear-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 28px;
  width: 28px;
  height: 28px;
  border-radius: 7px;
  background: var(--kp-status-success-bg);
  color: var(--kp-status-success-fg);
  font-size: 16px;
}

.kp-home-clear-pins .kp-home-clear-icon {
  background: var(--tblr-bg-surface-secondary);
  color: var(--tblr-secondary);
}

.kp-home-clear-title {
  margin: 0;
  color: var(--tblr-body-color);
}

.kp-home-clear-items {
  display: flex;
  flex-wrap: wrap;
  gap: 2px 0;
  margin: 0;
  padding: 0;
  list-style: none;
}

.kp-home-clear-items > li + li::before {
  content: '\00B7';
  margin: 0 8px;
}

.kp-home-clear-go {
  margin-left: auto;
}

/* Floating elements are the only things that get a shadow. */
.dropdown-menu,
.modal-content,
.popover,
.offcanvas {
  box-shadow: var(--kp-shadow-float);
  border-color: var(--tblr-border-color);
}


/* ==========================================================================
   8. Surfaces, tables and controls
   ========================================================================== */

.card {
  background: var(--tblr-bg-surface);
  border: 1px solid var(--tblr-border-color);
  border-radius: var(--kp-radius);
  box-shadow: var(--kp-card-shadow);
}

/* Only a card that IS an action (a link, a board card, a tile) answers hover;
   a card that merely holds a form or a table stays still, because nothing
   happens when it is clicked (DESIGN.md section 1). */
.kp-card-interactive {
  cursor: pointer;
  transition: box-shadow var(--kp-transition), border-color var(--kp-transition),
    transform var(--kp-transition);
}

.kp-card-interactive:hover {
  border-color: var(--tblr-primary);
  box-shadow: var(--kp-card-shadow-hover);
  transform: translateY(-1px);
}

.kp-card-interactive:focus-visible {
  outline: 2px solid rgba(var(--tblr-primary-rgb), .4);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  .kp-card-interactive:hover { transform: none; }
}

.card-header,
.card-footer {
  background: transparent;
  border-color: var(--tblr-border-color);
}

.card-title {
  font-size: var(--kp-fs-card);
  font-weight: 600;
  margin: 0;
}

.table {
  font-size: var(--kp-fs-body);
  color: var(--tblr-body-color);
}

.table > thead > tr > th {
  text-transform: none;  /* Tabler capitalises these; labels here are sentence case */
  letter-spacing: normal;
  background: var(--tblr-bg-surface-secondary);
  font-size: var(--kp-fs-small);
  font-weight: 600;
  color: var(--tblr-secondary);
  border-bottom: 1px solid var(--tblr-border-color);
}

.table > tbody > tr:hover > * {
  background: var(--tblr-bg-surface-secondary);
}

.form-control,
.form-select {
  font-size: var(--kp-fs-body);
  border-radius: var(--kp-radius);
  border-color: var(--kp-control-border);
  background-color: var(--tblr-bg-surface);
  color: var(--tblr-body-color);
}

.form-control:focus,
.form-select:focus {
  border-color: var(--tblr-primary);
  box-shadow: var(--kp-focus-ring);
}

/* Placeholders are examples, not content: one token based colour that stays
   readable in both themes without competing with a typed value. */
.form-control::placeholder,
.form-select::placeholder,
textarea::placeholder,
input::placeholder {
  color: var(--tblr-secondary);
  opacity: 0.7;
}

.btn {
  font-size: var(--kp-fs-body);
  font-weight: 500;
  border-radius: var(--kp-radius);
}

/* Two heights only, set in px because Tabler sizes a button in rem and the
   root is 13px (--kp-fs-body): 32px for a normal button, 28px for `.btn-sm` (table rows,
   side panels and other tight places). Line height, padding and the 1px
   border add up to the height; Tabler's min-height follows the same numbers. */
.btn {
  --tblr-btn-line-height: 20px;
  --tblr-btn-padding-y: 5px;
}

.btn-sm,
.btn-group-sm > .btn {
  --tblr-btn-line-height: 18px;
  --tblr-btn-padding-y: 4px;
}

/* One secondary button: the white one a plain `.btn` already is. The outline
   classes older toolbars carry are drawn the same, so a list toolbar and a
   record header match. */
.btn-outline-secondary,
.btn-outline {
  --tblr-btn-color: var(--tblr-body-color);
  --tblr-btn-bg: var(--tblr-bg-surface);
  --tblr-btn-border-color: var(--tblr-border-color);
  --tblr-btn-hover-color: var(--tblr-body-color);
  --tblr-btn-hover-bg: var(--tblr-bg-surface);
  --tblr-btn-hover-border-color: var(--tblr-border-active-color);
  --tblr-btn-active-color: var(--tblr-primary);
  --tblr-btn-active-bg: color-mix(in srgb, var(--tblr-primary) 4%, transparent);
  --tblr-btn-active-border-color: var(--tblr-primary);
  --tblr-btn-disabled-color: var(--tblr-body-color);
  --tblr-btn-disabled-border-color: var(--tblr-border-color);
}

/* Tabler paints a link button in a fixed blue of its own. */
.btn-link,
.btn-link:hover {
  color: var(--tblr-primary);
}

.badge {
  border-radius: var(--kp-radius-sm);
  font-weight: 600;
}

.badge.rounded-pill {
  border-radius: var(--kp-radius-pill);
}

/* ==========================================================================
   9. Feedback - the success box
   ========================================================================== */

/* A success: a box in the centre of the screen with a tick, which goes by
   itself (imports/ui/shell/feedback.js). It sits above the page, its sticky
   footers and its dialogs, and takes no clicks away from the page around it. */
.kp-success {
  position: fixed;
  top: 50%;
  left: 50%;
  z-index: 1095;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  width: max-content;
  min-width: 220px;
  max-width: min(420px, calc(100vw - 32px));
  padding: 22px 26px 20px;
  transform: translate(-50%, -50%);
  border: 1px solid var(--tblr-border-color);
  border-radius: var(--kp-radius, 8px);
  background: var(--tblr-bg-surface);
  box-shadow: 0 12px 32px rgba(15, 23, 42, .18);
  text-align: center;
  cursor: pointer;
  animation: kp-success-in .16s ease-out;
}

.kp-success-icon {
  font-size: 44px;
  line-height: 1;
  color: var(--tblr-success);
}

.kp-success-text {
  font-size: var(--kp-fs-card);
  font-weight: 600;
  color: var(--tblr-body-color);
  overflow-wrap: anywhere;
}

@keyframes kp-success-in {
  from { opacity: 0; transform: translate(-50%, -46%) scale(.96); }
  to { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}

@media (prefers-reduced-motion: reduce) {
  .kp-success { animation: none; }
}

/* ==========================================================================
   9b. Table, board and card base (DESIGN.md section 2, "Content")
   ========================================================================== */

/* Tables: sticky header, row hover, a leading checkbox column and a trailing row
   menu that only appears on hover. Pages opt in with .kp-table on the table. */
.kp-table-wrap {
  overflow: auto;
  border: 1px solid var(--tblr-border-color);
  border-radius: var(--kp-radius);
  background: var(--tblr-bg-surface);
}

.kp-table {
  width: 100%;
  margin: 0;
  font-size: var(--kp-fs-body);
  border-collapse: separate;
  border-spacing: 0;
}

.kp-table > thead > tr > th {
  text-transform: none;  /* Tabler capitalises these; labels here are sentence case */
  letter-spacing: normal;
  position: sticky;
  top: 0;
  z-index: 2;
  padding: 8px 12px;
  background: var(--tblr-bg-surface-secondary);
  border-bottom: 1px solid var(--tblr-border-color);
  font-size: var(--kp-fs-small);
  font-weight: 600;
  color: var(--tblr-secondary);
  white-space: nowrap;
}

.kp-table > tbody > tr > td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--tblr-border-color);
  vertical-align: middle;
}

.kp-table > tbody > tr:hover > td {
  background: var(--tblr-bg-surface-secondary);
  cursor: pointer;
}

.kp-table > tbody > tr.kp-row-selected > td {
  background: var(--kp-primary-soft);
}

.kp-table th.kp-col-check,
.kp-table td.kp-col-check {
  width: 36px;
  padding-right: 0;
}

.kp-table th.kp-col-menu,
.kp-table td.kp-col-menu {
  width: 36px;
  text-align: right;
}

.kp-table td.kp-col-menu .kp-row-menu {
  opacity: 0;
  transition: opacity var(--kp-transition);
}

/* The dots also stay while their menu is open (the pointer may have left the
   row) and while the keyboard is on them: an open menu is never invisible. */
.kp-table > tbody > tr:hover td.kp-col-menu .kp-row-menu,
.kp-table td.kp-col-menu .kp-row-menu:has(> .dropdown-menu.show),
.kp-table td.kp-col-menu .kp-row-menu:has(:focus-visible) {
  opacity: 1;
}

/* Empty state: an icon, one sentence, one button. */
.kp-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 48px 16px;
  color: var(--tblr-secondary);
  text-align: center;
}

/* Only the state's own icon: an icon inside its button keeps the button's size. */
.kp-empty > i {
  font-size: 28px;
}

/* Board: one column per stage, compact cards. */
.kp-board {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  overflow-x: auto;
  padding-bottom: 8px;
}

.kp-board-col {
  flex: 0 0 280px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 8px;
  border: 1px solid var(--tblr-border-color);
  border-radius: var(--kp-radius);
  background: var(--tblr-bg-surface-secondary);
}

.kp-board-col-head {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: var(--kp-fs-small);
  font-weight: 600;
}

.kp-board-col-total {
  margin-left: auto;
  color: var(--tblr-secondary);
  font-variant-numeric: tabular-nums;
  /* In a narrow column a long label wraps; the amount stays whole. */
  white-space: nowrap;
}

.kp-board-card {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 10px;
  border: 1px solid var(--tblr-border-color);
  border-radius: var(--kp-radius-sm);
  background: var(--tblr-bg-surface);
  font-size: var(--kp-fs-body);
}

.kp-board-card {
  box-shadow: var(--kp-card-shadow);
  transition: box-shadow var(--kp-transition), border-color var(--kp-transition);
}

.kp-board-card:hover {
  border-color: var(--tblr-primary);
  box-shadow: var(--kp-card-shadow-hover);
}

.kp-board-card-title {
  font-weight: 600;
}

/* A long auto-generated name must not make one card twice the height. The card
   template asks for this, so the rule belongs to no one module. */
.kp-board-card-clamp {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.kp-board-card-meta {
  display: flex;
  /* A row of an amount and two chips is wider than a 220px column: the last
     chip goes to a second line instead of being cut at the card's edge. */
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 6px;
  color: var(--tblr-secondary);
  font-size: var(--kp-fs-small);
}

.kp-dot {
  width: 8px;
  height: 8px;
  border-radius: var(--kp-radius-pill);
  background: var(--tblr-secondary);
}

/* Card grid, for record pages and summaries. */
.kp-card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
  align-items: start;
}

/* ==========================================================================
   9c. Loading (DESIGN.md section 2, "Loading states")
   ==========================================================================
   One vocabulary, five pieces: the progress bar under the tab strip, the page
   loader, skeleton rows, the overlay and the busy button, plus the connection
   banner. Nothing here is fixed positioned except the banner, so a loader can
   never cover the sidebar, the tab strip or a modal.
   -------------------------------------------------------------------------- */

/* --- The ring, shared by every variant and by the scroll list footer ------- */
.kp-spinner {
  display: inline-block;
  flex: none;
  border: 2px solid var(--tblr-border-color);
  border-top-color: var(--tblr-primary);
  border-radius: 50%;
  animation: kp-list-spin .7s linear infinite;
}

.kp-spinner-sm { width: 14px; height: 14px; }
.kp-spinner-md { width: 22px; height: 22px; }
.kp-spinner-lg { width: 32px; height: 32px; }

/* --- Inline -------------------------------------------------------------- */
.kp-loader-inline {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--tblr-secondary);
  font-size: var(--kp-fs-body);
}

.kp-loader-label {
  color: var(--tblr-secondary);
  font-size: var(--kp-fs-body);
}

/* --- Page ---------------------------------------------------------------- */
.kp-loader-page {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  width: 100%;
  min-height: 180px;
  max-height: 40vh;
  padding: 32px 16px;
  text-align: center;
}

.kp-loader-page .kp-loader-label {
  max-width: 34ch;
  font-size: var(--kp-fs-body);
}

/* --- Overlay ------------------------------------------------------------- */
/* The host bounds the overlay: a card, a modal body or a drawer panel. */
.kp-loader-host {
  position: relative;
}

.kp-loader-overlay {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  border-radius: inherit;
  background: color-mix(in srgb, var(--tblr-bg-surface) 72%, transparent);
  backdrop-filter: blur(1px);
}

/* --- Skeleton ------------------------------------------------------------ */
.kp-skeleton {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px 0;
}

.kp-skeleton-bar {
  display: block;
  height: 10px;
  border-radius: var(--kp-radius-sm);
  background: linear-gradient(
    90deg,
    var(--tblr-bg-surface-secondary) 0%,
    var(--tblr-border-color) 50%,
    var(--tblr-bg-surface-secondary) 100%
  );
  background-size: 200% 100%;
  animation: kp-skeleton-shimmer 1.4s ease-in-out infinite;
}

.kp-skeleton-row > td {
  vertical-align: middle;
}

@keyframes kp-skeleton-shimmer {
  from { background-position: 200% 0; }
  to { background-position: -200% 0; }
}

/* --- Busy button --------------------------------------------------------- */
.kp-btn-busy {
  position: relative;
  pointer-events: none;
  color: transparent !important;
}

.kp-btn-busy > * {
  visibility: hidden;
}

.kp-btn-busy::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 14px;
  height: 14px;
  margin: -7px 0 0 -7px;
  border: 2px solid currentColor;
  border-top-color: var(--tblr-primary);
  border-radius: 50%;
  color: var(--tblr-border-color);
  animation: kp-list-spin .7s linear infinite;
}

/* --- Progress bar -------------------------------------------------------- */
.kp-progress {
  position: absolute;
  top: 0;
  right: 0;
  left: 0;
  z-index: 4;
  height: 3px;
  overflow: hidden;
  background: color-mix(in srgb, var(--kp-accent, var(--tblr-primary)) 14%, transparent);
  opacity: 0;
  pointer-events: none;
  transition: opacity 200ms ease;
}

.kp-progress.is-active {
  opacity: 1;
}

.kp-progress > span {
  display: block;
  width: 40%;
  height: 100%;
  border-radius: var(--kp-radius-pill);
  background: linear-gradient(
    90deg,
    transparent 0%,
    var(--kp-accent, var(--tblr-primary)) 30%,
    var(--kp-accent, var(--tblr-primary)) 70%,
    transparent 100%
  );
  animation: kp-progress-slide 1.1s ease-in-out infinite;
}

@keyframes kp-progress-slide {
  from { transform: translateX(-100%); }
  to { transform: translateX(350%); }
}

/* --- Connection banner --------------------------------------------------- */
/* A pill, not a blocker: it sits above modals but leaves the page readable. */
.kp-conn-banner {
  position: fixed;
  top: 12px;
  left: 50%;
  z-index: 20000;
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: calc(100vw - 32px);
  padding: 8px 10px 8px 14px;
  transform: translateX(-50%);
  border: 1px solid var(--tblr-border-color);
  border-radius: var(--kp-radius-pill);
  background: var(--tblr-bg-surface);
  box-shadow: var(--kp-shadow-float);
  font-size: var(--kp-fs-body);
  color: var(--tblr-body-color);
}

.kp-conn-banner i {
  color: var(--tblr-warning);
}

.kp-conn-back i {
  color: var(--tblr-success);
}

.kp-conn-offline i {
  color: var(--tblr-danger);
}

.kp-conn-text {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.kp-conn-retry {
  flex: none;
  border-radius: var(--kp-radius-pill);
}

@media (prefers-reduced-motion: reduce) {
  .kp-spinner,
  .kp-btn-busy::after,
  .kp-progress > span,
  .kp-skeleton-bar {
    animation: none;
  }

  .kp-progress > span {
    width: 100%;
  }
}

/* ==========================================================================
   10. Legacy Bootstrap 4 aliases
   --------------------------------------------------------------------------
   Everything below exists only so unmigrated pages keep rendering. Delete a
   rule as soon as the last page using it is migrated. Spacer values follow
   Tabler's scale: 1 = .25rem, 2 = .5rem, 3 = 1rem, 4 = 1.5rem, 5 = 2rem.
   ========================================================================== */

/* Bootstrap 4 form-group spacing, dropped in Bootstrap 5. */
.form-group {
  margin-bottom: 1rem;
}

/* ml-* / mr-* became ms-* / me-*; pl-* / pr-* became ps-* / pe-*. */
.ml-0 { margin-left: 0 !important; }
.ml-1 { margin-left: .25rem !important; }
.ml-2 { margin-left: .5rem !important; }
.ml-3 { margin-left: 1rem !important; }
.ml-4 { margin-left: 1.5rem !important; }
.ml-5 { margin-left: 2rem !important; }
.ml-auto { margin-left: auto !important; }

.mr-0 { margin-right: 0 !important; }
.mr-1 { margin-right: .25rem !important; }
.mr-2 { margin-right: .5rem !important; }
.mr-3 { margin-right: 1rem !important; }
.mr-4 { margin-right: 1.5rem !important; }
.mr-5 { margin-right: 2rem !important; }
.mr-auto { margin-right: auto !important; }

.pl-0 { padding-left: 0 !important; }
.pl-1 { padding-left: .25rem !important; }
.pl-2 { padding-left: .5rem !important; }
.pl-3 { padding-left: 1rem !important; }
.pl-4 { padding-left: 1.5rem !important; }
.pl-5 { padding-left: 2rem !important; }

.pr-0 { padding-right: 0 !important; }
.pr-1 { padding-right: .25rem !important; }
.pr-2 { padding-right: .5rem !important; }
.pr-3 { padding-right: 1rem !important; }
.pr-4 { padding-right: 1.5rem !important; }
.pr-5 { padding-right: 2rem !important; }

/* Bootstrap 4 float and text helpers. The bs5-compat shim also adds the
   Bootstrap 5 class at runtime; these keep static markup correct even before
   the observer has run. */
.float-left { float: left !important; }
.float-right { float: right !important; }
.text-left { text-align: left !important; }
.text-right { text-align: right !important; }
.pull-right { float: right !important; }
.pull-left { float: left !important; }
.sr-only {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Input groups: Bootstrap 5 removed the append/prepend wrappers. */
.input-group-append,
.input-group-prepend {
  display: flex;
  align-items: stretch;
}

.input-group-prepend { margin-right: -1px; }
.input-group-append { margin-left: -1px; }

/* custom-select got the form-select look. */
.custom-select {
  display: block;
  width: 100%;
  padding: .4375rem 2.25rem .4375rem .75rem;
  font-size: var(--kp-fs-body);
  line-height: 1.45;
  color: var(--tblr-body-color);
  background-color: var(--tblr-bg-surface);
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%2364748B' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m2 5 6 6 6-6'/%3e%3c/svg%3e");
  background-repeat: no-repeat;
  background-position: right .75rem center;
  background-size: 16px 12px;
  border: 1px solid var(--kp-control-border);
  border-radius: var(--kp-radius);
  appearance: none;
}

/* btn-block was dropped in Bootstrap 5. */
.btn-block {
  display: block;
  width: 100%;
}

/* Legacy close button: Bootstrap 5 has no `.close`, and we deliberately do not
   alias it to `.btn-close` because that would hide the `&times;` glyph. */
.close {
  padding: 0;
  border: 0;
  background: transparent;
  font-size: 20px;
  font-weight: 600;
  line-height: 1;
  color: var(--tblr-secondary);
  opacity: .7;
  cursor: pointer;
}

.close:hover {
  opacity: 1;
  color: var(--tblr-body-color);
}

/* Bootstrap 4 badge colour variants, renamed to text-bg-* in Bootstrap 5. */
.badge-primary { background-color: var(--tblr-primary); color: #fff; }
.badge-secondary { background-color: var(--tblr-secondary); color: #fff; }
.badge-success { background-color: var(--tblr-success); color: #fff; }
.badge-danger { background-color: var(--tblr-danger); color: #fff; }
.badge-warning { background-color: var(--tblr-warning); color: #fff; }
.badge-info { background-color: var(--tblr-info); color: #fff; }
.badge-light { background-color: var(--tblr-bg-surface-secondary); color: var(--tblr-body-color); }
.badge-dark { background-color: #1E293B; color: #fff; }

/* --------------------------------------------------------------------------
   10a. Toolbar button labels
   --------------------------------------------------------------------------
   The rules that dressed the old list widget's header (`.page-title-box >
   .card > .firstCard`, its filter pills `.taskHeader` and its round icon
   buttons) are gone with the widget: every list is on `pageToolbar` now. What
   is left is what the toolbar buttons of every page still use.
   -------------------------------------------------------------------------- */

/* A button with an icon and a label: the gap Tabler leaves out. */
.btn:not(.btn-icon):has(> .kp-btn-label) {
  gap: 6px;
}

/* Under 1280px the secondary labels collapse so the toolbar never wraps to two
   rows. The `title` and `aria-label` still say what each button does. */
@media (max-width: 1280px) {
  .kp-btn-label {
    display: none;
  }
}

/* On a laptop the toolbar of a list with the most actions (Opportunities, Sales
   orders) still ran onto a second row: the buttons whose icon says it alone
   (Refresh, Pin to Home) drop their label first. Their title says what they do. */
@media (max-width: 1600px) {
  .kp-btn-quiet > .kp-btn-label {
    display: none;
  }
}

/* --------------------------------------------------------------------------
   10b. Status pills
   --------------------------------------------------------------------------
   Every status - lead status, quotation status, activity status, sample
   request status - renders as a small soft pill: a tinted fill and strong
   text, in one of ten swatches (imports/api/statusPill.js). A status an
   administrator colours in a master is drawn through the same swatches, never
   as a solid fill with white text.
   -------------------------------------------------------------------------- */

.kp-status-pill {
  display: inline-flex;
  align-items: center;
  height: 22px;
  padding: 0 8px;
  border-radius: var(--kp-radius-pill);
  background: var(--kp-status-neutral-bg);
  color: var(--kp-status-neutral-fg);
  font-size: var(--kp-fs-small) !important;
  font-weight: 600;
  letter-spacing: .01em;
  line-height: 22px;
  text-transform: none;
  white-space: nowrap;
  vertical-align: middle;
}

/* The ten swatches. Slate, blue, red, amber and green carry a meaning and keep
   the names the code gives them (neutral, info, danger, warning, success). */
.kp-status-pill.kp-status-success { background: var(--kp-status-success-bg); color: var(--kp-status-success-fg); }
.kp-status-pill.kp-status-warning { background: var(--kp-status-warning-bg); color: var(--kp-status-warning-fg); }
.kp-status-pill.kp-status-danger { background: var(--kp-status-danger-bg); color: var(--kp-status-danger-fg); }
.kp-status-pill.kp-status-info { background: var(--kp-status-info-bg); color: var(--kp-status-info-fg); }
.kp-status-pill.kp-status-neutral { background: var(--kp-status-neutral-bg); color: var(--kp-status-neutral-fg); }
.kp-status-pill.kp-status-indigo { background: var(--kp-status-indigo-bg); color: var(--kp-status-indigo-fg); }
.kp-status-pill.kp-status-violet { background: var(--kp-status-violet-bg); color: var(--kp-status-violet-fg); }
.kp-status-pill.kp-status-pink { background: var(--kp-status-pink-bg); color: var(--kp-status-pink-fg); }
.kp-status-pill.kp-status-orange { background: var(--kp-status-orange-bg); color: var(--kp-status-orange-fg); }
.kp-status-pill.kp-status-teal { background: var(--kp-status-teal-bg); color: var(--kp-status-teal-fg); }

/* On the toolbar band these five keep their shape as the other five do
   (section 6b). */
.kp-content .kp-toolbar:not(.kp-print-toolbar) .kp-status-pill:is(.kp-status-indigo, .kp-status-violet, .kp-status-pink, .kp-status-orange, .kp-status-teal) {
  box-shadow: inset 0 0 0 1px color-mix(in srgb, currentColor 22%, transparent);
}

/* A swatch outside a pill: the dot of a board column and of a stage in a
   menu, and the current step of a stage bar. The swatch class sets the three
   colours and the element picks what it draws with. */
.kp-status-neutral { --kp-swatch: var(--kp-swatch-slate); --kp-swatch-bg: var(--kp-status-neutral-bg); --kp-swatch-fg: var(--kp-status-neutral-fg); }
.kp-status-info { --kp-swatch: var(--kp-swatch-blue); --kp-swatch-bg: var(--kp-status-info-bg); --kp-swatch-fg: var(--kp-status-info-fg); }
.kp-status-indigo { --kp-swatch: var(--kp-swatch-indigo); --kp-swatch-bg: var(--kp-status-indigo-bg); --kp-swatch-fg: var(--kp-status-indigo-fg); }
.kp-status-violet { --kp-swatch: var(--kp-swatch-violet); --kp-swatch-bg: var(--kp-status-violet-bg); --kp-swatch-fg: var(--kp-status-violet-fg); }
.kp-status-pink { --kp-swatch: var(--kp-swatch-pink); --kp-swatch-bg: var(--kp-status-pink-bg); --kp-swatch-fg: var(--kp-status-pink-fg); }
.kp-status-danger { --kp-swatch: var(--kp-swatch-red); --kp-swatch-bg: var(--kp-status-danger-bg); --kp-swatch-fg: var(--kp-status-danger-fg); }
.kp-status-orange { --kp-swatch: var(--kp-swatch-orange); --kp-swatch-bg: var(--kp-status-orange-bg); --kp-swatch-fg: var(--kp-status-orange-fg); }
.kp-status-warning { --kp-swatch: var(--kp-swatch-amber); --kp-swatch-bg: var(--kp-status-warning-bg); --kp-swatch-fg: var(--kp-status-warning-fg); }
.kp-status-success { --kp-swatch: var(--kp-swatch-green); --kp-swatch-bg: var(--kp-status-success-bg); --kp-swatch-fg: var(--kp-status-success-fg); }
.kp-status-teal { --kp-swatch: var(--kp-swatch-teal); --kp-swatch-bg: var(--kp-status-teal-bg); --kp-swatch-fg: var(--kp-status-teal-fg); }

.kp-dot[class*="kp-status-"] {
  background: var(--kp-swatch);
}

/* Bootstrap badges inside tables read as status pills too, so pages this pass
   does not touch improve as well. */
.table .badge,
.table-responsive .badge {
  display: inline-flex;
  align-items: center;
  height: 22px;
  padding: 0 8px;
  border-radius: var(--kp-radius-pill);
  font-size: var(--kp-fs-small);
  font-weight: 600;
}

.badge-success, .badge.bg-success, .table .badge.badge-success {
  background-color: var(--kp-status-success-bg) !important;
  color: var(--kp-status-success-fg) !important;
}
.badge-warning, .badge.bg-warning, .table .badge.badge-warning {
  background-color: var(--kp-status-warning-bg) !important;
  color: var(--kp-status-warning-fg) !important;
}
.badge-danger, .badge.bg-danger, .table .badge.badge-danger {
  background-color: var(--kp-status-danger-bg) !important;
  color: var(--kp-status-danger-fg) !important;
}
.badge-info, .badge.bg-info, .table .badge.badge-info {
  background-color: var(--kp-status-info-bg) !important;
  color: var(--kp-status-info-fg) !important;
}
.badge-secondary, .badge.bg-secondary, .table .badge.badge-secondary {
  background-color: var(--kp-status-neutral-bg) !important;
  color: var(--kp-status-neutral-fg) !important;
}
.badge-primary, .badge.bg-primary {
  background-color: var(--kp-primary-soft) !important;
  color: var(--tblr-primary) !important;
}
.badge-light {
  background-color: var(--kp-status-neutral-bg) !important;
  color: var(--kp-status-neutral-fg) !important;
}

/* --------------------------------------------------------------------------
   10c. Legacy tables
   -------------------------------------------------------------------------- */

.table > thead > tr > th {
  font-size: var(--kp-fs-label);
  letter-spacing: .07em;
}

/* The pin column is a control, not data: muted until it is set. */
.pinToggle,
.pin-inactive {
  color: var(--tblr-secondary);
  opacity: .55;
}

.pinToggle:hover {
  opacity: 1;
  color: var(--tblr-primary);
}

.pin-active {
  color: var(--tblr-primary) !important;
  opacity: 1;
}

/* Compact numbered paginator for the pages that still use one. */
.pagination {
  gap: 2px;
  font-size: var(--kp-fs-small) !important;
  margin-bottom: 1.5rem !important;
}

.pagination .page-item .page-link,
.pagination .page-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 28px;
  height: 28px;
  padding: 0 6px !important;
  border: 0;
  border-radius: var(--kp-radius-sm);
  background: transparent;
  color: var(--tblr-secondary);
  font-size: var(--kp-fs-small);
  font-variant-numeric: tabular-nums;
}

.pagination .page-item .page-link:hover {
  background: var(--tblr-bg-surface-secondary);
  color: var(--tblr-body-color);
}

.pagination .page-item.active .page-link {
  background: var(--tblr-primary);
  color: var(--tblr-primary-fg);
  font-weight: 600;
}

.pagination .page-item.disabled .page-link {
  opacity: .4;
}

/* Some legacy tables put the header row inside <tbody> as `tr.bg-tr` instead of
   a <thead>. It has to read as a header row all the same. */
.table > tbody > tr.bg-tr > th,
.table > tbody > tr.bg-tr > td {
  background: var(--tblr-bg-surface-secondary);
  font-size: var(--kp-fs-small);
  font-weight: 600;
  color: var(--tblr-secondary);
  border-bottom: 1px solid var(--tblr-border-color);
  white-space: nowrap;
}

.table > tbody > tr.bg-tr:hover > * {
  background: var(--tblr-bg-surface-secondary);
}

/* Sticky header inside the card's own scroller, so the header stays while the
   rows scroll. The legacy scroller is `.table-responsive`. */
.table-responsive > .table > thead > tr > th {
  position: sticky;
  top: 0;
  z-index: 2;
}

/* The row menu column: a real last column, right aligned and only as wide as
   the 32px ghost button it holds. `width` attributes in the markup are
   overridden so the column stops stealing space from the data. */
.table > thead > tr > th:last-child:empty,
.table > tbody > tr.bg-tr > th:last-child:empty {
  width: 44px;
}

.table > tbody > tr > td:has(> .dropdown > .btn .ti-dots-vertical) {
  width: 44px !important;
  text-align: right;
  white-space: nowrap;
}

/* The kebab itself: 32px ghost icon button, muted at rest. */
.table .dropdown > .btn.btn-flat,
.table .dropdown > .btn-flat {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 0;
  border-radius: var(--kp-radius);
  background: transparent;
  color: var(--tblr-secondary);
  font-size: 14px;
  box-shadow: none;
}

.table .dropdown > .btn.btn-flat:hover,
.table .dropdown.show > .btn.btn-flat {
  background: var(--tblr-bg-surface-tertiary);
  color: var(--tblr-body-color);
}

/* Where the table scrolls sideways inside the card, the row menu must stay
   reachable, so its column pins to the right edge of the scroller. */
.table-responsive .table > tbody > tr > td:last-child:has(.ti-dots-vertical) {
  position: sticky;
  right: 0;
  background: var(--tblr-bg-surface);
}

.table-responsive .table > tbody > tr:hover > td:last-child:has(.ti-dots-vertical) {
  background: var(--tblr-bg-surface-secondary);
}

.table-responsive .table:has(tbody td .ti-dots-vertical) > thead > tr > th:last-child {
  position: sticky;
  right: 0;
  z-index: 3;
  background: var(--tblr-bg-surface-secondary);
}

/* Checkboxes and the pin icon are controls, not data: muted and centred. */
.table > tbody > tr > td > input[type="checkbox"],
.table > thead > tr > th > input[type="checkbox"],
.table .form-check-input {
  vertical-align: middle;
}

/* Numbers read as numbers. */
.table .text-end,
.table .text-right,
.table td.amount,
.table td.number {
  font-variant-numeric: tabular-nums;
}

/* --------------------------------------------------------------------------
   Card footer - where a page still has a numbered paginator it lives here,
   right aligned, below the table and inside the card. Never beside the table.
   -------------------------------------------------------------------------- */

.kp-card-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  width: 100%;
  margin: 12px 0 0;
  padding: 10px 0 0;
  border-top: 1px solid var(--tblr-border-color);
}

.kp-card-footer:empty {
  display: none;
}

.kp-card-footer .pagination,
.kp-card-footer .pagination.float-right {
  float: none !important;
  margin: 0 !important;
}

/* Defensive: a paginator any page still floats inside a card body would sit in
   a gutter beside the table and squeeze it. Un-float it and drop it below. */
.card-body > .float-right:has(> .pagination),
.card-body > .float-right:has(.pagination),
.card-body .row.float-right:has(.pagination),
.card-body > .pull-right:has(.pagination) {
  float: none !important;
  display: flex !important;
  justify-content: flex-end;
  width: 100% !important;
  max-width: none !important;
  margin: 12px 0 0 !important;
  padding: 0 !important;
}

/* Tables fill the card. No `col-md-*` cage, no fixed wrapper width. */
.card-body > .table-responsive {
  width: 100%;
  max-width: none;
  margin-left: 0;
  margin-right: 0;
}

.card-body .table-responsive > .table,
.card-body > .table {
  width: 100%;
  margin-bottom: 0;
  table-layout: auto;
}

/* --------------------------------------------------------------------------
   Roles: the hierarchy tree (/role/list) and the permission matrix
   (/role/create/:_id/:supervisor)
   --------------------------------------------------------------------------
   Roles are a hierarchy, so the list stays a tree rather than a table. The
   editor is a matrix: one row per resource, one column per action, a cell only
   where the catalogue has that key.
   -------------------------------------------------------------------------- */

.kp-role-tree,
.kp-role-tree ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

.kp-role-children {
  margin-left: 11px;
  padding-left: 15px;
  border-left: 1px solid var(--tblr-border-color);
}

.kp-role-node.kp-role-collapsed > .kp-role-children {
  display: none;
}

.kp-role-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  padding: 2px 6px 2px 0;
  border-radius: var(--kp-radius-sm, 6px);
  font-size: var(--kp-fs-body);
}

.kp-role-row:hover {
  background: var(--tblr-bg-surface-secondary);
}

.kp-role-caret {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  padding: 0;
  border: 0;
  border-radius: var(--kp-radius-sm, 6px);
  background: transparent;
  color: var(--tblr-secondary);
  cursor: pointer;
}

.kp-role-caret-empty {
  cursor: default;
}

.kp-role-node.kp-role-collapsed > .kp-role-row .kp-role-caret i {
  transform: rotate(-90deg);
}

.kp-role-caret i {
  font-size: 14px;
  transition: transform var(--kp-transition, 150ms ease-out);
}

.kp-role-name {
  font-size: var(--kp-fs-body);
  font-weight: 500;
  color: var(--tblr-body-color);
}

.kp-role-meta {
  font-size: var(--kp-fs-small);
  color: var(--tblr-secondary);
  font-variant-numeric: tabular-nums;
}

.kp-role-meta-dim::before {
  content: "\00b7";
  margin-right: 8px;
}

/* Row actions stay quiet until the row is hovered or focused. */
.kp-role-actions {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  margin-left: auto;
  opacity: 0;
  transition: opacity var(--kp-transition, 150ms ease-out);
}

.kp-role-row:hover .kp-role-actions,
.kp-role-actions:focus-within {
  opacity: 1;
}

.kp-link-btn {
  height: 24px;
  padding: 0 8px;
  border: 0;
  border-radius: var(--kp-radius-sm, 6px);
  background: transparent;
  color: var(--tblr-secondary);
  font-size: var(--kp-fs-small);
  font-weight: 500;
  cursor: pointer;
}

.kp-link-btn:hover {
  background: var(--tblr-bg-surface-tertiary, var(--tblr-bg-surface-secondary));
  color: var(--tblr-body-color);
}

.kp-link-btn.kp-link-danger:hover {
  background: var(--kp-status-danger-bg);
  color: var(--kp-status-danger-fg);
}

/* Users holding a role, in the Assign drawer. */
.kp-role-users {
  list-style: none;
  margin: 0;
  padding: 0;
  border: 1px solid var(--tblr-border-color);
  border-radius: var(--kp-radius, 8px);
  overflow: hidden;
}

.kp-role-user {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 10px 0 0;
  border-bottom: 1px solid var(--tblr-border-color);
}

.kp-role-user:last-child {
  border-bottom: 0;
}

.kp-role-user-link {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 1px;
  padding: 8px 10px;
  border: 0;
  background: transparent;
  text-align: left;
  cursor: pointer;
}

.kp-role-user-link:hover {
  background: var(--tblr-bg-surface-secondary);
}

.kp-role-user-name {
  font-size: var(--kp-fs-body);
  font-weight: 500;
  color: var(--tblr-body-color);
}

.kp-role-user-meta {
  font-size: var(--kp-fs-small);
  color: var(--tblr-secondary);
}

/* --- the editor ---------------------------------------------------------- */

.kp-role-editor {
  padding-bottom: 64px;
}

.kp-card-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}

.kp-card-title {
  margin: 0;
  font-size: var(--kp-fs-card);
  font-weight: 600;
  letter-spacing: -.01em;
  color: var(--tblr-body-color);
}

.kp-form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px 20px;
}

.kp-form-grid .kp-field-wide {
  grid-column: 1 / -1;
}

@media (max-width: 767.98px) {
  .kp-form-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

.kp-matrix-search {
  position: relative;
  margin-left: auto;
  width: 240px;
  max-width: 50%;
}

.kp-matrix-search i {
  position: absolute;
  top: 50%;
  left: 9px;
  transform: translateY(-50%);
  font-size: 14px;
  color: var(--tblr-secondary);
  pointer-events: none;
}

.kp-matrix-search .form-control {
  height: 32px;
  padding-left: 29px;
  font-size: var(--kp-fs-small);
}

.kp-matrix-group + .kp-matrix-group {
  margin-top: 22px;
}

.kp-matrix-group-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 0 6px;
  border-bottom: 1px solid var(--tblr-border-color);
}

.kp-matrix-group-title {
  margin: 0;
  font-size: var(--kp-fs-small);
  font-weight: 600;
  color: var(--tblr-secondary);
}

.kp-matrix-group-count {
  font-size: var(--kp-fs-small);
  color: var(--tblr-secondary);
  font-variant-numeric: tabular-nums;
}

.kp-matrix-group-actions {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  margin-left: auto;
}

.kp-matrix-sep {
  font-size: var(--kp-fs-label);
  color: var(--tblr-secondary);
}

.kp-matrix-table {
  font-size: var(--kp-fs-body);
}

.kp-matrix-table thead th {
  text-transform: none;  /* Tabler capitalises these; labels here are sentence case */
  letter-spacing: normal;
  padding: 7px 6px;
  font-size: var(--kp-fs-small);
  font-weight: 600;
  color: var(--tblr-secondary);
  white-space: nowrap;
}

.kp-matrix-table tbody th,
.kp-matrix-table tbody td {
  padding: 5px 6px;
  vertical-align: middle;
}

.kp-matrix-table .kp-matrix-col {
  width: 66px;
  text-align: center;
}

.kp-matrix-rowhead {
  width: 210px;
  font-weight: 500;
  text-align: left;
}

.kp-matrix-rowlabel > span {
  display: inline-block;
}

.kp-matrix-rowlabel > span::first-letter {
  text-transform: uppercase;
}

.kp-matrix-rowlabel {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  font-size: var(--kp-fs-body);
  font-weight: 500;
  color: var(--tblr-body-color);
  cursor: pointer;
}

.kp-matrix-cell {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  margin: 0;
  cursor: pointer;
}

.kp-matrix-empty {
  color: var(--tblr-secondary);
}

.kp-matrix-other {
  min-width: 180px;
}

.kp-matrix-verb {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin: 0 10px 2px 0;
  font-size: var(--kp-fs-small);
  color: var(--tblr-secondary);
  cursor: pointer;
  white-space: nowrap;
}

.kp-matrix-verb span {
  color: var(--tblr-body-color);
}

.kp-sensitive {
  font-size: var(--kp-fs-small);
  color: var(--tblr-warning);
  cursor: help;
}

/* A yes or no confirmation, centred over a scrim. */
.kp-confirm-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1055;
  background: rgba(15, 23, 42, .38);
}

[data-bs-theme="dark"] .kp-confirm-backdrop {
  background: rgba(2, 6, 23, .6);
}

.kp-confirm {
  position: fixed;
  top: 50%;
  left: 50%;
  z-index: 1056;
  width: min(420px, calc(100vw - 32px));
  transform: translate(-50%, -50%);
  padding: 18px;
  border: 1px solid var(--tblr-border-color);
  border-radius: var(--kp-radius, 8px);
  background: var(--tblr-bg-surface);
  box-shadow: 0 8px 24px rgba(15, 23, 42, .12);
}

.kp-confirm-title {
  margin: 0 0 8px;
  font-size: var(--kp-fs-card);
  font-weight: 600;
  color: var(--tblr-body-color);
}

.kp-confirm-text {
  margin: 0 0 16px;
  font-size: var(--kp-fs-body);
  color: var(--tblr-secondary);
}

.kp-confirm-check {
  margin: -4px 0 16px;
  font-size: var(--kp-fs-body);
}

.kp-confirm-list {
  margin: -8px 0 16px;
  padding-left: 18px;
  max-height: 220px;
  overflow-y: auto;
  font-size: var(--kp-fs-body);
}

.kp-confirm-list li + li {
  margin-top: 4px;
}

.kp-confirm-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.kp-toolbar-switch {
  margin: 0 4px 0 0;
}

/* --------------------------------------------------------------------------
   Admin action panels (/systemConfig/list)
   --------------------------------------------------------------------------
   A page of one-shot maintenance actions. None of them is "the" primary action
   of the page, so they are all secondary buttons on an even grid; only the
   destructive one carries colour.
   -------------------------------------------------------------------------- */

.kp-section-hint {
  margin: 0 0 12px;
  font-size: var(--kp-fs-small);
  color: var(--tblr-secondary);
}

.kp-panel-title {
  margin: 0;
  font-size: var(--kp-fs-body);
  font-weight: 600;
  letter-spacing: -.01em;
  color: var(--tblr-body-color);
}

.kp-action-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 8px;
}

.btn.kp-action-btn {
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
  min-height: 36px;
  padding: 8px 12px;
  border: 1px solid var(--tblr-border-color);
  border-radius: var(--kp-radius);
  background: var(--tblr-bg-surface);
  color: var(--tblr-body-color);
  font-size: var(--kp-fs-body);
  font-weight: 500;
  text-align: left;
  box-shadow: none;
}

.btn.kp-action-btn:hover {
  background: var(--tblr-bg-surface-secondary);
  border-color: var(--tblr-secondary);
  color: var(--tblr-body-color);
}

.btn.kp-action-btn.kp-action-danger {
  color: var(--kp-status-danger-fg);
}

.btn.kp-action-btn.kp-action-danger:hover {
  background: var(--kp-status-danger-bg);
  border-color: var(--kp-status-danger-fg);
  color: var(--kp-status-danger-fg);
}

/* A card's own action row: one primary, right aligned. */
.kp-form-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid var(--tblr-border-color);
}

/* --------------------------------------------------------------------------
   10d. Legacy record pages
   -------------------------------------------------------------------------- */

/* The record "Edit" pill becomes a quiet secondary button. */
.updateLeadCls .btn.rounded-pill,
.updateLeadCls .btn.btn-outline-primary {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 32px;
  width: auto !important;
  padding: 0 12px !important;
  border: 1px solid var(--tblr-border-color) !important;
  border-radius: var(--kp-radius) !important;
  background: var(--tblr-bg-surface) !important;
  color: var(--tblr-body-color) !important;
  font-size: var(--kp-fs-body);
  font-weight: 500;
  box-shadow: none !important;
}

.updateLeadCls .btn:hover {
  background: var(--tblr-bg-surface-secondary) !important;
}

/* Facts grid: labels above values, no zebra, values not bold. A facts table is
   not a data table, so it does not light up under the pointer. */
.table > tbody > tr.table-border:hover > * {
  background: transparent;
}

tr.table-border > td > label,
tr.table-border > td > .textColor,
.textColor {
  display: block;
  margin-bottom: 2px;
  font-size: var(--kp-fs-small);
  font-weight: 600;
  color: var(--tblr-secondary) !important;
}

tr.table-border > td > div {
  font-size: var(--kp-fs-body);
  font-weight: 500 !important;
  color: var(--tblr-body-color);
}

.textFonts {
  font-weight: 500 !important;
}

/* The "Recent Activities" card is a card like any other. */
.recent-activities-title {
  font-size: var(--kp-fs-card) !important;
  font-weight: 600;
  color: var(--tblr-body-color) !important;
}

.activity-item-label {
  font-size: var(--kp-fs-small) !important;
  font-weight: 600;
  color: var(--tblr-secondary) !important;
  text-decoration: none !important;
}

.activity-item-container {
  background-color: var(--tblr-bg-surface-secondary) !important;
  border: 1px solid var(--tblr-border-color);
}

.activity-item-enquiry {
  font-size: var(--kp-fs-body) !important;
  color: var(--tblr-body-color) !important;
}

.activity-item-status,
.activity-item-communicationMethod,
.activity-item-discussion,
.activity-item-followup {
  font-size: var(--kp-fs-body) !important;
  color: var(--tblr-secondary);
}

/* --------------------------------------------------------------------------
   10e. Legacy forms and modals
   -------------------------------------------------------------------------- */

.page-title-create-size {
  margin: 0 0 4px !important;
  font-size: var(--kp-fs-title) !important;
  font-weight: 700;
  letter-spacing: -.02em;
  color: var(--tblr-body-color) !important;
}

.modal-header {
  padding: 12px 16px;
  border-bottom: 1px solid var(--tblr-border-color);
  background: var(--tblr-bg-surface);
}

.modal-title,
.modal-header h4,
.modal-header h5 {
  font-size: var(--kp-fs-card) !important;
  font-weight: 600;
  color: var(--tblr-body-color) !important;
}

.modal-body {
  font-size: var(--kp-fs-body);
}

/* The old theme's green hover on generic buttons. */
.common-button:hover,
#updateProfile:hover,
#resetPassword:hover {
  background-color: var(--tblr-bg-surface-secondary);
  color: var(--tblr-body-color);
}

.activity-item-followup,
.activity-item-nextFollowup {
  margin-bottom: 2px;
  font-size: var(--kp-fs-body) !important;
  font-weight: 500;
  color: var(--tblr-secondary) !important;
}

/* Legacy forms use bare <select> elements; give them the `.form-select` look so
   they stop reading as raw browser widgets. */
.card-body select:not(.form-select):not(.custom-select),
form select:not(.form-select):not(.custom-select) {
  display: block;
  width: 100%;
  height: 34px;
  padding: 0 32px 0 10px;
  border: 1px solid var(--kp-control-border);
  border-radius: var(--kp-radius);
  background-color: var(--tblr-bg-surface);
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%236B7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m2 5 6 6 6-6'/%3e%3c/svg%3e");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 14px 10px;
  color: var(--tblr-body-color);
  font-size: var(--kp-fs-body);
  appearance: none;
}

/* Collapsible section headings inside legacy forms are card titles. */
.card-header h5 > a.text-dark,
.card-header h5 > a.collapse1 {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: var(--kp-fs-card) !important;
  font-weight: 600;
  color: var(--tblr-body-color) !important;
  text-decoration: none;
}

.card-header h5 > a.text-dark i {
  float: none !important;
  font-size: 12px;
  color: var(--tblr-secondary);
}

/* Radio and checkbox rows in legacy forms stop breaking mid word. */
.form-check-inline,
.form-check-label {
  white-space: nowrap;
}

.asteric_red {
  color: var(--kp-danger-text);
}


/* One control height across the form. Legacy pages mix bare inputs, selects
   and date pickers; all of them land on 36px. */
.card-body .form-control,
.card-body .form-select,
.card-body .custom-select,
form .form-control,
form .form-select {
  min-height: 36px;
}

.card-body textarea.form-control,
form textarea.form-control {
  min-height: 72px;
}

.card-body select:not(.form-select):not(.custom-select),
form select:not(.form-select):not(.custom-select) {
  height: 36px;
}

/* Date pickers are an input plus a button in an input group; the button has to
   match the input it sits against. */
.input-group .form-control + .input-group-append > .btn,
.input-group-append > .input-group-text,
.input-group-prepend > .input-group-text {
  min-height: 36px;
  border-color: var(--kp-control-border);
  background: var(--tblr-bg-surface-secondary);
  color: var(--tblr-secondary);
}

/* Labels sit above their field, uppercase-free and quiet. */
.card-body form label,
.card-body > form label {
  margin-bottom: 4px;
  font-size: var(--kp-fs-small);
  font-weight: 500;
  color: var(--tblr-body-color);
}

/* Radios and checkboxes line up with their own label instead of floating
   above it. */
.card-body input[type="radio"],
.card-body input[type="checkbox"],
form input[type="radio"],
form input[type="checkbox"] {
  margin: 0 6px 0 0;
  vertical-align: middle;
}

.card-body input[type="radio"] + label,
.card-body input[type="checkbox"] + label,
form input[type="radio"] + label,
form input[type="checkbox"] + label {
  display: inline-flex;
  align-items: center;
  margin: 0 16px 0 0;
  vertical-align: middle;
  cursor: pointer;
}

/* The form's action row: one primary on the right, Cancel beside it, pinned to
   the bottom of the viewport so long forms keep it in reach. */
form .form-group:has(button[type="submit"]),
form .form-group:has(> div > button[type="submit"]) {
  position: sticky;
  bottom: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  margin: 20px -16px -16px;
  padding: 12px 16px;
  border-top: 1px solid var(--tblr-border-color);
  background: var(--tblr-bg-surface);
}

form .form-group:has(button[type="submit"]) > div {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  width: 100%;
}

form .form-group:has(button[type="submit"]) button {
  float: none !important;
  margin: 0 !important;
}

form .form-group:has(button[type="submit"]) button[type="submit"],
form .form-group:has(button[type="submit"]) .saveBtn {
  order: 2;
}

form .form-group:has(button[type="submit"]) button[type="reset"],
form .form-group:has(button[type="submit"]) .close-button,
form .form-group:has(button[type="submit"]) .closeButton:not(.addbutton) {
  order: 1;
  border: 1px solid var(--tblr-border-color) !important;
  background: var(--tblr-bg-surface) !important;
  color: var(--tblr-body-color) !important;
  box-shadow: none !important;
}

/* A section heading that sits in its own card reads as a card title, not as an
   empty card above the fields. */
.card > .card-header {
  padding: 12px 16px;
  border-bottom: 1px solid var(--tblr-border-color);
}

.card > .card-header + .card-body {
  padding-top: 16px;
}

/* Links inside legacy panels: primary coloured, never underlined at rest. */
.kp-quiet-link {
  color: var(--tblr-primary);
  text-decoration: none;
}

.kp-quiet-link:hover {
  text-decoration: underline;
}

/* A chip that shows a state the user cannot act on. */
.kp-disabled-chip {
  opacity: 1;
  background-color: var(--tblr-bg-surface-secondary) !important;
  border: 1px solid var(--tblr-border-color) !important;
  color: var(--tblr-secondary) !important;
  cursor: not-allowed;
  pointer-events: none;
}

/* Global search groups a result list per entity: a quiet heading and a count
   pill, the same pair the list toolbars use. */
.kp-search-group-title {
  font-size: var(--kp-fs-card);
  font-weight: 700;
  letter-spacing: -.01em;
  color: var(--tblr-body-color);
}

.kp-search-group-title + .totalCount {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 7px;
  border-radius: var(--kp-radius-pill);
  background: var(--tblr-bg-surface-tertiary);
  color: var(--tblr-secondary);
  font-size: var(--kp-fs-small);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

/* ==========================================================================
   11. Forms and the Entities admin page
   (DESIGN.md section 2: every create and edit form is a full page; the side
   drawer was retired on 2026-09-23.)
   ========================================================================== */

/* Labels above fields, validation under them (DESIGN.md section 2, "Forms"). */
.kp-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.kp-field-label {
  font-size: var(--kp-fs-small);
  font-weight: 600;
  color: var(--tblr-secondary);
  margin: 0;
}

.kp-req {
  color: var(--kp-danger-text);
}

.kp-field-hint {
  font-size: var(--kp-fs-small);
  color: var(--tblr-secondary);
}

.kp-field-error {
  font-size: var(--kp-fs-small);
  color: var(--kp-danger-text);
}

/* An alert icon before the message: colour is not the only signal. */
.kp-field-error::before {
  content: "\ea05";
  margin-right: 4px;
  font-family: "tabler-icons";
  font-size: var(--kp-fs-body);
  line-height: 1;
  vertical-align: -2px;
}

/* The field the message belongs to: the controls of the `.kp-field` that
   holds it, leaving out a product line grid inside it (the lead's Products),
   whose filled cells are not wrong. `aria-invalid` is set by the shell
   (imports/ui/shell/formErrors.js) and marks the empty cells of a grid. */
.kp-field:has(> .kp-field-error) :is(.form-control, .form-select, .custom-select):not(.kp-readonly):not(.kp-lines *),
:is(.form-control, .form-select)[aria-invalid="true"],
.kp-picker-control:has([aria-invalid="true"]) {
  border-color: var(--tblr-danger);
  box-shadow: 0 0 0 2px rgba(var(--tblr-danger-rgb), .2);
}

.kp-field:has(> .kp-field-error) :is(.form-control, .form-select, .custom-select):not(.kp-readonly):not(.kp-lines *):focus,
:is(.form-control, .form-select)[aria-invalid="true"]:focus,
.kp-field:has(> .kp-field-error) .kp-picker-control:not(.kp-lines *):focus-within,
.kp-picker-control:has([aria-invalid="true"]):focus-within {
  border-color: var(--tblr-danger);
  box-shadow: 0 0 0 2px rgba(var(--tblr-danger-rgb), .4);
}

/* "7 fields need attention" at the left of a form's footer, with previous and
   next (imports/ui/shell/formErrors.js). */
.kp-form-issues {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-right: auto;
  color: var(--kp-danger-text);
  font-size: var(--kp-fs-small);
  font-weight: 600;
}

.kp-form-issues > i {
  font-size: 16px;
}

.kp-form-issues-text {
  margin-right: 4px;
}

.kp-form-footer:has(> .kp-form-issues) {
  flex-wrap: wrap;
}

/* The running total of a quotation or sales order form, at the left of the
   Save bar; after the error count when there is one. */
.kp-form-footer-total {
  margin-right: auto;
  font-size: var(--kp-fs-body);
  color: var(--tblr-secondary);
  white-space: nowrap;
}

.kp-form-footer-total strong {
  margin-left: 4px;
  font-size: var(--kp-fs-card);
  font-weight: 700;
  color: var(--tblr-body-color);
  font-variant-numeric: tabular-nums;
}

.kp-form-issues ~ .kp-form-footer-total {
  margin-right: 12px;
}

.kp-form-error {
  padding: 8px 10px;
  border: 1px solid var(--kp-status-danger-bg);
  border-radius: var(--kp-radius, 8px);
  background: var(--kp-status-danger-bg);
  color: var(--kp-status-danger-fg);
  font-size: var(--kp-fs-small);
}

/* The shell's own strip (`kpPageError`, imports/ui/shell/feedback.js): the same
   message with a dismiss button, for every page without a strip of its own. */
.kp-page-error {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 6px 8px 6px 12px;
}

.kp-page-error-text {
  flex: 1 1 auto;
  min-width: 0;
  padding: 3px 0;
  overflow-wrap: anywhere;
}

.kp-page-error-close {
  width: 24px;
  height: 24px;
  flex-basis: 24px;
  color: inherit;
}

.kp-page-error-close:hover {
  background: color-mix(in srgb, var(--kp-status-danger-fg) 12%, transparent);
  color: inherit;
}

/* The same strip saying a warning (`showPageWarning`): what was asked for did
   happen, so it is amber, never red. */
.kp-page-error.kp-page-warning {
  border-color: var(--kp-status-warning-bg);
  background: var(--kp-status-warning-bg);
  color: var(--kp-status-warning-fg);
}

.kp-page-warning .kp-page-error-close:hover {
  background: color-mix(in srgb, var(--kp-status-warning-fg) 12%, transparent);
}

.kp-main > .kp-page-error.kp-page-warning {
  border-bottom-color: color-mix(in srgb, var(--kp-status-warning-fg) 22%, var(--kp-status-warning-bg));
}

/* In the shell it is a band under the tab strip. It is a row of the main
   column, so a full height list (section 12) gives up its height and nothing
   else; where the document scrolls it stays at the top of the window, because
   an error has to be in view wherever the person was when it was raised. */
.kp-main > .kp-page-error {
  position: sticky;
  top: 0;
  z-index: 6;
  flex: 0 0 auto;
  padding-right: 12px;
  padding-left: var(--kp-page-padding);
  border-width: 0 0 1px;
  border-bottom-color: color-mix(in srgb, var(--kp-status-danger-fg) 22%, var(--kp-status-danger-bg));
  border-radius: 0;
}

/* Below 1200px the inspector lies over the right of the workspace (section 7):
   the band stops short of it, so the message and its button stay readable. On
   a phone the panel covers the page, and the band is there when it closes. */
@media (min-width: 768px) and (max-width: 1199.98px) {
  .kp-has-inspector .kp-main > .kp-page-error {
    margin-right: var(--kp-inspector-width);
  }
}

/* The logged out pages are full bleed, so there it floats over the top of the
   window instead of pushing the page down. */
.kp-bare > .kp-page-error {
  position: fixed;
  top: 12px;
  left: 50%;
  z-index: 1050;
  width: 560px;
  max-width: calc(100vw - 32px);
  transform: translateX(-50%);
  box-shadow: var(--kp-shadow-float);
}

.kp-form-section {
  margin-top: 4px;
  padding-top: 12px;
  border-top: 1px solid var(--tblr-border-color);
  font-size: var(--kp-fs-small);
  font-weight: 600;
  color: var(--tblr-secondary);
}

.kp-upper {
  text-transform: uppercase;
}

.kp-switch {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
}

/* A switch that cannot be changed still says where it stands: at full
   strength (the browser default fades it to half, which read as "off" in
   dark), with a lock after its label. */
.form-switch .form-check-input:disabled {
  opacity: 1;
  cursor: not-allowed;
}

.form-switch .form-check-input:disabled ~ .form-check-label {
  opacity: 1;
  cursor: not-allowed;
}

.form-switch .form-check-input:disabled ~ .form-check-label::after {
  content: "\eae2";
  margin-left: 6px;
  font-family: "tabler-icons";
  font-size: var(--kp-fs-body);
  color: var(--tblr-secondary);
  vertical-align: -1px;
}

/* --------------------------------------------------------------------------
   Record page cards: a field once, empty optional ones folded (kpFieldList)
   -------------------------------------------------------------------------- */

/* A required or to-do field left empty says so in words. */
.kp-field-todo {
  color: var(--kp-status-warning-fg);
  font-weight: 500;
}

.kp-field-blank {
  color: var(--tblr-secondary);
}

.kp-fieldlist-none {
  margin: 0;
  font-size: var(--kp-fs-body);
  color: var(--tblr-secondary);
}

.kp-fieldlist-toggle {
  display: inline-block;
  margin-top: 10px;
  padding: 0;
  border: 0;
  background: transparent;
  font-size: var(--kp-fs-small);
}

.kp-colour-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.kp-colour-row .form-control-color {
  flex: 0 0 44px;
  width: 44px;
  padding: 3px;
}

.kp-colour-row .kp-entity-swatch {
  flex: 0 0 auto;
}

/* The entity colour presets (imports/api/entity/colors.js): twelve dots under
   the picker, the chosen one ringed. */
.kp-colour-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.kp-colour-preset {
  width: 22px;
  height: 22px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--kp-preset);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .12);
  cursor: pointer;
  transition: transform var(--kp-transition);
}

.kp-colour-preset:hover {
  transform: scale(1.12);
}

.kp-colour-preset:focus-visible {
  outline: 2px solid var(--tblr-primary);
  outline-offset: 2px;
}

.kp-colour-preset.is-selected {
  box-shadow: 0 0 0 2px var(--tblr-bg-surface), 0 0 0 4px var(--kp-preset);
}

.kp-field-hint.kp-field-warn {
  color: var(--kp-status-warning-fg, #B45309);
}

.kp-colour-chip {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 3px;
  background: var(--kp-accent);
  vertical-align: -1px;
  margin-right: 4px;
}

/* Drawer view mode: identity then a plain facts list. */








.kp-facts {
  display: grid;
  grid-template-columns: 132px 1fr;
  gap: 6px 12px;
  margin: 0;
  font-size: var(--kp-fs-body);
}

.kp-facts dt {
  font-size: var(--kp-fs-small);
  font-weight: 600;
  color: var(--tblr-secondary);
  padding-top: 2px;
}

.kp-facts dd {
  margin: 0;
  min-width: 0;
}

/* A number in a facts list lines up with the values above and below it (the
   left edge), not with the card's right edge; its digits stay tabular. */
.kp-facts dd.kp-num {
  text-align: left;
}

.kp-facts dd.kp-fact-break {
  overflow-wrap: anywhere;
}

/* Entities page: the table fills the card. The row menu is placed against the
   window (imports/ui/shell/rowMenu.js), so the wrap can scroll sideways on a
   phone, where the table is wider than the screen, without cutting the menu. */
.kp-entities-card {
  overflow: visible;
}

.kp-entities-wrap {
  overflow-x: auto;
  border: 0;
  border-radius: var(--kp-radius, 8px);
}

.kp-entities-table th.kp-col-tile,
.kp-entities-table td.kp-col-tile {
  width: 44px;
  padding-right: 0;
}

.kp-entities-table .kp-cell-code {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.kp-entities-table .kp-cell-name {
  font-weight: 500;
}

/* The list and drawer reuse the switcher tile, with the colour passed inline. */
.kp-entity-swatch {
  background: var(--kp-accent);
}

.kp-entity-swatch-lg {
  min-width: 36px;
  height: 36px;
  padding: 0 8px;
  border-radius: 9px;
  font-size: var(--kp-fs-small);
}

/* A value the form fills in itself (filled from the quotation, the same as the
   bill-to contact) reads as text, not as a box that looks editable but is not.
   A picker that is only waiting for another field keeps its control look
   (.kp-picker-disabled): it will open once that field is chosen. */
.kp-record-form .form-control[readonly]:not(.kp-picker-search)::placeholder {
  color: transparent;
}

.kp-record-form .form-control[readonly]:not(.kp-picker-search) {
  padding-left: 0;
  border-color: transparent;
  background: transparent;
  box-shadow: none;
  color: var(--tblr-body-color);
  cursor: default;
}

/* --------------------------------------------------------------------------
   System settings (/system/settings)
   --------------------------------------------------------------------------
   One card per concern on a two column grid, each card saving on its own.
   -------------------------------------------------------------------------- */

.kp-settings-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  align-items: start;
}

.kp-settings-grid > .kp-settings-wide {
  grid-column: 1 / -1;
}

/* The half-width cards sit in two stacks, each its own column, so a short
   card on one side leaves no blank block beside a tall one on the other. */
.kp-settings-col {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 0;
}

@media (max-width: 991.98px) {
  .kp-settings-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

.kp-settings-grid .kp-field + .kp-field {
  margin-top: 14px;
}

.kp-facts.kp-facts-2 {
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr) max-content minmax(0, 1fr);
  gap: 6px 16px;
}

@media (max-width: 767.98px) {
  .kp-facts.kp-facts-2 {
    grid-template-columns: max-content minmax(0, 1fr);
  }
}

.form-control.kp-mono {
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  font-size: var(--kp-fs-small);
}

/* ==========================================================================
   11. Opportunities (DESIGN.md section 2)
   --------------------------------------------------------------------------
   The pipeline list (table and board), the inspector panel it opens, the
   filter chips in the toolbar and the line items editor inside the 720px
   drawer. Nothing here is module specific except the class prefixes: the
   chips, the typeahead and the line items table are meant to be reused by the
   enquiry and sales order modules as they are built.
   ========================================================================== */

/* The table fills the card: no card padding between the two. */
.kp-opps-card {
  overflow: hidden;
}

/* The scroller fills the card; section 12 gives the card its height. A fixed
   vh height here would leave a third of the viewport empty. */
.kp-opps-wrap {
  height: 100%;
  border: 0;
}

/* Keep the columns readable: the table scrolls inside its card rather than
   squeezing every cell when the inspector takes 340px off the width. */
.kp-opps-table {
  min-width: 900px;
}

.kp-opps-table > tbody > tr > td,
.kp-opps-table > thead > tr > th {
  white-space: nowrap;
}

/* A close date that has passed on an open opportunity. Bootstrap paints table
   cells through `.table > :not(caption) > * > *`, so the table needs a selector
   of its own to win. */
.kp-overdue,
.kp-table > tbody > tr > td.kp-overdue {
  color: var(--kp-danger-text);
  font-weight: 600;
}

.kp-loading-more {
  padding: 10px;
  text-align: center;
  font-size: var(--kp-fs-small);
  color: var(--tblr-secondary);
}

/* Owner: initials avatar plus the name. */
.kp-owner {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

.kp-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 22px;
  width: 22px;
  height: 22px;
  border-radius: var(--kp-radius-pill);
  background: var(--kp-primary-soft);
  color: var(--tblr-primary);
  font-size: var(--kp-fs-label);
  font-weight: 700;
  letter-spacing: .02em;
}

.kp-avatar-sm {
  flex-basis: 18px;
  width: 18px;
  height: 18px;
  font-size: 9px;
}

/* Filter chips in the toolbar: a select that reads as a chip. */
.kp-chip-select {
  width: auto;
  min-width: 0;
  height: 28px;
  padding: 0 26px 0 10px;
  border-radius: var(--kp-radius-pill);
  background-position: right 8px center;
  font-size: var(--kp-fs-small);
}

.kp-chip-search {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.kp-chip-search i {
  position: absolute;
  left: 9px;
  font-size: 14px;
  color: var(--tblr-secondary);
  pointer-events: none;
}

.kp-chip-search .form-control {
  width: 180px;
  height: 28px;
  padding: 0 10px 0 28px;
  border-radius: var(--kp-radius-pill);
  font-size: var(--kp-fs-small);
  /* A filter chip keeps the hairline: it is a toolbar control, not a field
     to type into, and the darker control border made the chip row loud. */
  border-color: var(--tblr-border-color);
}

/* Board: drag targets and the empty column. The board itself is generic and
   lives in section 19; only the drag feedback stays here, beside the table. */

.kp-board-card {
  cursor: grab;
}

.kp-board-card-dragging {
  opacity: .5;
}

.kp-board-col-over {
  border-color: var(--tblr-primary);
  background: var(--kp-primary-soft);
}

.kp-board-empty {
  padding: 12px 4px;
  color: var(--tblr-secondary);
  font-size: var(--kp-fs-small);
  text-align: center;
}

.kp-dot-danger {
  background: var(--tblr-danger);
}

.kp-board-card .kp-avatar {
  margin-left: auto;
}

/* Stage picker, shown in the small centred dialog. */
.kp-stage-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-bottom: 14px;
}

.kp-stage-option {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 7px 8px;
  border: 0;
  border-radius: var(--kp-radius-sm);
  background: transparent;
  color: var(--tblr-body-color);
  font-size: var(--kp-fs-body);
  text-align: left;
}

.kp-stage-option:hover {
  background: var(--tblr-bg-surface-secondary);
}

.kp-stage-prob {
  margin-left: auto;
  color: var(--tblr-secondary);
  font-variant-numeric: tabular-nums;
}

/* Inspector contents. */
.kp-insp {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.kp-insp-identity {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
}

.kp-insp-name {
  font-size: var(--kp-fs-card);
  font-weight: 700;
  letter-spacing: -.01em;
}

.kp-insp-account {
  font-size: var(--kp-fs-small);
  color: var(--tblr-secondary);
}

.kp-insp-headline {
  display: flex;
  flex-direction: column;
  padding: 10px 12px;
  border: 1px solid var(--tblr-border-color);
  border-radius: var(--kp-radius);
  background: var(--tblr-bg-surface-secondary);
}

.kp-insp-value {
  font-size: var(--kp-fs-title);
  font-weight: 700;
  letter-spacing: -.02em;
}

.kp-insp-value-label {
  font-size: var(--kp-fs-small);
  font-weight: 600;
  color: var(--tblr-secondary);
}

.kp-insp-actions {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 14px;
}

/* A greyed action in the side panel: the full-width button with its reason
   under it, always shown (the panel has the room the record header lacks). */
.kp-insp-actions .kp-disabled-action {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 2px;
}

.kp-insp-actions .kp-disabled-reason {
  display: block;
  white-space: normal;
  text-align: center;
}

.kp-insp-section {
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid var(--tblr-border-color);
}

.kp-insp-placeholder {
  margin: 6px 0 0;
  font-size: var(--kp-fs-small);
  color: var(--tblr-secondary);
}

/* The shared side panel (imports/ui/components/kpSidePanel.*): the head puts
   "Open full page" as an icon beside the name; the identity takes the rest. */
.kp-insp-head {
  display: flex;
  align-items: flex-start;
  gap: 8px;
}

.kp-insp-head .kp-insp-identity {
  flex: 1 1 auto;
  min-width: 0;
}

.kp-insp-head .kp-insp-name {
  overflow-wrap: anywhere;
}

.btn.kp-insp-open {
  flex: 0 0 auto;
  width: 28px;
  padding: 0;
}

/* The panel's block: the last activity, the account of a contact, a text. */
.kp-insp-last,
.kp-insp-deal {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin: 8px 0 0;
}

.kp-insp-text {
  margin: 8px 0 0;
  font-size: var(--kp-fs-body);
  white-space: pre-line;
  overflow-wrap: anywhere;
}

/* --------------------------------------------------------------------------
   The 720px drawer form
   -------------------------------------------------------------------------- */

.kp-form-section-first {
  margin-top: 0;
  padding-top: 0;
  border-top: 0;
}

.kp-form-grid-2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 14px;
}

.kp-inline-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.kp-inline-row .form-control {
  min-width: 0;
}

.kp-suffix {
  flex: 0 0 auto;
  font-size: var(--kp-fs-small);
  font-weight: 600;
  color: var(--tblr-secondary);
}

.kp-readonly {
  background: var(--tblr-bg-surface-secondary);
  color: var(--tblr-body-color);
}

.kp-checkrow {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 16px;
}

/* Typeahead: an input with a menu of matches under it. */
.kp-typeahead {
  position: relative;
}

.kp-typeahead-menu {
  position: absolute;
  z-index: 10;
  left: 0;
  right: 0;
  max-height: 220px;
  overflow-y: auto;
  margin-top: 2px;
  padding: 4px;
  border: 1px solid var(--tblr-border-color);
  border-radius: var(--kp-radius);
  background: var(--tblr-bg-surface);
  box-shadow: var(--kp-shadow-float, 0 8px 24px rgba(15, 23, 42, .12));
}

.kp-typeahead-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 6px 8px;
  border: 0;
  border-radius: var(--kp-radius-sm);
  background: transparent;
  color: var(--tblr-body-color);
  font-size: var(--kp-fs-body);
  text-align: left;
}

.kp-typeahead-item:hover {
  background: var(--tblr-bg-surface-secondary);
}

.kp-typeahead-meta {
  margin-left: auto;
  color: var(--tblr-secondary);
  font-size: var(--kp-fs-small);
}

/* Line items editor. */
.kp-lines-wrap {
  overflow-x: auto;
  border: 1px solid var(--tblr-border-color);
  border-radius: var(--kp-radius);
}

.kp-lines {
  min-width: 620px;
  margin: 0;
}

.kp-lines > tbody > tr > td,
.kp-lines > tfoot > tr > td {
  padding: 6px 8px;
  vertical-align: middle;
}

.kp-lines .form-control,
.kp-lines .form-select {
  height: 30px;
  padding: 0 8px;
  font-size: var(--kp-fs-body);
}

.kp-lines td:nth-child(3) .form-control,
.kp-lines td:nth-child(5) .form-control {
  width: 88px;
  text-align: right;
}

.kp-lines > tfoot > tr > td {
  border-top: 1px solid var(--tblr-border-color);
  background: var(--tblr-bg-surface-secondary);
  font-weight: 600;
}

.kp-lines-total {
  font-variant-numeric: tabular-nums;
}

/* Card titles are sentence case (DESIGN.md section 4); Tabler capitalises them. */
.card-header .card-title {
  text-transform: none;
}

/* The record page's headline value in the toolbar. */
.kp-record-value {
  font-size: var(--kp-fs-card);
  font-weight: 700;
  letter-spacing: -.01em;
}

/* ==========================================================================
   11b. Record page (DESIGN.md section 2, "Record page")
   --------------------------------------------------------------------------
   ONE column, no side panel: under the header the key figures in a row
   (`kpRecordHighlights`), what blocks the next step and the approval, the
   stage bar, the tabs; the first tab opens on the details card (every field of
   the record in four columns), then the record's own cards (lines, schedule),
   then its activity. A side column beside a main column left one of the two
   mostly empty on most records (a contact, an activity, a new lead); one
   column has no second column to leave a hole, and a record with little data
   is simply a shorter page.
   ========================================================================== */

.kp-record {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
}

/* The column spaces its parts; their own top margins would double it. */
.kp-record > * {
  margin-top: 0 !important;
  margin-bottom: 0 !important;
}

/* The hint sits close to the stage bar it explains. */
.kp-record > .kp-stagebar + .kp-stagebar-note {
  margin-top: -6px !important;
}

/* The tabs sit close to the card they open. */
.kp-record > .kp-rtabs + * {
  margin-top: -4px !important;
}

/* The key figures (kpRecordHighlights): what someone checks first, in one row. */
.kp-highlights {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  gap: 10px 36px;
  padding: 12px 16px;
}

.kp-highlight {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.kp-highlight-value {
  font-size: var(--kp-fs-body);
  font-weight: 600;
}

/* The details card: every field of the record as label over value, four
   across. The fields of a `kpFieldList` and the page's own cells (a contact,
   an address, related records, the team) are cells of the same grid, so
   they line up whatever made them. */
.kp-details-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  /* A later one-column field fills the hole a two-column cell left, so no row
     ends in an empty slot. */
  grid-auto-flow: row dense;
  gap: 16px 24px;
}

.kp-details-grid > .kp-vlist {
  display: contents;
}

.kp-details-grid .kp-fieldlist-toggle,
.kp-details-grid .kp-fieldlist-none,
.kp-details-grid > .kp-details-wide {
  grid-column: 1 / -1;
}

.kp-details-grid .kp-vitem-wide,
.kp-details-grid > .kp-details-half {
  grid-column: span 2;
}

.kp-details-grid > .kp-ident {
  padding: 0;
  margin: 0;
  border: 0;
}

.kp-details-cell {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.kp-details-cell .kp-related {
  margin: 0 -8px;
}

/* A button in the details card keeps its own width, at the left of its cell. */
.kp-details-cell .btn {
  width: auto !important;
  align-self: flex-start;
}

/* A name in the details card wraps rather than being cut: nothing in it is
   shortened (DESIGN.md "No data is hidden on a record page"). */
.kp-details-cell .kp-related-name {
  white-space: normal;
  overflow: visible;
  text-overflow: clip;
}

.kp-details-cell .kp-facts {
  grid-template-columns: max-content minmax(0, 1fr);
}

/* Related records as chips, each a way in. */
.kp-relchips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.kp-relchip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 100%;
  padding: 3px 10px;
  border: 1px solid var(--tblr-border-color);
  border-radius: 999px;
  background: var(--tblr-bg-surface);
  color: var(--tblr-body-color);
  font-size: var(--kp-fs-small);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

button.kp-relchip:hover {
  border-color: var(--tblr-primary);
  color: var(--tblr-primary);
}

.kp-relchip > .ti {
  flex: 0 0 auto;
}

.kp-relchip-meta {
  margin-left: 2px;
  color: var(--tblr-secondary);
}

@media (max-width: 1199.98px) {
  .kp-details-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 575.98px) {
  .kp-details-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .kp-details-grid .kp-vitem-wide,
  .kp-details-grid > .kp-details-half {
    grid-column: auto;
  }
}

/* --------------------------------------------------------------------------
   Record toolbar
   -------------------------------------------------------------------------- */

.kp-record-toolbar {
  flex-wrap: wrap;
  row-gap: 6px;
}

.kp-record-identity {
  min-width: 0;
}

.kp-record-badges {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: 4px;
}

/* --------------------------------------------------------------------------
   Record header (kpRecordHeader, imports/ui/components/kpRecordHeader.html)
   --------------------------------------------------------------------------
   One row from 992px up: icon, the title with the pills and the amount beside
   it and the account muted under it, then the actions. A title of up to about
   30 characters stays whole: the pills wrap under it first. A longer one gives
   way (cut with an ellipsis, whole in its hover text) down to that width; past
   that, too, the pills wrap under the title rather than run under the
   actions. The actions keep their size, and take the next row only when
   they would leave the title and the account less than 260px. */

.kp-record-titleline {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 8px;
  min-width: 0;
}

.kp-record-header .kp-record-title {
  flex: 1 1 16em;
  max-width: max-content;
  min-width: 0;
}

.kp-record-header .kp-record-title > span,
.kp-record-header .kp-record-title .kp-inline-edit > span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.kp-record-header .kp-record-title .kp-inline-edit {
  min-width: 0;
}

.kp-record-header .kp-record-badges {
  flex: 0 1 auto;
  flex-wrap: wrap;
  row-gap: 4px;
  min-width: 0;
  margin-left: 4px;
}

/* A pill that names its system carries that system's icon ("SAP failed"). */
.kp-record-header .kp-status-pill > .ti {
  margin-right: 4px;
  font-size: 13px;
}

/* The line under the title wraps onto a second line rather than cutting a
   name: the account wraps between its words, the codes and the owner move to
   the next line whole, each with its separator dot. */
.kp-record-sub {
  display: block;
  min-width: 0;
}

.kp-record-sub-part {
  display: inline;
  white-space: nowrap;
}

/* The account wraps; as a link (`.kp-link`, which is cut to one line
   elsewhere) it wraps too, and stays in the line's muted size. */
.kp-record-sub .kp-record-sub-main {
  overflow: visible;
  text-overflow: clip;
  white-space: normal;
  overflow-wrap: anywhere;
}

.kp-record-sub .kp-link {
  font-weight: inherit;
}

.kp-record-sub-part + .kp-record-sub-part::before {
  content: "\00B7";
  margin: 0 6px;
}

@media (min-width: 992px) {
  .kp-record-header .kp-toolbar-actions {
    flex-wrap: nowrap;
  }

  .kp-record-header .kp-record-identity {
    flex: 1 1 0;
    min-width: 260px;
  }
}

/* A greyed action's written reason ("Available once the customer has
   accepted") needs room the header has only on a wide window; narrower, the
   reason is the button's hover text, as below 1200px everywhere. */
@media (max-width: 1599.98px) {
  .kp-record-header .kp-disabled-reason {
    display: none;
  }
}

@media (max-width: 575.98px) {
  .kp-record-header .kp-record-title > span {
    white-space: normal;
  }
}

/* A plain-language alert above a record's tabs, with its action beside it
   (a sales order SAP refused: "Try again"). */
.kp-record-alert {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
  padding: 10px 12px;
  border-radius: var(--kp-radius);
  background: var(--kp-status-danger-bg);
  color: var(--kp-status-danger-fg);
  font-size: var(--kp-fs-body);
}

.kp-record-alert > .ti {
  flex: 0 0 auto;
  font-size: 18px;
}

.kp-record-alert-text {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.kp-record-alert-reason {
  overflow-wrap: anywhere;
  color: var(--tblr-body-color);
  font-size: var(--kp-fs-small);
}

.kp-record-alert > .btn {
  flex: 0 0 auto;
}

/* The name reads as a heading and only shows it is editable on hover. */
.kp-inline-edit {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  letter-spacing: inherit;
  text-align: left;
}

.kp-inline-edit > span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.kp-inline-edit > i {
  flex: 0 0 auto;
  font-size: 14px;
  color: var(--tblr-secondary);
  opacity: 0;
  transition: opacity var(--kp-transition, 150ms ease-out);
}

.kp-inline-edit:hover > i,
.kp-inline-edit:focus-visible > i {
  opacity: 1;
}

.kp-rename {
  display: flex;
  align-items: center;
  gap: 4px;
}

.kp-rename .form-control {
  height: 30px;
  min-width: 240px;
  font-size: var(--kp-fs-card);
  font-weight: 600;
}

/* --------------------------------------------------------------------------
   Identity card
   -------------------------------------------------------------------------- */

.kp-ident {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding-bottom: 12px;
  margin-bottom: 12px;
  border-bottom: 1px solid var(--tblr-border-color);
}

.kp-ident-label {
  font-size: var(--kp-fs-small);
  font-weight: 600;
  color: var(--tblr-secondary);
}

.kp-ident-meta {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: var(--kp-fs-small);
  color: var(--tblr-secondary);
  overflow-wrap: anywhere;
}

.kp-ident-meta:hover {
  color: var(--tblr-primary);
}

/* A link that is a button, so it can open a tab instead of navigating. */
.kp-link {
  display: inline-block;
  max-width: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--tblr-primary);
  font: inherit;
  font-weight: 500;
  text-align: left;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.kp-link:hover {
  text-decoration: underline;
}

/* --------------------------------------------------------------------------
   Stage bar
   -------------------------------------------------------------------------- */

.kp-stagebar {
  display: flex;
  align-items: stretch;
  gap: 2px;
  margin-bottom: 12px;
  overflow-x: auto;
  scrollbar-width: none;
}

.kp-stagebar::-webkit-scrollbar {
  height: 0;
}

.kp-stageseg {
  position: relative;
  /* The labels are never shortened: the bar scrolls inside its column instead,
     so "Technical Evaluation" is not read as "Technical...". */
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 32px;
  padding: 0 14px 0 20px;
  border: 1px solid var(--tblr-border-color);
  border-left: 0;
  background: var(--tblr-bg-surface);
  color: var(--tblr-secondary);
  font-size: var(--kp-fs-small);
  font-weight: 600;
  white-space: nowrap;
  clip-path: polygon(0 0, calc(100% - 9px) 0, 100% 50%, calc(100% - 9px) 100%, 0 100%, 9px 50%);
}

.kp-stageseg:first-child {
  border-left: 1px solid var(--tblr-border-color);
  padding-left: 14px;
  border-top-left-radius: var(--kp-radius-sm);
  border-bottom-left-radius: var(--kp-radius-sm);
  clip-path: polygon(0 0, calc(100% - 9px) 0, 100% 50%, calc(100% - 9px) 100%, 0 100%);
}

.kp-stageseg:last-child {
  clip-path: polygon(0 0, 100% 0, 100% 100%, 0 100%, 9px 50%);
  border-top-right-radius: var(--kp-radius-sm);
  border-bottom-right-radius: var(--kp-radius-sm);
}

.kp-stageseg:not([disabled]):hover {
  background: var(--tblr-bg-surface-secondary);
  color: var(--tblr-body-color);
}

.kp-stageseg-done {
  background: var(--tblr-bg-surface-secondary);
  color: var(--tblr-body-color);
}

/* The current step: its swatch's soft fill and a 2px edge in the base colour
   (the swatch class is on the step, section 10b). */
.kp-stageseg-current {
  background: var(--kp-swatch-bg, var(--kp-status-neutral-bg));
  color: var(--kp-swatch-fg, var(--kp-status-neutral-fg));
  box-shadow: inset 0 -2px 0 var(--kp-swatch, var(--kp-swatch-slate));
}

/* Closed Won and Closed Lost sit at the end as the final state. */
.kp-stageseg-close {
  font-weight: 500;
}

/* A completed step carries a tick before its label (kpStageBar). */
.kp-stageseg-tick {
  margin-right: 4px;
  font-size: var(--kp-fs-body);
}

/* --------------------------------------------------------------------------
   Centre tabs
   -------------------------------------------------------------------------- */

.kp-rtabs {
  display: flex;
  align-items: stretch;
  gap: 2px;
  margin-bottom: 12px;
  border-bottom: 1px solid var(--tblr-border-color);
  overflow-x: auto;
  scrollbar-width: none;
}

.kp-rtabs::-webkit-scrollbar {
  height: 0;
}

.kp-rtab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  border: 0;
  border-bottom: 2px solid transparent;
  background: transparent;
  color: var(--tblr-secondary);
  font-size: var(--kp-fs-body);
  font-weight: 600;
  white-space: nowrap;
}

.kp-rtab:hover {
  color: var(--tblr-body-color);
}

.kp-rtab.active {
  border-bottom-color: var(--tblr-primary);
  color: var(--tblr-primary);
}

.kp-rtab i {
  font-size: 15px;
}

/* --------------------------------------------------------------------------
   Activity composer and timeline
   -------------------------------------------------------------------------- */

.kp-composer {
  padding-bottom: 14px;
  margin-bottom: 14px;
  border-bottom: 1px solid var(--tblr-border-color);
}

.kp-composer-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  margin-bottom: 12px;
}

.kp-composer-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 12px;
}

.kp-timeline {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.kp-timeline-item {
  display: flex;
  gap: 10px;
}

.kp-timeline-tile {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 30px;
  width: 30px;
  height: 30px;
  border-radius: var(--kp-radius-sm);
  background: var(--kp-primary-soft);
  color: var(--tblr-primary);
  font-size: 15px;
}

.kp-timeline-body {
  flex: 1 1 auto;
  min-width: 0;
}

.kp-timeline-head {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.kp-timeline-type {
  font-size: var(--kp-fs-body);
  font-weight: 600;
}

.kp-timeline-when {
  font-size: var(--kp-fs-small);
  color: var(--tblr-secondary);
}

.kp-timeline-text {
  margin: 4px 0 2px;
  font-size: var(--kp-fs-body);
  overflow-wrap: anywhere;
}

.kp-timeline-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px 14px;
  font-size: var(--kp-fs-small);
  color: var(--tblr-secondary);
}

.kp-timeline-meta i {
  margin-right: 4px;
}

/* --------------------------------------------------------------------------
   Record feed (kpRecordFeed): the activities and the changes of a record in
   one timeline (DESIGN.md section 2, "Record page")
   -------------------------------------------------------------------------- */

.kp-feed-compose {
  margin-bottom: 16px;
}

/* A change reads quieter than an activity: a grey tile, the sentence in
   body weight, who and when after it. */
.kp-feed-change .kp-timeline-tile {
  background: var(--tblr-bg-surface-secondary);
  color: var(--tblr-secondary);
}

.kp-feed-change-text {
  font-size: var(--kp-fs-body);
  overflow-wrap: anywhere;
}

.kp-feed-change .kp-hist-changes {
  margin: 4px 0 0;
}

/* The line under a stage bar a person can click: how long the record has been
   in its stage, and that a click on a stage moves it. */
.kp-stagebar-note {
  margin: -6px 0 12px;
  font-size: var(--kp-fs-small);
  color: var(--tblr-secondary);
}

/* --------------------------------------------------------------------------
   Label over value, for the commercial terms tab
   -------------------------------------------------------------------------- */

.kp-vlist {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 14px 20px;
}

.kp-vitem {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.kp-vitem-wide {
  grid-column: 1 / -1;
}

.kp-vlabel {
  font-size: var(--kp-fs-small);
  font-weight: 600;
  color: var(--tblr-secondary);
}

.kp-vvalue {
  font-size: var(--kp-fs-body);
  overflow-wrap: anywhere;
}

/* --------------------------------------------------------------------------
   Right column cards
   -------------------------------------------------------------------------- */

.kp-nextlist {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.kp-next {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.kp-next-value {
  font-size: var(--kp-fs-body);
  font-weight: 600;
}

.kp-related {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.kp-related-row {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 7px 8px;
  border: 0;
  border-radius: var(--kp-radius-sm);
  background: transparent;
  color: var(--tblr-body-color);
  font-size: var(--kp-fs-body);
  text-align: left;
}

button.kp-related-row:hover {
  background: var(--tblr-bg-surface-secondary);
}

.kp-related-row > i {
  flex: 0 0 auto;
  font-size: 16px;
  color: var(--tblr-secondary);
}

.kp-related-name {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.kp-related-meta {
  flex: 0 0 auto;
  font-size: var(--kp-fs-small);
  font-weight: 600;
  color: var(--tblr-secondary);
}

/* A long table shown as a second card on a record page's first tab (a
   contact's activities under Overview) scrolls inside its card, the heading
   row in place. */
.kp-rows-capped > .kp-table-wrap {
  max-height: 428px;
  overflow-y: auto;
}

/* --------------------------------------------------------------------------
   Inspector: the last three activities
   -------------------------------------------------------------------------- */

.kp-insp-activity {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 8px 0 0;
  padding: 0;
  list-style: none;
}

.kp-insp-activity > li {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.kp-insp-activity-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}

.kp-insp-activity-type {
  font-size: var(--kp-fs-small);
  font-weight: 600;
}

.kp-insp-activity-when {
  font-size: var(--kp-fs-label);
  color: var(--tblr-secondary);
}

.kp-insp-activity-text {
  font-size: var(--kp-fs-small);
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

/* --------------------------------------------------------------------------
   Lead conversion, on the legacy lead pages
   -------------------------------------------------------------------------- */

.kp-convert-wrap {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  flex-wrap: wrap;
}

.kp-converted-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: var(--kp-fs-small);
  font-weight: 600;
  color: var(--tblr-primary);
  background: transparent;
  border: 0;
  padding: 0;
}

.kp-converted-link:hover {
  text-decoration: underline;
}

/* ==========================================================================
   11c. Sales orders (DESIGN.md section 2)

   Everything the sales order list, drawer and record page needs beyond
   sections 11 and 11b: the locked-field treatment, the delivery schedule
   table, the SAP attempts table and the date range filter chip. Pills, tables,
   cards, drawers, stage bars and record columns are reused as they are.
   ========================================================================== */

/* The order number stays on one line; the account takes the room that is left
   (the list pass, further down). */
.kp-so-table .kp-cell-code {
  white-space: nowrap;
}

/* A failed posting's message, wherever it is shown. */
.kp-so-error {
  margin: 8px 0 0;
  font-size: var(--kp-fs-small);
  color: var(--tblr-danger);
  overflow-wrap: anywhere;
}

/* --- Locked fields ------------------------------------------------------- */

.kp-lock-note {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  padding: 10px 12px;
  margin-bottom: 12px;
  font-size: var(--kp-fs-small);
  border: 1px solid var(--tblr-border-color);
  border-radius: 8px;
  background: var(--tblr-bg-surface-secondary);
  color: var(--tblr-secondary);
}

.kp-lock-note > i {
  flex: none;
  margin-top: 1px;
  font-size: 15px;
}

.kp-override-switch {
  margin-bottom: 8px;
}

.kp-override-warning {
  font-size: var(--kp-fs-small);
}

.kp-lock-icon {
  margin-left: 6px;
  font-size: 13px;
  color: var(--tblr-secondary);
  vertical-align: middle;
}

.kp-lock-hint {
  display: inline-flex;
  gap: 4px;
  align-items: center;
  margin-left: 10px;
  font-size: var(--kp-fs-small);
  color: var(--tblr-secondary);
}

.kp-lock-hint > i {
  font-size: 13px;
}

/* A locked line renders as text in the cell an input would fill. */
.kp-line-readonly {
  display: block;
  padding: 4px 2px;
  font-size: var(--kp-fs-body);
  color: var(--tblr-body-color);
}

/* --- A saved-state message, the quiet sibling of .kp-form-error ---------- */

.kp-form-notice {
  padding: 8px 12px;
  margin: 0 0 12px;
  font-size: var(--kp-fs-small);
  border: 1px solid var(--tblr-border-color);
  border-radius: 8px;
  background: var(--kp-status-success-bg);
  color: var(--kp-status-success-fg);
}

/* --- Date range filter chip --------------------------------------------- */

.kp-chip-dates {
  display: inline-flex;
  gap: 4px;
  align-items: center;
}

.kp-chip-dates-sep {
  font-size: var(--kp-fs-small);
  color: var(--tblr-secondary);
}

.form-control.kp-chip-date {
  width: auto;
  min-width: 132px;
  height: 28px;
  padding: 2px 8px;
  font-size: var(--kp-fs-small);
  background: var(--tblr-bg-surface-secondary);
}

/* --- Delivery schedule and SAP attempts --------------------------------- */

.kp-schedule .form-control,
.kp-schedule .form-select {
  height: 30px;
  padding: 2px 8px;
  font-size: var(--kp-fs-body);
}

.kp-schedule > tbody > tr > td {
  padding-top: 4px;
  padding-bottom: 4px;
  vertical-align: middle;
}

/* A select has to hold "In production" and a product line's name without the
   caret sitting on top of the label. */
.kp-schedule .kp-picker:has(> input.js-sched-status) {
  min-width: 132px;
}

.kp-schedule .kp-picker:has(> input.js-sched-line) {
  min-width: 200px;
}

.kp-sched-remaining {
  font-variant-numeric: tabular-nums;
  color: var(--tblr-secondary);
}

.kp-sap-table > tbody > tr > td:nth-child(6) {
  max-width: 280px;
}

.kp-hash {
  font-family: var(--kp-font-mono, ui-monospace, SFMono-Regular, Menlo, monospace);
  font-size: var(--kp-fs-small);
  color: var(--tblr-secondary);
  white-space: nowrap;
}

/* --- Record page identity ----------------------------------------------- */

.kp-ident-address {
  white-space: pre-line;
  font-size: var(--kp-fs-small);
  line-height: 1.45;
  color: var(--tblr-body-color);
  overflow-wrap: anywhere;
}

/* The SAP password form in the Entities drawer, below the facts list. */
.kp-sap-password {
  padding-top: 8px;
  border-top: 1px solid var(--tblr-border-color);
}

/* ==========================================================================
   12. Full height list pages
   --------------------------------------------------------------------------
   A list page is a column the height of the content area: the toolbar at its
   natural height, then the table card. The card is as tall as its rows and
   stops there (a list of three rows is a short card, not a white slab to the
   bottom of the screen); once the rows need more than the room left it stops
   growing and its scroller scrolls. The scroller is the only thing that
   scrolls vertically, its header is sticky, and it scrolls sideways only when
   the columns genuinely do not fit. Every level of the chain is therefore
   `flex: 0 1 auto`: content height, shrinking to fit, never growing.

   The behaviour is opt in: a list template puts `kp-page-fill` on its root, so
   forms, record pages, dashboards and reports keep scrolling the document.
   ========================================================================== */

/* The chain from the viewport down to the card. Only a page that opted in makes
   the shell stop scrolling the document. */
.kp-shell:has(.kp-page-fill) .kp-main {
  height: 100vh;
  min-height: 0;
}

/* The tab strip must keep its height: in the fixed-height column the table would
   otherwise squeeze it (it is a flex item with the default shrink of 1). */
.kp-main > .kp-tabstrip {
  flex: 0 0 var(--kp-tabstrip-height);
}

.kp-shell:has(.kp-page-fill) .kp-workspace {
  flex: 1 1 0;
  min-height: 0;
  overflow: hidden;
}

.kp-shell:has(.kp-page-fill) .kp-content {
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

.kp-page-fill {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
}

/* A full-height page whose content is a stack of cards rather than one list:
   the page itself scrolls (search results, targets), since .kp-content does
   not while a .kp-page-fill is on it. */
/* The scroller reaches the edges of the content area and pads itself back in,
   so the page header band keeps its full-width bleed and the scrollbar sits
   at the window edge. */
.kp-page-fill.kp-page-scroll {
  margin: 0 calc(-1 * var(--kp-page-padding)) calc(-1 * var(--kp-page-padding));
  padding: 0 var(--kp-page-padding) var(--kp-page-padding);
  overflow-x: hidden;
  overflow-y: auto;
}

.kp-page-fill.kp-page-scroll > * {
  flex: 0 0 auto;
}

/* The toolbar and the filter summary keep their natural height. */
.kp-page-fill > .card:first-child,
.kp-page-fill .card#filter {
  flex: 0 0 auto;
}

/* On the migrated pages the toolbar is a sibling of the card, so the card is the
   direct child that fits its rows. */
.kp-page-fill > .card {
  display: flex;
  flex: 0 1 auto;
  flex-direction: column;
  min-height: 0;
}

/* The card holding the table is the one that grows. */
.kp-page-fill .card:has(.kp-list-scroller),
.kp-page-fill .card:has(.kp-table-wrap) {
  overflow: hidden;
}

/* The scroller: its rows' height, capped by the card, never a fixed pixel or
   vh box. */
.kp-list-scroller,
.kp-page-fill .kp-table-wrap {
  flex: 0 1 auto;
  height: auto;
  min-height: 0;
  max-height: none;
  overflow: auto;
}

/* A scroller that is a section of a page rather than the page itself: the
   attachments tab inside a record, the settings table on the Configuration
   page. It cannot take the card's height, because the card is not the page. */
.kp-list-scroller-inset {
  flex: 0 1 auto;
  height: auto;
  max-height: 360px;
}

/* Sticky header inside the scroller, for the legacy tables too. */
.kp-list-scroller > .table > thead > tr > th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--tblr-bg-surface-secondary);
}

/* The sentinel the scroll list appends: it is where "Loading more" and the
   quiet end of list line are written. */
.kp-list-foot {
  min-height: 24px;
  padding: 8px 12px 14px;
  text-align: center;
  font-size: var(--kp-fs-small);
  color: var(--tblr-secondary);
}

.kp-list-foot-loading::before {
  content: "";
  display: inline-block;
  width: 12px;
  height: 12px;
  margin-right: 6px;
  vertical-align: -2px;
  border: 2px solid var(--tblr-border-color);
  border-top-color: var(--tblr-primary);
  border-radius: 50%;
  animation: kp-list-spin .7s linear infinite;
}

.kp-list-foot-end {
  opacity: .65;
}

/* A page that failed says so and offers the retry, rather than spinning. */
.kp-list-foot-error {
  color: var(--tblr-danger);
}

.kp-list-retry {
  padding: 0 4px;
  font-size: var(--kp-fs-small);
  vertical-align: baseline;
}

@keyframes kp-list-spin {
  to { transform: rotate(360deg); }
}

@media (prefers-reduced-motion: reduce) {
  .kp-list-foot-loading::before { animation: none; }
}

/* --------------------------------------------------------------------------
   Column types
   --------------------------------------------------------------------------
   Long text truncates to one line with a tooltip instead of wrapping to three;
   codes, statuses, dates and numbers never wrap.
   -------------------------------------------------------------------------- */

.kp-list-scroller .table th.kp-col-sl,
.kp-list-scroller .table td.kp-col-sl,
.kp-table th.kp-col-sl,
.kp-table td.kp-col-sl {
  width: 48px;
  min-width: 48px;
  max-width: 48px;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.kp-col-code {
  min-width: 88px;
  max-width: 150px;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.kp-col-name {
  min-width: 120px;
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.kp-col-owner {
  min-width: 100px;
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.kp-col-status {
  min-width: 84px;
  white-space: nowrap;
}

.kp-col-date {
  min-width: 92px;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.kp-col-num {
  min-width: 96px;
  white-space: nowrap;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* A two word header may wrap: a column whose data never wraps should not be held
   open by the width of its own label. */
.kp-list-scroller .table > thead > tr > th.kp-col-status,
.kp-list-scroller .table > thead > tr > th.kp-col-date,
.kp-list-scroller .table > thead > tr > th.kp-col-owner,
.kp-list-scroller .table > thead > tr > th.kp-col-text {
  white-space: normal;
  line-height: 1.2;
}

/* Free text that can run long (a conversion time, a note) is capped hard. */
.kp-col-text {
  min-width: 100px;
  max-width: 130px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* A truncated cell still has to hold a link or a pill without breaking. */
.kp-col-name > a,
.kp-col-name > button,
.kp-col-owner > a {
  display: inline;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
}

/* On a laptop the low priority columns give way so nothing scrolls sideways.
   The breakpoint is 1600px rather than 1400px because the sidebar and the page
   gutters take about 350px off the window: a 1440px laptop leaves the card
   roughly 1090px, which the full column set does not fit into. Above 1600px
   every column comes back. */
@media (max-width: 1599.98px) {
  .kp-col-lowprio {
    display: none !important;
  }
}

/* A second tier for the widest tables (leads), so a 1366px laptop fits too. */
@media (max-width: 1439.98px) {
  .kp-col-lowprio-sm {
    display: none !important;
  }
}

/* A name over its code in one cell cuts with an ellipsis, like a plain name. */
.kp-col-name .kp-cell-stack > .kp-cell-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* The side panel takes 340px off a list. On a laptop the list answers in two
   ways, the same on every list (DESIGN.md, "Lists beside the side panel"):
   - `.kp-col-panel-hide` columns give way: the Owner first, because the panel
     shows it for the selected row;
   - the `.kp-col-main` column (the name of the record) takes whatever width
     is left; a long name wraps onto a second line and is cut only after
     that (`.kp-wrap2`), with the whole name in the cell's title and at the
     top of the panel. `max-width: 0` with `width: 100%` is what lets a table
     cell shrink below its text.
   The panel takes the width a laptop lacks, so this holds up to 1900px: a
   1600px to 1900px window with the panel open leaves the list no more room
   than a laptop has without it, and the low priority columns give way there
   as well. From 1900px there is room for every column beside the panel. */
@media (max-width: 1899.98px) {
  .kp-has-inspector .kp-col-panel-hide,
  .kp-has-inspector .kp-col-lowprio {
    display: none !important;
  }

  /* The opportunity table's own floor (900px) is for the full column set. */
  .kp-has-inspector .kp-opps-table {
    min-width: 0;
  }

  .kp-has-inspector .kp-table > thead > tr > th.kp-col-main,
  .kp-has-inspector .kp-table > tbody > tr > td.kp-col-main {
    width: 100%;
    min-width: 150px;
    max-width: 0;
  }

  .kp-has-inspector .kp-table > tbody > tr > td.kp-col-main .kp-cell-name {
    max-width: 100%;
  }

  /* A list with a second name that matters as much (the account of an
     opportunity) splits the room between the two: `.kp-col-main-share` on
     the first, `.kp-col-main2` on the second. */
  .kp-has-inspector .kp-table > thead > tr > th.kp-col-main.kp-col-main-share,
  .kp-has-inspector .kp-table > tbody > tr > td.kp-col-main.kp-col-main-share {
    width: 60%;
  }

  .kp-has-inspector .kp-table > thead > tr > th.kp-col-main2,
  .kp-has-inspector .kp-table > tbody > tr > td.kp-col-main2 {
    width: 40%;
    min-width: 120px;
    max-width: 0;
  }

  /* The other name columns go back to the shared width where a list had
     widened them, so the table fits beside the panel. */
  .kp-has-inspector .kp-contacts-table .kp-col-name:not(.kp-col-main):not(.kp-col-main2) {
    max-width: 180px;
  }
}

/* Opportunities and Quotations have the most columns: beside the panel on a
   desktop of 1900px to 2000px they came to a little more than the card (38px
   and 21px), which pushed the row menu out of sight. The Owner gives way
   there too (the panel shows it). */
@media (min-width: 1900px) and (max-width: 1999.98px) {
  .kp-has-inspector .kp-opps-table .kp-col-owner.kp-col-panel-hide,
  .kp-has-inspector .kp-qtn-table .kp-col-owner.kp-col-panel-hide {
    display: none !important;
  }
}

/* --------------------------------------------------------------------------
   The list pass (docs/ui-audit-2026-10-13, item 7 and section 5.1)
   --------------------------------------------------------------------------
   One set of rules for the module lists (DESIGN.md section 2, "List columns"):
   - `.kp-col-main` (and `.kp-col-main2` where a list has two names that
     matter) is the flexible column: it takes the width the other columns
     leave, so a customer name is never cut while the row has room. The text
     carries `.kp-wrap2`: it wraps onto a second line and is cut only then.
   - `.kp-row-title` is the row's own name or number: 13px, weight 600, body
     colour, never monospace, with the secondary code under it in muted 12px.
   - dates, statuses, totals and the owner keep the width of what they hold.
   The audit list keeps its one line summary, so it is left out.
   -------------------------------------------------------------------------- */

.kp-table > thead > tr > th.kp-col-main,
.kp-table > tbody > tr > td.kp-col-main,
.kp-table > thead > tr > th.kp-col-main2,
.kp-table > tbody > tr > td.kp-col-main2 {
  width: 100%;
  min-width: 200px;
  max-width: none;
  overflow: visible;
  white-space: normal;
}

.kp-audit-table > thead > tr > th.kp-col-main,
.kp-audit-table > tbody > tr > td.kp-col-main {
  width: auto;
  min-width: 0;
  max-width: 420px;
  overflow: hidden;
  white-space: nowrap;
}

/* Two flexible columns share the room, the account ahead: an opportunity's
   name usually repeats its account. */
.kp-table > thead > tr > th.kp-col-main.kp-col-main-share,
.kp-table > tbody > tr > td.kp-col-main.kp-col-main-share {
  width: 42%;
}

.kp-table > thead > tr > th.kp-col-main2,
.kp-table > tbody > tr > td.kp-col-main2 {
  width: 58%;
  min-width: 160px;
}

/* Contacts: a person's name is short, so the account takes most of the room,
   beside the side panel as well. */
.kp-table.kp-contacts-table > thead > tr > th.kp-col-main.kp-col-main-share,
.kp-table.kp-contacts-table > tbody > tr > td.kp-col-main.kp-col-main-share {
  width: 30%;
  min-width: 140px;
}

.kp-table.kp-contacts-table > thead > tr > th.kp-col-main2,
.kp-table.kp-contacts-table > tbody > tr > td.kp-col-main2 {
  width: 70%;
}

/* Quotations: the account ahead of the opportunity, so a long opportunity
   name wraps too instead of being cut while the account has room. Where the
   opportunity gives way (a laptop, the side panel) the account takes the
   whole room again. */
.kp-table.kp-qtn-table > thead > tr > th.kp-col-main.kp-col-main-share,
.kp-table.kp-qtn-table > tbody > tr > td.kp-col-main.kp-col-main-share {
  width: 58%;
}

.kp-table.kp-qtn-table > thead > tr > th.kp-col-main2,
.kp-table.kp-qtn-table > tbody > tr > td.kp-col-main2 {
  width: 42%;
}

@media (max-width: 1599.98px) {
  .kp-table.kp-qtn-table > thead > tr > th.kp-col-main.kp-col-main-share,
  .kp-table.kp-qtn-table > tbody > tr > td.kp-col-main.kp-col-main-share {
    width: 100%;
  }
}

@media (max-width: 1899.98px) {
  .kp-has-inspector .kp-table.kp-qtn-table > thead > tr > th.kp-col-main.kp-col-main-share,
  .kp-has-inspector .kp-table.kp-qtn-table > tbody > tr > td.kp-col-main.kp-col-main-share {
    width: 100%;
  }
}

/* On a span (or the text of a link), never on the cell: see `.kp-clamp`. The
   second selector outranks the one line cut of a name over its code. */
.kp-wrap2,
.kp-table .kp-cell-stack > .kp-wrap2 {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  white-space: normal;
  overflow-wrap: anywhere;
  line-height: 1.35;
}

/* An opportunity row is three lines tall already (its name over two lines,
   then the code), so the account beside it may use the third. */
.kp-opps-table .kp-col-main2 .kp-wrap2 {
  -webkit-line-clamp: 3;
}

/* A link around wrapped text gives up its own one line cut. */
.kp-table td > .kp-link:has(> .kp-wrap2) {
  display: block;
  white-space: normal;
}

.kp-table .kp-row-title {
  color: var(--tblr-body-color);
  font-family: inherit;
  font-size: var(--kp-fs-body);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.kp-table .kp-row-title ~ .kp-cell-sub {
  font-size: var(--kp-fs-small);
}

/* A date holds its own width, and the line under it ("16 days overdue",
   "Today", "in 3 days") says how far off it is. The date itself stays in
   normal weight and colour: a column of bold red dates read as an alarm. */
.kp-table > thead > tr > th.kp-col-date,
.kp-table > tbody > tr > td.kp-col-date {
  width: 112px;
}

.kp-due {
  display: block;
  color: var(--tblr-secondary);
  font-size: var(--kp-fs-small);
  font-weight: 500;
  white-space: nowrap;
}

/* The same words on a record page's Facts line, after the date: "23 Oct 2026,
   in 9 days". Only the words take the colour; danger and warning follow. */
.kp-due-note {
  color: var(--tblr-secondary);
  font-weight: 500;
}

.kp-due-danger {
  color: var(--kp-danger-text);
}

.kp-due-warning {
  color: var(--kp-status-warning-fg);
}

/* The owner is the initials and the name beside them. A name wider than the
   column wraps between its words onto a second line, never cut. The cap sits
   on the content, since a table cell's own max-width is not a hard limit. */
.kp-table > tbody > tr > td.kp-col-owner.kp-col-avatar > .kp-owner {
  display: flex;
  max-width: 140px;
  min-width: 0;
}

.kp-owner > .kp-owner-name {
  min-width: 0;
  overflow-wrap: break-word;
  white-space: normal;
  line-height: 1.25;
}

/* The table's automatic layout shrinks a cell to its narrowest wrap, so the
   name broke onto two lines even with room to spare. Where the window has the
   room, the column keeps enough width for a first and last name on one line;
   on a laptop it still wraps rather than cutting the name. */
@media (min-width: 1500px) {
  .kp-table > thead > tr > th.kp-col-owner.kp-col-avatar,
  .kp-table > tbody > tr > td.kp-col-owner.kp-col-avatar {
    min-width: 170px;
  }
}

/* When the columns still do not fit, the scrollbar is inside the card and the
   first data column stays put. */
.kp-list-scroller .table > thead > tr > th.kp-col-sticky,
.kp-list-scroller .table > tbody > tr > td.kp-col-sticky,
.kp-table > thead > tr > th.kp-col-sticky,
.kp-table > tbody > tr > td.kp-col-sticky {
  position: sticky;
  left: 0;
  z-index: 1;
  background: var(--tblr-bg-surface);
}

.kp-list-scroller .table > thead > tr > th.kp-col-sticky,
.kp-table > thead > tr > th.kp-col-sticky {
  z-index: 3;
  background: var(--tblr-bg-surface-secondary);
}

.kp-list-scroller .table > tbody > tr:hover > td.kp-col-sticky,
.kp-table > tbody > tr:hover > td.kp-col-sticky {
  background: var(--tblr-bg-surface-secondary);
}

/* ==========================================================================
   13. Reports
   --------------------------------------------------------------------------
   The Reports module: the two pane folders page, the report list tables, the
   report builder and the static reports. Everything here reads its colour from
   a token, so the module works in dark mode; the page templates carry no inline
   colours any more.
   ========================================================================== */

/* --------------------------------------------------------------------------
   13a. Folders page - two panes
   -------------------------------------------------------------------------- */

.kp-reports-panes {
  display: flex;
  flex: 1 1 auto;
  gap: 16px;
  min-height: 0;
  min-width: 0;
}

/* Left pane: its own card, fixed width, scrolling on its own. */
.kp-reports-folders {
  display: flex;
  flex: 0 0 280px;
  flex-direction: column;
  width: 280px;
  min-height: 0;
  margin-bottom: 0;
  background: var(--tblr-bg-surface);
  border: 1px solid var(--tblr-border-color);
  border-radius: var(--kp-radius);
}

.kp-reports-folders-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 12px 8px;
}

.kp-reports-folders-head .kp-panel-title {
  flex: 1 1 auto;
  font-size: var(--kp-fs-card);
  font-weight: 600;
}

.kp-reports-folders-search {
  padding: 0 12px 10px;
}

.kp-reports-folders-scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding-bottom: 8px;
}

.kp-reports-folders-group {
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px solid var(--tblr-border-color);
}

/* --------------------------------------------------------------------------
   13b. Folder and category rows
   -------------------------------------------------------------------------- */

.dynamicReportFolder_foldersList {
  display: flex;
  flex-direction: column;
}

.dynamicReportFolder_foldersList .changeCategory {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  height: 36px;
  margin: 1px 6px;
  padding: 0 6px 0 12px;
  border: 0;
  border-radius: var(--kp-radius-sm);
  font-size: var(--kp-fs-body);
  color: var(--tblr-body-color);
  cursor: pointer;
}

.dynamicReportFolder_foldersList .changeCategory > .ti {
  flex: 0 0 auto;
  font-size: 15px;
  color: var(--tblr-secondary);
}

.kp-reports-folder-name {
  flex: 1 1 auto;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dynamicReportFolder_foldersList .changeCategory:hover {
  background: var(--tblr-bg-surface-secondary);
}

/* Active row: the insights hue, with the same 3px bar as the sidebar. */
.dynamicReportFolder_foldersList .changeCategory.active {
  background: var(--kp-hue-insights-soft);
  font-weight: 600;
}

.dynamicReportFolder_foldersList .changeCategory.active > .ti {
  color: var(--kp-hue-insights);
}

.dynamicReportFolder_foldersList .changeCategory.active::before {
  content: "";
  position: absolute;
  top: 6px;
  bottom: 6px;
  left: 0;
  width: 3px;
  border-radius: 2px;
  background: var(--kp-hue-insights);
}

/* The row kebab is a repeated row level action: one glyph, same place, and only
   while the row is hovered or something inside it has focus. */
.dynamicReportFolder_foldersList .moreBtn {
  flex: 0 0 auto;
  opacity: 0;
  transition: opacity var(--kp-transition, 150ms ease-out);
}

.dynamicReportFolder_foldersList .changeCategory:hover .moreBtn,
.dynamicReportFolder_foldersList .changeCategory:focus-within .moreBtn,
.dynamicReportFolder_foldersList .moreBtn.show {
  opacity: 1;
}

.dynamicReportFolder_foldersList .moreBtn > .btn {
  padding: 2px 6px;
  border: 0;
  background: transparent;
  box-shadow: none;
  line-height: 1;
  color: var(--tblr-secondary);
}

.dynamicReportFolder_foldersList .moreBtn > .btn:hover,
.dynamicReportFolder_foldersList .moreBtn.show > .btn {
  color: var(--tblr-body-color);
}

@media (prefers-reduced-motion: reduce) {
  .dynamicReportFolder_foldersList .moreBtn {
    transition: none;
  }
}

/* A report dragged over a folder. */
.dynamicReportFolder_foldersList .changeCategory.dropZone {
  outline: 2px dashed var(--tblr-primary);
  outline-offset: -2px;
  background: var(--tblr-bg-surface-secondary);
}

/* --------------------------------------------------------------------------
   13c. Folders page - right pane
   -------------------------------------------------------------------------- */

.kp-reports-main {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
}

.kp-reports-main > .card:first-child {
  flex: 0 0 auto;
}

.kp-reports-main > .kp-reports-list-card {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  min-height: 0;
  margin-bottom: 0;
  overflow: hidden;
}

.kp-reports-main > .kp-reports-list-card > .card-body {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
}

/* Below 992px the panes stack and the page scrolls as one column. */
@media (max-width: 991.98px) {
  .kp-reports-panes {
    flex-direction: column;
    overflow-y: auto;
  }

  .kp-reports-folders {
    flex: 0 0 auto;
    width: 100%;
  }

  .kp-reports-folders-scroll {
    max-height: 260px;
  }

  .kp-reports-main {
    flex: 1 0 auto;
  }
}

/* --------------------------------------------------------------------------
   13d. Report list columns
   -------------------------------------------------------------------------- */

.kp-list-scroller .table th.kp-col-fav,
.kp-list-scroller .table td.kp-col-fav {
  width: 40px;
  min-width: 40px;
  text-align: center;
}

.kp-list-scroller .table th.kp-col-menu,
.kp-list-scroller .table td.kp-col-menu {
  width: 44px;
  min-width: 44px;
  text-align: right;
}

/* Favourite toggle: outline when off, filled and red when on. */
.kp-fav-btn {
  padding: 2px 4px;
  border: 0;
  background: transparent;
  line-height: 1;
  font-size: 15px;
  color: var(--tblr-secondary);
  cursor: pointer;
}

.kp-fav-btn:hover,
.kp-fav-btn.kp-fav-on {
  color: var(--tblr-danger);
}

/* --------------------------------------------------------------------------
   13e. Report builder and report view
   -------------------------------------------------------------------------- */

/* The drop zone the builder asks you to drag fields into. */
.kp-field-dropzone {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 80%;
  max-width: 50em;
  min-height: 4em;
  padding: 8px 16px;
  border: 2px dashed var(--tblr-border-color);
  border-radius: var(--kp-radius);
  background: var(--tblr-bg-surface-secondary);
  text-align: center;
  font-weight: 600;
  color: var(--tblr-secondary);
}

/* The "how a report is built" explainer band above the builder. */
.kp-report-hint {
  display: flex;
  gap: 1em;
  padding: 16px;
  border: 1px solid var(--tblr-border-color);
  border-radius: var(--kp-radius);
  background: var(--tblr-bg-surface-secondary);
}

.kp-field-hint {
  font-weight: 400;
  font-size: var(--kp-fs-small);
  color: var(--tblr-secondary);
}

/* The dot that marks a column with a filter on it. */
.kp-filter-dot {
  position: absolute;
  top: 2px;
  right: 0;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--tblr-warning);
}

/* The chart band on a report that shows a graph. */
.kp-report-graph {
  background: var(--tblr-bg-surface-secondary);
  border-radius: var(--kp-radius);
}

/* --------------------------------------------------------------------------
   13f. Static reports
   --------------------------------------------------------------------------
   These tables scroll inside the card and freeze their header, and two of them
   freeze the first columns as well.
   -------------------------------------------------------------------------- */

.kp-report-scroll {
  /* Use the height the screen has, rather than a fixed 500px box. */
  max-height: max(360px, calc(100vh - 240px));
  overflow: auto;
}

.kp-report-scroll > .table > thead > tr > th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--tblr-bg-surface-secondary);
}

/* A second header row sits under the first one, so it cannot stick at 0. */
.kp-report-scroll > .table > thead > tr:nth-child(2) > th {
  z-index: 1;
}

.kp-col-freeze-1,
.kp-col-freeze-2 {
  position: sticky;
  z-index: 1;
  background: var(--tblr-bg-surface);
}

.kp-col-freeze-1 {
  left: 0;
  width: 80px;
  min-width: 80px;
}

.kp-col-freeze-2 {
  left: 80px;
  min-width: 220px;
}

.kp-report-scroll > .table > tbody > tr:hover > .kp-col-freeze-1,
.kp-report-scroll > .table > tbody > tr:hover > .kp-col-freeze-2 {
  background: var(--tblr-bg-surface-secondary);
}

/* --------------------------------------------------------------------------
   10f. Action vocabulary support
   --------------------------------------------------------------------------
   DESIGN.md section 4, "Action vocabulary". One icon and one label per action,
   so these two rules only have to make icon plus label sit right; nothing here
   chooses a glyph.
   -------------------------------------------------------------------------- */

/* Row menu items are icon plus label. The gap replaces the `&nbsp;` runs the
   legacy templates used to space them with. The child combinators keep the
   notification dropdown, whose rows are `<li>` elements rather than
   `.dropdown-item`s, out of this. */
.dropdown-menu > .dropdown-item,
.dropdown-menu > li > .dropdown-item {
  display: flex;
  align-items: center;
  gap: 8px;
}

.dropdown-menu > .dropdown-item > i,
.dropdown-menu > li > .dropdown-item > i {
  flex: none;
  font-size: 15px;
  line-height: 1;
}

/* ==========================================================================
   14. Users and access
   --------------------------------------------------------------------------
   The user form (details plus the entity access table), the user list, the
   entity people drawer, the one-time password dialog, the sudo prompt and the
   forced password change dialog. Colours are tokens only, so every piece works
   in both themes.
   ========================================================================== */

/* The entity access table: dense controls, one row per entity. */
.kp-membership-table {
  table-layout: fixed;
  min-width: 980px;
}

/* Names get the room (the entity and the manager show their text in full on a
   laptop); the SAP code is three or four digits; territories take what is left
   (several chips wrap there); the switch and the bin are short. */
.kp-membership-table > thead > tr > th:nth-child(1) { width: 25%; }
.kp-membership-table > thead > tr > th:nth-child(2) { width: 15%; }
.kp-membership-table > thead > tr > th:nth-child(3) { width: 21%; }
.kp-membership-table > thead > tr > th:nth-child(4) { width: 13%; }

/* The long heading over the short SAP code box wraps instead of being cut. */
.kp-membership-table > thead > tr > th {
  white-space: normal;
  vertical-align: bottom;
}
.kp-membership-table > thead > tr > th:nth-child(6) { width: 70px; }
.kp-membership-table > thead > tr > th:nth-child(7) { width: 44px; }

.kp-membership-table > tbody > tr > td {
  vertical-align: top;
}

.kp-membership-table .form-control {
  width: 100%;
  min-width: 0;
  font-size: var(--kp-fs-body);
}

.kp-membership-table .kp-field-hint {
  margin-top: 2px;
}

.kp-membership-locked {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--tblr-secondary);
}

.kp-membership-note-row > td {
  padding-top: 0;
  border-top: 0;
  font-size: var(--kp-fs-small);
}

/* Users list: the name cell carries the username under it. */
.kp-person-name {
  display: block;
  font-weight: 600;
  color: var(--tblr-body-color);
}

.kp-person-username {
  display: block;
  font-size: var(--kp-fs-small);
  color: var(--tblr-secondary);
}

/* A small, non interactive chip: entity codes on a user row or a role. */
.kp-chip-static {
  display: inline-block;
  margin: 0 4px 2px 0;
  padding: 1px 8px;
  border: 1px solid var(--tblr-border-color);
  border-radius: var(--kp-radius-pill, 999px);
  background: var(--tblr-bg-surface-secondary);
  font-size: var(--kp-fs-small);
  color: var(--tblr-secondary);
}

/* The people drawer is wide, so its table scrolls on its own. */
/* Chips never break across lines; the people table keeps names and roles on
   one line and lets the drawer scroll sideways on a narrow screen. */
.kp-chip-static { white-space: nowrap; }
.kp-people-table > tbody > tr > td { white-space: nowrap; vertical-align: middle; }
.kp-people-table .kp-chip-static { margin-left: 6px; }

.kp-people-drawer .kp-table-wrap {
  overflow-x: auto;
}

/* One-time password dialog: the value sits beside its Copy button. */
.kp-password-dialog {
  width: min(520px, calc(100vw - 32px));
}

.kp-password-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.kp-password-row .form-control {
  flex: 1 1 auto;
}

/* Sudo prompt (SECURITY.md section 4): a plain confirm box with one field. */
.kp-sudo .kp-field {
  margin-bottom: 14px;
}

/* Forced password change: above the shell, below the connection banner, with
   no way out but setting a password or signing out. */
.kp-force-password-backdrop {
  position: fixed;
  inset: 0;
  z-index: 19000;
  background: rgba(15, 23, 42, .45);
}

[data-bs-theme="dark"] .kp-force-password-backdrop {
  background: rgba(2, 6, 23, .65);
}

.kp-force-password {
  z-index: 19001;
  width: min(460px, calc(100vw - 32px));
}

.kp-password-rules {
  margin: 4px 0 16px;
  padding: 0;
  list-style: none;
  font-size: var(--kp-fs-small);
  color: var(--tblr-secondary);
}

.kp-password-rules li {
  display: flex;
  align-items: center;
  gap: 6px;
}

/* What the server also refuses, under the checklist. The checklist gives up
   its bottom margin to it. */
.kp-password-rules:has(+ .kp-password-note) {
  margin-bottom: 4px;
}

.kp-password-note {
  margin: 0 0 16px;
}

.kp-password-rules li.is-met {
  color: var(--tblr-success);
}

/* ==========================================================================
   15. SAP sync (DESIGN.md section 4, "Action vocabulary" and the From SAP chip)
   ========================================================================== */

/* --- The "From SAP" chip, next to a record title ------------------------- */

.kp-from-sap {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-left: 8px;
  padding: 1px 8px;
  border: 1px solid var(--kp-status-info-bg);
  border-radius: var(--kp-radius-pill, 999px);
  background: var(--kp-status-info-bg);
  color: var(--kp-status-info-fg);
  font-size: var(--kp-fs-small);
  font-weight: 600;
  letter-spacing: 0.01em;
  vertical-align: middle;
  white-space: nowrap;
}

.kp-from-sap .ti {
  font-size: 13px;
}

/* A field SAP owns is readable but not editable: every sync overwrites it. */
.form-control.kp-sap-locked,
.form-select.kp-sap-locked {
  background: var(--tblr-bg-surface-secondary);
  color: var(--tblr-secondary);
  cursor: not-allowed;
}

.kp-sap-hint {
  color: var(--tblr-secondary);
}

/* --- The sync drawer ----------------------------------------------------- */

.kp-sap-sync .kp-sap-connection {
  margin-bottom: 4px;
}

.kp-sap-sync .kp-status-pill .kp-loader-inline {
  margin-right: 4px;
  vertical-align: -1px;
}

.kp-sap-live {
  margin-left: 8px;
  color: var(--tblr-secondary);
  font-size: var(--kp-fs-small);
  font-variant-numeric: tabular-nums;
}

.kp-sap-actions {
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.kp-sap-actions .kp-field-hint {
  margin: 0;
}

/* The confirmation on a full sync: the quiet sibling of .kp-form-error. */
.kp-form-warning {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 8px 10px;
  border: 1px solid var(--kp-status-warning-bg);
  border-radius: var(--kp-radius, 8px);
  background: var(--kp-status-warning-bg);
  color: var(--kp-status-warning-fg);
  font-size: var(--kp-fs-small);
}

.kp-sap-error {
  display: inline-block;
  max-width: 460px;
  color: var(--kp-status-danger-fg);
  font-size: var(--kp-fs-small);
  overflow-wrap: anywhere;
}

.kp-sap-datasets > tbody > tr > td,
.kp-sap-runs > tbody > tr > td {
  vertical-align: middle;
}

.kp-sap-run-row {
  cursor: pointer;
}

.kp-sap-run-detail > td {
  background: var(--tblr-bg-surface-secondary);
}

.kp-sap-run-breakdown {
  margin: 0;
  font-size: var(--kp-fs-small);
}

.kp-sap-run-breakdown th {
  text-transform: none;  /* Tabler capitalises these; labels here are sentence case */
  letter-spacing: normal;
  font-size: var(--kp-fs-small);
  color: var(--tblr-secondary);
}

.kp-sap-sync .kp-table-wrap {
  overflow-x: auto;
}

/* ==========================================================================
   16. Leads (DESIGN.md section 2)

   The lead list, the lead form and the lead record page. Everything here is
   either a lead specific class or a small shared piece the lead pages were the
   first to need (the rating chip, the bulk selection bar, the duplicate warning
   card, the territories drawer). Token colours only, so both themes follow.
   ========================================================================== */

/* Contact rows on the lead form: every column gets a share of the width, so a
   phone number or a last name is never squeezed into a few characters. The
   email takes what is left, and the last column holds Edit and Remove. */
.kp-lead-contacts { table-layout: fixed; min-width: 1020px; }
.kp-lead-contacts > thead > tr > th:nth-child(1) { width: 72px; }
.kp-lead-contacts > thead > tr > th:nth-child(2) { width: 120px; }
.kp-lead-contacts > thead > tr > th:nth-child(3),
.kp-lead-contacts > thead > tr > th:nth-child(4) { width: 12%; }
.kp-lead-contacts > thead > tr > th:nth-child(5) { width: 16%; }
.kp-lead-contacts > thead > tr > th:nth-child(6) { width: 164px; }
/* `.kp-list-scroller .table th.kp-col-menu` pins the last column to 44px,
   which holds one icon; the class here outweighs it. */
.kp-lead-contacts > thead > tr > th.kp-col-menu:last-child { width: 84px; min-width: 84px; }
/* The contacts on the lead read as text (the name with its title across the
   three name columns); a click on the row does nothing, and a long email wraps
   instead of pushing the table wider. */
.kp-lead-contacts > tbody > tr > td { overflow-wrap: anywhere; }
.kp-lead-contacts > tbody > tr:hover > td { cursor: default; }
.kp-lead-contacts .kp-contact-name { margin-right: 6px; font-weight: 600; }
.kp-lead-contacts td.kp-col-menu { white-space: nowrap; }
.kp-lead-contacts .kp-contact-none > td { color: var(--tblr-secondary); }
/* The one row open as inputs and the strip under it (its message, then Add or
   Save and Cancel) read as one block. The strip stays in view while the table
   is scrolled sideways on a narrow screen. */
.kp-lead-contacts > tbody > tr.kp-contact-edit > td {
  border-bottom: 0;
  background: var(--tblr-bg-surface-secondary);
}
.kp-lead-contacts > tbody > tr.kp-contact-edit-foot > td {
  padding-top: 0;
  background: var(--tblr-bg-surface-secondary);
}
.kp-contact-edit-bar {
  position: sticky;
  left: 10px;
  display: inline-flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  max-width: min(560px, calc(100vw - 112px));
}
.kp-contact-edit-actions { display: flex; gap: 8px; }
/* `.kp-lines` pins its 3rd and 5th columns to a narrow right-aligned box for
   quantity and price; here those columns are last name and phone. */
.kp-lead-contacts td .form-control,
.kp-lead-contacts td .form-select,
.kp-lead-contacts td:nth-child(3) .form-control,
.kp-lead-contacts td:nth-child(5) .form-control {
  width: 100%;
  min-width: 0;
  text-align: left;
}


/* Product lines on the lead form: Product (kpProductLine, three sub group
   filters above the picker), Volume, Unit, Per. The shared positional
   `.kp-lines` rules are written for Product, Grade, Quantity, Unit; these set
   the columns again, repeating the shared ones' :not()s so they outrank them. */
.kp-lines.kp-lead-products:not(.kp-lead-contacts):not(.kp-dm-table) {
  min-width: 720px;
}

.kp-lines.kp-lead-products:not(.kp-lead-contacts):not(.kp-dm-table) > thead > tr > th:first-child {
  min-width: 420px;
}

.kp-lines.kp-lead-products:not(.kp-lead-contacts):not(.kp-dm-table) td:nth-child(2) .form-control {
  width: 110px;
  min-width: 0;
  /* The box sits at the right of its cell, under the right-aligned heading. */
  margin-left: auto;
  text-align: right;
}

/* The unit picker's control carries .form-control, which the shared rules
   narrow to a number box in the third column. */
.kp-lines.kp-lead-products:not(.kp-lead-contacts):not(.kp-dm-table) td:nth-child(3) .form-control {
  width: auto;
  text-align: left;
}

.kp-lines.kp-lead-products:not(.kp-lead-contacts):not(.kp-dm-table) td:nth-child(3) .kp-picker,
.kp-lines.kp-lead-products:not(.kp-lead-contacts):not(.kp-dm-table) td:nth-child(4) .kp-picker {
  min-width: 110px;
}


/* --- Addresses on the lead form ------------------------------------------
   One block per address rather than a cramped table row: a lead can carry
   several, each marked Billing or Shipping, the way SAP holds a business
   partner's addresses. */

.kp-addr-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.kp-addr-block {
  padding: 12px;
  border: 1px solid var(--tblr-border-color);
  border-radius: 8px;
  background: var(--tblr-bg-surface-secondary);
}

.kp-addr-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.kp-addr-remove {
  margin-left: auto;
}

/* The Billing / Shipping choice: two radios that read as one segmented
   control, so the type is visible without opening a select. */
.kp-addr-seg {
  display: inline-flex;
  overflow: hidden;
  border: 1px solid var(--kp-control-border);
  border-radius: 8px;
  background: var(--tblr-bg-surface);
}

.kp-addr-segopt {
  position: relative;
  margin: 0;
}

.kp-addr-segopt input {
  position: absolute;
  width: 0;
  height: 0;
  opacity: 0;
}

.kp-addr-segopt span {
  display: inline-flex;
  align-items: center;
  padding: 5px 14px;
  font-size: var(--kp-fs-small);
  font-weight: 600;
  color: var(--tblr-secondary);
  cursor: pointer;
}

.kp-addr-segopt + .kp-addr-segopt span {
  border-left: 1px solid var(--tblr-border-color);
}

.kp-addr-segopt input:checked + span {
  background: var(--kp-primary-soft);
  color: var(--tblr-primary);
}

.kp-addr-segopt input:focus-visible + span {
  outline: 2px solid var(--tblr-primary);
  outline-offset: -2px;
}

/* A saved address keeps its type: the choice is shown, not offered. */
.kp-addr-segopt input:disabled + span {
  cursor: not-allowed;
}

.kp-addr-segopt input:disabled:not(:checked) + span {
  opacity: 0.45;
}

.kp-addr-default {
  margin: 0;
}

/* --- Addresses on the record page ---------------------------------------- */

.kp-addr-group + .kp-addr-group {
  margin-top: 16px;
}

.kp-addr-group-title {
  margin: 0 0 8px;
  font-size: var(--kp-fs-small);
  font-weight: 600;
  color: var(--tblr-secondary);
}

.kp-addr-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
}

.kp-addr-card {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 10px 12px;
  border: 1px solid var(--tblr-border-color);
  border-radius: 8px;
  background: var(--tblr-bg-surface);
}

.kp-addr-card-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.kp-addr-name {
  font-size: var(--kp-fs-body);
  font-weight: 600;
}

/* Edit and Remove on one address card (the Addresses tab of a lead). */
.kp-addr-card-actions {
  display: inline-flex;
  gap: 2px;
  margin-left: auto;
}

/* The one address being added or corrected, above the cards. */
.kp-addr-editor,
.kp-addr-note {
  margin-bottom: 16px;
}

.kp-addr-chip {
  padding: 1px 8px;
  border-radius: 6px;
  background: var(--kp-status-neutral-bg);
  color: var(--kp-status-neutral-fg);
  font-size: var(--kp-fs-label);
  font-weight: 600;
}

.kp-addr-lines {
  display: flex;
  flex-direction: column;
  font-size: var(--kp-fs-small);
  line-height: 1.45;
}

.kp-addr-meta {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: var(--kp-fs-small);
  color: var(--tblr-secondary);
}


/* --- List ---------------------------------------------------------------- */

.kp-leads-card {
  overflow: hidden;
}

/* The scroller fills the card; section 12 gives the card its height. */
.kp-leads-wrap {
  height: 100%;
  border: 0;
}

.kp-table th.kp-col-rating,
.kp-table td.kp-col-rating {
  width: 84px;
  white-space: nowrap;
}

.kp-lead-row {
  cursor: pointer;
}

/* Two lines in one cell: the name, and the code or phone under it. */
.kp-cell-stack {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}

.kp-cell-sub {
  font-size: var(--kp-fs-small);
  color: var(--tblr-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* --- Rating chip --------------------------------------------------------- */

.kp-rating-chip {
  display: inline-flex;
  align-items: center;
  padding: 1px 8px;
  border-radius: 6px;
  font-size: var(--kp-fs-label);
  font-weight: 600;
  letter-spacing: 0.02em;
  background: var(--kp-status-neutral-bg);
  color: var(--kp-status-neutral-fg);
}

.kp-rating-hot {
  background: var(--kp-status-danger-bg);
  color: var(--kp-status-danger-fg);
}

.kp-rating-warm {
  background: var(--kp-status-warning-bg);
  color: var(--kp-status-warning-fg);
}

.kp-rating-cold {
  background: var(--kp-status-info-bg);
  color: var(--kp-status-info-fg);
}

/* --- Bulk selection bar -------------------------------------------------- */

.kp-page-fill > .kp-bulkbar {
  flex: 0 0 auto;
}

.kp-bulkbar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  padding: 6px 12px;
  border: 1px solid var(--tblr-border-color);
  border-radius: 8px;
  background: var(--kp-primary-soft);
}

.kp-bulkbar-count {
  font-size: var(--kp-fs-body);
  font-weight: 600;
}

/* --- Form ---------------------------------------------------------------- */

.kp-lead-editor {
  padding-bottom: 0;
}

/* The footer stays in view on a long form (DESIGN.md section 2, "Forms"). */
.kp-lead-editor > .kp-form-footer {
  position: sticky;
  bottom: 0;
  z-index: 3;
  margin-top: 12px;
  padding: 10px 12px;
  border: 1px solid var(--tblr-border-color);
  border-radius: 8px;
  background: var(--tblr-bg-surface);
}

/* --- Duplicate warning --------------------------------------------------- */

.kp-dup-card {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 12px;
  padding: 10px 12px;
  border: 1px solid var(--tblr-border-color);
  border-left: 3px solid var(--tblr-warning);
  border-radius: 8px;
  background: var(--kp-status-warning-bg);
  color: var(--tblr-body-color);
}

.kp-dup-title {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: var(--kp-fs-small);
  font-weight: 700;
  color: var(--kp-status-warning-fg);
}

.kp-dup-list {
  margin: 0;
  padding-left: 18px;
  font-size: var(--kp-fs-small);
}

.kp-dup-list li {
  margin: 2px 0;
}

.kp-dup-meta,
.kp-dup-note {
  font-size: var(--kp-fs-small);
  color: var(--tblr-secondary);
}

/* --- Record page --------------------------------------------------------- */

.kp-ident-name {
  font-size: var(--kp-fs-body);
  font-weight: 600;
}

.kp-address {
  margin: 0;
  font-size: var(--kp-fs-small);
  line-height: 1.45;
}

/* The chip in the record header that links to the opportunity a lead became. */
.kp-link-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border: 1px solid var(--tblr-border-color);
  border-radius: 6px;
  background: var(--tblr-bg-surface-secondary);
  color: var(--tblr-primary);
  font-size: var(--kp-fs-small);
  font-weight: 600;
}

.kp-link-chip:hover {
  border-color: var(--tblr-primary);
}

/* --- Territories drawer -------------------------------------------------- */

.kp-territories .kp-table-wrap {
  overflow-x: auto;
}

.kp-territories .form-select {
  min-width: 200px;
}

/* ==========================================================================
   17. My account (/me)

   A header band (the toolbar band of section 6b, taller) with the photo, the
   name and one chip per entity in that entity's colour; pill tabs; then each
   section as a two column grid of cards that stacks below 992px.
   ========================================================================== */

.kp-toolbar.kp-me-hero {
  align-items: center;
  gap: 18px;
  padding-top: 18px;
  padding-bottom: 18px;
}

.kp-me-hero-photo {
  position: relative;
  flex: 0 0 auto;
}

.kp-me-hero-avatar {
  display: block;
  width: 88px;
  height: 88px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--tblr-bg-surface-secondary);
  border: 3px solid var(--tblr-bg-surface);
  box-shadow: 0 0 0 1px var(--tblr-border-color), var(--kp-card-shadow);
}

/* The camera button sits on the photo's lower right edge. */
.kp-me-hero-camera {
  position: absolute;
  right: -2px;
  bottom: -2px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  padding: 0;
  border: 2px solid var(--tblr-bg-surface);
  border-radius: 50%;
  background: var(--tblr-primary);
  color: #FFFFFF;
  font-size: 15px;
  cursor: pointer;
}

.kp-me-hero-camera:hover {
  filter: brightness(1.1);
}

.kp-me-hero-camera:focus-visible {
  outline: 2px solid var(--tblr-primary);
  outline-offset: 2px;
}

.kp-me-hero-text .kp-toolbar-heading {
  font-size: var(--kp-fs-display);
}

.kp-me-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

/* An entity chip: its colour as a dot and a faint fill, the code, the role. */
.kp-me-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 26px;
  padding: 0 10px;
  border-radius: var(--kp-radius-pill);
  border: 1px solid color-mix(in srgb, var(--kp-chip) 30%, var(--tblr-border-color));
  background: color-mix(in srgb, var(--kp-chip) 8%, var(--tblr-bg-surface));
  font-size: var(--kp-fs-small);
  color: var(--tblr-body-color);
}

.kp-me-chip strong {
  font-weight: 700;
}

.kp-me-chip span:last-child {
  color: var(--tblr-secondary);
}

.kp-me-chip-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--kp-chip);
}

.kp-me-chip.is-current {
  border-color: var(--kp-chip);
  box-shadow: 0 0 0 1px var(--kp-chip);
}

.kp-me-hero-side {
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
}

.kp-me-since {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: var(--kp-fs-small);
  color: var(--tblr-secondary);
}

.kp-me-crop-card {
  margin-bottom: 16px;
}

.kp-me-crop-card .kp-card-head {
  align-items: baseline;
  gap: 10px;
}

.kp-me-crop-card .kp-me-photo-actions {
  justify-content: flex-start;
  margin-top: 12px;
}

.kp-me {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* Pill tabs. */
/* One row always: on a narrow screen the strip scrolls sideways rather than
   wrapping inside its pill. */
.kp-me-tabs {
  display: inline-flex;
  flex-wrap: nowrap;
  max-width: 100%;
  overflow-x: auto;
  scrollbar-width: none;
  align-self: flex-start;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--tblr-border-color);
  border-radius: var(--kp-radius-pill);
  background: var(--tblr-bg-surface);
}

.kp-me-tabs::-webkit-scrollbar {
  display: none;
}

.kp-me-tab {
  flex: 0 0 auto;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 32px;
  padding: 0 14px;
  border: 0;
  border-radius: var(--kp-radius-pill);
  background: transparent;
  color: var(--tblr-secondary);
  font-size: var(--kp-fs-body);
  font-weight: 500;
}

.kp-me-tab:hover {
  color: var(--tblr-body-color);
  background: var(--tblr-bg-surface-secondary);
}

.kp-me-tab.active {
  background: var(--kp-primary-soft);
  color: var(--tblr-primary);
  font-weight: 600;
}

.kp-me-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.kp-me-grid > .card {
  margin: 0;
}

/* Preferences: a short card (Appearance) above a tall one (Notifications).
   Side by side they left half the page empty, so they stack in one column
   across the page. */
.kp-me-grid.kp-me-grid-stack {
  grid-template-columns: minmax(0, 1fr);
}

/* A card that runs under the two halves (Security: Recent activity). */
.kp-me-grid > .kp-me-grid-wide {
  grid-column: 1 / -1;
}

/* Details: the fields take the room, the read-only facts a narrow column. */
.kp-me-grid.kp-me-grid-side {
  grid-template-columns: minmax(0, 1fr) 360px;
}

@media (min-width: 1200px) {
  .kp-me-grid-side .kp-me-form {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 991.98px) {
  .kp-toolbar.kp-me-hero {
    flex-wrap: wrap;
  }

  .kp-me-hero-side {
    align-items: flex-start;
    flex: 1 1 100%;
    flex-direction: row;
  }

  .kp-me-grid,
  .kp-me-grid.kp-me-grid-side {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* One column of fields, for the narrow half of a grid. */
.kp-me-stack {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.kp-me-form {
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
}

/* Entities and roles: a card per entity, bordered on top in its colour. */
.kp-me-entities {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 16px;
}

.kp-me-entity {
  margin: 0;
  border-top: 3px solid var(--kp-accent);
}

.kp-me-entity.is-current {
  box-shadow: 0 0 0 1px var(--kp-accent), var(--kp-card-shadow);
}

.kp-me-entity-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

.kp-me-entity-name {
  display: flex;
  flex-direction: column;
  min-width: 0;
  flex: 1 1 auto;
}

.kp-me-entity-name strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.kp-me-entity-name span {
  font-size: var(--kp-fs-small);
  color: var(--tblr-secondary);
}

/* Recent activity as a timeline: a rule down the left, a dot per event. */
/* Up to 25 events: about six show, the rest scroll inside the card. */
.kp-me-timeline-scroll {
  max-height: 340px;
  overflow-y: auto;
  padding-right: 6px;
}

.kp-me-timeline {
  position: relative;
  list-style: none;
  margin: 10px 0 0;
  padding: 0 0 0 20px;
}

.kp-me-timeline::before {
  content: '';
  position: absolute;
  left: 5px;
  top: 6px;
  bottom: 6px;
  width: 2px;
  background: var(--tblr-border-color);
}

.kp-me-event {
  position: relative;
  padding: 0 0 12px;
}

.kp-me-event:last-child {
  padding-bottom: 0;
}

.kp-me-event-dot {
  position: absolute;
  left: -20px;
  top: 4px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--tblr-bg-surface);
  border: 2px solid var(--tblr-primary);
}

.kp-me-event.is-failed .kp-me-event-dot {
  border-color: var(--tblr-danger);
  background: var(--tblr-danger);
}

.kp-me-event-body {
  display: flex;
  flex-direction: column;
}

.kp-me-event-title {
  font-size: var(--kp-fs-body);
  font-weight: 600;
}

.kp-me-event.is-failed .kp-me-event-title {
  color: var(--tblr-danger);
}

.kp-me-event-meta {
  font-size: var(--kp-fs-small);
  color: var(--tblr-secondary);
}

/* The crop area is bounded: cropper sizes itself to the image otherwise. */
.kp-me-crop {
  width: 100%;
  max-width: 240px;
  max-height: 240px;
  overflow: hidden;
}

.kp-me-crop img {
  display: block;
  max-width: 100%;
}

.kp-me-photo-actions,
.kp-me-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
}

.kp-me-actions {
  justify-content: flex-start;
}

/* A block below a form: the read-only facts, the recent activity table. It is
   a container, not a heading, so it must not take `kp-form-section`'s type. */
.kp-me-block {
  padding-top: 12px;
  border-top: 1px solid var(--tblr-border-color);
}

/* Sessions: one line each, the current one chipped. */
.kp-me-sessions {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.kp-me-session {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: var(--kp-fs-body);
}

.kp-me-session i {
  color: var(--tblr-secondary);
}

.kp-me-session-when {
  min-width: 0;
}

/* Appearance: two radios on one row, stacked on a phone. */
.kp-me-radios {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 24px;
}

.kp-me-radio {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: var(--kp-fs-body);
  margin: 0;
}

/* ==========================================================================
   18. Picker (`kpPicker`)

   One control for every long list: accounts, products, people, countries and
   the masters that outgrew a native select (DESIGN.md section 2, "Pickers").

   The closed field is a `form-control`, so it lines up with every other input
   in a form grid. The menu is absolutely positioned inside the field wrapper
   rather than appended to the body, which is what makes it work unchanged
   inside the drawer (section 11) and inside a confirm dialog: it inherits
   their stacking context, and the z-index below only has to beat the field's
   own siblings.
   ========================================================================== */

.kp-picker {
  position: relative;
  /* A grid cell and a table cell both need this, or a long label makes the
     whole column wider instead of truncating. */
  min-width: 0;
}

.kp-picker-control {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
  min-height: 36px;
  padding: 4px 8px;
  cursor: text;
}

.kp-picker-open > .kp-picker-control {
  border-color: var(--tblr-primary);
  box-shadow: 0 0 0 .25rem rgba(var(--tblr-primary-rgb), .15);
}

/* The multiple variant wraps its chips, so it grows down rather than sideways. */
.kp-picker-multi > .kp-picker-control {
  align-items: flex-start;
  padding-top: 6px;
  padding-bottom: 6px;
}

.kp-picker-disabled > .kp-picker-control {
  background: var(--tblr-bg-surface-secondary);
  cursor: not-allowed;
  opacity: .7;
}

.kp-picker-single {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.kp-picker-search {
  flex: 1 1 80px;
  min-width: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  outline: none;
}

.kp-picker-search:disabled {
  cursor: not-allowed;
}

/* The control carries the one focus ring; the global :focus-visible ring on
   the search box inside it drew a second, smaller box. */
.kp-picker-search:focus-visible {
  box-shadow: none;
}

.kp-picker-control:focus-within {
  border-color: var(--tblr-primary);
  box-shadow: 0 0 0 .25rem rgba(var(--tblr-primary-rgb), .15);
}

/* Chips, for the multiple variant. */
.kp-picker-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  max-width: 100%;
  padding: 0 4px 0 8px;
  border: 1px solid var(--tblr-border-color);
  border-radius: var(--kp-radius-sm);
  background: var(--tblr-bg-surface-secondary);
  font-size: var(--kp-fs-small);
  line-height: 20px;
}

.kp-picker-chip-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.kp-picker-chip-x,
.kp-picker-clear,
.kp-picker-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--tblr-secondary);
  line-height: 1;
}

.kp-picker-chip-x {
  width: 16px;
  height: 16px;
  font-size: var(--kp-fs-small);
}

.kp-picker-clear,
.kp-picker-toggle {
  width: 20px;
  height: 20px;
  margin-left: auto;
  font-size: 14px;
}

.kp-picker-clear + .kp-picker-toggle {
  margin-left: 0;
}

.kp-picker-chip-x:hover,
.kp-picker-clear:hover,
.kp-picker-toggle:hover {
  color: var(--tblr-body-color);
}

.kp-picker-toggle i {
  transition: transform var(--kp-transition, 150ms ease-out);
}

.kp-picker-open .kp-picker-toggle i {
  transform: rotate(180deg);
}

/* The menu. 1060 clears the drawer (1046) and the confirm dialog (1056) even
   where an ancestor has not made a stacking context of its own. */
.kp-picker-menu {
  position: absolute;
  z-index: 1060;
  left: 0;
  right: 0;
  max-height: 280px;
  overflow-y: auto;
  margin-top: 2px;
  padding: 4px;
  border: 1px solid var(--tblr-border-color);
  border-radius: var(--kp-radius);
  background: var(--tblr-bg-surface);
  box-shadow: var(--kp-shadow-float, 0 8px 24px rgba(15, 23, 42, .12));
}

.kp-picker-option {
  display: flex;
  align-items: flex-start;
  flex-wrap: wrap;
  column-gap: 8px;
  row-gap: 1px;
  padding: 6px 8px;
  border-radius: var(--kp-radius-sm);
  color: var(--tblr-body-color);
  font-size: var(--kp-fs-body);
  cursor: pointer;
}

/* The whole name, wrapping to a second line, with the code under it: product
   names here are long and differ only at the end, so a cut-off name could not
   be told from its neighbour. */
.kp-picker-option-label {
  flex: 1 1 100%;
  min-width: 0;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  line-height: 1.35;
  word-break: break-word;
}

.kp-picker-option-meta {
  flex: 1 1 auto;
  color: var(--tblr-secondary);
  font-size: var(--kp-fs-label);
  white-space: nowrap;
}

.kp-picker-tick {
  margin-left: 4px;
  color: var(--tblr-primary);
}

.kp-picker-option-meta + .kp-picker-tick {
  margin-left: 0;
}

.kp-picker-option:hover,
.kp-picker-active {
  background: var(--tblr-bg-surface-secondary);
}

.kp-picker-chosen .kp-picker-option-label {
  font-weight: 500;
}

/* The three states of the menu: loading, empty and failed. */
.kp-picker-state {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 8px;
  color: var(--tblr-secondary);
  font-size: var(--kp-fs-small);
}

.kp-picker-empty {
  justify-content: center;
}

.kp-picker-error {
  color: var(--kp-danger-text);
}

.kp-picker-sentinel {
  min-height: 1px;
}

/* --- Date field (kpDateField) -------------------------------------------- */

/* One box that shows and takes the day first ("03 Oct 2026"), with a clear
   button while an optional field holds a day and a calendar button at the
   end. The small size (filters) has room for one: the clear button while
   there is a value, the calendar otherwise. The calendar is fixed to the
   window like a picker's menu (kpDateField.js, `place`). The selectors carry
   the input's own two classes so a table's or a chip's `.form-control`
   padding does not run the text under the buttons. */
.kp-datefield {
  position: relative;
  min-width: 0;
}

.kp-datefield > .form-control.kp-date-input {
  padding-right: 34px;
  font-variant-numeric: tabular-nums;
}

.kp-datefield.kp-datefield-has-clear:not(.kp-datefield-sm) > .form-control.kp-date-input {
  padding-right: 56px;
}

.kp-datefield-sm > .form-control.kp-date-input {
  padding-right: 26px;
}

.kp-datefield-open > .form-control.kp-date-input {
  border-color: var(--tblr-primary);
  box-shadow: 0 0 0 .25rem rgba(var(--tblr-primary-rgb), .15);
}

/* Typed text that is not a day, or a day outside the field's limits; the
   reason is the box's tooltip. */
.kp-datefield > .form-control.kp-date-input.kp-date-bad {
  border-color: var(--tblr-danger);
  box-shadow: 0 0 0 2px rgba(var(--tblr-danger-rgb), .2);
}

.kp-datefield-btn {
  position: absolute;
  top: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  padding: 0;
  border: 0;
  border-radius: var(--kp-radius-sm);
  background: transparent;
  color: var(--tblr-secondary);
  font-size: 14px;
  line-height: 1;
  transform: translateY(-50%);
}

.kp-datefield-toggle {
  right: 7px;
}

.kp-datefield-clear {
  right: 31px;
}

.kp-datefield-sm .kp-datefield-btn {
  right: 3px;
  width: 20px;
  height: 20px;
  font-size: 13px;
}

.kp-datefield-btn:hover {
  color: var(--tblr-body-color);
}

.kp-datefield-btn:disabled {
  opacity: .5;
  cursor: not-allowed;
}

.kp-datefield-pop {
  position: fixed;
  z-index: 1060;
  width: 272px;
  max-width: calc(100vw - 16px);
  padding: 8px;
  border: 1px solid var(--tblr-border-color);
  border-radius: var(--kp-radius);
  background: var(--tblr-bg-surface);
  box-shadow: var(--kp-shadow-float, 0 8px 24px rgba(15, 23, 42, .12));
  color: var(--tblr-body-color);
  font-size: var(--kp-fs-body);
}

.kp-cal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
  margin-bottom: 4px;
}

.kp-cal-title {
  font-weight: 600;
}

.kp-cal-nav {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  padding: 0;
  border: 0;
  border-radius: var(--kp-radius-sm);
  background: transparent;
  color: var(--tblr-secondary);
  font-size: 16px;
}

.kp-cal-nav:hover {
  background: var(--tblr-bg-surface-secondary);
  color: var(--tblr-body-color);
}

.kp-cal-grid {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

.kp-cal-grid th {
  padding: 4px 0;
  color: var(--tblr-secondary);
  font-size: var(--kp-fs-label);
  font-weight: 600;
  text-align: center;
}

.kp-cal-grid td {
  padding: 1px;
  text-align: center;
}

.kp-cal-day {
  width: 100%;
  height: 32px;
  padding: 0;
  border: 0;
  border-radius: var(--kp-radius-sm);
  background: transparent;
  color: var(--tblr-body-color);
  font-size: var(--kp-fs-body);
  font-variant-numeric: tabular-nums;
}

.kp-cal-day:hover {
  background: var(--tblr-bg-surface-secondary);
}

.kp-cal-day.is-other {
  color: var(--tblr-secondary);
}

.kp-cal-day.is-today {
  box-shadow: inset 0 0 0 1px var(--tblr-primary);
  color: var(--tblr-primary);
  font-weight: 600;
}

.kp-cal-day.is-selected,
.kp-cal-day.is-selected:hover {
  background: var(--tblr-primary);
  color: var(--tblr-primary-fg);
  font-weight: 600;
}

.kp-cal-day.is-off,
.kp-cal-day.is-off:hover {
  background: transparent;
  color: var(--tblr-secondary);
  opacity: .4;
  cursor: not-allowed;
}

.kp-cal-day:focus-visible,
.kp-cal-nav:focus-visible,
.kp-cal-link:focus-visible {
  outline: none;
  box-shadow: var(--kp-focus-ring);
}

.kp-cal-foot {
  display: flex;
  justify-content: flex-end;
  margin-top: 4px;
  padding-top: 4px;
  border-top: 1px solid var(--tblr-border-color);
}

.kp-cal-link {
  padding: 4px 8px;
  border: 0;
  border-radius: var(--kp-radius-sm);
  background: transparent;
  color: var(--tblr-primary);
  font-size: var(--kp-fs-small);
  font-weight: 500;
}

.kp-cal-link:hover {
  background: var(--tblr-bg-surface-secondary);
}

.kp-cal-link:disabled {
  color: var(--tblr-secondary);
  background: transparent;
  cursor: not-allowed;
}

/* Two date fields side by side (the date chip's custom range, a report's
   period) share the row. */
.kp-datechip-custom-row > .kp-datefield,
.kp-rep-row > .kp-datefield {
  flex: 1 1 0;
  min-width: 0;
}

/* The calendar takes the focus on a phone after a day is picked in a date
   and time field, so the keyboard goes down; it shows no ring for that. */
.kp-datefield-pop:focus {
  outline: none;
}

/* A date and time field (`time=true`): the hour, minute and AM/PM row under
   the month, and a foot with Now and Done. */
.kp-cal-time {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 6px;
  padding-top: 8px;
  border-top: 1px solid var(--tblr-border-color);
}

.kp-cal-time > .ti {
  flex: 0 0 auto;
  color: var(--tblr-secondary);
  font-size: 16px;
}

.kp-cal-time > .form-select {
  flex: 1 1 0;
  width: auto;
  min-width: 0;
  min-height: 32px;
  padding: 4px 26px 4px 8px;
  background-position: right 6px center;
  font-size: var(--kp-fs-body);
  font-variant-numeric: tabular-nums;
}

.kp-cal-colon {
  color: var(--tblr-secondary);
  font-weight: 600;
}

.kp-cal-ampm {
  display: inline-flex;
  flex: 0 0 auto;
  overflow: hidden;
  border: 1px solid var(--tblr-border-color);
  border-radius: var(--kp-radius-sm);
}

.kp-cal-half {
  min-width: 38px;
  min-height: 30px;
  padding: 0 8px;
  border: 0;
  background: transparent;
  color: var(--tblr-secondary);
  font-size: var(--kp-fs-small);
  font-weight: 600;
}

.kp-cal-half + .kp-cal-half {
  border-left: 1px solid var(--tblr-border-color);
}

.kp-cal-half:hover {
  background: var(--tblr-bg-surface-secondary);
  color: var(--tblr-body-color);
}

.kp-cal-half.is-active,
.kp-cal-half.is-active:hover {
  background: var(--tblr-primary);
  color: var(--tblr-primary-fg);
}

.kp-cal-half:focus-visible {
  position: relative;
  outline: none;
  box-shadow: var(--kp-focus-ring);
}

.kp-cal-foot.kp-cal-foot-time {
  align-items: center;
  justify-content: space-between;
  margin-top: 8px;
  padding-top: 8px;
}

/* A phone or tablet: every target in the calendar is finger-sized. */
@media (pointer: coarse) {
  .kp-cal-day {
    height: 40px;
  }

  .kp-cal-nav {
    width: 40px;
    height: 40px;
  }

  .kp-cal-link {
    min-height: 40px;
    padding: 8px 12px;
  }

  .kp-cal-time > .form-select,
  .kp-cal-half,
  .kp-cal-done {
    min-height: 44px;
  }

  .kp-cal-half {
    min-width: 48px;
  }

  .kp-cal-done {
    min-width: 88px;
  }
}

/* `size="lg"`: the 56px field of a phone-first page (the shop floor), and
   its calendar (`.kp-cal-lg`, 340px wide). */
.kp-datefield-lg > .form-control.kp-date-input {
  min-height: 56px;
  padding-right: 52px;
  font-size: var(--kp-fs-card);
}

.kp-datefield.kp-datefield-lg.kp-datefield-has-clear > .form-control.kp-date-input {
  padding-right: 98px;
}

.kp-datefield-lg .kp-datefield-btn {
  width: 44px;
  height: 44px;
  font-size: 20px;
}

.kp-datefield-lg .kp-datefield-toggle {
  right: 6px;
}

.kp-datefield-lg .kp-datefield-clear {
  right: 50px;
}

.kp-cal-lg .kp-cal-day {
  height: 44px;
  font-size: var(--kp-fs-card);
}

.kp-cal-lg .kp-cal-nav {
  width: 48px;
  height: 48px;
  font-size: 20px;
}

.kp-cal-lg .kp-cal-time > .form-select,
.kp-cal-lg .kp-cal-half,
.kp-cal-lg .kp-cal-done,
.kp-cal-lg .kp-cal-link {
  min-height: 56px;
  font-size: var(--kp-fs-card);
}

.kp-cal-lg .kp-cal-half {
  min-width: 56px;
}

.kp-cal-lg .kp-cal-done {
  min-width: 112px;
}

/* Inside a table row the field has no room for a wide menu, so it takes the
   width of the cell and the rows truncate rather than wrap. */

/* ==========================================================================
   19. Workspace tabs, entity field, board
   ========================================================================== */

/* --- The entity a tab remembers ------------------------------------------ */

/* Each tab carries the entity it was opened in as a 3px edge in that entity's
   colour. Home has no entity of its own (it always follows the current one), so
   its custom property is empty and the fallback keeps the edge invisible. */
.kp-tab {
  border-left: 3px solid var(--kp-tab-entity, transparent);
  border-top-left-radius: 3px;
  border-bottom-left-radius: 3px;
}

/* The short code after the title, for a person who works in several entities.
   Small and quiet: it answers "which entity is this?" without competing with
   the tab's own name. */
.kp-tab-entity {
  flex: 0 0 auto;
  padding: 1px 4px;
  border-radius: 4px;
  background: var(--tblr-bg-surface-tertiary);
  color: var(--tblr-secondary);
  font-size: var(--kp-fs-label);
  font-weight: 700;
  letter-spacing: .02em;
  line-height: 1.45;
}

.kp-tab-active .kp-tab-entity {
  color: var(--tblr-body-color);
}

/* The badge beside a record's code, same tile as the sidebar switcher but one
   size down so it sits inside a toolbar row. */
.kp-entity-badge {
  min-width: 24px;
  height: 24px;
  padding: 0 5px;
  border-radius: 6px;
  font-size: var(--kp-fs-label);
}

/* --- The Entity field on a form ------------------------------------------ */

/* The field sits at the top of a form, above the first real input, so it needs a
   little more air under it than a field in a row. */
.kp-entity-field {
  margin-bottom: 14px;
}

/* Read-only by design: a record belongs to one entity and never moves. It reads
   as a value with a dot, not as a control, so nobody tries to type in it. */
.kp-entity-field-value {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  padding: 6px 10px;
  border: 1px solid var(--tblr-border-color);
  border-radius: var(--kp-radius-sm);
  background: var(--tblr-bg-surface-secondary);
}

.kp-entity-field-code {
  font-size: var(--kp-fs-small);
  font-weight: 700;
  letter-spacing: .02em;
}

.kp-entity-field-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--tblr-secondary);
  font-size: var(--kp-fs-body);
}

.kp-entity-field-switch {
  margin-left: auto;
  flex: 0 0 auto;
  font-size: var(--kp-fs-small);
}

/* --- The shared board ---------------------------------------------------- */

/* A board is the page, so it takes the height the list would have taken and
   scrolls inside itself rather than pushing the toolbar off the screen.
   `height: 100%` is deliberately NOT set: as a flex item it would then ask for
   the whole page and squeeze the toolbar above it, which pushed the toolbar's
   buttons down over the first row of columns. */
.kp-page-fill > .kp-board {
  flex: 1 1 auto;
  min-height: 0;
  overflow-x: auto;
  overflow-y: hidden;
  align-items: stretch;
}

/* The toolbar sits above the list or the board at its natural height. It wraps
   on a narrow screen, so it must never be shrunk to make room for what is
   below it. */
.kp-page-fill > .kp-toolbar {
  flex: 0 0 auto;
}

/* Two rows, not three: the title, the view switch and the page's buttons share
   the first row, and the filter chips take the row under them. Without this the
   filters pushed the buttons onto a third row of their own. */
.kp-toolbar > .kp-toolbar-actions {
  order: 2;
}

.kp-toolbar > .kp-toolbar-filters {
  order: 3;
  flex: 1 1 100%;
}

/* Columns share the width when they fit and scroll sideways when they do not,
   so five statuses fill a laptop screen instead of leaving a gap and a
   scrollbar. 220px is the width at which five columns fit a 1440px laptop
   and seven a 1920px screen. */
.kp-page-fill > .kp-board > .kp-board-col {
  flex: 1 1 220px;
  min-width: 220px;
  max-width: 520px;
}

/* Each column scrolls on its own, so a long column never scrolls the board. */
.kp-board-col-body {
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1 1 auto;
  min-height: 40px;
  overflow-y: auto;
  padding-right: 2px;
}

/* Cards are focusable, so the board can be walked with the keyboard: Tab moves
   between cards and Enter opens one. The ring has to be visible against both
   the card and the column behind it. */
.kp-board-card:focus-visible {
  outline: 2px solid var(--tblr-primary);
  outline-offset: 2px;
}

/* A column with nothing draggable must not offer a grab cursor. */
.kp-board-card[draggable="false"] {
  cursor: pointer;
}

/* --- A form that is a page, not a drawer --------------------------------- */

/* The record forms (lead, opportunity, sales order) are full pages inside their
   module's tab. They scroll as one column of cards with the footer in view, so
   Save is never a scroll away on a long form (DESIGN.md section 2, "Forms"). */
.kp-record-form {
  display: flex;
  flex-direction: column;
  padding-bottom: 0;
}

/* Density on a full page form (DESIGN.md section 2, "Forms").
   A form is read in one column of cards, so it stops short of the full width
   of a wide screen: a date field 1,300px wide is harder to use, not easier.
   The fields inside breathe more than they do in the 480px drawer. */
.kp-record-form > .card,
.kp-record-form > .kp-form-error,
.kp-record-form > .kp-lock-note,
.kp-record-form > .kp-entity-field,
.kp-record-form > .kp-form-footer {
  width: 100%;
  max-width: 1320px;
}

/* On a wide desktop screen the 1320px column left a blank strip of some 330px
   down the right. The form grows to 1600px there: the fields stay four to a
   row and get a little wider, which is still short of the full width. */
@media (min-width: 1800px) {
  .kp-record-form > .card,
  .kp-record-form > .kp-form-error,
  .kp-record-form > .kp-lock-note,
  .kp-record-form > .kp-entity-field,
  .kp-record-form > .kp-form-footer {
    max-width: 1600px;
  }
}

/* The permission table of the role form is a table, not a column of fields:
   it takes the full width, so the ticks of its last column stay on one line. */
.kp-record-form > .kp-role-matrix-card {
  max-width: none;
}

.kp-record-form > .card + .card {
  margin-top: 16px;
}

.kp-record-form .card-body,
.kp-lead-editor .card-body {
  padding: 20px 22px 22px;
}

.kp-record-form .kp-card-head,
.kp-lead-editor .kp-card-head {
  margin-bottom: 16px;
}

/* Two columns on a laptop, three or four on a wide screen, one on a phone:
   the fields decide, so no form has to declare a breakpoint of its own. */
.kp-record-form .kp-form-grid,
.kp-lead-editor .kp-form-grid,
.kp-record-form .kp-form-grid-2,
.kp-lead-editor .kp-form-grid-2 {
  /* auto-fill, not auto-fit: a card with only one or two fields keeps them at
     one column's width instead of stretching them across the card. */
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 260px), 1fr));
  gap: 18px 24px;
}

/* A field worth two columns (a company, account or record name, the entity,
   a linked record); on a narrow screen it takes the whole row. */
.kp-record-form .kp-field-span2,
.kp-lead-editor .kp-field-span2 {
  grid-column: span 2;
}

@media (max-width: 767.98px) {
  .kp-record-form .kp-field-span2,
  .kp-lead-editor .kp-field-span2 {
    grid-column: 1 / -1;
  }
}

.kp-field-span2 > .kp-entity-field {
  margin-bottom: 0;
}



/* A field that is not in a grid still must not stretch across the card,
   unless it is text to write (notes, remarks, terms) or a row of tick boxes,
   which read better across the card than squeezed into its left half. */
.kp-record-form .card-body > .kp-field,
.kp-lead-editor .card-body > .kp-field {
  max-width: 640px;
}

.kp-record-form .card-body > .kp-field:has(textarea, .kp-checkrow),
.kp-lead-editor .card-body > .kp-field:has(textarea, .kp-checkrow) {
  max-width: none;
}

/* Tabler gives a checkbox `--tblr-border-radius`, which our 8px token turns
   into a circle on a 16px box: every checkbox in the app looked like a radio,
   so a multi-choice field such as Product interest read as "pick one". Square
   corners for a checkbox, round for a radio, pill for a switch. */
.form-check-input[type="checkbox"]:not(.form-switch .form-check-input) {
  border-radius: 4px;
}

/* An empty box or radio button is drawn by its outline alone, so it takes the
   control border: on the hairline colour the unticked boxes of the role
   matrix could not be seen in dark. A ticked one keeps its fill. (A radio
   button with none of its group chosen is :indeterminate too.) */
.form-check-input:not(:checked):not([type="checkbox"]:indeterminate) {
  border-color: var(--kp-control-border);
}

/* An empty box of a field that holds a message (Product interest on the lead
   form) is outlined in red like any other refused control. Same weight as the
   rule above and after it, so it wins. */
.kp-field:has(> .kp-field-error) .form-check-input:not(:checked) {
  border-color: var(--tblr-danger);
}

/* Vertical rhythm inside a card: every block after the first is pushed off the
   one above it, whichever kind it is. Without this a grid followed by a loose
   field (Terms, then Regulatory compliance) read as one squashed block. */
.kp-record-form .card-body > * + *,
.kp-lead-editor .card-body > * + * {
  margin-top: 18px;
}

/* The two column grid some cards use keeps the same gaps as the shared one. */
.kp-record-form .kp-form-grid-2,
.kp-lead-editor .kp-form-grid-2 {
  gap: 18px 24px;
}

.kp-record-form .kp-field,
.kp-lead-editor .kp-field {
  gap: 6px;
}

.kp-record-form .kp-field-hint,
.kp-lead-editor .kp-field-hint {
  margin-top: 2px;
}

.kp-record-form > .kp-form-footer {
  position: sticky;
  bottom: 0;
  z-index: 3;
  margin-top: 12px;
  padding: 10px 12px;
  border: 1px solid var(--tblr-border-color);
  border-radius: 8px;
  background: var(--tblr-bg-surface);
}

/* ==========================================================================
   20. Approvals
   ==========================================================================
   The approval engine's three surfaces (DESIGN.md section 2, "Approvals"):
   the queue at /approvals, the card a record page carries while it is waiting,
   and the rules editor at /approvals/rules.

   Everything here is built from the existing tokens, so dark mode needs no
   overrides of its own except where a tint is mixed by hand.
   -------------------------------------------------------------------------- */

/* --- The badge the sidebar draws next to Approvals ----------------------- */

/* A count, not a dot: "3" says how much work there is. It is only drawn when
   the count is above zero, so an empty badge never appears. */
.kp-nav-badge {
  flex: 0 0 auto;
  margin-left: auto;
  min-width: 18px;
  padding: 0 5px;
  border-radius: 9px;
  background: var(--tblr-primary);
  color: var(--tblr-primary-fg);
  font-size: var(--kp-fs-label);
  font-weight: 700;
  line-height: 18px;
  text-align: center;
}

/* In the 64px rail the label is hidden, so the badge would sit alone in the
   middle of the row; it is tucked into the icon's top right corner instead.
   The link is the positioning context for it. */
.kp-nav-link {
  position: relative;
}

@media (min-width: 992px) {
  .kp-shell-collapsed .kp-sidebar .kp-nav-badge {
    position: absolute;
    top: 3px;
    right: 8px;
    margin-left: 0;
    min-width: 16px;
    padding: 0 4px;
    font-size: var(--kp-fs-label);
    line-height: 16px;
  }
}

/* --- The queue at /approvals --------------------------------------------- */

.kp-approvalpage-card {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
}

.kp-approvalpage-wrap {
  flex: 0 1 auto;
  min-height: 0;
}

.kp-approvalpage-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

/* One request per row: the document, the rule, who asked, and the decision
   buttons on the right for the rows that are waiting on this person. */
.kp-approvalpage-row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--tblr-border-color);
  cursor: pointer;
}

.kp-approvalpage-row:last-child {
  border-bottom: 0;
}

.kp-approvalpage-row:hover,
.kp-approvalpage-row:focus-visible {
  background: var(--kp-sidebar-hover);
  outline: none;
}

/* A row that is not waiting on anybody carries the neutral tile. The base
   `.kp-notif-tile` is already neutral; this exists so the modifier the
   template writes is a real class rather than a silent no-op. */
.kp-notif-tile-info {
  background: var(--tblr-bg-surface-secondary);
  color: var(--tblr-secondary);
}

.kp-approvalpage-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  flex: 1 1 auto;
}

.kp-approval-doc {
  font-weight: 600;
  color: var(--tblr-body-color);
}

.kp-approval-rulename {
  font-size: var(--kp-fs-body);
  color: var(--tblr-secondary);
}

.kp-approval-stepline {
  color: var(--tblr-secondary);
}

.kp-approval-rowsummary {
  font-size: var(--kp-fs-body);
  color: var(--tblr-secondary);
}

.kp-approval-rowerror {
  font-size: var(--kp-fs-body);
  color: var(--tblr-danger);
}

/* The right hand side of a row: the status pill above the buttons, so the two
   never fight for the same line on a narrow window. */
.kp-approvalpage-side {
  display: flex;
  flex: 0 0 auto;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
}

.kp-approvalpage-actions {
  display: flex;
  gap: 6px;
}

/* --- The card on a record page ------------------------------------------- */

/* What a record still needs before its next step (kpReadiness), at the top of
   the record's right column: a warning tint, the step as its title, one line
   per missing thing. Shown only while something is missing. */
/* One row across the whole right column (a grid on wide screens), the steps
   side by side, each only as tall as its own list. */
.kp-readiness-group {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 12px;
}

.kp-readiness {
  flex: 1 1 260px;
  padding: 12px 14px;
  border: 1px solid color-mix(in srgb, var(--tblr-warning) 35%, var(--tblr-border-color));
  border-radius: var(--kp-radius);
  background: var(--kp-status-warning-bg);
}

[data-bs-theme="dark"] .kp-readiness {
  background: var(--tblr-bg-surface-secondary);
}

.kp-readiness-title {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 600;
  color: var(--kp-status-warning-fg);
}

.kp-readiness-title > .ti {
  font-size: 16px;
}

.kp-readiness-list {
  margin: 6px 0 0;
  padding-left: 22px;
  color: var(--tblr-body-color);
}

.kp-readiness-list > li + li {
  margin-top: 2px;
}

.kp-approval-card .card-header {
  display: flex;
  align-items: center;
  gap: 8px;
}

.kp-approval-rule {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.kp-approval-summary {
  margin: 0 0 12px;
  font-size: var(--kp-fs-body);
  color: var(--tblr-secondary);
}

/* The steps as a vertical line: one dot per step, joined by a rule that stops
   at the last one. */
.kp-approval-steps {
  margin: 0;
  padding: 0;
  list-style: none;
}

.kp-approval-step {
  position: relative;
  display: flex;
  gap: 10px;
  padding: 0 0 14px 0;
}

.kp-approval-step:last-child {
  padding-bottom: 0;
}

.kp-approval-step:not(:last-child)::before {
  content: "";
  position: absolute;
  top: 22px;
  bottom: 2px;
  left: 10px;
  width: 2px;
  background: var(--tblr-border-color);
}

.kp-approval-dot {
  position: relative;
  z-index: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 22px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--tblr-bg-surface-secondary);
  color: var(--tblr-secondary);
  font-size: var(--kp-fs-body);
}

.kp-approval-step-current .kp-approval-dot {
  background: rgba(var(--tblr-primary-rgb), .14);
  color: var(--tblr-primary);
}

.kp-approval-step-approved .kp-approval-dot {
  background: rgba(var(--tblr-success-rgb), .14);
  color: var(--tblr-success);
}

.kp-approval-step-rejected .kp-approval-dot {
  background: rgba(var(--tblr-danger-rgb), .14);
  color: var(--tblr-danger);
}

/* A step nobody ever reached is stated, not hidden, so the history reads
   straight down. */
.kp-approval-step-skipped {
  opacity: .6;
}

.kp-approval-stepbody {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.kp-approval-steptitle {
  font-size: var(--kp-fs-small);
  font-weight: 700;
  color: var(--tblr-secondary);
}

.kp-approval-stepwho {
  font-size: var(--kp-fs-body);
  color: var(--tblr-body-color);
}

.kp-approval-decision {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-top: 4px;
  font-size: var(--kp-fs-body);
}

.kp-approval-decname {
  font-weight: 600;
  color: var(--tblr-body-color);
}

.kp-approval-dectag {
  padding: 0 6px;
  border-radius: 4px;
  font-size: var(--kp-fs-label);
  font-weight: 700;
  line-height: 18px;
}

.kp-approval-dectag-success {
  background: rgba(var(--tblr-success-rgb), .14);
  color: var(--tblr-success);
}

.kp-approval-dectag-danger {
  background: rgba(var(--tblr-danger-rgb), .14);
  color: var(--kp-danger-text);
}

.kp-approval-decwhen {
  color: var(--tblr-secondary);
}

/* A comment belongs under the decision it explains, not beside it. */
.kp-approval-deccomment {
  flex: 1 0 100%;
  color: var(--tblr-secondary);
}

.kp-approval-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

/* --- The decision bar under a record's header ----------------------------- */

/* For the person the request is waiting for: what needs approval, in one
   sentence, with Approve and Reject at the height of the header's buttons. */
.kp-approval-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  margin: 0 0 12px;
  padding: 10px 12px;
  border: 1px solid color-mix(in srgb, var(--kp-status-warning-fg) 30%, transparent);
  border-radius: var(--kp-radius);
  background: var(--kp-status-warning-bg);
  color: var(--kp-status-warning-fg);
  font-size: var(--kp-fs-body);
}

.kp-approval-bar > .ti {
  flex: 0 0 auto;
  font-size: 16px;
}

.kp-approval-bar-text {
  flex: 1 1 320px;
  min-width: 0;
  font-weight: 500;
}

.kp-approval-bar-actions {
  display: flex;
  flex: 0 0 auto;
  gap: 8px;
  margin-left: auto;
}

/* --- The rules editor at /approvals/rules -------------------------------- */

.kp-rulegroup .card-header {
  display: flex;
  align-items: center;
  gap: 8px;
}

.kp-rulelist {
  margin: 0;
  padding: 0;
  list-style: none;
}

.kp-rulerow {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--tblr-border-color);
}

.kp-rulerow:last-child {
  border-bottom: 0;
}

/* A rule that is switched off holds nothing, and says so by receding. Only the
   words are greyed: the switch, the arrows and the menu stay at full strength. */
.kp-rulerow-off .kp-ruletext {
  opacity: .55;
}

/* A rule for every entity repeated, read only, under an entity's own rules: on
   a tinted band with a rule down its left edge, so it is not taken for one of
   the entity's own. The caption row above them opens the band. */
.kp-rulerow-shared {
  background: var(--tblr-bg-surface-secondary);
  box-shadow: inset 3px 0 0 var(--tblr-border-color);
}

.kp-rulerow-caption {
  padding-top: 8px;
  padding-bottom: 8px;
}

.kp-ruletext {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
  flex: 1 1 auto;
}

.kp-rulename {
  font-weight: 600;
  color: var(--tblr-body-color);
}

.kp-rulemeta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  font-size: var(--kp-fs-body);
}

.kp-rulecondition {
  color: var(--tblr-secondary);
}

/* The steps in words, in a monospaced-feeling size so the arrows line up and
   read as a sequence rather than as prose. */
.kp-rulesteps {
  font-size: var(--kp-fs-body);
  color: var(--tblr-body-color);
}

.kp-ruledesc {
  font-size: var(--kp-fs-body);
  color: var(--tblr-secondary);
}

.kp-ruleside {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 8px;
}

/* The order arrows at the ends of the order, and all of them while a move is
   being saved: greyed out, with no hover, so a dead arrow never looks live. */
.kp-ruleside .kp-icon-btn:disabled {
  opacity: .3;
  pointer-events: none;
}

/* --- The rule drawer ----------------------------------------------------- */

.kp-rulecondition-field {
  border: 0;
  padding: 0;
  margin: 0 0 12px;
}

/* Each step is a small card inside the form, so a rule with three of them is
   still readable at 560px. */
.kp-rulestep {
  margin-bottom: 10px;
  padding: 10px;
  border: 1px solid var(--tblr-border-color);
  border-radius: var(--kp-radius-sm, 6px);
  background: var(--tblr-bg-surface-secondary);
}

.kp-rulestep-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
}

.kp-rulestep-index {
  font-size: var(--kp-fs-small);
  font-weight: 700;
  color: var(--tblr-secondary);
}

.kp-rulestep-tools {
  display: flex;
  gap: 2px;
}

/* Dark mode: the surface tints above are mixed from the theme's own colours,
   so only the step card needs a hand, where the secondary surface is too close
   to the drawer behind it. */
[data-bs-theme="dark"] .kp-rulestep {
  background: rgba(255, 255, 255, .03);
}

/* ==========================================================================
   21. Quotations
   ==========================================================================
   The quotation module (imports/ui/pages/quotation/**): the wide product table
   on the form, the totals footer, the per product offer blocks on the record
   page, and the A4 sheet the print view renders.

   Everything is built from the existing tokens, so dark mode needs no overrides
   of its own except where a tint is mixed by hand. The printed sheet is the one
   exception: paper is white, so it is pinned to black on white in both themes.
   -------------------------------------------------------------------------- */

/* A picker used as a filter chip, next to the chip selects in a list toolbar.
   The picker brings its own control; this only gives it a chip's width. */
.kp-chip-picker {
  min-width: 180px;
  max-width: 220px;
}

.kp-chip-picker .kp-picker-control {
  min-height: 28px;
  height: 28px;
  padding: 0 4px 0 10px;
  border-radius: var(--kp-radius-pill);
  font-size: var(--kp-fs-small);
  /* A filter chip keeps the hairline: it is a toolbar control, not a field
     to type into, and the darker control border made the chip row loud. */
  border-color: var(--tblr-border-color);
}

.kp-chip-picker .kp-picker-toggle,
.kp-chip-picker .kp-picker-clear {
  width: 20px;
  height: 20px;
}

/* The list table: the number stays on one line; the account takes the room
   that is left (the list pass, further up).
   `kp-qtn-form`, `kp-line-subtotal`, `kp-line-tax` and `kp-line-total` carry no rules: they are
   the hooks form.js repaints through, exactly as the sales order form's are. */
.kp-qtn-table .kp-cell-code {
  white-space: nowrap;
}

/* ---- The forms' product lines (kpDocLine) -------------------------------- */

/* One card per line, on the opportunity, quotation and sales order forms (a
   table had too many columns for any screen, and its amounts wrapped): the
   deal on the first row, what the form adds per line on the second, the money
   on the third. Each field carries its own label, so nothing depends on a
   header. */
/* A fieldset used only to disable a group of fields at once: no box of its own. */
.kp-fieldset-plain {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.kp-doc-lines {
  display: flex;
  flex-direction: column;
  gap: 12px;
  /* The line rows lay themselves out by the room this card really has, which
     changes with the sidebar, not by the width of the window. */
  container-type: inline-size;
}

.kp-doc-line {
  padding: 14px 16px 12px;
  border: 1px solid var(--tblr-border-color);
  border-radius: var(--kp-radius);
  background: var(--tblr-bg-surface);
}

.kp-doc-line-head {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.kp-doc-line-no {
  flex: 0 0 auto;
  width: 26px;
  height: 26px;
  margin-top: 22px;
  border-radius: 50%;
  background: var(--tblr-bg-surface-secondary);
  color: var(--tblr-secondary);
  font-size: var(--kp-fs-small);
  font-weight: 600;
  line-height: 26px;
  text-align: center;
}

.kp-doc-line-main {
  flex: 1 1 auto;
  min-width: 0;
  display: grid;
  /* The product cell holds kpProductLine (three sub group filters above the
     picker), so it needs about 400px; the other fields keep to the top of the
     taller row. */
  /* Product, quantity, unit, unit price, discount %, tax: the pickers get the
     room the number boxes do not need, so their text is not cut. */
  grid-template-columns: minmax(380px, 3fr) minmax(80px, .8fr) minmax(120px, 1.2fr) minmax(122px, 1.1fr)
    minmax(80px, .8fr) minmax(130px, 1.3fr);
  align-items: start;
  gap: 10px 12px;
}

/* A line with no discount and no tax (the opportunity): four fields. */
.kp-doc-line-main.is-short {
  grid-template-columns: minmax(380px, 3fr) minmax(80px, .8fr) minmax(120px, 1.2fr) minmax(122px, 1.1fr);
}

.kp-doc-line-head > .js-remove-line {
  margin-top: 22px;
}

/* The form's own fields of the line. auto-fill, so two fields keep a column's
   width each; a field marked wide (a packaging) takes two. */
.kp-doc-line-spec {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 10px 12px;
  margin: 12px 38px 0;
  padding-top: 12px;
  border-top: 1px dashed var(--tblr-border-color);
}

.kp-doc-line-spec > .kp-doc-line-wide {
  grid-column: span 2;
}

/* The quotation's seven: with room for all of them the MOQ stays on their
   row, and each column is as wide as its example needs, so "e.g. Pigment
   Red 57:1" and "e.g. 25 kg HDPE drums" are not cut at 1366px. */
@container (min-width: 1000px) {
  .kp-doc-line-spec.kp-qtn-spec {
    grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr) minmax(0, 1.15fr) minmax(0, .85fr)
      minmax(0, 1.6fr) minmax(0, 1fr) minmax(0, .6fr);
  }
  .kp-doc-line-spec.kp-qtn-spec > .kp-doc-line-wide {
    grid-column: auto;
  }
}

.kp-doc-lines .kp-field {
  margin: 0;
  min-width: 0;
}

.kp-doc-lines .kp-field-label {
  margin-bottom: 0;
  /* One line always: a label that wraps pushes its own box below its neighbours. */
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.kp-doc-lines .kp-line-readonly {
  display: block;
  padding: 8px 0;
}

.kp-doc-line-money {
  display: flex;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 6px 24px;
  margin-top: 10px;
  color: var(--tblr-secondary);
  font-size: var(--kp-fs-small);
}

.kp-doc-line-money strong {
  margin-left: 6px;
  /* An amount is never broken over two lines. */
  white-space: nowrap;
  color: var(--tblr-body-color);
}

/* A card narrower than the six fields side by side (a laptop, or a wide
   screen with the sidebar open): the product takes the whole first row and the
   numbers sit in one row under it. */
@container (max-width: 1120px) {
  .kp-doc-line-main {
    /* 156px: the narrowest box that shows a whole tax code ("CG+SG@12"). */
    grid-template-columns: repeat(auto-fit, minmax(156px, 1fr));
  }
  /* auto-fill: the opportunity's three numbers keep a column's width each. */
  .kp-doc-line-main.is-short {
    grid-template-columns: repeat(auto-fill, minmax(156px, 1fr));
  }
  .kp-doc-line-main > .kp-doc-line-product {
    grid-column: 1 / -1;
  }
}

/* The minimum order quantity is read-only: it comes from the product master, or
   from the opportunity. On a quotation it turns red the moment the quantity
   drops under it; on an opportunity, a reference only, amber. */
.kp-doc-moq {
  color: var(--tblr-secondary);
}

.kp-doc-moq-warn {
  color: var(--tblr-warning);
  font-weight: 600;
}

.kp-doc-moq-short {
  color: var(--tblr-danger);
  font-weight: 600;
}

/* The MOQ on opportunity lines: a reference, so amber rather than red when the
   quantity is below it (the quotation is where it is enforced). */
.kp-table td.kp-line-moq {
  color: var(--tblr-secondary);
  white-space: nowrap;
}

.kp-table td.kp-line-moq.kp-line-moq-short {
  color: var(--tblr-warning);
  font-weight: 600;
}

/* ---- The totals footer --------------------------------------------------- */

/* "Add line" at the left and the totals box at the right, on one row. */
.kp-qtn-foot {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px 16px;
  margin-top: 12px;
}

.kp-qtn-foot > .kp-qtn-totals {
  margin-top: 0;
}

.kp-qtn-totals {
  display: flex;
  flex-direction: column;
  gap: 4px;
  align-self: flex-end;
  width: min(320px, 100%);
  margin-top: 16px;
  margin-left: auto;
  padding: 12px 14px;
  border: 1px solid var(--tblr-border-color);
  border-radius: 8px;
  background: var(--tblr-bg-surface-secondary);
}

.kp-qtn-total-row {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  font-size: var(--kp-fs-body);
  color: var(--tblr-body-color);
}

.kp-qtn-total-row .kp-num {
  color: var(--tblr-body-color);
  font-variant-numeric: tabular-nums;
}

.kp-qtn-total-grand {
  margin-top: 4px;
  padding-top: 8px;
  border-top: 1px solid var(--tblr-border-color);
  font-size: var(--kp-fs-card);
  font-weight: 600;
  color: var(--tblr-body-color);
}

/* The block is one component (`kpTotals`): the quotation and sales order
   record pages and forms and the SAP order page all draw it. Under a lines
   table it stands at the right of its card, clear of the card's edge, and
   stays in view when the table scrolls sideways. */
.card > .kp-qtn-totals {
  width: min(320px, calc(100% - 24px));
  margin: 12px 12px 12px auto;
}

/* The discount typed in the block itself (the quotation and sales order forms). */
.kp-qtn-total-row:has(> .kp-totals-edit) {
  align-items: center;
}

.kp-totals-edit {
  display: flex;
  align-items: center;
  gap: 8px;
}

.kp-totals-edit > label {
  margin: 0;
  font-weight: 600;
}

.kp-totals-edit > .form-control {
  flex: 0 0 84px;
  width: 84px;
}

/* The quotation's "%" or currency: a small picker in place of the "%" after
   the box. The block takes the room it needs, so the amount stays on the row. */
.kp-totals-edit > .kp-picker {
  flex: 0 0 80px;
  width: 80px;
}

.kp-qtn-totals:has(.kp-totals-edit > .kp-picker) {
  width: min(380px, 100%);
}

/* Why the line totals do not add up to the Total. */
.kp-totals-note {
  margin-top: 6px;
  font-size: var(--kp-fs-small);
  color: var(--tblr-secondary);
}

/* ---- The record page's Lines card ---------------------------------------- */

/* A number is never broken over two lines; when the table is wider than the
   card it scrolls sideways, and the totals box under it stays in view. */
.kp-qtn-numbers .kp-num {
  white-space: nowrap;
}

/* Nine columns in the centre column of a 1366px window: the cells stand closer
   together, and the numbers do not take their room from the product's name. */
.kp-qtn-numbers .kp-table > thead > tr > th:not(:first-child),
.kp-qtn-numbers .kp-table > tbody > tr > td:not(:first-child) {
  padding-left: 8px;
}

.kp-qtn-numbers .kp-table > thead > tr > th:not(:last-child),
.kp-qtn-numbers .kp-table > tbody > tr > td:not(:last-child) {
  padding-right: 8px;
}

.kp-qtn-numbers td.kp-cell-name {
  min-width: 140px;
}

.kp-qtn-numbers > .kp-qtn-totals {
  width: min(320px, calc(100% - 24px));
  margin: 12px 12px 12px auto;
}

/* ---- The record page's offer blocks -------------------------------------- */

/* One card per product, the fields in the order the client's quotation format
   prints them. */
.kp-qtn-offer .kp-vlist {
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.kp-qtn-revision {
  cursor: pointer;
}

/* ---- The printed sheet --------------------------------------------------- */

.kp-print-scroll {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 16px;
  background: var(--tblr-bg-surface-secondary);
}

/* A4 at 96dpi is 794px wide. The sheet keeps those proportions on screen so
   what the user sees is what comes out of the printer.

   The sheet is paper: black on white in dark mode too, so its colours are its
   own and never the theme's; only the frame around it follows the theme. It
   reads in black and white: hairline rules and greys, no colour that carries
   meaning, figures right aligned in tabular digits. */
.kp-sheet {
  --kp-sheet-ink: #111827;
  --kp-sheet-muted: #4b5563;
  --kp-sheet-rule: #d1d5db;
  --kp-sheet-rule-strong: #111827;
  --kp-sheet-band: #f3f4f6;
  width: 794px;
  max-width: 100%;
  margin: 0 auto;
  padding: 40px 44px;
  border: 1px solid var(--tblr-border-color);
  border-radius: 4px;
  background: #fff;
  color: var(--kp-sheet-ink);
  font-size: 12px;
  line-height: 1.45;
}

[data-bs-theme="dark"] .kp-sheet {
  border-color: rgba(255, 255, 255, .18);
}

.kp-sheet dl {
  margin: 0;
}

.kp-sheet dd {
  margin: 0;
}

.kp-sheet-num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.kp-sheet-nowrap {
  white-space: nowrap;
}

.kp-sheet-strong {
  font-weight: 600;
}

.kp-sheet-muted {
  color: var(--kp-sheet-muted);
}

.kp-sheet-pre {
  white-space: pre-line;
}

/* GSTIN and PAN, phone and email: two facts on one line, a dot between. */
.kp-sheet-sep::before {
  content: "\00B7";
  margin: 0 6px;
  color: var(--kp-sheet-muted);
}

.kp-sheet-block-title {
  margin-bottom: 4px;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--kp-sheet-muted);
}

/* ---- Letterhead ----------------------------------------------------------- */

.kp-sheet-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 24px;
  padding-bottom: 14px;
  border-bottom: 1.5px solid var(--kp-sheet-rule-strong);
}

.kp-sheet-brand {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  min-width: 0;
}

.kp-sheet-logo {
  display: block;
  max-height: 44px;
  max-width: 180px;
  object-fit: contain;
}

.kp-sheet-company {
  font-size: 11px;
  color: var(--kp-sheet-muted);
}

.kp-sheet-entity {
  font-size: 15px;
  font-weight: 700;
  line-height: 1.3;
  color: var(--kp-sheet-ink);
}

.kp-sheet-doc {
  flex: none;
  text-align: right;
}

.kp-sheet-doctype {
  font-size: 22px;
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: -.01em;
}

.kp-sheet .kp-sheet-docmeta {
  display: grid;
  grid-template-columns: auto auto;
  gap: 1px 12px;
  margin-top: 8px;
  justify-content: end;
}

.kp-sheet-docmeta dt {
  font-weight: 400;
  color: var(--kp-sheet-muted);
}

.kp-sheet-docmeta dd {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

/* ---- Buyer and our contact ------------------------------------------------ */

.kp-sheet-parties {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 32px;
  margin: 18px 0 20px;
}

.kp-sheet .kp-sheet-pairs {
  display: grid;
  grid-template-columns: 56px 1fr;
  gap: 1px 8px;
  margin-top: 6px;
}

.kp-sheet-pairs dt {
  font-weight: 400;
  color: var(--kp-sheet-muted);
}

/* ---- Lines ---------------------------------------------------------------- */

.kp-sheet-lines {
  width: 100%;
  border-collapse: collapse;
}

/* The head repeats at the top of every printed page. */
.kp-sheet-lines thead {
  display: table-header-group;
}

.kp-sheet-lines th {
  padding: 6px 8px;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: .04em;
  text-transform: uppercase;
  text-align: left;
  white-space: nowrap;
  color: var(--kp-sheet-muted);
  border-bottom: 1.5px solid var(--kp-sheet-rule-strong);
}

.kp-sheet-lines td {
  padding: 8px;
  vertical-align: top;
  border-bottom: 1px solid var(--kp-sheet-rule);
}

.kp-sheet-lines th:first-child,
.kp-sheet-lines td:first-child {
  padding-left: 0;
}

.kp-sheet-lines th:last-child,
.kp-sheet-lines td:last-child {
  padding-right: 0;
}

.kp-sheet-lines th.kp-sheet-num {
  text-align: right;
}

.kp-sheet-lines tr {
  break-inside: avoid;
}

.kp-sheet-col-no {
  width: 28px;
  color: var(--kp-sheet-muted);
  font-variant-numeric: tabular-nums;
}

.kp-sheet-details {
  margin-top: 2px;
  font-size: 11px;
  color: var(--kp-sheet-muted);
}

.kp-sheet-details > span + span::before {
  content: "\00B7";
  margin: 0 6px;
}

.kp-sheet-empty {
  color: var(--kp-sheet-muted);
}

/* The last line and the totals under it are one tbody that a page never
   splits, so the totals never sit alone at the top of a page. */
.kp-sheet-lines-end {
  break-inside: avoid;
}

.kp-sheet-lines .kp-sheet-totals-row > td {
  padding: 12px 0 0;
  border-bottom: 0;
}

.kp-sheet-foot {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 32px;
}

.kp-sheet-words {
  flex: 1;
  min-width: 0;
  padding-top: 4px;
  font-size: 11px;
}

/* The totals, as the record page's totals block (`kpTotals`) lays them out:
   label left, amount right, the Total in bold on a light band. */
.kp-sheet-totals {
  flex: none;
  width: 280px;
}

.kp-sheet-total {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 3px 8px;
}

.kp-sheet-total-grand {
  margin-top: 4px;
  padding: 6px 8px;
  border-top: 1.5px solid var(--kp-sheet-rule-strong);
  background: var(--kp-sheet-band);
  font-size: 13px;
  font-weight: 700;
  -webkit-print-color-adjust: exact;
  print-color-adjust: exact;
}

/* ---- Terms and signature -------------------------------------------------- */

/* The terms and the signature move to the next page together, so the
   signature never stands alone on a page. */
.kp-sheet-close {
  break-inside: avoid;
}

.kp-sheet-terms {
  margin-top: 24px;
  padding-top: 12px;
  border-top: 1px solid var(--kp-sheet-rule);
}

.kp-sheet-terms-list {
  display: grid;
  grid-template-columns: 160px 1fr;
  gap: 2px 12px;
}

.kp-sheet-terms-list dt {
  font-weight: 400;
  color: var(--kp-sheet-muted);
}

.kp-sheet-note {
  margin: 10px 0 0;
  font-size: 11px;
  color: var(--kp-sheet-muted);
}

.kp-sheet-sign {
  width: 240px;
  margin: 28px 0 0 auto;
}

.kp-sheet-sign-for {
  font-weight: 600;
}

/* Room for the signature and the stamp, above the signatory's name. */
.kp-sheet-sign-line {
  height: 48px;
  margin-bottom: 6px;
  border-bottom: 1px solid var(--kp-sheet-rule-strong);
}

/* ---- Printing ------------------------------------------------------------ */

/* The stamp across the print of a quotation that is still a draft. On screen it
   lies over the sheet; on paper it is fixed, so it repeats on every page. */
.kp-print-section {
  position: relative;
}

.kp-print-watermark {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  pointer-events: none;
}

.kp-print-watermark span {
  transform: rotate(-30deg);
  font-size: 120px;
  font-weight: 700;
  letter-spacing: .12em;
  white-space: nowrap;
  color: rgba(200, 30, 30, .22);
  -webkit-print-color-adjust: exact;
  print-color-adjust: exact;
}

/* A stamp of several words ("SUPERSEDED BY REV 2"): smaller, so the whole of
   it fits across the sheet. */
.kp-print-watermark-long span {
  font-size: 46px;
  letter-spacing: .08em;
}

@media print {
  .kp-print-watermark {
    position: fixed;
  }
}

/*
 * `kp-print-page` on the print view's root is what takes the workspace off the
 * paper: the sidebar, the phone app bar (a narrow print width is under its
 * 992px breakpoint), the tab strip and every toolbar are hidden, the scroll
 * containers stop scrolling, and the sheet loses the frame it wears on screen.
 * Anything else the shell draws is hidden the same way.
 */
@media print {
  .kp-sidebar,
  .kp-mobile-bar,
  .kp-tabstrip,
  .kp-toolbar,
  .kp-print-toolbar,
.kp-inspector,
.kp-board,
.kp-confirm,
.kp-confirm-backdrop {
    display: none !important;
  }

  .kp-shell,
  .kp-main,
  .kp-content,
  .kp-page-fill,
  .kp-print-page {
    display: block !important;
    height: auto !important;
    max-height: none !important;
    overflow: visible !important;
    margin: 0 !important;
    padding: 0 !important;
    background: #fff !important;
  }

  .kp-print-scroll {
    overflow: visible !important;
    padding: 0 !important;
    background: #fff !important;
  }

  .kp-sheet {
    width: auto !important;
    max-width: none !important;
    padding: 0 !important;
    border: 0 !important;
    border-radius: 0 !important;
  }

  @page {
    size: A4;
    margin: 14mm;
  }
}

/* ==========================================================================
   22. Sales order review
   ==========================================================================
   The order review checklist (a card of the sales order form, and the
   "Review checklist" tab on the record page). It is not printed from here:
   its details go on the sales order layout SAP will print.

   Three things: the two column read view on the record page, the form
   number beside the card title, and the small "Advance pending" chip a board
   card and a list row can carry. All built from the existing tokens, so dark
   mode needs no overrides of its own.
   -------------------------------------------------------------------------- */

/* ---- The read view on the record page ------------------------------------ */

.kp-review-hint,
.kp-review-saved {
  margin: 0 0 12px;
  font-size: var(--kp-fs-body);
  color: var(--tblr-secondary);
}

.kp-review-saved {
  margin-top: -6px;
}

.kp-review-group + .kp-review-group {
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--tblr-border-color);
}

.kp-review-group-title {
  margin: 0 0 8px;
  font-size: var(--kp-fs-small);
  font-weight: 600;
  color: var(--tblr-secondary);
}

/* Label and value in two columns, the same rhythm as the Facts list, and one
   column under 720px so a phone never truncates a consignee block. */
.kp-review-grid {
  display: grid;
  grid-template-columns: minmax(160px, 34%) 1fr;
  gap: 6px 16px;
  margin: 0;
}

.kp-review-grid dt {
  font-weight: 500;
  color: var(--tblr-secondary);
}

.kp-review-grid dd {
  margin: 0;
}

@media (max-width: 720px) {
  .kp-review-grid {
    grid-template-columns: 1fr;
    gap: 2px;
  }

  .kp-review-grid dd {
    margin-bottom: 8px;
  }
}

/* ---- The form ------------------------------------------------------------ */

/* The form number sits at the right of the first card's heading, so the person
   filling it can see which of the client's two forms they are on. */
.kp-review-form-number {
  margin-left: auto;
  font-size: var(--kp-fs-small);
  font-weight: 600;
  letter-spacing: .06em;
  color: var(--tblr-secondary);
}

/* ---- The "Advance pending" chip ------------------------------------------ */

/* A board card and a list row both carry it. It is a chip rather than a status
   pill: the order's status is elsewhere on the card, and this is a warning
   about one field. */
.kp-chip-advance {
  display: inline-flex;
  align-items: center;
  padding: 1px 8px;
  border: 1px solid color-mix(in srgb, var(--tblr-warning) 45%, transparent);
  border-radius: 999px;
  background: var(--kp-status-warning-bg);
  color: var(--kp-status-warning-fg);
  font-size: var(--kp-fs-label);
  font-weight: 600;
  white-space: nowrap;
}

/* ==========================================================================
   23. Sample requests
   ==========================================================================
   The sample request module rebuilt on the workspace shell
   (imports/ui/pages/sampleRequest/{list,form,details}.*).

   Almost everything it needs is already here: the toolbar, the table, the board,
   the record grid, the status pills, the confirm dialog and the pickers are the
   shared parts. Only four things are new:

     - the list card and its table widths,
     - the line table on the form, which is narrower than the sales order one
       because a sample has no prices,
     - the upload control and the attachment list, shared by the form and by the
       dispatch and logistics dialogs,
     - the two wider dialogs (dispatch and COA) that carry a small table.

   Everything is built from the existing tokens, so dark mode needs no overrides
   of its own.
   -------------------------------------------------------------------------- */

/* ---- The list ------------------------------------------------------------ */

.kp-samples-card {
  display: flex;
  flex-direction: column;
  min-height: 0;
  flex: 1 1 auto;
}

.kp-samples-wrap {
  flex: 1 1 auto;
  min-height: 0;
}

.kp-samples-table .kp-col-code {
  width: 190px;
}

.kp-samples-table .kp-col-num {
  width: 72px;
}

/* A row opens its record, so it says so on hover like the other list pages. */
.kp-sample-row {
  cursor: pointer;
}

/* ---- The form ------------------------------------------------------------ */

.kp-sample-lines-table th,
.kp-sample-lines-table td {
  vertical-align: top;
}

/* Product (kpProductLine, three sub group filters above the picker),
   Quantity, Unit, Remarks. The Grade column is gone, so the shared positional
   `.kp-lines` rules no longer fit; these set the columns again. The selectors
   repeat the shared ones' :not()s so they outrank them. */
.kp-lines.kp-sample-lines-table:not(.kp-lead-contacts):not(.kp-dm-table) > thead > tr > th:first-child {
  min-width: 420px;
}

/* The unit picker's control carries .form-control, which the shared rules
   narrow to a number box in the third column. */
.kp-lines.kp-sample-lines-table:not(.kp-lead-contacts):not(.kp-dm-table) td:nth-child(3) .form-control {
  width: auto;
  text-align: left;
}

.kp-lines.kp-sample-lines-table:not(.kp-lead-contacts):not(.kp-dm-table) td:nth-child(3) .kp-picker {
  min-width: 96px;
}

.kp-sample-lines-table .js-line-quantity {
  max-width: 120px;
}

/* ---- The upload control and the attachment lists ------------------------- */

.kp-upload {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.kp-upload-drop {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 8px 12px;
  border: 1px dashed var(--tblr-border-color);
  border-radius: var(--tblr-border-radius, 6px);
  background: var(--tblr-bg-surface-secondary);
  color: var(--tblr-secondary);
  cursor: pointer;
}

.kp-upload-drop:hover {
  border-color: var(--tblr-primary);
  color: var(--tblr-primary);
}

.kp-upload-input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}

.kp-attach-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.kp-attach-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border: 1px solid var(--tblr-border-color);
  border-radius: var(--tblr-border-radius, 6px);
  background: var(--tblr-bg-surface);
}

.kp-attach-item > i {
  color: var(--tblr-secondary);
}

.kp-attach-name {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--tblr-body-color);
}

a.kp-attach-name:hover {
  color: var(--tblr-primary);
}

.kp-attach-meta {
  color: var(--tblr-secondary);
  font-size: var(--kp-fs-small);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.kp-attach-group + .kp-attach-group {
  margin-top: 16px;
}

.kp-attach-group-title {
  margin: 0 0 8px;
  font-size: var(--kp-fs-body);
  font-weight: 600;
  color: var(--tblr-secondary);
}

/* ---- The workflow dialog ------------------------------------------------- */

/* The dispatch and the COA steps carry a small table, so this dialog is wider
   than a plain confirmation and scrolls rather than growing off the screen. */
.kp-sample-dialog {
  width: min(920px, calc(100vw - 32px));
  max-height: calc(100vh - 96px);
  overflow-y: auto;
}

.kp-sample-dispatch th,
.kp-sample-batch th {
  white-space: nowrap;
}

.kp-sample-dispatch .form-check {
  margin: 0;
}

/* ---- The record page's next step card ------------------------------------ */

.kp-next-step {
  margin: 0;
  color: var(--tblr-secondary);
  line-height: 1.45;
}

/* ==========================================================================
   24. Contacts and activities
   ==========================================================================
   The contact and activity modules rebuilt on the workspace shell
   (imports/ui/pages/contact/{list,form,details}.* and
   imports/ui/pages/activity/{list,form,details}.*).

   Almost everything they need is already here: the toolbar, the table, the
   board, the record grid, the status pills, the confirm dialog, the duplicate
   card and the pickers are the shared parts. Only five things are new: the
   two full-height list cards, a clamped cell for a discussion that can run to
   several paragraphs, the discussion as it reads on the record page, the two
   part phone field, and the column of quick actions on the contact record.
   ========================================================================== */

/* ---- The full height list cards ------------------------------------------ */

/* Both lists fill the page like the sample requests list does, so the table
   scrolls inside the card rather than the page scrolling under the toolbar. */
.kp-contacts-card,
.kp-activities-card {
  display: flex;
  flex-direction: column;
  min-height: 0;
  flex: 1 1 auto;
}

.kp-contacts-table .kp-col-name,
.kp-activities-table .kp-col-name {
  max-width: 220px;
}

/* A row is the whole record, so the pointer says so; the row menu and the mail
   and phone links inside it keep their own cursor. */
.kp-contact-row,
.kp-activity-row,
.kp-activity-link {
  cursor: pointer;
}

/* ---- A discussion in a cell ---------------------------------------------- */

/* The discussion is free text and often several sentences. In a table it is
   clamped to two lines with the full text on the title attribute, so a long
   one never pushes the status and the owner off the row. */
/* It goes on a span inside the cell, never on the cell: a clamped box is not a
   table cell any more, and its row line then sits out of step with the others. */
.kp-clamp {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  max-width: 360px;
  line-height: 1.35;
}

/* On a board card there is less room still, so it is one line shorter. */
.kp-board-card-text {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  font-size: var(--kp-fs-small);
  line-height: 1.35;
  color: var(--tblr-body-color);
}

/* ---- The discussion on the record page ----------------------------------- */

/* The record page is the one place the whole discussion is shown, so the line
   length is held back to something readable and the author's own line breaks
   are kept. */
.kp-discussion {
  margin: 0;
  max-width: 70ch;
  white-space: pre-wrap;
  line-height: 1.6;
  color: var(--tblr-body-color);
}

/* ---- The phone field ----------------------------------------------------- */

/* A country code and a number are one field to the eye and two inputs to the
   form, so they sit in one row with the code held narrow. */
.kp-phone-field {
  display: flex;
  gap: 8px;
}

.kp-phone-code {
  flex: 0 0 84px;
  width: 84px;
}

/* ---- Quick actions on the contact record --------------------------------- */

/* A short column of full width buttons in the right hand card, so each one
   reads as its own action rather than as a row of chips. */
.kp-quick-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.kp-quick-actions .btn {
  justify-content: flex-start;
  width: 100%;
}

/* ==========================================================================
   25. Accounts
   ==========================================================================
   The accounts module rebuilt on the workspace shell
   (imports/ui/pages/accounts/{list,form,details}.*).

   Nearly everything it needs is already here: the toolbar, the table, the
   bulk bar, the record grid, the facts list, the confirm dialog, the pickers
   and the From SAP chip are all shared parts. Only five things are new: the
   full height list card, a smaller From SAP chip for a table cell and a fact
   value, the pinned glyph on a row, the clickable rows of the compact related
   lists, and the small "SAP" tag that marks one fact on the Overview tab.
   ========================================================================== */

/* ---- The full height list card ------------------------------------------ */

/* The list fills the page like the sample requests list does, so the table
   scrolls inside the card rather than the page scrolling under the toolbar. */
.kp-accounts-card {
  display: flex;
  flex-direction: column;
  min-height: 0;
  flex: 1 1 auto;
}

.kp-accounts-wrap {
  flex: 1 1 auto;
  min-height: 0;
}

.kp-accounts-table .kp-col-name {
  max-width: 240px;
}

/* ---- The figures at the top of an account's page ------------------------ */

/* Invoiced this FY, Open pipeline, Open quotations and Last contact: the
   Dashboard's figure tiles (.kp-dsh-kpi), four to a row, two on a phone. */
.kp-account-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}

/* A figure with nothing in it says so in words, smaller and muted, so it
   never reads as an amount. */
.kp-account-stats .kp-dsh-kpi.is-none .kp-dsh-kpi-value {
  color: var(--tblr-secondary);
  font-size: var(--kp-fs-card);
  font-weight: 600;
  letter-spacing: 0;
}

@media (max-width: 599.98px) {
  .kp-account-stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .kp-account-stats .kp-dsh-kpi {
    padding: 10px 11px;
  }

  .kp-account-stats .kp-dsh-kpi-value {
    font-size: var(--kp-fs-title);
  }
}

/* ---- The product list (imports/ui/pages/masters/products) ---------------- */

/* The card fills the page like the other lists, so the table scrolls inside it. */
.kp-products-card,
.kp-master-list-card {
  display: flex;
  flex-direction: column;
  min-height: 0;
  flex: 1 1 auto;
}

/* A row opens the product in the side panel, so the pointer says so. */
.kp-product-row,
.kp-master-row {
  cursor: pointer;
}

/* Product names are the longest names in the portal (up to 60 characters), so
   the name is shown whole: a long one wraps onto a second line instead of
   widening the table, and every column stays on screen. Only here; the shared
   .kp-col-name of the other lists still cuts a long name short on one line. */
.kp-products-table .kp-col-name {
  max-width: 540px;
}

.kp-products-table td.kp-col-name {
  min-width: 160px;
  overflow: visible;
  text-overflow: clip;
  white-space: normal;
  overflow-wrap: anywhere;
  line-height: 1.35;
}

/* The item code and the sub groups stay on one line while there is room. With
   the side panel open on a laptop they may wrap too, at a hyphen or a space,
   so the table still fits beside the panel. */
.kp-products-table td.kp-col-wrap {
  max-width: none;
  white-space: normal;
  overflow-wrap: break-word;
}

/* On a phone a whole name on one line is wider than the screen, so there it
   wraps instead: still whole, and the columns after it stay within reach. */
@media (max-width: 767.98px) {
  .kp-products-table td.kp-col-name {
    min-width: 180px;
    max-width: 220px;
    white-space: normal;
    overflow-wrap: anywhere;
  }
}

/* A heading that sorts the list (`kpSortTh`) is a button that reads as the
   heading it sits in, on every list. The arrow is faint until its column is
   the one the list is sorted by. */
.kp-table .kp-sort-th {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  text-transform: inherit;
  letter-spacing: inherit;
  white-space: nowrap;
  cursor: pointer;
}

.kp-table .kp-sort-th:hover {
  color: var(--tblr-body-color);
}

.kp-table .kp-sort-idle {
  opacity: .45;
}

/* The second heading of a column that stacks a name over its code. */
.kp-table .kp-sort-also {
  margin-left: 12px;
  font-weight: 500;
}

/* A row is the whole record, so the pointer says so; the checkbox and the row
   menu inside it keep their own behaviour. */
.kp-account-row {
  cursor: pointer;
}

/* ---- The From SAP chip inside a cell ------------------------------------ */

/* The chip sits beside a code in a table cell and beside a fact value, where
   the full size chip would push the line out of its row. */
.kp-from-sap.kp-from-sap-sm {
  margin-left: 6px;
  padding: 0 6px;
  font-size: var(--kp-fs-label);
}

.kp-from-sap.kp-from-sap-sm .ti {
  font-size: 12px;
}

/* A fact value the sync owns is not a form control, so the locked style has to
   read as a colour rather than as a disabled input. */
dd.kp-sap-locked {
  color: var(--tblr-secondary);
}

/* ---- The pinned glyph on a row ------------------------------------------ */

/* The bundled Tabler build ships no filled glyphs, so a pinned row is marked
   by colour rather than by a different shape (imports/ui/shell/actions.js). */
.kp-pin-on {
  margin-left: 6px;
  color: var(--kp-status-warning-fg, #B45309);
  font-size: 14px;
  vertical-align: middle;
}

/* ---- The compact related lists ------------------------------------------ */

/* Every row of an Opportunities, Quotations, Sales orders or Sample requests
   tab opens that record, so it behaves like a list row. */
.kp-mini-row {
  cursor: pointer;
}

.kp-mini-row:hover {
  background: var(--tblr-bg-surface-secondary);
}

/* ==========================================================================
   26. Discount matrix
   ==========================================================================
   The discount matrix page (imports/ui/pages/discountMatrix/matrix.*) and the
   hint the quotation record page shows beside Send
   (imports/ui/pages/quotation/details.*), plus the "not used" note the rules
   editor puts on an old quotation discount rule.

   The band table reuses the line table (`kp-lines`); only its column widths,
   the entity chip in the card head, the preview list and the hint strip are
   new. Colours come from the status tokens, which section 1 redefines for dark
   mode, so nothing here needs a dark override of its own.
   ========================================================================== */

/* ---- The card head's entity chip ---------------------------------------- */

.kp-dm-entity {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
  padding: 2px 10px;
  border: 1px solid var(--tblr-border-color);
  border-radius: var(--kp-radius-pill);
  background: var(--tblr-bg-surface-secondary);
  font-size: var(--kp-fs-small);
  color: var(--tblr-body-color);
  max-width: 50%;
}

.kp-dm-entity-code {
  font-weight: 700;
  letter-spacing: 0.03em;
}

.kp-dm-entity-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--tblr-secondary);
}

.kp-dm-intro {
  max-width: 72ch;
  margin: 0 0 14px;
  color: var(--tblr-secondary);
  font-size: var(--kp-fs-body);
}

/* ---- The band table ----------------------------------------------------- */

.kp-dm-table {
  min-width: 560px;
}

.kp-dm-table > tbody > tr > td {
  vertical-align: top;
}

.kp-dm-table .kp-dm-col-pct {
  width: 120px;
}

/* The line table narrows its third and fifth columns for numbers; here the
   third column is the approver picker, which takes the rest of the row. */
.kp-dm-table td.kp-dm-col-approver .form-control {
  width: 100%;
  text-align: left;
}

.kp-dm-table td.kp-dm-col-pct .form-control {
  width: 100%;
  text-align: right;
}

.kp-dm-table .kp-readonly {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  background: var(--tblr-bg-surface-secondary);
  color: var(--tblr-secondary);
}

.kp-dm-table .kp-field-error {
  margin-top: 4px;
  font-size: var(--kp-fs-small);
  text-align: left;
  white-space: normal;
}

.kp-dm-actions {
  margin-top: 10px;
}

/* ---- The preview -------------------------------------------------------- */

.kp-dm-preview {
  margin-top: 16px;
  padding: 12px 14px;
  border: 1px solid var(--tblr-border-color);
  border-radius: var(--kp-radius);
  background: var(--tblr-bg-surface-secondary);
}

.kp-dm-preview-title {
  margin: 0 0 6px;
  font-size: var(--kp-fs-small);
  font-weight: 600;
  color: var(--tblr-secondary);
}

.kp-dm-preview-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.kp-dm-preview-line {
  position: relative;
  padding: 3px 0 3px 16px;
  font-size: var(--kp-fs-body);
}

.kp-dm-preview-line::before {
  content: "";
  position: absolute;
  left: 2px;
  top: 10px;
  width: 7px;
  height: 7px;
  border-radius: var(--kp-radius-pill);
  background: var(--kp-status-info-fg);
}

.kp-dm-preview-free::before {
  background: var(--kp-status-success-fg);
}

.kp-dm-preview-blocked {
  color: var(--kp-status-danger-fg);
}

.kp-dm-preview-blocked::before {
  background: var(--kp-status-danger-fg);
}

.kp-dm-empty {
  padding: 28px 12px;
}

.kp-dm-updated {
  margin-top: 12px;
}

/* ---- The hint beside Send on a quotation -------------------------------- */

.kp-dm-hint {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin: 8px 0 0;
  padding: 8px 12px;
  border-radius: var(--kp-radius);
  background: var(--kp-status-success-bg);
  color: var(--kp-status-success-fg);
  font-size: var(--kp-fs-body);
}

.kp-dm-hint .ti {
  flex: 0 0 auto;
  margin-top: 2px;
  font-size: 15px;
}

.kp-dm-hint-approval {
  background: var(--kp-status-warning-bg);
  color: var(--kp-status-warning-fg);
}

.kp-dm-hint-blocked {
  background: var(--kp-status-danger-bg);
  color: var(--kp-status-danger-fg);
}

/* ---- An old quotation discount rule on the rules editor ------------------ */

.kp-rule-ignored {
  color: var(--kp-status-warning-fg);
}

/* ---- A currency no value rule covers, on the rules editor ---------------- */

.kp-rule-gap {
  color: var(--kp-status-warning-fg);
}

/* ==========================================================================
   27. System settings: SAP sync card
   ========================================================================== */

/* The schedule fields on one row on a laptop, stacked on a phone. */
.kp-sap-sync-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 180px), 1fr));
  gap: 12px 18px;
}

.kp-sap-sync-table td {
  vertical-align: middle;
}

.kp-sap-sync-table .kp-col-actions {
  width: 1%;
  white-space: nowrap;
  text-align: right;
}

/* The page spaces consecutive fields apart; inside the row they align. */
.kp-sap-sync-grid {
  margin-top: 14px;
}

.kp-settings-grid .kp-sap-sync-grid > .kp-field {
  margin: 0;
}

/* Port and Security side by side on the Email (SMTP) card: a narrow port, the
   rest for the security choice. The pair keeps the form's 14px rhythm. */
.kp-smtp-pair {
  display: grid;
  grid-template-columns: minmax(90px, 1fr) minmax(0, 3fr);
  gap: 12px 18px;
  margin: 14px 0;
}

.kp-settings-grid .kp-smtp-pair > .kp-field {
  margin: 0;
}

.kp-card-head > #kpSapRunAll {
  margin-left: auto;
}

/* ==========================================================================
   28. Room to read: record page tables, the stage bar, single pickers
   ========================================================================== */

/* The tables on a record page (line items, schedules, related lists) are read,
   not scanned in bulk like a list, so they get more air than list rows. */
.kp-record .kp-table > thead > tr > th {
  padding: 10px 14px;
}

.kp-record .kp-table > tbody > tr > td,
.kp-record .kp-table > tfoot > tr > td {
  padding: 13px 14px;
  font-size: var(--kp-fs-body);
  vertical-align: middle;
}

/* An amount with its currency stays on one line ("1,000.00 INR"); the product
   name gives up the width instead. */
.kp-record .kp-table > tbody > tr > td.kp-num,
.kp-record .kp-table > tfoot > tr > td.kp-num {
  white-space: nowrap;
}

/* Stages share the width when there is room, and scroll when there is not. */
.kp-stagebar > .kp-stageseg {
  flex: 1 0 auto;
}

/* A single choice stays one line high: a long product name is cut with an
   ellipsis beside the search box instead of pushing it onto a second line. */
.kp-picker:not(.kp-picker-multi) > .kp-picker-control {
  flex-wrap: nowrap;
}

.kp-picker:not(.kp-picker-multi) .kp-picker-single {
  flex: 0 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.kp-picker:not(.kp-picker-multi) .kp-picker-single + .kp-picker-search {
  flex: 1 1 24px;
  min-width: 24px;
}

/* Seven stages fit a laptop's centre column with a little less padding (and,
   up to 1440px, with the compact steps below). */
.kp-stagebar > .kp-stageseg {
  padding-right: 9px;
  padding-left: 16px;
}

.kp-stagebar > .kp-stageseg:first-child {
  padding-left: 12px;
}

/* The MOQ, and a locked line's figures, are text under a left-aligned label,
   not a column of figures. */
.kp-doc-lines .kp-line-readonly.kp-num {
  text-align: left;
}

@media (max-width: 1439.98px) {
  .kp-stagebar {
    gap: 0;
  }

  .kp-stagebar > .kp-stageseg {
    padding-right: 6px;
    padding-left: 13px;
    font-size: var(--kp-fs-small);
  }
}

/* ---- Line tables on the forms (opportunity, sales order, sample request) --
   Every one runs Product, Grade, Quantity, Unit, then the money or remarks.
   The controls were 30px high at 12.5px and the selects shrank until "Select
   grade" read "Select g": full size controls, and each column a floor.
   The column rules skip the tables that reuse `.kp-lines` with other columns
   (lead contacts, discount bands): those set their own widths. */
.kp-lines:not(.kp-lead-contacts):not(.kp-dm-table) {
  min-width: 860px;
}

.kp-lines > thead > tr > th {
  padding: 10px 10px;
}

.kp-lines > tbody > tr > td,
.kp-lines > tfoot > tr > td {
  padding: 9px 10px;
}

.kp-lines .form-control,
.kp-lines .form-select {
  height: 36px;
  font-size: var(--kp-fs-body);
}

.kp-lines .form-select {
  padding-right: 28px;
}

.kp-lines:not(.kp-lead-contacts):not(.kp-dm-table) > thead > tr > th:first-child {
  width: 34%;
  min-width: 220px;
}

/* A selected product's name does not wrap, and an automatic table would widen
   the column to fit all of it; a nominal max-width makes the cell keep its
   share and the name end in an ellipsis instead. */
.kp-lines:not(.kp-lead-contacts):not(.kp-dm-table) > tbody > tr > td:first-child {
  max-width: 1px;
}

.kp-lines:not(.kp-lead-contacts):not(.kp-dm-table) td:nth-child(2) .form-control,
.kp-lines:not(.kp-lead-contacts):not(.kp-dm-table) td:nth-child(2) .form-select {
  min-width: 120px;
}

.kp-lines:not(.kp-lead-contacts):not(.kp-dm-table) td:nth-child(3) .form-control,
.kp-lines:not(.kp-lead-contacts):not(.kp-dm-table) td:nth-child(5) .form-control {
  width: 92px;
}

.kp-lines:not(.kp-lead-contacts):not(.kp-dm-table) td:nth-child(4) .kp-picker {
  min-width: 96px;
}

.kp-lines .kp-picker-control {
  min-height: 36px;
}

/* The product's sub group filters stay compact in a lines table too, the same
   as on every other line (kpProductLine passes size="sm"). */
.kp-lines .kp-picker-sm > .kp-picker-control {
  min-height: 30px;
}

/* ==========================================================================
   Admin forms as full pages (roles, entities, approval rules, masters)
   ==========================================================================
   The side drawers are gone: the role editor (/role/new, /role/:_id/edit),
   the entity form and record page (/entities/new, /entities/:_id[/edit]),
   the approval rule form (/approvals/rules/new, /approvals/rules/:_id/edit)
   and the shared master form (master_create) are full pages built on
   `.kp-record-form`. Only what those pages add is here.
   -------------------------------------------------------------------------- */

/* A card inside a scrolling record form keeps its content height. A card with
   `overflow: hidden` (the permission matrix) would otherwise be squeezed by
   the flex column down to its head. */
.kp-record-form > .card {
  flex-shrink: 0;
}

/* Role editor: each module block of the permission matrix folds away. */
.kp-matrix-toggle {
  flex: 0 0 auto;
  width: 24px;
  height: 24px;
}

.kp-matrix-toggle i {
  transition: transform .15s ease;
}

.kp-matrix-collapsed .kp-matrix-toggle i {
  transform: rotate(-90deg);
}

.kp-matrix-collapsed .kp-matrix-group-head {
  border-bottom-color: transparent;
}

.kp-role-matrix-card .kp-card-head {
  flex-wrap: wrap;
}

/* The panels that used to live in drawers (SAP sync, Territories): one column
   with the drawer's rhythm, now inside a card on the entity record page. */
.kp-panel-stack {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* Entity record page: tabs above one column of cards, as wide as a form. */
.kp-entity-record > .kp-rtabs,
.kp-entity-record > .card {
  width: 100%;
  max-width: 1320px;
}

.kp-entity-record > .card {
  flex-shrink: 0;
}

.kp-entity-record > .card + .card {
  margin-top: 16px;
}

/* Details tab: the identity card and the SAP connection card. One under the
   other on a laptop; side by side on a wide screen, each with its facts in one
   label and value column, so both fit on one screen with no blank strip. */
.kp-entity-details {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 16px;
  flex-shrink: 0;
  width: 100%;
  max-width: 1320px;
}

.kp-entity-details > .card {
  margin: 0;
}

@media (min-width: 1600px) {
  .kp-entity-details {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    max-width: none;
  }

  .kp-entity-record:has(> .kp-entity-details) > .kp-rtabs {
    max-width: none;
  }

  .kp-entity-details .kp-facts.kp-facts-2 {
    grid-template-columns: max-content minmax(0, 1fr);
  }
}

.kp-entity-record .card-body {
  padding: 20px 22px 22px;
}

.kp-entity-identity {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 18px;
}

.kp-entity-identity-text {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.kp-entity-identity-name {
  font-size: var(--kp-fs-card);
  font-weight: 700;
  letter-spacing: -.01em;
}

.kp-entity-identity-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.kp-entity-record .kp-sap-password {
  max-width: 480px;
  margin-top: 16px;
}

.kp-entity-record #kpSetSapPassword {
  margin-top: 16px;
}

/* Approval rule form: the step cards sit under one another at full width. */
.kp-record-form .kp-rulestep {
  margin-bottom: 12px;
  padding: 14px;
}

.kp-record-form .kp-rulestep .kp-form-grid {
  gap: 12px 20px;
}

/* Master form: the colour of a status is one of the ten swatches, each drawn
   as the pill it gives; the chosen one is ringed and ticked. */
.kp-swatch-choices {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.kp-status-pill.kp-swatch-choice {
  gap: 4px;
  height: 28px;
  padding: 0 12px;
  border: 0;
  line-height: 28px;
  cursor: pointer;
}

.kp-swatch-choice:focus-visible {
  outline: 2px solid var(--tblr-primary);
  outline-offset: 2px;
}

.kp-swatch-choice.is-selected {
  box-shadow: 0 0 0 2px var(--tblr-bg-surface), 0 0 0 4px var(--kp-swatch);
}

.kp-swatch-choice:disabled {
  cursor: default;
}

.kp-swatch-choice:disabled:not(.is-selected) {
  opacity: .5;
}

/* ---- Entity print logo (entity form and record page) ---------------------
   The logo prints on white paper, so its preview is white in both themes. */
.kp-logo-field {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* The help line and the buttons: under the box on a phone, to its right on
   anything wider, so the card is as tall as the box and no half of it is blank. */
.kp-logo-side {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 12px;
  min-width: 0;
}

.kp-logo-side > .kp-field-hint {
  margin: 0;
  max-width: 460px;
}

@media (min-width: 768px) {
  .kp-logo-field {
    flex-direction: row;
    align-items: flex-start;
    gap: 24px;
  }

  .kp-logo-field > .kp-logo-preview {
    flex: 1 1 0;
  }

  .kp-logo-side {
    flex: 1 1 0;
  }
}

/* Entity form: the colour field takes two columns so the twelve preset dots
   sit on one line; the hex code stays a short box. */
.kp-entity-colour .kp-colour-row .form-control:not(.form-control-color) {
  max-width: 160px;
}

.kp-logo-preview {
  display: flex;
  align-items: center;
  justify-content: center;
  max-width: 600px;
  min-height: 120px;
  padding: 16px;
  border: 1px dashed var(--tblr-border-color);
  border-radius: var(--kp-radius);
  background: #FFFFFF;
}

.kp-logo-preview img {
  max-width: 100%;
  max-height: 150px;
}

.kp-logo-empty {
  font-size: var(--kp-fs-body);
  color: #64748B;
  text-align: center;
}

.kp-logo-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.kp-logo-thumb {
  max-width: 240px;
  max-height: 80px;
  padding: 6px;
  border: 1px solid var(--tblr-border-color);
  border-radius: var(--kp-radius-sm);
  background: #FFFFFF;
}

/* Sales order form: the full SAP address under the bill-to and ship-to pickers. */
.kp-address-full {
  white-space: pre-line;
  margin-top: 6px;
  font-size: var(--kp-fs-small);
  line-height: 1.45;
  color: var(--tblr-secondary);
}

/* ---- SAP orders list (/salesOrder/sap) -------------------------------------
   The read-only list of orders entered in SAP: a one line note under the
   toolbar, and the order's lines in its side panel. */
.kp-list-note {
  margin: 0 0 10px;
  font-size: var(--kp-fs-small);
  color: var(--tblr-secondary);
}

.kp-sap-crm-tag {
  display: inline-block;
  margin-left: 6px;
  padding: 0 5px;
  border-radius: var(--kp-radius-pill);
  background: var(--kp-status-info-bg);
  color: var(--kp-status-info-fg);
  font-size: var(--kp-fs-label);
  font-weight: 600;
  line-height: 16px;
  vertical-align: 1px;
}

.kp-sap-lines {
  margin: 8px 0 0;
  padding: 0;
  list-style: none;
}

.kp-sap-lines > li {
  padding: 8px 0;
  border-bottom: 1px solid var(--tblr-border-color);
}

.kp-sap-lines > li:last-child {
  border-bottom: 0;
}

.kp-sap-line-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.kp-sap-line-head .kp-cell-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ==========================================================================
   29. List charts and "Needs attention"
   --------------------------------------------------------------------------
   The charts between a module list's toolbar and its table or board
   (imports/ui/components/kpInsightStrip.*, kpListCharts.*; the chart styles are
   further down, "List charts"). Folded, the strip is one line of pills. The
   button at the end of the row folds it.
   ========================================================================== */

.kp-attention-filter {
  flex: 0 0 auto;
  margin: 0 0 8px;
}

.kp-insights {
  display: flex;
  align-items: flex-start;
  gap: 4px;
  flex: 0 0 auto;
  min-width: 0;
  margin: -2px 0 12px;
}

/* The fold button at the end of the row. */
.kp-ins-toggle {
  margin-top: 4px;
}

.kp-ins-toggle:hover {
  background: var(--tblr-bg-surface-secondary);
  color: var(--tblr-body-color);
}

.kp-insights.is-compact .kp-ins-toggle {
  margin-top: 0;
}

/* ---------------------------------------------------------------------------
   List charts (kpListCharts, DESIGN.md section 2 "List charts"): four small
   charts above a module list. Thin marks, 4px rounded data ends, a 2px gap
   between touching segments, hairline axes; text in the text colours, never in
   the mark's. The ramp is one hue, validated for both themes (light end at
   least 2:1 on the card); in dark mode it runs dark to light, so the step that
   matters most is the brightest in both.
   --------------------------------------------------------------------------- */
:root {
  --kp-lc-mark: var(--kp-chart-1);
  --kp-lc-mark-soft: color-mix(in srgb, var(--kp-chart-1) 45%, var(--tblr-bg-surface));
  --kp-lc-step-1: #9AA6FA;
  --kp-lc-step-2: #6366F1;
  --kp-lc-step-3: #3730A3;
  --kp-lc-grid: #E6E7EB;
}

[data-bs-theme=dark] {
  --kp-lc-step-1: #4338CA;
  --kp-lc-step-2: #6D6FF2;
  --kp-lc-step-3: #A5B4FC;
  --kp-lc-grid: #2A2B30;
}

.kp-insights.kp-insights-charts {
  align-items: stretch;
}

.kp-lc-grid {
  flex: 1 1 auto;
  min-width: 0;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  align-items: stretch;
}

@media (max-width: 1199.98px) {
  .kp-lc-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 575.98px) {
  .kp-lc-grid { grid-template-columns: minmax(0, 1fr); }
}

.kp-insights.is-refreshing .kp-lc-grid {
  opacity: .6;
  transition: opacity .15s;
}

.kp-lc-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
  padding: 12px 14px;
  background: var(--tblr-bg-surface);
  border: 1px solid var(--tblr-border-color);
  border-radius: var(--kp-radius);
  box-shadow: var(--kp-card-shadow);
}

.kp-lc-head {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 22px;
}

.kp-lc-title {
  margin: 0;
  font-size: var(--kp-fs-body, 13px);
  font-weight: 600;
  white-space: nowrap;
}

.kp-lc-note {
  flex: 1 1 auto;
  min-width: 0;
  text-align: right;
  font-size: var(--kp-fs-small, 12px);
  line-height: 1.35;
  color: var(--tblr-secondary);
}

.kp-lc-head { align-items: flex-start; }
.kp-lc-title { line-height: 1.35; }

.kp-lc-head .kp-lc-flip {
  width: 22px;
  height: 22px;
  margin-right: -4px;
  color: var(--tblr-secondary);
  opacity: .7;
}

.kp-lc-head .kp-lc-flip:hover,
.kp-lc-head .kp-lc-flip:focus-visible { opacity: 1; }

/* Rows of label, bar and value: the funnel, ranked bars, stacked bars. */
/* One grid for all rows of a card (subgrid), so the label column is as wide as
   the longest label and the bars start at one line; a label is cut only past
   55% of the card. */
.kp-lc-rows {
  display: grid;
  grid-template-columns: fit-content(55%) minmax(32px, 1fr) auto;
  row-gap: 6px;
}

.kp-lc-rows > .kp-lc-legend { grid-column: 1 / -1; }

/* A next step under the bars, at the card's foot. */
.kp-lc-footnote {
  margin: auto 0 0;
  padding-top: 6px;
  border-top: 1px solid var(--kp-lc-grid);
  font-size: var(--kp-fs-small, 12px);
  color: var(--tblr-secondary);
}

/* The breakdown under a figure sits a step below it, at the card's foot. */
.kp-lc-breakdown { margin-top: auto; padding-top: 4px; }

.kp-lc-row {
  display: grid;
  grid-column: 1 / -1;
  grid-template-columns: subgrid;
  align-items: center;
  gap: 8px;
  font-size: var(--kp-fs-small, 12px);
  border-radius: 4px;
}

.kp-lc-row:focus-visible,
.kp-lc-seg:focus-visible,
.kp-lc-col-slot:focus-visible,
.kp-lc-meter:focus-visible {
  outline: 2px solid var(--tblr-primary);
  outline-offset: 2px;
}

.kp-lc-label {
  color: var(--tblr-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.kp-lc-value {
  min-width: 22px;
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  white-space: nowrap;
}

.kp-lc-value small {
  margin-left: 6px;
  font-size: inherit;
  font-weight: 400;
  color: var(--tblr-secondary);
}

.kp-lc-track {
  display: flex;
  height: 12px;
  min-width: 0;
}

.kp-lc-centre { justify-content: center; }

.kp-lc-bar {
  display: block;
  height: 100%;
  background: var(--kp-lc-mark);
  border-radius: 0 4px 4px 0;
}

/* A funnel bar stands on no baseline: rounded at both ends. */
.kp-lc-centre .kp-lc-bar { border-radius: 4px; }

.kp-lc-row:hover .kp-lc-bar { filter: brightness(1.12); }

/* Stacked bars: segments one hue in three steps, a 2px surface gap between. */
.kp-lc-stack { gap: 2px; }

.kp-lc-seg {
  display: block;
  height: 100%;
  min-width: 4px;
  cursor: default;
}

.kp-lc-seg:last-child { border-radius: 0 4px 4px 0; }
.kp-lc-seg:hover { filter: brightness(1.12); }

.kp-lc-step-1 { background: var(--kp-lc-step-1); }
.kp-lc-step-2 { background: var(--kp-lc-step-2); }
.kp-lc-step-3 { background: var(--kp-lc-step-3); }

.kp-lc-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 2px 12px;
  margin-top: 2px;
  font-size: 11px;
  color: var(--tblr-secondary);
}

.kp-lc-key {
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-right: 5px;
  border-radius: 2px;
  vertical-align: baseline;
}

/* A figure with its context: "2 new in the last 4 weeks, down 1". */
.kp-lc-figure {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 2px 8px;
}

.kp-lc-figure-value {
  font-size: 22px;
  font-weight: 600;
  line-height: 1.1;
}

.kp-lc-figure-text {
  font-size: var(--kp-fs-small, 12px);
  color: var(--tblr-secondary);
}

.kp-lc-delta {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  font-size: var(--kp-fs-small, 12px);
  color: var(--tblr-secondary);
}

.kp-lc-delta-good { color: var(--kp-status-success-fg, var(--tblr-success)); }
.kp-lc-delta-bad { color: var(--kp-status-danger-fg, var(--tblr-danger)); }

/* Columns per week: the last week in the full mark colour, the rest softer. */
.kp-lc-cols {
  position: relative;
  display: flex;
  align-items: flex-end;
  gap: 2px;
  height: 44px;
  border-bottom: 1px solid var(--kp-lc-grid);
}

.kp-lc-col-slot {
  flex: 1 1 0;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  height: 100%;
  min-width: 0;
  border-radius: 4px 4px 0 0;
}

.kp-lc-col {
  display: block;
  width: 100%;
  max-width: 24px;
  background: var(--kp-lc-mark-soft);
  border-radius: 4px 4px 0 0;
}

.kp-lc-col.is-current { background: var(--kp-lc-mark); }
.kp-lc-col-slot:hover .kp-lc-col { filter: brightness(1.12); }

/* The weekly average: a solid hairline, recessive. */
.kp-lc-avg {
  position: absolute;
  left: 0;
  right: 0;
  height: 0;
  border-top: 1px solid var(--tblr-secondary);
  opacity: .45;
  pointer-events: none;
}

.kp-lc-axis {
  display: flex;
  justify-content: space-between;
  margin-top: -4px;
  font-size: 11px;
  color: var(--tblr-secondary);
}

/* A meter: the share in the mark colour on a track of the same hue. */
.kp-lc-meter {
  display: block;
  height: 6px;
  border-radius: 3px;
  background: color-mix(in srgb, var(--kp-lc-mark) 16%, var(--tblr-bg-surface));
  overflow: hidden;
}

.kp-lc-meter > span {
  display: block;
  height: 100%;
  border-radius: 3px;
  background: var(--kp-lc-mark);
}

.kp-lc-meter-danger { background: color-mix(in srgb, var(--tblr-danger) 16%, var(--tblr-bg-surface)); }
.kp-lc-meter-danger > span { background: var(--tblr-danger); }
.kp-lc-meter-warning { background: color-mix(in srgb, var(--tblr-warning) 18%, var(--tblr-bg-surface)); }
.kp-lc-meter-warning > span { background: var(--tblr-warning); }

.kp-lc-sub {
  font-size: var(--kp-fs-small, 12px);
  color: var(--tblr-secondary);
}

/* "Needs attention": each rule a row with its icon, count and share of the
   open records. A row narrows the list to what the rule flags. */
.kp-lc-attn {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.kp-lc-attn-row {
  display: grid;
  grid-template-columns: 16px minmax(0, 1fr) auto;
  align-items: center;
  column-gap: 8px;
  row-gap: 3px;
  width: 100%;
  margin: 0;
  padding: 3px 6px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: none;
  color: inherit;
  font: inherit;
  font-size: var(--kp-fs-small, 12px);
  text-align: left;
  cursor: pointer;
}

.kp-lc-attn-row .kp-lc-meter {
  grid-column: 2 / 4;
  height: 4px;
}

.kp-lc-attn-row:hover:not(:disabled) { background: var(--tblr-bg-surface-secondary); }
.kp-lc-attn-row:focus-visible { outline: 2px solid var(--tblr-primary); outline-offset: 1px; }

.kp-lc-attn-row.is-active {
  border-color: var(--tblr-primary);
  background: color-mix(in srgb, var(--tblr-primary) 8%, var(--tblr-bg-surface));
}

.kp-lc-attn-row:disabled {
  cursor: default;
  color: var(--tblr-secondary);
}

.kp-lc-attn-row:disabled .kp-lc-value { font-weight: 400; }

.kp-lc-attn-label {
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.kp-lc-tone-danger { color: var(--tblr-danger); }
.kp-lc-tone-warning { color: var(--kp-status-warning-fg, var(--tblr-warning)); }

/* The table view of a chart. */
.kp-lc-table-wrap {
  max-height: 150px;
  overflow: auto;
}

.kp-lc-table {
  width: 100%;
  font-size: var(--kp-fs-small, 12px);
  border-collapse: collapse;
}

.kp-lc-table th {
  font-weight: 500;
  color: var(--tblr-secondary);
  text-align: left;
  padding: 0 6px 4px 0;
  border-bottom: 1px solid var(--kp-lc-grid);
}

.kp-lc-table td {
  padding: 3px 6px 3px 0;
  border-bottom: 1px solid var(--kp-lc-grid);
  font-variant-numeric: tabular-nums;
}

.kp-lc-table td:not(:first-child),
.kp-lc-table th:not(:first-child) { text-align: right; }

/* Folded: the key numbers as one line of pills. */
.kp-lc-folded {
  flex: 1 1 auto;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  min-height: 30px;
}

.kp-lc-pill {
  padding: 3px 10px;
  border: 1px solid var(--tblr-border-color);
  border-radius: 999px;
  background: var(--tblr-bg-surface);
  font-size: var(--kp-fs-small, 12px);
}

/* The one tooltip: the value leads, on the raised surface. */
.kp-lc-tip {
  position: fixed;
  z-index: 2000;
  max-width: 260px;
  padding: 5px 9px;
  border-radius: 6px;
  background: var(--tblr-gray-900, #1F2937);
  color: #FFFFFF;
  font-size: var(--kp-fs-small, 12px);
  line-height: 1.4;
  pointer-events: none;
  opacity: 0;
  transform: translateY(2px);
  transition: opacity .1s, transform .1s;
}

[data-bs-theme=dark] .kp-lc-tip {
  background: #F4F4F5;
  color: #111113;
}

.kp-lc-tip.is-on {
  opacity: 1;
  transform: none;
}

/* Rows a "Needs attention" rule flags: a bar on the left edge in the worst
   tone, and the reasons as one line under the name (DESIGN.md "List rows"). */
.kp-table tr.kp-flag-danger > td:first-child { box-shadow: inset 3px 0 0 var(--tblr-danger); }
.kp-table tr.kp-flag-warning > td:first-child { box-shadow: inset 3px 0 0 var(--tblr-warning); }

.kp-row-reasons {
  display: block;
  font-size: var(--kp-fs-small, 12px);
  line-height: 1.4;
  white-space: normal;
}

.kp-row-reason-danger { color: var(--kp-status-danger-fg, var(--tblr-danger)); }
.kp-row-reason-warning { color: var(--kp-status-warning-fg, #B45309); }

/* The reasons: small chips in the side panel. */
.kp-why {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 4px;
}

.kp-why-chip {
  display: inline-flex;
  align-items: center;
  padding: 1px 8px;
  border-radius: 6px;
  font-size: var(--kp-fs-small);
  font-weight: 500;
  line-height: 1.6;
  white-space: nowrap;
}

.kp-why-warning {
  background: var(--kp-status-warning-bg);
  color: var(--kp-status-warning-fg);
}

.kp-why-danger {
  background: var(--kp-status-danger-bg);
  color: var(--kp-status-danger-fg);
}

.kp-insp-attention {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 0 0 12px;
  padding: 10px 12px;
  border: 1px solid color-mix(in srgb, var(--tblr-warning) 35%, var(--tblr-border-color));
  border-radius: 8px;
  background: color-mix(in srgb, var(--tblr-warning) 6%, var(--tblr-bg-surface));
}

.kp-insp-attention-title {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--kp-status-warning-fg);
  font-size: var(--kp-fs-small);
  font-weight: 600;
}

.kp-insp-attention-title .ti {
  font-size: 14px;
}

/* The board header: the weighted value under the column total. */
.kp-board-col-head:has(.kp-board-col-sub) {
  flex-wrap: wrap;
  row-gap: 2px;
}

.kp-board-col-sub {
  flex: 1 0 100%;
  color: var(--tblr-secondary);
  font-size: var(--kp-fs-small);
  font-weight: 500;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* Home: the "Needs attention" card spans the grid, one tile per module list. */
.kp-hue-orange { --kp-card-hue: #EA580C; --kp-card-hue-soft: #FFF7ED; }

[data-bs-theme="dark"] .kp-hue-orange {
  --kp-card-hue: #FB923C;
  --kp-card-hue-soft: color-mix(in srgb, #FB923C 18%, var(--tblr-bg-surface));
}

.kp-home-wide {
  grid-column: 1 / -1;
}

/* auto-fit, not auto-fill: the tiles that exist share the whole card, so a
   wide screen has no empty tracks to their right. 180px lets the five module
   tiles share one row at 1366px. */
.kp-home-attn-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
}

/* Dark mode: a warm tint turns brown on near-black, so the box takes the
   raised grey and keeps its colour on the border. */
[data-bs-theme="dark"] .kp-home-attn {
  background: var(--tblr-bg-surface-secondary);
}

.kp-home-attn-grid > .kp-home-empty {
  grid-column: 1 / -1;
}

.kp-home-attn {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
  padding: 12px 14px;
  border: 1px solid color-mix(in srgb, var(--kp-card-hue) 25%, var(--tblr-border-color));
  border-radius: 10px;
  background: color-mix(in srgb, var(--kp-card-hue) 4%, var(--tblr-bg-surface));
  color: var(--tblr-body-color);
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: border-color .15s ease-out, box-shadow .15s ease-out, transform .15s ease-out;
}

.kp-home-attn:hover {
  border-color: color-mix(in srgb, var(--kp-card-hue) 55%, var(--tblr-border-color));
  box-shadow: var(--kp-card-shadow-hover);
  transform: translateY(-1px);
}

.kp-home-attn:focus-visible {
  outline: 2px solid color-mix(in srgb, var(--tblr-primary) 40%, transparent);
  outline-offset: 2px;
}

.kp-home-attn-head {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.kp-home-attn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  flex: 0 0 26px;
  border-radius: 7px;
  background: var(--kp-card-hue-soft);
  color: var(--kp-card-hue);
  font-size: 15px;
}

.kp-home-attn-title {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.kp-home-attn-count {
  font-size: var(--kp-fs-title);
  font-weight: 700;
  line-height: 1;
  color: var(--kp-card-hue);
  font-variant-numeric: tabular-nums;
}

.kp-home-attn-reasons {
  color: var(--tblr-secondary);
  font-size: var(--kp-fs-small);
  line-height: 1.45;
}

.kp-home-attn-go {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-top: auto;
  color: var(--tblr-primary);
  font-size: var(--kp-fs-small);
  font-weight: 600;
}

@media (prefers-reduced-motion: reduce) {
  .kp-home-attn,
  .kp-home-attn:hover {
    transition: none;
    transform: none;
  }
}

/* Masters > Attention rules (/masters/attention): one card per module list,
   one line per rule, the number of days typed inside the sentence. */
.kp-ar-form {
  gap: 0;
}

.kp-ar-intro {
  max-width: 88ch;
  margin: 0 0 14px;
  color: var(--tblr-secondary);
  font-size: var(--kp-fs-body);
  line-height: 1.6;
}

.kp-ar-intro strong {
  color: var(--tblr-body-color);
  font-weight: 600;
}

.kp-ar-entity {
  margin-left: 2px;
  padding: 0 8px;
  vertical-align: 1px;
}

/* Columns the cards flow down, not a grid of rows: each column is its own
   stack, so a short card leaves no blank band beside a tall one. Two columns
   on a laptop, three on a wide screen, one on a phone. */
.kp-ar-grid {
  columns: 440px;
  column-gap: 16px;
}

.kp-ar-grid > .kp-ar-card {
  break-inside: avoid;
  margin: 0 0 16px;
}

.kp-record-form.kp-ar-form .kp-ar-card .card-body {
  padding: 16px 18px 8px;
}

.kp-record-form.kp-ar-form .kp-ar-head {
  margin-bottom: 6px;
}

.kp-ar-tile {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  flex: 0 0 28px;
  border-radius: 8px;
  background: var(--kp-primary-soft);
  color: var(--tblr-primary);
  font-size: 16px;
}

.kp-ar-on {
  margin-left: auto;
  color: var(--tblr-secondary);
  font-size: var(--kp-fs-small);
  font-weight: 500;
}

.kp-ar-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.kp-ar-rule {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 0;
  border-top: 1px solid var(--tblr-border-color);
}

.kp-ar-rule:first-child {
  border-top: 0;
}

.kp-ar-switch {
  flex: 0 0 auto;
  min-height: 0;
  margin: 2px 0 0;
  padding-left: 2.5em;
}

.kp-ar-main {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.kp-ar-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  cursor: pointer;
}

.kp-ar-changed {
  color: var(--tblr-primary);
  font-size: var(--kp-fs-small);
  font-weight: 600;
}

.kp-ar-sentence {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  color: var(--tblr-body-color);
  font-size: var(--kp-fs-body);
  line-height: 1.45;
}

.kp-ar-sentence > .kp-ar-days.form-control {
  width: 72px;
  height: 30px;
  min-height: 0;
  padding: 2px 8px;
  font-size: var(--kp-fs-body);
  text-align: right;
}

.kp-ar-default {
  align-self: flex-start;
  font-size: var(--kp-fs-small);
}

/* A rule that is off reads as off: grey, its chip and sentence faded. */
.kp-ar-rule.is-off .kp-ar-sentence,
.kp-ar-rule.is-off .kp-why-chip {
  opacity: .5;
}

/* ==========================================================================
   30. Scrollbars
   --------------------------------------------------------------------------
   One quiet scrollbar for the whole application, every page and every layer
   (login, print previews, dropdowns and dialogs appended to <body>): thin,
   rounded, no track, the thumb faint at rest and darker while the pointer is
   over the area that scrolls. It replaces Tabler's own. `:where()` keeps it at
   zero specificity, so a place that hides its scrollbar on purpose (the tab
   strip, the stage bar, the record tabs) still wins. No component styles its
   own scrollbar: change the look here.
   ========================================================================== */

:root {
  --kp-scroll-thumb: color-mix(in srgb, var(--tblr-secondary) 28%, transparent);
  --kp-scroll-thumb-hover: color-mix(in srgb, var(--tblr-secondary) 55%, transparent);
}

:where(*) {
  scrollbar-width: thin;
  scrollbar-color: var(--kp-scroll-thumb) transparent;
}

:where(*):hover {
  scrollbar-color: var(--kp-scroll-thumb-hover) transparent;
}

/* Tabler styles dialog bodies with a class selector of its own. */
.modal-body {
  scrollbar-color: var(--kp-scroll-thumb) transparent;
}

.modal-body:hover {
  scrollbar-color: var(--kp-scroll-thumb-hover) transparent;
}

/* Browsers without the standard properties (older Safari): the same look. */
@supports not (scrollbar-color: auto) {
  ::-webkit-scrollbar {
    width: 10px;
    height: 10px;
  }

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

  ::-webkit-scrollbar-thumb {
    border: 3px solid transparent;
    border-radius: 999px;
    box-shadow: none;
    background: var(--kp-scroll-thumb);
    background-clip: padding-box;
  }

  :hover::-webkit-scrollbar-thumb {
    background-color: var(--kp-scroll-thumb-hover);
  }
}

/* Home: pinned views. Each shortcut has the list's icon and a remove button
   that shows on hover or focus. */
.kp-home-pin {
  position: relative;
}

.kp-home-pin > .kp-home-row {
  padding-right: 44px;
}

.kp-home-pin-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  flex: 0 0 28px;
  border-radius: 8px;
  background: var(--kp-card-hue-soft);
  color: var(--kp-card-hue);
  font-size: 15px;
}

.kp-home-pin-remove {
  position: absolute;
  top: 50%;
  right: 6px;
  transform: translateY(-50%);
  opacity: 0;
  transition: opacity .15s ease-out;
}

.kp-home-pin:hover .kp-home-pin-remove,
.kp-home-pin-remove:focus-visible {
  opacity: 1;
}

.kp-home-pin-remove:hover {
  background: var(--kp-status-danger-bg);
  color: var(--tblr-danger);
}

@media (hover: none) {
  .kp-home-pin-remove {
    opacity: 1;
  }
}

/* "Pin to Home" in a list toolbar: pinned reads as on. */
.kp-pin-btn.is-pinned {
  border-color: color-mix(in srgb, var(--tblr-primary) 45%, var(--tblr-border-color));
  background: var(--kp-primary-soft);
  color: var(--tblr-primary);
}

.kp-pin-summary {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 12px;
}

.kp-pin-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.kp-pin-chip {
  padding: 1px 8px;
  border-radius: 6px;
  background: var(--tblr-bg-surface-secondary);
  border: 1px solid var(--tblr-border-color);
  font-size: var(--kp-fs-small);
}

.kp-pin-none {
  color: var(--tblr-secondary);
  font-size: var(--kp-fs-small);
}

/* ==========================================================================
   31. Session: the inactivity warning (imports/ui/shell/session.js)
   ========================================================================== */

.kp-session-warning {
  z-index: 1090;
  text-align: left;
}

.kp-confirm-backdrop:has(+ .kp-session-warning) {
  z-index: 1089;
}

.kp-session-warning-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  margin-bottom: 10px;
  border-radius: 10px;
  background: color-mix(in srgb, var(--tblr-warning) 16%, transparent);
  color: var(--tblr-warning);
  font-size: 20px;
}

.kp-session-warning .js-session-left {
  color: var(--tblr-body-color);
  font-variant-numeric: tabular-nums;
}

/* ==========================================================================
   32. Reports (imports/ui/pages/reports)
   --------------------------------------------------------------------------
   The list at /reports, and one report: a view card (table, summary, chart)
   with the filter chips above it and the Customise panel beside it. The
   panel sits on the right from 1100px and moves under the view below that.
   ========================================================================== */

/* --- The list ------------------------------------------------------------ */
.kp-rl-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

.kp-rl-search {
  position: relative;
  flex: 1 1 240px;
  max-width: 360px;
}

.kp-rl-search > i {
  position: absolute;
  top: 50%;
  left: 10px;
  transform: translateY(-50%);
  color: var(--tblr-secondary);
  pointer-events: none;
}

.kp-rl-search .form-control {
  height: 32px;
  padding-left: 32px;
}

/* The approval buckets above a module list: the caller's own records, the ones
   waiting for their approval, the ones they decided. */
.kp-approval-bucket {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  margin: 0 0 12px;
}

.kp-approval-bucket .kp-field-hint {
  margin: 0;
}

.kp-seg-count {
  margin-left: 6px;
  padding: 0 6px;
  border-radius: var(--kp-radius-pill);
  background: color-mix(in srgb, var(--tblr-secondary) 14%, transparent);
  font-size: var(--kp-fs-label);
  font-variant-numeric: tabular-nums;
}

.kp-rl-folders {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.kp-rl-folder {
  flex: none;
  overflow: hidden;
}

.kp-rl-folder-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--tblr-border-color);
  color: var(--tblr-secondary);
}

.kp-rl-folder-head h2 {
  margin: 0;
  font-size: var(--kp-fs-body);
  font-weight: 600;
  color: var(--tblr-body-color);
}

.kp-rl-folder-count {
  font-size: var(--kp-fs-small);
  font-variant-numeric: tabular-nums;
}

.kp-rl-table {
  margin: 0;
}

.kp-rl-row {
  cursor: pointer;
}

.kp-rl-row.is-selected > td {
  background: var(--kp-primary-soft);
}

.kp-rl-star-cell {
  width: 40px;
}

.kp-rl-star {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border: 0;
  border-radius: var(--kp-radius-sm);
  background: transparent;
  color: var(--tblr-secondary);
  font-size: 16px;
}

.kp-rl-star:hover {
  background: var(--tblr-bg-surface-secondary);
}

.kp-rl-star.is-on {
  color: #D97706;
}

.kp-rl-name {
  display: block;
  font-weight: 600;
  color: var(--tblr-body-color);
}

.kp-rl-desc {
  display: block;
  max-width: 60ch;
  overflow: hidden;
  font-size: var(--kp-fs-small);
  color: var(--tblr-secondary);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.kp-rl-source,
.kp-rl-view {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: var(--kp-fs-body);
  white-space: nowrap;
}

.kp-rl-source i,
.kp-rl-view i {
  color: var(--tblr-secondary);
}

.kp-rl-owner-cell,
.kp-rl-when-cell {
  font-size: var(--kp-fs-body);
  color: var(--tblr-secondary);
  white-space: nowrap;
}

.kp-rl-mine {
  font-weight: 600;
  color: var(--tblr-body-color);
}

.kp-rl-vis {
  margin-left: 6px;
}

.kp-rl-insp-desc,
.kp-rl-insp-note {
  margin: 8px 0;
  font-size: var(--kp-fs-body);
  color: var(--tblr-secondary);
}

/* --- The report page ------------------------------------------------------ */
.kp-rep-body {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 12px;
  flex: 1 1 auto;
  min-height: 0;
}

@media (min-width: 1100px) {
  .kp-rep-body.has-design {
    grid-template-columns: minmax(0, 1fr) 300px;
  }
}

.kp-rep-main {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
  min-height: 0;
}

.kp-rep-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.kp-rep-scope {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-left: auto;
  font-size: var(--kp-fs-small);
  color: var(--tblr-secondary);
}

.kp-rep-filters {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.kp-rep-chip {
  display: inline-flex;
  align-items: stretch;
  max-width: 100%;
  border: 1px solid color-mix(in srgb, var(--tblr-primary) 35%, var(--tblr-border-color));
  border-radius: var(--kp-radius-pill);
  background: var(--kp-primary-soft);
  color: var(--tblr-body-color);
  font-size: var(--kp-fs-small);
}

.kp-rep-chip-text,
.kp-rep-chip-x {
  border: 0;
  background: transparent;
  color: inherit;
}

.kp-rep-chip-text {
  overflow: hidden;
  padding: 3px 4px 3px 10px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.kp-rep-chip-x {
  display: inline-flex;
  align-items: center;
  padding: 0 8px 0 4px;
  color: var(--tblr-secondary);
}

.kp-rep-chip-x:hover {
  color: var(--tblr-danger);
}

.kp-rep-addfilter {
  border-style: dashed;
}

.kp-rep-clear {
  padding-inline: 4px;
  font-size: var(--kp-fs-small);
}

.kp-rep-view {
  display: flex;
  flex-direction: column;
  flex: 0 1 auto;
  min-height: 160px;
  overflow: hidden;
}

.kp-rep-view > .kp-table-wrap {
  flex: 0 1 auto;
  min-height: 0;
}

.kp-rep-table {
  margin: 0;
}

.kp-rep-table thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--tblr-bg-surface);
  white-space: nowrap;
}

.kp-rep-table td {
  white-space: nowrap;
  max-width: 320px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.kp-rep-table tbody tr.is-link {
  cursor: pointer;
}

.kp-rep-table tfoot td,
.kp-rep-table tfoot th {
  position: sticky;
  bottom: 0;
  background: var(--tblr-bg-surface-secondary);
  font-weight: 600;
  border-top: 1px solid var(--tblr-border-color);
}

.kp-rep-th {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  text-transform: inherit;
  letter-spacing: inherit;
}

.kp-num .kp-rep-th {
  flex-direction: row-reverse;
}

.kp-rep-sort-idle {
  opacity: 0;
}

.kp-rep-th:hover .kp-rep-sort-idle,
.kp-rep-th:focus-visible .kp-rep-sort-idle {
  opacity: .5;
}

.kp-rep-pager {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 12px;
  border-top: 1px solid var(--tblr-border-color);
  font-size: var(--kp-fs-small);
  color: var(--tblr-secondary);
  font-variant-numeric: tabular-nums;
}

.kp-rep-pager-btns {
  display: flex;
  gap: 4px;
}

/* Summary */
.kp-rep-tiles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  padding: 16px;
}

.kp-rep-tile {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 14px 16px;
  border: 1px solid var(--tblr-border-color);
  border-radius: var(--kp-radius);
}

.kp-rep-tile-label {
  font-size: var(--kp-fs-small);
  color: var(--tblr-secondary);
}

.kp-rep-tile-value {
  font-size: var(--kp-fs-display);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.kp-rep-sum tbody tr {
  cursor: pointer;
}

.kp-rep-sum th[scope="row"],
.kp-rep-cross th[scope="row"] {
  font-weight: 500;
  white-space: nowrap;
}

.kp-rep-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-right: 8px;
  border-radius: 50%;
  background: var(--kp-dot);
  vertical-align: 1px;
}

.kp-rep-bar-track {
  display: block;
  height: 3px;
  margin-top: 4px;
  border-radius: 2px;
  background: var(--tblr-bg-surface-secondary);
}

.kp-rep-bar-fill {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--tblr-primary);
  margin-left: auto;
}

.kp-rep-cross td {
  background: color-mix(in srgb, var(--tblr-primary) calc(var(--kp-heat, 0%) * .18), transparent);
}

.kp-rep-cross td.is-link {
  cursor: pointer;
}

.kp-rep-cross td.is-link:hover,
.kp-rep-cross td.is-link:focus-visible {
  box-shadow: inset 0 0 0 1px var(--tblr-primary);
  outline: none;
}

.kp-rep-cross td.is-empty {
  color: var(--tblr-secondary);
}

.kp-rep-rowtotal {
  font-weight: 600;
}

.kp-rep-corner {
  white-space: nowrap;
}

.kp-rep-corner-sep {
  margin: 0 4px;
  color: var(--tblr-secondary);
}

.kp-rep-subbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--tblr-border-color);
  font-size: var(--kp-fs-small);
}

/* As wide as the choice it shows ("Sum of estimated value"), within limits:
   it gives way only when the bar runs out of room, never beside free space. */
.kp-rep-select {
  flex: 0 1 auto;
  width: auto;
  min-width: 140px;
  max-width: 360px;
}

.kp-rep-select.kp-picker:not(.kp-picker-multi) .kp-picker-single + .kp-picker-search {
  flex: 0 0 24px;
  width: 24px;
}

.kp-rep-select.kp-picker-nosearch:not(.kp-picker-multi) .kp-picker-single + .kp-picker-search {
  flex: 0 0 0;
  width: 0;
}

.kp-rep-inline {
  margin: 0 0 0 6px;
  color: var(--tblr-secondary);
}

.kp-rep-stack {
  margin: 0 0 0 4px;
}

.kp-rep-note {
  margin: 0;
  padding: 8px 12px;
  font-size: var(--kp-fs-small);
  color: var(--tblr-secondary);
}

/* Chart */
.kp-rep-chart {
  position: relative;
  /* The chart takes the height the window has left under the toolbar, the
     filter chips and the chart bar, so a tall window is not left a third blank. */
  height: clamp(280px, calc(100vh - 380px), 720px);
  padding: 12px 16px;
}

.kp-rep-chart.is-donut {
  height: clamp(260px, 42vh, 400px);
}

.kp-rep-chart-skeleton {
  padding: 16px;
}

/* "Pin to Home" sits at the end of the chart bar. */
.kp-rep-pin {
  margin-left: auto;
}

.kp-rep-pin.is-on {
  border-color: color-mix(in srgb, var(--tblr-primary) 40%, var(--tblr-border-color));
  background: var(--kp-primary-soft);
  color: var(--tblr-primary);
}

/* A report chart pinned to Home (imports/ui/pages/home/reportChart.html). */
.kp-home-chart-title {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  min-width: 0;
  flex: 1 1 auto;
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  text-align: left;
  cursor: pointer;
}

.kp-home-chart-title .card-title {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.kp-home-chart-title:hover .card-title,
.kp-home-chart-title:focus-visible .card-title {
  color: var(--tblr-primary);
  text-decoration: underline;
}

.kp-home-chart-sub {
  font-size: var(--kp-fs-small);
  color: var(--tblr-secondary);
}

.kp-home-chart-body {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  min-height: 280px;
}

.kp-home-chart-canvas {
  position: relative;
  height: 280px;
  padding: 8px 14px 12px;
}

@media (max-width: 575.98px) {
  .kp-rep-type-label {
    display: none;
  }

  .kp-rep-scope {
    margin-left: 0;
  }
}

/* Customise panel */
.kp-rep-design {
  display: flex;
  flex-direction: column;
  min-height: 0;
  max-height: 100%;
  overflow: hidden;
}

.kp-rep-design-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border-bottom: 1px solid var(--tblr-border-color);
}

.kp-rep-design-head h2 {
  margin: 0;
  font-size: var(--kp-fs-body);
  font-weight: 600;
}

.kp-rep-design-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  padding: 4px 12px 12px;
}

.kp-rep-sec {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 12px 0;
  border-bottom: 1px solid var(--tblr-border-color);
}

.kp-rep-sec:last-child {
  border-bottom: 0;
}

.kp-rep-sec h3 {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0 0 2px;
  font-size: var(--kp-fs-small);
  font-weight: 600;
  color: var(--tblr-secondary);
}

.kp-rep-sec-count {
  font-variant-numeric: tabular-nums;
}

.kp-rep-cols,
.kp-rep-measures {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.kp-rep-col {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 3px 2px 3px 6px;
  border-radius: var(--kp-radius-sm);
  font-size: var(--kp-fs-small);
}

.kp-rep-col:hover {
  background: var(--tblr-bg-surface-secondary);
}

.kp-rep-col-type {
  flex: none;
  width: 18px;
  color: var(--tblr-secondary);
}

.kp-rep-col-name {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.kp-rep-line-tag {
  margin-left: 6px;
  padding: 0 5px;
  border-radius: 4px;
  background: var(--tblr-bg-surface-secondary);
  font-size: var(--kp-fs-label);
  color: var(--tblr-secondary);
}

.kp-icon-btn.kp-rep-mini {
  width: 24px;
  height: 24px;
  font-size: 13px;
}

.kp-icon-btn.kp-rep-mini:disabled {
  opacity: .3;
}

.kp-rep-lbl {
  margin-top: 4px;
  font-size: var(--kp-fs-small);
  font-weight: 500;
}

.kp-rep-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.kp-rep-row > .kp-picker,
.kp-rep-row > .form-control {
  flex: 1 1 auto;
  min-width: 0;
}

.kp-rep-row > .kp-rep-bucket,
.kp-rep-row > .kp-rep-fn {
  flex: 0 0 104px;
  width: 104px;
}

.kp-rep-hint {
  margin: 0;
  font-size: var(--kp-fs-small);
  color: var(--tblr-secondary);
}

.kp-rep-full {
  display: flex;
}

.kp-rep-full > .kp-viewswitch-btn {
  flex: 1 1 0;
  justify-content: center;
}

/* Source picker */
.kp-rep-pick {
  padding: 8px 0 24px;
}

.kp-rep-pick-title {
  margin: 0 0 4px;
  font-size: var(--kp-fs-title);
  font-weight: 700;
  text-wrap: balance;
}

.kp-rep-pick-sub {
  margin: 0 0 16px;
  color: var(--tblr-secondary);
}

.kp-rep-pick-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
}

.kp-rep-source {
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr);
  grid-template-rows: auto auto;
  column-gap: 12px;
  align-items: center;
  padding: 14px;
  border: 1px solid var(--tblr-border-color);
  border-radius: var(--kp-radius);
  background: var(--tblr-bg-surface);
  text-align: left;
  transition: border-color 120ms ease, box-shadow 120ms ease;
}

.kp-rep-source:hover,
.kp-rep-source:focus-visible {
  border-color: var(--tblr-primary);
  box-shadow: 0 0 0 1px var(--tblr-primary);
}

.kp-rep-source.is-skeleton {
  display: block;
  min-height: 70px;
}

.kp-rep-source-icon {
  grid-row: span 2;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: var(--kp-primary-soft);
  color: var(--tblr-primary);
  font-size: 20px;
}

.kp-rep-source-name {
  font-weight: 600;
  color: var(--tblr-body-color);
}

.kp-rep-source-meta {
  font-size: var(--kp-fs-small);
  color: var(--tblr-secondary);
}

/* Dialogs */
.kp-confirm.kp-rep-fdlg,
.kp-confirm.kp-rep-sdlg {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: min(480px, calc(100vw - 32px));
  max-height: calc(100vh - 48px);
  overflow: auto;
}

.kp-rep-fields,
.kp-rep-values {
  display: flex;
  flex-direction: column;
  max-height: 320px;
  overflow: auto;
  border: 1px solid var(--tblr-border-color);
  border-radius: var(--kp-radius-sm);
}

.kp-rep-fgroup {
  display: flex;
  flex-direction: column;
  padding: 4px 0;
}

.kp-rep-fgroup-label {
  padding: 4px 10px;
  font-size: var(--kp-fs-small);
  font-weight: 600;
  color: var(--tblr-secondary);
}

.kp-rep-fpick {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border: 0;
  background: transparent;
  color: var(--tblr-body-color);
  font-size: var(--kp-fs-body);
  text-align: left;
}

.kp-rep-fpick:hover,
.kp-rep-fpick:focus-visible {
  background: var(--kp-primary-soft);
}

.kp-rep-fpick i {
  width: 16px;
  color: var(--tblr-secondary);
}

.kp-rep-value {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  padding: 6px 10px;
  font-size: var(--kp-fs-body);
  cursor: pointer;
}

.kp-rep-value:hover {
  background: var(--tblr-bg-surface-secondary);
}

.kp-rep-value .form-check-input {
  flex: none;
  margin: 0;
}

.kp-rep-value .kp-rep-dot {
  margin-right: 0;
}

.kp-rep-value-label {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.kp-rep-value-count {
  font-size: var(--kp-fs-small);
  color: var(--tblr-secondary);
  font-variant-numeric: tabular-nums;
}

.kp-rep-values > .kp-skeleton {
  padding: 8px 10px;
}

.kp-rep-values > .kp-rep-hint {
  padding: 10px;
}

.kp-rep-to {
  color: var(--tblr-secondary);
  font-size: var(--kp-fs-small);
}

.kp-rep-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.kp-rep-preset {
  padding: 3px 10px;
  border: 1px solid var(--tblr-border-color);
  border-radius: var(--kp-radius-pill);
  background: var(--tblr-bg-surface);
  color: var(--tblr-body-color);
  font-size: var(--kp-fs-small);
}

.kp-rep-preset.is-on {
  border-color: var(--tblr-primary);
  background: var(--kp-primary-soft);
  color: var(--tblr-primary);
  font-weight: 600;
}

.kp-rep-vis {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin: 0 0 8px;
  cursor: pointer;
}

.kp-rep-vis .form-check-input {
  flex: none;
  margin-top: 3px;
}

.kp-rep-vis-label {
  display: block;
  font-size: var(--kp-fs-body);
  font-weight: 500;
}

.kp-rep-vis-hint {
  display: block;
  font-size: var(--kp-fs-small);
  color: var(--tblr-secondary);
}

.kp-rep-dirty {
  display: inline-block;
  width: 7px;
  height: 7px;
  margin-left: 6px;
  border-radius: 50%;
  background: #F59E0B;
}

/* Every folder is its own table: fixed widths keep the columns in line. */
.kp-rl-table {
  table-layout: fixed;
}

.kp-rl-name-cell { width: auto; }
.kp-rl-source-cell { width: 170px; }
.kp-rl-view-cell { width: 110px; }
.kp-rl-owner-cell { width: 150px; }
.kp-rl-when-cell { width: 120px; }

.kp-rl-name-cell .kp-rl-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@media (max-width: 767.98px) {
  .kp-rl-source-cell { width: 130px; }
}

/* The star on a lead, an account or an opportunity (kpFavStar). In a table
   row it sits before the name and stays out of the way until hovered or on. */
.kp-fav-star {
  flex: 0 0 auto;
  vertical-align: middle;
}

.kp-table td .kp-fav-star {
  width: 24px;
  height: 24px;
  margin: -2px 2px -2px -6px;
  font-size: 15px;
}

.kp-table tr:not(:hover) .kp-fav-star:not(.is-on):not(:focus-visible) {
  opacity: 0.35;
}

/* ==========================================================================
   Filter bar: the date range chip and the "Filters" button (kpFilters)
   ========================================================================== */
.kp-chip-toggle.is-active {
  border-color: var(--tblr-primary);
  background: rgba(var(--tblr-primary-rgb), 0.08);
  color: var(--tblr-primary);
}

.kp-chip-toggle.is-active i {
  color: inherit;
}

.kp-chip-toggle .kp-chip-caret {
  margin-left: 2px;
  font-size: 12px;
}

.kp-chip-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 17px;
  height: 17px;
  padding: 0 5px;
  border-radius: var(--kp-radius-pill);
  background: var(--tblr-primary);
  color: #fff;
  font-size: var(--kp-fs-label);
  font-weight: 600;
}

.kp-datechip,
.kp-morefilters {
  position: relative;
  display: inline-flex;
}

.kp-datechip-menu,
.kp-morefilters-panel {
  position: absolute;
  z-index: 1055;
  top: calc(100% + 4px);
  left: 0;
  padding: 6px;
  border: 1px solid var(--tblr-border-color);
  border-radius: var(--kp-radius);
  background: var(--tblr-bg-surface);
  box-shadow: var(--kp-shadow-float, 0 8px 24px rgba(15, 23, 42, .12));
}

.kp-datechip-menu {
  display: flex;
  flex-direction: column;
  min-width: 250px;
}

/* A popover that would run off the right of the window hangs from the right
   edge of its chip instead (kpFilters.js, keepOnScreen). */
.kp-datechip.is-end > .kp-datechip-menu,
.kp-morefilters.is-end > .kp-morefilters-panel {
  left: auto;
  right: 0;
}

.kp-datechip-option {
  padding: 6px 10px;
  border: 0;
  border-radius: var(--kp-radius-sm);
  background: transparent;
  color: var(--tblr-body-color);
  font-size: var(--kp-fs-body);
  text-align: left;
}

.kp-datechip-option:hover {
  background: var(--tblr-bg-surface-secondary);
}

.kp-datechip-option.is-active {
  color: var(--tblr-primary);
  font-weight: 600;
}

.kp-datechip-custom {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 6px;
  padding: 8px 4px 2px;
  border-top: 1px solid var(--tblr-border-color);
}

.kp-datechip-custom-title {
  font-size: var(--kp-fs-small);
  font-weight: 600;
  color: var(--tblr-secondary);
}

.kp-datechip-custom-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.kp-datechip-custom-row .form-control {
  min-width: 0;
  height: 30px;
  padding: 2px 6px;
  font-size: var(--kp-fs-small);
}

.kp-datechip-custom-actions {
  display: flex;
  justify-content: flex-end;
  gap: 6px;
}

/* The chips behind "Filters": closed they are only hidden, so they keep what
   they show; open they stack, each as wide as the panel. */
.kp-morefilters-panel {
  display: none;
  flex-direction: column;
  gap: 8px;
  width: 260px;
  padding: 10px;
}

.kp-morefilters.is-open > .kp-morefilters-panel {
  display: flex;
}

.kp-morefilters-foot {
  display: flex;
  justify-content: flex-end;
  padding-top: 2px;
}

/* "Filters" ends the bar, so its panel opens towards the left. */
.kp-morefilters > .kp-morefilters-panel {
  left: auto;
  right: 0;
}

.kp-morefilters-panel > .kp-picker,
.kp-morefilters-panel > .kp-chip-picker,
.kp-morefilters-panel > .kp-datechip,
.kp-morefilters-panel > .kp-datechip > .kp-chip-toggle {
  display: flex;
  width: 100%;
  max-width: none;
}

.kp-morefilters-panel > .kp-datechip > .kp-chip-toggle .kp-chip-caret {
  margin-left: auto;
}

/* Search leads the bar, in the same place on every list. From tablet width up
   the box grows to fit its own placeholder ("Search by customer, SAP no. or
   reference"), so the hint is never cut off; a browser without field-sizing
   keeps the fixed width. On a phone the box takes the whole row (the
   max-width: 767.98px block near the top). */
@media (min-width: 768px) {
  .kp-toolbar-filters > .kp-chip-search .form-control {
    width: 220px;
  }

  @supports (field-sizing: content) {
    .kp-toolbar-filters > .kp-chip-search .form-control {
      field-sizing: content;
      width: auto;
      min-width: 220px;
      max-width: 320px;
    }
  }
}

/* ==========================================================================
   Quieter rows: one loud thing per row (the status, an overdue date)
   ==========================================================================
   A rating is a coloured dot and plain text, not a second filled pill. */
.kp-rating-chip,
.kp-rating-chip.kp-rating-hot,
.kp-rating-chip.kp-rating-warm,
.kp-rating-chip.kp-rating-cold {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--tblr-body-color);
  font-size: var(--kp-fs-body);
  font-weight: 400;
}

.kp-rating-chip::before {
  content: '';
  flex: 0 0 auto;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--tblr-secondary);
}

.kp-rating-chip.kp-rating-hot::before { background: #DC2626; }
.kp-rating-chip.kp-rating-warm::before { background: #D97706; }
.kp-rating-chip.kp-rating-cold::before { background: #2563EB; }

/* A cell or a fact with nothing in it (a lone "-", marked by
   imports/ui/shell/emptyCells.js) steps back. */
.kp-is-empty,
.kp-is-empty .kp-cell-sub {
  color: var(--tblr-secondary) !important;
  opacity: .7;
}

/* Nobody assigned: no "?" avatar, and the word instead of a dash. The helper
   leaves the avatar empty when there is no name. */
.kp-avatar:empty {
  display: none;
}

.kp-avatar:empty + .kp-owner-name {
  font-size: 0;
}

.kp-avatar:empty + .kp-owner-name::after {
  content: 'Unassigned';
  font-size: var(--kp-fs-body);
  color: var(--tblr-secondary);
}

/* The totals under a table of lines read as one block at the right: each
   label sits against its amount instead of at the far left of a wide row. */
.kp-table tfoot td:not(:only-child) {
  height: auto;
  padding-top: 5px;
  padding-bottom: 5px;
  border-bottom: 0;
}

/* The item of an SAP order line keeps a readable width. */
.kp-sapd-item {
  min-width: 150px;
}

.kp-table tfoot td:first-child:not(:only-child) {
  text-align: right;
}

.kp-table tfoot tr:first-child td:not(:only-child) {
  padding-top: 12px;
}

.kp-table tfoot tr:last-child td:not(:only-child) {
  padding-bottom: 12px;
  font-size: var(--kp-fs-body);
  font-weight: 600;
  color: var(--tblr-body-color) !important;
}

/* The Masters page: every master as a card, grouped by what it belongs to. */
.kp-masters {
  display: flex;
  flex-direction: column;
  gap: 20px;
  min-height: 0;
  overflow-y: auto;
  padding-bottom: 16px;
}

.kp-masters-title {
  margin: 0 0 8px;
  font-size: var(--kp-fs-small);
  font-weight: 600;
  color: var(--tblr-secondary);
}

.kp-masters-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(270px, 1fr));
  gap: 10px;
}

.kp-master-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--tblr-border-color);
  border-radius: var(--kp-radius);
  background: var(--tblr-bg-surface);
  color: var(--tblr-body-color);
  text-decoration: none;
  transition: border-color .12s ease-out, box-shadow .12s ease-out;
}

.kp-master-card:hover,
.kp-master-card:focus-visible {
  border-color: var(--tblr-primary);
  box-shadow: 0 2px 10px rgba(15, 23, 42, .08);
  color: var(--tblr-body-color);
  text-decoration: none;
}

.kp-master-icon {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: var(--kp-radius);
  background: rgba(var(--tblr-primary-rgb), 0.08);
  color: var(--tblr-primary);
  font-size: 19px;
}

.kp-master-text {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  min-width: 0;
}

.kp-master-name {
  font-size: var(--kp-fs-card);
  font-weight: 600;
}

.kp-master-about {
  font-size: var(--kp-fs-small);
  line-height: 1.45;
  color: var(--tblr-secondary);
}

.kp-master-go {
  flex: 0 0 auto;
  color: var(--tblr-secondary);
}

.kp-masters-note {
  max-width: 720px;
  margin-top: 0;
}

/* On a wide screen the groups sit two to a row, each with its own card grid,
   so a group of three cards no longer leaves half the row blank. The note
   under them then runs the full width. */
@media (min-width: 1400px) {
  .kp-masters {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-content: start;
    column-gap: 28px;
  }

  .kp-masters > .kp-empty,
  .kp-masters > .kp-masters-note {
    grid-column: 1 / -1;
  }

  .kp-masters > .kp-masters-note {
    max-width: none;
  }
}

/* ---- The shared master list (imports/ui/pages/widget/masterList) ---------- */

/* The name of the swatch beside the colour pill in the side panel. */
.kp-master-hex {
  margin-left: 6px;
  font-size: var(--kp-fs-small);
  font-variant-numeric: tabular-nums;
}

/* A master's table is narrow enough to show its created date at every width.
   Only beside the open side panel on a laptop does it give way: the panel
   shows the same date. */
@media (max-width: 1599.98px) {
  .kp-has-inspector .kp-master-table .kp-master-created {
    display: none;
  }
}

/* The Colour column draws the row's name in its colour. A long name is cut
   there with an ellipsis (the name column beside it has it whole), so the
   table still fits beside the side panel. */
.kp-master-table td.kp-col-status > .kp-master-colour {
  display: inline-block;
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  vertical-align: middle;
}

/* The lock that stands in for the row menu on a row SAP owns. */
.kp-master-table td.kp-col-menu > .ti-lock {
  font-size: 15px;
}

/* A short piece of guidance inside a dialog or a card. */
.kp-callout {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin: 10px 0 0;
  padding: 8px 10px;
  border: 1px solid rgba(var(--tblr-primary-rgb), 0.18);
  border-radius: var(--kp-radius-sm);
  background: rgba(var(--tblr-primary-rgb), 0.06);
  color: var(--tblr-body-color);
  font-size: var(--kp-fs-body);
  line-height: 1.45;
}

.kp-callout > i {
  flex: 0 0 auto;
  margin-top: 1px;
  font-size: 15px;
  color: var(--tblr-primary);
}

/* A name cell with its star: the star keeps its size, the name still cuts. */
.kp-fav-cell {
  display: flex;
  align-items: center;
  gap: 2px;
  min-width: 0;
}

.kp-fav-cell > .kp-cell-stack,
.kp-fav-cell > .kp-fav-text {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.kp-table td .kp-fav-cell .kp-fav-star {
  margin: 0 2px 0 -6px;
}

/* The list's "Favourites" filter: a chip that is either on or off. */
.kp-chip-toggle {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 28px;
  padding: 0 11px;
  border: 1px solid var(--tblr-border-color);
  border-radius: var(--kp-radius-pill);
  background: var(--tblr-bg-surface);
  color: var(--tblr-body-color);
  font-size: var(--kp-fs-small);
  white-space: nowrap;
}

.kp-chip-toggle:hover {
  background: var(--tblr-bg-surface-secondary);
}

.kp-chip-toggle i {
  font-size: 14px;
  color: var(--tblr-secondary);
}

.kp-chip-toggle .kp-rl-star-svg {
  width: 14px;
  height: 14px;
}

.kp-chip-toggle.is-on {
  border-color: #D97706;
  background: rgba(217, 119, 6, 0.10);
  color: #B45309;
}

/* The icon font has no filled glyphs, so a favourite's star is an inline SVG. */
.kp-rl-star-svg {
  width: 17px;
  height: 17px;
}

/* ==========================================================================
   kpPicker fixed lists (item 29: one dropdown everywhere)
   ==========================================================================
   A fixed list with no search box reads as a button: pointer, no text caret,
   and the (read only) input only there for focus and the keyboard. */
.kp-picker-nosearch > .kp-picker-control,
.kp-picker-nosearch .kp-picker-search {
  cursor: pointer;
  caret-color: transparent;
}

.kp-picker-nosearch:not(.kp-picker-multi) .kp-picker-single + .kp-picker-search {
  flex: 1 1 0;
  min-width: 0;
  width: 0;
}

/* The empty row ("Select industry") stands for no value: in a form field it
   reads as a placeholder, in a filter chip ("All statuses") as the value. */
.kp-picker-at-empty .kp-picker-single {
  color: var(--tblr-secondary);
}

.kp-chip-picker.kp-picker-at-empty .kp-picker-single {
  color: var(--tblr-body-color);
}

/* A filter chip that is a fixed list is as wide as what it says, like the
   chip select it replaced. */
.kp-chip-picker.kp-picker-nosearch {
  display: inline-block;
  min-width: 0;
  max-width: 240px;
  vertical-align: middle;
}

.kp-chip-picker.kp-picker-nosearch > .kp-picker-control {
  display: inline-flex;
  max-width: 100%;
}

.kp-chip-picker.kp-picker-nosearch .kp-picker-single + .kp-picker-search {
  flex: 0 0 0;
}

/* Compact field for dense tables (units, titles, periods in line rows). */
.kp-picker-sm > .kp-picker-control {
  min-height: 30px;
  padding: 2px 4px 2px 8px;
  font-size: var(--kp-fs-small);
}

.kp-picker-sm .kp-picker-toggle,
.kp-picker-sm .kp-picker-clear {
  width: 20px;
  height: 20px;
}

/* A picker that carries its own label lines up with a field whose label sits
   outside it (.kp-field: label, gap, control; the gap is 6px in record forms). */
.kp-picker > .kp-field-label {
  display: block;
  margin-bottom: 4px;
}

.kp-record-form .kp-picker > .kp-field-label,
.kp-lead-editor .kp-picker > .kp-field-label {
  margin-bottom: 6px;
}

/* A fixed list beside a number (volume + unit + period, amount + currency):
   the select it replaced sized to its words; a picker needs a width. */
.kp-inline-row > .kp-picker {
  flex: 0 0 96px;
  width: 96px;
}

/* Text inside a picker starts where it does in the inputs beside it: Tabler's
   1rem in a form (13px, the root is --kp-fs-body), the tables' own 8px in line
   rows (.kp-lines), 10px in a chip. */
.kp-picker:not(.kp-chip-picker):not(.kp-picker-sm) > .kp-picker-control {
  padding-left: 1rem;
}

.kp-lines .kp-picker:not(.kp-chip-picker) > .kp-picker-control,
.kp-picker-sm > .kp-picker-control {
  padding-left: 8px;
}

/* ==========================================================================
   Help (DESIGN.md section 2, Help; imports/ui/pages/help, components/kpHelp)
   ==========================================================================
   The "?" in the toolbar, the Help page (sections, article, "On this page")
   and the article inside the inspector. Articles are Markdown from
   private/help rendered on the server; everything below styles that HTML. */

.kp-toolbar-help {
  display: flex;
  align-items: center;
  flex: 0 0 auto;
  margin-left: auto;
}

/* After the page's own buttons it sits beside them rather than pushing apart. */
.kp-toolbar-actions ~ .kp-toolbar-help {
  margin-left: -4px;
}

/* On a phone the toolbar wraps: the "?" stays at the top right of the title row
   instead of taking a line of its own. */
@media (max-width: 575.98px) {
  .kp-toolbar:has(> .kp-toolbar-help) {
    position: relative;
  }

  .kp-toolbar > .kp-toolbar-help {
    position: absolute;
    top: 14px;
    right: var(--kp-page-padding);
  }

  .kp-toolbar:has(> .kp-toolbar-help) > .kp-toolbar-title {
    padding-right: 36px;
  }

  /* A short title ("Leads") left room for the Table / Board switch beside it,
     and the switch then ran under the "?". With a switch the title takes the
     rest of its row (the icon is 38px and the gap 12px), so the switch starts
     the next row on every list, as it already did under a longer title. */
  .kp-toolbar:has(> .kp-toolbar-help):has(> .kp-viewswitch) > .kp-toolbar-title {
    flex-basis: calc(100% - 50px);
  }
}

.kp-help-btn.active {
  background: var(--kp-primary-soft);
  color: var(--tblr-primary);
}

/* The page: sections left, the article in the middle, "On this page" right. */
.kp-help {
  display: grid;
  grid-template-columns: 248px minmax(0, 1fr);
  gap: 24px;
  align-items: start;
  width: 100%;
  max-width: 1280px;
}

/* The middle column stops at the article's reading width (740px plus the
   card's padding and border), so "On this page" stays beside the text and a
   wide window's spare room is a plain margin on the right. */
.kp-help.has-toc {
  grid-template-columns: 248px minmax(0, 806px) 200px;
}

/* The Help page fills the window (`kp-page-fill`), so this is what scrolls:
   the toolbar stays put and the sections, the article and "On this page"
   move under it. */
.kp-page-fill > .kp-help {
  flex: 1 1 auto;
  min-height: 0;
  max-width: none;
  padding-bottom: 24px;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.kp-page-fill > .kp-help > * {
  max-width: 100%;
}

.kp-page-fill > .kp-help > .kp-help-nav,
.kp-page-fill > .kp-help > .kp-help-toc {
  top: 0;
}

/* The section list keeps its own scroll, inside what is left under the toolbar. */
.kp-page-fill > .kp-help > .kp-help-nav {
  max-height: calc(100vh - var(--kp-tabstrip-height) - 112px);
}

.kp-help-nav {
  position: sticky;
  top: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  /* The shell scrolls .kp-content, which starts under the tab strip. */
  max-height: calc(100vh - var(--kp-tabstrip-height) - 32px);
  min-width: 0;
}

.kp-help-search {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 10px;
  border: 1px solid var(--tblr-border-color);
  border-radius: var(--kp-radius);
  background: var(--tblr-bg-surface);
  color: var(--tblr-secondary);
}

.kp-help-search:focus-within {
  border-color: var(--tblr-primary);
  box-shadow: 0 0 0 3px var(--kp-primary-soft);
}

.kp-help-search .form-control {
  flex: 1 1 auto;
  min-width: 0;
  height: 34px;
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
}

.kp-help-nav-toggle {
  display: none;
  align-self: flex-start;
}

.kp-help-sections {
  overflow-y: auto;
  min-height: 0;
  padding-right: 4px;
}

.kp-help-home-link,
.kp-help-nav-link {
  display: block;
  padding: 5px 8px;
  border-radius: var(--kp-radius-sm);
  color: var(--tblr-body-color);
  font-size: var(--kp-fs-body);
  line-height: 1.35;
  text-decoration: none;
}

.kp-help-home-link {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  font-weight: 500;
}

.kp-help-home-link:hover,
.kp-help-nav-link:hover {
  background: var(--tblr-bg-surface-secondary);
  color: var(--tblr-body-color);
  text-decoration: none;
}

.kp-help-home-link.active,
.kp-help-nav-link.active {
  background: var(--kp-primary-soft);
  color: var(--tblr-primary);
  font-weight: 500;
}

.kp-help-section + .kp-help-section {
  margin-top: 12px;
}

.kp-help-section-label {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  color: var(--tblr-secondary);
  font-size: var(--kp-fs-label);
  font-weight: 600;
  letter-spacing: .04em;
  text-transform: uppercase;
}

.kp-help-section ul,
.kp-help-card ul,
.kp-help-toc ul,
.kp-help-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.kp-help-main {
  min-width: 0;
  padding: 24px 32px 40px;
  border: 1px solid var(--tblr-border-color);
  border-radius: var(--kp-radius);
  background: var(--tblr-bg-surface);
}

.kp-help-toc {
  position: sticky;
  top: 16px;
  font-size: var(--kp-fs-small);
}

.kp-help-toc-label {
  margin-bottom: 6px;
  color: var(--tblr-secondary);
  font-size: var(--kp-fs-label);
  font-weight: 600;
  letter-spacing: .04em;
  text-transform: uppercase;
}

.kp-help-toc a {
  display: block;
  padding: 3px 0 3px 10px;
  border-left: 2px solid var(--tblr-border-color);
  color: var(--tblr-secondary);
  text-decoration: none;
}

.kp-help-toc a:hover {
  border-left-color: var(--tblr-primary);
  color: var(--tblr-body-color);
}

.kp-help-toc .level-3 a {
  padding-left: 22px;
}

/* The home: a card per section. */
.kp-help-home > .kp-help-summary {
  max-width: 680px;
}

.kp-help-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
  /* Each card is as tall as its own list, so its outline ends where the list does. */
  align-items: start;
  margin-top: 20px;
}

.kp-help-card-more {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-top: 6px;
  padding: 4px 8px;
  border: 0;
  border-radius: var(--kp-radius-sm);
  background: transparent;
  color: var(--tblr-primary);
  font-size: var(--kp-fs-small);
  font-weight: 500;
}

.kp-help-card-more:hover {
  background: var(--kp-primary-soft);
}

.kp-help-card {
  margin: 0;
  padding: 16px;
}

.kp-help-card-head {
  display: flex;
  gap: 12px;
  margin-bottom: 10px;
}

.kp-help-card-head h2 {
  margin: 0 0 2px;
  font-size: var(--kp-fs-card);
  font-weight: 600;
}

.kp-help-card-head p {
  margin: 0;
  color: var(--tblr-secondary);
  font-size: var(--kp-fs-small);
}

.kp-help-card-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 32px;
  width: 32px;
  height: 32px;
  border-radius: var(--kp-radius-sm);
  background: var(--kp-primary-soft);
  color: var(--tblr-primary);
  font-size: 18px;
}

.kp-help-card .kp-help-nav-link {
  padding-left: 0;
  color: var(--tblr-primary);
}

.kp-help-card .kp-help-nav-link:hover {
  background: none;
  text-decoration: underline;
}

/* Search results and the panel's list of articles. */
.kp-help-results-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
  color: var(--tblr-secondary);
  font-size: var(--kp-fs-body);
}

.kp-help-list li + li {
  border-top: 1px solid var(--tblr-border-color);
}

.kp-help-list-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
  width: 100%;
  padding: 10px 8px;
  border: 0;
  border-radius: var(--kp-radius-sm);
  background: transparent;
  color: var(--tblr-body-color);
  text-align: left;
  text-decoration: none;
}

.kp-help-list-item:hover {
  background: var(--tblr-bg-surface-secondary);
  color: var(--tblr-body-color);
  text-decoration: none;
}

.kp-help-list-title {
  color: var(--tblr-primary);
  font-weight: 500;
}

.kp-help-list-sub {
  color: var(--tblr-secondary);
  font-size: var(--kp-fs-small);
}

.kp-help-list-section {
  color: var(--tblr-secondary);
  font-size: var(--kp-fs-label);
}

.kp-help-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 40px 16px;
  color: var(--tblr-secondary);
  text-align: center;
}

.kp-help-empty > i {
  font-size: 28px;
}

.kp-help-tip {
  font-size: var(--kp-fs-small);
}

/* The article. */
.kp-help-article {
  max-width: 740px;
  font-size: var(--kp-fs-read);
  line-height: 1.65;
}

.kp-help-crumb {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 6px;
  color: var(--tblr-secondary);
  font-size: var(--kp-fs-small);
  font-weight: 500;
}

.kp-help-title {
  margin: 0 0 6px;
  font-size: var(--kp-fs-title);
  font-weight: 600;
  line-height: 1.35;
}

.kp-help-summary {
  margin: 0 0 20px;
  color: var(--tblr-secondary);
  font-size: var(--kp-fs-card);
}

.kp-help-body h2 {
  margin: 28px 0 8px;
  font-size: var(--kp-fs-card);
  font-weight: 600;
  scroll-margin-top: 16px;
}

.kp-help-body h3 {
  margin: 20px 0 6px;
  font-size: var(--kp-fs-read);
  font-weight: 600;
  scroll-margin-top: 16px;
}

.kp-help-body p,
.kp-help-body ul,
.kp-help-body ol {
  margin: 0 0 12px;
}

.kp-help-body ul,
.kp-help-body ol {
  padding-left: 22px;
}

.kp-help-body li + li {
  margin-top: 4px;
}

.kp-help-body li > ul,
.kp-help-body li > ol {
  margin: 4px 0 0;
}

.kp-help-body a {
  color: var(--tblr-primary);
}

.kp-help-body code {
  padding: 1px 5px;
  border-radius: 4px;
  background: var(--tblr-bg-surface-secondary);
  color: inherit;
  font-size: var(--kp-fs-small);
}

.kp-help-article kbd,
.kp-help-home kbd {
  display: inline-block;
  min-width: 20px;
  padding: 0 5px;
  border: 1px solid var(--tblr-border-color);
  border-bottom-width: 2px;
  border-radius: 4px;
  background: var(--tblr-bg-surface);
  color: var(--tblr-body-color);
  font-family: inherit;
  font-size: var(--kp-fs-small);
  font-weight: 500;
  line-height: 18px;
  text-align: center;
  box-shadow: none;
}

.kp-help-table {
  margin: 0 0 16px;
  overflow-x: auto;
}

.kp-help-table table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--kp-fs-body);
}

.kp-help-table th,
.kp-help-table td {
  padding: 7px 10px;
  border: 1px solid var(--tblr-border-color);
  vertical-align: top;
  text-align: left;
}

.kp-help-table th {
  background: var(--tblr-bg-surface-secondary);
  font-weight: 600;
}

.kp-help-body blockquote {
  margin: 0 0 12px;
  padding: 2px 14px;
  border-left: 3px solid var(--tblr-border-color);
  color: var(--tblr-secondary);
}

.kp-help-callout {
  margin: 0 0 16px;
  padding: 10px 14px;
  border-left: 3px solid var(--kp-status-info-fg);
  border-radius: 0 var(--kp-radius-sm) var(--kp-radius-sm) 0;
  background: var(--kp-status-info-bg);
}

.kp-help-callout.is-tip {
  border-left-color: var(--kp-status-success-fg);
  background: var(--kp-status-success-bg);
}

.kp-help-callout.is-important {
  border-left-color: var(--kp-status-warning-fg);
  background: var(--kp-status-warning-bg);
}

.kp-help-callout > p:last-child {
  margin-bottom: 0;
}

.kp-help-callout-label {
  display: block;
  margin-bottom: 2px;
  font-size: var(--kp-fs-small);
  font-weight: 600;
  letter-spacing: .02em;
}

.kp-help-related {
  margin-top: 32px;
  padding-top: 16px;
  border-top: 1px solid var(--tblr-border-color);
}

.kp-help-related h2 {
  margin: 0 0 8px;
  font-size: var(--kp-fs-card);
  font-weight: 600;
}

.kp-help-related ul {
  margin: 0;
  padding: 0;
  list-style: none;
}

.kp-help-related li {
  display: flex;
  flex-direction: column;
  padding: 6px 0;
}

.kp-help-related li span {
  color: var(--tblr-secondary);
  font-size: var(--kp-fs-small);
}

/* The same article in the 340px inspector. */
.kp-help-panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.kp-help-panel-back {
  align-self: flex-start;
}

.kp-help-panel-intro {
  margin: 0;
  color: var(--tblr-secondary);
  font-size: var(--kp-fs-small);
  font-weight: 600;
}

.kp-help-panel-empty {
  padding: 16px 0;
  color: var(--tblr-secondary);
}

.kp-help-panel-foot {
  padding-top: 12px;
  border-top: 1px solid var(--tblr-border-color);
}

.kp-help-article.is-compact {
  font-size: var(--kp-fs-body);
  line-height: 1.6;
}

.kp-help-article.is-compact .kp-help-title {
  font-size: var(--kp-fs-card);
}

.kp-help-article.is-compact .kp-help-summary {
  margin-bottom: 14px;
  font-size: var(--kp-fs-body);
}

.kp-help-article.is-compact .kp-help-body h2 {
  margin-top: 20px;
  font-size: var(--kp-fs-body);
}

.kp-help-article.is-compact .kp-help-body h3 {
  font-size: var(--kp-fs-body);
}

.kp-help-article.is-compact .kp-help-table table {
  font-size: var(--kp-fs-small);
}

/* No room for "On this page": it goes, the article keeps the width. */
@media (max-width: 1279.98px) {
  .kp-help.has-toc {
    grid-template-columns: 248px minmax(0, 1fr);
  }

  .kp-help-toc {
    display: none;
  }
}

/* Narrow: the sections fold away above the article. */
@media (max-width: 991.98px) {
  .kp-help,
  .kp-help.has-toc {
    grid-template-columns: minmax(0, 1fr);
    gap: 12px;
  }

  .kp-help-nav {
    position: static;
    max-height: none;
  }

  .kp-help-nav-toggle {
    display: inline-flex;
  }

  .kp-help-sections {
    display: none;
    padding: 8px;
    border: 1px solid var(--tblr-border-color);
    border-radius: var(--kp-radius);
    background: var(--tblr-bg-surface);
  }

  .kp-help-sections.is-open {
    display: block;
  }

  .kp-help-main {
    padding: 16px;
  }

  .kp-help-cards {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* ==========================================================================
   "Lead" tag: a contact or an activity filed under a lead, not an account
   ========================================================================== */
.kp-lead-tag {
  display: inline-block;
  margin-left: 6px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--kp-hue-sales-soft);
  color: var(--kp-hue-sales);
  font-size: var(--kp-fs-label);
  font-weight: 500;
  line-height: 18px;
  vertical-align: 1px;
  white-space: nowrap;
}

[data-bs-theme="dark"] .kp-lead-tag {
  color: #C7D2FE;
}

/* ==========================================================================
   Targets (DESIGN.md section 2, Targets; imports/ui/pages/targets)
   ==========================================================================
   The progress page (KPI tiles, the month chart, the table with attainment
   bars and month sparks), its side panel, the plan grid and the Home card. */

/* The page is a flex column (.kp-page-fill): its cards keep their height and
   the page scrolls, rather than squeezing the chart under the table. */
.kp-page-fill.kp-targets > * {
  flex: 0 0 auto;
}

.kp-tgt-kpis {
  display: grid;
  /* 150px: the five tiles stay on one row beside the side panel at 1440px. */
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
  margin-bottom: 12px;
  transition: opacity .15s ease-out;
}

.kp-tgt-kpis.is-refreshing {
  opacity: .72;
}

.kp-tgt-kpi {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
  padding: 12px 14px;
  border: 1px solid var(--tblr-border-color);
  border-radius: 10px;
  background: var(--tblr-bg-surface);
  box-shadow: var(--kp-card-shadow);
}

.kp-tgt-kpi-label {
  color: var(--tblr-secondary);
  font-size: var(--kp-fs-small);
  font-weight: 600;
}

.kp-tgt-kpi-value {
  font-size: var(--kp-fs-display);
  font-weight: 700;
  letter-spacing: -.02em;
  line-height: 1.2;
  font-variant-numeric: tabular-nums;
}

.kp-tgt-kpi-sub {
  overflow: hidden;
  color: var(--tblr-secondary);
  font-size: var(--kp-fs-small);
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* An attainment bar: the share achieved, capped at the full width. */
.kp-tgt-bar {
  display: block;
  height: 6px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--tblr-bg-surface-secondary);
}

.kp-tgt-bar > span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--tblr-primary);
}

.kp-tgt-bar-achieved > span,
.kp-tgt-bar-ontrack > span { background: var(--kp-status-success-fg); }
.kp-tgt-bar-atrisk > span { background: var(--kp-status-warning-fg); }
.kp-tgt-bar-behind > span,
.kp-tgt-bar-missed > span { background: var(--kp-status-danger-fg); }
.kp-tgt-bar-none > span,
.kp-tgt-bar-upcoming > span { background: var(--tblr-secondary); }

.kp-tgt-chart-card,
.kp-tgt-table-card {
  margin-bottom: 12px;
}

.kp-tgt-chart-card .card-header {
  display: flex;
  align-items: baseline;
  gap: 12px;
}

.kp-tgt-chart-note {
  color: var(--tblr-secondary);
  font-size: var(--kp-fs-small);
}

.kp-tgt-chart {
  position: relative;
  height: 240px;
}

.kp-tgt-row {
  cursor: pointer;
}

.kp-tgt-row.is-selected > td {
  background: var(--kp-primary-soft);
}

.kp-tgt-table .kp-tgt-name {
  min-width: 200px;
}

/* On a laptop the people table keeps Gap, Pipeline and By month in view, and
   the accounts table Gap and Pipeline (.kp-col-lowprio-sm). With the side
   panel open the table is a third narrower, so By month gives way again and
   nothing scrolls sideways. */
@media (max-width: 1599.98px) {
  .kp-has-inspector .kp-tgt-table .kp-tgt-spark-col {
    display: none !important;
  }
}

.kp-tgt-table td.kp-tgt-name .kp-cell-name,
.kp-tgt-table td.kp-tgt-name .kp-cell-sub,
.kp-tgt-table td .kp-cell-sub {
  display: block;
}

.kp-tgt-att {
  min-width: 150px;
}

.kp-tgt-att-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
}

.kp-tgt-att-wrap .kp-tgt-bar {
  flex: 1 1 auto;
  min-width: 60px;
}

.kp-tgt-att-pct {
  flex: 0 0 38px;
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.kp-tgt-unassigned td {
  color: var(--tblr-secondary);
  font-style: italic;
}

.kp-tgt-total td {
  border-top: 2px solid var(--tblr-border-color);
  font-weight: 700;
}

/* Twelve months in 84px: the target as a light column, achieved over it. */
.kp-tgt-spark {
  display: inline-flex;
  align-items: flex-end;
  gap: 2px;
  height: 24px;
}

.kp-tgt-spark-bar {
  position: relative;
  width: 5px;
  height: 100%;
  opacity: .45;
}

.kp-tgt-spark-bar.is-in {
  opacity: 1;
}

.kp-tgt-spark-target,
.kp-tgt-spark-achieved {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  border-radius: 1px;
}

.kp-tgt-spark-target {
  background: var(--tblr-border-color);
}

.kp-tgt-spark-achieved {
  background: var(--tblr-primary);
}

/* The side panel. */
.kp-tgt-panel-chart {
  position: relative;
  height: 180px;
  margin: 12px 0;
}

.kp-tgt-panel-block {
  margin-top: 14px;
}

.kp-tgt-panel-block h3 {
  margin: 0 0 6px;
  color: var(--tblr-secondary);
  font-size: var(--kp-fs-small);
  font-weight: 600;
}

.kp-tgt-panel-block p {
  margin: 0;
}

.kp-tgt-panel-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.kp-tgt-panel-list li {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 2px 12px;
  padding: 5px 0;
  border-bottom: 1px solid var(--tblr-border-color);
}

.kp-tgt-panel-list li > .kp-cell-sub {
  flex: 1 1 100%;
}

.kp-tgt-panel-list .kp-cell-sub {
  display: block;
  color: var(--tblr-secondary);
  font-size: var(--kp-fs-small);
}

/* The plan editor. */
.kp-tgt-tools {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}

.kp-tgt-tools-label {
  color: var(--tblr-secondary);
  font-size: var(--kp-fs-body);
}

.kp-tgt-growth {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 0;
  font-size: var(--kp-fs-body);
}

.kp-tgt-growth .form-control {
  width: 72px;
}

.kp-tgt-tools-hint {
  margin-left: auto;
  color: var(--tblr-secondary);
  font-size: var(--kp-fs-small);
}

.kp-tgt-plan-wrap {
  overflow-x: auto;
}

.kp-tgt-plan {
  min-width: 1400px;
}

/* Four quarters fit the card: no twelve-month minimum, and Total and last
   year keep a set width so the spare room goes to the names. */
.kp-tgt-plan.is-quarters {
  min-width: 0;
}

.kp-tgt-plan.is-quarters .kp-tgt-plan-total,
.kp-tgt-plan.is-quarters .kp-tgt-plan-last {
  width: 140px;
}

.kp-tgt-plan th,
.kp-tgt-plan td {
  vertical-align: middle;
}

/* The name stays in view while the months scroll. */
.kp-tgt-plan .kp-tgt-plan-name {
  position: sticky;
  left: 0;
  z-index: 1;
  min-width: 200px;
  max-width: 240px;
  background: var(--tblr-bg-surface);
}

.kp-tgt-plan thead .kp-tgt-plan-name {
  z-index: 3;
  background: var(--tblr-bg-surface-secondary);
}

/* A line on its right edge, so the months scroll visibly under it. */
.kp-tgt-plan .kp-tgt-plan-name {
  box-shadow: inset -1px 0 0 var(--tblr-border-color);
}

.kp-tgt-plan-row.is-focus > td.kp-tgt-plan-name {
  background: color-mix(in srgb, var(--tblr-primary) 8%, var(--tblr-bg-surface));
}

.kp-tgt-plan .kp-tgt-plan-name .kp-cell-name,
.kp-tgt-plan .kp-tgt-plan-name .kp-cell-sub {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.kp-tgt-plan-cell {
  min-width: 84px;
  padding-left: 3px !important;
  padding-right: 3px !important;
}

.kp-tgt-plan-cell .form-control,
.kp-tgt-plan-total .form-control {
  height: 30px;
  padding: 0 6px;
  font-size: var(--kp-fs-body);
  text-align: right;
}

.kp-tgt-plan-total {
  min-width: 110px;
}

/* By quarter: four cells of a set width, each heading saying which months it
   holds. Fixed, so the spare room goes to the name column and Total and last
   year stay in view instead of the quarters stretching across the table. */
.kp-tgt-plan th.kp-tgt-plan-quarter,
.kp-tgt-plan-cell.kp-tgt-plan-quarter {
  width: 140px;
  min-width: 140px;
  max-width: 140px;
}

.kp-tgt-plan th.kp-tgt-plan-quarter .kp-tgt-q-months {
  display: block;
  font-weight: 400;
  color: var(--tblr-secondary);
}

/* The By month / By quarter switch leads the tools row. */
.kp-tgt-tools > .kp-tgt-by {
  margin-right: 8px;
}

.kp-tgt-plan-total .form-control {
  font-weight: 600;
}

.kp-tgt-plan-last {
  min-width: 96px;
  color: var(--tblr-secondary);
}

.kp-tgt-plan-row.is-focus > td {
  background: var(--kp-primary-soft);
}

.kp-tgt-plan-empty {
  padding: 24px !important;
  text-align: center;
}

.kp-tgt-plan-add {
  max-width: 420px;
  padding: 12px 16px 16px;
}

.kp-tgt-plan-add.kp-tgt-plan-add-people {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 10px;
  max-width: none;
}

.kp-tgt-plan-add-people > .kp-picker,
.kp-tgt-plan-add-people > div:first-child {
  flex: 0 1 360px;
  min-width: 0;
}

/* Home: "My target". */
.kp-home-target {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.kp-home-target-line {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 6px;
}

.kp-home-target-big {
  font-size: var(--kp-fs-display);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.kp-home-target-of,
.kp-home-target-meta {
  color: var(--tblr-secondary);
  font-size: var(--kp-fs-small);
}

.kp-home-target-month {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding-top: 8px;
  border-top: 1px solid var(--tblr-border-color);
  font-size: var(--kp-fs-body);
}

@media (max-width: 575.98px) {
  .kp-tgt-kpis {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .kp-tgt-kpi-value {
    font-size: var(--kp-fs-title);
  }

  .kp-tgt-tools-hint {
    margin-left: 0;
  }
}

/* --------------------------------------------------------------------------
   An SAP order's deliveries and invoices (sapDocumentList, on the CRM order
   page and in the SAP orders side panel), each with a Print button; and the
   gateway's print layouts on the entity form.
   -------------------------------------------------------------------------- */
.kp-sap-docs {
  margin-top: 10px;
}

.kp-sap-docs-title {
  display: block;
  font-size: var(--kp-fs-small);
  font-weight: 600;
  color: var(--tblr-secondary);
}

.kp-sap-docs .kp-insp-placeholder {
  margin-top: 2px;
}

.kp-sap-docs-list {
  margin: 4px 0 0;
  padding: 0;
  list-style: none;
}

.kp-sap-docs-list > li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 6px 0;
  border-bottom: 1px solid var(--tblr-border-color);
}

.kp-sap-docs-list > li:last-child {
  border-bottom: 0;
}

.kp-sap-docs-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.kp-sap-docs-list .btn {
  flex: 0 0 auto;
  gap: 4px;
}

.kp-sap-layouts {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.kp-sap-layouts label {
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: var(--kp-fs-small);
  color: var(--tblr-secondary);
}

@media (max-width: 575.98px) {
  .kp-sap-layouts {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* Discount matrix on/off: the switch above the bands; switched off, the bands
   stay editable but read as dimmed. */
.kp-dm-switch {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-bottom: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--tblr-border-color);
}

.kp-dm-switch .form-check-label {
  font-weight: 600;
}

.kp-dm-off {
  opacity: 0.6;
}

/* A wide field in the auto-fit two column grid takes a row of its own
   (opportunity form: Product interest, Sample requested). */
.kp-form-grid-2 > .kp-field-wide {
  grid-column: 1 / -1;
}

/* Tick box rows start flush with their field label: the Bootstrap indent for
   the box (padding plus a negative margin) is dropped. */
.kp-checkrow .form-check {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 0;
  margin: 0;
  padding-left: 0;
}

.kp-checkrow .form-check .form-check-input {
  float: none;
  margin: 0;
}

/* In every line table a number box fills its column, so its right aligned
   figure sits under the right aligned heading. */
.kp-lines > tbody > tr > td.kp-num > .form-control {
  width: 100%;
  min-width: 0;
  text-align: right;
}

/* A switch or single tick box in a form field starts flush with the field's
   label, like the tick box rows: the Bootstrap indent is dropped. */
.kp-field > .form-check.kp-switch,
.kp-field > .form-check.form-switch,
.kp-field > .form-check:not(.form-check-inline) {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 36px;
  margin: 0;
  padding-left: 0;
}

.kp-field > .form-check .form-check-input {
  float: none;
  flex: 0 0 auto;
  margin: 0;
}

/* The whole quotation discount: its type picker keeps room for "Percent". */
#qtnDiscountMode ~ .kp-picker,
.kp-inline-row > .kp-picker:has(#qtnDiscountMode),
.kp-inline-row > .kp-picker:first-child {
  flex: 0 0 130px;
}

/* ==========================================================================
   Sales order form: the delivery schedule
   ==========================================================================
   Optional rows splitting a line's quantity across delivery dates. The
   product takes the spare room; the number and date boxes keep one width.
   -------------------------------------------------------------------------- */
.kp-sched-hint {
  margin: -4px 0 12px;
}

.kp-sched-form > thead > tr > th:nth-child(1) {
  min-width: 260px;
}

.kp-sched-form > thead > tr > th:nth-child(2),
.kp-sched-form > thead > tr > th:nth-child(5) {
  width: 150px;
}

.kp-sched-form > thead > tr > th:nth-child(3) {
  width: 90px;
}

.kp-sched-form > thead > tr > th:nth-child(4) {
  width: 180px;
}

.kp-sched-form > tbody > tr > td {
  vertical-align: middle;
}

.kp-sched-form > tbody > tr > td .form-control {
  width: 100%;
  min-width: 0;
}

.kp-sched-form .kp-sched-left {
  color: var(--tblr-secondary);
  white-space: nowrap;
}

.kp-sched-form .kp-sched-left.kp-sched-over {
  color: var(--tblr-danger);
  font-weight: 600;
}

/* ==========================================================================
   Sales order form: ship-to contact and per item packaging
   ==========================================================================
   The ship-to contact is text (SAP has none): a "Same as bill-to" switch
   beside the label, then name, phone and email in one row that folds on a
   phone. Each line item has a second row for its packaging, packing and
   hazard class, so the main row stays the commercial one.
   -------------------------------------------------------------------------- */
.kp-shipto-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 6px;
}

.kp-shipto-head .kp-field-label {
  margin-bottom: 0;
}

.kp-shipto-head .form-check {
  margin: 0;
}

.kp-shipto-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}



@media (max-width: 767.98px) {
  .kp-shipto-grid {
    grid-template-columns: 1fr;
  }
}

/* ==========================================================================
   PDF viewer (imports/ui/components/pdfViewer.js)
   ==========================================================================
   A PDF over the current page instead of a new tab: a header with the title
   and Download, Share and Print, and the document filling the rest. Nearly
   full screen on a desktop, full screen on a phone.
   -------------------------------------------------------------------------- */
.kp-pdfv-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1055;
  background: rgba(15, 23, 42, .5);
  backdrop-filter: blur(2px);
  animation: kp-pdfv-fade .15s ease-out;
}

[data-bs-theme="dark"] .kp-pdfv-backdrop {
  background: rgba(2, 6, 23, .7);
}

.kp-pdfv {
  position: fixed;
  top: 50%;
  left: 50%;
  z-index: 1056;
  display: flex;
  flex-direction: column;
  width: min(1100px, calc(100vw - 48px));
  height: calc(100vh - 48px);
  transform: translate(-50%, -50%);
  overflow: hidden;
  border: 1px solid var(--tblr-border-color);
  border-radius: 12px;
  background: var(--tblr-bg-surface);
  box-shadow: 0 24px 64px rgba(15, 23, 42, .28);
  animation: kp-pdfv-rise .18s ease-out;
}

@keyframes kp-pdfv-fade {
  from { opacity: 0; }
}

@keyframes kp-pdfv-rise {
  from { opacity: 0; transform: translate(-50%, calc(-50% + 12px)); }
}

.kp-pdfv-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px 10px 16px;
  border-bottom: 1px solid var(--tblr-border-color);
}

.kp-pdfv-title {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  font-weight: 600;
}

.kp-pdfv-title > span:first-of-type {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.kp-pdfv-title > .ti {
  color: var(--tblr-danger);
  font-size: 20px;
}

.kp-pdfv-mock {
  padding: 1px 8px;
  border-radius: 999px;
  background: var(--kp-status-warning-bg, #fef3c7);
  color: var(--kp-status-warning-fg, #92400e);
  font-size: var(--kp-fs-label);
  font-weight: 600;
  white-space: nowrap;
}

.kp-pdfv-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.kp-pdfv-notice {
  padding: 8px 16px;
  border-bottom: 1px solid var(--tblr-border-color);
  background: var(--tblr-bg-surface-secondary);
  font-size: var(--kp-fs-body);
}

.kp-pdfv-body {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  background: var(--tblr-bg-surface-secondary);
}

/* The app's own controls: pages, zoom, fit and rotate, in one centred bar. */
.kp-pdfv-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 4px 10px;
  padding: 6px 12px;
  border-bottom: 1px solid var(--tblr-border-color);
  background: var(--tblr-bg-surface);
}

.kp-pdfv-group {
  display: flex;
  align-items: center;
  gap: 2px;
}

.kp-pdfv-sep {
  width: 1px;
  height: 20px;
  background: var(--tblr-border-color);
}

.kp-pdfv-tool,
.kp-pdfv-zoom {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 30px;
  min-width: 30px;
  padding: 0 6px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--tblr-body-color);
  font-size: var(--kp-fs-body);
}

.kp-pdfv-tool .ti {
  font-size: 18px;
}

.kp-pdfv-zoom {
  min-width: 56px;
  font-variant-numeric: tabular-nums;
}

.kp-pdfv-tool:hover:not(:disabled),
.kp-pdfv-zoom:hover:not(:disabled) {
  background: var(--tblr-bg-surface-secondary);
}

.kp-pdfv-tool:disabled,
.kp-pdfv-zoom:disabled {
  opacity: .4;
}

.kp-pdfv-pages {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: var(--kp-fs-body);
  color: var(--tblr-secondary);
  font-variant-numeric: tabular-nums;
}

.kp-pdfv-page {
  width: 40px;
  height: 28px;
  padding: 0 4px;
  border: 1px solid var(--tblr-border-color);
  border-radius: 6px;
  background: var(--tblr-bg-surface);
  color: var(--tblr-body-color);
  text-align: center;
}

/* The pages, drawn by PDF.js, on a soft grey desk. */
.kp-pdfv-body {
  overflow: auto;
}

.kp-pdfv-sheets {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  min-width: max-content;
  padding: 16px;
}

.kp-pdfv-sheet {
  display: block;
  background: #fff;
  box-shadow: 0 1px 3px rgba(15, 23, 42, .12), 0 8px 24px rgba(15, 23, 42, .08);
}

/* Print goes through the browser's own PDF engine, off screen. */
.kp-pdfv-printframe {
  position: fixed;
  right: 0;
  bottom: 0;
  width: 1px;
  height: 1px;
  border: 0;
  opacity: 0;
  pointer-events: none;
}

.kp-pdfv-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  height: 100%;
  padding: 24px;
  color: var(--tblr-secondary);
  text-align: center;
}

.kp-pdfv-state > .ti {
  font-size: 32px;
}

.kp-pdfv-error {
  color: var(--tblr-danger);
}

.kp-pdfv-spinner {
  width: 28px;
  height: 28px;
  border: 3px solid var(--tblr-border-color);
  border-top-color: var(--tblr-primary);
  border-radius: 50%;
  animation: kp-pdfv-spin .8s linear infinite;
}

@keyframes kp-pdfv-spin {
  to { transform: rotate(360deg); }
}

@media (max-width: 767.98px) {
  .kp-pdfv {
    width: 100vw;
    height: 100dvh;
    border: 0;
    border-radius: 0;
  }

  .kp-pdfv-actions .kp-btn-label {
    display: none;
  }

  .kp-pdfv-actions .btn .ti {
    margin-right: 0 !important;
  }

  .kp-pdfv-sheets {
    padding: 8px;
    gap: 8px;
  }

  .kp-pdfv-bar .js-pdfv-fitwidth {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .kp-pdfv-backdrop,
  .kp-pdfv {
    animation: none;
  }
}

/* ==========================================================================
   Dashboard (DESIGN.md section 2, Dashboard)
   The page at /dashboard, its layout page at /dashboard/layout, and the
   Performance card on Home, which uses the same figure tiles.
   ========================================================================== */

.kp-dsh-scroll {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding-bottom: 20px;
  transition: opacity .15s ease-out;
}

.kp-dsh-scroll.is-refreshing {
  opacity: .72;
}

.kp-dsh-hint {
  margin: 0;
}

.kp-dsh-none {
  padding: 48px 16px;
}

/* The figures: as many to a row as fit. */
.kp-dsh-kpis,
.kp-home-perf {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 10px;
}

/* The dashboard has six figures: at 180px they share one row on a 1440px
   laptop instead of leaving the sixth alone on a second row. */
.kp-dsh-kpis {
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.kp-dsh-kpi {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
  padding: 12px 14px;
  border: 1px solid var(--tblr-border-color);
  border-radius: 10px;
  background: var(--tblr-bg-surface);
  box-shadow: var(--kp-card-shadow);
  text-align: left;
}

.kp-dsh-kpi.is-link {
  cursor: pointer;
  transition: border-color .12s ease-out, box-shadow .12s ease-out;
}

/* A figure that opens its list says so under the pointer and under the
   keyboard: a clearer border and the lifted shadow, nothing that moves. */
.kp-dsh-kpi.is-link:hover,
.kp-dsh-kpi.is-link:focus-visible {
  border-color: rgba(var(--tblr-primary-rgb), .65);
  background: color-mix(in srgb, var(--tblr-primary) 3%, var(--tblr-bg-surface));
  box-shadow: var(--kp-card-shadow-hover);
}

.kp-dsh-kpi.is-link:focus-visible {
  border-radius: 10px;
  outline: 2px solid rgba(var(--tblr-primary-rgb), .4);
  outline-offset: 2px;
}

.kp-dsh-kpi.is-arranging,
.kp-dsh-card.is-arranging {
  border-style: dashed;
  border-color: rgba(var(--tblr-primary-rgb), .5);
}

.kp-dsh-kpi-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  min-height: 20px;
}

/* The figure's icon, on the tint its card names (cards.js, `hue`). */
.kp-dsh-kpi-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 24px;
  width: 24px;
  height: 24px;
  border-radius: 7px;
  background: var(--kp-card-hue-soft, var(--tblr-bg-surface-secondary));
  color: var(--kp-card-hue, var(--tblr-secondary));
  font-size: 15px;
  line-height: 1;
}

.kp-dsh-kpi-label {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  color: var(--tblr-secondary);
  font-size: var(--kp-fs-small);
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.kp-dsh-kpi-line {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 4px 8px;
}

.kp-dsh-kpi-value {
  font-size: var(--kp-fs-display);
  font-weight: 700;
  letter-spacing: -.02em;
  line-height: 1.2;
  font-variant-numeric: tabular-nums;
}

/* How a figure moved against the period before. */
.kp-dsh-delta {
  padding: 1px 7px;
  border-radius: 999px;
  font-size: var(--kp-fs-small);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.kp-dsh-delta.is-up { background: var(--kp-status-success-bg); color: var(--kp-status-success-fg); }
.kp-dsh-delta.is-down { background: var(--kp-status-danger-bg); color: var(--kp-status-danger-fg); }
.kp-dsh-delta.is-neutral { background: var(--kp-status-neutral-bg); color: var(--kp-status-neutral-fg); }

.kp-dsh-kpi-sub {
  color: var(--tblr-body-color);
  font-size: var(--kp-fs-small);
  line-height: 1.35;
}

/* The last line sits at the bottom of the tile and is as tall as the small
   line it may carry, so a row of tiles lines up with and without one. */
.kp-dsh-kpi-foot {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 8px;
  min-height: 20px;
  margin-top: auto;
  color: var(--tblr-secondary);
  font-size: var(--kp-fs-small);
}

.kp-dsh-kpi-foot-text {
  min-width: 0;
}

/* A figure's last months: a line, a faint area under it, a dot on the running
   month and a dashed stretch leading to it (models.js, `trendModel`). */
.kp-dsh-spark {
  display: block;
  flex: 0 0 auto;
  overflow: visible;
  color: var(--kp-card-hue, var(--tblr-primary));
}

/* The line with "last 6 months" under it: it ignores the period picker, and
   the caption says so beside a foot that reads "vs last month". */
.kp-dsh-spark-wrap {
  display: flex;
  flex: 0 0 auto;
  flex-direction: column;
  align-items: flex-end;
  gap: 1px;
}

.kp-dsh-spark-caption {
  color: var(--tblr-secondary);
  font-size: var(--kp-fs-label);
  line-height: 1.2;
  white-space: nowrap;
}

.kp-dsh-spark-area {
  fill: currentColor;
  opacity: .12;
}

.kp-dsh-spark-line {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.kp-dsh-spark-line.is-running {
  stroke-dasharray: 2 2.5;
}

.kp-dsh-spark-dot {
  fill: currentColor;
  stroke: var(--tblr-bg-surface);
  stroke-width: 1;
}

/* While arranging, the arrows and the eye need the room: the icon and the
   small line step aside so the label stays readable. */
.kp-dsh-kpi.is-arranging .kp-dsh-kpi-icon,
.kp-dsh-kpi.is-arranging .kp-dsh-spark-wrap {
  display: none;
}

/* While the figures are on their way: the same tiles and cards, holding bars
   (dashboard.html, `dashboardPlaceholder`). */
.kp-dsh-wait .kp-skeleton-bar {
  display: inline-block;
  max-width: 100%;
  vertical-align: middle;
}

.kp-dsh-wait .kp-dsh-kpi-value .kp-skeleton-bar {
  height: 16px;
}

.kp-dsh-wait .kp-dsh-kpi-head {
  justify-content: flex-start;
}

.kp-dsh-wait-block {
  flex: 1 1 260px;
  min-height: 260px;
  border-radius: var(--kp-radius);
  background: var(--tblr-bg-surface-secondary);
}

.kp-dsh-wait-block.is-short {
  flex-basis: 140px;
  min-height: 140px;
}

/* A chip of the toolbar that comes with the answer. */
.kp-dsh-wait-chip {
  display: inline-block;
  flex: 0 0 auto;
  height: 28px;
  border-radius: var(--kp-radius-pill);
}

/* The card remembers how tall it stood: the block fills what is left of it. */
.kp-dsh-wait-block.is-measured {
  flex-basis: 0;
  min-height: 0;
}

.kp-dsh-kpi .kp-tgt-bar {
  margin: 2px 0;
}

/* The arrows and the eye while arranging. */
.kp-dsh-arrange {
  display: inline-flex;
  flex: 0 0 auto;
  gap: 2px;
  margin-left: auto;
}

.kp-dsh-arrange .kp-icon-btn {
  width: 24px;
  height: 24px;
  font-size: 14px;
}

/* Charts and tables: two to a row on a wide screen, a wide card across both. */
.kp-dsh-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  /* A wide card takes a whole row: the next narrow card fills the gap it would
     otherwise leave beside the one before it. */
  grid-auto-flow: dense;
  gap: 14px;
  align-items: stretch;
}

/* The cards drop into place when the Dashboard first draws them (the page
   holds `is-entering` for that moment only: dashboard.js). One after the
   other, the figures first and then the charts and tables; each takes about
   half a second, with a small bounce as it lands.
   They arrive where their outlines stood while the figures loaded, so a card
   never leaves a hole: its box stays where it is, empty, until its turn, then
   lifts a little and lands (`kp-dsh-land`) while what it holds fades in
   (`kp-dsh-fill`; `backwards` keeps that out of sight until then). The long
   fall (`kp-dsh-drop`) is left to the headings under the cards, which had no
   outline to stand in. */
@keyframes kp-dsh-land {
  0% {
    transform: none;
  }

  35% {
    transform: translateY(-12px) scale(.985);
  }

  70% {
    transform: translateY(3px) scale(1);
  }

  86% {
    transform: translateY(-1px);
  }

  100% {
    transform: none;
  }
}

@keyframes kp-dsh-fill {
  0% {
    opacity: 0;
  }

  30% {
    opacity: 0;
  }

  100% {
    opacity: 1;
  }
}

@keyframes kp-dsh-drop {
  0% {
    opacity: 0;
    transform: translateY(-56px) scale(.96);
  }

  60% {
    opacity: 1;
    transform: translateY(6px) scale(1);
  }

  80% {
    transform: translateY(-2px);
  }

  100% {
    opacity: 1;
    transform: none;
  }
}

.kp-dsh-scroll.is-entering .kp-dsh-kpis > *,
.kp-dsh-scroll.is-entering .kp-dsh-grid > * {
  animation: kp-dsh-land 480ms ease-out backwards;
  animation-delay: calc(var(--kp-dsh-start, 0ms) + var(--kp-dsh-turn, 0) * 80ms);
}

.kp-dsh-scroll.is-entering .kp-dsh-kpis > * > *,
.kp-dsh-scroll.is-entering .kp-dsh-grid > * > * {
  animation: kp-dsh-fill 480ms ease-out backwards;
  animation-delay: calc(var(--kp-dsh-start, 0ms) + var(--kp-dsh-turn, 0) * 80ms);
}

.kp-dsh-scroll.is-entering .kp-dsh-grid > * {
  --kp-dsh-start: 240ms;
}

.kp-dsh-scroll.is-entering .kp-dsh-section,
.kp-dsh-scroll.is-entering .kp-dsh-pin-hint {
  animation: kp-dsh-drop 480ms ease-out 500ms backwards;
}

.kp-dsh-scroll.is-entering .kp-dsh-kpis > :nth-child(2),
.kp-dsh-scroll.is-entering .kp-dsh-grid > :nth-child(2) {
  --kp-dsh-turn: 1;
}

.kp-dsh-scroll.is-entering .kp-dsh-kpis > :nth-child(3),
.kp-dsh-scroll.is-entering .kp-dsh-grid > :nth-child(3) {
  --kp-dsh-turn: 2;
}

.kp-dsh-scroll.is-entering .kp-dsh-kpis > :nth-child(4),
.kp-dsh-scroll.is-entering .kp-dsh-grid > :nth-child(4) {
  --kp-dsh-turn: 3;
}

.kp-dsh-scroll.is-entering .kp-dsh-kpis > :nth-child(5),
.kp-dsh-scroll.is-entering .kp-dsh-grid > :nth-child(5) {
  --kp-dsh-turn: 4;
}

.kp-dsh-scroll.is-entering .kp-dsh-kpis > :nth-child(6),
.kp-dsh-scroll.is-entering .kp-dsh-grid > :nth-child(6) {
  --kp-dsh-turn: 5;
}

.kp-dsh-scroll.is-entering .kp-dsh-kpis > :nth-child(7),
.kp-dsh-scroll.is-entering .kp-dsh-grid > :nth-child(7) {
  --kp-dsh-turn: 6;
}

.kp-dsh-scroll.is-entering .kp-dsh-kpis > :nth-child(8),
.kp-dsh-scroll.is-entering .kp-dsh-grid > :nth-child(8) {
  --kp-dsh-turn: 7;
}

.kp-dsh-scroll.is-entering .kp-dsh-kpis > :nth-child(9),
.kp-dsh-scroll.is-entering .kp-dsh-grid > :nth-child(9) {
  --kp-dsh-turn: 8;
}

.kp-dsh-scroll.is-entering .kp-dsh-kpis > :nth-child(10),
.kp-dsh-scroll.is-entering .kp-dsh-grid > :nth-child(10) {
  --kp-dsh-turn: 9;
}

.kp-dsh-scroll.is-entering .kp-dsh-kpis > :nth-child(11),
.kp-dsh-scroll.is-entering .kp-dsh-grid > :nth-child(11) {
  --kp-dsh-turn: 10;
}

.kp-dsh-scroll.is-entering .kp-dsh-kpis > :nth-child(12),
.kp-dsh-scroll.is-entering .kp-dsh-grid > :nth-child(12) {
  --kp-dsh-turn: 11;
}

/* A long dashboard does not keep the last cards waiting. */
.kp-dsh-scroll.is-entering .kp-dsh-kpis > :nth-child(n + 13),
.kp-dsh-scroll.is-entering .kp-dsh-grid > :nth-child(n + 13) {
  --kp-dsh-turn: 12;
}

/* "Reduce motion" on the person's computer: the Dashboard is simply there,
   all at once. A staggered arrival without movement only reads as lag. */
@media (prefers-reduced-motion: reduce) {
  .kp-dsh-scroll.is-entering .kp-dsh-kpis > *,
  .kp-dsh-scroll.is-entering .kp-dsh-grid > *,
  .kp-dsh-scroll.is-entering .kp-dsh-kpis > * > *,
  .kp-dsh-scroll.is-entering .kp-dsh-grid > * > *,
  .kp-dsh-scroll.is-entering .kp-dsh-section,
  .kp-dsh-scroll.is-entering .kp-dsh-pin-hint {
    animation: none;
  }
}

/* Cards below the fold when the page opens: each waits as an empty box and
   arrives when it is scrolled to, once, the way the cards on screen arrived
   (dashboard.js, `arriveOnScroll`, which sets neither class under "reduce
   motion"). The doubled class outranks the opening entrance above. */
.kp-dsh-scroll .is-waiting.is-waiting {
  animation: none;
}

.kp-dsh-scroll .is-waiting.is-waiting > *,
.kp-dsh-scroll .kp-dsh-section.is-waiting,
.kp-dsh-scroll .kp-dsh-pin-hint.is-waiting {
  animation: none;
  opacity: 0;
}

.kp-dsh-scroll .is-arriving.is-arriving {
  animation: kp-dsh-land 480ms ease-out backwards;
  animation-delay: calc(var(--kp-dsh-wave, 0) * 80ms);
}

.kp-dsh-scroll .is-arriving.is-arriving > *,
.kp-dsh-scroll .kp-dsh-section.is-arriving,
.kp-dsh-scroll .kp-dsh-pin-hint.is-arriving {
  animation: kp-dsh-fill 480ms ease-out backwards;
  animation-delay: calc(var(--kp-dsh-wave, 0) * 80ms);
}

@media (min-width: 1200px) {
  .kp-dsh-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .kp-dsh-card.is-wide {
    grid-column: 1 / -1;
  }

  /* Pinned report charts: an odd one out at the end takes the whole row. */
  .kp-dsh-grid > .kp-home-chart:last-child:nth-child(odd) {
    grid-column: 1 / -1;
  }

  /* No table scrolls inside its card: every one stops at eight rows
     (compute.js, TOP), so Top customers and Top products show all of theirs
     and the chart beside them grows to the same height. */
}

.kp-dsh-card,
.kp-dsh-grid > .kp-home-chart {
  display: flex;
  flex-direction: column;
  min-width: 0;
  margin: 0;
}

.kp-dsh-card-head {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 8px 14px;
}

.kp-dsh-card-head .card-title {
  margin: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.kp-dsh-card-tag {
  flex: 0 0 auto;
  color: var(--tblr-secondary);
  font-size: var(--kp-fs-small);
  white-space: nowrap;
}

.kp-dsh-card-body {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
  padding: 12px 14px;
}

.kp-dsh-facts {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 22px;
}

.kp-dsh-fact {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}

.kp-dsh-fact-label {
  color: var(--tblr-secondary);
  font-size: var(--kp-fs-small);
  font-weight: 600;
}

.kp-dsh-fact-value {
  font-size: var(--kp-fs-card);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.kp-dsh-fact-value.is-danger { color: var(--kp-status-danger-fg); }

/* A chart is at least 260px tall and grows to fill its card: two cards share a
   row, and the row is as tall as the taller one. The canvas is taken out of the
   flow so that a chart that has grown never holds the row open by itself. */
.kp-dsh-canvas {
  position: relative;
  flex: 1 1 260px;
  min-height: 260px;
  min-width: 0;
}

.kp-dsh-canvas.is-donut {
  flex-basis: 230px;
  min-height: 230px;
}

/* One bar cut into its parts, with its legend under it: it does not grow. */
.kp-dsh-canvas.is-strip {
  flex: 0 0 116px;
  min-height: 116px;
}

.kp-dsh-canvas > canvas {
  position: absolute;
  inset: 0;
}

.kp-dsh-empty {
  flex: 1 1 auto;
  min-height: 140px;
}

.kp-dsh-note {
  margin: 0;
  color: var(--tblr-secondary);
  font-size: var(--kp-fs-small);
}

.kp-dsh-table-wrap {
  min-width: 0;
  overflow-x: auto;
}

/* Lead to order (DESIGN.md, Dashboard): one sentence, a bar of where everything
   started now stands (the list charts' ordinal ramp, grey for what dropped
   out, a 2px gap between parts), then the steps and who waits where. The
   counts are in the legend as well, so a part too narrow for its figure
   still reads. */
.kp-dsh-funnel {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.kp-dsh-funnel-head {
  margin: 0;
  font-size: 20px;
  font-weight: 600;
  line-height: 1.25;
}

.kp-dsh-funnel-sub {
  margin: 0;
  color: var(--tblr-secondary);
  font-size: var(--kp-fs-small);
}

.kp-dsh-funnel-bar {
  display: flex;
  gap: 2px;
  height: 28px;
  margin-top: 10px;
}

.kp-dsh-funnel-part {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  overflow: hidden;
  border-radius: 4px;
  font-size: var(--kp-fs-small);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.kp-dsh-funnel-part.is-step-1 { background: var(--kp-lc-step-1); color: #1E1B4B; }
.kp-dsh-funnel-part.is-step-2 { background: var(--kp-lc-step-2); color: #FFFFFF; }
.kp-dsh-funnel-part.is-step-3 { background: var(--kp-lc-step-3); color: #FFFFFF; }
.kp-dsh-funnel-part.is-dropped { background: #9CA3AF; color: #111827; }
[data-bs-theme=dark] .kp-dsh-funnel-part.is-step-1 { color: #FFFFFF; }
[data-bs-theme=dark] .kp-dsh-funnel-part.is-step-3 { color: #1E1B4B; }
[data-bs-theme=dark] .kp-dsh-funnel-part.is-dropped { background: #4B5563; color: #FFFFFF; }

.kp-dsh-funnel-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 18px;
  font-size: var(--kp-fs-small);
}

.kp-dsh-funnel-legend i {
  display: inline-block;
  width: 10px;
  height: 10px;
  margin-right: 6px;
  border-radius: 2px;
  vertical-align: -1px;
}

.kp-dsh-funnel-legend i.is-step-1 { background: var(--kp-lc-step-1); }
.kp-dsh-funnel-legend i.is-step-2 { background: var(--kp-lc-step-2); }
.kp-dsh-funnel-legend i.is-step-3 { background: var(--kp-lc-step-3); }
.kp-dsh-funnel-legend i.is-dropped { background: #9CA3AF; }
[data-bs-theme=dark] .kp-dsh-funnel-legend i.is-dropped { background: #4B5563; }

.kp-dsh-funnel-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  /* Each table keeps its own row height; stretched to its neighbour's it would space its rows out. */
  align-items: start;
  gap: 24px;
  margin-top: 12px;
}

/* Who waits where: the column widths are fixed, so a long opportunity name is
   cut with an ellipsis (its whole name is the link's tooltip) rather than
   pushing the table past the card. */
.kp-dsh-funnel-wait {
  table-layout: fixed;
}

.kp-dsh-funnel-wait th:first-child,
.kp-dsh-funnel-wait td:first-child {
  width: 34%;
}

@media (max-width: 767.98px) {
  .kp-dsh-funnel-grid {
    grid-template-columns: minmax(0, 1fr);
    gap: 12px;
  }
}

.kp-dsh-funnel-link {
  padding: 0;
  border: 0;
  background: none;
  color: var(--tblr-primary);
  font: inherit;
  text-align: right;
  cursor: pointer;
}

.kp-dsh-funnel-link:hover,
.kp-dsh-funnel-link:focus-visible {
  text-decoration: underline;
}

/* The waiting opportunities, by name, under their count. */
.kp-dsh-funnel-count,
.kp-dsh-funnel-more {
  display: block;
}

.kp-dsh-funnel-count + .kp-dsh-funnel-link,
.kp-dsh-funnel-link + .kp-dsh-funnel-link {
  display: block;
  margin-left: auto;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.kp-dsh-funnel-more,
.kp-dsh-funnel-none {
  color: var(--tblr-secondary);
}

.kp-dsh-table {
  margin: 0;
  font-size: var(--kp-fs-body);
}

.kp-dsh-table thead th {
  text-transform: none;  /* Tabler capitalises these; labels here are sentence case */
  letter-spacing: normal;
  padding: 6px 8px;
  border-bottom: 1px solid var(--tblr-border-color);
  background: transparent;
  color: var(--tblr-secondary);
  font-size: var(--kp-fs-small);
  font-weight: 600;
  white-space: nowrap;
}

.kp-dsh-table tbody td {
  padding: 7px 8px;
  border-bottom: 1px solid var(--tblr-border-color-translucent, var(--tblr-border-color));
  vertical-align: top;
}

.kp-dsh-table tbody tr:last-child td {
  border-bottom: 0;
}

.kp-dsh-table tbody tr.is-link {
  cursor: pointer;
}

.kp-dsh-table tbody tr.is-link:hover td,
.kp-dsh-table tbody tr.is-link:focus-visible td {
  background: var(--tblr-bg-surface-secondary);
}

.kp-dsh-table td.kp-num {
  white-space: nowrap;
}

.kp-dsh-table td.is-danger { color: var(--kp-status-danger-fg); }
.kp-dsh-table td.is-warning { color: var(--kp-status-warning-fg); }
.kp-dsh-table td.is-success { color: var(--kp-status-success-fg); }

.kp-dsh-cell-text {
  display: block;
  font-weight: 500;
}

.kp-dsh-table td.kp-num .kp-dsh-cell-text {
  font-weight: 400;
}

.kp-dsh-cell-sub {
  display: block;
  color: var(--tblr-secondary);
  font-size: var(--kp-fs-small);
}

.kp-dsh-table .kp-tgt-bar {
  max-width: 220px;
  height: 4px;
  margin-top: 5px;
}

/* A heading between the cards and the pinned charts, or the hidden cards. */
.kp-dsh-section {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 4px 10px;
  margin: 8px 0 -4px;
  font-size: var(--kp-fs-card);
  font-weight: 600;
}

.kp-dsh-section-note,
.kp-dsh-pin-hint {
  color: var(--tblr-secondary);
  font-size: var(--kp-fs-small);
  font-weight: 400;
}

.kp-dsh-pin-hint {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0;
}

.kp-dsh-hidden {
  display: flex;
  flex-direction: column;
  border: 1px dashed var(--tblr-border-color);
  border-radius: 10px;
  background: var(--tblr-bg-surface);
}

.kp-dsh-hidden-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 14px;
}

.kp-dsh-hidden-row + .kp-dsh-hidden-row {
  border-top: 1px solid var(--tblr-border-color);
}

.kp-dsh-hidden-main {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  min-width: 0;
}

.kp-dsh-hidden-title {
  font-weight: 600;
}

.kp-dsh-hidden-about {
  color: var(--tblr-secondary);
  font-size: var(--kp-fs-small);
}

/* On a phone the figures go two to a row, so the first screen shows four. */
@media (max-width: 599.98px) {
  .kp-dsh-kpis,
  .kp-home-perf {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .kp-dsh-kpi {
    padding: 10px 11px;
  }

  .kp-dsh-kpi-value {
    font-size: var(--kp-fs-title);
  }
}

/* Performance on Home: the same tiles, the button on the right of the head. */
.kp-home-perf {
  padding: 12px 14px;
}

.kp-home-perf .kp-dsh-kpi {
  box-shadow: none;
}

.kp-home-perf-scope {
  overflow: hidden;
  color: var(--tblr-secondary);
  font-size: var(--kp-fs-small);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.kp-home-perf-open {
  flex: 0 0 auto;
  margin-left: auto;
}

/* Dashboard layout: the roles on the left, the role's cards on the right. */
.kp-dsl-body {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 14px;
  align-items: start;
  padding-bottom: 20px;
}

@media (min-width: 992px) {
  .kp-dsl-body {
    grid-template-columns: 280px minmax(0, 1fr);
  }

  .kp-dsl-roles {
    position: sticky;
    top: 0;
  }
}

.kp-dsl-roles {
  margin: 0;
}

.kp-dsl-role-list {
  display: flex;
  flex-direction: column;
  max-height: 60vh;
  padding: 6px;
  overflow-y: auto;
}

.kp-dsl-role {
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding: 7px 10px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: inherit;
  text-align: left;
}

.kp-dsl-role:hover {
  background: var(--tblr-bg-surface-secondary);
}

.kp-dsl-role.is-selected {
  background: rgba(var(--tblr-primary-rgb), .1);
}

.kp-dsl-role-name {
  font-weight: 600;
}

.kp-dsl-role-meta {
  color: var(--tblr-secondary);
  font-size: var(--kp-fs-small);
}

.kp-dsl-main {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
}

.kp-dsl-main > .kp-callout {
  margin: 0;
}

.kp-dsl-presets {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
}

.kp-dsl-presets-label {
  margin-right: 2px;
  color: var(--tblr-secondary);
  font-size: var(--kp-fs-small);
}

.kp-dsl-card {
  margin: 0;
}

/* The two tick lists: stacked, and side by side on a wide screen so the rows
   do not trail a long blank tail. */
.kp-dsl-cards {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 12px;
  align-items: start;
}

@media (min-width: 1600px) {
  .kp-dsl-cards.is-pair {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.kp-dsl-card > .card-header {
  gap: 8px;
}

.kp-dsl-count {
  margin-left: auto;
  color: var(--tblr-secondary);
  font-size: var(--kp-fs-small);
}

.kp-dsl-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
}

.kp-dsl-row + .kp-dsl-row {
  border-top: 1px solid var(--tblr-border-color);
}

.kp-dsl-row.is-off {
  opacity: .55;
}

.kp-dsl-check {
  display: flex;
  flex: 1 1 auto;
  align-items: flex-start;
  gap: 10px;
  min-width: 0;
  margin: 0;
  padding: 0;
  cursor: pointer;
}

.kp-dsl-check .form-check-input {
  flex: 0 0 auto;
  float: none;
  margin: 3px 0 0;
}

.kp-dsl-row-main {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.kp-dsl-row-title {
  font-weight: 600;
}

.kp-dsl-kind {
  margin-left: 8px;
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--tblr-bg-surface-secondary);
  color: var(--tblr-secondary);
  font-size: var(--kp-fs-label);
  font-weight: 500;
}

.kp-dsl-row-about {
  color: var(--tblr-secondary);
  font-size: var(--kp-fs-small);
}

.kp-dsl-row-move {
  display: inline-flex;
  flex: 0 0 auto;
  gap: 2px;
}

/* ==========================================================================
   History: what changed on a record, field by field (kpHistory), and the
   Audit log page that reads the same entries across every record.
   ========================================================================== */

.kp-hist {
  display: flex;
  flex-direction: column;
  gap: 0;
  margin: 0;
  padding: 0;
  list-style: none;
}

/* A rail down the left joins the entries into one timeline. */
.kp-hist-entry {
  position: relative;
  padding: 0 0 18px 22px;
  border-left: 2px solid var(--tblr-border-color);
  margin-left: 5px;
}

.kp-hist-entry:last-child {
  padding-bottom: 2px;
  border-left-color: transparent;
}

.kp-hist-entry::before {
  content: '';
  position: absolute;
  left: -6px;
  top: 4px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--tblr-bg-surface);
  border: 2px solid var(--tblr-primary);
}

.kp-hist-created::before { border-color: var(--tblr-success); }
.kp-hist-deleted::before { border-color: var(--tblr-danger); }

.kp-hist-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 8px;
  font-size: var(--kp-fs-body);
}

.kp-hist-verb {
  font-weight: 600;
  color: var(--tblr-body-color);
}

.kp-hist-who {
  color: var(--tblr-body-color);
}

.kp-hist-when {
  color: var(--tblr-secondary);
  font-size: var(--kp-fs-small);
}

.kp-hist-error {
  margin-top: 4px;
  font-size: var(--kp-fs-small);
  color: var(--tblr-danger);
}

.kp-hist-changes {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin: 8px 0 0;
  padding: 0;
  list-style: none;
  font-size: var(--kp-fs-body);
}

/* One sentence per changed field: "Payment terms changed from 30 days to 45 days". */
.kp-hist-change {
  min-width: 0;
  color: var(--tblr-secondary);
  overflow-wrap: anywhere;
}

/* An edit of one field is its sentence, in the head of the entry. */
.kp-hist-sentence {
  color: var(--tblr-secondary);
  overflow-wrap: anywhere;
}

.kp-hist-field {
  font-weight: 600;
  color: var(--tblr-body-color);
}

.kp-hist-old {
  color: var(--tblr-body-color);
}

.kp-hist-new {
  color: var(--tblr-body-color);
  font-weight: 600;
}

.kp-hist-more {
  margin-top: 6px;
  padding: 0;
  border: 0;
  background: transparent;
  font-size: var(--kp-fs-small);
}

/* In the 340px side panel the sentences stand a little further apart. */
.kp-inspector .kp-hist-changes {
  gap: 8px;
}

.kp-audit-table .kp-audit-when {
  white-space: nowrap;
  width: 150px;
}

/* "System administrator" beside its initials needs more than the shared
   140px of an owner column. */
.kp-audit-table .kp-col-owner {
  max-width: 200px;
}

.kp-audit-table .kp-audit-summary {
  max-width: 420px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--tblr-secondary);
}

.kp-audit-table .kp-cell-stack {
  white-space: nowrap;
}

.kp-audit-row {
  cursor: pointer;
}

/* ==========================================================================
   kpPicker kind tag (decision Q22: Lead or Customer on every company picker)
   ==========================================================================
   A small pill on each option, beside the code, and after the chosen value.
   Status tokens, so it reads the same in light and dark. */
.kp-picker-tag {
  flex: 0 0 auto;
  display: inline-block;
  padding: 0 6px;
  border-radius: var(--kp-radius-pill);
  background: var(--kp-status-neutral-bg);
  color: var(--kp-status-neutral-fg);
  font-size: var(--kp-fs-label);
  font-weight: 600;
  line-height: 16px;
  white-space: nowrap;
}

.kp-picker-tag.kp-picker-tag-lead {
  background: var(--kp-status-warning-bg);
  color: var(--kp-status-warning-fg);
}

.kp-picker-tag.kp-picker-tag-customer {
  background: var(--kp-status-success-bg);
  color: var(--kp-status-success-fg);
}

/* In an option the tag starts the second line, before the code; with no code
   the tick still sits at the right end. */
.kp-picker-option > .kp-picker-tag {
  align-self: center;
}

.kp-picker-option > .kp-picker-tag + .kp-picker-tick {
  margin-left: auto;
}

/* After the chosen value the search box keeps the room it has after a plain
   value (the rule above for `.kp-picker-single + .kp-picker-search`). */
.kp-picker:not(.kp-picker-multi) .kp-picker-tag + .kp-picker-search {
  flex: 1 1 24px;
  min-width: 24px;
}

/* `kpAccountBox`: the read-only Account box of a form carries the same tag
   after the name. The name truncates; the tag never does. */
.kp-account-box {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.kp-account-box-name {
  flex: 0 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ==========================================================================
   Price history (kpPriceHistory)
   ==========================================================================
   The small button beside the Unit price of a product line on the
   opportunity, quotation and sales order forms, and the window it opens
   (DESIGN.md section 2, "Product lines"). The button comes first in the cell,
   so the price box keeps its right edge under the right aligned heading, in
   line with the other number columns.
   -------------------------------------------------------------------------- */

.kp-price-cell {
  display: flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
}

.kp-price-cell > .form-control,
.kp-price-cell > .kp-line-readonly {
  flex: 1 1 0;
  min-width: 0;
  text-align: right;
}

.kp-pricehist {
  display: inline-flex;
  flex: 0 0 auto;
}

/* A line table shares its columns out itself, and on a laptop it is at its
   narrowest: the cell keeps the room of the button and a price box that still
   shows a price, so the box is never squeezed down to a digit or two. The box
   gives up some of its side padding to the figures. */
.kp-lines .kp-price-cell {
  gap: 2px;
  min-width: 93px;
}

.kp-lines .kp-price-cell > .form-control {
  padding-right: 6px;
  padding-left: 6px;
}

/* The window: the shared dialog, wide enough for a table, never taller than
   the screen. The table scrolls inside it, the page behind never sideways. */
.kp-confirm.kp-pricehist-dialog {
  display: flex;
  flex-direction: column;
  width: min(1000px, calc(100vw - 32px));
  max-height: calc(100vh - 32px);
  max-height: calc(100dvh - 32px);
}

.kp-pricehist-head {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 10px;
}

.kp-pricehist-heading {
  flex: 1 1 auto;
  min-width: 0;
}

.kp-pricehist-head .kp-confirm-title {
  margin-bottom: 2px;
}

.kp-pricehist-product {
  margin: 0;
  overflow: hidden;
  color: var(--tblr-secondary);
  font-size: var(--kp-fs-body);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.kp-pricehist-tabs {
  flex: 0 0 auto;
}

.kp-pricehist-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
}

.kp-pricehist-scroll {
  overflow-x: auto;
}

.kp-pricehist-table {
  margin: 0;
  font-size: var(--kp-fs-body);
}

.kp-pricehist-table > thead > tr > th,
.kp-pricehist-table > tbody > tr > td {
  padding: 8px 10px;
  vertical-align: middle;
}

.kp-pricehist-nowrap {
  white-space: nowrap;
}

.kp-pricehist-price {
  font-weight: 600;
}

/* The answer above the table: last, lowest, highest and this line's price. */
.kp-pricehist-summary {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 18px;
  margin: 0 0 10px;
  font-size: var(--kp-fs-body);
}

.kp-pricehist-fact {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.kp-pricehist-fact-label {
  margin-right: 4px;
  font-weight: 500;
  color: var(--tblr-secondary);
}

.kp-pricehist-mine {
  color: var(--tblr-primary);
}

.kp-pricehist-basis {
  flex-basis: 100%;
  font-size: var(--kp-fs-small);
  color: var(--tblr-secondary);
}

.kp-pricehist-customer {
  min-width: 140px;
}

.kp-pricehist-muted {
  color: var(--tblr-secondary);
}

.kp-pricehist-table .kp-pricehist-action {
  text-align: right;
}

.kp-pricehist-action > .btn {
  white-space: nowrap;
}

/* Why a row cannot be used: short, so it may wrap rather than widen the table. */
.kp-pricehist-action > .kp-pricehist-muted {
  display: inline-block;
  min-width: 110px;
  max-width: 150px;
  font-size: var(--kp-fs-small);
}

.kp-pricehist-state {
  padding: 28px 12px;
  text-align: center;
  font-size: var(--kp-fs-body);
}

.kp-pricehist-foot {
  flex: 0 0 auto;
  margin-top: 12px;
}

@media (max-width: 575.98px) {
  .kp-confirm.kp-pricehist-dialog {
    padding: 14px;
  }
}

/* ---- Additional charges (quotation and sales order forms) ----------------- */

/* The block under the product lines, at the left of the totals: one row per
   charge, a type picker that takes the room and a fixed amount box, so the
   amounts line up under each other (DESIGN.md section 2, "Additional
   charges"). */
.kp-charges {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  width: min(520px, 100%);
  margin-top: 16px;
}

.kp-qtn-foot > .kp-qtn-foot-add {
  flex: 1 1 320px;
  min-width: 0;
}

.kp-charges-title {
  font-size: var(--kp-fs-body);
  font-weight: 600;
  color: var(--tblr-body-color);
}

.kp-charges-title .kp-lock-icon {
  margin-left: 6px;
}

.kp-charge-row {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
}

.kp-charge-row > .kp-picker {
  flex: 1 1 200px;
  min-width: 0;
}

.kp-charge-row > .form-control {
  flex: 0 0 130px;
  width: 130px;
}

/* A locked order shows the charges as text: the name, then the amount. */
.kp-charge-row > .kp-charge-name {
  flex: 1 1 200px;
  min-width: 0;
  font-size: var(--kp-fs-body);
}

.kp-charge-row > .kp-charge-amount {
  flex: 0 0 auto;
  font-size: var(--kp-fs-body);
  font-variant-numeric: tabular-nums;
}

.kp-charges > .kp-field-hint,
.kp-charges > .kp-field-error {
  margin-top: 0;
}

/* Under the sales order's lines table, which has its own bottom edge. */
.kp-so-charges {
  margin-top: 14px;
}

@media (max-width: 575.98px) {
  .kp-charge-row > .form-control {
    flex-basis: 100px;
    width: 100px;
  }
}

/* ==========================================================================
   Relationship map (kpRelationshipMap)
   ==========================================================================
   The window a record's "Relationship map" button opens: the chain of
   documents as boxes in columns by stage, joined by an SVG layer of lines, with
   the sample requests in a lane underneath (DESIGN.md section 2, "Relationship
   map"). The picture is moved about inside the window, never the page: the
   canvas is panned and zoomed as one, and a box is dragged from its place in
   the columns. Both are transforms the component writes
   (imports/ui/components/kpRelationshipMap.js): no rule here sets a transform
   on `.kp-relmap-canvas` or on `.kp-relmap-box`.
   -------------------------------------------------------------------------- */

/* As wide as the chain needs, never wider than the screen. */
/* The window takes the screen: a chain needs the room, and a box that is
   dragged has somewhere to go. */
.kp-confirm.kp-relmap-dialog {
  display: flex;
  flex-direction: column;
  width: calc(100vw - 32px);
  max-width: calc(100vw - 32px);
  height: calc(100vh - 32px);
  height: calc(100dvh - 32px);
  max-height: calc(100vh - 32px);
  max-height: calc(100dvh - 32px);
}

.kp-relmap-head {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 10px;
}

.kp-relmap-heading {
  flex: 1 1 auto;
  min-width: 0;
}

.kp-relmap-head .kp-confirm-title {
  margin-bottom: 2px;
}

.kp-relmap-sub {
  margin: 0;
  overflow: hidden;
  color: var(--tblr-secondary);
  font-size: var(--kp-fs-body);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.kp-relmap-body {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  min-height: 0;
}

.kp-relmap-state {
  padding: 28px 12px;
  text-align: center;
  font-size: var(--kp-fs-body);
}

.kp-relmap-note {
  margin: 0 0 10px;
  color: var(--tblr-secondary);
  font-size: var(--kp-fs-body);
}

.kp-relmap-foot {
  flex: 0 0 auto;
  margin-top: 12px;
}

/* The hint and the zoom buttons, above the picture. */
.kp-relmap-tools {
  display: flex;
  flex: 0 0 auto;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 6px 16px;
  margin-bottom: 8px;
}

.kp-relmap-hint {
  margin: 0;
  color: var(--tblr-secondary);
  font-size: var(--kp-fs-small);
}

.kp-relmap-zoom {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-left: auto;
}

.kp-relmap-zoom > .btn {
  margin-left: 4px;
  white-space: nowrap;
}

/* Wide enough for "200%", so the buttons do not shift as the zoom changes. */
.kp-relmap-zoom-value {
  min-width: 42px;
  color: var(--tblr-body-color);
  font-size: var(--kp-fs-small);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  text-align: center;
}

/* What is seen of the picture: it clips the canvas and never scrolls. The
   notes and the buttons above it stay where they are. `position` makes it the
   box the canvas is placed in, which the component's arithmetic relies on. */
.kp-relmap-scroll {
  position: relative;
  flex: 1 1 auto;
  min-height: min(340px, 45vh);
  overflow: hidden;
  border: 1px solid var(--tblr-border-color);
  border-radius: var(--kp-radius, 8px);
  cursor: grab;
  /* A finger drags a box or pans the picture; the page under it stays put. */
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
}

.kp-relmap-scroll.is-grabbing,
.kp-relmap-scroll.is-grabbing .kp-relmap-box {
  cursor: grabbing;
}

/* The canvas: as wide as its columns need. Scaled and moved from its top left
   corner by the component, boxes and lines together. */
.kp-relmap-canvas {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 30px;
  width: max-content;
  min-width: 100%;
  padding: 10px 6px 8px;
  transform-origin: 0 0;
}

.kp-relmap-lines {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
  pointer-events: none;
}

.kp-relmap-line {
  fill: none;
  stroke: var(--tblr-secondary);
  stroke-width: 1.5;
  opacity: .6;
}

.kp-relmap-arrow {
  fill: var(--tblr-secondary);
  stroke: none;
  opacity: .75;
}

/* With a box selected: its own lines in the primary, the rest stepped back. */
.kp-relmap-line.is-on {
  stroke: var(--tblr-primary);
  stroke-width: 2;
  opacity: 1;
}

.kp-relmap-arrow.is-on {
  fill: var(--tblr-primary);
  opacity: 1;
}

.kp-relmap-line.is-dim,
.kp-relmap-arrow.is-dim {
  opacity: .25;
}

.kp-relmap-cols {
  display: flex;
  align-items: flex-start;
  gap: 40px;
}

.kp-relmap-col {
  display: flex;
  flex: 0 0 190px;
  flex-direction: column;
  gap: 22px;
  width: 190px;
}

/* A heading sits over the lines, like a box: a line never runs through its words. */
.kp-relmap-stage {
  position: relative;
  align-self: flex-start;
  margin: 0;
  padding-right: 8px;
  background: var(--tblr-bg-surface);
  color: var(--tblr-secondary);
  font-size: var(--kp-fs-small);
  font-weight: 600;
}

/* The headings name the columns of the tidy layout. Once a box has been
   dragged out of its column they would point at the wrong boxes, so they go
   (each box names its own type) and come back with "Reset layout". Hidden,
   not removed: the boxes keep their places. */
.kp-relmap-canvas.is-arranged .kp-relmap-stage {
  visibility: hidden;
}

.kp-relmap-lane {
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.kp-relmap-lane-row {
  display: flex;
  flex-wrap: nowrap;
  gap: 20px;
}

.kp-relmap-lane-row > .kp-relmap-box {
  flex: 0 0 190px;
  width: 190px;
}

/* A box: a small card. It sits over the lines, so a line that passes behind
   it does not run through its text. */
.kp-relmap-box {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
  padding: 10px 12px;
  border: 1px solid var(--tblr-border-color);
  border-radius: var(--kp-radius, 8px);
  background: var(--tblr-bg-surface);
  color: var(--tblr-body-color);
  font-size: var(--kp-fs-small);
  text-align: left;
}

/* Every box can be picked up, also a greyed one and the start. */
.kp-relmap-box {
  cursor: grab;
  transition: border-color 150ms ease-out, box-shadow 150ms ease-out, opacity 150ms ease-out;
}

.kp-relmap-box.is-link:hover {
  border-color: var(--tblr-primary);
  box-shadow: var(--kp-card-shadow-hover, 0 4px 12px rgba(15, 23, 42, .1));
}

/* The selected box: a soft ring in the primary, outside the start's own. The
   boxes it is joined to keep their weight and take a primary edge; the rest
   step back. */
.kp-relmap-box.is-selected {
  border-color: var(--tblr-primary);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--tblr-primary) 35%, transparent);
}

.kp-relmap-box.is-start.is-selected {
  box-shadow: 0 0 0 2px var(--tblr-primary), 0 0 0 5px color-mix(in srgb, var(--tblr-primary) 35%, transparent);
}

.kp-relmap-box.is-related {
  border-color: color-mix(in srgb, var(--tblr-primary) 65%, var(--tblr-border-color));
}

.kp-relmap-box.is-dim {
  opacity: .62;
}

.kp-relmap-box:focus-visible {
  outline: 2px solid color-mix(in srgb, var(--tblr-primary) 40%, transparent);
  outline-offset: 2px;
}

/* The record the map was opened from: a ring in the primary and its label. */
.kp-relmap-box.is-start {
  border-color: var(--tblr-primary);
  background: var(--kp-primary-soft);
  box-shadow: 0 0 0 2px var(--tblr-primary);
}

.kp-relmap-here {
  position: absolute;
  top: -10px;
  left: 10px;
  padding: 1px 7px;
  border-radius: 6px;
  background: var(--tblr-primary);
  color: #fff;
  font-size: var(--kp-fs-label);
  font-weight: 600;
  line-height: 1.45;
  white-space: nowrap;
}

[data-bs-theme="dark"] .kp-relmap-here {
  color: #0f1117;
}

/* A record the person may not open: its type and status, greyed. */
.kp-relmap-box.is-hidden {
  border-style: dashed;
  background: var(--tblr-bg-surface-secondary);
  color: var(--tblr-secondary);
}

.kp-relmap-box.is-hidden .kp-status-pill {
  opacity: .7;
  filter: grayscale(1);
}

.kp-relmap-unavailable {
  font-size: var(--kp-fs-small);
  font-style: italic;
}

/* The type, then the status at the right; a long status takes a line of its own. */
.kp-relmap-box-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 4px 6px;
  min-width: 0;
}

.kp-relmap-type {
  display: inline-flex;
  align-items: center;
  flex: 0 0 auto;
  gap: 4px;
  color: var(--tblr-secondary);
  font-size: var(--kp-fs-label);
  font-weight: 600;
  white-space: nowrap;
}

.kp-relmap-box-head > .kp-status-pill {
  flex: 0 1 auto;
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.kp-relmap-number {
  overflow: hidden;
  font-size: var(--kp-fs-body);
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.kp-relmap-company {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.kp-relmap-meta {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
  overflow: hidden;
  color: var(--tblr-secondary);
  font-size: var(--kp-fs-small);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.kp-relmap-value {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* The activities count: a small link inside the box. */
.kp-relmap-activities {
  align-self: flex-start;
  margin-top: 2px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--tblr-primary);
  font-size: var(--kp-fs-small);
  font-weight: 600;
}

.kp-relmap-activities:hover {
  text-decoration: underline;
}

/* The activities link and the PDF button of a box are clicked, not dragged. */
.kp-relmap-scroll .kp-relmap-activities {
  cursor: pointer;
}

/* A phone: the stages stack as a list, top to bottom, and no lines are drawn. */
@media (max-width: 575.98px) {
  .kp-confirm.kp-relmap-dialog {
    padding: 14px;
  }

  .kp-relmap-lines,
  .kp-relmap-tools {
    display: none;
  }

  /* A list that scrolls down, as any other: no canvas, nothing to drag. */
  .kp-relmap-scroll {
    min-height: 0;
    padding: 2px;
    overflow-x: hidden;
    overflow-y: auto;
    border: 0;
    border-radius: 0;
    cursor: auto;
    touch-action: auto;
    -webkit-user-select: auto;
    user-select: auto;
  }

  .kp-relmap-canvas {
    width: auto;
    gap: 18px;
    padding: 4px 0;
  }

  .kp-relmap-box {
    cursor: default;
  }

  .kp-relmap-box.is-link {
    cursor: pointer;
  }

  .kp-relmap-cols,
  .kp-relmap-lane-row {
    flex-direction: column;
    align-items: stretch;
    gap: 18px;
  }

  .kp-relmap-col,
  .kp-relmap-lane-row > .kp-relmap-box {
    flex: 0 0 auto;
    width: 100%;
  }

  .kp-relmap-col,
  .kp-relmap-lane {
    gap: 16px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .kp-relmap-box {
    transition: none;
  }
}

/* ==========================================================================
   Lists: row heights, the empty state, one board card, and lists on a phone
   (docs/ui-audit-2026-10-13, section 3 item 10 and section 5.1)
   ==========================================================================
   Every module and administration list table carries `kp-list-table`.
   - Two row heights: 45px for a row of one line, 54px on a list whose rows
     stack a second line (a code under the name, "16 days overdue" under a
     date). The whole list takes the taller one, so rows never alternate.
   - The empty state: "Clear search and filters" first, then the list's own
     create button (`kpListEmpty`).
   - The board card (`kpBoardRecord`): title, account, then the amount, the
     date that matters and the owner; exception pills between them.
   - Under 640px a row is two lines instead of the table: `kp-m-title` and
     `kp-m-value` (the amount or the date) on the first, `kp-m-sub` (the
     account or the code, muted) and `kp-m-status` (the pill) on the second.
     A list without a `kp-m-sub` lets the title cell use both lines (its own
     code stacks under it). The filters wait behind "Filters (n)" and the side
     panel takes the whole width. Above 640px nothing here applies.
   ========================================================================== */

.kp-table.kp-list-table > tbody > tr {
  height: 45px;
}

.kp-table.kp-list-table:has(> tbody > tr > td .kp-cell-sub, > tbody > tr > td .kp-due,
  > tbody > tr > td .kp-person-username, > tbody > tr > td .kp-rl-desc) > tbody > tr {
  height: 54px;
}

/* A skeleton or an empty row keeps its own height. */
.kp-table.kp-list-table > tbody > tr.kp-skeleton-row,
.kp-table.kp-list-table > tbody > tr:has(> td[colspan]) {
  height: auto;
}

.kp-empty-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
}

/* ---- The board card ------------------------------------------------------ */

.kp-board-card-account {
  overflow: hidden;
  color: var(--tblr-secondary);
  font-size: var(--kp-fs-small);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.kp-board-card-flags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.kp-board-card-flags:not(:has(*)) {
  display: none;
}

.kp-board-card-foot {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 4px 10px;
  margin-top: 2px;
  color: var(--tblr-secondary);
  font-size: var(--kp-fs-small);
}

.kp-board-card-amount {
  color: var(--tblr-body-color);
  font-weight: 600;
  white-space: nowrap;
}

.kp-board-card-date {
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.kp-board-card-date .kp-due {
  font-size: var(--kp-fs-small);
}

.kp-board-card-foot > .kp-board-card-owner {
  min-width: 0;
  max-width: 100%;
  margin-left: auto;
}

.kp-board-card-foot > .kp-board-card-owner > .kp-avatar {
  margin-left: 0;
}

/* "Delivery" or "Ordered" before a sales order card's date. */
.kp-board-card-date-label {
  margin-right: 4px;
}

/* ---- The filters button (a phone only) ---------------------------------- */

.kp-toolbar-filterbtn {
  display: none;
}

/* ---- Lists on a phone ---------------------------------------------------- */

@media (max-width: 639.98px) {
  .kp-toolbar > .kp-toolbar-filterbtn {
    display: inline-flex;
    order: 3;
  }

  .kp-toolbar > .kp-toolbar-filters {
    display: none;
    order: 4;
  }

  .kp-toolbar > .kp-toolbar-filters.is-open {
    display: flex;
  }

  /* Open, the chips behind the desktop's own "Filters" join the others. */
  .kp-toolbar-filters .kp-morefilters,
  .kp-toolbar-filters .kp-morefilters-panel {
    display: contents;
  }

  .kp-toolbar-filters .kp-morefilters > .js-more-toggle {
    display: none;
  }

  /* The side panel is the whole screen. */
  .kp-inspector {
    flex-basis: 100%;
    width: 100%;
    border-left: 0;
  }

  .kp-table.kp-list-table {
    display: block;
    width: 100%;
    min-width: 0 !important;
  }

  .kp-table.kp-list-table > thead {
    display: none;
  }

  .kp-table.kp-list-table > tbody {
    display: block;
  }

  .kp-table.kp-list-table > tbody > tr {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas:
      "title value"
      "sub status";
    align-items: center;
    gap: 3px 12px;
    /* Over the two desktop heights: a phone row is as tall as its two lines. */
    height: auto !important;
    padding: 10px 12px;
    border-bottom: 1px solid var(--tblr-border-color);
  }

  .kp-table.kp-list-table > tbody > tr:hover {
    background: var(--tblr-bg-surface-secondary);
  }

  .kp-table.kp-list-table > tbody > tr.kp-row-selected,
  .kp-table.kp-list-table > tbody > tr.is-selected {
    background: var(--kp-primary-soft);
  }

  .kp-table.kp-list-table > tbody > tr > td {
    display: none !important;
    position: static;
    width: auto !important;
    min-width: 0 !important;
    max-width: none !important;
    height: auto;
    padding: 0;
    border: 0;
    background: transparent !important;
  }

  .kp-table.kp-list-table > tbody > tr > td.kp-m-title,
  .kp-table.kp-list-table > tbody > tr > td.kp-m-value,
  .kp-table.kp-list-table > tbody > tr > td.kp-m-sub,
  .kp-table.kp-list-table > tbody > tr > td.kp-m-status:has(.kp-status-pill) {
    display: block !important;
  }

  .kp-table.kp-list-table > tbody > tr > td.kp-m-title {
    grid-area: title;
    overflow: hidden;
    font-weight: 600;
  }

  .kp-table.kp-list-table > tbody > tr > td.kp-m-title .kp-cell-sub {
    font-weight: 400;
  }

  .kp-table.kp-list-table > tbody > tr:not(:has(> td.kp-m-sub)) > td.kp-m-title {
    grid-row: 1 / span 2;
  }

  .kp-table.kp-list-table > tbody > tr > td.kp-m-value {
    grid-area: value;
    text-align: right;
    white-space: nowrap;
  }

  .kp-table.kp-list-table > tbody > tr > td.kp-m-sub {
    grid-area: sub;
    overflow: hidden;
    color: var(--tblr-secondary);
    font-size: var(--kp-fs-small);
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .kp-table.kp-list-table > tbody > tr > td.kp-m-status {
    grid-area: status;
    justify-self: end;
  }

  /* One line each on the second row: the account, not its code as well. */
  .kp-table.kp-list-table > tbody > tr:has(> td.kp-m-sub) > td.kp-m-title :is(.kp-cell-sub, .kp-person-username, .kp-rl-desc),
  .kp-table.kp-list-table td.kp-m-sub .kp-cell-sub {
    display: none;
  }

  .kp-table.kp-list-table td.kp-m-sub .kp-wrap2,
  .kp-table.kp-list-table td.kp-m-sub .kp-clamp {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    -webkit-line-clamp: unset;
  }

  .kp-table.kp-list-table td.kp-m-sub .kp-link {
    display: block;
    color: inherit;
  }

  /* A row is one target: the account in it opens the side panel too. */
  .kp-table.kp-list-table td.kp-m-title .kp-link,
  .kp-table.kp-list-table td.kp-m-sub .kp-link {
    pointer-events: none;
  }

  .kp-table.kp-list-table td.kp-m-title .kp-fav-star {
    display: none;
  }

  /* A skeleton row and the empty state of a list drawn inside its table. */
  .kp-table.kp-list-table > tbody > tr.kp-skeleton-row > td:first-child,
  .kp-table.kp-list-table > tbody > tr > td[colspan] {
    display: block !important;
    grid-column: 1 / -1;
  }
}

/* ==========================================================================
   Stored files
   kpFiles (imports/ui/components/kpFiles.*): the files of a record or of one
   group of it, the drop zone with the rules written under it, and the preview
   window for pictures and text, which wears the PDF viewer's frame
   (.kp-pdfv). DESIGN.md section 2, "Stored files".
   ========================================================================== */
.kp-files {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}

.kp-files-groups {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.kp-files-head {
  display: flex;
  align-items: center;
  gap: 8px;
}

.kp-files-title {
  margin: 0;
  font-size: var(--kp-fs-body);
  font-weight: 600;
  color: var(--tblr-secondary);
}

.kp-files-count {
  min-width: 18px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--tblr-bg-surface-secondary);
  color: var(--tblr-secondary);
  font-size: var(--kp-fs-label);
  font-weight: 600;
  line-height: 18px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

/* The drop zone: a label around the file input, so a click, Enter or Space
   on it opens the picker, and dropped files land on it. */
.kp-files-drop {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 52px;
  padding: 10px 12px;
  border: 1px dashed var(--kp-control-border);
  border-radius: 8px;
  background: var(--tblr-bg-surface-secondary);
  color: var(--tblr-secondary);
  cursor: pointer;
  transition: border-color .15s ease-out, background-color .15s ease-out;
}

.kp-files-drop > .ti {
  flex-shrink: 0;
  font-size: 20px;
}

.kp-files-drop:hover,
.kp-files-drop.is-dragging {
  border-color: var(--tblr-primary);
  background: var(--kp-primary-soft);
  color: var(--tblr-primary);
}

.kp-files-drop:focus-within {
  outline: 2px solid color-mix(in srgb, var(--tblr-primary) 40%, transparent);
  outline-offset: 2px;
}

.kp-files-drop.is-busy {
  cursor: progress;
  opacity: .7;
}

.kp-files-drop-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.kp-files-drop-main {
  font-size: var(--kp-fs-body);
  font-weight: 500;
  color: var(--tblr-body-color);
}

.kp-files-drop-rules {
  font-size: var(--kp-fs-small);
  line-height: 1.35;
}

.kp-files-input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: inherit;
}

.kp-files-error {
  margin: 0;
}

.kp-files-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.kp-files-item {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  padding: 6px 6px 6px 10px;
  border: 1px solid var(--tblr-border-color);
  border-radius: 8px;
  background: var(--tblr-bg-surface);
}

.kp-files-item.is-pending {
  border-style: dashed;
}

.kp-files-type {
  flex-shrink: 0;
  font-size: 20px;
  color: var(--tblr-secondary);
}

.kp-files-type.ti-file-type-pdf {
  color: var(--tblr-danger);
}

.kp-files-body {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-width: 0;
}

.kp-files-name {
  display: block;
  max-width: 100%;
  padding: 0;
  border: 0;
  background: none;
  color: var(--tblr-body-color);
  font: inherit;
  font-size: var(--kp-fs-body);
  font-weight: 500;
  line-height: 1.35;
  text-align: left;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

button.kp-files-name {
  cursor: pointer;
}

button.kp-files-name:hover {
  color: var(--tblr-primary);
  text-decoration: underline;
}

button.kp-files-name:focus-visible {
  outline: 2px solid color-mix(in srgb, var(--tblr-primary) 40%, transparent);
  outline-offset: 2px;
  border-radius: 4px;
}

.kp-files-meta {
  font-size: var(--kp-fs-small);
  line-height: 1.35;
  color: var(--tblr-secondary);
  font-variant-numeric: tabular-nums;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.kp-files-actions {
  display: flex;
  align-items: center;
  gap: 2px;
  flex-shrink: 0;
}

.kp-files-spinner {
  flex-shrink: 0;
  width: 16px;
  height: 16px;
  margin-right: 6px;
  border: 2px solid var(--tblr-border-color);
  border-top-color: var(--tblr-primary);
  border-radius: 50%;
  animation: kp-pdfv-spin .8s linear infinite;
}

.kp-files-empty {
  margin: 0;
  font-size: var(--kp-fs-small);
  color: var(--tblr-secondary);
}

/* The preview window: a picture fitted inside, or the text as written. */
.kp-files-preview-title > .ti {
  color: var(--tblr-secondary);
}

.kp-files-preview-title > .ti-file-type-pdf {
  color: var(--tblr-danger);
}

.kp-files-preview-body {
  display: flex;
  flex-direction: column;
  align-items: stretch;
}

.kp-files-preview-body:focus-visible {
  outline: 2px solid color-mix(in srgb, var(--tblr-primary) 40%, transparent);
  outline-offset: -2px;
}

.kp-files-image {
  display: block;
  max-width: calc(100% - 32px);
  max-height: calc(100% - 32px);
  margin: auto;
  object-fit: contain;
  background: #fff;
  box-shadow: 0 1px 3px rgba(15, 23, 42, .12), 0 8px 24px rgba(15, 23, 42, .08);
}

.kp-files-text {
  flex: 1 1 auto;
  margin: 16px;
  padding: 16px;
  border: 1px solid var(--tblr-border-color);
  border-radius: 8px;
  background: var(--tblr-bg-surface);
  color: var(--tblr-body-color);
  font-family: var(--tblr-font-monospace, ui-monospace, SFMono-Regular, Menlo, monospace);
  font-size: var(--kp-fs-small);
  line-height: 1.45;
  white-space: pre;
  overflow: auto;
  tab-size: 4;
}

.kp-files-preview-note {
  padding: 8px 16px;
  border-bottom: 1px solid var(--tblr-border-color);
  background: var(--kp-status-warning-bg);
  color: var(--kp-status-warning-fg);
  font-size: var(--kp-fs-small);
}

@media (max-width: 575.98px) {
  .kp-files-drop {
    min-height: 56px;
  }

  .kp-files-item {
    padding-left: 8px;
  }

  .kp-files-text {
    margin: 8px;
    padding: 12px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .kp-files-drop {
    transition: none;
  }

  .kp-files-spinner {
    animation-duration: 2s;
  }
}

/* ==========================================================================
   List kit: columns, views, grouping, bulk
   (DESIGN.md section 2, "List kit: columns, views, grouping and bulk actions";
   imports/ui/components/kpListTable.*, kpListKit.*, imports/ui/shell/listKit.js)
   ========================================================================== */

/* --- Headings: the grip that moves a column, the edge that resizes it ----- */

.kp-lk-table > thead > tr > th {
  position: sticky;
}

.kp-lk-th-tools {
  position: static;
}

.kp-lk-grip {
  position: absolute;
  top: 50%;
  left: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 12px;
  height: 20px;
  margin-top: -10px;
  color: var(--tblr-secondary);
  font-size: var(--kp-fs-small);
  cursor: grab;
  opacity: 0;
  transition: opacity .12s ease;
}

.kp-lk-table > thead > tr > th:hover .kp-lk-grip,
.kp-lk-table > thead > tr > th:focus-within .kp-lk-grip {
  opacity: .7;
}

.kp-lk-grip:active {
  cursor: grabbing;
}

.kp-lk-resize {
  position: absolute;
  top: 0;
  right: -3px;
  bottom: 0;
  z-index: 1;
  width: 7px;
  cursor: col-resize;
  touch-action: none;
}

.kp-lk-resize::after {
  content: "";
  position: absolute;
  top: 25%;
  bottom: 25%;
  left: 3px;
  width: 1px;
  background: var(--tblr-border-color);
  opacity: 0;
  transition: opacity .12s ease;
}

.kp-lk-table > thead > tr > th:hover .kp-lk-resize::after,
.kp-lk-resize:focus-visible::after,
.kp-lk-table > thead > tr > th.kp-lk-resizing .kp-lk-resize::after {
  top: 0;
  bottom: 0;
  width: 2px;
  background: var(--tblr-primary);
  opacity: 1;
}

.kp-lk-resize:focus-visible {
  outline: none;
}

.kp-lk-table > thead > tr > th.kp-lk-dragging {
  opacity: .5;
}

/* Where a dragged heading lands: a bar on that side of the heading under it. */
.kp-lk-table > thead > tr > th.kp-lk-drop-before {
  box-shadow: inset 2px 0 0 var(--tblr-primary);
}

.kp-lk-table > thead > tr > th.kp-lk-drop-after {
  box-shadow: inset -2px 0 0 var(--tblr-primary);
}

/* A ticked row reads as chosen, under the side panel's own highlight. */
.kp-table.kp-lk-table > tbody > tr.kp-lk-checked > td {
  background: var(--kp-primary-soft);
}

/* --- Group headings ------------------------------------------------------ */

.kp-table.kp-lk-table > tbody > tr.kp-group-row {
  height: auto !important;
  cursor: default;
}

.kp-table.kp-lk-table > tbody > tr.kp-group-row > td {
  padding: 6px 12px;
  border-bottom: 1px solid var(--tblr-border-color);
  background: var(--tblr-bg-surface-secondary);
}

.kp-table.kp-lk-table > tbody > tr.kp-group-row:hover > td {
  background: var(--tblr-bg-surface-secondary);
}

.kp-group-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--tblr-body-color);
  font-size: var(--kp-fs-body);
  font-weight: 600;
  text-align: left;
}

.kp-group-toggle > .ti {
  color: var(--tblr-secondary);
  font-size: var(--kp-fs-body);
}

.kp-group-count {
  min-width: 22px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--tblr-bg-surface);
  border: 1px solid var(--tblr-border-color);
  color: var(--tblr-secondary);
  font-size: var(--kp-fs-small);
  font-weight: 600;
  text-align: center;
}

.kp-group-toggle:focus-visible {
  outline: 2px solid var(--tblr-primary);
  outline-offset: 2px;
  border-radius: 4px;
}

/* --- Popovers: Columns and Views ------------------------------------------ */

.kp-lk-pop-wrap {
  position: relative;
  display: inline-flex;
}

.kp-lk-pop {
  position: absolute;
  z-index: 1055;
  top: calc(100% + 4px);
  right: 0;
  display: flex;
  flex-direction: column;
  width: 300px;
  max-width: calc(100vw - 32px);
  max-height: min(70vh, 520px);
  overflow: auto;
  padding: 8px;
  border: 1px solid var(--tblr-border-color);
  border-radius: var(--kp-radius);
  background: var(--tblr-bg-surface);
  box-shadow: var(--kp-shadow-float, 0 8px 24px rgba(15, 23, 42, .12));
  font-size: var(--kp-fs-body);
  text-align: left;
}

.kp-lk-pop-head {
  padding: 6px 6px 4px;
  color: var(--tblr-secondary);
  font-size: var(--kp-fs-small);
  font-weight: 600;
}

.kp-lk-pop-hint,
.kp-lk-pop-empty {
  margin: 0 6px 6px;
  color: var(--tblr-secondary);
  font-size: var(--kp-fs-small);
}

.kp-lk-pop-foot {
  display: flex;
  justify-content: flex-end;
  margin-top: 6px;
  padding-top: 8px;
  border-top: 1px solid var(--tblr-border-color);
}

.kp-lk-col-list,
.kp-lk-view-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.kp-lk-col-item {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 2px 4px 2px 6px;
  border-radius: 6px;
}

.kp-lk-col-item:hover {
  background: var(--tblr-bg-surface-secondary);
}

.kp-lk-col-switch {
  flex: 1 1 auto;
  min-width: 0;
  margin: 0;
  padding-top: 4px;
  padding-bottom: 4px;
}

.kp-lk-col-switch .form-check-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.kp-lk-col-item .kp-icon-btn[disabled] {
  opacity: .35;
  pointer-events: none;
}

.kp-lk-view {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  padding: 6px;
  border: 0;
  border-radius: 6px;
  background: none;
  color: var(--tblr-body-color);
  font-size: var(--kp-fs-body);
  text-align: left;
}

.kp-lk-view:hover,
.kp-lk-view:focus-visible {
  background: var(--tblr-bg-surface-secondary);
  outline: none;
}

.kp-lk-view.is-current {
  background: var(--kp-primary-soft);
  font-weight: 600;
}

.kp-lk-view-name {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.kp-lk-view-tag {
  flex: 0 0 auto;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--tblr-bg-surface-secondary);
  border: 1px solid var(--tblr-border-color);
  color: var(--tblr-secondary);
  font-size: var(--kp-fs-label);
  font-weight: 600;
}

.kp-lk-view-owner {
  flex: 0 1 auto;
  min-width: 0;
  overflow: hidden;
  color: var(--tblr-secondary);
  font-size: var(--kp-fs-small);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.kp-lk-pop-actions {
  display: flex;
  flex-direction: column;
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px solid var(--tblr-border-color);
}

.kp-lk-action {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 6px;
  border: 0;
  border-radius: 6px;
  background: none;
  color: var(--tblr-body-color);
  font-size: var(--kp-fs-body);
  text-align: left;
}

.kp-lk-action > .ti {
  color: var(--tblr-secondary);
  font-size: 16px;
}

.kp-lk-action:hover,
.kp-lk-action:focus-visible {
  background: var(--tblr-bg-surface-secondary);
  outline: none;
}

.kp-lk-action-danger,
.kp-lk-action-danger > .ti {
  color: var(--kp-danger-text);
}

/* The view's name on the button, cut rather than widening the toolbar. */
.kp-lk-views-btn .kp-btn-label {
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.kp-lk-dirty {
  margin-left: 6px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--kp-status-warning-bg);
  color: var(--kp-status-warning-fg);
  font-size: var(--kp-fs-label);
  font-weight: 600;
}

.kp-lk-dialog .kp-picker {
  width: 100%;
}

/* --- Bulk bar and its result ---------------------------------------------- */

.kp-lk-bulkbar {
  flex-wrap: wrap;
}

.kp-lk-allmatch {
  padding-left: 0;
  padding-right: 0;
}

.kp-lk-bulk-none {
  color: var(--tblr-secondary);
  font-size: var(--kp-fs-small);
}

.kp-lk-result-list {
  max-height: 240px;
  margin: 0 0 8px;
  padding-left: 18px;
  overflow: auto;
  font-size: var(--kp-fs-small);
}

.kp-lk-result-list > li + li {
  margin-top: 2px;
}

.kp-lk-result-more {
  margin: 0 0 8px;
  color: var(--tblr-secondary);
  font-size: var(--kp-fs-small);
}

/* --- Phones ---------------------------------------------------------------- */

@media (max-width: 639.98px) {
  /* A group heading is one full-width line among the two-line rows. */
  .kp-table.kp-list-table.kp-lk-table > tbody > tr.kp-group-row {
    display: block;
    padding: 0;
  }

  .kp-table.kp-list-table.kp-lk-table > tbody > tr.kp-group-row > td {
    display: block !important;
    padding: 8px 12px;
    background: var(--tblr-bg-surface-secondary) !important;
  }

  /* No column moving or resizing on a phone: there are no headings. */
  .kp-lk-pop {
    position: fixed;
    top: auto;
    right: 16px;
    left: 16px;
    bottom: 16px;
    width: auto;
  }
}

@media (prefers-reduced-motion: reduce) {
  .kp-lk-grip,
  .kp-lk-resize::after {
    transition: none;
  }
}

/* List kit: a column of the default layout that gives way on a narrow window
   says so in the column menu, under its name. */
.kp-lk-col-note {
  display: block;
  color: var(--tblr-secondary);
  font-size: var(--kp-fs-small);
  font-weight: 400;
}

/* ---- Sample request additions -------------------------------------------- */

/* The "Add this as ..." row a picker offers last when the typed text is not in the list (kpPicker `createOption`). */
.kp-picker-create-icon {
  flex: 0 0 auto;
  color: var(--tblr-primary);
}

.kp-picker-option .kp-picker-create-icon + .kp-picker-option-label {
  color: var(--tblr-primary);
  font-weight: 600;
}

/* A product line that may carry a sample product: the SAP product / Sample
   product switch sits beside the picker and wraps under it when the column is narrow. */
.kp-productline-with-source {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 8px;
}

.kp-productline-with-source .kp-productline-source {
  flex: 0 0 auto;
}

.kp-productline-with-source .kp-productline-picker {
  flex: 1 1 200px;
  min-width: 0;
}

/* Documents of a sample line: the COA and MSDS files, small, one under the other. */
.kp-line-docs {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 180px;
}

.kp-line-doc-label {
  margin: 0;
  font-size: var(--kp-fs-small);
  font-weight: 600;
  color: var(--tblr-secondary);
}

.kp-files-compact {
  gap: 4px;
}

.kp-files-compact .kp-files-drop {
  min-height: 0;
  padding: 4px 8px;
  gap: 6px;
}

.kp-files-compact .kp-files-drop-rules {
  display: none;
}

.kp-files-compact .kp-files-empty {
  margin: 0;
}

.kp-files-compact .kp-files-item {
  padding: 4px 6px;
}

/* ---------------------------------------------------------------------------
   Credit check (DESIGN.md section 2, "Credit check"; kpCreditStrip).
   A left edge in the tone, the figures in one row that wraps.
   ------------------------------------------------------------------------- */
.kp-credit {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 10px 12px;
  border: 1px solid var(--tblr-border-color);
  border-left-width: 3px;
  border-radius: 8px;
  background: var(--tblr-bg-surface);
  font-size: var(--kp-fs-small);
}

.kp-credit.is-loading,
.kp-credit.is-muted {
  flex-direction: row;
  align-items: center;
  gap: 8px;
  color: var(--tblr-secondary);
}

.kp-credit-none { border-left-color: var(--tblr-border-color); }
.kp-credit-ok { border-left-color: var(--kp-status-success-fg); }
.kp-credit-warn { border-left-color: var(--kp-status-warning-fg); background: var(--kp-status-warning-bg); }
.kp-credit-over { border-left-color: var(--kp-status-danger-fg); background: var(--kp-status-danger-bg); }

.kp-credit-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 10px;
  min-height: 28px;
}

.kp-credit-head > .ti-credit-card {
  font-size: 16px;
  color: var(--tblr-secondary);
}

.kp-credit-title {
  font-weight: 600;
  color: var(--tblr-body-color);
}

.kp-credit-ok .kp-credit-title { color: var(--kp-status-success-fg); }
.kp-credit-warn .kp-credit-title { color: var(--kp-status-warning-fg); }
.kp-credit-over .kp-credit-title { color: var(--kp-status-danger-fg); }

.kp-credit-verdict {
  color: var(--tblr-body-color);
}

.kp-credit-source {
  margin-left: auto;
  color: var(--tblr-secondary);
  white-space: nowrap;
}

.kp-credit-reload {
  width: 24px;
  height: 24px;
  flex-basis: 24px;
  font-size: 14px;
}

.kp-credit-figures {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 28px;
  margin: 0;
}

.kp-credit-figure dt {
  font-weight: 400;
  color: var(--tblr-secondary);
}

.kp-credit-figure dt .ti {
  font-size: 12px;
}

.kp-credit-figure dd {
  margin: 0;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--tblr-body-color);
}

.kp-credit-overdue {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--kp-status-warning-fg);
  font-weight: 600;
}

.kp-credit-over .kp-credit-overdue {
  color: var(--kp-status-danger-fg);
}

/* A slot that holds no check (a lead, an account not in SAP) takes no row. */
.kp-credit-slot:not(:has(.kp-credit)) {
  display: none;
}

/* In a side panel: the figures stack, the source goes under the title. */
.kp-insp-credit {
  margin: 0 0 4px;
}

.kp-insp-credit .kp-credit-source {
  margin-left: 0;
  flex-basis: 100%;
  order: 3;
}

/* ---------------------------------------------------------------------------
   Account: Products bought tab (accountProductsBought).
   ------------------------------------------------------------------------- */
.kp-buy-insight {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--tblr-border-color);
  font-size: var(--kp-fs-small);
  color: var(--tblr-body-color);
}

.kp-buy-insight > .ti {
  flex: none;
  margin-top: 1px;
  font-size: 16px;
  color: var(--kp-status-warning-fg);
}

.kp-buy-table tr.kp-buy-lapsed > td:first-child {
  box-shadow: inset 3px 0 0 var(--kp-status-danger-fg);
}

.kp-buy-table tr.kp-buy-due > td:first-child {
  box-shadow: inset 3px 0 0 var(--kp-status-warning-fg);
}

.kp-buy-trend {
  display: inline-flex;
  align-items: center;
  gap: 3px;
}

.kp-buy-trend.is-up { color: var(--kp-status-success-fg); }
.kp-buy-trend.is-down { color: var(--kp-status-danger-fg); }

.kp-buy-action {
  width: 1%;
  white-space: nowrap;
  text-align: right;
}

/* Opportunity "Why was this lost?": their price per product line. */
.kp-loss-prices {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 0;
  padding: 0;
  border: 0;
  max-height: 240px;
  overflow-y: auto;
}

.kp-loss-prices > legend {
  float: none;
  width: auto;
  margin-bottom: 2px;
}

.kp-loss-price-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 210px);
  gap: 10px;
  align-items: center;
}

.kp-loss-price-name {
  display: flex;
  flex-direction: column;
  min-width: 0;
  font-size: var(--kp-fs-small);
}

.kp-loss-price-name > span:first-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@media (max-width: 575.98px) {
  .kp-loss-price-row {
    grid-template-columns: minmax(0, 1fr);
    gap: 4px;
  }
}

/* ---------------------------------------------------------------------------
   Opportunities: Changes view, the weekly pipeline review (opportunityChanges).
   ------------------------------------------------------------------------- */
.kp-chg {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding-bottom: 16px;
}

/* On the list page the view is the part that scrolls: .kp-page-fill holds the
   page to the window, so without this the cards below the fold are cut off. */
.kp-page-fill > .kp-chg {
  flex: 1 1 auto;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
}

.kp-page-fill > .kp-chg > * { flex: 0 0 auto; }

.kp-chg-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.kp-chg-scope {
  margin-left: auto;
  font-size: var(--kp-fs-small);
  color: var(--tblr-secondary);
}

.kp-chg-tiles {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
}

.kp-chg-tile {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  padding: 10px 12px;
  border: 1px solid var(--tblr-border-color);
  border-radius: 10px;
  background: var(--tblr-bg-surface);
  color: var(--tblr-body-color);
  text-align: left;
  cursor: pointer;
}

.kp-chg-tile:hover { border-color: var(--tblr-primary); }
.kp-chg-tile.is-active { border-color: var(--tblr-primary); box-shadow: inset 0 0 0 1px var(--tblr-primary); }
.kp-chg-tile.is-none .kp-chg-tile-value { color: var(--tblr-secondary); }

.kp-chg-tile-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: var(--kp-fs-small);
  color: var(--tblr-secondary);
}

.kp-chg-tile-value {
  font-size: 20px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.kp-chg-tile-sub {
  font-size: var(--kp-fs-small);
  color: var(--tblr-secondary);
}

.kp-chg-person {
  border: 1px solid var(--tblr-border-color);
  border-radius: 10px;
  background: var(--tblr-bg-surface);
  overflow: hidden;
}

.kp-chg-person-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 10px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--tblr-border-color);
}

.kp-chg-avatar {
  flex-basis: 28px;
  width: 28px;
  height: 28px;
  font-size: 12px;
}

.kp-chg-person-name { font-weight: 600; }

.kp-chg-person-counts {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-left: auto;
}

.kp-chg-row {
  display: grid;
  grid-template-columns: 130px minmax(0, 1.5fr) minmax(0, 1.6fr) 120px;
  gap: 12px;
  align-items: center;
  padding: 8px 14px;
  border-bottom: 1px solid var(--tblr-border-color);
  font-size: var(--kp-fs-small);
  cursor: pointer;
}

.kp-chg-row:last-child { border-bottom: 0; }
.kp-chg-row:hover, .kp-chg-row:focus-visible { background: var(--tblr-bg-surface-secondary); outline: none; }

.kp-chg-deal,
.kp-chg-amount {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.kp-chg-deal .kp-cell-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.kp-chg-amount { align-items: flex-end; text-align: right; }
.kp-chg-amount .kp-num { font-weight: 600; }

.kp-chg-what {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.kp-chg-old { color: var(--tblr-secondary); }

@media (max-width: 991.98px) {
  .kp-chg-tiles { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .kp-chg-row { grid-template-columns: minmax(0, 1fr) auto; }
  .kp-chg-row > div:first-child { grid-column: 1 / -1; }
  .kp-chg-what { grid-column: 1 / -1; order: 3; }
}

@media (max-width: 575.98px) {
  .kp-chg-tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kp-chg-scope { margin-left: 0; flex-basis: 100%; }
}

/* ==========================================================================
   Importing from Excel (DESIGN.md "Importing from Excel"; dataImport_page).
   ========================================================================== */
.kp-import {
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-width: 960px;
  padding: 12px 0 24px;
}
.kp-import-step-title {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 6px;
  font-size: 1rem;
  font-weight: 600;
}
.kp-import-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--tblr-primary);
  color: #fff;
  font-size: .75rem;
  font-weight: 600;
}
.kp-import-text { margin: 0 0 10px; color: var(--tblr-secondary); max-width: 70ch; }
.kp-import-muted { font-size: .8125rem; }
.kp-import-file { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.kp-import-file .form-control { flex: 1 1 260px; max-width: 420px; }
.kp-import-summary { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
.kp-import-figure {
  padding: 4px 10px;
  border-radius: 6px;
  border: 1px solid var(--tblr-border-color);
  font-variant-numeric: tabular-nums;
}
.kp-import-figure.is-ok { background: var(--kp-status-success-bg); color: var(--kp-status-success-fg); border-color: transparent; }
.kp-import-figure.is-bad { background: var(--kp-status-danger-bg); color: var(--kp-status-danger-fg); border-color: transparent; }
.kp-import-figure.is-note { background: var(--kp-status-warning-bg); color: var(--kp-status-warning-fg); border-color: transparent; }
.kp-import-actions { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; }
.kp-import-rowno { width: 56px; font-variant-numeric: tabular-nums; color: var(--tblr-secondary); }
.kp-import-problems,
.kp-import-notes { margin: 0; padding-left: 16px; }
.kp-import-problems { color: var(--kp-status-danger-fg); }
.kp-import-notes { color: var(--kp-status-warning-fg); }
.kp-import-ok { display: inline-flex; align-items: center; gap: 4px; color: var(--kp-status-success-fg); }
.kp-import-row-bad > td:first-child { box-shadow: inset 3px 0 0 var(--kp-status-danger-fg); }
.kp-import-row-note > td:first-child { box-shadow: inset 3px 0 0 var(--kp-status-warning-fg); }

/* Quotation form: the follow-up reminder switch and its days (DESIGN.md "Quotation follow-up"). */
.kp-followup-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; min-height: 31px; }
.kp-followup-days { width: auto; flex: 0 0 auto; }
.kp-followup-days .form-control { width: 72px; flex: 0 0 72px; }

/* Activities calendar (DESIGN.md section 2, "Activities calendar"). */
.kp-calendar-card { display: flex; flex-direction: column; min-height: 0; }
.kp-acal-head {
  display: flex; align-items: center; flex-wrap: wrap; gap: 8px 16px;
  padding: 10px 14px; border-bottom: 1px solid var(--tblr-border-color);
}
.kp-acal-nav { display: inline-flex; align-items: center; gap: 6px; }
.kp-acal-title { margin: 0; flex: 1 1 auto; font-size: var(--kp-fs-body, 15px); font-weight: 600; }
.kp-acal-note {
  padding: 6px 14px; color: var(--tblr-secondary); font-size: var(--kp-fs-small);
  border-bottom: 1px solid var(--tblr-border-color);
}
.kp-acal-scroller { position: relative; padding: 0; }
.kp-acal-scroller.is-loading .kp-acal-grid { opacity: .55; }
.kp-acal-loading { position: absolute; top: 8px; right: 12px; }
.kp-acal-weekdays {
  display: grid; grid-template-columns: repeat(7, minmax(0, 1fr));
  border-bottom: 1px solid var(--tblr-border-color);
  color: var(--tblr-secondary); font-size: var(--kp-fs-small); font-weight: 600; text-align: center;
}
.kp-acal-weekdays > div { padding: 6px 0; }
.kp-acal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); }
.kp-acal-day {
  position: relative; min-height: 96px; min-width: 0; padding: 4px 5px 6px;
  border-right: 1px solid var(--tblr-border-color); border-bottom: 1px solid var(--tblr-border-color);
}
.kp-acal-grid > .kp-acal-day:nth-child(7n) { border-right: 0; }
.kp-acal-week .kp-acal-day { min-height: 220px; }
.kp-acal-day.is-outside { background: var(--tblr-bg-surface-secondary); }
.kp-acal-day.is-outside .kp-acal-num { color: var(--tblr-secondary); opacity: .7; }
.kp-acal-day.can-add { cursor: pointer; }
.kp-acal-daynum { display: flex; align-items: center; gap: 6px; min-height: 22px; }
.kp-acal-num { font-size: var(--kp-fs-small); font-weight: 600; }
.kp-acal-wd { color: var(--tblr-secondary); font-weight: 500; }
.kp-acal-day.is-today .kp-acal-num {
  display: inline-flex; align-items: center; justify-content: center; min-width: 22px; height: 22px;
  padding: 0 5px; border-radius: var(--kp-radius-pill); background: var(--tblr-primary); color: #fff;
}
.kp-acal-day.is-today .kp-acal-wd { color: inherit; }
.kp-acal-count {
  display: none; margin-left: auto; min-width: 20px; padding: 0 6px; border-radius: var(--kp-radius-pill);
  background: var(--kp-primary-soft); color: var(--tblr-primary);
  font-size: var(--kp-fs-small); font-weight: 600; text-align: center;
}
.kp-acal-add { display: none; margin-left: auto; color: var(--tblr-secondary); }
@media (hover: hover) and (pointer: fine) {
  .kp-acal-day.can-add:hover { background: var(--kp-primary-soft); }
  .kp-acal-day.can-add:hover .kp-acal-add { display: inline-block; }
}
.kp-acal-items { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.kp-acal-chip, .kp-acal-card, .kp-acal-more {
  display: flex; min-width: 0; width: 100%; margin: 0; text-align: left; font: inherit; color: inherit;
  border: 0; background: transparent; cursor: pointer;
}
.kp-acal-chip {
  align-items: center; gap: 5px; padding: 2px 5px; border-radius: var(--kp-radius-sm);
  background: var(--tblr-bg-surface-secondary); font-size: var(--kp-fs-small); line-height: 18px;
}
.kp-acal-chip:hover, .kp-acal-card:hover { background: var(--kp-primary-soft); }
.kp-acal-dot { flex: 0 0 8px; width: 8px; height: 8px; border-radius: 50%; background: var(--tblr-secondary); }
.kp-acal-chip-name { flex: 0 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kp-acal-chip-type {
  flex: 1 1 0; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  color: var(--tblr-secondary);
}
.kp-acal-more { padding: 1px 5px; color: var(--tblr-primary); font-size: var(--kp-fs-small); font-weight: 600; }
.kp-acal-card {
  flex-direction: column; gap: 3px; padding: 6px 8px; border: 1px solid var(--tblr-border-color);
  border-radius: var(--kp-radius-sm); background: var(--tblr-bg-surface); font-size: var(--kp-fs-small);
}
.kp-acal-card-top { display: flex; align-items: center; gap: 6px; min-width: 0; }
.kp-acal-card-name { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.kp-acal-card-type { color: var(--tblr-secondary); }
.kp-acal-card-text {
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
  overflow-wrap: anywhere;
}
.kp-acal-chip.is-overdue, .kp-acal-card.is-overdue { background: var(--kp-status-danger-bg); }
.kp-acal-chip.is-overdue .kp-acal-chip-name, .kp-acal-card.is-overdue .kp-acal-card-name { color: var(--kp-status-danger-fg); }
.kp-acal-chip.is-done, .kp-acal-card.is-done { opacity: .6; }
.kp-acal-chip.is-selected, .kp-acal-card.is-selected {
  background: var(--kp-primary-soft); box-shadow: inset 0 0 0 1px var(--tblr-primary); opacity: 1;
}
@media (max-width: 720px) {
  .kp-acal-week { grid-template-columns: minmax(0, 1fr); }
  .kp-acal-week .kp-acal-day { min-height: 0; border-right: 0; }
}
@media (max-width: 640px) {
  .kp-acal-head { padding: 8px 10px; }
  .kp-acal-title { flex-basis: 100%; order: -1; }
  .kp-acal-grid.kp-acal-month .kp-acal-day { min-height: 56px; padding: 4px; cursor: pointer; }
  .kp-acal-grid.kp-acal-month .kp-acal-items { display: none; }
  .kp-acal-grid.kp-acal-month .kp-acal-count { display: inline-block; }
  .kp-acal-grid.kp-acal-month .kp-acal-add { display: none !important; }
}

/* ==========================================================================
   Forecast commit (DESIGN.md section 2, "Forecast"; forecast_page).
   ========================================================================== */
.kp-fc { display: flex; flex-direction: column; gap: 12px; max-width: 1100px; padding: 12px 0 24px; }
.kp-fc-stamp { font-size: .8125rem; color: var(--tblr-secondary); }
.kp-fc-figures { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin: 4px 0 14px; }
.kp-fc-figure {
  display: flex; flex-direction: column; gap: 2px; padding: 10px 12px;
  border: 1px solid var(--tblr-border-color); border-radius: 8px;
}
.kp-fc-figure.is-warn { border-color: transparent; background: var(--kp-status-warning-bg); }
.kp-fc-figure-label { font-size: .75rem; color: var(--tblr-secondary); }
.kp-fc-figure-value { font-size: 1.125rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.kp-fc-figure.is-warn .kp-fc-figure-value,
.kp-fc-figure.is-warn .kp-fc-figure-sub { color: var(--kp-status-warning-fg); }
.kp-fc-figure-sub { font-size: .75rem; color: var(--tblr-secondary); }

.kp-fc-bar { margin: 2px 0 14px; }
.kp-fc-bar.is-compact { margin: 0; min-width: 120px; }
.kp-fc-bar-track {
  position: relative; height: 10px; border-radius: 5px; overflow: visible;
  background: var(--tblr-bg-surface-secondary, rgba(127, 127, 127, .12));
}
.kp-fc-bar.is-compact .kp-fc-bar-track { height: 8px; }
.kp-fc-bar-commit,
.kp-fc-bar-fill { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 5px; }
.kp-fc-bar-commit { background: color-mix(in srgb, var(--tblr-primary) 28%, transparent); }
.kp-fc-bar-fill { background: var(--tblr-primary); }
.kp-fc-bar-target {
  position: absolute; top: -3px; bottom: -3px; width: 2px; margin-left: -1px;
  background: var(--tblr-body-color); border-radius: 1px;
}
.kp-fc-bar-legend { display: flex; flex-wrap: wrap; gap: 4px 14px; margin-top: 6px; font-size: .75rem; color: var(--tblr-secondary); }
.kp-fc-bar-legend span { display: inline-flex; align-items: center; gap: 5px; }
.kp-fc-key { display: inline-block; width: 10px; height: 10px; border-radius: 2px; }
.kp-fc-key.is-fill { background: var(--tblr-primary); }
.kp-fc-key.is-commit { background: color-mix(in srgb, var(--tblr-primary) 28%, transparent); }
.kp-fc-key.is-target { width: 2px; height: 12px; background: var(--tblr-body-color); }

.kp-fc-form { display: grid; grid-template-columns: repeat(2, minmax(160px, 220px)) minmax(200px, 1fr) auto; gap: 12px; align-items: end; }
.kp-fc-form .kp-field { margin: 0; }
.kp-fc-save { display: flex; flex-direction: column; gap: 4px; align-items: flex-start; }
.kp-fc-readonly,
.kp-fc-last,
.kp-fc-insight { margin: 10px 0 0; color: var(--tblr-secondary); font-size: .875rem; }
.kp-fc-insight { margin: 0 0 10px; }
.kp-fc-none { color: var(--kp-status-warning-fg); font-size: .8125rem; }
.kp-fc-slipped { color: var(--kp-status-warning-fg); }
.kp-fc-table .kp-col-num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.kp-fc-barcol { width: 160px; vertical-align: middle; }
.kp-fc-total > td { font-weight: 600; border-top: 2px solid var(--tblr-border-color); }
@media (max-width: 720px) {
  .kp-fc-form { grid-template-columns: 1fr; }
  .kp-fc-barcol,
  .kp-fc-opt { display: none; }
}
