/* ==========================================================================
   KernexaProperty — design system
   --------------------------------------------------------------------------
   Foundation: white and black, carried by a single neutral ramp.
   Colour is reserved for meaning (status, money, risk) — never decoration.
   Dark mode is authored, not inverted: its own surfaces, borders and accents.

   Contents
     1.  Tokens (light)
     2.  Tokens (dark)
     3.  Base elements
     4.  Typography
     5.  Buttons
     6.  Forms
     7.  Cards & surfaces
     8.  Tables
     9.  Badges & status
     10. Alerts, toasts, empty & loading states
     11. Modals, dropdowns, tooltips
     12. App shell (sidebar, topbar, content)
     13. Dashboard widgets
     14. Public site
     15. Auth
     16. Prose (legal & long-form)
     17. Utilities, motion, print
   ========================================================================== */

/* ==========================================================================
   0. Typeface
   --------------------------------------------------------------------------
   Inter is served from this origin rather than Google Fonts — one request
   instead of two cross-origin ones, and no third party in the critical path.
   `swap` means text is readable immediately in the fallback stack and
   re-renders when Inter lands, rather than the page sitting blank.
   ========================================================================== */

@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("../vendor/fonts/inter-latin-wght-normal.260c81a4759b.woff2") format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA,
                 U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122,
                 U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* ==========================================================================
   1. Tokens (light)
   ========================================================================== */

:root {
  /* Neutral ramp — the whole product is built from these. */
  --kx-n-0:  #ffffff;
  --kx-n-25: #fcfcfd;
  --kx-n-50: #f7f7f8;
  --kx-n-100:#f1f1f3;
  --kx-n-150:#e9e9ec;
  --kx-n-200:#e2e2e6;
  --kx-n-300:#d3d3d8;
  --kx-n-400:#a5a5ad;
  --kx-n-500:#78787f;
  --kx-n-600:#56565d;
  --kx-n-700:#3d3d43;
  --kx-n-800:#26262a;
  --kx-n-900:#161618;
  --kx-n-950:#0a0a0b;

  /* Surfaces */
  --kx-canvas:      var(--kx-n-50);
  --kx-surface:     var(--kx-n-0);
  --kx-surface-2:   var(--kx-n-50);
  --kx-surface-3:   var(--kx-n-100);
  --kx-surface-inv: var(--kx-n-950);

  /* Lines */
  --kx-border:        var(--kx-n-200);
  --kx-border-subtle: var(--kx-n-150);
  --kx-border-strong: var(--kx-n-300);

  /* The chevron on a `<select>`. A token rather than a rule, so the theme can
     recolour it without any rule other than `.form-select` ever mentioning
     `background-image` — the separation that produced the tiled chevrons. The
     stroke colour is baked into the SVG because `currentColor` is not
     available inside a `url(data:…)`. */
  --kx-select-chevron: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%2378787f' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'%3e%3cpath d='M4 6l4 4 4-4'/%3e%3c/svg%3e");

  /* Text */
  --kx-text:        var(--kx-n-950);
  --kx-text-2:      #2f2f35;
  --kx-text-muted:  #4f4f56;
  --kx-text-faint:  #7c7c84;
  --kx-text-inv:    var(--kx-n-0);

  /* Accent — black in light, white in dark. Deliberate, not decorative. */
  --kx-accent:        var(--kx-n-950);
  --kx-accent-hover:  var(--kx-n-800);
  --kx-accent-text:   var(--kx-n-0);
  --kx-focus-ring:    rgba(10, 10, 11, 0.16);

  /* Status — desaturated, readable, used only to carry meaning */
  --kx-success:     #15803d;
  --kx-success-bg:  #edf7f0;
  --kx-success-bd:  #cfe7d8;
  --kx-warning:     #a35a06;
  --kx-warning-bg:  #fdf4e7;
  --kx-warning-bd:  #f0dcbd;
  --kx-danger:      #b42318;
  --kx-danger-bg:   #fdf0ef;
  --kx-danger-bd:   #f3d3d0;
  /* Only ever the hover state of a destructive button. */
  --kx-danger-hover:#912018;
  --kx-danger-text: #ffffff;
  --kx-info:        #1d4ed8;
  --kx-info-bg:     #eef3fe;
  --kx-info-bd:     #d5e0fa;
  --kx-neutral:     var(--kx-n-600);
  --kx-neutral-bg:  var(--kx-n-100);
  --kx-neutral-bd:  var(--kx-n-200);

  /* Sidebar (light mode keeps it a quiet surface, not a slab of colour) */
  --kx-sidebar-bg:      var(--kx-n-0);
  --kx-sidebar-border:  var(--kx-border);
  --kx-sidebar-text:    #3a3a40;
  --kx-sidebar-text-hi: var(--kx-n-950);
  --kx-sidebar-hover:   var(--kx-n-100);
  --kx-sidebar-active:  var(--kx-n-100);
  --kx-sidebar-section: var(--kx-n-400);

  /* Type scale.
     --------------------------------------------------------------------
     Nine steps, and nothing between them. The stylesheet had grown a dozen
     one-off sizes — 1.175rem, 1.05rem, 0.975rem, 0.9rem, 0.78125rem — which is
     what made the hierarchy read as mush: `h3`, `h4` and `h5` were 18.8px,
     16.8px and 15.6px, differences a reader cannot see, so a sub-heading
     looked like body text in bold.

     Body is `md`. Each step from there is far enough from its neighbour to be
     legible as a level rather than as a rendering accident. The one size not
     on the scale is the 16px on mobile form controls, which is a hard iOS
     threshold rather than a design decision — see the media query that sets
     it. */
  --kx-fs-2xs: 0.6875rem;  /* 11px — badge counts, axis labels */
  --kx-fs-xs:  0.75rem;    /* 12px — eyebrows, timestamps */
  --kx-fs-sm:  0.8125rem;  /* 13px — help text, table meta, h6 */
  --kx-fs-md:  0.875rem;   /* 14px — dense UI text */
  --kx-fs-base:0.9375rem;  /* 15px — body, h5 */
  --kx-fs-lg:  1rem;       /* 16px */
  --kx-fs-xl:  1.125rem;   /* 18px — h4 */
  --kx-fs-2xl: 1.3125rem;  /* 21px — h3 */
  --kx-fs-3xl: 1.5rem;     /* 24px — h2, and a figure read across a room */
  --kx-fs-4xl: 1.75rem;    /* 28px — h1, page titles */

  /* Weight scale. Four steps, nothing between them. Inter is variable, so
     450 renders as drawn and reads crisper than 400 on Windows. */
  --kx-fw-body: 450;
  --kx-fw-label: 550;
  --kx-fw-strong: 640;
  --kx-fw-display: 720;

  /* Shape — restrained. Nothing is a pill unless it is a badge. */
  --kx-r-xs: 4px;
  --kx-r-sm: 6px;
  --kx-r-md: 8px;
  --kx-r-lg: 12px;
  --kx-r-xl: 16px;

  /* Elevation — light mode leans on shadow, dark mode on borders. */
  --kx-shadow-xs: 0 1px 2px rgba(10, 10, 11, 0.05);
  --kx-shadow-sm: 0 1px 3px rgba(10, 10, 11, 0.06), 0 1px 2px rgba(10, 10, 11, 0.04);
  --kx-shadow-md: 0 4px 12px rgba(10, 10, 11, 0.07), 0 1px 3px rgba(10, 10, 11, 0.05);
  --kx-shadow-lg: 0 12px 32px rgba(10, 10, 11, 0.10), 0 2px 8px rgba(10, 10, 11, 0.05);
  --kx-shadow-inner-top: inset 0 1px 0 rgba(255, 255, 255, 0.06);

  /* Type */
  --kx-font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --kx-font-mono: ui-monospace, SFMono-Regular, 'SF Mono', Menlo, Consolas, monospace;

  /* Layout */
  --kx-sidebar-w: 244px;
  --kx-sidebar-w-collapsed: 68px;
  --kx-topbar-h: 60px;

  color-scheme: light;
}

/* ==========================================================================
   2. Tokens (dark) — authored surfaces, not an inversion
   ========================================================================== */

[data-theme="dark"] {
  --kx-canvas:      #0a0a0b;
  --kx-surface:     #131316;
  --kx-surface-2:   #1a1a1e;
  --kx-surface-3:   #232328;
  --kx-surface-inv: #fafafa;

  --kx-border:        #27272c;
  --kx-border-subtle: #202024;
  --kx-border-strong: #38383f;

  --kx-select-chevron: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%238b8b95' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'%3e%3cpath d='M4 6l4 4 4-4'/%3e%3c/svg%3e");

  --kx-text:        #fafafa;
  --kx-text-2:      #d8d8df;
  --kx-text-muted:  #b9b9c3;
  --kx-text-faint:  #8f8f99;
  --kx-text-inv:    #0a0a0b;

  --kx-accent:        #fafafa;
  --kx-accent-hover:  #e4e4e7;
  --kx-accent-text:   #0a0a0b;
  --kx-focus-ring:    rgba(250, 250, 250, 0.22);

  /* Status in dark: lifted foregrounds on low-alpha tints so they glow softly
     rather than shouting. */
  --kx-success:     #63d38c;
  --kx-success-bg:  rgba(52, 168, 96, 0.13);
  --kx-success-bd:  rgba(52, 168, 96, 0.26);
  --kx-warning:     #e0a758;
  --kx-warning-bg:  rgba(197, 132, 47, 0.14);
  --kx-warning-bd:  rgba(197, 132, 47, 0.28);
  --kx-danger:      #f08076;
  --kx-danger-bg:   rgba(214, 84, 68, 0.14);
  --kx-danger-bd:   rgba(214, 84, 68, 0.28);
  --kx-danger-hover:#f5a49c;
  --kx-danger-text: #2a0b08;
  --kx-info:        #86a9f5;
  --kx-info-bg:     rgba(80, 120, 230, 0.14);
  --kx-info-bd:     rgba(80, 120, 230, 0.28);
  --kx-neutral:     #a9a9b2;
  --kx-neutral-bg:  rgba(255, 255, 255, 0.06);
  --kx-neutral-bd:  rgba(255, 255, 255, 0.10);

  --kx-sidebar-bg:      #0e0e10;
  --kx-sidebar-border:  #1f1f24;
  --kx-sidebar-text:    #c6c6ce;
  --kx-sidebar-text-hi: #fafafa;
  --kx-sidebar-hover:   rgba(255, 255, 255, 0.05);
  --kx-sidebar-active:  rgba(255, 255, 255, 0.08);
  --kx-sidebar-section: #63636c;

  --kx-shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.4);
  --kx-shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.45);
  --kx-shadow-md: 0 4px 14px rgba(0, 0, 0, 0.5);
  --kx-shadow-lg: 0 16px 40px rgba(0, 0, 0, 0.6);

  color-scheme: dark;
}

/* ==========================================================================
   3. Base elements
   ========================================================================== */

*,
*::before,
*::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

/* Bouncing past the end of a page shows what's behind it, and that has to be the footer's colour. */
html:has(.kx-public),
html:has(.kx-public) body {
  background: var(--kx-surface);
  overscroll-behavior-y: none;
}

body {
  background: var(--kx-canvas);
  color: var(--kx-text);
  font-family: var(--kx-font);
  font-size: 0.9375rem;
  font-weight: var(--kx-fw-body);
  line-height: 1.6;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: 'cv02', 'cv03', 'cv04', 'cv11';
  min-height: 100vh;
  margin: 0;
}

a {
  color: var(--kx-text);
  text-decoration: none;
  text-underline-offset: 0.2em;
}
a:hover { color: var(--kx-text); text-decoration: underline; }

hr {
  border: 0;
  border-top: 1px solid var(--kx-border);
  opacity: 1;
  margin: 1.25rem 0;
}

::selection { background: var(--kx-text); color: var(--kx-surface); }

:focus-visible {
  outline: 2px solid var(--kx-accent);
  outline-offset: 2px;
  border-radius: var(--kx-r-xs);
}

/* Keyboard-only skip link for the app and site shells. */
.kx-skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 2000;
  background: var(--kx-surface);
  color: var(--kx-text);
  border: 1px solid var(--kx-border-strong);
  border-radius: var(--kx-r-md);
  padding: 0.625rem 1rem;
  font-size: 0.875rem;
  font-weight: var(--kx-fw-strong);
  box-shadow: var(--kx-shadow-md);
}
.kx-skip-link:focus {
  left: 1rem;
  top: 1rem;
  text-decoration: none;
}

/* ==========================================================================
   4. Typography
   ========================================================================== */

h1, h2, h3, h4, h5, h6, .kx-font-display {
  font-family: var(--kx-font);
  color: var(--kx-text);
  font-weight: var(--kx-fw-strong);
  letter-spacing: -0.018em;
  line-height: 1.25;
  margin-top: 0;
}

h1 { font-size: var(--kx-fs-4xl); letter-spacing: -0.028em; }
h2 { font-size: var(--kx-fs-3xl); letter-spacing: -0.024em; }
h3 { font-size: var(--kx-fs-2xl); }
h4 { font-size: var(--kx-fs-xl); }
h5 { font-size: var(--kx-fs-base); }
h6 { font-size: var(--kx-fs-sm); }

p { margin-top: 0; }

small, .small { font-size: 0.8125rem; }

.kx-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.75rem;
  font-weight: var(--kx-fw-strong);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--kx-text-muted);
}

.kx-lead {
  font-size: var(--kx-fs-xl);
  line-height: 1.65;
  color: var(--kx-text-2);
}

.text-muted-kx { color: var(--kx-text-muted) !important; }
.kx-text-2 { color: var(--kx-text-2) !important; }

/* Money and any aligned figures share one lining, tabular treatment. */
.kx-num,
.kx-table td.kx-num,
.kx-stat-value,
.kx-money {
  font-variant-numeric: tabular-nums;
  font-feature-settings: 'tnum' 1;
}

.kx-mono {
  font-family: var(--kx-font-mono);
  font-size: 0.8125em;
  letter-spacing: -0.01em;
  color: var(--kx-text-muted);
}

/* Section heading used inside cards and panels. */
.kx-section-title {
  display: block;
  font-size: 0.9375rem;
  font-weight: var(--kx-fw-strong);
  letter-spacing: -0.01em;
  color: var(--kx-text);
  margin: 0;
}

/* Page header — one consistent pattern across every screen. */
.kx-page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1.5rem;
}
.kx-page-header h1,
.kx-page-header h2 {
  font-size: var(--kx-fs-2xl);
  margin: 0 0 0.2rem;
}
.kx-page-header .kx-page-desc {
  color: var(--kx-text-muted);
  font-size: 0.875rem;
  margin: 0;
  max-width: 68ch;
}
.kx-page-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.kx-back-link {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.8125rem;
  font-weight: var(--kx-fw-label);
  color: var(--kx-text-muted);
  margin-bottom: 0.625rem;
}
.kx-back-link:hover { color: var(--kx-text); text-decoration: none; }

/* ==========================================================================
   5. Buttons
   ========================================================================== */

.btn,
.kx-btn {
  --kx-btn-h: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  min-height: var(--kx-btn-h);
  padding: 0 0.875rem;
  border-radius: var(--kx-r-md);
  border: 1px solid transparent;
  font-family: var(--kx-font);
  font-size: 0.875rem;
  font-weight: var(--kx-fw-label);
  line-height: 1.2;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color 0.12s ease, border-color 0.12s ease, color 0.12s ease, box-shadow 0.12s ease;
}
.btn:focus-visible,
.kx-btn:focus-visible { box-shadow: 0 0 0 3px var(--kx-focus-ring); outline: none; }

.btn-sm, .kx-btn-sm { --kx-btn-h: 32px; padding: 0 0.6875rem; font-size: 0.8125rem; border-radius: var(--kx-r-sm); }
.btn-lg, .kx-btn-lg { --kx-btn-h: 44px; padding: 0 1.25rem; font-size: 0.9375rem; }

.btn i, .kx-btn i { font-size: 1em; line-height: 1; }
.btn.disabled, .btn:disabled, .kx-btn:disabled { opacity: 0.5; pointer-events: none; }

/* Primary — solid ink in light, solid white in dark. */
.btn-kx-primary {
  background: var(--kx-accent);
  border-color: var(--kx-accent);
  color: var(--kx-accent-text);
  box-shadow: var(--kx-shadow-xs);
}
.btn-kx-primary:hover,
.btn-kx-primary:focus {
  background: var(--kx-accent-hover);
  border-color: var(--kx-accent-hover);
  color: var(--kx-accent-text);
}

/* Secondary — the everyday button. */
.btn-kx-outline {
  background: var(--kx-surface);
  border-color: var(--kx-border-strong);
  color: var(--kx-text);
  box-shadow: var(--kx-shadow-xs);
}
.btn-kx-outline:hover,
.btn-kx-outline:focus {
  background: var(--kx-surface-2);
  border-color: var(--kx-border-strong);
  color: var(--kx-text);
}

/* Tertiary — for dense toolbars and icon-only actions. */
.btn-kx-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--kx-text-2);
}
.btn-kx-ghost:hover,
.btn-kx-ghost:focus {
  background: var(--kx-surface-3);
  color: var(--kx-text);
}

.btn-kx-danger {
  background: var(--kx-surface);
  border-color: var(--kx-danger-bd);
  color: var(--kx-danger);
  box-shadow: var(--kx-shadow-xs);
}
.btn-kx-danger:hover,
.btn-kx-danger:focus {
  background: var(--kx-danger-bg);
  border-color: var(--kx-danger);
  color: var(--kx-danger);
}

/* Legacy alias kept so no call site can silently lose its styling. */
.btn-kx-amber { background: var(--kx-accent); border-color: var(--kx-accent); color: var(--kx-accent-text); }
.btn-kx-amber:hover { background: var(--kx-accent-hover); border-color: var(--kx-accent-hover); color: var(--kx-accent-text); }

.btn-kx-icon { width: var(--kx-btn-h); padding: 0; }

/* Bootstrap overrides so third-party markup can't break the language. */
.btn-outline-danger  { background: var(--kx-surface); border-color: var(--kx-border-strong); color: var(--kx-text-2); box-shadow: var(--kx-shadow-xs); }
.btn-outline-danger:hover  { background: var(--kx-danger-bg); border-color: var(--kx-danger-bd); color: var(--kx-danger); }
.btn-outline-success { background: var(--kx-surface); border-color: var(--kx-border-strong); color: var(--kx-text-2); box-shadow: var(--kx-shadow-xs); }
.btn-outline-success:hover { background: var(--kx-success-bg); border-color: var(--kx-success-bd); color: var(--kx-success); }
.btn-success { background: var(--kx-success); border-color: var(--kx-success); color: #fff; }
.btn-success:hover { filter: brightness(0.94); color: #fff; }
.btn-dark { background: var(--kx-n-950); border-color: var(--kx-n-950); color: #fff; }

/* Button group — one seam, square inner corners. */
.btn-group > .btn { box-shadow: none; }
.btn-group > .btn:not(:first-child) { margin-left: -1px; }
.btn-group > .btn:hover { z-index: 2; }

/* Segmented control for list filters. */
.kx-segmented {
  display: inline-flex;
  padding: 3px;
  background: var(--kx-surface-3);
  border-radius: var(--kx-r-md);
  gap: 2px;
  /* A tab strip of four periods does not fit across a 320px phone. Scrolling
     it inside its own strip keeps every tab reachable, which shrinking the
     labels to two characters or dropping the last one would not. */
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.kx-segmented::-webkit-scrollbar { display: none; }
.kx-segmented a,
.kx-segmented button {
  display: inline-flex;
  align-items: center;
  flex: 0 0 auto;
  white-space: nowrap;
  gap: 0.35rem;
  padding: 0.3125rem 0.6875rem;
  border: 0;
  background: transparent;
  border-radius: var(--kx-r-sm);
  font-size: 0.8125rem;
  font-weight: var(--kx-fw-label);
  color: var(--kx-text-2);
  transition: background-color 0.12s ease, color 0.12s ease;
}
.kx-segmented a:hover,
.kx-segmented button:hover { color: var(--kx-text); text-decoration: none; }
.kx-segmented a.active,
.kx-segmented button.active {
  background: var(--kx-surface);
  color: var(--kx-text);
  box-shadow: var(--kx-shadow-xs);
}
[data-theme="dark"] .kx-segmented a.active,
[data-theme="dark"] .kx-segmented button.active { background: var(--kx-surface-3); }

/* ==========================================================================
   6. Forms
   ========================================================================== */

.form-label,
.kx-label {
  display: block;
  font-size: 0.8125rem;
  font-weight: var(--kx-fw-label);
  color: var(--kx-text);
  margin-bottom: 0.375rem;
}
.form-label .kx-optional,
.kx-label .kx-optional { color: var(--kx-text-faint); font-weight: var(--kx-fw-body); }

/* `background-color`, never the `background` shorthand, on any rule that can
   apply to a `.form-select`.

   The shorthand resets every background longhand it does not mention —
   including `background-image`, `background-repeat`, `background-size` and
   `background-position`, which are what put a single chevron at the right-hand
   end of a select and keep it there. A state rule using the shorthand therefore
   silently throws the chevron's geometry away, and what happens next depends on
   whether some *other* rule is still supplying the image:

   - dark mode: `[data-theme="dark"] .form-select` (specificity 0,2,0) outranks
     `.form-select:focus` (0,1,1), so the image survived while its `no-repeat`
     did not — and a focused select grew a row of three chevrons marching across
     it, which is what this looked like in use;
   - light mode: nothing outranked the shorthand, so the chevron simply vanished
     the moment the select was focused.

   One bug, two appearances. The chevron itself is now defined once, as
   `--kx-select-chevron` (see `.form-select` below), so no theme rule ever needs
   to restate `background-image` and the geometry can no longer be separated
   from the image it belongs to. */
.form-control,
.form-select,
.kx-input {
  width: 100%;
  min-height: 38px;
  padding: 0.4375rem 0.6875rem;
  background-color: var(--kx-surface);
  border: 1px solid var(--kx-border-strong);
  border-radius: var(--kx-r-md);
  color: var(--kx-text);
  font-family: var(--kx-font);
  font-size: 0.875rem;
  line-height: 1.5;
  box-shadow: var(--kx-shadow-xs);
  transition: border-color 0.12s ease, box-shadow 0.12s ease, background-color 0.12s ease;
}
.form-control::placeholder { color: var(--kx-text-faint); }
.form-control:hover,
.form-select:hover { border-color: var(--kx-n-400); }
[data-theme="dark"] .form-control:hover,
[data-theme="dark"] .form-select:hover { border-color: var(--kx-border-strong); }

.form-control:focus,
.form-select:focus,
.kx-input:focus {
  background-color: var(--kx-surface);
  border-color: var(--kx-accent);
  color: var(--kx-text);
  box-shadow: 0 0 0 3px var(--kx-focus-ring);
  outline: none;
}
.form-control:disabled,
.form-select:disabled {
  background-color: var(--kx-surface-3);
  color: var(--kx-text-muted);
  cursor: not-allowed;
}
.form-control-sm, .form-select-sm { min-height: 32px; padding: 0.25rem 0.5rem; font-size: 0.8125rem; border-radius: var(--kx-r-sm); }

textarea.form-control { min-height: 84px; line-height: 1.55; }

/* The chevron is declared in exactly one place, and the theme changes only its
   colour. That is the point: while `background-image` was restated per theme,
   any rule that touched the shorthand could keep the image and drop its
   `no-repeat` — see the note above the `.form-control` block. A custom property
   cannot come apart from the four longhands that position it, because there is
   only ever one rule setting them. */
.form-select {
  background-image: var(--kx-select-chevron);
  background-repeat: no-repeat;
  background-position: right 0.625rem center;
  background-size: 15px 15px;
  padding-right: 2rem;
  appearance: none;
}

/* Date/file inputs keep the same skin in dark mode. */
[data-theme="dark"] input[type="date"]::-webkit-calendar-picker-indicator,
[data-theme="dark"] input[type="datetime-local"]::-webkit-calendar-picker-indicator { filter: invert(0.8); }
.form-control[type="file"] { padding: 0.3125rem 0.6875rem; }
.form-control[type="file"]::file-selector-button {
  margin: -0.3125rem 0.75rem -0.3125rem -0.6875rem;
  padding: 0.4375rem 0.75rem;
  border: 0;
  border-right: 1px solid var(--kx-border);
  background: var(--kx-surface-2);
  color: var(--kx-text);
  font-size: 0.8125rem;
  font-weight: var(--kx-fw-label);
  cursor: pointer;
}

.form-text,
.kx-help {
  display: block;
  font-size: 0.8125rem;
  color: var(--kx-text-muted);
  margin-top: 0.375rem;
  line-height: 1.5;
}

.kx-error,
.invalid-feedback,
.errorlist {
  display: block;
  font-size: 0.8125rem;
  color: var(--kx-danger);
  margin-top: 0.375rem;
  list-style: none;
  padding: 0;
}
.form-control.is-invalid,
.kx-input.is-invalid { border-color: var(--kx-danger); }
.form-control.is-invalid:focus { box-shadow: 0 0 0 3px var(--kx-danger-bd); }

/* Checkboxes & radios */
.form-check { padding-left: 1.6rem; margin-bottom: 0.35rem; }
.form-check-input {
  width: 1rem;
  height: 1rem;
  margin-left: -1.6rem;
  margin-top: 0.28rem;
  background-color: var(--kx-surface);
  border: 1px solid var(--kx-border-strong);
  box-shadow: var(--kx-shadow-xs);
  cursor: pointer;
}
.form-check-input:checked {
  background-color: var(--kx-accent);
  border-color: var(--kx-accent);
}
[data-theme="dark"] .form-check-input:checked {
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3e%3cpath fill='none' stroke='%230a0a0b' stroke-linecap='round' stroke-linejoin='round' stroke-width='3' d='m6 10 3 3 6-6'/%3e%3c/svg%3e");
}
[data-theme="dark"] .form-check-input:checked[type="radio"] {
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='-4 -4 8 8'%3e%3ccircle r='2' fill='%230a0a0b'/%3e%3c/svg%3e");
}
.form-check-input:focus { border-color: var(--kx-accent); box-shadow: 0 0 0 3px var(--kx-focus-ring); }
.form-check-label { font-size: 0.875rem; color: var(--kx-text); cursor: pointer; }

/* A permission grid is a form, not a table of data — give it its own affordances. */
.kx-perm-table th { white-space: nowrap; }
.kx-perm-table td.kx-perm-cell { text-align: center; }
.kx-perm-table input[type="checkbox"] {
  width: 1rem;
  height: 1rem;
  accent-color: var(--kx-accent);
  cursor: pointer;
  vertical-align: middle;
}
.kx-perm-table tbody tr:hover { background: var(--kx-surface-2); }

/* Field group spacing used by the polished forms. */
.kx-field { margin-bottom: 1rem; }
.kx-fieldset { border: 0; padding: 0; margin: 0 0 0.5rem; }
.kx-fieldset-legend {
  font-size: 0.8125rem;
  font-weight: var(--kx-fw-strong);
  color: var(--kx-text);
  padding: 0;
  margin-bottom: 0.75rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.kx-fieldset-legend::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--kx-border);
}

/* A field the system fills in rather than the operator: shown in the place the
   input would have been, so the form still reads as a complete set of answers. */
.kx-field-static {
  margin: 0;
  padding: 0.5rem 0;
  font-size: 0.875rem;
  font-weight: var(--kx-fw-label);
  color: var(--kx-text-muted);
}

/* "Unsaved changes" on a Settings card. Each card is its own form now, so the
   page has to say which one has been touched; a single Save at the bottom of
   eight fieldsets was exactly the thing that made this necessary to fix. */
.kx-unsaved {
  padding: 0.1875rem 0.5rem;
  border-radius: 999px;
  background: var(--kx-warning-bg);
  border: 1px solid var(--kx-warning-bd);
  font-size: 0.6875rem;
  font-weight: var(--kx-fw-strong);
  letter-spacing: 0.01em;
  color: var(--kx-text);
}

/* A group heading on the reports index. Fifteen tiles in one grid is a wall;
   four small headings turn it back into a menu. */
.kx-reports-heading {
  display: block;
  margin: 1.5rem 0 0.75rem;
  font-size: 0.75rem;
  font-weight: var(--kx-fw-strong);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--kx-text-muted);
}
.kx-reports-heading:first-of-type { margin-top: 0; }

/* The export picker.

   Twenty datasets stacked one per row ran to a page and a half with the
   right-hand third of the screen empty beside them, and the group headings
   read as more rows because they carried the same weight as the labels. So:
   six headings that look like headings, the datasets two across under each,
   and the whole tile as the label so the target is the row rather than a 16px
   box. The aside follows the list down, because a Submit at the top of a long
   list is a Submit nobody can find at the bottom of it. */

.kx-export-group + .kx-export-group { margin-top: 1.75rem; }
.kx-export-group-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.625rem;
}
.kx-export-group-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0;
  cursor: pointer;
}
.kx-export-group-toggle .form-check-input { margin: 0; float: none; flex-shrink: 0; }
.kx-export-group-name {
  font-size: 0.75rem;
  font-weight: var(--kx-fw-strong);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--kx-text-2);
}
.kx-export-group-count {
  font-size: 0.75rem;
  color: var(--kx-text-faint);
  font-variant-numeric: tabular-nums lining-nums;
}

.kx-export-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.5rem;
}
.kx-export-row {
  display: flex;
  align-items: flex-start;
  gap: 0.625rem;
  margin: 0;
  padding: 0.75rem 0.875rem;
  border: 1px solid var(--kx-border);
  border-radius: var(--kx-r-md);
  background: var(--kx-surface);
  cursor: pointer;
  transition: border-color 0.12s ease, background-color 0.12s ease;
}
.kx-export-row:hover { border-color: var(--kx-border-strong); background: var(--kx-surface-2); }
.kx-export-row .form-check-input { margin: 0.15rem 0 0; float: none; flex-shrink: 0; }
.kx-export-body { display: flex; flex-direction: column; gap: 0.1875rem; min-width: 0; }
.kx-export-name {
  display: inline-flex;
  align-items: center;
  gap: 0.4375rem;
  font-size: 0.875rem;
  font-weight: var(--kx-fw-label);
  color: var(--kx-text);
}
.kx-export-desc { font-size: 0.75rem; line-height: 1.5; color: var(--kx-text-muted); }

/* A checkbox that is off does not mean the row is unreadable. */
.kx-export-row .form-check-input:disabled { opacity: 1; }

/* The aside travels with the list. `top` clears the sticky topbar. */
.kx-export-aside { position: sticky; top: calc(var(--kx-topbar-h) + 1rem); }

/* The same headings on the review table. */
.kx-export-group-row th {
  padding-top: 1rem;
  font-size: 0.75rem;
  font-weight: var(--kx-fw-strong);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--kx-text-muted);
}

/* Form action bar sits on a hairline so long forms read as finished. */
.kx-form-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  padding-top: 1.125rem;
  margin-top: 0.5rem;
  border-top: 1px solid var(--kx-border);
}

/* ==========================================================================
   7. Cards & surfaces
   ========================================================================== */

.kx-card,
.card {
  background: var(--kx-surface);
  border: 1px solid var(--kx-border);
  border-radius: var(--kx-r-lg);
  box-shadow: var(--kx-shadow-sm);
}
[data-theme="dark"] .kx-card,
[data-theme="dark"] .card { box-shadow: none; }

.kx-card-body { padding: 1.25rem; }
.kx-card-body.p-0 { padding: 0; }

.kx-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
  padding: 0.875rem 1.25rem;
  border-bottom: 1px solid var(--kx-border);
}
.kx-card-footer {
  padding: 0.875rem 1.25rem;
  border-top: 1px solid var(--kx-border);
  background: var(--kx-surface-2);
  border-radius: 0 0 var(--kx-r-lg) var(--kx-r-lg);
}

/* Interactive cards (property tiles, report tiles). */
.kx-card-link {
  display: block;
  color: inherit;
  transition: border-color 0.14s ease, box-shadow 0.14s ease, transform 0.14s ease;
}
.kx-card-link:hover { text-decoration: none; color: inherit; }
.kx-card-interactive:hover {
  border-color: var(--kx-border-strong);
  box-shadow: var(--kx-shadow-md);
}
[data-theme="dark"] .kx-card-interactive:hover { background: var(--kx-surface-2); box-shadow: none; }

/* Compact fact strip (lease terms, meta rows). */
.kx-meta-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.75rem;
  padding: 0.75rem 1.25rem;
  font-size: 0.8125rem;
  color: var(--kx-text-muted);
}
.kx-meta-strip strong { color: var(--kx-text); font-weight: var(--kx-fw-strong); }
.kx-meta-strip > span { display: inline-flex; align-items: center; gap: 0.4rem; }

.kx-divider { height: 1px; background: var(--kx-border); border: 0; margin: 1.25rem 0; }

/* ==========================================================================
   8. Tables
   ========================================================================== */

.kx-table-wrap {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.table {
  width: 100%;
  margin: 0;
  font-size: 0.875rem;
  color: var(--kx-text);
  border-collapse: separate;
  border-spacing: 0;
}

.table > thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--kx-surface);
  padding: 0.625rem 0.875rem;
  font-size: 0.75rem;
  font-weight: var(--kx-fw-strong);
  letter-spacing: 0.02em;
  color: var(--kx-text-muted);
  text-transform: none;
  white-space: nowrap;
  border-bottom: 1px solid var(--kx-border);
  vertical-align: middle;
}

.table > tbody td {
  padding: 0.6875rem 0.875rem;
  border-bottom: 1px solid var(--kx-border-subtle);
  vertical-align: middle;
  color: var(--kx-text);
  background: transparent;
}
.table > tbody tr:last-child td { border-bottom: 0; }
.table > tbody tr { transition: background-color 0.1s ease; }
.table.kx-table-hover > tbody tr:hover td,
.table > tbody tr.kx-row-link:hover td { background: var(--kx-surface-2); }

.table td a { font-weight: var(--kx-fw-label); }
.table td a:hover { text-decoration: underline; }

/* Numbers align right and share a column rhythm. */
.table th.kx-num, .table td.kx-num { text-align: right; font-variant-numeric: tabular-nums; }
.table td.kx-cell-strong { font-weight: var(--kx-fw-strong); }
.table td.kx-cell-muted, .table td .kx-cell-muted { color: var(--kx-text-muted); }

/* A second line under a cell's main value, for the reason behind it — why a
   rent charge is not a whole month, for instance. Smaller and muted so the
   figure stays the thing being read. */
.table td .kx-cell-sub {
  display: block;
  margin-top: 0.15rem;
  font-size: 0.75rem;
  line-height: 1.35;
  color: var(--kx-text-muted);
}
.table td.kx-actions { text-align: right; white-space: nowrap; }
.table td.kx-actions .btn + .btn,
.table td.kx-actions .btn + form,
.table td.kx-actions form + form { margin-left: 0.25rem; }

.table-borderless > tbody td { border-bottom: 0; }
.table-sm > tbody td, .table-sm > thead th { padding: 0.4375rem 0.625rem; }

/* A table that fills a card edge-to-edge. */
.kx-card > .kx-table-wrap > .table > thead th:first-child,
.kx-card > .kx-table-wrap > .table > tbody td:first-child { padding-left: 1.25rem; }
.kx-card > .kx-table-wrap > .table > thead th:last-child,
.kx-card > .kx-table-wrap > .table > tbody td:last-child { padding-right: 1.25rem; }

/* Totals row. */
.table tfoot td,
.table tr.kx-total td {
  border-top: 1px solid var(--kx-border-strong);
  border-bottom: 0;
  font-weight: var(--kx-fw-strong);
  background: var(--kx-surface-2);
}

/* ==========================================================================
   9. Badges & status
   ========================================================================== */

.kx-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.1875rem 0.5rem;
  border-radius: 999px;
  border: 1px solid transparent;
  font-size: 0.75rem;
  font-weight: var(--kx-fw-label);
  line-height: 1.4;
  white-space: nowrap;
  vertical-align: middle;
}
.kx-badge::before {
  content: '';
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: currentColor;
  flex-shrink: 0;
}
.kx-badge.kx-badge-plain::before { display: none; }

.kx-badge-success, .kx-badge-paid, .kx-badge-active, .kx-badge-occupied {
  background: var(--kx-success-bg); border-color: var(--kx-success-bd); color: var(--kx-success);
}
.kx-badge-warning, .kx-badge-partial, .kx-badge-pending {
  background: var(--kx-warning-bg); border-color: var(--kx-warning-bd); color: var(--kx-warning);
}
.kx-badge-danger, .kx-badge-unpaid, .kx-badge-rejected {
  background: var(--kx-danger-bg); border-color: var(--kx-danger-bd); color: var(--kx-danger);
}
.kx-badge-info {
  background: var(--kx-info-bg); border-color: var(--kx-info-bd); color: var(--kx-info);
}
.kx-badge-neutral, .kx-badge-inactive, .kx-badge-vacant {
  background: var(--kx-neutral-bg); border-color: var(--kx-neutral-bd); color: var(--kx-neutral);
}
.kx-badge-preview {
  background: var(--kx-surface-inv); border-color: var(--kx-surface-inv); color: var(--kx-text-inv);
}
.kx-badge-outline {
  background: transparent; border-color: var(--kx-border-strong); color: var(--kx-text-2);
}

.kx-badge-lg { padding: 0.25rem 0.625rem; font-size: 0.8125rem; }

/* Amounts that carry meaning. */
.kx-amount-credit { color: var(--kx-success); font-weight: var(--kx-fw-strong); }
.kx-amount-due { color: var(--kx-text); font-weight: var(--kx-fw-strong); }
.kx-amount-zero { color: var(--kx-text-muted); }

/* ==========================================================================
   10. Alerts, toasts, empty & loading states
   ========================================================================== */

.kx-alert,
.alert {
  display: flex;
  align-items: flex-start;
  gap: 0.625rem;
  padding: 0.75rem 0.9375rem;
  border: 1px solid var(--kx-border);
  border-radius: var(--kx-r-md);
  background: var(--kx-surface-2);
  color: var(--kx-text);
  font-size: 0.875rem;
  line-height: 1.55;
  margin-bottom: 1rem;
}
.kx-alert i:first-child,
.alert > i:first-child { flex-shrink: 0; margin-top: 0.15rem; font-size: var(--kx-fs-base); }
.kx-alert-title { font-weight: var(--kx-fw-strong); display: block; margin-bottom: 0.15rem; }

.kx-alert-success, .alert-success { background: var(--kx-success-bg); border-color: var(--kx-success-bd); color: var(--kx-text); }
.kx-alert-warning, .alert-warning { background: var(--kx-warning-bg); border-color: var(--kx-warning-bd); color: var(--kx-text); }
.kx-alert-danger,  .alert-danger  { background: var(--kx-danger-bg);  border-color: var(--kx-danger-bd);  color: var(--kx-text); }
.kx-alert-info,    .alert-info    { background: var(--kx-info-bg);    border-color: var(--kx-info-bd);    color: var(--kx-text); }
.kx-alert-success i:first-child { color: var(--kx-success); }
.kx-alert-warning i:first-child { color: var(--kx-warning); }
.kx-alert-danger i:first-child  { color: var(--kx-danger); }
.kx-alert-info i:first-child    { color: var(--kx-info); }

/* Toasts */
/* ---- Cookie notice -----------------------------------------------------

   Bottom of the viewport rather than a centred modal: it is an FYI, not a
   decision, and nothing on the page should be unreachable behind it. It sits
   below the toast region's z-index so a flash message — which *is* about
   something the reader just did — is never covered by it.

   `hidden` is honoured by the [hidden] rule; the script clears it only when
   the notice has not already been dismissed. */
.kx-cookie-notice {
  position: fixed;
  left: 1rem;
  right: 1rem;
  bottom: 1rem;
  /* Under the menu (1050), dialogs (1055) and their backdrops, or it covers their buttons. */
  z-index: 1030;
  margin-inline: auto;
  width: min(680px, calc(100vw - 2rem));
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.875rem 1rem;
  background: var(--kx-surface);
  border: 1px solid var(--kx-border);
  border-radius: var(--kx-r-md);
  box-shadow: var(--kx-shadow-lg);
  color: var(--kx-text);
  font-size: 0.875rem;
  line-height: 1.5;
  animation: kx-cookie-in 0.22s cubic-bezier(0.16, 1, 0.3, 1);
}
/* Rises from below. `kx-toast-in` drops from above, which is right for a
   toast pinned to the top and backwards for a bar pinned to the bottom. */
@keyframes kx-cookie-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: none; }
}
@media (prefers-reduced-motion: reduce) {
  .kx-cookie-notice { animation: none; }
}
.kx-cookie-notice[hidden] { display: none; }
.kx-cookie-notice-text { margin: 0; flex: 1; min-width: 0; overflow-wrap: anywhere; }
.kx-cookie-notice-text a { color: var(--kx-text); text-decoration: underline; }
.kx-cookie-notice .btn { flex-shrink: 0; }

.kx-toast-region {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 1080;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  width: min(380px, calc(100vw - 2rem));
}
.kx-toast {
  display: flex;
  align-items: flex-start;
  gap: 0.625rem;
  padding: 0.75rem 0.875rem;
  background: var(--kx-surface);
  border: 1px solid var(--kx-border);
  border-radius: var(--kx-r-md);
  box-shadow: var(--kx-shadow-lg);
  font-size: 0.875rem;
  line-height: 1.5;
  color: var(--kx-text);
  animation: kx-toast-in 0.22s cubic-bezier(0.16, 1, 0.3, 1);
}
.kx-toast .kx-toast-icon { flex-shrink: 0; margin-top: 0.1rem; font-size: 1rem; }
.kx-toast-success .kx-toast-icon { color: var(--kx-success); }
.kx-toast-warning .kx-toast-icon { color: var(--kx-warning); }
.kx-toast-danger  .kx-toast-icon { color: var(--kx-danger); }
.kx-toast-info    .kx-toast-icon { color: var(--kx-info); }
.kx-toast-body { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.kx-toast-close {
  flex-shrink: 0;
  background: none;
  border: 0;
  padding: 0.1rem 0.2rem;
  color: var(--kx-text-faint);
  font-size: var(--kx-fs-md);
  line-height: 1;
  cursor: pointer;
  border-radius: var(--kx-r-xs);
}
.kx-toast-close:hover { color: var(--kx-text); }
.kx-toast.kx-toast-leaving { animation: kx-toast-out 0.16s ease forwards; }

@keyframes kx-toast-in {
  from { opacity: 0; transform: translateY(-6px) scale(0.99); }
  to   { opacity: 1; transform: none; }
}
@keyframes kx-toast-out {
  to { opacity: 0; transform: translateX(8px); }
}

/* Empty states — the same anatomy everywhere: mark, headline, one sentence, one action. */
.kx-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 3rem 1.5rem;
}
.kx-empty-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  margin-bottom: 0.875rem;
  border-radius: var(--kx-r-lg);
  background: var(--kx-surface-3);
  color: var(--kx-text-muted);
  font-size: 1.125rem;
}
.kx-empty-title {
  font-size: 0.9375rem;
  font-weight: var(--kx-fw-strong);
  color: var(--kx-text);
  margin: 0 0 0.25rem;
}
.kx-empty-text {
  font-size: 0.875rem;
  color: var(--kx-text-muted);
  max-width: 44ch;
  margin: 0;
}
.kx-empty-actions { margin-top: 1.125rem; display: flex; gap: 0.5rem; flex-wrap: wrap; justify-content: center; }
td .kx-empty, th .kx-empty { padding: 2.25rem 1rem; }

/* Loading */
.kx-spinner {
  display: inline-block;
  width: 1em;
  height: 1em;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: kx-spin 0.7s linear infinite;
  vertical-align: -0.125em;
}
@keyframes kx-spin { to { transform: rotate(360deg); } }

.kx-skeleton {
  background: linear-gradient(90deg, var(--kx-surface-3) 25%, var(--kx-surface-2) 37%, var(--kx-surface-3) 63%);
  background-size: 400% 100%;
  animation: kx-shimmer 1.4s ease infinite;
  border-radius: var(--kx-r-sm);
  height: 0.75rem;
}
@keyframes kx-shimmer {
  0%   { background-position: 100% 50%; }
  100% { background-position: 0 50%; }
}

/* Alpine: keep x-show content hidden until Alpine has booted. */
[x-cloak] { display: none !important; }

/* htmx: show a progress hint only while a request is genuinely in flight. */
.kx-indicator { display: none; }
.htmx-request .kx-indicator,
.htmx-request.kx-indicator { display: inline-flex; }
.htmx-request.kx-swap-target { opacity: 0.55; transition: opacity 0.12s ease; }

/* Buttons announce their own work. */
.kx-btn-busy { position: relative; pointer-events: none; color: transparent !important; }
.kx-btn-busy::after {
  content: '';
  position: absolute;
  inset: 0;
  margin: auto;
  width: 1em;
  height: 1em;
  border: 2px solid var(--kx-accent-text);
  border-right-color: transparent;
  border-radius: 50%;
  animation: kx-spin 0.7s linear infinite;
}

/* ==========================================================================
   11. Modals, dropdowns, tooltips
   ========================================================================== */

.modal-content {
  background: var(--kx-surface);
  border: 1px solid var(--kx-border);
  border-radius: var(--kx-r-lg);
  box-shadow: var(--kx-shadow-lg);
  color: var(--kx-text);
}
.modal-backdrop.show { opacity: 0.5; }
[data-theme="dark"] .modal-backdrop.show { opacity: 0.7; }

.modal-header {
  align-items: flex-start;
  padding: 1.125rem 1.25rem 0.875rem;
  border-bottom: 1px solid var(--kx-border);
}
.modal-title { font-size: 1rem; font-weight: var(--kx-fw-strong); letter-spacing: -0.01em; }
.modal-header .kx-modal-desc { font-size: 0.8125rem; color: var(--kx-text-muted); margin: 0.2rem 0 0; }
.modal-body { padding: 1.25rem; }
.modal-footer {
  padding: 0.875rem 1.25rem;
  border-top: 1px solid var(--kx-border);
  background: var(--kx-surface-2);
  border-radius: 0 0 var(--kx-r-lg) var(--kx-r-lg);
  gap: 0.5rem;
}
.modal-footer > * { margin: 0; }
.btn-close {
  --bs-btn-close-opacity: 0.5;
  padding: 0.5rem;
  border-radius: var(--kx-r-sm);
}
.btn-close:hover { --bs-btn-close-opacity: 1; background-color: var(--kx-surface-3); }
[data-theme="dark"] .btn-close { filter: invert(1) grayscale(1); }

.dropdown-menu {
  --bs-dropdown-bg: var(--kx-surface);
  --bs-dropdown-border-color: var(--kx-border);
  --bs-dropdown-link-color: var(--kx-text);
  --bs-dropdown-link-hover-bg: var(--kx-surface-2);
  --bs-dropdown-link-hover-color: var(--kx-text);
  --bs-dropdown-link-active-bg: var(--kx-surface-3);
  --bs-dropdown-link-active-color: var(--kx-text);
  --bs-dropdown-divider-bg: var(--kx-border);
  padding: 0.3125rem;
  border-radius: var(--kx-r-lg);
  box-shadow: var(--kx-shadow-lg);
  font-size: 0.875rem;
  min-width: 12rem;
}
.dropdown-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4375rem 0.625rem;
  border-radius: var(--kx-r-sm);
  font-size: 0.875rem;
}
.dropdown-item i { color: var(--kx-text-muted); width: 1rem; text-align: center; }
.dropdown-item:hover i { color: var(--kx-text); }
.dropdown-item-text { padding: 0.4375rem 0.625rem; }
.dropdown-header {
  padding: 0.4375rem 0.625rem;
  font-size: 0.75rem;
  font-weight: var(--kx-fw-strong);
  color: var(--kx-text-muted);
}
.dropdown-divider { margin: 0.3125rem 0; border-color: var(--kx-border); }

.tooltip-inner {
  background: var(--kx-surface-inv);
  color: var(--kx-text-inv);
  border-radius: var(--kx-r-sm);
  font-size: 0.75rem;
  padding: 0.3125rem 0.5rem;
}
.tooltip .tooltip-arrow::before { border-top-color: var(--kx-surface-inv); }

/* ==========================================================================
   12. App shell
   ========================================================================== */

.kx-app {
  display: flex;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--kx-canvas);
}

.kx-sidebar {
  position: sticky;
  top: 0;
  z-index: 30;
  flex-shrink: 0;
  width: var(--kx-sidebar-w);
  /* `dvh` tracks the viewport as a phone's browser chrome slides in and out;
     `vh` does not, and measures the *tallest* the viewport ever gets. At 100vh
     the drawer ran past the bottom of the screen by the height of the address
     bar, which put Log out — and the last nav items on a short phone — where
     they could not be reached or even seen. The vh line stays first as the
     fallback for browsers without dvh. */
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--kx-sidebar-bg);
  border-right: 1px solid var(--kx-sidebar-border);
  transition: width 0.18s ease;
}
.kx-sidebar.collapsed { width: var(--kx-sidebar-w-collapsed); }
.kx-sidebar.collapsed .kx-sidebar-label,
.kx-sidebar.collapsed .kx-logo-text,
.kx-sidebar.collapsed .kx-sidebar-section-title,
.kx-sidebar.collapsed .kx-sidebar-lock { display: none; }
.kx-sidebar.collapsed .kx-sidebar-brand,
.kx-sidebar.collapsed .kx-sidebar-link,
.kx-sidebar.collapsed .kx-sidebar-foot { justify-content: center; padding-left: 0; padding-right: 0; }
.kx-sidebar.collapsed .kx-sidebar-nav { padding-left: 0.5rem; padding-right: 0.5rem; }

.kx-sidebar-brand {
  display: flex;
  align-items: center;
  gap: 0.5625rem;
  height: var(--kx-topbar-h);
  padding: 0 1rem;
  flex-shrink: 0;
  border-bottom: 1px solid var(--kx-sidebar-border);
  color: var(--kx-sidebar-text-hi);
}
.kx-sidebar-brand:hover { text-decoration: none; color: var(--kx-sidebar-text-hi); }

.kx-sidebar-nav {
  flex: 1;
  padding: 0.75rem;
  overflow-y: auto;
  overscroll-behavior: contain;
}
.kx-sidebar-nav::-webkit-scrollbar { width: 6px; }
.kx-sidebar-nav::-webkit-scrollbar-thumb { background: var(--kx-border-strong); border-radius: 3px; }

.kx-sidebar-section-title {
  padding: 0 0.5rem;
  margin: 1.125rem 0 0.375rem;
  font-size: 0.6875rem;
  font-weight: var(--kx-fw-strong);
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--kx-sidebar-section);
}
.kx-sidebar-nav > .kx-sidebar-section-title:first-child { margin-top: 0.125rem; }

.kx-sidebar-link {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.625rem;
  padding: 0.4375rem 0.5rem;
  margin-bottom: 1px;
  border-radius: var(--kx-r-sm);
  color: var(--kx-sidebar-text);
  font-size: 0.875rem;
  font-weight: var(--kx-fw-label);
  transition: background-color 0.12s ease, color 0.12s ease;
}
.kx-sidebar-link:hover {
  background: var(--kx-sidebar-hover);
  color: var(--kx-sidebar-text-hi);
  text-decoration: none;
}
.kx-sidebar-link.active {
  background: var(--kx-sidebar-active);
  color: var(--kx-sidebar-text-hi);
  font-weight: var(--kx-fw-strong);
}
.kx-sidebar-link i:first-child {
  width: 1.125rem;
  flex-shrink: 0;
  text-align: center;
  font-size: 1rem;
  color: var(--kx-text-faint);
}
.kx-sidebar-link:hover i:first-child,
.kx-sidebar-link.active i:first-child { color: var(--kx-sidebar-text-hi); }
.kx-sidebar-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kx-sidebar-lock { margin-left: auto; font-size: 0.75rem; color: var(--kx-text-faint); }
.kx-sidebar-link[aria-disabled="true"] { cursor: pointer; }

.kx-sidebar-foot {
  padding: 0.75rem;
  border-top: 1px solid var(--kx-sidebar-border);
  flex-shrink: 0;
}

/* A <button> standing in for a link (POST-only logout). */
.kx-link-btn {
  background: none;
  border: 0;
  width: 100%;
  text-align: left;
  font: inherit;
  cursor: pointer;
}

.kx-sidebar-backdrop { display: none; }

.kx-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.kx-topbar {
  position: sticky;
  top: 0;
  z-index: 25;
  display: flex;
  align-items: center;
  gap: 0.625rem;
  height: var(--kx-topbar-h);
  padding: 0 1.25rem;
  background: color-mix(in srgb, var(--kx-surface) 88%, transparent);
  backdrop-filter: saturate(180%) blur(10px);
  -webkit-backdrop-filter: saturate(180%) blur(10px);
  border-bottom: 1px solid var(--kx-border);
}
@supports not (backdrop-filter: blur(1px)) {
  .kx-topbar { background: var(--kx-surface); }
}

.kx-search {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex: 1;
  max-width: 380px;
  height: 34px;
  padding: 0 0.6875rem;
  background: var(--kx-surface-2);
  border: 1px solid var(--kx-border);
  border-radius: var(--kx-r-md);
  color: var(--kx-text-muted);
  transition: border-color 0.12s ease, box-shadow 0.12s ease;
}
.kx-search:focus-within {
  border-color: var(--kx-accent);
  box-shadow: 0 0 0 3px var(--kx-focus-ring);
  background: var(--kx-surface);
}
.kx-search input {
  flex: 1;
  min-width: 0;
  background: transparent;
  border: 0;
  outline: none;
  font-size: 0.8125rem;
  color: var(--kx-text);
}
.kx-search input::placeholder { color: var(--kx-text-faint); }
.kx-search kbd {
  font-family: var(--kx-font);
  font-size: 0.6875rem;
  color: var(--kx-text-faint);
  background: var(--kx-surface);
  border: 1px solid var(--kx-border);
  border-radius: var(--kx-r-xs);
  padding: 0.05rem 0.3rem;
}

/* The assistant's Ctrl+K trigger, styled as the search box it replaced. */

.kx-ai-trigger {
  cursor: pointer;
  text-align: left;
  font: inherit;
}
.kx-ai-trigger:hover { border-color: var(--kx-border-strong); background: var(--kx-surface); }
.kx-ai-trigger:focus-visible { outline: none; border-color: var(--kx-accent); box-shadow: 0 0 0 3px var(--kx-focus-ring); }
.kx-ai-trigger-text {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  font-size: var(--kx-fs-sm);
  color: var(--kx-text-faint);
}

.kx-ai-kbd {
  display: inline-flex;
  align-items: center;
  font-family: var(--kx-font);
  font-size: var(--kx-fs-2xs);
  line-height: 1;
  color: var(--kx-text-muted);
  background: var(--kx-surface);
  border: 1px solid var(--kx-border);
  border-bottom-width: 2px;
  border-radius: var(--kx-r-xs);
  padding: 0.2rem 0.35rem;
}


.kx-topbar-actions {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  margin-left: auto;
}

.kx-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border: 1px solid transparent;
  border-radius: var(--kx-r-md);
  background: transparent;
  color: var(--kx-text-2);
  font-size: 0.9375rem;
  cursor: pointer;
  transition: background-color 0.12s ease, color 0.12s ease;
}
.kx-icon-btn:hover { background: var(--kx-surface-3); color: var(--kx-text); }
.kx-icon-btn:focus-visible { box-shadow: 0 0 0 3px var(--kx-focus-ring); outline: none; }

.kx-bell-wrap { position: relative; }
/* Anchored from the left so a longer count grows away from the bell. */
.kx-bell-badge {
  position: absolute;
  top: 1px;
  left: 52%;
  min-width: 15px;
  height: 15px;
  padding: 0 3px;
  border-radius: 999px;
  background: var(--kx-danger);
  color: #fff;
  font-size: var(--kx-fs-2xs);
  font-weight: var(--kx-fw-strong);
  line-height: 15px;
  text-align: center;
  border: 2px solid var(--kx-surface);
  box-sizing: content-box;
}

/* Notification dropdown */
/* 340px is the width this menu wants; on a 320px phone it is 20px more than
   exists, and being right-aligned in the topbar that surplus lands off the
   left edge and drags the page with it. `min()` keeps the intended width
   wherever there is room and gives way where there is not. */
.kx-notif-menu { width: min(340px, calc(100vw - 1.5rem)); padding: 0; }
.kx-notif-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.6875rem 0.875rem;
  border-bottom: 1px solid var(--kx-border);
  font-size: 0.8125rem;
  font-weight: var(--kx-fw-strong);
}
.kx-notif-list { max-height: 320px; overflow-y: auto; }
.kx-notif-item {
  display: block;
  padding: 0.6875rem 0.875rem;
  border-bottom: 1px solid var(--kx-border-subtle);
  font-size: 0.8125rem;
  line-height: 1.5;
  color: var(--kx-text);
}
.kx-notif-item:last-child { border-bottom: 0; }
.kx-notif-item.is-unread { background: var(--kx-surface-2); }
.kx-notif-time { display: block; margin-top: 0.15rem; font-size: 0.75rem; color: var(--kx-text-faint); }
.kx-notif-foot { padding: 0.5rem; border-top: 1px solid var(--kx-border); }

/* User button */
.kx-user-btn {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  height: 34px;
  padding: 0 0.5rem 0 0.3125rem;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--kx-r-md);
  color: var(--kx-text);
  font-size: 0.8125rem;
  font-weight: var(--kx-fw-label);
  cursor: pointer;
  max-width: 200px;
}
.kx-user-btn:hover { background: var(--kx-surface-3); }
.kx-user-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.kx-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  flex-shrink: 0;
  border-radius: 50%;
  background: var(--kx-surface-inv);
  color: var(--kx-text-inv);
  font-size: 0.6875rem;
  font-weight: var(--kx-fw-strong);
  letter-spacing: 0.01em;
  text-transform: uppercase;
}
.kx-avatar-lg { width: 36px; height: 36px; font-size: 0.8125rem; }

.kx-content {
  flex: 1;
  width: 100%;
  max-width: 1440px;
  padding: 1.5rem;
  margin: 0 auto;
}

/* Preview-mode banner: informative, not a marketing bar. */
.kx-preview-banner {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  padding: 0.625rem 1.25rem;
  background: var(--kx-warning-bg);
  border-bottom: 1px solid var(--kx-warning-bd);
  color: var(--kx-text);
  font-size: 0.8125rem;
}
.kx-preview-banner i { color: var(--kx-warning); }
.kx-preview-banner .kx-preview-actions { margin-left: auto; }

/* Shown to a KernexaProperty operator reading a customer's data under a
   support grant. Louder than the preview banner on purpose: preview is a state
   the user chose, this is somebody standing in someone else's business. */
.kx-support-banner {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  padding: 0.625rem 1.25rem;
  background: var(--kx-danger-bg);
  border-bottom: 2px solid var(--kx-danger);
  color: var(--kx-text);
  font-size: 0.8125rem;
}
.kx-support-banner i { color: var(--kx-danger); }
.kx-support-banner .kx-support-actions { margin-left: auto; }

/* ==========================================================================
   13. Dashboard widgets
   ========================================================================== */

.kx-stat {
  position: relative;
  height: 100%;
  padding: 1.125rem 1.25rem;
  background: var(--kx-surface);
  border: 1px solid var(--kx-border);
  border-radius: var(--kx-r-lg);
  box-shadow: var(--kx-shadow-sm);
}
[data-theme="dark"] .kx-stat { box-shadow: none; }
.kx-stat-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
}
.kx-stat-label {
  font-size: 0.8125rem;
  font-weight: var(--kx-fw-label);
  color: var(--kx-text-muted);
}
.kx-stat-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  flex-shrink: 0;
  border-radius: var(--kx-r-sm);
  background: var(--kx-surface-3);
  color: var(--kx-text-2);
  font-size: 0.875rem;
}
.kx-stat-value {
  font-size: var(--kx-fs-3xl);
  font-weight: var(--kx-fw-strong);
  letter-spacing: -0.03em;
  line-height: 1.2;
  color: var(--kx-text);
}
.kx-stat-value.kx-stat-value-sm { font-size: var(--kx-fs-xl); letter-spacing: -0.02em; }
.kx-stat-meta { margin-top: 0.3125rem; font-size: 0.8125rem; color: var(--kx-text-muted); }
.kx-stat-currency { font-size: 0.8125rem; font-weight: var(--kx-fw-label); color: var(--kx-text-muted); margin-right: 0.2rem; }

/* One line under a figure people otherwise misread, such as Outstanding
   against the outstanding rent report. Quieter than the meta line, because it
   is an explanation rather than part of the number. */
.kx-stat-note {
  margin: 0.5rem 0 0;
  padding-top: 0.5rem;
  border-top: 1px solid var(--kx-border);
  font-size: 0.75rem;
  line-height: 1.45;
  color: var(--kx-text-muted);
}

/* A stat whose rows can be opened. The link sits in the meta line rather than
   wrapping the card: the number itself is not a control, and a card-sized
   anchor swallows text selection on the figure people came to read. */
.kx-stat-open:hover { border-color: var(--kx-accent); }
.kx-stat-link {
  display: inline-flex;
  align-items: center;
  gap: 0.125rem;
  color: var(--kx-text-muted);
  text-decoration: none;
}
.kx-stat-link:hover, .kx-stat-link:focus-visible {
  color: var(--kx-text);
  text-decoration: underline;
}
.kx-stat-link i { font-size: 1rem; transition: transform 0.12s ease; }
.kx-stat-open:hover .kx-stat-link i { transform: translateX(2px); }

/* Slim progress bar used for occupancy. */
.kx-meter {
  height: 4px;
  margin-top: 0.75rem;
  border-radius: 999px;
  background: var(--kx-surface-3);
  overflow: hidden;
}
.kx-meter > span {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: var(--kx-text);
}

/* Activity feed */
.kx-feed { list-style: none; margin: 0; padding: 0; }
.kx-feed li {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.5625rem 0;
  border-bottom: 1px solid var(--kx-border-subtle);
  font-size: 0.875rem;
}
.kx-feed li:last-child { border-bottom: 0; padding-bottom: 0; }
.kx-feed li:first-child { padding-top: 0; }
.kx-feed time { flex-shrink: 0; font-size: 0.8125rem; color: var(--kx-text-faint); }

/* Definition list for detail pages. */
.kx-dl { display: grid; grid-template-columns: minmax(120px, auto) 1fr; gap: 0.5rem 1.25rem; margin: 0; font-size: 0.875rem; }
.kx-dl dt { color: var(--kx-text-muted); font-weight: var(--kx-fw-body); }
.kx-dl dd { margin: 0; color: var(--kx-text); font-weight: var(--kx-fw-label); }

/* ==========================================================================
   14. Public site
   ========================================================================== */

.kx-public { background: var(--kx-surface); }
.kx-public-main { display: block; }

.kx-public-nav {
  position: sticky;
  top: 0;
  z-index: 40;
  background: color-mix(in srgb, var(--kx-surface) 86%, transparent);
  backdrop-filter: saturate(180%) blur(12px);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--kx-border);
}
@supports not (backdrop-filter: blur(1px)) {
  .kx-public-nav { background: var(--kx-surface); }
}
.kx-public-nav-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  height: 64px;
}
.kx-public-links {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  margin: 0 auto;
}
.kx-public-links a {
  padding: 0.4rem 0.6875rem;
  border-radius: var(--kx-r-sm);
  font-size: 0.875rem;
  font-weight: var(--kx-fw-label);
  color: var(--kx-text-2);
  transition: background-color 0.12s ease, color 0.12s ease;
}
.kx-public-links a:hover { background: var(--kx-surface-2); color: var(--kx-text); text-decoration: none; }
.kx-public-links a.active { color: var(--kx-text); font-weight: var(--kx-fw-strong); }
.kx-public-actions { display: flex; align-items: center; gap: 0.5rem; }

/* Nothing in this bar may push the menu button off the edge. A flex item
   defaults to min-width:auto and so refuses to shrink below its text, which
   let the logo and the buttons overflow together: on a 320px screen the
   primary button ended up sitting on top of the toggle, and the toggle stopped
   answering taps. The wordmark is what gives way, because a truncated brand is
   recoverable and an unreachable menu is not. */
.kx-public-nav-inner { min-width: 0; }
.kx-public-actions { flex-shrink: 0; }
.kx-logo { min-width: 0; }
.kx-logo-mark { flex-shrink: 0; }
.kx-logo > span:not(.kx-logo-mark) {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.kx-logo {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.9375rem;
  font-weight: var(--kx-fw-strong);
  letter-spacing: -0.02em;
  color: var(--kx-text);
}
.kx-logo:hover { text-decoration: none; color: var(--kx-text); }
.kx-logo-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  flex-shrink: 0;
  border-radius: var(--kx-r-sm);
  background: var(--kx-surface-inv);
  color: var(--kx-text-inv);
  font-size: 0.8125rem;
  font-weight: var(--kx-fw-display);
  letter-spacing: -0.02em;
}
.kx-logo-mark-lg { width: 32px; height: 32px; font-size: 0.9375rem; border-radius: var(--kx-r-md); }

.kx-nav-toggle { display: none; }

/* ---------------------------------------------------------------------------
   Mobile drawer — the public site's menu
   ---------------------------------------------------------------------------

   Deliberately the same object as the signed-in app's off-canvas sidebar: the
   same width, the same slide, the same backdrop, and the same
   `.kx-sidebar-link` rows inside it. The public menu used to be a list that
   pushed the page down while the app used a drawer, so meeting the two on a
   phone felt like meeting two different products.

   The link styling is not duplicated here — the markup reuses
   `.kx-sidebar-link` and `.kx-sidebar-section-title`, so the two navigations
   cannot drift apart by one of them being restyled.
   -------------------------------------------------------------------------- */

.kx-drawer {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: var(--kx-sidebar-w);
  max-width: 86vw;
  display: flex;
  flex-direction: column;
  background: var(--kx-sidebar-bg);
  border-right: 1px solid var(--kx-sidebar-border);
  transform: translateX(-100%);
  transition: transform 0.22s cubic-bezier(0.16, 1, 0.3, 1);
  z-index: 1050;
  box-shadow: var(--kx-shadow-lg);
  visibility: hidden;
}
.kx-drawer.open { transform: none; visibility: visible; }

/* Toggle first, then the brand — the same order as the app's topbar, so the
   control sits where the finger that opened it already is. */
.kx-drawer-head {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  height: var(--kx-topbar-h, 60px);
  padding: 0 1rem 0 0.75rem;
  border-bottom: 1px solid var(--kx-sidebar-border);
}

.kx-drawer-nav {
  flex: 1;
  overflow-y: auto;
  padding: 0.75rem 0.625rem;
}

.kx-drawer-actions {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(0, 1fr);
  gap: 0.5rem;
  padding: 0.75rem;
  border-bottom: 1px solid var(--kx-sidebar-border);
}

.kx-drawer-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 1040;
  background: rgba(10, 10, 11, 0.45);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}
.kx-drawer-backdrop.show { opacity: 1; pointer-events: auto; }

/* Sections */
.kx-section { padding: 5rem 0; border-top: 1px solid var(--kx-border); }
.kx-section-sm { padding: 3.5rem 0; }
.kx-section-alt { background: var(--kx-canvas); }
[data-theme="dark"] .kx-section-alt { background: #101013; }

.kx-section-head { max-width: 42rem; margin-bottom: 2.75rem; }
.kx-section-head.center { margin-left: auto; margin-right: auto; text-align: center; }
.kx-section-head h2 {
  font-size: clamp(1.5rem, 3vw, 2rem);
  letter-spacing: -0.03em;
  margin: 0.625rem 0 0.75rem;
}
.kx-section-head p { color: var(--kx-text-2); font-size: 1rem; margin: 0; }

/* Hero */
.kx-hero { padding: 5.5rem 0 4.5rem; }
.kx-hero-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(0, 0.95fr);
  gap: 4rem;
  align-items: center;
}
.kx-hero h1 {
  font-size: clamp(2rem, 4.6vw, 3.125rem);
  line-height: 1.08;
  letter-spacing: -0.035em;
  margin: 1rem 0 1.125rem;
}
.kx-hero p.kx-lead { max-width: 46ch; margin-bottom: 1.75rem; }
.kx-hero-actions { display: flex; gap: 0.625rem; flex-wrap: wrap; }
.kx-hero-note {
  margin-top: 1.125rem;
  font-size: 0.8125rem;
  color: var(--kx-text-muted);
  display: flex;
  align-items: flex-start;
  gap: 0.4rem;
  max-width: 46ch;
}
.kx-hero-note i { margin-top: 0.25rem; flex-shrink: 0; }

/* Two overlapping panels give the hero depth without a photograph. The product
   is the illustration — nothing here is stock imagery, because a monochrome,
   data-dense tool looks dishonest wrapped in one. */
.kx-hero-stack { position: relative; padding-bottom: 3.25rem; }
.kx-hero-stack .kx-panel-front { position: relative; z-index: 2; }
.kx-hero-stack .kx-panel-back {
  position: absolute;
  left: 2.25rem;
  right: -1rem;
  bottom: 0;
  z-index: 1;
  opacity: 0.96;
}
.kx-panel-row-total {
  border-top: 1px solid var(--kx-border);
  border-bottom: 0;
  margin-top: 0.25rem;
  padding-top: 0.75rem;
  font-weight: var(--kx-fw-strong);
}

/* The money-flow strip — one diagram in place of three paragraphs. */
.kx-flow {
  display: flex;
  align-items: stretch;
  gap: 0.5rem;
  list-style: none;
  margin: 0;
  padding: 0;
}
.kx-flow-step {
  flex: 1 1 0;
  min-width: 0;
  padding: 1.5rem 1.25rem;
  background: var(--kx-surface);
  border: 1px solid var(--kx-border);
  border-radius: var(--kx-r-lg);
  text-align: center;
}
.kx-flow-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.5rem;
  height: 2.5rem;
  margin-bottom: 0.875rem;
  border-radius: var(--kx-r-md);
  background: var(--kx-surface-3);
  color: var(--kx-text);
  font-size: var(--kx-fs-xl);
}
.kx-flow-step h3 {
  font-size: 0.9375rem;
  font-weight: var(--kx-fw-strong);
  letter-spacing: -0.01em;
  margin: 0 0 0.35rem;
}
.kx-flow-step p {
  margin: 0;
  font-size: 0.8125rem;
  color: var(--kx-text-muted);
  line-height: 1.5;
}
.kx-flow-arrow {
  display: flex;
  align-items: center;
  color: var(--kx-text-faint);
  font-size: 1rem;
  flex: 0 0 auto;
}

.kx-section-tight { padding-top: 3.5rem; padding-bottom: 3.5rem; }

/* Before / after, as two cards rather than two lists of dashes. */
.kx-contrast {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(20rem, 1fr));
  gap: 1.25rem;
}
.kx-contrast-card {
  padding: 1.75rem;
  border: 1px solid var(--kx-border);
  border-radius: var(--kx-r-lg);
  background: var(--kx-surface);
}
.kx-contrast-card ul { list-style: none; margin: 0; padding: 0; }
.kx-contrast-card li {
  position: relative;
  padding-left: 1.5rem;
  margin-bottom: 0.75rem;
  font-size: 0.9375rem;
  line-height: 1.55;
}
.kx-contrast-card li:last-child { margin-bottom: 0; }
.kx-contrast-card li::before {
  position: absolute;
  left: 0;
  top: 0;
  font-family: 'bootstrap-icons';
  font-size: 0.875rem;
}
.kx-contrast-tag {
  display: inline-block;
  margin-bottom: 1rem;
  padding: 0.2rem 0.6rem;
  font-size: 0.6875rem;
  font-weight: var(--kx-fw-strong);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  border-radius: 999px;
}
.kx-contrast-before { background: var(--kx-canvas); }
[data-theme="dark"] .kx-contrast-before { background: #0d0d10; }
.kx-contrast-before .kx-contrast-tag {
  background: var(--kx-surface-3);
  color: var(--kx-text-muted);
}
.kx-contrast-before li { color: var(--kx-text-muted); }
.kx-contrast-before li::before { content: "\F63B"; color: var(--kx-text-faint); }

.kx-contrast-after { border-color: var(--kx-border-strong); }
.kx-contrast-after .kx-contrast-tag {
  background: var(--kx-success-bg);
  color: var(--kx-success);
}
.kx-contrast-after li::before { content: "\F26E"; color: var(--kx-success); }

/* Product panel — a faithful, static rendering of the real UI. */
.kx-panel {
  background: var(--kx-surface);
  border: 1px solid var(--kx-border);
  border-radius: var(--kx-r-xl);
  box-shadow: var(--kx-shadow-lg);
  overflow: hidden;
}
[data-theme="dark"] .kx-panel { box-shadow: var(--kx-shadow-md); }
.kx-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--kx-border);
  background: var(--kx-surface-2);
  font-size: 0.8125rem;
  font-weight: var(--kx-fw-strong);
}
.kx-panel-body { padding: 0.5rem 1rem 1rem; }
.kx-panel-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.625rem 0;
  border-bottom: 1px solid var(--kx-border-subtle);
  font-size: 0.8125rem;
}
.kx-panel-row:last-child { border-bottom: 0; }
.kx-panel-row .kx-panel-label { color: var(--kx-text-2); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kx-panel-row strong { font-variant-numeric: tabular-nums; }

/* Feature grid */
.kx-feature-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1px;
  background: var(--kx-border);
  border: 1px solid var(--kx-border);
  border-radius: var(--kx-r-lg);
  overflow: hidden;
}
.kx-feature {
  background: var(--kx-surface);
  padding: 1.75rem 1.5rem;
}
.kx-feature-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  margin-bottom: 0.875rem;
  border-radius: var(--kx-r-md);
  background: var(--kx-surface-3);
  color: var(--kx-text);
  font-size: 1rem;
}
.kx-feature h3 { font-size: 0.9375rem; margin-bottom: 0.375rem; }
.kx-feature p { font-size: 0.875rem; color: var(--kx-text-2); margin: 0; line-height: 1.6; }

/* Alternating detail rows */
.kx-split {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 3.5rem;
  align-items: center;
}
.kx-split + .kx-split { margin-top: 4.5rem; }
.kx-split.reverse .kx-split-copy { order: 2; }
.kx-split.reverse .kx-split-visual { order: 1; }
.kx-split h3 { font-size: var(--kx-fs-2xl); letter-spacing: -0.025em; margin: 0.625rem 0 0.75rem; }
.kx-split p { color: var(--kx-text-2); margin: 0; }
.kx-check-list { list-style: none; padding: 0; margin: 1.125rem 0 0; }
.kx-check-list li {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  padding: 0.3125rem 0;
  font-size: 0.875rem;
  color: var(--kx-text-2);
}
.kx-check-list i { color: var(--kx-text); margin-top: 0.2rem; font-size: 0.8125rem; }

/* Steps */
.kx-steps {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 2rem;
  counter-reset: kx-step;
}
.kx-step { position: relative; padding-top: 1.75rem; border-top: 2px solid var(--kx-border); }
.kx-step::before {
  counter-increment: kx-step;
  content: counter(kx-step, decimal-leading-zero);
  position: absolute;
  top: -0.75rem;
  left: 0;
  padding-right: 0.625rem;
  background: var(--kx-surface);
  font-size: 0.75rem;
  font-weight: var(--kx-fw-strong);
  letter-spacing: 0.08em;
  color: var(--kx-text-faint);
}
.kx-section-alt .kx-step::before { background: var(--kx-canvas); }
[data-theme="dark"] .kx-section-alt .kx-step::before { background: #101013; }
.kx-step h3 { font-size: 0.9375rem; margin-bottom: 0.375rem; }
.kx-step p { font-size: 0.875rem; color: var(--kx-text-2); margin: 0; }

/* FAQ — native disclosure, no JS. */
.kx-faq { max-width: 46rem; margin: 0 auto; border-top: 1px solid var(--kx-border); }
.kx-faq details { border-bottom: 1px solid var(--kx-border); }
.kx-faq summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.125rem 0;
  font-size: 0.9375rem;
  font-weight: var(--kx-fw-label);
  color: var(--kx-text);
  cursor: pointer;
  list-style: none;
}
.kx-faq summary::-webkit-details-marker { display: none; }
.kx-faq summary::after {
  content: '\F4FE';
  font-family: 'bootstrap-icons';
  font-size: 0.875rem;
  color: var(--kx-text-muted);
  transition: transform 0.16s ease;
  flex-shrink: 0;
}
.kx-faq details[open] summary::after { transform: rotate(45deg); }
.kx-faq summary:hover { color: var(--kx-text); }
.kx-faq-answer {
  padding: 0 0 1.25rem;
  font-size: 0.9375rem;
  color: var(--kx-text-2);
  line-height: 1.65;
  max-width: 62ch;
}

/* --------------------------------------------------------------------------
   Pricing

   Built out of the language the rest of the public site already speaks: the
   seam grid the feature cards use, the segmented control the list filters use,
   the hairline sections, the tabular figures. A price list that looked like a
   different product would undercut the one thing it is there to establish.

   The monthly/yearly control is two radios and the four rules under
   `.kx-bill-*`. No script is involved on purpose: the price list is the page a
   visitor came for, and it has to be readable before anything has loaded and
   on a browser that never runs JavaScript at all. The radios stay in the flow
   rather than being `display: none`, so they can still be reached and changed
   from the keyboard, and the tabs carry a focus ring that follows them.
   -------------------------------------------------------------------------- */

/* The plans sit in their own opening section rather than under a rule, so the
   page starts on the prices instead of on a border. */
.kx-price-section { padding: 4.5rem 0 5rem; }

.kx-page-head { max-width: 44rem; margin: 0 auto 2.5rem; text-align: center; }
.kx-page-head h1 {
  font-size: clamp(1.75rem, 4vw, 2.75rem);
  line-height: 1.1;
  letter-spacing: -0.035em;
  margin: 0.875rem 0 1rem;
}
.kx-page-head .kx-lead { margin: 0 auto; max-width: 54ch; }

/* Billing tabs ------------------------------------------------------------ */

.kx-billing { display: flex; justify-content: center; margin-bottom: 2rem; }
.kx-billing-tabs { padding: 4px; gap: 3px; }
.kx-billing-tabs label {
  display: inline-flex;
  align-items: center;
  gap: 0.4375rem;
  flex: 0 0 auto;
  white-space: nowrap;
  padding: 0.4375rem 0.9375rem;
  border-radius: var(--kx-r-sm);
  font-size: 0.8125rem;
  font-weight: var(--kx-fw-label);
  color: var(--kx-text-2);
  cursor: pointer;
  transition: background-color 0.12s ease, color 0.12s ease;
}
.kx-billing-tabs label:hover { color: var(--kx-text); }

/* The chosen tab, and the focus ring that has to follow it because the radio
   itself is off screen. */
.kx-bill-monthly:checked ~ .kx-billing .kx-bill-tab-monthly,
.kx-bill-yearly:checked ~ .kx-billing .kx-bill-tab-yearly {
  background: var(--kx-surface);
  color: var(--kx-text);
  box-shadow: var(--kx-shadow-xs);
}
[data-theme="dark"] .kx-bill-monthly:checked ~ .kx-billing .kx-bill-tab-monthly,
[data-theme="dark"] .kx-bill-yearly:checked ~ .kx-billing .kx-bill-tab-yearly {
  background: var(--kx-surface-3);
}
.kx-bill-monthly:focus-visible ~ .kx-billing .kx-bill-tab-monthly,
.kx-bill-yearly:focus-visible ~ .kx-billing .kx-bill-tab-yearly {
  outline: 2px solid var(--kx-accent);
  outline-offset: 2px;
}

/* The saving is worked out from the prices, so it earns a little colour. */
.kx-bill-save {
  padding: 0.1875rem 0.4375rem;
  border-radius: 999px;
  background: color-mix(in srgb, var(--kx-success) 14%, transparent);
  color: var(--kx-success);
  font-size: 0.6875rem;
  font-weight: var(--kx-fw-strong);
  letter-spacing: 0.01em;
}

/* Which body is on show. Monthly is the default, so a browser that ignores the
   radios entirely still renders one complete, correct price list.

   Written against `.kx-price-body` rather than the state class alone: the body
   sets `display: flex` further down, and a bare `.kx-when-yearly` loses to it
   on source order, which showed both prices in every card at once. */
.kx-price-body.kx-when-yearly { display: none; }
.kx-bill-yearly:checked ~ .kx-price-grid .kx-price-body.kx-when-monthly { display: none; }
.kx-bill-yearly:checked ~ .kx-price-grid .kx-price-body.kx-when-yearly { display: flex; }

/* The tiers ---------------------------------------------------------------- */

/* One bordered block divided by hairline seams, the same construction as the
   feature grid. Four separate floating cards read as four things; this reads
   as one price list, which is what it is. */
.kx-price-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1px;
  background: var(--kx-border);
  border: 1px solid var(--kx-border);
  border-radius: var(--kx-r-lg);
  overflow: hidden;
}
.kx-price-card {
  display: flex;
  flex-direction: column;
  padding: 1.75rem 1.5rem;
  background: var(--kx-surface);
  transition: background-color 0.14s ease;
}
.kx-price-card:hover { background: var(--kx-surface-2); }

.kx-price-head { margin-bottom: 1.25rem; }
.kx-price-head h2 {
  font-size: var(--kx-fs-lg);
  letter-spacing: -0.015em;
  margin: 0 0 0.375rem;
}
/* Two lines of room whether the description fills them or not, so every price
   in the row starts on the same baseline. */
.kx-price-head p {
  min-height: 2.6em;
  font-size: 0.8125rem;
  line-height: 1.5;
  color: var(--kx-text-2);
  margin: 0;
}

.kx-price-figure { display: flex; align-items: baseline; gap: 0.375rem; }
.kx-price-figure strong {
  font-size: var(--kx-fs-4xl);
  font-weight: var(--kx-fw-strong);
  line-height: 1.1;
  letter-spacing: -0.035em;
  font-variant-numeric: tabular-nums lining-nums;
  color: var(--kx-text);
}
.kx-price-figure span { font-size: 0.8125rem; color: var(--kx-text-muted); }

/* Both of these keep their height when they have nothing to say, so the
   buttons across the row stay on one line. */
.kx-price-note {
  min-height: 1.5em;
  margin: 0.375rem 0 0;
  font-size: 0.8125rem;
  color: var(--kx-text-muted);
}
/* Only the yearly bodies hold a saving, and only they reserve room for one.
   Reserving it in the monthly view too would leave an empty band under every
   price in the row, and there is nothing coming to fill it. */
.kx-price-saving {
  margin: 0.125rem 0 0;
  font-size: 0.8125rem;
  font-weight: var(--kx-fw-label);
  color: var(--kx-success);
}
.kx-when-yearly .kx-price-saving { min-height: 1.5em; }
.kx-price-saving i { font-size: 0.75rem; }

.kx-price-body { display: flex; flex-direction: column; }
.kx-price-body > .btn { margin-top: 1.25rem; }
.kx-price-limits {
  margin: 1.25rem 0 0;
  padding-top: 1.125rem;
  border-top: 1px solid var(--kx-border);
  font-size: 0.8125rem;
  font-weight: var(--kx-fw-strong);
  color: var(--kx-text);
}
.kx-price-body .kx-check-list { margin-top: 0.375rem; }
.kx-price-body .kx-check-list li { font-size: 0.8125rem; padding: 0.25rem 0; }

.kx-price-foot {
  max-width: 60ch;
  margin: 1.75rem auto 0;
  text-align: center;
  font-size: 0.8125rem;
  line-height: 1.65;
  color: var(--kx-text-muted);
}

/* The way in --------------------------------------------------------------- */

/* The trial is how a company starts, not a fifth column in the price list, so
   it gets a band of its own with the offer raised out of it on a card. */
.kx-trial-band {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr);
  gap: 3rem;
  align-items: center;
}
.kx-trial-copy h2 {
  font-size: clamp(1.5rem, 3vw, 2rem);
  letter-spacing: -0.03em;
  margin: 0.625rem 0 0.75rem;
}
.kx-trial-copy > p { color: var(--kx-text-2); font-size: 1rem; margin: 0; }
.kx-trial-copy .kx-check-list { margin-top: 1.25rem; }
.kx-trial-aside {
  padding: 1.75rem;
  background: var(--kx-surface);
  border: 1px solid var(--kx-border);
  border-radius: var(--kx-r-lg);
  box-shadow: var(--kx-shadow-md);
}
[data-theme="dark"] .kx-trial-aside { box-shadow: none; }
.kx-trial-aside .btn { margin-top: 1.25rem; }
.kx-trial-aside .kx-help { margin-top: 0.75rem; text-align: center; }

/* The landing page's summary of the same plans: a name, a figure and the
   ceiling, and nothing else. Anything more and it becomes a second price list
   to keep in step with the first. */
.kx-plan-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1px;
  list-style: none;
  margin: 0;
  padding: 0;
  background: var(--kx-border);
  border: 1px solid var(--kx-border);
  border-radius: var(--kx-r-lg);
  overflow: hidden;
}
.kx-plan-strip li {
  display: flex;
  flex-direction: column;
  gap: 0.3125rem;
  padding: 1.5rem 1.375rem;
  background: var(--kx-surface);
}
.kx-plan-strip-name {
  font-size: 0.75rem;
  font-weight: var(--kx-fw-strong);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--kx-text-muted);
}
.kx-plan-strip-price { font-size: 0.8125rem; color: var(--kx-text-muted); }
.kx-plan-strip-price strong {
  font-size: var(--kx-fs-3xl);
  font-weight: var(--kx-fw-strong);
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums lining-nums;
  color: var(--kx-text);
}
.kx-plan-strip-limit { font-size: 0.8125rem; color: var(--kx-text-2); }
.kx-hero-actions.center { justify-content: center; margin-top: 1.75rem; }

/* CTA */
.kx-cta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 2rem;
  flex-wrap: wrap;
  padding: 2.5rem;
  background: var(--kx-surface-inv);
  border-radius: var(--kx-r-xl);
  color: var(--kx-text-inv);
}
.kx-cta h2 { color: var(--kx-text-inv); font-size: var(--kx-fs-3xl); margin: 0 0 0.5rem; letter-spacing: -0.025em; }
.kx-cta p { color: color-mix(in srgb, var(--kx-text-inv) 68%, transparent); margin: 0; max-width: 52ch; font-size: 0.9375rem; }
.kx-cta .btn-kx-primary {
  background: var(--kx-accent-text);
  border-color: var(--kx-accent-text);
  color: var(--kx-accent);
}
.kx-cta .btn-kx-primary:hover { background: var(--kx-n-200); border-color: var(--kx-n-200); color: var(--kx-n-950); }
[data-theme="dark"] .kx-cta .btn-kx-primary:hover { background: var(--kx-n-700); border-color: var(--kx-n-700); color: #fff; }
.kx-cta .btn-kx-outline {
  background: transparent;
  border-color: color-mix(in srgb, var(--kx-text-inv) 32%, transparent);
  color: var(--kx-text-inv);
  box-shadow: none;
}
.kx-cta .btn-kx-outline:hover {
  background: color-mix(in srgb, var(--kx-text-inv) 10%, transparent);
  border-color: color-mix(in srgb, var(--kx-text-inv) 48%, transparent);
  color: var(--kx-text-inv);
}

/* Contact channels */
.kx-channel-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 1rem;
}
.kx-channel {
  display: block;
  padding: 1.375rem;
  background: var(--kx-surface);
  border: 1px solid var(--kx-border);
  border-radius: var(--kx-r-lg);
  color: inherit;
  transition: border-color 0.14s ease, box-shadow 0.14s ease;
}
.kx-channel:hover { border-color: var(--kx-border-strong); box-shadow: var(--kx-shadow-md); text-decoration: none; color: inherit; }
[data-theme="dark"] .kx-channel:hover { box-shadow: none; background: var(--kx-surface-2); }
.kx-channel-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  margin-bottom: 0.875rem;
  border-radius: var(--kx-r-md);
  background: var(--kx-surface-3);
  font-size: 0.9375rem;
}
.kx-channel h3 { font-size: 0.9375rem; margin-bottom: 0.25rem; }
.kx-channel p { font-size: 0.875rem; color: var(--kx-text-2); margin: 0 0 0.5rem; }
.kx-channel-value { font-size: 0.875rem; font-weight: var(--kx-fw-label); color: var(--kx-text); }

/* Footer */
.kx-footer {
  background: var(--kx-surface);
  border-top: 1px solid var(--kx-border);
  padding: 3.5rem 0 1.75rem;
  font-size: 0.875rem;
  color: var(--kx-text-2);
}
.kx-footer-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) repeat(3, minmax(0, 1fr));
  gap: 2.5rem;
}
.kx-footer h4 {
  font-size: 0.75rem;
  font-weight: var(--kx-fw-strong);
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--kx-text-muted);
  margin-bottom: 0.875rem;
}
.kx-footer-links { list-style: none; padding: 0; margin: 0; }
.kx-footer-links li { margin-bottom: 0.5rem; }
.kx-footer-links a { color: var(--kx-text-2); font-size: 0.875rem; }
.kx-footer-links a:hover { color: var(--kx-text); text-decoration: none; }
.kx-footer-blurb { max-width: 34ch; color: var(--kx-text-muted); margin: 0.875rem 0 0; font-size: 0.875rem; }
.kx-footer-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin-top: 3rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--kx-border);
  font-size: 0.8125rem;
  color: var(--kx-text-muted);
}

/* ==========================================================================
   15. Auth
   ========================================================================== */

.kx-auth {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  min-height: 100vh;
  background: var(--kx-surface);
}
.kx-auth-main {
  display: flex;
  flex-direction: column;
  padding: 2rem;
}
.kx-auth-inner {
  width: 100%;
  max-width: 25rem;
  margin: auto;
  padding: 2.5rem 0;
}
.kx-auth-inner.kx-auth-wide { max-width: 30rem; }
.kx-auth-head { margin-bottom: 1.75rem; }
.kx-auth-head h1 { font-size: var(--kx-fs-3xl); letter-spacing: -0.028em; margin-bottom: 0.375rem; }
.kx-auth-head p { color: var(--kx-text-muted); font-size: 0.875rem; margin: 0; }
.kx-auth-foot {
  margin-top: 1.75rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--kx-border);
  font-size: 0.875rem;
  color: var(--kx-text-muted);
  text-align: center;
}
.kx-auth-foot a { font-weight: var(--kx-fw-label); color: var(--kx-text); }
.kx-auth-foot a:hover { text-decoration: underline; }
.kx-auth-legal { margin-top: 1rem; font-size: 0.75rem; color: var(--kx-text-faint); text-align: center; line-height: 1.55; }
.kx-auth-legal a { color: var(--kx-text-muted); text-decoration: underline; }

.kx-label-row { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; }
.kx-label-row a { font-size: 0.8125rem; color: var(--kx-text-muted); }
.kx-label-row a:hover { color: var(--kx-text); }

/* Aside: quiet, factual, no marketing shouting. */
.kx-auth-aside {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 2.5rem;
  background: var(--kx-surface-inv);
  color: var(--kx-text-inv);
}
/* In dark mode — the default — half a screen of white would glare. Use an
   elevated dark surface instead and keep the contrast in the type. */
[data-theme="dark"] .kx-auth-aside {
  background: var(--kx-surface-2);
  color: var(--kx-text);
  border-left: 1px solid var(--kx-border);
}
[data-theme="dark"] .kx-auth-aside .kx-logo,
[data-theme="dark"] .kx-auth-aside .kx-logo:hover { color: var(--kx-text); }
[data-theme="dark"] .kx-auth-aside .kx-logo-mark { background: var(--kx-accent); color: var(--kx-accent-text); }
[data-theme="dark"] .kx-auth-points li { color: var(--kx-text-2); }
[data-theme="dark"] .kx-auth-points i { color: var(--kx-text); }
[data-theme="dark"] .kx-auth-aside-foot { color: var(--kx-text-faint); }
.kx-auth-aside .kx-logo,
.kx-auth-aside .kx-logo:hover { color: var(--kx-text-inv); }
.kx-auth-aside .kx-logo-mark { background: var(--kx-text-inv); color: var(--kx-surface-inv); }
.kx-auth-quote {
  max-width: 30rem;
  font-size: var(--kx-fs-2xl);
  line-height: 1.4;
  letter-spacing: -0.025em;
  font-weight: var(--kx-fw-label);
}
.kx-auth-points { list-style: none; padding: 0; margin: 1.75rem 0 0; }
.kx-auth-points li {
  display: flex;
  align-items: flex-start;
  gap: 0.625rem;
  padding: 0.375rem 0;
  font-size: 0.875rem;
  color: color-mix(in srgb, var(--kx-text-inv) 70%, transparent);
}
.kx-auth-points i { margin-top: 0.2rem; font-size: 0.8125rem; color: var(--kx-text-inv); }
.kx-auth-shot {
  margin: 2rem -2.5rem 2rem 0;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-right: 0;
  border-radius: 12px 0 0 12px;
  background: #0b0b0d;
  -webkit-mask-image: linear-gradient(180deg, #000 55%, transparent);
  mask-image: linear-gradient(180deg, #000 55%, transparent);
}
.kx-auth-shot img { display: block; width: 100%; height: auto; }
.kx-auth-aside-foot { font-size: 0.8125rem; color: color-mix(in srgb, var(--kx-text-inv) 55%, transparent); }

/* Password visibility toggle */
.kx-password-wrap { position: relative; }
.kx-password-wrap .form-control { padding-right: 2.5rem; }
.kx-password-toggle {
  position: absolute;
  top: 50%;
  right: 0.3125rem;
  transform: translateY(-50%);
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  background: transparent;
  color: var(--kx-text-faint);
  border-radius: var(--kx-r-sm);
  cursor: pointer;
}
.kx-password-toggle:hover { color: var(--kx-text); background: var(--kx-surface-3); }

/* A credential being handed over — shown once, meant to be copied.
   The value gets a surface of its own so it reads as something to take away
   rather than as another line of body text, and it wraps rather than
   truncating: a password with its tail cut off is worse than an ugly line. */
.kx-credential {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--kx-border);
}
.kx-credential:last-of-type { border-bottom: 0; }
.kx-credential-label {
  flex: 0 0 9rem;
  font-size: 0.8125rem;
  color: var(--kx-text-muted);
}
.kx-credential-value {
  flex: 1 1 12rem;
  min-width: 0;
  padding: 0.5rem 0.75rem;
  background: var(--kx-surface-3);
  border: 1px solid var(--kx-border);
  border-radius: var(--kx-r-sm);
  font-size: 1rem;
  letter-spacing: 0.02em;
  overflow-wrap: anywhere;
  user-select: all;
}
@media (max-width: 575.98px) {
  .kx-credential-label { flex-basis: 100%; }
}

/* ==========================================================================
   16. Prose (legal & long-form)
   ========================================================================== */

.kx-prose {
  max-width: 44rem;
  font-size: 0.9375rem;
  line-height: 1.75;
  color: var(--kx-text-2);
}
.kx-prose h2 {
  font-size: 1.125rem;
  color: var(--kx-text);
  margin: 2.5rem 0 0.75rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--kx-border);
}
.kx-prose h2:first-child { margin-top: 0; padding-top: 0; border-top: 0; }
.kx-prose h3 { font-size: 0.9375rem; color: var(--kx-text); margin: 1.5rem 0 0.5rem; }
.kx-prose p { margin: 0 0 1rem; }
.kx-prose ul, .kx-prose ol { margin: 0 0 1rem; padding-left: 1.25rem; }
.kx-prose li { margin-bottom: 0.4375rem; }
.kx-prose strong { color: var(--kx-text); font-weight: var(--kx-fw-strong); }
.kx-prose a { color: var(--kx-text); text-decoration: underline; }

.kx-toc {
  position: sticky;
  top: calc(64px + 1.5rem);
  font-size: 0.875rem;
}
.kx-toc h4 {
  font-size: 0.75rem;
  font-weight: var(--kx-fw-strong);
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--kx-text-muted);
  margin-bottom: 0.75rem;
}
.kx-toc ul { list-style: none; padding: 0; margin: 0; border-left: 1px solid var(--kx-border); }
.kx-toc li a {
  display: block;
  padding: 0.3125rem 0 0.3125rem 0.875rem;
  margin-left: -1px;
  border-left: 1px solid transparent;
  color: var(--kx-text-muted);
  font-size: 0.8125rem;
}
.kx-toc li a:hover { color: var(--kx-text); border-left-color: var(--kx-border-strong); text-decoration: none; }

/* Invoice document — a card that reads as paper, on screen and on paper. */
.kx-doc { overflow: hidden; }
.kx-doc-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1.5rem;
  flex-wrap: wrap;
  padding: 1.5rem;
  background: var(--kx-surface-inv);
  color: var(--kx-text-inv);
}
/* Bounded on both axes and never distorted. `max-height` alone let a wide
   wordmark scale to 40px tall and several hundred pixels across, which pushed
   the whole page sideways on a phone; `object-fit: contain` keeps the shape
   the company uploaded rather than squeezing it into the box. */
.kx-doc-head img {
  display: block;
  max-width: min(200px, 100%);
  max-height: 40px;
  width: auto;
  height: auto;
  object-fit: contain;
  margin-bottom: 0.5rem;
}
.kx-doc-head > div { min-width: 0; }
.kx-doc-company { font-size: 1.125rem; font-weight: var(--kx-fw-strong); letter-spacing: -0.02em; }
.kx-doc-contact { font-size: 0.8125rem; color: color-mix(in srgb, var(--kx-text-inv) 62%, transparent); margin-top: 0.15rem; }
.kx-doc-type {
  font-size: 0.75rem;
  font-weight: var(--kx-fw-strong);
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: color-mix(in srgb, var(--kx-text-inv) 72%, transparent);
}
.kx-doc-ref { font-size: 0.8125rem; margin-top: 0.25rem; font-variant-numeric: tabular-nums; }
.kx-doc-billed { font-size: 0.75rem; font-weight: var(--kx-fw-strong); letter-spacing: 0.05em; text-transform: uppercase; color: var(--kx-text-muted); }
.kx-doc-totals { width: min(20rem, 100%); margin-left: auto; font-size: 0.875rem; }
.kx-doc-totals td { padding: 0.3125rem 0; }
.kx-doc-totals td:last-child { text-align: right; font-variant-numeric: tabular-nums; }
.kx-doc-totals tr.kx-doc-total td {
  border-top: 1px solid var(--kx-border-strong);
  padding-top: 0.625rem;
  font-weight: var(--kx-fw-strong);
  font-size: 0.9375rem;
}
.kx-doc-note {
  margin-top: 1.5rem;
  padding: 0.875rem 1rem;
  border-left: 2px solid var(--kx-border-strong);
  background: var(--kx-surface-2);
  border-radius: 0 var(--kx-r-sm) var(--kx-r-sm) 0;
  font-size: 0.8125rem;
  color: var(--kx-text-muted);
}
/* In dark mode the letterhead stays part of the document rather than becoming
   a white slab inside a dark card. It prints black either way. */
[data-theme="dark"] .kx-doc-head {
  background: var(--kx-surface-2);
  color: var(--kx-text);
  border-bottom: 1px solid var(--kx-border);
}
[data-theme="dark"] .kx-doc-contact,
[data-theme="dark"] .kx-doc-type { color: var(--kx-text-muted); }

@media print {
  .kx-doc-head { background: #000 !important; color: #fff !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}

/* Error pages */
.kx-error-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 70vh;
  padding: 3rem 1.5rem;
  text-align: center;
}
.kx-error-code {
  font-size: 0.75rem;
  font-weight: var(--kx-fw-strong);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--kx-text-faint);
}
.kx-error-page h1 { font-size: clamp(1.5rem, 3vw, 2rem); margin: 0.75rem 0 0.625rem; letter-spacing: -0.03em; }
.kx-error-page p { color: var(--kx-text-2); max-width: 44ch; margin: 0 auto 1.75rem; }

/* ==========================================================================
   17. Utilities, motion, print
   ========================================================================== */

.kx-stack-sm > * + * { margin-top: 0.5rem; }
.kx-stack > * + * { margin-top: 1rem; }
.kx-truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kx-nowrap { white-space: nowrap; }
.kx-w-full { width: 100%; }

/* Screen-reader-only text.

   `top`/`left` are not decoration here, they are the fix for a real bug. With
   no offsets, an absolutely positioned element sits at its *static* position
   while its containing block is the nearest positioned ancestor — and these
   spans live inside plain buttons in table cells, so that ancestor is the page
   itself. An element whose containing block is outside a scroll container is
   not clipped by it, so `overflow-x: auto` on `.kx-table-wrap` could not
   contain them: each one reported its position inside the wide table straight
   to the document, and the page grew to reach it. That is what made the
   tenant page scroll sideways on a phone.

   Pinning them to their containing block's origin removes the overhang
   entirely, and costs nothing: the element is one pixel across and clipped to
   nothing, so where it sits is invisible either way. */
.kx-visually-hidden {
  position: absolute !important;
  top: 0;
  left: 0;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

/* Controls that host that text become its containing block, so it stays with
   its control rather than at the corner of the page. */
.kx-actions,
.kx-icon-btn,
.btn-kx-icon { position: relative; }

/* Scrollbars stay quiet and theme-aware. */
* { scrollbar-color: var(--kx-border-strong) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--kx-border-strong); border-radius: 6px; border: 3px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background: var(--kx-n-400); background-clip: content-box; }

/* Theme toggle keeps its two icons in one box so the topbar never reflows. */
.kx-theme-toggle .bi-sun { display: none; }
[data-theme="dark"] .kx-theme-toggle .bi-sun { display: inline-block; }
[data-theme="dark"] .kx-theme-toggle .bi-moon-stars { display: none; }

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

/* --------------------------------------------------------------------------
   Responsive
   -------------------------------------------------------------------------- */

@media (max-width: 1199.98px) {
  .kx-export-aside { position: static; }
  .kx-feature-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kx-steps { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 2rem 1.75rem; }
  .kx-footer-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 2rem; }
}

@media (max-width: 991.98px) {
  .kx-price-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kx-price-head p { min-height: 0; }
  .kx-trial-band { grid-template-columns: minmax(0, 1fr); gap: 1.75rem; }
  .kx-hero { padding: 3.5rem 0 3rem; }
  .kx-hero-grid { grid-template-columns: minmax(0, 1fr); gap: 2.5rem; }
  .kx-hero-stack { padding-bottom: 0; }
  .kx-hero-stack .kx-panel-back {
    position: static;
    margin-top: 1rem;
    opacity: 1;
  }
  .kx-split,
  .kx-split.reverse { grid-template-columns: minmax(0, 1fr); gap: 2rem; }
  .kx-split.reverse .kx-split-copy,
  .kx-split.reverse .kx-split-visual { order: initial; }
  .kx-split + .kx-split { margin-top: 3rem; }
  .kx-section { padding: 3.5rem 0; }
  .kx-auth { grid-template-columns: minmax(0, 1fr); }
  .kx-auth-aside { display: none; }
  .kx-toc { display: none; }
  .kx-content { padding: 1.25rem; }
}

@media (max-width: 767.98px) {
  body { font-size: 0.9375rem; }

  /* Sidebar becomes an off-canvas drawer. */
  .kx-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--kx-sidebar-w) !important;
    transform: translateX(-100%);
    transition: transform 0.22s cubic-bezier(0.16, 1, 0.3, 1);
    z-index: 1050;
    box-shadow: var(--kx-shadow-lg);
  }
  .kx-sidebar.mobile-open { transform: none; }
  .kx-sidebar.collapsed .kx-sidebar-label,
  .kx-sidebar.collapsed .kx-logo-text,
  .kx-sidebar.collapsed .kx-sidebar-section-title,
  .kx-sidebar.collapsed .kx-sidebar-lock { display: block; }
  .kx-sidebar.collapsed .kx-sidebar-brand,
  .kx-sidebar.collapsed .kx-sidebar-link { justify-content: flex-start; padding-left: 0.5rem; padding-right: 0.5rem; }
  .kx-sidebar.collapsed .kx-sidebar-brand { padding-left: 1rem; }
  .kx-sidebar.collapsed .kx-sidebar-nav { padding: 0.75rem; }

  /* Sixteen links plus their headings is a tall list on a phone. Tightening
     the gaps — not the labels or the tap targets, which stay at 40px — buys
     back roughly three rows, so the list needs less scrolling to cross. */
  .kx-sidebar-nav { padding: 0.5rem 0.625rem; }
  .kx-sidebar-link { padding: 0.5rem; min-height: 40px; }
  .kx-sidebar-section-title { margin: 0.75rem 0 0.25rem; }

  /* Clear of the iOS home indicator, so Log out is never half under it. */
  .kx-sidebar-foot {
    padding: 0.625rem 0.75rem;
    padding-bottom: max(0.625rem, env(safe-area-inset-bottom, 0));
  }

  .kx-sidebar-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 1040;
    background: rgba(10, 10, 11, 0.45);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
  }
  .kx-sidebar-backdrop.show { opacity: 1; pointer-events: auto; }

  .kx-topbar { padding: 0 0.875rem; gap: 0.375rem; }
  .kx-search { display: none; }
  .kx-user-name { display: none; }
  .kx-user-btn { padding: 0 0.25rem; }
  .kx-content { padding: 1rem; }
  .kx-card-body { padding: 1rem; }
  .kx-card > .kx-table-wrap > .table > thead th:first-child,
  .kx-card > .kx-table-wrap > .table > tbody td:first-child { padding-left: 1rem; }
  .kx-card > .kx-table-wrap > .table > thead th:last-child,
  .kx-card > .kx-table-wrap > .table > tbody td:last-child { padding-right: 1rem; }
  .kx-card-header { padding: 0.875rem 1rem; }
  .kx-preview-banner { padding: 0.625rem 0.875rem; }
  .kx-preview-banner .kx-preview-actions { margin-left: 0; width: 100%; }

  .kx-page-header { margin-bottom: 1.25rem; }
  .kx-page-actions { width: 100%; }
  .kx-page-actions > .btn { flex: 1 1 auto; }

  /* Bootstrap's container leaves 12px each side, which reads as text jammed
     against the bezel. 20px is the going rate on a phone and matches the
     padding the app's own screens already use. Safe-area insets are added on
     top so a landscape notch never clips the copy. */
  .container,
  .container-fluid {
    padding-left: max(1.25rem, env(safe-area-inset-left, 0));
    padding-right: max(1.25rem, env(safe-area-inset-right, 0));
  }

  /* Public nav collapses into the same drawer the app uses. */
  .kx-public-links { display: none; }
  .kx-public-actions .kx-public-cta { display: none; }
  .kx-nav-toggle { display: inline-flex; }
  .kx-drawer-backdrop { display: block; }
  .kx-feature-grid { grid-template-columns: minmax(0, 1fr); }
  .kx-steps { grid-template-columns: minmax(0, 1fr); gap: 1.75rem; }
  .kx-price-grid { grid-template-columns: minmax(0, 1fr); }
  .kx-export-grid { grid-template-columns: minmax(0, 1fr); }
  .kx-price-card { padding: 1.375rem 1.25rem; }
  .kx-price-note,
  .kx-when-yearly .kx-price-saving { min-height: 0; }
  .kx-plan-strip { grid-template-columns: minmax(0, 1fr); }
  .kx-price-section { padding: 3rem 0 3.5rem; }
  .kx-trial-aside { padding: 1.375rem; }
  .kx-flow { flex-direction: column; }
  .kx-flow-arrow { justify-content: center; transform: rotate(90deg); padding: 0.25rem 0; }
  .kx-contrast { grid-template-columns: minmax(0, 1fr); }
  .kx-contrast-card { padding: 1.25rem; }
  .kx-footer-grid { grid-template-columns: minmax(0, 1fr); gap: 1.75rem; }
  .kx-cta { padding: 1.75rem; gap: 1.25rem; }
  .kx-cta .btn { width: 100%; }
  .kx-section { padding: 3rem 0; }
  .kx-hero-actions .btn { flex: 1 1 auto; }
  .kx-dl { grid-template-columns: minmax(0, 1fr); gap: 0.15rem; }
  .kx-dl dd { margin-bottom: 0.625rem; }
  .kx-auth-main { padding: 1.25rem; }
  .kx-auth-inner { padding: 1.5rem 0; }
  .modal-footer { flex-direction: column-reverse; }
  .modal-footer > .btn { width: 100%; }
  .kx-toast-region { top: 0.625rem; right: 0.625rem; left: 0.625rem; width: auto; }

  .kx-cookie-notice {
    left: 0.625rem;
    right: 0.625rem;
    bottom: max(0.625rem, env(safe-area-inset-bottom, 0));
    width: auto;
    gap: 0.75rem;
    padding: 0.625rem 0.75rem;
    font-size: 0.8125rem;
    line-height: 1.4;
  }

  /* On a phone a dialog behaves like a sheet: pinned to the bottom, using the
     full width, with its own header and footer staying put while the body
     scrolls. Centring a tall form on a short screen is what made Add Tenant
     unusable — the top and bottom were both off-screen at once. */
  .modal-dialog,
  .modal-dialog-centered {
    margin: 0;
    max-width: none;
    width: 100%;
    min-height: 100%;
    max-height: 100%;
    align-items: flex-end;
  }
  .modal-content {
    border-radius: var(--kx-r-lg) var(--kx-r-lg) 0 0;
    border-bottom: none;
    max-height: 96vh;
    /* Clear of the home indicator on iOS. */
    padding-bottom: env(safe-area-inset-bottom, 0);
  }
  .modal-header { position: sticky; top: 0; z-index: 2; background: var(--kx-surface); }
  .modal-footer { position: sticky; bottom: 0; z-index: 2; border-radius: 0; }
  .modal-body { padding: 1rem; }

  /* Filters collapse to a single column and the search fills the row. */
  .kx-filters-head { gap: 0.5rem; }
  .kx-filter-search { flex: 1 1 100%; order: -1; }
  .kx-filters-actions { margin-left: 0; width: 100%; }
  .kx-filters-actions > .btn { flex: 1 1 auto; }
  .kx-filter-fields { grid-template-columns: minmax(0, 1fr); }
  .kx-filter-field-wide { grid-column: span 1; }
  .kx-filter-range { flex-wrap: wrap; }
  .kx-filter-range .form-control { flex: 1 1 40%; }

  .kx-pagination { flex-direction: column; align-items: stretch; padding: 0.875rem 1rem; }
  .kx-pages { justify-content: center; flex-wrap: wrap; }
  .kx-pagination-summary { text-align: center; }

  .kx-danger-card { padding: 1.25rem; }
  .kx-danger-head { flex-direction: column; gap: 0.75rem; }
  .kx-danger-actions { flex-direction: column-reverse; }
  .kx-danger-actions > .btn { width: 100%; }

  .kx-related-grid { grid-template-columns: minmax(0, 1fr); }

  /* The permission grid is a real matrix — let it scroll rather than crush. */
  .kx-perm-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .kx-perm-table { min-width: 30rem; }
}

@media (max-width: 575.98px) {
  .kx-stat { padding: 1rem; }
  .kx-stat-value { font-size: var(--kx-fs-2xl); }
  .kx-empty { padding: 2.25rem 1rem; }

  /* On a phone a data table should scroll sideways, not shred every cell into
     two-word columns. Descriptions are already truncated server-side. */
  .kx-table-wrap .table th,
  .kx-table-wrap .table td { white-space: nowrap; }
}

/* ==========================================================================
   17b. No zoom-on-focus, on any phone
   --------------------------------------------------------------------------
   Safari on iOS zooms the whole page when you focus a form control whose text
   is smaller than 16px, and it does not zoom back out afterwards — so tapping
   one search box left every page oversized and scrolled sideways for the rest
   of the visit. The app's controls are 14px, and its small variants 13px, so
   this fired on essentially every form.

   The fix is to make the controls 16px on phones, not to disable zooming.
   `maximum-scale=1` / `user-scalable=no` in the viewport tag would also stop
   it, by taking pinch-zoom away from everyone — including people who need it
   to read at all. Failing an accessibility requirement to save a font-size
   rule is not a trade worth making.

   Only the *controls* change. Body text stays as it is.
   ========================================================================== */

@media (max-width: 767.98px) {
  .form-control,
  .form-select,
  .form-control-sm,
  .form-select-sm,
  textarea.form-control,
  .kx-input,
  .kx-search input,
  input[type="text"],
  input[type="email"],
  input[type="tel"],
  input[type="url"],
  input[type="number"],
  input[type="password"],
  input[type="search"],
  input[type="date"],
  input[type="datetime-local"],
  input[type="month"],
  input[type="time"],
  select,
  textarea {
    /* 16px exactly — the threshold, not a round-up. */
    font-size: 16px;
  }

  /* The small variants were short to match 13px text; at 16px they need the
     room or the text sits tight against the border. */
  .form-control-sm,
  .form-select-sm { min-height: 38px; padding: 0.375rem 0.625rem; }
}

/* ==========================================================================
   18. Modal scrolling — every dialog, every screen size
   --------------------------------------------------------------------------
   Bootstrap's `.modal-dialog-scrollable` works by making `.modal-content` a
   flex column and letting `.modal-body` take `overflow-y: auto` inside it.
   Almost every dialog here wraps its header, body and footer in a <form>, and
   that <form> sits between the two — breaking the chain, so the body never
   receives a bounded height and long forms (Add Tenant, above all) simply got
   cut off with no way to reach the rest.

   The fix is to let the <form> carry the flex column itself, and to make
   scrolling the default for every modal rather than something each dialog has
   to remember to opt into.
   ========================================================================== */

.modal-dialog {
  /* Never taller than the viewport, so there is always something to scroll
     against — the previous behaviour let a tall dialog run off the bottom. */
  max-height: calc(100% - 1rem);
}
.modal-dialog-centered { max-height: calc(100% - 2rem); }

.modal-content {
  display: flex;
  flex-direction: column;
  max-height: inherit;
  overflow: hidden;
}

/* The missing link: a <form> wrapping the dialog's three regions. */
.modal-content > form {
  display: flex;
  flex-direction: column;
  min-height: 0;
  max-height: 100%;
  overflow: hidden;
}

.modal-header,
.modal-footer { flex: 0 0 auto; }

.modal-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

/* Opening a dialog must not move the page underneath it.

   Bootstrap hides the body's scrollbar while a modal is open and adds
   `padding-right` of exactly the scrollbar's width to compensate, so the
   content does not jump sideways as it disappears. The compensation works, but
   it makes the body *wider than the viewport* for as long as the dialog is
   open — and every full-width element inside it, the backdrop included, is
   then wider than the phone. `core.test_viewport` measures that and is right
   to: at 320px the page really was laying out at 345.

   Reserving the gutter permanently solves the same problem from the other end.
   The space is always there, so hiding the scrollbar takes nothing away,
   nothing shifts, and no compensation is needed — which is why the padding can
   then be dropped. On a phone, where scrollbars are overlays with no width,
   both of these are no-ops and the layout is exactly what it was.

   `scrollbar-gutter` needs a browser from 2022 or later. An older one loses
   only the padding, and gets the sideways jump every Bootstrap site had before
   that property existed. */
html { scrollbar-gutter: stable; }
body.modal-open { padding-right: 0 !important; }

/* A shadow at the scroll boundary, so it reads as "there is more below". */
.modal-body { scrollbar-width: thin; }
.modal-body::-webkit-scrollbar { width: 10px; }
.modal-body::-webkit-scrollbar-thumb {
  background: var(--kx-border-strong);
  border: 3px solid var(--kx-surface);
  border-radius: 999px;
}

/* ==========================================================================
   19. Filter bar
   ========================================================================== */

.kx-filters {
  background: var(--kx-surface);
  border: 1px solid var(--kx-border);
  border-radius: var(--kx-r-lg);
  padding: 0.75rem;
  margin-bottom: 1rem;
}

.kx-filters-head {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.kx-filters-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.4rem 0.7rem;
  font-size: 0.8125rem;
  font-weight: var(--kx-fw-label);
  color: var(--kx-text);
  background: var(--kx-surface-2);
  border: 1px solid var(--kx-border);
  border-radius: var(--kx-r-sm);
  cursor: pointer;
}
.kx-filters-toggle:hover { background: var(--kx-surface-3); }
.kx-filters-toggle[aria-expanded="true"] {
  background: var(--kx-text);
  color: var(--kx-surface);
  border-color: var(--kx-text);
}
.kx-filters-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.15rem;
  height: 1.15rem;
  padding: 0 0.3rem;
  font-size: 0.6875rem;
  font-weight: var(--kx-fw-strong);
  border-radius: 999px;
  background: var(--kx-accent);
  color: var(--kx-surface);
}
.kx-filters-toggle[aria-expanded="true"] .kx-filters-count {
  background: var(--kx-surface);
  color: var(--kx-text);
}

.kx-filter-search {
  position: relative;
  flex: 1 1 14rem;
  min-width: 0;
}
.kx-filter-search .bi {
  position: absolute;
  left: 0.7rem;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.8125rem;
  color: var(--kx-text-muted);
  pointer-events: none;
}
.kx-filter-search .form-control {
  padding-left: 2rem;
  height: 2.125rem;
  font-size: 0.8125rem;
}

.kx-filters-actions { display: flex; gap: 0.375rem; margin-left: auto; }

.kx-filter-fields {
  display: none;
  grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr));
  gap: 0.75rem;
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--kx-border);
}
.kx-filter-fields.open { display: grid; }
.kx-filter-field-wide { grid-column: span 2; }
.kx-filter-field .form-label {
  font-size: 0.6875rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--kx-text-muted);
  margin-bottom: 0.25rem;
}
.kx-filter-range { display: flex; align-items: center; gap: 0.4rem; }
.kx-filter-range-sep { color: var(--kx-text-muted); font-size: 0.75rem; }

.kx-filter-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.375rem;
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--kx-border);
}
.kx-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.25rem 0.55rem;
  font-size: 0.75rem;
  border-radius: 999px;
  background: var(--kx-surface-2);
  border: 1px solid var(--kx-border);
  color: var(--kx-text);
  text-decoration: none;
}
.kx-chip:hover { background: var(--kx-surface-3); color: var(--kx-text); }
.kx-chip-label { color: var(--kx-text-muted); }
.kx-chip-value { font-weight: var(--kx-fw-strong); }
.kx-chip .bi { font-size: 0.75rem; opacity: 0.6; }

/* ==========================================================================
   20. Pagination
   ========================================================================== */

.kx-pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
  padding: 0.875rem 1.25rem;
  border-top: 1px solid var(--kx-border);
}
.kx-pagination-summary {
  margin: 0;
  font-size: 0.8125rem;
  color: var(--kx-text-muted);
}
.kx-pages {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  list-style: none;
  margin: 0;
  padding: 0;
}
.kx-page {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2rem;
  height: 2rem;
  padding: 0 0.4rem;
  font-size: 0.8125rem;
  border-radius: var(--kx-r-sm);
  border: 1px solid transparent;
  color: var(--kx-text);
  text-decoration: none;
}
.kx-page:hover { background: var(--kx-surface-2); color: var(--kx-text); }
.kx-page.current {
  background: var(--kx-text);
  color: var(--kx-surface);
  font-weight: var(--kx-fw-strong);
}
.kx-page.disabled { opacity: 0.3; pointer-events: none; }
.kx-page-gap { padding: 0 0.25rem; color: var(--kx-text-muted); }

/* ==========================================================================
   21. Destructive actions
   --------------------------------------------------------------------------
   Red is reserved for this. If it appears anywhere else in the product, it
   stops meaning "this is irreversible".
   ========================================================================== */

.kx-danger-page { max-width: 44rem; margin: 0 auto; }

.kx-danger-card {
  background: var(--kx-surface);
  border: 1px solid var(--kx-danger-bd);
  border-top: 3px solid var(--kx-danger);
  border-radius: var(--kx-r-lg);
  padding: 1.75rem;
}
.kx-danger-card-archive {
  border-color: var(--kx-border);
  border-top-color: var(--kx-warning);
}

.kx-danger-head { display: flex; gap: 1rem; align-items: flex-start; }
.kx-danger-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  width: 2.5rem;
  height: 2.5rem;
  border-radius: var(--kx-r-md);
  background: var(--kx-danger-bg);
  color: var(--kx-danger);
  font-size: 1.125rem;
}
.kx-danger-icon-warn {
  background: var(--kx-warning-bg);
  color: var(--kx-warning);
}
.kx-danger-title { font-size: var(--kx-fs-xl); margin: 0 0 0.35rem; letter-spacing: -0.015em; }
.kx-danger-lede { margin: 0; color: var(--kx-text-muted); font-size: 0.9375rem; line-height: 1.55; }

.kx-danger-section { margin-top: 1.5rem; }
.kx-danger-subtitle {
  font-size: 0.6875rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--kx-text-muted);
  margin: 0 0 0.6rem;
}

.kx-dependents { list-style: none; margin: 0; padding: 0; }
.kx-dependents li {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.625rem 0.75rem;
  border: 1px solid var(--kx-border);
  border-radius: var(--kx-r-sm);
  background: var(--kx-surface-2);
}
.kx-dependents li + li { margin-top: 0.4rem; }
.kx-dependents li.blocking {
  border-color: var(--kx-danger-bd);
  background: var(--kx-danger-bg);
}
.kx-dependent-count {
  font-variant-numeric: tabular-nums;
  font-weight: var(--kx-fw-display);
  font-size: 1rem;
  min-width: 2rem;
}
.kx-dependent-label { flex: 1 1 auto; font-size: 0.875rem; }
.kx-dependent-note {
  display: block;
  font-size: 0.75rem;
  color: var(--kx-text-muted);
  margin-top: 0.1rem;
}

.kx-danger-warning {
  display: flex;
  gap: 0.5rem;
  margin: 1rem 0 0;
  padding: 0.75rem 0.875rem;
  border-radius: var(--kx-r-sm);
  background: var(--kx-warning-bg);
  color: var(--kx-warning);
  font-size: 0.8125rem;
  line-height: 1.55;
}
.kx-danger-warning .bi { flex: 0 0 auto; margin-top: 0.1rem; }

.kx-danger-actions {
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
  margin-top: 1.75rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--kx-border);
}
.kx-danger-alt {
  margin: 1rem 0 0;
  font-size: 0.8125rem;
  color: var(--kx-text-muted);
  text-align: center;
}

.btn-kx-danger {
  background: var(--kx-danger);
  border: 1px solid var(--kx-danger);
  color: var(--kx-danger-text);
  font-weight: var(--kx-fw-label);
}
.btn-kx-danger:hover,
.btn-kx-danger:focus-visible {
  background: var(--kx-danger-hover);
  border-color: var(--kx-danger-hover);
  color: var(--kx-danger-text);
}
.btn-kx-danger-outline {
  background: transparent;
  border: 1px solid var(--kx-danger-bd);
  color: var(--kx-danger);
}
.btn-kx-danger-outline:hover {
  background: var(--kx-danger-bg);
  color: var(--kx-danger-hover);
}

/* ==========================================================================
   22. Relationship panels & ledgers
   ========================================================================== */

.kx-related-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(19rem, 1fr));
  gap: 1rem;
}

.kx-linked-list { list-style: none; margin: 0; padding: 0; }
.kx-linked-list li + li { border-top: 1px solid var(--kx-border); }
.kx-linked-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.7rem 0;
  text-decoration: none;
  color: var(--kx-text);
}
.kx-linked-item:hover { color: var(--kx-text); }
.kx-linked-item:hover .kx-linked-title { text-decoration: underline; }
.kx-linked-body { flex: 1 1 auto; min-width: 0; }
.kx-linked-title { font-size: 0.875rem; font-weight: var(--kx-fw-label); display: block; }
.kx-linked-meta {
  display: block;
  font-size: 0.75rem;
  color: var(--kx-text-muted);
  margin-top: 0.1rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.kx-linked-value {
  flex: 0 0 auto;
  font-variant-numeric: tabular-nums;
  font-size: 0.875rem;
  font-weight: var(--kx-fw-strong);
}

.kx-meta-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 1.25rem;
  font-size: 0.8125rem;
  color: var(--kx-text-muted);
}
.kx-meta-strip strong { color: var(--kx-text); font-weight: var(--kx-fw-strong); }
.kx-meta-strip .bi { margin-right: 0.25rem; }

.kx-ledger-bar {
  height: 0.375rem;
  border-radius: 999px;
  background: var(--kx-surface-3);
  overflow: hidden;
}
.kx-ledger-bar span {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: var(--kx-text);
}

.kx-trend { display: flex; align-items: flex-end; gap: 0.3rem; height: 4.5rem; }
.kx-trend-col { flex: 1 1 0; display: flex; flex-direction: column; justify-content: flex-end; height: 100%; }
.kx-trend-bar {
  border-radius: 3px 3px 0 0;
  background: var(--kx-text);
  min-height: 2px;
  transition: opacity 0.15s ease;
}
.kx-trend-col:hover .kx-trend-bar { opacity: 0.7; }
.kx-trend-labels {
  display: flex;
  gap: 0.3rem;
  margin-top: 0.35rem;
  font-size: var(--kx-fs-2xs);
  color: var(--kx-text-muted);
}
.kx-trend-labels span { flex: 1 1 0; text-align: center; overflow: hidden; }

/* A row of summary tiles that reflows on its own — the Bootstrap column
   version of this appears on nearly every screen and needed four wrappers to
   say the same thing. */
.kx-stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(13.5rem, 1fr));
  gap: 0.875rem;
  margin-bottom: 1rem;
}

/* Card headers carry a title, an optional description and optional actions.
   `.kx-card-title` is the heading-element twin of `.kx-section-title`, which
   is a span — both look identical on purpose. */
.kx-card-title {
  font-size: 0.9375rem;
  font-weight: var(--kx-fw-strong);
  letter-spacing: -0.01em;
  color: var(--kx-text);
  margin: 0;
}
.kx-card-desc {
  margin: 0.15rem 0 0;
  font-size: 0.8125rem;
  color: var(--kx-text-muted);
}
.kx-card-header > div:first-child .kx-card-desc { margin-top: 0.2rem; }
.kx-card-actions {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  flex-wrap: wrap;
  margin-left: auto;
}

.kx-empty-inline {
  margin: 0;
  padding: 0.5rem 0;
  font-size: 0.875rem;
  color: var(--kx-text-muted);
}
.kx-inline-link {
  display: inline-block;
  margin-top: 0.75rem;
  font-size: 0.8125rem;
  font-weight: var(--kx-fw-label);
}
.kx-field-error {
  margin: 0.3rem 0 0;
  font-size: 0.8125rem;
  color: var(--kx-danger);
}

/* The summary at the top of a form that was refused. It exists because these
   forms sit in modals: a modal re-rendered after a failed save comes back
   closed, so a message under a field is a message nobody reads. See
   partials/_form_errors.html. */
.kx-form-errors {
  margin: 0 0 1rem;
  padding: 0.75rem 0.875rem;
  border: 1px solid color-mix(in srgb, var(--kx-danger) 35%, transparent);
  border-radius: var(--kx-radius-sm, 8px);
  background: color-mix(in srgb, var(--kx-danger) 8%, transparent);
}
.kx-form-errors-title {
  margin: 0 0 0.35rem;
  font-size: 0.8125rem;
  font-weight: var(--kx-fw-strong);
  color: var(--kx-danger);
}
.kx-form-errors-list {
  margin: 0;
  padding-left: 1.1rem;
  font-size: 0.8125rem;
  line-height: 1.5;
  color: var(--kx-text);
}
.kx-form-errors-list li + li { margin-top: 0.2rem; }

/* A destructive entry in the activity feed reads differently from a routine
   one — this is the only place red appears in a list. */
.kx-feed li.destructive > span > strong { color: var(--kx-danger); }
.kx-feed-tag {
  display: inline-block;
  margin-left: 0.4rem;
  padding: 0.05rem 0.35rem;
  font-size: 0.6875rem;
  font-weight: var(--kx-fw-strong);
  border-radius: var(--kx-r-sm);
  background: var(--kx-danger-bg);
  color: var(--kx-danger);
}

/* The band at the foot of a detail page holding its irreversible action. */
.kx-danger-zone {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.25rem;
  flex-wrap: wrap;
  padding: 1.25rem;
  border: 1px solid var(--kx-danger-bd);
  border-radius: var(--kx-r-lg);
  background: var(--kx-danger-bg);
}
.kx-danger-zone-title {
  margin: 0 0 0.25rem;
  font-size: 0.9375rem;
  font-weight: var(--kx-fw-strong);
  color: var(--kx-text);
}
.kx-danger-zone-text {
  margin: 0;
  max-width: 46rem;
  font-size: 0.8125rem;
  color: var(--kx-text-muted);
  line-height: 1.55;
}

/* Permission grid on the staff forms. */
.kx-perm-table { width: 100%; font-size: 0.8125rem; }
.kx-perm-table th, .kx-perm-table td { padding: 0.5rem 0.6rem; border-bottom: 1px solid var(--kx-border); }
.kx-perm-table th { font-size: 0.6875rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--kx-text-muted); font-weight: var(--kx-fw-strong); }
.kx-perm-table td.kx-perm-module { font-weight: var(--kx-fw-label); }
.kx-perm-check { text-align: center; }

.kx-locked-note {
  display: flex;
  gap: 0.6rem;
  align-items: flex-start;
  padding: 0.875rem 1rem;
  border-radius: var(--kx-r-sm);
  background: var(--kx-surface-2);
  border: 1px solid var(--kx-border);
  font-size: 0.8125rem;
  color: var(--kx-text-muted);
  line-height: 1.55;
}
.kx-locked-note .bi { color: var(--kx-text); margin-top: 0.1rem; }
.kx-locked-note strong { color: var(--kx-text); }

/* ==========================================================================
   19. Setup wizard
   ========================================================================== */

.kx-setup { max-width: 52rem; }

/* The progress rail scrolls inside itself rather than widening the page. Four
   labelled steps do not fit across a 360px screen, and hiding them would lose
   the only signal of how far along you are. */
.kx-setup-rail {
  display: flex;
  gap: 0.5rem;
  list-style: none;
  margin: 0 0 1rem;
  padding: 0 0 0.25rem;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
}
.kx-setup-rail-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex: 1 1 0;
  min-width: 9.5rem;
  padding: 0.625rem 0.75rem;
  background: var(--kx-surface);
  border: 1px solid var(--kx-border);
  border-radius: var(--kx-r-md);
}
.kx-setup-rail-item.is-current { border-color: var(--kx-text); }
.kx-setup-rail-mark {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 22px;
  height: 22px;
  border-radius: 999px;
  background: var(--kx-surface-3);
  color: var(--kx-text-2);
  font-size: 0.75rem;
  font-weight: var(--kx-fw-strong);
}
.kx-setup-rail-item.is-completed .kx-setup-rail-mark { background: var(--kx-success-bg); color: var(--kx-success); }
.kx-setup-rail-item.is-skipped .kx-setup-rail-mark { background: var(--kx-warning-bg); color: var(--kx-warning); }
.kx-setup-rail-body { min-width: 0; }
.kx-setup-rail-title {
  display: block;
  font-size: 0.8125rem;
  font-weight: var(--kx-fw-label);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.kx-setup-rail-state { display: block; font-size: 0.6875rem; color: var(--kx-text-muted); }

/* One option per row, each explaining itself. A radio label that says only
   "In arrears" is a coin toss for anyone who has not met the term. */
.kx-choice-set { display: grid; gap: 0.625rem; }
.kx-choice {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.875rem 1rem;
  border: 1px solid var(--kx-border);
  border-radius: var(--kx-r-md);
  cursor: pointer;
}
.kx-choice:hover { border-color: var(--kx-border-strong); }
.kx-choice:focus-within { border-color: var(--kx-accent); box-shadow: 0 0 0 3px var(--kx-focus-ring); }
.kx-choice input { margin-top: 0.2rem; flex-shrink: 0; }
.kx-choice-body { min-width: 0; }
.kx-choice-title { display: block; font-weight: var(--kx-fw-strong); font-size: 0.9375rem; }
.kx-choice-desc { display: block; margin-top: 0.2rem; font-size: 0.8125rem; color: var(--kx-text-muted); }
.kx-choice-example {
  margin-top: 0.35rem;
  font-size: var(--kx-fs-sm);
  color: var(--kx-text-2);
  font-variant-numeric: tabular-nums;
}

.kx-setup-actions { align-items: center; }
.kx-setup-note { font-size: 0.8125rem; color: var(--kx-text-muted); }

.kx-setup-implications {
  margin-top: 1.5rem;
  padding: 1rem 1.125rem;
  background: var(--kx-surface-2);
  border-radius: var(--kx-r-md);
}
.kx-setup-implications-title { margin: 0 0 0.5rem; font-size: 0.875rem; font-weight: var(--kx-fw-strong); }
.kx-setup-implications ul { margin: 0 0 0.75rem; padding-left: 1.15rem; }
.kx-setup-implications li { font-size: 0.8125rem; color: var(--kx-text-muted); margin-bottom: 0.25rem; }

.kx-setup-summary { list-style: none; margin: 0; padding: 0; }
.kx-setup-summary li {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.875rem 0;
  flex-wrap: wrap;
}
.kx-setup-summary li + li { border-top: 1px solid var(--kx-border); }
.kx-setup-summary-mark { flex-shrink: 0; margin-top: 0.1rem; }
.kx-setup-summary li.is-completed .kx-setup-summary-mark { color: var(--kx-success); }
.kx-setup-summary li.is-skipped .kx-setup-summary-mark { color: var(--kx-warning); }
.kx-setup-summary-body { flex: 1 1 14rem; min-width: 0; }
.kx-setup-summary-title { display: block; font-weight: var(--kx-fw-label); font-size: 0.875rem; }
.kx-setup-summary-desc { display: block; font-size: 0.8125rem; color: var(--kx-text-muted); margin-top: 0.15rem; }

.kx-setup-banner {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  padding: 0.625rem 1.25rem;
  background: var(--kx-info-bg, var(--kx-surface-2));
  border-bottom: 1px solid var(--kx-border);
  font-size: 0.8125rem;
}
.kx-setup-banner-text { flex: 1 1 16rem; min-width: 0; }
.kx-setup-banner-actions { margin-left: auto; }

/* A setting shown rather than offered. */
.kx-locked-setting {
  padding: 0.875rem 1rem;
  border: 1px solid var(--kx-border);
  border-radius: var(--kx-r-md);
  background: var(--kx-surface-2);
}
.kx-locked-setting-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 0.375rem;
}
.kx-locked-setting-label { font-size: 0.8125rem; font-weight: var(--kx-fw-strong); }
.kx-locked-setting-value { margin: 0 0 0.5rem; font-size: 0.875rem; }

/* The logo control — preview beside the input, never the stored file name. */
.kx-logo-field {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  flex-wrap: wrap;
}
.kx-logo-preview {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 96px;
  height: 64px;
  padding: 0.375rem;
  background: var(--kx-surface-3);
  border: 1px solid var(--kx-border);
  border-radius: var(--kx-r-md);
  overflow: hidden;
  color: var(--kx-text-muted);
  font-size: var(--kx-fs-2xl);
}
/* `contain`, not `cover`: this preview is meant to show the logo's real
   proportions, since those are what the document prints. `cover` would crop
   a wide wordmark to a square and quietly misrepresent the result. */
.kx-logo-preview img { max-width: 100%; max-height: 100%; width: auto; height: auto; object-fit: contain; }
.kx-logo-controls { flex: 1 1 16rem; min-width: 0; }
.kx-logo-state { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; margin: 0 0 0.5rem; }

/* ==========================================================================
   20. Horizontal overflow — the page never gets wider than the phone
   --------------------------------------------------------------------------
   Every rule here removes a *cause*. None of them is `overflow-x: hidden` on
   the page, which would leave the content just as wide and simply make the
   part that overflows unreachable.

   Two causes account for nearly all of it:

   1. A flex or grid child defaults to `min-width: auto`, meaning it refuses to
      shrink below its content's intrinsic width. One long email address, unit
      name or receipt number in such a child pushes the whole page out. The fix
      is `min-width: 0` on the children of every flex row the app lays out.

   2. Something genuinely wide — a table, a permission matrix, a progress rail —
      with nothing around it that scrolls. The fix is a scroll container of its
      own, so the wide thing stays fully reachable while the page does not move.
   ========================================================================== */

/* Nothing in the shell may be measured wider than the viewport. */
.kx-app, .kx-main, .kx-content { max-width: 100%; }
.kx-main, .kx-content { min-width: 0; }

/* (1) Let flex children shrink. These are the app's own row layouts; the text
   side of each is the part that must give way. */
.kx-page-header > div,
.kx-card-header > div,
.kx-danger-zone > div,
.kx-danger-head > div,
.kx-stat-head > .kx-stat-label,
.kx-meta-strip > span,
.kx-alert > div,
.kx-flex-text { min-width: 0; }

/* The topbar is its own case, and the one that bit on a tablet. `.kx-user-name`
   has always had `text-overflow: ellipsis`, but ellipsis only engages once the
   box is actually made narrower — and every flex box between it and the topbar
   defaulted to `min-width: auto`, so none of them would give. The truncation
   was written and never able to happen. Unlocking the whole chain is what
   makes it work; capping the button alone did not. */
.kx-topbar > *,
.kx-topbar-actions,
.kx-topbar-actions > .dropdown,
.kx-search,
.kx-user-btn { min-width: 0; }

/* (2) Long unbroken strings — emails, references, URLs, unit codes — wrap
   instead of setting the page's width. `anywhere` rather than `break-word`
   so it applies to the intrinsic-size calculation too, which is what actually
   stops the overflow. */
.kx-page-header h1,
.kx-page-desc,
.kx-meta-strip,
.kx-stat-meta,
.kx-card-desc,
.kx-alert,
.kx-help,
.kx-empty-text,
.kx-linked-meta,
.kx-feed li,
.kx-locked-setting-value,
.kx-setup-summary-desc,
.kx-doc-contact { overflow-wrap: anywhere; }

/* Images never exceed their column, whatever their natural size. */
.kx-content img { max-width: 100%; height: auto; }

/* Buttons hold their label rather than their label holding the page open. */
.kx-page-actions > .btn,
.kx-card-actions > .btn { max-width: 100%; }

@media (max-width: 575.98px) {
  /* At the narrowest sizes an auto-fit track wider than the viewport is a
     single column that overflows. Pinning the minimum to 0 makes it a column
     that fits. Larger screens keep the auto-fit behaviour untouched. */
  .kx-stat-grid,
  .kx-related-grid,
  .kx-filter-fields { grid-template-columns: minmax(0, 1fr); }

  /* Page actions stack rather than squeezing four buttons onto one line. */
  .kx-page-actions { width: 100%; }
  .kx-page-actions > .btn { flex: 1 1 100%; justify-content: center; }

  /* The tenant page's ledger and payment tables are the widest thing in the
     app. They already scroll inside `.kx-table-wrap`; this keeps that wrapper
     from being stretched by its own card. */
  .kx-card > .kx-table-wrap { max-width: 100%; }

  .kx-setup-rail-item { min-width: 8.5rem; }
  .kx-logo-field { gap: 0.75rem; }
}

/* --------------------------------------------------------------------------
   Print — invoices and statements are real documents.
   -------------------------------------------------------------------------- */

@media print {
  .kx-sidebar,
  .kx-topbar,
  .kx-setup-banner,
  .kx-preview-banner,
  .kx-toast-region,
  .kx-page-actions,
  .kx-print-hide,
  .kx-public-nav,
  .kx-footer { display: none !important; }

  body, .kx-app, .kx-content { background: #fff !important; color: #000 !important; }
  .kx-content { padding: 0 !important; max-width: none !important; }
  .kx-card { border: 1px solid #ddd !important; box-shadow: none !important; break-inside: avoid; }
  .table > thead th { position: static; }
  a { text-decoration: none !important; color: #000 !important; }
  @page { margin: 16mm; }
}

/* ---------------------------------------------------------------------------
   Conditional blocks
   ---------------------------------------------------------------------------

   Fields that only exist to override a value the system already knows. Shut by
   default so the override reads as an exception rather than as a question the
   form is asking. Driven by `initConditionalBlocks` in kernexa.js; with JS off
   the block simply stays visible, which is the safe way round.
   -------------------------------------------------------------------------- */

.kx-conditional {
  display: none;
  margin-top: 0.75rem;
  padding: 0.875rem 1rem;
  border: 1px dashed var(--kx-border-strong);
  border-radius: var(--kx-r-md);
  background: var(--kx-surface-2);
}
.kx-conditional.open { display: block; }

/* No JS: show it, so the fields are reachable. */
html:not(.kx-js) .kx-conditional { display: block; }

/* A saved setting shown as the reader will actually encounter it — a formatted
   amount, a document number, a count. Larger than body text because the whole
   point is that it is glanceable next to the input that produces it. */
.kx-setting-example {
  font-size: 1.125rem;
  font-weight: var(--kx-fw-strong);
  color: var(--kx-text);
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--kx-border);
  border-radius: var(--kx-r-sm);
  background: var(--kx-surface-2);
}

/* A table used as reference material rather than as data — the import column
   guide, for one. Tighter than a list of records, because it is read once and
   then scrolled past. */
.kx-table-compact th,
.kx-table-compact td {
  padding-top: 0.4rem;
  padding-bottom: 0.4rem;
  font-size: 0.8125rem;
}

/* ==========================================================================
   23. Label/value lists, and the subscription panel
   --------------------------------------------------------------------------
   `.kx-detail-list` is the plain two-column read-out used wherever a screen
   states facts it is not offering to change — who is being approved, where a
   company stands on its plan, what a company is subscribed to. Three templates
   were already asking for it before it existed, which rendered them as bulleted
   lists with the label and the value run together.

   The subscription panel below is the company's own view of the same facts. It
   is read-only for a structural reason, not a cosmetic one: price, period,
   features and limits all belong to the plan, which is platform-owned, so
   there is nothing here to submit. What it can do is make the state legible at
   a glance — what you are on, how long is left, how much of the plan you are
   using, and what it includes.
   ========================================================================== */

.kx-detail-list {
  list-style: none;
  margin: 0;
  padding: 0;
  font-size: 0.875rem;
}
.kx-detail-list > li {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.25rem 1.5rem;
  flex-wrap: wrap;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--kx-border-subtle);
}
.kx-detail-list > li:first-child { padding-top: 0; }
.kx-detail-list > li:last-child { border-bottom: 0; padding-bottom: 0; }
.kx-detail-list > li > span { min-width: 0; }
.kx-detail-list > li > span:first-child { color: var(--kx-text-muted); }
.kx-detail-list > li > span + span {
  flex: 1 1 auto;
  text-align: right;
  font-weight: var(--kx-fw-label);
  color: var(--kx-text);
}

/* The plan itself, on its own strip above the body — it is the answer to the
   question the card asks, so it does not queue up behind the details. */
.kx-plan-hero {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.5rem 1rem;
  flex-wrap: wrap;
  padding: 1.125rem 1.25rem;
  background: var(--kx-surface-2);
  border-bottom: 1px solid var(--kx-border);
}
.kx-plan-id { flex: 1 1 9rem; min-width: 0; }
.kx-plan-price { flex: 0 1 auto; min-width: 0; text-align: right; }
.kx-plan-name,
.kx-plan-amount {
  display: block;
  font-size: var(--kx-fs-xl);
  font-weight: var(--kx-fw-strong);
  letter-spacing: -0.02em;
  color: var(--kx-text);
}
.kx-plan-amount { font-variant-numeric: tabular-nums; }
.kx-plan-desc {
  display: block;
  margin-top: 0.2rem;
  font-size: 0.8125rem;
  color: var(--kx-text-muted);
}
.kx-plan-cadence {
  display: block;
  margin-top: 0.25rem;
  font-size: 0.6875rem;
  font-weight: var(--kx-fw-strong);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--kx-text-muted);
}

/* How much of the paid-for period has been used. */
.kx-plan-term-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem 1rem;
  flex-wrap: wrap;
  font-size: 0.8125rem;
}
.kx-plan-term-head > span { min-width: 0; }
.kx-plan-term-label { font-weight: var(--kx-fw-label); color: var(--kx-text); }
.kx-plan-term-left { color: var(--kx-text-muted); font-variant-numeric: tabular-nums; }
.kx-plan-term-left.is-close { color: var(--kx-warning); font-weight: var(--kx-fw-strong); }
.kx-plan-term-foot { margin: 0.4375rem 0 0; font-size: 0.75rem; color: var(--kx-text-faint); }

/* Colour is meaning here: a bar only leaves neutral when the reader has
   something to act on — a period nearly up, or a ceiling reached. */
.kx-meter.is-close > span { background: var(--kx-warning); }
.kx-meter.is-full > span  { background: var(--kx-danger); }

/* Usage against the plan's ceilings. The counts are the ones the limit checks
   refuse on, so this bar and that refusal can never tell different stories. */
.kx-plan-usage {
  display: grid;
  gap: 0.875rem;
  margin-top: 1.25rem;
  padding-top: 1rem;
  border-top: 1px solid var(--kx-border-subtle);
}
.kx-plan-usage-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem 1rem;
  font-size: 0.8125rem;
  color: var(--kx-text-muted);
}
.kx-plan-usage-head > span { min-width: 0; }
.kx-plan-usage-count {
  font-weight: var(--kx-fw-strong);
  color: var(--kx-text);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.kx-plan-usage-count.is-full { color: var(--kx-danger); }
.kx-plan-usage-row .kx-meter { margin-top: 0.4375rem; }

.kx-plan-features {
  list-style: none;
  display: grid;
  gap: 0.4375rem;
  margin: 1.25rem 0 0;
  padding: 1rem 0 0;
  border-top: 1px solid var(--kx-border-subtle);
  font-size: 0.8125rem;
  color: var(--kx-text-2);
}
.kx-plan-features li { display: flex; align-items: baseline; gap: 0.5rem; min-width: 0; }
.kx-plan-features i { flex-shrink: 0; color: var(--kx-success); }

.kx-plan .kx-alert { margin: 1.25rem 0 0; }

/* A company that predates the plans. Nothing is wrong, so this is a statement
   rather than a warning. */
.kx-plan-none {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.875rem 1rem;
  border: 1px solid var(--kx-border);
  border-radius: var(--kx-r-md);
  background: var(--kx-surface-2);
  font-size: 0.8125rem;
  color: var(--kx-text-muted);
}
.kx-plan-none > div { min-width: 0; }
.kx-plan-none > i { flex-shrink: 0; margin-top: 0.1rem; color: var(--kx-success); }
.kx-plan-none-title {
  display: block;
  margin-bottom: 0.15rem;
  font-size: 0.875rem;
  font-weight: var(--kx-fw-strong);
  color: var(--kx-text);
}

.kx-plan-note {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  margin-top: 1.25rem;
  padding-top: 0.875rem;
  border-top: 1px solid var(--kx-border-subtle);
  font-size: 0.75rem;
  line-height: 1.6;
  color: var(--kx-text-muted);
}
.kx-plan-note > i { flex-shrink: 0; color: var(--kx-text-faint); }

/* ==========================================================================
   24. Platform console
   --------------------------------------------------------------------------
   The platform operator's screens share the app shell but are a different job.
   They used to render with an empty sidebar, which left an operator on a page
   with no way to anywhere else; they now carry `PLATFORM_NAV_SECTIONS`. This
   strip says which of the two consoles you are looking at, because the menus
   are alike enough that the question comes up.
   ========================================================================== */

.kx-sidebar-mode {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0 0.75rem 0.25rem;
  padding: 0.4375rem 0.625rem;
  border: 1px solid var(--kx-border);
  border-radius: var(--kx-r-sm);
  background: var(--kx-surface-2);
  font-size: 0.6875rem;
  font-weight: var(--kx-fw-strong);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--kx-text-2);
}
.kx-sidebar-mode > i { flex-shrink: 0; font-size: 0.8125rem; color: var(--kx-text-muted); }

/* Collapsed to icons: the label goes with every other label. */
.kx-sidebar.collapsed .kx-sidebar-mode { justify-content: center; margin-inline: 0.5rem; }
.kx-sidebar.collapsed .kx-sidebar-mode .kx-sidebar-label { display: none; }

/* Where the company search box would be. The topbar pushes its actions right
   with `flex: 1` on the search; without a stand-in they slide left and the
   whole bar rearranges itself between a company page and a platform one. */
.kx-search-spacer { flex: 1; }

/* --------------------------------------------------------------------------
   Date window picker
   --------------------------------------------------------------------------
   Shared by the reports, the landlord page and anything else read over a
   period. Laid out as a wrapping row rather than a grid so the two date boxes
   can disappear for a preset without leaving a gap where they were. */

.kx-period-row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0.75rem;
}
.kx-period-row .kx-field { margin-bottom: 0; }
.kx-period-preset { flex: 1 1 14rem; min-width: 0; max-width: 20rem; }
.kx-period-custom { flex: 0 1 11rem; min-width: 0; }
.kx-period-apply { flex: 0 0 auto; }
.kx-period-summary { margin-top: 0.6rem; margin-bottom: 0; }

/* On a phone every control takes the full width — a date input squeezed to a
   third of a narrow screen shows a truncated placeholder and nothing else. */
@media (max-width: 575.98px) {
  .kx-period-preset,
  .kx-period-custom,
  .kx-period-apply { flex: 1 1 100%; }
  .kx-period-apply .btn { width: 100%; }
}

/* Duplicate warning
   --------------------------------------------------------------------------
   "You may already have this person." Shown above the form that was just
   submitted, on the tenant and staff create screens.

   Deliberately warning-coloured rather than danger-coloured: nothing has gone
   wrong, and nothing is being refused. Two people really can share a name, so
   the panel's job is to be read once and then either heeded or overruled — red
   would say "you have made a mistake", which is not what this knows. */

.kx-duplicate-warning {
  border: 1px solid var(--kx-warning-bd);
  background: var(--kx-warning-bg);
  border-radius: var(--kx-r-md);
  padding: 0.875rem 1rem;
  margin-bottom: 1rem;
}

.kx-duplicate-head {
  display: flex;
  align-items: flex-start;
  gap: 0.625rem;
}
.kx-duplicate-head > i {
  flex-shrink: 0;
  margin-top: 0.15rem;
  color: var(--kx-warning);
  font-size: 1rem;
}
.kx-duplicate-title {
  margin: 0;
  font-weight: var(--kx-fw-strong);
  color: var(--kx-text);
}
.kx-duplicate-desc {
  margin: 0.15rem 0 0;
  font-size: 0.8125rem;
  line-height: 1.55;
  color: var(--kx-text-muted);
}

.kx-duplicate-list {
  list-style: none;
  margin: 0.75rem 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.kx-duplicate-item {
  background: var(--kx-surface);
  border: 1px solid var(--kx-border);
  border-radius: var(--kx-r-sm);
  padding: 0.5rem 0.75rem;
}
/* The name and its badge wrap rather than squeeze: on a phone the badge text
   is longer than the space beside a full name, and truncating the one that
   says how sure we are defeats the point of showing it. */
.kx-duplicate-item-main {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}
.kx-duplicate-item-main a {
  font-weight: var(--kx-fw-strong);
  color: var(--kx-text);
}
.kx-duplicate-item-why {
  margin: 0.2rem 0 0;
  font-size: 0.8125rem;
  color: var(--kx-text-muted);
}

.kx-duplicate-foot {
  margin: 0.75rem 0 0;
  font-size: 0.8125rem;
  color: var(--kx-text-muted);
}

/* Notification rows on the full-page list
   --------------------------------------------------------------------------
   Distinct from `.kx-notif-item`, which is the compact row in the header
   dropdown. This one carries a badge, a message that may be a link, a time and
   a button, and has to hold together at 360px — hence the wrap rather than a
   fixed two-column layout. */

.kx-notif-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.875rem 1.25rem;
  border-bottom: 1px solid var(--kx-border-subtle);
}
.kx-notif-row:last-child { border-bottom: 0; }
.kx-notif-row.is-unread { background: var(--kx-surface-2); }

/* Mark read and Dismiss sit together on the right. Wrapping rather than
   shrinking, so a narrow screen stacks them under each other instead of
   squeezing the message. */
.kx-notif-row-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 0.375rem;
}

.kx-notif-row-main {
  min-width: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.4rem;
  font-size: 0.875rem;
  line-height: 1.55;
}
.kx-notif-message { color: var(--kx-text); }
a.kx-notif-message { text-decoration: none; }
a.kx-notif-message:hover { text-decoration: underline; }

/* The whole row is dimmed rather than the text alone: a resolved notification
   should read as finished at a glance, without anyone having to look for the
   word. Not hidden — "did that get sorted?" is a fair question. */
.kx-notif-row.is-resolved { opacity: 0.62; }
.kx-notif-row.is-resolved .kx-notif-message { text-decoration: line-through; }

.kx-notif-row .kx-notif-time { display: inline; margin-top: 0; }

/* Subscription strip on the owner's dashboard
   --------------------------------------------------------------------------
   One line above the stat tiles. Quiet by default and coloured only as the
   period runs out — a dashboard that raises its voice every day is one nobody
   reads by the second week. See dashboard/_subscription_strip.html. */

.kx-sub-strip {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.6875rem 1rem;
  margin-bottom: 0.75rem;
  border: 1px solid var(--kx-border);
  border-radius: var(--kx-r-md);
  background: var(--kx-surface);
}
.kx-sub-strip.is-close {
  border-color: var(--kx-warning-bd);
  background: var(--kx-warning-bg);
}
.kx-sub-strip.is-expired {
  border-color: var(--kx-danger-bd);
  background: var(--kx-danger-bg);
}

.kx-sub-strip-main {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  min-width: 0;
}
.kx-sub-strip-icon { flex-shrink: 0; color: var(--kx-text-muted); font-size: 1rem; }
.kx-sub-strip.is-close .kx-sub-strip-icon { color: var(--kx-warning); }
.kx-sub-strip.is-expired .kx-sub-strip-icon { color: var(--kx-danger); }

.kx-sub-strip-text { min-width: 0; }
.kx-sub-strip-plan {
  display: block;
  font-weight: var(--kx-fw-strong);
  font-size: 0.875rem;
  color: var(--kx-text);
}
.kx-sub-strip-term {
  display: block;
  font-size: 0.8125rem;
  line-height: 1.5;
  color: var(--kx-text-muted);
}

.kx-sub-strip-side {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex: 0 1 auto;
}
/* The meter is the first thing to go when there is no room for it: it repeats
   what the "N days left" text already says, and the link must survive. */
.kx-sub-strip-side .kx-meter { width: 8rem; }
@media (max-width: 575.98px) {
  .kx-sub-strip-side { width: 100%; justify-content: space-between; }
  .kx-sub-strip-side .kx-meter { display: none; }
}

/* ==========================================================================
   24. Ownership editor
   --------------------------------------------------------------------------
   A property's landlords and their shares, edited as one allocation rather
   than one row at a time. The running total is the point of the layout: a
   property whose shares miss 100% pays out the wrong amount to everybody on
   it, and before this screen existed nothing said so.

   The share box and its `%` sit in one bordered group so the suffix reads as
   part of the field rather than as text next to it.
   ========================================================================== */

.kx-ownership-rows { display: grid; gap: 0.5rem; }

.kx-ownership-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 7.5rem auto;
  align-items: center;
  gap: 0.5rem;
}

.kx-ownership-share {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}
.kx-ownership-share .form-control { text-align: right; }
.kx-ownership-suffix { color: var(--kx-text-muted); font-size: 0.875rem; }

/* The total when it does not come to 100%. Stated in colour *and* in the
   sentence underneath, because colour alone is not a message. */
.kx-share-off { color: var(--kx-danger); }

.kx-hidden { display: none !important; }

/* A disclosure for past ownership periods. Closed by default — history is
   worth keeping and worth checking, and not worth the space on first look. */
.kx-details > summary {
  cursor: pointer;
  font-size: 0.875rem;
  color: var(--kx-text-muted);
}
.kx-details > summary:hover { color: var(--kx-text); }

@media (max-width: 575.98px) {
  .kx-ownership-row { grid-template-columns: minmax(0, 1fr) 5.5rem auto; }
}

/* ---- Free trial card (Preview Mode) ---------------------------------------

   The one action a company waiting to be approved can take, so it sits above
   the sample data and is allowed to look like an offer rather than another
   panel. Two columns on a desktop, stacked on a phone, with the action pinned
   to the top of its column so it stays beside the heading rather than
   drifting down beside the last bullet. */

.kx-trial-card {
  border-color: var(--kx-border-strong);
  background:
    linear-gradient(180deg, var(--kx-surface-2) 0%, var(--kx-surface) 62%);
}

.kx-trial-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 17rem);
  gap: 1.5rem;
  align-items: start;
}

.kx-trial-title {
  margin: 0.35rem 0 0.5rem;
  /* A step below a page heading: this is a card title, not the page's subject. */
  font-size: var(--kx-fs-2xl);
  line-height: 1.25;
}

.kx-trial-desc {
  margin: 0 0 0.875rem;
  color: var(--kx-text-muted);
  max-width: 46ch;
}

.kx-trial-points {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.4rem;
  font-size: 0.875rem;
}

.kx-trial-points li {
  display: grid;
  grid-template-columns: 1.1rem minmax(0, 1fr);
  gap: 0.5rem;
  align-items: start;
}

.kx-trial-points i {
  color: var(--kx-success);
  line-height: 1.45;
}

.kx-trial-action { padding-top: 0.35rem; }

@media (max-width: 767.98px) {
  .kx-trial-grid { grid-template-columns: minmax(0, 1fr); gap: 1.125rem; }
  .kx-trial-action { padding-top: 0; }
}

/* ---- Onboarding: account type ---------------------------------------- */

.kx-onboard-eyebrow {
  margin: 0 0 0.5rem;
  font-size: 0.75rem;
  font-weight: var(--kx-fw-strong);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--kx-text-muted);
}
.kx-type-choice-group { display: grid; gap: 0.75rem; min-width: 0; margin: 0; padding: 0; border: 0; }
.kx-type-choice { position: relative; display: block; margin: 0; cursor: pointer; }
/* Hidden but still focusable and announced, so the cards work from a keyboard. */
.kx-type-choice-input { position: absolute; top: 0; left: 0; width: 1px; height: 1px; opacity: 0; }
.kx-type-choice-card {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: start;
  gap: 1rem;
  padding: 1.125rem;
  border: 1px solid var(--kx-border);
  border-radius: var(--kx-r-lg);
  background: var(--kx-surface);
  box-shadow: var(--kx-shadow-xs);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.kx-type-choice:hover .kx-type-choice-card { border-color: var(--kx-border-strong); box-shadow: var(--kx-shadow-sm); }
.kx-type-choice-input:focus-visible + .kx-type-choice-card { border-color: var(--kx-text); box-shadow: 0 0 0 4px var(--kx-focus-ring); }
.kx-type-choice-input:checked + .kx-type-choice-card { border-color: var(--kx-text); box-shadow: 0 0 0 1px var(--kx-text), var(--kx-shadow-md); }
.kx-type-choice-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.75rem;
  height: 2.75rem;
  border: 1px solid var(--kx-border-subtle);
  border-radius: var(--kx-r-md);
  background: var(--kx-surface-2);
  color: var(--kx-text);
  font-size: var(--kx-fs-2xl);
  transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.kx-type-choice-input:checked + .kx-type-choice-card .kx-type-choice-icon { border-color: var(--kx-accent); background: var(--kx-accent); color: var(--kx-accent-text); }
.kx-type-choice-body { display: grid; gap: 0.25rem; min-width: 0; }
.kx-type-choice-title { font-size: 0.9375rem; font-weight: var(--kx-fw-strong); letter-spacing: -0.01em; color: var(--kx-text); }
.kx-type-choice-text { font-size: 0.8125rem; line-height: 1.45; color: var(--kx-text-muted); }
.kx-type-choice-points { display: grid; gap: 0.25rem; margin-top: 0.5rem; }
.kx-type-choice-points span { display: flex; align-items: flex-start; gap: 0.5rem; font-size: 0.8125rem; color: var(--kx-text-2); }
.kx-type-choice-points i { margin-top: 0.125rem; font-size: 0.75rem; color: var(--kx-text); }
.kx-type-choice-check {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.375rem;
  height: 1.375rem;
  border: 1px solid var(--kx-border-strong);
  border-radius: 999px;
  color: transparent;
  font-size: 0.8125rem;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}
.kx-type-choice-input:checked + .kx-type-choice-card .kx-type-choice-check { border-color: var(--kx-accent); background: var(--kx-accent); color: var(--kx-accent-text); }

@media (max-width: 575.98px) {
  .kx-type-choice-card { grid-template-columns: auto minmax(0, 1fr); gap: 0.875rem; padding: 1rem; }
  .kx-type-choice-check { position: absolute; top: 1rem; right: 1rem; }
  .kx-type-choice-body { padding-right: 1.75rem; }
}
@media (prefers-reduced-motion: reduce) {
  .kx-type-choice-card, .kx-type-choice-icon, .kx-type-choice-check { transition: none; }
}

/* ---- Account type change: what it would do ----------------------------- */

.kx-type-impact { display: grid; gap: 0.625rem; margin: 0; padding: 0; list-style: none; }
.kx-type-impact > li {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.875rem 1rem;
  border: 1px solid var(--kx-border);
  border-radius: var(--kx-r-md);
  background: var(--kx-surface);
  font-size: var(--kx-fs-md);
  line-height: 1.5;
  color: var(--kx-text-2);
}
.kx-type-impact > li strong { font-weight: var(--kx-fw-strong); color: var(--kx-text); }
.kx-type-impact > li > i { margin-top: 0.125rem; font-size: var(--kx-fs-lg); color: var(--kx-text); }
.kx-type-impact > li.kx-type-impact-danger { border-color: var(--kx-danger-bd); background: var(--kx-danger-bg); }
.kx-type-impact > li.kx-type-impact-danger > i { color: var(--kx-danger); }

/* ---- Assistant: tokens and the pieces drawn before assistant.css loads ---- */

:root {
  --kx-ai-1: #6d5dfc;
  --kx-ai-2: #1fb6d4;
  --kx-ai-grad: linear-gradient(135deg, var(--kx-ai-1), var(--kx-ai-2));
  --kx-ai-soft: rgba(109, 93, 252, 0.07);
  --kx-ai-ring: rgba(109, 93, 252, 0.22);
  --kx-ai-panel-w: 440px;
}
[data-theme="dark"] {
  --kx-ai-1: #8b7dff;
  --kx-ai-2: #3fc9e3;
  --kx-ai-soft: rgba(139, 125, 255, 0.10);
  --kx-ai-ring: rgba(139, 125, 255, 0.32);
}

/* Explain buttons on figures */
.kx-ai-explain {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.15rem 0.5rem;
  border: 1px solid transparent;
  border-radius: 999px;
  background: transparent;
  font-size: var(--kx-fs-xs);
  font-weight: var(--kx-fw-label);
  color: var(--kx-text-muted);
  transition: color 0.12s ease, background-color 0.12s ease, border-color 0.12s ease;
}
.kx-ai-explain .bi { background: var(--kx-ai-grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.kx-ai-explain:hover { color: var(--kx-text); background: var(--kx-ai-soft); border-color: var(--kx-ai-ring); }
.btn.kx-ai-explain-btn .bi { background: var(--kx-ai-grad); -webkit-background-clip: text; background-clip: text; color: transparent; }

.kx-stat-head > .kx-ai-explain {
  margin-left: auto;
  justify-content: center;
  width: 1.75rem;
  height: 1.75rem;
  padding: 0;
  font-size: var(--kx-fs-sm);
}
.kx-stat-head > .kx-ai-explain .kx-ai-explain-text { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Bootstrap's weight utilities and bold elements follow the same scale. */
b, strong { font-weight: var(--kx-fw-strong); }
.fw-normal { font-weight: var(--kx-fw-body) !important; }
.fw-medium { font-weight: var(--kx-fw-label) !important; }
.fw-semibold { font-weight: var(--kx-fw-strong) !important; }
.fw-bold { font-weight: var(--kx-fw-display) !important; }

/* ==========================================================================
   App accents
   --------------------------------------------------------------------------
   Inside the signed-in app only; the public site stays black and white.
   Colour marks meaning (what kind of figure, money in, late) and stays in
   small surfaces: icon chips, initials, one bar. Glass is for what floats.
   ========================================================================== */

:root {
  --kx-brand: #4338ca;
  --kx-tone-green: #16a34a;
  --kx-tone-amber: #d97706;
  --kx-tone-red: #dc2626;
  --kx-tone-blue: #2563eb;
  --kx-tone-teal: #0d9488;
  --kx-tone-indigo: #4f46e5;
  --kx-tone-violet: #7c3aed;
  --kx-tone-slate: #475569;
  --kx-tone-rose: #e11d48;
}
[data-theme="dark"] {
  --kx-brand: #a5b4fc;
  --kx-tone-green: #4ade80;
  --kx-tone-amber: #fbbf24;
  --kx-tone-red: #f87171;
  --kx-tone-blue: #60a5fa;
  --kx-tone-teal: #2dd4bf;
  --kx-tone-indigo: #818cf8;
  --kx-tone-violet: #a78bfa;
  --kx-tone-slate: #94a3b8;
  --kx-tone-rose: #fb7185;
}

/* ---- Every screen takes its section's colour ---- */

/* One table: `dashboard/nav.py` names the tone, and every shared piece below reads it. */
.kx-content,
.kx-sidebar-link[data-tone="indigo"] { --kx-page-tone: var(--kx-tone-indigo); }
.kx-content[data-tone="green"], .kx-sidebar-link[data-tone="green"] { --kx-page-tone: var(--kx-tone-green); }
.kx-content[data-tone="amber"], .kx-sidebar-link[data-tone="amber"] { --kx-page-tone: var(--kx-tone-amber); }
.kx-content[data-tone="red"], .kx-sidebar-link[data-tone="red"] { --kx-page-tone: var(--kx-tone-red); }
.kx-content[data-tone="blue"], .kx-sidebar-link[data-tone="blue"] { --kx-page-tone: var(--kx-tone-blue); }
.kx-content[data-tone="teal"], .kx-sidebar-link[data-tone="teal"] { --kx-page-tone: var(--kx-tone-teal); }
.kx-content[data-tone="violet"], .kx-sidebar-link[data-tone="violet"] { --kx-page-tone: var(--kx-tone-violet); }
.kx-content[data-tone="slate"], .kx-sidebar-link[data-tone="slate"] { --kx-page-tone: var(--kx-tone-slate); }
.kx-content[data-tone="rose"], .kx-sidebar-link[data-tone="rose"] { --kx-page-tone: var(--kx-tone-rose); }

.kx-content[style] .kx-page-header > div:first-child:has(> h1) {
  position: relative;
  min-height: 2.75rem;
  padding-left: 3.5rem;
}
.kx-content[style] .kx-page-header > div:first-child:has(> h1)::before {
  content: var(--kx-page-glyph);
  position: absolute;
  top: 0.1rem;
  left: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.75rem;
  height: 2.75rem;
  border-radius: 13px;
  background: color-mix(in srgb, var(--kx-page-tone) 12%, transparent);
  color: var(--kx-page-tone);
  font-family: bootstrap-icons;
  font-size: var(--kx-fs-2xl);
  font-weight: normal;
  line-height: 1;
}
.kx-content .kx-stat-icon,
.kx-content .kx-empty-icon {
  background: color-mix(in srgb, var(--kx-page-tone) 12%, transparent);
  color: var(--kx-page-tone);
}
.kx-content .kx-card-header .kx-section-title {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}
.kx-content .kx-card-header .kx-section-title::before {
  content: "";
  flex: none;
  width: 3px;
  height: 0.95em;
  border-radius: 3px;
  background: var(--kx-page-tone);
}
.kx-content .table.kx-table-hover > tbody tr:hover td {
  background: color-mix(in srgb, var(--kx-page-tone) 5%, var(--kx-surface));
}
.kx-content .kx-table-hover tbody td a:not(.btn):hover { color: var(--kx-page-tone); }

/* A person's name in a list carries the same initials as the dashboard. */
.kx-person { display: flex; align-items: center; gap: 0.625rem; min-width: 0; }
.kx-person .kx-list-avatar { width: 32px; height: 32px; }
.kx-person-text { min-width: 0; white-space: nowrap; }

@media (max-width: 575.98px) {
  .kx-content[style] .kx-page-header > div:first-child:has(> h1) { min-height: 2.25rem; padding-left: 2.875rem; }
  .kx-content[style] .kx-page-header > div:first-child:has(> h1)::before { width: 2.25rem; height: 2.25rem; border-radius: 11px; font-size: var(--kx-fs-lg); }
}

/* ---- Dashboard figures ---- */

.kx-stat[data-figure] { --tone: var(--kx-tone-slate); }
.kx-stat[data-figure="collected"] { --tone: var(--kx-tone-green); }
.kx-stat[data-figure="outstanding"] { --tone: var(--kx-tone-amber); }
.kx-stat[data-figure="credit"] { --tone: var(--kx-tone-blue); }
.kx-stat[data-figure="deposits"] { --tone: var(--kx-tone-teal); }
.kx-stat[data-figure="billed"] { --tone: var(--kx-tone-indigo); }
.kx-stat[data-figure="overdue"] { --tone: var(--kx-tone-red); }
.kx-stat[data-figure="occupancy"] { --tone: var(--kx-tone-violet); }
.kx-stat[data-figure="landlords_owed"] { --tone: var(--kx-tone-amber); }
.kx-stat[data-figure="payouts"] { --tone: var(--kx-tone-green); }

.kx-app .kx-stat[data-figure] {
  display: flex;
  flex-direction: column;
  padding: 1rem 1.1rem 0.95rem;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
}
.kx-app .kx-stat-open:hover {
  border-color: color-mix(in srgb, var(--tone, var(--kx-border)) 35%, var(--kx-border));
  box-shadow: var(--kx-shadow-md);
  transform: translateY(-1px);
}
.kx-app .kx-stat-head { justify-content: flex-start; gap: 0.6rem; margin-bottom: 0.75rem; }
.kx-app .kx-stat-head > .kx-stat-icon {
  width: 32px;
  height: 32px;
  border-radius: 9px;
  background: color-mix(in srgb, var(--tone, var(--kx-text-2)) 12%, transparent);
  color: var(--tone, var(--kx-text-2));
  font-size: var(--kx-fs-md);
}
.kx-app .kx-stat-label { color: var(--kx-text-2); font-weight: var(--kx-fw-label); }
.kx-stat-info { display: inline-flex; color: var(--kx-text-faint); cursor: help; font-size: var(--kx-fs-xs); }
.kx-stat-info:hover, .kx-stat-info:focus-visible { color: var(--kx-text); outline: none; }
.kx-app .kx-stat-head > .kx-ai-explain { margin-left: auto; }
.kx-app .kx-stat[data-figure] .kx-stat-value { letter-spacing: -0.025em; }
.kx-app .kx-stat[data-figure] .kx-stat-meta { margin-top: auto; padding-top: 0.35rem; }
.kx-app .kx-stat .kx-meter span { background: var(--tone, var(--kx-accent)); }

/* ---- Lists: payments in, rent due ---- */

.kx-list { list-style: none; margin: 0; padding: 0.25rem 0; }
.kx-list > li + li .kx-list-row { border-top: 1px solid var(--kx-border-subtle); }
.kx-list-row {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 0.7rem 1.25rem;
  color: var(--kx-text);
  text-decoration: none;
  transition: background-color 0.12s ease;
}
.kx-list-row:hover { background: var(--kx-surface-2); color: var(--kx-text); }
.kx-list-avatar {
  --tone: var(--kx-tone-indigo);
  display: inline-grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--tone) 13%, transparent);
  color: var(--tone);
  font-size: var(--kx-fs-xs);
  font-weight: var(--kx-fw-strong);
  flex: none;
}
.kx-list-avatar[data-tone="b"] { --tone: var(--kx-tone-teal); }
.kx-list-avatar[data-tone="c"] { --tone: var(--kx-tone-amber); }
.kx-list-avatar[data-tone="d"] { --tone: var(--kx-tone-rose); }
.kx-list-avatar[data-tone="e"] { --tone: var(--kx-tone-blue); }
.kx-list-main { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.kx-list-title { font-weight: var(--kx-fw-label); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kx-list-sub { font-size: var(--kx-fs-xs); color: var(--kx-text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kx-list-end { display: flex; flex-direction: column; align-items: flex-end; gap: 0.25rem; flex: none; }
.kx-list-amount { font-weight: var(--kx-fw-strong); font-variant-numeric: tabular-nums; white-space: nowrap; }
.kx-list-amount.is-in { color: var(--kx-tone-green); }
.kx-list-amount.is-reversed { color: var(--kx-text-faint); text-decoration: line-through; }

.kx-date-chip {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: 10px;
  border: 1px solid var(--kx-border);
  background: var(--kx-surface-2);
  flex: none;
  line-height: 1;
}
.kx-date-chip b { font-size: var(--kx-fs-md); font-weight: var(--kx-fw-strong); }
.kx-date-chip small { margin-top: 0.15rem; font-size: var(--kx-fs-2xs); font-weight: var(--kx-fw-label); letter-spacing: 0.04em; text-transform: uppercase; color: var(--kx-text-muted); }
.kx-date-chip.is-late { border-color: var(--kx-danger-bd); background: var(--kx-danger-bg); color: var(--kx-danger); }
.kx-date-chip.is-late small { color: var(--kx-danger); }

/* ---- Navigation and headers ---- */

.kx-app .kx-sidebar-link.active { position: relative; }
.kx-app .kx-sidebar-link.active::before {
  content: "";
  position: absolute;
  left: -0.6rem;
  top: 22%;
  bottom: 22%;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: var(--kx-brand);
}
.kx-app .kx-sidebar-link.active > .bi { color: var(--kx-brand); }
.kx-app .kx-card-header .kx-section-title { font-weight: var(--kx-fw-strong); }
.kx-app .kx-sidebar-link[data-tone] > i:first-child { color: var(--kx-page-tone); }
.kx-app .kx-sidebar-link[data-tone]:hover { background: color-mix(in srgb, var(--kx-page-tone) 7%, transparent); }
.kx-app .kx-sidebar-link[data-tone].active { background: color-mix(in srgb, var(--kx-page-tone) 12%, transparent); }
.kx-app .kx-sidebar-link[data-tone].active::before { background: var(--kx-page-tone); }

/* ---- Glass for what floats over the page ---- */

body:has(.kx-app) .modal-backdrop.show {
  opacity: 1;
  background: rgba(10, 10, 11, 0.26);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}
[data-theme="dark"] body:has(.kx-app) .modal-backdrop.show { background: rgba(0, 0, 0, 0.5); }
.kx-app ~ .modal .modal-content,
body:has(.kx-app) .modal .modal-content {
  background: color-mix(in srgb, var(--kx-surface) 92%, transparent);
  backdrop-filter: blur(22px) saturate(160%);
  -webkit-backdrop-filter: blur(22px) saturate(160%);
  box-shadow: 0 24px 60px rgba(10, 10, 11, 0.18), var(--kx-shadow-sm);
}
.kx-app .dropdown-menu {
  background: color-mix(in srgb, var(--kx-surface) 90%, transparent);
  backdrop-filter: blur(18px) saturate(160%);
  -webkit-backdrop-filter: blur(18px) saturate(160%);
}

@media (prefers-reduced-motion: reduce) {
  .kx-app .kx-stat, .kx-list-row { transition: none; }
  .kx-app .kx-stat-open:hover { transform: none; }
}

/* Ten figures sit as two even rows of five on a wide screen. */
@media (min-width: 1200px) {
  .kx-app .kx-stat-grid:has(> .kx-stat[data-figure]) { grid-template-columns: repeat(5, minmax(0, 1fr)); }
}
.kx-app .kx-stat[data-figure] .kx-stat-value { font-size: var(--kx-fs-2xl); white-space: nowrap; }
.kx-app .kx-stat-label { min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kx-app .kx-stat-head > .kx-stat-icon, .kx-app .kx-stat-head > .kx-stat-info { flex: none; }
/* Explain sits in the corner and shows on hover, so the label keeps its width. */
.kx-app .kx-stat { position: relative; }
.kx-app .kx-stat-head > .kx-ai-explain {
  position: absolute;
  top: 0.7rem;
  right: 0.7rem;
  opacity: 0;
  background: var(--kx-surface);
  transition: opacity 0.12s ease;
}
.kx-app .kx-stat:hover .kx-ai-explain, .kx-app .kx-stat .kx-ai-explain:focus-visible { opacity: 1; }
@media (hover: none) { .kx-app .kx-stat-head > .kx-ai-explain { opacity: 1; } }

/* ---- Reports index ---- */

[data-tone="green"]  { --tone: var(--kx-tone-green); }
[data-tone="amber"]  { --tone: var(--kx-tone-amber); }
[data-tone="indigo"] { --tone: var(--kx-tone-indigo); }
[data-tone="slate"]  { --tone: var(--kx-tone-slate); }

.kx-reports-hero {
  position: relative;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1.5rem;
  margin-bottom: 2rem;
  padding: 1.75rem 1.75rem 1.5rem;
  border: 1px solid var(--kx-border);
  border-radius: var(--kx-r-xl);
  background:
    radial-gradient(520px 200px at 100% 0%, color-mix(in srgb, var(--kx-brand) 9%, transparent), transparent 70%),
    radial-gradient(420px 180px at 0% 100%, color-mix(in srgb, var(--kx-tone-green) 6%, transparent), transparent 70%),
    var(--kx-surface);
  overflow: hidden;
}
.kx-reports-hero h1 { margin: 0.5rem 0 0.35rem; font-size: var(--kx-fs-4xl); letter-spacing: -0.02em; }
.kx-reports-hero .kx-page-desc { margin: 0; max-width: 34rem; }
.kx-reports-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.2rem 0.65rem;
  border-radius: 999px;
  background: color-mix(in srgb, var(--kx-brand) 10%, transparent);
  color: var(--kx-brand);
  font-size: var(--kx-fs-xs);
  font-weight: var(--kx-fw-strong);
}
.kx-reports-hero-formats { display: flex; gap: 0.5rem; flex: none; }
.kx-reports-hero-formats span {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.4rem 0.8rem;
  border: 1px solid var(--kx-border);
  border-radius: 999px;
  background: var(--kx-surface);
  box-shadow: var(--kx-shadow-xs);
  font-size: var(--kx-fs-sm);
  font-weight: var(--kx-fw-label);
  color: var(--kx-text-2);
}
.kx-reports-hero-formats [data-format="pdf"] .bi { color: #c2362b; }
.kx-reports-hero-formats [data-format="xlsx"] .bi { color: #1d7a45; }

.kx-report-group + .kx-report-group { margin-top: 2.25rem; }
.kx-report-group-head { display: flex; align-items: center; gap: 0.75rem; margin-bottom: 0.875rem; }
.kx-report-group-icon {
  display: inline-grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: color-mix(in srgb, var(--tone) 12%, transparent);
  color: var(--tone);
  font-size: var(--kx-fs-lg);
  flex: none;
}
.kx-report-group-text { min-width: 0; flex: 1; }
.kx-report-group-text h2 { margin: 0; font-size: var(--kx-fs-lg); font-weight: var(--kx-fw-strong); letter-spacing: -0.01em; }
.kx-report-group-text p { margin: 0.1rem 0 0; font-size: var(--kx-fs-sm); color: var(--kx-text-muted); }
.kx-report-group-count {
  min-width: 1.75rem;
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  background: var(--kx-surface-3);
  color: var(--kx-text-2);
  font-size: var(--kx-fs-xs);
  font-weight: var(--kx-fw-strong);
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.kx-report-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0.875rem; }
.kx-report-card {
  position: relative;
  display: flex;
  flex-direction: column;
  padding: 1.15rem 1.15rem 1rem;
  border: 1px solid var(--kx-border);
  border-radius: var(--kx-r-lg);
  background: var(--kx-surface);
  color: var(--kx-text);
  text-decoration: none;
  overflow: hidden;
  transition: border-color 0.18s ease, box-shadow 0.18s ease, transform 0.18s ease;
}
/* A thin bar in the group's colour, drawn in from the left on hover. */
.kx-report-card::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 2px;
  background: var(--tone);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.25s ease;
}
.kx-report-card:hover, .kx-report-card:focus-visible {
  border-color: color-mix(in srgb, var(--tone) 40%, var(--kx-border));
  box-shadow: var(--kx-shadow-md), 0 10px 28px color-mix(in srgb, var(--tone) 10%, transparent);
  transform: translateY(-2px);
  color: var(--kx-text);
}
.kx-report-card:hover::before, .kx-report-card:focus-visible::before { transform: scaleX(1); }
.kx-report-card:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--kx-focus-ring); }
.kx-report-card-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 0.5rem; margin-bottom: 0.875rem; }
.kx-report-icon {
  display: inline-grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 11px;
  background: color-mix(in srgb, var(--tone) 11%, transparent);
  color: var(--tone);
  font-size: var(--kx-fs-xl);
  transition: background-color 0.18s ease, color 0.18s ease;
}
.kx-report-card:hover .kx-report-icon { background: var(--tone); color: #fff; }
.kx-report-lock {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.15rem 0.55rem;
  border: 1px solid var(--kx-border);
  border-radius: 999px;
  font-size: var(--kx-fs-2xs);
  font-weight: var(--kx-fw-label);
  color: var(--kx-text-muted);
}
.kx-report-title { font-size: var(--kx-fs-base); font-weight: var(--kx-fw-strong); letter-spacing: -0.005em; }
.kx-report-desc { margin-top: 0.3rem; font-size: var(--kx-fs-sm); line-height: 1.5; color: var(--kx-text-muted); }
.kx-report-go {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  margin-top: auto;
  padding-top: 0.875rem;
  font-size: var(--kx-fs-xs);
  font-weight: var(--kx-fw-strong);
  color: var(--kx-text-faint);
  transition: color 0.18s ease;
}
.kx-report-go .bi { transition: transform 0.18s ease; }
.kx-report-card:hover .kx-report-go { color: var(--tone); }
.kx-report-card:hover .kx-report-go .bi { transform: translateX(3px); }

@media (max-width: 1199.98px) { .kx-report-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 767.98px) {
  .kx-reports-hero { flex-direction: column; align-items: flex-start; padding: 1.25rem; }
  .kx-reports-hero h1 { font-size: var(--kx-fs-3xl); }
}
@media (max-width: 575.98px) {
  .kx-report-grid { grid-template-columns: minmax(0, 1fr); gap: 0.625rem; }
  /* A row per report: icon left, words right, so fifteen fit in a few screens. */
  .kx-report-card { display: grid; grid-template-columns: 40px minmax(0, 1fr); column-gap: 0.875rem; padding: 0.875rem 1rem; }
  .kx-report-card-top { grid-row: 1 / span 2; margin: 0; }
  .kx-report-title { padding-right: 1.5rem; }
  .kx-report-desc { margin-top: 0.15rem; }
  .kx-report-lock { position: absolute; top: 0.75rem; right: 0.75rem; padding: 0; border: 0; }
  .kx-report-lock span { display: none; }
  .kx-report-go { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  .kx-report-card, .kx-report-card::before, .kx-report-icon, .kx-report-go .bi { transition: none; }
  .kx-report-card:hover { transform: none; }
}

/* ---- Company settings ---- */

[data-tone="teal"]   { --tone: var(--kx-tone-teal); }
[data-tone="violet"] { --tone: var(--kx-tone-violet); }

.kx-settings-hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1.25rem 1.5rem;
  margin-bottom: 1.25rem;
  padding: 1.5rem 1.75rem;
  border: 1px solid var(--kx-border);
  border-radius: var(--kx-r-xl);
  background:
    radial-gradient(560px 220px at 100% 0%, color-mix(in srgb, var(--kx-brand) 10%, transparent), transparent 70%),
    radial-gradient(420px 200px at 0% 100%, color-mix(in srgb, var(--kx-tone-teal) 7%, transparent), transparent 70%),
    var(--kx-surface);
}
.kx-settings-identity { display: flex; align-items: center; gap: 1rem; min-width: 0; }
.kx-settings-identity-text { min-width: 0; }
.kx-settings-logo {
  flex: none;
  width: 56px;
  height: 56px;
  border: 1px solid var(--kx-border);
  border-radius: 14px;
  background: #fff;
  object-fit: contain;
  box-shadow: var(--kx-shadow-sm);
}
.kx-settings-logo.is-initial {
  display: grid;
  place-items: center;
  border: 0;
  background: var(--kx-brand);
  color: #fff;
  font-size: var(--kx-fs-2xl);
  font-weight: var(--kx-fw-display);
}
.kx-settings-eyebrow {
  font-size: var(--kx-fs-xs);
  font-weight: var(--kx-fw-strong);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--kx-brand);
}
.kx-settings-hero h1 { margin: 0.15rem 0 0.2rem; font-size: var(--kx-fs-3xl); letter-spacing: -0.02em; overflow-wrap: anywhere; }
.kx-settings-hero .kx-page-desc { margin: 0; }
.kx-settings-facts { display: flex; flex-wrap: wrap; gap: 0.5rem; margin: 0; max-width: 100%; }
.kx-settings-fact {
  min-width: 7.5rem;
  padding: 0.6rem 0.9rem;
  border: 1px solid var(--kx-border-subtle);
  border-radius: var(--kx-r-lg);
  background: color-mix(in srgb, var(--kx-surface) 70%, transparent);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
.kx-settings-fact dt {
  font-size: var(--kx-fs-2xs);
  font-weight: var(--kx-fw-strong);
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--kx-text-muted);
}
.kx-settings-fact dd { margin: 0.15rem 0 0; font-weight: var(--kx-fw-strong); color: var(--kx-text); white-space: nowrap; }
.kx-settings-fact.is-alert dd { color: var(--kx-tone-amber); }

/* The group switcher floats over the page as it scrolls, so it is glass. */
.kx-settings-tabs {
  position: sticky;
  top: calc(var(--kx-topbar-h) + 0.5rem);
  z-index: 6;
  display: flex;
  gap: 0.25rem;
  width: fit-content;
  max-width: 100%;
  margin: 0 0 1.5rem;
  padding: 0.3rem;
  border: 1px solid var(--kx-border);
  border-radius: 999px;
  background: color-mix(in srgb, var(--kx-surface) 72%, transparent);
  backdrop-filter: blur(16px) saturate(160%);
  -webkit-backdrop-filter: blur(16px) saturate(160%);
  box-shadow: var(--kx-shadow-sm);
  overflow-x: auto;
  scrollbar-width: none;
}
.kx-settings-tabs::-webkit-scrollbar { display: none; }
.kx-settings-tabs[hidden] { display: none; }
.kx-settings-tab {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  flex: none;
  padding: 0.45rem 0.95rem;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--kx-text-2);
  font-size: var(--kx-fs-sm);
  font-weight: var(--kx-fw-label);
  white-space: nowrap;
  transition: background-color 0.15s ease, color 0.15s ease;
}
.kx-settings-tab:hover { background: var(--kx-surface-3); color: var(--kx-text); }
.kx-settings-tab[aria-selected="true"] { background: var(--kx-text); color: var(--kx-surface); box-shadow: var(--kx-shadow-sm); }
.kx-settings-tab:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--kx-focus-ring); }

.kx-settings-panel + .kx-settings-panel { margin-top: 2.5rem; }
.kx-settings-panel[hidden] { display: none; }
.kx-settings.is-tabbed .kx-settings-panel { animation: kx-settings-in 0.25s ease; }
.kx-settings-panel-head { display: flex; align-items: center; gap: 0.85rem; margin-bottom: 1rem; }
.kx-settings-panel-icon {
  display: inline-grid;
  place-items: center;
  flex: none;
  width: 40px;
  height: 40px;
  border-radius: 11px;
  background: color-mix(in srgb, var(--tone) 12%, transparent);
  color: var(--tone);
  font-size: var(--kx-fs-xl);
}
.kx-settings-panel-head h2 { margin: 0; font-size: var(--kx-fs-xl); letter-spacing: -0.01em; }
.kx-settings-panel-head p { margin: 0.1rem 0 0; font-size: var(--kx-fs-sm); color: var(--kx-text-muted); }

.kx-settings-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 1rem; align-items: start; max-width: 64rem; }
.kx-settings-grid > .kx-card { margin-bottom: 0 !important; }
.kx-settings-grid.is-pair, .kx-settings-grid.is-tiles { max-width: none; }
.kx-settings-grid.is-tiles { grid-template-columns: repeat(auto-fill, minmax(min(100%, 22rem), 1fr)); }
.kx-settings-grid.is-single { max-width: 46rem; }
@media (min-width: 1400px) {
  .kx-settings-grid.is-pair { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kx-settings-grid.is-pair > #section-account { grid-column: 1 / -1; }
}

.kx-settings .kx-card { border-radius: var(--kx-r-xl); transition: border-color 0.2s ease, box-shadow 0.2s ease; }
/* The section being edited lifts a little, in its group's colour. */
.kx-settings .kx-card:focus-within {
  border-color: color-mix(in srgb, var(--tone, var(--kx-border)) 35%, var(--kx-border));
  box-shadow: var(--kx-shadow-md);
}
.kx-settings-card-title { display: inline-flex; align-items: center; gap: 0.6rem; min-width: 0; }
.kx-settings-card-icon {
  display: inline-grid;
  place-items: center;
  flex: none;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: color-mix(in srgb, var(--tone, var(--kx-text-2)) 12%, transparent);
  color: var(--tone, var(--kx-text-2));
  font-size: var(--kx-fs-md);
}

@keyframes kx-settings-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

@media (max-width: 767.98px) {
  .kx-settings-hero { padding: 1.1rem; }
  .kx-settings-hero h1 { font-size: var(--kx-fs-2xl); }
  .kx-settings-logo { width: 44px; height: 44px; border-radius: 12px; }
  .kx-settings-facts { width: 100%; }
  .kx-settings-fact { min-width: 0; }
  .kx-settings-fact dd { white-space: normal; }
  .kx-settings-tabs { width: 100%; border-radius: var(--kx-r-lg); }
}
@media (prefers-reduced-motion: reduce) {
  .kx-settings.is-tabbed .kx-settings-panel { animation: none; }
  .kx-settings-tab, .kx-settings .kx-card { transition: none; }
}

/* Clear of the topbar and the sticky tabs when a link lands on a section. */
.kx-settings [id^="section-"], .kx-settings #subscription { scroll-margin-top: calc(var(--kx-topbar-h) + 4.75rem); }
@media (max-width: 767.98px) {
  .kx-settings-identity { align-items: flex-start; }
  .kx-settings-hero .kx-page-desc { font-size: var(--kx-fs-sm); }
  /* The facts become one list of label and value rows. */
  .kx-settings-facts {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 0;
    border: 1px solid var(--kx-border-subtle);
    border-radius: var(--kx-r-lg);
    background: color-mix(in srgb, var(--kx-surface) 70%, transparent);
    overflow: hidden;
  }
  .kx-settings-fact {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.55rem 0.85rem;
    border: 0;
    border-radius: 0;
    background: none;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
  }
  .kx-settings-fact + .kx-settings-fact { border-top: 1px solid var(--kx-border-subtle); }
  .kx-settings-fact dd { margin: 0; text-align: right; }
}

/* A card too narrow for a form's columns stacks them, wherever the card sits:
   in the three-across tiles the activity form squeezed its select to a stub. */
.kx-settings .kx-card { container-type: inline-size; }
@container (max-width: 560px) {
  .kx-settings .kx-card .row > [class*="col-"] { flex: 0 0 100%; width: 100%; max-width: 100%; }
}

/* --------------------------------------------------------------------------
   Tenant and landlord access, on staff screens: list selection, switch rows,
   the access card, the share page and the printed slip.
   -------------------------------------------------------------------------- */

/* A selection box for a table row. Not a .form-check-input: that one is
   pulled left to sit inside a labelled row, which clips it in a table cell. */
.kx-select {
  appearance: none;
  -webkit-appearance: none;
  display: inline-grid;
  place-content: center;
  width: 1.125rem;
  height: 1.125rem;
  margin: 0;
  vertical-align: middle;
  border: 1.5px solid var(--kx-border-strong);
  border-radius: 5px;
  background: var(--kx-surface);
  cursor: pointer;
  transition: background-color 0.12s ease, border-color 0.12s ease, box-shadow 0.12s ease;
}
.kx-select::before {
  content: "";
  width: 0.625rem;
  height: 0.625rem;
  transform: scale(0);
  transition: transform 0.12s ease;
  background: var(--kx-accent-text);
  clip-path: polygon(14% 44%, 0 65%, 40% 100%, 100% 23%, 84% 9%, 39% 70%);
}
.kx-select:hover { border-color: var(--kx-text-muted); }
.kx-select:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--kx-focus-ring); }
.kx-select:checked,
.kx-select:indeterminate { background: var(--kx-accent); border-color: var(--kx-accent); }
.kx-select:checked::before { transform: scale(1); }
.kx-select:indeterminate::before { transform: scale(1); clip-path: inset(40% 10% 40% 10%); }
.kx-select:disabled { opacity: 0.4; cursor: default; }
.kx-check-cell { width: 3rem; text-align: center; }
.kx-card > .kx-table-wrap > .table > thead th.kx-check-cell,
.kx-card > .kx-table-wrap > .table > tbody td.kx-check-cell { padding-left: 1.25rem; padding-right: 0.25rem; }
.table > tbody tr.is-selected td { background: color-mix(in srgb, var(--kx-page-tone, var(--kx-accent)) 6%, var(--kx-surface)); }

/* The selection bar: hidden until something is ticked, then it floats. */
.kx-bulkbar {
  position: fixed;
  left: 50%;
  bottom: calc(1.25rem + env(safe-area-inset-bottom));
  z-index: 1030;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4375rem 0.4375rem 0.4375rem 1rem;
  border: 1px solid var(--kx-border);
  border-radius: 14px;
  background: color-mix(in srgb, var(--kx-surface) 86%, transparent);
  backdrop-filter: blur(20px) saturate(160%);
  -webkit-backdrop-filter: blur(20px) saturate(160%);
  box-shadow: 0 16px 40px rgba(10, 10, 11, 0.16), var(--kx-shadow-sm);
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 12px);
  transition: opacity 0.16s ease, transform 0.16s ease;
}
.kx-bulkbar.is-open { opacity: 1; pointer-events: auto; transform: translate(-50%, 0); }
.kx-bulkbar-count { font-size: var(--kx-fs-md); color: var(--kx-text-2); white-space: nowrap; margin-right: 0.25rem; }
.kx-bulkbar-count b { color: var(--kx-text); font-variant-numeric: tabular-nums; }
html:not(.kx-js) .kx-bulkbar { position: static; opacity: 1; pointer-events: auto; transform: none; margin: 1rem; }
@media (max-width: 575.98px) {
  .kx-bulkbar { left: 0.75rem; right: 0.75rem; transform: translateY(12px); }
  /* Above the assistant's Ask button, which sits in the same corner. */
  body:has(.kx-ai-fab) .kx-bulkbar { bottom: calc(5.25rem + env(safe-area-inset-bottom)); }
  .kx-bulkbar.is-open { transform: none; }
  .kx-bulkbar .btn-kx-primary { margin-left: auto; }
}

/* A switch. Used for on and off settings, one per row. */
.kx-switch {
  appearance: none;
  -webkit-appearance: none;
  position: relative;
  flex: none;
  width: 2.25rem;
  height: 1.3125rem;
  margin: 0;
  border-radius: 999px;
  background: var(--kx-border-strong);
  cursor: pointer;
  transition: background-color 0.15s ease;
}
.kx-switch::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: calc(1.3125rem - 4px);
  height: calc(1.3125rem - 4px);
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 2px rgba(10, 10, 11, 0.24);
  transition: transform 0.15s ease;
}
.kx-switch:checked { background: var(--kx-tone-green); }
.kx-switch:checked::after { transform: translateX(0.9375rem); }
.kx-switch:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--kx-focus-ring); }

/* A setting per row: what it is, then its switch. */
.kx-toggle-list { list-style: none; margin: 0; padding: 0; border: 1px solid var(--kx-border); border-radius: var(--kx-r-lg); overflow: hidden; }
.kx-toggle-row { display: flex; align-items: center; gap: 1rem; padding: 0.8125rem 1rem; background: var(--kx-surface); cursor: pointer; }
.kx-toggle-list > li + li .kx-toggle-row { border-top: 1px solid var(--kx-border-subtle); }
.kx-toggle-row:hover { background: var(--kx-surface-2); }
.kx-toggle-text { display: flex; flex-direction: column; gap: 0.125rem; flex: 1; min-width: 0; }
.kx-toggle-title { font-weight: var(--kx-fw-label); font-size: var(--kx-fs-md); color: var(--kx-text); }
.kx-toggle-help { font-size: var(--kx-fs-sm); color: var(--kx-text-muted); }
.kx-toggle-row.is-private .kx-toggle-title::after {
  content: "Personal data";
  margin-left: 0.5rem;
  padding: 0.0625rem 0.4375rem;
  border-radius: 999px;
  background: var(--kx-warning-bg);
  color: var(--kx-warning);
  font-size: var(--kx-fs-2xs);
  font-weight: var(--kx-fw-label);
  vertical-align: 0.1em;
}

/* Presets as a segmented control of radios. */
.kx-segmented-radio input { position: absolute; opacity: 0; pointer-events: none; }
.kx-segmented-radio label {
  display: inline-flex; align-items: center; padding: 0.3125rem 0.75rem; border-radius: var(--kx-r-sm);
  font-size: 0.8125rem; font-weight: var(--kx-fw-label); color: var(--kx-text-2); cursor: pointer; white-space: nowrap;
}
.kx-segmented-radio label:hover { color: var(--kx-text); }
.kx-segmented-radio input:checked + label { background: var(--kx-surface); color: var(--kx-text); box-shadow: var(--kx-shadow-xs); }
[data-theme="dark"] .kx-segmented-radio input:checked + label { background: var(--kx-surface-3); }
.kx-segmented-radio input:focus-visible + label { box-shadow: 0 0 0 3px var(--kx-focus-ring); }

/* ---- The Portal access card on a tenant or landlord page ---- */

.kx-access-intro { display: flex; align-items: flex-start; gap: 0.875rem; }
.kx-access-icon {
  display: inline-grid; place-items: center; width: 40px; height: 40px; flex: none; border-radius: 11px;
  background: color-mix(in srgb, var(--kx-page-tone, var(--kx-tone-blue)) 12%, transparent);
  color: var(--kx-page-tone, var(--kx-tone-blue)); font-size: 1.125rem;
}
.kx-access-intro p { margin: 0 0 0.75rem; color: var(--kx-text-2); font-size: var(--kx-fs-md); }
.kx-access-facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr)); gap: 0.75rem 1.25rem; margin: 0 0 1rem; }
.kx-access-facts dt { font-size: var(--kx-fs-xs); font-weight: var(--kx-fw-label); color: var(--kx-text-muted); margin-bottom: 0.125rem; }
.kx-access-facts dd { margin: 0; font-weight: var(--kx-fw-label); font-size: var(--kx-fs-md); font-variant-numeric: tabular-nums; }
.kx-access-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.kx-access-actions form { margin: 0; }
.kx-access-note {
  display: flex; gap: 0.5rem; align-items: flex-start; margin: 0 0 1rem; padding: 0.625rem 0.75rem;
  border-radius: var(--kx-r-md); background: var(--kx-warning-bg); color: var(--kx-warning); font-size: var(--kx-fs-sm);
}

/* A disclosure that matches the cards it sits in. */
.kx-disclosure { margin-top: 1rem; border-top: 1px solid var(--kx-border-subtle); }
.kx-disclosure > summary {
  display: flex; align-items: center; justify-content: space-between; gap: 0.5rem;
  padding: 0.75rem 0 0.25rem; cursor: pointer; list-style: none;
  font-size: var(--kx-fs-sm); font-weight: var(--kx-fw-label); color: var(--kx-text-2);
}
.kx-disclosure > summary::-webkit-details-marker { display: none; }
.kx-disclosure > summary::after { content: "\F282"; font-family: bootstrap-icons; font-size: 0.75rem; color: var(--kx-text-faint); transition: transform 0.15s ease; }
.kx-disclosure[open] > summary::after { transform: rotate(180deg); }
.kx-disclosure > summary:hover { color: var(--kx-text); }
.kx-disclosure-body { padding-top: 0.5rem; }

/* Recent account events, as a short timeline. */
.kx-timeline { list-style: none; margin: 0; padding: 0; }
.kx-timeline li { position: relative; padding: 0 0 0.75rem 1.125rem; font-size: var(--kx-fs-sm); }
.kx-timeline li::before { content: ""; position: absolute; left: 0; top: 0.4rem; width: 7px; height: 7px; border-radius: 50%; background: var(--kx-border-strong); }
.kx-timeline li::after { content: ""; position: absolute; left: 3px; top: 0.95rem; bottom: 0; width: 1px; background: var(--kx-border); }
.kx-timeline li:last-child { padding-bottom: 0; }
.kx-timeline li:last-child::after { display: none; }
.kx-timeline time { display: block; font-size: var(--kx-fs-xs); color: var(--kx-text-muted); }

/* ---- The share page ---- */

.kx-share-grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(min(100%, 34rem), 1fr)); }
.kx-share-person { display: flex; align-items: center; gap: 0.75rem; min-width: 0; }
.kx-share-person .kx-list-avatar { width: 36px; height: 36px; }
.kx-share-name { font-weight: var(--kx-fw-strong); }
.kx-share-sub { font-size: var(--kx-fs-xs); color: var(--kx-text-muted); font-variant-numeric: tabular-nums; }
.kx-share-field { display: flex; gap: 0.5rem; margin-bottom: 1rem; }
.kx-share-field .form-control { font-family: var(--kx-font-mono); font-size: var(--kx-fs-sm); background: var(--kx-surface-2); }
.kx-share-label { display: block; margin-bottom: 0.375rem; font-size: var(--kx-fs-xs); font-weight: var(--kx-fw-label); color: var(--kx-text-muted); }
.kx-share-secret { font-family: var(--kx-font-mono); font-size: var(--kx-fs-2xl); font-weight: var(--kx-fw-strong); letter-spacing: 0.06em; }
.kx-share-send { display: grid; grid-template-columns: repeat(auto-fit, minmax(8.5rem, 1fr)); gap: 0.5rem; }
.kx-share-send .btn { justify-content: center; }
.kx-share-send .bi-whatsapp { color: #25d366; }
.kx-share-hint { margin: 0.75rem 0 0; font-size: var(--kx-fs-sm); color: var(--kx-text-muted); }

/* The slip: a piece of paper, in both themes, because it is printed. */
.kx-slip {
  margin-top: 1.25rem;
  padding: 1.125rem 1.25rem;
  border: 1px dashed #b8b8bf;
  border-radius: var(--kx-r-md);
  background: #fff;
  color: #0a0a0b;
  break-inside: avoid;
}
.kx-slip-head { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; padding-bottom: 0.75rem; margin-bottom: 0.875rem; border-bottom: 1px solid #e6e6ea; }
.kx-slip-head strong { font-size: 1rem; letter-spacing: -0.01em; }
.kx-slip-head span { font-size: 0.75rem; color: #5b5b63; text-transform: uppercase; letter-spacing: 0.06em; }
.kx-slip-body { display: flex; gap: 1.25rem; align-items: flex-start; }
.kx-slip-qr svg { display: block; width: 8.25rem; height: 8.25rem; }
.kx-slip-text p { margin: 0 0 0.5rem; font-size: 0.8125rem; color: #3a3a40; }
.kx-slip-text .kx-mono { font-size: 0.8125rem; color: #0a0a0b; font-weight: 600; }
.kx-slip-name { font-size: 1rem !important; font-weight: 640; color: #0a0a0b !important; }
.kx-slip-number { margin-top: 0.25rem !important; font-family: var(--kx-font-mono); font-size: var(--kx-fs-2xl) !important; font-weight: 700; letter-spacing: 0.08em; color: #0a0a0b !important; }
.kx-slip-label { display: block; font-size: 0.6875rem; text-transform: uppercase; letter-spacing: 0.06em; color: #5b5b63; }

@media (max-width: 480px) {
  .kx-slip-body { flex-direction: column; }
  .kx-share-field { flex-direction: column; }
}

@media print {
  .kx-share-card { border: 0 !important; box-shadow: none !important; }
  .kx-share-card > .kx-card-header { display: none !important; }
  .kx-share-card > .kx-card-body { padding: 0 !important; }
  .kx-share-grid { display: block; }
  .kx-slip { margin: 0 0 8mm; }
  .kx-back-link, .kx-bulkbar { display: none !important; }
}

.kx-settings-subhead { margin: 0 0 0.625rem; font-size: var(--kx-fs-md); font-weight: var(--kx-fw-strong); color: var(--kx-text); }
.kx-settings-subhead-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.625rem 1rem; margin-bottom: 0.875rem; }
html:not(.kx-js) [data-portal-presets] { display: none; }
.kx-stat-of { font-size: 0.55em; font-weight: var(--kx-fw-label); color: var(--kx-text-muted); letter-spacing: 0; }
.kx-input-suffix { max-width: 12rem; }

.kx-readout {
  white-space: pre-line; padding: 0.625rem 0.75rem; border: 1px solid var(--kx-border); border-radius: var(--kx-r-md);
  background: var(--kx-surface-2); font-size: var(--kx-fs-md); line-height: 1.55; color: var(--kx-text);
}

/* ---- Choices drawn as tiles: payment method, type of repair, who sees a notice ---- */

.kx-choice-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(9.5rem, 1fr)); gap: 0.5rem; }
.kx-choice-grid.is-compact { grid-template-columns: repeat(auto-fill, minmax(13rem, 1fr)); }
.kx-choice-tile {
  --tone: var(--kx-accent);
  position: relative; display: flex; align-items: center; gap: 0.625rem; min-height: 3.25rem;
  padding: 0.625rem 0.75rem; border: 1px solid var(--kx-border); border-radius: var(--kx-r-md);
  background: var(--kx-surface); cursor: pointer;
  transition: border-color 0.12s ease, background-color 0.12s ease, box-shadow 0.12s ease;
}
.kx-choice-tile:hover { border-color: var(--kx-border-strong); }
.kx-choice-tile input { position: absolute; opacity: 0; pointer-events: none; }
.kx-choice-icon {
  display: inline-grid; place-items: center; width: 30px; height: 30px; flex: none; border-radius: 8px;
  background: var(--kx-surface-3); color: var(--kx-text-muted); font-size: 0.9375rem;
  transition: background-color 0.12s ease, color 0.12s ease;
}
.kx-choice-text { display: flex; flex-direction: column; min-width: 0; }
.kx-choice-label { font-size: var(--kx-fs-md); font-weight: var(--kx-fw-label); color: var(--kx-text); line-height: 1.25; }
.kx-choice-note { font-size: var(--kx-fs-xs); color: var(--kx-text-muted); line-height: 1.3; }
.kx-choice-tile:has(input:checked) {
  border-color: var(--tone); background: color-mix(in srgb, var(--tone) 7%, var(--kx-surface));
  box-shadow: 0 0 0 1px var(--tone);
}
.kx-choice-tile:has(input:checked) .kx-choice-icon { background: var(--tone); color: var(--kx-surface); }
.kx-choice-tile:has(input:focus-visible) { box-shadow: 0 0 0 3px var(--kx-focus-ring); }
.kx-choice-tile[data-tone="teal"] { --tone: var(--kx-tone-teal); }
.kx-choice-tile[data-tone="red"] { --tone: var(--kx-tone-red); }

/* ---- A request as a conversation ---- */

.kx-thread { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.875rem; }
.kx-msg {
  max-width: min(36rem, 88%); padding: 0.75rem 0.875rem; border-radius: 14px 14px 14px 4px;
  background: var(--kx-surface-2); border: 1px solid var(--kx-border);
}
.kx-msg.is-mine {
  align-self: flex-end; border-radius: 14px 14px 4px 14px;
  background: color-mix(in srgb, var(--kx-accent) 8%, var(--kx-surface));
  border-color: color-mix(in srgb, var(--kx-accent) 22%, var(--kx-border));
}
.kx-msg.is-internal {
  background: color-mix(in srgb, var(--kx-tone-amber) 8%, var(--kx-surface)); border-style: dashed;
  border-color: color-mix(in srgb, var(--kx-tone-amber) 45%, var(--kx-border));
}
.kx-msg-head { display: flex; flex-wrap: wrap; align-items: center; gap: 0.25rem 0.5rem; margin-bottom: 0.25rem; font-size: var(--kx-fs-sm); }
.kx-msg-head strong { font-weight: var(--kx-fw-label); color: var(--kx-text); }
.kx-msg-head time { color: var(--kx-text-faint); font-size: var(--kx-fs-xs); margin-left: auto; }
.kx-msg-body { font-size: var(--kx-fs-md); color: var(--kx-text); line-height: 1.55; overflow-wrap: anywhere; }
.kx-msg-foot { margin-top: 0.375rem; font-size: var(--kx-fs-xs); color: var(--kx-text-muted); }
.kx-thread-event { align-self: center; font-size: var(--kx-fs-xs); color: var(--kx-text-muted); }
.kx-thread-event span {
  display: inline-flex; align-items: center; gap: 0.375rem; padding: 0.25rem 0.75rem;
  border-radius: 999px; background: var(--kx-surface-3);
}
.kx-thread-reply, .kx-thread-compose { border-top: 1px solid var(--kx-border); padding: 0.875rem 1.25rem 1rem; }
.kx-thread-reply { display: flex; align-items: flex-end; gap: 0.5rem; }
.kx-thread-reply textarea { resize: vertical; min-height: 2.75rem; }
.kx-thread-reply .btn { flex: none; height: 2.75rem; width: 2.75rem; padding: 0; justify-content: center; }
.kx-thread-compose textarea.is-note { border-style: dashed; border-color: color-mix(in srgb, var(--kx-tone-amber) 55%, var(--kx-border)); }
.kx-thread-compose-foot { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.75rem; margin-top: 0.75rem; }
.kx-thread-status { display: flex; align-items: center; gap: 0.5rem; }
.kx-thread-status .form-select { width: auto; }
.kx-thread-closed { margin: 0; padding: 0.875rem 1.25rem; border-top: 1px solid var(--kx-border); font-size: var(--kx-fs-sm); color: var(--kx-text-muted); }

/* ---- Waiting for you, on the dashboard and in lists ---- */

.kx-waiting-count {
  display: inline-grid; place-items: center; min-width: 36px; height: 36px; padding: 0 0.5rem; flex: none;
  border-radius: 10px; background: color-mix(in srgb, var(--tone) 14%, transparent); color: var(--tone);
  font-weight: var(--kx-fw-strong); font-variant-numeric: tabular-nums;
}
.kx-waiting-note { margin-top: 0.25rem; font-size: var(--kx-fs-xs); font-weight: var(--kx-fw-label); color: var(--kx-tone-amber); white-space: nowrap; }
.kx-list-chevron { flex: none; color: var(--kx-text-faint); }
.kx-list-row:hover .kx-list-chevron { color: var(--kx-text-muted); }
/* A reference or receipt number in a detail list is read and matched, so it keeps the text's size. */
.kx-dl dd .kx-mono, .kx-feed .kx-mono { font-size: inherit; letter-spacing: 0.01em; }
.kx-notice-text { font-size: var(--kx-fs-md); line-height: 1.65; color: var(--kx-text); overflow-wrap: anywhere; }
.kx-notice-text p:last-child { margin-bottom: 0; }

@media (max-width: 575.98px) {
  .kx-choice-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kx-choice-grid.is-compact { grid-template-columns: 1fr; }
  .kx-msg { max-width: 92%; }
}

/* ==========================================================================
   Platform team: roles, admins, two-step sign-in
   ========================================================================== */

.kx-role-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.35rem 0.75rem;
  border-radius: 999px;
  border: 1px solid var(--kx-border);
  background: var(--kx-surface-2);
  font-size: var(--kx-fs-sm);
  font-weight: var(--kx-fw-label);
  color: var(--kx-text);
  white-space: nowrap;
}
.kx-role-chip .bi { color: var(--kx-tone-indigo); }
.kx-role-chip.is-super .bi { color: var(--kx-tone-rose); }

/* Role editor: one card per console area, actions as switches. */
.kx-perm-summary {
  display: flex;
  align-items: center;
  gap: 0.75rem 1rem;
  flex-wrap: wrap;
  padding: 0.9rem 1.1rem;
  margin-bottom: 1rem;
  border: 1px solid var(--kx-border);
  border-radius: var(--kx-r-lg);
  background: var(--kx-surface);
}
.kx-perm-summary-count { font-size: var(--kx-fs-2xl); font-weight: var(--kx-fw-strong); font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }
.kx-perm-summary-label { font-size: var(--kx-fs-sm); color: var(--kx-text-muted); }
.kx-perm-summary-meter { flex: 1 1 10rem; height: 6px; border-radius: 999px; background: var(--kx-surface-3); overflow: hidden; }
.kx-perm-summary-meter span { display: block; height: 100%; width: 0; background: var(--kx-tone-indigo); border-radius: inherit; transition: width 0.2s ease; }
.kx-perm-summary-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; }

.kx-perm-areas { display: grid; gap: 0.85rem; grid-template-columns: repeat(auto-fill, minmax(min(100%, 17rem), 1fr)); }
.kx-perm-area {
  --tone: var(--kx-tone-slate);
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding: 1rem;
  border: 1px solid var(--kx-border);
  border-radius: var(--kx-r-lg);
  background: var(--kx-surface);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.kx-perm-area.is-on {
  border-color: color-mix(in srgb, var(--tone) 45%, var(--kx-border));
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--tone) 9%, transparent);
}
.kx-perm-area-head { display: flex; align-items: center; gap: 0.65rem; }
.kx-perm-area-icon {
  display: inline-grid;
  place-items: center;
  flex: none;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: color-mix(in srgb, var(--tone) 13%, transparent);
  color: var(--tone);
}
.kx-perm-area-title { font-weight: var(--kx-fw-strong); }
.kx-perm-area-state { margin-left: auto; font-size: var(--kx-fs-xs); color: var(--kx-text-faint); white-space: nowrap; }
.kx-perm-area.is-on .kx-perm-area-state { color: var(--tone); font-weight: var(--kx-fw-label); }
.kx-perm-toggles { display: flex; flex-direction: column; gap: 0.4rem; }
.kx-perm-toggle {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  min-height: 44px;
  margin: 0;
  padding: 0.45rem 0.7rem;
  border: 1px solid var(--kx-border-subtle);
  border-radius: var(--kx-r-md);
  font-size: var(--kx-fs-sm);
  cursor: pointer;
  user-select: none;
  transition: background-color 0.12s ease, border-color 0.12s ease;
}
.kx-perm-toggle:hover { background: var(--kx-surface-2); }
.kx-perm-toggle input { position: absolute; opacity: 0; width: 1px; height: 1px; pointer-events: none; }
.kx-perm-switch {
  position: relative;
  flex: none;
  width: 34px;
  height: 20px;
  border-radius: 999px;
  background: var(--kx-surface-3);
  border: 1px solid var(--kx-border-strong);
  transition: background-color 0.15s ease, border-color 0.15s ease;
}
.kx-perm-switch::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 14px;
  height: 14px;
  border-radius: 999px;
  background: #fff;
  box-shadow: var(--kx-shadow-xs);
  transition: transform 0.15s ease;
}
.kx-perm-toggle input:checked + .kx-perm-switch { background: var(--tone); border-color: var(--tone); }
.kx-perm-toggle input:checked + .kx-perm-switch::after { transform: translateX(14px); }
.kx-perm-toggle input:focus-visible + .kx-perm-switch { box-shadow: 0 0 0 3px var(--kx-focus-ring); }
.kx-perm-toggle:has(input:checked) {
  border-color: color-mix(in srgb, var(--tone) 30%, var(--kx-border-subtle));
  background: color-mix(in srgb, var(--tone) 5%, transparent);
}
.kx-perm-toggle-label { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 0.1rem; line-height: 1.35; }
.kx-perm-sensitive {
  align-self: flex-start;
  color: var(--kx-warning);
  font-size: var(--kx-fs-xs);
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  white-space: nowrap;
}

/* Roles page */
.kx-role-card { display: flex; flex-direction: column; height: 100%; }
.kx-role-card .kx-card-body { display: flex; flex-direction: column; gap: 0.85rem; flex: 1; }
.kx-role-desc { margin: 0; color: var(--kx-text-muted); font-size: var(--kx-fs-sm); }
.kx-role-areas { display: flex; flex-wrap: wrap; gap: 0.35rem; }
.kx-role-area {
  --tone: var(--kx-tone-slate);
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  font-size: var(--kx-fs-xs);
  background: color-mix(in srgb, var(--tone) 11%, transparent);
  color: var(--tone);
  font-weight: var(--kx-fw-label);
}
.kx-role-card-foot {
  margin-top: auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  flex-wrap: wrap;
}
.kx-role-card.is-super { border-color: color-mix(in srgb, var(--kx-tone-rose) 35%, var(--kx-border)); }

/* Admin profile */
.kx-team-hero { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }
.kx-team-hero .kx-list-avatar { width: 56px; height: 56px; font-size: var(--kx-fs-lg); }
.kx-team-hero-text { min-width: 0; flex: 1 1 12rem; }
.kx-team-hero-text h2 { margin: 0; font-size: var(--kx-fs-xl); font-weight: var(--kx-fw-strong); overflow-wrap: anywhere; }
.kx-team-hero-text p { margin: 0.15rem 0 0; color: var(--kx-text-muted); font-size: var(--kx-fs-sm); overflow-wrap: anywhere; }
.kx-team-badges { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.kx-action-row { display: flex; flex-direction: column; gap: 0.6rem; padding: 1rem 0; border-top: 1px solid var(--kx-border-subtle); }
.kx-action-row:first-child { border-top: 0; padding-top: 0; }
.kx-action-row:last-child { padding-bottom: 0; }
.kx-action-row h3 { margin: 0; font-size: 0.9375rem; font-weight: var(--kx-fw-strong); }
.kx-action-row p { margin: 0; color: var(--kx-text-muted); font-size: var(--kx-fs-sm); }
.kx-action-row form { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: flex-end; }
.kx-action-row form .kx-field { flex: 1 1 14rem; margin: 0; }
.kx-action-row form .btn { flex: none; }
.kx-action-row.is-danger h3 { color: var(--kx-danger); }

/* Two-step sign-in */
.kx-2fa-steps { list-style: none; counter-reset: step; margin: 0 0 1.25rem; padding: 0; display: flex; flex-direction: column; gap: 0.85rem; }
.kx-2fa-steps li { counter-increment: step; display: flex; gap: 0.75rem; font-size: var(--kx-fs-sm); color: var(--kx-text-2); line-height: 1.5; }
.kx-2fa-steps li::before {
  content: counter(step);
  flex: none;
  display: inline-grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 999px;
  font-size: var(--kx-fs-xs);
  font-weight: var(--kx-fw-strong);
  background: var(--kx-surface-3);
  color: var(--kx-text);
}
.kx-qr {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  padding: 1.1rem;
  margin-bottom: 1.25rem;
  border: 1px solid var(--kx-border);
  border-radius: var(--kx-r-lg);
  background: var(--kx-surface-2);
}
.kx-qr-image { padding: 0.5rem; border-radius: var(--kx-r-md); background: #fff; line-height: 0; box-shadow: var(--kx-shadow-sm); }
.kx-qr-image svg { width: min(200px, 60vw); height: auto; }
.kx-qr details { width: 100%; }
.kx-qr summary { font-size: var(--kx-fs-sm); cursor: pointer; color: var(--kx-text-muted); text-align: center; }
.kx-mono-key {
  margin-top: 0.5rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: var(--kx-fs-sm);
  letter-spacing: 0.06em;
  text-align: center;
  overflow-wrap: anywhere;
  color: var(--kx-text);
}
.kx-code-input.form-control {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 1.5rem;
  letter-spacing: 0.3em;
  text-align: center;
  font-variant-numeric: tabular-nums;
  padding-top: 0.6rem;
  padding-bottom: 0.6rem;
}
.kx-2fa-badge {
  display: inline-grid;
  place-items: center;
  width: 48px;
  height: 48px;
  margin-bottom: 0.75rem;
  border-radius: 14px;
  background: color-mix(in srgb, var(--kx-tone-teal) 14%, transparent);
  color: var(--kx-tone-teal);
  font-size: var(--kx-fs-2xl);
}
.kx-2fa-badge.is-off { background: var(--kx-warning-bg); color: var(--kx-warning); }
.kx-backup-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.5rem; margin: 0 0 1rem; padding: 0; list-style: none; }
.kx-backup-grid li {
  padding: 0.6rem 0.5rem;
  border: 1px dashed var(--kx-border-strong);
  border-radius: var(--kx-r-md);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 1rem;
  letter-spacing: 0.08em;
  text-align: center;
  background: var(--kx-surface-2);
}
.kx-security-status { display: flex; align-items: center; gap: 0.85rem; }
.kx-security-status .kx-2fa-badge { margin: 0; flex: none; }
@media (min-width: 576px) { .kx-backup-grid { grid-template-columns: repeat(2, 11rem); } }
@media print {
  .kx-app .kx-sidebar, .kx-app .kx-topbar, .kx-no-print { display: none !important; }
}

/* Tones for the team parts (declared after their defaults, so they win). */
:is(.kx-perm-area, .kx-role-area)[data-tone="indigo"] { --tone: var(--kx-tone-indigo); }
:is(.kx-perm-area, .kx-role-area)[data-tone="teal"] { --tone: var(--kx-tone-teal); }
:is(.kx-perm-area, .kx-role-area)[data-tone="blue"] { --tone: var(--kx-tone-blue); }
:is(.kx-perm-area, .kx-role-area)[data-tone="green"] { --tone: var(--kx-tone-green); }
:is(.kx-perm-area, .kx-role-area)[data-tone="violet"] { --tone: var(--kx-tone-violet); }
:is(.kx-perm-area, .kx-role-area)[data-tone="amber"] { --tone: var(--kx-tone-amber); }
:is(.kx-perm-area, .kx-role-area)[data-tone="slate"] { --tone: var(--kx-tone-slate); }
:is(.kx-perm-area, .kx-role-area)[data-tone="rose"] { --tone: var(--kx-tone-rose); }
:is(.kx-perm-area, .kx-role-area)[data-tone="red"] { --tone: var(--kx-tone-red); }
.kx-role-card.is-super .kx-section-title .bi { color: var(--kx-tone-rose); margin-right: 0.25rem; }
.kx-auth-signout { background: none; border: 0; padding: 0; color: var(--kx-text-muted); font-size: var(--kx-fs-sm); text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }
.kx-auth-signout:hover { color: var(--kx-text); }

/* Console, Public site: the WhatsApp chat topics editor. */
.kx-topic-list { display: grid; gap: 0.75rem; }
.kx-topic-row {
  margin: 0;
  padding: 0.875rem 1rem;
  border: 1px solid var(--kx-border);
  border-radius: var(--kx-r-md);
  background: var(--kx-surface);
  min-width: 0;
}
.kx-topic-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 1.25rem;
  margin-top: 0.75rem;
  font-size: 0.8125rem;
  color: var(--kx-text-muted);
}
.kx-topic-order { display: inline-flex; align-items: center; gap: 0.5rem; margin: 0; }
.kx-topic-order .form-control { width: 4.5rem; }
.kx-topic-check { display: inline-flex; align-items: center; gap: 0.5rem; margin: 0; cursor: pointer; }
.kx-topic-remove { margin-left: auto; }
.kx-topic-remove:has(input:checked) { color: var(--kx-danger); }
.kx-topic-row:has(.kx-topic-remove input:checked) { opacity: 0.6; }

/* Console plan picker (Approve, Assign a plan): one card per plan. */
.kx-plan-choices { display: grid; gap: 0.75rem; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 768px) { .kx-plan-choices { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.kx-plan-choice {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 1rem 1.125rem;
  border: 1px solid var(--kx-border);
  border-radius: var(--kx-r-md);
  background: var(--kx-surface);
  cursor: pointer;
  transition: border-color 0.15s ease, background-color 0.15s ease, box-shadow 0.15s ease;
  min-width: 0;
}
.kx-plan-choice:hover { border-color: var(--kx-border-strong); }
.kx-plan-choice:focus-within { box-shadow: 0 0 0 3px var(--kx-focus-ring); }
.kx-plan-choice:has(input:checked) {
  border-color: var(--kx-accent);
  background: var(--kx-surface-2);
  box-shadow: inset 0 0 0 1px var(--kx-accent);
}
.kx-plan-choice input { margin-top: 0.3rem; flex-shrink: 0; accent-color: var(--kx-accent); width: 1rem; height: 1rem; }
.kx-plan-choice-body { display: flex; flex-direction: column; gap: 0.375rem; min-width: 0; flex: 1; }
.kx-plan-choice-head { display: flex; align-items: baseline; justify-content: space-between; gap: 0.75rem; }
.kx-plan-choice-name { font-weight: var(--kx-fw-strong); font-size: 0.9375rem; color: var(--kx-text); overflow-wrap: anywhere; }
.kx-plan-choice-price {
  font-weight: var(--kx-fw-strong);
  font-size: 0.9375rem;
  color: var(--kx-text);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.kx-plan-choice-price small { font-weight: var(--kx-fw-body); font-size: 0.8125rem; color: var(--kx-text-muted); }
.kx-plan-choice-tags { display: flex; flex-wrap: wrap; gap: 0.375rem; }
.kx-plan-choice-tag {
  display: inline-flex;
  align-items: center;
  padding: 0.125rem 0.5rem;
  border-radius: 999px;
  background: var(--kx-surface-2);
  border: 1px solid var(--kx-border-subtle);
  font-size: 0.75rem;
  color: var(--kx-text-muted);
}
.kx-plan-choice:has(input:checked) .kx-plan-choice-tag { background: var(--kx-surface); }
.kx-plan-choice-tag.is-trial { color: var(--kx-tone-green); border-color: color-mix(in srgb, var(--kx-tone-green) 35%, transparent); }
.kx-plan-choice-desc { font-size: 0.8125rem; line-height: 1.5; color: var(--kx-text-muted); }
.kx-plan-choice-limits { font-size: 0.8125rem; line-height: 1.5; color: var(--kx-text-2); }

/* A smaller empty state, for inside a card that shares a row. */
.kx-empty.kx-empty-sm { padding: 1.75rem 1.25rem; }
.kx-empty.kx-empty-sm .kx-empty-icon { margin-bottom: 0.5rem; }

/* A text box with a button on its right, e.g. a model name and Test. */
.kx-input-action { display: flex; gap: 0.5rem; }
.kx-input-action .form-control { min-width: 0; flex: 1; }
.kx-input-action .btn { flex-shrink: 0; }

/* Console, AI assistant. */
.kx-model-name { font-size: 0.8125rem; color: var(--kx-text); background: none; padding: 0; overflow-wrap: anywhere; }
.kx-ai-meter { width: 8rem; max-width: 100%; height: 0.375rem; border-radius: 999px; background: var(--kx-surface-2); overflow: hidden; margin-bottom: 0.25rem; }
.kx-ai-meter-bar { display: block; height: 100%; border-radius: inherit; background: var(--kx-tone-green); }
.kx-ai-meter-bar.is-close { background: var(--kx-warning); }

/* Settings: the card that leads to Invite a company. */
.kx-invite-card { display: flex; align-items: center; gap: 1rem; padding: 1rem 1.25rem; text-decoration: none; color: var(--kx-text); }
.kx-invite-card-icon { display: grid; place-items: center; flex-shrink: 0; width: 2.5rem; height: 2.5rem; border-radius: 10px;
  background: color-mix(in srgb, var(--kx-tone-green) 14%, transparent); color: var(--kx-tone-green); font-size: 1.125rem; }
.kx-invite-card-text { display: flex; flex-direction: column; gap: 0.125rem; min-width: 0; flex: 1; }
.kx-invite-card-title { font-weight: var(--kx-fw-strong); font-size: 0.9375rem; }
.kx-invite-card-help { font-size: 0.8125rem; color: var(--kx-text-muted); }
.kx-invite-card-go { color: var(--kx-text-faint); }

/* A notice for everyone, set under Console > Public site. */
.kx-site-notice {
  display: flex; align-items: center; justify-content: center; gap: 0.5rem;
  padding: 0.625rem 1rem; font-size: 0.875rem; line-height: 1.45; text-align: center;
  background: color-mix(in srgb, var(--kx-warning) 14%, var(--kx-surface));
  border-bottom: 1px solid color-mix(in srgb, var(--kx-warning) 35%, transparent);
  color: var(--kx-text);
}
.kx-site-notice .bi { color: var(--kx-warning); flex-shrink: 0; }
