:root {
  --bg: #eef2f5;
  --panel: #ffffff;
  --ink: #18222d;
  --muted: #667085;
  --line: #d6dde6;
  --head: #f3f6f8;
  --accent: #176b5b;
  --accent-2: #2f6fed;
  --danger: #b42318;
  --warn: #a15c07;
  --good: #147044;
  --shadow: 0 14px 34px rgba(24, 34, 45, .08);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Microsoft YaHei", "Segoe UI", Arial, sans-serif;
  font-size: 14px;
  overflow: hidden;
}

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

.search-select {
  position: relative;
}

.search-options {
  position: absolute;
  z-index: 40;
  top: calc(100% + 3px);
  left: 0;
  right: auto;
  width: max(100%, 560px);
  max-height: 320px;
  overflow: auto;
  display: block;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  box-shadow: var(--shadow);
}

.search-options.floating {
  position: fixed;
  z-index: 300;
  max-height: 340px;
  overflow: auto;
}

.search-options.drop-up {
  top: auto;
  bottom: calc(100% + 3px);
}

.search-option-head,
.search-options button.search-option-row {
  display: grid;
  grid-template-columns: var(--search-option-columns, minmax(220px, 1fr));
  align-items: stretch;
  min-width: max-content;
}

.search-option-head {
  position: sticky;
  top: 0;
  z-index: 1;
  min-height: 34px;
  background: #f3f6f8;
  border-bottom: 1px solid var(--line);
  color: #344054;
  font-weight: 700;
}

.search-option-head span,
.search-options button.search-option-row span {
  min-width: 0;
  padding: 7px 10px;
  border-right: 1px solid var(--line);
  line-height: 1.35;
  word-break: break-all;
}

.search-option-head span:last-child,
.search-options button.search-option-row span:last-child {
  border-right: 0;
}

.search-options button.search-option-row {
  width: 100%;
  min-height: 38px;
  justify-content: flex-start;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  padding: 0;
  text-align: left;
  white-space: normal;
  background: #fff;
}

.search-options button.search-option-row:last-child {
  border-bottom: 0;
}

.search-options button.search-option-row:hover {
  background: #f3f6f8;
}

button {
  min-height: 32px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  padding: 0 10px;
  cursor: pointer;
}

button:hover { border-color: var(--accent); }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.danger { color: var(--danger); border-color: #f2b8b5; }
button.ghost { background: transparent; }
button.full { width: 100%; min-height: 40px; }
button:disabled,
input:disabled,
select:disabled,
textarea:disabled {
  cursor: not-allowed;
  opacity: .62;
  background: #f3f6f8;
}

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

textarea { min-height: 72px; resize: vertical; }

label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 12px;
}

label input,
label select,
label textarea {
  color: var(--ink);
  font-size: 14px;
}

.hidden { display: none !important; }

.login-view {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 28px;
  background: linear-gradient(140deg, #e8f4f1 0%, #f4f7fa 48%, #edf3ff 100%);
}

.login-panel {
  width: min(420px, 100%);
  display: grid;
  gap: 14px;
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
}

.brand-block {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
}

.brand-block h1 { margin: 0; font-size: 24px; letter-spacing: 0; }
.brand-block p { margin: 4px 0 0; color: var(--muted); }

.brand-mark {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-weight: 800;
  letter-spacing: 0;
}

.brand-mark.small {
  width: 34px;
  height: 34px;
  border-radius: 6px;
  font-size: 13px;
}

.hint { margin: 0; color: var(--muted); font-size: 12px; }
.error { color: var(--danger); margin: 0; min-height: 18px; }

.app-view {
  height: 100vh;
  display: grid;
  grid-template-columns: 210px minmax(0, 1fr);
  transition: grid-template-columns .18s ease;
  overflow: hidden;
}

.app-view.sidebar-hidden {
  grid-template-columns: 0 minmax(0, 1fr);
}

.sidebar {
  background: #102820;
  color: #e8f5ef;
  height: 100vh;
  overflow-y: auto;
  width: 178px;
  transition: transform .18s ease, width .18s ease;
}

.app-view.sidebar-hidden .sidebar {
  transform: translateX(-178px);
  width: 0;
  overflow: hidden;
}

.sidebar-head {
  height: 64px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px;
  border-bottom: 1px solid rgba(255,255,255,.12);
}

.sidebar-title { display: grid; gap: 2px; }
.sidebar-title span { color: rgba(255,255,255,.64); font-size: 12px; }
.menu {
  padding: 8px 6px;
  display: grid;
  gap: 6px;
}

.menu-controls {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  padding-bottom: 8px;
  border-bottom: 1px solid rgba(255,255,255,.12);
}

.menu-controls button {
  min-height: 28px;
  justify-content: center;
  border: 1px solid rgba(255,255,255,.12);
  background: rgba(255,255,255,.08);
  color: #e8f5ef;
  font-size: 12px;
}

.menu-group {
  border-bottom: 1px solid rgba(255,255,255,.08);
  padding-bottom: 8px;
}

.menu-group-title {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 22px;
  align-items: center;
  gap: 6px;
  min-height: 32px;
  padding: 0 8px;
  color: rgba(255,255,255,.66);
  font-size: 14px;
  font-weight: 700;
  white-space: nowrap;
}

.menu-group-title span {
  display: block;
  text-align: left;
}

.group-toggle {
  width: 22px;
  min-width: 22px;
  height: 22px;
  min-height: 22px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  background: transparent;
  color: #fff;
  font-weight: 800;
}

.menu-category {
  margin: 8px 0 3px;
  padding: 0 8px;
  color: rgba(255,255,255,.46);
  font-size: 11px;
}

.menu button {
  width: 100%;
  justify-content: flex-start;
  display: flex;
  gap: 6px;
  align-items: center;
  border: none;
  background: transparent;
  color: #e8f5ef;
  text-align: left;
  min-height: 30px;
  padding: 0 8px;
}

.menu button em {
  margin-left: auto;
  min-width: 22px;
  height: 20px;
  display: inline-grid;
  place-items: center;
  border-radius: 999px;
  background: #f4b63f;
  color: #102820;
  font-style: normal;
  font-size: 11px;
  font-weight: 800;
}

.menu button.active,
.menu button:hover {
  background: rgba(255,255,255,.12);
  border-color: transparent;
}

.menu .group-toggle {
  width: 22px;
  min-width: 22px;
  height: 22px;
  min-height: 22px;
  justify-content: center;
  padding: 0;
  border: 0;
  background: transparent;
  font-size: 18px;
  line-height: 1;
}

.menu-items > button {
  padding-left: 24px;
}

.menu-category {
  padding-left: 24px;
}

.menu button.disabled {
  cursor: not-allowed;
  opacity: .46;
}

.menu button.disabled:hover {
  background: transparent;
}

.main {
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-rows: auto auto 1fr;
}

.topbar {
  min-height: 64px;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 14px;
  padding: 12px 18px;
  background: rgba(255,255,255,.96);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 5;
}

.topbar h2 { margin: 0; font-size: 18px; letter-spacing: 0; }
.topbar p { margin: 2px 0 0; color: var(--muted); font-size: 12px; }
.topbar-right { display: flex; align-items: center; gap: 8px; }
.icon-btn { min-width: 36px; padding: 0; }
.user-chip {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 999px;
  padding: 5px 10px;
  color: var(--muted);
}

.opened-tabs {
  min-width: 0;
  min-height: 34px;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 5px 14px 0;
  overflow-x: auto;
  overflow-y: hidden;
  background: #eaf1f8;
  border-bottom: 1px solid var(--line);
}

.module-tab {
  height: 29px;
  min-height: 29px;
  max-width: 190px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border: 1px solid #b8c8db;
  border-bottom-color: #8ea8c5;
  border-radius: 5px 5px 0 0;
  background: linear-gradient(#f8fbff, #d7e5f5);
  color: #244566;
  padding: 0 6px 0 9px;
  white-space: nowrap;
}

.module-tab.active {
  background: #fff;
  color: var(--ink);
  border-bottom-color: #fff;
  font-weight: 700;
}

.module-tab span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tab-close {
  width: 18px;
  min-width: 18px;
  height: 18px;
  min-height: 18px;
  display: grid;
  place-items: center;
  padding: 0;
  border-radius: 3px;
  border-color: #afbfce;
  background: #edf4fb;
  color: #52677b;
  font-size: 13px;
  line-height: 1;
}

.tab-close-all {
  height: 29px;
  min-height: 29px;
  display: inline-flex;
  align-items: center;
  margin-left: 6px;
  border: 1px solid #b8c8db;
  border-radius: 5px 5px 0 0;
  background: #fff;
  color: #52677b;
  padding: 0 10px;
  white-space: nowrap;
}

.tab-dirty {
  width: 7px;
  min-width: 7px;
  height: 7px;
  border-radius: 999px;
  background: #f4b63f;
}

.content {
  min-width: 0;
  min-height: 0;
  padding: 14px;
  overflow: hidden;
  position: relative;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(130px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.kpi {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 14px;
  min-height: 92px;
}

.kpi strong { display: block; font-size: 24px; margin-bottom: 6px; }
.kpi span { color: var(--muted); font-size: 12px; }

.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
  margin-bottom: 14px;
  overflow: hidden;
}

.panel-head {
  min-height: 42px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 7px 12px;
  border-bottom: 1px solid var(--line);
  background: var(--head);
}

.panel-title { display: grid; gap: 2px; }
.panel-title strong { font-size: 15px; }
.panel-title span { color: var(--muted); font-size: 12px; }
.panel-actions { display: flex; gap: 8px; flex-wrap: nowrap; align-items: center; }

.panel.full-list > .panel-head {
  align-items: center;
}

.panel.full-list > .panel-head .panel-title span {
  display: none;
}

.panel.full-list > .panel-head > .panel-actions {
  min-width: 0;
  overflow-x: auto;
}

.panel-body {
  min-height: 0;
  padding: 10px 12px;
  overflow: hidden;
}

.panel-body.todo-workspace {
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow: auto;
}

.full-list {
  height: calc(100vh - 94px);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
}

.split {
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(360px, .7fr);
  gap: 14px;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(15, 23, 42, .36);
}

.modal-panel {
  width: min(1080px, calc(100vw - 48px));
  max-height: calc(100vh - 48px);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 22px 64px rgba(15, 23, 42, .22);
  overflow: visible;
}

.modal-panel.wide-modal {
  width: min(1520px, calc(100vw - 32px));
}

.modal-panel.dragging {
  pointer-events: none;
}

.modal-head {
  min-height: 52px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  background: var(--head);
  cursor: move;
  user-select: none;
}

.modal-body {
  padding: 14px;
  overflow: visible;
}

.delivery-template-panel {
  width: min(560px, calc(100vw - 48px));
}

.delivery-template-options {
  display: grid;
  gap: 10px;
}

.delivery-template-option {
  display: grid;
  gap: 4px;
  min-height: 62px;
  padding: 12px 14px;
  text-align: left;
}

.delivery-template-option strong {
  font-size: 15px;
}

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

.content > .modal-backdrop:not(.field-settings-backdrop):not(.roll-picker-backdrop):not(.record-view-backdrop):not(.stock-backdrop) {
  position: absolute;
  inset: 0;
  z-index: 22;
  display: block;
  padding: 0;
  background: transparent;
}

.content > .modal-backdrop:not(.field-settings-backdrop):not(.roll-picker-backdrop):not(.record-view-backdrop):not(.stock-backdrop) > .modal-panel {
  width: 100%;
  height: 100%;
  max-height: none;
  border-radius: 8px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
}

.content > .modal-backdrop:not(.field-settings-backdrop):not(.roll-picker-backdrop):not(.record-view-backdrop):not(.stock-backdrop) .modal-body {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 10px 12px;
}

.content > .modal-backdrop:not(.field-settings-backdrop):not(.roll-picker-backdrop):not(.record-view-backdrop):not(.stock-backdrop) .modal-body form {
  min-height: 100%;
  display: flex;
  flex-direction: column;
}

.content > .modal-backdrop:not(.field-settings-backdrop):not(.roll-picker-backdrop):not(.record-view-backdrop):not(.stock-backdrop) .modal-body h4,
.operation-panel .panel-body h4 {
  margin: 10px 0 6px;
}

.content > .modal-backdrop:not(.field-settings-backdrop):not(.roll-picker-backdrop):not(.record-view-backdrop):not(.stock-backdrop) .modal-body .form-grid,
.operation-panel .panel-body .form-grid {
  gap: 8px;
}

.content > .modal-backdrop:not(.field-settings-backdrop):not(.roll-picker-backdrop):not(.record-view-backdrop):not(.stock-backdrop) .modal-body form .table-wrap,
.operation-panel .panel-body form .table-wrap {
  height: auto;
  max-height: 260px;
  overflow: auto;
}

.operation-panel .panel-body {
  padding: 10px 12px;
}

.content > .modal-backdrop:not(.field-settings-backdrop):not(.roll-picker-backdrop):not(.record-view-backdrop):not(.stock-backdrop) .modal-body form > .panel-actions:last-child,
.content > .modal-backdrop:not(.field-settings-backdrop):not(.roll-picker-backdrop):not(.record-view-backdrop):not(.stock-backdrop) .modal-body form > .flow-actions {
  position: sticky;
  bottom: 0;
  z-index: 12;
  margin-top: auto !important;
  padding: 10px 0;
  border-top: 1px solid var(--line);
  background: #fff;
}

.content > .modal-backdrop:not(.field-settings-backdrop):not(.roll-picker-backdrop):not(.record-view-backdrop):not(.stock-backdrop) .modal-head {
  cursor: default;
}

button.action-enabled {
  background: var(--accent-2);
  border-color: var(--accent-2);
  color: #fff;
}

button.action-enabled.secondary {
  background: var(--accent);
  border-color: var(--accent);
}

button.action-enabled.danger {
  background: #fff5f5;
  border-color: #f2b8b5;
  color: var(--danger);
}

button.action-disabled,
button.action-disabled:hover {
  cursor: not-allowed;
  opacity: .56;
  background: #eef2f5;
  border-color: var(--line);
  color: #7a8594;
}

.permission-page .panel-body {
  padding: 12px;
}

.permission-layout {
  display: grid;
  grid-template-columns: 220px 360px minmax(0, 1fr);
  gap: 12px;
  height: calc(100vh - 250px);
  min-height: 500px;
}

.permission-card {
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.permission-card-head {
  display: flex;
  gap: 8px;
  align-items: center;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  background: #f8fafc;
}

.permission-card-head strong {
  font-size: 15px;
}

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

.permission-role-list,
.permission-employee-list,
.permission-tree {
  min-height: 0;
  overflow: auto;
  padding: 8px;
}

.permission-role-btn {
  width: 100%;
  min-height: 44px;
  justify-content: center;
  align-items: flex-start;
  flex-direction: column;
  margin-bottom: 6px;
  text-align: left;
}

.permission-role-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.permission-role-btn span {
  font-size: 12px;
  opacity: .82;
}

.permission-role-form {
  padding: 10px;
  border-bottom: 1px solid var(--line);
}

.permission-check {
  display: flex;
  gap: 8px;
  align-items: center;
  min-height: 34px;
}

.permission-check input[type="checkbox"] {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
}

.permission-check span {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.permission-check em {
  color: var(--muted);
  font-size: 12px;
  font-style: normal;
}

.permission-employee {
  padding: 6px;
  border-bottom: 1px solid #eef2f5;
}

.permission-tree-tools {
  display: flex;
  gap: 6px;
  margin-left: auto;
}

.permission-tree-tools button,
.permission-group summary button {
  min-height: 28px;
  padding: 4px 8px;
  font-size: 12px;
}

.permission-group {
  overflow: hidden;
  margin-bottom: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.permission-group summary {
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: space-between;
  padding: 8px 10px;
  cursor: pointer;
  background: #f6f9fb;
}

.permission-row {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  gap: 10px;
  padding: 10px;
  border-top: 1px solid var(--line);
}

.permission-actions-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(88px, 1fr));
  gap: 6px;
}

.permission-chip {
  display: flex;
  gap: 5px;
  align-items: center;
  padding: 5px 7px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  font-size: 12px;
}

.permission-chip input {
  width: 16px;
  height: 16px;
}

.compact-empty {
  min-height: 120px;
}

.permission-denied {
  pointer-events: none;
}

@media (max-width: 1200px) {
  .permission-layout {
    grid-template-columns: 1fr;
    height: auto;
  }

  .permission-card {
    max-height: none;
  }

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

.field-settings-backdrop .modal-panel {
  width: min(1540px, calc(100vw - 20px));
  height: calc(100vh - 20px);
  max-height: calc(100vh - 20px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
}

.field-settings-backdrop .modal-head {
  flex: 0 0 auto;
  position: sticky;
  top: 0;
  z-index: 30;
  background: var(--panel);
}

.field-settings-backdrop .modal-body {
  flex: 1 1 auto;
  min-height: 0;
  padding: 10px 14px;
  padding-bottom: 96px;
  overflow: auto;
}

.field-settings-backdrop h4 {
  margin: 4px 0 8px;
}

.field-settings-footer {
  flex: 0 0 auto;
  position: sticky;
  left: 0;
  right: 0;
  margin: 0;
  bottom: 0;
  z-index: 30;
  padding: 10px 14px;
  border-top: 1px solid var(--line);
  background: #fff;
  justify-content: flex-start;
  box-shadow: 0 -8px 20px rgba(15, 23, 42, .06);
}

.layout-editor input {
  min-height: 28px;
  padding: 4px 8px;
}

.layout-section {
  display: grid;
  gap: 8px;
}

.layout-two {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 12px;
}

.layout-title {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.layout-editor th,
.layout-editor td {
  padding: 5px 8px;
}

.layout-editor button {
  min-width: 34px;
  min-height: 28px;
  padding: 0;
}

.form-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: end;
  align-content: flex-start;
}

.form-grid.compact {
  gap: 8px;
}

.form-grid .wide {
  flex: 1 0 100%;
  max-width: 100%;
}

.form-grid > .layout-field,
.production-entry-fields > .layout-field {
  box-sizing: border-box;
  min-width: 0;
}

.layout-field[data-layout-hidden="true"] {
  display: none !important;
}

.layout-field > input,
.layout-field > select,
.layout-field > textarea,
.layout-field .search-select {
  width: 100%;
  min-width: 0;
}

label.field-mini { width: 140px; }
label.field-normal { width: 200px; }
label.field-mid { width: 240px; }
label.field-wide { width: 340px; }
label.wide { width: 100%; }

.structured-editor {
  display: grid;
  gap: 6px;
  margin-top: 6px;
  min-height: 0;
}

.structured-section {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fbfdff;
  padding: 7px 9px;
}

.structured-head {
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 6px;
}

.structured-head strong {
  font-size: 15px;
}

.structured-head span {
  color: var(--muted);
  font-size: 12px;
}

.structured-tools {
  margin-bottom: 6px;
}

.structured-tabs {
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
  width: fit-content;
  border: 1px solid var(--line);
  border-radius: 6px;
  overflow: hidden;
  background: #fff;
}

.structured-tabs button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 34px;
  padding: 0 14px;
  border: 0;
  border-radius: 0;
  background: #fff;
}

.structured-tabs button + button {
  border-left: 1px solid var(--line);
}

.structured-tabs button.active {
  background: #0f766e;
  color: #fff;
}

.structured-tabs span {
  min-width: 20px;
  padding: 1px 6px;
  border-radius: 999px;
  background: rgba(15, 118, 110, .1);
  color: inherit;
  font-size: 12px;
  text-align: center;
}

.structured-tabs button.active span {
  background: rgba(255, 255, 255, .18);
}

.product-structured-panel {
  min-height: 178px;
}

.product-structure-table {
  display: block;
  height: auto;
  max-height: 116px;
  overflow: auto;
}

.product-structure-table table {
  min-width: 720px;
}

.production-structured {
  margin-top: 8px;
  display: flex;
  flex-direction: column;
  min-height: 0;
  flex: 1 1 0;
}

.production-modal-body {
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden !important;
}

.production-modal-body > .notice {
  flex: 0 0 auto;
}

.production-modal-body #productionForm {
  height: auto !important;
  flex: 1 1 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.production-modal-body #productionForm > .form-grid {
  flex: 0 0 auto;
}

.production-modal-body #productionForm > .production-structured {
  flex: 1 1 0;
  min-height: 0;
}

.production-structured-panel {
  min-height: 0;
  display: flex;
  flex-direction: column;
  flex: 1 1 0;
  overflow: hidden;
}

.production-structured .table-wrap {
  height: 100%;
  min-height: 0;
  max-height: none;
  flex: 1 1 0;
  overflow: auto;
}

#productionForm .production-structured .table-wrap {
  height: 100%;
  min-height: 0;
  max-height: none !important;
  flex: 1 1 0;
}

#productionForm {
  min-height: 0;
}

.content > .modal-backdrop:not(.field-settings-backdrop):not(.roll-picker-backdrop):not(.record-view-backdrop):not(.stock-backdrop) .modal-body form#productionForm,
.operation-panel .panel-body form#productionForm {
  height: 100%;
  min-height: 0;
}

#productionForm .notice {
  margin-bottom: 8px;
  padding: 7px 10px;
}

.production-section-actions {
  margin: 0;
}

.production-entry-row {
  display: grid;
  grid-template-columns: minmax(120px, 150px) minmax(0, 1fr);
  align-items: end;
  gap: 8px;
  min-width: 0;
  margin-bottom: 4px;
  overflow: visible;
  padding-bottom: 0;
}

.production-entry-title {
  min-width: 0;
  margin: 0;
}

.production-entry-title.structured-head {
  display: grid;
  align-self: center;
  gap: 2px;
}

.production-entry-title strong {
  white-space: nowrap;
}

.production-entry-title span {
  display: block;
  max-width: 100%;
  line-height: 1.15;
  white-space: normal;
}

.production-entry-main {
  display: flex;
  align-items: end;
  gap: 8px;
  min-width: 0;
  overflow: visible;
}

.production-entry-fields {
  flex: 1 1 auto;
  flex-wrap: nowrap;
  min-width: 0;
}

.production-entry-fields label {
  flex: 0 0 auto;
}

.production-entry-row .production-section-actions {
  align-self: end;
  flex: 0 0 auto;
  white-space: nowrap;
}

.production-entry-row .production-section-actions button,
.production-entry-row .production-section-actions .inline-input {
  min-height: 30px;
}

.production-entry-row .production-section-actions button {
  padding: 0 7px;
}

.production-entry-row .inline-input {
  display: inline-grid;
  gap: 3px;
  align-items: end;
}

.production-form-footer {
  gap: 12px;
  align-items: center;
  flex-wrap: nowrap;
  flex: 0 0 auto;
  margin-top: 6px !important;
  padding-top: 8px !important;
  padding-bottom: 6px !important;
}

.production-form-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
}

.production-inline-totals {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
  flex: 1 1 auto;
  overflow-x: auto;
  padding: 7px 10px;
  border: 1px solid #c7e4da;
  border-radius: 6px;
  background: #f4fbf8;
  color: #243447;
  font-size: 13px;
  white-space: nowrap;
}

.production-inline-totals strong {
  color: var(--accent);
}

.production-knife-cell {
  vertical-align: middle;
  background: #f8fbfd;
  font-weight: 700;
}

.production-select-cell {
  text-align: center;
  white-space: nowrap;
}

.production-select-boxes {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-width: 48px;
}

.production-check-placeholder {
  display: inline-block;
  width: 16px;
  height: 16px;
  flex: 0 0 16px;
}

.production-knife-cell,
.production-seq-cell {
  white-space: nowrap;
  vertical-align: middle;
}

.production-knife-check,
.production-output-check {
  width: 16px;
  height: 16px;
  min-height: 16px;
  margin: 0;
}

#productionForm .form-grid {
  gap: 7px;
}

#productionForm label {
  gap: 3px;
}

#productionForm label input,
#productionForm label select,
#productionForm label textarea {
  min-height: 34px;
  padding: 4px 8px;
  font-size: 13px;
}

#productionForm .structured-tabs button {
  min-height: 30px;
}

#productionForm .structured-section {
  padding: 6px 8px;
}

#productionForm .dense-table th,
#productionForm .dense-table td {
  padding: 3px 5px;
  font-size: 12px;
  line-height: 1.15;
}

#productionForm .dense-table input,
#productionForm .dense-table select {
  min-height: 28px;
  padding: 2px 6px;
  font-size: 12px;
}

#productionForm .dense-table .production-output-product-cell label {
  margin: 0;
  display: block;
  width: 100%;
}

#productionForm .dense-table .production-output-product-cell .search-select {
  min-width: 0;
  width: 100%;
}

#productionForm .dense-table .production-output-product-cell .search-input {
  min-height: 28px;
  padding: 2px 6px;
  font-size: 12px;
}

#productionForm .production-output-table input,
#productionForm .production-output-table .search-input {
  width: 100%;
  box-sizing: border-box;
}

#productionForm .dense-table button {
  min-height: 26px;
  padding: 0 6px;
  font-size: 12px;
}

#productionForm .empty {
  min-height: 0;
  padding: 16px 10px;
}

.compact-empty {
  min-height: 112px;
  padding: 18px 12px;
}

.sales-header-line,
.sales-item-line,
.sales-address-line,
.notice-form-line {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 10px;
}

.sales-address-line {
  margin-top: 10px;
}

.notice-form-line {
  flex-wrap: nowrap;
}

.dense-table th,
.dense-table td {
  padding: 7px 8px;
}

.sales-lines {
  min-width: 1110px;
}

.table-wrap {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 5px;
  overflow: hidden;
  max-width: 100%;
  height: 100%;
}

.table-wrap.action-table {
  grid-template-rows: auto minmax(0, 1fr) auto;
}

.table-command-strip {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  overflow-x: auto;
  overflow-y: visible;
  padding: 1px 0 4px;
}

.panel-table-tools {
  margin-left: 4px;
  padding: 0;
  flex: 0 1 auto;
  overflow-x: visible;
}

.panel-table-tools .table-actionbar,
.panel-table-tools .table-tools {
  min-height: 28px;
}

.panel-table-tools .table-selection-count {
  min-width: 54px;
}

.panel-table-tools .table-tools button,
.panel-table-tools .table-selection-buttons button {
  min-height: 28px;
  padding: 4px 10px;
}

.table-summary {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  border-top: 1px solid var(--line);
  background: #f7fbfa;
  color: #243447;
  padding: 9px 12px;
  font-size: 14px;
}

.table-summary.hidden {
  display: none;
}

.table-summary-title {
  color: var(--muted);
  font-weight: 700;
}

.table-summary-item {
  white-space: nowrap;
}

.table-summary-item strong {
  color: var(--accent);
}

.table-actionbar {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  padding: 0;
  flex: 0 0 auto;
}

.table-selection-count {
  min-width: 78px;
  color: var(--muted);
  font-size: 13px;
}

.table-selection-buttons {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: nowrap;
}

.table-selection-buttons button:not(:disabled):not(.danger):not(.action-disabled) {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.table-selection-buttons button.danger:not(:disabled) {
  background: #fff5f5;
  border-color: #f2b8b5;
  color: var(--danger);
}

.select-header,
.select-cell {
  width: 46px;
  min-width: 46px;
  text-align: center;
}

.select-header input,
.select-cell input[type="checkbox"],
.table-row-check {
  width: 20px;
  min-height: 20px;
  cursor: pointer;
}

.table-tools {
  display: flex;
  align-items: center;
  gap: 8px;
  justify-content: flex-start;
  flex-wrap: nowrap;
  min-width: 0;
  flex: 0 0 auto;
}

.table-tools input {
  width: 280px;
  max-width: 280px;
}

.table-scroll {
  min-height: 0;
  overflow: auto;
}

table {
  min-width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
  background: #fff;
}

th, td {
  border-bottom: 1px solid var(--line);
  padding: 9px 10px;
  text-align: left;
  vertical-align: middle;
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: break-word;
}

th {
  background: #f7f9fb;
  color: #344054;
  font-weight: 700;
  font-size: 12px;
  position: sticky;
  top: 0;
  z-index: 3;
}

.table-sort-btn {
  width: 100%;
  min-height: 24px;
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
  border: 0;
  border-radius: 0;
  padding: 0;
  background: transparent;
  color: inherit;
  font-weight: 700;
  text-align: left;
}

.table-sort-btn:hover,
.table-sort-btn.active {
  border: 0;
  color: var(--accent);
  background: transparent;
}

.column-filter-row th {
  top: 38px;
  padding: 3px 2px;
  background: #f7f9fb;
  z-index: 3;
}

.multi-filter {
  position: relative;
  width: 100%;
  min-width: 0;
}

.table-tools .multi-filter {
  width: 140px;
  min-width: 120px;
}

.view-switch {
  display: inline-flex;
  align-items: center;
  gap: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  overflow: hidden;
  background: #fff;
}

.view-switch button {
  border: 0;
  border-radius: 0;
  min-height: 34px;
  padding: 0 14px;
}

.view-switch button.active {
  background: #0f766e;
  color: #fff;
}

.muted-cell {
  margin-top: 4px;
  color: #667085;
  font-size: 12px;
}

.section-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 12px;
}

.section-title-row h3 {
  margin: 0;
}

.inline-picker {
  margin: 10px 0 14px;
  border: 1px solid var(--line);
  border-radius: 6px;
  overflow: hidden;
  background: #fff;
}

.compact-head {
  padding: 10px 12px;
}

.totals-bar {
  margin-top: 10px;
  padding: 10px 12px;
  border: 1px solid #c7e4da;
  border-radius: 6px;
  background: #f4fbf8;
  color: #0f513c;
  font-weight: 600;
}

.roll-picker-backdrop {
  z-index: 80;
}

.multi-filter-btn {
  width: 100%;
  min-height: 26px;
  padding: 0 3px;
  text-align: left;
  font-size: 11px;
  overflow: hidden;
  text-overflow: clip;
}

.multi-filter-btn.active {
  border-color: var(--accent);
  color: var(--accent);
  background: #edf8f5;
}

.multi-filter-menu {
  position: absolute;
  left: 0;
  top: calc(100% + 4px);
  z-index: 20;
  width: max(220px, 100%);
  max-height: 280px;
  display: grid;
  gap: 6px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  box-shadow: var(--shadow);
}

.multi-filter-search {
  min-height: 30px;
  padding: 4px 6px;
  font-size: 12px;
}

.multi-filter-options {
  max-height: 210px;
  overflow: auto;
  display: grid;
  gap: 2px;
}

.filter-option {
  min-height: 28px;
  display: flex;
  grid-template-columns: none;
  align-items: center;
  gap: 6px;
  padding: 4px 5px;
  border-radius: 4px;
  color: var(--ink);
  font-size: 12px;
  cursor: pointer;
}

.filter-option:hover {
  background: #f3f6f8;
}

.filter-option input {
  width: 14px;
  min-height: 14px;
}

.multi-checks {
  min-height: 40px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
}

.check-pill {
  min-height: 28px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--ink);
  font-size: 12px;
}

.check-pill input {
  width: 14px;
  min-height: 14px;
}

.cell-date {
  min-height: 30px;
  padding: 4px 6px;
}

tbody tr:hover { background: #f8fbfa; }

.merged-cell {
  background: #fbfcfd;
  border-top-color: transparent;
}

.row-actions {
  display: flex;
  flex-wrap: nowrap;
  gap: 6px;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  border-radius: 999px;
  padding: 1px 8px;
  font-size: 12px;
  font-weight: 700;
}

.pill.good { color: var(--good); background: #e8f7ef; }
.pill.warn { color: var(--warn); background: #fff4d8; }
.pill.risk { color: var(--danger); background: #fde7e7; }
.pill.neutral { color: #174b8f; background: #e9f2ff; }

.empty {
  display: grid;
  place-items: center;
  gap: 6px;
  min-height: 160px;
  color: var(--muted);
}

.empty strong { color: var(--ink); }

.notice {
  border: 1px solid #bad7cc;
  background: #f4fbf8;
  color: #214d42;
  padding: 10px 12px;
  border-radius: 8px;
  margin-bottom: 12px;
}

.tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.tabs button.active { background: var(--accent); color: #fff; border-color: var(--accent); }

.print-sheet {
  background: #fff;
  color: #000;
  padding: 24px;
  font-family: "Microsoft YaHei", Arial, sans-serif;
}

.print-sheet h1 {
  text-align: center;
  margin: 0 0 18px;
  font-size: 22px;
}

.delivery-print-sheet {
  width: 190mm;
  min-height: 130mm;
  margin: 0 auto;
  padding: 10mm 12mm;
  font-family: "SimSun", "Microsoft YaHei", Arial, sans-serif;
}

.delivery-print-company {
  min-height: 24px;
  text-align: center;
  font-size: 20px;
  font-weight: 700;
}

.delivery-print-sheet h1 {
  margin: 4px 0 8px;
  font-size: 22px;
}

.delivery-print-topline,
.delivery-print-meta,
.delivery-print-sign {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 8px;
  font-size: 14px;
}

.delivery-print-topline span:first-child,
.delivery-print-meta span:last-child {
  flex: 1;
}

.delivery-print-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
  font-size: 13px;
}

.delivery-print-table th,
.delivery-print-table td {
  height: 30px;
  padding: 4px 6px;
  text-align: center;
  vertical-align: middle;
}

.delivery-print-table th:nth-child(1) { width: 44px; }
.delivery-print-table th:nth-child(2) { width: 30%; }
.delivery-print-table th:nth-child(3) { width: 25%; }
.delivery-print-table th:nth-child(4),
.delivery-print-table th:nth-child(5) { width: 82px; }

.delivery-print-copy,
.delivery-print-note {
  margin: 8px 0;
  font-size: 13px;
}

.delivery-print-date {
  margin-top: 8px;
  padding-left: 120px;
  font-size: 14px;
}

.print-meta {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-bottom: 12px;
}

.print-sheet table th,
.print-sheet table td {
  border: 1px solid #333;
}

.label-preview {
  width: 75mm;
  min-height: 50mm;
  border: 1px solid #333;
  padding: 4mm;
  background: #fff;
  color: #000;
}

.label-code {
  height: 28px;
  margin: 6px 0;
  background: repeating-linear-gradient(90deg, #000 0 2px, #fff 2px 4px, #000 4px 5px, #fff 5px 8px);
}

@media (max-width: 1100px) {
  .app-view { grid-template-columns: 190px minmax(0, 1fr); }
  .sidebar { width: 190px; }
  .app-view.sidebar-hidden .sidebar { transform: translateX(-190px); }
  .split { grid-template-columns: 1fr; }
  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 760px) {
  .topbar { grid-template-columns: auto 1fr; }
  .topbar-right { grid-column: 1 / -1; justify-content: flex-start; flex-wrap: wrap; }
  .layout-two,
  .form-grid,
  .form-grid.compact { grid-template-columns: 1fr; }
  .content { padding: 12px; }
}

@media print {
  body * { visibility: hidden; }
  #printArea,
  #printArea * { visibility: visible; }
  #printArea {
    position: fixed;
    inset: 0;
    background: #fff;
    padding: 0;
  }
}
