:root {
  color-scheme: light;
  --bg: #f5f5f7;
  --panel: #ffffff;
  --text: #1d1d1f;
  --muted: #6e6e73;
  --line: #d2d2d7;
  --border: var(--line);
  --surface: #fafafc;
  --brand: #0071e3;
  --brand-dark: #0066cc;
  --selected: #eaf3ff;
  --danger: #b42318;
  --warn: #b7791f;
}

* {
  box-sizing: border-box;
  letter-spacing: 0;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", Arial, sans-serif;
  font-size: 14px;
  line-height: 1.5;
}

a {
  color: inherit;
  text-decoration: none;
}

.app-shell {
  display: grid;
  grid-template-columns: 224px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  background: rgba(29, 29, 31, 0.94);
  backdrop-filter: saturate(180%) blur(20px);
  color: #f5f5f7;
  padding: 0 12px 24px;
  position: sticky;
  top: 0;
  height: 100dvh;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: #626265 transparent;
  z-index: 60;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 17px;
  font-weight: 600;
  white-space: nowrap;
}

.sidebar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 80px;
  padding: 12px 8px;
}

.brand-mark {
  align-items: center;
  background: #f5f5f7;
  border-radius: 8px;
  color: #1d1d1f;
  display: inline-flex;
  font-size: 13px;
  font-weight: 600;
  height: 32px;
  justify-content: center;
  width: 32px;
  flex: 0 0 auto;
}

.nav-group {
  margin: 4px 0 12px;
}

.nav-title {
  align-items: center;
  color: #c4c4c8;
  cursor: pointer;
  display: flex;
  font-size: 12px;
  gap: 10px;
  list-style: none;
  padding: 10px;
}

.nav-title::-webkit-details-marker {
  display: none;
}

.nav-title::after {
  content: "";
  background: url("/static/vendor/lucide/chevron-right.svg") center / 14px no-repeat;
  filter: invert(1);
  width: 14px;
  height: 14px;
  margin-left: auto;
  transform: rotate(0deg);
  transition: transform 120ms ease;
}

.nav-group[open] > .nav-title::after {
  transform: rotate(90deg);
}

.nav-title:hover {
  color: #ffffff;
}

.nav-link {
  display: block;
  border-radius: 6px;
  color: #dcdcdf;
  padding: 9px 12px 9px 38px;
  margin: 2px 0;
}

.nav-link:hover {
  background: rgba(255, 255, 255, 0.07);
  color: #fff;
}

.nav-link.active {
  background: #0071e3;
  color: #fff;
}

.main {
  min-width: 0;
  transition: opacity 120ms ease;
}

#main-content.htmx-request {
  opacity: 0.55;
}

.topbar {
  min-height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
  background: rgba(245, 245, 247, 0.9);
  backdrop-filter: saturate(180%) blur(20px);
  padding: 8px 28px;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 45;
}

.content {
  padding: 28px;
  min-width: 0;
}

.topbar-heading,
.account-menu {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.workspace-name {
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}

.account-menu {
  margin: 0;
}

.account-name {
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
}

.ui-icon {
  display: block;
  flex: 0 0 auto;
  height: 18px;
  width: 18px;
}

.sidebar .ui-icon {
  filter: invert(1);
}

.dashboard-workbench-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px 28px;
  margin-bottom: 16px;
}

.dashboard-workbench-grid > .panel {
  min-width: 0;
  margin: 0;
}

.dashboard-workbench-grid > [data-workbench-full-row] {
  grid-column: 1 / -1;
}

.dashboard-workbench-grid .section-head {
  align-items: center;
  display: flex;
  gap: 10px;
  justify-content: space-between;
  margin-bottom: 12px;
}

.dashboard-workbench-grid .section-head h2 {
  margin: 0;
}

.dashboard-workbench-grid .table-wrap {
  min-width: 0;
  width: 100%;
}

.page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.page-head > .actions {
  flex-wrap: nowrap;
  max-width: 100%;
  overflow-x: auto;
  padding-bottom: 2px;
  white-space: nowrap;
}

h1 {
  margin: 0;
  font-size: 26px;
  font-weight: 600;
  line-height: 1.3;
  overflow-wrap: anywhere;
}

h2 {
  margin: 0 0 14px;
  font-size: 17px;
  font-weight: 600;
  overflow-wrap: anywhere;
}

.muted {
  color: var(--muted);
}

.panel {
  background: transparent;
  border: 0;
  border-top: 1px solid var(--line);
  border-radius: 0;
  padding: 20px 0;
  min-width: 0;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 0;
  margin-bottom: 24px;
  background: var(--panel);
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.stat {
  padding: 18px 20px;
  min-width: 0;
}

.stat strong {
  display: block;
  font-size: 28px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.summary-grid {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  margin-top: 12px;
}

.summary-cell {
  background: var(--panel);
  border: 0;
  border-radius: 0;
  padding: 10px 12px;
}

.summary-cell strong {
  display: block;
  font-size: 18px;
}

.logistics-card {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 12px;
  margin-top: 10px;
  background: var(--surface);
}

.binding-picker {
  position: relative;
}

.binding-selected {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-height: 32px;
  padding-top: 8px;
}

.binding-chip {
  display: inline-flex;
  align-items: center;
  padding: 4px 8px;
  border: 1px solid #c1d9f5;
  border-radius: 6px;
  background: var(--selected);
  color: var(--brand-dark);
}

.binding-options {
  position: absolute;
  z-index: 30;
  top: 42px;
  right: 0;
  left: 0;
  max-height: 260px;
  overflow-y: auto;
  padding: 6px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.14);
}

.binding-option {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px;
  cursor: pointer;
}

.binding-option:hover {
  background: var(--selected);
}

.logistics-edit-form {
  margin-top: 10px;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.button,
button {
  border: 1px solid var(--brand);
  border-radius: 8px;
  background: var(--brand);
  color: white;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  padding: 7px 12px;
  font: inherit;
  gap: 6px;
  font-weight: 500;
  transition: background-color 120ms ease, border-color 120ms ease;
}

.button.secondary,
button.secondary {
  background: transparent;
  color: var(--brand-dark);
  border-color: var(--line);
}

.button:hover,
button:hover {
  background: #0077ed;
}

.button.secondary:hover,
button.secondary:hover {
  background: #e8e8ed;
  border-color: #b8b8bd;
}

.button.danger,
button.danger {
  border-color: var(--danger);
  background: var(--danger);
}

.table-wrap {
  min-width: 0;
  max-width: 100%;
  overflow-x: auto;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.data-grid {
  min-width: var(--data-grid-min-width, 100%);
  table-layout: fixed;
  width: max(100%, var(--data-grid-min-width, 100%));
}

.data-grid:not([data-grid-has-flexible]) {
  width: var(--data-grid-min-width, 100%);
}

.data-grid col[data-col-group="compact"],
.data-grid col[data-col-group="bounded"] {
  width: var(--data-col-width);
}

.data-grid [data-col-ellipsis] {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.data-grid [data-col-type="quantity"],
.data-grid [data-col-type="money"] {
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.data-grid [data-col-type="name"],
.data-grid [data-col-type="description"],
.data-grid [data-col-type="skuComposite"] {
  overflow-wrap: anywhere;
  white-space: normal;
}

.data-grid [data-col-type="skuComposite"] {
  min-width: 320px;
}

[data-col-type="remark"] {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.data-grid [data-col-type="name"][data-col-ellipsis],
.data-grid .cell-ellipsis {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.data-grid [data-col-type="spacer"] {
  padding-left: 0;
  padding-right: 0;
}

.data-grid th[data-col-type="selection"] .checkbox-option {
  font-size: 0;
  gap: 0;
}

.data-grid [data-col-type="actions"] {
  overflow: visible;
  white-space: nowrap;
}

.data-grid [data-col-type="actions"] .document-actions,
.data-grid [data-col-type="actions"] .actions,
.data-grid [data-col-type="actions"] form {
  flex-wrap: nowrap;
  white-space: nowrap;
}

.data-grid [data-col-group="bounded"] input,
.data-grid [data-col-group="bounded"] select {
  min-width: 0;
  width: 100%;
}

table {
  border-collapse: collapse;
  width: 100%;
  min-width: 0;
}

.stable-shortage-table .shortage-action-cell {
  background: var(--panel);
  box-shadow: -8px 0 10px rgb(15 23 42 / 4%);
  position: sticky;
  right: 0;
  z-index: 2;
}

.stable-shortage-table th.shortage-action-cell {
  background: var(--surface);
  z-index: 3;
}

.shortage-row-actions {
  align-items: center;
  display: flex;
  flex-wrap: nowrap;
  gap: 6px;
}

.shortage-source-toggle {
  align-items: center;
  display: inline-flex;
  flex: 0 0 34px;
  height: 34px;
  justify-content: center;
  padding: 0;
  width: 34px;
}

.shortage-source-toggle > span {
  border: 2px solid currentColor;
  border-radius: 50%;
  display: block;
  height: 11px;
  position: relative;
  width: 11px;
}

.shortage-source-toggle > span::after {
  background: currentColor;
  content: "";
  height: 2px;
  position: absolute;
  right: -6px;
  top: 9px;
  transform: rotate(45deg);
  transform-origin: left center;
  width: 7px;
}

.shortage-source-row > td {
  background: var(--surface);
  padding: 12px 16px;
  white-space: normal;
}

.shortage-source-panel {
  border-left: 2px solid var(--line);
  padding-left: 12px;
}

.shortage-source-entry {
  margin-top: 8px;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 10px 12px;
  text-align: left;
  vertical-align: top;
  white-space: nowrap;
}

th {
  background: var(--surface);
  color: var(--muted);
  font-weight: 600;
}

tr:last-child td {
  border-bottom: 0;
}

.change-log-table {
  table-layout: fixed;
  min-width: 1000px;
}

.change-log-table th:nth-child(1) { width: 160px; }
.change-log-table th:nth-child(2) { width: 140px; }
.change-log-table th:nth-child(3) { width: 130px; }
.change-log-table th:nth-child(4) { width: 220px; }

.change-log-table td {
  overflow-wrap: anywhere;
  white-space: normal;
  vertical-align: top;
  line-height: 1.5;
}

.production-change-log-table th:nth-child(1) { width: 150px; }
.production-change-log-table th:nth-child(2) { width: 150px; }
.production-change-log-table th:nth-child(3) { width: 120px; }
.production-change-log-table th:nth-child(4) { width: 230px; }

.production-change-log-table td:nth-child(-n+4) {
  overflow: hidden;
  text-overflow: ellipsis;
}

.status {
  display: inline-block;
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 12px;
  background: #ecfdf3;
  color: #027a48;
}

.status.off {
  background: #f2f4f7;
  color: #667085;
}

.status.warn {
  background: #fffaeb;
  color: var(--warn);
}

.status.danger-text {
  background: #fff1f0;
  color: var(--danger);
}

.status-success {
  background: #ecfdf3;
  color: #027a48;
}

.status-neutral {
  background: #f2f4f7;
  color: #667085;
}

.status-warning {
  background: #fffaeb;
  color: #b54708;
}

.status-info {
  background: #eff8ff;
  color: #175cd3;
}

.status-danger {
  background: #fef3f2;
  color: #b42318;
}

.nested-table {
  margin-top: 10px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px 16px;
}

.form-grid.compact {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.uploaded-image-preview {
  display: block;
  max-width: 240px;
  max-height: 180px;
  margin-top: 8px;
  object-fit: contain;
  border: 1px solid var(--border);
  background: #fff;
}

.field {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.contract-requirements-table td {
  height: 132px;
  white-space: normal;
}

.contract-requirements-table tbody tr {
  height: 132px;
}

.contract-requirements-table textarea {
  height: 88px;
  min-height: 88px;
}

.contract-custom-title {
  margin-top: 8px;
  min-width: 0;
  width: 100%;
}

.contract-custom-title label {
  font-size: 12px;
}

.lookup {
  position: relative;
  width: 100%;
}

.lookup input[data-lookup-input] {
  padding-right: 34px;
}

.lookup::after {
  color: var(--muted);
  content: "⌄";
  pointer-events: none;
  position: absolute;
  right: 11px;
  top: 36px;
}

td .lookup::after {
  top: 10px;
}

.lookup-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 6px;
  box-shadow: 0 12px 28px rgba(16, 24, 40, 0.14);
  left: 0;
  max-height: 320px;
  min-width: min(620px, calc(100vw - 72px));
  overflow: auto;
  padding: 8px;
  position: absolute;
  top: calc(100% + 4px);
  z-index: 40;
}

.lookup-expansion-panel {
  --lookup-row-height: 42px;
  min-height: calc(var(--lookup-row-height) * 5 + 136px);
}

.lookup-expansion-panel .table-wrap {
  min-height: calc(var(--lookup-row-height) * 5 + 76px);
  overflow-y: visible;
}

.lookup-expansion-panel .lookup-panel {
  max-height: calc(var(--lookup-row-height) * 5 + 48px);
}

.lookup-table {
  border-collapse: collapse;
  width: 100%;
}

.lookup-table th,
.lookup-table td {
  border-bottom: 0;
  padding: 8px 10px;
}

.lookup-table th {
  background: var(--surface);
  color: var(--muted);
}

.lookup-table tr[data-lookup-option] {
  cursor: pointer;
}

.lookup-table tr[data-lookup-option]:hover,
.lookup-table tr[data-lookup-option].active {
  background: var(--selected);
}

.lookup-empty {
  color: var(--muted);
  padding: 12px;
}

label {
  color: var(--text);
  font-weight: 500;
  font-size: 13px;
}

input,
select,
textarea {
  border: 1px solid #b8b8bd;
  border-radius: 8px;
  color: var(--text);
  background: var(--panel);
  font: inherit;
  min-height: 38px;
  padding: 8px 10px;
  width: 100%;
  min-width: 0;
  max-width: 100%;
}

input[type="checkbox"] {
  accent-color: var(--brand);
  cursor: pointer;
  flex: 0 0 auto;
  height: 16px;
  margin: 0;
  min-height: 0;
  padding: 0;
  width: 16px;
}

input[type="radio"] {
  accent-color: var(--brand);
  cursor: pointer;
  flex: 0 0 auto;
  height: 16px;
  margin: 0;
  min-height: 0;
  padding: 0;
  width: 16px;
}

.checkbox-option {
  align-items: center;
  color: var(--text);
  display: inline-flex;
  font-weight: 500;
  gap: 8px;
  min-height: 38px;
}

.role-permission-list {
  border-top: 1px solid var(--line);
  margin: 12px 0;
}

.role-permission-row {
  align-items: start;
  border-bottom: 1px solid var(--line);
  display: grid;
  gap: 16px;
  grid-template-columns: minmax(260px, 0.9fr) minmax(360px, 1.6fr);
  padding: 10px 0;
}

.role-default-details summary {
  color: var(--brand-dark);
  cursor: pointer;
  font-weight: 600;
  padding: 8px 0;
}

.permission-name-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 12px;
  padding: 4px 0 8px;
}

.permission-name-list > span:not(.muted) {
  background: #eef6ff;
  border-radius: 4px;
  color: #175cd3;
  padding: 3px 6px;
}

textarea {
  min-height: 88px;
  resize: vertical;
}

.full {
  grid-column: 1 / -1;
}

.form-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 16px;
  flex-wrap: wrap;
}

.list-section-head {
  flex-wrap: wrap;
  align-items: center;
  display: flex;
  gap: 12px;
  justify-content: space-between;
  margin-bottom: 12px;
}

.list-section-head h2 {
  margin: 0;
}

.line-editor-head {
  flex-wrap: wrap;
  align-items: center;
  display: flex;
  gap: 12px;
  justify-content: space-between;
  margin-bottom: 12px;
}

.section-head {
  flex-wrap: wrap;
  align-items: center;
  display: flex;
  gap: 12px;
  justify-content: space-between;
  margin-bottom: 12px;
}

.section-head h2 {
  margin: 0;
}

.other-inventory-form .lookup-panel {
  min-width: min(760px, calc(100vw - 96px));
}

.other-inventory-form .data-grid [data-col-type="skuComposite"] {
  width: 360px;
}

.other-inventory-form .data-grid [data-col-type="quantity"],
.other-inventory-form .data-grid [data-col-type="money"] {
  width: 130px;
}

.other-inventory-form .data-grid [data-col-type="actions"] {
  width: 78px;
}

.other-inventory-detail-grid {
  display: grid;
  gap: 14px 28px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

@media (max-width: 900px) {
  .other-inventory-detail-grid {
    grid-template-columns: 1fr;
  }
}

.line-editor-head h2 {
  margin: 0;
}

.order-batch-actions {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.production-order-filter-panel {
  padding: 16px;
}

.production-order-filter-row {
  align-items: end;
  display: grid;
  gap: 12px;
  grid-template-columns: minmax(150px, 0.85fr) repeat(3, minmax(180px, 1fr)) auto;
}

.production-order-filter-actions {
  margin-top: 0;
  white-space: nowrap;
}

.production-order-action-panel {
  padding: 16px;
}

.production-order-batch-actions {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.action-dialog {
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 18px 48px rgb(15 23 42 / 18%);
  color: var(--text);
  max-width: 520px;
  padding: 16px;
  width: min(520px, calc(100vw - 48px));
}

.review-dialog {
  max-width: 560px;
  padding: 0;
  width: min(560px, calc(100vw - 48px));
}

.action-dialog::backdrop {
  background: rgb(15 23 42 / 28%);
}

.dialog-head {
  align-items: center;
  display: flex;
  gap: 12px;
  justify-content: space-between;
  margin-bottom: 0;
  padding: 16px 18px 12px;
}

.dialog-head h2 {
  margin: 0;
  font-size: 20px;
}

.dialog-body {
  display: grid;
  gap: 14px;
  padding: 6px 18px 16px;
}

.compact-button {
  min-height: 30px;
  padding: 4px 10px;
}

.radio-option {
  align-items: center;
  display: inline-flex;
  gap: 6px;
  margin-right: 16px;
}

.review-choice-group {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.review-choice-card {
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  gap: 10px;
  min-height: 44px;
  padding: 10px 12px;
  white-space: nowrap;
}

.review-choice-card:has(input:checked) {
  background: var(--selected);
  border-color: var(--brand);
}

.review-option-text {
  color: var(--text);
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
}

.review-reason-field textarea {
  min-height: 88px;
}

.dialog-actions {
  border-top: 1px solid var(--line);
  margin-top: 0;
  padding: 12px 18px 16px;
}

@media (max-width: 1180px) {
  .production-order-filter-row {
    grid-template-columns: repeat(2, minmax(180px, 1fr));
  }

  .production-order-filter-actions {
    justify-content: flex-start;
  }
}

.inline-editor {
  display: inline-block;
}

.inline-editor > summary {
  list-style: none;
}

.inline-editor > summary::-webkit-details-marker {
  display: none;
}

.supplier-price-row [data-supplier-price-edit][hidden] {
  display: none;
}

.supplier-price-row.is-editing [data-supplier-price-display] {
  display: none;
}

.supplier-price-row.is-editing [data-supplier-price-edit] {
  display: block;
  width: 100%;
  min-width: 0;
}

.supplier-price-row.is-editing .actions[data-supplier-price-edit] {
  display: flex;
}

.editor-panel {
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 8px;
  margin-top: 8px;
  min-width: min(680px, calc(100vw - 96px));
  padding: 12px;
}

.issue-order-main-row > td:not([data-col-type="actions"]) {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.purchase-allocation-table select,
.purchase-allocation-table input {
  min-width: 0;
  width: 100%;
}

.data-grid[data-grid-align="left"] th,
.data-grid[data-grid-align="left"] td {
  text-align: left;
}

.followup-review-actions {
  display: flex;
  flex-wrap: nowrap;
  white-space: nowrap;
}

.followup-review-actions form {
  flex: 0 0 auto;
  margin: 0;
}

.followup-review-actions button {
  font-size: 12px;
  min-height: 30px;
  padding: 5px 8px;
  white-space: nowrap;
}

.purchase-allocation-table .allocation-material-name,
.logistics-line-detail {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.purchase-allocation-table .allocation-material-name {
  max-width: 200px;
}

.logistics-line-detail {
  max-width: 260px;
}

.logistics-list-table {
  font-size: 12px;
  table-layout: fixed;
  width: 100%;
}

.logistics-list-table th,
.logistics-list-table td {
  overflow-wrap: anywhere;
  padding: 8px 6px;
  white-space: normal;
}

.logistics-list-table th:nth-child(1) { width: 7.5%; }
.logistics-list-table th:nth-child(2) { width: 10.5%; }
.logistics-list-table th:nth-child(3) { width: 11%; }
.logistics-list-table th:nth-child(4) { width: 8.5%; }
.logistics-list-table th:nth-child(5) { width: 12%; }
.logistics-list-table th:nth-child(6) { width: 8.5%; }
.logistics-list-table th:nth-child(7) { width: 15%; }
.logistics-list-table th:nth-child(8) { width: 7%; }
.logistics-list-table th:nth-child(9) { width: 7.5%; }
.logistics-list-table th:nth-child(10) { width: 12.5%; }

.logistics-list-table .logistics-line-detail {
  max-width: 100%;
}

.logistics-list-table .row-actions {
  gap: 4px;
}

.logistics-list-table .button,
.logistics-list-table button {
  font-size: 12px;
  min-height: 28px;
  padding: 4px 6px;
}

.issue-order-actions {
  align-items: center;
  gap: 6px;
}

.issue-order-actions .button,
.issue-order-actions button {
  min-height: 32px;
  padding: 5px 10px;
}

.issue-order-detail-row[hidden] {
  display: none;
}

.issue-order-detail-row > td {
  background: var(--surface);
  padding: 10px 12px 14px;
}

.issue-order-detail-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-left: 2px solid var(--line);
  border-radius: 6px;
  overflow: hidden;
}

.issue-order-detail-table {
  font-size: 11px;
  line-height: 1.45;
}

.issue-order-detail-table th,
.issue-order-detail-table td {
  overflow: hidden;
  padding: 7px 8px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.issue-order-detail-table th {
  background: var(--surface);
}

.issue-order-detail-table td {
  background: var(--panel);
}

.issue-order-detail-table tr:nth-child(even) td {
  background: var(--surface);
}

.document-main-row > td:not([data-col-type="actions"]) {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.document-actions {
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
  white-space: normal;
}

.document-status-cell {
  white-space: nowrap;
}

.document-processing-cell {
  overflow: visible !important;
  white-space: nowrap !important;
}

.document-actions .button,
.document-actions button {
  flex: 0 0 auto;
  font-size: 12px;
  min-height: 30px;
  padding: 4px 7px;
}

.document-actions form {
  flex: 0 0 auto;
  margin: 0;
}

.purchase-order-row-actions {
  flex-wrap: wrap;
}

.purchase-order-detail-table th,
.purchase-order-detail-table td {
  vertical-align: top;
}

.qualified-quantity-cell {
  white-space: nowrap;
}

.qualified-quantity-cell input {
  width: 120px;
}

.purchase-receipt-actions {
  align-items: flex-end;
  display: flex;
  flex-wrap: nowrap;
  gap: 8px;
  white-space: nowrap;
}

.purchase-receipt-actions input[name="quantity"] {
  width: 125px;
}

.purchase-receipt-actions input[name="notes"] {
  width: 150px;
}

.inline-number-field {
  align-items: flex-start;
  display: inline-flex;
  flex: 0 0 auto;
  flex-direction: column;
  gap: 2px;
}

.inline-number-field span {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.2;
}

.quality-inspection-table th,
.quality-inspection-table td {
  vertical-align: top;
}

.quality-row-actions {
  align-items: flex-start;
  display: flex;
  flex-wrap: nowrap;
  gap: 6px;
  white-space: nowrap;
}

.quality-row-actions form {
  flex: 0 0 auto;
  margin: 0;
}

.quality-material-row > td {
  border-top: 2px solid var(--line);
}

.quality-material-group-a.quality-material-row > td {
  background: var(--surface);
  border-top-color: var(--line);
}

.quality-material-group-b.quality-material-row > td {
  background: #ededf2;
  border-top-color: #b8b8bd;
}

.quality-material-extra-row > td {
  background: #ffffff;
  border-bottom: 9px solid #f2f5f8;
}

.quality-material-row-standalone > td {
  border-bottom: 9px solid #f2f5f8;
}

.document-detail-row[hidden] {
  display: none;
}

.document-detail-row > td {
  background: var(--surface);
  padding: 10px 12px 14px;
}

.document-detail-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-left: 2px solid var(--line);
  border-radius: 6px;
  overflow: hidden;
}

.document-detail-table {
  font-size: 12px;
}

.document-detail-table th,
.document-detail-table td {
  overflow: hidden;
  padding: 8px 10px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.document-detail-table th {
  background: var(--surface);
}

.document-detail-table td {
  background: var(--panel);
}

.clip-cell {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.alert {
  border-radius: 6px;
  margin-bottom: 14px;
  padding: 10px 12px;
}

.alert.success {
  background: #ecfdf3;
  color: #027a48;
}

.alert.warn {
  background: #fffaeb;
  color: #b54708;
}

.alert.error {
  background: #fef3f2;
  color: var(--danger);
}

.login-page {
  align-items: center;
  display: flex;
  justify-content: center;
  min-height: 100dvh;
  padding: 24px;
}

.login-box {
  max-width: 360px;
  padding: 32px 0;
  width: 100%;
}

.login-box h1 {
  margin: 20px 0 8px;
  font-size: 30px;
  text-align: center;
}

.login-box > .muted {
  text-align: center;
}

.login-mark {
  width: 56px;
  height: 56px;
  font-size: 22px;
  background: #1d1d1f;
  color: white;
  margin: 0 auto;
  display: flex;
}

.login-box form {
  margin-top: 32px;
}

.login-box .field + .field {
  margin-top: 18px;
}

.login-box .form-actions button {
  width: 100%;
  min-height: 44px;
  margin-top: 8px;
}

.login-box .alert {
  margin-top: 20px;
}

:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 3px;
}

input:focus,
select:focus,
textarea:focus {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
  border-color: var(--brand);
}

input:disabled,
select:disabled,
textarea:disabled {
  background: #ededf2;
  color: var(--muted);
}

button:disabled,
.button[aria-disabled="true"] {
  opacity: 0.5;
  cursor: not-allowed;
}

button.danger:hover,
.button.danger:hover {
  background: #941e16;
}

td a:not(.button) {
  color: var(--brand-dark);
}

td a:not(.button):hover {
  text-decoration: underline;
}

button.icon-button {
  align-items: center;
  background: transparent;
  border-color: transparent;
  color: var(--text);
  flex: 0 0 36px;
  width: 36px;
  height: 36px;
  padding: 8px;
}

button.icon-button:hover {
  background: rgba(128, 128, 128, 0.14);
}

.navigation-toggle,
.sidebar-close,
.navigation-backdrop {
  display: none !important;
}

@media (min-width: 1200px) {
  form.panel[method="get"] .form-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

@media (max-width: 900px) {
  .dashboard-workbench-grid {
    grid-template-columns: 1fr;
  }

  .app-shell {
    grid-template-columns: minmax(0, 1fr);
  }

  .sidebar {
    position: fixed;
    left: 0;
    bottom: 0;
    width: min(300px, calc(100vw - 48px));
    transform: translateX(-100%);
    visibility: hidden;
    transition: transform 160ms ease, visibility 160ms ease;
  }

  .navigation-open .sidebar {
    transform: translateX(0);
    visibility: visible;
    transition-property: transform;
  }

  .navigation-open {
    overflow: hidden;
  }

  .navigation-toggle,
  .sidebar-close {
    display: inline-flex !important;
  }

  .navigation-backdrop:not([hidden]) {
    background: rgba(0, 0, 0, 0.32);
    display: block !important;
    position: fixed;
    inset: 0;
    z-index: 55;
  }

  .form-grid,
  .form-grid.compact,
  .production-order-filter-row {
    grid-template-columns: 1fr;
  }

  .stat-grid {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }

  .role-permission-row {
    grid-template-columns: 1fr;
  }

  .topbar {
    padding: 0 14px;
  }

  .content {
    padding: 24px 16px;
  }

  .account-name {
    max-width: 112px;
  }

  .table-wrap {
    width: 100%;
  }

  .page-head > .actions {
    flex-wrap: wrap;
    overflow: visible;
    white-space: normal;
  }

  .order-batch-actions,
  .production-order-batch-actions {
    justify-content: flex-start;
  }

  .form-actions {
    justify-content: flex-start;
  }

  .button,
  button,
  .nav-link,
  .nav-title,
  button.icon-button {
    min-height: 44px;
  }

  button.icon-button {
    flex-basis: 44px;
    height: 44px;
    width: 44px;
  }

  .lookup-panel {
    min-width: min(620px, calc(100vw - 48px));
  }
}

@media (max-width: 560px) {
  .stat-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .stat {
    padding: 14px 16px;
  }

  .topbar {
    gap: 8px;
    padding: 6px 10px;
  }

  .topbar-heading,
  .account-menu {
    gap: 6px;
  }

  .workspace-name {
    font-size: 12px;
  }

  .account-name {
    max-width: 84px;
  }

  .summary-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .summary-cell,
  .other-inventory-detail-grid > * {
    overflow-wrap: anywhere;
  }

  h1 {
    font-size: 24px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition: none !important;
    scroll-behavior: auto !important;
  }
}
