:root {
  --nav-bg: #425164;
  --nav-bg-deep: #394656;
  --panel-bg: #ffffff;
  --page-bg: #f3f4f7;
  --line: #e8edf3;
  --line-strong: #dfe5ed;
  --text: #2f4259;
  --muted: #8c97a7;
  --primary: #3b82f6;
  --primary-soft: #edf4ff;
  --orange: #f0a33a;
  --danger: #ef5b5b;
  --shadow: 0 16px 30px rgba(31, 45, 61, 0.08);
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 10px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Noto Sans SC", sans-serif;
  background: var(--page-bg);
  color: var(--text);
}

button,
input {
  font: inherit;
}

.erp-shell {
  display: grid;
  grid-template-columns: 144px 1fr;
  min-height: 100vh;
}

.global-nav {
  background: var(--nav-bg);
  color: #fff;
  padding: 12px 0;
  display: flex;
  flex-direction: column;
  align-items: stretch;
}

.avatar {
  width: 30px;
  height: 30px;
  margin: 0 0 12px 10px;
  border-radius: 999px;
  background: linear-gradient(135deg, #9ccf62, #3f7f30);
  display: grid;
  place-items: center;
  font-size: 12px;
  font-weight: 700;
}

.nav-list {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 0 6px;
}

.nav-item {
  border: none;
  background: transparent;
  color: #fff;
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 11px 10px;
  border-radius: 6px;
  cursor: pointer;
  text-align: left;
  font-weight: 600;
}

.nav-item.active {
  background: #607185;
}

.nav-icon {
  width: 16px;
  display: inline-grid;
  place-items: center;
  color: #fff;
  opacity: 0.95;
}

.nav-icon-green,
.nav-icon-orange,
.nav-icon-dark {
  width: 18px;
  height: 18px;
  border-radius: 4px;
}

.nav-icon-green {
  background: #8ecf4d;
}

.nav-icon-orange {
  background: #f3b13d;
}

.nav-icon-dark {
  background: #000;
}

.nav-badge {
  margin-left: auto;
  min-width: 18px;
  padding: 0 5px;
  height: 18px;
  border-radius: 999px;
  background: #ef4d4d;
  font-size: 11px;
  line-height: 18px;
  text-align: center;
}

.nav-divider {
  height: 1px;
  margin: 10px 8px;
  background: rgba(255, 255, 255, 0.16);
}

.nav-footer {
  margin-top: auto;
  display: flex;
  justify-content: space-around;
  padding: 10px 6px 0;
}

.nav-mini {
  width: 24px;
  height: 24px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: #fff;
  cursor: pointer;
}

.workspace {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.topbar {
  height: 38px;
  padding: 0 14px;
  background: var(--nav-bg);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.topbar-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
}

.topbar-mark {
  width: 14px;
  height: 14px;
  border-radius: 3px;
  background: #f1b249;
}

.topbar-actions {
  display: flex;
  gap: 10px;
}

.topbar-icon {
  border: none;
  background: transparent;
  color: #fff;
  cursor: pointer;
  opacity: 0.95;
}

.workspace-body {
  display: grid;
  grid-template-columns: 286px 1fr;
  gap: 10px;
  padding: 10px 10px 14px 10px;
  min-height: calc(100vh - 38px);
}

.warehouse-sidebar,
.content-area {
  min-width: 0;
}

.warehouse-card,
.filter-bar,
.table-panel {
  background: var(--panel-bg);
  box-shadow: var(--shadow);
}

.warehouse-card {
  height: 100%;
  border-radius: var(--radius-lg);
  margin: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.warehouse-top-gap {
  height: 8px;
  flex: 0 0 auto;
}

.warehouse-card-body {
  flex: 1 1 auto;
  padding: 0 6px 6px 8px;
  overflow: auto;
}

.warehouse-bottom-gap {
  height: 14px;
  flex: 0 0 auto;
}

.warehouse-tree {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.warehouse-node {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.warehouse-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 34px;
  padding: 7px 10px 7px 12px;
  border-radius: var(--radius-sm);
  font-size: 14px;
}

.warehouse-row.level-0 {
  padding-left: 12px;
}

.warehouse-row.level-1 {
  padding-left: 28px;
}

.warehouse-row.level-2 {
  padding-left: 44px;
}

.warehouse-row.active {
  background: transparent;
  color: var(--text);
  font-weight: 500;
}

.warehouse-item {
  width: 100%;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 22px;
  align-items: center;
  gap: 12px;
  min-height: 38px;
  padding: 8px 10px 8px 50px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  text-align: left;
  position: relative;
  color: var(--text);
}

.warehouse-main {
  border: none;
  background: transparent;
  width: 100%;
  min-width: 0;
  padding: 0;
  display: block;
  text-align: left;
  color: inherit;
  cursor: pointer;
}

.warehouse-item.level-2 {
  padding-left: 66px;
}

.warehouse-item.active {
  background: #f0f3f7;
}

.warehouse-label {
  display: block;
  min-width: 0;
  position: relative;
  width: 100%;
  padding-right: 20px;
}

.warehouse-alert-indicator {
  width: 16px;
  height: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  position: absolute;
  right: 4px;
  top: 50%;
  transform: translateY(-50%);
  color: #d96b1d;
  pointer-events: none;
}

.warehouse-alert-indicator svg {
  width: 16px;
  height: 16px;
  display: block;
}

.tree-toggle {
  border: none;
  background: transparent;
  padding: 0;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  color: inherit;
  cursor: pointer;
}

.warehouse-arrow {
  color: #616d7d;
  font-size: 11px;
  display: inline-block;
  transition: transform 0.16s ease;
}

.warehouse-arrow.expanded {
  transform: rotate(0deg);
}

.warehouse-arrow:not(.expanded) {
  transform: rotate(-90deg);
}

.warehouse-name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.warehouse-actions {
  position: relative;
  width: 22px;
  min-width: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.dots-button,
.plus-button {
  border: none;
  background: transparent;
  color: #6d7786;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.plus-button {
  width: 20px;
  height: 20px;
  padding: 0;
  line-height: 1;
  font-size: 14px;
}

.dots-button {
  width: 22px;
  height: 22px;
  padding: 0;
  gap: 3px;
  border-radius: 999px;
}

.dots-button span {
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.88;
}

.dots-button:hover,
.plus-button:hover {
  background: rgba(59, 130, 246, 0.08);
}

.more-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: -6px;
  min-width: 92px;
  background: #fff;
  border: 1px solid #e6ebf2;
  border-radius: 10px;
  box-shadow: 0 12px 24px rgba(49, 61, 78, 0.12);
  z-index: 20;
  overflow: hidden;
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.menu-item {
  display: flex;
  align-items: center;
  width: 100%;
  border: none;
  background: #fff;
  min-height: 30px;
  padding: 0 10px;
  border-radius: 7px;
  text-align: left;
  cursor: pointer;
  color: #58677a;
  font-size: 13px;
  line-height: 1;
}

.menu-item:hover {
  background: #f4f7fb;
}

.menu-item.primary {
  color: #58677a;
  font-weight: 400;
}

.content-area {
  display: flex;
  flex-direction: column;
  gap: 0;
  padding: 0 0 0 0;
}

.content-top-gap {
  height: 0;
  flex: 0 0 auto;
}

.content-card {
  background: var(--panel-bg);
  box-shadow: var(--shadow);
  border-radius: var(--radius-lg);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
}

.filter-bar {
  min-height: 62px;
  padding: 12px 18px 0;
  display: flex;
  align-items: center;
  gap: 14px;
  background: transparent;
  box-shadow: none;
  border-radius: 0;
}

.search-box {
  width: 256px;
  height: 34px;
  border: 1px solid #d4dbe5;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 10px;
}

.search-box input {
  border: none;
  outline: none;
  width: 100%;
  color: var(--text);
}

.search-box input::placeholder {
  color: #a0a9b5;
}

.search-icon {
  color: #7a8798;
}

.checkbox-line {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: #778396;
  font-size: 14px;
}

.table-panel {
  display: flex;
  flex-direction: column;
  min-height: 0;
  flex: 1 1 auto;
  overflow: hidden;
  background: transparent;
  box-shadow: none;
  border-radius: 0;
}

.table-wrap {
  overflow: auto;
  padding: 12px 10px 0 10px;
}

table {
  width: max-content;
  min-width: 100%;
  border-collapse: collapse;
  table-layout: auto;
}

th,
td {
  border: 1px solid #edf1f6;
  height: 46px;
  padding: 10px 12px;
  font-size: 14px;
  color: #4d5e73;
  vertical-align: middle;
  background: #fff;
}

th {
  background: #eff3f7;
  font-weight: 500;
  color: #394b62;
  text-align: left;
}

td:first-child a,
.product-link {
  color: #2d73ff;
  text-decoration: none;
}

.table-panel th:nth-child(1),
.table-panel th:nth-child(2),
.table-panel td:nth-child(1),
.table-panel td:nth-child(2) {
  width: 1%;
  white-space: nowrap;
}

.numeric {
  text-align: right;
}

.stock-cell {
  min-width: 150px;
}

.stock-value {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.transit-chip {
  position: relative;
  min-width: 18px;
  height: 20px;
  padding: 0 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: #edf4ff;
  color: #2b73e0;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}

.transit-popover {
  position: absolute;
  left: 50%;
  bottom: calc(100% + 10px);
  transform: translateX(-50%) translateY(4px);
  min-width: 220px;
  padding: 10px;
  border-radius: 10px;
  background: rgba(43, 53, 68, 0.96);
  color: #fff;
  font-size: 12px;
  line-height: 1.4;
  box-shadow: 0 14px 28px rgba(24, 33, 48, 0.22);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.16s ease, transform 0.16s ease;
  z-index: 8;
}

.transit-chip:hover .transit-popover {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.transit-row {
  display: grid;
  grid-template-columns: 22px 1fr auto;
  align-items: center;
  gap: 8px;
  padding: 7px 8px;
  border-radius: 8px;
}

.transit-row + .transit-row {
  margin-top: 4px;
}

.transit-row.pending {
  background: rgba(240, 163, 58, 0.12);
}

.transit-row.approving {
  background: rgba(59, 130, 246, 0.14);
}

.transit-row.approved {
  background: rgba(62, 179, 126, 0.14);
}

.transit-icon {
  width: 22px;
  height: 22px;
  display: inline-grid;
  place-items: center;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
}

.transit-icon svg {
  width: 14px;
  height: 14px;
  display: block;
}

.transit-label {
  color: rgba(255, 255, 255, 0.88);
  white-space: nowrap;
}

.transit-qty {
  color: #fff;
  font-weight: 700;
  white-space: nowrap;
}

.type-tag,
.attr-tag,
.footer-tag,
.meta-pill,
.status-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
}

.type-tag {
  padding: 2px 8px;
  background: #f5f7fa;
  color: #6f7c8e;
  font-size: 12px;
}

.attr-tags {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.attr-tag {
  min-width: 34px;
  padding: 2px 8px;
  background: #f5f7fa;
  color: #5f7086;
  font-size: 12px;
  border-radius: 4px;
}

.attr-tag.link {
  color: #2d73ff;
}

.status-pill {
  padding: 5px 10px;
  font-size: 12px;
}

.status-empty {
  color: #7b8695;
  background: #f1f4f8;
}

.status-low {
  color: #b26d10;
  background: #fff1da;
}

.status-high {
  color: #c54b3f;
  background: #fde4e1;
}

.status-normal {
  color: #2f7d4e;
  background: #e6f7ec;
}

.table-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 62px;
  padding: 12px 16px 16px;
}

.footer-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #7c8897;
  font-size: 13px;
  flex-wrap: wrap;
}

.footer-tag,
.meta-pill {
  padding: 4px 8px;
  background: #f3f6fb;
  color: #627287;
  font-size: 12px;
}

.pagination {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

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

.page-btn {
  min-width: 34px;
  height: 32px;
  border: 1px solid #dfe5ed;
  border-radius: var(--radius-sm);
  background: #fff;
  color: #627287;
  cursor: pointer;
}

.page-btn.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

.page-btn[disabled] {
  opacity: 0.45;
  cursor: default;
}

.page-size {
  display: inline-flex;
  align-items: center;
  height: 32px;
  padding: 0 10px;
  border: 1px solid #dfe5ed;
  border-radius: var(--radius-sm);
  background: #fff;
  color: #627287;
  font-size: 13px;
}

.content-bottom-gap {
  height: 0;
  flex: 0 0 auto;
}

.hidden-trigger,
.hidden {
  display: none !important;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(27, 39, 53, 0.32);
  display: grid;
  place-items: center;
  z-index: 40;
}

.modal {
  width: min(1060px, calc(100vw - 60px));
  height: min(660px, calc(100vh - 70px));
  max-height: calc(100vh - 70px);
  background: #fff;
  border-radius: var(--radius-lg);
  box-shadow: 0 22px 40px rgba(20, 30, 41, 0.22);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 22px;
  border-bottom: 1px solid #eef2f7;
}

.modal-title-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.modal-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--primary);
}

.modal h3 {
  margin: 0;
  font-size: 18px;
}

.modal-subtitle {
  margin: 8px 0 0;
  color: #7b8697;
  font-size: 13px;
}

.modal-search-box {
  width: 320px;
  height: 34px;
  margin-top: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 11px;
  border: 1px solid #d6dce6;
  border-radius: var(--radius-sm);
  background: #fff;
}

.modal-search-box:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.12);
}

.modal-search-icon {
  color: #8c97a7;
  font-size: 15px;
  flex: 0 0 auto;
}

.modal-search-box input {
  width: 100%;
  min-width: 0;
  border: 0;
  outline: 0;
  color: #31455d;
  background: transparent;
}

.modal-search-box input::placeholder {
  color: #a7b0bf;
}

.close-button {
  border: none;
  background: transparent;
  font-size: 26px;
  color: #8590a0;
  cursor: pointer;
  line-height: 1;
}

.modal-table-wrap {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 0 10px 0;
  margin-top: 10px;
}

.modal-table-wrap::before {
  content: "";
  position: sticky;
  display: block;
  top: 0;
  height: 10px;
  margin: 0 -10px;
  background: #fff;
  z-index: 9;
}

.modal-table th {
  position: sticky;
  top: 10px;
  z-index: 8;
  background: #eef3f8;
  box-shadow: 0 1px 0 #dfe7f1;
  background-clip: padding-box;
}

.modal-table {
  width: 100%;
  table-layout: fixed;
}

.modal-col-select {
  width: 58px;
}

.modal-col-product {
  width: 20%;
}

.modal-col-stock {
  width: 10%;
}

.modal-col-upper,
.modal-col-lower {
  width: 34%;
}

.modal-table th,
.modal-table td {
  height: auto;
  padding: 12px 12px;
  vertical-align: top;
}

.bulk-header-cell {
  display: block;
  position: relative;
  background: #eef3f8;
}

.bulk-header {
  position: relative;
  min-height: 24px;
  background: #eef3f8;
}

.bulk-header-top {
  display: flex;
  align-items: center;
  gap: 8px;
}

.bulk-icon-btn {
  width: 22px;
  height: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid #cfd8e6;
  border-radius: 6px;
  background: #fff;
  color: #6f7d91;
  cursor: pointer;
  transition: all 0.2s ease;
}

.bulk-icon-btn svg {
  width: 14px;
  height: 14px;
}

.bulk-icon-btn.active {
  color: var(--primary);
  border-color: #bdd1ff;
  background: #edf4ff;
}

.bulk-field-panel {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  z-index: 6;
  padding: 10px 12px 12px;
  background: #edf2f7;
  border: 1px solid #dfe6ef;
  border-radius: 8px;
  box-shadow: 0 2px 6px rgba(31, 45, 61, 0.04);
}

.bulk-field-wrap {
  width: 100%;
}

.bulk-field-wrap input {
  max-width: none;
  background: #fff;
}

.modal-table td:first-child,
.modal-table td:nth-child(2),
.modal-table td:nth-child(3) {
  white-space: normal;
}

.bulk-select-header,
.bulk-select-cell {
  text-align: center;
}

.bulk-select-header {
  min-width: 34px;
  white-space: nowrap;
}

.bulk-select-cell {
  padding: 0;
}

.bulk-select-cell-inner {
  min-height: 74px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-product-name {
  color: #31455d;
  font-weight: 500;
  line-height: 1.5;
  word-break: break-word;
}

.product-type-row {
  margin-top: 6px;
}

.product-type-badge {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 0 8px;
  border-radius: 999px;
  font-size: 12px;
  line-height: 1;
  border: 1px solid transparent;
}

.product-type-badge.integer {
  color: #7a4f11;
  background: #fff4df;
  border-color: #f5d7a6;
}

.product-type-badge.decimal {
  color: #1e5bb8;
  background: #edf5ff;
  border-color: #c8dcfb;
}

.field-wrap {
  display: flex;
  flex-direction: column;
  gap: 4px;
  align-items: flex-start;
  width: 100%;
}

.field-wrap input {
  height: 34px;
  width: 100%;
  max-width: 320px;
  border: 1px solid #d6dce6;
  border-radius: var(--radius-sm);
  padding: 0 10px;
  outline: none;
}

.field-wrap input:focus {
  border-color: var(--primary);
}

.field-wrap input.invalid {
  border-color: var(--danger);
  background: #fff8f8;
}

.field-error {
  font-size: 12px;
}

.field-error {
  color: var(--danger);
}

.bulk-checkbox {
  position: relative;
  width: 16px;
  height: 16px;
  margin: 0 auto;
  flex: 0 0 16px;
}

.bulk-checkbox input {
  position: absolute;
  inset: 0;
  opacity: 0;
  margin: 0;
  cursor: pointer;
}

.bulk-checkbox.disabled input {
  cursor: not-allowed;
}

.bulk-checkbox span {
  display: block;
  width: 16px;
  height: 16px;
  border: 1px solid #cbd5e3;
  border-radius: 4px;
  background: #fff;
}

.bulk-checkbox input:checked + span {
  background: var(--primary);
  border-color: var(--primary);
  box-shadow: inset 0 0 0 3px #fff;
}

.bulk-checkbox.disabled span {
  background: #f2f4f8;
  border-color: #d9e0ea;
  opacity: 0.7;
}

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

.secondary-button,
.primary-button {
  min-width: 74px;
  height: 34px;
  border-radius: var(--radius-sm);
  cursor: pointer;
}

.secondary-button {
  border: 1px solid #d6dce6;
  background: #fff;
  color: #637386;
}

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

.toast {
  position: fixed;
  top: 56px;
  left: 50%;
  transform: translateX(-50%);
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  background: rgba(29, 39, 52, 0.94);
  color: #fff;
  z-index: 50;
  box-shadow: 0 10px 24px rgba(29, 39, 52, 0.18);
}

@media (max-width: 1180px) {
  .erp-shell {
    grid-template-columns: 88px 1fr;
  }

  .workspace-body {
    grid-template-columns: 240px 1fr;
  }

  .nav-item span:last-child:not(.nav-badge),
  .nav-item span:nth-child(2) {
    display: none;
  }
}

@media (max-width: 900px) {
  .workspace-body {
    grid-template-columns: 1fr;
  }

  .warehouse-sidebar {
    display: none;
  }

  .filter-bar,
  .table-panel {
    border-radius: 8px;
  }
}
