/* ==========================================================================================================
   Bulganprint design system — app.css (owner: web-shell). Documentation with copy-paste snippets: design/UI-KIT.md;
   every component rendered live on /dev/ui-kit (Development only).
   Rules: mobile-first (min-width queries at 600 / 720 / 1024 / 1280), no inline styles anywhere (CSP style-src 'self'),
   page-specific CSS goes to wwwroot/css/pages/<page>.css — never here.

    1  tokens                     10  alerts, toasts              19  public layout (header, drawer, footer)
    2  reset + base               11  dialog, drawer              20  admin layout (sidebar, topbar, page head)
    3  typography                 12  tabs, pager                 21  auth (login) + error page
    4  layout utilities           13  stepper, timeline           22  catalog pieces (category + template cards)
    5  buttons                    14  kpi tiles                   23  commerce pieces (price, summary, copy field)
    6  forms                      15  empty state                 24  htmx, loading, motion
    7  segmented, choice, qty     16  key/value, lists            25  print
    8  chips, badges              17  menus, avatar
    9  cards, tables              18  utilities
   ========================================================================================================== */

/* 1 ─ tokens ───────────────────────────────────────────────────────────────────────────────────────────── */
:root {
  color-scheme: light;

  /* brand (CONTRACTS §7) */
  --c-primary: #1F4FD8;
  --c-primary-hover: #1A43B8;
  --c-primary-active: #163A9E;
  --c-primary-50: #EEF3FE;
  --c-primary-100: #DCE6FC;
  --c-primary-200: #B9CCF8;
  --c-primary-300: #8FADF3;

  /* ink + surfaces */
  --c-ink: #0F172A;
  --c-ink-2: #334155;
  --c-muted: #5B6B82;          /* 5.4:1 on white, 5.1:1 on the page colour */
  --c-faint: #8B98AD;          /* placeholders and decoration only */
  --c-surface: #FFFFFF;
  --c-page: #F6F7FB;
  --c-subtle: #F1F4F9;
  --c-subtle-2: #E9EDF4;
  --c-border: #E3E7EF;
  --c-border-strong: #CBD3E1;
  --c-navy: #0F172A;
  --c-navy-2: #16213A;

  /* status: solid colour · tinted background · border · text on the tint (AA on its tint) */
  --c-success: #12805C;  --c-success-bg: #E7F5EF; --c-success-border: #B9E2CF; --c-success-text: #0B6B4C;
  --c-warn: #B25E09;     --c-warn-bg: #FDF3E4;    --c-warn-border: #F3D5A8;    --c-warn-text: #8F4B06;
  --c-danger: #C0362C;   --c-danger-bg: #FCECEA;  --c-danger-border: #F3C4BF;  --c-danger-text: #A12D24;
  --c-info: #1F4FD8;     --c-info-bg: #EEF3FE;    --c-info-border: #CAD8FA;    --c-info-text: #1A43B8;
  --c-done-bg: #EEF1F5;  --c-done-border: #DCE2EA; --c-done-text: #334155;
  --c-muted-bg: #F1F3F7; --c-muted-border: #E3E7EF; --c-muted-text: #5B6B82;

  /* category accents (thumbnails, category cards): [data-cat="ORG"] … */
  --cat-org: #1F4FD8; --cat-med: #0E8A7B; --cat-sch: #6D4BD1; --cat-kg: #D9731F;
  --cat-pol: #1E3A8A; --cat-crt: #8A5A2B; --cat-gov: #0F766E; --cat-spc: #B4235A;

  /* type */
  --font: "Segoe UI", Roboto, "Noto Sans", "Helvetica Neue", Arial, sans-serif, "Segoe UI Emoji", "Apple Color Emoji", "Noto Color Emoji";
  --font-mono: ui-monospace, "Cascadia Mono", Consolas, "SF Mono", Menlo, monospace;
  --fs-xs: .75rem;  --fs-sm: .875rem;  --fs-base: 1rem;  --fs-md: 1.125rem;  --fs-lg: 1.25rem;
  --fs-xl: 1.5rem;  --fs-2xl: 1.875rem; --fs-3xl: 2.25rem; --fs-4xl: 2.75rem;

  /* space (4 px grid) */
  --s-1: 4px; --s-2: 8px; --s-3: 12px; --s-4: 16px; --s-5: 20px; --s-6: 24px; --s-8: 32px; --s-10: 40px; --s-12: 48px; --s-16: 64px;

  /* shape + depth */
  --r-sm: 6px; --r: 10px; --r-lg: 14px; --r-xl: 20px; --r-full: 999px;
  --shadow-xs: 0 1px 2px rgba(15, 23, 42, .05);
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, .06), 0 1px 3px rgba(15, 23, 42, .05);
  --shadow: 0 6px 16px -4px rgba(15, 23, 42, .10), 0 2px 4px -2px rgba(15, 23, 42, .06);
  --shadow-lg: 0 24px 48px -12px rgba(15, 23, 42, .28);
  --ring: 0 0 0 3px rgba(31, 79, 216, .28);
  --ring-danger: 0 0 0 3px rgba(192, 54, 44, .22);

  /* controls */
  --h-sm: 36px; --h: 44px; --h-lg: 52px;

  /* layout */
  --container: 1120px; --container-narrow: 720px; --gutter: 16px;
  --header-h: 64px; --topbar-h: 60px; --sidebar-w: 252px;

  --ease: cubic-bezier(.2, .8, .2, 1);
}
@media (min-width: 720px) { :root { --gutter: 24px; --header-h: 72px; } }

/* 2 ─ reset + base ─────────────────────────────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; scroll-padding-top: calc(var(--header-h) + 12px); }
body {
  margin: 0; min-height: 100vh; min-height: 100dvh;
  font-family: var(--font); font-size: var(--fs-base); line-height: 1.55; color: var(--c-ink);
  background: var(--c-page); -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}
h1, h2, h3, h4, h5, h6, p, ul, ol, dl, dd, figure, blockquote, fieldset { margin: 0; }
ul[class], ol[class] { padding: 0; list-style: none; }
fieldset { border: 0; padding: 0; min-width: 0; }
legend { padding: 0; }
img, svg, video { max-width: 100%; }
img { height: auto; }
button, input, select, textarea { font: inherit; color: inherit; }
button { -webkit-tap-highlight-color: transparent; }
a { color: var(--c-primary); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
:focus-visible { outline: 2px solid var(--c-primary); outline-offset: 2px; }
::selection { background: var(--c-primary-100); }
hr { border: 0; border-top: 1px solid var(--c-border); margin: var(--s-6) 0; }
[hidden] { display: none !important; }
main:focus { outline: none; }

.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.icon {
  width: 20px; height: 20px; flex: none; display: inline-block; vertical-align: middle;
  fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round;
}
.icon--sm { width: 16px; height: 16px; stroke-width: 2.1; }
.icon--lg { width: 24px; height: 24px; }
.icon--xl { width: 32px; height: 32px; stroke-width: 1.7; }

.skip-link {
  position: fixed; left: var(--s-4); top: var(--s-3); z-index: 100; padding: 10px 16px; border-radius: var(--r);
  background: var(--c-ink); color: #fff; font-weight: 600;
}
.skip-link:not(:focus) { width: 1px; height: 1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.skip-link:focus { text-decoration: none; }

/* 3 ─ typography ───────────────────────────────────────────────────────────────────────────────────────── */
h1, h2, h3, h4, .h1, .h2, .h3, .h4 { line-height: 1.25; font-weight: 700; letter-spacing: -.012em; color: var(--c-ink); }
.display { font-size: clamp(1.625rem, 1.25rem + 1.6vw, var(--fs-3xl)); line-height: 1.15; font-weight: 700; letter-spacing: -.02em; }
h1, .h1 { font-size: clamp(1.5rem, 1.25rem + 1vw, var(--fs-2xl)); }
h2, .h2 { font-size: clamp(1.25rem, 1.12rem + .6vw, var(--fs-xl)); }
h3, .h3 { font-size: var(--fs-md); }
h4, .h4 { font-size: var(--fs-base); }
.lead { font-size: var(--fs-md); color: var(--c-ink-2); line-height: 1.6; }
.eyebrow { font-size: var(--fs-xs); font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--c-primary); }
.prose p, .prose ul, .prose ol { margin-bottom: .85em; }
.prose p:last-child { margin-bottom: 0; }
.muted { color: var(--c-muted); }
.small { font-size: var(--fs-sm); }
.tiny { font-size: var(--fs-xs); }
.strong { font-weight: 700; }
.mono { font-family: var(--font-mono); font-size: .92em; letter-spacing: .01em; }
.num, .money { font-variant-numeric: tabular-nums; white-space: nowrap; }
.money--neg { color: var(--c-danger); }
.text-right { text-align: right; }
.text-center { text-align: center; }
.nowrap { white-space: nowrap; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.c-success { color: var(--c-success-text); } .c-warn { color: var(--c-warn-text); } .c-danger { color: var(--c-danger-text); } .c-primary { color: var(--c-primary); }

/* 4 ─ layout utilities ─────────────────────────────────────────────────────────────────────────────────── */
.container { width: 100%; max-width: calc(var(--container) + 2 * var(--gutter)); margin-inline: auto; padding-inline: var(--gutter); }
.container--narrow { max-width: calc(var(--container-narrow) + 2 * var(--gutter)); }
.page { padding-block: var(--s-6) var(--s-12); }
@media (min-width: 720px) { .page { padding-block: var(--s-8) var(--s-16); } }

.stack { display: flex; flex-direction: column; gap: var(--stack, var(--s-4)); }
.stack--xs { --stack: var(--s-1); } .stack--sm { --stack: var(--s-2); } .stack--md { --stack: var(--s-3); }
.stack--lg { --stack: var(--s-6); } .stack--xl { --stack: var(--s-8); }
.cluster { display: flex; flex-wrap: wrap; align-items: center; gap: var(--cluster, var(--s-3)); }
.cluster--sm { --cluster: var(--s-2); } .cluster--lg { --cluster: var(--s-4); }
.cluster--between { justify-content: space-between; } .cluster--end { justify-content: flex-end; } .cluster--center { justify-content: center; }
.cluster--nowrap { flex-wrap: nowrap; }
.grow { flex: 1 1 auto; min-width: 0; }

.grid { display: grid; gap: var(--grid-gap, var(--s-4)); grid-template-columns: minmax(0, 1fr); }
.grid--2, .grid--3 { grid-template-columns: minmax(0, 1fr); }
.grid--4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (min-width: 720px) { .grid--2, .grid--3 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (min-width: 1024px) { .grid--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); } .grid--4 { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.span-all { grid-column: 1 / -1; }

/* main column + sticky aside (cart, checkout, order page, admin detail) */
.split { display: grid; gap: var(--s-6); grid-template-columns: minmax(0, 1fr); align-items: start; }
@media (min-width: 1024px) {
  .split { grid-template-columns: minmax(0, 1fr) 360px; gap: var(--s-8); }
  .split--wide-aside { grid-template-columns: minmax(0, 1fr) 400px; }
  .split__aside { position: sticky; top: calc(var(--header-h) + var(--s-4)); }
  .admin .split__aside { top: calc(var(--topbar-h) + var(--s-4)); }
}

.section { padding-block: var(--s-10); }
.section + .section { padding-top: 0; }
.section__head { display: flex; align-items: end; justify-content: space-between; gap: var(--s-4); margin-bottom: var(--s-5); }
.section__title { font-size: var(--fs-xl); }
.section__sub { color: var(--c-muted); margin-top: var(--s-1); }
.section__link { display: inline-flex; align-items: center; gap: 4px; padding-block: 10px; margin-block: -10px; font-weight: 600; white-space: nowrap; }

/* 5 ─ buttons ──────────────────────────────────────────────────────────────────────────────────────────── */
.btn {
  position: relative; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: var(--h); padding: 0 18px; border: 1px solid transparent; border-radius: var(--r);
  background: var(--c-surface); color: var(--c-ink); font-weight: 600; font-size: .9375rem; line-height: 1.2;
  text-decoration: none; white-space: nowrap; cursor: pointer; user-select: none; touch-action: manipulation;
  transition: background-color .15s, border-color .15s, box-shadow .15s, color .15s, transform .05s;
}
.btn:hover { text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: none; box-shadow: var(--ring); }
.btn .icon { width: 18px; height: 18px; margin-inline: -2px; }
.btn--primary { background: var(--c-primary); color: #fff; box-shadow: 0 1px 2px rgba(31, 79, 216, .3), inset 0 1px 0 rgba(255, 255, 255, .12); }
.btn--primary:hover { background: var(--c-primary-hover); }
.btn--primary:active { background: var(--c-primary-active); }
.btn--secondary { background: var(--c-surface); border-color: var(--c-border-strong); box-shadow: var(--shadow-xs); }
.btn--secondary:hover { background: var(--c-subtle); border-color: #B7C1D2; }
.btn--ghost { background: transparent; color: var(--c-ink-2); }
.btn--ghost:hover { background: var(--c-subtle); color: var(--c-ink); }
.btn--danger { background: var(--c-danger); color: #fff; box-shadow: 0 1px 2px rgba(192, 54, 44, .3); }
.btn--danger:hover { background: #A72E25; }
.btn--danger:focus-visible { box-shadow: var(--ring-danger); }
.btn--danger-soft { background: var(--c-danger-bg); color: var(--c-danger-text); border-color: var(--c-danger-border); }
.btn--danger-soft:hover { background: #F9DEDA; }
.btn--success { background: var(--c-success); color: #fff; box-shadow: 0 1px 2px rgba(18, 128, 92, .3); }
.btn--success:hover { background: #0E6E4F; }
.btn--link { min-height: 0; padding: 6px 0; border: 0; background: none; color: var(--c-primary); box-shadow: none; }
.btn--link:hover { text-decoration: underline; text-underline-offset: 3px; background: none; }
@media (pointer: coarse), (max-width: 719.98px) { .btn--link { min-height: var(--h); } }   /* a tap target like any button */
.btn--sm { min-height: var(--h-sm); padding: 0 12px; font-size: var(--fs-sm); border-radius: 8px; gap: 6px; }
.btn--sm .icon { width: 16px; height: 16px; }
.btn--lg { min-height: var(--h-lg); padding: 0 24px; font-size: var(--fs-base); border-radius: 12px; }
.btn--block { display: flex; width: 100%; }
.btn--icon { width: var(--h); padding: 0; }
.btn--icon.btn--sm { width: var(--h-sm); }
.btn:disabled, .btn[aria-disabled="true"], .btn.is-disabled { opacity: .5; cursor: not-allowed; transform: none; pointer-events: none; }
.btn.is-loading { cursor: progress; pointer-events: none; opacity: .85; }
.btn.is-loading::before {
  content: ""; width: 16px; height: 16px; flex: none; border-radius: 50%;
  border: 2px solid currentColor; border-right-color: transparent; animation: spin .7s linear infinite;
}
@media (pointer: coarse), (max-width: 719.98px) { .btn--sm { min-height: var(--h); } .btn--icon.btn--sm { width: var(--h); } }
.btn-row { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-3); }
@media (max-width: 599.98px) { .btn-row--stack-sm { flex-direction: column-reverse; } .btn-row--stack-sm > .btn { width: 100%; } }

.icon-btn {
  display: inline-grid; place-items: center; width: var(--h); height: var(--h); flex: none;
  border: 0; border-radius: var(--r); background: transparent; color: var(--c-ink-2); cursor: pointer;
  transition: background-color .15s, color .15s;
}
.icon-btn:hover { background: var(--c-subtle); color: var(--c-ink); text-decoration: none; }
.icon-btn:focus-visible { outline: none; box-shadow: var(--ring); }
.icon-btn--sm { width: var(--h-sm); height: var(--h-sm); }
.icon-btn--light { color: #CBD5E1; }
.icon-btn--light:hover { background: rgba(255, 255, 255, .08); color: #fff; }

/* 6 ─ forms ────────────────────────────────────────────────────────────────────────────────────────────── */
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field__label { font-size: var(--fs-sm); font-weight: 600; color: var(--c-ink-2); }
.field__req { color: var(--c-danger); margin-left: 2px; }
.field__opt { font-weight: 400; color: var(--c-muted); }
.field__hint { display: flex; align-items: center; gap: 6px; font-size: .8125rem; color: var(--c-muted); }
.field__error, .field-validation-error { display: flex; align-items: center; gap: 6px; font-size: .8125rem; font-weight: 600; color: var(--c-danger-text); }
.field-validation-valid { display: none; }
.validation-summary-errors ul { margin: 0; padding-left: 18px; }

.input {
  display: block; width: 100%; min-height: var(--h); padding: 10px 14px;
  border: 1px solid var(--c-border-strong); border-radius: var(--r); background: var(--c-surface); color: var(--c-ink);
  font-size: 1rem; line-height: 1.4; box-shadow: var(--shadow-xs);
  transition: border-color .15s, box-shadow .15s, background-color .15s;
}
.input::placeholder { color: var(--c-faint); }
.input:hover { border-color: #AFBACD; }
.input:focus { outline: none; border-color: var(--c-primary); box-shadow: var(--ring); }
.input.is-invalid, .input.input-validation-error, .input[aria-invalid="true"] { border-color: var(--c-danger); }
.input.is-invalid:focus, .input.input-validation-error:focus, .input[aria-invalid="true"]:focus { box-shadow: var(--ring-danger); }
.input:disabled, .input[readonly] { background: var(--c-subtle); color: var(--c-muted); }
.input--lg { min-height: var(--h-lg); font-size: 1.0625rem; border-radius: 12px; }
.input--sm { min-height: var(--h-sm); padding: 6px 10px; font-size: var(--fs-sm); border-radius: 8px; }
.input--mono { font-family: var(--font-mono); letter-spacing: .02em; }
.input--num { text-align: right; font-variant-numeric: tabular-nums; }
textarea.input { min-height: 104px; resize: vertical; line-height: 1.5; }
select.input {
  appearance: none; padding-right: 40px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%235B6B82' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center; background-size: 18px;
}
input[type="date"].input, input[type="datetime-local"].input { min-width: 0; }
input[type="file"].input { padding: 8px; cursor: pointer; }
input[type="file"].input::file-selector-button {
  margin-right: 12px; padding: 6px 14px; border: 1px solid var(--c-border-strong); border-radius: 8px;
  background: var(--c-subtle); color: var(--c-ink); font: inherit; font-size: var(--fs-sm); font-weight: 600; cursor: pointer;
}
input[type="search"].input::-webkit-search-cancel-button { cursor: pointer; }

.input-group { position: relative; display: flex; align-items: stretch; }
.input-group > .input { flex: 1 1 auto; min-width: 0; }
.input-group__addon {
  display: flex; align-items: center; padding: 0 14px; background: var(--c-subtle); color: var(--c-muted);
  border: 1px solid var(--c-border-strong); font-weight: 600; white-space: nowrap;
}
.input-group__addon:first-child { border-right: 0; border-radius: var(--r) 0 0 var(--r); }
.input-group__addon:last-child { border-left: 0; border-radius: 0 var(--r) var(--r) 0; }
.input-group > .input:not(:first-child) { border-top-left-radius: 0; border-bottom-left-radius: 0; }
.input-group > .input:not(:last-child):has(+ .input-group__addon) { border-top-right-radius: 0; border-bottom-right-radius: 0; }
.input-group__btn {
  position: absolute; right: 4px; top: 50%; transform: translateY(-50%); display: grid; place-items: center;
  width: 40px; height: 40px; border: 0; border-radius: 8px; background: none; color: var(--c-muted); cursor: pointer;
}
.input-group__btn:hover { background: var(--c-subtle); color: var(--c-ink); }
.input-group__btn:focus-visible { outline: none; box-shadow: var(--ring); }
.input-group:has(.input-group__btn) > .input { padding-right: 48px; }
.input-group:has(.input--lg) .input-group__btn { width: 44px; height: 44px; }
@media (pointer: coarse), (max-width: 719.98px) { .input-group__btn { right: 0; width: 44px; height: 44px; } }
.input-icon { position: relative; }
.input-icon > .icon { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); color: var(--c-muted); pointer-events: none; }
.input-icon > .input { padding-left: 42px; }
/* file picker: the native control says "Choose File · No file chosen" in the browser's language — a Mongolian button
   in front of the (visually hidden, still focusable) input and the chosen name next to it; app.js [data-filepick] */
.filepick {
  position: relative; display: flex; align-items: center; gap: 12px; min-height: var(--h); padding: 4px 12px 4px 4px;
  border: 1px dashed var(--c-border-strong); border-radius: var(--r); background: var(--c-surface);
}
.filepick__input { position: absolute; width: 1px; height: 1px; opacity: 0; overflow: hidden; clip-path: inset(50%); }
.filepick__btn { flex: none; cursor: pointer; }
.filepick__input:focus-visible + .filepick__btn { box-shadow: var(--ring); }
.filepick__name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--c-muted); font-size: var(--fs-sm); }
.filepick.has-file { border-style: solid; }
.filepick.has-file .filepick__name { color: var(--c-ink); font-weight: 600; }
.filepick.is-invalid, .filepick:has(.filepick__input[aria-invalid="true"]) { border-color: var(--c-danger); }

.check { display: inline-flex; align-items: flex-start; gap: 10px; min-height: 28px; cursor: pointer; font-size: .9375rem; line-height: 1.45; }
.check input { flex: none; width: 20px; height: 20px; margin: 1px 0 0; accent-color: var(--c-primary); cursor: pointer; }
.check__text small { display: block; color: var(--c-muted); font-size: var(--fs-sm); }

.switch { display: inline-flex; align-items: center; gap: 12px; cursor: pointer; min-height: 32px; font-size: .9375rem; }
.switch input {
  appearance: none; position: relative; flex: none; width: 44px; height: 26px; margin: 0; border-radius: var(--r-full);
  background: #C7D0DE; cursor: pointer; transition: background-color .18s var(--ease);
}
.switch input::before {
  content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 3px rgba(15, 23, 42, .3); transition: transform .18s var(--ease);
}
.switch input:checked { background: var(--c-primary); }
.switch input:checked::before { transform: translateX(18px); }
.switch input:focus-visible { outline: none; box-shadow: var(--ring); }
.switch input:disabled { opacity: .5; cursor: not-allowed; }
@media (pointer: coarse), (max-width: 719.98px) { .check, .switch { min-height: 44px; align-items: center; } .check input { margin-top: 0; } }

.form-grid { display: grid; gap: var(--s-4); grid-template-columns: minmax(0, 1fr); }
@media (min-width: 720px) {
  .form-grid--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s-4) var(--s-5); }
  .form-grid--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--s-4) var(--s-5); }
}
.form-section { display: grid; gap: var(--s-4); }
.form-section + .form-section { padding-top: var(--s-6); border-top: 1px solid var(--c-border); }
.form-section__title { font-size: var(--fs-base); font-weight: 700; }
.form-section__sub { font-size: var(--fs-sm); color: var(--c-muted); margin-top: 2px; }
.form-actions { display: flex; flex-wrap: wrap; gap: var(--s-3); justify-content: flex-end; align-items: center; padding-top: var(--s-2); }
@media (max-width: 599.98px) { .form-actions { flex-direction: column-reverse; align-items: stretch; } .form-actions > .btn { width: 100%; } }
/* phone: the one primary action stays under the thumb (checkout, order page) */
.sticky-actions {
  position: sticky; bottom: 0; z-index: 20; margin-inline: calc(-1 * var(--gutter)); padding: 12px var(--gutter) calc(12px + env(safe-area-inset-bottom));
  background: rgba(255, 255, 255, .94); border-top: 1px solid var(--c-border); backdrop-filter: blur(8px);
}
@media (min-width: 1024px) { .sticky-actions { position: static; margin: 0; padding: 0; background: none; border: 0; backdrop-filter: none; } }

/* 7 ─ segmented control, choice cards, qty stepper ─────────────────────────────────────────────────────── */
.seg {
  display: inline-grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 4px; padding: 4px;
  background: var(--c-subtle-2); border-radius: 12px; max-width: 100%;
}
.seg--block { display: grid; width: 100%; }
.seg__opt { position: relative; display: block; min-width: 0; }
.seg__opt input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
.seg__opt span {
  display: flex; align-items: center; justify-content: center; gap: 8px; min-height: 40px; padding: 0 16px;
  border-radius: 9px; color: var(--c-muted); font-weight: 600; font-size: .9375rem; text-align: center; line-height: 1.2;
  transition: background-color .15s, color .15s, box-shadow .15s; pointer-events: none;
}
.seg__opt:hover span { color: var(--c-ink); }
@media (pointer: coarse), (max-width: 719.98px) { .seg__opt span { min-height: var(--h); } }
.seg__opt input:checked + span { background: var(--c-surface); color: var(--c-ink); box-shadow: var(--shadow-sm); }
.seg__opt input:focus-visible + span { box-shadow: var(--ring); }
.seg__opt input:disabled + span { opacity: .45; }

.choices { display: grid; gap: var(--s-3); grid-template-columns: minmax(0, 1fr); }
@media (min-width: 600px) { .choices--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.choice { position: relative; display: block; cursor: pointer; }
.choice > input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.choice__body {
  display: flex; align-items: flex-start; gap: 14px; height: 100%; padding: 16px;
  background: var(--c-surface); border: 1.5px solid var(--c-border); border-radius: var(--r-lg);
  transition: border-color .15s, background-color .15s, box-shadow .15s;
}
.choice:hover .choice__body { border-color: var(--c-border-strong); }
.choice__icon {
  display: grid; place-items: center; width: 44px; height: 44px; flex: none; border-radius: 12px;
  background: var(--c-subtle); color: var(--c-ink-2);
}
.choice__main { flex: 1; min-width: 0; }
.choice__title { display: block; font-weight: 700; line-height: 1.3; }
.choice__text { display: block; margin-top: 2px; font-size: var(--fs-sm); color: var(--c-muted); line-height: 1.45; }
.choice__check {
  flex: none; width: 22px; height: 22px; margin-top: 2px; border-radius: 50%;
  border: 2px solid var(--c-border-strong); background: var(--c-surface); transition: all .15s;
}
.choice > input:checked + .choice__body { border-color: var(--c-primary); background: #F8FAFF; box-shadow: 0 0 0 1px var(--c-primary); }
.choice > input:checked + .choice__body .choice__icon { background: var(--c-primary-50); color: var(--c-primary); }
.choice > input:checked + .choice__body .choice__check {
  border-color: var(--c-primary); background: var(--c-primary) no-repeat center / 14px
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m5 12.5 4.5 4.5L19 7.5'/%3E%3C/svg%3E");
}
.choice > input:focus-visible + .choice__body { box-shadow: var(--ring); }
.choice > input:disabled + .choice__body { opacity: .5; cursor: not-allowed; }

/* The frame is an inset outline, not a border: the buttons then get the full control height (44 px touch targets)
   while the stepper still lines up with 44 px inputs and buttons. The outline paints over the children's edges. */
.qty {
  display: inline-flex; align-items: stretch; height: var(--h); outline: 1px solid var(--c-border-strong); outline-offset: -1px;
  border-radius: var(--r); background: var(--c-surface); box-shadow: var(--shadow-xs); overflow: hidden;
}
.qty:focus-within { outline-color: var(--c-primary); box-shadow: var(--ring); }
.qty__btn {
  display: grid; place-items: center; width: 44px; flex: none; border: 0; background: transparent;
  color: var(--c-ink-2); cursor: pointer; touch-action: manipulation; transition: background-color .12s;
}
.qty__btn:hover { background: var(--c-subtle); color: var(--c-ink); }
.qty__btn:active { background: var(--c-subtle-2); }
.qty__btn:disabled { color: var(--c-faint); cursor: not-allowed; background: none; }
.qty__input {
  width: 76px; min-width: 0; border: 0; border-inline: 1px solid var(--c-border); background: transparent;
  text-align: center; font-weight: 700; font-size: 1rem; font-variant-numeric: tabular-nums; -moz-appearance: textfield; appearance: textfield;
}
.qty__input::-webkit-outer-spin-button, .qty__input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.qty__input:focus { outline: none; background: var(--c-primary-50); }
.qty--sm { height: var(--h-sm); }
.qty--sm .qty__btn { width: 36px; }
.qty--sm .qty__input { width: 60px; font-size: .9375rem; }
.qty--block { display: flex; width: 100%; }
.qty--block .qty__input { flex: 1; width: auto; }
@media (pointer: coarse), (max-width: 719.98px) { .qty--sm { height: var(--h); } .qty--sm .qty__btn { width: 44px; } }
.qty-field { display: inline-flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.qty-field__unit { color: var(--c-muted); font-size: var(--fs-sm); }

/* 8 ─ chips, badges ────────────────────────────────────────────────────────────────────────────────────── */
.chips { display: flex; flex-wrap: wrap; gap: var(--s-2); }
.chips--scroll {
  flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; overscroll-behavior-x: contain;
  margin-inline: calc(-1 * var(--gutter)); padding: 2px var(--gutter) 4px; scroll-padding-inline: var(--gutter);
}
.chips--scroll::-webkit-scrollbar { display: none; }
@media (min-width: 1024px) { .chips--scroll { flex-wrap: wrap; overflow: visible; margin-inline: 0; padding-inline: 0; } }
.chip {
  display: inline-flex; align-items: center; gap: 7px; flex: none; min-height: var(--h-sm); padding: 0 14px;
  border: 1px solid var(--c-border); border-radius: var(--r-full); background: var(--c-surface);
  color: var(--c-ink-2); font-size: var(--fs-sm); font-weight: 600; line-height: 1.2; white-space: nowrap;
  text-decoration: none; cursor: pointer; transition: background-color .15s, border-color .15s, color .15s;
}
.chip:hover { border-color: var(--c-border-strong); background: var(--c-subtle); color: var(--c-ink); text-decoration: none; }
.chip:focus-visible { outline: none; box-shadow: var(--ring); }
.chip.is-active, .chip[aria-current="page"], .chip[aria-pressed="true"] { background: var(--c-ink); border-color: var(--c-ink); color: #fff; }
.chip__emoji { font-size: 1.05em; line-height: 1; }
.chip__count {
  min-width: 22px; padding: 1px 7px; border-radius: var(--r-full); background: var(--c-subtle-2); color: var(--c-ink-2);
  font-size: var(--fs-xs); font-weight: 700; text-align: center; font-variant-numeric: tabular-nums;
}
.chip.is-active .chip__count, .chip[aria-current="page"] .chip__count, .chip[aria-pressed="true"] .chip__count { background: #334155; color: #fff; }
.chip--lg { min-height: var(--h); padding: 0 18px; font-size: .9375rem; }
@media (pointer: coarse), (max-width: 719.98px) { .chip { min-height: var(--h); padding-inline: 16px; } }

.badge {
  display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px 3px 8px; border: 1px solid transparent;
  border-radius: var(--r-full); font-size: var(--fs-xs); font-weight: 700; line-height: 1.4; white-space: nowrap;
  letter-spacing: .005em; vertical-align: middle;
}
.badge::before { content: ""; width: 6px; height: 6px; flex: none; border-radius: 50%; background: currentColor; }
.badge--nodot { padding-inline: 10px; }
.badge--nodot::before { display: none; }
.badge--warn { color: var(--c-warn-text); background: var(--c-warn-bg); border-color: var(--c-warn-border); }
.badge--info { color: var(--c-info-text); background: var(--c-info-bg); border-color: var(--c-info-border); }
.badge--success { color: var(--c-success-text); background: var(--c-success-bg); border-color: var(--c-success-border); }
.badge--done { color: var(--c-done-text); background: var(--c-done-bg); border-color: var(--c-done-border); }
.badge--done::before { background: var(--c-success); }
.badge--danger { color: var(--c-danger-text); background: var(--c-danger-bg); border-color: var(--c-danger-border); }
.badge--muted { color: var(--c-muted-text); background: var(--c-muted-bg); border-color: var(--c-muted-border); }
.badge--muted::before { background: #9AA6B8; }
.badge--lg { padding: 5px 14px 5px 11px; font-size: var(--fs-sm); }
.count-dot {
  display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 6px; border-radius: var(--r-full);
  background: var(--c-danger); color: #fff; font-size: 11px; font-weight: 700; font-variant-numeric: tabular-nums;
}

/* 9 ─ cards, tables ────────────────────────────────────────────────────────────────────────────────────── */
.card { background: var(--c-surface); border: 1px solid var(--c-border); border-radius: var(--r-lg); box-shadow: var(--shadow-xs); min-width: 0; }
.card__head {
  display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); flex-wrap: wrap;
  padding: 14px var(--card-pad, 20px); border-bottom: 1px solid var(--c-border);
}
.card__title { font-size: var(--fs-base); font-weight: 700; display: flex; align-items: center; gap: 8px; }
.card__title .icon { color: var(--c-muted); }
.card__sub { font-size: var(--fs-sm); color: var(--c-muted); }
.card__body { padding: var(--card-pad, 20px); }
.card__foot {
  display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); flex-wrap: wrap;
  padding: 12px var(--card-pad, 20px); border-top: 1px solid var(--c-border); background: #FAFBFD;
  border-radius: 0 0 var(--r-lg) var(--r-lg);
}
.card--pad { padding: var(--card-pad, 20px); }
.card--muted { background: var(--c-subtle); box-shadow: none; }
.card--link { display: block; color: inherit; text-decoration: none; transition: border-color .15s, box-shadow .15s, transform .15s; }
.card--link:hover { border-color: var(--c-primary-200); box-shadow: var(--shadow); text-decoration: none; transform: translateY(-1px); }
.card--accent { border-top: 3px solid var(--c-primary); }
@media (max-width: 599.98px) { .card { --card-pad: 16px; } }

.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.card > .table-wrap:first-child .table, .card > .table:first-child { border-top-left-radius: var(--r-lg); }
.table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: .9375rem; }
.table th, .table td { padding: 12px 16px; text-align: left; vertical-align: middle; border-bottom: 1px solid var(--c-border); }
.table thead th {
  position: sticky; top: 0; z-index: 1; background: #F8FAFC; color: var(--c-muted); font-size: var(--fs-xs);
  font-weight: 700; letter-spacing: .04em; text-transform: uppercase; white-space: nowrap; border-bottom-color: var(--c-border);
}
.table tbody tr { transition: background-color .12s; }
.table tbody tr:hover { background: #FAFBFE; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr.is-selected { background: var(--c-primary-50); }
.table tr[data-href] { cursor: pointer; }
.table .num, .table .td-num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table .td-actions { text-align: right; white-space: nowrap; width: 1%; }
.table .td-check { width: 44px; }
.table .td-title a { color: var(--c-ink); font-weight: 600; }
.table .td-title a:hover { color: var(--c-primary); }
.table__sub { display: block; font-size: .8125rem; color: var(--c-muted); }
.table tfoot td { font-weight: 700; background: #F8FAFC; border-top: 1px solid var(--c-border); border-bottom: 0; }
.table--compact th, .table--compact td { padding: 8px 12px; }
@media (max-width: 719.98px) {
  .table--stack thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .table--stack, .table--stack tbody, .table--stack tr, .table--stack td { display: block; width: 100%; }
  .table--stack tbody { display: grid; gap: var(--s-3); }
  .card .table--stack tbody { padding: var(--s-3); }
  .table--stack tr { padding: 10px 14px; background: var(--c-surface); border: 1px solid var(--c-border); border-radius: var(--r-lg); box-shadow: var(--shadow-xs); }
  .table--stack tbody tr:hover { background: var(--c-surface); }
  .table--stack td { padding: 7px 0; border: 0; text-align: right; }
  .table--stack td::before { content: attr(data-label); float: left; max-width: 45%; margin-right: var(--s-4); color: var(--c-muted); font-size: .8125rem; font-weight: 600; line-height: 1.9; text-align: left; }
  .table--stack td::after { content: ""; display: table; clear: both; }
  .table--stack td:not([data-label])::before, .table--stack td[data-label=""]::before { content: none; }
  .table--stack td.td-title { display: block; padding: 4px 0 10px; margin-bottom: 4px; border-bottom: 1px solid var(--c-border); text-align: left; font-size: 1rem; }
  .table--stack td.td-title::before { content: none; }
  .table--stack td.td-actions { width: 100%; padding-top: 10px; }
  .table--stack td.td-check { position: absolute; }
  .table--stack tfoot { display: block; }
  .table--stack tfoot tr { display: flex; justify-content: space-between; }
}

/* 10 ─ alerts, toasts ──────────────────────────────────────────────────────────────────────────────────── */
.alert {
  display: flex; align-items: flex-start; gap: 12px; padding: 14px 16px; border: 1px solid; border-radius: var(--r);
  font-size: .9375rem; line-height: 1.5;
}
.alert__icon { flex: none; margin-top: 1px; }
.alert__body { flex: 1; min-width: 0; }
.alert__title { font-weight: 700; margin-bottom: 2px; }
.alert__text a { color: inherit; text-decoration: underline; }
.alert__actions { display: flex; flex-wrap: wrap; gap: var(--s-2); margin-top: var(--s-3); }
.alert__close { flex: none; display: grid; place-items: center; width: 40px; height: 40px; margin: -10px -10px -10px 0; border: 0; border-radius: 8px; background: none; color: inherit; opacity: .7; cursor: pointer; }
.alert__close:hover { opacity: 1; background: rgba(15, 23, 42, .06); }
@media (pointer: coarse), (max-width: 719.98px) { .alert__close { width: 44px; height: 44px; margin: -12px -12px -12px 0; } }
.alert--info { background: var(--c-info-bg); border-color: var(--c-info-border); color: #1B3A93; }
.alert--info .alert__icon { color: var(--c-primary); }
.alert--success { background: var(--c-success-bg); border-color: var(--c-success-border); color: #0A5A40; }
.alert--success .alert__icon { color: var(--c-success); }
.alert--warn { background: var(--c-warn-bg); border-color: var(--c-warn-border); color: #7A3F05; }
.alert--warn .alert__icon { color: var(--c-warn); }
.alert--danger { background: var(--c-danger-bg); border-color: var(--c-danger-border); color: #8C251D; }
.alert--danger .alert__icon { color: var(--c-danger); }
.alert--banner { border-radius: 0; border-width: 0 0 1px; }

.toasts {
  position: fixed; z-index: 90; left: 50%; bottom: calc(16px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  display: flex; flex-direction: column; align-items: stretch; gap: var(--s-2); width: min(440px, calc(100vw - 24px)); pointer-events: none;
}
@media (min-width: 720px) { .toasts { left: auto; right: 24px; bottom: 24px; transform: none; width: 400px; } }
.toast {
  pointer-events: auto; display: flex; align-items: center; gap: 10px; padding: 12px 10px 12px 16px;
  border-radius: 12px; background: var(--c-navy); color: #F1F5F9; box-shadow: var(--shadow-lg);
  font-size: .9375rem; line-height: 1.45; animation: toast-in .24s var(--ease);
}
.toast__icon { flex: none; color: #93B4FF; }
.toast--success .toast__icon { color: #4ADE9B; }
.toast--warn .toast__icon { color: #FBBF5A; }
.toast--danger .toast__icon { color: #FF8F85; }
.toast__text { flex: 1; min-width: 0; }
.toast__action { color: #9DB8FF; font-weight: 700; white-space: nowrap; }
.toast__close { flex: none; display: grid; place-items: center; width: 32px; height: 32px; border: 0; border-radius: 8px; background: none; color: rgba(241, 245, 249, .7); cursor: pointer; }
.toast__close:hover { background: rgba(255, 255, 255, .1); color: #fff; }
.toast.is-leaving { animation: toast-out .2s ease-in forwards; }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px) scale(.98); } }
@keyframes toast-out { to { opacity: 0; transform: translateY(6px); } }

/* 11 ─ dialog, drawer (native <dialog>: focus trap, Esc and backdrop for free) ─────────────────────────── */
.dialog {
  width: min(480px, calc(100vw - 32px)); max-height: calc(100dvh - 48px); padding: 0; border: 0; border-radius: var(--r-xl);
  background: var(--c-surface); color: var(--c-ink); box-shadow: var(--shadow-lg); overflow: auto;
}
.dialog--wide { width: min(720px, calc(100vw - 32px)); }
.dialog::backdrop { background: rgba(15, 23, 42, .5); backdrop-filter: blur(2px); }
.dialog[open] { animation: dialog-in .2s var(--ease); }
.dialog__form { display: contents; }
.dialog__head { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); padding: 18px 20px 0; }
.dialog__title { font-size: var(--fs-md); font-weight: 700; }
.dialog__body { display: flex; gap: 14px; padding: 20px; }
.dialog__body--col { flex-direction: column; }
.dialog__icon { display: grid; place-items: center; width: 44px; height: 44px; flex: none; border-radius: 50%; background: var(--c-primary-50); color: var(--c-primary); }
.dialog--warn .dialog__icon { background: var(--c-warn-bg); color: var(--c-warn); }
.dialog--danger .dialog__icon { background: var(--c-danger-bg); color: var(--c-danger); }
.dialog__text { margin-top: 6px; color: var(--c-muted); }
.dialog__foot {
  display: flex; justify-content: flex-end; gap: var(--s-3); padding: 14px 20px; border-top: 1px solid var(--c-border);
  background: #FAFBFD; border-radius: 0 0 var(--r-xl) var(--r-xl);
}
@media (max-width: 599.98px) {
  .dialog { width: 100%; max-width: 100%; margin: auto 0 0; border-radius: var(--r-xl) var(--r-xl) 0 0; }
  .dialog[open] { animation: sheet-in .24s var(--ease); }
  .dialog__foot { flex-direction: column-reverse; padding-bottom: calc(14px + env(safe-area-inset-bottom)); border-radius: 0; }
  .dialog__foot .btn { width: 100%; }
}
@keyframes dialog-in { from { opacity: 0; transform: translateY(8px) scale(.98); } }
@keyframes sheet-in { from { transform: translateY(100%); } }

.drawer {
  position: fixed; inset: 0 auto 0 0; width: min(320px, 86vw); max-width: none; height: 100%; max-height: none;
  margin: 0; padding: 0; border: 0; background: var(--c-surface); color: var(--c-ink); box-shadow: var(--shadow-lg);
}
.drawer[open] { display: flex; flex-direction: column; animation: drawer-left .24s var(--ease); }
.drawer--right { inset: 0 0 0 auto; }
.drawer--right[open] { animation-name: drawer-right; }
.drawer::backdrop { background: rgba(15, 23, 42, .5); backdrop-filter: blur(2px); }
.drawer__head { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); padding: 12px 12px 12px 20px; border-bottom: 1px solid var(--c-border); min-height: var(--header-h); }
.drawer__title { font-weight: 700; font-size: var(--fs-md); }
.drawer__nav { display: flex; flex-direction: column; gap: 2px; padding: 12px; }
.drawer__link {
  display: flex; align-items: center; gap: 14px; min-height: 50px; padding: 0 14px; border-radius: var(--r);
  color: var(--c-ink); font-weight: 600; text-decoration: none;
}
.drawer__link .icon { color: var(--c-muted); }
.drawer__link:hover { background: var(--c-subtle); text-decoration: none; }
.drawer__link[aria-current="page"] { background: var(--c-primary-50); color: var(--c-primary); }
.drawer__link[aria-current="page"] .icon { color: var(--c-primary); }
.drawer__foot { display: grid; gap: var(--s-3); margin-top: auto; padding: 16px 20px calc(16px + env(safe-area-inset-bottom)); border-top: 1px solid var(--c-border); }
.drawer--dark { background: var(--c-navy); color: #CBD5E1; }
.drawer--dark .drawer__head { border-bottom-color: rgba(255, 255, 255, .08); }
.drawer--dark .side-nav { padding: 12px; }
.drawer--dark .sidebar__foot { padding: 12px; }
@keyframes drawer-left { from { transform: translateX(-100%); } }
@keyframes drawer-right { from { transform: translateX(100%); } }

/* 12 ─ tabs, pager ─────────────────────────────────────────────────────────────────────────────────────── */
.tabs {
  display: flex; gap: 2px; margin-bottom: var(--s-5); border-bottom: 1px solid var(--c-border);
  overflow-x: auto; scrollbar-width: none; overscroll-behavior-x: contain;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  display: inline-flex; align-items: center; gap: 8px; flex: none; min-height: var(--h); padding: 0 14px; margin-bottom: -1px;
  border: 0; border-bottom: 2px solid transparent; background: none; color: var(--c-muted);
  font-size: .9375rem; font-weight: 600; white-space: nowrap; text-decoration: none; cursor: pointer; transition: color .15s, border-color .15s;
}
.tab:hover { color: var(--c-ink); text-decoration: none; }
.tab:focus-visible { outline: none; box-shadow: inset var(--ring); border-radius: 8px 8px 0 0; }
.tab.is-active, .tab[aria-selected="true"], .tab[aria-current="page"] { color: var(--c-primary); border-bottom-color: var(--c-primary); }
.tab__count {
  min-width: 22px; padding: 1px 8px; border-radius: var(--r-full); background: var(--c-subtle-2); color: var(--c-ink-2);
  font-size: var(--fs-xs); font-weight: 700; text-align: center; font-variant-numeric: tabular-nums;
}
.tab.is-active .tab__count, .tab[aria-selected="true"] .tab__count, .tab[aria-current="page"] .tab__count { background: var(--c-primary-50); color: var(--c-primary); }
.tabs--pills { gap: var(--s-2); border-bottom: 0; }
.tabs--pills .tab { min-height: var(--h-sm); padding: 0 14px; margin: 0; border: 0; border-radius: var(--r-full); }
.tabs--pills .tab.is-active, .tabs--pills .tab[aria-selected="true"], .tabs--pills .tab[aria-current="page"] { background: var(--c-primary-50); }

.pager { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: var(--s-3); margin-top: var(--s-4); }
.pager__info { color: var(--c-muted); font-size: var(--fs-sm); }
.pager__info strong { color: var(--c-ink); font-variant-numeric: tabular-nums; }
.pager__list { display: flex; align-items: center; gap: 4px; list-style: none; margin: 0; padding: 0; }
.pager__link {
  display: grid; place-items: center; min-width: 40px; height: 40px; padding: 0 8px; border-radius: var(--r);
  color: var(--c-ink-2); font-weight: 600; font-size: var(--fs-sm); font-variant-numeric: tabular-nums; text-decoration: none;
}
.pager__link:hover { background: var(--c-surface); box-shadow: inset 0 0 0 1px var(--c-border); text-decoration: none; color: var(--c-ink); }
.pager__link.is-current { background: var(--c-primary); color: #fff; box-shadow: none; }
.pager__link.is-disabled { color: var(--c-faint); pointer-events: none; }
.pager__gap { color: var(--c-faint); padding: 0 4px; }
@media (pointer: coarse), (max-width: 719.98px) { .pager__link { min-width: 44px; height: 44px; } .tabs--pills .tab { min-height: var(--h); } }
@media (max-width: 479.98px) { .pager { justify-content: center; } .pager__info { width: 100%; text-align: center; } }
/* _Pager renders two windows: ‹ 1 … 4 5 [6] 7 8 … 12 › on wide screens, ‹ 1 … [6] … 12 › on phones (44 px links) */
.pager__list--narrow { display: none; }
@media (max-width: 719.98px) { .pager__list--wide { display: none; } .pager__list--narrow { display: flex; } }

/* 13 ─ status stepper, timeline ────────────────────────────────────────────────────────────────────────── */
.stepper { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); list-style: none; padding: 0; }
.stepper__step { position: relative; display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 0 4px; text-align: center; }
.stepper__step::before {
  content: ""; position: absolute; top: 17px; left: calc(-50% + 24px); right: calc(50% + 24px); height: 3px;
  border-radius: 2px; background: var(--c-border);
}
.stepper__step:first-child::before { display: none; }
.stepper__step.is-done::before { background: var(--c-success); }
.stepper__step.is-current::before { background: linear-gradient(90deg, var(--c-success), var(--c-primary-200)); }
.stepper__step.is-current.is-warn::before { background: linear-gradient(90deg, var(--c-success), var(--c-warn-border)); }
.stepper__dot {
  position: relative; z-index: 1; display: grid; place-items: center; width: 36px; height: 36px; border-radius: 50%;
  border: 2px solid var(--c-border-strong); background: var(--c-surface); color: var(--c-faint);
}
.stepper__step.is-done .stepper__dot { border-color: var(--c-success); background: var(--c-success); color: #fff; }
.stepper__step.is-current .stepper__dot { border-color: var(--c-primary); background: var(--c-primary-50); color: var(--c-primary); box-shadow: 0 0 0 5px rgba(31, 79, 216, .1); }
.stepper__step.is-current.is-warn .stepper__dot { border-color: var(--c-warn); background: var(--c-warn-bg); color: var(--c-warn); box-shadow: 0 0 0 5px rgba(178, 94, 9, .1); }
.stepper__label { font-size: .8125rem; font-weight: 600; line-height: 1.3; color: var(--c-muted); }
.stepper__step.is-done .stepper__label, .stepper__step.is-current .stepper__label { color: var(--c-ink); }
.stepper__time { font-size: var(--fs-xs); color: var(--c-muted); font-variant-numeric: tabular-nums; }
.alert + .stepper { margin-top: var(--s-5); }

.timeline { position: relative; list-style: none; padding: 0; }
.timeline__item { position: relative; display: flex; gap: 14px; padding-bottom: var(--s-5); }
.timeline__item:last-child { padding-bottom: 0; }
.timeline__item::before { content: ""; position: absolute; left: 7px; top: 20px; bottom: 0; width: 2px; background: var(--c-border); }
.timeline__item:last-child::before { display: none; }
.timeline__dot { position: relative; flex: none; width: 16px; height: 16px; margin-top: 3px; border-radius: 50%; background: var(--c-surface); border: 3px solid var(--c-border-strong); }
.timeline__dot--info { border-color: var(--c-primary); } .timeline__dot--success { border-color: var(--c-success); }
.timeline__dot--warn { border-color: var(--c-warn); } .timeline__dot--danger { border-color: var(--c-danger); }
.timeline__body { flex: 1; min-width: 0; }
.timeline__title { font-weight: 600; line-height: 1.4; }
.timeline__meta { font-size: .8125rem; color: var(--c-muted); }
.timeline__note { margin-top: 4px; font-size: var(--fs-sm); color: var(--c-ink-2); }

/* 14 ─ KPI tiles ───────────────────────────────────────────────────────────────────────────────────────── */
.kpis { display: grid; gap: var(--s-3); grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (min-width: 900px) { .kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--s-4); } }
@media (min-width: 1440px) { .kpis--6 { grid-template-columns: repeat(6, minmax(0, 1fr)); } }
.kpi {
  display: flex; flex-direction: column; gap: 6px; min-width: 0; padding: 16px; color: inherit;
  background: var(--c-surface); border: 1px solid var(--c-border); border-radius: var(--r-lg); box-shadow: var(--shadow-xs);
}
a.kpi { text-decoration: none; transition: border-color .15s, box-shadow .15s; }
a.kpi:hover { border-color: var(--c-primary-200); box-shadow: var(--shadow); text-decoration: none; }
.kpi__head { display: flex; align-items: center; justify-content: space-between; gap: var(--s-2); }
.kpi__label { font-size: .8125rem; font-weight: 600; color: var(--c-muted); line-height: 1.3; }
.kpi__icon { display: grid; place-items: center; width: 34px; height: 34px; flex: none; border-radius: 10px; background: var(--c-primary-50); color: var(--c-primary); }
.kpi__value { font-size: clamp(1.375rem, 1.1rem + 1vw, 1.75rem); font-weight: 750; letter-spacing: -.02em; line-height: 1.15; font-variant-numeric: tabular-nums; }
.kpi__meta { font-size: .8125rem; color: var(--c-muted); }
.kpi--success .kpi__icon { background: var(--c-success-bg); color: var(--c-success); }
.kpi--warn .kpi__icon { background: var(--c-warn-bg); color: var(--c-warn); }
.kpi--danger .kpi__icon { background: var(--c-danger-bg); color: var(--c-danger); }
.kpi--muted .kpi__icon { background: var(--c-subtle); color: var(--c-muted); }
.kpi--alert { border-color: var(--c-warn-border); background: linear-gradient(180deg, #FFFBF3, var(--c-surface) 60%); }

/* 15 ─ empty state ─────────────────────────────────────────────────────────────────────────────────────── */
.empty { display: flex; flex-direction: column; align-items: center; gap: var(--s-2); padding: var(--s-12) var(--s-6); text-align: center; }
.empty__icon { display: grid; place-items: center; width: 72px; height: 72px; margin-bottom: var(--s-2); border-radius: 50%; background: var(--c-subtle); color: var(--c-faint); }
.empty__title { font-size: var(--fs-md); font-weight: 700; }
.empty__text { max-width: 420px; color: var(--c-muted); }
.empty .btn { margin-top: var(--s-3); }
.empty--sm { padding: var(--s-8) var(--s-4); }
.empty--sm .empty__icon { width: 56px; height: 56px; }

/* 16 ─ key/value, lists ────────────────────────────────────────────────────────────────────────────────── */
.kv { display: grid; grid-template-columns: minmax(0, 1fr); gap: 2px var(--s-5); }
.kv > div { display: grid; grid-template-columns: minmax(110px, 40%) minmax(0, 1fr); gap: var(--s-4); padding: 10px 0; border-bottom: 1px solid var(--c-border); }
.kv > div:last-child { border-bottom: 0; }
.kv dt { color: var(--c-muted); font-size: var(--fs-sm); }
.kv dd { margin: 0; font-weight: 500; overflow-wrap: anywhere; }
@media (min-width: 1024px) { .kv--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

.list { list-style: none; padding: 0; }
.list__item { display: flex; align-items: center; gap: var(--s-3); padding: 12px 0; border-bottom: 1px solid var(--c-border); }
.list__item:last-child { border-bottom: 0; }
.list__main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.list__title { font-weight: 600; line-height: 1.35; }
.list__meta { font-size: .8125rem; color: var(--c-muted); }
.card > .list .list__item { padding-inline: var(--card-pad, 20px); }
a.list__item { color: inherit; text-decoration: none; }
a.list__item:hover { background: #FAFBFE; text-decoration: none; }

.contact-list, .link-list, .pay-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.contact-list li, .pay-list li { display: flex; align-items: flex-start; gap: 10px; }
.contact-list .icon, .pay-list .icon { margin-top: 3px; }
/* phone / e-mail links are flex items (not inline text), so on touch screens they need the full 44 px tap height;
   the negative margin keeps the list spacing unchanged */
@media (pointer: coarse), (max-width: 719.98px) { .contact-list a { display: inline-flex; align-items: center; min-height: 44px; margin-block: -12px; } }

/* 17 ─ menus, avatar ───────────────────────────────────────────────────────────────────────────────────── */
.menu { position: relative; }
.menu > summary { list-style: none; cursor: pointer; }
.menu > summary::-webkit-details-marker { display: none; }
.menu__pop {
  position: absolute; top: calc(100% + 8px); left: 0; z-index: 60; min-width: 240px; padding: 6px;
  background: var(--c-surface); border: 1px solid var(--c-border); border-radius: 12px; box-shadow: var(--shadow-lg);
  animation: dialog-in .14s var(--ease);
}
.menu__pop--right { left: auto; right: 0; }
.menu__head { display: flex; flex-direction: column; gap: 2px; padding: 10px 12px 12px; margin-bottom: 4px; border-bottom: 1px solid var(--c-border); }
.menu__item {
  display: flex; align-items: center; gap: 10px; width: 100%; min-height: 42px; padding: 0 12px; border: 0; border-radius: 8px;
  background: none; color: var(--c-ink); font-size: .9375rem; text-align: left; text-decoration: none; cursor: pointer;
}
.menu__item .icon { color: var(--c-muted); }
.menu__item:hover { background: var(--c-subtle); text-decoration: none; }
.menu__item:focus-visible { outline: none; box-shadow: var(--ring); }
.menu__item--danger, .menu__item--danger .icon { color: var(--c-danger-text); }
.menu__form { margin: 0; }
@media (pointer: coarse), (max-width: 719.98px) { .menu__item { min-height: 46px; } }
.menu__sep { height: 1px; margin: 4px 0; background: var(--c-border); }

.avatar {
  display: inline-grid; place-items: center; width: 34px; height: 34px; flex: none; border-radius: 50%;
  background: linear-gradient(135deg, #3566F0, var(--c-primary-active)); color: #fff; font-size: 13px; font-weight: 700; letter-spacing: .02em;
}

/* 18 ─ utilities ───────────────────────────────────────────────────────────────────────────────────────── */
.sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.divider { height: 1px; background: var(--c-border); margin-block: var(--s-5); }
.w-full { width: 100%; }
@media (max-width: 719.98px) { .hide-sm { display: none !important; } }
@media (min-width: 720px) { .show-sm { display: none !important; } }
@media (max-width: 1023.98px) { .hide-md { display: none !important; } }
@media (min-width: 1024px) { .show-md { display: none !important; } }
.print-only { display: none; }
.spinner { display: inline-block; width: 18px; height: 18px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; animation: spin .7s linear infinite; vertical-align: middle; }
@keyframes spin { to { transform: rotate(360deg); } }
[data-copy] { cursor: pointer; }
.is-copied { color: var(--c-success-text) !important; }
[data-cat="ORG"] { --accent: var(--cat-org); } [data-cat="MED"] { --accent: var(--cat-med); }
[data-cat="SCH"] { --accent: var(--cat-sch); } [data-cat="KG"] { --accent: var(--cat-kg); }
[data-cat="POL"] { --accent: var(--cat-pol); } [data-cat="CRT"] { --accent: var(--cat-crt); }
[data-cat="GOV"] { --accent: var(--cat-gov); } [data-cat="SPC"] { --accent: var(--cat-spc); }

/* 19 ─ public layout ───────────────────────────────────────────────────────────────────────────────────── */
.site { display: flex; flex-direction: column; }
.site-main { flex: 1 0 auto; }
.site-header {
  position: sticky; top: 0; z-index: 40; background: rgba(255, 255, 255, .92); border-bottom: 1px solid var(--c-border);
  backdrop-filter: saturate(1.4) blur(10px);
}
.site-header__inner { display: flex; align-items: center; gap: var(--s-4); height: var(--header-h); }
.brand { display: inline-flex; align-items: center; gap: 10px; min-width: 0; min-height: 44px; color: var(--c-ink); text-decoration: none; }
.brand:hover { text-decoration: none; }
.brand__mark { flex: none; border-radius: 10px; }
.brand__text { display: flex; flex-direction: column; min-width: 0; line-height: 1.15; }
.brand__name { font-size: 1.0625rem; font-weight: 800; letter-spacing: -.015em; white-space: nowrap; }
.brand__tag { font-size: .75rem; font-weight: 500; color: var(--c-muted); white-space: nowrap; }
.brand--light { color: #fff; }
.brand--light .brand__tag { color: #94A3B8; }
.brand--compact .brand__name { font-size: 1rem; }
@media (max-width: 399.98px) { .site-header .brand__tag { display: none; } }
.site-nav { display: none; }
@media (min-width: 900px) {
  .site-nav { display: flex; align-items: center; gap: 4px; margin-left: var(--s-6); }
  .site-nav__link { padding: 9px 14px; border-radius: var(--r); color: var(--c-ink-2); font-weight: 600; font-size: .9375rem; }
  .site-nav__link:hover { background: var(--c-subtle); color: var(--c-ink); text-decoration: none; }
  .site-nav__link[aria-current="page"] { color: var(--c-primary); background: var(--c-primary-50); }
}
.site-header__actions { display: flex; align-items: center; gap: var(--s-2); margin-left: auto; }
.cart-btn {
  position: relative; display: inline-flex; align-items: center; gap: 8px; height: var(--h); padding: 0 12px;
  border-radius: var(--r-full); color: var(--c-ink); font-weight: 700; font-size: .9375rem; text-decoration: none;
  transition: background-color .15s;
}
.cart-btn:hover { background: var(--c-subtle); text-decoration: none; }
.cart-btn[aria-current="page"] { background: var(--c-primary-50); color: var(--c-primary); }
.cart-btn__label { display: none; }
.cart-badge {
  position: absolute; top: 3px; right: 1px; display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 5px;
  border-radius: var(--r-full); border: 2px solid #fff; background: var(--c-primary); color: #fff;
  font-size: 11px; font-weight: 800; line-height: 1; font-variant-numeric: tabular-nums;
}
.cart-badge.is-bump { animation: bump .45s var(--ease); }
@keyframes bump { 30% { transform: scale(1.35); } 60% { transform: scale(.92); } }
@media (min-width: 600px) {
  .cart-btn { padding: 0 16px; border: 1px solid var(--c-border-strong); background: var(--c-surface); box-shadow: var(--shadow-xs); }
  .cart-btn__label { display: inline; }
  .cart-badge { position: static; border: 0; }
}
@media (min-width: 900px) { .site-header__menu { display: none; } }
/* «Захиалгын утас» (Shop.Phone) in the header, tap to call: an icon button on small screens, label + big number on desktop */
.order-phone {
  display: inline-grid; place-items: center; width: var(--h); height: var(--h); flex: none; border-radius: var(--r-full);
  background: var(--c-primary-50); color: var(--c-primary); text-decoration: none;
}
.order-phone__text { display: none; }
@media (min-width: 900px) {
  .order-phone { display: inline-flex; gap: 10px; width: auto; height: auto; margin-right: var(--s-3); background: none; border-radius: 0; }
  .order-phone > .icon { box-sizing: content-box; padding: 9px; border-radius: var(--r-full); background: var(--c-primary-50); }
  .order-phone__text { display: flex; flex-direction: column; line-height: 1.1; }
  .order-phone__label { font-size: .75rem; font-weight: 600; color: var(--c-muted); }
  .order-phone__num { font-size: 1.25rem; font-weight: 800; letter-spacing: -.01em; color: var(--c-navy); font-variant-numeric: tabular-nums; }
  .order-phone:hover { text-decoration: none; }
  .order-phone:hover .order-phone__num { color: var(--c-primary); }
}

.site-footer { margin-top: auto; padding-top: var(--s-12); background: var(--c-navy); color: #B6C2D4; font-size: .9375rem; }
.site-footer a { color: #E2E8F0; }
.site-footer__grid { display: grid; gap: var(--s-8); grid-template-columns: minmax(0, 1fr); padding-bottom: var(--s-10); }
@media (min-width: 720px) { .site-footer__grid { grid-template-columns: 1.3fr 1fr 1fr 1fr; } }
.site-footer__tagline { margin-top: var(--s-3); max-width: 280px; color: #94A3B8; }
.site-footer__title { margin-bottom: var(--s-4); font-size: var(--fs-xs); font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: #fff; }
.site-footer .icon { color: #7C93B8; }
.site-footer__bottom {
  display: flex; flex-wrap: wrap; justify-content: space-between; gap: var(--s-2) var(--s-6); padding-block: var(--s-5) calc(var(--s-5) + env(safe-area-inset-bottom));
  border-top: 1px solid rgba(255, 255, 255, .08); font-size: var(--fs-sm); color: #8494AD;
}
.site-footer__bottom .muted { color: #8494AD; }

/* 20 ─ admin layout ────────────────────────────────────────────────────────────────────────────────────── */
.admin { background: var(--c-page); }
.admin-shell { display: grid; grid-template-columns: minmax(0, 1fr); min-height: 100vh; min-height: 100dvh; }
@media (min-width: 1024px) { .admin-shell { grid-template-columns: var(--sidebar-w) minmax(0, 1fr); } }
.sidebar { display: none; }
@media (min-width: 1024px) {
  .sidebar {
    position: sticky; top: 0; display: flex; flex-direction: column; height: 100vh; height: 100dvh; overflow-y: auto;
    padding: 18px 14px 14px; background: var(--c-navy); color: #CBD5E1; scrollbar-width: thin; scrollbar-color: #334155 transparent;
  }
}
.sidebar__brand { padding: 2px 8px 22px; }
.sidebar__foot { margin-top: auto; padding-top: 12px; border-top: 1px solid rgba(255, 255, 255, .08); }
.side-nav__list { display: flex; flex-direction: column; gap: 2px; }
.side-nav__group { padding: 20px 12px 8px; font-size: 11px; font-weight: 700; letter-spacing: .09em; text-transform: uppercase; color: #7D8CA6; }
.side-nav__link {
  position: relative; display: flex; align-items: center; gap: 12px; min-height: 42px; padding: 0 12px; border-radius: var(--r);
  color: #CBD5E1; font-size: .9375rem; font-weight: 600; text-decoration: none; transition: background-color .15s, color .15s;
}
.side-nav__link .icon { color: #8595B1; transition: color .15s; }
.side-nav__link:hover { background: rgba(255, 255, 255, .06); color: #fff; text-decoration: none; }
.side-nav__link:hover .icon { color: #fff; }
.side-nav__link:focus-visible { outline: none; box-shadow: 0 0 0 2px #6D93FF; }
.side-nav__link[aria-current="page"] { background: #1C2B55; color: #fff; }
.side-nav__link[aria-current="page"] .icon { color: #A9C1FF; }
.side-nav__link[aria-current="page"]::before { content: ""; position: absolute; left: -14px; top: 9px; bottom: 9px; width: 3px; border-radius: 0 3px 3px 0; background: #6D93FF; }
.drawer .side-nav__link[aria-current="page"]::before { left: -12px; }
.side-nav__ext { margin-left: auto; opacity: .6; }

.admin-main { display: flex; flex-direction: column; min-width: 0; }
.topbar {
  position: sticky; top: 0; z-index: 40; display: flex; align-items: center; gap: var(--s-3); height: var(--topbar-h);
  padding: 0 var(--gutter); background: rgba(255, 255, 255, .92); border-bottom: 1px solid var(--c-border); backdrop-filter: saturate(1.4) blur(10px);
}
.topbar__menu { margin-left: -8px; }
.topbar__brand .brand__mark { border-radius: 8px; }
@media (min-width: 1024px) { .topbar__menu, .topbar__brand { display: none; } .topbar { padding: 0 28px; } }
.topbar__search { position: relative; display: none; flex: 1; max-width: 440px; }
@media (min-width: 720px) { .topbar__search { display: block; } }
.topbar__search .input { min-height: 40px; padding-left: 40px; background: var(--c-subtle); border-color: transparent; box-shadow: none; font-size: .9375rem; }
.topbar__search .input:hover { border-color: var(--c-border); }
.topbar__search .input:focus { background: var(--c-surface); border-color: var(--c-primary); }
.topbar__search-icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--c-muted); pointer-events: none; }
.topbar__actions { display: flex; align-items: center; gap: var(--s-2); margin-left: auto; }
.usermenu__btn { display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 5px 8px 5px 5px; border-radius: var(--r-full); transition: background-color .15s; }
.usermenu__btn:hover { background: var(--c-subtle); }
.usermenu[open] .usermenu__btn { background: var(--c-subtle); }
.usermenu__btn:focus-visible { outline: none; box-shadow: var(--ring); }
.usermenu__who { display: none; flex-direction: column; line-height: 1.2; }
.usermenu__name { font-size: var(--fs-sm); font-weight: 700; max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.usermenu__role { font-size: var(--fs-xs); color: var(--c-muted); }
.usermenu__chev { color: var(--c-muted); display: none; }
@media (min-width: 720px) { .usermenu__who { display: flex; } .usermenu__chev { display: inline-block; } }

.admin-content { flex: 1; width: 100%; max-width: 1480px; padding: var(--s-5) var(--gutter) var(--s-12); }
@media (min-width: 1024px) { .admin-content { padding: var(--s-6) 28px var(--s-16); } }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; flex-wrap: wrap; gap: var(--s-3) var(--s-4); margin-bottom: var(--s-6); }
.page-head__main { min-width: 0; }
.page-head__back { display: inline-flex; align-items: center; gap: 4px; min-height: 44px; padding-block: 10px; margin: -11px 0 -5px; color: var(--c-muted); font-size: var(--fs-sm); font-weight: 600; }
.page-head__back:hover { color: var(--c-primary); text-decoration: none; }
.page-head__title { font-size: clamp(1.375rem, 1.2rem + .8vw, 1.75rem); font-weight: 750; letter-spacing: -.02em; }
.page-head__sub { margin-top: 4px; color: var(--c-muted); }
.page-head__actions { display: flex; flex-wrap: wrap; gap: var(--s-2); }
.page-head--actions-only { justify-content: flex-end; }
@media (max-width: 599.98px) { .page-head__actions { width: 100%; } .page-head__actions > .btn { flex: 1; } }
.toolbar { display: flex; flex-wrap: wrap; align-items: flex-end; gap: var(--s-3); margin-bottom: var(--s-4); }
.toolbar > .field { flex: 1 1 180px; }
.toolbar > .field--grow { flex: 3 1 260px; }

/* 21 ─ auth (login) + error page ───────────────────────────────────────────────────────────────────────── */
.auth {
  display: grid; place-items: center; min-height: 100vh; min-height: 100dvh;
  background:
    radial-gradient(1200px 520px at 12% -10%, rgba(31, 79, 216, .14), transparent 60%),
    radial-gradient(900px 480px at 110% 110%, rgba(18, 128, 92, .08), transparent 60%),
    var(--c-page);
}
.auth__main { display: flex; flex-direction: column; align-items: center; gap: var(--s-5); width: min(440px, calc(100% - 32px)); padding-block: var(--s-8); }
.auth__card { width: 100%; padding: 28px 22px; background: var(--c-surface); border: 1px solid var(--c-border); border-radius: 22px; box-shadow: 0 30px 60px -24px rgba(15, 23, 42, .25), var(--shadow-xs); }
@media (min-width: 480px) { .auth__card { padding: 36px 36px 32px; } }
.auth__brand { display: flex; align-items: center; gap: 14px; margin-bottom: var(--s-8); }
.auth__brand img { border-radius: 14px; box-shadow: 0 8px 20px -8px rgba(31, 79, 216, .6); }
.auth__name { font-size: var(--fs-md); font-weight: 800; letter-spacing: -.015em; }
.auth__sub { font-size: var(--fs-sm); color: var(--c-muted); }
.auth__title { font-size: var(--fs-xl); font-weight: 800; letter-spacing: -.02em; }
.auth__lead { margin: 6px 0 var(--s-6); color: var(--c-muted); }
.auth__card .alert { margin-bottom: var(--s-5); }
.auth__foot { margin-top: var(--s-6); text-align: center; font-size: .8125rem; color: var(--c-muted); }
.auth__back { display: inline-flex; align-items: center; gap: 6px; min-height: 44px; color: var(--c-muted); font-size: var(--fs-sm); font-weight: 600; }
.auth__back:hover { color: var(--c-primary); text-decoration: none; }
.auth .stack { --stack: var(--s-5); }

.error-page { display: flex; flex-direction: column; align-items: center; gap: var(--s-3); padding-block: var(--s-10) var(--s-8); text-align: center; }
.error-page__code { font-size: clamp(4rem, 3rem + 5vw, 6.5rem); font-weight: 800; line-height: 1; letter-spacing: -.05em; color: var(--c-primary-100); user-select: none; }
.error-page__icon { display: grid; place-items: center; width: 72px; height: 72px; margin-top: -44px; border-radius: 50%; background: var(--c-surface); color: var(--c-primary); box-shadow: var(--shadow); }
.error-page__title { margin-top: var(--s-2); font-size: var(--fs-xl); }
.error-page__text { max-width: 440px; color: var(--c-muted); margin-bottom: var(--s-3); }
.error-page__ref { margin-top: var(--s-4); font-size: var(--fs-xs); color: var(--c-muted); }

/* 22 ─ catalog pieces ──────────────────────────────────────────────────────────────────────────────────── */
.catgrid { display: grid; gap: var(--s-3); grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (min-width: 720px) { .catgrid { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--s-4); } }
.catcard {
  position: relative; display: flex; flex-direction: column; gap: 10px; min-height: 132px; padding: 16px; overflow: hidden;
  background: var(--c-surface); border: 1px solid var(--c-border); border-radius: var(--r-lg); box-shadow: var(--shadow-xs);
  color: var(--c-ink); text-decoration: none; transition: border-color .15s, box-shadow .15s, transform .15s;
}
.catcard::after { content: ""; position: absolute; inset: auto 0 0; height: 3px; background: var(--accent, var(--c-primary)); opacity: .85; }
.catcard:hover { border-color: color-mix(in srgb, var(--accent, var(--c-primary)) 35%, var(--c-border)); box-shadow: var(--shadow); transform: translateY(-2px); text-decoration: none; }
.catcard__icon {
  display: grid; place-items: center; width: 48px; height: 48px; border-radius: 14px; font-size: 26px; line-height: 1;
  background: color-mix(in srgb, var(--accent, var(--c-primary)) 11%, #fff);
}
.catcard__name { font-weight: 700; line-height: 1.3; }
.catcard__count { margin-top: auto; font-size: .8125rem; color: var(--c-muted); }

.tgrid { display: grid; gap: var(--s-3); grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (min-width: 720px) { .tgrid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--s-4); } }
@media (min-width: 1024px) { .tgrid { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--s-5); } }
.tcard {
  container-type: inline-size; display: flex; flex-direction: column; min-width: 0; overflow: hidden;
  background: var(--c-surface); border: 1px solid var(--c-border); border-radius: var(--r-lg); box-shadow: var(--shadow-xs);
  transition: border-color .15s, box-shadow .15s;
}
.tcard:hover { border-color: var(--c-primary-200); box-shadow: var(--shadow); }
.tcard__thumb { display: block; aspect-ratio: 4 / 3; min-height: 0; overflow: hidden; padding: 14px; background: linear-gradient(180deg, #F3F6FB, #E9EEF6); }   /* overflow: a portrait picture must not stretch the 4:3 box */
.tcard__thumb img { display: block; width: 100%; height: 100%; object-fit: contain; filter: drop-shadow(0 6px 10px rgba(15, 23, 42, .12)); transition: transform .2s var(--ease); }
.tcard:hover .tcard__thumb img { transform: translateY(-2px) scale(1.02); }
.tcard__body { display: flex; flex-direction: column; flex: 1; gap: 6px; padding: 12px 14px 14px; }
.tcard__cat { font-size: var(--fs-xs); color: var(--c-muted); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tcard__title { font-size: .9375rem; font-weight: 700; line-height: 1.3; }
.tcard__title a { color: var(--c-ink); }
.tcard__title a:hover { color: var(--c-primary); text-decoration: none; }
.tcard__meta { display: flex; flex-wrap: wrap; gap: 4px 10px; font-size: var(--fs-xs); color: var(--c-muted); }
.tcard__foot { display: flex; flex-direction: column; align-items: stretch; gap: 10px; margin-top: auto; padding-top: 8px; }
@container (min-width: 250px) { .tcard__foot { flex-direction: row; align-items: center; justify-content: space-between; } }
.tag {
  display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 6px; background: var(--c-subtle);
  color: var(--c-ink-2); font-size: var(--fs-xs); font-weight: 600; white-space: nowrap;
}
.tag--primary { background: var(--c-primary-50); color: var(--c-primary); }
.tag--warn { background: var(--c-warn-bg); color: var(--c-warn-text); }

/* 23 ─ commerce pieces ─────────────────────────────────────────────────────────────────────────────────── */
.price { display: inline-flex; align-items: baseline; gap: 4px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.price__value { font-weight: 800; font-size: var(--fs-base); color: var(--c-ink); letter-spacing: -.01em; }
.price__unit { font-size: var(--fs-xs); color: var(--c-muted); }
.price--lg .price__value { font-size: var(--fs-2xl); }
.price--lg .price__unit { font-size: var(--fs-sm); }

.summary { display: grid; gap: 10px; }
.summary__row { display: flex; align-items: baseline; justify-content: space-between; gap: var(--s-4); color: var(--c-ink-2); }
.summary__row dt { color: var(--c-muted); }
.summary__row dd { margin: 0; font-weight: 600; font-variant-numeric: tabular-nums; }
.summary__row--total { margin-top: 4px; padding-top: 14px; border-top: 1px dashed var(--c-border-strong); color: var(--c-ink); }
.summary__row--total dt { color: var(--c-ink); font-weight: 700; }
.summary__row--total dd { font-size: var(--fs-xl); font-weight: 800; letter-spacing: -.01em; }

.copy-field {
  display: flex; align-items: center; gap: var(--s-3); padding: 12px 12px 12px 16px;
  background: var(--c-surface); border: 1px solid var(--c-border); border-radius: var(--r);
}
.copy-field__main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.copy-field__label { font-size: var(--fs-xs); font-weight: 600; color: var(--c-muted); }
.copy-field__value { font-weight: 700; font-size: 1.0625rem; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.copy-field--hero {
  flex-wrap: wrap; padding: 18px 18px 18px 20px; border: 2px dashed var(--c-primary-300); background: var(--c-primary-50);
}
.copy-field--hero .copy-field__label { color: var(--c-info-text); font-size: var(--fs-sm); }
.copy-field--hero .copy-field__value { font-size: clamp(1.75rem, 1.3rem + 2vw, 2.25rem); letter-spacing: .02em; color: var(--c-ink); font-family: var(--font-mono); }
@media (max-width: 479.98px) { .copy-field--hero .btn { width: 100%; } }

.qr-frame { display: inline-grid; place-items: center; padding: 14px; background: #fff; border: 1px solid var(--c-border); border-radius: var(--r-lg); box-shadow: var(--shadow-sm); }
.qr-frame img { display: block; width: 240px; height: 240px; image-rendering: pixelated; }

.steps { display: grid; gap: var(--s-4); grid-template-columns: minmax(0, 1fr); counter-reset: step; list-style: none; padding: 0; }
@media (min-width: 720px) { .steps { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.steps__item { position: relative; display: flex; gap: 14px; align-items: flex-start; padding: 18px; background: var(--c-surface); border: 1px solid var(--c-border); border-radius: var(--r-lg); counter-increment: step; }
.steps__num { display: grid; place-items: center; width: 40px; height: 40px; flex: none; border-radius: 12px; background: var(--c-primary-50); color: var(--c-primary); font-weight: 800; }
.steps__num::before { content: counter(step); }
.steps__title { font-weight: 700; }
.steps__text { font-size: var(--fs-sm); color: var(--c-muted); margin-top: 2px; }

/* 24 ─ htmx, loading, motion ───────────────────────────────────────────────────────────────────────────── */
.htmx-indicator { opacity: 0; transition: opacity .2s; }
.htmx-request .htmx-indicator, .htmx-request.htmx-indicator { opacity: 1; }
.htmx-swapping { opacity: .6; transition: opacity .12s; }
.htmx-added { animation: fade-in .25s var(--ease); }
.htmx-request.btn, .htmx-request .btn[type="submit"] { cursor: progress; }
@keyframes fade-in { from { opacity: 0; } }
.loadbar { position: fixed; top: 0; left: 0; right: 0; z-index: 100; height: 3px; pointer-events: none; overflow: hidden; opacity: 0; transition: opacity .2s; }
.loadbar::before { content: ""; position: absolute; inset: 0; width: 40%; background: linear-gradient(90deg, transparent, var(--c-primary), transparent); animation: loadbar 1s ease-in-out infinite; }
.loadbar.is-active { opacity: 1; }
@keyframes loadbar { from { transform: translateX(-100%); } to { transform: translateX(250%); } }
.is-flash { animation: flash 1.2s var(--ease); }
@keyframes flash { 0% { background-color: var(--c-primary-100); } 100% { background-color: transparent; } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}

/* spacing utilities last: they must win over any component rule of the same specificity */
.mt-0 { margin-top: 0 !important; } .mt-2 { margin-top: var(--s-2); } .mt-4 { margin-top: var(--s-4); } .mt-6 { margin-top: var(--s-6); } .mt-8 { margin-top: var(--s-8); }
.mb-2 { margin-bottom: var(--s-2); } .mb-4 { margin-bottom: var(--s-4); } .mb-6 { margin-bottom: var(--s-6); }

/* 25 ─ print (job sheets and the receipt add their own sheet in css/pages/) ────────────────────────────── */
@media print {
  @page { size: A4; margin: 12mm; }
  html, body { background: #fff !important; color: #000; font-size: 10.5pt; }
  .site-header, .site-footer, .sidebar, .topbar, .drawer, .toasts, .skip-link, .loadbar, dialog,
  .no-print, .pager, .page-head__actions, .sticky-actions, .btn, .icon-btn { display: none !important; }
  .print-only { display: block !important; }
  .admin-shell { display: block; }
  .admin-content, .page { max-width: none; padding: 0 !important; }
  .container { max-width: none; padding: 0; }
  .card, .kpi, .tcard { box-shadow: none !important; border-color: #BBB; break-inside: avoid; }
  .table thead th { position: static; background: #F2F2F2 !important; color: #000; }
  .table th, .table td { border-color: #BBB; }
  .badge { border-color: #999 !important; background: none !important; color: #000 !important; }
  a { color: inherit !important; text-decoration: none !important; }
  .split { display: block; }
}
