:root {
  color-scheme: light;
  --bg: #f4f6f8;
  --surface: #ffffff;
  --ink: #17202a;
  --muted: #65717d;
  --line: #dfe5ea;
  --accent: #16775a;
  --accent-strong: #0e6048;
  --danger: #b3261e;
  --shadow: 0 14px 35px rgba(31, 42, 55, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: Arial, Helvetica, sans-serif;
}

button,
input,
select,
textarea {
  font: inherit;
}

button,
.ghost-link {
  border: 0;
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  font-weight: 700;
  min-height: 42px;
  padding: 0 16px;
  text-decoration: none;
  transition: background 160ms ease, transform 160ms ease;
}

button:hover,
.ghost-link:hover {
  background: var(--accent-strong);
  transform: translateY(-1px);
}

input,
select,
textarea {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  padding: 0 12px;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  outline: 3px solid rgba(22, 119, 90, 0.16);
}

textarea {
  min-height: 96px;
  padding: 10px 12px;
  resize: vertical;
}

.auth-page {
  background:
    linear-gradient(rgba(18, 29, 38, 0.54), rgba(18, 29, 38, 0.42)),
    url("/login-bg.jpg") center/cover fixed;
}

.auth-shell {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 24px;
}

.auth-panel {
  display: grid;
  gap: 24px;
  width: min(100%, 480px);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.95);
  box-shadow: var(--shadow);
  padding: 34px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 12px;
  font-size: clamp(36px, 8vw, 64px);
  line-height: 0.95;
}

h2 {
  margin-bottom: 0;
  font-size: 24px;
}

.lead {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 18px;
  line-height: 1.45;
}

.setup-box {
  display: grid;
  gap: 6px;
  border: 1px solid #f1c453;
  border-radius: 6px;
  background: #fff8db;
  color: #5c4700;
  padding: 14px;
  line-height: 1.45;
}


.danger-zone {
  border-color: #f2b8b5;
  background: #fff8f7;
}

.muted-note {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
}

.login-form {
  display: grid;
  gap: 12px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  width: 90vw;
  margin: 0 auto;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
  padding: 18px 0;
}

.topbar h1 {
  margin: 0;
  font-size: 32px;
}

.profile {
  display: flex;
  align-items: center;
  gap: 12px;
}

.profile img {
  width: 42px;
  height: 42px;
  border-radius: 50%;
}

.profile div {
  display: grid;
  gap: 3px;
  max-width: 280px;
}

.profile span,
.section-heading span {
  color: var(--muted);
  font-size: 14px;
}

.ghost-link {
  display: inline-flex;
  align-items: center;
  background: #fff;
  border: 1px solid var(--line);
  color: var(--ink);
}

.ghost-link:hover {
  background: #eef4f1;
}

.workspace {
  display: grid;
  gap: 24px;
  width: 90vw;
  max-width: none;
  margin: 28px auto;
}

.toolbar,
.inventory {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 8px 22px rgba(31, 42, 55, 0.06);
}

.toolbar {
  padding: 16px;
}

.catalog-tabs,
.search-toolbar {
  display: grid;
  gap: 14px;
}

.tab-list {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.tab-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--ink);
  font-weight: 800;
  padding: 0 16px;
  text-decoration: none;
  transition: background 160ms ease, border-color 160ms ease, transform 160ms ease;
}

.tab-link:hover {
  background: #eef4f1;
  transform: translateY(-1px);
}

.tab-link.is-active {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

.tab-link small {
  display: inline-grid;
  min-width: 24px;
  min-height: 24px;
  place-items: center;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.08);
  font-size: 12px;
}

.tab-link.is-active small {
  background: rgba(255, 255, 255, 0.2);
}

.subtabs {
  display: grid;
  gap: 12px;
  border-top: 1px solid var(--line);
  padding-top: 14px;
}

.filter-form {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) auto auto;
  gap: 10px;
}

.filter-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  color: var(--muted);
  font-size: 14px;
}


.sold-filter-form {
  grid-template-columns: minmax(260px, 1.1fr) minmax(220px, 0.8fr) minmax(180px, 0.55fr) minmax(180px, 0.55fr) auto auto auto;
  align-items: end;
}

.sold-filter-form .field-label {
  min-width: 180px;
}


.sold-filter-form input[type="date"] {
  min-width: 180px;
}


.date-picker-control {
  position: relative;
  display: grid;
  grid-template-columns: 1fr 44px;
  gap: 6px;
  align-items: center;
}

.date-display-input {
  width: 100%;
}

.native-date-input {
  position: absolute;
  right: 0;
  bottom: 0;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.date-picker-button {
  min-width: 44px;
  padding: 10px 0;
}

.balance-filter-form {
  display: grid;
  grid-template-columns: minmax(160px, 0.9fr) minmax(180px, 0.9fr) minmax(280px, 1.4fr) auto auto;
  gap: 10px;
}

.item-form {
  display: grid;
  grid-template-columns: 170px 170px 170px 170px 140px 220px 150px 140px auto;
  gap: 10px;
  min-width: 1800px;
}




.reserve-expiry {
  display: inline-block;
  margin-top: 4px;
  color: var(--danger);
  font-weight: 800;
}

.reserve-settings-form {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) minmax(180px, 0.5fr) minmax(220px, 0.7fr) auto;
  gap: 12px;
  align-items: end;
  padding: 16px;
}

.reserve-settings-check {
  align-self: center;
}

.field-label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.buyer-form {
  display: grid;
  grid-template-columns: minmax(240px, 0.8fr) minmax(280px, 1.2fr) auto;
  gap: 10px;
  padding: 16px;
}

.buyers-grid {
  display: grid;
  min-width: 980px;
}

.buyers-header,
.buyers-row {
  display: grid;
  grid-template-columns: var(--table-columns, 240px 310px 200px 200px 180px);
  gap: 10px;
  align-items: center;
  padding: 12px 14px;
}

.buyers-header {
  background: #f3f7f5;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.buyers-row {
  border-top: 1px solid var(--line);
}


.buyers-edit-row {
  margin: 0;
}


.stock-create-page-form {
  grid-template-columns: minmax(180px, 0.8fr) minmax(200px, 0.8fr) minmax(240px, 1fr) minmax(320px, 1.4fr) minmax(160px, 0.7fr);
  padding: 16px;
}


.product-card-search {
  min-width: 220px;
}


.product-card-combobox {
  position: relative;
  min-width: 320px;
}

.product-card-combobox-input {
  width: 100%;
}

.product-card-options {
  position: absolute;
  z-index: 60;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  max-height: 320px;
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
  box-shadow: 0 18px 35px rgba(18, 29, 38, 0.14);
  padding: 6px;
}

.product-card-option {
  display: grid;
  gap: 3px;
  width: 100%;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--ink);
  padding: 10px 12px;
  text-align: left;
}


.product-card-option[hidden] {
  display: none !important;
}

.product-card-option:hover,
.product-card-option.is-selected {
  background: #eef4f1;
}

.product-card-option strong {
  font-size: 14px;
}

.product-card-option span {
  color: var(--muted);
  font-size: 12px;
}

.stock-create-page-form textarea,
.stock-create-page-actions {
  grid-column: 1 / -1;
}

.stock-create-form {
  display: grid;
  grid-template-columns: minmax(160px, 0.8fr) minmax(180px, 0.8fr) minmax(280px, 1.4fr) minmax(140px, 0.7fr) minmax(260px, 1.2fr) auto;
  gap: 10px;
  align-items: start;
}

.category-form {
  display: grid;
  grid-template-columns: minmax(200px, 1fr) auto;
  gap: 10px;
  padding: 16px;
}

.import-export-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.excel-import-form {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto;
  gap: 10px;
  width: min(100%, 520px);
}

.split-toolbar {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}

.user-form {
  display: grid;
  grid-template-columns: minmax(120px, 0.8fr) minmax(160px, 1fr) minmax(170px, 1fr) minmax(150px, 0.8fr) 150px 110px auto;
  gap: 10px;
  padding: 16px;
}

.compact-heading {
  border-bottom: 0;
  padding-bottom: 0;
}

.inventory {
  overflow: visible;
}

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--line);
  padding: 18px;
}

.table-wrap {
  overflow-x: auto;
}

.items-grid {
  min-width: 1840px;
}

.items-header {
  display: grid;
  grid-template-columns: var(--table-columns, 44px 170px 170px 170px 230px 360px 150px 140px 280px);
  gap: 10px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  padding: 14px 18px;
  text-transform: uppercase;
}


.resizable-header-cell {
  position: relative;
  min-width: 0;
  padding-right: 10px;
}

.column-resizer {
  position: absolute;
  top: -8px;
  right: -6px;
  bottom: -8px;
  z-index: 5;
  width: 12px;
  cursor: col-resize;
  touch-action: none;
}

.column-resizer::after {
  content: '';
  position: absolute;
  top: 8px;
  right: 5px;
  bottom: 8px;
  width: 2px;
  border-radius: 999px;
  background: transparent;
}

.resizable-header-cell:hover .column-resizer::after,
.column-resizer.is-dragging::after {
  background: var(--accent);
}

body.is-resizing-columns {
  cursor: col-resize;
  user-select: none;
}

.sort-link {
  color: inherit;
  font-weight: 800;
  text-decoration: none;
}

.sort-link:hover,
.sort-link.is-active {
  color: var(--accent);
}

.sort-link.is-active {
  text-decoration: underline;
  text-underline-offset: 4px;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th {
  color: var(--muted);
  font-size: 13px;
  text-align: left;
  text-transform: uppercase;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 6px 10px;
}

tr:last-child td {
  border-bottom: 0;
}

.row-form {
  display: grid;
  grid-template-columns: 170px 170px 170px 170px 140px 360px 150px 140px 230px;
  gap: 10px;
  align-items: center;
  border-bottom: 1px solid var(--line);
  padding: 16px 18px;
}

.item-read-row {
  display: grid;
  grid-template-columns: var(--table-columns, 44px 170px 170px 170px 230px 360px 150px 140px 280px);
  gap: 6px;
  align-items: center;
  border-bottom: 1px solid var(--line);
  padding: 6px 10px;
}


.location-group-start {
  border-top: 4px solid #9aa7a0;
}

.item-read-row span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.item-read-row.is-reserved {
  background: #fff8db;
}

.item-read-row small {
  color: var(--muted);
  line-height: 1.15;
}

.balances-grid {
  min-width: 1440px;
}

.balances-header,
.balances-row {
  display: grid;
  grid-template-columns: var(--table-columns, 170px 170px 230px 420px 170px 100px 110px 100px);
  gap: 6px;
  align-items: center;
  border-bottom: 1px solid var(--line);
  padding: 6px 10px;
}

.balances-header {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
}

.balances-row:last-child {
  border-bottom: 0;
}

.balances-row span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.balances-row .is-low-stock {
  color: #d93025;
  font-weight: 900;
}

.sold-grid {
  min-width: 2040px;
}

.sold-header,
.sold-row {
  display: grid;
  grid-template-columns: var(--table-columns, 44px 170px 160px 160px 170px 230px 360px 150px 140px 320px);
  gap: 6px;
  align-items: center;
  border-bottom: 1px solid var(--line);
  padding: 6px 10px;
}

.sold-header {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
}

.sold-row:last-child {
  border-bottom: 0;
}

.sold-row span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sold-row small {
  color: var(--muted);
  line-height: 1.15;
}

.row-check {
  display: grid;
  min-height: 24px;
  place-items: center;
}

.row-check input {
  width: 15px;
  min-height: 15px;
}

.inventory-actions {
  position: sticky;
  top: 0;
  z-index: 15;
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 8px 18px rgba(31, 42, 55, 0.08);
  backdrop-filter: blur(6px);
  padding: 10px 18px;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  background: rgba(18, 29, 38, 0.45);
  padding: 24px;
}

.modal-backdrop[hidden] {
  display: none;
}

.modal {
  display: grid;
  gap: 14px;
  width: min(100%, 440px);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
  padding: 22px;
}

.modal h3 {
  margin-bottom: 0;
}


.create-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.modal-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.create-modal {
  width: min(900px, calc(100vw - 48px));
}

.create-modal 


.reserve-expiry {
  display: inline-block;
  margin-top: 4px;
  color: var(--danger);
  font-weight: 800;
}

.reserve-settings-form {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) minmax(180px, 0.5fr) minmax(220px, 0.7fr) auto;
  gap: 12px;
  align-items: end;
  padding: 16px;
}

.reserve-settings-check {
  align-self: center;
}

.field-label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.buyer-form {
  display: grid;
  grid-template-columns: minmax(240px, 0.8fr) minmax(280px, 1.2fr) auto;
  gap: 10px;
  padding: 16px;
}

.buyers-grid {
  display: grid;
  min-width: 980px;
}

.buyers-header,
.buyers-row {
  display: grid;
  grid-template-columns: var(--table-columns, 240px 310px 200px 200px 180px);
  gap: 10px;
  align-items: center;
  padding: 12px 14px;
}

.buyers-header {
  background: #f3f7f5;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.buyers-row {
  border-top: 1px solid var(--line);
}


.buyers-edit-row {
  margin: 0;
}


.stock-create-page-form {
  grid-template-columns: minmax(180px, 0.8fr) minmax(200px, 0.8fr) minmax(240px, 1fr) minmax(320px, 1.4fr) minmax(160px, 0.7fr);
  padding: 16px;
}

.stock-create-page-form textarea,
.stock-create-page-actions {
  grid-column: 1 / -1;
}

.stock-create-form {
  grid-template-columns: minmax(160px, 1fr) minmax(180px, 1fr);
}

.create-modal .product-card-select,
.create-modal textarea,
.create-modal .modal-actions {
  grid-column: 1 / -1;
}

.subcategory-row-form {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto;
  gap: 10px;
  align-items: center;
}

.subcategory-item-form {
  display: grid;
  grid-template-columns: minmax(160px, 1fr) minmax(140px, 0.8fr) minmax(360px, 1.8fr) minmax(150px, 0.8fr) auto;
  gap: 10px;
  padding: 16px;
}

.subcategory-items-grid {
  min-width: 1320px;
}

.subcategory-items-header,
.subcategory-card-row {
  display: grid;
  grid-template-columns: var(--table-columns, 170px 150px 420px 160px 190px);
  gap: 10px;
  align-items: center;
  padding: 14px 18px;
}

.subcategory-items-header {
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
}

.subcategory-card-row {
  border-bottom: 1px solid var(--line);
}

.subcategory-card-row:last-child {
  border-bottom: 0;
}

.admin-row-form {
  display: grid;
  grid-template-columns: minmax(120px, 0.8fr) minmax(150px, 1fr) minmax(170px, 1fr) 145px 105px minmax(150px, 0.8fr) auto;
  gap: 10px;
  align-items: center;
}

.category-list {
  display: grid;
  gap: 0;
}

.category-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  border-bottom: 1px solid var(--line);
  padding: 16px 18px;
}

.category-card:last-child {
  border-bottom: 0;
}

.category-card h3 {
  margin-bottom: 4px;
  font-size: 18px;
}

.category-card p {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 14px;
}

.row-actions {
  display: flex;
  gap: 6px;
  justify-content: flex-end;
  white-space: nowrap;
}

.check-control {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 42px;
  color: var(--muted);
  font-size: 14px;
  white-space: nowrap;
}

.check-control input {
  width: 15px;
  min-height: 15px;
}

.ghost-button {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
}

.ghost-button:hover {
  background: #eef4f1;
}

.order-button {
  min-width: 42px;
  width: auto;
  padding: 0 12px;
}


.select-all-control {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 9px 12px;
  color: var(--ink);
  font-weight: 700;
  cursor: pointer;
  user-select: none;
}

.select-all-control input {
  width: auto;
  margin: 0;
}

.compact-select-all {
  margin-left: auto;
  padding: 6px 10px;
  font-size: 13px;
}

.danger-button {
  background: #fff0ee;
  color: var(--danger);
}

.danger-button:hover {
  background: #ffd9d5;
}

.empty-state {
  padding: 34px 18px;
  text-align: center;
}

.empty-state p {
  margin-bottom: 0;
  color: var(--muted);
}

code {
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.08);
  padding: 2px 5px;
}

@media (max-width: 820px) {
  .topbar,
  .workspace {
    width: calc(100% - 24px);
  }

  .topbar,
  .profile {
    align-items: flex-start;
    flex-direction: column;
  }

  .item-form,
  .stock-create-form,
  .row-form,
  .category-form,
  .excel-import-form,
  .split-toolbar,
  .subcategory-row-form,
  .subcategory-item-form,
  .user-form,
  .admin-row-form,
  .filter-form,
  .balance-filter-form,
  .sold-filter-form,
  .reserve-settings-form,
  .buyer-form {
    grid-template-columns: 1fr;
  }

  .row-actions {
    justify-content: stretch;
  }

  .category-card {
    align-items: stretch;
    flex-direction: column;
  }

  .import-export-toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .row-actions button,
  .row-actions form {
    width: 100%;
  }
}



.users-table {
  border-collapse: separate;
  border-spacing: 0 18px;
}

.users-table th {
  border-bottom: 0;
  padding-bottom: 0;
}

.users-table td {
  border-bottom: 0;
  padding: 0 18px 18px;
}

.user-edit-form {
  border: 1px solid rgba(22, 119, 90, 0.18);
  border-left: 6px solid var(--accent);
  border-radius: 18px;
  background: linear-gradient(180deg, #ffffff 0%, #fbfdfc 100%);
  box-shadow: 0 18px 38px rgba(18, 29, 38, 0.08);
  padding: 18px;
}

.user-card-heading {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 6px;
  padding-bottom: 14px;
}

.user-card-heading div {
  display: grid;
  gap: 3px;
}

.user-card-heading strong {
  color: var(--ink);
  font-size: 18px;
}

.user-card-heading small,
.user-card-kicker {
  color: var(--muted);
  font-size: 13px;
}

.user-card-kicker {
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.user-card-state {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 12px;
  background: #f3f7f5;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  white-space: nowrap;
}

.user-card-state.is-active {
  border-color: rgba(22, 119, 90, 0.3);
  background: #f1faf6;
  color: var(--accent-strong);
}

.user-card-state.is-disabled {
  border-color: rgba(185, 28, 28, 0.22);
  background: #fff0ee;
  color: #b91c1c;
}

.permissions-panel {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 8px 12px;
  border-top: 1px solid var(--line);
  margin-top: 2px;
  padding-top: 12px;
}

.permissions-title {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: var(--ink);
  font-weight: 800;
}

.permissions-title span,
.permissions-note {
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
}

.permission-control {
  display: grid;
  grid-template-columns: 18px 1fr;
  gap: 2px 8px;
  align-items: start;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  padding: 9px 10px;
  font-size: 14px;
}

.permission-control input {
  grid-row: span 2;
  margin-top: 2px;
  min-height: 16px;
  width: 16px;
}

.permission-control span {
  color: var(--ink);
  font-weight: 700;
}

.permission-control small {
  color: var(--muted);
  font-size: 12px;
}

.permission-control:has(input:checked) {
  border-color: rgba(22, 119, 90, 0.45);
  background: #f1faf6;
}

.permission-control:has(input:disabled) {
  opacity: 0.72;
}

.permissions-note {
  grid-column: 1 / -1;
  margin: 0;
}

.user-edit-form {
  align-items: start;
}

@media (max-width: 680px) {
  body {
    overflow-x: hidden;
  }

  button,
  .ghost-link {
    justify-content: center;
    width: 100%;
    min-height: 44px;
    padding: 0 12px;
  }

  .auth-shell {
    padding: 14px;
  }

  .auth-panel {
    gap: 18px;
    padding: 24px 18px;
  }

  .topbar,
  .workspace {
    width: calc(100% - 16px);
  }

  .topbar {
    gap: 14px;
    padding: 14px 0;
  }

  .topbar h1 {
    font-size: 26px;
  }

  .profile {
    width: 100%;
    gap: 6px;
  }

  .profile .ghost-link,
  .profile form,
  .profile button {
    width: 100%;
  }

  .workspace {
    gap: 16px;
    margin: 16px auto;
  }

  .toolbar {
    padding: 12px;
  }

  .section-heading,
  .compact-heading,
  .create-toolbar,
  .modal-heading,
  .import-export-toolbar,
  .inventory-actions,
  .filter-summary,
  .permissions-title,
  .user-card-heading {
    align-items: stretch;
    flex-direction: column;
  }

  .section-heading {
    padding: 14px;
  }

  .inventory-actions {
    justify-content: stretch;
    padding: 12px;
  }

  .select-all-control,
  .compact-select-all {
    width: 100%;
    justify-content: center;
    margin-left: 0;
  }

  .tab-link {
    width: 100%;
    justify-content: center;
  }

  .date-picker-control,
  .filter-form,
  .balance-filter-form,
  .sold-filter-form,
  .reserve-settings-form,
  .buyer-form,
  .category-form,
  .excel-import-form,
  .stock-create-page-form,
  .stock-create-form,
  .subcategory-row-form,
  .subcategory-item-form,
  .user-form,
  .admin-row-form {
    grid-template-columns: 1fr !important;
    min-width: 0;
  }

  .product-card-combobox,
  .product-card-search,
  .sold-filter-form .field-label,
  .sold-filter-form input[type="date"] {
    min-width: 0;
  }

  .stock-create-page-form textarea,
  .stock-create-page-actions,
  .create-modal .product-card-select,
  .create-modal textarea,
  .create-modal .modal-actions,
  .permissions-panel,
  .permissions-title,
  .user-card-heading {
    grid-column: 1 / -1;
  }

  .table-wrap {
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .items-grid,
  .sold-grid,
  .balances-grid,
  .buyers-grid,
  .subcategory-items-grid {
    min-width: 980px;
  }

  .users-table,
  .users-table tbody,
  .users-table tr,
  .users-table td {
    display: block;
    width: 100%;
  }

  .users-table thead {
    display: none;
  }

  .users-table td {
    padding: 0 0 14px;
  }

  .user-edit-form {
    border-radius: 14px;
    padding: 14px;
  }

  .permissions-panel {
    grid-template-columns: 1fr;
  }

  .row-actions {
    display: grid;
    grid-template-columns: 1fr;
    width: 100%;
    white-space: normal;
  }

  .row-actions form,
  .row-actions a,
  .row-actions button {
    width: 100%;
  }

  .category-card {
    padding: 14px;
  }

  .modal-backdrop {
    padding: 12px;
  }

  .modal,
  .create-modal {
    width: min(100%, calc(100vw - 24px));
    max-height: calc(100vh - 24px);
    overflow-y: auto;
    padding: 18px;
  }
}

.online-grid {
  display: grid;
  min-width: 1180px;
}

.online-header,
.online-row {
  display: grid;
  grid-template-columns: 150px 190px 170px 130px 190px 260px 160px;
  gap: 10px;
  align-items: center;
  border-bottom: 1px solid var(--line);
  padding: 14px 18px;
}

.online-header {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
}

.online-row:last-child {
  border-bottom: 0;
}

.online-row span,
.online-row strong:not(.online-status) {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.online-status {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  padding: 7px 10px;
  font-size: 13px;
}

.online-status.online {
  background: #e8f5ee;
  color: #0e6048;
}

.online-status.recent {
  background: #fff8db;
  color: #8a6500;
}

.online-status.offline {
  background: #f1f3f5;
  color: var(--muted);
}

@media (max-width: 680px) {
  .online-grid {
    min-width: 1180px;
  }
}

@media (max-width: 680px) {
  .tab-list {
    flex-wrap: nowrap;
    overflow-x: auto;
    padding-bottom: 4px;
    -webkit-overflow-scrolling: touch;
  }

  .tab-link {
    flex: 0 0 auto;
    width: auto;
    min-height: 38px;
    justify-content: flex-start;
    padding: 0 12px;
    white-space: nowrap;
  }

  .tab-link small {
    min-width: 22px;
    min-height: 22px;
  }

  .workspace {
    padding-bottom: 110px;
  }

  .inventory-actions {
    position: fixed;
    right: 8px;
    bottom: 8px;
    left: 8px;
    top: auto;
    z-index: 60;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-start;
    gap: 6px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.97);
    box-shadow: 0 12px 32px rgba(31, 42, 55, 0.18);
    padding: 8px;
  }

  .inventory-actions button,
  .inventory-actions .ghost-button,
  .inventory-actions .danger-button,
  .inventory-actions .select-all-control {
    flex: 0 0 auto;
    width: auto;
    min-height: 36px;
    justify-content: center;
    padding: 0 10px;
    font-size: 13px;
    white-space: nowrap;
  }

  .inventory-actions .select-all-control input {
    width: auto;
  }
}

@media (max-width: 680px) {
  html,
  body {
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
  }

  .topbar,
  .workspace {
    width: 100% !important;
    max-width: 100% !important;
    margin-right: 0 !important;
    margin-left: 0 !important;
    padding-right: 8px;
    padding-left: 8px;
  }

  .toolbar,
  .inventory,
  .catalog-tabs,
  .search-toolbar {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
  }

  .catalog-tabs,
  .search-toolbar {
    overflow: hidden;
  }

  .tab-list {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    flex-wrap: nowrap !important;
    overflow-x: auto;
    overflow-y: hidden;
    padding-bottom: 6px;
  }

  .tab-link,
  .catalog-tabs .tab-link {
    width: auto !important;
    max-width: 82vw;
    flex: 0 0 auto;
    justify-content: flex-start !important;
    min-height: 36px;
    padding: 0 10px;
    white-space: nowrap;
  }

  .filter-form,
  .balance-filter-form,
  .sold-filter-form,
  .reserve-settings-form,
  .buyer-form,
  .category-form,
  .excel-import-form,
  .stock-create-page-form,
  .stock-create-form,
  .subcategory-row-form,
  .subcategory-item-form,
  .user-form,
  .admin-row-form {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    grid-template-columns: minmax(0, 1fr) !important;
  }

  .filter-form > *,
  .balance-filter-form > *,
  .sold-filter-form > *,
  .reserve-settings-form > *,
  .buyer-form > *,
  .category-form > *,
  .excel-import-form > *,
  .stock-create-page-form > *,
  .stock-create-form > *,
  .subcategory-row-form > *,
  .subcategory-item-form > *,
  .user-form > *,
  .admin-row-form > * {
    max-width: 100%;
    min-width: 0 !important;
  }

  .filter-form button,
  .balance-filter-form button,
  .sold-filter-form button,
  .filter-form .ghost-link,
  .balance-filter-form .ghost-link,
  .sold-filter-form .ghost-link,
  .excel-import-form button,
  .excel-import-form .ghost-link {
    width: 100% !important;
  }

  .table-wrap {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    overflow-x: auto;
    overflow-y: visible;
  }

  .workspace {
    padding-bottom: 120px;
  }

  .inventory-actions {
    position: fixed !important;
    right: 8px !important;
    bottom: 8px !important;
    left: 8px !important;
    top: auto !important;
    z-index: 1000 !important;
    display: flex !important;
    flex-direction: row !important;
    flex-wrap: wrap !important;
    align-items: center !important;
    justify-content: flex-start !important;
    max-width: calc(100vw - 16px) !important;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.98);
    box-shadow: 0 12px 32px rgba(31, 42, 55, 0.22);
    padding: 8px !important;
  }

  .inventory-actions button,
  .inventory-actions .ghost-button,
  .inventory-actions .danger-button,
  .inventory-actions .select-all-control {
    width: auto !important;
    min-width: 0 !important;
    min-height: 34px !important;
    flex: 0 0 auto !important;
    padding: 0 9px !important;
    font-size: 12px;
    white-space: nowrap;
  }

  .inventory-actions .select-all-control {
    gap: 6px;
  }
}

.reserved-groups {
  display: grid;
  gap: 18px;
  padding: 16px;
}

.reserved-user-block {
  display: grid;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  overflow: hidden;
}

.reserved-user-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: #f3f7f5;
  padding: 12px 14px;
}

.reserved-user-heading h3 {
  margin-bottom: 2px;
}

.reserved-user-heading span {
  color: var(--muted);
  font-size: 13px;
}

.reserves-grid {
  display: grid;
  min-width: 1980px;
}

.reserves-header,
.reserves-row {
  display: grid;
  grid-template-columns: var(--table-columns, 44px 190px 170px 260px 160px 160px 170px 230px 360px 150px 150px);
  gap: 6px;
  align-items: center;
  border-bottom: 1px solid var(--line);
  padding: 6px 10px;
}

.reserves-header {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
}

.reserves-row:last-child {
  border-bottom: 0;
}

.reserves-row span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@media (max-width: 680px) {
  .reserved-groups {
    padding: 10px;
  }

  .reserved-user-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .reserves-grid {
    min-width: 1180px;
  }
}

.reserved-user-controls {
  display: flex;
  align-items: center;
  gap: 10px;
}

.reserved-user-controls .compact-select-all {
  min-height: 34px;
  padding: 7px 10px;
}

@media (max-width: 680px) {
  .reserved-user-controls {
    flex-wrap: wrap;
  }

  .reserved-user-controls .compact-select-all {
    width: auto !important;
  }
}

.reserved-user-block.is-readonly-reserve-group .reserved-user-heading {
  background: #f8fafb;
}

.reserves-row.is-action-disabled {
  color: var(--muted);
  background: #fafbfc;
}

.reserves-row.is-action-disabled .row-check {
  opacity: 0.35;
}


/* v1.12.12: нормальное закрепление настоящих заголовков таблиц без JS-копий */
@media (min-width: 681px) {
  .table-wrap {
    overflow: visible;
  }

  .items-header,
  .balances-header,
  .sold-header,
  .reserves-header {
    position: sticky;
    top: 0;
    z-index: 30;
    background: rgba(255, 255, 255, 0.98);
    box-shadow: 0 8px 18px rgba(31, 42, 55, 0.10);
  }

  .has-sticky-actions .items-header,
  .has-sticky-actions .sold-header,
  .has-sticky-actions .reserves-header {
    top: 64px;
  }
}

.items-header > :first-child,
.item-read-row > :first-child,
.sold-header > :first-child,
.sold-row > :first-child,
.reserves-header > :first-child,
.reserves-row > :first-child {
  position: sticky;
  left: 0;
  z-index: 12;
  border-right: 1px solid var(--line);
  background: #fff;
}

.items-header > :first-child,
.sold-header > :first-child,
.reserves-header > :first-child {
  z-index: 35;
  background: rgba(255, 255, 255, 0.98);
}

.item-read-row.is-reserved > :first-child {
  background: #fff8db;
}

.reserves-row.is-action-disabled > :first-child {
  background: #fafbfc;
}


/* v1.12.13: заголовки таблиц выровнены по левому краю */
.items-header,
.balances-header,
.sold-header,
.reserves-header,
.subcategory-items-header {
  justify-items: start;
  text-align: left;
}

.items-header > *,
.balances-header > *,
.sold-header > *,
.reserves-header > *,
.subcategory-items-header > * {
  justify-self: start;
  text-align: left;
}

.sort-link {
  display: inline-block;
  text-align: left;
}


/* v1.12.14: заголовок склада использует те же отступы и промежутки, что строки товаров */
.items-header {
  gap: 6px;
  align-items: center;
  padding: 6px 10px;
}

.items-header > * {
  min-width: 0;
}


/* v1.12.15: компактная панель действий и безопасный отступ для закреплённого заголовка */
.inventory-actions {
  padding-top: 7px;
  padding-bottom: 7px;
}

.inventory-actions button,
.inventory-actions .ghost-button,
.inventory-actions .danger-button,
.inventory-actions .select-all-control {
  min-height: 36px;
  padding-left: 14px;
  padding-right: 14px;
}

@media (min-width: 681px) {
  .has-sticky-actions .items-header,
  .has-sticky-actions .sold-header,
  .has-sticky-actions .reserves-header {
    top: 56px;
  }
}


/* v1.12.16: панель действий всегда выше закреплённого заголовка */
.inventory-actions {
  z-index: 120;
}

@media (min-width: 681px) {
  .has-sticky-actions .items-header,
  .has-sticky-actions .sold-header,
  .has-sticky-actions .reserves-header {
    top: 64px;
  }

  .items-header,
  .balances-header,
  .sold-header,
  .reserves-header {
    z-index: 40;
  }

  .items-header > :first-child,
  .sold-header > :first-child,
  .reserves-header > :first-child {
    z-index: 45;
  }
}


/* v1.12.17: заголовок опущен ниже панели действий, чтобы его не срезало */
@media (min-width: 681px) {
  .has-sticky-actions .items-header,
  .has-sticky-actions .sold-header,
  .has-sticky-actions .reserves-header {
    top: 84px;
  }
}


/* v1.12.18: убран зазор между панелью действий и закреплённым заголовком */
@media (min-width: 681px) {
  .has-sticky-actions .items-header,
  .has-sticky-actions .sold-header,
  .has-sticky-actions .reserves-header {
    top: 74px;
  }
}


.app-version-badge {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #f8fafb;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  padding: 0 10px;
  white-space: nowrap;
}


.modal textarea[name="reserved_note"] {
  min-height: 72px;
}


/* v1.12.21: модальные окна выше закреплённой панели действий и заголовка */
.modal-backdrop {
  z-index: 1000;
}

.modal {
  position: relative;
  z-index: 1001;
}


.logs-table td {
  vertical-align: top;
}

.logs-table small {
  color: var(--muted);
  line-height: 1.35;
}


.online-grid {
  min-width: 1480px;
}

.online-header,
.online-row {
  grid-template-columns: 150px 190px 170px 130px 190px 260px 180px 170px 160px;
}


.db-backup-panel {
  display: grid;
  gap: 14px;
}


/* v1.13.6: закрепление заголовков таблиц на мобильной версии */
@media (max-width: 680px) {
  .table-wrap {
    overflow: visible;
  }

  .items-header,
  .balances-header,
  .sold-header,
  .reserves-header,
  .subcategory-items-header {
    position: sticky;
    top: 0;
    z-index: 90;
    background: rgba(255, 255, 255, 0.98);
    box-shadow: 0 8px 18px rgba(31, 42, 55, 0.12);
  }

  .items-header > :first-child,
  .sold-header > :first-child,
  .reserves-header > :first-child {
    z-index: 95;
    background: rgba(255, 255, 255, 0.98);
  }
}


/* v1.13.7: мобильный плавающий заголовок без поломки горизонтального скролла */
@media (max-width: 680px) {
  .table-wrap {
    overflow-x: auto !important;
    overflow-y: visible !important;
    -webkit-overflow-scrolling: touch;
  }

  .items-header,
  .balances-header,
  .sold-header,
  .reserves-header,
  .subcategory-items-header {
    position: static;
    top: auto;
  }

  .mobile-sticky-table-header {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 260;
    display: none;
    overflow: hidden;
    max-width: 100vw;
    background: rgba(255, 255, 255, 0.98);
    box-shadow: 0 8px 18px rgba(31, 42, 55, 0.14);
    pointer-events: auto;
  }

  .mobile-sticky-table-header.is-visible {
    display: block;
  }

  .mobile-sticky-table-header > * {
    position: static !important;
    top: auto !important;
    margin: 0 !important;
    box-shadow: none !important;
    will-change: transform;
  }
}


/* v1.13.9: надёжное открытие календаря по кнопке */
.date-picker-control {
  grid-template-columns: minmax(0, 1fr) 44px;
}

.date-picker-control .date-display-input {
  grid-column: 1;
  grid-row: 1;
}

.date-picker-control .native-date-input {
  position: static;
  grid-column: 2;
  grid-row: 1;
  z-index: 3;
  width: 44px;
  min-width: 44px;
  height: 44px;
  min-height: 44px;
  padding: 0;
  opacity: 0;
  pointer-events: auto;
  cursor: pointer;
}

.date-picker-control .date-picker-button {
  grid-column: 2;
  grid-row: 1;
  z-index: 2;
  pointer-events: none;
}


/* v1.13.10: календарь открывается через настоящий видимый native date input */
.date-picker-control {
  grid-template-columns: minmax(0, 1fr) 44px;
}

.date-picker-control .native-date-input {
  position: static !important;
  grid-column: 2;
  grid-row: 1;
  z-index: 3;
  width: 44px !important;
  min-width: 44px !important;
  max-width: 44px !important;
  height: 44px !important;
  min-height: 44px !important;
  padding: 0 !important;
  opacity: 1 !important;
  pointer-events: auto !important;
  cursor: pointer;
  color: transparent;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 12px;
}

.date-picker-control .native-date-input::-webkit-datetime-edit,
.date-picker-control .native-date-input::-webkit-inner-spin-button,
.date-picker-control .native-date-input::-webkit-clear-button {
  display: none;
}

.date-picker-control .native-date-input::-webkit-calendar-picker-indicator {
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  cursor: pointer;
  opacity: 1;
}

.date-picker-control .date-picker-button {
  display: none;
}


/* v1.13.11: календарь открывается именно по видимой иконке */
.date-picker-control {
  grid-template-columns: minmax(0, 1fr) 44px;
}

.date-picker-control .native-date-input {
  position: absolute !important;
  right: 0;
  top: 0;
  z-index: 1;
  display: block !important;
  width: 44px !important;
  min-width: 44px !important;
  max-width: 44px !important;
  height: 44px !important;
  min-height: 44px !important;
  padding: 0 !important;
  opacity: 0.01 !important;
  pointer-events: none !important;
  color: transparent;
  background: transparent;
  border: 0;
}

.date-picker-control .date-picker-button {
  display: inline-flex !important;
  grid-column: 2;
  grid-row: 1;
  z-index: 4;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  width: 44px;
  height: 44px;
  padding: 0;
  pointer-events: auto;
  cursor: pointer;
}


.password-change-panel {
  display: grid;
  gap: 14px;
}

.password-change-form {
  display: grid;
  gap: 12px;
  max-width: 520px;
}

.success-note,
.error-note {
  border-radius: 12px;
  padding: 12px 14px;
  font-weight: 800;
}

.success-note {
  background: #e8f5ee;
  color: #0e6048;
  border: 1px solid #b9dccf;
}

.error-note {
  background: #fff1f0;
  color: var(--danger);
  border: 1px solid #f1c3bf;
}


/* v1.13.14: заголовок таблицы снова вплотную под панелью действий */
@media (min-width: 681px) {
  .has-sticky-actions .items-header,
  .has-sticky-actions .sold-header,
  .has-sticky-actions .reserves-header {
    top: 50px;
  }
}


/* v1.13.15: отступ заголовка считается по фактической высоте панели действий */
@media (min-width: 681px) {
  .has-sticky-actions .items-header,
  .has-sticky-actions .sold-header,
  .has-sticky-actions .reserves-header {
    top: var(--sticky-actions-offset, 74px);
  }
}


.back-to-top-button {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 2200;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 46px;
  min-width: 46px;
  height: 46px;
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.96);
  color: var(--accent-strong);
  box-shadow: 0 10px 28px rgba(31, 42, 55, 0.18);
  font-size: 24px;
  font-weight: 900;
  cursor: pointer;
  backdrop-filter: blur(8px);
}

.back-to-top-button:hover {
  background: #eef4f1;
}

@media (max-width: 680px) {
  .back-to-top-button {
    right: 14px;
    bottom: 92px;
    width: 42px;
    min-width: 42px;
    height: 42px;
    min-height: 42px;
    font-size: 22px;
  }
}


/* v1.13.22: панель кнопок не зависит от изменения ширины колонок таблицы */
.inventory-actions {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  box-sizing: border-box;
  display: flex;
  flex-wrap: nowrap;
  justify-content: flex-end;
  align-items: center;
  gap: 8px;
  overflow-x: auto;
  overflow-y: hidden;
  overscroll-behavior-x: contain;
}

.inventory-actions .select-all-control,
.inventory-actions button,
.inventory-actions .ghost-button,
.inventory-actions .danger-button {
  flex: 0 0 auto;
}

@media (min-width: 681px) {
  .has-sticky-actions > .inventory-actions {
    left: 0;
    right: 0;
  }
}


/* v1.13.23: таблица не расширяется шире окна при изменении ширины колонок */
.items-grid,
.balances-grid,
.sold-grid,
.reserves-grid,
.subcategory-items-grid {
  max-width: 100%;
}


.modal-check {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
  font-size: 14px;
  font-weight: 800;
  margin-top: 4px;
}

.modal-check input {
  width: 16px;
  height: 16px;
}


/* v1.13.27: модальное окно всегда выше всех панелей, фон только блокирует клики */
.modal-backdrop {
  z-index: 3000 !important;
  pointer-events: auto;
}

.modal {
  position: relative;
  z-index: 3001 !important;
  pointer-events: auto;
}


/* v1.13.28: объединённое отображение производитель-артикул */
.manufacturer-article-value {
  font-weight: 700;
}


.item-edit-modal {
  width: min(100%, 760px);
}

.item-edit-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(220px, 1fr));
  gap: 12px;
}

.item-edit-title-field {
  grid-column: 1 / -1;
}

.item-edit-button {
  margin-top: 8px;
  min-height: 30px;
  padding: 6px 10px;
  font-size: 12px;
}

@media (max-width: 680px) {
  .item-edit-grid {
    grid-template-columns: 1fr;
  }

  .item-edit-title-field {
    grid-column: auto;
  }
}


.reserve-history-table td {
  vertical-align: top;
}

.reserve-history-table small {
  color: var(--muted);
}

.reserve-history-note {
  padding: 12px 18px;
}


/* v1.13.36: текст в кнопках верхнего меню по центру */
.topbar .profile .ghost-link,
.topbar .profile .ghost-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  line-height: 1.15;
}


/* v1.13.39: заказы */
.balances-grid.has-order-selection {
  min-width: 1480px;
}

.balances-grid.has-order-selection .balances-header,
.balances-grid.has-order-selection .balances-row {
  grid-template-columns: var(--table-columns, 44px 160px 160px 220px 390px 150px 90px 100px 90px);
}

.balance-order-actions {
  position: sticky;
  top: 0;
  z-index: 120;
}

.order-quantity-modal {
  width: min(100%, 720px);
}

.order-quantity-list {
  display: grid;
  gap: 10px;
  max-height: min(52vh, 520px);
  overflow-y: auto;
}

.order-quantity-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 140px;
  gap: 12px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
}

.order-quantity-row strong,
.order-quantity-row small {
  display: block;
}

.order-quantity-row small {
  margin-top: 3px;
  color: var(--muted);
}

.orders-filter-form {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(220px, 1fr) auto auto auto;
  gap: 10px;
  align-items: end;
}

.orders-list {
  display: grid;
  gap: 14px;
}

.order-card {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  box-shadow: 0 8px 22px rgba(31, 42, 55, 0.06);
  overflow: hidden;
}

.order-summary {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) auto auto;
  gap: 14px;
  align-items: center;
  padding: 16px 18px;
  cursor: pointer;
  list-style: none;
}

.order-summary::-webkit-details-marker {
  display: none;
}

.order-summary-main {
  display: grid;
  gap: 4px;
}

.order-summary-main small {
  color: var(--muted);
}

.order-status-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 32px;
  border-radius: 999px;
  padding: 0 12px;
  font-weight: 800;
  white-space: nowrap;
}

.order-status-badge.is-ordered {
  background: #e8f5ee;
  color: #0e6048;
}

.order-status-badge.is-not-ordered {
  background: #fff3e8;
  color: #8a4b08;
}

.order-card-body {
  display: grid;
  gap: 14px;
  border-top: 1px solid var(--line);
  padding: 16px 18px 18px;
}

.order-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  color: var(--muted);
}

.order-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: end;
}

.order-inline-form {
  display: flex;
  gap: 8px;
  align-items: center;
}

.order-inline-form input,
.order-inline-form select {
  min-width: 200px;
}

.order-items-table td {
  vertical-align: top;
}

@media (min-width: 681px) {
  .has-sticky-actions .balances-header {
    top: var(--sticky-actions-offset, 74px);
  }
}

@media (max-width: 680px) {
  .orders-filter-form {
    grid-template-columns: 1fr;
  }

  .order-summary {
    grid-template-columns: 1fr;
  }

  .order-quantity-row {
    grid-template-columns: 1fr;
  }

  .order-inline-form {
    display: grid;
    width: 100%;
  }

  .order-inline-form input,
  .order-inline-form select,
  .order-inline-form button {
    width: 100%;
  }
}


/* v1.13.40: предварительное создание заказа и постоянный выбор заказа */
.order-create-panel { display: grid; gap: 14px; }
.order-create-form {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(220px, 1fr) minmax(260px, 1fr) auto;
  gap: 12px;
  align-items: end;
}
.balance-current-order {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #f8fafb;
  color: var(--muted);
  padding: 0 12px;
  font-size: 13px;
  font-weight: 800;
}
.balance-no-orders-note {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  color: var(--danger);
  font-size: 13px;
  font-weight: 800;
}
.balance-order-select-field { margin-bottom: 4px; }
.order-empty-state { margin: 0; }
@media (max-width: 980px) { .order-create-form { grid-template-columns: 1fr 1fr; } }
@media (max-width: 680px) { .order-create-form { grid-template-columns: 1fr; } }


/* v1.13.42: цены */
.price-cell {
  display: inline-flex !important;
  align-items: baseline;
  gap: 8px;
  min-width: 0;
  white-space: nowrap !important;
}

.price-cell strong,
.price-cell small {
  white-space: nowrap;
}

.price-cell small {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.2;
}

.items-grid.has-price-column {
  min-width: 2020px;
}

.items-grid.has-price-column .items-header,
.items-grid.has-price-column .item-read-row {
  grid-template-columns: var(--table-columns, 44px 160px 160px 160px 220px 165px 340px 145px 130px 270px);
}

.balances-grid.has-price-column:not(.has-order-selection) {
  min-width: 1600px;
}

.balances-grid.has-price-column:not(.has-order-selection) .balances-header,
.balances-grid.has-price-column:not(.has-order-selection) .balances-row {
  grid-template-columns: var(--table-columns, 160px 160px 220px 165px 390px 150px 90px 100px 90px);
}

.balances-grid.has-order-selection.has-price-column {
  min-width: 1660px;
}

.balances-grid.has-order-selection.has-price-column .balances-header,
.balances-grid.has-order-selection.has-price-column .balances-row {
  grid-template-columns: var(--table-columns, 44px 150px 150px 210px 165px 360px 145px 85px 95px 85px);
}

.sold-grid.has-price-column {
  min-width: 2210px;
}

.sold-grid.has-price-column .sold-header,
.sold-grid.has-price-column .sold-row {
  grid-template-columns: var(--table-columns, 44px 160px 150px 150px 160px 220px 165px 340px 145px 130px 300px);
}

.reserves-grid.has-price-column {
  min-width: 2150px;
}

.reserves-grid.has-price-column .reserves-header,
.reserves-grid.has-price-column .reserves-row {
  grid-template-columns: var(--table-columns, 44px 180px 160px 240px 150px 150px 160px 220px 165px 340px 145px 140px);
}

.subcategory-item-form.has-price-column {
  grid-template-columns: minmax(150px, 1fr) minmax(130px, .8fr) minmax(330px, 1.7fr) minmax(140px, .8fr) minmax(150px, .8fr) auto;
}

.subcategory-items-grid.has-price-column {
  min-width: 1510px;
}

.subcategory-items-grid.has-price-column .subcategory-items-header,
.subcategory-items-grid.has-price-column .subcategory-card-row {
  grid-template-columns: var(--table-columns, 160px 145px 210px 390px 150px 190px);
}

.product-card-price-editor {
  display: grid;
  grid-template-columns: auto auto;
  gap: 4px 8px;
  align-items: baseline;
  min-width: 0;
}

.product-card-price-editor input {
  grid-column: 1 / -1;
}

.product-card-price-editor strong {
  white-space: nowrap;
}

.product-card-price-editor small {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.2;
}

.product-card-price-editor input {
  grid-column: 1 / -1;
  min-width: 0;
}

.prices-table {
  min-width: 1180px;
}

.price-update-form {
  display: grid;
  grid-template-columns: minmax(150px, 1fr) auto;
  gap: 8px;
  align-items: center;
  min-width: 320px;
}

.order-items-table tfoot td {
  border-top: 2px solid var(--line);
  background: #f7faf8;
}

@media (max-width: 680px) {
  .subcategory-item-form.has-price-column {
    grid-template-columns: 1fr;
  }

  .price-update-form {
    grid-template-columns: 1fr;
    min-width: 220px;
  }
}


/* v1.13.43: на узких экранах таблицы не сжимаются JS-ширинами и сохраняют правильный порядок колонок */
@media (max-width: 680px) {
  .items-grid,
  .balances-grid,
  .sold-grid,
  .reserves-grid,
  .subcategory-items-grid {
    width: max-content !important;
    max-width: none !important;
  }

  .items-grid.has-price-column {
    min-width: 2020px !important;
  }

  .balances-grid.has-price-column:not(.has-order-selection) {
    min-width: 1600px !important;
  }

  .balances-grid.has-order-selection.has-price-column {
    min-width: 1660px !important;
  }

  .balances-grid.has-order-selection:not(.has-price-column) {
    min-width: 1480px !important;
  }

  .sold-grid.has-price-column {
    min-width: 2210px !important;
  }

  .reserves-grid.has-price-column {
    min-width: 2150px !important;
  }

  .subcategory-items-grid.has-price-column {
    min-width: 1510px !important;
  }

  .table-wrap {
    overflow-x: auto !important;
    overflow-y: visible;
    -webkit-overflow-scrolling: touch;
  }
}


/* v1.13.48: карточки товаров с нулевым остатком */
.zero-stock-card-note {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 600;
  line-height: 1.1;
  white-space: nowrap;
}


/* v1.13.50: нативный переход из Остатков к позиции на Складе */
.balances-row.is-stock-link {
  position: relative;
}

.balance-stock-link-overlay {
  position: absolute;
  inset: 0;
  z-index: 2;
  border-radius: inherit;
}

.balances-row.is-stock-link:hover {
  background: #f1f7f4;
}

.balance-stock-link-overlay:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

/* Галочка заказа должна оставаться выше ссылки всей строки. */
.balances-row.is-stock-link .row-check {
  position: relative;
  z-index: 3;
}

/* Текст остаётся видимым, но клик по нему принимает ссылка строки. */
.balances-row.is-stock-link > :not(.balance-stock-link-overlay):not(.row-check) {
  position: relative;
  z-index: 1;
}


/* v1.13.54: крупные категории в Остатках */
.balance-category-strip {
  overflow: hidden;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: #fff;
  padding: 18px 0;
}

.balance-category-pills {
  display: flex;
  gap: 14px;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 0 18px 4px;
  scrollbar-width: thin;
  -webkit-overflow-scrolling: touch;
}

.balance-category-pill {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 8px;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--ink);
  padding: 0 16px;
  font-size: inherit;
  font-weight: 800;
  line-height: 1;
  text-decoration: none;
  white-space: nowrap;
  transition:
    background 160ms ease,
    border-color 160ms ease,
    color 160ms ease,
    transform 160ms ease;
}

.balance-category-pill:hover {
  border-color: #b9cbc4;
  background: #f3f8f6;
  transform: translateY(-1px);
}

.balance-category-pill small {
  display: inline-grid;
  min-width: 24px;
  min-height: 24px;
  place-items: center;
  border-radius: 999px;
  background: #f1f2f3;
  color: #1f2b36;
  padding: 0;
  font-size: 12px;
  font-weight: 900;
  line-height: 1;
}

.balance-category-pill.is-active {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

.balance-category-pill.is-active small {
  background: rgba(255, 255, 255, 0.24);
  color: #fff;
}

.balance-category-pill:focus-visible {
  outline: 3px solid rgba(22, 119, 90, 0.28);
  outline-offset: 2px;
}

@media (max-width: 680px) {
  .balance-category-strip {
    padding: 12px 0;
  }

  .balance-category-pills {
    gap: 10px;
    padding: 0 10px 4px;
  }
}


/* v1.13.56: колонка ГТД на складе только по праву gtd_view */
.items-grid.has-gtd-column:not(.has-price-column) {
  min-width: 2030px;
}

.items-grid.has-gtd-column:not(.has-price-column) .items-header,
.items-grid.has-gtd-column:not(.has-price-column) .item-read-row {
  grid-template-columns: var(--table-columns, 44px 160px 160px 160px 220px 190px 340px 145px 130px 270px);
}

.items-grid.has-price-column.has-gtd-column {
  min-width: 2210px;
}

.items-grid.has-price-column.has-gtd-column .items-header,
.items-grid.has-price-column.has-gtd-column .item-read-row {
  grid-template-columns: var(--table-columns, 44px 150px 150px 160px 210px 190px 165px 330px 145px 130px 270px);
}

@media (max-width: 680px) {
  .items-grid.has-gtd-column:not(.has-price-column) {
    min-width: 2030px !important;
  }

  .items-grid.has-price-column.has-gtd-column {
    min-width: 2210px !important;
  }
}


/* v1.13.56: условная колонка ГТД в Продано и Резервах */
.sold-grid.has-gtd-column:not(.has-price-column) {
  min-width: 2220px;
}

.sold-grid.has-gtd-column:not(.has-price-column) .sold-header,
.sold-grid.has-gtd-column:not(.has-price-column) .sold-row {
  grid-template-columns: var(--table-columns, 44px 160px 150px 150px 160px 220px 190px 340px 145px 130px 300px);
}

.sold-grid.has-price-column.has-gtd-column {
  min-width: 2400px;
}

.sold-grid.has-price-column.has-gtd-column .sold-header,
.sold-grid.has-price-column.has-gtd-column .sold-row {
  grid-template-columns: var(--table-columns, 44px 155px 145px 145px 155px 210px 190px 165px 330px 140px 125px 290px);
}

.reserves-grid.has-gtd-column:not(.has-price-column) {
  min-width: 2160px;
}

.reserves-grid.has-gtd-column:not(.has-price-column) .reserves-header,
.reserves-grid.has-gtd-column:not(.has-price-column) .reserves-row {
  grid-template-columns: var(--table-columns, 44px 180px 160px 240px 150px 150px 160px 220px 190px 340px 145px 140px);
}

.reserves-grid.has-price-column.has-gtd-column {
  min-width: 2340px;
}

.reserves-grid.has-price-column.has-gtd-column .reserves-header,
.reserves-grid.has-price-column.has-gtd-column .reserves-row {
  grid-template-columns: var(--table-columns, 44px 175px 155px 230px 145px 145px 155px 210px 190px 165px 325px 140px 135px);
}

@media (max-width: 680px) {
  .sold-grid.has-gtd-column,
  .reserves-grid.has-gtd-column {
    max-width: none !important;
  }
}


/* v1.13.57: ввод нового ГТД при создании складского товара */
.gtd-combobox {
  min-width: 220px;
}

.gtd-combobox .gtd-input {
  width: 100%;
}


/* v1.13.58: навигация по дереву Категории -> Подкатегории -> Карточки */
.catalog-tree-navigation {
  display: grid;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: #fff;
  padding: 14px;
}

.catalog-breadcrumbs {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 7px;
  min-height: 34px;
  color: var(--muted);
  font-size: 14px;
}

.catalog-breadcrumbs a {
  color: var(--accent);
  font-weight: 800;
  text-decoration: none;
}

.catalog-breadcrumbs a:hover {
  text-decoration: underline;
  text-underline-offset: 3px;
}

.catalog-breadcrumbs strong {
  color: var(--ink);
  font-weight: 900;
}

.catalog-tree-panel {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  overflow-y: hidden;
  padding-bottom: 4px;
  scrollbar-width: thin;
  -webkit-overflow-scrolling: touch;
}

.catalog-tree-branch {
  display: grid;
  align-content: start;
  flex: 0 0 min(300px, 78vw);
  gap: 7px;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: #fafcfb;
  padding: 8px;
}

.catalog-tree-branch.is-active {
  border-color: rgba(22, 119, 90, 0.42);
  background: #f4f9f7;
}

.catalog-tree-category {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 42px;
  border-radius: 11px;
  color: var(--ink);
  padding: 0 11px;
  font-weight: 900;
  text-decoration: none;
}

.catalog-tree-category:hover {
  background: #edf4f1;
}

.catalog-tree-category.is-current {
  background: var(--accent);
  color: #fff;
}

.catalog-tree-category small {
  display: inline-grid;
  min-width: 24px;
  min-height: 24px;
  place-items: center;
  border-radius: 999px;
  background: #e9efec;
  color: var(--ink);
  padding: 0 6px;
  font-size: 11px;
  font-weight: 900;
}

.catalog-tree-category.is-current small {
  background: rgba(255, 255, 255, 0.22);
  color: #fff;
}

.catalog-tree-children {
  display: grid;
  gap: 4px;
  padding-left: 16px;
}

.catalog-tree-subcategory {
  position: relative;
  display: flex;
  align-items: center;
  min-height: 36px;
  border-radius: 9px;
  color: var(--muted);
  padding: 5px 10px 5px 18px;
  font-size: 13px;
  font-weight: 800;
  text-decoration: none;
}

.catalog-tree-subcategory::before {
  content: '';
  position: absolute;
  left: 4px;
  top: 0;
  bottom: 50%;
  width: 10px;
  border-left: 1px solid #cfdad5;
  border-bottom: 1px solid #cfdad5;
  border-bottom-left-radius: 6px;
}

.catalog-tree-subcategory:hover {
  background: #edf4f1;
  color: var(--ink);
}

.catalog-tree-subcategory.is-current {
  background: #dceee7;
  color: #0c5e45;
}

@media (max-width: 680px) {
  .catalog-tree-navigation {
    border-radius: 14px;
    padding: 10px;
  }

  .catalog-tree-branch {
    flex-basis: min(270px, 84vw);
  }
}


/* v1.13.59: массовый поиск и сканирование штрихкодов */
.bulk-search-modal {
  width: min(100%, 820px);
}

.bulk-search-modal form {
  display: grid;
  gap: 14px;
}

.bulk-search-modal .section-heading {
  align-items: center;
}

.bulk-search-count {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  border-radius: 999px;
  background: #eef4f1;
  color: #0c5e45;
  padding: 0 11px;
  font-size: 12px;
  font-weight: 900;
  white-space: nowrap;
}

.bulk-search-scanner-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.bulk-search-modal textarea {
  width: 100%;
  min-height: 220px;
  resize: vertical;
  font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
  line-height: 1.45;
}

.bulk-search-status {
  min-height: 20px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.bulk-search-status.is-warning {
  color: #a05a00;
}

.bulk-search-status.is-success {
  color: #0c6a4d;
}

.bulk-search-preview {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  max-height: 130px;
  overflow-y: auto;
}

.bulk-search-chip {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  max-width: 100%;
  border: 1px solid #d8e3de;
  border-radius: 999px;
  background: #f7faf8;
  color: var(--ink);
  padding: 3px 9px;
  font-size: 12px;
  font-weight: 800;
  overflow-wrap: anywhere;
}

.bulk-search-chip.is-more {
  background: #e8f3ee;
  color: #0c5e45;
}

.bulk-search-actions {
  justify-content: flex-end;
}

@media (max-width: 680px) {
  .bulk-search-scanner-row {
    grid-template-columns: 1fr;
  }

  .bulk-search-actions {
    display: grid;
    grid-template-columns: 1fr;
  }

  .bulk-search-actions button {
    width: 100%;
  }
}


/* v1.13.60: предупреждение о приближении срока резерва */
.reserve-expiry-notice-modal {
  width: min(100%, 900px);
}

.reserve-expiry-notice-count {
  display: inline-grid;
  min-width: 36px;
  min-height: 36px;
  place-items: center;
  border-radius: 999px;
  background: #fff0c7;
  color: #8a5600;
  padding: 0 9px;
  font-size: 13px;
  font-weight: 900;
}

.reserve-expiry-notice-list {
  display: grid;
  gap: 8px;
  max-height: min(56vh, 520px);
  overflow-y: auto;
  margin-top: 14px;
}

.reserve-expiry-notice-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 16px;
  align-items: center;
  border: 1px solid #ead8a6;
  border-radius: 14px;
  background: #fffaf0;
  padding: 12px 14px;
}

.reserve-expiry-notice-item-main {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.reserve-expiry-notice-item-main strong,
.reserve-expiry-notice-item-main span,
.reserve-expiry-notice-item-main small {
  overflow-wrap: anywhere;
}

.reserve-expiry-notice-item-main span,
.reserve-expiry-notice-item-main small {
  color: var(--muted);
}

.reserve-expiry-notice-deadline {
  display: grid;
  gap: 3px;
  justify-items: end;
  text-align: right;
  white-space: nowrap;
}

.reserve-expiry-notice-deadline strong {
  color: #9b5d00;
}

.reserve-expiry-notice-deadline span {
  color: var(--muted);
  font-size: 12px;
}

.reserve-expiry-notice-actions {
  justify-content: flex-end;
  margin-top: 16px;
}

@media (max-width: 680px) {
  .reserve-expiry-notice-item {
    grid-template-columns: 1fr;
  }

  .reserve-expiry-notice-deadline {
    justify-items: start;
    text-align: left;
    white-space: normal;
  }

  .reserve-expiry-notice-actions {
    display: grid;
    grid-template-columns: 1fr;
  }

  .reserve-expiry-notice-actions > * {
    width: 100%;
  }
}
