/* MOAM UI — планировщик WB (единая система с админкой раздач) */
@import url("https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap");

:root {
  --font-sans: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --text: #0f172a;
  --text-muted: #475569;
  --surface: #ffffff;
  --surface-subtle: #f8fafc;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --secondary: #7c3aed;
  --primary-gradient: linear-gradient(135deg, #2563eb 0%, #7c3aed 100%);
  --primary-soft: #eff6ff;
  --primary-text: #1e3a8a;
  --success: #059669;
  --success-bg: #ecfdf5;
  --danger: #dc2626;
  --danger-bg: #fef2f2;
  --radius: 20px;
  --radius-sm: 12px;
  --shadow: 0 4px 12px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.04);
  --control-h: 42px;
  --space-1: 6px;
  --space-2: 10px;
  --space-3: 16px;
  --space-4: 24px;
  --focus: 0 0 0 3px rgba(37, 99, 235, 0.25);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.5;
  background:
    radial-gradient(1200px 500px at 10% -10%, rgba(37, 99, 235, 0.15), transparent 65%),
    radial-gradient(900px 450px at 90% -15%, rgba(124, 58, 237, 0.14), transparent 62%),
    linear-gradient(180deg, #f5f7ff 0%, #f8fafc 100%);
  color: var(--text);
  min-height: 100vh;
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
}

.container {
  max-width: 1400px;
  margin: 0 auto;
  padding: var(--space-4) var(--space-3);
}

/* ——— Единая панель: поиск + сортировка + показ столбцов ——— */
:root {
  --table-toolbar-h: 38px;
  --sticky-cat-w: 118px;
  --sticky-photo-w: 58px;
}

.table-toolbar {
  margin-bottom: 8px;
}

.aggrid-beta-wrap {
  margin: 10px 0 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px;
  background: #fff;
  position: relative;
}

.aggrid-beta-head {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: flex-start;
  gap: 8px;
  margin-bottom: 8px;
}

.aggrid-beta-actions-wrap {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  width: 100%;
}

.aggrid-beta-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.aggrid-beta-actions--secondary {
  margin-top: 6px;
}

.aggrid-beta-actions--right {
  justify-content: flex-end;
}

.warehouse-ref-ag-wrap .aggrid-beta-head {
  margin-bottom: 0;
}

.warehouse-ref-ag-wrap .ref-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}

.warehouse-ref-ag-wrap .warehouse-ref-tab-btn {
  position: relative;
  border-left: 3px solid transparent;
}

.warehouse-ref-ag-wrap .warehouse-ref-tab-btn.active {
  background: #eff6ff;
  color: #1d4ed8;
  border-color: #bfdbfe;
  border-left-color: #2563eb;
  box-shadow: inset 3px 0 0 #2563eb;
}

.warehouse-ref-ag-wrap .ref-actions {
  padding: 12px 16px;
  margin-top: 12px;
  margin-bottom: 12px;
  margin-left: 0;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  align-items: flex-start !important;
}

.warehouse-ref-ag-wrap .ref-actions .aggrid-beta-actions {
  gap: 16px;
  align-items: center;
  justify-content: flex-start !important;
  margin-left: 0 !important;
  width: 100%;
}

.warehouse-ref-okrug-filter {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text-muted);
}

.warehouse-ref-okrug-filter .okrug-filter-select {
  min-height: 36px;
}

.warehouse-ref-okrug-filter .okrug-filter-select.is-placeholder {
  color: #94a3b8;
}

.warehouse-ref-ag-wrap .aggrid-beta-actions-wrap {
  padding-left: 16px;
  padding-right: 16px;
  align-items: flex-start !important;
}

.warehouse-ref-ag-wrap .ref-actions,
.warehouse-ref-ag-wrap .ref-actions * {
  text-align: left;
}

.cabinet-current-inline {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.cabinet-switch-select {
  width: 100px;
  height: 32px;
  min-height: 32px;
  max-width: 100%;
  border: 1px solid #c7d2e3;
  border-radius: 8px;
  padding: 0 10px;
  font-size: 13px;
  line-height: 1.2;
}

.settings-planning-form {
  max-width: 720px;
}

.settings-planning-grid {
  display: grid;
  grid-template-columns: repeat(2, 300px);
  gap: 14px 18px;
}

.settings-planning-check {
  justify-self: start;
  align-self: start;
  display: flex;
  align-items: center;
}

.settings-planning-grid > label {
  width: 300px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0;
}

.settings-planning-grid > label > input,
.settings-planning-grid > label > select {
  width: 300px;
}

.settings-planning-label {
  display: block;
  min-height: auto;
  line-height: 1.2;
  white-space: nowrap;
  margin-bottom: 0;
}

.settings-planning-save {
  margin-top: 20px;
  width: 300px;
}

.settings-planning-grid > .settings-planning-check {
  flex-direction: column !important;
  justify-content: flex-start !important;
  align-items: flex-start !important;
  gap: 0 !important;
  width: 300px;
  padding: 0;
  margin: 0;
  box-sizing: border-box;
  text-align: left;
}

.settings-checkbox-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  width: 100%;
  margin-top: 8px;
}
.settings-checkbox-row input[type="checkbox"] {
  margin: 0;
  flex-shrink: 0;
}
.cancel-rate-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  background: #f1f5f9;
  color: #475569;
  font-size: 12px;
  font-weight: 600;
}
.cancel-rate-chip .muted {
  font-weight: 400;
  color: #94a3b8;
}
.cancel-rate-chip--mid {
  background: #fef3c7;
  color: #92400e;
}
.cancel-rate-chip--high {
  background: #fee2e2;
  color: #991b1b;
}

.settings-planning-check-box {
  width: 300px;
  height: 42px;
  min-height: 42px;
  max-height: 42px;
  display: flex;
  flex-direction: row;
  justify-content: flex-start;
  align-items: center;
  gap: 8px;
  padding: 0 10px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  box-sizing: border-box;
}

.settings-planning-check-box > input[type="checkbox"] {
  margin: 0 !important;
  flex: 0 0 auto;
}

.settings-planning-check-text {
  display: flex;
  flex-direction: column;
  gap: 0;
  line-height: 1.2;
  white-space: normal;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

.settings-planning-check-text > span {
  display: block;
}

.settings-tab-content[data-settings-tab-panel="settings-api"] .api-settings-layout {
  max-width: 720px;
  gap: 14px;
}

.settings-tab-content[data-settings-tab-panel="settings-api"] .api-row {
  display: grid;
  grid-template-columns: repeat(2, 300px);
  gap: 14px 18px;
  align-items: end;
}

.settings-tab-content[data-settings-tab-panel="settings-api"] .api-row > label,
.settings-tab-content[data-settings-tab-panel="settings-api"] .settings-zone > label {
  width: 300px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0;
}

.settings-tab-content[data-settings-tab-panel="settings-api"] .api-row > label > input,
.settings-tab-content[data-settings-tab-panel="settings-api"] .settings-zone > label > select,
.settings-tab-content[data-settings-tab-panel="settings-api"] .settings-zone > label > input {
  width: 300px;
}

.settings-tab-content[data-settings-tab-panel="settings-api"] .fixed-btn {
  width: 300px;
}

.settings-tab-content[data-settings-tab-panel="settings-api"] .settings-zone > label {
  margin-top: 14px;
}

.aggrid-columns-popover {
  position: absolute;
  right: 10px;
  top: 44px;
  z-index: 30;
  background: #fff;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  box-shadow: var(--shadow-md);
  padding: 8px 10px;
  max-height: 320px;
  overflow: auto;
  min-width: 240px;
}

.proc-settings-upload-row {
  margin-bottom: 10px;
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: nowrap;
}

.proc-settings-upload-row input[type="file"] {
  flex: 0 0 300px;
  width: 300px;
  min-width: 300px;
  max-width: 300px;
}

.proc-settings-upload-row button {
  margin-left: auto;
  white-space: nowrap;
}

@media (max-width: 680px) {
  .proc-settings-upload-row {
    flex-wrap: wrap;
  }

  .proc-settings-upload-row input[type="file"] {
    flex: 1 1 100%;
    width: 100%;
    min-width: 0;
    max-width: none;
  }
}

.ag-col-choice {
  display: block;
  font-size: 13px;
  margin: 4px 0;
}

.proc-panel-subtitle {
  margin: 2px 0 14px;
  font-size: 13px;
}

.section-subtitle {
  margin-top: -4px;
  margin-bottom: 12px;
  font-size: 13px;
}

.main-tab-content:not(.summary-redesign) .side-nav .settings-tab-btn,
.main-tab-content:not(.summary-redesign) .side-nav .local-tab-btn,
.main-tab-content:not(.summary-redesign) .side-nav .proc-tab-btn {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  text-align: left;
  min-height: 62px;
  padding: 10px 12px;
}

.main-tab-content:not(.summary-redesign) .side-nav .settings-tab-btn .subtab-icon,
.main-tab-content:not(.summary-redesign) .side-nav .local-tab-btn .subtab-icon,
.main-tab-content:not(.summary-redesign) .side-nav .proc-tab-btn .subtab-icon {
  font-size: 16px;
  line-height: 1.1;
  margin-top: 1px;
}

.main-tab-content:not(.summary-redesign) .side-nav .settings-tab-btn .subtab-copy,
.main-tab-content:not(.summary-redesign) .side-nav .local-tab-btn .subtab-copy,
.main-tab-content:not(.summary-redesign) .side-nav .proc-tab-btn .subtab-copy {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.main-tab-content:not(.summary-redesign) .side-nav .settings-tab-btn .subtab-title,
.main-tab-content:not(.summary-redesign) .side-nav .local-tab-btn .subtab-title,
.main-tab-content:not(.summary-redesign) .side-nav .proc-tab-btn .subtab-title {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 600;
}

.subtab-help {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  border-radius: 999px;
  border: 1px solid #94a3b8;
  color: #64748b;
  background: #fff;
  font-size: 11px;
  line-height: 1;
  cursor: help;
}

.main-tab-content:not(.summary-redesign) .side-nav .settings-tab-btn .subtab-note,
.main-tab-content:not(.summary-redesign) .side-nav .local-tab-btn .subtab-note,
.main-tab-content:not(.summary-redesign) .side-nav .proc-tab-btn .subtab-note {
  display: none;
}

.inbound-ag-grid {
  height: 420px;
  width: 100%;
}

.generic-ag-grid {
  height: 420px;
  width: 100%;
}

.inbound-ag-grid .ag-header {
  border-bottom: 1px solid var(--border-strong);
}

.inbound-ag-grid .ag-header-cell {
  border-right: 1px solid #e2e8f0;
}

.inbound-ag-grid .ag-cell {
  border-right: 1px solid #f1f5f9;
}

.inbound-ag-grid .ag-header-cell.inbound-order-col {
  background: #eef6ff;
  border-left: 2px solid #bfdbfe;
}

.inbound-ag-grid .ag-cell.inbound-order-col {
  background: #f8fbff;
  border-left: 2px solid #dbeafe;
}

/* Keep source inbound matrix hidden once AG layer is active */
.local-tab-content[data-local-tab-panel="inbound"] > .table-wrap.matrix-wrap {
  display: none !important;
}

.inbound-ag-grid .ag-cell[col-id="c0"] .ag-cell-wrapper {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100% !important;
}

.inbound-ag-grid .ag-cell[col-id="c0"] .ag-selection-checkbox {
  display: inline-flex;
  align-self: center;
  align-items: center;
  height: 100% !important;
  margin-top: 0;
  margin-bottom: 0;
}

.inbound-ag-grid .ag-cell[col-id="c0"] .ag-checkbox-input-wrapper {
  margin-top: 0 !important;
  margin-bottom: 0 !important;
  align-self: center;
}

.inbound-ag-grid .ag-header-cell-resize {
  opacity: 1;
  width: 8px;
  right: 0;
}

.inbound-ag-grid .ag-header-cell-resize::after {
  content: "";
  position: absolute;
  right: 3px;
  top: 20%;
  width: 2px;
  height: 60%;
  background: #94a3b8;
}

.inbound-ag-grid .ag-thumb,
.inbound-ag-grid .thumb.ag-thumb {
  width: 22px;
  height: 22px;
  display: block;
  margin: 0 auto;
  object-fit: contain;
  object-position: center;
  background: #fff;
  border-radius: 6px;
  border: 1px solid var(--border);
  max-width: 22px;
  max-height: 22px;
}

.inbound-ag-grid .ag-cell[col-id="c0"] {
  overflow: hidden;
}

.generic-ag-grid .ag-header {
  border-bottom: 1px solid var(--border-strong);
}

.generic-ag-grid .ag-header-cell {
  border-right: 1px solid #e2e8f0;
}

.generic-ag-grid .ag-cell {
  border-right: 1px solid #f1f5f9;
}

.generic-ag-grid .ag-header-cell.supply-triplet-start,
.generic-ag-grid .ag-cell.supply-triplet-start {
  border-left: 2px solid #cbd5e1 !important;
}

.generic-ag-grid .ag-header-cell.supply-triplet-end,
.generic-ag-grid .ag-cell.supply-triplet-end {
  border-right: 2px solid #cbd5e1 !important;
}

.generic-ag-grid .ag-cell[col-id="c0"] {
  overflow: hidden;
}

.generic-ag-grid .ag-cell[col-id="c0"] .ag-cell-wrapper {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100% !important;
}

.ag-theme-alpine .ag-menu,
.ag-theme-alpine .ag-popup-child,
.ag-theme-alpine .ag-filter,
.ag-theme-alpine .ag-filter-wrapper {
  background: #ffffff !important;
  opacity: 1 !important;
}

.generic-ag-grid .ag-thumb,
.generic-ag-grid .thumb.ag-thumb {
  width: 22px;
  height: 22px;
  display: block;
  margin: 0 auto;
  object-fit: contain;
  object-position: center;
  background: #fff;
  border-radius: 6px;
  border: 1px solid var(--border);
  max-width: 22px;
  max-height: 22px;
}

.ag-order-header {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 240px;
}

.ag-order-title {
  font-size: 11px;
  font-weight: 700;
  color: #334155;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.ag-order-title-sortable {
  cursor: pointer;
}

.ag-order-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
}

.ag-order-grid .ag-oh-date,
.ag-order-grid .ag-oh-status {
  width: 100%;
  min-width: 0;
  height: 26px;
  min-height: 26px;
  font-size: 11px;
  padding: 2px 6px;
}

.ag-order-grid .ag-oh-btn {
  min-height: 24px;
  height: 24px;
  padding: 0 6px;
  font-size: 11px;
  line-height: 1;
}

.ag-order-grid .ag-oh-del {
  background: #dc2626;
}

.ag-supply-status-head {
  line-height: 1.15;
}

.ag-supply-status-sub {
  margin-top: 2px;
  font-size: 11px;
  color: #64748b;
  white-space: normal;
}

.table-toolbar-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--space-2);
  align-items: stretch;
  margin-bottom: 6px;
}

.table-toolbar-row .search-input,
.table-toolbar-row .sort-field,
.table-toolbar-row .sort-order {
  width: 100%;
  min-width: 0;
  min-height: var(--table-toolbar-h);
  max-width: none;
  flex: unset;
}

.table-toolbar .col-toggle {
  margin: 0 0 4px;
}

.table-toolbar .col-toggle summary {
  cursor: pointer;
  color: var(--primary-text);
  font-weight: 600;
  font-size: 14px;
  list-style: none;
  padding: 2px 0;
}

.table-toolbar .col-toggle summary::-webkit-details-marker {
  display: none;
}

.table-toolbar .col-toggle summary::before {
  content: "";
  display: inline-block;
  width: 0;
  height: 0;
  border-style: solid;
  border-width: 5px 0 5px 7px;
  border-color: transparent transparent transparent var(--primary-text);
  margin-right: 8px;
  vertical-align: middle;
  transition: transform 0.15s ease;
}

.table-toolbar .col-toggle[open] summary::before {
  transform: rotate(90deg);
}

.table-toolbar .col-toggle-list {
  margin-top: 8px;
}

/* ——— Top bar: сервисы + выход ——— */
.page-header {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  margin-bottom: var(--space-3);
  background: #f8fafc;
  border-bottom: 1px solid #e2e8f0;
  padding-bottom: 8px;
}

.service-switch {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  flex: 1 1 auto;
  margin: 0;
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.header-logout {
  margin: 0;
  margin-left: 8px;
  flex-shrink: 0;
}

.header-user-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-start;
  gap: 10px 14px;
  flex: 1 1 auto;
  min-width: 320px;
}

.header-user-actions {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  margin-left: auto;
}

.header-action-btn {
  min-height: 32px !important;
  height: 32px !important;
  max-height: 32px !important;
  padding: 0 10px !important;
}

select.cabinet-switch-select,
.cabinet-switch-select {
  height: 32px !important;
  min-height: 32px !important;
  max-height: 32px !important;
}

.header-faq-btn.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

@media (max-width: 900px) {
  .header-user-meta {
    min-width: 0;
    width: 100%;
  }

  .header-user-actions {
    width: 100%;
    justify-content: flex-end;
  }
}

/* Mobile burger button (hidden on desktop) */
.header-burger {
  display: none;
  width: 40px;
  height: 40px;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 4px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  cursor: pointer;
  flex-shrink: 0;
}

.header-burger__bar {
  display: block;
  width: 18px;
  height: 2px;
  background: var(--text);
  border-radius: 2px;
  transition: transform 0.18s, opacity 0.18s;
}

.header-burger[aria-expanded="true"] .header-burger__bar:nth-child(1) {
  transform: translateY(6px) rotate(45deg);
}
.header-burger[aria-expanded="true"] .header-burger__bar:nth-child(2) {
  opacity: 0;
}
.header-burger[aria-expanded="true"] .header-burger__bar:nth-child(3) {
  transform: translateY(-6px) rotate(-45deg);
}

@media (max-width: 640px) {
  .header-burger { display: inline-flex; }

  .page-header {
    padding-bottom: 6px;
    gap: 8px;
    align-items: center;
  }

  /* On mobile: meta + actions are hidden by default,
     toggled visible when burger is clicked (via .is-open on .page-header) */
  .page-header .header-user-meta,
  .page-header .header-user-actions {
    display: none;
    width: 100%;
  }

  .page-header.is-open .header-user-meta,
  .page-header.is-open .header-user-actions {
    display: flex;
    animation: header-drop 0.18s ease-out;
  }

  @keyframes header-drop {
    from { opacity: 0; transform: translateY(-4px); }
    to   { opacity: 1; transform: translateY(0); }
  }

  .header-user-meta {
    gap: 6px 10px;
    font-size: 12px;
    line-height: 1.35;
  }

  .header-user-meta > span {
    flex: 0 1 auto;
  }

  .header-user-meta .cabinet-current-inline {
    width: 100%;
    flex: 1 1 100%;
  }

  .cabinet-switch-select {
    flex: 1;
    width: 100%;
    max-width: none;
  }

  .header-user-actions {
    justify-content: flex-end;
    width: 100%;
    gap: 6px;
  }

  .header-action-btn {
    width: auto !important;
    margin-bottom: 0 !important;
    padding: 0 10px !important;
    font-size: 12px;
  }

  .renew-btn {
    margin-left: 4px;
    padding: 4px 8px;
    font-size: 11px;
  }
}

.header-logout button {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border-strong);
}

.header-logout button:hover {
  background: var(--surface-subtle);
  border-color: #94a3b8;
}

.service-switch a {
  text-decoration: none;
  background: var(--primary-soft);
  color: var(--primary-text);
  padding: var(--space-1) 14px;
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  border: 1px solid transparent;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.service-switch a:hover {
  background: #dbeafe;
  border-color: #bfdbfe;
}

.service-switch a.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

/* ——— Tabs ——— */
.main-tabs,
.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-bottom: var(--space-3);
}

.main-tab-btn,
.tab-btn,
.settings-tab-btn,
.local-tab-btn,
.proc-tab-btn {
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  padding: var(--space-1) 14px;
  min-height: 40px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--primary-text);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.main-tab-btn:hover,
.tab-btn:hover,
.settings-tab-btn:hover,
.local-tab-btn:hover,
.proc-tab-btn:hover {
  background: var(--surface-subtle);
  border-color: var(--border-strong);
}

.main-tab-btn.active,
.tab-btn.active,
.settings-tab-btn.active,
.local-tab-btn.active,
.proc-tab-btn.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

.main-tab-content,
.tab-content,
.settings-tab-content,
.local-tab-content {
  display: none;
}

.main-tab-content.active,
.tab-content.active,
.settings-tab-content.active,
.local-tab-content.active {
  display: block;
}

h1 {
  margin: 0 0 var(--space-3);
  font-size: 1.65rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

h2 {
  margin: 0 0 var(--space-3);
  font-size: 1.25rem;
  font-weight: 600;
}

.muted {
  color: var(--text-muted);
  margin-top: -4px;
  font-size: 14px;
}

.card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  padding: var(--space-3);
  margin-bottom: var(--space-3);
}

/* ——— Forms: единая высота, без «скачков» ——— */
label {
  font-size: 13px;
  font-weight: 500;
  color: #334155;
}

input[type="text"],
input[type="number"],
input[type="password"],
input[type="email"],
input[type="date"],
input[type="search"],
select {
  font-family: inherit;
  font-size: 14px;
  width: 100%;
  max-width: 100%;
  min-height: var(--control-h);
  padding: 0 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  transition: border-color 0.15s, box-shadow 0.15s;
}

input[type="text"],
input[type="number"],
input[type="password"],
input[type="email"],
input[type="date"],
input[type="search"],
select:not([multiple]),
button {
  height: var(--control-h);
}

input::placeholder {
  color: #94a3b8;
}

input:hover,
select:hover {
  border-color: #94a3b8;
}

input:focus,
select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: var(--focus);
}

select[multiple] {
  min-height: 140px;
  height: auto;
  padding: 8px 10px;
  line-height: 1.45;
}

input[type="file"] {
  font-family: inherit;
  font-size: 13px;
  min-height: var(--control-h);
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  border: 1px dashed var(--border-strong);
  background: var(--surface-subtle);
  cursor: pointer;
  width: 100%;
  max-width: 100%;
}

input[type="checkbox"] {
  width: 18px;
  height: 18px;
  min-height: 18px;
  padding: 0;
  margin: 0;
  border-radius: 4px;
  accent-color: var(--primary);
  cursor: pointer;
  flex-shrink: 0;
}

button {
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  min-height: var(--control-h);
  padding: 0 18px;
  border-radius: var(--radius-sm);
  border: none;
  background: var(--primary-gradient);
  color: #fff;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease, filter 0.2s ease;
  box-shadow: none;
}

button:hover {
  transform: translateY(-1px);
  filter: saturate(1.06);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

button:active {
  transform: translateY(1px);
}

button:focus-visible {
  outline: none;
  box-shadow: var(--focus);
}

.btn-danger {
  background: var(--danger);
}

.btn-danger:hover {
  background: #b91c1c;
}

.grid-form {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: var(--space-3);
  align-items: start;
}

.stack-grid {
  grid-template-columns: 1fr;
}

.api-settings-layout {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.settings-zone {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--space-3);
  background: var(--surface-subtle);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.settings-zone h3 {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  color: var(--primary-text);
}

.api-row {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  align-items: stretch;
}

@media (min-width: 768px) {
  .api-row {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: flex-end;
  }

  .api-row > label {
    flex: 1 1 240px;
    min-width: 200px;
  }

  .api-row > .fixed-btn {
    flex: 0 0 auto;
  }
}

.api-row label,
.grid-form label,
.inline-form label {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  margin: 0;
}

.fixed-btn {
  min-width: min(100%, 220px);
  width: auto;
  max-width: 100%;
  align-self: flex-start;
}

@media (min-width: 768px) {
  .fixed-btn {
    align-self: flex-end;
  }
}

.checkbox-row {
  flex-direction: row !important;
  align-items: center !important;
  gap: var(--space-2) !important;
}

/* Горизонтальные формы: одна линия по центру контролов */
.inline-form {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
  margin-bottom: var(--space-3);
}

.inline-form > input,
.inline-form > select,
.inline-form > button {
  margin: 0;
}

.inline-form > input[type="text"],
.inline-form > input[type="number"],
.inline-form > input[type="search"] {
  flex: 1 1 160px;
  min-width: 140px;
  max-width: 100%;
}

.inline-form > input[type="file"] {
  flex: 1 1 220px;
  min-width: 180px;
}

.inline-form > button {
  flex: 0 0 auto;
}

.inline-edit {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  align-items: center;
}

.inline-edit input {
  width: 96px;
  min-width: 72px;
  flex: 0 0 auto;
}

.inline-edit button {
  flex: 0 0 auto;
}

/* Alerts */
.alert {
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 14px;
  margin: var(--space-2) 0 0;
}

.alert-success {
  background: var(--success-bg);
  color: var(--success);
  border: 1px solid #a7f3d0;
}

.alert-error {
  background: var(--danger-bg);
  color: var(--danger);
  border: 1px solid #fecaca;
}

/* Tables */
table {
  width: 100%;
  border-collapse: collapse;
  min-width: 900px;
}

th,
td {
  border-bottom: 1px solid var(--border);
  text-align: left;
  padding: var(--space-2) var(--space-2);
  font-size: 14px;
  vertical-align: middle;
}

.table-wrap thead th {
  position: sticky;
  top: 0;
  z-index: 6;
  background: #f1f5f9;
  font-weight: 600;
  color: #475569;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  box-shadow: 0 1px 0 var(--border);
}

/*
 * Вторая строка thead «Поставки» (Кол-во / Статус): без position:sticky — иначе в части
 * браузеров ломается привязка колонок к colspan в первой строке.
 */
.table-wrap.matrix-wrap .matrix-table--sticky-lead thead tr:nth-child(2) > th {
  position: static;
  top: auto;
  z-index: 5;
  box-shadow: none;
  border-bottom: 1px solid var(--border);
}

.table-wrap td:has(input[type="checkbox"]) {
  text-align: center;
  width: 1%;
  white-space: nowrap;
}

.export-link {
  display: inline-flex;
  align-items: center;
  margin-bottom: var(--space-2);
  font-weight: 500;
  font-size: 14px;
  color: var(--primary);
  text-decoration: none;
}

.export-link:hover {
  text-decoration: underline;
}

.table-tools {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-bottom: var(--space-2);
  align-items: center;
}

.search-input {
  min-width: 0;
  flex: 1 1 200px;
}

.table-tools select:not([multiple]) {
  min-width: 180px;
  flex: 0 1 auto;
}

#planning-warehouses {
  min-width: min(100%, 280px);
}

.table-wrap {
  max-height: min(78vh, 960px);
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
}

.matrix-wrap {
  max-height: min(82vh, 1040px);
}

/* Липкий только 1-й столбец (Фото); категория не фиксируется */
.table-wrap .table-sticky-photo:not(.table-summary-warehouse) {
  table-layout: fixed;
}

.table-wrap .table-sticky-photo th:nth-child(1),
.table-wrap .table-sticky-photo td:nth-child(1) {
  position: sticky;
  left: 0;
  z-index: 3;
  width: var(--sticky-photo-w);
  min-width: var(--sticky-photo-w);
  max-width: var(--sticky-photo-w);
  background: var(--surface);
  box-shadow: 2px 0 6px rgba(15, 23, 42, 0.06);
  text-align: center;
  vertical-align: middle;
}

.table-wrap .table-sticky-photo th:nth-child(2),
.table-wrap .table-sticky-photo td:nth-child(2) {
  min-width: var(--sticky-cat-w);
  max-width: 168px;
  vertical-align: middle;
  overflow: hidden;
  text-overflow: ellipsis;
}

.table-wrap .table-sticky-photo thead th:nth-child(1) {
  z-index: 9;
  background: #f1f5f9;
  box-shadow: 0 1px 0 var(--border), 2px 0 6px rgba(15, 23, 42, 0.06);
}

.table-wrap .table-sticky-photo thead th:nth-child(2) {
  z-index: 8;
  background: #f1f5f9;
  box-shadow: 0 1px 0 var(--border);
}

.table-wrap .table-sticky-photo td:nth-child(1).photo-cell {
  overflow: visible;
}

/* Сводные отчёты по складам: ширина по содержимому + полосы изменения ширины */
.table-wrap .table-summary-warehouse {
  table-layout: fixed;
  width: max-content;
  min-width: 100%;
}

.table-wrap .table-summary-warehouse th,
.table-wrap .table-summary-warehouse td {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.table-wrap .table-summary-warehouse th:nth-child(2),
.table-wrap .table-summary-warehouse td:nth-child(2) {
  max-width: none;
  min-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.table-wrap .table-summary-warehouse th:nth-child(3),
.table-wrap .table-summary-warehouse td:nth-child(3) {
  min-width: 200px;
  max-width: 480px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.table-wrap .table-summary-warehouse th:nth-child(4),
.table-wrap .table-summary-warehouse td:nth-child(4) {
  min-width: 100px;
}

.table-wrap .table-summary-warehouse th:nth-child(5),
.table-wrap .table-summary-warehouse td:nth-child(5) {
  min-width: 120px;
}

.table-wrap .table-summary-warehouse th:nth-child(6),
.table-wrap .table-summary-warehouse td:nth-child(6) {
  min-width: 72px;
}

.table-wrap .table-summary-warehouse th:nth-child(n + 7),
.table-wrap .table-summary-warehouse td:nth-child(n + 7) {
  min-width: 88px;
  text-align: right;
}

.table-wrap table[data-table="local"],
.table-wrap table[data-table="movements"],
.table-wrap table[data-table="inbound-unknown"] {
  table-layout: fixed;
  width: max-content;
  min-width: 100%;
}

.table-wrap table[data-table="local"] th,
.table-wrap table[data-table="local"] td,
.table-wrap table[data-table="movements"] th,
.table-wrap table[data-table="movements"] td,
.table-wrap table[data-table="inbound-unknown"] th,
.table-wrap table[data-table="inbound-unknown"] td {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.table-wrap table[data-table="local"] td:nth-child(15),
.table-wrap table[data-table="inbound-unknown"] td:nth-child(3),
.table-wrap table[data-table="inbound-unknown"] td:nth-child(4),
.table-wrap table[data-table="movements"] td:nth-child(13) {
  overflow: visible;
  text-overflow: unset;
}

.table-wrap .table-summary-warehouse thead th.col-resizable-th {
  position: relative;
  padding-right: 12px;
}

.column-filter-row th {
  position: sticky;
  top: 34px;
  z-index: 7;
  background: #f8fafc;
  padding: 4px 6px;
}

.col-filter-input {
  width: 100%;
  min-height: 28px;
  height: 28px;
  font-size: 12px;
  padding: 2px 6px;
  border-radius: 6px;
}

.col-filter-input--num {
  text-align: right;
}

.col-resize-handle {
  position: absolute;
  right: 0;
  top: 0;
  bottom: 0;
  width: 8px;
  cursor: col-resize;
  user-select: none;
  z-index: 14;
  touch-action: none;
}

.col-resize-handle:hover,
body.col-resize-active .col-resize-handle.active {
  background: rgba(37, 99, 235, 0.2);
}

/* Матрицы поставок / поступлений — липкий первый столбец (Фото) */
.matrix-wrap .matrix-table--sticky-lead thead tr:first-child > th:nth-child(1),
.matrix-wrap .matrix-table--sticky-lead tbody td:nth-child(1) {
  position: sticky;
  left: 0;
  z-index: 4;
  width: var(--sticky-photo-w);
  min-width: var(--sticky-photo-w);
  max-width: var(--sticky-photo-w);
  background: var(--surface);
  box-shadow: 2px 0 6px rgba(15, 23, 42, 0.06);
  text-align: center;
  vertical-align: middle;
}

.matrix-wrap .matrix-table--sticky-lead thead tr:first-child > th:nth-child(2),
.matrix-wrap .matrix-table--sticky-lead tbody td:nth-child(2) {
  width: var(--sticky-cat-w);
  min-width: var(--sticky-cat-w);
  max-width: 168px;
  vertical-align: middle;
  overflow: hidden;
  text-overflow: ellipsis;
}

.matrix-wrap .matrix-table--sticky-lead thead tr:first-child > th:nth-child(1) {
  z-index: 11;
  background: #f1f5f9;
  box-shadow: 0 1px 0 var(--border), 2px 0 6px rgba(15, 23, 42, 0.06);
}

.matrix-wrap .matrix-table--sticky-lead thead tr:first-child > th:nth-child(2) {
  z-index: 10;
  background: #f1f5f9;
  box-shadow: 0 1px 0 var(--border);
}

.matrix-wrap .matrix-table--sticky-lead tbody td:nth-child(1).photo-cell {
  overflow: visible;
}

.matrix-table {
  table-layout: fixed;
  width: max-content;
  min-width: 100%;
  min-width: 1400px;
}

.matrix-table th,
.matrix-table td {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  word-break: normal;
  overflow-wrap: normal;
}

.matrix-table td:has(input),
.matrix-table td:has(select),
.matrix-table td:has(button),
.matrix-table th:has(input),
.matrix-table th:has(select),
.matrix-table th:has(button),
.matrix-table .matrix-col-head,
.matrix-table .inbound-col-head {
  overflow: visible;
  text-overflow: unset;
}

.matrix-wrap .matrix-table--inbound th:nth-child(3),
.matrix-wrap .matrix-table--inbound td:nth-child(3) {
  min-width: 220px;
  max-width: 280px;
}

.matrix-wrap .matrix-table--inbound th:nth-child(4),
.matrix-wrap .matrix-table--inbound td:nth-child(4) {
  min-width: 150px;
  max-width: 180px;
}

.matrix-wrap .matrix-table--inbound td:nth-child(3),
.matrix-wrap .matrix-table--inbound td:nth-child(4) {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Жестко ограничиваем контент ячейки рамками столбца */
.table-wrap th,
.table-wrap td {
  box-sizing: border-box;
}

.table-wrap td input,
.table-wrap td select,
.table-wrap td button,
.table-wrap td a.btn-outline,
.table-wrap td form {
  max-width: 100%;
  min-width: 0;
  box-sizing: border-box;
}

.table-wrap td .inline-edit {
  min-width: 0;
  flex-wrap: nowrap;
}

.table-wrap td .inline-edit input {
  min-width: 0;
  width: 100%;
}

.matrix-col-head {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 280px;
}

.matrix-col-title {
  font-weight: 700;
  text-align: center;
  width: 100%;
}

.matrix-col-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  align-items: stretch;
  width: 100%;
}

.matrix-col-form {
  display: flex;
  min-width: 0;
  width: 100%;
  margin: 0;
}

.matrix-col-form input[type="date"],
.matrix-col-form select {
  width: 100%;
  min-width: 0;
  min-height: var(--control-h);
  box-sizing: border-box;
}

.matrix-col-form--btn {
  align-items: stretch;
}

.matrix-col-form--btn .matrix-col-btn {
  width: 100%;
  min-width: 0;
  min-height: var(--control-h);
  height: 100%;
  box-sizing: border-box;
  padding: 6px 8px;
  white-space: normal;
  line-height: 1.15;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.matrix-col-form--empty {
  min-height: var(--control-h);
}

.matrix-col-head--dim {
  opacity: 0.78;
}

/* Панели над матрицами «Поставки» / «Ожидаемые поступления» — сетка, одна строка */
.local-matrix-toolbar {
  margin-bottom: 4px;
}

.local-matrix-toolbar--supplies {
  --matrix-actions-col: clamp(300px, 36vw, 520px);
}

.local-matrix-toolbar--inbound {
  --matrix-actions-col: clamp(300px, 36vw, 560px);
}

.local-panel-row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 12px;
  margin-bottom: 12px;
}

.local-panel-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}

.local-matrix-toolbar .local-panel-row {
  margin-bottom: 8px;
}

/* Одна ширина колонки кнопок в обеих строках + одинаковая высота пары кнопок */
.local-matrix-toolbar .local-panel-actions {
  margin-left: 0;
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  align-items: stretch;
  gap: 8px;
  width: 100%;
  min-width: 0;
}

.local-matrix-toolbar .local-panel-actions > button,
.local-matrix-toolbar .local-panel-actions > a.btn-outline {
  flex: 1 1 0;
  min-width: 0;
  min-height: var(--control-h);
  box-sizing: border-box;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px 10px;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.25;
  text-align: center;
  text-decoration: none;
}

.local-matrix-toolbar .local-panel-actions > a.btn-outline {
  border-width: 1px;
}

/* Поставки: склад и дата — равные колонки, без пустого 1fr; файл на всю ширину этих двух колонок */
.local-panel-row--supplies-head,
.local-panel-row--supplies-import {
  display: grid;
  grid-template-columns: 1fr 1fr var(--matrix-actions-col);
  align-items: center;
  gap: 10px;
}

.local-panel-row--supplies-head .local-matrix-warehouse,
.local-panel-row--supplies-head .local-matrix-date {
  width: 100%;
  min-width: 0;
  min-height: var(--control-h);
}

.local-panel-row--supplies-head .local-panel-actions {
  justify-self: stretch;
}

.local-panel-row--supplies-import .local-panel-file {
  grid-column: 1 / 3;
  width: 100%;
  min-width: 0;
}

.local-panel-row--supplies-import .local-panel-actions {
  justify-self: stretch;
}

/* Поступления: поля в общей сетке, кнопки один блок 2×2 одинакового размера */
.local-inbound-toolbar-grid {
  display: grid;
  grid-template-columns: minmax(200px, 1fr) minmax(200px, 1fr) var(--matrix-actions-col);
  grid-template-rows: auto auto;
  gap: 10px;
  align-items: stretch;
  margin-bottom: 8px;
}

.inbound-form-mesh {
  display: contents;
}

.inbound-mesh-date {
  grid-column: 1;
  grid-row: 1;
  width: 100%;
  min-width: 0;
  min-height: var(--control-h);
  height: var(--control-h);
  max-height: var(--control-h);
  box-sizing: border-box;
}

.inbound-mesh-select {
  grid-column: 1;
  grid-row: 2;
  width: 100%;
  min-width: 0;
  min-height: var(--control-h);
  height: var(--control-h);
  max-height: var(--control-h);
  box-sizing: border-box;
}

.inbound-mesh-file {
  grid-column: 2;
  grid-row: 2;
  width: 100%;
  min-width: 0;
  min-height: var(--control-h);
  height: var(--control-h);
  max-height: var(--control-h);
  box-sizing: border-box;
}

.inbound-actions-grid {
  grid-column: 3;
  grid-row: 1 / span 2;
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr 1fr;
  gap: 8px;
  align-self: stretch;
  min-width: 0;
  min-height: 0;
}

.inbound-actions-grid > button,
.inbound-actions-grid > a.btn-outline {
  width: 100%;
  min-width: 0;
  min-height: var(--control-h);
  height: var(--control-h);
  max-height: var(--control-h);
  box-sizing: border-box;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 10px;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.15;
  text-align: center;
  text-decoration: none;
}

.inbound-actions-grid > a.btn-outline {
  border-width: 1px;
}

@media (max-width: 768px) {
  .local-matrix-toolbar .local-panel-actions {
    flex-wrap: wrap;
  }

  .local-matrix-toolbar--supplies,
  .local-matrix-toolbar--inbound {
    --matrix-actions-col: minmax(0, 1fr);
  }

  .local-panel-row--supplies-head {
    grid-template-columns: 1fr 1fr;
  }

  .local-panel-row--supplies-head .local-panel-actions {
    grid-column: 1 / -1;
  }

  .local-panel-row--supplies-import {
    grid-template-columns: 1fr;
  }

  .local-panel-row--supplies-import .local-panel-file {
    grid-column: auto;
  }

  .local-panel-row--supplies-import .local-panel-actions {
    grid-column: 1 / -1;
  }

  .local-inbound-toolbar-grid {
    grid-template-columns: 1fr;
  }

  .inbound-mesh-date {
    grid-column: 1;
    grid-row: 1;
  }

  .inbound-mesh-select {
    grid-column: 1;
    grid-row: 2;
  }

  .inbound-mesh-file {
    grid-column: 1;
    grid-row: 3;
  }

  .inbound-actions-grid {
    grid-column: 1;
    grid-row: 4;
  }

  .local-matrix-toolbar .local-panel-actions > button,
  .local-matrix-toolbar .local-panel-actions > a.btn-outline {
    flex: 1 1 calc(50% - 4px);
    min-width: 140px;
  }
}

.local-matrix-toolbar .muted {
  margin-top: 0;
  margin-bottom: 6px;
  font-size: 13px;
  line-height: 1.35;
}

.local-tab-content > .table-toolbar {
  margin-top: 2px;
  margin-bottom: 6px;
}

.local-tab-content > .table-toolbar .table-toolbar-row {
  margin-bottom: 4px;
}

.local-add-product-details {
  margin-bottom: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  background: var(--surface-subtle);
}

.local-add-product-details summary {
  cursor: pointer;
  color: var(--primary-text);
  font-weight: 600;
  font-size: 14px;
  list-style: none;
}

.local-add-product-details summary::-webkit-details-marker {
  display: none;
}

.local-add-product-details .inline-form {
  margin-top: 10px;
  margin-bottom: 0;
}

/* Ожидаемые поступления: компактный заголовок колонки (2×3 сетка) */
.inbound-col-head {
  min-width: 188px;
  max-width: 240px;
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 8px 8px 6px;
  box-sizing: border-box;
}

.inbound-col-head--dim {
  opacity: 0.78;
}

.inbound-col-title-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 6px;
}

.inbound-col-title {
  text-align: center;
  font-weight: 700;
  font-size: 12px;
  line-height: 1.2;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.inbound-hide-form {
  margin: 0;
  display: inline-flex;
}

.inbound-hide-chip {
  font-family: inherit;
  font-size: 10px;
  font-weight: 600;
  padding: 2px 8px;
  min-height: 0;
  height: auto;
  line-height: 1.3;
  border-radius: 999px;
  background: #fff;
  color: #64748b;
  border: 1px solid #cbd5e1;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.inbound-hide-chip:hover {
  background: #e2e8f0;
  border-color: #94a3b8;
}

.inbound-col-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px 6px;
  width: 100%;
}

.inbound-col-cell {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.inbound-col-label {
  font-size: 9px;
  line-height: 1.15;
  color: #64748b;
  min-height: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
}

.inbound-col-label--btn {
  user-select: none;
}

.inbound-col-form {
  display: flex;
  width: 100%;
  margin: 0;
  min-width: 0;
}

.inbound-col-form--btn {
  flex: 1;
  align-items: stretch;
}

.matrix-table--inbound .inbound-col-form input[type="date"],
.matrix-table--inbound .inbound-col-form select {
  width: 100%;
  min-width: 0;
  min-height: 30px;
  max-height: 30px;
  height: 30px;
  box-sizing: border-box;
  font-size: 12px;
  padding: 2px 6px;
  background: #fff;
  border: 1px solid #cbd5e1;
}

.matrix-table--inbound .inbound-col-btn {
  width: 100%;
  min-width: 0;
  min-height: 30px;
  max-height: 30px;
  height: 30px;
  box-sizing: border-box;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  border-radius: var(--radius-sm);
  border: none;
  cursor: pointer;
  transition: background 0.15s, transform 0.05s;
}

.matrix-table--inbound .inbound-col-btn--save {
  background: var(--primary);
  color: #fff;
}

.matrix-table--inbound .inbound-col-btn--save:hover {
  background: var(--primary-hover);
}

.matrix-table--inbound .inbound-col-btn--delete {
  background: var(--danger);
  color: #fff;
}

.matrix-table--inbound .inbound-col-btn--delete:hover {
  background: #b91c1c;
}

.matrix-table--inbound .inbound-col-form input[type="date"]:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  background: #e2e8f0;
}

.status-pill {
  display: inline-flex;
  padding: 2px 8px;
  border-radius: 999px;
  background: #e2e8f0;
  color: #334155;
  font-size: 12px;
}

.photo-cell {
  position: relative;
}

.photo-delete-form {
  position: absolute;
  right: 2px;
  top: 2px;
  opacity: 0;
  transition: opacity 0.15s;
}

.photo-cell:hover .photo-delete-form {
  opacity: 1;
}

.photo-delete-btn {
  min-height: 24px;
  width: 24px;
  padding: 0;
  border-radius: 6px;
  background: #dc2626;
}

.inbound-picker-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

.inbound-new-badge {
  display: inline-flex;
  padding: 2px 8px;
  border-radius: 999px;
  background: #dc2626;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
}

.wh-recommended-badge {
  display: inline-flex;
  margin-left: 8px;
  padding: 2px 8px;
  border-radius: 999px;
  background: #e0f2fe;
  color: #0c4a6e;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}

.hidden {
  display: none !important;
}

.col-resize-handle {
  position: absolute;
  right: -3px;
  top: 0;
  width: 10px;
  height: 100%;
  cursor: col-resize;
  user-select: none;
  z-index: 6;
}

.col-resize-handle::after {
  content: "";
  position: absolute;
  right: 4px;
  top: 12%;
  width: 2px;
  height: 76%;
  background: rgba(71, 85, 105, 0.35);
}

.photo-dropdown {
  position: relative;
}

.photo-dropdown-summary {
  cursor: pointer;
  color: var(--primary-text);
  font-size: 12px;
  font-weight: 600;
}

.photo-dropdown-list {
  position: absolute;
  left: 0;
  top: calc(100% + 6px);
  z-index: 10;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(46px, 1fr));
  gap: 6px;
  min-width: 220px;
  max-width: 360px;
  max-height: 220px;
  overflow: auto;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px;
  box-shadow: var(--shadow-md);
}

.photo-option {
  min-height: 46px;
  width: 46px;
  padding: 0;
  border-radius: 8px;
  background: #fff;
  border: 1px solid var(--border);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.photo-option img.thumb {
  width: 100%;
  height: 100%;
}

.photo-fallback {
  font-size: 10px;
  color: #475569;
  text-transform: uppercase;
}

.thumb {
  width: 42px;
  height: 42px;
  object-fit: cover;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

.thumb-hover-preview {
  position: fixed;
  z-index: 120;
  pointer-events: none;
  display: none;
  width: 260px;
  height: 260px;
  border-radius: 10px;
  border: 1px solid var(--border-strong);
  background: #fff;
  box-shadow: var(--shadow-md);
  overflow: hidden;
}

.thumb-hover-preview img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #fff;
}

.thumb-hover-preview.shown {
  display: block;
}

.mark-green {
  background: #dcfce7;
}

.mark-yellow {
  background: #fef9c3;
}

.mark-red {
  background: #fee2e2;
}

.mark-burgundy {
  background: #7f1d1d;
  color: #fff;
}

.ag-theme-alpine .ag-cell.ag-turnover-green {
  background: #dcfce7;
}

.ag-theme-alpine .ag-cell.ag-turnover-yellow {
  background: #fef9c3;
}

.ag-theme-alpine .ag-cell.ag-turnover-red {
  background: #fee2e2;
}

.ag-theme-alpine .ag-cell.ag-turnover-burgundy {
  background: #7f1d1d;
  color: #fff;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-bottom: var(--space-2);
}

.pill {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: var(--space-1) 12px;
  font-size: 12px;
  font-weight: 500;
  border: 1px solid rgba(15, 23, 42, 0.08);
}

.col-toggle:not(.table-toolbar .col-toggle) {
  margin-bottom: var(--space-2);
}

.col-toggle:not(.table-toolbar .col-toggle) summary {
  cursor: pointer;
  color: var(--primary-text);
  font-weight: 600;
  font-size: 14px;
  list-style-position: outside;
}

.col-toggle-list {
  margin-top: var(--space-2);
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2) var(--space-3);
}

.col-toggle-actions {
  width: 100%;
  display: flex;
  gap: 8px;
  margin-bottom: 4px;
}

.col-toggle-actions button {
  min-height: 28px;
  height: 28px;
  padding: 0 10px;
  font-size: 12px;
}

.col-item {
  font-size: 13px;
}

.help-tip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  font-size: 11px;
  margin-left: var(--space-1);
  cursor: help;
}

.index-badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}

.inner-layout {
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: var(--space-3);
  align-items: start;
}

.side-nav {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.inner-content {
  min-width: 0;
}

/* Summary reports redesign */
.summary-redesign {
  background: #f8fafc;
}

.summary-redesign .summary-period-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 12px 16px;
  margin-bottom: 18px;
  border: 1px solid #e2e8f0;
  border-radius: 16px;
  background: #fff;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.06);
}

.summary-redesign .summary-period-main {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.summary-redesign .summary-period-display {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 38px;
  padding: 0 12px;
  border: 1px solid #e2e8f0;
  border-radius: 999px;
  background: #f8fafc;
  color: #334155;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.summary-redesign .summary-period-icon {
  font-size: 14px;
}

.summary-redesign .summary-range-input-hidden {
  position: absolute;
  pointer-events: none;
  opacity: 0;
  width: 0;
  height: 0;
  padding: 0;
  border: 0;
}

.summary-redesign .summary-period-chips {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.summary-redesign .summary-period-chips .period-hotkey {
  min-height: 34px;
  height: 34px;
  padding: 0 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  margin: 0;
}

.summary-redesign .summary-period-submit {
  min-height: 40px;
  height: 40px;
  margin: 0;
  border-radius: 999px;
  padding: 0 18px;
}

.summary-redesign .inner-layout {
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
  gap: 20px;
}

.summary-redesign .summary-side-nav {
  position: sticky;
  top: 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 10px;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 20px;
}

.summary-redesign .summary-side-group {
  padding: 4px 0;
}

.summary-redesign .summary-side-group:not(:last-child) {
  border-bottom: 1px solid #eef2f6;
}

.summary-redesign .summary-side-title {
  padding: 4px 10px 8px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #94a3b8;
}

.summary-redesign .summary-side-nav .tab-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  border: 0;
  border-left: 3px solid transparent;
  border-radius: 10px;
  background: transparent;
  color: #475569;
  font-size: 13px;
  font-weight: 600;
  margin: 0;
  min-height: 38px;
  padding: 0 10px;
  text-align: left;
}

.summary-redesign .summary-side-nav .tab-btn .tab-icon {
  width: 20px;
  text-align: center;
}

.summary-redesign .summary-side-nav .tab-btn:hover {
  background: #f1f5f9;
  color: #0f172a;
}

.summary-redesign .summary-side-nav .tab-btn.active {
  background: #eff6ff;
  color: #1d4ed8;
  border-left-color: #2563eb;
}

.summary-redesign .inner-content {
  min-width: 0;
}

.summary-redesign .tab-content {
  border: 1px solid #e2e8f0;
  border-radius: 20px;
  background: #fff;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.06);
  padding: 16px;
  animation: summaryFadeIn 0.18s ease;
}

/* Apply summary-like visual system to other main sections */
.main-tab-content:not(.summary-redesign) .inner-layout {
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
  gap: 20px;
  align-items: start;
}

.main-tab-content:not(.summary-redesign) .side-nav {
  position: sticky;
  top: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 20px;
}

.main-tab-content:not(.summary-redesign) .side-nav .settings-tab-btn,
.main-tab-content:not(.summary-redesign) .side-nav .local-tab-btn,
.main-tab-content:not(.summary-redesign) .side-nav .proc-tab-btn,
.main-tab-content:not(.summary-redesign) .side-nav .tab-btn {
  width: 100%;
  border: 0;
  border-left: 3px solid transparent;
  border-radius: 10px;
  background: transparent;
  color: #475569;
  font-size: 13px;
  font-weight: 600;
  margin: 0;
  min-height: 38px;
  padding: 0 10px;
  text-align: left;
}

.main-tab-content:not(.summary-redesign) .side-nav .settings-tab-btn:hover,
.main-tab-content:not(.summary-redesign) .side-nav .local-tab-btn:hover,
.main-tab-content:not(.summary-redesign) .side-nav .proc-tab-btn:hover,
.main-tab-content:not(.summary-redesign) .side-nav .tab-btn:hover {
  background: #f1f5f9;
  color: #0f172a;
  border-left-color: transparent;
}

.main-tab-content:not(.summary-redesign) .side-nav .settings-tab-btn.active,
.main-tab-content:not(.summary-redesign) .side-nav .local-tab-btn.active,
.main-tab-content:not(.summary-redesign) .side-nav .proc-tab-btn.active,
.main-tab-content:not(.summary-redesign) .side-nav .tab-btn.active {
  background: #eff6ff;
  color: #1d4ed8;
  border-left-color: #2563eb;
}

.main-tab-content:not(.summary-redesign) .inner-content > .settings-tab-content.active,
.main-tab-content:not(.summary-redesign) .inner-content > .local-tab-content.active,
.main-tab-content:not(.summary-redesign) .inner-content > .proc-tab-content.active,
.main-tab-content:not(.summary-redesign) .inner-content > .tab-content.active {
  border: 1px solid #e2e8f0;
  border-radius: 20px;
  background: #fff;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.06);
  padding: 16px;
  animation: summaryFadeIn 0.18s ease;
}

@keyframes summaryFadeIn {
  from { opacity: 0; transform: translateY(3px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (min-width: 768px) and (max-width: 1024px) {
  .summary-redesign .inner-layout {
    grid-template-columns: 200px minmax(0, 1fr);
  }

  .main-tab-content:not(.summary-redesign) .inner-layout {
    grid-template-columns: 200px minmax(0, 1fr);
  }
}

@media (max-width: 767px) {
  .summary-redesign .summary-period-card {
    flex-direction: column;
    align-items: stretch;
  }

  .summary-redesign .summary-period-main {
    width: 100%;
  }

  .summary-redesign .summary-period-display {
    width: 100%;
    justify-content: flex-start;
  }

  .summary-redesign .summary-period-chips {
    width: 100%;
    overflow-x: auto;
    padding-bottom: 2px;
  }

  .summary-redesign .summary-period-submit {
    width: 100%;
  }

  .summary-redesign .inner-layout {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .summary-redesign .summary-side-nav {
    position: static;
    display: block;
    overflow-x: auto;
    white-space: nowrap;
    padding: 8px;
  }

  .summary-redesign .summary-side-group {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    border: 0 !important;
    margin-right: 8px;
    padding: 0;
  }

  .summary-redesign .summary-side-title {
    display: none;
  }

  .summary-redesign .summary-side-nav .tab-btn {
    width: auto;
    min-width: max-content;
    border-left-width: 0;
    border-bottom: 2px solid transparent;
    border-radius: 999px;
    padding: 0 10px;
  }

  .summary-redesign .summary-side-nav .tab-btn.active {
    border-bottom-color: #2563eb;
  }

  .main-tab-content:not(.summary-redesign) .inner-layout {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .main-tab-content:not(.summary-redesign) .side-nav {
    position: static;
    display: block;
    overflow-x: auto;
    white-space: nowrap;
    padding: 8px;
  }

  .main-tab-content:not(.summary-redesign) .side-nav .settings-tab-btn,
  .main-tab-content:not(.summary-redesign) .side-nav .local-tab-btn,
  .main-tab-content:not(.summary-redesign) .side-nav .proc-tab-btn,
  .main-tab-content:not(.summary-redesign) .side-nav .tab-btn {
    width: auto;
    min-width: max-content;
    border-left-width: 0;
    border-bottom: 2px solid transparent;
    border-radius: 999px;
    padding: 0 10px;
    margin-right: 6px;
  }

  .main-tab-content:not(.summary-redesign) .side-nav .settings-tab-btn.active,
  .main-tab-content:not(.summary-redesign) .side-nav .local-tab-btn.active,
  .main-tab-content:not(.summary-redesign) .side-nav .proc-tab-btn.active,
  .main-tab-content:not(.summary-redesign) .side-nav .tab-btn.active {
    border-bottom-color: #2563eb;
  }

  .warehouse-ref-ag-wrap .ref-actions .aggrid-beta-actions {
    flex-wrap: wrap;
  }

  .warehouse-ref-ag-wrap .aggrid-beta-actions-wrap {
    padding-left: 0;
    padding-right: 0;
  }
}

.idx-red {
  background: #fee2e2;
  color: #991b1b;
}

.idx-orange {
  background: #ffedd5;
  color: #9a3412;
}

.idx-yellow {
  background: #fef3c7;
  color: #854d0e;
}

.idx-green {
  background: #dcfce7;
  color: #166534;
}

/* Flatpickr — в тон интерфейсу */
.flatpickr-calendar {
  border-radius: var(--radius-sm) !important;
  box-shadow: var(--shadow-md) !important;
  border: 1px solid var(--border) !important;
  overflow: hidden;
}

.flatpickr-months {
  background: #f8fafc;
  border-bottom: 1px solid #e2e8f0;
}

.flatpickr-current-month,
.flatpickr-weekday {
  color: #1e293b;
}

.flatpickr-day.selected,
.flatpickr-day.startRange,
.flatpickr-day.endRange {
  background: var(--primary) !important;
  border-color: var(--primary) !important;
}

.flatpickr-day.inRange {
  box-shadow: none !important;
  background: var(--primary-soft) !important;
  border-color: transparent !important;
}

.flatpickr-day.today {
  border-color: #93c5fd !important;
}

input[type="date"]::-webkit-calendar-picker-indicator {
  opacity: 0.65;
  cursor: pointer;
}

/* Excel по складам + подсказки */
.wh-excel-toolbar {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  margin-bottom: var(--space-3);
  padding: var(--space-3);
  background: var(--surface-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.wh-excel-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
}

.wh-excel-row form {
  display: contents;
}

.wh-excel-row input[type="file"] {
  flex: 1 1 220px;
  min-width: 180px;
  max-width: 100%;
}

.btn-outline {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: var(--control-h);
  height: var(--control-h);
  max-height: var(--control-h);
  padding: 0 18px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--primary-text);
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  transition: background 0.2s, border-color 0.2s, transform 0.2s;
  box-shadow: none;
}

.btn-outline:hover {
  background: var(--primary-soft);
  border-color: var(--primary);
  color: var(--primary);
  transform: translateY(-1px);
}

.print-subtab-btn.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.help-details {
  position: relative;
  margin: 0;
}

.help-summary {
  list-style: none;
  cursor: help;
  width: 28px;
  height: 28px;
  min-height: 28px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
  color: #fff;
  background: var(--primary);
  border: none;
  flex-shrink: 0;
  box-shadow: var(--shadow);
}

.help-summary::-webkit-details-marker {
  display: none;
}

.help-summary::marker {
  content: "";
}

.help-details[open] .help-summary {
  background: var(--primary-hover);
}

.help-body {
  position: absolute;
  left: 0;
  top: calc(100% + 8px);
  z-index: 40;
  min-width: min(100vw - 48px, 360px);
  max-width: 420px;
  padding: 12px 14px;
  font-size: 13px;
  font-weight: 400;
  line-height: 1.45;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md);
}

.help-body strong {
  font-weight: 600;
}

/* FAQ */
.faq-lead {
  margin-bottom: var(--space-4);
}

.faq-layout {
  display: grid;
  grid-template-columns: minmax(200px, 260px) minmax(0, 1fr);
  gap: var(--space-4);
  align-items: start;
}

.faq-sidebar {
  position: sticky;
  top: 72px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: var(--space-2);
  background: var(--surface-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  max-height: calc(100vh - 100px);
  overflow-y: auto;
}

.faq-nav-btn {
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  text-align: left;
  width: 100%;
  margin: 0;
  padding: 10px 12px;
  min-height: auto;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: #334155;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.faq-nav-btn:hover {
  background: #e2e8f0;
  color: var(--text);
}

.faq-nav-btn.is-active {
  background: var(--primary);
  color: #fff;
}

.faq-nav-btn.is-active:hover {
  background: var(--primary-hover);
  color: #fff;
}

.faq-content {
  min-width: 0;
  padding: var(--space-2) var(--space-3);
  background: var(--surface-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  min-height: 280px;
}

.faq-pane {
  display: none;
}

.faq-pane.is-active {
  display: block;
  animation: faq-fade 0.2s ease;
}

@keyframes faq-fade {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.faq-pane h3 {
  margin: 0 0 var(--space-3);
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--primary-text);
  padding-bottom: var(--space-2);
  border-bottom: 1px solid var(--border);
}

.faq-pane h4 {
  margin: 1.35rem 0 var(--space-2);
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text);
}

.faq-pane h3 + h4 {
  margin-top: 0.35rem;
}

.faq-pane .faq-section-lead {
  margin: 0 0 var(--space-3);
  font-size: 14px;
  line-height: 1.55;
  color: #475569;
}

.faq-dl {
  margin: 0;
}

.faq-dl dt {
  margin-top: var(--space-3);
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

.faq-dl dt:first-child {
  margin-top: 0;
}

.faq-dl dd {
  margin: var(--space-1) 0 0;
  font-size: 14px;
  line-height: 1.55;
  color: #475569;
}

.faq-list {
  margin: 0;
  padding-left: 1.2rem;
  color: #475569;
  font-size: 14px;
  line-height: 1.6;
}

.faq-list li {
  margin-bottom: var(--space-2);
}

.faq-list li:last-child {
  margin-bottom: 0;
}

.faq-p {
  margin: 0 0 var(--space-2);
  font-size: 14px;
  line-height: 1.55;
  color: #475569;
}

.faq-p:last-child {
  margin-bottom: 0;
}

.faq-p.muted {
  color: var(--text-muted);
}

/* FAQ enhancements: quickstart cards, Q&A accordion, troubleshooting, callouts */
.faq-quickstart {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
  margin: 0 0 16px;
}

.faq-step {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  position: relative;
}

.faq-step__num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--primary-gradient);
  color: #fff;
  font-weight: 700;
  font-size: 13px;
  margin-bottom: 8px;
}

.faq-step__title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 4px;
}

.faq-step__desc {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.45;
}

.faq-step__desc a {
  color: var(--primary);
  text-decoration: none;
}

.faq-step__desc a:hover { text-decoration: underline; }

/* Q&A accordion using <details> */
.faq-qa {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 0;
}

.faq-qa details {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.faq-qa details[open] {
  border-color: #bfdbfe;
  box-shadow: 0 1px 4px rgba(37, 99, 235, 0.06);
}

.faq-qa summary {
  list-style: none;
  cursor: pointer;
  padding: 12px 18px 12px 16px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 10px;
  user-select: none;
}

.faq-qa summary::-webkit-details-marker { display: none; }

.faq-qa summary::before {
  content: "+";
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #eff6ff;
  color: var(--primary);
  font-weight: 700;
  font-size: 16px;
  line-height: 1;
  flex-shrink: 0;
  transition: transform 0.18s, background 0.15s;
}

.faq-qa details[open] summary::before {
  content: "−";
  background: var(--primary);
  color: #fff;
}

.faq-qa summary:hover { background: #f8fafc; }

.faq-qa .faq-qa__body {
  padding: 0 16px 14px 48px;
  font-size: 14px;
  line-height: 1.55;
  color: #475569;
}

.faq-qa .faq-qa__body p { margin: 0 0 8px; }
.faq-qa .faq-qa__body p:last-child { margin-bottom: 0; }
.faq-qa .faq-qa__body ul { margin: 6px 0; padding-left: 1.1rem; }
.faq-qa .faq-qa__body code {
  background: #f1f5f9;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 6px;
  font-size: 13px;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}

/* Troubleshooting cards (problem/solution pair) */
.faq-trouble {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin: 0;
}

.faq-trouble__item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 4px solid #f59e0b;
  border-radius: var(--radius-sm);
  padding: 14px 16px;
}

.faq-trouble__problem {
  font-weight: 600;
  color: #92400e;
  font-size: 14px;
  margin: 0 0 8px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.faq-trouble__solution {
  font-size: 13.5px;
  line-height: 1.55;
  color: #475569;
}

.faq-trouble__solution p { margin: 0 0 6px; }
.faq-trouble__solution p:last-child { margin-bottom: 0; }
.faq-trouble__solution ol { margin: 4px 0; padding-left: 1.1rem; }

/* Callouts inside FAQ panes */
.faq-callout {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  line-height: 1.5;
  margin: 12px 0;
}

.faq-callout--tip { background: #ecfdf5; border: 1px solid #a7f3d0; color: #065f46; }
.faq-callout--warn { background: #fef3c7; border: 1px solid #fcd34d; color: #92400e; }
.faq-callout--info { background: #eff6ff; border: 1px solid #bfdbfe; color: #1e3a8a; }

.faq-callout__icon { flex-shrink: 0; font-size: 16px; line-height: 1.3; }
.faq-callout p { margin: 0; }

/* Mobile FAQ */
@media (max-width: 900px) {
  .faq-layout {
    grid-template-columns: 1fr;
  }
  .faq-sidebar {
    position: static;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 6px;
    max-height: none;
    overflow: visible;
  }
  .faq-nav-btn {
    width: auto;
    flex: 0 0 auto;
    font-size: 12px;
    padding: 8px 12px;
  }
}

/* Supply matrix: status indicator dots in column headers */
.matrix-status-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 6px;
  vertical-align: middle;
  flex-shrink: 0;
}

.matrix-status-dot--assembling { background: #f59e0b; box-shadow: 0 0 0 2px #fef3c7; }
.matrix-status-dot--shipped    { background: #2563eb; box-shadow: 0 0 0 2px #dbeafe; }
.matrix-status-dot--accepted   { background: #10b981; box-shadow: 0 0 0 2px #d1fae5; }
.matrix-status-dot--default    { background: #94a3b8; box-shadow: 0 0 0 2px #e2e8f0; }

/* Колонка поставки на OZON — визуальное отличие от WB-поставок */
.matrix-col-head--ozon {
  border-top: 3px solid #f97316;
  padding-top: 4px;
}
.matrix-col-head--ozon .matrix-col-title {
  color: #c2410c;
  font-weight: 700;
}

.matrix-col-title {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

/* Horizontal scroll affordance — fade-edge hint when content overflows */
.matrix-wrap {
  position: relative;
  background:
    /* Right edge fade */
    linear-gradient(to left, rgba(255,255,255,0), rgba(255,255,255,0.95) 100%) right center / 16px 100% no-repeat,
    /* Right shadow, only visible when scrollable */
    linear-gradient(to left, rgba(15,23,42,0.08), transparent 100%) right center / 8px 100% no-repeat;
  background-attachment: local, scroll;
}

/* Mobile: card-style supply matrix instead of horizontal scroll */
@media (max-width: 768px) {
  .matrix-status-dot {
    width: 10px;
    height: 10px;
  }
}

.faq-swatch {
  display: inline-block;
  width: 14px;
  height: 14px;
  border-radius: 4px;
  vertical-align: middle;
  margin-right: 6px;
  border: 1px solid rgba(0, 0, 0, 0.08);
}

.faq-swatch.mark-burgundy {
  background: #7f1d1d;
}

@media (max-width: 900px) {
  .wh-excel-row {
    flex-direction: column;
    align-items: stretch;
  }

  .wh-excel-row .help-details {
    align-self: flex-start;
  }

  .help-body {
    position: fixed;
    left: 16px;
    right: 16px;
    top: auto;
    bottom: 16px;
    max-width: none;
    max-height: 40vh;
    overflow-y: auto;
  }
}

@media (max-width: 640px) {
  body {
    padding: 12px;
    font-size: 14px;
  }

  h1 {
    font-size: 24px;
  }

  h2 {
    font-size: 18px;
  }

  .container {
    padding: 12px;
  }

  .card {
    padding: 16px;
    border-radius: 16px;
    margin-bottom: 12px;
    box-shadow: none;
  }

  .grid-form,
  .table-toolbar-row,
  .faq-layout,
  .support-layout,
  .inner-layout {
    grid-template-columns: 1fr !important;
  }

  button,
  .btn-outline {
    width: 100%;
    min-height: 44px;
    margin-bottom: 12px;
  }

  input[type="text"],
  input[type="number"],
  input[type="password"],
  input[type="email"],
  input[type="date"],
  input[type="search"],
  select {
    width: 100%;
    padding: 12px;
    border-radius: 12px;
  }

  a,
  li,
  p,
  span {
    overflow-wrap: anywhere;
    word-break: break-word;
  }
}

@media (max-width: 900px) {
  .container {
    padding: var(--space-3) var(--space-2);
  }

  .inner-layout {
    grid-template-columns: 1fr;
  }

  .side-nav {
    flex-direction: row;
    flex-wrap: wrap;
  }

  .grid-form {
    grid-template-columns: 1fr;
  }

  .settings-zone {
    padding: var(--space-2);
  }

  .fixed-btn {
    width: 100%;
    min-width: 0;
  }

  .inline-form {
    flex-direction: column;
    align-items: stretch;
  }

  .inline-form > button,
  .inline-form > input,
  .inline-form > input[type="file"] {
    width: 100%;
    max-width: none;
  }

  table {
    min-width: 760px;
  }

  .faq-layout {
    grid-template-columns: 1fr;
  }

  .faq-sidebar {
    position: static;
    max-height: none;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 6px;
  }

  .faq-nav-btn {
    flex: 1 1 calc(50% - 4px);
    min-width: 0;
    text-align: center;
    font-size: 12px;
    padding: 8px 6px;
  }

  .faq-content {
    padding: var(--space-2);
  }

  .cabinet-current-inline {
    width: 100%;
  }

  .cabinet-switch-select {
    width: min(180px, 100%);
    height: 28px;
    min-height: 28px;
  }
}

/* Support page */
.support-layout {
  display: grid;
  grid-template-columns: 300px 820px;
  gap: 16px;
  align-items: start;
}

.support-sidebars-col {
  display: flex;
  flex-direction: column;
  gap: 16px;
  width: 300px;
}

.support-sidebar {
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
  padding: 10px;
  width: 300px;
}

.support-sidebar-open {
  min-height: 520px;
}

.support-sidebar-closed {
  height: 300px;
  min-height: 300px;
  max-height: 300px;
  overflow: hidden;
}

.support-list {
  margin-top: 8px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  max-height: 520px;
  overflow-y: auto;
  overflow-x: hidden;
}

.support-list-closed {
  max-height: 240px;
}

.support-list-item {
  width: 220px;
  max-width: 220px;
  text-align: left;
  background: #f8fafc;
  color: #0f172a;
  border: 1px solid #dbe3ee;
  border-radius: 8px;
  padding: 8px;
  min-height: 42px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.support-list-item.active {
  border-color: #2563eb;
  background: #eff6ff;
}

.support-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 999px;
  margin-left: 6px;
  background: transparent;
}

.support-dot.has-reply {
  background: #dc2626;
}

.support-main {
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
  padding: 10px;
  width: 820px;
}

.support-create {
  display: grid;
  grid-template-columns: 1fr;
  gap: 6px;
  margin-bottom: 6px;
}

.support-messages {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  width: 800px;
  min-width: 800px;
  max-width: 800px;
  height: 150px;
  min-height: 150px;
  max-height: 150px;
  overflow: auto;
  padding: 8px;
}

.support-msg {
  border-radius: 8px;
  padding: 8px;
  margin: 6px 0;
}

.support-msg-user {
  background: #f1f5f9;
}

.support-msg-admin {
  background: #e9f2ff;
}

.support-msg-meta {
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 3px;
}

.support-send {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  margin-top: 8px;
  width: 800px;
}

.support-send textarea,
.support-create textarea {
  width: 800px;
  min-width: 800px;
  max-width: 800px;
  min-height: 98px;
  height: 150px;
  max-height: 150px;
  resize: vertical;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--border-strong);
  font-family: inherit;
  font-size: 14px;
  line-height: 1.4;
}

.support-send textarea:focus,
.support-create textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: var(--focus);
}

.support-modal {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.35);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 120;
  padding: 16px;
}

.support-modal.open {
  display: flex;
}

.support-modal-card {
  width: min(840px, 100%);
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow-md);
  padding: 14px;
  max-height: 90vh;
  overflow: auto;
}

.support-create input[type="text"] {
  width: 800px;
  min-width: 800px;
  max-width: 800px;
  height: 42px;
  min-height: 42px;
  max-height: 42px;
}

#supportOpenCreateModalBtn {
  margin-top: 0;
  margin-bottom: 0;
}

.support-send button {
  width: 200px;
}

@media (max-width: 900px) {
  .support-layout {
    grid-template-columns: 1fr;
  }
}

/* Mobile hardening: prevent global horizontal overflow */
@media (max-width: 640px) {
  html,
  body,
  main,
  section,
  .container,
  .card,
  .page-header,
  .inner-content,
  .support-main,
  .support-sidebar,
  .support-sidebars-col {
    max-width: 100% !important;
    overflow-x: hidden !important;
    box-sizing: border-box;
  }

  body,
  .container {
    padding: 12px !important;
  }

  .table-wrap,
  .matrix-wrap {
    overflow-x: auto !important;
  }

  .main-tabs,
  .tabs {
    overflow-x: auto !important;
    overflow-y: hidden !important;
    flex-wrap: nowrap !important;
    -webkit-overflow-scrolling: touch;
  }

  .api-row,
  .settings-planning-grid,
  .local-panel-row,
  .local-panel-actions,
  .local-matrix-toolbar .local-panel-actions,
  .table-tools,
  .inline-form,
  .wh-excel-row,
  .support-send,
  .support-create,
  .support-layout,
  .support-sidebars-col {
    display: flex !important;
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 10px !important;
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
  }

  .settings-planning-grid > label,
  .settings-planning-grid > label > input,
  .settings-planning-grid > label > select,
  .settings-planning-grid > .settings-planning-check,
  .settings-planning-check-box,
  .settings-tab-content[data-settings-tab-panel="settings-api"] .api-row > label,
  .settings-tab-content[data-settings-tab-panel="settings-api"] .api-row > label > input,
  .settings-tab-content[data-settings-tab-panel="settings-api"] .settings-zone > label > select,
  .settings-tab-content[data-settings-tab-panel="settings-api"] .settings-zone > label > input,
  .settings-tab-content[data-settings-tab-panel="settings-api"] .fixed-btn,
  .local-panel-row--supplies-head .local-matrix-warehouse,
  .local-panel-row--supplies-head .local-matrix-date,
  .local-panel-row--supplies-import .local-panel-file,
  .inbound-mesh-date,
  .inbound-mesh-select,
  .inbound-mesh-file,
  .support-messages,
  .support-send textarea,
  .support-create textarea,
  .support-create input[type="text"] {
    width: 100% !important;
    min-width: 0 !important;
    max-width: 100% !important;
  }

  .btn,
  button,
  .login-btn,
  .fixed-btn,
  .btn-outline,
  [type="submit"] {
    width: 100% !important;
    min-height: 44px !important;
    margin: 4px 0 !important;
    box-sizing: border-box !important;
  }

  input,
  select,
  textarea {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    font-size: 16px !important;
    padding: 12px !important;
    border-radius: 12px !important;
    box-sizing: border-box !important;
  }

  .support-modal {
    padding: 12px !important;
  }

  .support-modal-card {
    width: calc(100% - 24px) !important;
    max-width: none !important;
    margin: 12px !important;
  }
}

/* Unified button variants */
.btn-primary {
  background: #2563eb !important;
  color: #fff !important;
  border: 1px solid #2563eb !important;
}

.btn-secondary {
  background: #e2e8f0 !important;
  color: #0f172a !important;
  border: 1px solid #cbd5e1 !important;
}

.btn-danger {
  background: #dc2626 !important;
  color: #fff !important;
  border: 1px solid #dc2626 !important;
}

.btn-outline {
  background: transparent !important;
  color: #0f172a !important;
  border: 1px solid #cbd5e1 !important;
}

.btn-icon {
  margin-right: 6px;
  opacity: 0.9;
}

/* Custom feedback UI */
.ui-toast-container {
  position: fixed;
  right: 14px;
  bottom: 14px;
  z-index: 4000;
  display: grid;
  gap: 8px;
  max-width: min(92vw, 360px);
}

.ui-toast {
  background: #0f172a;
  color: #fff;
  padding: 10px 12px;
  border-radius: 12px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
  font-size: 13px;
}

.ui-toast.error {
  background: #991b1b;
}

.ui-confirm-overlay {
  position: fixed;
  inset: 0;
  z-index: 4100;
  background: rgba(15, 23, 42, 0.5);
  display: none;
  align-items: center;
  justify-content: center;
}

.ui-confirm-overlay.open {
  display: flex;
}

.ui-confirm-card {
  width: min(520px, calc(100% - 24px));
  margin: 12px;
  background: #fff;
  border-radius: 16px;
  border: 1px solid #e2e8f0;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
  padding: 16px;
}

.ui-confirm-actions {
  margin-top: 12px;
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

.is-loading {
  opacity: 0.75;
  pointer-events: none;
}

.spinner-inline {
  display: inline-block;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-top-color: #fff;
  animation: spin 0.8s linear infinite;
  vertical-align: middle;
  margin-right: 6px;
}

/* Support improvements */
.support-tools {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 10px;
}

.support-list-item .status-badge {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 6px;
  border-radius: 999px;
  font-size: 11px;
  background: #e0f2fe;
  color: #0c4a6e;
}

/* Warehouse settings helpers */
.warehouse-tools {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 8px;
  margin-bottom: 10px;
}

/* Mobile strict requirements */
@media (max-width: 768px) {
  button,
  .btn,
  .btn-outline,
  .fixed-btn,
  [type="submit"] {
    width: 100% !important;
    min-height: 44px !important;
    margin-bottom: 8px !important;
  }

  input,
  select,
  textarea {
    width: 100% !important;
    max-width: 100% !important;
    font-size: 16px !important;
  }

  .card {
    padding: 16px !important;
    margin-bottom: 12px !important;
  }

  .table-wrap,
  .matrix-wrap {
    -webkit-overflow-scrolling: touch;
  }

  #supply-import-modal > div,
  #template-supply-modal > div {
    width: calc(100% - 24px) !important;
    max-width: none !important;
    margin: 12px !important;
    padding: 16px !important;
  }

  td:has(input[type="checkbox"]),
  th:has(input[type="checkbox"]) {
    min-width: 52px !important;
    width: 52px !important;
    text-align: center;
  }
}

@media (max-width: 480px) {
  .support-tools,
  .warehouse-tools {
    grid-template-columns: 1fr;
  }

  .ui-confirm-actions {
    flex-direction: column;
  }
}

@media (max-width: 767px) {
  .summary-redesign .summary-side-nav .tab-btn,
  .summary-redesign .summary-period-chips .period-hotkey,
  .warehouse-ref-ag-wrap .btn-outline {
    width: auto !important;
    margin-bottom: 0 !important;
  }
}

/* ============================================================
   UX layer: toasts, subscription warning, empty states
   (Iteration 4 — non-breaking visual improvements)
   ============================================================ */

/* Toast notifications */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
  max-width: calc(100vw - 32px);
}

.toast {
  background: #1e293b;
  color: #fff;
  padding: 12px 16px 12px 18px;
  border-radius: 12px;
  font-size: 14px;
  line-height: 1.4;
  pointer-events: auto;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  max-width: 400px;
  min-width: 240px;
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.18);
  border-left: 3px solid #64748b;
  animation: toast-in 0.18s ease-out;
}

.toast--success { border-left-color: #10b981; }
.toast--error   { border-left-color: #ef4444; }
.toast--info    { border-left-color: #2563eb; }
.toast--warning { border-left-color: #f59e0b; }

.toast.is-leaving { animation: toast-out 0.25s ease-in forwards; }

.toast__body { flex: 1; min-width: 0; word-wrap: break-word; }

.toast__close {
  background: transparent;
  border: 0;
  color: rgba(255, 255, 255, 0.7);
  font-size: 16px;
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
}

.toast__close:hover { color: #fff; }

@keyframes toast-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes toast-out {
  from { opacity: 1; transform: translateY(0); }
  to   { opacity: 0; transform: translateY(8px); }
}

@media (max-width: 640px) {
  .toast-container {
    left: 16px;
    right: 16px;
    bottom: 16px;
    max-width: calc(100vw - 32px);
  }
  .toast { max-width: 100%; }
}

/* Subscription warning banner (sticky under header) */
.subscription-warning {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  background: #fef3c7;
  border: 1px solid #fcd34d;
  color: #78350f;
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 13px;
  font-weight: 500;
  margin: 12px 0 16px;
  box-shadow: 0 1px 2px rgba(146, 64, 14, 0.08);
}

.subscription-warning--critical {
  background: #fee2e2;
  border-color: #fca5a5;
  color: #991b1b;
}

.subscription-warning__icon { font-size: 16px; line-height: 1; }
.subscription-warning__text { flex: 1; min-width: 200px; }

.subscription-warning__cta {
  background: #fff;
  border: 1px solid currentColor;
  color: inherit;
  padding: 6px 14px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

.subscription-warning__cta:hover { background: rgba(255, 255, 255, 0.6); }

/* Empty states */
.empty-state {
  text-align: center;
  padding: 36px 20px;
  color: #94a3b8;
}

.empty-state__icon {
  font-size: 2.2rem;
  margin-bottom: 10px;
  line-height: 1;
}

.empty-state__title {
  font-size: 0.95rem;
  font-weight: 600;
  color: #64748b;
  margin-bottom: 6px;
}

.empty-state__hint {
  font-size: 0.82rem;
  color: #94a3b8;
}

/* Inline-flash → keep server-rendered alerts hidden when JS toast layer is active */
body.has-toast-layer .alert.alert-success[data-flash="auto"],
body.has-toast-layer .alert.alert-error[data-flash="auto"] {
  display: none;
}

/* Dashboard Overview tab — KPI cards */
.overview-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.kpi-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  position: relative;
  overflow: hidden;
}

.kpi-card::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 4px;
  background: var(--primary-gradient);
}

.kpi-card--warning::before { background: linear-gradient(180deg, #f59e0b, #d97706); }
.kpi-card--danger::before  { background: linear-gradient(180deg, #ef4444, #b91c1c); }
.kpi-card--success::before { background: linear-gradient(180deg, #10b981, #059669); }

.kpi-card__label {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}

.kpi-card__value {
  font-size: 28px;
  font-weight: 800;
  color: var(--text);
  line-height: 1.1;
}

.kpi-card__hint {
  font-size: 12px;
  color: var(--text-muted);
}

.overview-quick-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 8px;
}

.overview-quick-actions .btn-outline,
.overview-quick-actions .btn-primary {
  font-size: 13px;
}

/* ── Loading states ────────────────────────────────────────── */
@keyframes spin {
  to { transform: rotate(360deg); }
}

.spinner-inline {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  vertical-align: middle;
  margin-left: 6px;
  opacity: 0.8;
}

.btn-loading {
  opacity: 0.7;
  cursor: not-allowed;
  pointer-events: none;
}

.htmx-indicator { display: none; }
.htmx-request .htmx-indicator { display: inline-block; }
.htmx-request.htmx-indicator { display: inline-block; }

/* ── CSS Tooltips ──────────────────────────────────────────── */
[data-tip] {
  position: relative;
  cursor: help;
}

[data-tip]::after {
  content: attr(data-tip);
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  background: #1e293b;
  color: #f8fafc;
  font-size: 12px;
  font-weight: 400;
  line-height: 1.45;
  padding: 6px 10px;
  border-radius: 8px;
  white-space: pre-wrap;
  max-width: 260px;
  width: max-content;
  text-align: left;
  box-shadow: 0 4px 12px rgba(0,0,0,0.18);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s ease;
  z-index: 9000;
}

[data-tip]:hover::after {
  opacity: 1;
}

/* keep inline info badges consistent */
.info-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 14px;
  height: 14px;
  border: 1px solid #94a3b8;
  border-radius: 50%;
  font-size: 10px;
  line-height: 1;
  color: #64748b;
  background: transparent;
  cursor: help;
  vertical-align: middle;
  margin-left: 3px;
}

/* ── Responsive warehouse-settings table → cards (≤768px) ── */
@media (max-width: 768px) {
  table[data-table="settings-warehouses"] thead { display: none; }

  table[data-table="settings-warehouses"],
  table[data-table="settings-warehouses"] tbody,
  table[data-table="settings-warehouses"] tr,
  table[data-table="settings-warehouses"] td {
    display: block;
    width: 100%;
  }

  table[data-table="settings-warehouses"] tr {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    margin-bottom: 10px;
    padding: 12px 14px;
    display: flex;
    flex-direction: column;
    gap: 6px;
  }

  table[data-table="settings-warehouses"] td {
    padding: 0;
    border: none;
  }

  /* warehouse name row */
  table[data-table="settings-warehouses"] td:first-child {
    font-weight: 600;
    font-size: 13px;
    color: var(--text);
    margin-bottom: 6px;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--border);
  }

  /* checkbox rows as labeled rows */
  table[data-table="settings-warehouses"] td:not(:first-child) {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: var(--text-muted);
  }

  table[data-table="settings-warehouses"] td:nth-child(2)::before { content: "Остатки"; }
  table[data-table="settings-warehouses"] td:nth-child(3)::before { content: "Заказы"; }
  table[data-table="settings-warehouses"] td:nth-child(4)::before { content: "Оборачиваемость"; }
  table[data-table="settings-warehouses"] td:nth-child(5)::before { content: "Учитывать в планировании"; }
  table[data-table="settings-warehouses"] td:nth-child(6)::before { content: "Учитывать при расчете"; }

  table[data-table="settings-warehouses"] td:not(:first-child)::before {
    min-width: 160px;
    font-weight: 500;
    color: var(--text-muted);
  }
}

/* ── Sales Plan ─────────────────────────────────────────────────────────── */
.sp-hint-dot {
  display: inline-block;
  width: 9px; height: 9px;
  border-radius: 50%;
  cursor: help;
  flex-shrink: 0;
  vertical-align: middle;
  margin-left: 4px;
}
.sp-hint-dot--high        { background: #10b981; }
.sp-hint-dot--medium      { background: #f59e0b; }
.sp-hint-dot--low         { background: #94a3b8; }
.sp-hint-dot--conservative { background: #f59e0b; }
.sp-hint-dot--realistic   { background: #10b981; }
.sp-hint-dot--ambitious   { background: #ef4444; }
.sp-hint-dot--insufficient { background: #94a3b8; }

/* Modal overlay */
.sp-modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.55);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.sp-modal-overlay.sp-modal-open { display: flex; }
.sp-modal {
  background: var(--bg-card, #1e293b);
  border-radius: 14px;
  width: 100%;
  max-width: 680px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 24px 64px rgba(0,0,0,.5);
}
.sp-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px 14px;
  border-bottom: 1px solid var(--border-color, #334155);
}
.sp-modal-header h3 { margin: 0; font-size: 1rem; font-weight: 600; }
.sp-modal-close {
  background: none; border: none; cursor: pointer;
  color: var(--text-muted); font-size: 1.2rem; padding: 2px 6px;
}
.sp-modal-body { flex: 1; overflow-y: auto; padding: 16px 20px; }
.sp-modal-footer {
  padding: 14px 20px;
  border-top: 1px solid var(--border-color, #334155);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.sp-step { display: none; }
.sp-step.sp-step--active { display: block; }

/* SKU list in modal step 1 */
.sp-sku-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 340px;
  overflow-y: auto;
  border: 1px solid var(--border-color, #334155);
  border-radius: 8px;
  padding: 6px;
  margin-top: 8px;
}
.sp-sku-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 8px;
  border-radius: 6px;
  cursor: pointer;
  user-select: none;
}
.sp-sku-row:hover { background: rgba(255,255,255,.04); }
.sp-sku-check { flex-shrink: 0; accent-color: #3b82f6; }
.sp-sku-photo { width: 36px; height: 36px; flex-shrink: 0; }
.sp-sku-photo-placeholder { display: flex; align-items: center; justify-content: center; width: 36px; height: 36px; font-size: 1.3rem; }
.sp-sku-info { flex: 1; min-width: 0; }
.sp-sku-article { display: block; font-size: .8rem; font-weight: 600; color: var(--text-muted); }
.sp-sku-name { display: block; font-size: .85rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sp-sku-hist {
  font-size: .78rem;
  font-weight: 500;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 4px;
}
.sp-sku-hist--high   { color: #10b981; }
.sp-sku-hist--medium { color: #f59e0b; }
.sp-sku-hist--low    { color: #94a3b8; }

/* Step 2 — daily plan table */
.sp-plan-table { width: 100%; border-collapse: collapse; font-size: .85rem; }
.sp-plan-table th {
  text-align: left;
  padding: 6px 8px;
  font-size: .75rem;
  font-weight: 600;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border-color, #334155);
}
.sp-plan-table td { padding: 6px 8px; vertical-align: middle; }
.sp-plan-table tbody tr:hover { background: rgba(255,255,255,.03); }
.sp-plan-input {
  width: 80px;
  background: var(--bg-input, #0f172a);
  border: 1px solid var(--border-color, #334155);
  border-radius: 6px;
  color: inherit;
  padding: 4px 6px;
  font-size: .85rem;
  text-align: right;
}
.sp-plan-input:focus { outline: none; border-color: #3b82f6; }
.sp-plan-dot-cell { display: flex; align-items: center; gap: 6px; }

/* Period warn */
.sp-period-warn {
  font-size: .78rem;
  color: #f59e0b;
  margin-top: 4px;
  display: none;
}
.sp-period-warn.sp-period-warn--show { display: block; }

/* Gap table (plan view) */
.sp-gap-table { width: 100%; border-collapse: collapse; font-size: .83rem; }
.sp-gap-table th {
  text-align: left;
  padding: 7px 10px;
  font-size: .75rem;
  font-weight: 600;
  color: var(--text-muted);
  border-bottom: 2px solid var(--border-color, #334155);
  white-space: nowrap;
}
.sp-gap-table td { padding: 7px 10px; vertical-align: middle; border-bottom: 1px solid rgba(255,255,255,.05); }
.sp-gap-table tbody tr:hover { background: rgba(255,255,255,.03); }

.sp-coverage-bar-wrap { display: flex; align-items: center; gap: 8px; min-width: 120px; }
.sp-coverage-bar-bg {
  flex: 1; height: 8px; border-radius: 4px;
  background: rgba(255,255,255,.1);
  overflow: hidden;
}
.sp-coverage-bar-fill {
  height: 100%;
  border-radius: 4px;
  transition: width .3s;
  max-width: 100%;
}
.sp-coverage-bar-fill--ok     { background: #10b981; }
.sp-coverage-bar-fill--medium { background: #f59e0b; }
.sp-coverage-bar-fill--high   { background: #ef4444; }
.sp-coverage-bar-fill--no-plan { background: #475569; }

.sp-risk-badge {
  display: inline-block;
  padding: 2px 7px;
  border-radius: 10px;
  font-size: .7rem;
  font-weight: 700;
  letter-spacing: .03em;
}
.sp-risk-badge--ok     { background: rgba(16,185,129,.15); color: #10b981; }
.sp-risk-badge--medium { background: rgba(245,158,11,.15); color: #f59e0b; }
.sp-risk-badge--high   { background: rgba(239,68,68,.15);  color: #ef4444; }
.sp-risk-badge--no-plan { background: rgba(71,85,105,.15); color: #94a3b8; }

/* KPI row in plan view */
.sp-kpi-row { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.sp-kpi-card {
  flex: 1; min-width: 120px;
  background: var(--bg-input, #0f172a);
  border: 1px solid var(--border-color, #334155);
  border-radius: 10px;
  padding: 12px 14px;
}
.sp-kpi-card__label { font-size: .72rem; color: var(--text-muted); margin-bottom: 4px; }
.sp-kpi-card__value { font-size: 1.15rem; font-weight: 700; }

/* ══════════════════════════════════════════════════════════
   FAQ: Live search
   ══════════════════════════════════════════════════════════ */
.faq-search-wrap {
  position: relative;
  margin-bottom: 20px;
}
.faq-search-wrap svg {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: #94a3b8;
  pointer-events: none;
  width: 16px; height: 16px;
}
#faq-input {
  width: 100%;
  box-sizing: border-box;
  padding: 10px 16px 10px 38px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  background: var(--surface, #fff);
  color: var(--text);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
#faq-input:focus {
  border-color: var(--primary, #6366f1);
  box-shadow: 0 0 0 3px rgba(99,102,241,0.12);
}
#faq-results { padding-bottom: 8px; }
#faq-results[hidden] { display: none; }

.faq-result-item {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 18px;
  margin-bottom: 10px;
  background: var(--surface, #fff);
  cursor: pointer;
  transition: border-color 0.15s, background 0.1s;
}
.faq-result-item:hover {
  border-color: var(--primary, #6366f1);
  background: var(--surface-2, #f8fafc);
}
.faq-result-item__section {
  font-size: 11px;
  color: #94a3b8;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  margin-bottom: 4px;
}
.faq-result-item__q {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 6px;
  line-height: 1.4;
}
.faq-result-item__a {
  font-size: 12.5px;
  color: #64748b;
  line-height: 1.55;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
#faq-results mark {
  background: #fef08a;
  color: inherit;
  padding: 0 2px;
  border-radius: 2px;
  font-style: normal;
}
.faq-no-results {
  text-align: center;
  padding: 40px 24px;
  color: #94a3b8;
}
.faq-no-results a {
  color: var(--primary, #6366f1);
  text-decoration: underline;
}

/* ══════════════════════════════════════════════════════════
   FAQ: Anchor link buttons
   ══════════════════════════════════════════════════════════ */
.faq-anchor-btn {
  opacity: 0;
  background: none;
  border: none;
  color: #94a3b8;
  cursor: pointer;
  font-size: 13px;
  padding: 0 5px;
  vertical-align: middle;
  transition: opacity 0.15s, color 0.12s;
  line-height: 1;
  user-select: none;
}
.faq-pane h3:hover .faq-anchor-btn,
.faq-pane h4:hover .faq-anchor-btn,
.faq-qa details summary:hover .faq-anchor-btn {
  opacity: 1;
}
.faq-anchor-btn:hover { color: var(--primary, #6366f1); }
.faq-anchor-btn.copied {
  opacity: 1;
  color: #10b981;
}

/* ══════════════════════════════════════════════════════════
   FAQ: Term tooltips (.term-tip reuses [data-tip]::after)
   ══════════════════════════════════════════════════════════ */
.term-tip {
  border-bottom: 1px dashed #94a3b8;
  cursor: help;
  /* max-width for this variant */
}
/* override max-width for term-tip (wider definition) */
.term-tip[data-tip]::after {
  max-width: 280px;
  white-space: pre-wrap;
}
/* Mobile tap: toggle .tip-open class via JS */
@media (max-width: 640px) {
  [data-tip]:hover::after         { opacity: 0; }  /* disable hover */
  .term-tip.tip-open[data-tip]::after { opacity: 1; }
}

/* ══════════════════════════════════════════════════════════
   FAQ: Simple data table (.faq-table)
   ══════════════════════════════════════════════════════════ */
.faq-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
  margin: 12px 0 16px;
}
.faq-table th,
.faq-table td {
  padding: 8px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border, #e2e8f0);
}
.faq-table thead th {
  background: var(--surface, #f8fafc);
  font-weight: 600;
  color: var(--text, #1e293b);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.faq-table tbody tr:hover {
  background: var(--surface, #f8fafc);
}
@media (max-width: 600px) {
  .faq-table thead { display: none; }
  .faq-table tr    { display: block; padding: 8px 0; border-bottom: 1px solid var(--border, #e2e8f0); }
  .faq-table td    { display: block; padding: 2px 0; border: none; }
  .faq-table td:first-child { font-weight: 600; }
}

/* ─── Модалка создания поставки ─────────────────────────────────── */
.sup-modal {
  position: fixed;
  inset: 0;
  z-index: 9000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.sup-modal[hidden] { display: none; }
.sup-modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(2px);
}
.sup-modal__dialog {
  position: relative;
  background: #fff;
  color: #0f172a;
  border-radius: 14px;
  width: 100%;
  max-width: 820px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.4);
  overflow: hidden;
}
.sup-modal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid #e2e8f0;
}
.sup-modal__header h3 { margin: 0; font-size: 1.1rem; }
.sup-modal__close {
  background: none;
  border: none;
  font-size: 1.4rem;
  cursor: pointer;
  color: #64748b;
  padding: 0 4px;
}
.sup-modal__close:hover { color: #0f172a; }
.sup-modal__body {
  padding: 16px 20px;
  overflow-y: auto;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.sup-modal__params {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 12px;
}
.sup-modal__field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.85rem;
  font-weight: 600;
  color: #475569;
}
.sup-modal__field select,
.sup-modal__field input {
  padding: 8px 10px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  font-size: 0.95rem;
  color: #0f172a;
  background: #fff;
}
.sup-modal__field select:focus,
.sup-modal__field input:focus {
  outline: none;
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}
.sup-modal__items-head {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}
.sup-modal__search {
  flex: 1;
  min-width: 200px;
  padding: 8px 12px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  font-size: 0.95rem;
}
.sup-modal__excel-btn {
  cursor: pointer;
  white-space: nowrap;
}
.sup-modal__hint {
  font-size: 0.8rem;
  margin: 0;
}
.sup-modal__items-list {
  max-height: 50vh;
  min-height: 200px;
  overflow-y: auto;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  background: #f8fafc;
}
.sup-modal__item {
  display: grid;
  grid-template-columns: 48px 1fr 120px;
  gap: 10px;
  align-items: center;
  padding: 8px 12px;
  border-bottom: 1px solid #e2e8f0;
  transition: background 0.1s;
}
.sup-modal__item:last-child { border-bottom: none; }
.sup-modal__item:hover { background: #fff; }
.sup-modal__item--active { background: #ecfdf5; }
.sup-modal__item--active:hover { background: #d1fae5; }
.sup-modal__item-photo img {
  width: 48px;
  height: 48px;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid #e2e8f0;
}
.sup-modal__no-photo {
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #e2e8f0;
  border-radius: 6px;
  color: #94a3b8;
}
.sup-modal__item-info { min-width: 0; }
.sup-modal__item-article {
  font-weight: 600;
  font-size: 0.9rem;
  color: #0f172a;
}
.sup-modal__item-name {
  font-size: 0.85rem;
  color: #475569;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.sup-modal__item-meta {
  font-size: 0.75rem;
  color: #94a3b8;
}
.sup-modal__item-qty input {
  width: 100%;
  padding: 6px 8px;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  text-align: center;
  font-size: 0.95rem;
}
.sup-modal__item-qty input:focus {
  outline: none;
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}
.sup-modal__empty {
  padding: 32px;
  text-align: center;
  color: #94a3b8;
  font-size: 0.9rem;
}
.sup-modal__counter {
  font-size: 0.9rem;
  color: #475569;
  padding: 4px 0;
}
.sup-modal__counter strong { color: #0f172a; }
.sup-modal__footer {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  padding: 12px 20px;
  border-top: 1px solid #e2e8f0;
  background: #f8fafc;
  flex-wrap: wrap;
}
.sup-modal__footer button[disabled] {
  opacity: 0.5;
  cursor: not-allowed;
}
@media (max-width: 640px) {
  .sup-modal__dialog { max-height: 100vh; border-radius: 0; }
  .sup-modal__params { grid-template-columns: 1fr; }
  .sup-modal__item { grid-template-columns: 40px 1fr 90px; }
}

/* ─── KPI-карточки: маркер тренда ─────────────────────────────── */
.kpi-card__value-row {
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex-wrap: wrap;
}
.kpi-trend {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 99px;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.4;
  white-space: nowrap;
  cursor: help;
  user-select: none;
}
.kpi-trend__arrow { font-size: 13px; }
.kpi-trend__delta { font-size: 11px; opacity: 0.9; }
.kpi-trend.trend--good {
  background: #dcfce7;
  color: #15803d;
  border: 1px solid #bbf7d0;
}
.kpi-trend.trend--bad {
  background: #fee2e2;
  color: #b91c1c;
  border: 1px solid #fecaca;
}
.kpi-trend.trend--neutral {
  background: #f1f5f9;
  color: #475569;
  border: 1px solid #e2e8f0;
}
