:root {
  --bg: #f5f6f8;
  --card: #ffffff;
  --line: #dde1e7;
  --text: #1f2937;
  --muted: #6b7280;
  --primary: #0f766e;
  --primary-soft: #dff3f0;
  --danger: #b91c1c;
  --radius: 12px;
  --space-xs: 6px;
  --space-sm: 10px;
  --space-md: 16px;
  --space-lg: 22px;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: "PingFang SC", "Microsoft YaHei", sans-serif;
  color: var(--text);
  background: radial-gradient(circle at top left, #ffffff, #eef1f5 45%, #e8edf2);
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-md) var(--space-lg);
  background: linear-gradient(120deg, #0f766e, #155e75);
  color: #fff;
  border-bottom: 1px solid rgba(255, 255, 255, 0.2);
}

.topbar h1 {
  margin: 0;
  font-size: 22px;
  letter-spacing: 0.3px;
}

.stats {
  font-size: 14px;
  opacity: 0.95;
}

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

.topbar-user {
  font-size: 13px;
  opacity: 0.92;
}

.topbar-logout {
  border-color: rgba(255, 255, 255, 0.35);
  background: rgba(255, 255, 255, 0.08);
  color: #ffffff;
}

.topbar-logout:hover {
  background: rgba(255, 255, 255, 0.16);
}

.app-shell {
  display: grid;
  grid-template-columns: clamp(172px, 15vw, 236px) minmax(0, 1fr);
  gap: var(--space-md);
  padding: var(--space-md);
  align-items: start;
}

.app-footer {
  padding: 0 var(--space-md) var(--space-md);
}

.app-footer-meta {
  display: flex;
  justify-content: flex-end;
  gap: 18px;
  font-size: 12px;
  color: var(--muted);
}

.auth-page {
  min-height: 100vh;
  display: grid;
  grid-template-rows: 1fr auto;
}

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

.auth-card {
  width: min(420px, 100%);
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 20px 48px rgba(15, 23, 42, 0.08);
}

.auth-card h1 {
  margin: 0 0 10px;
  font-size: 28px;
}

.auth-form {
  display: grid;
  gap: 10px;
  margin-top: 16px;
}

.auth-label {
  font-size: 14px;
  font-weight: 600;
}

.auth-footer-meta {
  justify-content: center;
}

.permission-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px 14px;
}

.permission-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
}

.permission-item input {
  width: auto;
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: var(--space-md);
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.03);
}

.nav-sidebar {
  position: sticky;
  top: var(--space-md);
}

.nav-sidebar h2 {
  margin: 0 0 var(--space-sm);
  font-size: 18px;
}

.nav-group {
  border-top: 1px solid var(--line);
  padding-top: var(--space-sm);
  margin-top: var(--space-sm);
}

.nav-level1 {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: var(--space-xs);
  font-weight: 600;
}

.nav-level2 {
  display: block;
  text-decoration: none;
  color: var(--text);
  font-size: 14px;
  white-space: nowrap;
  padding: 8px 10px;
  border-radius: 8px;
  margin: 4px 0;
  transition: background 0.2s ease;
}

.nav-level2:hover,
.nav-level2.active {
  background: var(--primary-soft);
  color: #0b5f59;
}

.content-column {
  min-height: calc(100vh - 120px);
}

.content-page {
  display: none;
}

.content-page.active {
  display: block;
  animation: pageFade 0.18s ease;
}

@keyframes pageFade {
  from {
    opacity: 0.45;
    transform: translateY(4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

h2 {
  margin: 0 0 12px;
  font-size: 18px;
}

.mt12 {
  margin-top: 12px;
}

.row {
  display: grid;
  grid-template-columns: 88px 1fr;
  gap: 8px;
  align-items: center;
  margin-bottom: 8px;
}

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

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  background: #fff;
}

.picker-trigger {
  width: 100%;
  justify-content: flex-start;
  border-color: var(--line);
  background: #fff;
  color: var(--text);
  text-align: left;
  min-height: 42px;
}

.picker-trigger.placeholder {
  color: var(--muted);
}

button {
  border: 1px solid var(--primary);
  background: var(--primary);
  color: #fff;
  border-radius: 8px;
  padding: 8px 14px;
  cursor: pointer;
}

button:hover {
  filter: brightness(0.95);
}

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

button.ghost {
  border-color: var(--line);
  background: #fff;
  color: var(--text);
}

.button-row {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

#editSelectedProductBtn:disabled {
  border-color: #d1d5db;
  background: #e5e7eb;
  color: #6b7280;
  cursor: not-allowed;
  filter: none;
}

.category-layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

.category-action-zone,
.category-tree-zone {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px;
  background: #fcfdff;
}

.category-tree-zone h3 {
  margin: 0 0 8px;
  font-size: 15px;
}

.action-tabs {
  display: flex;
  gap: 8px;
  margin-top: 10px;
  margin-bottom: 10px;
}

.action-tab {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
}

.action-tab.danger {
  border-color: #fecaca;
  background: #fff5f5;
  color: #991b1b;
}

.action-tab.active {
  border-color: var(--primary);
  background: var(--primary-soft);
  color: #0b5f59;
}

.action-tab.danger.active {
  border-color: var(--danger);
  background: #fee2e2;
  color: #7f1d1d;
}

.action-panel {
  display: none;
}

.action-panel.active {
  display: block;
}

.action-tab:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

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

.checkbox input {
  width: auto;
}

.product-detail-shell {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 14px;
  align-items: start;
}

.product-media-col,
.product-form-col {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fcfdff;
  padding: 10px;
}

.product-form-col .row {
  grid-template-columns: 96px 1fr;
}

.detail-section {
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 10px;
  margin-bottom: 10px;
  background: #fff;
}

.detail-section h3 {
  margin: 0 0 10px;
  font-size: 15px;
}

.field-col {
  width: 100%;
}

.field-error {
  min-height: 16px;
  margin-top: 4px;
  color: #b91c1c;
  font-size: 12px;
  line-height: 1.2;
}

.bom-editor {
  margin-top: 8px;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 10px;
  background: #fff;
}

.bom-input-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 8px;
}

#bomItemsBody .button-row button {
  padding: 4px 8px;
  font-size: 12px;
}

.product-image-panel {
  display: block;
  margin: 8px 0 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px;
  background: #fbfcfd;
}

.product-main-image-wrap {
  height: 240px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  position: relative;
}

.product-main-image {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: none;
}

.product-main-image.show {
  display: block;
}

.product-image-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.28);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  line-height: 1;
  z-index: 2;
}

.product-image-nav:hover {
  background: rgba(15, 23, 42, 0.42);
  filter: none;
}

.product-image-nav.prev {
  left: 10px;
}

.product-image-nav.next {
  right: 10px;
}

.product-image-nav:disabled {
  opacity: 0.28;
  cursor: not-allowed;
}

#productMainImageHint {
  position: absolute;
}

.product-thumbs {
  grid-template-columns: repeat(4, minmax(60px, 1fr));
  margin-top: 10px;
}

.product-thumbs .image-card {
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.product-thumbs .image-card.active {
  border-color: #0f766e;
  box-shadow: 0 0 0 1px #0f766e inset;
}

.product-thumbs .image-card img {
  height: 56px;
}

.product-thumbs .image-card button {
  margin-top: 4px;
  padding: 4px;
}

.image-card-actions {
  display: grid;
  gap: 4px;
}

.tree {
  list-style: none;
  margin: 0;
  padding: 0;
}

.tree-item {
  padding: 6px 8px;
  border-radius: 6px;
  cursor: pointer;
  margin: 2px 0;
  display: flex;
  align-items: center;
  gap: 8px;
  position: relative;
  overflow: visible;
}

.tree-item-label {
  flex: 1;
  min-width: 0;
}

.tree-item-quick-actions {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
}

#categoryTree .tree-item .tree-item-quick-actions-bubble {
  position: absolute;
  left: var(--bubble-x, calc(100% - 26px));
  top: var(--bubble-y, 10px);
  transform: translate(-50%, calc(-100% - 10px));
  margin-left: 0;
  padding: 4px;
  border: 1px solid #8fd2ca;
  border-radius: 999px;
  background: #ffffff;
  box-shadow: 0 8px 18px rgba(15, 23, 42, 0.14);
  z-index: 6;
  animation: treeBubblePop 0.16s ease;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.12s ease;
}

#categoryTree .tree-item .tree-item-quick-actions-bubble[data-bubble-visible="1"] {
  opacity: 1;
  pointer-events: auto;
}

#categoryTree .tree-item .tree-item-quick-actions-bubble::after {
  content: "";
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  top: 100%;
  border: 6px solid transparent;
  border-top-color: #8fd2ca;
}

#categoryTree .tree-item .tree-item-quick-actions-bubble::before {
  content: "";
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  top: calc(100% - 1px);
  border: 6px solid transparent;
  border-top-color: #ffffff;
  z-index: 1;
}

@keyframes treeBubblePop {
  from {
    opacity: 0;
    transform: translateY(3px) scale(0.96);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.tree-quick-edit-btn {
  border: 1px solid #0f766e;
  background: #ffffff;
  color: #0f766e;
  border-radius: 5px;
  padding: 2px 8px;
  font-size: 11px;
  line-height: 1.2;
}

.tree-quick-edit-btn:hover {
  background: #ecfdf5;
}

.tree-sign {
  display: inline-flex;
  width: 16px;
  justify-content: center;
  font-weight: 700;
  color: #0b5f59;
}

.tree-sign.empty {
  color: #9ca3af;
}

.tree-products {
  list-style: none;
  margin: 2px 0 6px;
  padding: 0;
}

.tree-product-item {
  margin: 6px 0 6px 24px;
  padding: 8px;
  border-left: 2px solid #d9f3f0;
  border-radius: 4px;
  color: #334155;
  font-size: 13px;
  background: #ffffff;
  cursor: pointer;
  transition: border-color 0.15s ease, background-color 0.15s ease;
}

.tree-product-item:hover {
  border-left-color: #7ccfc8;
  background: #f8fcfc;
}

.tree-product-item.active {
  border-left-color: #0f766e;
  background: #e9f8f6;
}

.recycle-product-item {
  cursor: default;
}

.tree-product-main {
  display: grid;
  grid-template-columns: 88px 1fr;
  gap: 10px;
  align-items: start;
}

.tree-product-media {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.tree-product-thumb {
  width: 84px;
  height: 84px;
  object-fit: cover;
  border: 1px solid var(--line);
  border-radius: 6px;
}

.tree-product-no-image {
  width: 84px;
  height: 84px;
  border: 1px dashed var(--line);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: 12px;
}

.tree-product-title {
  font-weight: 600;
  color: #111827;
}

.tree-product-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
}

.tree-product-edit-btn {
  border: 1px solid #0f766e;
  background: #ffffff;
  color: #0f766e;
  border-radius: 6px;
  padding: 3px 10px;
  font-size: 12px;
  line-height: 1.2;
}

.tree-product-edit-btn:hover {
  background: #ecfdf5;
}

.tree-product-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 4px 10px;
}

.tree-product-grid div {
  word-break: break-all;
}

.packaging-machine-card {
  cursor: default;
}

.packaging-machine-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.packaging-machine-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
}

.packaging-machine-field {
  display: grid;
  gap: 6px;
}

.packaging-machine-field span {
  font-size: 12px;
  color: var(--muted);
}

.production-zone-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 12px;
}

.production-zone-card {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fbfcfd;
  padding: 12px;
}

.production-zone-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.production-zone-head h3 {
  margin: 0;
  font-size: 16px;
}

.production-machine-list {
  display: grid;
  gap: 10px;
}

.production-machine-card {
  border: 1px solid #d7ebe8;
  border-radius: 10px;
  background: #f4fbfa;
  padding: 12px;
}

.production-machine-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.production-machine-code {
  font-weight: 700;
  color: #0f766e;
}

.production-machine-mold {
  font-size: 15px;
  font-weight: 600;
  color: #111827;
  word-break: break-all;
}

.assembly-machine-board {
  position: relative;
  min-height: 320px;
  overflow: auto;
  border: 1px dashed #d7ebe8;
  border-radius: 12px;
  background:
    linear-gradient(90deg, rgba(15, 118, 110, 0.04) 1px, transparent 1px),
    linear-gradient(rgba(15, 118, 110, 0.04) 1px, transparent 1px),
    #fbfcfd;
  background-size: 24px 24px;
}

.assembly-machine-card {
  position: absolute;
  width: 190px;
  min-height: 108px;
  padding: 8px;
  border-radius: 12px;
  border: 1px solid #b9d8d3;
  background: rgba(219, 244, 239, 0.96);
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.08);
  cursor: grab;
  user-select: none;
}

.assembly-machine-card.is-disabled {
  background: rgba(229, 231, 235, 0.96);
  border-color: #d1d5db;
  color: #6b7280;
}

.assembly-machine-card.dragging {
  cursor: grabbing;
  box-shadow: 0 16px 36px rgba(15, 23, 42, 0.16);
  z-index: 3;
}

.assembly-machine-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
}

.assembly-machine-name-wrap {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 6px;
}

.assembly-machine-name {
  font-size: 15px;
  font-weight: 700;
  color: #0f172a;
  word-break: break-all;
}

.assembly-machine-rename-btn {
  width: 24px;
  min-width: 24px;
  height: 24px;
  min-height: 24px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
}

.assembly-machine-rename-icon {
  width: 14px;
  height: 14px;
  fill: currentColor;
}

.assembly-machine-card.is-disabled .assembly-machine-name {
  color: #6b7280;
}

.assembly-machine-field {
  display: grid;
  gap: 6px;
}

.assembly-machine-field span {
  font-size: 12px;
  color: #475569;
}

.assembly-machine-card.is-disabled .assembly-machine-field span {
  color: #6b7280;
}

.assembly-machine-product-row {
  display: grid;
  gap: 6px;
}

.assembly-machine-product-picker-btn {
  width: fit-content;
  min-height: 28px;
  padding: 4px 10px;
  font-size: 12px;
}

.assembly-machine-product-name {
  font-size: 13px;
  font-weight: 600;
  color: #0f172a;
  word-break: break-all;
}

.assembly-machine-card.is-disabled .assembly-machine-product-name {
  color: #6b7280;
}

.assembly-product-picker-products {
  list-style: none;
  margin: 6px 0 0;
  padding: 0 0 0 16px;
  display: grid;
  gap: 6px;
}

.assembly-product-picker-item {
  margin-top: 0;
  padding: 8px 10px;
}

.assembly-machine-switch {
  position: relative;
  width: 44px;
  height: 24px;
  display: inline-flex;
  align-items: center;
}

.assembly-machine-switch input {
  opacity: 0;
  width: 0;
  height: 0;
  position: absolute;
}

.assembly-machine-switch-track {
  position: relative;
  width: 44px;
  height: 24px;
  border-radius: 999px;
  background: #cbd5e1;
  transition: background 0.2s ease;
}

.assembly-machine-switch-track::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.2);
  transition: transform 0.2s ease;
}

.assembly-machine-switch input:checked + .assembly-machine-switch-track {
  background: #0f766e;
}

.assembly-machine-switch input:checked + .assembly-machine-switch-track::after {
  transform: translateX(20px);
}

.tree-item:hover,
.tree-item.active {
  background: #d9f3f0;
}

.tree-item.drag-target {
  background: #d7f4ef;
  box-shadow: 0 0 0 1px #0f766e inset;
}

.tree-item.dragging-category {
  opacity: 0.55;
}

.tree-item.drag-target-before,
.tree-item.drag-target-after {
  background: #eefcf9;
  box-shadow: 0 0 0 1px rgba(15, 118, 110, 0.18) inset;
}

.tree-item.drag-target-before {
  border-top: 3px solid #0f766e;
}

.tree-item.drag-target-after {
  border-bottom: 3px solid #0f766e;
}

.tree-product-item.dragging {
  opacity: 0.55;
  border-left-color: #0f766e;
  background: #eefcf9;
}

.tree-product-item.drag-target-before,
.tree-product-item.drag-target-after {
  background: #eefcf9;
  box-shadow: 0 0 0 1px rgba(15, 118, 110, 0.18) inset;
}

.tree-product-item.drag-target-before {
  border-top: 3px solid #0f766e;
}

.tree-product-item.drag-target-after {
  border-bottom: 3px solid #0f766e;
}

.filter-grid {
  display: grid;
  grid-template-columns: 1fr 220px 100px;
  gap: 8px;
}

.material-filter-grid {
  grid-template-columns: 1fr 220px 100px;
}

.material-price-editor {
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  background: #fcfdff;
  padding: 10px;
}

.boom-base-layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  align-items: start;
}

.boom-base-tree-zone {
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  background: #fcfdff;
  padding: 10px;
}

.boom-base-tree-zone h3 {
  margin: 0;
  font-size: 15px;
}

.result-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 8px;
}

.result-card {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fbfcfd;
  padding: 10px;
}

.result-label {
  color: var(--muted);
  font-size: 12px;
}

.result-value {
  margin-top: 4px;
  font-size: 15px;
  font-weight: 600;
  color: #0f172a;
  word-break: break-all;
}

.line-editor {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) 120px 120px 100px;
  gap: 8px;
  align-items: center;
}

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

.table-wrap {
  width: 100%;
  overflow-x: auto;
}

th,
td {
  border-bottom: 1px solid var(--line);
  text-align: left;
  padding: 8px;
  vertical-align: top;
}

th {
  font-weight: 600;
  font-size: 14px;
}

td {
  font-size: 14px;
}

.thumb {
  width: 60px;
  height: 60px;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid var(--line);
}

.pager {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 10px;
}

.image-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  gap: 8px;
  margin-top: 10px;
}

.image-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 6px;
}

.image-card img {
  width: 100%;
  height: 90px;
  object-fit: cover;
  border-radius: 4px;
}

.image-card button {
  width: 100%;
  margin-top: 6px;
  font-size: 12px;
}

.hint {
  color: var(--muted);
  font-size: 13px;
}

.toast {
  position: fixed;
  right: 16px;
  bottom: 16px;
  background: #111827;
  color: #fff;
  padding: 8px 12px;
  border-radius: 8px;
  opacity: 0;
  transform: translateY(20px);
  transition: 0.2s ease;
}

.toast.show {
  opacity: 0.95;
  transform: translateY(0);
}

.move-loading-overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(15, 23, 42, 0.22);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease;
  z-index: 40;
}

.move-loading-overlay.show {
  opacity: 1;
  pointer-events: auto;
}

.move-loading-card {
  min-width: 180px;
  display: grid;
  justify-items: center;
  gap: 10px;
  padding: 16px 20px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 16px 36px rgba(15, 23, 42, 0.16);
  color: #0f172a;
}

.move-loading-spinner {
  width: 34px;
  height: 34px;
  border-radius: 999px;
  border: 3px solid #cbd5e1;
  border-top-color: var(--primary);
  animation: moveSpin 0.72s linear infinite;
}

@keyframes moveSpin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

.category-action-modal {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(15, 23, 42, 0.25);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease;
  z-index: 30;
}

#boomBaseLinkedProductsModal {
  z-index: 36;
}

.category-action-modal.show {
  opacity: 1;
  pointer-events: auto;
}

.category-action-dialog {
  width: min(520px, 100%);
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  padding: 14px;
  box-shadow: 0 12px 28px rgba(15, 23, 42, 0.14);
  transform: translateY(16px) scale(0.98);
  transition: transform 0.18s ease;
}

.boom-base-item-dialog {
  width: min(760px, 100%);
}

.product-form-modal-dialog {
  width: min(1220px, 100%);
  max-height: calc(100vh - 32px);
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 12px;
  overflow: hidden;
}

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

.product-form-modal-head h3 {
  margin: 0;
}

.product-form-modal-body {
  overflow: auto;
  min-height: 0;
}

.product-form-modal-body > .content-page {
  display: block;
  margin: 0;
  box-shadow: none;
}

.category-action-modal.show .category-action-dialog {
  transform: translateY(0) scale(1);
}

.category-action-dialog h3 {
  margin: 0 0 8px;
  font-size: 18px;
}

.product-category-move-tree {
  max-height: 420px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px;
  background: #fbfcfd;
}

.boom-base-picker-item {
  width: 100%;
  display: grid;
  gap: 2px;
  justify-items: start;
  text-align: left;
  border: 1px solid #dbe4ea;
  background: #fff;
  color: var(--text);
  margin-top: 6px;
}

.boom-base-picker-item-name {
  font-weight: 600;
}

.boom-base-picker-item-meta {
  font-size: 12px;
  color: var(--muted);
}

.boom-base-picker-item.active {
  border-color: var(--primary);
  background: #eefcf9;
  color: #0f172a;
}

.boom-base-picker-item.scrapped,
.boom-base-item-row.scrapped {
  opacity: 0.55;
  color: #6b7280;
}

.boom-base-picker-item.scrapped {
  border-color: #d1d5db;
  background: #f3f4f6;
}

.boom-base-picker-item.scrapped.active {
  border-color: #d1d5db;
  background: #f3f4f6;
}

#categoryAddModeRow button.active,
#boomCategoryAddModeRow button.active {
  border-color: var(--primary);
  background: var(--primary-soft);
  color: #0b5f59;
}

@media (max-width: 1080px) {
  .app-shell {
    grid-template-columns: 1fr;
    padding: 12px;
    gap: 12px;
  }

  .nav-sidebar {
    position: static;
  }

  .content-column {
    min-height: auto;
  }

  .app-footer-meta {
    justify-content: flex-start;
    flex-wrap: wrap;
  }
}

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

  .topbar {
    padding: 12px;
  }

  .topbar {
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
  }

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

  .stats {
    font-size: 12px;
  }

  .topbar-actions {
    width: 100%;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 8px;
  }

  .topbar-logout {
    margin-left: auto;
  }

  .card {
    padding: 12px;
    border-radius: 10px;
  }

  .action-tabs {
    flex-wrap: wrap;
  }

  .action-tab {
    flex: 1 1 calc(50% - 8px);
    text-align: center;
    justify-content: center;
  }

  .button-row > button {
    min-height: 40px;
  }

  .filter-grid {
    grid-template-columns: 1fr;
  }

  .line-editor {
    grid-template-columns: 1fr;
  }

  .bom-input-grid {
    grid-template-columns: 1fr;
  }

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

  .category-layout {
    grid-template-columns: 1fr;
  }

  .boom-base-layout {
    grid-template-columns: 1fr;
  }

  .tree-product-main {
    grid-template-columns: 1fr;
  }

  .tree-product-item {
    margin-left: 12px;
  }

  .tree-product-media {
    flex-direction: row;
    align-items: center;
  }

  .tree-product-head {
    flex-direction: column;
    align-items: flex-start;
  }

  .tree-product-head .button-row {
    width: 100%;
  }

  .tree-product-head .button-row .tree-product-edit-btn {
    flex: 1 1 auto;
    text-align: center;
  }

  .tree-product-grid {
    grid-template-columns: 1fr;
  }

  .product-detail-shell {
    grid-template-columns: 1fr;
  }

  .product-main-image-wrap {
    height: 220px;
  }

  .product-image-nav {
    width: 32px;
    height: 32px;
    font-size: 20px;
  }

  .product-thumbs {
    grid-template-columns: repeat(3, minmax(60px, 1fr));
  }

  .category-action-modal {
    padding: 8px;
  }

  .category-action-dialog {
    width: 100%;
    max-height: calc(100vh - 16px);
    overflow: auto;
  }

  .product-form-modal-dialog {
    width: 100%;
    max-height: calc(100vh - 16px);
    border-radius: 10px;
  }

  .product-form-modal-head {
    position: sticky;
    top: 0;
    z-index: 1;
    background: #fff;
    padding-bottom: 8px;
  }

  .table-wrap {
    -webkit-overflow-scrolling: touch;
  }

  .table-wrap table {
    min-width: 680px;
  }

  th,
  td {
    padding: 7px;
    font-size: 13px;
  }

  .assembly-machine-board {
    min-height: 260px;
  }

  .assembly-machine-card {
    width: 164px;
    min-height: 98px;
    padding: 7px;
  }

  .app-footer {
    padding: 0 12px 12px;
  }

  .app-footer-meta {
    gap: 10px;
    font-size: 11px;
  }
}

@media (max-width: 480px) {
  .action-tab {
    flex-basis: 100%;
  }

  .product-thumbs {
    grid-template-columns: repeat(2, minmax(60px, 1fr));
  }

  .tree-quick-edit-btn {
    padding: 2px 6px;
  }
}
