/* ─── KAL Portal glue on the KAL Bright kit (KB1) ───────────────────────────
   Loaded LAST by layouts/main.ejs and overlay.ejs (after kal-bright.css,
   style.css, dark.css, theme-views.css, help.css), and by the standalone
   login / SSO pages.
   1. Shell: top bar, area tabs, centre switch, account menu, footer.
   2. Page header (views/partials/page-header.ejs) beyond the kit's kb-band.
   3. Style pass: the Portal's shared component classes (.btn, form fields,
      .data-table, cards, modals, .filter-tabs, pills, toasts, pagination)
      drawn the way the kit draws kb-btn / kb-field / kb-select / kb-table /
      dialog. This is the INTERIM look: each page is rebuilt on ui-sdk in its
      own wave later; never hand-tune a single page here.
   Colours, shadows and radii are kit tokens only (no hex). Layout sizes are
   the Portal's own. */

/* ui-sdk parts that are headings (a dialog title is an h2) keep ui-sdk's own look: the Portal's
   bare h2/h3/h4 rules (style.css) and the kit's heading reset are unlayered, so they would win.
   Same specificity as `h2`, loaded later; any class rule on the part still beats it. */
h1:where([data-slot]), h2:where([data-slot]), h3:where([data-slot]), h4:where([data-slot]) {
  margin: revert-layer; font-size: revert-layer; font-weight: revert-layer;
  letter-spacing: revert-layer; color: revert-layer; text-align: revert-layer;
}

/* ===================== 1. Shell ===================== */

:root {
  --kb-page-max: 1600px;
  /* Clock glyph for native time inputs (section 3); used as a mask, so only its shape counts. */
  --kb-icon-clock: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='12' cy='12' r='9'/%3E%3Cpath d='M12 7v5l3 2'/%3E%3C/svg%3E");
  /* DA2 Z2: ui-select's chevron (web.css --ui-icon-chevron: the same path, stroke 2, square caps),
     filled in the kit ink. A <select> cannot have a ::after to mask, so the glyph is a background
     image, and its colour has to be in the image: one per theme (= --kb-ink light / dark). */
  --kb-select-chevron: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%232B2520' stroke-width='2' stroke-linecap='square'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  /* DA3 K4: the kit's i-doc icon (partials/kb-icons.ejs) for the native file button, in --kb-ink. */
  --kb-file-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%232B2520' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M14 3H7a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V8z'/%3E%3Cpath d='M14 3v5h5'/%3E%3Cpath d='M9 13h6M9 17h4'/%3E%3C/svg%3E");
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) { --kb-select-chevron: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23F6EFE9' stroke-width='2' stroke-linecap='square'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    --kb-file-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23F6EFE9' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M14 3H7a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V8z'/%3E%3Cpath d='M14 3v5h5'/%3E%3Cpath d='M9 13h6M9 17h4'/%3E%3C/svg%3E"); }
}
[data-theme="dark"] { --kb-select-chevron: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23F6EFE9' stroke-width='2' stroke-linecap='square'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  --kb-file-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23F6EFE9' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M14 3H7a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V8z'/%3E%3Cpath d='M14 3v5h5'/%3E%3Cpath d='M9 13h6M9 17h4'/%3E%3C/svg%3E"); }


.kb-topbar-row { max-width: var(--kb-page-max); }
.kb-areas { max-width: var(--kb-page-max); }

/* Area tabs IN the top row when they fit (Chris 2026-11-14): brand | tabs | tools, the two
   side columns equal (1fr each) so the tabs sit in the true centre of the bar. When they do
   not fit (laptop with many sections, tablet, phone) the tabs drop to their own row under
   brand + tools. public/js/kb-shell.js::fitTopbar measures and sets .kb-one-line; without JS
   the bar stays two rows. */
.kb-topbar-row {
  display: grid; grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas: "brand tools" "tabs tabs";
  column-gap: var(--kb-sp-4); row-gap: var(--kb-sp-1h);
}
.kb-topbar-row > .kb-brand { grid-area: brand; justify-self: start; }
.kb-topbar-row > .kb-tools { grid-area: tools; justify-self: end; display: flex; align-items: center; gap: var(--kb-sp-2); }
.kb-topbar-row > .kb-areas { grid-area: tabs; min-width: 0; max-width: none; margin: 0 -8px; padding: 0 0 var(--kb-sp-half); }
.kb-topbar-row.kb-one-line { grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); grid-template-areas: "brand tabs tools"; }
.kb-topbar-row.kb-one-line > .kb-areas { margin: 0; padding: 0; }
/* Before ui-sdk upgrades the account menu, its items sit inline (the tools measured ~700px wide)
   and the bar jumped from two rows to one at ~1s. Never show that content un-upgraded. */
.kb-tools ui-menu-content:not(:defined) { display: none; }

/* ── First paint, before ui-sdk upgrades (FP1, 2026-11-18) ──
   web.js imports each component module only after the page is parsed, so for up to a few
   seconds every ui-* tag is a plain inline element: menus and select options spilled across
   the toolbar, the search box drew a box in a box with a grey X, and the page jumped when the
   kit arrived. These rules give the un-upgraded tags the kit's box, so the first paint has the
   final layout. `:not(:defined)` stops matching the moment the module loads; nothing here can
   touch an upgraded element. Same sizes as the kit rules they stand in for. */
:is(ui-select-content, ui-menu-content, ui-tooltip-content, ui-popover-content, ui-hover-card-content):not(:defined) { display: none; }
:is(ui-select, ui-select-trigger, ui-menu, ui-menu-trigger, ui-tooltip, ui-tooltip-trigger, ui-toolbar-button, ui-input, ui-input-clear, ui-tabs-tab, ui-collapsible-trigger):not(:defined) { display: contents; }
.kb-toolrow ui-toolbar:not(:defined) { display: flex; align-items: center; gap: var(--kb-sp-2); }
/* Search box: the bare input inside the kb-field edge, no clear button until there is text. */
.kb-field ui-input:not(:defined) > input {
  flex: 1 1 auto; min-width: 0; width: 100%; height: 100%; min-height: 0; padding: 0;
  border: 0; border-radius: 0; background: transparent; box-shadow: none; outline: none;
  color: var(--kb-ink); font-size: var(--kb-fs-lg); font-weight: 600;
}
.kb-field ui-input:not(:defined) > input::-webkit-search-cancel-button { display: none; }
.kb-field ui-input-clear:not(:defined) > button { display: none; }
/* Select trigger: the kit's box. The value text and the chevron arrive with the module. */
.kb-select:not(:defined) ui-select-trigger > button {
  display: inline-flex; align-items: center; justify-content: space-between; gap: var(--kb-sp-2);
  min-width: 200px; height: var(--kb-ctl-h); padding: 0 var(--kb-sp-3) 0 14px;
  border: 0; border-radius: var(--kb-radius-ctl);
  background: var(--kb-surface); color: var(--kb-ink);
  box-shadow: inset 0 0 0 1.5px var(--kb-edge);
  font: inherit; font-weight: 700; font-size: 14.5px;
}
/* DA3 K5: the chosen label waits in data-kb-first (partials/kb/select.ejs), drawn here until ui-sdk
   takes the part over (it sets data-slot). Text INSIDE <ui-select-value> made ui-sdk treat it as
   custom content and never update it: a pick or a value set from code kept the first label. */
ui-select-value[data-kb-first]:not([data-slot])::before { content: attr(data-kb-first); }
/* Phone: the same wrap rule as the upgraded toolbar (section 3, "Toolbar phone rule"). */
@media (max-width: 760px) {
  .kb-toolrow ui-toolbar:not(:defined) { flex: 1 1 100%; flex-wrap: wrap; min-width: 0; }
  .kb-toolrow .kb-select:not(:defined) ui-select-trigger > button { flex: 1 1 140px; min-width: 140px; max-width: 100%; width: auto; overflow: hidden; white-space: nowrap; }
}
/* Area tabs: one centred row, as after the upgrade. */
.kb-areas ui-tabs-list:not(:defined) { display: flex; gap: var(--kb-sp-half); padding: var(--kb-sp-half) var(--kb-sp-2); }
.kb-areas ui-tabs-list:not(:defined) > ui-tabs-tab:first-of-type > a { margin-inline-start: auto; }
.kb-areas ui-tabs-list:not(:defined) > ui-tabs-tab:last-of-type > a { margin-inline-end: auto; }
.kb-areas ui-tabs-indicator:not(:defined) { display: none; }
/* Group rows: a block with its totals at the right; a closed group shows no body, an open
   one has its chevron down. `default-open` is the attribute kb/group writes. */
ui-collapsible:not(:defined) { display: block; }
/* flow-root: the upgraded panel is overflow:hidden, so a child margin stays inside it. */
ui-collapsible-panel:not(:defined) { display: flow-root; }
ui-collapsible:not(:defined):not([default-open]) > ui-collapsible-panel { display: none; }
ui-collapsible[default-open]:not(:defined) > .kb-group-head .kb-chev .kb-ico,
ui-collapsible[default-open]:not(:defined) > .kb-subgroup-head .kb-subgroup-toggle > .kb-ico { rotate: 0deg; }
/* One line: Ask Assist is the round sparkle button (the phone look), so the sides stay narrow. */
.kb-one-line .kb-ask { width: 40px; padding: 0; }
.kb-one-line .kb-ask .kb-ask-word { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
/* The tab link's size before ui-sdk upgrades it (data-slot comes later), so the first
   fitTopbar measure matches the upgraded tab and the bar does not jump. Same box as the kit's
   [data-slot="tabs-tab"] rule. */
.kb-areas ui-tabs-tab > a {
  display: inline-flex; align-items: center; gap: var(--kb-sp-1h); height: 36px; padding: 0 14px;
  font-weight: 700; font-size: var(--kb-fs-md); white-space: nowrap; text-decoration: none;
}

/* The area tabs are links (each opens its section). The kit styles the tab
   part by data-slot; these keep a link looking like the kit's button tab. */
.kb-areas [data-slot="tabs-tab"] {
  display: inline-flex; align-items: center; gap: var(--kb-sp-1h);
  text-decoration: none; cursor: pointer;
}
.kb-areas [data-slot="tabs-list"] { scroll-padding-inline: 16px; }
/* Centred like the pick rows below (Chris 2026-11-14). Auto margins, not justify-content:
   they centre while the tabs fit and collapse to 0 when the list overflows, so a phone still
   scrolls from the first tab. ui-tabs-tab is display:contents, so the margin goes on its
   [data-slot="tabs-tab"] child. The indicator is absolute and ignores them. */
.kb-areas ui-tabs-tab:first-of-type > [data-slot="tabs-tab"] { margin-inline-start: auto; }
.kb-areas ui-tabs-tab:last-of-type > [data-slot="tabs-tab"] { margin-inline-end: auto; }
/* UF2 laptop sweep: from ~1000 to 1200 wide the most tabs (super admin, 10) needed 1111px in a
   992px row at 1024, so Settings sat off the end behind the fade and Users was cut. Tighter tabs
   here fit them all down to ~1000 wide (955px at 1024); narrower than that the row scrolls with
   the kit's fade, as on a tablet or phone. Padding only, so a tab's hover look is unchanged. */
@media (min-width: 761px) and (max-width: 1199px) {
  .kb-areas ui-tabs-tab > a, .kb-areas [data-slot="tabs-tab"] { padding-inline: var(--kb-sp-2); gap: var(--kb-sp-1); }
  .kb-areas [data-slot="tabs-list"] { padding-inline: var(--kb-sp-1); }
}
/* No indicator when the page belongs to no section (Assist, Help...). */
/* ui-tabs always selects a tab (the first, when default-value matches none), so a page in no
   section (Assist, Help, errors) carries data-no-section and shows every tab unselected. */
.kb-areas[data-no-section] [data-slot="tabs-indicator"] { display: none; }
.kb-areas[data-no-section] [data-slot="tabs-tab"][data-selected] { color: var(--kb-muted); }
.kb-areas[data-no-section] [data-slot="tabs-tab"][data-selected]:hover { color: var(--kb-ink); background: var(--kb-tone-wash); }
.kb-areas[data-no-section] [data-selected] .kb-dot { background: var(--kb-tone); opacity: 1; }
/* UF1: Home's tone is the pale neutral fill, which vanishes as a small dot; the kit draws an
   unselected neutral dot with --kb-neutral-dot, and an "unselected-looking" selected tab must too. */
.kb-areas[data-no-section] [data-tone="neutral"][data-selected] .kb-dot { background: var(--kb-neutral-dot); }

/* Area tab page panels (KB4, public/js/kb-area-drop.js): popovers placed under their tab by
   script. The kit's menu surface (ui-menu-content / menu-item in kal-bright.css), drawn on our
   own classes so ui-sdk's menu script never claims them. data-area on the panel gives it the
   section's wash; the current page gets the crumb menu's wash + dot. */
.kb-area-drop {
  display: none; position: fixed; inset: auto; margin: 0;
  min-inline-size: 220px; max-inline-size: min(340px, calc(100vw - 16px));
  max-block-size: var(--kb-drop-max-h, 70vh); overflow-y: auto; overscroll-behavior: contain;
  padding: var(--kb-sp-1h); border: 0; border-radius: var(--kb-radius-md);
  background: var(--kb-surface); color: var(--kb-ink);
  box-shadow: var(--kb-shadow-3); font-size: var(--kb-fs-md);
}
.kb-area-drop:is(:popover-open, .\:popover-open) { display: grid; gap: 1px; }
.kb-area-drop-item {
  display: flex; align-items: center; gap: var(--kb-sp-2h); min-block-size: 38px; padding: 0 var(--kb-sp-2h); border-radius: 10px;
  color: var(--kb-ink); font-weight: 600; text-decoration: none; white-space: nowrap;
}
.kb-area-drop-item:focus-visible { outline-offset: -2px; background: var(--kb-area-wash); }
.kb-area-drop-item:active { background: var(--kb-area-wash); }
.kb-area-drop-item[data-current] { background: var(--kb-area-wash); }
.kb-area-drop-item[data-current]::after { content: ""; inline-size: 8px; block-size: 8px; margin-inline-start: auto; border-radius: 50%; background: var(--kb-area); flex: none; }
@media (hover: hover) and (pointer: fine) {
  .kb-area-drop-item:hover { background: var(--kb-area-wash); }
}
@media (prefers-reduced-motion: no-preference) {
  .kb-area-drop:not([data-instant]) {
    transform-origin: top left;
    transition: opacity 160ms var(--kb-ease), scale 220ms var(--kb-spring);
  }
  @starting-style {
    .kb-area-drop:not([data-instant]):is(:popover-open, .\:popover-open) { opacity: 0; scale: 0.96; }
  }
}

/* Pick rows (KB6): every one-click choice row (centres in the top bar, partials/centre-bar.ejs; year
   and month on Home, views/pages/dashboard.ejs) is ONE family: same pill, gap, hover, press and
   selected fill. Selected = filled: neutral ink (ink on light, light on dark); a centre fills with
   its brand colour (brand-kit.css [data-brand]; ALL has none, so it fills like a year). Unselected
   pills are calm text; a centre shows only a small brand dot and tints its own colour on hover.
   Each row is centred in its space; once it is wider than the screen the auto margins on its first
   and last pill collapse to 0, so it scrolls sideways inside itself from the left edge (the
   `safe center` result, in every browser that has flexbox). */
@property --kb-pick-fade-start { syntax: "<length>"; inherits: false; initial-value: 0px; }
@property --kb-pick-fade-end { syntax: "<length>"; inherits: false; initial-value: 0px; }
/* 40px: at 24px the fade fell in the gap after a pill, so a cut row (390: ends after DOO) read as
   complete. 40px always reaches into the next pill, so the row visibly runs on (UF1 SH2 / K note). */
@keyframes kb-pick-edges {
  from { --kb-pick-fade-start: 0px; --kb-pick-fade-end: 40px; }
  10%, 90% { --kb-pick-fade-start: 40px; --kb-pick-fade-end: 40px; }
  to { --kb-pick-fade-start: 40px; --kb-pick-fade-end: 0px; }
}
.kb-pick-row {
  /* relative: the selected pill's offsetLeft is measured from the row (dashboard-home.js). */
  position: relative; display: flex; gap: var(--kb-sp-1); min-inline-size: 0; max-inline-size: 100%;
  padding: 3px var(--kb-sp-1); /* room for the focus ring inside the scroller */
  overflow-x: auto; overscroll-behavior-x: contain; scrollbar-width: none; scroll-padding-inline: 40px;
  /* Fade only the side that still has pills to scroll to. No fallback: without scroll timelines
     the row simply scrolls without the fade. A mask reads only alpha, so any opaque token works. */
  animation: kb-pick-edges linear;
  animation-timeline: scroll(self inline);
  /* The edge keeps 30% so the cut pill still shows as a ghost, not a blank that reads as the end. */
  --kb-pick-ghost: color-mix(in oklch, var(--kb-ink) 30%, transparent);
  mask-image: linear-gradient(to right, var(--kb-pick-ghost), var(--kb-ink) var(--kb-pick-fade-start), var(--kb-ink) calc(100% - var(--kb-pick-fade-end)), var(--kb-pick-ghost));
}
.kb-pick-row::-webkit-scrollbar { display: none; }
.kb-pick-row > :first-child { margin-inline-start: auto; }
.kb-pick-row > :last-child { margin-inline-end: auto; }
.kb-pick {
  --kb-pick-tint: var(--kb-ink);
  display: inline-flex; align-items: center; justify-content: center; gap: var(--kb-sp-1h); flex: none;
  min-inline-size: 48px; block-size: 34px; padding: 0 13px; border-radius: var(--kb-radius-pill);
  background: transparent; color: var(--kb-muted);
  font-size: var(--kb-fs-md); font-weight: 700; letter-spacing: 0.01em; line-height: 1;
  font-variant-numeric: tabular-nums; white-space: nowrap; text-decoration: none;
}
.kb-pick[data-brand] { --kb-pick-tint: var(--kb-centre, var(--kb-ink)); }
.kb-pick-dot { flex: none; inline-size: 7px; block-size: 7px; border-radius: 50%; background: var(--kb-pick-tint); }
.kb-pick:focus-visible { outline: 3px solid var(--kb-coral-text); outline-offset: 2px; }
.kb-pick:active { background: color-mix(in oklch, var(--kb-pick-tint) 18%, transparent); color: var(--kb-ink); scale: 0.96; }
.kb-pick[aria-current] {
  background: var(--kb-ink); color: var(--kb-surface);
  /* A quiet edge so a dark brand fill still reads on the dark bar; invisible on the ink fill. */
  box-shadow: inset 0 0 0 1px color-mix(in oklch, var(--kb-ink) 14%, transparent);
}
.kb-pick[data-brand][aria-current] { background: var(--brand-primary, var(--kb-ink)); color: var(--brand-on-primary, var(--kb-surface)); }
.kb-pick[aria-current] .kb-pick-dot { background: currentColor; opacity: 0.75; }
.kb-pick[aria-current]:focus-visible { outline-color: var(--kb-coral-text); outline-offset: 2px; }
@media (hover: hover) and (pointer: fine) {
  .kb-pick:not([aria-current]):hover { background: color-mix(in oklch, var(--kb-pick-tint) 11%, transparent); color: var(--kb-ink); }
}
@media (prefers-reduced-motion: no-preference) {
  .kb-pick { transition: scale 160ms var(--kb-ease), background-color var(--kb-dur-fast) var(--kb-ease), color var(--kb-dur-fast) var(--kb-ease); }
}

/* Centre row: the top bar's last row, centred in the page width. */
.kb-topbar .centre-bar { max-inline-size: var(--kb-page-max); margin: 0 auto; padding: 0 var(--kb-sp-5) 7px; }

/* Compact bar on scroll (TB1, Chris 2026-11-16; public/js/kb-shell.js "Compact bar"). Scrolled down,
   [data-compact] shows only the top row. The bar keeps its full height in the flow (height locked to
   --kb-topbar-full, measured expanded) and CLIPS below the row (--kb-topbar-cut), so nothing on the
   page moves. Clipped rows stay in the tab order (focus brings them back) and let clicks through;
   the tab panels and menus are popovers in the top layer, so the clip never cuts them. The centre row
   is pinned to the bar's bottom so it stays put while the clip edge passes over it.
   Layouts: 'centred' = the one-line row as is; 'line' = brand | tabs | tools (tabs fade in);
   'bare' = brand + tools, the tab row stays clipped. --kb-topbar-h (on <html>) = the visible height. */
.kb-topbar { clip-path: inset(0 0 -1px 0); } /* -1px: the bar's bottom line (box-shadow) stays visible */
.kb-topbar[data-compact] {
  block-size: var(--kb-topbar-full);
  clip-path: inset(0 0 calc(100% - var(--kb-topbar-cut) - 1px) 0);
}
.kb-topbar[data-compact] > .centre-bar { position: absolute; inset-inline: 0; inset-block-end: 0; }
/* The compact bar's bottom line, on the clip edge. */
.kb-topbar::after {
  content: ""; position: absolute; inset: 0 0 auto; block-size: 1px; background: var(--kb-line);
  translate: 0 var(--kb-topbar-full, 0px); opacity: 0; pointer-events: none;
}
.kb-topbar[data-compact]::after { translate: 0 var(--kb-topbar-cut); opacity: 1; }
.kb-topbar[data-compact="line"] .kb-topbar-row {
  grid-template-columns: auto minmax(0, 1fr) auto; grid-template-areas: "brand tabs tools";
}
.kb-topbar[data-compact="line"] .kb-topbar-row > .kb-areas { margin: 0; padding: 0; }
.kb-topbar[data-compact="line"] .kb-ask { width: 40px; padding: 0; }
.kb-topbar[data-compact="line"] .kb-ask .kb-ask-word { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
@keyframes kb-topbar-tabs-in { from { opacity: 0; } }
@media (prefers-reduced-motion: no-preference) {
  .kb-topbar:not([data-instant]) { transition: clip-path 160ms var(--kb-ease); }
  .kb-topbar:not([data-instant])::after { transition: translate 160ms var(--kb-ease), opacity 160ms var(--kb-ease); }
  .kb-topbar[data-tabs-moved] .kb-areas { animation: kb-topbar-tabs-in 160ms var(--kb-ease); }
}
/* The selected centre in the compact bar: one 40px control like the rest of the bar, the code chip's
   fixed width, filled like the selected centre pill. Click = back to the top with the centre row. */
.kb-centre-chip {
  display: none; place-items: center; flex: none; inline-size: 56px; block-size: 40px; padding: 0; margin: 0;
  border: 0; border-radius: var(--kb-radius-pill); appearance: none; cursor: pointer;
  background: var(--brand-primary, var(--kb-ink)); color: var(--brand-on-primary, var(--kb-surface));
  box-shadow: inset 0 0 0 1px color-mix(in oklch, var(--kb-ink) 14%, transparent);
  font: inherit; font-size: var(--kb-fs-md); font-weight: 800; letter-spacing: 0.04em; line-height: 1;
  transition: box-shadow var(--kb-dur-fast) var(--kb-ease);
}
.kb-topbar[data-compact] .kb-centre-chip:not([hidden]) { display: inline-grid; }
.kb-centre-chip:focus-visible { outline: 3px solid var(--kb-coral-text); outline-offset: 2px; }
@media (hover: hover) and (pointer: fine) {
  .kb-centre-chip:hover { box-shadow: inset 0 0 0 1px color-mix(in oklch, var(--kb-ink) 14%, transparent), 0 0 0 3px color-mix(in oklch, var(--kb-centre, var(--kb-ink)) 28%, transparent); }
}

/* Ask Assist: the pressed state on /assist. */
.kb-ask.is-current { background: var(--kb-coral-hover); box-shadow: inset 0 2px 4px color-mix(in srgb, var(--kb-ink) 22%, transparent); transform: none; }

/* Help "?" (partials/help-button.ejs; help.css draws the old disc): the kit's ghost icon button. */
.kb-topbar .help-btn {
  display: inline-grid; place-items: center; flex: none;
  width: 40px; height: 40px; padding: 0; margin: 0; /* UF1: every top-bar control is 40px */
  border: 0; border-radius: var(--kb-radius-ctl);
  background: transparent; color: var(--kb-ink); box-shadow: none;
  cursor: pointer;
  transition: background-color var(--kb-dur-fast) var(--kb-ease);
}
/* D-a (UF1): hover is colour only, nothing moves. */
.kb-topbar .help-btn:hover { background: var(--kb-surface-2); }
.kb-topbar .help-btn svg { width: 20px; height: 20px; }
.kb-topbar .help-btn[aria-expanded="true"] { background: var(--kb-area-wash); box-shadow: inset 0 0 0 2px var(--kb-area-ink); }

/* One shape for the right-hand top-bar buttons (theme, Ask Assist, "?", avatar): 40px round,
   like the avatar. Theme and "?" get the same soft filled disc so they read as buttons, not
   loose icons (matches KAL ServiceDesk's header). Ask Assist keeps its coral; with its word
   showing it is a 40px pill. Hover is colour only. */
.kb-topbar :is(.kb-theme-toggle, .help-btn, .kb-ask) { border-radius: var(--kb-radius-pill); }
.kb-topbar :is(.kb-theme-toggle, .help-btn) { background: var(--kb-surface-2); box-shadow: inset 0 0 0 1px var(--kb-line); }
.kb-topbar :is(.kb-theme-toggle, .help-btn):hover { background: var(--kb-surface-3); }

/* Account menu: links as menu rows. */
[data-slot="menu-item"] > a, a[data-slot="menu-item"] { display: flex; align-items: center; gap: var(--kb-sp-2h); color: var(--kb-ink); text-decoration: none; }
/* A <button> menu row (What's new, layouts/main.ejs) drops the browser's ButtonFace fill and
   outset border so it draws exactly like the link rows (UF1 SH1). Zero-specificity background so
   the kit's [data-highlighted] / [data-current] wash still wins. */
[data-slot="menu-item"] > button, button[data-slot="menu-item"] {
  appearance: none; display: flex; align-items: center; gap: var(--kb-sp-2h); inline-size: 100%;
  margin: 0; border: 0; color: var(--kb-ink); font: inherit; font-weight: 600; text-align: start; cursor: pointer;
}
:where([data-slot="menu-item"] > button, button[data-slot="menu-item"]) { background: transparent; }
[data-slot="menu-item"] > button { padding: 0; }
#kb-user-menu [data-slot="menu-group-label"] { max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Banners above the bar keep their place; the bar sticks under them. */
.impersonation-banner, .sysalert-bar { position: relative; z-index: 21; }

/* Page loader: the kit canvas. */
.page-loader { background: var(--kb-canvas); }

/* Footer: quiet, no rule. */
.footer { border-top: 0; margin-top: var(--kb-sp-2); padding: var(--kb-sp-6); }
.footer-logo { opacity: 0.5; }

@media (max-width: 760px) {
  .kb-topbar-row { gap: var(--kb-sp-1h); }
  .kb-topbar .kb-theme-toggle { width: 40px; height: 40px; }
  /* The centre row runs to the screen edges (its own 16px inset instead of the bar's), so the next
     pill shows as a faded dot + letter at the right edge. Inside the bar's inset the cut fell on that
     pill's empty padding and the row read as complete (UF1 SH2). */
  .kb-topbar .centre-bar { padding: 0 0 5px; }
  .kb-topbar .kb-centre-row { padding-inline: var(--kb-sp-4); }
}

/* ===================== 2. Page header ===================== */

/* D-d (UF1): ONE header pattern on every page. Crumb (or Back crumb), title, one meta line, then
   the stat tiles under them (lined up with the title, not the icon tile), actions top right.
   partials/page-header.ejs renders .kb-band-main, .kb-band-actions, .kb-stats as band children. */
.kb-band { margin: 0 0 var(--kb-sp-5); text-align: left; grid-template-columns: minmax(0, 1fr) auto; align-items: start; row-gap: var(--kb-sp-5); }
.kb-band > .kb-band-main { grid-column: 1; }
.kb-band > .kb-band-actions { grid-column: 2; grid-row: 1; }
.kb-band > .kb-stats { grid-column: 1 / -1; margin-inline-start: 84px; } /* 64px tile + 20px gap */
.kb-band-text { flex: 1; min-width: 0; }
.kb-title { overflow-wrap: anywhere; }
/* The crumb is a block of its own height: <ui-menu> is inline, so its 28px button hung ~5px below
   the 18px line box into the title's box (UF1 PPL-36 overlap). fit-content keeps hover tight.
   The 48px title's glyph box (font ascent) also reaches ~9px above its 1.02 line box, so the crumb
   keeps 10px clear of it; the eye sees about 20px between the crumb text and the title's caps. */
.kb-band-text > .kb-crumb { display: flex; inline-size: fit-content; margin-block-end: var(--kb-sp-2); }
.kb-crumb--plain { margin: 0 0 var(--kb-sp-half); color: var(--kb-area-ink); font-weight: 800; font-size: var(--kb-fs-md); }
/* Back as the crumb: a link that sits where the crumb menu button sits, same size. */
.kb-crumb--back {
  display: inline-flex; align-items: center; gap: var(--kb-sp-1); block-size: 28px; margin: 0 0 var(--kb-sp-half) -8px; padding: 0 var(--kb-sp-2);
  border-radius: var(--kb-radius-sm); color: var(--kb-area-ink); font-weight: 800; font-size: var(--kb-fs-md); text-decoration: none;
}
.kb-crumb--back .kb-ico { inline-size: 15px; block-size: 15px; rotate: 90deg; }
.kb-crumb--back:focus-visible { outline: 3px solid var(--kb-coral-text); outline-offset: 2px; }
@media (hover: hover) and (pointer: fine) {
  .kb-crumb--back:hover { background: color-mix(in srgb, var(--kb-area) 30%, transparent); }
}
.kb-band-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; align-items: center; gap: var(--kb-sp-2); min-width: 0; }
.kb-context:empty { display: none; }
/* Context-line buttons and links in the band */
.kb-context .btn { min-height: 34px; padding: 0 var(--kb-sp-3); font-size: 13.5px; background: var(--kb-glass); }
.kb-context a:not(.btn):not(.kb-btn) { color: var(--kb-area-ink); font-weight: 700; text-decoration: underline; text-underline-offset: 2px; }
/* The meta line's one pill: a record count, a meta-pill, a kb-tag or a kb-status all draw the same
   pill, the one chip size (24px, DA2 M12). */
.kb-context :is(.meta-pill, .kb-tag, .kb-status) {
  margin: 0; block-size: 24px; padding: 0 var(--kb-sp-2h); border-radius: var(--kb-radius-pill);
  font-size: 12.5px; font-weight: 700; letter-spacing: 0;
}
/* A record count ("12 records", debts / banking / petty cash; page JS rewrites its text) is plain
   context text like the rest of the meta line, not a pill (DA2, FIN request). */
.kb-band .record-count {
  display: inline; margin: 0; block-size: auto; padding: 0; border: 0; border-radius: 0;
  background: none; box-shadow: none; color: var(--kb-muted); font-size: inherit; font-weight: 600; letter-spacing: 0;
}
.kb-band .record-count::before { content: none; }
/* A heading for a part of a page (never a second band). */
.kb-section-title { margin: 28px 0 var(--kb-sp-3); color: var(--kb-ink); font-size: var(--kb-fs-2xl); font-weight: 800; letter-spacing: -0.01em; text-align: left; }
/* Inside the overlay iframe: a compact band (the dialog already frames it). */
.overlay-frame-body .kb-band { padding: var(--kb-sp-4) var(--kb-sp-5); margin-bottom: var(--kb-sp-4); }
.overlay-frame-body .kb-band-blob, .overlay-frame-body .kb-crumb { display: none; }
.overlay-frame-body .kb-title { font-size: 26px; }
/* DA2 X9: with the crumb hidden the title is one line, so it centres on the icon tile (the kit
   aligns the text to the tile's top for the crumb + title pair). */
.overlay-frame-body .kb-band-main { align-items: center; }
@media (max-width: 900px) {
  .kb-band { grid-template-columns: minmax(0, 1fr); }
  .kb-band > .kb-band-actions { grid-column: 1; grid-row: auto; justify-content: flex-start; }
  .kb-band > .kb-stats { margin-inline-start: 0; }
}
@media (max-width: 760px) {
  .kb-title { font-size: 32px; }
}

/* ===================== 3. Style pass: shared Portal classes ===================== */

/* ── Buttons (= kb-btn; D-c, UF1) ──
   The legacy family renders as the kit's: .btn = kb-btn (42px), .btn-sm = kb-btn-sm (32px) except
   in a toolbar / form row, where every control is 42px (D-b); .btn-icon / .btn-dark = kb-icon-btn.
   Hover and press are colour only, like the kit (D-a; DA2 B2/H5: the press no longer shrinks).
   Markup moves to kb-btn when a view is touched. */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  box-sizing: border-box; min-height: var(--kb-ctl-h); padding: 0 var(--kb-sp-4); gap: var(--kb-sp-2);
  border: 0; border-radius: var(--kb-radius-ctl);
  background: var(--kb-surface); color: var(--kb-ink);
  box-shadow: inset 0 0 0 1.5px var(--kb-edge);
  font-family: inherit; font-weight: 700; font-size: 14.5px; letter-spacing: 0; line-height: 1.2;
  text-decoration: none; white-space: nowrap; cursor: pointer; filter: none;
  transition: box-shadow var(--kb-dur-fast) var(--kb-ease), background-color var(--kb-dur-fast) var(--kb-ease), color var(--kb-dur-fast) var(--kb-ease);
}
.btn:hover { background: var(--kb-surface-2); color: var(--kb-ink); border-color: transparent; }
/* Press = the kit's: a darker fill, nothing moves (kal-bright.css .kb-btn:active). */
.btn:active:not(:disabled):not(.btn-primary):not(.btn-success):not(.btn-icon):not(.btn-dark) { background: var(--kb-surface-3); }
/* Icons: 17px in a button (= .kb-btn .kb-ico), 16px in an icon button (= .kb-icon-btn .kb-ico). */
.btn > svg, .btn .kb-ico { flex: none; inline-size: 17px; block-size: 17px; }
.btn-sm { min-height: var(--kb-ctl-h-sm); padding: 0 var(--kb-sp-3); font-size: var(--kb-fs-base); }
/* DA3 K10: + the centre-notes action-item row and the compose "Ask" row (42px inputs beside them). */
:is(.kb-toolrow, .table-tools-bar, .filter-bar, .page-toolbar, .form-actions, .kb-band-actions, .centre-note-action-item-row, .cn-compose-ask-row) .btn:not(.btn-icon) { min-height: var(--kb-ctl-h); padding: 0 var(--kb-sp-4); font-size: 14.5px; }
.btn-block { width: 100%; }
/* Icon button and the old dark "View" eye = kb-icon-btn: tone wash, filled with the tone on hover.
   Before the colour variants, so .btn-icon.btn-primary / .btn-danger-outline keep their colour. */
.btn-icon { width: 32px; height: var(--kb-ctl-h-sm); min-height: 0; padding: 0; border-radius: 10px; }
.btn-icon > svg, .btn-icon .kb-ico, .btn-dark > svg, .btn-dark .kb-ico { inline-size: 16px; block-size: 16px; }
.btn-icon, .btn-dark {
  background: var(--kb-tone-wash, var(--kb-surface-2)); color: var(--kb-tone-text, var(--kb-ink)); box-shadow: none;
}
.btn-icon:hover, .btn-dark:hover, .btn-dark:focus-visible { background: var(--kb-tone, var(--kb-neutral-fill)); color: var(--kb-primary-ink); box-shadow: none; }
.btn-primary { background: var(--kb-coral); color: var(--kb-primary-ink); box-shadow: var(--kb-shadow-fill); }
.btn-primary:hover { background: var(--kb-coral-hover); color: var(--kb-primary-ink); }
.btn-success { background: var(--kb-leaf); color: var(--kb-primary-ink); box-shadow: none; }
.btn-success:hover { background: color-mix(in srgb, var(--kb-leaf) 88%, var(--kb-surface)); color: var(--kb-primary-ink); }
/* Danger = .kb-btn-danger: the surface with a coral edge and coral text; hover is the plain button's. */
.btn-danger-outline, .btn-danger { background: var(--kb-surface); color: var(--kb-coral-text); box-shadow: inset 0 0 0 1.5px var(--kb-coral-text); }
.btn-danger-outline:hover, .btn-danger:hover { background: var(--kb-surface-2); color: var(--kb-coral-text); }
.btn-ghost, .btn-link { background: transparent; box-shadow: none; }
.btn-ghost:hover, .btn-link:hover { background: var(--kb-surface-2); }
.btn-icon.is-open, .btn-dark.is-open, .btn-dark[aria-expanded="true"] { background: var(--kb-area); color: var(--kb-primary-ink); box-shadow: none; }
/* Disabled = the kit's: every variant keeps its own colours at half strength, not-allowed cursor; hover
   and press change nothing (style.css's greyscale filter is cleared on .btn above). */
/* style.css's .btn:disabled (same weight, loaded earlier) drops the edge and greys the fill: undone here. */
.btn:is(:disabled, [disabled], [aria-disabled="true"]) { opacity: 0.5; cursor: not-allowed; filter: none; box-shadow: inset 0 0 0 1.5px var(--kb-edge); }
.btn-primary:is(:disabled, [disabled], [aria-disabled="true"]) { box-shadow: var(--kb-shadow-fill); }
:is(.btn-danger-outline, .btn-danger):is(:disabled, [disabled], [aria-disabled="true"]) { box-shadow: inset 0 0 0 1.5px var(--kb-coral-text); }
:is(.btn-success, .btn-ghost, .btn-link, .btn-icon, .btn-dark):is(:disabled, [disabled], [aria-disabled="true"]) { box-shadow: none; }
.btn:is(:disabled, [disabled], [aria-disabled="true"]):is(:hover, :active) { background: var(--kb-surface); color: var(--kb-ink); }
.btn-primary:is(:disabled, [disabled], [aria-disabled="true"]):is(:hover, :active) { background: var(--kb-coral); color: var(--kb-primary-ink); }
.btn-success:is(:disabled, [disabled], [aria-disabled="true"]):is(:hover, :active) { background: var(--kb-leaf); color: var(--kb-primary-ink); }
:is(.btn-danger-outline, .btn-danger):is(:disabled, [disabled], [aria-disabled="true"]):is(:hover, :active) { background: var(--kb-surface); color: var(--kb-coral-text); }
:is(.btn-ghost, .btn-link):is(:disabled, [disabled], [aria-disabled="true"]):is(:hover, :active) { background: transparent; }
:is(.btn-icon, .btn-dark):is(:disabled, [disabled], [aria-disabled="true"]):is(:hover, :active) { background: var(--kb-tone-wash, var(--kb-surface-2)); color: var(--kb-tone-text, var(--kb-ink)); }
.btn:focus-visible { outline: 3px solid var(--kb-coral-text); outline-offset: 2px; }

/* ── Form fields (= kb-field / kb-select) ── */
:where(input:not([type]), input[type="text"], input[type="search"], input[type="email"], input[type="password"], input[type="number"], input[type="tel"], input[type="url"], input[type="date"], input[type="datetime-local"], input[type="month"], input[type="time"], input[type="week"], select, textarea):not([data-slot]) {
  box-sizing: border-box; min-height: var(--kb-ctl-h); padding: var(--kb-sp-2) var(--kb-sp-3);
  border: 0; border-radius: var(--kb-radius-ctl);
  background-color: var(--kb-surface); color: var(--kb-ink);
  box-shadow: inset 0 0 0 1.5px var(--kb-edge);
  font: inherit; font-size: 14.5px; font-weight: 600;
  transition: box-shadow var(--kb-dur-fast) var(--kb-ease), background-color var(--kb-dur-fast) var(--kb-ease);
}
:where(textarea):not([data-slot]) { line-height: 1.5; min-height: 84px; }
:where(input, select, textarea):not([data-slot])::placeholder { color: var(--kb-muted); font-weight: 400; opacity: 1; }
:where(input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="file"]), select, textarea):not([data-slot]):focus,
:where(input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="file"]), select, textarea):not([data-slot]):focus-visible {
  /* DA3 K3 (D2): focus = the one ring OUTSIDE the box (3px coral, 2px off). The box keeps its own
     edge (normal, or the red error edge), so in a still picture focus and error never look alike. */
  outline: 3px solid var(--kb-coral-text); outline-offset: 2px;
}
:where(input, select, textarea):not([data-slot]):disabled { background-color: var(--kb-surface-2); color: var(--kb-muted); box-shadow: inset 0 0 0 1.5px var(--kb-edge-quiet); cursor: not-allowed; }
:where(input, select, textarea):not([data-slot])[readonly] { background-color: var(--kb-surface-2); }
/* The .form-group rules in style.css draw a 1px border; the kit draws an inset edge instead. */
.form-group input, .form-group select, .form-group textarea,
.cn-action-item-text, .cn-transcript-editable { border: 0; border-radius: var(--kb-radius-ctl); background-color: var(--kb-surface); color: var(--kb-ink); box-shadow: inset 0 0 0 1.5px var(--kb-edge); }
.form-group :is(input:not([type="checkbox"]):not([type="radio"]), select, textarea):not([data-slot]):focus,
.cn-action-item-text:focus, .cn-transcript-editable:focus { border: 0; outline: 3px solid var(--kb-coral-text); outline-offset: 2px; }
/* The red error edge on a .form-group field (list-live.js .has-error) or an aria-invalid one, with
   the weight to beat the edge above, focused or not. */
.form-group.has-error :is(input:not([type="checkbox"]):not([type="radio"]):not([type="file"]), select, textarea):not([data-slot]),
.form-group :is(input, select, textarea):not([data-slot])[aria-invalid="true"] { box-shadow: inset 0 0 0 2px var(--kb-coral-text); background-color: var(--kb-surface); }
/* A kit field (ui-input-group.kb-field) inside a .form-group draws the edge and the focus ring on
   the GROUP; the input in it must not draw a second edge 12px inside it (the two rules above and
   style.css's focus ring did: doubled boxes in the staff list Add row and the training Email
   Subject, UF states fault 3). */
.form-group .kb-field [data-slot="input"],
.form-group .kb-field [data-slot="input"]:focus { border-radius: 0; box-shadow: none; }
/* DA3 X1 (D2): one ring only. An <input> inside a kit field never draws its own outline or edge
   (the .form-group :focus rule above did, a second ring inside the group's); the group draws it. */
:root .kb-field input:not(#kb-x):is(:focus, :focus-visible) { outline: 0; box-shadow: none; }
/* A tick box inside a .form-group: style.css's `.form-group input` padding and radius turned it
   into a 27x20 empty oval (UF1 G7 / FIN-10). Back to the kit's 20px box. */
.form-group input:is([type="checkbox"], [type="radio"]) {
  inline-size: 20px; block-size: 20px; min-height: 0; padding: 0; margin: 0;
  border-radius: 6px; box-shadow: inset 0 0 0 2px var(--kb-edge);
}
.form-group input[type="radio"] { border-radius: 50%; }
.form-group input:is([type="checkbox"], [type="radio"]):checked { box-shadow: inset 0 0 0 2px var(--kb-coral); }

/* Select (D-c, UF1): ONE look for a plain <select> and the kit's ui-select: the same chevron
   (--kb-select-chevron, one per theme in :root). `.hr-native-select` draws its own mask chevron
   (hr-kb.css), so it is left out here or it showed two carets (HR-07). */
:where(select):not([data-slot]):not([multiple]):not([size]):not(.hr-native-select) {
  appearance: none; -webkit-appearance: none;
  padding-left: 14px; padding-right: 36px; cursor: pointer;
  /* DA2 X5/Z2: the SAME glyph as ui-select's trigger: its chevron image in a 16px box, 12px from the
     right edge (the trigger's padding), and the trigger's 14.5px / 700 text and 14px left padding,
     so a plain select and a ui-select side by side read as one control. */
  font-size: 14.5px; font-weight: 700;
  background-image: var(--kb-select-chevron);
  background-position: right var(--kb-sp-3) center;
  background-size: var(--kb-sp-4) var(--kb-sp-4);
  background-repeat: no-repeat;
}
:where(select):not([data-slot]):not([multiple]):not([size]):hover { background-color: var(--kb-surface-2); }
:where(select[multiple], select[size]):not([data-slot]) { padding: var(--kb-sp-1h); }

/* Checkbox and radio (= the kit's checkbox): drawn here, no browser default. */
:where(input[type="checkbox"], input[type="radio"]):not([data-slot]) {
  appearance: none; -webkit-appearance: none;
  display: inline-grid; place-content: center; flex: none;
  width: 20px; height: 20px; min-height: 0; margin: 0; padding: 0;
  border: 0; border-radius: 6px;
  background: var(--kb-surface); color: var(--kb-primary-ink);
  box-shadow: inset 0 0 0 2px var(--kb-edge);
  vertical-align: -4px; cursor: pointer;
  transition: background-color 120ms var(--kb-ease), box-shadow 120ms var(--kb-ease);
}
:where(input[type="radio"]):not([data-slot]) { border-radius: 50%; }
/* D-a (UF1 FIN-03 / PPL-16): hover darkens the edge only; the box never grows. */
:where(input[type="checkbox"], input[type="radio"]):not([data-slot]):hover:not(:disabled):not(:checked) { box-shadow: inset 0 0 0 2px var(--kb-ink); }
:where(input[type="checkbox"], input[type="radio"]):not([data-slot]):checked,
:where(input[type="checkbox"]):not([data-slot]):indeterminate { background: var(--kb-coral); box-shadow: inset 0 0 0 2px var(--kb-coral); }
:where(input[type="checkbox"]):not([data-slot])::before {
  content: ""; width: 12px; height: 12px;
  background: currentColor;
  clip-path: polygon(14% 44%, 0 59%, 40% 96%, 100% 22%, 86% 8%, 39% 66%);
  transform: scale(0); transition: transform 160ms var(--kb-spring);
}
:where(input[type="checkbox"]):not([data-slot]):checked::before { transform: scale(1); }
:where(input[type="checkbox"]):not([data-slot]):indeterminate::before { clip-path: inset(40% 10%); transform: scale(1); }
:where(input[type="radio"]):not([data-slot])::before {
  content: ""; width: 8px; height: 8px; border-radius: 50%;
  background: currentColor; transform: scale(0); transition: transform 160ms var(--kb-spring);
}
:where(input[type="radio"]):not([data-slot]):checked::before { transform: scale(1); }
:where(input[type="checkbox"], input[type="radio"]):not([data-slot]):disabled { background: var(--kb-surface-2); box-shadow: inset 0 0 0 2px var(--kb-edge-quiet); cursor: not-allowed; }
:where(input[type="checkbox"], input[type="radio"]):not([data-slot]):focus-visible { outline: 3px solid var(--kb-coral-text); outline-offset: 2px; }

/* Date and time fields (D-g, UF1 FIN-09 / HR-06 / PPL-17): one 42px box like every input, and
   the browser's calendar / clock glyph swapped for the kit's thin calendar icon (a mask in the
   muted ink, so it follows the theme). The picker still opens on click. */
:where(input[type="date"], input[type="datetime-local"], input[type="month"], input[type="time"], input[type="week"]):not([data-slot]) {
  /* DA3 K8: line-height 1 cut the descenders of the empty "dd/mm/yyyy" cue (it read "vvvv");
     a normal line box still centres in the 42px box. */
  block-size: 42px; min-height: var(--kb-ctl-h); padding-block: 0; line-height: normal;
}
:where(input[type="date"], input[type="datetime-local"], input[type="month"], input[type="week"]):not([data-slot])::-webkit-calendar-picker-indicator,
:where(input[type="time"]):not([data-slot])::-webkit-calendar-picker-indicator {
  inline-size: 16px; block-size: 16px; margin-inline-start: var(--kb-sp-1h); padding: var(--kb-sp-half);
  border-radius: 6px; cursor: pointer; opacity: 1;
  background: var(--kb-muted);
  -webkit-mask: var(--ui-icon-calendar) center / 16px 16px no-repeat;
  mask: var(--ui-icon-calendar) center / 16px 16px no-repeat;
}
:where(input[type="date"], input[type="datetime-local"], input[type="month"], input[type="time"], input[type="week"]):not([data-slot])::-webkit-datetime-edit { padding: 0; }
:where(input[type="date"], input[type="datetime-local"], input[type="month"], input[type="time"], input[type="week"]):not([data-slot])::-webkit-datetime-edit-fields-wrapper { padding: 0; }
.form-group :is(input[type="date"], input[type="datetime-local"], input[type="month"], input[type="time"], input[type="week"]) { block-size: 42px; padding-block: 0; }

/* ui-date-input (partials/kb/field.ejs kind 'date', and every page that uses it) had no kit look:
   a 32px pill beside 42px inputs (UF1 F5). Promoted from settings-kb.css's .set-field rule. */
[data-slot="date-input"] {
  display: flex; align-items: center; gap: var(--kb-sp-half); box-sizing: border-box; inline-size: 100%; min-block-size: 42px; padding: 0 var(--kb-sp-3);
  border: 0; border-radius: var(--kb-radius-ctl); background: var(--kb-surface); box-shadow: inset 0 0 0 1.5px var(--kb-edge);
  color: var(--kb-ink); font-size: var(--kb-fs-lg); font-weight: 600;
}
[data-slot="date-input"]:focus-within { outline: 3px solid var(--kb-coral-text); outline-offset: 2px; }
[data-slot="date-input-segment"], .form-group [data-slot="date-input-segment"] {
  min-height: 0; padding: 0; border: 0; background: transparent; box-shadow: none; color: inherit; font: inherit; outline: none;
}
input[data-slot="date-input-segment"]::placeholder { color: var(--kb-muted); }
/* DA3 K4 (D4): ONE empty-date look = the native box (Chrome draws "dd/mm/yyyy" in the field's own
   ink): tight slashes and the kit calendar icon at the right edge. ui-sdk hard-codes "––"
   placeholders, so they go transparent and each empty segment shows its letters from a ::after
   stacked in the same grid cell as its input. The focused empty segment gets the selection wash,
   like the native field. The icon is the same mask as the native picker glyph. */
[data-slot="date-input"] { gap: 0; }
[data-slot="date-input"] > ui-date-input-segment[segment="year"] { margin-inline-end: var(--kb-sp-2); }
[data-slot="date-input"] > ui-date-input-segment:not([data-type="literal"]) { display: inline-grid; }
[data-slot="date-input"] > ui-date-input-segment:not([data-type="literal"]) > input { grid-area: 1 / 1; inline-size: 100%; min-inline-size: 0; field-sizing: content; }
[data-slot="date-input"] > ui-date-input-segment > input[data-slot="date-input-segment"]::placeholder { color: transparent; }
[data-slot="date-input"] > ui-date-input-segment:has(> input:placeholder-shown)::after {
  grid-area: 1 / 1; white-space: nowrap; pointer-events: none; color: inherit;
}
[data-slot="date-input"] > ui-date-input-segment[segment="day"]:has(> input:placeholder-shown)::after { content: "dd"; }
[data-slot="date-input"] > ui-date-input-segment[segment="month"]:has(> input:placeholder-shown)::after { content: "mm"; }
[data-slot="date-input"] > ui-date-input-segment[segment="year"]:has(> input:placeholder-shown)::after { content: "yyyy"; }
[data-slot="date-input"] > ui-date-input-segment:has(> input:focus) { border-radius: 4px; background: var(--kb-coral-wash); }
/* The field draws the one focus ring (D2); the segment itself takes no second ring inside it. */
[data-slot="date-input"] > ui-date-input-segment > input[data-slot="date-input-segment"]:focus-visible { outline: none; }
[data-slot="date-input"]::after {
  content: ""; flex: none; inline-size: 16px; block-size: 16px; margin-inline-start: auto; padding: var(--kb-sp-half);
  background: var(--kb-muted);
  -webkit-mask: var(--ui-icon-calendar) center / 16px 16px no-repeat; mask: var(--ui-icon-calendar) center / 16px 16px no-repeat;
}

/* Range and file pickers */
:where(input[type="range"]):not([data-slot]) { accent-color: var(--kb-coral); }
/* File input (D-g, UF1 FIN-09 / HR-25): a kit field box holding the kit button; the file name (or
   the browser's "No file chosen") sits in it as muted text, not loose on the page. */
:where(input[type="file"]):not([data-slot]) {
  box-sizing: border-box; max-inline-size: 100%; min-block-size: 42px; padding: var(--kb-sp-1) var(--kb-sp-3) var(--kb-sp-1) var(--kb-sp-1);
  border-radius: var(--kb-radius-ctl); background: var(--kb-surface); box-shadow: inset 0 0 0 1.5px var(--kb-edge);
  font: inherit; font-size: var(--kb-fs-md); color: var(--kb-muted); cursor: pointer;
}
:where(input[type="file"]):not([data-slot]):focus-visible { outline: 3px solid var(--kb-coral-text); outline-offset: 2px; }
/* DA3 K4 (D3): ONE file-picker look = the paygen one (hr-kb.css .hr-file): a 34px kit button with
   the file icon and bold ink label inside the field, the file name beside it in muted 600. The
   icon's colour has to be in the image (a button part cannot hold a mask child): --kb-file-icon,
   one per theme at the top of this file. */
:where(input[type="file"]):not([data-slot]) { block-size: 42px; font-weight: 600; line-height: 32px; }
:where(input[type="file"]):not([data-slot])::file-selector-button {
  margin-inline-end: var(--kb-sp-2h); block-size: 34px; padding: 0 var(--kb-sp-3) 0 34px;
  border: 0; border-radius: var(--kb-radius-ctl);
  background: var(--kb-surface) var(--kb-file-icon) no-repeat 12px center / 16px 16px; color: var(--kb-ink);
  box-shadow: inset 0 0 0 1.5px var(--kb-edge);
  font: inherit; font-size: 13.5px; font-weight: 700; line-height: normal; vertical-align: middle; cursor: pointer;
}
:where(input[type="file"]):not([data-slot])::file-selector-button:hover { background-color: var(--kb-surface-2); }
.form-group input[type="file"] { padding: var(--kb-sp-1) var(--kb-sp-3) var(--kb-sp-1) var(--kb-sp-1); }

/* DA2 C1/H8: the last browser-default parts of native controls inside the app. */
/* Time: a clock, not the calendar (the mask is defined in :root at the top of this file). */
:where(input[type="time"]):not([data-slot])::-webkit-calendar-picker-indicator {
  -webkit-mask-image: var(--kb-icon-clock); mask-image: var(--kb-icon-clock);
}
/* Number: no spinner arrows (type a figure; arrow keys still step it). */
:where(input[type="number"]):not([data-slot]) { -moz-appearance: textfield; appearance: textfield; }
:where(input[type="number"]):not([data-slot])::-webkit-inner-spin-button,
:where(input[type="number"]):not([data-slot])::-webkit-outer-spin-button { -webkit-appearance: none; appearance: none; margin: 0; }
/* Colour well: a 42px kit field frame holding a rounded swatch. */
:where(input[type="color"]):not([data-slot]) {
  -webkit-appearance: none; appearance: none; box-sizing: border-box;
  inline-size: 56px; block-size: 42px; min-height: var(--kb-ctl-h); padding: 5px; flex: none;
  border: 0; border-radius: var(--kb-radius-ctl); background: var(--kb-surface);
  box-shadow: inset 0 0 0 1.5px var(--kb-edge); cursor: pointer;
}
:where(input[type="color"]):not([data-slot])::-webkit-color-swatch-wrapper { padding: 0; }
:where(input[type="color"]):not([data-slot])::-webkit-color-swatch { border: 0; border-radius: var(--kb-radius-sm); }
:where(input[type="color"]):not([data-slot])::-moz-color-swatch { border: 0; border-radius: var(--kb-radius-sm); }
/* DA2 X3: a kit input (ui-input's <input data-slot="input">) of type date / time / number kept
   Chrome's glyph and spinners, because the rules above skip [data-slot]. The kit draws its box;
   only the browser's inner parts are swapped here. ui-date-input segments are another slot
   (date-input-segment), so they are untouched. */
input[data-slot="input"]:is([type="date"], [type="datetime-local"], [type="month"], [type="week"], [type="time"])::-webkit-calendar-picker-indicator {
  inline-size: 16px; block-size: 16px; margin-inline-start: var(--kb-sp-1h); padding: var(--kb-sp-half);
  border-radius: 6px; cursor: pointer; opacity: 1;
  background: var(--kb-muted);
  -webkit-mask: var(--ui-icon-calendar) center / 16px 16px no-repeat;
  mask: var(--ui-icon-calendar) center / 16px 16px no-repeat;
}
input[data-slot="input"][type="time"]::-webkit-calendar-picker-indicator { -webkit-mask-image: var(--kb-icon-clock); mask-image: var(--kb-icon-clock); }
input[data-slot="input"]:is([type="date"], [type="datetime-local"], [type="month"], [type="week"], [type="time"])::-webkit-datetime-edit,
input[data-slot="input"]:is([type="date"], [type="datetime-local"], [type="month"], [type="week"], [type="time"])::-webkit-datetime-edit-fields-wrapper { padding: 0; }
input[data-slot="input"][type="number"] { -moz-appearance: textfield; appearance: textfield; }
input[data-slot="input"][type="number"]::-webkit-inner-spin-button,
input[data-slot="input"][type="number"]::-webkit-outer-spin-button { -webkit-appearance: none; appearance: none; margin: 0; }
.form-group input[type="color"] { inline-size: 56px; padding: 5px; }
/* Textarea: no resize grip. Where the browser can (field-sizing), a field in a form grows with its
   text instead; a loose textarea keeps a vertical-only resize so long text can still be opened up. */
:where(textarea):not([data-slot]) { resize: vertical; }
.form-group textarea:not([data-slot]) { resize: none; }
@supports (field-sizing: content) {
  .form-group textarea:not([data-slot]) { field-sizing: content; min-block-size: 84px; max-block-size: 60vh; }
}

/* Labels: plain sentence case (the kit bans ALL-CAPS micro labels). */
.kv dt, .detail-card h4 { color: var(--kb-muted); font-size: var(--kb-fs-base); font-weight: 700; letter-spacing: 0; text-transform: none; }
/* DA2 X6: ONE field label. A .form-group label (style.css: bold, muted) and a kb/field label
   (ui-field-label, web.css: 500, ink) sat in one form with two looks. Both are now ink, 600, 13px. */
.form-group label, ui-field.kb-form-field [data-slot="field-label"] { color: var(--kb-ink); font-size: var(--kb-fs-base); font-weight: 600; line-height: 1.35; letter-spacing: 0; text-transform: none; }
/* Stacked kit fields keep the .form-group rhythm (0.85rem under each), so two never touch at 390.
   Only where fields stack as blocks in a form box: in a toolbar or flex row a bottom margin would
   drop the field below the buttons beside it. The last field in its box adds nothing.
   DA3 K9: the audit-trail filter form (.set-filters) and the notices category forms are flex rows
   too (the margin lifted their boxes 13px above the selects / buttons). */
:is(form, fieldset, .form-card, .kb-card, .detail-card, [data-slot="dialog-content"], .kal-modal-panel, .kal-modal-body):not(.kb-toolrow, .page-toolbar, .filter-bar, .table-tools-bar, .kb-actions, .set-filters, .notices-cat-forms form) > ui-field.kb-form-field:not(:last-child) { margin-block-end: 0.85rem; }
.radio-group label { color: var(--kb-ink); }
.form-hint { color: var(--kb-muted); }

/* ── Cards and panels ── */
.form-card, .filter-bar, .detail-card, .dashboard-card {
  border: 0; background: var(--kb-surface); box-shadow: var(--kb-shadow-1);
}
.form-card { border-radius: var(--kb-radius-card); }
.filter-bar { border-radius: var(--kb-radius-card); padding: var(--kb-sp-3); }
.detail-card { border-radius: var(--kb-radius-md); }
/* DA2 M5: one hovered-row colour (--kb-row-hover) and one opened-row colour (--kb-row-picked) on every
   list. The opened row and the detail strip under it are one tinted block; no beige surface-2 fill. */
.detail-panel { border-top: 0; background: var(--kb-row-picked); }
.detail-row > td { background: var(--kb-row-picked); }
.summary-row.is-open > td { background: var(--kb-row-picked); }
.data-table tbody tr.detail-row:hover > td, .data-table tbody tr.summary-row.is-open:hover > td { background: var(--kb-row-picked); }
/* DA2 Z3: the same on the kit's own tables (kal-bright.css:579 hover is (0,2,3) and beat the rules
   above), and the strip right under an opened row is ALWAYS the picked colour, also where a page
   rule cleared or whitened detail cells (list-kb.css:52, hr-kb.css:130 at up to (0,3,3)). */
:is(.kb-table, .data-table) tbody tr.is-open > td,
:is(.kb-table, .data-table) tbody tr.is-open:hover > td,
:is(.kb-table, .data-table) tbody tr.is-open + tr.detail-row > td,
:is(.kb-table, .data-table) tbody tr.is-open + tr.detail-row:hover > td { background: var(--kb-row-picked); }
/* DA2 X4: on a phone a kit table row is a card (kal-bright.css grid). An opened or ticked row paints
   the CARD (the tr) and its cells stay clear; painting each cell left stripes and square corners
   inside the rounded card. The rules above (and list-kb.css) paint cells and are unlayered, so
   they beat the kit's clear cells: !important is the one way back for this phone-only override. */
@media (max-width: 760px) {
  .kb-table > tbody > tr.summary-row.is-open,
  .kb-table > tbody > tr:not(.detail-row):has(input[type="checkbox"]:checked) { background: var(--kb-row-picked); }
  .kb-table > tbody > tr:not(.detail-row) > td { background-color: transparent !important; }
  /* The opened strip under a card is one full-width block. Left to the kit's card grid, its single
     colspan cell dropped into the 34px lead column (a sliver; seen on the fixture for every list
     without its own page rule, as hr-kb / notes-kb / nqaits-kb / financial-kb each had to add). */
  .kb-table > tbody > tr.detail-row:not([hidden]) { display: block; padding: 0; background: transparent; }
  .kb-table > tbody > tr.detail-row > td { display: block; inline-size: auto; max-inline-size: none; }
  /* Z3 on a phone: the strip under an opened card is a picked card of its own (the tr), cells clear. */
  .kb-table > tbody > tr.is-open + tr.detail-row:not([hidden]) { background: var(--kb-row-picked); border-radius: 14px; }
  .kb-table > tbody > tr.is-open + tr.detail-row > td { background-color: transparent !important; }
}

/* DA2 M11: ONE card recipe. The kit's .kb-card is the Assist suggestion tile (tone wash, lift on hover,
   132px tall); in the Portal it is the plain panel: surface, card radius, soft shadow, 24px (16px tight).
   A card inside a card drops its own frame. */
.kb-card {
  position: relative; display: block; box-sizing: border-box; min-height: 0; padding: var(--kb-sp-6);
  border: 0; border-radius: var(--kb-radius-card); background: var(--kb-surface); color: var(--kb-ink);
  box-shadow: var(--kb-shadow-1); text-align: start; cursor: auto;
  font-weight: inherit; font-size: inherit; line-height: inherit; transition: none;
}
.kb-card:hover { box-shadow: var(--kb-shadow-1); }
.kb-card-tight { padding: var(--kb-sp-4); }
.kb-card .kb-card, .kb-card .kb-card:hover { padding: 0; border-radius: 0; background: transparent; box-shadow: none; }
.kb-card + .kb-card { margin-block-start: var(--kb-sp-4); }
.kb-card-title { margin: 0 0 var(--kb-sp-3); color: var(--kb-ink); font-size: var(--kb-fs-xl); font-weight: 800; letter-spacing: -0.01em; line-height: 1.3; text-align: start; }
@media (max-width: 760px) { .kb-card { padding: var(--kb-sp-4); } }

/* DA2 M13: one empty state. kb/empty (.kb-empty) and the legacy .empty-state draw the same box; inside
   a card or group it is plain text in the card, never a second card. */
.empty-state, .kb-empty {
  padding: 48px var(--kb-sp-6); border: 0; border-radius: var(--kb-radius-card);
  background: var(--kb-surface); box-shadow: var(--kb-shadow-1);
  color: var(--kb-muted); font-size: var(--kb-fs-lg); font-weight: 600; line-height: 1.45; text-align: center;
}
:is(.kb-card, .kb-group, .kb-subgroup, .list-kb-card, .form-card, .detail-card, .group-section, .kal-modal-panel, [data-slot="dialog-content"]) :is(.kb-empty, .empty-state) {
  padding: var(--kb-sp-8) var(--kb-sp-4); border-radius: 0; background: transparent; box-shadow: none;
}
:is(.kb-empty, .empty-state) a { color: var(--kb-coral-text); font-weight: 700; text-decoration: underline; text-underline-offset: 2px; }

/* ── Sortable headers (public/js/list-sort.js, every table in the Portal) ──
   The script moves each sortable header's label into a real <button class="th-sort"> and adds a
   fixed-width arrow span, so nothing moves or changes size on hover, focus or sort. The button
   takes the header's own font, colour and alignment; only its colour changes on hover / when active. */
th.sortable > .th-sort {
  appearance: none; -webkit-appearance: none;
  display: inline-block; max-width: 100%;
  margin: 0; padding: 0; border: 0; border-radius: 4px; background: none; box-shadow: none;
  font: inherit; color: inherit; letter-spacing: inherit; text-transform: inherit; text-align: inherit; line-height: inherit;
  cursor: pointer; user-select: none; min-height: 0; min-width: 0; width: auto;
}
th.sortable > .th-sort:hover { color: var(--kb-ink); background: none; transform: none; }
th.sortable > .th-sort:focus { outline: none; }
th.sortable > .th-sort:focus-visible { outline: 3px solid var(--kb-coral-text); outline-offset: 2px; }
th.sortable[aria-sort] > .th-sort { color: var(--kb-coral-text); }
.th-sort-glue { white-space: nowrap; }
/* The arrow is glued to the last word of the label (first word on right-aligned headers): see glueIcon(). */
.th-sort-ico { display: inline-block; width: 1em; margin-inline-start: 0.3em; text-align: center; font-size: 0.9em; line-height: 1; opacity: 0.65; }
.th-sort--end .th-sort-ico { margin-inline-start: 0; margin-inline-end: 0.3em; }
.th-sort-ico::before { content: "\2195"; }
th.sortable[aria-sort="ascending"] .th-sort-ico::before { content: "\25B2"; }
th.sortable[aria-sort="descending"] .th-sort-ico::before { content: "\25BC"; }
th.sortable[aria-sort] .th-sort-ico { opacity: 0.9; }
@media print { .th-sort-ico { display: none; } }

/* ── Tables (= kb-table, inside a card) ── */
.data-table {
  border: 0; border-radius: var(--kb-radius-card);
  background: var(--kb-surface); box-shadow: var(--kb-shadow-1);
  font-size: var(--kb-fs-md);
}
.data-table thead th {
  background: transparent; color: var(--kb-muted);
  font-size: 12.5px; font-weight: 700; letter-spacing: 0; text-transform: none;
  border-bottom: 1px solid var(--kb-line);
  padding-top: var(--kb-sp-3); padding-bottom: var(--kb-sp-2h);
}
.data-table tbody td { border-bottom: 1px solid var(--kb-line); vertical-align: middle; }
/* DA2 X10: hover and the ticked fill paint a table's OWN rows only. Written as descendant rules they
   also painted every cell of a table nested in a detail panel whenever the pointer was anywhere
   over the opened strip (or a box was ticked inside it). */
.data-table > tbody > tr:hover > td { background: var(--kb-row-hover); }
.data-table > tbody > tr:not(.detail-row):has(input[type="checkbox"]:checked) > td { background: var(--kb-row-picked); }
/* The kit (kal-bright.css:579 `.kb-table tbody tr:hover td`) and style.css:1050
   (`.data-table tbody tr:hover td`) are descendant rules at (0,2,3): a cell under a hovered
   ANCESTOR row, in a row that is not itself hovered, keeps its own look. This is just heavier
   (0,2,5). Totals (tfoot) and ticked rows are left alone. */
:is(.kb-table, .data-table) tbody tr:hover tbody > tr:where(:not(:hover):not(:has(input[type="checkbox"]:checked)):not(:has([data-checked]))) > td { background-color: transparent; }
/* Totals: a firmer rule above, no beige fill (DA2 M5). */
.data-table tfoot th, .data-table tfoot td { background: var(--kb-surface); border-top: 2px solid var(--kb-line); font-weight: 700; }
.clear-sort-chip { background: var(--kb-surface-2); color: var(--kb-muted); }
.clear-sort-chip:hover, .clear-sort-chip:focus-visible { background: var(--kb-coral); color: var(--kb-primary-ink); border-color: transparent; }

/* ── Filter tabs (DA2 M10): the kit's tab look, the same pill as the area tabs (kb-areas): muted text,
   the current tab filled with the area colour. The row is the white top of the panel below it (no beige
   track), so the tabs still touch the content they filter. ── */
.filter-tabs {
  gap: var(--kb-sp-1); padding: var(--kb-sp-2); margin: 0; border: 0; border-radius: var(--kb-radius-card) var(--kb-radius-card) 0 0;
  background: var(--kb-surface); box-shadow: var(--kb-shadow-1), inset 0 -1px 0 var(--kb-line); align-items: center;
}
.filter-tab {
  top: 0; box-sizing: border-box; height: 36px; padding: 0 14px; border: 0 !important;
  border-radius: var(--kb-radius-pill); background: transparent;
  color: var(--kb-muted); font-weight: 700; font-size: var(--kb-fs-md); text-decoration: none;
  transition: background-color var(--kb-dur-fast) var(--kb-ease), color var(--kb-dur-fast) var(--kb-ease);
}
.filter-tab:hover { color: var(--kb-ink); background: var(--kb-area-wash); }
.filter-tab.active, .filter-tab.active:hover { background: var(--kb-area); color: var(--kb-primary-ink); box-shadow: var(--kb-shadow-fill); }
.filter-tab:focus-visible { outline: 3px solid var(--kb-coral-text); outline-offset: 2px; }
.filter-tab.clear { color: var(--kb-muted); font-weight: 600; }
.filter-tab.clear:hover { color: var(--kb-coral-text); }
.filter-tab-count { min-width: 22px; height: 20px; box-sizing: border-box; padding: 0 7px; background: var(--kb-surface-3); color: var(--kb-ink); font-size: var(--kb-fs-sm); font-weight: 800; letter-spacing: 0; }
/* Current tab count: ink on the surface in BOTH themes (never --kb-primary-ink on a dark pill, UF1
   PPL-04). !important beats the old per-page coral fills (dictated-notes.css, training tabs). */
.filter-tab.active .filter-tab-count { background: var(--kb-surface) !important; color: var(--kb-ink) !important; }
/* The panel under the tabs meets them: square top corners. */
.filter-tabs + .data-table, .filter-tabs + * .data-table:first-child,
.filter-tabs + .group-section, .filter-tabs + .list-shell .data-table { border-top-left-radius: 0; border-top-right-radius: 0; }

/* ── Group sections (= kb-group: a card with a tab of the area / centre colour, no coloured bar) ── */
.group-section { border-radius: var(--kb-radius-card); background: var(--kb-surface); box-shadow: var(--kb-shadow-1); }
.group-header, .centre-header {
  position: relative;
  min-height: 52px; padding: var(--kb-sp-2h) var(--kb-sp-4) var(--kb-sp-2h) 26px;
  border: 0; border-radius: var(--kb-radius-card) var(--kb-radius-card) 0 0;
  background: var(--kb-surface); color: var(--kb-ink); box-shadow: none;
  font-size: var(--kb-fs-lg); font-weight: 700; letter-spacing: 0;
}
details:not([open]) > .group-header { border-radius: var(--kb-radius-card); }
.group-header::before {
  content: ""; position: absolute; left: 0; top: var(--kb-sp-3); bottom: var(--kb-sp-3); width: 7px; border-radius: 0 6px 6px 0;
  background: var(--kb-centre, var(--kb-area));
}
.group-header:hover { background: var(--kb-surface-2); }
.centre-header strong { font-size: var(--kb-fs-xl); font-weight: 800; letter-spacing: 0.01em; }
.count-badge { background: var(--kb-surface-2); color: var(--kb-ink); font-weight: 800; letter-spacing: 0; }
.week-header { background: var(--kb-surface-2); }
.centre-header-stat-label { opacity: 1; color: var(--kb-muted); }
.qbo-pushed-repush { background: var(--kb-surface-2); }
.group-section .data-table { border-radius: 0 0 var(--kb-radius-card) var(--kb-radius-card); box-shadow: inset 0 1px 0 var(--kb-line); }
.filter-tabs + .group-section > .group-header { border-radius: 0; }
.collapse-icon::before { content: ""; width: 8px; height: 8px; margin: 0 var(--kb-sp-1h) var(--kb-sp-half) var(--kb-sp-half); border-right: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: rotate(45deg); transition: transform var(--kb-dur-move) var(--kb-spring); opacity: 0.7; }
details:not([open]) .collapse-icon::before { transform: rotate(-45deg); }

/* ── Pills and chips (DA2 M12): ONE chip. .meta-pill, .kb-tag and .kb-status are the same 24px box,
   12.5px / 700, sentence case, coloured by one tone set (--kb-tone-* from [data-tone], kal-bright.css).
   .meta-pill's classes map onto those tones: neutral (no class), success / progress = leaf,
   warning = sun, danger = coral, via-resend = sky. A meta-pill with data-tone takes that tone. ── */
:is(.meta-pill, .kb-tag, .kb-status) {
  display: inline-flex; align-items: center; gap: 5px; box-sizing: border-box;
  height: 24px; min-height: 24px; padding: 0 9px; border: 0; border-radius: var(--kb-radius-pill);
  background: var(--kb-tone-wash); color: var(--kb-tone-text);
  font-size: 12.5px; font-weight: 700; letter-spacing: 0; line-height: 1.2; text-transform: none; white-space: nowrap;
}
:is(.meta-pill, .kb-tag, .kb-status) :is(.kb-ico, svg) { flex: none; inline-size: 14px; block-size: 14px; }
/* A kb-tag a page lets wrap (white-space: normal) grows past one line (the kit's min-height contract). */
.kb-tag { height: auto; }
.meta-pill:not([data-tone]) { --kb-tone-wash: var(--kb-neutral-wash); --kb-tone-text: var(--kb-ink); }
.kb-status:not([data-tone]) { --kb-tone-wash: var(--kb-coral-wash); --kb-tone-text: var(--kb-coral-text); }
.meta-pill:is(.success, .progress):not([data-tone]) { --kb-tone-wash: var(--kb-leaf-wash); --kb-tone-text: var(--kb-leaf-text); }
.meta-pill.warning:not([data-tone]) { --kb-tone-wash: var(--kb-sun-wash); --kb-tone-text: var(--kb-sun-text); }
.meta-pill.danger:not([data-tone]) { --kb-tone-wash: var(--kb-coral-wash); --kb-tone-text: var(--kb-coral-text); }
.meta-pill.via-resend:not([data-tone]) { --kb-tone-wash: var(--kb-sky-wash); --kb-tone-text: var(--kb-sky-text); }
/* The success tick glyph (style.css) was on one chip only: no glyphs drawn by the class. */
.meta-pill.success::before { content: none; }
/* Same weight as style.css's own .meta-pill.<tone> colours (loaded earlier), so these win. */
.meta-pill:is(.success, .progress, .warning, .danger, .via-resend) { background: var(--kb-tone-wash); color: var(--kb-tone-text); border-color: transparent; }

/* ── Toolbars ── */
.page-toolbar { gap: var(--kb-sp-2h); }
/* Active-filter strip (partials/filter-chips.ejs, DA2 MSC-10): the chips and "Clear filters" are ONE
   32px height. The .page-toolbar rule in section 3 made the button 42px beside 24px chips. */
.filter-chip-row .page-toolbar-actions { display: flex; flex-wrap: wrap; align-items: center; gap: var(--kb-sp-2); }
.filter-chip-row .page-toolbar-actions .meta-pill { height: 32px; min-height: 32px; padding: 0 var(--kb-sp-3); gap: var(--kb-sp-1h); font-size: var(--kb-fs-base); }
.filter-chip-row .page-toolbar-actions .meta-pill-removable { padding-inline-end: var(--kb-sp-1h); }
.filter-chip-row .page-toolbar-actions .btn.btn-sm { min-height: var(--kb-ctl-h-sm); height: var(--kb-ctl-h-sm); padding: 0 var(--kb-sp-3); font-size: var(--kb-fs-base); }

/* ── Button rows (D-e, UF1 PPL-19 / PPL-33): .form-actions had no base rule, so buttons sat on the
   text baseline with whitespace gaps. One flex row, left aligned (Save first, then Cancel), wrapping
   on a phone. Zero specificity: every page or scoped rule (.filter-bar .form-actions) still wins. ── */
:where(.form-actions) { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-start; gap: var(--kb-sp-2h); }

/* ── Charts (public/js/kal-chart.js): header wraps; its range select is a kit field, 42px like
   the Home chart's ui-select (UF1 FIN-08). ── */
.kal-chart-header { flex-wrap: wrap; }
.kal-chart-range { font-size: var(--kb-fs-md); color: var(--kb-muted); font-weight: 600; }
.kal-chart-range select { min-height: var(--kb-ctl-h); padding: 0 38px 0 14px; border: 0; border-radius: var(--kb-radius-ctl); background-color: var(--kb-surface); box-shadow: inset 0 0 0 1.5px var(--kb-edge); color: var(--kb-ink); font-size: 14.5px; font-weight: 700; }

/* ── Table tools (public/js/table-tools.js): search box, Search / clear / Filters on the kit, all
   42px so they line up with the kit toolbar (UF1 G11 / FIN-13 / ACT-08 / ACT-31). ── */
.table-tools-bar { gap: var(--kb-sp-2); }
.table-tools-bar .search-input {
  box-sizing: border-box; inline-size: 260px; max-inline-size: 100%; block-size: 42px; min-height: var(--kb-ctl-h); padding: 0 14px;
  border: 0; border-radius: var(--kb-radius-ctl); background: var(--kb-surface); color: var(--kb-ink);
  box-shadow: inset 0 0 0 1.5px var(--kb-edge); font: inherit; font-size: var(--kb-fs-lg); font-weight: 600;
}
.table-tools-bar .search-input:focus { outline: 3px solid var(--kb-coral-text); outline-offset: 2px; }
.table-tools-bar .kb-btn { flex: none; }
.table-tools-bar .kb-btn .kb-tt-ico { inline-size: 17px; block-size: 17px; }
.table-tools-bar .search-clear { inline-size: 42px; padding: 0; }
.table-tools-bar .search-clear svg { inline-size: 16px; block-size: 16px; }
.filter-active-badge {
  display: inline-flex; align-items: center; block-size: 26px; padding: 0 var(--kb-sp-2h); border-radius: var(--kb-radius-pill);
  background: var(--kb-coral-wash); color: var(--kb-coral-text); font-size: 12.5px; font-weight: 800; letter-spacing: 0;
}

/* Filters dialog (table-tools.js openFilterModal): a native <dialog class="filter-modal"> drawn as
   the kit's dialog. The Portal's reset (style.css, margin:0 on *) beats the browser's
   `dialog { margin: auto }`, so it is put back here or the dialog pins top-left. */
dialog.filter-modal {
  box-sizing: border-box; inline-size: min(720px, calc(100vw - 32px)); max-inline-size: none; max-block-size: min(80vh, 720px);
  margin: auto; padding: var(--kb-sp-6); overflow-y: auto; overscroll-behavior: contain;
  border: 0; border-radius: 24px; background: var(--kb-surface); color: var(--kb-ink); box-shadow: var(--kb-shadow-3);
}
dialog.filter-modal::backdrop { background: var(--kb-backdrop); }
@media (prefers-reduced-motion: no-preference) {
  dialog.filter-modal[open] { animation: kb-filter-in 240ms var(--kb-spring); }
  @keyframes kb-filter-in { from { opacity: 0; scale: 0.96; translate: 0 10px; } }
}
.filter-modal .filter-modal-header { display: flex; align-items: center; justify-content: space-between; gap: var(--kb-sp-3); margin: 0 0 var(--kb-sp-4); }
.filter-modal .filter-modal-header h2 { margin: 0; color: var(--kb-ink); font-size: var(--kb-fs-2xl); font-weight: 800; letter-spacing: -0.02em; text-align: left; }
/* The close x is the one close-x look (see kb/dialog below). */
@media (hover: hover) and (pointer: fine) {
  .filter-modal .filter-mode-btn:not(.active):hover { color: var(--kb-ink); }
}
.filter-modal .filter-mode-bar { display: flex; align-items: center; gap: var(--kb-sp-2h); margin: 0 0 var(--kb-sp-4); padding: 0; background: none; border-radius: 0; }
.filter-modal .filter-mode-label { margin: 0; color: var(--kb-muted); font-size: var(--kb-fs-md); font-weight: 700; }
.filter-modal .filter-mode-seg { display: inline-flex; gap: var(--kb-sp-half); padding: 3px; border-radius: var(--kb-radius-pill); background: var(--kb-surface-2); }
.filter-modal .filter-mode-btn {
  block-size: 34px; padding: 0 var(--kb-sp-4); border: 0; border-radius: var(--kb-radius-pill);
  background: transparent; color: var(--kb-muted); font: inherit; font-size: var(--kb-fs-md); font-weight: 700; cursor: pointer;
}
.filter-modal .filter-mode-btn.active { background: var(--kb-surface); color: var(--kb-ink); box-shadow: var(--kb-shadow-1); }
.filter-modal .filter-mode-btn:focus-visible { outline: 3px solid var(--kb-coral-text); outline-offset: 2px; }
.filter-modal .filter-rules { display: grid; gap: var(--kb-sp-2); margin: 0 0 var(--kb-sp-3); }
.filter-modal .filter-rule-row {
  display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 0.9fr) minmax(0, 1.3fr) 42px; align-items: center; gap: var(--kb-sp-2);
  margin: 0; padding: 0; background: none; border: 0; border-radius: 0;
}
.filter-modal :is(.filter-rule-field, .filter-rule-operator, .filter-rule-value) { inline-size: 100%; min-inline-size: 0; flex: none; }
.filter-modal .filter-rule-delete { inline-size: 42px; block-size: 42px; min-height: 0; padding: 0; }
.filter-modal .filter-rule-delete svg { inline-size: 16px; block-size: 16px; }
.filter-modal .filter-add-rule .kb-ico { inline-size: 16px; block-size: 16px; }
.filter-modal .filter-add-rule { gap: var(--kb-sp-1h); }
/* Apply first, at the left, then Clear all (D61, DA2 X8; table-tools.js appends them in that order). */
.filter-modal .filter-modal-footer { display: flex; justify-content: flex-start; flex-wrap: wrap; gap: var(--kb-sp-2h); margin: var(--kb-sp-5) 0 0; padding: var(--kb-sp-4) 0 0; border-top: 1px solid var(--kb-line); }
@media (max-width: 600px) {
  .filter-modal .filter-rule-row { grid-template-columns: minmax(0, 1fr) 42px; padding-block-end: var(--kb-sp-2); border-block-end: 1px solid var(--kb-line); }
  .filter-modal .filter-rule-row > :not(.filter-rule-delete) { grid-column: 1; }
  .filter-modal .filter-rule-delete { grid-column: 2; grid-row: 1; }
}

/* ── Phone: a wide table scrolls inside its own card, never the page (interim, until each
   page's wave stacks its rows as kit cards). ── */
@media (max-width: 760px) {
  .main-content *:has(> .data-table) { overflow-x: auto; overscroll-behavior-x: contain; max-width: 100%; }
  .main-content .data-table { min-width: 680px; }
  /* A table placed straight in <main> has no card to scroll in, so it becomes its own box. */
  .main-content > .data-table { display: block; overflow-x: auto; overscroll-behavior-x: contain; min-width: 0; max-width: 100%; }
}

/* ── Toolbar phone rule (DA2 B3/H9): at 760px and under, a toolbar's items WRAP onto more rows and a
   select never squeezes below 140px, so its value stays readable ("All centres", never "Al..."). The
   kit kept the ui-toolbar on one nowrap line and let selects shrink to nothing. Two selects share a
   row at 390; buttons and menus wrap after them at their own width. Page rules that zero a trigger's
   min-width still wrap here: the 140px flex-basis decides the line break. ── */
@media (max-width: 760px) {
  .kb-toolrow [data-slot="toolbar"] { flex: 1 1 100%; flex-wrap: wrap; min-width: 0; row-gap: var(--kb-sp-2); }
  .kb-toolrow .kb-select [data-slot="select-trigger"] { flex: 1 1 140px; min-width: 140px; max-width: 100%; width: auto; }
  .kb-toolrow > :is(select, ui-select:not(.kb-select)), .kb-toolrow [data-slot="toolbar"] > select { flex: 1 1 140px; min-width: 140px; max-width: 100%; }
  .table-tools-bar { flex-wrap: wrap; }
  .table-tools-bar .search-input { flex: 1 1 100%; inline-size: 100%; }
}

/* ── kb/dialog (ui-dialog, DA2 M3): close x at the top right (the kit's 32px icon button; the content
   box is position: fixed in web.css, so it is the x's containing block); the title keeps clear of it.
   Actions at the bottom, primary first, at the left (D61). ── */
/* ui-sdk draws <ui-dialog-close> as display: contents, so the button itself is placed. */
.kb-dialog-x > .kb-icon-btn { position: absolute; inset-block-start: 16px; inset-inline-end: 16px; z-index: 1; }
/* DA2 X8/X9: ONE close x for every dialog, modal and overlay: a 32px ghost square (no fill, ink
   icon 16px, radius 10), surface-2 on hover, surface-3 pressed, the one focus ring. The kit
   dialog x, the Filters dialog, the page overlay, the Kathy email x (.ke-close) and EVERY icon
   button in a dialog or modal head (kal-modal, bills-modal, paygen-modal; kb-icon-btn, kb-btn-icon
   or btn-icon) draw this (DA2 Z1); only colour changes on hover. flex: none keeps it 32x32 at 390. */
:is(.kb-dialog-x > .kb-icon-btn, .filter-modal .filter-modal-close, .page-overlay-close, .ke-close, :is(.kal-modal-head, .bills-modal-head, .paygen-modal-head, .filter-modal-header, [data-slot="dialog-content"] > header) :is(.kb-icon-btn, .kb-btn-icon, .btn-icon)) {
  display: inline-grid; place-items: center; box-sizing: border-box;
  inline-size: var(--kb-ctl-h-sm); block-size: var(--kb-ctl-h-sm); min-inline-size: var(--kb-ctl-h-sm); max-inline-size: none; min-block-size: 0; padding: 0;
  border: 0; border-radius: 10px; background: transparent; color: var(--kb-ink); box-shadow: none;
  cursor: pointer; flex: none;
  transition: background-color var(--kb-dur-fast) var(--kb-ease);
}
:is(.kb-dialog-x > .kb-icon-btn, .filter-modal .filter-modal-close, .page-overlay-close, .ke-close, :is(.kal-modal-head, .bills-modal-head, .paygen-modal-head, .filter-modal-header, [data-slot="dialog-content"] > header) :is(.kb-icon-btn, .kb-btn-icon, .btn-icon)):hover { background: var(--kb-surface-2); color: var(--kb-ink); box-shadow: none; }
:is(.kb-dialog-x > .kb-icon-btn, .filter-modal .filter-modal-close, .page-overlay-close, .ke-close, :is(.kal-modal-head, .bills-modal-head, .paygen-modal-head, .filter-modal-header, [data-slot="dialog-content"] > header) :is(.kb-icon-btn, .kb-btn-icon, .btn-icon)):active { background: var(--kb-surface-3); }
:is(.kb-dialog-x > .kb-icon-btn, .filter-modal .filter-modal-close, .page-overlay-close, .ke-close, :is(.kal-modal-head, .bills-modal-head, .paygen-modal-head, .filter-modal-header, [data-slot="dialog-content"] > header) :is(.kb-icon-btn, .kb-btn-icon, .btn-icon)):focus-visible { outline: 3px solid var(--kb-coral-text); outline-offset: 2px; }
:is(.kb-dialog-x > .kb-icon-btn, .filter-modal .filter-modal-close, .page-overlay-close, .ke-close, :is(.kal-modal-head, .bills-modal-head, .paygen-modal-head, .filter-modal-header, [data-slot="dialog-content"] > header) :is(.kb-icon-btn, .kb-btn-icon, .btn-icon)) :is(svg, .kb-ico) { display: block; inline-size: var(--kb-sp-4); block-size: var(--kb-sp-4); }
/* DA2 Z5: dark. A neutral kit icon button (no tone of its own or from a parent, or tone neutral)
   filled with --kb-neutral-fill on hover (kal-bright.css:417), which is a LIGHT fill in dark: a
   pale square lit up under the pointer. In dark it takes the next surface step instead, ink icon.
   The ghost close x keeps its own hover (surface-2, the one close-x look above). */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) .kb-icon-btn:is(:not([data-tone]):not([data-tone] *), [data-tone="neutral"], [data-tone="neutral"] *):not(.kb-dialog-x > *, .ke-close, :is(.kal-modal-head, .bills-modal-head, .paygen-modal-head, .filter-modal-header, [data-slot="dialog-content"] > header) *):hover { background: var(--kb-surface-3); color: var(--kb-ink); }
}
[data-theme="dark"] .kb-icon-btn:is(:not([data-tone]):not([data-tone] *), [data-tone="neutral"], [data-tone="neutral"] *):not(.kb-dialog-x > *, .ke-close, :is(.kal-modal-head, .bills-modal-head, .paygen-modal-head, .filter-modal-header, [data-slot="dialog-content"] > header) *):hover { background: var(--kb-surface-3); color: var(--kb-ink); }
/* The overlay's x sits on the iframe page's band: 16px in from the dialog's corner, like kb/dialog. */
.page-overlay-close { position: absolute; inset-block-start: 16px; inset-inline-end: 16px; z-index: 2; }
[data-kb-has-x] > [data-slot="dialog-title"], ui-dialog-content[data-kb-has-x] > ui-dialog-title { padding-inline-end: var(--kb-sp-10); }
[data-slot="dialog-content"] > .kb-actions { justify-content: flex-start; flex-wrap: wrap; }

/* ── Modals (= the kit's dialog) ── */
.kal-modal-backdrop, .bills-modal-backdrop, .paygen-modal-backdrop { background: var(--kb-backdrop); }
.kal-modal-panel, .bills-modal-panel, .paygen-modal-card {
  border: 0; border-radius: 24px; padding: var(--kb-sp-6);
  background: var(--kb-surface); color: var(--kb-ink); box-shadow: var(--kb-shadow-3);
}
/* DA2 X7: a modal title is ink, like the kit dialog title (style.css:4501 made it coral). */
.kal-modal-head h3, .bills-modal-head h3 { color: var(--kb-ink); font-size: var(--kb-fs-2xl); font-weight: 800; letter-spacing: -0.02em; }
/* DA3 K1 (D1): a KALConfirm question (kal-confirm.js marks it data-kal-confirm and puts OK first)
   reads like the kit confirm: primary first, then Cancel, at the LEFT; the close x top right. */
.kal-modal[data-kal-confirm] .kal-modal-actions, .ke-modal .kal-modal-actions { justify-content: flex-start; } /* DA3 X5: Email Kathy footer at the left, primary first (D61) */
.kal-modal[data-kal-confirm] .kal-modal-head { align-items: flex-start; }

/* ── Alerts and banners ── */
/* DA2 M13: .alert is ONE kit note (the kit's .kb-caution look): the tone's wash, ink text, a 4px tone
   edge on the left (a background strip, so the rounded corner clips it straight, no crescent).
   Tones: info = sky, success = leaf (good), warning = sun, error / danger = coral (bad); no tone = neutral. */
.alert {
  --kb-note-tone: var(--kb-edge); --kb-note-wash: var(--kb-neutral-wash);
  padding: var(--kb-sp-3) var(--kb-sp-4) var(--kb-sp-3) var(--kb-sp-5); border: 0; border-radius: 14px;
  background: linear-gradient(to right, var(--kb-note-tone) 4px, var(--kb-note-wash) 4px);
  color: var(--kb-ink); font-size: var(--kb-fs-md); font-weight: 600; line-height: 1.45;
}
.alert-info { --kb-note-tone: var(--kb-sky); --kb-note-wash: var(--kb-sky-wash); }
.alert-success { --kb-note-tone: var(--kb-leaf); --kb-note-wash: var(--kb-leaf-wash); }
.alert-warning { --kb-note-tone: var(--kb-sun); --kb-note-wash: var(--kb-sun-wash); }
.alert-error, .alert-danger { --kb-note-tone: var(--kb-coral); --kb-note-wash: var(--kb-coral-wash); }
:is(.alert-info, .alert-success, .alert-warning, .alert-error, .alert-danger) {
  background: linear-gradient(to right, var(--kb-note-tone) 4px, var(--kb-note-wash) 4px); color: var(--kb-ink); border-color: transparent;
}
.alert a:not(.btn):not(.kb-btn) { color: inherit; font-weight: 700; text-decoration: underline; text-underline-offset: 2px; }
.alert strong { color: var(--kb-ink); font-weight: 800; }
.sysalert-bar { color: var(--kb-primary-ink); font-weight: 600; }
.sysalert-bar-link { color: var(--kb-primary-ink); }
.impersonation-banner { color: var(--kb-primary-ink); border-bottom: 0; box-shadow: none; }
.impersonation-banner-btn, .impersonation-banner .btn.btn-sm { background: var(--kb-surface); color: var(--kb-ink); box-shadow: none; border: 0; }
.impersonation-banner-btn:hover, .impersonation-banner .btn.btn-sm:hover { background: var(--kb-surface-2); color: var(--kb-ink); }

/* ── Toasts (B1 / DA1 H7): tone edge on the left, icon, text, close button. Error = danger tone +
   alert icon (stays 8 s, set in toast.js); success = good tone + tick; info = neutral. ── */
/* z-index stays 10000 (style.css): today's modals sit at 2500-9999, so a lower toast layer would hide
   behind an open dialog. Move to --kb-z-toast only when the dialogs move to the kit z scale (DA1 C3). */
.kal-toast {
  --kal-toast-tone: var(--kb-muted);
  position: relative; overflow: hidden; border: 0; border-radius: var(--kb-radius-md); box-shadow: var(--kb-shadow-3);
  background: var(--kb-surface); color: var(--kb-ink); font-weight: 600;
  padding: var(--kb-sp-3) var(--kb-sp-2) var(--kb-sp-3) 18px; display: flex; gap: var(--kb-sp-2h); align-items: center;
}
/* X4: the tone edge is a straight 4px bar clipped by the rounded box, not a border (which curved into a crescent). */
.kal-toast::before { content: ""; position: absolute; inset-block: 0; inset-inline-start: 0; inline-size: 4px; background: var(--kal-toast-tone); }
@media (max-width: 760px) {
  #kal-toast-stack { inset-inline: 16px; inset-inline-end: 16px; right: var(--kb-sp-4); left: var(--kb-sp-4); max-inline-size: none; align-items: center; }
  #kal-toast-stack .kal-toast { inline-size: 100%; max-inline-size: 420px; box-sizing: border-box; }
}
.kal-toast--success { --kal-toast-tone: var(--kb-toast-ok, var(--kb-leaf-text)); }
.kal-toast--error { --kal-toast-tone: var(--kb-toast-bad, var(--kb-coral-text)); }
.kal-toast--warning { --kal-toast-tone: var(--kb-sun); }
.kal-toast--info { --kal-toast-tone: var(--kb-toast-info, var(--kb-muted)); }
.kal-toast-ico { flex: none; display: inline-grid; place-items: center; inline-size: 20px; block-size: 20px; color: var(--kal-toast-tone); }
.kal-toast--warning .kal-toast-ico { color: var(--kb-ink); }
.kal-toast-text { flex: 1; min-inline-size: 0; overflow-wrap: anywhere; }
.kal-toast-close {
  flex: none; display: inline-grid; place-items: center; inline-size: 28px; block-size: 28px; padding: 0; margin: 0;
  border: 0; border-radius: var(--kb-radius-sm); background: transparent; color: var(--kb-muted); cursor: pointer; box-shadow: none;
}
.kal-toast-close:hover { background: var(--kb-surface-2); color: var(--kb-ink); }
.kal-toast-close:focus-visible { outline: 3px solid var(--kb-coral-text); outline-offset: 2px; }

/* ── Rich-text editors (Quill 1.3.7, public/vendor/quill, never edited) on the kit (UF1 ACT-07 /
   FIN-22 / ST-28 / AD3): kit font and size, the 1.5px kit edge, 12px radius, a quiet toolbar strip,
   kit picker menus. Tokens only, so dark mode follows (the old dark.css Quill block is gone).
   quill.snow.css loads AFTER this file (layouts/main.ejs), so every rule carries `:root` for the
   one extra class of specificity it needs. ── */
:root .ql-toolbar.ql-snow {
  box-sizing: border-box; padding: var(--kb-sp-1h) var(--kb-sp-2); border: 0; border-radius: var(--kb-radius-ctl) var(--kb-radius-ctl) 0 0;
  background: var(--kb-surface-2); font-family: var(--kb-font);
  box-shadow: inset 1.5px 0 0 var(--kb-edge), inset -1.5px 0 0 var(--kb-edge), inset 0 1.5px 0 var(--kb-edge), inset 0 -1px 0 var(--kb-line);
}
:root .ql-container.ql-snow, :root .ql-toolbar.ql-snow + .ql-container.ql-snow {
  border: 0; border-radius: 0 0 var(--kb-radius-ctl) var(--kb-radius-ctl);
  background: var(--kb-surface); color: var(--kb-ink);
  box-shadow: inset 1.5px 0 0 var(--kb-edge), inset -1.5px 0 0 var(--kb-edge), inset 0 -1.5px 0 var(--kb-edge);
}
/* Quill puts the toolbar and the mount (which becomes .ql-container) side by side in the field, and
   .form-group is a flex column with a 0.35rem gap (style.css), which split the box in two with a
   ~6px blank strip. Pull the container back up by that gap. */
:root .form-group > .ql-toolbar.ql-snow + .ql-container.ql-snow { margin-block-start: -0.35rem; }
/* A read-only editor has no toolbar: the container is the whole box. */
:root .ql-container.ql-snow:not(.ql-toolbar + .ql-container) { border-radius: var(--kb-radius-ctl); box-shadow: inset 0 0 0 1.5px var(--kb-edge); }
:root .ql-container { font-family: var(--kb-font); font-size: var(--kb-fs-lg); }
:root .ql-editor { padding: var(--kb-sp-3) 14px; color: var(--kb-ink); font-size: var(--kb-fs-lg); line-height: 1.55; }
:root .ql-editor.ql-blank::before { left: 14px; right: 14px; color: var(--kb-muted); font-style: normal; }
:root .ql-snow .ql-stroke { stroke: var(--kb-ink); }
:root .ql-snow .ql-fill, :root .ql-snow .ql-stroke.ql-fill { fill: var(--kb-ink); }
:root .ql-snow .ql-picker { color: var(--kb-ink); font-weight: 700; }
/* appearance + font: the browser's button look and font counted as native controls (UF1 FIN-22). */
:root .ql-snow.ql-toolbar button, :root .ql-snow .ql-toolbar button { appearance: none; border-radius: var(--kb-radius-sm); font: inherit; }
:root .ql-snow.ql-toolbar :is(button:hover, button:focus-visible, button.ql-active, .ql-picker-label:hover, .ql-picker-label.ql-active, .ql-picker-item:hover, .ql-picker-item.ql-selected) { color: var(--kb-coral-text); }
:root .ql-snow.ql-toolbar :is(button:hover, button.ql-active) { background: var(--kb-surface-3); }
:root .ql-snow.ql-toolbar :is(button:hover, button:focus-visible, button.ql-active, .ql-picker-label:hover, .ql-picker-label.ql-active) .ql-stroke { stroke: var(--kb-coral-text); }
:root .ql-snow.ql-toolbar :is(button:hover, button:focus-visible, button.ql-active) .ql-fill { fill: var(--kb-coral-text); }
:root .ql-snow .ql-picker.ql-expanded .ql-picker-label { border-color: transparent; color: var(--kb-ink); }
:root .ql-snow .ql-picker-options, :root .ql-snow .ql-picker.ql-expanded .ql-picker-options {
  padding: var(--kb-sp-1h); border: 0; border-radius: 14px; background: var(--kb-surface); box-shadow: var(--kb-shadow-3);
}
:root .ql-snow .ql-tooltip { border: 0; border-radius: 14px; background: var(--kb-surface); color: var(--kb-ink); box-shadow: var(--kb-shadow-3); }
:root .ql-snow .ql-tooltip input[type="text"] { block-size: 34px; border: 0; border-radius: 10px; background: var(--kb-surface-2); color: var(--kb-ink); box-shadow: inset 0 0 0 1.5px var(--kb-edge); }
:root .ql-snow .ql-editor a, :root .ql-snow a { color: var(--kb-coral-text); }
:root .ql-snow .ql-editor :is(code, pre) { background: var(--kb-surface-2); color: var(--kb-ink); }
:root .ql-snow .ql-editor blockquote { border-left-color: var(--kb-edge-quiet); }
:root .form-group.has-error .ql-toolbar + .ql-container.ql-snow { box-shadow: inset 2px 0 0 var(--kb-coral-text), inset -2px 0 0 var(--kb-coral-text), inset 0 -2px 0 var(--kb-coral-text); }
/* DA3 K3: the error edge runs round the WHOLE editor, toolbar included. */
:root .form-group.has-error .ql-toolbar.ql-snow { box-shadow: inset 2px 0 0 var(--kb-coral-text), inset -2px 0 0 var(--kb-coral-text), inset 0 2px 0 var(--kb-coral-text), inset 0 -1px 0 var(--kb-line); }
/* DA3 K3 (D2): focus = the one ring OUTSIDE the whole editor (toolbar + text box), 3px coral, 2px
   off, like every field; the edge itself stays as it is (normal or the red error edge). Quill puts
   the toolbar and the box side by side with no common wrapper, so each draws its half of the ring:
   the toolbar the top and sides, the box the sides and bottom; they meet at the seam. Quill's
   own toolbar ::after is its float clearfix, so the ring is ::before. */
:root .ql-toolbar.ql-snow { position: relative; }
:root .ql-toolbar.ql-snow:has(:focus-visible)::before,
:root .ql-toolbar.ql-snow:has(+ .ql-container .ql-editor:focus)::before,
:root .ql-toolbar.ql-snow + .ql-container.ql-snow:has(.ql-editor:focus)::before,
:root .ql-toolbar.ql-snow:has(:focus-visible) + .ql-container.ql-snow::before { content: ""; }
/* The two halves' shape (drawn only while the rules above give them content). */
:root .ql-toolbar.ql-snow::before, :root .ql-toolbar.ql-snow + .ql-container.ql-snow::before {
  position: absolute; pointer-events: none; z-index: 1; box-sizing: border-box;
  border: 0 solid var(--kb-coral-text);
}
:root .ql-toolbar.ql-snow::before { inset: -5px -5px 0; border-width: 3px 3px 0; border-radius: calc(var(--kb-radius-ctl) + 5px) calc(var(--kb-radius-ctl) + 5px) 0 0; }
:root .ql-toolbar.ql-snow + .ql-container.ql-snow::before { inset: 0 -5px -5px; border-width: 0 3px 3px; border-radius: 0 0 calc(var(--kb-radius-ctl) + 5px) calc(var(--kb-radius-ctl) + 5px); }
/* DA3 K6: the heading picker shows the kit chevron (ui-select's glyph), not Quill's up/down arrows. */
:root .ql-snow .ql-picker:not(.ql-color-picker):not(.ql-icon-picker) .ql-picker-label svg { display: none; }
:root .ql-snow .ql-picker:not(.ql-color-picker):not(.ql-icon-picker) .ql-picker-label { padding-inline-end: 22px; }
:root .ql-snow .ql-picker:not(.ql-color-picker):not(.ql-icon-picker) .ql-picker-label::after {
  content: ""; position: absolute; inset-inline-end: 2px; inset-block-start: 50%; inline-size: 16px; block-size: 16px; margin-block-start: -8px;
  background: currentColor; -webkit-mask: var(--ui-icon-chevron) center / contain no-repeat; mask: var(--ui-icon-chevron) center / contain no-repeat;
}
:root .ql-snow .ql-picker.ql-expanded .ql-picker-label::after { rotate: 180deg; }

/* ── Pagination ── */
/* DA2 M4: the pager's buttons are the kit's small buttons (32px, = .kb-btn-sm) with the kit hover; the
   current page / page size is the coral fill (aria-current). partials/pagination.ejs marks a one-page
   list [hidden]: style.css's display:flex would otherwise show it. */
.pagination-bar { border-top: 0; }
.pagination-bar[hidden] { display: none; }
.pagination-info { color: var(--kb-muted); font-size: var(--kb-fs-md); font-weight: 600; }
.pagination-info strong { color: var(--kb-ink); font-weight: 800; }
.pagination-size { color: var(--kb-muted); font-size: var(--kb-fs-md); font-weight: 600; }
.pagination-controls, .pagination-size { gap: var(--kb-sp-1h); }
.pagination-controls .btn.btn-sm, .pagination-size .btn.btn-sm {
  box-sizing: border-box; min-width: 32px; width: auto; height: var(--kb-ctl-h-sm); min-height: var(--kb-ctl-h-sm); padding: 0 var(--kb-sp-2h);
  border: 0; border-radius: var(--kb-radius-ctl);
  background: var(--kb-surface); color: var(--kb-ink); box-shadow: inset 0 0 0 1.5px var(--kb-edge);
  font-size: var(--kb-fs-base); font-weight: 700; font-variant-numeric: tabular-nums;
}
.pagination-controls .btn.btn-sm:hover, .pagination-size .btn.btn-sm:hover { background: var(--kb-surface-2); color: var(--kb-ink); }
.pagination-controls .btn.btn-sm:active, .pagination-size .btn.btn-sm:active { background: var(--kb-surface-3); }
.pagination-controls .btn.btn-sm.btn-primary, .pagination-size .btn.btn-sm.btn-primary,
.pagination-controls .btn.btn-sm.btn-primary:is(:hover, :active), .pagination-size .btn.btn-sm.btn-primary:is(:hover, :active) {
  background: var(--kb-coral); color: var(--kb-primary-ink); box-shadow: var(--kb-shadow-fill); cursor: default;
}
@media (max-width: 760px) {
  .pagination-bar { justify-content: flex-start; }
  .pagination-controls, .pagination-size { flex-wrap: wrap; }
}

/* ── Login and standalone pages ── */
.login-page { background: transparent; }
.login-container { border: 0; border-radius: var(--kb-radius-band); box-shadow: var(--kb-shadow-3); }
.login-container::before { content: none; }
.login-header h1 { color: var(--kb-ink); font-weight: 800; }

/* ── Shared states (B1 / DA1 H3 H4 H7 M2 M6) ── */

/* Swap fade (H4): page-swap.js sets body.kal-swapping. style.css fades the whole .main-content, which
   dimmed the band and title too. Undo that and fade only what the swap replaces: the content below
   the band. The thin top bar (.kal-swap-bar) is untouched. */
body.kal-swapping .main-content { opacity: 1; }
/* X2: page-swap.js marks only the results it replaces (.kb-swapping), so tab bars, toolbars, filter
   cards and page wrappers stay at full strength. */
.kb-swapping { opacity: .55; transition: opacity .15s ease; }
@media (prefers-reduced-motion: reduce) {
  .kb-swapping { transition: none; }
}

/* Busy (H3): [aria-busy="true"] / .is-busy on .kb-btn and .btn (page-swap.js, list-live.js and
   kal-confirm.js set it, and the guard also disables the button against a double submit). Busy is
   not dead: the enabled colours stay (these selectors outweigh the kit's disabled look and its
   disabled opacity), the cursor is "progress", and a small spinner sits inside the button's own
   padding at the start edge, so the width never changes. */
/* X1: while busy the button's own label/icon is hidden (transparent text, hidden children) and the
   spinner is CENTRED, so it never covers them; width and height are unchanged. The spinner takes the
   variant's text colour from --kb-busy-ink (currentColor is transparent while busy). */
:is(.kb-btn, .btn, .filter-tab, .kb-icon-btn):is([aria-busy="true"], .is-busy) { --kb-busy-ink: var(--kb-ink); position: relative; cursor: progress; opacity: 1; pointer-events: none; }
:is(.kb-btn-primary, .btn-primary, .btn-success):is([aria-busy="true"], .is-busy) { --kb-busy-ink: var(--kb-primary-ink); }
:is(.kb-btn-danger, .btn-danger-outline):is([aria-busy="true"], .is-busy) { --kb-busy-ink: var(--kb-coral-text); }
:is(.btn-icon, .btn-dark, .kb-icon-btn):is([aria-busy="true"], .is-busy) { --kb-busy-ink: var(--kb-tone-text, var(--kb-ink)); }
:is(.kb-btn, .btn, .filter-tab, .kb-icon-btn):is([aria-busy="true"], .is-busy)::after {
  content: ""; position: absolute; inset-inline-start: 50%; inset-block-start: 50%;
  inline-size: 14px; block-size: 14px; margin-inline-start: -7px; margin-block-start: -7px; box-sizing: border-box;
  border: 2px solid var(--kb-busy-ink); border-inline-end-color: transparent; border-radius: 50%;
  animation: kb-portal-spin .8s linear infinite;
}
:is(.kb-btn, .btn, .filter-tab, .kb-icon-btn):is([aria-busy="true"], .is-busy):not(#kb-busy) { color: transparent; }
:is(.kb-btn, .btn, .filter-tab, .kb-icon-btn):is([aria-busy="true"], .is-busy) > * { visibility: hidden; }
@keyframes kb-portal-spin { to { rotate: 360deg; } }
@media (prefers-reduced-motion: reduce) {
  :is(.kb-btn, .btn, .filter-tab, .kb-icon-btn):is([aria-busy="true"], .is-busy)::after { animation-duration: 2.4s; }
}
/* Busy and disabled together: re-state each variant's enabled look. :is(:hover, :not(:hover)) adds
   one class of weight so hover changes nothing either. */
:is(.kb-btn, .btn):is([aria-busy="true"], .is-busy):is(:disabled, [aria-disabled="true"]):is(:hover, :not(:hover)) {
  opacity: 1; cursor: progress; background: var(--kb-surface); color: var(--kb-ink); box-shadow: inset 0 0 0 1.5px var(--kb-edge);
}
:is(.kb-btn-primary, .btn-primary):is([aria-busy="true"], .is-busy):is(:disabled, [aria-disabled="true"]):is(:hover, :not(:hover)) {
  background: var(--kb-coral); color: var(--kb-primary-ink); box-shadow: var(--kb-shadow-fill);
}
.btn-success:is([aria-busy="true"], .is-busy):is(:disabled, [aria-disabled="true"]):is(:hover, :not(:hover)) { background: var(--kb-leaf); color: var(--kb-primary-ink); box-shadow: none; }
:is(.kb-btn-danger, .btn-danger-outline):is([aria-busy="true"], .is-busy):is(:disabled, [aria-disabled="true"]):is(:hover, :not(:hover)) {
  background: transparent; color: var(--kb-coral-text); box-shadow: inset 0 0 0 1.5px var(--kb-coral-text);
}
.kb-btn-ghost:is([aria-busy="true"], .is-busy):is(:disabled, [aria-disabled="true"]):is(:hover, :not(:hover)) { background: transparent; color: var(--kb-ink); box-shadow: none; }
:is(.btn-icon, .btn-dark, .kb-icon-btn):is([aria-busy="true"], .is-busy):is(:disabled, [aria-disabled="true"]):is(:hover, :not(:hover)) {
  background: var(--kb-tone-wash, var(--kb-surface-2)); color: var(--kb-tone-text, var(--kb-ink)); box-shadow: none;
}

/* Focus (M2): the one ring is a 3px coral-text outline, 2px off. The checkbox / radio rule above sits
   in :where() (zero weight) and lost to style.css on some pages, so it is repeated here with weight. */
input[type="checkbox"]:not([data-slot]):focus-visible, input[type="radio"]:not([data-slot]):focus-visible { outline: 3px solid var(--kb-coral-text); outline-offset: 2px; }

/* Field error (M6): red edge on the field + one small message style. Native validation bubbles are
   out of scope. :user-invalid only fires after the person has touched the field. */
:where(input, select, textarea):not([data-slot]):is([aria-invalid="true"], :user-invalid, .is-invalid),
.has-error > :where(input, select, textarea):not([data-slot]) {
  box-shadow: inset 0 0 0 2px var(--kb-coral-text); background-color: var(--kb-surface); border-color: transparent;
}
:where(input, select, textarea):not([data-slot]):is([aria-invalid="true"], :user-invalid, .is-invalid):focus-visible {
  box-shadow: inset 0 0 0 2px var(--kb-coral-text); outline: 3px solid var(--kb-coral-text); outline-offset: 2px;
}
.kb-field-error { display: flex; align-items: flex-start; gap: var(--kb-sp-1h); margin: var(--kb-sp-1) 0 0; color: var(--kb-coral-text); font-size: var(--kb-fs-base); font-weight: 600; line-height: 1.35; }
.kb-field-error :is(.kb-ico, svg) { flex: none; inline-size: 14px; block-size: 14px; margin-block-start: var(--kb-sp-half); }

/* X3: the same red edge on the kit's fields. A kit field draws its edge on a wrapper or on the
   element carrying data-slot, so aria-invalid is matched on the element, its field/group wrapper or
   any date segment. */
[data-slot]:not([data-slot="select"], ui-select)[aria-invalid="true"],
.kb-field:has([aria-invalid="true"]),
ui-input-group:has([aria-invalid="true"]),
:is(ui-date-input, [data-slot="date-input"]):is([aria-invalid="true"], :has([aria-invalid="true"])),
ui-select:has([aria-invalid="true"]) :is(ui-select-trigger, [data-slot="select-trigger"]),
ui-select[aria-invalid="true"] :is(ui-select-trigger, [data-slot="select-trigger"]) {
  box-shadow: inset 0 0 0 2px var(--kb-coral-text); border-color: transparent;
}
:is(.kb-field, ui-input-group, ui-date-input, [data-slot="date-input"], [data-slot="input-group"]):is([aria-invalid="true"], :has([aria-invalid="true"])):focus-within {
  box-shadow: inset 0 0 0 2px var(--kb-coral-text); outline: 3px solid var(--kb-coral-text); outline-offset: 2px;
}
/* DA3 K3 (D2): a focused kit field (kal-bright.css drew a coral edge + wash, the error look) keeps
   its normal edge and takes the one ring outside. The error rule above outweighs this one. */
.kb-field:has(input:focus-visible) { box-shadow: inset 0 0 0 1.5px var(--kb-edge); outline: 3px solid var(--kb-coral-text); outline-offset: 2px; }
/* An input inside an invalid group must not draw a second edge, focused or not (the group shows
   the focus halo through :focus-within). */
:is(.kb-field, ui-input-group, [data-slot="input-group"], ui-date-input, [data-slot="date-input"]):has([aria-invalid="true"]) :is(input, [data-slot="input"]):not(#kb-x) { box-shadow: none; }
/* Page CSS that draws a date field's edge with more weight (list-kb.css .kbf-date) must still show
   the red edge: :root lifts this one rule above it. */
:root :is(ui-date-input, [data-slot="date-input"]):is([aria-invalid="true"], :has([aria-invalid="true"])):not(:focus-within) { box-shadow: inset 0 0 0 2px var(--kb-coral-text); }
/* A busy ui-select filter (page-swap.js sets aria-busy / .is-busy on the root) shows the same
   centred spinner on its trigger; label and chevron hidden, size unchanged. Only the trigger BUTTON
   ([data-slot]) is matched: it is itself a child of ui-select-trigger, so "> *" on the wrapper hid it. */
ui-select:is([aria-busy="true"], .is-busy) [data-slot="select-trigger"] { position: relative; cursor: progress; pointer-events: none; }
ui-select:is([aria-busy="true"], .is-busy) [data-slot="select-trigger"]:not(#kb-busy) { color: transparent; }
ui-select:is([aria-busy="true"], .is-busy) [data-slot="select-trigger"] > * { visibility: hidden; }
ui-select:is([aria-busy="true"], .is-busy) [data-slot="select-trigger"]::after {
  content: ""; position: absolute; inset-inline-start: 50%; inset-block-start: 50%;
  inline-size: 14px; block-size: 14px; margin-inline-start: -7px; margin-block-start: -7px; box-sizing: border-box;
  border: 2px solid var(--kb-ink); border-inline-end-color: transparent; border-radius: 50%;
  animation: kb-portal-spin .8s linear infinite;
}
@media (prefers-reduced-motion: reduce) {
  ui-select:is([aria-busy="true"], .is-busy) [data-slot="select-trigger"]::after { animation-duration: 2.4s; }
}

/* X5: colour input gets the kit ring. (The Quill editor's focus is the outside ring in the
   rich-text block above, DA3 K3; its edge no longer turns coral on focus.) */
input[type="color"]:focus-visible { outline: 3px solid var(--kb-coral-text); outline-offset: 2px; }
