:root {
  color-scheme: light;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --nav: #08213e;
  --nav-active: #2563eb;
  --border: #d8dee8;
  --muted: #64748b;
  --text: #172033;
  --bg: #f5f7fb;
  --panel: #ffffff;
  --primary: #2563eb;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  display: flex;
  min-height: 100vh;
  color: var(--text);
  background: var(--bg);
}

.sidebar {
  width: 128px;
  flex: 0 0 128px;
  background: var(--nav);
  color: white;
  padding: 18px 10px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 15px;
  font-weight: 700;
  margin-bottom: 28px;
}

.brand-icon {
  width: 28px;
  height: 28px;
  border: 2px solid white;
  display: grid;
  place-items: center;
}

nav {
  display: grid;
  gap: 10px;
}

.nav-item {
  border: 0;
  border-radius: 7px;
  padding: 12px 12px;
  text-align: left;
  color: white;
  background: transparent;
  font-size: 16px;
  cursor: default;
}

.nav-item.active {
  background: var(--nav-active);
}

.main {
  min-width: 0;
  flex: 1;
  padding: 28px;
}

.topbar,
.page-titlebar {
  display: flex;
  gap: 20px;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 18px;
}

.page-titlebar {
  min-height: 54px;
  border-bottom: 1px solid var(--border);
  margin: -28px -28px 18px;
  padding: 0 28px;
  background: white;
}

.page-titlebar h1 {
  flex: 1;
  margin: 0;
  font-size: 24px;
}

.menu-button {
  width: 36px;
  height: 36px;
  padding: 0;
  border: 0;
  background: transparent;
  font-size: 24px;
}

.user-area {
  font-weight: 700;
}

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

p {
  margin: 0;
  color: var(--muted);
}

.actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

button {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 14px;
  background: white;
  color: var(--text);
  font-size: 14px;
}

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

button.secondary:disabled {
  color: #94a3b8;
  background: #f8fafc;
}

.product-actions-row {
  display: flex;
  justify-content: flex-start;
  gap: 8px;
  align-items: center;
  margin-bottom: 14px;
  flex-wrap: nowrap;
  overflow-x: auto;
}

.product-actions {
  display: flex;
  flex-wrap: nowrap;
  gap: 8px;
  flex: 0 0 auto;
}

.product-actions button {
  min-width: 58px;
  height: 34px;
  padding: 6px 10px;
  font-weight: 700;
  font-size: 13px;
}

.product-actions .orange-action {
  min-width: 98px;
}

.product-actions .purple-action,
.product-actions .gray-action {
  min-width: 78px;
}

.blue-action {
  color: #1d4ed8;
  border-color: #93c5fd;
  background: #eff6ff;
}

.blue-outline {
  color: #1d4ed8;
  border-color: #93c5fd;
}

.green-action {
  color: #15803d;
  border-color: #86efac;
  background: #f0fdf4;
}

.red-action {
  color: #dc2626;
  border-color: #fecaca;
  background: #fef2f2;
}

.purple-action {
  color: #7c3aed;
  border-color: #ddd6fe;
  background: #faf5ff;
}

.orange-action {
  color: #ea580c;
  border-color: #fed7aa;
  background: #fff7ed;
}

.gray-action {
  color: #334155;
  border-color: #cbd5e1;
  background: #f8fafc;
}

.product-search {
  display: flex;
  width: 360px;
  flex: 0 0 360px;
  height: 34px;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  background: white;
}

.product-search select,
.product-search input,
.product-search button {
  border: 0;
  border-radius: 0;
  height: 100%;
}

.product-search select {
  width: 92px;
  padding-left: 8px;
  border-right: 1px solid var(--border);
  background: #f8fafc;
}

.product-search input {
  flex: 1;
  padding: 0 8px;
}

.product-search button {
  width: 40px;
  font-size: 22px;
  font-weight: 800;
  display: grid;
  place-items: center;
  line-height: 1;
  padding: 0;
}

.selection-inline {
  color: #2563eb;
  font-weight: 800;
  white-space: nowrap;
  margin-left: 2px;
  flex: 0 0 auto;
  font-size: 14px;
}

.product-workspace {
  display: grid;
  grid-template-columns: 160px minmax(0, 1fr);
  gap: 12px;
  min-height: calc(100vh - 150px);
}

.category-panel {
  background: white;
  border: 1px solid var(--border);
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  min-height: 520px;
}

.category-title {
  padding: 14px 16px;
  font-weight: 800;
  border-bottom: 1px solid var(--border);
}

.category-list {
  display: grid;
}

.category-item {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  border: 0;
  border-bottom: 1px solid #eef2f7;
  border-radius: 0;
  padding: 14px 16px;
  text-align: left;
  font-weight: 700;
  background: white;
}

.category-item.active {
  color: #1d4ed8;
  background: #eaf3ff;
}

.category-hint {
  margin-top: auto;
  padding: 14px 16px;
  color: var(--muted);
  font-size: 12px;
}

.product-table-area {
  min-width: 0;
}

.stats {
  display: grid;
  grid-template-columns: repeat(5, minmax(130px, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}

.stat {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px;
}

.stat strong {
  display: block;
  font-size: 24px;
  margin-bottom: 4px;
}

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

.toolbar {
  display: flex;
  gap: 10px;
  margin-bottom: 14px;
}

.task-panel {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) auto;
  gap: 14px;
  align-items: start;
  background: white;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px;
  margin-bottom: 14px;
}

.task-panel h2 {
  margin: 0 0 6px;
}

.task-summary {
  grid-column: 1 / -1;
}

.hidden {
  display: none !important;
}

.packaging-wrap {
  height: 420px;
  margin-bottom: 14px;
}

.work-actions-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  flex-wrap: nowrap;
  overflow-x: auto;
}

.work-actions-row button {
  height: 34px;
  min-width: auto;
  font-weight: 800;
  font-size: 14px;
  padding: 0 10px;
  white-space: nowrap;
}

.work-search {
  display: flex;
  flex: 0 0 470px;
  min-width: 360px;
  height: 34px;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  background: white;
}

.work-search input {
  flex: 1;
  border: 0;
  min-width: 0;
  padding: 0 12px;
  font-size: 14px;
}

.work-search button {
  border: 0;
  border-left: 1px solid var(--border);
  border-radius: 0;
  min-width: 78px;
}

.search-action,
.green-big {
  background: #16a34a;
  color: white;
  border-color: #16a34a;
}

.green-big {
  height: 56px;
  min-width: 150px;
  font-size: 20px;
  font-weight: 900;
}

.packaging-board {
  background: white;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
}

.packaging-summary-row,
.packaging-header-row,
.packaging-main-scroll {
  display: grid;
  grid-template-columns: minmax(420px, var(--packaging-product-width, 64%)) 6px minmax(260px, 1fr);
  gap: 0;
}

.packaging-summary-row {
  height: 34px;
  align-items: center;
  margin: 0 0 4px;
  padding: 0 calc(12px + var(--packaging-scrollbar-width, 0px)) 0 12px;
  box-sizing: border-box;
}

.packaging-product-summary {
  position: relative;
  height: 34px;
  min-width: 0;
}

.packaging-summary-row .task-summary {
  margin: 0;
  padding-right: 0;
  line-height: 34px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.packaging-prepared-total {
  display: none;
}

.packaging-summary-row .packaging-caja-total-clip {
  align-self: stretch;
}

.packaging-caja-total-clip {
  overflow: hidden;
  background: white;
}

.packaging-main-scroll {
  height: calc(100vh - 289px);
  min-height: 520px;
  overflow-y: auto;
  overflow-x: hidden;
  align-items: start;
}

.packaging-header-row {
  height: 34px;
  overflow: hidden;
  padding-right: var(--packaging-scrollbar-width, 0px);
  box-sizing: border-box;
}

.packaging-header-pane {
  border-bottom: 0;
}

.packaging-header-x {
  overflow: hidden;
}

.packaging-product-pane,
.packaging-caja-pane {
  border: 2px solid #d6d9d1;
  background: white;
  overflow: visible;
  min-width: 0;
}

.packaging-product-pane {
  border-right: 0;
}

.packaging-caja-pane {
  border-left: 0;
}

.packaging-main-scroll .packaging-product-pane,
.packaging-main-scroll .packaging-caja-pane {
  border-top: 0;
}

.packaging-divider {
  position: relative;
  z-index: 8;
  cursor: col-resize;
  background:
    linear-gradient(#d7dde8, #d7dde8) 0 33px / 100% 1px no-repeat,
    repeating-linear-gradient(to bottom, transparent 0 45px, #d7dde8 45px 46px) 0 34px / 100% 46px repeat-y,
    #bdbdbd;
  border-top: 2px solid #d6d9d1;
  border-bottom: 2px solid #d6d9d1;
  touch-action: none;
  user-select: none;
  min-height: 100%;
}

.packaging-divider:hover,
.packaging-main-scroll.dragging .packaging-divider {
  background: #9ca3af;
}

.packaging-x-scroll {
  overflow-x: auto;
  overflow-y: visible;
  width: 100%;
}

.packaging-product-table,
.packaging-caja-table {
  table-layout: fixed;
  min-width: auto;
  width: max-content;
}

.packaging-product-table th,
.packaging-product-table td,
.packaging-caja-table th,
.packaging-caja-table td {
  height: 46px;
  min-height: 46px;
  max-height: 46px;
  box-sizing: border-box;
  padding: 0 6px;
  font-size: 14px;
  text-align: center;
}

.packaging-product-table tbody tr,
.packaging-caja-table tbody tr {
  height: 46px;
  min-height: 46px;
  max-height: 46px;
}

.packaging-product-table th {
  height: 34px;
  min-height: 34px;
  max-height: 34px;
  padding: 0 6px;
  background: #fff7c2;
  font-weight: 900;
  position: static;
  z-index: 1;
}

.packaging-product-table thead,
.packaging-caja-table thead {
  z-index: 2;
}

.packaging-caja-totals {
  display: grid;
  width: max-content;
  height: 34px;
  min-height: 34px;
  background: white;
  will-change: transform;
}

.packaging-caja-totals div {
  display: grid;
  place-items: center;
  color: #2563eb;
  font-size: 18px;
  font-weight: 900;
  border-right: 1px solid #edf0f5;
}

.packaging-caja-table th {
  height: 34px;
  min-height: 34px;
  max-height: 34px;
  padding: 0 6px;
  background: #e6f4d7;
  font-weight: 900;
  position: static;
  z-index: 1;
}

.packaging-product-table th:nth-child(1),
.packaging-product-table td:nth-child(1),
.packaging-product-table th:nth-child(2),
.packaging-product-table td:nth-child(2) {
  width: 66px;
}

.packaging-product-table th:nth-child(3),
.packaging-product-table td:nth-child(3) {
  width: 54px;
  min-width: 54px;
  max-width: 54px;
  padding-left: 2px;
  padding-right: 2px;
}

.packaging-product-table .pack-status-col {
  width: 54px;
  min-width: 54px;
  max-width: 54px;
  padding-left: 2px;
  padding-right: 2px;
}

.packaging-product-table td.pack-status-col {
  font-size: 10px;
}

.packaging-product-table th:nth-child(4),
.packaging-product-table td:nth-child(4) {
  width: 145px;
}

.packaging-product-table th:nth-child(5),
.packaging-product-table td:nth-child(5) {
  width: 64px;
}

.packaging-product-table th:nth-child(6),
.packaging-product-table td:nth-child(6) {
  width: 110px;
}

.packaging-product-table th:nth-child(7),
.packaging-product-table td:nth-child(7) {
  width: 58px;
  text-align: center;
}

.packaging-product-table th:nth-child(8),
.packaging-product-table td:nth-child(8) {
  width: 210px;
  text-align: left;
}

.packaging-product-table th:nth-child(9),
.packaging-product-table td:nth-child(9),
.packaging-product-table th:nth-child(10),
.packaging-product-table td:nth-child(10) {
  width: 80px;
}

.packaging-product-table th:nth-child(11),
.packaging-product-table td:nth-child(11) {
  width: 120px;
}

.packaging-product-table th:nth-child(12),
.packaging-product-table td:nth-child(12) {
  width: 84px;
}

.packaging-product-table th:nth-child(13),
.packaging-product-table td:nth-child(13) {
  width: 72px;
}

.packaging-product-table th:nth-child(14),
.packaging-product-table td:nth-child(14) {
  width: 92px;
}

.packaging-product-table th:nth-child(15),
.packaging-product-table td:nth-child(15) {
  width: 76px;
}

.packaging-caja-table th,
.packaging-caja-table td {
  width: 58px;
}

.row-delete-btn,
.row-edit-btn {
  width: 30px;
  height: 30px;
  padding: 0;
  border-radius: 6px;
  font-weight: 900;
  font-size: 20px;
  line-height: 1;
}

.row-delete-btn {
  background: #ef4444;
  color: white;
  border-color: #ef4444;
}

.row-edit-btn {
  background: #2563eb;
  color: white;
  border-color: #2563eb;
}

.print-label-btn {
  background: #08213e;
  color: white;
  border-color: #08213e;
  font-weight: 800;
  min-width: 62px;
  height: 30px;
  padding: 4px 8px;
}

.packaging-product-table .thumb {
  width: 40px;
  height: 40px;
}

.packaging-bottom-actions {
  display: grid;
  grid-template-columns: 180px 1fr 180px;
  align-items: center;
  gap: 14px;
  margin-top: 14px;
}

.packing-note {
  text-align: center;
  color: #ef4444;
  font-size: 20px;
  font-weight: 900;
}

.caja-input {
  width: 44px;
  height: 26px;
  border: 1px solid var(--border);
  border-radius: 6px;
  text-align: center;
}

.caja-input::-webkit-outer-spin-button,
.caja-input::-webkit-inner-spin-button {
  appearance: none;
  margin: 0;
}

.qty-positive,
.caja-input.qty-positive-input {
  color: #2563eb;
  font-weight: 900;
}

.caja-input:disabled {
  background: #f1f5f9;
  color: #94a3b8;
}

.toolbar input,
.toolbar select {
  height: 40px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: white;
  padding: 0 12px;
  font-size: 14px;
}

.toolbar input {
  width: min(460px, 50vw);
}

.table-wrap {
  height: calc(100vh - 245px);
  overflow: auto;
  background: white;
  border: 1px solid var(--border);
  border-radius: 8px;
}

.product-table-wrap {
  height: calc(100vh - 168px);
}

table {
  border-collapse: separate;
  border-spacing: 0;
  min-width: 1800px;
  width: 100%;
}

.product-table {
  min-width: 1680px;
  table-layout: fixed;
}

th,
td {
  border-bottom: 1px solid var(--border);
  border-right: 1px solid #edf0f5;
  padding: 6px 10px;
  vertical-align: middle;
  font-size: 13px;
  background: white;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

td {
  height: 64px;
  max-height: 64px;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f8fafc;
  font-weight: 700;
  white-space: nowrap;
}

.group-amazon {
  background: #e7f2ff;
}

.group-combo {
  background: #eaf7df;
}

.group-warehouse {
  background: #fff1c7;
}

th.amazon-col {
  background: #fff7c2;
}

th.warehouse-head {
  background: #166534;
  color: white;
}

th[data-sort] {
  cursor: pointer;
}

th[data-pack-sort] {
  cursor: pointer;
}

th.name-head,
td.name {
  width: 210px;
  min-width: 210px;
  max-width: 210px;
}

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

.amazon-link-cell {
  width: 58px;
  min-width: 58px;
  max-width: 58px;
  text-align: center;
}

th.qty-head,
td.qty-cell {
  width: 70px;
  min-width: 70px;
  max-width: 70px;
  text-align: center;
}

.product-table th:nth-child(1),
.product-table td:nth-child(1) {
  width: 150px;
}

.product-table th:nth-child(2),
.product-table td:nth-child(2) {
  width: 125px;
}

.product-table th:nth-child(3),
.product-table td:nth-child(3) {
  width: 130px;
}

.product-table th:nth-child(7),
.product-table td:nth-child(7) {
  width: 90px;
}

.product-table th:nth-child(8),
.product-table td:nth-child(8) {
  width: 60px;
  text-align: center;
}

.product-table th:nth-child(9),
.product-table td:nth-child(9) {
  width: 76px;
  text-align: center;
}

.product-table th:nth-child(10),
.product-table td:nth-child(10) {
  width: 84px;
}

.product-table th:nth-child(11),
.product-table td:nth-child(11) {
  width: 70px;
  text-align: center;
}

.product-table th:nth-child(12),
.product-table td:nth-child(12),
.product-table th:nth-child(13),
.product-table td:nth-child(13) {
  width: 72px;
  text-align: center;
}

.product-table th:nth-child(14),
.product-table td:nth-child(14) {
  width: 92px;
}

.product-table th:nth-child(16),
.product-table td:nth-child(16) {
  width: 100px;
}

.product-table th:nth-child(17),
.product-table td:nth-child(17) {
  width: 110px;
}

.muted {
  color: var(--muted);
}

.status-ok {
  color: #047857;
  font-weight: 600;
}

.status-warn {
  color: #b45309;
  font-weight: 600;
}

.shrink-text {
  display: block;
  width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 9px;
  line-height: 1.1;
}


.thumb {
  width: 46px;
  height: 46px;
  object-fit: contain;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: white;
  cursor: zoom-in;
}

.product-table th:nth-child(6),
.product-table td:nth-child(6) {
  width: 64px;
  min-width: 64px;
  max-width: 64px;
  text-align: center;
}

.no-image {
  color: #dc2626;
  font-weight: 800;
  white-space: nowrap;
}

tr.selected td {
  background: #eff6ff;
}

.link {
  color: var(--primary);
  text-decoration: none;
  font-weight: 600;
}

.modal {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(15, 23, 42, 0.72);
  z-index: 1000;
}

.modal.hidden {
  display: none;
}

.modal img {
  max-width: 88vw;
  max-height: 88vh;
  background: white;
  border-radius: 8px;
}

.modal-close {
  position: fixed;
  top: 18px;
  right: 18px;
}

.product-form {
  width: min(920px, 92vw);
  max-height: 92vh;
  overflow: auto;
  background: white;
  border-radius: 8px;
  padding: 22px;
}

.category-form {
  width: min(720px, 90vw);
  max-height: 90vh;
  overflow: auto;
  background: white;
  border-radius: 8px;
  padding: 22px;
}

.category-editor-rows {
  display: grid;
  gap: 8px;
  margin-bottom: 14px;
}

.category-editor-row {
  display: grid;
  grid-template-columns: minmax(160px, 1fr) 80px 64px 64px 64px;
  gap: 8px;
  align-items: center;
}

.category-editor-row input {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 9px 10px;
  font: inherit;
}

.category-editor-row input[readonly] {
  background: #f8fafc;
  color: #64748b;
  font-weight: 800;
}

.category-editor-row span {
  color: var(--muted);
}

.category-editor-actions {
  display: flex;
  justify-content: space-between;
  gap: 10px;
}

.form-head,
.form-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.form-head h2 {
  margin: 0;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.form-grid label {
  display: grid;
  gap: 6px;
  font-weight: 600;
  font-size: 13px;
}

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

.form-grid input,
.form-grid select,
.form-grid textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 9px 10px;
  font: inherit;
  font-weight: 400;
}

.form-grid textarea {
  resize: vertical;
}

.component-editor {
  display: grid;
  gap: 8px;
}

.component-editor-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.component-editor-head button {
  padding: 7px 10px;
}

.component-grid {
  display: grid;
  grid-template-columns: 1fr 90px 1fr 1fr 70px;
  gap: 8px;
  align-items: center;
}

.component-grid-head {
  color: var(--muted);
  font-weight: 800;
}

.component-row input {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 9px 10px;
  font: inherit;
}

.remove-component-btn {
  color: #dc2626;
}

@media (max-width: 900px) {
  body {
    min-width: 1180px;
  }
}
