:root {
  color-scheme: light;
  --ke-brand-50: #f0f7ff;
  --ke-brand-100: #e0effe;
  --ke-brand-200: #b9dffe;
  --ke-brand-300: #7cc6fd;
  --ke-brand-400: #36aafa;
  --ke-brand-500: #0c8eeb;
  --ke-brand-600: #0070c9;
  --ke-brand-700: #0059a3;
  --ke-brand-800: #054b86;
  --ke-brand-900: #0a3f6f;
  --ke-canvas: #f0f4ff;
  --ke-surface: rgba(255, 255, 255, 0.72);
  --ke-surface-hover: rgba(255, 255, 255, 0.88);
  --ke-surface-secondary: rgba(255, 255, 255, 0.48);
  --ke-dropdown-bg: rgba(255, 255, 255, 0.97);
  --ke-dropdown-border: rgba(88, 102, 135, 0.2);
  --ke-muted-surface: rgba(0, 0, 0, 0.04);
  /* Opaque stand-in for --ke-muted-surface over a glass card — sticky table
     headers (EN-0376) must hide the rows scrolling underneath them. */
  --ke-sticky-head-bg: #edf0f6;
  --ke-border: rgba(255, 255, 255, 0.72);
  /* Structural shell dividers (topbar underline, brand/sidebar rail edges).
     Kept separate from --ke-border, which is the white glass-highlight edge
     frosted cards use against the light canvas — that reads as no line at all
     on the near-white topbar. This one is a true grey in light mode and
     matches the dark-mode border weight in dark. */
  --ke-chrome-border: rgba(88, 102, 135, 0.24);
  --ke-text: #1a1a2e;
  --ke-text-muted: #555570;
  --ke-text-subtle: #6b6b82;
  --ke-track: rgba(0, 0, 0, 0.06);
  --ke-shadow: 0 18px 60px rgba(20, 35, 80, 0.12);
  --ke-shadow-sm: 0 8px 28px rgba(20, 35, 80, 0.08);
  --ke-tooltip-bg: #1a1a2e;
  --ke-tooltip-fg: #ffffff;
  /* Stage 40 — squared-corner design decision: every chrome radius token
     flattens to 0 platform-wide. Exceptions: true circles (avatars, dots,
     the tools FAB, radio inputs, rounded-circle) and the form-switch pill. */
  --ke-radius-card: 0;
  --ke-radius-control: 0;
  --ke-sidebar-width: 13rem;
  --ke-sidebar-collapsed-width: 5.5rem;
  --ke-topbar-height: 4rem;

  /* Stacking scale — every chrome-level z-index in this file references one of
     these tokens; never restate the literals. The values interleave with
     Bootstrap's own layers (sticky 1020, fixed 1030, offcanvas backdrop 1040,
     offcanvas 1045, modal backdrop 1050, modal 1055, toast 1090), which is why
     the numbers are irregular. Component-local stacking (z-index 1/2 inside a
     card or table) stays literal — only viewport-level chrome belongs here. */
  --ke-z-fixed: 1030; /* viewport-pinned floats: rail tip/search, tools FAB */
  --ke-z-topbar: 1045; /* topbar — under the sidebar */
  --ke-z-sidebar: 1046; /* app sidebar — above the topbar and offcanvas backdrop (1040), below the modal backdrop (1050) so every open modal dims it */
  --ke-z-dropdown: 1080; /* dropdowns clear modals and the sidebar */
  --ke-z-overlay: 1085; /* fixed helper panels above dropdowns */
  --ke-z-toast: 1090; /* matches Bootstrap $zindex-toast */
  --ke-z-skip-link: 1100; /* a11y skip link — topmost */
  --bs-body-font-family: Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
  --bs-body-bg: var(--ke-canvas);
  --bs-body-color: var(--ke-text);
  --bs-primary: var(--ke-brand-600);
  --bs-primary-rgb: 0, 112, 201;
  --bs-link-color: var(--ke-brand-700);
  --bs-link-hover-color: var(--ke-brand-800);
  --bs-border-color: rgba(88, 102, 135, 0.24);
  --bs-border-radius: var(--ke-radius-control);
  --bs-border-radius-sm: 0;
  --bs-border-radius-lg: var(--ke-radius-card);
  --bs-border-radius-xl: 0;
  --bs-border-radius-xxl: 0;
  --bs-border-radius-pill: 0;
  --bs-focus-ring-color: rgba(12, 142, 235, 0.25);
  --bs-secondary-color: var(--ke-text-muted);
  --bs-tertiary-color: var(--ke-text-subtle);
  /* Drawing takeoff overlay colours — prototype hues darkened for >=4.5:1
     contrast on the light canvas; the prototype's original (brighter) values
     are restored in the dark theme block below. */
  --ke-takeoff-measure: hsl(187, 92%, 28%);
  --ke-takeoff-weld: hsl(30, 95%, 34%);
  --ke-takeoff-fixture: hsl(25, 95%, 36%);
  --ke-takeoff-note: hsl(45, 92%, 27%);
  --ke-takeoff-time: hsl(330, 75%, 40%);
  --ke-takeoff-calibrate: hsl(142, 76%, 28%);
  --ke-takeoff-selection: hsl(258, 70%, 50%);
  --ke-takeoff-temp: hsl(217, 91%, 45%);

  /* Delivery-status traffic-light tokens — kept in step with the delivery
     doughnut palette (apps/planning/views/dashboard_panel_views.py) so the
     legend swatches match their chart segments exactly. Theme-independent: the
     chart uses the same values in light and dark, and these vivid mid-tones
     read on both canvases. */
  --ke-status-on-time: #10b981;
  --ke-status-running-late: #f59e0b;
  --ke-status-overdue: #ef4444;
}

[data-bs-theme="dark"] {
  color-scheme: dark;
  --ke-canvas: #0c0c14;
  --ke-surface: rgba(255, 255, 255, 0.065);
  --ke-surface-hover: rgba(255, 255, 255, 0.095);
  --ke-surface-secondary: rgba(255, 255, 255, 0.04);
  --ke-dropdown-bg: #1a1a23;
  --ke-dropdown-border: rgba(255, 255, 255, 0.14);
  --ke-sidebar-bg: rgba(10, 13, 27, 0.96);
  --ke-muted-surface: rgba(255, 255, 255, 0.055);
  --ke-sticky-head-bg: #2a2a33;
  --ke-border: rgba(255, 255, 255, 0.105);
  --ke-chrome-border: rgba(255, 255, 255, 0.105);
  --ke-text: #f0f0f8;
  --ke-text-muted: #a0a0b8;
  --ke-text-subtle: #8a8aa2;
  --ke-track: rgba(255, 255, 255, 0.08);
  --ke-shadow: 0 18px 60px rgba(0, 0, 0, 0.36);
  --ke-shadow-sm: 0 8px 28px rgba(0, 0, 0, 0.25);
  --ke-tooltip-bg: #f0f0f8;
  --ke-tooltip-fg: #0c0c14;
  --bs-body-bg: var(--ke-canvas);
  --bs-body-color: var(--ke-text);
  --bs-link-color: var(--ke-brand-300);
  --bs-link-hover-color: var(--ke-brand-200);
  --bs-border-color: rgba(255, 255, 255, 0.11);
  --bs-secondary-color: var(--ke-text-muted);
  --bs-tertiary-color: var(--ke-text-subtle);
  /* Drawing takeoff overlay colours — prototype palette (plan Appendix A). */
  --ke-takeoff-measure: hsl(187, 92%, 50%);
  --ke-takeoff-weld: hsl(30, 95%, 55%);
  --ke-takeoff-fixture: #f97316;
  --ke-takeoff-note: #facc15;
  --ke-takeoff-time: #f472b6;
  --ke-takeoff-calibrate: hsl(142, 72%, 45%);
  --ke-takeoff-selection: hsl(258, 90%, 66%);
  --ke-takeoff-temp: hsl(217, 91%, 60%);
}

html {
  min-height: 100%;
  background: var(--ke-canvas);
  scroll-behavior: smooth;
}

body {
  min-height: 100vh;
  background: var(--ke-canvas);
  color: var(--ke-text);
  font-size: 0.875rem;
}

.page-body p,
.modal p {
  margin-bottom: 0;
}

/* Right-align the close control in every modal header. This Bootstrap build's
   `.modal-header` has no `justify-content: space-between`, so it relies on
   Bootstrap's native `.btn-close` (which carries `margin-left: auto`). Custom
   close buttons used by some modals lack that margin and would otherwise sit
   next to the title — this restores the top-right corner placement globally. */
.modal-header > .btn-close,
.modal-header > [data-bs-dismiss="modal"] {
  margin-left: auto;
}

[x-cloak] {
  display: none !important;
}

img,
svg {
  vertical-align: middle;
}

.canvas-bg {
  background:
    radial-gradient(circle at 20% 0%, #dbeafe 0%, transparent 42%),
    radial-gradient(circle at 80% 20%, #e0e7ff 0%, transparent 38%),
    radial-gradient(circle at 50% 82%, #d1fae5 0%, transparent 42%),
    var(--ke-canvas);
}

[data-bs-theme="dark"] .canvas-bg {
  background:
    radial-gradient(circle at 30% 20%, rgba(59, 130, 246, 0.16) 0%, transparent 48%),
    radial-gradient(circle at 70% 80%, rgba(139, 92, 246, 0.12) 0%, transparent 42%),
    radial-gradient(circle at 50% 50%, rgba(6, 182, 212, 0.08) 0%, transparent 42%),
    var(--ke-canvas);
}

.glass-surface,
.glass-card,
.modal-content,
.dropdown-menu,
.offcanvas {
  background: var(--ke-surface);
  border-color: var(--ke-border);
  box-shadow: var(--ke-shadow-sm);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}

.glass-card {
  border: 1px solid var(--ke-border);
  border-radius: var(--ke-radius-card);
  box-shadow: var(--ke-shadow);
}

.dropdown-menu {
  --bs-dropdown-bg: var(--ke-dropdown-bg);
  --bs-dropdown-border-color: var(--ke-dropdown-border);
  --bs-dropdown-color: var(--ke-text);
  --bs-dropdown-link-color: var(--ke-text);
  --bs-dropdown-link-hover-bg: var(--ke-muted-surface);
  --bs-dropdown-link-hover-color: var(--ke-text);
  --bs-dropdown-link-active-bg: var(--ke-brand-600);
  --bs-dropdown-link-active-color: #fff;
  --bs-dropdown-divider-bg: var(--ke-dropdown-border);
  z-index: var(--ke-z-dropdown);
  background: var(--ke-dropdown-bg);
  border: 1px solid var(--ke-dropdown-border);
  box-shadow: var(--ke-shadow);
}

.dropdown-item {
  color: var(--ke-text);
}

.dropdown-item:hover,
.dropdown-item:focus-visible {
  background-color: var(--ke-muted-surface);
  color: var(--ke-text);
}

/* Modal panels must stay readable even where backdrop-filter does not render
   (e.g. GPU acceleration disabled on some Windows / remote-desktop setups) —
   base them on the opaque surface token, not the translucent glass token,
   so page content never bleeds through. */
.modal-content {
  background: var(--ke-dropdown-bg);
}

.modal-backdrop.show {
  opacity: 0.6;
}

/* Fallback for browsers/contexts without backdrop-filter support: make the
   frosted surfaces solid so nothing behind them shows through. */
@supports not ((backdrop-filter: blur(20px)) or (-webkit-backdrop-filter: blur(20px))) {
  .glass-surface,
  .glass-card,
  .modal-content,
  .dropdown-menu,
  .offcanvas,
  .btn-glass {
    background: var(--ke-dropdown-bg);
  }
}

/* modal-dialog-scrollable assumes .modal-header/.modal-body/.modal-footer are
   direct children of .modal-content; a <form> wrapping them breaks the flex
   chain (the form can't shrink below its content), so the body never scrolls
   and the footer is pushed off-screen. Restore the chain through the form. */
.modal-dialog-scrollable .modal-content > form {
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

/* Invite Team Members modal — deliberately oversized. The body is a two-step
   builder: a multi-column grid of role cards on top and the staged-invitation
   list below it. A much taller, wider frame lets most of the ~27 role cards and
   a useful stretch of the staged list show at once without scrolling. */
.modal-invite {
  --bs-modal-width: min(1280px, 95vw);
}
.modal-invite .modal-content {
  min-height: min(80vh, 760px);
}

/* Document preview modal — sized to sit inside the main content area, clear of
   the fixed sidebar and topbar, rather than filling the whole viewport (which
   tucked the header behind the higher-z-index chrome). */
.modal-preview {
  max-width: none;
  width: auto;
  margin: 4.5rem 1rem 1rem;
}
@media (min-width: 992px) {
  /* Clear the 5.5rem fixed desktop sidebar rail (app-main-wrap margin) + a gutter. */
  .modal-preview {
    margin-left: 6.5rem;
  }

  html.sidebar-expanded .modal-preview {
    margin-left: calc(var(--ke-sidebar-width) + 1rem);
  }
}
.modal-preview .modal-content {
  height: calc(100vh - 5.5rem);
}
.modal-preview .modal-body {
  overflow: auto;
}
.doc-preview-stage {
  min-height: 0;
}
.doc-preview-frame {
  height: 100%;
}
.doc-preview-image {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.glass-muted {
  background: var(--ke-muted-surface);
}

/* AI-working placeholder (components/loading.html#ai-working) */
.ke-ai-halo {
  animation: ke-ai-halo 1.8s ease-out infinite;
}
.ke-ai-halo .ke-icon {
  animation: ke-ai-breathe 1.8s ease-in-out infinite;
}
.ke-shimmer {
  background: linear-gradient(
    90deg,
    var(--ke-muted-surface) 25%,
    rgba(var(--bs-primary-rgb), 0.12) 50%,
    var(--ke-muted-surface) 75%
  );
  background-size: 200% 100%;
  animation: ke-shimmer 1.6s linear infinite;
}
@keyframes ke-ai-halo {
  from { box-shadow: 0 0 0 0 rgba(var(--bs-primary-rgb), 0.35); }
  to { box-shadow: 0 0 0 0.875rem rgba(var(--bs-primary-rgb), 0); }
}
@keyframes ke-ai-breathe {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.12); }
}
@keyframes ke-shimmer {
  from { background-position: 200% 0; }
  to { background-position: -200% 0; }
}
@media (prefers-reduced-motion: reduce) {
  .ke-ai-halo,
  .ke-ai-halo .ke-icon,
  .ke-shimmer {
    animation: none;
  }
  .ke-shimmer {
    background: var(--ke-muted-surface);
  }
}

.bg-ke-track {
  background-color: var(--ke-track) !important;
}

.bg-primary.text-primary {
  background-color: rgba(var(--bs-primary-rgb), 0.14) !important;
  color: var(--bs-link-color) !important;
}

.bg-danger.text-danger {
  background-color: rgba(var(--bs-danger-rgb), 0.14) !important;
  color: var(--bs-danger-text-emphasis) !important;
}

.border-top.border:not(.border-bottom):not(.border-start):not(.border-end),
.border-bottom.border:not(.border-top):not(.border-start):not(.border-end),
.border-start.border:not(.border-top):not(.border-bottom):not(.border-end):not(.border-4),
.border-end.border:not(.border-top):not(.border-bottom):not(.border-start):not(.border-4) {
  border-right-width: 0 !important;
  border-bottom-width: 0 !important;
  border-left-width: 0 !important;
}

.border-bottom.border:not(.border-top):not(.border-start):not(.border-end) {
  border-top-width: 0 !important;
  border-bottom-width: var(--bs-border-width) !important;
}

.border-start.border:not(.border-top):not(.border-bottom):not(.border-end):not(.border-4) {
  border-top-width: 0 !important;
  border-bottom-width: 0 !important;
  border-left-width: var(--bs-border-width) !important;
}

.border-end.border:not(.border-top):not(.border-bottom):not(.border-start):not(.border-4) {
  border-top-width: 0 !important;
  border-right-width: var(--bs-border-width) !important;
  border-bottom-width: 0 !important;
  border-left-width: 0 !important;
}

.btn-primary {
  --bs-btn-bg: var(--ke-brand-600);
  --bs-btn-border-color: var(--ke-brand-600);
  --bs-btn-hover-bg: var(--ke-brand-700);
  --bs-btn-hover-border-color: var(--ke-brand-700);
  --bs-btn-active-bg: var(--ke-brand-800);
  --bs-btn-active-border-color: var(--ke-brand-800);
}

.btn-outline-primary {
  --bs-btn-color: var(--ke-brand-700);
  --bs-btn-border-color: rgba(0, 112, 201, 0.45);
  --bs-btn-hover-bg: var(--ke-brand-600);
  --bs-btn-hover-border-color: var(--ke-brand-600);
}

[data-bs-theme="dark"] .btn-outline-primary {
  --bs-btn-color: var(--ke-brand-300);
  --bs-btn-border-color: rgba(124, 198, 253, 0.45);
}

.btn-glass {
  --bs-btn-color: var(--ke-text);
  --bs-btn-bg: var(--ke-surface);
  --bs-btn-border-color: var(--ke-border);
  --bs-btn-hover-color: var(--ke-text);
  --bs-btn-hover-bg: var(--ke-surface-hover);
  --bs-btn-hover-border-color: var(--ke-border);
  box-shadow: var(--ke-shadow-sm);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}

.btn-topbar-icon {
  --bs-btn-color: var(--ke-text-muted);
  --bs-btn-bg: transparent;
  --bs-btn-border-color: transparent;
  --bs-btn-hover-color: var(--ke-text);
  --bs-btn-hover-bg: var(--ke-muted-surface);
  --bs-btn-hover-border-color: transparent;
  --bs-btn-active-color: var(--ke-text);
  --bs-btn-active-bg: var(--ke-muted-surface);
  --bs-btn-active-border-color: transparent;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  padding: 0;
  border-radius: 0;
}

.btn-topbar-user {
  width: auto;
  padding-inline: 0.5rem;
}

/* --- Global search (topbar) ------------------------------------------ */
.global-search {
  width: min(22rem, 30vw);
}

.global-search-field {
  position: relative;
}

.global-search-icon {
  position: absolute;
  left: 0.625rem;
  top: 50%;
  transform: translateY(-50%);
  display: inline-flex;
  color: var(--ke-text-muted);
  pointer-events: none;
}

.global-search-input {
  padding-left: 2.25rem;
}

/* The typeahead panel is deliberately not a .dropdown-menu (that sets
   display:none, which would defeat Alpine's x-show), so the dropdown-item
   variables its rows use have to be re-declared here. */
.global-search-panel {
  --bs-dropdown-link-color: var(--ke-text);
  --bs-dropdown-link-hover-bg: var(--ke-muted-surface);
  --bs-dropdown-link-hover-color: var(--ke-text);
  position: absolute;
  top: calc(100% + 0.25rem);
  right: 0;
  width: min(28rem, 92vw);
  max-height: 26rem;
  overflow-y: auto;
  z-index: var(--ke-z-dropdown);
  /* .glass-card alone paints the translucent --ke-surface; only .dropdown-menu
     picks up the solid --ke-dropdown-bg, and this panel deliberately isn't one
     (see above). Nested inside .app-topbar's own backdrop-filter the frosting
     never resolved either, so page content read straight through the results.
     Take the solid dropdown surface and drop the filter that wasn't working. */
  background: var(--ke-dropdown-bg);
  border-color: var(--ke-dropdown-border);
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}

/* [class*="cad-"] buttons are exempt from this reset: its :not() chains carry
   ~11 classes of specificity, which no feature-level `.foo.active` rule can
   beat, so the CAD editor's button states (active tool, osnap chips, toggles)
   were silently overridden. static/cad/css/cad.css owns all cad-* button
   chrome instead. The roster board's buttons (a class token starting
   "board-") are exempt for the same reason: the board section below owns
   their padding, border, background and active states. The field (phone)
   big buttons (`field-btn*`) are exempt too: their own block owns them, and
   so are the map markers (`ke-map-*`, the "Interactive maps" section), and
   a button styled as a select (`.form-select`, the checkbox dropdown) keeps
   Bootstrap's select border, padding and background. */
button:not(.btn):not(.btn-close):not(.form-select):not(.page-link):not(.dropdown-item):not(.nav-link):not(.accordion-button):not(.navbar-toggler):not([class*="cad-"]):not([class^="board-"]):not([class*=" board-"]):not([class*="field-btn"]):not([class*="ke-map-"]) {
  color: inherit;
  font: inherit;
  line-height: inherit;
  cursor: pointer;
}

button:not(.btn):not(.btn-close):not(.form-select):not(.page-link):not(.dropdown-item):not(.nav-link):not(.accordion-button):not(.navbar-toggler):not([class*="bg-"]):not(.glass-surface):not(.glass-card):not(.glass-muted):not([class*="cad-"]):not([class^="board-"]):not([class*=" board-"]):not([class*="field-btn"]):not([class*="ke-map-"]) {
  background-color: transparent;
}

button:not(.btn):not(.btn-close):not(.form-select):not(.page-link):not(.dropdown-item):not(.nav-link):not(.accordion-button):not(.navbar-toggler):not([class*="border"]):not([class*="cad-"]):not([class^="board-"]):not([class*=" board-"]):not([class*="field-btn"]):not([class*="ke-map-"]) {
  border: 0;
}

button:not(.btn):not(.btn-close):not(.form-select):not(.page-link):not(.dropdown-item):not(.nav-link):not(.accordion-button):not(.navbar-toggler):not([class*="p-"]):not([class*="px-"]):not([class*="py-"]):not([class*="cad-"]):not([class^="board-"]):not([class*=" board-"]):not([class*="field-btn"]):not([class*="ke-map-"]) {
  padding: 0;
}

button:not(.btn):disabled {
  cursor: not-allowed;
  opacity: 0.58;
}

.btn-icon-ghost {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
}

.btn-icon-ghost:hover,
.btn-icon-ghost:focus-visible {
  background: var(--ke-muted-surface);
  color: var(--ke-text);
}

[data-bs-theme="dark"] [data-theme-visible-when="light"],
[data-bs-theme="light"] [data-theme-visible-when="dark"] {
  display: none !important;
}

/* Enias brand lockup — theme-aware two-file swap (Stage 40, D2). The class
   names follow the artwork's ink colour, not the theme it appears in: the
   dark-ink lockup (EniasLogo_dark.png) shows on the light theme, and the
   light-ink lockup (EniasLogo_light.png) shows on the dark theme. */
.brand-logo-light {
  display: none;
}

[data-bs-theme="dark"] .brand-logo-light {
  display: inline-block;
}

[data-bs-theme="dark"] .brand-logo-dark {
  display: none;
}

.form-control,
.form-select {
  background-color: color-mix(in srgb, var(--ke-surface) 82%, transparent);
  border-color: rgba(88, 102, 135, 0.24);
  color: var(--ke-text);
}

.page-body input:not([type]),
.page-body input[type="date"],
.page-body input[type="datetime-local"],
.page-body input[type="email"],
.page-body input[type="month"],
.page-body input[type="number"],
.page-body input[type="password"],
.page-body input[type="search"],
.page-body input[type="tel"],
.page-body input[type="text"],
.page-body input[type="time"],
.page-body input[type="url"],
.page-body input[type="week"],
.page-body select,
.page-body textarea,
.modal input:not([type]),
.modal input[type="date"],
.modal input[type="datetime-local"],
.modal input[type="email"],
.modal input[type="month"],
.modal input[type="number"],
.modal input[type="password"],
.modal input[type="search"],
.modal input[type="tel"],
.modal input[type="text"],
.modal input[type="time"],
.modal input[type="url"],
.modal input[type="week"],
.modal select,
.modal textarea {
  background-color: color-mix(in srgb, var(--ke-surface) 82%, transparent);
  border: 1px solid rgba(88, 102, 135, 0.24);
  border-radius: var(--ke-radius-control);
  color: var(--ke-text);
}

.page-body input:not([type]),
.page-body input[type="date"],
.page-body input[type="datetime-local"],
.page-body input[type="email"],
.page-body input[type="month"],
.page-body input[type="number"],
.page-body input[type="password"],
.page-body input[type="search"],
.page-body input[type="tel"],
.page-body input[type="text"],
.page-body input[type="time"],
.page-body input[type="url"],
.page-body input[type="week"],
.page-body select:not([multiple]),
.modal input:not([type]),
.modal input[type="date"],
.modal input[type="datetime-local"],
.modal input[type="email"],
.modal input[type="month"],
.modal input[type="number"],
.modal input[type="password"],
.modal input[type="search"],
.modal input[type="tel"],
.modal input[type="text"],
.modal input[type="time"],
.modal input[type="url"],
.modal input[type="week"],
.modal select:not([multiple]) {
  min-height: 2.35rem;
}

.page-body select[multiple],
.modal select[multiple] {
  min-height: 7rem;
}

.page-body input::placeholder,
.page-body textarea::placeholder,
.modal input::placeholder,
.modal textarea::placeholder {
  color: var(--ke-text-subtle);
}

.page-body input:focus,
.page-body select:focus,
.page-body textarea:focus,
.modal input:focus,
.modal select:focus,
.modal textarea:focus {
  border-color: var(--ke-brand-500);
  box-shadow: 0 0 0 0.25rem rgba(12, 142, 235, 0.18);
  outline: 0;
}

.page-body input:disabled,
.page-body select:disabled,
.page-body textarea:disabled,
.modal input:disabled,
.modal select:disabled,
.modal textarea:disabled {
  opacity: 0.68;
}

.page-body select option,
.modal select option {
  background: var(--ke-canvas);
  color: var(--ke-text);
}

/* The option background above hides the browser's own selected-option
   highlight, so a multi-select showed no sign of what was picked (EN-0607).
   A gradient, not background-color: Chromium ignores a plain colour on a
   checked option. */
.page-body select[multiple] option:checked,
.modal select[multiple] option:checked {
  background: linear-gradient(var(--ke-brand-100), var(--ke-brand-100));
  color: var(--ke-brand-900);
  font-weight: 600;
}

[data-bs-theme="dark"] .page-body select[multiple] option:checked,
[data-bs-theme="dark"] .modal select[multiple] option:checked {
  background: linear-gradient(var(--ke-brand-800), var(--ke-brand-800));
  color: var(--ke-brand-100);
}

/* Checkbox dropdown (components/forms.html#checkbox-dropdown): a compact
   multi-select for filter bars. */
.ke-checkbox-dropdown > .form-select {
  /* Same height as the page's selects (.page-body select above). */
  min-height: 2.35rem;
  min-width: 11rem;
  max-width: 16rem;
}

/* A glass surface (backdrop-filter) is its own stacking context, so a
   dropdown opened inside one was painted under the cards that follow it
   (the H&S dashboard filters). Lift the surface while its menu is open. */
.glass-surface:has(.dropdown-menu.show),
.glass-card:has(.dropdown-menu.show) {
  position: relative;
  z-index: 3;
}

.ke-checkbox-dropdown .dropdown-menu {
  max-height: 20rem;
  overflow-y: auto;
}

/* full_width (#field-checkbox-dropdown): as wide as the form's other
   controls, with a menu to match. */
.ke-checkbox-dropdown--field > .form-select {
  min-width: 0;
  max-width: none;
  width: 100%;
}

.ke-checkbox-dropdown--field .dropdown-menu {
  width: 100%;
}

.ke-checkbox-dropdown .dropdown-item .form-check-input {
  flex-shrink: 0;
  margin: 0;
}

.form-control:focus,
.form-select:focus {
  border-color: var(--ke-brand-500);
  box-shadow: 0 0 0 0.25rem rgba(12, 142, 235, 0.18);
}

.form-control::placeholder {
  color: var(--ke-text-subtle);
}

/* Auto-growing textarea (EN-0389): grows with its content up to 24rem, then
   scrolls; the user can still drag it taller. Pure CSS — no JS. */
.form-control-autogrow {
  field-sizing: content;
  min-height: calc(2lh + 0.75rem + 2px);
  max-height: 24rem;
  resize: vertical;
}

.form-check-input:checked {
  background-color: var(--ke-brand-600);
  border-color: var(--ke-brand-600);
}

/* Stage 40 squared corners: Bootstrap's compiled dist ships a literal
   `border-radius: .25em` on `.form-check-input[type="checkbox"]` that the
   zeroed --bs-border-radius* tokens don't reach, so it needs an explicit
   override. `.form-switch .form-check-input` is the one documented
   exception (D4, toggle switches keep their pill shape) — it carries equal
   selector specificity to the checkbox rule above, so it must come after it
   here to win the cascade. Radio inputs are untouched (`border-radius: 50%`
   stays a true circle). */
.form-check-input[type="checkbox"] {
  border-radius: 0;
}

.form-switch .form-check-input {
  border-radius: 2em;
}

.app-shell {
  height: 100vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* Row below the full-width topbar: fixed sidebar rail + scrolling main area. */
.app-body {
  flex: 1 1 auto;
  min-height: 0;
}

.app-main-wrap {
  height: 100%;
  overflow: hidden;
}

@media (min-width: 992px) {
  .app-main-wrap {
    margin-left: var(--ke-sidebar-collapsed-width);
    transition: margin-left 0.2s ease;
  }

  html.sidebar-expanded .app-main-wrap {
    margin-left: var(--ke-sidebar-width);
  }
}

.app-sidebar {
  width: var(--ke-sidebar-width);
  overflow-x: hidden;
  background: var(--ke-sidebar-bg, rgba(255, 255, 255, 0.96)) !important;
  border-right: 1px solid var(--ke-chrome-border) !important;
}

.app-sidebar .nav-pills .nav-link {
  border-radius: 0;
}

.app-sidebar .nav-pills .nav-link.active {
  background-color: rgba(var(--bs-primary-rgb), 0.12);
  color: var(--ke-brand-700);
}

[data-bs-theme="dark"] .app-sidebar .nav-pills .nav-link.active {
  background-color: rgba(12, 142, 235, 0.16);
  color: var(--ke-brand-300);
}

/* The sidebar nav scrolls when there are more modules than fit; the scrollbar
   is hidden in favour of the chevron affordance in the sticky footer. */
.app-sidebar-nav {
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.app-sidebar-nav::-webkit-scrollbar {
  width: 0;
  height: 0;
}

/* Absolutely positioned so toggling it never changes the nav's own height —
   an in-flow hint would resize the scroll area and could oscillate at the
   point where the list only just overflows. It sits inside the sticky
   section's top padding. */
.app-sidebar-scroll-hint {
  position: absolute;
  top: 0.0625rem;
  left: 50%;
  transform: translate(-50%, 0);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.5rem;
  height: 0.875rem;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--bs-secondary-color);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.15s ease;
}

.app-sidebar-scroll-hint:hover,
.app-sidebar-scroll-hint:focus-visible {
  color: var(--bs-body-color);
}

.app-sidebar-scroll-hint.is-visible {
  opacity: 1;
  visibility: visible;
  animation: ke-sidebar-scroll-hint 1.8s ease-in-out infinite;
}

@keyframes ke-sidebar-scroll-hint {
  0%,
  100% {
    transform: translate(-50%, 0);
  }
  50% {
    transform: translate(-50%, 0.125rem);
  }
}

@media (prefers-reduced-motion: reduce) {
  .app-sidebar-scroll-hint.is-visible {
    animation: none;
  }
}

@media (min-width: 992px) {
  .app-sidebar {
    position: fixed;
    inset: var(--ke-topbar-height) auto 0 0;
    z-index: var(--ke-z-sidebar);
    width: var(--ke-sidebar-collapsed-width);
    transform: none !important;
    visibility: visible !important;
    transition: width 0.2s ease;
  }

  html.sidebar-expanded .app-sidebar {
    width: var(--ke-sidebar-width);
  }

  .app-sidebar [data-sidebar-nav-link] {
    width: 100%;
    flex-direction: column;
    gap: 0.125rem !important;
    justify-content: center;
    padding: 0.5rem 0.25rem;
  }

  html.sidebar-expanded .app-sidebar [data-sidebar-nav-link] {
    flex-direction: row;
    gap: 1rem !important;
    justify-content: flex-start;
    padding: 0.5rem 1rem;
  }

  .app-sidebar [data-sidebar-label] {
    font-size: 0.6875rem;
    line-height: 1.2;
    text-align: center;
    white-space: normal;
    flex-grow: 0 !important;
  }

  html.sidebar-expanded .app-sidebar [data-sidebar-label] {
    font-size: inherit;
    text-align: start;
    white-space: nowrap;
    flex-grow: 1 !important;
  }

  .app-sidebar [data-sidebar-expanded] {
    opacity: 0;
    pointer-events: none;
    max-width: 0;
    overflow: hidden;
    white-space: nowrap;
    transition: opacity 0.12s ease;
  }

  html.sidebar-expanded .app-sidebar [data-sidebar-expanded] {
    opacity: 1;
    pointer-events: auto;
    max-width: 12rem;
  }

  /* Nav count badge (components/nav_badge.html): inline pill after the label
     when expanded; floated over the icon's top-right corner when the rail is
     collapsed, mirroring the topbar bell badge. */
  .app-sidebar [data-sidebar-nav-link] {
    position: relative;
  }

  .app-sidebar .app-nav-badge {
    position: absolute;
    top: 0.125rem;
    left: 50%;
    margin-left: 0.375rem;
  }

  html.sidebar-expanded .app-sidebar .app-nav-badge {
    position: static;
    margin-left: 0;
  }

  /* First nav row carries the rail toggle: beside the link when expanded,
     stacked above it when collapsed (DOM order is link-then-button, so the
     collapsed state uses column-reverse). */
  .app-sidebar-lead {
    display: flex;
    flex-direction: column-reverse;
    align-items: center;
    gap: 0.25rem;
    /* The nav <ul> is a wrapping column flex container, so its single line
       stretches every <li> to the widest one's content. Pinning this row to the
       list width stops the added toggle widening all of them past the
       sidebar's overflow-x: hidden edge. */
    width: 100%;
    min-width: 0;
  }

  .app-sidebar-lead > [data-sidebar-nav-link] {
    width: 100%;
  }

  html.sidebar-expanded .app-sidebar-lead {
    flex-direction: row;
  }

  html.sidebar-expanded .app-sidebar-lead > [data-sidebar-nav-link] {
    flex: 1 1 auto;
    min-width: 0;
    width: auto;
  }
}

.app-topbar {
  position: relative;
  z-index: var(--ke-z-topbar);
  min-height: var(--ke-topbar-height);
  border-bottom: 1px solid var(--ke-chrome-border);
}

@media (min-width: 992px) {
  /* Locked to the token the fixed sidebar offsets itself by, so the rail
     always starts exactly under the topbar. */
  .app-topbar {
    height: var(--ke-topbar-height);
  }
}

.app-topbar-brand {
  display: flex;
  align-items: center;
  flex-shrink: 0;
  height: 100%;
  padding-inline: 1rem;
  border-right: 1px solid var(--ke-chrome-border);
}

.app-topbar-brand img {
  max-height: 3.5rem;
  /* Below lg there is no sidebar to match and the topbar still has to fit the
     offcanvas hamburger, search and user controls, so the lockup runs small. */
  max-width: 4.5rem;
}

@media (min-width: 992px) {
  /* Fixed at the expanded sidebar width so the divider lines up exactly with
     the sidebar's right edge. */
  .app-topbar-brand {
    width: var(--ke-sidebar-width);
  }

  /* Pins the lockup to the size it rendered at in the old sidebar header,
     where the collapse toggle shared the row; the brand block is wider than
     that, so without the cap the logo would grow. */
  .app-topbar-brand img {
    max-width: 9.4rem;
  }
}

/* EN-0613: a tenant logo sits centred in the brand box, the way the Enias
   lockup sits centred in the sidebar foot. Only the tenant variant: the default
   Enias brand keeps its left-aligned layout. */
.app-topbar-brand--org {
  justify-content: center;
}

/* My Onboarding (EN-0614): the next pending step is scrolled to after a
   submit; keep it off the very top edge of the scroll area. */
[data-onb-pending] {
  scroll-margin-top: 1rem;
}

/* EN-0753: the envelope on buttons that email a customer / supplier straight
   away ({% send_hint_icon %}) — visible without hover, for touch devices. */
.send-hint-icon {
  display: inline-flex;
  align-items: center;
  margin-inline-end: 0.25rem;
  vertical-align: -0.125em;
}

/* Tenant logo (EN-0341) in the brand slot. Arbitrary artwork, so it is fitted
   inside the slot rather than sized to it; a light plate keeps dark-ink logos
   legible on the dark theme. */
.app-topbar-brand .app-topbar-org-logo {
  display: block;
  width: auto;
  height: auto;
  max-height: calc(var(--ke-topbar-height) - 1rem);
  object-fit: contain;
}

[data-bs-theme="dark"] .app-topbar-brand .app-topbar-org-logo {
  padding: 0.25rem 0.375rem;
  border-radius: var(--bs-border-radius);
  background: rgba(255, 255, 255, 0.92);
}

/* An organisation logo on a page (EN-0546): fitted inside a box at its own
   aspect ratio, never stretched or enlarged, so neither a tall nor a very wide
   logo can overflow its container. The box defaults to 4rem high; a page sets
   --org-logo-max-h (and, rarely, --org-logo-max-w) for a different size. */
.org-logo-fit {
  display: inline-block;
  width: auto;
  height: auto;
  max-width: min(100%, var(--org-logo-max-w, 20rem));
  max-height: var(--org-logo-max-h, 4rem);
  object-fit: contain;
}

/* The ID card's brand band (My ID). */
[data-id-card-brand] .org-logo-fit {
  --org-logo-max-h: 3.5rem;
}

/* Enias moves to the sidebar foot when a tenant logo takes the topbar slot:
   full lockup in the offcanvas and on the expanded rail, monogram when the
   rail is collapsed. */
.app-sidebar-brand {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.25rem 0.5rem 0;
}

.app-sidebar-brand-full {
  display: block;
}

.app-sidebar-brand-full img {
  max-height: 2.5rem;
  max-width: 8rem;
}

.app-sidebar-brand-icon {
  display: none;
  width: 2rem;
  height: 2rem;
}

@media (min-width: 992px) {
  html:not(.sidebar-expanded) .app-sidebar-brand-full {
    display: none;
  }

  html:not(.sidebar-expanded) .app-sidebar-brand-icon {
    display: block;
  }
}

.content-container {
  width: min(100%, 90rem);
  margin-inline: auto;
}

.page-body a.d-block {
  color: inherit;
  text-decoration: none;
}

.page-body a:not(.text-decoration-underline):not([class*="link-underline"]),
.modal a:not(.text-decoration-underline):not([class*="link-underline"]) {
  text-decoration: none;
}

.page-body a:not(.text-decoration-underline):not([class*="link-underline"]):hover,
.page-body a:not(.text-decoration-underline):not([class*="link-underline"]):focus-visible,
.modal a:not(.text-decoration-underline):not([class*="link-underline"]):hover,
.modal a:not(.text-decoration-underline):not([class*="link-underline"]):focus-visible {
  text-decoration: none;
}

.page-body a.glass-surface,
.page-body a.glass-card,
.modal a.glass-surface,
.modal a.glass-card {
  color: inherit;
  text-decoration: none;
}

.page-body a.glass-surface:hover,
.page-body a.glass-surface:focus-visible,
.page-body a.glass-card:hover,
.page-body a.glass-card:focus-visible,
.modal a.glass-surface:hover,
.modal a.glass-surface:focus-visible,
.modal a.glass-card:hover,
.modal a.glass-card:focus-visible {
  color: inherit;
  text-decoration: none;
}

.page-body a.d-inline-flex[class*="rounded-"].border,
.page-body a.d-flex[class*="rounded-"].border,
.modal a.d-inline-flex[class*="rounded-"].border,
.modal a.d-flex[class*="rounded-"].border {
  text-decoration: none;
}

.page-body a.d-inline-flex[class*="rounded-"].border:hover,
.page-body a.d-inline-flex[class*="rounded-"].border:focus-visible,
.page-body a.d-flex[class*="rounded-"].border:hover,
.page-body a.d-flex[class*="rounded-"].border:focus-visible,
.modal a.d-inline-flex[class*="rounded-"].border:hover,
.modal a.d-inline-flex[class*="rounded-"].border:focus-visible,
.modal a.d-flex[class*="rounded-"].border:hover,
.modal a.d-flex[class*="rounded-"].border:focus-visible {
  text-decoration: none;
}

/* Scrollable underline tabs — hides the scrollbar and keeps the underline on the
   container border like the old ke-tabs component. */
.app-tabs {
  --bs-nav-underline-link-active-color: var(--bs-primary);
  scrollbar-width: none;
  margin-bottom: -1px;
}
.app-tabs::-webkit-scrollbar { display: none; }
.app-tabs .nav-link { color: var(--bs-secondary-color); }
.app-tabs .nav-link:hover, .app-tabs .nav-link:focus-visible { color: var(--ke-brand-500); }
/* Vertical divider between tab groups (a {"divider": True} entry in a module's
   nav_tabs). Not Bootstrap's .vr: as an empty flex item it has no min-content
   width, so once a long strip (People) overflows its scroll container the
   default flex-shrink squeezed it to 0px and it vanished — whether it showed
   depended on the viewport width and on which tab was active (the bold active
   label widens the strip). Never shrink it, give it a fixed height, and paint
   it from the themed border token so it reads in light and dark. */
.app-tabs-divider {
  flex: 0 0 auto;
  align-self: center;
  width: var(--bs-border-width);
  height: 1rem;
  background-color: var(--bs-border-color);
}

/* ---------------------------------------------------------------------------
   Icon rail — compact vertical section navigation for detail pages. Collapsed
   to a 46px strip of icon buttons with CSS tooltips; pin-to-expand reveals the
   labels (state persisted in localStorage by initIconRails in app.js). All
   colours flow from design tokens so light/dark themes come free.
   --------------------------------------------------------------------------- */
.app-rail-layout {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
}
.app-rail-panels {
  flex: 1 1 auto;
  min-width: 0;
}
.app-rail {
  flex: 0 0 auto;
  width: 46px;
  /* Sit in the page's left padding gutter, closer to the primary sidebar,
     without shifting the panels out of alignment with the page header. */
  margin-left: -1.5rem;
  position: sticky;
  top: 1rem;
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding: 4px;
  background: var(--ke-surface);
  border: 1px solid var(--ke-border);
  border-radius: var(--ke-radius-control);
  box-shadow: var(--ke-shadow-sm);
  overflow: visible;
  transition: width 0.18s ease;
  z-index: 2;
}
.app-rail.is-expanded {
  width: 188px;
}
/* Rails nested inside a card keep a breathing gap from the card border. */
.glass-surface .app-rail {
  margin-left: -0.75rem;
}
.app-rail-top {
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.app-rail-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  padding: 6px;
  border: 0;
  background: transparent;
  color: var(--ke-text-muted);
  border-radius: calc(var(--ke-radius-control) - 4px);
  cursor: pointer;
}
.app-rail-btn:hover,
.app-rail-btn:focus-visible {
  background: var(--ke-track);
  color: var(--bs-primary);
}
/* The search toggle carries a "Jump to Section" label that shows, like the
   item labels, only once the rail is expanded. */
.app-rail-btn-labelled {
  gap: 0.625rem;
  white-space: nowrap;
}
.app-rail.is-expanded .app-rail-btn-labelled {
  justify-content: flex-start;
  padding: 6px 10px;
}
.app-rail.is-expanded [data-rail-expand] .ke-icon {
  transform: scaleX(-1);
}
.app-rail-sep {
  height: 1px;
  background: var(--ke-border);
  margin: 3px 4px;
}
/* Group label above a run of consecutive same-group tabs — only meaningful
   once the rail is expanded and there's room for text; collapsed rails keep
   just the divider above. */
.app-rail-group-label {
  display: none;
  padding: 4px 10px 2px;
  font-size: 0.6875rem;
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--ke-text-muted);
  white-space: nowrap;
}
.app-rail.is-expanded .app-rail-group-label {
  display: block;
}
.app-rail-items {
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.app-rail-item {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.625rem;
  min-height: 36px;
  padding: 6px;
  border: 0;
  background: transparent;
  color: var(--ke-text-muted);
  text-align: left;
  text-decoration: none;
  border-radius: calc(var(--ke-radius-control) - 4px);
  cursor: pointer;
  white-space: nowrap;
}
.app-rail-item:hover,
.app-rail-item:focus-visible {
  background: var(--ke-track);
  color: var(--bs-primary);
}
.app-rail-item.active {
  background: rgba(var(--bs-primary-rgb), 0.1);
  color: var(--bs-primary);
  font-weight: 600;
}
.app-rail.is-expanded .app-rail-item {
  justify-content: flex-start;
  padding: 6px 10px;
}
.app-rail-label,
.app-rail-count {
  display: none;
}
.app-rail.is-expanded .app-rail-label {
  display: inline;
  overflow: hidden;
  text-overflow: ellipsis;
}
.app-rail.is-expanded .app-rail-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.25rem;
  margin-left: auto;
  padding: 0 0.375rem;
  font-size: 0.6875rem;
  font-weight: 600;
  line-height: 1.25rem;
  color: var(--bs-primary);
  background: rgba(var(--bs-primary-rgb), 0.12);
  border-radius: 0;
}
/* Collapsed tooltip — the dark (light-theme) pill to the right of the icon.
   Only shown while the rail is collapsed; the visible label replaces it once
   expanded. */
.app-rail-tip {
  position: absolute;
  left: calc(100% + 10px);
  top: 50%;
  transform: translateY(-50%);
  z-index: var(--ke-z-fixed);
  padding: 0.25rem 0.5rem;
  font-size: 0.75rem;
  font-weight: 500;
  line-height: 1.2;
  white-space: nowrap;
  color: var(--ke-tooltip-fg);
  background: var(--ke-tooltip-bg);
  border-radius: 0;
  box-shadow: var(--ke-shadow-sm);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.12s ease;
}
.app-rail:not(.is-expanded) .app-rail-item:hover .app-rail-tip,
.app-rail:not(.is-expanded) .app-rail-item:focus-visible .app-rail-tip {
  opacity: 1;
}
/* Type-to-jump search popover — floats to the right of the rail. */
.app-rail-search {
  position: absolute;
  left: calc(100% + 12px);
  top: 0;
  z-index: var(--ke-z-fixed);
  width: 250px;
  padding: 0.5rem;
  background: var(--ke-dropdown-bg);
  border: 1px solid var(--ke-dropdown-border);
  border-radius: var(--ke-radius-control);
  box-shadow: var(--ke-shadow);
}
.app-rail-search[hidden] {
  display: none;
}
.app-rail-search-results {
  max-height: 280px;
  overflow-y: auto;
  margin-top: 0.5rem;
}
.app-rail-search-results .app-rail-item {
  justify-content: flex-start;
  padding: 6px 10px;
  color: var(--ke-text);
}
.app-rail-search-results .app-rail-label {
  display: inline;
}
@media (max-width: 767.98px) {
  .app-rail {
    width: 46px !important;
  }
  .app-rail .app-rail-label,
  .app-rail .app-rail-count,
  .app-rail .app-rail-group-label {
    display: none !important;
  }
}
@media (prefers-reduced-motion: reduce) {
  .app-rail {
    transition: none;
  }
}

/* Per-day timesheet tabs. The active panel is selected by CSS from the
   persistent [data-active-tab] wrapper rather than Alpine x-show: the panels
   live inside #ts-week, which htmx re-renders wholesale on add/delete, and
   x-show does not reliably re-apply to swapped-in nodes. The wrapper itself is
   never swapped, so its attribute is always current and the right panel shows
   immediately on every render. Panels 0–6 are days; 7 is Attachments. */
.ts-day-tabs .ts-day-panel {
  display: none;
}
.ts-day-tabs[data-active-tab="0"] .ts-day-panel[data-tab-panel="0"],
.ts-day-tabs[data-active-tab="1"] .ts-day-panel[data-tab-panel="1"],
.ts-day-tabs[data-active-tab="2"] .ts-day-panel[data-tab-panel="2"],
.ts-day-tabs[data-active-tab="3"] .ts-day-panel[data-tab-panel="3"],
.ts-day-tabs[data-active-tab="4"] .ts-day-panel[data-tab-panel="4"],
.ts-day-tabs[data-active-tab="5"] .ts-day-panel[data-tab-panel="5"],
.ts-day-tabs[data-active-tab="6"] .ts-day-panel[data-tab-panel="6"],
.ts-day-tabs[data-active-tab="7"] .ts-day-panel[data-tab-panel="7"] {
  display: block;
}

.ke-action-card {
  min-height: 5.875rem;
  padding: 1.25rem;
  color: inherit;
  text-decoration: none;
  transition: background-color 0.15s ease, transform 0.15s ease;
}

.ke-action-card:hover {
  color: inherit;
  background: var(--ke-surface-hover);
  transform: translateY(-1px);
}

/* Selectable role card in the invite modal's role grid. The whole card is the
   label for its checkbox, so clicking anywhere toggles it; the selected state
   is driven by an Alpine :class binding rather than :has(). */
.ke-role-card {
  height: 100%;
  background: var(--ke-surface);
  border: 1px solid var(--ke-border);
  border-radius: var(--ke-radius-card);
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease;
}

.ke-role-card:hover {
  background: var(--ke-surface-hover);
}

.ke-role-card.is-selected {
  background: var(--ke-surface-hover);
  border-color: var(--ke-brand-600);
}

.ke-role-card:focus-within {
  outline: 2px solid var(--ke-brand-600);
  outline-offset: 2px;
}

/* One staged invitation awaiting send. `.has-error` marks a row the server
   rejected on the last submit. */
.ke-invite-row {
  background: var(--ke-surface);
  border: 1px solid var(--ke-border);
  border-radius: var(--ke-radius-card);
}

.ke-invite-row.has-error {
  border-color: var(--bs-danger);
}

.ke-stat-card {
  min-height: 5.875rem;
  padding: 1.25rem;
}

.ke-section-card {
  padding: 1.25rem;
}

.ke-timesheet-row {
  padding: 0.75rem;
}

/* Bordered list-row link — hover treatment for clickable dashboard rows. */
.ke-action-row {
  transition: background-color 0.15s ease;
}

.ke-action-row:hover {
  background: var(--ke-surface-hover);
}

/* Dashboard module-card lists — rows share one hairline rule between them
   instead of each sitting in its own bordered box, so a card reads as a list
   rather than a stack of nested panels. */
.ke-dashboard-list > * + * {
  border-top: 1px solid var(--bs-border-color);
}

.ke-dashboard-row {
  padding-block: 0.375rem;
}

/* Clickable rows keep a little inline padding so the hover fill is not flush
   against the text; the negative margin keeps the text aligned with the
   section heading above. */
.ke-dashboard-row.ke-action-row {
  padding-inline: 0.5rem;
  margin-inline: -0.5rem;
}

/* Stacked tables — on phones (<md) each row becomes a stacked card: the
   thead is hidden and every cell renders as a "LABEL value" line, the label
   coming from the cell's data-label attribute (cells without one span the
   full line). Cells holding a select or text/number input switch to
   label-above so the control gets the full row width. Works on DataTables-
   enhanced tables, which keep the original <table> markup, so table search
   and pagination keep working. */
@media (max-width: 767.98px) {
  .ke-table-stack thead { display: none; }
  .ke-table-stack,
  .ke-table-stack tbody { display: block; width: 100%; }
  .ke-table-stack tbody tr {
    display: block;
    padding: 0.75rem 0.25rem;
  }
  .ke-table-stack tbody tr + tr { border-top: 1px solid var(--bs-border-color); }
  .ke-table-stack tbody td {
    display: block;
    padding: 0.25rem 0 !important;
    border: 0 !important;
    white-space: normal !important;
    text-align: start !important;
  }
  .ke-table-stack tbody td[data-label] {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
  }
  .ke-table-stack tbody td[data-label]::before {
    content: attr(data-label);
    flex-shrink: 0;
    font-size: 0.75rem;
    font-weight: 500;
    text-transform: uppercase;
    color: var(--bs-secondary-color);
  }
  .ke-table-stack tbody td[data-label]:has(.form-select, input.form-control) {
    display: block;
  }
  .ke-table-stack tbody td[data-label]:has(.form-select, input.form-control)::before {
    display: block;
    margin-bottom: 0.25rem;
  }
}

/* On phones the truncated KPI sublabels and action-row titles lose too much
   to the ellipsis — let them wrap instead (utilities need !important to win
   over Bootstrap's .text-truncate). */
@media (max-width: 575.98px) {
  .ke-kpi-card .text-truncate,
  .ke-action-row .text-truncate {
    white-space: normal !important;
    overflow: visible !important;
    text-overflow: clip !important;
  }
}

.operational-settings-layout {
  display: grid;
  gap: 1.25rem;
  align-items: start;
}

.operational-settings-nav {
  min-width: 0;
}

.operational-settings-nav .nav {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.operational-settings-nav .nav > hr,
.operational-settings-nav .nav > .small {
  grid-column: 1 / -1;
}

.operational-settings-nav .nav > hr {
  width: 100%;
  margin-block: 0.35rem;
}

.operational-settings-nav .nav-link {
  position: relative;
  min-width: 0;
  border-radius: 0;
  padding: 0.5rem 0.5rem;
  font-size: 0.8125rem;
}

.operational-settings-nav .nav-link.active {
  background: var(--ke-muted-surface);
  box-shadow: inset 2px 0 0 var(--ke-brand-500);
  color: var(--ke-brand-500);
  font-weight: 700;
}

.operational-settings-nav .nav-link.active:hover,
.operational-settings-nav .nav-link.active:focus-visible {
  color: var(--ke-brand-400);
}

.operational-settings-content {
  min-width: 0;
}

/* The roster pages' left nav (plan 66): a compact white card styled like a
   dropdown menu, so it takes less room beside the roster tools. */
.roster-section-nav {
  align-self: start;
  padding: 0.35rem 0;
  background: var(--ke-dropdown-bg);
  border: 1px solid var(--ke-dropdown-border);
  box-shadow: var(--bs-box-shadow-sm);
}

.roster-section-nav .nav {
  gap: 0;
}

.roster-section-nav .nav > .small {
  padding: 0.45rem 0.9rem 0.15rem !important;
  font-size: 0.68rem;
  letter-spacing: 0.06em;
}

.roster-section-nav .nav > hr {
  margin-block: 0.3rem;
  color: var(--ke-dropdown-border);
  opacity: 1;
}

.roster-section-nav.operational-settings-nav .nav-link {
  padding: 0.28rem 0.9rem;
  font-size: 0.8rem;
}

.roster-section-nav .nav-link.text-body-secondary {
  color: var(--ke-text) !important;
}

.roster-section-nav .nav-link:hover,
.roster-section-nav .nav-link:focus-visible {
  background: var(--ke-muted-surface);
}

.roster-section-nav.operational-settings-nav .nav-link.active,
.roster-section-nav.operational-settings-nav .nav-link.active:hover,
.roster-section-nav.operational-settings-nav .nav-link.active:focus-visible {
  background: var(--ke-brand-600);
  box-shadow: none;
  color: #fff;
  font-weight: 600;
}

/* Icon rails nested in a settings child (Skills catalogue) pull left with a
   negative margin sized for a full page's p-4 gutter; inside the settings
   grid that would overlap the vertical nav column. */
.operational-settings-content .app-rail {
  margin-left: 0;
}

.operational-form-card {
  padding: 1rem;
}

.operational-settings-form .mb-3 {
  margin-bottom: 0 !important;
}

.settings-edit-table {
  min-width: 44rem;
  border-collapse: separate;
  border-spacing: 0;
}

.settings-edit-table thead th {
  background: var(--ke-muted-surface);
}

.settings-edit-table th,
.settings-edit-table td {
  padding: 0.55rem 0.75rem;
  border-bottom: 1px solid rgba(88, 102, 135, 0.14);
}

[data-bs-theme="dark"] .settings-edit-table th,
[data-bs-theme="dark"] .settings-edit-table td {
  border-bottom-color: rgba(255, 255, 255, 0.06);
}

.settings-edit-table .form-control,
.settings-edit-table .form-select {
  min-height: 2rem;
  border-radius: 0;
  font-size: 0.8125rem;
  padding: 0.3rem 0.55rem;
}

.settings-edit-table .form-check-input {
  margin-top: 0.15rem;
}

.settings-edit-table .form-control-color {
  width: 2.25rem;
  min-height: 2rem;
  padding: 0.2rem;
}

.settings-delete-overlay {
  position: fixed;
  inset: 0;
  z-index: var(--ke-z-overlay);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background-color: rgba(0, 0, 0, 0.58);
}

.settings-delete-dialog {
  width: min(100%, 28rem);
  padding: 1.5rem;
}

@media (min-width: 768px) {
  .operational-settings-layout {
    grid-template-columns: minmax(10rem, 11rem) minmax(0, 1fr);
  }

  .operational-settings-nav {
    position: sticky;
    top: 1rem;
  }
}

.quote-totals dl {
  margin-bottom: 0;
}

.quote-totals-divider {
  margin-top: 0.65rem;
  padding-top: 0.65rem;
  border-top: 1px solid var(--bs-border-color);
}

/* EN-0677: the Subtotal (ex VAT) is the emphasised figure; the grand total
   sits below it in the regular VAT-row weight with the ordinary divider. */
.quote-totals-grand {
  margin-top: 0.65rem;
  padding-top: 0.65rem;
  border-top: 1px solid var(--bs-border-color);
}

.quote-line-table {
  border-collapse: separate;
  border-spacing: 0;
  min-width: 58rem;
}

.quote-line-table.is-editable {
  min-width: 76rem;
}

.quote-line-table > thead > tr > th {
  background: var(--ke-muted-surface);
}

.quote-line-table > tbody > tr > * {
  border-bottom: 1px solid rgba(88, 102, 135, 0.12);
  /* Top-align cells so every field shares the same top edge. Material lines
     stack the source name / Edit link under the description input, which would
     otherwise shift the row's shared baseline and pull the single-line inputs
     out of line. The grip cell keeps its own .align-middle. */
  vertical-align: top;
}

[data-bs-theme="dark"] .quote-line-table > tbody > tr > * {
  border-bottom-color: rgba(255, 255, 255, 0.055);
}

/* Tighten cell padding so the dropdown columns have room to show full labels.
   Overrides Bootstrap's .px-3 utility (which carries !important) on these cells. */
.quote-line-table > thead > tr > th,
.quote-line-table > tbody > tr > td {
  padding-left: 0.375rem !important;
  padding-right: 0.375rem !important;
}

/* Row hover feedback. The table opts out of DataTables (data-datatable="false"
   on the markup), so it carries neither .table-hover nor the DataTables theme's
   hover rule — this keeps the tint the grid has always had. Group header rows
   set their own !important cell background and stay branded. */
.quote-line-table > tbody > tr:hover > * {
  background: var(--ke-muted-surface);
}

/* Column widths (EN-0376). Every deliverable table uses table-layout: fixed
   with a <colgroup>, so each deliverable's columns line up with the next one's
   (and the stacked sticky headers align) whatever the rows contain. Widths are
   percentages of the table, so a table always fills its card; the grip column
   is a fixed sliver and Description (no class) takes whatever is left. The same
   classes sit on the matching <th> for readability. */
.quote-col-grip {
  width: 2.25rem;
}

.quote-col-type {
  width: 11%;
}

.quote-col-qty {
  width: 9%;
}

.quote-col-unit {
  width: 11%;
}

.quote-col-num {
  width: 7.5%;
}

.quote-col-total {
  width: 8.5%;
}

.quote-col-flags {
  width: 8.5%;
}

.quote-col-actions {
  width: 10%;
}

/* Fixed columns can be narrower than a row's buttons — let them wrap rather
   than spill into the neighbouring cell. */
.deliverable-line-table .quote-table-actions {
  flex-wrap: wrap;
}

/* Job deliverable tables (editable card and read-only overview card). Their
   column sets differ from the quote's (Actual / Rate on T&M, CAD, Status), so
   they get their own widths. */
.job-col-type {
  width: 12%;
}

.job-col-qty {
  width: 7%;
}

.job-col-actual {
  width: 9%;
}

.job-col-unit {
  width: 10%;
}

.job-col-num {
  width: 9%;
}

.job-col-markup {
  width: 8%;
}

.job-col-cad {
  width: 7%;
}

.job-col-status {
  width: 12%;
}

.job-col-actions {
  width: 9%;
}

/* EN-0757: the line-select checkbox column (Create PO from ticked lines). */
.job-col-select {
  width: 2.25rem;
}

/* EN-0581: the editable job card's cells hold inputs, so its fixed columns
   get tighter padding, and on T&M the Actual column (clock toggle + input +
   timesheet panel) takes width from Type / Unit / Status / Actions — the
   inputs could not shrink and spilled over the Quoted column. Scoped to the
   editable table; the read-only overview and the quote grid keep theirs. */
.job-line-table-edit > thead > tr > th:not(.quote-col-grip),
.job-line-table-edit > tbody > tr > td:not(.quote-col-grip) {
  padding-left: 0.5rem !important;
  padding-right: 0.5rem !important;
}

/* EN-0752: T&M rows carry a Markup column too, so its widths come out of
   Type / Qty / Actual / Unit / Status (Qty only ever holds a figure or a dash
   on a line added on the job). */
.job-line-table-tm .job-col-type {
  width: 10%;
}

.job-line-table-tm .job-col-qty {
  width: 6%;
}

.job-line-table-tm .job-col-actual {
  width: 12%;
}

.job-line-table-tm .job-col-unit {
  width: 8%;
}

.job-line-table-tm .job-col-markup {
  width: 7%;
}

.job-line-table-tm .job-col-cad {
  width: 6%;
}

.job-line-table-tm .job-col-status {
  width: 10%;
}

.job-line-table-tm .job-col-actions {
  width: 7%;
}

/* Number spinners eat most of a narrow cell; typed figures are the norm here. */
.job-line-table-edit input[type="number"] {
  -moz-appearance: textfield;
  appearance: textfield;
}

.job-line-table-edit input[type="number"]::-webkit-inner-spin-button,
.job-line-table-edit input[type="number"]::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.job-line-table-edit .form-control-sm,
.job-line-table-edit .form-select-sm {
  min-width: 0;
}

/* The Actual input fills what the clock toggle leaves of its cell (capped at
   the old compact width) instead of a fixed 6.5rem that overflowed it. */
.job-line-actual-field {
  min-width: 0;
}

.job-line-actual-input {
  flex: 1 1 auto;
  width: 100%;
  min-width: 0;
  max-width: 6.5rem;
}

/* Timesheet figures wrap inside the Actual cell rather than spilling out. */
.job-line-ts-panel {
  min-width: 0;
  white-space: normal;
  overflow-wrap: anywhere;
}

.job-line-ts-panel > button {
  max-width: 100%;
}

/* Shared deliverable line table (quote card, job editable card, job overview
   card). border-collapse: separate so cell borders travel with the sticky
   header cells; collapsed borders stay behind on the table. */
.deliverable-line-table {
  border-collapse: separate;
  border-spacing: 0;
  table-layout: fixed;
}

.deliverable-line-table > thead > tr > th {
  border-bottom: 1px solid var(--bs-border-color);
}

.job-line-table > thead > tr > th {
  border-top: 1px solid var(--bs-border-color);
}

.job-line-table > tbody > tr > * {
  border-bottom: 1px solid rgba(88, 102, 135, 0.12);
}

[data-bs-theme="dark"] .job-line-table > tbody > tr > * {
  border-bottom-color: rgba(255, 255, 255, 0.055);
}

/* Read-only overview card: the group row's divider now lives on its cells
   (separate borders ignore a <tr> border). */
.job-line-table > tbody > tr[data-overview-group-row] > td {
  border-top: 1px solid var(--bs-border-color);
}

/* Sticky column headers (EN-0376). The page scroller is main#main-content, so
   no wrapper between a table and main may set overflow (that would become the
   sticky container) — the tables overflow into main, which scrolls sideways
   on narrow screens. Each header is constrained by its own table, so the next
   deliverable's header pushes the previous one off. The opaque background
   hides the rows passing underneath; the z-index clears row inputs and
   focused input groups (Bootstrap z 5) but stays below dropdowns
   (--ke-z-dropdown) and modals. */
.ke-sticky-head > thead > tr > th {
  position: sticky;
  top: 0;
  z-index: 6;
  background: var(--ke-sticky-head-bg) !important;
}

/* The page scroller (main.app-main, p-4 p-lg-5) insets the sticky area by its
   own top padding, which left a strip of rows scrolling between the top bar
   and the stuck header. Pull the header up by that padding so it sits flush
   under the top bar. Keep in step with the padding classes in app_shell.html. */
.app-main .ke-sticky-head > thead > tr > th {
  top: -1.5rem;
}

@media (min-width: 992px) {
  .app-main .ke-sticky-head > thead > tr > th {
    top: -3rem;
  }
}

/* A deliverable card grows with its table when the table's floor is wider than
   the viewport, so the card chrome keeps wrapping the lines while main
   scrolls sideways. */
.deliverable-card-fit {
  width: fit-content;
  min-width: 100%;
}

/* Below the split-pane breakpoint the job tables get a floor too; at lg+ they
   sit in the 2/3 split column and must fit it (overflowing would run under the
   Milestones pane). */
@media (max-width: 991.98px) {
  .job-line-table {
    min-width: 44rem;
  }

  /* Inputs need more room than read-only figures (EN-0581). */
  .job-line-table-edit {
    min-width: 50rem;
  }
}

/* EN-0596: with the Milestones pane open the split column can be narrower than
   the editable table needs, and the Status button and Actions buttons spilled
   out of their fixed-% cells (under the pane). Their content now wraps inside
   the cell, and at lg+ the table's frame is a size container: only while it is
   narrower than the table's floor does the inner scroller turn on overflow-x,
   so the table scrolls inside its card. Any wider (pane closed, big screens)
   nothing scrolls and the sticky header (EN-0376) keeps sticking to main; while
   scrolling, the scroller captures the header so it no longer sticks — the
   trade-off for not running under the pane. Below lg the frame is no container,
   so the card keeps growing with the table as before. */
.job-line-status-cell,
.job-line-actions-cell {
  overflow-wrap: anywhere;
}

.job-line-status-cell .btn {
  max-width: 100%;
  white-space: normal;
  text-align: start;
}

.job-line-actions-cell .job-line-actions > button {
  white-space: nowrap;
}

@media (min-width: 992px) {
  .job-line-table-frame {
    container: job-lines / inline-size;
  }
}

@container job-lines (max-width: 49.99rem) {
  .job-line-table-scroll {
    overflow-x: auto;
  }

  .job-line-table-scroll > .job-line-table-edit {
    min-width: 50rem;
  }
}

.quote-row-grip,
.quote-group-grip {
  opacity: 0.5;
}

.quote-row-grip:hover,
.quote-group-grip:hover {
  opacity: 1;
}

.quote-line-group-row > * {
  background: color-mix(in srgb, var(--ke-brand-600) 14%, var(--ke-surface) 86%) !important;
  border-top-color: rgba(var(--bs-primary-rgb), 0.35) !important;
  border-bottom-color: rgba(var(--bs-primary-rgb), 0.35) !important;
}

[data-bs-theme="dark"] .quote-line-group-row > * {
  background: color-mix(in srgb, var(--ke-brand-600) 22%, var(--ke-surface) 78%) !important;
}

.quote-line-group-accent {
  background: var(--ke-brand-400);
}

.quote-line-group-count {
  border: 1px solid rgba(var(--bs-primary-rgb), 0.32);
  background: rgba(var(--bs-primary-rgb), 0.18);
  color: var(--ke-brand-700);
  font-size: 0.6875rem;
}

[data-bs-theme="dark"] .quote-line-group-count {
  color: var(--ke-brand-300);
}

/* Collapsible groups: hide the group's child line rows, keep its header. */
tbody[data-group-id].quote-group-collapsed tr[data-line-row] {
  display: none;
}

.quote-group-collapse-chevron {
  transition: transform 0.15s ease;
}

tbody.quote-group-collapsed .quote-group-collapse-chevron {
  transform: rotate(-90deg);
}

/* Drop-zone hint row: hidden until a line drag is in progress, so the
   standalone tbody always has a visible drop target even when every line
   currently belongs to a group (and the tbody would otherwise be 0-height).
   Table-agnostic on purpose — the quote builder and the job deliverable card
   share the reorder behaviour but not the .quote-line-table sizing, whose
   min-width would force a horizontal scrollbar inside the Job Overview. */
tr[data-drop-hint] {
  display: none;
}

table.quote-drag-active tr[data-drop-hint] {
  display: table-row;
}

table.quote-drag-active tr[data-drop-hint] > td {
  border: 1px dashed var(--bs-border-color);
}

.quote-table-actions button,
.quote-table-actions a {
  font-weight: 500;
  text-decoration: none;
}

.quote-table-actions button:hover,
.quote-table-actions a:hover {
  text-decoration: none;
}

.quote-line-cell-input {
  background: transparent;
  border: 0;
  padding: 0.25rem 0.4rem;
  width: 100%;
  border-radius: 0;
  color: inherit;
  font-size: inherit;
  font-family: inherit;
}

.quote-line-cell-input:focus {
  outline: 2px solid var(--bs-primary);
  background: var(--bs-body-bg);
}

.quote-line-cell-input.is-invalid {
  box-shadow: 0 0 0 2px var(--bs-danger);
}

.quote-line-cell-input::placeholder {
  opacity: 0.55;
}

.quote-line-cell-input:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* Cell inputs are read as figures, not steppers: hide the native spinner so it
   cannot eat the width of a narrow column. */
.quote-line-cell-input[type="number"] {
  -moz-appearance: textfield;
  appearance: textfield;
}

.quote-line-cell-input[type="number"]::-webkit-outer-spin-button,
.quote-line-cell-input[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

/* The TOTAL column swaps a text-width button for a number input on click.
   The quote table is table-layout: fixed (EN-0376), so the column width comes
   from its <col> and cannot shift while a total is being edited; the input
   just fills the cell. */
.quote-line-total-cell .quote-line-cell-input {
  min-width: 0;
}

/* Click-to-edit line total: reads as a plain figure in the row, and only
   hints that it is editable on hover/focus. Pairs with the input above,
   which replaces it while the cell is being edited. */
.quote-line-total-display {
  background: transparent;
  border: 0;
  padding: 0.25rem 0.4rem;
  width: 100%;
  border-radius: 0;
  text-align: right;
  color: inherit;
  font: inherit;
}

.quote-line-total-display:hover {
  background: var(--bs-secondary-bg);
  cursor: text;
}

.quote-line-total-display:focus-visible {
  outline: 2px solid var(--bs-primary);
  background: var(--bs-body-bg);
}

/* Quote builder inventory combobox (search-as-you-type material/consumable/
   machine picker). The results panel is appended to <body> and fixed-
   positioned by JS so the table's overflow-x wrapper / DataTables can't clip
   it; it inherits Bootstrap theme vars so dark mode works automatically. */
.quote-combobox {
  position: relative;
}

.quote-combobox-panel {
  position: fixed;
  z-index: var(--ke-z-overlay);
  max-height: 16rem;
  overflow-y: auto;
  padding: 0.25rem;
  background: var(--bs-body-bg);
  border: 1px solid var(--bs-border-color);
  border-radius: 0;
  box-shadow: 0 0.5rem 1.25rem rgba(0, 0, 0, 0.18);
}

.quote-combobox-option {
  display: block;
  width: 100%;
  text-align: left;
  border: 0;
  background: transparent;
  color: inherit;
  padding: 0.375rem 0.5rem;
  border-radius: 0;
  font-size: 0.8125rem;
  line-height: 1.25;
  cursor: pointer;
}

.quote-combobox-option:hover,
.quote-combobox-option.is-active {
  background: var(--bs-secondary-bg);
}

.quote-combobox-option[aria-selected="true"] {
  font-weight: 600;
}

.quote-combobox-option-name {
  display: block;
}

.quote-combobox-option-sub {
  display: block;
  font-size: 0.6875rem;
  color: var(--bs-secondary-color);
}

.quote-combobox-empty,
.quote-combobox-more {
  padding: 0.5rem;
  font-size: 0.75rem;
}

.quote-combobox-add-new {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  width: 100%;
  text-align: left;
  border: 0;
  border-top: 1px solid var(--bs-border-color);
  margin-top: 0.25rem;
  background: transparent;
  color: var(--bs-primary);
  padding: 0.5rem;
  font-size: 0.8125rem;
  line-height: 1.25;
  cursor: pointer;
}

.quote-combobox-add-new:hover,
.quote-combobox-add-new.is-active {
  background: var(--bs-secondary-bg);
}

.quote-combobox-add-new-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.125rem;
  height: 1.125rem;
  border-radius: 0;
  background: var(--bs-secondary-bg);
  font-weight: 600;
  line-height: 1;
}

.doc-row {
  transition: background-color 0.12s ease-in-out;
}

@keyframes doc-row-flash {
  0% {
    background-color: var(--bs-primary-bg-subtle);
  }
  100% {
    background-color: transparent;
  }
}

.doc-row-highlight {
  animation: doc-row-flash 2.5s ease-out 1;
}

/* Documents drop zone — dashed drop target at the top of a Documents tab.
   Uses Bootstrap CSS variables so it adapts to both light and dark themes. */
.document-dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 1.5rem 1rem;
  text-align: center;
  cursor: pointer;
  border: 2px dashed var(--bs-border-color);
  border-radius: var(--bs-border-radius-xl, 1rem);
  background: var(--bs-tertiary-bg);
  color: var(--bs-body-color);
  transition: border-color 0.15s ease-in-out, background-color 0.15s ease-in-out;
}

.document-dropzone:hover,
.document-dropzone:focus-visible {
  border-color: var(--bs-primary);
  outline: none;
}

.document-dropzone--active {
  border-color: var(--bs-primary);
  background: rgba(var(--bs-primary-rgb), 0.08);
}

/* Compact file-drop input — shared component templates/components/file_drop_input.html.
   The real file input is stretched invisibly over the face so click, focus and
   validation stay native; [data-file-drop] is the JS behaviour hook. */
.file-drop {
  position: relative;
  border: 2px dashed var(--bs-border-color);
  border-radius: var(--bs-border-radius-lg, 0.75rem);
  background: var(--bs-tertiary-bg);
  transition: border-color 0.15s ease-in-out, background-color 0.15s ease-in-out;
}
.file-drop:hover,
.file-drop:focus-within {
  border-color: var(--bs-primary);
}
.file-drop--invalid {
  border-color: var(--bs-form-invalid-border-color, var(--bs-danger));
}
.file-drop--has-files {
  border-style: solid;
}
.file-drop:has(.file-drop-input:disabled) {
  opacity: 0.6;
}
.file-drop-input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
  z-index: 1;
}
.file-drop-input:disabled { cursor: not-allowed; }
.file-drop-face {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  padding: 0.5rem 0.75rem;
  min-height: 2.75rem;
}
.file-drop-clear {
  position: relative;
  z-index: 2;
  margin-left: auto;
  flex-shrink: 0;
}
/* Accumulated picks of a multiple zone (filled by app.js). Stacked above the
   stretched input so its remove buttons are clickable and clicking a name does
   not reopen the file dialog; the face above stays the browse target. */
.file-drop-list {
  position: relative;
  z-index: 2;
  margin: 0;
  padding: 0.25rem 0.75rem 0.375rem;
  border-top: 1px dashed var(--bs-border-color);
  cursor: default;
}
.file-drop-remove {
  flex-shrink: 0;
  font-size: 0.625rem;
}
/* Drag-over highlight — standalone (not scoped under .file-drop) so bespoke
   zones opted into [data-file-drop] (e.g. the org logo uploader) get it too. */
.file-drop--active {
  border-color: var(--bs-primary) !important;
  background: rgba(var(--bs-primary-rgb), 0.08);
}

.line-item-inline-row .form-control,
.line-item-inline-row .form-select {
  min-height: 2.25rem;
  border-color: rgba(88, 102, 135, 0.28);
  border-radius: 0;
  background-color: color-mix(in srgb, var(--ke-surface) 86%, transparent);
  color: var(--ke-text);
  font-size: 0.8125rem;
  padding: 0.375rem 0.625rem;
}

.line-item-inline-row .form-control[type="number"] {
  text-align: right;
}

.line-item-inline-row .line-item-toggle-label {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.line-item-inline-row .form-check-input {
  margin-top: 0;
  background-color: color-mix(in srgb, var(--ke-surface) 82%, transparent);
  border-color: rgba(148, 163, 184, 0.45);
}

.line-item-inline-row .form-check-input:checked {
  background-color: var(--ke-brand-600);
  border-color: var(--ke-brand-600);
}

.dt-container {
  color: var(--ke-text);
}

/* DataTables 2 reverses the header (sort arrow before the label) on columns it
   detects as numeric/date. app.js pins every column to its header's alignment,
   so keep the arrow after the label unless the column is right-aligned. */
table.dataTable thead th.dt-type-numeric:not(.text-end) div.dt-column-header,
table.dataTable thead th.dt-type-date:not(.text-end) div.dt-column-header {
  flex-direction: row;
}

.dt-container .row {
  --bs-gutter-x: 0.5rem;
  --bs-gutter-y: 0.5rem;
}

.dt-container .dt-layout-row,
.dt-container > .row {
  margin-inline: 0;
  margin-block: 0 0.5rem;
}

.dt-container .dt-layout-row:last-child,
.dt-container > .row:last-child {
  margin-block: 0.5rem 0;
}

.dt-container .dt-length,
.dt-container .dt-search,
.dt-container .dt-info,
.dt-container .dt-paging {
  font-size: 0.75rem;
  color: var(--ke-text-muted);
}

.dt-container .dt-length label,
.dt-container .dt-search label {
  color: var(--ke-text-muted);
}

div.dt-container div.dt-layout-start > *:not(:last-child) {
  margin-right: 0.5rem;
}

div.dt-container div.dt-layout-end > *:not(:first-child) {
  margin-left: 0.5rem;
}

.dt-container .dt-input,
.dt-container .form-select,
.dt-container .form-control {
  min-height: 2rem;
  border-color: var(--bs-border-color);
  border-radius: 0;
  background-color: color-mix(in srgb, var(--ke-surface) 74%, transparent);
  color: var(--ke-text);
  font-size: 0.8125rem;
  padding-block: 0.25rem;
}

.dt-container .dt-search input {
  width: min(14rem, 100%);
}

.dt-container .dt-input:focus,
.dt-container .form-select:focus,
.dt-container .form-control:focus {
  border-color: var(--ke-brand-500);
  box-shadow: 0 0 0 0.2rem rgba(12, 142, 235, 0.16);
}

.dt-container .pagination {
  gap: 0.25rem;
  margin-bottom: 0;
}

.dt-container .page-link {
  min-width: 1.875rem;
  border-color: var(--bs-border-color);
  border-radius: 0 !important;
  background-color: transparent;
  color: var(--ke-text-muted);
  font-size: 0.75rem;
  padding: 0.25rem 0.5rem;
}

.dt-container .page-item.active .page-link {
  border-color: var(--ke-brand-600);
  background-color: var(--ke-brand-600);
  color: #fff;
}

.dt-container .page-item.disabled .page-link {
  background-color: transparent;
  color: var(--ke-text-subtle);
}

.dt-container table.dataTable {
  width: 100% !important;
  margin: 0 !important;
  border-top: 0 !important;
}

.dt-container table.dataTable.table-group-divider,
.dt-container table.dataTable > .table-group-divider {
  border-top: 0 !important;
}

.dt-container table.dataTable > thead > tr > th,
.dt-container table.dataTable > thead > tr > td {
  border-top: 0 !important;
  border-bottom: 1px solid var(--bs-border-color) !important;
  background: var(--ke-muted-surface);
  color: var(--ke-text-muted);
  font-size: 0.75rem;
  font-weight: 700;
  line-height: 1.25;
  padding: 0.65rem 1rem !important;
  text-transform: uppercase;
}

.dt-container table.table.dataTable > tbody > tr > *,
.dt-container table.table.dataTable > tfoot > tr > * {
  border-bottom-color: var(--bs-border-color);
  background-color: transparent;
  color: var(--ke-text);
  padding: 0.65rem 1rem !important;
  vertical-align: middle;
}

.dt-container table.dataTable > tbody > tr > th,
.dt-container table.dataTable > tbody > tr > td,
.dt-container table.dataTable > tfoot > tr > th,
.dt-container table.dataTable > tfoot > tr > td {
  line-height: 1.35;
}

.dt-container table.dataTable > tbody > tr:hover > * {
  background: var(--ke-muted-surface);
}

.dt-container table.dataTable thead > tr > th.dt-orderable-asc:hover,
.dt-container table.dataTable thead > tr > th.dt-orderable-desc:hover,
.dt-container table.dataTable thead > tr > td.dt-orderable-asc:hover,
.dt-container table.dataTable thead > tr > td.dt-orderable-desc:hover,
.dt-container table.dataTable thead > tr > th:focus,
.dt-container table.dataTable thead > tr > td:focus,
.dt-container table.dataTable thead > tr > th:focus-visible,
.dt-container table.dataTable thead > tr > td:focus-visible {
  outline: 0 !important;
  box-shadow: none !important;
}

.dt-container table.dataTable .dt-empty {
  padding-block: 2rem;
  color: var(--ke-text-muted);
  text-align: center;
}

/* ── DataTables controls on phones ───────────────────────────────────────
   The default DataTables Bootstrap layout lays the length menu, search, info
   and paging on justified rows (col-md-auto + m*-auto). Below md those cells
   collapse to content width and the auto margins centre them, so the "per
   page" select and the search box float awkwardly mid-screen (and the search
   input keeps its narrow 14rem cap). Stack every control to the full content
   width, left-aligned, with a full-width search field. The md breakpoint and
   up is untouched, so tablet and desktop keep the side-by-side strip. */
@media (max-width: 767.98px) {
  .dt-container .dt-layout-row {
    flex-wrap: wrap;
    row-gap: 0.5rem;
  }
  .dt-container .dt-layout-start,
  .dt-container .dt-layout-end,
  .dt-container .dt-layout-full {
    flex: 0 0 100%;
    max-width: 100%;
    width: 100%;
    margin-inline: 0 !important;
    justify-content: flex-start;
  }
  .dt-container .dt-length,
  .dt-container .dt-search {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    width: 100%;
    margin: 0;
  }
  .dt-container .dt-search input {
    flex: 1 1 auto;
    width: 100%;
  }
  /* The DataTables Bootstrap theme centres the info text and the pager below
     md (text-align:center; the pager uses justify-content:center !important).
     Match its selector specificity to pull both back to the start edge so the
     whole strip reads as one left-aligned column. */
  div.dt-container div.dt-info,
  div.dt-container div.dt-paging {
    text-align: start;
  }
  div.dt-container div.dt-paging ul.pagination {
    flex-wrap: wrap;
    justify-content: flex-start !important;
  }
}

/* Filter-strip tables (data-datatable-filters, class added by app.js) move the
   table search to the row start, where it is the page's only search box. The
   shrink-to-fit start cell squeezes it to ~10rem and clips the placeholder, so
   give it room from md up — below md the stacking rules above already take it
   to full width. */
@media (min-width: 768px) {
  .dt-container.dt-filter-strip .dt-search input {
    width: 18rem;
  }
}

.ke-icon {
  display: inline-block;
  width: 1rem;
  height: 1rem;
  flex-shrink: 0;
}

.ke-icon-xs {
  width: 0.75rem;
  height: 0.75rem;
}

.ke-icon-sm {
  width: 0.875rem;
  height: 0.875rem;
}

.ke-icon-md {
  width: 1rem;
  height: 1rem;
}

.ke-icon-lg {
  width: 1.25rem;
  height: 1.25rem;
}

.ke-icon-xl {
  width: 1.5rem;
  height: 1.5rem;
}

.htmx-indicator {
  display: none;
}

.htmx-request .htmx-indicator,
.htmx-request.htmx-indicator {
  display: inline-flex;
}

.htmx-request .htmx-hide-on-request {
  display: none !important;
}

.sortable-drop-target {
  outline: 2px dashed rgba(12, 142, 235, 0.45);
  outline-offset: 0.25rem;
}

.sortable-ghost {
  opacity: 0.35;
}

.sortable-chosen {
  transform: scale(1.01);
}

.toast-container {
  z-index: var(--ke-z-toast);
}

/* Skip link: hidden until keyboard focus. A plain translateY(-150%) only just
   cleared the top edge, and iOS Safari (URL bar, safe areas, overscroll)
   showed a sliver of it below the address bar. So the unfocused link is also
   clipped to nothing and moved past its own height plus its 1rem offset.
   Not display:none/visibility:hidden — it must stay reachable by Tab. */
.skip-link {
  position: absolute;
  top: 1rem;
  left: 1rem;
  z-index: var(--ke-z-skip-link);
  clip-path: inset(50%);
  transform: translateY(calc(-100% - 2rem));
  transition: transform 0.15s ease;
}

.skip-link:focus {
  clip-path: none;
  transform: translateY(0);
}

/* Honeypot field (apps.users.forms.HoneypotFormMixin) — deliberately NOT
   Bootstrap's .visually-hidden, which screen readers still announce and would
   give a real user a field to fill in.

   Uses display:none rather than off-screen positioning: browsers and password
   managers DO autofill off-screen inputs, and on the identifier-first password
   step the honeypot was the only fillable text input beside the password, so
   managers filled it and every real login was rejected as a bot. display:none
   is skipped by autofill. It is marginally easier for a sophisticated bot to
   detect, which is the right trade: the real throttles are the per-IP and
   per-email rate limits on login step 1 plus allauth's own login rate limits
   and lockouts, and a honeypot that locks legitimate users out is worse than a
   slightly more detectable one. */
.aux-field {
  display: none !important;
}

/* Auth-shell main column (layouts/auth_shell.html): the card's width cap. */
.auth-shell-main {
  max-width: 28rem;
}

/* Auth-shell theme switcher (layouts/auth_shell.html) — the Light / Dark /
   System links under the auth card read as quiet text links; the active
   choice (aria-pressed) is emphasised rather than coloured. */
.auth-theme-switcher .btn-link {
  color: var(--bs-secondary-color);
  text-decoration: none;
}

.auth-theme-switcher .btn-link:hover,
.auth-theme-switcher .btn-link:focus-visible {
  color: var(--bs-body-color);
  text-decoration: underline;
}

.auth-theme-switcher .btn-link[aria-pressed="true"] {
  color: var(--bs-body-color);
  font-weight: 600;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}

@media print {
  .app-sidebar,
  .app-topbar,
  .btn,
  .toast-container,
  [data-print-hidden] {
    display: none !important;
  }

  /* Sticky deliverable headers print as ordinary header rows. */
  .ke-sticky-head > thead > tr > th {
    position: static;
  }

  /* Collapsed quote groups still print in full. */
  tbody[data-group-id].quote-group-collapsed tr[data-line-row] {
    display: table-row;
  }

  /* With the roster left-nav + header (data-print-hidden) removed, let the
     content span the full page instead of sitting in a grid column. */
  .operational-settings-layout {
    display: block !important;
  }

  .roster-print-day,
  .roster-print-shift {
    break-inside: avoid;
  }

  .roster-print-table {
    border-collapse: collapse;
  }
  .roster-print-table th,
  .roster-print-table td {
    border: 1px solid #999;
    padding: 0.2rem 0.4rem;
  }

  body,
  .canvas-bg {
    background: #fff !important;
    color: #000 !important;
  }

  .glass-card,
  .glass-surface,
  .card {
    box-shadow: none !important;
    border-color: #ddd !important;
    background: #fff !important;
  }
}

/* ── Official Bootstrap-extension utility set ─────────────────────────────
   App-owned fixed-size helpers kept after the Tailwind→Bootstrap migration.
   Bootstrap has no fixed-rem sizing utilities, so these stay. Policy: a class
   lives here only while it has 3+ template usages — one-offs are inline
   styles. Do not add new ke-grid/Tailwind-port utilities; use native
   Bootstrap classes (row/col, gap-*, fst-italic, …) instead. */
.ke-w-1 { width: 0.25rem; }
.ke-h-1 { height: 0.25rem; }
.ke-h-2 { height: 0.5rem; }
.ke-w-3 { width: 0.75rem; }
.ke-h-3 { height: 0.75rem; }
.ke-w-4 { width: 1rem; }
.ke-h-4 { height: 1rem; }
.ke-h-5 { height: 1.25rem; }
.ke-h-6 { height: 1.5rem; }
.ke-w-8 { width: 2rem; }
.ke-h-8 { height: 2rem; }
.ke-w-20 { width: 5rem; }
.ke-w-24 { width: 6rem; }
.ke-w-48 { width: 12rem; }
.ke-field-compact { flex: 0 0 auto; width: 6.5rem; }
.ke-size-4 { width: 1rem; height: 1rem; }
.ke-size-5 { width: 1.25rem; height: 1.25rem; }
.ke-size-7 { width: 1.75rem; height: 1.75rem; }
.ke-size-8 { width: 2rem; height: 2rem; }
.ke-size-9 { width: 2.25rem; height: 2.25rem; }
.ke-size-10 { width: 2.5rem; height: 2.5rem; }
.ke-size-12 { width: 3rem; height: 3rem; }
.ke-size-16 { width: 4rem; height: 4rem; }
.ke-size-3-5 { width: 0.875rem; height: 0.875rem; }
.ke-min-h-0 { min-height: 0; }
.ke-max-h-80 { max-height: 20rem; }
.ke-max-sm { max-width: 24rem; }
.ke-max-md { max-width: 32rem; }
.ke-max-lg { max-width: 48rem; }
.ke-max-xl { max-width: 72rem; }
.ke-max-form { max-width: 42rem; }
.ke-max-none { max-width: none; }
.ke-min-w-48 { min-width: 12rem; }
/* QFE-13: the repeated static inline styles, as classes. Font size .875em is
   Bootstrap's own `small`; hidden-until-Alpine elements keep x-cloak plus
   their inline display:none (htmx settle restores server styles on id'd
   x-show nodes, so that one stays inline on purpose). */
.ke-h-7 { height: 1.75rem; }
.ke-h-24 { height: 6rem; }
.ke-h-48 { height: 12rem; }
.ke-min-h-8 { min-height: 2rem; }
.ke-min-w-0 { min-width: 0; }
.ke-min-w-64 { min-width: 16rem; }
.ke-max-h-480 { max-height: 480px; }
.ke-chart-h-200 { height: 200px; }
.ke-chart-h-220 { height: 220px; }
.ke-chart-h-240 { height: 240px; }
.ke-chart-h-260 { height: 260px; }
.ke-swatch { width: 0.8rem; height: 0.8rem; }
.ke-pre-wrap { white-space: pre-wrap; }
.ke-pre-line { white-space: pre-line; }
.ke-tracking-wide { letter-spacing: 0.06em; }
.ke-transition-transform { transition: transform 0.15s ease; }
.ke-touch-none { touch-action: none; }

/* ITP involvement columns — the four party headings read bottom-to-top so a
   full organisation or customer name fits over a one-letter column without
   widening it. Colour is inherited from the header row, so both themes work. */
.ke-th-vertical {
  width: 2.25rem;
  min-width: 2.25rem;
  max-width: 2.25rem;
  vertical-align: bottom;
  padding-bottom: 0.4rem;
}

.ke-th-vertical > span {
  display: inline-block;
  writing-mode: vertical-rl;
  transform: rotate(180deg);
  max-height: 9rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  line-height: 1.1;
  /* The header row is .text-uppercase; names read better as entered. */
  text-transform: none;
}

.crm-dashboard-widget {
  min-height: 10.625rem;
  padding: 1rem !important;
}

.crm-dashboard-widget > .d-flex {
  margin-bottom: 0.875rem !important;
}

.crm-dashboard-table {
  margin-bottom: 0;
}

.crm-dashboard-table thead {
  display: none;
}

.crm-dashboard-table tbody tr + tr,
.crm-dashboard-list > li + li {
  border-top: 1px solid var(--bs-border-color);
}

.crm-dashboard-table td {
  padding: 0.5rem 1rem 0.5rem 0 !important;
  vertical-align: top;
}

.crm-dashboard-table td:last-child {
  padding-right: 0 !important;
  text-align: right;
}

.crm-dashboard-table td:first-child {
  width: 100%;
}

.crm-dashboard-list > li {
  padding-block: 0.5rem !important;
}

.inventory-dashboard-grid {
  display: grid;
  align-items: stretch;
  gap: 1rem !important;
}

.inventory-dashboard-side {
  display: grid;
  align-content: start;
  gap: 1rem !important;
}

/* Side cards sit 2-up between sm and lg (was ke-grid-cols-sm-2); the lg block
   below re-stacks them into the narrow side column. */
@media (min-width: 576px) {
  .inventory-dashboard-side {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.inventory-filter-actions {
  align-self: end;
}

.inventory-filter-grid .inventory-filter-actions,
.inventory-inline-filter-grid .inventory-filter-actions {
  grid-column: 1 / -1;
}

@media (min-width: 768px) {
  .inventory-inline-filter-grid {
    grid-template-columns: minmax(0, 2fr) minmax(12rem, 1fr);
  }
}

@media (min-width: 992px) {
  .inventory-dashboard-page .ke-stat-card {
    min-height: 5.25rem;
    padding: 1rem 1.25rem;
  }

  .inventory-dashboard-grid {
    grid-template-columns: minmax(0, 1.5fr) minmax(19rem, 1fr);
  }

  .inventory-dashboard-grid > .glass-surface {
    padding: 1.25rem !important;
  }

  .inventory-dashboard-grid > .glass-surface > .d-flex,
  .inventory-dashboard-grid > .glass-surface .inventory-dashboard-kpis {
    margin-bottom: 1rem !important;
  }

  .inventory-dashboard-grid > .glass-surface .glass-muted {
    padding: 0.75rem 1rem !important;
  }

  .inventory-dashboard-grid > .glass-surface .vstack a,
  .inventory-dashboard-grid > .glass-surface > .rounded-4.border {
    padding: 0.75rem 1rem !important;
  }

  .inventory-dashboard-side {
    grid-template-columns: minmax(0, 1fr);
  }

  .inventory-dashboard-side > .glass-surface {
    padding: 1.25rem !important;
  }

  .inventory-dashboard-side > .glass-surface .mt-5 {
    margin-top: 1rem !important;
  }
}

.ke-timeline-line {
  left: 1rem;
  width: 1px;
  background: var(--bs-border-color);
}
.min-w-0 { min-width: 0; }
.whitespace-pre-line { white-space: pre-line !important; }
.fs-7 { font-size: 0.75rem !important; }
.border-dashed { border-style: dashed !important; }
.ke-line-clamp-2 { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.ke-cursor-grab { cursor: grab; }
.ke-cursor-not-allowed { cursor: not-allowed; }
.ke-cursor-help { cursor: help; }
/* Error-toned callout — the briefing card's "needs attention now" section. */
.ke-section-danger {
  background:
    radial-gradient(circle at 0% 0%, rgba(239, 68, 68, 0.1) 0%, transparent 60%),
    var(--ke-surface);
}

/* Chevron on an inline collapse toggle flips while its target is open. */
.ke-collapse-toggle .ke-icon {
  transition: transform 0.15s ease;
}

.ke-collapse-toggle[aria-expanded="true"] .ke-icon {
  transform: rotate(180deg);
}

/* My Onboarding (my_profile/onboarding.html) — section toggles keep a
   comfortable tap target, an info-only section carries an info rule on its
   left edge, and a step waiting on the starter is edged in warning. The
   !important on the step beats Bootstrap's .border utility. */
.my-onb-section-toggle {
  min-height: 2.75rem;
}

.my-onb-section-info {
  border-left: 3px solid var(--bs-info-border-subtle);
  padding-left: 0.75rem;
}

.my-onb-step-mine {
  border-color: var(--bs-warning-border-subtle) !important;
  border-left: 4px solid var(--bs-warning) !important;
}

/* ---------------------------------------------------------------------------
 * Ported utilities — used across templates but with no Bootstrap equivalent.
 * Defined once here so the markup that references them styles correctly,
 * rather than swapping each call site. See docs/styling-compat-audit.md.
 * ------------------------------------------------------------------------- */
/* Multi-checkbox group (CheckboxSelectMultiple) rendered by the bound-field
 * partial — a contained, scrollable list styled like a form control. */
.ke-checkbox-group {
  max-height: 14rem;
  overflow-y: auto;
  border: 1px solid rgba(88, 102, 135, 0.24);
  border-radius: var(--ke-radius-control);
  padding: 0.6rem 0.75rem;
  background-color: color-mix(in srgb, var(--ke-surface) 82%, transparent);
}
.whitespace-pre-wrap { white-space: pre-wrap !important; }
.scroll-mt-5 { scroll-margin-top: 3rem; }
.scroll-mt-24 { scroll-margin-top: 6rem; }

/* ---------------------------------------------------------------------------
 * Rich-text editor (Tiptap) — central component behind RichTextFormField.
 * Built from frontend/src/editor; mounted by static/dist/editor.bundle.js.
 * Styled to read as a native form-control and to theme automatically via the
 * --ke-*/--bs-* tokens (no per-theme overrides needed). `.rich-text-content`
 * shares the typography for HTML rendered back on detail pages.
 * ------------------------------------------------------------------------- */

/* Plain textarea fallback: a normal control until the editor mounts and hides
 * it; if JS never runs, authors still get a usable textarea. */
.rich-text-source { display: block; }

.rich-text-editor {
  background-color: color-mix(in srgb, var(--ke-surface) 82%, transparent);
  border: 1px solid rgba(88, 102, 135, 0.24);
  border-radius: var(--ke-radius-control);
  overflow: hidden;
}
.rich-text-editor:focus-within {
  border-color: var(--ke-brand-500);
  box-shadow: 0 0 0 0.25rem rgba(12, 142, 235, 0.18);
}

.rich-text-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.125rem;
  padding: 0.375rem 0.5rem;
  background: var(--ke-muted-surface);
  border-bottom: 1px solid rgba(88, 102, 135, 0.24);
}

.rich-text-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--ke-text-muted);
  cursor: pointer;
  transition: background-color 0.12s ease, color 0.12s ease;
}
.rich-text-btn:hover {
  background: var(--ke-surface-hover);
  color: var(--ke-text);
}
.rich-text-btn:focus-visible {
  outline: 2px solid var(--ke-brand-500);
  outline-offset: -1px;
}
.rich-text-btn.is-active {
  background: var(--ke-brand-600);
  color: #fff;
}
/* Table tools outside a table, merge/split with nothing to act on (EN-0645).
 * Scoped under the toolbar to outrank the global button:not(.btn):disabled. */
.rich-text-toolbar .rich-text-btn:disabled,
.rich-text-toolbar .rich-text-btn:disabled:hover {
  opacity: 0.35;
  cursor: default;
  background: transparent;
  color: var(--ke-text-muted);
}

.rich-text-divider {
  width: 1px;
  align-self: stretch;
  margin: 0.25rem 0.125rem;
  background: rgba(88, 102, 135, 0.24);
}

/* The Tiptap/ProseMirror editing surface. Taller by default to read like a
 * document, and user-resizable vertically (drag the bottom-right handle). */
.rich-text-editor .ProseMirror {
  min-height: 18rem;
  padding: 0.6rem 0.75rem;
  color: var(--ke-text);
  outline: none;
  overflow-wrap: anywhere;
  overflow: auto;
  resize: vertical;
}

/* Shared typography for the editing surface and rendered detail content. */
.rich-text-editor .ProseMirror,
.rich-text-content {
  line-height: 1.6;
}
.rich-text-editor .ProseMirror > :first-child,
.rich-text-content > :first-child { margin-top: 0; }
.rich-text-editor .ProseMirror > :last-child,
.rich-text-content > :last-child { margin-bottom: 0; }
.rich-text-editor .ProseMirror p,
.rich-text-content p { margin: 0 0 0.5rem; }
.rich-text-editor .ProseMirror h1,
.rich-text-content h1 { font-size: 1.5rem; font-weight: 600; margin: 0.75rem 0 0.5rem; }
.rich-text-editor .ProseMirror h2,
.rich-text-content h2 { font-size: 1.25rem; font-weight: 600; margin: 0.75rem 0 0.5rem; }
.rich-text-editor .ProseMirror h3,
.rich-text-content h3 { font-size: 1.1rem; font-weight: 600; margin: 0.75rem 0 0.5rem; }
.rich-text-editor .ProseMirror ul,
.rich-text-editor .ProseMirror ol,
.rich-text-content ul,
.rich-text-content ol { margin: 0 0 0.5rem; padding-left: 1.5rem; }
.rich-text-editor .ProseMirror a,
.rich-text-content a { color: var(--bs-link-color, var(--ke-brand-600)); text-decoration: underline; }
/* "full" profile extras (EN-0619): block quotes, rules and highlight. */
.rich-text-editor .ProseMirror blockquote,
.rich-text-content blockquote {
  margin: 0 0 0.5rem;
  padding: 0.25rem 0 0.25rem 1rem;
  border-left: 3px solid var(--bs-border-color);
  color: var(--bs-secondary-color);
}
.rich-text-editor .ProseMirror hr,
.rich-text-content hr { margin: 1rem 0; }
.rich-text-editor .ProseMirror mark,
.rich-text-content mark { padding: 0 0.125rem; }

/* Tables (document/full profiles, EN-0645) in the editor and rendered back.
 * Fixed layout at full width: the editor is not resizable and the sanitiser
 * drops Tiptap's <colgroup> widths, so columns share the width evenly. */
.rich-text-editor .ProseMirror table,
.rich-text-content table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
  margin: 0.75rem 0;
}
.rich-text-editor .ProseMirror th,
.rich-text-editor .ProseMirror td,
.rich-text-content th,
.rich-text-content td {
  position: relative;
  box-sizing: border-box;
  min-width: 3rem;
  padding: 0.375rem 0.5rem;
  border: 1px solid var(--bs-border-color);
  vertical-align: top;
  overflow-wrap: anywhere;
}
.rich-text-editor .ProseMirror th,
.rich-text-content th {
  background: var(--bs-tertiary-bg);
  font-weight: 600;
  text-align: left;
}
.rich-text-editor .ProseMirror th p,
.rich-text-editor .ProseMirror td p,
.rich-text-content th p,
.rich-text-content td p { margin: 0; }
/* Cells in a ProseMirror cell selection (drag across cells to merge). */
.rich-text-editor .ProseMirror .selectedCell::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 2;
  background: rgba(12, 142, 235, 0.18);
  pointer-events: none;
}

/* The document profile's page stays white in either theme (its background
 * and body colour are set inline by the editor bundle), so pin the colours
 * of everything on it to light-theme values: the theme tokens would turn
 * near-invisible on white under data-bs-theme="dark". */
.rich-text-surface-document .ProseMirror {
  color-scheme: light;
  --bs-border-color: #dee2e6;
  --bs-tertiary-bg: #f8f9fa;
}
.rich-text-surface-document .ProseMirror,
.rich-text-surface-document .ProseMirror h1,
.rich-text-surface-document .ProseMirror h2,
.rich-text-surface-document .ProseMirror h3,
.rich-text-surface-document .ProseMirror th,
.rich-text-surface-document .ProseMirror td { color: #212529; }
.rich-text-surface-document .ProseMirror blockquote { color: #6c757d; border-left-color: #dee2e6; }
.rich-text-surface-document .ProseMirror a { color: #0a58ca; }
.rich-text-surface-document .ProseMirror mark { background-color: #fff3cd; color: #212529; }
.rich-text-surface-document .ProseMirror hr { border-top-color: #adb5bd; opacity: 1; }
.rich-text-surface-document .ProseMirror ::selection { background: rgba(12, 142, 235, 0.25); color: inherit; }

/* ── Module dashboards — KPI strips, segmented bars, chart cards ───────── */
/* Tighter-than-g-3 gutters for dashboard KPI strips (rows, not CSS grid). */
.ke-dashboard-kpis {
  --bs-gutter-x: 0.75rem;
  --bs-gutter-y: 0.75rem;
}

.ke-kpi-card {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 5.5rem;
  padding: 1rem 1.25rem;
  transition: background-color 0.15s ease, transform 0.15s ease;
}

.page-body a:hover > .ke-kpi-card,
.page-body a:focus-visible > .ke-kpi-card {
  background: var(--ke-surface-hover);
  transform: translateY(-1px);
}

/* Status chip — a larger type-badge for the headline status strip under a
   detail page title (pass type_class="ke-status-chip"). Text uses the
   *-text-emphasis tokens so amber/green stay legible in light and dark mode,
   and a subtle border lifts the chip off glass surfaces. */
.ke-status-chip {
  font-size: 0.8125rem !important;
  padding: 0.3rem 0.65rem !important;
  gap: 0.375rem !important;
  border: 1px solid var(--bs-border-color-translucent);
}
.ke-status-chip.bg-success-subtle { color: var(--bs-success-text-emphasis) !important; border-color: var(--bs-success-border-subtle); }
.ke-status-chip.bg-warning-subtle { color: var(--bs-warning-text-emphasis) !important; border-color: var(--bs-warning-border-subtle); }
.ke-status-chip.bg-danger-subtle { color: var(--bs-danger-text-emphasis) !important; border-color: var(--bs-danger-border-subtle); }
.ke-status-chip.bg-primary-subtle { color: var(--bs-primary-text-emphasis) !important; border-color: var(--bs-primary-border-subtle); }

/* Segmented status bar — one flex track, segments sized by flex-grow. */
.ke-segbar {
  display: flex;
  width: 100%;
  height: 0.875rem;
  border-radius: 0;
  overflow: hidden;
  background: var(--ke-track);
}

.ke-segbar > span {
  display: block;
  height: 100%;
  min-width: 0;
}

.ke-dot {
  display: inline-block;
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 999px;
  flex-shrink: 0;
}

.ke-chart-card {
  display: flex;
  flex-direction: column;
  padding: 1.25rem;
}

.ke-chart-card .ke-chart-body {
  position: relative;
  flex-grow: 1;
  min-height: 0;
}

/* ── Utilisation bars (Business Utilisation Dashboard) ────────────────────
   Pure-CSS horizontal capacity bars used by the machine and staff panels.
   The track represents 100% of capacity. Segment widths are passed inline as
   percentages of capacity (allocated + downtime + absence + idle == 100); an
   overload segment is positioned ABSOLUTELY past the right edge so it visibly
   spills beyond the 100% line. Colours are design-token driven, dark-mode
   aware via [data-bs-theme="dark"], and print-safe. No JavaScript. */
.ke-util-bar {
  position: relative;
  display: flex;
  width: 100%;
  height: 1rem;
  border-radius: 0;
  overflow: visible;
  background: var(--ke-track);
}

.ke-util-bar__track {
  display: flex;
  width: 100%;
  height: 100%;
  border-radius: 0;
  overflow: hidden;
}

.ke-util-bar__seg {
  display: block;
  height: 100%;
  min-width: 0;
}

.ke-util-bar__seg--allocated {
  background: var(--ke-brand-500);
}

/* Confirmed roster commitment — a distinct committed layer alongside
   allocation (staff only). Uses the info token so it reads apart from the
   brand-coloured allocation segment in both light and dark themes. */
.ke-util-bar__seg--rostered {
  background: var(--bs-info, #0dcaf0);
}

.ke-util-bar__seg--downtime {
  background: #9ca3af;
  background-image: repeating-linear-gradient(
    45deg,
    rgba(0, 0, 0, 0.12) 0,
    rgba(0, 0, 0, 0.12) 3px,
    transparent 3px,
    transparent 6px
  );
}

.ke-util-bar__seg--absence {
  background: #f59e0b;
  background-image: repeating-linear-gradient(
    45deg,
    rgba(255, 255, 255, 0.45) 0,
    rgba(255, 255, 255, 0.45) 3px,
    transparent 3px,
    transparent 6px
  );
}

.ke-util-bar__seg--idle {
  background: transparent;
}

/* Overload spills past the 100% line: a thin marker sitting just outside the
   track's right edge in an alarm colour. */
.ke-util-bar__overload {
  position: absolute;
  top: -2px;
  bottom: -2px;
  left: 100%;
  background: var(--bs-danger, #ef4444);
  border-radius: 0;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.06);
}

/* The 100% reference line. */
.ke-util-bar__limit {
  position: absolute;
  top: -3px;
  bottom: -3px;
  right: 0;
  width: 2px;
  background: var(--ke-text-subtle);
  opacity: 0.5;
}

/* Legend swatch. */
.ke-util-swatch {
  display: inline-block;
  width: 0.75rem;
  height: 0.75rem;
  border-radius: 0;
  flex-shrink: 0;
  vertical-align: middle;
}

.ke-util-swatch--allocated {
  background: var(--ke-brand-500);
}

.ke-util-swatch--rostered {
  background: var(--bs-info, #0dcaf0);
}

.ke-util-swatch--downtime {
  background: #9ca3af;
}

.ke-util-swatch--absence {
  background: #f59e0b;
}

.ke-util-swatch--idle {
  background: var(--ke-track);
  border: 1px solid var(--bs-border-color);
}

.ke-util-swatch--overload {
  background: var(--bs-danger, #ef4444);
}

.ke-util-swatch--pipeline {
  background: var(--ke-brand-300);
  opacity: 0.55;
}

/* Pipeline (unconfirmed demand) overlay segment — translucent so it reads as
   provisional next to the confirmed allocation. */
.ke-util-bar__seg--pipeline {
  background: var(--ke-brand-300);
  opacity: 0.5;
}

/* Verification week review — day-by-day claimed vs rostered table. A day with
   open flags carries its most severe one as an accent on the day cell; a day
   with nothing claimed or rostered is muted so the working days stand out. */
.ke-verify-days > tbody > tr > td {
  vertical-align: top;
}

.ke-verify-days > tbody > tr[data-severity] > td:first-child {
  box-shadow: inset 3px 0 0 var(--bs-warning);
}

.ke-verify-days > tbody > tr[data-severity="block"] > td:first-child {
  box-shadow: inset 3px 0 0 var(--bs-danger);
}

.ke-verify-days > tbody > tr[data-severity="info"] > td:first-child {
  box-shadow: inset 3px 0 0 var(--bs-primary);
}

.ke-verify-days > tbody > tr.is-empty > td,
.ke-verify-days > tbody > tr.is-empty > td .text-body {
  color: var(--bs-tertiary-color) !important;
}

.ke-verify-days__window-label {
  min-width: 4.5rem;
}

/* Roster grid cells — one per person per day. */
.ke-roster-cell {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.75rem;
  height: 1.75rem;
  border-radius: 0;
  font-size: 0.6875rem;
  font-weight: 600;
}

.ke-roster-cell--working {
  background: var(--bs-success-bg-subtle);
  color: var(--bs-success-text-emphasis);
}

.ke-roster-cell--holiday {
  background: var(--bs-primary-bg-subtle);
  color: var(--bs-primary-text-emphasis);
}

.ke-roster-cell--sick {
  background: var(--bs-danger-bg-subtle);
  color: var(--bs-danger-text-emphasis);
}

.ke-roster-cell--absent {
  background: var(--bs-warning-bg-subtle);
  color: var(--bs-warning-text-emphasis);
}

.ke-roster-cell--non_working,
.ke-roster-cell--bank_holiday {
  background: var(--ke-muted-surface);
  color: var(--ke-text-subtle);
}

/* ── Tools floating action button ────────────────────────────────────────
   Launches the context-aware Tools offcanvas. Sits below the offcanvas
   (1045) and its backdrop (1040) so it hides behind the panel when open. */
.tools-fab {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  width: 56px;
  height: 56px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  /* Contrast ring (1px) keeps the edge visible on both light-grey and
     dark-navy canvases; brand gradient fill makes the disc pop on either. */
  border: 1px solid rgba(255, 255, 255, 0.55);
  border-radius: 50%;
  background: linear-gradient(150deg, var(--ke-brand-500), var(--ke-brand-600));
  color: #fff;
  box-shadow:
    0 6px 20px rgba(12, 142, 235, 0.45),
    var(--ke-shadow);
  z-index: var(--ke-z-fixed);
  transition: filter 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
}
.tools-fab > svg { color: #fff; }
.tools-fab:hover {
  filter: brightness(1.06);
  transform: translateY(-1px);
  box-shadow:
    0 8px 24px rgba(12, 142, 235, 0.55),
    var(--ke-shadow);
}
.tools-fab:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
/* Slightly stronger ring in dark mode so the disc separates from the canvas. */
[data-bs-theme="dark"] .tools-fab { border-color: rgba(255, 255, 255, 0.28); }

@media print {
  /* Keep bar fills visible on paper (browsers strip backgrounds by default). */
  .ke-util-bar,
  .ke-util-bar__seg,
  .ke-util-bar__overload,
  .ke-util-swatch,
  .ke-roster-cell {
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  .ke-util-bar {
    border: 1px solid #999;
  }
}

/* ── Planning backlog hierarchy ─────────────────────────────────────── */

/* Tier 1: customer band — tinted full-bleed band with brand accent. */
.ke-backlog-customer-header {
  padding: 0.375rem 0.75rem;
  box-shadow: inset 0.1875rem 0 0 var(--ke-brand-600);
}
[data-bs-theme="dark"] .ke-backlog-customer-header {
  box-shadow: inset 0.1875rem 0 0 var(--ke-brand-400);
}

/* Tier 2: job / quote row — indented one step. */
.ke-backlog-parent {
  padding: 0.3125rem 0.75rem 0.3125rem 1.5rem;
}

/* Tier 3: deliverable + its lines — indented rail group. */
.ke-backlog-group {
  margin: 0.25rem 0 0.375rem 1.5rem;
  border-left: 2px solid var(--bs-border-color);
}
.ke-backlog-deliverable {
  padding: 0.25rem 0.75rem 0.125rem;
  letter-spacing: 0.04em;
}

/* Tier 4: line rows — quietest, most compact. */
.ke-backlog-row {
  padding: 0.25rem 0.75rem;
}
.ke-backlog-row + .ke-backlog-row {
  border-top: 1px solid var(--bs-border-color);
}
.ke-backlog-row:hover {
  background: var(--ke-muted-surface);
}
.ke-backlog-hours {
  min-width: 3.5rem;
}
.ke-backlog-row .btn {
  --bs-btn-padding-y: 0.125rem;
  --bs-btn-padding-x: 0.5rem;
  --bs-btn-font-size: 0.75rem;
}

/* ── Entity reports (order/job Reports tab) ───────────────────────────── */
.report-stats {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(13rem, 1fr));
    gap: 0.75rem 1.5rem;
}
.report-stats .report-stat {
    min-width: 0;
}
.report-stats dt {
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--bs-secondary-color);
    margin-bottom: 0.125rem;
}
.report-stats dd {
    margin-bottom: 0;
}
.report-stats .report-stat--wide {
    grid-column: 1 / -1;
}
.report-section h3 {
    font-size: 0.9375rem;
    font-weight: 600;
    margin: 1rem 0 0.5rem;
}
.report-section .table {
    font-size: 0.875rem;
}
.report-section .table > :not(caption) > * > * {
    padding-block: 0.35rem;
}

/* ==========================================================================
   Analytics dashboards (Finance → Analytics)
   Pipeline funnel, stage board, per-customer bars and the customer ledger
   matrix. Stage colour tokens are shared across light + dark (validated for
   both surfaces); layout leans on Bootstrap utilities.
   ========================================================================== */
:root {
    --ke-stage-draft: #a98a3a;
    --ke-stage-sent: var(--ke-brand-600);
    --ke-stage-accepted: #2f9e77;
    --ke-stage-converted: #b3599d;
    --ke-stage-lost: #9aa3b2;
}

/* Stage colour fills (funnel segments, bars, swatches). */
.ke-an-seg-draft { background-color: var(--ke-stage-draft); }
.ke-an-seg-sent { background-color: var(--ke-stage-sent); }
.ke-an-seg-accepted { background-color: var(--ke-stage-accepted); }
.ke-an-seg-converted { background-color: var(--ke-stage-converted); }
.ke-an-seg-lost { background-color: var(--ke-stage-lost); }

/* Funnel band. */
.ke-an-funnel {
    display: flex;
    gap: 2px;
    height: 46px;
    border-radius: 0;
    overflow: hidden;
}
.ke-an-funnel-seg {
    min-width: 2.5rem;
    border-radius: 0;
}
/* Funnel label-row cells — same min-width as the segments so the two bands
   stay aligned even for tiny non-zero stages. */
.ke-an-funnel-cell {
    min-width: 2.5rem;
}

/* Small colour swatch dot. */
.ke-an-swatch {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 0;
    flex-shrink: 0;
}

/* Stage board columns. */
.ke-an-board-col {
    background-color: var(--ke-track);
    border-radius: 0;
    padding: 0.75rem;
}
.ke-an-board-card {
    transition: border-color 0.15s ease;
}
.ke-an-board-card:hover {
    border-color: var(--ke-stage-sent);
}

/* Horizontal stacked / value bars. */
.ke-an-bar-track {
    display: flex;
    gap: 2px;
    height: 16px;
    border-radius: 0;
    background-color: var(--ke-track);
    overflow: hidden;
}
.ke-an-bar-seg {
    height: 100%;
    border-radius: 0;
}
.ke-an-cust-name { width: 8rem; flex-shrink: 0; }
.ke-an-cust-total { width: 6rem; flex-shrink: 0; }

/* Live order-book progress bar. */
.ke-an-progress { height: 12px; }

/* Ledger matrix. Bootstrap's cell rule (.table>:not(caption)>*>*) paints every
   cell with the opaque --bs-table-bg at 0-1-1 specificity, so heat tints must
   target the td at equal specificity and the customer band/hover must ride the
   --bs-table-bg-type/-state inset-shadow channel — a tr background never shows. */
.ke-an-matrix-row { --bs-table-bg-type: var(--ke-track); }
.ke-an-matrix-row:hover { --bs-table-bg-state: color-mix(in srgb, var(--bs-emphasis-color) 11%, transparent); }
.ke-an-caret { display: inline-block; }
td.ke-an-t1 { background-color: color-mix(in srgb, var(--ke-brand-600) 10%, var(--bs-table-bg)); }
td.ke-an-t2 { background-color: color-mix(in srgb, var(--ke-brand-600) 18%, var(--bs-table-bg)); }
td.ke-an-t3 { background-color: color-mix(in srgb, var(--ke-brand-600) 26%, var(--bs-table-bg)); }
.ke-an-detail > td {
    background-color: color-mix(in srgb, #fff 60%, var(--bs-table-bg));
}
/* Dark surfaces already read clearly without the band; keep their tint mixes. */
[data-bs-theme="dark"] .ke-an-matrix-row { --bs-table-bg-type: initial; }
[data-bs-theme="dark"] td.ke-an-t1 { background-color: color-mix(in srgb, var(--ke-brand-600) 12%, transparent); }
[data-bs-theme="dark"] td.ke-an-t2 { background-color: color-mix(in srgb, var(--ke-brand-600) 20%, transparent); }
[data-bs-theme="dark"] td.ke-an-t3 { background-color: color-mix(in srgb, var(--ke-brand-600) 30%, transparent); }
[data-bs-theme="dark"] .ke-an-detail > td {
    background-color: color-mix(in srgb, var(--ke-brand-600) 8%, transparent);
}

/* Ledger sparkline. */
.ke-an-spark {
    width: 90px;
    height: 22px;
    vertical-align: middle;
}
.ke-an-spark polyline {
    stroke: var(--ke-brand-600);
    fill: none;
    stroke-width: 1.6;
}

/* ---------------------------------------------------------------------------
   Production tracker (stage 38)
   Board columns, card state stripes, the claimed tick, the table row tints,
   the ten-week timeline grid and the capacity bars. Every colour comes from an
   existing token (--ke-*) or a Bootstrap subtle/emphasis variable, so light and
   dark are both covered without a new palette.
--------------------------------------------------------------------------- */

/* Board — a horizontally scrolling row of fixed-width stage columns. */
.production-col {
  width: 17.5rem;
}
.production-col-body {
  /* Keeps an empty column a valid SortableJS drop target. */
  min-height: 3.5rem;
}
.production-col-unstaged {
  background-color: color-mix(in srgb, var(--bs-warning-bg-subtle) 40%, var(--ke-track));
}

/* Cards carry a left stripe for the two states that need chasing. An inset
   shadow, not a border: Bootstrap's .border utility is !important and would
   win over any border-left declared here. */
.production-card-blocked {
  box-shadow: inset 3px 0 0 var(--ke-status-running-late), var(--ke-shadow-sm);
}
.production-card-overdue {
  box-shadow: inset 3px 0 0 var(--ke-status-overdue), var(--ke-shadow-sm);
}
.production-status-line {
  line-height: 1.2;
}

/* Claimed % sits on the built-% track as a tick, not a second bar. */
.production-claimed-tick {
  position: absolute;
  top: -0.15rem;
  bottom: -0.15rem;
  width: 2px;
  margin-left: -1px;
  border-radius: 0;
  background-color: var(--bs-emphasis-color);
  opacity: 0.65;
}

.production-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.5rem;
  height: 1.5rem;
  border-radius: 999px;
}

/* Delta chips — one tone per change type. */
.production-delta {
  background-color: var(--bs-secondary-bg-subtle);
  color: var(--bs-secondary-text-emphasis);
}
.production-delta-new {
  background-color: var(--bs-primary-bg-subtle);
  color: var(--bs-primary-text-emphasis);
}
.production-delta-moved {
  background-color: var(--bs-info-bg-subtle);
  color: var(--bs-info-text-emphasis);
}
.production-delta-slipped {
  background-color: var(--bs-warning-bg-subtle);
  color: var(--bs-warning-text-emphasis);
}
.production-delta-completed {
  background-color: var(--bs-success-bg-subtle);
  color: var(--bs-success-text-emphasis);
}

/* Table view — tint the cells, never the row (an opaque --bs-table-bg on every
   cell would hide a tr background). */
/* --bs-table-bg is only defined inside a .table, and these tables are bare, so
   it needs a transparent fallback or the whole declaration is dropped. */
td.production-cell-blocked {
  background-color: color-mix(in srgb, var(--bs-warning-bg-subtle) 60%, var(--bs-table-bg, transparent));
}
td.production-cell-overdue {
  background-color: color-mix(in srgb, var(--bs-danger-bg-subtle) 55%, var(--bs-table-bg, transparent));
}
.production-mini-bar {
  display: inline-block;
  width: 4rem;
  height: 0.4rem;
  overflow: hidden;
}
.production-mini-bar > span {
  display: block;
  height: 100%;
}

/* Timeline — a --production-weeks column grid with absolutely placed bars. */
.production-timeline {
  min-width: 46rem;
}
.production-timeline-row {
  display: grid;
  grid-template-columns: minmax(9rem, 14rem) minmax(0, 1fr);
  align-items: center;
  gap: 0.75rem;
}
.production-timeline-label {
  min-width: 0;
}
.production-timeline-site {
  margin: 0.75rem 0 0.25rem;
}
.production-timeline-track {
  position: relative;
  height: 1.75rem;
}
.production-timeline-head .production-timeline-track {
  height: 1.25rem;
}
.production-timeline-weeks {
  position: absolute;
  inset: 0;
  display: grid;
  grid-template-columns: repeat(var(--production-weeks, 10), minmax(0, 1fr));
}
.production-timeline-week {
  border-left: 1px solid var(--ke-border);
  padding-left: 0.25rem;
  overflow: hidden;
}
.production-timeline-week.is-current {
  background-color: var(--ke-track);
}
.production-timeline-today {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 2px;
  margin-left: -1px;
  background-color: var(--ke-status-overdue);
  opacity: 0.7;
}
.production-timeline-bar {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  height: 1.2rem;
  min-width: 1.5rem;
  display: flex;
  align-items: center;
  border-radius: 0;
  overflow: hidden;
  text-decoration: none;
}
.production-timeline-bar.is-clipped-start {
  border-top-left-radius: 0;
  border-bottom-left-radius: 0;
}
.production-timeline-bar.is-clipped-end {
  border-top-right-radius: 0;
  border-bottom-right-radius: 0;
}
.production-timeline-fill {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  background-color: color-mix(in srgb, var(--bs-emphasis-color) 14%, transparent);
}
.production-timeline-bar-label {
  position: relative;
  padding: 0 0.4rem;
  white-space: nowrap;
}
.production-timeline-nobar {
  position: absolute;
  top: 50%;
  left: 0.25rem;
  transform: translateY(-50%);
}

/* Capacity — one bar per department week and per machine. */
.production-capacity-bar {
  display: block;
  width: 100%;
  height: 0.5rem;
  overflow: hidden;
}
.production-capacity-bar > span {
  display: block;
  height: 100%;
}

/* ---------------------------------------------------------------------------
   Colour picker — organisation branding (onboarding Branding step + Org
   Settings → Edit Organisation, _colour_picker.html). A compact colour
   square and an eyedropper icon form one clickable unit with the native
   <input type="color"> stretched invisibly over both; the icon sits outside
   the square so it stays visible whatever colour is chosen. The hex text
   input beside them is the field that actually submits. Sizing lives here
   rather than inline because Alpine string :style bindings replace the whole
   style attribute. Squared corners per Stage 40 — no border-radius. */
.colour-picker-control {
  cursor: pointer;
}

.colour-swatch {
  width: 3rem;
  min-height: 2.5rem;
  border: 1px solid var(--bs-border-color);
  background-color: var(--bs-body-bg);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.colour-picker-control:hover .colour-swatch {
  border-color: var(--bs-secondary-color);
}

/* The native colour input is opacity-0, so surface keyboard focus on the
   square instead. */
.colour-picker-control:focus-within .colour-swatch {
  border-color: var(--ke-brand-600);
  box-shadow: 0 0 0 0.25rem var(--bs-focus-ring-color);
}

/* No valid hex yet — checkerboard placeholder so "empty" doesn't read as
   white. Theme-aware via --bs-secondary-bg. */
.colour-swatch.is-empty {
  background-image:
    conic-gradient(var(--bs-secondary-bg) 25%, transparent 0 50%,
                   var(--bs-secondary-bg) 0 75%, transparent 0);
  background-size: 0.75rem 0.75rem;
}

.colour-picker-icon {
  line-height: 0;
}

.colour-hex-input {
  flex: 0 0 10rem;
  width: 10rem;
}

/* ── Onboarding compliance report (EN-0569) ──────────────────────────────
   Pure-CSS dashboard pieces for templates/reports/body/
   people_onboarding_compliance.html: larger headline tiles, the pipeline
   (one row per journey template; one stage block per stage of that template
   in order, then sign-off — the number of live journeys at the stage is the
   key figure, stages with none are muted, a stage with an overdue journey
   gets a danger ring) and the small inline bars of the attention and
   breakdown panels. Stage blocks are sized by an inline flex-grow weight
   (1–4, from the service). Colours come from the Bootstrap theme tokens, so
   light and dark mode need no overrides. Stage blocks wrap on narrow
   screens. Squared corners, like every other dashboard bar. */
.ke-onb-headline .ke-kpi-card {
  min-height: 7.25rem;
}

.ke-onb-headline .ke-kpi-card .fs-3 {
  font-size: 2.25rem !important;
}

.ke-onb-legend {
  display: inline-block;
  width: 0.75rem;
  height: 0.5rem;
  flex-shrink: 0;
}

/* Legend swatch for the ring a stage with an overdue journey gets. */
.ke-onb-legend--overdue {
  box-shadow: 0 0 0 2px var(--bs-danger);
}

/* Up to two lines, then an ellipsis (the full text is in a title). */
.ke-onb-clamp-2 {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  overflow-wrap: anywhere;
}

.ke-onb-tpl {
  padding: 1rem 0;
  border-top: 1px solid var(--bs-border-color-translucent);
}

.ke-onb-stages {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 3px;
}

.ke-onb-stage {
  display: flex;
  flex: 1 1 0;
  flex-direction: column;
  gap: 0.25rem;
  min-width: 7rem;
  color: inherit;
  text-decoration: none;
}

.ke-onb-stage__label {
  display: -webkit-box;
  overflow: hidden;
  min-height: 1.8rem;
  font-size: 0.75rem;
  font-weight: 500;
  line-height: 1.2;
  white-space: normal;
  color: var(--bs-body-color);
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.ke-onb-stage__bar {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 2.25rem;
  font-size: 1.25rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  background: var(--bs-primary);
  color: var(--bs-white);
  transition: filter 0.15s ease;
}

.ke-onb-stage--gate .ke-onb-stage__bar {
  background: var(--bs-warning);
  color: var(--bs-dark);
}

.ke-onb-stage.is-empty .ke-onb-stage__bar {
  background: var(--ke-track);
  color: var(--bs-secondary-color);
  font-size: 0.875rem;
  font-weight: 500;
}

.ke-onb-stage.is-empty .ke-onb-stage__label {
  color: var(--bs-secondary-color);
}

.ke-onb-stage.has-overdue .ke-onb-stage__bar {
  box-shadow: inset 0 0 0 3px var(--bs-danger);
}

.ke-onb-stage:hover .ke-onb-stage__bar,
.ke-onb-stage:focus-visible .ke-onb-stage__bar {
  filter: brightness(1.12);
}

.ke-onb-stage__figs {
  display: flex;
  flex-direction: column;
  gap: 0.125rem;
  margin-top: 0.125rem;
  font-size: 0.75rem;
  line-height: 1.35;
  color: var(--bs-secondary-color);
}

/* Inline mini bar for a table cell or list row; widths are inline %. */
.ke-onb-minibar {
  display: flex;
  width: 100%;
  min-width: 4rem;
  height: 0.5rem;
  overflow: hidden;
  background: var(--ke-track);
}

.ke-onb-minibar span {
  display: block;
  height: 100%;
}

.ke-onb-attention-bar {
  display: grid;
  grid-template-columns: minmax(0, 13rem) minmax(0, 1fr) 2.5rem;
  gap: 0.75rem;
  align-items: center;
  padding: 0.375rem 0.5rem;
  color: inherit;
  text-decoration: none;
}

.ke-onb-attention-bar:hover,
.ke-onb-attention-bar:focus-visible,
.ke-onb-attention-bar.is-selected {
  background: var(--ke-surface-hover);
}

@media (max-width: 767.98px) {
  .ke-onb-attention-bar {
    grid-template-columns: minmax(0, 1fr) 2.5rem;
  }

  .ke-onb-attention-bar .ke-onb-minibar {
    grid-column: 1 / -1;
    grid-row: 2;
  }
}

/* ── Dashed "not yet counted" badge (plan 65, S2/S9) ─────────────────────
   A pending competency row: amber like a warning, but dashed so it reads as
   provisional rather than as an alert. Bootstrap's subtle warning tokens
   switch with data-bs-theme; dark mode takes the emphasis colour for the
   border, the subtle border being too faint on the dark surface. */
.badge-dashed {
  border: 1px dashed var(--bs-warning-border-subtle);
  background: var(--bs-warning-bg-subtle);
  color: var(--bs-warning-text-emphasis);
}
[data-bs-theme="dark"] .badge-dashed {
  border-color: var(--bs-warning-text-emphasis);
}

/* ── Competency Matrix (plan 65, S4) ──────────────────────────────────────
   people/skills_matrix.html: one filter bar with proof chips, a coloured band
   per proof-type column group, short column headers, two-line status badges
   and a "held" footer. Proof colours follow components/badges.html#proof-chip
   (certification success, training primary, skill warning); every colour is
   a Bootstrap subtle/emphasis token so both themes follow data-bs-theme.
   Corners stay square (Stage 40). */
.ke-matrix-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.25rem 0.625rem;
  border: 1px solid var(--bs-border-color);
  border-radius: var(--ke-radius-control);
  background: var(--ke-surface);
  color: var(--bs-secondary-color);
  font-size: 0.75rem;
  font-weight: 600;
  line-height: 1.25rem;
  white-space: nowrap;
  text-decoration: none;
}
.ke-matrix-chip:hover,
.ke-matrix-chip:focus-visible {
  background: var(--ke-surface-hover);
  color: var(--bs-body-color);
}
.ke-matrix-chip.is-active {
  border-color: var(--bs-primary-border-subtle);
  background: var(--bs-primary-bg-subtle);
  color: var(--bs-primary-text-emphasis);
}
[data-bs-theme="dark"] .ke-matrix-chip.is-active {
  border-color: var(--bs-primary-text-emphasis);
}
.ke-matrix-dot {
  display: inline-block;
  flex-shrink: 0;
  width: 0.5rem;
  height: 0.5rem;
}
.ke-matrix-dot-certification { background: var(--bs-success); }
.ke-matrix-dot-training { background: var(--bs-primary); }
.ke-matrix-dot-skill { background: var(--bs-warning); }

/* Bootstrap's cell rule paints --bs-table-bg / --bs-table-color, so the tints
   are set through those rather than background/color. */
.ke-matrix > thead > tr > th.ke-matrix-group {
  padding: 0.375rem 0.5rem;
  text-align: center;
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.ke-matrix > thead > tr > th.ke-matrix-group-certification {
  --bs-table-bg: var(--bs-success-bg-subtle);
  --bs-table-color: var(--bs-success-text-emphasis);
}
.ke-matrix > thead > tr > th.ke-matrix-group-training {
  --bs-table-bg: var(--bs-primary-bg-subtle);
  --bs-table-color: var(--bs-primary-text-emphasis);
}
.ke-matrix > thead > tr > th.ke-matrix-group-skill {
  --bs-table-bg: var(--bs-warning-bg-subtle);
  --bs-table-color: var(--bs-warning-text-emphasis);
}
.ke-matrix > thead > tr > th.ke-matrix-col {
  max-width: 9rem;
  padding: 0.5rem;
  vertical-align: bottom;
  font-weight: 600;
}
.ke-matrix-col-name,
.ke-matrix-col-meta {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ke-matrix-col-name {
  font-size: 0.75rem;
  color: var(--bs-body-color);
}
.ke-matrix-col-meta {
  font-size: 0.6875rem;
  font-weight: 500;
  color: var(--bs-tertiary-color);
}
.ke-matrix > tbody > tr > td.ke-matrix-cell,
.ke-matrix > tfoot > tr > td.ke-matrix-cell {
  padding: 0.375rem 0.5rem;
  text-align: center;
  vertical-align: middle;
}
.ke-matrix > :not(caption) > tr > .ke-matrix-sticky {
  position: sticky;
  left: 0;
  z-index: 1;
  --bs-table-bg: var(--ke-sticky-head-bg);
  border-right: 1px solid var(--bs-border-color);
}

.ke-matrix-badge {
  display: inline-block;
  min-width: 4.5rem;
  padding: 0.1875rem 0.375rem;
  border: 1px solid transparent;
  border-radius: var(--ke-radius-control);
  font-size: 0.6875rem;
  font-weight: 700;
  line-height: 1.2;
  white-space: nowrap;
}
.ke-matrix-badge-detail {
  display: block;
  font-size: 0.625rem;
  font-weight: 500;
  opacity: 0.9;
}
.ke-matrix-badge-ok {
  background: var(--bs-success-bg-subtle);
  color: var(--bs-success-text-emphasis);
}
.ke-matrix-badge-due {
  background: var(--bs-warning-bg-subtle);
  color: var(--bs-warning-text-emphasis);
}
.ke-matrix-badge-exp {
  background: var(--bs-danger-bg-subtle);
  color: var(--bs-danger-text-emphasis);
}
.ke-matrix-badge-held {
  background: var(--bs-primary-bg-subtle);
  color: var(--bs-primary-text-emphasis);
}
.ke-matrix-badge-sus {
  border: 1px dashed var(--bs-danger-text-emphasis);
  background: var(--bs-danger-bg-subtle);
  color: var(--bs-danger-text-emphasis);
}
.ke-matrix-badge-pend {
  border: 1px dashed var(--bs-secondary-color);
  background: var(--bs-secondary-bg-subtle);
  color: var(--bs-secondary-color);
}
.ke-matrix-empty {
  font-size: 0.75rem;
  color: var(--bs-tertiary-color);
}
.ke-matrix-chip:focus-within {
  outline: 2px solid var(--bs-focus-ring-color);
  outline-offset: 1px;
}
label.ke-matrix-chip {
  cursor: pointer;
  margin-bottom: 0;
}

/* ==========================================================================
   Rostering board v3 (plan 66 §7.1–7.5, §7.7)
   One owner (stage 66.4a): the board page, people rail, job blocks, slot
   rows, gap/person panel, drawers, Days and People views, the checks queue,
   the leave cover table and the worker's My shifts cards. Every colour is a
   token below with a light and a dark value; corners stay square. Status is
   never colour alone — the markup carries text, icons or aria labels too.
   ========================================================================== */

:root {
  --ke-board-rail-width: 260px;
  --ke-board-column-width: 258px;
  --ke-board-day-width: 236px;
  --ke-board-row-height: 22px;
  --ke-board-role-width: 84px;
  --ke-board-drawer-width: 430px;
  --ke-board-panel-width: 300px;
  --ke-board-surface: #ffffff;
  --ke-board-surface-2: #f6f8fc;
  --ke-board-ink: #1a1a2e;
  --ke-board-muted: #555570;
  --ke-board-subtle: #6b6b82;
  --ke-board-line: rgba(88, 102, 135, 0.22);
  --ke-board-line-strong: rgba(88, 102, 135, 0.42);
  --ke-board-brand: #0070c9;
  --ke-board-brand-ink: #0059a3;
  --ke-board-brand-soft: #e0effe;
  --ke-board-on-brand: #ffffff;
  --ke-board-ok: #2b8a3e;
  --ke-board-ok-bg: #d3f5db;
  --ke-board-check: #7a5500;
  --ke-board-check-bg: #fff1b8;
  --ke-board-sponsor: #b3400b;
  --ke-board-sponsor-bg: #ffe1c7;
  --ke-board-bad: #c92a2a;
  --ke-board-bad-bg: #ffe0e0;
  --ke-board-on-bad: #ffffff;
  --ke-board-leave: #6741d9;
  --ke-board-leave-bg: #ebe4ff;
  --ke-board-gap: #c92a2a;
  --ke-board-focus: #f59f00;
  --ke-board-shadow: 0 12px 40px rgba(20, 35, 80, 0.12);
}

[data-bs-theme="dark"] {
  --ke-board-surface: #171c2b;
  --ke-board-surface-2: #1d2334;
  --ke-board-ink: #e7e9f2;
  --ke-board-muted: #a7abc2;
  --ke-board-subtle: #8d92a9;
  --ke-board-line: rgba(160, 170, 200, 0.18);
  --ke-board-line-strong: rgba(160, 170, 200, 0.36);
  --ke-board-brand: #4aa8f5;
  --ke-board-brand-ink: #7cc6fd;
  --ke-board-brand-soft: #13304d;
  --ke-board-on-brand: #0c0c14;
  --ke-board-ok: #69db7c;
  --ke-board-ok-bg: #163821;
  --ke-board-check: #ffd43b;
  --ke-board-check-bg: #3b3110;
  --ke-board-sponsor: #ffa94d;
  --ke-board-sponsor-bg: #43260f;
  --ke-board-bad: #ff8787;
  --ke-board-bad-bg: #47181b;
  --ke-board-on-bad: #0c0c14;
  --ke-board-leave: #b197fc;
  --ke-board-leave-bg: #2a2148;
  --ke-board-gap: #ff8787;
  --ke-board-focus: #ffc078;
  --ke-board-shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
}

/* ── Page layout: rail | toolbar + stats + board area ──────────────────── */

/* The page keeps the standard People header and tabs; the board fills the
   rest of the main area and scrolls inside itself. */
.app-main:has(#board-root) {
  overflow: hidden !important;
}

.app-main:has(#board-root) > .page-body {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
}

.board-page-header {
  flex: none;
}

.board-page-body {
  display: flex;
  flex: 1 1 auto;
  min-height: 0;
}

/* Exempt from the global button reset (top of this file), so they take the
   page font here and their chrome from the rules below. */
button[class^="board-"],
button[class*=" board-"] {
  font-family: inherit;
}

.board-root {
  display: grid;
  grid-template-columns: var(--ke-board-rail-width) minmax(0, 1fr);
  flex: 1 1 auto;
  min-width: 0;
  min-height: 0;
  border: 1px solid var(--ke-board-line);
  position: relative;
  font-size: 0.75rem;
  line-height: 1.35;
  color: var(--ke-board-ink);
}

.board-main {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
}

@media (max-width: 991.98px) {
  .board-root {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto minmax(0, 1fr);
  }

  .board-rail {
    max-height: 30vh;
    border-right: 0 !important;
    border-bottom: 1px solid var(--ke-board-line-strong);
  }
}

/* ── People rail ───────────────────────────────────────────────────────── */

.board-rail {
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--ke-board-surface);
  border-right: 1px solid var(--ke-board-line-strong);
}

.board-rail-head {
  display: grid;
  gap: 0.4rem;
  padding: 0.6rem 0.75rem 0.5rem;
  border-bottom: 1px solid var(--ke-board-line);
}

.board-rail-title {
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

.board-rail-head b {
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.board-rail-tabs {
  display: flex;
  border: 1px solid var(--ke-board-line-strong);
}

.board-rail-tabs > button,
.board-rail-tabs > a {
  flex: 1;
  padding: 0.3rem 0.25rem;
  border: 0;
  background: none;
  color: var(--ke-board-muted);
  font-weight: 600;
  font-size: 0.7rem;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
}

.board-rail-tabs > .is-active {
  background: var(--ke-board-brand);
  color: var(--ke-board-on-brand);
}

.board-rail-filters {
  display: grid;
  gap: 0.35rem;
}

.board-rail-filters select,
.board-rail-filters input {
  width: 100%;
  min-height: 0 !important;
  padding: 0.2rem 0.35rem;
  font-size: 0.75rem;
  border: 1px solid var(--ke-board-line-strong);
  border-radius: 0;
  background: var(--ke-board-surface);
  color: var(--ke-board-ink);
}

.board-rail-summary {
  padding: 0.35rem 0.5rem;
  background: var(--ke-board-brand-soft);
  font-size: 0.72rem;
  line-height: 1.4;
}

.board-rail-summary b {
  font-variant-numeric: tabular-nums;
}

.board-rail-body {
  flex: 1;
  min-height: 0;
  overflow: auto;
}

.board-rail-team {
  border-bottom: 1px solid var(--ke-board-line);
}

.board-rail-team > summary {
  display: flex;
  justify-content: space-between;
  padding: 0.45rem 0.75rem;
  background: var(--ke-board-surface-2);
  font-weight: 600;
  font-size: 0.72rem;
  cursor: pointer;
  list-style: none;
}

.board-rail-team > summary::-webkit-details-marker {
  display: none;
}

.board-rail-team > summary span {
  color: var(--ke-board-subtle);
  font-weight: 500;
}

.board-rail-person {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.4rem;
  padding: 0.25rem 0.75rem 0.25rem 0.9rem;
  border-top: 1px solid var(--ke-board-line);
}

/* EN-0685: a grab cursor only where drag is on (data-draggable="true": rail
   people the viewer can place, filled slots of non-combined blocks). Keyed on
   the data attribute — SortableJS resets the draggable property after a drop. */
.board-rail-person[data-draggable="true"],
.board-slot[data-draggable="true"] {
  cursor: grab;
}

.board-slot[data-draggable="true"] .board-slot-trigger {
  cursor: pointer;
}

.board-rail-person:hover {
  background: var(--ke-board-surface-2);
}

.board-rail-person--off {
  cursor: not-allowed;
  opacity: 0.85;
}

.board-rail-person--hidden {
  display: none;
}

.board-rail-name {
  min-width: 0;
  overflow: hidden;
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font-size: inherit;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
}

.board-rail-name:hover {
  color: var(--ke-board-brand-ink);
  text-decoration: underline;
}

.board-rail-name:focus-visible {
  outline: 2px solid var(--ke-board-brand);
  outline-offset: 1px;
}

.board-rail-name small {
  display: block;
  overflow: hidden;
  color: var(--ke-board-subtle);
  font-size: 0.66rem;
  font-weight: 400;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.board-rail-chips {
  display: inline-flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.2rem;
}

.board-rail-empty {
  padding: 0.75rem;
  color: var(--ke-board-subtle);
}

.board-rail-leave {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.1rem 0.5rem;
  padding: 0.3rem 0.75rem;
  border-top: 1px solid var(--ke-board-line);
}

.board-rail-leave small {
  grid-column: 1 / -1;
  color: var(--ke-board-subtle);
}

/* ── Chips (rail, slot rows, people cells) ─────────────────────────────── */

.board-chip {
  display: inline-block;
  padding: 0.15rem 0.3rem;
  border: 1px solid transparent;
  font-size: 0.62rem;
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
}

.board-chip--free {
  background: var(--ke-board-ok-bg);
  color: var(--ke-board-ok);
}

.board-chip--busy {
  background: var(--ke-board-surface-2);
  border-color: var(--ke-board-line);
  color: var(--ke-board-muted);
}

.board-chip--leave {
  background: var(--ke-board-leave-bg);
  color: var(--ke-board-leave);
}

.board-chip--leave-pending {
  border: 1px dashed var(--ke-board-leave);
  background: transparent;
  color: var(--ke-board-leave);
}

.board-chip--sponsor {
  background: var(--ke-board-sponsor-bg);
  color: var(--ke-board-sponsor);
}

.board-chip--released {
  background: var(--ke-board-bad-bg);
  color: var(--ke-board-bad);
}

.board-chip--role {
  background: var(--ke-board-brand-soft);
  color: var(--ke-board-brand-ink);
}

/* ── Toolbar ───────────────────────────────────────────────────────────── */

.board-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.6rem;
  padding: 0.5rem 0.75rem;
  background: var(--ke-board-surface);
  border-bottom: 1px solid var(--ke-board-line);
}

.board-toolbar-spacer {
  flex: 1;
}

.board-week {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-weight: 700;
  font-size: 0.8rem;
  white-space: nowrap;
}

.board-week-jump {
  margin: 0;
}

.page-body .board-toolbar input.board-week-input {
  width: 8.5rem;
  min-height: 0;
  padding: 0.15rem 0.3rem;
  font-size: 0.72rem;
  border: 1px solid var(--ke-board-line-strong);
  background: var(--ke-board-surface);
  color: var(--ke-board-ink);
}

.board-tb-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.25rem;
  padding: 0.35rem 0.6rem;
  border: 1px solid var(--ke-board-line-strong);
  border-radius: 0;
  background: var(--ke-board-surface);
  color: var(--ke-board-ink);
  font-size: 0.72rem;
  font-weight: 600;
  line-height: 1.2;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
}

.board-tb-btn:hover,
.board-tb-btn:focus-visible {
  background: var(--ke-board-surface-2);
  color: var(--ke-board-ink);
}

.board-tb-btn--primary,
.board-tb-btn--primary:hover,
.board-tb-btn--primary:focus-visible {
  background: var(--ke-board-brand);
  border-color: var(--ke-board-brand);
  color: var(--ke-board-on-brand);
}

.board-tb-btn--danger {
  border-color: var(--ke-board-bad);
  color: var(--ke-board-bad);
}

.board-tb-icon {
  width: 1.6rem;
  height: 1.6rem;
  padding: 0;
}

.board-view-toggles {
  display: inline-flex;
  gap: 0.5rem;
}

.board-seg {
  display: inline-flex;
  border: 1px solid var(--ke-board-line-strong);
}

.board-seg-btn {
  padding: 0.3rem 0.55rem;
  border: 0;
  background: var(--ke-board-surface);
  color: var(--ke-board-muted);
  font-size: 0.72rem;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
}

.board-seg-btn:hover {
  color: var(--ke-board-ink);
}

.board-seg-btn.is-active {
  background: var(--ke-board-ink);
  color: var(--ke-board-surface);
}

/* A two-way choice (copy modal's Copy names / Leave blank): the picked side
   is filled and ticked; the tick's space is always reserved so the buttons
   don't shift when the choice flips. */
.board-seg--choice .board-seg-btn {
  display: inline-flex;
  align-items: center;
  padding: 0.35rem 0.7rem;
  font-size: 0.8rem;
}

.board-seg--choice .board-seg-btn + .board-seg-btn {
  border-left: 1px solid var(--ke-board-line-strong);
}

.board-seg--choice .board-seg-btn::before {
  content: "\2713";
  margin-right: 0.35rem;
  font-weight: 700;
  opacity: 0;
}

.board-seg--choice .board-seg-btn.is-active {
  background: var(--ke-board-brand);
  color: var(--ke-board-on-brand);
}

.board-seg--choice .board-seg-btn.is-active::before {
  opacity: 1;
}

.board-seg--choice .board-seg-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.board-menu {
  max-height: 70vh;
  overflow-y: auto;
  font-size: 0.8rem;
}

/* ── Notices and empty states ──────────────────────────────────────────── */

.board-notice {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin: 0;
  padding: 0.45rem 0.75rem;
  border-left: 3px solid var(--ke-board-brand);
  background: var(--ke-board-brand-soft);
  color: var(--ke-board-ink);
  font-size: 0.75rem;
}

.board-notice--warning {
  border-left-color: var(--ke-board-check);
  background: var(--ke-board-check-bg);
}

.board-notice--danger {
  border-left-color: var(--ke-board-bad);
  background: var(--ke-board-bad-bg);
}

.board-empty {
  margin: 0;
  padding: 0.6rem 0.75rem;
  color: var(--ke-board-muted);
}

/* ── Stats strip ───────────────────────────────────────────────────────── */

.board-stats {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem 0.5rem;
  padding: 0.35rem 0.75rem;
  background: var(--ke-board-surface-2);
  border-bottom: 1px solid var(--ke-board-line);
}

.board-stat {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding-right: 0.6rem;
  border-right: 1px solid var(--ke-board-line);
  color: var(--ke-board-muted);
  font-size: 0.72rem;
  white-space: nowrap;
}

.board-stat b {
  color: var(--ke-board-ink);
  font-size: 0.8rem;
  font-variant-numeric: tabular-nums;
}

.board-stat-version {
  margin-left: auto;
  color: var(--ke-board-muted);
  font-size: 0.72rem;
  white-space: nowrap;
}

.board-stat-version b {
  color: var(--ke-board-ink);
}

.board-stat-changed {
  color: var(--ke-board-sponsor);
  font-weight: 600;
}

.board-swatch {
  display: inline-block;
  width: 0.7rem;
  height: 0.7rem;
  border: 1px solid var(--ke-board-line-strong);
}

.board-swatch--checked {
  background: var(--ke-board-ok-bg);
}

.board-swatch--needs-check {
  background: var(--ke-board-check-bg);
}

.board-swatch--sponsor-pending {
  background: var(--ke-board-sponsor-bg);
}

.board-swatch--gap {
  background: repeating-linear-gradient(
    135deg,
    transparent 0 3px,
    var(--ke-board-gap) 3px 4px
  );
}

.board-swatch--leave {
  background: var(--ke-board-leave);
}

.board-swatch--cancelled {
  background: var(--ke-board-bad);
}

/* EN-0690 legend: role green = accepted, whole row green = ready. */
.board-swatch--ready {
  background: var(--ke-board-ok-bg);
  border-color: var(--ke-board-ok);
  box-shadow: inset 0 0 0 1px var(--ke-board-ok);
}

.board-swatch--declined {
  background: var(--ke-board-bad-bg);
  border-color: var(--ke-board-bad);
}

/* EN-0689: the stats strip's statuses as filter toggles. Each button has its
   own board-* class, so the global button:not(.btn) reset leaves it alone. */
.board-stat-filters {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem 0.5rem;
}

.board-stat--filter {
  margin: 0;
  padding: 0.1rem 0.6rem 0.1rem 0.3rem;
  border-top: 0;
  border-bottom: 0;
  border-left: 0;
  border-radius: 0.25rem 0 0 0.25rem;
  background: none;
  font-family: inherit;
  line-height: 1.4;
  cursor: pointer;
}

.board-stat--filter:hover:not(:disabled) {
  background: var(--ke-board-brand-soft);
  color: var(--ke-board-ink);
}

.board-stat--filter:focus-visible,
.board-stat-clear:focus-visible {
  outline: 2px solid var(--ke-board-brand);
  outline-offset: 1px;
}

.board-stat--active,
.board-stat--active:hover:not(:disabled) {
  background: var(--ke-board-brand-soft);
  box-shadow: inset 0 -2px 0 var(--ke-board-brand);
  color: var(--ke-board-ink);
}

.board-stat--filter:disabled {
  opacity: 0.5;
  cursor: default;
}

.board-stat-clear {
  padding: 0.1rem 0.3rem;
  border: 0;
  background: none;
  color: var(--ke-board-brand-ink);
  font-family: inherit;
  font-size: 0.72rem;
  font-weight: 600;
  text-decoration: underline;
  cursor: pointer;
}

.board-legend {
  display: flex;
  flex-basis: 100%;
  flex-wrap: wrap;
  gap: 0.2rem 0.9rem;
  color: var(--ke-board-subtle);
  font-size: 0.66rem;
}

.board-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  white-space: nowrap;
}

/* ── Board area and Jobs view ──────────────────────────────────────────── */

.board-area {
  position: relative;
  flex: 1;
  min-height: 0;
  overflow: auto;
  background: var(--ke-canvas);
}

.board-columns {
  display: flex;
  align-items: flex-start;
  min-width: max-content;
}

.board-column {
  flex: none;
  width: var(--ke-board-column-width);
  min-height: 100%;
  border-right: 1px solid var(--ke-board-line-strong);
}

.board-column-head {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.4rem;
  padding: 0.35rem 0.5rem;
  background: var(--ke-board-surface);
  border-bottom: 2px solid var(--ke-board-ink);
}

.board-column-title {
  min-width: 0;
  flex: 1;
}

.board-column-title b {
  display: block;
  overflow: hidden;
  font-size: 0.8rem;
  line-height: 1.1;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.board-column-title small {
  display: block;
  color: var(--ke-board-subtle);
  font-size: 0.66rem;
}

.board-column-count {
  color: var(--ke-board-muted);
  font-size: 0.7rem;
  font-variant-numeric: tabular-nums;
}

.board-column-add {
  flex: none;
  width: 1.4rem;
  height: 1.4rem;
  padding: 0;
  border: 1px solid var(--ke-board-line-strong);
  background: var(--ke-board-surface);
  color: var(--ke-board-brand-ink);
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
}

.board-column-body {
  display: grid;
  gap: 0.5rem;
  padding: 0.5rem;
}

.board-column-empty {
  margin: 0;
  color: var(--ke-board-subtle);
  font-size: 0.7rem;
}

/* ── Job blocks ────────────────────────────────────────────────────────── */

.board-job {
  background: var(--ke-board-surface);
  border: 1px solid var(--ke-board-line-strong);
  scroll-margin: 3rem;
}

.board-job--focus {
  outline: 3px solid var(--ke-board-focus);
  outline-offset: 1px;
}

.board-job-head {
  display: flex;
  align-items: flex-start;
  gap: 0.35rem;
  padding: 0.3rem 0.35rem 0.25rem 0.5rem;
  background: var(--ke-board-surface-2);
  border-bottom: 1px solid var(--ke-board-line);
}

.board-job-title {
  flex: 1;
  min-width: 0;
  font-size: 0.75rem;
  line-height: 1.25;
}

.board-job-when {
  color: var(--ke-board-brand-ink);
  font-family: var(--bs-font-monospace);
  font-size: 0.66rem;
  font-weight: 600;
  white-space: nowrap;
}

.board-job-flag {
  font-size: 0.62rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

.board-job-menu {
  flex: none;
  width: 1.2rem;
  height: 1.2rem;
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  line-height: 1;
  cursor: pointer;
}

.board-job-meta {
  display: grid;
  gap: 0.05rem;
  padding: 0.25rem 0.5rem 0.3rem;
  border-bottom: 1px solid var(--ke-board-line);
  color: var(--ke-board-muted);
  font-size: 0.68rem;
}

.board-job-times {
  color: var(--ke-board-ink);
  font-family: var(--bs-font-monospace);
  font-size: 0.66rem;
}

.board-job-planned {
  color: var(--ke-board-muted);
}

.board-job-empty {
  margin: 0;
  padding: 0.3rem 0.5rem;
  color: var(--ke-board-subtle);
  font-size: 0.7rem;
}

.board-job-foot {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  padding: 0.25rem 0.35rem;
  border-top: 1px solid var(--ke-board-line);
  background: var(--ke-board-surface-2);
}

.board-job-foot button,
.board-job-foot a {
  padding: 0.05rem 0.2rem;
  border: 0;
  background: none;
  color: var(--ke-board-brand-ink);
  font-size: 0.66rem;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
}

.board-job--cancelled {
  border-color: var(--ke-board-bad);
}

.board-job--cancelled .board-job-head {
  background: var(--ke-board-bad);
  color: var(--ke-board-on-bad);
}

.board-job--cancelled .board-job-when {
  color: var(--ke-board-on-bad);
}

.board-job--cancelled .board-slot-name {
  color: var(--ke-board-muted);
  text-decoration: line-through;
}

/* ── Slot rows (22px) ──────────────────────────────────────────────────── */

.board-slot {
  display: grid;
  grid-template-columns: var(--ke-board-role-width) minmax(0, 1fr) auto;
  align-items: stretch;
  min-height: var(--ke-board-row-height);
  border-top: 1px solid var(--ke-board-line);
}

.board-slot:first-child {
  border-top: 0;
}

.board-slot:focus-visible,
.board-slot-trigger:focus-visible {
  outline: 2px solid var(--ke-board-brand);
  outline-offset: -2px;
}

/* A publish blocker's slot (roster-board.js focusBoardTarget): ringed until
   the next jump, with a short pulse so the eye finds it after the scroll. */
.board-slot--focus {
  position: relative;
  z-index: 1;
  outline: 3px solid var(--ke-board-focus);
  outline-offset: -1px;
  animation: board-slot-focus-pulse 0.6s ease-in-out 3;
}

@keyframes board-slot-focus-pulse {
  50% {
    outline-color: transparent;
  }
}

@media (prefers-reduced-motion: reduce) {
  .board-slot--focus {
    animation: none;
  }
}

.board-slot-role {
  align-self: center;
  overflow: hidden;
  padding: 0.15rem 0.35rem;
  border-right: 1px solid var(--ke-board-line);
  color: var(--ke-board-muted);
  font-size: 0.68rem;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.board-slot-role--button {
  min-width: 0;
  border-top: 0;
  border-bottom: 0;
  border-left: 0;
  background: none;
  text-align: left;
  cursor: pointer;
}

.board-slot-role--button:hover {
  background: var(--ke-board-brand-soft);
  color: var(--ke-board-ink);
}

.board-slot-role--button:focus-visible {
  outline: 2px solid var(--ke-board-brand);
  outline-offset: -2px;
}

.board-slot-label {
  color: var(--ke-board-ink);
  font-weight: 600;
}

.board-slot-name,
.board-slot-trigger {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  min-width: 0;
  overflow: hidden;
  padding: 0.15rem 0.35rem;
  font-weight: 500;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.board-slot-trigger {
  width: 100%;
  border: 0;
  background: none;
  color: inherit;
  font-size: inherit;
  text-align: left;
  cursor: pointer;
}

.board-slot-name--gap,
.board-slot--gap .board-slot-trigger {
  color: var(--ke-board-gap);
  font-weight: 600;
}

.board-slot-status {
  display: flex;
  align-items: center;
  gap: 0.2rem;
  padding: 0 0.3rem;
  font-size: 0.7rem;
}

.board-slot--checked > .board-slot-name,
.board-slot--checked > .board-slot-trigger,
.board-slot--checked > .board-slot-status {
  background: var(--ke-board-ok-bg);
}

.board-slot--needs-check > .board-slot-name,
.board-slot--needs-check > .board-slot-trigger,
.board-slot--needs-check > .board-slot-status {
  background: var(--ke-board-check-bg);
}

.board-slot--sponsor-pending > .board-slot-name,
.board-slot--sponsor-pending > .board-slot-trigger,
.board-slot--sponsor-pending > .board-slot-status {
  background: var(--ke-board-sponsor-bg);
}

.board-slot--gap > .board-slot-name,
.board-slot--gap > .board-slot-trigger {
  background: repeating-linear-gradient(
    135deg,
    transparent 0 5px,
    var(--ke-board-bad-bg) 5px 7px
  );
}

.board-slot--leave-clash > .board-slot-name,
.board-slot--leave-clash > .board-slot-trigger {
  box-shadow: inset 3px 0 0 var(--ke-board-leave);
}

.board-slot--combined .board-slot-status {
  gap: 0.25rem;
}

/* Drag and drop (66.4c). */
.board-drop-hover {
  outline: 2px dashed var(--ke-board-brand);
  outline-offset: -2px;
}

.board-dragging {
  opacity: 0.55;
}

.board-drag-ghost {
  background: var(--ke-board-brand-soft);
  box-shadow: var(--ke-board-shadow);
}

/* Response icons: ✓ accepted, ◷ awaiting reply, ✕ declined. */
.board-response {
  display: inline-block;
  min-width: 0.8rem;
  font-weight: 700;
  line-height: 1;
  text-align: center;
}

.board-response--accepted {
  color: var(--ke-board-ok);
}

.board-response--pending {
  color: var(--ke-board-check);
}

.board-response--declined {
  color: var(--ke-board-bad);
}

/* Day chips on combined rows (D2). */
.board-day-chips {
  display: inline-flex;
  gap: 1px;
}

.board-day-chip {
  padding: 0.12rem 0.15rem;
  border: 1px solid var(--ke-board-line);
  color: var(--ke-board-subtle);
  font-family: var(--bs-font-monospace);
  font-size: 0.56rem;
  font-weight: 600;
  line-height: 1;
}

.board-day-chip--checked {
  background: var(--ke-board-ok-bg);
  color: var(--ke-board-ok);
}

.board-day-chip--needs-check {
  background: var(--ke-board-check-bg);
  color: var(--ke-board-check);
}

.board-day-chip--sponsor-pending {
  background: var(--ke-board-sponsor-bg);
  color: var(--ke-board-sponsor);
}

.board-day-chip--gap {
  background: var(--ke-board-bad);
  border-color: var(--ke-board-bad);
  color: var(--ke-board-on-bad);
}

.board-day-chip--leave {
  box-shadow: inset 0 -2px 0 var(--ke-board-leave);
}

/* EN-0690: the reply on a day chip — accepted outlines it green (a checked,
   accepted day is a green chip with a green outline), declined turns it red,
   awaiting leaves it as the check status draws it. */
.board-day-chip--accepted {
  border-color: var(--ke-board-ok);
}

.board-day-chip--declined {
  border-color: var(--ke-board-bad);
  background: var(--ke-board-bad-bg);
  color: var(--ke-board-bad);
}

/* EN-0690: the reply on a slot row's role cell. Accepted = green (with the
   name's checked green, the whole row is green); declined = red; awaiting
   reply leaves the role cell neutral (the ◷ icon says it). */
.board-slot--accepted > .board-slot-role {
  background: var(--ke-board-ok-bg);
  color: var(--ke-board-ok);
}

.board-slot--declined > .board-slot-role {
  background: var(--ke-board-bad-bg);
  color: var(--ke-board-bad);
}

.board-slot--accepted > .board-slot-role--button:hover,
.board-slot--declined > .board-slot-role--button:hover {
  background: var(--ke-board-brand-soft);
  color: var(--ke-board-ink);
}

.board-slot--accepted > .board-slot-role .board-slot-label,
.board-slot--declined > .board-slot-role .board-slot-label {
  color: var(--ke-board-ink);
}

/* EN-0689: a row matching the status filter. */
.board-slot--filter-match {
  box-shadow: inset 0 0 0 2px var(--ke-board-brand);
}

/* ── Anchored gap shortlist / person menu (66.4c) ──────────────────────── */

.board-panel {
  position: absolute;
  z-index: 50;
  width: var(--ke-board-panel-width);
  max-height: 420px;
  overflow: auto;
  background: var(--ke-board-surface);
  border: 1px solid var(--ke-board-line-strong);
  box-shadow: var(--ke-board-shadow);
  font-size: 0.75rem;
}

.board-panel:empty {
  display: none;
}

.board-panel-head {
  display: grid;
  gap: 0.1rem;
  padding: 0.5rem 0.6rem;
  background: var(--ke-board-surface-2);
  border-bottom: 1px solid var(--ke-board-line);
}

.board-panel-head small {
  color: var(--ke-board-subtle);
}

.board-panel-group {
  padding: 0.35rem 0.6rem 0.2rem;
  color: var(--ke-board-subtle);
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.board-overview-shift {
  display: grid;
  grid-template-columns: 3.4rem minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.4rem;
  padding: 0.3rem 0.6rem;
  border-top: 1px solid var(--ke-board-line);
  color: var(--ke-board-ink);
  text-decoration: none;
}

.board-overview-shift:hover,
.board-overview-shift:focus-visible {
  background: var(--ke-board-brand-soft);
  color: var(--ke-board-ink);
}

.board-overview-shift.is-cancelled .board-overview-what b {
  color: var(--ke-board-muted);
  text-decoration: line-through;
}

.board-overview-when {
  font-weight: 600;
  white-space: nowrap;
}

.board-overview-period {
  color: var(--ke-board-brand-ink);
  font-family: var(--bs-font-monospace);
  font-size: 0.66rem;
}

.board-overview-what {
  min-width: 0;
}

.board-overview-what small {
  display: block;
  overflow: hidden;
  color: var(--ke-board-subtle);
  font-size: 0.66rem;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.board-overview-status {
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
}

.board-overview-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.4rem;
  margin: 0;
  padding: 0.25rem 0.6rem;
  border-top: 1px solid var(--ke-board-line);
}

.board-overview-line small {
  color: var(--ke-board-subtle);
  font-size: 0.66rem;
  white-space: nowrap;
}

.board-overview-empty {
  margin: 0;
  padding: 0.3rem 0.6rem;
  color: var(--ke-board-subtle);
}

.board-candidate {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.25rem;
  width: 100%;
  padding: 0.3rem 0.6rem;
  border: 0;
  border-top: 1px solid var(--ke-board-line);
  background: none;
  color: var(--ke-board-ink);
  font-size: inherit;
  text-align: left;
  cursor: pointer;
}

.board-candidate:hover,
.board-candidate:focus-visible {
  background: var(--ke-board-brand-soft);
}

.board-candidate small {
  display: block;
  color: var(--ke-board-subtle);
  font-size: 0.66rem;
}

.board-candidate--unavailable {
  cursor: default;
  opacity: 0.65;
}

.board-candidate--unavailable:hover {
  background: none;
}

.board-panel-menu > button,
.board-panel-menu > a {
  display: block;
  width: 100%;
  padding: 0.45rem 0.6rem;
  border: 0;
  border-top: 1px solid var(--ke-board-line);
  background: none;
  color: var(--ke-board-ink);
  font-size: 0.75rem;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
}

.board-panel-menu > button:hover,
.board-panel-menu > a:hover {
  background: var(--ke-board-brand-soft);
}

.board-panel-menu > button small {
  display: block;
  color: var(--ke-board-subtle);
  font-size: 0.66rem;
}

.board-panel-menu > .is-current {
  box-shadow: inset 3px 0 0 var(--ke-board-brand);
  font-weight: 600;
}

.board-panel-menu > .is-danger {
  color: var(--ke-board-bad);
}

/* ── Drawers (one slide-over, 430px) ───────────────────────────────────── */

#offcanvas-board {
  --bs-offcanvas-width: var(--ke-board-drawer-width);
}

.board-drawer {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  font-size: 0.8rem;
}

.board-drawer-section {
  display: grid;
  gap: 0.4rem;
}

.board-drawer-foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 0.5rem;
  padding-top: 0.6rem;
  border-top: 1px solid var(--ke-board-line);
}

.board-drawer-note {
  margin-right: auto;
  color: var(--ke-board-subtle);
  font-size: 0.7rem;
}

/* "Existing job" work register lines: a long register scrolls in place. */
.board-register-lines {
  max-height: 16rem;
  overflow-y: auto;
}

/* The job form's wide modal: sectioned two-column layout, sticky footer. */
.board-job-modal .modal-body {
  padding: 0 1.5rem;
}

.board-job-form {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  padding-top: 1.25rem;
}

.board-job-form-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
}

.board-job-section {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding: 1rem;
  border: 1px solid var(--ke-board-line);
}

.board-job-section .mb-3 {
  margin-bottom: 0 !important;
}

.board-job-section-title {
  margin: 0;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ke-board-subtle);
}

.board-job-form-foot {
  position: sticky;
  bottom: 0;
  z-index: 2;
  margin: 0 -1.5rem;
  padding: 0.75rem 1.5rem;
  background: var(--bs-body-bg);
}

.board-job-modal #board-job-deployment {
  margin-bottom: 1.25rem;
  padding: 1rem;
  border: 1px solid var(--ke-board-line);
}

/* Quick-pick time chips (components/forms.html#time-picks). */
.time-picks {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  margin-top: 0.35rem;
}

.btn.time-pick {
  padding: 0.1rem 0.5rem;
  border: 1px solid var(--bs-border-color);
  border-radius: 999px;
  background: var(--bs-tertiary-bg);
  color: var(--bs-body-color);
  font-size: 0.72rem;
  font-variant-numeric: tabular-nums;
  line-height: 1.4;
}

.btn.time-pick:hover,
.btn.time-pick:focus-visible {
  border-color: var(--bs-primary);
}

.btn.time-pick.is-active {
  border-color: var(--bs-primary);
  background: var(--bs-primary);
  color: #fff;
}

.board-date-ticks {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
}

.board-date-ticks label {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.25rem 0.45rem;
  border: 1px solid var(--ke-board-line-strong);
  font-size: 0.7rem;
  cursor: pointer;
}

.board-role-rows {
  display: grid;
  gap: 0.25rem;
}

.board-role-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 3.5rem 4.5rem 1.6rem;
  gap: 0.25rem;
  align-items: center;
}

/* Column headings over the role rows, on the same grid as the inputs. */
.board-role-head .form-label {
  margin-bottom: 0;
}

.board-diff {
  display: grid;
  border: 1px solid var(--ke-board-line);
}

.board-diff-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.1rem 0.5rem;
  padding: 0.3rem 0.5rem;
  border-top: 1px solid var(--ke-board-line);
}

.board-diff-row:first-child {
  border-top: 0;
}

.board-diff-row small {
  grid-column: 1 / -1;
  color: var(--ke-board-muted);
}

.board-diff-added {
  color: var(--ke-board-ok);
}

.board-diff-removed {
  color: var(--ke-board-bad);
}

/* ── Days view ─────────────────────────────────────────────────────────── */

.board-days {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: var(--ke-board-day-width);
  min-width: max-content;
}

.board-day {
  min-height: 100%;
  border-right: 1px solid var(--ke-board-line-strong);
}

.board-day-card {
  display: grid;
  gap: 0.1rem;
  padding: 0.35rem 0.5rem;
  background: var(--ke-board-surface);
  border: 1px solid var(--ke-board-line-strong);
  color: var(--ke-board-ink);
  text-align: left;
  text-decoration: none;
  cursor: pointer;
}

.board-day-card:hover,
.board-day-card:focus-visible {
  border-color: var(--ke-board-brand);
}

.board-day-card small {
  color: var(--ke-board-subtle);
}

.board-day-card--cancelled {
  border-color: var(--ke-board-bad);
}

.board-day-card--cancelled b {
  text-decoration: line-through;
}

.board-day-card-fill {
  font-family: var(--bs-font-monospace);
  font-size: 0.66rem;
  font-weight: 600;
}

.board-day-card-fill--gaps {
  color: var(--ke-board-gap);
}

.board-fill-bar {
  display: flex;
  height: 4px;
  background: var(--ke-board-line);
}

.board-fill-bar > span {
  display: block;
  height: 100%;
}

.board-fill-bar > .is-checked {
  background: var(--ke-board-ok);
}

.board-fill-bar > .is-needs-check {
  background: var(--ke-board-check);
}

.board-fill-bar > .is-sponsor-pending {
  background: var(--ke-board-sponsor);
}

/* ── People view ───────────────────────────────────────────────────────── */

.board-people {
  min-width: 100%;
  border-collapse: collapse;
  background: var(--ke-board-surface);
  font-size: 0.72rem;
}

.board-people th,
.board-people td {
  padding: 0.25rem 0.4rem;
  border: 1px solid var(--ke-board-line);
  text-align: left;
  white-space: nowrap;
}

.board-people thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--ke-board-surface);
  font-size: 0.7rem;
}

.board-people .board-people-name {
  position: sticky;
  left: 0;
  z-index: 1;
  background: var(--ke-board-surface);
  font-weight: 600;
}

.board-people thead .board-people-name {
  z-index: 3;
}

.board-people-team th {
  background: var(--ke-board-surface-2);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.board-people-cell--checked {
  background: var(--ke-board-ok-bg);
}

.board-people-cell--needs-check {
  background: var(--ke-board-check-bg);
}

.board-people-cell--sponsor-pending {
  background: var(--ke-board-sponsor-bg);
}

.board-people-cell--leave {
  background: var(--ke-board-leave-bg);
  color: var(--ke-board-leave);
  font-weight: 600;
}

.board-people-cell--leave-pending {
  color: var(--ke-board-leave);
  font-style: italic;
}

.board-people-cell--clash {
  box-shadow: inset 0 0 0 2px var(--ke-board-bad);
}

/* ── Checks queue (66.4f) ──────────────────────────────────────────────── */

.board-checks-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 0.35rem 0.75rem;
  padding: 0.45rem 0;
  border-top: 1px solid var(--ke-board-line);
  font-size: 0.8rem;
}

.board-checks-row small {
  display: block;
  color: var(--ke-board-subtle);
}

.board-checks-row--sponsor-pending {
  box-shadow: inset 3px 0 0 var(--ke-board-sponsor);
}

.board-checks-row--needs-check {
  box-shadow: inset 3px 0 0 var(--ke-board-check);
}

.board-checks-bulk {
  position: sticky;
  bottom: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0;
  background: var(--ke-board-surface);
  border-top: 1px solid var(--ke-board-line-strong);
}

/* ── Leave cover table (holiday request, 66.5) ─────────────────────────── */

.roster-cover {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8rem;
}

.roster-cover th,
.roster-cover td {
  padding: 0.35rem;
  border-bottom: 1px solid var(--ke-board-line);
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.roster-cover th:first-child,
.roster-cover td:first-child {
  text-align: left;
}

.roster-cover thead th {
  color: var(--ke-board-subtle);
  font-size: 0.66rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.roster-cover .is-short {
  color: var(--ke-board-bad);
  font-weight: 700;
}

.roster-cover .is-ok {
  color: var(--ke-board-ok);
  font-weight: 700;
}

/* ── My shifts (worker, mobile first, 66.5) ────────────────────────────── */

.my-shift-list {
  display: grid;
  gap: 0.5rem;
}

.my-shift-card {
  display: grid;
  gap: 0.25rem;
  padding: 0.75rem;
  background: var(--ke-board-surface);
  border: 1px solid var(--ke-board-line);
  border-left: 4px solid var(--ke-board-line-strong);
  color: var(--ke-board-ink);
}

.my-shift-card--pending {
  border-left-color: var(--ke-board-check);
}

.my-shift-card--accepted {
  border-left-color: var(--ke-board-ok);
}

.my-shift-card--declined {
  border-left-color: var(--ke-board-bad);
}

.my-shift-card-time {
  color: var(--ke-board-brand-ink);
  font-family: var(--bs-font-monospace);
  font-size: 0.8rem;
  font-weight: 600;
}

.my-shift-card-meta {
  color: var(--ke-board-muted);
  font-size: 0.8rem;
}

.my-shift-card-change {
  color: var(--ke-board-sponsor);
  font-size: 0.66rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.my-shift-card-status {
  font-size: 0.8rem;
  font-weight: 600;
}

.my-shift-card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.25rem;
}

.my-shift-card-actions > .btn,
.my-shift-card-actions > form {
  flex: 1 1 8rem;
}

.my-shift-card-actions > form > .btn {
  width: 100%;
}

@media (min-width: 768px) {
  .my-shift-list {
    grid-template-columns: repeat(auto-fill, minmax(18rem, 1fr));
  }
}

/* ==========================================================================
   Field (phone) screens (plan 68.5, D20; contract C16)
   Security staff pages extend templates/deployments/field/_base.html, which
   stays inside app_shell and sets <body class="field">. Under 768 px the
   sidebar and desktop top bar are hidden, main padding drops and a fixed
   bottom tab bar shows; at 768 px and up the page sits in a centred 480 px
   column inside the normal shell. Tokens only — dark mode comes from them.
   Status is never colour alone: pills and timeline rows carry text.
   ========================================================================== */

.field-page {
  max-width: 480px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.field-content {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

@media (max-width: 767.98px) {
  .field .app-topbar,
  .field .app-sidebar {
    display: none !important;
  }

  .field .app-main {
    padding: 0 0 calc(4rem + env(safe-area-inset-bottom, 0px)) !important;
  }

  .field .field-page {
    max-width: none;
    gap: 0.625rem;
  }

  .field .field-content {
    padding: 0 0.75rem 0.75rem;
  }
}

/* Compact top bar: back arrow, title / subtitle, optional pill. */
.field-topbar {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  min-height: 3.5rem;
  padding: 0.5rem 0.75rem;
  padding-top: calc(0.5rem + env(safe-area-inset-top, 0px));
  background: var(--ke-surface);
  border-bottom: 1px solid var(--ke-chrome-border);
}

.field-topbar-back {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.75rem;
  height: 2.75rem;
  flex-shrink: 0;
  color: var(--ke-text);
}

.field-topbar-back[href=""] {
  display: none;
}

.field-topbar-text {
  flex: 1 1 auto;
  min-width: 0;
}

.field-topbar-title {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.field-topbar-subtitle {
  margin: 0;
  font-size: 0.8rem;
  color: var(--ke-text-muted);
}

.field-topbar-subtitle:empty,
.field-topbar-pill:empty {
  display: none;
}

.field-topbar-pill {
  flex-shrink: 0;
}

/* Cards */
.field-card {
  padding: 0.75rem 0.875rem;
  background: var(--ke-surface);
  border: 1px solid var(--bs-border-color);
  color: var(--ke-text);
}

.field-card-label {
  margin: 0 0 0.375rem;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ke-text-muted);
}

.field-notice {
  background: var(--bs-warning-bg-subtle);
  border-color: var(--bs-warning-border-subtle);
  color: var(--bs-warning-text-emphasis);
}

.field-notice .field-card-label {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  color: var(--bs-warning-text-emphasis);
}

.field-notice-body > :last-child {
  margin-bottom: 0;
}

.field-notices {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

/* Big buttons: full width, 48 px tall. */
.field-btn-wrap {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.field-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  width: 100%;
  min-height: 48px;
  padding: 0.625rem 1rem;
  font-size: 1rem;
  font-weight: 700;
  text-align: center;
  text-decoration: none;
  border: 1px solid transparent;
  color: #fff;
  background: var(--bs-primary);
  cursor: pointer;
}

.field-btn:focus-visible {
  outline: 0;
  box-shadow: 0 0 0 0.25rem var(--bs-focus-ring-color);
}

.field-btn-primary {
  background: var(--bs-primary);
}

.field-btn-go {
  background: var(--bs-success);
}

.field-btn-stop {
  background: var(--bs-danger);
}

.field-btn-ghost {
  background: transparent;
  border-color: var(--bs-border-color);
  color: var(--ke-text);
  font-weight: 600;
  font-size: 0.9rem;
}

.field-btn:hover:not([disabled]) {
  filter: brightness(0.94);
}

.field-btn[disabled] {
  background: var(--bs-secondary-bg);
  border-color: var(--bs-border-color);
  color: var(--ke-text-subtle);
  cursor: not-allowed;
  filter: none;
}

/* A field checkbox with a 24 px box and a 44 px tall row to tap. */
.field-check-lg {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  min-height: 44px;
  padding-left: 0;
}

.field-check-lg .form-check-input {
  float: none;
  flex-shrink: 0;
  width: 1.5rem;
  height: 1.5rem;
  margin: 0;
}

.field-btn-reason {
  margin: 0;
  font-size: 0.8rem;
  text-align: center;
  color: var(--ke-text-muted);
}

/* Status pills: g success · a warning · r danger · b primary · k secondary. */
.field-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.15rem 0.5rem;
  font-size: 0.72rem;
  font-weight: 700;
  line-height: 1.4;
  white-space: nowrap;
  border: 1px solid transparent;
}

.field-pill-g {
  background: var(--bs-success-bg-subtle);
  border-color: var(--bs-success-border-subtle);
  color: var(--bs-success-text-emphasis);
}

.field-pill-a {
  background: var(--bs-warning-bg-subtle);
  border-color: var(--bs-warning-border-subtle);
  color: var(--bs-warning-text-emphasis);
}

.field-pill-r {
  background: var(--bs-danger-bg-subtle);
  border-color: var(--bs-danger-border-subtle);
  color: var(--bs-danger-text-emphasis);
}

.field-pill-b {
  background: var(--bs-primary-bg-subtle);
  border-color: var(--bs-primary-border-subtle);
  color: var(--bs-primary-text-emphasis);
}

.field-pill-k {
  background: var(--bs-secondary-bg-subtle);
  border-color: var(--bs-secondary-border-subtle);
  color: var(--bs-secondary-text-emphasis);
}

/* GPS panel (geo.js fills the line and the quality pill). */
.field-gps-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.field-gps-line {
  font-size: 0.85rem;
}

.field-gps-line[data-tone="a"] {
  color: var(--bs-warning-text-emphasis);
}

.field-gps-retry {
  min-height: 2.5rem;
  margin-top: 0.5rem;
}

.field-gps[data-geo-state="fixed"] .field-gps-retry {
  display: none;
}

/* Bottom tab bar: fixed on phones only. */
.field-tabbar {
  display: none;
}

@media (max-width: 767.98px) {
  .field .field-tabbar {
    position: fixed;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: var(--ke-z-fixed);
    display: flex;
    padding-bottom: env(safe-area-inset-bottom, 0px);
    background: var(--ke-dropdown-bg);
    border-top: 1px solid var(--ke-chrome-border);
  }
}

.field-tabbar-item {
  flex: 1 1 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.15rem;
  min-height: 3.5rem;
  font-size: 0.72rem;
  font-weight: 600;
  text-decoration: none;
  color: var(--ke-text-muted);
}

.field-tabbar-item.is-active {
  color: var(--bs-primary);
}

[data-bs-theme="dark"] .field-tabbar-item.is-active {
  color: var(--ke-brand-300);
}

.field-tabbar-item.is-disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

/* In-page tabs (Where & when · Pack · Checkpoints). */
.field-tabs {
  display: flex;
  overflow-x: auto;
  border-bottom: 1px solid var(--ke-chrome-border);
  scrollbar-width: none;
}

.field-tabs > a,
.field-tabs > button {
  flex: 1 0 auto;
  min-height: 2.75rem;
  padding: 0.5rem 0.75rem;
  font-size: 0.85rem;
  font-weight: 600;
  text-align: center;
  text-decoration: none;
  white-space: nowrap;
  color: var(--ke-text-muted);
  background: none;
  border: 0;
  border-bottom: 3px solid transparent;
}

.field-tabs > .is-active,
.field-tabs > [aria-selected="true"] {
  color: var(--ke-text);
  border-bottom-color: var(--bs-primary);
}

/* Shift timeline (book on → visits → occurrences → book off). */
.field-timeline {
  margin: 0;
  padding: 0 0 0 1.25rem;
  list-style: none;
  border-left: 2px solid var(--bs-border-color);
}

.field-timeline > li {
  position: relative;
  padding: 0.25rem 0 0.625rem;
  font-size: 0.85rem;
}

.field-timeline > li::before {
  content: "";
  position: absolute;
  top: 0.5rem;
  left: calc(-1.25rem - 6px);
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--bs-primary);
  box-shadow: 0 0 0 2px var(--bs-body-bg);
}

.field-timeline > li.is-occurrence::before {
  background: var(--bs-warning);
}

.field-timeline > li.is-end::before {
  background: var(--bs-success);
}

/* Route checkpoints: done / current / next. */
.field-checkpoint {
  display: flex;
  align-items: flex-start;
  gap: 0.625rem;
  padding: 0.625rem 0;
  border-bottom: 1px solid var(--bs-border-color);
  font-size: 0.875rem;
}

.field-checkpoint:last-child {
  border-bottom: 0;
}

.field-checkpoint-marker {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.75rem;
  height: 1.75rem;
  flex-shrink: 0;
  border-radius: 50%;
  font-size: 0.75rem;
  font-weight: 700;
  background: var(--bs-secondary-bg);
  color: var(--ke-text);
}

.field-checkpoint.is-done .field-checkpoint-marker {
  background: var(--bs-success);
  color: #fff;
}

.field-checkpoint.is-current .field-checkpoint-marker {
  background: var(--bs-primary);
  color: #fff;
}

.field-checkpoint.is-current {
  font-weight: 600;
}

/* Phone-safe tables: label / value rows that stack under 576 px. */
.field-table {
  width: 100%;
  font-size: 0.85rem;
  border-collapse: collapse;
}

.field-table th,
.field-table td {
  padding: 0.375rem 0.5rem;
  vertical-align: top;
  border-bottom: 1px solid var(--bs-border-color);
}

.field-table th {
  font-weight: 600;
  color: var(--ke-text-muted);
}

@media (max-width: 575.98px) {
  .field-table thead {
    display: none;
  }

  .field-table,
  .field-table tbody,
  .field-table tr,
  .field-table th,
  .field-table td {
    display: block;
    width: 100%;
  }

  .field-table tr {
    padding: 0.375rem 0;
    border-bottom: 1px solid var(--bs-border-color);
  }

  .field-table th,
  .field-table td {
    padding: 0.125rem 0;
    border-bottom: 0;
  }

  .field-table td[data-label]::before {
    content: attr(data-label);
    display: block;
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--ke-text-muted);
  }
}

/* ============================================================
   Interactive maps
   templates/components/maps.html + frontend/src/app/maps.js (the
   Silas map stack: MapLibre GL + self-hosted PMTiles). One
   vocabulary for every map surface — inline panels, the
   "Show on map" drawer and the deployments live map.
   Marker tones are the status-pill tones (g / a / r / b / k).
   ============================================================ */

.ke-map {
  position: relative;
  overflow: hidden;
  border-radius: var(--ke-radius-card);
  /* Also what a map that never finishes loading looks like. */
  background: var(--ke-muted-surface);
}

.ke-map--panel { height: 22rem; }
.ke-map--tall { height: 35rem; }
.ke-map--drawer { flex: 1 1 auto; min-height: 16rem; border-radius: 0; }
/* A pin dropper: aim, don't grab (a drag still pans). */
.ke-map--pick .maplibregl-canvas-container.maplibregl-interactive { cursor: crosshair; }
/* The live map: most of a phone screen; from lg as tall as the viewport
   allows below the page header, beside its sidebar. */
.ke-map--fill { height: 60vh; min-height: 20rem; }

@media (min-width: 992px) {
  .ke-map--fill { height: max(24rem, calc(100vh - var(--ke-topbar-height) - 15rem)); }
}

/* --- Markers --- */

.ke-map-marker {
  position: relative;
  display: grid;
  place-items: center;
  width: 1.875rem;
  height: 1.875rem;
  padding: 0;
  color: #fff;
  font-size: 0.72rem;
  font-weight: 700;
  line-height: 1;
  border: 3px solid var(--bs-body-bg);
  border-radius: 999px;
  cursor: pointer;
  box-shadow: var(--ke-shadow-sm);
}

.ke-map-marker--g { background: var(--bs-success); }
.ke-map-marker--a { background: var(--bs-warning); color: #212529; }
.ke-map-marker--r { background: var(--bs-danger); }
.ke-map-marker--b { background: var(--bs-primary); }
.ke-map-marker--k { background: var(--ke-text-subtle); }

/* An alert on a person's marker: a coloured halo, not a second pin. */
.ke-map-marker--ring-r { box-shadow: 0 0 0 0.25rem rgba(var(--bs-danger-rgb), 0.45), var(--ke-shadow-sm); }
.ke-map-marker--ring-a { box-shadow: 0 0 0 0.25rem rgba(var(--bs-warning-rgb), 0.55), var(--ke-shadow-sm); }

/* Planned-but-not-yet points (a route's unvisited checkpoints). */
.ke-map-marker.is-muted {
  width: 1.5rem;
  height: 1.5rem;
  font-size: 0.65rem;
  opacity: 0.8;
}

.ke-map-marker.is-selected {
  z-index: 2;
  width: 2.25rem;
  height: 2.25rem;
  outline: 3px solid rgba(var(--bs-primary-rgb), 0.35);
}

.ke-map-marker:focus-visible {
  outline: 2px solid var(--bs-primary);
  outline-offset: 2px;
}

.ke-map-marker-glyph { pointer-events: none; }

/* The marker's name: shown on hover, focus and selection by CSS alone. */
.ke-map-marker-chip {
  position: absolute;
  left: calc(100% + 0.375rem);
  top: 50%;
  transform: translateY(-50%);
  padding: 0.125rem 0.4rem;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--bs-body-color);
  white-space: nowrap;
  pointer-events: none;
  background: var(--bs-body-bg);
  border: 1px solid var(--bs-border-color);
  border-radius: var(--ke-radius-control);
  opacity: 0;
  transition: opacity 120ms ease;
}

.ke-map-marker-chip:empty { display: none; }

.ke-map-marker:hover .ke-map-marker-chip,
.ke-map-marker:focus-visible .ke-map-marker-chip,
.ke-map-marker.is-selected .ke-map-marker-chip { opacity: 1; }

/* --- Fallback (no JS, no WebGL, tiles unreachable) --- */

.ke-map-fallback {
  display: none;
  position: absolute;
  inset: 0;
  z-index: 3;
  margin: 0;
  padding: 1.5rem;
  align-items: center;
  justify-content: center;
  text-align: center;
  color: var(--ke-text-muted);
  background: var(--ke-muted-surface);
}

.ke-map--failed .ke-map-fallback,
.ke-map-fallback--noscript { display: flex; }

/* --- MapLibre chrome --- */

/* The attribution is a licence requirement (ODbL): sized down, never hidden. */
.ke-map .maplibregl-ctrl-attrib { font-size: 0.6875rem; }
.ke-map .maplibregl-ctrl-group { border-radius: var(--ke-radius-control); }

.ke-map .maplibregl-popup-content {
  padding: 0.5rem 1.75rem 0.5rem 0.75rem;
  color: var(--bs-body-color);
  background: var(--bs-body-bg);
  border-radius: var(--ke-radius-control);
  box-shadow: var(--ke-shadow-sm);
}

.ke-map .maplibregl-popup-close-button { color: var(--bs-body-color); font-size: 1.1rem; }
.ke-map .maplibregl-popup-anchor-bottom .maplibregl-popup-tip { border-top-color: var(--bs-body-bg); }
.ke-map .maplibregl-popup-anchor-top .maplibregl-popup-tip { border-bottom-color: var(--bs-body-bg); }
.ke-map .maplibregl-popup-anchor-left .maplibregl-popup-tip { border-right-color: var(--bs-body-bg); }
.ke-map .maplibregl-popup-anchor-right .maplibregl-popup-tip { border-left-color: var(--bs-body-bg); }

/* MapLibre's controls are a fixed light palette drawn with SVG data URIs;
   invert them in dark mode rather than hardcoding colours. */
[data-bs-theme="dark"] .ke-map .maplibregl-ctrl-group,
[data-bs-theme="dark"] .ke-map .maplibregl-ctrl-attrib {
  filter: invert(1) hue-rotate(180deg);
}

/* --- The "Show on map" drawer ---
   A bottom sheet covering the lower half of the page (70% on a phone),
   never a modal: the page above keeps
   scrolling, and maps.js puts .ke-map-drawer-open on <body> while it is open
   so the last rows of a page can still be scrolled clear of it. It spans the
   main body only, never the sidebar. */
:root { --ke-map-drawer-height: 50vh; }

.ke-map-drawer.offcanvas-bottom { --bs-offcanvas-height: var(--ke-map-drawer-height); }

@media (max-width: 767.98px) {
  :root { --ke-map-drawer-height: 70vh; }
}

/* The page scrolls inside .app-main (not <body>): pad that, past the
   utility padding (p-lg-5 is !important), so the last rows clear the sheet. */
body.ke-map-drawer-open .app-main {
  padding-bottom: calc(var(--ke-map-drawer-height) + 1.5rem) !important;
}

/* Stay inside the main body: from lg the sheet starts where .app-main-wrap
   does, beside the rail or the expanded sidebar, never under it. */
@media (min-width: 992px) {
  .ke-map-drawer.offcanvas-bottom {
    left: var(--ke-sidebar-collapsed-width);
    transition: transform 0.3s ease-in-out, left 0.2s ease;
  }

  html.sidebar-expanded .ke-map-drawer.offcanvas-bottom { left: var(--ke-sidebar-width); }
}

/* --- Deployments live map: map + sidebar --- */

.live-map-sidebar {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

@media (min-width: 992px) {
  .live-map-sidebar {
    max-height: max(24rem, calc(100vh - var(--ke-topbar-height) - 15rem));
    overflow-y: auto;
  }
}

.live-map-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.5rem 0;
}

.live-map-row + .live-map-row { border-top: 1px solid var(--bs-border-color); }

.live-map-key {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 0.75rem;
  font-size: 0.75rem;
  color: var(--ke-text-muted);
}

.live-map-key > span { display: inline-flex; align-items: center; gap: 0.3rem; }

.live-map-key-dot {
  display: inline-block;
  width: 0.7rem;
  height: 0.7rem;
  border-radius: 999px;
}

/* Recent activity: a compact feed of the latest check-ins and occurrences */
.live-map-activity {
  padding: 0.25rem 0.75rem;
  font-size: 0.8125rem;
}

.live-map-activity-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.35rem 0;
}

.live-map-activity-item + .live-map-activity-item { border-top: 1px solid var(--bs-border-color); }

.live-map-activity-time {
  flex-shrink: 0;
  font-variant-numeric: tabular-nums;
  color: var(--ke-text-muted);
}

.live-map-activity-focus,
.live-map-activity-text {
  display: flex;
  flex-direction: column;
  width: 100%;
  min-width: 0;
  text-align: start;
  line-height: 1.25;
}

.live-map-activity-focus {
  padding: 0;
  border: 0;
  background: none;
  border-radius: 0.25rem;
}

.live-map-activity-focus > span,
.live-map-activity-text > span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.live-map-activity-focus:hover .fw-medium,
.live-map-activity-focus:focus-visible .fw-medium { color: var(--bs-link-color) !important; text-decoration: underline; }

/* Occurrences Map view: the list beside the map scrolls within its height */
@media (min-width: 992px) {
  .occurrence-map-list { max-height: 35rem; overflow-y: auto; }
}

/* --- Shift audit: the trail map sits beside the timeline on wide screens --- */
@media (min-width: 992px) {
  .audit-trail-map { position: sticky; top: calc(var(--ke-topbar-height) + 1rem); }
}

/* EN-0698: scan triage — the sheet preview beside the extracted rows (stacked on narrow screens, sticky on wide). */
.scan-preview-pane { height: min(75vh, 56rem); min-height: 20rem; }
@media (min-width: 1200px) {
  .scan-preview-sticky { position: sticky; top: calc(var(--ke-topbar-height) + 1rem); }
}

/* EN-0694: roster "Week N" badge leading the week row (board toolbar and the shared week bar). */
.board-week-number {
  display: inline-flex;
  align-items: center;
  margin-right: 0.3rem;
  padding: 0.25rem 0.75rem;
  border-radius: 999px;
  background: var(--ke-board-brand);
  color: #fff;
  font-size: 0.85rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
  letter-spacing: 0.02em;
  white-space: nowrap;
}
[data-bs-theme="dark"] .board-week-number { color: #0b1a2e; }
.board-week-label { font-size: 0.85rem; }
@media (max-width: 575.98px) {
  .board-week { flex-wrap: wrap; white-space: normal; row-gap: 0.4rem; }
}

/* EN-0703: field photo pickers (deployments/field/partials/_photo_inputs.html)
   and the ~96px photo thumbnails (_photo_thumbs.html). */
.field-photo-pickers {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr));
  gap: 0.5rem;
}
.field-photo-progress { width: 100%; height: 0.5rem; }
.field-photo-thumbs { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.field-photo-thumb {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 96px;
  height: 96px;
  overflow: hidden;
  border: 1px solid var(--bs-border-color);
  border-radius: var(--bs-border-radius);
  background: var(--bs-tertiary-bg);
  color: var(--bs-secondary-color);
  text-decoration: none;
}
.field-photo-thumb img { width: 100%; height: 100%; object-fit: cover; }

/* ── Work register Gantt (EN-0830, templates/jobs/work_register/gantt.html) ──
   One fixed-height line per stage header and row: a sticky label column and
   a track --gantt-days days wide at the scale's day width, so the chart
   scrolls sideways inside its card (never the page). Bars are placed by
   left / width percentages of the track; the overlay over the tracks holds
   the today line and the dependency arrows (SVG, redrawn in pixels by
   frontend/src/app/work-register-gantt.js). Colours come from Bootstrap
   variables, so dark mode follows. */
.work-register-gantt {
  --gantt-label-w: 14rem;
  --gantt-line-h: 2rem;
  --gantt-day-w: 0.75rem;
  max-width: 100%;
  min-width: 0;
  page: work-register-gantt;
}
.work-register-gantt.is-scale-day {
  --gantt-day-w: 1.75rem;
}
.work-register-gantt.is-scale-week {
  --gantt-col-days: 7;
}
.work-register-gantt-card {
  max-width: 100%;
  overflow: hidden;
}
.work-register-gantt-scroll {
  overflow-x: auto;
  max-width: 100%;
}
.work-register-gantt-grid {
  width: max-content;
  min-width: 100%;
}
.work-register-gantt-line {
  display: grid;
  grid-template-columns: var(--gantt-label-w) calc(var(--gantt-days) * var(--gantt-day-w));
  align-items: center;
  height: var(--gantt-line-h);
}
.work-register-gantt-line.is-head {
  height: 1.75rem;
  border-bottom: 1px solid var(--bs-border-color);
}
.work-register-gantt-line.is-stage {
  background-color: var(--bs-tertiary-bg);
}
.work-register-gantt-label {
  position: sticky;
  left: 0;
  z-index: 3;
  height: 100%;
  display: flex;
  align-items: center;
  min-width: 0;
  padding: 0 0.75rem;
  background-color: var(--bs-body-bg);
  border-right: 1px solid var(--bs-border-color);
}
.work-register-gantt-line.is-stage .work-register-gantt-label {
  background-color: var(--bs-tertiary-bg);
}
.work-register-gantt-label.text-truncate {
  display: block;
  line-height: var(--gantt-line-h);
}
.work-register-gantt-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  min-width: 0;
  text-align: left;
}
.work-register-gantt-toggle::before {
  content: "";
  width: 0.4rem;
  height: 0.4rem;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(45deg);
  transition: transform 0.15s ease;
}
.work-register-gantt-toggle[aria-expanded="false"]::before {
  transform: rotate(-45deg);
}
.work-register-gantt-track {
  position: relative;
  height: 100%;
  /* Day (or week) gridlines without a cell per day per row. */
  background-image: repeating-linear-gradient(
    to right,
    var(--bs-border-color-translucent) 0 1px,
    transparent 1px calc(var(--gantt-day-w) * var(--gantt-col-days, 1))
  );
}
.work-register-gantt-cols {
  display: grid;
  grid-template-columns: repeat(var(--gantt-cols), minmax(0, 1fr));
  background-image: none;
}
.work-register-gantt-col {
  overflow: hidden;
  white-space: nowrap;
  padding-left: 0.2rem;
  border-left: 1px solid var(--bs-border-color-translucent);
}
.work-register-gantt-col.is-current {
  background-color: var(--bs-primary-bg-subtle);
}
.work-register-gantt-col.is-weekend {
  background-color: var(--bs-tertiary-bg);
}
.work-register-gantt-body {
  position: relative;
}
.work-register-gantt-bar,
.work-register-gantt-summary {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  min-width: 0.4rem;
}
.work-register-gantt-bar {
  z-index: 1;
  height: 1.1rem;
  border-radius: 0.25rem;
}
button.work-register-gantt-bar {
  cursor: pointer;
}
/* Outlines are box-shadows: the global button:not(.btn) reset strips borders
   (and backgrounds — a bar's fill is a Bootstrap bg-* / text-bg-* class). */
.work-register-gantt-bar.is-not-started,
.work-register-gantt-swatch.is-not-started {
  background-color: var(--bs-secondary-bg);
  box-shadow: inset 0 0 0 1px var(--bs-border-color);
}
.work-register-gantt-bar.is-no-start {
  border-top-left-radius: 0;
  border-bottom-left-radius: 0;
}
.work-register-gantt-bar.is-no-start::before {
  content: "";
  position: absolute;
  top: -0.15rem;
  bottom: -0.15rem;
  left: 0;
  border-left: 2px dashed var(--bs-secondary-color);
}
.work-register-gantt-bar.is-milestone {
  width: auto !important;
  height: 0.85rem;
  aspect-ratio: 1;
  border-radius: 0.1rem;
  transform: translate(-50%, -50%) rotate(45deg);
  margin-left: calc(var(--gantt-day-w) / 2);
}
.work-register-gantt-bar.is-dragging {
  opacity: 0.8;
  outline: 2px solid var(--bs-primary);
  outline-offset: 1px;
}
@media (min-width: 992px) {
  [data-gantt-drag-url] {
    cursor: grab;
    touch-action: none;
  }
  [data-gantt-drag-url].is-dragging {
    cursor: grabbing;
  }
}
.work-register-gantt-handle {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 0.4rem;
  cursor: ew-resize;
}
.work-register-gantt-handle.is-start {
  left: 0;
}
.work-register-gantt-handle.is-end {
  right: 0;
}
@media (max-width: 991.98px) {
  .work-register-gantt-handle {
    display: none;
  }
}
.work-register-gantt-summary {
  height: 0.4rem;
  border-radius: 0.2rem;
  background-color: var(--bs-secondary-color);
  opacity: 0.6;
}
.work-register-gantt-note {
  position: absolute;
  bottom: 0;
  transform: translateX(-100%);
  padding-right: 0.25rem;
  white-space: nowrap;
  line-height: 1;
}
.work-register-gantt-actual,
.work-register-gantt-swatch.is-actual {
  background-color: var(--bs-success);
}
.work-register-gantt-actual {
  position: absolute;
  bottom: 0.1rem;
  height: 0.2rem;
  border-radius: 0.1rem;
  opacity: 0.85;
}
.work-register-gantt-swatch {
  display: inline-block;
  width: 0.85rem;
  height: 0.6rem;
  border-radius: 0.15rem;
}
.work-register-gantt-swatch.is-actual {
  height: 0.2rem;
}
.work-register-gantt-overlay {
  position: absolute;
  top: 0;
  bottom: 0;
  left: var(--gantt-label-w);
  width: calc(var(--gantt-days) * var(--gantt-day-w));
  z-index: 2;
  pointer-events: none;
}
.work-register-gantt-today {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 2px;
  margin-left: -1px;
  background-color: var(--bs-danger);
  opacity: 0.6;
}
.work-register-gantt-arrows {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
}
.work-register-gantt-arrow {
  fill: none;
  stroke: var(--bs-secondary-color);
  stroke-width: 1.25;
}
.work-register-gantt-arrow.is-violated {
  stroke: var(--bs-danger);
  stroke-width: 1.75;
}
.work-register-gantt-head {
  fill: var(--bs-secondary-color);
}
.work-register-gantt-head.is-violated {
  fill: var(--bs-danger);
}
@page work-register-gantt {
  size: A4 landscape;
}
@media print {
  .work-register-gantt-scroll {
    overflow: visible;
  }
  .work-register-gantt-bar,
  .work-register-gantt-summary,
  .work-register-gantt-actual,
  .work-register-gantt-today,
  .work-register-gantt-swatch,
  .work-register-gantt-line.is-stage,
  .work-register-gantt-col {
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
}
