/* ============================================================
   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);
}

/* ============================================================
   Auth layout
   ============================================================ */

.auth-body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: var(--space-6);
}

.auth-card {
  width: 100%;
  max-width: 420px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
  padding: var(--space-8);
}

.auth-brand {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-bottom: var(--space-6);
}

.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.5rem;
  font-weight: 800;
}

.auth-subtitle {
  color: var(--muted);
  margin-bottom: var(--space-6);
}

.auth-footer {
  margin-top: var(--space-6);
  text-align: center;
  font-size: 0.8rem;
  color: var(--muted);
}

/* ============================================================
   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;
}

.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);
}

/* 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: 15px;
  height: 15px;
  flex: 0 0 15px;
  margin: 0;
  accent-color: var(--primary);
  cursor: pointer;
}

/* Inherited grant: checked but visually distinct from an explicit grant */
.group-check--inherited {
  accent-color: #9db9ee;
  opacity: 0.75;
}

.group-check--inherited:hover {
  opacity: 1;
}

.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);
}

/* 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;
}

.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. */
.storefront__grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(285px, 330px));
  gap: 14px;
  justify-content: start;
}

@media (min-width: 1700px) {
  .storefront__grid {
    grid-template-columns: repeat(4, 330px);
    justify-content: start;
  }
}

@media (min-width: 1150px) and (max-width: 1699px) {
  .storefront__grid {
    grid-template-columns: repeat(3, minmax(0, 330px));
    justify-content: start;
  }
}

.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;
}

.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__grid {
    grid-template-columns: 1fr;
  }

  .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);
  }

  .sidebar--open {
    display: flex;
  }

  .menu-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  .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%;
  }
}
