/* Базовая типографика и фон в стиле Notion */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
}

.app-body {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background-color: #f7f6f3;
  color: #1f1f1f;
}

.app-shell {
  display: flex;
  height: 100vh;
  max-height: 100vh;
  overflow: hidden;
}

/* Sidebar: прокручивается только список пунктов меню */
.sidebar {
  width: 260px;
  flex-shrink: 0;
  background-color: #f4f3ef;
  border-right: 1px solid #e0ded8;
  padding: 12px 10px;
  display: flex;
  flex-direction: column;
  min-height: 0;
  height: 100%;
  overflow: hidden;
}

.sidebar-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px 12px;
  margin-bottom: 6px;
}

.sidebar-logo {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  background-color: #ffffff;
  box-shadow: 0 0 0 1px rgba(15, 15, 15, 0.05);
}

.sidebar-title {
  display: flex;
  flex-direction: column;
}

.sidebar-app-name {
  font-size: 14px;
  font-weight: 600;
}

.sidebar-app-subtitle {
  font-size: 11px;
  color: #84827a;
}

.sidebar-search {
  padding: 0 10px 10px;
}

.sidebar-search input {
  width: 100%;
  padding: 6px 8px;
  border-radius: 6px;
  border: 1px solid #d9d4c9;
  background-color: #fbfaf7;
  font-size: 13px;
}

.sidebar-nav {
  padding: 4px 4px 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
}

.sidebar-section-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #a39f93;
  padding: 8px 8px 4px;
}

.sidebar-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: 6px;
  border: none;
  background: transparent;
  text-align: left;
  font-size: 13px;
  color: #3f3d36;
  cursor: pointer;
}

.sidebar-item:hover {
  background-color: #e8e4db;
}

.sidebar-item--active {
  background-color: #e2dfd5;
  box-shadow: 0 0 0 1px rgba(15, 15, 15, 0.04);
}

.sidebar-item-icon {
  width: 20px;
  text-align: center;
}

/* Main: контент справа прокручивается внутри панели, не растягивая страницу */
.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 20px;
  border-bottom: 1px solid #e0ded8;
  background-color: #f7f6f3;
}

.topbar-breadcrumbs {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: #6b675f;
}

.topbar-breadcrumb-current {
  font-weight: 500;
  color: #262421;
}

.sync-status {
  font-size: 12px;
  padding: 4px 8px;
  border-radius: 999px;
  background-color: #ecebe7;
  color: #5a574f;
  white-space: nowrap;
}

.sync-status--online {
  background-color: #e0f5e8;
  color: #207244;
}

.sync-status--error {
  background-color: #fdecea;
  color: #a33a2c;
}

/* Auth indicator styles within sync-status */
.sync-status[data-auth="unauthenticated"] {
  background-color: #fff3cd;
  color: #856404;
}

.sync-status[data-auth="offline"] {
  background-color: #e2e3e5;
  color: #383d41;
}

/* ========== Pagination ========== */
.pagination-container {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  background: #f7f6f3;
  border-top: 1px solid #e0ded8;
  font-size: 13px;
}

.pagination-info {
  color: #6b675f;
}

.pagination-buttons {
  display: flex;
  align-items: center;
  gap: 8px;
}

.pagination-current {
  padding: 0 12px;
  color: #3f3d36;
  font-weight: 500;
}

.pagination-buttons .btn {
  padding: 5px 10px;
  font-size: 12px;
}

.pagination-buttons .btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.content {
  padding: 16px 24px 24px;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
}

.content-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.page-title {
  font-size: 22px;
  margin: 0 0 4px;
}

.content-header-search {
  display: flex;
  align-items: center;
  gap: 8px;
}

.input {
  border-radius: 6px;
  border: 1px solid #d9d4c9;
  padding: 7px 9px;
  font-size: 13px;
  background-color: #fbfaf7;
}

.input:focus {
  outline: none;
  border-color: #a39f93;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.04);
}

.input--textarea {
  resize: vertical;
}

.btn {
  border-radius: 6px;
  padding: 7px 12px;
  font-size: 13px;
  border: 1px solid transparent;
  cursor: pointer;
  background-color: #f4f3ef;
  color: #292826;
}

.btn:hover {
  background-color: #e9e6de;
}

.btn-primary {
  background-color: #2f76ff;
  border-color: #2f76ff;
  color: #ffffff;
}

.btn-primary:hover {
  background-color: #265fcc;
}

.btn-secondary {
  background-color: #f4f3ef;
  border-color: #d9d4c9;
}

.btn-danger {
  background-color: #e55353;
  border-color: #e55353;
  color: #ffffff;
}

.btn-danger:hover {
  background-color: #c73d3d;
}

.btn-tertiary {
  background-color: #fbfaf7;
  border-color: #e0ded8;
}

.table-wrapper {
  background-color: #ffffff;
  border-radius: 10px;
  box-shadow: 0 1px 2px rgba(15, 15, 15, 0.05);
  border: 1px solid rgba(15, 15, 15, 0.06);
  overflow: hidden;
}

.product-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.product-table thead {
  background-color: #f7f6f3;
}

.product-table th,
.product-table td {
  padding: 8px 10px;
  border-bottom: 1px solid #efede7;
  text-align: left;
  vertical-align: top;
}

.product-table th {
  font-weight: 500;
  color: #666258;
  font-size: 12px;
}

.product-table tr:hover td {
  background-color: #f6f5f1;
}

.product-table tr.selected td {
  background-color: #e3f2ff;
}

.product-table td.text-muted {
  color: #969186;
}

/* Row action buttons - shown on hover */
.row-actions {
  display: none;
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  gap: 4px;
  z-index: 10;
}

.product-table tbody tr {
  position: relative;
}

.product-table tbody tr:hover .row-actions {
  display: flex;
}

.row-action-btn {
  width: 28px;
  height: 28px;
  border: none;
  border-radius: 4px;
  background: #ffffff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  transition: all 0.15s ease;
}

.row-action-btn:hover {
  transform: scale(1.1);
}

.row-action-btn--view {
  color: #2f76ff;
}

.row-action-btn--view:hover {
  background: #e8f0fe;
}

.row-action-btn--edit {
  color: #f5a623;
}

.row-action-btn--edit:hover {
  background: #fef3e2;
}

.row-action-btn--delete {
  color: #e53935;
}

.row-action-btn--delete:hover {
  background: #fdecea;
}

/* ========== Category Cards Grid ========== */
.categories-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 20px;
  padding: 10px;
}

.category-card {
  background: #ffffff;
  border-radius: 12px;
  padding: 24px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  cursor: pointer;
  transition: all 0.2s ease;
  border: 2px solid transparent;
  position: relative;
  overflow: hidden;
}

.category-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: linear-gradient(90deg, #2f76ff, #5a9fff);
  opacity: 0;
  transition: opacity 0.2s ease;
}

.category-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.12);
  border-color: #e8f0fe;
}

.category-card:hover::before {
  opacity: 1;
}

.category-card-icon {
  font-size: 48px;
  margin-bottom: 16px;
  display: block;
}

.category-card-name {
  font-size: 18px;
  font-weight: 600;
  color: #1f1f1f;
  margin: 0 0 8px;
}

.category-card-description {
  font-size: 13px;
  color: #7b776f;
  margin: 0;
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.category-card-children-count {
  position: absolute;
  top: 16px;
  right: 16px;
  background: #f7f6f3;
  color: #67645b;
  font-size: 11px;
  padding: 4px 8px;
  border-radius: 12px;
  font-weight: 500;
}

/* ========== Category Hierarchy Modal ========== */
.category-hierarchy-tree {
  padding: 8px 0;
}

.category-hierarchy-node {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  margin: 8px 0;
  background: #f7f6f3;
  border-radius: 8px;
  transition: background 0.15s ease;
}

.category-hierarchy-node:hover {
  background: #efede7;
}

.category-hierarchy-node-info {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
}

.category-hierarchy-node-icon {
  font-size: 24px;
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  transition: background 0.15s ease;
  position: relative;
}

.category-hierarchy-node-icon:hover {
  background: #e8e4db;
}

.category-hierarchy-node-icon .icon-actions {
  display: none;
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  background: #ffffff;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  border-radius: 6px;
  padding: 4px;
  gap: 4px;
  z-index: 10;
  margin-bottom: 4px;
}

.category-hierarchy-node-icon:hover .icon-actions {
  display: flex;
}

.icon-action-btn {
  width: 28px;
  height: 28px;
  border: none;
  border-radius: 4px;
  background: transparent;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  transition: background 0.15s ease;
}

.icon-action-btn:hover {
  background: #f7f6f3;
}

.icon-action-btn--edit {
  color: #f5a623;
}

.icon-action-btn--delete {
  color: #e53935;
}

.category-hierarchy-node-name {
  font-size: 14px;
  font-weight: 500;
  color: #1f1f1f;
}

.category-hierarchy-children {
  margin-left: 32px;
  border-left: 2px solid #e0ded8;
  padding-left: 16px;
}

/* Drag and drop styles */
.category-hierarchy-node.dragging {
  opacity: 0.5;
  background: #e8f0fe;
}

.category-hierarchy-node.drag-over {
  border-top: 2px solid #2f76ff;
}

.category-hierarchy-node[draggable="true"] {
  cursor: move;
}

/* Inline action buttons */
.category-hierarchy-node-actions {
  display: flex;
  gap: 4px;
  opacity: 0;
  transition: opacity 0.15s ease;
}

.category-hierarchy-node:hover .category-hierarchy-node-actions {
  opacity: 1;
}

.category-node-action-btn {
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 6px;
  background: #ffffff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  transition: all 0.15s ease;
}

.category-node-action-btn:hover {
  transform: scale(1.1);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}

.category-node-action-btn--move {
  color: #2f76ff;
}

.category-node-action-btn--add-child {
  color: #34a853;
}

.category-node-action-btn--edit {
  color: #f5a623;
}

.category-node-action-btn--delete {
  color: #e53935;
}

/* Drop zone indicator */
.drop-zone-active {
  background: #e8f0fe !important;
  border: 2px dashed #2f76ff !important;
}

.table-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 10px;
}

.toolbar-left,
.toolbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.empty-state {
  padding: 16px;
  font-size: 13px;
  color: #7b776f;
}

.hidden {
  display: none !important;
}

/* Модальное окно */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background-color: rgba(15, 15, 15, 0.2);
  z-index: 20;
}

.modal {
  position: fixed;
  right: 32px;
  top: 40px;
  bottom: 40px;
  width: 520px;
  max-width: calc(100% - 80px);
  background-color: #ffffff;
  border-radius: 10px;
  box-shadow: 0 10px 40px rgba(15, 15, 15, 0.25);
  display: flex;
  flex-direction: column;
  z-index: 30;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid #efede7;
}

.modal-header h2 {
  margin: 0;
  font-size: 16px;
}

.modal-close-btn {
  border: none;
  background: transparent;
  cursor: pointer;
  font-size: 16px;
}

.modal-body {
  padding: 16px 18px 12px;
  overflow-y: auto;
  flex: 1;
}

.modal-footer {
  padding: 10px 18px 14px;
  border-top: 1px solid #efede7;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px 14px;
}

.form-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.form-field--wide {
  grid-column: 1 / -1;
}

.form-field label {
  font-size: 12px;
  color: #67645b;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
}

@media (max-width: 900px) {
  .sidebar {
    display: none;
  }

  .main {
    width: 100%;
  }

  .modal {
    right: 16px;
    left: 16px;
    width: auto;
  }

  .tabs-header {
    display: flex;
    gap: 4px;
    border-bottom: 1px solid #e0ded8;
    margin-bottom: 16px;
}
.tab-button {
    padding: 8px 16px;
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    cursor: pointer;
    font-size: 14px;
}
.tab-button.active {
    border-bottom-color: #2f76ff;
    font-weight: 500;
}
.invoice-table {
    width: 100%;
    border-collapse: collapse;
}
/* остальные стили можно скопировать из product-table */

/* ========== Вкладки (tabs) ========== */
.tabs-header {
    display: flex;
    gap: 2px;
    border-bottom: 1px solid #e0ded8;
    margin-bottom: 16px;
}

.tab-button {
    padding: 8px 16px;
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    font-size: 13px;
    font-weight: 500;
    color: #6b675f;
    cursor: pointer;
    transition: all 0.1s ease;
}

.tab-button:hover {
    color: #1f1f1f;
    background-color: #e8e4db;
    border-radius: 6px 6px 0 0;
}

.tab-button.active {
    color: #1f1f1f;
    border-bottom-color: #2f76ff;
    font-weight: 600;
}

/* ========== Таблица накладных ========== */
/* Используем те же стили, что и для product-table, но можно задать отдельный класс */
.invoice-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.invoice-table th {
    background-color: #f7f6f3;
    font-weight: 500;
    color: #666258;
    font-size: 12px;
    padding: 8px 10px;
    text-align: left;
    border-bottom: 1px solid #efede7;
}

.invoice-table td {
    padding: 8px 10px;
    border-bottom: 1px solid #efede7;
    vertical-align: top;
}

.invoice-table tbody tr:hover td {
    background-color: #f6f5f1;
    cursor: pointer;
}

.invoice-table tbody tr.selected td {
    background-color: #e3f2ff;
}

/* Сумма выравнивается вправо (как денежное поле) */
.invoice-table td:nth-child(5) {
    text-align: right;
}

.buyer-links-table.invoice-table td:nth-child(5),
.buyer-links-table.invoice-table td:nth-child(6) {
    text-align: left;
    white-space: nowrap;
}

.buyer-links-table-wrapper {
    overflow-x: auto;
    max-width: 100%;
}

/* Если нужно скрыть блок с накладными изначально */
.hidden {
    display: none !important;
}

/* Кнопка "Создать из Excel" уже стилизована через .btn-primary, 
   но можно добавить отступы в контейнере */
#invoices-content .content-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

#invoices-content .content-header h1 {
    margin: 0;
}

}

/* ========== Вкладки (tabs) ========== */
.tabs-header {
  display: flex;
  gap: 2px;
  border-bottom: 1px solid #e0ded8;
  margin-bottom: 16px;
}

.tab-button {
  padding: 8px 16px;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  font-size: 13px;
  font-weight: 500;
  color: #6b675f;
  cursor: pointer;
  transition: all 0.1s ease;
}

.tab-button:hover {
  color: #1f1f1f;
  background-color: #e8e4db;
  border-radius: 6px 6px 0 0;
}

.tab-button.active {
  color: #1f1f1f;
  border-bottom-color: #2f76ff;
  font-weight: 600;
}

/* ========== Таблица накладных ========== */
/* Используем те же стили, что и для product-table, но можно задать отдельный класс */
.invoice-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.invoice-table th {
  background-color: #f7f6f3;
  font-weight: 500;
  color: #666258;
  font-size: 12px;
  padding: 8px 10px;
  text-align: left;
  border-bottom: 1px solid #efede7;
}

.invoice-table td {
  padding: 8px 10px;
  border-bottom: 1px solid #efede7;
  vertical-align: top;
}

.invoice-table tbody tr:hover td {
  background-color: #f6f5f1;
  cursor: pointer;
}

.invoice-table tbody tr.selected td {
  background-color: #e3f2ff;
}

/* Сумма выравнивается вправо (как денежное поле) */
.invoice-table td:nth-child(5) {
  text-align: right;
}

/* Таблица связей физ. лица: 5–6 колонки — кнопки, не денежные суммы */
.buyer-links-table.invoice-table td:nth-child(5),
.buyer-links-table.invoice-table td:nth-child(6) {
  text-align: left;
  white-space: nowrap;
}

.buyer-links-table-wrapper {
  overflow-x: auto;
  max-width: 100%;
}

/* Если нужно скрыть блок с накладными изначально */
.hidden {
  display: none !important;
}

/* Кнопка "Создать из Excel" уже стилизована через .btn-primary, 
 но можно добавить отступы в контейнере */
#invoices-content .content-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

#invoices-content .content-header h1 {
  margin: 0;
}

/* Остатки: тулбар, сортировка, фильтр-колонки */
.stock-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 12px;
  margin-top: 8px;
}

.stock-toolbar .form-field {
  margin: 0;
  min-width: 200px;
  flex: 1;
  max-width: 360px;
}

.stock-toolbar .form-field label {
  display: block;
  font-size: 12px;
  color: #6b675f;
  margin-bottom: 4px;
}

.stock-toolbar-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: flex-end;
}

.stock-table-wrapper {
  flex: 1;
  min-height: 0;
  overflow: auto;
  max-width: 100%;
}

.stock-th-row th {
  white-space: nowrap;
  vertical-align: bottom;
  font-size: 12px;
}

.stock-th-inner {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.stock-th-sort {
  border: none;
  background: transparent;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 4px;
  color: #262421;
}

.stock-th-sort:hover {
  background: #ecebe7;
}

.stock-th-sort--active {
  color: #1a6bb5;
}

.stock-sort-ind {
  font-size: 10px;
  opacity: 0.85;
}

.stock-th-filter {
  border: none;
  background: #ecebe7;
  border-radius: 4px;
  width: 22px;
  height: 22px;
  line-height: 1;
  cursor: pointer;
  font-size: 11px;
  padding: 0;
  flex-shrink: 0;
}

.stock-th-filter:hover {
  background: #e0ded8;
}

.stock-th-filter--active {
  background: #d4e8f7;
  box-shadow: 0 0 0 1px #8abae0;
}

.stock-qty-cell {
  text-align: right;
  cursor: help;
}

.stock-filter-popover {
  position: fixed;
  z-index: 4000;
  width: 300px;
  max-height: min(70vh, 420px);
  display: flex;
  flex-direction: column;
  background: #fff;
  border: 1px solid #d9d4c9;
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(15, 15, 15, 0.12);
  font-size: 13px;
}

.stock-filter-popover-search {
  padding: 8px 10px;
  border-bottom: 1px solid #ecebe7;
}

.stock-filter-popover-list {
  flex: 1;
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.stock-filter-select-all {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-bottom: 1px solid #f0efe9;
  cursor: pointer;
  user-select: none;
}

.stock-filter-popover-checkboxes {
  overflow-y: auto;
  flex: 1;
  min-height: 80px;
  max-height: 200px;
  padding: 4px 10px 8px;
}

.stock-filter-popover-checkboxes label {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 4px 0;
  cursor: pointer;
  word-break: break-word;
}

.stock-filter-popover-advanced {
  border-top: 1px solid #ecebe7;
  padding: 6px 10px 8px;
}

.stock-filter-advanced-toggle {
  font-size: 12px;
  color: #3f3d36;
  cursor: pointer;
  padding: 4px 0;
}

.stock-filter-advanced-toggle:hover {
  color: #1a6bb5;
}

.stock-filter-text-ops {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-top: 6px;
  padding-left: 4px;
}

.stock-filter-text-ops button {
  text-align: left;
  border: none;
  background: transparent;
  padding: 4px 6px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 12px;
}

.stock-filter-text-ops button:hover {
  background: #f0efe9;
}

.stock-filter-text-form {
  margin-top: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.stock-filter-popover-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 8px 10px;
  border-top: 1px solid #ecebe7;
  background: #fbfaf7;
  border-radius: 0 0 8px 8px;
}

#stock-content:not(.hidden) {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.stock-th-inner {
  width: 100%;
  justify-content: space-between;
}

.stock-stock-popup-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  justify-content: flex-end;
  width: 100%;
}

.stock-loc-tooltip {
  display: none;
  position: absolute;
  right: 0;
  bottom: calc(100% + 6px);
  z-index: 50;
  min-width: 220px;
  max-width: min(90vw, 400px);
  padding: 8px 10px;
  background: #fff;
  border: 1px solid #d9d4c9;
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(15, 15, 15, 0.12);
  font-size: 12px;
  line-height: 1.45;
  text-align: left;
}

.stock-stock-popup-wrap:hover .stock-loc-tooltip,
.stock-stock-popup-wrap:focus-within .stock-loc-tooltip,
.stock-stock-popup-wrap.stock-loc-tooltip--open .stock-loc-tooltip {
  display: block;
}

.stock-loc-tooltip ul {
  margin: 0;
  padding-left: 18px;
}

.stock-loc-info {
  border: none;
  background: #ecebe7;
  border-radius: 4px;
  width: 22px;
  height: 22px;
  line-height: 1;
  cursor: pointer;
  font-size: 12px;
  padding: 0;
  flex-shrink: 0;
}

.stock-loc-info:hover {
  background: #e0ded8;
}

/* ========================================
   MOBILE RESPONSIVE STYLES
   ======================================== */

/* Mobile hamburger menu button */
.mobile-menu-toggle {
  display: none;
  position: fixed;
  top: 10px;
  left: 10px;
  z-index: 10001;
  width: 44px;
  height: 44px;
  border: none;
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  cursor: pointer;
  font-size: 20px;
  align-items: center;
  justify-content: center;
  color: #1f1f1f;
  transition: background 0.15s ease;
}

.mobile-menu-toggle:hover {
  background: #f7f6f3;
}

.mobile-menu-toggle:active {
  background: #e8e4db;
}

/* Sidebar overlay for mobile */
.sidebar-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 9998;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.sidebar-overlay.active {
  display: block;
  opacity: 1;
}

/* ========================================
   TABLET STYLES (max-width: 1024px)
   ======================================== */
@media (max-width: 1024px) {
  .sidebar {
    width: 220px;
  }
  
  .categories-grid {
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 16px;
  }
}

/* ========================================
   MOBILE STYLES (max-width: 768px)
   ======================================== */
@media (max-width: 768px) {
  /* Show hamburger menu button */
  .mobile-menu-toggle {
    display: flex;
  }
  
  /* Sidebar becomes slide-in overlay */
  .sidebar {
    position: fixed;
    top: 0;
    left: -280px;
    width: 280px;
    height: 100vh;
    z-index: 9999;
    transition: left 0.3s ease;
    box-shadow: none;
  }
  
  .sidebar.open {
    left: 0;
    box-shadow: 2px 0 12px rgba(0, 0, 0, 0.15);
  }
  
  /* Adjust main content */
  .main {
    width: 100%;
  }
  
  /* Topbar adjustments */
  .topbar {
    padding: 10px 10px 10px 60px; /* Left padding for hamburger button */
    flex-wrap: wrap;
    gap: 8px;
  }
  
  .topbar-breadcrumbs {
    font-size: 12px;
    flex: 1;
    min-width: 0;
  }
  
  .topbar-right {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
  }
  
  .topbar-right > * {
    font-size: 11px;
  }
  
  /* Content area */
  .content {
    padding: 12px;
  }
  
  .content-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }
  
  .content-header-search {
    width: 100%;
    flex-direction: column;
  }
  
  .content-header-search .input,
  .content-header-search .btn {
    width: 100%;
  }
  
  .page-title {
    font-size: 20px;
  }
  
  /* Toolbar buttons wrap */
  .table-toolbar {
    flex-direction: column;
    gap: 8px;
  }
  
  .toolbar-left,
  .toolbar-right {
    width: 100%;
    flex-wrap: wrap;
    gap: 6px;
  }
  
  /* Make buttons touch-friendly */
  .btn {
    padding: 10px 16px;
    font-size: 14px;
    min-height: 44px;
  }
  
  /* Tables: horizontal scroll */
  .table-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin: 0 -12px;
    padding: 0 12px;
  }
  
  .table-wrapper table {
    min-width: 600px; /* Ensures table doesn't compress too much */
  }
  
  /* Category cards: single column */
  .categories-grid {
    grid-template-columns: 1fr;
    gap: 12px;
    padding: 0;
  }
  
  .category-card {
    padding: 16px;
  }
  
  .category-card-icon {
    font-size: 36px;
    margin-bottom: 12px;
  }
  
  .category-card-name {
    font-size: 16px;
  }
  
  /* Sidebar items: larger touch targets */
  .sidebar-item {
    padding: 12px 10px;
    font-size: 14px;
    min-height: 44px;
  }
  
  .sidebar-item-icon {
    width: 24px;
    font-size: 18px;
  }
  
  /* Form fields: larger for touch */
  .input,
  input[type="text"],
  input[type="search"],
  input[type="password"],
  input[type="email"],
  input[type="number"],
  textarea,
  select {
    font-size: 16px; /* Prevents iOS zoom on focus */
    min-height: 44px;
    padding: 10px 12px;
  }
  
  .form-field {
    margin-bottom: 16px;
  }
  
  .form-field label {
    font-size: 14px;
    margin-bottom: 6px;
  }
  
  /* Modals: fullscreen on mobile */
  .modal {
    width: 100%;
    max-width: none;
    height: 100vh;
    max-height: 100vh;
    margin: 0;
    border-radius: 0;
    overflow-y: auto;
  }
  
  .modal-backdrop {
    padding: 0;
  }
  
  .modal-header {
    padding: 16px;
    position: sticky;
    top: 0;
    background: #ffffff;
    z-index: 10;
    border-bottom: 1px solid #e0ded8;
  }
  
  .modal-body {
    padding: 16px;
  }
  
  .modal-footer {
    padding: 16px;
    position: sticky;
    bottom: 0;
    background: #ffffff;
    border-top: 1px solid #e0ded8;
  }
  
  .modal-footer .btn {
    flex: 1;
  }
  
  /* Tabs: wrap on mobile */
  .tabs-header {
    flex-wrap: wrap;
  }
  
  .tab-btn {
    padding: 10px 12px;
    font-size: 13px;
    min-height: 44px;
  }
  
  /* Search inputs full width */
  .sidebar-search {
    padding: 0 12px 12px;
  }
  
  .sidebar-search input {
    font-size: 16px;
    min-height: 44px;
    padding: 10px 12px;
  }
  
  /* Pagination: stack on mobile */
  .pagination-container {
    flex-direction: column;
    gap: 12px;
    align-items: center;
  }
  
  .pagination-info {
    order: 2;
  }
  
  .pagination-controls {
    order: 1;
  }
  
  /* Shipment line items: stack fields */
  .shipment-line-item td,
  .shipment-line-item th {
    display: block;
    width: 100%;
  }
  
  .shipment-line-item {
    display: block;
    margin-bottom: 16px;
    padding: 12px;
    background: #f7f6f3;
    border-radius: 8px;
  }
  
  /* Auth modal adjustments */
  .auth-mode {
    padding: 12px;
  }
  
  /* Reduce hover effects on touch devices */
  .sidebar-item:hover,
  .category-card:hover {
    transform: none;
  }
  
  /* Better touch feedback */
  .btn:active,
  .sidebar-item:active,
  .category-card:active {
    transform: scale(0.98);
  }
}

/* ========================================
   SMALL MOBILE STYLES (max-width: 480px)
   ======================================== */
@media (max-width: 480px) {
  .topbar {
    padding: 8px 8px 8px 56px;
  }
  
  .topbar-breadcrumbs {
    font-size: 11px;
  }
  
  .sync-status {
    font-size: 10px;
    padding: 3px 6px;
  }
  
  .page-title {
    font-size: 18px;
  }
  
  .content {
    padding: 8px;
  }
  
  .btn {
    padding: 8px 12px;
    font-size: 13px;
  }
  
  .table-wrapper table {
    min-width: 500px;
  }
  
  .modal-header h2,
  .modal-title {
    font-size: 18px;
  }
  
  /* Smaller sidebar on very small screens */
  .sidebar {
    width: 260px;
    left: -260px;
  }
  
  /* Compact category cards */
  .category-card {
    padding: 12px;
  }
  
  .category-card-icon {
    font-size: 28px;
    margin-bottom: 8px;
  }
  
  .category-card-name {
    font-size: 14px;
  }
  
  .category-card-description {
    font-size: 12px;
  }
}

/* Баннер и панель обновлений приложения */
.app-update-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 10px 16px;
  background: #fff8e6;
  border-bottom: 1px solid #f0d78c;
  color: #5c4a00;
  z-index: 9999;
  position: relative;
}

.app-update-banner.hidden {
  display: none;
}

.app-update-banner-text {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 13px;
  flex: 1;
  min-width: 200px;
}

.app-update-banner-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.app-version-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
  margin-bottom: 8px;
}

.app-version-card {
  border: 1px solid #e0ded8;
  border-radius: 8px;
  padding: 12px;
  background: #fff;
}

.app-version-card-label {
  font-size: 11px;
  color: #888;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 6px;
}

.app-version-card-value {
  font-size: 14px;
  word-break: break-word;
}

.app-version-status {
  font-size: 14px;
  font-weight: 600;
}

.app-version-status--ok {
  color: #155724;
}

.app-version-status--pending {
  color: #856404;
}

.app-version-badge {
  display: inline-block;
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 12px;
  background: #f0f0f0;
  color: #666;
}

.app-version-badge--ok {
  background: #d4edda;
  color: #155724;
}