/* COPY of the KAL brand kit (OneDrive - KAL Child Care/Logos/brand-kit, kit 2026.11.09-1, ui/ as on disk 2026-11-21, source md5 0bd43801). Edit the KIT, then copy again. Never edit this copy. */
@layer ui-sdk;

/*
  KAL Bright UI. One stylesheet for every KAL app.
  1 tokens (light, dark, OS default)  2 area theming  3 ui-sdk restyles  4 KAL patterns (kb-*)
  Load after ui-sdk's web.css and ../brand-kit.css. Pages hold layout only, never colours.
*/

/* ===================== 1. Tokens ===================== */
/* data-theme="light|dark" on <html> forces a theme; none follows the OS. It also works on any
   element (a scoped panel), which is how the gallery shows both themes side by side. */
:root, [data-theme="light"] {
  color-scheme: light;

  --kb-font: "Nunito Sans", ui-sans-serif, system-ui, sans-serif;

  --kb-canvas: #FFFFFF;
  --kb-canvas-top: #FFF9F4;
  --kb-surface: #FFFFFF;
  --kb-surface-2: #FBF7F3;
  --kb-surface-3: #F3ECE6;
  --kb-ink: #2B2520;           /* 15.13:1 on surface */
  --kb-muted: #6B5F57;         /* 6.18:1 on surface */
  --kb-line: #F1EAE4;
  --kb-edge: #8F8279;          /* 3.73:1 on surface */
  --kb-edge-quiet: #E4DAD2;
  --kb-primary-ink: #2B2520;   /* text on every brand fill, both themes */

  --kb-coral: #FF5E3F;
  --kb-coral-hover: #FF6E52;
  --kb-coral-text: #B8361A;
  --kb-coral-wash: #FFEDE8;
  --kb-sun: #FFC94A;
  --kb-sun-text: #7A5200;
  --kb-sun-wash: #FFF4D6;
  --kb-sky: #5AC8E6;
  --kb-sky-text: #1D6A80;
  --kb-sky-wash: #E3F6FB;
  --kb-leaf: #7CC27A;
  --kb-leaf-text: #2F6B2E;
  --kb-leaf-wash: #E8F5E7;
  --kb-grape: #9B7BD4;
  --kb-grape-fill: #C2AFE5;    /* grape lifted so ink text clears 4.5:1 */
  --kb-grape-text: #6E4FB0;
  --kb-grape-wash: #EFE9FA;
  --kb-bubble: #FFB6C6;
  --kb-bubble-text: #A8324F;
  --kb-bubble-wash: #FFEEF2;
  --kb-neutral-fill: #EFE8E2;
  --kb-neutral-wash: #F7F2EE;
  --kb-neutral-dot: #8F8279;   /* neutral-fill vanishes as a small dot on white; dark keeps the fill */

  --kb-row-hover: #FFFCF6;
  --kb-row-picked: #FFF6F3;
  --kb-band-hi: 34%;
  --kb-band-lo: 12%;
  --kb-blob-alpha: 0.26;
  --kb-glass: rgb(255 255 255 / 0.78);
  /* Solid, like dark: a see-through bar smeared the coloured page behind the logo (UF1 SH3). */
  --kb-topbar-bg: #FFFFFF;
  --kb-topbar-filter: none;
  --kb-backdrop: rgb(43 37 32 / 0.32);
  --kb-centre-mix: 100%;

  --kb-shadow-1: 0 1px 2px rgb(92 52 28 / 0.06), 0 4px 14px -4px rgb(120 64 30 / 0.10);
  --kb-shadow-2: 0 1px 2px rgb(92 52 28 / 0.05), 0 10px 30px -10px rgb(120 64 30 / 0.18), 0 2px 6px -2px rgb(120 64 30 / 0.06);
  --kb-shadow-3: 0 2px 4px rgb(92 52 28 / 0.06), 0 24px 60px -16px rgb(120 64 30 / 0.28), 0 0 0 1px rgb(92 52 28 / 0.05);
  --kb-shadow-fill: 0 6px 16px -6px rgb(255 94 63 / 0.6);
  --kb-shadow-lift: 0 14px 28px -16px rgb(120 64 30 / 0.45);

  --kb-radius-ctl: 12px;
  --kb-radius-card: 20px;
  --kb-radius-band: 28px;
  --kb-radius-sm: 8px;
  --kb-radius-md: 16px;

  /* Scales (D-audit 2026-11-21): today's most-used values, so adopting them changes nothing. */
  --kb-fs-2xs: 10px; --kb-fs-xs: 11px; --kb-fs-sm: 12px; --kb-fs-base: 13px; --kb-fs-md: 14px;
  --kb-fs-lg: 15px; --kb-fs-xl: 18px; --kb-fs-2xl: 22px; --kb-fs-3xl: 24px; --kb-fs-4xl: 30px;
  --kb-sp-half: 2px; --kb-sp-1: 4px; --kb-sp-1h: 6px; --kb-sp-2: 8px; --kb-sp-2h: 10px; --kb-sp-3: 12px;
  --kb-sp-4: 16px; --kb-sp-5: 20px; --kb-sp-6: 24px; --kb-sp-8: 32px; --kb-sp-10: 40px;
  --kb-z-sticky: 20; --kb-z-bar: 30; --kb-z-rail: 40; --kb-z-drawer: 100; --kb-z-dialog: 200; --kb-z-toast: 300; --kb-z-guide: 400;
  --kb-ctl-h: 42px; --kb-ctl-h-sm: 32px;
  --kb-radius-pill: 999px;

  --kb-dur-fast: 200ms;
  --kb-dur-move: 280ms;
  --kb-ease: cubic-bezier(0.2, 0.7, 0.2, 1);
  --kb-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    color-scheme: dark;
    --kb-canvas: #16120F; --kb-canvas-top: #1A1512; --kb-surface: #211B17; --kb-surface-2: #2A231E; --kb-surface-3: #342B25;
    --kb-ink: #F6EFE9; --kb-muted: #B9ACA2; --kb-line: #352D27; --kb-edge: #8A7C72; --kb-edge-quiet: #4A4039;
    --kb-coral-hover: #FF7458; --kb-coral-text: #FF8A70; --kb-coral-wash: #3A2420;
    --kb-sun-text: #FFC94A; --kb-sun-wash: #3A3020; --kb-sky-text: #7FD6EE; --kb-sky-wash: #1F3238;
    --kb-leaf-text: #9BD699; --kb-leaf-wash: #24301F; --kb-grape-text: #C3AEEA; --kb-grape-wash: #2E2738;
    --kb-bubble-text: #FFC2CF; --kb-bubble-wash: #3A2A2D; --kb-neutral-fill: #DCD2CA; --kb-neutral-wash: #2A231E; --kb-neutral-dot: #DCD2CA;
    --kb-row-hover: #262019; --kb-row-picked: #33231E;
    --kb-band-hi: 20%; --kb-band-lo: 7%; --kb-blob-alpha: 0.10;
    --kb-glass: rgb(42 35 30 / 0.85); --kb-topbar-bg: #1C1714; --kb-topbar-filter: none; --kb-backdrop: rgb(0 0 0 / 0.55);
    --kb-centre-mix: 60%;
    --kb-shadow-1: inset 0 1px 0 rgb(255 255 255 / 0.05), 0 1px 2px rgb(0 0 0 / 0.35);
    --kb-shadow-2: inset 0 1px 0 rgb(255 255 255 / 0.06), 0 8px 24px -12px rgb(0 0 0 / 0.6);
    --kb-shadow-3: inset 0 1px 0 rgb(255 255 255 / 0.07), 0 0 0 1px rgb(255 255 255 / 0.06), 0 20px 44px -14px rgb(0 0 0 / 0.7);
    --kb-shadow-fill: 0 4px 12px -6px rgb(0 0 0 / 0.6);
    --kb-shadow-lift: inset 0 1px 0 rgb(255 255 255 / 0.06), 0 12px 24px -14px rgb(0 0 0 / 0.7);
  }
}
[data-theme="dark"] {
  color-scheme: dark;
  --kb-canvas: #16120F; --kb-canvas-top: #1A1512; --kb-surface: #211B17; --kb-surface-2: #2A231E; --kb-surface-3: #342B25;
  --kb-ink: #F6EFE9; --kb-muted: #B9ACA2; --kb-line: #352D27; --kb-edge: #8A7C72; --kb-edge-quiet: #4A4039;
  --kb-coral-hover: #FF7458; --kb-coral-text: #FF8A70; --kb-coral-wash: #3A2420;
  --kb-sun-text: #FFC94A; --kb-sun-wash: #3A3020; --kb-sky-text: #7FD6EE; --kb-sky-wash: #1F3238;
  --kb-leaf-text: #9BD699; --kb-leaf-wash: #24301F; --kb-grape-text: #C3AEEA; --kb-grape-wash: #2E2738;
  --kb-bubble-text: #FFC2CF; --kb-bubble-wash: #3A2A2D; --kb-neutral-fill: #DCD2CA; --kb-neutral-wash: #2A231E; --kb-neutral-dot: #DCD2CA;
  --kb-row-hover: #262019; --kb-row-picked: #33231E;
  --kb-band-hi: 20%; --kb-band-lo: 7%; --kb-blob-alpha: 0.10;
  --kb-glass: rgb(42 35 30 / 0.85); --kb-topbar-bg: #1C1714; --kb-topbar-filter: none; --kb-backdrop: rgb(0 0 0 / 0.55);
  --kb-centre-mix: 60%;
  --kb-shadow-1: inset 0 1px 0 rgb(255 255 255 / 0.05), 0 1px 2px rgb(0 0 0 / 0.35);
  --kb-shadow-2: inset 0 1px 0 rgb(255 255 255 / 0.06), 0 8px 24px -12px rgb(0 0 0 / 0.6);
  --kb-shadow-3: inset 0 1px 0 rgb(255 255 255 / 0.07), 0 0 0 1px rgb(255 255 255 / 0.06), 0 20px 44px -14px rgb(0 0 0 / 0.7);
  --kb-shadow-fill: 0 4px 12px -6px rgb(0 0 0 / 0.6);
  --kb-shadow-lift: inset 0 1px 0 rgb(255 255 255 / 0.06), 0 12px 24px -14px rgb(0 0 0 / 0.7);
}

/* ui-sdk's own tokens follow ours, so its defaults match in both themes (re-resolved in scoped panels) */
:root, [data-theme] {
  --ui-background: var(--kb-surface);
  --ui-foreground: var(--kb-ink);
  --ui-muted: var(--kb-surface-2);
  --ui-muted-foreground: var(--kb-muted);
  --ui-border: var(--kb-line);
  --ui-input: var(--kb-edge);
  --ui-primary: var(--kb-coral);
  --ui-primary-foreground: var(--kb-primary-ink);
  --ui-ring: var(--kb-coral-wash);
  --ui-ring-border: var(--kb-coral-text);
  --ui-destructive: var(--kb-coral-text);
  --ui-overlay: var(--kb-backdrop);
  --ui-shadow: var(--kb-shadow-3);
  --ui-radius: 12px;
  --ui-font-sans: var(--kb-font);
  --ui-font-size: 0.875rem;
  /* Toast tones: variables here, so a scoped dark panel re-resolves them */
  --kb-toast-ok: var(--kb-leaf-text); --kb-toast-bad: var(--kb-coral-text); --kb-toast-info: var(--kb-muted);
}

/* ===================== 2. Tones and areas ===================== */
/* A tone is a colour job: fill (with ink text), wash (quiet background) and text (on wash or surface). */
[data-tone="sun"]     { --kb-tone: var(--kb-sun);    --kb-tone-text: var(--kb-sun-text);    --kb-tone-wash: var(--kb-sun-wash); }
[data-tone="sky"]     { --kb-tone: var(--kb-sky);    --kb-tone-text: var(--kb-sky-text);    --kb-tone-wash: var(--kb-sky-wash); }
[data-tone="leaf"]    { --kb-tone: var(--kb-leaf);   --kb-tone-text: var(--kb-leaf-text);   --kb-tone-wash: var(--kb-leaf-wash); }
[data-tone="coral"]   { --kb-tone: var(--kb-coral);  --kb-tone-text: var(--kb-coral-text);  --kb-tone-wash: var(--kb-coral-wash); }
[data-tone="grape"]   { --kb-tone: var(--kb-grape-fill); --kb-tone-text: var(--kb-grape-text); --kb-tone-wash: var(--kb-grape-wash); }
[data-tone="bubble"]  { --kb-tone: var(--kb-bubble); --kb-tone-text: var(--kb-bubble-text); --kb-tone-wash: var(--kb-bubble-wash); }
[data-tone="neutral"] { --kb-tone: var(--kb-neutral-fill); --kb-tone-text: var(--kb-ink); --kb-tone-wash: var(--kb-neutral-wash); }

/* An area is the top-level part of an app the page belongs to. Put data-area on <body>. A scoped data-theme panel re-reads its area so the wash matches its theme. */
:root, :where([data-theme]:not([data-area])), [data-area="action"], [data-area="action"] :where([data-theme]:not([data-area])) { --kb-area: var(--kb-coral); --kb-area-ink: var(--kb-coral-text); --kb-area-wash: var(--kb-coral-wash); }
[data-area="financial"], [data-area="financial"] :where([data-theme]:not([data-area])), [data-area="insurance"], [data-area="insurance"] :where([data-theme]:not([data-area])), [data-area="reports"], [data-area="reports"] :where([data-theme]:not([data-area])) { --kb-area: var(--kb-sun); --kb-area-ink: var(--kb-sun-text); --kb-area-wash: var(--kb-sun-wash); }
[data-area="families"], [data-area="families"] :where([data-theme]:not([data-area])) { --kb-area: var(--kb-sky); --kb-area-ink: var(--kb-sky-text); --kb-area-wash: var(--kb-sky-wash); }
[data-area="hr"], [data-area="hr"] :where([data-theme]:not([data-area])), [data-area="maintenance"], [data-area="maintenance"] :where([data-theme]:not([data-area])) { --kb-area: var(--kb-leaf); --kb-area-ink: var(--kb-leaf-text); --kb-area-wash: var(--kb-leaf-wash); }
[data-area="settings"], [data-area="settings"] :where([data-theme]:not([data-area])), [data-area="users"], [data-area="users"] :where([data-theme]:not([data-area])) { --kb-area: var(--kb-grape-fill); --kb-area-ink: var(--kb-grape-text); --kb-area-wash: var(--kb-grape-wash); }
[data-area="visitors"], [data-area="visitors"] :where([data-theme]:not([data-area])), [data-area="notices"], [data-area="notices"] :where([data-theme]:not([data-area])) { --kb-area: var(--kb-bubble); --kb-area-ink: var(--kb-bubble-text); --kb-area-wash: var(--kb-bubble-wash); }
[data-area="home"], [data-area="home"] :where([data-theme]:not([data-area])) { --kb-area: var(--kb-neutral-fill); --kb-area-ink: var(--kb-ink); --kb-area-wash: var(--kb-neutral-wash); }

/* A centre's own colour (from brand-kit.css [data-brand]), lifted in dark so it still reads on the surface */
[data-brand] { --kb-centre: color-mix(in oklab, var(--brand-primary, var(--kb-ink)) var(--kb-centre-mix), white); }

/* ===================== Base ===================== */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100vh;
  background: linear-gradient(180deg, var(--kb-canvas-top) 0, var(--kb-canvas) 420px) no-repeat, var(--kb-canvas);
  color: var(--kb-ink);
  font-family: var(--kb-font); font-size: 15px; line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow-x: clip;
}
[data-theme]:not(:root) { background: var(--kb-canvas); color: var(--kb-ink); }
h1, h2, h3, p { margin: 0; }
button, input, textarea { font: inherit; color: inherit; }
a { color: inherit; }
.kb-num { font-variant-numeric: tabular-nums; }
.kb-mono { font-variant-numeric: tabular-nums slashed-zero; letter-spacing: 0.03em; font-weight: 600; white-space: nowrap; }
.kb-muted { color: var(--kb-muted); }
.kb-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.kb-ico { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
:where(button, a, [tabindex]):focus-visible, [data-slot]:focus-visible { outline: 3px solid var(--kb-coral-text); outline-offset: 2px; }

/* ===================== 3. ui-sdk restyles ===================== */

/* Button (ui-button wraps a native button; a wrapping trigger can own data-slot, so key off data-pending) */
button:not([data-pending]) [data-show="pending"], button[data-pending] [data-show="idle"] { display: none; }
button[data-pending] .kb-spin { animation: kb-spin 0.9s linear infinite; }
@keyframes kb-spin { to { rotate: 360deg; } }

/* Tabs with a sliding colour pill (area nav).
   When the tabs do not fit (phones) the list scrolls sideways; the side that still has tabs to
   scroll to fades out, so a cut tab reads as "more this way" (scroll-driven; no fade without it). */
@property --kb-areas-fade-start { syntax: "<length>"; inherits: false; initial-value: 0px; }
@property --kb-areas-fade-end { syntax: "<length>"; inherits: false; initial-value: 0px; }
@keyframes kb-areas-edges {
  from { --kb-areas-fade-start: 0px; --kb-areas-fade-end: 32px; }
  10%, 90% { --kb-areas-fade-start: 32px; --kb-areas-fade-end: 32px; }
  to { --kb-areas-fade-start: 32px; --kb-areas-fade-end: 0px; }
}
.kb-areas [data-slot="tabs-list"] {
  position: relative; display: flex; gap: 2px; padding: 2px 8px;
  border: 0; overflow-x: auto; scrollbar-width: none;
  animation: kb-areas-edges linear; animation-timeline: scroll(self inline);
  mask-image: linear-gradient(to right, transparent, #000 var(--kb-areas-fade-start), #000 calc(100% - var(--kb-areas-fade-end)), transparent);
}
.kb-areas [data-slot="tabs-list"]::-webkit-scrollbar { display: none; }
.kb-areas [data-slot="tabs-tab"] {
  position: relative; z-index: 1; height: 36px; margin: 0; padding: 0 14px;
  border: 0; border-radius: var(--kb-radius-pill); background: transparent;
  color: var(--kb-muted); font-weight: 700; font-size: 14px; white-space: nowrap;
  transition: color var(--kb-dur-fast) var(--kb-ease), background-color var(--kb-dur-fast) var(--kb-ease);
}
.kb-areas [data-slot="tabs-tab"]:hover:not([data-selected]) { color: var(--kb-ink); background: var(--kb-tone-wash); }
.kb-areas [data-slot="tabs-tab"][data-selected] { color: var(--kb-primary-ink); }
.kb-areas .kb-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--kb-tone); margin-right: 2px; }
.kb-areas [data-selected] .kb-dot { background: var(--kb-primary-ink); opacity: 0.85; }
/* The neutral (Home) tone's fill is near-white: its unselected dot uses the darker neutral-dot (UF1 SH5). */
.kb-areas [data-tone="neutral"]:not([data-selected]) .kb-dot { background: var(--kb-neutral-dot); }
.kb-areas [data-slot="tabs-indicator"] {
  position: absolute; z-index: 0;
  left: var(--active-tab-left); top: var(--active-tab-top);
  width: var(--active-tab-width); height: var(--active-tab-height);
  border-radius: var(--kb-radius-pill); background: var(--kb-coral);
  box-shadow: var(--kb-shadow-fill);
  transition: left var(--kb-dur-move) var(--kb-spring), width var(--kb-dur-move) var(--kb-spring), background-color var(--kb-dur-fast) var(--kb-ease);
}
.kb-areas:has([data-selected][data-tone="sun"])     [data-slot="tabs-indicator"] { background: var(--kb-sun); }
.kb-areas:has([data-selected][data-tone="sky"])     [data-slot="tabs-indicator"] { background: var(--kb-sky); }
.kb-areas:has([data-selected][data-tone="leaf"])    [data-slot="tabs-indicator"] { background: var(--kb-leaf); }
.kb-areas:has([data-selected][data-tone="coral"])   [data-slot="tabs-indicator"] { background: var(--kb-coral); }
.kb-areas:has([data-selected][data-tone="grape"])   [data-slot="tabs-indicator"] { background: var(--kb-grape-fill); }
.kb-areas:has([data-selected][data-tone="bubble"])  [data-slot="tabs-indicator"] { background: var(--kb-bubble); }
.kb-areas:has([data-selected][data-tone="neutral"]) [data-slot="tabs-indicator"] { background: var(--kb-neutral-fill); }

/* Popups: menu, select, popover */
:is([data-slot="menu-content"], [data-slot="select-content"], [data-slot="popover-content"]) {
  padding: 6px; border: 0; border-radius: 16px;
  background: var(--kb-surface); color: var(--kb-ink);
  box-shadow: var(--kb-shadow-3); font-size: 14px;
  transform-origin: var(--transform-origin);
  transition: opacity 160ms var(--kb-ease), scale 220ms var(--kb-spring);
}
:is([data-slot="menu-content"], [data-slot="select-content"], [data-slot="popover-content"]):is([data-starting-style], [data-ending-style]) { opacity: 0; scale: 0.94; }
:is([data-slot="menu-item"], [data-slot="select-item"]) {
  min-height: 38px; padding: 0 10px; gap: 10px; border-radius: 10px;
  font-weight: 600; color: var(--kb-ink); text-decoration: none;
}
:is([data-slot="menu-item"], [data-slot="select-item"])[data-highlighted] { background: var(--kb-area-wash); }
[data-slot="menu-item"] .kb-ico { width: 17px; height: 17px; color: var(--kb-muted); }
[data-slot="menu-item"][data-highlighted] .kb-ico { color: var(--kb-ink); }
[data-slot="menu-item"] .kb-hint { margin-left: auto; color: var(--kb-muted); font-weight: 600; font-size: 12.5px; }
[data-slot="menu-item"][data-current] { background: var(--kb-area-wash); }
[data-slot="menu-item"][data-current]::after { content: ""; width: 8px; height: 8px; margin-left: auto; border-radius: 50%; background: var(--kb-area); }
[data-slot="menu-separator"] { height: 1px; margin: 6px 4px; background: var(--kb-line); }
[data-slot="menu-group-label"] { padding: 8px 10px 4px; color: var(--kb-muted); font-size: 12.5px; font-weight: 700; }
[data-slot="select-item"][data-selected] { font-weight: 800; }
[data-slot="select-item-indicator"] { color: var(--kb-coral-text); }
[data-slot="popover-content"] { max-width: none; padding: 16px; gap: 10px; }
[data-slot="popover-title"] { font-size: 15px; font-weight: 800; }

/* Select trigger: chunky, edged */
.kb-select [data-slot="select-trigger"] {
  min-width: 200px; height: 42px; padding: 0 12px 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-weight: 700; font-size: 14.5px;
  transition: background-color var(--kb-dur-fast) var(--kb-ease);
}
.kb-select [data-slot="select-trigger"]:hover { background: var(--kb-surface-2); }
.kb-select [data-slot="select-trigger"]::after { color: var(--kb-ink); }

/* Tooltip */
[data-slot="tooltip-content"] {
  padding: 6px 10px; border-radius: 10px;
  background: var(--kb-ink); color: var(--kb-surface);
  font-size: 13px; font-weight: 600; box-shadow: var(--kb-shadow-2);
  transform-origin: var(--transform-origin);
  transition: opacity 140ms var(--kb-ease), scale 180ms var(--kb-spring);
}
[data-slot="tooltip-content"]:is([data-starting-style], [data-ending-style]) { opacity: 0; scale: 0.9; }

/* Checkbox */
[data-slot="checkbox"] {
  width: 22px; height: 22px; border: 0; border-radius: 7px;
  background: var(--kb-surface); color: var(--kb-primary-ink);
  box-shadow: inset 0 0 0 2px var(--kb-edge);
  transition: background-color 120ms var(--kb-ease), box-shadow 120ms var(--kb-ease);
}
/* Hover never moves or resizes anything (D-a, 2026-11-16): colour, shadow or underline only. */
[data-slot="checkbox"]:hover:not([data-disabled]) { box-shadow: inset 0 0 0 2px var(--kb-ink); }
[data-slot="checkbox"]:is([data-checked], [data-indeterminate]) { background: var(--kb-coral); box-shadow: inset 0 0 0 2px var(--kb-coral); }
[data-slot="checkbox"][data-disabled] { opacity: 1; background: var(--kb-surface-2); box-shadow: inset 0 0 0 2px var(--kb-edge-quiet); }
[data-slot="checkbox-indicator"] { --ui-icon-size: 14px; }
[data-slot="checkbox"][data-checked] [data-slot="checkbox-indicator"] { animation: kb-pop 220ms var(--kb-spring); }
@keyframes kb-pop { from { scale: 0.4; } }

/* Input group (search + clear) */
.kb-field {
  display: flex; align-items: center; gap: 8px; height: 42px; padding: 0 6px 0 12px;
  border-radius: var(--kb-radius-ctl); background: var(--kb-surface);
  box-shadow: inset 0 0 0 1.5px var(--kb-edge);
  transition: box-shadow var(--kb-dur-fast) var(--kb-ease);
}
.kb-field:has(input:focus-visible) { box-shadow: inset 0 0 0 2px var(--kb-coral-text), 0 0 0 4px var(--kb-coral-wash); }
.kb-field > .kb-ico { color: var(--kb-muted); }
.kb-field [data-slot="input"] { height: 100%; padding: 0; border: 0; background: transparent; color: var(--kb-ink); font-size: 15px; font-weight: 600; outline: none; }
.kb-field [data-slot="input"]::placeholder { color: var(--kb-muted); font-weight: 400; }
.kb-field [data-slot="input"]::-webkit-search-cancel-button { display: none; }
.kb-field [data-slot="input-clear"] {
  display: inline-grid; place-items: center; width: 30px; height: 30px; flex: none; padding: 0;
  border: 0; border-radius: 9px; background: var(--kb-surface-2); color: var(--kb-ink); cursor: pointer;
}
.kb-field [data-slot="input-clear"][hidden] { display: none; }
.kb-field [data-slot="input-clear"] .kb-ico { width: 15px; height: 15px; }

/* Collapsible: draw our own chevron (web.css adds one unless an svg is a DIRECT child of the trigger) */
.kb-group-toggle::after, .kb-subgroup-toggle::after { content: none !important; }
[data-slot="collapsible-panel"] {
  overflow: hidden; height: var(--collapsible-panel-height);
  color: inherit; font-size: inherit;
  transition: height 240ms var(--kb-ease);
}
[data-slot="collapsible-panel"]:is([data-starting-style], [data-ending-style]) { height: 0; }
[data-slot="accordion"] { max-width: none; }

/* Dialog */
[data-slot="dialog-backdrop"] { background: var(--kb-backdrop); transition: opacity 200ms var(--kb-ease); }
[data-slot="dialog-backdrop"]:is([data-starting-style], [data-ending-style]) { opacity: 0; }
[data-slot="dialog-content"] {
  width: min(520px, calc(100vw - 32px)); padding: 24px; border: 0; border-radius: 24px;
  background: var(--kb-surface); color: var(--kb-ink); box-shadow: var(--kb-shadow-3);
  transition: opacity 180ms var(--kb-ease), scale 240ms var(--kb-spring), translate 240ms var(--kb-spring);
}
[data-slot="dialog-content"]:is([data-starting-style], [data-ending-style]) { opacity: 0; scale: 0.96; translate: 0 10px; }
[data-slot="dialog-title"] { display: block; font-size: 22px; font-weight: 800; letter-spacing: -0.02em; }
[data-slot="dialog-description"] { display: block; margin-top: 6px; color: var(--kb-muted); font-size: 14.5px; }

/* Textarea (composer) */
.kb-composer [data-slot="textarea"] {
  display: block; width: 100%; min-height: 84px; max-height: 260px;
  padding: 14px 16px 6px; border: 0; border-radius: 18px; background: transparent; color: var(--kb-ink);
  font-size: 17px; line-height: 1.5; resize: none; outline: none;
}
.kb-composer [data-slot="textarea"]::placeholder { color: var(--kb-muted); }

/* Toggle as a tone pill (Finance, Note) */
.kb-toggle-pill {
  display: inline-flex; align-items: center; gap: 7px; height: 38px; padding: 0 13px;
  border: 0; border-radius: var(--kb-radius-pill);
  background: var(--kb-tone-wash); color: var(--kb-tone-text);
  font-weight: 800; font-size: 13.5px; cursor: pointer;
  transition: background-color var(--kb-dur-fast) var(--kb-ease), color var(--kb-dur-fast) var(--kb-ease);
}
.kb-toggle-pill:hover:not([data-pressed]) { background: color-mix(in srgb, var(--kb-tone) 30%, var(--kb-tone-wash)); }
.kb-toggle-pill[data-pressed] { background: var(--kb-tone); color: var(--kb-primary-ink); box-shadow: inset 0 0 0 1.5px rgb(43 37 32 / 0.25); }
.kb-toggle-pill .kb-ico { width: 16px; height: 16px; }

/* Theme toggle: moon while light, sun while dark */
.kb-theme-toggle .kb-sun { display: none; }
.kb-theme-toggle[data-pressed] .kb-sun { display: block; }
.kb-theme-toggle[data-pressed] .kb-moon { display: none; }
[data-slot="toggle-icon"] { display: contents; }

/* ===================== 4. KAL patterns ===================== */

/* Buttons */
.kb-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 42px; padding: 0 16px; border: 0; border-radius: var(--kb-radius-ctl);
  background: var(--kb-surface); color: var(--kb-ink);
  font-weight: 700; font-size: 14.5px; white-space: nowrap; text-decoration: none;
  box-shadow: inset 0 0 0 1.5px var(--kb-edge); cursor: pointer;
  transition: box-shadow var(--kb-dur-fast) var(--kb-ease), background-color var(--kb-dur-fast) var(--kb-ease);
}
.kb-btn:hover { background: var(--kb-surface-2); }
.kb-btn:active:not(.kb-btn-primary) { background: var(--kb-surface-3); }
.kb-btn .kb-ico { width: 17px; height: 17px; }
.kb-btn[data-open] { background: var(--kb-area-wash); box-shadow: inset 0 0 0 2px var(--kb-area-ink); }
.kb-btn .kb-chev { width: 15px; height: 15px; transition: rotate var(--kb-dur-fast) var(--kb-spring); }
.kb-btn[data-open] .kb-chev { rotate: 180deg; }
.kb-btn-primary { background: var(--kb-coral); color: var(--kb-primary-ink); box-shadow: var(--kb-shadow-fill); }
.kb-btn-primary:hover { background: var(--kb-coral-hover); }
.kb-btn-ghost { background: transparent; box-shadow: none; }
.kb-btn-ghost:hover { background: var(--kb-surface-2); }
.kb-btn-icon { width: 42px; padding: 0; }
.kb-btn-sm { height: 32px; padding: 0 12px; font-size: 13px; }
.kb-btn-danger { color: var(--kb-coral-text); box-shadow: inset 0 0 0 1.5px var(--kb-coral-text); }
/* Disabled: every variant keeps its own colours (a disabled primary still reads as primary, just
   off) at half strength, with a not-allowed cursor. Hover changes nothing. */
.kb-btn:is(:disabled, [aria-disabled="true"]) { opacity: 0.5; cursor: not-allowed; }
.kb-btn:is(:disabled, [aria-disabled="true"]):hover { background: var(--kb-surface); }
.kb-btn-primary:is(:disabled, [aria-disabled="true"]):hover { background: var(--kb-coral); }
.kb-btn-ghost:is(:disabled, [aria-disabled="true"]):hover { background: transparent; }

.kb-icon-btn {
  display: inline-grid; place-items: center; width: 32px; height: 32px; padding: 0;
  border: 0; border-radius: 10px; background: var(--kb-tone-wash, var(--kb-surface-2)); color: var(--kb-tone-text, var(--kb-ink));
  cursor: pointer; text-decoration: none;
  transition: background-color var(--kb-dur-fast) var(--kb-ease), color var(--kb-dur-fast) var(--kb-ease);
}
.kb-icon-btn:hover { background: var(--kb-tone, var(--kb-neutral-fill)); color: var(--kb-primary-ink); }
.kb-icon-btn .kb-ico { width: 16px; height: 16px; }

/* Top bar */
.kb-topbar {
  position: sticky; top: 0; z-index: var(--kb-z-sticky);
  background: var(--kb-topbar-bg); backdrop-filter: var(--kb-topbar-filter);
  box-shadow: 0 1px 0 var(--kb-line);
}
.kb-topbar-row { display: flex; align-items: center; gap: 12px; max-width: 1360px; margin: 0 auto; padding: 10px 24px 6px; }
.kb-topbar-row.kb-wide { max-width: none; padding-bottom: 10px; }
.kb-brand { display: inline-flex; align-items: center; gap: 10px; color: var(--kb-ink); text-decoration: none; border-radius: 10px; }
.kb-brand img { display: block; height: 30px; width: auto; }
.kb-brand-app { padding-left: 10px; box-shadow: inset 1.5px 0 0 var(--kb-line); font-weight: 800; font-size: 17px; letter-spacing: -0.01em; }
.kb-spacer { flex: 1; }
.kb-areas { max-width: 1360px; margin: 0 auto; padding: 0 16px 8px; }
.kb-avatar {
  display: inline-grid; place-items: center; width: 40px; height: 40px; padding: 0; border: 0; border-radius: 50%;
  background: var(--kb-sky); color: var(--kb-primary-ink); font-weight: 800; font-size: 15px; cursor: pointer;
  transition: box-shadow var(--kb-dur-fast) var(--kb-ease);
}
.kb-avatar:hover { box-shadow: 0 0 0 3px var(--kb-sky-wash), 0 0 0 4.5px var(--kb-sky); }
/* "What's new" unseen dot on the avatar and its menu item (Portal: public/js/whats-new.js toggles [hidden]) */
.kb-avatar { position: relative; }
.wn-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--kb-coral, #ef5a3c); box-shadow: 0 0 0 2px var(--kb-surface, #fff); }
.wn-dot[hidden] { display: none; }
.kb-avatar .wn-dot { position: absolute; top: 0; right: 0; z-index: 1; }
/* M365 photo (D72): fills the same 40px circle over the initials; hidden until it has loaded, so nothing moves. */
/* Clicks go to the button (no image drag ghost); the sky fill keeps a transparent PNG from showing the initials through. */
.kb-avatar-photo { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; border-radius: 50%; background: var(--kb-sky); pointer-events: none; }
.kb-avatar-photo[hidden] { display: none; }
.wn-dot--item { margin-left: auto; }
.kb-ask { height: 40px; padding: 0 14px 0 12px; }
/* Every control in the top bar is one 40px height: Ask, avatar, centre switch and icon buttons (UF1 SH4). */
.kb-topbar .kb-btn-icon { width: 40px; height: 40px; }

/* Centre switcher + centre code chip */
.kb-centre-switch [data-slot="select-trigger"] {
  min-width: 0; height: 40px; padding: 0 10px 0 12px; gap: 8px;
  border: 0; border-radius: var(--kb-radius-ctl); background: var(--kb-surface-2); color: var(--kb-ink);
  box-shadow: inset 0 0 0 1.5px var(--kb-edge); font-weight: 700; font-size: 14px;
}
/* Text starts 12px in like every other trigger; a leading code chip sits closer (it has its own fill). */
.kb-centre-switch [data-slot="select-trigger"]:has(> .kb-code-chip:first-child) { padding-left: 6px; }
.kb-centre-switch [data-slot="select-trigger"]:hover { background: var(--kb-surface-3); }
.kb-centre-switch [data-slot="select-trigger"]::after { color: var(--kb-ink); }
.kb-centre-switch .kb-switch-label { color: var(--kb-muted); font-weight: 600; }
/* One fixed width for every code (D-b): wide enough for the widest centre code (DOO, 44px), so the
   names beside a column of chips start on one edge. Never stretched or squeezed by a flex row. */
.kb-code-chip {
  display: inline-grid; place-items: center; flex: none; width: 46px; min-width: 46px; height: 26px; padding: 0; border-radius: 8px;
  white-space: nowrap;
  background: var(--brand-primary, var(--kb-ink)); color: var(--brand-on-primary, var(--kb-surface));
  box-shadow: inset 0 0 0 1px rgb(255 255 255 / 0.12);
  font-size: 12px; font-weight: 800; letter-spacing: 0.04em;
}

/* Page container */
.kb-page { max-width: 1360px; margin: 0 auto; padding: 20px 24px 140px; }

/* Page header band: wash of the area colour, bold icon tile, title, stats, one blob */
.kb-band {
  position: relative; overflow: hidden; isolation: isolate;
  display: grid; grid-template-columns: 1fr auto; align-items: end; gap: 24px 40px;
  padding: 26px 32px 28px; border-radius: var(--kb-radius-band);
  background: radial-gradient(120% 140% at 0% 0%,
    color-mix(in srgb, var(--kb-area) var(--kb-band-hi), var(--kb-surface)) 0%,
    color-mix(in srgb, var(--kb-area) calc(var(--kb-band-hi) * 0.7), var(--kb-surface)) 40%,
    color-mix(in srgb, var(--kb-area) var(--kb-band-lo), var(--kb-surface)) 100%);
  box-shadow: var(--kb-shadow-1);
}
.kb-band-blob { position: absolute; z-index: -1; right: -90px; top: -120px; width: 360px; height: 280px; color: var(--kb-area); opacity: var(--kb-blob-alpha); }
.kb-band-main { display: flex; gap: 20px; align-items: flex-start; min-width: 0; }
.kb-tile {
  display: grid; place-items: center; flex: none; width: 64px; height: 64px; border-radius: 20px;
  background: var(--kb-area); color: var(--kb-primary-ink);
  box-shadow: var(--kb-shadow-fill), inset 0 1px 0 rgb(255 255 255 / 0.45);
  rotate: -4deg;
}
.kb-tile .kb-ico { width: 30px; height: 30px; stroke-width: 2.2; }
.kb-crumb button {
  display: inline-flex; align-items: center; gap: 4px; height: 28px; margin: 0 0 2px -8px; padding: 0 8px;
  border: 0; border-radius: 8px; background: transparent; color: var(--kb-area-ink);
  font-weight: 800; font-size: 14px; cursor: pointer;
}
.kb-crumb button:hover { background: color-mix(in srgb, var(--kb-area) 30%, transparent); }
.kb-crumb button .kb-ico { width: 15px; height: 15px; transition: rotate var(--kb-dur-fast) var(--kb-spring); }
.kb-crumb button[data-open] .kb-ico { rotate: 180deg; }
.kb-title { font-size: 48px; line-height: 1.02; font-weight: 800; letter-spacing: -0.035em; }
.kb-context { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 12px; margin-top: 10px; color: var(--kb-muted); font-weight: 600; }
.kb-context .kb-btn { height: 34px; padding: 0 12px; font-size: 13.5px; background: var(--kb-glass); }
/* The glass fill is for plain buttons; a primary button in the context band keeps its coral (its ink is dark on coral). */
.kb-context .kb-btn-primary { background: var(--kb-coral); }
.kb-context .kb-btn-primary:hover { background: var(--kb-coral-hover); }
.kb-context .kb-btn:is(:disabled, [aria-disabled="true"]):hover { background: var(--kb-glass); }
.kb-context .kb-btn-primary:is(:disabled, [aria-disabled="true"]):hover { background: var(--kb-coral); }

/* Stat figure */
/* Tiles in one band share one width (D-b) and never stretch across the band: the row is only as wide
   as its tiles (fit-content), so each 1fr column = the widest tile's content, held to 150-240px
   (long labels wrap inside 240). Left-aligned wherever the page puts the row. */
.kb-stats { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 10px; margin: 0; width: fit-content; max-width: 100%; justify-self: start; }
.kb-stat { min-width: 150px; max-width: 240px; padding: 14px 18px 12px; border-radius: 18px; background: var(--kb-glass); box-shadow: var(--kb-shadow-1); }
.kb-stat dt { color: var(--kb-muted); font-size: 13px; font-weight: 700; }
.kb-stat dd { margin: 2px 0 0; font-size: 26px; line-height: 1.15; font-weight: 800; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.kb-stat--key { background: var(--kb-surface); box-shadow: inset 0 0 0 2px var(--kb-area), var(--kb-shadow-1); }
.kb-stat--key dt { display: flex; align-items: center; gap: 6px; }
.kb-stat--key dt::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--kb-area); }

/* Toolbar row */
.kb-toolrow { display: flex; align-items: center; gap: 10px; margin: 18px 0 22px; padding: 10px; border-radius: var(--kb-radius-card); background: var(--kb-surface); box-shadow: var(--kb-shadow-1); }
.kb-toolrow .kb-field { flex: 1 1 320px; min-width: 0; }
/* The ui-toolbar is only a keyboard group here: no frame of its own inside the card (ui-sdk gives it a
   border, padding and fill), and every control in the row is one 42px height (D-b). */
.kb-toolrow [data-slot="toolbar"] { display: flex; align-items: center; gap: 8px; padding: 0; border: 0; border-radius: 0; background: transparent; box-shadow: none; }
.kb-toolrow :is(.kb-btn, [data-slot="toolbar-button"], [data-slot="toolbar-link"], [data-slot="toggle"], [data-slot="select-trigger"]):not(.kb-icon-btn) { height: 42px; }

/* Tag: small tone chip */
/* min-height, not height: a one-line tag is 24px; a tag a page lets wrap (white-space: normal) grows. */
.kb-tag { display: inline-flex; align-items: center; gap: 5px; min-height: 24px; padding: 2px 9px; border-radius: var(--kb-radius-pill); background: var(--kb-tone-wash); color: var(--kb-tone-text); font-size: 12.5px; font-weight: 700; white-space: nowrap; }
.kb-tag .kb-ico { width: 14px; height: 14px; stroke-width: 2.6; }

/* Group card with a centre header (centre tab = the centre's brand colour) */
.kb-group { margin-bottom: 18px; border-radius: var(--kb-radius-card); background: var(--kb-surface); box-shadow: var(--kb-shadow-1); }
.kb-group[hidden] { display: none; }
.kb-group-head { position: relative; display: flex; align-items: center; gap: 12px; padding: 8px 12px 8px 26px; }
.kb-group-head::before { content: ""; position: absolute; left: 0; top: 14px; bottom: 14px; width: 7px; border-radius: 0 6px 6px 0; background: var(--kb-centre, var(--kb-ink)); }
.kb-group-toggle { flex: 1; display: flex; align-items: center; gap: 14px; min-width: 0; height: 56px; padding: 0 8px; border: 0; border-radius: 14px; background: transparent; color: var(--kb-ink); text-align: left; cursor: pointer; }
.kb-group-toggle:hover { background: var(--kb-surface-2); }
.kb-group-code { font-size: 22px; font-weight: 800; letter-spacing: 0.01em; }
.kb-group-meta { display: flex; align-items: baseline; gap: 22px; margin-left: auto; color: var(--kb-muted); font-weight: 600; font-size: 14px; white-space: nowrap; }
.kb-group-meta b { color: var(--kb-ink); font-weight: 800; font-size: 15.5px; font-variant-numeric: tabular-nums; }
.kb-chev { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 10px; background: var(--kb-surface-2); }
.kb-chev .kb-ico, .kb-subgroup-toggle > .kb-ico { width: 18px; height: 18px; rotate: -90deg; transition: rotate 260ms var(--kb-spring); }
.kb-group-toggle[data-open] .kb-chev .kb-ico, .kb-subgroup-toggle[data-open] > .kb-ico { rotate: 0deg; }

/* White with a hairline, not the beige surface-2 (that read as the old cream paper, UF1 D-h). */
.kb-subgroup { margin: 0 12px 12px; border-radius: 16px; background: var(--kb-surface); box-shadow: inset 0 0 0 1px var(--kb-line); }
.kb-subgroup[hidden] { display: none; }
.kb-subgroup-head { display: flex; align-items: center; gap: 8px; padding: 6px 8px; }
.kb-subgroup-head .kb-btn-sm { margin-left: auto; }
/* min-height: on a phone a long label + count wraps, and a fixed 36px let it spill into the panel below. */
.kb-subgroup-toggle { display: inline-flex; align-items: center; gap: 10px; min-height: 36px; padding: 6px 10px; text-align: left; border: 0; border-radius: 10px; background: transparent; color: var(--kb-ink); font-weight: 800; font-size: 14.5px; cursor: pointer; }
.kb-subgroup-toggle:hover { background: var(--kb-surface-3); }
.kb-subgroup-toggle > .kb-ico { width: 16px; height: 16px; }
.kb-subgroup-toggle .kb-count { color: var(--kb-muted); font-weight: 600; }
.kb-subgroup-empty { padding: 4px 18px 16px; color: var(--kb-muted); font-size: 14px; }

/* Data table. Cells take data-col="lead|main|end|meta|extra|foot|wide" for the stacked phone layout. */
/* On the page a table is flush with the band and toolbar above it; inside a group card it keeps a small inset. */
.kb-table-wrap { padding: 0 0 8px; }
.kb-group .kb-table-wrap { padding: 0 6px 8px; }
.kb-table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 14px; table-layout: fixed; }
.kb-table thead th { padding: 6px 10px 8px; text-align: left; color: var(--kb-muted); font-size: 12.5px; font-weight: 700; }
.kb-table .kb-r { text-align: right; }
.kb-table tbody td { padding: 12px 10px; vertical-align: middle; background: var(--kb-surface); }
/* The rows read as one block: only its four outer corners are round, so no notch shows at a row divider. */
.kb-table tbody tr:nth-child(1 of :not([hidden])) td:first-child { border-top-left-radius: 12px; }
.kb-table tbody tr:nth-child(1 of :not([hidden])) td:last-child { border-top-right-radius: 12px; }
.kb-table tbody tr:nth-last-child(1 of :not([hidden])) td:first-child { border-bottom-left-radius: 12px; }
.kb-table tbody tr:nth-last-child(1 of :not([hidden])) td:last-child { border-bottom-right-radius: 12px; }
.kb-table tbody tr + tr td { box-shadow: inset 0 1px 0 var(--kb-line); }
.kb-table tbody tr:hover td { background: var(--kb-row-hover); }
.kb-table tbody tr:has([data-checked]) td { background: var(--kb-row-picked); }
.kb-table tbody tr[hidden] { display: none; }
.kb-table [data-col="phone"] { display: none; }
.kb-cell { display: flex; align-items: center; gap: 10px; min-width: 0; }
/* The first child (the text) takes the spare width. A leading code chip keeps its fixed width and
   the text after it takes the spare width instead. */
.kb-cell > :first-child:not(.kb-code-chip), .kb-cell > .kb-code-chip:first-child + * { flex: 1; min-width: 0; }
.kb-cell-main { display: block; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kb-cell-sub { display: block; color: var(--kb-muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-variant-numeric: tabular-nums; }
.kb-cell-clip { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.kb-cell ui-tooltip, .kb-cell ui-tooltip-trigger { flex: none; }
.kb-date { font-variant-numeric: tabular-nums; white-space: nowrap; }

/* Editable money cell */
.kb-amount {
  display: inline-flex; align-items: center; gap: 6px; margin-right: -6px; height: 32px; padding: 0 6px 0 8px;
  border: 0; border-radius: 9px; background: transparent; color: var(--kb-ink);
  font-weight: 800; font-size: 15px; font-variant-numeric: tabular-nums; cursor: pointer;
}
.kb-amount .kb-ico { width: 13px; height: 13px; color: var(--kb-muted); opacity: 0; transition: opacity var(--kb-dur-fast); }
.kb-amount:hover { background: var(--kb-area-wash); }
.kb-amount:hover .kb-ico, .kb-amount:focus-visible .kb-ico { opacity: 1; }
.kb-amount[disabled] { cursor: default; color: var(--kb-muted); }
.kb-amount[disabled]:hover { background: transparent; }
.kb-amount.kb-overridden { color: var(--kb-coral-text); }
.kb-amount-sub { display: block; margin-top: 2px; color: var(--kb-muted); font-size: 12.5px; font-weight: 600; line-height: 1.3; }
.kb-amount-edit { display: inline-flex; width: 112px; height: 34px; padding: 0 8px; }
.kb-amount-edit [data-slot="input"] { text-align: right; font-weight: 800; font-variant-numeric: tabular-nums; }
.kb-linkish { border: 0; background: none; padding: 0 0 0 6px; color: var(--kb-coral-text); font-weight: 700; font-size: 12.5px; cursor: pointer; text-decoration: underline; text-underline-offset: 2px; }

/* Status chip (default: needs attention) */
.kb-status { display: inline-flex; align-items: center; gap: 7px; height: 30px; padding: 0 12px 0 9px; border-radius: var(--kb-radius-pill); background: var(--kb-tone-wash, var(--kb-coral-wash)); color: var(--kb-tone-text, var(--kb-coral-text)); font-weight: 700; font-size: 13px; white-space: nowrap; }
.kb-status .kb-ico { width: 15px; height: 15px; }

/* "N more" pill that opens a popover list */
.kb-more { flex: none; height: 26px; padding: 0 9px; border: 0; border-radius: var(--kb-radius-pill); background: var(--kb-sky-wash); color: var(--kb-sky-text); font-weight: 800; font-size: 12.5px; cursor: pointer; transition: background-color var(--kb-dur-fast) var(--kb-ease), color var(--kb-dur-fast) var(--kb-ease); }
.kb-more:hover, .kb-more[data-open] { background: var(--kb-sky); color: var(--kb-primary-ink); }
.kb-pop-list { width: min(460px, calc(100vw - 32px)); }
.kb-pop-list ol { margin: 0; padding: 0; list-style: none; display: grid; gap: 2px; max-height: 320px; overflow: auto; }
.kb-pop-list li { display: grid; grid-template-columns: 1fr auto; gap: 2px 14px; padding: 8px 10px; border-radius: 10px; }
.kb-pop-list li:nth-child(odd) { background: var(--kb-surface-2); }
.kb-pop-list .kb-pl-main { font-weight: 600; font-size: 13.5px; }
.kb-pop-list .kb-pl-sub { grid-column: 1; color: var(--kb-muted); font-size: 12.5px; }
.kb-pop-list .kb-pl-end { grid-row: 1; grid-column: 2; font-weight: 800; font-variant-numeric: tabular-nums; font-size: 13.5px; }

/* Empty state */
.kb-empty { padding: 48px 24px; border-radius: var(--kb-radius-card); background: var(--kb-surface); box-shadow: var(--kb-shadow-1); color: var(--kb-muted); font-weight: 600; text-align: center; }
.kb-empty[hidden] { display: none; }

/* Sticky action bar: rises when there is something to act on (set data-active) */
.kb-actionbar {
  position: fixed; z-index: var(--kb-z-bar); left: 50%; bottom: 20px;
  display: flex; align-items: center; gap: 18px; width: min(880px, calc(100vw - 32px)); padding: 12px 12px 12px 14px;
  border-radius: 22px; background: var(--kb-surface); box-shadow: var(--kb-shadow-3);
  translate: -50% calc(100% + 40px); visibility: hidden;
  transition: translate 300ms var(--kb-spring), visibility 0s linear 300ms;
}
.kb-actionbar[data-active] { translate: -50% 0; visibility: visible; transition: translate 300ms var(--kb-spring), visibility 0s; }
.kb-actionbar-count { display: grid; place-items: center; flex: none; min-width: 46px; height: 46px; padding: 0 10px; border-radius: 15px; background: var(--kb-coral); color: var(--kb-primary-ink); font-size: 20px; font-weight: 800; font-variant-numeric: tabular-nums; }
.kb-actionbar-count.kb-bump { animation: kb-bump 260ms var(--kb-spring); }
@keyframes kb-bump { 40% { scale: 1.18; } }
.kb-actionbar-what { min-width: 0; }
.kb-actionbar-what strong { display: block; font-weight: 800; font-size: 15.5px; }
.kb-actionbar-what span { display: block; color: var(--kb-muted); font-size: 13.5px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kb-actionbar-total { margin-left: auto; text-align: right; }
.kb-actionbar-total span { display: block; color: var(--kb-muted); font-size: 12.5px; font-weight: 700; }
.kb-actionbar-total strong { font-size: 24px; font-weight: 800; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.kb-actionbar .kb-btn-primary { height: 46px; padding: 0 20px; font-size: 15.5px; }

/* Dialog summary list */
.kb-summary { margin: 18px 0; padding: 0; list-style: none; display: grid; gap: 8px; }
.kb-summary li { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 14px; background: var(--kb-surface-2); }
.kb-summary li b { margin-left: auto; font-variant-numeric: tabular-nums; font-weight: 800; }
.kb-summary li.kb-sum { background: transparent; box-shadow: inset 0 1px 0 var(--kb-line); border-radius: 0; font-weight: 700; }
.kb-actions { display: flex; justify-content: flex-end; gap: 10px; }
.kb-note { margin-top: 12px; color: var(--kb-muted); font-size: 13px; }

/* Assist: workspace with a chat rail */
.kb-workspace { display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: 28px; max-width: 1360px; margin: 0 auto; padding: 20px 24px 60px; }
.kb-rail { position: sticky; top: 76px; align-self: start; display: flex; flex-direction: column; gap: 12px; max-height: calc(100vh - 96px); padding: 14px; border-radius: var(--kb-radius-card); background: var(--kb-surface); box-shadow: var(--kb-shadow-1); }
.kb-rail-new { width: 100%; justify-content: flex-start; background: var(--kb-coral-wash); box-shadow: none; }
.kb-rail-new:hover { background: color-mix(in srgb, var(--kb-coral) 22%, var(--kb-surface)); }
.kb-rail-new .kb-plus { display: grid; place-items: center; width: 26px; height: 26px; border-radius: 8px; background: var(--kb-coral); color: var(--kb-primary-ink); }
.kb-rail-new kbd { margin-left: auto; padding: 0; border: 0; color: var(--kb-muted); font: inherit; font-size: 12.5px; font-weight: 600; }
.kb-rail-tools { display: flex; align-items: center; justify-content: space-between; min-height: 34px; padding: 0 4px; }
.kb-rail-tools label { display: inline-flex; align-items: center; gap: 8px; color: var(--kb-muted); font-size: 13.5px; font-weight: 700; cursor: pointer; }
.kb-chat-list { margin: 0 -6px; padding: 0 6px 4px; overflow: auto; }
.kb-chat-month { margin: 12px 8px 4px; color: var(--kb-muted); font-size: 12.5px; font-weight: 800; }
.kb-chat { display: grid; grid-template-columns: auto 1fr; gap: 2px 10px; align-items: start; padding: 9px 10px; border-radius: 12px; transition: background-color var(--kb-dur-fast) var(--kb-ease); }
.kb-chat:hover { background: var(--kb-surface-2); }
.kb-chat[data-current] { background: var(--kb-coral-wash); }
.kb-chat[hidden] { display: none; }
.kb-chat [data-slot="checkbox"] { width: 18px; height: 18px; border-radius: 6px; margin-top: 2px; }
.kb-chat a { color: var(--kb-ink); text-decoration: none; font-weight: 700; font-size: 14px; line-height: 1.35; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; border-radius: 4px; }
.kb-chat time { grid-column: 2; color: var(--kb-muted); font-size: 12.5px; font-weight: 600; }
.kb-rail-toggle { display: none; }

.kb-main { min-width: 0; max-width: 860px; width: 100%; margin: 0 auto; padding-top: 18px; }
.kb-hello { display: flex; align-items: center; gap: 16px; }
.kb-hello .kb-tile { width: 56px; height: 56px; border-radius: 18px; rotate: -5deg; }
.kb-hello .kb-tile .kb-ico { width: 28px; height: 28px; }
.kb-hello .kb-title { font-size: 46px; line-height: 1.05; }
.kb-intro { margin-top: 12px; max-width: 64ch; color: var(--kb-muted); font-size: 15px; }

.kb-composer { margin-top: 24px; padding: 8px 8px 10px; border-radius: 26px; background: var(--kb-surface); box-shadow: var(--kb-shadow-2), 0 0 0 1.5px var(--kb-edge); transition: box-shadow var(--kb-dur-fast) var(--kb-ease); }
.kb-composer:focus-within { box-shadow: var(--kb-shadow-2), 0 0 0 2px var(--kb-coral-text), 0 0 0 7px var(--kb-coral-wash); }
.kb-composer-row { display: flex; align-items: center; gap: 8px; padding: 0 4px 0 6px; }
.kb-composer-row .kb-hint { margin-left: 6px; color: var(--kb-muted); font-size: 12.5px; font-weight: 600; }
.kb-composer-row .kb-end { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.kb-composer .kb-btn-primary { height: 44px; padding: 0 18px 0 20px; font-size: 16px; }

/* Suggestion card */
.kb-suggest { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-top: 16px; }
.kb-card {
  position: relative; display: flex; flex-direction: column; gap: 12px; align-items: flex-start;
  min-height: 132px; padding: 14px 14px 16px; border: 0; border-radius: var(--kb-radius-card);
  background: var(--kb-tone-wash); color: var(--kb-ink); text-align: left; cursor: pointer;
  font-weight: 700; font-size: 14.5px; line-height: 1.35;
  transition: box-shadow 220ms var(--kb-ease);
}
.kb-card:hover { box-shadow: var(--kb-shadow-lift), inset 0 0 0 2px color-mix(in srgb, var(--kb-tone) 55%, transparent); }
.kb-card .kb-card-tile { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 12px; background: var(--kb-tone); color: var(--kb-primary-ink); }
.kb-card .kb-card-tile .kb-ico { width: 19px; height: 19px; }
.kb-card .kb-card-flag { position: absolute; top: 14px; right: 14px; display: inline-flex; align-items: center; height: 22px; padding: 0 8px; border-radius: var(--kb-radius-pill); background: var(--kb-surface); color: var(--kb-tone-text); font-size: 11.5px; font-weight: 800; }

/* Conversation */
.kb-thread { margin-top: 40px; display: grid; gap: 18px; }
.kb-thread-head { display: flex; align-items: center; gap: 10px; color: var(--kb-muted); font-weight: 800; font-size: 14px; }
.kb-thread-head::after { content: ""; flex: 1; height: 1px; background: var(--kb-line); }
.kb-caution { display: flex; align-items: flex-start; gap: 10px; padding: 10px 14px; border-radius: 14px; background: var(--kb-sun-wash); color: var(--kb-ink); font-size: 13.5px; font-weight: 600; }
.kb-caution .kb-ico { width: 18px; height: 18px; margin-top: 1px; color: var(--kb-sun-text); }
.kb-bubble { justify-self: end; max-width: 78%; }
.kb-bubble p { padding: 14px 18px; border-radius: 22px 22px 6px 22px; background: var(--kb-sky); color: var(--kb-primary-ink); font-weight: 700; font-size: 15.5px; box-shadow: var(--kb-shadow-fill); }
.kb-bubble time { display: block; margin-top: 6px; color: var(--kb-muted); font-size: 12.5px; font-weight: 600; text-align: right; }
.kb-answer { display: grid; grid-template-columns: 40px 1fr; gap: 12px; }
.kb-answer-avatar { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 14px; background: var(--kb-coral); color: var(--kb-primary-ink); }
.kb-answer-avatar .kb-ico { width: 20px; height: 20px; }
.kb-answer-card { padding: 18px 22px 16px; border-radius: 6px 22px 22px 22px; background: var(--kb-surface); box-shadow: var(--kb-shadow-1); }
.kb-answer-meta { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.kb-answer-meta time { margin-left: auto; color: var(--kb-muted); font-size: 12.5px; font-weight: 600; }
.kb-answer-body { font-size: 15.5px; line-height: 1.6; }
.kb-answer-body p + p, .kb-answer-body p + ul, .kb-answer-body ul + p { margin-top: 10px; }
.kb-answer-body ul { margin: 10px 0 0; padding: 0; list-style: none; display: grid; gap: 8px; }
.kb-answer-body li { position: relative; padding-left: 20px; }
.kb-answer-body li::before { content: ""; position: absolute; left: 4px; top: 0.62em; width: 7px; height: 7px; border-radius: 50%; background: var(--kb-coral); }
.kb-cite { display: inline-grid; place-items: center; vertical-align: 2px; min-width: 22px; height: 20px; margin: 0 1px; padding: 0 6px; border: 0; border-radius: var(--kb-radius-pill); background: var(--kb-tone); color: var(--kb-primary-ink); font-size: 11.5px; font-weight: 800; cursor: pointer; transition: box-shadow var(--kb-dur-fast) var(--kb-ease); }
.kb-cite:hover { box-shadow: 0 0 0 2px var(--kb-tone-text); }
.kb-sources { margin-top: 16px; padding-top: 14px; box-shadow: inset 0 1px 0 var(--kb-line); }
.kb-sources h2 { margin-bottom: 8px; color: var(--kb-muted); font-size: 13.5px; font-weight: 800; }
.kb-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.kb-source { display: inline-flex; align-items: center; gap: 10px; max-width: 100%; padding: 6px 14px 6px 6px; border-radius: 14px; background: var(--kb-tone-wash); color: var(--kb-ink); text-decoration: none; transition: box-shadow var(--kb-dur-fast) var(--kb-ease); }
.kb-source:hover { box-shadow: var(--kb-shadow-lift), inset 0 0 0 1.5px var(--kb-tone-text); }
.kb-source .kb-source-n { display: grid; place-items: center; flex: none; width: 28px; height: 28px; border-radius: 9px; background: var(--kb-tone); color: var(--kb-primary-ink); font-weight: 800; font-size: 13px; }
.kb-source .kb-source-t { display: block; font-weight: 700; font-size: 13.5px; line-height: 1.3; }
.kb-source .kb-source-s { display: block; color: var(--kb-tone-text); font-size: 12.5px; font-weight: 700; }
.kb-answer-actions { display: flex; gap: 6px; margin-top: 12px; }

/* ===================== Motion and size ===================== */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 1ms !important; animation-duration: 1ms !important; animation-iteration-count: 1 !important; }
}

@media (max-width: 1100px) { .kb-suggest { grid-template-columns: 1fr 1fr; } }
@media (max-width: 900px) {
  .kb-band { grid-template-columns: 1fr; }
  /* Tablet keeps the one-row tiles: when the row is wider than the band the equal columns shrink
     together (4 tiles x 150px fit down to 760px), so no tile wraps onto a row of its own. */
}
@media (max-width: 860px) {
  .kb-workspace { grid-template-columns: 1fr; padding: 12px 16px 40px; }
  .kb-rail-toggle { display: inline-grid; }
  .kb-rail { position: fixed; z-index: var(--kb-z-rail); top: 64px; left: 12px; bottom: 12px; width: min(320px, calc(100vw - 24px)); max-height: none; translate: calc(-100% - 24px) 0; transition: translate var(--kb-dur-move) var(--kb-spring); box-shadow: var(--kb-shadow-3); }
  .kb-rail[data-open] { translate: 0 0; }
  .kb-hello .kb-title { font-size: 36px; }
  .kb-composer-row .kb-hint { display: none; }
  .kb-bubble { max-width: 92%; }
  .kb-answer { grid-template-columns: 1fr; }
  .kb-answer-avatar { display: none; }
}
@media (max-width: 760px) {
  .kb-topbar-row { padding: 8px 16px 4px; gap: 8px; }
  .kb-brand img { height: 26px; }
  .kb-brand-app { display: none; }
  .kb-ask { width: 40px; padding: 0; }
  .kb-ask .kb-ask-word { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
  .kb-centre-switch .kb-switch-label { display: none; }
  .kb-areas { padding: 0 4px 6px; }

  .kb-page { padding: 14px 16px 150px; }
  .kb-band { padding: 20px 18px 18px; border-radius: 24px; gap: 18px; }
  .kb-band-blob { width: 260px; height: 210px; right: -80px; top: -70px; }
  .kb-band-main { gap: 14px; }
  .kb-band .kb-tile { width: 52px; height: 52px; border-radius: 16px; }
  .kb-band .kb-tile .kb-ico { width: 25px; height: 25px; }
  .kb-title { font-size: 38px; }
  /* Two equal columns; an odd last tile keeps the same width as the others (no full-width span). */
  .kb-stats { grid-auto-flow: row; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; width: auto; justify-self: stretch; }
  .kb-stat { min-width: 0; max-width: none; padding: 12px 14px; }
  .kb-stat dd { font-size: 20px; }

  .kb-toolrow { flex-wrap: wrap; padding: 8px; }
  .kb-toolrow .kb-field { flex-basis: 100%; }
  .kb-toolrow [data-slot="toolbar"] { flex: 1; flex-wrap: nowrap; min-width: 0; }
  .kb-toolrow .kb-select [data-slot="select-trigger"] { flex: 1 1 auto; min-width: 0; width: auto; }
  .kb-toolrow .kb-select [data-slot="select-value"] { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

  .kb-group-head { padding: 6px 8px 6px 18px; }
  .kb-group-toggle { height: auto; min-height: 56px; padding: 8px 6px; flex-wrap: wrap; gap: 4px 10px; }
  .kb-group-meta { order: 3; flex-basis: 100%; margin-left: 0; gap: 14px; font-size: 13px; }
  .kb-chev { margin-left: auto; }
  .kb-subgroup { margin: 0 8px 8px; }
  .kb-table-wrap { padding: 0 4px 6px; }

  /* The card layout is for the table's OWN rows and cells only: a table nested inside a detail row
     stays a table. The :where() tails pin each rule to the outer table's rows without changing the
     selector's weight, so page overrides written against these rules still win as before. */
  .kb-table, .kb-table > tbody { display: block; }
  .kb-table > colgroup, .kb-table > thead { display: none; }
  .kb-table tbody tr:where(.kb-table > tbody > tr) {
    display: grid; grid-template-columns: 34px 1fr auto; gap: 4px 10px;
    grid-template-areas: "lead main end" "lead meta meta" "lead extra extra" "lead foot foot";
    margin-bottom: 6px; padding: 12px; border-radius: 14px; background: var(--kb-surface);
  }
  .kb-table tbody tr[hidden]:where(.kb-table > tbody > tr) { display: none; }
  .kb-table tbody tr:has([data-checked]):where(.kb-table > tbody > tr) { background: var(--kb-row-picked); }
  .kb-table tbody td:where(.kb-table > tbody > tr > td), .kb-table tbody tr:hover td:where(.kb-table > tbody > tr > td), .kb-table tbody tr:has([data-checked]) td:where(.kb-table > tbody > tr > td) { min-width: 0; padding: 0; background: transparent; border-radius: 0 !important; box-shadow: none !important; }
  .kb-table [data-col="lead"]:where(.kb-table > tbody > tr > *) { grid-area: lead; padding-top: 2px; }
  .kb-table [data-col="main"]:where(.kb-table > tbody > tr > *) { grid-area: main; }
  .kb-table [data-col="main"]:where(.kb-table > tbody > tr > *) .kb-cell-main { white-space: normal; }
  .kb-table [data-col="end"]:where(.kb-table > tbody > tr > *) { grid-area: end; }
  /* meta / phone, extra and foot cells take the COLUMNS of their named area but no fixed row: each one
     gets its own row, in that order, so two cells of one kind never paint on top of each other. A page
     template that names these areas (any order) still works; main, end and lead keep their areas. */
  .kb-table :is([data-col="meta"], [data-col="phone"]):where(.kb-table > tbody > tr > *) { grid-column: meta; order: 1; }
  .kb-table [data-col="phone"]:where(.kb-table > tbody > tr > *) { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; color: var(--kb-muted); font-size: 13px; font-weight: 600; }
  .kb-table [data-col="extra"]:where(.kb-table > tbody > tr > *) { grid-column: extra; order: 2; }
  .kb-table [data-col="foot"]:where(.kb-table > tbody > tr > *) { grid-column: foot; order: 3; }
  .kb-table [data-col="desk"]:where(.kb-table > tbody > tr > *) { display: none; }

  .kb-actionbar { flex-wrap: wrap; gap: 10px; padding: 10px; bottom: 12px; border-radius: 20px; }
  .kb-actionbar-count { min-width: 40px; height: 40px; font-size: 17px; border-radius: 13px; }
  .kb-actionbar-total strong { font-size: 19px; }
  .kb-actionbar .kb-hide-phone { display: none; }
  .kb-actionbar .kb-actionbar-go button { flex-basis: 100%; width: 100%; }
}
@media (max-width: 520px) { .kb-suggest { grid-template-columns: 1fr; } .kb-card { min-height: 0; flex-direction: row; align-items: center; } }
