/* Palette unified with the WB Pilot hub (src/index.css :root) and with the
   Profit dashboard. All three used to disagree: the hub is emerald-accented,
   while both bot dashboards ran an unrelated blue theme with their own
   success/warning/danger steps, so a seller crossing between them saw what
   looked like a different product. Same hue families everywhere now.
   --text-on-accent exists because white on emerald is only 2.54:1; a filled
   accent button needs dark text. */
:root {
  --bg: #060913;
  --card: #121826;
  --card-raised: #182236;
  --line: #2a3348;
  --text: #f8fafc;
  --muted: #94a3b8;
  --accent: #10b981;
  --accent-soft: rgba(16, 185, 129, .14);
  --text-on-accent: #042f1a;
  --ok: #10b981;
  --warn: #f59e0b;
  --danger: #ef4444;
}

* { box-sizing: border-box; }
html { background: var(--bg); color-scheme: dark; }
body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", "Trebuchet MS", sans-serif;
  font-size: 16px;
  line-height: 1.45;
}
button, input, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible {
  outline: 3px solid rgba(16, 185, 129, .65);
  outline-offset: 2px;
}
[hidden] { display: none !important; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(18, 24, 38, .98);
  border-bottom: 1px solid var(--line);
}
.nav {
  display: flex;
  align-items: center;
  gap: 10px;
  width: min(1240px, 100%);
  min-height: 56px;
  margin: 0 auto;
  padding: 0 20px;
}
/* 40px tall before: the logo is a link, so it needs the 44px tap floor. */
.brand { display: flex; align-items: center; min-height: 44px; flex: 0 1 auto; min-width: 0; padding-right: 16px; }
.brand img { display: block; width: auto; max-width: 235px; height: 40px; object-fit: contain; }
.nav-links { display: flex; align-items: stretch; gap: 4px; margin-left: auto; }
.nav-tab, .link-button {
  display: inline-flex;
  align-items: center;
  min-height: 56px;
  padding: 0 14px;
  border: 0;
  border-bottom: 2px solid transparent;
  background: transparent;
  color: var(--muted);
  font-size: 14px;
  text-decoration: none;
  white-space: nowrap;
}
.nav-tab:hover, .link-button:hover { color: var(--text); }
.nav-tab.active { color: var(--text); border-bottom-color: var(--accent); }
.link-button { min-height: 42px; margin-left: 4px; color: var(--accent); }
.nav-toggle { display: none; }

main { width: min(1120px, 100%); margin: 0 auto; padding: 28px 20px 48px; }
.tab-panel { min-width: 0; }
.dashboard-context {
  display: flex;
  align-items: center;
  gap: 7px;
  min-height: 44px;
  margin: 0 0 8px;
  font-size: clamp(19px, 2.2vw, 23px);
  font-weight: 750;
  line-height: 1.15;
}
.dashboard-context-label { color: var(--text); white-space: nowrap; }
.dashboard-context-divider { color: var(--muted); font-weight: 500; }
.cabinet-switcher {
  position: relative;
  display: inline-flex;
  align-items: center;
  min-width: 0;
  max-width: min(480px, 68vw);
  color: var(--accent);
}
.dashboard-context .cabinet-switcher select {
  width: auto;
  max-width: 100%;
  min-height: 44px;
  padding: 6px 28px 6px 3px;
  overflow: hidden;
  border: 0;
  border-radius: 6px;
  appearance: none;
  background: transparent;
  color: var(--accent);
  cursor: pointer;
  font-size: inherit;
  font-weight: 750;
  line-height: 1.15;
  text-overflow: ellipsis;
  white-space: nowrap;
  transition: background-color .16s ease, color .16s ease, opacity .16s ease;
}
.dashboard-context .cabinet-switcher select:hover { background: var(--accent-soft); }
.dashboard-context .cabinet-switcher select:focus-visible {
  outline: 2px solid rgba(16, 185, 129, .72);
  outline-offset: 1px;
}
.dashboard-context .cabinet-switcher select:disabled {
  cursor: default;
  opacity: 1;
}
.cabinet-chevron {
  position: absolute;
  top: 50%;
  right: 9px;
  width: 7px;
  height: 7px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  pointer-events: none;
  transform: translateY(-70%) rotate(45deg);
  transition: opacity .16s ease;
}
.cabinet-switcher select:disabled + .cabinet-chevron { opacity: 0; }
.cabinet-switcher select.is-busy { cursor: progress; opacity: .68; pointer-events: none; }
.cabinet-switcher select.is-busy + .cabinet-chevron { opacity: .4; }
.managed-in-bot {
  max-width: 310px;
  margin: 0;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  font-size: 13px;
  text-align: right;
}
.panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 20px;
}
.page-heading, .section-heading, .notice {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
}
.page-heading { margin: 4px 0 20px; }
.heading-actions { display: grid; justify-items: end; gap: 8px; }
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 4px; font-size: clamp(24px, 3vw, 30px); line-height: 1.15; }
h2 { margin-bottom: 4px; color: var(--accent); font-size: 19px; line-height: 1.25; }
.eyebrow { margin-bottom: 5px; color: var(--accent); font-size: 12px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.muted, .field-hint { color: var(--muted); }
.muted { margin-bottom: 0; font-size: 14px; }
.field-hint { margin: 7px 0 0; font-size: 13px; }

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 10px 16px;
  border: 1px solid transparent;
  border-radius: 8px;
  color: #fff;
  font-size: 14px;
  font-weight: 650;
  line-height: 1.1;
  text-decoration: none;
  transition: background-color .16s ease, border-color .16s ease, transform .16s ease;
}
.button:active { transform: translateY(1px); }
/* White on emerald is 2.54:1; the filled primary needs dark ink. */
.button.primary { background: var(--accent); color: var(--text-on-accent); }
.button.primary:hover { background: #14d495; }
.button.secondary { background: transparent; border-color: var(--line); color: var(--text); }
.button.secondary:hover { background: var(--card-raised); }
.button.danger { background: transparent; border-color: rgba(239, 68, 68, .7); color: var(--danger); }
.button.danger:hover { background: rgba(239, 68, 68, .1); }
.button[disabled] { cursor: not-allowed; opacity: .55; transform: none; }

.notice {
  align-items: center;
  margin-bottom: 18px;
  padding: 13px 15px;
  border: 1px solid var(--accent);
  border-radius: 10px;
  background: var(--accent-soft);
  color: var(--text);
  font-size: 14px;
}
.notice > div { display: grid; gap: 2px; }
.notice.warning { border-color: var(--warn); background: rgba(245, 158, 11, .1); }
.notice.error { border-color: var(--danger); background: rgba(239, 68, 68, .1); }
.auth-gate { max-width: 610px; margin: 12vh auto 0; text-align: left; }
.auth-gate h1 { margin-bottom: 12px; }

.onboarding { display: grid; grid-template-columns: minmax(230px, .8fr) minmax(320px, 1.2fr); gap: 28px; margin-bottom: 18px; }
.onboarding h2 { margin-bottom: 9px; }
.alert-row label, .manual-group-panel label { display: block; margin: 0 0 6px; color: var(--muted); font-size: 13px; font-weight: 600; }
input, select {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #0a0f1e;
  color: var(--text);
}
select { appearance: auto; }
.input-action { display: flex; gap: 10px; }
.input-action .button { flex: 0 0 auto; }

.summary-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; margin-bottom: 18px; }
.metric { min-height: 132px; display: flex; flex-direction: column; justify-content: center; gap: 4px; padding: 18px; }
.metric > span { color: var(--muted); font-size: 13px; }
.metric strong { color: var(--text); font-size: 30px; line-height: 1; font-variant-numeric: tabular-nums; }
.metric small { color: var(--muted); font-size: 13px; }
.warning-metric strong { color: var(--warn); }
.danger-metric strong { color: var(--danger); }

.supply-management { display: grid; gap: 18px; }
.supply-management > .page-heading { margin-bottom: 0; }
.supply-form { min-width: 0; }
.supply-form-heading { align-items: center; }
.supply-reset { min-height: 38px; padding: 8px 12px; }
.supply-filter-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1.35fr) minmax(0, .75fr);
  gap: 12px;
}
.supply-filter {
  position: relative;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #0a0f1e;
}
.supply-filter[open] { z-index: 30; border-color: rgba(16, 185, 129, .72); }
.supply-filter > summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 46px;
  padding: 10px 12px;
  color: var(--text);
  font-size: 13px;
  font-weight: 650;
  cursor: pointer;
  list-style: none;
}
.supply-filter > summary::-webkit-details-marker { display: none; }
.supply-filter > summary::after {
  width: 8px;
  height: 8px;
  flex: 0 0 auto;
  border-right: 2px solid var(--muted);
  border-bottom: 2px solid var(--muted);
  content: "";
  transform: rotate(45deg) translateY(-2px);
  transition: transform .16s ease;
}
.supply-filter[open] > summary::after { transform: rotate(225deg) translate(-2px, -2px); }
.supply-filter > summary span { margin-right: auto; }
.supply-filter > summary small { color: var(--accent); font-size: 11px; font-weight: 600; white-space: nowrap; }
.supply-filter-popover {
  position: absolute;
  z-index: 30;
  top: calc(100% + 7px);
  left: 0;
  width: max(100%, 270px);
  overflow: hidden;
  border: 1px solid rgba(16, 185, 129, .52);
  border-radius: 9px;
  background: #0a0f1e;
  box-shadow: 0 18px 42px rgba(0, 0, 0, .42);
}
.supply-article-filter .supply-filter-popover { width: max(100%, 430px); }
.supply-size-filter .supply-filter-popover { right: 0; left: auto; }
.supply-options {
  display: grid;
  max-height: 240px;
  overflow-y: auto;
  padding: 7px;
  scrollbar-color: var(--line) transparent;
}
.supply-option {
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr);
  align-items: center;
  gap: 9px;
  min-height: 44px;
  padding: 8px;
  border-radius: 7px;
  cursor: pointer;
}
.supply-option:hover { background: var(--card-raised); }
.supply-option.is-unavailable { cursor: not-allowed; opacity: .38; }
.supply-option.is-unavailable:hover { background: transparent; }
.supply-option.is-selected-unavailable { cursor: pointer; opacity: .62; }
.supply-option.is-selected-unavailable:hover { background: var(--card-raised); }
.supply-option input {
  width: 18px;
  min-height: 18px;
  margin: 0;
  padding: 0;
  accent-color: var(--accent);
}
.supply-option input:disabled { cursor: not-allowed; }
.supply-option-text { display: grid; min-width: 0; gap: 1px; }
.supply-option-text strong { overflow: hidden; color: var(--text); font-size: 13px; font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
.supply-option-text small { overflow: hidden; color: var(--muted); font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.supply-options-empty { margin: 0; padding: 10px 8px; color: var(--muted); font-size: 12px; }
.supply-options-retry {
  min-height: 34px;
  margin: 0 8px 10px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--card-raised);
  color: var(--text);
  cursor: pointer;
}
.supply-options-retry:hover { border-color: var(--accent); }
.supply-search-wrap { padding: 8px; border-bottom: 1px solid var(--line); }
.supply-search-wrap input { min-height: 38px; font-size: 13px; }
.supply-period-grid {
  display: grid;
  grid-template-columns: minmax(320px, 1.55fr) repeat(2, minmax(0, 1fr)) auto;
  align-items: end;
  gap: 12px;
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}
.supply-field { min-width: 0; }
.supply-field > label, .supply-field > legend { display: block; margin-bottom: 6px; color: var(--muted); font-size: 13px; font-weight: 600; }
.supply-date-field { min-inline-size: 0; margin: 0; padding: 0; border: 0; }
.supply-date-field > legend { width: 100%; padding: 0; }
.supply-date-range {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: end;
  gap: 8px;
}
.supply-date-range label { display: grid; min-width: 0; gap: 4px; }
.supply-date-range label > span { color: var(--muted); font-size: 11px; font-weight: 600; }
.supply-date-range input { min-width: 0; color-scheme: dark; font-variant-numeric: tabular-nums; }
.supply-date-separator { padding-bottom: 13px; color: var(--muted); }
.supply-date-field.invalid .supply-date-range input { border-color: var(--danger); }
.supply-date-field.invalid .field-hint { color: var(--danger); }
.supply-input-unit { position: relative; }
.supply-input-unit input { padding-right: 58px; }
.supply-input-unit span {
  position: absolute;
  top: 50%;
  right: 12px;
  color: var(--muted);
  font-size: 12px;
  pointer-events: none;
  transform: translateY(-50%);
}
.supply-field .field-hint { min-height: 36px; margin-bottom: 0; font-size: 11px; }
.supply-submit { min-width: 178px; margin-bottom: 36px; }
.supply-status {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--card);
}
.supply-status-dot { width: 10px; height: 10px; flex: 0 0 auto; border-radius: 50%; background: var(--muted); box-shadow: 0 0 0 5px rgba(138, 152, 181, .1); }
.supply-status > div { display: grid; gap: 2px; }
.supply-status strong { font-size: 14px; }
.supply-status span:not(.supply-status-dot) { color: var(--muted); font-size: 13px; }
.supply-status.loading { border-color: rgba(16, 185, 129, .55); background: rgba(16, 185, 129, .07); }
.supply-status.loading .supply-status-dot { background: var(--accent); box-shadow: 0 0 0 5px rgba(16, 185, 129, .12); }
.supply-status.ok { border-color: rgba(16, 185, 129, .55); background: rgba(16, 185, 129, .07); }
.supply-status.ok .supply-status-dot { background: var(--ok); box-shadow: 0 0 0 5px rgba(16, 185, 129, .12); }
.supply-status.warning { border-color: rgba(245, 158, 11, .55); background: rgba(245, 158, 11, .07); }
.supply-status.warning .supply-status-dot { background: var(--warn); box-shadow: 0 0 0 5px rgba(245, 158, 11, .12); }
.supply-status.error { border-color: rgba(239, 68, 68, .65); background: rgba(239, 68, 68, .08); }
.supply-status.error .supply-status-dot { background: var(--danger); box-shadow: 0 0 0 5px rgba(239, 68, 68, .12); }
.supply-summary-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.supply-metric { min-height: 126px; display: flex; flex-direction: column; justify-content: center; gap: 4px; padding: 18px; }
.supply-metric > span { color: var(--muted); font-size: 13px; }
.supply-metric strong { color: var(--text); font-size: 28px; line-height: 1; font-variant-numeric: tabular-nums; }
.supply-metric small { color: var(--muted); font-size: 12px; }
.supply-recommendation-metric { border-color: rgba(16, 185, 129, .55); background: linear-gradient(145deg, var(--card), rgba(16, 185, 129, .12)); }
.supply-recommendation-metric strong { color: var(--accent); }
.supply-result-panel { min-width: 0; }
.supply-result-heading { align-items: center; }
.supply-table { min-width: 980px; }
.supply-more { display: flex; justify-content: center; padding-top: 16px; }
.supply-product { min-width: 160px; }
.supply-size-toggle {
  display: flex;
  width: 100%;
  min-height: 44px;
  align-items: center;
  gap: 9px;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  text-align: left;
  cursor: pointer;
}
.supply-size-toggle:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; border-radius: 4px; }
.supply-size-chevron { color: var(--accent); font-size: 22px; line-height: 1; transition: transform .16s ease; }
.supply-article-row.expanded .supply-size-chevron { transform: rotate(90deg); }
.supply-product-copy { display: grid; min-width: 0; gap: 2px; }
.supply-product strong { color: var(--text); font-size: 13px; }
.supply-product small { max-width: 220px; overflow: hidden; color: var(--muted); font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.supply-size-detail-row > td { padding: 0 10px 16px; background: rgba(16, 185, 129, .035); }
.supply-size-details { padding: 14px; border: 1px solid var(--line); border-radius: 9px; background: #0a0f1e; }
.supply-size-details-title { display: block; margin-bottom: 10px; color: var(--accent); font-size: 13px; }
.supply-size-table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.supply-size-table { min-width: 1050px; font-size: 12px; }
.supply-size-table th, .supply-size-table td { padding: 9px 8px; }
.supply-size-name { color: var(--text); font-weight: 650; }
.supply-recommended { color: var(--accent); font-size: 15px; font-variant-numeric: tabular-nums; }
.supply-recommendation-stack { display: inline-grid; justify-items: end; gap: 3px; }
.supply-partial-note { max-width: 150px; color: var(--warn); font-size: 10px; line-height: 1.25; text-align: right; }
.supply-unavailable { display: inline-block; max-width: 115px; color: var(--muted); font-size: 11px; line-height: 1.25; text-align: right; }
.supply-assumptions { padding-top: 16px; padding-bottom: 16px; }
.supply-assumptions > summary { color: var(--accent); font-size: 14px; font-weight: 650; cursor: pointer; }
.supply-assumptions ul { display: grid; gap: 7px; margin: 14px 0 0; padding-left: 20px; color: var(--muted); font-size: 13px; }

.analytics-grid { display: grid; grid-template-columns: 1.25fr .75fr; gap: 14px; margin-bottom: 18px; }
.chart-card { min-width: 0; }
.chart-card .section-heading { align-items: flex-start; }
.chart-total { color: var(--text); font-size: 24px; font-variant-numeric: tabular-nums; }
.chart-controls { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: flex-end; gap: 12px; }
.chart-controls label { display: grid; gap: 4px; color: var(--muted); font-size: 11px; font-weight: 650; }
.chart-controls select { width: auto; min-width: 118px; min-height: 38px; padding: 7px 10px; font-size: 13px; }
.chart-controls #stockHistoryType { min-width: 84px; }
.line-chart-wrap { position: relative; min-width: 0; }
.line-chart { display: block; width: 100%; min-height: 210px; overflow: visible; }
.chart-grid-line { stroke: var(--line); stroke-width: 1; }
.chart-area { fill: rgba(16, 185, 129, .12); }
.chart-line { fill: none; stroke: var(--accent); stroke-width: 4; stroke-linecap: round; stroke-linejoin: round; }
.chart-point { fill: var(--card); stroke: var(--accent); stroke-width: 3; }
.chart-point-target { outline: none; cursor: help; }
.chart-guide { opacity: 0; stroke: rgba(16, 185, 129, .72); stroke-width: 1; stroke-dasharray: 4 4; pointer-events: none; transition: opacity .15s ease; }
.chart-guide.is-visible { opacity: 1; }
.chart-hit-zones { pointer-events: all; }
.chart-hit-zone { fill: transparent; cursor: crosshair; pointer-events: all; touch-action: pan-y; }
.chart-point-target.is-active .chart-point,
.chart-point-target:focus-visible .chart-point { fill: var(--accent); stroke: #fff; stroke-width: 5; }
.chart-tooltip {
  position: absolute;
  z-index: 3;
  max-width: calc(100% - 16px);
  padding: 7px 9px;
  border: 1px solid rgba(158, 193, 255, .45);
  border-radius: 7px;
  background: var(--card-raised);
  box-shadow: 0 8px 22px rgba(0, 0, 0, .32);
  color: var(--text);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  line-height: 1.25;
  white-space: nowrap;
  pointer-events: none;
  transform: translate(-50%, calc(-100% - 10px));
}
.chart-tooltip.below { transform: translate(-50%, 10px); }
.chart-tooltip[hidden] { display: none; }
.chart-label { fill: var(--muted); font-size: 11px; font-family: "Segoe UI", sans-serif; pointer-events: none; }
.chart-empty { fill: var(--muted); font-size: 14px; font-family: "Segoe UI", sans-serif; }
.status-chart-layout { display: grid; grid-template-columns: 150px 1fr; align-items: center; gap: 20px; min-height: 210px; }
.donut-chart {
  position: relative;
  width: 148px;
  aspect-ratio: 1;
  border-radius: 50%;
  background: conic-gradient(var(--line) 0 100%);
}
.donut-chart::after {
  content: "";
  position: absolute;
  inset: 25px;
  border-radius: 50%;
  background: var(--card);
}
.donut-chart > span {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: grid;
  place-content: center;
  text-align: center;
}
.donut-chart strong { color: var(--text); font-size: 25px; line-height: 1; }
.donut-chart small { margin-top: 4px; color: var(--muted); font-size: 11px; }
.chart-legend { display: grid; gap: 9px; }
.legend-row { display: grid; grid-template-columns: 10px minmax(0, 1fr) auto; align-items: center; gap: 8px; color: var(--muted); font-size: 12px; }
.legend-dot { width: 9px; height: 9px; border-radius: 50%; }
.legend-row strong { color: var(--text); font-variant-numeric: tabular-nums; }

.stock-panel { margin-bottom: 18px; }
.section-heading { margin-bottom: 16px; }
.badge { display: inline-flex; align-items: center; min-height: 28px; padding: 4px 8px; border: 1px solid var(--line); border-radius: 6px; color: var(--muted); font-size: 12px; }
.badge.ok { border-color: rgba(16, 185, 129, .55); color: var(--ok); }
.badge.warn { border-color: rgba(245, 158, 11, .55); color: var(--warn); }
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; min-width: 760px; border-collapse: collapse; font-size: 14px; }
th, td { padding: 12px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
th { color: var(--muted); font-size: 12px; font-weight: 650; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tr:last-child td { border-bottom: 0; }
.status { display: inline-flex; min-width: 86px; justify-content: center; padding: 4px 7px; border-radius: 5px; font-size: 12px; font-weight: 650; }
.status.ok { color: var(--ok); background: rgba(16, 185, 129, .12); }
.status.warning { color: var(--warn); background: rgba(245, 158, 11, .12); }
.status.danger { color: var(--danger); background: rgba(239, 68, 68, .12); }
.status.muted { color: var(--muted); background: rgba(138, 152, 181, .1); }
.empty-state { display: grid; justify-items: start; gap: 4px; padding: 26px 0 4px; color: var(--muted); }
.empty-state strong { color: var(--text); }

.settings-list { display: grid; gap: 10px; margin-bottom: 14px; }
.alert-row { display: grid; grid-template-columns: 1fr 112px; align-items: end; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.alert-row:first-child { padding-top: 0; }
.alert-row:last-child { border-bottom: 0; }
.switch-label { display: flex !important; align-items: center; gap: 8px; margin-bottom: 0 !important; color: var(--text) !important; }
.switch-label input { width: 18px; min-height: 18px; accent-color: var(--accent); }
.alert-row small { display: block; margin-top: 3px; color: var(--muted); font-size: 12px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.danger-zone { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-top: 22px; padding-top: 16px; border-top: 1px solid var(--line); color: var(--muted); font-size: 13px; }

.visually-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

.inventory-management {
  display: grid;
  gap: 18px;
  margin: 0;
}
.inventory-heading { align-items: end; margin: 0; }
.inventory-heading h2 { color: var(--text); font-size: clamp(22px, 3vw, 28px); }
.write-status {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--card);
}
.write-status-dot { width: 10px; height: 10px; flex: 0 0 auto; border-radius: 50%; background: var(--muted); box-shadow: 0 0 0 5px rgba(138, 152, 181, .1); }
.write-status > div { display: grid; gap: 2px; }
.write-status strong { font-size: 14px; }
.write-status span:not(.write-status-dot) { color: var(--muted); font-size: 13px; }
.write-status.active { border-color: rgba(16, 185, 129, .55); background: rgba(16, 185, 129, .07); }
.write-status.active .write-status-dot { background: var(--ok); box-shadow: 0 0 0 5px rgba(16, 185, 129, .12); }
.write-status.paused { border-color: rgba(245, 158, 11, .55); background: rgba(245, 158, 11, .07); }
.write-status.paused .write-status-dot { background: var(--warn); box-shadow: 0 0 0 5px rgba(245, 158, 11, .12); }
.write-status.error { border-color: rgba(239, 68, 68, .65); background: rgba(239, 68, 68, .08); }
.write-status.error .write-status-dot { background: var(--danger); box-shadow: 0 0 0 5px rgba(239, 68, 68, .12); }

.inventory-columns { display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, .95fr); gap: 18px; align-items: start; }
.cabinet-list, .suggestion-list, .group-list { display: grid; gap: 12px; }
.cabinet-card, .suggestion-card, .group-card {
  padding: 15px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #151d2c;
}
.card-heading, .suggestion-top, .group-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.card-title { margin: 0; color: var(--text); font-size: 16px; line-height: 1.3; }
.card-subtitle { display: block; margin-top: 3px; color: var(--muted); font-size: 12px; }
.cabinet-meta { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 12px; color: var(--muted); font-size: 12px; }
.card-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 13px; }
.card-actions .button, .suggestion-card > .button { min-height: 38px; padding: 8px 11px; }
.inline-error { margin: 10px 0 0; color: var(--danger); font-size: 12px; overflow-wrap: anywhere; }
.cabinet-form { display: grid; gap: 11px; margin-top: 17px; padding-top: 17px; border-top: 1px solid var(--line); }
.cabinet-form .button { justify-self: start; }
.empty-state.compact { padding: 10px 0 2px; font-size: 13px; }

.suggestion-card { display: grid; gap: 12px; }
.suggestion-quantity { display: grid; justify-items: end; flex: 0 0 auto; }
.suggestion-quantity strong { color: var(--accent); font-size: 25px; font-variant-numeric: tabular-nums; line-height: 1; }
.suggestion-quantity span { color: var(--muted); font-size: 11px; }
.suggestion-card > .button { justify-self: start; }

.manual-group-panel, .group-panel, .event-panel { min-width: 0; }
.catalog-scroll { max-height: 390px; border: 1px solid var(--line); border-radius: 9px; }
.catalog-table { min-width: 780px; }
.catalog-table th { position: sticky; top: 0; z-index: 1; background: var(--card-raised); }
.catalog-table .select-cell { width: 42px; text-align: center; }
.catalog-table input[type="checkbox"] { width: 18px; min-height: 18px; padding: 0; accent-color: var(--accent); }
.catalog-table input[type="checkbox"][disabled] { opacity: .38; }
.row-note { display: block; margin-top: 2px; color: var(--accent); font-size: 10px; }
.fbs-stock-panel { min-width: 0; }
.fbs-stock-toolbar { display: grid; grid-template-columns: minmax(210px, .7fr) minmax(280px, 1.3fr); gap: 12px; margin-bottom: 14px; }
.stock-filter-field { display: grid; min-width: 0; gap: 6px; }
.stock-filter-field > span { color: var(--muted); font-size: 12px; font-weight: 650; }
.fbs-stock-scroll { max-height: 520px; border: 1px solid var(--line); border-radius: 9px; }
.fbs-stock-table { min-width: 980px; }
.fbs-stock-table th { position: sticky; top: 0; z-index: 2; background: var(--card-raised); }
.fbs-stock-table td { vertical-align: middle; }
.fbs-stock-identity strong { display: block; max-width: 210px; overflow: hidden; color: var(--text); text-overflow: ellipsis; white-space: nowrap; }
.fbs-stock-identity small, .fbs-stock-link small { display: block; max-width: 210px; margin-top: 3px; overflow: hidden; color: var(--muted); font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
.fbs-stock-link .status { min-width: 72px; }
.fbs-stock-current { color: var(--text); font-size: 15px; font-weight: 700; font-variant-numeric: tabular-nums; }
.fbs-stock-input-cell { width: 134px; }
.fbs-stock-input { width: 112px; min-height: 38px; padding: 7px 9px; font-variant-numeric: tabular-nums; }
.fbs-stock-action-cell { width: 190px; }
.fbs-stock-action { display: grid; min-width: 170px; gap: 6px; }
.fbs-stock-apply { width: 100%; min-height: 38px; padding: 8px 11px; }
.fbs-stock-status { min-height: 16px; margin: 0; font-size: 10px; line-height: 1.3; }
.fbs-stock-status:empty { min-height: 0; padding-left: 0; }
.fbs-stock-status:empty::before { display: none; }
.fbs-stock-row.stock-applied > td { animation: fbs-stock-success .9s ease both; }
@keyframes fbs-stock-success {
  0%, 100% { background: transparent; }
  45% { background: rgba(16, 185, 129, .13); }
}
.fbs-stock-more { display: flex; justify-content: center; padding-top: 14px; }
.fbs-stock-more[hidden] { display: none; }
.manual-group-panel form { display: grid; gap: 15px; }
.link-builder-stage {
  display: grid;
  gap: 14px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: rgba(15, 22, 35, .55);
}
.link-stage-heading { display: flex; align-items: center; gap: 11px; }
.link-stage-heading > div { min-width: 0; }
.link-stage-heading h3 { margin: 0; color: var(--text); font-size: 16px; }
.link-stage-heading p { margin: 2px 0 0; color: var(--muted); font-size: 12px; }
.link-step {
  display: inline-grid;
  width: 30px;
  height: 30px;
  flex: 0 0 30px;
  place-items: center;
  border-radius: 50%;
  background: var(--accent);
  color: var(--text-on-accent);
  font-size: 13px;
  font-weight: 750;
  box-shadow: 0 0 0 5px rgba(16, 185, 129, .12);
}
.link-target-stage.revealed { animation: link-stage-in .32s ease both; }
@keyframes link-stage-in {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}
.link-cabinet-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(280px, 100%), 1fr)); gap: 12px; align-items: stretch; }
.link-cabinet-grid.horizontal-scroll {
  grid-template-columns: none;
  grid-auto-flow: column;
  grid-auto-columns: min(440px, calc(100vw - 72px));
  overflow-x: auto;
  overflow-y: hidden;
  overscroll-behavior-inline: contain;
  scroll-padding-inline: 2px;
  scroll-snap-type: inline proximity;
  padding: 2px 2px 10px;
}
.link-cabinet-grid.horizontal-scroll > .link-cabinet-card { scroll-snap-align: start; }
.link-cabinet-card {
  display: grid;
  grid-template-rows: auto auto minmax(132px, 1fr) auto;
  min-width: 0;
  max-height: 475px;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #151d2c;
  transition: opacity .2s ease, border-color .2s ease, box-shadow .2s ease, transform .2s ease, filter .2s ease;
}
.link-cabinet-card.has-selection { border-color: rgba(16, 185, 129, .75); box-shadow: 0 0 0 3px rgba(16, 185, 129, .1); transform: translateY(-2px); }
.link-cabinet-card.inactive { opacity: .43; filter: grayscale(.72); }
.link-cabinet-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 9px; margin-bottom: 10px; }
.link-cabinet-heading h4 { margin: 0; color: var(--text); font-size: 14px; overflow-wrap: anywhere; }
.link-cabinet-heading div > span { display: block; margin-top: 2px; color: var(--muted); font-size: 11px; }
.link-selection-badge { flex: 0 0 auto; padding: 3px 6px; border-radius: 5px; background: rgba(138, 152, 181, .1); color: var(--muted); font-size: 10px; font-weight: 650; }
.link-selection-badge.selected { background: rgba(16, 185, 129, .12); color: var(--ok); }
.link-cabinet-search { min-height: 38px; margin-bottom: 9px; padding: 8px 10px; font-size: 12px; }
.link-sku-list { display: grid; align-content: start; gap: 6px; min-height: 132px; overflow: auto; overscroll-behavior: contain; padding-right: 3px; }
.link-sku-option {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto 24px;
  align-items: center;
  gap: 9px;
  width: 100%;
  min-height: 56px;
  padding: 8px 9px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: rgba(15, 22, 35, .75);
  color: var(--text);
  text-align: left;
  transition: background-color .16s ease, border-color .16s ease, transform .16s ease;
}
.link-sku-option:not(:disabled):hover { border-color: var(--line); background: var(--card-raised); transform: translateX(2px); }
.link-sku-option.selected { border-color: rgba(16, 185, 129, .72); background: var(--accent-soft); }
.link-sku-option.linked { cursor: not-allowed; opacity: .42; }
.link-sku-copy { display: grid; min-width: 0; }
.link-sku-copy strong { overflow: hidden; font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.link-sku-copy small { overflow: hidden; color: var(--muted); font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
.link-sku-stock { display: grid; justify-items: end; min-width: 38px; font-variant-numeric: tabular-nums; }
.link-sku-stock strong { font-size: 13px; }
.link-sku-stock small { color: var(--muted); font-size: 9px; }
.link-sku-check { display: inline-grid; width: 22px; height: 22px; place-items: center; border: 1px solid var(--line); border-radius: 50%; color: var(--muted); font-size: 13px; }
.link-sku-option.selected .link-sku-check { border-color: var(--accent); background: var(--accent); color: var(--text-on-accent); }
.link-no-results { margin: 12px 4px; color: var(--muted); font-size: 12px; }
.link-cabinet-footer { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 25px; padding-top: 7px; color: var(--muted); font-size: 10px; }
.link-load-more { padding: 3px 0; border: 0; background: transparent; color: var(--accent); font-size: 11px; }
.link-builder-summary { display: flex; align-items: center; justify-content: space-between; gap: 15px; padding: 13px 15px; border: 1px solid rgba(16, 185, 129, .36); border-radius: 9px; background: var(--accent-soft); }
.link-builder-summary > div { display: grid; min-width: 0; gap: 2px; }
.link-summary-label { color: var(--muted); font-size: 10px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; }
.link-builder-summary strong { overflow-wrap: anywhere; font-size: 13px; }
.link-summary-stock { flex: 0 0 auto; color: #b9d1ff; font-size: 12px; font-weight: 650; }
.manual-group-controls { display: grid; grid-template-columns: minmax(220px, 1fr) auto; align-items: end; gap: 12px; }

.group-list { grid-template-columns: minmax(0, 1fr); }
.group-card { display: grid; gap: 14px; min-width: 0; transition: border-color .22s ease, box-shadow .22s ease, transform .22s ease; }
.group-card.enabled { border-color: rgba(16, 185, 129, .55); }
.group-card.just-created { border-color: var(--ok); box-shadow: 0 0 0 5px rgba(16, 185, 129, .12); transform: translateY(-3px); }
.group-card.stock-applied { animation: stock-card-success .75s ease both; }
@keyframes stock-card-success {
  0%, 100% { border-color: rgba(16, 185, 129, .55); box-shadow: none; }
  45% { border-color: var(--ok); box-shadow: 0 0 0 6px rgba(16, 185, 129, .15); }
}
.group-quantity { display: flex; align-items: baseline; gap: 7px; padding: 13px 14px; border-radius: 8px; background: var(--accent-soft); }
.group-quantity > span { margin-right: auto; color: var(--muted); font-size: 12px; }
.group-quantity strong { color: var(--text); font-size: 30px; font-variant-numeric: tabular-nums; line-height: 1; }
.group-quantity small { color: var(--muted); }
.member-list { display: grid; gap: 7px; margin: 0; padding: 0; list-style: none; }
.member-list li { display: flex; justify-content: space-between; gap: 12px; padding-bottom: 7px; border-bottom: 1px solid rgba(42, 53, 80, .75); color: var(--muted); font-size: 12px; }
.member-list li:last-child { padding-bottom: 0; border-bottom: 0; }
.member-list li strong { flex: 0 0 auto; color: var(--text); font-variant-numeric: tabular-nums; }
.member-list.compact-list li { display: list-item; padding: 0 0 0 13px; border: 0; position: relative; }
.member-list.compact-list li::before { position: absolute; left: 0; content: "•"; color: var(--accent); }
.last-event { display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; padding-top: 11px; border-top: 1px solid var(--line); }
.last-event > span { grid-column: 1 / -1; color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .04em; }
.last-event strong { min-width: 0; font-size: 12px; font-weight: 600; overflow-wrap: anywhere; }
.last-event time { color: var(--muted); font-size: 11px; white-space: nowrap; }
.group-stock-editor { padding: 15px; border: 1px solid var(--line); border-radius: 10px; background: rgba(15, 22, 35, .62); }
.stock-editor-heading { display: flex; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.stock-editor-heading h4 { margin: 0; color: var(--text); font-size: 14px; }
.stock-editor-heading p { margin: 2px 0 0; color: var(--muted); font-size: 12px; }
.stock-editor-form { display: grid; gap: 9px; }
.stock-editor-grid { display: grid; grid-template-columns: minmax(240px, 1.3fr) minmax(130px, .55fr) minmax(155px, .7fr) auto; align-items: end; gap: 10px; }
.stock-editor-field { display: grid; gap: 5px; min-width: 0; }
.stock-editor-field > span, .stock-source-current > span { color: var(--muted); font-size: 11px; font-weight: 650; }
.stock-editor-field select, .stock-editor-field input { min-height: 42px; font-size: 13px; }
.stock-source-current { display: grid; min-height: 64px; align-content: center; justify-items: start; padding: 8px 11px; border: 1px solid var(--line); border-radius: 8px; background: var(--card); }
.stock-source-current strong { color: var(--text); font-size: 19px; font-variant-numeric: tabular-nums; }
.stock-apply-button { min-height: 42px; white-space: nowrap; }
.stock-apply-status { position: relative; min-height: 18px; margin: 0; padding-left: 18px; color: var(--muted); font-size: 11px; }
.stock-apply-status::before { position: absolute; top: 4px; left: 2px; width: 8px; height: 8px; border-radius: 50%; background: var(--muted); content: ""; }
.stock-apply-status.manual { color: #b9d1ff; }
.stock-apply-status.manual::before { background: var(--accent); }
.stock-apply-status.pending { color: var(--warn); }
.stock-apply-status.pending::before { top: 2px; width: 10px; height: 10px; border: 2px solid rgba(245, 158, 11, .25); border-top-color: var(--warn); background: transparent; animation: stock-status-spin .75s linear infinite; }
.stock-apply-status.success { color: var(--ok); font-weight: 650; }
.stock-apply-status.success::before { background: var(--ok); box-shadow: 0 0 0 4px rgba(16, 185, 129, .11); }
.stock-apply-status.local, .stock-apply-status.queued { color: var(--warn); }
.stock-apply-status.local::before, .stock-apply-status.queued::before { background: var(--warn); }
.stock-apply-status.error { color: var(--danger); }
.stock-apply-status.error::before { background: var(--danger); }
@keyframes stock-status-spin { to { transform: rotate(360deg); } }
.group-controls { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 8px; }
.quantity-form { display: flex; min-width: 0; gap: 7px; }
.quantity-form input { width: 86px; flex: 0 0 86px; min-height: 40px; }
.quantity-form .button, .group-controls > .button { min-height: 40px; padding: 8px 10px; }
.button.danger.confirming { border-color: var(--danger); background: rgba(239, 68, 68, .12); }

.event-list { display: grid; }
.event-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 11px 0; border-bottom: 1px solid var(--line); }
.event-row:first-child { padding-top: 0; }
.event-row:last-child { padding-bottom: 0; border-bottom: 0; }
.event-row > div:first-child { display: grid; gap: 2px; min-width: 0; }
.event-row strong { font-size: 13px; font-weight: 650; overflow-wrap: anywhere; }
.event-row span:not(.status) { color: var(--muted); font-size: 12px; }
.event-side { display: grid; justify-items: end; flex: 0 0 auto; gap: 5px; }
.event-side time { color: var(--muted); font-size: 11px; white-space: nowrap; }

/* Ручной компактный просмотр повторяет телефонную иерархию на широком экране.
   Это сохраняет привычный переключатель из wb-profit-bot и удобен при тесте. */
body.manual-mobile .nav { flex-wrap: wrap; padding: 4px 12px; }
body.manual-mobile .nav-toggle { display: inline-flex; align-items: center; justify-content: center; min-height: 40px; margin-left: auto; padding: 0 10px; border: 1px solid var(--line); border-radius: 8px; background: transparent; color: var(--text); }
body.manual-mobile .nav-links { display: none; flex-direction: column; align-items: stretch; width: 100%; margin: 0; padding-bottom: 8px; }
body.manual-mobile .nav-links.open { display: flex; }
body.manual-mobile .nav-tab, body.manual-mobile .link-button { min-height: 42px; padding: 0 8px; border-bottom: 1px solid var(--line); text-align: left; }
body.manual-mobile main { width: min(680px, 100%); padding: 16px 12px 28px; }
body.manual-mobile .page-heading, body.manual-mobile .notice, body.manual-mobile .danger-zone { align-items: stretch; flex-direction: column; }
body.manual-mobile .heading-actions { justify-items: stretch; }
body.manual-mobile .analytics-grid { grid-template-columns: 1fr; }
body.manual-mobile .dashboard-context { gap: 5px; margin-bottom: 6px; font-size: 18px; }
body.manual-mobile .cabinet-switcher { max-width: calc(100% - 104px); }
body.manual-mobile .page-heading .button, body.manual-mobile .notice .button, body.manual-mobile .danger-zone .button { width: 100%; }
body.manual-mobile .onboarding { grid-template-columns: 1fr; }
body.manual-mobile .summary-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
body.manual-mobile .metric { min-height: 112px; padding: 14px; }
body.manual-mobile .metric strong { font-size: 25px; }
body.manual-mobile .inventory-heading, body.manual-mobile .write-status { align-items: stretch; flex-direction: column; }
body.manual-mobile .inventory-heading .button { width: 100%; }
body.manual-mobile .inventory-columns, body.manual-mobile .group-list { grid-template-columns: 1fr; }
body.manual-mobile .fbs-stock-toolbar { grid-template-columns: 1fr; }
body.manual-mobile .manual-group-controls, body.manual-mobile .group-controls { display: grid; grid-template-columns: 1fr; }
body.manual-mobile .quantity-form input { width: 90px; flex-basis: 90px; }
body.manual-mobile .link-cabinet-grid, body.manual-mobile .stock-editor-grid { grid-template-columns: 1fr; }
body.manual-mobile .link-cabinet-grid.horizontal-scroll { grid-template-columns: none; grid-auto-columns: min(360px, calc(100vw - 90px)); }
body.manual-mobile .link-cabinet-card.inactive { grid-template-rows: auto; max-height: none; }
body.manual-mobile .link-cabinet-card.inactive .link-cabinet-search,
body.manual-mobile .link-cabinet-card.inactive .link-sku-list,
body.manual-mobile .link-cabinet-card.inactive .link-cabinet-footer { display: none; }
body.manual-mobile .link-cabinet-card.inactive .link-cabinet-heading { margin-bottom: 0; }
body.manual-mobile .link-builder-summary, body.manual-mobile .link-stage-heading { align-items: stretch; flex-direction: column; }
body.manual-mobile .link-step { align-self: flex-start; }
body.manual-mobile .group-controls > .button, body.manual-mobile .stock-apply-button { width: 100%; }
body.manual-mobile .supply-filter-grid, body.manual-mobile .supply-period-grid { grid-template-columns: 1fr; }
body.manual-mobile .supply-filter-popover { right: auto; left: 0; width: 100%; max-width: calc(100vw - 54px); }
body.manual-mobile .supply-summary-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
body.manual-mobile .supply-submit { width: 100%; margin-bottom: 0; }
body.manual-mobile .supply-table-scroll { overflow-x: visible; }
body.manual-mobile .supply-table { display: block; min-width: 0; }
body.manual-mobile .supply-table > thead { display: none; }
body.manual-mobile .supply-table > tbody { display: grid; gap: 12px; }
body.manual-mobile .supply-table > tbody > tr { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); padding: 12px; border: 1px solid var(--line); border-radius: 9px; background: #151d2c; }
body.manual-mobile .supply-table > tbody > tr > td { display: grid; gap: 3px; padding: 8px; border-bottom: 1px solid rgba(42, 53, 80, .75); text-align: left; }
body.manual-mobile .supply-table > tbody > tr > td::before { color: var(--muted); font-size: 10px; font-weight: 600; content: attr(data-label); }
body.manual-mobile .supply-table > tbody > tr > td:first-child, body.manual-mobile .supply-table > tbody > tr > td:nth-child(7), body.manual-mobile .supply-table > tbody > tr > td:nth-child(8) { grid-column: 1 / -1; }
body.manual-mobile .supply-table > tbody > tr > td:last-child { border-bottom: 0; }
body.manual-mobile .supply-result-heading { align-items: stretch; flex-direction: column; }
body.manual-mobile .supply-result-heading .button { width: 100%; }
body.manual-mobile .supply-size-detail-row { grid-template-columns: 1fr !important; padding: 0 !important; background: transparent !important; }
body.manual-mobile .supply-size-detail-row > td { display: block !important; grid-column: 1 / -1; padding: 0 !important; border: 0 !important; }
body.manual-mobile .supply-size-detail-row > td::before { content: none !important; }
body.manual-mobile .supply-size-table-scroll { overflow-x: visible; }
body.manual-mobile .supply-size-table { display: block; min-width: 0; }
body.manual-mobile .supply-size-table thead { display: none; }
body.manual-mobile .supply-size-table tbody { display: grid; gap: 8px; }
body.manual-mobile .supply-size-table tr { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); padding: 8px; border: 1px solid var(--line); border-radius: 8px; background: var(--card); }
body.manual-mobile .supply-size-table td { display: grid; gap: 2px; padding: 7px; border-bottom: 1px solid rgba(42, 53, 80, .65); text-align: left; }
body.manual-mobile .supply-size-table td::before { color: var(--muted); font-size: 11px; font-weight: 600; content: attr(data-label); }
body.manual-mobile .supply-size-table td:first-child, body.manual-mobile .supply-size-table td:nth-child(9), body.manual-mobile .supply-size-table td:nth-child(10) { grid-column: 1 / -1; }
body.manual-mobile .supply-recommendation-stack { justify-items: start; }
body.manual-mobile .supply-partial-note { max-width: none; text-align: left; }
body.manual-mobile .supply-unavailable { max-width: none; text-align: left; }
body.manual-mobile .supply-more .button { width: 100%; }

@media (max-width: 820px) {
  .summary-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .onboarding, .inventory-columns, .group-list, .analytics-grid { grid-template-columns: 1fr; }
  .stock-editor-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stock-editor-field:first-child { grid-column: 1 / -1; }
  .stock-apply-button { width: 100%; }
  .supply-filter-grid, .supply-period-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .supply-article-filter { grid-column: auto; }
  .supply-submit { width: 100%; margin-bottom: 0; }
  .supply-summary-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 680px) {
  body.mobile main, main { padding: 16px 12px calc(28px + env(safe-area-inset-bottom)); }
  .topbar { padding-top: env(safe-area-inset-top); }
  .nav { min-height: 54px; padding: 0 12px; flex-wrap: wrap; }
  .brand img { max-width: 170px; height: 34px; }
  .nav-toggle { display: inline-flex; align-items: center; justify-content: center; min-height: 40px; margin-left: auto; padding: 0 10px; border: 1px solid var(--line); border-radius: 8px; background: transparent; color: var(--text); font-size: 14px; }
  .nav-links { display: none; flex-direction: column; align-items: stretch; width: 100%; margin: 0; padding-bottom: 8px; }
  .nav-links.open { display: flex; }
  .nav-tab, .link-button { min-height: 42px; padding: 0 8px; border-bottom: 1px solid var(--line); text-align: left; }
  .link-button { display: none; }
  .page-heading { display: grid; gap: 12px; }
  .dashboard-context { gap: 5px; margin-bottom: 6px; font-size: 18px; }
  .cabinet-switcher { max-width: calc(100% - 104px); }
  .chart-card .section-heading { align-items: stretch; flex-direction: column; }
  .chart-controls { align-items: center; justify-content: space-between; }
  .heading-actions { justify-items: stretch; }
  .page-heading .button { width: 100%; }
  .panel { padding: 15px; border-radius: 10px; }
  .input-action { display: grid; }
  .summary-grid { gap: 10px; }
  .metric { min-height: 112px; padding: 14px; }
  .metric strong { font-size: 25px; }
  .status-chart-layout { grid-template-columns: 130px 1fr; gap: 14px; }
  .donut-chart { width: 128px; }
  .notice { align-items: stretch; flex-direction: column; }
  .notice .button { width: 100%; }
  .danger-zone { align-items: stretch; flex-direction: column; }
  .danger-zone .button { width: 100%; }
  .inventory-heading { align-items: stretch; flex-direction: column; }
  .inventory-heading .button { width: 100%; }
  .write-status { align-items: flex-start; }
  .fbs-stock-toolbar { grid-template-columns: 1fr; }
  .cabinet-form .form-row, .manual-group-controls, .group-controls { display: grid; grid-template-columns: 1fr; }
  .cabinet-form .button, .manual-group-controls .button, .group-controls > .button { width: 100%; }
  .link-cabinet-grid, .stock-editor-grid { grid-template-columns: 1fr; }
  .link-cabinet-grid.horizontal-scroll { grid-template-columns: none; grid-auto-columns: min(360px, calc(100vw - 90px)); }
  .stock-editor-field:first-child { grid-column: auto; }
  .link-builder-summary { align-items: flex-start; flex-direction: column; }
  .link-summary-stock { flex-basis: auto; }
  .link-stage-heading { align-items: flex-start; flex-wrap: wrap; }
  .link-stage-heading > div { flex: 1 1 calc(100% - 44px); }
  .link-cabinet-card { max-height: 430px; }
  .link-cabinet-card.inactive { grid-template-rows: auto; max-height: none; }
  .link-cabinet-card.inactive .link-cabinet-search,
  .link-cabinet-card.inactive .link-sku-list,
  .link-cabinet-card.inactive .link-cabinet-footer { display: none; }
  .link-cabinet-card.inactive .link-cabinet-heading { margin-bottom: 0; }
  .quantity-form input { width: 90px; flex-basis: 90px; }
  .quantity-form .button { flex: 1 1 auto; }
  .event-row { align-items: flex-start; }
  .supply-form-heading { align-items: stretch; flex-direction: column; }
  .supply-result-heading { align-items: stretch; flex-direction: column; }
  .supply-result-heading .button { width: 100%; }
  .supply-reset { width: 100%; }
  .supply-filter-grid, .supply-period-grid { grid-template-columns: 1fr; }
  .supply-article-filter { grid-column: auto; }
  .supply-filter-popover { right: auto; left: 0; width: 100%; max-width: calc(100vw - 54px); }
  .supply-field .field-hint { min-height: 0; }
  .supply-status { align-items: flex-start; }
  .supply-summary-grid { gap: 10px; }
  .supply-metric { min-height: 112px; padding: 14px; }
  .supply-metric strong { font-size: 25px; }
  .supply-table-scroll { overflow-x: visible; }
  .supply-table { display: block; min-width: 0; }
  .supply-table > thead { display: none; }
  .supply-table > tbody { display: grid; gap: 12px; }
  .supply-table > tbody > tr { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); padding: 12px; border: 1px solid var(--line); border-radius: 9px; background: #151d2c; }
  .supply-table > tbody > tr > td { display: grid; gap: 3px; padding: 8px; border-bottom: 1px solid rgba(42, 53, 80, .75); text-align: left; }
  .supply-table > tbody > tr > td::before { color: var(--muted); font-size: 10px; font-weight: 600; content: attr(data-label); }
  .supply-table > tbody > tr > td:first-child, .supply-table > tbody > tr > td:nth-child(7), .supply-table > tbody > tr > td:nth-child(8) { grid-column: 1 / -1; }
  .supply-table > tbody > tr > td:last-child { border-bottom: 0; }
  .supply-size-detail-row { grid-template-columns: 1fr !important; padding: 0 !important; background: transparent !important; }
  .supply-size-detail-row > td { display: block !important; grid-column: 1 / -1; padding: 0 !important; border: 0 !important; }
  .supply-size-detail-row > td::before { content: none !important; }
  .supply-size-details { padding: 11px; }
  .supply-size-table-scroll { overflow-x: visible; }
  .supply-size-table { display: block; min-width: 0; }
  .supply-size-table thead { display: none; }
  .supply-size-table tbody { display: grid; gap: 8px; }
  .supply-size-table tr { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); padding: 8px; border: 1px solid var(--line); border-radius: 8px; background: var(--card); }
  .supply-size-table td { display: grid; gap: 2px; padding: 7px; border-bottom: 1px solid rgba(42, 53, 80, .65); text-align: left; }
  .supply-size-table td::before { color: var(--muted); font-size: 11px; font-weight: 600; content: attr(data-label); }
  .supply-size-table td:first-child, .supply-size-table td:nth-child(9), .supply-size-table td:nth-child(10) { grid-column: 1 / -1; }
  .supply-recommendation-stack { justify-items: start; }
  .supply-partial-note { max-width: none; text-align: left; }
  .supply-unavailable { max-width: none; text-align: left; }
  .supply-more .button { width: 100%; }
  /* В Mini App важнее принять решение, чем увидеть весь набор складских
     разрезов. Убираем второстепенные колонки, чтобы «до нуля» и статус не
     уезжали за горизонтальный свайп. Полная таблица остаётся на ПК. */
  .stock-panel .table-scroll { overflow-x: visible; }
  .stock-table { min-width: 0; font-size: 13px; }
  .stock-table th, .stock-table td { padding: 10px 6px; }
  .stock-table th:nth-child(2), .stock-table td:nth-child(2),
  .stock-table th:nth-child(3), .stock-table td:nth-child(3),
  .stock-table th:nth-child(5), .stock-table td:nth-child(5) { display: none; }
  .stock-table th:nth-child(1), .stock-table td:nth-child(1) { max-width: 118px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .catalog-scroll { overflow-x: auto; }
  .catalog-table th, .catalog-table td { padding: 10px 8px; }
  .status { min-width: 0; padding: 4px 5px; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { transition-duration: .01ms !important; animation-duration: .01ms !important; }
}
