/*
 * The design tokens of KF Inventory (docs/pdr/prd-redesign.md, "Tokens"; docs/design/README.md). The only file under
 * assets/react with colour values: every other stylesheet uses these variables (tokens.test.ts checks both, and the
 * contrast of every pair the screens use, in both themes).
 *
 * The theme is html[data-theme="light" | "dark"], set before the first paint by the inline script in
 * templates/spa.html.twig and kept by shared/lib/theme.ts.
 */
:root {
  color-scheme: light;

  /* Surfaces and text: one warm-neutral family tinted towards the olive. */
  --kf-bg: #f6f7f5;
  --kf-surface: #ffffff;
  --kf-surface-sunken: #eef0ec;
  --kf-surface-raised: #ffffff;
  --kf-border: #dfe3dc;
  --kf-border-strong: #848c85;
  --kf-text: #1d2420;
  --kf-text-muted: #5d6862;

  /* The accent: the KF logo's olive. Links use the darker hover (the plain olive is 4.51:1 on the page). */
  --kf-accent: #5d7b2b;
  --kf-accent-hover: #4d6823;
  --kf-accent-soft: #e9efe0;
  --kf-on-accent: #ffffff;
  --kf-link: #4d6823;
  --kf-focus: #5d7b2b;

  /* Meaning: danger only for destructive actions; warning needs attention; info is a state. */
  --kf-danger: #b42318;
  --kf-danger-hover: #912018;
  --kf-danger-soft: #fbe9e7;
  --kf-danger-text: #8a1c12;
  --kf-on-danger: #ffffff;
  --kf-warning: #b54708;
  --kf-warning-soft: #fbeedc;
  --kf-warning-text: #7a3103;
  --kf-on-warning: #ffffff;
  --kf-info: #1f5f8b;
  --kf-info-soft: #e3eef7;
  --kf-info-text: #174a6e;
  --kf-on-info: #ffffff;
  --kf-neutral-soft: #eef0ec;
  --kf-neutral-text: #3f4843;

  /* The shell's sidebar: the logo's dark ring. */
  --kf-sidebar: #23241c;
  --kf-sidebar-text: #e8ebe4;
  --kf-sidebar-muted: #8f9189;
  --kf-sidebar-active: #9cc263;
  --kf-sidebar-hover: #2f3127;

  /* Overlays */
  --kf-backdrop: rgb(20 22 18 / 0.45);
  --kf-shadow-float:
    0 12px 32px -8px rgb(35 36 28 / 0.28), 0 2px 6px rgb(35 36 28 / 0.12);
  --kf-skeleton: #e6e9e3;
  --kf-skeleton-shine: #f2f4f0;

  /* Type */
  --kf-font-sans:
    'Geist Variable', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --kf-font-mono:
    'Geist Mono Variable', ui-monospace, 'SFMono-Regular', Menlo, monospace;
  --kf-text-label: 0.75rem;
  --kf-text-sm: 0.875rem;
  --kf-text-body: 1rem;
  --kf-text-lg: 1.125rem;
  --kf-text-title: 1.375rem;
  --kf-text-kpi: 1.75rem;

  /* Space: a 4 px scale */
  --kf-space-1: 4px;
  --kf-space-2: 8px;
  --kf-space-3: 12px;
  --kf-space-4: 16px;
  --kf-space-5: 24px;
  --kf-space-6: 32px;
  --kf-space-7: 40px;
  --kf-space-8: 48px;

  /* Shape */
  --kf-radius-control: 6px;
  --kf-radius-card: 10px;
  --kf-radius-pill: 999px;
  --kf-row-height: 44px;
  --kf-row-height-comfortable: 52px;
  --kf-target: 44px;

  /* Layers */
  --kf-z-dropdown: 100;
  --kf-z-sticky: 200;
  --kf-z-popover: 250;
  --kf-z-drawer: 300;
  --kf-z-dialog: 400;
  --kf-z-toast: 500;

  /* Layout */
  --kf-content-max: 1200px;
  --kf-form-max: 720px;
  --kf-form-narrow: 640px;
  --kf-sidebar-width: 240px;
  --kf-rail-width: 64px;
  --kf-topbar-height: 56px;
  --kf-tabbar-height: 60px;

  /* Motion */
  --kf-ease: cubic-bezier(0.2, 0.7, 0.3, 1);
  --kf-duration-fast: 150ms;
  --kf-duration: 200ms;
}

html[data-theme='dark'] {
  color-scheme: dark;

  --kf-bg: #141612;
  --kf-surface: #1c1f19;
  --kf-surface-sunken: #181a15;
  --kf-surface-raised: #24281f;
  --kf-border: #30352a;
  --kf-border-strong: #6b7364;
  --kf-text: #e8ebe4;
  --kf-text-muted: #a3ab9c;

  --kf-accent: #9cc263;
  --kf-accent-hover: #b0d27e;
  --kf-accent-soft: #2a3620;
  --kf-on-accent: #141612;
  --kf-link: #9cc263;
  --kf-focus: #9cc263;

  --kf-danger: #ff8a7a;
  --kf-danger-hover: #ffa395;
  --kf-danger-soft: #3a1f1b;
  --kf-danger-text: #ff8a7a;
  --kf-on-danger: #141612;
  --kf-warning: #f0b35a;
  --kf-warning-soft: #3a2c17;
  --kf-warning-text: #f0b35a;
  --kf-on-warning: #141612;
  --kf-info: #7ab8e0;
  --kf-info-soft: #182c3a;
  --kf-info-text: #7ab8e0;
  --kf-on-info: #141612;
  --kf-neutral-soft: #2a2e26;
  --kf-neutral-text: #c9cfc3;

  --kf-sidebar: #141612;
  --kf-sidebar-text: #e8ebe4;
  --kf-sidebar-muted: #8f9189;
  --kf-sidebar-active: #9cc263;
  --kf-sidebar-hover: #1f221b;

  --kf-backdrop: rgb(0 0 0 / 0.6);
  --kf-shadow-float:
    0 12px 32px -8px rgb(0 0 0 / 0.6), 0 2px 6px rgb(0 0 0 / 0.4);
  --kf-skeleton: #262a22;
  --kf-skeleton-shine: #30352a;
}

@media (prefers-reduced-motion: reduce) {
  :root {
    --kf-duration-fast: 0ms;
    --kf-duration: 0ms;
  }
}

/*
 * Bootstrap 4's classes mapped onto the tokens (tokens.css), in both themes. Loaded after Bootstrap and Font Awesome
 * (app/index.tsx). The meaning of colour: primary/success = the accent (the one main action), danger = destructive
 * only, every other button (secondary, info, outline-*) = secondary. Cancel and Close are never red.
 */

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

body {
  background-color: var(--kf-bg);
  color: var(--kf-text);
  font-family: var(--kf-font-sans);
  font-feature-settings: 'cv11', 'ss01';
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

h1,
h2,
h3,
h4,
h5,
h6,
.h1,
.h2,
.h3,
.h4,
.h5,
.h6 {
  color: var(--kf-text);
  font-weight: 600;
  letter-spacing: -0.01em;
}

a {
  color: var(--kf-link);
}

a:hover {
  color: var(--kf-accent-hover);
}

code,
kbd,
pre,
samp,
.text-monospace {
  font-family: var(--kf-font-mono);
}

code {
  color: var(--kf-text);
}

hr {
  border-top-color: var(--kf-border);
}

::selection {
  background: var(--kf-accent-soft);
  color: var(--kf-text);
}

/* One visible focus ring: 2 px accent, 2 px away, on keyboard focus only. */
:focus {
  outline: none;
}

:focus-visible {
  outline: 2px solid var(--kf-focus);
  outline-offset: 2px;
}

.btn:focus,
.btn.focus,
.form-control:focus,
.custom-select:focus,
.page-link:focus,
.close:focus {
  box-shadow: none;
}

.btn:focus-visible,
.page-link:focus-visible,
.close:focus-visible,
.dropdown-item:focus-visible {
  outline: 2px solid var(--kf-focus);
  outline-offset: 2px;
}

.text-muted,
.form-text,
.blockquote-footer {
  color: var(--kf-text-muted) !important;
}

.text-danger {
  color: var(--kf-danger) !important;
}

.text-success {
  color: var(--kf-accent) !important;
}

.text-warning {
  color: var(--kf-warning-text) !important;
}

.text-info,
.text-primary {
  color: var(--kf-link) !important;
}

.text-secondary {
  color: var(--kf-text-muted) !important;
}

.text-dark,
.text-body {
  color: var(--kf-text) !important;
}

.bg-light,
.bg-white {
  background-color: var(--kf-surface) !important;
}

.bg-dark {
  background-color: var(--kf-sidebar) !important;
}

.border,
.border-top,
.border-bottom,
.border-left,
.border-right {
  border-color: var(--kf-border) !important;
}

/* Numbers line up. */
.text-right,
td.text-right,
th.text-right {
  font-variant-numeric: tabular-nums;
}

/* ---- Buttons ---------------------------------------------------------------------------------------------- */
.btn {
  border-radius: var(--kf-radius-control);
  font-weight: 500;
  transition:
    background-color var(--kf-duration-fast) var(--kf-ease),
    border-color var(--kf-duration-fast) var(--kf-ease),
    color var(--kf-duration-fast) var(--kf-ease),
    transform var(--kf-duration-fast) var(--kf-ease);
}

.btn:not(:disabled):not(.disabled):active {
  transform: translateY(1px);
}

.btn.disabled,
.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-primary,
.btn-success {
  background-color: var(--kf-accent);
  border-color: var(--kf-accent);
  color: var(--kf-on-accent);
}

.btn-primary:hover,
.btn-success:hover,
.btn-primary:not(:disabled):not(.disabled):active,
.btn-success:not(:disabled):not(.disabled):active,
.btn-primary:focus,
.btn-success:focus {
  background-color: var(--kf-accent-hover);
  border-color: var(--kf-accent-hover);
  color: var(--kf-on-accent);
}

.btn-primary.disabled,
.btn-primary:disabled,
.btn-success.disabled,
.btn-success:disabled {
  background-color: var(--kf-accent);
  border-color: var(--kf-accent);
  color: var(--kf-on-accent);
}

.btn-danger {
  background-color: var(--kf-danger);
  border-color: var(--kf-danger);
  color: var(--kf-on-danger);
}

.btn-danger:hover,
.btn-danger:focus,
.btn-danger:not(:disabled):not(.disabled):active,
.btn-danger.disabled,
.btn-danger:disabled {
  background-color: var(--kf-danger-hover);
  border-color: var(--kf-danger-hover);
  color: var(--kf-on-danger);
}

.btn-danger.disabled,
.btn-danger:disabled {
  background-color: var(--kf-danger);
  border-color: var(--kf-danger);
}

.btn-secondary,
.btn-info,
.btn-light,
.btn-dark,
.btn-warning,
.btn-outline-primary,
.btn-outline-secondary,
.btn-outline-success,
.btn-outline-info,
.btn-outline-dark,
.btn-outline-light,
.btn-outline-warning {
  background-color: var(--kf-surface);
  border-color: var(--kf-border-strong);
  color: var(--kf-text);
}

.btn-secondary:hover,
.btn-info:hover,
.btn-light:hover,
.btn-dark:hover,
.btn-warning:hover,
.btn-outline-primary:hover,
.btn-outline-secondary:hover,
.btn-outline-success:hover,
.btn-outline-info:hover,
.btn-outline-dark:hover,
.btn-outline-light:hover,
.btn-outline-warning:hover,
.btn-secondary:not(:disabled):not(.disabled):active,
.btn-info:not(:disabled):not(.disabled):active,
.btn-outline-secondary:not(:disabled):not(.disabled):active,
.btn-outline-primary:not(:disabled):not(.disabled):active,
.btn-secondary:focus,
.btn-info:focus,
.btn-outline-secondary:focus,
.btn-outline-primary:focus {
  background-color: var(--kf-surface-sunken);
  border-color: var(--kf-border-strong);
  color: var(--kf-text);
}

.btn-secondary.disabled,
.btn-secondary:disabled,
.btn-info.disabled,
.btn-info:disabled,
.btn-outline-secondary.disabled,
.btn-outline-secondary:disabled {
  background-color: var(--kf-surface);
  border-color: var(--kf-border-strong);
  color: var(--kf-text);
}

.btn-outline-danger {
  background-color: var(--kf-surface);
  border-color: var(--kf-danger);
  color: var(--kf-danger);
}

.btn-outline-danger:hover,
.btn-outline-danger:focus,
.btn-outline-danger:not(:disabled):not(.disabled):active {
  background-color: var(--kf-danger-soft);
  border-color: var(--kf-danger);
  color: var(--kf-danger-text);
}

.btn-link {
  color: var(--kf-link);
}

.btn-link:hover {
  color: var(--kf-accent-hover);
}

/* Touch screens get 44 px targets. */
@media (pointer: coarse) {
  .btn,
  .form-control,
  .custom-select {
    min-height: var(--kf-target);
  }
}

/* ---- Forms ------------------------------------------------------------------------------------------------ */
label {
  font-weight: 500;
  font-size: var(--kf-text-sm);
  color: var(--kf-text);
  margin-bottom: var(--kf-space-1);
}

.form-check-label {
  font-weight: 400;
  font-size: var(--kf-text-body);
}

.form-control,
.custom-select,
.custom-file-label,
.input-group-text {
  background-color: var(--kf-surface);
  border-color: var(--kf-border-strong);
  border-radius: var(--kf-radius-control);
  color: var(--kf-text);
  transition:
    border-color var(--kf-duration-fast) var(--kf-ease),
    box-shadow var(--kf-duration-fast) var(--kf-ease);
}

.input-group-text {
  background-color: var(--kf-surface-sunken);
  color: var(--kf-text-muted);
}

.form-control::placeholder {
  color: var(--kf-text-muted);
  opacity: 1;
}

.form-control:focus,
.custom-select:focus {
  background-color: var(--kf-surface);
  border-color: var(--kf-accent);
  color: var(--kf-text);
  outline: 2px solid var(--kf-focus);
  outline-offset: 0;
}

.form-control:disabled,
.form-control[readonly],
.custom-select:disabled {
  background-color: var(--kf-surface-sunken);
  color: var(--kf-text-muted);
}

/* Bootstrap draws the select's arrow with a hard-coded dark SVG; a native select shows the theme's own. */
select.form-control,
.custom-select {
  color-scheme: inherit;
}

.custom-select {
  background-color: var(--kf-surface);
}

.form-control.is-invalid,
.was-validated .form-control:invalid,
.custom-select.is-invalid {
  border-color: var(--kf-danger);
  background-image: none;
  padding-right: 0.75rem;
}

.form-control.is-invalid:focus,
.custom-select.is-invalid:focus {
  border-color: var(--kf-danger);
  outline-color: var(--kf-danger);
}

.invalid-feedback {
  color: var(--kf-danger);
  font-size: var(--kf-text-sm);
}

.form-control.is-valid {
  border-color: var(--kf-border-strong);
  background-image: none;
}

input[type='checkbox'],
input[type='radio'] {
  accent-color: var(--kf-accent);
}

input[type='file'].form-control-file {
  color: var(--kf-text);
}

/* ---- Tables ----------------------------------------------------------------------------------------------- */
.table {
  color: var(--kf-text);
  background-color: var(--kf-surface);
  font-size: var(--kf-text-sm);
}

.table th,
.table td {
  border-top-color: var(--kf-border);
  vertical-align: middle;
}

.table thead th {
  background-color: var(--kf-surface-sunken);
  border-bottom: 1px solid var(--kf-border);
  color: var(--kf-text-muted);
  font-size: var(--kf-text-label);
  font-weight: 600;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.table thead th .btn-link {
  color: var(--kf-text-muted) !important;
  font-size: inherit;
}

.table-sm td,
.table-sm th {
  padding: 0.5rem 0.75rem;
}

.table td {
  height: var(--kf-row-height);
}

.table-striped tbody tr:nth-of-type(odd) {
  background-color: transparent;
}

.table-hover tbody tr:hover {
  background-color: var(--kf-surface-sunken);
  color: var(--kf-text);
}

.table-bordered,
.table-bordered td,
.table-bordered th {
  border-color: var(--kf-border);
}

.table-success,
.table-success > td,
.table-success > th {
  background-color: var(--kf-accent-soft);
}

.table-warning,
.table-warning > td,
.table-warning > th {
  background-color: var(--kf-warning-soft);
}

.table-danger,
.table-danger > td,
.table-danger > th {
  background-color: var(--kf-danger-soft);
}

.table-active,
.table-active > td,
.table-active > th {
  background-color: var(--kf-accent-soft);
}

.table-responsive {
  border: 1px solid var(--kf-border);
  border-radius: var(--kf-radius-card);
  background-color: var(--kf-surface);
}

.table-responsive > .table {
  margin-bottom: 0;
}

/* A legacy table without a .table-responsive box scrolls inside itself on narrow screens, never the page. */
@media (max-width: 1023px) {
  .table:not(.kf-table) {
    display: block;
    max-width: 100%;
    overflow-x: auto;
  }
}

/* ---- Cards, alerts, badges -------------------------------------------------------------------------------- */
.card {
  background-color: var(--kf-surface);
  border: 1px solid var(--kf-border);
  border-radius: var(--kf-radius-card);
  color: var(--kf-text);
}

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

.card-header:first-child {
  border-radius: var(--kf-radius-card) var(--kf-radius-card) 0 0;
}

.list-group-item {
  background-color: var(--kf-surface);
  border-color: var(--kf-border);
  color: var(--kf-text);
}

.alert {
  border-radius: var(--kf-radius-control);
  border-width: 1px;
  color: var(--kf-text);
}

.alert-success {
  background-color: var(--kf-accent-soft);
  border-color: var(--kf-accent);
}

.alert-danger {
  background-color: var(--kf-danger-soft);
  border-color: var(--kf-danger);
}

.alert-warning {
  background-color: var(--kf-warning-soft);
  border-color: var(--kf-warning);
}

.alert-info,
.alert-primary,
.alert-secondary,
.alert-light,
.alert-dark {
  background-color: var(--kf-info-soft);
  border-color: var(--kf-info);
}

.alert .alert-link,
.alert a {
  color: var(--kf-text);
  text-decoration: underline;
}

.alert .close {
  color: var(--kf-text);
}

.badge {
  border-radius: var(--kf-radius-pill);
  font-weight: 500;
  padding: 0.25em 0.6em;
}

.badge-primary,
.badge-success {
  background-color: var(--kf-accent-soft);
  color: var(--kf-link);
}

.badge-danger {
  background-color: var(--kf-danger-soft);
  color: var(--kf-danger-text);
}

.badge-warning {
  background-color: var(--kf-warning-soft);
  color: var(--kf-warning-text);
}

.badge-info {
  background-color: var(--kf-info-soft);
  color: var(--kf-info-text);
}

.badge-secondary,
.badge-light,
.badge-dark {
  background-color: var(--kf-neutral-soft);
  color: var(--kf-neutral-text);
}

/* ---- Dialogs ---------------------------------------------------------------------------------------------- */
.modal {
  z-index: var(--kf-z-dialog);
}

.modal-backdrop {
  z-index: calc(var(--kf-z-dialog) - 1);
  background-color: var(--kf-backdrop);
}

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

.modal-content {
  background-color: var(--kf-surface-raised);
  border: 1px solid var(--kf-border);
  border-radius: var(--kf-radius-card);
  box-shadow: var(--kf-shadow-float);
  color: var(--kf-text);
}

.modal-header,
.modal-footer {
  border-color: var(--kf-border);
}

.close {
  color: var(--kf-text);
  text-shadow: none;
  opacity: 0.7;
}

.close:hover {
  color: var(--kf-text);
  opacity: 1;
}

/* ---- Navigation pieces ------------------------------------------------------------------------------------ */
.nav-tabs {
  border-bottom-color: var(--kf-border);
}

.nav-tabs .nav-link {
  color: var(--kf-text-muted);
  border: 0;
  border-bottom: 2px solid transparent;
  border-radius: 0;
}

.nav-tabs .nav-link:hover,
.nav-tabs .nav-link:focus {
  color: var(--kf-text);
  border-bottom-color: var(--kf-border-strong);
}

.nav-tabs .nav-link.active,
.nav-tabs .nav-item.show .nav-link {
  background-color: transparent;
  color: var(--kf-text);
  border-bottom-color: var(--kf-accent);
  font-weight: 600;
}

.pagination .page-link {
  background-color: var(--kf-surface);
  border-color: var(--kf-border);
  color: var(--kf-link);
}

.pagination .page-link:hover {
  background-color: var(--kf-surface-sunken);
  border-color: var(--kf-border);
  color: var(--kf-accent-hover);
}

.pagination .page-item.active .page-link {
  background-color: var(--kf-accent);
  border-color: var(--kf-accent);
  color: var(--kf-on-accent);
}

.pagination .page-item.disabled .page-link {
  background-color: var(--kf-surface);
  border-color: var(--kf-border);
  color: var(--kf-text-muted);
}

.dropdown-menu {
  z-index: var(--kf-z-dropdown);
  background-color: var(--kf-surface-raised);
  border: 1px solid var(--kf-border);
  border-radius: var(--kf-radius-control);
  box-shadow: var(--kf-shadow-float);
  color: var(--kf-text);
}

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

.dropdown-item:hover,
.dropdown-item:focus {
  background-color: var(--kf-surface-sunken);
  color: var(--kf-text);
}

.dropdown-item.active,
.dropdown-item:active {
  background-color: var(--kf-accent-soft);
  color: var(--kf-text);
}

.dropdown-divider {
  border-top-color: var(--kf-border);
}

/* ---- Spinners --------------------------------------------------------------------------------------------- */
.spinner-border.text-secondary {
  color: var(--kf-text-muted) !important;
}

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

  .spinner-border {
    animation-duration: 1.5s !important;
  }
}

/*
 * react-select on the tokens, in both themes: a Select with classNamePrefix="kf-select". The class is doubled so
 * these rules win over react-select's own (emotion) styles whatever order they are inserted in.
 */
.kf-select__control.kf-select__control {
  min-height: calc(1.5em + 0.75rem + 2px);
  background-color: var(--kf-surface);
  border-color: var(--kf-border-strong);
  border-radius: var(--kf-radius-control);
  box-shadow: none;
}

.kf-select__control.kf-select__control:hover {
  border-color: var(--kf-border-strong);
}

.kf-select__control.kf-select__control--is-focused {
  border-color: var(--kf-accent);
  outline: 2px solid var(--kf-focus);
  outline-offset: 0;
}

.kf-select__control.kf-select__control--is-disabled {
  background-color: var(--kf-surface-sunken);
}

.kf-select__single-value.kf-select__single-value,
.kf-select__input-container.kf-select__input-container,
.kf-select__input.kf-select__input {
  color: var(--kf-text);
}

.kf-select__placeholder.kf-select__placeholder {
  color: var(--kf-text-muted);
}

.kf-select__indicator-separator.kf-select__indicator-separator {
  background-color: var(--kf-border);
}

.kf-select__indicator.kf-select__indicator {
  color: var(--kf-text-muted);
}

.kf-select__indicator.kf-select__indicator:hover {
  color: var(--kf-text);
}

/* Over the sticky bars (a form's action bar, the phone's tab bar): a list that opens down near the bottom of the
   screen is picked from, not hidden under them. */
.kf-select__menu.kf-select__menu {
  z-index: var(--kf-z-popover);
  background-color: var(--kf-surface-raised);
  border: 1px solid var(--kf-border);
  border-radius: var(--kf-radius-control);
  box-shadow: var(--kf-shadow-float);
}

.kf-select__option.kf-select__option {
  background-color: transparent;
  color: var(--kf-text);
}

.kf-select__option.kf-select__option--is-focused {
  background-color: var(--kf-surface-sunken);
}

.kf-select__option.kf-select__option--is-selected {
  background-color: var(--kf-accent-soft);
  color: var(--kf-text);
}

.kf-select__menu-notice.kf-select__menu-notice {
  color: var(--kf-text-muted);
}

.kf-select__multi-value.kf-select__multi-value {
  background-color: var(--kf-accent-soft);
}

.kf-select__multi-value__label.kf-select__multi-value__label {
  color: var(--kf-text);
}

/* On a touch screen the control is as tall as the other fields: a 44 px target (docs/design/README.md). */
@media (pointer: coarse) {
  .kf-select__control.kf-select__control {
    min-height: var(--kf-target);
  }

  .kf-select__option.kf-select__option {
    display: flex;
    align-items: center;
    min-height: var(--kf-target);
  }
}

/* The kit's own components (@/shared/ui), on the tokens, in both themes. One block per component. */

/* ---- Money, Num ------------------------------------------------------------------------------------------ */
.kf-num {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.kf-num--negative {
  color: var(--kf-danger);
}

.kf-mono {
  font-family: var(--kf-font-mono);
  font-size: 0.95em;
  overflow-wrap: anywhere;
}

/* ---- Button ---------------------------------------------------------------------------------------------- */
.kf-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--kf-space-2);
  min-height: 36px;
  padding: 0 var(--kf-space-4);
  border: 1px solid transparent;
  border-radius: var(--kf-radius-control);
  font-family: inherit;
  font-size: var(--kf-text-sm);
  font-weight: 500;
  line-height: 1.2;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
  transition:
    background-color var(--kf-duration-fast) var(--kf-ease),
    border-color var(--kf-duration-fast) var(--kf-ease),
    color var(--kf-duration-fast) var(--kf-ease),
    transform var(--kf-duration-fast) var(--kf-ease);
}

.kf-btn:hover {
  text-decoration: none;
}

.kf-btn:not(:disabled):active {
  transform: translateY(1px);
}

.kf-btn:disabled,
.kf-btn[aria-disabled='true'] {
  opacity: 0.5;
  cursor: not-allowed;
}

.kf-btn--sm {
  min-height: 30px;
  padding: 0 var(--kf-space-3);
  font-size: var(--kf-text-label);
}

.kf-btn--lg {
  min-height: 48px;
  padding: 0 var(--kf-space-5);
  font-size: var(--kf-text-body);
}

.kf-btn--icon {
  padding: 0;
  width: 36px;
}

.kf-btn--icon.kf-btn--sm {
  width: 30px;
}

.kf-btn--icon.kf-btn--lg {
  width: 48px;
}

@media (pointer: coarse) {
  .kf-btn,
  .kf-btn--sm {
    min-height: var(--kf-target);
  }

  .kf-btn--icon,
  .kf-btn--icon.kf-btn--sm {
    width: var(--kf-target);
  }

  /* Large stays larger than the touch minimum (the getting-ready steppers: 48 × 48). */
  .kf-btn--lg {
    min-height: 48px;
  }
}

.kf-btn--primary {
  background-color: var(--kf-accent);
  border-color: var(--kf-accent);
  color: var(--kf-on-accent);
}

.kf-btn--primary:hover:not(:disabled) {
  background-color: var(--kf-accent-hover);
  border-color: var(--kf-accent-hover);
  color: var(--kf-on-accent);
}

.kf-btn--secondary {
  background-color: var(--kf-surface);
  border-color: var(--kf-border-strong);
  color: var(--kf-text);
}

.kf-btn--secondary:hover:not(:disabled) {
  background-color: var(--kf-surface-sunken);
  color: var(--kf-text);
}

.kf-btn--ghost {
  background-color: transparent;
  color: var(--kf-text);
}

.kf-btn--ghost:hover:not(:disabled),
.kf-btn--ghost[aria-expanded='true'] {
  background-color: var(--kf-surface-sunken);
  color: var(--kf-text);
}

.kf-btn--danger {
  background-color: var(--kf-danger);
  border-color: var(--kf-danger);
  color: var(--kf-on-danger);
}

.kf-btn--danger:hover:not(:disabled) {
  background-color: var(--kf-danger-hover);
  border-color: var(--kf-danger-hover);
  color: var(--kf-on-danger);
}

.kf-btn[aria-pressed='true'] {
  background-color: var(--kf-accent-soft);
  color: var(--kf-text);
}

.kf-btn.is-loading .kf-btn__label,
.kf-btn.is-loading .kf-btn__icon {
  visibility: hidden;
}

.kf-btn__spinner {
  position: absolute;
  inset: 0;
  margin: auto;
  width: 1em;
  height: 1em;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: kf-spin 0.7s linear infinite;
}

@keyframes kf-spin {
  to {
    transform: rotate(360deg);
  }
}

/* ---- StatusBadge ----------------------------------------------------------------------------------------- */
.kf-badge {
  display: inline-flex;
  align-items: center;
  gap: var(--kf-space-1);
  padding: 2px var(--kf-space-2);
  border-radius: var(--kf-radius-pill);
  font-size: var(--kf-text-label);
  font-weight: 600;
  line-height: 1.5;
  white-space: nowrap;
}

.kf-badge--neutral {
  background-color: var(--kf-neutral-soft);
  color: var(--kf-neutral-text);
}

.kf-badge--info {
  background-color: var(--kf-info-soft);
  color: var(--kf-info-text);
}

.kf-badge--accent {
  background-color: var(--kf-accent-soft);
  color: var(--kf-link);
}

.kf-badge--warning {
  background-color: var(--kf-warning-soft);
  color: var(--kf-warning-text);
}

.kf-badge--danger {
  background-color: var(--kf-danger-soft);
  color: var(--kf-danger-text);
}

.kf-badge--filled.kf-badge--neutral {
  background-color: var(--kf-neutral-text);
  color: var(--kf-surface);
}

.kf-badge--filled.kf-badge--info {
  background-color: var(--kf-info);
  color: var(--kf-on-info);
}

.kf-badge--filled.kf-badge--accent {
  background-color: var(--kf-accent);
  color: var(--kf-on-accent);
}

.kf-badge--filled.kf-badge--warning {
  background-color: var(--kf-warning);
  color: var(--kf-on-warning);
}

.kf-badge--filled.kf-badge--danger {
  background-color: var(--kf-danger);
  color: var(--kf-on-danger);
}

/* ---- Skeleton -------------------------------------------------------------------------------------------- */
.kf-skeleton {
  display: grid;
  gap: var(--kf-space-3);
}

.kf-skeleton__block {
  display: block;
  height: 0.875rem;
  border-radius: 4px;
  background: linear-gradient(
    90deg,
    var(--kf-skeleton) 25%,
    var(--kf-skeleton-shine) 50%,
    var(--kf-skeleton) 75%
  );
  background-size: 200% 100%;
  animation: kf-shimmer 1.4s ease-in-out infinite;
}

.kf-skeleton--text .kf-skeleton__block:last-child {
  width: 60%;
}

.kf-skeleton--row .kf-skeleton__block {
  height: var(--kf-row-height);
}

.kf-skeleton--card .kf-skeleton__block {
  height: 120px;
  border-radius: var(--kf-radius-card);
}

.kf-skeleton--form .kf-skeleton__block {
  height: 38px;
  max-width: var(--kf-form-max);
}

.kf-skeleton--kpi {
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
}

.kf-skeleton--kpi .kf-skeleton__block {
  height: 72px;
  border-radius: var(--kf-radius-card);
}

@keyframes kf-shimmer {
  from {
    background-position: 100% 0;
  }

  to {
    background-position: -100% 0;
  }
}

/* ---- EmptyState ------------------------------------------------------------------------------------------ */
.kf-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--kf-space-2);
  padding: var(--kf-space-7) var(--kf-space-4);
  text-align: center;
  color: var(--kf-text-muted);
}

.kf-empty p {
  margin: 0;
  max-width: 48ch;
}

.kf-empty__icon {
  font-size: 2rem;
  color: var(--kf-border-strong);
}

.kf-empty__title {
  color: var(--kf-text);
  font-weight: 600;
}

.kf-empty__action {
  margin-top: var(--kf-space-2);
}

/* ---- KpiStrip -------------------------------------------------------------------------------------------- */
.kf-kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: var(--kf-space-3);
  margin: 0 0 var(--kf-space-4);
}

.kf-kpi {
  padding: var(--kf-space-3) var(--kf-space-4);
  border: 1px solid var(--kf-border);
  border-radius: var(--kf-radius-card);
  background-color: var(--kf-surface);
}

.kf-kpi__label {
  font-size: var(--kf-text-label);
  font-weight: 500;
  color: var(--kf-text-muted);
}

.kf-kpi__value {
  margin: 0;
  font-size: var(--kf-text-kpi);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
}

.kf-kpi--warning .kf-kpi__value {
  color: var(--kf-warning-text);
}

.kf-kpi--danger .kf-kpi__value {
  color: var(--kf-danger);
}

@media (max-width: 599px) {
  .kf-kpis {
    grid-template-columns: 1fr 1fr;
  }
}

/* ---- PageHeader, PageCard -------------------------------------------------------------------------------- */
.kf-page-header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--kf-space-3) var(--kf-space-4);
  margin-bottom: var(--kf-space-5);
}

.kf-page-header__titles {
  min-width: 0;
}

.kf-page-header__back {
  display: inline-flex;
  align-items: center;
  gap: var(--kf-space-1);
  margin-bottom: var(--kf-space-1);
  font-size: var(--kf-text-sm);
}

@media (pointer: coarse) {
  .kf-page-header__back {
    min-height: var(--kf-target);
    margin-bottom: 0;
  }
}

.kf-page-header__title {
  margin: 0;
  font-size: var(--kf-text-title);
  font-weight: 600;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.kf-page-header__subtitle {
  margin: var(--kf-space-1) 0 0;
  color: var(--kf-text-muted);
  font-size: var(--kf-text-sm);
}

.kf-page-header__actions {
  position: relative;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--kf-space-2);
}

.kf-page-header__secondary {
  display: flex;
  flex-wrap: wrap;
  gap: var(--kf-space-2);
}

.kf-page-header__more {
  display: none;
}

@media (max-width: 599px) {
  .kf-page-header__more {
    display: inline-flex;
  }

  .kf-page-header__secondary {
    display: none;
  }

  .kf-page-header__secondary.is-open {
    position: absolute;
    top: calc(100% + var(--kf-space-1));
    right: 0;
    z-index: var(--kf-z-popover);
    display: flex;
    flex-direction: column;
    align-items: stretch;
    min-width: 220px;
    padding: var(--kf-space-2);
    border: 1px solid var(--kf-border);
    border-radius: var(--kf-radius-control);
    background-color: var(--kf-surface-raised);
    box-shadow: var(--kf-shadow-float);
  }
}

.kf-page-card {
  margin-bottom: var(--kf-space-5);
}

/* ---- Toolbar, chips, search ------------------------------------------------------------------------------ */
.kf-toolbar {
  position: sticky;
  top: var(--kf-toolbar-top, 0);
  z-index: var(--kf-z-sticky);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--kf-space-2) var(--kf-space-3);
  margin: 0 calc(-1 * var(--kf-space-2)) var(--kf-space-4);
  padding: var(--kf-space-2);
  background-color: var(--kf-bg);
}

/* On a phone the filters wrap to several lines: sticky, they would cover half the screen. */
@media (max-width: 599px) {
  .kf-toolbar {
    position: static;
  }
}

.kf-chips {
  display: flex;
  flex-wrap: wrap;
  gap: var(--kf-space-2);
}

.kf-chip {
  display: inline-flex;
  align-items: center;
  gap: var(--kf-space-2);
  min-height: 32px;
  padding: 0 var(--kf-space-3);
  border: 1px solid var(--kf-border-strong);
  border-radius: var(--kf-radius-pill);
  background-color: var(--kf-surface);
  color: var(--kf-text);
  font-size: var(--kf-text-sm);
  font-weight: 500;
  cursor: pointer;
}

.kf-chip:hover {
  background-color: var(--kf-surface-sunken);
}

.kf-chip[aria-pressed='true'] {
  border-color: var(--kf-accent);
  background-color: var(--kf-accent-soft);
}

.kf-chip__count {
  color: var(--kf-text-muted);
  font-variant-numeric: tabular-nums;
}

@media (pointer: coarse) {
  .kf-chip {
    min-height: var(--kf-target);
  }
}

.kf-search {
  position: relative;
  flex: 1 1 220px;
  max-width: 360px;
  min-width: 0;
}

.kf-search__icon {
  position: absolute;
  top: 50%;
  left: var(--kf-space-3);
  transform: translateY(-50%);
  color: var(--kf-text-muted);
  pointer-events: none;
}

.form-control.kf-search__input {
  padding-left: 2.25rem;
  padding-right: 2.25rem;
}

.kf-search__input::-webkit-search-cancel-button {
  display: none;
}

.kf-search__clear {
  position: absolute;
  top: 50%;
  right: var(--kf-space-1);
  transform: translateY(-50%);
  width: 30px;
  height: 30px;
  border: 0;
  border-radius: var(--kf-radius-control);
  background: transparent;
  color: var(--kf-text-muted);
}

.kf-search__clear:hover {
  color: var(--kf-text);
  background-color: var(--kf-surface-sunken);
}

/* ---- Segmented controls: warehouse, language ------------------------------------------------------------- */
.kf-segmented {
  display: inline-flex;
  max-width: 100%;
  padding: 2px;
  border: 1px solid var(--kf-border-strong);
  border-radius: var(--kf-radius-control);
  background-color: var(--kf-surface-sunken);
  overflow-x: auto;
}

.kf-segmented__option {
  flex: 0 0 auto;
  min-height: 32px;
  padding: 0 var(--kf-space-3);
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--kf-text-muted);
  font-size: var(--kf-text-sm);
  font-weight: 500;
  cursor: pointer;
}

.kf-segmented__option:hover {
  color: var(--kf-text);
}

.kf-segmented__option[aria-checked='true'] {
  background-color: var(--kf-surface);
  color: var(--kf-text);
  box-shadow: 0 0 0 1px var(--kf-border-strong);
  font-weight: 600;
}

.kf-segmented--sm .kf-segmented__option {
  min-height: 28px;
  padding: 0 var(--kf-space-2);
  font-size: var(--kf-text-label);
}

@media (pointer: coarse) {
  .kf-segmented__option,
  .kf-segmented--sm .kf-segmented__option {
    min-width: var(--kf-target);
    min-height: var(--kf-target);
  }
}

.kf-warehouse-switch--select {
  display: inline-flex;
  align-items: center;
  gap: var(--kf-space-2);
  color: var(--kf-text-muted);
}

.kf-warehouse-switch--select select {
  width: auto;
}

/* ---- DataTable ------------------------------------------------------------------------------------------- */
.kf-data-table__search {
  margin-bottom: var(--kf-space-3);
}

.kf-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--kf-border);
  border-radius: var(--kf-radius-card);
  background-color: var(--kf-surface);
}

.kf-table {
  width: 100%;
  border-collapse: collapse;
  color: var(--kf-text);
  font-size: var(--kf-text-sm);
}

.kf-table th,
.kf-table td {
  padding: 0 var(--kf-space-3);
  height: var(--kf-row-height);
  border-top: 1px solid var(--kf-border);
  text-align: left;
  vertical-align: middle;
}

.kf-table--comfortable th,
.kf-table--comfortable td {
  height: var(--kf-row-height-comfortable);
}

.kf-table thead th {
  height: 36px;
  border-top: 0;
  background-color: var(--kf-surface-sunken);
  color: var(--kf-text-muted);
  font-size: var(--kf-text-label);
  font-weight: 600;
  white-space: nowrap;
}

.kf-table--sticky thead th {
  position: sticky;
  top: var(--kf-toolbar-top, 0);
  z-index: 1;
}

.kf-table-wrap:has(.kf-table--sticky) {
  overflow: visible;
}

.kf-table tbody tr:hover {
  background-color: var(--kf-surface-sunken);
}

.kf-table tbody tr.is-selected {
  background-color: var(--kf-accent-soft);
}

.kf-table--clickable tbody tr {
  cursor: pointer;
}

.kf-table__num {
  text-align: right !important;
  font-variant-numeric: tabular-nums;
}

.kf-table__mono {
  font-family: var(--kf-font-mono);
  white-space: nowrap;
}

.kf-table__select {
  width: 44px;
}

/* The checkbox's whole cell selects the row (a label: a tap there never opens the row). */
.kf-table__select-hit {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 24px;
  min-height: 24px;
  margin: 0;
  cursor: pointer;
}

@media (pointer: coarse) {
  .kf-table__select-hit {
    min-width: var(--kf-target);
    min-height: var(--kf-target);
  }
}

.kf-table__actions {
  width: 1%;
  text-align: right !important;
  white-space: nowrap;
}

.kf-table__actions > * + * {
  margin-left: var(--kf-space-1);
}

.kf-table__card-title {
  display: none;
}

.kf-table__sort {
  display: inline-flex;
  align-items: center;
  gap: var(--kf-space-1);
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  cursor: pointer;
}

.kf-table__sort-icon {
  opacity: 0.6;
  font-size: 0.85em;
}

.kf-table--skeleton td {
  border-top: 1px solid var(--kf-border);
}

.kf-selection-bar {
  position: sticky;
  top: var(--kf-toolbar-top, 0);
  z-index: var(--kf-z-sticky);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--kf-space-2) var(--kf-space-3);
  margin-bottom: var(--kf-space-3);
  padding: var(--kf-space-2) var(--kf-space-3);
  border: 1px solid var(--kf-accent);
  border-radius: var(--kf-radius-card);
  background-color: var(--kf-accent-soft);
}

.kf-selection-bar__count {
  font-weight: 600;
}

.kf-selection-bar__actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--kf-space-2);
}

/* On a phone the bar floats above the tab bar, like a form's action bar: above the list, a card ticked low on the
   screen put it out of sight. The page keeps room for it under the last card (DataTable shares its height as
   --kf-floating-bar-height). The count and Clear share its first line, the actions the second. */
@media (max-width: 599px) {
  .kf-selection-bar {
    position: fixed;
    top: auto;
    right: var(--kf-space-4);
    bottom: calc(var(--kf-shell-bottom, 0px) + var(--kf-space-2));
    left: var(--kf-space-4);
    margin: 0;
    box-shadow: var(--kf-shadow-float);
  }

  .kf-selection-bar__count {
    flex: 1 1 auto;
  }

  .kf-selection-bar__actions {
    order: 1;
    flex: 1 1 100%;
  }

  .kf-selection-bar__actions > * {
    flex: 1 1 auto;
  }
}

.kf-pager {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--kf-space-2);
  margin-top: var(--kf-space-3);
}

.kf-pager__label {
  color: var(--kf-text-muted);
  font-size: var(--kf-text-sm);
}

/* Cards under 600 px: CSS only, the explicit roles keep the table's semantics. */
@media (max-width: 599px) {
  .kf-table-wrap {
    overflow: visible;
    border: 0;
    background: transparent;
  }

  .kf-table,
  .kf-table tbody,
  .kf-table tr,
  .kf-table td {
    display: block;
    width: 100%;
  }

  .kf-table thead {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
  }

  .kf-table tbody tr {
    position: relative;
    margin-bottom: var(--kf-space-3);
    padding: var(--kf-space-3) var(--kf-space-4);
    border: 1px solid var(--kf-border);
    border-radius: var(--kf-radius-card);
    background-color: var(--kf-surface);
  }

  .kf-table td {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: var(--kf-space-3);
    height: auto;
    min-height: 0;
    padding: var(--kf-space-1) 0;
    border: 0;
    text-align: right;
    overflow-wrap: anywhere;
  }

  .kf-table td[data-label]::before {
    content: attr(data-label);
    flex: 0 0 auto;
    color: var(--kf-text-muted);
    font-size: var(--kf-text-label);
    font-weight: 500;
    text-align: left;
  }

  .kf-table .kf-table__card-title {
    display: block;
    padding-right: 88px;
    font-size: var(--kf-text-body);
    font-weight: 600;
    text-align: left;
  }

  .kf-table .kf-table__card-hidden {
    display: none;
  }

  .kf-table .kf-table__mono {
    white-space: normal;
  }

  .kf-table .kf-table__select {
    position: absolute;
    top: 0;
    left: 0;
    width: auto;
    padding: 0;
  }

  .kf-table .kf-table__select-hit {
    min-width: var(--kf-target);
    min-height: var(--kf-target);
  }

  .kf-table tr:has(.kf-table__select) {
    padding-left: var(--kf-target);
  }

  /* A card without a title: its first line leaves room for the row's actions, top right. */
  .kf-table .kf-table__card-lead {
    padding-right: 88px;
  }

  .kf-table .kf-table__actions {
    position: absolute;
    top: var(--kf-space-2);
    right: var(--kf-space-2);
    width: auto;
    padding: 0;
  }
}

/* ---- RowMenu (and every menu) ---------------------------------------------------------------------------- */
.kf-menu {
  position: fixed;
  z-index: var(--kf-z-toast);
  min-width: 200px;
  max-width: calc(100vw - 16px);
  padding: var(--kf-space-1);
  border: 1px solid var(--kf-border);
  border-radius: var(--kf-radius-control);
  background-color: var(--kf-surface-raised);
  box-shadow: var(--kf-shadow-float);
}

.kf-menu__item {
  display: flex;
  align-items: center;
  gap: var(--kf-space-2);
  width: 100%;
  min-height: 36px;
  padding: 0 var(--kf-space-3);
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--kf-text);
  font-size: var(--kf-text-sm);
  text-align: left;
  text-decoration: none;
  cursor: pointer;
}

.kf-menu__item:hover,
.kf-menu__item:focus {
  background-color: var(--kf-surface-sunken);
  color: var(--kf-text);
  text-decoration: none;
}

.kf-menu__item:focus-visible {
  outline-offset: -2px;
}

.kf-menu__item--danger,
.kf-menu__item--danger:hover,
.kf-menu__item--danger:focus {
  color: var(--kf-danger);
}

.kf-menu__item[aria-disabled='true'] {
  opacity: 0.5;
  cursor: not-allowed;
}

.kf-menu__icon {
  display: inline-flex;
  justify-content: center;
  width: 1.25em;
  color: var(--kf-text-muted);
}

.kf-menu__item--danger .kf-menu__icon {
  color: inherit;
}

@media (pointer: coarse) {
  .kf-menu__item {
    min-height: var(--kf-target);
  }
}

/* ---- SlideOver ------------------------------------------------------------------------------------------- */
/* Centred over the page, as the legacy modals were (user decision, 2026-10-06): the page dims behind it, the body
   scrolls inside, the header and the footer stay put. */
.kf-slideover {
  position: fixed;
  inset: 0;
  z-index: var(--kf-z-dialog);
  display: grid;
  place-items: center;
  padding: var(--kf-space-6) var(--kf-space-4);
}

.kf-slideover__backdrop {
  position: absolute;
  inset: 0;
  background-color: var(--kf-backdrop);
  animation: kf-fade var(--kf-duration) var(--kf-ease);
}

.kf-slideover__panel {
  position: relative;
  display: flex;
  flex-direction: column;
  width: min(560px, 100%);
  max-height: calc(100dvh - 2 * var(--kf-space-6));
  border-radius: var(--kf-radius-card);
  background-color: var(--kf-surface-raised);
  color: var(--kf-text);
  box-shadow: var(--kf-shadow-float);
  animation: kf-pop var(--kf-duration) var(--kf-ease);
}

.kf-slideover__panel--lg {
  width: min(800px, 100%);
}

@media (max-width: 599px) {
  .kf-slideover {
    padding: var(--kf-space-2);
  }

  .kf-slideover__panel {
    max-height: calc(100dvh - 2 * var(--kf-space-2));
  }
}

.kf-slideover__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--kf-space-3);
  padding: var(--kf-space-4) var(--kf-space-5);
  border-bottom: 1px solid var(--kf-border);
}

/* The close button keeps its touch width: a long heading beside it wraps, the button does not shrink. */
.kf-slideover__header > .kf-btn {
  flex: none;
}

.kf-slideover__title {
  margin: 0;
  font-size: var(--kf-text-lg);
  font-weight: 600;
}

/* With content under the title, the header's line is drawn under that content instead. */
.kf-slideover__header--summary {
  padding-bottom: 0;
  border-bottom: 0;
}

.kf-slideover__scroll {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-height: 0;
}

.kf-slideover__summary {
  flex: none;
  padding: 0 var(--kf-space-5) var(--kf-space-4);
  border-bottom: 1px solid var(--kf-border);
}

.kf-slideover__body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: var(--kf-space-5);
}

/* A phone has little height: only the title and × stay, the content under the title scrolls with the body. The
   bottom padding moves to the scrolling part, so what sticks to the body's bottom (the comment box) stays flush. */
@media (max-width: 599px) {
  .kf-slideover__scroll {
    overflow-y: auto;
    padding-bottom: var(--kf-space-5);
  }

  .kf-slideover__body {
    flex: none;
    min-height: auto;
    overflow: visible;
    padding-bottom: 0;
  }
}

.kf-slideover__footer {
  display: flex;
  justify-content: flex-end;
  gap: var(--kf-space-2);
  padding: var(--kf-space-3) var(--kf-space-5);
  border-top: 1px solid var(--kf-border);
}

@keyframes kf-pop {
  from {
    transform: translateY(8px) scale(0.98);
    opacity: 0;
  }
}

@keyframes kf-fade {
  from {
    opacity: 0;
  }
}

/* ---- Toast ----------------------------------------------------------------------------------------------- */
.kf-toasts {
  position: fixed;
  right: var(--kf-space-5);
  bottom: calc(var(--kf-space-5) + var(--kf-shell-bottom, 0px));
  z-index: var(--kf-z-toast);
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: var(--kf-space-2);
  max-width: calc(100vw - 2 * var(--kf-space-4));
  pointer-events: none;
}

.kf-toast {
  display: flex;
  align-items: center;
  gap: var(--kf-space-3);
  width: 380px;
  max-width: 100%;
  padding: var(--kf-space-3) var(--kf-space-3) var(--kf-space-3)
    var(--kf-space-4);
  border: 1px solid var(--kf-border);
  border-left: 4px solid var(--kf-accent);
  border-radius: var(--kf-radius-control);
  background-color: var(--kf-surface-raised);
  color: var(--kf-text);
  box-shadow: var(--kf-shadow-float);
  pointer-events: auto;
  animation: kf-toast-in var(--kf-duration) var(--kf-ease);
}

.kf-toast--error {
  border-left-color: var(--kf-danger);
}

.kf-toast__icon {
  color: var(--kf-accent);
}

.kf-toast--error .kf-toast__icon {
  color: var(--kf-danger);
}

.kf-toast__text {
  flex: 1;
  font-size: var(--kf-text-sm);
}

.kf-toast__action {
  font-size: var(--kf-text-sm);
  font-weight: 600;
  white-space: nowrap;
}

.kf-toast__close {
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: var(--kf-radius-control);
  background: transparent;
  color: var(--kf-text-muted);
}

.kf-toast__close:hover {
  background-color: var(--kf-surface-sunken);
  color: var(--kf-text);
}

/* On a phone the bottom of the screen is where the thumb acts (the tab bar, a form's action bar, a panel's write
   box, Ship, Add to the warehouse): a toast there covered them, an error one until closed. It comes down from the
   top instead, over the top bar. */
@media (max-width: 599px) {
  .kf-toasts {
    top: calc(env(safe-area-inset-top, 0px) + var(--kf-space-2));
    right: var(--kf-space-4);
    bottom: auto;
    left: var(--kf-space-4);
    align-items: stretch;
  }

  .kf-toast {
    width: auto;
    animation-name: kf-toast-down;
  }
}

@keyframes kf-toast-down {
  from {
    transform: translateY(-8px);
    opacity: 0;
  }
}

@keyframes kf-toast-in {
  from {
    transform: translateY(8px);
    opacity: 0;
  }
}

/* ---- FormLayout, FormSection, ActionBar ------------------------------------------------------------------ */
.kf-form {
  max-width: var(--kf-form-max);
}

.kf-form--narrow {
  max-width: var(--kf-form-narrow);
}

@media (min-width: 1280px) {
  .kf-form--two {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0 var(--kf-space-6);
    max-width: var(--kf-content-max);
  }

  .kf-form--two > .kf-action-bar {
    grid-column: 1 / -1;
  }
}

.kf-form-section {
  margin-bottom: var(--kf-space-5);
  padding: var(--kf-space-5);
  border: 1px solid var(--kf-border);
  border-radius: var(--kf-radius-card);
  background-color: var(--kf-surface);
}

.kf-form-section__header {
  margin-bottom: var(--kf-space-4);
}

.kf-form-section__title {
  margin: 0;
  font-size: var(--kf-text-lg);
  font-weight: 600;
}

.kf-form-section__description {
  margin: var(--kf-space-1) 0 0;
  color: var(--kf-text-muted);
  font-size: var(--kf-text-sm);
}

.kf-form-section__body > .form-group:last-child {
  margin-bottom: 0;
}

.kf-action-bar {
  position: sticky;
  bottom: var(--kf-shell-bottom, 0px);
  z-index: var(--kf-z-sticky);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: var(--kf-space-2) var(--kf-space-4);
  margin: var(--kf-space-4) calc(-1 * var(--kf-space-2)) 0;
  padding: var(--kf-space-3) var(--kf-space-2);
  border-top: 1px solid var(--kf-border);
  background-color: var(--kf-bg);
}

.kf-action-bar--static {
  position: static;
}

.kf-action-bar__status {
  margin-right: auto;
  color: var(--kf-text-muted);
  font-size: var(--kf-text-sm);
}

.kf-action-bar__buttons {
  display: flex;
  gap: var(--kf-space-2);
}

@media (max-width: 599px) {
  /* Side by side while they fit, one under the other when a label is long (Spanish): never wider than the phone. */
  .kf-action-bar__buttons {
    flex-wrap: wrap;
    width: 100%;
  }

  .kf-action-bar__buttons > * {
    flex: 1 1 auto;
  }
}

/* ---- PasswordField --------------------------------------------------------------------------------------- */
.kf-password__control {
  position: relative;
}

.kf-password__control .form-control {
  padding-right: 3rem;
}

.kf-password__toggle {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 44px;
  border: 0;
  border-radius: 0 var(--kf-radius-control) var(--kf-radius-control) 0;
  background: transparent;
  color: var(--kf-text-muted);
}

.kf-password__toggle:hover,
.kf-password__toggle[aria-pressed='true'] {
  color: var(--kf-text);
}

.kf-password__caps {
  min-height: 1.25rem;
  margin-top: var(--kf-space-1);
  color: var(--kf-warning-text);
  font-size: var(--kf-text-label);
  font-weight: 500;
}

/* ---- ScanInput ------------------------------------------------------------------------------------------- */
.kf-scan-input__control {
  position: relative;
}

.kf-scan-input__icon {
  position: absolute;
  top: 50%;
  left: var(--kf-space-3);
  transform: translateY(-50%);
  color: var(--kf-text-muted);
  pointer-events: none;
}

.kf-scan-input .form-control {
  padding-left: 2.5rem;
  font-family: var(--kf-font-mono);
}

.kf-scan-input--lg .form-control {
  height: 52px;
  font-size: var(--kf-text-lg);
}

/* ---- CameraScanner --------------------------------------------------------------------------------------- */
.kf-camera {
  display: grid;
  gap: var(--kf-space-2);
}

.kf-camera__viewport {
  position: relative;
  overflow: hidden;
  aspect-ratio: 4 / 3;
  max-height: 60vh;
  border-radius: var(--kf-radius-card);
  background-color: var(--kf-sidebar);
}

.kf-camera__viewport[hidden] {
  display: none;
}

.kf-camera__video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.kf-camera__guide {
  position: absolute;
  inset: 25% 12%;
  border: 2px solid var(--kf-sidebar-active);
  border-radius: var(--kf-radius-control);
  box-shadow: 0 0 0 100vmax var(--kf-backdrop);
}

.kf-camera__bar {
  display: flex;
  flex-wrap: wrap;
  gap: var(--kf-space-2);
}

.kf-camera__status {
  min-height: 1.25rem;
  margin: 0;
  color: var(--kf-text-muted);
  font-size: var(--kf-text-sm);
}

.kf-camera__status--note:not(:empty) {
  padding: var(--kf-space-2) var(--kf-space-3);
  border-left: 3px solid var(--kf-warning);
  border-radius: 4px;
  background-color: var(--kf-warning-soft);
  color: var(--kf-text);
}

.kf-menu__header {
  margin-bottom: var(--kf-space-1);
  padding: var(--kf-space-2) var(--kf-space-3);
  border-bottom: 1px solid var(--kf-border);
  font-size: var(--kf-text-sm);
}

/* App-wide layout rules. Colours, type and Bootstrap's look come from shared/ui/styles (tokens + overrides). */
html,
body {
  height: 100%;
}

/* The legacy row tints (the getting-ready screen and the order statuses use them), on the tokens. */
.row-selected-success {
  background-color: var(--kf-accent-soft);
}

.row-selected-warning {
  background-color: var(--kf-warning-soft);
}

.row-selected-danger {
  background-color: var(--kf-danger-soft);
}

/* The filter kit (docs/pdr/prd-shops-settings.md, "Screen proposals" 1): the filter row, its buttons and panels, the
   active-filter chips, the phone's bottom sheet and the pager. Tokens only. */

/* ---- The filter row ------------------------------------------------------------------------------------- */
.kf-table .kf-table__filters td {
  height: auto;
  padding: var(--kf-space-1) var(--kf-space-2);
  border-top: 1px solid var(--kf-border);
  background-color: var(--kf-surface-sunken);
}

.kf-filter-text {
  min-width: 96px;
  height: 32px;
  padding: 0 var(--kf-space-2);
  font-size: var(--kf-text-sm);
}

.kf-filter-button {
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--kf-space-2);
  width: 100%;
  min-width: 96px;
  min-height: 32px;
  padding: 0 var(--kf-space-2);
  border: 1px solid var(--kf-border-strong);
  border-radius: var(--kf-radius-control);
  background-color: var(--kf-surface);
  color: var(--kf-text-muted);
  font-size: var(--kf-text-sm);
  text-align: left;
  white-space: nowrap;
  cursor: pointer;
}

.kf-filter-button:hover {
  background-color: var(--kf-surface-sunken);
}

.kf-filter-button:focus-visible {
  outline: 2px solid var(--kf-focus);
  outline-offset: 1px;
}

.kf-filter-button.is-active {
  border-color: var(--kf-accent);
  background-color: var(--kf-accent-soft);
  color: var(--kf-text);
  font-weight: 500;
}

.kf-filter-button__label {
  overflow: hidden;
  text-overflow: ellipsis;
}

.kf-filter-button .fas {
  font-size: 0.75em;
  opacity: 0.7;
}

@media (pointer: coarse) {
  .kf-filter-text,
  .kf-filter-button {
    min-height: var(--kf-target);
  }
}

/* ---- The panel a filter button opens -------------------------------------------------------------------- */
.kf-filter-popover {
  position: fixed;
  z-index: var(--kf-z-popover);
  min-width: 240px;
  max-width: min(360px, calc(100vw - 16px));
  max-height: min(420px, 70vh);
  overflow-y: auto;
  border: 1px solid var(--kf-border);
  border-radius: var(--kf-radius-card);
  background-color: var(--kf-surface-raised);
  box-shadow: var(--kf-shadow-float);
  color: var(--kf-text);
}

.kf-filter-panel {
  display: flex;
  flex-direction: column;
  gap: var(--kf-space-3);
  padding: var(--kf-space-3);
}

.kf-filter-panel__footer {
  display: flex;
  justify-content: flex-end;
  border-top: 1px solid var(--kf-border);
  padding-top: var(--kf-space-2);
}

.kf-filter-checklist {
  display: flex;
  flex-direction: column;
  margin: 0;
  padding: 0;
  border: 0;
}

.kf-filter-checklist__option {
  display: flex;
  align-items: center;
  gap: var(--kf-space-2);
  min-height: 36px;
  margin: 0;
  padding: 0 var(--kf-space-2);
  border-radius: var(--kf-radius-control);
  font-size: var(--kf-text-sm);
  cursor: pointer;
}

.kf-filter-checklist__option:hover {
  background-color: var(--kf-surface-sunken);
}

.kf-filter-checklist__label {
  flex: 1 1 auto;
}

.kf-filter-checklist__count {
  color: var(--kf-text-muted);
  font-variant-numeric: tabular-nums;
}

.kf-filter-empty {
  margin: 0;
  color: var(--kf-text-muted);
  font-size: var(--kf-text-sm);
}

.kf-filter-quick {
  display: flex;
  flex-wrap: wrap;
  gap: var(--kf-space-2);
}

.kf-filter-dates__fields,
.kf-filter-range__fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--kf-space-2);
}

.kf-filter-dates,
.kf-filter-range {
  display: flex;
  flex-direction: column;
  gap: var(--kf-space-3);
}

.kf-filter-field {
  display: flex;
  flex-direction: column;
  gap: var(--kf-space-1);
  margin: 0;
}

.kf-filter-field__label {
  color: var(--kf-text-muted);
  font-size: var(--kf-text-label);
  font-weight: 500;
}

@media (pointer: coarse) {
  .kf-filter-checklist__option,
  .kf-filter-field .form-control {
    min-height: var(--kf-target);
  }
}

/* ---- The active filters above the table ----------------------------------------------------------------- */
.kf-data-table__filters {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--kf-space-2);
  margin-bottom: var(--kf-space-3);
}

.kf-data-table__filters:empty {
  display: none;
}

.kf-active-filters {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--kf-space-2);
}

.kf-active-filters__chip {
  display: inline-flex;
  align-items: center;
  gap: var(--kf-space-1);
  min-height: 32px;
  padding: 0 var(--kf-space-1) 0 var(--kf-space-3);
  border: 1px solid var(--kf-accent);
  border-radius: var(--kf-radius-pill);
  background-color: var(--kf-accent-soft);
  color: var(--kf-text);
  font-size: var(--kf-text-sm);
}

.kf-active-filters__text {
  max-width: 280px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.kf-active-filters__remove {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  border: 0;
  border-radius: var(--kf-radius-pill);
  background: transparent;
  color: var(--kf-text-muted);
  cursor: pointer;
}

.kf-active-filters__remove:hover {
  background-color: var(--kf-surface);
  color: var(--kf-text);
}

@media (pointer: coarse) {
  .kf-active-filters__chip {
    min-height: var(--kf-target);
  }

  .kf-active-filters__remove {
    width: var(--kf-target);
    height: var(--kf-target);
  }
}

.kf-filters-button.is-active {
  border-color: var(--kf-accent);
  background-color: var(--kf-accent-soft);
}

/* ---- The pager -------------------------------------------------------------------------------------------- */
.kf-pager {
  flex-wrap: wrap;
}

.kf-pager__size {
  display: inline-flex;
  align-items: center;
  gap: var(--kf-space-2);
  margin: 0;
  color: var(--kf-text-muted);
  font-size: var(--kf-text-sm);
}

.kf-pager__size select {
  width: auto;
}

@media (pointer: coarse) {
  .kf-pager .kf-btn,
  .kf-pager__size select {
    min-height: var(--kf-target);
  }
}

/* ---- The phone's bottom sheet ------------------------------------------------------------------------------ */
.kf-sheet {
  position: fixed;
  inset: 0;
  z-index: var(--kf-z-dialog);
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
}

.kf-sheet__backdrop {
  position: absolute;
  inset: 0;
  background-color: var(--kf-backdrop);
  animation: kf-fade var(--kf-duration) var(--kf-ease);
}

.kf-sheet__panel {
  position: relative;
  display: flex;
  flex-direction: column;
  max-height: 88dvh;
  border-radius: var(--kf-radius-card) var(--kf-radius-card) 0 0;
  background-color: var(--kf-surface-raised);
  box-shadow: var(--kf-shadow-float);
  color: var(--kf-text);
  animation: kf-sheet-in var(--kf-duration) var(--kf-ease);
}

.kf-sheet__panel:focus {
  outline: none;
}

@keyframes kf-sheet-in {
  from {
    transform: translateY(24px);
    opacity: 0;
  }
}

.kf-sheet__handle {
  width: 40px;
  height: 4px;
  margin: var(--kf-space-2) auto 0;
  border-radius: var(--kf-radius-pill);
  background-color: var(--kf-border-strong);
}

.kf-sheet__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--kf-space-2) var(--kf-space-4);
  border-bottom: 1px solid var(--kf-border);
}

.kf-sheet__title {
  margin: 0;
  font-size: var(--kf-text-lg);
  font-weight: 600;
}

.kf-sheet__body {
  flex: 1 1 auto;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: var(--kf-space-2) var(--kf-space-4);
}

.kf-sheet__sort {
  display: flex;
  flex-direction: column;
  gap: var(--kf-space-1);
  margin: var(--kf-space-2) 0 var(--kf-space-3);
}

.kf-sheet__sort select {
  min-height: var(--kf-target);
}

.kf-sheet__section {
  border-top: 1px solid var(--kf-border);
}

.kf-sheet__section-toggle {
  display: flex;
  align-items: center;
  gap: var(--kf-space-2);
  width: 100%;
  min-height: var(--kf-target);
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--kf-text);
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.kf-sheet__section-label {
  font-weight: 600;
}

.kf-sheet__section-summary {
  flex: 1 1 auto;
  overflow: hidden;
  color: var(--kf-text-muted);
  font-size: var(--kf-text-sm);
  text-align: right;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.kf-sheet__section-toggle .fas {
  margin-left: auto;
  color: var(--kf-text-muted);
}

.kf-sheet__section-summary + .fas {
  margin-left: 0;
}

.kf-sheet__section-body {
  padding-bottom: var(--kf-space-3);
}

.kf-sheet__section-body .kf-filter-checklist__option,
.kf-sheet__section-body .form-control,
.kf-sheet__section-body .kf-chip {
  min-height: var(--kf-target);
}

.kf-sheet__footer {
  position: sticky;
  bottom: 0;
  display: flex;
  gap: var(--kf-space-2);
  padding: var(--kf-space-3) var(--kf-space-4)
    calc(var(--kf-space-3) + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid var(--kf-border);
  background-color: var(--kf-surface-raised);
}

.kf-sheet__apply {
  flex: 1 1 auto;
}

/* A server-mode table filtered to nothing keeps its header and filter row; the empty state is its one body row. */
.kf-table tbody tr.kf-table__empty-row,
.kf-table tbody tr.kf-table__empty-row:hover {
  background-color: transparent;
  cursor: default;
}

.kf-table td.kf-table__empty {
  padding: 0;
  white-space: normal;
}

/* Sign in: the olive brand panel and the form side by side from 900 px, one column below. */
.kf-login {
  display: grid;
  grid-template-columns: minmax(320px, 5fr) 7fr;
  min-height: 100vh;
  min-height: 100dvh;
  background-color: var(--kf-bg);
}

.kf-login__brand {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: var(--kf-space-3);
  padding: var(--kf-space-8);
  background-color: var(--kf-sidebar);
  color: var(--kf-sidebar-text);
}

.kf-login__name {
  margin: var(--kf-space-3) 0 0;
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.kf-login__tagline {
  max-width: 32ch;
  margin: 0;
  color: var(--kf-sidebar-muted);
}

.kf-login__panel {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--kf-space-6) var(--kf-space-4);
}

.kf-login__card {
  width: 100%;
  max-width: 400px;
}

.kf-login__mark-small {
  display: none;
  margin-bottom: var(--kf-space-4);
}

.kf-login__title {
  margin-bottom: var(--kf-space-5);
  font-size: var(--kf-text-title);
}

.kf-login__error {
  display: flex;
  align-items: flex-start;
  gap: var(--kf-space-2);
  margin-bottom: var(--kf-space-3);
  padding: var(--kf-space-2) var(--kf-space-3);
  border-left: 3px solid var(--kf-danger);
  border-radius: 4px;
  background-color: var(--kf-danger-soft);
  color: var(--kf-text);
  font-size: var(--kf-text-sm);
}

.kf-login__error i {
  margin-top: 3px;
  color: var(--kf-danger);
}

.kf-login__submit {
  width: 100%;
}

.kf-login__language {
  display: flex;
  justify-content: center;
  margin-top: var(--kf-space-5);
}

@media (max-width: 899px) {
  .kf-login {
    grid-template-columns: 1fr;
  }

  .kf-login__brand {
    display: none;
  }

  .kf-login__mark-small {
    display: block;
  }

  .kf-login__panel {
    align-items: flex-start;
    padding-top: var(--kf-space-8);
  }
}

/* On a touch screen "Remember me" is a 44 px target, like every other control. */
@media (pointer: coarse) {
  .kf-login .form-check-label {
    display: inline-flex;
    align-items: center;
    min-height: var(--kf-target);
  }

  .kf-login .form-check-input {
    top: 50%;
    margin-top: 0;
    transform: translateY(-50%);
  }
}

.kf-not-found {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--kf-space-3);
  padding: var(--kf-space-8) var(--kf-space-4);
  text-align: center;
}

.kf-not-found__title {
  margin: var(--kf-space-2) 0 0;
  font-size: var(--kf-text-title);
}

.kf-not-found__body {
  margin: 0 0 var(--kf-space-2);
  color: var(--kf-text-muted);
}

/* The shell: sidebar or rail from 1024 px, drawer and bottom tab bar below; the top bar; the content's width. */
.kf-shell {
  --kf-toolbar-top: var(--kf-topbar-height);

  display: flex;
  min-height: 100vh;
  min-height: 100dvh;
}

.kf-skip {
  position: absolute;
  top: var(--kf-space-2);
  left: var(--kf-space-2);
  z-index: var(--kf-z-toast);
  padding: var(--kf-space-2) var(--kf-space-4);
  border-radius: var(--kf-radius-control);
  background-color: var(--kf-accent);
  color: var(--kf-on-accent);
  font-weight: 600;
  transform: translateY(-200%);
}

.kf-skip:focus {
  color: var(--kf-on-accent);
  transform: none;
}

/* ---- Sidebar --------------------------------------------------------------------------------------------- */
.kf-sidebar {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  flex: 0 0 var(--kf-sidebar-width);
  width: var(--kf-sidebar-width);
  height: 100vh;
  height: 100dvh;
  background-color: var(--kf-sidebar);
  color: var(--kf-sidebar-text);
  transition:
    width var(--kf-duration) var(--kf-ease),
    flex-basis var(--kf-duration) var(--kf-ease);
}

.kf-shell--rail .kf-sidebar {
  flex-basis: var(--kf-rail-width);
  width: var(--kf-rail-width);
}

.kf-brand {
  display: flex;
  align-items: center;
  gap: var(--kf-space-3);
  height: var(--kf-topbar-height);
  padding: 0 var(--kf-space-4);
  color: var(--kf-sidebar-text);
  font-weight: 600;
  letter-spacing: -0.01em;
  white-space: nowrap;
}

.kf-brand:hover {
  color: var(--kf-sidebar-text);
  text-decoration: none;
}

.kf-brand__mark {
  flex: 0 0 auto;
}

.kf-sidebar__nav {
  flex: 1;
  overflow-y: auto;
  padding: var(--kf-space-2) 0;
}

.kf-nav-group + .kf-nav-group {
  margin-top: var(--kf-space-3);
}

.kf-nav-group__label {
  margin: 0;
  padding: var(--kf-space-2) var(--kf-space-4) var(--kf-space-1);
  color: var(--kf-sidebar-muted);
  font-size: var(--kf-text-label);
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.kf-nav-group__list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.kf-nav-link {
  position: relative;
  display: flex;
  align-items: center;
  gap: var(--kf-space-3);
  min-height: 40px;
  margin: 1px var(--kf-space-2);
  padding: var(--kf-space-2) var(--kf-space-3);
  border-radius: var(--kf-radius-control);
  color: var(--kf-sidebar-text);
  font-size: var(--kf-text-sm);
  font-weight: 500;
  line-height: 1.3;
}

/* A long label ("Cargar una hoja de existencias") wraps to a second line rather than being cut. */
.kf-nav-link span {
  min-width: 0;
  overflow-wrap: anywhere;
}

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

.kf-nav-link i {
  flex: none;
  color: var(--kf-sidebar-muted);
}

.kf-nav-link[aria-current='page'] {
  background-color: var(--kf-sidebar-hover);
  color: var(--kf-sidebar-active);
}

.kf-nav-link[aria-current='page'] i {
  color: var(--kf-sidebar-active);
}

.kf-nav-link[aria-current='page']::before {
  content: '';
  position: absolute;
  top: 8px;
  bottom: 8px;
  left: calc(-1 * var(--kf-space-2));
  width: 3px;
  border-radius: 0 3px 3px 0;
  background-color: var(--kf-sidebar-active);
}

.kf-shell--rail .kf-nav-link {
  justify-content: center;
  padding: 0;
}

.kf-shell--rail .kf-brand {
  justify-content: center;
  padding: 0;
}

.kf-sidebar__collapse {
  display: flex;
  align-items: center;
  gap: var(--kf-space-3);
  min-height: 44px;
  margin: var(--kf-space-2);
  padding: 0 var(--kf-space-3);
  border: 0;
  border-radius: var(--kf-radius-control);
  background: transparent;
  color: var(--kf-sidebar-muted);
  font-size: var(--kf-text-sm);
}

.kf-shell--rail .kf-sidebar__collapse {
  justify-content: center;
  padding: 0;
}

.kf-sidebar__collapse:hover {
  background-color: var(--kf-sidebar-hover);
  color: var(--kf-sidebar-text);
}

.kf-sidebar :focus-visible {
  outline-color: var(--kf-sidebar-active);
}

/* ---- Body, top bar --------------------------------------------------------------------------------------- */
.kf-shell__body {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
}

.kf-topbar {
  position: sticky;
  top: 0;
  z-index: calc(var(--kf-z-sticky) + 1);
  display: flex;
  align-items: center;
  gap: var(--kf-space-2);
  height: var(--kf-topbar-height);
  padding: 0 var(--kf-space-5);
  border-bottom: 1px solid var(--kf-border);
  background-color: var(--kf-surface);
}

.kf-topbar__end {
  display: flex;
  align-items: center;
  gap: var(--kf-space-2);
  margin-left: auto;
}

.kf-topbar__icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: var(--kf-radius-control);
  background: transparent;
  color: var(--kf-text);
}

.kf-topbar__icon:hover,
.kf-topbar__icon[aria-expanded='true'] {
  background-color: var(--kf-surface-sunken);
  color: var(--kf-text);
}

.kf-topbar__mark {
  flex: 0 0 auto;
}

.kf-topbar__title {
  min-width: 0;
  overflow: hidden;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.kf-topbar__account {
  display: inline-flex;
  align-items: center;
  gap: var(--kf-space-2);
  height: 40px;
  padding: 0 var(--kf-space-2) 0 var(--kf-space-1);
  border: 0;
  border-radius: var(--kf-radius-control);
  background: transparent;
  color: var(--kf-text);
  font-size: var(--kf-text-sm);
  font-weight: 500;
}

.kf-topbar__account:hover,
.kf-topbar__account[aria-expanded='true'] {
  background-color: var(--kf-surface-sunken);
}

.kf-topbar__account .fa-chevron-down {
  color: var(--kf-text-muted);
  font-size: 0.7em;
}

/* Touch screens: the top bar's buttons are 44 px targets. */
@media (pointer: coarse) {
  .kf-topbar__icon {
    width: var(--kf-target);
    height: var(--kf-target);
  }

  .kf-topbar__account {
    min-width: var(--kf-target);
    height: var(--kf-target);
  }
}

.kf-topbar__avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background-color: var(--kf-accent-soft);
  color: var(--kf-link);
  font-size: var(--kf-text-label);
  font-weight: 700;
}

.kf-topbar__menu-user {
  font-weight: 600;
}

.kf-topbar__menu-email {
  color: var(--kf-text-muted);
  overflow-wrap: anywhere;
}

/* ---- Content --------------------------------------------------------------------------------------------- */
.kf-main {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
}

.kf-main:focus {
  outline: none;
}

.kf-main__inner {
  flex: 1;
  width: 100%;
  max-width: calc(var(--kf-content-max) + 2 * var(--kf-space-6));
  margin: 0 auto;
  padding: var(--kf-space-6);
  min-width: 0;
}

.kf-main__footer {
  padding: var(--kf-space-4);
  color: var(--kf-text-muted);
  font-size: var(--kf-text-label);
  text-align: center;
}

/* What sticks to the window's edges is kept clear when the browser brings something into view (a focused field, a
   menu reached with Tab, scrollIntoView): the top bar, the phone's tab bar and a form's sticky action bar (ActionBar
   sets its height). */
html {
  scroll-padding-top: var(--kf-topbar-height);
  scroll-padding-bottom: calc(
    var(--kf-tabbar-space, 0px) + var(--kf-action-bar-height, 0px) +
      var(--kf-floating-bar-height, 0px)
  );
}

html:has(> body.kf-has-tabbar) {
  --kf-tabbar-space: calc(
    var(--kf-tabbar-height) + env(safe-area-inset-bottom, 0px)
  );
}

/* ---- Phones and tablets ---------------------------------------------------------------------------------- */
body.kf-has-tabbar {
  --kf-shell-bottom: calc(
    var(--kf-tabbar-height) + env(safe-area-inset-bottom, 0px)
  );
}

.kf-shell--compact .kf-topbar {
  padding: 0 var(--kf-space-2);
}

.kf-shell--compact .kf-topbar__name {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.kf-shell--compact .kf-topbar__account .fa-chevron-down {
  display: none;
}

.kf-shell--compact .kf-topbar__end {
  gap: var(--kf-space-1);
}

.kf-shell--compact .kf-main__inner {
  padding: var(--kf-space-4) var(--kf-space-4)
    calc(
      var(--kf-space-4) + var(--kf-shell-bottom, 0px) +
        var(--kf-floating-bar-height, 0px)
    );
}

@media (max-width: 599px) {
  .kf-shell--compact .kf-main__footer {
    display: none;
  }
}

/* On a phone the top bar's buttons leave its title a letter or two ("P…"): the page's own heading names it. */
@media (max-width: 479px) {
  .kf-shell--compact .kf-topbar__title {
    display: none;
  }
}

.kf-tabbar {
  position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: calc(var(--kf-z-sticky) + 1);
  display: flex;
  height: calc(var(--kf-tabbar-height) + env(safe-area-inset-bottom, 0px));
  padding-bottom: env(safe-area-inset-bottom, 0px);
  border-top: 1px solid var(--kf-border);
  background-color: var(--kf-surface);
}

.kf-tabbar__item {
  display: flex;
  flex: 1;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-width: 0;
  border: 0;
  background: transparent;
  color: var(--kf-text-muted);
  font-size: var(--kf-text-label);
  font-weight: 500;
}

.kf-tabbar__item span {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.kf-tabbar__item i {
  font-size: 1.15rem;
}

.kf-tabbar__item:hover {
  color: var(--kf-text);
  text-decoration: none;
}

.kf-tabbar__item[aria-current='page'] {
  color: var(--kf-link);
  font-weight: 600;
}

.kf-drawer {
  position: fixed;
  inset: 0;
  z-index: var(--kf-z-drawer);
}

.kf-drawer__backdrop {
  position: absolute;
  inset: 0;
  background-color: var(--kf-backdrop);
  animation: kf-fade var(--kf-duration) var(--kf-ease);
}

.kf-drawer__panel {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  display: flex;
  flex-direction: column;
  width: min(300px, 86vw);
  background-color: var(--kf-sidebar);
  color: var(--kf-sidebar-text);
  box-shadow: var(--kf-shadow-float);
  animation: kf-drawer-in var(--kf-duration) var(--kf-ease);
}

.kf-drawer__panel:focus {
  outline: none;
}

.kf-drawer__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-right: var(--kf-space-2);
}

.kf-drawer__header .kf-topbar__icon {
  color: var(--kf-sidebar-text);
}

.kf-drawer__header .kf-topbar__icon:hover {
  background-color: var(--kf-sidebar-hover);
}

.kf-drawer .kf-nav-link {
  min-height: var(--kf-target);
}

.kf-drawer :focus-visible {
  outline-color: var(--kf-sidebar-active);
}

@keyframes kf-drawer-in {
  from {
    transform: translateX(-24px);
    opacity: 0;
  }
}

/* ---- The shell's skeleton (while the session is asked) --------------------------------------------------- */
.kf-shell-skeleton .kf-sidebar {
  position: static;
}

@media (max-width: 1023px) {
  .kf-shell-skeleton .kf-sidebar {
    display: none;
  }
}

