@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@300;400;500;600&display=swap');

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

:root {
  --bg: #F8F7F5;
  --surface: #FFFFFF;
  --text: #141414;
  --text-muted: #6B6B6B;
  --border: #E5E4E1;
  --accent: #2563EB;
  --accent-hover: #1D4ED8;
  --radius: 12px;
  --radius-sm: 6px;
  --shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
}

body {
  font-family: 'DM Sans', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  min-height: 100vh;
}

/* ── Header ── */
.header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(248, 247, 245, 0.92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.wordmark {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.3px;
  color: var(--text);
}
.header-right {
  display: flex;
  align-items: center;
  gap: 16px;
}
.updated-at {
  font-size: 13px;
  color: var(--text-muted);
}
.next-sync {
  font-size: 13px;
  color: var(--text-muted);
  opacity: 0.7;
}
.btn-primary {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  padding: 7px 14px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background 150ms;
}
.btn-primary:hover { background: var(--accent-hover); }
.btn-primary:disabled { opacity: 0.6; cursor: default; }

/* ── Main layout ── */
.main { padding: 24px; max-width: 1400px; margin: 0 auto; }
.section-title {
  font-size: 12px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 12px;
}

/* ── Supplier cards ──
   Auto-fill grid: each card has a guaranteed ~290px so internal labels,
   URLs and badges never spill out. The grid lays out 4 columns when the
   viewport allows, otherwise reflows to 3/2/1 — preserving the original
   "4 across on desktop" spec while preventing the right-side overflow
   we got with a hard `repeat(4, 1fr)`. */
.suppliers-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
  gap: 10px;
  margin-bottom: 20px;
}

.supplier-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  box-shadow: var(--shadow);
  transition: box-shadow 150ms;
  position: relative;
  min-width: 0;          /* let card shrink within its grid track */
  display: flex;
  flex-direction: column;
  /* Prevent any inner content (chevron, long button labels, etc.) from
     escaping the rounded card on narrow viewports. `overflow-x: clip`
     clips horizontally without breaking vertical scroll inside modals. */
  overflow-x: clip;
}

/* ── Skiboard markup-pct block (v73) ── */
.skiboard-markup-block {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px dashed var(--border);
}
.skb-markup-title {
  font-weight: 600;
  font-size: 12px;
  margin-bottom: 6px;
}
.skb-markup-row {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;     /* button drops to a new line on narrow screens */
}
.skb-markup-input-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
  flex: 0 0 auto;
}
.skb-markup-input-wrap .pricing-input {
  width: 96px;
  padding-right: 22px; /* room for the % suffix */
  text-align: right;
}
.skb-markup-suffix {
  position: absolute;
  right: 8px;
  font-size: 12px;
  color: var(--text-muted);
  pointer-events: none;
}
.js-skb-markup-pct-save-btn { flex: 0 1 auto; }
.skb-markup-helper { margin-top: 6px; font-size: 11px; }
.supplier-card:hover { box-shadow: 0 4px 12px rgba(0,0,0,0.08); }
.supplier-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.card-top {
  gap: 8px;
  margin-bottom: 6px;
  cursor: pointer;
  user-select: none;
  border-radius: 4px;
}
.card-top:focus { outline: none; }
.card-top:focus-visible {
  outline: 2px solid var(--accent, #2563EB);
  outline-offset: 2px;
}
.card-top-right { display: inline-flex; align-items: center; gap: 6px; flex-shrink: 0; }

/* Compact always-visible summary: status badge + format + last-sync date */
.card-summary {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 4px;
}
.card-meta {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  font-size: 12px;
  color: var(--text-muted);
}
.card-meta span + span::before { content: '·'; padding-right: 4px; color: var(--text-muted); opacity: 0.6; }

/* ── Status dot + mobile-date span (rendered desktop-side too,
       hidden on desktop, used on mobile compact card row) ── */
.card-status-dot { display: none; }
.card-mobile-date { display: none; }

/* Collapsible body — hidden by default on every viewport.
   Toggled by .supplier-card.expanded (set on click of .card-top). */
.card-collapse {
  display: none;
  margin-top: 4px;
}
.supplier-card.expanded > .card-collapse { display: block; }

/* ── Supplier visibility toggle ── */
.card-toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}
.card-toggle-label {
  font-size: 12px;
  color: var(--text-muted);
}
.toggle-switch {
  position: relative;
  display: inline-flex;
  align-items: center;
  cursor: pointer;
  flex-shrink: 0;
}
.toggle-switch input { display: none; }
.toggle-track {
  width: 32px;
  height: 18px;
  background: #D1D5DB;
  border-radius: 100px;
  transition: background 150ms;
  position: relative;
}
.toggle-thumb {
  position: absolute;
  top: 2px; left: 2px;
  width: 14px; height: 14px;
  background: #fff;
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
  transition: transform 150ms;
}
.toggle-switch input:checked + .toggle-track { background: #2563EB; }
.toggle-switch input:checked + .toggle-track .toggle-thumb { transform: translateX(14px); }

.card-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 12px;
}
.supplier-name {
  font-weight: 600;
  font-size: 14px;
  line-height: 1.3;
}
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 9px;
  border-radius: 100px;
  font-size: 11px;
  font-weight: 500;
  white-space: nowrap;
}
.badge-green  { background: #DCFCE7; color: #15803D; }
.badge-red    { background: #FEE2E2; color: #B91C1C; }
.badge-amber  { background: #FEF3C7; color: #92400E; }
.badge-gray   { background: #F3F4F6; color: #6B7280; }
.badge-blue   { background: #DBEAFE; color: #1D4ED8; }

/* Session 6 / Task A — auto-drafted indicator next to product name.
   Visual: same gray family as .badge-gray but smaller / pill-shape /
   used as an inline marker rather than a column badge.            */
.badge-auto-drafted {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 7px;
  background: #F3F4F6;
  color: #6B7280;
  font-size: 11px;
  font-weight: 500;
  font-family: 'DM Sans', system-ui, sans-serif;
  border-radius: 999px;
  text-decoration: none;
  vertical-align: middle;
  line-height: 1.4;
  letter-spacing: 0.02em;
}
.badge-auto-drafted:hover { background: #E5E7EB; color: #374151; }

/* (.card-meta defined above with the compact card-summary block) */

.card-url {
  font-size: 12px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: nowrap;
  margin-top: 6px;
  min-width: 0;
}
.url-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1 1 auto;
  min-width: 0;
}
.link-edit {
  color: var(--accent);
  cursor: pointer;
  font-size: 11px;
  font-weight: 500;
  white-space: nowrap;
  text-decoration: none;
  transition: opacity 150ms;
}
.link-edit:hover { opacity: 0.75; }

.url-edit-form {
  display: none;
  flex-direction: column;
  gap: 6px;
  margin-top: 8px;
}
.url-edit-form.active { display: flex; }
.url-input {
  font-family: inherit;
  font-size: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 5px 8px;
  outline: none;
  transition: border-color 150ms;
  width: 100%;
}
.url-input:focus { border-color: var(--accent); }
.url-edit-actions { display: flex; gap: 6px; }
.btn-sm {
  font-family: inherit;
  font-size: 11px;
  font-weight: 500;
  border-radius: 5px;
  padding: 4px 10px;
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  transition: all 150ms;
}
.btn-sm.btn-save {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.btn-sm:hover { opacity: 0.8; }

/* ── Pricing section ─────────────────────────────────── */
.card-pricing {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}
.pricing-header {
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}
.pricing-field {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}
.pricing-label {
  font-size: 11.5px;
  font-weight: 500;
  color: var(--text-muted);
  flex: 0 0 84px;
}
.pricing-method,
.pricing-input {
  flex: 1 1 auto;
  font-family: inherit;
  font-size: 13px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  outline: none;
  transition: border-color 150ms, box-shadow 150ms;
  min-width: 0;
}
.pricing-method:hover,
.pricing-input:hover { border-color: #c9c8c4; }
.pricing-method:focus,
.pricing-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}
.pricing-helper {
  font-size: 11px;
  color: var(--text-muted);
  opacity: 0.85;
  line-height: 1.35;
  padding-left: 90px;
}

/* Conditional rows: smooth fade + height. JS toggles `.is-visible`.
   The 200px cap is fine for the small "Наценка %" row but is far too
   tight for the price-sources block, which can hold N source cards plus
   an inline editor form. The sources block opts out below. */
.pricing-conditional {
  max-height: 0;
  opacity: 0;
  overflow: hidden;
  transition: max-height 200ms ease, opacity 200ms ease;
}
.pricing-conditional.is-visible {
  max-height: 200px;
  opacity: 1;
}
/* Sources block: let it grow with content, no horizontal clip. */
.pricing-sources-block.pricing-conditional.is-visible {
  max-height: none;
  overflow: visible;
}
/* Inline (button) variants need to be hidden via display, not max-height. */
button.pricing-conditional,
.pricing-actions .pricing-conditional { display: none; }
button.pricing-conditional.is-visible,
.pricing-actions .pricing-conditional.is-visible { display: inline-flex; }

.pricing-status {
  font-size: 11px;
  color: var(--text-muted);
  padding-left: 90px;
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 16px;
}
.pricing-status.is-empty { opacity: 0.7; font-style: italic; }
.pricing-status.is-error { color: #B91C1C; font-style: normal; opacity: 1; }
.pricing-status .status-icon {
  width: 12px; height: 12px;
  flex-shrink: 0;
  color: #15803D;
}

.pricing-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 24px;
}
.pricing-save-btn[disabled] {
  opacity: 0;
  pointer-events: none;
  transform: translateX(-4px);
  transition: opacity 150ms, transform 150ms;
}
.pricing-save-btn:not([disabled]) {
  opacity: 1;
  transform: none;
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.pricing-saved-indicator {
  display: none;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  color: #15803D;
  font-weight: 500;
}
.pricing-saved-indicator.is-visible {
  display: inline-flex;
  animation: pricing-saved-fade 1500ms ease forwards;
}
@keyframes pricing-saved-fade {
  0%   { opacity: 0; transform: translateX(-2px); }
  20%  { opacity: 1; transform: none; }
  80%  { opacity: 1; }
  100% { opacity: 0; }
}

/* Mobile — stack labels above controls */
@media (max-width: 600px) {
  .pricing-field { flex-direction: column; align-items: stretch; gap: 4px; }
  .pricing-label { flex: 0 0 auto; }
  .pricing-helper,
  .pricing-status { padding-left: 0; }
}

/* ── Multiple price-list sources ── */
.pricing-sources-block {
  margin-top: 4px;
}
.sources-header-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
}
.sources-header-text {
  font-size: 12px;
  font-weight: 500;
  color: var(--text);
  letter-spacing: 0.02em;
  text-transform: uppercase;
}
.sources-summary {
  font-size: 11px;
  color: var(--text-muted, #6b6a66);
}
.sources-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.sources-loading,
.sources-empty {
  font-size: 12px;
  color: var(--text-muted, #6b6a66);
  font-style: italic;
  padding: 6px 0;
}
.sources-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 8px;
  padding-top: 6px;
  border-top: 0.5px solid var(--border, #e5e4e0);
}

/* Source card — tight density so 6+ items fit without dominating the card */
.source-card {
  border: 0.5px solid var(--border, #e5e4e0);
  border-radius: var(--radius-sm, 4px);
  padding: 6px 8px;
  background: var(--surface, #fff);
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}
.source-card.is-error {
  border-color: #FCA5A5;
  background: #FEF2F2;
}
.src-row {
  display: flex;
  align-items: baseline;
  gap: 6px;
  font-size: 12px;
  line-height: 1.35;
  min-width: 0;
}
.src-top {
  justify-content: space-between;
  margin-bottom: 1px;
}
.src-name {
  font-weight: 600;
  font-size: 12.5px;
  color: var(--text);
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.src-priority {
  font-size: 10.5px;
  color: var(--text-muted, #6b6a66);
  background: var(--surface-muted, #f5f4f0);
  border-radius: 3px;
  padding: 1px 5px;
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}
.src-meta {
  font-size: 11.5px;
  color: var(--text-muted, #6b6a66);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  display: block;
}
.src-stat {
  font-size: 11px;
  color: var(--text-muted, #6b6a66);
  font-style: italic;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  display: block;
}
.src-error {
  font-size: 11px;
  color: #B91C1C;
  margin-top: 2px;
  word-break: break-word;
}
.src-actions {
  display: flex;
  gap: 12px;
  margin-top: 4px;
  padding-top: 4px;
  border-top: 0.5px dashed var(--border, #e5e4e0);
}
.src-actions .btn-link {
  font-size: 11.5px;
  padding: 0;
}

/* Status badges */
.src-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  font-size: 10px;
  font-weight: 700;
  margin-right: 4px;
  vertical-align: text-top;
}
.src-badge-ok  { background: #DCFCE7; color: #15803D; }
.src-badge-err { background: #FEE2E2; color: #B91C1C; }
.src-badge-na  { background: var(--surface-muted, #f5f4f0); color: var(--text-muted, #6b6a66); }

/* Inline editor form */
.source-edit-form {
  border: 0.5px solid var(--border, #e5e4e0);
  border-radius: var(--radius-sm, 4px);
  padding: 10px 12px;
  background: var(--surface-muted, #f9f9f7);
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 4px;
}
.sef-row { display: flex; flex-direction: column; gap: 3px; }
.sef-grid { flex-direction: row; gap: 12px; }
.sef-col  { flex: 1; display: flex; flex-direction: column; gap: 3px; }
.sef-label {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-muted, #6b6a66);
  text-transform: uppercase;
  letter-spacing: 0.02em;
}
.sef-input {
  font-family: inherit;
  font-size: 13px;
  border: 0.5px solid var(--border, #e5e4e0);
  border-radius: var(--radius-sm, 4px);
  padding: 6px 8px;
  background: var(--surface, #fff);
  outline: none;
}
.sef-input:focus { border-color: var(--text, #2a2926); }
.sef-hint {
  margin: 2px 0 0;
  font-size: 10.5px;
  color: var(--text-muted, #6b6a66);
  font-style: italic;
}
.sef-actions { display: flex; gap: 12px; align-items: center; }

@media (max-width: 600px) {
  .sef-grid { flex-direction: column; gap: 8px; }
}

/* ── Filters bar ── */
.filters-section { margin-bottom: 16px; }
.search-wrap {
  position: relative;
  margin-bottom: 10px;
}
/* Битрикс tab has its own structured tables (exports/imports/snapshots/
   drafts) — the global product-search input doesn't apply there. */
body.view-bitrix .search-wrap { display: none; }
.search-icon {
  position: absolute;
  left: 11px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
}
.search-input {
  width: 100%;
  font-family: inherit;
  font-size: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 9px 12px 9px 36px;
  background: var(--surface);
  outline: none;
  transition: border-color 150ms;
}
.search-input:focus { border-color: var(--accent); }

.autocomplete-list {
  position: absolute;
  top: calc(100% + 4px);
  left: 0; right: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: 0 8px 24px rgba(0,0,0,0.1);
  z-index: 50;
  overflow: hidden;
  display: none;
}
.autocomplete-list.open { display: block; }
.autocomplete-item {
  padding: 9px 12px;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  transition: background 100ms;
}
.autocomplete-item:last-child { border-bottom: none; }
.autocomplete-item:hover { background: var(--bg); }
.autocomplete-item .sub { font-size: 11px; color: var(--text-muted); margin-top: 1px; }

.filters-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.filter-select {
  font-family: inherit;
  font-size: 13px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 7px 10px;
  background: var(--surface);
  color: var(--text);
  outline: none;
  cursor: pointer;
  transition: border-color 150ms;
  flex: 1;
  min-width: 130px;
}
.filter-select:focus { border-color: var(--accent); }

/* ── Table ── */
.table-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}
.table-count { font-size: 13px; color: var(--text-muted); }

.table-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: auto;
  max-height: calc(100vh - 320px);
}
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
thead { position: sticky; top: 0; z-index: 10; }
thead th {
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  padding: 10px 12px;
  text-align: left;
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
  transition: color 150ms;
}
thead th:hover { color: var(--text); }
thead th.th-right { text-align: right; }
.sort-arrow { margin-left: 4px; opacity: 0.4; font-style: normal; }
thead th.active .sort-arrow { opacity: 1; color: var(--accent); }

tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background 100ms;
}
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: #FAFAF9; }
td {
  padding: 10px 12px;
  vertical-align: middle;
  max-width: 280px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
td.td-right { text-align: right; font-variant-numeric: tabular-nums; }
td.td-sku { font-family: monospace; font-size: 12px; color: var(--text-muted); width: 120px; }
td a { color: var(--text); text-decoration: none; border-bottom: 1px solid transparent; transition: border-color 150ms; }
td a:hover { border-bottom-color: var(--text-muted); }

/* ── Column resize handle ── */
thead th { position: relative; }
.col-resize-handle {
  position: absolute;
  right: 0; top: 0;
  width: 4px; height: 100%;
  cursor: col-resize;
  background: transparent;
  z-index: 1;
}
.col-resize-handle:hover { background: var(--border); }

/* ── Toast ── */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(16px);
  background: #141414;
  color: #fff;
  padding: 10px 20px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  opacity: 0;
  transition: opacity 200ms, transform 200ms;
  pointer-events: none;
  z-index: 999;
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ── Empty state ── */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-muted);
}
.empty-state p { margin-top: 8px; font-size: 13px; }

/* ── Sync Progress Bar ── */
.sync-progress-wrap {
  display: none;
  padding: 0 32px 0;
  margin-bottom: 4px;
}
.sync-progress-wrap.visible {
  display: block;
}
.sync-progress-wrap.fading {
  opacity: 0;
  transition: opacity 400ms ease;
}
.sync-progress-track {
  width: 100%;
  height: 3px;
  background: var(--color-border-tertiary, #e5e7eb);
  border-radius: 99px;
  overflow: hidden;
  margin-bottom: 6px;
}
.sync-progress-fill {
  height: 100%;
  width: 0%;
  background: #2563EB;
  border-radius: 99px;
  transition: width 400ms ease;
}
.sync-progress-label {
  display: block;
  font-size: 12px;
  color: var(--text-muted, #6b7280);
  letter-spacing: 0.01em;
}

/* ── Card top right (badge + chevron) ── */
.card-top-right {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}
.card-chevron {
  display: block;        /* always visible — collapse works on every viewport */
  color: var(--text-muted);
  transition: transform 220ms ease;
  flex-shrink: 0;
}
.supplier-card.expanded .card-chevron {
  transform: rotate(180deg);
}

/* ── Mobile product cards ── */
.product-cards { display: none; }
#cards-sentinel { height: 1px; }

.pcard {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 14px 0;
}
.pcard:first-child { border-top: 1px solid var(--border); border-radius: var(--radius) var(--radius) 0 0; padding-top: 14px; }
.pcard:last-child  { border-bottom: none; border-radius: 0 0 var(--radius) var(--radius); }
.pcard-name {
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  margin-bottom: 3px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ─── Name split (тип-префикс ↓ + бренд+модель ⬆) ───
 * .sp-name-main — крупная главная строка (стиль задаётся wrapper'ом
 * .pcard-name / .mrow-name / .cnew-name / .hidden-name, либо используется
 * как самостоятельный block в `<td>` desktop-таблиц).
 * .sp-name-type — мелкая серая подпись типа товара ПОД главной строкой.
 */
.sp-name-main {
  font-weight: 500;
  color: var(--text);
}
.sp-name-main a { color: var(--text); text-decoration: none; border-bottom: 1px solid transparent; }
.sp-name-main a:hover { border-bottom-color: var(--text-muted); }
.sp-name-type {
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 400;
  margin-top: 2px;
  line-height: 1.3;
  white-space: normal;
}
.pcard-name a { color: var(--text); text-decoration: none; border-bottom: 1px solid transparent; }
.pcard-name a:hover { border-bottom-color: var(--text-muted); }
.pcard-sub {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 4px;
}
.pcard-sku {
  font-family: monospace;
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 4px;
}
.pcard-row {
  font-size: 13px;
  color: var(--text);
  margin-bottom: 6px;
}
.pcard-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}
.product-cards-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 0 16px;
  overflow: hidden;
}

/* ── Tablet (≤768px) ── */
@media (max-width: 768px) {
  .main { padding: 16px; }

  /* Header: stack vertically */
  .header {
    height: auto;
    flex-direction: column;
    align-items: stretch;
    padding: 10px 16px;
    gap: 6px;
  }
  .header-right {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
  }
  .updated-at, .next-sync { font-size: 11px; }
  .btn-primary {
    flex: 1 0 100%;
    text-align: center;
    padding: 10px 14px;
  }

  /* Suppliers: 2 columns */
  .suppliers-grid { grid-template-columns: repeat(2, 1fr); }

  /* Table: hide Контент and В XML */
  .col-content, .col-xml { display: none; }

  /* Progress bar */
  .sync-progress-wrap { padding: 0 16px; }
}

/* ── Mobile (≤480px) ── */
@media (max-width: 480px) {
  /* Suppliers: 1 column, collapsible */
  .suppliers-grid { grid-template-columns: 1fr; }

  /* ── Compact one-row supplier card (v51) ──
     Layout: dot — name — flex spacer — date — toggle — chevron.
     Implemented via CSS grid on .supplier-card with intermediate
     boxes (.card-top / .card-top-right / .card-toggle-row) unwrapped
     via display:contents so their children become direct grid items.
     The toggle stays a single DOM input — no JS sync needed. */
  .supplier-card {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto auto auto;
    grid-template-areas:
      "dot name date toggle chevron"
      "role role role role role"
      "summary summary summary summary summary"
      "coll coll coll coll coll";
    align-items: center;
    column-gap: 8px;
    row-gap: 0;
    padding: 10px 12px;
    min-height: 44px;
  }
  .supplier-card > .card-top,
  .supplier-card > .card-top > .card-top-right,
  .supplier-card > .card-toggle-row { display: contents; }

  /* Compact-row items */
  .card-status-dot {
    grid-area: dot;
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
  }
  .card-status-success { background: #22C55E; }
  .card-status-error   { background: #EF4444; }
  .card-status-none    { background: #9CA3AF; }
  .supplier-name      { grid-area: name; min-width: 0; }
  .card-mobile-date   {
    grid-area: date;
    display: inline;
    font-size: 12px;
    color: var(--text-muted);
    white-space: nowrap;
  }
  .card-toggle-row > .toggle-switch { grid-area: toggle; }
  .card-chevron       { grid-area: chevron; }

  /* Items hidden when collapsed — shown on .expanded */
  .card-role-badge    { grid-area: role; justify-self: start; display: none; }
  .card-summary       { grid-area: summary; display: none; }
  .card-toggle-label  { display: none; }

  /* Reset desktop chrome on the now-unwrapped boxes */
  .card-top { margin: 0; min-height: 0; }
  .card-toggle-row { margin: 0; padding: 0; border: none; }

  /* Expanded state — reveal role badge, summary, and the existing
     .card-collapse details block (URL / categories / pricing) */
  .supplier-card.expanded { row-gap: 6px; }
  .supplier-card.expanded .card-role-badge { display: inline-flex; }
  .supplier-card.expanded .card-summary    { display: flex; flex-wrap: wrap; }
  .supplier-card.expanded > .card-collapse { padding-top: 4px; }

  /* Filters: 2×2 grid */
  .filters-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }
  .filter-select {
    min-width: 0;
    font-size: 14px;
    min-height: 44px;
  }
  .search-input {
    font-size: 14px;
    min-height: 44px;
    padding-top: 11px;
    padding-bottom: 11px;
  }

  /* Touch targets */
  .btn-sm { min-height: 36px; }
  .toggle-track { width: 38px; height: 22px; }
  .toggle-thumb { width: 18px; height: 18px; }
  .toggle-switch input:checked + .toggle-track .toggle-thumb { transform: translateX(16px); }

  /* Switch to card view in supplier mode */
  .table-wrap { display: none; }
  .product-cards { display: block; }

  /* Catalog mode: always use the table (no card renderer for catalog) */
  body.view-catalog .table-wrap {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  body.view-catalog .product-cards { display: none; }
}

/* ── View Switcher ── */
.view-switcher-wrap {
  display: flex;
  justify-content: center;
  padding: 12px 24px 0;
  background: var(--bg);
}
.view-switcher {
  display: inline-flex;
  background: var(--border);
  border-radius: 10px;
  padding: 3px;
  gap: 2px;
}
.view-tab {
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  background: transparent;
  border: none;
  border-radius: 8px;
  padding: 6px 18px;
  cursor: pointer;
  transition: background 150ms, color 150ms, box-shadow 150ms;
  white-space: nowrap;
}
.view-tab:hover { color: var(--text); }
.view-tab.active {
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 1px 3px rgba(0,0,0,0.10), 0 1px 2px rgba(0,0,0,0.06);
}

@media (max-width: 768px) {
  .view-switcher-wrap { padding: 10px 16px 0; }
  .view-tab { font-size: 12px; padding: 6px 12px; }
}

/* ── Catalog Settings Bar ── */
.catalog-settings-bar {
  margin: 0 0 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 9px 14px;
  font-size: 13px;
}
.csb-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: nowrap;
  min-width: 0;
}
/* Left group: label + url + edit link — shrinks and truncates */
.csb-left {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  flex: 1;
}
/* Right group: date + button — never shrinks */
.csb-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}
.csb-label {
  color: var(--text-muted);
  white-space: nowrap;
  flex-shrink: 0;
}
.csb-url {
  color: var(--text);
  font-family: ui-monospace, monospace;
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}
.csb-meta { color: var(--text-muted); white-space: nowrap; font-size: 12px; }
.csb-input { flex: 1; min-width: 200px; }
.btn-link {
  background: none;
  border: none;
  color: var(--accent, #4f8ef7);
  font-size: 12px;
  font-family: inherit;
  cursor: pointer;
  padding: 0;
  white-space: nowrap;
  flex-shrink: 0;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.btn-link:hover { opacity: 0.75; }
@media (max-width: 768px) {
  .catalog-settings-bar { margin: 10px 16px 0; padding: 10px 14px; }

  /* Allow rows to wrap on mobile so nothing overflows */
  .csb-row { flex-wrap: wrap; gap: 6px; }

  /* On mobile the URL row: label takes full row, url + button below it */
  .csb-left {
    flex-wrap: wrap;
    gap: 4px 8px;
  }
  .csb-label { flex: 0 0 100%; font-size: 11px; margin-bottom: 0; }
  .csb-url   { max-width: 100%; }

  /* Right group stacks below on narrow screens */
  .csb-right { gap: 6px; flex-wrap: wrap; }
  .csb-meta  { font-size: 11px; }
}

/* ═══════════════════════════════════════════════════════
   Matching Tab
   ═══════════════════════════════════════════════════════ */

/* ── Stats bar ── */
.matching-stats-bar {
  display: flex;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.mstat-card {
  flex: 1 1 200px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 18px;
  min-width: 0;
}
.mstat-name {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  margin-bottom: 6px;
}
.mstat-numbers {
  font-size: 22px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.2;
  margin-bottom: 8px;
}
.mstat-numbers .mstat-matched   { color: var(--accent); }
.mstat-numbers .mstat-confirmed { color: #6366f1; }
.mstat-numbers .mstat-unmatched { color: var(--text); }
.mstat-numbers .mstat-sep,
.mstat-numbers .mstat-total { color: var(--text-muted); font-size: 16px; }
.mstat-numbers .mstat-label { font-size: 13px; font-weight: 400; color: var(--text-muted); }
.mstat-bar-track {
  height: 4px;
  background: var(--border);
  border-radius: 99px;
  overflow: hidden;
}
.mstat-bar-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 99px;
  transition: width 400ms ease;
}
.mstat-loading { color: var(--text-muted); font-size: 13px; padding: 4px 0; }

/* ── Filters row ── */
.matching-filters-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}
.match-toggle-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  user-select: none;
  font-size: 13px;
  color: var(--text);
}
.match-toggle-wrap input[type="checkbox"] {
  width: 15px;
  height: 15px;
  accent-color: var(--accent);
  cursor: pointer;
}

/* ── Matching table ── */
.matching-table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.matching-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.matching-table thead th {
  background: var(--bg);
  color: var(--text-muted);
  font-weight: 500;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  text-align: left;
}
.matching-table thead th.th-right { text-align: right; }
.matching-table thead th.th-match  { min-width: 280px; }
.matching-table tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background 120ms;
}
.matching-table tbody tr:hover { background: rgba(0,0,0,0.018); }
.matching-table tbody td {
  padding: 10px 12px;
  vertical-align: top;
}
.matching-table tbody td.td-right { text-align: right; }
.matching-table .mrow-name {
  font-weight: 500;
  color: var(--text);
  line-height: 1.35;
}
.matching-table .mrow-sku {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
  font-family: ui-monospace, monospace;
}
.matching-table .mrow-meta {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 4px;
}

/* Two-column layout for matching table */
.matching-table .th-supplier-product,
.matching-table .td-supplier-product { width: 38%; }
.matching-table .th-suggestions,
.matching-table .td-suggestions      { width: 62%; }

/* ── Suggestions panel (right column) ── */
.suggest-wrap {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.btn-load-suggestions {
  font-family: inherit;
  font-size: 12px;
  font-weight: 500;
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  cursor: pointer;
  align-self: flex-start;
  transition: background 120ms, border-color 120ms;
}
.btn-load-suggestions:hover {
  background: var(--bg);
  border-color: var(--text-muted);
}
.suggest-loading,
.suggest-error,
.suggest-empty {
  font-size: 12px;
  color: var(--text-muted);
  padding: 4px 0;
}
.suggest-error { color: #ef4444; }

.suggest-panel {
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px;
}
.suggest-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.suggest-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 100ms;
  user-select: none;
}
.suggest-item:hover { background: var(--surface); }
.suggest-item.is-selected {
  background: rgba(59, 130, 246, 0.10);
  outline: 1px solid var(--accent);
}
.suggest-item input[type="radio"] {
  margin: 3px 0 0 0;
  accent-color: var(--accent);
  flex-shrink: 0;
}
.suggest-item-body { flex: 1; min-width: 0; }
.suggest-item-row1 {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.suggest-item-name {
  font-size: 13px;
  color: var(--text);
  font-weight: 500;
  line-height: 1.3;
}
.suggest-item-sub {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
  font-family: ui-monospace, monospace;
}
.suggest-score {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 10px;
  flex-shrink: 0;
}
.score-high { background: rgba(34, 197, 94, 0.15); color: #15803d; }
.score-mid  { background: rgba(245, 158, 11, 0.15); color: #b45309; }
.score-low  { background: rgba(120, 120, 120, 0.15); color: var(--text-muted); }

.suggest-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.btn-confirm-link {
  font-family: inherit;
  font-size: 12px;
  font-weight: 500;
  padding: 5px 12px;
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: #fff;
  border: none;
  cursor: pointer;
  white-space: nowrap;
  transition: background 150ms, opacity 150ms;
}
.btn-confirm-link:hover:not(:disabled) { background: var(--accent-hover); }
.btn-confirm-link:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

/* ── "Создать новый товар" inline button ── */
.btn-create-new {
  font-family: inherit;
  font-size: 11px;
  font-weight: 500;
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-muted);
  border: 1px dashed var(--border);
  cursor: pointer;
  white-space: nowrap;
  align-self: flex-start;
  transition: background 120ms, color 120ms, border-color 120ms;
}
.btn-create-new:hover {
  background: var(--bg);
  color: var(--text);
  border-color: var(--text-muted);
  border-style: solid;
}

/* ── Already linked state ── */
.match-linked-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
}
.match-linked-name {
  font-size: 12px;
  color: var(--text);
  font-weight: 500;
}
.btn-unlink {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 12px;
  cursor: pointer;
  font-family: inherit;
  padding: 0;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.btn-unlink:hover { color: #ef4444; }

/* ── Green flash animation on link success ── */
@keyframes row-link-flash {
  0%   { background: rgba(34, 197, 94, 0.20); }
  70%  { background: rgba(34, 197, 94, 0.12); }
  100% { background: transparent; opacity: 0; }
}
.mrow-linking {
  animation: row-link-flash 500ms ease forwards;
  pointer-events: none;
}

/* ── Matching blocks (sections within matching tab) ── */
.matching-block {
  margin-top: 24px;
}
.matching-block-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 6px;
}
.matching-block-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  margin: 0;
}
.matching-block-hint {
  font-size: 12px;
  color: var(--text-muted);
  margin: 0 0 10px 0;
}
.matching-block-confirmed { margin-top: 32px; }

/* ── Confirmed-new list ── */
.confirmed-new-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px;
}
.cnew-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  transition: background 100ms;
}
.cnew-row:hover { background: var(--bg); }
.cnew-info { min-width: 0; flex: 1; }
.cnew-name {
  font-size: 13px;
  color: var(--text);
  font-weight: 500;
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.cnew-sub {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}
.btn-cnew-cancel {
  font-family: inherit;
  font-size: 11px;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
  padding: 0;
  flex-shrink: 0;
}
.btn-cnew-cancel:hover { color: #ef4444; }

/* ── View body class: hide standard table UI in matching mode ── */
body.view-matching .filters-section,
body.view-matching .table-meta:not(.matching-section .table-meta),
body.view-matching .table-wrap:not(.matching-section .table-wrap),
body.view-matching .product-cards,
body.view-matching #cards-sentinel { display: none !important; }

body.view-matching .matching-section { display: block !important; }
body.view-matching .matching-table-wrap {
  display: block;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

@media (max-width: 768px) {
  .matching-stats-bar { gap: 8px; }
  .mstat-card { padding: 12px 14px; }
  .mstat-numbers { font-size: 18px; }
  .matching-table .th-supplier-product,
  .matching-table .td-supplier-product,
  .matching-table .th-suggestions,
  .matching-table .td-suggestions { width: auto; }
  /* v75 TASK 2 — mobile: длинные имена в одну строку с многоточием.
     Полное имя остаётся в `title` (доступно по long-tap / hover). */
  .matching-table .mrow-name {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  /* v75 TASK 2 — Каталог: первая колонка (имя товара) — ellipsis.
     Title уже на td (renderCatalogTable). */
  #tbl-suppliers tbody td:first-child {
    max-width: 180px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  #tbl-suppliers tbody td:first-child a {
    display: inline-block;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    vertical-align: bottom;
  }
}

/* ═══════════════════════════════════════════════════════
   Supplier Category Filters
   ═══════════════════════════════════════════════════════ */

/* ── Row in supplier card ── */
.card-categories-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}
.cats-summary-text {
  font-size: 12px;
  color: var(--text-muted);
}

/* v74 UX-hint: «✓ авто» indicator that the row auto-saves
   (category-toggle + min_price), to disambiguate from the
   pricing section which has a manual «Сохранить» button. */
.auto-save-hint {
  font-size: 11px;
  color: var(--text-muted);
  opacity: 0.75;
  margin-left: auto;
  margin-right: 8px;
  white-space: nowrap;
  cursor: help;
}

/* ── Expandable panel ── */
.categories-panel {
  margin-top: 8px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.cats-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.cats-panel-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
}
.cats-panel-close {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 16px;
  padding: 0 2px;
  line-height: 1;
}
.cats-panel-close:hover { color: var(--text); }

/* ── Category list ── */
.cats-list {
  max-height: 280px;
  overflow-y: auto;
}
.cat-item {
  display: flex;
  align-items: center;
  padding: 7px 12px;
  gap: 10px;
  border-bottom: 1px solid var(--border);
  transition: background 100ms;
}
.cat-item:last-child { border-bottom: none; }
.cat-item:hover { background: rgba(0,0,0,0.02); }
.cat-name {
  flex: 1;
  font-size: 12px;
  color: var(--text);
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.cat-count {
  font-size: 11px;
  color: var(--text-muted);
  flex-shrink: 0;
  white-space: nowrap;
}
.cat-toggle { flex-shrink: 0; }

/* ── Bulk-action footer ── */
.cats-panel-footer {
  display: flex;
  gap: 8px;
  padding: 8px 12px;
  border-top: 1px solid var(--border);
  background: var(--surface);
}
.btn-cats-all {
  font-family: inherit;
  font-size: 11px;
  font-weight: 500;
  padding: 4px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text-muted);
  cursor: pointer;
  transition: all 120ms;
}
.btn-cats-all:hover { border-color: var(--accent); color: var(--accent); }

/* Loading state in panel */
.cat-loading {
  padding: 14px 12px;
  font-size: 12px;
  color: var(--text-muted);
  text-align: center;
}

/* ── Login page ─────────────────────────────────────────────────
   Re-uses dashboard tokens (--bg, --surface, --border, --accent)
   so the login screen feels like the same product. Layout is a
   centred card; on mobile it fills the viewport with comfortable
   padding. */
.login-body {
  min-height: 100vh;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.login-corner {
  position: fixed;
  top: 16px;
  left: 20px;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}
.login-wrap {
  width: 100%;
  max-width: 360px;
}
.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px 24px 24px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.login-title {
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -0.3px;
  margin-bottom: 4px;
}
.login-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.login-input {
  font-family: inherit;
  font-size: 15px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text);
  outline: none;
  transition: border-color 150ms, box-shadow 150ms;
}
.login-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}
.login-input:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.login-remember {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text);
  cursor: pointer;
  user-select: none;
}
.login-remember input[type="checkbox"] {
  width: 14px;
  height: 14px;
  accent-color: var(--accent);
  cursor: pointer;
}
.login-error {
  font-size: 13px;
  color: #B91C1C;
  background: #FEF2F2;
  border: 1px solid #FECACA;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
}
.login-submit {
  margin-top: 4px;
  padding: 10px 14px;
  font-size: 14px;
}
.login-hint {
  margin-top: 8px;
  font-size: 12px;
  color: var(--text-muted);
  text-align: center;
  opacity: 0.85;
}

/* Shake animation on wrong password — short and subtle */
@keyframes login-shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-6px); }
  40% { transform: translateX(6px); }
  60% { transform: translateX(-4px); }
  80% { transform: translateX(4px); }
}
.login-shake {
  animation: login-shake 380ms ease-in-out;
}

/* ── Header left cluster (wordmark + logout) ──────────────────── */
.header-left {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

/* ── Logout button — ghost style, sits next to X.Stock wordmark ── */
.logout-form { margin: 0; display: inline-flex; }
.logout-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  padding: 5px 11px;
  font-family: inherit;
  font-size: 12px;
  font-weight: 500;
  line-height: 1;
  cursor: pointer;
  transition: color 150ms, border-color 150ms, background 150ms;
}
.logout-btn:hover {
  color: var(--text);
  border-color: var(--text-muted);
  background: var(--surface);
}
.logout-icon { display: none; }
.logout-text { display: inline; }

/* Mobile (≤600px): icon-only square button */
@media (max-width: 600px) {
  .logout-btn {
    padding: 6px 7px;
    width: 30px;
    height: 30px;
    justify-content: center;
  }
  .logout-text { display: none; }
  .logout-icon { display: block; }
}

@media (max-width: 480px) {
  .login-corner { font-size: 11px; }
  .login-card { padding: 22px 18px 18px; }
}

/* ─────────────────────────────────────────────────────────────────
   ── Block B: Bitrix tab ──────────────────────────────────────────
   ───────────────────────────────────────────────────────────────── */

/* Hide Bitrix tab on mobile (manage-shop is a desktop-only workflow) */
@media (max-width: 768px) {
  .view-tab.desktop-only { display: none; }
}

.bitrix-section {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.bitrix-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 18px 20px;
  box-shadow: var(--shadow);
}
.bitrix-card-title {
  font-size: 15px;
  font-weight: 600;
  margin: 0 0 14px;
  color: var(--text);
}
.bitrix-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}
.bitrix-card-header .bitrix-card-title { margin: 0; }

.bitrix-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px 24px;
  margin-bottom: 16px;
}
.bitrix-toggle,
.bitrix-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 13px;
  color: var(--text);
  cursor: pointer;
}
.bitrix-toggle input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
}
.bitrix-toggle {
  display: grid;
  grid-template-columns: auto 1fr;
  grid-template-rows: auto auto;
  column-gap: 8px;
  align-items: center;
}
.bitrix-toggle input { grid-column: 1; grid-row: 1; }
.bitrix-toggle-label {
  grid-column: 2; grid-row: 1;
  font-weight: 500;
}
.bitrix-toggle .bitrix-hint {
  grid-column: 1 / -1; grid-row: 2;
  margin-left: 24px;
}
.bitrix-field-label {
  font-weight: 500;
  font-size: 13px;
  color: var(--text);
}
.bitrix-field input[type="number"],
.bitrix-field input[type="text"],
.bitrix-field select {
  padding: 6px 9px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 13px;
  background: var(--surface);
  color: var(--text);
}
.bitrix-field input:focus,
.bitrix-field select:focus {
  outline: none;
  border-color: var(--accent);
}
.bitrix-hint {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 400;
  line-height: 1.35;
}

.bitrix-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}
.bitrix-actions-inline {
  display: flex;
  gap: 12px;
  align-items: end;
  flex-wrap: wrap;
}
.bitrix-field-inline {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-muted);
}
.bitrix-field-inline input {
  width: 60px;
  padding: 4px 6px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 12px;
}

/* "Secondary" button — same shape as primary but ghost-style */
.btn-secondary {
  background: var(--surface) !important;
  color: var(--text) !important;
  border: 1px solid var(--border) !important;
}
.btn-secondary:hover {
  background: var(--bg) !important;
  border-color: var(--text-muted) !important;
}

.bitrix-status {
  margin-top: 14px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  border: 1px solid var(--border);
  background: var(--bg);
}
.bitrix-status[data-kind="success"] { border-color: #1f9d55; color: #166534; background: #ecfdf5; }
.bitrix-status[data-kind="error"]   { border-color: #dc2626; color: #991b1b; background: #fef2f2; }
.bitrix-status[data-kind="info"]    { border-color: var(--accent); color: var(--accent); background: #eff6ff; }
.bitrix-status[data-kind="warn"]    { border-color: #b45309; color: #92400e; background: #fffbeb; }

/* History / snapshot tables */
/* Session 6 / Task E — fixed-height history blocks on Bitrix tab.
   Three tables (импорты, экспорты, снимки) cap at 50vh with sticky
   <thead> so the operator can scroll long history without losing the
   column labels. Mobile (<=768px) keeps natural scrolling.        */
@media (min-width: 769px) {
  .bitrix-table-wrap--history {
    max-height: 50vh;
    overflow-y: auto;
  }
  .bitrix-table-wrap--history thead th {
    position: sticky;
    top: 0;
    z-index: 2;
    background: var(--surface, #fff);
    box-shadow: 0 1px 0 rgba(0,0,0,0.06);
  }
}

.bitrix-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.bitrix-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.bitrix-table thead th {
  text-align: left;
  padding: 8px 12px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  font-weight: 500;
  color: var(--text-muted);
  font-size: 12px;
  white-space: nowrap;
}
.bitrix-table tbody td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.bitrix-table tbody tr:last-child td { border-bottom: none; }
.bitrix-table tbody tr:hover { background: var(--bg); }
.bitrix-table .empty-state { text-align: center; color: var(--text-muted); padding: 18px; }
.bitrix-warning {
  margin: 0 0 8px 0;
  padding: 8px 12px;
  font-size: 13px;
  color: #92400e;
  background: #fef3c7;
  border: 1px solid #fde68a;
  border-radius: 6px;
}

/* v63: card-header actions row + "показывать тестовые" checkbox */
.bitrix-card-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}
.b-imports-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-muted);
  cursor: pointer;
  user-select: none;
}
.b-imports-toggle input[type="checkbox"] {
  margin: 0;
  cursor: pointer;
}

/* v62: clickable import history rows + inline detail expansion */
.b-import-row { cursor: pointer; }
.b-import-detail-row > td {
  padding: 0 !important;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}
.b-import-details { padding: 12px 16px; }
.b-import-details-header {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 8px;
}
.b-import-details-msg {
  padding: 12px 16px;
  color: var(--text-muted);
  font-size: 13px;
  font-style: italic;
}
.b-import-details-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  background: var(--card-bg, #fff);
  border: 1px solid var(--border);
  border-radius: 4px;
  overflow: hidden;
}
.b-import-details-table th {
  padding: 6px 10px;
  text-align: left;
  font-weight: 500;
  color: var(--text-muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
}
.b-import-details-table td {
  padding: 6px 10px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.b-import-details-table tbody tr:last-child td { border-bottom: none; }
.b-import-details-table strong { color: var(--text); font-weight: 600; }
.b-diff-unchanged { color: var(--text-muted); }

.b-status-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
.b-status-badge[data-status="success"]     { background: #d1fae5; color: #065f46; }
.b-status-badge[data-status="running"]     { background: #dbeafe; color: #1e40af; }
.b-status-badge[data-status="aborted"]     { background: #fef3c7; color: #92400e; }
.b-status-badge[data-status="failed"]      { background: #fee2e2; color: #991b1b; }
.b-status-badge[data-status="rolled_back"] { background: #ede9fe; color: #5b21b6; }

/* Section 4: YML stats — v50 visual hierarchy.
   Totals (primary) get full cards; per-supplier breakdown is a thin
   subordinate inline row underneath. */
.bitrix-yml-stats {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 14px;
}
.bitrix-yml-primary {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.bitrix-yml-stat {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
}
.bitrix-yml-stat--primary {
  padding: 14px 16px;
}
.bitrix-yml-stat-value {
  font-size: 18px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.2;
}
.bitrix-yml-stat--primary .bitrix-yml-stat-value {
  font-size: 26px;
}
.bitrix-yml-stat-label {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

/* Subordinate per-supplier breakdown row */
.bitrix-yml-suppliers {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 6px 8px;
  padding: 6px 4px 0;
  font-size: 12px;
  color: var(--text-muted);
}
.bitrix-yml-sub-label {
  font-weight: 500;
  color: var(--text-muted);
}
.bitrix-yml-sub-item {
  display: inline-flex;
  align-items: baseline;
  gap: 4px;
}
.bitrix-yml-sub-code {
  color: #555;
  letter-spacing: 0.2px;
}
.bitrix-yml-sub-sep {
  color: #bbb;
}
.bitrix-yml-sub-value {
  color: #111;
  font-weight: 600;
}
.bitrix-yml-sub-divider {
  color: #ccc;
  user-select: none;
}

.bitrix-endpoint {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}
.bitrix-token-row {
  display: flex;
  gap: 8px;
  align-items: center;
}
.bitrix-token-row input { flex: 1; min-width: 0; }
.bitrix-conn {
  font-size: 12px;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text-muted);
}
.bitrix-conn[data-state="ok"]   { background: #ecfdf5; color: #166534; }
.bitrix-conn[data-state="bad"]  { background: #fef2f2; color: #991b1b; }
.bitrix-conn[data-state="stub"] { background: #fffbeb; color: #92400e; }

/* ── Token reveal modals (Block B UX fix) ───────────────── */
.x-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 16px;
}
.x-modal-backdrop[hidden] { display: none; }
.x-modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md, 8px);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.25);
  width: 100%;
  max-width: 480px;
  padding: 20px 22px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.x-modal-title {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
}
.x-modal-body {
  margin: 0;
  font-size: 13px;
  line-height: 1.5;
  color: var(--text-muted);
}
.x-modal-body code {
  background: var(--bg);
  padding: 1px 6px;
  border-radius: 3px;
  font-size: 12px;
  color: var(--text);
}
.x-modal-token-row {
  display: flex;
  gap: 8px;
  align-items: center;
}
.x-modal-token-row input {
  flex: 1;
  min-width: 0;
  font-family: var(--font-mono, "Menlo", "Consolas", monospace);
  font-size: 13px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text);
}
.x-modal-error {
  font-size: 12px;
  color: #991b1b;
  background: #fef2f2;
  border-radius: var(--radius-sm);
  padding: 6px 10px;
}
.x-modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 4px;
}

/* Universal small button (already used elsewhere, ensure exists in Bitrix scope) */
.btn-sm {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 5px 10px;
  font-family: inherit;
  font-size: 12px;
  cursor: pointer;
  transition: background 150ms, border-color 150ms;
}
.btn-sm:hover { background: var(--bg); border-color: var(--text-muted); }
.btn-sm:disabled { opacity: 0.6; cursor: default; }

/* ── Block D: Telegram alerts panel ─────────────────────────── */
.bitrix-alerts {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 6px;
}
.bitrix-alerts-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.b-alert-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--text-muted);
  flex-shrink: 0;
}
.b-alert-dot[data-state="ok"]      { background: #16a34a; }
.b-alert-dot[data-state="bad"]     { background: #dc2626; }
.b-alert-dot[data-state="loading"] { background: #94a3b8; }
.b-alert-state-text {
  font-size: 13px;
  color: var(--text);
}
.bitrix-alerts-stats {
  font-size: 12px;
  color: var(--text-muted);
}

@media (max-width: 768px) {
  .bitrix-grid { grid-template-columns: 1fr; }
  .bitrix-card { padding: 14px; }
}

/* ── Block F: match status badges ───────────────────── */
.badge-status-matched       { background: #DCFCE7; color: #15803D; }
.badge-status-confirmed_new { background: #DBEAFE; color: #1D4ED8; }
.badge-status-not_matched   { background: #FEF3C7; color: #92400E; }
.badge-status-postponed     { background: #E5E7EB; color: #4B5563; }
.badge-status-excluded      { background: #FEE2E2; color: #B91C1C; }
/* v67 — VTSport migration statuses */
.badge-status-not_in_catalog { background: #F3F4F6; color: #6B7280; }
.badge-status-ambiguous      { background: #FEF3C7; color: #92400E; }
.mrow-note {
  margin-top: 4px;
  padding: 4px 8px;
  background: #FEF3C7;
  border-left: 3px solid #F59E0B;
  border-radius: 3px;
  color: #78350F;
  font-size: 12px;
  line-height: 1.4;
}

/* ── Block F: collapsible matching-block-header ─────── */
.matching-block-collapsible {
  cursor: pointer;
  user-select: none;
}
.matching-block-collapsible:hover .matching-block-title { opacity: 0.85; }
.matching-collapse-arrow {
  display: inline-block;
  width: 12px;
  font-size: 11px;
  color: var(--text-muted);
  transition: transform 120ms ease;
}
.matching-block-collapsible[aria-expanded="true"] .matching-collapse-arrow {
  transform: rotate(90deg);
}
.matching-block-hidden { margin-top: 32px; }

.hidden-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px;
}
.hidden-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  transition: background 100ms;
}
.hidden-row:hover { background: var(--bg); }
.hidden-info { min-width: 0; flex: 1; }
.hidden-name { font-size: 13px; color: var(--text); font-weight: 500; }
.hidden-sub  { font-size: 11px; color: var(--text-muted); margin-top: 2px; }
.hidden-actions {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-shrink: 0;
}

/* ── Block F: postpone / exclude buttons in suggestions ── */
.btn-postpone, .btn-exclude, .btn-restore {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 4px 10px;
  font-size: 12px;
  color: var(--text-muted);
  cursor: pointer;
  transition: background 100ms, color 100ms, border-color 100ms;
}
.btn-postpone:hover { color: #4B5563; border-color: #9CA3AF; background: #F3F4F6; }
.btn-exclude:hover  { color: #B91C1C; border-color: #FCA5A5; background: #FEF2F2; }
.btn-restore:hover  { color: #15803D; border-color: #86EFAC; background: #F0FDF4; }
.btn-postpone:disabled,
.btn-exclude:disabled,
.btn-restore:disabled { opacity: 0.5; cursor: not-allowed; }

/* ── Block F: 5-bucket stats row ── */
.mstat-postponed { color: #4B5563; }
.mstat-excluded  { color: #B91C1C; }

/* ── Block F: brand glossary panel ── */
.csb-glossary-row { padding-top: 4px; }
.csb-glossary-toggle {
  font-size: 13px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.csb-glossary-count {
  color: var(--text-muted);
  font-size: 12px;
}
.csb-glossary-panel {
  flex-direction: column;
  gap: 8px;
  align-items: stretch !important;
}
.glossary-add {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}
.glossary-add .filter-select { min-width: 160px; }
.glossary-input { flex: 1; min-width: 140px; max-width: 220px; }
.glossary-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 6px;
  background: var(--surface);
  max-height: 280px;
  overflow-y: auto;
}
.gloss-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 5px 8px;
  border-radius: var(--radius-sm);
  font-size: 12px;
}
.gloss-row:hover { background: var(--bg); }
.gloss-cell { min-width: 0; }
.gloss-brand { color: var(--text-muted); font-weight: 500; min-width: 100px; }
.gloss-arrow { color: var(--text-muted); }
.gloss-note  { color: var(--text-muted); font-style: italic; }
.btn-gloss-del {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-muted);
  font-size: 12px;
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  cursor: pointer;
}
.btn-gloss-del:hover { color: #B91C1C; border-color: #FCA5A5; background: #FEF2F2; }

/* ── Block F: brand boost reason chip in suggestions ── */
.suggest-boost {
  display: inline-block;
  margin-left: 6px;
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 8px;
  vertical-align: middle;
  background: #F3F4F6;
  color: #6B7280;
}
.suggest-boost-same { background: #DCFCE7; color: #15803D; }
.suggest-boost-other { background: #FEF3C7; color: #92400E; }


/* ══════════════════════════════════════════════════════════
   Phase 2a UI cleanup — header health indicators (replaces old Block G)
   ══════════════════════════════════════════════════════════ */

.hdr-ind {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  color: #555;
  text-decoration: none;
  white-space: nowrap;
  margin: 0 4px;
}
a.hdr-ind { color: #555; }
a.hdr-ind:hover .hdr-ind-text,
a.hdr-ind:hover .hdr-ind-val { color: #000; text-decoration: underline; }
.hdr-ind-text { color: #555; }
.hdr-ind-val  { color: #111; font-weight: 600; }
.hdr-sep { color: #ccc; margin: 0 2px; user-select: none; }

.hdr-ind-dot {
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 50%;
  background: #aaa;
}
.hdr-ind-dot.dot-green  { background: #2ecc71; }
.hdr-ind-dot.dot-yellow { background: #f1c40f; }
.hdr-ind-dot.dot-red    { background: #e74c3c; }
.hdr-ind-dot.dot-grey   { background: #aaa; }
.hdr-ind-dot.dot-blue   { background: #3498db; }  /* v64: new-products badge */

/* v64: matching tab "новые за 24ч" filter banner */
.matching-newonly-banner {
  margin: 8px 0 12px;
  padding: 8px 12px;
  background: #eaf4fd;
  border-left: 3px solid #3498db;
  border-radius: 4px;
  font-size: 13px;
  color: #1a3a5a;
}
.matching-newonly-banner a {
  margin-left: 8px;
  color: #2980b9;
  font-weight: 500;
  text-decoration: underline;
}

/* v64: settings → Алерты section */
.alerts-settings-grid {
  display: flex;
  flex-direction: column;
  gap: 16px;
  max-width: 640px;
}
.alerts-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 12px;
  background: #fafbfc;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
}
.alerts-label {
  font-weight: 500;
  font-size: 14px;
}
.alerts-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
}
.alerts-row input[type="time"],
.alerts-row input[type="number"] {
  width: 140px;
  padding: 6px 8px;
  border: 1px solid #d1d5db;
  border-radius: 4px;
  font-size: 14px;
}
.alerts-hint {
  font-size: 12px;
  margin: 0;
}
.alerts-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-top: 4px;
}
.alerts-status-ok  { color: #2ecc71; }
.alerts-status-err { color: #e74c3c; }

@media (max-width: 768px) {
  /* Keep header-status labels visible on mobile — dots alone are
     unreadable. Allow header-left cluster to wrap onto a 2nd row. */
  .header-left {
    flex-wrap: wrap;
    row-gap: 4px;
    column-gap: 8px;
  }
  .hdr-ind { font-size: 11px; margin: 0 2px; }
  .hdr-sep { margin: 0; }
}

.hdr-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px; height: 28px;
  font-size: 16px;
  text-decoration: none;
  border-radius: 6px;
  margin-right: 6px;
}
.hdr-link:hover { background: #f0f0f0; }

@media (max-width: 768px) {
  .hdr-ind-label { display: none; }
}

/* ── /glossary + /alerts standalone pages ─────────────── */

.page-narrow .header { border-bottom: 1px solid #ececec; }
.wordmark-link { text-decoration: none; color: inherit; }
.page-crumb { color: #888; font-size: 14px; margin-left: 6px; }
.main-narrow { max-width: 1100px; margin: 0 auto; padding: 24px 20px; }
.page-h2 { margin: 0 0 8px; font-size: 22px; font-weight: 500; }
.page-sub { color: #666; margin: 0 0 20px; font-size: 14px; }

.btn-secondary {
  display: inline-flex; align-items: center;
  height: 28px; padding: 0 12px;
  border: 1px solid #d0d0d0; background: #fff; color: #222;
  border-radius: 6px; font-size: 13px; text-decoration: none; cursor: pointer;
}
.btn-secondary:hover { background: #f4f4f4; }

.glossary-card {
  background: #fff; border: 1px solid #ececec; border-radius: 8px;
  padding: 16px;
}
.glossary-meta { color: #666; font-size: 12px; margin: 12px 0 8px; }

/* Alerts page */
.alerts-stats { color: #444; font-size: 14px; margin-bottom: 14px; }
.alerts-stats b { color: #111; font-weight: 600; padding: 0 2px; }
.alerts-filters { display: flex; flex-direction: column; gap: 8px; margin-bottom: 14px; }
.alerts-filter-group { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; }
.alerts-filter-label { color: #666; font-size: 12px; margin-right: 6px; }
.alerts-chip {
  border: 1px solid #d8d8d8; background: #fff; color: #333;
  padding: 3px 10px; border-radius: 12px; font-size: 12px; cursor: pointer;
}
.alerts-chip:hover { background: #f4f4f4; }
.alerts-chip.active { background: #2c3e50; color: #fff; border-color: #2c3e50; }

.alerts-table {
  width: 100%; border-collapse: collapse; font-size: 13px;
  background: #fff; border: 1px solid #ececec; border-radius: 8px; overflow: hidden;
}
.alerts-table th, .alerts-table td {
  text-align: left; padding: 8px 12px; border-bottom: 1px solid #f0f0f0;
  vertical-align: top;
}
.alerts-table th { background: #fafafa; font-weight: 600; color: #555; font-size: 12px; }
.al-col-time { width: 110px; color: #666; white-space: nowrap; }
.al-col-sev  { width: 110px; }
.al-col-mod  { width: 140px; color: #555; }
.al-col-status { width: 130px; }
.al-title { color: #111; font-weight: 500; }
.al-msg   { color: #666; font-size: 12px; margin-top: 2px; white-space: pre-wrap; }

.al-sev-badge {
  display: inline-block; padding: 1px 8px; border-radius: 3px; font-size: 11px;
  font-weight: 600;
}
.al-sev-badge.al-sev-info     { background: #ebf5ff; color: #1f6feb; }
.al-sev-badge.al-sev-warn     { background: #fff5e0; color: #b07b00; }
.al-sev-badge.al-sev-error    { background: #ffe5e0; color: #c0392b; }
.al-sev-badge.al-sev-critical { background: #c0392b; color: #fff; }

.al-status        { font-size: 11px; color: #777; }
.al-status.al-st-ok    { color: #1f7a3a; }
.al-status.al-st-err   { color: #c0392b; cursor: help; }
.al-status.al-st-dedup { color: #888; font-style: italic; }

.alerts-more { text-align: center; margin-top: 16px; }

   X.SUP — /settings + gear icon (Phase 2b)
   ─────────────────────────────────────────────────────────────────── */

.gear-link {
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; margin-right: 8px;
  color: var(--text-muted, #666); text-decoration: none; border-radius: 6px;
  transition: background .15s, color .15s;
}
.gear-link:hover { background: rgba(0,0,0,.05); color: var(--text, #111); }
.gear-link svg { width: 18px; height: 18px; }

.user-badge {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 13px; color: var(--text-muted, #666); margin-right: 12px;
}
.user-badge .role-chip { font-size: 10px; padding: 1px 6px; }

.role-chip {
  display: inline-block; padding: 2px 8px; border-radius: 10px;
  font-size: 11px; font-weight: 500; line-height: 1.4;
  background: #eef2ff; color: #4338ca; margin-right: 4px;
}
.role-chip.role-admin   { background: #fee2e2; color: #b91c1c; }
.role-chip.role-manager { background: #dcfce7; color: #166534; }

.wordmark-link { color: inherit; text-decoration: none; }
.back-link {
  margin-left: 12px; font-size: 13px; color: var(--text-muted, #666);
  text-decoration: none;
}
.back-link:hover { color: var(--accent, #4f46e5); }

/* ── /settings page layout ── */
.settings-body { background: #fafafa; }
.settings-main { max-width: 1100px; margin: 0 auto; padding: 24px 20px 80px; }
.settings-title { font-size: 22px; font-weight: 500; margin: 0 0 24px; }

.settings-section {
  background: #fff; border: 1px solid #e5e7eb; border-radius: 10px;
  padding: 20px 24px; margin-bottom: 18px;
}
.settings-section h2 {
  font-size: 16px; font-weight: 500; margin: 0 0 14px;
  color: var(--text, #111);
}
.settings-section-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; margin-bottom: 14px; flex-wrap: wrap;
}
.settings-section-head h2 { margin: 0; }

.settings-table-wrap { overflow-x: auto; }
.settings-table {
  width: 100%; border-collapse: collapse; font-size: 13px;
}
.settings-table th, .settings-table td {
  padding: 8px 10px; text-align: left; border-bottom: 1px solid #f1f5f9;
  vertical-align: middle;
}
.settings-table th {
  font-weight: 500; color: #6b7280; font-size: 12px;
  text-transform: uppercase; letter-spacing: .03em;
}
.settings-table td code {
  background: #f3f4f6; padding: 1px 6px; border-radius: 4px;
  font-size: 12px;
}
.settings-table .row-actions {
  display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end;
}
.btn-danger { color: #b91c1c; }
.btn-danger:hover { background: #fee2e2; }

.muted { color: #9ca3af; font-size: 12px; }
.badge-ok   { color: #166534; font-weight: 500; }
.badge-fail { color: #b91c1c; font-weight: 500; }
.form-error {
  color: #b91c1c; font-size: 13px; padding: 8px 10px;
  background: #fee2e2; border-radius: 6px; margin-top: 8px;
}

/* ── modules grid ── */
.modules-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
}
.module-card {
  border: 1px solid #e5e7eb; border-radius: 8px; padding: 12px 14px;
  background: #fff;
}
.module-card.module-wip { background: #f9fafb; opacity: .6; }
.module-head {
  display: flex; justify-content: space-between; align-items: baseline;
  margin-bottom: 4px;
}
.module-name { font-weight: 500; font-size: 14px; }
.module-status { font-size: 11px; color: #9ca3af; text-transform: uppercase; }
.module-desc { font-size: 12px; }

/* Phase 2c-2: per-module configuration links inside .module-card */
.module-config-links {
  margin-top: 10px; padding-top: 10px;
  border-top: 1px dashed #e5e7eb;
}
.module-config-title {
  font-size: 11px; color: #6b7280; text-transform: uppercase;
  letter-spacing: .03em; margin-bottom: 6px;
}
.module-config-list { list-style: none; padding: 0; margin: 0; }
.module-config-list li {
  display: flex; flex-direction: column; gap: 2px;
  padding: 6px 0; border-bottom: 1px solid #f3f4f6;
}
.module-config-list li:last-child { border-bottom: 0; }
.module-config-link {
  font-size: 13px; color: #2563eb; text-decoration: none; font-weight: 500;
}
.module-config-link:hover { text-decoration: underline; }
.module-config-desc { font-size: 11px; line-height: 1.35; }

/* deep-link landing target offset so anchored sections aren't hidden
   under the sticky header when navigated from /settings */
:target { scroll-margin-top: 80px; }

/* Phase 2d: self-service password change link in headers + form page */
.me-pw-link {
  font-size: 12px; color: #6b7280; text-decoration: none;
  padding: 4px 8px; border-radius: 4px;
}
.me-pw-link:hover { color: #2563eb; background: #f3f4f6; }
.me-password-section { max-width: 460px; }
.me-pw-form { display: flex; flex-direction: column; gap: 14px; }
.me-pw-form label { display: flex; flex-direction: column; gap: 4px; }
.me-pw-form label > span:first-child {
  font-size: 12px; color: #374151; font-weight: 500;
}
.me-pw-form input[type="password"] {
  padding: 8px 10px; border: 1px solid #d1d5db; border-radius: 6px;
  font-size: 14px;
}
.me-pw-hint { font-size: 11px; }
.me-pw-actions { display: flex; gap: 12px; align-items: center; margin-top: 4px; }
.me-pw-ok {
  background: #ecfdf5; color: #047857; border: 1px solid #a7f3d0;
  padding: 10px 12px; border-radius: 6px; margin-bottom: 14px; font-size: 13px;
}
.btn-link {
  background: none; border: 0; color: #2563eb;
  text-decoration: none; font-size: 13px; cursor: pointer;
}
.btn-link:hover { text-decoration: underline; }

.login-log-filters {
  display: flex; gap: 8px; align-items: center; flex-wrap: wrap;
}
.login-log-filters input,
.login-log-filters select {
  font-size: 13px; padding: 5px 8px; border: 1px solid #d1d5db;
  border-radius: 6px; background: #fff;
}

.settings-footer-note {
  font-size: 12px; color: #6b7280; padding: 12px 4px; max-width: 700px;
}
.settings-footer-note a { color: var(--accent, #4f46e5); }

/* ── modal ── */
body.modal-open { overflow: hidden; }
.modal-overlay {
  position: fixed; inset: 0; background: rgba(15, 23, 42, .55);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000; padding: 20px;
}
.modal-overlay[hidden] { display: none !important; }
.modal {
  background: #fff; border-radius: 10px; width: 100%; max-width: 480px;
  max-height: 90vh; overflow-y: auto; box-shadow: 0 20px 60px rgba(0,0,0,.25);
}
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; border-bottom: 1px solid #f1f5f9;
}
.modal-head h3 { margin: 0; font-size: 16px; font-weight: 500; }
.modal-close {
  background: none; border: 0; font-size: 22px; line-height: 1;
  cursor: pointer; color: #9ca3af; padding: 0 4px;
}
.modal-close:hover { color: #111; }
.modal-body { padding: 16px 20px 20px; }
.modal-body label {
  display: block; margin-bottom: 12px; font-size: 13px;
}
.modal-body label > span { display: block; margin-bottom: 4px; color: #374151; }
.modal-body label > span small { color: #9ca3af; font-weight: 400; }
.modal-body input[type="text"],
.modal-body input[type="email"],
.modal-body input[type="password"] {
  width: 100%; padding: 7px 10px; border: 1px solid #d1d5db;
  border-radius: 6px; font-size: 13px; box-sizing: border-box;
}
.radio-label {
  display: flex !important; align-items: center; gap: 6px;
  margin-bottom: 6px; font-size: 13px; cursor: pointer;
}
.perm-fieldset, .pw-fieldset {
  border: 1px solid #e5e7eb; border-radius: 8px; padding: 10px 14px;
  margin: 0 0 14px;
}
.perm-fieldset legend, .pw-fieldset legend {
  padding: 0 6px; font-size: 12px; color: #6b7280;
}
.perm-row {
  display: flex; align-items: center; gap: 10px;
  padding: 4px 0; font-size: 13px;
}
.perm-row-name { flex: 1; }
.perm-row select {
  font-size: 13px; padding: 4px 8px; border: 1px solid #d1d5db;
  border-radius: 6px; background: #fff;
}
.modal-actions {
  display: flex; gap: 10px; justify-content: flex-end; margin-top: 16px;
}
.btn-secondary {
  background: #fff; color: #374151; border: 1px solid #d1d5db;
  padding: 7px 14px; border-radius: 6px; font-size: 13px; cursor: pointer;
}
.btn-secondary:hover { background: #f3f4f6; }
.pw-show {
  display: flex; gap: 8px; align-items: center; padding: 10px 12px;
  background: #f3f4f6; border-radius: 6px; margin-bottom: 12px;
}
.pw-show code {
  flex: 1; font-size: 14px; word-break: break-all;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
}

/* ── Phase 2c-1: manager (read-only) UI variant ─────────────────── */
/* Body gets `.role-manager` for non-admins; the rule below hides
   every control with `[data-admin-only]`. JS-rendered admin actions
   (snapshot restore, source CRUD, rollback, glossary delete) check
   `window.__IS_ADMIN__` instead and simply omit the buttons. */
body.role-manager [data-admin-only] { display: none !important; }

.role-banner {
  background: #fef3c7;
  border-bottom: 1px solid #fcd34d;
  color: #78350f;
  font-size: 13px;
  font-weight: 500;
  text-align: center;
  padding: 6px 12px;
}

/* /glossary filter row (v47) */
.glossary-filter-label {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 13px; color: #555;
}
.glossary-filter-label .glossary-input { width: 220px; }
.glossary-meta { display: flex; align-items: center; gap: 12px; }
.glossary-meta-spacer { flex: 1; }

/* v65: NULL-quantity policy
   --------------------------------------------------------------
   .qty-unknown — поставщик не сообщает остаток (NULL в БД).
   Рендерится как «≈ 1» в muted-серой обёртке с тултипом.
   В YML на сайт такие позиции уходят как <quantity>1</quantity>.

   .qty-zero — явный нулевой остаток (поставщик прислал 0).
   Подсвечен красным, чтобы выделять в таблице. */
.qty-unknown {
  color: #6B7280;
  font-style: italic;
  cursor: help;
}
.qty-zero {
  color: #DC2626;
  font-weight: 500;
}
