/* ============================================================
   Orders — Design System (Phase 2)
   Tokens per approved specification: bright clean SaaS look,
   white + light blue-gray background, pastel blue accents,
   restrained pink confectionery branding, dark navy typography.
   ============================================================ */

:root {
  /* Typography */
  --font-sans: "Inter", "Segoe UI Variable", "Segoe UI", system-ui,
    -apple-system, "Roboto", "Helvetica Neue", Arial, sans-serif;

  /* Colors */
  --bg: #f6f9fe;
  --surface: #ffffff;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-soft: #eaf2ff;
  --heading: #101b3a;
  --text: #243452;
  --muted: #687a98;
  --border: #e5ebf5;
  --pink: #f47c98;
  --pink-soft: #fdeef1;
  --success: #16a36a;
  --success-soft: #e7f7f0;
  --warning: #d98b21;
  --warning-soft: #fdf3e3;
  --danger: #d64554;
  --danger-soft: #fdecee;

  /* Geometry */
  --radius-card: 18px;
  --radius-btn: 12px;
  --radius-input: 10px;
  --control-h: 44px;
  --sidebar-w: 240px;
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;

  --shadow-card: 0 1px 3px rgba(16, 27, 58, 0.06), 0 8px 24px rgba(16, 27, 58, 0.05);
  --shadow-pop: 0 4px 12px rgba(16, 27, 58, 0.1), 0 16px 40px rgba(16, 27, 58, 0.12);
  --focus-ring: 0 0 0 3px rgba(37, 99, 235, 0.25);
}

* {
  box-sizing: border-box;
}

/* ============================================================
   Locally hosted Inter (SIL OFL 1.1, variable weight 100-900).
   Served from /static/fonts — no CDN or internet dependency.
   Armenian glyphs are not present in Inter's published builds and
   fall back to Segoe UI (verified U+0540/U+0561/U+0587 coverage).
   ============================================================ */

@font-face {
  font-family: "Inter";
  src: url("/static/fonts/InterVariable.woff2") format("woff2-variations");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Inter";
  src: url("/static/fonts/InterVariable-Italic.woff2") format("woff2-variations");
  font-weight: 100 900;
  font-style: italic;
  font-display: swap;
}

html {
  font-size: 16px;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

button,
input,
select,
textarea {
  font-family: inherit;
}

h1, h2, h3, h4 {
  color: var(--heading);
  margin: 0;
}

p {
  margin: 0;
}

a {
  color: var(--primary);
  text-decoration: none;
}

a:hover {
  color: var(--primary-hover);
}

/* Focus accessibility */
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
summary:focus-visible,
[tabindex]:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
  border-radius: var(--radius-input);
}

/* ============================================================
   Buttons
   ============================================================ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  height: var(--control-h);
  padding: 0 var(--space-5);
  border-radius: var(--radius-btn);
  border: 1px solid transparent;
  font-size: 0.95rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition: background-color 120ms ease, border-color 120ms ease, color 120ms ease;
}

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

.btn-primary {
  background: var(--primary);
  color: #fff;
}

.btn-primary:hover:not(:disabled) {
  background: var(--primary-hover);
  color: #fff;
}

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

.btn-outline:hover:not(:disabled) {
  border-color: var(--primary);
  color: var(--primary);
}

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

.btn-ghost:hover:not(:disabled) {
  background: var(--primary-soft);
  color: var(--primary);
}

.btn-danger {
  background: var(--danger);
  color: #fff;
}

.btn-danger:hover:not(:disabled) {
  background: #bf3443;
  color: #fff;
}

.btn-sm {
  height: 36px;
  padding: 0 var(--space-4);
  font-size: 0.875rem;
  border-radius: 10px;
}

.btn-block {
  width: 100%;
}

/* ============================================================
   Cards
   ============================================================ */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  padding: var(--space-6);
  box-shadow: var(--shadow-card);
}

.card + .card {
  margin-top: var(--space-5);
}

.card__title {
  font-size: 1.05rem;
  font-weight: 700;
}

.card__text {
  color: var(--muted);
  margin-top: var(--space-2);
}

/* ============================================================
   Forms
   ============================================================ */

.field {
  margin-bottom: var(--space-4);
}

.field__label {
  display: block;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--heading);
  margin-bottom: var(--space-2);
}

.field__help {
  font-size: 0.8rem;
  color: var(--muted);
  margin-top: var(--space-1);
}

.field__error {
  font-size: 0.8rem;
  color: var(--danger);
  margin-top: var(--space-1);
}

.input,
.select,
.textarea {
  width: 100%;
  min-height: var(--control-h);
  padding: 0 var(--space-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-input);
  background: var(--surface);
  color: var(--text);
  font-size: 0.95rem;
  font-family: inherit;
}

.textarea {
  padding: var(--space-3);
  min-height: 96px;
  resize: vertical;
}

.input:focus,
.select:focus,
.textarea:focus {
  border-color: var(--primary);
  box-shadow: var(--focus-ring);
  outline: none;
}

.input[aria-invalid="true"],
.select[aria-invalid="true"],
.textarea[aria-invalid="true"] {
  border-color: var(--danger);
}

.input:disabled {
  background: var(--bg);
  color: var(--muted);
}

/* Checkboxes / radio rows */

.check-row {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-input);
  margin-bottom: var(--space-2);
  background: var(--surface);
  cursor: pointer;
}

.check-row:hover {
  border-color: var(--primary);
}

.check-row input[type="checkbox"],
.check-row input[type="radio"] {
  margin-top: 3px;
  width: 16px;
  height: 16px;
  accent-color: var(--primary);
  flex-shrink: 0;
}

.check-row__title {
  font-weight: 600;
  color: var(--heading);
  font-size: 0.9rem;
}

.check-row__sub {
  font-size: 0.8rem;
  color: var(--muted);
}

/* ============================================================
   Alerts
   ============================================================ */

.alert {
  display: flex;
  gap: var(--space-3);
  align-items: flex-start;
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-input);
  border: 1px solid;
  font-size: 0.9rem;
  margin-bottom: var(--space-4);
}

.alert--info {
  background: var(--primary-soft);
  border-color: #c9dcff;
  color: var(--heading);
}

.alert--success {
  background: var(--success-soft);
  border-color: #bfe7d7;
  color: #0d6b47;
}

.alert--warning {
  background: var(--warning-soft);
  border-color: #f2dfbd;
  color: #7a4e0e;
}

.alert--error {
  background: var(--danger-soft);
  border-color: #f5c9cf;
  color: #8f2533;
}

/* ============================================================
   Badges / chips
   ============================================================ */

.chip {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  background: var(--primary-soft);
  color: var(--primary-hover);
  border: 1px solid transparent;
  white-space: nowrap;
}

.chip--pink {
  background: var(--pink-soft);
  color: #b34d63;
}

.chip--success {
  background: var(--success-soft);
  color: var(--success);
}

.chip--muted {
  background: #eef3fa;
  color: var(--muted);
}

.chip--warning {
  background: var(--warning-soft);
  color: var(--warning);
}

/* R57: the 1C document of a sent order is posted («Проведён») */
.chip--posted {
  background: #fff1b8;
  color: #7a5c00;
}

/* R68: a sent order not yet posted in 1C («Отправлен») — between the grey of a draft and the yellow of «Проведён» */
.chip--sent {
  background: #f3efdc;
  color: #6f6a52;
}

/* R68: the 1C document of the order is cancelled / deletion-marked («Отменён») */
.chip--cancelled {
  background: var(--danger-soft);
  color: var(--danger);
}

/* R68: the number of a cancelled order is struck through with a semi-transparent grey line.
   R70: also beats the later `.order-row__number { text-decoration: none }` of the orders list (higher specificity). */
.order-number--cancelled,
.order-row__number.order-number--cancelled {
  text-decoration: line-through;
  text-decoration-color: rgba(104, 122, 152, 0.55);
  text-decoration-thickness: 2px;
}

/* ============================================================
   Auth layout
   ============================================================ */

/* «Бисквит» welcome screen: the form on the left, the photo on the right;
   on phones the photo becomes a short band above the form. */
body.auth-body {
  background: var(--surface);
}

.auth-split {
  display: grid;
  grid-template-columns: minmax(380px, 46%) 1fr;
  min-height: 100vh;
}

.auth-split__panel {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-8) var(--space-6);
}

.auth-split__photo {
  background-color: #eef2f7;
  background-position: center;
  background-size: cover;
  background-repeat: no-repeat;
}

.auth-card {
  width: 100%;
  max-width: 420px;
}

.auth-brand {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-bottom: var(--space-6);
}

.auth-brand__logo {
  display: block;
  width: min(300px, 78%);
  height: auto;
}

.auth-input {
  position: relative;
}

.auth-input__icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  pointer-events: none;
}

.auth-input .input {
  padding-left: 42px;
}

@media (max-width: 860px) {
  .auth-split {
    grid-template-columns: 1fr;
    grid-template-rows: 30vh auto;
  }

  .auth-split__photo {
    grid-row: 1;
  }

  .auth-split__panel {
    grid-row: 2;
    align-items: flex-start;
    padding: var(--space-6) var(--space-4) var(--space-8);
  }
}

@media (max-width: 860px) and (max-height: 640px) {
  .auth-split {
    grid-template-rows: 18vh auto;
  }
}

/* Brand logo (vector, the original calligraphy) in the app shell. */
.brand-logo {
  display: block;
  height: auto;
}

.sidebar__brand {
  text-decoration: none;
}

.sidebar__brand .brand-logo {
  width: 150px;
}

.topbar__brand {
  display: none;
}

.topbar__brand .brand-logo {
  width: 92px;
}

.brand-mark {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--primary) 0%, #5b8def 100%);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 1.3rem;
}

.brand-mark--pink {
  background: linear-gradient(135deg, var(--pink) 0%, #f7a0b4 100%);
}

.auth-title {
  font-size: 1.85rem;
  font-weight: 800;
  color: var(--heading);
  margin-bottom: var(--space-2);
}

.auth-subtitle {
  color: var(--muted);
  font-size: 1.05rem;
  margin-bottom: var(--space-6);
}

.auth-footer {
  margin-top: var(--space-6);
  text-align: center;
  font-size: 0.8rem;
  color: var(--muted);
  text-wrap: balance;
}

/* ============================================================
   App shell (sidebar + topbar)
   ============================================================ */

.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100vh;
}

.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: var(--space-5) var(--space-4);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  position: sticky;
  top: 0;
  height: 100vh;
  /* R40: the navigation scrolls on its own inside the viewport (wheel / trackpad over it scroll the menu, not the
     page; the page never drags it along); its items keep their size instead of being squeezed */
  height: 100dvh;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
}

.sidebar > * { flex-shrink: 0; }

.sidebar__brand {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  margin-bottom: var(--space-4);
}

.sidebar__name {
  font-weight: 800;
  font-size: 1.15rem;
  color: var(--heading);
}

.sidebar__section {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  padding: var(--space-3) var(--space-3) var(--space-2);
}

.nav-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: 10px var(--space-3);
  border-radius: var(--radius-input);
  color: var(--text);
  font-weight: 600;
  font-size: 0.925rem;
  text-decoration: none;
}

.nav-item svg {
  flex-shrink: 0;
  color: var(--muted);
}

.nav-item:hover {
  background: var(--primary-soft);
  color: var(--primary);
}

.nav-item:hover svg {
  color: var(--primary);
}

.nav-item--active {
  background: var(--primary-soft);
  color: var(--primary);
}

.nav-item--active svg {
  color: var(--primary);
}

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

.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: var(--space-3) var(--space-6);
  display: flex;
  align-items: center;
  gap: var(--space-4);
  position: sticky;
  top: 0;
  z-index: 20;
}

.topbar__spacer {
  flex: 1;
}

.topbar__user {
  font-weight: 600;
  color: var(--heading);
  font-size: 0.925rem;
  white-space: nowrap;
}

/* Active-store switcher (native details dropdown, no JS) */

.store-switcher {
  position: relative;
}

.store-switcher summary {
  list-style: none;
  display: flex;
  align-items: center;
  gap: var(--space-2);
  height: var(--control-h);
  padding: 0 var(--space-4);
  border: 1px solid #c9dcff;
  background: var(--primary-soft);
  color: var(--primary-hover);
  border-radius: var(--radius-btn);
  font-weight: 700;
  font-size: 0.9rem;
  cursor: pointer;
  white-space: nowrap;
}

.store-switcher summary::-webkit-details-marker {
  display: none;
}

.store-switcher--empty summary {
  background: var(--warning-soft);
  border-color: #f2dfbd;
  color: var(--warning);
}

.store-switcher__menu {
  position: absolute;
  top: calc(100% + var(--space-2));
  left: 0;
  min-width: 280px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-btn);
  box-shadow: var(--shadow-pop);
  padding: var(--space-2);
  z-index: 50;
}

.store-switcher__menu form {
  margin: 0;
}

.store-switcher__menu .btn {
  justify-content: flex-start;
  width: 100%;
}

.store-switcher__item {
  display: flex;
  width: 100%;
  align-items: center;
  gap: var(--space-3);
  border: none;
  background: transparent;
  padding: 10px var(--space-3);
  border-radius: var(--radius-input);
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
  text-align: left;
}

.store-switcher__item:hover {
  background: var(--primary-soft);
  color: var(--primary);
}

.store-switcher__item--active {
  background: var(--primary-soft);
  color: var(--primary);
}

/* Content region */

.content {
  padding: var(--space-4) var(--space-6);
  max-width: 1080px;
  width: 100%;
}

/* Wide admin pages (directory, storefront, single-user creation) use the
   full available width — root cause of the previously narrow table was
   this 1080px cap combined with the three-column directory grid. */
.content--wide {
  max-width: none;
}

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  flex-wrap: wrap;
  margin-bottom: var(--space-6);
}

.page-title {
  font-size: 1.45rem;
  font-weight: 800;
}

.page-subtitle {
  color: var(--muted);
  margin-top: 2px;
}

/* Data rows (clean list instead of enterprise tables) */

.data-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.data-row {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  padding: var(--space-4) var(--space-5);
  display: flex;
  align-items: center;
  gap: var(--space-4);
  flex-wrap: wrap;
  box-shadow: var(--shadow-card);
}

.data-row__main {
  flex: 1;
  min-width: 180px;
}

.data-row__title {
  font-weight: 700;
  color: var(--heading);
}

.data-row__sub {
  color: var(--muted);
  font-size: 0.85rem;
  margin-top: 2px;
}

.data-row__meta {
  display: flex;
  gap: var(--space-2);
  flex-wrap: wrap;
}

.data-row__actions {
  display: flex;
  gap: var(--space-2);
  flex-wrap: wrap; /* R71: on a narrow tablet / phone the buttons wrap instead of leaving the screen */
}

/* Permission groups */

.perm-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: var(--space-3);
}

.perm-group__title {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--heading);
  margin: var(--space-5) 0 var(--space-3);
}

/* Preview page */

.preview-banner {
  background: var(--primary-soft);
  border: 1px solid #c9dcff;
  border-radius: var(--radius-card);
  padding: var(--space-4) var(--space-5);
  margin-bottom: var(--space-5);
  color: var(--heading);
  font-size: 0.9rem;
}

.perm-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
  margin: 2px;
}

.perm-tag--on {
  background: var(--success-soft);
  color: #0d6b47;
}

.perm-tag--off {
  background: #eef3fa;
  color: var(--muted);
}

/* Empty state */

.empty-state {
  text-align: center;
  padding: var(--space-8) var(--space-6);
  color: var(--muted);
}

.empty-state__icon {
  font-size: 2rem;
  margin-bottom: var(--space-3);
}

.empty-state__title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--heading);
}

/* Utility */

.muted {
  color: var(--muted);
}

.small {
  font-size: 0.8rem;
}

.mt-2 { margin-top: var(--space-2); }
.mt-4 { margin-top: var(--space-4); }
.mb-4 { margin-bottom: var(--space-4); }
.mb-2 { margin-bottom: var(--space-2); }

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-4);
}

/* ============================================================
   Customer directory manager (3-area layout)
   ============================================================ */

.directory-shell {
  display: grid;
  grid-template-columns: 300px 1fr 340px;
  gap: var(--space-4);
  align-items: start;
}

/* Basket removed: two panes only; the table takes ALL remaining width. */
.directory-shell--two {
  grid-template-columns: 320px minmax(0, 1fr);
}

@media (min-width: 1600px) {
  .directory-shell {
    grid-template-columns: 360px 1fr 360px;
  }

  .directory-shell--two {
    grid-template-columns: 380px minmax(0, 1fr);
  }
}

.directory-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  padding: var(--space-4);
  box-shadow: var(--shadow-card);
  min-height: 300px;
}

.directory-panel--grow {
  min-width: 0;
}

.directory-panel__title {
  font-weight: 700;
  color: var(--heading);
  margin-bottom: var(--space-3);
}

.directory-toolbar {
  display: flex;
  gap: var(--space-2);
  margin-bottom: var(--space-3);
}

.directory-toolbar .input {
  flex: 1;
}

.directory-toolbar .select {
  max-width: 220px;
}

.directory-tree {
  font-size: 0.9rem;
  max-height: 62vh;
  overflow-y: auto;
}

.directory-tree__node {
  margin-left: 0;
}

.directory-tree__sub {
  margin-left: var(--space-3);
  border-left: 1px solid var(--border);
  padding-left: var(--space-2);
}

.directory-tree__item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  width: 100%;
  text-align: left;
  background: transparent;
  border: none;
  border-radius: var(--radius-input);
  padding: 6px var(--space-2);
  font-family: inherit;
  font-size: 0.875rem;
  color: var(--text);
  cursor: pointer;
}

.directory-tree__item:hover {
  background: var(--primary-soft);
}

.directory-tree__item--active {
  background: var(--primary-soft);
  color: var(--primary-hover);
  font-weight: 600;
}

.directory-check {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  cursor: pointer;
  font-weight: 700;
  color: var(--heading);
}

.directory-check input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--primary);
}

@media (max-width: 1100px) {
  .directory-shell {
    grid-template-columns: 1fr;
  }

  .directory-panel {
    min-height: 0;
  }

  .directory-tree {
    max-height: 40vh;
  }
}

/* ============================================================
   1C-style directory tree (shared by counterparty + nomenclature)
   ============================================================ */

.tree-row {
  display: flex;
  align-items: center;
  gap: 5px;
  width: 100%;
  padding: 3px 6px;
  border-radius: var(--radius-input);
  cursor: pointer;
  font-size: 0.85rem;
  color: var(--text);
  border: none;
  background: transparent;
  text-align: left;
  box-sizing: border-box;
}

.tree-row:hover {
  background: var(--primary-soft);
}

.tree-row--active {
  background: var(--primary-soft);
  color: var(--primary-hover);
  font-weight: 600;
}

.tree-toggle {
  width: 18px;
  height: 18px;
  flex: 0 0 18px;
  border: none;
  background: transparent;
  cursor: pointer;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
}

.tree-toggle svg {
  width: 12px;
  height: 12px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.5;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: transform 0.15s ease;
}

.tree-toggle--closed svg {
  transform: rotate(-90deg);
}

.tree-folder {
  flex: 0 0 17px;
  width: 17px;
  height: 17px;
  display: inline-flex;
  align-items: center;
}

.tree-folder svg {
  width: 17px;
  height: 17px;
  fill: #f5c518;
  stroke: #a97f00;
  stroke-width: 1.3;
}

.tree-label {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tree-count {
  color: var(--muted);
  font-size: 0.72rem;
  flex: 0 0 auto;
}

.group-check {
  width: 16px;
  height: 16px;
  flex: 0 0 16px;
  margin: 0;
  accent-color: var(--primary);
  cursor: pointer;
}

/* R40: the checkbox shows the EFFECTIVE selection — an inherited folder is checked exactly like an explicit one
   (the «наследует» tag tells them apart); no faded / disabled look for an included folder */
.group-check:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.group-check:disabled { cursor: not-allowed; }

@media (pointer: coarse) {
  .group-check { width: 22px; height: 22px; flex-basis: 22px; }
  .tree-row { min-height: 40px; }
}

.group-check-spacer {
  width: 15px;
  height: 15px;
  flex: 0 0 15px;
  display: inline-block;
}

.field__help {
  font-size: 0.75rem;
  color: var(--muted);
  margin-top: 2px;
}

/* ============================================================
   Role assortment editor: TWO editing panels on top, one full-width
   final summary block below (approved layout)
   ============================================================ */

.role-explorer {
  display: grid;
  grid-template-columns: 28% minmax(0, 1fr);
  gap: var(--space-4);
  align-items: start;
}

@media (max-width: 1100px) {
  .role-explorer {
    grid-template-columns: 1fr;
  }
}

.assortment-summary {
  margin-top: var(--space-4);
}

.assortment-summary__head {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex-wrap: wrap;
}

.assortment-summary__tree {
  max-height: 520px;
  overflow-y: auto;
  padding-right: 6px;
}

.role-main-sections summary {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-3) 0;
}

.role-main-sections .card {
  border: none;
  box-shadow: none;
  padding-left: 0;
  padding-right: 0;
}

/* Effective assortment panel */

.eff-group {
  border: 1px solid var(--border);
  border-radius: var(--radius-input);
  margin-bottom: var(--space-2);
  background: var(--surface);
}

.eff-group--active {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px var(--primary-soft);
}

.eff-group__head {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 8px;
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--heading);
  min-width: 0;
}

.eff-group__head:hover {
  background: var(--primary-soft);
}

.eff-group__name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.eff-group__counts {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 500;
  flex-shrink: 0;
  white-space: nowrap;
}

.eff-chevron {
  color: var(--muted);
  font-size: 0.7rem;
  transition: transform 0.15s ease;
  display: inline-block;
  flex-shrink: 0;
}

.eff-chevron--closed {
  transform: rotate(-90deg);
}

.eff-group__body {
  border-top: 1px solid var(--border);
  padding: 4px;
  margin-left: 18px;
  margin-right: 4px;
}

.eff-table {
  table-layout: fixed;
  width: 100%;
}

.eff-table th:first-child,
.eff-table td:first-child {
  width: 46%;
}

.eff-table td {
  padding: 3px 6px;
  font-size: 0.8rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  vertical-align: top;
}

.eff-table .dir-name {
  font-weight: 500;
}

/* ============================================================
   Two-column user editor (V2 action row replaces the top bar)
   ============================================================ */

/* ============================================================
   User card V2 (approved design)
   ============================================================ */

.user-card__grid {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr);
  gap: var(--space-6);
  align-items: start;
}

.user-card__col {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  min-width: 0;
}

.input--readonly {
  display: flex;
  align-items: center;
  background: #f4f7fb;
  color: var(--heading);
  font-weight: 600;
  cursor: default;
  min-height: var(--control-h);
  padding: 0 var(--space-4);
  border: 1px solid var(--border);
  border-radius: var(--radius-input);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Roles multi-select popover (absolutely positioned — never reflows) */

.roles-select {
  position: relative;
}

.roles-field {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  width: 100%;
  min-height: var(--control-h);
  padding: 6px var(--space-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-input);
  background: var(--surface);
  cursor: pointer;
  font-family: inherit;
  font-size: 0.9rem;
  text-align: left;
  color: var(--text);
}

.roles-field:focus-visible {
  box-shadow: var(--focus-ring);
}

.roles-field__chips {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.roles-field__empty {
  color: var(--muted);
  font-size: 0.85rem;
}

.roles-field__caret {
  color: var(--muted);
  flex-shrink: 0;
}

.roles-pop {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-input);
  box-shadow: var(--shadow-pop);
  z-index: 30;
  max-height: 204px; /* ~5 options visible */
  overflow-y: auto;
  padding: 4px;
}

.roles-opt {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: 8px 10px;
  border-radius: var(--radius-input);
  cursor: pointer;
  font-size: 0.9rem;
}

.roles-opt:hover {
  background: var(--primary-soft);
}

.roles-opt input {
  width: 16px;
  height: 16px;
  accent-color: var(--primary);
}

/* Password section */

.password-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr);
  gap: var(--space-6);
  align-items: start;
}

/* Action row */

.action-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  flex-wrap: wrap;
  margin-top: var(--space-5);
  padding: var(--space-4);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-input);
}

.action-row__left {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex-wrap: wrap;
}

@media (max-width: 1100px) {
  .user-card__grid,
  .password-grid {
    grid-template-columns: 1fr;
  }

  .user-edit-grid {
    grid-template-columns: 1fr;
  }
}

/* ============================================================
   Product detail page (customer storefront)
   ============================================================ */

.product-detail {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 0.9fr);
  gap: var(--space-6);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  padding: var(--space-6);
  box-shadow: var(--shadow-card);
  align-items: start;
  max-width: 1080px;
}

.qty-stepper {
  display: flex;
  align-items: stretch;
}

.qty-stepper .input {
  width: 96px;
  text-align: center;
  border-radius: 0;
}

.qty-stepper .btn:first-child {
  border-top-right-radius: 0;
  border-bottom-right-radius: 0;
}

.qty-stepper .btn:last-child {
  border-top-left-radius: 0;
  border-bottom-left-radius: 0;
}

/* ============================================================
   Characteristic choice controls (catalog cards + detail page)
   ============================================================ */

.product-card__chars,
.product-detail__chars {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: var(--space-2) 0;
}

.product-detail__chars-label {
  font-size: 0.75rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--muted);
}

.char-option {
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  min-height: 34px;
  cursor: pointer;
  font-size: 0.88rem;
  line-height: 1.35;
}

.char-option:hover {
  border-color: var(--primary);
}

.char-option:has(input:checked) {
  border-color: var(--primary);
  background: var(--primary-soft);
  box-shadow: 0 0 0 1px var(--primary);
}

.char-option:focus-within {
  outline: 2px solid var(--primary);
  outline-offset: 1px;
}

.char-option input[type="radio"] {
  width: 15px;
  height: 15px;
  flex-shrink: 0;
  accent-color: var(--primary);
}

.char-option span {
  overflow-wrap: anywhere;
  white-space: normal;
  min-width: 0;
}

.char-option__price {
  color: var(--muted);
  font-size: 0.8rem;
  white-space: nowrap;
  margin-left: auto;
}

@media (max-width: 960px) {
  .char-option {
    min-height: 44px;
    padding: 10px 12px;
  }

  /* Phase 6E mobile: 44px touch targets stay; the 191px cap + scroll
     engage only when a 5th option exists (4×44 + 3×4 = 188 <= 191). */
  .product-card__chars:has(.char-option:nth-child(5)) {
    max-height: 191px;
  }

  .product-card__chars {
    gap: 4px;
  }
}

/* ultra-narrow safety: scale the fixed media blocks proportionally,
   never cause horizontal overflow */
@media (max-width: 340px) {
  .product-card__media {
    width: 100%;
    height: auto;
    aspect-ratio: 4 / 3;
  }

  .product-card--portrait .product-card__media {
    width: 112px;
    height: 250px;
  }
}

.cart-line__name .chip {
  margin-left: 6px;
}

.product-detail__media {
  min-width: 0;
}

.product-detail__image {
  width: 100%;
  aspect-ratio: 4 / 3;
  max-height: 460px;
  object-fit: contain;
  border-radius: var(--radius-input);
  border: 1px solid var(--border);
  background: #f6f8fc;
}

.product-detail__placeholder {
  aspect-ratio: 4 / 3;
  max-height: 460px;
  width: 100%;
  border-radius: var(--radius-input);
  background:
    radial-gradient(circle at 50% 40%, rgba(255, 255, 255, 0.95), rgba(242, 246, 253, 0) 62%),
    linear-gradient(135deg, #f2f6fd, #e6edfa);
  border: 1px dashed #c9d6ee;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-3);
}

.product-detail__placeholder-mark {
  width: 88px;
  height: 88px;
  border-radius: 50%;
  background: #ffffff;
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.3rem;
  font-weight: 800;
  color: var(--primary);
  box-shadow: var(--shadow-card);
}

.product-detail__placeholder-caption {
  font-size: 0.85rem;
  color: var(--muted);
}

.product-detail__crumbs {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1) var(--space-2);
  align-items: center;
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: var(--space-4);
}

.product-detail__crumbs a {
  color: var(--primary);
  text-decoration: none;
}

.product-detail__crumbs a:hover {
  text-decoration: underline;
}

.product-detail__crumbs-current {
  color: var(--heading);
  font-weight: 600;
}

.product-detail__gallery {
  display: flex;
  gap: var(--space-2);
  margin-top: var(--space-3);
  flex-wrap: wrap;
}

.product-detail__thumb {
  border: 2px solid transparent;
  border-radius: var(--radius-input);
  padding: 0;
  background: none;
  cursor: pointer;
  overflow: hidden;
  width: 64px;
  height: 64px;
}

.product-detail__thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.product-detail__thumb--active {
  border-color: var(--primary);
}

.product-detail__name {
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--heading);
  margin-bottom: var(--space-2);
}

.product-detail__pricebox {
  margin: var(--space-5) 0;
}

.product-detail__price-label {
  font-size: 0.75rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: var(--space-1);
}

.product-detail__price {
  font-size: 1.5rem;
  margin-bottom: 0;
}

.product-detail__descblock {
  margin-bottom: var(--space-5);
}

.product-detail__desc-label {
  font-size: 0.75rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: var(--space-2);
}

.product-detail__description {
  white-space: pre-line;
  color: var(--text);
  font-size: 0.95rem;
  line-height: 1.6;
}

.product-detail__actions {
  display: flex;
  gap: var(--space-3);
  align-items: center;
  flex-wrap: wrap;
}

.product-card__media,
.product-card__name {
  text-decoration: none;
  display: block;
}

@media (max-width: 960px) {
  .product-detail {
    grid-template-columns: 1fr;
    padding: var(--space-4);
  }
}

/* ============================================================
   Product settings two-column layout (50/50 on wide screens)
   ============================================================ */

.settings-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: var(--space-4);
  align-items: start;
}

@media (max-width: 960px) {
  .settings-grid {
    grid-template-columns: 1fr;
  }
}

/* ============================================================
   Nomenclature explorer (two panes)
   ============================================================ */

.explorer-shell {
  display: grid;
  grid-template-columns: 420px 1fr;
  gap: var(--space-4);
  align-items: start;
}

.catalog-explorer {
  grid-template-columns: 340px 1fr;
}

.explorer-pane {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  padding: var(--space-3);
  min-width: 0;
}

.explorer-pane__title {
  font-weight: 700;
  color: var(--heading);
  margin-bottom: var(--space-2);
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.explorer-tree {
  max-height: 56vh;
  overflow-y: auto;
  overflow-x: hidden;
}

.explorer-products {
  max-height: 52vh;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-input);
}

.explorer-toolbar {
  display: flex;
  gap: var(--space-2);
  align-items: center;
  margin-bottom: var(--space-2);
  flex-wrap: wrap;
}

.explorer-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.explorer-table th {
  text-align: left;
  padding: 6px 8px;
  border-bottom: 1px solid var(--border);
  color: var(--muted);
  font-weight: 600;
  position: sticky;
  top: 0;
  background: var(--surface);
  z-index: 1;
}

.explorer-table td {
  padding: 5px 8px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.explorer-table tbody tr:hover td {
  background: var(--primary-soft);
}

.explorer-table tr.explorer-row--unavailable td {
  color: var(--muted);
  background: #f4f6f8;
}

.product-check {
  width: 15px;
  height: 15px;
  accent-color: var(--primary);
  cursor: pointer;
}

.state-tag {
  display: inline-block;
  font-size: 0.72rem;
  padding: 1px 8px;
  border-radius: 999px;
  font-weight: 600;
  white-space: nowrap;
}

.state-tag--inherit {
  background: var(--primary-soft);
  color: var(--primary-hover);
}

.state-tag--allow {
  background: var(--success-soft);
  color: #0d6b47;
}

.state-tag--exclude {
  background: #fde8e8;
  color: #b3261e;
}

.state-tag--unavailable {
  background: #eef3fa;
  color: var(--muted);
}

.state-tag--partial {
  background: #fff4d6;
  color: #8a5a00;
}

/* Organization-first user directory rows */

.user-row .data-row__title {
  font-size: 1.05rem;
}

.user-row .data-row__sub {
  font-size: 0.8rem;
}

/* Compact counterparty directory table + independent scrolling */

.directory-scroll {
  max-height: 58vh;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-input);
}

.dir-table th {
  position: sticky;
  top: 0;
  background: var(--surface);
  z-index: 1;
}

.dir-table td {
  padding: 5px 8px;
  font-size: 0.85rem;
  vertical-align: top;
}

.dir-table td.dir-name {
  font-weight: 600;
  white-space: normal;
  word-break: break-word;
}

.dir-pagination {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

/* Preview demo cart */

.preview-cart-line {
  display: flex;
  justify-content: space-between;
  gap: var(--space-3);
  align-items: center;
}

/* Single-user creation view */

.single-user-shell {
  display: grid;
  grid-template-columns: minmax(0, 780px) 320px;
  gap: var(--space-4);
  align-items: start;
}

.single-user-card {
  min-width: 0;
}

@media (max-width: 1100px) {
  .single-user-shell {
    grid-template-columns: 1fr;
  }
}

/* ============================================================
   Customer-facing storefront
   ============================================================ */

.preview-admin {
  margin-bottom: var(--space-6);
}

.storefront {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  overflow: hidden;
  box-shadow: var(--shadow-card);
}

.storefront__header {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-4);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}

.storefront__brand {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-weight: 800;
  color: var(--heading);
}

.storefront__org {
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 600;
  max-width: 340px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.storefront__search {
  flex: 1;
  min-width: 220px;
  max-width: 480px;
  margin-left: auto;
}

.storefront__body {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  min-height: 420px;
}

.storefront__nav {
  border-right: 1px solid var(--border);
  padding: var(--space-4);
  overflow-y: auto;
  overflow-x: hidden;
  max-height: 72vh;
}

.storefront__nav-title {
  font-weight: 700;
  color: var(--heading);
  margin-bottom: var(--space-2);
}

.storefront__cat {
  display: flex;
  justify-content: space-between;
  gap: var(--space-2);
  width: 100%;
  text-align: left;
  padding: 8px 10px;
  border: none;
  background: transparent;
  border-radius: var(--radius-input);
  font-family: inherit;
  font-size: 0.9rem;
  color: var(--text);
  cursor: pointer;
}

.storefront__cat-name {
  min-width: 0;
  overflow-wrap: anywhere;
  text-align: left;
}

.storefront__cat-count {
  flex-shrink: 0;
}

.storefront__cat:hover {
  background: var(--primary-soft);
}

.storefront__cat--active {
  background: var(--primary-soft);
  color: var(--primary-hover);
  font-weight: 600;
}

.storefront__cat-count {
  color: var(--muted);
  font-size: 0.75rem;
  flex-shrink: 0;
}

.storefront__main {
  padding: var(--space-4);
  min-width: 0;
  /* R5: the card grid sizes itself from THIS box (after the app sidebar and the
     category panel), not from the browser window. */
  container: catalog / inline-size;
}

.storefront__title {
  font-weight: 800;
  color: var(--heading);
  margin-bottom: var(--space-4);
}

/* Phase 6D: adaptive card composition. Rows equalize LOCALLY (each row
   takes the height of its tallest card; the next row is independent).
   Cards stretch and the internal spacer anchors the footer at the row
   bottom. No global fixed/minimum card height. */
/* R5: the column count follows the width available to the catalog. A column is
   at least 270px and at most 330px wide, gaps are 14px, at most four columns:
   4 from 4·270+3·14 = 1122px, 3 from 838px, 2 from 554px, else 1. Columns are
   minmax(0, …) so they can never be wider than the box (the old fixed
   repeat(4, 330px) from a 1700px WINDOW needed 1362px and was cut off by
   .storefront's overflow:hidden). The first rule is the fallback for browsers
   without container queries. */
.storefront__grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 270px), 330px));
  gap: 14px;
  justify-content: start;
}

@container catalog (min-width: 0px) {
  .storefront__grid { grid-template-columns: minmax(0, 330px); }
}

@container catalog (min-width: 554px) {
  .storefront__grid { grid-template-columns: repeat(2, minmax(0, 330px)); }
}

@container catalog (min-width: 838px) {
  .storefront__grid { grid-template-columns: repeat(3, minmax(0, 330px)); }
}

@container catalog (min-width: 1122px) {
  .storefront__grid { grid-template-columns: repeat(4, minmax(0, 330px)); }
}

.product-card {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 13px;
  background: var(--surface);
  display: flex;
  flex-direction: column;
  gap: 10px;
  box-shadow: var(--shadow-card);
  min-width: 0;
  max-width: 330px;
}

/* VERTICAL composition — wide profile: FIXED 280×210 (4:3) photo block
   on top, everything text/controls below it. */
.product-card__media {
  width: 280px;
  height: 210px;
  max-width: 100%;
  flex-shrink: 0;
  align-self: center;
  border-radius: var(--radius-input);
  background:
    radial-gradient(circle at 50% 40%, rgba(255, 255, 255, 0.95), rgba(242, 246, 253, 0) 62%),
    linear-gradient(135deg, #f2f6fd, #e6edfa);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--primary);
  text-decoration: none;
  overflow: hidden;
}

.product-card__media img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.product-card__media-mark {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: #ffffff;
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--primary);
}

/* ---- PORTRAIT profile: FIXED 125×280 media block LEFT, text column
   RIGHT, description inside the column, characteristics + footer below
   the media/text row. */
.product-card--portrait .product-card__row {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  min-width: 0;
}

.product-card--portrait .product-card__media {
  width: 125px;
  height: 280px;
  margin: 0;
  align-self: flex-start;
}

.product-card--portrait .product-card__titles {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.product-card--portrait .product-card__name {
  font-size: 0.86rem; /* 12–14px column scale */
  -webkit-line-clamp: 4; /* long names wrap, max 4 lines */
}

.product-card--portrait .product-card__meta {
  font-size: 0.72rem;
}

.product-card--portrait .storefront__price {
  font-size: 0.95rem;
}

.product-card--portrait .product-card__desc {
  font-size: 0.76rem;
  line-height: 1.4;
}

.product-card__name {
  display: block;
  font-weight: 700;
  color: var(--heading);
  font-size: 0.92rem;
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-decoration: none;
}

.product-card__meta {
  color: var(--muted);
  font-size: 0.75rem;
  margin-top: 2px;
}

.storefront__price {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--primary-hover);
  padding-top: 2px;
}

.storefront__price--missing {
  color: var(--danger);
  font-size: 0.82rem;
  font-weight: 600;
}

/* real description preview (2–3 lines, Type B only) */
.product-card__desc {
  font-size: 0.8125rem;
  line-height: 1.5;
  color: var(--text);
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* flexible spacer: pushes the action row to the shared card bottom */
.product-card__spacer {
  flex: 1 1 auto;
  min-height: 0;
}

/* Phase 6E: content-dependent overflow. The cap + internal scroll
   engage ONLY when a 5th option exists. Four or fewer options never
   show a scrollbar and are never clipped (immune to border/padding/
   rounding drift). Desktop geometry: 4×32 + 3×4 = 140px <= 151px. */
.product-card__chars:has(.char-option:nth-child(5)) {
  max-height: 151px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.product-card__chars:has(.char-option:nth-child(5))::-webkit-scrollbar {
  width: 6px;
}

.product-card__chars:has(.char-option:nth-child(5))::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}

@media (min-width: 961px) {
  /* desktop card selectors: compact rows (4×32 + 3×4 = 140 <= 151),
     horizontal padding and readable prices preserved */
  .product-card__chars {
    gap: 4px;
  }

  .product-card__chars .char-option {
    min-height: 32px;
    padding: 5px 10px;
  }
}

/* bottom action row — exact 50/50 split, both controls 40px tall */
.product-card__actions {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 10px;
  align-items: stretch;
  min-width: 0;
}

.product-card__actions .input {
  width: 100%;
  min-width: 0;
  height: 40px;
  min-height: 40px;
  padding: 0 8px 0 12px; /* value LEFT-aligned with 12px padding */
  font-size: 0.9rem;
  text-align: left;
}

.product-card__actions .btn {
  width: 100%;
  min-width: 0;
  height: 40px;
  padding-left: 8px;
  padding-right: 8px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.storefront__empty {
  text-align: center;
  padding: var(--space-8);
  color: var(--muted);
}

.cart-drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 400px;
  max-width: 92vw;
  background: var(--surface);
  box-shadow: var(--shadow-pop);
  z-index: 40;
  display: flex;
  flex-direction: column;
}

/* Saved-draft context remains readable at phone widths. */
.draft-context { display: block; overflow-wrap: anywhere; }
.draft-context > b, .draft-context > span { display: block; }
.draft-context > p { margin: 4px 0 8px; }
.draft-context > .btn { margin: 4px 4px 0 0; }
.draft-context #draft-status:empty { display: none; }

.cart-drawer[hidden] {
  display: none;
}

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

.cart-drawer__title {
  font-weight: 800;
  color: var(--heading);
}

.cart-drawer__lines {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-4);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.cart-drawer__foot {
  border-top: 1px solid var(--border);
  padding: var(--space-4);
}

.cart-drawer__total {
  font-weight: 800;
  color: var(--heading);
  margin-bottom: var(--space-3);
}

.cart-line {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 4px 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-input);
  padding: var(--space-3);
}

.cart-line__name {
  font-weight: 600;
  color: var(--heading);
  font-size: 0.9rem;
}

.cart-line__price {
  color: var(--muted);
  font-size: 0.8rem;
}

.cart-line__controls {
  display: flex;
  align-items: center;
  gap: 6px;
  grid-column: 1;
}

.cart-line__qty {
  min-width: 34px;
  text-align: center;
  font-weight: 600;
}

.cart-line__total {
  grid-column: 2;
  grid-row: 1 / span 3;
  align-self: center;
  font-weight: 700;
}

@media (max-width: 960px) {
  .storefront__body {
    grid-template-columns: 1fr;
  }

  .storefront__nav {
    border-right: none;
    border-bottom: 1px solid var(--border);
    display: flex;
    gap: 6px;
    overflow-x: auto;
    padding: var(--space-3);
    max-height: none;
  }

  .storefront__nav-title {
    display: none;
  }

  .storefront__cat {
    width: auto;
    white-space: nowrap;
  }

  .storefront__header {
    gap: var(--space-2);
    padding: var(--space-2) var(--space-3);
  }

  .storefront__org {
    order: 10;
    width: 100%;
    max-width: none;
  }
}

@media (max-width: 1100px) {
  .explorer-shell {
    grid-template-columns: 1fr;
  }
}

/* ============================================================
   Responsive
   ============================================================ */

.menu-toggle {
  display: none;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-input);
  width: var(--control-h);
  height: var(--control-h);
  cursor: pointer;
  color: var(--heading);
}

@media (max-width: 960px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .store-switcher summary {
    max-width: 46vw;
  }

  .store-switcher summary span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .topbar__user {
    display: none;
  }

  .store-switcher__menu {
    max-width: calc(100vw - 24px);
  }

  .topbar {
    gap: var(--space-2);
  }

  .sidebar {
    display: none;
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    z-index: 100;
    width: min(300px, 85vw);
    box-shadow: var(--shadow-pop);
    /* R40: the drawer spans the visible viewport (top/bottom, not 100vh behind the browser bars) and scrolls by
       touch; the safe area keeps the last items above the home indicator */
    height: auto;
    max-height: 100dvh;
    padding-bottom: calc(var(--space-5) + env(safe-area-inset-bottom, 0px));
    -webkit-overflow-scrolling: touch;
  }

  .sidebar--open {
    display: flex;
  }

  .sidebar-backdrop {
    position: fixed;
    inset: 0;
    z-index: 99;
    background: rgba(15, 23, 42, 0.35);
  }

  /* R40: while the drawer is open the page underneath stays still (app.js keeps / restores its scroll position) */
  html.nav-locked body {
    position: fixed;
    left: 0;
    right: 0;
    width: 100%;
    overflow: hidden;
  }

  .menu-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  .topbar__brand {
    display: block;
  }

  .content {
    padding: var(--space-5) var(--space-4);
  }

  .grid-2 {
    grid-template-columns: 1fr;
  }
}

/* ============================================================
   Phase 7A — local B2B orders: list + editor
   ============================================================ */

.order-row {
  display: grid;
  grid-template-columns: 56px minmax(0, 1fr) auto minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}

.order-row:last-child { border-bottom: none; }

.order-row__thumb {
  width: 56px;
  height: 56px;
  border-radius: var(--radius-input);
  background: linear-gradient(135deg, #f2f6fd, #e6edfa);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  text-decoration: none;
}

.order-row__thumb img { width: 100%; height: 100%; object-fit: contain; }
.order-row__mark { font-size: 1.4rem; }

.order-row__number { font-weight: 700; color: var(--heading); text-decoration: none; }
.order-row__total { font-weight: 700; }
.order-row__actions { display: flex; gap: 6px; justify-content: flex-end; }

/* ---- editor two-column layout ---- */
.order-editor {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 20px;
  align-items: start;
}

/* ONE shared grid for ALL lines: every quantity/total/remove control
   starts at the same X coordinate regardless of name length, variant
   chips or per-piece badges (Phase 7B addendum). */
.order-lines {
  display: grid;
  grid-template-columns: 56px minmax(0, 1fr) 132px 120px 36px;
  column-gap: 12px;
  row-gap: 4px;
  align-items: center;
}

.order-line {
  display: contents;
}

.order-line__thumb {
  width: 56px;
  height: 56px;
  border-radius: var(--radius-input);
  background: linear-gradient(135deg, #f2f6fd, #e6edfa);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.order-line__thumb img { width: 100%; height: 100%; object-fit: contain; }

.order-line__mark {
  width: 34px; height: 34px; border-radius: 50%;
  background: #fff; border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; color: var(--primary);
}

.order-line > * {
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}

.order-line:last-child > * {
  border-bottom: none;
}

.order-line__qty form {
  display: flex;
  gap: 6px;
  align-items: center;
  justify-content: flex-start;
}

.order-line__qty .input {
  width: 76px;
  min-width: 0;
  text-align: left;
  padding-left: 10px;
}

.order-line__name { font-weight: 600; color: var(--heading); }
.order-line__meta { font-size: 0.78rem; color: var(--muted); }
.order-line__price { font-size: 0.82rem; color: var(--muted); }
.order-line__total { font-weight: 700; white-space: nowrap; }

/* ---- summary panel ---- */
.order-summary { display: grid; grid-template-columns: auto 1fr; gap: 8px 12px; margin: 0; }
.order-summary dt { color: var(--muted); font-size: 0.82rem; }
.order-summary dd { margin: 0; text-align: right; min-width: 0; }
.order-summary .input, .order-summary .textarea { width: 100%; }
.order-summary__total { font-size: 1.15rem; font-weight: 800; color: var(--primary-hover); }

/* ---- history timeline ---- */
.order-history { display: flex; flex-direction: column; gap: 0; }
.order-history__row { display: flex; gap: 12px; padding: 8px 0; }
.order-history__dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--primary); margin-top: 5px; flex-shrink: 0;
}
.order-history__label { font-weight: 600; }

@media (max-width: 1200px) {
  .order-editor { grid-template-columns: 1fr; }
}

@media (max-width: 960px) {
  .order-row { grid-template-columns: 48px minmax(0, 1fr) auto; }
  .order-row__meta { grid-column: 2; }
  .order-row__actions { grid-column: 3; grid-row: 1 / span 2; }
  /* deliberate mobile line composition: own grid per line */
  .order-lines { display: block; }
  .order-line { display: grid; grid-template-columns: 48px minmax(0, 1fr) auto; gap: 12px; align-items: center; }
  .order-line > * { border-bottom: none; padding: 8px 0; }
  .order-line__sep { grid-column: 1 / -1; border-top: 1px solid var(--border); height: 0; padding: 0; }
  .order-line:last-child .order-line__sep { display: none; }
  .order-line__qty { grid-column: 2; }
  .order-line__total { grid-column: 2; }
  .order-line__actions { grid-column: 3; grid-row: 1 / span 3; }
}

/* ---- Phase 7B add-to-cart micro-animation ---- */
.cart-fly-dot {
  position: fixed;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--primary);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25);
  z-index: 80;
  pointer-events: none;
  transition: transform 0.45s ease-in, opacity 0.45s ease-in;
}

.product-card__actions .btn.is-pressed {
  transform: scale(0.94);
}

.product-card__actions .btn.is-added {
  background: var(--success, #16a34a) !important;
  border-color: var(--success, #16a34a) !important;
  color: #fff !important;
}

@media (prefers-reduced-motion: reduce) {
  .cart-fly-dot { display: none; }
  .product-card__actions .btn.is-pressed { transform: none; }
}

/* ---- Phase 7B accessible order row ---- */
.order-row {
  position: relative;
  cursor: pointer;
  border-radius: 8px;
  padding: 12px;
  transition: background-color 0.15s ease;
}

.order-row:hover { background-color: var(--primary-soft, #eef3fd); }
.order-row:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.order-row > * { pointer-events: none; }
.order-row .btn, .order-row a.btn { pointer-events: auto; }

/* ============================================================
   Phase 7D — ONE functional account block under the logo
   ============================================================ */

.sidebar__account {
  margin-bottom: var(--space-3);
  font-size: 0.875rem;
}

.sidebar__account summary {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  color: var(--heading);
  font-weight: 700;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-input);
  background: var(--surface);
  cursor: pointer;
  list-style: none;
}

.sidebar__account summary::-webkit-details-marker { display: none; }
.sidebar__account summary:hover { background: var(--primary-soft); }
.sidebar__account summary svg:last-child { margin-left: auto; color: var(--muted); }

.sidebar__account-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

.sidebar__account-menu {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-top: 4px;
  padding: 4px 4px 4px 10px;
  border-left: 2px solid var(--border);
  margin-left: 12px;
}

.sidebar__account-user {
  color: var(--muted);
  font-size: 0.78rem;
  padding: 2px 8px 6px;
}

.sidebar__account-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  text-align: left;
  padding: 6px 8px;
  border: none;
  background: none;
  border-radius: var(--radius-input);
  color: var(--text);
  font-size: 0.85rem;
  cursor: pointer;
  text-decoration: none;
}

.sidebar__account-item svg { color: var(--muted); flex-shrink: 0; }
.sidebar__account-item:hover { background: var(--primary-soft); color: var(--primary); }
.sidebar__account-item--active { color: var(--primary); font-weight: 700; }

/* the top chrome is gone on desktop: content starts immediately */
@media (min-width: 961px) {
  .topbar { display: none; }
}

/* compact catalog page: content starts higher, less dead chrome */
.content--compact {
  padding-top: var(--space-3);
}

.content--compact .page-header {
  margin-bottom: var(--space-3);
}

/* customer catalog header: search stretches across the row */
.storefront__header .storefront__search {
  flex: 1;
  min-width: 200px;
}

.storefront__header .storefront__search .input {
  width: 100%;
  max-width: 480px;
}

/* ============================================================
   Phase 7B Addendum 08 — 50/50 editor + continuous dividers
   ============================================================ */

.order-editor {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 20px;
  align-items: start;
  width: 100%;
  max-width: none;
}

/* ONE continuous separator per line: a dedicated element spanning all
   grid columns (display:contents rows cannot carry their own border) */
.order-line > * {
  padding: 10px 0;
  border-bottom: none;
}

.order-line__sep {
  grid-column: 1 / -1;
  border-top: 1px solid var(--border);
  height: 0;
  padding: 0 !important;
}

.order-line:last-child .order-line__sep {
  display: none;
}

/* summary: read-only rows label/value; editable fields stacked with
   full-width controls and the label above */
.order-summary {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin: 0;
}

.order-summary__row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: baseline;
}

.order-summary__row dt {
  color: var(--muted);
  font-size: 0.82rem;
  flex-shrink: 0;
}

.order-summary__row dd {
  margin: 0;
  font-weight: 600;
  text-align: right;
  min-width: 0;
  overflow-wrap: anywhere;
}

.order-summary__row--stack {
  flex-direction: column;
  align-items: stretch;
  gap: 4px;
}

.order-summary__row--stack dd {
  text-align: left;
  font-weight: 400;
}

.order-summary__row--stack .input,
.order-summary__row--stack .textarea {
  width: 100%;
}

.order-summary__row--total dd {
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--primary-hover);
}

/* collapse MUST come after the base 50/50 rule (source order) */
@media (max-width: 1200px) {
  .order-editor {
    grid-template-columns: 1fr;
  }
}

/* Phase 7F hotfix — ONE shared action row: Save+Submit left group,
   Delete right-aligned, all 40px, no divider, no second row */
.order-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-top: 12px;
}

.order-actions__primary {
  display: flex;
  align-items: center;
  gap: 8px;
}

.order-actions .btn {
  height: 40px;
}

.order-actions .btn-danger {
  width: 150px;
  max-width: 100%;
}

@media (max-width: 960px) {
  .order-actions {
    flex-wrap: wrap;
  }

  .order-actions .btn-danger {
    width: auto;
    max-width: 100%;
  }
}

/* Phase 7E — New Order button below the orders list, in normal flow */
.orders-new-wrap {
  margin-top: 14px;
  display: flex;
  justify-content: flex-start;
}

/* Phase 7E — compact single-line toolbar on narrow screens so the
   viewport-bounded list has room for the rows */
@media (max-width: 960px) {
  .orders-toolbar {
    flex-wrap: nowrap;
  }

  .orders-toolbar .field {
    min-width: 0;
  }

  .orders-toolbar .select {
    max-width: 132px;
    flex-shrink: 0;
  }
}

/* mobile: the delete button may span the narrow panel but stays bounded */
@media (max-width: 960px) {
  .order-actions .btn-danger {
    width: auto;
    max-width: 100%;
  }
}

/* ============================================================
   R4 — store context (administrator), stock states, stock panel
   ============================================================ */
.store-context { margin-bottom: var(--space-4); }
.store-context__row { display: flex; gap: var(--space-3); flex-wrap: wrap; align-items: flex-end; }
.store-context__field { flex: 1 1 320px; margin: 0; }
/* R52: «Магазин» — search field + suggestions instead of a long list (store_search.js); the <select> stays as the
   value holder, visually hidden but present (1 px) for the page code and the label */
.store-search { position: relative; }
.store-search__native { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden;
  clip-path: inset(50%); white-space: nowrap; border: 0; opacity: 0; }
.store-search__input { width: 100%; font-size: 16px; }   /* 16 px: iOS does not zoom the page on focus */
.store-search__list { position: absolute; z-index: 40; left: 0; right: 0; top: calc(100% + 4px); max-height: min(340px, 50vh);
  overflow-y: auto; margin: 0; padding: 4px 0; list-style: none; background: #fff; border: 1px solid var(--border);
  border-radius: var(--radius-input); box-shadow: var(--shadow-pop); -webkit-overflow-scrolling: touch; }
.store-search__list [role=option] { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 8px; padding: 10px 14px;
  min-height: 44px; box-sizing: border-box; cursor: pointer; line-height: 1.3; }
.store-search__list [role=option]:hover, .store-search__list [aria-selected=true] { background: #eef3ff; }
.store-search__name { font-weight: 600; color: var(--text, #172b4d); }
.store-search__login { color: var(--muted); font-size: 0.9em; }
.store-search__note { padding: 10px 14px; color: var(--muted); font-size: 0.9em; }
/* R54: «Группа номенклатуры» beside the store controls; a narrow screen stacks them */
.orders-group__field { flex: 1 1 240px; }
.orders-group__warn { color: #b45309; font-weight: 600; }
/* R66: several groups — a tree of checkboxes under a select-looking summary */
.orders-group { position: relative; }
.orders-group__summary { display: flex; align-items: center; justify-content: space-between; gap: 8px; cursor: pointer; list-style: none; user-select: none; }
.orders-group__summary::-webkit-details-marker { display: none; }
.orders-group__summary > span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.orders-group__summary::after { content: "▾"; color: var(--muted); flex: none; }
.orders-group__panel { position: absolute; z-index: 40; left: 0; right: 0; top: calc(100% + 4px); display: flex; flex-direction: column;
  max-height: min(380px, 60vh); background: #fff; border: 1px solid var(--border); border-radius: var(--radius-input); box-shadow: var(--shadow-card); }
#orders-group-tree { flex: 1 1 auto; min-height: 0; overflow-y: auto; padding: 4px 0; }
.orders-group__item { display: flex; align-items: center; gap: 8px; min-height: 34px; padding-right: 12px; cursor: pointer; }
.orders-group__item:hover { background: var(--surface-2, #f1f5f9); }
.orders-group__item input { width: 18px; height: 18px; margin: 0; flex: none; accent-color: #2563eb; }
.orders-group__heading { display: flex; align-items: center; min-height: 30px; padding-right: 12px; color: var(--muted); font-size: 0.9em; }
.orders-group__footer { padding: 8px 12px; border-top: 1px solid var(--border); text-align: right; }
.link-btn { background: none; border: 0; padding: 0; color: #2563eb; font: inherit; cursor: pointer; text-decoration: underline; }
/* R51: «Все» of «Мои заказы» — next to «Применить», a touch-sized checkbox */
.orders-all { display: inline-flex; align-items: center; gap: 8px; min-height: var(--control-h); font-weight: 600; cursor: pointer; user-select: none; }
.orders-all input { width: 18px; height: 18px; margin: 0; accent-color: #2563eb; }
.product-card__stock { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 6px; font-size: 0.85rem; }
.stock-line { font-weight: 600; color: var(--muted); }
.stock-line--ok { color: var(--success); }
.stock-line--none { color: var(--danger); }
.stock-line--unknown { color: var(--warning); }
.stock-line--exempt { color: var(--primary); }
.stock-link { padding: 2px 8px; min-height: 0; height: auto; font-size: 0.8rem; }
.stock-reason { flex-basis: 100%; }
.cart-line__stock { grid-column: 1 / -1; color: var(--danger); }
.stock-panel { position: fixed; inset: 0; background: rgba(16, 27, 58, 0.35); display: flex; align-items: center; justify-content: center; z-index: 120; padding: var(--space-4); }
.stock-panel[hidden] { display: none; }
.stock-panel__box { background: var(--surface); border-radius: var(--radius-card); box-shadow: var(--shadow-pop); width: min(460px, 100%); max-height: 85vh; overflow: auto; padding: var(--space-5); }
.stock-panel__head { display: flex; justify-content: space-between; align-items: center; gap: var(--space-3); }
.stock-panel__title { font-weight: 800; font-size: 1.1rem; color: var(--heading); }
.stock-panel__product { font-weight: 600; }
.stock-rows { border-top: 1px solid var(--border); }
.stock-row { display: flex; justify-content: space-between; gap: var(--space-3); padding: 8px 0; border-bottom: 1px solid var(--border); }
.stock-row__qty { font-weight: 700; white-space: nowrap; }
@media (max-width: 640px) {
  .stock-panel { align-items: flex-end; padding: 0; }
  .stock-panel__box { width: 100%; border-radius: var(--radius-card) var(--radius-card) 0 0; }
}
.product-card__stock { display: block; }
.product-card__stock .stock-title { font-weight: 700; color: var(--heading); font-size: 0.85rem; margin-bottom: 2px; }
.product-card__stock .stock-rows { border-top: 1px solid var(--border); }
.product-card__stock .stock-row { padding: 3px 0; font-size: 0.85rem; }
.product-card__stock .stock-when { margin-top: 2px; }

/* R5: the expanded product card (modal over the catalog) */
.product-card__media[data-open], .product-card__name[data-open] { cursor: pointer; }
.product-card__media[data-open]:focus-visible, .product-card__name[data-open]:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.product-card__name[data-open]:hover { color: var(--primary); }
.product-modal { position: fixed; inset: 0; z-index: 120; display: flex; align-items: center; justify-content: center; padding: 16px; }
.product-modal[hidden] { display: none; }
.product-modal__backdrop { position: absolute; inset: 0; background: rgba(16, 27, 58, 0.45); }
.product-modal__dialog { position: relative; background: var(--surface); border-radius: var(--radius-card); box-shadow: var(--shadow-pop); width: min(940px, 100%); max-height: 90vh; overflow: auto; padding: 20px; }
.product-modal__close { position: absolute; top: 10px; right: 10px; z-index: 1; }
.product-modal__body { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); gap: 20px; }
.product-modal__media { background: #ffffff; border: 1px solid var(--border); border-radius: var(--radius-input); display: flex; align-items: center; justify-content: center; min-height: 340px; padding: 8px; }
.product-modal__image { max-width: 100%; max-height: 72vh; object-fit: contain; display: block; }
.product-modal__placeholder { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.product-modal__name { font-size: 1.25rem; font-weight: 800; color: var(--heading); margin: 0 36px 6px 0; line-height: 1.3; }
.product-modal__char { margin-top: 8px; }
.product-modal__price-label { margin-top: 12px; }
.product-modal__price { font-size: 1.15rem; }
.product-modal__chars { margin-top: 10px; display: flex; flex-direction: column; gap: 4px; }
.product-modal__info .product-card__stock { margin-top: 12px; }
.product-modal__desc { margin-top: 12px; white-space: pre-line; font-size: 0.9rem; }
.product-modal__actions { margin-top: 14px; }
body.modal-open { overflow: hidden; }
@media (max-width: 760px) {
  .product-modal { padding: 0; align-items: stretch; }
  .product-modal__dialog { max-height: 100vh; border-radius: 0; padding: 16px; }
  .product-modal__body { grid-template-columns: 1fr; }
  .product-modal__media { min-height: 220px; }
}

/* R6: «Показать все» and the long-absent mark */
.storefront__show-all { display: inline-flex; align-items: center; gap: 6px; font-size: 0.9rem; color: var(--text); cursor: pointer; white-space: nowrap; user-select: none; }
.storefront__show-all input { width: 16px; height: 16px; margin: 0; cursor: pointer; }
.storefront__hidden-note { margin: -8px 0 12px; }
.product-card__absent { display: inline-block; align-self: flex-start; font-size: 0.75rem; font-weight: 600; color: var(--muted); background: var(--surface-2, #f3f5f9); border: 1px solid var(--border); border-radius: 999px; padding: 2px 8px; }

/* R9 «Мои накладные» */
#invoices-message[hidden] { display: none; }
.invoice-head { display: grid; gap: 6px; }
.invoice-pay { padding: 12px 14px; border-radius: 10px; background: var(--surface-muted, #f6f8fc); }
.invoice-lines { width: 100%; border-collapse: collapse; font-size: 14px; }
.invoice-lines th, .invoice-lines td { padding: 8px 6px; border-bottom: 1px solid var(--border, #e6e8ef); vertical-align: top; text-align: left; }
.invoice-lines th { font-weight: 600; color: var(--muted, #6b7280); font-size: 12px; }
.invoice-lines .num { text-align: right; white-space: nowrap; }
@media (max-width: 640px) {
  .invoice-lines thead { display: none; }
  .invoice-lines tr { display: grid; grid-template-columns: 1fr auto; gap: 2px 8px; padding: 8px 0; border-bottom: 1px solid var(--border, #e6e8ef); }
  .invoice-lines td { border: 0; padding: 0; }
  .invoice-lines td:first-child { display: none; }
  .invoice-lines td:nth-child(2) { grid-column: 1 / -1; }
  .invoice-lines .num { text-align: left; }
  .invoice-lines td[data-label]::before { content: attr(data-label) ": "; color: var(--muted, #6b7280); font-size: 12px; }
  .invoices-toolbar input[type=date] { max-width: none !important; flex: 1; }
}


/* Order editor view preference and shareable table; scoped to this editor. */
.order-editor-header { align-items: flex-start; gap: 16px; }
.order-view-choice { margin-left: auto; max-width: 100%; }
.order-view-controls { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; border: 1px solid var(--border); border-radius: 12px; padding: 10px 14px; margin: 0; background: #fff; }
.order-view-controls legend { float: left; padding: 0; margin-right: 12px; font-weight: 600; }
.order-view-controls label { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }
.order-view-controls input { accent-color: #2563eb; width: 16px; height: 16px; margin: 0; }
.order-view-feedback { max-width: 380px; margin-top: 6px; }
.order-editor [hidden], .order-view-choice [hidden] { display: none !important; }
.order-table-heading { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: 12px; }
.order-table-heading .card__title { margin: 0; flex: 1 1 230px; overflow-wrap: anywhere; }
.order-copy-status { min-height: 1.3em; margin: 8px 0; color: var(--muted); }
.order-copy-table { width: 100%; table-layout: fixed; border-collapse: collapse; margin-top: 12px; font-size: 14px; }
.order-copy-table th, .order-copy-table td { padding: 12px; border: 1px solid var(--border); text-align: left; vertical-align: top; overflow-wrap: anywhere; white-space: normal; }
.order-copy-table th { background: #f5f8ff; font-weight: 600; }
.order-copy-table th:first-child { width: 42px; }
.order-copy-table th:last-child { width: 115px; }
.order-table-totals { display: flex; flex-wrap: wrap; gap: 10px 24px; margin-top: 16px; }
@media (max-width: 600px) {
  .order-editor-header { flex-wrap: wrap; }
  .order-view-choice { width: 100%; margin-left: 0; }
  .order-view-controls { justify-content: flex-start; }
  .order-copy-table th, .order-copy-table td { padding: 8px 6px; font-size: 13px; }
  .order-copy-table th:first-child { width: 30px; }
  .order-copy-table th:last-child { width: 96px; }
}

.order-editor__main > .order-table-card { margin-top: 0; }

/* R18: role restrictions — quiet shipping hints and the mixed-order decision dialog */
.product-card__shipping { font-size: 0.75rem; color: var(--muted); margin-top: 4px; }
.product-modal__info .product-card__shipping { margin-top: 10px; font-size: 0.82rem; }
.cart-line .product-card__shipping { grid-column: 1 / -1; margin-top: 2px; }
.order-line__shipping { font-size: 0.78rem; color: var(--muted); margin-top: 4px; }
.order-line__shipping--late { color: var(--warning-text, #8a5a00); font-weight: 600; }
.restriction-dialog { position: fixed; inset: 0; z-index: 130; display: flex; align-items: center; justify-content: center; padding: 16px; }
.restriction-dialog__backdrop { position: absolute; inset: 0; background: rgba(16, 27, 58, 0.45); }
.restriction-dialog__box { position: relative; background: var(--surface); border-radius: var(--radius-card); box-shadow: var(--shadow-pop); width: min(620px, 100%); max-height: 90vh; overflow: auto; padding: 20px; }
.restriction-dialog__title { font-size: 1.1rem; font-weight: 800; color: var(--heading); margin: 0 0 8px; line-height: 1.3; }
.restriction-dialog__list { margin: 10px 0; padding-left: 18px; display: flex; flex-direction: column; gap: 6px; }
.restriction-dialog__actions { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; margin-top: 14px; }
.restriction-dialog__actions form { margin: 0; }
@media (max-width: 640px) {
  .restriction-dialog { padding: 0; align-items: stretch; }
  .restriction-dialog__box { max-height: 100vh; border-radius: 0; }
  .restriction-dialog__actions { flex-direction: column-reverse; }
  .restriction-dialog__actions .btn, .restriction-dialog__actions form { width: 100%; }
}
.restriction-rules td, .restriction-rules th { vertical-align: top; }
.restriction-tree__node { padding: 6px 0; border-bottom: 1px solid var(--border); }
.restriction-tree__name { font-weight: 700; color: var(--heading); }
.restriction-tree__line { font-size: 0.82rem; }
.restriction-picker select { width: 100%; min-height: 220px; }

/* R19: role editor sections, locked permissions, the restriction group picker */
.role-sections { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 16px; }
.check-row--locked { opacity: 0.75; }
.perm-locked-reason { color: var(--warning, #d98b21); }
.restriction-selected { margin: 4px 0 10px; color: var(--muted); }
.restriction-selected--chosen { color: var(--heading); font-weight: 700; }
.restriction-group-info { border: 1px solid var(--border); border-radius: var(--radius-input); padding: 8px 10px; display: flex; flex-direction: column; gap: 4px; }
.restriction-explorer .explorer-tree { max-height: 420px; overflow: auto; }
@media (max-width: 640px) {
  .restriction-explorer .explorer-tree { max-height: 300px; }
  .role-sections .btn { flex: 1 1 calc(50% - 8px); }
}

/* R20: the unified restriction editor — two panels, compact one-line summary rows */
.restr-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.restr-panel { margin: 0; min-width: 0; }
.restr-tree { max-height: 360px; overflow: auto; margin-top: 8px; border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.restr-selected { margin: 10px 0 6px; color: var(--muted); font-size: 0.9rem; }
.restr-selected--chosen { color: var(--heading); font-weight: 700; }
.restr-fields { display: flex; flex-direction: column; gap: 6px; }
.restr-field { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 0.92rem; }
.restr-input { width: 110px; padding: 4px 8px; height: auto; }
.restr-input--days { width: 72px; }
.restr-preview { margin-top: 8px; color: var(--muted); }
.restr-error { margin-top: 6px; color: var(--danger, #c62828); }
.restr-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 10px; }
.restr-products { margin-top: 10px; border-top: 1px solid var(--border); padding-top: 6px; }
.restr-products summary { cursor: pointer; color: var(--muted); }
.restr-summary-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.restr-summary-head .card__title { margin: 0; }
.restr-summary-tools { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; margin: 6px 0; }
.restr-table-wrap { overflow-x: auto; }
.restr-table { width: 100%; border-collapse: collapse; font-size: 0.88rem; table-layout: fixed; }
.restr-table th { text-align: left; font-weight: 600; color: var(--muted); border-bottom: 1px solid var(--border); padding: 4px 6px; }
.restr-table th:nth-child(2), .restr-table th:nth-child(3) { width: 112px; }
.restr-table td { border-bottom: 1px solid var(--border); padding: 3px 6px; white-space: nowrap; }
.restr-name { overflow: hidden; text-overflow: ellipsis; }
.restr-label { overflow: hidden; text-overflow: ellipsis; }
.restr-value { color: var(--heading); }
.restr-row--selected td { background: var(--surface-2, #eef3fb); }
.restr-toggle { border: 0; background: none; cursor: pointer; padding: 0 4px 0 0; color: var(--muted); font-size: 0.8rem; }
.restr-toggle--closed { display: inline-block; transform: rotate(-90deg); }
.restr-more { color: var(--primary, #2f5fd0); font-size: 0.6rem; margin-left: 6px; vertical-align: middle; }
@media (max-width: 900px) {
  .restr-layout { grid-template-columns: 1fr; }
  .restr-table { min-width: 340px; }
}

/* R21: effective restriction labels in the restriction picker tree (picker mode only) */
.tree-badge { flex: 0 0 auto; font-size: 0.68rem; font-weight: 600; line-height: 1.3; color: #1b6e35; background: #e6f4ea; border: 1px solid #b7dfc2; border-radius: 999px; padding: 0 6px; white-space: nowrap; }
.tree-badge--below { color: #2e8b4e; background: none; border: 0; padding: 0 2px; font-size: 0.8rem; }

/* R22: «Производство» — controls and the sheet preview (the template grid; scrolls inside on narrow screens) */
.prod-controls { display: flex; gap: 16px; align-items: flex-end; flex-wrap: wrap; }
.prod-date { margin: 0; min-width: 180px; }
.prod-buttons { display: flex; gap: 8px; flex-wrap: wrap; }
.prod-pages { display: flex; flex-direction: column; gap: 16px; }
.prod-page { background: #fff; border: 1px solid var(--border); box-shadow: var(--shadow-card, 0 1px 3px rgba(0,0,0,.08)); padding: 12px; overflow-x: auto; max-width: 900px; }
.prod-sheet { width: 860px; min-width: 860px; table-layout: fixed; border-collapse: collapse; font-family: Arial, sans-serif; color: #000; }
.prod-sheet td { padding: 0 3px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; vertical-align: middle; line-height: 1.15; }
.prod-places td { vertical-align: top; }
.prod-row-form { display: flex; gap: 4px; align-items: center; margin-bottom: 4px; }
.prod-label { width: 56px; padding: 2px 6px; height: auto; }
.prod-row-form .select { max-width: 160px; padding: 2px 6px; height: auto; }
.prod-sheet td[rowspan] { white-space: normal; }
.prod-client-divider td { border-bottom: 1px dashed #9aa4b2; }
/* R29: menu visibility settings */
.nav-vis-list { display: flex; flex-direction: column; gap: 4px; }
.nav-vis-row { display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap; padding: 6px 0; border-bottom: 1px solid var(--border); }
.nav-vis-row__modes { display: flex; gap: 12px; flex-wrap: wrap; }
.nav-vis-mode { display: inline-flex; gap: 4px; align-items: center; font-size: 14px; }
.nav-vis-row--denied { opacity: .55; }

/* ================= R31 «Быстрый заказ»: a compact list without photos =================
   Mobile first: a row = name / characteristic, then price and the stepper, the line sum under the price.
   From 900px a dense 1C-like table: Наименование | Характеристика | Цена | Количество | Сумма. */
.view-switch { display: inline-flex; border: 1px solid var(--border); border-radius: var(--radius-btn); overflow: hidden; background: var(--surface); }
.view-switch__btn { border: 0; background: transparent; padding: 8px 12px; font: inherit; font-size: 13px; color: var(--muted); cursor: pointer; min-height: 36px; }
.view-switch__btn--active { background: var(--primary-soft); color: var(--primary); font-weight: 600; }
.qo-header { display: flex; gap: 12px; align-items: flex-start; justify-content: space-between; flex-wrap: wrap; }
.qo-store .store-context__row { flex-wrap: wrap; }
.qo-own-store { margin: 0 0 8px; }
.qo { min-width: 0; padding-bottom: 88px; }
.qo-toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center;
  padding: 8px 0; background: var(--bg); }
.qo-toolbar__search { flex: 1 1 220px; min-width: 0; }
.qo-toolbar__cat { flex: 1 1 180px; min-width: 0; max-width: 100%; }
.qo-toolbar__check { display: inline-flex; gap: 6px; align-items: center; font-size: 14px; white-space: nowrap; }
.qo-list { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; overflow: hidden; min-width: 0; }
.qo-head { display: none; }
.qo-empty { padding: 12px; padding-left: calc(12px + var(--qo-depth, 0) * 14px); margin: 0; }
.qo-num { text-align: right; font-variant-numeric: tabular-nums; }
.qo-group { border-top: 1px solid var(--border); }
.qo-group:first-child { border-top: 0; }
.qo-group__btn { display: flex; width: 100%; gap: 8px; align-items: center; text-align: left; border: 0; background: #f3f6fb;
  padding: 10px 12px; padding-left: calc(12px + min(var(--qo-depth, 0), 4) * 14px); font: inherit; font-weight: 600;
  color: var(--heading); cursor: pointer; min-height: 44px; }
.qo-group__btn[aria-expanded="true"] { background: var(--primary-soft); }
.qo-group__mark { width: 14px; flex: none; color: var(--muted); }
.qo-group__name { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.qo-group__count { flex: none; }
.qo-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "main main" "char char" "price qty" "sum qty";
  column-gap: 10px; row-gap: 2px; align-items: center; padding: 8px 12px; padding-left: calc(12px + min(var(--qo-depth, 0), 4) * 14px);
  border-top: 1px solid var(--border); min-width: 0; }
.qo-row--product { grid-template-areas: "main main"; padding-bottom: 2px; }
.qo-row--variant { border-top: 1px dashed var(--border); padding-left: calc(24px + min(var(--qo-depth, 0), 4) * 14px); }
.qo-row--in-cart { background: #f2fbf6; }
.qo-row--error { background: var(--danger-soft); }
.qo-c { min-width: 0; }
.qo-c-main { grid-area: main; }
.qo-c-main:empty { display: none; }
.qo-c-char { grid-area: char; font-size: 14px; overflow-wrap: anywhere; }
.qo-c-char:empty { display: none; }
.qo-c-price { grid-area: price; text-align: left; }
.qo-c-qty { grid-area: qty; justify-self: end; }
.qo-c-sum { grid-area: sum; text-align: left; font-weight: 600; min-height: 1.2em; }
.qo-name { font-weight: 600; color: var(--heading); overflow-wrap: anywhere; line-height: 1.3; }
.qo-meta { overflow-wrap: anywhere; }
.qo-warn { color: var(--danger); }
.qo-ship { color: var(--warning); display: block; }
.qo-sum--provisional { color: var(--muted); font-weight: 400; }
.qo-step { display: inline-flex; align-items: center; gap: 4px; }
.qo-step__btn { width: 38px; height: 38px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface);
  font-size: 20px; line-height: 1; color: var(--heading); cursor: pointer; touch-action: manipulation; }
.qo-step__btn:disabled { opacity: .4; cursor: default; }
.qo-step__input { width: 64px; height: 38px; border: 1px solid var(--border); border-radius: 10px; text-align: center;
  font: inherit; font-variant-numeric: tabular-nums; padding: 0 4px; background: var(--surface); }
.qo-step__input:focus { outline: none; box-shadow: var(--focus-ring); border-color: var(--primary); }
.qo-row--busy .qo-step__input { border-color: var(--warning); }
.qo-row--ok .qo-step__input { border-color: var(--success); }
.qo-row--error .qo-step__input { border-color: var(--danger); }
.qo-row__err { color: var(--danger); max-width: 150px; text-align: right; }
.qo-row__err:empty { display: none; }
.qo-bar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; display: flex; gap: 10px; align-items: center;
  justify-content: space-between; padding: 10px 16px calc(10px + env(safe-area-inset-bottom)); background: var(--surface);
  border-top: 1px solid var(--border); box-shadow: 0 -4px 16px rgba(16, 27, 58, .08); }
.qo-bar__summary { display: flex; flex-wrap: wrap; gap: 2px 10px; align-items: baseline; min-width: 0; }
.qo-bar__btn { flex: none; }
.qo-state--busy { color: var(--warning); }
.qo-state--error { color: var(--danger); }
.qo-state--ok { color: var(--success); }
.qo-review { position: fixed; inset: 0; z-index: 60; }
.qo-review__backdrop { position: absolute; inset: 0; background: rgba(16, 27, 58, .45); }
.qo-review__dialog { position: absolute; inset: 0; background: var(--surface); display: flex; flex-direction: column; overflow: hidden; }
.qo-review__head { display: flex; justify-content: space-between; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.qo-review__title { font-size: 18px; margin: 0; }
.qo-review__body { overflow-y: auto; padding: 12px 16px 16px; }
.qo-review__meta { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 4px 12px; margin: 0 0 12px; }
.qo-review__meta dt { color: var(--muted); }
.qo-review__meta dd { margin: 0; overflow-wrap: anywhere; font-weight: 600; }
.qo-review__fields { display: grid; gap: 8px; }
.qo-review__comment { min-height: 60px; resize: vertical; }
.qo-review__lines { margin-top: 12px; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.qo-rv { display: grid; grid-template-columns: minmax(0, 1fr) auto auto auto; gap: 4px 10px; padding: 8px 10px; border-top: 1px solid var(--border); font-size: 14px; }
.qo-rv:first-child { border-top: 0; }
.qo-rv--head { background: #f3f6fb; color: var(--muted); font-size: 12px; }
.qo-rv--bad { background: var(--danger-soft); }
.qo-rv__name { overflow-wrap: anywhere; }
.qo-review__total { margin-top: 10px; font-size: 16px; }
.qo-review__note { margin-top: 8px; }
.qo-review__actions { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; margin-top: 12px; }
@media (max-width: 480px) {
  .qo-rv { grid-template-columns: minmax(0, 1fr) auto auto; }
  .qo-rv > :nth-child(3) { display: none; }
  .qo-review__actions .btn { flex: 1 1 100%; }
}
@media (min-width: 700px) {
  .qo-review__dialog { inset: 5vh 50% auto auto; transform: translateX(50%); width: min(820px, 92vw); max-height: 90vh; border-radius: var(--radius-card); box-shadow: var(--shadow-pop); }
}
@media (min-width: 961px) {
  .qo-bar { left: var(--sidebar-w); }
  /* the search stays at hand on a wide screen (on a phone the top bar is sticky already) */
  .qo-toolbar { position: sticky; top: 0; z-index: 5; }
}
@media (min-width: 900px) {
  .qo-head { display: grid; grid-template-columns: minmax(0, 1fr) minmax(120px, 220px) 140px 160px 120px; gap: 10px;
    padding: 8px 12px; background: #eef2f8; color: var(--muted); font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .02em; }
  .qo-row { grid-template-columns: minmax(0, 1fr) minmax(120px, 220px) 140px 160px 120px; grid-template-areas: "main char price qty sum";
    padding-top: 4px; padding-bottom: 4px; }
  .qo-row--product { grid-template-areas: "main main main main main"; }
  .qo-c-char:empty, .qo-c-main:empty { display: block; }
  .qo-c-price, .qo-c-sum { text-align: right; }
  .qo-c-qty { justify-self: end; }
  .qo-step__btn { width: 30px; height: 30px; font-size: 16px; border-radius: 8px; }
  .qo-step__input { height: 30px; width: 70px; border-radius: 8px; }
  .qo-group__btn { min-height: 34px; padding-top: 6px; padding-bottom: 6px; }
}
/* ================= R32: «Мои заказы» on narrow screens =================
   The filters: one line (search shrinks, status keeps its width). 601–960px: the thumbnail column stays and the
   status / lines / total get their own row (they used to fall into the 48px thumbnail cell and overlap).
   ≤600px: a two-row card without the decorative thumbnail — number + date·store | action / status · lines | total. */
.orders-toolbar { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; margin-bottom: 16px; }
.orders-toolbar__search { flex: 1; min-width: 220px; margin: 0; }
.orders-toolbar__status { max-width: 200px; }
.order-row__act-short { display: none; }
@media (max-width: 960px) {
  .orders-toolbar { flex-wrap: nowrap; }
  .orders-toolbar__search { min-width: 0; }
  .order-row { grid-template-columns: 48px auto minmax(0, 1fr) auto; grid-template-areas: "thumb main main action" "thumb status meta action"; row-gap: 6px; }
  .order-row__thumb { grid-area: thumb; width: 48px; height: 48px; }
  .order-row__main { grid-area: main; min-width: 0; }
  .order-row__status { grid-area: status; }
  .order-row__meta { grid-area: meta; display: flex; justify-content: space-between; align-items: baseline; gap: 8px; min-width: 0; }
  .order-row__actions { grid-area: action; }
  .order-row__number { overflow-wrap: anywhere; }
  .order-row__total { white-space: nowrap; }
  .order-row__sub { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
}
@media (max-width: 600px) {
  .orders-card { padding: 12px; }
  .orders-toolbar { gap: 8px; margin-bottom: 8px; }
  .orders-toolbar .orders-toolbar__status { flex: 0 0 auto; width: auto; max-width: 48%; }
  .order-row { grid-template-columns: auto minmax(0, 1fr) auto; grid-template-areas: "main main action" "status meta meta";
    column-gap: 10px; row-gap: 6px; padding: 10px 8px; align-items: center; }
  .order-row__thumb { display: none; }
  /* a long number fills whole lines (not one line per hyphen), at most two; the full number is in the title */
  .order-row__number { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2;
    overflow: hidden; word-break: break-all; line-height: 1.25; }
  .order-row__actions { align-self: start; }
  .order-row__actions .btn { height: 34px; padding: 0 12px; font-size: 0.8125rem; border-radius: 9px; }
  .order-row__meta { flex-wrap: wrap; row-gap: 2px; }          /* a very long total moves down, never out of the card */
  .order-row__total { margin-left: auto; font-size: 0.9375rem; }
  .order-row__act-long { display: none; }
  .order-row__act-short { display: inline; }
  #orders-pagination { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 8px; margin-top: 12px; }
  #orders-pagination .btn { min-width: 44px; }
}
@media (max-width: 360px) {
  .order-row { column-gap: 8px; padding: 10px 6px; }
  .order-row__status .chip { padding: 2px 8px; }
  .order-row__meta { column-gap: 6px; }
  .order-row__total { font-size: 0.875rem; }
}
/* ================= R33 «Склад»: inventory counting — mobile first =================
   Phones: vertical rows (name / characteristic + unit / a big quantity field), 16px inputs (no Safari zoom),
   44px touch targets, safe areas (cutouts, Dynamic Island, the home indicator) on pages that opt into
   viewport-fit=cover, a bottom bar that steps aside while the soft keyboard is open. ≥900px: a dense 1C-like
   table «Наименование | Характеристика | Ед. | Факт». No hover-only behaviour anywhere. */
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.wh-page .app-shell { padding-left: env(safe-area-inset-left, 0px); padding-right: env(safe-area-inset-right, 0px); }
.wh-page .topbar { padding-top: max(var(--space-3), env(safe-area-inset-top, 0px)); }
.wh-page .content { min-width: 0; }
.wh-touch { min-height: 44px; }
.wh-actions { display: grid; grid-template-columns: 1fr; gap: 12px; }
.wh-action { display: flex; flex-direction: column; gap: 4px; padding: 20px; border-radius: var(--radius-card); background: var(--surface);
  border: 1px solid var(--border); box-shadow: var(--shadow-card); text-decoration: none; color: var(--text); min-height: 88px; }
.wh-action--primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.wh-action__title { font-size: 1.25rem; font-weight: 700; }
.wh-action__text { font-size: 0.9rem; opacity: .85; }
@media (min-width: 640px) { .wh-actions { grid-template-columns: 1fr 1fr; } }
.wh-card-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; }
.wh-draft-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 10px 4px; min-height: 44px;
  border-top: 1px solid var(--border); text-decoration: none; color: var(--text); flex-wrap: wrap; }
.wh-draft-row__main { display: flex; flex-direction: column; min-width: 0; flex: 1 1 200px; overflow-wrap: anywhere; }
.wh-draft-row__badges { display: flex; gap: 6px; flex-wrap: wrap; }
/* R41: a draft row + its «Удалить» (a form cannot live inside the row link) */
.wh-draft-item { display: flex; align-items: center; gap: 8px; border-top: 1px solid var(--border); }
.wh-draft-item > .wh-draft-row { flex: 1 1 auto; min-width: 0; border-top: 0; }
.wh-draft-del { flex: 0 0 auto; margin: 0; }
.wh-del { color: #b3261e; border-color: #f1c4c1; min-height: 40px; }
.wh-del:hover { background: #fdecec; color: #8e1d16; }
/* R43: the «Передача в 1С» state of a count */
.wh-export { font-weight: 600; flex: 1 1 220px; min-width: 0; overflow-wrap: anywhere; }
.wh-export--exported { color: #0d6b47; }
.wh-export--pending, .wh-export--uncertain { color: #8a6400; }
.wh-export--failed { color: #b3261e; }
/* R41: saved settings of each warehouse on «Настройка» */
.wh-saved__groups { margin: 8px 0 0; padding-left: 22px; columns: 2 260px; column-gap: 24px; }
.wh-saved__groups li { break-inside: avoid; padding: 2px 0; overflow-wrap: anywhere; }
.wh-badge { display: inline-flex; align-items: center; padding: 2px 10px; border-radius: 999px; font-size: 0.8rem; font-weight: 600; white-space: nowrap; }
.wh-badge--red { background: #fdecec; color: #a23b3b; }
.wh-badge--yellow { background: #fdf4d8; color: #8a6400; }
.wh-badge--green { background: #e6f6ec; color: #1f7a45; }
.wh-store-pick__row, .wh-btn-row { display: flex; gap: 8px; flex-wrap: wrap; }
.wh-store-pick__row .select { flex: 1 1 200px; min-width: 0; }
/* the count */
.wh-count { min-width: 0; padding-bottom: 8px; }
.wh-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.wh-head__main { min-width: 0; flex: 1 1 220px; }
.wh-head__title { font-size: 1.2rem; margin: 0; color: var(--heading); overflow-wrap: anywhere; line-height: 1.25; }
.wh-head__sub { margin: 2px 0 0; overflow-wrap: anywhere; }
.wh-sync { padding: 6px 10px; border-radius: 10px; font-size: 0.875rem; margin-bottom: 8px; }
.wh-sync--ok { background: #e6f6ec; color: #1f7a45; }
.wh-sync--busy { background: #fdf4d8; color: #8a6400; }
.wh-sync--offline { background: #eef2f8; color: #3c4b67; }
.wh-sync--error { background: #fdecec; color: #a23b3b; }
.wh-groupnav { display: flex; gap: 8px; margin-bottom: 8px; flex-wrap: wrap; }
.wh-groupnav__select { flex: 1 1 200px; min-width: 0; font-size: 16px; min-height: 44px; }
.wh-body { min-width: 0; }
.wh-group { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; overflow: hidden; margin-bottom: 8px; }
.wh-group__head { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; grid-template-areas: "icon name count" "icon status status";
  gap: 0 10px; align-items: center; width: 100%; text-align: left; border: 0; padding: 10px 12px; min-height: 52px; font: inherit; color: var(--heading); }
button.wh-group__head { cursor: pointer; }
.wh-group__icon { grid-area: icon; font-size: 1.1rem; }
.wh-group__name { grid-area: name; font-weight: 700; overflow-wrap: anywhere; }
.wh-group__count { grid-area: count; font-variant-numeric: tabular-nums; font-weight: 600; }
.wh-group__status { grid-area: status; }
.wh-state--red { background: #fdeeee; }
.wh-state--red .wh-group__icon, .wh-state--red .wh-group__status { color: #a23b3b; }
.wh-state--yellow { background: #fdf6dc; }
.wh-state--yellow .wh-group__icon, .wh-state--yellow .wh-group__status { color: #8a6400; }
.wh-state--green { background: #e9f7ee; }
.wh-state--green .wh-group__icon, .wh-state--green .wh-group__status { color: #1f7a45; }
.wh-group__foot { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 10px 12px; border-top: 1px solid var(--border); }
.wh-group__foot:empty { display: none; }
.wh-verify { display: inline-flex; align-items: center; gap: 10px; min-height: 44px; font-weight: 600; cursor: pointer; }
.wh-verify input { width: 22px; height: 22px; accent-color: #1f7a45; }
.wh-verify--off { color: var(--muted); }
.wh-cols { display: none; }
.wh-line { display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "name name" "sub qty" "msg msg";
  gap: 4px 12px; align-items: center; padding: 10px 12px; border-top: 1px solid var(--border); scroll-margin: 96px 0 140px; }
.wh-line__sub { grid-area: sub; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.wh-line__name { grid-area: name; font-weight: 600; color: var(--heading); overflow-wrap: anywhere; line-height: 1.3; }
.wh-line__code { font-weight: 400; font-size: 0.8rem; color: var(--muted); }
.wh-line__char { font-size: 0.9rem; overflow-wrap: anywhere; }
.wh-line__char:empty { display: none; }
.wh-line__unit { font-size: 0.85rem; color: var(--muted); }
.wh-line__qty { grid-area: qty; display: flex; align-items: center; gap: 6px; }
.wh-qty { width: 112px; height: 48px; font-size: 18px; font-variant-numeric: tabular-nums; text-align: right; padding: 0 10px;
  border: 1px solid var(--border); border-radius: 10px; background: #fff; color: var(--heading); }
.wh-qty:focus { outline: none; border-color: var(--primary); box-shadow: var(--focus-ring); }
.wh-qty::placeholder { color: #b6c0d3; }
.wh-line__mark { width: 18px; text-align: center; font-weight: 700; }
.wh-line--saved .wh-line__mark { color: #1f7a45; }
.wh-line--pending .wh-line__mark { color: #8a6400; }
.wh-line--pending .wh-qty { border-color: #e2b23c; }
.wh-line--error .wh-qty, .wh-line--conflict .wh-qty { border-color: #d64554; }
.wh-line--error .wh-line__mark, .wh-line--conflict .wh-line__mark { color: #d64554; }
.wh-line__msg { grid-area: msg; color: #a23b3b; overflow-wrap: anywhere; }
.wh-line__msg:empty { display: none; }
.wh-link { background: none; border: 0; padding: 4px 0; color: var(--primary); font: inherit; text-decoration: underline; cursor: pointer; min-height: 32px; }
.wh-doc-meta { margin-bottom: 8px; overflow-wrap: anywhere; }
.wh-bar { position: sticky; bottom: 0; z-index: 10; display: flex; gap: 8px; align-items: center; flex-wrap: wrap;
  margin: 8px -4px 0; padding: 10px 4px calc(10px + env(safe-area-inset-bottom, 0px)); background: var(--bg); border-top: 1px solid var(--border); }
.wh-bar .btn { flex: 1 1 auto; }
.wh-bar #wh-prev { flex: 0 0 auto; }
.wh-bar__progress { flex: 0 0 auto; font-variant-numeric: tabular-nums; }
.wh-bar__actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; width: 100%; }
.wh-ready { width: 100%; padding: 8px 10px; border-radius: 10px; overflow-wrap: anywhere; }
.wh-ready--ok { background: #e6f6ec; color: #1f7a45; }
.wh-ready--no { background: #fdecec; color: #a23b3b; }
body.wh-kb .wh-bar { position: static; }          /* the soft keyboard is open: never cover the focused row */
/* settings */
.wh-search { width: 100%; font-size: 16px; margin: 8px 0; }
.wh-tree { max-height: 65vh; max-height: 65dvh; overflow-y: auto; border: 1px solid var(--border); border-radius: 12px; }
.wh-node { display: flex; align-items: center; gap: 6px; padding: 4px 8px 4px calc(8px + min(var(--d, 0), 5) * 14px); border-top: 1px solid var(--border); min-height: 44px; }
.wh-node:first-child { border-top: 0; }
.wh-node--group { background: #f6f8fc; }
.wh-node__toggle { width: 36px; height: 36px; border: 0; background: none; font-size: 1rem; cursor: pointer; flex: none; }
.wh-node__label, .wh-node--product { cursor: pointer; }
.wh-node__label { display: flex; align-items: center; gap: 8px; flex: 1; min-width: 0; min-height: 44px; }
.wh-node input[type=checkbox] { width: 22px; height: 22px; flex: none; }
.wh-node--product { padding-left: calc(52px + min(var(--d, 0), 5) * 14px); }
.wh-node__text { display: flex; flex-direction: column; min-width: 0; }
.wh-node__name { overflow-wrap: anywhere; }
.wh-node--group .wh-node__name { font-weight: 600; }
.wh-order { list-style: none; margin: 0; padding: 0; }
.wh-order__item { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 6px 0; border-top: 1px solid var(--border); }
.wh-order__name { min-width: 0; overflow-wrap: anywhere; }
.wh-order__btns { display: flex; gap: 6px; flex: none; }
.wh-order__btns .btn { width: 44px; padding: 0; }
.wh-save-bar { position: sticky; bottom: 0; z-index: 10; display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap;
  margin-top: 12px; padding: 10px 0 calc(10px + env(safe-area-inset-bottom, 0px)); background: var(--bg); }
.wh-state-text--ok { color: #1f7a45; }
.wh-state-text--warn { color: #8a6400; }
.wh-state-text--error { color: #a23b3b; }
@media (min-width: 900px) {
  .wh-cols, .wh-line { display: grid; grid-template-columns: minmax(0, 1fr) minmax(140px, 260px) 90px 150px; grid-template-areas: "name char unit qty" "msg msg msg msg";
    gap: 0 12px; }
  .wh-cols { padding: 6px 12px; background: #eef2f8; color: var(--muted); font-size: 12px; font-weight: 600; text-transform: uppercase; }
  .wh-line { padding: 4px 12px; }
  .wh-line__sub { display: contents; }                 /* characteristic and unit become their own columns */
  .wh-line__char { grid-area: char; }
  .wh-line__unit { grid-area: unit; }
  .wh-line__char:empty { display: block; }
  .wh-qty { height: 36px; width: 110px; font-size: 16px; }
  .wh-group__head { grid-template-columns: auto minmax(0, 1fr) auto auto; grid-template-areas: "icon name status count"; min-height: 44px; }
  .wh-bar { margin: 8px 0 0; padding-left: 0; padding-right: 0; }
  .wh-bar .btn { flex: 0 0 auto; }
  .wh-bar #wh-accept { margin-left: auto; }
}
/* R35 «Склады организации» */
.wh-wlist { list-style: none; margin: 8px 0 0; padding: 0; }
.wh-wlist__item { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; padding: 8px 0;
  border-top: 1px solid var(--border); min-height: 44px; overflow-wrap: anywhere; }
/* ================= R36 «Пользователи»: ONE card — «Учётные данные» | «Настройки пользователя» =================
   ≥900px: two columns aligned at the top; below: one column, credentials first. Phones: full-width controls,
   16px inputs (no Safari zoom), 44px touch targets, no horizontal scroll. */
.user-card__grid.user-card__grid--r36 { grid-template-columns: 1fr; gap: var(--space-6); }
@media (min-width: 900px) {
  .user-card__grid.user-card__grid--r36 { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: start; }
}
.user-card__heading { font-size: 1rem; font-weight: 700; color: var(--heading); margin: 0; }
.user-card__generate { width: 100%; }
.user-card__reps { max-height: 260px; overflow-y: auto; }
.cred-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.cred-row .input { flex: 1 1 200px; min-width: 0; }
.cred-row .btn { flex: 0 0 auto; }
.cred-status--ok { color: var(--success); }
.cred-status--error { color: var(--danger); }
@media (max-width: 767px) {
  .user-card .input, .user-card .select { font-size: 16px; }
  .user-card .btn, .user-card .check-row { min-height: 44px; }
  .cred-row .btn { flex: 1 1 auto; }
}
/* R38 «Склад → Настройка»: the shared nomenclature picker on a phone — tree first, products below, no crushed panes */
.wh-page .role-explorer .explorer-pane { min-width: 0; }
.wh-page .explorer-products { overflow-x: hidden; }
.wh-page .explorer-table { table-layout: fixed; }
.wh-page .explorer-table td { overflow-wrap: anywhere; }
.wh-page .explorer-table th:first-child, .wh-page .explorer-table td:first-child { width: 40px; }
.wh-page .explorer-table input[type=checkbox], .wh-page .explorer-tree input[type=checkbox] { width: 22px; height: 22px; }
@media (max-width: 600px) {
  .wh-page .explorer-table th:nth-child(3), .wh-page .explorer-table td:nth-child(3) { width: 34%; }
  .wh-page .explorer-table th:nth-child(4), .wh-page .explorer-table td:nth-child(4) { width: 44px; }
  .wh-page .explorer-table th:nth-child(5), .wh-page .explorer-table td:nth-child(5) { display: none; }
  .wh-page .tree-row { min-height: 44px; }
  .wh-page .explorer-tree { max-height: 46vh; max-height: 46dvh; }
  .wh-page .explorer-products { max-height: 60vh; max-height: 60dvh; }
}
/* R39 «Новый пользователь» on a phone: type · counterparty · roles → credentials → status / store / representative
   (the DOM order — also the tab and screen-reader order); ≥900px the approved two columns stay: credentials on the
   left over the whole height, the settings and then the extra settings on the right. */
.user-card__grid.user-card__grid--r39 { grid-template-columns: 1fr; grid-template-areas: "main" "cred" "extra"; }
.user-card__grid--r39 > .user-card__main { grid-area: main; }
.user-card__grid--r39 > .user-card__cred { grid-area: cred; }
.user-card__grid--r39 > .user-card__extra { grid-area: extra; }
@media (min-width: 900px) {
  .user-card__grid.user-card__grid--r39 { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    grid-template-areas: "cred main" "cred extra"; grid-template-rows: auto 1fr; align-items: start; row-gap: var(--space-4); }
}

/* ---- R55: lines without a price + the native 1C order («Заказ в 1С») ---- */
.price-missing { color: #a15c00; font-weight: 600; white-space: nowrap; }
.price-missing-note { color: #a15c00; margin: 6px 0 0; grid-column: 1 / -1; text-align: left; }
.native-order__number { font-weight: 600; color: var(--muted); font-size: 0.9rem; }
.native-order__state { margin: 4px 0 12px; font-size: 0.88rem; }
.native-order__state--ok { color: var(--success, #1f7a3d); }
.native-order__state--failed { color: #b42318; font-weight: 600; }
.native-order__state--pending { color: var(--muted); }
.native-order__warn { color: #b42318; }
.native-order__doc { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 8px 16px; margin: 0 0 12px; }
.native-order__doc dt { color: var(--muted); font-size: 0.78rem; }
.native-order__doc dd { margin: 0; overflow-wrap: anywhere; }
.native-order__h { font-size: 0.95rem; margin: 0 0 6px; }
.native-order__changes { background: #fff8eb; border: 1px solid #f3d9a4; border-radius: var(--radius-input); padding: 10px 14px; margin-bottom: 12px; }
.native-order__changes ul { margin: 0; padding-left: 18px; }
.native-order__ambiguous { font-style: italic; }
.native-order__part { border-top: 1px solid var(--border); padding: 8px 0; }
.native-order__part > summary { cursor: pointer; font-weight: 700; color: var(--heading); padding: 4px 0; }
.native-lines { display: flex; flex-direction: column; }
.native-line { display: grid; grid-template-columns: minmax(0, 1fr) 72px 128px 84px; gap: 4px 12px; padding: 7px 0; border-bottom: 1px solid var(--border); align-items: baseline; }
.native-line:last-child { border-bottom: none; }
.native-line--changed { background: #fff8eb; }
.native-line--separator { display: block; font-weight: 700; color: var(--muted); }
.native-line--total { grid-template-columns: minmax(0, 1fr) auto; }
.native-line__name { min-width: 0; overflow-wrap: anywhere; }
.native-line__qty, .native-line__price, .native-line__sum { text-align: right; white-space: nowrap; }
.native-history { margin: 6px 0; padding-left: 18px; }
.native-history li { margin-bottom: 6px; overflow-wrap: anywhere; }
@media (max-width: 600px) {
  .native-line { grid-template-columns: minmax(0, 1fr) auto auto; }
  .native-line__name { grid-column: 1 / -1; }
  .native-line__qty { text-align: left; }
  .native-line--total .native-line__name { grid-column: 1; }
  .native-order .order-table-heading { flex-wrap: wrap; gap: 8px; }
}

/* ---- R56: who the order is from now («Создан клиентом» / «Создан администратором» / «Изменён в 1С») ---- */
.order-row__origin { color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.native-order__state { margin: 0; }
/* the order rows: name (+ characteristic) bold, the price small grey below; on phones quantity | sum on line two */
.order-line__char { font-weight: 400; color: var(--muted); }
@media (max-width: 960px) {
  .order-line { grid-template-columns: minmax(0, 1fr) auto auto; grid-template-areas: "info info actions" "qty total actions";
    column-gap: 12px; row-gap: 0; }
  .order-line__thumb { display: none; }
  .order-line__info { grid-area: info; padding: 8px 0 2px; }
  .order-line__qty { grid-area: qty; grid-column: auto; padding: 2px 0 8px; }
  .order-line__total { grid-area: total; grid-column: auto; text-align: right; padding: 2px 0 8px; }
  .order-line__actions { grid-area: actions; grid-column: auto; grid-row: auto; align-self: center; }
}
/* ============================================================
   R71 — tablet (Redmi Pad class, touch, 9–11") and the installed app (PWA)
   Tablet = touch screen at least 600 px wide and 500 px high (phones in either orientation stay on the phone
   layout). Landscape (> 960 px): the usual sidebar, bigger touch targets. Portrait (600–960 px): instead of the
   hidden drawer an always visible rail of icons with short labels (pwa.js keeps its account menu closed).
   ============================================================ */

.nav-item--refresh {
  width: 100%;
  margin-top: auto;
  border: 0;
  background: none;
  font: inherit;
  font-weight: 600;
  font-size: 0.925rem;
  text-align: left;
  cursor: pointer;
}

.nav-item[hidden],
.sidebar__account-item[hidden],
.btn[hidden],
.card__text[hidden] { display: none !important; }

@media (pointer: coarse) and (min-width: 600px) and (min-height: 500px) {
  :root { --control-h: 48px; }
  body { -webkit-tap-highlight-color: transparent; }
  .btn { font-size: 1rem; }
  .input, .select, .textarea { font-size: 1rem; }
  .nav-item { min-height: 48px; font-size: 1rem; }
  .sidebar__account summary { min-height: 48px; }
  .sidebar__account-item { min-height: 44px; font-size: 0.95rem; }

  /* «Производство» — the main (often the only) section of a production account: the date and the two sheets
     stay at hand above the A4 preview while it scrolls */
  .prod-print-page .prod-controls {
    position: sticky;
    top: 0;
    z-index: 15;
    gap: 12px;
    box-shadow: var(--shadow-pop);
  }
  .prod-print-page .prod-print-hint { display: none; }
  .prod-print-page .prod-controls.card { padding: 16px; }
  .prod-controls .btn { min-height: 52px; padding: 0 20px; }
  .prod-date .input { min-height: 52px; font-size: 1.05rem; }
  /* the date speaks for itself: its label stays for screen readers only, the panel is one row lower */
  .prod-date .field__label {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
  }
}

/* R85: no icon rail on a tablet any more — the menu is a drawer behind «☰» (the ≤960px rules above); only the
   portrait layout of «Производство» stays */
@media (pointer: coarse) and (min-width: 600px) and (max-width: 960px) and (min-height: 500px) {
  .content { padding: var(--space-4); }

  /* «Производство» in portrait: date + Excel + print on the first row, the two sheets on the second */
  .prod-print-page .prod-controls { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); align-items: end; }
  .prod-print-page .prod-date { grid-column: span 2; min-width: 0; }
  .prod-print-page .prod-buttons { display: contents; }
  .prod-print-page #production-clients, .prod-print-page #production-summary { grid-row: 2; grid-column: span 2; }
  .prod-print-page .prod-controls .btn { padding: 0 10px; }
}
/* ============================================================
   R73 — «Взвешивание»: the confectioners' screen (tablet first)
   ============================================================ */

.weigh-mode .sidebar,
.weigh-mode .topbar,
.weigh-mode .sidebar-backdrop { display: none !important; }
.weigh-mode .app-shell { grid-template-columns: minmax(0, 1fr); }
.weigh-mode .content { max-width: 1100px; margin: 0 auto; padding: var(--space-4); }

.weigh { display: flex; flex-direction: column; gap: 12px; min-height: calc(100dvh - 32px); }
.weigh-head { display: flex; align-items: center; gap: 16px; }
.weigh-head__title { flex: 1 1 auto; min-width: 0; }
.weigh-step { font-weight: 700; color: var(--primary); font-size: 1rem; }
.weigh-client { margin: 2px 0; font-size: 1.45rem; line-height: 1.2; color: var(--heading); overflow-wrap: anywhere; }
.weigh-count { flex: none; font-size: 1.6rem; font-weight: 800; color: var(--heading); font-variant-numeric: tabular-nums; }
.weigh-exit { flex: none; }
.weigh-track { height: 6px; border-radius: 3px; background: var(--border); overflow: hidden; }
.weigh-track span { display: block; height: 100%; background: var(--primary); }

.weigh-lines { display: flex; flex-direction: column; gap: 10px; flex: 1 1 auto; }
.weigh-line { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-card); padding: 14px 16px; }
.weigh-line__head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px; margin-bottom: 10px; }
.weigh-line__name { font-weight: 700; color: var(--heading); font-size: 1.1rem; overflow-wrap: anywhere; }
.weigh-line__char { font-weight: 600; color: var(--primary); white-space: nowrap; }
.weigh-line__meta { color: var(--muted); font-size: 0.95rem; }
/* the lines that are not weighed: visible, pale and closed */
.weigh-line--closed { display: flex; justify-content: space-between; gap: 12px; padding: 10px 16px; opacity: 0.45;
  background: repeating-linear-gradient(135deg, var(--surface), var(--surface) 10px, var(--bg) 10px, var(--bg) 20px);
  pointer-events: none; user-select: none; }
.weigh-line--closed .weigh-line__name { font-size: 0.95rem; font-weight: 600; }

.weigh-pieces { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 10px; }
.weigh-piece { display: grid; grid-template-columns: 32px minmax(0, 1fr) auto; grid-template-rows: auto auto; align-items: center;
  gap: 2px 8px; padding: 8px 10px; border: 2px solid var(--border); border-radius: var(--radius-btn); background: var(--bg); }
.weigh-piece__n { grid-row: 1 / span 2; width: 32px; height: 32px; border-radius: 50%; display: inline-flex; align-items: center;
  justify-content: center; background: var(--primary-soft); color: var(--primary); font-weight: 800; }
.weigh-input { min-height: 56px; font-size: 1.6rem; font-weight: 700; text-align: right; font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em; padding: 0 10px; }
.weigh-piece__unit { color: var(--muted); font-weight: 700; }
.weigh-piece__state { grid-column: 2 / span 2; font-size: 0.8rem; min-height: 1em; color: var(--muted); }
.weigh-piece--saved { border-color: var(--success); background: var(--success-soft, #ecfdf3); }
.weigh-piece--saved .weigh-piece__state { color: var(--success); }
.weigh-piece--pending, .weigh-piece--busy { border-color: var(--warning); }
.weigh-piece--error { border-color: var(--danger); }
.weigh-piece--error .weigh-piece__state { color: var(--danger); }

.weigh-bar { position: sticky; bottom: 0; z-index: 10; display: flex; align-items: center; gap: 12px; padding: 12px 0
  calc(12px + env(safe-area-inset-bottom, 0px)); background: linear-gradient(to top, var(--bg) 75%, transparent); }
.weigh-bar__prev { flex: 0 0 auto; min-width: 140px; }
.weigh-bar__state { flex: 1 1 auto; text-align: center; }
.weigh-bar .btn { min-height: 56px; font-size: 1.1rem; padding: 0 24px; }
.weigh-bar__next { flex: 0 0 auto; min-width: 200px; }
.weigh-bar__next[aria-disabled="true"] { opacity: 0.45; }

.weigh-summary { display: flex; flex-direction: column; padding: 4px 0; }
.weigh-summary__row { display: flex; align-items: center; gap: 12px; padding: 12px 16px; min-height: 56px; color: var(--text);
  text-decoration: none; border-bottom: 1px solid var(--border); }
.weigh-summary__row:last-child { border-bottom: 0; }
.weigh-summary__n { width: 32px; height: 32px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center;
  background: var(--warning-soft, #fff7e6); font-weight: 800; flex: none; }
.weigh-summary__row--done .weigh-summary__n { background: var(--success-soft, #ecfdf3); color: var(--success); }
.weigh-summary__name { flex: 1 1 auto; min-width: 0; font-weight: 600; overflow-wrap: anywhere; }
.weigh-summary__state { flex: none; font-weight: 700; }
.weigh-send { display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
.weigh-send__btn { min-height: 56px; font-size: 1.15rem; padding: 0 32px; }

.weigh-day__pick { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.weigh-day__date { max-width: 200px; }
.weigh-day__actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0; }
.weigh-start { min-height: 56px; font-size: 1.1rem; padding: 0 28px; }
.weigh-day__list { margin: 8px 0 0; padding-left: 24px; }
.weigh-day__list li { padding: 3px 0; }
.weigh-history { display: flex; flex-direction: column; gap: 10px; }
.weigh-history__row { padding: 8px 0; border-bottom: 1px solid var(--border); }
.weigh-history__row:last-child { border-bottom: 0; }

@media (max-width: 640px) {
  .weigh-head { flex-wrap: wrap; }
  .weigh-client { font-size: 1.2rem; }
  .weigh-bar__prev { min-width: 0; }
  .weigh-bar__next { min-width: 0; }
  .weigh-bar__state { display: none; }
}
.weigh-input::placeholder { color: #c3cad6; font-weight: 600; }

/* R74: «монетка» — order paid in 1C (its «Расходная накладная» settled); partial = outlined */
.order-coin { display: inline-flex; align-items: center; justify-content: center; width: 20px; height: 20px;
  margin-left: 6px; border-radius: 50%; vertical-align: middle; font-size: 11px; font-weight: 700; line-height: 1;
  color: #7a5200; background: radial-gradient(circle at 35% 30%, #fff3b0 0%, #f5c542 55%, #d9a21b 100%);
  box-shadow: inset 0 0 0 1.5px #c08a12; flex: 0 0 auto; cursor: default; user-select: none; }
.order-coin--partial { background: transparent; color: #a77510; box-shadow: inset 0 0 0 1.5px #d9a21b; }
.order-row__status .order-coin { margin-left: 4px; }
/* R75: a piece product of «Кондитерские изделия» — the count, pre-filled with the ordered one */
.weigh-line--count { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 16px; }
.weigh-count-field { display: grid; grid-template-columns: auto 110px auto; grid-template-rows: auto auto; align-items: center;
  gap: 2px 8px; padding: 6px 10px; border: 2px solid var(--border); border-radius: var(--radius-btn); background: var(--bg); }
.weigh-count-field__ordered { grid-column: 1; grid-row: 1 / span 2; }
.weigh-count-input { min-height: 52px; font-size: 1.4rem; font-weight: 700; text-align: right; font-variant-numeric: tabular-nums; }
.weigh-count-field .weigh-piece__state { grid-column: 2 / span 2; }
.weigh-count-field--changed { border-color: var(--warning); background: var(--warning-soft, #fff7e6); }
.weigh-count-field--changed .weigh-piece__state { color: #8a5a00; font-weight: 600; }
/* R76: «Убрать / Вернуть» a confectionery position */
.weigh-piece { position: relative; }
.weigh-del { grid-column: 1 / -1; justify-self: end; margin-top: 2px; border: 0; background: none; color: var(--danger);
  font: inherit; font-size: 0.85rem; font-weight: 600; padding: 4px 6px; cursor: pointer; border-radius: 8px; }
.weigh-del[data-deleted="1"] { color: var(--primary); }
.weigh-count-field .weigh-del { grid-column: 3; grid-row: 2; }
.weigh-piece--deleted { border-style: dashed; background: transparent; opacity: 0.7; }
.weigh-piece--deleted .weigh-input, .weigh-piece--deleted .weigh-count-input { text-decoration: line-through; background: transparent; }
.weigh-piece--deleted .weigh-piece__state { color: var(--danger); font-weight: 600; }

/* R77: the open days of «Взвешивание» with their number of orders */
.weigh-day__n { display: inline-flex; min-width: 22px; height: 22px; padding: 0 6px; margin-left: 6px; align-items: center;
  justify-content: center; border-radius: 11px; background: rgba(255, 255, 255, 0.25); font-size: 0.8rem; font-weight: 800; }
.btn-outline .weigh-day__n { background: var(--primary-soft); color: var(--primary); }

/* R77: orders done (big) + the cakes of this order (plain line) */
.weigh-items { font-size: 1rem; color: var(--text); margin: 2px 0; }
.weigh-items span { font-weight: 700; font-variant-numeric: tabular-nums; }
.weigh-count { text-align: right; line-height: 1.1; }
.weigh-count__label { display: block; font-size: 0.8rem; font-weight: 600; color: var(--muted); }

/* R78: «Убрать / Вернуть» — a separate small button to the RIGHT of the field, outside its box */
.weigh-piece-wrap { display: flex; align-items: stretch; gap: 8px; min-width: 0; }
.weigh-piece-wrap > .weigh-piece, .weigh-piece-wrap > .weigh-count-field { flex: 1 1 auto; min-width: 0; }
.weigh-pieces { grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); }
.weigh-del { grid-column: auto; grid-row: auto; justify-self: auto; align-self: center; flex: 0 0 auto; margin: 0;
  min-height: 44px; padding: 0 14px; border: 1.5px solid var(--danger); border-radius: var(--radius-btn); background: var(--surface);
  color: var(--danger); font: inherit; font-size: 0.9rem; font-weight: 700; cursor: pointer; }
.weigh-del[data-deleted="1"] { border-color: var(--primary); color: var(--primary); }
.weigh-count-field .weigh-del { grid-column: auto; grid-row: auto; }

/* R78: «взвешено 12 из 13» */
.weigh-count__word { font-size: 1rem; font-weight: 600; color: var(--muted); }

/* R78: «заказано 2 шт» under the count field — a compact block leaves room for «Убрать» */
.weigh-count-field { grid-template-columns: 96px auto; grid-template-rows: auto auto auto; gap: 2px 8px; }
.weigh-count-field .weigh-count-input { grid-column: 1; grid-row: 1; }
.weigh-count-field .weigh-piece__unit { grid-column: 2; grid-row: 1; }
.weigh-count-field .weigh-count-field__ordered { grid-column: 1 / -1; grid-row: 2; }
.weigh-count-field .weigh-piece__state { grid-column: 1 / -1; grid-row: 3; }
/* R79: the home list of a started weighing; read-only order view */
.weigh-summary--home { border: 1px solid var(--border); border-radius: var(--radius-card); margin-top: 8px; }
.weigh-summary__row--shipped .weigh-summary__state { color: var(--muted); font-weight: 600; }
.weigh--readonly .weigh-del { display: none; }
.weigh--readonly .weigh-input, .weigh--readonly .weigh-count-input { pointer-events: none; background: transparent; }

/* R81: «торты — 5 шт · эклеры — 10 шт · остальное — 3 шт» — smaller type so it always fits */
.weigh-summary__state { font-size: 0.85rem; font-weight: 600; text-align: right; }
.weigh-summary__row { gap: 10px; }
@media (max-width: 640px) { .weigh-summary__state { font-size: 0.78rem; max-width: 55%; } }

/* R83: the parts of an order as icon columns — cakes · eclairs · everything else, fixed widths so they line up */
.weigh-summary__mark { flex: none; font-size: 0.8rem; font-weight: 700; color: var(--success); text-align: right; white-space: nowrap; }
.weigh-summary__row--shipped .weigh-summary__mark { color: var(--muted); }
.weigh-parts { flex: none; display: grid; grid-template-columns: repeat(3, 84px); gap: 8px; }
.weigh-part { display: inline-flex; align-items: center; gap: 4px; font-size: 0.9rem; color: var(--text); white-space: nowrap; }
.weigh-part b { font-weight: 800; min-width: 1.3em; text-align: right; font-size: 1rem; }
.weigh-part__icon { width: 32px; height: 32px; flex: none; }


/* R84: an order row is two lines on every screen — the name across the whole width, below it the 1C number on the
   left and the mark + the three icon columns on the right */
.weigh-summary__body { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.weigh-summary__body .weigh-summary__name { flex: none; }
.weigh-summary__line2 { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.weigh-summary__num { white-space: nowrap; }
.weigh-summary__right { display: inline-flex; align-items: center; gap: 12px; margin-left: auto; flex-wrap: wrap; justify-content: flex-end; max-width: 100%; }
@media (max-width: 640px) {
  .weigh-parts { grid-template-columns: repeat(3, 66px); gap: 4px; }
  .weigh-part { font-size: 0.78rem; gap: 2px; }
  .weigh-part__icon { width: 24px; height: 24px; }
  .weigh-summary__mark { font-size: 0.72rem; }
  .weigh-summary__right { gap: 6px; }
}

/* ============================================================
   R85 — a touch tablet in landscape (961–1400px) gets the same drawer menu as portrait: hidden by default,
   «☰» in the top bar opens it over the page
   ============================================================ */
@media (pointer: coarse) and (min-width: 961px) and (max-width: 1400px) and (min-height: 500px) {
  .app-shell { grid-template-columns: minmax(0, 1fr); }
  .sidebar {
    display: none;
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    z-index: 100;
    width: min(320px, 85vw);
    height: auto;
    max-height: 100dvh;
    box-shadow: var(--shadow-pop);
    padding-bottom: calc(var(--space-5) + env(safe-area-inset-bottom, 0px));
    -webkit-overflow-scrolling: touch;
  }
  .sidebar--open { display: flex; }
  .sidebar-backdrop { position: fixed; inset: 0; z-index: 99; background: rgba(15, 23, 42, 0.35); }
  html.nav-locked body { position: fixed; left: 0; right: 0; width: 100%; overflow: hidden; }
  .topbar { display: flex; }
  .menu-toggle { display: inline-flex; align-items: center; justify-content: center; }
  .topbar__brand { display: block; }
}

/* R92 — the tablet app's own calendar for date fields (kiosk_date.js, user agent «OrdersKiosk» only):
   a tap on a day sets the date, no «Установить / Отмена / Удалить». */
.kd-overlay { position: fixed; inset: 0; z-index: 1000; background: rgba(15, 23, 42, .45); display: flex;
  align-items: center; justify-content: center; padding: 16px; }
.kd-card { background: var(--surface); border-radius: 24px; box-shadow: 0 20px 50px rgba(15, 23, 42, .3);
  padding: 18px 16px 14px; width: min(420px, 100%); user-select: none; -webkit-user-select: none; }
.kd-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.kd-title { font-size: 20px; font-weight: 700; color: var(--text); }
.kd-nav { width: 48px; height: 48px; border: 0; border-radius: 50%; background: var(--primary-soft); color: var(--primary);
  font-size: 30px; line-height: 1; cursor: pointer; }
.kd-week, .kd-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.kd-week span { text-align: center; font-size: 13px; font-weight: 600; color: var(--muted); padding: 4px 0; }
.kd-week .kd-weekend { color: #dc2626; }
.kd-day { aspect-ratio: 1; min-height: 44px; border: 0; border-radius: 50%; background: transparent; color: var(--text);
  font-size: 18px; font-weight: 500; cursor: pointer; }
.kd-day.kd-out { color: #b8c2d4; }
.kd-day.kd-today { box-shadow: inset 0 0 0 2px var(--primary); color: var(--primary); font-weight: 700; }
.kd-day.kd-sel { background: var(--primary); color: #fff; font-weight: 700; box-shadow: none; }
.kd-day:disabled { color: #dfe4ec; cursor: default; }
.kd-day:not(:disabled):active { background: var(--primary-soft); }
/* R111 — the same calendar everywhere (computers, phones): the site's font, the month picker, «Сегодня / Очистить» */
.kd-card, .kd-card button { font-family: inherit; }
.kd-field { cursor: pointer; }
.kd-field::-webkit-calendar-picker-indicator { display: none; }
.kd-day.kd-we:not(.kd-out):not(.kd-sel) { color: #dc2626; }
.kd-grid--months { grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 6px; }
.kd-day.kd-month { aspect-ratio: auto; min-height: 52px; border-radius: 14px; font-size: 17px; }
.kd-foot { display: flex; justify-content: space-between; gap: 8px; margin-top: 10px; }
.kd-link { border: 0; background: transparent; color: var(--primary); font-size: 15px; font-weight: 600; padding: 8px 10px;
  border-radius: 10px; cursor: pointer; }
.kd-link:hover, .kd-day:not(:disabled):hover, .kd-nav:hover { background: var(--primary-soft); }
.kd-day.kd-sel:hover { background: var(--primary); }
.kd-card :focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
@media (min-width: 768px) {
  .kd-card { width: 340px; padding: 14px 14px 10px; border-radius: 18px; }
  .kd-title { font-size: 17px; }
  .kd-nav { width: 38px; height: 38px; font-size: 24px; }
  .kd-day { min-height: 38px; font-size: 15px; }
  .kd-day.kd-month { min-height: 44px; font-size: 15px; }
}

/* R93 — the tablet app: «Печать» (= «На принтер») asks only «Напечатать?» — «Да» / «Нет» (production_print.js). */
.kp-card { width: min(360px, 100%); padding: 26px 22px 20px; text-align: center; }
.kp-title { font-size: 24px; font-weight: 700; color: var(--text); margin-bottom: 22px; }
.kp-buttons { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.kp-buttons .btn { min-height: 52px; font-size: 18px; }
.prod-kiosk-print { display: inline-flex; align-items: center; gap: 8px; }

/* R94 — «Производство» in the tablet app (html.kiosk-app, set by kiosk_date.js): no «Скачать Excel»; the date and
   «Печать» at the two edges (the date left, «Печать» right, the middle empty — operator 10.11), as wide as one quarter;
   the two sheets on the second row. */
html.kiosk-app .prod-print-page .prod-controls { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); align-items: end; }
html.kiosk-app .prod-print-page .prod-buttons { display: contents; }
html.kiosk-app .prod-print-page .prod-date { grid-row: 1; grid-column: 1; min-width: 0; }
html.kiosk-app .prod-print-page #production-to-printer { grid-row: 1; grid-column: 4; }

html.kiosk-app .prod-print-page #production-clients, html.kiosk-app .prod-print-page #production-summary { grid-row: 2; grid-column: span 2; }
html.kiosk-app .prod-print-page .prod-controls .btn { padding: 0 10px; }

/* R96 — «Касса» водителей (phone first) */
.cash-head { align-items: center; }
.cash-head__driver { font-weight: 500; color: var(--text-muted, #64748b); }
.cash-card { padding: 14px; }
.cash-driver { display: grid; gap: 4px; margin-bottom: 12px; }
.cash-day { display: grid; grid-template-columns: 52px 1fr 52px; gap: 8px; align-items: center; }
.cash-day__arrow { height: 48px; font-size: 26px; line-height: 1; padding: 0; display: flex; align-items: center; justify-content: center; }
.cash-day__mid { display: grid; justify-items: center; gap: 2px; }
.cash-day__date { height: 48px; text-align: center; font-size: 17px; width: 100%; max-width: 240px; }
.cash-balance { margin-top: 14px; padding: 12px 14px; border-radius: 14px; background: var(--surface-muted, #f1f5f9); }
.cash-balance__main { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.cash-balance__main b { font-size: 22px; }
.cash-balance__day { margin-top: 4px; }
.cash-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 12px; }
.cash-actions .btn { min-height: 48px; white-space: normal; }
.cash-orders__head { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; }
.cash-list { display: grid; gap: 8px; margin-top: 8px; }
.cash-row { display: grid; grid-template-columns: 26px 1fr 56px; gap: 10px; align-items: center; padding: 10px 10px 10px 8px;
  border: 1px solid var(--border, #e2e8f0); border-radius: 14px; background: var(--surface, #fff); }
.cash-row__n { color: var(--text-muted, #64748b); font-size: 14px; text-align: center; }
.cash-row__body { display: grid; gap: 2px; min-width: 0; }
.cash-row__name { font-weight: 600; overflow-wrap: anywhere; }
.cash-row__line2 { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.cash-row__sum { font-weight: 700; font-size: 17px; white-space: nowrap; }
.cash-row__by { color: #15803d; }
.cash-row--paid { background: var(--surface-muted, #f1f5f9); }
.cash-row--paid .cash-row__name, .cash-row--paid .cash-row__sum { color: var(--text-muted, #64748b); }
.cash-row--gone { opacity: .7; }
.cash-check { width: 52px; height: 52px; border-radius: 14px; border: 2px solid var(--border-strong, #94a3b8); background: #fff;
  color: transparent; font-size: 28px; font-weight: 700; cursor: pointer; }
.cash-check:not([disabled]):active { transform: scale(.96); }
.cash-check--on { background: #16a34a; border-color: #16a34a; color: #fff; cursor: pointer; }
.cash-check--on[disabled] { cursor: default; opacity: .75; }
.cash-undo { background: none; border: 0; padding: 0 0 0 6px; color: var(--danger, #dc2626); text-decoration: underline; cursor: pointer; font-size: 14px; }
.cash-op { display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; padding: 10px 0; border-bottom: 1px solid var(--border, #e2e8f0); }
.cash-op__body { display: grid; gap: 2px; }
.cash-op__sum { font-weight: 700; white-space: nowrap; }
.cash-op--incoming .cash-op__sum, .cash-op--deposit .cash-op__sum { color: #15803d; }
/* R120: the superadmin's balances of every 1C cash box */
.cash-bal-list { display: grid; margin: 4px 0 6px; }
.cash-bal { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--border, #e2e8f0); }
.cash-bal__sum { font-weight: 700; white-space: nowrap; font-variant-numeric: tabular-nums; }
.cash-bal--zero .cash-bal__sum { color: var(--text-muted, #64748b); font-weight: 500; }
.cash-bal--neg .cash-bal__sum { color: #dc2626; }
.cash-bal--total { border-bottom: 0; font-size: 17px; }
.cash-actions #cash-send { grid-column: 1 / -1; }                    /* R116: five buttons — «Отправить в 1С» full width */
.cash-op--expense .cash-op__sum { color: #dc2626; }                  /* R114: spent — red minus */
.cash-form__rest { color: var(--text, #0f172a); }
.cash-form__rest .btn-link { padding: 4px 6px; font-size: 15px; }                 /* R112: moved in by another driver */
.cash-form__box { font-size: 16px !important; }
.cash-op .cash-undo { grid-column: 1 / -1; justify-self: start; padding-left: 0; }
.cash-form { display: grid; gap: 12px; width: min(420px, 100%); }
.cash-form__title { margin-bottom: 2px; }
.cash-form__label { display: grid; gap: 4px; font-size: 14px; color: var(--text-muted, #64748b); }
.cash-form__label .input { height: 48px; font-size: 18px; color: var(--text, #0f172a); }
.cash-form__error { color: var(--danger, #dc2626); margin: 0; }
.cash-form .kp-buttons .btn { min-height: 50px; font-size: 17px; }
.cash-tree-card .cash-tree__search { margin: 8px 0; }
.cash-tree { max-height: 60vh; overflow: auto; border: 1px solid var(--border, #e2e8f0); border-radius: 12px; padding: 6px 8px; }
.cash-tree__item { display: flex; gap: 8px; align-items: center; padding: 6px 2px; cursor: pointer; }
.cash-tree__item input { width: 20px; height: 20px; flex: none; }
.cash-tree__group > summary { list-style: none; cursor: pointer; }
.cash-tree__group > summary::before { content: "▸"; display: inline-block; width: 16px; color: var(--text-muted, #64748b); }
.cash-tree__group[open] > summary::before { content: "▾"; }
.cash-tree__group > summary .cash-tree__item { display: inline-flex; }
.cash-tree__kids { padding-left: 22px; }
.cash-tree__group--off > .cash-tree__kids { opacity: .45; }
.cash-tree__actions { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin-top: 12px; }
@media (min-width: 768px) {
  .cash-actions { grid-template-columns: repeat(5, auto); justify-content: start; }
  .cash-actions #cash-send { grid-column: auto; }
  .cash-card { padding: 20px; }
}
#cash-error[hidden], #cash-settings-ok[hidden], #cash-settings-error[hidden] { display: none; }

/* R98 — the cash flow item picker (search + list + «Закрыть») */
.cash-form__article-pick { text-align: left; color: var(--text-muted, #64748b); cursor: pointer; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cash-form__article-pick--set { color: var(--text, #0f172a); font-weight: 600; }
.cash-pick-overlay { align-items: stretch; padding: 12px; }
.cash-pick { width: min(520px, 100%); max-height: calc(100vh - 24px); display: flex; flex-direction: column; gap: 10px; margin: auto; }
.cash-pick__head { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.cash-pick__close { min-height: 44px; }
.cash-pick__search { height: 48px; font-size: 17px; flex: none; }
.cash-pick__list { overflow-y: auto; display: grid; gap: 6px; padding-bottom: 4px; min-height: 120px; }
.cash-pick__item { display: grid; gap: 2px; text-align: left; padding: 12px; border: 1px solid var(--border, #e2e8f0); border-radius: 12px;
  background: var(--surface, #fff); font-size: 16px; cursor: pointer; color: var(--text, #0f172a); }
.cash-pick__item:active { background: var(--surface-muted, #f1f5f9); }
.cash-pick__name { font-weight: 600; }
.cash-pick__empty { padding: 12px; }

/* R99 — pull down to reload (the app only, pull_refresh.js) */
.ptr { position: fixed; top: 0; left: 50%; z-index: 2000; transform: translate(-50%, -52px); opacity: 0; pointer-events: none; }
.ptr--back { transition: transform .2s ease, opacity .2s ease; }
.ptr__circle { width: 44px; height: 44px; border-radius: 50%; background: #fff; color: #64748b; display: flex; align-items: center;
  justify-content: center; box-shadow: 0 4px 14px rgba(15, 23, 42, .22); }
.ptr--ready .ptr__circle, .ptr--spin .ptr__circle { color: #2563eb; }
.ptr--spin svg { animation: ptr-spin .8s linear infinite; }
@keyframes ptr-spin { to { transform: rotate(360deg); } }
/* R99: paid in 1C by the accountant */
.cash-row__by--1c { color: #2563eb; }
.cash-check--1c, .cash-check--1c[disabled] { background: #93c5fd; border-color: #93c5fd; opacity: 1; }
/* R101: the 1C state of a cash operation */
.cash-sync { display: block; color: var(--text-muted, #64748b); }
.cash-sync--ok { color: #15803d; }
.cash-sync--err { color: var(--danger, #dc2626); }
.cash-1c-table { width: 100%; border-collapse: collapse; }
.cash-1c-table td, .cash-1c-table th { padding: 6px 4px; border-bottom: 1px solid var(--border, #e2e8f0); vertical-align: top; text-align: left; }
.cash-1c-table select { width: 100%; min-width: 140px; }
.cash-1c-grid { display: grid; gap: 10px; }

/* R104 — «Зарплата» торгового представителя */
.salary-card { padding: 14px; }
.salary-sum { margin-top: 12px; display: grid; gap: 10px; }
.salary-sum__total { display: flex; justify-content: space-between; align-items: baseline; flex-wrap: wrap; gap: 8px;
  padding: 12px 14px; border-radius: 14px; background: var(--surface-muted, #f1f5f9); }
.salary-sum__money { font-size: 26px; }
.salary-sum__parts { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 8px; }
.salary-part { display: grid; gap: 2px; padding: 8px 10px; border: 1px solid var(--border, #e2e8f0); border-radius: 12px; }
.salary-sum--compact .salary-sum__money { font-size: 22px; }
.salary-reward { color: #a16207; }
.salary-debt { color: var(--danger, #dc2626); }
/* R130 (operator 19.11): the invoice number bold and in the text colour — the order next to it stays thin and grey */
.salary-invoice { font-weight: 700; color: var(--text, #111827); }
.salary-terms { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 10px; align-items: end; }
.salary-list { display: grid; gap: 8px; margin-top: 8px; }
.salary-row { display: grid; grid-template-columns: 1fr auto; gap: 10px; padding: 10px 12px; border: 1px solid var(--border, #e2e8f0);
  border-radius: 14px; align-items: center; }
.salary-row__main { display: grid; gap: 2px; min-width: 0; }
.salary-row__name { font-weight: 600; overflow-wrap: anywhere; }
.salary-row__right { display: grid; justify-items: end; gap: 4px; }
.salary-row__sum { font-weight: 700; white-space: nowrap; display: inline-flex; align-items: center; }
.salary-reward-chip { background: #fef3c7; color: #92400e; border: 1px solid #fcd34d; border-radius: 999px; padding: 2px 8px;
  font-size: 13px; font-weight: 700; white-space: nowrap; }
.salary-reward-chip--unpaid { background: transparent; border-color: transparent; color: var(--text-muted, #64748b); }   /* R124 */

/* R104: «Сотрудник 1С» combobox */
.emp-combo { position: relative; }
.emp-list { position: absolute; z-index: 30; left: 0; right: 0; top: calc(100% + 4px); max-height: 260px; overflow-y: auto;
  background: var(--surface, #fff); border: 1px solid var(--border, #e2e8f0); border-radius: 12px; box-shadow: 0 10px 30px rgba(15, 23, 42, .15); }
.emp-opt { padding: 10px 12px; cursor: pointer; }
.emp-opt:hover { background: var(--surface-muted, #f1f5f9); }
.emp-opt b { background: #fef3c7; font-weight: 700; }
.emp-opt--none { color: var(--text-muted, #64748b); }
.emp-opt--empty { color: var(--text-muted, #64748b); cursor: default; }
/* R104: an alert with the hidden attribute is never shown (its display rule overrode [hidden]) */
.alert[hidden] { display: none !important; }

/* R106 — «Должны клиенты»: the toggle of the orders list, the debt chip of a row, the dashboard card, the salary link */
.orders-debt { white-space: nowrap; }
.orders-debt--on { background: #fef3c7; border-color: #f59e0b; color: #92400e; font-weight: 600; }
.chip--debt { background: #fee2e2; color: #b91c1c; border: 1px solid #fecaca; margin-left: 4px; white-space: nowrap; }
.debt-card { display: grid; gap: 4px; text-decoration: none; color: inherit; cursor: pointer; border: 1px solid var(--border, #e2e8f0); }
.debt-card:hover { border-color: #f59e0b; box-shadow: 0 2px 10px rgba(245, 158, 11, .15); }
.debt-card__title { font-weight: 600; }
.debt-card__sum { font-size: 1.5rem; }
.debt-card--due .debt-card__sum { color: #b91c1c; }
.salary-part--link { text-decoration: none; color: inherit; cursor: pointer; }
.salary-part--link:hover { border-color: #f59e0b; background: #fffbeb; }
@media (max-width: 767px) {
  /* R106: on a phone «Должны клиенты» takes its own row under the search and the status */
  .orders-toolbar:has(.orders-debt) { flex-wrap: wrap; }
  .orders-toolbar:has(.orders-debt) .orders-toolbar__search { flex: 1 1 55%; min-width: 0; }
  .orders-toolbar .orders-debt { flex: 1 1 100%; order: 3; }
}

/* R107 — «Расчёт в 1С» on «Зарплата» */
.salary-1c__ok { font-weight: 600; color: #15803d; }

/* R108 — the representative's daily debt notice and the debtors on «Зарплата» */
.debt-notice { position: fixed; inset: 0; z-index: 1000; background: rgba(15, 23, 42, .55); display: flex; align-items: center; justify-content: center; padding: 16px; }
.debt-notice__box { background: var(--surface, #fff); border-radius: 16px; max-width: 460px; width: 100%; max-height: 85vh; overflow: auto; padding: 20px; box-shadow: 0 20px 50px rgba(0, 0, 0, .25); }
.debt-notice__title { margin: 0 0 12px; font-size: 1.15rem; color: #b91c1c; }
.debt-notice__list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.debt-notice__list li { display: grid; grid-template-columns: 1fr auto auto; gap: 10px; align-items: baseline; border-bottom: 1px solid var(--border, #e2e8f0); padding-bottom: 6px; }
.debt-notice__total { margin: 12px 0; }
.debt-notice__ok { width: 100%; }
html.debt-notice-open, html.debt-notice-open body { overflow: hidden; }
.salary-row--overdue { border-left: 4px solid #dc2626; padding-left: 8px; }

/* ============================================================
   R132 (operator 20.11) — the phone tab bar (≤599px) and the catalogue as a list of sections, like a shop app
   ============================================================ */
.tabbar { display: none; }
.sf-browse, .sf-crumb { display: none; }

@media (max-width: 599px) {
  :root { --tabbar-h: 60px; --tabbar-full: calc(var(--tabbar-h) + env(safe-area-inset-bottom, 0px)); }
  /* R136 (operator 20.11): the bar is ALWAYS on top — over the sections drawer, dialogs, calendars; those end above
     it. While the on-screen keyboard is open (tabbar.js → html.kb-open) the keyboard covers the bar: it is not lifted
     over the keyboard, and the bars that sit on it go down to the keyboard (--tabbar-full: 0). */
  html.in-app.kb-open { --tabbar-full: 0px; }
  .in-app.kb-open .app-shell--tabbar .tabbar { visibility: hidden; transform: translateY(110%); }
  .in-app .app-shell--tabbar .sidebar { bottom: var(--tabbar-full); max-height: calc(100dvh - var(--tabbar-full)); }
  .in-app .app-shell--tabbar .sidebar-backdrop,
  .in-app .app-shell--tabbar .kd-overlay, .in-app .app-shell--tabbar .debt-notice,
  .in-app .app-shell--tabbar .product-modal, .in-app .app-shell--tabbar .stock-panel,
  .in-app .app-shell--tabbar .restriction-dialog, .in-app .app-shell--tabbar .qo-review { bottom: var(--tabbar-full); }
  .in-app .app-shell--tabbar .tabbar {
    display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 1500;
    transform: translateZ(0); -webkit-transform: translateZ(0); will-change: transform;
    height: var(--tabbar-full); padding-bottom: env(safe-area-inset-bottom, 0px);
    background: var(--surface); border-top: 1px solid var(--border); box-shadow: 0 -4px 16px rgba(16, 27, 58, 0.06);
  }
  .tabbar__item {
    flex: 1 1 0; position: relative; display: flex; align-items: center; justify-content: center;
    height: var(--tabbar-h); padding: 0; border: 0; background: transparent; color: #a3adbf; cursor: pointer;
    -webkit-tap-highlight-color: transparent; text-decoration: none;
  }
  .tabbar__item svg { width: 28px; height: 28px; stroke-width: 2.1; }
  .tabbar__item--active { color: var(--primary); }
  .tabbar__item:active svg { transform: scale(0.92); }
  .tabbar__badge {
    position: absolute; top: 7px; left: calc(50% + 5px); min-width: 19px; height: 19px; padding: 0 5px;
    border-radius: 10px; background: var(--pink); color: #fff; font-size: 11px; font-weight: 800; line-height: 19px;
    text-align: center; box-shadow: 0 0 0 2px var(--surface);
  }
  .tabbar__badge[hidden] { display: none; }

  /* the bar replaces the top «☰» row; the page keeps clear of the bar */
  .in-app .app-shell--tabbar .topbar { display: none; }
  .in-app .app-shell--tabbar .main { padding-bottom: var(--tabbar-full); }
  .in-app .app-shell--tabbar .cart-drawer { width: 100%; max-width: none; bottom: var(--tabbar-full); box-shadow: none; }
  .in-app .app-shell--tabbar .qo-bar { bottom: var(--tabbar-full); padding-bottom: 10px; }
  .in-app .app-shell--tabbar .wh-bar, .in-app .app-shell--tabbar .wh-save-bar, .in-app .app-shell--tabbar .weigh-bar {
    bottom: var(--tabbar-full); padding-bottom: 10px;
  }

  /* the catalogue: a full-width white page, the search on top, sections as rows with «›» */
  .storefront--phone { border: 0; border-radius: 0; box-shadow: none; margin: 0 calc(-1 * var(--space-4)); }
  .storefront--phone .storefront__nav { display: none; }
  .storefront--phone .storefront__header {
    position: sticky; top: 0; z-index: 15; background: var(--surface); padding: 10px var(--space-4);
    border-bottom: 0; box-shadow: 0 1px 0 var(--border);
  }
  .storefront--phone .storefront__header .storefront__search { min-width: 0; flex: 1 1 100%; max-width: none; margin: 0; }
  .storefront--phone .storefront__header .storefront__search .input {
    max-width: none; height: 46px; border-radius: 12px; border-color: transparent; background: #f1f4f9;
    padding-left: 42px; font-size: 1rem;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23687a98' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cline x1='16.5' y1='16.5' x2='21' y2='21'/%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: 13px center; background-size: 20px 20px;
  }
  .storefront--phone #storefront-cart-open { display: none; }
  .storefront--phone .storefront__show-all { font-size: 0.85rem; color: var(--muted); }
  .storefront--browse .storefront__show-all { display: none; }
  .storefront--phone .storefront__main { padding: 0 var(--space-4) var(--space-4); }
  .storefront--phone #storefront-title { display: none; }

  .storefront--phone .sf-crumb:not([hidden]) {
    display: flex; align-items: center; gap: 6px; margin: 0 calc(-1 * var(--space-4)) 10px; padding: 8px var(--space-4) 8px 6px;
    border-bottom: 1px solid var(--border);
  }
  .sf-crumb__back {
    flex: none; width: 40px; height: 40px; display: inline-flex; align-items: center; justify-content: center;
    border: 0; background: transparent; color: var(--heading); border-radius: 50%; cursor: pointer;
  }
  .sf-crumb__back:active { background: var(--primary-soft); }
  .sf-crumb__title { flex: 1 1 auto; min-width: 0; font-weight: 800; font-size: 1.12rem; color: var(--heading);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .sf-crumb__count { flex: none; color: var(--muted); font-size: 0.9rem; font-weight: 600; }

  .storefront--browse .sf-browse { display: block; margin: 0 calc(-1 * var(--space-4)); }
  .storefront--browse #storefront-products, .storefront--browse #storefront-pagination,
  .storefront--browse #storefront-hidden-note { display: none !important; }
  .sf-row {
    display: flex; align-items: center; gap: 14px; width: 100%; min-height: 68px; padding: 10px var(--space-4);
    border: 0; border-bottom: 1px solid var(--border); background: var(--surface); color: var(--heading);
    text-align: left; font: inherit; cursor: pointer; -webkit-tap-highlight-color: transparent;
  }
  .sf-row:active { background: #f5f7fb; }
  .sf-row__mark {
    flex: none; width: 52px; height: 52px; border-radius: 50%; display: inline-flex; align-items: center;
    justify-content: center; font-weight: 800; font-size: 1.15rem;
  }
  .sf-row__mark--0 { background: #fdeef1; color: #d9536f; }
  .sf-row__mark--1 { background: #eaf2ff; color: #2563eb; }
  .sf-row__mark--2 { background: #e7f7f0; color: #16935f; }
  .sf-row__mark--3 { background: #fdf3e3; color: #c27712; }
  .sf-row__mark--4 { background: #f1ecff; color: #7048d8; }
  .sf-row__mark--5 { background: #e6f6fa; color: #0f8aa6; }
  .sf-row__mark--6 { background: #f4ede6; color: #8a5a35; }
  .sf-row__pic { flex: none; width: 52px; height: 52px; display: inline-flex; align-items: center; justify-content: center; }
  .sf-row__pic img { max-width: 100%; max-height: 100%; object-fit: contain; border-radius: 8px; }
  .sf-row__name { flex: 1 1 auto; min-width: 0; font-size: 1.02rem; font-weight: 500; line-height: 1.3; overflow-wrap: anywhere; }
  .sf-row__count { flex: none; color: var(--muted); font-size: 0.85rem; }
  .sf-row__chev { flex: none; color: #b3bccb; }
}

.weigh-mode .tabbar { display: none !important; }
.weigh-mode .app-shell--tabbar .main { padding-bottom: 0; }

@media (max-width: 599px) {
  /* R132: the catalogue page on a phone — no page title (the search is the top row), cards as list rows */
  .in-app .app-shell--tabbar .sf-page-header { display: none; }
  .in-app .app-shell--tabbar .content--compact { padding-top: 0; }
  .storefront--phone .storefront__grid { grid-template-columns: minmax(0, 1fr) !important; gap: 0; }
  .storefront--phone .product-card {
    display: grid; grid-template-columns: 104px minmax(0, 1fr); column-gap: 14px; row-gap: 6px; align-items: start;
    border: 0; border-bottom: 1px solid var(--border); border-radius: 0; box-shadow: none;
    margin: 0 calc(-1 * var(--space-4)); padding: 14px var(--space-4); max-width: none;
  }
  .storefront--phone .product-card > * { grid-column: 2; min-width: 0; }
  .storefront--phone .product-card > .product-card__media {
    grid-column: 1; grid-row: 1 / span 4; width: 104px; height: 104px; aspect-ratio: auto; margin: 0; align-self: start;
  }
  .storefront--phone .product-card__media img { width: 100%; height: 100%; object-fit: contain; }
  .storefront--phone .product-card__name { font-size: 0.98rem; font-weight: 600; -webkit-line-clamp: 3; }
  .storefront--phone .storefront__price { font-size: 1.2rem; font-weight: 800; }
  .storefront--phone .product-card > .product-card__chars,
  .storefront--phone .product-card > .product-card__stock,
  .storefront--phone .product-card > .product-card__shipping,
  .storefront--phone .product-card > .product-card__absent,
  .storefront--phone .product-card > .product-card__desc,
  .storefront--phone .product-card > .product-card__spacer,
  .storefront--phone .product-card > .product-card__actions { grid-column: 1 / -1; }
  .storefront--phone .product-card__spacer { display: none; }
  /* the tall (portrait) photo cards keep their own row, only smaller */
  .storefront--phone .product-card--portrait > .product-card__row { grid-column: 1 / -1; }
  .storefront--phone .product-card--portrait .product-card__media { width: 96px; height: 190px; }
  .storefront--phone .product-card__actions { grid-template-columns: 96px minmax(0, 1fr); }
  .storefront--phone .product-card__actions .btn { min-height: 44px; font-size: 1rem; border-radius: 12px; }
}

/* R132: «Нижняя панель (телефон)» in the user card */
.tabbar-editor__slots { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; margin-top: 12px; }

/* R132: «Торговые представители» — the salary terms of every representative (the superadmin) */
.sr-list { display: flex; flex-direction: column; }
.sr-row { display: grid; grid-template-columns: minmax(0, 1fr) 180px 120px auto; gap: 14px; align-items: end;
  padding: 14px 0; border-bottom: 1px solid var(--border); }
.sr-row:last-child { border-bottom: 0; }
.sr-row__who { align-self: center; min-width: 0; }
.sr-row__links { margin-top: 4px; }
.sr-warn { color: var(--warning); font-weight: 600; }
.sr-row__save { display: flex; align-items: center; gap: 10px; }
.sr-row__state--ok { color: var(--success); font-weight: 600; }
.sr-row__state--err { color: var(--danger); font-weight: 600; }
.sr-row__state--dirty { color: var(--warning); }
@media (max-width: 760px) {
  .sr-row { grid-template-columns: 1fr 1fr; }
  .sr-row__who, .sr-row__save { grid-column: 1 / -1; }
}
